Mercurial > libavcodec.hg
annotate truemotion1.c @ 2025:591233f22963 libavcodec
rtp callback context patch by ("Chris Flerackers" <cflerackers at androme dot be>)
author | michael |
---|---|
date | Tue, 18 May 2004 17:23:49 +0000 |
parents | d7505fbe66cb |
children | 141a9539e270 |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
39 #include "truemotion1data.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
40 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
41 typedef struct TrueMotion1Context { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
42 AVCodecContext *avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
43 AVFrame frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
44 AVFrame prev_frame; |
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 unsigned char *buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
47 int size; |
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 *mb_change_bits; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
50 int mb_change_bits_row_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
51 unsigned char *index_stream; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
52 int index_stream_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 int flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
55 int x, y, w, h; |
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 uint32_t y_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
58 uint32_t c_predictor_table[1024]; |
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 int compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
61 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
62 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
63 int block_height; |
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 int16_t *ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
66 int16_t *cdt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
67 int16_t *fat_ydt; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
68 int16_t *fat_cdt; |
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 int last_deltaset, last_vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
71 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
72 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
73 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
74 } TrueMotion1Context; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
75 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
76 #define FLAG_SPRITE 32 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
77 #define FLAG_KEYFRAME 16 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
78 #define FLAG_INTERFRAME 8 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
79 #define FLAG_INTERPOLATED 4 |
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 struct frame_header { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
82 uint8_t header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
83 uint8_t compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
84 uint8_t deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
85 uint8_t vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
86 uint16_t ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
87 uint16_t xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
88 uint16_t checksum; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
89 uint8_t version; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
90 uint8_t header_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
91 uint8_t flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
92 uint8_t control; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
93 uint16_t xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
94 uint16_t yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
95 uint16_t width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
96 uint16_t height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
97 }; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
98 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
99 #define ALGO_NOP 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
100 #define ALGO_RGB16V 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
101 #define ALGO_RGB16H 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
102 #define ALGO_RGB24H 3 |
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 /* 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
|
105 #define BLOCK_2x2 0 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
106 #define BLOCK_2x4 1 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
107 #define BLOCK_4x2 2 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
108 #define BLOCK_4x4 3 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
109 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
110 typedef struct comp_types { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
111 int algorithm; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
112 int block_width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
113 int block_height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
114 int block_type; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
115 } comp_types; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
116 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
117 /* { 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
|
118 static comp_types compression_types[17] = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
119 { ALGO_NOP, 0, 0, 0 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
120 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
121 { ALGO_RGB16V, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
122 { ALGO_RGB16H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
123 { ALGO_RGB16V, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
124 { ALGO_RGB16H, 4, 2, BLOCK_4x2 }, |
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, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
127 { ALGO_RGB16H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
128 { ALGO_RGB16V, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
129 { ALGO_RGB16H, 2, 2, BLOCK_2x2 }, |
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_NOP, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
132 { ALGO_RGB24H, 4, 4, BLOCK_4x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
133 { ALGO_NOP, 4, 2, BLOCK_4x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
134 { ALGO_RGB24H, 4, 2, BLOCK_4x2 }, |
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, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
137 { ALGO_RGB24H, 2, 4, BLOCK_2x4 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
138 { ALGO_NOP, 2, 2, BLOCK_2x2 }, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
139 { ALGO_RGB24H, 2, 2, BLOCK_2x2 } |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
142 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
|
143 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
144 int i; |
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 if (delta_table_index > 3) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
147 return; |
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 s->ydt = ydts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
150 s->cdt = cdts[delta_table_index]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
151 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
|
152 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
|
153 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
154 /* 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
|
155 * skinny Y deltas should be modified */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
156 for (i = 0; i < 8; i++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
157 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
158 /* 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
|
159 * 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
|
160 s->ydt[i] &= 0xFFFE; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
161 s->ydt[i] /= 2; |
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 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
164 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
165 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
166 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
|
167 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
168 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
|
169 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
170 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
171 int lo, hi; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
172 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
173 lo = ydt[p1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
174 lo += (lo << 5) + (lo << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
175 hi = ydt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
176 hi += (hi << 5) + (hi << 10); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
177 return ((lo + (hi << 16)) << 1); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
178 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
179 |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
180 #ifdef WORDS_BIGENDIAN |
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
181 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
|
182 #else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
183 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
|
184 #endif |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
185 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
186 int r, b, lo; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
187 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
188 b = cdt[p2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
189 r = cdt[p1] << 10; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
190 lo = b + r; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
191 return ((lo + (lo << 16)) << 1); |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
194 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
|
195 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
196 int len, i, j; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
197 unsigned char delta_pair; |
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 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
|
200 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
201 len = *sel_vector_table++ / 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
202 for (j = 0; j < len; j++) |
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 delta_pair = *sel_vector_table++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 } |
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-1)] |= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
211 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
|
212 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
213 } |
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 /* 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
|
216 * 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
|
217 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
|
218 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
219 int i; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
220 struct frame_header header; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
221 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
|
222 uint8_t *sel_vector_table; |
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 /* 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
|
225 * 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
|
226 * 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
|
227 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
|
228 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
229 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
|
230 if (s->buf[0] < 0x10) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
231 { |
1927 | 232 av_log(s->avctx, AV_LOG_ERROR, "invalid header size\n"); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
233 return -1; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
236 /* 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
|
237 memset(header_buffer, 0, 128); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
238 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
|
239 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
|
240 header.compression = header_buffer[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
241 header.deltaset = header_buffer[1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
242 header.vectable = header_buffer[2]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 header.version = header_buffer[9]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
247 header.header_type = header_buffer[10]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
248 header.flags = header_buffer[11]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
249 header.control = header_buffer[12]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
250 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
251 /* Version 2 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
252 if (header.version >= 2) |
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 if (header.header_type > 3) |
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 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
|
257 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
258 } 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
|
259 s->flags = header.flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
260 if (!(s->flags & FLAG_INTERFRAME)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
261 s->flags |= FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
262 } else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
263 s->flags = FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
264 } else /* Version 1 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
265 s->flags = FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
266 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
267 if (s->flags & FLAG_SPRITE) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
268 s->w = header.width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
269 s->h = header.height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
270 s->x = header.xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
271 s->y = header.yoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
272 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
273 s->w = header.xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
274 s->h = header.ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
275 if (header.header_type < 2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
276 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
|
277 s->flags |= FLAG_INTERPOLATED; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
278 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
279 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
280 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
281 if (header.compression > 17) { |
1927 | 282 av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
283 return -1; |
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.deltaset != s->last_deltaset) || |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
287 (header.vectable != s->last_vectable)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
288 select_delta_tables(s, header.deltaset); |
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 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
|
291 sel_vector_table = pc_tbl2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
292 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
293 if (header.vectable < 4) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
294 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
|
295 else { |
1927 | 296 av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
297 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
298 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
299 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
300 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
301 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
|
302 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
303 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
|
304 { |
1927 | 305 av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n"); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
306 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
307 else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
308 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
|
309 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
310 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
311 /* 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
|
312 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
|
313 if (s->flags & FLAG_KEYFRAME) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
314 /* 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
|
315 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
|
316 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
317 /* one change bit per 4x4 block */ |
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 (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
|
320 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
321 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
|
322 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
323 s->last_deltaset = header.deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
324 s->last_vectable = header.vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
325 s->compression = header.compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
330 return header.header_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
331 } |
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 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
|
334 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
335 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
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 s->avctx = avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
338 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
339 avctx->pix_fmt = PIX_FMT_RGB555; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
340 avctx->has_b_frames = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
341 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
|
342 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
343 /* 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
|
344 * predictor is 0 to start with */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
345 s->vert_pred = |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
346 (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
|
347 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
348 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
349 } |
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 #define GET_NEXT_INDEX() \ |
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 if (index_stream_index >= s->index_stream_size) { \ |
1927 | 354 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \ |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
355 return; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
356 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
357 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
|
358 } |
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 #define APPLY_C_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
361 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
|
362 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
363 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
364 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
365 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
366 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
367 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
|
368 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
369 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
370 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
371 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
372 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
373 } \ |
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 #define APPLY_Y_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
378 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
|
379 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
380 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
381 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
382 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
383 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
384 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
|
385 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
386 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
387 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
388 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
389 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
390 } \ |
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 #define OUTPUT_PIXEL_PAIR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
395 *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
|
396 *vert_pred++ = *current_pixel_pair++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
397 prev_pixel_pair++; |
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 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
|
400 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
401 int y; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
402 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
|
403 unsigned int predictor_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
404 unsigned int horiz_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
405 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
406 unsigned int *current_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
407 unsigned int *prev_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
408 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
|
409 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
|
410 int keyframe = s->flags & FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
411 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
412 /* 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
|
413 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
|
414 unsigned char mb_change_byte; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
415 unsigned char mb_change_byte_mask; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
416 int mb_change_index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
417 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
418 /* 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
|
419 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
|
420 int index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
421 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
422 /* clean out the line buffer */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
423 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
|
424 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
425 GET_NEXT_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 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
|
428 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
429 /* 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
|
430 horiz_pred = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
431 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
|
432 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
|
433 vert_pred = s->vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
434 mb_change_index = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
435 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
|
436 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
437 pixels_left = s->avctx->width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
438 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
439 while (pixels_left > 0) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
440 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
441 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
|
442 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
443 switch (y & 3) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
444 case 0: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
445 /* 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
|
446 * apply C-Y-Y */ |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
447 if (s->block_width == 2) { |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
448 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
449 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
450 OUTPUT_PIXEL_PAIR(); |
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 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
455 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
456 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
457 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
458 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
459 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
460 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
461 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
462 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
463 case 1: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
464 case 3: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
465 /* 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
|
466 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
467 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
468 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
469 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
470 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
471 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
472 case 2: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
473 /* 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
|
474 * depending on the macroblock type */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
475 if (s->block_type == BLOCK_2x2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
476 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
477 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
478 OUTPUT_PIXEL_PAIR(); |
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 } 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
|
483 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
484 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
485 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
486 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
487 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
488 } else { |
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 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
494 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
495 } |
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 } else { |
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 /* 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
|
500 * predictor */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
501 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
502 *vert_pred++ = *current_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
503 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
504 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
|
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
507 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
508 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
509 if (!keyframe) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
510 mb_change_byte_mask <<= 1; |
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 /* next byte */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
513 if (!mb_change_byte_mask) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
514 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
|
515 mb_change_byte_mask = 0x01; |
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 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
518 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
519 pixels_left -= 4; |
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 /* next change row */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
523 if (((y + 1) & 3) == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
524 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
|
525 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
526 current_line += s->frame.linesize[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
527 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
|
528 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
529 } |
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 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
|
532 void *data, int *data_size, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
533 uint8_t *buf, int buf_size) |
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 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
536 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
537 s->buf = buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
538 s->size = 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 s->frame.reference = 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
541 if (avctx->get_buffer(avctx, &s->frame) < 0) { |
1927 | 542 av_log(s->avctx, AV_LOG_ERROR, "truemotion1: get_buffer() failed\n"); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
543 return -1; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
546 /* no supplementary picture */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
547 if (buf_size == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
548 return 0; |
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 *data_size = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
551 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
552 if (truemotion1_decode_header(s) == -1) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
553 return -1; |
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 /* 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
|
556 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
|
557 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
558 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
|
559 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
|
560 } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
1927 | 561 av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n"); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
562 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
563 truemotion1_decode_16bit(s); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
564 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
565 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
566 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
567 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
|
568 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
569 /* shuffle frames */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
570 s->prev_frame = s->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 *data_size = sizeof(AVFrame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
573 *(AVFrame*)data = 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 /* 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
|
576 return buf_size; |
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
579 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
|
580 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
581 TrueMotion1Context *s = (TrueMotion1Context *)avctx->priv_data; |
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 /* release the last frame */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
584 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
585 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
|
586 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
587 av_free(s->vert_pred); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
588 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
589 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
590 } |
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 AVCodec truemotion1_decoder = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
593 "truemotion1", |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
594 CODEC_TYPE_VIDEO, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
595 CODEC_ID_TRUEMOTION1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
596 sizeof(TrueMotion1Context), |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
597 truemotion1_decode_init, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
598 NULL, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
599 truemotion1_decode_end, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
600 truemotion1_decode_frame, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
601 CODEC_CAP_DR1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
602 }; |