[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.45, Fri Feb 21 00:00:57 2003 UTC revision 1.45.2.9, Thu Jul 10 17:39:51 2003 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-2003 Peter Ross <pross@xvid.org>
7     *
8   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
9   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
10   *  the Free Software Foundation ; either version 2 of the License, or   *  the Free Software Foundation ; either version 2 of the License, or
# Line 45  Line 47 
47  #include "utils/timer.h"  #include "utils/timer.h"
48  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
49    
50    #if defined(_DEBUG)
51    unsigned int xvid_debug = 0; /* xvid debug mask */
52    #endif
53    
54  #if defined(ARCH_IS_IA32)  #if defined(ARCH_IS_IA32)
55    
56  #if defined(_MSC_VER)  #if defined(_MSC_VER)
# Line 153  Line 159 
159    
160    
161  static  static
162  int xvid_init_init(XVID_INIT_PARAM * init_param)  int xvid_gbl_init(xvid_gbl_init_t * init)
 {  
         int cpu_flags;  
   
         /* Inform the client the API version */  
         init_param->api_version = API_VERSION;  
   
         /* Inform the client the core build - unused because we're still alpha */  
         init_param->core_build = 1000;  
   
         /* Do we have to force CPU features  ? */  
         if ((init_param->cpu_flags & XVID_CPU_FORCE)) {  
   
                 cpu_flags = init_param->cpu_flags;  
   
         } else {  
   
                 cpu_flags = detect_cpu_flags();  
         }  
   
         if ((init_param->cpu_flags & XVID_CPU_CHKONLY))  
163          {          {
164                  init_param->cpu_flags = cpu_flags;          unsigned int cpu_flags;
                 return XVID_ERR_OK;  
         }  
165    
166          init_param->cpu_flags = cpu_flags;          if (XVID_MAJOR(init->version) != 1) /* v1.x.x */
167                    return XVID_ERR_VERSION;
168    
169            cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();
170    
171          /* Initialize the function pointers */          /* Initialize the function pointers */
172          idct_int32_init();          idct_int32_init();
# Line 302  Line 288 
288    
289  #if defined(ARCH_IS_IA32)  #if defined(ARCH_IS_IA32)
290    
291          if ((cpu_flags & XVID_CPU_ASM))          if ((cpu_flags & XVID_CPU_ASM)) {
         {  
292                  vfilter_31 = xvid_VFilter_31_x86;                  vfilter_31 = xvid_VFilter_31_x86;
293                  hfilter_31 = xvid_HFilter_31_x86;                  hfilter_31 = xvid_HFilter_31_x86;
294          }          }
# Line 502  Line 487 
487                  dev16    = dev16_sse2;                  dev16    = dev16_sse2;
488  #endif  #endif
489                  /* Forward and Inverse DCT */                  /* Forward and Inverse DCT */
490    #if 0 /* Both function are known to be unprecise, better keep them deactivated */
491                  idct  = idct_sse2;                  idct  = idct_sse2;
492                  fdct = fdct_sse2;                  fdct = fdct_sse2;
493    #endif
494          }          }
495  #endif  #endif
496    
# Line 530  Line 517 
517            transfer_8to16sub2 = transfer_8to16sub2_ia64;            transfer_8to16sub2 = transfer_8to16sub2_ia64;
518            transfer_16to8add = transfer_16to8add_ia64;            transfer_16to8add = transfer_16to8add_ia64;
519            transfer8x8_copy = transfer8x8_copy_ia64;            transfer8x8_copy = transfer8x8_copy_ia64;
           DPRINTF(DPRINTF_DEBUG, "Using IA-64 assembler routines.");  
520          }          }
521  #endif  #endif
522    
# Line 552  Line 538 
538          }          }
539  #endif  #endif
540    
541          return XVID_ERR_OK;  #if defined(_DEBUG)
542        xvid_debug = init->debug;
543    #endif
544    
545        return 0;
546  }  }
547    
548    
549    static int
550    xvid_gbl_info(xvid_gbl_info_t * info)
551    {
552            if (XVID_MAJOR(info->version) != 1) /* v1.x.x */
553                    return XVID_ERR_VERSION;
554    
555            info->actual_version = XVID_VERSION;
556            info->build = "dev-api-4";
557            info->cpu_flags = detect_cpu_flags();
558    
559    #if defined(_SMP) && defined(WIN32)
560            info->num_threads = pthread_num_processors_np();;
561    #else
562            info->num_threads = 0;
563    #endif
564    
565            return 0;
566    }
567    
568    
569  static int  static int
570  xvid_init_convert(XVID_INIT_CONVERTINFO* convert)  xvid_gbl_convert(xvid_gbl_convert_t* convert)
571  {  {
572  /*          int width;
573          const int flip1 =          int height;
574                  (convert->input.colorspace & XVID_CSP_VFLIP) ^          int width2;
575                  (convert->output.colorspace & XVID_CSP_VFLIP);          int height2;
 */  
         const int width = convert->width;  
         const int height = convert->height;  
         const int width2 = convert->width/2;  
         const int height2 = convert->height/2;  
576          IMAGE img;          IMAGE img;
577    
578          switch (convert->input.colorspace & ~XVID_CSP_VFLIP)          if (XVID_MAJOR(convert->version) != 1)   /* v1.x.x */
579                  return XVID_ERR_VERSION;
580    
581    #if 0
582            const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
583    #endif
584            width = convert->width;
585            height = convert->height;
586            width2 = convert->width/2;
587            height2 = convert->height/2;
588    
589            switch (convert->input.csp & ~XVID_CSP_VFLIP)
590          {          {
591                  case XVID_CSP_YV12 :                  case XVID_CSP_YV12 :
592                          img.y = convert->input.y;                          img.y = convert->input.plane[0];
593                          img.v = (uint8_t*)convert->input.y + width*height;                          img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height;
594                          img.u = (uint8_t*)convert->input.y + width*height + width2*height2;                          img.u = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height + (convert->input.stride[0]/2)*height2;
595                          image_output(&img, width, height, width,                          image_output(&img, width, height, width,
596                                                  convert->output.y, convert->output.y_stride,                                                  (uint8_t**)convert->output.plane, convert->output.stride,
597                                                  convert->output.colorspace, convert->interlacing);                                                  convert->output.csp, convert->interlacing);
598                          break;                          break;
599    
600                  default :                  default :
# Line 588  Line 603 
603    
604    
605          emms();          emms();
606          return XVID_ERR_OK;          return 0;
607  }  }
608    
609    
# Line 637  Line 652 
652  {  {
653          int i, diff = 0;          int i, diff = 0;
654          for (i = 0; i < size; i++)          for (i = 0; i < size; i++)
655                  diff += ABS(blockA[i]-blockB[i]);                  diff += abs(blockA[i]-blockB[i]);
656          return diff;          return diff;
657  }  }
658    
# Line 954  Line 969 
969    
970          emms();          emms();
971    
972          return XVID_ERR_OK;          return 0;
973  }  }
974    
975    
976    /*****************************************************************************
977     * XviD Global Entry point
978     *
979     * Well this function initialize all internal function pointers according
980     * to the CPU features forced by the library client or autodetected (depending
981     * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all
982     * image colorspace transformation tables.
983     *
984     ****************************************************************************/
985    
986    
987  int  int
988  xvid_init(void *handle,  xvid_global(void *handle,
989                    int opt,                    int opt,
990                    void *param1,                    void *param1,
991                    void *param2)                    void *param2)
992  {  {
993          switch(opt)          switch(opt)
994          {          {
995                  case XVID_INIT_INIT :                  case XVID_GBL_INIT :
996                          return xvid_init_init((XVID_INIT_PARAM*)param1);                          return xvid_gbl_init((xvid_gbl_init_t*)param1);
997    
998                  case XVID_INIT_CONVERT :          case XVID_GBL_INFO :
999                          return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);              return xvid_gbl_info((xvid_gbl_info_t*)param1);
1000    
1001                  case XVID_INIT_TEST :                  case XVID_GBL_CONVERT :
1002                            return xvid_gbl_convert((xvid_gbl_convert_t*)param1);
1003    
1004                    case XVID_GBL_TEST :
1005                  {                  {
1006                          ptr_t flags = (ptr_t)param1;                          ptr_t flags = (ptr_t)param1;
1007                          return xvid_init_test((int)flags);                          return xvid_init_test((int)flags);
# Line 999  Line 1028 
1028                          void *param2)                          void *param2)
1029  {  {
1030          switch (opt) {          switch (opt) {
         case XVID_DEC_DECODE:  
                 return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);  
   
1031          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
1032                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((xvid_dec_create_t *) param1);
1033    
1034          case XVID_DEC_DESTROY:          case XVID_DEC_DESTROY:
1035                  return decoder_destroy((DECODER *) handle);                  return decoder_destroy((DECODER *) handle);
1036    
1037            case XVID_DEC_DECODE:
1038                    return decoder_decode((DECODER *) handle, (xvid_dec_frame_t *) param1, (xvid_dec_stats_t*) param2);
1039    
1040          default:          default:
1041                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1042          }          }
# Line 1033  Line 1062 
1062          switch (opt) {          switch (opt) {
1063          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
1064    
1065                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  return enc_encode((Encoder *) handle,
1066                          return encoder_encode_bframes((Encoder *) handle,                                                            (xvid_enc_frame_t *) param1,
1067                                                                                    (XVID_ENC_FRAME *) param1,                                                            (xvid_enc_stats_t *) param2);
                                                                                   (XVID_ENC_STATS *) param2);  
                 else  
                         return encoder_encode((Encoder *) handle,  
                                                                   (XVID_ENC_FRAME *) param1,  
                                                                   (XVID_ENC_STATS *) param2);  
1068    
1069          case XVID_ENC_CREATE:          case XVID_ENC_CREATE:
1070                  return encoder_create((XVID_ENC_PARAM *) param1);                  return enc_create((xvid_enc_create_t *) param1);
1071    
1072          case XVID_ENC_DESTROY:          case XVID_ENC_DESTROY:
1073                  return encoder_destroy((Encoder *) handle);                  return enc_destroy((Encoder *) handle);
1074    
1075          default:          default:
1076                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.45.2.9

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