⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.c

📁 C写的MPEG4音频源代码(G.723/G.729)
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************* MPEG-2 NBC Audio Decoder ************************** *                                                                           *"This software module was originally developed by AT&T, Dolby Laboratories, Fraunhofer Gesellschaft IIS in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/MPEG-4Audio  standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original developerretains full right to use the code for his/her  own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice mustbe included in all copies or derivative works." Copyright(c)1996. *                                                                           * ****************************************************************************/#include <stdio.h>#include <string.h>#include "block.h"               /* handler, defines, enums */#include "buffersHandle.h"       /* handler, defines, enums */#include "concealmentHandle.h"   /* handler, defines, enums */#include "interface.h"           /* handler, defines, enums */#include "mod_bufHandle.h"       /* handler, defines, enums */#include "monopredHandle.h"      /* handler, defines, enums */#include "reorderspecHandle.h"   /* handler, defines, enums */#include "resilienceHandle.h"    /* handler, defines, enums */#include "tf_mainHandle.h"       /* handler, defines, enums */#include "all.h"                 /* structs */#include "monopredStruct.h"      /* structs */#include "nok_ltp_common.h"      /* structs */#include "nok_prediction.h"      /* structs */#include "tf_mainStruct.h"       /* structs */#include "tns.h"                 /* structs */#include "allVariables.h"        /* variables */#include "buffers.h"#include "bitstream.h"#include "common_m4a.h"#include "port.h"int default_config; /* defined in allVariables.h as 'extern int default_config' *//*  * profile dependent parameters */int tns_max_bands(int islong, QC_MOD_SELECT qc_select){  int i;  /* construct second index */  i = islong ? 0 : 1;  i += (mc_info.profile ==  SSR_Profile) ? 2 : 0;      return tns_max_bands_tbl[mc_info.sampling_rate_idx][i];}inttns_max_order(int islong){  if (islong) {    switch (mc_info.profile) {    case Main_Profile:      return 20;    case LC_Profile:    case SSR_Profile:      return 12;    }  }  else {    /* short window */    return 7;  }  return 0;}intpred_max_bands(void){  return pred_max_bands_tbl[mc_info.sampling_rate_idx];}/* * adif_header */int get_adif_header( int               block_size_samples,                     HANDLE_RESILIENCE hResilience,                     HANDLE_BUFFER     hVm,                      HANDLE_EP_INFO    hEpInfo ){  int i, n;  int tag = 0;  int  select_status;  ProgConfig tmp_config;  ADIF_Header *p = &adif_header;      /* adif header */  for (i=0; i<LEN_ADIF_ID; i++)    p->adif_id[i] = GetBits ( ADIF_ID,                              LEN_BYTE,                              hResilience,                              hVm,                               hEpInfo );   p->adif_id[i] = 0;	    /* null terminated string */  /* test for id */  if (strncmp(p->adif_id, "ADIF", 4) != 0)    return -1;	    /* bad id */  /* copyright string */	  if ((p->copy_id_present = GetBits ( COPYRIGHT_ID_PRESENT,                                      LEN_COPYRT_PRES,                                      hResilience,                                      hVm,                                       hEpInfo )) == 1) {    for (i=0; i<LEN_COPYRT_ID; i++)      p->copy_id[i] = GetBits ( COPYRIGHT_ID,                                 LEN_BYTE,                                hResilience,                                hVm,                                 hEpInfo );     p->copy_id[i] = 0;  /* null terminated string */  }  p->original_copy = GetBits ( ORIGINAL_COPY,                                LEN_ORIG,                               hResilience,                               hVm,                                hEpInfo );  p->home = GetBits ( HOME,                       LEN_HOME,                      hResilience,                      hVm,                       hEpInfo );  p->bitstream_type = GetBits ( BITSTREAM_TYPE,                                 LEN_BS_TYPE,                                hResilience,                                hVm,                                 hEpInfo );  p->bitrate = GetBits ( BITRATE,                          LEN_BIT_RATE,                         hResilience,                         hVm,                          hEpInfo );  /* program config elements */   select_status = -1;     n = GetBits ( NUM_PROGRAM_CONFIG_ELEMENTS,                 LEN_NUM_PCE,                hResilience,                hVm,                 hEpInfo ) + 1;  for (i=0; i<n; i++) {    tmp_config.buffer_fullness =      (p->bitstream_type == 0) ? GetBits ( ADIF_BUFFER_FULLNESS,                                            LEN_ADIF_BF,                                           hResilience,                                           hVm,                                            hEpInfo ) : 0;    tag = get_prog_config ( &tmp_config,                            block_size_samples,                            hResilience,                            hVm,                             hEpInfo );    if (current_program < 0)      current_program = tag;	    /* default is first prog */    if (current_program == tag) {      memcpy(&prog_config, &tmp_config, sizeof(prog_config));      select_status = 1;    }  }  if (debug['v']) {    fprintf(stderr, "\nADIF header:\n");    fprintf(stderr, "%s %d\n", "p->copy_id_present", p->copy_id_present);    fprintf(stderr, "%s %d\n", "p->original_copy", p->original_copy);    fprintf(stderr, "%s %d\n", "p->home", p->home);    fprintf(stderr, "%s %d\n", "p->bitstream_type", p->bitstream_type);    fprintf(stderr, "%s %ld\n", "p->bitrate", p->bitrate);    fprintf(stderr, "%s %d\n", "number of PCE", n);    fprintf(stderr, "Select status %d for PCE tag %d\n", select_status, tag);    if (select_status) {      ProgConfig *p = &prog_config;      fprintf(stderr, "%s %d\n", "p->profile", p->profile);      fprintf(stderr, "%s %d\n", "p->sampling_rate_idx", p->sampling_rate_idx);      fprintf(stderr, "%s %d\n", "p->front.num_ele", p->front.num_ele);      fprintf(stderr, "%s %d\n", "p->side.num_ele", p->side.num_ele);      fprintf(stderr, "%s %d\n", "p->back.num_ele", p->back.num_ele);      fprintf(stderr, "%s %d\n", "p->lfe.num_ele", p->lfe.num_ele);      fprintf(stderr, "%s %d\n", "p->data.num_ele", p->data.num_ele);      fprintf(stderr, "%s %d\n", "p->coupling.num_ele", p->coupling.num_ele);      fprintf(stderr, "%s %d\n", "p->mono_mix.present", p->mono_mix.present);      fprintf(stderr, "%s %d\n", "p->stereo_mix.present", p->stereo_mix.present);      fprintf(stderr, "%s %d\n", "p->matrix_mix.present", p->matrix_mix.present);	          fprintf(stderr, "Comment: %s\n", prog_config.comments);    }  }  return select_status;}/* * program configuration element */static void get_ele_list ( EleList*          p,                            int               enable_cpe,                           HANDLE_RESILIENCE hResilience,                           HANDLE_BUFFER     hVm,                            HANDLE_EP_INFO    hEpInfo ){    int i, j;  for (i=0, j=p->num_ele; i<j; i++) {    if (enable_cpe)      p->ele_is_cpe[i] = GetBits(FRONT_SIDE_BACK_ELEMENT_IS_CPE,                                  LEN_ELE_IS_CPE,                                 hResilience,                                 hVm,                                  hEpInfo );    p->ele_tag[i] = GetBits(FRONT_SIDE_BACK_LFE_DATA_CC_ELEMENT_TAG_SELECT,                             LEN_TAG,                            hResilience,                            hVm,                             hEpInfo );  }}int get_prog_config ( ProgConfig*       p,                      int               block_size_samples,                      HANDLE_RESILIENCE hResilience,                      HANDLE_BUFFER     hVm,                       HANDLE_EP_INFO    hEpInfo ){  int i, j, tag;  tag = GetBits(ELEMENT_INSTANCE_TAG,                 LEN_TAG,                hResilience,                hVm,                 hEpInfo );  p->profile = GetBits(PROFILE,                        LEN_PROFILE,                       hResilience,                       hVm,                        hEpInfo );  p->sampling_rate_idx = GetBits(SAMPLING_FREQUENCY_INDEX,                                  LEN_SAMP_IDX,                                 hResilience,                                 hVm,                                  hEpInfo );  p->front.num_ele = GetBits(NUM_FRONT_CHANNEL_ELEMENTS,                              LEN_NUM_ELE,                             hResilience,                             hVm,                              hEpInfo );  p->side.num_ele = GetBits(NUM_SIDE_CHANNEL_ELEMENTS,                             LEN_NUM_ELE,                            hResilience,                            hVm,                             hEpInfo );  p->back.num_ele = GetBits(NUM_BACK_CHANNEL_ELEMENTS,                             LEN_NUM_ELE,                            hResilience,                            hVm,                             hEpInfo );  p->lfe.num_ele = GetBits(NUM_LFE_CHANNEL_ELEMENTS,                            LEN_NUM_LFE,                           hResilience,                           hVm,                            hEpInfo );  p->data.num_ele = GetBits(NUM_ASSOC_DATA_ELEMENTS,                             LEN_NUM_DAT,                            hResilience,                            hVm,                             hEpInfo );  p->coupling.num_ele = GetBits(NUM_VALID_CC_ELEMENTS,                                 LEN_NUM_CCE,                                hResilience,                                hVm,                                 hEpInfo );  if ((p->mono_mix.present = GetBits(MONO_MIXDOWN_PRESENT,                                      LEN_MIX_PRES,                                     hResilience,                                     hVm,                                      hEpInfo )) == 1)    p->mono_mix.ele_tag = GetBits(MONO_MIXDOWN_ELEMENT_NUMBER,                                   LEN_TAG,                                  hResilience,                                  hVm,                                   hEpInfo );  if ((p->stereo_mix.present = GetBits(STEREO_MIXDOWN_PRESENT,                                        LEN_MIX_PRES,                                       hResilience,                                       hVm,                                        hEpInfo )) == 1)    p->stereo_mix.ele_tag = GetBits(STEREO_MIXDOWN_ELEMENT_NUMBER,                                     LEN_TAG,                                    hResilience,                                    hVm,                                     hEpInfo );  if ((p->matrix_mix.present = GetBits(MATRIX_MIXDOWN_IDX_PRESENT,                                        LEN_MIX_PRES,                                       hResilience,                                       hVm,                                        hEpInfo )) == 1) {    p->matrix_mix.ele_tag = GetBits(MATRIX_MIXDOWN_IDX,                                     LEN_MMIX_IDX,                                    hResilience,                                    hVm,                                     hEpInfo );    p->matrix_mix.pseudo_enab = GetBits(PSEUDO_SURROUND_ENABLE,                                         LEN_PSUR_ENAB,                                        hResilience,                                        hVm,                                         hEpInfo );  }  /* front_channel_elements */  get_ele_list(&p->front,                1,                hResilience,               hVm,                hEpInfo );  /* side_channel_elements */  get_ele_list(&p->side,                1,               hResilience,               hVm,                 hEpInfo );  /* back_channel_elements */  get_ele_list(&p->back,                1,               hResilience,               hVm,                 hEpInfo );  /* lfe_channel_elements */  get_ele_list(&p->lfe,                0,               hResilience,               hVm,                 hEpInfo );  /* assoc_data_elements */  get_ele_list(&p->data,                0,               hResilience,               hVm,                 hEpInfo );  /* valid_cc_elements */  get_ele_list(&p->coupling,                1,               hResilience,               hVm,                 hEpInfo );      byte_align();  j = GetBits(COMMENT_FIELD_BYTES,               LEN_COMMENT_BYTES,              hResilience,              hVm,               hEpInfo );  for (i=0; i<j; i++)    p->comments[i] = GetBits(COMMENT_FIELD_DATA,                              LEN_BYTE,                             hResilience,                             hVm,                              hEpInfo );  p->comments[i] = 0;	/* null terminator for string */  /* activate new program configuration if appropriate */  if (current_program < 0)    current_program = tag;	    /* always select new program */  if (tag == current_program) {    /* enter configuration into MC_Info structure */    if (enter_mc_info(&mc_info, p,block_size_samples, hEpInfo, hResilience ) < 0)      return -1;    /* inhibit default configuration */    default_config = 0;  }     return tag;}/* enter program configuration into MC_Info structure *  only configures for channels specified in all.h */int enter_mc_info ( MC_Info*          mip,                     ProgConfig*       pcp,                    int               block_size_samples,                     HANDLE_EP_INFO    hEpInfo,                    HANDLE_RESILIENCE hResilience ){    int i, j, cpe, tag, cw;  EleList *elp;  MIXdown *mxp;  /* reset channel counts */  mip->nch = 0;  mip->nfch = 0;  mip->nfsce = 0;  mip->nsch = 0;  mip->nbch = 0;  mip->nlch = 0;  mip->ncch = 0;  /* profile and sampling rate   *	re-configure if new sampling rate   */      mip->profile = pcp->profile;  if (mip->sampling_rate_idx != pcp->sampling_rate_idx) {    mip->sampling_rate_idx = pcp->sampling_rate_idx;    infoinit(&samp_rate_info[mip->sampling_rate_idx],block_size_samples);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -