FFmpeg
Loading...
Searching...
No Matches
tiffenc.c File Reference

TIFF image encoder. More...

#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "encode.h"
#include "lzw.h"
#include "rle.h"
#include "tiff.h"
#include "tiff_common.h"
#include "version.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)
 
#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.
 
static void tnput (uint8_t **p, int n, const uint8_t *val, enum AVTiffDataType type, int flip)
 Put n values to buffer.
 
static int add_entry (TiffEncoderContext *s, enum TiffTags tag, enum AVTiffDataType type, int count, const void *ptr_val)
 Add entry to directory in tiff header.
 
static int add_entry1 (TiffEncoderContext *s, enum TiffTags tag, enum AVTiffDataType 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.
 
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)
 
static const AVOption options []
 
static const AVClass tiffenc_class
 
const FFCodec ff_tiff_encoder
 

Detailed Description

TIFF image encoder.

Author
Bartlomiej Wolowiec

Definition in file tiffenc.c.

Macro Definition Documentation

◆ TIFF_MAX_ENTRY

#define TIFF_MAX_ENTRY   32

Definition at line 48 of file tiffenc.c.

Referenced by add_entry().

◆ 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)
#define s(width, name)
Definition cbs_vp9.c:198
#define fail
Definition test.h:479
cl_device_type type
uint32_t tag
Definition movenc.c:2073
static int add_entry(TiffEncoderContext *s, enum TiffTags tag, enum AVTiffDataType type, int count, const void *ptr_val)
Add entry to directory in tiff header.
Definition tiffenc.c:129

Definition at line 234 of file tiffenc.c.

Referenced by encode_frame().

◆ ADD_ENTRY1

#define ADD_ENTRY1 ( s,
tag,
type,
val )
Value:
do { \
ret = add_entry1(s, tag, type, val); \
if (ret < 0) \
goto fail; \
} while (0)
static double val(void *priv, double ch)
Definition aeval.c:77
static int add_entry1(TiffEncoderContext *s, enum TiffTags tag, enum AVTiffDataType type, int val)
Definition tiffenc.c:153

Definition at line 241 of file tiffenc.c.

Referenced by encode_frame().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 564 of file tiffenc.c.

◆ VE

Definition at line 565 of file tiffenc.c.

Function Documentation

◆ check_size()

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

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

◆ tnput()

static void tnput ( uint8_t ** p,
int n,
const uint8_t * val,
enum AVTiffDataType 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 109 of file tiffenc.c.

Referenced by add_entry().

◆ add_entry()

static int add_entry ( TiffEncoderContext * s,
enum TiffTags tag,
enum AVTiffDataType 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 129 of file tiffenc.c.

Referenced by add_entry1().

◆ add_entry1()

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

Definition at line 153 of file tiffenc.c.

◆ encode_strip()

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

Referenced by encode_frame().

◆ pack_yuv()

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

Definition at line 206 of file tiffenc.c.

Referenced by encode_frame().

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

◆ encode_init()

static av_cold int encode_init ( AVCodecContext * avctx)
static

Definition at line 536 of file tiffenc.c.

◆ encode_close()

static av_cold int encode_close ( AVCodecContext * avctx)
static

Definition at line 553 of file tiffenc.c.

Variable Documentation

◆ type_sizes2

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

Referenced by add_entry(), and tnput().

◆ options

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, .unit = "compression_algo" },
{ "packbits", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TIFF_PACKBITS }, 0, 0, VE, .unit = "compression_algo" },
{ "raw", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TIFF_RAW }, 0, 0, VE, .unit = "compression_algo" },
{ "lzw", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TIFF_LZW }, 0, 0, VE, .unit = "compression_algo" },
{ "deflate", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TIFF_DEFLATE }, 0, 0, VE, .unit = "compression_algo" },
{ NULL },
}
#define VE
Definition amfenc_av1.c:30
#define NULL
Definition coverity.c:32
#define OFFSET(x)
#define AV_OPT_FLAG_VIDEO_PARAM
Definition opt.h:357
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition opt.h:351
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ TIFF_RAW
Definition tiff.h:127
@ TIFF_LZW
Definition tiff.h:131
@ TIFF_DEFLATE
Definition tiff.h:136
@ TIFF_PACKBITS
Definition tiff.h:135

Definition at line 566 of file tiffenc.c.

◆ tiffenc_class

const AVClass tiffenc_class
static
Initial value:
= {
.class_name = "TIFF encoder",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 576 of file tiffenc.c.

◆ ff_tiff_encoder

const FFCodec ff_tiff_encoder
Initial value:
= {
.p.name = "tiff",
CODEC_LONG_NAME("TIFF image"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(TiffEncoderContext),
.color_ranges = AVCOL_RANGE_MPEG,
.p.priv_class = &tiffenc_class,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
static av_cold int encode_init(AVCodecContext *avctx)
Definition asvenc.c:373
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
static av_cold int encode_close(AVCodecContext *avctx)
Definition dcaenc.c:354
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
Definition ffmpeg_enc.c:694
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition codec.h:98
@ AV_CODEC_ID_TIFF
Definition codec_id.h:146
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
Definition pixfmt.h:83
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
Definition pixfmt.h:143
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YA16LE
16 bits gray, 16 bits alpha (little-endian)
Definition pixfmt.h:210
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_RGBA64LE
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:203
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_RGB48LE
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:110
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Definition pixfmt.h:105
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition pixfmt.h:84
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
Definition pixfmt.h:82
static const AVClass tiffenc_class
Definition tiffenc.c:576

Definition at line 583 of file tiffenc.c.