FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
truemotion2.c File Reference
#include <inttypes.h>
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  TM2Context
 
struct  TM2Codes
 Huffman codes for each of streams. More...
 
struct  TM2Huff
 structure for gathering Huffman codes information More...
 

Macros

#define TM2_ESCAPE   0x80000000
 
#define TM2_DELTAS   64
 
#define TM2_OLD_HEADER_MAGIC   0x00000100
 
#define TM2_NEW_HEADER_MAGIC   0x00000101
 
#define TM2_INIT_POINTERS()
 
#define TM2_INIT_POINTERS_2()
 
#define TM2_RECALC_BLOCK(CHR, stride, last, CD)
 
#define TM2_HEADER_SIZE   40
 

Enumerations

enum  TM2_STREAMS {
  TM2_C_HI = 0, TM2_C_LO, TM2_L_HI, TM2_L_LO,
  TM2_UPD, TM2_MOT, TM2_TYPE, TM2_NUM_STREAMS
}
 
enum  TM2_BLOCKS {
  TM2_HI_RES = 0, TM2_MED_RES, TM2_LOW_RES, TM2_NULL_RES,
  TM2_UPDATE, TM2_STILL, TM2_MOTION
}
 

Functions

static int tm2_read_tree (TM2Context *ctx, int length, TM2Huff *huff)
 
static int tm2_build_huff_table (TM2Context *ctx, TM2Codes *code)
 
static void tm2_free_codes (TM2Codes *code)
 
static int tm2_get_token (GetBitContext *gb, TM2Codes *code)
 
static int tm2_read_header (TM2Context *ctx, const uint8_t *buf)
 
static int tm2_read_deltas (TM2Context *ctx, int stream_id)
 
static int tm2_read_stream (TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
 
static int GET_TOK (TM2Context *ctx, int type)
 
static void tm2_apply_deltas (TM2Context *ctx, int *Y, int stride, int *deltas, int *last)
 
static void tm2_high_chroma (int *data, int stride, int *last, unsigned *CD, int *deltas)
 
static void tm2_low_chroma (int *data, int stride, int *clast, unsigned *CD, int *deltas, int bx)
 
static void tm2_hi_res_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_med_res_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_low_res_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_null_res_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_still_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_update_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static void tm2_motion_block (TM2Context *ctx, AVFrame *pic, int bx, int by)
 
static int tm2_decode_blocks (TM2Context *ctx, AVFrame *p)
 
static int decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
static av_cold int decode_init (AVCodecContext *avctx)
 
static av_cold int decode_end (AVCodecContext *avctx)
 

Variables

static const int tm2_stream_order [TM2_NUM_STREAMS]
 
AVCodec ff_truemotion2_decoder
 

Detailed Description

Duck TrueMotion2 decoder.

Definition in file truemotion2.c.

Macro Definition Documentation

◆ TM2_ESCAPE

#define TM2_ESCAPE   0x80000000

Definition at line 35 of file truemotion2.c.

◆ TM2_DELTAS

#define TM2_DELTAS   64

Definition at line 36 of file truemotion2.c.

◆ TM2_OLD_HEADER_MAGIC

#define TM2_OLD_HEADER_MAGIC   0x00000100

Definition at line 237 of file truemotion2.c.

◆ TM2_NEW_HEADER_MAGIC

#define TM2_NEW_HEADER_MAGIC   0x00000101

Definition at line 238 of file truemotion2.c.

◆ TM2_INIT_POINTERS

#define TM2_INIT_POINTERS ( )
Value:
int *last, *clast; \
int *Y, *U, *V;\
int Ystride, Ustride, Vstride;\
\
Ystride = ctx->y_stride;\
Vstride = ctx->uv_stride;\
Ustride = ctx->uv_stride;\
Y = (ctx->cur?ctx->Y2:ctx->Y1) + by * 4 * Ystride + bx * 4;\
V = (ctx->cur?ctx->V2:ctx->V1) + by * 2 * Vstride + bx * 2;\
U = (ctx->cur?ctx->U2:ctx->U1) + by * 2 * Ustride + bx * 2;\
last = ctx->last + bx * 4;\
clast = ctx->clast + bx * 4;

Definition at line 420 of file truemotion2.c.

◆ TM2_INIT_POINTERS_2

#define TM2_INIT_POINTERS_2 ( )
Value:
unsigned *Yo, *Uo, *Vo;\
int oYstride, oUstride, oVstride;\
oYstride = Ystride;\
oVstride = Vstride;\
oUstride = Ustride;\
Yo = (ctx->cur?ctx->Y1:ctx->Y2) + by * 4 * oYstride + bx * 4;\
Vo = (ctx->cur?ctx->V1:ctx->V2) + by * 2 * oVstride + bx * 2;\
Uo = (ctx->cur?ctx->U1:ctx->U2) + by * 2 * oUstride + bx * 2;

Definition at line 434 of file truemotion2.c.

◆ TM2_RECALC_BLOCK

#define TM2_RECALC_BLOCK (   CHR,
  stride,
  last,
  CD 
)
Value:
{\
CD[0] = (unsigned)CHR[ 1] - (unsigned)last[1];\
CD[1] = (unsigned)CHR[stride + 1] - (unsigned) CHR[1];\
last[0] = (int)CHR[stride + 0];\
last[1] = (int)CHR[stride + 1];}

Definition at line 447 of file truemotion2.c.

◆ TM2_HEADER_SIZE

#define TM2_HEADER_SIZE   40

Definition at line 886 of file truemotion2.c.

Enumeration Type Documentation

◆ TM2_STREAMS

Enumerator
TM2_C_HI 
TM2_C_LO 
TM2_L_HI 
TM2_L_LO 
TM2_UPD 
TM2_MOT 
TM2_TYPE 
TM2_NUM_STREAMS 

