---
 libavcodec/tiffenc.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index a141a47..0c0e112 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -211,12 +211,13 @@ static int encode_frame(AVCodecContext * avctx, unsigned 
char *buf,
     uint32_t *strip_offsets = NULL;
     int bytes_per_row;
     uint32_t res[2] = { 72, 1 };        // image resolution (72/1)
-    static const uint16_t bpp_tab[] = { 8, 8, 8, 8 };
+    uint16_t bpp_tab[] = { 8, 8, 8, 8 };
     int ret = -1;
     int is_yuv = 0;
     uint8_t *yuv_line = NULL;
     int shift_h, shift_v;
 
+    s->avctx = avctx;
     s->buf_start = buf;
     s->buf = &ptr;
     s->buf_size = buf_size;
@@ -243,6 +244,14 @@ static int encode_frame(AVCodecContext * avctx, unsigned 
char *buf,
     s->subsampling[1] = 1;
 
     switch (avctx->pix_fmt) {
+    case PIX_FMT_RGB48LE:
+        s->bpp = 48;
+        s->photometric_interpretation = 2;
+        bpp_tab[0] = 16;
+        bpp_tab[1] = 16;
+        bpp_tab[2] = 16;
+        bpp_tab[3] = 16;
+        break;
     case PIX_FMT_RGB24:
         s->bpp = 24;
         s->photometric_interpretation = 2;
@@ -283,13 +292,9 @@ static int encode_frame(AVCodecContext * avctx, unsigned 
char *buf,
         return -1;
     }
     if (!is_yuv)
-        s->bpp_tab_size = (s->bpp >> 3);
+        s->bpp_tab_size = (s->bpp >= 48) ? (s->bpp >> 4) : (s->bpp >> 3);
 
-    if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr 
== TIFF_LZW)
-        //best choose for DEFLATE
-        s->rps = s->height;
-    else
-        s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);     // 
suggest size of strip
+    s->rps = s->height;
     s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1]; // 
round rps up
 
     strips = (s->height - 1) / s->rps + 1;
@@ -454,7 +459,7 @@ AVCodec ff_tiff_encoder = {
                               PIX_FMT_MONOBLACK, PIX_FMT_MONOWHITE,
                               PIX_FMT_YUV420P, PIX_FMT_YUV422P,
                               PIX_FMT_YUV444P, PIX_FMT_YUV410P,
-                              PIX_FMT_YUV411P,
+                              PIX_FMT_YUV411P, PIX_FMT_RGB48LE,
                               PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
 };
-- 
1.7.4.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to