diff options
author | Michael Niedermayer <[email protected]> | 2013-03-20 21:41:22 +0100 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2013-03-20 21:41:26 +0100 |
commit | 426ebdf923f9826e456bb734299fa2d2b6199524 (patch) | |
tree | f30fd4ac99579f87dec2bb4df06e30cbb0ee8859 /libavfilter/avf_concat.c | |
parent | b853103fe0e59edc8970462abc6c181610ad9216 (diff) | |
parent | 2753d4ebf067593070ca4e9b3ea1dbe6ace23ba3 (diff) |
Merge remote-tracking branch 'cigaes/master'
* cigaes/master:
lavfi/vf_yadif: use standard options parsing.
lavfi/vf_unsharp: use standard options parsing.
lavfi/vf_transpose: use standard options parsing.
lavfi/vf_pad: use standard options parsing.
lavfi/vf_fps: use standard options parsing.
lavfi/vf_fade: use standard options parsing.
lavi/vf_drawbox: use standard options parsing.
lavfi/vf_delogo: use standard options parsing.
lavfi/vf_decimate: use standard options parsing.
lavfi/vf_crop: use standard options parsing.
lavfi/af_volume: use standard options parsing.
lavfi/vf_tile: use standard options parsing.
lavfi/avf_concat: use standard options parsing.
lavfi: add common code to handle options parsing.
lavf/vobsub: free index pseudo-packet.
ffmpeg: fix freeing of sub2video frame.
lavfi: add sine audio source.
lavu/opt: add AV_OPT_TYPE_DURATION.
lavfi/concat: fix silence duration computation.
lavf/concatdec: support seeking.
Merged-by: Michael Niedermayer <[email protected]>
Diffstat (limited to 'libavfilter/avf_concat.c')
-rw-r--r-- | libavfilter/avf_concat.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index 7b5d5913d3..2b3640b1b0 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -232,7 +232,7 @@ static void close_input(AVFilterContext *ctx, unsigned in_no) ctx->input_pads[in_no].name, cat->nb_in_active); } -static void find_next_delta_ts(AVFilterContext *ctx) +static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta) { ConcatContext *cat = ctx->priv; unsigned i = cat->cur_idx; @@ -243,13 +243,15 @@ static void find_next_delta_ts(AVFilterContext *ctx) for (; i < imax; i++) pts = FFMAX(pts, cat->in[i].pts); cat->delta_ts += pts; + *seg_delta = pts; } -static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no) +static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no, + int64_t seg_delta) { ConcatContext *cat = ctx->priv; AVFilterLink *outlink = ctx->outputs[out_no]; - int64_t base_pts = cat->in[in_no].pts + cat->delta_ts; + int64_t base_pts = cat->in[in_no].pts + cat->delta_ts - seg_delta; int64_t nb_samples, sent = 0; int frame_nb_samples, ret; AVRational rate_tb = { 1, ctx->inputs[in_no]->sample_rate }; @@ -258,7 +260,7 @@ static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no) if (!rate_tb.den) return AVERROR_BUG; - nb_samples = av_rescale_q(cat->delta_ts - base_pts, + nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts, outlink->time_base, rate_tb); frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */ while (nb_samples) { @@ -283,8 +285,9 @@ static int flush_segment(AVFilterContext *ctx) int ret; ConcatContext *cat = ctx->priv; unsigned str, str_max; + int64_t seg_delta; - find_next_delta_ts(ctx); + find_next_delta_ts(ctx, &seg_delta); cat->cur_idx += ctx->nb_outputs; cat->nb_in_active = ctx->nb_outputs; av_log(ctx, AV_LOG_VERBOSE, "Segment finished at pts=%"PRId64"\n", @@ -295,7 +298,8 @@ static int flush_segment(AVFilterContext *ctx) str = cat->nb_streams[AVMEDIA_TYPE_VIDEO]; str_max = str + cat->nb_streams[AVMEDIA_TYPE_AUDIO]; for (; str < str_max; str++) { - ret = send_silence(ctx, cat->cur_idx - ctx->nb_outputs + str, str); + ret = send_silence(ctx, cat->cur_idx - ctx->nb_outputs + str, str, + seg_delta); if (ret < 0) return ret; } @@ -354,17 +358,8 @@ static int request_frame(AVFilterLink *outlink) static av_cold int init(AVFilterContext *ctx, const char *args) { ConcatContext *cat = ctx->priv; - int ret; unsigned seg, type, str; - cat->class = &concat_class; - av_opt_set_defaults(cat); - ret = av_set_options_string(cat, args, "=", ":"); - if (ret < 0) { - av_log(ctx, AV_LOG_ERROR, "Error parsing options: '%s'\n", args); - return ret; - } - /* create input pads */ for (seg = 0; seg < cat->nb_segments; seg++) { for (type = 0; type < TYPE_ALL; type++) { @@ -414,6 +409,8 @@ static av_cold void uninit(AVFilterContext *ctx) av_free(cat->in); } +static const char *const shorthand[] = { NULL }; + AVFilter avfilter_avf_concat = { .name = "concat", .description = NULL_IF_CONFIG_SMALL("Concatenate audio and video streams."), @@ -424,4 +421,5 @@ AVFilter avfilter_avf_concat = { .inputs = NULL, .outputs = NULL, .priv_class = &concat_class, + .shorthand = shorthand, }; |