FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
iff.c File Reference
#include <stdint.h>
#include "libavutil/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"

Go to the source code of this file.

Data Structures

struct  IffContext
 

Macros

#define LUT8_PART(plane, v)
 
#define LUT8(plane)
 
#define LUT32(plane)
 
#define DECODE_HAM_PLANE32(x)
 
#define DECODE_RGBX_COMMON(type)
 
#define GETNIBBLE   ((i & 1) ? (src[i>>1] & 0xF) : (src[i>>1] >> 4))
 

Enumerations

enum  mask_type { MASK_NONE, MASK_HAS_MASK, MASK_HAS_TRANSPARENT_COLOR, MASK_LASSO }
 

Functions

static av_always_inline uint32_t gray2rgb (const uint32_t x)
 
static int cmap_read_palette (AVCodecContext *avctx, uint32_t *pal)
 Convert CMAP buffer (stored in extradata) to lavc palette format. More...
 
static int extract_header (AVCodecContext *const avctx, const uint8_t *const extradata, int extradata_size)
 Extracts the IFF extra context and updates internal decoder structures. More...
 
static av_cold int decode_end (AVCodecContext *avctx)
 
static av_cold int decode_init (AVCodecContext *avctx)
 
static void decodeplane8 (uint8_t *dst, const uint8_t *buf, int buf_size, int plane)
 Decode interleaved plane buffer up to 8bpp. More...
 
static void decodeplane32 (uint32_t *dst, const uint8_t *buf, int buf_size, int plane)
 Decode interleaved plane buffer up to 24bpp. More...
 
static void decode_ham_plane32 (uint32_t *dst, const uint8_t *buf, const uint32_t *const pal, unsigned buf_size)
 Converts one line of HAM6/8-encoded chunky buffer to 24bpp. More...
 
static void lookup_pal_indicies (uint32_t *dst, const uint32_t *buf, const uint32_t *const pal, unsigned width)
 
static int decode_byterun (uint8_t *dst, int dst_size, GetByteContext *gb)
 Decode one complete byterun1 encoded line. More...
 
static int decode_byterun2 (uint8_t *dst, int height, int line_size, GetByteContext *gb)
 
static void decode_rgb8 (GetByteContext *gb, uint8_t *dst, int width, int height, int linesize)
 Decode RGB8 buffer. More...
 
static void decode_rgbn (GetByteContext *gb, uint8_t *dst, int width, int height, int linesize)
 Decode RGBN buffer. More...
 
static void decode_deep_rle32 (uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize)
 Decode DEEP RLE 32-bit buffer. More...
 
static void decode_deep_tvdc32 (uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize, const int16_t *tvdc)
 Decode DEEP TVDC 32-bit buffer. More...
 
static void decode_short_horizontal_delta (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
 
static void decode_byte_vertical_delta (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int xor, int bpp, int dst_size)
 
static void decode_delta_j (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int h, int bpp, int dst_size)
 
static void decode_short_vertical_delta (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
 
static void decode_long_vertical_delta (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
 
static void decode_short_vertical_delta2 (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
 
static void decode_long_vertical_delta2 (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
 
static void decode_delta_d (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
 
static void decode_delta_e (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
 
static void decode_delta_l (uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
 
static int unsupported (AVCodecContext *avctx)
 
static int parse_packet_header (AVCodecContext *const avctx, GetByteContext *gb)
 
static int decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
 

Variables

static const uint64_t plane8_lut [8][256]
 
static const uint32_t plane32_lut [32][16 *4]
 
const FFCodec ff_iff_ilbm_decoder
 

Detailed Description

IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN bitmap decoder

Definition in file iff.c.

Macro Definition Documentation

◆ LUT8_PART

#define LUT8_PART (   plane,
 
)
Value:
AV_LE2NE64C(UINT64_C(0x0000000)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1000000)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0010000)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1010000)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0000100)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1000100)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0010100)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1010100)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0000001)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1000001)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0010001)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1010001)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0000101)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1000101)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x0010101)<<32 | v) << plane, \
AV_LE2NE64C(UINT64_C(0x1010101)<<32 | v) << plane

Definition at line 69 of file iff.c.

◆ LUT8

