]> git.sesse.net Git - ffmpeg/commitdiff
libavcodec/imgconvert.c: support left band while cropping
authorPrzemysław Sobala <przemyslaw.sobala@grupawp.pl>
Fri, 12 Jun 2015 16:38:05 +0000 (18:38 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 12 Jun 2015 17:52:30 +0000 (19:52 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/imgconvert.c

index 8cb609946a5cb0a543bc7f2c09aa40d89303e4a7..dc67560742ae1c741b5ef13e2e5460f2061cc5a1 100644 (file)
@@ -201,12 +201,14 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src,
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
     int y_shift;
     int x_shift;
+    int max_step[4];
 
     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
         return -1;
 
     y_shift = desc->log2_chroma_h;
     x_shift = desc->log2_chroma_w;
+    av_image_fill_max_pixsteps(max_step, NULL, desc);
 
     if (is_yuv_planar(desc)) {
     dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
@@ -215,9 +217,7 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src,
     } else{
         if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
             return -1;
-        if(left_band) //FIXME add support for this too
-            return -1;
-        dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
+        dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + (left_band * max_step[0]);
     }
 
     dst->linesize[0] = src->linesize[0];