Skip to content

Commit

Permalink
COM-12575: Investigate erratic behaviour of AAC audio reference decod…
Browse files Browse the repository at this point in the history
…ers (#209)

* COM-12575:

* Include improvements in mpeg reference decoders building
* Add JSON generation from ISO-MPEG2-AAC decoder in "iso_mpeg2_aac.py" file
* Change ""result":" values of MPEG2_AAC-ADIF.json and MPEG2_AAC-ADTS.json, from reference decoder, .pcm files
* Pass to x32 mpeg2 and mpeg4 building
* improve "ifeq" to install all dependencies (gcc-multilib and g++-multilib)
* use glob library, (review comment #209 (comment))
  • Loading branch information
rsanchez87 authored Nov 19, 2024
1 parent a6360e9 commit 4e4ca85
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 561 deletions.
33 changes: 16 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ h264_reference_decoder: ## build H.264 reference decoder
find $(CONTRIB_DIR)/JM/bin/umake -name "ldecod" -type f -exec cp {} $(DECODERS_DIR)/ \;

mpeg_4_aac_reference_decoder: ## build ISO MPEG4 AAC reference decoder
ifeq ($(dpkg -l | grep gcc-multilib), "")
ifeq ("$(dpkg -l | grep gcc-multilib)", "")
sudo apt-get install gcc-multilib
endif
ifeq ($(dpkg -l | grep g++-multilib), "")
ifeq ("$(dpkg -l | grep g++-multilib)", "")
sudo apt-get install g++-multilib
endif
ifeq ($(wildcard /usr/include/asm), )
Expand All @@ -114,8 +114,9 @@ ifeq ($(wildcard $(CONTRIB_DIR)/C050470e_Electronic_inserts), )
cd $(CONTRIB_DIR) && unzip -oq c050470__ISO_IEC_14496-5_2001_Amd_20_2009_Reference_Software.zip
cd $(CONTRIB_DIR) && rm -f iso_cookies.txt c050470__ISO_IEC_14496-5_2001_Amd_20_2009_Reference_Software.zip

cd $(CONTRIB_DIR) && git clone https://github.com/MPEGGroup/isobmff.git
cd $(CONTRIB_DIR)/isobmff && mkdir build && cd build && cmake .. -DCMAKE_C_FLAGS=-m64 && $(MAKE) libisomediafile
cd $(CONTRIB_DIR) && rm -rf isobmff && git clone https://github.com/MPEGGroup/isobmff.git
cd $(CONTRIB_DIR)/isobmff && git checkout tags/v0.2.0 -b v0.2.0
cd $(CONTRIB_DIR)/isobmff && mkdir -p build && cd build && cmake .. -DCMAKE_C_FLAGS=-m32 && $(MAKE) libisomediafile
cd $(CONTRIB_DIR)/isobmff && mv lib/liblibisomediafile.a lib/libisomediafile.a
cd $(CONTRIB_DIR) && cp isobmff/lib/libisomediafile.a C050470e_Electronic_inserts/audio/natural/import/lib/
cd $(CONTRIB_DIR) && cp isobmff/IsoLib/libisomediafile/src/ISOMovies.h C050470e_Electronic_inserts/audio/natural/import/include/
Expand All @@ -128,15 +129,15 @@ else ifeq ($(KERNEL_NAME), Darwin)
cd $(CONTRIB_DIR) && cp isobmff/IsoLib/libisomediafile/macosx/MP4OSMacros.h C050470e_Electronic_inserts/audio/natural/import/include/ || true
endif
cd $(CONTRIB_DIR) && wget --no-check-certificate https://www-mmsp.ece.mcgill.ca/Documents/Downloads/libtsp/libtsp-v7r0.tar.gz
cd $(CONTRIB_DIR) && tar -zxf libtsp-v7r0.tar.gz && chmod -R ugo=rwx libtsp-v7r0/ && cd libtsp-v7r0/ && $(MAKE) -s COPTS=-m64
cd $(CONTRIB_DIR) && tar -zxf libtsp-v7r0.tar.gz && chmod -R ugo=rwx libtsp-v7r0/ && cd libtsp-v7r0/ && $(MAKE) -s COPTS=-m32
cd $(CONTRIB_DIR) && rm -f libtsp-v7r0.tar.gz
cd $(CONTRIB_DIR) && cp libtsp-v7r0/lib/libtsp.a C050470e_Electronic_inserts/audio/natural/import/lib/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp.h C050470e_Electronic_inserts/audio/natural/import/include/
cd $(CONTRIB_DIR) && mkdir C050470e_Electronic_inserts/audio/natural/import/include/libtsp/
cd $(CONTRIB_DIR) && mkdir -p C050470e_Electronic_inserts/audio/natural/import/include/libtsp/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp/AFpar.h C050470e_Electronic_inserts/audio/natural/import/include/libtsp/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp/UTpar.h C050470e_Electronic_inserts/audio/natural/import/include/libtsp/
endif
cd $(CONTRIB_DIR)/C050470e_Electronic_inserts/audio/natural/mp4mcDec && MAKELEVEL=0 $(MAKE) mp4audec_mc REFSOFT_INCLUDE_PATH=../import/include REFSOFT_LIBRARY_PATH=../import/lib CFLAGS=-m64 LDFLAGS=-m64
cd $(CONTRIB_DIR)/C050470e_Electronic_inserts/audio/natural/mp4mcDec && MAKELEVEL=0 $(MAKE) mp4audec_mc REFSOFT_INCLUDE_PATH=../import/include REFSOFT_LIBRARY_PATH=../import/lib CFLAGS=-m32 LDFLAGS=-m32
find $(CONTRIB_DIR)/C050470e_Electronic_inserts/audio/natural/bin/mp4mcDec -name "mp4audec_mc" -type f -exec cp {} $(DECODERS_DIR) \;

ifneq ($(wildcard /usr/include/asm), )
Expand All @@ -146,10 +147,10 @@ endif
endif

mpeg_2_aac_reference_decoder: ## build ISO MPEG2 AAC reference decoder
ifeq ($(dpkg -l | grep gcc-multilib), "")
ifeq ("$(dpkg -l | grep gcc-multilib)", "")
sudo apt-get install gcc-multilib
endif
ifeq ($(dpkg -l | grep g++-multilib), "")
ifeq ("$(dpkg -l | grep g++-multilib)", "")
sudo apt-get install g++-multilib
endif
ifeq ($(wildcard /usr/include/asm), )
Expand All @@ -168,12 +169,12 @@ ifeq ($(wildcard $(CONTRIB_DIR)/C039486_Electronic_inserts), )
cd $(CONTRIB_DIR) && unzip -oq c039486_ISO_IEC_13818-5_2005_Reference_Software.zip
cd $(CONTRIB_DIR) && rm -f iso_cookies.txt c039486_ISO_IEC_13818-5_2005_Reference_Software.zip ipmp.zip mpeg2audio.zip systems.zip video.zip

# Unzip and setup MPEG-2 AAC decoder files
cd $(CONTRIB_DIR) && unzip -oq mpeg2aac.zip
cd $(CONTRIB_DIR) && rm -f mpeg2aac.zip

cd $(CONTRIB_DIR) && git clone https://github.com/MPEGGroup/isobmff.git
cd $(CONTRIB_DIR)/isobmff && mkdir build && cd build && cmake .. -DCMAKE_C_FLAGS=-m64 && $(MAKE) libisomediafile
cd $(CONTRIB_DIR) && rm -rf isobmff && git clone https://github.com/MPEGGroup/isobmff.git
cd $(CONTRIB_DIR)/isobmff && git checkout tags/v0.2.0 -b v0.2.0
cd $(CONTRIB_DIR)/isobmff && mkdir -p build && cd build && cmake .. -DCMAKE_C_FLAGS=-m32 && $(MAKE) libisomediafile
cd $(CONTRIB_DIR)/isobmff && mv lib/liblibisomediafile.a lib/libisomediafile.a
cd $(CONTRIB_DIR) && cp isobmff/lib/libisomediafile.a mpeg2aac/import/lib/
cd $(CONTRIB_DIR) && cp isobmff/IsoLib/libisomediafile/src/ISOMovies.h mpeg2aac/import/include/
Expand All @@ -186,17 +187,15 @@ else ifeq ($(KERNEL_NAME), Darwin)
cd $(CONTRIB_DIR) && cp isobmff/IsoLib/libisomediafile/macosx/MP4OSMacros.h mpeg2aac/import/include/ || true
endif
cd $(CONTRIB_DIR) && wget --no-check-certificate https://www-mmsp.ece.mcgill.ca/Documents/Downloads/libtsp/libtsp-v7r0.tar.gz
cd $(CONTRIB_DIR) && tar -zxf libtsp-v7r0.tar.gz && chmod -R ugo=rwx libtsp-v7r0/ && cd libtsp-v7r0/ && $(MAKE) -s COPTS=-m64
cd $(CONTRIB_DIR) && tar -zxf libtsp-v7r0.tar.gz && chmod -R ugo=rwx libtsp-v7r0/ && cd libtsp-v7r0/ && $(MAKE) -s COPTS=-m32
cd $(CONTRIB_DIR) && rm -f libtsp-v7r0.tar.gz
cd $(CONTRIB_DIR) && cp libtsp-v7r0/lib/libtsp.a mpeg2aac/import/lib/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp.h mpeg2aac/import/include/
cd $(CONTRIB_DIR) && mkdir mpeg2aac/import/include/libtsp/
cd $(CONTRIB_DIR) && mkdir -p mpeg2aac/import/include/libtsp/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp/AFpar.h mpeg2aac/import/include/libtsp/
cd $(CONTRIB_DIR) && cp libtsp-v7r0/include/libtsp/UTpar.h mpeg2aac/import/include/libtsp/
endif

# Build the MPEG-2 AAC decoder
cd $(CONTRIB_DIR)/mpeg2aac/aacDec && MAKELEVEL=0 $(MAKE) aacdec_mc REFSOFT_INCLUDE_PATH=../import/include REFSOFT_LIBRARY_PATH=../import/lib CFLAGS=-m64 LDFLAGS=-m64
cd $(CONTRIB_DIR)/mpeg2aac/aacDec && MAKELEVEL=0 $(MAKE) aacdec_mc REFSOFT_INCLUDE_PATH=../import/include REFSOFT_LIBRARY_PATH=../import/lib CFLAGS=-m32 LDFLAGS=-m32
find $(CONTRIB_DIR)/mpeg2aac/bin/mp4mcDec -name "aacdec_mc" -type f -exec cp {} $(DECODERS_DIR) \;

ifneq ($(wildcard /usr/include/asm), )
Expand Down
18 changes: 16 additions & 2 deletions fluster/decoders/iso_mpeg2_aac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
import glob
import os

from fluster.codec import Codec, OutputFormat
from fluster.decoder import Decoder, register_decoder
Expand Down Expand Up @@ -42,10 +44,22 @@ def decode(
# 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 += ".wav"
output_filepath += ".pcm"
run_command(
[self.binary, "-w", input_filepath, output_filepath],
[self.binary, input_filepath, output_filepath],
timeout=timeout,
verbose=verbose,
)

base_output = output_filepath[:-4]
pcm_out_f00_file = f"{base_output}_f00.pcm"

if os.path.exists(pcm_out_f00_file):
return file_checksum(pcm_out_f00_file)

output_files = glob.glob(f"{base_output}_f[0-9][0-9].pcm")

for pcm_file in output_files:
return file_checksum(pcm_file)

return file_checksum(output_filepath)
Loading

0 comments on commit 4e4ca85

Please sign in to comment.