FFmpeg  4.0
Data Structures | Macros | Functions | Variables
tiff.c File Reference

TIFF image decoder. More...

#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "faxcompr.h"
#include "internal.h"
#include "lzw.h"
#include "mathops.h"
#include "tiff.h"
#include "tiff_data.h"
#include "thread.h"

Go to the source code of this file.

Data Structures

struct  TiffContext
 

Macros

#define RET_GEOKEY(TYPE, array, element)
 
#define RET_GEOKEY_VAL(TYPE, array)
 
#define ADD_METADATA(count, name, sep)
 

Functions

static void free_geotags (TiffContext *const s)
 
static const char * get_geokey_name (int key)
 
static int get_geokey_type (int key)
 
static int cmp_id_key (const void *id, const void *k)
 
static const char * search_keyval (const TiffGeoTagKeyName *keys, int n, int id)
 
static char * get_geokey_val (int key, int val)
 
static char * doubles2str (double *dp, int count, const char *sep)
 
static int add_metadata (int count, int type, const char *name, const char *sep, TiffContext *s, AVFrame *frame)
 
static void av_always_inline horizontal_fill (unsigned int bpp, uint8_t *dst, int usePtr, const uint8_t *src, uint8_t c, int width, int offset)
 
static int deinvert_buffer (TiffContext *s, const uint8_t *src, int size)
 
static void unpack_yuv (TiffContext *s, AVFrame *p, const uint8_t *src, int lnum)
 
static int tiff_unpack_fax (TiffContext *s, uint8_t *dst, int stride, const uint8_t *src, int size, int width, int lines)
 
static int tiff_unpack_strip (TiffContext *s, AVFrame *p, uint8_t *dst, int stride, const uint8_t *src, int size, int strip_start, int lines)
 
static int init_image (TiffContext *s, ThreadFrame *frame)
 
static void set_sar (TiffContext *s, unsigned tag, unsigned num, unsigned den)
 
static int tiff_decode_tag (TiffContext *s, AVFrame *frame)
 
static int decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
static av_cold int tiff_init (AVCodecContext *avctx)
 
static av_cold int tiff_end (AVCodecContext *avctx)
 

Variables

AVCodec ff_tiff_decoder
 

Detailed Description

TIFF image decoder.

Author
Konstantin Shishkov

Definition in file tiff.c.

Macro Definition Documentation

◆ RET_GEOKEY

#define RET_GEOKEY (   TYPE,
  array,
  element 
)
Value:
if (key >= TIFF_##TYPE##_KEY_ID_OFFSET &&\
key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_name_type_map))\
return ff_tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].element;
const char * key
#define FF_ARRAY_ELEMS(a)
#define TYPE
Definition: ffv1.h:204
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:106

Definition at line 95 of file tiff.c.

Referenced by get_geokey_name(), and get_geokey_type().

◆ RET_GEOKEY_VAL

#define RET_GEOKEY_VAL (   TYPE,
  array 
)
Value:
if (val >= TIFF_##TYPE##_OFFSET &&\
val - TIFF_##TYPE##_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_codes))\
return av_strdup(ff_tiff_##array##_codes[val - TIFF_##TYPE##_OFFSET]);
const char const char void * val
Definition: avisynth_c.h:771
#define FF_ARRAY_ELEMS(a)
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:251
#define TYPE
Definition: ffv1.h:204
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:106

Referenced by get_geokey_val().

◆ ADD_METADATA

#define ADD_METADATA (   count,
  name,
  sep 
)
Value:
if ((ret = add_metadata(count, type, name, sep, s, frame)) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
goto end;\
}
const char * name
Definition: avisynth_c.h:775
const char * s
Definition: avisynth_c.h:768
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
static AVFrame * frame
static int add_metadata(int count, int type, const char *name, const char *sep, TiffContext *s, AVFrame *frame)
Definition: tiff.c:228
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
cl_device_type type
void INT64 INT64 count
Definition: avisynth_c.h:690

Referenced by tiff_decode_tag().

Function Documentation

◆ free_geotags()

static void free_geotags ( TiffContext *const  s)
static

Definition at line 84 of file tiff.c.

Referenced by decode_frame(), and tiff_end().

◆ get_geokey_name()

static const char* get_geokey_name ( int  key)
static

Definition at line 100 of file tiff.c.

Referenced by decode_frame().

◆ get_geokey_type()

static int get_geokey_type ( int  key)
static

Definition at line 110 of file tiff.c.

Referenced by decode_frame().

◆ cmp_id_key()

static int cmp_id_key ( const void id,
const void k 
)
static

Definition at line 120 of file tiff.c.

Referenced by search_keyval().

◆ search_keyval()

static const char* search_keyval ( const TiffGeoTagKeyName keys,
int  n,
int  id 
)
static

Definition at line 125 of file tiff.c.

Referenced by get_geokey_val().

◆ get_geokey_val()

static char* get_geokey_val ( int  key,
int  val 
)
static

Definition at line 134 of file tiff.c.

Referenced by tiff_decode_tag().

◆ doubles2str()

static char* doubles2str ( double *  dp,
int  count,
const char *  sep 
)
static

Definition at line 202 of file tiff.c.

Referenced by tiff_decode_tag().

◆ add_metadata()

static int add_metadata ( int  count,
int  type,
const char *  name,
const char *  sep,
TiffContext s,
AVFrame frame 
)
static

Definition at line 228 of file tiff.c.

◆ horizontal_fill()

static void av_always_inline horizontal_fill ( unsigned int  bpp,
uint8_t dst,
int  usePtr,
const uint8_t src,
uint8_t  c,
int  width,
int  offset 
)
static

Definition at line 239 of file tiff.c.

Referenced by tiff_unpack_fax(), tiff_unpack_strip(), and unpack_yuv().

◆ deinvert_buffer()

static int deinvert_buffer ( TiffContext s,
const uint8_t src,
int  size 
)
static

Definition at line 279 of file tiff.c.

Referenced by tiff_unpack_strip(), and unpack_yuv().

◆ unpack_yuv()

static void unpack_yuv ( TiffContext s,
AVFrame p,
const uint8_t src,
int  lnum 
)
static

Definition at line 292 of file tiff.c.

Referenced by tiff_unpack_strip().

◆ tiff_unpack_fax()

static int tiff_unpack_fax ( TiffContext s,
uint8_t dst,
int  stride,
const uint8_t src,
int  size,
int  width,
int  lines 
)
static

Definition at line 452 of file tiff.c.

Referenced by tiff_unpack_strip().

◆ tiff_unpack_strip()

static int tiff_unpack_strip ( TiffContext s,
AVFrame p,
uint8_t dst,
int  stride,
const uint8_t src,
int  size,
int  strip_start,
int  lines 
)
static

Definition at line 485 of file tiff.c.

Referenced by decode_frame().

◆ init_image()

static int init_image ( TiffContext s,
ThreadFrame frame 
)
static

Definition at line 655 of file tiff.c.

Referenced by decode_frame().

◆ set_sar()

static void set_sar ( TiffContext s,
unsigned  tag,
unsigned  num,
unsigned  den 
)
static

Definition at line 773 of file tiff.c.

Referenced by tiff_decode_tag().

◆ tiff_decode_tag()

static int tiff_decode_tag ( TiffContext s,
AVFrame frame 
)
static

Definition at line 792 of file tiff.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
void data,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 1212 of file tiff.c.

◆ tiff_init()

static av_cold int tiff_init ( AVCodecContext avctx)
static

Definition at line 1396 of file tiff.c.

◆ tiff_end()

static av_cold int tiff_end ( AVCodecContext avctx)
static

Definition at line 1411 of file tiff.c.

Variable Documentation

◆ ff_tiff_decoder

AVCodec ff_tiff_decoder
Initial value:
= {
.name = "tiff",
.long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
.priv_data_size = sizeof(TiffContext),
.close = tiff_end,
}
static int init_thread_copy(AVCodecContext *avctx)
Definition: tta.c:392
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: tiff.c:1212
static av_cold int tiff_init(AVCodecContext *avctx)
Definition: tiff.c:1396
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int tiff_end(AVCodecContext *avctx)
Definition: tiff.c:1411
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1015
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:225
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

Definition at line 1425 of file tiff.c.