[FFmpeg-cvslog] lavfi/mptestsrc: make use of AV_OPT_TYPE_VIDEO_RATE
Paul B Mahol
git at videolan.org
Tue Mar 26 14:29:53 CET 2013
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Mar 26 12:23:46 2013 +0000| [62d36abef4b7bf49856b0838bd87f7a23910a391] | committer: Paul B Mahol
lavfi/mptestsrc: make use of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62d36abef4b7bf49856b0838bd87f7a23910a391
---
libavfilter/vsrc_mptestsrc.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 05a1af6..856c3e4 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -53,18 +53,18 @@ enum test_type {
typedef struct MPTestContext {
const AVClass *class;
unsigned int frame_nb;
- AVRational time_base;
+ AVRational frame_rate;
int64_t pts, max_pts;
int hsub, vsub;
- char *size, *rate, *duration;
+ char *size, *duration;
enum test_type test;
} MPTestContext;
#define OFFSET(x) offsetof(MPTestContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
static const AVOption mptestsrc_options[]= {
- { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
- { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
+ { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
+ { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
@@ -259,7 +259,6 @@ static void ring2_test(uint8_t *dst, int dst_linesize, int off)
static av_cold int init(AVFilterContext *ctx, const char *args)
{
MPTestContext *test = ctx->priv;
- AVRational frame_rate_q;
int64_t duration = -1;
int ret;
@@ -269,26 +268,19 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0)
return ret;
- if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0) {
- av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate);
- return ret;
- }
-
if ((test->duration) && (ret = av_parse_time(&duration, test->duration, 1)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n", test->duration);
return ret;
}
- test->time_base.num = frame_rate_q.den;
- test->time_base.den = frame_rate_q.num;
test->max_pts = duration >= 0 ?
- av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1;
+ av_rescale_q(duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
test->frame_nb = 0;
test->pts = 0;
av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
- frame_rate_q.num, frame_rate_q.den,
- duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base));
+ test->frame_rate.num, test->frame_rate.den,
+ duration < 0 ? -1 : test->max_pts * av_q2d(av_inv_q(test->frame_rate)));
init_idct();
return 0;
@@ -305,7 +297,7 @@ static int config_props(AVFilterLink *outlink)
outlink->w = WIDTH;
outlink->h = HEIGHT;
- outlink->time_base = test->time_base;
+ outlink->time_base = av_inv_q(test->frame_rate);
return 0;
}
More information about the ffmpeg-cvslog
mailing list