[FFmpeg-devel] [PATCH 4/5] avformat: move AVStream.codec_info_nb_frames to AVStreamInternal
James Almer
jamrial at gmail.com
Mon May 3 16:31:59 EEST 2021
It's a private field, no reason to have it exposed in a public header.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/avformat.h | 5 -----
libavformat/dump.c | 2 +-
libavformat/internal.h | 5 +++++
libavformat/utils.c | 30 +++++++++++++++---------------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 9ed6d333d3..ecf76b4bfc 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1003,11 +1003,6 @@ typedef struct AVStream {
int64_t first_dts;
int64_t cur_dts;
- /**
- * Number of frames that have been demuxed during avformat_find_stream_info()
- */
- int codec_info_nb_frames;
-
/**
* Stream Identifier
* This is the MPEG-TS stream identifier +1
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 04c93dd7d3..cf892de107 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -544,7 +544,7 @@ static void dump_stream_format(const AVFormatContext *ic, int i,
av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
if (lang)
av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
- av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames,
+ av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->internal->codec_info_nb_frames,
st->time_base.num, st->time_base.den);
av_log(NULL, AV_LOG_INFO, ": %s", buf);
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 928ec6edf2..94115960ea 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -377,6 +377,11 @@ struct AVStreamInternal {
/* av_read_frame() support */
enum AVStreamParseType need_parsing;
struct AVCodecParserContext *parser;
+
+ /**
+ * Number of frames that have been demuxed during avformat_find_stream_info()
+ */
+ int codec_info_nb_frames;
};
#ifdef __GNUC__
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3ccebce2b9..8fbb6bfc13 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1793,7 +1793,7 @@ int av_find_default_stream_index(AVFormatContext *s)
if (st->codecpar->sample_rate)
score += 50;
}
- if (st->codec_info_nb_frames)
+ if (st->internal->codec_info_nb_frames)
score += 12;
if (st->discard != AVDISCARD_ALL)
@@ -2677,7 +2677,7 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
break;
}
bit_rate += st->codecpar->bit_rate;
- } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->internal->codec_info_nb_frames > 1) {
// If we have a videostream with packets but without a bitrate
// then consider the sum not known
bit_rate = 0;
@@ -2941,7 +2941,7 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
if (st->internal->info->found_decoder >= 0 && avctx->pix_fmt == AV_PIX_FMT_NONE)
FAIL("unspecified pixel format");
if (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40)
- if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !st->codec_info_nb_frames)
+ if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !st->internal->codec_info_nb_frames)
FAIL("no frame in rv30/40 and no sar");
break;
case AVMEDIA_TYPE_SUBTITLE:
@@ -3018,7 +3018,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st,
while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
ret >= 0 &&
(!has_codec_parameters(st, NULL) || !has_decode_delay_been_guessed(st) ||
- (!st->codec_info_nb_frames &&
+ (!st->internal->codec_info_nb_frames &&
(avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) {
got_picture = 0;
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO ||
@@ -3696,7 +3696,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
break;
if (st->first_dts == AV_NOPTS_VALUE &&
!(ic->iformat->flags & AVFMT_NOTIMESTAMPS) &&
- st->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) &&
+ st->internal->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) &&
(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))
break;
@@ -3767,7 +3767,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
st->internal->avctx_inited = 1;
}
- if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) {
+ if (pkt->dts != AV_NOPTS_VALUE && st->internal->codec_info_nb_frames > 1) {
/* check for non-increasing dts */
if (st->internal->info->fps_last_dts != AV_NOPTS_VALUE &&
st->internal->info->fps_last_dts >= pkt->dts) {
@@ -3775,7 +3775,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
"Non-increasing DTS in stream %d: packet %d with DTS "
"%"PRId64", packet %d with DTS %"PRId64"\n",
st->index, st->internal->info->fps_last_dts_idx,
- st->internal->info->fps_last_dts, st->codec_info_nb_frames,
+ st->internal->info->fps_last_dts, st->internal->codec_info_nb_frames,
pkt->dts);
st->internal->info->fps_first_dts =
st->internal->info->fps_last_dts = AV_NOPTS_VALUE;
@@ -3792,7 +3792,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
"DTS discontinuity in stream %d: packet %d with DTS "
"%"PRId64", packet %d with DTS %"PRId64"\n",
st->index, st->internal->info->fps_last_dts_idx,
- st->internal->info->fps_last_dts, st->codec_info_nb_frames,
+ st->internal->info->fps_last_dts, st->internal->codec_info_nb_frames,
pkt->dts);
st->internal->info->fps_first_dts =
st->internal->info->fps_last_dts = AV_NOPTS_VALUE;
@@ -3801,22 +3801,22 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
/* update stored dts values */
if (st->internal->info->fps_first_dts == AV_NOPTS_VALUE) {
st->internal->info->fps_first_dts = pkt->dts;
- st->internal->info->fps_first_dts_idx = st->codec_info_nb_frames;
+ st->internal->info->fps_first_dts_idx = st->internal->codec_info_nb_frames;
}
st->internal->info->fps_last_dts = pkt->dts;
- st->internal->info->fps_last_dts_idx = st->codec_info_nb_frames;
+ st->internal->info->fps_last_dts_idx = st->internal->codec_info_nb_frames;
}
- if (st->codec_info_nb_frames>1) {
+ if (st->internal->codec_info_nb_frames>1) {
int64_t t = 0;
int64_t limit;
if (st->time_base.den > 0)
t = av_rescale_q(st->internal->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q);
if (st->avg_frame_rate.num > 0)
- t = FFMAX(t, av_rescale_q(st->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
+ t = FFMAX(t, av_rescale_q(st->internal->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
if ( t == 0
- && st->codec_info_nb_frames>30
+ && st->internal->codec_info_nb_frames>30
&& st->internal->info->fps_first_dts != AV_NOPTS_VALUE
&& st->internal->info->fps_last_dts != AV_NOPTS_VALUE) {
int64_t dur = av_sat_sub64(st->internal->info->fps_last_dts, st->internal->info->fps_first_dts);
@@ -3872,7 +3872,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (ic->flags & AVFMT_FLAG_NOBUFFER)
av_packet_unref(pkt1);
- st->codec_info_nb_frames++;
+ st->internal->codec_info_nb_frames++;
count++;
}
@@ -4150,7 +4150,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
}
disposition = !(st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED))
+ !! (st->disposition & AV_DISPOSITION_DEFAULT);
- count = st->codec_info_nb_frames;
+ count = st->internal->codec_info_nb_frames;
bitrate = par->bit_rate;
multiframe = FFMIN(5, count);
if ((best_disposition > disposition) ||
--
2.31.1
More information about the ffmpeg-devel
mailing list