[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.21, Sun Jun 23 03:58:32 2002 UTC revision 1.33.2.3, Wed Sep 25 16:51:05 2002 UTC
# Line 27  Line 27 
27   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28   *   *
29   ****************************************************************************/   ****************************************************************************/
30    
31  /*****************************************************************************  /*****************************************************************************
32   *   *
33   *  History   *  History
# Line 49  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"
57  #include "motion/sad.h"  #include "motion/sad.h"
58  #include "utils/emms.h"  #include "utils/emms.h"
59  #include "utils/timer.h"  #include "utils/timer.h"
60  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
61    
62    #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE)
63    
64    #ifdef WIN32
65    #include <windows.h>
66    #else
67    #include <signal.h>
68    #include <setjmp.h>
69    #endif
70    
71    
72    #ifndef WIN32
73    
74    static jmp_buf mark;
75    
76    static void
77    sigill_handler(int signal)
78    {
79       longjmp(mark, 1);
80    }
81    #endif
82    
83    
84    /*
85    calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled
86    return values:
87    -1 : could not determine
88    0  : SIGILL was *not* signalled
89    1  : SIGILL was signalled
90    */
91    
92    int
93    sigill_check(void (*func)())
94    {
95    #ifdef WIN32
96            _try {
97                    func();
98            }
99            _except(EXCEPTION_EXECUTE_HANDLER) {
100    
101                    if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
102                            return 1;
103            }
104            return 0;
105    #else
106        void * old_handler;
107        int jmpret;
108    
109    
110        old_handler = signal(SIGILL, sigill_handler);
111        if (old_handler == SIG_ERR)
112        {
113            return -1;
114        }
115    
116        jmpret = setjmp(mark);
117        if (jmpret == 0)
118        {
119            func();
120        }
121    
122        signal(SIGILL, old_handler);
123    
124        return jmpret;
125    #endif
126    }
127    #endif
128    
129  /*****************************************************************************  /*****************************************************************************
130   * XviD Init Entry point   * XviD Init Entry point
131   *   *
# Line 87  Line 157 
157          /* Inform the client the core build - unused because we're still alpha */          /* Inform the client the core build - unused because we're still alpha */
158          init_param->core_build = 1000;          init_param->core_build = 1000;
159    
         if ((init_param->cpu_flags & XVID_CPU_CHKONLY))  
         {  
                 init_param->cpu_flags = check_cpu_features();  
                 return XVID_ERR_OK;  
         }  
   
160          /* Do we have to force CPU features  ? */          /* Do we have to force CPU features  ? */
161          if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) {          if ((init_param->cpu_flags & XVID_CPU_FORCE)) {
162    
163                  cpu_flags = init_param->cpu_flags;                  cpu_flags = init_param->cpu_flags;
164    
165          } else {          } else {
166    
 #ifdef ARCH_X86  
167                  cpu_flags = check_cpu_features();                  cpu_flags = check_cpu_features();
168  #else  
169                  cpu_flags = 0;  #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE)
170                    if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger))
171                            cpu_flags &= ~XVID_CPU_SSE;
172    
173                    if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger))
174                            cpu_flags &= ~XVID_CPU_SSE2;
175  #endif  #endif
176            }
177    
178            if ((init_param->cpu_flags & XVID_CPU_CHKONLY))
179            {
180                  init_param->cpu_flags = cpu_flags;                  init_param->cpu_flags = cpu_flags;
181                    return XVID_ERR_OK;
182          }          }
183    
184            init_param->cpu_flags = cpu_flags;
185    
186    
187          /* Initialize the function pointers */          /* Initialize the function pointers */
188          idct_int32_init();          idct_int32_init();
189          init_vlc_tables();          init_vlc_tables();
# Line 139  Line 217 
217          transfer_16to8add  = transfer_16to8add_c;          transfer_16to8add  = transfer_16to8add_c;
218          transfer8x8_copy   = transfer8x8_copy_c;          transfer8x8_copy   = transfer8x8_copy_c;
219    
220            /* Interlacing functions */
221            MBFieldTest = MBFieldTest_c;
222    
223          /* Image interpolation related functions */          /* Image interpolation related functions */
224          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;
225          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;
# Line 168  Line 249 
249          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
250          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
251          sad16    = sad16_c;          sad16    = sad16_c;
         sad16bi  = sad16bi_c;  
252          sad8     = sad8_c;          sad8     = sad8_c;
253            sad16bi  = sad16bi_c;
254            sad8bi   = sad8bi_c;
255          dev16    = dev16_c;          dev16    = dev16_c;
256            sad16v   = sad16v_c;
257    
258    //      Halfpel8_Refine = Halfpel8_Refine_c;
259    
260  #ifdef ARCH_X86  #ifdef ARCH_X86
261          if ((cpu_flags & XVID_CPU_MMX) > 0) {          if ((cpu_flags & XVID_CPU_MMX) > 0) {
# Line 197  Line 282 
282                  transfer_8to16copy = transfer_8to16copy_mmx;                  transfer_8to16copy = transfer_8to16copy_mmx;
283                  transfer_16to8copy = transfer_16to8copy_mmx;                  transfer_16to8copy = transfer_16to8copy_mmx;
284                  transfer_8to16sub  = transfer_8to16sub_mmx;                  transfer_8to16sub  = transfer_8to16sub_mmx;
285                    transfer_8to16sub2 = transfer_8to16sub2_mmx;
286                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
287                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
288    
289                    /* Interlacing functions */
290                    MBFieldTest = MBFieldTest_mmx;
291    
292                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
293                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
294                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
# Line 222  Line 311 
311                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
312                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
313                  sad8     = sad8_mmx;                  sad8     = sad8_mmx;
314                    sad16bi = sad16bi_mmx;
315                    sad8bi  = sad8bi_mmx;
316                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
317                    sad16v   = sad16v_mmx;
318    
319          }          }
320    
321            /* these 3dnow functions are faster than mmx, but slower than xmm. */
322            if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
323    
324                    /* ME functions */
325                    sad16bi = sad16bi_3dn;
326                    sad8bi  = sad8bi_3dn;
327            }
328    
329    
330          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {
331    
332                  /* Inverse DCT */                  /* Inverse DCT */
# Line 236  Line 337 
337                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;
338                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
339    
340                    /* Quantization */
341                    dequant_intra = dequant_intra_xmm;
342                    dequant_inter = dequant_inter_xmm;
343    
344                  /* Buffer transfer */                  /* Buffer transfer */
345                  transfer_8to16sub2 = transfer_8to16sub2_xmm;                  transfer_8to16sub2 = transfer_8to16sub2_xmm;
346    
# Line 245  Line 350 
350                  /* ME functions */                  /* ME functions */
351                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
352                  sad8  = sad8_xmm;                  sad8  = sad8_xmm;
353                    sad16bi = sad16bi_xmm;
354                    sad8bi  = sad8bi_xmm;
355                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
356                    sad16v   = sad16v_xmm;
357                    fprintf(stderr,"sad16v=XMM\n");
358    
359          }          }
360    
# Line 260  Line 369 
369          if ((cpu_flags & XVID_CPU_SSE2) > 0) {          if ((cpu_flags & XVID_CPU_SSE2) > 0) {
370  #ifdef EXPERIMENTAL_SSE2_CODE  #ifdef EXPERIMENTAL_SSE2_CODE
371    
372                    calc_cbp = calc_cbp_sse2;
373    
374                  /* Quantization */                  /* Quantization */
375                  quant_intra   = quant_intra_sse2;                  quant_intra   = quant_intra_sse2;
376                  dequant_intra = dequant_intra_sse2;                  dequant_intra = dequant_intra_sse2;
# Line 267  Line 378 
378                  dequant_inter = dequant_inter_sse2;                  dequant_inter = dequant_inter_sse2;
379    
380                  /* ME */                  /* ME */
                 calc_cbp = calc_cbp_sse2;  
381                  sad16    = sad16_sse2;                  sad16    = sad16_sse2;
382                  dev16    = dev16_sse2;                  dev16    = dev16_sse2;
383    
# Line 291  Line 401 
401            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
402            sad8 = sad8_ia64;            sad8 = sad8_ia64;
403            dev16 = dev16_ia64;            dev16 = dev16_ia64;
404    //        Halfpel8_Refine = Halfpel8_Refine_ia64;
405            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
406            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
407            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.33.2.3

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