[MPlayer-cvslog] CVS: main/libmpcodecs ad_twin.c, NONE, 1.1 vqf.h, NONE, 1.1 Makefile, 1.137, 1.138 ad.c, 1.19, 1.20

Roberto Togni CVS syncmail at mplayerhq.hu
Wed Dec 29 20:51:58 CET 2004


CVS change done by Roberto Togni CVS

Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv7943/libmpcodecs

Modified Files:
	Makefile ad.c 
Added Files:
	ad_twin.c vqf.h 
Log Message:
TwinVQ decoder and demuxer


--- NEW FILE ---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "config.h"

#ifdef USE_WIN32DLL

#include "ad_internal.h"
#include "vqf.h"
#include "../../loader/ldt_keeper.h"
#include "wine/windef.h"
#include "../libaf/af_format.h"

#include "help_mp.h"

static ad_info_t info = 
{
    "TWinVQ decoder",
    "vqf",
    "Roberto Togni",
    "Nick Kurshev",
    "Ported from MPlayerXP"
};

LIBAD_EXTERN(twin)

void* WINAPI LoadLibraryA(char* name);
void*  WINAPI GetProcAddress(void* handle, char* func);
int WINAPI FreeLibrary(void* handle);

static int (*TvqInitialize)( headerInfo *setupInfo, INDEX *index, int dispErrorMessageBox );
static void (*TvqTerminate)( INDEX *index );
static void (*TvqGetVectorInfo)(int *bits0[], int *bits1[]);

static void (*TvqDecodeFrame)(INDEX  *indexp, float out[]);
static int  (*TvqWtypeToBtype)( int w_type, int *btype );
static void (*TvqUpdateVectorInfo)(int varbits, int *ndiv, int bits0[], int bits1[]);

static int   (*TvqCheckVersion)(char *versionID);
static void  (*TvqGetConfInfo)(tvqConfInfo *cf);
static int   (*TvqGetFrameSize)();
static int   (*TvqGetNumFixedBitsPerFrame)();

#define BYTE_BIT    8
#define BBUFSIZ     1024        /* Bit buffer size (bytes) */
#define BBUFLEN     (BBUFSIZ*BYTE_BIT)  /* Bit buffer length (bits) */
typedef struct vqf_priv_s
{
  float pts;
  WAVEFORMATEX o_wf;   // out format
  INDEX index;
  tvqConfInfo cf;
  headerInfo hi;
  int *bits_0[N_INTR_TYPE], *bits_1[N_INTR_TYPE];
  unsigned framesize;
  /* stream related */
  int readable;
  int ptr;           /* current point in the bit buffer */
  int nbuf;          /* bit buffer size */
  char buf[BBUFSIZ];  /* the bit buffer */
  int skip_cnt;
}vqf_priv_t;

static void* vqf_dll;

static int load_dll( char *libname )
{
#ifdef WIN32_LOADER
    Setup_LDT_Keeper();
#endif
    vqf_dll = LoadLibraryA(libname);
    if( vqf_dll == NULL )
    {
        mp_msg(MSGT_DECAUDIO, MSGL_ERR, "failed loading dll\n" );
    return 0;
    }
  TvqInitialize = GetProcAddress(vqf_dll,"TvqInitialize");
  TvqTerminate = GetProcAddress(vqf_dll,"TvqTerminate");
  TvqGetVectorInfo = GetProcAddress(vqf_dll,"TvqGetVectorInfo");
  TvqDecodeFrame = GetProcAddress(vqf_dll,"TvqDecodeFrame");
  TvqWtypeToBtype = GetProcAddress(vqf_dll,"TvqWtypeToBtype");
  TvqUpdateVectorInfo = GetProcAddress(vqf_dll,"TvqUpdateVectorInfo");
  TvqCheckVersion = GetProcAddress(vqf_dll,"TvqCheckVersion");
  TvqGetConfInfo = GetProcAddress(vqf_dll,"TvqGetConfInfo");
  TvqGetFrameSize = GetProcAddress(vqf_dll,"TvqGetFrameSize");
  TvqGetNumFixedBitsPerFrame = GetProcAddress(vqf_dll,"TvqGetNumFixedBitsPerFrame");
  return TvqInitialize && TvqTerminate && TvqGetVectorInfo &&
     TvqDecodeFrame && TvqWtypeToBtype && TvqUpdateVectorInfo &&
     TvqCheckVersion && TvqGetConfInfo && TvqGetFrameSize &&
     TvqGetNumFixedBitsPerFrame;
}

