Mercurial > libavcodec.hg
comparison mimic.c @ 6666:1c76797e2216 libavcodec
Use bytestream functions for reading frame header.
author | ramiro |
---|---|
date | Tue, 22 Apr 2008 20:24:07 +0000 |
parents | 603c780be9ff |
children | 4a5c7112e35c |
comparison
equal
deleted
inserted
replaced
6665:c22932db0ebb | 6666:1c76797e2216 |
---|---|
23 #include <string.h> | 23 #include <string.h> |
24 #include <stdint.h> | 24 #include <stdint.h> |
25 | 25 |
26 #include "avcodec.h" | 26 #include "avcodec.h" |
27 #include "bitstream.h" | 27 #include "bitstream.h" |
28 #include "bytestream.h" | |
28 #include "dsputil.h" | 29 #include "dsputil.h" |
29 | 30 |
30 #define MIMIC_HEADER_SIZE 20 | 31 #define MIMIC_HEADER_SIZE 20 |
31 | 32 |
32 typedef struct { | 33 typedef struct { |
295 if(buf_size < MIMIC_HEADER_SIZE) { | 296 if(buf_size < MIMIC_HEADER_SIZE) { |
296 av_log(avctx, AV_LOG_ERROR, "insufficient data\n"); | 297 av_log(avctx, AV_LOG_ERROR, "insufficient data\n"); |
297 return -1; | 298 return -1; |
298 } | 299 } |
299 | 300 |
300 width = AV_RL16(buf + 4); | 301 buf += 2; |
301 height = AV_RL16(buf + 6); | 302 quality = bytestream_get_le16(&buf); |
303 width = bytestream_get_le16(&buf); | |
304 height = bytestream_get_le16(&buf); | |
305 buf += 4; | |
306 is_pframe = bytestream_get_le32(&buf); | |
307 num_coeffs = bytestream_get_le32(&buf); | |
302 | 308 |
303 if(!ctx->avctx) { | 309 if(!ctx->avctx) { |
304 int i; | 310 int i; |
305 | 311 |
306 if(!(width == 160 && height == 120) && | 312 if(!(width == 160 && height == 120) && |
320 } else if(width != ctx->avctx->width || height != ctx->avctx->height) { | 326 } else if(width != ctx->avctx->width || height != ctx->avctx->height) { |
321 av_log(avctx, AV_LOG_ERROR, "resolution changing is not supported\n"); | 327 av_log(avctx, AV_LOG_ERROR, "resolution changing is not supported\n"); |
322 return -1; | 328 return -1; |
323 } | 329 } |
324 | 330 |
325 quality = AV_RL16(buf + 2); | |
326 is_pframe = AV_RL32(buf + 12); | |
327 num_coeffs = buf[16]; | |
328 | |
329 if(is_pframe && !ctx->buf_ptrs[ctx->prev_index].data[0]) { | 331 if(is_pframe && !ctx->buf_ptrs[ctx->prev_index].data[0]) { |
330 av_log(avctx, AV_LOG_ERROR, "decoding must start with keyframe\n"); | 332 av_log(avctx, AV_LOG_ERROR, "decoding must start with keyframe\n"); |
331 return -1; | 333 return -1; |
332 } | 334 } |
333 | 335 |
344 swap_buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | 346 swap_buf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
345 if(!ctx->swap_buf) | 347 if(!ctx->swap_buf) |
346 return AVERROR_NOMEM; | 348 return AVERROR_NOMEM; |
347 | 349 |
348 ctx->dsp.bswap_buf((uint32_t*)ctx->swap_buf, | 350 ctx->dsp.bswap_buf((uint32_t*)ctx->swap_buf, |
349 (const uint32_t*) (buf + MIMIC_HEADER_SIZE), | 351 (const uint32_t*) buf, |
350 swap_buf_size>>2); | 352 swap_buf_size>>2); |
351 init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); | 353 init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); |
352 | 354 |
353 if(!decode(ctx, quality, num_coeffs, !is_pframe)) { | 355 if(!decode(ctx, quality, num_coeffs, !is_pframe)) { |
354 avctx->release_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index]); | 356 avctx->release_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index]); |