[svn] / branches / dev-api-4 / xvidcore / src / xvid.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/xvid.c

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

trunk/xvidcore/src/xvid.c revision 273, Tue Jul 9 01:44:44 2002 UTC branches/dev-api-4/xvidcore/src/xvid.c revision 1053, Mon Jun 9 01:25:19 2003 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Native API implementation  -   *  - Native API implementation  -
5   *   *
  *  This program is an implementation of a part of one or more MPEG-4  
  *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
  *  to use this software module in hardware or software products are  
  *  advised that its use may infringe existing patents or copyrights, and  
  *  any such use would be at such party's own risk.  The original  
  *  developer of this software module and his/her company, and subsequent  
  *  editors and their companies, will have no liability for use of this  
  *  software or modifications or derivatives thereof.  
  *  
6   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
7   *  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
8   *  the Free Software Foundation ; either version 2 of the License, or   *  the Free Software Foundation ; either version 2 of the License, or
# Line 26  Line 17 
17   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19   *   *
20   ****************************************************************************/   * $Id: xvid.c,v 1.45.2.5 2003-06-09 01:16:57 edgomez Exp $
 /*****************************************************************************  
  *  
  *  History  
  *  
  *      - 23.06.2002    added XVID_CPU_CHKONLY  
  *  - 17.03.2002        Added interpolate8x8_halfpel_hv_xmm  
  *  - 22.12.2001  API change: added xvid_init() - Isibaar  
  *  - 16.12.2001        inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
  *  
  *  $Id: xvid.c,v 1.28 2002-07-09 01:44:44 chenm001 Exp $  
21   *   *
22   ****************************************************************************/   ****************************************************************************/
23    
24    #include <stdio.h>
25    #include <stdlib.h>
26    #include <string.h>
27    #include <time.h>
28    
29  #include "xvid.h"  #include "xvid.h"
30  #include "decoder.h"  #include "decoder.h"
31  #include "encoder.h"  #include "encoder.h"
# Line 48  Line 34 
34  #include "dct/fdct.h"  #include "dct/fdct.h"
35  #include "image/colorspace.h"  #include "image/colorspace.h"
36  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
37    #include "image/reduced.h"
38  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
39    #include "utils/mbfunctions.h"
40  #include "quant/quant_h263.h"  #include "quant/quant_h263.h"
41  #include "quant/quant_mpeg4.h"  #include "quant/quant_mpeg4.h"
42    #include "motion/motion.h"
43  #include "motion/sad.h"  #include "motion/sad.h"
44  #include "utils/emms.h"  #include "utils/emms.h"
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)
53    
54    #if defined(_MSC_VER)
55    #       include <windows.h>
56    #else
57    #       include <signal.h>
58    #       include <setjmp.h>
59    
60            static jmp_buf mark;
61    
62            static void
63            sigill_handler(int signal)
64            {
65               longjmp(mark, 1);
66            }
67    #endif
68    
69    
70    /*
71     * Calls the funcptr, and returns whether SIGILL (illegal instruction) was
72     * signalled
73     *
74     * Return values:
75     *  -1 : could not determine
76     *   0 : SIGILL was *not* signalled
77     *   1 : SIGILL was signalled
78     */
79    
80    int
81    sigill_check(void (*func)())
82    {
83    #if defined(_MSC_VER)
84            _try {
85                    func();
86            }
87            _except(EXCEPTION_EXECUTE_HANDLER) {
88    
89                    if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
90                            return 1;
91            }
92            return 0;
93    #else
94        void * old_handler;
95        int jmpret;
96    
97    
98        old_handler = signal(SIGILL, sigill_handler);
99        if (old_handler == SIG_ERR)
100        {
101            return -1;
102        }
103    
104        jmpret = setjmp(mark);
105        if (jmpret == 0)
106        {
107            func();
108        }
109    
110        signal(SIGILL, old_handler);
111    
112        return jmpret;
113    #endif
114    }
115    #endif
116    
117    
118    /* detect cpu flags  */
119    static unsigned int
120    detect_cpu_flags()
121    {
122            /* enable native assembly optimizations by default */
123            unsigned int cpu_flags = XVID_CPU_ASM;
124    
125    #if defined(ARCH_IS_IA32)
126            cpu_flags |= check_cpu_features();
127            if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger))
128                    cpu_flags &= ~XVID_CPU_SSE;
129    
130            if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger))
131                    cpu_flags &= ~XVID_CPU_SSE2;
132    #endif
133    
134    #if defined(ARCH_IS_PPC)
135    #if defined(ARCH_IS_PPC_ALTIVEC)
136            cpu_flags |= XVID_CPU_ALTIVEC;
137    #endif
138    #endif
139    
140            return cpu_flags;
141    }
142    
143    
144  /*****************************************************************************  /*****************************************************************************
145   * XviD Init Entry point   * XviD Init Entry point
146   *   *
# Line 70  Line 155 
155   *   *
156   ****************************************************************************/   ****************************************************************************/
157    
 int  
 xvid_init(void *handle,  
                   int opt,  
                   void *param1,  
                   void *param2)  
 {  
         int cpu_flags;  
         XVID_INIT_PARAM *init_param;  
   
         init_param = (XVID_INIT_PARAM *) param1;  
   
         /* 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;  
   
         printf("init_param->cpu_flags %x\n",init_param->cpu_flags);//NIC  
158    
159          if ((init_param->cpu_flags & XVID_CPU_CHKONLY))  static
160    int xvid_gbl_init(xvid_gbl_init_t * init)
161          {          {
162                  //init_param->cpu_flags = check_cpu_features();//nic          unsigned int cpu_flags;
                 return XVID_ERR_OK;  
         }  
163    
164          /* Do we have to force CPU features  ? */          if (XVID_MAJOR(init->version) != 1) /* v1.x.x */
165          if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) {                  return XVID_ERR_VERSION;
                 cpu_flags = init_param->cpu_flags;  
         } else {  
166    
167                  //cpu_flags = check_cpu_features();//nic          cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags();
                 init_param->cpu_flags = cpu_flags;  
         }  
168    
169          /* Initialize the function pointers */          /* Initialize the function pointers */
170          idct_int32_init();          idct_int32_init();
# Line 133  Line 195 
195          transfer_8to16copy = transfer_8to16copy_c;          transfer_8to16copy = transfer_8to16copy_c;
196          transfer_16to8copy = transfer_16to8copy_c;          transfer_16to8copy = transfer_16to8copy_c;
197          transfer_8to16sub  = transfer_8to16sub_c;          transfer_8to16sub  = transfer_8to16sub_c;
198            transfer_8to16subro  = transfer_8to16subro_c;
199          transfer_8to16sub2 = transfer_8to16sub2_c;          transfer_8to16sub2 = transfer_8to16sub2_c;
200          transfer_16to8add  = transfer_16to8add_c;          transfer_16to8add  = transfer_16to8add_c;
201          transfer8x8_copy   = transfer8x8_copy_c;          transfer8x8_copy   = transfer8x8_copy_c;
202    
203            /* Interlacing functions */
204            MBFieldTest = MBFieldTest_c;
205    
206          /* Image interpolation related functions */          /* Image interpolation related functions */
207          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;          interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_c;
208          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;          interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_c;
209          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;          interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
210    
211            interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;
212            interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;
213            interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;
214    
215            interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;
216            interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;
217            interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;
218    
219            interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;
220            interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;
221    
222            interpolate8x8_avg2 = interpolate8x8_avg2_c;
223            interpolate8x8_avg4 = interpolate8x8_avg4_c;
224    
225            /* reduced resoltuion */
226            copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;
227            add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;
228            vfilter_31 = xvid_VFilter_31_C;
229            hfilter_31 = xvid_HFilter_31_C;
230            filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C;
231            filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C;
232    
233          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
234          colorspace_init();          colorspace_init();
235    
236          /* All colorspace transformation functions User Format->YV12 */          /* All colorspace transformation functions User Format->YV12 */
237            yv12_to_yv12    = yv12_to_yv12_c;
238          rgb555_to_yv12 = rgb555_to_yv12_c;          rgb555_to_yv12 = rgb555_to_yv12_c;
239          rgb565_to_yv12 = rgb565_to_yv12_c;          rgb565_to_yv12 = rgb565_to_yv12_c;
240          rgb24_to_yv12  = rgb24_to_yv12_c;          bgr_to_yv12     = bgr_to_yv12_c;
241          rgb32_to_yv12  = rgb32_to_yv12_c;          bgra_to_yv12    = bgra_to_yv12_c;
242          yuv_to_yv12    = yuv_to_yv12_c;          abgr_to_yv12    = abgr_to_yv12_c;
243            rgba_to_yv12    = rgba_to_yv12_c;
244          yuyv_to_yv12   = yuyv_to_yv12_c;          yuyv_to_yv12   = yuyv_to_yv12_c;
245          uyvy_to_yv12   = uyvy_to_yv12_c;          uyvy_to_yv12   = uyvy_to_yv12_c;
246    
247            rgb555i_to_yv12 = rgb555i_to_yv12_c;
248            rgb565i_to_yv12 = rgb565i_to_yv12_c;
249            bgri_to_yv12    = bgri_to_yv12_c;
250            bgrai_to_yv12   = bgrai_to_yv12_c;
251            abgri_to_yv12   = abgri_to_yv12_c;
252            rgbai_to_yv12   = rgbai_to_yv12_c;
253            yuyvi_to_yv12   = yuyvi_to_yv12_c;
254            uyvyi_to_yv12   = uyvyi_to_yv12_c;
255    
256    
257          /* All colorspace transformation functions YV12->User format */          /* All colorspace transformation functions YV12->User format */
258          yv12_to_rgb555 = yv12_to_rgb555_c;          yv12_to_rgb555 = yv12_to_rgb555_c;
259          yv12_to_rgb565 = yv12_to_rgb565_c;          yv12_to_rgb565 = yv12_to_rgb565_c;
260          yv12_to_rgb24  = yv12_to_rgb24_c;          yv12_to_bgr     = yv12_to_bgr_c;
261          yv12_to_rgb32  = yv12_to_rgb32_c;          yv12_to_bgra    = yv12_to_bgra_c;
262          yv12_to_yuv    = yv12_to_yuv_c;          yv12_to_abgr    = yv12_to_abgr_c;
263            yv12_to_rgba    = yv12_to_rgba_c;
264          yv12_to_yuyv   = yv12_to_yuyv_c;          yv12_to_yuyv   = yv12_to_yuyv_c;
265          yv12_to_uyvy   = yv12_to_uyvy_c;          yv12_to_uyvy   = yv12_to_uyvy_c;
266    
267            yv12_to_rgb555i = yv12_to_rgb555i_c;
268            yv12_to_rgb565i = yv12_to_rgb565i_c;
269            yv12_to_bgri    = yv12_to_bgri_c;
270            yv12_to_bgrai   = yv12_to_bgrai_c;
271            yv12_to_abgri   = yv12_to_abgri_c;
272            yv12_to_rgbai   = yv12_to_rgbai_c;
273            yv12_to_yuyvi   = yv12_to_yuyvi_c;
274            yv12_to_uyvyi   = yv12_to_uyvyi_c;
275    
276          /* Functions used in motion estimation algorithms */          /* Functions used in motion estimation algorithms */
277          calc_cbp = calc_cbp_c;          calc_cbp = calc_cbp_c;
278          sad16    = sad16_c;          sad16    = sad16_c;
         sad16bi  = sad16bi_c;  
279          sad8     = sad8_c;          sad8     = sad8_c;
280            sad16bi  = sad16bi_c;
281            sad8bi   = sad8bi_c;
282          dev16    = dev16_c;          dev16    = dev16_c;
283            sad16v   = sad16v_c;
284    
285    /*      Halfpel8_Refine = Halfpel8_Refine_c; */
286    
287  #ifdef ARCH_X86  #if defined(ARCH_IS_IA32)
288          if ((cpu_flags & XVID_CPU_MMX) > 0) {  
289            if ((cpu_flags & XVID_CPU_ASM))
290            {
291                    vfilter_31 = xvid_VFilter_31_x86;
292                    hfilter_31 = xvid_HFilter_31_x86;
293            }
294    
295            if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) ||
296                    (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) ||
297                    (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2))
298            {
299                    /* Restore FPU context : emms_c is a nop functions */
300                    emms = emms_mmx;
301            }
302    
303            if ((cpu_flags & XVID_CPU_MMX)) {
304    
305                  /* Forward and Inverse Discrete Cosine Transformation functions */                  /* Forward and Inverse Discrete Cosine Transformation functions */
306                  fdct = fdct_mmx;                  fdct = fdct_mmx;
307                  idct = idct_mmx;                  idct = idct_mmx;
308    
                 /* To restore FPU context after mmx use */  
                 emms = emms_mmx;  
   
309                  /* Quantization related functions */                  /* Quantization related functions */
310                  quant_intra   = quant_intra_mmx;                  quant_intra   = quant_intra_mmx;
311                  dequant_intra = dequant_intra_mmx;                  dequant_intra = dequant_intra_mmx;
# Line 195  Line 321 
321                  transfer_8to16copy = transfer_8to16copy_mmx;                  transfer_8to16copy = transfer_8to16copy_mmx;
322                  transfer_16to8copy = transfer_16to8copy_mmx;                  transfer_16to8copy = transfer_16to8copy_mmx;
323                  transfer_8to16sub  = transfer_8to16sub_mmx;                  transfer_8to16sub  = transfer_8to16sub_mmx;
324                    transfer_8to16subro  = transfer_8to16subro_mmx;
325                  transfer_8to16sub2 = transfer_8to16sub2_mmx;                  transfer_8to16sub2 = transfer_8to16sub2_mmx;
326                  transfer_16to8add  = transfer_16to8add_mmx;                  transfer_16to8add  = transfer_16to8add_mmx;
327                  transfer8x8_copy   = transfer8x8_copy_mmx;                  transfer8x8_copy   = transfer8x8_copy_mmx;
328    
329                    /* Interlacing Functions */
330                    MBFieldTest = MBFieldTest_mmx;
331    
332                  /* Image Interpolation related functions */                  /* Image Interpolation related functions */
333                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;                  interpolate8x8_halfpel_h  = interpolate8x8_halfpel_h_mmx;
334                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_mmx;
335                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
336    
337                  /* Image RGB->YV12 related functions */                  interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;
338                  rgb24_to_yv12 = rgb24_to_yv12_mmx;                  interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;
339                  rgb32_to_yv12 = rgb32_to_yv12_mmx;  
340                  yuv_to_yv12   = yuv_to_yv12_mmx;                  interpolate8x8_avg2 = interpolate8x8_avg2_mmx;
341                    interpolate8x8_avg4 = interpolate8x8_avg4_mmx;
342    
343                    /* reduced resolution */
344                    copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;
345                    add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;
346                    hfilter_31 = xvid_HFilter_31_mmx;
347                    filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx;
348                    filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx;
349    
350                    /* image input xxx_to_yv12 related functions */
351                    yv12_to_yv12  = yv12_to_yv12_mmx;
352                    bgr_to_yv12   = bgr_to_yv12_mmx;
353                    bgra_to_yv12  = bgra_to_yv12_mmx;
354                  yuyv_to_yv12  = yuyv_to_yv12_mmx;                  yuyv_to_yv12  = yuyv_to_yv12_mmx;
355                  uyvy_to_yv12  = uyvy_to_yv12_mmx;                  uyvy_to_yv12  = uyvy_to_yv12_mmx;
356    
357                  /* Image YV12->RGB related functions */                  /* image output yv12_to_xxx related functions */
358                  yv12_to_rgb24 = yv12_to_rgb24_mmx;                  yv12_to_bgr   = yv12_to_bgr_mmx;
359                  yv12_to_rgb32 = yv12_to_rgb32_mmx;                  yv12_to_bgra  = yv12_to_bgra_mmx;
360                  yv12_to_yuyv  = yv12_to_yuyv_mmx;                  yv12_to_yuyv  = yv12_to_yuyv_mmx;
361                  yv12_to_uyvy  = yv12_to_uyvy_mmx;                  yv12_to_uyvy  = yv12_to_uyvy_mmx;
362    
363                    yv12_to_yuyvi = yv12_to_yuyvi_mmx;
364                    yv12_to_uyvyi = yv12_to_uyvyi_mmx;
365    
366                  /* Motion estimation related functions */                  /* Motion estimation related functions */
367                  calc_cbp = calc_cbp_mmx;                  calc_cbp = calc_cbp_mmx;
368                  sad16    = sad16_mmx;                  sad16    = sad16_mmx;
369                  sad8     = sad8_mmx;                  sad8     = sad8_mmx;
370                    sad16bi = sad16bi_mmx;
371                    sad8bi  = sad8bi_mmx;
372                  dev16    = dev16_mmx;                  dev16    = dev16_mmx;
373                    sad16v   = sad16v_mmx;
374            }
375    
376            /* these 3dnow functions are faster than mmx, but slower than xmm. */
377            if ((cpu_flags & XVID_CPU_3DNOW)) {
378    
379                    emms = emms_3dn;
380    
381                    /* ME functions */
382                    sad16bi = sad16bi_3dn;
383                    sad8bi  = sad8bi_3dn;
384    
385                    yuyv_to_yv12  = yuyv_to_yv12_3dn;
386                    uyvy_to_yv12  = uyvy_to_yv12_3dn;
387          }          }
388    
389          if ((cpu_flags & XVID_CPU_MMXEXT) > 0) {  
390            if ((cpu_flags & XVID_CPU_MMXEXT)) {
391    
392                  /* Inverse DCT */                  /* Inverse DCT */
393                  idct = idct_xmm;                  idct = idct_xmm;
# Line 236  Line 397 
397                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;                  interpolate8x8_halfpel_v  = interpolate8x8_halfpel_v_xmm;
398                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
399    
400                    /* reduced resolution */
401                    copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm;
402                    add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;
403    
404                    /* Quantization */
405                    quant4_intra = quant4_intra_xmm;
406                    quant4_inter = quant4_inter_xmm;
407    
408                    dequant_intra = dequant_intra_xmm;
409                    dequant_inter = dequant_inter_xmm;
410    
411                  /* Buffer transfer */                  /* Buffer transfer */
412                  transfer_8to16sub2 = transfer_8to16sub2_xmm;                  transfer_8to16sub2 = transfer_8to16sub2_xmm;
413    
414                  /* Colorspace transformation */                  /* Colorspace transformation */
415                  yuv_to_yv12 = yuv_to_yv12_xmm;                  yv12_to_yv12  = yv12_to_yv12_xmm;
416                    yuyv_to_yv12  = yuyv_to_yv12_xmm;
417                    uyvy_to_yv12  = uyvy_to_yv12_xmm;
418    
419                  /* ME functions */                  /* ME functions */
420                  sad16 = sad16_xmm;                  sad16 = sad16_xmm;
421                  sad8  = sad8_xmm;                  sad8  = sad8_xmm;
422                    sad16bi = sad16bi_xmm;
423                    sad8bi  = sad8bi_xmm;
424                  dev16 = dev16_xmm;                  dev16 = dev16_xmm;
425                    sad16v   = sad16v_xmm;
426          }          }
427    
428          if ((cpu_flags & XVID_CPU_3DNOW) > 0) {          if ((cpu_flags & XVID_CPU_3DNOW)) {
429    
430                  /* Interpolation */                  /* Interpolation */
431                  interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn;                  interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn;
# Line 257  Line 433 
433                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;
434          }          }
435    
436          if ((cpu_flags & XVID_CPU_SSE2) > 0) {          if ((cpu_flags & XVID_CPU_3DNOWEXT)) {
437  #ifdef EXPERIMENTAL_SSE2_CODE  
438                    /* Inverse DCT */
439                    idct =  idct_3dne;
440    
441                    /* Buffer transfer */
442                    transfer_8to16copy =  transfer_8to16copy_3dne;
443                    transfer_16to8copy = transfer_16to8copy_3dne;
444                    transfer_8to16sub =  transfer_8to16sub_3dne;
445                    transfer_8to16subro =  transfer_8to16subro_3dne;
446                    transfer_8to16sub2 =  transfer_8to16sub2_3dne;
447                    transfer_16to8add = transfer_16to8add_3dne;
448                    transfer8x8_copy = transfer8x8_copy_3dne;
449    
450                    /* Quantization */
451                    dequant4_intra = dequant4_intra_3dne;
452                    dequant4_inter = dequant4_inter_3dne;
453                    quant_intra = quant_intra_3dne;
454                    quant_inter = quant_inter_3dne;
455                    dequant_intra = dequant_intra_3dne;
456                    dequant_inter = dequant_inter_3dne;
457    
458                    /* ME functions */
459                    calc_cbp = calc_cbp_3dne;
460                    sad16 = sad16_3dne;
461                    sad8 = sad8_3dne;
462                    sad16bi = sad16bi_3dne;
463                    sad8bi = sad8bi_3dne;
464                    dev16 = dev16_3dne;
465    
466                    /* Interpolation */
467                    interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne;
468                    interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne;
469                    interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne;
470            }
471    
472    
473            if ((cpu_flags & XVID_CPU_SSE2)) {
474    
475                    calc_cbp = calc_cbp_sse2;
476    
477                  /* Quantization */                  /* Quantization */
478                  quant_intra   = quant_intra_sse2;                  quant_intra   = quant_intra_sse2;
# Line 266  Line 480 
480                  quant_inter   = quant_inter_sse2;                  quant_inter   = quant_inter_sse2;
481                  dequant_inter = dequant_inter_sse2;                  dequant_inter = dequant_inter_sse2;
482    
483                  /* ME */  #if defined(EXPERIMENTAL_SSE2_CODE)
484                  calc_cbp = calc_cbp_sse2;                  /* ME; slower than xmm */
485                  sad16    = sad16_sse2;                  sad16    = sad16_sse2;
486                  dev16    = dev16_sse2;                  dev16    = dev16_sse2;
487    #endif
488                  /* Forward and Inverse DCT */                  /* Forward and Inverse DCT */
489                  idct  = idct_sse2;                  idct  = idct_sse2;
490                  fdct = fdct_sse2;                  fdct = fdct_sse2;
 #endif  
491          }          }
   
