Part 2 of Kenan Gillet's QCELP silence handling patch.

Originally committed as revision 16337 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Reynaldo H. Verdejo Pinochet 16 years ago
parent 6fe68c7b97
commit 4f54fb54e3
  1. 25
      libavcodec/qcelpdec.c

@ -415,6 +415,9 @@ static void compute_svector(QCELPContext *q, const float *gain,
*cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cbseed++ & 127]; *cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cbseed++ & 127];
} }
break; break;
case SILENCE:
memset(cdn_vector, 0, 160 * sizeof(float));
break;
} }
} }
@ -510,7 +513,7 @@ static const float *do_pitchfilter(float memory[303], const float v_in[160],
/** /**
* Apply pitch synthesis filter and pitch prefilter to the scaled codebook vector. * Apply pitch synthesis filter and pitch prefilter to the scaled codebook vector.
* TIA/EIA/IS-733 2.4.5.2 * TIA/EIA/IS-733 2.4.5.2, 2.4.8.7.2
* *
* @param q the context * @param q the context
* @param cdn_vector the scaled codebook vector * @param cdn_vector the scaled codebook vector
@ -521,6 +524,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
const float *v_synthesis_filtered, *v_pre_filtered; const float *v_synthesis_filtered, *v_pre_filtered;
if(q->bitrate >= RATE_HALF || if(q->bitrate >= RATE_HALF ||
q->bitrate == SILENCE ||
(q->bitrate == I_F_Q && (q->prev_bitrate >= RATE_HALF))) (q->bitrate == I_F_Q && (q->prev_bitrate >= RATE_HALF)))
{ {
@ -538,10 +542,17 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
{ {
float max_pitch_gain; float max_pitch_gain;
if (q->bitrate == I_F_Q)
{
if (q->erasure_count < 3) if (q->erasure_count < 3)
max_pitch_gain = 0.9 - 0.3 * (q->erasure_count - 1); max_pitch_gain = 0.9 - 0.3 * (q->erasure_count - 1);
else else
max_pitch_gain = 0.0; max_pitch_gain = 0.0;
}else
{
assert(q->bitrate == SILENCE);
max_pitch_gain = 1.0;
}
for(i=0; i<4; i++) for(i=0; i<4; i++)
q->pitch_gain[i] = FFMIN(q->pitch_gain[i], max_pitch_gain); q->pitch_gain[i] = FFMIN(q->pitch_gain[i], max_pitch_gain);
@ -577,7 +588,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
* Interpolates LSP frequencies and computes LPC coefficients * Interpolates LSP frequencies and computes LPC coefficients
* for a given bitrate & pitch subframe. * for a given bitrate & pitch subframe.
* *
* TIA/EIA/IS-733 2.4.3.3.4 * TIA/EIA/IS-733 2.4.3.3.4, 2.4.8.7.2
* *
* @param q the context * @param q the context
* @param curr_lspf LSP frequencies vector of the current frame * @param curr_lspf LSP frequencies vector of the current frame
@ -605,6 +616,8 @@ void interpolate_lpc(QCELPContext *q, const float *curr_lspf, float *lpc,
}else if(q->bitrate >= RATE_QUARTER || }else if(q->bitrate >= RATE_QUARTER ||
(q->bitrate == I_F_Q && !subframe_num)) (q->bitrate == I_F_Q && !subframe_num))
ff_qcelp_lspf2lpc(curr_lspf, lpc); ff_qcelp_lspf2lpc(curr_lspf, lpc);
else if(q->bitrate == SILENCE && !subframe_num)
ff_qcelp_lspf2lpc(q->prev_lspf, lpc);
} }
static qcelp_packet_rate buf_size2bitrate(const int buf_size) static qcelp_packet_rate buf_size2bitrate(const int buf_size)
@ -666,9 +679,11 @@ static int determine_bitrate(AVCodecContext *avctx, const int buf_size,
if(bitrate == SILENCE) if(bitrate == SILENCE)
{ {
// FIXME: the decoder should not handle SILENCE frames as I_F_Q frames //FIXME: Remove experimental warning when tested with samples.
ff_log_missing_feature(avctx, "Blank frame", 1); av_log(avctx, AV_LOG_WARNING, "'Blank frame handling is experimental."
bitrate = I_F_Q; " If you want to help, upload a sample "
"of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
"and contact the ffmpeg-devel mailing list.\n");
} }
return bitrate; return bitrate;
} }

Loading…
Cancel
Save