Browse code

ffmpeg: Allocate buffers of the size needed by the decoder.

Fixes bug127

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2012/01/24 09:29:03
Showing 1 changed files
... ...
@@ -469,9 +469,8 @@ static void reset_options(OptionsContext *o, int is_input)
469 469
     init_opts();
470 470
 }
471 471
 
472
-static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf)
472
+static int alloc_buffer(AVCodecContext *s, InputStream *ist, FrameBuffer **pbuf)
473 473
 {
474
-    AVCodecContext *s = ist->st->codec;
475 474
     FrameBuffer  *buf = av_mallocz(sizeof(*buf));
476 475
     int ret, i;
477 476
     const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
... ...
@@ -547,7 +546,7 @@ static int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
547 547
     FrameBuffer *buf;
548 548
     int ret, i;
549 549
 
550
-    if (!ist->buffer_pool && (ret = alloc_buffer(ist, &ist->buffer_pool)) < 0)
550
+    if (!ist->buffer_pool && (ret = alloc_buffer(s, ist, &ist->buffer_pool)) < 0)
551 551
         return ret;
552 552
 
553 553
     buf              = ist->buffer_pool;
... ...
@@ -557,7 +556,7 @@ static int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
557 557
         av_freep(&buf->base[0]);
558 558
         av_free(buf);
559 559
         ist->dr1 = 0;
560
-        if ((ret = alloc_buffer(ist, &buf)) < 0)
560
+        if ((ret = alloc_buffer(s, ist, &buf)) < 0)
561 561
             return ret;
562 562
     }
563 563
     buf->refcount++;