[Ffmpeg-devel] [PATCH] fix error croping

Luca Abeni lucabe72
Wed Apr 4 09:08:31 CEST 2007


Hi Limin,

Limin Wang wrote:

[...]
> After investigating, I found out packed format can crop without more
> change.
Uhmmm... This looks strange. But anyway, let's look at the patch...

[...]
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 8622)
> +++ ffmpeg.c	(working copy)
> @@ -730,7 +730,7 @@
>      if (ost->video_pad) {
>          final_picture = &ost->pict_tmp;
>          if (ost->video_resample) {
> -            if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
> +            if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, dec->pix_fmt, ost->padtop, ost->padleft) < 0) {
>                  av_log(NULL, AV_LOG_ERROR, "error padding picture\n");
>                  return;
>              }
As I said yesterday, I believe the code is ok as it is, and this change 
is an error. Note that here av_picture_crop() is used on the final 
picture, to identify the area in which resampling must output.
And the final picture is in enc->pix_fmt pixel format.

> Index: libavcodec/imgconvert.c
> ===================================================================
> --- libavcodec/imgconvert.c	(revision 8622)
> +++ libavcodec/imgconvert.c	(working copy)
> @@ -2220,19 +2220,22 @@
>      int y_shift;
>      int x_shift;
>  
> -    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt]))
> +    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
>          return -1;
>  
> -    y_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
> -    x_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
> -
>      dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
This looks wrong (regarding the left_band) for a packed format. Is it 
really working for you?
For example, when using yuyv422 I have to skip 4 bytes for cropping 2 
pixels, no?

Anyway, I might be confused about this... Let's see other people's comments.


					Luca




More information about the ffmpeg-devel mailing list