Commit 315cc8c0 authored by Mark Thompson's avatar Mark Thompson

cbs_h2645: Simplify representation of fixed values

parent d7786b66
...@@ -239,6 +239,11 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, ...@@ -239,6 +239,11 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name) #define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name) #define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
#define fixed(width, name, value) do { \
av_unused uint32_t fixed_value = value; \
xu(width, name, fixed_value, value, value); \
} while (0)
#define READ #define READ
#define READWRITE read #define READWRITE read
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw) static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw)
{ {
int err; int err;
av_unused int one = 1, zero = 0;
xu(1, rbsp_stop_one_bit, one, 1, 1); fixed(1, rbsp_stop_one_bit, 1);
while (byte_alignment(rw) != 0) while (byte_alignment(rw) != 0)
xu(1, rbsp_alignment_zero_bit, zero, 0, 0); fixed(1, rbsp_alignment_zero_bit, 0);
return 0; return 0;
} }
...@@ -740,9 +740,8 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -740,9 +740,8 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
break; break;
case H264_SEI_TYPE_FILLER_PAYLOAD: case H264_SEI_TYPE_FILLER_PAYLOAD:
{ {
av_unused int ff_byte = 0xff;
for (i = 0; i < current->payload_size; i++) for (i = 0; i < current->payload_size; i++)
xu(8, ff_byte, ff_byte, 0xff, 0xff); fixed(8, ff_byte, 0xff);
} }
break; break;
case H264_SEI_TYPE_USER_DATA_REGISTERED: case H264_SEI_TYPE_USER_DATA_REGISTERED:
...@@ -770,10 +769,9 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -770,10 +769,9 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
} }
if (byte_alignment(rw)) { if (byte_alignment(rw)) {
av_unused int one = 1, zero = 0; fixed(1, bit_equal_to_one, 1);
xu(1, bit_equal_to_one, one, 1, 1);
while (byte_alignment(rw)) while (byte_alignment(rw))
xu(1, bit_equal_to_zero, zero, 0, 0); fixed(1, bit_equal_to_zero, 0);
} }
#ifdef READ #ifdef READ
...@@ -810,14 +808,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -810,14 +808,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
uint32_t tmp; uint32_t tmp;
while (show_bits(rw, 8) == 0xff) { while (show_bits(rw, 8) == 0xff) {
xu(8, ff_byte, tmp, 0xff, 0xff); fixed(8, ff_byte, 0xff);
payload_type += 255; payload_type += 255;
} }
xu(8, last_payload_type_byte, tmp, 0, 254); xu(8, last_payload_type_byte, tmp, 0, 254);
payload_type += tmp; payload_type += tmp;
while (show_bits(rw, 8) == 0xff) { while (show_bits(rw, 8) == 0xff) {
xu(8, ff_byte, tmp, 0xff, 0xff); fixed(8, ff_byte, 0xff);
payload_size += 255; payload_size += 255;
} }
xu(8, last_payload_size_byte, tmp, 0, 254); xu(8, last_payload_size_byte, tmp, 0, 254);
...@@ -853,14 +851,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -853,14 +851,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
tmp = current->payload[k].payload_type; tmp = current->payload[k].payload_type;
while (tmp >= 255) { while (tmp >= 255) {
xu(8, ff_byte, 0xff, 0xff, 0xff); fixed(8, ff_byte, 0xff);
tmp -= 255; tmp -= 255;
} }
xu(8, last_payload_type_byte, tmp, 0, 254); xu(8, last_payload_type_byte, tmp, 0, 254);
tmp = current->payload[k].payload_size; tmp = current->payload[k].payload_size;
while (tmp >= 255) { while (tmp >= 255) {
xu(8, ff_byte, 0xff, 0xff, 0xff); fixed(8, ff_byte, 0xff);
tmp -= 255; tmp -= 255;
} }
xu(8, last_payload_size_byte, tmp, 0, 254); xu(8, last_payload_size_byte, tmp, 0, 254);
...@@ -1240,9 +1238,8 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -1240,9 +1238,8 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
} }
if (pps->entropy_coding_mode_flag) { if (pps->entropy_coding_mode_flag) {
av_unused int one = 1;
while (byte_alignment(rw)) while (byte_alignment(rw))
xu(1, cabac_alignment_one_bit, one, 1, 1); fixed(1, cabac_alignment_one_bit, 1);
} }
return 0; return 0;
...@@ -1251,7 +1248,6 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -1251,7 +1248,6 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
H264RawFiller *current) H264RawFiller *current)
{ {
av_unused int ff_byte = 0xff;
int err; int err;
HEADER("Filler Data"); HEADER("Filler Data");
...@@ -1261,14 +1257,14 @@ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -1261,14 +1257,14 @@ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
#ifdef READ #ifdef READ
while (show_bits(rw, 8) == 0xff) { while (show_bits(rw, 8) == 0xff) {
xu(8, ff_byte, ff_byte, 0xff, 0xff); fixed(8, ff_byte, 0xff);
++current->filler_size; ++current->filler_size;
} }
#else #else
{ {
uint32_t i; uint32_t i;
for (i = 0; i < current->filler_size; i++) for (i = 0; i < current->filler_size; i++)
xu(8, ff_byte, ff_byte, 0xff, 0xff); fixed(8, ff_byte, 0xff);
} }
#endif #endif
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw) static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw)
{ {
int err; int err;
av_unused int one = 1, zero = 0;
xu(1, rbsp_stop_one_bit, one, 1, 1); fixed(1, rbsp_stop_one_bit, 1);
while (byte_alignment(rw) != 0) while (byte_alignment(rw) != 0)
xu(1, rbsp_alignment_zero_bit, zero, 0, 0); fixed(1, rbsp_alignment_zero_bit, 0);
return 0; return 0;
} }
...@@ -50,10 +50,10 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -50,10 +50,10 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw) static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw)
{ {
int err; int err;
av_unused int one = 1, zero = 0;
xu(1, alignment_bit_equal_to_one, one, 1, 1); fixed(1, alignment_bit_equal_to_one, 1);
while (byte_alignment(rw) != 0) while (byte_alignment(rw) != 0)
xu(1, alignment_bit_equal_to_zero, zero, 0, 0); fixed(1, alignment_bit_equal_to_zero, 0);
return 0; return 0;
} }
...@@ -90,7 +90,6 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -90,7 +90,6 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
int profile_present_flag, int profile_present_flag,
int max_num_sub_layers_minus1) int max_num_sub_layers_minus1)
{ {
av_unused unsigned int zero = 0;
int err, i, j; int err, i, j;
if (profile_present_flag) { if (profile_present_flag) {
...@@ -125,15 +124,15 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -125,15 +124,15 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
if (profile_compatible(5) || profile_compatible(9) || if (profile_compatible(5) || profile_compatible(9) ||
profile_compatible(10)) { profile_compatible(10)) {
flag(general_max_14bit_constraint_flag); flag(general_max_14bit_constraint_flag);
xu(24, general_reserved_zero_33bits, zero, 0, 0); fixed(24, general_reserved_zero_33bits, 0);
xu(9, general_reserved_zero_33bits, zero, 0, 0); fixed( 9, general_reserved_zero_33bits, 0);
} else { } else {
xu(24, general_reserved_zero_34bits, zero, 0, 0); fixed(24, general_reserved_zero_34bits, 0);
xu(10, general_reserved_zero_34bits, zero, 0, 0); fixed(10, general_reserved_zero_34bits, 0);
} }
} else { } else {
xu(24, general_reserved_zero_43bits, zero, 0, 0); fixed(24, general_reserved_zero_43bits, 0);
xu(19, general_reserved_zero_43bits, zero, 0, 0); fixed(19, general_reserved_zero_43bits, 0);
} }
if (profile_compatible(1) || profile_compatible(2) || if (profile_compatible(1) || profile_compatible(2) ||
...@@ -141,7 +140,7 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -141,7 +140,7 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
profile_compatible(5) || profile_compatible(9)) { profile_compatible(5) || profile_compatible(9)) {
flag(general_inbld_flag); flag(general_inbld_flag);
} else { } else {
xu(1, general_reserved_zero_bit, zero, 0, 0); fixed(1, general_reserved_zero_bit, 0);
} }
#undef profile_compatible #undef profile_compatible
} }
...@@ -154,10 +153,8 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -154,10 +153,8 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
} }
if (max_num_sub_layers_minus1 > 0) { if (max_num_sub_layers_minus1 > 0) {
for (i = max_num_sub_layers_minus1; i < 8; i++) { for (i = max_num_sub_layers_minus1; i < 8; i++)
av_unused int zero = 0; fixed(2, reserved_zero_2bits, 0);
xu(2, reserved_zero_2bits, zero, 0, 0);
}
} }
for (i = 0; i < max_num_sub_layers_minus1; i++) { for (i = 0; i < max_num_sub_layers_minus1; i++) {
...@@ -386,10 +383,7 @@ static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw, ...@@ -386,10 +383,7 @@ static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
{ fixed(16, vps_reserved_0xffff_16bits, 0xffff);
av_unused uint16_t ffff = 0xffff;
xu(16, vps_reserved_0xffff_16bits, ffff, 0xffff, 0xffff);
}
CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level, CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,
1, current->vps_max_sub_layers_minus1)); 1, current->vps_max_sub_layers_minus1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment