Commit e995e239 authored by Jun Zhao's avatar Jun Zhao

lavf/flvdec: Cosmetics: Fix indentation for flv_read_packet

Commit e34ba5ec missed the indent
Signed-off-by: 's avatarJun Zhao <barryjzhao@tencent.com>
parent 24dac56e
...@@ -986,144 +986,144 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -986,144 +986,144 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
retry: retry:
/* pkt size is repeated at end. skip it */ /* pkt size is repeated at end. skip it */
pos = avio_tell(s->pb); pos = avio_tell(s->pb);
type = (avio_r8(s->pb) & 0x1F); type = (avio_r8(s->pb) & 0x1F);
orig_size = orig_size =
size = avio_rb24(s->pb); size = avio_rb24(s->pb);
flv->sum_flv_tag_size += size + 11; flv->sum_flv_tag_size += size + 11;
dts = avio_rb24(s->pb); dts = avio_rb24(s->pb);
dts |= (unsigned)avio_r8(s->pb) << 24; dts |= (unsigned)avio_r8(s->pb) << 24;
av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb)); av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb));
if (avio_feof(s->pb)) if (avio_feof(s->pb))
return AVERROR_EOF; return AVERROR_EOF;
avio_skip(s->pb, 3); /* stream id, always 0 */ avio_skip(s->pb, 3); /* stream id, always 0 */
flags = 0; flags = 0;
if (flv->validate_next < flv->validate_count) { if (flv->validate_next < flv->validate_count) {
int64_t validate_pos = flv->validate_index[flv->validate_next].pos; int64_t validate_pos = flv->validate_index[flv->validate_next].pos;
if (pos == validate_pos) { if (pos == validate_pos) {
if (FFABS(dts - flv->validate_index[flv->validate_next].dts) <= if (FFABS(dts - flv->validate_index[flv->validate_next].dts) <=
VALIDATE_INDEX_TS_THRESH) { VALIDATE_INDEX_TS_THRESH) {
flv->validate_next++; flv->validate_next++;
} else { } else {
clear_index_entries(s, validate_pos);
flv->validate_count = 0;
}
} else if (pos > validate_pos) {
clear_index_entries(s, validate_pos); clear_index_entries(s, validate_pos);
flv->validate_count = 0; flv->validate_count = 0;
} }
} else if (pos > validate_pos) {
clear_index_entries(s, validate_pos);
flv->validate_count = 0;
} }
}
if (size == 0) { if (size == 0) {
ret = FFERROR_REDO; ret = FFERROR_REDO;
goto leave; goto leave;
} }
next = size + avio_tell(s->pb); next = size + avio_tell(s->pb);
if (type == FLV_TAG_TYPE_AUDIO) { if (type == FLV_TAG_TYPE_AUDIO) {
stream_type = FLV_STREAM_TYPE_AUDIO; stream_type = FLV_STREAM_TYPE_AUDIO;
flags = avio_r8(s->pb); flags = avio_r8(s->pb);
size--; size--;
} else if (type == FLV_TAG_TYPE_VIDEO) { } else if (type == FLV_TAG_TYPE_VIDEO) {
stream_type = FLV_STREAM_TYPE_VIDEO; stream_type = FLV_STREAM_TYPE_VIDEO;
flags = avio_r8(s->pb); flags = avio_r8(s->pb);
size--; size--;
if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD)
goto skip; goto skip;
} else if (type == FLV_TAG_TYPE_META) { } else if (type == FLV_TAG_TYPE_META) {
stream_type=FLV_STREAM_TYPE_SUBTITLE; stream_type=FLV_STREAM_TYPE_SUBTITLE;
if (size > 13 + 1 + 4) { // Header-type metadata stuff if (size > 13 + 1 + 4) { // Header-type metadata stuff
int type; int type;
meta_pos = avio_tell(s->pb); meta_pos = avio_tell(s->pb);
type = flv_read_metabody(s, next); type = flv_read_metabody(s, next);
if (type == 0 && dts == 0 || type < 0) { if (type == 0 && dts == 0 || type < 0) {
if (type < 0 && flv->validate_count && if (type < 0 && flv->validate_count &&
flv->validate_index[0].pos > next && flv->validate_index[0].pos > next &&
flv->validate_index[0].pos - 4 < next flv->validate_index[0].pos - 4 < next
) { ) {
av_log(s, AV_LOG_WARNING, "Adjusting next position due to index mismatch\n"); av_log(s, AV_LOG_WARNING, "Adjusting next position due to index mismatch\n");
next = flv->validate_index[0].pos - 4; next = flv->validate_index[0].pos - 4;
}
goto skip;
} else if (type == TYPE_ONTEXTDATA) {
avpriv_request_sample(s, "OnTextData packet");
return flv_data_packet(s, pkt, dts, next);
} else if (type == TYPE_ONCAPTION) {
return flv_data_packet(s, pkt, dts, next);
} else if (type == TYPE_UNKNOWN) {
stream_type = FLV_STREAM_TYPE_DATA;
} }
avio_seek(s->pb, meta_pos, SEEK_SET); goto skip;
} } else if (type == TYPE_ONTEXTDATA) {
} else { avpriv_request_sample(s, "OnTextData packet");
av_log(s, AV_LOG_DEBUG, return flv_data_packet(s, pkt, dts, next);
"Skipping flv packet: type %d, size %d, flags %d.\n", } else if (type == TYPE_ONCAPTION) {
type, size, flags); return flv_data_packet(s, pkt, dts, next);
skip: } else if (type == TYPE_UNKNOWN) {
if (avio_seek(s->pb, next, SEEK_SET) != next) { stream_type = FLV_STREAM_TYPE_DATA;
// This can happen if flv_read_metabody above read past
// next, on a non-seekable input, and the preceding data has
// been flushed out from the IO buffer.
av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
return AVERROR_INVALIDDATA;
} }
ret = FFERROR_REDO; avio_seek(s->pb, meta_pos, SEEK_SET);
goto leave;
} }
} else {
/* skip empty data packets */ av_log(s, AV_LOG_DEBUG,
if (!size) { "Skipping flv packet: type %d, size %d, flags %d.\n",
ret = FFERROR_REDO; type, size, flags);
goto leave; skip:
if (avio_seek(s->pb, next, SEEK_SET) != next) {
// This can happen if flv_read_metabody above read past
// next, on a non-seekable input, and the preceding data has
// been flushed out from the IO buffer.
av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
return AVERROR_INVALIDDATA;
} }
ret = FFERROR_REDO;
goto leave;
}
/* now find stream */ /* skip empty data packets */
for (i = 0; i < s->nb_streams; i++) { if (!size) {
st = s->streams[i]; ret = FFERROR_REDO;
if (stream_type == FLV_STREAM_TYPE_AUDIO) { goto leave;
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && }
(s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(s->video_codec_id || flv_same_video_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
break;
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
break;
}
}
if (i == s->nb_streams) {
static const enum AVMediaType stream_types[] = {AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, AVMEDIA_TYPE_DATA};
st = create_stream(s, stream_types[stream_type]);
if (!st)
return AVERROR(ENOMEM);
/* now find stream */
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (stream_type == FLV_STREAM_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
(s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(s->video_codec_id || flv_same_video_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
break;
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
break;
} }
av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard); }
if (i == s->nb_streams) {
static const enum AVMediaType stream_types[] = {AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, AVMEDIA_TYPE_DATA};
st = create_stream(s, stream_types[stream_type]);
if (!st)
return AVERROR(ENOMEM);
if (flv->time_pos <= pos) { }
dts += flv->time_offset; av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard);
}
if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && if (flv->time_pos <= pos) {
((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || dts += flv->time_offset;
stream_type == FLV_STREAM_TYPE_AUDIO)) }
av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME);
if ( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || (stream_type == FLV_STREAM_TYPE_AUDIO))) if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && (stream_type == FLV_STREAM_TYPE_VIDEO))) ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY ||
|| st->discard >= AVDISCARD_ALL stream_type == FLV_STREAM_TYPE_AUDIO))
) { av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME);
avio_seek(s->pb, next, SEEK_SET);
ret = FFERROR_REDO; if ( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || (stream_type == FLV_STREAM_TYPE_AUDIO)))
goto leave; ||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && (stream_type == FLV_STREAM_TYPE_VIDEO)))
} || st->discard >= AVDISCARD_ALL
) {
avio_seek(s->pb, next, SEEK_SET);
ret = FFERROR_REDO;
goto leave;
}
// if not streamed and no duration from metadata then seek to end to find // if not streamed and no duration from metadata then seek to end to find
// the duration from the timestamps // the duration from the timestamps
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment