summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <[email protected]>2023-06-02 15:12:58 +0200
committerAnton Khirnov <[email protected]>2023-06-19 09:48:55 +0200
commit7d4e00ccf0b77dab1bf74320b26af968ba670394 (patch)
tree90c63643850c3e7882272bc5a30101909950497f
parent1bdd53e2f95522eefddc34217c74afe8aa8d9a03 (diff)
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.
-rw-r--r--fftools/ffmpeg_dec.c18
1 files 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