[FFmpeg-devel] [PATCH 2/3] idet improvements: add reset_count feature
Michael Niedermayer
michaelni at gmx.at
Sun Nov 2 18:43:37 CET 2014
On Sun, Nov 02, 2014 at 05:03:44AM -0800, Kevin Mitchell wrote:
> Removed the unrelated documentation changes, used uint64_t instead of float.
> doc/filters.texi | 8 +++++
> libavfilter/version.h | 2 -
> libavfilter/vf_idet.c | 79 ++++++++++++++++++++++++++++++++++----------------
> libavfilter/vf_idet.h | 9 ++++-
> 4 files changed, 71 insertions(+), 27 deletions(-)
> d7f412c49b294b54535d4cfe48e54aa10f35ba08 0001-avfilter-vf_idet-add-a-half_life-option-for-statisti.patch
> From 0fc44ce601266e94fb8c6137091f3eb91616a235 Mon Sep 17 00:00:00 2001
> From: Kevin Mitchell <kevmitch at gmail.com>
> Date: Sun, 2 Nov 2014 04:37:13 -0800
> Subject: [PATCH 1/2] avfilter/vf_idet: add a "half_life" option for statistics
>
> This can be useful for videos in which the interlacing pattern changes.
>
> Also log the total number of frames as metadata and with avlog.
> ---
> doc/filters.texi | 8 ++++++
> libavfilter/version.h | 2 +-
> libavfilter/vf_idet.c | 79 +++++++++++++++++++++++++++++++++++----------------
> libavfilter/vf_idet.h | 9 ++++--
> 4 files changed, 71 insertions(+), 27 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 33f842b..03bd1c6 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -5583,6 +5583,9 @@ Multiple frame detection incorporates the classification history of previous fra
> The filter will log these metadata values:
>
> @table @option
> + at item frames_total
> +Total number of frames considered in current statistics.
> +
> @item single.current_frame
> Detected type of current frame using single-frame detection. One of:
> ``tff'' (top field first), ``bff'' (bottom field first),
> @@ -5625,6 +5628,11 @@ The filter accepts the following options:
> Set interlacing threshold.
> @item prog_thres
> Set progressive threshold.
> + at item half_life
> +Number of frames after which a given frame's contribution to the
> +statistics is halved (i.e., it contributes only 0.5 to it's
> +classification). The default of 0 means that all frames seen are given
> +full weight of 1.0 forever.
> @end table
>
> @section il
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index 440c587..dab9b45 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>
> #define LIBAVFILTER_VERSION_MAJOR 5
> #define LIBAVFILTER_VERSION_MINOR 2
> -#define LIBAVFILTER_VERSION_MICRO 101
> +#define LIBAVFILTER_VERSION_MICRO 102
>
> #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
> LIBAVFILTER_VERSION_MINOR, \
> diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
> index 6f99f39..4adadd4 100644
> --- a/libavfilter/vf_idet.c
> +++ b/libavfilter/vf_idet.c
> @@ -32,6 +32,7 @@
> static const AVOption idet_options[] = {
> { "intl_thres", "set interlacing threshold", OFFSET(interlace_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 1.04}, -1, FLT_MAX, FLAGS },
> { "prog_thres", "set progressive threshold", OFFSET(progressive_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 1.5}, -1, FLT_MAX, FLAGS },
> + { "half_life", "half life of cumulative statistics", OFFSET(half_life), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1, INT_MAX, FLAGS },
> { NULL }
> };
>
> @@ -48,6 +49,14 @@ static const char *type2str(Type type)
> return NULL;
> }
>
> +static int av_dict_set_float(AVDictionary **pm, const char *key, float value,
> + int flags)
> +{
> + char valuestr[22];
> + snprintf(valuestr, sizeof(valuestr), "%.1f", value);
> + return av_dict_set(pm, key, valuestr, flags);
> +}
i dont think "%f" is guranteed to produce the same value across
platforms, i think we had a issue in fate with win32 and a %f once
but maybe i misremember
something like
%d.%d", A/10, A%10
could be used
> +
> int ff_idet_filter_line_c(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
> {
> int x;
> @@ -74,6 +83,26 @@ int ff_idet_filter_line_c_16bit(const uint16_t *a, const uint16_t *b, const uint
> return ret;
> }
>
> +static void log_cumulative_stats(AVFilterContext *ctx)
> +{
> + IDETContext *idet = ctx->priv;
> +
> + av_log(ctx, AV_LOG_INFO, "Single frame detection: TFF:%6.1f BFF:%6.1f Progressive:%6.1f Undetermined:%6.1f Total: %6.1f\n",
> + idet->prestat[TFF] / PRECISION,
> + idet->prestat[BFF] / PRECISION,
> + idet->prestat[PROGRESSIVE] / PRECISION,
> + idet->prestat[UNDETERMINED] / PRECISION,
> + idet->total / PRECISION
> + );
> + av_log(ctx, AV_LOG_INFO, "Multi frame detection: TFF:%6.1f BFF:%6.1f Progressive:%6.1f Undetermined:%6.1f Total: %6.1f\n",
> + idet->poststat[TFF] / PRECISION,
> + idet->poststat[BFF] / PRECISION,
> + idet->poststat[PROGRESSIVE] / PRECISION,
> + idet->poststat[UNDETERMINED] / PRECISION,
> + idet->total / PRECISION
> + );
> +}
same issue
also its at least to me a bit unexpected that the filter
prints final statistics which only represent the last frames instead
of all
> +
> static void filter(AVFilterContext *ctx)
> {
> IDETContext *idet = ctx->priv;
> @@ -146,23 +175,31 @@ static void filter(AVFilterContext *ctx)
> idet->cur->interlaced_frame = 0;
> }
>
> - idet->prestat [ type] ++;
> - idet->poststat[idet->last_type] ++;
> + idet->total = (uint64_t) round(idet->total * idet->decay_coefficient);
> + for(i=0; i<4; i++){
> + idet->prestat [i] = (uint64_t) round(idet->prestat [i] * idet->decay_coefficient);
> + idet->poststat[i] = (uint64_t) round(idet->poststat[i] * idet->decay_coefficient);
> + }
i really think floats should not be used except for storing the user
provided parameters, which can be choosen to be exactly representable
for the case of a regression test
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141102/c194b5a7/attachment.asc>
More information about the ffmpeg-devel
mailing list