extern void print_wave_header(WAVEFORMATEX *h);
static int init_vqf_audio_codec(sh_audio_t *sh_audio){
    WAVEFORMATEX *in_fmt=sh_audio->wf;
    vqf_priv_t*priv=sh_audio->context;
    int ver;
    mp_msg(MSGT_DECAUDIO, MSGL_INFO, "======= Win32 (TWinVQ) AUDIO Codec init =======\n");

    sh_audio->channels=in_fmt->nChannels;
    sh_audio->samplerate=in_fmt->nSamplesPerSec;
    sh_audio->sample_format=AF_FORMAT_S16_NE;
//    sh_audio->sample_format=AF_FORMAT_FLOAT_NE;
    sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/8;
    priv->o_wf.nChannels=in_fmt->nChannels;
    priv->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
    priv->o_wf.nBlockAlign=sh_audio->samplesize*in_fmt->nChannels;
    priv->o_wf.nAvgBytesPerSec=in_fmt->nBlockAlign*in_fmt->nChannels;
    priv->o_wf.wFormatTag=0x01;
    priv->o_wf.wBitsPerSample=in_fmt->wBitsPerSample;
    priv->o_wf.cbSize=0;

    if(verbose)
    {
    mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Input format:\n");
    print_wave_header(in_fmt);
    mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Output fmt:\n");
    print_wave_header(&priv->o_wf);
    }
    memcpy(&priv->hi,&in_fmt[1],sizeof(headerInfo));
    if((ver=TvqInitialize(&priv->hi,&priv->index,0))){
    const char *tvqe[]={
    "No errors",
    "General error",
    "Wrong version",
    "Channel setting error",
    "Wrong coding mode",
    "Inner parameter setting error",
    "Wrong number of VQ pre-selection candidates, used only in encoder" };
    mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Tvq initialization error: %s\n",ver>=0&&ver<7?tvqe[ver]:"Unknown");
    return 0;
    }
    ver=TvqCheckVersion(priv->hi.ID);
    if(ver==TVQ_UNKNOWN_VERSION){
    mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Tvq unknown version of stream\n" );
    return 0;
    }
    TvqGetConfInfo(&priv->cf);
    TvqGetVectorInfo(priv->bits_0,priv->bits_1);
    priv->framesize=TvqGetFrameSize();
    sh_audio->audio_in_minsize=priv->framesize*in_fmt->nChannels;
    sh_audio->a_in_buffer_size=4*sh_audio->audio_in_minsize;
    sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
    sh_audio->a_in_buffer_len=0;


    return 1;
}

static int close_vqf_audio_codec(sh_audio_t *sh_audio)
{
    vqf_priv_t*priv=sh_audio->context;
    TvqTerminate(&priv->index);
    return 1;
}

int init(sh_audio_t *sh_audio)
{
    return 1;
}

int preinit(sh_audio_t *sh_audio)
{
  /* Win32 VQF audio codec: */
  vqf_priv_t *priv;
  if(!(sh_audio->context=malloc(sizeof(vqf_priv_t)))) return 0;
  priv=sh_audio->context;
  if(!load_dll(sh_audio->codec->dll))
  {
    mp_msg(MSGT_DECAUDIO, MSGL_ERR, "win32.dll looks broken :(\n");
    return 0;
  }
  if(!init_vqf_audio_codec(sh_audio)){
    mp_msg(MSGT_DECAUDIO, MSGL_ERR, "TWinVQ initialization fail\n");
    return 0;
  }
  mp_msg(MSGT_DECAUDIO, MSGL_INFO, "INFO: TWinVQ (%s) audio codec init OK!\n",sh_audio->codec->dll);
  priv->skip_cnt = 2;
  return 1;
}

void uninit(sh_audio_t *sh)
{
  close_vqf_audio_codec(sh);
  free(sh->context);
  FreeLibrary(vqf_dll);
}

int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
{
  switch(cmd) {
      case ADCTRL_QUERY_FORMAT:
          return CONTROL_TRUE;
      default:
          return CONTROL_UNKNOWN;
  }
}

