annotate truemotion1.c @ 12468:443f38ceeaad libavcodec

Reimplement av_picture_data_copy() avoiding the use of PixFmtInfo information. Required for moving the function to libavcore.
author stefano
date Tue, 07 Sep 2010 21:23:52 +0000
parents 31736ceab3aa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 11560
diff changeset
23 * @file
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
24 * Duck TrueMotion v1 Video Decoder by
4869
6c5198376e06 cosmetics: remove my email address
alex
parents: 4827
diff changeset
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
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
36 #include "avcodec.h"
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
37 #include "dsputil.h"
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
38
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
39 #include "truemotion1data.h"
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
40
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
41 typedef struct TrueMotion1Context {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
42 AVCodecContext *avctx;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
43 AVFrame frame;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
44
6257
michael
parents: 5514
diff changeset
45 const uint8_t *buf;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
46 int size;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
47
6257
michael
parents: 5514
diff changeset
48 const uint8_t *mb_change_bits;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
49 int mb_change_bits_row_size;
6284
20a72aa8179b more const
michael
parents: 6257
diff changeset
50 const uint8_t *index_stream;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
51 int index_stream_size;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
52
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
53 int flags;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
54 int x, y, w, h;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
55
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
56 uint32_t y_predictor_table[1024];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
57 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
58 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
59 uint32_t fat_c_predictor_table[1024];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
60
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
61 int compression;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
62 int block_type;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
63 int block_width;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
64 int block_height;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
65
2073
95d303a305d2 fix initialization bug in which execution overwrites essential data
melanson
parents: 2028
diff changeset
66 int16_t ydt[8];
95d303a305d2 fix initialization bug in which execution overwrites essential data
melanson
parents: 2028
diff changeset
67 int16_t cdt[8];
95d303a305d2 fix initialization bug in which execution overwrites essential data
melanson
parents: 2028
diff changeset
68 int16_t fat_ydt[8];
95d303a305d2 fix initialization bug in which execution overwrites essential data
melanson
parents: 2028
diff changeset
69 int16_t fat_cdt[8];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
70
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
71 int last_deltaset, last_vectable;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
72
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
73 unsigned int *vert_pred;
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 } TrueMotion1Context;
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 #define FLAG_SPRITE 32
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
78 #define FLAG_KEYFRAME 16
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
79 #define FLAG_INTERFRAME 8
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
80 #define FLAG_INTERPOLATED 4
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
81
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
82 struct frame_header {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
83 uint8_t header_size;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
84 uint8_t compression;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
85 uint8_t deltaset;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
86 uint8_t vectable;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
87 uint16_t ysize;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
88 uint16_t xsize;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
89 uint16_t checksum;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
90 uint8_t version;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
91 uint8_t header_type;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
92 uint8_t flags;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
93 uint8_t control;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
94 uint16_t xoffset;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
95 uint16_t yoffset;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
96 uint16_t width;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
97 uint16_t height;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
98 };
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
99
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
100 #define ALGO_NOP 0
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
101 #define ALGO_RGB16V 1
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
102 #define ALGO_RGB16H 2
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
103 #define ALGO_RGB24H 3
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
104
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
105 /* 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
106 #define BLOCK_2x2 0
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
107 #define BLOCK_2x4 1
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
108 #define BLOCK_4x2 2
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
109 #define BLOCK_4x4 3
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
110
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
111 typedef struct comp_types {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
112 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
113 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
114 int block_height; // hres
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
115 int block_type;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
116 } comp_types;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
117
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
118 /* { valid for metatype }, algorithm, num of deltas, vert res, horiz res */
7129
322023e630a6 mark read-only data as const
stefang
parents: 7040
diff changeset
119 static const comp_types compression_types[17] = {
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
120 { ALGO_NOP, 0, 0, 0 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
121
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
122 { ALGO_RGB16V, 4, 4, BLOCK_4x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
123 { ALGO_RGB16H, 4, 4, BLOCK_4x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
124 { ALGO_RGB16V, 4, 2, BLOCK_4x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
125 { ALGO_RGB16H, 4, 2, BLOCK_4x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
126
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
127 { ALGO_RGB16V, 2, 4, BLOCK_2x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
128 { ALGO_RGB16H, 2, 4, BLOCK_2x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
129 { ALGO_RGB16V, 2, 2, BLOCK_2x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
130 { ALGO_RGB16H, 2, 2, BLOCK_2x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
131
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
132 { ALGO_NOP, 4, 4, BLOCK_4x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
133 { ALGO_RGB24H, 4, 4, BLOCK_4x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
134 { ALGO_NOP, 4, 2, BLOCK_4x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
135 { ALGO_RGB24H, 4, 2, BLOCK_4x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
136
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
137 { ALGO_NOP, 2, 4, BLOCK_2x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
138 { ALGO_RGB24H, 2, 4, BLOCK_2x4 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
139 { ALGO_NOP, 2, 2, BLOCK_2x2 },
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
140 { ALGO_RGB24H, 2, 2, BLOCK_2x2 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
141 };
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
142
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
143 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
144 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
145 int i;
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 if (delta_table_index > 3)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
148 return;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
149
2073
95d303a305d2 fix initialization bug in which execution overwrites essential data
melanson
parents: 2028
diff changeset
150 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
151 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
152 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
153 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
154
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
155 /* 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
156 * skinny Y deltas should be modified */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
157 for (i = 0; i < 8; i++)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
158 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
159 /* 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
160 * 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
161 s->ydt[i] &= 0xFFFE;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
162 s->ydt[i] /= 2;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
163 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
164 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
165
9985
266bf83f634d Replace WORDS_BIGENDIAN with HAVE_BIGENDIAN
mru
parents: 9981
diff changeset
166 #if HAVE_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
167 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
168 #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
169 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
170 #endif
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
171 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
172 int lo, hi;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
173
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
174 lo = ydt[p1];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
175 lo += (lo << 5) + (lo << 10);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
176 hi = ydt[p2];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
177 hi += (hi << 5) + (hi << 10);
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
178 return (lo + (hi << 16)) << 1;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
179 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
180
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
181 static int make_cdt15_entry(int p1, int p2, int16_t *cdt)
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
182 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
183 int r, b, lo;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
184
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
185 b = cdt[p2];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
186 r = cdt[p1] << 10;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
187 lo = b + r;
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
188 return (lo + (lo << 16)) << 1;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
189 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
190
9985
266bf83f634d Replace WORDS_BIGENDIAN with HAVE_BIGENDIAN
mru
parents: 9981
diff changeset
191 #if HAVE_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
192 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
193 #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
194 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
195 #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
196 {
81802fed5b8c Decoding to bgr15/16 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 int lo, hi;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
198
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
199 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
200 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
201 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
202 hi += (hi << 6) + (hi << 11);
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
203 return (lo + (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
204 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 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
207 {
81802fed5b8c Decoding to bgr15/16 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 int r, b, lo;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
209
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
210 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
211 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
212 lo = b + r;
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
213 return (lo + (lo << 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
214 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 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
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 lo, hi;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
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 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
221 hi = ydt[p2];
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
222 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
223 }
81802fed5b8c Decoding to bgr15/16 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 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
226 {
81802fed5b8c Decoding to bgr15/16 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 int r, b;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
228
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
229 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
230 r = cdt[p1]<<16;
6750
c93570aeb3eb Remove unnecessary parentheses from return calls.
diego
parents: 6717
diff changeset
231 return (b+r) << 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
232 }
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
233
2753
ba8ecddf5598 adding a few const
michael
parents: 2453
diff changeset
234 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
235 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
236 int len, i, j;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
237 unsigned char delta_pair;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
238
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
239 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
240 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
241 len = *sel_vector_table++ / 2;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
242 for (j = 0; j < len; j++)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
243 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
244 delta_pair = *sel_vector_table++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
245 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
246 make_ydt15_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
247 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
248 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
249 }
81802fed5b8c Decoding to bgr15/16 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 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
251 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
252 }
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
253 }
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
254
2753
ba8ecddf5598 adding a few const
michael
parents: 2453
diff changeset
255 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
256 {
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
257 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
258 unsigned char delta_pair;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
259
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
260 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
261 {
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
262 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
263 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
264 {
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
265 delta_pair = *sel_vector_table++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
266 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
267 make_ydt16_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
268 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
269 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
270 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
271 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
272 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
273 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
274 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
275
2753
ba8ecddf5598 adding a few const
michael
parents: 2453
diff changeset
276 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
277 {
81802fed5b8c Decoding to bgr15/16 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 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
279 unsigned char delta_pair;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
280
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
281 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
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 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
284 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
285 {
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
286 delta_pair = *sel_vector_table++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
287 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
288 make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
289 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
290 make_cdt24_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
291 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
292 make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->fat_ydt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
293 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
294 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
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 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
297 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
298 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
299 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
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 }
81802fed5b8c Decoding to bgr15/16 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
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
303 /* Returns the number of bytes consumed from the bytestream. Returns -1 if
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
304 * 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
305 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
306 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
307 int i;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
308 struct frame_header header;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
309 uint8_t header_buffer[128]; /* logical maximum size of the header */
2753
ba8ecddf5598 adding a few const
michael
parents: 2453
diff changeset
310 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
311
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
312 /* 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
313 * 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
314 * 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
315 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
316
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
317 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
318 if (s->buf[0] < 0x10)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
319 {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
320 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
321 return -1;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
322 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
323
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
324 /* 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
325 memset(header_buffer, 0, 128);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
326 for (i = 1; i < header.header_size; i++)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
327 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
328
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
329 header.compression = header_buffer[0];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
330 header.deltaset = header_buffer[1];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
331 header.vectable = header_buffer[2];
4364
05e932ddaaa9 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 3947
diff changeset
332 header.ysize = AV_RL16(&header_buffer[3]);
05e932ddaaa9 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 3947
diff changeset
333 header.xsize = AV_RL16(&header_buffer[5]);
05e932ddaaa9 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 3947
diff changeset
334 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
335 header.version = header_buffer[9];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
336 header.header_type = header_buffer[10];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
337 header.flags = header_buffer[11];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
338 header.control = header_buffer[12];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
339
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
340 /* Version 2 */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
341 if (header.version >= 2)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
342 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
343 if (header.header_type > 3)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
344 {
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
345 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
346 return -1;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
347 } 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
348 s->flags = header.flags;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
349 if (!(s->flags & FLAG_INTERFRAME))
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
350 s->flags |= FLAG_KEYFRAME;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
351 } else
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
352 s->flags = FLAG_KEYFRAME;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
353 } else /* Version 1 */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
354 s->flags = FLAG_KEYFRAME;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
355
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
356 if (s->flags & FLAG_SPRITE) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
357 av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n");
4476
16e85254118f fix use of uninitialized variables
faust3
parents: 4364
diff changeset
358 /* FIXME header.width, height, xoffset and yoffset aren't initialized */
16e85254118f fix use of uninitialized variables
faust3
parents: 4364
diff changeset
359 #if 0
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
360 s->w = header.width;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
361 s->h = header.height;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
362 s->x = header.xoffset;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
363 s->y = header.yoffset;
4476
16e85254118f fix use of uninitialized variables
faust3
parents: 4364
diff changeset
364 #else
16e85254118f fix use of uninitialized variables
faust3
parents: 4364
diff changeset
365 return -1;
16e85254118f fix use of uninitialized variables
faust3
parents: 4364
diff changeset
366 #endif
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
367 } else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
368 s->w = header.xsize;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
369 s->h = header.ysize;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
370 if (header.header_type < 2) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
371 if ((s->w < 213) && (s->h >= 176))
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
372 {
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
373 s->flags |= FLAG_INTERPOLATED;
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
374 av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n");
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
375 }
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
376 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
377 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
378
7006
48cfbc65d688 Fix reading an element after the array.
michael
parents: 6750
diff changeset
379 if (header.compression >= 17) {
1927
d7505fbe66cb conversion to av_log
alex
parents: 1881
diff changeset
380 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
381 return -1;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
382 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
383
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
384 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
385 (header.vectable != s->last_vectable))
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
386 select_delta_tables(s, header.deltaset);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
387
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
388 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
389 sel_vector_table = pc_tbl2;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
390 else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
391 if (header.vectable < 4)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
392 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
393 else {
1927
d7505fbe66cb conversion to av_log
alex
parents: 1881
diff changeset
394 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
395 return -1;
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 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
398
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
399 // 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
400 if (compression_types[header.compression].algorithm == ALGO_RGB24H)
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4476
diff changeset
401 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
402 else
4561
726deec26122 cosmetics: aswell --> as well typo fix
diego
parents: 4494
diff changeset
403 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
404
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
405 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
406 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
407 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
408 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
409 else
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
410 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
411 gen_vector_table15(s, sel_vector_table);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
412 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
413 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
414 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
415
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
416 /* 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
417 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
418 if (s->flags & FLAG_KEYFRAME) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
419 /* 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
420 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
421 } else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
422 /* one change bit per 4x4 block */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
423 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
424 (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
425 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
426 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
427
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
428 s->last_deltaset = header.deltaset;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
429 s->last_vectable = header.vectable;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
430 s->compression = header.compression;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
431 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
432 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
433 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
434
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
435 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
436 av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
437 s->last_deltaset, s->last_vectable, s->compression, s->block_width,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
438 s->block_height, s->block_type,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
439 s->flags & FLAG_KEYFRAME ? " KEY" : "",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
440 s->flags & FLAG_INTERFRAME ? " INTER" : "",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
441 s->flags & FLAG_SPRITE ? " SPRITE" : "",
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
442 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
443
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
444 return header.header_size;
1650
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
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6284
diff changeset
447 static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
448 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
449 TrueMotion1Context *s = avctx->priv_data;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
450
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
451 s->avctx = avctx;
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 // 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
454 // if (avctx->bits_per_sample == 24)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
455 // 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
456 // else
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
457 // 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
458
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
459 s->frame.data[0] = NULL;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
460
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
461 /* 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
462 * predictor is 0 to start with */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
463 s->vert_pred =
2938
363be7734674 improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents: 2753
diff changeset
464 (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
465
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
466 return 0;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
467 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
468
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
469 /*
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
470 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
471
81802fed5b8c Decoding to bgr15/16 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 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
473 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
474 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
475
81802fed5b8c Decoding to bgr15/16 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 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
477 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 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
492 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
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
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
495 #define GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
496 {\
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
497 if (index_stream_index >= s->index_stream_size) { \
1927
d7505fbe66cb conversion to av_log
alex
parents: 1881
diff changeset
498 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
499 return; \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
500 } \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
501 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
502 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
503
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
504 #define APPLY_C_PREDICTOR() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
505 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
506 horiz_pred += (predictor_pair >> 1); \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
507 if (predictor_pair & 1) { \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
508 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
509 if (!index) { \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
510 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
511 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
512 horiz_pred += ((predictor_pair >> 1) * 5); \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
513 if (predictor_pair & 1) \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
514 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
515 else \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
516 index++; \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
517 } \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
518 } else \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
519 index++;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
520
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
521 #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
522 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
523 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
524 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
525 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
526 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
527 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
528 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
529 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
530 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
531 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
532 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
533 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
534 } \
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
535 } else \
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
536 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
537
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
538
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
539 #define APPLY_Y_PREDICTOR() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
540 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
541 horiz_pred += (predictor_pair >> 1); \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
542 if (predictor_pair & 1) { \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
543 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
544 if (!index) { \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
545 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
546 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
547 horiz_pred += ((predictor_pair >> 1) * 5); \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
548 if (predictor_pair & 1) \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
549 GET_NEXT_INDEX() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
550 else \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
551 index++; \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
552 } \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
553 } else \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
554 index++;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
555
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
556 #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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564 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
565 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
566 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
567 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
568 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
569 } \
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
570 } 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
571 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
572
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
573 #define OUTPUT_PIXEL_PAIR() \
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
574 *current_pixel_pair = *vert_pred + horiz_pred; \
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
575 *vert_pred++ = *current_pixel_pair++;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
576
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
577 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
578 {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
579 int y;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
580 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
581 unsigned int predictor_pair;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
582 unsigned int horiz_pred;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
583 unsigned int *vert_pred;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
584 unsigned int *current_pixel_pair;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
585 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
586 int keyframe = s->flags & FLAG_KEYFRAME;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
587
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
588 /* these variables are for managing the stream of macroblock change bits */
6284
20a72aa8179b more const
michael
parents: 6257
diff changeset
589 const unsigned char *mb_change_bits = s->mb_change_bits;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
590 unsigned char mb_change_byte;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
591 unsigned char mb_change_byte_mask;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
592 int mb_change_index;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
593
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
594 /* 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
595 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
596 int index;
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 /* clean out the line buffer */
2938
363be7734674 improvements by Reimar D«Óffinger; 24-bit decoding is not perfect, only
melanson
parents: 2753
diff changeset
599 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
600
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
601 GET_NEXT_INDEX();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
602
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
603 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
604
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
605 /* 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
606 horiz_pred = 0;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
607 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
608 vert_pred = s->vert_pred;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
609 mb_change_index = 0;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
610 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
611 mb_change_byte_mask = 0x01;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
612 pixels_left = s->avctx->width;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
613
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
614 while (pixels_left > 0) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
615
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
616 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
617
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
618 switch (y & 3) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
619 case 0:
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
620 /* 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
621 * apply C-Y-Y */
1654
1c123e036890 this should make the decoder safe for big-endian platforms
melanson
parents: 1650
diff changeset
622 if (s->block_width == 2) {
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
623 APPLY_C_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
624 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
625 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
626 APPLY_C_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
627 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
628 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
629 } else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
630 APPLY_C_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
631 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
632 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
633 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
634 OUTPUT_PIXEL_PAIR();
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 break;
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 case 1:
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
639 case 3:
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
640 /* 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
641 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
642 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
643 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
644 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
645 break;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
646
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
647 case 2:
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
648 /* 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
649 * depending on the macroblock type */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
650 if (s->block_type == BLOCK_2x2) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
651 APPLY_C_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
652 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
653 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
654 APPLY_C_PREDICTOR();
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 } 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
658 APPLY_C_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
659 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
660 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
661 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
662 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
663 } else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
664 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
665 OUTPUT_PIXEL_PAIR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
666 APPLY_Y_PREDICTOR();
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
667 OUTPUT_PIXEL_PAIR();
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 break;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
670 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
671
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
672 } else {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
673
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
674 /* 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
675 * predictor */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
676 *vert_pred++ = *current_pixel_pair++;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
677 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
678 *vert_pred++ = *current_pixel_pair++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
679
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
680 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
681
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
682 if (!keyframe) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
683 mb_change_byte_mask <<= 1;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
684
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
685 /* next byte */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
686 if (!mb_change_byte_mask) {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
687 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
688 mb_change_byte_mask = 0x01;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
689 }
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
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
692 pixels_left -= 4;
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
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
695 /* next change row */
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
696 if (((y + 1) & 3) == 0)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
697 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
698
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
699 current_line += s->frame.linesize[0];
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
700 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
701 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
702
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
703 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
704 {
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
705 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
706 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
707 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
708 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
709 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
710 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
711 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
712 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
713
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
714 /* these variables are for managing the stream of macroblock change bits */
6284
20a72aa8179b more const
michael
parents: 6257
diff changeset
715 const unsigned char *mb_change_bits = s->mb_change_bits;
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
716 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
717 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
718 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
719
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
720 /* 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
721 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
722 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
723
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
724 /* clean out the line buffer */
2939
04cf75617d00 clear the whole vert_pred buffer for 24 bit decoding.
reimar
parents: 2938
diff changeset
725 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
726
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
727 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
728
81802fed5b8c Decoding to bgr15/16 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 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
730
81802fed5b8c Decoding to bgr15/16 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 /* 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
732 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
733 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
734 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
735 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
736 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
737 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
738 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
739
81802fed5b8c Decoding to bgr15/16 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 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
741
81802fed5b8c Decoding to bgr15/16 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 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
743
81802fed5b8c Decoding to bgr15/16 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 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
745 case 0:
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
746 /* 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
747 * 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
748 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
749 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
750 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
751 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
752 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
753 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
754 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
755 } 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
756 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
757 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
758 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
759 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
760 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
761 }
81802fed5b8c Decoding to bgr15/16 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 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
763
81802fed5b8c Decoding to bgr15/16 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 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
765 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
766 /* 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
767 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
768 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
769 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
770 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
771 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
772
81802fed5b8c Decoding to bgr15/16 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 2:
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
774 /* 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
775 * 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
776 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
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 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
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 } 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
790 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
791 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
792 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
793 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
794 }
81802fed5b8c Decoding to bgr15/16 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 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
796 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 } 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
799
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
800 /* 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
801 * 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
802 *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
803 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
804 *vert_pred++ = *current_pixel_pair++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2939
diff changeset
805
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
806 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 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
809 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
810
81802fed5b8c Decoding to bgr15/16 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 /* 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
812 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
813 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
814 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
815 }
81802fed5b8c Decoding to bgr15/16 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 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 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
819 }
81802fed5b8c Decoding to bgr15/16 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
81802fed5b8c Decoding to bgr15/16 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 /* 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
822 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
823 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
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 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
826 }
81802fed5b8c Decoding to bgr15/16 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 }
81802fed5b8c Decoding to bgr15/16 from 16bit input. Decoding of 24bit input added, not yet finished, but at least the picture can be recognized
alex
parents: 2073
diff changeset
828
81802fed5b8c Decoding to bgr15/16 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
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
830 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
831 void *data, int *data_size,
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
832 AVPacket *avpkt)
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
833 {
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
834 const uint8_t *buf = avpkt->data;
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
835 int buf_size = avpkt->size;
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
836 TrueMotion1Context *s = avctx->priv_data;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
837
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
838 s->buf = buf;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
839 s->size = buf_size;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
840
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
841 if (truemotion1_decode_header(s) == -1)
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
842 return -1;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
843
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
844 s->frame.reference = 1;
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
845 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID |
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
846 FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
847 if (avctx->reget_buffer(avctx, &s->frame) < 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
848 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
849 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
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
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
852 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
853 truemotion1_decode_24bit(s);
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
854 } else if (compression_types[s->compression].algorithm != ALGO_NOP) {
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
855 truemotion1_decode_16bit(s);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
856 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
857
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
858 *data_size = sizeof(AVFrame);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
859 *(AVFrame*)data = s->frame;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
860
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
861 /* 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
862 return buf_size;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
863 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
864
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6284
diff changeset
865 static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
866 {
4827
b3ee9a1526b0 Get rid of unnecessary pointer casts.
diego
parents: 4801
diff changeset
867 TrueMotion1Context *s = avctx->priv_data;
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
868
5514
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
869 if (s->frame.data[0])
e2dbd1623e1d use reget_buffer and remove internal copying of buffer - codec works again
alex
parents: 4962
diff changeset
870 avctx->release_buffer(avctx, &s->frame);
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
871
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
872 av_free(s->vert_pred);
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
873
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
874 return 0;
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
875 }
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
876
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
877 AVCodec truemotion1_decoder = {
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
878 "truemotion1",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 9985
diff changeset
879 AVMEDIA_TYPE_VIDEO,
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
880 CODEC_ID_TRUEMOTION1,
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
881 sizeof(TrueMotion1Context),
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
882 truemotion1_decode_init,
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
883 NULL,
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
884 truemotion1_decode_end,
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
885 truemotion1_decode_frame,
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
886 CODEC_CAP_DR1,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 7006
diff changeset
887 .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"),
1650
bdade3baabfc initial support for Duck TrueMotion v1 (think of it as On2 VP1); only
melanson
parents:
diff changeset
888 };