X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fra144enc.c;h=725abc2f381d801ddd39fe8484084f9cdbb954fd;hb=7f83db312454b3673a4dfd34745428f61309ab30;hp=5a64a5ec74436d32572f2937c50c0e0934cd1086;hpb=aedc908601de7396751a9a4504e064782d9f6a0b;p=ffmpeg diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 5a64a5ec744..725abc2f381 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -214,7 +214,7 @@ static int adaptive_cb_search(const int16_t *adapt_cb, float *work, ff_celp_lp_synthesis_filterf(work, coefs, exc, BLOCKSIZE, LPC_ORDER); for (i = 0; i < BLOCKSIZE; i++) data[i] -= best_gain * work[i]; - return (best_vect - BLOCKSIZE / 2 + 1); + return best_vect - BLOCKSIZE / 2 + 1; } @@ -477,7 +477,10 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, * The filter is unstable: use the coefficients of the previous frame. */ ff_int_to_int16(block_coefs[NBLOCKS - 1], ractx->lpc_coef[1]); - ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx); + if (ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx)) { + /* the filter is still unstable. set reflection coeffs to zero. */ + memset(lpc_refl, 0, sizeof(lpc_refl)); + } } init_put_bits(&pb, frame, buf_size); for (i = 0; i < LPC_ORDER; i++) { @@ -516,5 +519,7 @@ AVCodec ff_ra_144_encoder = { .init = ra144_encode_init, .encode = ra144_encode_frame, .close = ra144_encode_close, + .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"), };