[FFmpeg-cvslog] r20070 - in trunk/libavcodec: vorbis.c vorbis.h vorbis_data.c vorbis_dec.c vorbis_enc.c

diego subversion
Mon Sep 28 23:13:47 CEST 2009


Author: diego
Date: Mon Sep 28 23:13:47 2009
New Revision: 20070

Log:
brace placement and linebreak cosmetics

Modified:
   trunk/libavcodec/vorbis.c
   trunk/libavcodec/vorbis.h
   trunk/libavcodec/vorbis_data.c
   trunk/libavcodec/vorbis_dec.c
   trunk/libavcodec/vorbis_enc.c

Modified: trunk/libavcodec/vorbis.c
==============================================================================
--- trunk/libavcodec/vorbis.c	Mon Sep 28 17:37:18 2009	(r20069)
+++ trunk/libavcodec/vorbis.c	Mon Sep 28 23:13:47 2009	(r20070)
@@ -32,7 +32,9 @@
 
 /* Helper functions */
 
-unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n) {   // x^(1/n)
+// x^(1/n)
+unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n)
+{
     unsigned int ret=0, i, j;
 
     do {
@@ -48,7 +50,8 @@ unsigned int ff_vorbis_nth_root(unsigned
 // the two bits[p] > 32 checks should be redundant, all calling code should
 // already ensure that, but since it allows overwriting the stack it seems
 // reasonable to check redundantly.
-int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num) {
+int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num)
+{
     uint_fast32_t exit_at_level[33]={404,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
@@ -67,16 +70,14 @@ int ff_vorbis_len2vlc(uint8_t *bits, uin
 
     codes[p]=0;
     if (bits[p] > 32) return 1;
-    for(i=0;i<bits[p];++i) {
+    for(i=0;i<bits[p];++i)
         exit_at_level[i+1]=1<<i;
-    }
 
 #ifdef V_DEBUG
     av_log(NULL, AV_LOG_INFO, " %d. of %d code len %d code %d - ", p, num, bits[p], codes[p]);
     init_get_bits(&gb, (uint_fast8_t *)&codes[p], bits[p]);
-    for(i=0;i<bits[p];++i) {
+    for(i=0;i<bits[p];++i)
         av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
-    }
     av_log(NULL, AV_LOG_INFO, "\n");
 #endif
 
@@ -86,24 +87,21 @@ int ff_vorbis_len2vlc(uint8_t *bits, uin
         if (bits[p] > 32) return 1;
         if (bits[p]==0) continue;
         // find corresponding exit(node which the tree can grow further from)
-        for(i=bits[p];i>0;--i) {
+        for(i=bits[p];i>0;--i)
             if (exit_at_level[i]) break;
-        }
         if (!i) return 1; // overspecified tree
         code=exit_at_level[i];
         exit_at_level[i]=0;
         // construct code (append 0s to end) and introduce new exits
-        for(j=i+1;j<=bits[p];++j) {
+        for(j=i+1;j<=bits[p];++j)
             exit_at_level[j]=code+(1<<(j-1));
-        }
         codes[p]=code;
 
 #ifdef V_DEBUG
         av_log(NULL, AV_LOG_INFO, " %d. code len %d code %d - ", p, bits[p], codes[p]);
         init_get_bits(&gb, (uint_fast8_t *)&codes[p], bits[p]);
-        for(i=0;i<bits[p];++i) {
+        for(i=0;i<bits[p];++i)
             av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
-        }
         av_log(NULL, AV_LOG_INFO, "\n");
 #endif
 
@@ -116,7 +114,8 @@ int ff_vorbis_len2vlc(uint8_t *bits, uin
     return 0;
 }
 
-void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) {
+void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values)
+{
     int i;
     list[0].sort = 0;
     list[1].sort = 1;
@@ -146,7 +145,10 @@ void ff_vorbis_ready_floor1_list(vorbis_
     }
 }
 
-static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1, intptr_t sy, int ady, int adx, float * buf) {
+static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1,
+                                        intptr_t sy, int ady, int adx,
+                                        float * buf)
+{
     int err = -adx;
     x -= x1-1;
     buf += x1-1;
@@ -166,7 +168,8 @@ static inline void render_line_unrolled(
     }
 }
 
-static void render_line(int x0, int y0, int x1, int y1, float * buf) {
+static void render_line(int x0, int y0, int x1, int y1, float * buf)
+{
     int dy = y1 - y0;
     int adx = x1 - x0;
     int ady = FFABS(dy);
@@ -192,7 +195,10 @@ static void render_line(int x0, int y0, 
     }
 }
 
-void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) {
+void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
+                                  uint_fast16_t * y_list, int * flag,
+                                  int multiplier, float * out, int samples)
+{
     int lx, ly, i;
     lx = 0;
     ly = y_list[0] * multiplier;

Modified: trunk/libavcodec/vorbis.h
==============================================================================
--- trunk/libavcodec/vorbis.h	Mon Sep 28 17:37:18 2009	(r20069)
+++ trunk/libavcodec/vorbis.h	Mon Sep 28 23:13:47 2009	(r20070)
@@ -36,7 +36,9 @@ typedef struct {
 void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values);
 unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
 int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num);
-void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples);
+void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
+                                  uint_fast16_t * y_list, int * flag,
+                                  int multiplier, float * out, int samples);
 
 #define ilog(i) av_log2(2*(i))
 

Modified: trunk/libavcodec/vorbis_data.c
==============================================================================
--- trunk/libavcodec/vorbis_data.c	Mon Sep 28 17:37:18 2009	(r20069)
+++ trunk/libavcodec/vorbis_data.c	Mon Sep 28 23:13:47 2009	(r20070)
@@ -2152,5 +2152,8 @@ const float ff_vorbis_floor1_inverse_db_
   0.82788260F, 0.88168307F, 0.9389798F, 1.F,
 };
 
-const float * const ff_vorbis_vwin[8] = { vwin64, vwin128, vwin256, vwin512, vwin1024, vwin2048, vwin4096, vwin8192 };
+const float * const ff_vorbis_vwin[8] = {
+      vwin64,  vwin128,  vwin256,  vwin512,
+    vwin1024, vwin2048, vwin4096, vwin8192
+};
 

Modified: trunk/libavcodec/vorbis_dec.c
==============================================================================
--- trunk/libavcodec/vorbis_dec.c	Mon Sep 28 17:37:18 2009	(r20069)
+++ trunk/libavcodec/vorbis_dec.c	Mon Sep 28 23:13:47 2009	(r20070)
@@ -65,10 +65,8 @@ uint_fast8_t (* vorbis_floor_decode_func
 typedef struct {
     uint_fast8_t floor_type;
     vorbis_floor_decode_func decode;
-    union vorbis_floor_u
-    {
-        struct vorbis_floor0_s
-        {
+    union vorbis_floor_u {
+        struct vorbis_floor0_s {
             uint_fast8_t order;
             uint_fast16_t rate;
             uint_fast16_t bark_map_size;
@@ -80,8 +78,7 @@ typedef struct {
             uint_fast8_t * book_list;
             float * lsp;
         } t0;
-        struct vorbis_floor1_s
-        {
+        struct vorbis_floor1_s {
             uint_fast8_t partitions;
             uint_fast8_t maximum_class;
             uint_fast8_t partition_class[32];
@@ -163,17 +160,20 @@ typedef struct vorbis_context_s {
 #define BARK(x) \
     (13.1f*atan(0.00074f*(x))+2.24f*atan(1.85e-8f*(x)*(x))+1e-4f*(x))
 
-static float vorbisfloat2float(uint_fast32_t val) {
+static float vorbisfloat2float(uint_fast32_t val)
+{
     double mant=val&0x1fffff;
     long exp=(val&0x7fe00000L)>>21;
-    if (val&0x80000000) mant=-mant;
+    if (val&0x80000000)
+        mant=-mant;
     return ldexp(mant, exp - 20 - 768);
 }
 
 
 // Free all allocated memory -----------------------------------------
 
-static void vorbis_free(vorbis_context *vc) {
+static void vorbis_free(vorbis_context *vc)
+{
     int_fast16_t i;
 
     av_freep(&vc->channel_residues);
@@ -198,8 +198,7 @@ static void vorbis_free(vorbis_context *
             av_free(vc->floors[i].data.t0.map[1]);
             av_free(vc->floors[i].data.t0.book_list);
             av_free(vc->floors[i].data.t0.lsp);
-        }
-        else {
+        } else {
             av_free(vc->floors[i].data.t1.list);
         }
     }
@@ -217,7 +216,8 @@ static void vorbis_free(vorbis_context *
 
 // Process codebooks part
 
-static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
+{
     uint_fast16_t cb;
     uint8_t *tmp_vlc_bits;
     uint32_t *tmp_vlc_codes;
@@ -275,16 +275,15 @@ static int vorbis_parse_setup_hdr_codebo
                     if (flag) {
                         tmp_vlc_bits[ce]=get_bits(gb, 5)+1;
                         ++used_entries;
-                    }
-                    else tmp_vlc_bits[ce]=0;
+                    } else
+                        tmp_vlc_bits[ce]=0;
                 }
             } else {
                 AV_DEBUG(" not sparse \n");
 
                 used_entries=entries;
-                for(ce=0;ce<entries;++ce) {
+                for(ce=0;ce<entries;++ce)
                     tmp_vlc_bits[ce]=get_bits(gb, 5)+1;
-                }
             }
         } else {
             uint_fast16_t current_entry=0;
@@ -302,9 +301,9 @@ static int vorbis_parse_setup_hdr_codebo
 
                 AV_DEBUG(" number: %d \n", number);
 
-                for(i=current_entry;i<number+current_entry;++i) {
-                    if (i<used_entries) tmp_vlc_bits[i]=current_length;
-                }
+                for(i=current_entry;i<number+current_entry;++i)
+                    if (i<used_entries)
+                        tmp_vlc_bits[i]=current_length;
 
                 current_entry+=number;
             }
@@ -356,18 +355,16 @@ static int vorbis_parse_setup_hdr_codebo
                     for(k=0;k<dim;++k) {
                         uint_fast32_t multiplicand_offset = lookup_offset % codebook_lookup_values;
                         codebook_setup->codevectors[j*dim+k]=codebook_multiplicands[multiplicand_offset]*codebook_delta_value+codebook_minimum_value+last;
-                        if (codebook_sequence_p) {
+                        if (codebook_sequence_p)
                             last=codebook_setup->codevectors[j*dim+k];
-                        }
                         lookup_offset/=codebook_lookup_values;
                     }
                     tmp_vlc_bits[j]=tmp_vlc_bits[i];
 
 #ifdef V_DEBUG
                     av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %d, vector: ", j);
-                    for(k=0;k<dim;++k) {
+                    for(k=0;k<dim;++k)
                         av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j*dim+k]);
-                    }
                     av_log(vc->avccontext, AV_LOG_INFO, "\n");
 #endif
 
@@ -379,8 +376,7 @@ static int vorbis_parse_setup_hdr_codebo
                 goto error;
             }
             entries=used_entries;
-        }
-        else if (codebook_setup->lookup_type>=2) {
+        } else if (codebook_setup->lookup_type>=2) {
             av_log(vc->avccontext, AV_LOG_ERROR, "Codebook lookup type not supported. \n");
             goto error;
         }
@@ -392,10 +388,13 @@ static int vorbis_parse_setup_hdr_codebo
         }
         codebook_setup->maxdepth=0;
         for(t=0;t<entries;++t)
-            if (tmp_vlc_bits[t]>=codebook_setup->maxdepth) codebook_setup->maxdepth=tmp_vlc_bits[t];
+            if (tmp_vlc_bits[t]>=codebook_setup->maxdepth)
+                codebook_setup->maxdepth=tmp_vlc_bits[t];
 
-        if(codebook_setup->maxdepth > 3*V_NB_BITS) codebook_setup->nb_bits=V_NB_BITS2;
-        else                                       codebook_setup->nb_bits=V_NB_BITS;
+        if(codebook_setup->maxdepth > 3*V_NB_BITS)
+            codebook_setup->nb_bits=V_NB_BITS2;
+        else
+            codebook_setup->nb_bits=V_NB_BITS;
 
         codebook_setup->maxdepth=(codebook_setup->maxdepth+codebook_setup->nb_bits-1)/codebook_setup->nb_bits;
 
@@ -418,7 +417,8 @@ error:
 
 // Process time domain transforms part (unused in Vorbis I)
 
-static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t i;
     uint_fast8_t vorbis_time_count=get_bits(gb, 6)+1;
@@ -443,7 +443,8 @@ static uint_fast8_t vorbis_floor0_decode
 static void create_map( vorbis_context * vc, uint_fast8_t floor_number );
 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
                                          vorbis_floor_data *vfu, float *vec);
-static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast16_t i,j,k;
 
@@ -471,7 +472,8 @@ static int vorbis_parse_setup_hdr_floors
 
             for(j=0;j<floor_setup->data.t1.partitions;++j) {
                 floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);
-                if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];
+                if (floor_setup->data.t1.partition_class[j]>maximum_class)
+                    maximum_class=floor_setup->data.t1.partition_class[j];
 
                 AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
 
@@ -513,9 +515,8 @@ static int vorbis_parse_setup_hdr_floors
             floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;
             floor_setup->data.t1.x_list_dim=2;
 
-            for(j=0;j<floor_setup->data.t1.partitions;++j) {
+            for(j=0;j<floor_setup->data.t1.partitions;++j)
                 floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
-            }
 
             floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry));
 
@@ -534,8 +535,7 @@ static int vorbis_parse_setup_hdr_floors
 
 // Precalculate order of x coordinates - needed for decode
             ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
-        }
-        else if(floor_setup->floor_type==0) {
+        } else if(floor_setup->floor_type==0) {
             uint_fast8_t max_codebook_dim=0;
 
             floor_setup->decode=vorbis_floor0_decode;
@@ -557,7 +557,8 @@ static int vorbis_parse_setup_hdr_floors
             /* allocate mem for booklist */
             floor_setup->data.t0.book_list=
                 av_malloc(floor_setup->data.t0.num_books);
-            if(!floor_setup->data.t0.book_list) { return -1; }
+            if(!floor_setup->data.t0.book_list)
+                return -1;
             /* read book indexes */
             {
                 int idx;
@@ -581,7 +582,8 @@ static int vorbis_parse_setup_hdr_floors
                 floor_setup->data.t0.lsp=
                     av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
                               * sizeof(float));
-                if(!floor_setup->data.t0.lsp) { return -1; }
+                if(!floor_setup->data.t0.lsp)
+                    return -1;
             }
 
 #ifdef V_DEBUG /* debug output parsed headers */
