00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022
00023 #include "libavformat/avformat.h"
00024 #include "libavutil/pixdesc.h"
00025 #include "libavutil/samplefmt.h"
00026 #include "libavfilter/avfilter.h"
00027 #include "libavfilter/formats.h"
00028
00029 #undef fprintf
00030 #undef printf
00031
00032 static void print_formats(AVFilterContext *filter_ctx)
00033 {
00034 int i, j;
00035
00036 #define PRINT_FMTS(inout, outin, INOUT) \
00037 for (i = 0; i < filter_ctx->inout##put_count; i++) { \
00038 if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \
00039 AVFilterFormats *fmts = \
00040 filter_ctx->inout##puts[i]->outin##_formats; \
00041 for (j = 0; j < fmts->format_count; j++) \
00042 if(av_get_pix_fmt_name(fmts->formats[j])) \
00043 printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
00044 i, filter_ctx->filter->inout##puts[i].name, \
00045 av_get_pix_fmt_name(fmts->formats[j])); \
00046 } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
00047 AVFilterFormats *fmts; \
00048 AVFilterChannelLayouts *layouts; \
00049 \
00050 fmts = filter_ctx->inout##puts[i]->outin##_formats; \
00051 for (j = 0; j < fmts->format_count; j++) \
00052 printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
00053 i, filter_ctx->filter->inout##puts[i].name, \
00054 av_get_sample_fmt_name(fmts->formats[j])); \
00055 \
00056 layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \
00057 for (j = 0; j < layouts->nb_channel_layouts; j++) { \
00058 char buf[256]; \
00059 av_get_channel_layout_string(buf, sizeof(buf), -1, \
00060 layouts->channel_layouts[j]); \
00061 printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
00062 i, filter_ctx->filter->inout##puts[i].name, buf); \
00063 } \
00064 } \
00065 } \
00066
00067 PRINT_FMTS(in, out, IN);
00068 PRINT_FMTS(out, in, OUT);
00069 }
00070
00071 int main(int argc, char **argv)
00072 {
00073 AVFilter *filter;
00074 AVFilterContext *filter_ctx;
00075 const char *filter_name;
00076 const char *filter_args = NULL;
00077 int i;
00078
00079 av_log_set_level(AV_LOG_DEBUG);
00080
00081 if (argc < 2) {
00082 fprintf(stderr, "Missing filter name as argument\n");
00083 return 1;
00084 }
00085
00086 filter_name = argv[1];
00087 if (argc > 2)
00088 filter_args = argv[2];
00089
00090 avfilter_register_all();
00091
00092
00093 if (!(filter = avfilter_get_by_name(filter_name))) {
00094 fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
00095 return 1;
00096 }
00097
00098 if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
00099 fprintf(stderr, "Impossible to open filter with name '%s'\n",
00100 filter_name);
00101 return 1;
00102 }
00103 if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
00104 fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
00105 filter_name, filter_args);
00106 return 1;
00107 }
00108
00109
00110 for (i = 0; i < filter_ctx->input_count; i++) {
00111 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00112 link->type = filter_ctx->filter->inputs[i].type;
00113 filter_ctx->inputs[i] = link;
00114 }
00115 for (i = 0; i < filter_ctx->output_count; i++) {
00116 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00117 link->type = filter_ctx->filter->outputs[i].type;
00118 filter_ctx->outputs[i] = link;
00119 }
00120
00121 if (filter->query_formats)
00122 filter->query_formats(filter_ctx);
00123 else
00124 ff_default_query_formats(filter_ctx);
00125
00126 print_formats(filter_ctx);
00127
00128 avfilter_free(filter_ctx);
00129 fflush(stdout);
00130 return 0;
00131 }