492  #endif  #endif
493    
494  #ifdef ARCH_IA64  #if defined(ARCH_IS_IA64)
495          if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines?          if ((cpu_flags & XVID_CPU_ASM)) { /* use assembler routines? */
496            idct_ia64_init();            idct_ia64_init();
497            fdct = fdct_ia64;            fdct = fdct_ia64;
498            idct = idct_ia64;   //not yet working, crashes            idct = idct_ia64;   /*not yet working, crashes */
499            interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64;            interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64;
500            interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64;            interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64;
501            interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64;            interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64;
# Line 291  Line 503 
503            sad16bi = sad16bi_ia64;            sad16bi = sad16bi_ia64;
504            sad8 = sad8_ia64;            sad8 = sad8_ia64;
505            dev16 = dev16_ia64;            dev16 = dev16_ia64;
506    /*        Halfpel8_Refine = Halfpel8_Refine_ia64; */
507            quant_intra = quant_intra_ia64;            quant_intra = quant_intra_ia64;
508            dequant_intra = dequant_intra_ia64;            dequant_intra = dequant_intra_ia64;
509            quant_inter = quant_inter_ia64;            quant_inter = quant_inter_ia64;
# Line 301  Line 514 
514            transfer_8to16sub2 = transfer_8to16sub2_ia64;            transfer_8to16sub2 = transfer_8to16sub2_ia64;
515            transfer_16to8add = transfer_16to8add_ia64;            transfer_16to8add = transfer_16to8add_ia64;
516            transfer8x8_copy = transfer8x8_copy_ia64;            transfer8x8_copy = transfer8x8_copy_ia64;
517            DEBUG("Using IA-64 assembler routines.\n");            DPRINTF(DPRINTF_DEBUG, "Using IA-64 assembler routines.");
518          }          }
519  #endif  #endif
520    
521  #ifdef ARCH_PPC  #if defined(ARCH_IS_PPC)
522  #ifdef ARCH_PPC_ALTIVEC          if ((cpu_flags & XVID_CPU_ASM))
523            {
524                    calc_cbp = calc_cbp_ppc;
525            }
526    
527            if ((cpu_flags & XVID_CPU_ALTIVEC))
528            {
529          calc_cbp = calc_cbp_altivec;          calc_cbp = calc_cbp_altivec;
530          fdct = fdct_altivec;          fdct = fdct_altivec;
531          idct = idct_altivec;          idct = idct_altivec;
# Line 314  Line 533 
533          sad16 = sad16_altivec;          sad16 = sad16_altivec;
534          sad8 = sad8_altivec;          sad8 = sad8_altivec;
535          dev16 = dev16_altivec;          dev16 = dev16_altivec;
536            }
537    #endif
538    
539    #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  #else
560          calc_cbp = calc_cbp_ppc;          info->num_threads = 0;
561    #endif
562    
563            return 0;
564    }
565    
566    
567    static int
568    xvid_gbl_convert(xvid_gbl_convert_t* convert)
569    {
570            int width;
571            int height;
572            int width2;
573            int height2;
574            IMAGE img;
575    
576            if (XVID_MAJOR(convert->version) != 1)   /* v1.x.x */
577                  return XVID_ERR_VERSION;
578    
579    #if 0
580            const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
581    #endif
582            width = convert->width;
583            height = convert->height;
584            width2 = convert->width/2;
585            height2 = convert->height/2;
586    
587            switch (convert->input.csp & ~XVID_CSP_VFLIP)
588            {
589                    case XVID_CSP_YV12 :
590                            img.y = convert->input.plane[0];
591                            img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height;
592                            img.u = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height + (convert->input.stride[0]/2)*height2;
593                            image_output(&img, width, height, width,
594                                                    (uint8_t**)convert->output.plane, convert->output.stride,
595                                                    convert->output.csp, convert->interlacing);
596                            break;
597    
598                    default :
599                            return XVID_ERR_FORMAT;
600            }
601    
602    
603            emms();
604            return 0;
605    }
606    
607    
608    
609    void fill8(uint8_t * block, int size, int value)
610    {
611            int i;
612            for (i = 0; i < size; i++)
613                    block[i] = value;
614    }
615    
616    void fill16(int16_t * block, int size, int value)
617    {
618            int i;
619            for (i = 0; i < size; i++)
620                    block[i] = value;
621    }
622    
623    #define RANDOM(min,max) min + (rand() % (max-min))
624    
625    void random8(uint8_t * block, int size, int min, int max)
626    {
627            int i;
628            for (i = 0; i < size; i++)
629                    block[i] = RANDOM(min,max);
630    }
631    
632    void random16(int16_t * block, int size, int min, int max)
633    {
634            int i;
635            for (i = 0; i < size; i++)
636                    block[i] = RANDOM(min,max);
637    }
638    
639    int compare16(const int16_t * blockA, const int16_t * blockB, int size)
640    {
641            int i;
642            for (i = 0; i < size; i++)
643                    if (blockA[i] != blockB[i])
644                            return 1;
645    
646            return 0;
647    }
648    
649    int diff16(const int16_t * blockA, const int16_t * blockB, int size)
650    {
651            int i, diff = 0;
652            for (i = 0; i < size; i++)
653                    diff += abs(blockA[i]-blockB[i]);
654            return diff;
655    }
656    
657    
658    #define XVID_TEST_RANDOM        0x00000001      /* random input data */
659    #define XVID_TEST_VERBOSE       0x00000002      /* verbose error output */
660    
661    
662    #define TEST_FORWARD    0x00000001      /* intra */
663    #define TEST_FDCT  (TEST_FORWARD)
664    #define TEST_IDCT  (0)
665    
666    static int test_transform(void * funcA, void * funcB, const char * nameB,
667                                       int test, int flags)
668    {
669            int i;
670            int64_t timeSTART;
671            int64_t timeA = 0;
672            int64_t timeB = 0;
673            DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
674            DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
675            int min, max;
676            int count = 0;
677    
678            int tmp;
679            int min_error = 0x10000*64;
680            int max_error = 0;
681    
682    
683            if ((test & TEST_FORWARD))      /* forward */
684            {
685                    min = -256;
686                    max = 255;
687            }else{          /* inverse */
688                    min = -2048;
689                    max = 2047;
690            }
691    
692            for (i = 0; i < 64*64; i++)
693            {
694                    if ((flags & XVID_TEST_RANDOM))
695                    {
696                            random16(arrayA, 64, min, max);
697                    }else{
698                            fill16(arrayA, 64, i);
699                    }
700                    memcpy(arrayB, arrayA, 64*sizeof(int16_t));
701    
702                    if ((test & TEST_FORWARD))
703                    {
704                            timeSTART = read_counter();
705                            ((fdctFunc*)funcA)(arrayA);
706                            timeA += read_counter() - timeSTART;
707    
708                            timeSTART = read_counter();
709                            ((fdctFunc*)funcB)(arrayB);
710                            timeB += read_counter() - timeSTART;
711                    }
712                    else
713                    {
714                            timeSTART = read_counter();
715                            ((idctFunc*)funcA)(arrayA);
716                            timeA += read_counter() - timeSTART;
717    
718                            timeSTART = read_counter();
719                            ((idctFunc*)funcB)(arrayB);
720                            timeB += read_counter() - timeSTART;
721                    }
722    
723                    tmp = diff16(arrayA, arrayB, 64) / 64;
724                    if (tmp > max_error)
725                            max_error = tmp;
726                    if (tmp < min_error)
727                            min_error = tmp;
728    
729                    count++;
730            }
731    
732            /* print the "average difference" of best/worst transforms */
733            printf("%s:\t%i\t(min_error:%i, max_error:%i)\n", nameB, (int)(timeB / count), min_error, max_error);
734    
735            return 0;
736    }
737    
738    
739    #define TEST_QUANT      0x00000001      /* forward quantization */
740    #define TEST_INTRA      0x00000002      /* intra */
741    #define TEST_QUANT_INTRA        (TEST_QUANT|TEST_INTRA)
742    #define TEST_QUANT_INTER        (TEST_QUANT)
743    #define TEST_DEQUANT_INTRA      (TEST_INTRA)
744    #define TEST_DEQUANT_INTER      (0)
745    
746    static int test_quant(void * funcA, void * funcB, const char * nameB,
747                               int test, int flags)
748    {
749            int q,i;
750            int64_t timeSTART;
751            int64_t timeA = 0;
752            int64_t timeB = 0;
753            int retA = 0, retB = 0;
754            DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE);
755            DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
756            DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
757            int min, max;
758            int count = 0;
759            int errors = 0;
760    
761            if ((test & TEST_QUANT))        /* quant */
762            {
763                    min = -2048;
764                    max = 2047;
765            }else{          /* dequant */
766                    min = -256;
767                    max = 255;
768            }
769    
770            for (q = 1; q <= 31; q++)       /* quantizer */
771            {
772                    for (i = min; i < max; i++)     /* input coeff */
773                    {
774                            if ((flags & XVID_TEST_RANDOM))
775                            {
776                                    random16(arrayX, 64, min, max);
777                            }else{
778                                    fill16(arrayX, 64, i);
779                            }
780    
781                            if ((test & TEST_INTRA))        /* intra */
782                            {
783                                    timeSTART = read_counter();
784                                    ((quanth263_intraFunc*)funcA)(arrayA, arrayX, q, q);
785                                    timeA += read_counter() - timeSTART;
786    
787                                    timeSTART = read_counter();
788                                    ((quanth263_intraFunc*)funcB)(arrayB, arrayX, q, q);
789                                    timeB += read_counter() - timeSTART;
790                            }
791                            else    /* inter */
792                            {
793                                    timeSTART = read_counter();
794                                    retA = ((quanth263_interFunc*)funcA)(arrayA, arrayX, q);
795                                    timeA += read_counter() - timeSTART;
796    
797                                    timeSTART = read_counter();
798                                    retB = ((quanth263_interFunc*)funcB)(arrayB, arrayX, q);
799                                    timeB += read_counter() - timeSTART;
800                            }
801    
802                            /* compare return value from quant_inter, and compare (de)quantiz'd arrays */
803                            if ( ((test&TEST_QUANT) && !(test&TEST_INTRA) && retA != retB ) ||
804                                    compare16(arrayA, arrayB, 64))
805                            {
806                                    errors++;
807                                    if ((flags & XVID_TEST_VERBOSE))
808                                            printf("%s error: q=%i, i=%i\n", nameB, q, i);
809                            }
810    
811                            count++;
812                    }
813            }
814    
815            printf("%s:\t%i", nameB, (int)(timeB / count));
816            if (errors>0)
817                    printf("\t(%i errors out of %i)", errors, count);
818            printf("\n");
819    
820            return 0;
821    }
822    
823    
824    
825    int xvid_init_test(int flags)
826    {
827    #if defined(ARCH_IS_IA32)
828            int cpu_flags;
829  #endif  #endif
830    
831            printf("XviD tests\n\n");
832    
833    #if defined(ARCH_IS_IA32)
834            cpu_flags = detect_cpu_flags();
835  #endif  #endif
836    
837          return XVID_ERR_OK;          idct_int32_init();
838            emms();
839    
840            srand(time(0));
841    
842            /* fDCT test */
843            printf("--- fdct ---\n");
844                    test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags);
845    
846    #if defined(ARCH_IS_IA32)
847            if (cpu_flags & XVID_CPU_MMX)
848                    test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags);
849            if (cpu_flags & XVID_CPU_SSE2)
850                    test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags);
851    #endif
852    
853            /* iDCT test */
854            printf("\n--- idct ---\n");
855                    test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags);
856    
857    #if defined(ARCH_IS_IA32)
858            if (cpu_flags & XVID_CPU_MMX)
859                    test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags);
860            if (cpu_flags & XVID_CPU_MMXEXT)
861                    test_transform(idct_int32, idct_xmm, "xmm", TEST_IDCT, flags);
862            if (cpu_flags & XVID_CPU_3DNOWEXT)
863                    test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags);
864            if (cpu_flags & XVID_CPU_SSE2)
865                    test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags);
866    #endif
867    
868            /* Intra quantization test */
869            printf("\n--- quant intra ---\n");
870                    test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags);
871    
872    #if defined(ARCH_IS_IA32)
873            if (cpu_flags & XVID_CPU_MMX)
874                    test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags);
875            if (cpu_flags & XVID_CPU_3DNOWEXT)
876                    test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags);
877            if (cpu_flags & XVID_CPU_SSE2)
878                    test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags);
879    #endif
880    
881            /* Inter quantization test */
882            printf("\n--- quant inter ---\n");
883                    test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags);
884    
885    #if defined(ARCH_IS_IA32)
886            if (cpu_flags & XVID_CPU_MMX)
887                    test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags);
888            if (cpu_flags & XVID_CPU_3DNOWEXT)
889                    test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags);
890            if (cpu_flags & XVID_CPU_SSE2)
891                    test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags);
892    #endif
893    
894            /* Intra dequantization test */
895            printf("\n--- dequant intra ---\n");
896                    test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags);
897    
898    #if defined(ARCH_IS_IA32)
899            if (cpu_flags & XVID_CPU_MMX)
900                    test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags);
901            if (cpu_flags & XVID_CPU_MMXEXT)
902                    test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags);
903            if (cpu_flags & XVID_CPU_3DNOWEXT)
904                    test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags);
905            if (cpu_flags & XVID_CPU_SSE2)
906                    test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags);
907    #endif
908    
909            /* Inter dequantization test */
910            printf("\n--- dequant inter ---\n");
911                    test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags);
912    
913    #if defined(ARCH_IS_IA32)
914            if (cpu_flags & XVID_CPU_MMX)
915                    test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags);
916            if (cpu_flags & XVID_CPU_MMXEXT)
917                    test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags);
918            if (cpu_flags & XVID_CPU_3DNOWEXT)
919                    test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags);
920            if (cpu_flags & XVID_CPU_SSE2)
921                    test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags);
922    #endif
923    
924            /* Intra quantization test */
925            printf("\n--- quant4 intra ---\n");
926                    test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags);
927    
928    #if defined(ARCH_IS_IA32)
929            if (cpu_flags & XVID_CPU_MMX)
930                    test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags);
931            if (cpu_flags & XVID_CPU_MMXEXT)
932                    test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags);
933    #endif
934    
935            /* Inter quantization test */
936            printf("\n--- quant4 inter ---\n");
937                    test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags);
938    
939    #if defined(ARCH_IS_IA32)
940            if (cpu_flags & XVID_CPU_MMX)
941                    test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags);
942            if (cpu_flags & XVID_CPU_MMXEXT)
943                    test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags);
944    #endif
945    
946            /* Intra dequantization test */
947            printf("\n--- dequant4 intra ---\n");
948                    test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags);
949    
950    #if defined(ARCH_IS_IA32)
951            if (cpu_flags & XVID_CPU_MMX)
952                    test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags);
953            if (cpu_flags & XVID_CPU_3DNOWEXT)
954                    test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags);
955    #endif
956    
957            /* Inter dequantization test */
958            printf("\n--- dequant4 inter ---\n");
959                    test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags);
960    
961    #if defined(ARCH_IS_IA32)
962            if (cpu_flags & XVID_CPU_MMX)
963                    test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags);
964            if (cpu_flags & XVID_CPU_3DNOWEXT)
965                    test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags);
966    #endif
967    
968            emms();
969    
970            return 0;
971    }
972    
973    
974    /*****************************************************************************
975     * XviD Global Entry point
976     *
977     * Well this function initialize all internal function pointers according
978     * to the CPU features forced by the library client or autodetected (depending
979     * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all
980     * image colorspace transformation tables.
981     *
982     ****************************************************************************/
983    
984    
985    int
986    xvid_global(void *handle,
987                      int opt,
988                      void *param1,
989                      void *param2)
990    {
991            switch(opt)
992            {
993                    case XVID_GBL_INIT :
994                            return xvid_gbl_init((xvid_gbl_init_t*)param1);
995    
996            case XVID_GBL_INFO :
997                return xvid_gbl_info((xvid_gbl_info_t*)param1);
998    
999                    case XVID_GBL_CONVERT :
1000                            return xvid_gbl_convert((xvid_gbl_convert_t*)param1);
1001    
1002                    case XVID_GBL_TEST :
1003                    {
1004                            ptr_t flags = (ptr_t)param1;
1005                            return xvid_init_test((int)flags);
1006                    }
1007                    default :
1008                            return XVID_ERR_FAIL;
1009            }
1010  }  }
1011    
1012  /*****************************************************************************  /*****************************************************************************
# Line 339  Line 1026 
1026                          void *param2)                          void *param2)
1027  {  {
1028          switch (opt) {          switch (opt) {
         case XVID_DEC_DECODE:  
                 return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1);  
   
1029          case XVID_DEC_CREATE:          case XVID_DEC_CREATE:
1030                  /* ***************************************************************************                  return decoder_create((xvid_dec_create_t *) param1);
                 NIC uso il secondo parametro 'param2' ma in realta` non so bene per cosa e`  
                 stato pensato ..... e quindi in futuro potrebbe essere un problema  
                 *************************************************************************** */  
                 if(param2!=NULL)  
                         return IM1_decoder_create((XVID_DEC_PARAM *) param1,(XVID_DEC_FRAME *) param2);  
                 else  
                         return decoder_create((XVID_DEC_PARAM *) param1); //NIC commentata  
