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

📄 prmdec.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
                    * arbitrarily choose substream 0 here.
                    */
                    ulCodec4CC = ra_depack_get_codec_4cc(pDepack_a, 0);

                    rmaudiocodec4cc = ulCodec4CC;
                    /* Create the ra_decode object */
                    pDecode_a = ra_decode_create(HXNULL, rm2wav_error);
                    if (!pDecode_a)
                    {
                        goto cleanup;
                    }

                    /* Assign the decode object into the rm2wav_info struct */
                    info_a.pDecode = pDecode_a;

                    /*
                    * Get the bitstream header information. Again,
                    * we arbitrarily choose substream 0.
                    */
                    retVal = ra_depack_get_codec_init_info(pDepack_a, 0, &pInfo_a);
                    if (retVal != HXR_OK)
                    {
                        goto cleanup;
                    }

                    /* Init the ra_decode object */
                    retVal = ra_decode_init(pDecode_a, ulCodec4CC, HXNULL, 0, pInfo_a);
                    if (retVal != HXR_OK)
                    {
                        goto cleanup;
                    }

                    /* Get the maximum number of output samples */
                    retVal = ra_decode_getmaxsize(pDecode_a, &ulMaxSamples);

                    if (retVal != HXR_OK)
                    {
                        goto cleanup;
                    }

                    /* Get the number of channels */
                    retVal = ra_decode_getchannels(pDecode_a, &ulChannels);
                    if (retVal != HXR_OK)
                    {
                        goto cleanup;
                    }

                    /* Get the sample rate */
                    retVal = ra_decode_getrate(pDecode_a, &ulSampleRate);
                    if (retVal != HXR_OK)
                    {
                        goto cleanup;
                    }

                    /* Compute the size of the output buffer */
                    ulOutBufSize = ulMaxSamples * sizeof(UINT16);

                    /* Allocate an output buffer */
                    pOutBuf = (BYTE*) malloc(ulOutBufSize);
                    rm_OutLeft = (short *)malloc(ulOutBufSize);
                    rm_OutRight = (short *)malloc(ulOutBufSize);
                    if (!pOutBuf)
                    {
                        goto cleanup;
                    }

                    /* Assign the output frame into the info_a struct */
                    info_a.pOutBuf      = pOutBuf;
                    info_a.ulOutBufSize = ulOutBufSize;

                    /* get the max size of packet */
                    {
                        unsigned long ulMaxPacket = rm_parser_get_max_packet_size(pParser);
                        p_decode_a_new_packetData_a = malloc(ulMaxPacket);
                        //maxPacketSize = ulMaxPacket;
                    }
                    //Vincent Hisung : Test for speed up SEEK
                    if (HXR_OK == rm_parser_seek(pParser, rm_parser_get_duration(pParser)))
                    {
                        ra_seekable = 1;
                    }
                    else
                    {
                        ra_seekable = 0;
                    }
                    rm_parser_seek(pParser, 0);

                    {
                        rm_parser_internal* ptmp = (rm_parser_internal*)pParser;
                        rm_parseri_file_seek(ptmp, ptmp->propHdr.data_offset  +
                                             18, 0);
                    }
                }
                //Vincent Hisung : Test for speed up SEEK
                /*rm_parser_seek(pParser,rm_parser_get_duration(pParser));
                rm_parser_seek(pParser,0);
                }*/
                else
                {
                    //Bug Fix: No Audio Stream :( By Vincent Hisung ,Dec 06,2007
                    goto cleanup;
                }
                //------------------------------------------------------
                return(1);//return success message.
