incremental update to make sure the massive modifications exist on
[platform/upstream/libvorbis.git] / lib / synthesis.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: single-block PCM synthesis
15  last mod: $Id: synthesis.c,v 1.13 2000/01/20 04:43:04 xiphmont Exp $
16
17  ********************************************************************/
18
19 #include <stdio.h>
20 #include "vorbis/codec.h"
21 #include "registry.h"
22 #include "bitwise.h"
23
24 int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
25   vorbis_dsp_state *vd=vb->vd;
26   vorbis_info      *vi=vd->vi;
27   oggpack_buffer   *opb=&vb->opb;
28   int              type;
29   int              mode;
30
31   /* first things first.  Make sure decode is ready */
32   _vorbis_block_ripcord(vb);
33   _oggpack_readinit(opb,op->packet,op->bytes);
34
35   /* Check the packet type */
36   if(_oggpack_read(opb,1)!=0){
37     /* Oops.  This is not an audio data packet */
38     return(-1);
39   }
40
41   /* read our mode */
42   mode=_oggpack_read(&vb->opb,vd->modebits);
43   type=vi->mappingtypes[mode]; /* unpack_header enforces range checking */
44
45   return(vorbis_map_synthesis_P[type](vb,vi->modelist[mode],op));
46 }
47
48