diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-01-10 14:20:21 +0400 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-01-17 15:03:30 +0400 |
commit | a798c20a76196d76db27f7446ab90f8062f3c4eb (patch) | |
tree | f543171bcf0af5e0c72474b51a451a54be2f369a /libavfilter | |
parent | 9f7144b44cdecd27ca8c509e095d6a1ff51a7162 (diff) |
lavfi/testsrc: add "decimals" option to the testsrc filter
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/version.h | 2 | ||||
-rw-r--r-- | libavfilter/vsrc_testsrc.c | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/libavfilter/version.h b/libavfilter/version.h index 0eb5f7e70a..d2af525bb4 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 59 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 7336f980f7..0839a2b88e 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -47,6 +47,7 @@ typedef struct { char *rate; ///< video frame rate char *duration; ///< total duration of the generated video AVRational sar; ///< sample aspect ratio + int nb_decimals; void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref); @@ -64,6 +65,8 @@ static const AVOption testsrc_options[]= { { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, + { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, + { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, { NULL }, }; @@ -97,6 +100,12 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) return ret; } + if (test->nb_decimals && strcmp(ctx->filter->name, "testsrc")) { + av_log(ctx, AV_LOG_WARNING, + "Option 'decimals' is ignored with source '%s'\n", + ctx->filter->name); + } + test->time_base.num = frame_rate_q.den; test->time_base.den = frame_rate_q.num; test->max_pts = duration >= 0 ? @@ -361,7 +370,11 @@ static void test_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) /* draw digits */ seg_size = width / 80; if (seg_size >= 1 && height >= 13 * seg_size) { - second = test->nb_frame * test->time_base.num / test->time_base.den; + double time = av_q2d(test->time_base) * test->nb_frame * + pow(10, test->nb_decimals); + if (time > INT_MAX) + return; + second = (int)time; x = width - (width - seg_size * 64) / 2; y = (height - seg_size * 13) / 2; p = data + (x*3 + y * picref->linesize[0]); |