diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-07-01 22:40:20 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-01 22:54:57 +0200 |
commit | 64d98dadc7d033961d01eb880286ae77d016f189 (patch) | |
tree | 6359a9746483434105c4d78fa6fdb166553c27e6 | |
parent | 7558e55345811ce8868a94593cd0df4766ba25be (diff) | |
download | ffmpeg-64d98dadc7d033961d01eb880286ae77d016f189.tar.gz |
avcodec/mjpegdec: set upscale_h/upscale_v using generic code instead of hardcoding a list
Some code is left to handle corner cases
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/mjpegdec.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index acecc0a8a0..3b0710537d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -388,6 +388,16 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) if (!(pix_fmt_id & 0x0D0D0D0D)) pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1; + for (i = 0; i < 8; i++) { + int j = 6 + (i&1) - (i&6); + int is = (pix_fmt_id >> (4*i)) & 0xF; + int js = (pix_fmt_id >> (4*j)) & 0xF; + if (is == 1 && js == 2) { + if (i & 1) s->upscale_h |= 1 << (j/2); + else s->upscale_v |= 1 << (j/2); + } + } + switch (pix_fmt_id) { case 0x11111100: if (s->rgb) @@ -441,8 +451,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; - s->upscale_v = 4; - s->upscale_h = 2*(pix_fmt_id == 0x22122100); s->chroma_height = s->height; break; case 0x21211100: @@ -451,8 +459,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; - s->upscale_v = 2*(pix_fmt_id == 0x22211200); - s->upscale_h = 4; s->chroma_height = s->height; break; case 0x22221100: @@ -461,8 +467,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; - s->upscale_v = 2<<(pix_fmt_id == 0x22221100); - s->upscale_h = 2<<(pix_fmt_id == 0x22221100); s->chroma_height = s->height / 2; break; case 0x11222200: @@ -495,7 +499,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; - s->upscale_h = 4 * (pix_fmt_id == 0x22211100) + 2 * (pix_fmt_id == 0x22112100); s->chroma_height = s->height / 2; break; case 0x21111100: @@ -509,7 +512,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) else goto unk_pixfmt; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; - s->upscale_v = 2 << (pix_fmt_id == 0x22121100); break; case 0x22111100: case 0x42111100: @@ -530,6 +532,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) default: unk_pixfmt: av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id); + s->upscale_h = s->upscale_v = 0; return AVERROR_PATCHWELCOME; } if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) { |