[cvs] / xvidcore / src / xvid.c Repository:
ViewVC logotype

Diff of /xvidcore/src/xvid.c

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

revision 1.33.2.17, Mon Dec 9 10:47:05 2002 UTC revision 1.35, Wed Sep 4 22:07:54 2002 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Native API implementation  -   *  - Native API implementation  -
5   *   *
6     *  Copyright(C) 2001-2002 Peter Ross <pross@cs.rmit.edu.au>
7     *
8   *  This program is an implementation of a part of one or more MPEG-4   *  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   *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10   *  to use this software module in hardware or software products are   *  to use this software module in hardware or software products are
# Line 28  Line 30 
30   *   *
31   ****************************************************************************/   ****************************************************************************/
32    
 /*****************************************************************************  
  *  
  *  History  
  *  
  *      - 23.06.2002    added XVID_CPU_CHKONLY  
  *  - 17.03.2002        Added interpolate8x8_halfpel_hv_xmm  
  *  - 22.12.2001  API change: added xvid_init() - Isibaar  
  *  - 16.12.2001        inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
  *  
  *  $Id$  
  *  
  ****************************************************************************/  
   
33  #include "xvid.h"  #include "xvid.h"
34  #include "decoder.h"  #include "decoder.h"
35  #include "encoder.h"  #include "encoder.h"
# Line 49  Line 38 
38  #include "dct/fdct.h"  #include "dct/fdct.h"
39  #include "image/colorspace.h"  #include "image/colorspace.h"
40  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
 #include "image/reduced.h"  
41  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
 #include "utils/mbfunctions.h"  
42  #include "quant/quant_h263.h"  #include "quant/quant_h263.h"
43  #include "quant/quant_mpeg4.h"  #include "quant/quant_mpeg4.h"
44  #include "motion/motion.h"  #include "motion/motion.h"
# Line 83  Line 70 
70    
71    
72  /*  /*
73  calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled   * Calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled
74  return values:   * Return values:
75  -1 : could not determine   * -1 : could not determine
76  0  : SIGILL was *not* signalled   * 0  : SIGILL was *not* signalled
77  1  : SIGILL was signalled   * 1  : SIGILL was signalled
78  */  */
79    
80  int  int
# Line 141  Line 128 
128   *   *
129   ****************************************************************************/   ****************************************************************************/
130    
131    int
132  static  xvid_init(void *handle,
133  int xvid_init_init(XVID_INIT_PARAM * init_param)                    int opt,
134                      void *param1,
135                      void *param2)
136  {  {
137          int cpu_flags;          int cpu_flags;
138            XVID_INIT_PARAM *init_param;
139    
140            init_param = (XVID_INIT_PARAM *) param1;
141    
142          /* Inform the client the API version */          /* Inform the client the API version */
143          init_param->api_version = API_VERSION;          init_param->api_version = API_VERSION;
# Line 213  Line 205 
205          transfer_16to8add  = transfer_16to8add_c;          transfer_16to8add  = transfer_16to8add_c;
206          transfer8x8_copy   = transfer8x8_copy_c;          transfer8x8_copy   = transfer8x8_copy_c;
207    
         /* Interlacing functions */  
         MBFieldTest = MBFieldTest_c;  
   
208          /* Image interpolation related functions */          /* Image interpolation related functions */
209          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;
210          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;
211          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
212    
         interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;  
         interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;  
         interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;  
   
         interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;  
         interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;  
         interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;  
   
         interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;  
         interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;  
   
         interpolate8x8_avg2 = interpolate8x8_avg2_c;  
         interpolate8x8_avg4 = interpolate8x8_avg4_c;  
   
         /* reduced resoltuion */  
   
         copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;  
         add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;  
 #ifdef ARCH_X86  
         vfilter_31 = xvid_VFilter_31_x86;  
         hfilter_31 = xvid_HFilter_31_x86;  
 #else  
         vfilter_31 = xvid_VFilter_31_C;  
         hfilter_31 = xvid_HFilter_31_C;  
 #endif  
         filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C;  
         filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C;  
   
213          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
214          colorspace_init();          colorspace_init();
215    
216          /* All colorspace transformation functions User Format->YV12 */          /* All colorspace transformation functions User Format->YV12 */
         yv12_to_yv12    = yv12_to_yv12_c;  
217          rgb555_to_yv12  = rgb555_to_yv12_c;          rgb555_to_yv12  = rgb555_to_yv12_c;
218          rgb565_to_yv12  = rgb565_to_yv12_c;          rgb565_to_yv12  = rgb565_to_yv12_c;
219          bgr_to_yv12     = bgr_to_yv12_c;          rgb24_to_yv12  = rgb24_to_yv12_c;
220          bgra_to_yv12    = bgra_to_yv12_c;          rgb32_to_yv12  = rgb32_to_yv12_c;
221          abgr_to_yv12    = abgr_to_yv12_c;          yuv_to_yv12    = yuv_to_yv12_c;
         rgba_to_yv12    = rgba_to_yv12_c;  
222          yuyv_to_yv12    = yuyv_to_yv12_c;          yuyv_to_yv12    = yuyv_to_yv12_c;
223          uyvy_to_yv12    = uyvy_to_yv12_c;          uyvy_to_yv12    = uyvy_to_yv12_c;
224    
         rgb555i_to_yv12 = rgb555i_to_yv12_c;  
         rgb565i_to_yv12 = rgb565i_to_yv12_c;  
         bgri_to_yv12    = bgri_to_yv12_c;  
         bgrai_to_yv12   = bgrai_to_yv12_c;  
         abgri_to_yv12   = abgri_to_yv12_c;  
         rgbai_to_yv12   = rgbai_to_yv12_c;  
         yuyvi_to_yv12   = yuyvi_to_yv12_c;  
         uyvyi_to_yv12   = uyvyi_to_yv12_c;  
   
   
225          /* All colorspace transformation functions YV12->User format */          /* All colorspace transformation functions YV12->User format */
226          yv12_to_rgb555  = yv12_to_rgb555_c;          yv12_to_rgb555  = yv12_to_rgb555_c;
227          yv12_to_rgb565  = yv12_to_rgb565_c;          yv12_to_rgb565  = yv12_to_rgb565_c;
228          yv12_to_bgr     = yv12_to_bgr_c;          yv12_to_rgb24  = yv12_to_rgb24_c;
229          yv12_to_bgra    = yv12_to_bgra_c;          yv12_to_rgb32  = yv12_to_rgb32_c;
230          yv12_to_abgr    = yv12_to_abgr_c;          yv12_to_yuv    = yv12_to_yuv_c;
         yv12_to_rgba    = yv12_to_rgba_c;  
231          yv12_to_yuyv    = yv12_to_yuyv_c;          yv12_to_yuyv    = yv12_to_yuyv_c;
232          yv12_to_uyvy    = yv12_to_uyvy_c;          yv12_to_uyvy    = yv12_to_uyvy_c;
233    
         yv12_to_rgb555i = yv12_to_rgb555i_c;  
         yv12_to_rgb565i = yv12_to_rgb565i_c;  
         yv12_to_bgri    = yv12_to_bgri_c;  
         yv12_to_bgrai   = yv12_to_bgrai_c;  
         yv12_to_abgri   = yv12_to_abgri_c;  
         yv12_to_rgbai   = yv12_to_rgbai_c;  
         yv12_to_yuyvi   = yv12_to_yuyvi_c;  
         yv12_to_uyvyi   = yv12_to_uyvyi_c;  
   
234          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
235          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
236          sad16    = sad16_c;          sad16    = sad16_c;
# Line 299  Line 238 
238          sad16bi  = sad16bi_c;          sad16bi  = sad16bi_c;
239          sad8bi   = sad8bi_c;          sad8bi   = sad8bi_c;
240          dev16    = dev16_c;          dev16    = dev16_c;
         sad16v   = sad16v_c;  
241    
242  //      Halfpel8_Refine = Halfpel8_Refine_c;          Halfpel8_Refine = Halfpel8_Refine_c;
243    
244  #ifdef ARCH_X86  #ifdef ARCH_X86
   
         if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) ||  
                 (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) ||  
                 (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2))  
         {  
                 /* Restore FPU context : emms_c is a nop functions */  
                 emms = emms_mmx;  
         }  
   
