Functions | |
bool | ReadMPEGFile (std::ifstream *fp, void *image_buffer, size_t length) |
routine for MPEG decompression |
|
routine for MPEG decompression
Definition at line 310 of file gdcmMpeg.cxx. References Decode_Bitstream(), Error(), and Initialize_Decoder(). 00311 { 00312 int ret, code; 00313 00314 #if 0 00315 fp->read((char*)image_buffer, length); 00316 ofstream out("/tmp/etiam.mpeg"); 00317 out.write((char*)image_buffer, length); 00318 out.close(); 00319 #endif 00320 00321 // Clear_Options(); 00322 00323 /* decode command line arguments */ 00324 // Process_Options(argc,argv); 00325 00326 #ifdef DEBUG 00327 Print_Options(); 00328 #endif 00329 00330 ld = &base; /* select base layer context */ 00331 00332 /* open MPEG base layer bitstream file(s) */ 00333 /* NOTE: this is either a base layer stream or a spatial enhancement stream */ 00334 #if 0 00335 if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0) 00336 { 00337 fprintf(stderr,"Base layer input file %s not found\n", Main_Bitstream_Filename); 00338 exit(1); 00339 } 00340 #else 00341 base.Infile = -1; //DEBUG 00342 #endif 00343 00344 00345 if ( base.Infile != 0 ) 00346 { 00347 Initialize_Buffer(); 00348 00349 if ( Show_Bits(8)==0x47 ) 00350 { 00351 sprintf(Error_Text,"Decoder currently does not parse transport streams\n"); 00352 Error(Error_Text); 00353 } 00354 00355 next_start_code(); 00356 code = Show_Bits(32); 00357 00358 switch(code) 00359 { 00360 case SEQUENCE_HEADER_CODE: 00361 break; 00362 case PACK_START_CODE: 00363 System_Stream_Flag = 1; 00364 case VIDEO_ELEMENTARY_STREAM: 00365 System_Stream_Flag = 1; 00366 break; 00367 default: 00368 sprintf(Error_Text,"Unable to recognize stream type\n"); 00369 Error(Error_Text); 00370 break; 00371 } 00372 00373 //lseek(base.Infile, 0l, SEEK_SET); 00374 //fp->seekg(mpeg_start, ios_base::beg); 00375 Initialize_Buffer(); 00376 } 00377 00378 if ( base.Infile!=0 ) 00379 { 00380 //lseek(base.Infile, 0l, SEEK_SET); 00381 //fp->seekg(mpeg_start, ios_base::beg); 00382 } 00383 00384 Initialize_Buffer(); 00385 00386 if ( Two_Streams ) 00387 { 00388 abort(); 00389 ld = &enhan; /* select enhancement layer context */ 00390 00391 if ( (enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0) 00392 { 00393 sprintf(Error_Text,"enhancment layer bitstream file %s not found\n", 00394 Enhancement_Layer_Bitstream_Filename); 00395 00396 Error(Error_Text); 00397 } 00398 00399 Initialize_Buffer(); 00400 ld = &base; 00401 } 00402 00403 Initialize_Decoder(); 00404 00405 ret = Decode_Bitstream(); 00406 00407 //close(base.Infile); 00408 00409 if ( Two_Streams ) 00410 { 00411 abort(); 00412 close(enhan.Infile); 00413 } 00414 00415 return ret; 00416 }
|