diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2012-12-30 15:15:50 +0100 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2013-01-01 02:01:28 +0100 |
commit | 2eb2e1798eeea155399197aeb0d8ed9f17d1eb0b (patch) | |
tree | 770173d1ea91efcb9a91e1bdd9b0a2a9dbdd2fe6 /libavfilter/audio.c | |
parent | f105fe5c22c5b7f426f65d82bee0de47c14bad65 (diff) | |
download | ffmpeg-2eb2e1798eeea155399197aeb0d8ed9f17d1eb0b.tar.gz |
lavfi: add avfilter_get_audio_buffer_ref_from_arrays_channels.
It is the same as avfilter_get_audio_buffer_ref_from_arrays
except it has a "channels" and the channel layout can be 0.
Diffstat (limited to 'libavfilter/audio.c')
-rw-r--r-- | libavfilter/audio.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/libavfilter/audio.c b/libavfilter/audio.c index 3564896534..74cf9a8130 100644 --- a/libavfilter/audio.c +++ b/libavfilter/audio.c @@ -58,9 +58,9 @@ AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) goto fail; - samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, full_perms, - nb_samples, link->format, - link->channel_layout); + samplesref = avfilter_get_audio_buffer_ref_from_arrays_channels( + data, linesize, full_perms, nb_samples, link->format, + link->channels, link->channel_layout); if (!samplesref) goto fail; @@ -92,13 +92,14 @@ AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms, return ret; } -AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, - int linesize,int perms, - int nb_samples, - enum AVSampleFormat sample_fmt, - uint64_t channel_layout) +AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data, + int linesize, + int perms, + int nb_samples, + enum AVSampleFormat sample_fmt, + int channels, + uint64_t channel_layout) { - int channels = av_get_channel_layout_nb_channels(channel_layout); int planes; AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); @@ -106,6 +107,10 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, if (!samples || !samplesref) goto fail; + av_assert0(channels); + av_assert0(channel_layout == 0 || + channels == av_get_channel_layout_nb_channels(channel_layout)); + samplesref->buf = samples; samplesref->buf->free = ff_avfilter_default_free_buffer; if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) @@ -163,6 +168,18 @@ fail: return NULL; } +AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, + int linesize,int perms, + int nb_samples, + enum AVSampleFormat sample_fmt, + uint64_t channel_layout) +{ + int channels = av_get_channel_layout_nb_channels(channel_layout); + return avfilter_get_audio_buffer_ref_from_arrays_channels(data, linesize, perms, + nb_samples, sample_fmt, + channels, channel_layout); +} + static int default_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame) { return ff_filter_frame(link->dst->outputs[0], frame); |