aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-01 02:33:37 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-01 02:33:42 +0100
commitffd02d0c197449052488b6867280dedd5425e94a (patch)
treeec9da069ef2d5b1ee2a30d6627fa8eeec6abdc15
parent4789c25d83c4a90e8ef81d2cc05be6d2f12dfa68 (diff)
parent28f36dce3e5c6be6b7f208362fca3531ed3cb50d (diff)
downloadffmpeg-ffd02d0c197449052488b6867280dedd5425e94a.tar.gz
Merge remote-tracking branch 'mjbshaw/master'
* mjbshaw/master: libopenjpegenc: simplify switch statement libopenjpegenc: add support for pix fmt gbrp (8-16 bit) Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/libopenjpegenc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 13e8ef914c..2bbbae902a 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -100,6 +100,12 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_RGB48:
case AV_PIX_FMT_RGBA64:
+ case AV_PIX_FMT_GBR24P:
+ case AV_PIX_FMT_GBRP9:
+ case AV_PIX_FMT_GBRP10:
+ case AV_PIX_FMT_GBRP12:
+ case AV_PIX_FMT_GBRP14:
+ case AV_PIX_FMT_GBRP16:
color_space = CLRSPC_SRGB;
break;
case AV_PIX_FMT_YUV410P:
@@ -351,6 +357,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
opj_cio_t *stream;
int cpyresult = 0;
int ret, len;
+ AVFrame gbrframe;
// x0, y0 is the top left corner of the image
// x1, y1 is the width, height of the reference grid
@@ -369,6 +376,25 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case AV_PIX_FMT_RGBA64:
cpyresult = libopenjpeg_copy_packed16(avctx, frame, image);
break;
+ case AV_PIX_FMT_GBR24P:
+ case AV_PIX_FMT_GBRP9:
+ case AV_PIX_FMT_GBRP10:
+ case AV_PIX_FMT_GBRP12:
+ case AV_PIX_FMT_GBRP14:
+ case AV_PIX_FMT_GBRP16:
+ gbrframe = *frame;
+ gbrframe.data[0] = frame->data[2]; // swap to be rgb
+ gbrframe.data[1] = frame->data[0];
+ gbrframe.data[2] = frame->data[1];
+ gbrframe.linesize[0] = frame->linesize[2];
+ gbrframe.linesize[1] = frame->linesize[0];
+ gbrframe.linesize[2] = frame->linesize[1];
+ if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) {
+ cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image);
+ } else {
+ cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image);
+ }
+ break;
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
@@ -505,6 +531,8 @@ AVCodec ff_libopenjpeg_encoder = {
.capabilities = 0,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,
+ AV_PIX_FMT_GBR24P,
+ AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, AV_PIX_FMT_GRAY16,
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P,
AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA422P,