@@ -606,8 +608,7 @@ static int vorbis_parse_setup_hdr_floors
               }
             }
 #endif
-        }
-        else {
+        } else {
             av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
             return -1;
         }
@@ -617,7 +618,8 @@ static int vorbis_parse_setup_hdr_floors
 
 // Process residues part
 
-static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){
+static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t i, j, k;
 
@@ -660,9 +662,8 @@ static int vorbis_parse_setup_hdr_residu
         for(j=0;j<res_setup->classifications;++j) {
             high_bits=0;
             low_bits=get_bits(gb, 3);
-            if (get_bits1(gb)) {
+            if (get_bits1(gb))
                 high_bits=get_bits(gb, 5);
-            }
             cascade[j]=(high_bits<<3)+low_bits;
 
             AV_DEBUG("     %d class casscade depth: %d \n", j, ilog(cascade[j]));
@@ -681,9 +682,8 @@ static int vorbis_parse_setup_hdr_residu
 
                     AV_DEBUG("     %d class casscade depth %d book: %d \n", j, k, res_setup->books[j][k]);
 
-                    if (k>res_setup->maxpass) {
+                    if (k>res_setup->maxpass)
                         res_setup->maxpass=k;
-                    }
                 } else {
                     res_setup->books[j][k]=-1;
                 }
@@ -695,7 +695,8 @@ static int vorbis_parse_setup_hdr_residu
 
 // Process mappings part
 
-static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t i, j;
 
@@ -784,8 +785,7 @@ static void create_map( vorbis_context *
     int_fast32_t * map;
     int_fast32_t n; //TODO: could theoretically be smaller?
 
-    for (blockflag=0;blockflag<2;++blockflag)
-    {
+    for (blockflag=0;blockflag<2;++blockflag) {
     n=vc->blocksize[blockflag]/2;
     floors[floor_number].data.t0.map[blockflag]=
         av_malloc((n+1) * sizeof(int_fast32_t)); // n+sentinel
@@ -797,9 +797,8 @@ static void create_map( vorbis_context *
         map[idx]=floor( BARK((vf->rate*idx)/(2.0f*n)) *
                               ((vf->bark_map_size)/
                                BARK(vf->rate/2.0f )) );
-        if (vf->bark_map_size-1 < map[idx]) {
+        if (vf->bark_map_size-1 < map[idx])
             map[idx]=vf->bark_map_size-1;
-        }
     }
     map[n]=-1;
     vf->map_size[blockflag]=n;
@@ -813,7 +812,8 @@ static void create_map( vorbis_context *
 #   endif
 }
 
-static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t i;
 
@@ -841,7 +841,8 @@ static int vorbis_parse_setup_hdr_modes(
 
 // Process the whole setup header using the functions above
 
-static int vorbis_parse_setup_hdr(vorbis_context *vc) {
+static int vorbis_parse_setup_hdr(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
 
     if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||
@@ -885,7 +886,8 @@ static int vorbis_parse_setup_hdr(vorbis
 
 // Process the identification header
 
-static int vorbis_parse_id_hdr(vorbis_context *vc){
+static int vorbis_parse_id_hdr(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t bl0, bl1;
 
@@ -956,7 +958,8 @@ static int vorbis_parse_id_hdr(vorbis_co
 
 // Process the extradata using the functions above (identification header, setup header)
 
-static av_cold int vorbis_decode_init(AVCodecContext *avccontext) {
+static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
+{
     vorbis_context *vc = avccontext->priv_data ;
     uint8_t *headers = avccontext->extradata;
     int headers_len=avccontext->extradata_size;
@@ -1024,7 +1027,8 @@ static av_cold int vorbis_decode_init(AV
 // Read and decode floor
 
 static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
-                                         vorbis_floor_data *vfu, float *vec) {
+                                         vorbis_floor_data *vfu, float *vec)
+{
     vorbis_floor0 * vf=&vfu->t0;
     float * lsp=vf->lsp;
     uint_fast32_t amplitude;
@@ -1061,9 +1065,8 @@ static uint_fast8_t vorbis_floor0_decode
                              codebook.dimensions;
             AV_DEBUG( "floor0 dec: vector offset: %d\n", vec_off );
             /* copy each vector component and add last to it */
-            for (idx=0; idx<codebook.dimensions; ++idx) {
+            for (idx=0; idx<codebook.dimensions; ++idx)
                 lsp[lsp_len+idx]=codebook.codevectors[vec_off+idx]+last;
-            }
             last=lsp[lsp_len+idx-1]; /* set last to last vector component */
 
             lsp_len += codebook.dimensions;
@@ -1083,7 +1086,8 @@ static uint_fast8_t vorbis_floor0_decode
             int order=vf->order;
             float wstep=M_PI/vf->bark_map_size;
 
-            for(i=0;i<order;i++) { lsp[i]=2.0f*cos(lsp[i]); }
+            for(i=0;i<order;i++)
+                lsp[i]=2.0f*cos(lsp[i]);
 
             AV_DEBUG("floor0 synth: map_size=%d; m=%d; wstep=%f\n",
                      vf->map_size, order, wstep);
@@ -1103,8 +1107,7 @@ static uint_fast8_t vorbis_floor0_decode
                 if(j==order) { // even order
                     p *= p*(2.0f-two_cos_w);
                     q *= q*(2.0f+two_cos_w);
-                }
-                else { // odd order
+                } else { // odd order
                     q *= two_cos_w-lsp[j]; // one more time for q
 
                     /* final step and square */
@@ -1122,11 +1125,12 @@ static uint_fast8_t vorbis_floor0_decode
                 }
 
                 /* fill vector */
-                do { vec[i]=q; ++i; }while(vf->map[blockflag][i]==iter_cond);
+                do {
+                    vec[i]=q; ++i;
+                } while (vf->map[blockflag][i]==iter_cond);
             }
         }
-    }
-    else {
+    } else {
         /* this channel is unused */
         return 1;
     }
@@ -1136,7 +1140,9 @@ static uint_fast8_t vorbis_floor0_decode
     return 0;
 }
 
-static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) {
+static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
+                                         vorbis_floor_data *vfu, float *vec)
+{
     vorbis_floor1 * vf=&vfu->t1;
     GetBitContext *gb=&vc->gb;
     uint_fast16_t range_v[4]={ 256, 128, 86, 64 };
@@ -1175,10 +1181,9 @@ static uint_fast8_t vorbis_floor1_decode
 
         AV_DEBUG("Cbits %d \n", cbits);
 
-        if (cbits) { // this reads all subclasses for this partition's class
+        if (cbits) // this reads all subclasses for this partition's class
             cval=get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table,
             vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3);
-        }
 
         for(j=0;j<cdim;++j) {
             book=vf->subclass_books[class_][cval & csub];
@@ -1267,7 +1272,14 @@ static uint_fast8_t vorbis_floor1_decode
 
 // Read and decode residue
 
-static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) {
+static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
+                                                           vorbis_residue *vr,
+                                                           uint_fast8_t ch,
+                                                           uint_fast8_t *do_not_decode,
+                                                           float *vec,
+                                                           uint_fast16_t
+                                                           vlen, int vr_type)
+{
     GetBitContext *gb=&vc->gb;
     uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions;
     uint_fast16_t n_to_read=vr->end-vr->begin;
@@ -1279,10 +1291,10 @@ static av_always_inline int vorbis_resid
     uint_fast16_t k;
 
     if (vr_type==2) {
-        for(j=1;j<ch;++j) {
+        for(j=1;j<ch;++j)
                 do_not_decode[0]&=do_not_decode[j];  // FIXME - clobbering input
-        }
-        if (do_not_decode[0]) return 0;
+        if (do_not_decode[0])
+            return 0;
         ch_used=1;
     } else {
         ch_used=ch;
@@ -1311,9 +1323,8 @@ static av_always_inline int vorbis_resid
                             uint_fast32_t temp2;
 
                             temp2=(((uint_fast64_t)temp) * inverse_class)>>32;
-                            if (partition_count+c_p_c-1-i < ptns_to_read) {
+                            if (partition_count+c_p_c-1-i < ptns_to_read)
                                 classifs[j_times_ptns_to_read+partition_count+c_p_c-1-i]=temp-temp2*vr->classifications;
-                            }
                             temp=temp2;
                         }
                     }
@@ -1340,12 +1351,10 @@ static av_always_inline int vorbis_resid
                                 voffs=voffset+j*vlen;
                                 for(k=0;k<step;++k) {
                                     coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
-                                    for(l=0;l<dim;++l) {
+                                    for(l=0;l<dim;++l)
                                         vec[voffs+k+l*step]+=codebook.codevectors[coffs+l];  // FPMATH
-                                    }
                                 }
-                            }
-                            else if (vr_type==1) {
+                            } else if (vr_type==1) {
                                 voffs=voffset+j*vlen;
                                 for(k=0;k<step;++k) {
                                     coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
@@ -1355,8 +1364,7 @@ static av_always_inline int vorbis_resid
                                         AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d  \n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
                                     }
                                 }
-                            }
-                            else if (vr_type==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) { // most frequent case optimized
+                            } else if (vr_type==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) { // most frequent case optimized
                                 voffs=voffset>>1;
 
                                 if(dim==2) {
@@ -1384,8 +1392,7 @@ static av_always_inline int vorbis_resid
                                     }
                                 }
 
-                            }
-                            else if (vr_type==2) {
+                            } else if (vr_type==2) {
                                 voffs=voffset;
 
                                 for(k=0;k<step;++k) {
@@ -1409,7 +1416,10 @@ static av_always_inline int vorbis_resid
     return 0;
 }
 
-static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen)
+static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
+                                        uint_fast8_t ch,
+                                        uint_fast8_t *do_not_decode,
+                                        float *vec, uint_fast16_t vlen)
 {
     if (vr->type==2)
         return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
@@ -1426,8 +1436,7 @@ static inline int vorbis_residue_decode(
 void vorbis_inverse_coupling(float *mag, float *ang, int blocksize)
 {
     int i;
-    for(i=0; i<blocksize; i++)
-    {
+    for(i=0; i<blocksize; i++) {
         if (mag[i]>0.0) {
             if (ang[i]>0.0) {
                 ang[i]=mag[i]-ang[i];
@@ -1448,7 +1457,8 @@ void vorbis_inverse_coupling(float *mag,
     }
 }
 
-static void copy_normalize(float *dst, float *src, int len, int exp_bias, float add_bias)
+static void copy_normalize(float *dst, float *src, int len, int exp_bias,
+                           float add_bias)
 {
     int i;
     if(exp_bias) {
@@ -1461,7 +1471,8 @@ static void copy_normalize(float *dst, f
 
 // Decode the audio packet using the functions above
 
-static int vorbis_parse_audio_packet(vorbis_context *vc) {
+static int vorbis_parse_audio_packet(vorbis_context *vc)
+{
     GetBitContext *gb=&vc->gb;
 
     uint_fast8_t previous_window=vc->previous_window;
@@ -1500,9 +1511,8 @@ static int vorbis_parse_audio_packet(vor
 
     blockflag=vc->modes[mode_number].blockflag;
     blocksize=vc->blocksize[blockflag];
-    if (blockflag) {
+    if (blockflag)
         skip_bits(gb, 2); // previous_window, next_window
-    }
 
     memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
     memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
@@ -1616,9 +1626,8 @@ static int vorbis_decode_frame(AVCodecCo
 
     int_fast16_t len;
 
-    if(!buf_size){
+    if(!buf_size)
         return 0;
-    }
 
     AV_DEBUG("packet length %d \n", buf_size);
 
@@ -1649,7 +1658,8 @@ static int vorbis_decode_frame(AVCodecCo
 
 // Close decoder
 
-static av_cold int vorbis_decode_close(AVCodecContext *avccontext) {
+static av_cold int vorbis_decode_close(AVCodecContext *avccontext)
+{
     vorbis_context *vc = avccontext->priv_data;
 
     vorbis_free(vc);

Modified: trunk/libavcodec/vorbis_enc.c
==============================================================================
--- trunk/libavcodec/vorbis_enc.c	Mon Sep 28 17:37:18 2009	(r20069)
+++ trunk/libavcodec/vorbis_enc.c	Mon Sep 28 23:13:47 2009	(r20070)
@@ -125,20 +125,26 @@ typedef struct {
     int64_t sample_count;
 } vorbis_enc_context;
 
-static inline void put_codeword(PutBitContext * pb, vorbis_enc_codebook * cb, int entry) {
+static inline void put_codeword(PutBitContext * pb, vorbis_enc_codebook * cb,
+                                int entry)
+{
     assert(entry >= 0);
     assert(entry < cb->nentries);
     assert(cb->lens[entry]);
     put_bits(pb, cb->lens[entry], cb->codewords[entry]);
 }
 
-static int cb_lookup_vals(int lookup, int dimentions, int entries) {
-    if      (lookup == 1) return ff_vorbis_nth_root(entries, dimentions);
-    else if (lookup == 2) return dimentions * entries;
+static int cb_lookup_vals(int lookup, int dimentions, int entries)
+{
+    if (lookup == 1)
+        return ff_vorbis_nth_root(entries, dimentions);
+    else if (lookup == 2)
+        return dimentions * entries;
     return 0;
 }
 
-static void ready_codebook(vorbis_enc_codebook * cb) {
+static void ready_codebook(vorbis_enc_codebook * cb)
+{
     int i;
 
     ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries);
@@ -171,7 +177,8 @@ static void ready_codebook(vorbis_enc_co
     }
 }
 
-static void ready_residue(vorbis_enc_residue * rc, vorbis_enc_context * venc) {
+static void ready_residue(vorbis_enc_residue * rc, vorbis_enc_context * venc)
+{
     int i;
     assert(rc->type == 2);
     rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications);
@@ -179,15 +186,18 @@ static void ready_residue(vorbis_enc_res
         int j;
         vorbis_enc_codebook * cb;
         for (j = 0; j < 8; j++)
-            if (rc->books[i][j] != -1) break;
-        if (j == 8) continue; // zero
+            if (rc->books[i][j] != -1)
+                break;
+        if (j == 8)
+            continue; // zero
         cb = &venc->codebooks[rc->books[i][j]];
         assert(cb->ndimentions >= 2);
         assert(cb->lookup);
 
         for (j = 0; j < cb->nentries; j++) {
             float a;
-            if (!cb->lens[j]) continue;
+            if (!cb->lens[j])
+                continue;
             a = fabs(cb->dimentions[j * cb->ndimentions]);
             if (a > rc->maxes[i][0])
                 rc->maxes[i][0] = a;
@@ -203,7 +213,9 @@ static void ready_residue(vorbis_enc_res
     }
 }
 
-static void create_vorbis_context(vorbis_enc_context * venc, AVCodecContext * avccontext) {
+static void create_vorbis_context(vorbis_enc_context * venc,
+                                  AVCodecContext * avccontext)
+{
     vorbis_enc_floor * fc;
     vorbis_enc_residue * rc;
     vorbis_enc_mapping * mc;
@@ -363,17 +375,22 @@ static void create_vorbis_context(vorbis
     ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0);
 }
 
-static void put_float(PutBitContext * pb, float f) {
+static void put_float(PutBitContext * pb, float f)
+{
     int exp, mant;
     uint32_t res = 0;
     mant = (int)ldexp(frexp(f, &exp), 20);
     exp += 788 - 20;
-    if (mant < 0) { res |= (1 << 31); mant = -mant; }
+    if (mant < 0) {
+        res |= (1 << 31);
+        mant = -mant;
+    }
     res |= mant | (exp << 21);
     put_bits(pb, 32, res);
 }
 
-static void put_codebook_header(PutBitContext * pb, vorbis_enc_codebook * cb) {
+static void put_codebook_header(PutBitContext * pb, vorbis_enc_codebook * cb)
+{
     int i;
     int ordered = 0;
 
@@ -382,7 +399,8 @@ static void put_codebook_header(PutBitCo
     put_bits(pb, 24, cb->nentries);
 
     for (i = 1; i < cb->nentries; i++)
-        if (cb->lens[i] < cb->lens[i-1]) break;
+        if (cb->lens[i] < cb->lens[i-1])
+            break;
     if (i == cb->nentries)
         ordered = 1;
 
@@ -394,7 +412,8 @@ static void put_codebook_header(PutBitCo
         while (i < cb->nentries) {
             int j;
             for (j = 0; j+i < cb->nentries; j++)
-                if (cb->lens[j+i] != len) break;
+                if (cb->lens[j+i] != len)
+                    break;
             put_bits(pb, ilog(cb->nentries - i), j);
             i += j;
             len++;
@@ -402,14 +421,17 @@ static void put_codebook_header(PutBitCo
     } else {
         int sparse = 0;
         for (i = 0; i < cb->nentries; i++)
-            if (!cb->lens[i]) break;
+            if (!cb->lens[i])
+                break;
         if (i != cb->nentries)
             sparse = 1;
         put_bits(pb, 1, sparse);
 
         for (i = 0; i < cb->nentries; i++) {
-            if (sparse) put_bits(pb, 1, !!cb->lens[i]);
-            if (cb->lens[i]) put_bits(pb, 5, cb->lens[i] - 1);
+            if (sparse)
+                put_bits(pb, 1, !!cb->lens[i]);
+            if (cb->lens[i])
+                put_bits(pb, 5, cb->lens[i] - 1);
         }
     }
 
@@ -432,7 +454,8 @@ static void put_codebook_header(PutBitCo
     }
 }
 
-static void put_floor_header(PutBitContext * pb, vorbis_enc_floor * fc) {
+static void put_floor_header(PutBitContext * pb, vorbis_enc_floor * fc)
+{
     int i;
 
     put_bits(pb, 16, 1); // type, only floor1 is supported
@@ -464,7 +487,8 @@ static void put_floor_header(PutBitConte
         put_bits(pb, fc->rangebits, fc->list[i].x);
 }
 
-static void put_residue_header(PutBitContext * pb, vorbis_enc_residue * rc) {
+static void put_residue_header(PutBitContext * pb, vorbis_enc_residue * rc)
+{
     int i;
 
     put_bits(pb, 16, rc->type);
@@ -495,7 +519,8 @@ static void put_residue_header(PutBitCon
     }
 }
 
-static int put_main_header(vorbis_enc_context * venc, uint8_t ** out) {
+static int put_main_header(vorbis_enc_context * venc, uint8_t ** out)
+{
     int i;
     PutBitContext pb;
     uint8_t buffer[50000] = {0}, * p = buffer;
@@ -624,7 +649,8 @@ static int put_main_header(vorbis_enc_co
     return p - *out;
 }
 
-static float get_floor_average(vorbis_enc_floor * fc, float * coeffs, int i) {
+static float get_floor_average(vorbis_enc_floor * fc, float * coeffs, int i)
+{
     int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
     int end   = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
     int j;
@@ -635,7 +661,9 @@ static float get_floor_average(vorbis_en
     return average / (end - begin);
 }
 
-static void floor_fit(vorbis_enc_context * venc, vorbis_enc_floor * fc, float * coeffs, uint_fast16_t * posts, int samples) {
+static void floor_fit(vorbis_enc_context * venc, vorbis_enc_floor * fc,
+                      float * coeffs, uint_fast16_t * posts, int samples)
+{
     int range = 255 / fc->multiplier + 1;
     int i;
     float tot_average = 0.;
@@ -654,16 +682,21 @@ static void floor_fit(vorbis_enc_context
 
         average *= pow(tot_average / average, 0.5) * pow(1.25, position/200.); // MAGIC!
         for (j = 0; j < range - 1; j++)
-            if (ff_vorbis_floor1_inverse_db_table[j * fc->multiplier] > average) break;
+            if (ff_vorbis_floor1_inverse_db_table[j * fc->multiplier] > average)
+                break;
         posts[fc->list[i].sort] = j;
     }
 }
 
-static int render_point(int x0, int y0, int x1, int y1, int x) {
+static int render_point(int x0, int y0, int x1, int y1, int x)
+{
     return y0 +  (x - x0) * (y1 - y0) / (x1 - x0);
 }
 
-static void floor_encode(vorbis_enc_context * venc, vorbis_enc_floor * fc, PutBitContext * pb, uint_fast16_t * posts, float * floor, int samples) {
+static void floor_encode(vorbis_enc_context * venc, vorbis_enc_floor * fc,
+                         PutBitContext * pb, uint_fast16_t * posts,
+                         float * floor, int samples)
+{
     int range = 255 / fc->multiplier + 1;
     int coded[fc->values]; // first 2 values are unused
     int i, counter;
@@ -686,8 +719,10 @@ static void floor_encode(vorbis_enc_cont
             coded[i] = 0; // must be used later as flag!
             continue;
         } else {
-            if (!coded[fc->list[i].low ]) coded[fc->list[i].low ] = -1;
-            if (!coded[fc->list[i].high]) coded[fc->list[i].high] = -1;
+            if (!coded[fc->list[i].low ])
+                coded[fc->list[i].low ] = -1;
+            if (!coded[fc->list[i].high])
+                coded[fc->list[i].high] = -1;
         }
         if (posts[i] > predicted) {
             if (posts[i] - predicted > room)
@@ -716,7 +751,8 @@ static void floor_encode(vorbis_enc_cont
                     if (c->books[l] != -1)
                         maxval = venc->codebooks[c->books[l]].nentries;
                     // coded could be -1, but this still works, cause that is 0
-                    if (coded[counter + k] < maxval) break;
+                    if (coded[counter + k] < maxval)
+                        break;
                 }
                 assert(l != csub);
                 cval |= l << cshift;
@@ -728,8 +764,10 @@ static void floor_encode(vorbis_enc_cont
             int book = c->books[cval & (csub-1)];
             int entry = coded[counter++];
             cval >>= c->subclass;
-            if (book == -1) continue;
-            if (entry == -1) entry = 0;
+            if (book == -1)
+                continue;
+            if (entry == -1)
+                entry = 0;
             put_codeword(pb, &venc->codebooks[book], entry);
         }
     }
@@ -737,14 +775,16 @@ static void floor_encode(vorbis_enc_cont
     ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded, fc->multiplier, floor, samples);
 }
 
-static float * put_vector(vorbis_enc_codebook * book, PutBitContext * pb, float * num) {
+static float * put_vector(vorbis_enc_codebook * book, PutBitContext * pb, float * num)
+{
     int i, entry = -1;
     float distance = FLT_MAX;
     assert(book->dimentions);
     for (i = 0; i < book->nentries; i++) {
         float * vec = book->dimentions + i * book->ndimentions, d = book->pow2[i];
         int j;
-        if (!book->lens[i]) continue;
+        if (!book->lens[i])
+            continue;
         for (j = 0; j < book->ndimentions; j++)
             d -= vec[j] * num[j];
         if (distance > d) {
@@ -756,7 +796,10 @@ static float * put_vector(vorbis_enc_cod
     return &book->dimentions[entry * book->ndimentions];
 }
 
-static void residue_encode(vorbis_enc_context * venc, vorbis_enc_residue * rc, PutBitContext * pb, float * coeffs, int samples, int real_ch) {
+static void residue_encode(vorbis_enc_context * venc, vorbis_enc_residue * rc,
+                           PutBitContext * pb, float * coeffs, int samples,
+                           int real_ch)
+{
     int pass, i, j, p, k;
     int psize = rc->partition_size;
     int partitions = (rc->end - rc->begin) / psize;
@@ -774,9 +817,9 @@ static void residue_encode(vorbis_enc_co
             max2 = FFMAX(max2, fabs(coeffs[samples + k / real_ch]));
         }
 
-        for (i = 0; i < rc->classifications - 1; i++) {
-            if (max1 < rc->maxes[i][0] && max2 < rc->maxes[i][1]) break;
-        }
+        for (i = 0; i < rc->classifications - 1; i++)
+            if (max1 < rc->maxes[i][0] && max2 < rc->maxes[i][1])
+                break;
         classes[0][p] = i;
     }
 
@@ -798,7 +841,8 @@ static void residue_encode(vorbis_enc_co
                     int nbook = rc->books[classes[j][p]][pass];
                     vorbis_enc_codebook * book = &venc->codebooks[nbook];
                     float * buf = coeffs + samples*j + rc->begin + p*psize;
-                    if (nbook == -1) continue;
+                    if (nbook == -1)
+                        continue;
 
                     assert(rc->type == 0 || rc->type == 2);
                     assert(!(psize % book->ndimentions));
@@ -841,7 +885,9 @@ static void residue_encode(vorbis_enc_co
     }
 }
 
-static int apply_window_and_mdct(vorbis_enc_context * venc, signed short * audio, int samples) {
+static int apply_window_and_mdct(vorbis_enc_context * venc,
+                                 signed short * audio, int samples)
+{
     int i, j, channel;
     const float * win = venc->win[0];
     int window_len = 1 << (venc->log2_blocksize[0] - 1);
@@ -850,15 +896,12 @@ static int apply_window_and_mdct(vorbis_
 
     if (!venc->have_saved && !samples) return 0;
 
-    if (venc->have_saved) {
-        for (channel = 0; channel < venc->channels; channel++) {
+    if (venc->have_saved)
+        for (channel = 0; channel < venc->channels; channel++)
             memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len);
-        }
-    } else {
-        for (channel = 0; channel < venc->channels; channel++) {
+    else
+        for (channel = 0; channel < venc->channels; channel++)
             memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);
-        }
-    }
 
     if (samples) {
         for (channel = 0; channel < venc->channels; channel++) {
@@ -868,14 +911,12 @@ static int apply_window_and_mdct(vorbis_
                 offset[i] = -audio[j] / 32768. / n * win[window_len - i - 1]; //FIXME find out why the sign has to be fliped
         }
     } else {
-        for (channel = 0; channel < venc->channels; channel++) {
+        for (channel = 0; channel < venc->channels; channel++)
             memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len);
-        }
     }
 
-    for (channel = 0; channel < venc->channels; channel++) {
+    for (channel = 0; channel < venc->channels; channel++)
         ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2);
-    }
 
     if (samples) {
         for (channel = 0; channel < venc->channels; channel++) {
@@ -928,7 +969,8 @@ static int vorbis_encode_frame(AVCodecCo
     PutBitContext pb;
     int i;
 
-    if (!apply_window_and_mdct(venc, audio, samples)) return 0;
+    if (!apply_window_and_mdct(venc, audio, samples))
+        return 0;
     samples = 1 << (venc->log2_blocksize[0] - 1);
 
     init_put_bits(&pb, packets, buf_size);
@@ -951,9 +993,8 @@ static int vorbis_encode_frame(AVCodecCo
         floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
     }
 
-    for (i = 0; i < venc->channels * samples; i++) {
+    for (i = 0; i < venc->channels * samples; i++)
         venc->coeffs[i] /= venc->floor[i];
-    }
 
     for (i = 0; i < mapping->coupling_steps; i++) {
         float * mag = venc->coeffs + mapping->magnitude[i] * samples;
@@ -962,8 +1003,10 @@ static int vorbis_encode_frame(AVCodecCo
         for (j = 0; j < samples; j++) {
             float a = ang[j];
             ang[j] -= mag[j];
-            if (mag[j] > 0) ang[j] = -ang[j];
-            if (ang[j] < 0) mag[j] = a;
+            if (mag[j] > 0)
+                ang[j] = -ang[j];
+            if (ang[j] < 0)
+                mag[j] = a;
         }
     }
 



More information about the ffmpeg-cvslog mailing list