28 #define FF_INTERNAL_FIELDS 1
39 #define PRINT_FMTS(inout, outin, INOUT) \
40 for (i = 0; i < filter_ctx->nb_##inout##puts; i++) { \
41 if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \
42 AVFilterFormats *fmts = \
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; \
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])); \
59 layouts = filter_ctx->inout##puts[i]->outin##cfg.channel_layouts; \
60 for (j = 0; j < layouts->nb_channel_layouts; j++) { \
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); \
74 int main(
int argc,
char **argv)
79 const char *filter_name;
80 const char *filter_args =
NULL;
87 fprintf(stderr,
"Missing filter name as argument\n");
91 filter_name = argv[1];
93 filter_args = argv[2];
102 fprintf(stderr,
"Unrecognized filter with name '%s'\n", filter_name);
108 fprintf(stderr,
"Impossible to open filter with name '%s'\n",
113 fprintf(stderr,
"Impossible to init filter '%s' with arguments '%s'\n",
114 filter_name, filter_args);
122 fprintf(stderr,
"Unable to allocate memory for filter input link\n");
132 fprintf(stderr,
"Unable to allocate memory for filter output link\n");
140 if (
filter->query_formats)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Main libavfilter public API header.
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
audio channel layout utility functions
int main(int argc, char **argv)
#define PRINT_FMTS(inout, outin, INOUT)
static void print_formats(AVFilterContext *filter_ctx)
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
void avfilter_free(AVFilterContext *filter)
Free a filter context.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_log_set_level(int level)
Set the log level.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Memory handling functions.
A link between two filters.
enum AVMediaType type
filter media type
static FilteringContext * filter_ctx