Only I-frames are decoded for now.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
... | ... |
@@ -342,6 +342,7 @@ library: |
342 | 342 |
@item iLBC @tab X @tab X |
343 | 343 |
@item Interplay MVE @tab @tab X |
344 | 344 |
@tab Format used in various Interplay computer games. |
345 |
+@item Iterated Systems ClearVideo @tab @tab X |
|
345 | 346 |
@item IV8 @tab @tab X |
346 | 347 |
@tab A format generated by IndigoVision 8000 video server. |
347 | 348 |
@item IVF (On2) @tab X @tab X |
... | ... |
@@ -228,6 +228,7 @@ OBJS-$(CONFIG_CDXL_DECODER) += cdxl.o |
228 | 228 |
OBJS-$(CONFIG_CFHD_DECODER) += cfhd.o cfhddata.o |
229 | 229 |
OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o |
230 | 230 |
OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o |
231 |
+OBJS-$(CONFIG_CLEARVIDEO_DECODER) += clearvideo.o |
|
231 | 232 |
OBJS-$(CONFIG_CLJR_DECODER) += cljrdec.o |
232 | 233 |
OBJS-$(CONFIG_CLJR_ENCODER) += cljrenc.o |
233 | 234 |
OBJS-$(CONFIG_CLLC_DECODER) += cllc.o canopus.o |
... | ... |
@@ -157,6 +157,7 @@ void avcodec_register_all(void) |
157 | 157 |
REGISTER_DECODER(CDXL, cdxl); |
158 | 158 |
REGISTER_DECODER(CFHD, cfhd); |
159 | 159 |
REGISTER_ENCDEC (CINEPAK, cinepak); |
160 |
+ REGISTER_DECODER(CLEARVIDEO, clearvideo); |
|
160 | 161 |
REGISTER_ENCDEC (CLJR, cljr); |
161 | 162 |
REGISTER_DECODER(CLLC, cllc); |
162 | 163 |
REGISTER_ENCDEC (COMFORTNOISE, comfortnoise); |
422 | 423 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,387 @@ |
0 |
+/* |
|
1 |
+ * ClearVideo decoder |
|
2 |
+ * Copyright (c) 2012 Konstantin Shishkov |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+/** |
|
22 |
+ * @file |
|
23 |
+ * ClearVideo decoder |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#include "avcodec.h" |
|
27 |
+#include "idctdsp.h" |
|
28 |
+#include "internal.h" |
|
29 |
+#include "get_bits.h" |
|
30 |
+#include "bytestream.h" |
|
31 |
+ |
|
32 |
+#define NUM_DC_CODES 127 |
|
33 |
+#define NUM_AC_CODES 103 |
|
34 |
+ |
|
35 |
+static const uint8_t clv_dc_codes[NUM_DC_CODES] = { |
|
36 |
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
|
37 |
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
|
38 |
+ 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x07, 0x0B, |
|
39 |
+ 0x0C, 0x08, 0x08, 0x09, 0x04, 0x06, 0x07, 0x05, |
|
40 |
+ 0x04, 0x05, 0x04, 0x06, 0x05, 0x06, 0x07, 0x05, |
|
41 |
+ 0x06, 0x07, 0x06, 0x07, 0x08, 0x06, 0x07, 0x08, |
|
42 |
+ 0x09, 0x0A, 0x0B, 0x07, 0x08, 0x09, 0x07, 0x08, |
|
43 |
+ 0x06, 0x07, 0x08, 0x06, 0x04, 0x05, 0x02, 0x01, |
|
44 |
+ 0x03, 0x06, 0x07, 0x07, 0x09, 0x0A, 0x0B, 0x09, |
|
45 |
+ 0x0A, 0x0B, 0x0A, 0x0B, 0x0C, 0x0D, 0x0C, 0x09, |
|
46 |
+ 0x0D, 0x0A, 0x0B, 0x08, 0x09, 0x0A, 0x0B, 0x07, |
|
47 |
+ 0x08, 0x09, 0x0A, 0x0B, 0x06, 0x07, 0x06, 0x08, |
|
48 |
+ 0x07, 0x09, 0x0A, 0x0B, 0x09, 0x0A, 0x0B, 0x0C, |
|
49 |
+ 0x14, 0x0D, 0x0D, 0x0E, 0x0F, 0x15, 0x15, 0x16, |
|
50 |
+ 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, |
|
51 |
+ 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, |
|
52 |
+}; |
|
53 |
+ |
|
54 |
+static const uint8_t clv_dc_bits[NUM_DC_CODES] = { |
|
55 |
+ 22, 22, 22, 22, 22, 22, 22, 22, |
|
56 |
+ 22, 22, 22, 22, 22, 22, 22, 22, |
|
57 |
+ 22, 22, 22, 21, 22, 22, 19, 20, |
|
58 |
+ 20, 19, 18, 18, 15, 17, 17, 16, |
|
59 |
+ 14, 15, 12, 13, 14, 14, 14, 12, |
|
60 |
+ 12, 12, 11, 11, 11, 10, 10, 10, |
|
61 |
+ 10, 10, 10, 9, 9, 9, 8, 8, |
|
62 |
+ 7, 7, 7, 6, 5, 5, 3, 1, |
|
63 |
+ 3, 5, 5, 6, 7, 7, 7, 8, |
|
64 |
+ 8, 8, 9, 9, 9, 9, 10, 11, |
|
65 |
+ 10, 11, 11, 12, 12, 12, 12, 13, |
|
66 |
+ 14, 14, 14, 14, 15, 15, 16, 17, |
|
67 |
+ 16, 17, 18, 18, 19, 19, 19, 19, |
|
68 |
+ 21, 19, 20, 19, 19, 21, 22, 22, |
|
69 |
+ 22, 22, 22, 22, 22, 22, 22, 22, |
|
70 |
+ 22, 22, 22, 22, 22, 22, 22, |
|
71 |
+}; |
|
72 |
+ |
|
73 |
+static const uint16_t clv_ac_syms[NUM_AC_CODES] = { |
|
74 |
+ 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, |
|
75 |
+ 0x0009, 0x000A, 0x000B, 0x000C, 0x0011, 0x0012, 0x0013, 0x0014, |
|
76 |
+ 0x0015, 0x0016, 0x0021, 0x0022, 0x0023, 0x0024, 0x0031, 0x0032, |
|
77 |
+ 0x0033, 0x0041, 0x0042, 0x0043, 0x0051, 0x0052, 0x0053, 0x0061, |
|
78 |
+ 0x0062, 0x0063, 0x0071, 0x0072, 0x0081, 0x0082, 0x0091, 0x0092, |
|
79 |
+ 0x00A1, 0x00A2, 0x00B1, 0x00C1, 0x00D1, 0x00E1, 0x00F1, 0x0101, |
|
80 |
+ 0x0111, 0x0121, 0x0131, 0x0141, 0x0151, 0x0161, 0x0171, 0x0181, |
|
81 |
+ 0x0191, 0x01A1, 0x1001, 0x1002, 0x1003, 0x1011, 0x1012, 0x1021, |
|
82 |
+ 0x1031, 0x1041, 0x1051, 0x1061, 0x1071, 0x1081, 0x1091, 0x10A1, |
|
83 |
+ 0x10B1, 0x10C1, 0x10D1, 0x10E1, 0x10F1, 0x1101, 0x1111, 0x1121, |
|
84 |
+ 0x1131, 0x1141, 0x1151, 0x1161, 0x1171, 0x1181, 0x1191, 0x11A1, |
|
85 |
+ 0x11B1, 0x11C1, 0x11D1, 0x11E1, 0x11F1, 0x1201, 0x1211, 0x1221, |
|
86 |
+ 0x1231, 0x1241, 0x1251, 0x1261, 0x1271, 0x1281, 0x1BFF, |
|
87 |
+}; |
|
88 |
+ |
|
89 |
+static const uint8_t clv_ac_codes[NUM_AC_CODES] = { |
|
90 |
+ 0x02, 0x0F, 0x15, 0x17, 0x1F, 0x25, 0x24, 0x21, |
|
91 |
+ 0x20, 0x07, 0x06, 0x20, 0x06, 0x14, 0x1E, 0x0F, |
|
92 |
+ 0x21, 0x50, 0x0E, 0x1D, 0x0E, 0x51, 0x0D, 0x23, |
|
93 |
+ 0x0D, 0x0C, 0x22, 0x52, 0x0B, 0x0C, 0x53, 0x13, |
|
94 |
+ 0x0B, 0x54, 0x12, 0x0A, 0x11, 0x09, 0x10, 0x08, |
|
95 |
+ 0x16, 0x55, 0x15, 0x14, 0x1C, 0x1B, 0x21, 0x20, |
|
96 |
+ 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x22, 0x23, |
|
97 |
+ 0x56, 0x57, 0x07, 0x19, 0x05, 0x0F, 0x04, 0x0E, |
|
98 |
+ 0x0D, 0x0C, 0x13, 0x12, 0x11, 0x10, 0x1A, 0x19, |
|
99 |
+ 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x18, 0x17, |
|
100 |
+ 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x07, 0x06, |
|
101 |
+ 0x05, 0x04, 0x24, 0x25, 0x26, 0x27, 0x58, 0x59, |
|
102 |
+ 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x03, |
|
103 |
+}; |
|
104 |
+ |
|
105 |
+static const uint8_t clv_ac_bits[NUM_AC_CODES] = { |
|
106 |
+ 2, 4, 6, 7, 8, 9, 9, 10, |
|
107 |
+ 10, 11, 11, 11, 3, 6, 8, 10, |
|
108 |
+ 11, 12, 4, 8, 10, 12, 5, 9, |
|
109 |
+ 10, 5, 9, 12, 5, 10, 12, 6, |
|
110 |
+ 10, 12, 6, 10, 6, 10, 6, 10, |
|
111 |
+ 7, 12, 7, 7, 8, 8, 9, 9, |
|
112 |
+ 9, 9, 9, 9, 9, 9, 11, 11, |
|
113 |
+ 12, 12, 4, 9, 11, 6, 11, 6, |
|
114 |
+ 6, 6, 7, 7, 7, 7, 8, 8, |
|
115 |
+ 8, 8, 8, 8, 8, 8, 9, 9, |
|
116 |
+ 9, 9, 9, 9, 9, 9, 10, 10, |
|
117 |
+ 10, 10, 11, 11, 11, 11, 12, 12, |
|
118 |
+ 12, 12, 12, 12, 12, 12, 7, |
|
119 |
+}; |
|
120 |
+ |
|
121 |
+typedef struct CLVContext { |
|
122 |
+ AVCodecContext *avctx; |
|
123 |
+ IDCTDSPContext idsp; |
|
124 |
+ AVFrame *pic; |
|
125 |
+ GetBitContext gb; |
|
126 |
+ int mb_width, mb_height; |
|
127 |
+ VLC dc_vlc, ac_vlc; |
|
128 |
+ int luma_dc_quant, chroma_dc_quant, ac_quant; |
|
129 |
+ DECLARE_ALIGNED(16, int16_t, block)[64]; |
|
130 |
+ int top_dc[3], left_dc[4]; |
|
131 |
+} CLVContext; |
|
132 |
+ |
|
133 |
+static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac, |
|
134 |
+ int ac_quant) |
|
135 |
+{ |
|
136 |
+ GetBitContext *gb = &ctx->gb; |
|
137 |
+ int idx = 1, last = 0, val, skip; |
|
138 |
+ |
|
139 |
+ memset(blk, 0, sizeof(*blk) * 64); |
|
140 |
+ blk[0] = get_vlc2(gb, ctx->dc_vlc.table, 9, 3); |
|
141 |
+ if (blk[0] < 0) |
|
142 |
+ return AVERROR_INVALIDDATA; |
|
143 |
+ blk[0] -= 63; |
|
144 |
+ |
|
145 |
+ if (!has_ac) |
|
146 |
+ return 0; |
|
147 |
+ |
|
148 |
+ while (idx < 64 && !last) { |
|
149 |
+ val = get_vlc2(gb, ctx->ac_vlc.table, 9, 2); |
|
150 |
+ if (val < 0) |
|
151 |
+ return AVERROR_INVALIDDATA; |
|
152 |
+ if (val != 0x1BFF) { |
|
153 |
+ last = val >> 12; |
|
154 |
+ skip = (val >> 4) & 0xFF; |
|
155 |
+ val &= 0xF; |
|
156 |
+ if (get_bits1(gb)) |
|
157 |
+ val = -val; |
|
158 |
+ } else { |
|
159 |
+ last = get_bits1(gb); |
|
160 |
+ skip = get_bits(gb, 6); |
|
161 |
+ val = get_sbits(gb, 8); |
|
162 |
+ } |
|
163 |
+ if (val) { |
|
164 |
+ int aval = FFABS(val), sign = val < 0; |
|
165 |
+ val = ac_quant * (2 * aval + 1); |
|
166 |
+ if (!(ac_quant & 1)) |
|
167 |
+ val--; |
|
168 |
+ if (sign) |
|
169 |
+ val = -val; |
|
170 |
+ } |
|
171 |
+ idx += skip; |
|
172 |
+ if (idx >= 64) |
|
173 |
+ return AVERROR_INVALIDDATA; |
|
174 |
+ blk[ff_zigzag_direct[idx++]] = val; |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+ return (idx <= 64 && last) ? 0 : -1; |
|
178 |
+} |
|
179 |
+ |
|
180 |
+#define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP) \ |
|
181 |
+ const int t0 = OP( 2841 * blk[1 * step] + 565 * blk[7 * step]); \ |
|
182 |
+ const int t1 = OP( 565 * blk[1 * step] - 2841 * blk[7 * step]); \ |
|
183 |
+ const int t2 = OP( 1609 * blk[5 * step] + 2408 * blk[3 * step]); \ |
|
184 |
+ const int t3 = OP( 2408 * blk[5 * step] - 1609 * blk[3 * step]); \ |
|
185 |
+ const int t4 = OP( 1108 * blk[2 * step] - 2676 * blk[6 * step]); \ |
|
186 |
+ const int t5 = OP( 2676 * blk[2 * step] + 1108 * blk[6 * step]); \ |
|
187 |
+ const int t6 = ((blk[0 * step] + blk[4 * step]) << dshift) + bias; \ |
|
188 |
+ const int t7 = ((blk[0 * step] - blk[4 * step]) << dshift) + bias; \ |
|
189 |
+ const int t8 = t0 + t2; \ |
|
190 |
+ const int t9 = t0 - t2; \ |
|
191 |
+ const int tA = 181 * (t9 + (t1 - t3)) + 0x80 >> 8; \ |
|
192 |
+ const int tB = 181 * (t9 - (t1 - t3)) + 0x80 >> 8; \ |
|
193 |
+ const int tC = t1 + t3; \ |
|
194 |
+ \ |
|
195 |
+ blk[0 * step] = (t6 + t5 + t8) >> shift; \ |
|
196 |
+ blk[1 * step] = (t7 + t4 + tA) >> shift; \ |
|
197 |
+ blk[2 * step] = (t7 - t4 + tB) >> shift; \ |
|
198 |
+ blk[3 * step] = (t6 - t5 + tC) >> shift; \ |
|
199 |
+ blk[4 * step] = (t6 - t5 - tC) >> shift; \ |
|
200 |
+ blk[5 * step] = (t7 - t4 - tB) >> shift; \ |
|
201 |
+ blk[6 * step] = (t7 + t4 - tA) >> shift; \ |
|
202 |
+ blk[7 * step] = (t6 + t5 - t8) >> shift; \ |
|
203 |
+ |
|
204 |
+#define ROP(x) x |
|
205 |
+#define COP(x) (((x) + 4) >> 3) |
|
206 |
+ |
|
207 |
+static void clv_dct(int16_t *block) |
|
208 |
+{ |
|
209 |
+ int i; |
|
210 |
+ int16_t *ptr; |
|
211 |
+ |
|
212 |
+ ptr = block; |
|
213 |
+ for (i = 0; i < 8; i++) { |
|
214 |
+ DCT_TEMPLATE(ptr, 1, 0x80, 8, 11, ROP); |
|
215 |
+ ptr += 8; |
|
216 |
+ } |
|
217 |
+ |
|
218 |
+ ptr = block; |
|
219 |
+ for (i = 0; i < 8; i++) { |
|
220 |
+ DCT_TEMPLATE(ptr, 8, 0x2000, 14, 8, COP); |
|
221 |
+ ptr++; |
|
222 |
+ } |
|
223 |
+} |
|
224 |
+ |
|
225 |
+static int decode_mb(CLVContext *c, int x, int y) |
|
226 |
+{ |
|
227 |
+ int i; |
|
228 |
+ int has_ac[6]; |
|
229 |
+ int off; |
|
230 |
+ |
|
231 |
+ for (i = 0; i < 6; i++) |
|
232 |
+ has_ac[i] = get_bits1(&c->gb); |
|
233 |
+ |
|
234 |
+ off = x * 16 + y * 16 * c->pic->linesize[0]; |
|
235 |
+ for (i = 0; i < 4; i++) { |
|
236 |
+ if (decode_block(c, c->block, has_ac[i], c->ac_quant) < 0) |
|
237 |
+ return AVERROR_INVALIDDATA; |
|
238 |
+ if (!x && !(i & 1)) { |
|
239 |
+ c->block[0] += c->top_dc[0]; |
|
240 |
+ c->top_dc[0] = c->block[0]; |
|
241 |
+ } else { |
|
242 |
+ c->block[0] += c->left_dc[(i & 2) >> 1]; |
|
243 |
+ } |
|
244 |
+ c->left_dc[(i & 2) >> 1] = c->block[0]; |
|
245 |
+ c->block[0] *= c->luma_dc_quant; |
|
246 |
+ clv_dct(c->block); |
|
247 |
+ if (i == 2) |
|
248 |
+ off += c->pic->linesize[0] * 8; |
|
249 |
+ c->idsp.put_pixels_clamped(c->block, c->pic->data[0] + off + (i & 1) * 8, |
|
250 |
+ c->pic->linesize[0]); |
|
251 |
+ } |
|
252 |
+ |
|
253 |
+ off = x * 8 + y * 8 * c->pic->linesize[1]; |
|
254 |
+ for (i = 1; i < 3; i++) { |
|
255 |
+ if (decode_block(c, c->block, has_ac[i + 3], c->ac_quant) < 0) |
|
256 |
+ return AVERROR_INVALIDDATA; |
|
257 |
+ if (!x) { |
|
258 |
+ c->block[0] += c->top_dc[i]; |
|
259 |
+ c->top_dc[i] = c->block[0]; |
|
260 |
+ } else { |
|
261 |
+ c->block[0] += c->left_dc[i + 1]; |
|
262 |
+ } |
|
263 |
+ c->left_dc[i + 1] = c->block[0]; |
|
264 |
+ c->block[0] *= c->chroma_dc_quant; |
|
265 |
+ clv_dct(c->block); |
|
266 |
+ c->idsp.put_pixels_clamped(c->block, c->pic->data[i] + off, |
|
267 |
+ c->pic->linesize[i]); |
|
268 |
+ } |
|
269 |
+ |
|
270 |
+ return 0; |
|
271 |
+} |
|
272 |
+ |
|
273 |
+static int clv_decode_frame(AVCodecContext *avctx, void *data, |
|
274 |
+ int *got_frame, AVPacket *avpkt) |
|
275 |
+{ |
|
276 |
+ const uint8_t *buf = avpkt->data; |
|
277 |
+ int buf_size = avpkt->size; |
|
278 |
+ CLVContext *c = avctx->priv_data; |
|
279 |
+ GetByteContext gb; |
|
280 |
+ uint32_t frame_type; |
|
281 |
+ int i, j; |
|
282 |
+ int ret; |
|
283 |
+ |
|
284 |
+ bytestream2_init(&gb, buf, buf_size); |
|
285 |
+ if (avctx->codec_tag == MKTAG('C','L','V','1')) { |
|
286 |
+ int skip = bytestream2_get_byte(&gb); |
|
287 |
+ bytestream2_skip(&gb, (skip + 1) * 8); |
|
288 |
+ } |
|
289 |
+ |
|
290 |
+ frame_type = bytestream2_get_byte(&gb); |
|
291 |
+ if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) |
|
292 |
+ return ret; |
|
293 |
+ |
|
294 |
+ c->pic->key_frame = frame_type & 0x20 ? 1 : 0; |
|
295 |
+ c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; |
|
296 |
+ |
|
297 |
+ if (frame_type & 0x2) { |
|
298 |
+ bytestream2_get_be32(&gb); // frame size; |
|
299 |
+ c->ac_quant = bytestream2_get_byte(&gb); |
|
300 |
+ c->luma_dc_quant = 32; |
|
301 |
+ c->chroma_dc_quant = 32; |
|
302 |
+ |
|
303 |
+ if ((ret = init_get_bits8(&c->gb, buf + bytestream2_tell(&gb), |
|
304 |
+ (buf_size - bytestream2_tell(&gb)))) < 0) |
|
305 |
+ return ret; |
|
306 |
+ |
|
307 |
+ for (i = 0; i < 3; i++) |
|
308 |
+ c->top_dc[i] = 32; |
|
309 |
+ for (i = 0; i < 4; i++) |
|
310 |
+ c->left_dc[i] = 32; |
|
311 |
+ |
|
312 |
+ for (j = 0; j < c->mb_height; j++) { |
|
313 |
+ for (i = 0; i < c->mb_width; i++) { |
|
314 |
+ ret |= decode_mb(c, i, j); |
|
315 |
+ } |
|
316 |
+ } |
|
317 |
+ } else { |
|
318 |
+ } |
|
319 |
+ |
|
320 |
+ if ((ret = av_frame_ref(data, c->pic)) < 0) |
|
321 |
+ return ret; |
|
322 |
+ |
|
323 |
+ *got_frame = 1; |
|
324 |
+ |
|
325 |
+ return ret < 0 ? ret : buf_size; |
|
326 |
+} |
|
327 |
+ |
|
328 |
+static av_cold int clv_decode_init(AVCodecContext *avctx) |
|
329 |
+{ |
|
330 |
+ CLVContext * const c = avctx->priv_data; |
|
331 |
+ int ret; |
|
332 |
+ |
|
333 |
+ c->avctx = avctx; |
|
334 |
+ |
|
335 |
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P; |
|
336 |
+ |
|
337 |
+ c->pic = av_frame_alloc(); |
|
338 |
+ if (!c->pic) |
|
339 |
+ return AVERROR(ENOMEM); |
|
340 |
+ |
|
341 |
+ c->mb_width = FFALIGN(avctx->width, 16) >> 4; |
|
342 |
+ c->mb_height = FFALIGN(avctx->height, 16) >> 4; |
|
343 |
+ |
|
344 |
+ ff_idctdsp_init(&c->idsp, avctx); |
|
345 |
+ ret = init_vlc(&c->dc_vlc, 9, NUM_DC_CODES, |
|
346 |
+ clv_dc_bits, 1, 1, |
|
347 |
+ clv_dc_codes, 1, 1, 0); |
|
348 |
+ if (ret) { |
|
349 |
+ av_log(avctx, AV_LOG_ERROR, "Error initialising DC VLC\n"); |
|
350 |
+ return ret; |
|
351 |
+ } |
|
352 |
+ ret = ff_init_vlc_sparse(&c->ac_vlc, 9, NUM_AC_CODES, |
|
353 |
+ clv_ac_bits, 1, 1, |
|
354 |
+ clv_ac_codes, 1, 1, |
|
355 |
+ clv_ac_syms, 2, 2, 0); |
|
356 |
+ if (ret) { |
|
357 |
+ av_log(avctx, AV_LOG_ERROR, "Error initialising AC VLC\n"); |
|
358 |
+ return ret; |
|
359 |
+ } |
|
360 |
+ |
|
361 |
+ return 0; |
|
362 |
+} |
|
363 |
+ |
|
364 |
+static av_cold int clv_decode_end(AVCodecContext *avctx) |
|
365 |
+{ |
|
366 |
+ CLVContext * const c = avctx->priv_data; |
|
367 |
+ |
|
368 |
+ av_frame_free(&c->pic); |
|
369 |
+ |
|
370 |
+ ff_free_vlc(&c->dc_vlc); |
|
371 |
+ ff_free_vlc(&c->ac_vlc); |
|
372 |
+ |
|
373 |
+ return 0; |
|
374 |
+} |
|
375 |
+ |
|
376 |
+AVCodec ff_clearvideo_decoder = { |
|
377 |
+ .name = "clearvideo", |
|
378 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
379 |
+ .id = AV_CODEC_ID_CLEARVIDEO, |
|
380 |
+ .priv_data_size = sizeof(CLVContext), |
|
381 |
+ .init = clv_decode_init, |
|
382 |
+ .close = clv_decode_end, |
|
383 |
+ .decode = clv_decode_frame, |
|
384 |
+ .capabilities = CODEC_CAP_DR1, |
|
385 |
+ .long_name = NULL_IF_CONFIG_SMALL("Iterated Systems ClearVideo"), |
|
386 |
+}; |
... | ... |
@@ -1367,6 +1367,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
1367 | 1367 |
.long_name = NULL_IF_CONFIG_SMALL("ScreenPressor"), |
1368 | 1368 |
.props = AV_CODEC_PROP_LOSSLESS | AV_CODEC_PROP_LOSSY, |
1369 | 1369 |
}, |
1370 |
+ { |
|
1371 |
+ .id = AV_CODEC_ID_CLEARVIDEO, |
|
1372 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
1373 |
+ .name = "clearvideo", |
|
1374 |
+ .long_name = NULL_IF_CONFIG_SMALL("Iterated Systems ClearVideo"), |
|
1375 |
+ .props = AV_CODEC_PROP_LOSSY, |
|
1376 |
+ }, |
|
1370 | 1377 |
|
1371 | 1378 |
/* image codecs */ |
1372 | 1379 |
{ |
... | ... |
@@ -28,8 +28,8 @@ |
28 | 28 |
#include "libavutil/version.h" |
29 | 29 |
|
30 | 30 |
#define LIBAVCODEC_VERSION_MAJOR 57 |
31 |
-#define LIBAVCODEC_VERSION_MINOR 81 |
|
32 |
-#define LIBAVCODEC_VERSION_MICRO 103 |
|
31 |
+#define LIBAVCODEC_VERSION_MINOR 82 |
|
32 |
+#define LIBAVCODEC_VERSION_MICRO 100 |
|
33 | 33 |
|
34 | 34 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
35 | 35 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -450,6 +450,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { |
450 | 450 |
{ AV_CODEC_ID_SPEEDHQ, MKTAG('S', 'H', 'Q', '9') }, |
451 | 451 |
{ AV_CODEC_ID_FMVC, MKTAG('F', 'M', 'V', 'C') }, |
452 | 452 |
{ AV_CODEC_ID_SCPR, MKTAG('S', 'C', 'P', 'R') }, |
453 |
+ { AV_CODEC_ID_CLEARVIDEO, MKTAG('U', 'C', 'O', 'D') }, |
|
453 | 454 |
|
454 | 455 |
{ AV_CODEC_ID_NONE, 0 } |
455 | 456 |
}; |
... | ... |
@@ -43,5 +43,6 @@ const AVCodecTag ff_rm_codec_tags[] = { |
43 | 43 |
{ AV_CODEC_ID_AAC, MKTAG('r','a','a','c') }, |
44 | 44 |
{ AV_CODEC_ID_AAC, MKTAG('r','a','c','p') }, |
45 | 45 |
{ AV_CODEC_ID_RALF, MKTAG('L','S','D',':') }, |
46 |
+ { AV_CODEC_ID_CLEARVIDEO, MKTAG('C','L','V','1') }, |
|
46 | 47 |
{ AV_CODEC_ID_NONE }, |
47 | 48 |
}; |