[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.32, Sun Jul 21 23:34:08 2002 UTC revision 1.33.2.16, Sun Dec 8 06:43:34 2002 UTC
# Line 49  Line 49 
49  #include "dct/fdct.h"  #include "dct/fdct.h"
50  #include "image/colorspace.h"  #include "image/colorspace.h"
51  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
52    #include "image/reduced.h"
53  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
54    #include "utils/mbfunctions.h"
55  #include "quant/quant_h263.h"  #include "quant/quant_h263.h"
56  #include "quant/quant_mpeg4.h"  #include "quant/quant_mpeg4.h"
57  #include "motion/motion.h"  #include "motion/motion.h"
# Line 139  Line 141 
141   *   *
142   ****************************************************************************/   ****************************************************************************/
143    
144  int  
145  xvid_init(void *handle,  static
146                    int opt,  int xvid_init_init(XVID_INIT_PARAM * init_param)
                   void *param1,  
                   void *param2)  
147  {  {
148          int cpu_flags;          int cpu_flags;
         XVID_INIT_PARAM *init_param;  
   
         init_param = (XVID_INIT_PARAM *) param1;  
149    
150          /* Inform the client the API version */          /* Inform the client the API version */
151          init_param->api_version = API_VERSION;          init_param->api_version = API_VERSION;
# Line 216  Line 213 
213          transfer_16to8add  = transfer_16to8add_c;          transfer_16to8add  = transfer_16to8add_c;
214          transfer8x8_copy   = transfer8x8_copy_c;          transfer8x8_copy   = transfer8x8_copy_c;
215    
216            /* Interlacing functions */
217            MBFieldTest = MBFieldTest_c;
218    
219          /* Image interpolation related functions */          /* Image interpolation related functions */
220          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;
221          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;
222          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
223    
224            interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;
225            interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;
226            interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;
227    
228            interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;
229            interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;
230            interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;
231    
232            interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;
233            interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;
234    
235            interpolate8x8_avg2 = interpolate8x8_avg2_c;
236            interpolate8x8_avg4 = interpolate8x8_avg4_c;
237    
238            /* reduced resoltuion */
239    
240    #ifdef ARCH_X86
241            vfilter_31 = xvid_VFilter_31_x86;
242            hfilter_31 = xvid_HFilter_31_x86;
243    #else
244            copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;
245            add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;
246            vfilter_31 = xvid_VFilter_31_C;
247            hfilter_31 = xvid_HFilter_31_C;
248    #endif
249    
250          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
251          colorspace_init();          colorspace_init();
252    
253          /* All colorspace transformation functions User Format->YV12 */          /* All colorspace transformation functions User Format->YV12 */
254            yv12_to_yv12    = yv12_to_yv12_c;
255          rgb555_to_yv12 = rgb555_to_yv12_c;          rgb555_to_yv12 = rgb555_to_yv12_c;
256          rgb565_to_yv12 = rgb565_to_yv12_c;          rgb565_to_yv12 = rgb565_to_yv12_c;
257          rgb24_to_yv12  = rgb24_to_yv12_c;          bgr_to_yv12     = bgr_to_yv12_c;
258          rgb32_to_yv12  = rgb32_to_yv12_c;          bgra_to_yv12    = bgra_to_yv12_c;
259          yuv_to_yv12    = yuv_to_yv12_c;          abgr_to_yv12    = abgr_to_yv12_c;
260            rgba_to_yv12    = rgba_to_yv12_c;
261          yuyv_to_yv12   = yuyv_to_yv12_c;          yuyv_to_yv12   = yuyv_to_yv12_c;
262          uyvy_to_yv12   = uyvy_to_yv12_c;          uyvy_to_yv12   = uyvy_to_yv12_c;
263    
264            rgb555i_to_yv12 = rgb555i_to_yv12_c;
265            rgb565i_to_yv12 = rgb565i_to_yv12_c;
266            bgri_to_yv12    = bgri_to_yv12_c;
267            bgrai_to_yv12   = bgrai_to_yv12_c;
268            abgri_to_yv12   = abgri_to_yv12_c;
269            rgbai_to_yv12   = rgbai_to_yv12_c;
270            yuyvi_to_yv12   = yuyvi_to_yv12_c;
271            uyvyi_to_yv12   = uyvyi_to_yv12_c;
272    
273    
274          /* All colorspace transformation functions YV12->User format */          /* All colorspace transformation functions YV12->User format */
275          yv12_to_rgb555 = yv12_to_rgb555_c;          yv12_to_rgb555 = yv12_to_rgb555_c;
276          yv12_to_rgb565 = yv12_to_rgb565_c;          yv12_to_rgb565 = yv12_to_rgb565_c;
277          yv12_to_rgb24  = yv12_to_rgb24_c;          yv12_to_bgr     = yv12_to_bgr_c;
278          yv12_to_rgb32  = yv12_to_rgb32_c;          yv12_to_bgra    = yv12_to_bgra_c;
279          yv12_to_yuv    = yv12_to_yuv_c;          yv12_to_abgr    = yv12_to_abgr_c;
280            yv12_to_rgba    = yv12_to_rgba_c;
281          yv12_to_yuyv   = yv12_to_yuyv_c;          yv12_to_yuyv   = yv12_to_yuyv_c;
282          yv12_to_uyvy   = yv12_to_uyvy_c;          yv12_to_uyvy   = yv12_to_uyvy_c;
283    
284            yv12_to_rgb555i = yv12_to_rgb555i_c;
285            yv12_to_rgb565i = yv12_to_rgb565i_c;
286            yv12_to_bgri    = yv12_to_bgri_c;
287            yv12_to_bgrai   = yv12_to_bgrai_c;
288            yv12_to_abgri   = yv12_to_abgri_c;
289            yv12_to_rgbai   = yv12_to_rgbai_c;
290            yv12_to_yuyvi   = yv12_to_yuyvi_c;
291            yv12_to_uyvyi   = yv12_to_uyvyi_c;
292    
293          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
294          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
295          sad16    = sad16_c;          sad16    = sad16_c;
         sad16bi  = sad16bi_c;  
296          sad8     = sad8_c;          sad8     = sad8_c;
297          dev16    = dev16_c;          sad16bi  = sad16bi_c;
298          sad8bi   = sad8bi_c;          sad8bi   = sad8bi_c;
299          Halfpel8_Refine = Halfpel8_Refine_c;          dev16    = dev16_c;
300            sad16v   = sad16v_c;
301    
302    //      Halfpel8_Refine = Halfpel8_Refine_c;
303    
304  #ifdef ARCH_X86  #ifdef ARCH_X86
305    
306            if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) ||
307                    (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) ||
308                    (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2))
309            {
310                    /* Restore FPU context : emms_c is a nop functions */
311                    emms = emms_mmx;
312            }
313    
314          if ((cpu_flags & XVID_CPU_MMX) > 0) {          if ((cpu_flags & XVID_CPU_MMX) > 0) {
315    
316                  /* Forward and Inverse Discrete Cosine Transformation functions */                  /* Forward and Inverse Discrete Cosine Transformation functions */
317                  fdct = fdct_mmx;                  fdct = fdct_mmx;
318                  idct = idct_mmx;                  idct = idct_mmx;
319    
                 /* To restore FPU context after mmx use */  
                 emms = emms_mmx;  
   
320                  /* Quantization related functions */                  /* Quantization related functions */
321                  quant_intra   = quant_intra_mmx;                  quant_intra   = quant_intra_mmx;
322                  dequant_intra = dequant_intra_mmx;                  dequant_intra = dequant_intra_mmx;
# Line 280  Line 336 
336                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
337                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
338    
339                    /* Interlacing Functions */
340                    MBFieldTest = MBFieldTest_mmx;
341    
342                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
343                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
344                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
345                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
346    
347                  /* Image RGB->YV12 related functions */                  interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;
348                  rgb24_to_yv12 = rgb24_to_yv12_mmx;                  interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;
349                  rgb32_to_yv12 = rgb32_to_yv12_mmx;  
350                  yuv_to_yv12   = yuv_to_yv12_mmx;                  interpolate8x8_avg2 = interpolate8x8_avg2_mmx;
351                    interpolate8x8_avg4 = interpolate8x8_avg4_mmx;
352    
353                    /* reduced resolution */
354                    copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;
355                    add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;
356                    hfilter_31 = xvid_HFilter_31_mmx;
357    
358                    /* image input xxx_to_yv12 related functions */
359                    yv12_to_yv12  = yv12_to_yv12_mmx;
360                    bgr_to_yv12   = bgr_to_yv12_mmx;
361                    bgra_to_yv12  = bgra_to_yv12_mmx;
362                  yuyv_to_yv12  = yuyv_to_yv12_mmx;                  yuyv_to_yv12  = yuyv_to_yv12_mmx;
363                  uyvy_to_yv12  = uyvy_to_yv12_mmx;                  uyvy_to_yv12  = uyvy_to_yv12_mmx;
364    
365                  /* Image YV12->RGB related functions */                  /* image output yv12_to_xxx related functions */
366                  yv12_to_rgb24 = yv12_to_rgb24_mmx;                  yv12_to_bgr   = yv12_to_bgr_mmx;
367                  yv12_to_rgb32 = yv12_to_rgb32_mmx;                  yv12_to_bgra  = yv12_to_bgra_mmx;
368                  yv12_to_yuyv  = yv12_to_yuyv_mmx;                  yv12_to_yuyv  = yv12_to_yuyv_mmx;
369                  yv12_to_uyvy  = yv12_to_uyvy_mmx;                  yv12_to_uyvy  = yv12_to_uyvy_mmx;
370    
371                    yv12_to_yuyvi = yv12_to_yuyvi_mmx;
372                    yv12_to_uyvyi = yv12_to_uyvyi_mmx;
373    
374                  /* Motion estimation related functions */                  /* Motion estimation related functions */
375                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
376                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
377                  sad8     = sad8_mmx;                  sad8     = sad8_mmx;
378                    sad16bi = sad16bi_mmx;
379                    sad8bi  = sad8bi_mmx;
380                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
381                    sad16v   = sad16v_mmx;
382    
383          }          }
384    
385            /* these 3dnow functions are faster than mmx, but slower than xmm. */
386            if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
387    
388                    /* ME functions */
389                    sad16bi = sad16bi_3dn;
390                    sad8bi  = sad8bi_3dn;
391    
392                    yuyv_to_yv12  = yuyv_to_yv12_3dn;
393                    uyvy_to_yv12  = uyvy_to_yv12_3dn;
394            }
395    
396    
397          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {
398    
399                  /* Inverse DCT */                  /* Inverse DCT */
# Line 317  Line 404 
404                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;
405                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
406    
407                    /* reduced resolution */
408                    copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm;
409                    add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;
410    
411                  /* Quantization */                  /* Quantization */
412                  dequant_intra = dequant_intra_xmm;                  dequant_intra = dequant_intra_xmm;
413                  dequant_inter = dequant_inter_xmm;                  dequant_inter = dequant_inter_xmm;
# Line 325  Line 416 
416                  transfer_8to16sub2 = transfer_8to16sub2_xmm;                  transfer_8to16sub2 = transfer_8to16sub2_xmm;
417    
418                  /* Colorspace transformation */                  /* Colorspace transformation */
419                  yuv_to_yv12 = yuv_to_yv12_xmm;                  yv12_to_yv12  = yv12_to_yv12_xmm;
420                    yuyv_to_yv12  = yuyv_to_yv12_xmm;
421                    uyvy_to_yv12  = uyvy_to_yv12_xmm;
422    
423                  /* ME functions */                  /* ME functions */
424                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
                 sad16bi = sad16bi_xmm;  
425                  sad8  = sad8_xmm;                  sad8  = sad8_xmm;
426                    sad16bi = sad16bi_xmm;
427                    sad8bi  = sad8bi_xmm;
428                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
429                    sad16v   = sad16v_xmm;
430          }          }
431    
432          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
# Line 378  Line 472 
472            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
473            sad8 = sad8_ia64;            sad8 = sad8_ia64;
474            dev16 = dev16_ia64;            dev16 = dev16_ia64;
475            Halfpel8_Refine = Halfpel8_Refine_ia64;  //        Halfpel8_Refine = Halfpel8_Refine_ia64;
476            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
477            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
478            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;
# Line 410  Line 504 
504          return XVID_ERR_OK;          return XVID_ERR_OK;
505  }  }
506    
507    
508    
509    static int
510    xvid_init_convert(XVID_INIT_CONVERTINFO* convert)
511    {
512            // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
513            const int width = convert->width;
514            const int height = convert->height;
515            const int width2 = convert->width/2;
516            const int height2 = convert->height/2;
517            IMAGE img;
518    
519            switch (convert->input.colorspace & ~XVID_CSP_VFLIP)
520            {
521                    case XVID_CSP_YV12 :
522                            img.y = convert->input.y;
523                            img.v = (uint8_t*)convert->input.y + width*height;
524                            img.u = (uint8_t*)convert->input.y + width*height + width2*height2;
525                            image_output(&img, width, height, width,
526                                                    convert->output.y, convert->output.y_stride,
527                                                    convert->output.colorspace, convert->interlacing);
528                            break;
529    
530                    default :
531                            return XVID_ERR_FORMAT;
532            }
533    
534    
535            emms();
536            return XVID_ERR_OK;
537    }
538    
539    
540    int
541    xvid_init(void *handle,
542                      int opt,
543                      void *param1,
544                      void *param2)
545    {
546            switch(opt)
547            {
548                    case XVID_INIT_INIT :
549                            return xvid_init_init((XVID_INIT_PARAM*)param1);
550    
551                    case XVID_INIT_CONVERT :
552                            return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);
553    
554                    default :
555                            return XVID_ERR_FAIL;
556            }
557    }
558    
559  /*****************************************************************************  /*****************************************************************************
560   * XviD Native decoder entry point   * XviD Native decoder entry point
561   *   *
# Line 428  Line 574 
574  {  {
575          switch (opt) {          switch (opt) {
576          case XVID_DEC_DECODE:          case XVID_DEC_DECODE:
577                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1);                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);
578    
579          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
580                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((XVID_DEC_PARAM *) param1);
# Line 460  Line 606 
606  {  {
607          switch (opt) {          switch (opt) {
608          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
609  #ifdef BFRAMES  
610                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)
611                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,
612                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
613                  else                  else
 #endif  
614                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,
615                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
616    

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33.2.16

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