History

lavfi: add a channels field to AVFilterLink.

Nicolas George committed 13 years ago

Commit 238edd21 parent a9275b46 files · +22 −2Browse files

Unified · Split

6 files
  1. libavfilter/af_aresample.c +1 −0
  2. libavfilter/af_pan.c +1 −0
  3. libavfilter/audio.c +4 −2
  4. libavfilter/avfilter.c +5 −0
  5. libavfilter/avfilter.h +10 −0
  6. libavfilter/avfiltergraph.c +1 −0
libavfilter/af_aresample.c+1−0
@@ -184,6 +184,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) · 183 unmodified lines
184184
185185 avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
186186 outsamplesref->format = outlink->format;
187+ outsamplesref->audio->channels = outlink->channels;
187188 outsamplesref->audio->channel_layout = outlink->channel_layout;
188189 outsamplesref->audio->sample_rate = outlink->sample_rate;
189190
libavfilter/af_pan.c+1−0
@@ -364,6 +364,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 363 unmodified lines
364364 swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n);
365365 avfilter_copy_buffer_ref_props(outsamples, insamples);
366366 outsamples->audio->channel_layout = outlink->channel_layout;
367+ outsamples->audio->channels = outlink->channels;
367368
368369 ret = ff_filter_frame(outlink, outsamples);
369370 avfilter_unref_buffer(insamples);
libavfilter/audio.c+4−2
@@ -93,6 +93,7 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 92 unmodified lines
9393 enum AVSampleFormat sample_fmt,
9494 uint64_t channel_layout)
9595 {
96+ int channels = av_get_channel_layout_nb_channels(channel_layout);
9697 int planes;
9798 AVFilterBuffer *samples = av_mallocz(sizeof(*samples));
9899 AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref));
@@ -107,9 +108,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 8 unmodified lines
107108
108109 samplesref->audio->nb_samples = nb_samples;
109110 samplesref->audio->channel_layout = channel_layout;
111+ samplesref->audio->channels = channels;
110112
111− planes = av_sample_fmt_is_planar(sample_fmt) ?
112− av_get_channel_layout_nb_channels(channel_layout) : 1;
113+ planes = av_sample_fmt_is_planar(sample_fmt) ? channels : 1;
113114
114115 /* make sure the buffer gets read permission or it's useless for output */
115116 samplesref->perms = perms | AV_PERM_READ;
@@ -225,6 +226,7 @@ int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) · 109 unmodified lines
225226 int ret = 0;
226227
227228 av_assert1(samplesref->format == link->format);
229+ av_assert1(samplesref->audio->channels == link->channels);
228230 av_assert1(samplesref->audio->channel_layout == link->channel_layout);
229231 av_assert1(samplesref->audio->sample_rate == link->sample_rate);
230232
libavfilter/avfilter.c+5−0
@@ -164,6 +164,11 @@ void avfilter_link_free(AVFilterLink **link) · 163 unmodified lines
164164 av_freep(link);
165165 }
166166
167+int avfilter_link_get_channels(AVFilterLink *link)
168+{
169+ return link->channels;
170+}
171+
167172 void avfilter_link_set_closed(AVFilterLink *link, int closed)
168173 {
169174 link->closed = closed;
libavfilter/avfilter.h+10−0
@@ -699,6 +699,11 @@ struct AVFilterLink { · 698 unmodified lines
699699 * filter.
700700 */
701701 int closed;
702+
703+ /**
704+ * Number of channels.
705+ */
706+ int channels;
702707 };
703708
704709 /**
@@ -718,6 +723,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 13 unmodified lines
718723 */
719724 void avfilter_link_free(AVFilterLink **link);
720725
726+/**
727+ * Get the number of channels of a link.
728+ */
729+int avfilter_link_get_channels(AVFilterLink *link);
730+
721731 /**
722732 * Set the closed field of a link.
723733 */
libavfilter/avfiltergraph.c+1−0
@@ -473,6 +473,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) · 472 unmodified lines
473473 }
474474 link->in_channel_layouts->nb_channel_layouts = 1;
475475 link->channel_layout = link->in_channel_layouts->channel_layouts[0];
476+ link->channels = av_get_channel_layout_nb_channels(link->channel_layout);
476477 }
477478
478479 ff_formats_unref(&link->in_formats);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t