comparison fraps.c @ 6477:36fb492f44cc libavcodec

Fraps v5 decoding support
author kostya
date Sun, 09 Mar 2008 09:04:35 +0000
parents e9aa4dc2d937
children 48759bfbd073
comparison
equal deleted inserted replaced
6476:e9aa4dc2d937 6477:36fb492f44cc
146 146
147 header = AV_RL32(buf); 147 header = AV_RL32(buf);
148 version = header & 0xff; 148 version = header & 0xff;
149 header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */ 149 header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
150 150
151 if (version > 2 && version != 4) { 151 if (version > 2 && version != 4 && version != 5) {
152 av_log(avctx, AV_LOG_ERROR, 152 av_log(avctx, AV_LOG_ERROR,
153 "This file is encoded with Fraps version %d. " \ 153 "This file is encoded with Fraps version %d. " \
154 "This codec can only decode version 0, 1, 2 and 4.\n", version); 154 "This codec can only decode version 0, 1, 2 and 4.\n", version);
155 return -1; 155 return -1;
156 } 156 }
286 av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); 286 av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
287 return -1; 287 return -1;
288 } 288 }
289 } 289 }
290 break; 290 break;
291 case 5:
292 /* Virtually the same as version 4, but is for RGB24 */
293 avctx->pix_fmt = PIX_FMT_BGR24;
294 planes = 3;
295 f->reference = 1;
296 f->buffer_hints = FF_BUFFER_HINTS_VALID |
297 FF_BUFFER_HINTS_PRESERVE |
298 FF_BUFFER_HINTS_REUSABLE;
299 if (avctx->reget_buffer(avctx, f)) {
300 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
301 return -1;
302 }
303 /* skip frame */
304 if(buf_size == 8) {
305 f->pict_type = FF_P_TYPE;
306 f->key_frame = 0;
307 break;
308 }
309 f->pict_type = FF_I_TYPE;
310 f->key_frame = 1;
311 if ((AV_RL32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) {
312 av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
313 return -1;
314 }
315 for(i = 0; i < planes; i++) {
316 offs[i] = AV_RL32(buf + 4 + i * 4);
317 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
318 av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i);
319 return -1;
320 }
321 }
322 offs[planes] = buf_size;
323 for(i = 0; i < planes; i++){
324 s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE);
325 if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0],
326 avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 1, 3) < 0) {
327 av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
328 return -1;
329 }
330 }
331 break;
291 } 332 }
292 333
293 *frame = *f; 334 *frame = *f;
294 *data_size = sizeof(AVFrame); 335 *data_size = sizeof(AVFrame);
295 336