[FFmpeg-devel] [PATCH 3/3] lavc: check decoded subtitles encoding.
Nicolas George
nicolas.george at normalesup.org
Wed Apr 10 17:44:47 CEST 2013
L'octidi 18 germinal, an CCXXI, Reimar Döffinger a écrit :
> IMHO not for a public API, and preferably not for something that has
> "valid" in its name.
> If it's up to discussion I'd have preferred a more vague name like
> guess_utf8 or such.
Ok.
> Possibly reasonable to add to GET_UTF8 as well - though might be worth
> discussion, also for performance reasons.
> Otherwise I believe this would do it:
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -279,6 +279,7 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
> #define GET_UTF8(val, GET_BYTE, ERROR)\
> val= GET_BYTE;\
> {\
> + uint32_t min = 0;\
> uint32_t top = (val & 128) >> 1;\
> if ((val & 0xc0) == 0x80)\
> ERROR\
> @@ -287,9 +288,12 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
> if(tmp>>6)\
> ERROR\
> val= (val<<6) + tmp;\
> + min = top << 1;\
> top <<= 5;\
> }\
> val &= (top << 1) - 1;\
> + if (val < min)\
> + ERROR\
> }
This seems to cost about 3% performance (281 instead of 271 decicycles for
~33E6 runs). The "val >= 0xFE" test seems to be negligible, OTOH.
I will submit a new pair of patches, keeping the overlong check outside.
Thanks for your help.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130410/d03146cb/attachment.asc>
More information about the ffmpeg-devel
mailing list