1 /********************************************************************
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. *
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/ *
12 ********************************************************************
14 function: single-block PCM analysis mode dispatch
15 last mod: $Id: analysis.c,v 1.22 2000/01/22 13:28:14 xiphmont Exp $
17 ********************************************************************/
22 #include "vorbis/codec.h"
26 /* decides between modes, dispatches to the appropriate mapping. */
27 int vorbis_analysis(vorbis_block *vb,ogg_packet *op){
28 vorbis_dsp_state *vd=vb->vd;
29 vorbis_info *vi=vd->vi;
38 /* first things first. Make sure encode is ready */
39 _oggpack_reset(&vb->opb);
40 /* Encode the packet type */
41 _oggpack_write(&vb->opb,0,1);
43 /* currently lazy. Short block dispatches to 0, long to 1. */
45 if(vb->W &&vi->modes>1)mode=1;
46 type=vi->map_type[vi->mode_param[mode]->mapping];
48 /* Encode frame mode, pre,post windowsize, then dispatch */
49 _oggpack_write(&vb->opb,mode,vd->modebits);
51 _oggpack_write(&vb->opb,vb->lW,1);
52 _oggpack_write(&vb->opb,vb->nW,1);
55 if(_mapping_P[type]->forward(vb,vd->mode[mode]))
58 /* set up the packet wrapper */
60 op->packet=_oggpack_buffer(&vb->opb);
61 op->bytes=_oggpack_bytes(&vb->opb);
63 op->e_o_s=vb->eofflag;
64 op->frameno=vb->frameno;
65 op->packetno=vb->sequence; /* for sake of completeness */