tiffenc.c File Reference

TIFF image encoder. More...

#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "config.h"
#include "bytestream.h"
#include "internal.h"
#include "tiff.h"
#include "rle.h"
#include "lzw.h"
#include "put_bits.h"
Include dependency graph for tiffenc.c:

Go to the source code of this file.

Data Structures

struct  TiffEncoderContext
 

Macros

#define TIFF_MAX_ENTRY   32
 
#define OFFSET(x)   offsetof(TiffEncoderContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Typedefs

typedef struct TiffEncoderContext TiffEncoderContext
 

Functions

static int check_size (TiffEncoderContext *s, uint64_t need)
 Check free space in buffer. More...
 
static void tnput (uint8_t **p, int n, const uint8_t *val, enum TiffTypes type, int flip)
 Put n values to buffer. More...
 
static void add_entry (TiffEncoderContext *s, enum TiffTags tag, enum TiffTypes type, int count, const void *ptr_val)
 Add entry to directory in tiff header. More...
 
static void add_entry1 (TiffEncoderContext *s, enum TiffTags tag, enum TiffTypes type, int val)
 
static int encode_strip (TiffEncoderContext *s, const int8_t *src, uint8_t *dst, int n, int compr)
 Encode one strip in tiff file. More...
 
static void pack_yuv (TiffEncoderContext *s, uint8_t *dst, int lnum)
 
static av_cold int encode_init (AVCodecContext *avctx)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static av_cold int encode_close (AVCodecContext *avctx)
 

Variables

static const uint8_t type_sizes2 [14]
 sizes of various TIFF field types (string size = 1) More...
 
static const AVOption options []
 
static const AVClass tiffenc_class
 
AVCodec ff_tiff_encoder
 

Detailed Description

TIFF image encoder.

Author
Bartlomiej Wolowiec

Definition in file tiffenc.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(TiffEncoderContext, x)

Definition at line 506 of file tiffenc.c.

#define TIFF_MAX_ENTRY   32

Definition at line 45 of file tiffenc.c.

Referenced by add_entry().

Definition at line 507 of file tiffenc.c.

Typedef Documentation

Function Documentation

static void add_entry ( TiffEncoderContext s,
enum TiffTags  tag,
enum TiffTypes  type,
int  count,
const void ptr_val 
)
static

Add entry to directory in tiff header.

Parameters
sTiff context
tagtag that identifies the entry
typeentry type
countthe number of values
ptr_valpointer to values

Definition at line 128 of file tiffenc.c.

Referenced by add_entry1(), and encode_frame().

static void add_entry1 ( TiffEncoderContext s,
enum TiffTags  tag,
enum TiffTypes  type,
int  val 
)
static

Definition at line 151 of file tiffenc.c.

Referenced by encode_frame().

static int check_size ( TiffEncoderContext s,
uint64_t  need 
)
inlinestatic

Check free space in buffer.

Parameters
sTiff context
needNeeded bytes
Returns
0 - ok, 1 - no free space

Definition at line 89 of file tiffenc.c.

Referenced by add_entry(), encode_frame(), and encode_strip().

static av_cold int encode_close ( AVCodecContext avctx)
static

Definition at line 495 of file tiffenc.c.

static int encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame pict,
int *  got_packet 
)
static

according to CCIR Recommendation 601.1

Definition at line 239 of file tiffenc.c.

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 227 of file tiffenc.c.

static int encode_strip ( TiffEncoderContext s,
const int8_t *  src,
uint8_t dst,
int  n,
int  compr 
)
static

Encode one strip in tiff file.

Parameters
sTiff context
srcinput buffer
dstoutput buffer
nsize of input buffer
comprcompression method
Returns
number of output bytes. If an output error is encountered, -1 is returned

Definition at line 168 of file tiffenc.c.

Referenced by encode_frame().

static void pack_yuv ( TiffEncoderContext s,
uint8_t dst,
int  lnum 
)
static

Definition at line 199 of file tiffenc.c.

Referenced by encode_frame().

static void tnput ( uint8_t **  p,
int  n,
const uint8_t val,
enum TiffTypes  type,
int  flip 
)
static

Put n values to buffer.

Parameters
ppointer to pointer to output buffer
nnumber of values
valpointer to values
typetype of values
flip= 0 - normal copy, >0 - flip

Definition at line 108 of file tiffenc.c.

Referenced by add_entry().

Variable Documentation

AVCodec ff_tiff_encoder
Initial value:
= {
.name = "tiff",
.priv_data_size = sizeof(TiffEncoderContext),
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
},
.long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
.priv_class = &tiffenc_class,
}
static av_cold int encode_init(AVCodecContext *avctx)
Definition: tiffenc.c:227
static av_cold int encode_close(AVCodecContext *avctx)
Definition: tiffenc.c:495
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:73
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
struct TiffEncoderContext TiffEncoderContext
8 bit with PIX_FMT_RGB32 palette
Definition: pixfmt.h:79
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:112
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:97
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:72
8bit gray, 8bit alpha
Definition: pixfmt.h:141
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: tiffenc.c:239
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
static const AVClass tiffenc_class
Definition: tiffenc.c:520
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:74
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:78
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:68
Y , 8bpp.
Definition: pixfmt.h:76
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:77
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:75
Y , 16bpp, little-endian.
Definition: pixfmt.h:102
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:103
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:210

Definition at line 527 of file tiffenc.c.

const AVOption options[]
static
Initial value:
= {
{"dpi", "set the image resolution (in dpi)", OFFSET(dpi), AV_OPT_TYPE_INT, {.i64 = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM},
{ "compression_algo", NULL, OFFSET(compr), AV_OPT_TYPE_INT, {.i64 = TIFF_PACKBITS}, TIFF_RAW, TIFF_DEFLATE, VE, "compression_algo" },
{ "packbits", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = TIFF_PACKBITS}, 0, 0, VE, "compression_algo" },
{ "raw", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = TIFF_RAW}, 0, 0, VE, "compression_algo" },
{ "lzw", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = TIFF_LZW}, 0, 0, VE, "compression_algo" },
{ NULL },
}
Definition: tiff.h:88
Definition: tiff.h:92
#define OFFSET(x)
Definition: tiffenc.c:506
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
#define VE
Definition: tiffenc.c:507
NULL
Definition: eval.c:55
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:285

Definition at line 508 of file tiffenc.c.

const AVClass tiffenc_class
static
Initial value:
= {
.class_name = "TIFF encoder",
.item_name = av_default_item_name,
.option = options,
}
av_default_item_name
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
static const AVOption options[]
Definition: tiffenc.c:508

Definition at line 520 of file tiffenc.c.

const uint8_t type_sizes2[14]
static
Initial value:
= {
0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4
}

sizes of various TIFF field types (string size = 1)

Definition at line 48 of file tiffenc.c.

Referenced by add_entry(), and tnput().