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.21 2000/01/20 04:42:51 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->mappingtypes[mode];
48 /* Encode frame mode and dispatch */
49 _oggpack_write(&vb->opb,mode,vd->modebits);
50 if(vorbis_map_analysis_P[type](vb,vi->modelist[mode],op))
53 /* set up the packet wrapper */
55 op->packet=_oggpack_buffer(&vb->opb);
56 op->bytes=_oggpack_bytes(&vb->opb);
58 op->e_o_s=vb->eofflag;
59 op->frameno=vb->frameno;
60 op->packetno=vb->sequence; /* for sake of completeness */