Mercurial > libavcodec.hg
annotate truemotion1.c @ 5346:b41036edcf2e libavcodec
fixpoint: lowlevel functional abstraction for all buffer arithmetics
author | mhoffman |
---|---|
date | Mon, 16 Jul 2007 12:32:41 +0000 |
parents | f99e40a7155b |
children | e2dbd1623e1d |
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 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
8 * 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
|
9 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
13 * 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
|
14 * 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
|
15 * 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
|
16 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1650
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
22 /** |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
23 * @file truemotion1.c |
2967 | 24 * Duck TrueMotion v1 Video Decoder by |
4869 | 25 * Alex Beregszaszi and |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
26 * Mike Melanson (melanson@pcisys.net) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
27 * |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
28 * The TrueMotion v1 decoder presently only decodes 16-bit TM1 data and |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
29 * outputs RGB555 (or RGB565) data. 24-bit TM1 data is not supported yet. |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
30 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
31 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
32 #include <stdio.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
33 #include <stdlib.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
34 #include <string.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
35 #include <unistd.h> |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
36 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
37 #include "avcodec.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
38 #include "dsputil.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
39 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
40 #include "truemotion1data.h" |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
41 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
42 typedef struct TrueMotion1Context { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
43 AVCodecContext *avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
44 AVFrame frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
45 AVFrame prev_frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
46 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
47 uint8_t *buf; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
48 int size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
49 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
50 uint8_t *mb_change_bits; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
51 int mb_change_bits_row_size; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
52 uint8_t *index_stream; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
53 int index_stream_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
54 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
55 int flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
56 int x, y, w, h; |
2967 | 57 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
58 uint32_t y_predictor_table[1024]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
59 uint32_t c_predictor_table[1024]; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
60 uint32_t fat_y_predictor_table[1024]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
61 uint32_t fat_c_predictor_table[1024]; |
2967 | 62 |
1650
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 |
2073
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
68 int16_t ydt[8]; |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
69 int16_t cdt[8]; |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
70 int16_t fat_ydt[8]; |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
71 int16_t fat_cdt[8]; |
2967 | 72 |
1650
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; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
115 int block_width; // vres |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
116 int block_height; // hres |
1650
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 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
120 /* { valid for metatype }, algorithm, num of deltas, vert res, horiz res */ |
1650
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 |
2073
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
152 memcpy(s->ydt, ydts[delta_table_index], 8 * sizeof(int16_t)); |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
153 memcpy(s->cdt, cdts[delta_table_index], 8 * sizeof(int16_t)); |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
154 memcpy(s->fat_ydt, fat_ydts[delta_table_index], 8 * sizeof(int16_t)); |
95d303a305d2
fix initialization bug in which execution overwrites essential data
melanson
parents:
2028
diff
changeset
|
155 memcpy(s->fat_cdt, fat_cdts[delta_table_index], 8 * sizeof(int16_t)); |
1650
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 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
169 static int make_ydt15_entry(int p2, int p1, int16_t *ydt) |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
170 #else |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
171 static int make_ydt15_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; |
2967 | 175 |
1650
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 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
184 static int make_cdt15_entry(int p2, int p1, int16_t *cdt) |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
185 #else |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
186 static int make_cdt15_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; |
2967 | 190 |
1650
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 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
197 #ifdef WORDS_BIGENDIAN |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
198 static int make_ydt16_entry(int p2, int p1, int16_t *ydt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
199 #else |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
200 static int make_ydt16_entry(int p1, int p2, int16_t *ydt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
201 #endif |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
202 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
203 int lo, hi; |
2967 | 204 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
205 lo = ydt[p1]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
206 lo += (lo << 6) + (lo << 11); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
207 hi = ydt[p2]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
208 hi += (hi << 6) + (hi << 11); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
209 return ((lo + (hi << 16)) << 1); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
210 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
211 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
212 #ifdef WORDS_BIGENDIAN |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
213 static int make_cdt16_entry(int p2, int p1, int16_t *cdt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
214 #else |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
215 static int make_cdt16_entry(int p1, int p2, int16_t *cdt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
216 #endif |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
217 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
218 int r, b, lo; |
2967 | 219 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
220 b = cdt[p2]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
221 r = cdt[p1] << 11; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
222 lo = b + r; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
223 return ((lo + (lo << 16)) << 1); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
224 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
225 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
226 #ifdef WORDS_BIGENDIAN |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
227 static int make_ydt24_entry(int p2, int p1, int16_t *ydt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
228 #else |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
229 static int make_ydt24_entry(int p1, int p2, int16_t *ydt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
230 #endif |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
231 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
232 int lo, hi; |
2967 | 233 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
234 lo = ydt[p1]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
235 hi = ydt[p2]; |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
236 return ((lo + (hi << 8) + (hi << 16)) << 1); |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
237 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
238 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
239 #ifdef WORDS_BIGENDIAN |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
240 static int make_cdt24_entry(int p2, int p1, int16_t *cdt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
241 #else |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
242 static int make_cdt24_entry(int p1, int p2, int16_t *cdt) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
243 #endif |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
244 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
245 int r, b; |
2967 | 246 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
247 b = cdt[p2]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
248 r = cdt[p1]<<16; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
249 return ((b+r) << 1); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
250 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
251 |
2753 | 252 static void gen_vector_table15(TrueMotion1Context *s, const uint8_t *sel_vector_table) |
1650
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 int len, i, j; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
255 unsigned char delta_pair; |
2967 | 256 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
257 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
|
258 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
259 len = *sel_vector_table++ / 2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
260 for (j = 0; j < len; j++) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
261 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
262 delta_pair = *sel_vector_table++; |
2967 | 263 s->y_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
264 make_ydt15_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); |
2967 | 265 s->c_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
266 make_cdt15_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
267 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
268 s->y_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
269 s->c_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
270 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
271 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
272 |
2753 | 273 static void gen_vector_table16(TrueMotion1Context *s, const uint8_t *sel_vector_table) |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
274 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
275 int len, i, j; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
276 unsigned char delta_pair; |
2967 | 277 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
278 for (i = 0; i < 1024; i += 4) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
279 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
280 len = *sel_vector_table++ / 2; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
281 for (j = 0; j < len; j++) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
282 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
283 delta_pair = *sel_vector_table++; |
2967 | 284 s->y_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
285 make_ydt16_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); |
2967 | 286 s->c_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
287 make_cdt16_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); |
1650
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 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
|
290 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
|
291 } |
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 |
2753 | 294 static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_table) |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
295 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
296 int len, i, j; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
297 unsigned char delta_pair; |
2967 | 298 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
299 for (i = 0; i < 1024; i += 4) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
300 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
301 len = *sel_vector_table++ / 2; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
302 for (j = 0; j < len; j++) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
303 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
304 delta_pair = *sel_vector_table++; |
2967 | 305 s->y_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
306 make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); |
2967 | 307 s->c_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
308 make_cdt24_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); |
2967 | 309 s->fat_y_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
310 make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->fat_ydt); |
2967 | 311 s->fat_c_predictor_table[i+j] = 0xfffffffe & |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
312 make_cdt24_entry(delta_pair >> 4, delta_pair & 0xf, s->fat_cdt); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
313 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
314 s->y_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
315 s->c_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
316 s->fat_y_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
317 s->fat_c_predictor_table[i+(j-1)] |= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
318 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
319 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
320 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
321 /* Returns the number of bytes consumed from the bytestream. Returns -1 if |
2967 | 322 * there was an error while decoding the header */ |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
323 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
|
324 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
325 int i; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
326 struct frame_header header; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
327 uint8_t header_buffer[128]; /* logical maximum size of the header */ |
2753 | 328 const uint8_t *sel_vector_table; |
1650
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 /* 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
|
331 * 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
|
332 * 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
|
333 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
|
334 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
335 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
|
336 if (s->buf[0] < 0x10) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
337 { |
2979 | 338 av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
339 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
340 } |
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 /* 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
|
343 memset(header_buffer, 0, 128); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
344 for (i = 1; i < header.header_size; i++) |
2979 | 345 header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1]; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
346 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
347 header.compression = header_buffer[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
348 header.deltaset = header_buffer[1]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
349 header.vectable = header_buffer[2]; |
4364 | 350 header.ysize = AV_RL16(&header_buffer[3]); |
351 header.xsize = AV_RL16(&header_buffer[5]); | |
352 header.checksum = AV_RL16(&header_buffer[7]); | |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
353 header.version = header_buffer[9]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
354 header.header_type = header_buffer[10]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
355 header.flags = header_buffer[11]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
356 header.control = header_buffer[12]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
357 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
358 /* Version 2 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
359 if (header.version >= 2) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
360 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
361 if (header.header_type > 3) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
362 { |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
363 av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
364 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
365 } 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
|
366 s->flags = header.flags; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
367 if (!(s->flags & FLAG_INTERFRAME)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
368 s->flags |= FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
369 } else |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
370 s->flags = FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
371 } else /* Version 1 */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
372 s->flags = FLAG_KEYFRAME; |
2967 | 373 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
374 if (s->flags & FLAG_SPRITE) { |
2979 | 375 av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n"); |
4476 | 376 /* FIXME header.width, height, xoffset and yoffset aren't initialized */ |
377 #if 0 | |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
378 s->w = header.width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
379 s->h = header.height; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
380 s->x = header.xoffset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
381 s->y = header.yoffset; |
4476 | 382 #else |
383 return -1; | |
384 #endif | |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
385 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
386 s->w = header.xsize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
387 s->h = header.ysize; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
388 if (header.header_type < 2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
389 if ((s->w < 213) && (s->h >= 176)) |
2979 | 390 { |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
391 s->flags |= FLAG_INTERPOLATED; |
2979 | 392 av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n"); |
393 } | |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
394 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
395 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
396 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
397 if (header.compression > 17) { |
1927 | 398 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
|
399 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
400 } |
2967 | 401 |
402 if ((header.deltaset != s->last_deltaset) || | |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
403 (header.vectable != s->last_vectable)) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
404 select_delta_tables(s, header.deltaset); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
405 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
406 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
|
407 sel_vector_table = pc_tbl2; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
408 else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
409 if (header.vectable < 4) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
410 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
|
411 else { |
1927 | 412 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
|
413 return -1; |
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 } |
2967 | 416 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
417 // FIXME: where to place this ?!?! |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
418 if (compression_types[header.compression].algorithm == ALGO_RGB24H) |
4494
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4476
diff
changeset
|
419 s->avctx->pix_fmt = PIX_FMT_RGB32; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
420 else |
4561 | 421 s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
422 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
423 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
|
424 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
425 if (compression_types[header.compression].algorithm == ALGO_RGB24H) |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
426 gen_vector_table24(s, sel_vector_table); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
427 else |
2979 | 428 if (s->avctx->pix_fmt == PIX_FMT_RGB555) |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
429 gen_vector_table15(s, sel_vector_table); |
2979 | 430 else |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
431 gen_vector_table16(s, sel_vector_table); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
432 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
433 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
434 /* 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
|
435 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
|
436 if (s->flags & FLAG_KEYFRAME) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
437 /* 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
|
438 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
|
439 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
440 /* one change bit per 4x4 block */ |
2967 | 441 s->index_stream = s->mb_change_bits + |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
442 (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
|
443 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
444 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
|
445 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
446 s->last_deltaset = header.deltaset; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
447 s->last_vectable = header.vectable; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
448 s->compression = header.compression; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
449 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
|
450 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
|
451 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
|
452 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
453 if (s->avctx->debug & FF_DEBUG_PICT_INFO) |
2979 | 454 av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n", |
455 s->last_deltaset, s->last_vectable, s->compression, s->block_width, | |
456 s->block_height, s->block_type, | |
457 s->flags & FLAG_KEYFRAME ? " KEY" : "", | |
458 s->flags & FLAG_INTERFRAME ? " INTER" : "", | |
459 s->flags & FLAG_SPRITE ? " SPRITE" : "", | |
460 s->flags & FLAG_INTERPOLATED ? " INTERPOL" : ""); | |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
461 |
2967 | 462 return header.header_size; |
1650
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 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
465 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
|
466 { |
4827 | 467 TrueMotion1Context *s = avctx->priv_data; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
468 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
469 s->avctx = avctx; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
470 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
471 // FIXME: it may change ? |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
472 // if (avctx->bits_per_sample == 24) |
2979 | 473 // avctx->pix_fmt = PIX_FMT_RGB24; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
474 // else |
2979 | 475 // avctx->pix_fmt = PIX_FMT_RGB555; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
476 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
477 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
|
478 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
479 /* 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
|
480 * predictor is 0 to start with */ |
2967 | 481 s->vert_pred = |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
482 (unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned int)); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
483 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
484 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
485 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
486 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
487 /* |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
488 Block decoding order: |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
489 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
490 dxi: Y-Y |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
491 dxic: Y-C-Y |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
492 dxic2: Y-C-Y-C |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
493 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
494 hres,vres,i,i%vres (0 < i < 4) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
495 2x2 0: 0 dxic2 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
496 2x2 1: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
497 2x2 2: 0 dxic2 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
498 2x2 3: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
499 2x4 0: 0 dxic2 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
500 2x4 1: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
501 2x4 2: 2 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
502 2x4 3: 3 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
503 4x2 0: 0 dxic |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
504 4x2 1: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
505 4x2 2: 0 dxic |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
506 4x2 3: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
507 4x4 0: 0 dxic |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
508 4x4 1: 1 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
509 4x4 2: 2 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
510 4x4 3: 3 dxi |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
511 */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
512 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
513 #define GET_NEXT_INDEX() \ |
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 if (index_stream_index >= s->index_stream_size) { \ |
1927 | 516 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
|
517 return; \ |
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 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
|
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 #define APPLY_C_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
523 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
|
524 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
525 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
526 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
527 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
528 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
529 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
|
530 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
531 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
532 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
533 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
534 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
535 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
536 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
537 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
538 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
539 #define APPLY_C_PREDICTOR_24() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
540 predictor_pair = s->c_predictor_table[index]; \ |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
541 horiz_pred += (predictor_pair >> 1); \ |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
542 if (predictor_pair & 1) { \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
543 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
544 if (!index) { \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
545 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
546 predictor_pair = s->fat_c_predictor_table[index]; \ |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
547 horiz_pred += (predictor_pair >> 1); \ |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
548 if (predictor_pair & 1) \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
549 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
550 else \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
551 index++; \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
552 } \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
553 } else \ |
2967 | 554 index++; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
555 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
556 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
557 #define APPLY_Y_PREDICTOR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
558 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
|
559 horiz_pred += (predictor_pair >> 1); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
560 if (predictor_pair & 1) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
561 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
562 if (!index) { \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
563 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
564 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
|
565 horiz_pred += ((predictor_pair >> 1) * 5); \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
566 if (predictor_pair & 1) \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
567 GET_NEXT_INDEX() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
568 else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
569 index++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
570 } \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
571 } else \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
572 index++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
573 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
574 #define APPLY_Y_PREDICTOR_24() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
575 predictor_pair = s->y_predictor_table[index]; \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
576 horiz_pred += (predictor_pair >> 1); \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
577 if (predictor_pair & 1) { \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
578 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
579 if (!index) { \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
580 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
581 predictor_pair = s->fat_y_predictor_table[index]; \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
582 horiz_pred += (predictor_pair >> 1); \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
583 if (predictor_pair & 1) \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
584 GET_NEXT_INDEX() \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
585 else \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
586 index++; \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
587 } \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
588 } else \ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
589 index++; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
590 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
591 #define OUTPUT_PIXEL_PAIR() \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
592 *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
|
593 *vert_pred++ = *current_pixel_pair++; \ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
594 prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
595 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
596 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
|
597 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
598 int y; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
599 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
|
600 unsigned int predictor_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
601 unsigned int horiz_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
602 unsigned int *vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
603 unsigned int *current_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
604 unsigned int *prev_pixel_pair; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
605 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
|
606 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
|
607 int keyframe = s->flags & FLAG_KEYFRAME; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
608 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
609 /* 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
|
610 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
|
611 unsigned char mb_change_byte; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
612 unsigned char mb_change_byte_mask; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
613 int mb_change_index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
614 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
615 /* 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
|
616 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
|
617 int index; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
618 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
619 /* clean out the line buffer */ |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
620 memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int)); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
621 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
622 GET_NEXT_INDEX(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
623 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
624 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
|
625 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
626 /* 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
|
627 horiz_pred = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
628 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
|
629 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
|
630 vert_pred = s->vert_pred; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
631 mb_change_index = 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
632 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
|
633 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
634 pixels_left = s->avctx->width; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
635 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
636 while (pixels_left > 0) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
637 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
638 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
|
639 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
640 switch (y & 3) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
641 case 0: |
2967 | 642 /* if macroblock width is 2, apply C-Y-C-Y; else |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
643 * apply C-Y-Y */ |
1654
1c123e036890
this should make the decoder safe for big-endian platforms
melanson
parents:
1650
diff
changeset
|
644 if (s->block_width == 2) { |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
645 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
646 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
647 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
648 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
649 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
650 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
651 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
652 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
653 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
654 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
655 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
656 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
657 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
658 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
659 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
660 case 1: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
661 case 3: |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
662 /* 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
|
663 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
664 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
665 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
666 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
667 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
668 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
669 case 2: |
2967 | 670 /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
671 * depending on the macroblock type */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
672 if (s->block_type == BLOCK_2x2) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
673 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
674 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
675 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
676 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
677 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
678 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
679 } 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
|
680 APPLY_C_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
681 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
682 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
683 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
684 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
685 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
686 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
687 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
688 APPLY_Y_PREDICTOR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
689 OUTPUT_PIXEL_PAIR(); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
690 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
691 break; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
692 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
693 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
694 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
695 |
2967 | 696 /* skip (copy) four pixels, but reassign the horizontal |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
697 * predictor */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
698 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
699 *vert_pred++ = *current_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
700 *current_pixel_pair = *prev_pixel_pair++; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
701 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
|
702 *vert_pred++ = *current_pixel_pair++; |
2967 | 703 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
704 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
705 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
706 if (!keyframe) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
707 mb_change_byte_mask <<= 1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
708 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
709 /* next byte */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
710 if (!mb_change_byte_mask) { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
711 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
|
712 mb_change_byte_mask = 0x01; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
713 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
714 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
715 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
716 pixels_left -= 4; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
717 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
718 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
719 /* next change row */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
720 if (((y + 1) & 3) == 0) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
721 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
|
722 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
723 current_line += s->frame.linesize[0]; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
724 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
|
725 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
726 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
727 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
728 static void truemotion1_decode_24bit(TrueMotion1Context *s) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
729 { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
730 int y; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
731 int pixels_left; /* remaining pixels on this line */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
732 unsigned int predictor_pair; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
733 unsigned int horiz_pred; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
734 unsigned int *vert_pred; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
735 unsigned int *current_pixel_pair; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
736 unsigned int *prev_pixel_pair; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
737 unsigned char *current_line = s->frame.data[0]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
738 unsigned char *prev_line = s->prev_frame.data[0]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
739 int keyframe = s->flags & FLAG_KEYFRAME; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
740 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
741 /* these variables are for managing the stream of macroblock change bits */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
742 unsigned char *mb_change_bits = s->mb_change_bits; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
743 unsigned char mb_change_byte; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
744 unsigned char mb_change_byte_mask; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
745 int mb_change_index; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
746 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
747 /* these variables are for managing the main index stream */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
748 int index_stream_index = 0; /* yes, the index into the index stream */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
749 int index; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
750 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
751 /* clean out the line buffer */ |
2939
04cf75617d00
clear the whole vert_pred buffer for 24 bit decoding.
reimar
parents:
2938
diff
changeset
|
752 memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int)); |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
753 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
754 GET_NEXT_INDEX(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
755 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
756 for (y = 0; y < s->avctx->height; y++) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
757 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
758 /* re-init variables for the next line iteration */ |
2938
363be7734674
improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents:
2753
diff
changeset
|
759 horiz_pred = 0; |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
760 current_pixel_pair = (unsigned int *)current_line; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
761 prev_pixel_pair = (unsigned int *)prev_line; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
762 vert_pred = s->vert_pred; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
763 mb_change_index = 0; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
764 mb_change_byte = mb_change_bits[mb_change_index++]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
765 mb_change_byte_mask = 0x01; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
766 pixels_left = s->avctx->width; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
767 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
768 while (pixels_left > 0) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
769 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
770 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
771 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
772 switch (y & 3) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
773 case 0: |
2967 | 774 /* if macroblock width is 2, apply C-Y-C-Y; else |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
775 * apply C-Y-Y */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
776 if (s->block_width == 2) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
777 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
778 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
779 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
780 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
781 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
782 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
783 } else { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
784 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
785 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
786 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
787 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
788 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
789 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
790 break; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
791 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
792 case 1: |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
793 case 3: |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
794 /* always apply 2 Y predictors on these iterations */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
795 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
796 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
797 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
798 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
799 break; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
800 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
801 case 2: |
2967 | 802 /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
803 * depending on the macroblock type */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
804 if (s->block_type == BLOCK_2x2) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
805 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
806 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
807 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
808 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
809 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
810 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
811 } else if (s->block_type == BLOCK_4x2) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
812 APPLY_C_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
813 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
814 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
815 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
816 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
817 } else { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
818 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
819 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
820 APPLY_Y_PREDICTOR_24(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
821 OUTPUT_PIXEL_PAIR(); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
822 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
823 break; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
824 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
825 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
826 } else { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
827 |
2967 | 828 /* skip (copy) four pixels, but reassign the horizontal |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
829 * predictor */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
830 *current_pixel_pair = *prev_pixel_pair++; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
831 *vert_pred++ = *current_pixel_pair++; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
832 *current_pixel_pair = *prev_pixel_pair++; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
833 horiz_pred = *current_pixel_pair - *vert_pred; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
834 *vert_pred++ = *current_pixel_pair++; |
2967 | 835 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
836 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
837 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
838 if (!keyframe) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
839 mb_change_byte_mask <<= 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
840 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
841 /* next byte */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
842 if (!mb_change_byte_mask) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
843 mb_change_byte = mb_change_bits[mb_change_index++]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
844 mb_change_byte_mask = 0x01; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
845 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
846 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
847 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
848 pixels_left -= 4; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
849 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
850 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
851 /* next change row */ |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
852 if (((y + 1) & 3) == 0) |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
853 mb_change_bits += s->mb_change_bits_row_size; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
854 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
855 current_line += s->frame.linesize[0]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
856 prev_line += s->prev_frame.linesize[0]; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
857 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
858 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
859 |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
860 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
861 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
|
862 void *data, int *data_size, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
863 uint8_t *buf, int buf_size) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
864 { |
4827 | 865 TrueMotion1Context *s = avctx->priv_data; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
866 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
867 s->buf = buf; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
868 s->size = buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
869 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
870 if (truemotion1_decode_header(s) == -1) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
871 return -1; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
872 |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
873 s->frame.reference = 1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
874 if (avctx->get_buffer(avctx, &s->frame) < 0) { |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
875 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
876 return -1; |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
877 } |
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
878 |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
879 /* 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
|
880 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
|
881 { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
882 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
|
883 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
|
884 } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
2245
81802fed5b8c
Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents:
2073
diff
changeset
|
885 truemotion1_decode_24bit(s); |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
886 } else { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
887 truemotion1_decode_16bit(s); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
888 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
889 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
890 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
891 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
|
892 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
893 /* shuffle frames */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
894 s->prev_frame = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
895 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
896 *data_size = sizeof(AVFrame); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
897 *(AVFrame*)data = s->frame; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
898 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
899 /* 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
|
900 return buf_size; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
901 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
902 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
903 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
|
904 { |
4827 | 905 TrueMotion1Context *s = avctx->priv_data; |
1650
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
906 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
907 /* release the last frame */ |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
908 if (s->prev_frame.data[0]) |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
909 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
|
910 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
911 av_free(s->vert_pred); |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
912 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
913 return 0; |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
914 } |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
915 |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
916 AVCodec truemotion1_decoder = { |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
917 "truemotion1", |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
918 CODEC_TYPE_VIDEO, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
919 CODEC_ID_TRUEMOTION1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
920 sizeof(TrueMotion1Context), |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
921 truemotion1_decode_init, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
922 NULL, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
923 truemotion1_decode_end, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
924 truemotion1_decode_frame, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
925 CODEC_CAP_DR1, |
bdade3baabfc
initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff
changeset
|
926 }; |