diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-02-01 12:34:23 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-05-09 20:26:19 +0200 |
commit | e727bca392995e4fec0104b7f75f89a66618c120 (patch) | |
tree | 87795d9f2a31f7fc1a1dbd16a74827de5b6af3bf /libavfilter/avfilter.c | |
parent | c8b4a3999bc7f3732a537cdec6475918a65d6e78 (diff) | |
download | ffmpeg-e727bca392995e4fec0104b7f75f89a66618c120.tar.gz |
lavfi: cleanup avfilter_get_audio_buffer() and pals.
Remove AVFilterBufferRefAudioProps.size, and use nb_samples in its place
everywhere.
This is required as the size in the audio buffer may be aligned, so it
may not contain a well defined number of samples.
Also remove the useless planar parameter, which can be deduced from the
sample format.
This is technically an API and ABI break, but since the audio part of
lavfi is not usable now, this should not be a problem in practice.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index e535bdab64..9f81be7a8d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -265,10 +265,9 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) av_get_picture_type_char(ref->video->pict_type)); } if (ref->audio) { - av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d", + av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d p:%d", ref->audio->channel_layout, ref->audio->nb_samples, - ref->audio->size, ref->audio->sample_rate, ref->audio->planar); } @@ -368,16 +367,16 @@ fail: } AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, - enum AVSampleFormat sample_fmt, int size, - uint64_t channel_layout, int planar) + enum AVSampleFormat sample_fmt, int nb_samples, + uint64_t channel_layout) { AVFilterBufferRef *ret = NULL; if (link->dstpad->get_audio_buffer) - ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); + ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); if (!ret) - ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); + ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); if (ret) ret->type = AVMEDIA_TYPE_AUDIO; @@ -585,6 +584,9 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) /* prepare to copy the samples if the buffer has insufficient permissions */ if ((dst->min_perms & samplesref->perms) != dst->min_perms || dst->rej_perms & samplesref->perms) { + int i, planar = av_sample_fmt_is_planar(samplesref->format); + int planes = !planar ? 1: + av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); av_log(link->dst, AV_LOG_DEBUG, "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", @@ -592,14 +594,14 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, samplesref->format, - samplesref->audio->size, - samplesref->audio->channel_layout, - samplesref->audio->planar); + samplesref->audio->nb_samples, + samplesref->audio->channel_layout); link->cur_buf->pts = samplesref->pts; link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; /* Copy actual data into new samples buffer */ - memcpy(link->cur_buf->data[0], samplesref->data[0], samplesref->audio->size); + for (i = 0; i < planes; i++) + memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]); avfilter_unref_buffer(samplesref); } else |