FFmpeg
Data Structures | Macros | Functions | Variables
truemotion1.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "truemotion1data.h"

Go to the source code of this file.

Data Structures

struct  TrueMotion1Context
 
struct  frame_header
 
struct  comp_types
 

Macros

#define FLAG_SPRITE   32
 
#define FLAG_KEYFRAME   16
 
#define FLAG_INTERFRAME   8
 
#define FLAG_INTERPOLATED   4
 
#define ALGO_NOP   0
 
#define ALGO_RGB16V   1
 
#define ALGO_RGB16H   2
 
#define ALGO_RGB24H   3
 
#define BLOCK_2x2   0
 
#define BLOCK_2x4   1
 
#define BLOCK_4x2   2
 
#define BLOCK_4x4   3
 
#define GET_NEXT_INDEX()
 
#define INC_INDEX
 
#define APPLY_C_PREDICTOR()
 
#define APPLY_C_PREDICTOR_24()
 
#define APPLY_Y_PREDICTOR()
 
#define APPLY_Y_PREDICTOR_24()
 
#define OUTPUT_PIXEL_PAIR()
 

Functions

static void select_delta_tables (TrueMotion1Context *s, int delta_table_index)
 
static int make_ydt15_entry (int p1, int p2, int16_t *ydt)
 
static int make_cdt15_entry (int p1, int p2, int16_t *cdt)
 
static int make_ydt16_entry (int p1, int p2, int16_t *ydt)
 
static int make_cdt16_entry (int p1, int p2, int16_t *cdt)
 
static int make_ydt24_entry (int p1, int p2, int16_t *ydt)
 
static int make_cdt24_entry (int p1, int p2, int16_t *cdt)
 
static void gen_vector_table15 (TrueMotion1Context *s, const uint8_t *sel_vector_table)
 
static void gen_vector_table16 (TrueMotion1Context *s, const uint8_t *sel_vector_table)
 
static void gen_vector_table24 (TrueMotion1Context *s, const uint8_t *sel_vector_table)
 
static int truemotion1_decode_header (TrueMotion1Context *s)
 
static av_cold int truemotion1_decode_init (AVCodecContext *avctx)
 
static void truemotion1_decode_16bit (TrueMotion1Context *s)
 
static void truemotion1_decode_24bit (TrueMotion1Context *s)
 
