mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavfi: add a channels field to AVFilterLink.
Also: fix af_pan and af_aresample, that forgot to update audio->channels.
This commit is contained in:
parent
a9275b4f69
commit
238edd2fe3
@ -184,6 +184,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
|
||||
|
||||
avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
|
||||
outsamplesref->format = outlink->format;
|
||||
outsamplesref->audio->channels = outlink->channels;
|
||||
outsamplesref->audio->channel_layout = outlink->channel_layout;
|
||||
outsamplesref->audio->sample_rate = outlink->sample_rate;
|
||||
|
||||
|
@ -364,6 +364,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples)
|
||||
swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n);
|
||||
avfilter_copy_buffer_ref_props(outsamples, insamples);
|
||||
outsamples->audio->channel_layout = outlink->channel_layout;
|
||||
outsamples->audio->channels = outlink->channels;
|
||||
|
||||
ret = ff_filter_frame(outlink, outsamples);
|
||||
avfilter_unref_buffer(insamples);
|
||||
|
@ -93,6 +93,7 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
|
||||
enum AVSampleFormat sample_fmt,
|
||||
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));
|
||||
@ -107,9 +108,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
|
||||
|
||||
samplesref->audio->nb_samples = nb_samples;
|
||||
samplesref->audio->channel_layout = channel_layout;
|
||||
samplesref->audio->channels = channels;
|
||||
|
||||
planes = av_sample_fmt_is_planar(sample_fmt) ?
|
||||
av_get_channel_layout_nb_channels(channel_layout) : 1;
|
||||
planes = av_sample_fmt_is_planar(sample_fmt) ? channels : 1;
|
||||
|
||||
/* make sure the buffer gets read permission or it's useless for output */
|
||||
samplesref->perms = perms | AV_PERM_READ;
|
||||
@ -225,6 +226,7 @@ int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
|
||||
int ret = 0;
|
||||
|
||||
av_assert1(samplesref->format == link->format);
|
||||
av_assert1(samplesref->audio->channels == link->channels);
|
||||
av_assert1(samplesref->audio->channel_layout == link->channel_layout);
|
||||
av_assert1(samplesref->audio->sample_rate == link->sample_rate);
|
||||
|
||||
|
@ -164,6 +164,11 @@ void avfilter_link_free(AVFilterLink **link)
|
||||
av_freep(link);
|
||||
}
|
||||
|
||||
int avfilter_link_get_channels(AVFilterLink *link)
|
||||
{
|
||||
return link->channels;
|
||||
}
|
||||
|
||||
void avfilter_link_set_closed(AVFilterLink *link, int closed)
|
||||
{
|
||||
link->closed = closed;
|
||||
|
@ -699,6 +699,11 @@ struct AVFilterLink {
|
||||
* filter.
|
||||
*/
|
||||
int closed;
|
||||
|
||||
/**
|
||||
* Number of channels.
|
||||
*/
|
||||
int channels;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -718,6 +723,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
||||
*/
|
||||
void avfilter_link_free(AVFilterLink **link);
|
||||
|
||||
/**
|
||||
* Get the number of channels of a link.
|
||||
*/
|
||||
int avfilter_link_get_channels(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* Set the closed field of a link.
|
||||
*/
|
||||
|
@ -473,6 +473,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref)
|
||||
}
|
||||
link->in_channel_layouts->nb_channel_layouts = 1;
|
||||
link->channel_layout = link->in_channel_layouts->channel_layouts[0];
|
||||
link->channels = av_get_channel_layout_nb_channels(link->channel_layout);
|
||||
}
|
||||
|
||||
ff_formats_unref(&link->in_formats);
|
||||
|
Loading…
Reference in New Issue
Block a user