31 #define FF_BUFQUEUE_SIZE 256
55 #define OFFSET(x) offsetof(ConcatContext, x)
56 #define A AV_OPT_FLAG_AUDIO_PARAM
57 #define F AV_OPT_FLAG_FILTERING_PARAM
58 #define V AV_OPT_FLAG_VIDEO_PARAM
61 {
"n",
"specify the number of segments",
OFFSET(nb_segments),
63 {
"v",
"specify the number of video streams",
66 {
"a",
"specify the number of audio streams",
69 {
"unsafe",
"enable unsafe mode",
80 unsigned type, nb_str, idx0 = 0, idx, str, seg;
84 for (type = 0; type <
TYPE_ALL; type++) {
86 for (str = 0; str < nb_str; str++) {
126 unsigned in_no = out_no, seg;
131 outlink->
w = inlink->
w;
132 outlink->
h = inlink->
h;
140 if (outlink->
w != inlink->
w ||
141 outlink->
h != inlink->
h ||
146 "(size %dx%d, SAR %d:%d) do not match the corresponding "
147 "output link %s parameters (%dx%d, SAR %d:%d)\n",
168 struct concat_in *
in = &cat->
in[in_no];
179 else if (in->nb_frames >= 2)
181 in->pts =
av_rescale(in->pts, in->nb_frames, in->nb_frames - 1);
193 if (in_no < cat->cur_idx) {
232 cat->
in[in_no].
eof = 1;
245 pts = cat->
in[i++].
pts;
246 for (; i < imax; i++)
257 int64_t base_pts = cat->
in[in_no].
pts + cat->
delta_ts - seg_delta;
258 int64_t nb_samples, sent = 0;
259 int frame_nb_samples,
ret;
268 frame_nb_samples =
FFMAX(9600, rate_tb.
den / 5);
270 frame_nb_samples =
FFMIN(frame_nb_samples, nb_samples);
275 nb_channels, outlink->
format);
280 sent += frame_nb_samples;
281 nb_samples -= frame_nb_samples;
290 unsigned str, str_max;
303 for (; str < str_max; str++) {
312 for (str = cat->
cur_idx; str < str_max; str++) {
328 unsigned in_no = out_no + cat->
cur_idx;
329 unsigned str, str_max;
335 if (!cat->
in[in_no].
eof) {
345 str = str == str_max ? cat->
cur_idx : str + 1) {
346 if (cat->
in[str].
eof)
364 unsigned seg,
type, str;
368 for (type = 0; type <
TYPE_ALL; type++) {
382 for (type = 0; type <
TYPE_ALL; type++) {
static AVFrame * ff_bufqueue_get(struct FFBufQueue *queue)
Get the first buffer from the queue and remove it.
static AVFrame * get_audio_buffer(AVFilterLink *inlink, int nb_samples)
static int flush_segment(AVFilterContext *ctx)
static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no, int64_t seg_delta)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVFilterContext *ctx)
unsigned nb_streams[TYPE_ALL]
number of out streams of each type
static const AVFilterPad outputs[]
Main libavfilter public API header.
int h
agreed upon image height
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static int request_frame(AVFilterLink *outlink)
enum AVMediaType type
AVFilterPad type.
#define FF_OUTLINK_IDX(link)
static enum AVSampleFormat formats[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static AVRational av_make_q(int num, int den)
Create a rational.
struct AVFilterChannelLayouts * in_channel_layouts
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
Structure holding the queue.
static av_cold void uninit(AVFilterContext *ctx)
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVFilterPad * output_pads
array of output pads
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
AVFilterPad * input_pads
array of input pads
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
unsigned nb_outputs
number of output pads
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
int w
agreed upon image width
char * av_asprintf(const char *fmt,...)
AVFrame * queue[FF_BUFQUEUE_SIZE]
int64_t delta_ts
timestamp to add to produce output timestamps
audio channel layout utility functions
static int process_frame(AVFilterLink *inlink, AVFrame *buf)
unsigned nb_inputs
number of input pads
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static void close_input(AVFilterContext *ctx, unsigned in_no)
static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta)
static const AVClass concat_class
AVFilterContext * src
source filter
static void ff_bufqueue_discard_all(struct FFBufQueue *queue)
Unref and remove all buffers from the queue.
AVFilterFormats * out_samplerates
int format
agreed upon media format
A list of supported channel layouts.
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
unsigned short available
number of available buffers
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
unsigned cur_idx
index of the first input of current segment
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
rational number numerator/denominator
unsigned nb_in_active
number of active inputs in current segment
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
static int64_t pts
Global timestamp for the audio frames.
#define FF_INLINK_IDX(link)
Find the index of a link.
static int query_formats(AVFilterContext *ctx)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static int config_output(AVFilterLink *outlink)
AVFilterContext * dst
dest filter
struct ConcatContext::concat_in * in
AVFILTER_DEFINE_CLASS(concat)
static const AVOption concat_options[]
static void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFrame *buf)
Add a buffer to the queue.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
static int ff_insert_outpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new output pad for the filter.
int nb_samples
number of audio samples (per channel) described by this frame
AVFilterFormats * out_formats
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.