static int truemotion1_decode_frame (AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
 
static av_cold int truemotion1_decode_end (AVCodecContext *avctx)
 

Variables

static const comp_types compression_types [17]
 
const FFCodec ff_truemotion1_decoder
 

Detailed Description

Duck TrueMotion v1 Video Decoder by Alex Beregszaszi and Mike Melanson (melan.nosp@m.son@.nosp@m.pcisy.nosp@m.s.ne.nosp@m.t)

The TrueMotion v1 decoder presently only decodes 16-bit TM1 data and outputs RGB555 (or RGB565) data. 24-bit TM1 data is not supported yet.

Definition in file truemotion1.c.

Macro Definition Documentation

◆ FLAG_SPRITE

#define FLAG_SPRITE   32

Definition at line 83 of file truemotion1.c.

◆ FLAG_KEYFRAME

#define FLAG_KEYFRAME   16

Definition at line 84 of file truemotion1.c.

◆ FLAG_INTERFRAME

#define FLAG_INTERFRAME   8

Definition at line 85 of file truemotion1.c.

◆ FLAG_INTERPOLATED

#define FLAG_INTERPOLATED   4

Definition at line 86 of file truemotion1.c.

◆ ALGO_NOP

#define ALGO_NOP   0

Definition at line 106 of file truemotion1.c.

◆ ALGO_RGB16V

#define ALGO_RGB16V   1

Definition at line 107 of file truemotion1.c.

◆ ALGO_RGB16H

#define ALGO_RGB16H   2

Definition at line 108 of file truemotion1.c.

◆ ALGO_RGB24H

#define ALGO_RGB24H   3

Definition at line 109 of file truemotion1.c.

◆ BLOCK_2x2

#define BLOCK_2x2   0

Definition at line 112 of file truemotion1.c.

◆ BLOCK_2x4

#define BLOCK_2x4   1

Definition at line 113 of file truemotion1.c.

◆ BLOCK_4x2

#define BLOCK_4x2   2

Definition at line 114 of file truemotion1.c.

◆ BLOCK_4x4

#define BLOCK_4x4   3

Definition at line 115 of file truemotion1.c.

◆ GET_NEXT_INDEX

#define GET_NEXT_INDEX ( )
Value:
{\
if (index_stream_index >= s->index_stream_size) { \
av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
return; \
} \
index = s->index_stream[index_stream_index++] * 4; \
}

Definition at line 532 of file truemotion1.c.

◆ INC_INDEX

#define INC_INDEX
Value:
do { \
if (index >= 1023) { \
av_log(s->avctx, AV_LOG_ERROR, "Invalid index value.\n"); \
return; \
} \
index++; \
} while (0)

Definition at line 541 of file truemotion1.c.

◆ APPLY_C_PREDICTOR

#define APPLY_C_PREDICTOR ( )
Value:
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
GET_NEXT_INDEX() \
if (!index) { \
GET_NEXT_INDEX() \
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += ((predictor_pair >> 1) * 5); \
if (predictor_pair & 1) \
GET_NEXT_INDEX() \
} \

Definition at line 550 of file truemotion1.c.

◆ APPLY_C_PREDICTOR_24

#define APPLY_C_PREDICTOR_24 ( )
Value:
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
GET_NEXT_INDEX() \
if (!index) { \
GET_NEXT_INDEX() \
predictor_pair = s->fat_c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \
GET_NEXT_INDEX() \
} \

Definition at line 567 of file truemotion1.c.

◆ APPLY_Y_PREDICTOR

#define APPLY_Y_PREDICTOR ( )
Value:
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
GET_NEXT_INDEX() \
if (!index) { \
GET_NEXT_INDEX() \
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += ((predictor_pair >> 1) * 5); \
if (predictor_pair & 1) \
GET_NEXT_INDEX() \
} \

Definition at line 585 of file truemotion1.c.

◆ APPLY_Y_PREDICTOR_24

#define APPLY_Y_PREDICTOR_24 ( )
Value:
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
GET_NEXT_INDEX() \
if (!index) { \
GET_NEXT_INDEX() \
predictor_pair = s->fat_y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \
GET_NEXT_INDEX() \
} \

Definition at line 602 of file truemotion1.c.

◆ OUTPUT_PIXEL_PAIR

#define OUTPUT_PIXEL_PAIR ( )
Value:
*current_pixel_pair = *vert_pred + horiz_pred; \
*vert_pred++ = *current_pixel_pair++;

Definition at line 619 of file truemotion1.c.

Function Documentation

◆ select_delta_tables()

static void select_delta_tables ( TrueMotion1Context s,
int  delta_table_index 
)
static

Definition at line 149 of file truemotion1.c.

Referenced by truemotion1_decode_header().

◆ make_ydt15_entry()

static int make_ydt15_entry ( int  p1,
int  p2,
int16_t *  ydt 
)
static

Definition at line 175 of file truemotion1.c.

Referenced by gen_vector_table15().

◆ make_cdt15_entry()

static int make_cdt15_entry ( int  p1,
int  p2,
int16_t *  cdt 
)
static

Definition at line 187 of file truemotion1.c.

Referenced by gen_vector_table15().

◆ make_ydt16_entry()

static int make_ydt16_entry ( int  p1,
int  p2,
int16_t *  ydt 
)
static

Definition at line 200 of file truemotion1.c.

Referenced by gen_vector_table16().

◆ make_cdt16_entry()

static int make_cdt16_entry ( int  p1,
int  p2,
int16_t *  cdt 
)
static

Definition at line 212 of file truemotion1.c.

Referenced by gen_vector_table16().

◆ make_ydt24_entry()

static int make_ydt24_entry ( int  p1,
int  p2,
int16_t *  ydt 
)
static

Definition at line 222 of file truemotion1.c.

Referenced by gen_vector_table24().

◆ make_cdt24_entry()

static int make_cdt24_entry ( int  p1,
int  p2,
int16_t *  cdt 
)
static

Definition at line 231 of file truemotion1.c.

Referenced by gen_vector_table24().

◆ gen_vector_table15()

static void gen_vector_table15 ( TrueMotion1Context s,
const uint8_t *  sel_vector_table 
)
static

Definition at line 240 of file truemotion1.c.

Referenced by truemotion1_decode_header().

◆ gen_vector_table16()

static void gen_vector_table16 ( TrueMotion1Context s,
const uint8_t *  sel_vector_table 
)
static

Definition at line 261 of file truemotion1.c.

Referenced by truemotion1_decode_header().

◆ gen_vector_table24()

static void gen_vector_table24 ( TrueMotion1Context s,
const uint8_t *  sel_vector_table 
)
static

Definition at line 282 of file truemotion1.c.

Referenced by truemotion1_decode_header().

◆ truemotion1_decode_header()

static int truemotion1_decode_header ( TrueMotion1Context s)
static

Definition at line 311 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

◆ truemotion1_decode_init()

static av_cold int truemotion1_decode_init ( AVCodecContext avctx)
static

Definition at line 481 of file truemotion1.c.

◆ truemotion1_decode_16bit()

static void truemotion1_decode_16bit ( TrueMotion1Context s)
static

Definition at line 623 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

◆ truemotion1_decode_24bit()

static void truemotion1_decode_24bit ( TrueMotion1Context s)
static

Definition at line 750 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

◆ truemotion1_decode_frame()

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

Definition at line 877 of file truemotion1.c.

◆ truemotion1_decode_end()

static av_cold int truemotion1_decode_end ( AVCodecContext avctx)
static

Definition at line 908 of file truemotion1.c.

Variable Documentation

◆ compression_types

const comp_types compression_types[17]
static
Initial value:
= {
{ ALGO_NOP, 0, 0, 0 },
{ ALGO_RGB16V, 4, 4, BLOCK_4x4 },
{ ALGO_RGB16H, 4, 4, BLOCK_4x4 },
{ ALGO_RGB16V, 4, 2, BLOCK_4x2 },
{ ALGO_RGB16H, 4, 2, BLOCK_4x2 },
{ ALGO_RGB16V, 2, 4, BLOCK_2x4 },
{ ALGO_RGB16H, 2, 4, BLOCK_2x4 },
{ ALGO_RGB16V, 2, 2, BLOCK_2x2 },
{ ALGO_RGB16H, 2, 2, BLOCK_2x2 },
{ ALGO_NOP, 4, 4, BLOCK_4x4 },
{ ALGO_RGB24H, 4, 4, BLOCK_4x4 },
{ ALGO_NOP, 4, 2, BLOCK_4x2 },
{ ALGO_RGB24H, 4, 2, BLOCK_4x2 },
{ ALGO_NOP, 2, 4, BLOCK_2x4 },
{ ALGO_RGB24H, 2, 4, BLOCK_2x4 },
{ ALGO_NOP, 2, 2, BLOCK_2x2 },
}

Definition at line 125 of file truemotion1.c.

Referenced by truemotion1_decode_frame(), and truemotion1_decode_header().

◆ ff_truemotion1_decoder

const FFCodec ff_truemotion1_decoder
Initial value:
= {
.p.name = "truemotion1",
CODEC_LONG_NAME("Duck TrueMotion 1.0"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(TrueMotion1Context),
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 918 of file truemotion1.c.

BLOCK_4x2
#define BLOCK_4x2
Definition: truemotion1.c:114
BLOCK_2x2
#define BLOCK_2x2
Definition: truemotion1.c:112
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
truemotion1_decode_init
static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
Definition: truemotion1.c:481
BLOCK_4x4
#define BLOCK_4x4
Definition: truemotion1.c:115
AV_CODEC_ID_TRUEMOTION1
@ AV_CODEC_ID_TRUEMOTION1
Definition: codec_id.h:103
BLOCK_2x4
#define BLOCK_2x4
Definition: truemotion1.c:113
ALGO_RGB16V
#define ALGO_RGB16V
Definition: truemotion1.c:107
ALGO_NOP
#define ALGO_NOP
Definition: truemotion1.c:106
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
TrueMotion1Context
Definition: truemotion1.c:46
s
#define s(width, name)
Definition: cbs_vp9.c:198
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
index
int index
Definition: gxfenc.c:90
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
ALGO_RGB16H
#define ALGO_RGB16H
Definition: truemotion1.c:108
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
truemotion1_decode_frame
static int truemotion1_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: truemotion1.c:877
INC_INDEX
#define INC_INDEX
Definition: truemotion1.c:541
truemotion1_decode_end
static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
Definition: truemotion1.c:908
ALGO_RGB24H
#define ALGO_RGB24H
Definition: truemotion1.c:109