aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-14 16:19:53 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-14 16:53:36 +0200
commit10c2d22ba19565ef65f6fd9cf6c8a931339470d4 (patch)
tree3d7d6391acdcb36a96f5cd1d32f817ebbb5ccb13
parent35738e589847ab958f209a44f818f4746d28c7f2 (diff)
downloadffmpeg-10c2d22ba19565ef65f6fd9cf6c8a931339470d4.tar.gz
avcodec/mjpegdec: Support AV_PIX_FMT_YUV420P16 with upscale_h
Fixes assertion failure Fixes: test42f.jpg Found-by: Piotr Bandurski <ami_stuff@o2.pl> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 5c7899a4834ee927f5629e4c02bfa225b846f016) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mjpegdec.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1a774ddc61..19fd9293a7 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1894,6 +1894,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int start_code;
int i, index;
int ret = 0;
+ int is16bit;
av_dict_free(&s->exif_metadata);
av_freep(&s->stereo3d);
@@ -2072,6 +2073,9 @@ fail:
s->got_picture = 0;
return ret;
the_end:
+
+ is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step_minus1;
+
if (s->upscale_h) {
int p;
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
@@ -2081,6 +2085,7 @@ the_end:
avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUV420P16||
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
@@ -2092,8 +2097,12 @@ the_end:
if (p==1 || p==2)
w >>= hshift;
for (i = 0; i < s->chroma_height; i++) {
- for (index = w - 1; index; index--)
- line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
+ for (index = w - 1; index; index--) {
+ if (is16bit)
+ ((uint16_t*)line)[index] = (((uint16_t*)line)[index / 2] + ((uint16_t*)line)[(index + 1) / 2]) >> 1;
+ else
+ line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
+ }
line += s->linesize[p];
}
}