FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
smacker.c File Reference
#include <stddef.h>
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"

Go to the source code of this file.

Data Structures

struct  SmackVContext
 
struct  HuffEntry
 
struct  HuffContext
 Context used for code reconstructing. More...
 
struct  DBCtx
 

Macros

#define SMKTREE_BITS   9
 
#define SMK_NODE   0x80000000
 
#define SMKTREE_DECODE_MAX_RECURSION   FFMIN(32, 3 * SMKTREE_BITS)
 
#define SMKTREE_DECODE_BIG_MAX_RECURSION   500
 
#define UNCHECKED_BITSTREAM_READER   1
 
#define BITSTREAM_READER_LE
 

Enumerations

enum  SmkBlockTypes { SMK_BLK_MONO = 0, SMK_BLK_FULL = 1, SMK_BLK_SKIP = 2, SMK_BLK_FILL = 3 }
 

Functions

static int smacker_decode_tree (AVCodecContext *avctx, GetBitContext *gb, HuffContext *hc, int length)
 Decode local frame tree. More...
 
static int smacker_decode_bigtree (AVCodecContext *avctx, GetBitContext *gb, DBCtx *ctx, int length)
 Decode header tree. More...
 
static int smacker_decode_header_tree (SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
 Store large tree as FFmpeg's vlc codes. More...
 
static int decode_header_trees (SmackVContext *smk)
 
static av_always_inline void last_reset (int *recode, int *last)
 
static av_always_inline int smk_get_code (GetBitContext *gb, int *recode, int *last)
 
static int decode_frame (AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
 
static av_cold int decode_end (AVCodecContext *avctx)
 
static av_cold int decode_init (AVCodecContext *avctx)
 
static av_cold int smka_decode_init (AVCodecContext *avctx)
 
static int smka_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 Decode Smacker audio data. More...
 

Variables

static const int block_runs [64]
 
const FFCodec ff_smacker_decoder
 
const FFCodec ff_smackaud_decoder
 

Detailed Description

Smacker decoder

Definition in file smacker.c.

Macro Definition Documentation

◆ SMKTREE_BITS

#define SMKTREE_BITS   9

Definition at line 38 of file smacker.c.

◆ SMK_NODE

#define SMK_NODE   0x80000000

Definition at line 39 of file smacker.c.

◆ SMKTREE_DECODE_MAX_RECURSION

#define SMKTREE_DECODE_MAX_RECURSION   FFMIN(32, 3 * SMKTREE_BITS)

Definition at line 41 of file smacker.c.

◆ SMKTREE_DECODE_BIG_MAX_RECURSION

#define SMKTREE_DECODE_BIG_MAX_RECURSION   500

Definition at line 42 of file smacker.c.

◆ UNCHECKED_BITSTREAM_READER

#define UNCHECKED_BITSTREAM_READER   1

Definition at line 49 of file smacker.c.

◆ BITSTREAM_READER_LE

#define BITSTREAM_READER_LE

Definition at line 51 of file smacker.c.

Enumeration Type Documentation

◆ SmkBlockTypes

Enumerator
SMK_BLK_MONO 
SMK_BLK_FULL 
SMK_BLK_SKIP 
SMK_BLK_FILL 

Definition at line 99 of file smacker.c.

Function Documentation

◆ smacker_decode_tree()

static int smacker_decode_tree ( AVCodecContext avctx,
GetBitContext gb,
HuffContext hc,
int  length 
)
static

Decode local frame tree.

Can read SMKTREE_DECODE_MAX_RECURSION before the first check; does not overread gb on success.

Definition at line 111 of file smacker.c.

Referenced by smacker_decode_header_tree(), and smka_decode_frame().

◆ smacker_decode_bigtree()

static int smacker_decode_bigtree ( AVCodecContext avctx,
GetBitContext gb,
DBCtx ctx,
int  length 
)
static

Decode header tree.

Checks before the first read, can overread by 6 * SMKTREE_BITS on success.

Definition at line 142 of file smacker.c.

Referenced by smacker_decode_header_tree().

◆ smacker_decode_header_tree()

static int smacker_decode_header_tree ( SmackVContext smk,
GetBitContext gb,
int **  recodes,
int *  last,
int  size 
)
static

Store large tree as FFmpeg's vlc codes.

Can read FFMAX(1 + SMKTREE_DECODE_MAX_RECURSION, 2 + 3 * 16) bits before the first check; can overread by 6 * SMKTREE_BITS + 1 on success.

Definition at line 198 of file smacker.c.

Referenced by decode_header_trees().

◆ decode_header_trees()

static int decode_header_trees ( SmackVContext smk)
static

Definition at line 274 of file smacker.c.

Referenced by decode_init().

◆ last_reset()

static av_always_inline void last_reset ( int *  recode,
int *  last 
)
static

Definition at line 346 of file smacker.c.

Referenced by decode_frame().

◆ smk_get_code()

static av_always_inline int smk_get_code ( GetBitContext gb,
int *  recode,
int *  last 
)
static

Definition at line 352 of file smacker.c.

Referenced by decode_frame().

◆ decode_frame()

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

Definition at line 373 of file smacker.c.

◆ decode_end()

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 536 of file smacker.c.

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 551 of file smacker.c.

◆ smka_decode_init()

static av_cold int smka_decode_init ( AVCodecContext avctx)
static

Definition at line 579 of file smacker.c.

◆ smka_decode_frame()

static int smka_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Decode Smacker audio data.

Definition at line 596 of file smacker.c.

Variable Documentation

◆ block_runs

const int block_runs[64]
static
Initial value:
= {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 128, 256, 512, 1024, 2048 }

Definition at line 89 of file smacker.c.

Referenced by decode_frame().

◆ ff_smacker_decoder

const FFCodec ff_smacker_decoder
Initial value:
= {
.p.name = "smackvid",
CODEC_LONG_NAME("Smacker video"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(SmackVContext),
.close = decode_end,
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 750 of file smacker.c.

◆ ff_smackaud_decoder

const FFCodec ff_smackaud_decoder
Initial value:
= {
.p.name = "smackaud",
CODEC_LONG_NAME("Smacker audio"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.capabilities = AV_CODEC_CAP_DR1,
}

Definition at line 763 of file smacker.c.

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:43
SmackVContext
Definition: smacker.c:57
AV_CODEC_ID_SMACKAUDIO
@ AV_CODEC_ID_SMACKAUDIO
Definition: codec_id.h:469
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: smacker.c:551
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
smka_decode_init
static av_cold int smka_decode_init(AVCodecContext *avctx)
Definition: smacker.c:579
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
smka_decode_frame
static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode Smacker audio data.
Definition: smacker.c:596
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: smacker.c:373
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: smacker.c:536
AV_CODEC_ID_SMACKVIDEO
@ AV_CODEC_ID_SMACKVIDEO
Definition: codec_id.h:135
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201