[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.4, Sat May 17 13:26:42 2003 UTC
# Line 45  Line 45 
45  #include "utils/timer.h"  #include "utils/timer.h"
46  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
47    
48    #if defined(_DEBUG)
49    unsigned int xvid_debug = 0; /* xvid debug mask */
50    #endif
51    
52  #if defined(ARCH_IS_IA32)  #if defined(ARCH_IS_IA32)
53    
54  #if defined(_MSC_VER)  #if defined(_MSC_VER)
# Line 153  Line 157 
157    
158    
159  static  static
160  int xvid_init_init(XVID_INIT_PARAM * init_param)  int xvid_gbl_init(xvid_gbl_init_t * init)
161  {  {
162          int cpu_flags;          unsigned int cpu_flags;
   
         /* Inform the client the API version */  
         init_param->api_version = API_VERSION;  
163    
164          /* Inform the client the core build - unused because we're still alpha */          if (XVID_MAJOR(init->version) != 1) /* v1.x.x */
165          init_param->core_build = 1000;                  return XVID_ERR_VERSION;
   
         /* 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))  
         {  
                 init_param->cpu_flags = cpu_flags;  
                 return XVID_ERR_OK;  
         }  
   
         init_param->cpu_flags = cpu_flags;  
166    
167            cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();
168    
169          /* Initialize the function pointers */          /* Initialize the function pointers */
170          idct_int32_init();          idct_int32_init();
# Line 552  Line 536 
536          }          }
537  #endif  #endif
538    
539          return XVID_ERR_OK;  #if defined(_DEBUG)
540        xvid_debug = init->debug;
541    #endif
542    
543        return 0;
544  }  }
545    
546    
547    static int
548    xvid_gbl_info(xvid_gbl_info_t * info)
549    {
550            if (XVID_MAJOR(info->version) != 1) /* v1.x.x */
551                    return XVID_ERR_VERSION;
552    
553            info->actual_version = XVID_VERSION;
554            info->build = "dev-api-4";
555            info->cpu_flags = detect_cpu_flags();
556    
557    #if defined(_SMP) && defined(WIN32)
558            info->num_threads = pthread_num_processors_np();;
559    #else
560            info->num_threads = 0;
561    #endif
562    
563            return 0;
564    }
565    
566    
567  static int  static int
568  xvid_init_convert(XVID_INIT_CONVERTINFO* convert)  xvid_gbl_convert(xvid_gbl_convert_t* convert)
569  {  {
570  /*          int width;
571          const int flip1 =          int height;
572                  (convert->input.colorspace & XVID_CSP_VFLIP) ^          int width2;
573                  (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;  
574          IMAGE img;          IMAGE img;
575    
576          switch (convert->input.colorspace & ~XVID_CSP_VFLIP)          if (XVID_MAJOR(convert->version) != 1)   /* v1.x.x */
577                  return XVID_ERR_VERSION;
578    
579            // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
580            width = convert->width;
581            height = convert->height;
582            width2 = convert->width/2;
583            height2 = convert->height/2;
584    
585            switch (convert->input.csp & ~XVID_CSP_VFLIP)
586          {          {
587                  case XVID_CSP_YV12 :                  case XVID_CSP_YV12 :
588                          img.y = convert->input.y;                          img.y = convert->input.plane[0];
589                          img.v = (uint8_t*)convert->input.y + width*height;                          img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height;
590                          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;
591                          image_output(&img, width, height, width,                          image_output(&img, width, height, width,
592                                                  convert->output.y, convert->output.y_stride,                                                  (uint8_t**)convert->output.plane, convert->output.stride,
593                                                  convert->output.colorspace, convert->interlacing);                                                  convert->output.csp, convert->interlacing);
594                          break;                          break;
595    
596                  default :                  default :
# Line 588  Line 599 
599    
600    
601          emms();          emms();
602          return XVID_ERR_OK;          return 0;
603  }  }
604    
605    
# Line 637  Line 648 
648  {  {
649          int i, diff = 0;          int i, diff = 0;
650          for (i = 0; i < size; i++)          for (i = 0; i < size; i++)
651                  diff += ABS(blockA[i]-blockB[i]);                  diff += abs(blockA[i]-blockB[i]);
652          return diff;          return diff;
653  }  }
654    
# Line 954  Line 965 
965    
966          emms();          emms();
967    
968          return XVID_ERR_OK;          return 0;
969  }  }
970    
971    
972    /*****************************************************************************
973     * XviD Global Entry point
974     *
975     * Well this function initialize all internal function pointers according
976     * to the CPU features forced by the library client or autodetected (depending
977     * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all
978     * image colorspace transformation tables.
979     *
980     ****************************************************************************/
981    
982    
983  int  int
984  xvid_init(void *handle,  xvid_global(void *handle,
985                    int opt,                    int opt,
986                    void *param1,                    void *param1,
987                    void *param2)                    void *param2)
988  {  {
989          switch(opt)          switch(opt)
990          {          {
991                  case XVID_INIT_INIT :                  case XVID_GBL_INIT :
992                          return xvid_init_init((XVID_INIT_PARAM*)param1);                          return xvid_gbl_init((xvid_gbl_init_t*)param1);
993    
994                  case XVID_INIT_CONVERT :          case XVID_GBL_INFO :
995                          return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);              return xvid_gbl_info((xvid_gbl_info_t*)param1);
996    
997                  case XVID_INIT_TEST :                  case XVID_GBL_CONVERT :
998                            return xvid_gbl_convert((xvid_gbl_convert_t*)param1);
999    
1000                    case XVID_GBL_TEST :
1001                  {                  {
1002                          ptr_t flags = (ptr_t)param1;                          ptr_t flags = (ptr_t)param1;
1003                          return xvid_init_test((int)flags);                          return xvid_init_test((int)flags);
# Line 999  Line 1024 
1024                          void *param2)                          void *param2)
1025  {  {
1026          switch (opt) {          switch (opt) {
         case XVID_DEC_DECODE:  
                 return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);  
   
1027          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
1028                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((xvid_dec_create_t *) param1);
1029    
1030          case XVID_DEC_DESTROY:          case XVID_DEC_DESTROY:
1031                  return decoder_destroy((DECODER *) handle);                  return decoder_destroy((DECODER *) handle);
1032    
1033            case XVID_DEC_DECODE:
1034                    return decoder_decode((DECODER *) handle, (xvid_dec_frame_t *) param1, (xvid_dec_stats_t*) param2);
1035    
1036          default:          default:
1037                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1038          }          }
# Line 1033  Line 1058 
1058          switch (opt) {          switch (opt) {
1059          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
1060    
1061                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  return enc_encode((Encoder *) handle,
1062                          return encoder_encode_bframes((Encoder *) handle,                                                            (xvid_enc_frame_t *) param1,
1063                                                                                    (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);  
1064    
1065          case XVID_ENC_CREATE:          case XVID_ENC_CREATE:
1066                  return encoder_create((XVID_ENC_PARAM *) param1);                  return enc_create((xvid_enc_create_t *) param1);
1067    
1068          case XVID_ENC_DESTROY:          case XVID_ENC_DESTROY:
1069                  return encoder_destroy((Encoder *) handle);                  return enc_destroy((Encoder *) handle);
1070    
1071          default:          default:
1072                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;

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

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