[FFmpeg-cvslog] lavfi/mptestsrc: use AV_OPT_TYPE_DURATION
Stefano Sabatini
git at videolan.org
Wed Apr 17 23:07:25 CEST 2013
ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Wed Apr 17 22:00:40 2013 +0200| [db84088e99f5305b6f887383be1ed01844074274] | committer: Stefano Sabatini
lavfi/mptestsrc: use AV_OPT_TYPE_DURATION
Simplify.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db84088e99f5305b6f887383be1ed01844074274
---
libavfilter/vsrc_mptestsrc.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 4386de8..a670da6 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;
More information about the ffmpeg-cvslog
mailing list