From d29f0cd9c1b00dba31ee6e6ecb99fd0819c26857 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 24 Jan 2005 00:35:18 +0000 Subject: [PATCH] fixing many bugs in bitplane_decoding() spliting row/colskip cases into their own functions as these will be needed for NORM/DIFF-6 Originally committed as revision 3879 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/vc9.c | 98 +++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/libavcodec/vc9.c b/libavcodec/vc9.c index aa753e09f0..675773c68c 100644 --- a/libavcodec/vc9.c +++ b/libavcodec/vc9.c @@ -699,11 +699,40 @@ static int advanced_entry_point_process(AVCodecContext *avctx, GetBitContext *gb #define IMODE_ROWSKIP 5 #define IMODE_COLSKIP 6 +static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ + int x, y; + + for (y=0; ygb, 1)) //rowskip + memset(plane, 0, width); + else + for (x=0; xgb, 1); + plane += stride; + } +} + +static void decode_colskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ + int x, y; + + for (x=0; xgb, 1)) //colskip + for (y=0; ygb, 1); + plane ++; + } +} + //FIXME optimize +//FIXME is this supposed to set elements to 0/FF or 0/1? static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context *v) { - int imode, x, y, code; + int imode, x, y, i, code, use_vertical_tile; uint8_t invert, *planep = plane; + int stride= width; invert = get_bits(&v->gb, 1); imode = get_vlc2(&v->gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); @@ -717,76 +746,61 @@ static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context * { for (x=0; xgb, 1)); //-1=0xFF - planep += width; + planep += stride; } + invert=0; //spec says ignore invert if raw break; case IMODE_DIFF2: case IMODE_NORM2: if ((height*width) & 1) *(++planep) = get_bits(&v->gb, 1); - code = get_vlc2(&v->gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); - *(++planep) = code&1; //lsb => left - *(++planep) = code&2; //msb => right - this is a bitplane, so only !0 matters + for(i=0; i<(height*width)>>1; i++){ + code = get_vlc2(&v->gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); + *(++planep) = code&1; //lsb => left + *(++planep) = code&2; //msb => right - this is a bitplane, so only !0 matters + //FIXME width->stride + } break; case IMODE_DIFF6: case IMODE_NORM6: + use_vertical_tile= height%3==0 && width%3!=0; + if(use_vertical_tile){ + }else{ + } + av_log(v->avctx, AV_LOG_ERROR, "Imode using Norm-6 isn't supported\n"); return -1; break; case IMODE_ROWSKIP: - for (y=0; ygb, 1)) //rowskip - memset(planep, 0, width); - else for (x=0; xgb, 1); - planep += width; - } + decode_rowskip(plane, width, height, stride, v); break; case IMODE_COLSKIP: //Teh ugly - for (x=0; xgb, 1)) //colskip - { - for (y=0; ygb, 1); - planep += width; - } - } - } + decode_rowskip(plane, width, height, stride, v); break; default: break; } /* Applying diff operator */ - if (imode == IMODE_DIFF2 || imode == IMODE_DIFF2) + if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { - /* And what about j=0 !? */ - planep = plane + width; - memset(plane, invert, width); - for (y=0; y