qtmux: fix byte order for opus extension
authorFrançois Laignel <francois@centricular.com>
Fri, 16 Jun 2023 08:02:16 +0000 (10:02 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 19 Jun 2023 15:09:48 +0000 (16:09 +0100)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4891>

subprojects/gst-plugins-good/gst/isomp4/atoms.c

index cb9de63..4332f86 100644 (file)
@@ -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);