Conversation
|
Hello! One or more of the commit messages in this PR do not match the Ladybird code submission policy, please check the |
Previously, the pcm_format() method always returned Float32 regardless of the actual audio format. This commit implements proper format detection by mapping FFmpeg's sample format to our PcmSampleFormat enum. The implementation supports the formats that extract_samples_from_frame() already handles (U8, S16, S32, Float32) and falls back to Float32 for any unsupported formats, maintaining backward compatibility.
This adds comprehensive tests for the FFmpegLoader pcm_format() method to verify that it correctly reports the audio format for different file types. Test coverage includes: - Vorbis OGG files (Float32 format) - WAV files (validates format is one of the supported types) - Basic functionality test for loading and decoding samples The tests follow the existing pattern established by TestWav.cpp and integrate with the existing test infrastructure.
74e5c4d to
323c011
Compare
|
|
||
| PcmSampleFormat FFmpegLoaderPlugin::pcm_format() | ||
| { | ||
| // FIXME: pcm_format() is unused, always return Float for now |
There was a problem hiding this comment.
You remove this FIXME that hints at this method not being used. What did you do to fix it?
|
I found that the PlaybackStream implementations are hardcoding
This PR implements the format detection in FFmpegLoader, but doesn't update those other files yet. Should I expand this PR to update them as well? |
|
FYI, the audio loader system is likely to be removed, it'll be unused after #6410 is merged. It's still present in that PR simply because WAV support isn't there yet, since it requires passing around channel maps, but once that's working, I won't waste any time in deleting the audio loader system.
I want to say that we probably won't have a reason to use any other format in the PlaybackStream implementations, actually, following the PR mentioned above. We have to mix multiple tracks into one output, so currently the AudioDecoder interface just outputs audio blocks in f32 before they reach the mixer, which will then mix the audio into the PlaybackStream. |
|
Thanks for the feedback, Gregory! Given that the audio loader system will be deprecated after #6410 and the new architecture will standardize on f32, this PR won't provide long-term value. I'll close this PR. Thanks for explaining the architectural direction! |
Summary
This PR implements proper PCM format detection in
FFmpegLoader::pcm_format(), which previously always returnedFloat32regardless of the actual audio format.Changes:
AVSampleFormat) to ourPcmSampleFormatenumextract_samples_from_frame()already handles: U8, S16, S32, Float32Why This Matters
The
pcm_format()method was marked with a FIXME comment indicating it was unused and always returned Float32. This implementation:Technical Details
The implementation uses FFmpeg's
av_get_packed_sample_fmt()to normalize planar and interleaved formats, then maps the packed format to our enum:AV_SAMPLE_FMT_U8→PcmSampleFormat::Uint8AV_SAMPLE_FMT_S16→PcmSampleFormat::Int16AV_SAMPLE_FMT_S32→PcmSampleFormat::Int32AV_SAMPLE_FMT_FLT→PcmSampleFormat::Float32For formats not currently handled by
extract_samples_from_frame(), we fall back to Float32 since that's what everything gets converted to anyway.Test Plan
Automated Tests:
Created Tests/LibMedia/TestFFmpegLoader.cpp with 3 test cases:
Test Execution:
Expected Results:
Files Changed