Beispiel #1
0
int16_t WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
                                 const uint8_t* encoded,
                                 int16_t len,
                                 int16_t* decoded,
                                 int16_t* speechType)
{
  int i=0;
  if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||
      (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||
      (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) {
    /* ok, do nothing */
  } else {
    return(-1);
  }

  while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) {
    WebRtcIlbcfix_DecodeImpl(
        &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl],
        (const uint16_t*)&encoded
            [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words],
        (IlbcDecoder*)iLBCdec_inst, 1);
    i++;
  }
  /* iLBC does not support VAD/CNG yet */
  *speechType=1;
  return(i*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
Beispiel #2
0
static int ilbc_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
{
    const uint8_t *buf = avpkt->data;
    int buf_size       = avpkt->size;
    ILBCDecContext *s  = avctx->priv_data;
    AVFrame *frame     = data;
    int ret;

    if (s->decoder.no_of_bytes > buf_size) {
        av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be %u)\n",
               buf_size, s->decoder.no_of_bytes);
        return AVERROR_INVALIDDATA;
    }

    frame->nb_samples = s->decoder.blockl;
    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
        return ret;

    WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) frame->data[0],
                             (const WebRtc_UWord16*) buf, &s->decoder, 1);

    *got_frame_ptr = 1;

    return s->decoder.no_of_bytes;
}
Beispiel #3
0
int16_t WebRtcIlbcfix_Decode(iLBC_Dec_Inst_t * iLBCdec_inst,
				   const int16_t * encoded,
				   int16_t len,
				   int16_t * decoded,
				   int16_t * speechType)
{
	int i = 0;
	/* Allow for automatic switching between the frame sizes
	   (although you do get some discontinuity) */
	if ((len == ((iLBC_Dec_Inst_t *) iLBCdec_inst)->no_of_bytes) ||
	    (len == 2 * ((iLBC_Dec_Inst_t *) iLBCdec_inst)->no_of_bytes) ||
	    (len == 3 * ((iLBC_Dec_Inst_t *) iLBCdec_inst)->no_of_bytes)) {
		/* ok, do nothing */
	} else {
		/* Test if the mode has changed */
		if (((iLBC_Dec_Inst_t *) iLBCdec_inst)->mode == 20) {
			if ((len == NO_OF_BYTES_30MS) ||
			    (len == 2 * NO_OF_BYTES_30MS) ||
			    (len == 3 * NO_OF_BYTES_30MS)) {
				WebRtcIlbcfix_InitDecode(((iLBC_Dec_Inst_t *)
							  iLBCdec_inst), 30,
							 ((iLBC_Dec_Inst_t *)
							  iLBCdec_inst)->
							 use_enhancer);
			} else {
				/* Unsupported frame length */
				return (-1);
			}
		} else {
			if ((len == NO_OF_BYTES_20MS) ||
			    (len == 2 * NO_OF_BYTES_20MS) ||
			    (len == 3 * NO_OF_BYTES_20MS)) {
				WebRtcIlbcfix_InitDecode(((iLBC_Dec_Inst_t *)
							  iLBCdec_inst), 20,
							 ((iLBC_Dec_Inst_t *)
							  iLBCdec_inst)->
							 use_enhancer);
			} else {
				/* Unsupported frame length */
				return (-1);
			}
		}
	}

	while ((i * ((iLBC_Dec_Inst_t *) iLBCdec_inst)->no_of_bytes) < len) {
		WebRtcIlbcfix_DecodeImpl(&decoded
					 [i *
					  ((iLBC_Dec_Inst_t *) iLBCdec_inst)->
					  blockl],
					 (const uint16_t *)&encoded[i *
									  ((iLBC_Dec_Inst_t *) iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t *) iLBCdec_inst, 1);
		i++;
	}
	/* iLBC does not support VAD/CNG yet */
	*speechType = 1;
	return (i * ((iLBC_Dec_Inst_t *) iLBCdec_inst)->blockl);
}
Beispiel #4
0
WebRtc_Word16 WebRtcIlbcfix_DecodePlc(iLBC_decinst_t *iLBCdec_inst, WebRtc_Word16 *decoded, WebRtc_Word16 noOfLostFrames) {
  int i;
  WebRtc_UWord16 dummy;

  for (i=0;i<noOfLostFrames;i++) {
    /* call decoder */
    WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], &dummy, (iLBC_Dec_Inst_t*) iLBCdec_inst, 0);
  }
  return (noOfLostFrames*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl);
}
Beispiel #5
0
int16_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst,
                                int16_t* decoded,
                                int16_t noOfLostFrames) {
  int i;
  uint16_t dummy;

  for (i=0;i<noOfLostFrames;i++) {
    /* call decoder */
    WebRtcIlbcfix_DecodeImpl(
        &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy,
        (IlbcDecoder*)iLBCdec_inst, 0);
  }
  return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
Beispiel #6
0
size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst,
                               int16_t* decoded,
                               size_t noOfLostFrames) {
  size_t i;
  uint16_t dummy;

  for (i=0;i<noOfLostFrames;i++) {
    // PLC decoding shouldn't fail, because there is no external input data
    // that can be bad.
    RTC_CHECK(WebRtcIlbcfix_DecodeImpl(
        &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy,
        (IlbcDecoder*)iLBCdec_inst, 0));
  }
  return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
Beispiel #7
0
WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst,
                                       const WebRtc_Word16 *encoded,
                                       WebRtc_Word16 len,
                                       WebRtc_Word16 *decoded,
                                       WebRtc_Word16 *speechType)
{
  int i=0;
  if ((len==((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)||
      (len==2*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)||
      (len==3*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)) {
    /* ok, do nothing */
  } else {
    return(-1);
  }

  while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)<len) {
    WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1);
    i++;
  }
  /* iLBC does not support VAD/CNG yet */
  *speechType=1;
  return(i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl);
}