[FFmpeg-devel] [PATCH]Support decoding and encoding of 64bit tiff, v2

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Jan 11 00:19:31 CET 2012


Hi!

Attached tiff patch allows to reencode the sample from ticket #503 (which is 
64bpp) to tiff (64bpp). Tested on LE and BE, I hope this is correct.
The ffmpeg patch is necessary to support 64bpp frames.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index b0ccbac..2330485 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -302,6 +302,9 @@ static int init_image(TiffContext *s)
     case 483:
         s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
         break;
+    case 644:
+        s->avctx->pix_fmt = s->le ? PIX_FMT_RGBA64LE : PIX_FMT_RGBA64BE;
+        break;
     default:
         av_log(s->avctx, AV_LOG_ERROR,
                "This format is not supported (bpp=%d, bppcount=%d)\n",
@@ -640,13 +643,15 @@ static int decode_frame(AVCodecContext *avctx,
         dst = p->data[0];
         soff = s->bpp >> 3;
         ssize = s->width * soff;
-        if (s->avctx->pix_fmt == PIX_FMT_RGB48LE) {
+        if (s->avctx->pix_fmt == PIX_FMT_RGB48LE ||
+            s->avctx->pix_fmt == PIX_FMT_RGBA64LE) {
             for (i = 0; i < s->height; i++) {
                 for (j = soff; j < ssize; j += 2)
                     AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
                 dst += stride;
             }
-        } else if (s->avctx->pix_fmt == PIX_FMT_RGB48BE) {
+        } else if (s->avctx->pix_fmt == PIX_FMT_RGB48BE ||
+                   s->avctx->pix_fmt == PIX_FMT_RGBA64BE) {
             for (i = 0; i < s->height; i++) {
                 for (j = soff; j < ssize; j += 2)
                     AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff));
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index f8ce11e..6776473 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -255,6 +255,14 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
     s->subsampling[1] = 1;
 
     switch (avctx->pix_fmt) {
+    case PIX_FMT_RGBA64:
+        s->bpp = 64;
+        s->photometric_interpretation = 2;
+        bpp_tab[0] = 16;
+        bpp_tab[1] = 16;
+        bpp_tab[2] = 16;
+        bpp_tab[3] = 16;
+        break;
     case PIX_FMT_RGB48LE:
         s->bpp = 48;
         s->photometric_interpretation = 2;
@@ -498,7 +506,7 @@ AVCodec ff_tiff_encoder = {
                               PIX_FMT_YUV420P, PIX_FMT_YUV422P,
                               PIX_FMT_YUV444P, PIX_FMT_YUV410P,
                               PIX_FMT_YUV411P, PIX_FMT_RGB48LE,
-                              PIX_FMT_RGBA, PIX_FMT_NONE},
+                              PIX_FMT_RGBA, PIX_FMT_RGBA64, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
     .priv_class     = &tiffenc_class,
 };
-------------- next part --------------
diff --git a/ffmpeg.c b/ffmpeg.c
index a13e33a..0a932e6 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2620,9 +2620,9 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
             }
         }
         if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-            /* maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664)*/
+            /* maximum video buffer size is 8-bytes per pixel, plus DPX header size (1664)*/
             int size        = codec->width * codec->height;
-            bit_buffer_size = FFMAX(bit_buffer_size, 7*size + 10000);
+            bit_buffer_size = FFMAX(bit_buffer_size, 9*size + 10000);
         }
     }
 


More information about the ffmpeg-devel mailing list