Browse code

Use correct context for av_log(), should prevent a crash for malformed files.

Patch by Francesco Lavra (francescolavra at interfree dot it).

Originally committed as revision 21031 to svn://svn.ffmpeg.org/ffmpeg/trunk

Francesco Lavra authored on 2010/01/06 01:25:41
Showing 1 changed files
... ...
@@ -33,6 +33,8 @@
33 33
 
34 34
 
35 35
 typedef struct {
36
+    AVCodecContext *avctx;
37
+
36 38
     unsigned int     old_energy;        ///< previous frame energy
37 39
 
38 40
     unsigned int     lpc_tables[2][10];
... ...
@@ -55,6 +57,8 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx)
55 55
 {
56 56
     RA144Context *ractx = avctx->priv_data;
57 57
 
58
+    ractx->avctx = avctx;
59
+
58 60
     ractx->lpc_coef[0] = ractx->lpc_tables[0];
59 61
     ractx->lpc_coef[1] = ractx->lpc_tables[1];
60 62
 
... ...
@@ -226,7 +230,7 @@ static void int_to_int16(int16_t *out, const int *inp)
226 226
  * @return 1 if one of the reflection coefficients is greater than
227 227
  *         4095, 0 if not.
228 228
  */
229
-static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx)
229
+static int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
230 230
 {
231 231
     int b, i, j;
232 232
     int buffer1[10];
... ...
@@ -240,7 +244,7 @@ static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx)
240 240
     refl[9] = bp2[9];
241 241
 
242 242
     if ((unsigned) bp2[9] + 0x1000 > 0x1fff) {
243
-        av_log(ractx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
243
+        av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
244 244
         return 1;
245 245
     }
246 246
 
... ...
@@ -275,7 +279,7 @@ static int interp(RA144Context *ractx, int16_t *out, int a,
275 275
     for (i=0; i<30; i++)
276 276
         out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
277 277
 
278
-    if (eval_refl(work, out, ractx)) {
278
+    if (eval_refl(work, out, ractx->avctx)) {
279 279
         // The interpolated coefficients are unstable, copy either new or old
280 280
         // coefficients.
281 281
         int_to_int16(out, ractx->lpc_coef[copyold]);