static int bread(char   *data,    /* Output: Output data array */
          int   size,     /* Input:  Length of each data */
          int   nbits,    /* Input:  Number of bits to write */
          sh_audio_t *sh)  /* Input:  File pointer */
{
    /*--- Variables ---*/
    int  ibits, iptr, idata, ibufadr, ibufbit, icl;
    unsigned char mask, tmpdat;
    int  retval;
    vqf_priv_t *priv=sh->context;
    
    /*--- Main operation ---*/
    retval = 0;
    mask = 0x1;
    for ( ibits=0; ibits<nbits; ibits++ ){
        if ( priv->readable == 0 ){  /* when the file data buffer is empty */
            priv->nbuf = demux_read_data(sh->ds, priv->buf, BBUFSIZ);
            priv->nbuf *= 8;
            priv->readable = 1;
        }
        iptr = priv->ptr;           /* current file data buffer pointer */
        if ( iptr >= priv->nbuf )   /* If data file is empty then return */
            return(retval);
        ibufadr = iptr/BYTE_BIT;      /* current file data buffer address */
        ibufbit = iptr%BYTE_BIT;      /* current file data buffer bit */
        /*  tmpdat = stream->buf[ibufadr] >> (BYTE_BIT-ibufbit-1); */
        tmpdat = (unsigned char)priv->buf[ibufadr];
        tmpdat >>= (BYTE_BIT-ibufbit-1);
        /* current data bit */
        
        idata = ibits*size;                   /* output data address */
        data[idata] = (char)(tmpdat & mask);  /* set output data */
        for (icl=1; icl<size; icl++)
            data[idata+icl] = 0; /* clear the rest output data buffer */
        priv->ptr += 1;       /* update data buffer pointer */
        if (priv->ptr == BBUFLEN){
            priv->ptr = 0;
            priv->readable = 0;
        }
        ++retval;
    }
    return(retval);
}

#define BITS_INT    (sizeof(int)*8)

static int get_bstm(int *data,          /* Input: input data */
            unsigned nbits,         /* Input: number of bits */
            sh_audio_t *sh)          /* Input: bit file pointer */
{
    unsigned    ibit;
    unsigned    mask;
    unsigned    work;
    char    tmpbit[BITS_INT];
    int     retval;
    
    if ( nbits > BITS_INT ){
        mp_msg(MSGT_DECAUDIO, MSGL_ERR, "get_bstm(): %d: %d Error.\n",
            nbits, BITS_INT);
        exit(1);
    }
    retval = bread(tmpbit, sizeof(*tmpbit), nbits, sh);
    for (ibit=retval; ibit<nbits; ibit++){
        tmpbit[ibit] = 0;
    }
    mask = 0x1<<(nbits-1);
    work=0;
    for ( ibit=0; ibit<nbits; ibit++ ){
        work += mask*tmpbit[ibit];
        mask >>= 1;
    }
    *data = work;
    return(retval);
}

static int GetVqInfo( tvqConfInfoSubBlock *cfg,
            int bits0[],
            int bits1[],
            int variableBits,
            INDEX *index,
            sh_audio_t *sh)
{
    int idiv;
    int bitcount = 0;

    if ( index->btype == BLK_LONG ){
        TvqUpdateVectorInfo( variableBits, &cfg->ndiv, bits0, bits1 ); // re-calculate VQ bits
    }
    for ( idiv=0; idiv<cfg->ndiv; idiv++ ){
        bitcount += get_bstm(&index->wvq[idiv],bits0[idiv],sh); /* CB 0 */
        bitcount += get_bstm(&index->wvq[idiv+cfg->ndiv],bits1[idiv],sh); /* CB 1 */
    }
    return bitcount;
}

static int GetBseInfo( tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh)
{
    int i_sup, isf, itmp, idiv;
    int bitcount = 0;

    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){
        for ( isf=0; isf<cfg->nsf; isf++ ){
            for ( idiv=0; idiv<cfg->fw_ndiv; idiv++ ){
                itmp = idiv + ( isf + i_sup * cfg->nsf ) * cfg->fw_ndiv;
                bitcount += get_bstm(&index->fw[itmp],cfg->fw_nbit,sh);
            }
        }
    }
    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){
        for ( isf=0; isf<cfg->nsf; isf++ ){
            bitcount += get_bstm(&index->fw_alf[i_sup * cfg->nsf + isf],cf->FW_ARSW_BITS,sh);
        }
    }
    return bitcount;
}

