iff.c File Reference

IFF PBM/ILBM bitmap decoder. More...

#include "libavutil/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.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)
 

Functions

static av_always_inline uint32_t gray2rgb (const uint32_t x)
 
static int ff_cmap_read_palette (AVCodecContext *avctx, uint32_t *pal)
 Convert CMAP buffer (stored in extradata) to lavc palette format. More...
 
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 int decode_byterun (uint8_t *dst, int dst_size, const uint8_t *buf, const uint8_t *const buf_end)
 Decode one complete byterun1 encoded line. More...
 
static int decode_frame_ilbm (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 
static int decode_frame_byterun1 (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 
static av_cold int decode_end (AVCodecContext *avctx)
 

Variables

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

Detailed Description

IFF PBM/ILBM bitmap decoder.

Definition in file iff.c.

Macro Definition Documentation

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

Definition at line 84 of file iff.c.

#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), \
}
#define LUT8_PART(plane, v)
Definition: iff.c:41

Definition at line 59 of file iff.c.

#define LUT8_PART (   plane,
  v 
)
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
#define v(n)
Definition: regs.h:34
#define AV_LE2NE64C(x)
Definition: bswap.h:107

Definition at line 41 of file iff.c.

Function Documentation

static int decode_byterun ( uint8_t *  dst,
int  dst_size,
const uint8_t *  buf,
const uint8_t *const  buf_end 
)
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 227 of file iff.c.

Referenced by decode_frame_byterun1().

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 362 of file iff.c.

static int decode_frame_byterun1 ( AVCodecContext avctx,
void data,
int *  data_size,
AVPacket avpkt 
)
static

Definition at line 306 of file iff.c.

static int decode_frame_ilbm ( AVCodecContext avctx,
void data,
int *  data_size,
AVPacket avpkt 
)
static

Definition at line 249 of file iff.c.

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 149 of file iff.c.

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 200 of file iff.c.

Referenced by decode_frame_byterun1(), and decode_frame_ilbm().

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 183 of file iff.c.

Referenced by decode_frame_byterun1(), and decode_frame_ilbm().

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

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

Definition at line 123 of file iff.c.

Referenced by decode_frame_byterun1(), and decode_frame_ilbm().

static av_always_inline uint32_t gray2rgb ( const uint32_t  x)
static

Definition at line 116 of file iff.c.

Referenced by ff_cmap_read_palette().

Variable Documentation

AVCodec ff_iff_byterun1_decoder
Initial value:
= {
.name = "iff_byterun1",
.priv_data_size = sizeof(IffContext),
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("IFF ByteRun1"),
}
static int decode_frame_byterun1(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: iff.c:306
static av_cold int decode_end(AVCodecContext *avctx)
Definition: iff.c:362
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:336
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:719
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
Definition: iff.c:34
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:327
static av_cold int decode_init(AVCodecContext *avctx)
Definition: iff.c:149

Definition at line 383 of file iff.c.

AVCodec ff_iff_ilbm_decoder
Initial value:
= {
.name = "iff_ilbm",
.priv_data_size = sizeof(IffContext),
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"),
}
static av_cold int decode_end(AVCodecContext *avctx)
Definition: iff.c:362
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:336
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:719
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
Definition: iff.c:34
static int decode_frame_ilbm(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: iff.c:249
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:327
static av_cold int decode_init(AVCodecContext *avctx)
Definition: iff.c:149

Definition at line 371 of file iff.c.

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),
}
#define LUT32(plane)
Definition: iff.c:84

Definition at line 104 of file iff.c.

Referenced by decodeplane32().

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),
}
#define LUT8(plane)
Definition: iff.c:59

Definition at line 79 of file iff.c.

Referenced by decodeplane8().