[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, Tue Jul 23 12:59:57 2002 UTC revision 1.33.2.13, Fri Nov 8 10:10:48 2002 UTC
# Line 50  Line 50 
50  #include "image/colorspace.h"  #include "image/colorspace.h"
51  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
52  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
53    #include "utils/mbfunctions.h"
54  #include "quant/quant_h263.h"  #include "quant/quant_h263.h"
55  #include "quant/quant_mpeg4.h"  #include "quant/quant_mpeg4.h"
56  #include "motion/motion.h"  #include "motion/motion.h"
# Line 139  Line 140 
140   *   *
141   ****************************************************************************/   ****************************************************************************/
142    
143  int  
144  xvid_init(void *handle,  static
145                    int opt,  int xvid_init_init(XVID_INIT_PARAM * init_param)
                   void *param1,  
                   void *param2)  
146  {  {
147          int cpu_flags;          int cpu_flags;
         XVID_INIT_PARAM *init_param;  
   
         init_param = (XVID_INIT_PARAM *) param1;  
148    
149          /* Inform the client the API version */          /* Inform the client the API version */
150          init_param->api_version = API_VERSION;          init_param->api_version = API_VERSION;
# Line 216  Line 212 
212          transfer_16to8add  = transfer_16to8add_c;          transfer_16to8add  = transfer_16to8add_c;
213          transfer8x8_copy   = transfer8x8_copy_c;          transfer8x8_copy   = transfer8x8_copy_c;
214    
215            /* Interlacing functions */
216            MBFieldTest = MBFieldTest_c;
217    
218          /* Image interpolation related functions */          /* Image interpolation related functions */
219          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;
220          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;
221          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
222    
223            interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;
224            interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;
225            interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;
226    
227            interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;
228            interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;
229            interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;
230    
231            interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;
232            interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;
233    
234            interpolate8x8_avg2 = interpolate8x8_avg2_c;
235            interpolate8x8_avg4 = interpolate8x8_avg4_c;
236    
237          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
238          colorspace_init();          colorspace_init();
239    
240          /* All colorspace transformation functions User Format->YV12 */          /* All colorspace transformation functions User Format->YV12 */
241            yv12_to_yv12    = yv12_to_yv12_c;
242          rgb555_to_yv12 = rgb555_to_yv12_c;          rgb555_to_yv12 = rgb555_to_yv12_c;
243          rgb565_to_yv12 = rgb565_to_yv12_c;          rgb565_to_yv12 = rgb565_to_yv12_c;
244          rgb24_to_yv12  = rgb24_to_yv12_c;          bgr_to_yv12     = bgr_to_yv12_c;
245          rgb32_to_yv12  = rgb32_to_yv12_c;          bgra_to_yv12    = bgra_to_yv12_c;
246          yuv_to_yv12    = yuv_to_yv12_c;          abgr_to_yv12    = abgr_to_yv12_c;
247            rgba_to_yv12    = rgba_to_yv12_c;
248          yuyv_to_yv12   = yuyv_to_yv12_c;          yuyv_to_yv12   = yuyv_to_yv12_c;
249          uyvy_to_yv12   = uyvy_to_yv12_c;          uyvy_to_yv12   = uyvy_to_yv12_c;
250    
251            rgb555i_to_yv12 = rgb555i_to_yv12_c;
252            rgb565i_to_yv12 = rgb565i_to_yv12_c;
253            bgri_to_yv12    = bgri_to_yv12_c;
254            bgrai_to_yv12   = bgrai_to_yv12_c;
255            abgri_to_yv12   = abgri_to_yv12_c;
256            rgbai_to_yv12   = rgbai_to_yv12_c;
257            yuyvi_to_yv12   = yuyvi_to_yv12_c;
258            uyvyi_to_yv12   = uyvyi_to_yv12_c;
259    
260    
261          /* All colorspace transformation functions YV12->User format */          /* All colorspace transformation functions YV12->User format */
262          yv12_to_rgb555 = yv12_to_rgb555_c;          yv12_to_rgb555 = yv12_to_rgb555_c;
263          yv12_to_rgb565 = yv12_to_rgb565_c;          yv12_to_rgb565 = yv12_to_rgb565_c;
264          yv12_to_rgb24  = yv12_to_rgb24_c;          yv12_to_bgr     = yv12_to_bgr_c;
265          yv12_to_rgb32  = yv12_to_rgb32_c;          yv12_to_bgra    = yv12_to_bgra_c;
266          yv12_to_yuv    = yv12_to_yuv_c;          yv12_to_abgr    = yv12_to_abgr_c;
267            yv12_to_rgba    = yv12_to_rgba_c;
268          yv12_to_yuyv   = yv12_to_yuyv_c;          yv12_to_yuyv   = yv12_to_yuyv_c;
269          yv12_to_uyvy   = yv12_to_uyvy_c;          yv12_to_uyvy   = yv12_to_uyvy_c;
270    
271            yv12_to_rgb555i = yv12_to_rgb555i_c;
272            yv12_to_rgb565i = yv12_to_rgb565i_c;
273            yv12_to_bgri    = yv12_to_bgri_c;
274            yv12_to_bgrai   = yv12_to_bgrai_c;
275            yv12_to_abgri   = yv12_to_abgri_c;
276            yv12_to_rgbai   = yv12_to_rgbai_c;
277            yv12_to_yuyvi   = yv12_to_yuyvi_c;
278            yv12_to_uyvyi   = yv12_to_uyvyi_c;
279    
280          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
281          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
282          sad16    = sad16_c;          sad16    = sad16_c;
# Line 249  Line 284 
284          sad16bi  = sad16bi_c;          sad16bi  = sad16bi_c;
285          sad8bi   = sad8bi_c;          sad8bi   = sad8bi_c;
286          dev16    = dev16_c;          dev16    = dev16_c;
287            sad16v   = sad16v_c;
288    
289          Halfpel8_Refine = Halfpel8_Refine_c;  //      Halfpel8_Refine = Halfpel8_Refine_c;
290    
291  #ifdef ARCH_X86  #ifdef ARCH_X86
292    
293            if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) ||
294                    (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) ||
295                    (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2))
296            {
297                    /* Restore FPU context : emms_c is a nop functions */
298                    emms = emms_mmx;
299            }
300    
301          if ((cpu_flags & XVID_CPU_MMX) > 0) {          if ((cpu_flags & XVID_CPU_MMX) > 0) {
302    
303                  /* Forward and Inverse Discrete Cosine Transformation functions */                  /* Forward and Inverse Discrete Cosine Transformation functions */
304                  fdct = fdct_mmx;                  fdct = fdct_mmx;
305                  idct = idct_mmx;                  idct = idct_mmx;
306    
                 /* To restore FPU context after mmx use */  
                 emms = emms_mmx;  
   
307                  /* Quantization related functions */                  /* Quantization related functions */
308                  quant_intra   = quant_intra_mmx;                  quant_intra   = quant_intra_mmx;
309                  dequant_intra = dequant_intra_mmx;                  dequant_intra = dequant_intra_mmx;
# Line 281  Line 323 
323                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
324                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
325    
326                    /* Interlacing Functions */
327                    MBFieldTest = MBFieldTest_mmx;
328    
329                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
330                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
331                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
332                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
333    
334                  /* Image RGB->YV12 related functions */                  interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;
335                  rgb24_to_yv12 = rgb24_to_yv12_mmx;                  interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;
336                  rgb32_to_yv12 = rgb32_to_yv12_mmx;  
337                  yuv_to_yv12   = yuv_to_yv12_mmx;  //              interpolate8x8_avg2 = interpolate8x8_avg2_mmx;
338                    interpolate8x8_avg4 = interpolate8x8_avg4_mmx;
339    
340                    /* image input xxx_to_yv12 related functions */
341                    yv12_to_yv12  = yv12_to_yv12_mmx;
342                    bgr_to_yv12   = bgr_to_yv12_mmx;
343                    bgra_to_yv12  = bgra_to_yv12_mmx;
344                  yuyv_to_yv12  = yuyv_to_yv12_mmx;                  yuyv_to_yv12  = yuyv_to_yv12_mmx;
345                  uyvy_to_yv12  = uyvy_to_yv12_mmx;                  uyvy_to_yv12  = uyvy_to_yv12_mmx;
346    
347                  /* Image YV12->RGB related functions */                  /* image output yv12_to_xxx related functions */
348                  yv12_to_rgb24 = yv12_to_rgb24_mmx;                  yv12_to_bgr   = yv12_to_bgr_mmx;
349                  yv12_to_rgb32 = yv12_to_rgb32_mmx;                  yv12_to_bgra  = yv12_to_bgra_mmx;
350                  yv12_to_yuyv  = yv12_to_yuyv_mmx;                  yv12_to_yuyv  = yv12_to_yuyv_mmx;
351                  yv12_to_uyvy  = yv12_to_uyvy_mmx;                  yv12_to_uyvy  = yv12_to_uyvy_mmx;
352    
353                    yv12_to_yuyvi = yv12_to_yuyvi_mmx;
354                    yv12_to_uyvyi = yv12_to_uyvyi_mmx;
355    
356                  /* Motion estimation related functions */                  /* Motion estimation related functions */
357                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
358                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
# Line 307  Line 360 
360                  sad16bi = sad16bi_mmx;                  sad16bi = sad16bi_mmx;
361                  sad8bi  = sad8bi_mmx;                  sad8bi  = sad8bi_mmx;
362                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
363                    sad16v   = sad16v_mmx;
364    
365          }          }
366    
# Line 316  Line 370 
370                  /* ME functions */                  /* ME functions */
371                  sad16bi = sad16bi_3dn;                  sad16bi = sad16bi_3dn;
372                  sad8bi  = sad8bi_3dn;                  sad8bi  = sad8bi_3dn;
373    
374                    yuyv_to_yv12  = yuyv_to_yv12_3dn;
375                    uyvy_to_yv12  = uyvy_to_yv12_3dn;
376          }          }
377    
378    
# Line 337  Line 394 
394                  transfer_8to16sub2 = transfer_8to16sub2_xmm;                  transfer_8to16sub2 = transfer_8to16sub2_xmm;
395    
396                  /* Colorspace transformation */                  /* Colorspace transformation */
397                  yuv_to_yv12 = yuv_to_yv12_xmm;                  yv12_to_yv12  = yv12_to_yv12_xmm;
398                    yuyv_to_yv12  = yuyv_to_yv12_xmm;
399                    uyvy_to_yv12  = uyvy_to_yv12_xmm;
400    
401                  /* ME functions */                  /* ME functions */
402                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
# Line 345  Line 404 
404                  sad16bi = sad16bi_xmm;                  sad16bi = sad16bi_xmm;
405                  sad8bi  = sad8bi_xmm;                  sad8bi  = sad8bi_xmm;
406                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
407                    sad16v   = sad16v_xmm;
408          }          }
409    
410          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
# Line 391  Line 450 
450            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
451            sad8 = sad8_ia64;            sad8 = sad8_ia64;
452            dev16 = dev16_ia64;            dev16 = dev16_ia64;
453            Halfpel8_Refine = Halfpel8_Refine_ia64;  //        Halfpel8_Refine = Halfpel8_Refine_ia64;
454            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
455            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
456            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;
# Line 423  Line 482 
482          return XVID_ERR_OK;          return XVID_ERR_OK;
483  }  }
484    
485    
486    
487    static int
488    xvid_init_convert(XVID_INIT_CONVERTINFO* convert)
489    {
490            const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
491            const int width = convert->width;
492            const int height = convert->height;
493            const int width2 = convert->width/2;
494            const int height2 = convert->height/2;
495            IMAGE img;
496    
497            switch (convert->input.colorspace & ~XVID_CSP_VFLIP)
498            {
499                    case XVID_CSP_YV12 :
500                            img.y = convert->input.y;
501                            img.v = (uint8_t*)convert->input.y + width*height;
502                            img.u = (uint8_t*)convert->input.y + width*height + width2*height2;
503                            image_output(&img, width, height, width,
504                                                    convert->output.y, convert->output.y_stride,
505                                                    convert->output.colorspace, convert->interlacing);
506                            break;
507    
508                    default :
509                            return XVID_ERR_FORMAT;
510            }
511    
512    
513            emms();
514            return XVID_ERR_OK;
515    }
516    
517    
518    int
519    xvid_init(void *handle,
520                      int opt,
521                      void *param1,
522                      void *param2)
523    {
524            switch(opt)
525            {
526                    case XVID_INIT_INIT :
527                            return xvid_init_init((XVID_INIT_PARAM*)param1);
528    
529                    case XVID_INIT_CONVERT :
530                            return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);
531    
532                    default :
533                            return XVID_ERR_FAIL;
534            }
535    }
536    
537  /*****************************************************************************  /*****************************************************************************
538   * XviD Native decoder entry point   * XviD Native decoder entry point
539   *   *
# Line 441  Line 552 
552  {  {
553          switch (opt) {          switch (opt) {
554          case XVID_DEC_DECODE:          case XVID_DEC_DECODE:
555                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1);                  return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);
556    
557          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
558                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((XVID_DEC_PARAM *) param1);
# Line 473  Line 584 
584  {  {
585          switch (opt) {          switch (opt) {
586          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
587  #ifdef BFRAMES  
588                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)
589                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,
590                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
591                  else                  else
 #endif  
592                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,
593                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
594    

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.33.2.13

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