In this case it also allows to avoid a runtime check to which filter an AVFilterContext belongs to.
Unified · Split
| @@ -244,9 +244,7 @@ static av_cold int config_output(AVFilterLink *outlink) · 243 unmodified lines | ||
| 244 | 244 | return 0; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | −static av_cold int query_formats(AVFilterContext *avctx) | |
| 248 | −{ | |
| 249 | − static const enum AVPixelFormat pixel_fmts[] = { | |
| 247 | +static const enum AVPixelFormat key_pixel_fmts[] = { | |
| 250 | 248 | AV_PIX_FMT_YUVA420P, |
| 251 | 249 | AV_PIX_FMT_YUVA422P, |
| 252 | 250 | AV_PIX_FMT_YUVA444P, |
| @@ -275,12 +273,6 @@ static av_cold int query_formats(AVFilterContext *avctx) · 22 unmodified lines | ||
| 275 | 273 | AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, |
| 276 | 274 | AV_PIX_FMT_NONE |
| 277 | 275 | }; |
| 278 | − const enum AVPixelFormat *pix_fmts; | |
| 279 | − | |
| 280 | − pix_fmts = !strcmp(avctx->filter->name, "hsvhold") ? hold_pixel_fmts : pixel_fmts; | |
| 281 | − | |
| 282 | − return ff_set_common_formats_from_list(avctx, pix_fmts); | |
| 283 | −} | |
| 284 | 276 | |
| 285 | 277 | static av_cold int config_input(AVFilterLink *inlink) |
| 286 | 278 | { |
| @@ -333,7 +325,7 @@ const AVFilter ff_vf_hsvkey = { · 46 unmodified lines | ||
| 333 | 325 | .priv_class = &hsvkey_class, |
| 334 | 326 | FILTER_INPUTS(hsvkey_inputs), |
| 335 | 327 | FILTER_OUTPUTS(hsvkey_outputs), |
| 336 | − FILTER_QUERY_FUNC(query_formats), | |
| 328 | + FILTER_PIXFMTS_ARRAY(key_pixel_fmts), | |
| 337 | 329 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 338 | 330 | .process_command = ff_filter_process_command, |
| 339 | 331 | }; |
| @@ -374,7 +366,7 @@ const AVFilter ff_vf_hsvhold = { · 34 unmodified lines | ||
| 374 | 366 | .priv_class = &hsvhold_class, |
| 375 | 367 | FILTER_INPUTS(hsvhold_inputs), |
| 376 | 368 | FILTER_OUTPUTS(hsvhold_outputs), |
| 377 | − FILTER_QUERY_FUNC(query_formats), | |
| 369 | + FILTER_PIXFMTS_ARRAY(hold_pixel_fmts), | |
| 378 | 370 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 379 | 371 | .process_command = ff_filter_process_command, |
| 380 | 372 | }; |