]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/sf_float into pu pu
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 19 Apr 2024 18:45:36 +0000 (20:45 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 19 Apr 2024 18:45:36 +0000 (20:45 +0200)
A single patch which adds two new sample formats for 32 bit IEEE
float waveform data.

<!--

- The alsa writer also supports 32 bit float sample formats.

-->

* refs/heads/t/sf_float:
  New audio formats: 32 bit float (little and big endian).

1  2 
check_wav.c

diff --combined check_wav.c
index cb39eb540dafae31733623625bf31474c463a243,821483274aba25f5f74473d2151a205c8dafee55..48a204bb598c1f9ebc873b10d64704eb256cc2de
@@@ -54,7 -54,7 +54,7 @@@ void check_wav_pre_monitor(struct sche
                sched_min_delay(s);
  }
  
 -static int check_wav_exec(struct btr_node *btrn, const char *cmd, char **result)
 +static int check_wav_exec(const struct btr_node *btrn, const char *cmd, char **result)
  {
        struct check_wav_context *cwc = btr_context(btrn);
        int val, header_val, given, arg;
@@@ -127,7 -127,7 +127,7 @@@ int check_wav_post_monitor(struct check
        unsigned char *a;
        size_t sz;
        int ret;
-       uint16_t bps; /* bits per sample */
+       uint16_t format_code, bps; /* bits per sample */
        const char *sample_formats[] = {SAMPLE_FORMATS};
  
        if (!btrn)
        cwc->state = CWS_HAVE_HEADER;
        /* Only set those values which have not already been set. */
        cwc->channels = a[22];
+       format_code = read_u16(a + 20);
+       if (format_code != 1 && format_code != 3) {
+               cwc->state = CWS_NO_HEADER;
+               goto out;
+       }
        cwc->sample_rate = read_u32(a + 24);
        bps = read_u16(a + 34);
-       if (bps != 8 && bps != 16) {
+       if (bps != 8 && bps != 16 && bps != 32) {
                PARA_WARNING_LOG("%u bps not supported, assuming 16\n",
                        bps);
                bps = 16;
        }
+       if ((bps < 32 && format_code != 1) || (bps == 32 && format_code != 3)) {
+               PARA_WARNING_LOG("invalid bps/format_code (%u/%u)\n",
+                       bps, format_code);
+               cwc->state = CWS_NO_HEADER;
+               goto out;
+       }
        /*
         * 8-bit samples are stored as unsigned bytes, ranging from 0
         * to 255.  16-bit samples are stored as 2's-complement signed
         */
        if (bps == 8)
                cwc->sample_format = SF_U8;
-       else
+       else if (bps == 16)
                cwc->sample_format = (a[3] == 'F')?
                        SF_S16_LE : SF_S16_BE;
+       else /* 32 bit */
+               cwc->sample_format = (a[3] == 'F')?
+                       SF_FLOAT_LE : SF_FLOAT_BE;
        PARA_NOTICE_LOG("%uHz, %s, %s\n", cwc->sample_rate,
                cwc->channels == 1? "mono" : "stereo",
                sample_formats[cwc->sample_format]);