Skip to content

Some fixes to WAV reader - #918

Open
madah81pnz1 wants to merge 1 commit into
xiph:masterfrom
madah81pnz1:fix-wav-reader
Open

Some fixes to WAV reader#918
madah81pnz1 wants to merge 1 commit into
xiph:masterfrom
madah81pnz1:fix-wav-reader

Conversation

@madah81pnz1

Copy link
Copy Markdown
Contributor
  • Checks that bps is a multiple of 8, and >0 and <= 32.
  • Checks that valid-bps is not 0
  • Validates entire WAV GUID, not just the first part
  • bytes_per_wide_sample is calculated with a rounded up bps value
  • explicit check if bytes_per_wide_sample is 0

Fixes #873
Fixes #917

* Checks that bps is a multiple of 8, and >0 and <= 32.
* Checks that valid-bps is not 0
* Validates entire WAV GUID, not just the first part
* bytes_per_wide_sample is calculated with a rounded up bps value
* explicit check if bytes_per_wide_sample is 0

Fixes xiph#873
Fixes xiph#917
Comment thread src/flac/encode.c
data_bytes -= 40;
}

e->info.bytes_per_wide_sample = channels * (bps / 8);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main issue, if bps < 8 then bytes_per_wide_sample ends up 0

Comment thread src/flac/encode.c
}

/* truncation in the division removes any padding byte that was counted in encoder_session.fmt.iff.data_bytes */
total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crashes here if bytes_per_wide_sample is 0

Comment thread test/test_flac.sh
done
for f in bps-*.rf64 ; do
bps_test $f ".rf64"
# RF64 differs from WAV how it handles WAVE_FORMAT_EXTENSIBLE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bit suprising though. There is no way to force RF64 or WAVE64 and also force or disable WAVE_FORMAT_EXTENSIBLE at the same time (due to "ERROR: only one of force format options allowed"):

      --force-rf64-format            Decode to RF64 format
      --force-wave64-format          Decode to Wave64 format
      --force-legacy-wave-format     Decode to legacy wave format
      --force-extensible-wave-format Decode to extensible wave format

So what happens with --keep-foreign-metadata is that RF64/WAVE64 is not able to restore back the exact 'fmt ' chunk like WAV is able to do. (ERROR verifying foreign metadata restore from file.flac to file.rf64: restore of foreign metadata failed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant