changeset 3859:0d0bd4b2baef libavcodec

Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines cosmetic, reorganize
author ods15
date Mon, 02 Oct 2006 06:07:44 +0000
parents 70b4bc721531
children be0344cea4ea
files vorbis_enc.c
diffstat 1 files changed, 69 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/vorbis_enc.c	Mon Oct 02 06:07:42 2006 +0000
+++ b/vorbis_enc.c	Mon Oct 02 06:07:44 2006 +0000
@@ -598,75 +598,6 @@
     return p - *out;
 }
 
-static int vorbis_encode_init(AVCodecContext * avccontext)
-{
-    venc_context_t * venc = avccontext->priv_data;
-
-    create_vorbis_context(venc, avccontext);
-
-    //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
-    //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
-
-    avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
-
-    avccontext->frame_size = 1 << (venc->blocksize[0] - 1);
-
-    avccontext->coded_frame = avcodec_alloc_frame();
-    avccontext->coded_frame->key_frame = 1;
-
-    return 0;
-}
-
-static int window(venc_context_t * venc, signed short * audio, int samples) {
-    int i, j, channel;
-    const float * win = venc->win[0];
-    int window_len = 1 << (venc->blocksize[0] - 1);
-    float n = (float)(1 << venc->blocksize[0]) / 4.;
-    // FIXME use dsp
-
-    if (!venc->have_saved && !samples) return 0;
-
-    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++) {
-            memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);
-        }
-    }
-
-    if (samples) {
-        for (channel = 0; channel < venc->channels; channel++) {
-            float * offset = venc->samples + channel*window_len*2 + window_len;
-            j = channel;
-            for (i = 0; i < samples; i++, j += venc->channels)
-                offset[i] = audio[j] / 32768. * win[window_len - i] / n;
-        }
-    } else {
-        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++) {
-        ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/);
-    }
-
-    if (samples) {
-        for (channel = 0; channel < venc->channels; channel++) {
-            float * offset = venc->saved + channel*window_len;
-            j = channel;
-            for (i = 0; i < samples; i++, j += venc->channels)
-                offset[i] = audio[j] / 32768. * win[i] / n;
-        }
-        venc->have_saved = 1;
-    } else {
-        venc->have_saved = 0;
-    }
-    return 1;
-}
-
 static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) {
     int i;
     int entry = -1;
@@ -728,6 +659,75 @@
     }
 }
 
+static int window(venc_context_t * venc, signed short * audio, int samples) {
+    int i, j, channel;
+    const float * win = venc->win[0];
+    int window_len = 1 << (venc->blocksize[0] - 1);
+    float n = (float)(1 << venc->blocksize[0]) / 4.;
+    // FIXME use dsp
+
+    if (!venc->have_saved && !samples) return 0;
+
+    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++) {
+            memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);
+        }
+    }
+
+    if (samples) {
+        for (channel = 0; channel < venc->channels; channel++) {
+            float * offset = venc->samples + channel*window_len*2 + window_len;
+            j = channel;
+            for (i = 0; i < samples; i++, j += venc->channels)
+                offset[i] = audio[j] / 32768. * win[window_len - i] / n;
+        }
+    } else {
+        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++) {
+        ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/);
+    }
+
+    if (samples) {
+        for (channel = 0; channel < venc->channels; channel++) {
+            float * offset = venc->saved + channel*window_len;
+            j = channel;
+            for (i = 0; i < samples; i++, j += venc->channels)
+                offset[i] = audio[j] / 32768. * win[i] / n;
+        }
+        venc->have_saved = 1;
+    } else {
+        venc->have_saved = 0;
+    }
+    return 1;
+}
+
+static int vorbis_encode_init(AVCodecContext * avccontext)
+{
+    venc_context_t * venc = avccontext->priv_data;
+
+    create_vorbis_context(venc, avccontext);
+
+    //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
+    //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
+
+    avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
+
+    avccontext->frame_size = 1 << (venc->blocksize[0] - 1);
+
+    avccontext->coded_frame = avcodec_alloc_frame();
+    avccontext->coded_frame->key_frame = 1;
+
+    return 0;
+}
+
 static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data)
 {
     venc_context_t * venc = avccontext->priv_data;