69 "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
83 for (; *p != -1; p++) {
92 "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
150 #define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \
151 static char *choose_ ## var ## s(OutputStream *ost) \
153 if (ost->enc_ctx->var != none) { \
154 get_name(ost->enc_ctx->var); \
155 return av_strdup(name); \
156 } else if (ost->enc && ost->enc->supported_list) { \
158 AVIOContext *s = NULL; \
162 if (avio_open_dyn_buf(&s) < 0) \
165 for (p = ost->enc->supported_list; *p != none; p++) { \
167 avio_printf(s, "%s|", name); \
169 len = avio_close_dyn_buf(s, &ret); \
211 ist->filters[ist->nb_filters - 1] = fg->
inputs[0];
236 int file_idx = strtol(in->
name, &p, 0);
247 if (stream_type != type &&
269 if (i == nb_input_streams) {
271 "unlabeled input pad %d on filter %s\n", in->
pad_idx,
294 const char *filter_name)
309 "recording time.\n", name);
317 if (duration != INT64_MAX) {
344 const char *filter_name,
const char *
args)
352 filter_name, args,
NULL, graph);
388 snprintf(args,
sizeof(args),
"%d:%d:0x%X",
392 snprintf(name,
sizeof(name),
"scaler for output stream %d:%d",
397 if ((ret =
avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
406 snprintf(name,
sizeof(name),
"pixel format for output stream %d:%d",
414 if ((ret =
avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
427 snprintf(name,
sizeof(name),
"fps for output stream %d:%d",
441 snprintf(name,
sizeof(name),
"trim for output stream %d:%d",
444 &last_filter, &pad_idx, name);
475 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
476 AVFilterContext *filt_ctx; \
478 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
479 "similarly to -af " filter_name "=%s.\n", arg); \
481 ret = avfilter_graph_create_filter(&filt_ctx, \
482 avfilter_get_by_name(filter_name), \
483 filter_name, arg, NULL, fg->graph); \
487 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
491 last_filter = filt_ctx; \
511 sample_fmts = choose_sample_fmts(ost);
512 sample_rates = choose_sample_rates(ost);
513 channel_layouts = choose_channel_layouts(ost);
514 if (sample_fmts || sample_rates || channel_layouts) {
523 av_strlcatf(args,
sizeof(args),
"sample_rates=%s:",
526 av_strlcatf(args,
sizeof(args),
"channel_layouts=%s:",
533 snprintf(name,
sizeof(name),
"audio format for output stream %d:%d",
545 last_filter = format;
564 if (i<of->ctx->nb_streams) {
570 snprintf(name,
sizeof(name),
"trim for output stream %d:%d",
573 &last_filter, &pad_idx, name);
583 #define DESCRIBE_FILTER_LINK(f, inout, in) \
585 AVFilterContext *ctx = inout->filter_ctx; \
586 AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; \
587 int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; \
590 if (avio_open_dyn_buf(&pb) < 0) \
593 avio_printf(pb, "%s", ctx->filter->name); \
595 avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
597 avio_close_dyn_buf(pb, &f->name); \
662 int ret, pad_idx = 0;
663 int64_t tsoffset = 0;
686 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
694 snprintf(name,
sizeof(name),
"graph %d input from stream %d:%d", fg->
index,
700 last_filter = ifilter->
filter;
705 if (fabs(theta - 90) < 1.0) {
706 ret =
insert_filter(&last_filter, &pad_idx,
"transpose",
"clock");
707 }
else if (fabs(theta - 180) < 1.0) {
712 }
else if (fabs(theta - 270) < 1.0) {
713 ret =
insert_filter(&last_filter, &pad_idx,
"transpose",
"cclock");
714 }
else if (fabs(theta) > 1.0) {
716 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
717 ret =
insert_filter(&last_filter, &pad_idx,
"rotate", rotate_buf);
726 snprintf(name,
sizeof(name),
"force CFR for input from stream %d:%d",
737 last_filter = setpts;
743 snprintf(name,
sizeof(name),
"deinterlace input from stream %d:%d",
757 snprintf(name,
sizeof(name),
"trim for input stream %d:%d",
766 &last_filter, &pad_idx, name);
784 int ret, pad_idx = 0;
785 int64_t tsoffset = 0;
793 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
798 av_bprintf(&args,
":channel_layout=0x%"PRIx64,
802 snprintf(name,
sizeof(name),
"graph %d input from stream %d:%d", fg->
index,
806 name, args.str,
NULL,
809 last_filter = ifilter->
filter;
811 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \
812 AVFilterContext *filt_ctx; \
814 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
815 "similarly to -af " filter_name "=%s.\n", arg); \
817 snprintf(name, sizeof(name), "graph %d %s for input stream %d:%d", \
818 fg->index, filter_name, ist->file_index, ist->st->index); \
819 ret = avfilter_graph_create_filter(&filt_ctx, \
820 avfilter_get_by_name(filter_name), \
821 name, arg, NULL, fg->graph); \
825 ret = avfilter_link(last_filter, 0, filt_ctx, 0); \
829 last_filter = filt_ctx; \
833 char args[256] = {0};
860 "audio filter instead.\n");
866 snprintf(name,
sizeof(name),
"trim for input stream %d:%d",
875 &last_filter, &pad_idx, name);
893 "No decoder for stream #%d:%d, filtering impossible\n",
929 args[strlen(args)-1] = 0;
938 args[strlen(args) - 1] =
'\0';
949 if (simple && (!inputs || inputs->
next || !outputs || outputs->
next)) {
951 "exactly one input and output.\n", graph_desc);
955 for (cur = inputs; !simple && init && cur; cur = cur->
next)
958 for (cur = inputs, i = 0; cur; cur = cur->
next, i++)
966 if (!init || simple) {
969 for (cur = outputs, i = 0; cur; cur = cur->
next, i++)
977 for (cur = outputs; cur;) {
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define DECODING_FOR_FILTER
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
double get_rotation(AVStream *st)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
#define CODEC_CAP_LOSSLESS
Codec is lossless.
static int insert_trim(int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
FilterGraph * init_simple_filtergraph(InputStream *ist, OutputStream *ost)
static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
int index
stream index in AVFormatContext
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int64_t start_time
start time in microseconds == AV_TIME_BASE units
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
all automatic conversions disabled
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
int configure_filtergraph(FilterGraph *fg)
memory buffer sink API for audio and video
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec, enum AVPixelFormat target)
char * name
name of this filter instance
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static AVFilter ** last_filter
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVFilterPad * output_pads
array of output pads
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
static int64_t start_time
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
AVStream ** streams
A list of all streams in the file.
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
char * resample_lavr_opts
libavresample options to use for the auto-inserted resample filters
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVDictionary * resample_opts
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
static int insert_filter(AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
AVFilterPad * input_pads
array of input pads
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define GET_CH_LAYOUT_NAME(ch_layout)
FilterGraph ** filtergraphs
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int capabilities
Codec capabilities.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
static const int sample_rates[]
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
uint64_t channel_layout
Audio channel layout.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVCodecContext * codec
Codec context associated with this stream.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
uint8_t nb_components
The number of components each pixel has, (1-4)
audio channel layout utility functions
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
struct OutputStream * ost
int width
picture width / height.
int audio_channels_mapped
#define GET_SAMPLE_FMT_NAME(sample_fmt)
AVFilterContext * filter_ctx
filter context associated to this input/output
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
A linked-list of the inputs/outputs of the filter chain.
enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
#define GET_SAMPLE_RATE_NAME(rate)
int frame_size
Number of samples per channel in an audio frame.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define AV_LOG_INFO
Standard information.
#define AV_BPRINT_SIZE_AUTOMATIC
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
enum AVMediaType codec_type
AVSampleFormat
Audio sample formats.
char * av_strdup(const char *s)
Duplicate the string s.
int sample_rate
samples per second
static char * choose_pix_fmts(OutputStream *ost)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
static int sub2video_prepare(InputStream *ist)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
static const AVFilterPad inputs[]
int pad_idx
index of the filt_ctx pad to use for linking
rational number numerator/denominator
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
float audio_drift_threshold
char * name
unique name for this input/output in the list
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
struct FilterGraph * graph
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
#define DESCRIBE_FILTER_LINK(f, inout, in)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
#define GROW_ARRAY(array, nb_elems)
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
int channels
number of audio channels
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
AVDictionary * encoder_opts
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static enum AVSampleFormat sample_fmts[]
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
OutputFile ** output_files
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void choose_sample_fmt(AVStream *st, AVCodec *codec)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVPixelFormat
Pixel format.
#define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
#define AV_NOPTS_VALUE
Undefined timestamp value.
InputStream ** input_streams
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2