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
| @@ -301,9 +301,7 @@ static av_cold int config_output(AVFilterLink *outlink) · 300 unmodified lines | |||
| 301 | return 0; | 301 | return 0; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | static av_cold int query_formats(AVFilterContext *avctx) | 304 | static const enum AVPixelFormat chromakey_fmts[] = { |
| 305 | { | ||
| 306 | static const enum AVPixelFormat pixel_fmts[] = { | ||
| 307 | AV_PIX_FMT_YUVA420P, | 305 | AV_PIX_FMT_YUVA420P, |
| 308 | AV_PIX_FMT_YUVA422P, | 306 | AV_PIX_FMT_YUVA422P, |
| 309 | AV_PIX_FMT_YUVA444P, | 307 | AV_PIX_FMT_YUVA444P, |
| @@ -332,12 +330,6 @@ static av_cold int query_formats(AVFilterContext *avctx) · 22 unmodified lines | |||
| 332 | AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, | 330 | AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, |
| 333 | AV_PIX_FMT_NONE | 331 | AV_PIX_FMT_NONE |
| 334 | }; | 332 | }; |
| 335 | const enum AVPixelFormat *pix_fmts; | ||
| 336 | |||
| 337 | pix_fmts = !strcmp(avctx->filter->name, "chromahold") ? hold_pixel_fmts : pixel_fmts; | ||
| 338 | |||
| 339 | return ff_set_common_formats_from_list(avctx, pix_fmts); | ||
| 340 | } | ||
| 341 | 333 | ||
| 342 | static av_cold int config_input(AVFilterLink *inlink) | 334 | static av_cold int config_input(AVFilterLink *inlink) |
| 343 | { | 335 | { |
| @@ -401,7 +393,7 @@ const AVFilter ff_vf_chromakey = { · 57 unmodified lines | |||
| 401 | .priv_class = &chromakey_class, | 393 | .priv_class = &chromakey_class, |
| 402 | FILTER_INPUTS(chromakey_inputs), | 394 | FILTER_INPUTS(chromakey_inputs), |
| 403 | FILTER_OUTPUTS(chromakey_outputs), | 395 | FILTER_OUTPUTS(chromakey_outputs), |
| 404 | FILTER_QUERY_FUNC(query_formats), | 396 | FILTER_PIXFMTS_ARRAY(chromakey_fmts), |
| 405 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, | 397 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 406 | .process_command = process_command, | 398 | .process_command = process_command, |
| 407 | }; | 399 | }; |
| @@ -441,7 +433,7 @@ const AVFilter ff_vf_chromahold = { · 33 unmodified lines | |||
| 441 | .priv_class = &chromahold_class, | 433 | .priv_class = &chromahold_class, |
| 442 | FILTER_INPUTS(chromahold_inputs), | 434 | FILTER_INPUTS(chromahold_inputs), |
| 443 | FILTER_OUTPUTS(chromahold_outputs), | 435 | FILTER_OUTPUTS(chromahold_outputs), |
| 444 | FILTER_QUERY_FUNC(query_formats), | 436 | FILTER_PIXFMTS_ARRAY(hold_pixel_fmts), |
| 445 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, | 437 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 446 | .process_command = process_command, | 438 | .process_command = process_command, |
| 447 | }; | 439 | }; |