len = lens[(lentype_flags >> lentype_bit_offset) & 0x03];
/* will make caller bail out with a short read if there's not enough data */
- if (*p_size < len) {
+ if (G_UNLIKELY (*p_size < len)) {
GST_WARNING ("need %u bytes, but only %u bytes available", len, *p_size);
return -1;
}
{
AsfPayload *ret;
- if (stream->payloads->len == 0) {
+ if (G_UNLIKELY (stream->payloads->len == 0)) {
GST_DEBUG ("No previous fragments to merge with for stream %u", stream->id);
return NULL;
}
ret =
&g_array_index (stream->payloads, AsfPayload, stream->payloads->len - 1);
- if (ret->mo_size != payload->mo_size ||
- ret->mo_number != payload->mo_number || ret->mo_offset != 0) {
+ if (G_UNLIKELY (ret->mo_size != payload->mo_size ||
+ ret->mo_number != payload->mo_number || ret->mo_offset != 0)) {
GST_WARNING ("Previous fragment does not match continued fragment");
return NULL;
}
GST_DEBUG_OBJECT (demux, "Got payload for stream %d ts:%" GST_TIME_FORMAT,
stream->id, GST_TIME_ARGS (payload->ts));
/* remember the first timestamp in the stream */
- if (!GST_CLOCK_TIME_IS_VALID (demux->first_ts) &&
- GST_CLOCK_TIME_IS_VALID (payload->ts)) {
+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (demux->first_ts) &&
+ GST_CLOCK_TIME_IS_VALID (payload->ts))) {
GST_DEBUG_OBJECT (demux, "first ts: %" GST_TIME_FORMAT,
GST_TIME_ARGS (payload->ts));
demux->first_ts = payload->ts;
}
/* make timestamps start from 0 */
- if (demux->first_ts < payload->ts)
+ if (G_LIKELY (demux->first_ts < payload->ts))
payload->ts -= demux->first_ts;
else
payload->ts = 0;
idx_last = stream->payloads->len - 1;
prev = &g_array_index (stream->payloads, AsfPayload, idx_last);
- if (gst_asf_payload_is_complete (prev))
+ if (G_UNLIKELY (gst_asf_payload_is_complete (prev)))
break;
GST_DEBUG_OBJECT (demux, "Dropping incomplete fragmented media object "
* absolutely necessary after a seek (we don't push out payloads that are
* before the segment start until we have at least one that falls within the
* segment) */
- if (GST_CLOCK_TIME_IS_VALID (payload->ts) &&
- payload->ts < demux->segment.start && payload->keyframe) {
+ if (G_UNLIKELY (GST_CLOCK_TIME_IS_VALID (payload->ts) &&
+ payload->ts < demux->segment.start && payload->keyframe)) {
GST_DEBUG_OBJECT (demux, "Queueing keyframe before segment start, removing"
" %u previously-queued payloads, which would be out of segment too and"
" hence don't have to be decoded", stream->payloads->len);
}
/* remember the first queued timestamp for the segment */
- if (!GST_CLOCK_TIME_IS_VALID (demux->segment_ts) &&
- GST_CLOCK_TIME_IS_VALID (payload->ts)) {
+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (demux->segment_ts) &&
+ GST_CLOCK_TIME_IS_VALID (payload->ts))) {
GST_DEBUG_OBJECT (demux, "segment ts: %" GST_TIME_FORMAT,
GST_TIME_ARGS (payload->ts));
demux->segment_ts = payload->ts;
off = 8;
for (ext = stream->ext_props.payload_extensions; ext->len > 0; ++ext) {
- if (off + ext->len > payload->rep_data_len) {
+ if (G_UNLIKELY (off + ext->len > payload->rep_data_len)) {
GST_WARNING ("not enough replicated data for defined extensions");
return;
}
switch (ext->id) {
case ASF_PAYLOAD_EXTENSION_DURATION:
- if (ext->len == 2) {
+ if (G_LIKELY (ext->len == 2)) {
payload->duration =
GST_READ_UINT16_LE (payload->rep_data + off) * GST_MSECOND;
} else {
}
break;
case ASF_PAYLOAD_EXTENSION_SYSTEM_CONTENT:
- if (ext->len == 1) {
+ if (G_LIKELY (ext->len == 1)) {
guint8 data = payload->rep_data[off];
payload->interlaced = data & 0x1;
}
break;
case ASF_PAYLOAD_EXTENSION_SYSTEM_PIXEL_ASPECT_RATIO:
- if (ext->len == 2) {
+ if (G_LIKELY (ext->len == 2)) {
payload->par_x = payload->rep_data[off];
payload->par_y = payload->rep_data[off + 1];
GST_DEBUG ("PAR %d / %d", payload->par_x, payload->par_y);
guint payload_len;
guint stream_num;
- if (*p_size < 1) {
+ if (G_UNLIKELY (*p_size < 1)) {
GST_WARNING_OBJECT (demux, "Short packet!");
return FALSE;
}
GST_LOG_OBJECT (demux, "keyframe : %s", (payload.keyframe) ? "yes" : "no");
GST_LOG_OBJECT (demux, "compressed : %s", (is_compressed) ? "yes" : "no");
- if (*p_size < payload.rep_data_len) {
+ if (G_UNLIKELY (*p_size < payload.rep_data_len)) {
GST_WARNING_OBJECT (demux, "Short packet! rep_data_len=%u, size=%u",
payload.rep_data_len, *p_size);
return FALSE;
*p_data += payload.rep_data_len;
*p_size -= payload.rep_data_len;
- if (*p_size == 0) {
+ if (G_UNLIKELY (*p_size == 0)) {
GST_WARNING_OBJECT (demux, "payload without data!?");
return FALSE;
}
/* we use -1 as lentype for a single payload that's the size of the packet */
- if (lentype >= 0 && lentype <= 3) {
+ if (G_UNLIKELY ((lentype >= 0 && lentype <= 3))) {
payload_len = asf_packet_read_varlen_int (lentype, 0, p_data, p_size);
if (*p_size < payload_len) {
GST_WARNING_OBJECT (demux, "Short packet! payload_len=%u, size=%u",
stream = gst_asf_demux_get_stream (demux, stream_num);
- if (stream == NULL) {
+ if (G_UNLIKELY (stream == NULL)) {
GST_WARNING_OBJECT (demux, "Payload for unknown stream %u, skipping",
stream_num);
*p_data += payload_len;
return TRUE;
}
- if (!is_compressed) {
+ if (G_UNLIKELY (!is_compressed)) {
GST_LOG_OBJECT (demux, "replicated data length: %u", payload.rep_data_len);
if (payload.rep_data_len >= 8) {
++payload_data;
--payload_len;
- if (payload_len < sub_payload_len) {
+ if (G_UNLIKELY (payload_len < sub_payload_len)) {
GST_WARNING_OBJECT (demux, "Short payload! %u bytes left", payload_len);
return FALSE;
}
- if (sub_payload_len > 0) {
+ if (G_LIKELY (sub_payload_len > 0)) {
payload.buf = asf_packet_create_payload_buffer (packet,
&payload_data, &payload_len, sub_payload_len);
size = GST_BUFFER_SIZE (buf);
/* need at least two payload flag bytes, send time, and duration */
- if (size < 2 + 4 + 2)
+ if (G_UNLIKELY (size < 2 + 4 + 2))
goto short_packet;
packet.buf = buf;
packet.padding = asf_packet_read_varlen_int (flags1, 3, &data, &size);
- if (size < 6)
+ if (G_UNLIKELY (size < 6))
goto short_packet;
packet.send_time = GST_READ_UINT32_LE (data) * GST_MSECOND;
GST_LOG_OBJECT (demux, "duration : %" GST_TIME_FORMAT,
GST_TIME_ARGS (packet.duration));
- if (packet.padding == (guint) - 1 || size < packet.padding)
+ if (G_UNLIKELY (packet.padding == (guint) - 1 || size < packet.padding))
goto short_packet;
size -= packet.padding;
/* adjust available size for parsing if there's less actual packet data for
* parsing than there is data in bytes (for sample see bug 431318) */
- if (packet.length != 0 && packet.length < demux->packet_size) {
+ if (G_UNLIKELY (packet.length != 0 && packet.length < demux->packet_size)) {
GST_LOG_OBJECT (demux, "shortened packet, adjusting available data size");
size -= (demux->packet_size - packet.length);
}
if (has_multiple_payloads) {
guint i, num, lentype;
- if (size < 1)
+ if (G_UNLIKELY (size < 1))
goto short_packet;
num = (GST_READ_UINT8 (data) & 0x3F) >> 0;
ret = gst_asf_demux_parse_payload (demux, &packet, lentype, &data, &size);
- if (!ret) {
+ if (G_UNLIKELY (!ret)) {
GST_WARNING_OBJECT (demux, "Failed to parse payload %u/%u", i + 1, num);
break;
}
GstClockTime idx_time;
guint idx;
- if (demux->sidx_num_entries == 0 || demux->sidx_interval == 0)
+ if (G_UNLIKELY (demux->sidx_num_entries == 0 || demux->sidx_interval == 0))
return FALSE;
idx = (guint) ((seek_time + demux->preroll) / demux->sidx_interval);
/* FIXME: seek beyond end of file should result in immediate EOS from
* streaming thread instead of a failed seek */
- if (idx >= demux->sidx_num_entries)
+ if (G_UNLIKELY (idx >= demux->sidx_num_entries))
return FALSE;
*packet = demux->sidx_entries[idx].packet;
GST_TIME_FORMAT, GST_TIME_ARGS (seek_time), *packet,
GST_TIME_ARGS (idx_time));
- if (p_idx_time)
+ if (G_LIKELY (p_idx_time))
*p_idx_time = idx_time;
return TRUE;
gint64 seek_time;
guint packet, speed_count = 1;
- if (demux->seekable == FALSE || demux->packet_size == 0 ||
- demux->num_packets == 0 || demux->play_time == 0) {
+ if (G_UNLIKELY (demux->seekable == FALSE || demux->packet_size == 0 ||
+ demux->num_packets == 0 || demux->play_time == 0)) {
GST_LOG_OBJECT (demux, "stream is not seekable");
return FALSE;
}
- if (!demux->activated_streams) {
+ if (G_UNLIKELY (!demux->activated_streams)) {
GST_LOG_OBJECT (demux, "streams not yet activated, ignoring seek");
return FALSE;
}
gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,
&stop_type, &stop);
- if (format != GST_FORMAT_TIME) {
+ if (G_UNLIKELY (format != GST_FORMAT_TIME)) {
GST_LOG_OBJECT (demux, "seeking is only supported in TIME format");
return FALSE;
}
- if (rate <= 0.0) {
+ if (G_UNLIKELY (rate <= 0.0)) {
GST_LOG_OBJECT (demux, "backward playback is not supported yet");
return FALSE;
}
((flags & GST_SEEK_FLAG_ACCURATE) == GST_SEEK_FLAG_ACCURATE);
keyunit_sync = ((flags & GST_SEEK_FLAG_KEY_UNIT) == GST_SEEK_FLAG_KEY_UNIT);
- if (demux->streaming) {
+ if (G_UNLIKELY (demux->streaming)) {
/* support it safely needs more segment handling, e.g. closing etc */
if (!flush) {
GST_LOG_OBJECT (demux, "streaming; non-flushing seek not supported");
}
/* unlock the streaming thread */
- if (flush) {
+ if (G_LIKELY (flush)) {
gst_pad_push_event (demux->sinkpad, gst_event_new_flush_start ());
gst_asf_demux_send_event_unlocked (demux, gst_event_new_flush_start ());
} else {
/* we now can stop flushing, since we have the stream lock now */
gst_pad_push_event (demux->sinkpad, gst_event_new_flush_stop ());
- if (flush)
+ if (G_LIKELY (flush))
gst_asf_demux_send_event_unlocked (demux, gst_event_new_flush_stop ());
/* operating on copy of segment until we know the seek worked */
segment = demux->segment;
- if (demux->segment_running && !flush) {
+ if (G_UNLIKELY (demux->segment_running && !flush)) {
GstEvent *newseg;
/* create the segment event to close the current segment */
packet = demux->num_packets;
}
} else {
- if (keyunit_sync) {
+ if (G_LIKELY (keyunit_sync)) {
GST_DEBUG_OBJECT (demux, "key unit seek, adjust seek_time = %"
GST_TIME_FORMAT " to index_time = %" GST_TIME_FORMAT,
GST_TIME_ARGS (seek_time), GST_TIME_ARGS (idx_time));
flow = gst_pad_pull_range (demux->sinkpad, offset, size, p_buf);
- if (p_flow)
+ if (G_LIKELY (p_flow))
*p_flow = flow;
- if (flow != GST_FLOW_OK) {
+ if (G_UNLIKELY (flow != GST_FLOW_OK)) {
GST_DEBUG_OBJECT (demux, "flow %s pulling buffer at %" G_GUINT64_FORMAT
"+%u", gst_flow_get_name (flow), offset, size);
*p_buf = NULL;
g_assert (*p_buf != NULL);
- if (GST_BUFFER_SIZE (*p_buf) < size) {
+ if (G_UNLIKELY (GST_BUFFER_SIZE (*p_buf) < size)) {
GST_DEBUG_OBJECT (demux, "short read pulling buffer at %" G_GUINT64_FORMAT
"+%u (got only %u bytes)", offset, size, GST_BUFFER_SIZE (*p_buf));
gst_buffer_unref (*p_buf);
- if (p_flow)
+ if (G_LIKELY (p_flow))
*p_flow = GST_FLOW_UNEXPECTED;
*p_buf = NULL;
return FALSE;
offset = demux->index_offset;
- if (offset == 0) {
+ if (G_UNLIKELY (offset == 0)) {
GST_DEBUG_OBJECT (demux, "can't read indices, don't know index offset");
return;
}
gst_buffer_replace (&buf, NULL);
/* check for sanity */
- if (obj.size > (5 * 1024 * 1024)) {
+ if (G_UNLIKELY (obj.size > (5 * 1024 * 1024))) {
GST_DEBUG_OBJECT (demux, "implausible index object size, bailing out");
break;
}
- if (!gst_asf_demux_pull_data (demux, offset, obj.size, &buf, NULL))
+ if (G_UNLIKELY (!gst_asf_demux_pull_data (demux, offset, obj.size, &buf,
+ NULL)))
break;
GST_LOG_OBJECT (demux, "index object at offset 0x%" G_GINT64_MODIFIER "X"
flow = gst_asf_demux_process_object (demux, &buf->data, &obj.size);
gst_buffer_replace (&buf, NULL);
- if (flow != GST_FLOW_OK)
+ if (G_UNLIKELY (flow != GST_FLOW_OK))
break;
++num_read;
guint last_idx;
stream = &demux->stream[i];
- if (stream->payloads->len == 0) {
+ if (G_UNLIKELY (stream->payloads->len == 0)) {
++num_no_data;
GST_LOG_OBJECT (stream->pad, "no data queued");
continue;
GST_LOG_OBJECT (stream->pad, "checking if %" GST_TIME_FORMAT " > %"
GST_TIME_FORMAT, GST_TIME_ARGS (last_payload->ts),
GST_TIME_ARGS (preroll_time));
- if (last_payload->ts <= preroll_time) {
+ if (G_UNLIKELY (last_payload->ts <= preroll_time)) {
GST_LOG_OBJECT (stream->pad, "not beyond preroll point yet");
return FALSE;
}
}
- if (num_no_data == demux->num_streams)
+ if (G_UNLIKELY (num_no_data == demux->num_streams))
return FALSE;
return TRUE;
}
/* Do we have tags pending for this stream? */
- if (stream->pending_tags) {
+ if (G_UNLIKELY (stream->pending_tags)) {
GST_LOG_OBJECT (stream->pad, "%" GST_PTR_FORMAT, stream->pending_tags);
gst_element_found_tags_for_pad (GST_ELEMENT (demux), stream->pad,
stream->pending_tags);
/* We have the whole packet now so we should push the packet to
* the src pad now. First though we should check if we need to do
* descrambling */
- if (demux->span > 1) {
+ if (G_UNLIKELY (demux->span > 1)) {
gst_asf_demux_descramble_buffer (demux, stream, &payload->buf);
}
payload->buf = gst_buffer_make_metadata_writable (payload->buf);
- if (!payload->keyframe) {
+ if (G_LIKELY (!payload->keyframe)) {
GST_BUFFER_FLAG_SET (payload->buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
- if (stream->discont) {
+ if (G_UNLIKELY (stream->discont)) {
GST_DEBUG_OBJECT (stream->pad, "marking DISCONT on stream");
GST_BUFFER_FLAG_SET (payload->buf, GST_BUFFER_FLAG_DISCONT);
stream->discont = FALSE;
guint64 off;
guint n;
- if (demux->state == GST_ASF_DEMUX_STATE_HEADER) {
+ if (G_UNLIKELY (demux->state == GST_ASF_DEMUX_STATE_HEADER)) {
if (!gst_asf_demux_pull_headers (demux)) {
flow = GST_FLOW_ERROR;
goto pause;
g_assert (demux->state == GST_ASF_DEMUX_STATE_DATA);
- if (demux->num_packets != 0 && demux->packet >= demux->num_packets)
+ if (G_UNLIKELY (demux->num_packets != 0
+ && demux->packet >= demux->num_packets))
goto eos;
GST_LOG_OBJECT (demux, "packet %u/%u", (guint) demux->packet + 1,
gst_buffer_unref (buf);
- if (demux->num_packets > 0 && demux->packet >= demux->num_packets) {
+ if (G_UNLIKELY (demux->num_packets > 0
+ && demux->packet >= demux->num_packets)) {
GST_LOG_OBJECT (demux, "reached EOS");
goto eos;
}
- if (flow != GST_FLOW_OK) {
+ if (G_UNLIKELY (flow != GST_FLOW_OK)) {
GST_DEBUG_OBJECT (demux, "pushing complete payloads failed");
goto pause;
}
GST_TIME_FORMAT, GST_BUFFER_SIZE (buf), GST_BUFFER_OFFSET (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
- if (GST_BUFFER_IS_DISCONT (buf)) {
+ if (G_UNLIKELY (GST_BUFFER_IS_DISCONT (buf))) {
GST_DEBUG_OBJECT (demux, "received DISCONT");
gst_asf_demux_mark_discont (demux);
}
- if (!GST_CLOCK_TIME_IS_VALID (demux->in_gap) &&
- GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
+ if (G_UNLIKELY ((!GST_CLOCK_TIME_IS_VALID (demux->in_gap) &&
+ GST_BUFFER_TIMESTAMP_IS_VALID (buf)))) {
demux->in_gap = GST_BUFFER_TIMESTAMP (buf) - demux->in_segment.start;
GST_DEBUG_OBJECT (demux, "upstream segment start %" GST_TIME_FORMAT
", interpolation gap: %" GST_TIME_FORMAT,
GstBuffer *buf;
/* do not overshoot data section when streaming */
- if (demux->num_packets != 0 && demux->packet >= 0
- && demux->packet >= demux->num_packets)
+ if (G_UNLIKELY (demux->num_packets != 0 && demux->packet >= 0
+ && demux->packet >= demux->num_packets))
goto eos;
buf = gst_adapter_take_buffer (demux->adapter, data_size);
/* FIXME: maybe we should just skip broken packets and error out only
* after a few broken packets in a row? */
- if (!gst_asf_demux_parse_packet (demux, buf)) {
+ if (G_UNLIKELY (!gst_asf_demux_parse_packet (demux, buf))) {
GST_WARNING_OBJECT (demux, "Parse error");
}