mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 13:32:29 +00:00
Hint bytestream about optimal size sync fixes for VBR streams
Original commit message from CVS: Hint bytestream about optimal size sync fixes for VBR streams
This commit is contained in:
parent
25bbab292f
commit
3616ba23f6
2 changed files with 25 additions and 9 deletions
|
@ -357,6 +357,8 @@ gst_avi_demux_strh (GstAviDemux *avi_demux)
|
||||||
|
|
||||||
target->skip = 0;
|
target->skip = 0;
|
||||||
|
|
||||||
|
avi_demux->avih.bufsize = MAX (avi_demux->avih.bufsize, target->strh.bufsize);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -644,6 +646,8 @@ gst_avi_demux_parse_index (GstAviDemux *avi_demux,
|
||||||
index_size = GUINT32_FROM_LE(*(guint32 *)(GST_BUFFER_DATA (buf) + 4));
|
index_size = GUINT32_FROM_LE(*(guint32 *)(GST_BUFFER_DATA (buf) + 4));
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
|
gst_bytestream_size_hint (avi_demux->bs, index_size);
|
||||||
|
|
||||||
got_bytes = gst_bytestream_read (avi_demux->bs, &buf, index_size);
|
got_bytes = gst_bytestream_read (avi_demux->bs, &buf, index_size);
|
||||||
if (got_bytes < index_size) {
|
if (got_bytes < index_size) {
|
||||||
GST_INFO (GST_CAT_PLUGIN_INFO, "avidemux: error reading index");
|
GST_INFO (GST_CAT_PLUGIN_INFO, "avidemux: error reading index");
|
||||||
|
@ -684,20 +688,29 @@ gst_avi_demux_parse_index (GstAviDemux *avi_demux,
|
||||||
if (stream->strh.type == GST_RIFF_FCC_auds) {
|
if (stream->strh.type == GST_RIFF_FCC_auds) {
|
||||||
/* all audio frames are keyframes */
|
/* all audio frames are keyframes */
|
||||||
target->flags |= GST_RIFF_IF_KEYFRAME;
|
target->flags |= GST_RIFF_IF_KEYFRAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* constant rate stream */
|
||||||
|
if (stream->strh.samplesize) {
|
||||||
gst_pad_convert (stream->pad, GST_FORMAT_BYTES, stream->total_bytes,
|
gst_pad_convert (stream->pad, GST_FORMAT_BYTES, stream->total_bytes,
|
||||||
&format, &target->ts);
|
&format, &target->ts);
|
||||||
}
|
}
|
||||||
|
/* VBR stream */
|
||||||
else {
|
else {
|
||||||
gst_pad_convert (stream->pad, GST_FORMAT_UNITS, stream->total_frames,
|
gst_pad_convert (stream->pad, GST_FORMAT_UNITS, stream->total_frames,
|
||||||
&format, &target->ts);
|
&format, &target->ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_avi_debug_entry ("index", target);
|
gst_avi_debug_entry ("index", target);
|
||||||
|
|
||||||
stream->total_bytes += target->size;
|
stream->total_bytes += target->size;
|
||||||
stream->total_frames++;
|
stream->total_frames++;
|
||||||
}
|
}
|
||||||
|
for (i = 0; i < avi_demux->num_streams; i++) {
|
||||||
|
avi_stream_context *stream;
|
||||||
|
|
||||||
|
stream = &avi_demux->stream[i];
|
||||||
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "stream %i: %d frames, %lld bytes", i, stream->total_frames, stream->total_bytes);
|
||||||
|
}
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -847,21 +860,21 @@ gst_avi_demux_handle_src_query (GstPad *pad, GstPadQueryType type,
|
||||||
*format = GST_FORMAT_TIME;
|
*format = GST_FORMAT_TIME;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
if (stream->strh.type == GST_RIFF_FCC_vids)
|
if (stream->strh.samplesize) {
|
||||||
*value = stream->current_frame * GST_SECOND * stream->strh.scale / stream->strh.rate;
|
|
||||||
else
|
|
||||||
*value = stream->current_byte * GST_SECOND * stream->strh.scale / stream->strh.rate;
|
*value = stream->current_byte * GST_SECOND * stream->strh.scale / stream->strh.rate;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*value = stream->current_frame * GST_SECOND * stream->strh.scale / stream->strh.rate;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_BYTES:
|
case GST_FORMAT_BYTES:
|
||||||
*value = stream->current_byte;
|
*value = stream->current_byte;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_UNITS:
|
case GST_FORMAT_UNITS:
|
||||||
if (stream->strh.type == GST_RIFF_FCC_auds)
|
if (stream->strh.samplesize)
|
||||||
*value = stream->current_byte * stream->strh.samplesize;
|
*value = stream->current_byte * stream->strh.samplesize;
|
||||||
else if (stream->strh.type == GST_RIFF_FCC_vids)
|
|
||||||
*value = stream->current_frame;
|
|
||||||
else
|
else
|
||||||
res = FALSE;
|
*value = stream->current_frame;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
|
@ -1118,6 +1131,8 @@ gst_avi_demux_process_chunk (GstAviDemux *avi_demux, guint64 *filepos,
|
||||||
|
|
||||||
gst_bytestream_get_status (avi_demux->bs, &remaining, &event);
|
gst_bytestream_get_status (avi_demux->bs, &remaining, &event);
|
||||||
}
|
}
|
||||||
|
if (avi_demux->avih.bufsize)
|
||||||
|
gst_bytestream_size_hint (avi_demux->bs, avi_demux->avih.bufsize);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* flush the form type */
|
/* flush the form type */
|
||||||
|
|
|
@ -73,6 +73,7 @@ typedef struct
|
||||||
guint32 current_byte;
|
guint32 current_byte;
|
||||||
guint64 delay;
|
guint64 delay;
|
||||||
gboolean need_flush;
|
gboolean need_flush;
|
||||||
|
guint32 av_bps;
|
||||||
|
|
||||||
guint64 total_bytes;
|
guint64 total_bytes;
|
||||||
gint32 total_frames;
|
gint32 total_frames;
|
||||||
|
|
Loading…
Reference in a new issue