diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-05 03:11:57 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-05 03:11:57 +0400 |
commit | 707138593af5c4783035d0b9cc2d7c8cb2137dfa (patch) | |
tree | 7ead2e3c73fd33764dede26546b0238bb40d484b /libavutil | |
parent | 2f8b6e909dd733d9b722a5266ca516a9a5ba67e9 (diff) | |
parent | dc6d0430503ecd7ed0d81276f977b26b4c4bd916 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
adpcmenc: cosmetics: pretty-printing
ac3dec: cosmetics: pretty-printing
yuv4mpeg: cosmetics: pretty-printing
shorten: remove dead initialization
roqvideodec: set AVFrame reference before reget_buffer.
bmp: fix some 1bit samples.
latmdec: add fate test for audio config change
oma: PCM support
oma: better format detection with small probe buffer
oma: clearify ambiguous if condition
wavpack: Properly clip samples during lossy decode
Code clean-up for crc.c, lfg.c, log.c, random_see.d, rational.c and tree.c.
Cleaned pixdesc.c file in libavutil
zmbv.c: coding style clean-up.
xan.c: coding style clean-up.
mpegvideo.c: code cleanup - first 500 lines.
Conflicts:
Changelog
libavcodec/adpcmenc.c
libavcodec/bmp.c
libavcodec/zmbv.c
libavutil/log.c
libavutil/pixdesc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/crc.c | 73 | ||||
-rw-r--r-- | libavutil/lfg.c | 34 | ||||
-rw-r--r-- | libavutil/log.c | 81 | ||||
-rw-r--r-- | libavutil/pixdesc.c | 967 | ||||
-rw-r--r-- | libavutil/random_seed.c | 28 | ||||
-rw-r--r-- | libavutil/rational.c | 110 | ||||
-rw-r--r-- | libavutil/tree.c | 196 |
7 files changed, 770 insertions, 719 deletions
diff --git a/libavutil/crc.c b/libavutil/crc.c index d0e736ed4d..d640184876 100644 --- a/libavutil/crc.c +++ b/libavutil/crc.c @@ -56,32 +56,34 @@ static AVCRC av_crc_table[AV_CRC_MAX][257]; * @param ctx_size size of ctx in bytes * @return <0 on failure */ -int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ +int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size) +{ unsigned i, j; uint32_t c; - if (bits < 8 || bits > 32 || poly >= (1LL<<bits)) + if (bits < 8 || bits > 32 || poly >= (1LL << bits)) return -1; - if (ctx_size != sizeof(AVCRC)*257 && ctx_size != sizeof(AVCRC)*1024) + if (ctx_size != sizeof(AVCRC) * 257 && ctx_size != sizeof(AVCRC) * 1024) return -1; for (i = 0; i < 256; i++) { if (le) { for (c = i, j = 0; j < 8; j++) - c = (c>>1)^(poly & (-(c&1))); + c = (c >> 1) ^ (poly & (-(c & 1))); ctx[i] = c; } else { for (c = i << 24, j = 0; j < 8; j++) - c = (c<<1) ^ ((poly<<(32-bits)) & (((int32_t)c)>>31) ); + c = (c << 1) ^ ((poly << (32 - bits)) & (((int32_t) c) >> 31)); ctx[i] = av_bswap32(c); } } - ctx[256]=1; + ctx[256] = 1; #if !CONFIG_SMALL - if(ctx_size >= sizeof(AVCRC)*1024) + if (ctx_size >= sizeof(AVCRC) * 1024) for (i = 0; i < 256; i++) - for(j=0; j<3; j++) - ctx[256*(j+1) + i]= (ctx[256*j + i]>>8) ^ ctx[ ctx[256*j + i]&0xFF ]; + for (j = 0; j < 3; j++) + ctx[256 *(j + 1) + i] = + (ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF]; #endif return 0; @@ -92,9 +94,10 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ * @param crc_id ID of a standard CRC * @return a pointer to the CRC table or NULL on failure */ -const AVCRC *av_crc_get_table(AVCRCId crc_id){ +const AVCRC *av_crc_get_table(AVCRCId crc_id) +{ #if !CONFIG_HARDCODED_TABLES - if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id])-1]) + if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id]) - 1]) if (av_crc_init(av_crc_table[crc_id], av_crc_table_params[crc_id].le, av_crc_table_params[crc_id].bits, @@ -112,46 +115,50 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id){ * * @see av_crc_init() "le" parameter */ -uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length){ - const uint8_t *end= buffer+length; +uint32_t av_crc(const AVCRC *ctx, uint32_t crc, + const uint8_t *buffer, size_t length) +{ + const uint8_t *end = buffer + length; #if !CONFIG_SMALL - if(!ctx[256]) { - while(((intptr_t) buffer & 3) && buffer < end) - crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); + if (!ctx[256]) { + while (((intptr_t) buffer & 3) && buffer < end) + crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8); - while(buffer<end-3){ - crc ^= av_le2ne32(*(const uint32_t*)buffer); buffer+=4; - crc = ctx[3*256 + ( crc &0xFF)] - ^ctx[2*256 + ((crc>>8 )&0xFF)] - ^ctx[1*256 + ((crc>>16)&0xFF)] - ^ctx[0*256 + ((crc>>24) )]; + while (buffer < end - 3) { + crc ^= av_le2ne32(*(const uint32_t *) buffer); buffer += 4; + crc = ctx[3 * 256 + ( crc & 0xFF)] ^ + ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^ + ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^ + ctx[0 * 256 + ((crc >> 24) )]; } } #endif - while(buffer<end) - crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); + while (buffer < end) + crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8); return crc; } #ifdef TEST #undef printf -int main(void){ +int main(void) +{ uint8_t buf[1999]; int i; - int p[4][3]={{AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04}, - {AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0}, - {AV_CRC_16_ANSI , 0x8005, 0x1FBB }, - {AV_CRC_8_ATM , 0x07, 0xE3 },}; + int p[4][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, + { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, + { AV_CRC_16_ANSI , 0x8005 , 0x1FBB }, + { AV_CRC_8_ATM , 0x07 , 0xE3 } + }; const AVCRC *ctx; - for(i=0; i<sizeof(buf); i++) - buf[i]= i+i*i; + for (i = 0; i < sizeof(buf); i++) + buf[i] = i + i * i; - for(i=0; i<4; i++){ + for (i = 0; i < 4; i++) { ctx = av_crc_get_table(p[i][0]); - printf("crc %08X =%X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf))); + printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf))); } return 0; } diff --git a/libavutil/lfg.c b/libavutil/lfg.c index b5db5a4b17..fb0b258ad4 100644 --- a/libavutil/lfg.c +++ b/libavutil/lfg.c @@ -27,19 +27,21 @@ #include "intreadwrite.h" #include "attributes.h" -void av_cold av_lfg_init(AVLFG *c, unsigned int seed){ - uint8_t tmp[16]={0}; +void av_cold av_lfg_init(AVLFG *c, unsigned int seed) +{ + uint8_t tmp[16] = { 0 }; int i; - for(i=8; i<64; i+=4){ - AV_WL32(tmp, seed); tmp[4]=i; - av_md5_sum(tmp, tmp, 16); - c->state[i ]= AV_RL32(tmp); - c->state[i+1]= AV_RL32(tmp+4); - c->state[i+2]= AV_RL32(tmp+8); - c->state[i+3]= AV_RL32(tmp+12); + for (i = 8; i < 64; i += 4) { + AV_WL32(tmp, seed); + tmp[4] = i; + av_md5_sum(tmp, tmp, 16); + c->state[i ] = AV_RL32(tmp); + c->state[i + 1] = AV_RL32(tmp + 4); + c->state[i + 2] = AV_RL32(tmp + 8); + c->state[i + 3] = AV_RL32(tmp + 12); } - c->index=0; + c->index = 0; } void av_bmg_get(AVLFG *lfg, double out[2]) @@ -47,9 +49,9 @@ void av_bmg_get(AVLFG *lfg, double out[2]) double x1, x2, w; do { - x1 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0; - x2 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0; - w = x1*x1 + x2*x2; + x1 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0; + x2 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0; + w = x1 * x1 + x2 * x2; } while (w >= 1.0); w = sqrt((-2.0 * log(w)) / w); @@ -63,7 +65,7 @@ void av_bmg_get(AVLFG *lfg, double out[2]) int main(void) { - int x=0; + int x = 0; int i, j; AVLFG state; @@ -71,8 +73,8 @@ int main(void) for (j = 0; j < 10000; j++) { START_TIMER for (i = 0; i < 624; i++) { -// av_log(NULL,AV_LOG_ERROR, "%X\n", av_lfg_get(&state)); - x+=av_lfg_get(&state); + //av_log(NULL, AV_LOG_ERROR, "%X\n", av_lfg_get(&state)); + x += av_lfg_get(&state); } STOP_TIMER("624 calls of av_lfg_get"); } diff --git a/libavutil/log.c b/libavutil/log.c index d38186f57a..3182885ace 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -34,49 +34,54 @@ static int flags; #if defined(_WIN32) && !defined(__MINGW32CE__) #include <windows.h> -static const uint8_t color[] = {12,12,12,14,7,7,7}; +static const uint8_t color[] = { 12, 12, 12, 14, 7, 7, 7 }; static int16_t background, attr_orig; static HANDLE con; #define set_color(x) SetConsoleTextAttribute(con, background | color[x]) #define reset_color() SetConsoleTextAttribute(con, attr_orig) #else -static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; -#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) +static const uint8_t color[] = { 0x41, 0x41, 0x11, 0x03, 9, 9, 9 }; +#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x] >> 4, color[x]&15) #define reset_color() fprintf(stderr, "\033[0m") #endif -static int use_color=-1; +static int use_color = -1; #undef fprintf -static void colored_fputs(int level, const char *str){ - if(use_color<0){ +static void colored_fputs(int level, const char *str) +{ + if (use_color < 0) { #if defined(_WIN32) && !defined(__MINGW32CE__) CONSOLE_SCREEN_BUFFER_INFO con_info; con = GetStdHandle(STD_ERROR_HANDLE); - use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); + use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && + !getenv("AV_LOG_FORCE_NOCOLOR"); if (use_color) { GetConsoleScreenBufferInfo(con, &con_info); attr_orig = con_info.wAttributes; background = attr_orig & 0xF0; } #elif HAVE_ISATTY - use_color= !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && - (getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR")); + use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && + (getenv("TERM") && isatty(2) || + getenv("AV_LOG_FORCE_COLOR")); #else - use_color= getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); + use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && + !getenv("AV_LOG_FORCE_NOCOLOR"); #endif } - if(use_color){ + if (use_color) { set_color(level); } fputs(str, stderr); - if(use_color){ + if (use_color) { reset_color(); } } -const char* av_default_item_name(void* ptr){ - return (*(AVClass**)ptr)->class_name; +const char *av_default_item_name(void *ptr) +{ + return (*(AVClass **) ptr)->class_name; } static void sanitize(uint8_t *line){ @@ -89,58 +94,64 @@ static void sanitize(uint8_t *line){ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) { - static int print_prefix=1; + static int print_prefix = 1; static int count; static char prev[1024]; char line[1024]; static int is_atty; - AVClass* avc= ptr ? *(AVClass**)ptr : NULL; - if(level>av_log_level) + AVClass* avc = ptr ? *(AVClass **) ptr : NULL; + if (level > av_log_level) return; - line[0]=0; + line[0] = 0; #undef fprintf - if(print_prefix && avc) { + if (print_prefix && avc) { if (avc->parent_log_context_offset) { - AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); - if(parent && *parent){ - snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); + AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + + avc->parent_log_context_offset); + if (parent && *parent) { + snprintf(line, sizeof(line), "[%s @ %p] ", + (*parent)->item_name(parent), parent); } } - snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); + snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", + avc->item_name(ptr), ptr); } vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); - print_prefix = strlen(line) && line[strlen(line)-1] == '\n'; + print_prefix = strlen(line) && line[strlen(line) - 1] == '\n'; #if HAVE_ISATTY - if(!is_atty) is_atty= isatty(2) ? 1 : -1; + if (!is_atty) + is_atty = isatty(2) ? 1 : -1; #endif - if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){ + if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){ count++; - if(is_atty==1) + if (is_atty == 1) fprintf(stderr, " Last message repeated %d times\r", count); return; } - if(count>0){ + if (count > 0) { fprintf(stderr, " Last message repeated %d times\n", count); - count=0; + count = 0; } strcpy(prev, line); sanitize(line); - colored_fputs(av_clip(level>>3, 0, 6), line); + colored_fputs(av_clip(level >> 3, 0, 6), line); } -static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; +static void (*av_log_callback)(void*, int, const char*, va_list) = + av_log_default_callback; void av_log(void* avcl, int level, const char *fmt, ...) { - AVClass* avc= avcl ? *(AVClass**)avcl : NULL; + AVClass* avc = avcl ? *(AVClass **) avcl : NULL; va_list vl; va_start(vl, fmt); - if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL) - level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset); + if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) && + avc->log_level_offset_offset && level >= AV_LOG_FATAL) + level += *(int *) (((uint8_t *) avcl) + avc->log_level_offset_offset); av_vlog(avcl, level, fmt, vl); va_end(vl); } @@ -162,7 +173,7 @@ void av_log_set_level(int level) void av_log_set_flags(int arg) { - flags= arg; + flags = arg; } void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index b89b11e0a2..c6616884a5 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -27,45 +27,46 @@ #include "intreadwrite.h" void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, + int read_pal_component) { - AVComponentDescriptor comp= desc->comp[c]; - int plane= comp.plane; - int depth= comp.depth_minus1+1; - int mask = (1<<depth)-1; - int shift= comp.shift; - int step = comp.step_minus1+1; - int flags= desc->flags; + AVComponentDescriptor comp = desc->comp[c]; + int plane = comp.plane; + int depth = comp.depth_minus1 + 1; + int mask = (1 << depth) - 1; + int shift = comp.shift; + int step = comp.step_minus1 + 1; + int flags = desc->flags; - if (flags & PIX_FMT_BITSTREAM){ - int skip = x*step + comp.offset_plus1-1; - const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); - int shift = 8 - depth - (skip&7); + if (flags & PIX_FMT_BITSTREAM) { + int skip = x * step + comp.offset_plus1 - 1; + const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3); + int shift = 8 - depth - (skip & 7); - while(w--){ + while (w--) { int val = (*p >> shift) & mask; - if(read_pal_component) - val= data[1][4*val + c]; + if (read_pal_component) + val = data[1][4*val + c]; shift -= step; - p -= shift>>3; + p -= shift >> 3; shift &= 7; - *dst++= val; + *dst++ = val; } } else { - const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; + const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1; int is_8bit = shift + depth <= 8; if (is_8bit) p += !!(flags & PIX_FMT_BE); - while(w--){ + while (w--) { int val = is_8bit ? *p : flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p); - val = (val>>shift) & mask; - if(read_pal_component) - val= data[1][4*val + c]; - p+= step; - *dst++= val; + val = (val >> shift) & mask; + if (read_pal_component) + val = data[1][4 * val + c]; + p += step; + *dst++ = val; } } } @@ -75,41 +76,41 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi { AVComponentDescriptor comp = desc->comp[c]; int plane = comp.plane; - int depth = comp.depth_minus1+1; - int step = comp.step_minus1+1; + int depth = comp.depth_minus1 + 1; + int step = comp.step_minus1 + 1; int flags = desc->flags; if (flags & PIX_FMT_BITSTREAM) { - int skip = x*step + comp.offset_plus1-1; - uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); - int shift = 8 - depth - (skip&7); + int skip = x * step + comp.offset_plus1 - 1; + uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3); + int shift = 8 - depth - (skip & 7); while (w--) { *p |= *src++ << shift; shift -= step; - p -= shift>>3; + p -= shift >> 3; shift &= 7; } } else { int shift = comp.shift; - uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; + uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1; if (shift + depth <= 8) { p += !!(flags & PIX_FMT_BE); while (w--) { - *p |= (*src++<<shift); + *p |= (*src++ << shift); p += step; } } else { while (w--) { if (flags & PIX_FMT_BE) { - uint16_t val = AV_RB16(p) | (*src++<<shift); + uint16_t val = AV_RB16(p) | (*src++ << shift); AV_WB16(p, val); } else { - uint16_t val = AV_RL16(p) | (*src++<<shift); + uint16_t val = AV_RL16(p) | (*src++ << shift); AV_WL16(p, val); } - p+= step; + p += step; } } } @@ -118,171 +119,171 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { [PIX_FMT_YUV420P] = { .name = "yuv420p", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUYV422] = { .name = "yuyv422", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,7}, /* Y */ - {0,3,2,0,7}, /* U */ - {0,3,4,0,7}, /* V */ + { 0, 1, 1, 0, 7 }, /* Y */ + { 0, 3, 2, 0, 7 }, /* U */ + { 0, 3, 4, 0, 7 }, /* V */ }, }, [PIX_FMT_RGB24] = { .name = "rgb24", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,2,1,0,7}, /* R */ - {0,2,2,0,7}, /* G */ - {0,2,3,0,7}, /* B */ + { 0, 2, 1, 0, 7 }, /* R */ + { 0, 2, 2, 0, 7 }, /* G */ + { 0, 2, 3, 0, 7 }, /* B */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_BGR24] = { .name = "bgr24", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,2,1,0,7}, /* B */ - {0,2,2,0,7}, /* G */ - {0,2,3,0,7}, /* R */ + { 0, 2, 1, 0, 7 }, /* B */ + { 0, 2, 2, 0, 7 }, /* G */ + { 0, 2, 3, 0, 7 }, /* R */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_YUV422P] = { .name = "yuv422p", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P] = { .name = "yuv444p", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV410P] = { .name = "yuv410p", - .nb_components= 3, - .log2_chroma_w= 2, - .log2_chroma_h= 2, + .nb_components = 3, + .log2_chroma_w = 2, + .log2_chroma_h = 2, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV411P] = { .name = "yuv411p", - .nb_components= 3, - .log2_chroma_w= 2, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 2, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_GRAY8] = { .name = "gray", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ + { 0, 0, 1, 0, 7 }, /* Y */ }, }, [PIX_FMT_MONOWHITE] = { .name = "monow", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,0}, /* Y */ + { 0, 0, 1, 0, 0 }, /* Y */ }, .flags = PIX_FMT_BITSTREAM, }, [PIX_FMT_MONOBLACK] = { .name = "monob", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,7,0}, /* Y */ + { 0, 0, 1, 7, 0 }, /* Y */ }, .flags = PIX_FMT_BITSTREAM, }, [PIX_FMT_PAL8] = { .name = "pal8", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, + { 0, 0, 1, 0, 7 }, }, .flags = PIX_FMT_PAL, }, [PIX_FMT_YUVJ420P] = { .name = "yuvj420p", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUVJ422P] = { .name = "yuvj422p", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUVJ444P] = { .name = "yuvj444p", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + {0, 0, 1, 0, 7}, /* Y */ + {1, 0, 1, 0, 7}, /* U */ + {2, 0, 1, 0, 7}, /* V */ }, .flags = PIX_FMT_PLANAR, }, @@ -296,171 +297,171 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_UYVY422] = { .name = "uyvy422", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,2,0,7}, /* Y */ - {0,3,1,0,7}, /* U */ - {0,3,3,0,7}, /* V */ + { 0, 1, 2, 0, 7 }, /* Y */ + { 0, 3, 1, 0, 7 }, /* U */ + { 0, 3, 3, 0, 7 }, /* V */ }, }, [PIX_FMT_UYYVYY411] = { .name = "uyyvyy411", - .nb_components= 3, - .log2_chroma_w= 2, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 2, + .log2_chroma_h = 0, .comp = { - {0,3,2,0,7}, /* Y */ - {0,5,1,0,7}, /* U */ - {0,5,4,0,7}, /* V */ + { 0, 3, 2, 0, 7 }, /* Y */ + { 0, 5, 1, 0, 7 }, /* U */ + { 0, 5, 4, 0, 7 }, /* V */ }, }, [PIX_FMT_BGR8] = { .name = "bgr8", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,6,1}, /* B */ - {0,0,1,3,2}, /* G */ - {0,0,1,0,2}, /* R */ + { 0, 0, 1, 6, 1 }, /* B */ + { 0, 0, 1, 3, 2 }, /* G */ + { 0, 0, 1, 0, 2 }, /* R */ }, .flags = PIX_FMT_PAL | PIX_FMT_RGB, }, [PIX_FMT_BGR4] = { .name = "bgr4", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,0}, /* B */ - {0,3,2,0,1}, /* G */ - {0,3,4,0,0}, /* R */ + { 0, 3, 1, 0, 0 }, /* B */ + { 0, 3, 2, 0, 1 }, /* G */ + { 0, 3, 4, 0, 0 }, /* R */ }, .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB, }, [PIX_FMT_BGR4_BYTE] = { .name = "bgr4_byte", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,3,0}, /* B */ - {0,0,1,1,1}, /* G */ - {0,0,1,0,0}, /* R */ + { 0, 0, 1, 3, 0 }, /* B */ + { 0, 0, 1, 1, 1 }, /* G */ + { 0, 0, 1, 0, 0 }, /* R */ }, .flags = PIX_FMT_PAL | PIX_FMT_RGB, }, [PIX_FMT_RGB8] = { .name = "rgb8", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,6,1}, /* R */ - {0,0,1,3,2}, /* G */ - {0,0,1,0,2}, /* B */ + { 0, 0, 1, 6, 1 }, /* R */ + { 0, 0, 1, 3, 2 }, /* G */ + { 0, 0, 1, 0, 2 }, /* B */ }, .flags = PIX_FMT_PAL | PIX_FMT_RGB, }, [PIX_FMT_RGB4] = { .name = "rgb4", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,0}, /* R */ - {0,3,2,0,1}, /* G */ - {0,3,4,0,0}, /* B */ + { 0, 3, 1, 0, 0 }, /* R */ + { 0, 3, 2, 0, 1 }, /* G */ + { 0, 3, 4, 0, 0 }, /* B */ }, .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB, }, [PIX_FMT_RGB4_BYTE] = { .name = "rgb4_byte", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,3,0}, /* R */ - {0,0,1,1,1}, /* G */ - {0,0,1,0,0}, /* B */ + { 0, 0, 1, 3, 0 }, /* R */ + { 0, 0, 1, 1, 1 }, /* G */ + { 0, 0, 1, 0, 0 }, /* B */ }, .flags = PIX_FMT_PAL | PIX_FMT_RGB, }, [PIX_FMT_NV12] = { .name = "nv12", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,1,1,0,7}, /* U */ - {1,1,2,0,7}, /* V */ + { 0,0,1,0,7 }, /* Y */ + { 1,1,1,0,7 }, /* U */ + { 1,1,2,0,7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_NV21] = { .name = "nv21", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,1,1,0,7}, /* V */ - {1,1,2,0,7}, /* U */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 1, 1, 0, 7 }, /* V */ + { 1, 1, 2, 0, 7 }, /* U */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_ARGB] = { .name = "argb", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,7}, /* A */ - {0,3,2,0,7}, /* R */ - {0,3,3,0,7}, /* G */ - {0,3,4,0,7}, /* B */ + { 0, 3, 1, 0, 7 }, /* A */ + { 0, 3, 2, 0, 7 }, /* R */ + { 0, 3, 3, 0, 7 }, /* G */ + { 0, 3, 4, 0, 7 }, /* B */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_RGBA] = { .name = "rgba", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,7}, /* R */ - {0,3,2,0,7}, /* G */ - {0,3,3,0,7}, /* B */ - {0,3,4,0,7}, /* A */ + { 0, 3, 1, 0, 7 }, /* R */ + { 0, 3, 2, 0, 7 }, /* G */ + { 0, 3, 3, 0, 7 }, /* B */ + { 0, 3, 4, 0, 7 }, /* A */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_ABGR] = { .name = "abgr", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,7}, /* A */ - {0,3,2,0,7}, /* B */ - {0,3,3,0,7}, /* G */ - {0,3,4,0,7}, /* R */ + { 0, 3, 1, 0, 7 }, /* A */ + { 0, 3, 2, 0, 7 }, /* B */ + { 0, 3, 3, 0, 7 }, /* G */ + { 0, 3, 4, 0, 7 }, /* R */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_BGRA] = { .name = "bgra", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,3,1,0,7}, /* B */ - {0,3,2,0,7}, /* G */ - {0,3,3,0,7}, /* R */ - {0,3,4,0,7}, /* A */ + { 0, 3, 1, 0, 7 }, /* B */ + { 0, 3, 2, 0, 7 }, /* G */ + { 0, 3, 3, 0, 7 }, /* R */ + { 0, 3, 4, 0, 7 }, /* A */ }, .flags = PIX_FMT_RGB, }, @@ -516,57 +517,57 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_GRAY16BE] = { .name = "gray16be", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ + { 0, 1, 1, 0, 15 }, /* Y */ }, .flags = PIX_FMT_BE, }, [PIX_FMT_GRAY16LE] = { .name = "gray16le", - .nb_components= 1, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 1, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ + { 0, 1, 1, 0, 15 }, /* Y */ }, }, [PIX_FMT_YUV440P] = { .name = "yuv440p", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUVJ440P] = { .name = "yuvj440p", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUVA420P] = { .name = "yuva420p", - .nb_components= 4, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 4, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,0,1,0,7}, /* Y */ - {1,0,1,0,7}, /* U */ - {2,0,1,0,7}, /* V */ - {3,0,1,0,7}, /* A */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ + { 3, 0, 1, 0, 7 }, /* A */ }, .flags = PIX_FMT_PLANAR, }, @@ -608,25 +609,25 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_RGB48BE] = { .name = "rgb48be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,5,1,0,15}, /* R */ - {0,5,3,0,15}, /* G */ - {0,5,5,0,15}, /* B */ + { 0, 5, 1, 0, 15 }, /* R */ + { 0, 5, 3, 0, 15 }, /* G */ + { 0, 5, 5, 0, 15 }, /* B */ }, .flags = PIX_FMT_RGB | PIX_FMT_BE, }, [PIX_FMT_RGB48LE] = { .name = "rgb48le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,5,1,0,15}, /* R */ - {0,5,3,0,15}, /* G */ - {0,5,5,0,15}, /* B */ + { 0, 5, 1, 0, 15 }, /* R */ + { 0, 5, 3, 0, 15 }, /* G */ + { 0, 5, 5, 0, 15 }, /* B */ }, .flags = PIX_FMT_RGB, }, @@ -658,97 +659,97 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_RGB565BE] = { .name = "rgb565be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,3,4}, /* R */ - {0,1,1,5,5}, /* G */ - {0,1,1,0,4}, /* B */ + { 0, 1, 0, 3, 4 }, /* R */ + { 0, 1, 1, 5, 5 }, /* G */ + { 0, 1, 1, 0, 4 }, /* B */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_RGB565LE] = { .name = "rgb565le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,3,4}, /* R */ - {0,1,1,5,5}, /* G */ - {0,1,1,0,4}, /* B */ + { 0, 1, 2, 3, 4 }, /* R */ + { 0, 1, 1, 5, 5 }, /* G */ + { 0, 1, 1, 0, 4 }, /* B */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_RGB555BE] = { .name = "rgb555be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,2,4}, /* R */ - {0,1,1,5,4}, /* G */ - {0,1,1,0,4}, /* B */ + { 0, 1, 0, 2, 4 }, /* R */ + { 0, 1, 1, 5, 4 }, /* G */ + { 0, 1, 1, 0, 4 }, /* B */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_RGB555LE] = { .name = "rgb555le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,2,4}, /* R */ - {0,1,1,5,4}, /* G */ - {0,1,1,0,4}, /* B */ + { 0, 1, 2, 2, 4 }, /* R */ + { 0, 1, 1, 5, 4 }, /* G */ + { 0, 1, 1, 0, 4 }, /* B */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_RGB444BE] = { .name = "rgb444be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,0,3}, /* R */ - {0,1,1,4,3}, /* G */ - {0,1,1,0,3}, /* B */ + { 0, 1, 0, 0, 3 }, /* R */ + { 0, 1, 1, 4, 3 }, /* G */ + { 0, 1, 1, 0, 3 }, /* B */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_RGB444LE] = { .name = "rgb444le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,0,3}, /* R */ - {0,1,1,4,3}, /* G */ - {0,1,1,0,3}, /* B */ + { 0, 1, 2, 0, 3 }, /* R */ + { 0, 1, 1, 4, 3 }, /* G */ + { 0, 1, 1, 0, 3 }, /* B */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_BGR48BE] = { .name = "bgr48be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,5,1,0,15}, /* B */ - {0,5,3,0,15}, /* G */ - {0,5,5,0,15}, /* R */ + { 0, 5, 1, 0, 15 }, /* B */ + { 0, 5, 3, 0, 15 }, /* G */ + { 0, 5, 5, 0, 15 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_BGR48LE] = { .name = "bgr48le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,5,1,0,15}, /* B */ - {0,5,3,0,15}, /* G */ - {0,5,5,0,15}, /* R */ + { 0, 5, 1, 0, 15 }, /* B */ + { 0, 5, 3, 0, 15 }, /* G */ + { 0, 5, 5, 0, 15 }, /* R */ }, .flags = PIX_FMT_RGB, }, @@ -779,73 +780,73 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_BGR565BE] = { .name = "bgr565be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,3,4}, /* B */ - {0,1,1,5,5}, /* G */ - {0,1,1,0,4}, /* R */ + { 0, 1, 0, 3, 4 }, /* B */ + { 0, 1, 1, 5, 5 }, /* G */ + { 0, 1, 1, 0, 4 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_BGR565LE] = { .name = "bgr565le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,3,4}, /* B */ - {0,1,1,5,5}, /* G */ - {0,1,1,0,4}, /* R */ + { 0, 1, 2, 3, 4 }, /* B */ + { 0, 1, 1, 5, 5 }, /* G */ + { 0, 1, 1, 0, 4 }, /* R */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_BGR555BE] = { .name = "bgr555be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,2,4}, /* B */ - {0,1,1,5,4}, /* G */ - {0,1,1,0,4}, /* R */ + { 0, 1, 0, 2, 4 }, /* B */ + { 0, 1, 1, 5, 4 }, /* G */ + { 0, 1, 1, 0, 4 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_BGR555LE] = { .name = "bgr555le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,2,4}, /* B */ - {0,1,1,5,4}, /* G */ - {0,1,1,0,4}, /* R */ + { 0, 1, 2, 2, 4 }, /* B */ + { 0, 1, 1, 5, 4 }, /* G */ + { 0, 1, 1, 0, 4 }, /* R */ }, .flags = PIX_FMT_RGB, }, [PIX_FMT_BGR444BE] = { .name = "bgr444be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,0,0,3}, /* B */ - {0,1,1,4,3}, /* G */ - {0,1,1,0,3}, /* R */ + { 0, 1, 0, 0, 3 }, /* B */ + { 0, 1, 1, 4, 3 }, /* G */ + { 0, 1, 1, 0, 3 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_RGB, }, [PIX_FMT_BGR444LE] = { .name = "bgr444le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,2,0,3}, /* B */ - {0,1,1,4,3}, /* G */ - {0,1,1,0,3}, /* R */ + { 0, 1, 2, 0, 3 }, /* B */ + { 0, 1, 1, 4, 3 }, /* G */ + { 0, 1, 1, 0, 3 }, /* R */ }, .flags = PIX_FMT_RGB, }, @@ -875,93 +876,93 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_YUV420P9LE] = { .name = "yuv420p9le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,8}, /* Y */ - {1,1,1,0,8}, /* U */ - {2,1,1,0,8}, /* V */ + { 0, 1, 1, 0, 8 }, /* Y */ + { 1, 1, 1, 0, 8 }, /* U */ + { 2, 1, 1, 0, 8 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV420P9BE] = { .name = "yuv420p9be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,8}, /* Y */ - {1,1,1,0,8}, /* U */ - {2,1,1,0,8}, /* V */ + { 0, 1, 1, 0, 8 }, /* Y */ + { 1, 1, 1, 0, 8 }, /* U */ + { 2, 1, 1, 0, 8 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV420P10LE] = { .name = "yuv420p10le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV420P10BE] = { .name = "yuv420p10be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV420P16LE] = { .name = "yuv420p16le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV420P16BE] = { .name = "yuv420p16be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 1, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV422P9LE] = { .name = "yuv422p9le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,8}, /* Y */ - {1,1,1,0,8}, /* U */ - {2,1,1,0,8}, /* V */ + { 0, 1, 1, 0, 8 }, /* Y */ + { 1, 1, 1, 0, 8 }, /* U */ + { 2, 1, 1, 0, 8 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV422P9BE] = { .name = "yuv422p9be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { {0,1,1,0,8}, /* Y */ {1,1,1,0,8}, /* U */ @@ -971,121 +972,121 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_YUV422P10LE] = { .name = "yuv422p10le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV422P10BE] = { .name = "yuv422p10be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV422P16LE] = { .name = "yuv422p16le", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV422P16BE] = { .name = "yuv422p16be", - .nb_components= 3, - .log2_chroma_w= 1, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P16LE] = { .name = "yuv444p16le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P16BE] = { .name = "yuv444p16be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* Y */ - {1,1,1,0,15}, /* U */ - {2,1,1,0,15}, /* V */ + { 0, 1, 1, 0, 15 }, /* Y */ + { 1, 1, 1, 0, 15 }, /* U */ + { 2, 1, 1, 0, 15 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P10LE] = { .name = "yuv444p10le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P10BE] = { .name = "yuv444p10be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + { 0, 1, 1, 0, 9 }, /* Y */ + { 1, 1, 1, 0, 9 }, /* U */ + { 2, 1, 1, 0, 9 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P9LE] = { .name = "yuv444p9le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,8}, /* Y */ - {1,1,1,0,8}, /* U */ - {2,1,1,0,8}, /* V */ + { 0, 1, 1, 0, 8 }, /* Y */ + { 1, 1, 1, 0, 8 }, /* U */ + { 2, 1, 1, 0, 8 }, /* V */ }, .flags = PIX_FMT_PLANAR, }, [PIX_FMT_YUV444P9BE] = { .name = "yuv444p9be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,8}, /* Y */ - {1,1,1,0,8}, /* U */ - {2,1,1,0,8}, /* V */ + { 0, 1, 1, 0, 8 }, /* Y */ + { 1, 1, 1, 0, 8 }, /* U */ + { 2, 1, 1, 0, 8 }, /* V */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR, }, @@ -1103,10 +1104,10 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_GRAY8A] = { .name = "gray8a", - .nb_components= 2, + .nb_components = 2, .comp = { - {0,1,1,0,7}, /* Y */ - {0,1,2,0,7}, /* A */ + { 0, 1, 1, 0, 7 }, /* Y */ + { 0, 1, 2, 0, 7 }, /* A */ }, }, [PIX_FMT_GBR24P] = { @@ -1121,85 +1122,85 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { }, [PIX_FMT_GBRP] = { .name = "gbrp", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,0,1,0,7}, /* G */ - {1,0,1,0,7}, /* B */ - {2,0,1,0,7}, /* R */ + { 0, 0, 1, 0, 7 }, /* G */ + { 1, 0, 1, 0, 7 }, /* B */ + { 2, 0, 1, 0, 7 }, /* R */ }, .flags = PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP9LE] = { .name = "gbrp9le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,8}, /* G */ - {1,1,1,0,8}, /* B */ - {2,1,1,0,8}, /* R */ + { 0, 1, 1, 0, 8 }, /* G */ + { 1, 1, 1, 0, 8 }, /* B */ + { 2, 1, 1, 0, 8 }, /* R */ }, .flags = PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP9BE] = { .name = "gbrp9be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,8}, /* G */ - {1,1,1,0,8}, /* B */ - {2,1,1,0,8}, /* R */ + { 0, 1, 1, 0, 8 }, /* G */ + { 1, 1, 1, 0, 8 }, /* B */ + { 2, 1, 1, 0, 8 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP10LE] = { .name = "gbrp10le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* G */ - {1,1,1,0,9}, /* B */ - {2,1,1,0,9}, /* R */ + { 0, 1, 1, 0, 9 }, /* G */ + { 1, 1, 1, 0, 9 }, /* B */ + { 2, 1, 1, 0, 9 }, /* R */ }, .flags = PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP10BE] = { .name = "gbrp10be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,9}, /* G */ - {1,1,1,0,9}, /* B */ - {2,1,1,0,9}, /* R */ + { 0, 1, 1, 0, 9 }, /* G */ + { 1, 1, 1, 0, 9 }, /* B */ + { 2, 1, 1, 0, 9 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP16LE] = { .name = "gbrp16le", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* G */ - {1,1,1,0,15}, /* B */ - {2,1,1,0,15}, /* R */ + { 0, 1, 1, 0, 15 }, /* G */ + { 1, 1, 1, 0, 15 }, /* B */ + { 2, 1, 1, 0, 15 }, /* R */ }, .flags = PIX_FMT_PLANAR | PIX_FMT_RGB, }, [PIX_FMT_GBRP16BE] = { .name = "gbrp16be", - .nb_components= 3, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { - {0,1,1,0,15}, /* G */ - {1,1,1,0,15}, /* B */ - {2,1,1,0,15}, /* R */ + { 0, 1, 1, 0, 15 }, /* G */ + { 1, 1, 1, 0, 15 }, /* B */ + { 2, 1, 1, 0, 15 }, /* R */ }, .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB, }, @@ -1254,8 +1255,8 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h; for (c = 0; c < pixdesc->nb_components; c++) { - int s = c==1 || c==2 ? 0 : log2_pixels; - bits += (pixdesc->comp[c].depth_minus1+1) << s; + int s = c == 1 || c == 2 ? 0 : log2_pixels; + bits += (pixdesc->comp[c].depth_minus1 + 1) << s; } return bits >> log2_pixels; @@ -1265,11 +1266,11 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) { /* print header */ if (pix_fmt < 0) { - snprintf (buf, buf_size, "name " " nb_components" " nb_bits"); + snprintf (buf, buf_size, "name" " nb_components" " nb_bits"); } else { const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt]; - snprintf(buf, buf_size, "%-11s %7d %10d", - pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); + snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name, + pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); } return buf; diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 81805e5db0..235028b5c5 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -40,24 +40,24 @@ static int read_random(uint32_t *dst, const char *file) static uint32_t get_generic_seed(void) { - clock_t last_t=0; - int bits=0; - uint64_t random=0; + clock_t last_t = 0; + int bits = 0; + uint64_t random = 0; unsigned i; - float s=0.000000000001; + float s = 0.000000000001; - for(i=0;bits<64;i++){ - clock_t t= clock(); - if(last_t && fabs(t-last_t)>s || t==(clock_t)-1){ - if(i<10000 && s<(1<<24)){ - s+=s; - i=t=0; - }else{ - random= 2*random + (i&1); + for (i = 0; bits < 64; i++) { + clock_t t = clock(); + if (last_t && fabs(t - last_t) > s || t == (clock_t) -1) { + if (i < 10000 && s < (1 << 24)) { + s += s; + i = t = 0; + } else { + random = 2 * random + (i & 1); bits++; } } - last_t= t; + last_t = t; } #ifdef AV_READ_TIME random ^= AV_READ_TIME(); @@ -65,7 +65,7 @@ static uint32_t get_generic_seed(void) random ^= clock(); #endif - random += random>>32; + random += random >> 32; return random; } diff --git a/libavutil/rational.c b/libavutil/rational.c index b1bd655158..1a833ebec1 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -33,75 +33,86 @@ #include "mathematics.h" #include "rational.h" -int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max){ - AVRational a0={0,1}, a1={1,0}; - int sign= (num<0) ^ (den<0); - int64_t gcd= av_gcd(FFABS(num), FFABS(den)); - - if(gcd){ - num = FFABS(num)/gcd; - den = FFABS(den)/gcd; +int av_reduce(int *dst_num, int *dst_den, + int64_t num, int64_t den, int64_t max) +{ + AVRational a0 = { 0, 1 }, a1 = { 1, 0 }; + int sign = (num < 0) ^ (den < 0); + int64_t gcd = av_gcd(FFABS(num), FFABS(den)); + + if (gcd) { + num = FFABS(num) / gcd; + den = FFABS(den) / gcd; } - if(num<=max && den<=max){ - a1= (AVRational){num, den}; - den=0; + if (num <= max && den <= max) { + a1 = (AVRational) { num, den }; + den = 0; } - while(den){ - uint64_t x = num / den; - int64_t next_den= num - den*x; - int64_t a2n= x*a1.num + a0.num; - int64_t a2d= x*a1.den + a0.den; + while (den) { + uint64_t x = num / den; + int64_t next_den = num - den * x; + int64_t a2n = x * a1.num + a0.num; + int64_t a2d = x * a1.den + a0.den; - if(a2n > max || a2d > max){ - if(a1.num) x= (max - a0.num) / a1.num; - if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den); + if (a2n > max || a2d > max) { + if (a1.num) x = (max - a0.num) / a1.num; + if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den); - if (den*(2*x*a1.den + a0.den) > num*a1.den) - a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den}; + if (den * (2 * x * a1.den + a0.den) > num * a1.den) + a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den }; break; } - a0= a1; - a1= (AVRational){a2n, a2d}; - num= den; - den= next_den; + a0 = a1; + a1 = (AVRational) { a2n, a2d }; + num = den; + den = next_den; } av_assert2(av_gcd(a1.num, a1.den) <= 1U); *dst_num = sign ? -a1.num : a1.num; *dst_den = a1.den; - return den==0; + return den == 0; } -AVRational av_mul_q(AVRational b, AVRational c){ - av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX); +AVRational av_mul_q(AVRational b, AVRational c) +{ + av_reduce(&b.num, &b.den, + b.num * (int64_t) c.num, + b.den * (int64_t) c.den, INT_MAX); return b; } -AVRational av_div_q(AVRational b, AVRational c){ - return av_mul_q(b, (AVRational){c.den, c.num}); +AVRational av_div_q(AVRational b, AVRational c) +{ + return av_mul_q(b, (AVRational) { c.den, c.num }); } -AVRational av_add_q(AVRational b, AVRational c){ - av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); +AVRational av_add_q(AVRational b, AVRational c) { + av_reduce(&b.num, &b.den, + b.num * (int64_t) c.den + + c.num * (int64_t) b.den, + b.den * (int64_t) c.den, INT_MAX); return b; } -AVRational av_sub_q(AVRational b, AVRational c){ - return av_add_q(b, (AVRational){-c.num, c.den}); +AVRational av_sub_q(AVRational b, AVRational c) +{ + return av_add_q(b, (AVRational) { -c.num, c.den }); } -AVRational av_d2q(double d, int max){ +AVRational av_d2q(double d, int max) +{ AVRational a; #define LOG2 0.69314718055994530941723212145817656807550013436025 int exponent; int64_t den; if (isnan(d)) - return (AVRational){0,0}; + return (AVRational) { 0,0 }; if (isinf(d)) - return (AVRational){ d<0 ? -1:1, 0 }; + return (AVRational) { d < 0 ? -1 : 1, 0 }; exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); den = 1LL << (61 - exponent); av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); @@ -127,7 +138,7 @@ int av_nearer_q(AVRational q, AVRational q1, AVRational q2) int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) { int i, nearest_q_idx = 0; - for(i=0; q_list[i].den; i++) + for (i = 0; q_list[i].den; i++) if (av_nearer_q(q, q_list[i], q_list[nearest_q_idx]) > 0) nearest_q_idx = i; @@ -138,16 +149,19 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) int main(void) { AVRational a,b; - for(a.num=-2; a.num<=2; a.num++){ - for(a.den=-2; a.den<=2; a.den++){ - for(b.num=-2; b.num<=2; b.num++){ - for(b.den=-2; b.den<=2; b.den++){ - int c= av_cmp_q(a,b); - double d= av_q2d(a) == av_q2d(b) ? 0 : (av_q2d(a) - av_q2d(b)); - if(d>0) d=1; - else if(d<0) d=-1; - else if(d != d) d= INT_MIN; - if(c!=d) av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num, a.den, b.num, b.den, c,d); + for (a.num = -2; a.num <= 2; a.num++) { + for (a.den = -2; a.den <= 2; a.den++) { + for (b.num = -2; b.num <= 2; b.num++) { + for (b.den = -2; b.den <= 2; b.den++) { + int c = av_cmp_q(a,b); + double d = av_q2d(a) == av_q2d(b) ? + 0 : (av_q2d(a) - av_q2d(b)); + if (d > 0) d = 1; + else if (d < 0) d = -1; + else if (d != d) d = INT_MIN; + if (c != d) + av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num, + a.den, b.num, b.den, c,d); } } } diff --git a/libavutil/tree.c b/libavutil/tree.c index 8769c76b0f..58cd33d770 100644 --- a/libavutil/tree.c +++ b/libavutil/tree.c @@ -21,22 +21,24 @@ #include "log.h" #include "tree.h" -typedef struct AVTreeNode{ +typedef struct AVTreeNode { struct AVTreeNode *child[2]; void *elem; int state; -}AVTreeNode; +} AVTreeNode; const int av_tree_node_size = sizeof(AVTreeNode); -void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const void *b), void *next[2]){ - if(t){ - unsigned int v= cmp(key, t->elem); - if(v){ - if(next) next[v>>31]= t->elem; - return av_tree_find(t->child[(v>>31)^1], key, cmp, next); - }else{ - if(next){ +void *av_tree_find(const AVTreeNode *t, void *key, + int (*cmp)(void *key, const void *b), void *next[2]) +{ + if (t) { + unsigned int v = cmp(key, t->elem); + if (v) { + if (next) next[v >> 31] = t->elem; + return av_tree_find(t->child[(v >> 31) ^ 1], key, cmp, next); + } else { + if (next) { av_tree_find(t->child[0], key, cmp, next); av_tree_find(t->child[1], key, cmp, next); } @@ -46,41 +48,43 @@ void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const v return NULL; } -void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){ - AVTreeNode *t= *tp; - if(t){ - unsigned int v= cmp(t->elem, key); +void *av_tree_insert(AVTreeNode **tp, void *key, + int (*cmp)(void *key, const void *b), AVTreeNode **next) +{ + AVTreeNode *t = *tp; + if (t) { + unsigned int v = cmp(t->elem, key); void *ret; - if(!v){ - if(*next) + if (!v) { + if (*next) return t->elem; - else if(t->child[0]||t->child[1]){ - int i= !t->child[0]; + else if (t->child[0] || t->child[1]) { + int i = !t->child[0]; void *next_elem[2]; av_tree_find(t->child[i], key, cmp, next_elem); - key= t->elem= next_elem[i]; - v= -i; - }else{ - *next= t; - *tp=NULL; + key = t->elem = next_elem[i]; + v = -i; + } else { + *next = t; + *tp = NULL; return NULL; } } - ret= av_tree_insert(&t->child[v>>31], key, cmp, next); - if(!ret){ - int i= (v>>31) ^ !!*next; - AVTreeNode **child= &t->child[i]; - t->state += 2*i - 1; - - if(!(t->state&1)){ - if(t->state){ + ret = av_tree_insert(&t->child[v >> 31], key, cmp, next); + if (!ret) { + int i = (v >> 31) ^ !!*next; + AVTreeNode **child = &t->child[i]; + t->state += 2 * i - 1; + + if (!(t->state & 1)) { + if (t->state) { /* The following code is equivalent to if((*child)->state*2 == -t->state) rotate(child, i^1); rotate(tp, i); with rotate(): - static void rotate(AVTreeNode **tp, int i){ + static void rotate(AVTreeNode **tp, int i) { AVTreeNode *t= *tp; *tp= t->child[i]; @@ -92,54 +96,62 @@ void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const voi } but such a rotate function is both bigger and slower */ - if((*child)->state*2 == -t->state){ - *tp= (*child)->child[i^1]; - (*child)->child[i^1]= (*tp)->child[i]; - (*tp)->child[i]= *child; - *child= (*tp)->child[i^1]; - (*tp)->child[i^1]= t; - - (*tp)->child[0]->state= -((*tp)->state>0); - (*tp)->child[1]->state= (*tp)->state<0 ; - (*tp)->state=0; - }else{ - *tp= *child; - *child= (*child)->child[i^1]; - (*tp)->child[i^1]= t; - if((*tp)->state) t->state = 0; - else t->state>>= 1; - (*tp)->state= -t->state; + if (( *child )->state * 2 == -t->state) { + *tp = (*child)->child[i ^ 1]; + (*child)->child[i ^ 1] = (*tp)->child[i]; + (*tp)->child[i] = *child; + *child = ( *tp )->child[i ^ 1]; + (*tp)->child[i ^ 1] = t; + + (*tp)->child[0]->state = -((*tp)->state > 0); + (*tp)->child[1]->state = (*tp)->state < 0; + (*tp)->state = 0; + } else { + *tp = *child; + *child = (*child)->child[i ^ 1]; + (*tp)->child[i ^ 1] = t; + if ((*tp)->state) t->state = 0; + else t->state >>= 1; + (*tp)->state = -t->state; } } } - if(!(*tp)->state ^ !!*next) + if (!(*tp)->state ^ !!*next) return key; } return ret; - }else{ - *tp= *next; *next= NULL; - if(*tp){ - (*tp)->elem= key; + } else { + *tp = *next; + *next = NULL; + if (*tp) { + (*tp)->elem = key; return NULL; - }else + } else return key; } } -void av_tree_destroy(AVTreeNode *t){ - if(t){ +void av_tree_destroy(AVTreeNode *t) +{ + if (t) { av_tree_destroy(t->child[0]); av_tree_destroy(t->child[1]); av_free(t); } } -void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){ - if(t){ - int v= cmp ? cmp(opaque, t->elem) : 0; - if(v>=0) av_tree_enumerate(t->child[0], opaque, cmp, enu); - if(v==0) enu(opaque, t->elem); - if(v<=0) av_tree_enumerate(t->child[1], opaque, cmp, enu); +void av_tree_enumerate(AVTreeNode *t, void *opaque, + int (*cmp)(void *opaque, void *elem), + int (*enu)(void *opaque, void *elem)) +{ + if (t) { + int v = cmp ? cmp(opaque, t->elem) : 0; + if (v >= 0) + av_tree_enumerate(t->child[0], opaque, cmp, enu); + if (v == 0) + enu(opaque, t->elem); + if (v <= 0) + av_tree_enumerate(t->child[1], opaque, cmp, enu); } } @@ -147,64 +159,68 @@ void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, voi #include "lfg.h" -static int check(AVTreeNode *t){ - if(t){ - int left= check(t->child[0]); - int right= check(t->child[1]); +static int check(AVTreeNode *t) +{ + if (t) { + int left = check(t->child[0]); + int right = check(t->child[1]); - if(left>999 || right>999) + if (left>999 || right>999) return 1000; - if(right - left != t->state) + if (right - left != t->state) return 1000; - if(t->state>1 || t->state<-1) + if (t->state>1 || t->state<-1) return 1000; - return FFMAX(left, right)+1; + return FFMAX(left, right) + 1; } return 0; } -static void print(AVTreeNode *t, int depth){ +static void print(AVTreeNode *t, int depth) +{ int i; - for(i=0; i<depth*4; i++) av_log(NULL, AV_LOG_ERROR, " "); - if(t){ + for (i = 0; i < depth * 4; i++) av_log(NULL, AV_LOG_ERROR, " "); + if (t) { av_log(NULL, AV_LOG_ERROR, "Node %p %2d %p\n", t, t->state, t->elem); - print(t->child[0], depth+1); - print(t->child[1], depth+1); - }else + print(t->child[0], depth + 1); + print(t->child[1], depth + 1); + } else av_log(NULL, AV_LOG_ERROR, "NULL\n"); } -static int cmp(void *a, const void *b){ - return (uint8_t*)a-(const uint8_t*)b; +static int cmp(void *a, const void *b) +{ + return (uint8_t *) a - (const uint8_t *) b; } -int main(void){ +int main (void) +{ int i; void *k; - AVTreeNode *root= NULL, *node=NULL; + AVTreeNode *root = NULL, *node = NULL; AVLFG prng; av_lfg_init(&prng, 1); - for(i=0; i<10000; i++){ + for (i = 0; i < 10000; i++) { int j = av_lfg_get(&prng) % 86294; - if(check(root) > 999){ + if (check(root) > 999) { av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i); print(root, 0); return -1; } av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); - if(!node) - node= av_mallocz(av_tree_node_size); - av_tree_insert(&root, (void*)(j+1), cmp, &node); + if (!node) + node = av_mallocz(av_tree_node_size); + av_tree_insert(&root, (void *) (j + 1), cmp, &node); j = av_lfg_get(&prng) % 86294; { - AVTreeNode *node2=NULL; + AVTreeNode *node2 = NULL; av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j); - av_tree_insert(&root, (void*)(j+1), cmp, &node2); - k= av_tree_find(root, (void*)(j+1), cmp, NULL); - if(k) + av_tree_insert(&root, (void *) (j + 1), cmp, &node2); + k = av_tree_find(root, (void *) (j + 1), cmp, NULL); + if (k) av_log(NULL, AV_LOG_ERROR, "removal failure %d\n", i); } } |