static int GetGainInfo(tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh )
{
    int i_sup, iptop, isf;
    int bitcount = 0;

    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){
        iptop = ( cfg->nsubg + 1 ) * i_sup;
        bitcount += get_bstm(&index->pow[iptop], cf->GAIN_BITS,sh);
        for ( isf=0; isf<cfg->nsubg; isf++ ){
            bitcount += get_bstm(&index->pow[iptop+isf+1], cf->SUB_GAIN_BITS,sh);
        }
    }
    return bitcount;
}

static int GetLspInfo( tvqConfInfo *cf, INDEX *index, sh_audio_t *sh )
{
    int i_sup, itmp;
    int bitcount = 0;

    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){
        bitcount += get_bstm(&index->lsp[i_sup][0], cf->LSP_BIT0,sh); /* pred. switch */
        bitcount += get_bstm(&index->lsp[i_sup][1], cf->LSP_BIT1,sh); /* first stage */
        for ( itmp=0; itmp<cf->LSP_SPLIT; itmp++ ){         /* second stage */
            bitcount += get_bstm(&index->lsp[i_sup][itmp+2], cf->LSP_BIT2,sh);
        }
    }

    return bitcount;
}

static int GetPpcInfo( tvqConfInfo *cf, INDEX *index, sh_audio_t *sh)
{
    int idiv, i_sup;
    int bitcount = 0;
    vqf_priv_t*priv=sh->context;
    
    for ( idiv=0; idiv<cf->N_DIV_P; idiv++ ){
        bitcount += get_bstm(&(index->pls[idiv]), priv->bits_0[BLK_PPC][idiv],sh);       /*CB0*/
        bitcount += get_bstm(&(index->pls[idiv+cf->N_DIV_P]), priv->bits_1[BLK_PPC][idiv],sh);/*CB1*/
    }
    for (i_sup=0; i_sup<cf->N_CH; i_sup++){
        bitcount += get_bstm(&(index->pit[i_sup]), cf->BASF_BIT,sh);
        bitcount += get_bstm(&(index->pgain[i_sup]), cf->PGAIN_BIT,sh);
    }
    
    return bitcount;
}

static int GetEbcInfo( tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh)
{
    int i_sup, isf, itmp;
    int bitcount = 0;

    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){
        for ( isf=0; isf<cfg->nsf; isf++){
            int indexSfOffset = isf * ( cfg->ncrb - cfg->ebc_crb_base ) - cfg->ebc_crb_base;
            for ( itmp=cfg->ebc_crb_base; itmp<cfg->ncrb; itmp++ ){
                bitcount += get_bstm(&index->bc[i_sup][itmp+indexSfOffset], cfg->ebc_bits,sh);
            }
        }
    }
    
    return bitcount;
}

static int vqf_read_frame(sh_audio_t *sh,INDEX *index)
{
    /*--- Variables ---*/
    tvqConfInfoSubBlock *cfg;
    int variableBits;
    int bitcount;
    int numFixedBitsPerFrame = TvqGetNumFixedBitsPerFrame();
    int btype;
    vqf_priv_t *priv=sh->context;
    
    /*--- Initialization ---*/
    variableBits = 0;
    bitcount = 0;

    /*--- read block independent factors ---*/
    /* Window type */
    bitcount += get_bstm( &index->w_type, priv->cf.BITS_WTYPE, sh );
    if ( TvqWtypeToBtype( index->w_type, &index->btype ) ) {
        mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Error: unknown window type: %d\n", index->w_type);
        return 0;
    }
    btype = index->btype;

    /*--- read block dependent factors ---*/
    cfg = &priv->cf.cfg[btype]; // set the block dependent paremeters table

    bitcount += variableBits;
    
    /* Interleaved vector quantization */
    bitcount += GetVqInfo( cfg, priv->bits_0[btype], priv->bits_1[btype], variableBits, index, sh );
    
    /* Bark-scale envelope */
    bitcount += GetBseInfo( &priv->cf, cfg, index, sh );
    /* Gain */
    bitcount += GetGainInfo( &priv->cf, cfg, index, sh );
    /* LSP */
    bitcount += GetLspInfo( &priv->cf, index, sh );
    /* PPC */
    if ( cfg->ppc_enable ){
        bitcount += GetPpcInfo( &priv->cf, index, sh );
    }
    /* Energy Balance Calibration */
    if ( cfg->ebc_enable ){
        bitcount += GetEbcInfo( &priv->cf, cfg, index, sh );
    }
    
    return bitcount == numFixedBitsPerFrame ? bitcount/8 : 0;
}

