mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 15:56:42 +00:00
71bb53a648
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.
114 lines
3.3 KiB
C
114 lines
3.3 KiB
C
/* GStreamer MPEG audio parser
|
|
* Copyright (C) 2006-2007 Jan Schmidt <thaytan@mad.scientist.com>
|
|
* Copyright (C) 2010 Mark Nauwelaerts <mnauw users sf net>
|
|
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
|
|
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 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
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __GST_MPEG_AUDIO_PARSE_H__
|
|
#define __GST_MPEG_AUDIO_PARSE_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/base/gstbaseparse.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_MPEG_AUDIO_PARSE \
|
|
(gst_mpeg_audio_parse_get_type())
|
|
#define GST_MPEG_AUDIO_PARSE(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MPEG_AUDIO_PARSE, GstMpegAudioParse))
|
|
#define GST_MPEG_AUDIO_PARSE_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_MPEG_AUDIO_PARSE, GstMpegAudioParseClass))
|
|
#define GST_IS_MPEG_AUDIO_PARSE(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_MPEG_AUDIO_PARSE))
|
|
#define GST_IS_MPEG_AUDIO_PARSE_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_MPEG_AUDIO_PARSE))
|
|
|
|
typedef struct _GstMpegAudioParse GstMpegAudioParse;
|
|
typedef struct _GstMpegAudioParseClass GstMpegAudioParseClass;
|
|
|
|
/**
|
|
* GstMpegAudioParse:
|
|
*
|
|
* The opaque GstMpegAudioParse object
|
|
*/
|
|
struct _GstMpegAudioParse {
|
|
GstBaseParse baseparse;
|
|
|
|
/*< private >*/
|
|
gint rate;
|
|
gint channels;
|
|
gint layer;
|
|
gint version;
|
|
|
|
GstClockTime max_bitreservoir;
|
|
/* samples per frame */
|
|
gint spf;
|
|
|
|
gint freerate;
|
|
|
|
gboolean sent_codec_tag;
|
|
guint last_posted_bitrate;
|
|
gint last_posted_crc, last_crc;
|
|
guint last_posted_channel_mode, last_mode;
|
|
|
|
/* Bitrate from non-vbr headers */
|
|
guint32 hdr_bitrate;
|
|
gboolean bitrate_is_constant;
|
|
|
|
/* Xing info */
|
|
guint32 xing_flags;
|
|
guint32 xing_frames;
|
|
GstClockTime xing_total_time;
|
|
guint32 xing_bytes;
|
|
/* percent -> filepos mapping */
|
|
guchar xing_seek_table[100];
|
|
/* filepos -> percent mapping */
|
|
guint16 xing_seek_table_inverse[256];
|
|
guint32 xing_vbr_scale;
|
|
guint xing_bitrate;
|
|
|
|
/* VBRI info */
|
|
guint32 vbri_frames;
|
|
GstClockTime vbri_total_time;
|
|
guint32 vbri_bytes;
|
|
guint vbri_bitrate;
|
|
guint vbri_seek_points;
|
|
guint32 *vbri_seek_table;
|
|
gboolean vbri_valid;
|
|
|
|
/* LAME info */
|
|
guint32 encoder_delay;
|
|
guint32 encoder_padding;
|
|
};
|
|
|
|
/**
|
|
* GstMpegAudioParseClass:
|
|
* @parent_class: Element parent class.
|
|
*
|
|
* The opaque GstMpegAudioParseClass data structure.
|
|
*/
|
|
struct _GstMpegAudioParseClass {
|
|
GstBaseParseClass baseparse_class;
|
|
};
|
|
|
|
GType gst_mpeg_audio_parse_get_type (void);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_MPEG_AUDIO_PARSE_H__ */
|