Mercurial > libavcodec.hg
annotate qpeg.c @ 5134:879b809b00cb libavcodec
kill one vector constant value load by the right combination of vec_splatX/vec_sl
patch by Sigbjorn Skjaeret %sskjer-1 A broadpark P no%
author | gpoirier |
---|---|
date | Tue, 12 Jun 2007 21:24:25 +0000 |
parents | 59f4fb490fa7 |
children | 16edc523f0c9 |
rev | line source |
---|---|
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
1 /* |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
2 * QPEG codec |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2004 Konstantin Shishkov |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
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 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
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. |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
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, |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
16 * |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
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 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
20 * |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
21 */ |
2967 | 22 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
23 /** |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
24 * @file qpeg.c |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
25 * QPEG codec. |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
26 */ |
2967 | 27 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
28 #include "avcodec.h" |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
29 #include "mpegvideo.h" |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
30 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
31 typedef struct QpegContext{ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
32 AVCodecContext *avctx; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
33 AVFrame pic; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
34 uint8_t *refdata; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
35 } QpegContext; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
36 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
37 static void qpeg_decode_intra(uint8_t *src, uint8_t *dst, int size, |
2979 | 38 int stride, int width, int height) |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
39 { |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
40 int i; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
41 int code; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
42 int c0, c1; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
43 int run, copy; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
44 int filled = 0; |
2823 | 45 int rows_to_go; |
2967 | 46 |
2823 | 47 rows_to_go = height; |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
48 height--; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
49 dst = dst + height * stride; |
2967 | 50 |
2823 | 51 while((size > 0) && (rows_to_go > 0)) { |
2979 | 52 code = *src++; |
53 size--; | |
54 run = copy = 0; | |
55 if(code == 0xFC) /* end-of-picture code */ | |
56 break; | |
57 if(code >= 0xF8) { /* very long run */ | |
58 c0 = *src++; | |
59 c1 = *src++; | |
60 size -= 2; | |
61 run = ((code & 0x7) << 16) + (c0 << 8) + c1 + 2; | |
62 } else if (code >= 0xF0) { /* long run */ | |
63 c0 = *src++; | |
64 size--; | |
65 run = ((code & 0xF) << 8) + c0 + 2; | |
66 } else if (code >= 0xE0) { /* short run */ | |
67 run = (code & 0x1F) + 2; | |
68 } else if (code >= 0xC0) { /* very long copy */ | |
69 c0 = *src++; | |
70 c1 = *src++; | |
71 size -= 2; | |
72 copy = ((code & 0x3F) << 16) + (c0 << 8) + c1 + 1; | |
73 } else if (code >= 0x80) { /* long copy */ | |
74 c0 = *src++; | |
75 size--; | |
76 copy = ((code & 0x7F) << 8) + c0 + 1; | |
77 } else { /* short copy */ | |
78 copy = code + 1; | |
79 } | |
2967 | 80 |
2979 | 81 /* perform actual run or copy */ |
82 if(run) { | |
83 int p; | |
2967 | 84 |
2979 | 85 p = *src++; |
86 size--; | |
87 for(i = 0; i < run; i++) { | |
88 dst[filled++] = p; | |
89 if (filled >= width) { | |
90 filled = 0; | |
91 dst -= stride; | |
2823 | 92 rows_to_go--; |
93 if(rows_to_go <= 0) | |
94 break; | |
2979 | 95 } |
96 } | |
97 } else { | |
2823 | 98 size -= copy; |
2979 | 99 for(i = 0; i < copy; i++) { |
100 dst[filled++] = *src++; | |
101 if (filled >= width) { | |
102 filled = 0; | |
103 dst -= stride; | |
2823 | 104 rows_to_go--; |
105 if(rows_to_go <= 0) | |
106 break; | |
2979 | 107 } |
108 } | |
109 } | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
110 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
111 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
112 |
2967 | 113 static int qpeg_table_h[16] = |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
114 { 0x00, 0x20, 0x20, 0x20, 0x18, 0x10, 0x10, 0x20, 0x10, 0x08, 0x18, 0x08, 0x08, 0x18, 0x10, 0x04}; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
115 static int qpeg_table_w[16] = |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
116 { 0x00, 0x20, 0x18, 0x08, 0x18, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x20, 0x08, 0x10, 0x18, 0x04}; |
2967 | 117 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
118 /* Decodes delta frames */ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
119 static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size, |
2979 | 120 int stride, int width, int height, |
121 int delta, uint8_t *ctable, uint8_t *refdata) | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
122 { |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
123 int i, j; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
124 int code; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
125 int filled = 0; |
2823 | 126 int orig_height; |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
127 uint8_t *blkdata; |
2967 | 128 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
129 /* copy prev frame */ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
130 for(i = 0; i < height; i++) |
2979 | 131 memcpy(refdata + (i * width), dst + (i * stride), width); |
2967 | 132 |
2823 | 133 orig_height = height; |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
134 blkdata = src - 0x86; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
135 height--; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
136 dst = dst + height * stride; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
137 |
2823 | 138 while((size > 0) && (height >= 0)) { |
2979 | 139 code = *src++; |
140 size--; | |
2967 | 141 |
2979 | 142 if(delta) { |
143 /* motion compensation */ | |
144 while((code & 0xF0) == 0xF0) { | |
145 if(delta == 1) { | |
146 int me_idx; | |
147 int me_w, me_h, me_x, me_y; | |
148 uint8_t *me_plane; | |
149 int corr, val; | |
2967 | 150 |
2979 | 151 /* get block size by index */ |
152 me_idx = code & 0xF; | |
153 me_w = qpeg_table_w[me_idx]; | |
154 me_h = qpeg_table_h[me_idx]; | |
2967 | 155 |
2979 | 156 /* extract motion vector */ |
157 corr = *src++; | |
158 size--; | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
159 |
2979 | 160 val = corr >> 4; |
161 if(val > 7) | |
162 val -= 16; | |
163 me_x = val; | |
2967 | 164 |
2979 | 165 val = corr & 0xF; |
166 if(val > 7) | |
167 val -= 16; | |
168 me_y = val; | |
2967 | 169 |
2823 | 170 /* check motion vector */ |
171 if ((me_x + filled < 0) || (me_x + me_w + filled > width) || | |
172 (height - me_y - me_h < 0) || (height - me_y > orig_height) || | |
173 (filled + me_w > width) || (height - me_h < 0)) | |
174 av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n", | |
175 me_x, me_y, me_w, me_h, filled, height); | |
176 else { | |
177 /* do motion compensation */ | |
178 me_plane = refdata + (filled + me_x) + (height - me_y) * width; | |
179 for(j = 0; j < me_h; j++) { | |
180 for(i = 0; i < me_w; i++) | |
181 dst[filled + i - (j * stride)] = me_plane[i - (j * width)]; | |
182 } | |
2979 | 183 } |
184 } | |
185 code = *src++; | |
186 size--; | |
187 } | |
188 } | |
2967 | 189 |
2979 | 190 if(code == 0xE0) /* end-of-picture code */ |
191 break; | |
192 if(code > 0xE0) { /* run code: 0xE1..0xFF */ | |
193 int p; | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
194 |
2979 | 195 code &= 0x1F; |
196 p = *src++; | |
197 size--; | |
198 for(i = 0; i <= code; i++) { | |
199 dst[filled++] = p; | |
200 if(filled >= width) { | |
201 filled = 0; | |
202 dst -= stride; | |
203 height--; | |
204 } | |
205 } | |
206 } else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */ | |
207 code &= 0x1F; | |
2967 | 208 |
2979 | 209 for(i = 0; i <= code; i++) { |
210 dst[filled++] = *src++; | |
211 if(filled >= width) { | |
212 filled = 0; | |
213 dst -= stride; | |
214 height--; | |
215 } | |
216 } | |
217 size -= code + 1; | |
218 } else if(code >= 0x80) { /* skip code: 0x80..0xBF */ | |
219 int skip; | |
2967 | 220 |
2979 | 221 code &= 0x3F; |
222 /* codes 0x80 and 0x81 are actually escape codes, | |
223 skip value minus constant is in the next byte */ | |
224 if(!code) | |
225 skip = (*src++) + 64; | |
226 else if(code == 1) | |
227 skip = (*src++) + 320; | |
228 else | |
229 skip = code; | |
230 filled += skip; | |
231 while( filled >= width) { | |
232 filled -= width; | |
233 dst -= stride; | |
234 height--; | |
2823 | 235 if(height < 0) |
236 break; | |
2979 | 237 } |
238 } else { | |
239 /* zero code treated as one-pixel skip */ | |
240 if(code) | |
241 dst[filled++] = ctable[code & 0x7F]; | |
242 else | |
243 filled++; | |
244 if(filled >= width) { | |
245 filled = 0; | |
246 dst -= stride; | |
247 height--; | |
248 } | |
249 } | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
250 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
251 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
252 |
2967 | 253 static int decode_frame(AVCodecContext *avctx, |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
254 void *data, int *data_size, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
255 uint8_t *buf, int buf_size) |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
256 { |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
257 QpegContext * const a = avctx->priv_data; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
258 AVFrame * const p= (AVFrame*)&a->pic; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
259 uint8_t* outdata; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
260 int delta; |
2967 | 261 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
262 if(p->data[0]) |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
263 avctx->release_buffer(avctx, p); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
264 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
265 p->reference= 0; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
266 if(avctx->get_buffer(avctx, p) < 0){ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
267 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
268 return -1; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
269 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
270 outdata = a->pic.data[0]; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
271 if(buf[0x85] == 0x10) { |
2979 | 272 qpeg_decode_intra(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height); |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
273 } else { |
2979 | 274 delta = buf[0x85]; |
275 qpeg_decode_inter(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height, delta, buf + 4, a->refdata); | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
276 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
277 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
278 /* make the palette available on the way out */ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
279 memcpy(a->pic.data[1], a->avctx->palctrl->palette, AVPALETTE_SIZE); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
280 if (a->avctx->palctrl->palette_changed) { |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
281 a->pic.palette_has_changed = 1; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
282 a->avctx->palctrl->palette_changed = 0; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
283 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
284 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
285 *data_size = sizeof(AVFrame); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
286 *(AVFrame*)data = a->pic; |
2967 | 287 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
288 return buf_size; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
289 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
290 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
291 static int decode_init(AVCodecContext *avctx){ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
292 QpegContext * const a = avctx->priv_data; |
2967 | 293 |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
294 a->avctx = avctx; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
295 avctx->pix_fmt= PIX_FMT_PAL8; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
296 a->pic.data[0] = NULL; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
297 a->refdata = av_malloc(avctx->width * avctx->height); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
298 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
299 return 0; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
300 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
301 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
302 static int decode_end(AVCodecContext *avctx){ |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
303 QpegContext * const a = avctx->priv_data; |
2586 | 304 AVFrame * const p= (AVFrame*)&a->pic; |
2967 | 305 |
2586 | 306 if(p->data[0]) |
307 avctx->release_buffer(avctx, p); | |
2355
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
308 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
309 av_free(a->refdata); |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
310 return 0; |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
311 } |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
312 |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
313 AVCodec qpeg_decoder = { |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
314 "qpeg", |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
315 CODEC_TYPE_VIDEO, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
316 CODEC_ID_QPEG, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
317 sizeof(QpegContext), |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
318 decode_init, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
319 NULL, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
320 decode_end, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
321 decode_frame, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
322 CODEC_CAP_DR1, |
69fcdad5f7d5
native QPEG video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
323 }; |