* [FFmpeg-devel] [PATCH 02/12] fftools/ffmpeg: replace InputStream.file_index by a pointer
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
@ 2023-12-13 19:29 ` Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index " Anton Khirnov
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:29 UTC (permalink / raw)
To: ffmpeg-devel
Reduces the need to use the input_files global array.
---
fftools/ffmpeg.c | 6 +++---
fftools/ffmpeg.h | 4 +++-
fftools/ffmpeg_dec.c | 10 +++++-----
fftools/ffmpeg_demux.c | 9 ++++-----
fftools/ffmpeg_filter.c | 14 +++++++-------
fftools/ffmpeg_mux_init.c | 10 +++++-----
6 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 30b594fd97..3aab302c27 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -390,7 +390,7 @@ OutputStream *ost_iter(OutputStream *prev)
InputStream *ist_iter(InputStream *prev)
{
- int if_idx = prev ? prev->file_index : 0;
+ int if_idx = prev ? prev->file->index : 0;
int ist_idx = prev ? prev->index + 1 : 0;
for (; if_idx < nb_input_files; if_idx++) {
@@ -752,7 +752,7 @@ static void print_stream_maps(void)
for (int j = 0; j < ist->nb_filters; j++) {
if (!filtergraph_is_simple(ist->filters[j]->graph)) {
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
- ist->file_index, ist->index, ist->dec ? ist->dec->name : "?",
+ ist->file->index, ist->index, ist->dec ? ist->dec->name : "?",
ist->filters[j]->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
@@ -781,7 +781,7 @@ static void print_stream_maps(void)
}
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
- ost->ist->file_index,
+ ost->ist->file->index,
ost->ist->index,
ost->file_index,
ost->index);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 69bd23f576..d7b6e689fc 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -333,7 +333,9 @@ typedef struct Decoder Decoder;
typedef struct InputStream {
const AVClass *class;
- int file_index;
+ /* parent source */
+ struct InputFile *file;
+
int index;
AVStream *st;
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 5dde82a276..219bcf39e4 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -193,7 +193,7 @@ static void audio_ts_process(void *logctx, Decoder *d, AVFrame *frame)
static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame)
{
const Decoder *d = ist->decoder;
- const InputFile *ifile = input_files[ist->file_index];
+ const InputFile *ifile = ist->file;
int64_t codec_duration = 0;
// XXX lavf currently makes up frame durations when they are not provided by
@@ -455,7 +455,7 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
{
- const InputFile *ifile = input_files[ist->file_index];
+ const InputFile *ifile = ist->file;
Decoder *d = ist->decoder;
AVCodecContext *dec = ist->dec_ctx;
const char *type_desc = av_get_media_type_string(dec->codec_type);
@@ -504,7 +504,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
update_benchmark(NULL);
ret = avcodec_receive_frame(dec, frame);
update_benchmark("decode_%s %d.%d", type_desc,
- ist->file_index, ist->index);
+ ifile->index, ist->index);
if (ret == AVERROR(EAGAIN)) {
av_assert0(pkt); // should never happen during flushing
@@ -550,7 +550,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
ret = video_frame_process(ist, frame);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
- "data for stream #%d:%d\n", ist->file_index, ist->index);
+ "data for stream #%d:%d\n", ifile->index, ist->index);
return ret;
}
}
@@ -568,7 +568,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
static void dec_thread_set_name(const InputStream *ist)
{
char name[16];
- snprintf(name, sizeof(name), "dec%d:%d:%s", ist->file_index, ist->index,
+ snprintf(name, sizeof(name), "dec%d:%d:%s", ist->file->index, ist->index,
ist->dec_ctx->codec->name);
ff_thread_setname(name);
}
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 91cd7a1125..61fb856106 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -463,8 +463,7 @@ static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags)
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base),
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base),
- av_ts2str(input_files[ist->file_index]->ts_offset),
- av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q));
+ av_ts2str(f->ts_offset), av_ts2timestr(f->ts_offset, &AV_TIME_BASE_Q));
}
pkt->stream_index = ds->sch_idx_stream;
@@ -761,7 +760,7 @@ void ifile_close(InputFile **pf)
static int ist_use(InputStream *ist, int decoding_needed)
{
- Demuxer *d = demuxer_from_ifile(input_files[ist->file_index]);
+ Demuxer *d = demuxer_from_ifile(ist->file);
DemuxStream *ds = ds_from_ist(ist);
int ret;
@@ -830,7 +829,7 @@ int ist_output_add(InputStream *ist, OutputStream *ost)
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
{
- Demuxer *d = demuxer_from_ifile(input_files[ist->file_index]);
+ Demuxer *d = demuxer_from_ifile(ist->file);
DemuxStream *ds = ds_from_ist(ist);
int ret;
@@ -994,7 +993,7 @@ static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st)
ds->sch_idx_dec = -1;
ds->ist.st = st;
- ds->ist.file_index = f->index;
+ ds->ist.file = f;
ds->ist.index = st->index;
ds->ist.class = &input_stream_class;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3b0d457cc2..40608d9e44 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1456,7 +1456,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
const AVPixFmtDescriptor *desc;
InputStream *ist = ifp->ist;
- InputFile *f = input_files[ist->file_index];
+ InputFile *f = ist->file;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
@@ -1497,7 +1497,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
- ist->file_index, ist->index);
+ f->index, ist->index);
if ((ret = avfilter_graph_create_filter(&ifp->filter, buffer_filt, name,
@@ -1556,7 +1556,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
}
snprintf(name, sizeof(name), "trim_in_%d_%d",
- ist->file_index, ist->index);
+ f->index, ist->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -1584,7 +1584,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
AVFilterContext *last_filter;
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
InputStream *ist = ifp->ist;
- InputFile *f = input_files[ist->file_index];
+ InputFile *f = ist->file;
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
@@ -1609,7 +1609,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
} else
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
- ist->file_index, ist->index);
+ f->index, ist->index);
if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt,
name, args.str, NULL,
@@ -1618,7 +1618,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
last_filter = ifp->filter;
snprintf(name, sizeof(name), "trim for input stream %d:%d",
- ist->file_index, ist->index);
+ f->index, ist->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -2569,7 +2569,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
if (ifp->format < 0) {
av_log(NULL, AV_LOG_ERROR,
"Cannot determine format of input stream %d:%d after EOF\n",
- ifp->ist->file_index, ifp->ist->index);
+ ifp->ist->file->index, ifp->ist->index);
return AVERROR_INVALIDDATA;
}
}
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6459296ab0..64c173e006 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -819,7 +819,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
}
if (ost->ist && ost->vsync_method == VSYNC_CFR) {
- const InputFile *ifile = input_files[ost->ist->file_index];
+ const InputFile *ifile = ost->ist->file;
if (ifile->nb_streams == 1 && ifile->input_ts_offset == 0)
ost->vsync_method = VSYNC_VSCFR;
@@ -907,7 +907,7 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
ist = ost->ist;
}
- if (!ist || (ist->file_index == map->file_idx && ist->index == map->stream_idx)) {
+ if (!ist || (ist->file->index == map->file_idx && ist->index == map->stream_idx)) {
ret = av_reallocp_array(&ost->audio_channels_map,
ost->audio_channels_mapped + 1,
sizeof(*ost->audio_channels_map));
@@ -970,7 +970,7 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost)
MuxStream *ms = ms_from_ost(ost);
const InputStream *ist = ost->ist;
- const InputFile *ifile = input_files[ist->file_index];
+ const InputFile *ifile = ist->file;
AVCodecParameters *par = ost->par_in;
uint32_t codec_tag = par->codec_tag;
@@ -1208,7 +1208,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
av_get_media_type_string(type));
if (ist)
av_log(ost, AV_LOG_VERBOSE, "input stream %d:%d",
- ist->file_index, ist->index);
+ ist->file->index, ist->index);
else if (ofilter)
av_log(ost, AV_LOG_VERBOSE, "complex filtergraph %d:[%s]\n",
ofilter->graph->index, ofilter->name);
@@ -1480,7 +1480,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
if (ret < 0)
return ret;
} else {
- ret = sch_connect(mux->sch, SCH_DSTREAM(ost->ist->file_index, sched_idx),
+ ret = sch_connect(mux->sch, SCH_DSTREAM(ost->ist->file->index, sched_idx),
SCH_MSTREAM(ost->file_index, ms->sch_idx));
if (ret < 0)
return ret;
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index by a pointer
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 02/12] fftools/ffmpeg: replace InputStream.file_index by a pointer Anton Khirnov
@ 2023-12-13 19:29 ` Anton Khirnov
2023-12-14 19:20 ` Michael Niedermayer
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: move InputStream.discard to private data Anton Khirnov
` (8 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:29 UTC (permalink / raw)
To: ffmpeg-devel
Reduces the need to use the output_files global array.
---
fftools/ffmpeg.c | 12 ++++++------
fftools/ffmpeg.h | 4 +++-
fftools/ffmpeg_enc.c | 21 +++++++++++----------
fftools/ffmpeg_filter.c | 22 +++++++++++-----------
fftools/ffmpeg_mux.c | 11 +++++------
fftools/ffmpeg_mux_init.c | 12 ++++++------
6 files changed, 42 insertions(+), 40 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 3aab302c27..8077248254 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -374,7 +374,7 @@ static void ffmpeg_cleanup(int ret)
OutputStream *ost_iter(OutputStream *prev)
{
- int of_idx = prev ? prev->file_index : 0;
+ int of_idx = prev ? prev->file->index : 0;
int ost_idx = prev ? prev->index + 1 : 0;
for (; of_idx < nb_output_files; of_idx++) {
@@ -515,7 +515,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
if (vid && ost->type == AVMEDIA_TYPE_VIDEO) {
av_bprintf(&buf, "q=%2.1f ", q);
av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
- ost->file_index, ost->index, q);
+ ost->file->index, ost->index, q);
}
if (!vid && ost->type == AVMEDIA_TYPE_VIDEO && ost->filter) {
float fps;
@@ -527,7 +527,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
av_bprintf(&buf_script, "frame=%"PRId64"\n", frame_number);
av_bprintf(&buf_script, "fps=%.2f\n", fps);
av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
- ost->file_index, ost->index, q);
+ ost->file->index, ost->index, q);
if (is_last_report)
av_bprintf(&buf, "L");
@@ -765,7 +765,7 @@ static void print_stream_maps(void)
if (ost->attachment_filename) {
/* an attached file */
av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
- ost->attachment_filename, ost->file_index, ost->index);
+ ost->attachment_filename, ost->file->index, ost->index);
continue;
}
@@ -775,7 +775,7 @@ static void print_stream_maps(void)
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
- av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
+ av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file->index,
ost->index, ost->enc_ctx->codec->name);
continue;
}
@@ -783,7 +783,7 @@ static void print_stream_maps(void)
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
ost->ist->file->index,
ost->ist->index,
- ost->file_index,
+ ost->file->index,
ost->index);
if (ost->enc_ctx) {
const AVCodec *in_codec = ost->ist->dec;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d7b6e689fc..63e72e4fbc 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -514,7 +514,9 @@ typedef struct OutputStream {
enum AVMediaType type;
- int file_index; /* file index */
+ /* parent muxer */
+ struct OutputFile *file;
+
int index; /* stream index in the output file */
/**
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 320df2dee7..9b013af2fe 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -172,7 +172,7 @@ int enc_open(void *opaque, const AVFrame *frame)
AVCodecContext *enc_ctx = ost->enc_ctx;
AVCodecContext *dec_ctx = NULL;
const AVCodec *enc = enc_ctx->codec;
- OutputFile *of = output_files[ost->file_index];
+ OutputFile *of = ost->file;
FrameData *fd;
int frame_samples = 0;
int ret;
@@ -188,7 +188,7 @@ int enc_open(void *opaque, const AVFrame *frame)
fd = (FrameData*)frame->opaque_ref->data;
}
- ret = set_encoder_id(output_files[ost->file_index], ost);
+ ret = set_encoder_id(of, ost);
if (ret < 0)
return ret;
@@ -374,7 +374,7 @@ int enc_open(void *opaque, const AVFrame *frame)
static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb)
{
- OutputFile *of = output_files[ost->file_index];
+ OutputFile *of = ost->file;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ts, tb, of->recording_time, AV_TIME_BASE_Q) >= 0) {
@@ -413,8 +413,8 @@ static int do_subtitle_out(OutputFile *of, OutputStream *ost, const AVSubtitle *
/* shift timestamp to honor -ss and make check_recording_time() work with -t */
pts = sub->pts;
- if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
- pts -= output_files[ost->file_index]->start_time;
+ if (of->start_time != AV_NOPTS_VALUE)
+ pts -= of->start_time;
for (i = 0; i < nb; i++) {
AVSubtitle local_sub = *sub;
@@ -495,7 +495,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
switch (c->type) {
case ENC_STATS_LITERAL: avio_write (io, c->str, c->str_len); continue;
- case ENC_STATS_FILE_IDX: avio_printf(io, "%d", ost->file_index); continue;
+ case ENC_STATS_FILE_IDX: avio_printf(io, "%d", ost->file->index); continue;
case ENC_STATS_STREAM_IDX: avio_printf(io, "%d", ost->index); continue;
case ENC_STATS_TIMEBASE: avio_printf(io, "%d/%d", tb.num, tb.den); continue;
case ENC_STATS_TIMEBASE_IN: avio_printf(io, "%d/%d", tbi.num, tbi.den); continue;
@@ -583,7 +583,8 @@ static int update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_
fprintf(vstats_file, "frame= %5"PRId64" q= %2.1f ", frame_number,
quality / (float)FF_QP2LAMBDA);
} else {
- fprintf(vstats_file, "out= %2d st= %2d frame= %5"PRId64" q= %2.1f ", ost->file_index, ost->index, frame_number,
+ fprintf(vstats_file, "out= %2d st= %2d frame= %5"PRId64" q= %2.1f ",
+ ost->file->index, ost->index, frame_number,
quality / (float)FF_QP2LAMBDA);
}
@@ -648,7 +649,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame,
ret = avcodec_receive_packet(enc, pkt);
update_benchmark("%s_%s %d.%d", action, type_desc,
- ost->file_index, ost->index);
+ of->index, ost->index);
pkt->time_base = enc->time_base;
@@ -787,7 +788,7 @@ static int do_video_out(OutputFile *of, OutputStream *ost,
static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt)
{
- OutputFile *of = output_files[ost->file_index];
+ OutputFile *of = ost->file;
enum AVMediaType type = ost->type;
if (type == AVMEDIA_TYPE_SUBTITLE) {
@@ -810,7 +811,7 @@ static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt)
static void enc_thread_set_name(const OutputStream *ost)
{
char name[16];
- snprintf(name, sizeof(name), "enc%d:%d:%s", ost->file_index, ost->index,
+ snprintf(name, sizeof(name), "enc%d:%d:%s", ost->file->index, ost->index,
ost->enc_ctx->codec->name);
ff_thread_setname(name);
}
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 40608d9e44..4ecaa06be9 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -720,7 +720,7 @@ static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
unsigned sched_idx_enc)
{
- const OutputFile *of = output_files[ost->file_index];
+ const OutputFile *of = ost->file;
OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
FilterGraph *fg = ofilter->graph;
FilterGraphPriv *fgp = fgp_from_fg(fg);
@@ -1040,7 +1040,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf#%d:%d",
av_get_media_type_string(ost->type)[0],
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
if (fg->nb_inputs != 1 || fg->nb_outputs != 1) {
av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
@@ -1219,7 +1219,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph,
{
OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
OutputStream *ost = ofilter->ost;
- OutputFile *of = output_files[ost->file_index];
+ OutputFile *of = ost->file;
AVFilterContext *last_filter = out->filter_ctx;
AVBPrint bprint;
int pad_idx = out->pad_idx;
@@ -1227,7 +1227,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph,
const char *pix_fmts;
char name[255];
- snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
+ snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index);
ret = avfilter_graph_create_filter(&ofp->filter,
avfilter_get_by_name("buffersink"),
name, NULL, NULL, graph);
@@ -1248,7 +1248,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph,
}
snprintf(name, sizeof(name), "scaler_out_%d_%d",
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
name, args, NULL, graph)) < 0)
return ret;
@@ -1281,7 +1281,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph,
}
snprintf(name, sizeof(name), "trim_out_%d_%d",
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
ret = insert_trim(of->start_time, of->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -1299,14 +1299,14 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
{
OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
OutputStream *ost = ofilter->ost;
- OutputFile *of = output_files[ost->file_index];
+ OutputFile *of = ost->file;
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
AVBPrint args;
char name[255];
int ret;
- snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
+ snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index);
ret = avfilter_graph_create_filter(&ofp->filter,
avfilter_get_by_name("abuffersink"),
name, NULL, NULL, graph);
@@ -1361,7 +1361,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
AVFilterContext *format;
snprintf(name, sizeof(name), "format_out_%d_%d",
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
ret = avfilter_graph_create_filter(&format,
avfilter_get_by_name("aformat"),
name, args.str, NULL, graph);
@@ -1389,7 +1389,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
}
snprintf(name, sizeof(name), "trim for output stream %d:%d",
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
ret = insert_trim(of->start_time, of->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -2675,7 +2675,7 @@ static void fg_thread_set_name(const FilterGraph *fg)
OutputStream *ost = fg->outputs[0]->ost;
snprintf(name, sizeof(name), "%cf#%d:%d",
av_get_media_type_string(ost->type)[0],
- ost->file_index, ost->index);
+ ost->file->index, ost->index);
} else {
snprintf(name, sizeof(name), "fc%d", fg->index);
}
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 067dc65d4e..fdedc550e1 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -102,7 +102,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
pkt->dts > pkt->pts) {
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n",
pkt->dts, pkt->pts,
- ost->file_index, ost->st->index);
+ mux->of.index, ost->st->index);
pkt->pts =
pkt->dts = pkt->pts + pkt->dts + ms->last_mux_dts + 1
- FFMIN3(pkt->pts, pkt->dts, ms->last_mux_dts + 1)
@@ -118,7 +118,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
loglevel = AV_LOG_ERROR;
av_log(s, loglevel, "Non-monotonic DTS in output stream "
"%d:%d; previous: %"PRId64", current: %"PRId64"; ",
- ost->file_index, ost->st->index, ms->last_mux_dts, pkt->dts);
+ mux->of.index, ost->st->index, ms->last_mux_dts, pkt->dts);
if (exit_on_error) {
ret = AVERROR(EINVAL);
goto fail;
@@ -203,7 +203,7 @@ static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt, int
return 0;
}
-static int of_streamcopy(OutputStream *ost, AVPacket *pkt);
+static int of_streamcopy(OutputFile *of, OutputStream *ost, AVPacket *pkt);
/* apply the output bitstream filters */
static int mux_packet_filter(Muxer *mux, MuxThreadContext *mt,
@@ -214,7 +214,7 @@ static int mux_packet_filter(Muxer *mux, MuxThreadContext *mt,
int ret = 0;
if (pkt && !ost->enc) {
- ret = of_streamcopy(ost, pkt);
+ ret = of_streamcopy(&mux->of, ost, pkt);
if (ret == AVERROR(EAGAIN))
return 0;
else if (ret == AVERROR_EOF) {
@@ -377,9 +377,8 @@ finish:
return (void*)(intptr_t)ret;
}
-static int of_streamcopy(OutputStream *ost, AVPacket *pkt)
+static int of_streamcopy(OutputFile *of, OutputStream *ost, AVPacket *pkt)
{
- OutputFile *of = output_files[ost->file_index];
MuxStream *ms = ms_from_ost(ost);
DemuxPktData *pd = pkt->opaque_ref ? (DemuxPktData*)pkt->opaque_ref->data : NULL;
int64_t dts = pd ? pd->dts_est : AV_NOPTS_VALUE;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 64c173e006..455876d456 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -431,7 +431,7 @@ static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type)
if (!ms)
return NULL;
- ms->ost.file_index = mux->of.index;
+ ms->ost.file = &mux->of;
ms->ost.index = mux->of.nb_streams - 1;
ms->ost.type = type;
@@ -748,7 +748,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
FILE *f;
/* compute this stream's global index */
- for (int i = 0; i <= ost->file_index; i++)
+ for (int i = 0; i <= ost->file->index; i++)
ost_idx += output_files[i]->nb_streams;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
@@ -793,7 +793,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
ost->vsync_method = video_sync_method;
MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st);
if (fps_mode) {
- ret = parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0);
+ ret = parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file->index, ost->index, 0);
if (ret < 0)
return ret;
}
@@ -893,7 +893,7 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
/* check for channel mapping for this audio stream */
for (int n = 0; n < o->nb_audio_channel_maps; n++) {
AudioChannelMap *map = &o->audio_channel_maps[n];
- if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&
+ if ((map->ofile_idx == -1 || ost->file->index == map->ofile_idx) &&
(map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {
InputStream *ist;
@@ -901,7 +901,7 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
ist = NULL;
} else if (!ost->ist) {
av_log(ost, AV_LOG_FATAL, "Cannot determine input stream for channel mapping %d.%d\n",
- ost->file_index, ost->st->index);
+ ost->file->index, ost->st->index);
continue;
} else {
ist = ost->ist;
@@ -1481,7 +1481,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
return ret;
} else {
ret = sch_connect(mux->sch, SCH_DSTREAM(ost->ist->file->index, sched_idx),
- SCH_MSTREAM(ost->file_index, ms->sch_idx));
+ SCH_MSTREAM(ost->file->index, ms->sch_idx));
if (ret < 0)
return ret;
}
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index by a pointer
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index " Anton Khirnov
@ 2023-12-14 19:20 ` Michael Niedermayer
2023-12-14 19:34 ` Anton Khirnov
0 siblings, 1 reply; 15+ messages in thread
From: Michael Niedermayer @ 2023-12-14 19:20 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1318 bytes --]
On Wed, Dec 13, 2023 at 08:29:58PM +0100, Anton Khirnov wrote:
> Reduces the need to use the output_files global array.
> ---
> fftools/ffmpeg.c | 12 ++++++------
> fftools/ffmpeg.h | 4 +++-
> fftools/ffmpeg_enc.c | 21 +++++++++++----------
> fftools/ffmpeg_filter.c | 22 +++++++++++-----------
> fftools/ffmpeg_mux.c | 11 +++++------
> fftools/ffmpeg_mux_init.c | 12 ++++++------
> 6 files changed, 42 insertions(+), 40 deletions(-)
git seems to fail to apply this
Applying: fftools/ffmpeg: replace OutputStream.file_index by a pointer
error: sha1 information is lacking or useless (fftools/ffmpeg.c).
error: could not build fake ancestor
Patch failed at 0001 fftools/ffmpeg: replace OutputStream.file_index by a pointer
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index by a pointer
2023-12-14 19:20 ` Michael Niedermayer
@ 2023-12-14 19:34 ` Anton Khirnov
2023-12-14 19:53 ` James Almer
0 siblings, 1 reply; 15+ messages in thread
From: Anton Khirnov @ 2023-12-14 19:34 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Michael Niedermayer (2023-12-14 20:20:01)
> On Wed, Dec 13, 2023 at 08:29:58PM +0100, Anton Khirnov wrote:
> > Reduces the need to use the output_files global array.
> > ---
> > fftools/ffmpeg.c | 12 ++++++------
> > fftools/ffmpeg.h | 4 +++-
> > fftools/ffmpeg_enc.c | 21 +++++++++++----------
> > fftools/ffmpeg_filter.c | 22 +++++++++++-----------
> > fftools/ffmpeg_mux.c | 11 +++++------
> > fftools/ffmpeg_mux_init.c | 12 ++++++------
> > 6 files changed, 42 insertions(+), 40 deletions(-)
>
> git seems to fail to apply this
>
> Applying: fftools/ffmpeg: replace OutputStream.file_index by a pointer
> error: sha1 information is lacking or useless (fftools/ffmpeg.c).
> error: could not build fake ancestor
> Patch failed at 0001 fftools/ffmpeg: replace OutputStream.file_index by a pointer
> Use 'git am --show-current-patch' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
Oh sorry, only saw this email after pushing the patches (didn't want to
wait long, because they are quite simple and fix reported issues).
No idea why is it failing to apply, the branch should have been based on
master.
--
Anton Khirnov
_______________________________________________
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] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index by a pointer
2023-12-14 19:34 ` Anton Khirnov
@ 2023-12-14 19:53 ` James Almer
0 siblings, 0 replies; 15+ messages in thread
From: James Almer @ 2023-12-14 19:53 UTC (permalink / raw)
To: ffmpeg-devel
On 12/14/2023 4:34 PM, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2023-12-14 20:20:01)
>> On Wed, Dec 13, 2023 at 08:29:58PM +0100, Anton Khirnov wrote:
>>> Reduces the need to use the output_files global array.
>>> ---
>>> fftools/ffmpeg.c | 12 ++++++------
>>> fftools/ffmpeg.h | 4 +++-
>>> fftools/ffmpeg_enc.c | 21 +++++++++++----------
>>> fftools/ffmpeg_filter.c | 22 +++++++++++-----------
>>> fftools/ffmpeg_mux.c | 11 +++++------
>>> fftools/ffmpeg_mux_init.c | 12 ++++++------
>>> 6 files changed, 42 insertions(+), 40 deletions(-)
>>
>> git seems to fail to apply this
>>
>> Applying: fftools/ffmpeg: replace OutputStream.file_index by a pointer
>> error: sha1 information is lacking or useless (fftools/ffmpeg.c).
>> error: could not build fake ancestor
>> Patch failed at 0001 fftools/ffmpeg: replace OutputStream.file_index by a pointer
>> Use 'git am --show-current-patch' to see the failed patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
>
> Oh sorry, only saw this email after pushing the patches (didn't want to
> wait long, because they are quite simple and fix reported issues).
>
> No idea why is it failing to apply, the branch should have been based on
> master.
You pushed four patches that also touched the CLI some hours ago, to fix
other reported bugs. They were not in master when you sent this set
yesterday.
My guess is that on your end a git rebase handled it without conflicts,
but git am is in my experience a lot more nitpicky about non matches,
hence these not applying.
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: move InputStream.discard to private data
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 02/12] fftools/ffmpeg: replace InputStream.file_index by a pointer Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index " Anton Khirnov
@ 2023-12-13 19:29 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 05/12] fftools/ffmpeg: move InputStream.codec_desc " Anton Khirnov
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:29 UTC (permalink / raw)
To: ffmpeg-devel
It is not used outside of ffmpeg_demux.
---
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_demux.c | 23 +++++++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 63e72e4fbc..0bab44cefc 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -339,7 +339,6 @@ typedef struct InputStream {
int index;
AVStream *st;
- int discard; /* true if stream data should be discarded */
int user_set_discard;
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
#define DECODING_FOR_OST 1
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 61fb856106..9779580819 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -63,6 +63,9 @@ typedef struct DemuxStream {
double ts_scale;
+ /* true if stream data should be discarded */
+ int discard;
+
// scheduler returned EOF for this stream
int finished;
@@ -136,7 +139,8 @@ static Demuxer *demuxer_from_ifile(InputFile *f)
InputStream *ist_find_unused(enum AVMediaType type)
{
for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
- if (ist->par->codec_type == type && ist->discard &&
+ DemuxStream *ds = ds_from_ist(ist);
+ if (ist->par->codec_type == type && ds->discard &&
ist->user_set_discard != AVDISCARD_ALL)
return ist;
}
@@ -556,11 +560,14 @@ static void discard_unused_programs(InputFile *ifile)
AVProgram *p = ifile->ctx->programs[j];
int discard = AVDISCARD_ALL;
- for (int k = 0; k < p->nb_stream_indexes; k++)
- if (!ifile->streams[p->stream_index[k]]->discard) {
+ for (int k = 0; k < p->nb_stream_indexes; k++) {
+ DemuxStream *ds = ds_from_ist(ifile->streams[p->stream_index[k]]);
+
+ if (!ds->discard) {
discard = AVDISCARD_DEFAULT;
break;
}
+ }
p->discard = discard;
}
}
@@ -637,7 +644,7 @@ static void *input_thread(void *arg)
dynamically in stream : we ignore them */
ds = pkt->stream_index < f->nb_streams ?
ds_from_ist(f->streams[pkt->stream_index]) : NULL;
- if (!ds || ds->ist.discard || ds->finished) {
+ if (!ds || ds->discard || ds->finished) {
report_new_stream(d, pkt);
av_packet_unref(pkt);
continue;
@@ -689,7 +696,7 @@ static void demux_final_stats(Demuxer *d)
DemuxStream *ds = ds_from_ist(ist);
enum AVMediaType type = ist->par->codec_type;
- if (ist->discard || type == AVMEDIA_TYPE_ATTACHMENT)
+ if (ds->discard || type == AVMEDIA_TYPE_ATTACHMENT)
continue;
total_size += ds->data_size;
@@ -777,8 +784,8 @@ static int ist_use(InputStream *ist, int decoding_needed)
ds->sch_idx_stream = ret;
}
- if (ist->discard) {
- ist->discard = 0;
+ if (ds->discard) {
+ ds->discard = 0;
d->nb_streams_used++;
}
@@ -1024,7 +1031,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
ist = &ds->ist;
- ist->discard = 1;
+ ds->discard = 1;
st->discard = AVDISCARD_ALL;
ds->first_dts = AV_NOPTS_VALUE;
ds->next_dts = AV_NOPTS_VALUE;
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 05/12] fftools/ffmpeg: move InputStream.codec_desc to private data
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (2 preceding siblings ...)
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: move InputStream.discard to private data Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg: drop unused InputFile.eof_reached Anton Khirnov
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
It is not used outside of ffmpeg_demux.
---
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_demux.c | 8 +++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 0bab44cefc..f214e4efcb 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -353,7 +353,6 @@ typedef struct InputStream {
Decoder *decoder;
AVCodecContext *dec_ctx;
const AVCodec *dec;
- const AVCodecDescriptor *codec_desc;
AVRational framerate_guessed;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 9779580819..865c1e7d2f 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -83,6 +83,8 @@ typedef struct DemuxStream {
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
int64_t dts;
+ const AVCodecDescriptor *codec_desc;
+
/* number of packets successfully read for this stream */
uint64_t nb_packets;
// combined size of all the packets read
@@ -320,8 +322,8 @@ static int ist_dts_update(DemuxStream *ds, AVPacket *pkt)
(AVRational){ 2, 1 });
int fields = 2;
- if (ist->codec_desc &&
- (ist->codec_desc->props & AV_CODEC_PROP_FIELDS) &&
+ if (ds->codec_desc &&
+ (ds->codec_desc->props & AV_CODEC_PROP_FIELDS) &&
av_stream_get_parser(ist->st))
fields = 1 + av_stream_get_parser(ist->st)->repeat_pict;
@@ -1252,7 +1254,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
return ret;
}
- ist->codec_desc = avcodec_descriptor_get(ist->par->codec_id);
+ ds->codec_desc = avcodec_descriptor_get(ist->par->codec_id);
return 0;
}
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg: drop unused InputFile.eof_reached
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (3 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 05/12] fftools/ffmpeg: move InputStream.codec_desc " Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 07/12] fftools/ffmpeg_demux: move InputFile.readrate to private data Anton Khirnov
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f214e4efcb..3db3d87dfe 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -407,7 +407,6 @@ typedef struct InputFile {
int format_nots;
AVFormatContext *ctx;
- int eof_reached; /* true if eof reached */
int64_t input_ts_offset;
int input_sync_ref;
/**
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 07/12] fftools/ffmpeg_demux: move InputFile.readrate to private data
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (4 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg: drop unused InputFile.eof_reached Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 08/12] fftools/ffmpeg_mux: move OutputStream.sq_idx_mux " Anton Khirnov
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
It is not used outside of ffmpeg_demux.
---
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_demux.c | 19 ++++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3db3d87dfe..2963d2d5d4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -423,7 +423,6 @@ typedef struct InputFile {
InputStream **streams;
int nb_streams;
- float readrate;
int accurate_seek;
} InputFile;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 865c1e7d2f..f9c71f5b9a 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -117,6 +117,7 @@ typedef struct Demuxer {
/* number of streams that the user was warned of */
int nb_streams_warn;
+ float readrate;
double readrate_initial_burst;
Scheduler *sch;
@@ -491,7 +492,7 @@ static void readrate_sleep(Demuxer *d)
int64_t stream_ts_offset, pts, now;
stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
- now = (av_gettime_relative() - d->wallclock_start) * f->readrate + stream_ts_offset;
+ now = (av_gettime_relative() - d->wallclock_start) * d->readrate + stream_ts_offset;
if (pts - burst_until > now)
av_usleep(pts - burst_until - now);
}
@@ -667,7 +668,7 @@ static void *input_thread(void *arg)
if (ret < 0)
break;
- if (f->readrate)
+ if (d->readrate)
readrate_sleep(d);
ret = demux_send(d, ds, pkt, send_flags);
@@ -1582,19 +1583,19 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
f->format_nots = !!(ic->iformat->flags & AVFMT_NOTIMESTAMPS);
- f->readrate = o->readrate ? o->readrate : 0.0;
- if (f->readrate < 0.0f) {
- av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", f->readrate);
+ d->readrate = o->readrate ? o->readrate : 0.0;
+ if (d->readrate < 0.0f) {
+ av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", d->readrate);
return AVERROR(EINVAL);
}
if (o->rate_emu) {
- if (f->readrate) {
- av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", f->readrate);
+ if (d->readrate) {
+ av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", d->readrate);
} else
- f->readrate = 1.0f;
+ d->readrate = 1.0f;
}
- if (f->readrate) {
+ if (d->readrate) {
d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.5;
if (d->readrate_initial_burst < 0.0) {
av_log(d, AV_LOG_ERROR,
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 08/12] fftools/ffmpeg_mux: move OutputStream.sq_idx_mux to private data
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (5 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 07/12] fftools/ffmpeg_demux: move InputFile.readrate to private data Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 09/12] fftools/ffmpeg: drop OutputFile.sq_encode Anton Khirnov
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
It should not be accessed outside of ffmpeg_mux*
---
fftools/ffmpeg.h | 2 --
fftools/ffmpeg_mux.c | 12 ++++++------
fftools/ffmpeg_mux.h | 2 ++
fftools/ffmpeg_mux_init.c | 12 ++++++------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 2963d2d5d4..5c061ef0f4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -586,8 +586,6 @@ typedef struct OutputStream {
/* packet quality factor */
atomic_int quality;
- int sq_idx_mux;
-
EncStats enc_stats_pre;
EncStats enc_stats_post;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index fdedc550e1..06db55a6d4 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -168,12 +168,12 @@ fail:
return ret;
}
-static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt, int *stream_eof)
+static int sync_queue_process(Muxer *mux, MuxStream *ms, AVPacket *pkt, int *stream_eof)
{
OutputFile *of = &mux->of;
- if (ost->sq_idx_mux >= 0) {
- int ret = sq_send(mux->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
+ if (ms->sq_idx_mux >= 0) {
+ int ret = sq_send(mux->sq_mux, ms->sq_idx_mux, SQPKT(pkt));
if (ret < 0) {
if (ret == AVERROR_EOF)
*stream_eof = 1;
@@ -198,7 +198,7 @@ static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt, int
return ret;
}
} else if (pkt)
- return write_packet(mux, ost, pkt);
+ return write_packet(mux, &ms->ost, pkt);
return 0;
}
@@ -268,14 +268,14 @@ static int mux_packet_filter(Muxer *mux, MuxThreadContext *mt,
if (!bsf_eof)
ms->bsf_pkt->time_base = ms->bsf_ctx->time_base_out;
- ret = sync_queue_process(mux, ost, bsf_eof ? NULL : ms->bsf_pkt, stream_eof);
+ ret = sync_queue_process(mux, ms, bsf_eof ? NULL : ms->bsf_pkt, stream_eof);
if (ret < 0)
goto mux_fail;
}
*stream_eof = 1;
return AVERROR_EOF;
} else {
- ret = sync_queue_process(mux, ost, pkt, stream_eof);
+ ret = sync_queue_process(mux, ms, pkt, stream_eof);
if (ret < 0)
goto mux_fail;
}
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 5d7cf3fa76..d0be8a51ea 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -50,6 +50,8 @@ typedef struct MuxStream {
int sch_idx_enc;
int sch_idx_src;
+ int sq_idx_mux;
+
int64_t max_frames;
// timestamp from which the streamcopied streams should start,
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 455876d456..f527a083db 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1923,7 +1923,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
MuxStream *ms = ms_from_ost(ost);
enum AVMediaType type = ost->type;
- ost->sq_idx_mux = -1;
+ ms->sq_idx_mux = -1;
nb_interleaved += IS_INTERLEAVED(type);
nb_av_enc += IS_AV_ENC(ost, type);
@@ -1992,13 +1992,13 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u
if (!IS_INTERLEAVED(type))
continue;
- ost->sq_idx_mux = sq_add_stream(mux->sq_mux,
- of->shortest || ms->max_frames < INT64_MAX);
- if (ost->sq_idx_mux < 0)
- return ost->sq_idx_mux;
+ ms->sq_idx_mux = sq_add_stream(mux->sq_mux,
+ of->shortest || ms->max_frames < INT64_MAX);
+ if (ms->sq_idx_mux < 0)
+ return ms->sq_idx_mux;
if (ms->max_frames != INT64_MAX)
- sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ms->max_frames);
+ sq_limit_frames(mux->sq_mux, ms->sq_idx_mux, ms->max_frames);
}
}
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 09/12] fftools/ffmpeg: drop OutputFile.sq_encode
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (6 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 08/12] fftools/ffmpeg_mux: move OutputStream.sq_idx_mux " Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 10/12] fftools/ffmpeg_sched: move trailing_dts() higher up Anton Khirnov
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
It is unused since d119ae2fd82a494d9430ff4d4fc262961a68c598
---
fftools/ffmpeg.h | 2 --
fftools/ffmpeg_mux.c | 1 -
2 files changed, 3 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 5c061ef0f4..b7ec6085d3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -607,8 +607,6 @@ typedef struct OutputFile {
OutputStream **streams;
int nb_streams;
- SyncQueue *sq_encode;
-
int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units
int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 06db55a6d4..383ca4ecef 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -777,7 +777,6 @@ void of_free(OutputFile **pof)
return;
mux = mux_from_of(of);
- sq_free(&of->sq_encode);
sq_free(&mux->sq_mux);
for (int i = 0; i < of->nb_streams; i++)
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 10/12] fftools/ffmpeg_sched: move trailing_dts() higher up
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (7 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 09/12] fftools/ffmpeg: drop OutputFile.sq_encode Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg: update the reported timestamp at the end Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 12/12] fftools/ffmpeg_sched: track dts+duration as last_dts Anton Khirnov
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
Will be useful in following commit.
---
fftools/ffmpeg_sched.c | 44 +++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index 69f8c0c3c0..ab14d6233e 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -423,6 +423,28 @@ static void task_init(Scheduler *sch, SchTask *task, enum SchedulerNodeType type
task->func_arg = func_arg;
}
+static int64_t trailing_dts(const Scheduler *sch)
+{
+ int64_t min_dts = INT64_MAX;
+
+ for (unsigned i = 0; i < sch->nb_mux; i++) {
+ const SchMux *mux = &sch->mux[i];
+
+ for (unsigned j = 0; j < mux->nb_streams; j++) {
+ const SchMuxStream *ms = &mux->streams[j];
+
+ if (ms->source_finished)
+ continue;
+ if (ms->last_dts == AV_NOPTS_VALUE)
+ return AV_NOPTS_VALUE;
+
+ min_dts = FFMIN(min_dts, ms->last_dts);
+ }
+ }
+
+ return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
+}
+
int sch_stop(Scheduler *sch)
{
int ret = 0, err;
@@ -1162,28 +1184,6 @@ int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_
return 0;
}
-static int64_t trailing_dts(const Scheduler *sch)
-{
- int64_t min_dts = INT64_MAX;
-
- for (unsigned i = 0; i < sch->nb_mux; i++) {
- const SchMux *mux = &sch->mux[i];
-
- for (unsigned j = 0; j < mux->nb_streams; j++) {
- const SchMuxStream *ms = &mux->streams[j];
-
- if (ms->source_finished)
- continue;
- if (ms->last_dts == AV_NOPTS_VALUE)
- return AV_NOPTS_VALUE;
-
- min_dts = FFMIN(min_dts, ms->last_dts);
- }
- }
-
- return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
-}
-
static void schedule_update_locked(Scheduler *sch)
{
int64_t dts;
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg: update the reported timestamp at the end
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (8 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 10/12] fftools/ffmpeg_sched: move trailing_dts() higher up Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 12/12] fftools/ffmpeg_sched: track dts+duration as last_dts Anton Khirnov
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
Reported-by: microchip
---
fftools/ffmpeg.c | 2 +-
fftools/ffmpeg_sched.c | 13 ++++++++-----
fftools/ffmpeg_sched.h | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8077248254..4c706eb46a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -926,7 +926,7 @@ static int transcode(Scheduler *sch)
print_report(0, timer_start, cur_time, transcode_ts);
}
- ret = sch_stop(sch);
+ ret = sch_stop(sch, &transcode_ts);
/* write the trailer if needed */
for (i = 0; i < nb_output_files; i++) {
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index ab14d6233e..b1c7db776e 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -423,7 +423,7 @@ static void task_init(Scheduler *sch, SchTask *task, enum SchedulerNodeType type
task->func_arg = func_arg;
}
-static int64_t trailing_dts(const Scheduler *sch)
+static int64_t trailing_dts(const Scheduler *sch, int count_finished)
{
int64_t min_dts = INT64_MAX;
@@ -433,7 +433,7 @@ static int64_t trailing_dts(const Scheduler *sch)
for (unsigned j = 0; j < mux->nb_streams; j++) {
const SchMuxStream *ms = &mux->streams[j];
- if (ms->source_finished)
+ if (ms->source_finished && !count_finished)
continue;
if (ms->last_dts == AV_NOPTS_VALUE)
return AV_NOPTS_VALUE;
@@ -445,7 +445,7 @@ static int64_t trailing_dts(const Scheduler *sch)
return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
}
-int sch_stop(Scheduler *sch)
+int sch_stop(Scheduler *sch, int64_t *finish_ts)
{
int ret = 0, err;
@@ -492,6 +492,9 @@ int sch_stop(Scheduler *sch)
ret = err_merge(ret, err);
}
+ if (finish_ts)
+ *finish_ts = trailing_dts(sch, 1);
+
return ret;
}
@@ -502,7 +505,7 @@ void sch_free(Scheduler **psch)
if (!sch)
return;
- sch_stop(sch);
+ sch_stop(sch, NULL);
for (unsigned i = 0; i < sch->nb_demux; i++) {
SchDemux *d = &sch->demux[i];
@@ -1194,7 +1197,7 @@ static void schedule_update_locked(Scheduler *sch)
if (atomic_load(&sch->terminate))
return;
- dts = trailing_dts(sch);
+ dts = trailing_dts(sch, 0);
atomic_store(&sch->last_dts, dts);
diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h
index 94bbd30e98..b167d8d158 100644
--- a/fftools/ffmpeg_sched.h
+++ b/fftools/ffmpeg_sched.h
@@ -127,7 +127,7 @@ Scheduler *sch_alloc(void);
void sch_free(Scheduler **sch);
int sch_start(Scheduler *sch);
-int sch_stop(Scheduler *sch);
+int sch_stop(Scheduler *sch, int64_t *finish_ts);
/**
* Wait until transcoding terminates or the specified timeout elapses.
--
2.42.0
_______________________________________________
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] 15+ messages in thread
* [FFmpeg-devel] [PATCH 12/12] fftools/ffmpeg_sched: track dts+duration as last_dts
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
` (9 preceding siblings ...)
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg: update the reported timestamp at the end Anton Khirnov
@ 2023-12-13 19:30 ` Anton Khirnov
10 siblings, 0 replies; 15+ messages in thread
From: Anton Khirnov @ 2023-12-13 19:30 UTC (permalink / raw)
To: ffmpeg-devel
This should be slightly (probably negligibly) more accurate for
scheduling, but mainly it improves the final reported time.
Reported-by: Paul B Mahol
---
fftools/ffmpeg_sched.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index b1c7db776e..263b0094ca 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -192,7 +192,7 @@ typedef struct SchMuxStream {
////////////////////////////////////////////////////////////
// The following are protected by Scheduler.schedule_lock //
- /* dts of the last packet sent to this stream
+ /* dts+duration of the last packet sent to this stream
in AV_TIME_BASE_Q */
int64_t last_dts;
// this stream no longer accepts input
@@ -1619,8 +1619,8 @@ static int send_to_mux(Scheduler *sch, SchMux *mux, unsigned stream_idx,
AVPacket *pkt)
{
SchMuxStream *ms = &mux->streams[stream_idx];
- int64_t dts = (pkt && pkt->dts != AV_NOPTS_VALUE) ?
- av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q) :
+ int64_t dts = (pkt && pkt->dts != AV_NOPTS_VALUE) ?
+ av_rescale_q(pkt->dts + pkt->duration, pkt->time_base, AV_TIME_BASE_Q) :
AV_NOPTS_VALUE;
// queue the packet if the muxer cannot be started yet
--
2.42.0
_______________________________________________
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] 15+ messages in thread