summaryrefslogtreecommitdiff
path: root/libavcodec/truemotion2.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2009-02-01 15:20:20 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2009-02-01 15:20:20 +0000
commita2a986371c94c6f294ecc31551ef5f3113910aa5 (patch)
tree128dc3fb352dfc4181b68d3f506f70b703d31b74 /libavcodec/truemotion2.c
parent3ffabd4e4967b3c41e0af7ae5a54d43a5625a78b (diff)
Factorize stream reading in TM2 decoder
Originally committed as revision 16917 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/truemotion2.c')
-rw-r--r--libavcodec/truemotion2.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 9651869273..ea87531973 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -757,13 +757,17 @@ static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p)
return keyframe;
}
+static const int tm2_stream_order[TM2_NUM_STREAMS] = {
+ TM2_C_HI, TM2_C_LO, TM2_L_HI, TM2_L_LO, TM2_UPD, TM2_MOT, TM2_TYPE
+};
+
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
TM2Context * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic;
- int skip, t;
+ int i, skip, t;
p->reference = 1;
p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
@@ -778,33 +782,13 @@ static int decode_frame(AVCodecContext *avctx,
if(skip == -1)
return -1;
- t = tm2_read_stream(l, buf + skip, TM2_C_HI);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_C_LO);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_L_HI);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_L_LO);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_UPD);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_MOT);
- if(t == -1)
- return -1;
- skip += t;
- t = tm2_read_stream(l, buf + skip, TM2_TYPE);
- if(t == -1)
- return -1;
+ for(i = 0; i < TM2_NUM_STREAMS; i++){
+ t = tm2_read_stream(l, buf + skip, tm2_stream_order[i]);
+ if(t == -1){
+ return -1;
+ }
+ skip += t;
+ }
p->key_frame = tm2_decode_blocks(l, p);
if(p->key_frame)
p->pict_type = FF_I_TYPE;