[cvs] / xvidcore / src / encoder.h Repository:
ViewVC logotype

Diff of /xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Fri Apr 5 14:40:36 2002 UTC revision 1.19, Wed Sep 4 20:56:52 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *  Modifications:   *  XVID MPEG-4 VIDEO CODEC
4     *  - Encoder header -
5   *   *
6   *  22.08.2001 added support for EXT_MODE encoding mode   *  Copyright(C) 2002 Michael Militzer
  *             support for EXTENDED API  
  *  22.08.2001 fixed bug in iDQtab  
7   *   *
8   *  Michael Militzer <isibaar@videocoding.de>   *  This program is an implementation of a part of one or more MPEG-4
9     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10     *  to use this software module in hardware or software products are
11     *  advised that its use may infringe existing patents or copyrights, and
12     *  any such use would be at such party's own risk.  The original
13     *  developer of this software module and his/her company, and subsequent
14     *  editors and their companies, will have no liability for use of this
15     *  software or modifications or derivatives thereof.
16   *   *
17   **************************************************************************/   *  This program is free software ; you can redistribute it and/or modify
18     *  it under the terms of the GNU General Public License as published by
19     *  the Free Software Foundation ; either version 2 of the License, or
20     *  (at your option) any later version.
21     *
22     *  This program is distributed in the hope that it will be useful,
23     *  but WITHOUT ANY WARRANTY ; without even the implied warranty of
24     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25     *  GNU General Public License for more details.
26     *
27     *  You should have received a copy of the GNU General Public License
28     *  along with this program ; if not, write to the Free Software
29     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30     *
31     ****************************************************************************/
32    
33  #ifndef _ENCODER_H_  #ifndef _ENCODER_H_
34  #define _ENCODER_H_  #define _ENCODER_H_
35    
   
36  #include "xvid.h"  #include "xvid.h"
   
37  #include "portab.h"  #include "portab.h"
38  #include "global.h"  #include "global.h"
39  #include "image/image.h"  #include "image/image.h"
40    #include "utils/ratecontrol.h"
41    
42    /*****************************************************************************
43     * Constants
44     ****************************************************************************/
45    
46    /* Quatization type */
47  #define H263_QUANT      0  #define H263_QUANT      0
48  #define MPEG4_QUANT     1  #define MPEG4_QUANT     1
49    
50    /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */
51    #define NO_CHANGE 64
52    
53  typedef uint32_t bool;  /*****************************************************************************
54     * Types
55     ****************************************************************************/
56    
57    typedef int bool;
58    
59  typedef enum  typedef enum
60  {  {
61      I_VOP = 0,      I_VOP = 0,
62      P_VOP = 1          P_VOP = 1,
63            B_VOP = 2
64  }  }
65  VOP_TYPE;  VOP_TYPE;
66    
67  /***********************************  /*****************************************************************************
68     * Structures
69         Encoding Parameters   ****************************************************************************/
   
 ************************************/  
