[FFmpeg-devel] [PATCH 2/2] avformat/demux: don't discard empty Theora packets

James Almer jamrial at gmail.com
Fri Feb 14 00:47:46 EET 2025


Theora signals "Output last frame again" with an empty packet.

Finishes fixing ticket #11451.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/demux.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index d8ab29431e..407e448252 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1172,8 +1172,14 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
     int ret = 0, got_output = flush;
 
     if (!size && !flush && sti->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
-        // preserve 0-size sync packets
-        compute_pkt_fields(s, st, sti->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
+        if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
+            compute_pkt_fields(s, st, sti->parser, pkt, pkt->dts, pkt->pts);
+            ret = avpriv_packet_list_put(&fci->parse_queue,
+                                         pkt, NULL, 0);
+            if (ret < 0)
+                goto fail;
+        } else // preserve 0-size sync packets
+            compute_pkt_fields(s, st, sti->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
     }
 
     while (size > 0 || (flush && got_output)) {
-- 
2.48.1



More information about the ffmpeg-devel mailing list