[svn] / branches / release-1_3-branch / xvidcore / src / xvid.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/xvidcore/src/xvid.c revision 1805, Thu Nov 27 00:47:03 2008 UTC branches/release-1_3-branch/xvidcore/src/xvid.c revision 2130, Fri Jan 8 17:40:12 2016 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-2004 Peter Ross <pross@xvid.org>   *  Copyright(C) 2001-2014 Peter Ross <pross@xvid.org>
7     *               2002-2014 Michael Militzer <isibaar@xvid.org>
8   *   *
9   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
10   *  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
# Line 19  Line 20 
20   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: xvid.c,v 1.76 2008-11-27 00:47:03 Isibaar Exp $   * $Id$
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 28  Line 29 
29  #include <string.h>  #include <string.h>
30  #include <time.h>  #include <time.h>
31    
32    #if !defined(_WIN32)
33    #include <unistd.h>
34    #endif
35    
36    #if defined(__APPLE__) && defined(__MACH__) && !defined(_SC_NPROCESSORS_CONF)
37    #include <sys/types.h>
38    #include <sys/sysctl.h>
39    #ifdef MAX
40    #undef MAX
41    #endif
42    #ifdef MIN
43    #undef MIN
44    #endif
45    #endif
46    
47    #if defined(__amigaos4__)
48    #include <exec/exec.h>
49    #include <proto/exec.h>
50    #endif
51    
52  #include "xvid.h"  #include "xvid.h"
53  #include "decoder.h"  #include "decoder.h"
54  #include "encoder.h"  #include "encoder.h"
# Line 54  Line 75 
75    
76  #if (defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)) && defined(_MSC_VER)  #if (defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)) && defined(_MSC_VER)
77  #       include <windows.h>  #       include <windows.h>
78  #elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || defined(ARCH_IS_PPC)  #elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || (defined(ARCH_IS_PPC) && !defined(__amigaos4__))
79  #       include <signal.h>  #       include <signal.h>
80  #       include <setjmp.h>  #       include <setjmp.h>
81    
# Line 67  Line 88 
88          }          }
89  #endif  #endif
90    
   
91  /*  /*
92   * Calls the funcptr, and returns whether SIGILL (illegal instruction) was   * Calls the funcptr, and returns whether SIGILL (illegal instruction) was
93   * signalled   * signalled
# Line 90  Line 110 
110          }          }
111          return(0);          return(0);
112  }  }
113  #elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || defined(ARCH_IS_PPC)  #elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || (defined(ARCH_IS_PPC) && !defined(__amigaos4__))
114  static int  static int
115  sigill_check(void (*func)())  sigill_check(void (*func)())
116  {  {
# Line 142  Line 162 
162  #endif  #endif
163    
164  #if defined(ARCH_IS_PPC)  #if defined(ARCH_IS_PPC)
165    #if defined(__amigaos4__)
166            {
167                    uint32_t vector_unit = VECTORTYPE_NONE;
168                    IExec->GetCPUInfoTags(GCIT_VectorUnit, &vector_unit, TAG_END);
169                    if (vector_unit == VECTORTYPE_ALTIVEC) {
170                            cpu_flags |= XVID_CPU_ALTIVEC;
171                    }
172            }
173    #else
174          if (!sigill_check(altivec_trigger))          if (!sigill_check(altivec_trigger))
175                  cpu_flags |= XVID_CPU_ALTIVEC;                  cpu_flags |= XVID_CPU_ALTIVEC;
176  #endif  #endif
177    #endif
178    
179          return cpu_flags;          return cpu_flags;
180  }  }
181    
182    
183  /*****************************************************************************  /*****************************************************************************
184   * XviD Init Entry point   * Xvid Init Entry point
185   *   *
186   * Well this function initialize all internal function pointers according   * Well this function initialize all internal function pointers according
187   * to the CPU features forced by the library client or autodetected (depending   * to the CPU features forced by the library client or autodetected (depending
# Line 176  Line 206 
206          cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();          cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();
207    
208          /* Initialize the function pointers */          /* Initialize the function pointers */
         idct_int32_init();  