70    
71  typedef struct  typedef struct
72  {  {
# Line 51  Line 78 
78          uint32_t mb_width;          uint32_t mb_width;
79          uint32_t mb_height;          uint32_t mb_height;
80    
81      VOP_TYPE coding_type;          /* frame rate increment & base */
82            uint32_t fincr;
83            uint32_t fbase;
84    
85    #ifdef _SMP
86            int num_threads;
87    #endif
88    
89    #ifdef BFRAMES
90            int max_bframes;
91    #endif
92    
93      /* rounding type; alternate 0-1 after each interframe */      /* rounding type; alternate 0-1 after each interframe */
   
     uint32_t rounding_type;  
   
94          /* 1 <= fixed_code <= 4          /* 1 <= fixed_code <= 4
95             automatically adjusted using motion vector statistics inside             automatically adjusted using motion vector statistics inside
96           */           */
97    
98      uint32_t fixed_code;          /* vars that not "quite" frame independant */
99            uint32_t m_quant_type;
100            uint32_t m_rounding_type;
101            uint32_t m_fcode;
102    
103            HINTINFO *hint;
104    
105            uint32_t m_seconds;
106            uint32_t m_ticks;
107    
108    }
109    MBParam;
110    
111    
112    typedef struct
113    {
114      uint32_t quant;      uint32_t quant;
         uint32_t quant_type;  
115          uint32_t motion_flags;          uint32_t motion_flags;
116          uint32_t global_flags;          uint32_t global_flags;
117    
118          HINTINFO * hint;          VOP_TYPE coding_type;
119  } MBParam;          uint32_t rounding_type;
120            uint32_t fcode;
121            uint32_t bcode;
122    
123            uint32_t seconds;
124            uint32_t ticks;
125    
126            IMAGE image;
127    
128            MACROBLOCK *mbs;
129    
130    }
131    FRAMEINFO;
132    
133  typedef struct  typedef struct
134  {  {
# Line 90  Line 150 
150    
151      int iFrameNum;      int iFrameNum;
152      int iMaxKeyInterval;      int iMaxKeyInterval;
         int lum_masking;  
153          int bitrate;          int bitrate;
154    
155          // images          // images
156    
157      IMAGE sCurrent;          FRAMEINFO *current;
158      IMAGE sReference;          FRAMEINFO *reference;
159    
160    #ifdef _DEBUG_PSNR
161            IMAGE sOriginal;
162    #endif
163      IMAGE vInterH;      IMAGE vInterH;
164      IMAGE vInterV;      IMAGE vInterV;
165          IMAGE vInterVf;          IMAGE vInterVf;
166      IMAGE vInterHV;      IMAGE vInterHV;
167          IMAGE vInterHVf;          IMAGE vInterHVf;
168    
169          // macroblock  #ifdef BFRAMES
170            /* constants */
171          MACROBLOCK * pMBs;          int global;
172            int bquant_ratio;
173            int frame_drop_ratio;
174    
175            /* image queue */
176            int queue_head;
177            int queue_tail;
178            int queue_size;
179            IMAGE *queue;
180    
181            /* bframe buffer */
182            int bframenum_head;
183            int bframenum_tail;
184            int flush_bframes;
185    
186            FRAMEINFO **bframes;
187            IMAGE f_refh;
188            IMAGE f_refv;
189            IMAGE f_refhv;
190            int bframenum_dx50bvop;
191    
192            int last_pframe;
193            int last_sync;
194            int time_pp;
195            int m_framenum; /* debug frame num counter; unlike iFrameNum, does not reset at ivop */
196    #endif
197    
198      Statistics sStat;      Statistics sStat;
199            RateControl rate_control;
200  }  }
201  Encoder;  Encoder;
202    
203    /*****************************************************************************
204     * Inline functions
205     ****************************************************************************/
206    
207  // indicates no quantizer changes in INTRA_Q/INTER_Q modes  static __inline uint8_t
208  #define NO_CHANGE 64  get_fcode(uint16_t sr)
   
 void init_encoder(uint32_t cpu_flags);  
   
 int encoder_create(XVID_ENC_PARAM * pParam);  
 int encoder_destroy(Encoder * pEnc);  
 int encoder_encode(Encoder * pEnc, XVID_ENC_FRAME * pFrame, XVID_ENC_STATS * pResult);  
   
 static __inline uint8_t get_fcode(uint16_t sr)  
209  {  {
210      if (sr <= 16)      if (sr <= 16)
211                  return 1;                  return 1;
# Line 148  Line 232 
232                  return 0;                  return 0;
233  }  }
234    
235  #endif /* _ENCODER_H_ */  
236    /*****************************************************************************
237     * Prototypes
238     ****************************************************************************/
239    
240    void init_encoder(uint32_t cpu_flags);
241    
242    int encoder_create(XVID_ENC_PARAM * pParam);
243    int encoder_destroy(Encoder * pEnc);
244    int encoder_encode(Encoder * pEnc,
245                                       XVID_ENC_FRAME * pFrame,
246                                       XVID_ENC_STATS * pResult);
247    
248    int encoder_encode_bframes(Encoder * pEnc,
249                                       XVID_ENC_FRAME * pFrame,
250                                       XVID_ENC_STATS * pResult);
251    
252    #endif

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.19

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4