mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 15:04:46 +00:00
avi: remove code that got converted
This commit is contained in:
parent
c199b1d039
commit
1b325945e5
1 changed files with 0 additions and 404 deletions
|
@ -2238,189 +2238,6 @@ out_of_mem:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* gst_avi_demux_parse_index:
|
|
||||||
* @avi: calling element (used for debugging/errors).
|
|
||||||
* @buf: buffer containing the full index.
|
|
||||||
* @entries_list: list (returned by this function) containing the index
|
|
||||||
* entries parsed from the buffer. The first in the list
|
|
||||||
* is also a pointer to the allocated data and should be
|
|
||||||
* free'ed at some point.
|
|
||||||
*
|
|
||||||
* Read index entries from the provided buffer. Takes ownership of @buf.
|
|
||||||
* The buffer should contain a GST_RIFF_TAG_idx1 chunk.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
gst_avi_demux_parse_index (GstAviDemux * avi,
|
|
||||||
GstBuffer * buf, GList ** _entries_list)
|
|
||||||
{
|
|
||||||
guint64 pos_before = avi->offset;
|
|
||||||
gst_avi_index_entry *entries = NULL;
|
|
||||||
guint8 *data;
|
|
||||||
GList *entries_list = NULL;
|
|
||||||
guint i, num, n;
|
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
gulong _nr_keyframes = 0;
|
|
||||||
#endif
|
|
||||||
GstClockTime stamp;
|
|
||||||
|
|
||||||
if (!buf || !GST_BUFFER_SIZE (buf)) {
|
|
||||||
*_entries_list = NULL;
|
|
||||||
GST_DEBUG ("empty index");
|
|
||||||
if (buf)
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stamp = gst_util_get_timestamp ();
|
|
||||||
|
|
||||||
data = GST_BUFFER_DATA (buf);
|
|
||||||
num = GST_BUFFER_SIZE (buf) / sizeof (gst_riff_index_entry);
|
|
||||||
if (!(entries = g_try_new (gst_avi_index_entry, num)))
|
|
||||||
goto out_of_mem;
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (avi, "Parsing index, nr_entries = %6d", num);
|
|
||||||
|
|
||||||
for (i = 0, n = 0; i < num; i++) {
|
|
||||||
gint64 next_ts;
|
|
||||||
gst_riff_index_entry entry, *_entry;
|
|
||||||
GstAviStream *stream;
|
|
||||||
guint stream_nr;
|
|
||||||
gst_avi_index_entry *target;
|
|
||||||
|
|
||||||
_entry = &((gst_riff_index_entry *) data)[i];
|
|
||||||
entry.id = GST_READ_UINT32_LE (&_entry->id);
|
|
||||||
entry.offset = GST_READ_UINT32_LE (&_entry->offset);
|
|
||||||
entry.flags = GST_READ_UINT32_LE (&_entry->flags);
|
|
||||||
entry.size = GST_READ_UINT32_LE (&_entry->size);
|
|
||||||
target = &entries[n];
|
|
||||||
|
|
||||||
if (entry.id == GST_RIFF_rec || entry.id == 0 ||
|
|
||||||
(entry.offset == 0 && n > 0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
stream_nr = CHUNKID_TO_STREAMNR (entry.id);
|
|
||||||
if (stream_nr >= avi->num_streams) {
|
|
||||||
GST_WARNING_OBJECT (avi,
|
|
||||||
"Index entry %d has invalid stream nr %d", i, stream_nr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
target->stream_nr = stream_nr;
|
|
||||||
stream = &avi->stream[stream_nr];
|
|
||||||
|
|
||||||
if (!stream->strh) {
|
|
||||||
GST_WARNING_OBJECT (avi, "Unhandled stream %d, skipping", stream_nr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
target->index_nr = i;
|
|
||||||
target->flags =
|
|
||||||
(entry.flags & GST_RIFF_IF_KEYFRAME) ? GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME
|
|
||||||
: 0;
|
|
||||||
target->size = entry.size;
|
|
||||||
target->offset = entry.offset + 8;
|
|
||||||
|
|
||||||
/* figure out if the index is 0 based or relative to the MOVI start */
|
|
||||||
if (n == 0) {
|
|
||||||
if (target->offset < pos_before)
|
|
||||||
avi->index_offset = pos_before + 8;
|
|
||||||
else
|
|
||||||
avi->index_offset = 0;
|
|
||||||
GST_DEBUG ("index_offset = %" G_GUINT64_FORMAT, avi->index_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream->strh->type == GST_RIFF_FCC_auds) {
|
|
||||||
/* all audio frames are keyframes */
|
|
||||||
target->flags |= GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME;
|
|
||||||
}
|
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
if (target->flags & GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME)
|
|
||||||
_nr_keyframes++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* stream duration unknown, now we can calculate it */
|
|
||||||
if (stream->idx_duration == -1)
|
|
||||||
stream->idx_duration = 0;
|
|
||||||
|
|
||||||
/* timestamps */
|
|
||||||
target->ts = stream->idx_duration;
|
|
||||||
if (stream->is_vbr) {
|
|
||||||
/* VBR stream next timestamp */
|
|
||||||
if (stream->strh->type == GST_RIFF_FCC_auds) {
|
|
||||||
next_ts = avi_stream_convert_frames_to_time_unchecked (stream,
|
|
||||||
stream->total_blocks + 1);
|
|
||||||
} else {
|
|
||||||
next_ts = avi_stream_convert_frames_to_time_unchecked (stream,
|
|
||||||
stream->idx_n + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* constant rate stream */
|
|
||||||
next_ts = avi_stream_convert_bytes_to_time_unchecked (stream,
|
|
||||||
stream->total_bytes + target->size);
|
|
||||||
}
|
|
||||||
/* duration is next - current */
|
|
||||||
target->dur = next_ts - target->ts;
|
|
||||||
|
|
||||||
/* stream position */
|
|
||||||
target->bytes_before = stream->total_bytes;
|
|
||||||
target->frames_before = stream->idx_n;
|
|
||||||
|
|
||||||
stream->total_bytes += target->size;
|
|
||||||
stream->idx_n++;
|
|
||||||
if (stream->strh->type == GST_RIFF_FCC_auds) {
|
|
||||||
if (stream->strf.auds->blockalign > 0)
|
|
||||||
stream->total_blocks +=
|
|
||||||
(target->size + stream->strf.auds->blockalign -
|
|
||||||
1) / stream->strf.auds->blockalign;
|
|
||||||
else
|
|
||||||
stream->total_blocks++;
|
|
||||||
}
|
|
||||||
stream->idx_duration = next_ts;
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (avi,
|
|
||||||
"Adding index entry %d (%6u), flags %02x, stream %d, size %u "
|
|
||||||
", offset %" G_GUINT64_FORMAT ", time %" GST_TIME_FORMAT ", dur %"
|
|
||||||
GST_TIME_FORMAT,
|
|
||||||
target->index_nr, stream->idx_n - 1, target->flags,
|
|
||||||
target->stream_nr, target->size, target->offset,
|
|
||||||
GST_TIME_ARGS (target->ts), GST_TIME_ARGS (target->dur));
|
|
||||||
entries_list = g_list_prepend (entries_list, target);
|
|
||||||
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (avi, "Parsed index, %6u/%6u entries, %5lu keyframes, "
|
|
||||||
"entry size = %2u, total size = %10u", n, num, _nr_keyframes,
|
|
||||||
(guint) sizeof (gst_avi_index_entry),
|
|
||||||
(guint) (n * sizeof (gst_avi_index_entry)));
|
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
|
|
||||||
if (n > 0) {
|
|
||||||
*_entries_list = g_list_reverse (entries_list);
|
|
||||||
} else {
|
|
||||||
g_free (entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
stamp = gst_util_get_timestamp () - stamp;
|
|
||||||
GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "parsing index %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (stamp));
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
out_of_mem:
|
|
||||||
{
|
|
||||||
GST_ELEMENT_ERROR (avi, RESOURCE, NO_SPACE_LEFT, (NULL),
|
|
||||||
("Cannot allocate memory for %u*%u=%u bytes",
|
|
||||||
(guint) sizeof (gst_avi_index_entry), num,
|
|
||||||
(guint) sizeof (gst_avi_index_entry) * num));
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gst_avi_demux_stream_index:
|
* gst_avi_demux_stream_index:
|
||||||
* @avi: avi demuxer object.
|
* @avi: avi demuxer object.
|
||||||
|
@ -4241,218 +4058,6 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* Read data from one index entry
|
|
||||||
*/
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_avi_demux_process_next_entry (GstAviDemux * avi)
|
|
||||||
{
|
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
|
||||||
gboolean processed = FALSE;
|
|
||||||
GstAviStream *stream;
|
|
||||||
gst_avi_index_entry *entry;
|
|
||||||
GstBuffer *buf;
|
|
||||||
|
|
||||||
do {
|
|
||||||
/* see if we are at the end */
|
|
||||||
if ((avi->segment.rate > 0 && avi->current_entry >= avi->index_size))
|
|
||||||
goto eos;
|
|
||||||
|
|
||||||
/* get next entry, this will work as we checked for the index size above */
|
|
||||||
entry = &avi->index_entries[avi->current_entry++];
|
|
||||||
|
|
||||||
/* check for reverse playback */
|
|
||||||
if (avi->segment.rate < 0 && avi->current_entry > avi->reverse_stop_index) {
|
|
||||||
GST_LOG_OBJECT (avi, "stop_index %d reached", avi->reverse_stop_index);
|
|
||||||
|
|
||||||
/* check if we have pushed enough data for this segment */
|
|
||||||
if (avi->reverse_start_index == 0)
|
|
||||||
goto eos_reverse_zero;
|
|
||||||
if (avi->index_entries[avi->reverse_start_index].ts < avi->segment.start)
|
|
||||||
goto eos_reverse_segment;
|
|
||||||
|
|
||||||
if (!(entry = gst_avi_demux_step_reverse (avi)))
|
|
||||||
goto eos;
|
|
||||||
|
|
||||||
avi->current_entry++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* see if we have a valid stream, ignore if not
|
|
||||||
* FIXME: can't we check this when building the index?
|
|
||||||
* we check it in _parse_index(), _stream_scan()
|
|
||||||
*/
|
|
||||||
if (entry->stream_nr >= avi->num_streams) {
|
|
||||||
GST_WARNING_OBJECT (avi,
|
|
||||||
"Entry %d has non-existing stream nr %d",
|
|
||||||
avi->current_entry - 1, entry->stream_nr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get stream now */
|
|
||||||
stream = &avi->stream[entry->stream_nr];
|
|
||||||
|
|
||||||
if (avi->segment.rate > 0.0) {
|
|
||||||
/* only check this for fowards playback for now */
|
|
||||||
if ((entry->flags & GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME)
|
|
||||||
&& GST_CLOCK_TIME_IS_VALID (entry->ts)
|
|
||||||
&& GST_CLOCK_TIME_IS_VALID (avi->segment.stop)
|
|
||||||
&& (entry->ts > avi->segment.stop)) {
|
|
||||||
goto eos_stop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* skip empty entries */
|
|
||||||
if (entry->size == 0 || !stream->pad) {
|
|
||||||
GST_DEBUG_OBJECT (avi, "Skipping entry %d (%d, %p)",
|
|
||||||
avi->current_entry - 1, entry->size, stream->pad);
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_LOG ("reading buffer (size=%d) from stream %d at current pos %"
|
|
||||||
G_GUINT64_FORMAT " (%llx)", entry->size, entry->stream_nr,
|
|
||||||
avi->index_offset + entry->offset, avi->index_offset + entry->offset);
|
|
||||||
|
|
||||||
/* pull in the data */
|
|
||||||
res = gst_pad_pull_range (avi->sinkpad, entry->offset +
|
|
||||||
avi->index_offset, entry->size, &buf);
|
|
||||||
if (res != GST_FLOW_OK)
|
|
||||||
goto pull_failed;
|
|
||||||
|
|
||||||
/* check for short buffers, this is EOS as well */
|
|
||||||
if (GST_BUFFER_SIZE (buf) < entry->size)
|
|
||||||
goto short_buffer;
|
|
||||||
|
|
||||||
/* invert the picture if needed */
|
|
||||||
buf = gst_avi_demux_invert (stream, buf);
|
|
||||||
|
|
||||||
/* mark non-keyframes */
|
|
||||||
if (!(entry->flags & GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME))
|
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) = entry->ts;
|
|
||||||
GST_BUFFER_DURATION (buf) = entry->dur;
|
|
||||||
if (stream->strh->type == GST_RIFF_FCC_vids) {
|
|
||||||
if (stream->current_frame >= 0)
|
|
||||||
GST_BUFFER_OFFSET (buf) = stream->current_frame;
|
|
||||||
else {
|
|
||||||
gint64 framenum;
|
|
||||||
GstFormat fmt = GST_FORMAT_DEFAULT;
|
|
||||||
|
|
||||||
if (gst_pad_query_convert (stream->pad, GST_FORMAT_TIME, entry->ts,
|
|
||||||
&fmt, &framenum))
|
|
||||||
GST_BUFFER_OFFSET (buf) = framenum;
|
|
||||||
else
|
|
||||||
GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
|
|
||||||
GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET_NONE;
|
|
||||||
gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (avi, "Pushing buffer of size %d, offset %"
|
|
||||||
G_GUINT64_FORMAT " and time %"
|
|
||||||
GST_TIME_FORMAT " on pad %s",
|
|
||||||
GST_BUFFER_SIZE (buf), GST_BUFFER_OFFSET (buf),
|
|
||||||
GST_TIME_ARGS (entry->ts), GST_PAD_NAME (stream->pad));
|
|
||||||
|
|
||||||
/* update current position in the segment */
|
|
||||||
gst_segment_set_last_stop (&avi->segment, GST_FORMAT_TIME, entry->ts);
|
|
||||||
|
|
||||||
/* mark discont when pending */
|
|
||||||
if (stream->discont) {
|
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
|
||||||
stream->discont = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = gst_pad_push (stream->pad, buf);
|
|
||||||
|
|
||||||
/* mark as processed, we increment the frame and byte counters then
|
|
||||||
* leave the while loop and return the GstFlowReturn */
|
|
||||||
processed = TRUE;
|
|
||||||
GST_DEBUG_OBJECT (avi, "Processed buffer %d: %s", entry->index_nr,
|
|
||||||
gst_flow_get_name (res));
|
|
||||||
|
|
||||||
if (avi->segment.rate < 0
|
|
||||||
&& entry->ts > avi->segment.stop && res == GST_FLOW_UNEXPECTED) {
|
|
||||||
/* In reverse playback we can get a GST_FLOW_UNEXPECTED when
|
|
||||||
* we are at the end of the segment, so we just need to jump
|
|
||||||
* back to the previous section.
|
|
||||||
*/
|
|
||||||
GST_DEBUG_OBJECT (avi, "downstream has reached end of segment");
|
|
||||||
|
|
||||||
if (!(entry = gst_avi_demux_step_reverse (avi)))
|
|
||||||
goto eos;
|
|
||||||
|
|
||||||
res = GST_FLOW_OK;
|
|
||||||
|
|
||||||
stream->current_frame = entry->frames_before;
|
|
||||||
stream->current_byte = entry->bytes_before;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* combine flows */
|
|
||||||
res = gst_avi_demux_combine_flows (avi, stream, res);
|
|
||||||
|
|
||||||
next:
|
|
||||||
stream->current_frame = entry->frames_before + 1;
|
|
||||||
stream->current_byte = entry->bytes_before + entry->size;
|
|
||||||
} while (!processed);
|
|
||||||
|
|
||||||
beach:
|
|
||||||
GST_DEBUG_OBJECT (avi, "returning %s", gst_flow_get_name (res));
|
|
||||||
|
|
||||||
return res;
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
eos:
|
|
||||||
{
|
|
||||||
GST_LOG_OBJECT (avi, "Handled last index entry, setting EOS (%d > %d)",
|
|
||||||
avi->current_entry, avi->index_size);
|
|
||||||
/* we mark the first stream as EOS */
|
|
||||||
res = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
eos_stop:
|
|
||||||
{
|
|
||||||
GST_LOG_OBJECT (avi, "Found keyframe after segment,"
|
|
||||||
" setting EOS (%" GST_TIME_FORMAT " > %" GST_TIME_FORMAT ")",
|
|
||||||
GST_TIME_ARGS (entry->ts), GST_TIME_ARGS (avi->segment.stop));
|
|
||||||
res = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
eos_reverse_zero:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (avi, "start_index was 0, setting EOS");
|
|
||||||
res = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
eos_reverse_segment:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (avi, "full segment pushed, setting EOS");
|
|
||||||
res = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
pull_failed:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (avi,
|
|
||||||
"pull range failed: pos=%" G_GUINT64_FORMAT " size=%d",
|
|
||||||
entry->offset + avi->index_offset, entry->size);
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
short_buffer:
|
|
||||||
{
|
|
||||||
GST_WARNING_OBJECT (avi, "Short read at offset %" G_GUINT64_FORMAT
|
|
||||||
", only got %d/%d bytes (truncated file?)", entry->offset +
|
|
||||||
avi->index_offset, GST_BUFFER_SIZE (buf), entry->size);
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
res = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* move @stream to the next position in its index */
|
/* move @stream to the next position in its index */
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_avi_demux_advance (GstAviDemux * avi, GstAviStream * stream,
|
gst_avi_demux_advance (GstAviDemux * avi, GstAviStream * stream,
|
||||||
|
@ -4705,15 +4310,6 @@ short_buffer:
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
eos_stream:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (avi, "No samples left for stream");
|
|
||||||
/* EOS will be raised if all are EOS */
|
|
||||||
ret = GST_FLOW_OK;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue