diff mbox

[FFmpeg-devel,v2,32/36] cbs_h264: Infer default VUI values if VUI parameters are not present

Message ID 20180607234331.32139-33-sw@jkqxz.net
State Accepted
Commit 1156b507f7df719bac1ed411314c82dcc1ecebc4
Headers show

Commit Message

Mark Thompson June 7, 2018, 11:43 p.m. UTC
---
 libavcodec/cbs_h264_syntax_template.c | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Comments

Xiang, Haihao June 15, 2018, 3:46 a.m. UTC | #1
On Fri, 2018-06-08 at 00:43 +0100, Mark Thompson wrote:
> ---

>  libavcodec/cbs_h264_syntax_template.c | 42

> +++++++++++++++++++++++++++++++++++

>  1 file changed, 42 insertions(+)

> 

> diff --git a/libavcodec/cbs_h264_syntax_template.c

> b/libavcodec/cbs_h264_syntax_template.c

> index f53c02467e..03f2a15b0b 100644

> --- a/libavcodec/cbs_h264_syntax_template.c

> +++ b/libavcodec/cbs_h264_syntax_template.c

> @@ -211,6 +211,46 @@ static int FUNC(vui_parameters)(CodedBitstreamContext

> *ctx, RWContext *rw,

>      return 0;

>  }

>  

> +static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,

> +                                        RWContext *rw, H264RawVUI *current,

> +                                        H264RawSPS *sps)

> +{

> +    infer(aspect_ratio_idc, 0);

> +

> +    infer(video_format,             5);

> +    infer(video_full_range_flag,    0);

> +    infer(colour_primaries,         2);

> +    infer(transfer_characteristics, 2);

> +    infer(matrix_coefficients,      2);

> +

> +    infer(chroma_sample_loc_type_top_field,    0);

> +    infer(chroma_sample_loc_type_bottom_field, 0);

> +

> +    infer(fixed_frame_rate_flag, 0);

> +    infer(low_delay_hrd_flag,    1);

> +

> +    infer(pic_struct_present_flag, 0);

> +

> +    infer(motion_vectors_over_pic_boundaries_flag, 1);

> +    infer(max_bytes_per_pic_denom, 2);

> +    infer(max_bits_per_mb_denom,   1);

> +    infer(log2_max_mv_length_horizontal, 15);

> +    infer(log2_max_mv_length_vertical,   15);


Both log2_max_mv_length_horizontal and log2_max_mv_length_vertical should be 16

> +

> +    if ((sps->profile_idc ==  44 || sps->profile_idc ==  86 ||

> +         sps->profile_idc == 100 || sps->profile_idc == 110 ||

> +         sps->profile_idc == 122 || sps->profile_idc == 244) &&

> +        sps->constraint_set3_flag) {

> +        infer(max_num_reorder_frames,  0);

> +        infer(max_dec_frame_buffering, 0);

> +    } else {

> +        infer(max_num_reorder_frames,  H264_MAX_DPB_FRAMES);

> +        infer(max_dec_frame_buffering, H264_MAX_DPB_FRAMES);

> +    }

> +

> +    return 0;

> +}

> +

>  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,

>                       H264RawSPS *current)

>  {

> @@ -315,6 +355,8 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext

> *rw,

>      flag(vui_parameters_present_flag);

>      if (current->vui_parameters_present_flag)

>          CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));

> +    else

> +        CHECK(FUNC(vui_parameters_default)(ctx, rw, &current->vui, current));

>  

>      CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));

