aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-10-13 13:08:10 +0200
committerAnton Khirnov <anton@khirnov.net>2024-10-16 16:46:29 +0200
commit86460a0342d7cbd59ad794f515d7d525331b54dd (patch)
treee3e0ff4126c5bad930943a40d06f391ced2b4840 /libavformat
parent31da5222a400a385c0633c54e20b0ae1b30730df (diff)
downloadffmpeg-86460a0342d7cbd59ad794f515d7d525331b54dd.tar.gz
lavf/flvdec: replace a private option with a field in FFFormatContext
The demuxer's 'missing_streams' private option is used to communicate information from the demuxer to avformat_find_stream_info(). However, that is not only unnecessarily complicated, it also leaks internal information to users, e.g. this option appears in the results of the fate-flv-demux test. Use a new field in FFFormatContext to communicate this information instead.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/demux.c24
-rw-r--r--libavformat/flvdec.c10
-rw-r--r--libavformat/internal.h2
3 files changed, 18 insertions, 18 deletions
diff --git a/libavformat/demux.c b/libavformat/demux.c
index f9517454ad..cba1f2e4df 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2537,7 +2537,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int64_t max_subtitle_analyze_duration;
int64_t probesize = ic->probesize;
int eof_reached = 0;
- int *missing_streams = av_opt_ptr(ic->iformat->priv_class, ic->priv_data, "missing_streams");
flush_codecs = probesize > 0;
@@ -2676,19 +2675,18 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
break;
}
analyzed_all_streams = 0;
- if (!missing_streams || !*missing_streams)
- if (i == ic->nb_streams) {
- analyzed_all_streams = 1;
- /* NOTE: If the format has no header, then we need to read some
- * packets to get most of the streams, so we cannot stop here. */
- if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
- /* If we found the info for all the codecs, we can stop. */
- ret = count;
- av_log(ic, AV_LOG_DEBUG, "All info found\n");
- flush_codecs = 0;
- break;
- }
+ if (i == ic->nb_streams && !si->missing_streams) {
+ analyzed_all_streams = 1;
+ /* NOTE: If the format has no header, then we need to read some
+ * packets to get most of the streams, so we cannot stop here. */
+ if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
+ /* If we found the info for all the codecs, we can stop. */
+ ret = count;
+ av_log(ic, AV_LOG_DEBUG, "All info found\n");
+ flush_codecs = 0;
+ break;
}
+ }
/* We did not get all the codec info, but we read too much data. */
if (read_size >= probesize) {
ret = count;
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 1fb3e0cd3f..08482eb2db 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -97,7 +97,6 @@ typedef struct FLVContext {
int64_t audio_bit_rate;
int64_t *keyframe_times;
int64_t *keyframe_filepositions;
- int missing_streams;
AVRational framerate;
int64_t last_ts;
int64_t time_offset;
@@ -189,6 +188,7 @@ static void add_keyframes_index(AVFormatContext *s)
static AVStream *create_stream(AVFormatContext *s, int codec_type)
{
+ FFFormatContext *const si = ffformatcontext(s);
FLVContext *flv = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
@@ -202,11 +202,11 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
if (codec_type == AVMEDIA_TYPE_AUDIO) {
st->codecpar->bit_rate = flv->audio_bit_rate;
- flv->missing_streams &= ~FLV_HEADER_FLAG_HASAUDIO;
+ si->missing_streams &= ~FLV_HEADER_FLAG_HASAUDIO;
}
if (codec_type == AVMEDIA_TYPE_VIDEO) {
st->codecpar->bit_rate = flv->video_bit_rate;
- flv->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
+ si->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
st->avg_frame_rate = flv->framerate;
}
@@ -843,6 +843,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
static int flv_read_header(AVFormatContext *s)
{
+ FFFormatContext *const si = ffformatcontext(s);
int flags;
FLVContext *flv = s->priv_data;
int offset;
@@ -855,7 +856,7 @@ static int flv_read_header(AVFormatContext *s)
avio_skip(s->pb, 4);
flags = avio_r8(s->pb);
- flv->missing_streams = flags & (FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO);
+ si->missing_streams = flags & (FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO);
s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -1577,7 +1578,6 @@ static const AVOption options[] = {
{ "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "flv_full_metadata", "Dump full metadata of the onMetadata", OFFSET(dump_full_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "flv_ignore_prevtag", "Ignore the Size of previous tag", OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
- { "missing_streams", "", OFFSET(missing_streams), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0xFF, VD | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
{ NULL }
};
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 5cfcc20ec3..b909adf209 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -120,6 +120,8 @@ typedef struct FFFormatContext {
* ID3v2 tag useful for MP3 demuxing
*/
AVDictionary *id3v2_meta;
+
+ int missing_streams;
} FFFormatContext;
static av_always_inline FFFormatContext *ffformatcontext(AVFormatContext *s)