[FFmpeg-devel,3/3] avcodec/cbs_h2645: rename macros to read and write fields with custom range of values

Submitted by James Almer on April 17, 2019, 2:56 a.m.

Details

Message ID 20190417025635.9700-3-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer April 17, 2019, 2:56 a.m.
These are more in line with the new ones introduced in the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
---
No more i() macro :p

Figured I'd leave all the byte and checksum fields using the custom range
macro, to have the explicit hex values visible. That's why they were not
changed in the first patch.

 libavcodec/cbs_h2645.c                |   8 +-
 libavcodec/cbs_h264_syntax_template.c |  52 ++++++-------
 libavcodec/cbs_h265_syntax_template.c | 106 +++++++++++++-------------
 3 files changed, 83 insertions(+), 83 deletions(-)

Comments

James Almer April 18, 2019, 1:20 a.m.
On 4/16/2019 11:56 PM, James Almer wrote:
> @@ -164,9 +164,9 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
>  
>      for (i = 0; i < max_num_sub_layers_minus1; i++) {
>          if (current->sub_layer_profile_present_flag[i]) {
> -            us(2, sub_layer_profile_space[i], 0, 0, 1, i);
> +            ucs(2, sub_layer_profile_space[i], 0, 0, 1, i);
>              flags(sub_layer_tier_flag[i],           1, i);
> -            us(5, sub_layer_profile_idc[i], 0, 31,  1, i);
> +            ucs(5, sub_layer_profile_idc[i], 0, 31,  1, i);
>  
>              for (j = 0; j < 32; j++)
>                  flags(sub_layer_profile_compatibility_flag[i][j], 2, i, j);
> @@ -220,7 +220,7 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
>  #undef profile_compatible
>          }
>          if (current->sub_layer_level_present_flag[i])
> -            us(8, sub_layer_level_idc[i], 0, 255, 1, i);
> +            ucs(8, sub_layer_level_idc[i], 0, 255, 1, i);

The last two should have been changed to ubs() in the first patch instead.

Fixed locally.
Mark Thompson April 28, 2019, 11:19 p.m.
On 17/04/2019 03:56, James Almer wrote:
> These are more in line with the new ones introduced in the previous commit.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> No more i() macro :p
> 
> Figured I'd leave all the byte and checksum fields using the custom range
> macro, to have the explicit hex values visible. That's why they were not
> changed in the first patch.
> 
>  libavcodec/cbs_h2645.c                |   8 +-
>  libavcodec/cbs_h264_syntax_template.c |  52 ++++++-------
>  libavcodec/cbs_h265_syntax_template.c | 106 +++++++++++++-------------
>  3 files changed, 83 insertions(+), 83 deletions(-)
> 
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 319202fc48..5623fa705e 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -250,21 +250,21 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
>  
>  #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
>  
> -#define u(width, name, range_min, range_max) \
> +#define uc(width, name, range_min, range_max) \
>          xu(width, name, current->name, range_min, range_max, 0)
>  #define ub(width, name) \
>          xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0)
>  #define flag(name) ub(1, name)
>  #define ue(name, range_min, range_max) \
>          xue(name, current->name, range_min, range_max, 0)
> -#define i(width, name, range_min, range_max) \
> +#define ic(width, name, range_min, range_max) \
>          xi(width, name, current->name, range_min, range_max, 0)
>  #define ib(width, name) \
>          xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0)
>  #define se(name, range_min, range_max) \
>          xse(name, current->name, range_min, range_max, 0)
>  
> -#define us(width, name, range_min, range_max, subs, ...) \
> +#define ucs(width, name, range_min, range_max, subs, ...) \
>          xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
>  #define ubs(width, name, subs, ...) \
>          xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
> @@ -272,7 +272,7 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
>          xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
>  #define ues(name, range_min, range_max, subs, ...) \
>          xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
> -#define is(width, name, range_min, range_max, subs, ...) \
> +#define ics(width, name, range_min, range_max, subs, ...) \
>          xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
>  #define ibs(width, name, subs, ...) \
>          xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__)

Not sure I'm convinced by this one - the existing flag/u/ue/se set is really very nice in matching the standard.  If anything, it makes me think of going the other way in the AV1 code, though there are fewer limited values there so the bare f() case is not so common.

Thanks,

