[Ffmpeg-devel] [PATCH] move utf8 writing to libavutil

Måns Rullgård mru
Sat Jul 8 19:51:12 CEST 2006


Justin Ruggles <jruggle at earthlink.net> writes:

> Hello,
>
> This patch moves UTF-8 writing to libavutil.  It is an extension of
> Michael's commit yesterday which did the same to UTF-8 reading.
>
> -Justin
>
> Index: libavutil/common.h
> ===================================================================
> --- libavutil/common.h	(revision 5675)
> +++ libavutil/common.h	(working copy)
> @@ -518,6 +518,22 @@
>          }\
>      }
>
> +#define PUT_UTF8(val, PUT_BYTE, OUTBYTE)\
> +    if(val < 0x80){\
> +        OUTBYTE = val;\
> +        PUT_BYTE\
> +    } else {\
> +        int bytes = (av_log2(val)+4) / 5;\
> +        int shift = (bytes - 1) * 6;\
> +        OUTBYTE = (256 - (256>>bytes)) | (val >> shift);\
> +        PUT_BYTE\
> +        while(shift >= 6){\
> +            shift -= 6;\
> +            OUTBYTE = 0x80 | ((val >> shift) & 0x3F);\
> +            PUT_BYTE\
> +        }\
> +    }\
> +

The \ on the last line should go away.  The whole macro should be
enclosed in do { } while(0).

-- 
M?ns Rullg?rd
mru at inprovide.com




More information about the ffmpeg-devel mailing list