[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.1, Sat Feb 22 08:49:44 2003 UTC
# Line 153  Line 153 
153    
154    
155  static  static
156  int xvid_init_init(XVID_INIT_PARAM * init_param)  int xvid_gbl_init(xvid_gbl_init_t * init)
157  {  {
158          int cpu_flags;          unsigned 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;  
159    
160          } else {          if (XVID_MAJOR(init->version) != 1) /* v1.x.x */
161                    return XVID_ERR_VERSION;
                 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;  
162    
163            cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();
164    
165          /* Initialize the function pointers */          /* Initialize the function pointers */
166          idct_int32_init();          idct_int32_init();
# Line 552  Line 532 
532          }          }
533  #endif  #endif
534    
535          return XVID_ERR_OK;          return 0;
536  }  }
537    
538    
539    static int
540    xvid_gbl_info(xvid_gbl_info_t * info)
541    {
542            if (XVID_MAJOR(info->version) != 1) /* v1.x.x */
543                    return XVID_ERR_VERSION;
544    
545            info->actual_version = XVID_VERSION;
546            info->build = "dev-api-4";
547            info->cpu_flags = detect_cpu_flags();
548    
549    #if defined(_SMP) && defined(WIN32)
550            info->num_threads = pthread_num_processors_np();;
551    #else
552            info->num_threads = 0;
553    #endif
554    
555            return 0;
556    }
557    
558    
559  static int  static int
560  xvid_init_convert(XVID_INIT_CONVERTINFO* convert)  xvid_gbl_convert(xvid_gbl_convert_t* convert)
561  {  {
562  /*          int width;
563          const int flip1 =          int height;
564                  (convert->input.colorspace & XVID_CSP_VFLIP) ^          int width2;
565                  (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;  
566          IMAGE img;          IMAGE img;
567    
568          switch (convert->input.colorspace & ~XVID_CSP_VFLIP)          if (XVID_MAJOR(convert->version) != 1)   /* v1.x.x */
569                  return XVID_ERR_VERSION;
570    
571            // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
572            width = convert->width;
573            height = convert->height;
574            width2 = convert->width/2;
575            height2 = convert->height/2;
576    
577            switch (convert->input.csp & ~XVID_CSP_VFLIP)
578          {          {
579                  case XVID_CSP_YV12 :                  case XVID_CSP_YV12 :
580                          img.y = convert->input.y;                          img.y = convert->input.plane[0];
581                          img.v = (uint8_t*)convert->input.y + width*height;                          img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height;
582                          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;
583                          image_output(&img, width, height, width,                          image_output(&img, width, height, width,
584                                                  convert->output.y, convert->output.y_stride,                                                  (uint8_t**)convert->output.plane, convert->output.stride,
585                                                  convert->output.colorspace, convert->interlacing);                                                  convert->output.csp, convert->interlacing);
586                          break;                          break;
587    
588                  default :                  default :
# Line 588  Line 591 
591    
592    
593          emms();          emms();
594          return XVID_ERR_OK;          return 0;
595  }  }
596    
597    
# Line 954  Line 957 
957    
958          emms();          emms();
959    
960          return XVID_ERR_OK;          return 0;
961  }  }
962    
963    
964    /*****************************************************************************
965     * XviD Global Entry point
966     *
967     * Well this function initialize all internal function pointers according
968     * to the CPU features forced by the library client or autodetected (depending
969     * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all
970     * image colorspace transformation tables.
971     *
972     ****************************************************************************/
973    
974    
975  int  int
976  xvid_init(void *handle,  xvid_global(void *handle,
977                    int opt,                    int opt,
978                    void *param1,                    void *param1,
979                    void *param2)                    void *param2)
980  {  {
981          switch(opt)          switch(opt)
982          {          {
983                  case XVID_INIT_INIT :                  case XVID_GBL_INIT :
984                          return xvid_init_init((XVID_INIT_PARAM*)param1);                          return xvid_gbl_init((xvid_gbl_init_t*)param1);
985    
986                  case XVID_INIT_CONVERT :          case XVID_GBL_INFO :
987                          return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);              return xvid_gbl_info((xvid_gbl_info_t*)param1);
988    
989                  case XVID_INIT_TEST :                  case XVID_GBL_CONVERT :
990                            return xvid_gbl_convert((xvid_gbl_convert_t*)param1);
991    
992                    case XVID_GBL_TEST :
993                  {                  {
994                          ptr_t flags = (ptr_t)param1;                          ptr_t flags = (ptr_t)param1;
995                          return xvid_init_test((int)flags);                          return xvid_init_test((int)flags);
# Line 999  Line 1016 
1016                          void *param2)                          void *param2)
1017  {  {
1018          switch (opt) {          switch (opt) {
         case XVID_DEC_DECODE:  
                 return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);  
   
1019          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
1020                  return decoder_create((XVID_DEC_PARAM *) param1);                  return decoder_create((xvid_dec_create_t *) param1);
1021    
1022          case XVID_DEC_DESTROY:          case XVID_DEC_DESTROY:
1023                  return decoder_destroy((DECODER *) handle);                  return decoder_destroy((DECODER *) handle);
1024    
1025            case XVID_DEC_DECODE:
1026                    return decoder_decode((DECODER *) handle, (xvid_dec_frame_t *) param1, (xvid_dec_stats_t*) param2);
1027    
1028          default:          default:
1029                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1030          }          }
# Line 1033  Line 1050 
1050          switch (opt) {          switch (opt) {
1051          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
1052    
1053                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  return enc_encode((Encoder *) handle,
1054                          return encoder_encode_bframes((Encoder *) handle,                                                            (xvid_enc_frame_t *) param1,
1055                                                                                    (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);  
1056    
1057          case XVID_ENC_CREATE:          case XVID_ENC_CREATE:
1058                  return encoder_create((XVID_ENC_PARAM *) param1);                  return enc_create((xvid_enc_create_t *) param1, (xvid_enc_rc_t*)param2);
1059    
1060          case XVID_ENC_DESTROY:          case XVID_ENC_DESTROY:
1061                  return encoder_destroy((Encoder *) handle);                  return enc_destroy((Encoder *) handle);
1062    
1063          default:          default:
1064                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;

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

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