ffmpeg-cvslog
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
October 2020
- 1 participants
- 392 discussions
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Tue Oct 20 19:37:28 2020 -0300| [7dac8ddb20ee663ca211bd8c152228536a884605] | committer: James Almer
avcodec/av1dec: don't derive loop filter delta parameters
This is now handled by CBS.
Signed-off-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7dac8ddb20ee663ca…
---
libavcodec/av1dec.c | 60 -----------------------------------------------------
libavcodec/av1dec.h | 3 ---
2 files changed, 63 deletions(-)
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index bb4295aa6f..e01ac6641a 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -26,54 +26,6 @@
#include "internal.h"
#include "profiles.h"
-static void setup_past_independence(AV1Frame *f)
-{
- f->loop_filter_delta_enabled = 1;
-
- f->loop_filter_ref_deltas[AV1_REF_FRAME_INTRA] = 1;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST] = 0;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST2] = 0;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST3] = 0;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_GOLDEN] = -1;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_BWDREF] = 0;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF2] = -1;
- f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF] = -1;
-
- f->loop_filter_mode_deltas[0] = 0;
- f->loop_filter_mode_deltas[1] = 0;
-}
-
-static void load_previous_and_update(AV1DecContext *s)
-{
- uint8_t primary_frame, prev_frame;
-
- primary_frame = s->raw_frame_header->primary_ref_frame;
- prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame];
- memcpy(s->cur_frame.loop_filter_ref_deltas,
- s->ref[prev_frame].loop_filter_ref_deltas,
- AV1_NUM_REF_FRAMES * sizeof(int8_t));
- memcpy(s->cur_frame.loop_filter_mode_deltas,
- s->ref[prev_frame].loop_filter_mode_deltas,
- 2 * sizeof(int8_t));
-
- if (s->raw_frame_header->loop_filter_delta_update) {
- for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
- if (s->raw_frame_header->update_ref_delta[i])
- s->cur_frame.loop_filter_ref_deltas[i] =
- s->raw_frame_header->loop_filter_ref_deltas[i];
- }
-
- for (int i = 0; i < 2; i++) {
- if (s->raw_frame_header->update_mode_delta[i])
- s->cur_frame.loop_filter_mode_deltas[i] =
- s->raw_frame_header->loop_filter_mode_deltas[i];
- }
- }
-
- s->cur_frame.loop_filter_delta_enabled =
- s->raw_frame_header->loop_filter_delta_enabled;
-}
-
static uint32_t inverse_recenter(int r, uint32_t v)
{
if (v > 2 * r)
@@ -363,13 +315,6 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
dst->spatial_id = src->spatial_id;
dst->temporal_id = src->temporal_id;
- dst->loop_filter_delta_enabled = src->loop_filter_delta_enabled;
- memcpy(dst->loop_filter_ref_deltas,
- src->loop_filter_ref_deltas,
- AV1_NUM_REF_FRAMES * sizeof(int8_t));
- memcpy(dst->loop_filter_mode_deltas,
- src->loop_filter_mode_deltas,
- 2 * sizeof(int8_t));
memcpy(dst->gm_type,
src->gm_type,
AV1_NUM_REF_FRAMES * sizeof(uint8_t));
@@ -645,11 +590,6 @@ static int get_current_frame(AVCodecContext *avctx)
return ret;
}
- if (s->raw_frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE)
- setup_past_independence(&s->cur_frame);
- else
- load_previous_and_update(s);
-
global_motion_params(s);
return ret;
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 63c958ca53..b58bc53961 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -39,9 +39,6 @@ typedef struct AV1Frame {
int temporal_id;
int spatial_id;
- uint8_t loop_filter_delta_enabled;
- int8_t loop_filter_ref_deltas[AV1_NUM_REF_FRAMES];
- int8_t loop_filter_mode_deltas[2];
uint8_t gm_type[AV1_NUM_REF_FRAMES];
int32_t gm_params[AV1_NUM_REF_FRAMES][6];
} AV1Frame;
1
0
28 Oct '20
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Tue Oct 20 18:20:24 2020 -0300| [5ed9f8c66c39af1d53e8b8339db81713d1585f4d] | committer: James Almer
avcodec/cbs_av1: infer segmentation parameters from reference frames
Partially implements setup_past_independence() and load_previous().
These ensures they are always set, even if the values were not coded
in the input bitstream and will not be coded in the output bitstream.
Reviewed-by: Mark Thompson <sw(a)jkqxz.net>
Signed-off-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ed9f8c66c39af1d5…
---
libavcodec/cbs_av1.h | 2 ++
libavcodec/cbs_av1_syntax_template.c | 29 ++++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 97aeee9795..a2d78e736f 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -416,6 +416,8 @@ typedef struct AV1ReferenceFrameState {
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
int8_t loop_filter_mode_deltas[2];
+ uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
+ int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
} AV1ReferenceFrameState;
typedef struct CodedBitstreamAV1Context {
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 137da5a860..f351b1de24 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -743,8 +743,11 @@ static int FUNC(quantization_params)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawFrameHeader *current)
{
+ CodedBitstreamAV1Context *priv = ctx->priv_data;
static const uint8_t bits[AV1_SEG_LVL_MAX] = { 8, 6, 6, 6, 6, 3, 0, 0 };
static const uint8_t sign[AV1_SEG_LVL_MAX] = { 1, 1, 1, 1, 1, 0, 0, 0 };
+ static const uint8_t default_feature_enabled[AV1_SEG_LVL_MAX] = { 0 };
+ static const int16_t default_feature_value[AV1_SEG_LVL_MAX] = { 0 };
int i, j, err;
flag(segmentation_enabled);
@@ -763,9 +766,22 @@ static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
flag(segmentation_update_data);
}
- if (current->segmentation_update_data) {
- for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
- for (j = 0; j < AV1_SEG_LVL_MAX; j++) {
+ for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
+ const uint8_t *ref_feature_enabled;
+ const int16_t *ref_feature_value;
+
+ if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) {
+ ref_feature_enabled = default_feature_enabled;
+ ref_feature_value = default_feature_value;
+ } else {
+ ref_feature_enabled =
+ priv->ref[current->ref_frame_idx[current->primary_ref_frame]].feature_enabled[i];
+ ref_feature_value =
+ priv->ref[current->ref_frame_idx[current->primary_ref_frame]].feature_value[i];
+ }
+
+ for (j = 0; j < AV1_SEG_LVL_MAX; j++) {
+ if (current->segmentation_update_data) {
flags(feature_enabled[i][j], 2, i, j);
if (current->feature_enabled[i][j] && bits[j] > 0) {
@@ -776,6 +792,9 @@ static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
} else {
infer(feature_value[i][j], 0);
}
+ } else {
+ infer(feature_enabled[i][j], ref_feature_enabled[j]);
+ infer(feature_value[i][j], ref_feature_value[j]);
}
}
}
@@ -1645,6 +1664,10 @@ update_refs:
sizeof(current->loop_filter_ref_deltas));
memcpy(priv->ref[i].loop_filter_mode_deltas, current->loop_filter_mode_deltas,
sizeof(current->loop_filter_mode_deltas));
+ memcpy(priv->ref[i].feature_enabled, current->feature_enabled,
+ sizeof(current->feature_enabled));
+ memcpy(priv->ref[i].feature_value, current->feature_value,
+ sizeof(current->feature_value));
}
}
1
0
28 Oct '20
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Tue Oct 20 17:48:31 2020 -0300| [5d1238f77fbd83e834b2f3066a60c29eb6f49ef8] | committer: James Almer
avcodec/cbs_av1: infer loop filter delta parameters from reference frames
Partially implements setup_past_independence() and load_previous().
These ensures they are always set, even if the values were not coded
in the input bitstream and will not be coded in the output bitstream.
Reviewed-by: Mark Thompson <sw(a)jkqxz.net>
Signed-off-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d1238f77fbd83e83…
---
libavcodec/cbs_av1.h | 3 +++
libavcodec/cbs_av1_syntax_template.c | 50 +++++++++++++++++++++++++++++-------
2 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 7a0c08c596..97aeee9795 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -413,6 +413,9 @@ typedef struct AV1ReferenceFrameState {
int subsampling_y; // RefSubsamplingY
int bit_depth; // RefBitDepth
int order_hint; // RefOrderHint
+
+ int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
+ int8_t loop_filter_mode_deltas[2];
} AV1ReferenceFrameState;
typedef struct CodedBitstreamAV1Context {
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index bcaa334134..137da5a860 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -837,6 +837,9 @@ static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawFrameHeader *current)
{
CodedBitstreamAV1Context *priv = ctx->priv_data;
+ static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] =
+ { 1, 0, 0, 0, -1, 0, -1, -1 };
+ static const int8_t default_loop_filter_mode_deltas[2] = { 0, 0 };
int i, err;
if (priv->coded_lossless || current->allow_intrabc) {
@@ -870,19 +873,44 @@ static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
flag(loop_filter_delta_enabled);
if (current->loop_filter_delta_enabled) {
+ const int8_t *ref_loop_filter_ref_deltas, *ref_loop_filter_mode_deltas;
+
+ if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) {
+ ref_loop_filter_ref_deltas = default_loop_filter_ref_deltas;
+ ref_loop_filter_mode_deltas = default_loop_filter_mode_deltas;
+ } else {
+ ref_loop_filter_ref_deltas =
+ priv->ref[current->ref_frame_idx[current->primary_ref_frame]].loop_filter_ref_deltas;
+ ref_loop_filter_mode_deltas =
+ priv->ref[current->ref_frame_idx[current->primary_ref_frame]].loop_filter_mode_deltas;
+ }
+
flag(loop_filter_delta_update);
- if (current->loop_filter_delta_update) {
- for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
+ for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
+ if (current->loop_filter_delta_update)
flags(update_ref_delta[i], 1, i);
- if (current->update_ref_delta[i])
- sus(1 + 6, loop_filter_ref_deltas[i], 1, i);
- }
- for (i = 0; i < 2; i++) {
+ else
+ infer(update_ref_delta[i], 0);
+ if (current->update_ref_delta[i])
+ sus(1 + 6, loop_filter_ref_deltas[i], 1, i);
+ else
+ infer(loop_filter_ref_deltas[i], ref_loop_filter_ref_deltas[i]);
+ }
+ for (i = 0; i < 2; i++) {
+ if (current->loop_filter_delta_update)
flags(update_mode_delta[i], 1, i);
- if (current->update_mode_delta[i])
- sus(1 + 6, loop_filter_mode_deltas[i], 1, i);
- }
+ else
+ infer(update_mode_delta[i], 0);
+ if (current->update_mode_delta[i])
+ sus(1 + 6, loop_filter_mode_deltas[i], 1, i);
+ else
+ infer(loop_filter_mode_deltas[i], ref_loop_filter_mode_deltas[i]);
}
+ } else {
+ for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++)
+ infer(loop_filter_ref_deltas[i], default_loop_filter_ref_deltas[i]);
+ for (i = 0; i < 2; i++)
+ infer(loop_filter_mode_deltas[i], default_loop_filter_mode_deltas[i]);
}
return 0;
@@ -1613,6 +1641,10 @@ update_refs:
.bit_depth = priv->bit_depth,
.order_hint = priv->order_hint,
};
+ memcpy(priv->ref[i].loop_filter_ref_deltas, current->loop_filter_ref_deltas,
+ sizeof(current->loop_filter_ref_deltas));
+ memcpy(priv->ref[i].loop_filter_mode_deltas, current->loop_filter_mode_deltas,
+ sizeof(current->loop_filter_mode_deltas));
}
}
1
0
28 Oct '20
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [744b7f2e91fad0953505c909bc2b0cebced03d28] | committer: Anton Khirnov
lavf: move AVStream.last_in_packet_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=744b7f2e91fad0953…
---
libavformat/avformat.h | 6 +-----
libavformat/internal.h | 5 +++++
libavformat/mux.c | 18 +++++++++---------
libavformat/mxfenc.c | 10 +++++-----
4 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index fc89db1838..4865c56cc3 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1079,13 +1079,9 @@ typedef struct AVStream {
enum AVStreamParseType need_parsing;
struct AVCodecParserContext *parser;
- /**
- * last packet in packet_buffer for this stream when muxing.
- */
- struct AVPacketList *last_in_packet_buffer;
-
#if LIBAVFORMAT_VERSION_MAJOR < 59
// kept for ABI compatibility only, do not access in any way
+ void *unused7;
AVProbeData unused6;
int64_t unused5[16+1];
void *unused2;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index b8e662b96e..49e82bfbca 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -338,6 +338,11 @@ struct AVStreamInternal {
AVRational display_aspect_ratio;
AVProbeData probe_data;
+
+ /**
+ * last packet in packet_buffer for this stream when muxing.
+ */
+ struct AVPacketList *last_in_packet_buffer;
};
#ifdef __GNUC__
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1a34ee7e96..d2a56d216b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -831,8 +831,8 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
av_packet_move_ref(&this_pktl->pkt, pkt);
pkt = &this_pktl->pkt;
- if (st->last_in_packet_buffer) {
- next_point = &(st->last_in_packet_buffer->next);
+ if (st->internal->last_in_packet_buffer) {
+ next_point = &(st->internal->last_in_packet_buffer->next);
} else {
next_point = &s->internal->packet_buffer;
}
@@ -876,7 +876,7 @@ next_non_null:
this_pktl->next = *next_point;
- st->last_in_packet_buffer = *next_point = this_pktl;
+ st->internal->last_in_packet_buffer = *next_point = this_pktl;
return 0;
}
@@ -926,7 +926,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
}
for (i = 0; i < s->nb_streams; i++) {
- if (s->streams[i]->last_in_packet_buffer) {
+ if (s->streams[i]->internal->last_in_packet_buffer) {
++stream_count;
} else if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
s->streams[i]->codecpar->codec_id != AV_CODEC_ID_VP8 &&
@@ -951,7 +951,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
for (i = 0; i < s->nb_streams; i++) {
int64_t last_dts;
- const AVPacketList *last = s->streams[i]->last_in_packet_buffer;
+ const AVPacketList *last = s->streams[i]->internal->last_in_packet_buffer;
if (!last)
continue;
@@ -1000,8 +1000,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
if (!s->internal->packet_buffer)
s->internal->packet_buffer_end = NULL;
- if (st->last_in_packet_buffer == pktl)
- st->last_in_packet_buffer = NULL;
+ if (st->internal->last_in_packet_buffer == pktl)
+ st->internal->last_in_packet_buffer = NULL;
av_packet_unref(&pktl->pkt);
av_freep(&pktl);
@@ -1019,8 +1019,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
if (!s->internal->packet_buffer)
s->internal->packet_buffer_end = NULL;
- if (st->last_in_packet_buffer == pktl)
- st->last_in_packet_buffer = NULL;
+ if (st->internal->last_in_packet_buffer == pktl)
+ st->internal->last_in_packet_buffer = NULL;
av_freep(&pktl);
return 1;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index cbb0fc5a6a..d8678c9d25 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3050,7 +3050,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
int i, stream_count = 0;
for (i = 0; i < s->nb_streams; i++)
- stream_count += !!s->streams[i]->last_in_packet_buffer;
+ stream_count += !!s->streams[i]->internal->last_in_packet_buffer;
if (stream_count && (s->nb_streams == stream_count || flush)) {
AVPacketList *pktl = s->internal->packet_buffer;
@@ -3061,8 +3061,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
if (!stream_count || pktl->pkt.stream_index == 0)
break;
// update last packet in packet buffer
- if (s->streams[pktl->pkt.stream_index]->last_in_packet_buffer != pktl)
- s->streams[pktl->pkt.stream_index]->last_in_packet_buffer = pktl;
+ if (s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer != pktl)
+ s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = pktl;
last = pktl;
pktl = pktl->next;
stream_count--;
@@ -3087,8 +3087,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
*out = pktl->pkt;
av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts);
s->internal->packet_buffer = pktl->next;
- if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
- s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
+ if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == pktl)
+ s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer= NULL;
if(!s->internal->packet_buffer)
s->internal->packet_buffer_end= NULL;
av_freep(&pktl);
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [30f5180ca6c05ce62b2f7d2ef56b1ce04951aa84] | committer: Anton Khirnov
lavf: move AVStream.probe_data to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30f5180ca6c05ce62…
---
libavformat/avformat.h | 2 +-
libavformat/internal.h | 2 ++
libavformat/utils.c | 5 +++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2f0573d561..fc89db1838 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1083,10 +1083,10 @@ typedef struct AVStream {
* last packet in packet_buffer for this stream when muxing.
*/
struct AVPacketList *last_in_packet_buffer;
- AVProbeData probe_data;
#if LIBAVFORMAT_VERSION_MAJOR < 59
// kept for ABI compatibility only, do not access in any way
+ AVProbeData unused6;
int64_t unused5[16+1];
void *unused2;
int unused3;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 23c2ce0dc3..b8e662b96e 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -336,6 +336,8 @@ struct AVStreamInternal {
* - decoding: Set by libavformat to calculate sample_aspect_ratio internally
*/
AVRational display_aspect_ratio;
+
+ AVProbeData probe_data;
};
#ifdef __GNUC__
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f1d8df636e..503e583ad0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -676,7 +676,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st)
static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{
if (st->internal->request_probe>0) {
- AVProbeData *pd = &st->probe_data;
+ AVProbeData *pd = &st->internal->probe_data;
int end;
av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets);
--st->probe_packets;
@@ -4343,6 +4343,8 @@ static void free_stream(AVStream **pst)
av_bsf_free(&st->internal->bsfc);
av_freep(&st->internal->priv_pts);
av_freep(&st->internal->index_entries);
+ av_freep(&st->internal->probe_data.buf);
+
av_bsf_free(&st->internal->extract_extradata.bsf);
av_packet_free(&st->internal->extract_extradata.pkt);
@@ -4354,7 +4356,6 @@ static void free_stream(AVStream **pst)
av_dict_free(&st->metadata);
avcodec_parameters_free(&st->codecpar);
- av_freep(&st->probe_data.buf);
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
avcodec_free_context(&st->codec);
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [91a98cc4ead6d871053011dafb72458a4e75fa8b] | committer: Anton Khirnov
lavf: move AVStream.pts_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91a98cc4ead6d8710…
---
libavformat/avformat.h | 3 +--
libavformat/internal.h | 4 ++++
libavformat/mux.c | 12 ++++++------
libavformat/utils.c | 14 +++++++-------
4 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5811e8e24e..2f0573d561 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1084,11 +1084,10 @@ typedef struct AVStream {
*/
struct AVPacketList *last_in_packet_buffer;
AVProbeData probe_data;
-#define MAX_REORDER_DELAY 16
- int64_t pts_buffer[MAX_REORDER_DELAY+1];
#if LIBAVFORMAT_VERSION_MAJOR < 59
// kept for ABI compatibility only, do not access in any way
+ int64_t unused5[16+1];
void *unused2;
int unused3;
unsigned int unused4;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index ce79da8000..23c2ce0dc3 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -308,12 +308,16 @@ struct AVStreamInternal {
*/
int update_initial_durations_done;
+#define MAX_REORDER_DELAY 16
+
/**
* Internal data to generate dts from pts
*/
int64_t pts_reorder_error[MAX_REORDER_DELAY+1];
uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1];
+ int64_t pts_buffer[MAX_REORDER_DELAY+1];
+
/**
* Internal data to analyze DTS and detect faulty mpeg streams
*/
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1cf885fbea..1a34ee7e96 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -595,13 +595,13 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
//calculate dts from pts
if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
- st->pts_buffer[0] = pkt->pts;
- for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
- st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
- for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
- FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
+ st->internal->pts_buffer[0] = pkt->pts;
+ for (i = 1; i < delay + 1 && st->internal->pts_buffer[i] == AV_NOPTS_VALUE; i++)
+ st->internal->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
+ for (i = 0; i<delay && st->internal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++)
+ FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]);
- pkt->dts = st->pts_buffer[0];
+ pkt->dts = st->internal->pts_buffer[0];
}
if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6ffc19517f..f1d8df636e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1357,12 +1357,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
}
if (pkt->pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
- st->pts_buffer[0] = pkt->pts;
- for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
- FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
+ st->internal->pts_buffer[0] = pkt->pts;
+ for (i = 0; i<delay && st->internal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++)
+ FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]);
if(has_decode_delay_been_guessed(st))
- pkt->dts = select_from_pts_buffer(st, st->pts_buffer, pkt->dts);
+ pkt->dts = select_from_pts_buffer(st, st->internal->pts_buffer, pkt->dts);
}
// We skipped it above so we try here.
if (!onein_oneout)
@@ -1886,7 +1886,7 @@ void ff_read_frame_flush(AVFormatContext *s)
st->probe_packets = s->max_probe_packets;
for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
- st->pts_buffer[j] = AV_NOPTS_VALUE;
+ st->internal->pts_buffer[j] = AV_NOPTS_VALUE;
if (s->internal->inject_global_side_data)
st->internal->inject_global_side_data = 1;
@@ -2867,7 +2867,7 @@ skip_duration_calc:
st->last_IP_pts = AV_NOPTS_VALUE;
st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
- st->pts_buffer[j] = AV_NOPTS_VALUE;
+ st->internal->pts_buffer[j] = AV_NOPTS_VALUE;
}
}
@@ -4526,7 +4526,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
st->last_IP_pts = AV_NOPTS_VALUE;
st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
for (i = 0; i < MAX_REORDER_DELAY + 1; i++)
- st->pts_buffer[i] = AV_NOPTS_VALUE;
+ st->internal->pts_buffer[i] = AV_NOPTS_VALUE;
st->sample_aspect_ratio = (AVRational) { 0, 1 };
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [cea7c19cda0ea1630ae1de8c102ab14231b9db10] | committer: Anton Khirnov
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cea7c19cda0ea1630…
---
libavformat/ape.c | 2 +-
libavformat/asfdec_f.c | 4 +-
libavformat/asfdec_o.c | 6 +-
libavformat/avformat.h | 10 ++-
libavformat/avidec.c | 100 ++++++++++++------------
libavformat/bink.c | 10 +--
libavformat/cafdec.c | 22 +++---
libavformat/cinedec.c | 2 +-
libavformat/dhav.c | 4 +-
libavformat/flacdec.c | 8 +-
libavformat/flic.c | 6 +-
libavformat/flvdec.c | 10 +--
libavformat/gxf.c | 6 +-
libavformat/ifv.c | 8 +-
libavformat/img2dec.c | 2 +-
libavformat/internal.h | 5 ++
libavformat/jvdec.c | 28 +++----
libavformat/matroskadec.c | 40 +++++-----
libavformat/mlvdec.c | 20 ++---
libavformat/mov.c | 190 +++++++++++++++++++++++-----------------------
libavformat/mp3dec.c | 6 +-
libavformat/mpc.c | 4 +-
libavformat/mpc8.c | 4 +-
libavformat/mux.c | 2 +-
libavformat/mvdec.c | 4 +-
libavformat/nsvdec.c | 4 +-
libavformat/nutdec.c | 6 +-
libavformat/nutenc.c | 12 +--
libavformat/rl2.c | 8 +-
libavformat/rpl.c | 4 +-
libavformat/segafilm.c | 2 +-
libavformat/tta.c | 8 +-
libavformat/utils.c | 46 +++++------
libavformat/vocdec.c | 8 +-
34 files changed, 304 insertions(+), 297 deletions(-)
diff --git a/libavformat/ape.c b/libavformat/ape.c
index 2698c770ee..4c161235fe 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -444,7 +444,7 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
if (index < 0)
return -1;
- if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET)) < 0)
return ret;
ape->currentframe = index;
return 0;
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index e0fee8301e..8e48e457d9 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -1682,11 +1682,11 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
asf->index_read = -1;
}
- if (asf->index_read > 0 && st->index_entries) {
+ if (asf->index_read > 0 && st->internal->index_entries) {
int index = av_index_search_timestamp(st, pts, flags);
if (index >= 0) {
/* find the position */
- uint64_t pos = st->index_entries[index].pos;
+ uint64_t pos = st->internal->index_entries[index].pos;
/* do the seek */
av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 1b10e47907..b142f83541 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1640,11 +1640,11 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
ASFContext *asf = s->priv_data;
int idx, ret;
- if (s->streams[stream_index]->nb_index_entries && asf->is_simple_index) {
+ if (s->streams[stream_index]->internal->nb_index_entries && asf->is_simple_index) {
idx = av_index_search_timestamp(s->streams[stream_index], timestamp, flags);
- if (idx < 0 || idx >= s->streams[stream_index]->nb_index_entries)
+ if (idx < 0 || idx >= s->streams[stream_index]->internal->nb_index_entries)
return AVERROR_INVALIDDATA;
- avio_seek(s->pb, s->streams[stream_index]->index_entries[idx].pos, SEEK_SET);
+ avio_seek(s->pb, s->streams[stream_index]->internal->index_entries[idx].pos, SEEK_SET);
} else {
if ((ret = ff_seek_frame_binary(s, stream_index, timestamp, flags)) < 0)
return ret;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index ae32f78393..5811e8e24e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1087,10 +1087,12 @@ typedef struct AVStream {
#define MAX_REORDER_DELAY 16
int64_t pts_buffer[MAX_REORDER_DELAY+1];
- AVIndexEntry *index_entries; /**< Only used if the format does not
- support seeking natively. */
- int nb_index_entries;
- unsigned int index_entries_allocated_size;
+#if LIBAVFORMAT_VERSION_MAJOR < 59
+ // kept for ABI compatibility only, do not access in any way
+ void *unused2;
+ int unused3;
+ unsigned int unused4;
+#endif
/**
* Stream Identifier
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 */
diff --git a/libavformat/bink.c b/libavformat/bink.c
index 08125ba8f1..99bbd27ef3 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -225,8 +225,8 @@ static int read_header(AVFormatContext *s)
return ret;
}
- if (vst->index_entries)
- avio_seek(pb, vst->index_entries[0].pos + bink->smush_size, SEEK_SET);
+ if (vst->internal->index_entries)
+ avio_seek(pb, vst->internal->index_entries[0].pos + bink->smush_size, SEEK_SET);
else
avio_skip(pb, 4);
@@ -256,8 +256,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
}
- bink->remain_packet_size = st->index_entries[index_entry].size;
- bink->flags = st->index_entries[index_entry].flags;
+ bink->remain_packet_size = st->internal->index_entries[index_entry].size;
+ bink->flags = st->internal->index_entries[index_entry].flags;
bink->current_track = 0;
}
@@ -313,7 +313,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
return -1;
/* seek to the first frame */
- ret = avio_seek(s->pb, vst->index_entries[0].pos + bink->smush_size, SEEK_SET);
+ ret = avio_seek(s->pb, vst->internal->index_entries[0].pos + bink->smush_size, SEEK_SET);
if (ret < 0)
return ret;
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index d0f942f3e4..3bf1fa64bc 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -329,7 +329,7 @@ found_data:
if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
if (caf->data_size > 0)
st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
- } else if (st->nb_index_entries && st->duration > 0) {
+ } else if (st->internal->nb_index_entries && st->duration > 0) {
if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) {
av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %d * 8 * %"PRId64"\n",
st->codecpar->sample_rate, caf->data_size / st->duration);
@@ -382,13 +382,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt_size = (CAF_MAX_PKT_SIZE / pkt_size) * pkt_size;
pkt_size = FFMIN(pkt_size, left);
pkt_frames = pkt_size / caf->bytes_per_packet;
- } else if (st->nb_index_entries) {
- if (caf->packet_cnt < st->nb_index_entries - 1) {
- pkt_size = st->index_entries[caf->packet_cnt + 1].pos - st->index_entries[caf->packet_cnt].pos;
- pkt_frames = st->index_entries[caf->packet_cnt + 1].timestamp - st->index_entries[caf->packet_cnt].timestamp;
- } else if (caf->packet_cnt == st->nb_index_entries - 1) {
- pkt_size = caf->num_bytes - st->index_entries[caf->packet_cnt].pos;
- pkt_frames = st->duration - st->index_entries[caf->packet_cnt].timestamp;
+ } else if (st->internal->nb_index_entries) {
+ if (caf->packet_cnt < st->internal->nb_index_entries - 1) {
+ pkt_size = st->internal->index_entries[caf->packet_cnt + 1].pos - st->internal->index_entries[caf->packet_cnt].pos;
+ pkt_frames = st->internal->index_entries[caf->packet_cnt + 1].timestamp - st->internal->index_entries[caf->packet_cnt].timestamp;
+ } else if (caf->packet_cnt == st->internal->nb_index_entries - 1) {
+ pkt_size = caf->num_bytes - st->internal->index_entries[caf->packet_cnt].pos;
+ pkt_frames = st->duration - st->internal->index_entries[caf->packet_cnt].timestamp;
} else {
return AVERROR(EIO);
}
@@ -427,10 +427,10 @@ static int read_seek(AVFormatContext *s, int stream_index,
pos = FFMIN(pos, caf->data_size);
packet_cnt = pos / caf->bytes_per_packet;
frame_cnt = caf->frames_per_packet * packet_cnt;
- } else if (st->nb_index_entries) {
+ } else if (st->internal->nb_index_entries) {
packet_cnt = av_index_search_timestamp(st, timestamp, flags);
- frame_cnt = st->index_entries[packet_cnt].timestamp;
- pos = st->index_entries[packet_cnt].pos;
+ frame_cnt = st->internal->index_entries[packet_cnt].timestamp;
+ pos = st->internal->index_entries[packet_cnt].pos;
} else {
return -1;
}
diff --git a/libavformat/cinedec.c b/libavformat/cinedec.c
index 0f2453cdf5..c6c0d927ee 100644
--- a/libavformat/cinedec.c
+++ b/libavformat/cinedec.c
@@ -291,7 +291,7 @@ static int cine_read_packet(AVFormatContext *avctx, AVPacket *pkt)
if (cine->pts >= st->duration)
return AVERROR_EOF;
- avio_seek(pb, st->index_entries[cine->pts].pos, SEEK_SET);
+ avio_seek(pb, st->internal->index_entries[cine->pts].pos, SEEK_SET);
n = avio_rl32(pb);
if (n < 8)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/dhav.c b/libavformat/dhav.c
index 79afe9be03..53deaff77e 100644
--- a/libavformat/dhav.c
+++ b/libavformat/dhav.c
@@ -441,10 +441,10 @@ static int dhav_read_seek(AVFormatContext *s, int stream_index,
if (index < 0)
return -1;
- if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0)
return -1;
- pts = st->index_entries[index].timestamp;
+ pts = st->internal->index_entries[index].timestamp;
for (int n = 0; n < s->nb_streams; n++) {
AVStream *st = s->streams[n];
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 79c05f14bf..6aca4755a1 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -40,8 +40,8 @@ static void reset_index_position(int64_t metadata_head_size, AVStream *st)
{
/* the real seek index offset should be the size of metadata blocks with the offset in the frame blocks */
int i;
- for(i=0; i<st->nb_index_entries; i++) {
- st->index_entries[i].pos += metadata_head_size;
+ for(i=0; i<st->internal->nb_index_entries; i++) {
+ st->internal->index_entries[i].pos += metadata_head_size;
}
}
@@ -319,10 +319,10 @@ static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
}
index = av_index_search_timestamp(s->streams[0], timestamp, flags);
- if(index<0 || index >= s->streams[0]->nb_index_entries)
+ if(index<0 || index >= s->streams[0]->internal->nb_index_entries)
return -1;
- e = s->streams[0]->index_entries[index];
+ e = s->streams[0]->internal->index_entries[index];
pos = avio_seek(s->pb, e.pos, SEEK_SET);
if (pos >= 0) {
return 0;
diff --git a/libavformat/flic.c b/libavformat/flic.c
index 4552bff69c..9a7b8081ed 100644
--- a/libavformat/flic.c
+++ b/libavformat/flic.c
@@ -268,7 +268,7 @@ static int flic_read_seek(AVFormatContext *s, int stream_index,
int64_t pos, ts;
int index;
- if (!st->index_entries || stream_index != flic->video_stream_index)
+ if (!st->internal->index_entries || stream_index != flic->video_stream_index)
return -1;
index = av_index_search_timestamp(st, pts, flags);
@@ -278,8 +278,8 @@ static int flic_read_seek(AVFormatContext *s, int stream_index,
if (index < 0)
return -1;
- pos = st->index_entries[index].pos;
- ts = st->index_entries[index].timestamp;
+ pos = st->internal->index_entries[index].pos;
+ ts = st->internal->index_entries[index].timestamp;
flic->frame_number = ts;
avio_seek(s->pb, pos, SEEK_SET);
return 0;
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index ac9f9c77db..ad6e7a3ca5 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -140,7 +140,7 @@ static void add_keyframes_index(AVFormatContext *s)
av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
stream = s->streams[flv->last_keyframe_stream_index];
- if (stream->nb_index_entries == 0) {
+ if (stream->internal->nb_index_entries == 0) {
for (i = 0; i < flv->keyframe_count; i++) {
av_log(s, AV_LOG_TRACE, "keyframe filepositions = %"PRId64" times = %"PRId64"\n",
flv->keyframe_filepositions[i], flv->keyframe_times[i] * 1000);
@@ -830,10 +830,10 @@ static void clear_index_entries(AVFormatContext *s, int64_t pos)
AVStream *st = s->streams[i];
/* Remove all index entries that point to >= pos */
out = 0;
- for (j = 0; j < st->nb_index_entries; j++)
- if (st->index_entries[j].pos < pos)
- st->index_entries[out++] = st->index_entries[j];
- st->nb_index_entries = out;
+ for (j = 0; j < st->internal->nb_index_entries; j++)
+ if (st->internal->index_entries[j].pos < pos)
+ st->internal->index_entries[out++] = st->internal->index_entries[j];
+ st->internal->nb_index_entries = out;
}
}
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 49364b7205..96b7035386 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -572,9 +572,9 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
if (idx < 0)
return -1;
- pos = st->index_entries[idx].pos;
- if (idx < st->nb_index_entries - 2)
- maxlen = st->index_entries[idx + 2].pos - pos;
+ pos = st->internal->index_entries[idx].pos;
+ if (idx < st->internal->nb_index_entries - 2)
+ maxlen = st->internal->index_entries[idx + 2].pos - pos;
maxlen = FFMAX(maxlen, 200 * 1024);
res = avio_seek(s->pb, pos, SEEK_SET);
if (res < 0)
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
index 4e904fa828..bca8f85d09 100644
--- a/libavformat/ifv.c
+++ b/libavformat/ifv.c
@@ -195,15 +195,15 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ifv->next_video_index < ifv->total_vframes) {
st = s->streams[ifv->video_stream_index];
- if (ifv->next_video_index < st->nb_index_entries)
- e_next = ev = &st->index_entries[ifv->next_video_index];
+ if (ifv->next_video_index < st->internal->nb_index_entries)
+ e_next = ev = &st->internal->index_entries[ifv->next_video_index];
}
if (ifv->is_audio_present &&
ifv->next_audio_index < ifv->total_aframes) {
st = s->streams[ifv->audio_stream_index];
- if (ifv->next_audio_index < st->nb_index_entries) {
- ea = &st->index_entries[ifv->next_audio_index];
+ if (ifv->next_audio_index < st->internal->nb_index_entries) {
+ ea = &st->internal->index_entries[ifv->next_audio_index];
if (!ev || ea->timestamp < ev->timestamp)
e_next = ea;
}
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 4f9bfc635a..a08d4f7977 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -587,7 +587,7 @@ static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0)
return -1;
- s1->img_number = st->index_entries[index].pos;
+ s1->img_number = st->internal->index_entries[index].pos;
return 0;
}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 87d62c51b2..ce79da8000 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -225,6 +225,11 @@ struct AVStreamInternal {
} *info;
+ AVIndexEntry *index_entries; /**< Only used if the format does not
+ support seeking natively. */
+ int nb_index_entries;
+ unsigned int index_entries_allocated_size;
+
int64_t interleaver_chunk_size;
int64_t interleaver_chunk_duration;
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 551f8069e6..47d18e2beb 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -92,7 +92,7 @@ static int read_header(AVFormatContext *s)
vst->codecpar->height = avio_rl16(pb);
vst->duration =
vst->nb_frames =
- ast->nb_index_entries = avio_rl16(pb);
+ ast->internal->nb_index_entries = avio_rl16(pb);
avpriv_set_pts_info(vst, 64, avio_rl16(pb), 1000);
avio_skip(pb, 4);
@@ -107,19 +107,19 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 10);
- ast->index_entries = av_malloc(ast->nb_index_entries *
- sizeof(*ast->index_entries));
- if (!ast->index_entries)
+ ast->internal->index_entries = av_malloc(ast->internal->nb_index_entries *
+ sizeof(*ast->internal->index_entries));
+ if (!ast->internal->index_entries)
return AVERROR(ENOMEM);
- jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame));
+ jv->frames = av_malloc(ast->internal->nb_index_entries * sizeof(JVFrame));
if (!jv->frames) {
- av_freep(&ast->index_entries);
+ av_freep(&ast->internal->index_entries);
return AVERROR(ENOMEM);
}
- offset = 0x68 + ast->nb_index_entries * 16;
- for (i = 0; i < ast->nb_index_entries; i++) {
- AVIndexEntry *e = ast->index_entries + i;
+ offset = 0x68 + ast->internal->nb_index_entries * 16;
+ for (i = 0; i < ast->internal->nb_index_entries; i++) {
+ AVIndexEntry *e = ast->internal->index_entries + i;
JVFrame *jvf = jv->frames + i;
/* total frame size including audio, video, palette data and padding */
@@ -139,7 +139,7 @@ static int read_header(AVFormatContext *s)
if (s->error_recognition & AV_EF_EXPLODE) {
read_close(s);
av_freep(&jv->frames);
- av_freep(&ast->index_entries);
+ av_freep(&ast->internal->index_entries);
return AVERROR_INVALIDDATA;
}
jvf->audio_size =
@@ -170,8 +170,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
AVStream *ast = s->streams[0];
int ret;
- while (!avio_feof(s->pb) && jv->pts < ast->nb_index_entries) {
- const AVIndexEntry *e = ast->index_entries + jv->pts;
+ while (!avio_feof(s->pb) && jv->pts < ast->internal->nb_index_entries) {
+ const AVIndexEntry *e = ast->internal->index_entries + jv->pts;
const JVFrame *jvf = jv->frames + jv->pts;
switch (jv->state) {
@@ -244,9 +244,9 @@ static int read_seek(AVFormatContext *s, int stream_index,
return 0;
}
- if (i < 0 || i >= ast->nb_index_entries)
+ if (i < 0 || i >= ast->internal->nb_index_entries)
return 0;
- if (avio_seek(s->pb, ast->index_entries[i].pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, ast->internal->index_entries[i].pos, SEEK_SET) < 0)
return -1;
jv->state = JV_AUDIO;
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index a183026359..981e044263 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3766,13 +3766,13 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
matroska_parse_cues(matroska);
}
- if (!st->nb_index_entries)
+ if (!st->internal->nb_index_entries)
goto err;
- timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
+ timestamp = FFMAX(timestamp, st->internal->index_entries[0].timestamp);
- if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 || index == st->nb_index_entries - 1) {
- matroska_reset_status(matroska, 0, st->index_entries[st->nb_index_entries - 1].pos);
- while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 || index == st->nb_index_entries - 1) {
+ if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 || index == st->internal->nb_index_entries - 1) {
+ matroska_reset_status(matroska, 0, st->internal->index_entries[st->internal->nb_index_entries - 1].pos);
+ while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 || index == st->internal->nb_index_entries - 1) {
matroska_clear_queue(matroska);
if (matroska_parse_cluster(matroska) < 0)
break;
@@ -3780,7 +3780,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
matroska_clear_queue(matroska);
- if (index < 0 || (matroska->cues_parsing_deferred < 0 && index == st->nb_index_entries - 1))
+ if (index < 0 || (matroska->cues_parsing_deferred < 0 && index == st->internal->nb_index_entries - 1))
goto err;
tracks = matroska->tracks.elem;
@@ -3792,17 +3792,17 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
/* We seek to a level 1 element, so set the appropriate status. */
- matroska_reset_status(matroska, 0, st->index_entries[index].pos);
+ matroska_reset_status(matroska, 0, st->internal->index_entries[index].pos);
if (flags & AVSEEK_FLAG_ANY) {
st->internal->skip_to_keyframe = 0;
matroska->skip_to_timecode = timestamp;
} else {
st->internal->skip_to_keyframe = 1;
- matroska->skip_to_timecode = st->index_entries[index].timestamp;
+ matroska->skip_to_timecode = st->internal->index_entries[index].timestamp;
}
matroska->skip_to_keyframe = 1;
matroska->done = 0;
- ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
+ ff_update_cur_dts(s, st, st->internal->index_entries[index].timestamp);
return 0;
err:
// slightly hackish but allows proper fallback to
@@ -3847,8 +3847,8 @@ static CueDesc get_cue_desc(AVFormatContext *s, int64_t ts, int64_t cues_start)
MatroskaDemuxContext *matroska = s->priv_data;
CueDesc cue_desc;
int i;
- int nb_index_entries = s->streams[0]->nb_index_entries;
- AVIndexEntry *index_entries = s->streams[0]->index_entries;
+ int nb_index_entries = s->streams[0]->internal->nb_index_entries;
+ AVIndexEntry *index_entries = s->streams[0]->internal->index_entries;
if (ts >= matroska->duration * matroska->time_scale) return (CueDesc) {-1, -1, -1, -1};
for (i = 1; i < nb_index_entries; i++) {
if (index_entries[i - 1].timestamp * matroska->time_scale <= ts &&
@@ -3878,11 +3878,11 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s)
uint32_t id = matroska->current_id;
int64_t cluster_pos, before_pos;
int index, rv = 1;
- if (s->streams[0]->nb_index_entries <= 0) return 0;
+ if (s->streams[0]->internal->nb_index_entries <= 0) return 0;
// seek to the first cluster using cues.
index = av_index_search_timestamp(s->streams[0], 0, 0);
if (index < 0) return 0;
- cluster_pos = s->streams[0]->index_entries[index].pos;
+ cluster_pos = s->streams[0]->internal->index_entries[index].pos;
before_pos = avio_tell(s->pb);
while (1) {
uint64_t cluster_id, cluster_length;
@@ -4006,9 +4006,9 @@ static int64_t webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t
double bandwidth = 0.0;
int i;
- for (i = 0; i < st->nb_index_entries; i++) {
+ for (i = 0; i < st->internal->nb_index_entries; i++) {
int64_t prebuffer_ns = 1000000000;
- int64_t time_ns = st->index_entries[i].timestamp * matroska->time_scale;
+ int64_t time_ns = st->internal->index_entries[i].timestamp * matroska->time_scale;
double nano_seconds_per_second = 1000000000.0;
int64_t prebuffered_ns = time_ns + prebuffer_ns;
double prebuffer_bytes = 0.0;
@@ -4146,14 +4146,14 @@ static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
// store cue point timestamps as a comma separated list for checking subsegment alignment in
// the muxer. assumes that each timestamp cannot be more than 20 characters long.
- buf = av_malloc_array(s->streams[0]->nb_index_entries, 20);
+ buf = av_malloc_array(s->streams[0]->internal->nb_index_entries, 20);
if (!buf) return -1;
strcpy(buf, "");
- for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
+ for (i = 0; i < s->streams[0]->internal->nb_index_entries; i++) {
int ret = snprintf(buf + end, 20,
- "%" PRId64"%s", s->streams[0]->index_entries[i].timestamp,
- i != s->streams[0]->nb_index_entries - 1 ? "," : "");
- if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries - 1)) {
+ "%" PRId64"%s", s->streams[0]->internal->index_entries[i].timestamp,
+ i != s->streams[0]->internal->nb_index_entries - 1 ? "," : "");
+ if (ret <= 0 || (ret == 20 && i == s->streams[0]->internal->nb_index_entries - 1)) {
av_log(s, AV_LOG_ERROR, "timestamp too long.\n");
av_free(buf);
return AVERROR_INVALIDDATA;
diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index f08aabf4e0..1ddef3461e 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -191,12 +191,12 @@ static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int f
}
} else if (vst && type == MKTAG('V', 'I', 'D', 'F') && size >= 4) {
uint64_t pts = avio_rl32(pb);
- ff_add_index_entry(&vst->index_entries, &vst->nb_index_entries, &vst->index_entries_allocated_size,
+ ff_add_index_entry(&vst->internal->index_entries, &vst->internal->nb_index_entries, &vst->internal->index_entries_allocated_size,
avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
size -= 4;
} else if (ast && type == MKTAG('A', 'U', 'D', 'F') && size >= 4) {
uint64_t pts = avio_rl32(pb);
- ff_add_index_entry(&ast->index_entries, &ast->nb_index_entries, &ast->index_entries_allocated_size,
+ ff_add_index_entry(&ast->internal->index_entries, &ast->internal->nb_index_entries, &ast->internal->index_entries_allocated_size,
avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
size -= 4;
} else if (vst && type == MKTAG('W','B','A','L') && size >= 28) {
@@ -374,22 +374,22 @@ static int read_header(AVFormatContext *avctx)
}
if (vst)
- vst->duration = vst->nb_index_entries;
+ vst->duration = vst->internal->nb_index_entries;
if (ast)
- ast->duration = ast->nb_index_entries;
+ ast->duration = ast->internal->nb_index_entries;
- if ((vst && !vst->nb_index_entries) || (ast && !ast->nb_index_entries)) {
+ if ((vst && !vst->internal->nb_index_entries) || (ast && !ast->internal->nb_index_entries)) {
av_log(avctx, AV_LOG_ERROR, "no index entries found\n");
read_close(avctx);
return AVERROR_INVALIDDATA;
}
if (vst && ast)
- avio_seek(pb, FFMIN(vst->index_entries[0].pos, ast->index_entries[0].pos), SEEK_SET);
+ avio_seek(pb, FFMIN(vst->internal->index_entries[0].pos, ast->internal->index_entries[0].pos), SEEK_SET);
else if (vst)
- avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
+ avio_seek(pb, vst->internal->index_entries[0].pos, SEEK_SET);
else if (ast)
- avio_seek(pb, ast->index_entries[0].pos, SEEK_SET);
+ avio_seek(pb, ast->internal->index_entries[0].pos, SEEK_SET);
return 0;
}
@@ -415,12 +415,12 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
return AVERROR(EIO);
}
- pb = mlv->pb[st->index_entries[index].size];
+ pb = mlv->pb[st->internal->index_entries[index].size];
if (!pb) {
ret = FFERROR_REDO;
goto next_packet;
}
- avio_seek(pb, st->index_entries[index].pos, SEEK_SET);
+ avio_seek(pb, st->internal->index_entries[index].pos, SEEK_SET);
avio_skip(pb, 4); // blockType
size = avio_rl32(pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1fdc9a312c..dd0db6bca7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3179,8 +3179,8 @@ static int find_prev_closest_index(AVStream *st,
int64_t* ctts_sample)
{
MOVStreamContext *msc = st->priv_data;
- AVIndexEntry *e_keep = st->index_entries;
- int nb_keep = st->nb_index_entries;
+ AVIndexEntry *e_keep = st->internal->index_entries;
+ int nb_keep = st->internal->nb_index_entries;
int64_t i = 0;
int64_t index_ctts_count;
@@ -3193,8 +3193,8 @@ static int find_prev_closest_index(AVStream *st,
timestamp_pts -= msc->dts_shift;
}
- st->index_entries = e_old;
- st->nb_index_entries = nb_old;
+ st->internal->index_entries = e_old;
+ st->internal->nb_index_entries = nb_old;
*index = av_index_search_timestamp(st, timestamp_pts, flag | AVSEEK_FLAG_BACKWARD);
// Keep going backwards in the index entries until the timestamp is the same.
@@ -3247,14 +3247,14 @@ static int find_prev_closest_index(AVStream *st,
}
/* restore AVStream state*/
- st->index_entries = e_keep;
- st->nb_index_entries = nb_keep;
+ st->internal->index_entries = e_keep;
+ st->internal->nb_index_entries = nb_keep;
return *index >= 0 ? 0 : -1;
}
/**
- * Add index entry with the given values, to the end of st->index_entries.
- * Returns the new size st->index_entries if successful, else returns -1.
+ * Add index entry with the given values, to the end of st->internal->index_entries.
+ * Returns the new size st->internal->index_entries if successful, else returns -1.
*
* This function is similar to ff_add_index_entry in libavformat/utils.c
* except that here we are always unconditionally adding an index entry to
@@ -3268,27 +3268,27 @@ static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
{
AVIndexEntry *entries, *ie;
int64_t index = -1;
- const size_t min_size_needed = (st->nb_index_entries + 1) * sizeof(AVIndexEntry);
+ const size_t min_size_needed = (st->internal->nb_index_entries + 1) * sizeof(AVIndexEntry);
// Double the allocation each time, to lower memory fragmentation.
// Another difference from ff_add_index_entry function.
const size_t requested_size =
- min_size_needed > st->index_entries_allocated_size ?
- FFMAX(min_size_needed, 2 * st->index_entries_allocated_size) :
+ min_size_needed > st->internal->index_entries_allocated_size ?
+ FFMAX(min_size_needed, 2 * st->internal->index_entries_allocated_size) :
min_size_needed;
- if (st->nb_index_entries + 1U >= UINT_MAX / sizeof(AVIndexEntry))
+ if (st->internal->nb_index_entries + 1U >= UINT_MAX / sizeof(AVIndexEntry))
return -1;
- entries = av_fast_realloc(st->index_entries,
- &st->index_entries_allocated_size,
+ entries = av_fast_realloc(st->internal->index_entries,
+ &st->internal->index_entries_allocated_size,
requested_size);
if (!entries)
return -1;
- st->index_entries= entries;
+ st->internal->index_entries= entries;
- index= st->nb_index_entries++;
+ index= st->internal->nb_index_entries++;
ie= &entries[index];
ie->pos = pos;
@@ -3307,10 +3307,10 @@ static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t end_
int64_t* frame_duration_buffer,
int frame_duration_buffer_size) {
int i = 0;
- av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
+ av_assert0(end_index >= 0 && end_index <= st->internal->nb_index_entries);
for (i = 0; i < frame_duration_buffer_size; i++) {
end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];
- st->index_entries[end_index - 1 - i].timestamp = end_ts;
+ st->internal->index_entries[end_index - 1 - i].timestamp = end_ts;
}
}
@@ -3362,14 +3362,14 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st)
if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
st->codecpar->codec_id == AV_CODEC_ID_H264) {
st->codecpar->video_delay = 0;
- for (ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) {
+ for (ind = 0; ind < st->internal->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) {
// Point j to the last elem of the buffer and insert the current pts there.
j = buf_start;
buf_start = (buf_start + 1);
if (buf_start == MAX_REORDER_DELAY + 1)
buf_start = 0;
- pts_buf[j] = st->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration;
+ pts_buf[j] = st->internal->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration;
// The timestamps that are already in the sorted buffer, and are greater than the
// current pts, are exactly the timestamps that need to be buffered to output PTS
@@ -3449,7 +3449,7 @@ static void mov_current_sample_set(MOVStreamContext *sc, int current_sample)
}
/**
- * Fix st->index_entries, so that it contains only the entries (and the entries
+ * Fix st->internal->index_entries, so that it contains only the entries (and the entries
* which are needed to decode them) that fall in the edit list time ranges.
* Also fixes the timestamps of the index entries to match the timeline
* specified the edit lists.
@@ -3457,8 +3457,8 @@ static void mov_current_sample_set(MOVStreamContext *sc, int current_sample)
static void mov_fix_index(MOVContext *mov, AVStream *st)
{
MOVStreamContext *msc = st->priv_data;
- AVIndexEntry *e_old = st->index_entries;
- int nb_old = st->nb_index_entries;
+ AVIndexEntry *e_old = st->internal->index_entries;
+ int nb_old = st->internal->nb_index_entries;
const AVIndexEntry *e_old_end = e_old + nb_old;
const AVIndexEntry *current = NULL;
MOVStts *ctts_data_old = msc->ctts_data;
@@ -3503,9 +3503,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
current_index_range = msc->index_ranges - 1;
// Clean AVStream from traces of old index
- st->index_entries = NULL;
- st->index_entries_allocated_size = 0;
- st->nb_index_entries = 0;
+ st->internal->index_entries = NULL;
+ st->internal->index_entries_allocated_size = 0;
+ st->internal->nb_index_entries = 0;
// Clean ctts fields of MOVStreamContext
msc->ctts_data = NULL;
@@ -3634,7 +3634,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
// Make timestamps strictly monotonically increasing for audio, by rewriting timestamps for
// discarded packets.
if (frame_duration_buffer) {
- fix_index_entry_timestamps(st, st->nb_index_entries, edit_list_dts_counter,
+ fix_index_entry_timestamps(st, st->internal->nb_index_entries, edit_list_dts_counter,
frame_duration_buffer, num_discarded_begin);
av_freep(&frame_duration_buffer);
}
@@ -3673,7 +3673,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
// Make timestamps strictly monotonically increasing by rewriting timestamps for
// discarded packets.
if (frame_duration_buffer) {
- fix_index_entry_timestamps(st, st->nb_index_entries, edit_list_dts_counter,
+ fix_index_entry_timestamps(st, st->internal->nb_index_entries, edit_list_dts_counter,
frame_duration_buffer, num_discarded_begin);
av_freep(&frame_duration_buffer);
}
@@ -3734,8 +3734,8 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (msc->min_corrected_pts > 0) {
av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts);
- for (i = 0; i < st->nb_index_entries; ++i) {
- st->index_entries[i].timestamp -= msc->min_corrected_pts;
+ for (i = 0; i < st->internal->nb_index_entries; ++i) {
+ st->internal->index_entries[i].timestamp -= msc->min_corrected_pts;
}
}
}
@@ -3828,17 +3828,17 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
current_dts -= sc->dts_shift;
last_dts = current_dts;
- if (!sc->sample_count || st->nb_index_entries)
+ if (!sc->sample_count || st->internal->nb_index_entries)
return;
- if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries) - st->nb_index_entries)
+ if (sc->sample_count >= UINT_MAX / sizeof(*st->internal->index_entries) - st->internal->nb_index_entries)
return;
- if (av_reallocp_array(&st->index_entries,
- st->nb_index_entries + sc->sample_count,
- sizeof(*st->index_entries)) < 0) {
- st->nb_index_entries = 0;
+ if (av_reallocp_array(&st->internal->index_entries,
+ st->internal->nb_index_entries + sc->sample_count,
+ sizeof(*st->internal->index_entries)) < 0) {
+ st->internal->nb_index_entries = 0;
return;
}
- st->index_entries_allocated_size = (st->nb_index_entries + sc->sample_count) * sizeof(*st->index_entries);
+ st->internal->index_entries_allocated_size = (st->internal->nb_index_entries + sc->sample_count) * sizeof(*st->internal->index_entries);
if (ctts_data_old) {
// Expand ctts entries such that we have a 1-1 mapping with samples
@@ -3921,7 +3921,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
av_log(mov->fc, AV_LOG_ERROR, "Sample size %u is too large\n", sample_size);
return;
}
- e = &st->index_entries[st->nb_index_entries++];
+ e = &st->internal->index_entries[st->internal->nb_index_entries++];
e->pos = current_offset;
e->timestamp = current_dts;
e->size = sample_size;
@@ -3930,7 +3930,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", "
"size %u, distance %u, keyframe %d\n", st->index, current_sample,
current_offset, current_dts, sample_size, distance, keyframe);
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries < 100)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->internal->nb_index_entries < 100)
ff_rfps_add_frame(mov->fc, st, current_dts);
}
@@ -4002,15 +4002,15 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
av_log(mov->fc, AV_LOG_TRACE, "chunk count %u\n", total);
- if (total >= UINT_MAX / sizeof(*st->index_entries) - st->nb_index_entries)
+ if (total >= UINT_MAX / sizeof(*st->internal->index_entries) - st->internal->nb_index_entries)
return;
- if (av_reallocp_array(&st->index_entries,
- st->nb_index_entries + total,
- sizeof(*st->index_entries)) < 0) {
- st->nb_index_entries = 0;
+ if (av_reallocp_array(&st->internal->index_entries,
+ st->internal->nb_index_entries + total,
+ sizeof(*st->internal->index_entries)) < 0) {
+ st->internal->nb_index_entries = 0;
return;
}
- st->index_entries_allocated_size = (st->nb_index_entries + total) * sizeof(*st->index_entries);
+ st->internal->index_entries_allocated_size = (st->internal->nb_index_entries + total) * sizeof(*st->internal->index_entries);
// populate index
for (i = 0; i < sc->chunk_count; i++) {
@@ -4045,7 +4045,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
}
- if (st->nb_index_entries >= total) {
+ if (st->internal->nb_index_entries >= total) {
av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %u\n", total);
return;
}
@@ -4053,7 +4053,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
av_log(mov->fc, AV_LOG_ERROR, "Sample size %u is too large\n", size);
return;
}
- e = &st->index_entries[st->nb_index_entries++];
+ e = &st->internal->index_entries[st->internal->nb_index_entries++];
e->pos = current_offset;
e->timestamp = current_dts;
e->size = size;
@@ -4076,8 +4076,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
// Update start time of the stream.
- if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries > 0) {
- st->start_time = st->index_entries[0].timestamp + sc->dts_shift;
+ if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->internal->nb_index_entries > 0) {
+ st->start_time = st->internal->index_entries[0].timestamp + sc->dts_shift;
if (sc->ctts_data) {
st->start_time += sc->ctts_data[0].duration;
}
@@ -4775,7 +4775,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
// A valid index_entry means the trun for the fragment was read
// and it's samples are in index_entries at the given position.
// New index entries will be inserted before the index_entry found.
- index_entry_pos = st->nb_index_entries;
+ index_entry_pos = st->internal->nb_index_entries;
for (i = c->frag_index.current + 1; i < c->frag_index.nb_items; i++) {
frag_stream_info = get_frag_stream_info(&c->frag_index, i, frag->track_id);
if (frag_stream_info && frag_stream_info->index_entry >= 0) {
@@ -4784,7 +4784,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
break;
}
}
- av_assert0(index_entry_pos <= st->nb_index_entries);
+ av_assert0(index_entry_pos <= st->internal->nb_index_entries);
avio_r8(pb); /* version */
flags = avio_rb24(pb);
@@ -4835,22 +4835,22 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_log(c->fc, AV_LOG_TRACE, "first sample flags 0x%x\n", first_sample_flags);
// realloc space for new index entries
- if((uint64_t)st->nb_index_entries + entries >= UINT_MAX / sizeof(AVIndexEntry)) {
- entries = UINT_MAX / sizeof(AVIndexEntry) - st->nb_index_entries;
+ if((uint64_t)st->internal->nb_index_entries + entries >= UINT_MAX / sizeof(AVIndexEntry)) {
+ entries = UINT_MAX / sizeof(AVIndexEntry) - st->internal->nb_index_entries;
av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
}
if (entries == 0)
return 0;
- requested_size = (st->nb_index_entries + entries) * sizeof(AVIndexEntry);
- new_entries = av_fast_realloc(st->index_entries,
- &st->index_entries_allocated_size,
+ requested_size = (st->internal->nb_index_entries + entries) * sizeof(AVIndexEntry);
+ new_entries = av_fast_realloc(st->internal->index_entries,
+ &st->internal->index_entries_allocated_size,
requested_size);
if (!new_entries)
return AVERROR(ENOMEM);
- st->index_entries= new_entries;
+ st->internal->index_entries= new_entries;
- requested_size = (st->nb_index_entries + entries) * sizeof(*sc->ctts_data);
+ requested_size = (st->internal->nb_index_entries + entries) * sizeof(*sc->ctts_data);
old_ctts_allocated_size = sc->ctts_allocated_size;
ctts_data = av_fast_realloc(sc->ctts_data, &sc->ctts_allocated_size,
requested_size);
@@ -4864,12 +4864,12 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
memset((uint8_t*)(sc->ctts_data) + old_ctts_allocated_size, 0,
sc->ctts_allocated_size - old_ctts_allocated_size);
- if (index_entry_pos < st->nb_index_entries) {
+ if (index_entry_pos < st->internal->nb_index_entries) {
// Make hole in index_entries and ctts_data for new samples
- memmove(st->index_entries + index_entry_pos + entries,
- st->index_entries + index_entry_pos,
- sizeof(*st->index_entries) *
- (st->nb_index_entries - index_entry_pos));
+ memmove(st->internal->index_entries + index_entry_pos + entries,
+ st->internal->index_entries + index_entry_pos,
+ sizeof(*st->internal->index_entries) *
+ (st->internal->nb_index_entries - index_entry_pos));
memmove(sc->ctts_data + index_entry_pos + entries,
sc->ctts_data + index_entry_pos,
sizeof(*sc->ctts_data) * (sc->ctts_count - index_entry_pos));
@@ -4878,15 +4878,15 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
}
- st->nb_index_entries += entries;
- sc->ctts_count = st->nb_index_entries;
+ st->internal->nb_index_entries += entries;
+ sc->ctts_count = st->internal->nb_index_entries;
// Record the index_entry position in frag_index of this fragment
if (frag_stream_info)
frag_stream_info->index_entry = index_entry_pos;
if (index_entry_pos > 0)
- prev_dts = st->index_entries[index_entry_pos-1].timestamp;
+ prev_dts = st->internal->index_entries[index_entry_pos-1].timestamp;
for (i = 0; i < entries && !pb->eof_reached; i++) {
unsigned sample_size = frag->size;
@@ -4935,11 +4935,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (prev_dts >= dts)
index_entry_flags |= AVINDEX_DISCARD_FRAME;
- st->index_entries[index_entry_pos].pos = offset;
- st->index_entries[index_entry_pos].timestamp = dts;
- st->index_entries[index_entry_pos].size= sample_size;
- st->index_entries[index_entry_pos].min_distance= distance;
- st->index_entries[index_entry_pos].flags = index_entry_flags;
+ st->internal->index_entries[index_entry_pos].pos = offset;
+ st->internal->index_entries[index_entry_pos].timestamp = dts;
+ st->internal->index_entries[index_entry_pos].size= sample_size;
+ st->internal->index_entries[index_entry_pos].min_distance= distance;
+ st->internal->index_entries[index_entry_pos].flags = index_entry_flags;
sc->ctts_data[index_entry_pos].count = 1;
sc->ctts_data[index_entry_pos].duration = ctts_duration;
@@ -4966,16 +4966,16 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
// EOF found before reading all entries. Fix the hole this would
// leave in index_entries and ctts_data
int gap = entries - i;
- memmove(st->index_entries + index_entry_pos,
- st->index_entries + index_entry_pos + gap,
- sizeof(*st->index_entries) *
- (st->nb_index_entries - (index_entry_pos + gap)));
+ memmove(st->internal->index_entries + index_entry_pos,
+ st->internal->index_entries + index_entry_pos + gap,
+ sizeof(*st->internal->index_entries) *
+ (st->internal->nb_index_entries - (index_entry_pos + gap)));
memmove(sc->ctts_data + index_entry_pos,
sc->ctts_data + index_entry_pos + gap,
sizeof(*sc->ctts_data) *
(sc->ctts_count - (index_entry_pos + gap)));
- st->nb_index_entries -= gap;
+ st->internal->nb_index_entries -= gap;
sc->ctts_count -= gap;
if (index_entry_pos < sc->current_sample) {
sc->current_sample -= gap;
@@ -4988,11 +4988,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
// fragment that overlap with AVINDEX_DISCARD_FRAME
prev_dts = AV_NOPTS_VALUE;
if (index_entry_pos > 0)
- prev_dts = st->index_entries[index_entry_pos-1].timestamp;
- for (i = index_entry_pos; i < st->nb_index_entries; i++) {
- if (prev_dts < st->index_entries[i].timestamp)
+ prev_dts = st->internal->index_entries[index_entry_pos-1].timestamp;
+ for (i = index_entry_pos; i < st->internal->nb_index_entries; i++) {
+ if (prev_dts < st->internal->index_entries[i].timestamp)
break;
- st->index_entries[i].flags |= AVINDEX_DISCARD_FRAME;
+ st->internal->index_entries[i].flags |= AVINDEX_DISCARD_FRAME;
}
// If a hole was created to insert the new index_entries into,
@@ -7172,9 +7172,9 @@ static void mov_read_chapters(AVFormatContext *s)
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
st->disposition |= AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS;
- if (st->nb_index_entries) {
+ if (st->internal->nb_index_entries) {
// Retrieve the first frame, if possible
- AVIndexEntry *sample = &st->index_entries[0];
+ AVIndexEntry *sample = &st->internal->index_entries[0];
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n");
goto finish;
@@ -7190,9 +7190,9 @@ static void mov_read_chapters(AVFormatContext *s)
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
st->discard = AVDISCARD_ALL;
- for (i = 0; i < st->nb_index_entries; i++) {
- AVIndexEntry *sample = &st->index_entries[i];
- int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration;
+ for (i = 0; i < st->internal->nb_index_entries; i++) {
+ AVIndexEntry *sample = &st->internal->index_entries[i];
+ int64_t end = i+1 < st->internal->nb_index_entries ? st->internal->index_entries[i+1].timestamp : st->duration;
uint8_t *title;
uint16_t ch;
int len, title_len;
@@ -7265,10 +7265,10 @@ static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
int64_t cur_pos = avio_tell(sc->pb);
int hh, mm, ss, ff, drop;
- if (!st->nb_index_entries)
+ if (!st->internal->nb_index_entries)
return -1;
- avio_seek(sc->pb, st->index_entries->pos, SEEK_SET);
+ avio_seek(sc->pb, st->internal->index_entries->pos, SEEK_SET);
avio_skip(s->pb, 13);
hh = avio_r8(s->pb);
mm = avio_r8(s->pb);
@@ -7290,10 +7290,10 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
int64_t cur_pos = avio_tell(sc->pb);
uint32_t value;
- if (!st->nb_index_entries)
+ if (!st->internal->nb_index_entries)
return -1;
- avio_seek(sc->pb, st->index_entries->pos, SEEK_SET);
+ avio_seek(sc->pb, st->internal->index_entries->pos, SEEK_SET);
value = avio_rb32(s->pb);
if (sc->tmcd_flags & 0x0001) flags |= AV_TIMECODE_FLAG_DROPFRAME;
@@ -7758,8 +7758,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
for (i = 0; i < s->nb_streams; i++) {
AVStream *avst = s->streams[i];
MOVStreamContext *msc = avst->priv_data;
- if (msc->pb && msc->current_sample < avst->nb_index_entries) {
- AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample];
+ if (msc->pb && msc->current_sample < avst->internal->nb_index_entries) {
+ AVIndexEntry *current_sample = &avst->internal->index_entries[msc->current_sample];
int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);
av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && current_sample->pos < sample->pos) ||
@@ -7962,8 +7962,8 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
sc->ctts_sample = 0;
}
} else {
- int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
- st->index_entries[sc->current_sample].timestamp : st->duration;
+ int64_t next_dts = (sc->current_sample < st->internal->nb_index_entries) ?
+ st->internal->index_entries[sc->current_sample].timestamp : st->duration;
if (next_dts >= pkt->dts)
pkt->duration = next_dts - pkt->dts;
@@ -8044,7 +8044,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp,
sample = av_index_search_timestamp(st, timestamp, flags);
av_log(s, AV_LOG_TRACE, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
- if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
+ if (sample < 0 && st->internal->nb_index_entries && timestamp < st->internal->index_entries[0].timestamp)
sample = 0;
if (sample < 0) /* not sure what to do */
return AVERROR_INVALIDDATA;
@@ -8099,7 +8099,7 @@ static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
if (mc->seek_individually) {
/* adjust seek timestamp to found sample timestamp */
- int64_t seek_timestamp = st->index_entries[sample].timestamp;
+ int64_t seek_timestamp = st->internal->index_entries[sample].timestamp;
for (i = 0; i < s->nb_streams; i++) {
int64_t timestamp;
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 5e7f273c6a..53f803ef55 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -431,8 +431,8 @@ static int mp3_read_header(AVFormatContext *s)
}
// the seek index is relative to the end of the xing vbr headers
- for (i = 0; i < st->nb_index_entries; i++)
- st->index_entries[i].pos += avio_tell(s->pb);
+ for (i = 0; i < st->internal->nb_index_entries; i++)
+ st->internal->index_entries[i].pos += avio_tell(s->pb);
/* the parameters will be extracted from the compressed bitstream */
return 0;
@@ -567,7 +567,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
if (ret < 0)
return ret;
- ie = &st->index_entries[ret];
+ ie = &st->internal->index_entries[ret];
} else if (fast_seek && st->duration > 0 && filesize > 0) {
if (!mp3->is_cbr)
av_log(s, AV_LOG_WARNING, "Using scaling to seek VBR MP3; may be imprecise.\n");
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index 6a94b5d1d0..31a2072406 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -194,8 +194,8 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
uint32_t lastframe;
/* if found, seek there */
- if (index >= 0 && st->index_entries[st->nb_index_entries-1].timestamp >= timestamp - DELAY_FRAMES){
- c->curframe = st->index_entries[index].pos;
+ if (index >= 0 && st->internal->index_entries[st->internal->nb_index_entries-1].timestamp >= timestamp - DELAY_FRAMES){
+ c->curframe = st->internal->index_entries[index].pos;
return 0;
}
/* if timestamp is out of bounds, return error */
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index dd13bbd0a4..0002e2a9dd 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -310,9 +310,9 @@ static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestam
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0) return -1;
- if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0)
return -1;
- ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
+ ff_update_cur_dts(s, st, st->internal->index_entries[index].timestamp);
return 0;
}
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 8a53f0feeb..1cf885fbea 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1285,7 +1285,7 @@ int av_write_trailer(AVFormatContext *s)
ret = s->pb ? s->pb->error : 0;
for (i = 0; i < s->nb_streams; i++) {
av_freep(&s->streams[i]->priv_data);
- av_freep(&s->streams[i]->index_entries);
+ av_freep(&s->streams[i]->internal->index_entries);
}
if (s->oformat->priv_class)
av_opt_free(s->priv_data);
diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index d5b400213d..d8f121bea5 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -431,8 +431,8 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
int64_t ret;
uint64_t pos;
- if (frame < st->nb_index_entries) {
- index = &st->index_entries[frame];
+ if (frame < st->internal->nb_index_entries) {
+ index = &st->internal->index_entries[frame];
pos = avio_tell(pb);
if (index->pos > pos)
avio_skip(pb, index->pos - pos);
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index eb26b29450..4fab52ed36 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -682,10 +682,10 @@ static int nsv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
if(index < 0)
return -1;
- if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0)
return -1;
- nst->frame_offset = st->index_entries[index].timestamp;
+ nst->frame_offset = st->internal->index_entries[index].timestamp;
nsv->state = NSV_UNSYNC;
return 0;
}
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 3779dce2a8..53a052503e 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -1235,15 +1235,15 @@ static int read_seek(AVFormatContext *s, int stream_index,
return AVERROR(ENOSYS);
}
- if (st->index_entries) {
+ if (st->internal->index_entries) {
int index = av_index_search_timestamp(st, pts, flags);
if (index < 0)
index = av_index_search_timestamp(st, pts, flags ^ AVSEEK_FLAG_BACKWARD);
if (index < 0)
return -1;
- pos2 = st->index_entries[index].pos;
- ts = st->index_entries[index].timestamp;
+ pos2 = st->internal->index_entries[index].pos;
+ ts = st->internal->index_entries[index].timestamp;
} else {
av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pts_cmp,
(void **) next_node);
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 6d3bf6c21e..1dcb2be1b1 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -1013,12 +1013,12 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
int index = av_index_search_timestamp(st, dts_tb,
AVSEEK_FLAG_BACKWARD);
if (index >= 0) {
- sp_pos = FFMIN(sp_pos, st->index_entries[index].pos);
- if (!nut->write_index && 2*index > st->nb_index_entries) {
- memmove(st->index_entries,
- st->index_entries + index,
- sizeof(*st->index_entries) * (st->nb_index_entries - index));
- st->nb_index_entries -= index;
+ sp_pos = FFMIN(sp_pos, st->internal->index_entries[index].pos);
+ if (!nut->write_index && 2*index > st->internal->nb_index_entries) {
+ memmove(st->internal->index_entries,
+ st->internal->index_entries + index,
+ sizeof(*st->internal->index_entries) * (st->internal->nb_index_entries - index));
+ st->internal->nb_index_entries -= index;
}
}
}
diff --git a/libavformat/rl2.c b/libavformat/rl2.c
index cfde23a945..fa1b38b133 100644
--- a/libavformat/rl2.c
+++ b/libavformat/rl2.c
@@ -237,9 +237,9 @@ static int rl2_read_packet(AVFormatContext *s,
/** check if there is a valid video or audio entry that can be used */
for(i=0; i<s->nb_streams; i++){
- if(rl2->index_pos[i] < s->streams[i]->nb_index_entries
- && s->streams[i]->index_entries[ rl2->index_pos[i] ].pos < pos){
- sample = &s->streams[i]->index_entries[ rl2->index_pos[i] ];
+ if(rl2->index_pos[i] < s->streams[i]->internal->nb_index_entries
+ && s->streams[i]->internal->index_entries[ rl2->index_pos[i] ].pos < pos){
+ sample = &s->streams[i]->internal->index_entries[ rl2->index_pos[i] ];
pos= sample->pos;
stream_id= i;
}
@@ -283,7 +283,7 @@ static int rl2_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
return -1;
rl2->index_pos[stream_index] = index;
- timestamp = st->index_entries[index].timestamp;
+ timestamp = st->internal->index_entries[index].timestamp;
for(i=0; i < s->nb_streams; i++){
AVStream *st2 = s->streams[i];
diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 208c50f00c..c79419d558 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -314,10 +314,10 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
stream = s->streams[rpl->chunk_part];
- if (rpl->chunk_number >= stream->nb_index_entries)
+ if (rpl->chunk_number >= stream->internal->nb_index_entries)
return AVERROR_EOF;
- index_entry = &stream->index_entries[rpl->chunk_number];
+ index_entry = &stream->internal->index_entries[rpl->chunk_number];
if (rpl->frame_in_part == 0)
if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index 91cd7b7c2b..1225227138 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -324,7 +324,7 @@ static int film_read_seek(AVFormatContext *s, int stream_index, int64_t timestam
if (ret < 0)
return ret;
- pos = avio_seek(s->pb, st->index_entries[ret].pos, SEEK_SET);
+ pos = avio_seek(s->pb, st->internal->index_entries[ret].pos, SEEK_SET);
if (pos < 0)
return pos;
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 467c24455c..70e98b2937 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -155,15 +155,15 @@ static int tta_read_packet(AVFormatContext *s, AVPacket *pkt)
if (c->currentframe >= c->totalframes)
return AVERROR_EOF;
- if (st->nb_index_entries < c->totalframes) {
+ if (st->internal->nb_index_entries < c->totalframes) {
av_log(s, AV_LOG_ERROR, "Index entry disappeared\n");
return AVERROR_INVALIDDATA;
}
- size = st->index_entries[c->currentframe].size;
+ size = st->internal->index_entries[c->currentframe].size;
ret = av_get_packet(s->pb, pkt, size);
- pkt->dts = st->index_entries[c->currentframe++].timestamp;
+ pkt->dts = st->internal->index_entries[c->currentframe++].timestamp;
pkt->duration = c->currentframe == c->totalframes ? c->last_frame_size :
c->frame_size;
return ret;
@@ -176,7 +176,7 @@ static int tta_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
int index = av_index_search_timestamp(st, timestamp, flags);
if (index < 0)
return -1;
- if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0)
return -1;
c->currentframe = index;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 683134d84a..6ffc19517f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1914,11 +1914,11 @@ void ff_reduce_index(AVFormatContext *s, int stream_index)
AVStream *st = s->streams[stream_index];
unsigned int max_entries = s->max_index_size / sizeof(AVIndexEntry);
- if ((unsigned) st->nb_index_entries >= max_entries) {
+ if ((unsigned) st->internal->nb_index_entries >= max_entries) {
int i;
- for (i = 0; 2 * i < st->nb_index_entries; i++)
- st->index_entries[i] = st->index_entries[2 * i];
- st->nb_index_entries = i;
+ for (i = 0; 2 * i < st->internal->nb_index_entries; i++)
+ st->internal->index_entries[i] = st->internal->index_entries[2 * i];
+ st->internal->nb_index_entries = i;
}
}
@@ -1985,8 +1985,8 @@ int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
int size, int distance, int flags)
{
timestamp = wrap_timestamp(st, timestamp);
- return ff_add_index_entry(&st->index_entries, &st->nb_index_entries,
- &st->index_entries_allocated_size, pos,
+ return ff_add_index_entry(&st->internal->index_entries, &st->internal->nb_index_entries,
+ &st->internal->index_entries_allocated_size, pos,
timestamp, size, distance, flags);
}
@@ -2062,13 +2062,13 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
if (ist1 == ist2)
continue;
- for (i1 = i2 = 0; i1 < st1->nb_index_entries; i1++) {
- AVIndexEntry *e1 = &st1->index_entries[i1];
+ for (i1 = i2 = 0; i1 < st1->internal->nb_index_entries; i1++) {
+ AVIndexEntry *e1 = &st1->internal->index_entries[i1];
int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q);
skip = FFMAX(skip, e1->size);
- for (; i2 < st2->nb_index_entries; i2++) {
- AVIndexEntry *e2 = &st2->index_entries[i2];
+ for (; i2 < st2->internal->nb_index_entries; i2++) {
+ AVIndexEntry *e2 = &st2->internal->index_entries[i2];
int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
continue;
@@ -2100,7 +2100,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
{
- return ff_index_search_timestamp(st->index_entries, st->nb_index_entries,
+ return ff_index_search_timestamp(st->internal->index_entries, st->internal->nb_index_entries,
wanted_timestamp, flags);
}
@@ -2133,7 +2133,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
pos_limit = -1; // GCC falsely says it may be uninitialized.
st = s->streams[stream_index];
- if (st->index_entries) {
+ if (st->internal->index_entries) {
AVIndexEntry *e;
/* FIXME: Whole function must be checked for non-keyframe entries in
@@ -2141,7 +2141,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
index = av_index_search_timestamp(st, target_ts,
flags | AVSEEK_FLAG_BACKWARD);
index = FFMAX(index, 0);
- e = &st->index_entries[index];
+ e = &st->internal->index_entries[index];
if (e->timestamp <= target_ts || e->pos == e->min_distance) {
pos_min = e->pos;
@@ -2154,9 +2154,9 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
index = av_index_search_timestamp(st, target_ts,
flags & ~AVSEEK_FLAG_BACKWARD);
- av_assert0(index < st->nb_index_entries);
+ av_assert0(index < st->internal->nb_index_entries);
if (index >= 0) {
- e = &st->index_entries[index];
+ e = &st->internal->index_entries[index];
av_assert1(e->timestamp >= target_ts);
pos_max = e->pos;
ts_max = e->timestamp;
@@ -2357,17 +2357,17 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
index = av_index_search_timestamp(st, timestamp, flags);
- if (index < 0 && st->nb_index_entries &&
- timestamp < st->index_entries[0].timestamp)
+ if (index < 0 && st->internal->nb_index_entries &&
+ timestamp < st->internal->index_entries[0].timestamp)
return -1;
- if (index < 0 || index == st->nb_index_entries - 1) {
+ if (index < 0 || index == st->internal->nb_index_entries - 1) {
AVPacket pkt;
int nonkey = 0;
- if (st->nb_index_entries) {
- av_assert0(st->index_entries);
- ie = &st->index_entries[st->nb_index_entries - 1];
+ if (st->internal->nb_index_entries) {
+ av_assert0(st->internal->index_entries);
+ ie = &st->internal->index_entries[st->internal->nb_index_entries - 1];
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
ff_update_cur_dts(s, st, ie->timestamp);
@@ -2404,7 +2404,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
if (s->iformat->read_seek)
if (s->iformat->read_seek(s, stream_index, timestamp, flags) >= 0)
return 0;
- ie = &st->index_entries[index];
+ ie = &st->internal->index_entries[index];
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
ff_update_cur_dts(s, st, ie->timestamp);
@@ -4342,6 +4342,7 @@ static void free_stream(AVStream **pst)
avcodec_free_context(&st->internal->avctx);
av_bsf_free(&st->internal->bsfc);
av_freep(&st->internal->priv_pts);
+ av_freep(&st->internal->index_entries);
av_bsf_free(&st->internal->extract_extradata.bsf);
av_packet_free(&st->internal->extract_extradata.pkt);
@@ -4354,7 +4355,6 @@ static void free_stream(AVStream **pst)
av_dict_free(&st->metadata);
avcodec_parameters_free(&st->codecpar);
av_freep(&st->probe_data.buf);
- av_freep(&st->index_entries);
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
avcodec_free_context(&st->codec);
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index fd1ca20c9b..d388fce92e 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -83,14 +83,14 @@ static int voc_read_seek(AVFormatContext *s, int stream_index,
st = s->streams[stream_index];
index = av_index_search_timestamp(st, timestamp, flags);
- if (index >= 0 && index < st->nb_index_entries - 1) {
- AVIndexEntry *e = &st->index_entries[index];
+ if (index >= 0 && index < st->internal->nb_index_entries - 1) {
+ AVIndexEntry *e = &st->internal->index_entries[index];
avio_seek(s->pb, e->pos, SEEK_SET);
voc->pts = e->timestamp;
voc->remaining_size = e->size;
return 0;
- } else if (st->nb_index_entries && st->index_entries[0].timestamp <= timestamp) {
- AVIndexEntry *e = &st->index_entries[st->nb_index_entries - 1];
+ } else if (st->internal->nb_index_entries && st->internal->index_entries[0].timestamp <= timestamp) {
+ AVIndexEntry *e = &st->internal->index_entries[st->internal->nb_index_entries - 1];
// prepare context for seek_frame_generic()
voc->pts = e->timestamp;
voc->remaining_size = e->size;
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [7e87288f73242dac6344e65f892569102893fac0] | committer: Anton Khirnov
lavf: move AVStream.interleaver_chunk_* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e87288f73242dac6…
---
libavformat/avformat.h | 3 ---
libavformat/internal.h | 3 +++
libavformat/mux.c | 16 ++++++++--------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 8c4ae9e6e5..ae32f78393 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1106,9 +1106,6 @@ typedef struct AVStream {
int pmt_version;
int pmt_stream_idx;
- int64_t interleaver_chunk_size;
- int64_t interleaver_chunk_duration;
-
/**
* An opaque field for libavformat internal usage.
* Must not be accessed in any way by callers.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index d8ceebb26e..87d62c51b2 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -225,6 +225,9 @@ struct AVStreamInternal {
} *info;
+ int64_t interleaver_chunk_size;
+ int64_t interleaver_chunk_duration;
+
/**
* stream probing state
* -1 -> probing finished
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 8a2d6370f6..8a53f0feeb 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -839,19 +839,19 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
- st->interleaver_chunk_size += pkt->size;
- st->interleaver_chunk_duration += pkt->duration;
- if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
- || (max && st->interleaver_chunk_duration > max)) {
- st->interleaver_chunk_size = 0;
+ st->internal->interleaver_chunk_size += pkt->size;
+ st->internal->interleaver_chunk_duration += pkt->duration;
+ if ( (s->max_chunk_size && st->internal->interleaver_chunk_size > s->max_chunk_size)
+ || (max && st->internal->interleaver_chunk_duration > max)) {
+ st->internal->interleaver_chunk_size = 0;
pkt->flags |= CHUNK_START;
- if (max && st->interleaver_chunk_duration > max) {
+ if (max && st->internal->interleaver_chunk_duration > max) {
int64_t syncoffset = (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
- st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
+ st->internal->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
} else
- st->interleaver_chunk_duration = 0;
+ st->internal->interleaver_chunk_duration = 0;
}
}
if (*next_point) {
1
0
lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternal
by Anton Khirnov 28 Oct '20
by Anton Khirnov 28 Oct '20
28 Oct '20
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [108864acee1d7b0cde653cee113f3001f1b8915a] | committer: Anton Khirnov
lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=108864acee1d7b0cd…
---
libavformat/asfdec_f.c | 2 +-
libavformat/avformat.h | 13 -------------
libavformat/avidec.c | 2 +-
libavformat/internal.h | 13 +++++++++++++
libavformat/matroskadec.c | 8 ++++----
libavformat/mpeg.c | 2 +-
libavformat/mpegts.c | 26 +++++++++++++-------------
libavformat/utils.c | 24 ++++++++++++------------
libavformat/wavdec.c | 2 +-
9 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 5b4119a315..e0fee8301e 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -479,7 +479,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
if (is_dvr_ms_audio) {
// codec_id and codec_tag are unreliable in dvr_ms
// files. Set them later by probing stream.
- st->request_probe = 1;
+ st->internal->request_probe = 1;
st->codecpar->codec_tag = 0;
}
if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2aea37443e..8c4ae9e6e5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1109,19 +1109,6 @@ typedef struct AVStream {
int64_t interleaver_chunk_size;
int64_t interleaver_chunk_duration;
- /**
- * stream probing state
- * -1 -> probing finished
- * 0 -> no probing requested
- * rest -> perform probing with request_probe being the minimum score to accept.
- */
- int request_probe;
- /**
- * Indicates that everything up to the next keyframe
- * should be discarded.
- */
- int skip_to_keyframe;
-
/**
* An opaque field for libavformat internal usage.
* Must not be accessed in any way by callers.
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 33e50e9878..866e87d23b 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -901,7 +901,7 @@ static int avi_read_header(AVFormatContext *s)
break;
case AVMEDIA_TYPE_SUBTITLE:
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->request_probe= 1;
+ st->internal->request_probe= 1;
avio_skip(pb, size);
break;
default:
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 12105aa7d0..d8ceebb26e 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -225,6 +225,19 @@ struct AVStreamInternal {
} *info;
+ /**
+ * stream probing state
+ * -1 -> probing finished
+ * 0 -> no probing requested
+ * rest -> perform probing with request_probe being the minimum score to accept.
+ */
+ int request_probe;
+ /**
+ * Indicates that everything up to the next keyframe
+ * should be discarded.
+ */
+ int skip_to_keyframe;
+
/**
* Number of samples to skip at the start of the frame decoded from the next packet.
*/
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 545559423c..a183026359 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3597,7 +3597,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
return res;
if (is_keyframe)
matroska->skip_to_keyframe = 0;
- else if (!st->skip_to_keyframe) {
+ else if (!st->internal->skip_to_keyframe) {
av_log(matroska->ctx, AV_LOG_ERROR, "File is broken, keyframes not correctly marked!\n");
matroska->skip_to_keyframe = 0;
}
@@ -3794,10 +3794,10 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
/* We seek to a level 1 element, so set the appropriate status. */
matroska_reset_status(matroska, 0, st->index_entries[index].pos);
if (flags & AVSEEK_FLAG_ANY) {
- st->skip_to_keyframe = 0;
+ st->internal->skip_to_keyframe = 0;
matroska->skip_to_timecode = timestamp;
} else {
- st->skip_to_keyframe = 1;
+ st->internal->skip_to_keyframe = 1;
matroska->skip_to_timecode = st->index_entries[index].timestamp;
}
matroska->skip_to_keyframe = 1;
@@ -3810,7 +3810,7 @@ err:
matroska_reset_status(matroska, 0, -1);
matroska->resync_pos = -1;
matroska_clear_queue(matroska);
- st->skip_to_keyframe =
+ st->internal->skip_to_keyframe =
matroska->skip_to_keyframe = 0;
matroska->done = 0;
return -1;
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index a5e17925ce..20d1e10168 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -622,7 +622,7 @@ skip:
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = 8000;
}
- st->request_probe = request_probe;
+ st->internal->request_probe = request_probe;
st->need_parsing = AVSTREAM_PARSE_FULL;
found:
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 2be312e36c..ebb09991dc 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -882,7 +882,7 @@ static void mpegts_find_stream_type(AVStream *st,
st->codecpar->codec_id = types->codec_id;
st->internal->need_context_update = 1;
}
- st->request_probe = 0;
+ st->internal->request_probe = 0;
return;
}
}
@@ -915,7 +915,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
mpegts_find_stream_type(st, pes->stream_type, ISO_types);
if (pes->stream_type == 4 || pes->stream_type == 0x0f)
- st->request_probe = 50;
+ st->internal->request_probe = 50;
if ((prog_reg_desc == AV_RL32("HDMV") ||
prog_reg_desc == AV_RL32("HDPR")) &&
st->codecpar->codec_id == AV_CODEC_ID_NONE) {
@@ -952,12 +952,12 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
st->codecpar->codec_type = old_codec_type;
}
if ((st->codecpar->codec_id == AV_CODEC_ID_NONE ||
- (st->request_probe > 0 && st->request_probe < AVPROBE_SCORE_STREAM_RETRY / 5)) &&
+ (st->internal->request_probe > 0 && st->internal->request_probe < AVPROBE_SCORE_STREAM_RETRY / 5)) &&
st->probe_packets > 0 &&
stream_type == STREAM_TYPE_PRIVATE_DATA) {
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
- st->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5;
+ st->internal->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5;
}
/* queue a context update if properties changed */
@@ -1198,12 +1198,12 @@ static int mpegts_push_data(MpegTSFilter *filter,
code != 0x1ff && code != 0x1f2 && /* program_stream_directory, DSMCC_stream */
code != 0x1f8) { /* ITU-T Rec. H.222.1 type E stream */
pes->state = MPEGTS_PESHEADER;
- if (pes->st->codecpar->codec_id == AV_CODEC_ID_NONE && !pes->st->request_probe) {
+ if (pes->st->codecpar->codec_id == AV_CODEC_ID_NONE && !pes->st->internal->request_probe) {
av_log(pes->stream, AV_LOG_TRACE,
"pid=%x stream_type=%x probing\n",
pes->pid,
pes->stream_type);
- pes->st->request_probe = 1;
+ pes->st->internal->request_probe = 1;
}
} else {
pes->pes_header_size = 6;
@@ -1799,7 +1799,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
av_log(fc, AV_LOG_TRACE, "tag: 0x%02x len=%d\n", desc_tag, desc_len);
- if ((st->codecpar->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) &&
+ if ((st->codecpar->codec_id == AV_CODEC_ID_NONE || st->internal->request_probe > 0) &&
stream_type == STREAM_TYPE_PRIVATE_DATA)
mpegts_find_stream_type(st, desc_tag, DESC_types);
@@ -1837,8 +1837,8 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
break;
if (mp4_descr_count > 0 &&
(st->codecpar->codec_id == AV_CODEC_ID_AAC_LATM ||
- (st->request_probe == 0 && st->codecpar->codec_id == AV_CODEC_ID_NONE) ||
- st->request_probe > 0) &&
+ (st->internal->request_probe == 0 && st->codecpar->codec_id == AV_CODEC_ID_NONE) ||
+ st->internal->request_probe > 0) &&
mp4_descr->dec_config_descr_len && mp4_descr->es_id == pid) {
AVIOContext pb;
ffio_init_context(&pb, mp4_descr->dec_config_descr,
@@ -1847,7 +1847,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
ff_mp4_read_dec_config_descr(fc, st, &pb);
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size > 0) {
- st->request_probe = st->need_parsing = 0;
+ st->internal->request_probe = st->need_parsing = 0;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->internal->need_context_update = 1;
}
@@ -1987,10 +1987,10 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
case REGISTRATION_DESCRIPTOR:
st->codecpar->codec_tag = bytestream_get_le32(pp);
av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char *)&st->codecpar->codec_tag);
- if (st->codecpar->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE || st->internal->request_probe > 0) {
mpegts_find_stream_type(st, st->codecpar->codec_tag, REGD_types);
if (st->codecpar->codec_tag == MKTAG('B', 'S', 'S', 'D'))
- st->request_probe = 50;
+ st->internal->request_probe = 50;
}
break;
case 0x52: /* stream identifier descriptor */
@@ -2143,7 +2143,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_ARIB_CAPTION;
st->codecpar->profile = picked_profile;
- st->request_probe = 0;
+ st->internal->request_probe = 0;
}
break;
case 0xb0: /* DOVI video stream descriptor */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c6bb971a6a..683134d84a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -365,7 +365,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
if (fmt_id_type[i].type != AVMEDIA_TYPE_AUDIO &&
st->codecpar->sample_rate)
continue;
- if (st->request_probe > score &&
+ if (st->internal->request_probe > score &&
st->codecpar->codec_id != fmt_id_type[i].id)
continue;
st->codecpar->codec_id = fmt_id_type[i].id;
@@ -675,7 +675,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st)
static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{
- if (st->request_probe>0) {
+ if (st->internal->request_probe>0) {
AVProbeData *pd = &st->probe_data;
int end;
av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets);
@@ -711,7 +711,7 @@ no_packet:
|| end) {
pd->buf_size = 0;
av_freep(&pd->buf);
- st->request_probe = -1;
+ st->internal->request_probe = -1;
if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index);
} else
@@ -807,7 +807,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (s->internal->raw_packet_buffer_remaining_size <= 0)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
- if (st->request_probe <= 0) {
+ if (st->internal->request_probe <= 0) {
avpriv_packet_list_get(&s->internal->raw_packet_buffer,
&s->internal->raw_packet_buffer_end, pkt);
s->internal->raw_packet_buffer_remaining_size += pkt->size;
@@ -828,10 +828,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->probe_packets || st->request_probe > 0)
+ if (st->probe_packets || st->internal->request_probe > 0)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
- av_assert0(st->request_probe <= 0);
+ av_assert0(st->internal->request_probe <= 0);
}
continue;
}
@@ -878,7 +878,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (s->use_wallclock_as_timestamps)
pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
- if (!pktl && st->request_probe <= 0)
+ if (!pktl && st->internal->request_probe <= 0)
return ret;
err = avpriv_packet_list_put(&s->internal->raw_packet_buffer,
@@ -1626,8 +1626,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_packet_unref(pkt);
}
if (pkt->flags & AV_PKT_FLAG_KEY)
- st->skip_to_keyframe = 0;
- if (st->skip_to_keyframe) {
+ st->internal->skip_to_keyframe = 0;
+ if (st->internal->skip_to_keyframe) {
av_packet_unref(pkt);
got_packet = 0;
}
@@ -3607,7 +3607,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
// only for the split stuff
- if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->request_probe <= 0) {
+ if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
st->parser = av_parser_init(st->codecpar->codec_id);
if (st->parser) {
if (st->need_parsing == AVSTREAM_PARSE_HEADERS) {
@@ -3628,7 +3628,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
ret = avcodec_parameters_to_context(avctx, st->codecpar);
if (ret < 0)
goto find_stream_info_err;
- if (st->request_probe <= 0)
+ if (st->internal->request_probe <= 0)
st->internal->avctx_inited = 1;
codec = find_probe_decoder(ic, st, st->codecpar->codec_id);
@@ -3649,7 +3649,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
// Try to just open decoders, in case this is enough to get parameters.
- if (!has_codec_parameters(st, NULL) && st->request_probe <= 0) {
+ if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) {
if (codec && !avctx->codec)
if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
av_log(ic, AV_LOG_WARNING,
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index d6ab0dde35..bca186a66f 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -154,7 +154,7 @@ static int wav_probe(const AVProbeData *p)
static void handle_stream_probing(AVStream *st)
{
if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
- st->request_probe = AVPROBE_SCORE_EXTENSION;
+ st->internal->request_probe = AVPROBE_SCORE_EXTENSION;
st->probe_packets = FFMIN(st->probe_packets, 32);
}
}
1
0
lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
by Anton Khirnov 28 Oct '20
by Anton Khirnov 28 Oct '20
28 Oct '20
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Fri Oct 9 09:22:36 2020 +0200| [456b170bd747ea7181c7305fd45278ea251f45ab] | committer: Anton Khirnov
lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=456b170bd747ea718…
---
libavformat/avformat.h | 29 -----------------------------
libavformat/internal.h | 29 +++++++++++++++++++++++++++++
libavformat/mov.c | 12 ++++++------
libavformat/mp3dec.c | 8 ++++----
libavformat/swfdec.c | 2 +-
libavformat/utils.c | 26 +++++++++++++-------------
6 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2b42fb7fad..2aea37443e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1122,35 +1122,6 @@ typedef struct AVStream {
*/
int skip_to_keyframe;
- /**
- * Number of samples to skip at the start of the frame decoded from the next packet.
- */
- int skip_samples;
-
- /**
- * If not 0, the number of samples that should be skipped from the start of
- * the stream (the samples are removed from packets with pts==0, which also
- * assumes negative timestamps do not happen).
- * Intended for use with formats such as mp3 with ad-hoc gapless audio
- * support.
- */
- int64_t start_skip_samples;
-
- /**
- * If not 0, the first audio sample that should be discarded from the stream.
- * This is broken by design (needs global sample count), but can't be
- * avoided for broken by design formats such as mp3 with ad-hoc gapless
- * audio support.
- */
- int64_t first_discard_sample;
-
- /**
- * The sample after last sample that is intended to be discarded after
- * first_discard_sample. Works on frame boundaries only. Used to prevent
- * early EOF if the gapless info is broken (considered concatenated mp3s).
- */
- int64_t last_discard_sample;
-
/**
* An opaque field for libavformat internal usage.
* Must not be accessed in any way by callers.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index b1112fe463..12105aa7d0 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -225,6 +225,35 @@ struct AVStreamInternal {
} *info;
+ /**
+ * Number of samples to skip at the start of the frame decoded from the next packet.
+ */
+ int skip_samples;
+
+ /**
+ * If not 0, the number of samples that should be skipped from the start of
+ * the stream (the samples are removed from packets with pts==0, which also
+ * assumes negative timestamps do not happen).
+ * Intended for use with formats such as mp3 with ad-hoc gapless audio
+ * support.
+ */
+ int64_t start_skip_samples;
+
+ /**
+ * If not 0, the first audio sample that should be discarded from the stream.
+ * This is broken by design (needs global sample count), but can't be
+ * avoided for broken by design formats such as mp3 with ad-hoc gapless
+ * audio support.
+ */
+ int64_t first_discard_sample;
+
+ /**
+ * The sample after last sample that is intended to be discarded after
+ * first_discard_sample. Works on frame boundaries only. Used to prevent
+ * early EOF if the gapless info is broken (considered concatenated mp3s).
+ */
+ int64_t last_discard_sample;
+
/**
* Number of internally decoded frames, used internally in libavformat, do not access
* its lifetime differs from info which is why it is not in that structure.
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3107865b04..1fdc9a312c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3550,7 +3550,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
}
if (first_non_zero_audio_edit > 0)
- st->skip_samples = msc->start_pad = 0;
+ st->internal->skip_samples = msc->start_pad = 0;
}
// While reordering frame index according to edit list we must handle properly
@@ -3625,7 +3625,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time &&
first_non_zero_audio_edit > 0) {
packet_skip_samples = edit_list_media_time - curr_cts;
- st->skip_samples += packet_skip_samples;
+ st->internal->skip_samples += packet_skip_samples;
// Shift the index entry timestamp by packet_skip_samples to be correct.
edit_list_dts_counter -= packet_skip_samples;
@@ -3658,7 +3658,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
// Increment skip_samples for the first non-zero audio edit list
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
first_non_zero_audio_edit > 0 && st->codecpar->codec_id != AV_CODEC_ID_VORBIS) {
- st->skip_samples += frame_duration;
+ st->internal->skip_samples += frame_duration;
}
}
}
@@ -3744,7 +3744,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
// Update av stream length, if it ends up shorter than the track's media duration
st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts);
- msc->start_pad = st->skip_samples;
+ msc->start_pad = st->internal->skip_samples;
// Free the old index and the old CTTS structures
av_free(e_old);
@@ -7616,7 +7616,7 @@ static int mov_read_header(AVFormatContext *s)
fix_timescale(mov, sc);
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codecpar->codec_id == AV_CODEC_ID_AAC) {
- st->skip_samples = sc->start_pad;
+ st->internal->skip_samples = sc->start_pad;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
@@ -8105,7 +8105,7 @@ static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
int64_t timestamp;
MOVStreamContext *sc = s->streams[i]->priv_data;
st = s->streams[i];
- st->skip_samples = (sample_time <= 0) ? sc->start_pad : 0;
+ st->internal->skip_samples = (sample_time <= 0) ? sc->start_pad : 0;
if (stream_index == i)
continue;
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index b044679c02..5e7f273c6a 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -255,13 +255,13 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
mp3->start_pad = v>>12;
mp3-> end_pad = v&4095;
- st->start_skip_samples = mp3->start_pad + 528 + 1;
+ st->internal->start_skip_samples = mp3->start_pad + 528 + 1;
if (mp3->frames) {
- st->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf;
- st->last_discard_sample = mp3->frames * (int64_t)spf;
+ st->internal->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf;
+ st->internal->last_discard_sample = mp3->frames * (int64_t)spf;
}
if (!st->start_time)
- st->start_time = av_rescale_q(st->start_skip_samples,
+ st->start_time = av_rescale_q(st->internal->start_skip_samples,
(AVRational){1, c->sample_rate},
st->time_base);
av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad);
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 2769a768de..fa11c050cd 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -292,7 +292,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(ENOMEM);
ast->duration = avio_rl32(pb); // number of samples
if (((v>>4) & 15) == 2) { // MP3 sound data record
- ast->skip_samples = avio_rl16(pb);
+ ast->internal->skip_samples = avio_rl16(pb);
len -= 2;
}
len -= 7;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d1e77d7b24..c6bb971a6a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1123,7 +1123,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) {
st->start_time = pktl_it->pkt.pts;
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate)
- st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base));
+ st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->internal->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base));
}
}
@@ -1136,7 +1136,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
st->start_time = pts;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate)
- st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base));
+ st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->internal->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base));
}
}
@@ -1639,25 +1639,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (ret >= 0) {
AVStream *st = s->streams[pkt->stream_index];
int discard_padding = 0;
- if (st->first_discard_sample && pkt->pts != AV_NOPTS_VALUE) {
+ if (st->internal->first_discard_sample && pkt->pts != AV_NOPTS_VALUE) {
int64_t pts = pkt->pts - (is_relative(pkt->pts) ? RELATIVE_TS_BASE : 0);
int64_t sample = ts_to_samples(st, pts);
int duration = ts_to_samples(st, pkt->duration);
int64_t end_sample = sample + duration;
- if (duration > 0 && end_sample >= st->first_discard_sample &&
- sample < st->last_discard_sample)
- discard_padding = FFMIN(end_sample - st->first_discard_sample, duration);
+ if (duration > 0 && end_sample >= st->internal->first_discard_sample &&
+ sample < st->internal->last_discard_sample)
+ discard_padding = FFMIN(end_sample - st->internal->first_discard_sample, duration);
}
- if (st->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE))
- st->skip_samples = st->start_skip_samples;
- if (st->skip_samples || discard_padding) {
+ if (st->internal->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE))
+ st->internal->skip_samples = st->internal->start_skip_samples;
+ if (st->internal->skip_samples || discard_padding) {
uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (p) {
- AV_WL32(p, st->skip_samples);
+ AV_WL32(p, st->internal->skip_samples);
AV_WL32(p + 4, discard_padding);
- av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d / discard %d\n", st->skip_samples, discard_padding);
+ av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d / discard %d\n", st->internal->skip_samples, discard_padding);
}
- st->skip_samples = 0;
+ st->internal->skip_samples = 0;
}
if (st->internal->inject_global_side_data) {
@@ -1891,7 +1891,7 @@ void ff_read_frame_flush(AVFormatContext *s)
if (s->internal->inject_global_side_data)
st->internal->inject_global_side_data = 1;
- st->skip_samples = 0;
+ st->internal->skip_samples = 0;
}
}
1
0