mpegaudioparse: Use a constant bit rate to convert between time and bytes if possible.
authorZebediah Figura <z.figura12@gmail.com>
Tue, 18 Feb 2020 04:37:10 +0000 (22:37 -0600)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 19 Mar 2020 14:02:44 +0000 (14:02 +0000)
commit71bb53a64839d88e0076ce5800612b9f8d6dc9d6
treeff116c781da5b2fae7ab82b7e2c6b670cc4ba23b
parent56e5243f030fe01398555f6ddf8cf2fdc8e19c34
mpegaudioparse: Use a constant bit rate to convert between time and bytes if possible.

This should result in no worse accuracy than the base parse element, and may
result in better accuracy. In particular, the number of bytes processed at any
given point, as accumulated by baseparse, can be only accurate to
(1 / # of frames) bytes per second, and if we try to seek immediately after
pausing the pipeline to a large offset, this small inaccuracy can propagate to
something noticeable.

The use case that prompted this patch is a 45-minute MPEG-1 layer 3 file, which
has a constant bit rate but no seek tables. Trying to seek the pipeline
immediately after pauisng it, without the ACCURATE flag, to a location 41
minutes in, yields a location that is, even with <https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/374>,
still audibly incorrect. This patch yields a much closer position, no longer
audibly incorrect, and likely within a frame of the most correct position.
gst/audioparsers/gstmpegaudioparse.c
gst/audioparsers/gstmpegaudioparse.h