LibAudio: Expand FLAC loader debug messages

These are now indented to aid readability.
This commit is contained in:
kleines Filmröllchen 2023-07-05 00:05:56 +02:00 committed by Andrew Kaster
parent 60f1472902
commit 252b1328ea
Notes: sideshowbarker 2024-07-17 05:23:40 +09:00

View File

@ -695,7 +695,7 @@ ErrorOr<void, LoaderError> FlacLoaderPlugin::parse_subframe(Vector<i64>& samples
case FlacSubframeType::Constant: { case FlacSubframeType::Constant: {
// 11.26. SUBFRAME_CONSTANT // 11.26. SUBFRAME_CONSTANT
u64 constant_value = TRY(bit_input.read_bits<u64>(subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample)); u64 constant_value = TRY(bit_input.read_bits<u64>(subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample));
dbgln_if(AFLACLOADER_DEBUG, "Constant subframe: {}", constant_value); dbgln_if(AFLACLOADER_DEBUG, " Constant subframe: {}", constant_value);
VERIFY(subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample != 0); VERIFY(subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample != 0);
i64 constant = sign_extend(static_cast<u64>(constant_value), subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample); i64 constant = sign_extend(static_cast<u64>(constant_value), subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample);
@ -705,17 +705,17 @@ ErrorOr<void, LoaderError> FlacLoaderPlugin::parse_subframe(Vector<i64>& samples
break; break;
} }
case FlacSubframeType::Fixed: { case FlacSubframeType::Fixed: {
dbgln_if(AFLACLOADER_DEBUG, "Fixed LPC subframe order {}", subframe_header.order); dbgln_if(AFLACLOADER_DEBUG, " Fixed LPC subframe order {}", subframe_header.order);
samples = TRY(decode_fixed_lpc(subframe_header, bit_input)); samples = TRY(decode_fixed_lpc(subframe_header, bit_input));
break; break;
} }
case FlacSubframeType::Verbatim: { case FlacSubframeType::Verbatim: {
dbgln_if(AFLACLOADER_DEBUG, "Verbatim subframe"); dbgln_if(AFLACLOADER_DEBUG, " Verbatim subframe");
samples = TRY(decode_verbatim(subframe_header, bit_input)); samples = TRY(decode_verbatim(subframe_header, bit_input));
break; break;
} }
case FlacSubframeType::LPC: { case FlacSubframeType::LPC: {
dbgln_if(AFLACLOADER_DEBUG, "Custom LPC subframe order {}", subframe_header.order); dbgln_if(AFLACLOADER_DEBUG, " Custom LPC subframe order {}", subframe_header.order);
TRY(decode_custom_lpc(samples, subframe_header, bit_input)); TRY(decode_custom_lpc(samples, subframe_header, bit_input));
break; break;
} }
@ -790,7 +790,7 @@ ErrorOr<void, LoaderError> FlacLoaderPlugin::decode_custom_lpc(Vector<i64>& deco
coefficients.unchecked_append(coefficient); coefficients.unchecked_append(coefficient);
} }
dbgln_if(AFLACLOADER_DEBUG, "{}-bit {} shift coefficients: {}", lpc_precision, lpc_shift, coefficients); dbgln_if(AFLACLOADER_DEBUG, " {}-bit {} shift coefficients: {}", lpc_precision, lpc_shift, coefficients);
TRY(decode_residual(decoded, subframe, bit_input)); TRY(decode_residual(decoded, subframe, bit_input));
@ -833,7 +833,7 @@ ErrorOr<Vector<i64>, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram
TRY(decode_residual(decoded, subframe, bit_input)); TRY(decode_residual(decoded, subframe, bit_input));
dbgln_if(AFLACLOADER_DEBUG, "decoded length {}, {} order predictor", decoded.size(), subframe.order); dbgln_if(AFLACLOADER_DEBUG, " decoded length {}, {} order predictor, now at file offset {:x}", decoded.size(), subframe.order, TRY(m_stream->tell()));
// Skip these comments if you don't care about the neat math behind fixed LPC :^) // Skip these comments if you don't care about the neat math behind fixed LPC :^)
// These coefficients for the recursive prediction formula are the only ones that can be resolved to polynomial predictor functions. // These coefficients for the recursive prediction formula are the only ones that can be resolved to polynomial predictor functions.
@ -893,6 +893,8 @@ MaybeLoaderError FlacLoaderPlugin::decode_residual(Vector<i64>& decoded, FlacSub
u8 partition_order = TRY(bit_input.read_bits<u8>(4)); u8 partition_order = TRY(bit_input.read_bits<u8>(4));
size_t partitions = 1 << partition_order; size_t partitions = 1 << partition_order;
dbgln_if(AFLACLOADER_DEBUG, " {}-bit Rice partitions, {} total (order {})", residual_mode == FlacResidualMode::Rice4Bit ? "4"sv : "5"sv, partitions, partition_order);
if (partitions > m_current_frame->sample_count) if (partitions > m_current_frame->sample_count)
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), "Too many Rice partitions, each partition must contain at least one sample" }; return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), "Too many Rice partitions, each partition must contain at least one sample" };