245          if ((cpu_flags & XVID_CPU_MMX) > 0) {          if ((cpu_flags & XVID_CPU_MMX) > 0) {
246    
247                  /* Forward and Inverse Discrete Cosine Transformation functions */                  /* Forward and Inverse Discrete Cosine Transformation functions */
248                  fdct = fdct_mmx;                  fdct = fdct_mmx;
249                  idct = idct_mmx;                  idct = idct_mmx;
250    
251                    /* To restore FPU context after mmx use */
252                    emms = emms_mmx;
253    
254                  /* Quantization related functions */                  /* Quantization related functions */
255                  quant_intra   = quant_intra_mmx;                  quant_intra   = quant_intra_mmx;
256                  dequant_intra = dequant_intra_mmx;                  dequant_intra = dequant_intra_mmx;
# Line 338  Line 270 
270                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
271                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
272    
                 /* Interlacing Functions */  
                 MBFieldTest = MBFieldTest_mmx;  
273    
274                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
275                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
276                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
277                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
278    
279                  interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;                  /* Image RGB->YV12 related functions */
280                  interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;                  rgb24_to_yv12 = rgb24_to_yv12_mmx;
281                    rgb32_to_yv12 = rgb32_to_yv12_mmx;
282                  interpolate8x8_avg2 = interpolate8x8_avg2_mmx;                  yuv_to_yv12   = yuv_to_yv12_mmx;
                 interpolate8x8_avg4 = interpolate8x8_avg4_mmx;  
   
                 /* reduced resolution */  
                 copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;  
                 add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;  
                 hfilter_31 = xvid_HFilter_31_mmx;  
                 filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx;  
                 filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx;  
   
                 /* image input xxx_to_yv12 related functions */  
                 yv12_to_yv12  = yv12_to_yv12_mmx;  
                 bgr_to_yv12   = bgr_to_yv12_mmx;  
                 bgra_to_yv12  = bgra_to_yv12_mmx;  
283                  yuyv_to_yv12  = yuyv_to_yv12_mmx;                  yuyv_to_yv12  = yuyv_to_yv12_mmx;
284                  uyvy_to_yv12  = uyvy_to_yv12_mmx;                  uyvy_to_yv12  = uyvy_to_yv12_mmx;
285    
286                  /* image output yv12_to_xxx related functions */                  /* Image YV12->RGB related functions */
287                  yv12_to_bgr   = yv12_to_bgr_mmx;                  yv12_to_rgb24 = yv12_to_rgb24_mmx;
288                  yv12_to_bgra  = yv12_to_bgra_mmx;                  yv12_to_rgb32 = yv12_to_rgb32_mmx;
289                  yv12_to_yuyv  = yv12_to_yuyv_mmx;                  yv12_to_yuyv  = yv12_to_yuyv_mmx;
290                  yv12_to_uyvy  = yv12_to_uyvy_mmx;                  yv12_to_uyvy  = yv12_to_uyvy_mmx;
291    
                 yv12_to_yuyvi = yv12_to_yuyvi_mmx;  
                 yv12_to_uyvyi = yv12_to_uyvyi_mmx;  
   
292                  /* Motion estimation related functions */                  /* Motion estimation related functions */
293                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
294                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
# Line 382  Line 296 
296                  sad16bi = sad16bi_mmx;                  sad16bi = sad16bi_mmx;
297                  sad8bi  = sad8bi_mmx;                  sad8bi  = sad8bi_mmx;
298                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
                 sad16v   = sad16v_mmx;  
299    
300          }          }
301    
# Line 392  Line 305 
305                  /* ME functions */                  /* ME functions */
306                  sad16bi = sad16bi_3dn;                  sad16bi = sad16bi_3dn;
307                  sad8bi  = sad8bi_3dn;                  sad8bi  = sad8bi_3dn;
   
                 yuyv_to_yv12  = yuyv_to_yv12_3dn;  
                 uyvy_to_yv12  = uyvy_to_yv12_3dn;  
