* [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data
@ 2024-02-14 18:24 Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
It should never be necessary now that decoders propagate global side
data to frames.
---
fftools/ffmpeg_filter.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 38ddd1963a..ed62e1d8ec 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1523,16 +1523,9 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
- const AVPacketSideData *sd = NULL;
int32_t *displaymatrix = ifp->displaymatrix;
double theta;
- if (!ifp->displaymatrix_present)
- sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data,
- ist->st->codecpar->nb_coded_side_data,
- AV_PKT_DATA_DISPLAYMATRIX);
- if (sd)
- displaymatrix = (int32_t *)sd->data;
theta = get_rotation(displaymatrix);
if (fabs(theta - 90) < 1.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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input Anton Khirnov
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
The computation is based on demuxer properties, so that is the more
appropriate place for it. Filter code just receives the desired
start time/duration.
---
fftools/ffmpeg.h | 11 +++++++----
fftools/ffmpeg_demux.c | 24 +++++++++++++++++++-----
fftools/ffmpeg_filter.c | 23 ++++++-----------------
3 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 33750e0bb3..cbc5413238 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -250,6 +250,11 @@ typedef struct OptionsContext {
SpecifierOptList mux_stats_fmt;
} OptionsContext;
+typedef struct InputFilterOptions {
+ int64_t trim_start_us;
+ int64_t trim_end_us;
+} InputFilterOptions;
+
typedef struct InputFilter {
struct FilterGraph *graph;
uint8_t *name;
@@ -394,15 +399,12 @@ typedef struct InputFile {
int64_t ts_offset;
/* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
int64_t start_time;
- int64_t recording_time;
/* streams that ffmpeg is aware of;
* there may be extra streams in ctx that are not mapped to an InputStream
* if new streams appear dynamically during demuxing */
InputStream **streams;
int nb_streams;
-
- int accurate_seek;
} InputFile;
enum forced_keyframes_const {
@@ -790,7 +792,8 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch);
void ifile_close(InputFile **f);
int ist_output_add(InputStream *ist, OutputStream *ost);
-int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple);
+int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
+ InputFilterOptions *opts);
/**
* Find an unused input stream of given type.
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 3bf95e2c3f..abda4ad0d9 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -103,6 +103,9 @@ typedef struct Demuxer {
int64_t ts_offset_discont;
int64_t last_ts;
+ int64_t recording_time;
+ int accurate_seek;
+
/* number of times input stream should be looped */
int loop;
int have_audio_dec;
@@ -450,13 +453,13 @@ static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags)
if (ret < 0)
return ret;
- if (f->recording_time != INT64_MAX) {
+ if (d->recording_time != INT64_MAX) {
int64_t start_time = 0;
if (copy_ts) {
start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0;
start_time += start_at_zero ? 0 : f->start_time_effective;
}
- if (ds->dts >= f->recording_time + start_time)
+ if (ds->dts >= d->recording_time + start_time)
*send_flags |= DEMUX_SEND_STREAMCOPY_EOF;
}
@@ -966,10 +969,12 @@ int ist_output_add(InputStream *ist, OutputStream *ost)
return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream;
}
-int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
+int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
+ InputFilterOptions *opts)
{
Demuxer *d = demuxer_from_ifile(ist->file);
DemuxStream *ds = ds_from_ist(ist);
+ int64_t tsoffset = 0;
int ret;
ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
@@ -995,6 +1000,15 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
ds->have_sub2video = 1;
}
+ if (copy_ts) {
+ tsoffset = d->f.start_time == AV_NOPTS_VALUE ? 0 : d->f.start_time;
+ if (!start_at_zero && d->f.ctx->start_time != AV_NOPTS_VALUE)
+ tsoffset += d->f.ctx->start_time;
+ }
+ opts->trim_start_us = ((d->f.start_time == AV_NOPTS_VALUE) || !d->accurate_seek) ?
+ AV_NOPTS_VALUE : tsoffset;
+ opts->trim_end_us = d->recording_time;
+
return ds->sch_idx_dec;
}
@@ -1722,11 +1736,11 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
}
f->start_time = start_time;
- f->recording_time = recording_time;
+ d->recording_time = recording_time;
f->input_sync_ref = o->input_sync_ref;
f->input_ts_offset = o->input_ts_offset;
f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
- f->accurate_seek = o->accurate_seek;
+ d->accurate_seek = o->accurate_seek;
d->loop = o->loop;
d->nb_streams_warn = ic->nb_streams;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ed62e1d8ec..c411b882de 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -103,6 +103,8 @@ typedef struct FilterGraphThread {
typedef struct InputFilterPriv {
InputFilter ifilter;
+ InputFilterOptions opts;
+
int index;
AVFilterContext *filter;
@@ -673,7 +675,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
ifp->ist = ist;
ifp->type_src = ist->st->codecpar->codec_type;
- dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph));
+ dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph),
+ &ifp->opts);
if (dec_idx < 0)
return dec_idx;
@@ -1478,7 +1481,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
- int64_t tsoffset = 0;
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
if (!par)
return AVERROR(ENOMEM);
@@ -1558,13 +1560,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
snprintf(name, sizeof(name), "trim_in_%d_%d",
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)
- tsoffset += f->ctx->start_time;
- }
- ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
- AV_NOPTS_VALUE : tsoffset, f->recording_time,
+ ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
@@ -1589,7 +1585,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
- int64_t tsoffset = 0;
ifp->time_base = (AVRational){ 1, ifp->sample_rate };
@@ -1615,13 +1610,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
snprintf(name, sizeof(name), "trim for input stream %d:%d",
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)
- tsoffset += f->ctx->start_time;
- }
- ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
- AV_NOPTS_VALUE : tsoffset, f->recording_time,
+ ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions Anton Khirnov
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Do not construct the name manually from input file/stream indices.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
fftools/ffmpeg.h | 2 ++
fftools/ffmpeg_demux.c | 4 ++++
fftools/ffmpeg_filter.c | 21 ++++++++-------------
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cbc5413238..2c1ad714b6 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -253,6 +253,8 @@ typedef struct OptionsContext {
typedef struct InputFilterOptions {
int64_t trim_start_us;
int64_t trim_end_us;
+
+ uint8_t *name;
} InputFilterOptions;
typedef struct InputFilter {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index abda4ad0d9..4cbad80e17 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1009,6 +1009,10 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
AV_NOPTS_VALUE : tsoffset;
opts->trim_end_us = d->recording_time;
+ opts->name = av_strdup(ds->dec_name);
+ if (!opts->name)
+ return AVERROR(ENOMEM);
+
return ds->sch_idx_dec;
}
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index c411b882de..0f57035104 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -889,6 +889,7 @@ void fg_free(FilterGraph **pfg)
av_buffer_unref(&ifp->hw_frames_ctx);
av_freep(&ifp->linklabel);
+ av_freep(&ifp->opts.name);
av_freep(&ifilter->name);
av_freep(&fg->inputs[j]);
}
@@ -1475,7 +1476,6 @@ 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 = ist->file;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
@@ -1506,8 +1506,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
ifp->color_space, ifp->color_range);
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,
- f->index, ist->index);
+ snprintf(name, sizeof(name), "graph %d input from stream %s", fg->index,
+ ifp->opts.name);
if ((ret = avfilter_graph_create_filter(&ifp->filter, buffer_filt, name,
@@ -1558,8 +1558,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
return ret;
}
- snprintf(name, sizeof(name), "trim_in_%d_%d",
- f->index, ist->index);
+ snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name);
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -1580,8 +1579,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
AVFilterContext *last_filter;
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
- InputStream *ist = ifp->ist;
- InputFile *f = ist->file;
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
@@ -1599,8 +1596,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
av_channel_layout_describe_bprint(&ifp->ch_layout, &args);
} else
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
- snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
- f->index, ist->index);
+ snprintf(name, sizeof(name), "graph_%d_in_%s", fg->index, ifp->opts.name);
if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt,
name, args.str, NULL,
@@ -1608,8 +1604,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
return ret;
last_filter = ifp->filter;
- snprintf(name, sizeof(name), "trim for input stream %d:%d",
- f->index, ist->index);
+ snprintf(name, sizeof(name), "trim for input stream %s", ifp->opts.name);
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -2566,8 +2561,8 @@ 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);
+ "Cannot determine format of input %s after EOF\n",
+ ifp->opts.name);
return AVERROR_INVALIDDATA;
}
}
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags " Anton Khirnov
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Rather than read them directly from InputStream.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
fftools/ffmpeg.h | 7 +++----
fftools/ffmpeg_demux.c | 41 ++++++++++++++++++++---------------------
fftools/ffmpeg_filter.c | 21 ++++++++++-----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 2c1ad714b6..6db7b8a9c4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -255,6 +255,9 @@ typedef struct InputFilterOptions {
int64_t trim_end_us;
uint8_t *name;
+
+ int sub2video_width;
+ int sub2video_height;
} InputFilterOptions;
typedef struct InputFilter {
@@ -366,10 +369,6 @@ typedef struct InputStream {
int fix_sub_duration;
- struct sub2video {
- int w, h;
- } sub2video;
-
/* decoded data from this stream goes into all those filters
* currently video and audio only */
InputFilter **filters;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 4cbad80e17..87ed8225c2 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -992,6 +992,26 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
return ret;
if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ /* Compute the size of the canvas for the subtitles stream.
+ If the subtitles codecpar has set a size, use it. Otherwise use the
+ maximum dimensions of the video streams in the same file. */
+ opts->sub2video_width = ist->par->width;
+ opts->sub2video_height = ist->par->height;
+ if (!(opts->sub2video_width && opts->sub2video_height)) {
+ for (int j = 0; j < d->f.nb_streams; j++) {
+ AVCodecParameters *par1 = d->f.streams[j]->par;
+ if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
+ opts->sub2video_width = FFMAX(opts->sub2video_width, par1->width);
+ opts->sub2video_height = FFMAX(opts->sub2video_height, par1->height);
+ }
+ }
+ }
+
+ if (!(opts->sub2video_width && opts->sub2video_height)) {
+ opts->sub2video_width = FFMAX(opts->sub2video_width, 720);
+ opts->sub2video_height = FFMAX(opts->sub2video_height, 576);
+ }
+
if (!d->pkt_heartbeat) {
d->pkt_heartbeat = av_packet_alloc();
if (!d->pkt_heartbeat)
@@ -1357,27 +1377,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
return ret;
}
}
-
- /* Compute the size of the canvas for the subtitles stream.
- If the subtitles codecpar has set a size, use it. Otherwise use the
- maximum dimensions of the video streams in the same file. */
- ist->sub2video.w = par->width;
- ist->sub2video.h = par->height;
- if (!(ist->sub2video.w && ist->sub2video.h)) {
- for (int j = 0; j < ic->nb_streams; j++) {
- AVCodecParameters *par1 = ic->streams[j]->codecpar;
- if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
- ist->sub2video.w = FFMAX(ist->sub2video.w, par1->width);
- ist->sub2video.h = FFMAX(ist->sub2video.h, par1->height);
- }
- }
- }
-
- if (!(ist->sub2video.w && ist->sub2video.h)) {
- ist->sub2video.w = FFMAX(ist->sub2video.w, 720);
- ist->sub2video.h = FFMAX(ist->sub2video.h, 576);
- }
-
break;
}
case AVMEDIA_TYPE_ATTACHMENT:
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 0f57035104..d182f3ab2e 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -689,6 +689,16 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
ifp->sub2video.frame = av_frame_alloc();
if (!ifp->sub2video.frame)
return AVERROR(ENOMEM);
+
+ ifp->width = ifp->opts.sub2video_width;
+ ifp->height = ifp->opts.sub2video_height;
+
+ /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
+ palettes for all rectangles are identical or compatible */
+ ifp->format = AV_PIX_FMT_RGB32;
+
+ av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n",
+ ifp->width, ifp->height);
}
return 0;
@@ -1829,17 +1839,6 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec)
ret = av_channel_layout_copy(&ifp->fallback.ch_layout, &dec->ch_layout);
if (ret < 0)
return ret;
- } else {
- // for subtitles (i.e. sub2video) we set the actual parameters,
- // rather than just fallback
- ifp->width = ifp->ist->sub2video.w;
- ifp->height = ifp->ist->sub2video.h;
-
- /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
- palettes for all rectangles are identical or compatible */
- ifp->format = AV_PIX_FMT_RGB32;
-
- av_log(NULL, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n", ifp->width, ifp->height);
}
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags through InputFilterOptions
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (2 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate " Anton Khirnov
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Rather than read them directly from InputStream.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
fftools/ffmpeg.h | 10 ++++++++--
fftools/ffmpeg_demux.c | 8 ++++++--
fftools/ffmpeg_filter.c | 5 +++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6db7b8a9c4..9942342f03 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -250,6 +250,11 @@ typedef struct OptionsContext {
SpecifierOptList mux_stats_fmt;
} OptionsContext;
+enum IFilterFlags {
+ IFILTER_FLAG_AUTOROTATE = (1 << 0),
+ IFILTER_FLAG_REINIT = (1 << 1),
+};
+
typedef struct InputFilterOptions {
int64_t trim_start_us;
int64_t trim_end_us;
@@ -258,6 +263,9 @@ typedef struct InputFilterOptions {
int sub2video_width;
int sub2video_height;
+
+ // a combination of IFILTER_FLAG_*
+ unsigned flags;
} InputFilterOptions;
typedef struct InputFilter {
@@ -381,8 +389,6 @@ typedef struct InputStream {
*/
struct OutputStream **outputs;
int nb_outputs;
-
- int reinit_filters;
} InputStream;
typedef struct InputFile {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 87ed8225c2..317e27e294 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -63,6 +63,7 @@ typedef struct DemuxStream {
int streamcopy_needed;
int have_sub2video;
+ int reinit_filters;
int wrap_correction_done;
int saw_first_ts;
@@ -1033,6 +1034,9 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
if (!opts->name)
return AVERROR(ENOMEM);
+ opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ist->autorotate) |
+ IFILTER_FLAG_REINIT * !!(ds->reinit_filters);
+
return ds->sch_idx_dec;
}
@@ -1309,8 +1313,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
if (ret < 0)
return ret;
- ist->reinit_filters = -1;
- MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
+ ds->reinit_filters = -1;
+ MATCH_PER_STREAM_OPT(reinit_filters, i, ds->reinit_filters, ic, st);
ist->user_set_discard = AVDISCARD_NONE;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d182f3ab2e..56aa3edd78 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1534,7 +1534,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
av_assert0(desc);
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
- if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+ if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
+ !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
int32_t *displaymatrix = ifp->displaymatrix;
double theta;
@@ -2614,7 +2615,7 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
} else if (ifp->displaymatrix_present)
need_reinit |= MATRIX_CHANGED;
- if (!ifp->ist->reinit_filters && fgt->graph)
+ if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)
need_reinit = 0;
if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx ||
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate through InputFilterOptions
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (3 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags " Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Rather than read it directly from InputStream.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
fftools/ffmpeg.h | 10 ++++++++--
fftools/ffmpeg_demux.c | 10 +++++++---
fftools/ffmpeg_filter.c | 9 +++------
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 9942342f03..1fdc835723 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -253,6 +253,7 @@ typedef struct OptionsContext {
enum IFilterFlags {
IFILTER_FLAG_AUTOROTATE = (1 << 0),
IFILTER_FLAG_REINIT = (1 << 1),
+ IFILTER_FLAG_CFR = (1 << 2),
};
typedef struct InputFilterOptions {
@@ -261,6 +262,13 @@ typedef struct InputFilterOptions {
uint8_t *name;
+ /* When IFILTER_FLAG_CFR is set, the stream is guaranteed to be CFR with
+ * this framerate.
+ *
+ * Otherwise, this is an estimate that should not be relied upon to be
+ * accurate */
+ AVRational framerate;
+
int sub2video_width;
int sub2video_height;
@@ -365,8 +373,6 @@ typedef struct InputStream {
Decoder *decoder;
const AVCodec *dec;
- AVRational framerate_guessed;
-
/* framerate forced with -r */
AVRational framerate;
#if FFMPEG_OPT_TOP
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 317e27e294..e543c4215c 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -992,7 +992,13 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
if (ret < 0)
return ret;
- if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (ist->framerate.num > 0 && ist->framerate.den > 0) {
+ opts->framerate = ist->framerate;
+ opts->flags |= IFILTER_FLAG_CFR;
+ } else
+ opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL);
+ } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
/* Compute the size of the canvas for the subtitles stream.
If the subtitles codecpar has set a size, use it. Otherwise use the
maximum dimensions of the video streams in the same file. */
@@ -1359,8 +1365,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
#endif
- ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL);
-
break;
case AVMEDIA_TYPE_AUDIO: {
int guess_layout_max = INT_MAX;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 56aa3edd78..dc65b441a6 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1486,7 +1486,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;
- AVRational fr = ist->framerate;
+ AVRational fr = ifp->opts.framerate;
AVRational sar;
AVBPrint args;
char name[255];
@@ -1495,14 +1495,11 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
if (!par)
return AVERROR(ENOMEM);
- if (!fr.num)
- fr = ist->framerate_guessed;
-
if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
sub2video_prepare(ifp);
- ifp->time_base = ist->framerate.num ? av_inv_q(ist->framerate) :
- ist->st->time_base;
+ ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ?
+ av_inv_q(ifp->opts.framerate) : ist->st->time_base;
sar = ifp->sample_aspect_ratio;
if(!sar.den)
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (4 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate " Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-15 1:58 ` Michael Niedermayer
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov
` (2 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Treat it analogously to stream parameters like format/dimensions/etc.
This is functionally different from previous code in 2 ways:
* for non-CFR video, the frame timebase (set by the decoder) is used
rather than the demuxer timebase
* for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the
subtitle decoding API
These changes should avoid unnecessary and potentially lossy timestamp
conversions from decoder timebase into the demuxer one.
Changes the timebases used in sub2video tests.
---
fftools/ffmpeg_filter.c | 17 ++-
tests/ref/fate/sub2video_basic | 182 +++++++++++++-------------
tests/ref/fate/sub2video_time_limited | 8 +-
3 files changed, 106 insertions(+), 101 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index dc65b441a6..a13b2ccf95 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -148,6 +148,8 @@ typedef struct InputFilterPriv {
// fallback parameters to use when no input is ever sent
struct {
+ AVRational time_base;
+
int format;
int width;
@@ -697,6 +699,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
palettes for all rectangles are identical or compatible */
ifp->format = AV_PIX_FMT_RGB32;
+ ifp->time_base = AV_TIME_BASE_Q;
+
av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n",
ifp->width, ifp->height);
}
@@ -1485,7 +1489,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
AVFilterContext *last_filter;
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
const AVPixFmtDescriptor *desc;
- InputStream *ist = ifp->ist;
AVRational fr = ifp->opts.framerate;
AVRational sar;
AVBPrint args;
@@ -1498,9 +1501,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
sub2video_prepare(ifp);
- ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ?
- av_inv_q(ifp->opts.framerate) : ist->st->time_base;
-
sar = ifp->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
@@ -1591,8 +1591,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
char name[255];
int ret, pad_idx = 0;
- ifp->time_base = (AVRational){ 1, ifp->sample_rate };
-
av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
ifp->time_base.num, ifp->time_base.den,
@@ -1821,6 +1819,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec)
{
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
+ ifp->fallback.time_base = dec->pkt_timebase;
+
if (dec->codec_type == AVMEDIA_TYPE_VIDEO) {
ifp->fallback.format = dec->pix_fmt;
ifp->fallback.width = dec->width;
@@ -1852,6 +1852,10 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
if (ret < 0)
return ret;
+ ifp->time_base = (ifp->type == AVMEDIA_TYPE_AUDIO) ? (AVRational){ 1, frame->sample_rate } :
+ (ifp->opts.flags & IFILTER_FLAG_CFR) ? av_inv_q(ifp->opts.framerate) :
+ frame->time_base;
+
ifp->format = frame->format;
ifp->width = frame->width;
@@ -2541,6 +2545,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
ifp->sample_aspect_ratio = ifp->fallback.sample_aspect_ratio;
ifp->color_space = ifp->fallback.color_space;
ifp->color_range = ifp->fallback.color_range;
+ ifp->time_base = ifp->fallback.time_base;
ret = av_channel_layout_copy(&ifp->ch_layout,
&ifp->fallback.ch_layout);
diff --git a/tests/ref/fate/sub2video_basic b/tests/ref/fate/sub2video_basic
index a6eb1a34ea..2e4dcb625e 100644
--- a/tests/ref/fate/sub2video_basic
+++ b/tests/ref/fate/sub2video_basic
@@ -1,95 +1,95 @@
-#tb 0: 1/1000
+#tb 0: 1/1000000
#media_type 0: video
#codec_id 0: rawvideo
#dimensions 0: 720x480
#sar 0: 0/1
-0, 132499, 132499, 0, 1382400, 0x00000000
-0, 132499, 132499, 0, 1382400, 0x8c93c2ba
-0, 137459, 137459, 0, 1382400, 0x00000000
-0, 147355, 147355, 0, 1382400, 0xb02e32ca
-0, 152088, 152088, 0, 1382400, 0x00000000
-0, 180797, 180797, 0, 1382400, 0x83b71116
-0, 183357, 183357, 0, 1382400, 0x00000000
-0, 183433, 183433, 0, 1382400, 0x85547fd1
-0, 185799, 185799, 0, 1382400, 0x00000000
-0, 185909, 185909, 0, 1382400, 0x00000000
-0, 185910, 185910, 0, 1382400, 0xb6a8f181
-0, 188606, 188606, 0, 1382400, 0x00000000
-0, 188663, 188663, 0, 1382400, 0xb64d1a2c
-0, 189925, 189925, 0, 1382400, 0x00000000
-0, 190014, 190014, 0, 1382400, 0x7b37ecf3
-0, 191675, 191675, 0, 1382400, 0x00000000
-0, 199724, 199724, 0, 1382400, 0xdc025bd1
-0, 201089, 201089, 0, 1382400, 0x00000000
-0, 201175, 201175, 0, 1382400, 0x688b294d
-0, 202733, 202733, 0, 1382400, 0x00000000
-0, 202819, 202819, 0, 1382400, 0xa2b33d1b
-0, 204684, 204684, 0, 1382400, 0x00000000
-0, 204762, 204762, 0, 1382400, 0xb3e525e3
-0, 206730, 206730, 0, 1382400, 0x00000000
-0, 206806, 206806, 0, 1382400, 0xaa8fbdd7
-0, 208637, 208637, 0, 1382400, 0x00000000
-0, 208716, 208716, 0, 1382400, 0x7b7f26dd
-0, 209978, 209978, 0, 1382400, 0x00000000
-0, 210051, 210051, 0, 1382400, 0x15e2f836
-0, 211575, 211575, 0, 1382400, 0x00000000
-0, 211644, 211644, 0, 1382400, 0x0fee9b0c
-0, 214306, 214306, 0, 1382400, 0x00000000
-0, 214380, 214380, 0, 1382400, 0x89d62791
-0, 217144, 217144, 0, 1382400, 0x00000000
-0, 217225, 217225, 0, 1382400, 0xa6a9fd74
-0, 219591, 219591, 0, 1382400, 0x00000000
-0, 219652, 219652, 0, 1382400, 0x7896178d
-0, 221483, 221483, 0, 1382400, 0x00000000
-0, 223531, 223531, 0, 1382400, 0x01751a52
-0, 225863, 225863, 0, 1382400, 0x00000000
-0, 227510, 227510, 0, 1382400, 0xa3959c6f
-0, 230809, 230809, 0, 1382400, 0x00000000
-0, 230872, 230872, 0, 1382400, 0x3d3ea47b
-0, 233033, 233033, 0, 1382400, 0x00000000
-0, 233124, 233124, 0, 1382400, 0x593f8b24
-0, 237220, 237220, 0, 1382400, 0x00000000
-0, 237303, 237303, 0, 1382400, 0x171f05ba
-0, 240033, 240033, 0, 1382400, 0x00000000
-0, 240106, 240106, 0, 1382400, 0xb014cdf1
-0, 242165, 242165, 0, 1382400, 0x00000000
-0, 273556, 273556, 0, 1382400, 0xd918e667
-0, 275217, 275217, 0, 1382400, 0x00000000
-0, 295445, 295445, 0, 1382400, 0xc9406331
-0, 296776, 296776, 0, 1382400, 0x00000000
-0, 300049, 300049, 0, 1382400, 0xaf08b10d
-0, 301949, 301949, 0, 1382400, 0x00000000
-0, 302034, 302034, 0, 1382400, 0x00000000
-0, 302035, 302035, 0, 1382400, 0x853a9d93
-0, 303559, 303559, 0, 1382400, 0x00000000
-0, 304203, 304203, 0, 1382400, 0x7491a87d
-0, 305898, 305898, 0, 1382400, 0x00000000
-0, 305947, 305947, 0, 1382400, 0xf7383c58
-0, 307881, 307881, 0, 1382400, 0x00000000
-0, 307957, 307957, 0, 1382400, 0xe66be411
-0, 309720, 309720, 0, 1382400, 0x00000000
-0, 321295, 321295, 0, 1382400, 0xd6850362
-0, 323263, 323263, 0, 1382400, 0x00000000
-0, 323356, 323356, 0, 1382400, 0x3e1ed109
-0, 324584, 324584, 0, 1382400, 0x00000000
-0, 324640, 324640, 0, 1382400, 0x39c1b7bd
-0, 326403, 326403, 0, 1382400, 0x00000000
-0, 327193, 327193, 0, 1382400, 0x35b85f2e
-0, 328285, 328285, 0, 1382400, 0x00000000
-0, 328360, 328360, 0, 1382400, 0x00000000
-0, 328361, 328361, 0, 1382400, 0x83f103e5
-0, 329885, 329885, 0, 1382400, 0x00000000
-0, 329946, 329946, 0, 1382400, 0xbc1ca9b3
-0, 331106, 331106, 0, 1382400, 0x00000000
-0, 331230, 331230, 0, 1382400, 0x94d4a51e
-0, 332857, 332857, 0, 1382400, 0x00000000
-0, 332924, 332924, 0, 1382400, 0xf88cdfde
-0, 334687, 334687, 0, 1382400, 0x00000000
-0, 342600, 342600, 0, 1382400, 0xdd51423b
-0, 344431, 344431, 0, 1382400, 0x00000000
-0, 346771, 346771, 0, 1382400, 0x08259fa4
-0, 348329, 348329, 0, 1382400, 0x00000000
-0, 357640, 357640, 0, 1382400, 0x1663fa34
-0, 359767, 359767, 0, 1382400, 0x00000000
-0, 359834, 359834, 0, 1382400, 0xda2ceb55
-0, 361096, 361096, 0, 1382400, 0x00000000
+0, 132499000, 132499000, 0, 1382400, 0x00000000
+0, 132499000, 132499000, 0, 1382400, 0x8c93c2ba
+0, 137459000, 137459000, 0, 1382400, 0x00000000
+0, 147355000, 147355000, 0, 1382400, 0xb02e32ca
+0, 152088000, 152088000, 0, 1382400, 0x00000000
+0, 180797000, 180797000, 0, 1382400, 0x83b71116
+0, 183357000, 183357000, 0, 1382400, 0x00000000
+0, 183433000, 183433000, 0, 1382400, 0x85547fd1
+0, 185799000, 185799000, 0, 1382400, 0x00000000
+0, 185909999, 185909999, 0, 1382400, 0x00000000
+0, 185910000, 185910000, 0, 1382400, 0xb6a8f181
+0, 188606000, 188606000, 0, 1382400, 0x00000000
+0, 188663000, 188663000, 0, 1382400, 0xb64d1a2c
+0, 189925000, 189925000, 0, 1382400, 0x00000000
+0, 190014000, 190014000, 0, 1382400, 0x7b37ecf3
+0, 191675000, 191675000, 0, 1382400, 0x00000000
+0, 199724000, 199724000, 0, 1382400, 0xdc025bd1
+0, 201089000, 201089000, 0, 1382400, 0x00000000
+0, 201175000, 201175000, 0, 1382400, 0x688b294d
+0, 202733000, 202733000, 0, 1382400, 0x00000000
+0, 202819000, 202819000, 0, 1382400, 0xa2b33d1b
+0, 204684000, 204684000, 0, 1382400, 0x00000000
+0, 204762000, 204762000, 0, 1382400, 0xb3e525e3
+0, 206730000, 206730000, 0, 1382400, 0x00000000
+0, 206806000, 206806000, 0, 1382400, 0xaa8fbdd7
+0, 208637000, 208637000, 0, 1382400, 0x00000000
+0, 208716000, 208716000, 0, 1382400, 0x7b7f26dd
+0, 209978000, 209978000, 0, 1382400, 0x00000000
+0, 210051000, 210051000, 0, 1382400, 0x15e2f836
+0, 211575000, 211575000, 0, 1382400, 0x00000000
+0, 211644000, 211644000, 0, 1382400, 0x0fee9b0c
+0, 214306000, 214306000, 0, 1382400, 0x00000000
+0, 214380000, 214380000, 0, 1382400, 0x89d62791
+0, 217144000, 217144000, 0, 1382400, 0x00000000
+0, 217225000, 217225000, 0, 1382400, 0xa6a9fd74
+0, 219591000, 219591000, 0, 1382400, 0x00000000
+0, 219652000, 219652000, 0, 1382400, 0x7896178d
+0, 221483000, 221483000, 0, 1382400, 0x00000000
+0, 223531000, 223531000, 0, 1382400, 0x01751a52
+0, 225863000, 225863000, 0, 1382400, 0x00000000
+0, 227510000, 227510000, 0, 1382400, 0xa3959c6f
+0, 230809000, 230809000, 0, 1382400, 0x00000000
+0, 230872000, 230872000, 0, 1382400, 0x3d3ea47b
+0, 233033000, 233033000, 0, 1382400, 0x00000000
+0, 233124000, 233124000, 0, 1382400, 0x593f8b24
+0, 237220000, 237220000, 0, 1382400, 0x00000000
+0, 237303000, 237303000, 0, 1382400, 0x171f05ba
+0, 240033000, 240033000, 0, 1382400, 0x00000000
+0, 240106000, 240106000, 0, 1382400, 0xb014cdf1
+0, 242165000, 242165000, 0, 1382400, 0x00000000
+0, 273556000, 273556000, 0, 1382400, 0xd918e667
+0, 275217000, 275217000, 0, 1382400, 0x00000000
+0, 295445000, 295445000, 0, 1382400, 0xc9406331
+0, 296776000, 296776000, 0, 1382400, 0x00000000
+0, 300049000, 300049000, 0, 1382400, 0xaf08b10d
+0, 301949000, 301949000, 0, 1382400, 0x00000000
+0, 302034999, 302034999, 0, 1382400, 0x00000000
+0, 302035000, 302035000, 0, 1382400, 0x853a9d93
+0, 303559000, 303559000, 0, 1382400, 0x00000000
+0, 304203000, 304203000, 0, 1382400, 0x7491a87d
+0, 305898000, 305898000, 0, 1382400, 0x00000000
+0, 305947000, 305947000, 0, 1382400, 0xf7383c58
+0, 307881000, 307881000, 0, 1382400, 0x00000000
+0, 307957000, 307957000, 0, 1382400, 0xe66be411
+0, 309720000, 309720000, 0, 1382400, 0x00000000
+0, 321295000, 321295000, 0, 1382400, 0xd6850362
+0, 323263000, 323263000, 0, 1382400, 0x00000000
+0, 323356000, 323356000, 0, 1382400, 0x3e1ed109
+0, 324584000, 324584000, 0, 1382400, 0x00000000
+0, 324640000, 324640000, 0, 1382400, 0x39c1b7bd
+0, 326403000, 326403000, 0, 1382400, 0x00000000
+0, 327193000, 327193000, 0, 1382400, 0x35b85f2e
+0, 328285000, 328285000, 0, 1382400, 0x00000000
+0, 328360999, 328360999, 0, 1382400, 0x00000000
+0, 328361000, 328361000, 0, 1382400, 0x83f103e5
+0, 329885000, 329885000, 0, 1382400, 0x00000000
+0, 329946000, 329946000, 0, 1382400, 0xbc1ca9b3
+0, 331106000, 331106000, 0, 1382400, 0x00000000
+0, 331230000, 331230000, 0, 1382400, 0x94d4a51e
+0, 332857000, 332857000, 0, 1382400, 0x00000000
+0, 332924000, 332924000, 0, 1382400, 0xf88cdfde
+0, 334687000, 334687000, 0, 1382400, 0x00000000
+0, 342600000, 342600000, 0, 1382400, 0xdd51423b
+0, 344431000, 344431000, 0, 1382400, 0x00000000
+0, 346771000, 346771000, 0, 1382400, 0x08259fa4
+0, 348329000, 348329000, 0, 1382400, 0x00000000
+0, 357640000, 357640000, 0, 1382400, 0x1663fa34
+0, 359767000, 359767000, 0, 1382400, 0x00000000
+0, 359834000, 359834000, 0, 1382400, 0xda2ceb55
+0, 361096000, 361096000, 0, 1382400, 0x00000000
diff --git a/tests/ref/fate/sub2video_time_limited b/tests/ref/fate/sub2video_time_limited
index c7d48d639f..07d50fc697 100644
--- a/tests/ref/fate/sub2video_time_limited
+++ b/tests/ref/fate/sub2video_time_limited
@@ -1,8 +1,8 @@
-#tb 0: 1/90000
+#tb 0: 1/1000000
#media_type 0: video
#codec_id 0: rawvideo
#dimensions 0: 1920x1080
#sar 0: 0/1
-0, 6072, 6072, 0, 8294400, 0x00000000
-0, 6072, 6072, 0, 8294400, 0xa87c518f
-0, 36101, 36101, 0, 8294400, 0xa87c518f
+0, 67467, 67467, 0, 8294400, 0x00000000
+0, 67467, 67467, 0, 8294400, 0xa87c518f
+0, 401132, 401132, 0, 8294400, 0xa87c518f
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (5 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs Anton Khirnov
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
Outside of ifilter_bind_ist(), there are no longer any assumptions about
about filter inputs being fed by an InputStream.
---
fftools/ffmpeg_filter.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index a13b2ccf95..dcd08dbc36 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -109,8 +109,6 @@ typedef struct InputFilterPriv {
AVFilterContext *filter;
- InputStream *ist;
-
// used to hold submitted input
AVFrame *frame;
@@ -124,6 +122,7 @@ typedef struct InputFilterPriv {
// same as type otherwise
enum AVMediaType type_src;
+ int bound;
int eof;
// parameters configured for this input
@@ -665,7 +664,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
FilterGraphPriv *fgp = fgp_from_fg(ifilter->graph);
int ret, dec_idx;
- av_assert0(!ifp->ist);
+ av_assert0(!ifp->bound);
+ ifp->bound = 1;
if (ifp->type != ist->par->codec_type &&
!(ifp->type == AVMEDIA_TYPE_VIDEO && ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
@@ -674,7 +674,6 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
return AVERROR(EINVAL);
}
- ifp->ist = ist;
ifp->type_src = ist->st->codecpar->codec_type;
dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph),
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (6 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs Anton Khirnov
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg.c | 120 -------------------------------------------
fftools/ffmpeg.h | 3 --
fftools/ffmpeg_dec.c | 120 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 123 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 035210a8e9..3ee7b26d26 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -640,126 +640,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
first_report = 0;
}
-int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
-{
- int ret = AVERROR_BUG;
- AVSubtitle tmp = {
- .format = src->format,
- .start_display_time = src->start_display_time,
- .end_display_time = src->end_display_time,
- .num_rects = 0,
- .rects = NULL,
- .pts = src->pts
- };
-
- if (!src->num_rects)
- goto success;
-
- if (!(tmp.rects = av_calloc(src->num_rects, sizeof(*tmp.rects))))
- return AVERROR(ENOMEM);
-
- for (int i = 0; i < src->num_rects; i++) {
- AVSubtitleRect *src_rect = src->rects[i];
- AVSubtitleRect *dst_rect;
-
- if (!(dst_rect = tmp.rects[i] = av_mallocz(sizeof(*tmp.rects[0])))) {
- ret = AVERROR(ENOMEM);
- goto cleanup;
- }
-
- tmp.num_rects++;
-
- dst_rect->type = src_rect->type;
- dst_rect->flags = src_rect->flags;
-
- dst_rect->x = src_rect->x;
- dst_rect->y = src_rect->y;
- dst_rect->w = src_rect->w;
- dst_rect->h = src_rect->h;
- dst_rect->nb_colors = src_rect->nb_colors;
-
- if (src_rect->text)
- if (!(dst_rect->text = av_strdup(src_rect->text))) {
- ret = AVERROR(ENOMEM);
- goto cleanup;
- }
-
- if (src_rect->ass)
- if (!(dst_rect->ass = av_strdup(src_rect->ass))) {
- ret = AVERROR(ENOMEM);
- goto cleanup;
- }
-
- for (int j = 0; j < 4; j++) {
- // SUBTITLE_BITMAP images are special in the sense that they
- // are like PAL8 images. first pointer to data, second to
- // palette. This makes the size calculation match this.
- size_t buf_size = src_rect->type == SUBTITLE_BITMAP && j == 1 ?
- AVPALETTE_SIZE :
- src_rect->h * src_rect->linesize[j];
-
- if (!src_rect->data[j])
- continue;
-
- if (!(dst_rect->data[j] = av_memdup(src_rect->data[j], buf_size))) {
- ret = AVERROR(ENOMEM);
- goto cleanup;
- }
- dst_rect->linesize[j] = src_rect->linesize[j];
- }
- }
-
-success:
- *dst = tmp;
-
- return 0;
-
-cleanup:
- avsubtitle_free(&tmp);
-
- return ret;
-}
-
-static void subtitle_free(void *opaque, uint8_t *data)
-{
- AVSubtitle *sub = (AVSubtitle*)data;
- avsubtitle_free(sub);
- av_free(sub);
-}
-
-int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
-{
- AVBufferRef *buf;
- AVSubtitle *sub;
- int ret;
-
- if (copy) {
- sub = av_mallocz(sizeof(*sub));
- ret = sub ? copy_av_subtitle(sub, subtitle) : AVERROR(ENOMEM);
- if (ret < 0) {
- av_freep(&sub);
- return ret;
- }
- } else {
- sub = av_memdup(subtitle, sizeof(*subtitle));
- if (!sub)
- return AVERROR(ENOMEM);
- memset(subtitle, 0, sizeof(*subtitle));
- }
-
- buf = av_buffer_create((uint8_t*)sub, sizeof(*sub),
- subtitle_free, NULL, 0);
- if (!buf) {
- avsubtitle_free(sub);
- av_freep(&sub);
- return AVERROR(ENOMEM);
- }
-
- frame->buf[0] = buf;
-
- return 0;
-}
-
static void print_stream_maps(void)
{
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1fdc835723..295f470a62 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -709,9 +709,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
Scheduler *sch, unsigned sch_idx_enc);
int init_complex_filtergraph(FilterGraph *fg);
-int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src);
-int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy);
-
/**
* Get our axiliary frame data attached to the frame, allocating it
* if needed.
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index bf41a44f1f..1cfa15b943 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -371,6 +371,126 @@ static int video_frame_process(DecoderPriv *dp, AVFrame *frame)
return 0;
}
+static int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
+{
+ int ret = AVERROR_BUG;
+ AVSubtitle tmp = {
+ .format = src->format,
+ .start_display_time = src->start_display_time,
+ .end_display_time = src->end_display_time,
+ .num_rects = 0,
+ .rects = NULL,
+ .pts = src->pts
+ };
+
+ if (!src->num_rects)
+ goto success;
+
+ if (!(tmp.rects = av_calloc(src->num_rects, sizeof(*tmp.rects))))
+ return AVERROR(ENOMEM);
+
+ for (int i = 0; i < src->num_rects; i++) {
+ AVSubtitleRect *src_rect = src->rects[i];
+ AVSubtitleRect *dst_rect;
+
+ if (!(dst_rect = tmp.rects[i] = av_mallocz(sizeof(*tmp.rects[0])))) {
+ ret = AVERROR(ENOMEM);
+ goto cleanup;
+ }
+
+ tmp.num_rects++;
+
+ dst_rect->type = src_rect->type;
+ dst_rect->flags = src_rect->flags;
+
+ dst_rect->x = src_rect->x;
+ dst_rect->y = src_rect->y;
+ dst_rect->w = src_rect->w;
+ dst_rect->h = src_rect->h;
+ dst_rect->nb_colors = src_rect->nb_colors;
+
+ if (src_rect->text)
+ if (!(dst_rect->text = av_strdup(src_rect->text))) {
+ ret = AVERROR(ENOMEM);
+ goto cleanup;
+ }
+
+ if (src_rect->ass)
+ if (!(dst_rect->ass = av_strdup(src_rect->ass))) {
+ ret = AVERROR(ENOMEM);
+ goto cleanup;
+ }
+
+ for (int j = 0; j < 4; j++) {
+ // SUBTITLE_BITMAP images are special in the sense that they
+ // are like PAL8 images. first pointer to data, second to
+ // palette. This makes the size calculation match this.
+ size_t buf_size = src_rect->type == SUBTITLE_BITMAP && j == 1 ?
+ AVPALETTE_SIZE :
+ src_rect->h * src_rect->linesize[j];
+
+ if (!src_rect->data[j])
+ continue;
+
+ if (!(dst_rect->data[j] = av_memdup(src_rect->data[j], buf_size))) {
+ ret = AVERROR(ENOMEM);
+ goto cleanup;
+ }
+ dst_rect->linesize[j] = src_rect->linesize[j];
+ }
+ }
+
+success:
+ *dst = tmp;
+
+ return 0;
+
+cleanup:
+ avsubtitle_free(&tmp);
+
+ return ret;
+}
+
+static void subtitle_free(void *opaque, uint8_t *data)
+{
+ AVSubtitle *sub = (AVSubtitle*)data;
+ avsubtitle_free(sub);
+ av_free(sub);
+}
+
+static int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
+{
+ AVBufferRef *buf;
+ AVSubtitle *sub;
+ int ret;
+
+ if (copy) {
+ sub = av_mallocz(sizeof(*sub));
+ ret = sub ? copy_av_subtitle(sub, subtitle) : AVERROR(ENOMEM);
+ if (ret < 0) {
+ av_freep(&sub);
+ return ret;
+ }
+ } else {
+ sub = av_memdup(subtitle, sizeof(*subtitle));
+ if (!sub)
+ return AVERROR(ENOMEM);
+ memset(subtitle, 0, sizeof(*subtitle));
+ }
+
+ buf = av_buffer_create((uint8_t*)sub, sizeof(*sub),
+ subtitle_free, NULL, 0);
+ if (!buf) {
+ avsubtitle_free(sub);
+ av_freep(&sub);
+ return AVERROR(ENOMEM);
+ }
+
+ frame->buf[0] = buf;
+
+ return 0;
+}
+
static int process_subtitle(DecoderPriv *dp, AVFrame *frame)
{
const AVSubtitle *subtitle = (AVSubtitle*)frame->buf[0]->data;
--
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] 11+ messages in thread
* [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
` (7 preceding siblings ...)
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user Anton Khirnov
@ 2024-02-14 18:24 ` Anton Khirnov
8 siblings, 0 replies; 11+ messages in thread
From: Anton Khirnov @ 2024-02-14 18:24 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg_dec.c | 38 ++++++-------
fftools/ffmpeg_demux.c | 68 +++++++++++------------
fftools/ffmpeg_filter.c | 120 ++++++++++++++++++++--------------------
fftools/ffmpeg_mux.h | 66 +++++++++++-----------
4 files changed, 146 insertions(+), 146 deletions(-)
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 1cfa15b943..769ae36296 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -35,20 +35,20 @@
#include "thread_queue.h"
typedef struct DecoderPriv {
- Decoder dec;
+ Decoder dec;
- AVCodecContext *dec_ctx;
+ AVCodecContext *dec_ctx;
- AVFrame *frame;
- AVPacket *pkt;
+ AVFrame *frame;
+ AVPacket *pkt;
// override output video sample aspect ratio with this value
- AVRational sar_override;
+ AVRational sar_override;
- AVRational framerate_in;
+ AVRational framerate_in;
// a combination of DECODER_FLAG_*, provided to dec_open()
- int flags;
+ int flags;
enum AVPixelFormat hwaccel_pix_fmt;
enum HWAccelID hwaccel_id;
@@ -58,22 +58,22 @@ typedef struct DecoderPriv {
// pts/estimated duration of the last decoded frame
// * in decoder timebase for video,
// * in last_frame_tb (may change during decoding) for audio
- int64_t last_frame_pts;
- int64_t last_frame_duration_est;
- AVRational last_frame_tb;
- int64_t last_filter_in_rescale_delta;
- int last_frame_sample_rate;
+ int64_t last_frame_pts;
+ int64_t last_frame_duration_est;
+ AVRational last_frame_tb;
+ int64_t last_filter_in_rescale_delta;
+ int last_frame_sample_rate;
/* previous decoded subtitles */
- AVFrame *sub_prev[2];
- AVFrame *sub_heartbeat;
+ AVFrame *sub_prev[2];
+ AVFrame *sub_heartbeat;
- Scheduler *sch;
- unsigned sch_idx;
+ Scheduler *sch;
+ unsigned sch_idx;
- void *log_parent;
- char log_name[32];
- char *parent_name;
+ void *log_parent;
+ char log_name[32];
+ char *parent_name;
} DecoderPriv;
static DecoderPriv *dp_from_dec(Decoder *d)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index e543c4215c..d5a3dbc1d2 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -40,41 +40,41 @@
#include "libavformat/avformat.h"
typedef struct DemuxStream {
- InputStream ist;
+ InputStream ist;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int sch_idx_stream;
- int sch_idx_dec;
+ int sch_idx_stream;
+ int sch_idx_dec;
- double ts_scale;
+ double ts_scale;
/* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
- int decoding_needed;
+ int decoding_needed;
#define DECODING_FOR_OST 1
#define DECODING_FOR_FILTER 2
/* true if stream data should be discarded */
- int discard;
+ int discard;
// scheduler returned EOF for this stream
- int finished;
+ int finished;
- int streamcopy_needed;
- int have_sub2video;
- int reinit_filters;
+ int streamcopy_needed;
+ int have_sub2video;
+ int reinit_filters;
- int wrap_correction_done;
- int saw_first_ts;
+ int wrap_correction_done;
+ int saw_first_ts;
///< dts of the first packet read for this stream (in AV_TIME_BASE units)
- int64_t first_dts;
+ int64_t first_dts;
/* predicted dts of the next packet read for this stream or (when there are
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
- int64_t next_dts;
+ int64_t next_dts;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
- int64_t dts;
+ int64_t dts;
const AVCodecDescriptor *codec_desc;
@@ -82,45 +82,45 @@ typedef struct DemuxStream {
DecoderOpts dec_opts;
char dec_name[16];
- AVBSFContext *bsf;
+ AVBSFContext *bsf;
/* number of packets successfully read for this stream */
- uint64_t nb_packets;
+ uint64_t nb_packets;
// combined size of all the packets read
- uint64_t data_size;
+ uint64_t data_size;
} DemuxStream;
typedef struct Demuxer {
- InputFile f;
+ InputFile f;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int64_t wallclock_start;
+ int64_t wallclock_start;
/**
* Extra timestamp offset added by discontinuity handling.
*/
- int64_t ts_offset_discont;
- int64_t last_ts;
+ int64_t ts_offset_discont;
+ int64_t last_ts;
- int64_t recording_time;
- int accurate_seek;
+ int64_t recording_time;
+ int accurate_seek;
/* number of times input stream should be looped */
- int loop;
- int have_audio_dec;
+ int loop;
+ int have_audio_dec;
/* duration of the looped segment of the input file */
- Timestamp duration;
+ Timestamp duration;
/* pts with the smallest/largest values ever seen */
- Timestamp min_pts;
- Timestamp max_pts;
+ Timestamp min_pts;
+ Timestamp max_pts;
/* number of streams that the user was warned of */
- int nb_streams_warn;
+ int nb_streams_warn;
- float readrate;
- double readrate_initial_burst;
+ float readrate;
+ double readrate_initial_burst;
Scheduler *sch;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index dcd08dbc36..27fafc6704 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -43,27 +43,27 @@
#include "libavcodec/mathops.h"
typedef struct FilterGraphPriv {
- FilterGraph fg;
+ FilterGraph fg;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int is_simple;
+ int is_simple;
// true when the filtergraph contains only meta filters
// that do not modify the frame data
- int is_meta;
+ int is_meta;
// source filters are present in the graph
- int have_sources;
- int disable_conversions;
+ int have_sources;
+ int disable_conversions;
- unsigned nb_outputs_done;
+ unsigned nb_outputs_done;
- const char *graph_desc;
+ const char *graph_desc;
// frame for temporarily holding output from the filtergraph
- AVFrame *frame;
+ AVFrame *frame;
// frame for sending output to the encoder
- AVFrame *frame_enc;
+ AVFrame *frame_enc;
Scheduler *sch;
unsigned sch_idx;
@@ -81,69 +81,69 @@ static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg)
// data that is local to the filter thread and not visible outside of it
typedef struct FilterGraphThread {
- AVFilterGraph *graph;
+ AVFilterGraph *graph;
- AVFrame *frame;
+ AVFrame *frame;
// Temporary buffer for output frames, since on filtergraph reset
// we cannot send them to encoders immediately.
// The output index is stored in frame opaque.
- AVFifo *frame_queue_out;
+ AVFifo *frame_queue_out;
// index of the next input to request from the scheduler
- unsigned next_in;
+ unsigned next_in;
// set to 1 after at least one frame passed through this output
- int got_frame;
+ int got_frame;
// EOF status of each input/output, as received by the thread
- uint8_t *eof_in;
- uint8_t *eof_out;
+ uint8_t *eof_in;
+ uint8_t *eof_out;
} FilterGraphThread;
typedef struct InputFilterPriv {
- InputFilter ifilter;
+ InputFilter ifilter;
- InputFilterOptions opts;
+ InputFilterOptions opts;
- int index;
+ int index;
- AVFilterContext *filter;
+ AVFilterContext *filter;
// used to hold submitted input
- AVFrame *frame;
+ AVFrame *frame;
/* for filters that are not yet bound to an input stream,
* this stores the input linklabel, if any */
- uint8_t *linklabel;
+ uint8_t *linklabel;
// filter data type
- enum AVMediaType type;
+ enum AVMediaType type;
// source data type: AVMEDIA_TYPE_SUBTITLE for sub2video,
// same as type otherwise
- enum AVMediaType type_src;
+ enum AVMediaType type_src;
- int bound;
- int eof;
+ int bound;
+ int eof;
// parameters configured for this input
- int format;
+ int format;
- int width, height;
- AVRational sample_aspect_ratio;
- enum AVColorSpace color_space;
- enum AVColorRange color_range;
+ int width, height;
+ AVRational sample_aspect_ratio;
+ enum AVColorSpace color_space;
+ enum AVColorRange color_range;
- int sample_rate;
- AVChannelLayout ch_layout;
+ int sample_rate;
+ AVChannelLayout ch_layout;
- AVRational time_base;
+ AVRational time_base;
- AVFifo *frame_queue;
+ AVFifo *frame_queue;
- AVBufferRef *hw_frames_ctx;
+ AVBufferRef *hw_frames_ctx;
- int displaymatrix_present;
- int32_t displaymatrix[9];
+ int displaymatrix_present;
+ int32_t displaymatrix[9];
// fallback parameters to use when no input is ever sent
struct {
@@ -178,15 +178,15 @@ static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter)
}
typedef struct FPSConvContext {
- AVFrame *last_frame;
+ AVFrame *last_frame;
/* number of frames emitted by the video-encoding sync code */
- int64_t frame_number;
+ int64_t frame_number;
/* history of nb_frames_prev, i.e. the number of times the
* previous frame was duplicated by vsync code in recent
* do_video_out() calls */
- int64_t frames_prev_hist[3];
+ int64_t frames_prev_hist[3];
- uint64_t dup_warning;
+ uint64_t dup_warning;
int last_dropped;
int dropped_keyframe;
@@ -198,38 +198,38 @@ typedef struct FPSConvContext {
} FPSConvContext;
typedef struct OutputFilterPriv {
- OutputFilter ofilter;
+ OutputFilter ofilter;
- int index;
+ int index;
- AVFilterContext *filter;
+ AVFilterContext *filter;
/* desired output stream properties */
- int format;
- int width, height;
- int sample_rate;
- AVChannelLayout ch_layout;
+ int format;
+ int width, height;
+ int sample_rate;
+ AVChannelLayout ch_layout;
// time base in which the output is sent to our downstream
// does not need to match the filtersink's timebase
- AVRational tb_out;
+ AVRational tb_out;
// at least one frame with the above timebase was sent
// to our downstream, so it cannot change anymore
- int tb_out_locked;
+ int tb_out_locked;
- AVRational sample_aspect_ratio;
+ AVRational sample_aspect_ratio;
// those are only set if no format is specified and the encoder gives us multiple options
// They point directly to the relevant lists of the encoder.
- const int *formats;
- const AVChannelLayout *ch_layouts;
- const int *sample_rates;
+ const int *formats;
+ const AVChannelLayout *ch_layouts;
+ const int *sample_rates;
- AVRational enc_timebase;
+ AVRational enc_timebase;
// offset for output timestamps, in AV_TIME_BASE_Q
- int64_t ts_offset;
- int64_t next_pts;
- FPSConvContext fps;
+ int64_t ts_offset;
+ int64_t next_pts;
+ FPSConvContext fps;
} OutputFilterPriv;
static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter)
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index e1b44142cf..16af6d38ba 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -34,73 +34,73 @@
#include "libavutil/fifo.h"
typedef struct MuxStream {
- OutputStream ost;
+ OutputStream ost;
// name used for logging
- char log_name[32];
+ char log_name[32];
- AVBSFContext *bsf_ctx;
- AVPacket *bsf_pkt;
+ AVBSFContext *bsf_ctx;
+ AVPacket *bsf_pkt;
- AVPacket *pkt;
+ AVPacket *pkt;
- EncStats stats;
+ EncStats stats;
- int sch_idx;
- int sch_idx_enc;
- int sch_idx_src;
+ int sch_idx;
+ int sch_idx_enc;
+ int sch_idx_src;
- int sq_idx_mux;
+ int sq_idx_mux;
- int64_t max_frames;
+ int64_t max_frames;
// timestamp from which the streamcopied streams should start,
// in AV_TIME_BASE_Q;
// everything before it should be discarded
- int64_t ts_copy_start;
+ int64_t ts_copy_start;
/* dts of the last packet sent to the muxer, in the stream timebase
* used for making up missing dts values */
- int64_t last_mux_dts;
+ int64_t last_mux_dts;
- int64_t stream_duration;
- AVRational stream_duration_tb;
+ int64_t stream_duration;
+ AVRational stream_duration_tb;
// state for av_rescale_delta() call for audio in write_packet()
- int64_t ts_rescale_delta_last;
+ int64_t ts_rescale_delta_last;
// combined size of all the packets sent to the muxer
- uint64_t data_size_mux;
+ uint64_t data_size_mux;
- int copy_initial_nonkeyframes;
- int copy_prior_start;
- int streamcopy_started;
+ int copy_initial_nonkeyframes;
+ int copy_prior_start;
+ int streamcopy_started;
} MuxStream;
typedef struct Muxer {
- OutputFile of;
+ OutputFile of;
// name used for logging
- char log_name[32];
+ char log_name[32];
- AVFormatContext *fc;
+ AVFormatContext *fc;
- Scheduler *sch;
- unsigned sch_idx;
+ Scheduler *sch;
+ unsigned sch_idx;
// OutputStream indices indexed by scheduler stream indices
- int *sch_stream_idx;
- int nb_sch_stream_idx;
+ int *sch_stream_idx;
+ int nb_sch_stream_idx;
- AVDictionary *opts;
+ AVDictionary *opts;
/* filesize limit expressed in bytes */
- int64_t limit_filesize;
- atomic_int_least64_t last_filesize;
- int header_written;
+ int64_t limit_filesize;
+ atomic_int_least64_t last_filesize;
+ int header_written;
- SyncQueue *sq_mux;
- AVPacket *sq_pkt;
+ SyncQueue *sq_mux;
+ AVPacket *sq_pkt;
} Muxer;
int mux_check_init(void *arg);
--
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] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov
@ 2024-02-15 1:58 ` Michael Niedermayer
0 siblings, 0 replies; 11+ messages in thread
From: Michael Niedermayer @ 2024-02-15 1:58 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 3445 bytes --]
On Wed, Feb 14, 2024 at 07:24:32PM +0100, Anton Khirnov wrote:
> Treat it analogously to stream parameters like format/dimensions/etc.
> This is functionally different from previous code in 2 ways:
> * for non-CFR video, the frame timebase (set by the decoder) is used
> rather than the demuxer timebase
> * for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the
> subtitle decoding API
>
> These changes should avoid unnecessary and potentially lossy timestamp
> conversions from decoder timebase into the demuxer one.
>
> Changes the timebases used in sub2video tests.
> ---
> fftools/ffmpeg_filter.c | 17 ++-
> tests/ref/fate/sub2video_basic | 182 +++++++++++++-------------
> tests/ref/fate/sub2video_time_limited | 8 +-
> 3 files changed, 106 insertions(+), 101 deletions(-)
breaks:
./ffmpeg -i \[a-s\]_full_metal_panic_fumoffu_-_01_-_the_man_from_the_south_-_a_hostage_with_no_compromises__rs2_\[1080p_bd-rip\]\[BBB48A25\].mkv -filter_complex '[0:s:1]scale=800:600' -t 15 -qscale 2 -bitexact -y /tmp/file-pgstest2.avi
...
Press [q] to stop, [?] for help
[aac @ 0x55dcd4a5a940] This stream seems to incorrectly report its last channel as LFE[3], mapping to LFE[0]
[mpeg4 @ 0x55dcd4a5b780] timebase 1/1000000 not supported by MPEG 4 standard, the maximum admitted value for the timebase denominator is 65535
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[fc#0 @ 0x55dcd4a37a00] Error sending frames to consumers: Invalid argument
[fc#0 @ 0x55dcd4a37a00] Task finished with error code: -22 (Invalid argument)
[fc#0 @ 0x55dcd4a37a00] Terminating thread with return code -22 (Invalid argument)
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Could not open encoder before EOF
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Terminating thread with return code -22 (Invalid argument)
[libmp3lame @ 0x55dcd4a5ca80] Trying to remove 1152 samples, but the queue is empty
[out#0/avi @ 0x55dcd4a7f680] Nothing was written into output file, because at least one of its streams received no packets.
frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!
vs.
Press [q] to stop, [?] for help
[aac @ 0x55b416e87e00] This stream seems to incorrectly report its last channel as LFE[3], mapping to LFE[0]
Output #0, avi, to '/tmp/file-pgstest2.avi':
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(progressive), 800x600, q=2-31, 200 kb/s, 1k tbn
Metadata:
encoder : Lavc mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp (default)
Metadata:
title : AAC
encoder : Lavc libmp3lame
[libmp3lame @ 0x55b416e76640] Trying to remove 1152 samples, but the queue is empty
[out#0/avi @ 0x55b416e7fec0] video:496KiB audio:235KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 51.412292%
frame= 360 fps=0.0 q=2.0 Lsize= 1108KiB time=00:00:14.97 bitrate= 605.9kbits/s dup=0 drop=16 speed=44.9x
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Never trust a computer, one day, it may think you are the virus. -- Compn
[-- 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] 11+ messages in thread
end of thread, other threads:[~2024-02-15 1:58 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags " Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate " Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov
2024-02-15 1:58 ` Michael Niedermayer
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user Anton Khirnov
2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs Anton Khirnov
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git