PR #25836 opened by romainhedouin
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25836
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25836.patch

If one object in a DVB subtitle couldn't be used, the decoder gave up on the 
whole subtitle and parts of it were therefore lost.
An object can be unusable if no region lists it, or if it uses a coding method 
ffmpeg doesn't support.

With this PR, the decoder skips that object and decodes the rest. Broken 
segments (too short, or with bad lengths) are still errors.
This is also closer to the DVB standard (EN 300 743, 7.2.0.1 and 7.2.0.2), 
which specifically mentions that a decoder must ignore what it doesn't support 
and still decode the rest.

Testing: DVB subtitle tests, 100k fuzzed streams with Asan and UBSan, the four 
FATE tests

Found during a code review sweep of ffmpeg using an LLM.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 67f31bc5046fb9fadae4e4a4bcfee062787ebda8 Mon Sep 17 00:00:00 2001
From: romainhedouin <[email protected]>
Date: Sat, 7 Nov 2026 13:14:51 +0100
Subject: [PATCH] avcodec/dvbsubdec: skip objects that cannot be decoded

An object segment for an object that belongs to no region, or that uses
the text, progressive or reserved coding method, made dvbsub_decode()
stop parsing the packet. The display set was lost, or with compute_edt=1
(set by the ffmpeg CLI) output without everything after the bad segment.

Skip such a segment and keep decoding. Data for an unlisted object is
legitimate, for example an ancillary page object used by another
service, and EN 300 743 7.2.0.1 and 7.2.0.2 ask decoders to ignore what
they do not support. This partly reverts a469d29c08 and restores the
silent skip that Libav 607ad990d3 removed. Segments that are too short
or have bad field lengths are still errors.

Found during a code review sweep of ffmpeg using an LLM.

Signed-off-by: romainhedouin <[email protected]>
---
 libavcodec/dvbsubdec.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 2426da896d1..78ec92ba19c 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1007,8 +1007,10 @@ static int dvbsub_parse_object_segment(AVCodecContext 
*avctx,
 
     object = get_object(ctx, object_id);
 
-    if (!object)
-        return AVERROR_INVALIDDATA;
+    if (!object) {
+        av_log(avctx, AV_LOG_DEBUG, "Object %d is not in any region, skipping 
it\n", object_id);
+        return 0;
+    }
 
     coding_method = ((*buf) >> 2) & 3;
     non_modifying_color = ((*buf++) >> 1) & 1;
@@ -1043,13 +1045,10 @@ static int dvbsub_parse_object_segment(AVCodecContext 
*avctx,
         }
     } else if (coding_method == 1) {
         avpriv_report_missing_feature(avctx, "coded as a string of 
characters");
-        return AVERROR_PATCHWELCOME;
     } else if (coding_method == 2) {
         avpriv_report_missing_feature(avctx, "progressive coding of pixels");
-        return AVERROR_PATCHWELCOME;
     } else {
         av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", 
coding_method);
-        return AVERROR_INVALIDDATA;
     }
 
     return 0;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to