On 1/27/2020 7:16 PM, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol <one...@gmail.com> > --- > libavformat/tty.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/libavformat/tty.c b/libavformat/tty.c > index 8d48f2c45c..75af16a6f1 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,17 @@ 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 += !!isprint(p->buf[i]);
cnt here will never be > p->buf_size, so just make it an int and cast it to int64_t in the line below. Otherwise the above loop will be slower than necessary on 32 bit arches. > + > + return (cnt * 100 / p->buf_size) * (cnt > 500) * > + !!av_match_ext(p->filename, "ans,art,asc,diz,ice,nfo,txt,vt"); > +} > + > /** > * Parse EFI header > */ > @@ -153,6 +166,7 @@ AVInputFormat ff_tty_demuxer = { > .name = "tty", > .long_name = NULL_IF_CONFIG_SMALL("Tele-typewriter"), > .priv_data_size = sizeof(TtyDemuxContext), > + .read_probe = read_probe, > .read_header = read_header, > .read_packet = read_packet, > .extensions = "ans,art,asc,diz,ice,nfo,txt,vt", > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".