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