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

📄 pwmadec.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2007 ROCK-CHIPS FUZHOU . All Rights Reserved. */
/*
File : \Audio\WMADec
Desc : WMA解码。

Author : fsh , Vincent Hisung
Date : 2007-08-xx
Notes : 功能尚未完整实现[可搜索TODO]

$Log :
* fsh        2007/08/xx 建立此文件
*
* vincent     2007/08/xx
*
*/
/****************************************************************/

#include "../include/audio_main.h"
#include "../include/file_access.h"

#ifdef WMA_INCLUDE
#include "../include/audio_globals.h"
#include "../buffer/buffer.h"
#include "../id3/id3.h"
#include "WmaDec.h"

extern    unsigned int  g_fDeviceResetState;
extern  void RK_PB_SetLocking(void);
extern  void RK_PB_SetUnlocking(void);
extern  struct _WMATag ID3_WMATag;
extern  cStartDec;

extern sPlayBuffer;
extern int RK_WMA_DecCheckSpec(tWMAGlobal*, tWMAFileHeader*);

//输出缓冲区大小
#define WMA_MAX_PCM_LENGTH            2048*4*2//2048*2 MOD BY VINCENT
#define MAX_SIZE_SERIAL_NUMBER      32

#if 1
unsigned char g_pmid[16] =
    /*{
        0x3233, 0x4445, 0x3845, 0x3241, 0x3934,
        0x4544, 0x4343, 0x3046
    };*/
{
    0x32, 0x33, 0x44, 0x45, 0x38, 0x45, 0x32, 0x41,
    0x39, 0x34, 0x45, 0x44, 0x43, 0x43, 0x30, 0x46
};
#else
extern unsigned char g_pmid[16];
#endif

#define MAX_SAMPLES     1024
#define pENCODED_DATA  (pWMA->pucWMAData)
#define STRING_SIZE     128

extern  unsigned char *pStartStruct;
static short * wma_psLeft;
static short * wma_psRight;
static long OutLength;

//****************************************************************************
//
// A structure which defines the persistent state of the WMA decoder.
//
//****************************************************************************
typedef struct
{
    // The persistent internal state of the WMA decoder library.  This must be
    // the first member of this structure.
    tWMAFileState sWMAState;

    // The file from which we read data.
    //tFile *pFile;

    // A buffer to contain the WMA file contents
    unsigned char pucWMAData[MAX_SAMPLES];

    // The offset of the data currently in the pucWMAData buffer.
    tWMA_U32 dwOffset;

    // The length of the data currently in the pucWMAData buffer.
    tWMA_U32 dwLength;

    // Buffers to contain the decoded WMA audio.
    short psLeft[WMA_MAX_PCM_LENGTH];
    short psRight[WMA_MAX_PCM_LENGTH];

    // The buffer to which we write decoded WMA audio.
    BufferState *pOutput;

    // The number of samples that have been played.
    tWMA_U32 dwTimePos;

    // The sample rate of the decoded PCM data.
    tWMA_U32 dwSampleRate;

    // The file header information structure.
    tWMAFileHeader sWMAHeader;

    // The file content descriptor structure.
    tWMAFileContDesc sWMADesc;

    // A buffer to contain the song title.
    unsigned char pucTitle[STRING_SIZE];

    // A buffer to contain the song author.
    unsigned char pucAuthor[STRING_SIZE];

    // A boolean that is true when there is more PCM data to be decoded for
    // the current WMA frame.
    tWMA_U32 bMorePCMToGenerate;
#ifdef WMV_INCLUDE
    int  fd_handle;
#endif
} tWMA;

