AviDecaps.h
上传用户:lusi_8715
上传日期:2007-01-08
资源大小:199k
文件大小:4k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /**************************************************************************************
  2.  *                                                                                    *
  3.  * This application contains code from OpenDivX and is released as a "Larger Work"    *
  4.  * under that license. Consistant with that license, this application is released     *
  5.  * under the GNU General Public License.                                              *
  6.  *                                                                                    *
  7.  * The OpenDivX license can be found at: http://www.projectmayo.com/opendivx/docs.php *
  8.  * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html                      *
  9.  *                                                                                    *
  10.  * Copyright (c) 2001 - Project Mayo                                                  *
  11.  *                                                                                    *
  12.  * Authors: Damien Chavarria <adrc at projectmayo.com>                                *
  13.  *                                                                                    *
  14.  **************************************************************************************/
  15. #ifndef AVI_DECAPS_H
  16. #define AVI_DECAPS_H
  17. /*
  18.  * includes
  19.  */
  20. #include "InputMedia.h"
  21. #include <windows.h>
  22. #include <windowsx.h>
  23. #include <malloc.h>
  24. #include <stdlib.h>
  25. /*
  26.  * SOME USEFUL MACROS
  27.  */
  28. #define AVI_MAX_LEN 2000000000
  29. #define HEADERBYTES 2048
  30. #define PAD_EVEN(x) ( ((x)+1) & ~1 )
  31. #define AVIIF_KEYFRAME 0x00000010L
  32. /*
  33.  * INDEX TYPES
  34.  */
  35. typedef struct
  36. {
  37.   long pos;
  38.   long len;
  39.   long flags;
  40. } video_index_entry;
  41. typedef struct
  42. {
  43.    long pos;
  44.    long len;
  45.    long tot;
  46. } audio_index_entry;
  47. /*
  48.  * Main Class
  49.  */
  50. class AviDecaps {
  51. public:
  52.    
  53. BITMAPINFOHEADER   bitmapinfoheader;
  54. WAVEFORMATEX       waveformatex;
  55.     long               width;             
  56.     long               height;            
  57.     double             fps;               
  58.     char               compressor[8];     
  59.     long               video_strn;        
  60.     long               video_frames;      
  61.     char               video_tag[4];      
  62.     long               video_pos;         
  63.     long               a_fmt;             
  64.     long               a_chans;           
  65.     long               a_rate;            
  66.     long               a_bits;            
  67.     long               audio_strn;        
  68.     long               audio_bytes;       
  69.     long               audio_chunks;      
  70.     char               audio_tag[4];      
  71.     long               audio_posc;        
  72.     long               audio_posb;        
  73.     long               pos;               
  74.     long               n_idx;             
  75.     long               max_idx;           
  76.     char               (*idx)[16]; 
  77.     video_index_entry *video_index;
  78.     audio_index_entry *audio_index;
  79.     long               last_pos;          
  80.     long               last_len;          
  81.     int                must_use_index;    
  82.     long               movi_start;
  83. HANDLE             hIOMutex;
  84. int IsAVI();
  85. int FillHeader(int getIndex);
  86. int AddIndexEntry(char *tag, 
  87.           long flags, 
  88.           long pos, 
  89.           long len);
  90. BOOL isKeyframe(long frame);
  91. InputMedia        *input;
  92. AviDecaps();
  93. ~AviDecaps();
  94. int               Open(char *lpFilename, int type);
  95. int               VideoStreams();
  96. int               AudioStreams();
  97. int               Width();
  98. int               Height();
  99. BITMAPINFOHEADER *BitmapInfoHeader();
  100. int               FrameSize(unsigned long frame_number);
  101. double            FrameRate();
  102. long              TotalFrames();
  103. int               NextVideoFrame(char *buffer);
  104. int               VideoSeek(long frame);
  105. int               AudioSeek(long bytes);
  106. int               NextKeyFrame();
  107. int   PreviousKeyFrame();
  108. int               Seek(int percent);
  109. int               ReSeekAudio();
  110. int               SampleSize();
  111. WAVEFORMATEX     *WaveFormatEx();
  112. int               ReadAudio(char *buffer, int size);
  113. int Rewind();
  114. double GetProgress();
  115. int GetBufferingState();
  116. int Close();
  117. };
  118. #endif