From: Paul B Mahol <onemda@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avformat/cdg: add probe Date: Tue, 14 Feb 2023 22:27:02 +0100 Message-ID: <CAPYw7P6sTVjUNVey7qvNeoNT51e-mbX0WK3=2YJB2_1xvgmBFw@mail.gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 16 bytes --] Patch attached. [-- Attachment #2: 0001-avformat-cdg-add-probe.patch --] [-- Type: text/x-patch, Size: 1358 bytes --] From b0cd65c70465da729d950dfff1c20129e81462fc Mon Sep 17 00:00:00 2001 From: Paul B Mahol <onemda@gmail.com> Date: Tue, 14 Feb 2023 22:25:42 +0100 Subject: [PATCH] avformat/cdg: add probe Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavformat/cdg.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavformat/cdg.c b/libavformat/cdg.c index 36f25e7f66..f598285911 100644 --- a/libavformat/cdg.c +++ b/libavformat/cdg.c @@ -26,6 +26,22 @@ #define CDG_COMMAND 0x09 #define CDG_MASK 0x3F +static int read_probe(const AVProbeData *p) +{ + const int cnt = p->buf_size / CDG_PACKET_SIZE; + int score = 0; + + for (int i = 0; i < cnt; i++) { + const int x = p->buf[i * CDG_PACKET_SIZE] & CDG_MASK; + + score += x == CDG_COMMAND; + if (x != CDG_COMMAND && x != 0) + return 0; + } + + return FFMIN(score, AVPROBE_SCORE_MAX); +} + static int read_header(AVFormatContext *s) { AVStream *vst; @@ -70,6 +86,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) const AVInputFormat ff_cdg_demuxer = { .name = "cdg", .long_name = NULL_IF_CONFIG_SMALL("CD Graphics"), + .read_probe = read_probe, .read_header = read_header, .read_packet = read_packet, .flags = AVFMT_GENERIC_INDEX, -- 2.39.1 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-02-14 21:27 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-14 21:27 Paul B Mahol [this message] 2023-02-16 12:08 ` Tomas Härdin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAPYw7P6sTVjUNVey7qvNeoNT51e-mbX0WK3=2YJB2_1xvgmBFw@mail.gmail.com' \ --to=onemda@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git