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

📄 pcodecs.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
字号:
/* Copyright (C) 2007 ROCK-CHIPS FUZHOU . All Rights Reserved. */
/*
File : \Audio\common\pCODECS.c
Desc : 音频CODEC管理

Author : FSH
Date :   2007-06-01
Notes :

$Log :
* FSH         2007/06/01 建立此文件
*
* Vincent Hisung    2007/07/xx 修改
*
*/
/****************************************************************/
#include "include.h"
#include "../include/audio_globals.h"

//临时函数
unsigned long
M3UFunction(unsigned long ulSubFn, unsigned long ulParam1, unsigned long ulParam2,
            unsigned long ulParam3, unsigned long ulParam4)
{
    return 0;
}

//函数指针数组
//提供多CODEC统一调用接口
//注意! 排列顺序务必与include/globals.h中CODEC_XXX枚举中顺序相对应!
static unsigned long(* const DecodePFn[NUMCODECS])(unsigned long ulSubFn,
        unsigned long ulParam1,
        unsigned long ulParam2,
        unsigned long ulParam3,
        unsigned long ulParam4) =
{
#ifdef BOARD //080619,HUANGSL,FOR pc 仿真.
#ifdef MP3_INCLUDE
    MP3Function,
#endif
#ifdef WMA_INCLUDE
    WMAFunction,
#endif
#ifdef  MP2_INCLUDE
    MP2Function,
#endif
#ifdef OGG_DEC_INCLUDE
    OggDecFunction,
#endif
#ifdef WAV_INCLUDE
    PCMFunction,
#endif
#ifdef MP4_INCLUDE
    MPEG4AudioFunction,
#endif
#ifdef M3U_INCLUDE
    M3UFunction,
#endif
// #ifdef ADPCM_INCLUDE
// MSADPCMFunction,
// #endif
#ifdef MP3_ENC_INCLUDE
    MP3EncFunction,
#endif
#ifdef WMA_ENC_INCLUDE
    WMAEncFunction,
#endif
#ifdef RM_DEC_INCLUDE //added by vincent
    RMFunction,
#endif
#ifdef APE_DEC_INCLUDE //added by hxd 20070710
    APEDecFunction,
#endif
#ifdef FLAC_DEC_INCLUDE //注册flacdec接口函数名,通过接口索引CODEC_FLAC_DEC来定位 added by hxd 20070717
    FLACDecFunction,
#endif
#ifdef AAC_DEC_INCLUDE
    AACDecFunction,
#endif
#ifdef AC3_DEC_INCLUDE //AC3接口
    AC3DecFunction,
#endif
#ifdef AMR_INCLUDE
    AMRFunction,
#endif
#else
    M3UFunction		//080619,huangsl,PC仿真,空函数.
#endif

};



