[FFmpeg-devel] [PATCH v2 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks
Zane van Iperen
zane at zanevaniperen.com
Fri Mar 27 16:25:02 EET 2020
On Wed, 18 Mar 2020 15:19:19 +0100
"Carl Eugen Hoyos" <ceffmpeg at gmail.com> wrote:
>
> Any restrictions on track_count and sample_rate that can be used for
> auto-detection?
>
I've done a preliminary probe function. How's this?
On all the files I tested, I received one of two values:
99 - For music (these have an extra condition I can test for)
87 - For everything else
static int pp_bnk_probe(const AVProbeData *p)
{
PPBnkHeader hdr;
uint32_t expected_sample_rate;
int score;
pp_bnk_parse_header(&hdr, p->buf);
if (hdr.track_count == 0 || hdr.sample_rate == 0)
return 0;
score = 0;
/* These limits are based on analysing the game files. */
if (hdr.track_count <= 113)
score += AVPROBE_SCORE_MAX / 4;
if (hdr.sample_rate <= 44100)
score += AVPROBE_SCORE_MAX / 4;
if ((hdr.flags & ~PP_BNK_FLAG_MASK) == 0)
score += AVPROBE_SCORE_MAX / 4;
if ((hdr.flags & PP_BNK_FLAG_MUSIC) && hdr.track_count == 2)
score += AVPROBE_SCORE_MAX / 8;
/* Also check based on file extension, if we have it. */
if (av_match_ext(p->filename, "5c"))
expected_sample_rate = 5512;
else if (av_match_ext(p->filename, "11c"))
expected_sample_rate = 11025;
else if (av_match_ext(p->filename, "22c"))
expected_sample_rate = 22050;
else if (av_match_ext(p->filename, "44c"))
expected_sample_rate = 44100;
else
expected_sample_rate = 0;
if (expected_sample_rate && hdr.sample_rate == expected_sample_rate)
score += AVPROBE_SCORE_MAX / 8;
return score;
}
Zane
More information about the ffmpeg-devel
mailing list