#define LUT8 (   plane)
Value:
{ \
LUT8_PART(plane, 0x0000000), \
LUT8_PART(plane, 0x1000000), \
LUT8_PART(plane, 0x0010000), \
LUT8_PART(plane, 0x1010000), \
LUT8_PART(plane, 0x0000100), \
LUT8_PART(plane, 0x1000100), \
LUT8_PART(plane, 0x0010100), \
LUT8_PART(plane, 0x1010100), \
LUT8_PART(plane, 0x0000001), \
LUT8_PART(plane, 0x1000001), \
LUT8_PART(plane, 0x0010001), \
LUT8_PART(plane, 0x1010001), \
LUT8_PART(plane, 0x0000101), \
LUT8_PART(plane, 0x1000101), \
LUT8_PART(plane, 0x0010101), \
LUT8_PART(plane, 0x1010101), \
}

Definition at line 87 of file iff.c.

◆ LUT32

#define LUT32 (   plane)
Value:
{ \
0, 0, 0, 0, \
0, 0, 0, 1U << plane, \
0, 0, 1U << plane, 0, \
0, 0, 1U << plane, 1U << plane, \
0, 1U << plane, 0, 0, \
0, 1U << plane, 0, 1U << plane, \
0, 1U << plane, 1U << plane, 0, \
0, 1U << plane, 1U << plane, 1U << plane, \
1U << plane, 0, 0, 0, \
1U << plane, 0, 0, 1U << plane, \
1U << plane, 0, 1U << plane, 0, \
1U << plane, 0, 1U << plane, 1U << plane, \
1U << plane, 1U << plane, 0, 0, \
1U << plane, 1U << plane, 0, 1U << plane, \
1U << plane, 1U << plane, 1U << plane, 0, \
1U << plane, 1U << plane, 1U << plane, 1U << plane, \
}

Definition at line 112 of file iff.c.

◆ DECODE_HAM_PLANE32

#define DECODE_HAM_PLANE32 (   x)
Value:
first = buf[x] << 1; \
second = buf[(x)+1] << 1; \
delta &= pal[first++]; \
delta |= pal[first]; \
dst[x] = delta; \
delta &= pal[second++]; \
delta |= pal[second]; \
dst[(x)+1] = delta

Definition at line 444 of file iff.c.

◆ DECODE_RGBX_COMMON

#define DECODE_RGBX_COMMON (   type)
Value:
if (!length) { \
length = bytestream2_get_byte(gb); \
if (!length) { \
length = bytestream2_get_be16(gb); \
if (!length) \
return; \
} \
} \
for (i = 0; i < length; i++) { \
*(type *)(dst + y*linesize + x * sizeof(type)) = pixel; \
x += 1; \
if (x >= width) { \
y += 1; \
if (y >= height) \
return; \
x = 0; \
} \
}

Definition at line 591 of file iff.c.

◆ GETNIBBLE

#define GETNIBBLE   ((i & 1) ? (src[i>>1] & 0xF) : (src[i>>1] >> 4))

Enumeration Type Documentation

◆ mask_type

enum mask_type
Enumerator
MASK_NONE 
MASK_HAS_MASK 
MASK_HAS_TRANSPARENT_COLOR 
MASK_LASSO 

Definition at line 39 of file iff.c.

Function Documentation

◆ gray2rgb()

static av_always_inline uint32_t gray2rgb ( const uint32_t  x)
static

Definition at line 144 of file iff.c.

Referenced by cmap_read_palette(), and extract_header().

◆ cmap_read_palette()

static int cmap_read_palette ( AVCodecContext avctx,
uint32_t *  pal 
)
static

Convert CMAP buffer (stored in extradata) to lavc palette format.

Definition at line 151 of file iff.c.

Referenced by decode_frame().

◆ extract_header()

static int extract_header ( AVCodecContext *const  avctx,
const uint8_t *const  extradata,
int  extradata_size 
)
static

Extracts the IFF extra context and updates internal decoder structures.

Parameters
avctxthe AVCodecContext where to extract extra context to
Returns
>= 0 in case of success, a negative error code otherwise

Definition at line 202 of file iff.c.

Referenced by decode_init().

◆ decode_end()

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 323 of file iff.c.

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 337 of file iff.c.

◆ decodeplane8()

static void decodeplane8 ( uint8_t *  dst,
const uint8_t *  buf,
int  buf_size,
int  plane 
)
static

Decode interleaved plane buffer up to 8bpp.

Parameters
dstDestination buffer
bufSource buffer
buf_size
planeplane number to decode as

Definition at line 404 of file iff.c.

Referenced by decode_frame().

◆ decodeplane32()

static void decodeplane32 ( uint32_t *  dst,
const uint8_t *  buf,
int  buf_size,
int  plane 
)
static

Decode interleaved plane buffer up to 24bpp.

Parameters
dstDestination buffer
bufSource buffer
buf_size
planeplane number to decode as

Definition at line 426 of file iff.c.

Referenced by decode_frame().

◆ decode_ham_plane32()

static void decode_ham_plane32 ( uint32_t *  dst,
const uint8_t *  buf,
const uint32_t *const  pal,
unsigned  buf_size 
)
static

Converts one line of HAM6/8-encoded chunky buffer to 24bpp.

Parameters
dstthe destination 24bpp buffer
bufthe source 8bpp chunky buffer
palthe HAM decode table
buf_sizethe plane size in bytes

Definition at line 462 of file iff.c.

Referenced by decode_frame().

◆ lookup_pal_indicies()

static void lookup_pal_indicies ( uint32_t *  dst,
const uint32_t *  buf,
const uint32_t *const  pal,
unsigned  width 
)
static

Definition at line 477 of file iff.c.

Referenced by decode_frame().

◆ decode_byterun()

static int decode_byterun ( uint8_t *  dst,
int  dst_size,
GetByteContext gb 
)
static

Decode one complete byterun1 encoded line.

Parameters
dstthe destination buffer where to store decompressed bitstream
dst_sizethe destination plane size in bytes
bufthe source byterun1 compressed bitstream
buf_endthe EOF of source byterun1 compressed bitstream
Returns
number of consumed bytes in byterun1 compressed bitstream

Definition at line 494 of file iff.c.

Referenced by decode_frame().

◆ decode_byterun2()

static int decode_byterun2 ( uint8_t *  dst,
int  height,
int  line_size,
GetByteContext gb 
)
static

Definition at line 521 of file iff.c.

Referenced by decode_frame().

◆ decode_rgb8()

static void decode_rgb8 ( GetByteContext gb,
uint8_t *  dst,
int  width,
int  height,
int  linesize 
)
static

Decode RGB8 buffer.

Parameters
[out]dstDestination buffer
widthWidth of destination buffer (pixels)
heightHeight of destination buffer (pixels)
linesizeLine size of destination buffer (bytes)

Definition at line 618 of file iff.c.

Referenced by decode_frame().

◆ decode_rgbn()

static void decode_rgbn ( GetByteContext gb,
uint8_t *  dst,
int  width,
int  height,
int  linesize 
)
static

Decode RGBN buffer.

Parameters
[out]dstDestination buffer
widthWidth of destination buffer (pixels)
heightHeight of destination buffer (pixels)
linesizeLine size of destination buffer (bytes)

Definition at line 635 of file iff.c.

Referenced by decode_frame().

◆ decode_deep_rle32()

static void decode_deep_rle32 ( uint8_t *  dst,
const uint8_t *  src,
int  src_size,
int  width,
int  height,
int  linesize 
)
static

Decode DEEP RLE 32-bit buffer.

Parameters
[out]dstDestination buffer
[in]srcSource buffer
src_sizeSource buffer size (bytes)
widthWidth of destination buffer (pixels)
heightHeight of destination buffer (pixels)
linesizeLine size of destination buffer (bytes)

Definition at line 655 of file iff.c.

Referenced by decode_frame().

◆ decode_deep_tvdc32()

static void decode_deep_tvdc32 ( uint8_t *  dst,
const uint8_t *  src,
int  src_size,
int  width,
int  height,
int  linesize,
const int16_t *  tvdc 
)
static

Decode DEEP TVDC 32-bit buffer.

Parameters
[out]dstDestination buffer
[in]srcSource buffer
src_sizeSource buffer size (bytes)
widthWidth of destination buffer (pixels)
heightHeight of destination buffer (pixels)
linesizeLine size of destination buffer (bytes)
[int]tvdc TVDC lookup table

Definition at line 707 of file iff.c.

Referenced by decode_frame().

◆ decode_short_horizontal_delta()

static void decode_short_horizontal_delta ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  bpp,
int  dst_size 
)
static

Definition at line 747 of file iff.c.

Referenced by decode_frame().

◆ decode_byte_vertical_delta()

