[FFmpeg-devel] [PATCH] avformat/tty: add probe function
Michael Niedermayer
michael at niedermayer.cc
Tue Jan 28 11:07:05 EET 2020
On Tue, Jan 28, 2020 at 08:17:11AM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavformat/tty.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/tty.c b/libavformat/tty.c
> index 8d48f2c45c..c127500fa1 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"
> @@ -34,6 +36,8 @@
> #include "internal.h"
> #include "sauce.h"
>
> +static const char *const tty_extensions = "ans,art,asc,diz,ice,nfo,txt,vt";
> +
> typedef struct TtyDemuxContext {
> AVClass *class;
> int chars_per_frame;
> @@ -42,6 +46,17 @@ typedef struct TtyDemuxContext {
> AVRational framerate; /**< Set by a private option. */
> } TtyDemuxContext;
>
> +static int read_probe(const AVProbeData *p)
> +{
> + int cnt = 0;
> +
> + for (int i = 0; i < p->buf_size; i++)
> + cnt += !!isprint(p->buf[i]);
> +
> + return (cnt * 100LL / p->buf_size) * (cnt > 400) *
> + !!av_match_ext(p->filename, tty_extensions);
> +}
> +
> /**
> * Parse EFI header
> */
> @@ -153,8 +168,9 @@ 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",
> + .extensions = tty_extensions,
src/libavformat/tty.c:174:23: error: initializer element is not constant
.extensions = tty_extensions,
^~~~~~~~~~~~~~
src/libavformat/tty.c:174:23: note: (near initialization for ‘ff_tty_demuxer.extensions’)
src/ffbuild/common.mak:59: recipe for target 'libavformat/tty.o' failed
make: *** [libavformat/tty.o] Error 1
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200128/a93ac71b/attachment.sig>
More information about the ffmpeg-devel
mailing list