[FFmpeg-devel] [PATCH] avformat: export probe score
Stefano Sabatini
stefasab at gmail.com
Wed Aug 28 21:43:06 CEST 2013
On date Tuesday 2013-08-27 23:43:48 +0200, Michael Niedermayer encoded:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> doc/formats.texi | 4 ++++
> libavformat/avformat.h | 18 ++++++++++++++++--
> libavformat/options_table.h | 1 +
> libavformat/utils.c | 18 ++++++++++++++----
> 4 files changed, 35 insertions(+), 6 deletions(-)
Reminder: missing micro minor bump.
> diff --git a/doc/formats.texi b/doc/formats.texi
> index e179755..21d4685 100644
> --- a/doc/formats.texi
> +++ b/doc/formats.texi
> @@ -137,6 +137,10 @@ non-monotonic negative timestamps.
> Flush the underlying I/O stream after each packet. Default 1 enables it, and
> has the effect of reducing the latency; 0 disables it and may slightly
> increase performance in some cases.
> +
> + at item probe_score @var{integer} (@emph{input})
> +This field is only accessable programatically, its value represents the score
typo: accessible
> +by which the format was detected.
> @end table
>
> @c man end FORMAT OPTIONS
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 77efc61..b414a0c 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1237,6 +1237,13 @@ typedef struct AVFormatContext {
> */
> int flush_packets;
>
> + /**
> + * format probing score
> + * - encoding: unused
> + * - decoding: set by avformat, read by user via AVOptions (NO direct access)
> + */
> + int probe_score;
Some indications about the range may be useful to developers. For the
same reason, a statement about when the field is set (after calling
function ...) would be useful.
> +
> /*****************************************************************
> * All fields below this line are not part of the public API. They
> * may not be used outside of libavformat and can be changed and
> @@ -1504,13 +1511,20 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score
> * @param logctx the log context
> * @param offset the offset within the bytestream to probe from
> * @param max_probe_size the maximum probe buffer size (zero for default)
> - * @return 0 in case of success, a negative value corresponding to an
> + * @return the score in case of success, a negative value corresponding to an
> + * the maximal score is AVPROBE_SCORE_MAX
> * AVERROR code otherwise
> */
> +int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
> + const char *filename, void *logctx,
> + unsigned int offset, unsigned int max_probe_size);
> +
> +/**
> + * Like av_probe_input_buffer2() but returns 0 on success
> + */
> int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
> const char *filename, void *logctx,
> unsigned int offset, unsigned int max_probe_size);
> -
> /**
> * Open an input stream and read the header. The codecs are not opened.
> * The stream must be closed with avformat_close_input().
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index a87868e..5392e22 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -76,6 +76,7 @@ static const AVOption avformat_options[] = {
> {"skip_initial_bytes", "skip initial bytes", OFFSET(skip_initial_bytes), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D},
> {"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
> {"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E},
> +{"probe_score", "score with which the format was probed", OFFSET(probe_score), AV_OPT_TYPE_INT, {.i64 = 0}, 0, AVPROBE_SCORE_MAX,},
nit: "read score ..."
[...]
I still got the feeling that a function returning the value may be
more proper since this is by no means an option, but I'm no
maintainer.
--
FFmpeg = Faithful & Foolish Martial Puristic ExchanGer
More information about the ffmpeg-devel
mailing list