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