libavutil/common.h File Reference

#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "attributes.h"
#include "config.h"
#include "intmath.h"
#include "mem.h"
#include "internal.h"
#include "intmath.h"

Go to the source code of this file.

Defines

#define RSHIFT(a, b)   ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
#define ROUNDED_DIV(a, b)   (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
#define FFABS(a)   ((a) >= 0 ? (a) : (-(a)))
#define FFSIGN(a)   ((a) > 0 ? 1 : -1)
#define FFMAX(a, b)   ((a) > (b) ? (a) : (b))
#define FFMAX3(a, b, c)   FFMAX(FFMAX(a,b),c)
#define FFMIN(a, b)   ((a) > (b) ? (b) : (a))
#define FFMIN3(a, b, c)   FFMIN(FFMIN(a,b),c)
#define FFSWAP(type, a, b)   do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
#define FF_ARRAY_ELEMS(a)   (sizeof(a) / sizeof((a)[0]))
#define FFALIGN(x, a)   (((x)+(a)-1)&~((a)-1))
#define MKTAG(a, b, c, d)   (a | (b << 8) | (c << 16) | (d << 24))
#define MKBETAG(a, b, c, d)   (d | (c << 8) | (b << 16) | (a << 24))
#define GET_UTF8(val, GET_BYTE, ERROR)
#define GET_UTF16(val, GET_16BIT, ERROR)
#define PUT_UTF8(val, tmp, PUT_BYTE)
#define PUT_UTF16(val, tmp, PUT_16BIT)

Functions

static av_const int av_log2_c (unsigned int v)
static av_const int av_log2_16bit_c (unsigned int v)
static av_const int av_clip (int a, int amin, int amax)
 Clips a signed integer value into the amin-amax range.
static av_const uint8_t av_clip_uint8 (int a)
 Clips a signed integer value into the 0-255 range.
static av_const uint16_t av_clip_uint16 (int a)
 Clips a signed integer value into the 0-65535 range.
static av_const int16_t av_clip_int16 (int a)
 Clips a signed integer value into the -32768,32767 range.
static av_const float av_clipf (float a, float amin, float amax)
 Clips a float value into the amin-amax range.
static av_const int av_ceil_log2 (int x)
 Computes ceil(log2(x)).

Variables

const uint8_t ff_log2_tab [256]
const uint8_t av_reverse [256]


Define Documentation

#define FF_ARRAY_ELEMS (  )     (sizeof(a) / sizeof((a)[0]))

Definition at line 52 of file common.h.

#define FFABS (  )     ((a) >= 0 ? (a) : (-(a)))

Definition at line 43 of file common.h.

#define FFALIGN ( x,
 )     (((x)+(a)-1)&~((a)-1))

Definition at line 53 of file common.h.

#define FFMAX ( a,
 )     ((a) > (b) ? (a) : (b))

Definition at line 46 of file common.h.

#define FFMAX3 ( a,
b,
 )     FFMAX(FFMAX(a,b),c)

Definition at line 47 of file common.h.

#define FFMIN ( a,
 )     ((a) > (b) ? (b) : (a))

Definition at line 48 of file common.h.

#define FFMIN3 ( a,
b,
 )     FFMIN(FFMIN(a,b),c)

Definition at line 49 of file common.h.

#define FFSIGN (  )     ((a) > 0 ? 1 : -1)

Definition at line 44 of file common.h.

#define FFSWAP ( type,
a,
 )     do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)

Definition at line 51 of file common.h.

#define GET_UTF16 ( val,
GET_16BIT,
ERROR   ) 

Value:

val = GET_16BIT;\
    {\
        unsigned int hi = val - 0xD800;\
        if (hi < 0x800) {\
            val = GET_16BIT - 0xDC00;\
            if (val > 0x3FFU || hi > 0x3FFU)\
                ERROR\
            val += (hi<<10) + 0x10000;\
        }\
    }\
Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
Parameters:
val is the output and should be of type uint32_t. It holds the converted UCS-4 character and should be a left value.
GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness. It can be a function or a statement whose return value or evaluated value is of type uint16_t. It will be executed up to 2 times.
ERROR action that should be taken when an invalid UTF-16 surrogate is returned from GET_BYTE. It should be a statement that jumps out of the macro, like exit(), goto, return, break, or continue.

Definition at line 213 of file common.h.

#define GET_UTF8 ( val,
GET_BYTE,
ERROR   ) 

Value:

val= GET_BYTE;\
    {\
        int ones= 7 - av_log2(val ^ 255);\
        if(ones==1)\
            ERROR\
        val&= 127>>ones;\
        while(--ones > 0){\
            int tmp= GET_BYTE - 128;\
            if(tmp>>6)\
                ERROR\
            val= (val<<6) + tmp;\
        }\
    }
Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form
Parameters:
val is the output and should be of type uint32_t. It holds the converted UCS-4 character and should be a left value.
GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be a function or a statement whose return value or evaluated value is of type uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, and up to 7 times in the general case.
ERROR action that should be taken when an invalid UTF-8 byte is returned from GET_BYTE. It should be a statement that jumps out of the macro, like exit(), goto, return, break, or continue.