308          }          }
309    
310    
# Line 408  Line 318 
318                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;
319                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
320    
                 /* reduced resolution */  
                 copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm;  
                 add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;  
   
321                  /* Quantization */                  /* Quantization */
322                  dequant_intra = dequant_intra_xmm;                  dequant_intra = dequant_intra_xmm;
323                  dequant_inter = dequant_inter_xmm;                  dequant_inter = dequant_inter_xmm;
# Line 420  Line 326 
326                  transfer_8to16sub2 = transfer_8to16sub2_xmm;                  transfer_8to16sub2 = transfer_8to16sub2_xmm;
327    
328                  /* Colorspace transformation */                  /* Colorspace transformation */
329                  yv12_to_yv12  = yv12_to_yv12_xmm;                  yuv_to_yv12 = yuv_to_yv12_xmm;
                 yuyv_to_yv12  = yuyv_to_yv12_xmm;  
                 uyvy_to_yv12  = uyvy_to_yv12_xmm;  
330    
331                  /* ME functions */                  /* ME functions */
332                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
# Line 430  Line 334 
334                  sad16bi = sad16bi_xmm;                  sad16bi = sad16bi_xmm;
335                  sad8bi  = sad8bi_xmm;                  sad8bi  = sad8bi_xmm;
336                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
337                  sad16v   = sad16v_xmm;  
338          }          }
339    
340          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
# Line 476  Line 380 
380            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
381            sad8 = sad8_ia64;            sad8 = sad8_ia64;
382            dev16 = dev16_ia64;            dev16 = dev16_ia64;
383  //        Halfpel8_Refine = Halfpel8_Refine_ia64;            Halfpel8_Refine = Halfpel8_Refine_ia64;
384            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
385            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
386            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;
# Line 508  Line 412 
412          return XVID_ERR_OK;          return XVID_ERR_OK;
413  }  }
414    
   
   
 static int  
 xvid_init_convert(XVID_INIT_CONVERTINFO* convert)  
 {  
         // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);  
         const int width = convert->width;  
         const int height = convert->height;  
         const int width2 = convert->width/2;  
         const int height2 = convert->height/2;  
         IMAGE img;  
   
         switch (convert->input.colorspace & ~XVID_CSP_VFLIP)  
         {  
                 case XVID_CSP_YV12 :  
                         img.y = convert->input.y;  
                         img.v = (uint8_t*)convert->input.y + width*height;  
                         img.u = (uint8_t*)convert->input.y + width*height + width2*height2;  
                         image_output(&img, width, height, width,  
                                                 convert->output.y, convert->output.y_stride,  
                                                 convert->output.colorspace, convert->interlacing);  
                         break;  
   
                 default :  
                         return XVID_ERR_FORMAT;  
         }  
   
   
         emms();  
         return XVID_ERR_OK;  
 }  
   
   
 int  
 xvid_init(void *handle,  
                   int opt,  
                   void *param1,  
                   void *param2)  
 {  
         switch(opt)  
         {  
                 case XVID_INIT_INIT :  
                         return xvid_init_init((XVID_INIT_PARAM*)param1);  
   
                 case XVID_INIT_CONVERT :  
                         return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);  
   
                 default :  
                         return XVID_ERR_FAIL;  
         }  
 }  
   
415  /*****************************************************************************  /*****************************************************************************
416   * XviD Native decoder entry point   * XviD Native decoder entry point
417   *   *
# Line 578  Line 430 
430  {  {
431          switch (opt) {          switch (opt) {
432          case XVID_DEC_DECODE:          case XVID_DEC_DECODE:
433                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1);
434    
435          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
436                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((XVID_DEC_PARAM *) param1);
# Line 610  Line 462 
462  {  {
463          switch (opt) {          switch (opt) {
464          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
   
                 if (((Encoder *) handle)->mbParam.max_bframes >= 0)  
                 return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,  
                                                           (XVID_ENC_STATS *) param2);  
                 else  
465                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,
466                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
467    

Legend:
Removed from v.1.33.2.17  
changed lines
  Added in v.1.35

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