2010-09-25 11:59:18 +00:00
|
|
|
/* 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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-09-25 11:59:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_MPEG_AUDIO_PARSE_H__
|
|
|
|
#define __GST_MPEG_AUDIO_PARSE_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2011-04-07 12:26:41 +00:00
|
|
|
#include <gst/base/gstbaseparse.h>
|
2010-09-25 11:59:18 +00:00
|
|
|
|
|
|
|
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 >*/
|
2019-09-07 17:15:42 +00:00
|
|
|
GstFormat upstream_format;
|
|
|
|
|
2010-09-25 11:59:18 +00:00
|
|
|
gint rate;
|
|
|
|
gint channels;
|
|
|
|
gint layer;
|
|
|
|
gint version;
|
|
|
|
|
|
|
|
GstClockTime max_bitreservoir;
|
2019-09-07 17:15:42 +00:00
|
|
|
|
|
|
|
/* Samples per frame */
|
|
|
|
gint spf;
|
|
|
|
|
|
|
|
GstClockTime frame_duration;
|
2010-09-25 11:59:18 +00:00
|
|
|
|
2012-02-21 17:42:31 +00:00
|
|
|
gint freerate;
|
|
|
|
|
2010-09-25 11:59:18 +00:00
|
|
|
gboolean sent_codec_tag;
|
|
|
|
guint last_posted_bitrate;
|
|
|
|
gint last_posted_crc, last_crc;
|
|
|
|
guint last_posted_channel_mode, last_mode;
|
|
|
|
|
2019-09-07 17:15:42 +00:00
|
|
|
gboolean outgoing_frame_is_xing_header;
|
|
|
|
|
2011-02-08 18:20:13 +00:00
|
|
|
/* Bitrate from non-vbr headers */
|
|
|
|
guint32 hdr_bitrate;
|
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.
2020-02-18 04:37:10 +00:00
|
|
|
gboolean bitrate_is_constant;
|
2011-02-08 18:20:13 +00:00
|
|
|
|
2010-09-25 11:59:18 +00:00
|
|
|
/* Xing info */
|
|
|
|
guint32 xing_flags;
|
|
|
|
guint32 xing_frames;
|
|
|
|
GstClockTime xing_total_time;
|
2019-09-07 17:15:42 +00:00
|
|
|
GstClockTime xing_actual_total_time;
|
2010-09-25 11:59:18 +00:00
|
|
|
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;
|
2011-04-01 12:47:43 +00:00
|
|
|
|
|
|
|
/* LAME info */
|
|
|
|
guint32 encoder_delay;
|
|
|
|
guint32 encoder_padding;
|
2019-09-07 17:15:42 +00:00
|
|
|
|
|
|
|
/* Gapless playback states */
|
|
|
|
guint32 decoder_delay;
|
|
|
|
guint64 start_of_actual_samples;
|
|
|
|
guint64 end_of_actual_samples;
|
|
|
|
GstClockTime start_padding_time;
|
|
|
|
GstClockTime end_padding_time;
|
|
|
|
GstClockTime total_padding_time;
|
2010-09-25 11:59:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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__ */
|