diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-02-13 12:18:27 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-02-21 10:27:20 +0100 |
commit | 6315f78e0c0d847532f221cc696956888410d094 (patch) | |
tree | 1b446468bd81fd85eaa13deaf0c21391ed257837 /fftools/ffmpeg_demux.c | |
parent | bd3c1c194bd2252ada4cfd025b14ae091a30b3b5 (diff) | |
download | ffmpeg-6315f78e0c0d847532f221cc696956888410d094.tar.gz |
fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions
Rather than read them directly from InputStream.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
Diffstat (limited to 'fftools/ffmpeg_demux.c')
-rw-r--r-- | fftools/ffmpeg_demux.c | 41 |
1 files changed, 20 insertions, 21 deletions
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: |