Re: [libav-devel] [PATCH 1/3] mpegvideo: Fix undefined negative shifts in ff_init_block_index

2016-03-02 Thread Luca Barbato
On 03/03/16 00:52, Vittorio Giovara wrote:
> From: Luca Barbato 
> 
> Found-by: gcc5-ubsan.
> 
> Signed-off-by: Vittorio Giovara 
> ---
>  libavcodec/mpegvideo.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index e0787a6..5974e18 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -1754,9 +1754,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME 
> maybe rename
>  s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + 
> s->b8_stride*s->mb_height*2 + s->mb_x - 1;
>  //block_index is not used by mpeg2, so it is not affected by 
> chroma_format
>  
> -s->dest[0] = s->current_picture.f->data[0] + ((s->mb_x - 1) <<  mb_size);
> -s->dest[1] = s->current_picture.f->data[1] + ((s->mb_x - 1) << (mb_size 
> - s->chroma_x_shift));
> -s->dest[2] = s->current_picture.f->data[2] + ((s->mb_x - 1) << (mb_size 
> - s->chroma_x_shift));
> +s->dest[0] = s->current_picture.f->data[0] + (s->mb_x - 1) * (1 << 
> mb_size);
> +s->dest[1] = s->current_picture.f->data[1] + (s->mb_x - 1) * (1 << 
> (mb_size - s->chroma_x_shift));
> +s->dest[2] = s->current_picture.f->data[2] + (s->mb_x - 1) * (1 << 
> (mb_size - s->chroma_x_shift));
>  
>  if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && 
> s->picture_structure==PICT_FRAME))
>  {
> 

If it is ok for you it is for me.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/3] mpegvideo: Fix undefined negative shifts in ff_init_block_index

2016-03-02 Thread Vittorio Giovara
From: Luca Barbato 

Found-by: gcc5-ubsan.

Signed-off-by: Vittorio Giovara 
---
 libavcodec/mpegvideo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index e0787a6..5974e18 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1754,9 +1754,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME 
maybe rename
 s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + 
s->b8_stride*s->mb_height*2 + s->mb_x - 1;
 //block_index is not used by mpeg2, so it is not affected by chroma_format
 
-s->dest[0] = s->current_picture.f->data[0] + ((s->mb_x - 1) <<  mb_size);
-s->dest[1] = s->current_picture.f->data[1] + ((s->mb_x - 1) << (mb_size - 
s->chroma_x_shift));
-s->dest[2] = s->current_picture.f->data[2] + ((s->mb_x - 1) << (mb_size - 
s->chroma_x_shift));
+s->dest[0] = s->current_picture.f->data[0] + (s->mb_x - 1) * (1 << 
mb_size);
+s->dest[1] = s->current_picture.f->data[1] + (s->mb_x - 1) * (1 << 
(mb_size - s->chroma_x_shift));
+s->dest[2] = s->current_picture.f->data[2] + (s->mb_x - 1) * (1 << 
(mb_size - s->chroma_x_shift));
 
 if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && 
s->picture_structure==PICT_FRAME))
 {
-- 
2.7.0

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel