[FFmpeg-cvslog] fftools/ffmpeg_dec: stop using Decoder.pkt
Anton Khirnov
git at videolan.org
Mon Jun 19 12:11:21 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jun 2 15:12:58 2023 +0200| [7d4e00ccf0b77dab1bf74320b26af968ba670394] | committer: Anton Khirnov
fftools/ffmpeg_dec: stop using Decoder.pkt
It is only used for flushing the subtitle decoder, so allocate a
dedicated packet for that.
Keep Decoder.pkt unused for now, it will be repurposed in future
commits.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7d4e00ccf0b77dab1bf74320b26af968ba670394
---
fftools/ffmpeg_dec.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 586be83dc1..f9053c424b 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -385,10 +385,20 @@ out:
static int transcode_subtitles(InputStream *ist, const AVPacket *pkt)
{
+ AVPacket *flush_pkt = NULL;
AVSubtitle subtitle;
int got_output;
- int ret = avcodec_decode_subtitle2(ist->dec_ctx,
- &subtitle, &got_output, pkt);
+ int ret;
+
+ if (!pkt) {
+ flush_pkt = av_packet_alloc();
+ if (!flush_pkt)
+ return AVERROR(ENOMEM);
+ }
+
+ ret = avcodec_decode_subtitle2(ist->dec_ctx, &subtitle, &got_output,
+ pkt ? pkt : flush_pkt);
+ av_packet_free(&flush_pkt);
if (ret < 0) {
av_log(ist, AV_LOG_ERROR, "Error decoding subtitles: %s\n",
@@ -399,7 +409,7 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt)
}
if (ret < 0 || !got_output) {
- if (!pkt->size)
+ if (!pkt)
sub2video_flush(ist);
return ret < 0 ? ret : AVERROR_EOF;
}
@@ -432,7 +442,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
int ret;
if (dec->codec_type == AVMEDIA_TYPE_SUBTITLE)
- return transcode_subtitles(ist, pkt ? pkt : d->pkt);
+ return transcode_subtitles(ist, pkt);
// With fate-indeo3-2, we're getting 0-sized packets before EOF for some
// reason. This seems like a semi-critical bug. Don't trigger EOF, and
More information about the ffmpeg-cvslog
mailing list