209          init_vlc_tables();          init_vlc_tables();
210    
211          /* Fixed Point Forward/Inverse DCT transformations */          /* Fixed Point Forward/Inverse DCT transformations */
# Line 309  Line 338 
338          sse8_16bit = sse8_16bit_c;          sse8_16bit = sse8_16bit_c;
339          sse8_8bit  = sse8_8bit_c;          sse8_8bit  = sse8_8bit_c;
340    
341            sseh8_16bit   = sseh8_16bit_c;
342            coeff8_energy = coeff8_energy_c;
343            blocksum8     = blocksum8_c;
344    
345          init_GMC(cpu_flags);          init_GMC(cpu_flags);
346    
347  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
# Line 540  Line 573 
573                  sad16    = sad16_sse2;                  sad16    = sad16_sse2;
574                  dev16    = dev16_sse2;                  dev16    = dev16_sse2;
575    
576                    /* PSNR-HVS-M distortion metric */
577                    sseh8_16bit   = sseh8_16bit_sse2;
578                    coeff8_energy = coeff8_energy_sse2;
579                    blocksum8     = blocksum8_sse2;
580    
581                  /* DCT operators */                  /* DCT operators */
582                  fdct = fdct_sse2_skal;                  fdct = fdct_sse2_skal;
583                  idct = idct_sse2_skal;   /* Is now IEEE1180 and Walken compliant. */                  idct = idct_sse2_skal;   /* Is now IEEE1180 and Walken compliant. */
# Line 661  Line 699 
699                  return XVID_ERR_VERSION;                  return XVID_ERR_VERSION;
700    
701          info->actual_version = XVID_VERSION;          info->actual_version = XVID_VERSION;
702          info->build = "xvid-1.2.0-dev";          info->build = "xvid-1.3.5";
703          info->cpu_flags = detect_cpu_flags();          info->cpu_flags = detect_cpu_flags();
704    info->num_threads = 0;          info->num_threads = 0; /* single-thread */
705    
706  #if defined(_WIN32)  #if defined(_WIN32)
707    
708    {    {
709      DWORD dwProcessAffinityMask, dwSystemAffinityMask;          SYSTEM_INFO siSysInfo;
710      if (GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR) &dwProcessAffinityMask, (PDWORD_PTR) &dwSystemAffinityMask)) {          GetSystemInfo(&siSysInfo);
711        int i;          info->num_threads = siSysInfo.dwNumberOfProcessors; /* number of _logical_ cores */
       for(i=0; i<32; i++) {  
         if ((dwProcessAffinityMask & (1<<i)))  
           info->num_threads++;  
712        }        }
     }  
   }  
 #else  
713    
714    #include <unistd.h>  #elif defined(_SC_NPROCESSORS_CONF) /* should be available on Apple too actually */
715    
716    info->num_threads = sysconf(_SC_NPROCESSORS_CONF);    info->num_threads = sysconf(_SC_NPROCESSORS_CONF);
717    
718    #elif defined(__APPLE__) && defined(__MACH__)
719    
720      {
721        size_t len;
722        int    mib[2], ncpu;
723    
724        mib[0] = CTL_HW;
725        mib[1] = HW_NCPU;
726        len    = sizeof(ncpu);
727        if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == 0)
728          info -> num_threads = ncpu;
729        else
730          info -> num_threads = 1;
731      }
732    
733    #elif defined(__amigaos4__)
734    
735      {
736        uint32_t num_threads = 1;
737        IExec->GetCPUInfoTags(GCIT_NumberOfCPUs, &num_threads, TAG_END);
738        info->num_threads = num_threads;
739      }
740    
741  #endif  #endif
742    
743          return 0;          return 0;
# Line 718  Line 775 
775                                                  convert->output.csp, convert->interlacing);                                                  convert->output.csp, convert->interlacing);
776                          break;                          break;
777    
778                    case XVID_CSP_INTERNAL :
779                            img.y = (uint8_t*)convert->input.plane[0];
780                            img.u = (uint8_t*)convert->input.plane[1];
781                            img.v = (uint8_t*)convert->input.plane[2];
782                            image_output(&img, width, height, convert->input.stride[0],
783                                                    (uint8_t**)convert->output.plane, convert->output.stride,
784                                                    convert->output.csp, convert->interlacing);
785                            break;
786    
787                  default :                  default :
788                          return XVID_ERR_FORMAT;                          return XVID_ERR_FORMAT;
789          }          }
# Line 728  Line 794 
794  }  }
795    
796  /*****************************************************************************  /*****************************************************************************
797   * XviD Global Entry point   * Xvid Global Entry point
798   *   *
799   * Well this function initialize all internal function pointers according   * Well this function initialize all internal function pointers according
800   * to the CPU features forced by the library client or autodetected (depending   * to the CPU features forced by the library client or autodetected (depending
# Line 761  Line 827 
827  }  }
828    
829  /*****************************************************************************  /*****************************************************************************
830   * XviD Native decoder entry point   * Xvid Native decoder entry point
831   *   *
832   * This function is just a wrapper to all the option cases.   * This function is just a wrapper to all the option cases.
833   *   *
# Line 793  Line 859 
859    
860    
861  /*****************************************************************************  /*****************************************************************************
862   * XviD Native encoder entry point   * Xvid Native encoder entry point
863   *   *
864   * This function is just a wrapper to all the option cases.   * This function is just a wrapper to all the option cases.
865   *   *

Legend:
Removed from v.1805  
changed lines
  Added in v.2130

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