[FFmpeg-devel] [PATCH 1/3] lavfi: implement samples framing on links.
Michael Niedermayer
michaelni at gmx.at
Sat Jun 30 13:40:41 CEST 2012
On Sat, Jun 30, 2012 at 11:00:15AM +0200, Nicolas George wrote:
> Links can be set up to group samples into buffers of
> specified minimum and maximum size.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/audio.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> libavfilter/audio.h | 7 +++++++
> libavfilter/avfilter.c | 14 +++++++++++---
> libavfilter/avfilter.h | 26 ++++++++++++++++++++++++++
> 4 files changed, 88 insertions(+), 4 deletions(-)
>
> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> index 6a86597..c29b8eb 100644
> --- a/libavfilter/audio.c
> +++ b/libavfilter/audio.c
> @@ -156,7 +156,8 @@ static void default_filter_samples(AVFilterLink *link,
> ff_filter_samples(link->dst->outputs[0], samplesref);
> }
>
> -void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
> +void ff_filter_samples_framed(AVFilterLink *link,
> + AVFilterBufferRef *samplesref)
> {
> void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
> AVFilterPad *dst = link->dstpad;
> @@ -195,3 +196,45 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
> filter_samples(link, buf_out);
> ff_update_link_current_pts(link, pts);
> }
> +
> +void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
> +{
> + int insamples = samplesref->audio->nb_samples, inpos = 0, nb_samples;
> + AVFilterBufferRef *pbuf = link->partial_buf;
> + int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
> +
> + if (!link->min_samples ||
> + (!pbuf &&
> + insamples >= link->min_samples && insamples <= link->max_samples)) {
> + ff_filter_samples_framed(link, samplesref);
> + return;
> + }
> + /* Handle framing (min_samples, max_samples) */
> + while (insamples) {
> + if (!pbuf) {
> + AVRational samples_tb = { 1, link->sample_rate };
> + int perms = link->dstpad->min_perms | AV_PERM_WRITE;
> + pbuf = ff_get_audio_buffer(link, perms, link->partial_buf_size);
> + if (!pbuf)
> + return;
this should print a warning i think
otherwise LGTM
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120630/baaeae93/attachment.asc>
More information about the ffmpeg-devel
mailing list