af_lavcac3enc: use new AVFrame API

This commit is contained in:
wm4 2014-03-16 13:03:54 +01:00
parent 05e3a5a2b4
commit 113ec0aba1
1 changed files with 3 additions and 3 deletions

View File

@ -185,7 +185,7 @@ static int filter(struct af_instance* af, struct mp_audio* audio, int flags)
} }
in_frame.samples = s->in_samples; in_frame.samples = s->in_samples;
AVFrame *frame = avcodec_alloc_frame(); AVFrame *frame = av_frame_alloc();
if (!frame) { if (!frame) {
MP_FATAL(af, "Could not allocate memory \n"); MP_FATAL(af, "Could not allocate memory \n");
return -1; return -1;
@ -194,19 +194,19 @@ static int filter(struct af_instance* af, struct mp_audio* audio, int flags)
frame->format = s->lavc_actx->sample_fmt; frame->format = s->lavc_actx->sample_fmt;
frame->channel_layout = s->lavc_actx->channel_layout; frame->channel_layout = s->lavc_actx->channel_layout;
assert(in_frame.num_planes <= AV_NUM_DATA_POINTERS); assert(in_frame.num_planes <= AV_NUM_DATA_POINTERS);
frame->extended_data = frame->data;
for (int n = 0; n < in_frame.num_planes; n++) for (int n = 0; n < in_frame.num_planes; n++)
frame->data[n] = in_frame.planes[n]; frame->data[n] = in_frame.planes[n];
frame->linesize[0] = s->in_samples * audio->sstride; frame->linesize[0] = s->in_samples * audio->sstride;
int ok; int ok;
ret = avcodec_encode_audio2(s->lavc_actx, &s->pkt, frame, &ok); ret = avcodec_encode_audio2(s->lavc_actx, &s->pkt, frame, &ok);
av_frame_free(&frame);
if (ret < 0 || !ok) { if (ret < 0 || !ok) {
MP_FATAL(af, "Encode failed.\n"); MP_FATAL(af, "Encode failed.\n");
return -1; return -1;
} }
avcodec_free_frame(&frame);
mp_audio_buffer_skip(s->pending, consumed_pending); mp_audio_buffer_skip(s->pending, consumed_pending);
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n", MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",