[FFmpeg-cvslog] flashv2enc: reallocate not only on block count changes but on dimension changes.

Michael Niedermayer git at videolan.org
Fri Sep 7 21:56:40 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Sep  7 21:24:33 2012 +0200| [9b6467fd4674e92334e1a34b3bfc24d1b800ae55] | committer: Michael Niedermayer

flashv2enc: reallocate not only on block count changes but on dimension changes.

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b6467fd4674e92334e1a34b3bfc24d1b800ae55
---

 libavcodec/flashsv2enc.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index 5a1d594..bc833f4 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -805,13 +805,15 @@ static int reconfigure_at_keyframe(FlashSV2Context * s, const uint8_t * image,
 {
     int update_palette = 0;
     int res;
-    s->block_width = optimum_block_width(s);
-    s->block_height = optimum_block_height(s);
+    int block_width  = optimum_block_width (s);
+    int block_height = optimum_block_height(s);
 
-    s->rows = (s->image_height + s->block_height - 1) / s->block_height;
-    s->cols = (s->image_width +  s->block_width -  1) / s->block_width;
+    s->rows = (s->image_height + block_height - 1) / block_height;
+    s->cols = (s->image_width  + block_width  - 1) / block_width;
 
-    if (s->rows * s->cols != s->blocks_size / sizeof(Block)) {
+    if (block_width != s->block_width || block_height != s->block_height) {
+        s->block_width  = block_width;
+        s->block_height = block_height;
         if (s->rows * s->cols > s->blocks_size / sizeof(Block)) {
             s->frame_blocks = av_realloc(s->frame_blocks, s->rows * s->cols * sizeof(Block));
             s->key_blocks = av_realloc(s->key_blocks, s->cols * s->rows * sizeof(Block));



More information about the ffmpeg-cvslog mailing list