diff mbox

[FFmpeg-devel,v2,30/36] cbs_h264: Fix range and default value of max mv lengths

Message ID 20180607234331.32139-31-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson June 7, 2018, 11:43 p.m. UTC
The max and default values are 15, not 16.
---
 libavcodec/cbs_h264_syntax_template.c | 8 ++++----
 libavcodec/vaapi_encode_h264.c        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Xiang, Haihao June 15, 2018, 3:01 a.m. UTC | #1
On Fri, 2018-06-08 at 00:43 +0100, Mark Thompson wrote:
> The max and default values are 15, not 16.


I guessed you mixed both h264 and h265. The h264 doc i have specifies the range
for log2_max_mv_length_vertical/log2_max_mv_length_horizontal is [0, 16] and the
value of log2_max_mv_length_vertical/log2_max_mv_length_horizontal should be
inferred to 16 when log2_max_mv_length_vertical/log2_max_mv_length_horizontal is
not present.

> ---

>  libavcodec/cbs_h264_syntax_template.c | 8 ++++----

>  libavcodec/vaapi_encode_h264.c        | 4 ++--

>  2 files changed, 6 insertions(+), 6 deletions(-)

> 

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

> b/libavcodec/cbs_h264_syntax_template.c

> index 027b555db6..21edcb799e 100644

> --- a/libavcodec/cbs_h264_syntax_template.c

> +++ b/libavcodec/cbs_h264_syntax_template.c

> @@ -185,16 +185,16 @@ static int FUNC(vui_parameters)(CodedBitstreamContext

> *ctx, RWContext *rw,

>          flag(motion_vectors_over_pic_boundaries_flag);

>          ue(max_bytes_per_pic_denom, 0, 16);

>          ue(max_bits_per_mb_denom,   0, 16);

> -        ue(log2_max_mv_length_horizontal, 0, 16);

> -        ue(log2_max_mv_length_vertical,   0, 16);

> +        ue(log2_max_mv_length_horizontal, 0, 15);

> +        ue(log2_max_mv_length_vertical,   0, 15);

>          ue(max_num_reorder_frames,  0, H264_MAX_DPB_FRAMES);

>          ue(max_dec_frame_buffering, 0, H264_MAX_DPB_FRAMES);

>      } else {

>          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, 16);

> -        infer(log2_max_mv_length_vertical,   16);

> +        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 == 110 || sps->profile_idc == 110 ||

> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c

> index 4034053dc0..0d7780110c 100644

> --- a/libavcodec/vaapi_encode_h264.c

> +++ b/libavcodec/vaapi_encode_h264.c

> @@ -491,8 +491,8 @@ static int

> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)

>  

>      sps->vui.bitstream_restriction_flag    = 1;

>      sps->vui.motion_vectors_over_pic_boundaries_flag = 1;

> -    sps->vui.log2_max_mv_length_horizontal = 16;

> -    sps->vui.log2_max_mv_length_vertical   = 16;

> +    sps->vui.log2_max_mv_length_horizontal = 15;

> +    sps->vui.log2_max_mv_length_vertical   = 15;

>      sps->vui.max_num_reorder_frames        = (ctx->b_per_p > 0);

>      sps->vui.max_dec_frame_buffering       = sps->max_num_ref_frames;

>
Mark Thompson June 17, 2018, 2:27 p.m. UTC | #2
On 15/06/18 04:01, Xiang, Haihao wrote:
> On Fri, 2018-06-08 at 00:43 +0100, Mark Thompson wrote:
>> The max and default values are 15, not 16.
> 
> I guessed you mixed both h264 and h265. The h264 doc i have specifies the range
> for log2_max_mv_length_vertical/log2_max_mv_length_horizontal is [0, 16] and the
> value of log2_max_mv_length_vertical/log2_max_mv_length_horizontal should be
> inferred to 16 when log2_max_mv_length_vertical/log2_max_mv_length_horizontal is
> not present.

Try the 2016/10 version (or later).

