Am Fr., 27. März 2020 um 15:25 Uhr schrieb Zane van Iperen
<z...@zanevaniperen.com>:
>
> On Wed, 18 Mar 2020 15:19:19 +0100
> "Carl Eugen Hoyos" <ceffm...@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;

Apart from what I wrote on irc:
What surprises me most is that iirc, you explained that the sample_rate
is written repeatedly to the file and is always identical in one file. Why
is that not checked?

You seem to have a fine (and small) collection of sample rates to check against.

Carl Eugen
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to