cleanup:
                /* If we have a packet, destroy it */
                if (pPacket)
                {
                    rm_parser_destroy_packet(pParser, &pPacket);
                }
                /* Destroy the stream header */
                if (pHdr_a)
                {
                    rm_parser_destroy_stream_header(pParser, &pHdr_a);
                }

                if (pDepack_a)
                {
                    ra_depack_destroy(pDepack_a);
                    pDepack_a = NULL;
                }

                /* Destroy the ra_decode object */
                if (pDecode_a)
                {
                    ra_decode_destroy(pDecode_a);
                    pDecode_a = HXNULL;
                }

                if (pOutBuf != NULL)
                {
                    free(pOutBuf);
                    pOutBuf = NULL;
                }
                if (rm_OutLeft != NULL)
                {
                    free(rm_OutLeft);
                    rm_OutLeft = NULL;
                }
                if (rm_OutRight != NULL)
                {
                    free(rm_OutRight);
                    rm_OutRight = NULL;
                }
                /* Destroy the parser */
                if (pParser)
                {
                    rm_parser_destroy(&pParser);
                }

                return (0);//return error
            }

            // Seek to the specified time position.
        case SUBFN_CODEC_SEEK:
            {
                //ulTime
                //The time, in milliseconds, to which the parser will seek.
                if (HXR_OK == rm_parser_seek_sp(pParser, ulParam2, usStreamNum_a))
                {
                    ra_seek_to_time = ulParam2;

                    IS_RA_BLOCK_SEND = 0 ;
                    IS_RA_BLOCK_SEND2 = 0 ;
                    g_VT_ulNumAU = 0;

                    //Bug Fix. Nov 30,2007
                    //By Vincent Hisung
                    {
                        ra_depack_internal* pInt = pDepack_a;
                        ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[0];
                        //decode_a_i = 0;
                        //pHdr->ulBlockCount = 0;
                        pHdr->ulKeyTime = 0; //Important, KEY Time ! :(

                        decode_a_i = 0;
                        decode_a_ulTimeOffset = 0;
                        decode_a_ulTimestamp  = 0;
                        decode_a_dTimeOffset  = 0.0;
                        pHdr->ulBlockCount = 0;
                        /* Clear the interleaving buffers */
                        if (pHdr->pIBuffer)
                            memset(pHdr->pIBuffer, 0, pHdr->ulSuperBlockSize);
                        if (pHdr->pDBuffer)
                            memset(pHdr->pDBuffer, 0, pHdr->ulSuperBlockSize);
                        if (pHdr->pIPresentFlags)
                            memset(pHdr->pIPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
                        if (pHdr->pDPresentFlags)
                            memset(pHdr->pDPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
                        /* Clear the state */
                        pHdr->bHasKeyTime  = FALSE;
                        pHdr->ulKeyTime    = 0;
                        pHdr->ulBlockCount = 0;
                    }

                    // Success.
                    return(1);
                }
                else
                {
                    ra_seek_to_time = 0;
                    // Failed.
                    return(0);
                }
            }

            // Return the current position (in milliseconds) within the file.
        case SUBFN_CODEC_GETTIME:
            {
                (*(unsigned long *)ulParam2) = ulCurrentTime;
                // Success.
                return(1);
            }

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

                pSampleRate = (unsigned long *)ulParam2;

                ra_decode_getrate(info_a.pDecode,
                                  (UINT32*)pSampleRate); //&pSampleRate);

                // Success.
                return(1);

            }

            // Return the number of channels in the file.
        case SUBFN_CODEC_GETCHANNELS:
            {
                // The second parameter is a pointer for the number of channels.
                // Return the number of channels in the file.
                ra_decode_getchannels(info_a.pDecode,
                                      (UINT32*)ulParam2);
                // Success.
                return(1);
            }

            // Return the bitrate at which this file is encoded.
        case SUBFN_CODEC_GETBITRATE:
            {
                //(*(unsigned long *)ulParam2)=rm_parser_get_avg_bit_rate(pParser);//ulAbr;
                (*(unsigned long *)ulParam2) = pHdr_a->ulAvgBitRate;
                // Success.
                return(1);
            }

            // Return the length (in milliseconds) of the file.
        case SUBFN_CODEC_GETLENGTH:
            {
                //Returns the total duration, in milliseconds, of the stream in the file.
                (*(unsigned long *)ulParam2) = rm_parser_get_duration(pParser);
                // Success.
                return(1);
            }

            // Set the output buffer for the decoder.
        case SUBFN_CODEC_SETBUFFER:
            {
                //TODO
                // Success.
                return(1);
            }

        case SUBFN_CODEC_GETCAPTUREBUFFER:
            {
                *(unsigned long *)ulParam2 = (unsigned long) rm_OutLeft ;
                *(unsigned long *)ulParam3 = (unsigned long) rm_OutRight;
                *(unsigned long *)ulParam4 = (unsigned long) OutLength ;

                //success
                return(1);
            }


            // Cleanup after the codec.
        case SUBFN_CODEC_CLOSE:
            {

                if (pInfo_a)
                {
                    ra_depack_destroy_codec_init_info(pDepack_a, &pInfo_a);
                }

                /*  will be freed in rm_parser_destroy_packet
                if (p_decode_a_new_packetData_a)
                {
                free(p_decode_a_new_packetData_a);
                p_decode_a_new_packetData_a = NULL;
                          }
                    */

                if (decode_a_Block.pData)
                {
                    free(decode_a_Block.pData);
                }



                if (pDepack_a)
                {
                    ra_depack_destroy(&pDepack_a);
                    pDepack_a = NULL;
                }

                /* If we have a packet, destroy it */
                if (pPacket)
                {
                    rm_parser_destroy_packet(pParser, &pPacket);
                }
                /* Destroy the stream header */
                if (pHdr_a)
                {
                    rm_parser_destroy_stream_header(pParser, &pHdr_a);
                }
                /* Destroy the ra_decode object */
                if (pDecode_a)
                {
                    ra_decode_destroy(pDecode_a);
                    pDecode_a = HXNULL;
                }
                /* Destroy the parser */
                if (pParser)
                {
                    rm_parser_destroy(&pParser);
                }
                if (pOutBuf != NULL)
                {
                    free(pOutBuf);
                    pOutBuf = NULL;
                }
                if (rm_OutLeft != NULL)
                {
                    free(rm_OutLeft);
                    rm_OutLeft = NULL;
                }
                if (rm_OutRight != NULL)
                {
                    free(rm_OutRight);
                    rm_OutRight = NULL;
                }

                return (1);
            }

        default:
            {
                // Return a failure.
                return(0);
            }
    }
}
int GetIsRASeekable(void)
{
    return ra_seekable;
}

⌨️ 快捷键说明

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