mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
gst/xingheader/gstxingmux.c: The size of the Xing header is actually 417 as it's rounded to the next smaller integer....
Original commit message from CVS: Patch by: Gautier Portet <kassoulet at gmail dot com> * gst/xingheader/gstxingmux.c: The size of the Xing header is actually 417 as it's rounded to the next smaller integer. Fixes #397759. * gst/xingheader/gstxingmux.c: (xing_generate_header), (xing_push_header): Some random cleanup, add FIXMEs and TODOs and check if the newsegment event to the beginning was successful before pushing the header again.
This commit is contained in:
parent
6350482df8
commit
69c24a99e4
2 changed files with 32 additions and 7 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2007-10-05 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
Patch by: Gautier Portet <kassoulet at gmail dot com>
|
||||||
|
|
||||||
|
* gst/xingheader/gstxingmux.c:
|
||||||
|
The size of the Xing header is actually 417 as it's rounded to the
|
||||||
|
next smaller integer. Fixes #397759.
|
||||||
|
|
||||||
|
* gst/xingheader/gstxingmux.c: (xing_generate_header),
|
||||||
|
(xing_push_header):
|
||||||
|
Some random cleanup, add FIXMEs and TODOs and check if the newsegment
|
||||||
|
event to the beginning was successful before pushing the header again.
|
||||||
|
|
||||||
2007-10-05 Sebastian Dröge <slomo@circular-chaos.org>
|
2007-10-05 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
Patch by: Wai-Ming Ho <webregbox at yahoo dot co dot uk>
|
Patch by: Wai-Ming Ho <webregbox at yahoo dot co dot uk>
|
||||||
|
|
|
@ -33,7 +33,7 @@ GST_BOILERPLATE (GstXingMux, gst_xing_mux, GstElement, GST_TYPE_ELEMENT);
|
||||||
/* Xing Header stuff */
|
/* Xing Header stuff */
|
||||||
struct _GstXingMuxPriv
|
struct _GstXingMuxPriv
|
||||||
{
|
{
|
||||||
guint64 duration;
|
GstClockTime duration;
|
||||||
guint64 byte_count;
|
guint64 byte_count;
|
||||||
GList *seek_table;
|
GList *seek_table;
|
||||||
gboolean flush;
|
gboolean flush;
|
||||||
|
@ -44,7 +44,7 @@ struct _GstXingMuxPriv
|
||||||
#define GST_XING_TOC_FIELD (1 << 2)
|
#define GST_XING_TOC_FIELD (1 << 2)
|
||||||
#define GST_XING_QUALITY_FIELD (1 << 3)
|
#define GST_XING_QUALITY_FIELD (1 << 3)
|
||||||
|
|
||||||
static const int XING_FRAME_SIZE = 418;
|
static const int XING_FRAME_SIZE = 417;
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
gst_xing_mux_change_state (GstElement * element, GstStateChange transition);
|
gst_xing_mux_change_state (GstElement * element, GstStateChange transition);
|
||||||
|
@ -186,7 +186,8 @@ xing_generate_header (GstXingMux * xing)
|
||||||
* (00b == no emphasis)
|
* (00b == no emphasis)
|
||||||
*
|
*
|
||||||
* Such a frame (MPEG1 Layer III) contains 1152 samples, its size is thus:
|
* Such a frame (MPEG1 Layer III) contains 1152 samples, its size is thus:
|
||||||
* (1152*(128000/8))/44100 = 417.96
|
* (1152*(128000/8))/44100 = 417.96 rounded to the next smaller integer, i.e.
|
||||||
|
* 417.
|
||||||
*
|
*
|
||||||
* There are also 32 bytes (ie 8 32 bits values) to skip after the header
|
* There are also 32 bytes (ie 8 32 bits values) to skip after the header
|
||||||
* for such frames
|
* for such frames
|
||||||
|
@ -203,14 +204,19 @@ xing_generate_header (GstXingMux * xing)
|
||||||
|
|
||||||
xing_flags = 0;
|
xing_flags = 0;
|
||||||
if (xing->priv->duration != GST_CLOCK_TIME_NONE) {
|
if (xing->priv->duration != GST_CLOCK_TIME_NONE) {
|
||||||
guint number_of_frames;
|
guint32 number_of_frames;
|
||||||
|
|
||||||
/* The Xing Header contains a NumberOfFrames field, which verifies to:
|
/* The Xing Header contains a NumberOfFrames field, which verifies to:
|
||||||
* Duration = NumberOfFrames *SamplesPerFrame/SamplingRate
|
* Duration = NumberOfFrames *SamplesPerFrame/SamplingRate
|
||||||
* SamplesPerFrame and SamplingRate are values for the current frame,
|
* SamplesPerFrame and SamplingRate are values for the current frame,
|
||||||
* ie 1152 and 44100 in our case.
|
* ie 1152 and 44100 in our case.
|
||||||
*/
|
*/
|
||||||
number_of_frames = (44100 * xing->priv->duration / GST_SECOND) / 1152;
|
|
||||||
|
/* FIXME: Better count the actual number of frames as the calculation
|
||||||
|
* below introduces rounding errors
|
||||||
|
*/
|
||||||
|
number_of_frames = gst_util_uint64_scale (xing->priv->duration, 44100,
|
||||||
|
GST_SECOND) / 1152;
|
||||||
data[SIDE_INFO_SIZE + 3] = GUINT32_TO_BE (number_of_frames);
|
data[SIDE_INFO_SIZE + 3] = GUINT32_TO_BE (number_of_frames);
|
||||||
|
|
||||||
xing_flags |= GST_XING_FRAME_FIELD;
|
xing_flags |= GST_XING_FRAME_FIELD;
|
||||||
|
@ -221,7 +227,7 @@ xing_generate_header (GstXingMux * xing)
|
||||||
data[SIDE_INFO_SIZE + 4] = GUINT32_TO_BE (xing->priv->byte_count);
|
data[SIDE_INFO_SIZE + 4] = GUINT32_TO_BE (xing->priv->byte_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Un-#ifdef when it's implemented :) xing code in VbrTag.c looks like
|
/* TODO: Un-#ifdef when it's implemented :) xing code in VbrTag.c looks like
|
||||||
* it could be stolen
|
* it could be stolen
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -256,10 +262,16 @@ xing_push_header (GstXingMux * xing)
|
||||||
GstBuffer *header;
|
GstBuffer *header;
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
|
|
||||||
|
/* FIXME: should actually be after any ID3v2/APE tags and before the real
|
||||||
|
* MP3 frames.
|
||||||
|
*/
|
||||||
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
|
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
|
||||||
0, GST_CLOCK_TIME_NONE, 0);
|
0, GST_CLOCK_TIME_NONE, 0);
|
||||||
|
|
||||||
gst_pad_push_event (xing->srcpad, event);
|
if (G_UNLIKELY (!gst_pad_push_event (xing->srcpad, event))) {
|
||||||
|
GST_WARNING ("Failed to seek to position 0 for pushing the Xing header");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
header = xing_generate_header (xing);
|
header = xing_generate_header (xing);
|
||||||
xing_set_flush (xing, FALSE);
|
xing_set_flush (xing, FALSE);
|
||||||
|
|
Loading…
Reference in a new issue