truemotion2: cosmetics, reformat

This commit is contained in:
Anton Khirnov 2012-11-20 07:43:00 +01:00
parent df9036830b
commit 60a42ef44c

View File

@ -31,12 +31,29 @@
#define TM2_ESCAPE 0x80000000
#define TM2_DELTAS 64
/* Huffman-coded streams of different types of blocks */
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_STREAMS {
TM2_C_HI = 0,
TM2_C_LO,
TM2_L_HI,
TM2_L_LO,
TM2_UPD,
TM2_MOT,
TM2_TYPE,
TM2_NUM_STREAMS
};
/* Block types */
enum TM2_BLOCKS{ TM2_HI_RES = 0, TM2_MED_RES, TM2_LOW_RES, TM2_NULL_RES,
TM2_UPDATE, TM2_STILL, TM2_MOTION};
enum TM2_BLOCKS {
TM2_HI_RES = 0,
TM2_MED_RES,
TM2_LOW_RES,
TM2_NULL_RES,
TM2_UPDATE,
TM2_STILL,
TM2_MOTION
};
typedef struct TM2Context {
AVCodecContext *avctx;
@ -92,7 +109,8 @@ static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *
{
int ret;
if (length > huff->max_bits) {
av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n", huff->max_bits);
av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n",
huff->max_bits);
return AVERROR_INVALIDDATA;
}
@ -132,12 +150,13 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
/* check for correct codes parameters */
if ((huff.val_bits < 1) || (huff.val_bits > 32) ||
(huff.max_bits < 0) || (huff.max_bits > 25)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",
huff.val_bits, huff.max_bits);
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal "
"length: %i, max code length: %i\n", huff.val_bits, huff.max_bits);
return AVERROR_INVALIDDATA;
}
if ((huff.nodes <= 0) || (huff.nodes > 0x10000)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes);
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree "
"nodes: %i\n", huff.nodes);
return AVERROR_INVALIDDATA;
}
/* one-node tree */
@ -216,7 +235,8 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
}
}
static int tm2_read_deltas(TM2Context *ctx, int stream_id) {
static int tm2_read_deltas(TM2Context *ctx, int stream_id)
{
int d, mb;
int i, v;
@ -336,7 +356,8 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
return skip;
}
static inline int GET_TOK(TM2Context *ctx,int type) {
static inline int GET_TOK(TM2Context *ctx,int type)
{
if (ctx->tok_ptrs[type] >= ctx->tok_lens[type]) {
av_log(ctx->avctx, AV_LOG_ERROR, "Read token from stream %i out of bounds (%i>=%i)\n", type, ctx->tok_ptrs[type], ctx->tok_lens[type]);
return 0;
@ -610,8 +631,10 @@ static inline void tm2_update_block(TM2Context *ctx, AVFrame *pic, int bx, int b
U[i] = Uo[i] + GET_TOK(ctx, TM2_UPD);
V[i] = Vo[i] + GET_TOK(ctx, TM2_UPD);
}
U += Ustride; V += Vstride;
Uo += oUstride; Vo += oVstride;
U += Ustride;
V += Vstride;
Uo += oUstride;
Vo += oVstride;
}
U -= Ustride * 2;
V -= Vstride * 2;
@ -657,8 +680,10 @@ static inline void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int b
U[i] = Uo[i];
V[i] = Vo[i];
}
U += Ustride; V += Vstride;
Uo += oUstride; Vo += oVstride;
U += Ustride;
V += Vstride;
Uo += oUstride;
Vo += oVstride;
}
U -= Ustride * 2;
V -= Vstride * 2;
@ -809,11 +834,12 @@ static int decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
TM2Context * const l = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size & ~3;
TM2Context * const l = avctx->priv_data;
AVFrame * const p = &l->pic;
int i, offset = TM2_HEADER_SIZE, t, ret;
int offset = TM2_HEADER_SIZE;
int i, t, ret;
uint8_t *swbuf;
swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
@ -863,7 +889,8 @@ static int decode_frame(AVCodecContext *avctx,
return buf_size;
}
static av_cold int decode_init(AVCodecContext *avctx){
static av_cold int decode_init(AVCodecContext *avctx)
{
TM2Context * const l = avctx->priv_data;
int i, w = avctx->width, h = avctx->height;
@ -922,7 +949,8 @@ static av_cold int decode_init(AVCodecContext *avctx){
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx){
static av_cold int decode_end(AVCodecContext *avctx)
{
TM2Context * const l = avctx->priv_data;
AVFrame *pic = &l->pic;
int i;