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