I was initially thinking the previous 16 value was an error on my part, but Andreas Rheinhardt noted that it was 16 in older standards and therefore we need to continue to accept 16 as an input value.

>> ---
>>  libavcodec/cbs_h264_syntax_template.c | 8 ++++----
>>  libavcodec/vaapi_encode_h264.c        | 4 ++--
>>  2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h264_syntax_template.c
>> b/libavcodec/cbs_h264_syntax_template.c
>> index 027b555db6..21edcb799e 100644
>> --- a/libavcodec/cbs_h264_syntax_template.c
>> +++ b/libavcodec/cbs_h264_syntax_template.c
>> @@ -185,16 +185,16 @@ static int FUNC(vui_parameters)(CodedBitstreamContext
>> *ctx, RWContext *rw,
>>          flag(motion_vectors_over_pic_boundaries_flag);
>>          ue(max_bytes_per_pic_denom, 0, 16);
>>          ue(max_bits_per_mb_denom,   0, 16);
>> -        ue(log2_max_mv_length_horizontal, 0, 16);
>> -        ue(log2_max_mv_length_vertical,   0, 16);
>> +        ue(log2_max_mv_length_horizontal, 0, 15);
>> +        ue(log2_max_mv_length_vertical,   0, 15);

So, removed this change to the bounds but kept the new inferred values below.

>>          ue(max_num_reorder_frames,  0, H264_MAX_DPB_FRAMES);
>>          ue(max_dec_frame_buffering, 0, H264_MAX_DPB_FRAMES);
>>      } else {
>>          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, 16);
>> -        infer(log2_max_mv_length_vertical,   16);
>> +        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 == 110 || sps->profile_idc == 110 ||
>> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
>> index 4034053dc0..0d7780110c 100644
>> --- a/libavcodec/vaapi_encode_h264.c
>> +++ b/libavcodec/vaapi_encode_h264.c
>> @@ -491,8 +491,8 @@ static int
>> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
>>  
>>      sps->vui.bitstream_restriction_flag    = 1;
>>      sps->vui.motion_vectors_over_pic_boundaries_flag = 1;
>> -    sps->vui.log2_max_mv_length_horizontal = 16;
>> -    sps->vui.log2_max_mv_length_vertical   = 16;
>> +    sps->vui.log2_max_mv_length_horizontal = 15;
>> +    sps->vui.log2_max_mv_length_vertical   = 15;
>>      sps->vui.max_num_reorder_frames        = (ctx->b_per_p > 0);
>>      sps->vui.max_dec_frame_buffering       = sps->max_num_ref_frames;
>>  

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index 027b555db6..21edcb799e 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -185,16 +185,16 @@  static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
         flag(motion_vectors_over_pic_boundaries_flag);
         ue(max_bytes_per_pic_denom, 0, 16);
         ue(max_bits_per_mb_denom,   0, 16);
-        ue(log2_max_mv_length_horizontal, 0, 16);
-        ue(log2_max_mv_length_vertical,   0, 16);
+        ue(log2_max_mv_length_horizontal, 0, 15);
+        ue(log2_max_mv_length_vertical,   0, 15);
         ue(max_num_reorder_frames,  0, H264_MAX_DPB_FRAMES);
         ue(max_dec_frame_buffering, 0, H264_MAX_DPB_FRAMES);
     } else {
         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, 16);
-        infer(log2_max_mv_length_vertical,   16);
+        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 == 110 || sps->profile_idc == 110 ||
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 4034053dc0..0d7780110c 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -491,8 +491,8 @@  static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 
     sps->vui.bitstream_restriction_flag    = 1;
     sps->vui.motion_vectors_over_pic_boundaries_flag = 1;
-    sps->vui.log2_max_mv_length_horizontal = 16;
-    sps->vui.log2_max_mv_length_vertical   = 16;
+    sps->vui.log2_max_mv_length_horizontal = 15;
+    sps->vui.log2_max_mv_length_vertical   = 15;
     sps->vui.max_num_reorder_frames        = (ctx->b_per_p > 0);
     sps->vui.max_dec_frame_buffering       = sps->max_num_ref_frames;