[FFmpeg-devel] [PATCH]libopenjpeg 64bit encoding

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Jan 12 23:59:35 CET 2012


Hi!

The encoded samples decode correctly with jasper and OSX preview, tested with 
tif (rgba64le), png (rgba64le), dpx (rgba64be) and sgi (rgba64be) as input on 
le and be.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index c07eccd..972f824 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -82,6 +82,11 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
         numcomps = 3;
         bpp = 16;
         break;
+    case PIX_FMT_RGBA64:
+        color_space = CLRSPC_SRGB;
+        numcomps = 4;
+        bpp = 16;
+        break;
     case PIX_FMT_YUV420P:
         color_space = CLRSPC_SYCC;
         numcomps = 3;
@@ -219,7 +224,7 @@ static int libopenjpeg_copy_rgb16(AVCodecContext *avctx, AVFrame *frame, opj_ima
     int y;
     uint16_t *frame_ptr = (uint16_t*)frame->data[0];
 
-    av_assert0(numcomps == 3);
+    av_assert0(numcomps == 3 || numcomps == 4);
 
     for (compno = 0; compno < numcomps; ++compno) {
         if (image->comps[compno].w > frame->linesize[0] / numcomps) {
@@ -326,6 +331,9 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf
     case PIX_FMT_RGB48:
         cpyresult = libopenjpeg_copy_rgb16(avctx, frame, image, 3);
         break;
+    case PIX_FMT_RGBA64:
+        cpyresult = libopenjpeg_copy_rgb16(avctx, frame, image, 4);
+        break;
     case PIX_FMT_YUV420P:
     case PIX_FMT_YUV422P:
     case PIX_FMT_YUV440P:
@@ -400,7 +408,7 @@ AVCodec ff_libopenjpeg_encoder = {
     .encode         = libopenjpeg_encode_frame,
     .close          = libopenjpeg_encode_close,
     .capabilities   = 0,
-    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24,PIX_FMT_RGBA,PIX_FMT_RGB48,PIX_FMT_GRAY8,
+    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24,PIX_FMT_RGBA,PIX_FMT_RGB48,PIX_FMT_RGBA64,PIX_FMT_GRAY8,
                                            PIX_FMT_YUV420P,PIX_FMT_YUV422P,PIX_FMT_YUVA420P,
                                            PIX_FMT_YUV440P,PIX_FMT_YUV444P,
                                            PIX_FMT_YUV420P9,PIX_FMT_YUV422P9,PIX_FMT_YUV444P9,


More information about the ffmpeg-devel mailing list