doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
analysis.c
Go to the documentation of this file.
1 /********************************************************************
2  * *
3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7  * *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
9  * by the XIPHOPHORUS Company http://www.xiph.org/ *
10  * *
11  ********************************************************************
12 
13  function: single-block PCM analysis mode dispatch
14  last mod: $Id: analysis.c,v 1.55 2002/07/11 06:40:48 xiphmont Exp $
15 
16  ********************************************************************/
17 
18 #include <stdio.h>
19 #include <string.h>
20 #include <math.h>
21 #include "../ogg/ogg.h"
22 #include "../vorbis/codec.h"
23 #include "codec_internal.h"
24 #include "registry.h"
25 #include "scales.h"
26 #include "os.h"
27 #include "misc.h"
28 
30 
31 /* decides between modes, dispatches to the appropriate mapping. */
33  int ret;
34 
35  vb->glue_bits=0;
36  vb->time_bits=0;
37  vb->floor_bits=0;
38  vb->res_bits=0;
39 
40  /* first things first. Make sure encode is ready */
41  oggpack_reset(&vb->opb);
42 
43  /* we only have one mapping type (0), and we let the mapping code
44  itself figure out what soft mode to use. This allows easier
45  bitrate management */
46 
47  if((ret=_mapping_P[0]->forward(vb)))
48  return(ret);
49 
50  if(op){
52  /* The app is using a bitmanaged mode... but not using the
53  bitrate management interface. */
54  return(OV_EINVAL);
55 
56  op->packet=oggpack_get_buffer(&vb->opb);
57  op->bytes=oggpack_bytes(&vb->opb);
58  op->b_o_s=0;
59  op->e_o_s=vb->eofflag;
60  op->granulepos=vb->granulepos;
61  op->packetno=vb->sequence; /* for sake of completeness */
62  }
63  return(0);
64 }
65 
66 /* there was no great place to put this.... */
67 void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){
68  int j;
69  FILE *of;
70  char buffer[80];
71 
72  /* if(i==5870){*/
73  sprintf(buffer,"%s_%d.m",base,i);
74  of=fopen(buffer,"w");
75 
76  if(!of)perror("failed to open data dump file");
77 
78  for(j=0;j<n;j++){
79  if(bark){
80  float b=toBARK((4000.f*j/n)+.25);
81  fprintf(of,"%f ",b);
82  }else
83  if(off!=0)
84  fprintf(of,"%f ",(double)(j+off)/8000.);
85  else
86  fprintf(of,"%f ",(double)j);
87 
88  if(dB){
89  float val;
90  if(v[j]==0.)
91  val=-140.;
92  else
93  val=todB(v+j);
94  fprintf(of,"%f\n",val);
95  }else{
96  fprintf(of,"%f\n",v[j]);
97  }
98  }
99  fclose(of);
100  /* } */
101 }
102 
103 void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
104  ogg_int64_t off){
105  if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);
106 }
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
vorbis_func_mapping * _mapping_P[]
Definition: registry.c:43
long glue_bits
Definition: codec.h:113
oggpack_buffer opb
Definition: codec.h:91
const GLdouble * v
Definition: glext.h:2936
Definition: ogg.h:84
void _analysis_output(char *base, int i, float *v, int n, int bark, int dB, ogg_int64_t off)
Definition: analysis.c:103
GLenum GLsizei n
Definition: glext.h:3705
void _analysis_output_always(char *base, int i, float *v, int n, int bark, int dB, ogg_int64_t off)
Definition: analysis.c:67
int i
Definition: process.py:33
long bytes
Definition: ogg.h:86
GLuint buffer
Definition: glext.h:3108
int vorbis_bitrate_managed(vorbis_block *vb)
Definition: bitrate.c:171
#define toBARK(n)
Definition: scales.h:76
unsigned char * packet
Definition: ogg.h:85
long floor_bits
Definition: codec.h:115
#define OV_EINVAL
Definition: codec.h:226
long b_o_s
Definition: ogg.h:87
GLubyte GLubyte b
Definition: glext.h:4662
int analysis_noisy
Definition: analysis.c:29
long time_bits
Definition: codec.h:114
int eofflag
Definition: codec.h:99
tuple f
Definition: idal.py:89
ogg_int64_t granulepos
Definition: codec.h:100
long oggpack_bytes(oggpack_buffer *b)
Definition: bitwise.c:426
ogg_int64_t granulepos
Definition: ogg.h:90
void oggpack_reset(oggpack_buffer *b)
Definition: bitwise.c:195
unsigned char * oggpack_get_buffer(oggpack_buffer *b)
Definition: bitwise.c:442
long res_bits
Definition: codec.h:116
GLint j
Definition: qgl.h:264
int64_t ogg_int64_t
Definition: os_types.h:140
ogg_int64_t sequence
Definition: codec.h:101
long e_o_s
Definition: ogg.h:88
int sprintf(idStr &string, const char *fmt,...)
Definition: Str.cpp:1528
ogg_int64_t packetno
Definition: ogg.h:92
int vorbis_analysis(vorbis_block *vb, ogg_packet *op)
Definition: analysis.c:32