History

avformat/cdg: add probe

Paul B Mahol committed 3 years ago

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

Unified · Split

libavformat/cdg.c+17−0
@@ -26,6 +26,22 @@ · 25 unmodified lines
26#define CDG_COMMAND 0x0926#define CDG_COMMAND 0x09
27#define CDG_MASK 0x3F27#define CDG_MASK 0x3F
28 28
29static 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
29static int read_header(AVFormatContext *s)45static int read_header(AVFormatContext *s)
30{46{
31 AVStream *vst;47 AVStream *vst;
@@ -70,6 +86,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 38 unmodified lines
70const AVInputFormat ff_cdg_demuxer = {86const AVInputFormat ff_cdg_demuxer = {
71 .name = "cdg",87 .name = "cdg",
72 .long_name = NULL_IF_CONFIG_SMALL("CD Graphics"),88 .long_name = NULL_IF_CONFIG_SMALL("CD Graphics"),
89 .read_probe = read_probe,
73 .read_header = read_header,90 .read_header = read_header,
74 .read_packet = read_packet,91 .read_packet = read_packet,
75 .flags = AVFMT_GENERIC_INDEX,92 .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