Unified · Split
| @@ -184,6 +184,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) · 183 unmodified lines | |||
| 184 | 184 | ||
| 185 | avfilter_copy_buffer_ref_props(outsamplesref, insamplesref); | 185 | avfilter_copy_buffer_ref_props(outsamplesref, insamplesref); |
| 186 | outsamplesref->format = outlink->format; | 186 | outsamplesref->format = outlink->format; |
| 187 | outsamplesref->audio->channels = outlink->channels; | ||
| 187 | outsamplesref->audio->channel_layout = outlink->channel_layout; | 188 | outsamplesref->audio->channel_layout = outlink->channel_layout; |
| 188 | outsamplesref->audio->sample_rate = outlink->sample_rate; | 189 | outsamplesref->audio->sample_rate = outlink->sample_rate; |
| 189 | 190 | ||
| @@ -364,6 +364,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 363 unmodified lines | |||
| 364 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); | 364 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); |
| 365 | avfilter_copy_buffer_ref_props(outsamples, insamples); | 365 | avfilter_copy_buffer_ref_props(outsamples, insamples); |
| 366 | outsamples->audio->channel_layout = outlink->channel_layout; | 366 | outsamples->audio->channel_layout = outlink->channel_layout; |
| 367 | outsamples->audio->channels = outlink->channels; | ||
| 367 | 368 | ||
| 368 | ret = ff_filter_frame(outlink, outsamples); | 369 | ret = ff_filter_frame(outlink, outsamples); |
| 369 | avfilter_unref_buffer(insamples); | 370 | avfilter_unref_buffer(insamples); |
| @@ -93,6 +93,7 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 92 unmodified lines | |||
| 93 | enum AVSampleFormat sample_fmt, | 93 | enum AVSampleFormat sample_fmt, |
| 94 | uint64_t channel_layout) | 94 | uint64_t channel_layout) |
| 95 | { | 95 | { |
| 96 | int channels = av_get_channel_layout_nb_channels(channel_layout); | ||
| 96 | int planes; | 97 | int planes; |
| 97 | AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); | 98 | AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); |
| 98 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); | 99 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); |
| @@ -107,9 +108,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 8 unmodified lines | |||
| 107 | 108 | ||
| 108 | samplesref->audio->nb_samples = nb_samples; | 109 | samplesref->audio->nb_samples = nb_samples; |
| 109 | samplesref->audio->channel_layout = channel_layout; | 110 | samplesref->audio->channel_layout = channel_layout; |
| 111 | samplesref->audio->channels = channels; | ||
| 110 | 112 | ||
| 111 | planes = av_sample_fmt_is_planar(sample_fmt) ? | 113 | planes = av_sample_fmt_is_planar(sample_fmt) ? channels : 1; |
| 112 | av_get_channel_layout_nb_channels(channel_layout) : 1; | ||
| 113 | 114 | ||
| 114 | /* make sure the buffer gets read permission or it's useless for output */ | 115 | /* make sure the buffer gets read permission or it's useless for output */ |
| 115 | samplesref->perms = perms | AV_PERM_READ; | 116 | samplesref->perms = perms | AV_PERM_READ; |
| @@ -225,6 +226,7 @@ int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) · 109 unmodified lines | |||
| 225 | int ret = 0; | 226 | int ret = 0; |
| 226 | 227 | ||
| 227 | av_assert1(samplesref->format == link->format); | 228 | av_assert1(samplesref->format == link->format); |
| 229 | av_assert1(samplesref->audio->channels == link->channels); | ||
| 228 | av_assert1(samplesref->audio->channel_layout == link->channel_layout); | 230 | av_assert1(samplesref->audio->channel_layout == link->channel_layout); |
| 229 | av_assert1(samplesref->audio->sample_rate == link->sample_rate); | 231 | av_assert1(samplesref->audio->sample_rate == link->sample_rate); |
| 230 | 232 | ||
| @@ -164,6 +164,11 @@ void avfilter_link_free(AVFilterLink **link) · 163 unmodified lines | |||
| 164 | av_freep(link); | 164 | av_freep(link); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | int avfilter_link_get_channels(AVFilterLink *link) | ||
| 168 | { | ||
| 169 | return link->channels; | ||
| 170 | } | ||
| 171 | |||
| 167 | void avfilter_link_set_closed(AVFilterLink *link, int closed) | 172 | void avfilter_link_set_closed(AVFilterLink *link, int closed) |
| 168 | { | 173 | { |
| 169 | link->closed = closed; | 174 | link->closed = closed; |
| @@ -699,6 +699,11 @@ struct AVFilterLink { · 698 unmodified lines | |||
| 699 | * filter. | 699 | * filter. |
| 700 | */ | 700 | */ |
| 701 | int closed; | 701 | int closed; |
| 702 | |||
| 703 | /** | ||
| 704 | * Number of channels. | ||
| 705 | */ | ||
| 706 | int channels; | ||
| 702 | }; | 707 | }; |
| 703 | 708 | ||
| 704 | /** | 709 | /** |
| @@ -718,6 +723,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 13 unmodified lines | |||
| 718 | */ | 723 | */ |
| 719 | void avfilter_link_free(AVFilterLink **link); | 724 | void avfilter_link_free(AVFilterLink **link); |
| 720 | 725 | ||
| 726 | /** | ||
| 727 | * Get the number of channels of a link. | ||
| 728 | */ | ||
| 729 | int avfilter_link_get_channels(AVFilterLink *link); | ||
| 730 | |||
| 721 | /** | 731 | /** |
| 722 | * Set the closed field of a link. | 732 | * Set the closed field of a link. |
| 723 | */ | 733 | */ |
| @@ -473,6 +473,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) · 472 unmodified lines | |||
| 473 | } | 473 | } |
| 474 | link->in_channel_layouts->nb_channel_layouts = 1; | 474 | link->in_channel_layouts->nb_channel_layouts = 1; |
| 475 | link->channel_layout = link->in_channel_layouts->channel_layouts[0]; | 475 | link->channel_layout = link->in_channel_layouts->channel_layouts[0]; |
| 476 | link->channels = av_get_channel_layout_nb_channels(link->channel_layout); | ||
| 476 | } | 477 | } |
| 477 | 478 | ||
| 478 | ff_formats_unref(&link->in_formats); | 479 | ff_formats_unref(&link->in_formats); |