1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/*! @file component.c
*
* @brief Code for parsing the inverse component transform and inverse component permutation.
*
* @version 1.0.0
*
* (C) Copyright 2018 GoPro Inc (http://gopro.com/).
*
* Licensed under either:
* - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
* - MIT license, http://opensource.org/licenses/MIT
* at your option.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "headers.h"
CODEC_ERROR ParseInverseComponentTransform(DECODER *decoder, BITSTREAM *stream, size_t chunk_size)
{
//CODEC_ERROR error = CODEC_ERROR_OKAY;
CODEC_STATE *codec = &decoder->codec;
int component_count = codec->channel_count;
int padding;
int i;
#if VC5_ENABLED_PART(VC5_PART_COLOR_SAMPLING)
if (IsPartEnabled(decoder->enabled_parts, VC5_PART_COLOR_SAMPLING))
{
// Recompute the number of components to account for color difference component subsampling
component_count = codec->pattern_width * codec->pattern_height + 2;
}
#endif
// Compute the padding (in bytes) from the end of the component transform to the end of the chunk payload
padding = (int)((chunk_size * sizeof(SEGMENT)) - ((component_count + 2) * component_count) * sizeof(uint8_t));
for (i = 0; i < component_count; i++)
{
int offset;
int scale;
int j;
for (j = 0; j < component_count; j++)
{
int matrix_index = i * component_count + j;
int matrix_value = GetBits(stream, 8);
//TODO: Need to save the value in the codec state
(void)matrix_index;
(void)matrix_value;
}
offset = GetBits(stream, 8);
scale = GetBits(stream, 8);
//TODO: Need to save the offset and scale in the codec state
(void)offset;
(void)scale;
}
// Skip the padding at the end of the chunk payload
GetBits(stream, 8 * padding);
// Should be at the end of the last segment in the chunk
assert(IsAlignedSegment(stream));
return CODEC_ERROR_OKAY;
}
CODEC_ERROR ParseInverseComponentPermutation(DECODER *decoder, BITSTREAM *stream, size_t chunk_size)
{
//CODEC_ERROR error = CODEC_ERROR_OKAY;
CODEC_STATE *codec = &decoder->codec;
int component_count = codec->channel_count;
int padding;
int i;
#if VC5_ENABLED_PART(VC5_PART_COLOR_SAMPLING)
if (IsPartEnabled(decoder->enabled_parts, VC5_PART_COLOR_SAMPLING))
{
// Recompute the number of components to account for color difference component subsampling
component_count = codec->pattern_width * codec->pattern_height + 2;
}
#endif
// Compute the padding (in bytes) from the end of the component transform to the end of the chunk payload
padding = (int)((chunk_size * sizeof(SEGMENT)) - component_count * sizeof(uint8_t));
for (i = 0; i < component_count; i++)
{
int value;
value = GetBits(stream, 8);
//TODO: Need to save the permutation index in yhe codec state
(void)value;
}
// Skip the padding at the end of the chunk payload
GetBits(stream, 8 * padding);
// Should be at the end of the last segment in the chunk
assert(IsAlignedSegment(stream));
return CODEC_ERROR_OKAY;
}
|