Mercurial > libavcodec.hg
annotate truemotion2.c @ 4490:0efc832d9102 libavcodec
wma encoder
author | michael |
---|---|
date | Tue, 06 Feb 2007 20:19:04 +0000 |
parents | 05e932ddaaa9 |
children | a96d905dcbaa |
rev | line source |
---|---|
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
1 /* |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
2 * Duck/ON2 TrueMotion 2 Decoder |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2005 Konstantin Shishkov |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
16 * |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
20 * |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
21 */ |
2967 | 22 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
23 /** |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
24 * @file truemotion2.c |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
25 * Duck TrueMotion2 decoder. |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
26 */ |
2967 | 27 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
28 #include "avcodec.h" |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
29 #include "common.h" |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
30 #include "bitstream.h" |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
31 #include "dsputil.h" |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
32 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
33 #define TM2_ESCAPE 0x80000000 |
2910 | 34 #define TM2_DELTAS 64 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
35 /* Huffman-coded streams of different types of blocks */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
36 enum TM2_STREAMS{ TM2_C_HI = 0, TM2_C_LO, TM2_L_HI, TM2_L_LO, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
37 TM2_UPD, TM2_MOT, TM2_TYPE, TM2_NUM_STREAMS}; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
38 /* Block types */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
39 enum TM2_BLOCKS{ TM2_HI_RES = 0, TM2_MED_RES, TM2_LOW_RES, TM2_NULL_RES, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
40 TM2_UPDATE, TM2_STILL, TM2_MOTION}; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
41 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
42 typedef struct TM2Context{ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
43 AVCodecContext *avctx; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
44 AVFrame pic; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
45 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
46 GetBitContext gb; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
47 DSPContext dsp; |
2967 | 48 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
49 /* TM2 streams */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
50 int *tokens[TM2_NUM_STREAMS]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
51 int tok_lens[TM2_NUM_STREAMS]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
52 int tok_ptrs[TM2_NUM_STREAMS]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
53 int deltas[TM2_NUM_STREAMS][TM2_DELTAS]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
54 /* for blocks decoding */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
55 int D[4]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
56 int CD[4]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
57 int *last; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
58 int *clast; |
2967 | 59 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
60 /* data for current and previous frame */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
61 int *Y1, *U1, *V1, *Y2, *U2, *V2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
62 int cur; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
63 } TM2Context; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
64 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
65 /** |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
66 * Huffman codes for each of streams |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
67 */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
68 typedef struct TM2Codes{ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
69 VLC vlc; ///< table for FFmpeg bitstream reader |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
70 int bits; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
71 int *recode; ///< table for converting from code indexes to values |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
72 int length; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
73 } TM2Codes; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
74 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
75 /** |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
76 * structure for gathering Huffman codes information |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
77 */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
78 typedef struct TM2Huff{ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
79 int val_bits; ///< length of literal |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
80 int max_bits; ///< maximum length of code |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
81 int min_bits; ///< minimum length of code |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
82 int nodes; ///< total number of nodes in tree |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
83 int num; ///< current number filled |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
84 int max_num; ///< total number of codes |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
85 int *nums; ///< literals |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
86 uint32_t *bits; ///< codes |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
87 int *lens; ///< codelengths |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
88 } TM2Huff; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
89 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
90 static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
91 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
92 if(length > huff->max_bits) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
93 av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n", huff->max_bits); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
94 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
95 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
96 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
97 if(!get_bits1(&ctx->gb)) { /* literal */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
98 if (length == 0) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
99 length = 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
100 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
101 if(huff->num >= huff->max_num) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
102 av_log(ctx->avctx, AV_LOG_DEBUG, "Too many literals\n"); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
103 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
104 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
105 huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
106 huff->bits[huff->num] = prefix; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
107 huff->lens[huff->num] = length; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
108 huff->num++; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
109 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
110 } else { /* non-terminal node */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
111 if(tm2_read_tree(ctx, prefix << 1, length + 1, huff) == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
112 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
113 if(tm2_read_tree(ctx, (prefix << 1) | 1, length + 1, huff) == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
114 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
115 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
116 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
117 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
118 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
119 static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
120 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
121 TM2Huff huff; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
122 int res = 0; |
2967 | 123 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
124 huff.val_bits = get_bits(&ctx->gb, 5); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
125 huff.max_bits = get_bits(&ctx->gb, 5); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
126 huff.min_bits = get_bits(&ctx->gb, 5); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
127 huff.nodes = get_bits_long(&ctx->gb, 17); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
128 huff.num = 0; |
2967 | 129 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
130 /* check for correct codes parameters */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
131 if((huff.val_bits < 1) || (huff.val_bits > 32) || |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
132 (huff.max_bits < 0) || (huff.max_bits > 32)) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
133 av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n", |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
134 huff.val_bits, huff.max_bits); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
135 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
136 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
137 if((huff.nodes < 0) || (huff.nodes > 0x10000)) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
138 av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
139 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
140 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
141 /* one-node tree */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
142 if(huff.max_bits == 0) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
143 huff.max_bits = 1; |
2967 | 144 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
145 /* allocate space for codes - it is exactly ceil(nodes / 2) entries */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
146 huff.max_num = (huff.nodes + 1) >> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
147 huff.nums = av_mallocz(huff.max_num * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
148 huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
149 huff.lens = av_mallocz(huff.max_num * sizeof(int)); |
2967 | 150 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
151 if(tm2_read_tree(ctx, 0, 0, &huff) == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
152 res = -1; |
2967 | 153 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
154 if(huff.num != huff.max_num) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
155 av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\n", |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
156 huff.num, huff.max_num); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
157 res = -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
158 } |
2967 | 159 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
160 /* convert codes to vlc_table */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
161 if(res != -1) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
162 int i; |
2967 | 163 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
164 res = init_vlc(&code->vlc, huff.max_bits, huff.max_num, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
165 huff.lens, sizeof(int), sizeof(int), |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
166 huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
167 if(res < 0) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
168 av_log(ctx->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
169 res = -1; |
2967 | 170 } else |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
171 res = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
172 if(res != -1) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
173 code->bits = huff.max_bits; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
174 code->length = huff.max_num; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
175 code->recode = av_malloc(code->length * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
176 for(i = 0; i < code->length; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
177 code->recode[i] = huff.nums[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
178 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
179 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
180 /* free allocated memory */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
181 av_free(huff.nums); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
182 av_free(huff.bits); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
183 av_free(huff.lens); |
2967 | 184 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
185 return res; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
186 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
187 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
188 static void tm2_free_codes(TM2Codes *code) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
189 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
190 if(code->recode) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
191 av_free(code->recode); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
192 if(code->vlc.table) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
193 free_vlc(&code->vlc); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
194 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
195 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
196 static inline int tm2_get_token(GetBitContext *gb, TM2Codes *code) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
197 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
198 int val; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
199 val = get_vlc2(gb, code->vlc.table, code->bits, 1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
200 return code->recode[val]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
201 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
202 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
203 static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
204 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
205 uint32_t magic; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
206 uint8_t *obuf; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
207 int length; |
2967 | 208 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
209 obuf = buf; |
2967 | 210 |
4364 | 211 magic = AV_RL32(buf); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
212 buf += 4; |
2967 | 213 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
214 if(magic == 0x00000100) { /* old header */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
215 /* av_log (ctx->avctx, AV_LOG_ERROR, "TM2 old header: not implemented (yet)\n"); */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
216 return 40; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
217 } else if(magic == 0x00000101) { /* new header */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
218 int w, h, size, flags, xr, yr; |
2967 | 219 |
4364 | 220 length = AV_RL32(buf); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
221 buf += 4; |
2967 | 222 |
2910 | 223 init_get_bits(&ctx->gb, buf, 32 * 8); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
224 size = get_bits_long(&ctx->gb, 31); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
225 h = get_bits(&ctx->gb, 15); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
226 w = get_bits(&ctx->gb, 15); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
227 flags = get_bits_long(&ctx->gb, 31); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
228 yr = get_bits(&ctx->gb, 9); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
229 xr = get_bits(&ctx->gb, 9); |
2967 | 230 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
231 return 40; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
232 } else { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
233 av_log (ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
234 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
235 } |
2967 | 236 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
237 return (buf - obuf); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
238 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
239 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
240 static int tm2_read_deltas(TM2Context *ctx, int stream_id) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
241 int d, mb; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
242 int i, v; |
2967 | 243 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
244 d = get_bits(&ctx->gb, 9); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
245 mb = get_bits(&ctx->gb, 5); |
2967 | 246 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
247 if((d < 1) || (d > TM2_DELTAS) || (mb < 1) || (mb > 32)) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
248 av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
249 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
250 } |
2967 | 251 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
252 for(i = 0; i < d; i++) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
253 v = get_bits_long(&ctx->gb, mb); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
254 if(v & (1 << (mb - 1))) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
255 ctx->deltas[stream_id][i] = v - (1 << mb); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
256 else |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
257 ctx->deltas[stream_id][i] = v; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
258 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
259 for(; i < TM2_DELTAS; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
260 ctx->deltas[stream_id][i] = 0; |
2967 | 261 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
262 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
263 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
264 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
265 static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
266 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
267 int cur = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
268 int skip = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
269 int len, toks; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
270 TM2Codes codes; |
2967 | 271 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
272 /* get stream length in dwords */ |
4364 | 273 len = AV_RB32(buf); buf += 4; cur += 4; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
274 skip = len * 4 + 4; |
2967 | 275 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
276 if(len == 0) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
277 return 4; |
2967 | 278 |
4364 | 279 toks = AV_RB32(buf); buf += 4; cur += 4; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
280 if(toks & 1) { |
4364 | 281 len = AV_RB32(buf); buf += 4; cur += 4; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
282 if(len == TM2_ESCAPE) { |
4364 | 283 len = AV_RB32(buf); buf += 4; cur += 4; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
284 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
285 if(len > 0) { |
2910 | 286 init_get_bits(&ctx->gb, buf, (skip - cur) * 8); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
287 if(tm2_read_deltas(ctx, stream_id) == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
288 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
289 buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
290 cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
291 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
292 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
293 /* skip unused fields */ |
4364 | 294 if(AV_RB32(buf) == TM2_ESCAPE) { |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
295 buf += 4; cur += 4; /* some unknown length - could be escaped too */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
296 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
297 buf += 4; cur += 4; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
298 buf += 4; cur += 4; /* unused by decoder */ |
2967 | 299 |
2910 | 300 init_get_bits(&ctx->gb, buf, (skip - cur) * 8); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
301 if(tm2_build_huff_table(ctx, &codes) == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
302 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
303 buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
304 cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; |
2967 | 305 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
306 toks >>= 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
307 /* check if we have sane number of tokens */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
308 if((toks < 0) || (toks > 0xFFFFFF)){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
309 av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
310 tm2_free_codes(&codes); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
311 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
312 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
313 ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
314 ctx->tok_lens[stream_id] = toks; |
4364 | 315 len = AV_RB32(buf); buf += 4; cur += 4; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
316 if(len > 0) { |
2910 | 317 init_get_bits(&ctx->gb, buf, (skip - cur) * 8); |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
318 for(i = 0; i < toks; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
319 ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
320 } else { |
2910 | 321 for(i = 0; i < toks; i++) |
322 ctx->tokens[stream_id][i] = codes.recode[0]; | |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
323 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
324 tm2_free_codes(&codes); |
2967 | 325 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
326 return skip; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
327 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
328 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
329 static inline int GET_TOK(TM2Context *ctx,int type) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
330 if(ctx->tok_ptrs[type] >= ctx->tok_lens[type]) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
331 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]); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
332 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
333 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
334 if(type <= TM2_MOT) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
335 return ctx->deltas[type][ctx->tokens[type][ctx->tok_ptrs[type]++]]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
336 return ctx->tokens[type][ctx->tok_ptrs[type]++]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
337 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
338 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
339 /* blocks decoding routines */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
340 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
341 /* common Y, U, V pointers initialisation */ |
2908 | 342 #define TM2_INIT_POINTERS() \ |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
343 int *last, *clast; \ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
344 int *Y, *U, *V;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
345 int Ystride, Ustride, Vstride;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
346 \ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
347 Ystride = ctx->avctx->width;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
348 Vstride = (ctx->avctx->width + 1) >> 1;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
349 Ustride = (ctx->avctx->width + 1) >> 1;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
350 Y = (ctx->cur?ctx->Y2:ctx->Y1) + by * 4 * Ystride + bx * 4;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
351 V = (ctx->cur?ctx->V2:ctx->V1) + by * 2 * Vstride + bx * 2;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
352 U = (ctx->cur?ctx->U2:ctx->U1) + by * 2 * Ustride + bx * 2;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
353 last = ctx->last + bx * 4;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
354 clast = ctx->clast + bx * 4; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
355 |
2908 | 356 #define TM2_INIT_POINTERS_2() \ |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
357 int *Yo, *Uo, *Vo;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
358 int oYstride, oUstride, oVstride;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
359 \ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
360 TM2_INIT_POINTERS();\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
361 oYstride = Ystride;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
362 oVstride = Vstride;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
363 oUstride = Ustride;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
364 Yo = (ctx->cur?ctx->Y1:ctx->Y2) + by * 4 * oYstride + bx * 4;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
365 Vo = (ctx->cur?ctx->V1:ctx->V2) + by * 2 * oVstride + bx * 2;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
366 Uo = (ctx->cur?ctx->U1:ctx->U2) + by * 2 * oUstride + bx * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
367 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
368 /* recalculate last and delta values for next blocks */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
369 #define TM2_RECALC_BLOCK(CHR, stride, last, CD) {\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
370 CD[0] = (CHR[1] - 128) - last[1];\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
371 CD[1] = (int)CHR[stride + 1] - (int)CHR[1];\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
372 last[0] = (int)CHR[stride + 0] - 128;\ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
373 last[1] = (int)CHR[stride + 1] - 128;} |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
374 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
375 /* common operations - add deltas to 4x4 block of luma or 2x2 blocks of chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
376 static inline void tm2_apply_deltas(TM2Context *ctx, int* Y, int stride, int *deltas, int *last) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
377 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
378 int ct, d; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
379 int i, j; |
2967 | 380 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
381 for(j = 0; j < 4; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
382 ct = ctx->D[j]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
383 for(i = 0; i < 4; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
384 d = deltas[i + j * 4]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
385 ct += d; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
386 last[i] += ct; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
387 Y[i] = clip_uint8(last[i]); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
388 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
389 Y += stride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
390 ctx->D[j] = ct; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
391 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
392 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
393 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
394 static inline void tm2_high_chroma(int *data, int stride, int *last, int *CD, int *deltas) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
395 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
396 int i, j; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
397 for(j = 0; j < 2; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
398 for(i = 0; i < 2; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
399 CD[j] += deltas[i + j * 2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
400 last[i] += CD[j]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
401 data[i] = last[i] + 128; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
402 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
403 data += stride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
404 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
405 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
406 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
407 static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, int *deltas, int bx) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
408 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
409 int t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
410 int l; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
411 int prev; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
412 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
413 if(bx > 0) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
414 prev = clast[-3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
415 else |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
416 prev = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
417 t = (CD[0] + CD[1]) >> 1; |
2912 | 418 l = (prev - CD[0] - CD[1] + clast[1]) >> 1; |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
419 CD[1] = CD[0] + CD[1] - t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
420 CD[0] = t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
421 clast[0] = l; |
2967 | 422 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
423 tm2_high_chroma(data, stride, clast, CD, deltas); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
424 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
425 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
426 static inline void tm2_hi_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
427 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
428 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
429 int deltas[16]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
430 TM2_INIT_POINTERS(); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
431 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
432 /* hi-res chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
433 for(i = 0; i < 4; i++) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
434 deltas[i] = GET_TOK(ctx, TM2_C_HI); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
435 deltas[i + 4] = GET_TOK(ctx, TM2_C_HI); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
436 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
437 tm2_high_chroma(U, Ustride, clast, ctx->CD, deltas); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
438 tm2_high_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas + 4); |
2967 | 439 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
440 /* hi-res luma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
441 for(i = 0; i < 16; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
442 deltas[i] = GET_TOK(ctx, TM2_L_HI); |
2967 | 443 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
444 tm2_apply_deltas(ctx, Y, Ystride, deltas, last); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
445 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
446 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
447 static inline void tm2_med_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
448 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
449 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
450 int deltas[16]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
451 TM2_INIT_POINTERS(); |
2967 | 452 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
453 /* low-res chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
454 deltas[0] = GET_TOK(ctx, TM2_C_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
455 deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
456 tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
457 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
458 deltas[0] = GET_TOK(ctx, TM2_C_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
459 deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
460 tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
461 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
462 /* hi-res luma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
463 for(i = 0; i < 16; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
464 deltas[i] = GET_TOK(ctx, TM2_L_HI); |
2967 | 465 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
466 tm2_apply_deltas(ctx, Y, Ystride, deltas, last); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
467 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
468 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
469 static inline void tm2_low_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
470 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
471 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
472 int t1, t2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
473 int deltas[16]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
474 TM2_INIT_POINTERS(); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
475 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
476 /* low-res chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
477 deltas[0] = GET_TOK(ctx, TM2_C_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
478 deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
479 tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
480 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
481 deltas[0] = GET_TOK(ctx, TM2_C_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
482 deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
483 tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
484 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
485 /* low-res luma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
486 for(i = 0; i < 16; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
487 deltas[i] = 0; |
2967 | 488 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
489 deltas[ 0] = GET_TOK(ctx, TM2_L_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
490 deltas[ 2] = GET_TOK(ctx, TM2_L_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
491 deltas[ 8] = GET_TOK(ctx, TM2_L_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
492 deltas[10] = GET_TOK(ctx, TM2_L_LO); |
2967 | 493 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
494 if(bx > 0) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
495 last[0] = (last[-1] - ctx->D[0] - ctx->D[1] - ctx->D[2] - ctx->D[3] + last[1]) >> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
496 else |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
497 last[0] = (last[1] - ctx->D[0] - ctx->D[1] - ctx->D[2] - ctx->D[3])>> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
498 last[2] = (last[1] + last[3]) >> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
499 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
500 t1 = ctx->D[0] + ctx->D[1]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
501 ctx->D[0] = t1 >> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
502 ctx->D[1] = t1 - (t1 >> 1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
503 t2 = ctx->D[2] + ctx->D[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
504 ctx->D[2] = t2 >> 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
505 ctx->D[3] = t2 - (t2 >> 1); |
2967 | 506 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
507 tm2_apply_deltas(ctx, Y, Ystride, deltas, last); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
508 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
509 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
510 static inline void tm2_null_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
511 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
512 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
513 int ct; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
514 int left, right, diff; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
515 int deltas[16]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
516 TM2_INIT_POINTERS(); |
2967 | 517 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
518 /* null chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
519 deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
520 tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
521 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
522 deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
523 tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx); |
2967 | 524 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
525 /* null luma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
526 for(i = 0; i < 16; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
527 deltas[i] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
528 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
529 ct = ctx->D[0] + ctx->D[1] + ctx->D[2] + ctx->D[3]; |
2967 | 530 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
531 if(bx > 0) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
532 left = last[-1] - ct; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
533 else |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
534 left = 0; |
2967 | 535 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
536 right = last[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
537 diff = right - left; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
538 last[0] = left + (diff >> 2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
539 last[1] = left + (diff >> 1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
540 last[2] = right - (diff >> 2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
541 last[3] = right; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
542 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
543 int tp = left; |
2967 | 544 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
545 ctx->D[0] = (tp + (ct >> 2)) - left; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
546 left += ctx->D[0]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
547 ctx->D[1] = (tp + (ct >> 1)) - left; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
548 left += ctx->D[1]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
549 ctx->D[2] = ((tp + ct) - (ct >> 2)) - left; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
550 left += ctx->D[2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
551 ctx->D[3] = (tp + ct) - left; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
552 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
553 tm2_apply_deltas(ctx, Y, Ystride, deltas, last); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
554 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
555 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
556 static inline void tm2_still_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
557 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
558 int i, j; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
559 TM2_INIT_POINTERS_2(); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
560 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
561 /* update chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
562 for(j = 0; j < 2; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
563 for(i = 0; i < 2; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
564 U[i] = Uo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
565 V[i] = Vo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
566 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
567 U += Ustride; V += Vstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
568 Uo += oUstride; Vo += oVstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
569 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
570 U -= Ustride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
571 V -= Vstride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
572 TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
573 TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
574 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
575 /* update deltas */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
576 ctx->D[0] = Yo[3] - last[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
577 ctx->D[1] = Yo[3 + oYstride] - Yo[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
578 ctx->D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
579 ctx->D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
580 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
581 for(j = 0; j < 4; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
582 for(i = 0; i < 4; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
583 Y[i] = Yo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
584 last[i] = Yo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
585 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
586 Y += Ystride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
587 Yo += oYstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
588 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
589 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
590 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
591 static inline void tm2_update_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
592 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
593 int i, j; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
594 int d; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
595 TM2_INIT_POINTERS_2(); |
2967 | 596 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
597 /* update chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
598 for(j = 0; j < 2; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
599 for(i = 0; i < 2; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
600 U[i] = Uo[i] + GET_TOK(ctx, TM2_UPD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
601 V[i] = Vo[i] + GET_TOK(ctx, TM2_UPD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
602 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
603 U += Ustride; V += Vstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
604 Uo += oUstride; Vo += oVstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
605 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
606 U -= Ustride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
607 V -= Vstride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
608 TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
609 TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
610 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
611 /* update deltas */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
612 ctx->D[0] = Yo[3] - last[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
613 ctx->D[1] = Yo[3 + oYstride] - Yo[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
614 ctx->D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
615 ctx->D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
616 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
617 for(j = 0; j < 4; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
618 d = last[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
619 for(i = 0; i < 4; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
620 Y[i] = Yo[i] + GET_TOK(ctx, TM2_UPD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
621 last[i] = Y[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
622 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
623 ctx->D[j] = last[3] - d; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
624 Y += Ystride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
625 Yo += oYstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
626 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
627 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
628 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
629 static inline void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int by) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
630 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
631 int i, j; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
632 int mx, my; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
633 TM2_INIT_POINTERS_2(); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
634 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
635 mx = GET_TOK(ctx, TM2_MOT); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
636 my = GET_TOK(ctx, TM2_MOT); |
2967 | 637 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
638 Yo += my * oYstride + mx; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
639 Uo += (my >> 1) * oUstride + (mx >> 1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
640 Vo += (my >> 1) * oVstride + (mx >> 1); |
2967 | 641 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
642 /* copy chroma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
643 for(j = 0; j < 2; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
644 for(i = 0; i < 2; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
645 U[i] = Uo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
646 V[i] = Vo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
647 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
648 U += Ustride; V += Vstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
649 Uo += oUstride; Vo += oVstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
650 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
651 U -= Ustride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
652 V -= Vstride * 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
653 TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
654 TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
655 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
656 /* copy luma */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
657 for(j = 0; j < 4; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
658 for(i = 0; i < 4; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
659 Y[i] = Yo[i]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
660 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
661 Y += Ystride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
662 Yo += oYstride; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
663 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
664 /* calculate deltas */ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
665 Y -= Ystride * 4; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
666 ctx->D[0] = Y[3] - last[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
667 ctx->D[1] = Y[3 + Ystride] - Y[3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
668 ctx->D[2] = Y[3 + Ystride * 2] - Y[3 + Ystride]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
669 ctx->D[3] = Y[3 + Ystride * 3] - Y[3 + Ystride * 2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
670 for(i = 0; i < 4; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
671 last[i] = Y[i + Ystride * 3]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
672 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
673 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
674 static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
675 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
676 int i, j; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
677 int bw, bh; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
678 int type; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
679 int keyframe = 1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
680 uint8_t *Y, *U, *V; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
681 int *src; |
2967 | 682 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
683 bw = ctx->avctx->width >> 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
684 bh = ctx->avctx->height >> 2; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
685 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
686 for(i = 0; i < TM2_NUM_STREAMS; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
687 ctx->tok_ptrs[i] = 0; |
2967 | 688 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
689 if (ctx->tok_lens[TM2_TYPE]<bw*bh){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
690 av_log(ctx->avctx,AV_LOG_ERROR,"Got %i tokens for %i blocks\n",ctx->tok_lens[TM2_TYPE],bw*bh); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
691 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
692 } |
2967 | 693 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
694 memset(ctx->last, 0, 4 * bw * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
695 memset(ctx->clast, 0, 4 * bw * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
696 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
697 for(j = 0; j < bh; j++) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
698 memset(ctx->D, 0, 4 * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
699 memset(ctx->CD, 0, 4 * sizeof(int)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
700 for(i = 0; i < bw; i++) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
701 type = GET_TOK(ctx, TM2_TYPE); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
702 switch(type) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
703 case TM2_HI_RES: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
704 tm2_hi_res_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
705 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
706 case TM2_MED_RES: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
707 tm2_med_res_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
708 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
709 case TM2_LOW_RES: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
710 tm2_low_res_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
711 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
712 case TM2_NULL_RES: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
713 tm2_null_res_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
714 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
715 case TM2_UPDATE: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
716 tm2_update_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
717 keyframe = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
718 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
719 case TM2_STILL: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
720 tm2_still_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
721 keyframe = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
722 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
723 case TM2_MOTION: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
724 tm2_motion_block(ctx, p, i, j); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
725 keyframe = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
726 break; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
727 default: |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
728 av_log(ctx->avctx, AV_LOG_ERROR, "Skipping unknown block type %i\n", type); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
729 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
730 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
731 } |
2967 | 732 |
733 /* copy data from our buffer to AVFrame */ | |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
734 Y = p->data[0]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
735 src = (ctx->cur?ctx->Y2:ctx->Y1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
736 for(j = 0; j < ctx->avctx->height; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
737 for(i = 0; i < ctx->avctx->width; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
738 Y[i] = clip_uint8(*src++); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
739 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
740 Y += p->linesize[0]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
741 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
742 U = p->data[2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
743 src = (ctx->cur?ctx->U2:ctx->U1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
744 for(j = 0; j < (ctx->avctx->height + 1) >> 1; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
745 for(i = 0; i < (ctx->avctx->width + 1) >> 1; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
746 U[i] = clip_uint8(*src++); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
747 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
748 U += p->linesize[2]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
749 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
750 V = p->data[1]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
751 src = (ctx->cur?ctx->V2:ctx->V1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
752 for(j = 0; j < (ctx->avctx->height + 1) >> 1; j++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
753 for(i = 0; i < (ctx->avctx->width + 1) >> 1; i++){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
754 V[i] = clip_uint8(*src++); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
755 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
756 V += p->linesize[1]; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
757 } |
2967 | 758 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
759 return keyframe; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
760 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
761 |
2967 | 762 static int decode_frame(AVCodecContext *avctx, |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
763 void *data, int *data_size, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
764 uint8_t *buf, int buf_size) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
765 { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
766 TM2Context * const l = avctx->priv_data; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
767 AVFrame * const p= (AVFrame*)&l->pic; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
768 int skip, t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
769 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
770 p->reference = 1; |
2910 | 771 p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
772 if(avctx->reget_buffer(avctx, p) < 0){ | |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
773 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
774 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
775 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
776 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
777 l->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, buf_size >> 2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
778 skip = tm2_read_header(l, buf); |
2967 | 779 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
780 if(skip == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
781 return -1; |
2967 | 782 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
783 t = tm2_read_stream(l, buf + skip, TM2_C_HI); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
784 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
785 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
786 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
787 t = tm2_read_stream(l, buf + skip, TM2_C_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
788 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
789 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
790 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
791 t = tm2_read_stream(l, buf + skip, TM2_L_HI); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
792 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
793 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
794 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
795 t = tm2_read_stream(l, buf + skip, TM2_L_LO); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
796 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
797 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
798 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
799 t = tm2_read_stream(l, buf + skip, TM2_UPD); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
800 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
801 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
802 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
803 t = tm2_read_stream(l, buf + skip, TM2_MOT); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
804 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
805 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
806 skip += t; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
807 t = tm2_read_stream(l, buf + skip, TM2_TYPE); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
808 if(t == -1) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
809 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
810 p->key_frame = tm2_decode_blocks(l, p); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
811 if(p->key_frame) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
812 p->pict_type = FF_I_TYPE; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
813 else |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
814 p->pict_type = FF_P_TYPE; |
2967 | 815 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
816 l->cur = !l->cur; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
817 *data_size = sizeof(AVFrame); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
818 *(AVFrame*)data = l->pic; |
2967 | 819 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
820 return buf_size; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
821 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
822 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
823 static int decode_init(AVCodecContext *avctx){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
824 TM2Context * const l = avctx->priv_data; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
825 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
826 |
3800
9b75ab171fa9
1l: correct argument order in avcodec_check_dimensions
kostya
parents:
3036
diff
changeset
|
827 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
828 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
829 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
830 if((avctx->width & 3) || (avctx->height & 3)){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
831 av_log(avctx, AV_LOG_ERROR, "Width and height must be multiple of 4\n"); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
832 return -1; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
833 } |
2967 | 834 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
835 l->avctx = avctx; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
836 l->pic.data[0]=NULL; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
837 avctx->has_b_frames = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
838 avctx->pix_fmt = PIX_FMT_YUV420P; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
839 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
840 dsputil_init(&l->dsp, avctx); |
2967 | 841 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
842 l->last = av_malloc(4 * sizeof(int) * (avctx->width >> 2)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
843 l->clast = av_malloc(4 * sizeof(int) * (avctx->width >> 2)); |
2967 | 844 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
845 for(i = 0; i < TM2_NUM_STREAMS; i++) { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
846 l->tokens[i] = NULL; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
847 l->tok_lens[i] = 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
848 } |
2967 | 849 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
850 l->Y1 = av_malloc(sizeof(int) * avctx->width * avctx->height); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
851 l->U1 = av_malloc(sizeof(int) * ((avctx->width + 1) >> 1) * ((avctx->height + 1) >> 1)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
852 l->V1 = av_malloc(sizeof(int) * ((avctx->width + 1) >> 1) * ((avctx->height + 1) >> 1)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
853 l->Y2 = av_malloc(sizeof(int) * avctx->width * avctx->height); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
854 l->U2 = av_malloc(sizeof(int) * ((avctx->width + 1) >> 1) * ((avctx->height + 1) >> 1)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
855 l->V2 = av_malloc(sizeof(int) * ((avctx->width + 1) >> 1) * ((avctx->height + 1) >> 1)); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
856 l->cur = 0; |
2967 | 857 |
2906
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
858 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
859 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
860 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
861 static int decode_end(AVCodecContext *avctx){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
862 TM2Context * const l = avctx->priv_data; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
863 int i; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
864 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
865 if(l->last) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
866 av_free(l->last); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
867 if(l->clast) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
868 av_free(l->clast); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
869 for(i = 0; i < TM2_NUM_STREAMS; i++) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
870 if(l->tokens[i]) |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
871 av_free(l->tokens[i]); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
872 if(l->Y1){ |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
873 av_free(l->Y1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
874 av_free(l->U1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
875 av_free(l->V1); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
876 av_free(l->Y2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
877 av_free(l->U2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
878 av_free(l->V2); |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
879 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
880 return 0; |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
881 } |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
882 |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
883 AVCodec truemotion2_decoder = { |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
884 "truemotion2", |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
885 CODEC_TYPE_VIDEO, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
886 CODEC_ID_TRUEMOTION2, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
887 sizeof(TM2Context), |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
888 decode_init, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
889 NULL, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
890 decode_end, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
891 decode_frame, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
892 CODEC_CAP_DR1, |
e578b3572987
Duck TrueMotion 2 video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
893 }; |