diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-26 17:22:10 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-11-29 17:19:47 +0400 |
commit | e2ceb17642f374a7df8f1f5d3d2b2446525bc7fb (patch) | |
tree | 49606a2320f2facd49af01c8debaada49d32923c /libavcodec/mpeg4videodec.c | |
parent | b452d5ae866942cec00aa1432fe29498b38b49fc (diff) |
mpeg4videodec: move mpeg4-specific post-frame-decode code from h264dec to mpeg4videodec
Diffstat (limited to 'libavcodec/mpeg4videodec.c')
-rw-r--r-- | libavcodec/mpeg4videodec.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index c42da7f11c..9a5a3b6ac6 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2492,6 +2492,49 @@ end: return decode_vop_header(ctx, gb); } +int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) +{ + Mpeg4DecContext *ctx = avctx->priv_data; + MpegEncContext *s = &ctx->m; + + /* divx 5.01+ bistream reorder stuff */ + if (s->divx_packed) { + int current_pos = get_bits_count(&s->gb) >> 3; + int startcode_found = 0; + + if (buf_size - current_pos > 5) { + int i; + for (i = current_pos; i < buf_size - 3; i++) + if (buf[i] == 0 && + buf[i + 1] == 0 && + buf[i + 2] == 1 && + buf[i + 3] == 0xB6) { + startcode_found = 1; + break; + } + } + if (s->gb.buffer == s->bitstream_buffer && buf_size > 7 && + s->xvid_build >= 0) { // xvid style + startcode_found = 1; + current_pos = 0; + } + + if (startcode_found) { + av_fast_malloc(&s->bitstream_buffer, + &s->allocated_bitstream_buffer_size, + buf_size - current_pos + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->bitstream_buffer) + return AVERROR(ENOMEM); + memcpy(s->bitstream_buffer, buf + current_pos, + buf_size - current_pos); + s->bitstream_buffer_size = buf_size - current_pos; + } + } + + return 0; +} + static int mpeg4_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { |