aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-23 13:00:12 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-31 16:19:49 +0200
commit5d530e3a7286df72026f77f7b02f4cf7f083f57c (patch)
treebafbbc0ff5dc5b3c483d2ace1c975832a06327b9 /fftools/ffmpeg_filter.c
parent3d35b73b2a40b9e99724401d6390750e2bc65318 (diff)
downloadffmpeg-5d530e3a7286df72026f77f7b02f4cf7f083f57c.tar.gz
fftools/ffmpeg_dec: move sub2video submission to ffmpeg_filter
This code is a sub2video analogue of ifilter_send_frame(), so it properly belongs to the filtering code. Note that using sub2video with more than one target for a given input subtitle stream is currently broken and this commit does not change that. It will be addressed in following commits.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3bf1862ab6..acfd83244b 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1638,6 +1638,36 @@ int reap_filters(int flush)
return 0;
}
+int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *subtitle)
+{
+ InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
+ InputStream *ist = ifp->ist;
+ int ret;
+
+ if (ist->sub2video.frame) {
+ sub2video_update(ist, INT64_MIN, subtitle);
+ } else {
+ AVSubtitle sub;
+
+ if (!ist->sub2video.sub_queue)
+ ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW);
+ if (!ist->sub2video.sub_queue)
+ return AVERROR(ENOMEM);
+
+ ret = copy_av_subtitle(&sub, subtitle);
+ if (ret < 0)
+ return ret;
+
+ ret = av_fifo_write(ist->sub2video.sub_queue, &sub, 1);
+ if (ret < 0) {
+ avsubtitle_free(&sub);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
{
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);