1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC - Unit tests and benches |
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - Unit tests and benches - |
5 |
|
* |
6 |
|
* Copyright(C) 2002 Pascal Massimino <skal@planet-d.net> |
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 |
17 |
* |
* |
18 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
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., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
* |
22 |
|
* $Id: xvid_bench.c,v 1.9.2.3 2003-06-10 09:14:48 edgomez Exp $ |
23 |
* |
* |
24 |
*************************************************************************/ |
****************************************************************************/ |
25 |
|
|
26 |
/************************************************************************ |
/***************************************************************************** |
27 |
* |
* |
28 |
* 'Reference' output is at the end of file. |
* 'Reference' output is at the end of file. |
29 |
* Don't take the checksums and crc too seriouly, they aren't |
* Don't take the checksums and crc too seriouly, they aren't |
32 |
* compiles with something like: |
* compiles with something like: |
33 |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
34 |
* |
* |
35 |
* History: |
****************************************************************************/ |
|
* |
|
|
* 06.06.2002 initial coding -Skal- |
|
|
* |
|
|
*************************************************************************/ |
|
36 |
|
|
37 |
#include <stdio.h> |
#include <stdio.h> |
38 |
#include <stdlib.h> |
#include <stdlib.h> |
120 |
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
121 |
, { "3DNOW ", XVID_CPU_3DNOW } |
, { "3DNOW ", XVID_CPU_3DNOW } |
122 |
, { "3DNOWE", XVID_CPU_3DNOWEXT } |
, { "3DNOWE", XVID_CPU_3DNOWEXT } |
123 |
, { "IA64 ", XVID_CPU_IA64 } |
//, { "IA64 ", XVID_CPU_IA64 } |
124 |
//, { "TSC ", XVID_CPU_TSC } |
//, { "TSC ", XVID_CPU_TSC } |
125 |
, { 0, 0 } } |
, { 0, 0 } }; |
126 |
|
|
127 |
, cpu_short_list[] = |
CPU cpu_short_list[] = |
128 |
{ { "PLAINC", 0 } |
{ { "PLAINC", 0 } |
129 |
, { "MMX ", XVID_CPU_MMX } |
, { "MMX ", XVID_CPU_MMX } |
130 |
//, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } |
//, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } |
131 |
, { "IA64 ", XVID_CPU_IA64 } |
//, { "IA64 ", XVID_CPU_IA64 } |
132 |
, { 0, 0 } } |
, { 0, 0 } }; |
133 |
|
|
134 |
, cpu_short_list2[] = |
CPU cpu_short_list2[] = |
135 |
{ { "PLAINC", 0 } |
{ { "PLAINC", 0 } |
136 |
, { "MMX ", XVID_CPU_MMX } |
, { "MMX ", XVID_CPU_MMX } |
137 |
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
141 |
int init_cpu(CPU *cpu) |
int init_cpu(CPU *cpu) |
142 |
{ |
{ |
143 |
int xerr, cpu_type; |
int xerr, cpu_type; |
144 |
XVID_INIT_PARAM xinit; |
xvid_gbl_init_t xinit; |
145 |
|
|
146 |
cpu_type = check_cpu_features() & cpu->cpu; |
cpu_type = check_cpu_features() & cpu->cpu; |
147 |
|
memset(&xinit, 0, sizeof(xinit)); |
148 |
xinit.cpu_flags = cpu_type | XVID_CPU_FORCE; |
xinit.cpu_flags = cpu_type | XVID_CPU_FORCE; |
149 |
/* xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; */ |
xinit.version = XVID_VERSION; |
150 |
xerr = xvid_init(NULL, 0, &xinit, NULL); |
xerr = xvid_global(NULL, 0, &xinit, NULL); |
151 |
if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) { |
if (cpu->cpu>0 && (cpu_type==0 || xerr==XVID_ERR_FAIL)) { |
152 |
printf( "%s - skipped...\n", cpu->name ); |
printf( "%s - skipped...\n", cpu->name ); |
153 |
return 0; |
return 0; |
154 |
} |
} |
1043 |
FILE *f = 0; |
FILE *f = 0; |
1044 |
void *dechandle = 0; |
void *dechandle = 0; |
1045 |
int xerr; |
int xerr; |
1046 |
XVID_INIT_PARAM xinit; |
xvid_gbl_init_t xinit; |
1047 |
XVID_DEC_PARAM xparam; |
xvid_dec_create_t xparam; |
1048 |
XVID_DEC_FRAME xframe; |
xvid_dec_frame_t xframe; |
1049 |
double t = 0.; |
double t = 0.; |
1050 |
int nb = 0; |
int nb = 0; |
1051 |
uint8_t *buf = 0; |
uint8_t *buf = 0; |
1053 |
int buf_size, pos; |
int buf_size, pos; |
1054 |
uint32_t chksum = 0; |
uint32_t chksum = 0; |
1055 |
|
|
1056 |
|
memset(&xinit, 0, sizeof(xinit)); |
1057 |
xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; |
xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; |
1058 |
xvid_init(NULL, 0, &xinit, NULL); |
xinit.version = XVID_VERSION; |
1059 |
printf( "API version: %d, core build:%d\n", xinit.api_version, xinit.core_build); |
xvid_global(NULL, 0, &xinit, NULL); |
|
|
|
1060 |
|
|
1061 |
|
memset(&xparam, 0, sizeof(xparam)); |
1062 |
xparam.width = width; |
xparam.width = width; |
1063 |
xparam.height = height; |
xparam.height = height; |
1064 |
|
xparam.version = XVID_VERSION; |
1065 |
xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL); |
xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL); |
1066 |
if (xerr!=XVID_ERR_OK) { |
if (xerr==XVID_ERR_FAIL) { |
1067 |
printf("can't init decoder (err=%d)\n", xerr); |
printf("can't init decoder (err=%d)\n", xerr); |
1068 |
return; |
return; |
1069 |
} |
} |
1100 |
pos = 0; |
pos = 0; |
1101 |
t = -gettime_usec(); |
t = -gettime_usec(); |
1102 |
while(1) { |
while(1) { |
1103 |
|
memset(&xframe, 0, sizeof(xframe)); |
1104 |
|
xframe.version = XVID_VERSION; |
1105 |
xframe.bitstream = buf + pos; |
xframe.bitstream = buf + pos; |
1106 |
xframe.length = buf_size - pos; |
xframe.length = buf_size - pos; |
1107 |
xframe.image = rgb_out; |
xframe.output.plane[0] = rgb_out; |
1108 |
xframe.stride = width; |
xframe.output.stride[0] = width; |
1109 |
xframe.colorspace = XVID_CSP_RGB24; |
xframe.output.csp = XVID_CSP_BGR; |
1110 |
xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0); |
xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0); |
1111 |
nb++; |
nb++; |
1112 |
pos += xframe.length; |
pos += xframe.length; |
1117 |
} |
} |
1118 |
if (pos==buf_size) |
if (pos==buf_size) |
1119 |
break; |
break; |
1120 |
if (xerr!=XVID_ERR_OK) { |
if (xerr==XVID_ERR_FAIL) { |
1121 |
printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr); |
printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr); |
1122 |
break; |
break; |
1123 |
} |
} |
1133 |
if (buf!=0) free(buf); |
if (buf!=0) free(buf); |
1134 |
if (dechandle!=0) { |
if (dechandle!=0) { |
1135 |
xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL); |
xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL); |
1136 |
if (xerr!=XVID_ERR_OK) |
if (xerr==XVID_ERR_FAIL) |
1137 |
printf("destroy-decoder failed (err=%d)!\n", xerr); |
printf("destroy-decoder failed (err=%d)!\n", xerr); |
1138 |
} |
} |
1139 |
if (f!=0) fclose(f); |
if (f!=0) fclose(f); |