Since the default in the libav fork is to only allow known layouts, making unknown layouts allowed by default here can be a security risk for filters directly merged from libav. However, usually it is simple to detect such cases, use of av_get_channel_layout_nb_channels is a good indicator, so I suggest we change this regardless. See http://ffmpeg.org/pipermail/ffmpeg-devel/2016-November/203204.html. This patch indirectly adds unknown channel layout support for filters where query_formats is not specified: abench afifo ainterleave anullsink apad aperms arealtime aselect asendcmd asetnsamples asetpts asettb ashowinfo azmq It introduces a query_formats callback for the asyncts filter, which only supports known channel layouts since it is using libavresample. And it removes .query_formats callback from filters where it was only there to support unknown layouts, as this is now the default: aloop ametadata anull asidedata asplit atrim
Unified · Split
| @@ -46,7 +46,6 @@ static const AVFilterPad avfilter_af_anull_outputs[] = { · 45 unmodified lines | ||
| 46 | 46 | AVFilter ff_af_anull = { |
| 47 | 47 | .name = "anull", |
| 48 | 48 | .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."), |
| 49 | − .query_formats = ff_query_formats_all, | |
| 50 | 49 | .inputs = avfilter_af_anull_inputs, |
| 51 | 50 | .outputs = avfilter_af_anull_outputs, |
| 52 | 51 | }; |
| @@ -317,6 +317,7 @@ AVFilter ff_af_asyncts = { · 316 unmodified lines | ||
| 317 | 317 | .uninit = uninit, |
| 318 | 318 | .priv_size = sizeof(ASyncContext), |
| 319 | 319 | .priv_class = &asyncts_class, |
| 320 | + .query_formats = ff_query_formats_all_layouts, | |
| 320 | 321 | .inputs = avfilter_af_asyncts_inputs, |
| 321 | 322 | .outputs = avfilter_af_asyncts_outputs, |
| 322 | 323 | }; |
| @@ -233,7 +233,6 @@ AVFilter ff_af_aloop = { · 232 unmodified lines | ||
| 233 | 233 | .priv_size = sizeof(LoopContext), |
| 234 | 234 | .priv_class = &aloop_class, |
| 235 | 235 | .uninit = auninit, |
| 236 | − .query_formats = ff_query_formats_all, | |
| 237 | 236 | .inputs = ainputs, |
| 238 | 237 | .outputs = aoutputs, |
| 239 | 238 | }; |
| @@ -373,7 +373,6 @@ AVFilter ff_af_ametadata = { · 372 unmodified lines | ||
| 373 | 373 | .priv_class = &ametadata_class, |
| 374 | 374 | .init = init, |
| 375 | 375 | .uninit = uninit, |
| 376 | − .query_formats = ff_query_formats_all, | |
| 377 | 376 | .inputs = ainputs, |
| 378 | 377 | .outputs = aoutputs, |
| 379 | 378 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, |
| @@ -139,7 +139,6 @@ AVFilter ff_af_asidedata = { · 138 unmodified lines | ||
| 139 | 139 | .priv_size = sizeof(SideDataContext), |
| 140 | 140 | .priv_class = &asidedata_class, |
| 141 | 141 | .init = init, |
| 142 | − .query_formats = ff_query_formats_all, | |
| 143 | 142 | .inputs = ainputs, |
| 144 | 143 | .outputs = aoutputs, |
| 145 | 144 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, |
| @@ -596,12 +596,12 @@ static int default_query_formats_common(AVFilterContext *ctx, · 595 unmodified lines | ||
| 596 | 596 | |
| 597 | 597 | int ff_default_query_formats(AVFilterContext *ctx) |
| 598 | 598 | { |
| 599 | − return default_query_formats_common(ctx, ff_all_channel_layouts); | |
| 599 | + return default_query_formats_common(ctx, ff_all_channel_counts); | |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | −int ff_query_formats_all(AVFilterContext *ctx) | |
| 602 | +int ff_query_formats_all_layouts(AVFilterContext *ctx) | |
| 603 | 603 | { |
| 604 | − return default_query_formats_common(ctx, ff_all_channel_counts); | |
| 604 | + return default_query_formats_common(ctx, ff_all_channel_layouts); | |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /* internal functions for parsing audio format arguments */ |
| @@ -186,15 +186,13 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, · 185 unmodified lines | ||
| 186 | 186 | av_warn_unused_result |
| 187 | 187 | int ff_default_query_formats(AVFilterContext *ctx); |
| 188 | 188 | |
| 189 | −/** | |
| 190 | − * Set the formats list to all existing formats. | |
| 191 | − * This function behaves like ff_default_query_formats(), except it also | |
| 192 | − * accepts channel layouts with unknown disposition. It should only be used | |
| 193 | − * with audio filters. | |
| 189 | + /** | |
| 190 | + * Set the formats list to all known channel layouts. This function behaves | |
| 191 | + * like ff_default_query_formats(), except it only accepts known channel | |
| 192 | + * layouts. It should only be used with audio filters. | |
| 194 | 193 | */ |
| 195 | 194 | av_warn_unused_result |
| 196 | −int ff_query_formats_all(AVFilterContext *ctx); | |
| 197 | − | |
| 195 | +int ff_query_formats_all_layouts(AVFilterContext *ctx); | |
| 198 | 196 | |
| 199 | 197 | /** |
| 200 | 198 | * Create a list of supported formats. This is intended for use in |
| @@ -144,7 +144,6 @@ AVFilter ff_af_asplit = { · 143 unmodified lines | ||
| 144 | 144 | .priv_class = &asplit_class, |
| 145 | 145 | .init = split_init, |
| 146 | 146 | .uninit = split_uninit, |
| 147 | − .query_formats = ff_query_formats_all, | |
| 148 | 147 | .inputs = avfilter_af_asplit_inputs, |
| 149 | 148 | .outputs = NULL, |
| 150 | 149 | .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, |
| @@ -365,7 +365,6 @@ AVFilter ff_af_atrim = { · 364 unmodified lines | ||
| 365 | 365 | .name = "atrim", |
| 366 | 366 | .description = NULL_IF_CONFIG_SMALL("Pick one continuous section from the input, drop the rest."), |
| 367 | 367 | .init = init, |
| 368 | − .query_formats = ff_query_formats_all, | |
| 369 | 368 | .priv_size = sizeof(TrimContext), |
| 370 | 369 | .priv_class = &atrim_class, |
| 371 | 370 | .inputs = atrim_inputs, |