changeset 8479:e818b3c06712 libavcodec

Part 2 of Kenan Gillet's QCELP silence handling patch.
author reynaldo
date Fri, 26 Dec 2008 16:49:06 +0000
parents 2f7c09bb6bfb
children c0f1e9a9402c
files qcelpdec.c
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/qcelpdec.c	Fri Dec 26 16:38:55 2008 +0000
+++ b/qcelpdec.c	Fri Dec 26 16:49:06 2008 +0000
@@ -415,6 +415,9 @@
                     *cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cbseed++ & 127];
             }
         break;
+        case SILENCE:
+            memset(cdn_vector, 0, 160 * sizeof(float));
+        break;
     }
 }
 
@@ -510,7 +513,7 @@
 
 /**
  * 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 cdn_vector the scaled codebook vector
@@ -521,6 +524,7 @@
     const float *v_synthesis_filtered, *v_pre_filtered;
 
     if(q->bitrate >= RATE_HALF ||
+       q->bitrate == SILENCE ||
        (q->bitrate == I_F_Q && (q->prev_bitrate >= RATE_HALF)))
     {
 
@@ -538,10 +542,17 @@
         {
             float max_pitch_gain;
 
+            if (q->bitrate == I_F_Q)
+            {
             if (q->erasure_count < 3)
                 max_pitch_gain = 0.9 - 0.3 * (q->erasure_count - 1);
              else
                 max_pitch_gain = 0.0;
+            }else
+            {
+                assert(q->bitrate == SILENCE);
+                max_pitch_gain = 1.0;
+            }
             for(i=0; i<4; i++)
                 q->pitch_gain[i] = FFMIN(q->pitch_gain[i], max_pitch_gain);
 
@@ -577,7 +588,7 @@
  * Interpolates LSP frequencies and computes LPC coefficients
  * 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 curr_lspf LSP frequencies vector of the current frame
@@ -605,6 +616,8 @@
     }else if(q->bitrate >= RATE_QUARTER ||
              (q->bitrate == I_F_Q && !subframe_num))
         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)
@@ -666,9 +679,11 @@
 
     if(bitrate == SILENCE)
     {
-        // FIXME: the decoder should not handle SILENCE frames as I_F_Q frames
-        ff_log_missing_feature(avctx, "Blank frame", 1);
-        bitrate = I_F_Q;
+        //FIXME: Remove experimental warning when tested with samples.
+        av_log(avctx, AV_LOG_WARNING, "'Blank frame handling is experimental."
+                      " 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;
 }