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>
This commit is contained in:
Michael Niedermayer 2014-02-27 21:55:31 +01:00
parent 501beae6f9
commit a05635ee01
1 changed files with 27 additions and 6 deletions

View File

@ -378,14 +378,13 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
if (s->rgb) if (s->rgb)
s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_ABGR : AV_PIX_FMT_RGBA64; s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_ABGR : AV_PIX_FMT_RGBA64;
else { else {
if (s->adobe_transform == 0) { if (s->adobe_transform == 0 && s->bits <= 8) {
av_log(s->avctx, AV_LOG_ERROR, "CMYK Unsupported\n"); s->avctx->pix_fmt = AV_PIX_FMT_GBRAP;
if (s->avctx->err_recognition & AV_EF_EXPLODE) } else {
goto unk_pixfmt;
}
s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_YUVA444P : AV_PIX_FMT_YUVA444P16; 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->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
} }
}
av_assert0(s->nb_components == 4); av_assert0(s->nb_components == 4);
break; break;
case 0x12121100: case 0x12121100:
@ -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) { if (s->stereo3d) {
AVStereo3D *stereo = av_stereo3d_create_side_data(data); AVStereo3D *stereo = av_stereo3d_create_side_data(data);