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
00026 static void print_formats(AVFilterContext *filter_ctx)
00027 {
00028 int i, j;
00029
00030 #define PRINT_FMTS(inout, outin, INOUT) \
00031 for (i = 0; i < filter_ctx->inout##put_count; i++) { \
00032 if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \
00033 AVFilterFormats *fmts = \
00034 filter_ctx->inout##puts[i]->outin##_formats; \
00035 for (j = 0; j < fmts->format_count; j++) \
00036 if(av_get_pix_fmt_name(fmts->formats[j])) \
00037 printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
00038 i, filter_ctx->filter->inout##puts[i].name, \
00039 av_get_pix_fmt_name(fmts->formats[j])); \
00040 } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
00041 AVFilterFormats *fmts; \
00042 \
00043 fmts = filter_ctx->inout##puts[i]->outin##_formats; \
00044 for (j = 0; j < fmts->format_count; j++) \
00045 printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
00046 i, filter_ctx->filter->inout##puts[i].name, \
00047 av_get_sample_fmt_name(fmts->formats[j])); \
00048 \
00049 fmts = filter_ctx->inout##puts[i]->outin##_chlayouts; \
00050 for (j = 0; j < fmts->format_count; j++) { \
00051 char buf[256]; \
00052 av_get_channel_layout_string(buf, sizeof(buf), -1, \
00053 fmts->formats[j]); \
00054 printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
00055 i, filter_ctx->filter->inout##puts[i].name, buf); \
00056 } \
00057 \
00058 fmts = filter_ctx->inout##puts[i]->outin##_packing; \
00059 for (j = 0; j < fmts->format_count; j++) { \
00060 printf(#INOUT "PUT[%d] %s: packing:%s\n", \
00061 i, filter_ctx->filter->inout##puts[i].name, \
00062 fmts->formats[j] == AVFILTER_PACKED ? \
00063 "packed" : "planar"); \
00064 } \
00065 } \
00066 } \
00067
00068 PRINT_FMTS(in, out, IN);
00069 PRINT_FMTS(out, in, OUT);
00070 }
00071
00072 int main(int argc, char **argv)
00073 {
00074 AVFilter *filter;
00075 AVFilterContext *filter_ctx;
00076 const char *filter_name;
00077 const char *filter_args = NULL;
00078 int i;
00079
00080 av_log_set_level(AV_LOG_DEBUG);
00081
00082 if (!argv[1]) {
00083 fprintf(stderr, "Missing filter name as argument\n");
00084 return 1;
00085 }
00086
00087 filter_name = argv[1];
00088 if (argv[2])
00089 filter_args = argv[2];
00090
00091 avfilter_register_all();
00092
00093
00094 if (!(filter = avfilter_get_by_name(filter_name))) {
00095 fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
00096 return 1;
00097 }
00098
00099 if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
00100 fprintf(stderr, "Inpossible to open filter with name '%s'\n",
00101 filter_name);
00102 return 1;
00103 }
00104 if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
00105 fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
00106 filter_name, filter_args);
00107 return 1;
00108 }
00109
00110
00111 for (i = 0; i < filter_ctx->input_count; i++) {
00112 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00113 link->type = filter_ctx->filter->inputs[i].type;
00114 filter_ctx->inputs[i] = link;
00115 }
00116 for (i = 0; i < filter_ctx->output_count; i++) {
00117 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00118 link->type = filter_ctx->filter->outputs[i].type;
00119 filter_ctx->outputs[i] = link;
00120 }
00121
00122 if (filter->query_formats)
00123 filter->query_formats(filter_ctx);
00124 else
00125 avfilter_default_query_formats(filter_ctx);
00126
00127 print_formats(filter_ctx);
00128
00129 avfilter_free(filter_ctx);
00130 fflush(stdout);
00131 return 0;
00132 }