lavfi/mptestsrc: use AV_OPT_TYPE_DURATION
Simplify.
This commit is contained in:
parent
bbf003e949
commit
db84088e99
@ -54,9 +54,9 @@ typedef struct MPTestContext {
|
|||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
unsigned int frame_nb;
|
unsigned int frame_nb;
|
||||||
AVRational frame_rate;
|
AVRational frame_rate;
|
||||||
int64_t pts, max_pts;
|
int64_t pts, max_pts, duration;
|
||||||
int hsub, vsub;
|
int hsub, vsub;
|
||||||
char *size, *duration;
|
char *size;
|
||||||
enum test_type test;
|
enum test_type test;
|
||||||
} MPTestContext;
|
} MPTestContext;
|
||||||
|
|
||||||
@ -65,8 +65,8 @@ typedef struct MPTestContext {
|
|||||||
static const AVOption mptestsrc_options[]= {
|
static const AVOption mptestsrc_options[]= {
|
||||||
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.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 },
|
{ "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 },
|
{ "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_STRING, {.str = NULL}, 0, 0, FLAGS },z
|
{ "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" },
|
{ "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" },
|
{ "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)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
MPTestContext *test = ctx->priv;
|
MPTestContext *test = ctx->priv;
|
||||||
int64_t duration = -1;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if ((test->duration) && (ret = av_parse_time(&duration, test->duration, 1)) < 0) {
|
test->max_pts = test->duration >= 0 ?
|
||||||
av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n", test->duration);
|
av_rescale_q(test->duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
test->max_pts = duration >= 0 ?
|
|
||||||
av_rescale_q(duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
|
|
||||||
test->frame_nb = 0;
|
test->frame_nb = 0;
|
||||||
test->pts = 0;
|
test->pts = 0;
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
|
av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
|
||||||
test->frame_rate.num, test->frame_rate.den,
|
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();
|
init_idct();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user