summaryrefslogtreecommitdiff
path: root/libavformat/avidec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-09 09:22:36 +0200
committerAnton Khirnov <anton@khirnov.net>2020-10-28 14:59:28 +0100
commitcea7c19cda0ea1630ae1de8c102ab14231b9db10 (patch)
tree9e703af026f15d976d79a0811566043ccb95ec9f /libavformat/avidec.c
parent7e87288f73242dac6344e65f892569102893fac0 (diff)
lavf: move AVStream.*index_entries* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. Since there are some (semi-)public fields located after these, even though this section is supposed to be private, keep some dummy padding there until the next major bump to preserve ABI compatibility.
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r--libavformat/avidec.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 866e87d23b..578cf68ce1 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -272,7 +272,7 @@ static void clean_index(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data;
- int n = st->nb_index_entries;
+ int n = st->internal->nb_index_entries;
int max = ast->sample_size;
int64_t pos, size, ts;
@@ -282,9 +282,9 @@ static void clean_index(AVFormatContext *s)
while (max < 1024)
max += max;
- pos = st->index_entries[0].pos;
- size = st->index_entries[0].size;
- ts = st->index_entries[0].timestamp;
+ pos = st->internal->index_entries[0].pos;
+ size = st->internal->index_entries[0].size;
+ ts = st->internal->index_entries[0].timestamp;
for (j = 0; j < size; j += max)
av_add_index_entry(st, pos + j, ts + j, FFMIN(max, size - j), 0,
@@ -432,12 +432,12 @@ static int calculate_bitrate(AVFormatContext *s)
int64_t len = 0;
AVStream *st = s->streams[i];
- if (!st->nb_index_entries)
+ if (!st->internal->nb_index_entries)
continue;
- for (j = 0; j < st->nb_index_entries; j++)
- len += st->index_entries[j].size;
- maxpos = FFMAX(maxpos, st->index_entries[j-1].pos);
+ for (j = 0; j < st->internal->nb_index_entries; j++)
+ len += st->internal->index_entries[j].size;
+ maxpos = FFMAX(maxpos, st->internal->index_entries[j-1].pos);
lensum += len;
}
if (maxpos < av_rescale(avi->io_fsize, 9, 10)) // index does not cover the whole file
@@ -451,12 +451,12 @@ static int calculate_bitrate(AVFormatContext *s)
int64_t duration;
int64_t bitrate;
- for (j = 0; j < st->nb_index_entries; j++)
- len += st->index_entries[j].size;
+ for (j = 0; j < st->internal->nb_index_entries; j++)
+ len += st->internal->index_entries[j].size;
- if (st->nb_index_entries < 2 || st->codecpar->bit_rate > 0)
+ if (st->internal->nb_index_entries < 2 || st->codecpar->bit_rate > 0)
continue;
- duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
+ duration = st->internal->index_entries[j-1].timestamp - st->internal->index_entries[0].timestamp;
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
if (bitrate > 0) {
st->codecpar->bit_rate = bitrate;
@@ -1034,7 +1034,7 @@ end_of_header:
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->nb_index_entries)
+ if (st->internal->nb_index_entries)
break;
}
// DV-in-AVI cannot be non-interleaved, if set this must be
@@ -1320,8 +1320,8 @@ start_sync:
if (size) {
uint64_t pos = avio_tell(pb) - 8;
- if (!st->index_entries || !st->nb_index_entries ||
- st->index_entries[st->nb_index_entries - 1].pos < pos) {
+ if (!st->internal->index_entries || !st->internal->nb_index_entries ||
+ st->internal->index_entries[st->internal->nb_index_entries - 1].pos < pos) {
av_add_index_entry(st, pos, ast->frame_offset, size,
0, AVINDEX_KEYFRAME);
}
@@ -1351,10 +1351,10 @@ static int ni_prepare_read(AVFormatContext *s)
int64_t ts = ast->frame_offset;
int64_t last_ts;
- if (!st->nb_index_entries)
+ if (!st->internal->nb_index_entries)
continue;
- last_ts = st->index_entries[st->nb_index_entries - 1].timestamp;
+ last_ts = st->internal->index_entries[st->internal->nb_index_entries - 1].timestamp;
if (!ast->remaining && ts > last_ts)
continue;
@@ -1383,11 +1383,11 @@ static int ni_prepare_read(AVFormatContext *s)
} else {
i = av_index_search_timestamp(best_st, best_ts, AVSEEK_FLAG_ANY);
if (i >= 0)
- best_ast->frame_offset = best_st->index_entries[i].timestamp;
+ best_ast->frame_offset = best_st->internal->index_entries[i].timestamp;
}
if (i >= 0) {
- int64_t pos = best_st->index_entries[i].pos;
+ int64_t pos = best_st->internal->index_entries[i].pos;
pos += best_ast->packet_size - best_ast->remaining;
if (avio_seek(s->pb, pos + 8, SEEK_SET) < 0)
return AVERROR_EOF;
@@ -1397,7 +1397,7 @@ static int ni_prepare_read(AVFormatContext *s)
avi->stream_index = best_stream_index;
if (!best_ast->remaining)
best_ast->packet_size =
- best_ast->remaining = best_st->index_entries[i].size;
+ best_ast->remaining = best_st->internal->index_entries[i].size;
}
else
return AVERROR_EOF;
@@ -1487,15 +1487,15 @@ resync:
pkt->dts /= ast->sample_size;
pkt->stream_index = avi->stream_index;
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->internal->index_entries) {
AVIndexEntry *e;
int index;
index = av_index_search_timestamp(st, ast->frame_offset, AVSEEK_FLAG_ANY);
- e = &st->index_entries[index];
+ e = &st->internal->index_entries[index];
if (index >= 0 && e->timestamp == ast->frame_offset) {
- if (index == st->nb_index_entries-1) {
+ if (index == st->internal->nb_index_entries-1) {
int key=1;
uint32_t state=-1;
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
@@ -1531,7 +1531,7 @@ resync:
}
ast->seek_pos= 0;
- if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1) {
+ if (!avi->non_interleaved && st->internal->nb_index_entries>1 && avi->index_loaded>1) {
int64_t dts= av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q);
if (avi->dts_max < dts) {
@@ -1631,8 +1631,8 @@ static int avi_read_idx1(AVFormatContext *s, int size)
if (!anykey) {
for (index = 0; index < s->nb_streams; index++) {
st = s->streams[index];
- if (st->nb_index_entries)
- st->index_entries[0].flags |= AVINDEX_KEYFRAME;
+ if (st->internal->nb_index_entries)
+ st->internal->index_entries[0].flags |= AVINDEX_KEYFRAME;
}
}
return 0;
@@ -1657,16 +1657,16 @@ static int check_stream_max_drift(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data;
- int n = st->nb_index_entries;
- while (idx[i] < n && st->index_entries[idx[i]].pos < pos)
+ int n = st->internal->nb_index_entries;
+ while (idx[i] < n && st->internal->index_entries[idx[i]].pos < pos)
idx[i]++;
if (idx[i] < n) {
int64_t dts;
- dts = av_rescale_q(st->index_entries[idx[i]].timestamp /
+ dts = av_rescale_q(st->internal->index_entries[idx[i]].timestamp /
FFMAX(ast->sample_size, 1),
st->time_base, AV_TIME_BASE_Q);
min_dts = FFMIN(min_dts, dts);
- min_pos = FFMIN(min_pos, st->index_entries[idx[i]].pos);
+ min_pos = FFMIN(min_pos, st->internal->index_entries[idx[i]].pos);
}
}
for (i = 0; i < s->nb_streams; i++) {
@@ -1675,7 +1675,7 @@ static int check_stream_max_drift(AVFormatContext *s)
if (idx[i] && min_dts != INT64_MAX / 2) {
int64_t dts;
- dts = av_rescale_q(st->index_entries[idx[i] - 1].timestamp /
+ dts = av_rescale_q(st->internal->index_entries[idx[i] - 1].timestamp /
FFMAX(ast->sample_size, 1),
st->time_base, AV_TIME_BASE_Q);
max_dts = FFMAX(max_dts, dts);
@@ -1704,30 +1704,30 @@ static int guess_ni_flag(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- int n = st->nb_index_entries;
+ int n = st->internal->nb_index_entries;
unsigned int size;
if (n <= 0)
continue;
if (n >= 2) {
- int64_t pos = st->index_entries[0].pos;
+ int64_t pos = st->internal->index_entries[0].pos;
unsigned tag[2];
avio_seek(s->pb, pos, SEEK_SET);
tag[0] = avio_r8(s->pb);
tag[1] = avio_r8(s->pb);
avio_rl16(s->pb);
size = avio_rl32(s->pb);
- if (get_stream_idx(tag) == i && pos + size > st->index_entries[1].pos)
+ if (get_stream_idx(tag) == i && pos + size > st->internal->index_entries[1].pos)
last_start = INT64_MAX;
- if (get_stream_idx(tag) == i && size == st->index_entries[0].size + 8)
+ if (get_stream_idx(tag) == i && size == st->internal->index_entries[0].size + 8)
last_start = INT64_MAX;
}
- if (st->index_entries[0].pos > last_start)
- last_start = st->index_entries[0].pos;
- if (st->index_entries[n - 1].pos < first_end)
- first_end = st->index_entries[n - 1].pos;
+ if (st->internal->index_entries[0].pos > last_start)
+ last_start = st->internal->index_entries[0].pos;
+ if (st->internal->index_entries[n - 1].pos < first_end)
+ first_end = st->internal->index_entries[n - 1].pos;
}
avio_seek(s->pb, oldpos, SEEK_SET);
@@ -1815,20 +1815,20 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
timestamp * FFMAX(ast->sample_size, 1),
flags);
if (index < 0) {
- if (st->nb_index_entries > 0)
+ if (st->internal->nb_index_entries > 0)
av_log(s, AV_LOG_DEBUG, "Failed to find timestamp %"PRId64 " in index %"PRId64 " .. %"PRId64 "\n",
timestamp * FFMAX(ast->sample_size, 1),
- st->index_entries[0].timestamp,
- st->index_entries[st->nb_index_entries - 1].timestamp);
+ st->internal->index_entries[0].timestamp,
+ st->internal->index_entries[st->internal->nb_index_entries - 1].timestamp);
return AVERROR_INVALIDDATA;
}
/* find the position */
- pos = st->index_entries[index].pos;
- timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
+ pos = st->internal->index_entries[index].pos;
+ timestamp = st->internal->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
av_log(s, AV_LOG_TRACE, "XX %"PRId64" %d %"PRId64"\n",
- timestamp, index, st->index_entries[index].timestamp);
+ timestamp, index, st->internal->index_entries[index].timestamp);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
/* One and only one real stream for DV in AVI, and it has video */
@@ -1859,7 +1859,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
continue;
}
- if (st2->nb_index_entries <= 0)
+ if (st2->internal->nb_index_entries <= 0)
continue;
// av_assert1(st2->codecpar->block_align);
@@ -1873,14 +1873,14 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
(st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
- ast2->seek_pos = st2->index_entries[index].pos;
+ ast2->seek_pos = st2->internal->index_entries[index].pos;
pos_min = FFMIN(pos_min,ast2->seek_pos);
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
- if (ast2->sub_ctx || st2->nb_index_entries <= 0)
+ if (ast2->sub_ctx || st2->internal->nb_index_entries <= 0)
continue;
index = av_index_search_timestamp(
@@ -1889,9 +1889,9 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
flags | AVSEEK_FLAG_BACKWARD | (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
- while (!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min)
+ while (!avi->non_interleaved && index>0 && st2->internal->index_entries[index-1].pos >= pos_min)
index--;
- ast2->frame_offset = st2->index_entries[index].timestamp;
+ ast2->frame_offset = st2->internal->index_entries[index].timestamp;
}
/* do the seek */