mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
flacparse: Make bitrate estimation more accurate
This implements the get_frame_overhead() vfunc so that baseparse can make more accurate bitrate estimates.
This commit is contained in:
parent
44878511b2
commit
fb4673cde9
1 changed files with 18 additions and 0 deletions
|
@ -86,6 +86,8 @@ static gboolean gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
GstBuffer * buffer, guint * framesize, gint * skipsize);
|
||||
static GstFlowReturn gst_flac_parse_parse_frame (GstBaseParse * parse,
|
||||
GstBuffer * buffer);
|
||||
static gint gst_flac_parse_get_frame_overhead (GstBaseParse * parse,
|
||||
GstBuffer * buffer);
|
||||
|
||||
GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse,
|
||||
GST_TYPE_BASE_PARSE);
|
||||
|
@ -122,6 +124,8 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
|
|||
baseparse_class->check_valid_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_flac_parse_check_valid_frame);
|
||||
baseparse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_parse_frame);
|
||||
baseparse_class->get_frame_overhead =
|
||||
GST_DEBUG_FUNCPTR (gst_flac_parse_get_frame_overhead);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1288,3 +1292,17 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBuffer * buffer)
|
|||
return GST_FLOW_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gst_flac_parse_get_frame_overhead (GstBaseParse * parse, GstBuffer * buffer)
|
||||
{
|
||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||
|
||||
if (flacparse->state != GST_FLAC_PARSE_STATE_DATA)
|
||||
return -1;
|
||||
else
|
||||
/* To simplify, we just assume that it's a fixed size header and ignore
|
||||
* subframe headers. The first could lead us to being off by 88 bits and
|
||||
* the second even less, so the total inaccuracy is negligible. */
|
||||
return 7;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue