home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / dctm.lzh / DCTM / source.lzh / source / INITS.Cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-08  |  3.4 KB  |  144 lines

  1. /*************************************************************************
  2.     INITS.cpp
  3.  
  4.     03/02/08    Xiaohong
  5. *************************************************************************/
  6. #include "inits.h"
  7. #include <windows.h>
  8. /*************************************************************************
  9.     Initialisieren von Strukturen fuer S*N cc Compiler.
  10.  
  11.     Initialize structs for S*N cc compiler.
  12. *************************************************************************/
  13.  
  14. Vaunit_struc::Vaunit_struc()
  15. {
  16.     empty();
  17. }
  18. void Vaunit_struc::empty(void)
  19. {
  20.     length = 0;
  21.     type = 0;
  22.     DTS.empty();
  23.     PTS.empty();
  24. }
  25. void Vaunit_struc::write_file(HANDLE hFile)
  26. {
  27.     DWORD dwResult;
  28.     WriteFile(hFile,&length,sizeof(length),&dwResult,NULL);
  29.     WriteFile(hFile,&type,sizeof(type),&dwResult,NULL);
  30. //    fwrite(&length,1,sizeof(length),fp);
  31. //    fwrite(&type,1,sizeof(type),fp);
  32.     DTS.write_file(hFile);
  33.     PTS.write_file(hFile);
  34. }
  35. bool Vaunit_struc::read_file(HANDLE hFile)
  36. {
  37.     //if(fread(&length,1,sizeof(length),fp) == sizeof(length)
  38.     //    && fread(&type,1,sizeof(type),fp) == sizeof(type)
  39.     DWORD dwResult = 0;
  40.     ReadFile(hFile,&length,sizeof(length),&dwResult,NULL);
  41.     if(dwResult<sizeof(length))
  42.         return false;
  43.  
  44.     dwResult = 0;
  45.     ReadFile(hFile,&type,sizeof(type),&dwResult,NULL);
  46.     if(dwResult<sizeof(type))
  47.         return false;
  48.  
  49.     if(DTS.read_file(hFile)
  50.         && PTS.read_file(hFile))
  51.     {
  52.         return true;
  53.     }
  54.     return false;
  55. }
  56.  
  57. Aaunit_struc::Aaunit_struc()
  58. {
  59.     empty();
  60. }
  61. void Aaunit_struc::empty(void)
  62. {
  63.     length = 0;
  64.     PTS.empty();
  65. }
  66. void Aaunit_struc::write_file(HANDLE hFile)
  67. {
  68.     DWORD dwResult;
  69.     WriteFile(hFile,&length,sizeof(length),&dwResult,NULL);
  70. //    fwrite(&length,1,sizeof(length),fp);
  71.     PTS.write_file(hFile);
  72. }
  73. bool Aaunit_struc::read_file(HANDLE hFile)
  74. {
  75. //    if(fread(&length,1,sizeof(length),fp) == sizeof(length)
  76.     DWORD dwResult = 0;
  77.     ReadFile(hFile,&length,sizeof(length),&dwResult,NULL);
  78.     if(dwResult<sizeof(length))
  79.         return false;
  80.  
  81.     return PTS.read_file(hFile);
  82. }
  83.  
  84.  
  85. void empty_video_struc (Video_struc* pointer)
  86. {
  87.     int i;
  88.  
  89.     pointer->stream_length    = 0;
  90.     pointer->num_sequence     = 0;
  91.     pointer->num_seq_end    = 0;
  92.     pointer->num_pictures     = 0;
  93.     pointer->num_groups       = 0;
  94.     for (i=0; i<4; i++)
  95.     {
  96.         pointer->num_frames[i]     = 0;
  97.         pointer->avg_frames[i]    = 0;
  98.     }
  99.     pointer->horizontal_size     = 0;
  100.     pointer->vertical_size    = 0;
  101.     pointer->aspect_ratio     = 0;
  102.     pointer->picture_rate     = 0;
  103.     pointer->bit_rate        = 0;
  104.     pointer->comp_bit_rate    = 0;
  105.     pointer->vbv_buffer_size    = 0;
  106.     pointer->CSPF        = 0;
  107. }
  108.  
  109. void empty_audio_struc (Audio_struc* pointer)
  110. {   
  111.     int i;
  112.  
  113.     pointer->stream_length     = 0;
  114.     pointer->num_syncword     = 0;
  115.     for (i=0; i<2; i++)
  116.     {
  117.         pointer->num_frames [i]    = 0;
  118.         pointer->size_frames[i]    = 0;
  119.     }
  120.     pointer->layer        = 0;
  121.     pointer->protection     = 0;
  122.     pointer->bit_rate         = 0;
  123.     pointer->frequency         = 0;
  124.     pointer->mode         = 0;
  125.     pointer->mode_extension     = 0;
  126.     pointer->copyright          = 0;
  127.     pointer->original_copy      = 0;
  128.     pointer->emphasis        = 0;
  129. }
  130.  
  131. void empty_sector_struc(Sector_struc* pointer)
  132. {
  133.     pointer->length_of_sector  = 0;
  134.     pointer->length_of_packet_data  = 0;
  135.     pointer->TS.empty();
  136. }
  137.  
  138.  
  139. void init_buffer_struc(Buffer_struc* pointer,unsigned int size)
  140. {
  141.     pointer->max_size = size;
  142.     pointer->first = NULL;
  143. }
  144.