- Mark
James Almer April 28, 2019, 11:35 p.m.
On 4/28/2019 8:19 PM, Mark Thompson wrote:
> On 17/04/2019 03:56, James Almer wrote:
>> These are more in line with the new ones introduced in the previous commit.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> No more i() macro :p
>>
>> Figured I'd leave all the byte and checksum fields using the custom range
>> macro, to have the explicit hex values visible. That's why they were not
>> changed in the first patch.
>>
>>  libavcodec/cbs_h2645.c                |   8 +-
>>  libavcodec/cbs_h264_syntax_template.c |  52 ++++++-------
>>  libavcodec/cbs_h265_syntax_template.c | 106 +++++++++++++-------------
>>  3 files changed, 83 insertions(+), 83 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
>> index 319202fc48..5623fa705e 100644
>> --- a/libavcodec/cbs_h2645.c
>> +++ b/libavcodec/cbs_h2645.c
>> @@ -250,21 +250,21 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
>>  
>>  #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
>>  
>> -#define u(width, name, range_min, range_max) \
>> +#define uc(width, name, range_min, range_max) \
>>          xu(width, name, current->name, range_min, range_max, 0)
>>  #define ub(width, name) \
>>          xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0)
>>  #define flag(name) ub(1, name)
>>  #define ue(name, range_min, range_max) \
>>          xue(name, current->name, range_min, range_max, 0)
>> -#define i(width, name, range_min, range_max) \
>> +#define ic(width, name, range_min, range_max) \
>>          xi(width, name, current->name, range_min, range_max, 0)
>>  #define ib(width, name) \
>>          xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0)
>>  #define se(name, range_min, range_max) \
>>          xse(name, current->name, range_min, range_max, 0)
>>  
>> -#define us(width, name, range_min, range_max, subs, ...) \
>> +#define ucs(width, name, range_min, range_max, subs, ...) \
>>          xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
>>  #define ubs(width, name, subs, ...) \
>>          xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
>> @@ -272,7 +272,7 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
>>          xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
>>  #define ues(name, range_min, range_max, subs, ...) \
>>          xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
>> -#define is(width, name, range_min, range_max, subs, ...) \
>> +#define ics(width, name, range_min, range_max, subs, ...) \
>>          xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
>>  #define ibs(width, name, subs, ...) \
>>          xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__)
> 
> Not sure I'm convinced by this one - the existing flag/u/ue/se set is really very nice in matching the standard.  If anything, it makes me think of going the other way in the AV1 code, though there are fewer limited values there so the bare f() case is not so common.
> 
> Thanks,
> 
> - Mark

I don't mind dropping this patch. You're right that as is it matches the
standard.

Patch hide | download patch | download mbox

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 319202fc48..5623fa705e 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -250,21 +250,21 @@  static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
 
 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
 
-#define u(width, name, range_min, range_max) \
+#define uc(width, name, range_min, range_max) \
         xu(width, name, current->name, range_min, range_max, 0)
 #define ub(width, name) \
         xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0)
 #define flag(name) ub(1, name)
 #define ue(name, range_min, range_max) \
         xue(name, current->name, range_min, range_max, 0)
-#define i(width, name, range_min, range_max) \
+#define ic(width, name, range_min, range_max) \
         xi(width, name, current->name, range_min, range_max, 0)
 #define ib(width, name) \
         xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0)
 #define se(name, range_min, range_max) \
         xse(name, current->name, range_min, range_max, 0)
 
-#define us(width, name, range_min, range_max, subs, ...) \
+#define ucs(width, name, range_min, range_max, subs, ...) \
         xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
 #define ubs(width, name, subs, ...) \
         xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
@@ -272,7 +272,7 @@  static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
         xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
 #define ues(name, range_min, range_max, subs, ...) \
         xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
-#define is(width, name, range_min, range_max, subs, ...) \
+#define ics(width, name, range_min, range_max, subs, ...) \
         xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
 #define ibs(width, name, subs, ...) \
         xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__)
diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index 95fc6d7194..898e426cff 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -157,8 +157,8 @@  static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
 
     flag(timing_info_present_flag);
     if (current->timing_info_present_flag) {
-        u(32, num_units_in_tick, 1, UINT32_MAX);
-        u(32, time_scale,        1, UINT32_MAX);
+        uc(32, num_units_in_tick, 1, UINT32_MAX);
+        uc(32, time_scale,        1, UINT32_MAX);
         flag(fixed_frame_rate_flag);
     } else {
         infer(fixed_frame_rate_flag, 0);
@@ -272,7 +272,7 @@  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
     flag(constraint_set4_flag);
     flag(constraint_set5_flag);
 
-    u(2, reserved_zero_2bits,  0, 0);
+    uc(2, reserved_zero_2bits,  0, 0);
 
     ub(8, level_idc);
 
@@ -453,7 +453,7 @@  static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw,
             allocate(current->slice_group_id,
                      current->pic_size_in_map_units_minus1 + 1);
             for (i = 0; i <= current->pic_size_in_map_units_minus1; i++)
-                us(av_log2(2 * current->num_slice_groups_minus1 + 1),
+                ucs(av_log2(2 * current->num_slice_groups_minus1 + 1),
                    slice_group_id[i], 0, current->num_slice_groups_minus1, 1, i);
         }
     }
@@ -462,7 +462,7 @@  static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw,
     ue(num_ref_idx_l1_default_active_minus1, 0, 31);
 
     flag(weighted_pred_flag);
-    u(2, weighted_bipred_idc, 0, 2);
+    uc(2, weighted_bipred_idc, 0, 2);
 
     se(pic_init_qp_minus26, -26 - 6 * sps->bit_depth_luma_minus8, +25);
     se(pic_init_qs_minus26, -26, +25);
@@ -559,27 +559,27 @@  static int FUNC(sei_pic_timestamp)(CodedBitstreamContext *ctx, RWContext *rw,
     uint8_t time_offset_length;
     int err;
 
-    u(2, ct_type, 0, 2);
+    uc(2, ct_type, 0, 2);
     flag(nuit_field_based_flag);
-    u(5, counting_type, 0, 6);
+    uc(5, counting_type, 0, 6);
     flag(full_timestamp_flag);
     flag(discontinuity_flag);
     flag(cnt_dropped_flag);
     ub(8, n_frames);
     if (current->full_timestamp_flag) {
-            u(6, seconds_value, 0, 59);
-            u(6, minutes_value, 0, 59);
-            u(5, hours_value,   0, 23);
+            uc(6, seconds_value, 0, 59);
+            uc(6, minutes_value, 0, 59);
+            uc(5, hours_value,   0, 23);
     } else {
         flag(seconds_flag);
         if (current->seconds_flag) {
-            u(6, seconds_value, 0, 59);
+            uc(6, seconds_value, 0, 59);
             flag(minutes_flag);
             if (current->minutes_flag) {
-                u(6, minutes_value, 0, 59);
+                uc(6, minutes_value, 0, 59);
                 flag(hours_flag);
                 if (current->hours_flag)
-                    u(5, hours_value, 0, 23);
+                    uc(5, hours_value, 0, 23);
             }
         }
     }
@@ -655,7 +655,7 @@  static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw,
         };
         int i;
 
-        u(4, pic_struct, 0, 8);
+        uc(4, pic_struct, 0, 8);
         if (current->pic_struct > 8)
             return AVERROR_INVALIDDATA;
 
@@ -704,11 +704,11 @@  static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext
 
     HEADER("User Data Registered ITU-T T.35");
 
