feat(convert): support same-format lossless re-encoding

This commit is contained in:
zarzet
2026-07-15 22:03:32 +07:00
parent 6f121c7543
commit 82ba586b72
3 changed files with 64 additions and 26 deletions
+7 -2
View File
@@ -128,8 +128,13 @@ bool canConvertAudioFormat({
required String sourceFormat,
required String targetFormat,
}) {
if (sourceFormat.trim().toUpperCase() == targetFormat.trim().toUpperCase()) {
return false;
final normalizedSource = sourceFormat.trim().toUpperCase();
final normalizedTarget = targetFormat.trim().toUpperCase();
if (normalizedSource == normalizedTarget) {
// Same-format lossless re-encoding is useful for reducing bit depth or
// sample rate while selecting the dither and resampler implementation.
return isLosslessConversionSource(normalizedSource) &&
isLosslessConversionTarget(normalizedTarget);
}
if (isLosslessConversionTarget(targetFormat) &&
!isLosslessConversionSource(sourceFormat)) {