[Ffmpeg-devel] [PATCH] vorbis.h -> vorbis_data.c

Oded Shimon ods15
Sat Sep 30 17:16:13 CEST 2006


On Sat, Sep 30, 2006 at 06:09:02PM +0300, Oded Shimon wrote:
> It would be silly for me to send this as a patch, because it's an almost 
> completely unreadable ~260kb patch. These are the changes to be made:
> 
> 1. the attached patch, for Makefile and vorbis.c
> 2. vorbis.h would be changed to what is attached below
> 3. vorbis_data.c would be svn-cp'ed from vorbis.h, having the 
> struct/typedefs removed, and a single line added:
> 
> const float * ff_vorbis_vwin[8] = { vwin64, vwin128, vwin256, vwin512, vwin1024, vwin2048, vwin4096, vwin8192 };
> 
> 
> I'll commit tommorrow, this is first step for me making vorbis_enc clean 
> enough to commit to lavc...

- ods15
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vorbis.h
Type: text/x-chdr
Size: 957 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060930/49725991/attachment.h>
-------------- next part --------------
Index: Makefile
===================================================================
--- Makefile	(revision 6260)
+++ Makefile	(working copy)
@@ -121,7 +121,7 @@
 OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdav.o
 OBJS-$(CONFIG_VMDVIDEO_DECODER)        += vmdav.o
 OBJS-$(CONFIG_VMNC_DECODER)            += vmnc.o
-OBJS-$(CONFIG_VORBIS_DECODER)          += vorbis.o
+OBJS-$(CONFIG_VORBIS_DECODER)          += vorbis.o vorbis_data.o
 OBJS-$(CONFIG_VP3_DECODER)             += vp3.o
 OBJS-$(CONFIG_VP5_DECODER)             += vp5.o vp56.o vp56data.o
 OBJS-$(CONFIG_VP6_DECODER)             += vp6.o vp56.o vp56data.o
Index: vorbis.c
===================================================================
--- vorbis.c	(revision 6328)
+++ vorbis.c	(working copy)
@@ -43,6 +43,124 @@
 #undef NDEBUG
 #include <assert.h>
 