//****************************************************************************
//
// CodecOpen opens a codec.  For decoders, the type of the current file is
// determined and used to determine the codec to open.  For encoders, the
// specified codec is opened.
//
//****************************************************************************
/******************************************************
Name:  CodecOpen
Desc:  打开CODEC准备编解码
Param: ulCodec -> CODEC编号(CODEC_XXX枚举)
    ulFlags -> 1. 打开解码器 SUBFN_CODEC_OPEN_DEC
          2. 打开编码器 CODEC_OPEN_ENCODE
          3. 打开播放列表 CODEC_OPEN_PLAYLIST 【未实现】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecOpen(unsigned long ulCodec, unsigned long ulFlags)
{
    unsigned long ulRet, ulOffset = 0;
    if (ulFlags & CODEC_OPEN_DECODE)
    {
        // Pass the open request to the entry point for the codec.
        ulRet = (DecodePFn[CurrentCodec])(SUBFN_CODEC_OPEN_DEC, ulEndOfRAM, ulOffset,
                                          ulFlags, 0);
    }
#if defined(MP3_ENC_INCLUDE)  || defined(ADPCM_ENC_INCLUDE) || defined(PCM_ENC_INCLUDE)
    else if (ulFlags & CODEC_OPEN_ENCODE)
    {
        ulRet = (DecodePFn[CurrentCodec])(SUBFN_CODEC_OPEN_ENC, ulEndOfRAM, ulOffset,
                                          ulFlags, 0);
    }
    else if (ulFlags & CODEC_OPEN_PLAYLIST)
    {
        return 0;
    }
#endif
    // Return the result to the caller.
    return(ulRet);
}

/******************************************************
Name:  CodecDecode
Desc:  调用CODEC解码
Param: 无
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecDecode(void)
{
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_DECODE, ulEndOfRAM,
                                     0, 0, 0));
}

/******************************************************
Name:  CodecSeek
Desc:  CODEC定位播放位置
Param: ulTime -> 定位时间 【单位:毫秒】
    ulSeekType -> 类型 【未启用】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecSeek(unsigned long ulTime, unsigned long ulSeekType)
{
    // Pass the seek request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_SEEK, ulEndOfRAM, ulTime, ulSeekType,
                                     0));
}

/******************************************************
Name:  CodecGetTime
Desc:  CODEC当前播放位置
Param: pulTime -> 当前时间指针 【回写】 【单位:毫秒】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecGetTime(unsigned long *pulTime)
{
    // Pass the time request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETTIME, ulEndOfRAM,
                                     (unsigned long)pulTime, 0, 0));
}
unsigned long CodecGetStoreTime(unsigned long *pulTime)
{
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_STORETIME, ulEndOfRAM,
                                     (unsigned long)pulTime, 0, 0));
}

/******************************************************
Name:  CodecGetBitrate
Desc:  当前曲目码率
Param: pulBitrate -> 码率指针 【回写】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecGetBitrate(unsigned long *pulBitrate)
{
    // Pass the bitrate request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETBITRATE, ulEndOfRAM,
                                     (unsigned long)pulBitrate, 0, 0));
}

/******************************************************
Name:  CodecGetSampleRate
Desc:  当前曲目采样率
Param: pulSampleRate -> 采样率指针 【回写】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecGetSampleRate(unsigned long *pulSampleRate)
{
    // Pass the sample rate request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETSAMPLERATE, ulEndOfRAM,
                                     (unsigned long)pulSampleRate, 0, 0));
}

/******************************************************
Name:  CodecGetChannels
Desc:  当前曲目声道数目
Param: pulChannels -> 声道数指针 【回写】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecGetChannels(unsigned long *pulChannels)
{
    // Pass the channels request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETCHANNELS, ulEndOfRAM,
                                     (unsigned long)pulChannels, 0, 0));
}

/******************************************************
Name:  CodecGetLength
Desc:  当前曲目时长
Param: pulLength -> 时长指针 【回写】 【单位:毫秒】
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecGetLength(unsigned long *pulLength)
{
    // Pass the length request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETLENGTH, ulEndOfRAM,
                                     (unsigned long)pulLength, 0, 0));
}

/******************************************************
Name:  CodecSetBuffer
Desc:  设置缓冲区
Param: psBuffer -> 缓冲区状态指针
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecSetBuffer(BufferState *psBuffer)
{
    // Pass the set buffer request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_SETBUFFER, ulEndOfRAM,
                                     (unsigned long)psBuffer, 0, 0));
}

/******************************************************
Name:  CodecClose
Desc:  关闭CODEC
Param: 无
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecClose(void)
{
    unsigned long ulRet;
    {
        // Pass the close request to the entry point for the specified codec.
        ulRet = (DecodePFn[CurrentCodec])(SUBFN_CODEC_CLOSE, ulEndOfRAM,
                                          CODEC_OPEN_ENCODE, 0, 0);    // will be change
    }
    // Return the result to the caller.
    //
    return(ulRet);
}

/******************************************************
Name:  CodecGetCaptureBuffer
Desc:  设置捕获缓冲
Param: ppsBuffer -> 指向缓冲区状态指针的指针
    plLength  -> 缓冲区长度
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
/*
unsigned long
CodecGetCaptureBuffer(short **ppsBuffer, long *plLength)
{
 // Pass the get capture buffer request to the entry point for the specified
 // codec.
 return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETCAPTUREBUFFER, ulEndOfRAM,
          (unsigned long)ppsBuffer,
          (unsigned long)plLength, 0));
}
*/
/******************************************************
Name:  CodecEncode
Desc:  CODEC编码
Param: 无
Return: 1-成功 0-失败
Global: 无
Note:  无
Author: FSH,Vincent Hisung
Log:
******************************************************/
unsigned long
CodecEncode(void)
{
    // Pass the encode request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_ENCODE, ulEndOfRAM, 0, 0,
                                     0));
}

#if ROCK_CAMERA
unsigned long
CodecDvEncode(void)
{
    // Pass the encode request to the entry point for the specified codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_DVENCODE, ulEndOfRAM, 0, 0,
                                      0));
}
#endif

unsigned long
CodecGetCaptureBuffer(short **LppsBuffer, short **RppsBuffer,  long *plLength)
{
    // Pass the get capture buffer request to the entry point for the specified
    // codec.
    return((DecodePFn[CurrentCodec])(SUBFN_CODEC_GETCAPTUREBUFFER, ulEndOfRAM,
                                     (unsigned long)LppsBuffer,
                                     (unsigned long)RppsBuffer, (unsigned long) plLength));
}



⌨️ 快捷键说明

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