diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-02-27 21:55:31 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-27 22:18:34 +0100 |
commit | a05635ee015883b132e4f1004162d40f8796d9fc (patch) | |
tree | 9ad8d1ebd054dbff9c5ec153ba6d8c462ab48d9c /libavcodec/mjpegdec.c | |
parent | 501beae6f9910280f386bd4b9b6dd77e9afb782f (diff) | |
download | ffmpeg-a05635ee015883b132e4f1004162d40f8796d9fc.tar.gz |
avcodec/mjpegdec: convert CMYK to GBRAP
Fixes Ticket2799
This should be moved into swscale once we have a CMYK pixel format
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r-- | libavcodec/mjpegdec.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index c0792281bc..ac94345613 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -378,13 +378,12 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) if (s->rgb) s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_ABGR : AV_PIX_FMT_RGBA64; else { - if (s->adobe_transform == 0) { - av_log(s->avctx, AV_LOG_ERROR, "CMYK Unsupported\n"); - if (s->avctx->err_recognition & AV_EF_EXPLODE) - goto unk_pixfmt; + if (s->adobe_transform == 0 && s->bits <= 8) { + s->avctx->pix_fmt = AV_PIX_FMT_GBRAP; + } else { + s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_YUVA444P : AV_PIX_FMT_YUVA444P16; + s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } - s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_YUVA444P : AV_PIX_FMT_YUVA444P16; - s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } av_assert0(s->nb_components == 4); break; @@ -2071,6 +2070,28 @@ the_end: } } } + if (s->adobe_transform == 0 && s->avctx->pix_fmt == AV_PIX_FMT_GBRAP) { + int w = s->picture_ptr->width; + int h = s->picture_ptr->height; + for (i=0; i<h; i++) { + int j; + uint8_t *dst[4]; + for (index=0; index<4; index++) { + dst[index] = s->picture_ptr->data[index] + + s->picture_ptr->linesize[index]*i; + } + for (j=0; j<w; j++) { + int k = dst[3][j]; + int r = dst[0][j] * k; + int g = dst[1][j] * k; + int b = dst[2][j] * k; + dst[0][j] = g*257 >> 16; + dst[1][j] = b*257 >> 16; + dst[2][j] = r*257 >> 16; + dst[3][j] = 255; + } + } + } if (s->stereo3d) { AVStereo3D *stereo = av_stereo3d_create_side_data(data); |