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