[Ffmpeg-devel] [PATCH] fix error croping
Limin Wang
lance.lmwang
Wed Apr 4 09:34:56 CEST 2007
Hi,
> [...]
> >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.
Attached patch to remove the fix which is wrong.
Thanks,
Limin
-------------- next part --------------
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;
- dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
- dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
+ dst->linesize[0] = src->linesize[0];
+ if( is_yuv_planar(&pix_fmt_info[pix_fmt])) {
+ y_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
+ x_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
- dst->linesize[0] = src->linesize[0];
- dst->linesize[1] = src->linesize[1];
- dst->linesize[2] = src->linesize[2];
+ dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
+ dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
+
+ dst->linesize[1] = src->linesize[1];
+ dst->linesize[2] = src->linesize[2];
+ }
+
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070404/413784b9/attachment.pgp>
More information about the ffmpeg-devel
mailing list