diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-23 13:07:57 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-31 16:20:19 +0200 |
commit | a6d67b11f5b83b72d1df37a88c864dc854374488 (patch) | |
tree | 40ca1e66e00fe3b55571624442794054e3708405 /fftools/ffmpeg_filter.c | |
parent | 5d530e3a7286df72026f77f7b02f4cf7f083f57c (diff) | |
download | ffmpeg-a6d67b11f5b83b72d1df37a88c864dc854374488.tar.gz |
fftools/ffmpeg_filter: move sub2video subtitle queue to InputFilterPriv
This queue should be associated with a specific filtergraph input - if
a subtitle stream is sent to multiple filters then each should have its
own queue.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index acfd83244b..2a73e3a3e3 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -104,6 +104,10 @@ typedef struct InputFilterPriv { AVChannelLayout ch_layout; } fallback; + struct { + ///< queue of AVSubtitle* before filter init + AVFifo *queue; + } sub2video; } InputFilterPriv; static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) @@ -593,7 +597,6 @@ void fg_free(FilterGraph **pfg) for (int j = 0; j < fg->nb_inputs; j++) { InputFilter *ifilter = fg->inputs[j]; InputFilterPriv *ifp = ifp_from_ifilter(ifilter); - InputStream *ist = ifp->ist; if (ifp->frame_queue) { AVFrame *frame; @@ -601,11 +604,11 @@ void fg_free(FilterGraph **pfg) av_frame_free(&frame); av_fifo_freep2(&ifp->frame_queue); } - if (ist && ist->sub2video.sub_queue) { + if (ifp->sub2video.queue) { AVSubtitle sub; - while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) + while (av_fifo_read(ifp->sub2video.queue, &sub, 1) >= 0) avsubtitle_free(&sub); - av_fifo_freep2(&ist->sub2video.sub_queue); + av_fifo_freep2(&ifp->sub2video.queue); } av_channel_layout_uninit(&ifp->fallback.ch_layout); @@ -1495,10 +1498,11 @@ int configure_filtergraph(FilterGraph *fg) /* process queued up subtitle packets */ for (i = 0; i < fg->nb_inputs; i++) { - InputStream *ist = ifp_from_ifilter(fg->inputs[i])->ist; - if (ist->sub2video.sub_queue && ist->sub2video.frame) { + InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]); + InputStream *ist = ifp->ist; + if (ifp->sub2video.queue && ist->sub2video.frame) { AVSubtitle tmp; - while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) { + while (av_fifo_read(ifp->sub2video.queue, &tmp, 1) >= 0) { sub2video_update(ist, INT64_MIN, &tmp); avsubtitle_free(&tmp); } @@ -1649,16 +1653,16 @@ int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *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) + if (!ifp->sub2video.queue) + ifp->sub2video.queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW); + if (!ifp->sub2video.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); + ret = av_fifo_write(ifp->sub2video.queue, &sub, 1); if (ret < 0) { avsubtitle_free(&sub); return ret; |