-    u(8, itu_t_t35_country_code, 0x00, 0xff);
+    uc(8, itu_t_t35_country_code, 0x00, 0xff);
     if (current->itu_t_t35_country_code != 0xff)
         i = 1;
     else {
-        u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
+        uc(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
         i = 2;
     }
 
@@ -750,7 +750,7 @@  static int FUNC(sei_user_data_unregistered)(CodedBitstreamContext *ctx, RWContex
 #endif
 
     for (i = 0; i < 16; i++)
-        us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
+        ucs(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
 
     allocate(current->data, current->data_length);
 
@@ -770,7 +770,7 @@  static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw,
     ue(recovery_frame_cnt, 0, 65535);
     flag(exact_match_flag);
     flag(broken_link_flag);
-    u(2, changing_slice_group_idc, 0, 2);
+    uc(2, changing_slice_group_idc, 0, 2);
 
     return 0;
 }
@@ -802,15 +802,15 @@  static int FUNC(sei_mastering_display_colour_volume)(CodedBitstreamContext *ctx,
     HEADER("Mastering Display Colour Volume");
 
     for (c = 0; c < 3; c++) {
-        us(16, display_primaries_x[c], 0, 50000, 1, c);
-        us(16, display_primaries_y[c], 0, 50000, 1, c);
+        ucs(16, display_primaries_x[c], 0, 50000, 1, c);
+        ucs(16, display_primaries_y[c], 0, 50000, 1, c);
     }
 
-    u(16, white_point_x, 0, 50000);
-    u(16, white_point_y, 0, 50000);
+    uc(16, white_point_x, 0, 50000);
+    uc(16, white_point_y, 0, 50000);
 
-    u(32, max_display_mastering_luminance, 1, MAX_UINT_BITS(32));
-    u(32, min_display_mastering_luminance, 0, current->max_display_mastering_luminance - 1);
+    uc(32, max_display_mastering_luminance, 1, MAX_UINT_BITS(32));
+    uc(32, min_display_mastering_luminance, 0, current->max_display_mastering_luminance - 1);
 
     return 0;
 }
@@ -1226,7 +1226,7 @@  static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
     h264->active_sps = sps;
 
     if (sps->separate_colour_plane_flag)
-        u(2, colour_plane_id, 0, 2);
+        uc(2, colour_plane_id, 0, 2);
 
     ub(sps->log2_max_frame_num_minus4 + 4, frame_num);
 
@@ -1347,7 +1347,7 @@  static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
               (pps->slice_group_change_rate_minus1 + 1);
         bits = av_log2(2 * max - 1);
 
-        u(bits, slice_group_change_cycle, 0, max);
+        uc(bits, slice_group_change_cycle, 0, max);
     }
 
     if (pps->entropy_coding_mode_flag) {
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index 9000bbc307..187997e885 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -36,13 +36,13 @@  static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, RWContext *rw,
     fixed(1, forbidden_zero_bit, 0);
 
     if (expected_nal_unit_type >= 0)
-        u(6, nal_unit_type, expected_nal_unit_type,
-                            expected_nal_unit_type);
+        uc(6, nal_unit_type, expected_nal_unit_type,
+                             expected_nal_unit_type);
     else
         ub(6, nal_unit_type);
 
-    u(6, nuh_layer_id,          0, 62);
-    u(3, nuh_temporal_id_plus1, 1,  7);
+    uc(6, nuh_layer_id,          0, 62);
+    uc(3, nuh_temporal_id_plus1, 1,  7);
 
     return 0;
 }
@@ -93,7 +93,7 @@  static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
     int err, i, j;
 
     if (profile_present_flag) {
-        u(2, general_profile_space, 0, 0);
+        uc(2, general_profile_space, 0, 0);
         flag(general_tier_flag);
         ub(5, general_profile_idc);
 
@@ -164,9 +164,9 @@  static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
 
     for (i = 0; i < max_num_sub_layers_minus1; i++) {
         if (current->sub_layer_profile_present_flag[i]) {
-            us(2, sub_layer_profile_space[i], 0, 0, 1, i);
+            ucs(2, sub_layer_profile_space[i], 0, 0, 1, i);
             flags(sub_layer_tier_flag[i],           1, i);
-            us(5, sub_layer_profile_idc[i], 0, 31,  1, i);
+            ucs(5, sub_layer_profile_idc[i], 0, 31,  1, i);
 
             for (j = 0; j < 32; j++)
                 flags(sub_layer_profile_compatibility_flag[i][j], 2, i, j);
@@ -220,7 +220,7 @@  static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
 #undef profile_compatible
         }
         if (current->sub_layer_level_present_flag[i])
-            us(8, sub_layer_level_idc[i], 0, 255, 1, i);
+            ucs(8, sub_layer_level_idc[i], 0, 255, 1, i);
     }
 
     return 0;
@@ -381,8 +381,8 @@  static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
 
     flag(vui_timing_info_present_flag);
     if (current->vui_timing_info_present_flag) {
-        u(32, vui_num_units_in_tick, 1, UINT32_MAX);
-        u(32, vui_time_scale,        1, UINT32_MAX);
+        uc(32, vui_num_units_in_tick, 1, UINT32_MAX);
+        uc(32, vui_time_scale,        1, UINT32_MAX);
         flag(vui_poc_proportional_to_timing_flag);
         if (current->vui_poc_proportional_to_timing_flag)
             ue(vui_num_ticks_poc_diff_one_minus1, 0, UINT32_MAX - 1);
@@ -430,8 +430,8 @@  static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
 
     flag(vps_base_layer_internal_flag);
     flag(vps_base_layer_available_flag);
-    u(6, vps_max_layers_minus1,     0, HEVC_MAX_LAYERS - 1);
-    u(3, vps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
+    uc(6, vps_max_layers_minus1,     0, HEVC_MAX_LAYERS - 1);
+    uc(3, vps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
     flag(vps_temporal_id_nesting_flag);
 
     if (current->vps_max_sub_layers_minus1 == 0 &&
@@ -469,7 +469,7 @@  static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
         }
     }
 
-    u(6, vps_max_layer_id,        0, HEVC_MAX_LAYERS - 1);
+    uc(6, vps_max_layer_id,       0, HEVC_MAX_LAYERS - 1);
     ue(vps_num_layer_sets_minus1, 0, HEVC_MAX_LAYER_SETS - 1);
     for (i = 1; i <= current->vps_num_layer_sets_minus1; i++) {
         for (j = 0; j <= current->vps_max_layer_id; j++)
@@ -480,8 +480,8 @@  static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
 
     flag(vps_timing_info_present_flag);
     if (current->vps_timing_info_present_flag) {
-        u(32, vps_num_units_in_tick, 1, UINT32_MAX);
-        u(32, vps_time_scale,        1, UINT32_MAX);
+        uc(32, vps_num_units_in_tick, 1, UINT32_MAX);
+        uc(32, vps_time_scale,        1, UINT32_MAX);
         flag(vps_poc_proportional_to_timing_flag);
         if (current->vps_poc_proportional_to_timing_flag)
             ue(vps_num_ticks_poc_diff_one_minus1, 0, UINT32_MAX - 1);
@@ -728,7 +728,7 @@  static int FUNC(sps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw,
         }
     }
 
-    u(2, motion_vector_resolution_control_idc, 0, 2);
+    uc(2, motion_vector_resolution_control_idc, 0, 2);
     flag(intra_boundary_filtering_disable_flag);
 
     return 0;
@@ -750,7 +750,7 @@  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
     ub(4, sps_video_parameter_set_id);
     h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];
 
-    u(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
+    uc(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
     flag(sps_temporal_id_nesting_flag);
     if (vps) {
         if (vps->vps_max_sub_layers_minus1 > current->sps_max_sub_layers_minus1) {
@@ -865,9 +865,9 @@  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
 
     flag(pcm_enabled_flag);
     if (current->pcm_enabled_flag) {
-        u(4, pcm_sample_bit_depth_luma_minus1,
+        uc(4, pcm_sample_bit_depth_luma_minus1,
           0, current->bit_depth_luma_minus8 + 8 - 1);
-        u(4, pcm_sample_bit_depth_chroma_minus1,
+        uc(4, pcm_sample_bit_depth_chroma_minus1,
           0, current->bit_depth_chroma_minus8 + 8 - 1);
 
         ue(log2_min_pcm_luma_coding_block_size_minus3,
@@ -1124,7 +1124,7 @@  static int FUNC(aud)(CodedBitstreamContext *ctx, RWContext *rw,
 
     CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_AUD));
 
-    u(3, pic_type, 0, 2);
+    uc(3, pic_type, 0, 2);
 
     CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
 
@@ -1143,14 +1143,14 @@  static int FUNC(ref_pic_lists_modification)(CodedBitstreamContext *ctx, RWContex
     flag(ref_pic_list_modification_flag_l0);
     if (current->ref_pic_list_modification_flag_l0) {
         for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++)
-            us(entry_size, list_entry_l0[i], 0, num_pic_total_curr - 1, 1, i);
+            ucs(entry_size, list_entry_l0[i], 0, num_pic_total_curr - 1, 1, i);
     }
 
     if (current->slice_type == HEVC_SLICE_B) {
         flag(ref_pic_list_modification_flag_l1);
         if (current->ref_pic_list_modification_flag_l1) {
             for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++)
-                us(entry_size, list_entry_l1[i], 0, num_pic_total_curr - 1, 1, i);
+                ucs(entry_size, list_entry_l1[i], 0, num_pic_total_curr - 1, 1, i);
         }
     }
 
@@ -1311,7 +1311,7 @@  static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
             flag(dependent_slice_segment_flag);
         else
             infer(dependent_slice_segment_flag, 0);
-        u(address_size, slice_segment_address, 0, pic_size_in_ctbs_y - 1);
+        uc(address_size, slice_segment_address, 0, pic_size_in_ctbs_y - 1);
     } else {
         infer(dependent_slice_segment_flag, 0);
     }
@@ -1326,7 +1326,7 @@  static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
             flag(pic_output_flag);
 
         if (sps->separate_colour_plane_flag)
-            u(2, colour_plane_id, 0, 2);
+            uc(2, colour_plane_id, 0, 2);
 
         if (current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_W_RADL &&
             current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_N_LP) {
@@ -1341,7 +1341,7 @@  static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
                 rps = &current->short_term_ref_pic_set;
             } else if (sps->num_short_term_ref_pic_sets > 1) {
                 unsigned int idx_size = av_log2(sps->num_short_term_ref_pic_sets - 1) + 1;
-                u(idx_size, short_term_ref_pic_set_idx,
+                uc(idx_size, short_term_ref_pic_set_idx,
                   0, sps->num_short_term_ref_pic_sets - 1);
                 rps = &sps->st_ref_pic_set[current->short_term_ref_pic_set_idx];
             } else {
@@ -1373,7 +1373,7 @@  static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
                                 current->num_long_term_pics; i++) {
                     if (i < current->num_long_term_sps) {
                         if (sps->num_long_term_ref_pics_sps > 1)
-                            us(idx_size, lt_idx_sps[i],
+                            ucs(idx_size, lt_idx_sps[i],
                                0, sps->num_long_term_ref_pics_sps - 1, 1, i);
                         if (sps->used_by_curr_pic_lt_sps_flag[current->lt_idx_sps[i]])
                             ++num_pic_total_curr;
@@ -1550,7 +1550,7 @@  static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
     if (pps->slice_segment_header_extension_present_flag) {
         ue(slice_segment_header_extension_length, 0, 256);
         for (i = 0; i < current->slice_segment_header_extension_length; i++)
-            us(8, slice_segment_header_extension_data_byte[i], 0x00, 0xff, 1, i);
+            ucs(8, slice_segment_header_extension_data_byte[i], 0x00, 0xff, 1, i);
     }
 
     CHECK(FUNC(byte_alignment)(ctx, rw));
@@ -1686,10 +1686,10 @@  static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw,
         sps->profile_tier_level.general_progressive_source_flag;
 
     if (sps->vui.frame_field_info_present_flag) {
-        u(4, pic_struct, 0, 12);
-        u(2, source_scan_type,
-          expected_source_scan_type >= 0 ? expected_source_scan_type : 0,
-          expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
+        uc(4, pic_struct, 0, 12);
+        uc(2, source_scan_type,
+           expected_source_scan_type >= 0 ? expected_source_scan_type : 0,
+           expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
         flag(duplicate_flag);
     } else {
         infer(pic_struct, 0);
@@ -1773,11 +1773,11 @@  static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext
 
     HEADER("User Data Registered ITU-T T.35");
 
-    u(8, itu_t_t35_country_code, 0x00, 0xff);
+    uc(8, itu_t_t35_country_code, 0x00, 0xff);
     if (current->itu_t_t35_country_code != 0xff)
         i = 1;
     else {
-        u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
+        uc(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
         i = 2;
     }
 
@@ -1819,7 +1819,7 @@  static int FUNC(sei_user_data_unregistered)(CodedBitstreamContext *ctx, RWContex
 #endif
 
     for (i = 0; i < 16; i++)
-        us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
+        ucs(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
 
     allocate(current->data, current->data_length);
 
@@ -1871,7 +1871,7 @@  static int FUNC(sei_active_parameter_sets)(CodedBitstreamContext *ctx, RWContext
 
     HEADER("Active Parameter Sets");
 
-    u(4, active_video_parameter_set_id, 0, HEVC_MAX_VPS_COUNT);
+    uc(4, active_video_parameter_set_id, 0, HEVC_MAX_VPS_COUNT);
     vps = h265->vps[current->active_video_parameter_set_id];
     if (!vps) {
         av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available for active "
@@ -1913,16 +1913,16 @@  static int FUNC(sei_decoded_picture_hash)(CodedBitstreamContext *ctx, RWContext
         return AVERROR_INVALIDDATA;
     }
 
-    u(8, hash_type, 0, 2);
+    uc(8, hash_type, 0, 2);
 
     for (c = 0; c < (sps->chroma_format_idc == 0 ? 1 : 3); c++) {
         if (current->hash_type == 0) {
             for (i = 0; i < 16; i++)
-                us(8, picture_md5[c][i], 0x00, 0xff, 2, c, i);
+                ucs(8, picture_md5[c][i], 0x00, 0xff, 2, c, i);
         } else if (current->hash_type == 1) {
-            us(16, picture_crc[c], 0x0000, 0xffff, 1, c);
+            ucs(16, picture_crc[c], 0x0000, 0xffff, 1, c);
         } else if (current->hash_type == 2) {
-            us(32, picture_checksum[c], 0x00000000, 0xffffffff, 1, c);
+            ucs(32, picture_checksum[c], 0x00000000, 0xffffffff, 1, c);
         }
     }
 
@@ -1936,14 +1936,14 @@  static int FUNC(sei_time_code)(CodedBitstreamContext *ctx, RWContext *rw,
 
     HEADER("Time Code");
 
-    u(2, num_clock_ts, 1, 3);
+    uc(2, num_clock_ts, 1, 3);
 
     for (i = 0; i < current->num_clock_ts; i++) {
         flags(clock_timestamp_flag[i],   1, i);
 
         if (current->clock_timestamp_flag[i]) {
             flags(units_field_based_flag[i], 1, i);
-            us(5, counting_type[i], 0, 6,    1, i);
+            ucs(5, counting_type[i], 0, 6,   1, i);
             flags(full_timestamp_flag[i],    1, i);
             flags(discontinuity_flag[i],     1, i);
             flags(cnt_dropped_flag[i],       1, i);
@@ -1951,19 +1951,19 @@  static int FUNC(sei_time_code)(CodedBitstreamContext *ctx, RWContext *rw,
             ubs(9, n_frames[i], 1, i);
 
             if (current->full_timestamp_flag[i]) {
-                us(6, seconds_value[i], 0, 59, 1, i);
-                us(6, minutes_value[i], 0, 59, 1, i);
-                us(5, hours_value[i],   0, 23, 1, i);
+                ucs(6, seconds_value[i], 0, 59, 1, i);
+                ucs(6, minutes_value[i], 0, 59, 1, i);
+                ucs(5, hours_value[i],   0, 23, 1, i);
             } else {
                 flags(seconds_flag[i], 1, i);
                 if (current->seconds_flag[i]) {
-                    us(6, seconds_value[i], 0, 59, 1, i);
+                    ucs(6, seconds_value[i], 0, 59, 1, i);
                     flags(minutes_flag[i], 1, i);
                     if (current->minutes_flag[i]) {
-                        us(6, minutes_value[i], 0, 59, 1, i);
+                        ucs(6, minutes_value[i], 0, 59, 1, i);
                         flags(hours_flag[i], 1, i);
                         if (current->hours_flag[i])
-                            us(5, hours_value[i], 0, 23, 1, i);
+                            ucs(5, hours_value[i], 0, 23, 1, i);
                     }
                 }
             }
@@ -1987,16 +1987,16 @@  static int FUNC(sei_mastering_display)(CodedBitstreamContext *ctx, RWContext *rw
     HEADER("Mastering Display Colour Volume");
 
     for (c = 0; c < 3; c++) {
-        us(16, display_primaries_x[c], 0, 50000, 1, c);
-        us(16, display_primaries_y[c], 0, 50000, 1, c);
+        ucs(16, display_primaries_x[c], 0, 50000, 1, c);
+        ucs(16, display_primaries_y[c], 0, 50000, 1, c);
     }
 
-    u(16, white_point_x, 0, 50000);
-    u(16, white_point_y, 0, 50000);
+    uc(16, white_point_x, 0, 50000);
+    uc(16, white_point_y, 0, 50000);
 
-    u(32, max_display_mastering_luminance,
+    uc(32, max_display_mastering_luminance,
       1, MAX_UINT_BITS(32));
-    u(32, min_display_mastering_luminance,
+    uc(32, min_display_mastering_luminance,
       0, current->max_display_mastering_luminance - 1);
 
     return 0;