From f3496ea3bf8dfabd66d09b0d4f8545066669cfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Fri, 16 Jun 2023 10:02:16 +0200 Subject: [PATCH] qtmux: fix byte order for opus extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Encapsulation of Opus in ISO Base Media File Format" [1] specifications, ยง 4.3.2 Opus Specific Box, indicates that data must be stored as big-endian. In `build_opus_extension`, `gst_byte_writer_put*_le ()` variants were used, causing audio streams conversion to Opus in mp4 to offset samples due to the PreSkip field incorrect value (29ms early in our test cases). [1] https://opus-codec.org/docs/opus_in_isobmff.html#4.3.2 Part-of: --- subprojects/gst-plugins-good/gst/isomp4/atoms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/isomp4/atoms.c b/subprojects/gst-plugins-good/gst/isomp4/atoms.c index cb9de639ea..4332f861c5 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/atoms.c +++ b/subprojects/gst-plugins-good/gst/isomp4/atoms.c @@ -5706,9 +5706,9 @@ build_opus_extension (guint32 rate, guint8 channels, guint8 mapping_family, gst_byte_writer_init (&bw); hdl &= gst_byte_writer_put_uint8 (&bw, 0x00); /* version number */ hdl &= gst_byte_writer_put_uint8 (&bw, channels); - hdl &= gst_byte_writer_put_uint16_le (&bw, pre_skip); - hdl &= gst_byte_writer_put_uint32_le (&bw, rate); - hdl &= gst_byte_writer_put_uint16_le (&bw, output_gain); + hdl &= gst_byte_writer_put_uint16_be (&bw, pre_skip); + hdl &= gst_byte_writer_put_uint32_be (&bw, rate); + hdl &= gst_byte_writer_put_uint16_be (&bw, output_gain); hdl &= gst_byte_writer_put_uint8 (&bw, mapping_family); if (mapping_family > 0) { hdl &= gst_byte_writer_put_uint8 (&bw, stream_count);