From 9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e Mon Sep 17 00:00:00 2001 From: Michiel Van Der Kolk Date: Mon, 11 Jul 2005 15:42:37 +0000 Subject: Songdb java version, source. only 1.5 compatible git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7101 a1c6a512-1295-4272-9138-f99709370657 --- songdbj/com/jcraft/jorbis/Mapping0.java | 566 ++++++++++++++++++++++++++++++++ 1 file changed, 566 insertions(+) create mode 100644 songdbj/com/jcraft/jorbis/Mapping0.java (limited to 'songdbj/com/jcraft/jorbis/Mapping0.java') diff --git a/songdbj/com/jcraft/jorbis/Mapping0.java b/songdbj/com/jcraft/jorbis/Mapping0.java new file mode 100644 index 0000000000..a2c3d06b5e --- /dev/null +++ b/songdbj/com/jcraft/jorbis/Mapping0.java @@ -0,0 +1,566 @@ +/* JOrbis + * Copyright (C) 2000 ymnk, JCraft,Inc. + * + * Written by: 2000 ymnk + * + * Many thanks to + * Monty and + * The XIPHOPHORUS Company http://www.xiph.org/ . + * JOrbis has been based on their awesome works, Vorbis codec. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package com.jcraft.jorbis; + +import com.jcraft.jogg.*; + +class Mapping0 extends FuncMapping{ + static int seq=0; + void free_info(Object imap){}; + void free_look(Object imap){ +/* + LookMapping0 l=(LookMapping0)imap; + InfoMapping0 info=l.map; + if(l!=null){ + for(int i=0;idecay[i]); + l.decay[i]=null; + } + //free(l->decay); + l.decay=null; + } + //free(l->time_func); + //free(l->floor_func); + //free(l->residue_func); + //free(l->time_look); + //free(l->floor_look); + //free(l->residue_look); + //f(l->psy_look)free(l->psy_look); + l.time_func=null; + l.floor_func=null; + l.residue_func=null; + l.time_look=null; + l.floor_look=null; + l.residue_look=null; + //memset(l,0,sizeof(vorbis_look_mapping0)); + //free(l); +*/ + } + + Object look(DspState vd, InfoMode vm, Object m){ +//System.err.println("Mapping0.look"); + Info vi=vd.vi; + LookMapping0 look=new LookMapping0(); + InfoMapping0 info=look.map=(InfoMapping0)m; + look.mode=vm; + + look.time_look=new Object[info.submaps]; + look.floor_look=new Object[info.submaps]; + look.residue_look=new Object[info.submaps]; + +/* + if(vd.analysisp!=0){ + look.floor_state=new Object[vi.channels]; + } + if(vi.psys!=0){ + look.psy_look=new PsyLook[info.submaps]; + for(int i=0; ipsy[0] != info->psy[1]){ + + int psynum=info->psy[0]; + look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy)); + _vp_psy_init(look->psy_look[0],ci->psy_param[psynum], + ci->psy_g_param, + ci->blocksizes[vm->blockflag]/2,vi->rate); + + psynum=info->psy[1]; + look->psy_look[1]=_ogg_calloc(1,sizeof(vorbis_look_psy)); + _vp_psy_init(look->psy_look[1],ci->psy_param[psynum], + ci->psy_g_param, + ci->blocksizes[vm->blockflag]/2,vi->rate); + }else{ + + int psynum=info->psy[0]; + look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy)); + look->psy_look[1]=look->psy_look[0]; + _vp_psy_init(look->psy_look[0],ci->psy_param[psynum], + ci->psy_g_param, + ci->blocksizes[vm->blockflag]/2,vi->rate); + + } + */ + } + + look.ch=vi.channels; +// if(vd->analysisp)drft_init(&look->fft_look,ci->blocksizes[vm->blockflag]); + + return(look); +//return null; + } + + void pack(Info vi, Object imap, Buffer opb){ + InfoMapping0 info=(InfoMapping0)imap; + + /* another 'we meant to do it this way' hack... up to beta 4, we + packed 4 binary zeros here to signify one submapping in use. We + now redefine that to mean four bitflags that indicate use of + deeper features; bit0:submappings, bit1:coupling, + bit2,3:reserved. This is backward compatable with all actual uses + of the beta code. */ + + if(info.submaps>1){ + opb.write(1,1); + opb.write(info.submaps-1,4); + } + else{ + opb.write(0,1); + } + + if(info.coupling_steps>0){ + opb.write(1,1); + opb.write(info.coupling_steps-1,8); + for(int i=0;i1){ + for(int i=0;i=vi.channels || + testA>=vi.channels){ + //goto err_out; + info.free(); + return(null); + } + } + } + + if(opb.read(2)>0){ /* 2,3:reserved */ + //goto err_out; + info.free(); + return(null); + } + + if(info.submaps>1){ + for(int i=0;i=info.submaps){ + //goto err_out; + info.free(); + return(null); + } + } + } + + for(int i=0;i=vi.times){ + //goto err_out; + info.free(); + return(null); + } + info.floorsubmap[i]=opb.read(8); + if(info.floorsubmap[i]>=vi.floors){ + //goto err_out; + info.free(); + return(null); + } + info.residuesubmap[i]=opb.read(8); + if(info.residuesubmap[i]>=vi.residues){ + //goto err_out; + info.free(); + return(null); + } + } + return info; + //err_out: + //free_info(info); + //return(NULL); + } + +/* + // no time mapping implementation for now + static int seq=0; + int forward(Block vb, Object l){ + DspState vd=vb.vd; + Info vi=vd.vi; + LookMapping0 look=(LookMapping0)l; + InfoMapping0 info=look.map; + InfoMode mode=look.mode; + int n=vb.pcmend; + float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype]; + + float[][] pcmbundle=new float[vi.channles][]; + int[] nonzero=new int[vi.channels]; + + // time domain pre-window: NONE IMPLEMENTED + + // window the PCM data: takes PCM vector, vb; modifies PCM vector + + for(int i=0;isequence) + // memset(decay,0,n*sizeof(float)/2); + + // perform psychoacoustics; do masking + _vp_compute_mask(look.psy_look[submap],pcm,floor,decay); + + _analysis_output("mdct",seq,pcm,n/2,0,1); + _analysis_output("lmdct",seq,pcm,n/2,0,0); + _analysis_output("prefloor",seq,floor,n/2,0,1); + + // perform floor encoding + nonzero[i]=look.floor_func[submap]. + forward(vb,look.floor_look[submap],floor,floor,look.floor_state[i]); + + _analysis_output("floor",seq,floor,n/2,0,1); + + // apply the floor, do optional noise levelling + _vp_apply_floor(look->psy_look+submap,pcm,floor); + + _analysis_output("res",seq++,pcm,n/2,0,0); + } + + // perform residue encoding with residue mapping; this is + // multiplexed. All the channels belonging to one submap are + // encoded (values interleaved), then the next submap, etc + + for(int i=0;i=0;i--){ + float[] pcmM=vb.pcm[info.coupling_mag[i]]; + float[] pcmA=vb.pcm[info.coupling_ang[i]]; + + for(int j=0;j0){ + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag-ang; + } + else{ + pcmA[j]=mag; + pcmM[j]=mag+ang; + } + } + else{ + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag+ang; + } + else{ + pcmA[j]=mag; + pcmM[j]=mag-ang; + } + } + } + } + +// /* compute and apply spectral envelope */ + + for(int i=0;i1){ + ret++; + v>>>=1; + } + return(ret); + } +} + +class InfoMapping0{ + int submaps; // <= 16 + int[] chmuxlist=new int[256]; // up to 256 channels in a Vorbis stream + + int[] timesubmap=new int[16]; // [mux] + int[] floorsubmap=new int[16]; // [mux] submap to floors + int[] residuesubmap=new int[16];// [mux] submap to residue + int[] psysubmap=new int[16]; // [mux]; encode only + + int coupling_steps; + int[] coupling_mag=new int[256]; + int[] coupling_ang=new int[256]; + + void free(){ + chmuxlist=null; + timesubmap=null; + floorsubmap=null; + residuesubmap=null; + psysubmap=null; + + coupling_mag=null; + coupling_ang=null; + } +} + +class LookMapping0{ + InfoMode mode; + InfoMapping0 map; + Object[] time_look; + Object[] floor_look; + Object[] floor_state; + Object[] residue_look; + PsyLook[] psy_look; + + FuncTime[] time_func; + FuncFloor[] floor_func; + FuncResidue[] residue_func; + + int ch; + float[][] decay; + int lastframe; // if a different mode is called, we need to + // invalidate decay and floor state +} -- cgit v1.2.3