static void frtobuf_s16(float out[],       /* Input  --- input data frame */
        short bufout[],    /* Output --- output data buffer array */
        unsigned frameSize,   /* Input  --- frame size */
        unsigned numChannels) /* Input  --- number of channels */
{
    /*--- Variables ---*/
    unsigned ismp, ich;
    float *ptr;
    float dtmp;
    
    for ( ich=0; ich<numChannels; ich++ ){
        ptr = out+ich*frameSize;
        for ( ismp=0; ismp<frameSize; ismp++ ){
            dtmp = ptr[ismp];
            if ( dtmp >= 0. ) {
                if ( dtmp > 32700. )
                dtmp = 32700.;
                bufout[ismp*numChannels+ich] = (short)(dtmp+0.5);
            } else {
                if ( dtmp < -32700. )
                dtmp = -32700.;
                bufout[ismp*numChannels+ich] = (short)(dtmp-0.5);
            }
        }
    }
}

static void frtobuf_float(float out[],       /* Input  --- input data frame */
        float bufout[],    /* Output --- output data buffer array */
        unsigned frameSize,   /* Input  --- frame size */
        unsigned numChannels) /* Input  --- number of channels */
{
    /*--- Variables ---*/
    unsigned ismp, ich;
    float *ptr;
    float dtmp;
    
    for ( ich=0; ich<numChannels; ich++ ){
        ptr = out+ich*frameSize;
        for ( ismp=0; ismp<frameSize; ismp++ ){
            dtmp = ptr[ismp];
            if ( dtmp >= 0. ) {
                if ( dtmp > 32700. )
                dtmp = 32700.;
                bufout[ismp*numChannels+ich] = dtmp/32767.;
            } else {
                if ( dtmp < -32700. )
                dtmp = -32700.;
                bufout[ismp*numChannels+ich] = dtmp/32767.;
            }
        }
    }
}

int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
    int l, len=0;
    vqf_priv_t *priv=sh_audio->context;
    while(len<minlen)
    {
        float out[priv->framesize*sh_audio->channels];
        l=vqf_read_frame(sh_audio,&priv->index);
        if(!l) break;
        TvqDecodeFrame(&priv->index, out);
        if (priv->skip_cnt) {
            // Ingnore first two frames, replace them with silence
            priv->skip_cnt--;
            memset(buf, 0, priv->framesize*sh_audio->channels*sh_audio->samplesize);
        } else {
           if (sh_audio->sample_format == AF_FORMAT_S16_NE)
               frtobuf_s16(out, (short *)buf, priv->framesize, sh_audio->channels);
           else
               frtobuf_float(out, (float *)buf, priv->framesize, sh_audio->channels);
        }
        len += priv->framesize*sh_audio->channels*sh_audio->samplesize;
        buf += priv->framesize*sh_audio->channels*sh_audio->samplesize;
    }
    return len;
}

#endif

--- NEW FILE ---
/* (c)Copyright 1996-2000 NTT Cyber Space Laboratories */
/*                Released on 2000.05.22 by N. Iwakami */
/*                Modified on 2000.05.25 by N. Iwakami */
/*                Released on 2000.09.06 by N. Iwakami */

// Modified for MPlayer on 2004.12.29

#ifndef tvqdec_h
#define tvqdec_h

#ifdef _MSC_VER
#	ifdef DLL_MODULE
#		define DllPort    __declspec( dllexport )
#	else
#		define DllPort    __declspec( dllimport )
#	endif
#else
#	define DllPort
#endif

