3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Native API implementation - |
* - Native API implementation - |
5 |
* |
* |
6 |
|
* Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> |
7 |
|
* |
8 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
9 |
* 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 |
10 |
* the Free Software Foundation ; either version 2 of the License, or |
* the Free Software Foundation ; either version 2 of the License, or |
19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: xvid.c,v 1.43 2003-02-19 21:13:00 edgomez Exp $ |
* $Id: xvid.c,v 1.45.2.8 2003-06-11 14:10:40 Isibaar Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
47 |
#include "utils/timer.h" |
#include "utils/timer.h" |
48 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
49 |
|
|
50 |
|
#if defined(_DEBUG) |
51 |
|
unsigned int xvid_debug = 0; /* xvid debug mask */ |
52 |
|
#endif |
53 |
|
|
54 |
#if defined(ARCH_IS_IA32) |
#if defined(ARCH_IS_IA32) |
55 |
|
|
56 |
#if defined(_MSC_VER) |
#if defined(_MSC_VER) |
159 |
|
|
160 |
|
|
161 |
static |
static |
162 |
int xvid_init_init(XVID_INIT_PARAM * init_param) |
int xvid_gbl_init(xvid_gbl_init_t * init) |
163 |
{ |
{ |
164 |
int cpu_flags; |
unsigned int cpu_flags; |
165 |
|
|
166 |
/* Inform the client the API version */ |
if (XVID_MAJOR(init->version) != 1) /* v1.x.x */ |
167 |
init_param->api_version = API_VERSION; |
return XVID_ERR_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; |
|
|
|
|
|
} else { |
|
|
|
|
|
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; |
|
168 |
|
|
169 |
|
cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags(); |
170 |
|
|
171 |
/* Initialize the function pointers */ |
/* Initialize the function pointers */ |
172 |
idct_int32_init(); |
idct_int32_init(); |
288 |
|
|
289 |
#if defined(ARCH_IS_IA32) |
#if defined(ARCH_IS_IA32) |
290 |
|
|
291 |
if ((cpu_flags & XVID_CPU_ASM)) |
if ((cpu_flags & XVID_CPU_ASM)) { |
|
{ |
|
292 |
vfilter_31 = xvid_VFilter_31_x86; |
vfilter_31 = xvid_VFilter_31_x86; |
293 |
hfilter_31 = xvid_HFilter_31_x86; |
hfilter_31 = xvid_HFilter_31_x86; |
294 |
} |
} |
487 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
488 |
#endif |
#endif |
489 |
/* Forward and Inverse DCT */ |
/* Forward and Inverse DCT */ |
490 |
|
#if 0 /* Both function are known to be unprecise, better keep them deactivated */ |
491 |
idct = idct_sse2; |
idct = idct_sse2; |
492 |
fdct = fdct_sse2; |
fdct = fdct_sse2; |
493 |
|
#endif |
494 |
} |
} |
495 |
#endif |
#endif |
496 |
|
|
539 |
} |
} |
540 |
#endif |
#endif |
541 |
|
|
542 |
return XVID_ERR_OK; |
#if defined(_DEBUG) |
543 |
|
xvid_debug = init->debug; |
544 |
|
#endif |
545 |
|
|
546 |
|
return 0; |
547 |
} |
} |
548 |
|
|
549 |
|
|
550 |
|
static int |
551 |
|
xvid_gbl_info(xvid_gbl_info_t * info) |
552 |
|
{ |
553 |
|
if (XVID_MAJOR(info->version) != 1) /* v1.x.x */ |
554 |
|
return XVID_ERR_VERSION; |
555 |
|
|
556 |
|
info->actual_version = XVID_VERSION; |
557 |
|
info->build = "dev-api-4"; |
558 |
|
info->cpu_flags = detect_cpu_flags(); |
559 |
|
|
560 |
|
#if defined(_SMP) && defined(WIN32) |
561 |
|
info->num_threads = pthread_num_processors_np();; |
562 |
|
#else |
563 |
|
info->num_threads = 0; |
564 |
|
#endif |
565 |
|
|
566 |
|
return 0; |
567 |
|
} |
568 |
|
|
569 |
|
|
570 |
static int |
static int |
571 |
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
xvid_gbl_convert(xvid_gbl_convert_t* convert) |
572 |
{ |
{ |
573 |
/* |
int width; |
574 |
const int flip1 = |
int height; |
575 |
(convert->input.colorspace & XVID_CSP_VFLIP) ^ |
int width2; |
576 |
(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; |
|
577 |
IMAGE img; |
IMAGE img; |
578 |
|
|
579 |
switch (convert->input.colorspace & ~XVID_CSP_VFLIP) |
if (XVID_MAJOR(convert->version) != 1) /* v1.x.x */ |
580 |
|
return XVID_ERR_VERSION; |
581 |
|
|
582 |
|
#if 0 |
583 |
|
const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
584 |
|
#endif |
585 |
|
width = convert->width; |
586 |
|
height = convert->height; |
587 |
|
width2 = convert->width/2; |
588 |
|
height2 = convert->height/2; |
589 |
|
|
590 |
|
switch (convert->input.csp & ~XVID_CSP_VFLIP) |
591 |
{ |
{ |
592 |
case XVID_CSP_YV12 : |
case XVID_CSP_YV12 : |
593 |
img.y = convert->input.y; |
img.y = convert->input.plane[0]; |
594 |
img.v = (uint8_t*)convert->input.y + width*height; |
img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height; |
595 |
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; |
596 |
image_output(&img, width, height, width, |
image_output(&img, width, height, width, |
597 |
convert->output.y, convert->output.y_stride, |
(uint8_t**)convert->output.plane, convert->output.stride, |
598 |
convert->output.colorspace, convert->interlacing); |
convert->output.csp, convert->interlacing); |
599 |
break; |
break; |
600 |
|
|
601 |
default : |
default : |
604 |
|
|
605 |
|
|
606 |
emms(); |
emms(); |
607 |
return XVID_ERR_OK; |
return 0; |
608 |
} |
} |
609 |
|
|
610 |
|
|
653 |
{ |
{ |
654 |
int i, diff = 0; |
int i, diff = 0; |
655 |
for (i = 0; i < size; i++) |
for (i = 0; i < size; i++) |
656 |
diff += ABS(blockA[i]-blockB[i]); |
diff += abs(blockA[i]-blockB[i]); |
657 |
return diff; |
return diff; |
658 |
} |
} |
659 |
|
|
827 |
|
|
828 |
int xvid_init_test(int flags) |
int xvid_init_test(int flags) |
829 |
{ |
{ |
830 |
|
#if defined(ARCH_IS_IA32) |
831 |
int cpu_flags; |
int cpu_flags; |
832 |
|
#endif |
833 |
|
|
834 |
srand(time(0)); |
printf("XviD tests\n\n"); |
|
|
|
|
printf("xvid_init_test\n"); |
|
835 |
|
|
836 |
#if defined(ARCH_IS_IA32) |
#if defined(ARCH_IS_IA32) |
837 |
cpu_flags = detect_cpu_flags(); |
cpu_flags = detect_cpu_flags(); |
838 |
|
#endif |
839 |
|
|
840 |
idct_int32_init(); |
idct_int32_init(); |
841 |
emms_mmx(); |
emms(); |
842 |
|
|
843 |
|
srand(time(0)); |
844 |
|
|
845 |
|
/* fDCT test */ |
846 |
printf("--- fdct ---\n"); |
printf("--- fdct ---\n"); |
847 |
test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags); |
test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags); |
848 |
|
|
849 |
|
#if defined(ARCH_IS_IA32) |
850 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
851 |
test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags); |
test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags); |
852 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
853 |
test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags); |
test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags); |
854 |
|
#endif |
855 |
|
|
856 |
|
/* iDCT test */ |
857 |
printf("\n--- idct ---\n"); |
printf("\n--- idct ---\n"); |
858 |
test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags); |
test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags); |
859 |
|
|
860 |
|
#if defined(ARCH_IS_IA32) |
861 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
862 |
test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags); |
test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags); |
863 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
866 |
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
867 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
868 |
test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags); |
test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags); |
869 |
|
#endif |
870 |
|
|
871 |
|
/* Intra quantization test */ |
872 |
printf("\n--- quant intra ---\n"); |
printf("\n--- quant intra ---\n"); |
873 |
test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags); |
test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags); |
874 |
|
|
875 |
|
#if defined(ARCH_IS_IA32) |
876 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
877 |
test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
878 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
879 |
test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags); |
test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags); |
880 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
881 |
test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags); |
test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags); |
882 |
|
#endif |
883 |
|
|
884 |
|
/* Inter quantization test */ |
885 |
printf("\n--- quant inter ---\n"); |
printf("\n--- quant inter ---\n"); |
886 |
test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags); |
test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags); |
887 |
|
|
888 |
|
#if defined(ARCH_IS_IA32) |
889 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
890 |
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
891 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
892 |
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
893 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
894 |
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
895 |
|
#endif |
896 |
|
|
897 |
|
/* Intra dequantization test */ |
898 |
printf("\n--- dequant intra ---\n"); |
printf("\n--- dequant intra ---\n"); |
899 |
test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
900 |
|
|
901 |
|
#if defined(ARCH_IS_IA32) |
902 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
903 |
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
904 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
907 |
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
908 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
909 |
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
910 |
|
#endif |
911 |
|
|
912 |
|
/* Inter dequantization test */ |
913 |
printf("\n--- dequant inter ---\n"); |
printf("\n--- dequant inter ---\n"); |
914 |
test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags); |
test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags); |
915 |
|
|
916 |
|
#if defined(ARCH_IS_IA32) |
917 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
918 |
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
919 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
922 |
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
923 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
924 |
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
925 |
|
#endif |
926 |
|
|
927 |
printf("\n--- quant4_intra ---\n"); |
/* Intra quantization test */ |
928 |
|
printf("\n--- quant4 intra ---\n"); |
929 |
test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags); |
test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags); |
930 |
|
|
931 |
|
#if defined(ARCH_IS_IA32) |
932 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
933 |
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
934 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
935 |
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
936 |
|
#endif |
937 |
|
|
938 |
printf("\n--- quant4_inter ---\n"); |
/* Inter quantization test */ |
939 |
|
printf("\n--- quant4 inter ---\n"); |
940 |
test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags); |
test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags); |
941 |
|
|
942 |
|
#if defined(ARCH_IS_IA32) |
943 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
944 |
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
945 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
946 |
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
947 |
|
#endif |
948 |
|
|
949 |
printf("\n--- dequant4_intra ---\n"); |
/* Intra dequantization test */ |
950 |
|
printf("\n--- dequant4 intra ---\n"); |
951 |
test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
952 |
|
|
953 |
|
#if defined(ARCH_IS_IA32) |
954 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
955 |
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
956 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
957 |
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
958 |
|
#endif |
959 |
|
|
960 |
printf("\n--- dequant4_inter ---\n"); |
/* Inter dequantization test */ |
961 |
|
printf("\n--- dequant4 inter ---\n"); |
962 |
test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags); |
test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags); |
963 |
|
|
964 |
|
#if defined(ARCH_IS_IA32) |
965 |
if (cpu_flags & XVID_CPU_MMX) |
if (cpu_flags & XVID_CPU_MMX) |
966 |
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
967 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
968 |
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
|
|
|
|
emms_mmx(); |
|
|
|
|
969 |
#endif |
#endif |
970 |
|
|
971 |
return XVID_ERR_OK; |
emms(); |
972 |
|
|
973 |
|
return 0; |
974 |
} |
} |
975 |
|
|
976 |
|
|
977 |
|
/***************************************************************************** |
978 |
|
* XviD Global Entry point |
979 |
|
* |
980 |
|
* Well this function initialize all internal function pointers according |
981 |
|
* to the CPU features forced by the library client or autodetected (depending |
982 |
|
* on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all |
983 |
|
* image colorspace transformation tables. |
984 |
|
* |
985 |
|
****************************************************************************/ |
986 |
|
|
987 |
|
|
988 |
int |
int |
989 |
xvid_init(void *handle, |
xvid_global(void *handle, |
990 |
int opt, |
int opt, |
991 |
void *param1, |
void *param1, |
992 |
void *param2) |
void *param2) |
993 |
{ |
{ |
994 |
switch(opt) |
switch(opt) |
995 |
{ |
{ |
996 |
case XVID_INIT_INIT : |
case XVID_GBL_INIT : |
997 |
return xvid_init_init((XVID_INIT_PARAM*)param1); |
return xvid_gbl_init((xvid_gbl_init_t*)param1); |
998 |
|
|
999 |
case XVID_INIT_CONVERT : |
case XVID_GBL_INFO : |
1000 |
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
return xvid_gbl_info((xvid_gbl_info_t*)param1); |
1001 |
|
|
1002 |
case XVID_INIT_TEST : |
case XVID_GBL_CONVERT : |
1003 |
return xvid_init_test((int)param1); |
return xvid_gbl_convert((xvid_gbl_convert_t*)param1); |
1004 |
|
|
1005 |
|
case XVID_GBL_TEST : |
1006 |
|
{ |
1007 |
|
ptr_t flags = (ptr_t)param1; |
1008 |
|
return xvid_init_test((int)flags); |
1009 |
|
} |
1010 |
default : |
default : |
1011 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
1012 |
} |
} |
1029 |
void *param2) |
void *param2) |
1030 |
{ |
{ |
1031 |
switch (opt) { |
switch (opt) { |
|
case XVID_DEC_DECODE: |
|
|
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
|
|
|
|
1032 |
case XVID_DEC_CREATE: |
case XVID_DEC_CREATE: |
1033 |
return decoder_create((XVID_DEC_PARAM *) param1); |
return decoder_create((xvid_dec_create_t *) param1); |
1034 |
|
|
1035 |
case XVID_DEC_DESTROY: |
case XVID_DEC_DESTROY: |
1036 |
return decoder_destroy((DECODER *) handle); |
return decoder_destroy((DECODER *) handle); |
1037 |
|
|
1038 |
|
case XVID_DEC_DECODE: |
1039 |
|
return decoder_decode((DECODER *) handle, (xvid_dec_frame_t *) param1, (xvid_dec_stats_t*) param2); |
1040 |
|
|
1041 |
default: |
default: |
1042 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
1043 |
} |
} |
1063 |
switch (opt) { |
switch (opt) { |
1064 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
1065 |
|
|
1066 |
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
return enc_encode((Encoder *) handle, |
1067 |
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
(xvid_enc_frame_t *) param1, |
1068 |
(XVID_ENC_STATS *) param2); |
(xvid_enc_stats_t *) param2); |
|
else |
|
|
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
|
|
(XVID_ENC_STATS *) param2); |
|
1069 |
|
|
1070 |
case XVID_ENC_CREATE: |
case XVID_ENC_CREATE: |
1071 |
return encoder_create((XVID_ENC_PARAM *) param1); |
return enc_create((xvid_enc_create_t *) param1); |
1072 |
|
|
1073 |
case XVID_ENC_DESTROY: |
case XVID_ENC_DESTROY: |
1074 |
return encoder_destroy((Encoder *) handle); |
return enc_destroy((Encoder *) handle); |
1075 |
|
|
1076 |
default: |
default: |
1077 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |