[FFmpeg-devel] [PATCH 1/5] Set timebase in the ffplay input and output filters.
Stefano Sabatini
stefano.sabatini-lala
Mon Oct 11 12:19:35 CEST 2010
---
ffplay.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index 9927006..0d025f5 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1778,8 +1778,29 @@ static AVFilter input_filter =
{ .name = NULL }},
};
-static void output_end_frame(AVFilterLink *link)
+static int output_init(AVFilterContext *ctx, const char *args, void *opaque)
{
+ FilterPriv *priv = ctx->priv;
+ if (!opaque) return AVERROR(EINVAL);
+
+ priv->is = opaque;
+ return 0;
+}
+
+static void output_end_frame(AVFilterLink *inlink)
+{
+ AVFilterContext *ctx = inlink->dst;
+ FilterPriv *priv = ctx->priv;
+ AVRational dst_time_base = priv->is->video_st->time_base;
+
+ if (av_cmp_q(inlink->time_base, dst_time_base)) {
+ int64_t pts1 = inlink->cur_buf->pts;
+ inlink->cur_buf->pts = av_rescale_q(pts1, inlink->time_base, dst_time_base);
+ av_log(ctx, AV_LOG_DEBUG,
+ "Converting PTS tb1:%d/%d pts1:%"PRId64" -> tb2:%d/%d pts2:%"PRId64"\n",
+ inlink->time_base.num, inlink->time_base.den, pts1,
+ dst_time_base.num, dst_time_base.den, inlink->cur_buf->pts);
+ }
}
static int output_query_formats(AVFilterContext *ctx)
@@ -1814,7 +1835,9 @@ static int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
static AVFilter output_filter =
{
.name = "ffplay_output",
+ .priv_size = sizeof(FilterPriv),
+ .init = output_init,
.query_formats = output_query_formats,
.inputs = (AVFilterPad[]) {{ .name = "default",
@@ -1846,7 +1869,7 @@ static int video_thread(void *arg)
if (avfilter_open(&filt_out, &output_filter, "out") < 0) goto the_end;
if(avfilter_init_filter(filt_src, NULL, is)) goto the_end;
- if(avfilter_init_filter(filt_out, NULL, frame)) goto the_end;
+ if(avfilter_init_filter(filt_out, NULL, is)) goto the_end;
if(vfilters) {
--
1.7.1
More information about the ffmpeg-devel
mailing list