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