blob: adc8678a587622f005e982dbea8fff37bcd3ce00 (
plain)
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
|
/*! @file utilities.c
*
* @brief The utilities in this file are included to allow the codec to be tested.
*
* @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 "common.h"
/*!
@brief Check that the enabled parts are correct
*/
CODEC_ERROR CheckEnabledParts(ENABLED_PARTS *enabled_parts_ref)
{
ENABLED_PARTS enabled_parts = (*enabled_parts_ref);
// The elementary bitstream is always enabled
if ((enabled_parts & VC5_PART_MASK(VC5_PART_ELEMENTARY)) == 0) {
enabled_parts |= VC5_PART_MASK(VC5_PART_ELEMENTARY);
}
// The conformance specification is never enabled
enabled_parts &= ~((uint32_t)VC5_PART_MASK(VC5_PART_CONFORMANCE));
// Image formats must be enabled if subsampled color differences are enabled
if ((enabled_parts & VC5_PART_MASK(VC5_PART_COLOR_SAMPLING)) != 0) {
enabled_parts |= VC5_PART_MASK(VC5_PART_IMAGE_FORMATS);
}
// Check that the enabled parts were built at compile-time
//assert((enabled_parts & VC5_ENABLED_PARTS) == enabled_parts);
if (! ((enabled_parts & VC5_ENABLED_PARTS) == enabled_parts)) {
return CODEC_ERROR_ENABLED_PARTS;
}
// Return the correct enabled parts mask
*enabled_parts_ref = enabled_parts;
return CODEC_ERROR_OKAY;
}
/*!
@brief Verify that the enabled parts are correct
*/
CODEC_ERROR VerifyEnabledParts(ENABLED_PARTS enabled_parts)
{
// The elementary bitstream must always be enabled
if ((enabled_parts & VC5_PART_MASK(VC5_PART_ELEMENTARY)) == 0) {
return CODEC_ERROR_ENABLED_PARTS;
}
// The conformance specification must not be enabled
if ((enabled_parts & VC5_PART_MASK(VC5_PART_CONFORMANCE)) != 0) {
return CODEC_ERROR_ENABLED_PARTS;
}
// Image formats must be enabled if subsampled color differences are enabled
if ((enabled_parts & VC5_PART_MASK(VC5_PART_COLOR_SAMPLING)) != 0 &&
(enabled_parts & VC5_PART_MASK(VC5_PART_IMAGE_FORMATS)) == 0) {
return CODEC_ERROR_ENABLED_PARTS;
}
// All enabled parts must be compiled into this codec implementation
if ((enabled_parts & VC5_ENABLED_PARTS) != enabled_parts) {
return CODEC_ERROR_ENABLED_PARTS;
}
// This codec implementation supports the enabled parts of the VC-5 standard
return CODEC_ERROR_OKAY;
}
|