OpenCores
URL https://opencores.org/ocsvn/mb-jpeg/mb-jpeg/trunk

Subversion Repositories mb-jpeg

[/] [mb-jpeg/] [tags/] [STEP2_2b/] [bmp2jpg_mb/] [huffman.c] - Diff between revs 39 and 40

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 40
Line 674... Line 674...
        int  count;
        int  count;
        mask=0x00;                                                              //init mask
        mask=0x00;                                                              //init mask
        if (vlc_amount_remaining >= 8)                                             //2 bytes to send, send first byte
        if (vlc_amount_remaining >= 8)                                             //2 bytes to send, send first byte
        {
        {
                send=vlc_remaining>>(vlc_amount_remaining-8);                         //shift so that first byte is ready to send
                send=vlc_remaining>>(vlc_amount_remaining-8);                         //shift so that first byte is ready to send
                  vlc_output_byte(send);
                  vlc_output_byte(send&0xff);
//                fwrite(&send,1,1,file);
//                fwrite(&send,1,1,file);
                if (send==0xFF)                                                 //is this still needed????
                if (send==0xFF)                                                 //is this still needed????
                {
                {
                        send=0x00;
                        send=0x00;
                           vlc_output_byte(send);
                           vlc_output_byte(send&0xff);
//                        fwrite(&send,1,1,file);
//                        fwrite(&send,1,1,file);
                }
                }
                vlc_amount_remaining=vlc_amount_remaining -8;                         // lower the value to the amount of bits that still needs to be send
                vlc_amount_remaining=vlc_amount_remaining -8;                         // lower the value to the amount of bits that still needs to be send
        }
        }
        if (vlc_amount_remaining >= 0)                                             //there is a last byte to send
        if (vlc_amount_remaining >= 0)                                             //there is a last byte to send
        {
        {
                send=vlc_remaining<<(8-vlc_amount_remaining);                         //shift the last bits to send to the front of the byte
                send=vlc_remaining<<(8-vlc_amount_remaining);                         //shift the last bits to send to the front of the byte
                mask=0x00;                                                      //init mask
                mask=0x00;                                                      //init mask
                for (count=(8-vlc_amount_remaining); count>0; count--) mask=(mask<<1)|0x01; //create mask to fill byte up with ones
                for (count=(8-vlc_amount_remaining); count>0; count--) mask=(mask<<1)|0x01; //create mask to fill byte up with ones
                send=send | mask;                                               //add the ones to the byte
                send=send | mask;                                               //add the ones to the byte
                vlc_output_byte(send);
                vlc_output_byte(send&0xff);
//                fwrite(&send,1,1,file);
//                fwrite(&send,1,1,file);
                vlc_amount_remaining=0x00;                                         //is this needed?
                vlc_amount_remaining=0x00;                                         //is this needed?
        }
        }
        return;
        return;
}
}
Line 724... Line 724...
char EncodeDataUnit(char dataunit[64], unsigned int color)
char EncodeDataUnit(char dataunit[64], unsigned int color)
{
{
        char difference;
        char difference;
        unsigned char magnitude,zerorun,ii,ert;
        unsigned char magnitude,zerorun,ii,ert;
        unsigned int bits;
        unsigned int bits;
 
        unsigned char bit_char;
         char last_dc_value;
         char last_dc_value;
                                         //init
                                         //init
  //    PrintMatrix(dataunit) ;
  //    PrintMatrix(dataunit) ;
        last_dc_value = dcvalue[color];
        last_dc_value = dcvalue[color];
        difference = dataunit[0] - last_dc_value;
        difference = dataunit[0] - last_dc_value;
        last_dc_value=dataunit[0];
        last_dc_value=dataunit[0];
        ReverseExtend(difference, &magnitude,&bits);
        ReverseExtend(difference, &magnitude,&bit_char);
 
        bits = bit_char;
        HuffmanEncodeUsingDCTable(magnitude);
        HuffmanEncodeUsingDCTable(magnitude);
        WriteRawBits16(magnitude,bits);
        WriteRawBits16(magnitude,bits);
        zerorun=0;
        zerorun=0;
        ii=1;
        ii=1;
        while ( ii < 64 )
        while ( ii < 64 )
Line 745... Line 747...
                        {
                        {
                                HuffmanEncodeUsingACTable(0xF0);
                                HuffmanEncodeUsingACTable(0xF0);
                                zerorun=zerorun-16;
                                zerorun=zerorun-16;
                            //    printf("16 zeros:  %d\n",zerorun);
                            //    printf("16 zeros:  %d\n",zerorun);
                        }
                        }
                        ReverseExtend(dataunit[ii],&magnitude,&bits);
                        ReverseExtend(dataunit[ii],&magnitude,&bit_char);
 
                        bits=bit_char;
                        ert= ((int)zerorun *16);                                     //ERROR !!!!!!!!!!!
                        ert= ((int)zerorun *16);                                     //ERROR !!!!!!!!!!!
                        ert=ert + magnitude;
                        ert=ert + magnitude;
                        HuffmanEncodeUsingACTable(ert);
                        HuffmanEncodeUsingACTable(ert);
                        WriteRawBits16(magnitude,bits);
                        WriteRawBits16(magnitude,bits);
                        zerorun=0;
                        zerorun=0;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.