diff options
author | Michael Bradshaw <mbradshaw@sorensonmedia.com> | 2012-02-01 15:51:18 +0100 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2012-02-01 15:51:18 +0100 |
commit | d76864d9cea6cc5e8cdf7afde898aee0eddc5a25 (patch) | |
tree | a279b0224d39cf137b4002b013ac45e0665c1b9b | |
parent | ec0d02e441e0602418b51b98c1fe95b9ff4aac78 (diff) | |
download | ffmpeg-d76864d9cea6cc5e8cdf7afde898aee0eddc5a25.tar.gz |
Support decoding rgba64 with libopenjpeg.
-rw-r--r-- | libavcodec/libopenjpegdec.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index 683b82c2f1..89bfb34913 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -50,6 +50,19 @@ static enum PixelFormat check_image_attributes(AVCodecContext *avctx, opj_image_ compRatio |= c1.dx << 9 | c1.dy << 6; compRatio |= c2.dx << 3 | c2.dy; + if (image->numcomps == 4) { + if (c0.prec == 8) { + if (compRatio == 0112222 && + image->comps[3].dx == 1 && image->comps[3].dy == 1) { + return PIX_FMT_YUVA420P; + } else { + return PIX_FMT_RGBA; + } + } else { + return PIX_FMT_RGBA64; + } + } + switch (compRatio) { case 0111111: goto libopenjpeg_yuv444_rgb; case 0111212: return PIX_FMT_YUV440P; @@ -91,15 +104,6 @@ libopenjpeg_rgb: return PIX_FMT_RGB24; } -static int is_yuva420(opj_image_t *image) -{ - return image->numcomps == 4 && - image->comps[0].dx == 1 && image->comps[0].dy == 1 && - image->comps[1].dx == 2 && image->comps[1].dy == 2 && - image->comps[2].dx == 2 && image->comps[2].dy == 2 && - image->comps[3].dx == 1 && image->comps[3].dy == 1; -} - static inline int libopenjpeg_ispacked(enum PixelFormat pix_fmt) { int i, component_plane; component_plane = av_pix_fmt_descriptors[pix_fmt].comp[0].plane; @@ -262,9 +266,8 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, break; case 2: avctx->pix_fmt = PIX_FMT_GRAY8A; break; - case 3: avctx->pix_fmt = check_image_attributes(avctx, image); - break; - case 4: avctx->pix_fmt = is_yuva420(image) ? PIX_FMT_YUVA420P : PIX_FMT_RGBA; + case 3: + case 4: avctx->pix_fmt = check_image_attributes(avctx, image); break; default: av_log(avctx, AV_LOG_ERROR, "%d components unsupported.\n", image->numcomps); goto done; @@ -318,6 +321,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, } break; case 6: + case 8: if (ispacked) { libopenjpeg_copy_to_packed16(picture, image); } |