//****************************************************************************
//
// The codec plug-in entry point for the WMA decoder.
//
//****************************************************************************
//功能实现情况:
//SUBFN_CODEC_GETNAME  :   得到解码器名称
//SUBFN_CODEC_GETARTIST:   得到艺术家名称
//SUBFN_CODEC_GETTITLE :   得到曲名
//SUBFN_CODEC_GETBITRATE:  得到码率
//SUBFN_CODEC_GETSAMPLERATE: 得到采样率
//SUBFN_CODEC_GETCHANNELS: 得到声道数目
//SUBFN_CODEC_GETLENGTH :  得到时长 [单位:毫秒]
//SUBFN_CODEC_GETTIME  :   得到当前播放时间 [单位:毫秒]
//SUBFN_CODEC_OPEN_DEC :   打开解码器(初始化)
//SUBFN_CODEC_DECODE   :   解码
//SUBFN_CODEC_ENCODE   :   不支持
//SUBFN_CODEC_SEEK     :   按时间直接定位 [单位:毫秒]
//SUBFN_CODEC_CLOSE    :   关闭解码器
/******************************************************
Name:  WMAFunction
Desc:  WMA解码器接口函数
Param: ulIoctl 子功能号
    ulParam1 子功能参数1
    ulParam2 子功能参数2
    ulParam3 子功能参数3
    ulParam4 子功能参数4

Return: 0-失败 1-成功
Global: 无
Note: 无
Author: FSH
Log:
******************************************************/
int WMAfft;
unsigned long
WMAFunction(unsigned long ulSubFn, unsigned long ulParam1, unsigned long ulParam2,
            unsigned long ulParam3, unsigned long ulParam4)
{
    unsigned int i;

    switch (ulSubFn)
    {
            // Return the name for this codec.
        case SUBFN_CODEC_GETNAME:
            {
                char **ppcName;

                // The secod parameter is a pointer for the name.
                ppcName = (char **)ulParam2;

                // Return the name of this codec.  The first four characters are
                // the short name and the string starting at the fifth character
                // is the long name.
                *ppcName = "WMA Windows Media(tm) Audio";

                // Success.
                return(1);
            }

            // Return the name of the artist.
        case SUBFN_CODEC_GETARTIST:
            {
                char **ppcName;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the name.
                ppcName = (char **)ulParam2;

                // Return the name of the artist.
                *ppcName = (char *)pWMA->pucAuthor;

                // Success.
                return(1);
            }

            // Return the name of the song
        case SUBFN_CODEC_GETTITLE:
            {
                char **ppcName;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the name.
                ppcName = (char **)ulParam2;

                // Return the name of the song.
                *ppcName = (char *)pWMA->pucTitle;

                // Success.
                return(1);
            }

            // Return the bitrate at which this file is encoded.
        case SUBFN_CODEC_GETBITRATE:
            {
                unsigned long *pulBitRate;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the bitrate.
                pulBitRate = (unsigned long *)ulParam2;

                // Return the average bitrate of the file.
                *pulBitRate = pWMA->sWMAHeader.bitrate;

                // Success.
                return(1);
            }

            // Return the sample rate at which this file is encoded.
        case SUBFN_CODEC_GETSAMPLERATE:
            {
                unsigned long *pulSampleRate;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the sample rate.
                pulSampleRate = (unsigned long *)ulParam2;

                // Return the sample rate of the file.
                *pulSampleRate = pWMA->dwSampleRate;

                // Success.
                return(1);
            }

            // Return the number of channels in the file.
        case SUBFN_CODEC_GETCHANNELS:
            {
                unsigned long *pulChannels;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the number of channels.
                pulChannels = (unsigned long *)ulParam2;

                // Return the number of channels in the file.
                *pulChannels = pWMA->sWMAHeader.num_channels;

                // Success.
                return(1);
            }

            // Return the length (in milliseconds) of the file.
        case SUBFN_CODEC_GETLENGTH:
            {
                unsigned long *pulLength;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the number of
                // milliseconds.
                pulLength = (unsigned long *)ulParam2;

                // Return the length of the file.
                *pulLength = pWMA->sWMAHeader.duration;

                // Success.
                return(1);
            }

            // Return the current position (in milliseconds) within the file.
        case SUBFN_CODEC_GETTIME:
            {
                unsigned long *pulTime;
                tWMA *pWMA;

                // The first parameter is a pointer to the WMA persistent data.
                pWMA = (tWMA *)ulParam1;

                // The second parameter is a pointer for the number of
                // milliseconds.
                pulTime = (unsigned long *)ulParam2;

                // Determine the time based on the sample rate.
                *pulTime = ((pWMA->dwTimePos / pWMA->dwSampleRate) * 1000) +
                           (((pWMA->dwTimePos % pWMA->dwSampleRate) * 1000) /
                            pWMA->dwSampleRate);


                // Success.
                return(1);
            }

            // Prepare the codec to encode or decode a file.
        case SUBFN_CODEC_OPEN_DEC:
            {

                tWMA *pWMA;
                tWMAFileLicParams sDeviceID;
                unsigned int test;

                unsigned char *pPBCtxt;
                int iPBID, BeingPBed;

                {
                    cStartDec = 1;
                }

                BeingPBed = 0;
                pPBCtxt = NULL;
                iPBID = 0x80000000;

                //

⌨️ 快捷键说明

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