On 01/18/2013 01:39 AM, Anton Khirnov wrote: > > On Wed, 9 Jan 2013 12:11:54 -0500, Justin Ruggles <[email protected]> > wrote: >> --- >> libavcodec/mpegaudiodec.c | 55 >> +++++++++++++++++++++----------------------- >> 1 files changed, 26 insertions(+), 29 deletions(-) >> >> diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c >> index fda0280..e5db694 100644 >> --- a/libavcodec/mpegaudiodec.c >> +++ b/libavcodec/mpegaudiodec.c >> @@ -83,7 +83,6 @@ typedef struct MPADecodeContext { >> AVCodecContext* avctx; >> MPADSPContext mpadsp; >> DSPContext dsp; >> - AVFrame frame; >> } MPADecodeContext; >> >> #if CONFIG_FLOAT >> @@ -447,9 +446,6 @@ static av_cold int decode_init(AVCodecContext * avctx) >> if (avctx->codec_id == AV_CODEC_ID_MP3ADU) >> s->adu_mode = 1; >> >> - avcodec_get_frame_defaults(&s->frame); >> - avctx->coded_frame = &s->frame; >> - >> return 0; >> } >> >> @@ -1556,7 +1552,7 @@ static int mp_decode_layer3(MPADecodeContext *s) >> static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, >> const uint8_t *buf, int buf_size) >> { >> - int i, nb_frames, ch, ret; >> + int i, nb_frames, ch; >> OUT_INT *samples_ptr; >> >> init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE) * 8); >> @@ -1609,16 +1605,6 @@ static int mp_decode_frame(MPADecodeContext *s, >> OUT_INT **samples, >> s->last_buf_size += i; >> } >> >> - /* get output buffer */ >> - if (!samples) { >> - s->frame.nb_samples = s->avctx->frame_size; >> - if ((ret = ff_get_buffer(s->avctx, &s->frame)) < 0) { >> - av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); >> - return ret; >> - } >> - samples = (OUT_INT **)s->frame.extended_data; >> - } >> - >> /* apply the synthesis filter */ >> for (ch = 0; ch < s->nb_channels; ch++) { >> int sample_stride; >> @@ -1648,6 +1634,7 @@ static int decode_frame(AVCodecContext * avctx, void >> *data, int *got_frame_ptr, >> const uint8_t *buf = avpkt->data; >> int buf_size = avpkt->size; >> MPADecodeContext *s = avctx->priv_data; >> + AVFrame *frame = data; >> uint32_t header; >> int ret; >> >> @@ -1678,10 +1665,16 @@ static int decode_frame(AVCodecContext * avctx, void >> *data, int *got_frame_ptr, >> buf_size= s->frame_size; >> } >> >> - ret = mp_decode_frame(s, NULL, buf, buf_size); >> + frame->nb_samples = MPA_FRAME_SIZE; > > That's not the same thing current code does. Is there a reason for that?
Yes. It's now getting the buffer before determining the frame size, so it needs to get a large enough buffer, then reduce nb_samples later if needed. I guess an alternative would be to keep the AVFrame pointer in MPADecodeContext but make it point to the current AVFrame from the user. -Justin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