Definition at line 39 of file truemotion2.c.

◆ TM2_BLOCKS

enum TM2_BLOCKS
Enumerator
TM2_HI_RES 
TM2_MED_RES 
TM2_LOW_RES 
TM2_NULL_RES 
TM2_UPDATE 
TM2_STILL 
TM2_MOTION 

Definition at line 51 of file truemotion2.c.

Function Documentation

◆ tm2_read_tree()

static int tm2_read_tree ( TM2Context ctx,
int  length,
TM2Huff huff 
)
static
Returns
the length of the longest code or an AVERROR code

Definition at line 118 of file truemotion2.c.

Referenced by tm2_build_huff_table().

◆ tm2_build_huff_table()

static int tm2_build_huff_table ( TM2Context ctx,
TM2Codes code 
)
static

Definition at line 148 of file truemotion2.c.

Referenced by tm2_read_stream().

◆ tm2_free_codes()

static void tm2_free_codes ( TM2Codes code)
static

Definition at line 221 of file truemotion2.c.

Referenced by tm2_read_stream().

◆ tm2_get_token()

static int tm2_get_token ( GetBitContext gb,
TM2Codes code 
)
inlinestatic

Definition at line 228 of file truemotion2.c.

Referenced by tm2_read_stream().

◆ tm2_read_header()

static int tm2_read_header ( TM2Context ctx,
const uint8_t buf 
)
inlinestatic

Definition at line 240 of file truemotion2.c.

Referenced by decode_frame().

◆ tm2_read_deltas()

static int tm2_read_deltas ( TM2Context ctx,
int  stream_id 
)
static

Definition at line 257 of file truemotion2.c.

Referenced by tm2_read_stream().

◆ tm2_read_stream()

static int tm2_read_stream ( TM2Context ctx,
const uint8_t buf,
int  stream_id,
int  buf_size 
)
static

Definition at line 284 of file truemotion2.c.

Referenced by decode_frame().

◆ GET_TOK()

static int GET_TOK ( TM2Context ctx,
int  type 
)
inlinestatic

◆ tm2_apply_deltas()

static void tm2_apply_deltas ( TM2Context ctx,
int Y,
int  stride,
int deltas,
int last 
)
inlinestatic

◆ tm2_high_chroma()

static void tm2_high_chroma ( int data,
int  stride,
int last,
unsigned *  CD,
int deltas 
)
inlinestatic

Definition at line 472 of file truemotion2.c.

Referenced by tm2_hi_res_block(), and tm2_low_chroma().

◆ tm2_low_chroma()

static void tm2_low_chroma ( int data,
int  stride,
int clast,
unsigned *  CD,
int deltas,
int  bx 
)
inlinestatic

Definition at line 485 of file truemotion2.c.

Referenced by tm2_low_res_block(), tm2_med_res_block(), and tm2_null_res_block().

◆ tm2_hi_res_block()

static void tm2_hi_res_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 504 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_med_res_block()

static void tm2_med_res_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 525 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_low_res_block()

static void tm2_low_res_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 547 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_null_res_block()

static void tm2_null_res_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 588 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_still_block()

static void tm2_still_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 635 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_update_block()

static void tm2_update_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 670 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_motion_block()

static void tm2_motion_block ( TM2Context ctx,
AVFrame pic,
int  bx,
int  by 
)
inlinestatic

Definition at line 710 of file truemotion2.c.

Referenced by tm2_decode_blocks().

◆ tm2_decode_blocks()

static int tm2_decode_blocks ( TM2Context ctx,
AVFrame p 
)
static

Definition at line 764 of file truemotion2.c.

Referenced by decode_frame().

◆ decode_frame()

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

Definition at line 888 of file truemotion2.c.

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 946 of file truemotion2.c.

◆ decode_end()

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 992 of file truemotion2.c.

Variable Documentation

◆ tm2_stream_order

const int tm2_stream_order[TM2_NUM_STREAMS]
static
Initial value:

Definition at line 882 of file truemotion2.c.

Referenced by decode_frame().

◆ ff_truemotion2_decoder

AVCodec ff_truemotion2_decoder
Initial value:
= {
.name = "truemotion2",
.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0"),
.priv_data_size = sizeof(TM2Context),
.close = decode_end,
.capabilities = AV_CODEC_CAP_DR1,
}

Definition at line 1011 of file truemotion2.c.

AV_CODEC_ID_TRUEMOTION2
@ AV_CODEC_ID_TRUEMOTION2
Definition: codec_id.h:126
stride
int stride
Definition: mace.c:144
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:41
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
TM2_INIT_POINTERS
#define TM2_INIT_POINTERS()
Definition: truemotion2.c:420
TM2_MOT
@ TM2_MOT
Definition: truemotion2.c:45
TM2_C_HI
@ TM2_C_HI
Definition: truemotion2.c:40
TM2_UPD
@ TM2_UPD
Definition: truemotion2.c:44
U
#define U(x)
Definition: vp56_arith.h:37
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
TM2_C_LO
@ TM2_C_LO
Definition: truemotion2.c:41
ctx
AVFormatContext * ctx
Definition: movenc.c:48
TM2_L_LO
@ TM2_L_LO
Definition: truemotion2.c:43
TM2Context
Definition: truemotion2.c:61
V
#define V
Definition: avdct.c:30
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
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: truemotion2.c:888
Y
#define Y
Definition: boxblur.h:38
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: internal.h:49
TM2_L_HI
@ TM2_L_HI
Definition: truemotion2.c:42
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: truemotion2.c:992
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: truemotion2.c:946
int
int
Definition: ffmpeg_filter.c:170
TM2_TYPE
@ TM2_TYPE
Definition: truemotion2.c:46