History

avformat/cdg: add probe

Paul B Mahol committed 3 years ago

Commit 097653b1 parent eabc3041 file · +17 −0Browse files

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/cdg.c+17−0
@@ -26,6 +26,22 @@ · 25 unmodified lines
2626 #define CDG_COMMAND 0x09
2727 #define CDG_MASK 0x3F
2828
29+static int read_probe(const AVProbeData *p)
30+{
31+ const int cnt = p->buf_size / CDG_PACKET_SIZE;
32+ int score = 0;
33+
34+ for (int i = 0; i < cnt; i++) {
35+ const int x = p->buf[i * CDG_PACKET_SIZE] & CDG_MASK;
36+
37+ score += x == CDG_COMMAND;
38+ if (x != CDG_COMMAND && x != 0)
39+ return 0;
40+ }
41+
42+ return FFMIN(score, AVPROBE_SCORE_MAX);
43+}
44+
2945 static int read_header(AVFormatContext *s)
3046 {
3147 AVStream *vst;
@@ -70,6 +86,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 38 unmodified lines
7086 const AVInputFormat ff_cdg_demuxer = {
7187 .name = "cdg",
7288 .long_name = NULL_IF_CONFIG_SMALL("CD Graphics"),
89+ .read_probe = read_probe,
7390 .read_header = read_header,
7491 .read_packet = read_packet,
7592 .flags = AVFMT_GENERIC_INDEX,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t