From dfc0e3c8d2b7c401b058c5f86c92c4570e2c1665 Mon Sep 17 00:00:00 2001 From: Michalis Dimopoulos Date: Wed, 13 Nov 2024 18:16:46 +0100 Subject: [PATCH] COM-12461: Add MPEG-2 AAC reference decoder to fluster decoder list Co-authored-by: Ruben Sanchez --- fluster/decoders/iso_mpeg2_aac.py | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 fluster/decoders/iso_mpeg2_aac.py diff --git a/fluster/decoders/iso_mpeg2_aac.py b/fluster/decoders/iso_mpeg2_aac.py new file mode 100644 index 00000000..4fb8af60 --- /dev/null +++ b/fluster/decoders/iso_mpeg2_aac.py @@ -0,0 +1,51 @@ +# Fluster - testing framework for decoders conformance +# Copyright (C) 2024, Fluendo, S.A. +# Author: Rubén Sánchez , Fluendo, S.A. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see . + +from fluster.codec import Codec, OutputFormat +from fluster.decoder import Decoder, register_decoder +from fluster.utils import file_checksum, run_command + + +@register_decoder +class ISOAACDecoder(Decoder): + """ISO MPEG2 AAC reference decoder implementation""" + + name = "ISO-MPEG2-AAC" + description = "ISO MPEG2 AAC reference decoder" + codec = Codec.AAC + binary = "aacdec_mc" + + def decode( + self, + input_filepath: str, + output_filepath: str, + output_format: OutputFormat, + timeout: int, + verbose: bool, + keep_files: bool, + ) -> str: + """Decodes input_filepath in output_filepath""" + # pylint: disable=unused-argument + # Addition of .pcm as extension is a must. If it is something else, e.g. ".out" the decoder will output a + # ".wav", which is undesirable. + output_filepath += ".pcm" + run_command( + [self.binary, input_filepath, output_filepath], + timeout=timeout, + verbose=verbose, + ) + return file_checksum(output_filepath)