summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-29 22:43:00 +0100
committerwm4 <wm4@nowhere>2016-01-29 22:43:00 +0100
commit354c1fc06d5c2381dc59a39f02aa61a3c252b283 (patch)
tree1c7c4389e3fd5532ff01264de15f9f39bc8dddb6 /audio/filter
parent946ee29a7ded5edf99942b07227cd81eb1bcc274 (diff)
downloadmpv-354c1fc06d5c2381dc59a39f02aa61a3c252b283.tar.bz2
mpv-354c1fc06d5c2381dc59a39f02aa61a3c252b283.tar.xz
audio: move mp_audio->AVFrame conversion to a function
This also makes it refcounted, i.e. the new AVFrame will reference the mp_audio buffers, instead of potentially forcing the consumer of the AVFrame to copy the data. All the extra code is for handling the >8 channels case, which requires very messy dealing with the extended_ fields (not our fault).
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af_lavfi.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/audio/filter/af_lavfi.c b/audio/filter/af_lavfi.c
index 1e05e734a1..bc4a687487 100644
--- a/audio/filter/af_lavfi.c
+++ b/audio/filter/af_lavfi.c
@@ -266,32 +266,15 @@ static int filter_frame(struct af_instance *af, struct mp_audio *data)
if (!p->graph)
goto error;
- AVFilterLink *l_in = p->in->outputs[0];
-
if (data) {
- frame = av_frame_alloc();
+ frame = mp_audio_to_avframe_and_unref(data);
+ data = NULL;
if (!frame)
goto error;
- frame->nb_samples = data->samples;
- frame->format = l_in->format;
-
// Timebase is 1/sample_rate
frame->pts = p->samples_in;
-
- frame->channel_layout = l_in->channel_layout;
- frame->sample_rate = l_in->sample_rate;
-#if LIBAVFILTER_VERSION_MICRO >= 100
- // FFmpeg being a stupid POS
- frame->channels = l_in->channels;
-#endif
-
- frame->extended_data = frame->data;
- for (int n = 0; n < data->num_planes; n++)
- frame->data[n] = data->planes[n];
- frame->linesize[0] = frame->nb_samples * data->sstride;
-
- p->samples_in += data->samples;
+ p->samples_in += frame->nb_samples;
}
if (av_buffersrc_add_frame(p->in, frame) < 0)