Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 339 lines (297 sloc) 10.862 kb
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
1 /*
2 * QPEG codec
3 * Copyright (c) 2004 Konstantin Shishkov
4 *
b78e719 @DonDiego Change license headers to say 'FFmpeg' instead of 'this program/this …
DonDiego authored
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
b78e719 @DonDiego Change license headers to say 'FFmpeg' instead of 'this program/this …
DonDiego authored
10 * version 2.1 of the License, or (at your option) any later version.
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
11 *
b78e719 @DonDiego Change license headers to say 'FFmpeg' instead of 'this program/this …
DonDiego authored
12 * FFmpeg is distributed in the hope that it will be useful,
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
b78e719 @DonDiego Change license headers to say 'FFmpeg' instead of 'this program/this …
DonDiego authored
18 * License along with FFmpeg; if not, write to the Free Software
5509bff @DonDiego Update licensing information: The FSF changed postal address.
DonDiego authored
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
20 */
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
21
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
22 /**
ba87f08 @DonDiego Remove explicit filename from Doxygen @file commands.
DonDiego authored
23 * @file
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
24 * QPEG codec.
25 */
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
26
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
27 #include "avcodec.h"
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
28 #include "bytestream.h"
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
29
30 typedef struct QpegContext{
31 AVCodecContext *avctx;
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
32 AVFrame pic, ref;
2d8591c make containers pass palette change in AVPacket
Kostya Shishkov authored
33 uint32_t pal[256];
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
34 GetByteContext buffer;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
35 } QpegContext;
36
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
37 static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
38 int stride, int width, int height)
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
39 {
40 int i;
41 int code;
42 int c0, c1;
43 int run, copy;
44 int filled = 0;
f63166f security fixes
Kostya Shishkov authored
45 int rows_to_go;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
46
f63166f security fixes
Kostya Shishkov authored
47 rows_to_go = height;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
48 height--;
49 dst = dst + height * stride;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
50
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
51 while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (rows_to_go > 0)) {
52 code = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
53 run = copy = 0;
54 if(code == 0xFC) /* end-of-picture code */
55 break;
56 if(code >= 0xF8) { /* very long run */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
57 c0 = bytestream2_get_byte(&qctx->buffer);
58 c1 = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
59 run = ((code & 0x7) << 16) + (c0 << 8) + c1 + 2;
60 } else if (code >= 0xF0) { /* long run */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
61 c0 = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
62 run = ((code & 0xF) << 8) + c0 + 2;
63 } else if (code >= 0xE0) { /* short run */
64 run = (code & 0x1F) + 2;
65 } else if (code >= 0xC0) { /* very long copy */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
66 c0 = bytestream2_get_byte(&qctx->buffer);
67 c1 = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
68 copy = ((code & 0x3F) << 16) + (c0 << 8) + c1 + 1;
69 } else if (code >= 0x80) { /* long copy */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
70 c0 = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
71 copy = ((code & 0x7F) << 8) + c0 + 1;
72 } else { /* short copy */
73 copy = code + 1;
74 }
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
75
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
76 /* perform actual run or copy */
77 if(run) {
78 int p;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
79
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
80 p = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
81 for(i = 0; i < run; i++) {
82 dst[filled++] = p;
83 if (filled >= width) {
84 filled = 0;
85 dst -= stride;
f63166f security fixes
Kostya Shishkov authored
86 rows_to_go--;
87 if(rows_to_go <= 0)
88 break;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
89 }
90 }
91 } else {
92 for(i = 0; i < copy; i++) {
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
93 dst[filled++] = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
94 if (filled >= width) {
95 filled = 0;
96 dst -= stride;
f63166f security fixes
Kostya Shishkov authored
97 rows_to_go--;
98 if(rows_to_go <= 0)
99 break;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
100 }
101 }
102 }
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
103 }
104 }
105
cf2baeb mark read-only data as const
Stefan Gehrer authored
106 static const int qpeg_table_h[16] =
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
107 { 0x00, 0x20, 0x20, 0x20, 0x18, 0x10, 0x10, 0x20, 0x10, 0x08, 0x18, 0x08, 0x08, 0x18, 0x10, 0x04};
cf2baeb mark read-only data as const
Stefan Gehrer authored
108 static const int qpeg_table_w[16] =
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
109 { 0x00, 0x20, 0x18, 0x08, 0x18, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x20, 0x08, 0x10, 0x18, 0x04};
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
110
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
111 /* Decodes delta frames */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
112 static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
113 int stride, int width, int height,
114 int delta, const uint8_t *ctable,
115 uint8_t *refdata)
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
116 {
117 int i, j;
118 int code;
119 int filled = 0;
f63166f security fixes
Kostya Shishkov authored
120 int orig_height;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
121
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
122 if(!refdata)
123 refdata= dst;
124
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
125 /* copy prev frame */
126 for(i = 0; i < height; i++)
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
127 memcpy(dst + (i * stride), refdata + (i * stride), width);
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
128
f63166f security fixes
Kostya Shishkov authored
129 orig_height = height;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
130 height--;
131 dst = dst + height * stride;
132
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
133 while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
134 code = bytestream2_get_byte(&qctx->buffer);
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
135
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
136 if(delta) {
137 /* motion compensation */
2af8f2c @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
138 while(bytestream2_get_bytes_left(&qctx->buffer) > 0 && (code & 0xF0) == 0xF0) {
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
139 if(delta == 1) {
140 int me_idx;
141 int me_w, me_h, me_x, me_y;
142 uint8_t *me_plane;
143 int corr, val;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
144
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
145 /* get block size by index */
146 me_idx = code & 0xF;
147 me_w = qpeg_table_w[me_idx];
148 me_h = qpeg_table_h[me_idx];
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
149
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
150 /* extract motion vector */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
151 corr = bytestream2_get_byte(&qctx->buffer);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
152
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
153 val = corr >> 4;
154 if(val > 7)
155 val -= 16;
156 me_x = val;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
157
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
158 val = corr & 0xF;
159 if(val > 7)
160 val -= 16;
161 me_y = val;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
162
f63166f security fixes
Kostya Shishkov authored
163 /* check motion vector */
164 if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
165 (height - me_y - me_h < 0) || (height - me_y > orig_height) ||
166 (filled + me_w > width) || (height - me_h < 0))
167 av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
168 me_x, me_y, me_w, me_h, filled, height);
169 else {
170 /* do motion compensation */
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
171 me_plane = refdata + (filled + me_x) + (height - me_y) * stride;
f63166f security fixes
Kostya Shishkov authored
172 for(j = 0; j < me_h; j++) {
173 for(i = 0; i < me_w; i++)
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
174 dst[filled + i - (j * stride)] = me_plane[i - (j * stride)];
f63166f security fixes
Kostya Shishkov authored
175 }
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
176 }
177 }
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
178 code = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
179 }
180 }
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
181
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
182 if(code == 0xE0) /* end-of-picture code */
183 break;
184 if(code > 0xE0) { /* run code: 0xE1..0xFF */
185 int p;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
186
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
187 code &= 0x1F;
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
188 p = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
189 for(i = 0; i <= code; i++) {
190 dst[filled++] = p;
191 if(filled >= width) {
192 filled = 0;
193 dst -= stride;
194 height--;
4299dfa @michaelni qpeg: Fix out of array writes.
michaelni authored
195 if(height < 0)
196 break;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
197 }
198 }
199 } else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
200 code &= 0x1F;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
201
2af8f2c @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
202 if(code + 1 > bytestream2_get_bytes_left(&qctx->buffer))
81d4b3a @michaelni qpeg: fix overreads.
michaelni authored
203 break;
204
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
205 for(i = 0; i <= code; i++) {
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
206 dst[filled++] = bytestream2_get_byte(&qctx->buffer);
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
207 if(filled >= width) {
208 filled = 0;
209 dst -= stride;
210 height--;
4299dfa @michaelni qpeg: Fix out of array writes.
michaelni authored
211 if(height < 0)
212 break;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
213 }
214 }
215 } else if(code >= 0x80) { /* skip code: 0x80..0xBF */
216 int skip;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
217
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
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)
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
222 skip = bytestream2_get_byte(&qctx->buffer) + 64;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
223 else if(code == 1)
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
224 skip = bytestream2_get_byte(&qctx->buffer) + 320;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
225 else
226 skip = code;
227 filled += skip;
228 while( filled >= width) {
229 filled -= width;
230 dst -= stride;
231 height--;
f63166f security fixes
Kostya Shishkov authored
232 if(height < 0)
233 break;
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
234 }
235 } else {
236 /* zero code treated as one-pixel skip */
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
237 if(code) {
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
238 dst[filled++] = ctable[code & 0x7F];
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
239 }
bb270c0 @DonDiego COSMETICS: tabs --> spaces, some prettyprinting
DonDiego authored
240 else
241 filled++;
242 if(filled >= width) {
243 filled = 0;
244 dst -= stride;
245 height--;
246 }
247 }
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
248 }
249 }
250
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
251 static int decode_frame(AVCodecContext *avctx,
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
252 void *data, int *data_size,
7a00bba Implement avcodec_decode_video2(), _audio3() and _subtitle2() which t…
Thilo Borgmann authored
253 AVPacket *avpkt)
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
254 {
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
255 uint8_t ctable[128];
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
256 QpegContext * const a = avctx->priv_data;
268098d @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
257 AVFrame * p = &a->pic;
258 AVFrame * ref= &a->ref;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
259 uint8_t* outdata;
a452493 @michaelni qpeg: remove unused var from decode_frame()
michaelni authored
260 int delta;
2d8591c make containers pass palette change in AVPacket
Kostya Shishkov authored
261 const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
262
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
263 if (avpkt->size < 0x86) {
264 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
265 return AVERROR_INVALIDDATA;
266 }
267
268 bytestream2_init(&a->buffer, avpkt->data, avpkt->size);
2af8f2c @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
269
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
270 if(ref->data[0])
271 avctx->release_buffer(avctx, ref);
272 FFSWAP(AVFrame, *ref, *p);
90bcbc7 @michaelni Revert "qpeg: use reget_buffer() in decode_frame()"
michaelni authored
273
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
274 p->reference= 3;
90bcbc7 @michaelni Revert "qpeg: use reget_buffer() in decode_frame()"
michaelni authored
275 if(avctx->get_buffer(avctx, p) < 0){
276 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
277 return -1;
278 }
279 outdata = a->pic.data[0];
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
280 bytestream2_skip(&a->buffer, 4);
281 bytestream2_get_buffer(&a->buffer, ctable, 128);
282 bytestream2_skip(&a->buffer, 1);
283
284 delta = bytestream2_get_byte(&a->buffer);
285 if(delta == 0x10) {
286 qpeg_decode_intra(a, outdata, a->pic.linesize[0], avctx->width, avctx->height);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
287 } else {
2af8f2c @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
288 qpeg_decode_inter(a, outdata, a->pic.linesize[0], avctx->width, avctx->height, delta, ctable, a->ref.data[0]);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
289 }
290
291 /* make the palette available on the way out */
2d8591c make containers pass palette change in AVPacket
Kostya Shishkov authored
292 if (pal) {
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
293 a->pic.palette_has_changed = 1;
2d8591c make containers pass palette change in AVPacket
Kostya Shishkov authored
294 memcpy(a->pal, pal, AVPALETTE_SIZE);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
295 }
2d8591c make containers pass palette change in AVPacket
Kostya Shishkov authored
296 memcpy(a->pic.data[1], a->pal, AVPALETTE_SIZE);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
297
298 *data_size = sizeof(AVFrame);
299 *(AVFrame*)data = a->pic;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
300
3e9cd8b @lionaneesh qpeg: Use bytestream2 functions to prevent buffer overreads.
lionaneesh authored
301 return avpkt->size;
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
302 }
303
98a6fff @zuxy Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy authored
304 static av_cold int decode_init(AVCodecContext *avctx){
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
305 QpegContext * const a = avctx->priv_data;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
306
01042d4 lavc: set defaults in internal codec frames
Stefano Sabatini authored
307 avcodec_get_frame_defaults(&a->pic);
308 avcodec_get_frame_defaults(&a->ref);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
309 a->avctx = avctx;
310 avctx->pix_fmt= PIX_FMT_PAL8;
311
312 return 0;
313 }
314
98a6fff @zuxy Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy authored
315 static av_cold int decode_end(AVCodecContext *avctx){
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
316 QpegContext * const a = avctx->priv_data;
562b6c7 @DonDiego Remove unnecessary AVFrame pointer casts.
DonDiego authored
317 AVFrame * const p = &a->pic;
268098d @michaelni Merge remote-tracking branch 'qatar/master'
michaelni authored
318 AVFrame * const ref= &a->ref;
115329f @DonDiego COSMETICS: Remove all trailing whitespace.
DonDiego authored
319
5b22546 @multimediamike free that last frame
multimediamike authored
320 if(p->data[0])
321 avctx->release_buffer(avctx, p);
a0db742 @michaelni Fix buffering in qpeg in a way that allows direct rendering.
michaelni authored
322 if(ref->data[0])
323 avctx->release_buffer(avctx, ref);
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
324
325 return 0;
326 }
327
e7e2df2 @Flameeyes Add ff_ prefix to data symbols of encoders, decoders, hwaccel, parser…
Flameeyes authored
328 AVCodec ff_qpeg_decoder = {
ec6402b @elenril lavc: use designated initialisers for all codecs.
elenril authored
329 .name = "qpeg",
330 .type = AVMEDIA_TYPE_VIDEO,
331 .id = CODEC_ID_QPEG,
332 .priv_data_size = sizeof(QpegContext),
333 .init = decode_init,
334 .close = decode_end,
335 .decode = decode_frame,
336 .capabilities = CODEC_CAP_DR1,
00c3b67 @mstorsjo cosmetics: Align codec declarations
mstorsjo authored
337 .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"),
acfd8f0 @multimediamike native QPEG video decoder, courtesy of Konstantin Shishkov
multimediamike authored
338 };
Something went wrong with that request. Please try again.