#ifdef __cplusplus
extern "C" {  // only need to import/export C interface if used by C++ source code
#endif

/************************/
/*** General settings ***/
/************************/
/* Initialization error code */
enum INIT_ERROR_CODE {
	TVQ_NO_ERROR = 0,     // no error
	TVQ_ERROR,            // general
	TVQ_ERROR_VERSION,    // wrong version
	TVQ_ERROR_CHANNEL,    // channel setting error
	TVQ_ERROR_MODE,       // wrong coding mode
	TVQ_ERROR_PARAM,      // inner parameter setting error
	TVQ_ERROR_N_CAN,      // wrong number of VQ pre-selection candidates, used only in encoder
};

/* version ID */
#define TVQ_UNKNOWN_VERSION  -1
#define V2                    0
#define V2PP                  1

#define N_VERSIONS            2

/* window types */
enum WINDOW_TYPE {
  ONLY_LONG_WINDOW = 0,
  LONG_SHORT_WINDOW,
  ONLY_SHORT_WINDOW,
  SHORT_LONG_WINDOW,
  SHORT_MEDIUM_WINDOW,
  MEDIUM_LONG_WINDOW,
  LONG_MEDIUM_WINDOW,
  MEDIUM_SHORT_WINDOW,
  ONLY_MEDIUM_WINDOW,
};

/* block types */
enum BLOCK_TYPE {
	BLK_SHORT = 0,
	BLK_MEDIUM,
	BLK_LONG,
	BLK_PPC,
};
#define N_BTYPE     3  // number of block types
#define N_INTR_TYPE 4  // number of interleave types, enum BLOCK_TYPE is commonly used for detecting interleave types.

/* maximum number of channels */
#define N_CH_MAX     2

/* type definition of code information interface */
typedef struct {
	/* block type */
    int  w_type;
    int  btype;

	/* FBC info */
    int  *segment_sw[ N_CH_MAX ];
    int  *band_sw[ N_CH_MAX ];
    int	 *fg_intensity[ N_CH_MAX ];

	/* VQ info */
    int  *wvq;

	/* BSE info */
    int  *fw;
    int  *fw_alf;

	/* gain info */
    int  *pow;

	/* LSP info */
    int  *lsp[ N_CH_MAX ];

	/* PPC info */
    int  pit[ N_CH_MAX ];
    int  *pls;
    int  pgain[ N_CH_MAX ];

	/* EBC info */
    int  *bc[ N_CH_MAX ];

    void *manager;
} INDEX;

/***********************************************/
/*** Definitions about program configuration ***/
/***********************************************/
/* type definition of tvqConfInfoSubBlock */
typedef struct {
	int sf_sz;         // subframe size
	int nsf;           // number of subframes
	int ndiv;          // number of division of weighted interleave vector quantization
	int ncrb;          // number of Bark-scale subbands
	int fw_ndiv;       // number of division of BSE VQ
	int fw_nbit;       // number of bits for BSE VQ
	int nsubg;         // number of sub-blocks for gain coding
	int ppc_enable;    // PPC switch
	int ebc_enable;    // EBC switch
	int ebc_crb_base;  // EBC base band
	int ebc_bits;      // EBC bits
	int fbc_enable;    // FBC switch
	int fbc_n_segment; // FBC number of segments
	int fbc_nband;     // FBC number of subbands
	int *fbc_crb_tbl;  // FBC subband table
} tvqConfInfoSubBlock;

/* type definition of tvqConfInfo */
typedef struct {
  /* frame configuration */
  int N_CH;
  /* window type coding */
  int BITS_WTYPE;
  /* LSP coding */
  int LSP_BIT0;
  int LSP_BIT1;
  int LSP_BIT2;
  int LSP_SPLIT;
  /* Bark-scale envelope coding */
  int FW_ARSW_BITS;
  /* gain coding */
  int GAIN_BITS;
  int SUB_GAIN_BITS;
  /* pitch excitation */
  int N_DIV_P;
  int BASF_BIT;
  int PGAIN_BIT;

  /* block type dependent parameters */
  tvqConfInfoSubBlock cfg[N_BTYPE];

} tvqConfInfo;


/*************************************************/
/*** Definitions about TwinVQ bitstream header ***/
/*************************************************/
//#include "../declib_src/tvq_hdr.h"
//#ifndef	BUFSIZ
//#define	BUFSIZ		1024
//#endif

#define	KEYWORD_BYTES	4
#define	VERSION_BYTES	8
#define ELEM_BYTES      sizeof(unsigned long)


/*
 */
typedef struct {
	char		ID[KEYWORD_BYTES+VERSION_BYTES+1];
	int size;
	/* Common Chunk */
	int channelMode;   /* channel mode (mono:0/stereo:1) */
	int bitRate;       /* bit rate (kbit/s) */
	int samplingRate;  /* sampling rate (44.1 kHz -> 44) */
	int securityLevel; /* security level (always 0) */
	/* Text Chunk */
	char	Name[BUFSIZ];
	char	Comt[BUFSIZ];
	char	Auth[BUFSIZ];
	char	Cpyr[BUFSIZ];
	char	File[BUFSIZ];
	char	Extr[BUFSIZ];  // add by OKAMOTO 99.12.21
	/* Data size chunk*/
	int		Dsiz;
} headerInfo;

// TwinVQ decoder initialization/termination functions
//DllPort int  TvqInitialize( headerInfo *setupInfo, INDEX *index, int dispErrorMessageBox );
//DllPort void TvqTerminate( INDEX *index );
//DllPort void TvqGetVectorInfo(int *bits0[], int *bits1[]);
//DllPort void TvqResetFrameCounter();

// TwinVQ decoder function
//DllPort void TvqDecodeFrame(INDEX  *indexp, float out[]);
//DllPort int  TvqWtypeToBtype( int w_type, int *btype );
//DllPort void TvqUpdateVectorInfo(int varbits, int *ndiv, int bits0[], int bits1[]);
//DllPort void TvqSetFrameCounter( int position );

// TwinVQ query functions
//DllPort int   TvqCheckVersion(char *versionID);
//DllPort void  TvqGetSetupInfo(headerInfo *setupInfo); // setup information
//DllPort void  TvqGetConfInfo(tvqConfInfo *cf);  // configuration information
//DllPort int   TvqGetFrameSize();   // frame size
//DllPort int   TvqGetNumChannels(); // number of channels
//DllPort int   TvqGetBitRate();                        // total bitrate
//DllPort float TvqGetSamplingRate();                   // sampling rate
//DllPort int   TvqGetNumFixedBitsPerFrame();           // number of fixed bits per frame
//DllPort int   TvqGetNumFrames();   // number of decoded frame
//DllPort int   TvqGetModuleVersion( char* versionString );

#ifdef V2PLUS_SUPPORT
// TwinVQ FB coding tool control
DllPort void  TvqFbCountUsedBits(int nbit);  // count number of used bits 
DllPort float TvqGetFbCurrentBitrate();  // query average bitrate for the tool
DllPort int   TvqGetFbTotalBits();  // query total number of used bits 
#endif

#ifdef __cplusplus
}
#endif


