Re: Fw: Fw: libxvidcore decompression

reno reballos <[email protected]>
Newsgroups gmane.comp.video.xvid.devel
Message-ID <[email protected]>
Hi Master Stephan,

thank you for the the reply... i had double check and scrutinized everything in my code specially when it comes to initialization of decoder and the main decoder itself, i will share to you my code hope you'll fine a time for this.... and here is exactly what i do... yes, you are free to give any comment with my code:

//======== main application file routine===============//
FILE *fpi = NULL;<-- input file
FILE *fpo = NULL;<-- output file

 unsigned char *mp4_buffer = NULL;
unsigned char *dec_output_buffer = NULL;
mp4_buffer = (unsigned char*)malloc(1024*1024*2);
dec_output_buffer = (unsigned char *)malloc(352*240*4);<---this should be enough for the res. of 352*240

static void *dec_handle = NULL;<--decoder handle
int useful_bytes = 0;
int used_bytes = 0;


    useful_bytes = fread(mp4_buffer, sizeof(unsigned int), 1024, fpi);

    xvid_dec_stats_t dec_stats;
    memset(&dec_stats,0, sizeof(xvid_dec_stats_t));
    dec_stats.version = XVID_VERSION;

    do{
    
        //reading 5008*4 bytes from the file(fpi)
        useful_bytes = fread(gmp4_buffer, sizeof(unsigned int), 5008,fpi);//65536,5008,2048, 262144reading 1MB 

        do{
                //decode until dec_outBuf got data
            used_bytes = dec_decode(gmp4_buffer, dec_outBuf, useful_bytes,&dec_stats);<--in here itself no decoder output from dec_outBuf...
        }while(sizeof(dec_outBuf==0));

        sprintf(FileNames, "%sdec%05d.pgm", FilePath, totalframe);
        fpo = fopen(FileNames, "w+b");
        
        width = dec_stats.data.vol.width;
        height = dec_stats.data.vol.height;

        writedata = fwrite(dec_outBuf,1,width*height*3/2,fpo);//used_bytes
        fclose(fpo);
        totalframe++;

    }while(useful_bytes>1 || !feof(fpi) || used_bytes==0);

----------------------------------------------------------------------------------------------

//============ global initialization routine ======
int dec_global_initialize()
{
    int retVal_GBL_init = NULL;

     xvid_gbl_init_t xvid_gbl_init;
    memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t));
    xvid_gbl_init.debug = 0;
    xvid_gbl_init.version = XVID_VERSION;            
    xvid_gbl_init.cpu_flags = 0;                    
 
    retVal_GBL_init = xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);

   /*note: error checking is removed...*/
  ....
  ..
  .

    return retVal_GBL_init;

-----------------------------------------------------------------------------------------------------

//=========== decoder initialization ===================

    xvid_dec_create_t dec_create;
    memset(&dec_create,0, sizeof(xvid_dec_create_t));
    dec_create.version = XVID_VERSION;
    dec_create.width = 0;
    dec_create.height = 0;
    
    retVal_DEC_create = xvid_decore(NULL, XVID_DEC_CREATE, &dec_create, NULL);

    /*note: error checking is removed...*/
    ...
    ..
    .

    dec_handle = dec_create.handle;//decoder handle

    return retVal_DEC_create;
-------------------------------------------------------------------------------------------------------------

//============ decoder main routine =============================
int dec_decode(unsigned char *dec_inputstream, unsigned char *dec_outputstream, int data_length, xvid_dec_stats_t *dec_stats)
{

    int retVal_DEC_decode = NULL;
     xvid_dec_frame_t dec_frame;
    memset(&dec_frame,0, sizeof(xvid_dec_frame_t));
    dec_frame.version = XVID_VERSION;
    dec_frame.general = 0;
    dec_frame.bitstream = dec_inputstream;<-- decoder input stream
    dec_frame.length = data_length;<-- data length 
    dec_frame.output.plane[0] = dec_outputstream;<---decoder output stream
    dec_stats->type = XVID_TYPE_AUTO;

    retVal_DEC_decode = xvid_decore(dec_handle, XVID_DEC_DECODE, &dec_frame,dec_stats);
    /*note: error checking is removed...*/
    ...
    ..
    .
    dec_frame.output.stride[0] = (dec_stats->data.vol.width)*3; 
    dec_frame.output.csp = XVID_CSP_BGR;
    
    return retVal_DEC_decode;

-------------------------------------------------------------------------------------

//===== stop the decoding routine ===========

int dec_stop()
{
    int dec_destroy = xvid_decore(dec_handle, XVID_DEC_DESTROY, NULL, NULL);
    dec_handle = NULL;
    return dec_destroy;
}
---------------------------------------------------------------------------------------

i hope you can help me sort this out.. thank you for the time spent and knowledge shared......
looking forward for your comment...

regards,
reno




      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.