FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
tiffenc.c File Reference

TIFF image encoder. More...

#include "config.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "lzw.h"
#include "put_bits.h"
#include "rle.h"
#include "tiff.h"

Go to the source code of this file.

Data Structures

struct  TiffEncoderContext
 

Macros

#define TIFF_MAX_ENTRY   32
 
#define ADD_ENTRY(s, tag, type, count, ptr_val)
 
#define ADD_ENTRY1(s, tag, type, val)
 
#define OFFSET(x)   offsetof(TiffEncoderContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

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 int 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 int 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, const AVFrame *p, uint8_t *dst, int lnum)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static av_cold int encode_init (AVCodecContext *avctx)
 
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 TIFF_MAX_ENTRY   32

Definition at line 45 of file tiffenc.c.

Referenced by add_entry().

#define ADD_ENTRY (   s,
  tag,
  type,
  count,
  ptr_val 
)
Value:
do { \
ret = add_entry(s, tag, type, count, ptr_val); \
if (ret < 0) \
goto fail; \
} while (0)
const char * s
Definition: avisynth_c.h:631
uint32_t tag
Definition: movenc.c:1334
GLsizei count
Definition: opengl_enc.c:109
#define fail()
Definition: checkasm.h:57
static int add_entry(TiffEncoderContext *s, enum TiffTags tag, enum TiffTypes type, int count, const void *ptr_val)
Add entry to directory in tiff header.
Definition: tiffenc.c:126
GLint GLenum type
Definition: opengl_enc.c:105
if(ret< 0)
Definition: vf_mcdeint.c:280

Definition at line 231 of file tiffenc.c.

Referenced by encode_frame().

#define ADD_ENTRY1 (   s,
  tag,
  type,
  val 
)
Value:
do { \
ret = add_entry1(s, tag, type, val); \
if (ret < 0) \
goto fail; \
} while (0)
const char const char void * val
Definition: avisynth_c.h:634
const char * s
Definition: avisynth_c.h:631
static int add_entry1(TiffEncoderContext *s, enum TiffTags tag, enum TiffTypes type, int val)
Definition: tiffenc.c:150
uint32_t tag
Definition: movenc.c:1334
#define fail()
Definition: checkasm.h:57
GLint GLenum type
Definition: opengl_enc.c:105
if(ret< 0)
Definition: vf_mcdeint.c:280

Definition at line 238 of file tiffenc.c.

Referenced by encode_frame().

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

Definition at line 546 of file tiffenc.c.

Definition at line 547 of file tiffenc.c.

Function Documentation

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 87 of file tiffenc.c.

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

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 106 of file tiffenc.c.

Referenced by add_entry().

static int 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 126 of file tiffenc.c.

Referenced by add_entry1().

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

Definition at line 150 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, a negative value corresponding to an AVERROR error code is returned.

Definition at line 170 of file tiffenc.c.

Referenced by encode_frame().

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

Definition at line 203 of file tiffenc.c.

Referenced by encode_frame().

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

according to CCIR Recommendation 601.1

Definition at line 245 of file tiffenc.c.

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 521 of file tiffenc.c.

static av_cold int encode_close ( AVCodecContext avctx)
static

Definition at line 535 of file tiffenc.c.

Variable Documentation

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().

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 },
}
#define NULL
Definition: coverity.c:32
Definition: tiff.h:89
Definition: tiff.h:93
#define OFFSET(x)
Definition: tiffenc.c:546
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:285
#define VE
Definition: tiffenc.c:547
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:291

Definition at line 548 of file tiffenc.c.

const AVClass tiffenc_class
static
Initial value:
= {
.class_name = "TIFF encoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
av_default_item_name
static const AVOption options[]
Definition: tiffenc.c:548

Definition at line 560 of file tiffenc.c.

AVCodec ff_tiff_encoder
Initial value:
= {
.name = "tiff",
.long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
.priv_data_size = sizeof(TiffEncoderContext),
.close = encode_close,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
},
.priv_class = &tiffenc_class,
}
static av_cold int encode_init(AVCodecContext *avctx)
Definition: tiffenc.c:521
static av_cold int encode_close(AVCodecContext *avctx)
Definition: tiffenc.c:535
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:68
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:65
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:940
8 bit with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:74
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. ...
Definition: internal.h:175
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:920
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:95
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:67
alias for AV_PIX_FMT_YA8
Definition: pixfmt.h:158
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: tiffenc.c:245
static const AVClass tiffenc_class
Definition: tiffenc.c:560
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:69
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:209
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:73
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:63
Y , 8bpp.
Definition: pixfmt.h:71
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:72
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:70
Y , 16bpp, little-endian.
Definition: pixfmt.h:100
16bit gray, 16bit alpha (little-endian)
Definition: pixfmt.h:247
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:101
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
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:272

Definition at line 567 of file tiffenc.c.