>
Mark Thompson June 17, 2018, 2:29 p.m. UTC | #2
On 15/06/18 04:46, Xiang, Haihao wrote:
> On Fri, 2018-06-08 at 00:43 +0100, Mark Thompson wrote:
>> ---
>>  libavcodec/cbs_h264_syntax_template.c | 42
>> +++++++++++++++++++++++++++++++++++
>>  1 file changed, 42 insertions(+)
>>
>> diff --git a/libavcodec/cbs_h264_syntax_template.c
>> b/libavcodec/cbs_h264_syntax_template.c
>> index f53c02467e..03f2a15b0b 100644
>> --- a/libavcodec/cbs_h264_syntax_template.c
>> +++ b/libavcodec/cbs_h264_syntax_template.c
>> @@ -211,6 +211,46 @@ static int FUNC(vui_parameters)(CodedBitstreamContext
>> *ctx, RWContext *rw,
>>      return 0;
>>  }
>>  
>> +static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,
>> +                                        RWContext *rw, H264RawVUI *current,
>> +                                        H264RawSPS *sps)
>> +{
>> +    infer(aspect_ratio_idc, 0);
>> +
>> +    infer(video_format,             5);
>> +    infer(video_full_range_flag,    0);
>> +    infer(colour_primaries,         2);
>> +    infer(transfer_characteristics, 2);
>> +    infer(matrix_coefficients,      2);
>> +
>> +    infer(chroma_sample_loc_type_top_field,    0);
>> +    infer(chroma_sample_loc_type_bottom_field, 0);
>> +
>> +    infer(fixed_frame_rate_flag, 0);
>> +    infer(low_delay_hrd_flag,    1);
>> +
>> +    infer(pic_struct_present_flag, 0);
>> +
>> +    infer(motion_vectors_over_pic_boundaries_flag, 1);
>> +    infer(max_bytes_per_pic_denom, 2);
>> +    infer(max_bits_per_mb_denom,   1);
>> +    infer(log2_max_mv_length_horizontal, 15);
>> +    infer(log2_max_mv_length_vertical,   15);
> 
> Both log2_max_mv_length_horizontal and log2_max_mv_length_vertical should be 16

No - see previous mail.

>> +
>> +    if ((sps->profile_idc ==  44 || sps->profile_idc ==  86 ||
>> +         sps->profile_idc == 100 || sps->profile_idc == 110 ||
>> +         sps->profile_idc == 122 || sps->profile_idc == 244) &&
>> +        sps->constraint_set3_flag) {
>> +        infer(max_num_reorder_frames,  0);
>> +        infer(max_dec_frame_buffering, 0);
>> +    } else {
>> +        infer(max_num_reorder_frames,  H264_MAX_DPB_FRAMES);
>> +        infer(max_dec_frame_buffering, H264_MAX_DPB_FRAMES);
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>>  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
>>                       H264RawSPS *current)
>>  {
>> @@ -315,6 +355,8 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext
>> *rw,
>>      flag(vui_parameters_present_flag);
>>      if (current->vui_parameters_present_flag)
>>          CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));
>> +    else
>> +        CHECK(FUNC(vui_parameters_default)(ctx, rw, &current->vui, current));
>>  
>>      CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
>>
diff mbox

Patch

diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index f53c02467e..03f2a15b0b 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -211,6 +211,46 @@  static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
     return 0;
 }
 
+static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,
+                                        RWContext *rw, H264RawVUI *current,
+                                        H264RawSPS *sps)
+{
+    infer(aspect_ratio_idc, 0);
+
+    infer(video_format,             5);
+    infer(video_full_range_flag,    0);
+    infer(colour_primaries,         2);
+    infer(transfer_characteristics, 2);
+    infer(matrix_coefficients,      2);
+
+    infer(chroma_sample_loc_type_top_field,    0);
+    infer(chroma_sample_loc_type_bottom_field, 0);
+
+    infer(fixed_frame_rate_flag, 0);
+    infer(low_delay_hrd_flag,    1);
+
+    infer(pic_struct_present_flag, 0);
+
+    infer(motion_vectors_over_pic_boundaries_flag, 1);
+    infer(max_bytes_per_pic_denom, 2);
+    infer(max_bits_per_mb_denom,   1);
+    infer(log2_max_mv_length_horizontal, 15);
+    infer(log2_max_mv_length_vertical,   15);
+
+    if ((sps->profile_idc ==  44 || sps->profile_idc ==  86 ||
+         sps->profile_idc == 100 || sps->profile_idc == 110 ||
+         sps->profile_idc == 122 || sps->profile_idc == 244) &&
+        sps->constraint_set3_flag) {
+        infer(max_num_reorder_frames,  0);
+        infer(max_dec_frame_buffering, 0);
+    } else {
+        infer(max_num_reorder_frames,  H264_MAX_DPB_FRAMES);
+        infer(max_dec_frame_buffering, H264_MAX_DPB_FRAMES);
+    }
+
+    return 0;
+}
+
 static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
                      H264RawSPS *current)
 {
@@ -315,6 +355,8 @@  static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
     flag(vui_parameters_present_flag);
     if (current->vui_parameters_present_flag)
         CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));
+    else
+        CHECK(FUNC(vui_parameters_default)(ctx, rw, &current->vui, current));
 
     CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));