+typedef struct {
+    uint_fast8_t dimensions;
+    uint_fast8_t lookup_type;
+    uint_fast8_t maxdepth;
+    VLC vlc;
+    float *codevectors;
+    unsigned int nb_bits;
+} vorbis_codebook;
+
+typedef union vorbis_floor_u vorbis_floor_data;
+typedef struct vorbis_floor0_s vorbis_floor0;
+typedef struct vorbis_floor1_s vorbis_floor1;
+struct vorbis_context_s;
+typedef
+uint_fast8_t (* vorbis_floor_decode_func)
+             (struct vorbis_context_s *, vorbis_floor_data *, float *);
+typedef struct {
+    uint_fast8_t floor_type;
+    vorbis_floor_decode_func decode;
+    union vorbis_floor_u
+    {
+        struct vorbis_floor0_s
+        {
+            uint_fast8_t order;
+            uint_fast16_t rate;
+            uint_fast16_t bark_map_size;
+            int_fast32_t * map[2];
+            uint_fast32_t map_size[2];
+            uint_fast8_t amplitude_bits;
+            uint_fast8_t amplitude_offset;
+            uint_fast8_t num_books;
+            uint_fast8_t * book_list;
+            float * lsp;
+        } t0;
+        struct vorbis_floor1_s
+        {
+            uint_fast8_t partitions;
+            uint_fast8_t maximum_class;
+            uint_fast8_t partition_class[32];
+            uint_fast8_t class_dimensions[16];
+            uint_fast8_t class_subclasses[16];
+            uint_fast8_t class_masterbook[16];
+            int_fast16_t subclass_books[16][8];
+            uint_fast8_t multiplier;
+            uint_fast16_t x_list_dim;
+            uint_fast16_t *x_list;
+            uint_fast16_t *x_list_order;
+            uint_fast16_t *low_neighbour;
+            uint_fast16_t *high_neighbour;
+        } t1;
+    } data;
+} vorbis_floor;
+
+typedef struct {
+    uint_fast16_t type;
+    uint_fast32_t begin;
+    uint_fast32_t end;
+    uint_fast32_t partition_size;
+    uint_fast8_t classifications;
+    uint_fast8_t classbook;
+    int_fast16_t books[64][8];
+    uint_fast8_t maxpass;
+} vorbis_residue;
+
+typedef struct {
+    uint_fast8_t submaps;
+    uint_fast16_t coupling_steps;
+    uint_fast8_t *magnitude;
+    uint_fast8_t *angle;
+    uint_fast8_t *mux;
+    uint_fast8_t submap_floor[16];
+    uint_fast8_t submap_residue[16];
+} vorbis_mapping;
+
+typedef struct {
+    uint_fast8_t blockflag;
+    uint_fast16_t windowtype;
+    uint_fast16_t transformtype;
+    uint_fast8_t mapping;
+} vorbis_mode;
+
+typedef struct vorbis_context_s {
+    AVCodecContext *avccontext;
+    GetBitContext gb;
+    DSPContext dsp;
+
+    MDCTContext mdct[2];
+    uint_fast8_t first_frame;
+    uint_fast32_t version;
+    uint_fast8_t audio_channels;
+    uint_fast32_t audio_samplerate;
+    uint_fast32_t bitrate_maximum;
+    uint_fast32_t bitrate_nominal;
+    uint_fast32_t bitrate_minimum;
+    uint_fast32_t blocksize[2];
+    const float * win[2];
+    uint_fast16_t codebook_count;
+    vorbis_codebook *codebooks;
+    uint_fast8_t floor_count;
+    vorbis_floor *floors;
+    uint_fast8_t residue_count;
+    vorbis_residue *residues;
+    uint_fast8_t mapping_count;
+    vorbis_mapping *mappings;
+    uint_fast8_t mode_count;
+    vorbis_mode *modes;
+    uint_fast8_t mode_number; // mode number for the current packet
+    float *channel_residues;
+    float *channel_floors;
+    float *saved;
+    uint_fast16_t saved_start;
+    float *ret;
+    float *buf;
+    float *buf_tmp;
+    uint_fast32_t add_bias; // for float->int conversion
+    uint_fast32_t exp_bias;
+} vorbis_context;
+
 /* Helper functions */
 
 /**
@@ -860,7 +978,6 @@
 static int vorbis_parse_id_hdr(vorbis_context *vc){
     GetBitContext *gb=&vc->gb;
     uint_fast8_t bl0, bl1;
-    const float *vwin[8]={ vwin64, vwin128, vwin256, vwin512, vwin1024, vwin2048, vwin4096, vwin8192 };
 
     if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||
     (get_bits(gb, 8)!='r') || (get_bits(gb, 8)!='b') ||
@@ -890,8 +1007,8 @@
                "output packets too large.\n");
         return 4;
     }
-    vc->win[0]=vwin[bl0-6];
-    vc->win[1]=vwin[bl1-6];
+    vc->win[0]=ff_vorbis_vwin[bl0-6];
+    vc->win[1]=ff_vorbis_vwin[bl1-6];
 
     if(vc->exp_bias){
         int i, j;
@@ -1262,7 +1379,7 @@
     lx=0;
     ly=floor1_Y_final[0]*vf->multiplier;  // conforms to SPEC
 
-    vec[0]=floor1_inverse_db_table[ly];
+    vec[0]=ff_vorbis_floor1_inverse_db_table[ly];
 
     for(i=1;i<vf->x_list_dim;++i) {
         AV_DEBUG(" Looking at post %d \n", i);
@@ -1289,7 +1406,7 @@
                 sy=base+1;
             }
             ady=ady-(base<0 ? -base : base)*adx;
-            vec[x]=floor1_inverse_db_table[y];
+            vec[x]=ff_vorbis_floor1_inverse_db_table[y];
 
             AV_DEBUG(" vec[ %d ] = %d \n", x, y);
 
@@ -1301,7 +1418,7 @@
                 } else {
                     y+=base;
                 }
-                vec[x]=floor1_inverse_db_table[y];
+                vec[x]=ff_vorbis_floor1_inverse_db_table[y];
 
                 AV_DEBUG(" vec[ %d ] = %d \n", x, y);
             }
@@ -1318,7 +1435,7 @@
                     predicted=ly+off;
                 }
                 if (lx+j < vf->x_list[1]) {
-                    vec[lx+j]=floor1_inverse_db_table[predicted];
+                    vec[lx+j]=ff_vorbis_floor1_inverse_db_table[predicted];
                 }
             }*/
 
@@ -1329,7 +1446,7 @@
 
     if (hx<vf->x_list[1]) {
         for(i=hx;i<vf->x_list[1];++i) {
-            vec[i]=floor1_inverse_db_table[hy];
+            vec[i]=ff_vorbis_floor1_inverse_db_table[hy];
         }
     }
 



More information about the ffmpeg-devel mailing list