diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-05-15 22:37:02 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-15 22:37:02 +0200 |
commit | a80f74c584296971c6e6b7e0c10d9b5ec0440857 (patch) | |
tree | 999167bc4cfd975fb033688016874a3d4ef2b7b7 /libavcodec/imgconvert.c | |
parent | 27614b121776aa2b32579808810fb95839627bd9 (diff) | |
download | ffmpeg-a80f74c584296971c6e6b7e0c10d9b5ec0440857.tar.gz |
av_picture_crop(): Support simple cases with packed pixels too.
This fixes a regression when linked to old ffmpeg.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r-- | libavcodec/imgconvert.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 59630dfb09..a86d2bd027 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -790,15 +790,23 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src, 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 = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h; x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w; + if (is_yuv_planar(&pix_fmt_info[pix_fmt])) { 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); + } 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->linesize[0] = src->linesize[0]; dst->linesize[1] = src->linesize[1]; |