Definition at line 186 of file common.h.

#define MKBETAG ( a,
b,
c,
 )     (d | (c << 8) | (b << 16) | (a << 24))

Definition at line 171 of file common.h.

#define MKTAG ( a,
b,
c,
 )     (a | (b << 8) | (c << 16) | (d << 24))

Definition at line 170 of file common.h.

#define PUT_UTF16 ( val,
tmp,
PUT_16BIT   ) 

Value:

{\
        uint32_t in = val;\
        if (in < 0x10000) {\
            tmp = in;\
            PUT_16BIT\
        } else {\
            tmp = 0xD800 | ((in - 0x10000) >> 10);\
            PUT_16BIT\
            tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
            PUT_16BIT\
        }\
    }\
Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
Parameters:
val is an input-only argument and should be of type uint32_t. It holds a UCS-4 encoded Unicode character that is to be converted to UTF-16. If val is given as a function it is executed only once.
tmp is a temporary variable and should be of type uint16_t. It represents an intermediate value during conversion that is to be output by PUT_16BIT.
PUT_16BIT writes the converted UTF-16 data to any proper destination in desired endianness. It could be a function or a statement, and uses tmp as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be executed 1 or 2 times depending on input character.

Definition at line 275 of file common.h.

#define PUT_UTF8 ( val,
tmp,
PUT_BYTE   ) 

Value:

{\
        int bytes, shift;\
        uint32_t in = val;\
        if (in < 0x80) {\
            tmp = in;\
            PUT_BYTE\
        } else {\
            bytes = (av_log2(in) + 4) / 5;\
            shift = (bytes - 1) * 6;\
            tmp = (256 - (256 >> bytes)) | (in >> shift);\
            PUT_BYTE\
            while (shift >= 6) {\
                shift -= 6;\
                tmp = 0x80 | ((in >> shift) & 0x3f);\
                PUT_BYTE\
            }\
        }\
    }
Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
Parameters:
val is an input-only argument and should be of type uint32_t. It holds a UCS-4 encoded Unicode character that is to be converted to UTF-8. If val is given as a function it is executed only once.
tmp is a temporary variable and should be of type uint8_t. It represents an intermediate value during conversion that is to be output by PUT_BYTE.
PUT_BYTE writes the converted UTF-8 bytes to any proper destination. It could be a function or a statement, and uses tmp as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be executed up to 4 times for values in the valid UTF-8 range and up to 7 times in the general case, depending on the length of the converted Unicode character.

Definition at line 241 of file common.h.

#define ROUNDED_DIV ( a,
 )     (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))

Definition at line 42 of file common.h.

#define RSHIFT ( a,
 )     ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))

Definition at line 40 of file common.h.


Function Documentation

static av_const int av_ceil_log2 ( int  x  )  [inline, static]

Computes ceil(log2(x)).

Parameters:
x value used to compute ceil(log2(x))
Returns:
computed ceiling of log2(x)

Definition at line 165 of file common.h.

static av_const int av_clip ( int  a,
int  amin,
int  amax 
) [inline, static]

Clips a signed integer value into the amin-amax range.

Parameters:
a value to clip
amin minimum value of the clip range
amax maximum value of the clip range
Returns:
clipped value

Definition at line 107 of file common.h.

static av_const int16_t av_clip_int16 ( int  a  )  [inline, static]

Clips a signed integer value into the -32768,32767 range.

Parameters:
a value to clip
Returns:
clipped value

Definition at line 141 of file common.h.

static av_const uint16_t av_clip_uint16 ( int  a  )  [inline, static]

Clips a signed integer value into the 0-65535 range.

Parameters:
a value to clip
Returns:
clipped value

Definition at line 130 of file common.h.

static av_const uint8_t av_clip_uint8 ( int  a  )  [inline, static]

Clips a signed integer value into the 0-255 range.

Parameters:
a value to clip
Returns:
clipped value

Definition at line 119 of file common.h.

static av_const float av_clipf ( float  a,
float  amin,
float  amax 
) [inline, static]

Clips a float value into the amin-amax range.

Parameters:
a value to clip
amin minimum value of the clip range
amax maximum value of the clip range
Returns:
clipped value

Definition at line 154 of file common.h.

static av_const int av_log2_16bit_c ( unsigned int  v  )  [inline, static]

Definition at line 76 of file common.h.

static av_const int av_log2_c ( unsigned int  v  )  [inline, static]

Definition at line 60 of file common.h.


Variable Documentation

const uint8_t av_reverse[256]

Definition at line 53 of file mathematics.c.

const uint8_t ff_log2_tab[256]

Definition at line 42 of file mathematics.c.


Generated on Tue Apr 20 17:39:21 2010 for FFmpeg by  doxygen 1.5.6