static void decode_byte_vertical_delta ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  xor,
int  bpp,
int  dst_size 
)
static

Definition at line 800 of file iff.c.

Referenced by decode_frame().

◆ decode_delta_j()

static void decode_delta_j ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  h,
int  bpp,
int  dst_size 
)
static

Definition at line 867 of file iff.c.

Referenced by decode_frame().

◆ decode_short_vertical_delta()

static void decode_short_vertical_delta ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  bpp,
int  dst_size 
)
static

Definition at line 978 of file iff.c.

Referenced by decode_frame().

◆ decode_long_vertical_delta()

static void decode_long_vertical_delta ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  bpp,
int  dst_size 
)
static

Definition at line 1046 of file iff.c.

Referenced by decode_frame().

◆ decode_short_vertical_delta2()

static void decode_short_vertical_delta2 ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  bpp,
int  dst_size 
)
static

Definition at line 1132 of file iff.c.

Referenced by decode_frame().

◆ decode_long_vertical_delta2()

static void decode_long_vertical_delta2 ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  bpp,
int  dst_size 
)
static

Definition at line 1192 of file iff.c.

Referenced by decode_frame().

◆ decode_delta_d()

static void decode_delta_d ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  flag,
int  bpp,
int  dst_size 
)
static

Definition at line 1274 of file iff.c.

Referenced by decode_frame().

◆ decode_delta_e()

static void decode_delta_e ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  flag,
int  bpp,
int  dst_size 
)
static

Definition at line 1333 of file iff.c.

Referenced by decode_frame().

◆ decode_delta_l()

static void decode_delta_l ( uint8_t *  dst,
const uint8_t *  buf,
const uint8_t *  buf_end,
int  w,
int  flag,
int  bpp,
int  dst_size 
)
static

Definition at line 1388 of file iff.c.

Referenced by decode_frame().

◆ unsupported()

static int unsupported ( AVCodecContext avctx)
static

Definition at line 1460 of file iff.c.

Referenced by decode_frame(), and txd_decode_frame().

◆ parse_packet_header()

static int parse_packet_header ( AVCodecContext *const  avctx,
GetByteContext gb 
)
static

Definition at line 1467 of file iff.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 1522 of file iff.c.

Variable Documentation

◆ plane8_lut

const uint64_t plane8_lut[8][256]
static
Initial value:
= {
LUT8(0), LUT8(1), LUT8(2), LUT8(3),
LUT8(4), LUT8(5), LUT8(6), LUT8(7),
}

Definition at line 107 of file iff.c.

Referenced by decodeplane8().

◆ plane32_lut

const uint32_t plane32_lut[32][16 *4]
static
Initial value:
= {
LUT32( 0), LUT32( 1), LUT32( 2), LUT32( 3),
LUT32( 4), LUT32( 5), LUT32( 6), LUT32( 7),
LUT32( 8), LUT32( 9), LUT32(10), LUT32(11),
LUT32(12), LUT32(13), LUT32(14), LUT32(15),
LUT32(16), LUT32(17), LUT32(18), LUT32(19),
LUT32(20), LUT32(21), LUT32(22), LUT32(23),
LUT32(24), LUT32(25), LUT32(26), LUT32(27),
LUT32(28), LUT32(29), LUT32(30), LUT32(31),
}

Definition at line 132 of file iff.c.

Referenced by decodeplane32().

◆ ff_iff_ilbm_decoder

const FFCodec ff_iff_ilbm_decoder
Initial value:
= {
.p.name = "iff",
CODEC_LONG_NAME("IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(IffContext),
.close = decode_end,
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 1902 of file iff.c.

decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: iff.c:337
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
LUT32
#define LUT32(plane)
Definition: iff.c:112
AV_CODEC_ID_IFF_ILBM
@ AV_CODEC_ID_IFF_ILBM
Definition: codec_id.h:188
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: iff.c:323
first
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
Definition: rate_distortion.txt:12
width
#define width
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
pixel
uint8_t pixel
Definition: tiny_ssim.c:41
LUT8
#define LUT8(plane)
Definition: iff.c:87
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_LE2NE64C
#define AV_LE2NE64C(x)
Definition: bswap.h:109
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: iff.c:1522
height
#define height
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
IffContext
Definition: iff.c:46
delta
float delta
Definition: vorbis_enc_data.h:430
U
#define U(x)
Definition: vpx_arith.h:37
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201