summaryrefslogtreecommitdiff
path: root/libavfilter/vsrc_mptestsrc.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-04-17 22:00:40 +0200
committerStefano Sabatini <stefasab@gmail.com>2013-04-17 22:40:02 +0200
commitdb84088e99f5305b6f887383be1ed01844074274 (patch)
tree21f663d9f01ab39783a921475a56e2aa2f5b564a /libavfilter/vsrc_mptestsrc.c
parentbbf003e949700e444216bfeb38aed8362c496108 (diff)
lavfi/mptestsrc: use AV_OPT_TYPE_DURATION
Simplify.
Diffstat (limited to 'libavfilter/vsrc_mptestsrc.c')
-rw-r--r--libavfilter/vsrc_mptestsrc.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 4386de841d..a670da617d 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -54,9 +54,9 @@ typedef struct MPTestContext {
const AVClass *class;
unsigned int frame_nb;
AVRational frame_rate;
- int64_t pts, max_pts;
+ int64_t pts, max_pts, duration;
int hsub, vsub;
- char *size, *duration;
+ char *size;
enum test_type test;
} MPTestContext;
@@ -65,8 +65,8 @@ typedef struct MPTestContext {
static const AVOption mptestsrc_options[]= {
{ "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 },z
+ { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
+ { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
{ "test", "set test to perform", OFFSET(test), AV_OPT_TYPE_INT, {.i64=TEST_ALL}, 0, INT_MAX, FLAGS, "test" },
{ "t", "set test to perform", OFFSET(test), AV_OPT_TYPE_INT, {.i64=TEST_ALL}, 0, INT_MAX, FLAGS, "test" },
@@ -258,22 +258,15 @@ static void ring2_test(uint8_t *dst, int dst_linesize, int off)
static av_cold int init(AVFilterContext *ctx)
{
MPTestContext *test = ctx->priv;
- int64_t duration = -1;
- int 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->max_pts = duration >= 0 ?
- av_rescale_q(duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
+ test->max_pts = test->duration >= 0 ?
+ av_rescale_q(test->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",
test->frame_rate.num, test->frame_rate.den,
- duration < 0 ? -1 : test->max_pts * av_q2d(av_inv_q(test->frame_rate)));
+ test->duration < 0 ? -1 : test->max_pts * av_q2d(av_inv_q(test->frame_rate)));
init_idct();
return 0;