truemotion1.c File Reference

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) More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "avcodec.h"
#include "internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "truemotion1data.h"
Include dependency graph for truemotion1.c:

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 APPLY_C_PREDICTOR()
 
#define APPLY_C_PREDICTOR_24()
 
#define APPLY_Y_PREDICTOR()
 
#define APPLY_Y_PREDICTOR_24()
 
#define OUTPUT_PIXEL_PAIR()
 

Typedefs

typedef struct TrueMotion1Context TrueMotion1Context
 
typedef struct comp_types comp_types
 

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, void *data, int *got_frame, AVPacket *avpkt)
 
static av_cold int truemotion1_decode_end (AVCodecContext *avctx)
 

Variables

static const comp_types compression_types [17]
 
AVCodec 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

#define ALGO_NOP   0

Definition at line 105 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

#define ALGO_RGB16H   2

Definition at line 107 of file truemotion1.c.

#define ALGO_RGB16V   1

Definition at line 106 of file truemotion1.c.

#define ALGO_RGB24H   3

Definition at line 108 of file truemotion1.c.

Referenced by truemotion1_decode_frame(), and truemotion1_decode_header().

#define APPLY_C_PREDICTOR ( )
Value:
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
}\
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
if (!index) { \
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += ((predictor_pair >> 1) * 5); \
if (predictor_pair & 1) \
index++; \
} \
const char * s
Definition: avisynth_c.h:668
#define GET_NEXT_INDEX()
Definition: truemotion1.c:506
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
int index
Definition: gxfenc.c:89
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Definition at line 515 of file truemotion1.c.

Referenced by truemotion1_decode_16bit().

#define APPLY_C_PREDICTOR_24 ( )
Value:
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
}\
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
if (!index) { \
predictor_pair = s->fat_c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \
index++; \
} \
const char * s
Definition: avisynth_c.h:668
#define GET_NEXT_INDEX()
Definition: truemotion1.c:506
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
int index
Definition: gxfenc.c:89
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Definition at line 536 of file truemotion1.c.

Referenced by truemotion1_decode_24bit().

#define APPLY_Y_PREDICTOR ( )
Value:
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
}\
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
if (!index) { \
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += ((predictor_pair >> 1) * 5); \
if (predictor_pair & 1) \
index++; \
} \
const char * s
Definition: avisynth_c.h:668
#define GET_NEXT_INDEX()
Definition: truemotion1.c:506
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
int index
Definition: gxfenc.c:89
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Definition at line 558 of file truemotion1.c.

Referenced by truemotion1_decode_16bit().

#define APPLY_Y_PREDICTOR_24 ( )
Value:
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
}\
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
if (!index) { \
predictor_pair = s->fat_y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \
index++; \
} \
const char * s
Definition: avisynth_c.h:668
#define GET_NEXT_INDEX()
Definition: truemotion1.c:506
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
int index
Definition: gxfenc.c:89
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Definition at line 579 of file truemotion1.c.

Referenced by truemotion1_decode_24bit().

#define BLOCK_2x2   0

Definition at line 111 of file truemotion1.c.

Referenced by truemotion1_decode_16bit(), and truemotion1_decode_24bit().

#define BLOCK_2x4   1

Definition at line 112 of file truemotion1.c.

#define BLOCK_4x2   2

Definition at line 113 of file truemotion1.c.

Referenced by truemotion1_decode_16bit(), and truemotion1_decode_24bit().

#define BLOCK_4x4   3

Definition at line 114 of file truemotion1.c.

#define FLAG_INTERFRAME   8

Definition at line 84 of file truemotion1.c.

Referenced by truemotion1_decode_header().

#define FLAG_INTERPOLATED   4

Definition at line 85 of file truemotion1.c.

Referenced by truemotion1_decode_header().

#define FLAG_KEYFRAME   16
#define FLAG_SPRITE   32

Definition at line 82 of file truemotion1.c.

Referenced by truemotion1_decode_header().

#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"); \
} \
index = s->index_stream[index_stream_index++] * 4; \
}
const char * s
Definition: avisynth_c.h:668
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
int index
Definition: gxfenc.c:89
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return
#define AV_LOG_INFO
Definition: log.h:156

Definition at line 506 of file truemotion1.c.

Referenced by truemotion1_decode_16bit(), and truemotion1_decode_24bit().

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

Definition at line 600 of file truemotion1.c.

Referenced by truemotion1_decode_16bit(), and truemotion1_decode_24bit().

Typedef Documentation

typedef struct comp_types comp_types

Function Documentation

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

Definition at line 239 of file truemotion1.c.

Referenced by truemotion1_decode_header().

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

Definition at line 260 of file truemotion1.c.

Referenced by truemotion1_decode_header().

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

Definition at line 281 of file truemotion1.c.

Referenced by truemotion1_decode_header().

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

Definition at line 186 of file truemotion1.c.

Referenced by gen_vector_table15().

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

Definition at line 211 of file truemotion1.c.

Referenced by gen_vector_table16().

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

Definition at line 230 of file truemotion1.c.

Referenced by gen_vector_table24().

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

Definition at line 174 of file truemotion1.c.

Referenced by gen_vector_table15(), and select_delta_tables().

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

Definition at line 199 of file truemotion1.c.

Referenced by gen_vector_table16(), and make_cdt15_entry().

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

Definition at line 221 of file truemotion1.c.

Referenced by gen_vector_table24().

static void select_delta_tables ( TrueMotion1Context s,
int  delta_table_index 
)
static

Definition at line 148 of file truemotion1.c.

Referenced by truemotion1_decode_header().

static void truemotion1_decode_16bit ( TrueMotion1Context s)
static

Definition at line 604 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

static void truemotion1_decode_24bit ( TrueMotion1Context s)
static

Definition at line 730 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

static av_cold int truemotion1_decode_end ( AVCodecContext avctx)
static

Definition at line 889 of file truemotion1.c.

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

Definition at line 857 of file truemotion1.c.

static int truemotion1_decode_header ( TrueMotion1Context s)
static

Definition at line 310 of file truemotion1.c.

Referenced by truemotion1_decode_frame().

static av_cold int truemotion1_decode_init ( AVCodecContext avctx)
static

Definition at line 459 of file truemotion1.c.

Variable Documentation

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 },
{ ALGO_RGB24H, 2, 2, BLOCK_2x2 }
}
#define BLOCK_4x2
Definition: truemotion1.c:113
#define ALGO_RGB16V
Definition: truemotion1.c:106
#define ALGO_NOP
Definition: truemotion1.c:105
#define ALGO_RGB16H
Definition: truemotion1.c:107
#define ALGO_RGB24H
Definition: truemotion1.c:108
#define BLOCK_2x2
Definition: truemotion1.c:111
#define BLOCK_4x4
Definition: truemotion1.c:114
#define BLOCK_2x4
Definition: truemotion1.c:112

Definition at line 124 of file truemotion1.c.

AVCodec ff_truemotion1_decoder
Initial value:
= {
.name = "truemotion1",
.priv_data_size = sizeof(TrueMotion1Context),
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"),
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
Definition: truemotion1.c:889
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
struct TrueMotion1Context TrueMotion1Context
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
Definition: truemotion1.c:459
static int truemotion1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: truemotion1.c:857
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: crystalhd.c:868

Definition at line 899 of file truemotion1.c.