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
| @@ -52,8 +52,6 @@ typedef struct ChromaShiftContext { · 51 unmodified lines | |||
| 52 | int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); | 52 | int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); |
| 53 | } ChromaShiftContext; | 53 | } ChromaShiftContext; |
| 54 | 54 | ||
| 55 | static int query_formats(AVFilterContext *ctx) | ||
| 56 | { | ||
| 57 | static const enum AVPixelFormat yuv_pix_fmts[] = { | 55 | static const enum AVPixelFormat yuv_pix_fmts[] = { |
| 58 | AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, | 56 | AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, |
| 59 | AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, | 57 | AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, |
| @@ -75,15 +73,6 @@ static int query_formats(AVFilterContext *ctx) · 15 unmodified lines | |||
| 75 | AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, | 73 | AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, |
| 76 | AV_PIX_FMT_NONE | 74 | AV_PIX_FMT_NONE |
| 77 | }; | 75 | }; |
| 78 | const enum AVPixelFormat *pix_fmts; | ||
| 79 | |||
| 80 | if (!strcmp(ctx->filter->name, "rgbashift")) | ||
| 81 | pix_fmts = rgb_pix_fmts; | ||
| 82 | else | ||
| 83 | pix_fmts = yuv_pix_fmts; | ||
| 84 | |||
| 85 | return ff_set_common_formats_from_list(ctx, pix_fmts); | ||
| 86 | } | ||
| 87 | 76 | ||
| 88 | #define DEFINE_SMEAR(depth, type, div) \ | 77 | #define DEFINE_SMEAR(depth, type, div) \ |
| 89 | static int smear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \ | 78 | static int smear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \ |
| @@ -447,7 +436,7 @@ const AVFilter ff_vf_chromashift = { · 357 unmodified lines | |||
| 447 | .priv_class = &chromashift_class, | 436 | .priv_class = &chromashift_class, |
| 448 | FILTER_OUTPUTS(outputs), | 437 | FILTER_OUTPUTS(outputs), |
| 449 | FILTER_INPUTS(inputs), | 438 | FILTER_INPUTS(inputs), |
| 450 | FILTER_QUERY_FUNC(query_formats), | 439 | FILTER_PIXFMTS_ARRAY(yuv_pix_fmts), |
| 451 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, | 440 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 452 | .process_command = process_command, | 441 | .process_command = process_command, |
| 453 | }; | 442 | }; |
| @@ -476,7 +465,7 @@ const AVFilter ff_vf_rgbashift = { · 22 unmodified lines | |||
| 476 | .priv_class = &rgbashift_class, | 465 | .priv_class = &rgbashift_class, |
| 477 | FILTER_OUTPUTS(outputs), | 466 | FILTER_OUTPUTS(outputs), |
| 478 | FILTER_INPUTS(inputs), | 467 | FILTER_INPUTS(inputs), |
| 479 | FILTER_QUERY_FUNC(query_formats), | 468 | FILTER_PIXFMTS_ARRAY(rgb_pix_fmts), |
| 480 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, | 469 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, |
| 481 | .process_command = process_command, | 470 | .process_command = process_command, |
| 482 | }; | 471 | }; |