summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-30 14:10:25 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-09-30 14:10:25 +0200
commit853a93804d16c79028ba8005d4c033a403fc34f9 (patch)
tree19778ac21caaa269684c4b04ed981ea9921b92f1
parente5ce6d447b952658b8a8568c807baeab5cf58783 (diff)
parentd9a2e87b1ce44cce23801e7ec6810f8bf994fa23 (diff)
Merge commit 'd9a2e87b1ce44cce23801e7ec6810f8bf994fa23'
* commit 'd9a2e87b1ce44cce23801e7ec6810f8bf994fa23': mpeg12: move mpeg_decode_frame() lower avsdec: Set dimensions instead of relying on the demuxer. wmalosslessdec: Reset put bit buffer when num_saved_bits is reset. Conflicts: libavcodec/avs.c libavcodec/mpeg12.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpeg12.c108
-rw-r--r--libavcodec/wmalosslessdec.c4
2 files changed, 54 insertions, 58 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 1e7ff9cf6f..2cf65e11c9 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -2242,62 +2242,6 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size,
static int decode_chunks(AVCodecContext *avctx,
AVFrame *picture, int *data_size,
- const uint8_t *buf, int buf_size);
-
-/* handle buffering and image synchronisation */
-static int mpeg_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- Mpeg1Context *s = avctx->priv_data;
- AVFrame *picture = data;
- MpegEncContext *s2 = &s->mpeg_enc_ctx;
- av_dlog(avctx, "fill_buffer\n");
-
- if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
- /* special case for last picture */
- if (s2->low_delay == 0 && s2->next_picture_ptr) {
- *picture = s2->next_picture_ptr->f;
- s2->next_picture_ptr = NULL;
-
- *data_size = sizeof(AVFrame);
- }
- return buf_size;
- }
-
- if (s2->flags & CODEC_FLAG_TRUNCATED) {
- int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
-
- if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
- return buf_size;
- }
-
- s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
- if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
- || s2->codec_tag == AV_RL32("BW10")
- ))
- vcr2_init_sequence(avctx);
-
- s->slice_count = 0;
-
- if (avctx->extradata && !s->parsed_extra) {
- int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
- if(*data_size) {
- av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
- *data_size = 0;
- }
- s->parsed_extra = 1;
- if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
- return ret;
- }
-
- return decode_chunks(avctx, picture, data_size, buf, buf_size);
-}
-
-static int decode_chunks(AVCodecContext *avctx,
- AVFrame *picture, int *data_size,
const uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
@@ -2564,6 +2508,58 @@ static int decode_chunks(AVCodecContext *avctx,
}
}
+static int mpeg_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ Mpeg1Context *s = avctx->priv_data;
+ AVFrame *picture = data;
+ MpegEncContext *s2 = &s->mpeg_enc_ctx;
+ av_dlog(avctx, "fill_buffer\n");
+
+ if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
+ /* special case for last picture */
+ if (s2->low_delay == 0 && s2->next_picture_ptr) {
+ *picture = s2->next_picture_ptr->f;
+ s2->next_picture_ptr = NULL;
+
+ *data_size = sizeof(AVFrame);
+ }
+ return buf_size;
+ }
+
+ if (s2->flags & CODEC_FLAG_TRUNCATED) {
+ int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
+
+ if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
+ return buf_size;
+ }
+
+ s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
+ if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
+ || s2->codec_tag == AV_RL32("BW10")
+ ))
+ vcr2_init_sequence(avctx);
+
+ s->slice_count = 0;
+
+ if (avctx->extradata && !s->parsed_extra) {
+ int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
+ if(*data_size) {
+ av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
+ *data_size = 0;
+ }
+ s->parsed_extra = 1;
+ if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
+ return ret;
+ }
+
+ return decode_chunks(avctx, picture, data_size, buf, buf_size);
+}
+
+
static void flush(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 7d6bd8e756..6e5dcb8ad6 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -1229,8 +1229,8 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
/* Reset number of saved bits so that the decoder does not start
* to decode incomplete frames in the s->len_prefix == 0 case. */
s->num_saved_bits = 0;
- init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
s->packet_loss = 0;
+ init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
} else {
@@ -1279,11 +1279,11 @@ static void flush(AVCodecContext *avctx)
s->packet_loss = 1;
s->packet_done = 0;
s->num_saved_bits = 0;
- init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
s->frame_offset = 0;
s->next_packet_start = 0;
s->cdlms[0][0].order = 0;
s->frame.nb_samples = 0;
+ init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
AVCodec ff_wmalossless_decoder = {