[FFmpeg-devel] avcodec/vc1_pred: properly clip interlaced motion vectors

Submitted by Paul B Mahol on April 21, 2018, 8:22 a.m.

Details

Message ID 20180421082252.4186-1-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol April 21, 2018, 8:22 a.m.
Fixes #2557.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/vc1_pred.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos April 21, 2018, 4:34 p.m.
2018-04-21 10:22 GMT+02:00, Paul B Mahol <onemda@gmail.com>:
> Fixes #2557.
>
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/vc1_pred.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
> index 54712f6b7a..9f42a930fe 100644
> --- a/libavcodec/vc1_pred.c
> +++ b/libavcodec/vc1_pred.c
> @@ -98,9 +98,9 @@ static av_always_inline int scaleforsame_y(VC1Context *v,
> int i, int n /* MV */,
>      }
>
>      if (v->cur_field_type && !v->ref_field_type[dir])
> -        return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2);
> +        return av_clip(scaledvalue, -v->range_y / 2 - 1, v->range_y / 2);
>      else
> -        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
> +        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 + 1);

Makes the affected frames bit-exact, so lgtm.

Thank you, Carl Eugen
Paul B Mahol April 21, 2018, 4:43 p.m.
On 4/21/18, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2018-04-21 10:22 GMT+02:00, Paul B Mahol <onemda@gmail.com>:
>> Fixes #2557.
>>
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavcodec/vc1_pred.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
>> index 54712f6b7a..9f42a930fe 100644
>> --- a/libavcodec/vc1_pred.c
>> +++ b/libavcodec/vc1_pred.c
>> @@ -98,9 +98,9 @@ static av_always_inline int scaleforsame_y(VC1Context
>> *v,
>> int i, int n /* MV */,
>>      }
>>
>>      if (v->cur_field_type && !v->ref_field_type[dir])
>> -        return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2);
>> +        return av_clip(scaledvalue, -v->range_y / 2 - 1, v->range_y / 2);
>>      else
>> -        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
>> +        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 + 1);
>
> Makes the affected frames bit-exact, so lgtm.

This probably needs no + 1 and - 1 part, so will commit without it.

Patch hide | download patch | download mbox

diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
index 54712f6b7a..9f42a930fe 100644
--- a/libavcodec/vc1_pred.c
+++ b/libavcodec/vc1_pred.c
@@ -98,9 +98,9 @@  static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */,
     }
 
     if (v->cur_field_type && !v->ref_field_type[dir])
-        return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2);
+        return av_clip(scaledvalue, -v->range_y / 2 - 1, v->range_y / 2);
     else
-        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
+        return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 + 1);
 }
 
 static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */)