[FFmpeg-devel] GSoC VQA v3 vptr decode function implementation

The Deep Explorer thedeepexplorer
Mon Apr 13 07:13:16 CEST 2009


Hi,
    I have implemented the decode function for vptr. It is not working
since I was not able to interpret what to do
with code 2. Also , please check/verify whether it is correctly
implemented or not as per the documentation provided.
Also, what to do with the other codes ? they do show up !!!

static void vqa_decode_vptr(const unsigned char *src, int src_size,
                            unsigned char *dest, int dest_size) {

    int src_index = 0;
    int dest_index = 0;
    short int code_buf = 0;
    short int code = 0;
    int   block_no = 0;
    int   count = 0;
    int   index = 0;

    while(src_index < src_size) {
        memcpy(&code_buf,&src[src_index],2);
        code = code_buf >> 13;
        code = code & 0x0007;

        av_log(NULL,AV_LOG_ERROR,"Actual value of code %d Code Value
is %d \n",code_buf,code);

        switch(code) {

        case 0:
             block_no = code_buf & 0x1ff;
             dest_index += block_no;
             av_log(NULL,AV_LOG_ERROR,"Code is 000 %d \n",code);
             break;
        case 1:
             block_no = code_buf & 0x1ff;
             count = (((code_buf/256) & 0x1f)+1)*2;
             // does it make sense since am writing the same value
again and again ?
             for(index = 0; index<count;index++)
                 dest[dest_index+index] = block_no;
             dest_index += index;
             av_log(NULL,AV_LOG_ERROR,"Code is 001 %d \n",code);
             break;
        case 2:
             /* 010 - Write block number (Val & 0xff) and then write
Count blocks getting their indexes by reading next Count bytes from
              the VPTR chunk. Count is (((Val/256) & 0x1f)+1)*2.
Again, the block numbers range from 0-255.*/
             block_no = code_buf & 0x1ff;
             count = (((code_buf/256) & 0x1f)+1)*2;
             //TOTALLY CONFUSED NEED INFO ( sorry for the caps, not
shouting , since it is inline ...one might miss it ,thats why ,thanks)

             av_log(NULL,AV_LOG_ERROR,"Code is 010 %d \n",code);
             break;
        case 3:
        /*   011 - Write block (Val & 0x1fff).*/
             block_no = code_buf & 0x1ff;
             dest[dest_index] = block_no;
             dest_index++;
             av_log(NULL,AV_LOG_ERROR,"Code is 011 %d\n",code);
             break;
        case 5:
        /*101 - Write block (Val & 0x1fff) Count times. Count is the next
                 byte from the VPTR chunk.*/
             block_no = code_buf & 0x1ff;
             memset(&count,&src[src_index+2],1);
             src_index++; // should I increase since I read it for the count ?
             for(index=0;index<count;index++)
                 dest[dest_index+index] = block_no;
             dest_index += index;
             av_log(NULL,AV_LOG_ERROR,"Code is 101 %d\n",code);
             break;
        default:
             av_log(NULL,AV_LOG_ERROR,"Code %d is unknown and not
supported \n",code);
             break;
        }

    code = code_buf = 0;
    src_index += 2;
    if(dest_index> dest_size){
        av_log(NULL,AV_LOG_ERROR,"VQA : deocde buffer overflow ");
    }
    av_log(NULL,AV_LOG_ERROR,"src_index  %d src_size = %d
\n",src_index,src_size);
    }
}

Ignore the formatting , please check the algorithm and let me know
what to modify and especially for code 2.
Look forward to your feedback...

Thanks,
-tde



More information about the ffmpeg-devel mailing list