aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-06-04 19:01:22 +0200
committerAnton Khirnov <anton@khirnov.net>2013-06-10 21:19:51 +0200
commit799f57ac96f9891d1a0f7d6c4b218ed536e8aca5 (patch)
treea684d997ef82d16a8e71f62e832a9f5b95ed0f72 /libavcodec
parent8835c554ff506992c47f6e347c74216ae073f0fa (diff)
downloadffmpeg-799f57ac96f9891d1a0f7d6c4b218ed536e8aca5.tar.gz
lavc: use AVFrame API properly in pad_last_frame().
This also simplifies the code.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 8a19393a26..accb6b3a94 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1119,26 +1119,22 @@ int ff_alloc_packet(AVPacket *avpkt, int size)
static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
{
AVFrame *frame = NULL;
- uint8_t *buf = NULL;
int ret;
if (!(frame = avcodec_alloc_frame()))
return AVERROR(ENOMEM);
- *frame = *src;
- if ((ret = av_samples_get_buffer_size(&frame->linesize[0], s->channels,
- s->frame_size, s->sample_fmt, 0)) < 0)
+ frame->format = src->format;
+ frame->channel_layout = src->channel_layout;
+ frame->nb_samples = s->frame_size;
+ ret = av_frame_get_buffer(frame, 32);
+ if (ret < 0)
goto fail;
- if (!(buf = av_malloc(ret))) {
- ret = AVERROR(ENOMEM);
+ ret = av_frame_copy_props(frame, src);
+ if (ret < 0)
goto fail;
- }
- frame->nb_samples = s->frame_size;
- if ((ret = avcodec_fill_audio_frame(frame, s->channels, s->sample_fmt,
- buf, ret, 0)) < 0)
- goto fail;
if ((ret = av_samples_copy(frame->extended_data, src->extended_data, 0, 0,
src->nb_samples, s->channels, s->sample_fmt)) < 0)
goto fail;
@@ -1152,10 +1148,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
return 0;
fail:
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
- av_freep(&buf);
- av_freep(&frame);
+ av_frame_free(&frame);
return ret;
}