1031    
1032          case XVID_DEC_DESTROY:          case XVID_DEC_DESTROY:
1033                  return decoder_destroy((DECODER *) handle);                  return decoder_destroy((DECODER *) handle);
1034    
1035            case XVID_DEC_DECODE:
1036                    return decoder_decode((DECODER *) handle, (xvid_dec_frame_t *) param1, (xvid_dec_stats_t*) param2);
1037    
1038          default:          default:
1039                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1040          }          }
# Line 379  Line 1059 
1059  {  {
1060          switch (opt) {          switch (opt) {
1061          case XVID_ENC_ENCODE:          case XVID_ENC_ENCODE:
1062  #ifdef BFRAMES  
1063                  if (((Encoder *) handle)->mbParam.max_bframes >= 0)                  return enc_encode((Encoder *) handle,
1064                  return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1,                                                            (xvid_enc_frame_t *) param1,
1065                                                            (XVID_ENC_STATS *) param2);                                                            (xvid_enc_stats_t *) param2);
                 else  
 #endif  
                 return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1,  
                                                           (XVID_ENC_STATS *) param2);  
1066    
1067          case XVID_ENC_CREATE:          case XVID_ENC_CREATE:
1068                  return encoder_create((XVID_ENC_PARAM *) param1);                  return enc_create((xvid_enc_create_t *) param1);
1069    
1070          case XVID_ENC_DESTROY:          case XVID_ENC_DESTROY:
1071                  return encoder_destroy((Encoder *) handle);                  return enc_destroy((Encoder *) handle);
1072    
1073          default:          default:
1074                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;

Legend:
Removed from v.273  
changed lines
  Added in v.1053

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