* [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg_mux_init: move more code from of_open() to create_streams()
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out() Anton Khirnov
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
Specificaly, the of_add_attachments() call (which can add attachment
streams to the output) and the check whether the output file contains
any streams. They both logically belong in create_streams().
---
fftools/ffmpeg_mux_init.c | 99 ++++++++++++++++++++-------------------
1 file changed, 50 insertions(+), 49 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 4755a2cc38..303bf25096 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1062,8 +1062,50 @@ loop_end:
}
}
+static void of_add_attachments(Muxer *mux, const OptionsContext *o)
+{
+ OutputStream *ost;
+ int err;
+
+ for (int i = 0; i < o->nb_attachments; i++) {
+ AVIOContext *pb;
+ uint8_t *attachment;
+ const char *p;
+ int64_t len;
+
+ if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
+ o->attachments[i]);
+ exit_program(1);
+ }
+ if ((len = avio_size(pb)) <= 0) {
+ av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n",
+ o->attachments[i]);
+ exit_program(1);
+ }
+ if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE ||
+ !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) {
+ av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n",
+ o->attachments[i]);
+ exit_program(1);
+ }
+ avio_read(pb, attachment, len);
+ memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+
+ ost = new_attachment_stream(mux, o, -1);
+ ost->attachment_filename = o->attachments[i];
+ ost->st->codecpar->extradata = attachment;
+ ost->st->codecpar->extradata_size = len;
+
+ p = strrchr(o->attachments[i], '/');
+ av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
+ avio_closep(&pb);
+ }
+}
+
static void create_streams(Muxer *mux, const OptionsContext *o)
{
+ AVFormatContext *oc = mux->fc;
int auto_disable_v = o->video_disable;
int auto_disable_a = o->audio_disable;
int auto_disable_s = o->subtitle_disable;
@@ -1101,6 +1143,14 @@ static void create_streams(Muxer *mux, const OptionsContext *o)
for (int i = 0; i < o->nb_stream_maps; i++)
map_manual(mux, o, &o->stream_maps[i]);
}
+
+ of_add_attachments(mux, o);
+
+ if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
+ av_dump_format(oc, nb_output_files - 1, oc->url, 1);
+ av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
+ exit_program(1);
+ }
}
static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us)
@@ -1194,47 +1244,6 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
return 0;
}
-static void of_add_attachments(Muxer *mux, const OptionsContext *o)
-{
- OutputStream *ost;
- int err;
-
- for (int i = 0; i < o->nb_attachments; i++) {
- AVIOContext *pb;
- uint8_t *attachment;
- const char *p;
- int64_t len;
-
- if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
- o->attachments[i]);
- exit_program(1);
- }
- if ((len = avio_size(pb)) <= 0) {
- av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n",
- o->attachments[i]);
- exit_program(1);
- }
- if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE ||
- !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) {
- av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n",
- o->attachments[i]);
- exit_program(1);
- }
- avio_read(pb, attachment, len);
- memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-
- ost = new_attachment_stream(mux, o, -1);
- ost->attachment_filename = o->attachments[i];
- ost->st->codecpar->extradata = attachment;
- ost->st->codecpar->extradata_size = len;
-
- p = strrchr(o->attachments[i], '/');
- av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
- avio_closep(&pb);
- }
-}
-
static void of_add_programs(AVFormatContext *oc, const OptionsContext *o)
{
/* process manually set programs */
@@ -1782,14 +1791,6 @@ int of_open(const OptionsContext *o, const char *filename)
/* create all output streams for this file */
create_streams(mux, o);
- of_add_attachments(mux, o);
-
- if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
- av_dump_format(oc, nb_output_files - 1, oc->url, 1);
- av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
- exit_program(1);
- }
-
/* check if all codec options have been used */
unused_opts = strip_specifiers(o->g->codec_opts);
for (int i = 0; i < of->nb_streams; i++) {
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out()
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg_mux_init: move more code from of_open() to create_streams() Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream Anton Khirnov
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
Frame limiting is now handled using sync queues. This code prevents the
sync queue from triggering EOF, resulting in unnecessarily many frames
being decoded, filtered, and then discarded.
Found-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
---
fftools/ffmpeg.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0fa2fe8c52..dfdfad3ce4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1206,14 +1206,6 @@ static void do_video_out(OutputFile *of,
}
}
- /*
- * For video, number of frames in == number of packets out.
- * But there may be reordering, so we can't throw away frames on encoder
- * flush, we need to limit them here, before they go into encoder.
- */
- nb_frames = FFMIN(nb_frames, ost->max_frames - ost->vsync_frame_number);
- nb0_frames = FFMIN(nb0_frames, nb_frames);
-
memmove(ost->last_nb0_frames + 1,
ost->last_nb0_frames,
sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1));
@@ -1262,7 +1254,9 @@ static void do_video_out(OutputFile *of,
in_picture->pict_type = forced_kf_apply(ost, in_picture, i);
ret = submit_encode_frame(of, ost, in_picture);
- if (ret < 0 && ret != AVERROR_EOF)
+ if (ret == AVERROR_EOF)
+ break;
+ else if (ret < 0)
exit_program(1);
ost->next_pts++;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg_mux_init: move more code from of_open() to create_streams() Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out() Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function Anton Khirnov
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
It no longer needs to be visible outside of the muxing code.
---
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_mux.c | 5 -----
fftools/ffmpeg_mux.h | 7 +++++++
fftools/ffmpeg_mux_init.c | 23 +++++++++++++----------
4 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 23850c7573..ad53ad4ce8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -508,7 +508,6 @@ typedef struct OutputStream {
AVRational enc_timebase;
AVCodecContext *enc_ctx;
- int64_t max_frames;
AVFrame *filtered_frame;
AVFrame *last_frame;
AVFrame *sq_frame;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 778626e20f..ad04f5049d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -45,11 +45,6 @@ static Muxer *mux_from_of(OutputFile *of)
return (Muxer*)of;
}
-static MuxStream *ms_from_ost(OutputStream *ost)
-{
- return (MuxStream*)ost;
-}
-
static int64_t filesize(AVIOContext *pb)
{
int64_t ret = -1;
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 6ea7c692ef..6a72b9dc91 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -42,6 +42,8 @@ typedef struct MuxStream {
AVBSFContext *bsf_ctx;
+ int64_t max_frames;
+
/*
* The size of the AVPackets' buffers in queue.
* Updated when a packet is either pushed or pulled from the queue.
@@ -84,4 +86,9 @@ extern int want_sdp;
int mux_check_init(Muxer *mux);
+static MuxStream *ms_from_ost(OutputStream *ost)
+{
+ return (MuxStream*)ost;
+}
+
#endif /* FFTOOLS_FFMPEG_MUX_H */
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 303bf25096..150eb77ee2 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -295,8 +295,8 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
ost->enc_timebase = q;
}
- ost->max_frames = INT64_MAX;
- MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
+ ms->max_frames = INT64_MAX;
+ MATCH_PER_STREAM_OPT(max_frames, i64, ms->max_frames, oc, st);
for (i = 0; i<o->nb_max_frames; i++) {
char *p = o->max_frames[i].specifier;
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
@@ -1165,6 +1165,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
for (int i = 0; i < oc->nb_streams; i++) {
OutputStream *ost = of->streams[i];
+ MuxStream *ms = ms_from_ost(ost);
enum AVMediaType type = ost->st->codecpar->codec_type;
ost->sq_idx_encode = -1;
@@ -1173,8 +1174,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
nb_interleaved += IS_INTERLEAVED(type);
nb_av_enc += IS_AV_ENC(ost, type);
- limit_frames |= ost->max_frames < INT64_MAX;
- limit_frames_av_enc |= (ost->max_frames < INT64_MAX) && IS_AV_ENC(ost, type);
+ limit_frames |= ms->max_frames < INT64_MAX;
+ limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type);
}
if (!((nb_interleaved > 1 && of->shortest) ||
@@ -1191,13 +1192,14 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
for (int i = 0; i < oc->nb_streams; i++) {
OutputStream *ost = of->streams[i];
+ MuxStream *ms = ms_from_ost(ost);
enum AVMediaType type = ost->st->codecpar->codec_type;
if (!IS_AV_ENC(ost, type))
continue;
ost->sq_idx_encode = sq_add_stream(of->sq_encode,
- of->shortest || ost->max_frames < INT64_MAX);
+ of->shortest || ms->max_frames < INT64_MAX);
if (ost->sq_idx_encode < 0)
return ost->sq_idx_encode;
@@ -1205,8 +1207,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
if (!ost->sq_frame)
return AVERROR(ENOMEM);
- if (ost->max_frames != INT64_MAX)
- sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ost->max_frames);
+ if (ms->max_frames != INT64_MAX)
+ sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ms->max_frames);
}
}
@@ -1223,18 +1225,19 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
for (int i = 0; i < oc->nb_streams; i++) {
OutputStream *ost = of->streams[i];
+ MuxStream *ms = ms_from_ost(ost);
enum AVMediaType type = ost->st->codecpar->codec_type;
if (!IS_INTERLEAVED(type))
continue;
ost->sq_idx_mux = sq_add_stream(mux->sq_mux,
- of->shortest || ost->max_frames < INT64_MAX);
+ of->shortest || ms->max_frames < INT64_MAX);
if (ost->sq_idx_mux < 0)
return ost->sq_idx_mux;
- if (ost->max_frames != INT64_MAX)
- sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ost->max_frames);
+ if (ms->max_frames != INT64_MAX)
+ sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ms->max_frames);
}
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
` (2 preceding siblings ...)
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_mux_init: do not call av{codec, format}_get_class() repeatedly Anton Khirnov
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg.h | 2 +-
fftools/ffmpeg_mux_init.c | 91 +++++++++++++++++++++------------------
fftools/ffmpeg_opt.c | 2 +-
3 files changed, 51 insertions(+), 44 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index ad53ad4ce8..b9262b373f 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -694,7 +694,7 @@ void assert_avoptions(AVDictionary *m);
void assert_file_overwrite(const char *filename);
char *file_read(const char *filename);
-AVDictionary *strip_specifiers(AVDictionary *dict);
+AVDictionary *strip_specifiers(const AVDictionary *dict);
const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder);
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 150eb77ee2..7ccaf9da78 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1725,14 +1725,60 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
return 0;
}
+static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt)
+{
+ const OutputFile *of = &mux->of;
+
+ AVDictionary *unused_opts;
+ const AVDictionaryEntry *e;
+
+ unused_opts = strip_specifiers(codec_avopt);
+ for (int i = 0; i < of->nb_streams; i++) {
+ e = NULL;
+ while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e,
+ AV_DICT_IGNORE_SUFFIX)))
+ av_dict_set(&unused_opts, e->key, NULL, 0);
+ }
+
+ e = NULL;
+ while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
+ const AVClass *class = avcodec_get_class();
+ const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
+ const AVClass *fclass = avformat_get_class();
+ const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
+ if (!option || foption)
+ continue;
+
+ if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
+ av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
+ "output file #%d (%s) is not an encoding option.\n", e->key,
+ option->help ? option->help : "", nb_output_files - 1,
+ mux->fc->url);
+ exit_program(1);
+ }
+
+ // gop_timecode is injected by generic code but not always used
+ if (!strcmp(e->key, "gop_timecode"))
+ continue;
+
+ av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
+ "output file #%d (%s) has not been used for any stream. The most "
+ "likely reason is either wrong type (e.g. a video option with "
+ "no video streams) or that it is a private option of some encoder "
+ "which was not actually used for any stream.\n", e->key,
+ option->help ? option->help : "", nb_output_files - 1, mux->fc->url);
+ }
+ av_dict_free(&unused_opts);
+}
+
int of_open(const OptionsContext *o, const char *filename)
{
Muxer *mux;
AVFormatContext *oc;
int err;
OutputFile *of;
- AVDictionary *unused_opts = NULL;
- const AVDictionaryEntry *e = NULL;
int64_t recording_time = o->recording_time;
int64_t stop_time = o->stop_time;
@@ -1795,46 +1841,7 @@ int of_open(const OptionsContext *o, const char *filename)
create_streams(mux, o);
/* check if all codec options have been used */
- unused_opts = strip_specifiers(o->g->codec_opts);
- for (int i = 0; i < of->nb_streams; i++) {
- e = NULL;
- while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e,
- AV_DICT_IGNORE_SUFFIX)))
- av_dict_set(&unused_opts, e->key, NULL, 0);
- }
-
- e = NULL;
- while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
- const AVClass *class = avcodec_get_class();
- const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
- AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
- const AVClass *fclass = avformat_get_class();
- const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
- AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
- if (!option || foption)
- continue;
-
-
- if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
- av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
- "output file #%d (%s) is not an encoding option.\n", e->key,
- option->help ? option->help : "", nb_output_files - 1,
- filename);
- exit_program(1);
- }
-
- // gop_timecode is injected by generic code but not always used
- if (!strcmp(e->key, "gop_timecode"))
- continue;
-
- av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
- "output file #%d (%s) has not been used for any stream. The most "
- "likely reason is either wrong type (e.g. a video option with "
- "no video streams) or that it is a private option of some encoder "
- "which was not actually used for any stream.\n", e->key,
- option->help ? option->help : "", nb_output_files - 1, filename);
- }
- av_dict_free(&unused_opts);
+ validate_enc_avopt(mux, o->g->codec_opts);
/* set the decoding_needed flags and create simple filtergraphs */
for (int i = 0; i < of->nb_streams; i++) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 0fd9d98f0f..5ab296828b 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -165,7 +165,7 @@ static int show_hwaccels(void *optctx, const char *opt, const char *arg)
}
/* return a copy of the input with the stream specifiers removed from the keys */
-AVDictionary *strip_specifiers(AVDictionary *dict)
+AVDictionary *strip_specifiers(const AVDictionary *dict)
{
const AVDictionaryEntry *e = NULL;
AVDictionary *ret = NULL;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_mux_init: do not call av{codec, format}_get_class() repeatedly
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
` (3 preceding siblings ...)
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 7/8] fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate Anton Khirnov
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg_mux_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 7ccaf9da78..6ed30eb498 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1727,6 +1727,8 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt)
{
+ const AVClass *class = avcodec_get_class();
+ const AVClass *fclass = avformat_get_class();
const OutputFile *of = &mux->of;
AVDictionary *unused_opts;
@@ -1742,10 +1744,8 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
- const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
- const AVClass *fclass = avformat_get_class();
const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option || foption)
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 7/8] fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
` (4 preceding siblings ...)
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_mux_init: do not call av{codec, format}_get_class() repeatedly Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg_mux_init: drop an always-false check Anton Khirnov
2022-11-14 17:29 ` [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Soft Works
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg_mux_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6ed30eb498..277cbd1f64 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1737,13 +1737,12 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt
unused_opts = strip_specifiers(codec_avopt);
for (int i = 0; i < of->nb_streams; i++) {
e = NULL;
- while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e,
- AV_DICT_IGNORE_SUFFIX)))
+ while ((e = av_dict_iterate(of->streams[i]->encoder_opts, e)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
- while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
+ while ((e = av_dict_iterate(unused_opts, e))) {
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg_mux_init: drop an always-false check
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
` (5 preceding siblings ...)
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 7/8] fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate Anton Khirnov
@ 2022-11-14 15:13 ` Anton Khirnov
2022-11-14 17:29 ` [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Soft Works
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-11-14 15:13 UTC (permalink / raw)
To: ffmpeg-devel
It cannot be true since 1959351aecf. Effectively reverts 6a3833e1411.
---
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_demux.c | 2 --
fftools/ffmpeg_mux_init.c | 6 ------
fftools/ffmpeg_opt.c | 5 -----
4 files changed, 14 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index b9262b373f..a96ff0d723 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -674,7 +674,6 @@ extern HWDevice *filter_hw_device;
extern unsigned nb_output_dumped;
extern int main_return_code;
-extern int input_stream_potentially_available;
extern int ignore_unknown_streams;
extern int copy_unknown_streams;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 94fd604fd9..595a56a590 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1097,7 +1097,5 @@ int ifile_open(const OptionsContext *o, const char *filename)
}
}
- input_stream_potentially_available = 1;
-
return 0;
}
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 277cbd1f64..db45fa09fa 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1911,12 +1911,6 @@ int of_open(const OptionsContext *o, const char *filename)
}
}
- if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {
- av_log(NULL, AV_LOG_ERROR,
- "No input streams but output needs an input stream\n");
- exit_program(1);
- }
-
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
/* test if it already exists to avoid losing precious files */
assert_file_overwrite(filename);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 5ab296828b..61aa0be0ab 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -95,7 +95,6 @@ static int no_file_overwrite = 0;
#if FFMPEG_OPT_PSNR
int do_psnr = 0;
#endif
-int input_stream_potentially_available = 0;
int ignore_unknown_streams = 0;
int copy_unknown_streams = 0;
int recast_media = 0;
@@ -1114,8 +1113,6 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
if (!fg->graph_desc)
return AVERROR(ENOMEM);
- input_stream_potentially_available = 1;
-
return 0;
}
@@ -1130,8 +1127,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
fg->index = nb_filtergraphs - 1;
fg->graph_desc = graph_desc;
- input_stream_potentially_available = 1;
-
return 0;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter()
2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov
` (6 preceding siblings ...)
2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg_mux_init: drop an always-false check Anton Khirnov
@ 2022-11-14 17:29 ` Soft Works
7 siblings, 0 replies; 9+ messages in thread
From: Soft Works @ 2022-11-14 17:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Anton Khirnov
> Sent: Monday, November 14, 2022 4:14 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify
> ost_iter()
>
> The inner loop never goes through more than 1 iteration, and so can
> be
> replaced by an if().
>
> Found-by: Andreas Rheinhardt
> ---
> fftools/ffmpeg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index e6f6773f6a..0fa2fe8c52 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -612,7 +612,7 @@ static OutputStream *ost_iter(OutputStream *prev)
>
> for (; of_idx < nb_output_files; of_idx++) {
> OutputFile *of = output_files[of_idx];
> - for (; ost_idx < of->nb_streams; ost_idx++)
> + if (ost_idx < of->nb_streams)
> return of->streams[ost_idx];
>
> ost_idx = 0;
> --
> 2.35.1
I'm objecting the whole patchset.
I think it's not fundamental enough.
softworkz
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread