[FFmpeg-devel] [PATCH 3/4] libavcodec: return specific error code on subtitles with invalid UTF-8

wm4 nfxjfg at googlemail.com
Thu Aug 8 01:04:38 CEST 2013


It's impossible for an application to distinguish between actual
decoding errors, and libavcodec rejecting perfectly subtitles that are
not encoded in UTF-8.

It could be argued that an application should test the input for valid
UTF-8 before passing it to libavcodec, but the input could be binary
(e.g. movtext), and libavcodec checks the text _after_ decoding it.

It would be much more useful if libavcodec just returned the (broken)
subtitle anyway, but such a patch was rejected earlier. The error code
is named in honour of Nicolas George, who insisted on this behavior.
---
 libavcodec/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index fd08bec..5069b11 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2337,7 +2337,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
                            "Invalid UTF-8 in decoded subtitles text; "
                            "maybe missing -sub_charenc option\n");
                     avsubtitle_free(sub);
-                    return AVERROR_INVALIDDATA;
+                    return FFERRTAG('N', 'I', 'C', 'O');
                 }
             }
 
-- 
1.8.4.rc1



More information about the ffmpeg-devel mailing list