Mercurial > libavcodec.hg
annotate truemotion1.c @ 1914:8337c46a5abe libavcodec
gmc segfault fix
author | michael |
---|---|
date | Fri, 02 Apr 2004 16:21:55 +0000 |
parents | 39ad6cd5d4a6 |
children | d7505fbe66cb |
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 typedef struct TrueMotion1Context { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
45 AVCodecContext *avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
46 AVFrame frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
47 AVFrame prev_frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
48 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
49 unsigned char *buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
50 int size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
51 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
52 unsigned char *mb_change_bits; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
53 int mb_change_bits_row_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
54 unsigned char *index_stream; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
55 int index_stream_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
56 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
57 int flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
58 int x, y, w, h; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
59 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
60 uint32_t y_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
61 uint32_t c_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
62 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
63 int compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
64 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
65 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
66 int block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
67 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
68 int16_t *ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
69 int16_t *cdt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
70 int16_t *fat_ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
71 int16_t *fat_cdt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
72 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
73 int last_deltaset, last_vectable; |
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 unsigned int *vert_pred; |
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 } TrueMotion1Context; |
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 #define FLAG_SPRITE 32 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
80 #define FLAG_KEYFRAME 16 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
81 #define FLAG_INTERFRAME 8 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
82 #define FLAG_INTERPOLATED 4 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
83 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
84 struct frame_header { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
85 uint8_t header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
86 uint8_t compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
87 uint8_t deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
88 uint8_t vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
89 uint16_t ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
90 uint16_t xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
91 uint16_t checksum; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
92 uint8_t version; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
93 uint8_t header_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
94 uint8_t flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
95 uint8_t control; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
96 uint16_t xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
97 uint16_t yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
98 uint16_t width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
99 uint16_t height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
100 }; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
101 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
102 #define ALGO_NOP 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
103 #define ALGO_RGB16V 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
104 #define ALGO_RGB16H 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
105 #define ALGO_RGB24H 3 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
106 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
107 /* 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
|
108 #define BLOCK_2x2 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
109 #define BLOCK_2x4 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
110 #define BLOCK_4x2 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
111 #define BLOCK_4x4 3 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
112 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
113 typedef struct comp_types { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
114 int algorithm; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
115 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
116 int block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
117 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
118 } comp_types; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
119 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
120 /* { 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
|
121 static comp_types compression_types[17] = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
122 { ALGO_NOP, 0, 0, 0 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
123 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
124 { ALGO_RGB16V, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
125 { ALGO_RGB16H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
126 { ALGO_RGB16V, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
127 { ALGO_RGB16H, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
128 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
129 { ALGO_RGB16V, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
130 { ALGO_RGB16H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
131 { ALGO_RGB16V, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
132 { ALGO_RGB16H, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
133 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
134 { ALGO_NOP, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
135 { ALGO_RGB24H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
136 { ALGO_NOP, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
137 { ALGO_RGB24H, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
138 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
139 { ALGO_NOP, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
140 { ALGO_RGB24H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
141 { ALGO_NOP, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
142 { ALGO_RGB24H, 2, 2, BLOCK_2x2 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
143 }; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
144 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
145 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
|
146 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
147 int i; |
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 if (delta_table_index > 3) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
150 return; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
151 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
152 s->ydt = ydts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
153 s->cdt = cdts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
154 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
|
155 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
|
156 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
157 /* 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
|
158 * skinny Y deltas should be modified */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
159 for (i = 0; i < 8; i++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
160 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
161 /* 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
|
162 * 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
|
163 s->ydt[i] &= 0xFFFE; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
164 s->ydt[i] /= 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
165 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
166 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
167 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
168 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
169 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
|
170 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
171 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
|
172 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
173 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
174 int lo, hi; |
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 lo = ydt[p1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
177 lo += (lo << 5) + (lo << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
178 hi = ydt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
179 hi += (hi << 5) + (hi << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
180 return ((lo + (hi << 16)) << 1); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
181 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
182 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
183 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
184 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
|
185 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
186 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
|
187 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
188 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
189 int r, b, lo; |
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 b = cdt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
192 r = cdt[p1] << 10; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
193 lo = b + r; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
194 return ((lo + (lo << 16)) << 1); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
195 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
196 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
197 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
|
198 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
199 int len, i, j; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
200 unsigned char delta_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
201 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
202 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
|
203 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
204 len = *sel_vector_table++ / 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
205 for (j = 0; j < len; j++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
206 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
207 delta_pair = *sel_vector_table++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
213 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
|
214 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
|
215 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
216 } |
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 /* 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
|
219 * 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
|
220 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
|
221 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
222 int i; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
223 struct frame_header header; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
224 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
|
225 uint8_t *sel_vector_table; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
226 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
227 /* 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
|
228 * 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
|
229 * 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
|
230 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
|
231 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
232 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
|
233 if (s->buf[0] < 0x10) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
234 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
235 printf("invalid header size\n"); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
236 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
237 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
238 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
239 /* 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
|
240 memset(header_buffer, 0, 128); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
241 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
|
242 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
|
243 header.compression = header_buffer[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
244 header.deltaset = header_buffer[1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
245 header.vectable = header_buffer[2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 header.version = header_buffer[9]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
250 header.header_type = header_buffer[10]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
251 header.flags = header_buffer[11]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
252 header.control = header_buffer[12]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
253 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
254 /* Version 2 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
255 if (header.version >= 2) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
256 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
257 if (header.header_type > 3) |
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 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
|
260 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
261 } 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
|
262 s->flags = header.flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
263 if (!(s->flags & FLAG_INTERFRAME)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
264 s->flags |= FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
265 } else |
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 /* Version 1 */ |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
270 if (s->flags & FLAG_SPRITE) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
271 s->w = header.width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
272 s->h = header.height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
273 s->x = header.xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
274 s->y = header.yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
275 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
276 s->w = header.xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
277 s->h = header.ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
278 if (header.header_type < 2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
279 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
|
280 s->flags |= FLAG_INTERPOLATED; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
281 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
282 } |
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 if (header.compression > 17) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
285 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
|
286 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
287 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
288 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
289 if ((header.deltaset != s->last_deltaset) || |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
290 (header.vectable != s->last_vectable)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
291 select_delta_tables(s, header.deltaset); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
292 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
293 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
|
294 sel_vector_table = pc_tbl2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
295 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
296 if (header.vectable < 4) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
297 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
|
298 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
299 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
|
300 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
301 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
302 } |
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 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
|
305 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
306 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
|
307 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
308 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
|
309 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
310 else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
311 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
|
312 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
313 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
314 /* 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
|
315 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
|
316 if (s->flags & FLAG_KEYFRAME) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
317 /* 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
|
318 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
|
319 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
320 /* one change bit per 4x4 block */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
321 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
|
322 (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
|
323 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
324 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
|
325 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
326 s->last_deltaset = header.deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
327 s->last_vectable = header.vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
328 s->compression = header.compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
333 return header.header_size; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
336 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
|
337 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
338 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
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 s->avctx = avctx; |
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 avctx->pix_fmt = PIX_FMT_RGB555; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
343 avctx->has_b_frames = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
344 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
|
345 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
346 /* 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
|
347 * predictor is 0 to start with */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
348 s->vert_pred = |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
349 (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
|
350 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
351 return 0; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
354 #define GET_NEXT_INDEX() \ |
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 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
|
357 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
|
358 return; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
359 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
360 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
|
361 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
362 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
363 #define APPLY_C_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
364 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
|
365 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
366 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
367 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
368 if (!index) { \ |
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 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
|
371 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
372 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
373 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
374 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
375 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
376 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
377 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
378 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
379 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
380 #define APPLY_Y_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
381 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
|
382 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
383 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
384 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
385 if (!index) { \ |
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 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
|
388 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
389 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
390 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
391 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
392 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
393 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
394 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
395 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
396 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
397 #define OUTPUT_PIXEL_PAIR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
398 *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
|
399 *vert_pred++ = *current_pixel_pair++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
400 prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
401 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
402 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
|
403 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
404 int y; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
405 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
|
406 unsigned int predictor_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
407 unsigned int horiz_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
408 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
409 unsigned int *current_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
410 unsigned int *prev_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
411 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
|
412 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
|
413 int keyframe = s->flags & FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
414 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
415 /* 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
|
416 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
|
417 unsigned char mb_change_byte; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
418 unsigned char mb_change_byte_mask; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
419 int mb_change_index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
420 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
421 /* 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
|
422 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
|
423 int index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
424 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
425 /* clean out the line buffer */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
426 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
|
427 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
428 GET_NEXT_INDEX(); |
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 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
|
431 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
432 /* 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
|
433 horiz_pred = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
434 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
|
435 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
|
436 vert_pred = s->vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
437 mb_change_index = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
438 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
|
439 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
440 pixels_left = s->avctx->width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
441 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
442 while (pixels_left > 0) { |
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 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
|
445 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
446 switch (y & 3) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
447 case 0: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
448 /* 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
|
449 * apply C-Y-Y */ |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
450 if (s->block_width == 2) { |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
451 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
452 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
453 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
454 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
455 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
456 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
457 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
458 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
459 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
460 OUTPUT_PIXEL_PAIR(); |
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 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
464 break; |
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 case 1: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
467 case 3: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
468 /* 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
|
469 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
470 OUTPUT_PIXEL_PAIR(); |
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 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
474 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
475 case 2: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
476 /* 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
|
477 * depending on the macroblock type */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
478 if (s->block_type == BLOCK_2x2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
479 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
480 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
481 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
482 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
483 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
484 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
485 } 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
|
486 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
487 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
488 OUTPUT_PIXEL_PAIR(); |
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 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
492 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
493 OUTPUT_PIXEL_PAIR(); |
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 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
497 break; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
500 } else { |
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 /* 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
|
503 * predictor */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
504 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
505 *vert_pred++ = *current_pixel_pair++; |
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 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
|
508 *vert_pred++ = *current_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
509 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
510 } |
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 if (!keyframe) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
513 mb_change_byte_mask <<= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
514 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
515 /* next byte */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
516 if (!mb_change_byte_mask) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
517 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
|
518 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
519 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
520 } |
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 pixels_left -= 4; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
525 /* next change row */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
526 if (((y + 1) & 3) == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
527 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
|
528 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
529 current_line += s->frame.linesize[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
530 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
|
531 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
532 } |
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 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
|
535 void *data, int *data_size, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
536 uint8_t *buf, int buf_size) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
537 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
538 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
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 s->buf = buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
541 s->size = buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
542 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
543 s->frame.reference = 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
544 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
|
545 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
|
546 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
547 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
548 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
549 /* no supplementary picture */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
550 if (buf_size == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
551 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
552 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
553 *data_size = 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 if (truemotion1_decode_header(s) == -1) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
556 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
557 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
558 /* 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
|
559 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
|
560 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
561 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
|
562 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
|
563 } 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
|
564 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
|
565 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
566 truemotion1_decode_16bit(s); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
567 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
568 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
569 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
570 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
|
571 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
572 /* shuffle frames */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
573 s->prev_frame = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
574 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
575 *data_size = sizeof(AVFrame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
576 *(AVFrame*)data = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
577 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
578 /* 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
|
579 return buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
580 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
581 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
582 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
|
583 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
584 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
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 /* release the last frame */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
587 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
588 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
|
589 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
590 av_free(s->vert_pred); |
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 return 0; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
595 AVCodec truemotion1_decoder = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
596 "truemotion1", |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
597 CODEC_TYPE_VIDEO, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
598 CODEC_ID_TRUEMOTION1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
599 sizeof(TrueMotion1Context), |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
600 truemotion1_decode_init, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
601 NULL, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
602 truemotion1_decode_end, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
603 truemotion1_decode_frame, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
604 CODEC_CAP_DR1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
605 }; |