Revision 20c68378 libavutil/common.h

View differences:

libavutil/common.h
266 266
    }
267 267

  
268 268
/*!
269
 * \def GET_UTF16(val, GET_16BIT, ERROR)
270
 * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
271
 * \param val is the output and should be of type uint32_t. It holds the converted
272
 * UCS-4 character and should be a left value.
273
 * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness.
274
 * It can be a function or a statement whose return value or evaluated value is of type
275
 * uint16_t. It will be executed up to 2 times.
276
 * \param ERROR action that should be taken when an invalid UTF-16 surrogate is
277
 * returned from GET_BYTE. It should be a statement that jumps out of the macro,
278
 * like exit(), goto, return, break, or continue.
279
 */
280
#define GET_UTF16(val, GET_16BIT, ERROR)\
281
    val = GET_16BIT;\
282
    {\
283
        unsigned int hi = val - 0xD800;\
284
        if (hi < 0x800) {\
285
            val = GET_16BIT - 0xDC00;\
286
            if (val > 0x3FFU || hi > 0x3FFU)\
287
                ERROR\
288
            val += (hi<<10) + 0x10000;\
289
        }\
290
    }\
291

  
292
/*!
269 293
 * \def PUT_UTF8(val, tmp, PUT_BYTE)
270 294
 * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
271 295
 * \param val is an input-only argument and should be of type uint32_t. It holds

Also available in: Unified diff