1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

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

View File

@ -378,14 +378,13 @@ 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;
}
}
av_assert0(s->nb_components == 4);
break;
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) {
AVStereo3D *stereo = av_stereo3d_create_side_data(data);