[FFmpeg-devel] [PATCH] snowenc: Fix encoding of GRAY8 videos

Derek Buitenhuis derek.buitenhuis at gmail.com
Wed Dec 28 22:40:28 CET 2011


snowenc previously had a hardcoded value of 3 for
the amount of planes it was to process.

Tested snow and snowll in fate. No regressions present.

Fixes ticket #839.
---
 libavcodec/snowenc.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index ab31533..e6d0c8b 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1609,11 +1609,15 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
     int level, orientation, plane_index, i, y;
     uint8_t rc_header_bak[sizeof(s->header_state)];
     uint8_t rc_block_bak[sizeof(s->block_state)];
+    int planes = 3;
+
+    if(avctx->pix_fmt == PIX_FMT_GRAY8)
+        planes = 1;
 
     ff_init_range_encoder(c, buf, buf_size);
     ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
 
-    for(i=0; i<3; i++){
+    for(i=0; i<planes; i++){
         int shift= !!i;
         for(y=0; y<(height>>shift); y++)
             memcpy(&s->input_picture.data[i][y * s->input_picture.linesize[i]],
@@ -1714,7 +1718,7 @@ redo_frame:
     ff_snow_common_init_after_header(avctx);
 
     if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){
-        for(plane_index=0; plane_index<3; plane_index++){
+        for(plane_index=0; plane_index<planes; plane_index++){
             calculate_visual_weight(s, &s->plane[plane_index]);
         }
     }
@@ -1724,7 +1728,7 @@ redo_frame:
     encode_blocks(s, 1);
     s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits;
 
-    for(plane_index=0; plane_index<3; plane_index++){
+    for(plane_index=0; plane_index<planes; plane_index++){
         Plane *p= &s->plane[plane_index];
         int w= p->width;
         int h= p->height;
-- 
1.7.7.3



More information about the ffmpeg-devel mailing list