This is possible now that AVFilterFormatsConfig exists.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -32,43 +32,50 @@ · 31 unmodified lines | |||
| 32 | #include "libavfilter/formats.h" | 32 | #include "libavfilter/formats.h" |
| 33 | #include "libavfilter/internal.h" | 33 | #include "libavfilter/internal.h" |
| 34 | 34 | ||
| 35 | static void print_formats_internal(AVFilterLink **links, const AVFilterPad *pads, | ||
| 36 | unsigned nb, size_t fmts_cfg_offset, | ||
| 37 | const char *inout_string) | ||
| 38 | { | ||
| 39 | for (unsigned i = 0; i < nb; i++) { | ||
| 40 | const AVFilterLink *const link = links[i]; | ||
| 41 | const AVFilterFormatsConfig *const cfg = (AVFilterFormatsConfig*)((const char*)link + fmts_cfg_offset); | ||
| 42 | const char *pad_name = avfilter_pad_get_name(pads, i); | ||
| 43 | |||
| 44 | if (link->type == AVMEDIA_TYPE_VIDEO) { | ||
| 45 | const AVFilterFormats *const fmts = cfg->formats; | ||
| 46 | for (unsigned j = 0; j < fmts->nb_formats; j++) { | ||
| 47 | printf("%s[%u] %s: fmt:%s\n", | ||
| 48 | inout_string, i, pad_name, | ||
| 49 | av_get_pix_fmt_name(fmts->formats[j])); | ||
| 50 | } | ||
| 51 | } else if (link->type == AVMEDIA_TYPE_AUDIO) { | ||
| 52 | const AVFilterFormats *const fmts = cfg->formats; | ||
| 53 | const AVFilterChannelLayouts *const layouts = cfg->channel_layouts; | ||
| 54 | |||
| 55 | for (unsigned j = 0; j < fmts->nb_formats; j++) | ||
| 56 | printf("%s[%u] %s: fmt:%s\n", | ||
| 57 | inout_string, i, pad_name, | ||
| 58 | av_get_sample_fmt_name(fmts->formats[j])); | ||
| 59 | |||
| 60 | for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) { | ||
| 61 | char buf[256]; | ||
| 62 | av_get_channel_layout_string(buf, sizeof(buf), -1, | ||
| 63 | layouts->channel_layouts[j]); | ||
| 64 | printf("%s[%u] %s: chlayout:%s\n", | ||
| 65 | inout_string, i, pad_name, buf); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 35 | static void print_formats(AVFilterContext *filter_ctx) | 71 | static void print_formats(AVFilterContext *filter_ctx) |
| 36 | { | 72 | { |
| 37 | int i, j; | 73 | print_formats_internal(filter_ctx->inputs, filter_ctx->input_pads, |
| 38 | 74 | filter_ctx->nb_inputs, | |
| 39 | #define PRINT_FMTS(inout, outin, INOUT) \ | 75 | offsetof(AVFilterLink, outcfg), "INPUT"); |
| 40 | for (i = 0; i < filter_ctx->nb_##inout##puts; i++) { \ | 76 | print_formats_internal(filter_ctx->outputs, filter_ctx->output_pads, |
| 41 | if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \ | 77 | filter_ctx->nb_outputs, |
| 42 | AVFilterFormats *fmts = \ | 78 | offsetof(AVFilterLink, incfg), "OUTPUT"); |
| 43 | filter_ctx->inout##puts[i]->outin##cfg.formats; \ | ||
| 44 | for (j = 0; j < fmts->nb_formats; j++) \ | ||
| 45 | if(av_get_pix_fmt_name(fmts->formats[j])) \ | ||
| 46 | printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ | ||
| 47 | i, avfilter_pad_get_name(filter_ctx->inout##put_pads, i), \ | ||
| 48 | av_get_pix_fmt_name(fmts->formats[j])); \ | ||
| 49 | } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \ | ||
| 50 | AVFilterFormats *fmts; \ | ||
| 51 | AVFilterChannelLayouts *layouts; \ | ||
| 52 | \ | ||
| 53 | fmts = filter_ctx->inout##puts[i]->outin##cfg.formats; \ | ||
| 54 | for (j = 0; j < fmts->nb_formats; j++) \ | ||
| 55 | printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ | ||
| 56 | i, avfilter_pad_get_name(filter_ctx->inout##put_pads, i), \ | ||
| 57 | av_get_sample_fmt_name(fmts->formats[j])); \ | ||
| 58 | \ | ||
| 59 | layouts = filter_ctx->inout##puts[i]->outin##cfg.channel_layouts; \ | ||
| 60 | for (j = 0; j < layouts->nb_channel_layouts; j++) { \ | ||
| 61 | char buf[256]; \ | ||
| 62 | av_get_channel_layout_string(buf, sizeof(buf), -1, \ | ||
| 63 | layouts->channel_layouts[j]); \ | ||
| 64 | printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ | ||
| 65 | i, avfilter_pad_get_name(filter_ctx->inout##put_pads, i), buf); \ | ||
| 66 | } \ | ||
| 67 | } \ | ||
| 68 | } \ | ||
| 69 | |||
| 70 | PRINT_FMTS(in, out, IN); | ||
| 71 | PRINT_FMTS(out, in, OUT); | ||
| 72 | } | 79 | } |
| 73 | 80 | ||
| 74 | int main(int argc, char **argv) | 81 | int main(int argc, char **argv) |