Mercurial > libavcodec.hg
annotate truemotion1.c @ 1858:ea2a4058441c libavcodec
silence warnings
author | iive |
---|---|
date | Thu, 04 Mar 2004 14:58:48 +0000 |
parents | a660ef952580 |
children | 39ad6cd5d4a6 |
rev | line source |
---|---|
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
1 /* |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
2 * Duck TrueMotion 1.0 Decoder |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
3 * Copyright (C) 2003 Alex Beregszaszi & Mike Melanson |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
4 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
9 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
14 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
18 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
19 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
20 /** |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
21 * @file truemotion1.c |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
22 * Duck TrueMotion v1 Video Decoder by |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
23 * Alex Beregszaszi (alex@fsn.hu) and |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
24 * Mike Melanson (melanson@pcisys.net) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
25 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
26 * The TrueMotion v1 decoder presently only decodes 16-bit TM1 data and |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
27 * outputs RGB555 data. 24-bit TM1 data is not supported yet. |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
28 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
29 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
30 #include <stdio.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
31 #include <stdlib.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
32 #include <string.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
33 #include <unistd.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
34 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
35 #include "common.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
36 #include "avcodec.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
37 #include "dsputil.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
38 |
1823
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1654
diff
changeset
|
39 #define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log |
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1654
diff
changeset
|
40 #define fprintf(...) {} |
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1654
diff
changeset
|
41 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
42 #include "truemotion1data.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
43 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
44 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
45 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
46 typedef struct TrueMotion1Context { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
47 AVCodecContext *avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
48 AVFrame frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
49 AVFrame prev_frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
50 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
51 unsigned char *buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
52 int size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
53 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
54 unsigned char *mb_change_bits; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
55 int mb_change_bits_row_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
56 unsigned char *index_stream; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
57 int index_stream_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
58 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
59 int flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
60 int x, y, w, h; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
61 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
62 uint32_t y_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
63 uint32_t c_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
64 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
65 int compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
66 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
67 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
68 int block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
69 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
70 int16_t *ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
71 int16_t *cdt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
72 int16_t *fat_ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
73 int16_t *fat_cdt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
74 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
75 int last_deltaset, last_vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
76 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
77 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
78 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
79 } TrueMotion1Context; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
80 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
81 #define FLAG_SPRITE 32 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
82 #define FLAG_KEYFRAME 16 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
83 #define FLAG_INTERFRAME 8 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
84 #define FLAG_INTERPOLATED 4 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
85 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
86 struct frame_header { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
87 uint8_t header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
88 uint8_t compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
89 uint8_t deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
90 uint8_t vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
91 uint16_t ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
92 uint16_t xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
93 uint16_t checksum; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
94 uint8_t version; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
95 uint8_t header_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
96 uint8_t flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
97 uint8_t control; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
98 uint16_t xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
99 uint16_t yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
100 uint16_t width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
101 uint16_t height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
102 }; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
103 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
104 #define ALGO_NOP 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
105 #define ALGO_RGB16V 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
106 #define ALGO_RGB16H 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
107 #define ALGO_RGB24H 3 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
108 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
109 /* these are the various block sizes that can occupy a 4x4 block */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
110 #define BLOCK_2x2 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
111 #define BLOCK_2x4 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
112 #define BLOCK_4x2 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
113 #define BLOCK_4x4 3 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
114 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
115 typedef struct comp_types { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
116 int algorithm; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
117 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
118 int block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
119 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
120 } comp_types; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
121 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
122 /* { valid for metatype }, algorithm, num of deltas, horiz res, vert res */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
123 static comp_types compression_types[17] = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
124 { ALGO_NOP, 0, 0, 0 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
125 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
126 { ALGO_RGB16V, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
127 { ALGO_RGB16H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
128 { ALGO_RGB16V, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
129 { ALGO_RGB16H, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
130 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
131 { ALGO_RGB16V, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
132 { ALGO_RGB16H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
133 { ALGO_RGB16V, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
134 { ALGO_RGB16H, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
135 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
136 { ALGO_NOP, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
137 { ALGO_RGB24H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
138 { ALGO_NOP, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
139 { ALGO_RGB24H, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
140 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
141 { ALGO_NOP, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
142 { ALGO_RGB24H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
143 { ALGO_NOP, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
144 { ALGO_RGB24H, 2, 2, BLOCK_2x2 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
145 }; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
146 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
147 static void select_delta_tables(TrueMotion1Context *s, int delta_table_index) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
148 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
149 int i; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
150 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
151 if (delta_table_index > 3) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
152 return; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
153 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
154 s->ydt = ydts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
155 s->cdt = cdts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
156 s->fat_ydt = fat_ydts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
157 s->fat_cdt = fat_cdts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
158 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
159 /* Y skinny deltas need to be halved for some reason; maybe the |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
160 * skinny Y deltas should be modified */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
161 for (i = 0; i < 8; i++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
162 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
163 /* drop the lsb before dividing by 2-- net effect: round down |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
164 * when dividing a negative number (e.g., -3/2 = -2, not -1) */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
165 s->ydt[i] &= 0xFFFE; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
166 s->ydt[i] /= 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
167 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
168 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
169 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
170 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
171 static int make_ydt_entry(int p2, int p1, int16_t *ydt) |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
172 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
173 static int make_ydt_entry(int p1, int p2, int16_t *ydt) |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
174 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
175 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
176 int lo, hi; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
177 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
178 lo = ydt[p1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
179 lo += (lo << 5) + (lo << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
180 hi = ydt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
181 hi += (hi << 5) + (hi << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
182 return ((lo + (hi << 16)) << 1); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
183 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
184 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
185 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
186 static int make_cdt_entry(int p2, int p1, int16_t *cdt) |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
187 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
188 static int make_cdt_entry(int p1, int p2, int16_t *cdt) |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
189 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
190 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
191 int r, b, lo; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
192 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
193 b = cdt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
194 r = cdt[p1] << 10; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
195 lo = b + r; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
196 return ((lo + (lo << 16)) << 1); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
197 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
198 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
199 static void gen_vector_table(TrueMotion1Context *s, uint8_t *sel_vector_table) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
200 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
201 int len, i, j; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
202 unsigned char delta_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
203 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
204 for (i = 0; i < 1024; i += 4) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
205 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
206 len = *sel_vector_table++ / 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
207 for (j = 0; j < len; j++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
208 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
209 delta_pair = *sel_vector_table++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
210 s->y_predictor_table[i+j] = 0xfffffffe & |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
211 make_ydt_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
212 s->c_predictor_table[i+j] = 0xfffffffe & |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
213 make_cdt_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
214 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
215 s->y_predictor_table[i+(j-1)] |= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
216 s->c_predictor_table[i+(j-1)] |= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
217 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
218 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
219 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
220 /* Returns the number of bytes consumed from the bytestream. Returns -1 if |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
221 * there was an error while decoding the header */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
222 static int truemotion1_decode_header(TrueMotion1Context *s) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
223 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
224 int i; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
225 struct frame_header header; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
226 uint8_t header_buffer[128]; /* logical maximum size of the header */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
227 uint8_t *sel_vector_table; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
228 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
229 /* There is 1 change bit per 4 pixels, so each change byte represents |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
230 * 32 pixels; divide width by 4 to obtain the number of change bits and |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
231 * then round up to the nearest byte. */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
232 s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
233 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
234 header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
235 if (s->buf[0] < 0x10) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
236 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
237 printf("invalid header size\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
238 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
239 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
240 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
241 /* unscramble the header bytes with a XOR operation */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
242 memset(header_buffer, 0, 128); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
243 for (i = 1; i < header.header_size; i++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
244 header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
245 header.compression = header_buffer[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
246 header.deltaset = header_buffer[1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
247 header.vectable = header_buffer[2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
248 header.ysize = LE_16(&header_buffer[3]); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
249 header.xsize = LE_16(&header_buffer[5]); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
250 header.checksum = LE_16(&header_buffer[7]); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
251 header.version = header_buffer[9]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
252 header.header_type = header_buffer[10]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
253 header.flags = header_buffer[11]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
254 header.control = header_buffer[12]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
255 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
256 /* Version 2 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
257 if (header.version >= 2) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
258 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
259 if (header.header_type > 3) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
260 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
261 av_log(s->avctx, AV_LOG_ERROR, "truemotion1: invalid header type\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
262 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
263 } else if ((header.header_type == 2) || (header.header_type == 3)) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
264 s->flags = header.flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
265 if (!(s->flags & FLAG_INTERFRAME)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
266 s->flags |= FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
267 } else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
268 s->flags = FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
269 } else /* Version 1 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
270 s->flags = FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
271 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
272 if (s->flags & FLAG_SPRITE) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
273 s->w = header.width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
274 s->h = header.height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
275 s->x = header.xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
276 s->y = header.yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
277 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
278 s->w = header.xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
279 s->h = header.ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
280 if (header.header_type < 2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
281 if ((s->w < 213) && (s->h >= 176)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
282 s->flags |= FLAG_INTERPOLATED; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
283 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
284 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
285 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
286 if (header.compression > 17) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
287 printf("invalid compression type (%d)\n", header.compression); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
288 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
289 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
290 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
291 if ((header.deltaset != s->last_deltaset) || |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
292 (header.vectable != s->last_vectable)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
293 select_delta_tables(s, header.deltaset); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
294 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
295 if ((header.compression & 1) && header.header_type) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
296 sel_vector_table = pc_tbl2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
297 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
298 if (header.vectable < 4) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
299 sel_vector_table = tables[header.vectable - 1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
300 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
301 printf("invalid vector table id (%d)\n", header.vectable); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
302 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
303 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
304 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
305 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
306 if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
307 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
308 if (compression_types[header.compression].algorithm == ALGO_RGB24H) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
309 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
310 printf("24bit compression not yet supported\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
311 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
312 else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
313 gen_vector_table(s, sel_vector_table); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
314 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
315 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
316 /* set up pointers to the other key data chunks */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
317 s->mb_change_bits = s->buf + header.header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
318 if (s->flags & FLAG_KEYFRAME) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
319 /* no change bits specified for a keyframe; only index bytes */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
320 s->index_stream = s->mb_change_bits; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
321 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
322 /* one change bit per 4x4 block */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
323 s->index_stream = s->mb_change_bits + |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
324 (s->mb_change_bits_row_size * (s->avctx->height >> 2)); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
325 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
326 s->index_stream_size = s->size - (s->index_stream - s->buf); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
327 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
328 s->last_deltaset = header.deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
329 s->last_vectable = header.vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
330 s->compression = header.compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
331 s->block_width = compression_types[header.compression].block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
332 s->block_height = compression_types[header.compression].block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
333 s->block_type = compression_types[header.compression].block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
334 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
335 return header.header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
336 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
337 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
338 static int truemotion1_decode_init(AVCodecContext *avctx) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
339 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
340 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
341 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
342 s->avctx = avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
343 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
344 avctx->pix_fmt = PIX_FMT_RGB555; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
345 avctx->has_b_frames = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
346 s->frame.data[0] = s->prev_frame.data[0] = NULL; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
347 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
348 /* there is a vertical predictor for each pixel in a line; each vertical |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
349 * predictor is 0 to start with */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
350 s->vert_pred = |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
351 (unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned short)); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
352 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
353 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
354 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
355 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
356 #define GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
357 {\ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
358 if (index_stream_index >= s->index_stream_size) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
359 printf (" help! truemotion1 decoder went out of bounds\n"); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
360 return; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
361 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
362 index = s->index_stream[index_stream_index++] * 4; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
363 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
364 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
365 #define APPLY_C_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
366 predictor_pair = s->c_predictor_table[index]; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
367 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
368 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
369 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
370 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
371 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
372 predictor_pair = s->c_predictor_table[index]; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
373 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
374 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
375 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
376 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
377 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
378 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
379 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
380 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
381 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
382 #define APPLY_Y_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
383 predictor_pair = s->y_predictor_table[index]; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
384 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
385 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
386 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
387 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
388 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
389 predictor_pair = s->y_predictor_table[index]; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
390 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
391 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
392 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
393 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
394 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
395 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
396 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
397 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
398 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
399 #define OUTPUT_PIXEL_PAIR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
400 *current_pixel_pair = *vert_pred + horiz_pred; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
401 *vert_pred++ = *current_pixel_pair++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
402 prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
403 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
404 static void truemotion1_decode_16bit(TrueMotion1Context *s) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
405 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
406 int y; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
407 int pixels_left; /* remaining pixels on this line */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
408 unsigned int predictor_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
409 unsigned int horiz_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
410 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
411 unsigned int *current_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
412 unsigned int *prev_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
413 unsigned char *current_line = s->frame.data[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
414 unsigned char *prev_line = s->prev_frame.data[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
415 int keyframe = s->flags & FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
416 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
417 /* these variables are for managing the stream of macroblock change bits */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
418 unsigned char *mb_change_bits = s->mb_change_bits; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
419 unsigned char mb_change_byte; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
420 unsigned char mb_change_byte_mask; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
421 int mb_change_index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
422 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
423 /* these variables are for managing the main index stream */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
424 int index_stream_index = 0; /* yes, the index into the index stream */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
425 int index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
426 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
427 /* clean out the line buffer */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
428 memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned short)); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
429 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
430 GET_NEXT_INDEX(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
431 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
432 for (y = 0; y < s->avctx->height; y++) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
433 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
434 /* re-init variables for the next line iteration */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
435 horiz_pred = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
436 current_pixel_pair = (unsigned int *)current_line; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
437 prev_pixel_pair = (unsigned int *)prev_line; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
438 vert_pred = s->vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
439 mb_change_index = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
440 mb_change_byte = mb_change_bits[mb_change_index++]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
441 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
442 pixels_left = s->avctx->width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
443 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
444 while (pixels_left > 0) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
445 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
446 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
447 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
448 switch (y & 3) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
449 case 0: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
450 /* if macroblock width is 2, apply C-Y-C-Y; else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
451 * apply C-Y-Y */ |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
452 if (s->block_width == 2) { |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
453 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
454 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
455 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
456 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
457 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
458 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
459 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
460 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
461 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
462 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
463 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
464 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
465 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
466 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
467 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
468 case 1: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
469 case 3: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
470 /* always apply 2 Y predictors on these iterations */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
471 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
472 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
473 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
474 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
475 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
476 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
477 case 2: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
478 /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
479 * depending on the macroblock type */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
480 if (s->block_type == BLOCK_2x2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
481 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
482 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
483 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
484 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
485 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
486 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
487 } else if (s->block_type == BLOCK_4x2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
488 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
489 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
490 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
491 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
492 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
493 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
494 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
495 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
496 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
497 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
498 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
499 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
500 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
501 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
502 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
503 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
504 /* skip (copy) four pixels, but reassign the horizontal |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
505 * predictor */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
506 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
507 *vert_pred++ = *current_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
508 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
509 horiz_pred = *current_pixel_pair - *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
510 *vert_pred++ = *current_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
511 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
512 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
513 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
514 if (!keyframe) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
515 mb_change_byte_mask <<= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
516 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
517 /* next byte */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
518 if (!mb_change_byte_mask) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
519 mb_change_byte = mb_change_bits[mb_change_index++]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
520 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
521 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
522 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
523 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
524 pixels_left -= 4; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
525 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
526 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
527 /* next change row */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
528 if (((y + 1) & 3) == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
529 mb_change_bits += s->mb_change_bits_row_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
530 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
531 current_line += s->frame.linesize[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
532 prev_line += s->prev_frame.linesize[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
533 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
534 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
535 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
536 static int truemotion1_decode_frame(AVCodecContext *avctx, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
537 void *data, int *data_size, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
538 uint8_t *buf, int buf_size) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
539 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
540 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
541 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
542 s->buf = buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
543 s->size = buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
544 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
545 s->frame.reference = 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
546 if (avctx->get_buffer(avctx, &s->frame) < 0) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
547 fprintf(stderr, "truemotion1: get_buffer() failed\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
548 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
549 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
550 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
551 /* no supplementary picture */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
552 if (buf_size == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
553 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
554 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
555 *data_size = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
556 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
557 if (truemotion1_decode_header(s) == -1) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
558 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
559 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
560 /* check for a do-nothing frame and copy the previous frame */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
561 if (compression_types[s->compression].algorithm == ALGO_NOP) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
562 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
563 memcpy(s->frame.data[0], s->prev_frame.data[0], |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
564 s->frame.linesize[0] * s->avctx->height); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
565 } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
566 printf (" 24-bit Duck TrueMotion decoding not yet implemented\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
567 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
568 truemotion1_decode_16bit(s); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
569 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
570 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
571 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
572 avctx->release_buffer(avctx, &s->prev_frame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
573 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
574 /* shuffle frames */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
575 s->prev_frame = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
576 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
577 *data_size = sizeof(AVFrame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
578 *(AVFrame*)data = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
579 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
580 /* report that the buffer was completely consumed */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
581 return buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
582 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
583 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
584 static int truemotion1_decode_end(AVCodecContext *avctx) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
585 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
586 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
587 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
588 /* release the last frame */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
589 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
590 avctx->release_buffer(avctx, &s->prev_frame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
591 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
592 av_free(s->vert_pred); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
593 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
594 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
595 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
596 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
597 AVCodec truemotion1_decoder = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
598 "truemotion1", |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
599 CODEC_TYPE_VIDEO, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
600 CODEC_ID_TRUEMOTION1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
601 sizeof(TrueMotion1Context), |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
602 truemotion1_decode_init, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
603 NULL, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
604 truemotion1_decode_end, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
605 truemotion1_decode_frame, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
606 CODEC_CAP_DR1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
607 }; |