summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-30 02:42:56 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-30 02:42:56 +0100
commitec5499d8bac82007bfc966fb1a7b8233375723cf (patch)
treebe754102ba76fd022b9d30463f06a4131177412b /libavcodec
parentb239f3f69d1c10a7d12354a9038c5b109661324e (diff)
parente2ceb17642f374a7df8f1f5d3d2b2446525bc7fb (diff)
Merge commit 'e2ceb17642f374a7df8f1f5d3d2b2446525bc7fb'
* commit 'e2ceb17642f374a7df8f1f5d3d2b2446525bc7fb': mpeg4videodec: move mpeg4-specific post-frame-decode code from h264dec to mpeg4videodec Conflicts: libavcodec/h263dec.c libavcodec/mpeg4video.h libavcodec/mpeg4videodec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h263dec.c33
-rw-r--r--libavcodec/mpeg4video.h1
-rw-r--r--libavcodec/mpeg4videodec.c42
3 files changed, 45 insertions, 31 deletions
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index afd2d779db..6324e9be87 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -623,37 +623,8 @@ frame_end:
ff_MPV_frame_end(s);
- /* divx 5.01+ bitstream reorder stuff */
- /* Since this clobbers the input buffer and hwaccel codecs still need the
- * data during hwaccel->end_frame we should not do this any earlier */
- if (s->codec_id == AV_CODEC_ID_MPEG4 && s->divx_packed) {
- int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);
- int startcode_found = 0;
-
- if (buf_size - current_pos > 7) {
- int i;
- for (i = current_pos; i < buf_size - 4; i++)
- if (buf[i] == 0 &&
- buf[i + 1] == 0 &&
- buf[i + 2] == 1 &&
- buf[i + 3] == 0xB6) {
- startcode_found = !(buf[i + 4] & 0x40);
- break;
- }
- }
-
- 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;
- }
- }
+ if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4)
+ ff_mpeg4_frame_end(avctx, buf, buf_size);
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 93c101ecec..1230baa178 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -120,6 +120,7 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx);
void ff_mpeg4_init_direct_mv(MpegEncContext *s);
void ff_mpeg4videodec_static_init(void);
int ff_mpeg4_workaround_bugs(AVCodecContext *avctx);
+int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
/**
*
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 1155163c1e..def22f5a89 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2624,6 +2624,48 @@ av_cold void ff_mpeg4videodec_static_init(void) {
}
}
+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+ bitstream reorder stuff */
+ /* Since this clobbers the input buffer and hwaccel codecs still need the
+ * data during hwaccel->end_frame we should not do this any earlier */
+ if (s->divx_packed) {
+ int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);
+ int startcode_found = 0;
+
+ if (buf_size - current_pos > 7) {
+
+ int i;
+ for (i = current_pos; i < buf_size - 4; i++)
+
+ if (buf[i] == 0 &&
+ buf[i + 1] == 0 &&
+ buf[i + 2] == 1 &&
+ buf[i + 3] == 0xB6) {
+ startcode_found = !(buf[i + 4] & 0x40);
+ break;
+ }
+ }
+
+ 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)
{