WebRtc_Word16 WebRtcIlbcfix_Encode(iLBC_encinst_t *iLBCenc_inst, const WebRtc_Word16 *speechIn, WebRtc_Word16 len, WebRtc_Word16 *encoded) { WebRtc_Word16 pos = 0; WebRtc_Word16 encpos = 0; if ((len != ((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl) && #ifdef SPLIT_10MS (len != 80) && #endif (len != 2*((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl) && (len != 3*((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl)) { /* A maximum of 3 frames/packet is allowed */ return(-1); } else { /* call encoder */ while (pos<len) { WebRtcIlbcfix_EncodeImpl((WebRtc_UWord16*) &encoded[encpos], &speechIn[pos], (iLBC_Enc_Inst_t*) iLBCenc_inst); #ifdef SPLIT_10MS pos += 80; if(((iLBC_Enc_Inst_t*)iLBCenc_inst)->section == 0) #else pos += ((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl; #endif encpos += ((iLBC_Enc_Inst_t*)iLBCenc_inst)->no_of_words; } return (encpos*2); } }
int16_t WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, const int16_t* speechIn, int16_t len, uint8_t* encoded) { int16_t pos = 0; int16_t encpos = 0; if ((len != ((IlbcEncoder*)iLBCenc_inst)->blockl) && #ifdef SPLIT_10MS (len != 80) && #endif (len != 2*((IlbcEncoder*)iLBCenc_inst)->blockl) && (len != 3*((IlbcEncoder*)iLBCenc_inst)->blockl)) { /* A maximum of 3 frames/packet is allowed */ return(-1); } else { /* call encoder */ while (pos<len) { WebRtcIlbcfix_EncodeImpl((uint16_t*)&encoded[2 * encpos], &speechIn[pos], (IlbcEncoder*)iLBCenc_inst); #ifdef SPLIT_10MS pos += 80; if(((IlbcEncoder*)iLBCenc_inst)->section == 0) #else pos += ((IlbcEncoder*)iLBCenc_inst)->blockl; #endif encpos += ((IlbcEncoder*)iLBCenc_inst)->no_of_words; } return (encpos*2); } }
static int ilbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { ILBCEncContext *s = avctx->priv_data; int ret; if ((ret = ff_alloc_packet2(avctx, avpkt, 50)) < 0) return ret; WebRtcIlbcfix_EncodeImpl((WebRtc_UWord16*) avpkt->data, (const WebRtc_Word16*) frame->data[0], &s->encoder); avpkt->size = s->encoder.no_of_bytes; *got_packet_ptr = 1; return 0; }
static int ilbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { ILBCEncContext *s = avctx->priv_data; int ret; if ((ret = ff_alloc_packet(avpkt, 50))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } WebRtcIlbcfix_EncodeImpl((uint16_t *) avpkt->data, (const int16_t *) frame->data[0], &s->encoder); avpkt->size = s->encoder.no_of_bytes; *got_packet_ptr = 1; return 0; }