annotate tremor/synthesis.c @ 33885:d3fb4ca54ce3

Restore alphabetical order.
author reimar
date Thu, 11 Aug 2011 18:15:00 +0000
parents e83eef58b30a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
1 /********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
2 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
4 * *
19251
cd6b211be811 Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents: 14280
diff changeset
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
cd6b211be811 Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents: 14280
diff changeset
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
cd6b211be811 Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents: 14280
diff changeset
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
cd6b211be811 Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents: 14280
diff changeset
8 * *
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
11 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
12 ********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
13
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
14 function: single-block PCM synthesis
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
15 last mod: $Id$
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
16
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
17 ********************************************************************/
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
18
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
19 #include <stdio.h>
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
20 #include "ogg.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
21 #include "ivorbiscodec.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
22 #include "codec_internal.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
23 #include "registry.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
24 #include "misc.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
25 #include "os.h"
24796
8dfda4d651ec _vorbis_block_alloc() is used w/o prototype, this will crash on ia64.
diego
parents: 19251
diff changeset
26 #include "block.h"
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
27
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
28 int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
29 vorbis_dsp_state *vd=vb->vd;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
30 backend_lookup_state *b=(backend_lookup_state *)vd->backend_state;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
31 vorbis_info *vi=vd->vi;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
32 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
33 oggpack_buffer *opb=&vb->opb;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
34 int type,mode,i;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 24796
diff changeset
35
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
36 /* first things first. Make sure decode is ready */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
37 _vorbis_block_ripcord(vb);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
38 oggpack_readinit(opb,op->packet,op->bytes);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
39
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
40 /* Check the packet type */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
41 if(oggpack_read(opb,1)!=0){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
42 /* Oops. This is not an audio data packet */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
43 return(OV_ENOTAUDIO);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
44 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
45
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
46 /* read our mode and pre/post windowsize */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
47 mode=oggpack_read(opb,b->modebits);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
48 if(mode==-1)return(OV_EBADPACKET);
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 24796
diff changeset
49
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
50 vb->mode=mode;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
51 vb->W=ci->mode_param[mode]->blockflag;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
52 if(vb->W){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
53 vb->lW=oggpack_read(opb,1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
54 vb->nW=oggpack_read(opb,1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
55 if(vb->nW==-1) return(OV_EBADPACKET);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
56 }else{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
57 vb->lW=0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
58 vb->nW=0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
59 }
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 24796
diff changeset
60
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
61 /* more setup */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
62 vb->granulepos=op->granulepos;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
63 vb->sequence=op->packetno-3; /* first block is third packet */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
64 vb->eofflag=op->e_o_s;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
65
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
66 /* alloc pcm passback storage */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
67 vb->pcmend=ci->blocksizes[vb->W];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
68 vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
69 for(i=0;i<vi->channels;i++)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
70 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
71
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
72 /* unpack_header enforces range checking */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
73 type=ci->map_type[ci->mode_param[mode]->mapping];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
74
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
75 return(_mapping_P[type]->inverse(vb,b->mode[mode]));
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
76 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
77
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
78 long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
79 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
80 oggpack_buffer opb;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
81 int mode;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 24796
diff changeset
82
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
83 oggpack_readinit(&opb,op->packet,op->bytes);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
84
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
85 /* Check the packet type */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
86 if(oggpack_read(&opb,1)!=0){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
87 /* Oops. This is not an audio data packet */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
88 return(OV_ENOTAUDIO);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
89 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
90
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
91 {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
92 int modebits=0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
93 int v=ci->modes;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
94 while(v>1){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
95 modebits++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
96 v>>=1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
97 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
98
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
99 /* read our mode and pre/post windowsize */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
100 mode=oggpack_read(&opb,modebits);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
101 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
102 if(mode==-1)return(OV_EBADPACKET);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
103 return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
104 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
105
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
106