1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

LibAudio: Don't unnecessarily copy the passed decode buffer

This commit is contained in:
kleines Filmröllchen 2021-12-17 00:00:03 +01:00 committed by Brian Gianforcaro
parent 0d28b6d236
commit 982529a948
2 changed files with 4 additions and 4 deletions

View file

@ -610,7 +610,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_custom_lpc(FlacSubfra
dbgln_if(AFLACLOADER_DEBUG, "{}-bit {} shift coefficients: {}", lpc_precision, lpc_shift, coefficients); 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 // approximate the waveform with the predictor
for (size_t i = subframe.order; i < m_current_frame->sample_count; ++i) { for (size_t i = subframe.order; i < m_current_frame->sample_count; ++i) {
@ -680,7 +680,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram
} }
// Decode the residual, the "error" between the function approximation and the actual audio data // Decode the residual, the "error" between the function approximation and the actual audio data
ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_residual(Vector<i32>& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input) MaybeLoaderError FlacLoaderPlugin::decode_residual(Vector<i32>& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input)
{ {
u8 residual_mode = static_cast<u8>(bit_input.read_bits_big_endian(2)); u8 residual_mode = static_cast<u8>(bit_input.read_bits_big_endian(2));
u8 partition_order = static_cast<u8>(bit_input.read_bits_big_endian(4)); u8 partition_order = static_cast<u8>(bit_input.read_bits_big_endian(4));
@ -701,7 +701,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_residual(Vector<i32>&
} else } else
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), "Reserved residual coding method" }; return LoaderError { LoaderError::Category::Format, static_cast<size_t>(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 // Decode a single Rice partition as part of the residual, every partition can have its own Rice parameter k

View file

@ -121,7 +121,7 @@ private:
ErrorOr<Vector<i32>, LoaderError> decode_fixed_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input); ErrorOr<Vector<i32>, LoaderError> decode_fixed_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input);
ErrorOr<Vector<i32>, LoaderError> decode_verbatim(FlacSubframeHeader& subframe, InputBitStream& bit_input); ErrorOr<Vector<i32>, LoaderError> decode_verbatim(FlacSubframeHeader& subframe, InputBitStream& bit_input);
ErrorOr<Vector<i32>, LoaderError> decode_custom_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input); ErrorOr<Vector<i32>, LoaderError> decode_custom_lpc(FlacSubframeHeader& subframe, InputBitStream& bit_input);
ErrorOr<Vector<i32>, LoaderError> decode_residual(Vector<i32>& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input); MaybeLoaderError decode_residual(Vector<i32>& decoded, FlacSubframeHeader& subframe, InputBitStream& bit_input);
// decode a single rice partition that has its own rice parameter // decode a single rice partition that has its own rice parameter
ALWAYS_INLINE Vector<i32> decode_rice_partition(u8 partition_type, u32 partitions, u32 partition_index, FlacSubframeHeader& subframe, InputBitStream& bit_input); ALWAYS_INLINE Vector<i32> decode_rice_partition(u8 partition_type, u32 partitions, u32 partition_index, FlacSubframeHeader& subframe, InputBitStream& bit_input);