[FFmpeg-devel] [PATCH] avformat/tty: add probe function

Carl Eugen Hoyos ceffmpeg at gmail.com
Tue Jan 28 00:03:34 EET 2020


Am Mo., 27. Jan. 2020 um 22:56 Uhr schrieb Paul B Mahol <onemda at gmail.com>:
>
> On 1/27/20, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> > Am Mo., 27. Jan. 2020 um 22:44 Uhr schrieb Paul B Mahol <onemda at gmail.com>:
> >>
> >> On 1/27/20, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> >> > Am Mo., 27. Jan. 2020 um 22:01 Uhr schrieb Paul B Mahol
> >> > <onemda at gmail.com>:
> >> >>
> >> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> >> ---
> >> >>  libavformat/tty.c | 13 +++++++++++++
> >> >>  1 file changed, 13 insertions(+)
> >> >>
> >> >> diff --git a/libavformat/tty.c b/libavformat/tty.c
> >> >> index 8d48f2c45c..acc6da27cc 100644
> >> >> --- a/libavformat/tty.c
> >> >> +++ b/libavformat/tty.c
> >> >> @@ -24,6 +24,8 @@
> >> >>   * Tele-typewriter demuxer
> >> >>   */
> >> >>
> >> >> +#include <ctype.h>
> >> >> +
> >> >>  #include "libavutil/intreadwrite.h"
> >> >>  #include "libavutil/avstring.h"
> >> >>  #include "libavutil/log.h"
> >> >> @@ -42,6 +44,16 @@ typedef struct TtyDemuxContext {
> >> >>      AVRational framerate; /**< Set by a private option. */
> >> >>  } TtyDemuxContext;
> >> >>
> >> >> +static int read_probe(const AVProbeData *p)
> >> >> +{
> >> >> +    int64_t cnt = 0;
> >> >> +
> >> >> +    for (int i = 0; i < p->buf_size; i++)
> >> >> +        cnt += !!isalnum(p->buf[i]);
> >> >> +
> >> >> +    return cnt * 100 / p->buf_size;
> >> >
> >> > The function looks as if it could return scores
> >> > higher than SCORE_MAX and as if it would
> >> > return high scores for very small probe size.
> >> > Both are not good, normally we test for both
> >> > a minimum number of counts and a high
> >> > percentage of correct values.
> >>
> >> Why are you propagandizing untrue statements here?
> >
> > Well, it is true that the function looked to me as if
> > it could return scores > 100 (which it does not).
> >
> >> Score returned by this probe can not be bigger than 100 and less than 0.
> >
> > It can return 100 for very small probe size which is not good.
>
> No it can not, check your math skills again.

To elaborate:
It can return 100 for a probe size of 32 which I think is not ideal.

Carl Eugen


More information about the ffmpeg-devel mailing list