#endif

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- Makefile	9 Dec 2004 13:11:21 -0000	1.137
+++ Makefile	29 Dec 2004 19:51:56 -0000	1.138
@@ -6,7 +6,7 @@
 
 AUDIO_SRCS_LIB=ad_liba52.c ad_hwac3.c ad_mp3lib.c
 AUDIO_SRCS_NAT=ad_alaw.c ad_dk3adpcm.c ad_pcm.c ad_dvdpcm.c ad_imaadpcm.c ad_msadpcm.c ad_msgsm.c ad_ra1428.c
-AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c ad_libvorbis.c ad_libmad.c ad_realaud.c ad_libdv.c
+AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c ad_libvorbis.c ad_libmad.c ad_realaud.c ad_libdv.c ad_twin.c
 AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
 
 VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c

Index: ad.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ad.c	15 Jul 2004 20:36:04 -0000	1.19
+++ ad.c	29 Dec 2004 19:51:56 -0000	1.20
@@ -38,6 +38,7 @@
 extern ad_functions_t mpcodecs_ad_libdv;
 extern ad_functions_t mpcodecs_ad_qtaudio;
 extern ad_functions_t mpcodecs_ad_ra1428;
+extern ad_functions_t mpcodecs_ad_twin;
 
 ad_functions_t* mpcodecs_ad_drivers[] =
 {
@@ -65,6 +66,7 @@
   &mpcodecs_ad_dmo,
 #endif
   &mpcodecs_ad_acm,
+  &mpcodecs_ad_twin,
 #endif
 #if defined(USE_QTX_CODECS) || defined(MACOSX)
   &mpcodecs_ad_qtaudio,




More information about the MPlayer-cvslog mailing list