]> git.sesse.net Git - vlc/commitdiff
speex: remove tabs and trailing spaces
authorLudovic Fauvet <etix@videolan.org>
Sat, 8 Sep 2012 12:52:06 +0000 (14:52 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 8 Sep 2012 15:45:07 +0000 (17:45 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/speex.c

index 67d0b00a0b59ba7bfd79d4bb3eaed99bf123d462..019f6005ec8990d4fed3e2ae78f4542be9567e1b 100644 (file)
@@ -224,14 +224,14 @@ static int OpenDecoder( vlc_object_t *p_this )
 
     /*
       Set callbacks
-      If the codec is spxr then this decoder is 
-      being invoked on a Speex stream arriving via RTP. 
+      If the codec is spxr then this decoder is
+      being invoked on a Speex stream arriving via RTP.
       A special decoder callback is used.
     */
     if (p_dec->fmt_in.i_original_fourcc == VLC_FOURCC('s', 'p', 'x', 'r'))
     {
-        msg_Dbg( p_dec, "Using RTP version of Speex decoder @ rate %d.", 
-           p_dec->fmt_in.audio.i_rate );
+        msg_Dbg( p_dec, "Using RTP version of Speex decoder @ rate %d.",
+        p_dec->fmt_in.audio.i_rate );
         p_dec->pf_decode_audio = DecodeRtpSpeexPacket;
     }
     else
@@ -484,74 +484,74 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
 
     if( p_sys->b_packetizer )
     {
-       if ( p_sys->p_header->frames_per_packet > 1 )
-       {
-           short *p_frame_holder = NULL;
-           int i_bits_before = 0, i_bits_after = 0, i_bytes_in_speex_frame = 0,
-               i_pcm_output_size = 0, i_bits_in_speex_frame = 0;
-           block_t *p_new_block = NULL;
-
-           i_pcm_output_size = p_sys->p_header->frame_size;
-           p_frame_holder = (short*)xmalloc( sizeof(short)*i_pcm_output_size );
-
-            speex_bits_read_from( &p_sys->bits, (char*)p_oggpacket->packet,
-               p_oggpacket->bytes);
-            i_bits_before = speex_bits_remaining( &p_sys->bits );
-           speex_decode_int(p_sys->p_state, &p_sys->bits, p_frame_holder);
-           i_bits_after = speex_bits_remaining( &p_sys->bits );
-
-            i_bits_in_speex_frame = i_bits_before - i_bits_after;
-           i_bytes_in_speex_frame = ( i_bits_in_speex_frame + 
-               (8 - (i_bits_in_speex_frame % 8)) )
-                / 8;
-
-            p_new_block = block_New( p_dec, i_bytes_in_speex_frame );
-           memset( p_new_block->p_buffer, 0xff, i_bytes_in_speex_frame );
-
-           /*
-            * Copy the first frame in this packet to a new packet.
-            */
-           speex_bits_rewind( &p_sys->bits );
-           speex_bits_write( &p_sys->bits, 
-               (char*)p_new_block->p_buffer, 
-                   (int)i_bytes_in_speex_frame );
-
-           /*
-            * Move the remaining part of the original packet (subsequent
-            * frames, if there are any) into the beginning 
-            * of the original packet so
-            * they are preserved following the realloc. 
-            * Note: Any bits that
-            * remain in the initial packet
-            * are "filler" if they do not constitute
-            * an entire byte. 
-            */
-           if ( i_bits_after > 7 )
-           {
-               /* round-down since we rounded-up earlier (to include
-                * the speex terminator code. 
-                */
-               i_bytes_in_speex_frame--;
-               speex_bits_write( &p_sys->bits, 
-                       (char*)p_block->p_buffer, 
-                       p_block->i_buffer - i_bytes_in_speex_frame );
-            p_block = block_Realloc( p_block, 
-                   0, 
-                       p_block->i_buffer-i_bytes_in_speex_frame );
-               *pp_block = p_block;
-           }
-           else
-           {
-               speex_bits_reset( &p_sys->bits );
-           }
-
-           free( p_frame_holder );
-           return SendPacket( p_dec, p_new_block);
-       }
-       else
-       {
-            return SendPacket( p_dec, p_block );
-       }
+        if ( p_sys->p_header->frames_per_packet > 1 )
+        {
+            short *p_frame_holder = NULL;
+            int i_bits_before = 0, i_bits_after = 0, i_bytes_in_speex_frame = 0,
+                i_pcm_output_size = 0, i_bits_in_speex_frame = 0;
+            block_t *p_new_block = NULL;
+
+            i_pcm_output_size = p_sys->p_header->frame_size;
+            p_frame_holder = (short*)xmalloc( sizeof(short)*i_pcm_output_size );
+
+                speex_bits_read_from( &p_sys->bits, (char*)p_oggpacket->packet,
+                p_oggpacket->bytes);
+                i_bits_before = speex_bits_remaining( &p_sys->bits );
+            speex_decode_int(p_sys->p_state, &p_sys->bits, p_frame_holder);
+            i_bits_after = speex_bits_remaining( &p_sys->bits );
+
+                i_bits_in_speex_frame = i_bits_before - i_bits_after;
+            i_bytes_in_speex_frame = ( i_bits_in_speex_frame +
+                (8 - (i_bits_in_speex_frame % 8)) )
+                    / 8;
+
+                p_new_block = block_New( p_dec, i_bytes_in_speex_frame );
+            memset( p_new_block->p_buffer, 0xff, i_bytes_in_speex_frame );
+
+            /*
+             * Copy the first frame in this packet to a new packet.
+             */
+            speex_bits_rewind( &p_sys->bits );
+            speex_bits_write( &p_sys->bits,
+                (char*)p_new_block->p_buffer,
+                (int)i_bytes_in_speex_frame );
+
+            /*
+             * Move the remaining part of the original packet (subsequent
+             * frames, if there are any) into the beginning
+             * of the original packet so
+             * they are preserved following the realloc.
+             * Note: Any bits that
+             * remain in the initial packet
+             * are "filler" if they do not constitute
+             * an entire byte.
+             */
+            if ( i_bits_after > 7 )
+            {
+                /* round-down since we rounded-up earlier (to include
+             * the speex terminator code.
+             */
+                i_bytes_in_speex_frame--;
+                speex_bits_write( &p_sys->bits,
+                    (char*)p_block->p_buffer,
+                    p_block->i_buffer - i_bytes_in_speex_frame );
+                p_block = block_Realloc( p_block,
+                    0,
+                    p_block->i_buffer-i_bytes_in_speex_frame );
+                *pp_block = p_block;
+            }
+            else
+            {
+                speex_bits_reset( &p_sys->bits );
+            }
+
+            free( p_frame_holder );
+            return SendPacket( p_dec, p_new_block);
+        }
+        else
+        {
+                return SendPacket( p_dec, p_block );
+        }
     }
     else
     {
@@ -574,63 +574,63 @@ static block_t *DecodeRtpSpeexPacket( decoder_t *p_dec, block_t **pp_block )
     if ( !p_speex_bit_block || p_speex_bit_block->i_pts <= VLC_TS_INVALID )
         return NULL;
 
-    /* 
+    /*
       If the SpeexBits buffer size is 0 (a default value),
       we know that a proper initialization has not yet been done.
     */
     if ( p_sys->bits.buf_size==0 )
     {
-       p_sys->p_header = (SpeexHeader *)malloc(sizeof(SpeexHeader));
-       if ( !p_sys->p_header )
-       {
-           msg_Err( p_dec, "Could not allocate a Speex header.");
-           return NULL;
-       }
-       speex_init_header( p_sys->p_header,p_sys->rtp_rate,1,&speex_nb_mode );
-        speex_bits_init( &p_sys->bits );
-       p_sys->p_state = speex_decoder_init( &speex_nb_mode );
-       if ( !p_sys->p_state )
-       {
-           msg_Err( p_dec, "Could not allocate a Speex decoder." );
-           free( p_sys->p_header );
-           return NULL;
-       }
-
-        /*
-         Assume that variable bit rate is enabled. Also assume
-         that there is only one frame per packet. 
-       */
-       p_sys->p_header->vbr = 1;
-       p_sys->p_header->frames_per_packet = 1;
-
-        p_dec->fmt_out.audio.i_channels = p_sys->p_header->nb_channels;
-       p_dec->fmt_out.audio.i_physical_channels = 
-       p_dec->fmt_out.audio.i_original_channels = 
-           pi_channels_maps[p_sys->p_header->nb_channels];
-        p_dec->fmt_out.audio.i_rate = p_sys->p_header->rate;
-
-        if ( speex_mode_query( &speex_nb_mode, 
-           SPEEX_MODE_FRAME_SIZE, 
-           &i_speex_frame_size ) )
-       {
-           msg_Err( p_dec, "Could not determine the frame size." );
-           speex_decoder_destroy( p_sys->p_state );
-           free( p_sys->p_header );
-           return NULL;
-       }
-       p_dec->fmt_out.audio.i_bytes_per_frame = i_speex_frame_size;
-
-       date_Init(&p_sys->end_date, p_sys->p_header->rate, 1);
+        p_sys->p_header = (SpeexHeader *)malloc(sizeof(SpeexHeader));
+        if ( !p_sys->p_header )
+        {
+            msg_Err( p_dec, "Could not allocate a Speex header.");
+            return NULL;
+        }
+        speex_init_header( p_sys->p_header,p_sys->rtp_rate,1,&speex_nb_mode );
+            speex_bits_init( &p_sys->bits );
+        p_sys->p_state = speex_decoder_init( &speex_nb_mode );
+        if ( !p_sys->p_state )
+        {
+            msg_Err( p_dec, "Could not allocate a Speex decoder." );
+            free( p_sys->p_header );
+            return NULL;
+        }
+
+            /*
+          Assume that variable bit rate is enabled. Also assume
+          that there is only one frame per packet.
+        */
+        p_sys->p_header->vbr = 1;
+        p_sys->p_header->frames_per_packet = 1;
+
+            p_dec->fmt_out.audio.i_channels = p_sys->p_header->nb_channels;
+        p_dec->fmt_out.audio.i_physical_channels =
+        p_dec->fmt_out.audio.i_original_channels =
+            pi_channels_maps[p_sys->p_header->nb_channels];
+            p_dec->fmt_out.audio.i_rate = p_sys->p_header->rate;
+
+            if ( speex_mode_query( &speex_nb_mode,
+            SPEEX_MODE_FRAME_SIZE,
+            &i_speex_frame_size ) )
+        {
+            msg_Err( p_dec, "Could not determine the frame size." );
+            speex_decoder_destroy( p_sys->p_state );
+            free( p_sys->p_header );
+            return NULL;
+        }
+        p_dec->fmt_out.audio.i_bytes_per_frame = i_speex_frame_size;
+
+        date_Init(&p_sys->end_date, p_sys->p_header->rate, 1);
     }
 
-    /* 
-      If the SpeexBits are initialized but there is 
+    /*
+      If the SpeexBits are initialized but there is
       still no header, an error must be thrown.
     */
     if ( !p_sys->p_header )
     {
         msg_Err( p_dec, "There is no valid Speex header found." );
-       return NULL;
+        return NULL;
     }
     *pp_block = NULL;
 
@@ -639,43 +639,43 @@ static block_t *DecodeRtpSpeexPacket( decoder_t *p_dec, block_t **pp_block )
 
     /*
       Ask for a new audio output buffer and make sure
-      we get one. 
+      we get one.
     */
-    p_aout_buffer = decoder_NewAudioBuffer( p_dec, 
+    p_aout_buffer = decoder_NewAudioBuffer( p_dec,
         p_sys->p_header->frame_size );
     if ( !p_aout_buffer || p_aout_buffer->i_buffer == 0 )
     {
         msg_Err(p_dec, "Oops: No new buffer was returned!");
-       return NULL;
+        return NULL;
     }
 
     /*
       Read the Speex payload into the SpeexBits buffer.
     */
-    speex_bits_read_from( &p_sys->bits, 
-        (char*)p_speex_bit_block->p_buffer, 
+    speex_bits_read_from( &p_sys->bits,
+        (char*)p_speex_bit_block->p_buffer,
         p_speex_bit_block->i_buffer );
-    
-    /* 
-      Decode the input and ensure that no errors 
+
+    /*
+      Decode the input and ensure that no errors
       were encountered.
     */
-    i_decode_ret = speex_decode_int( p_sys->p_state, &p_sys->bits, 
+    i_decode_ret = speex_decode_int( p_sys->p_state, &p_sys->bits,
             (int16_t*)p_aout_buffer->p_buffer );
     if ( i_decode_ret < 0 )
     {
         msg_Err( p_dec, "Decoding failed. Perhaps we have a bad stream?" );
-       return NULL;
+        return NULL;
     }
 
-    /* 
-      Handle date management on the audio output buffer. 
+    /*
+      Handle date management on the audio output buffer.
     */
     p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
     p_aout_buffer->i_length = date_Increment( &p_sys->end_date,
         p_sys->p_header->frame_size ) - p_aout_buffer->i_pts;
-    
-    
+
+
     p_sys->i_frame_in_packet++;
     block_Release( p_speex_bit_block );