[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.30, Tue Jul 16 11:15:15 2002 UTC revision 1.33.2.10, Sat Nov 2 16:11:07 2002 UTC
# Line 50  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"  #include "motion/motion.h"
# Line 58  Line 59 
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 89  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    
167                  cpu_flags = check_cpu_features();                  cpu_flags = check_cpu_features();
168    
169    #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
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 137  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;
226          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
227    
228            interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;
229            interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;
230            interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;
231    
232            interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;
233            interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;
234            interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;
235    
236            interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;
237            interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;
238    
239            interpolate8x8_avg2 = interpolate8x8_avg2_c;
240            interpolate8x8_avg4 = interpolate8x8_avg4_c;
241    
242          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
243          colorspace_init();          colorspace_init();
244    
# Line 159  Line 256 
256          yv12_to_rgb565 = yv12_to_rgb565_c;          yv12_to_rgb565 = yv12_to_rgb565_c;
257          yv12_to_rgb24  = yv12_to_rgb24_c;          yv12_to_rgb24  = yv12_to_rgb24_c;
258          yv12_to_rgb32  = yv12_to_rgb32_c;          yv12_to_rgb32  = yv12_to_rgb32_c;
259            yv12_to_abgr  = yv12_to_abgr_c;
260            yv12_to_rgba  = yv12_to_rgba_c;
261          yv12_to_yuv    = yv12_to_yuv_c;          yv12_to_yuv    = yv12_to_yuv_c;
262          yv12_to_yuyv   = yv12_to_yuyv_c;          yv12_to_yuyv   = yv12_to_yuyv_c;
263          yv12_to_uyvy   = yv12_to_uyvy_c;          yv12_to_uyvy   = yv12_to_uyvy_c;
# Line 166  Line 265 
265          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
266          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
267          sad16    = sad16_c;          sad16    = sad16_c;
         sad16bi  = sad16bi_c;  
268          sad8     = sad8_c;          sad8     = sad8_c;
269            sad16bi  = sad16bi_c;
270            sad8bi   = sad8bi_c;
271          dev16    = dev16_c;          dev16    = dev16_c;
272          Halfpel8_Refine = Halfpel8_Refine_c;          sad16v   = sad16v_c;
273    
274    //      Halfpel8_Refine = Halfpel8_Refine_c;
275    
276  #ifdef ARCH_X86  #ifdef ARCH_X86
277          if ((cpu_flags & XVID_CPU_MMX) > 0) {          if ((cpu_flags & XVID_CPU_MMX) > 0) {
# Line 200  Line 302 
302                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
303                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
304    
305                    /* Interlacing Functions */
306                    MBFieldTest = MBFieldTest_mmx;
307    
308                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
309                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
310                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
311                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
312    
313                    interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;
314                    interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;
315    
316    //              interpolate8x8_avg2 = interpolate8x8_avg2_mmx;
317                    interpolate8x8_avg4 = interpolate8x8_avg4_mmx;
318    
319                  /* Image RGB->YV12 related functions */                  /* Image RGB->YV12 related functions */
320                  rgb24_to_yv12 = rgb24_to_yv12_mmx;                  rgb24_to_yv12 = rgb24_to_yv12_mmx;
321                  rgb32_to_yv12 = rgb32_to_yv12_mmx;                  rgb32_to_yv12 = rgb32_to_yv12_mmx;
# Line 223  Line 333 
333                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
334                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
335                  sad8     = sad8_mmx;                  sad8     = sad8_mmx;
336                    sad16bi = sad16bi_mmx;
337                    sad8bi  = sad8bi_mmx;
338                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
339                    sad16v   = sad16v_mmx;
340    
341          }          }
342    
343            /* these 3dnow functions are faster than mmx, but slower than xmm. */
344            if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
345    
346                    /* ME functions */
347                    sad16bi = sad16bi_3dn;
348                    sad8bi  = sad8bi_3dn;
349            }
350    
351    
352          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {
353    
354                  /* Inverse DCT */                  /* Inverse DCT */
# Line 249  Line 371 
371    
372                  /* ME functions */                  /* ME functions */
373                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
                 sad16bi = sad16bi_xmm;  
374                  sad8  = sad8_xmm;                  sad8  = sad8_xmm;
375                    sad16bi = sad16bi_xmm;
376                    sad8bi  = sad8bi_xmm;
377                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
378                    sad16v   = sad16v_xmm;
379          }          }
380    
381          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {
# Line 298  Line 421 
421            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
422            sad8 = sad8_ia64;            sad8 = sad8_ia64;
423            dev16 = dev16_ia64;            dev16 = dev16_ia64;
424            Halfpel8_Refine = Halfpel8_Refine_ia64;  //        Halfpel8_Refine = Halfpel8_Refine_ia64;
425            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
426            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
427            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;
# Line 380  Line 503 
503  {  {
504          switch (opt) {          switch (opt) {
505          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
506  #ifdef BFRAMES  
507                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)
508                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,
509                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
510                  else                  else
 #endif  
511                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,                  return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,
512                                                            (XVID_ENC_STATS *) param2);                                                            (XVID_ENC_STATS *) param2);
513    

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.33.2.10

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