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

📄 amrdecode.cpp

📁 实现3GPP的GSM中AMR语音的CODECS。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
         mode = 0         FOR i = 0 TO NUM_AMRSID_RXMODE_BITS-1             mode |= (dec_ets_input_bfr[AMRSID_RXMODE_BIT_OFFSET+i] << i)         ENDFOR         IF (dec_ets_input_bfr[AMRSID_RXTYPE_BIT_OFFSET] == 0)         THEN             rx_type = RX_SID_FIRST         ELSE             rx_type = RX_SID_UPDATE         ENDIF     ELSEIF ((frame_type > AMR_SID) && (frame_type < NO_DATA))     THEN         // Use previous mode         mode = decoder_state->prev_mode         // Unsupported SID frames         rx_type = RX_SPEECH_BAD;     ELSE         // Use previous mode         mode = decoder_state->prev_mode         // No data received         rx_type = RX_NO_DATA;     ENDIF // Decode ETS frames ELSEIF (input_format == AMR_RX_ETS) THEN     // Change type of pointer to incoming raw ETS data     ets_word_ptr = (Word16 *) speech_bits_ptr     // Get RX frame type     rx_type = (enum RXFrameType) *ets_word_ptr     ets_word_ptr = ets_word_ptr + 1     // Copy incoming raw ETS data to dec_ets_input_bfr     FOR i = 0 TO MAX_SERIAL_SIZE-1         dec_ets_input_bfr[i] = *ets_word_ptr         ets_word_ptr = ets_word_ptr + 1     ENDFOR     // Get codec mode     IF (rx_type != RX_NO_DATA)     THEN         mode = (enum Mode) *ets_word_ptr     ELSE         //Use previous mode if no received data         mode = decoder_state->prev_mode     ENDIF     // Set up byte_offset     byte_offset = 2*(MAX_SERIAL_SIZE+2) ELSE     // Invalid format, return error code     byte_offset = -1 ENDIF // Proceed with decoding frame, if there are no errors IF (byte_offset != -1) THEN     // Decode a 20 ms frame     CALL GSMFrameDecode( st = decoder_state                          mode = mode                          serial = dec_ets_input_bfr,                          frame_type = rx_type,                          synth = (Word16 *)raw_pcm_buffer);       MODIFYING (nothing)       RETURNING (Nothing)     // Save mode for next frame     decoder_state->prev_mode = mode ENDIF RETURN (byte_offset)------------------------------------------------------------------------------ RESOURCES USED [optional] When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable                used to represent cycle count for each subroutine                called)     where: (cycle count variable) = cycle count for [subroutine                                     name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/Word16 AMRDecode(    void                      *state_data,    enum Frame_Type_3GPP      frame_type,    UWord8                    *speech_bits_ptr,    Word16                    *raw_pcm_buffer,    bitstream_format          input_format){    Word16 *ets_word_ptr;    enum Mode mode = (enum Mode)MR475;    int modeStore;    int tempInt;    enum RXFrameType rx_type = RX_NO_DATA;    Word16 dec_ets_input_bfr[MAX_SERIAL_SIZE];    Word16 i;    Word16 byte_offset = -1;    /* Type cast state_data to Speech_Decode_FrameState rather than passing     * that structure type to this function so the structure make up can't     * be viewed from higher level functions than this.     */    Speech_Decode_FrameState *decoder_state    = (Speech_Decode_FrameState *) state_data;    /* Determine type of de-formatting */    /* WMF or IF2 frames */    if ((input_format == MIME_IETF) | (input_format == IF2))    {        if (input_format == MIME_IETF)        {            /* Convert incoming packetized raw WMF data to ETS format */            wmf_to_ets(frame_type, speech_bits_ptr, dec_ets_input_bfr);            /* Address offset of the start of next frame */            byte_offset = WmfDecBytesPerFrame[frame_type];        }        else if (input_format == IF2)        {            /* Convert incoming packetized raw IF2 data to ETS format */            if2_to_ets(frame_type, speech_bits_ptr, dec_ets_input_bfr);            /* Address offset of the start of next frame */            byte_offset = If2DecBytesPerFrame[frame_type];        }        /* At this point, input data is in ETS format     */        /* Determine AMR codec mode and AMR RX frame type */        if (frame_type <= AMR_122)        {            mode = (enum Mode) frame_type;            rx_type = RX_SPEECH_GOOD;        }        else if (frame_type == AMR_SID)        {            /* Clear mode store prior to reading mode info from input buffer */            modeStore = 0;            for (i = 0; i < NUM_AMRSID_RXMODE_BITS; i++)            {                tempInt = dec_ets_input_bfr[AMRSID_RXMODE_BIT_OFFSET+i] << i;                modeStore |= tempInt;            }            mode = (enum Mode) modeStore;            /* Get RX frame type */            if (dec_ets_input_bfr[AMRSID_RXTYPE_BIT_OFFSET] == 0)            {                rx_type = RX_SID_FIRST;            }            else            {                rx_type = RX_SID_UPDATE;            }        }        else if ((frame_type > AMR_SID) && (frame_type < AMR_NO_DATA))        {            /* Invalid frame_type, return error code */            byte_offset = -1;   /*  !!! */        }        else        {            mode = decoder_state->prev_mode;            /*             * RX_NO_DATA, generate exponential decay from latest valid frame for the first 6 frames             * after that, create silent frames             */            rx_type = RX_NO_DATA;        }    }    /* ETS frames */    else if (input_format == ETS)    {        /* Change type of pointer to incoming raw ETS data */        ets_word_ptr = (Word16 *) speech_bits_ptr;        /* Get RX frame type */        rx_type = (enum RXFrameType) * ets_word_ptr;        ets_word_ptr++;        /* Copy incoming raw ETS data to dec_ets_input_bfr */        for (i = 0; i < MAX_SERIAL_SIZE; i++)        {            dec_ets_input_bfr[i] = *ets_word_ptr;            ets_word_ptr++;        }        /* Get codec mode */        if (rx_type != RX_NO_DATA)        {            /* Get mode from input bitstream */            mode = (enum Mode) * ets_word_ptr;        }        else        {            /* Use previous mode if no received data */            mode = decoder_state->prev_mode;        }        /* Set up byte_offset */        byte_offset = 2 * (MAX_SERIAL_SIZE + 2);    }    else    {        /* Invalid input format, return error code */        byte_offset = -1;    }    /* Proceed with decoding frame, if there are no errors */    if (byte_offset != -1)    {        /* Decode a 20 ms frame */#ifndef CONSOLE_DECODER_REF        /* Use PV version of sp_dec.c */        GSMFrameDecode(decoder_state, mode, dec_ets_input_bfr, rx_type,                       raw_pcm_buffer);#else        /* Use ETS version of sp_dec.c */        Speech_Decode_Frame(decoder_state, mode, dec_ets_input_bfr, rx_type,                            raw_pcm_buffer);#endif        /* Save mode for next frame */        decoder_state->prev_mode = mode;    }    return (byte_offset);}

⌨️ 快捷键说明

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