summaryrefslogtreecommitdiffstats
path: root/libavcodec/tiffenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/tiffenc.c')
-rw-r--r--libavcodec/tiffenc.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index d486b3f..722d78f 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -2,20 +2,20 @@
* TIFF image encoder
* Copyright (c) 2007 Bartlomiej Wolowiec
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -29,6 +29,7 @@
#if CONFIG_ZLIB
#include <zlib.h>
#endif
+#include "libavutil/opt.h"
#include "bytestream.h"
#include "tiff.h"
#include "rle.h"
@@ -43,6 +44,7 @@ static const uint8_t type_sizes2[6] = {
};
typedef struct TiffEncoderContext {
+ AVClass *avclass;
AVCodecContext *avctx;
AVFrame picture;
@@ -61,6 +63,7 @@ typedef struct TiffEncoderContext {
int buf_size; ///< buffer size
uint16_t subsampling[2]; ///< YUV subsampling factors
struct LZWEncodeState *lzws; ///< LZW Encode state
+ uint32_t dpi; ///< image resolution in DPI
} TiffEncoderContext;
@@ -210,8 +213,8 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
uint32_t *strip_sizes = NULL;
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 };
+ uint32_t res[2] = { s->dpi, 1 }; // image resolution (72/1)
+ uint16_t bpp_tab[] = { 8, 8, 8, 8 };
int ret = -1;
int is_yuv = 0;
uint8_t *yuv_line = NULL;
@@ -244,6 +247,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;
@@ -257,12 +268,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
s->photometric_interpretation = 3;
break;
case PIX_FMT_MONOBLACK:
- s->bpp = 1;
- s->photometric_interpretation = 1;
- break;
case PIX_FMT_MONOWHITE:
s->bpp = 1;
- s->photometric_interpretation = 0;
+ s->photometric_interpretation = avctx->pix_fmt == PIX_FMT_MONOBLACK;
+ bpp_tab[0] = 1;
break;
case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P:
@@ -284,7 +293,7 @@ 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 + 7) >> 4):((s->bpp + 7) >> 3);
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr == TIFF_LZW)
//best choose for DEFLATE
@@ -444,6 +453,12 @@ fail:
return ret;
}
+static const AVOption options[]={
+{"dpi", "set the image resolution (in dpi)", offsetof(TiffEncoderContext, dpi), FF_OPT_TYPE_INT, {.dbl = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM},
+{NULL}
+};
+static const AVClass class = { "tiff", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
+
AVCodec ff_tiff_encoder = {
.name = "tiff",
.type = AVMEDIA_TYPE_VIDEO,
@@ -455,7 +470,8 @@ 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"),
+ .priv_class= &class,
};
OpenPOWER on IntegriCloud