rather large commit, it now handles memory and threading properly.

---

more thorough commit message which was generated by the wonderful copilot AI tool:

Refactor and enhance audio encoding and decoding pipelines

- Introduced CodecUtils.h for utility functions related to audio codec selection, including sample format and bitrate clamping.
- Added DecoderPipeline.h to manage audio decoding, including opening files and retrieving audio stream information.
- Implemented EncoderPipeline.h to handle audio encoding, including encoder setup, resampling, and writing output files.
- Created OutputPathBuilder.h to generate output file paths based on reencode job specifications.
- Refactored SpectrogramWidget to improve OpenGL handling and ensure safe context usage.
- Updated ReencodeDialog.h to enhance code readability and maintainability.
- Improved error handling and logging throughout the audio processing components.
This commit is contained in:
2026-07-01 09:56:37 +02:00
parent 51421ffc2b
commit 1a00e98661
19 changed files with 984 additions and 1084 deletions
+11 -1
View File
@@ -6,15 +6,24 @@ extern "C" {
namespace engine {
/**
* @brief Selection Priority:
* 1. Exact match with sourceRate
* 2. Lowest supported rate that is >= sourceRate (upsample as little as possible)
* 3. Highest supported rate overall
* rates are below sourceRate, eg a low rate phone codec at 8khz
*/
inline int pickSampleRate(const AVCodec *encoder, int sourceRate)
{
if (!encoder->supported_samplerates)
return sourceRate;
// 1: exact match
for (const int *r = encoder->supported_samplerates; *r != 0; ++r)
if (*r == sourceRate)
return sourceRate;
// 2: lowest rate >= sourceRate (minimal upsampling)
int best = 0;
for (const int *r = encoder->supported_samplerates; *r != 0; ++r) {
if (*r >= sourceRate) {
@@ -25,6 +34,7 @@ inline int pickSampleRate(const AVCodec *encoder, int sourceRate)
if (best != 0)
return best;
// 3: all supported rates are below sourceRate
for (const int *r = encoder->supported_samplerates; *r != 0; ++r)
if (*r > best)
best = *r;
@@ -32,4 +42,4 @@ inline int pickSampleRate(const AVCodec *encoder, int sourceRate)
return best;
}
} // namespace engine
} // namespace engine