From 982529a948b85f70630ddfa7feb5075210991d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Fri, 17 Dec 2021 00:00:03 +0100 Subject: [PATCH] LibAudio: Don't unnecessarily copy the passed decode buffer --- Userland/Libraries/LibAudio/FlacLoader.cpp | 6 +++--- Userland/Libraries/LibAudio/FlacLoader.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 65c143d920..a4f4108435 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -610,7 +610,7 @@ ErrorOr, LoaderError> FlacLoaderPlugin::decode_custom_lpc(FlacSubfra dbgln_if(AFLACLOADER_DEBUG, "{}-bit {} shift coefficients: {}", lpc_precision, lpc_shift, coefficients); - decoded = TRY(decode_residual(decoded, subframe, bit_input)); + TRY(decode_residual(decoded, subframe, bit_input)); // approximate the waveform with the predictor for (size_t i = subframe.order; i < m_current_frame->sample_count; ++i) { @@ -680,7 +680,7 @@ ErrorOr, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram } // Decode the residual, the "error" between the function approximation and the actual audio data -ErrorOr, LoaderError> FlacLoaderPlugin::decode_residual(Vector& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input) +MaybeLoaderError FlacLoaderPlugin::decode_residual(Vector& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input) { u8 residual_mode = static_cast(bit_input.read_bits_big_endian(2)); u8 partition_order = static_cast(bit_input.read_bits_big_endian(4)); @@ -701,7 +701,7 @@ ErrorOr, LoaderError> FlacLoaderPlugin::decode_residual(Vector& } else return LoaderError { LoaderError::Category::Format, static_cast(m_current_sample_or_frame), "Reserved residual coding method" }; - return decoded; + return {}; } // Decode a single Rice partition as part of the residual, every partition can have its own Rice parameter k diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h index 0f552934c3..41e124b60e 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.h +++ b/Userland/Libraries/LibAudio/FlacLoader.h @@ -121,7 +121,7 @@ private: ErrorOr, LoaderError> decode_fixed_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input); ErrorOr, LoaderError> decode_verbatim(FlacSubframeHeader& subframe, InputBitStream& bit_input); ErrorOr, LoaderError> decode_custom_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input); - ErrorOr, LoaderError> decode_residual(Vector& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input); + MaybeLoaderError decode_residual(Vector& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input); // decode a single rice partition that has its own rice parameter ALWAYS_INLINE Vector decode_rice_partition(u8 partition_type, u32 partitions, u32 partition_index, FlacSubframeHeader& subframe, InputBitStream& bit_input);