OLD | NEW |
1 /* Copyright (c) 2011 Xiph.Org Foundation | 1 /* Copyright (c) 2011-2013 Xiph.Org Foundation |
2 Written by Gregory Maxwell */ | 2 Written by Gregory Maxwell */ |
3 /* | 3 /* |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
11 - Redistributions in binary form must reproduce the above copyright | 11 - Redistributions in binary form must reproduce the above copyright |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 VG_UNDEF(&err,sizeof(err)); | 141 VG_UNDEF(&err,sizeof(err)); |
142 dec = opus_decoder_create(48000, 2, &err); | 142 dec = opus_decoder_create(48000, 2, &err); |
143 if(err!=OPUS_OK || dec==NULL)test_failed(); | 143 if(err!=OPUS_OK || dec==NULL)test_failed(); |
144 VG_CHECK(dec,opus_decoder_get_size(2)); | 144 VG_CHECK(dec,opus_decoder_get_size(2)); |
145 cfgs++; | 145 cfgs++; |
146 | 146 |
147 fprintf(stdout," opus_decoder_create() ........................ OK.\n"); | 147 fprintf(stdout," opus_decoder_create() ........................ OK.\n"); |
148 fprintf(stdout," opus_decoder_init() .......................... OK.\n"); | 148 fprintf(stdout," opus_decoder_init() .......................... OK.\n"); |
149 | 149 |
| 150 err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL)); |
| 151 if(err != OPUS_BAD_ARG)test_failed(); |
150 VG_UNDEF(&dec_final_range,sizeof(dec_final_range)); | 152 VG_UNDEF(&dec_final_range,sizeof(dec_final_range)); |
151 err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); | 153 err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); |
152 if(err!=OPUS_OK)test_failed(); | 154 if(err!=OPUS_OK)test_failed(); |
153 VG_CHECK(&dec_final_range,sizeof(dec_final_range)); | 155 VG_CHECK(&dec_final_range,sizeof(dec_final_range)); |
154 fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); | 156 fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); |
155 cfgs++; | 157 cfgs++; |
156 | 158 |
157 err=opus_decoder_ctl(dec,OPUS_UNIMPLEMENTED); | 159 err=opus_decoder_ctl(dec,OPUS_UNIMPLEMENTED); |
158 if(err!=OPUS_UNIMPLEMENTED)test_failed(); | 160 if(err!=OPUS_UNIMPLEMENTED)test_failed(); |
159 fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); | 161 fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); |
160 cfgs++; | 162 cfgs++; |
161 | 163 |
| 164 err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH((opus_int32 *)NULL)); |
| 165 if(err != OPUS_BAD_ARG)test_failed(); |
162 VG_UNDEF(&i,sizeof(i)); | 166 VG_UNDEF(&i,sizeof(i)); |
163 err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i)); | 167 err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i)); |
164 if(err != OPUS_OK || i!=0)test_failed(); | 168 if(err != OPUS_OK || i!=0)test_failed(); |
165 fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); | 169 fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); |
166 cfgs++; | 170 cfgs++; |
167 | 171 |
| 172 err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL)); |
| 173 if(err != OPUS_BAD_ARG)test_failed(); |
| 174 VG_UNDEF(&i,sizeof(i)); |
| 175 err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(&i)); |
| 176 if(err != OPUS_OK || i!=48000)test_failed(); |
| 177 fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n"); |
| 178 cfgs++; |
| 179 |
168 /*GET_PITCH has different execution paths depending on the previously decoded
frame.*/ | 180 /*GET_PITCH has different execution paths depending on the previously decoded
frame.*/ |
169 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue)); | 181 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue)); |
170 if(err!=OPUS_BAD_ARG)test_failed(); | 182 if(err!=OPUS_BAD_ARG)test_failed(); |
171 cfgs++; | 183 cfgs++; |
172 VG_UNDEF(&i,sizeof(i)); | 184 VG_UNDEF(&i,sizeof(i)); |
173 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); | 185 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); |
174 if(err != OPUS_OK || i>0 || i<-1)test_failed(); | 186 if(err != OPUS_OK || i>0 || i<-1)test_failed(); |
175 cfgs++; | 187 cfgs++; |
176 VG_UNDEF(packet,sizeof(packet)); | 188 VG_UNDEF(packet,sizeof(packet)); |
177 packet[0]=63<<2;packet[1]=packet[2]=0; | 189 packet[0]=63<<2;packet[1]=packet[2]=0; |
178 if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); | 190 if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); |
179 cfgs++; | 191 cfgs++; |
180 VG_UNDEF(&i,sizeof(i)); | 192 VG_UNDEF(&i,sizeof(i)); |
181 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); | 193 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); |
182 if(err != OPUS_OK || i>0 || i<-1)test_failed(); | 194 if(err != OPUS_OK || i>0 || i<-1)test_failed(); |
183 cfgs++; | 195 cfgs++; |
184 packet[0]=1; | 196 packet[0]=1; |
185 if(opus_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed(); | 197 if(opus_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed(); |
186 cfgs++; | 198 cfgs++; |
187 VG_UNDEF(&i,sizeof(i)); | 199 VG_UNDEF(&i,sizeof(i)); |
188 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); | 200 err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); |
189 if(err != OPUS_OK || i>0 || i<-1)test_failed(); | 201 if(err != OPUS_OK || i>0 || i<-1)test_failed(); |
190 cfgs++; | 202 cfgs++; |
191 fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n"); | 203 fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n"); |
192 | 204 |
| 205 err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION((opus_int32 *)NULL)); |
| 206 if(err != OPUS_BAD_ARG)test_failed(); |
| 207 VG_UNDEF(&i,sizeof(i)); |
| 208 err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&i)); |
| 209 if(err != OPUS_OK || i!=960)test_failed(); |
| 210 cfgs++; |
| 211 fprintf(stdout," OPUS_GET_LAST_PACKET_DURATION ................ OK.\n"); |
| 212 |
193 VG_UNDEF(&i,sizeof(i)); | 213 VG_UNDEF(&i,sizeof(i)); |
194 err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i)); | 214 err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i)); |
195 VG_CHECK(&i,sizeof(i)); | 215 VG_CHECK(&i,sizeof(i)); |
196 if(err != OPUS_OK || i!=0)test_failed(); | 216 if(err != OPUS_OK || i!=0)test_failed(); |
197 cfgs++; | 217 cfgs++; |
198 err=opus_decoder_ctl(dec, OPUS_GET_GAIN(nullvalue)); | 218 err=opus_decoder_ctl(dec, OPUS_GET_GAIN(nullvalue)); |
199 if(err != OPUS_BAD_ARG)test_failed(); | 219 if(err != OPUS_BAD_ARG)test_failed(); |
200 cfgs++; | 220 cfgs++; |
201 err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-32769)); | 221 err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-32769)); |
202 if(err != OPUS_BAD_ARG)test_failed(); | 222 if(err != OPUS_BAD_ARG)test_failed(); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 if(tsz[sz]+i<1276) | 1025 if(tsz[sz]+i<1276) |
1006 { | 1026 { |
1007 if(ret!=1)test_failed(); | 1027 if(ret!=1)test_failed(); |
1008 if(size[0]!=tsz[sz]+i)test_failed(); | 1028 if(size[0]!=tsz[sz]+i)test_failed(); |
1009 if((toc>>2)!=i)test_failed(); | 1029 if((toc>>2)!=i)test_failed(); |
1010 } else if (ret!=OPUS_INVALID_PACKET)test_failed(); | 1030 } else if (ret!=OPUS_INVALID_PACKET)test_failed(); |
1011 } | 1031 } |
1012 } | 1032 } |
1013 } | 1033 } |
1014 fprintf(stdout," code 3 padding (%2d cases) ............... OK.\n",cfgs); | 1034 fprintf(stdout," code 3 padding (%2d cases) ............... OK.\n",cfgs); |
1015 cfgs_total+=cfgs;cfgs=0; | 1035 cfgs_total+=cfgs; |
1016 fprintf(stdout," opus_packet_parse ............................ OK.\n"); | 1036 fprintf(stdout," opus_packet_parse ............................ OK.\n"); |
1017 fprintf(stdout," All packet parsing tests passed\n"); | 1037 fprintf(stdout," All packet parsing tests passed\n"); |
1018 fprintf(stdout," (%d API invocations)\n",cfgs_total)
; | 1038 fprintf(stdout," (%d API invocations)\n",cfgs_total)
; |
1019 return cfgs_total; | 1039 return cfgs_total; |
1020 } | 1040 } |
1021 | 1041 |
1022 /* This is a helper macro for the encoder tests. | 1042 /* This is a helper macro for the encoder tests. |
1023 The encoder api tests all have a pattern of set-must-fail, set-must-fail, | 1043 The encoder api tests all have a pattern of set-must-fail, set-must-fail, |
1024 set-must-pass, get-and-compare, set-must-pass, get-and-compare. */ | 1044 set-must-pass, get-and-compare, set-must-pass, get-and-compare. */ |
1025 #define CHECK_SETGET(setcall,getcall,badv,badv2,goodv,goodv2,sok,gok) \ | 1045 #define CHECK_SETGET(setcall,getcall,badv,badv2,goodv,goodv2,sok,gok) \ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 if(enc==NULL)test_failed(); | 1133 if(enc==NULL)test_failed(); |
1114 opus_encoder_destroy(enc); | 1134 opus_encoder_destroy(enc); |
1115 cfgs++; | 1135 cfgs++; |
1116 | 1136 |
1117 VG_UNDEF(&err,sizeof(err)); | 1137 VG_UNDEF(&err,sizeof(err)); |
1118 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &er
r); | 1138 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &er
r); |
1119 if(err!=OPUS_OK || enc==NULL)test_failed(); | 1139 if(err!=OPUS_OK || enc==NULL)test_failed(); |
1120 cfgs++; | 1140 cfgs++; |
1121 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); | 1141 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); |
1122 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); | 1142 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); |
| 1143 cfgs++; |
1123 opus_encoder_destroy(enc); | 1144 opus_encoder_destroy(enc); |
1124 cfgs++; | |
1125 | 1145 |
1126 VG_UNDEF(&err,sizeof(err)); | 1146 VG_UNDEF(&err,sizeof(err)); |
1127 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &err); | 1147 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &err); |
1128 if(err!=OPUS_OK || enc==NULL)test_failed(); | 1148 if(err!=OPUS_OK || enc==NULL)test_failed(); |
1129 cfgs++; | 1149 cfgs++; |
1130 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); | 1150 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); |
1131 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); | 1151 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); |
1132 opus_encoder_destroy(enc); | 1152 opus_encoder_destroy(enc); |
1133 cfgs++; | 1153 cfgs++; |
1134 | 1154 |
1135 VG_UNDEF(&err,sizeof(err)); | 1155 VG_UNDEF(&err,sizeof(err)); |
1136 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err); | 1156 enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err); |
1137 if(err!=OPUS_OK || enc==NULL)test_failed(); | 1157 if(err!=OPUS_OK || enc==NULL)test_failed(); |
1138 cfgs++; | 1158 cfgs++; |
1139 | 1159 |
1140 fprintf(stdout," opus_encoder_create() ........................ OK.\n"); | 1160 fprintf(stdout," opus_encoder_create() ........................ OK.\n"); |
1141 fprintf(stdout," opus_encoder_init() .......................... OK.\n"); | 1161 fprintf(stdout," opus_encoder_init() .......................... OK.\n"); |
1142 | 1162 |
1143 i=-12345; | 1163 i=-12345; |
1144 VG_UNDEF(&i,sizeof(i)); | 1164 VG_UNDEF(&i,sizeof(i)); |
1145 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); | 1165 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); |
1146 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); | 1166 if(err!=OPUS_OK || i<0 || i>32766)test_failed(); |
1147 cfgs++; | 1167 cfgs++; |
| 1168 err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD((opus_int32 *)NULL)); |
| 1169 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1170 cfgs++; |
1148 fprintf(stdout," OPUS_GET_LOOKAHEAD ........................... OK.\n"); | 1171 fprintf(stdout," OPUS_GET_LOOKAHEAD ........................... OK.\n"); |
1149 | 1172 |
| 1173 err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(&i)); |
| 1174 if(err!=OPUS_OK || i!=48000)test_failed(); |
| 1175 cfgs++; |
| 1176 err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL)); |
| 1177 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1178 cfgs++; |
| 1179 fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n"); |
| 1180 |
1150 if(opus_encoder_ctl(enc,OPUS_UNIMPLEMENTED)!=OPUS_UNIMPLEMENTED)test_failed()
; | 1181 if(opus_encoder_ctl(enc,OPUS_UNIMPLEMENTED)!=OPUS_UNIMPLEMENTED)test_failed()
; |
1151 fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); | 1182 fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); |
1152 cfgs++; | 1183 cfgs++; |
1153 | 1184 |
| 1185 err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION((opus_int32 *)NULL)); |
| 1186 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1187 cfgs++; |
1154 CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO, | 1188 CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO, |
1155 OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY, | 1189 OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY, |
1156 " OPUS_SET_APPLICATION ......................... OK.\n", | 1190 " OPUS_SET_APPLICATION ......................... OK.\n", |
1157 " OPUS_GET_APPLICATION ......................... OK.\n") | 1191 " OPUS_GET_APPLICATION ......................... OK.\n") |
1158 | 1192 |
| 1193 err=opus_encoder_ctl(enc,OPUS_GET_BITRATE((opus_int32 *)NULL)); |
| 1194 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1195 cfgs++; |
1159 if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed(); | 1196 if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed(); |
1160 cfgs++; | 1197 cfgs++; |
1161 VG_UNDEF(&i,sizeof(i)); | 1198 VG_UNDEF(&i,sizeof(i)); |
1162 if(opus_encoder_ctl(enc,OPUS_GET_BITRATE(&i))!=OPUS_OK)test_failed(); | 1199 if(opus_encoder_ctl(enc,OPUS_GET_BITRATE(&i))!=OPUS_OK)test_failed(); |
1163 if(i>700000||i<256000)test_failed(); | 1200 if(i>700000||i<256000)test_failed(); |
1164 cfgs++; | 1201 cfgs++; |
1165 CHECK_SETGET(OPUS_SET_BITRATE(i),OPUS_GET_BITRATE(&i),-12345,0, | 1202 CHECK_SETGET(OPUS_SET_BITRATE(i),OPUS_GET_BITRATE(&i),-12345,0, |
1166 500,256000, | 1203 500,256000, |
1167 " OPUS_SET_BITRATE ............................. OK.\n", | 1204 " OPUS_SET_BITRATE ............................. OK.\n", |
1168 " OPUS_GET_BITRATE ............................. OK.\n") | 1205 " OPUS_GET_BITRATE ............................. OK.\n") |
1169 | 1206 |
| 1207 err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS((opus_int32 *)NULL)); |
| 1208 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1209 cfgs++; |
1170 CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3, | 1210 CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3, |
1171 1,OPUS_AUTO, | 1211 1,OPUS_AUTO, |
1172 " OPUS_SET_FORCE_CHANNELS ...................... OK.\n", | 1212 " OPUS_SET_FORCE_CHANNELS ...................... OK.\n", |
1173 " OPUS_GET_FORCE_CHANNELS ...................... OK.\n") | 1213 " OPUS_GET_FORCE_CHANNELS ...................... OK.\n") |
1174 | 1214 |
1175 i=-2; | 1215 i=-2; |
1176 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); | 1216 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); |
1177 cfgs++; | 1217 cfgs++; |
1178 i=OPUS_BANDWIDTH_FULLBAND+1; | 1218 i=OPUS_BANDWIDTH_FULLBAND+1; |
1179 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); | 1219 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); |
(...skipping 15 matching lines...) Expand all Loading... |
1195 because the change may be delayed until the encoder is advanced.*/ | 1235 because the change may be delayed until the encoder is advanced.*/ |
1196 i=-12345; | 1236 i=-12345; |
1197 VG_UNDEF(&i,sizeof(i)); | 1237 VG_UNDEF(&i,sizeof(i)); |
1198 err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(&i)); | 1238 err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(&i)); |
1199 if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& | 1239 if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& |
1200 i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& | 1240 i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& |
1201 i!=OPUS_BANDWIDTH_FULLBAND&&i!=OPUS_AUTO))test_failed(); | 1241 i!=OPUS_BANDWIDTH_FULLBAND&&i!=OPUS_AUTO))test_failed(); |
1202 cfgs++; | 1242 cfgs++; |
1203 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed()
; | 1243 if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed()
; |
1204 cfgs++; | 1244 cfgs++; |
| 1245 err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH((opus_int32 *)NULL)); |
| 1246 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1247 cfgs++; |
1205 fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); | 1248 fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); |
1206 | 1249 |
1207 i=-2; | 1250 i=-2; |
1208 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); | 1251 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); |
1209 cfgs++; | 1252 cfgs++; |
1210 i=OPUS_BANDWIDTH_FULLBAND+1; | 1253 i=OPUS_BANDWIDTH_FULLBAND+1; |
1211 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); | 1254 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); |
1212 cfgs++; | 1255 cfgs++; |
1213 i=OPUS_BANDWIDTH_NARROWBAND; | 1256 i=OPUS_BANDWIDTH_NARROWBAND; |
1214 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); | 1257 if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); |
(...skipping 10 matching lines...) Expand all Loading... |
1225 fprintf(stdout," OPUS_SET_MAX_BANDWIDTH ....................... OK.\n"); | 1268 fprintf(stdout," OPUS_SET_MAX_BANDWIDTH ....................... OK.\n"); |
1226 /*We don't test if the bandwidth has actually changed. | 1269 /*We don't test if the bandwidth has actually changed. |
1227 because the change may be delayed until the encoder is advanced.*/ | 1270 because the change may be delayed until the encoder is advanced.*/ |
1228 i=-12345; | 1271 i=-12345; |
1229 VG_UNDEF(&i,sizeof(i)); | 1272 VG_UNDEF(&i,sizeof(i)); |
1230 err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(&i)); | 1273 err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(&i)); |
1231 if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& | 1274 if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& |
1232 i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& | 1275 i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& |
1233 i!=OPUS_BANDWIDTH_FULLBAND))test_failed(); | 1276 i!=OPUS_BANDWIDTH_FULLBAND))test_failed(); |
1234 cfgs++; | 1277 cfgs++; |
| 1278 err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH((opus_int32 *)NULL)); |
| 1279 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1280 cfgs++; |
1235 fprintf(stdout," OPUS_GET_MAX_BANDWIDTH ....................... OK.\n"); | 1281 fprintf(stdout," OPUS_GET_MAX_BANDWIDTH ....................... OK.\n"); |
1236 | 1282 |
| 1283 err=opus_encoder_ctl(enc,OPUS_GET_DTX((opus_int32 *)NULL)); |
| 1284 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1285 cfgs++; |
1237 CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2, | 1286 CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2, |
1238 1,0, | 1287 1,0, |
1239 " OPUS_SET_DTX ................................. OK.\n", | 1288 " OPUS_SET_DTX ................................. OK.\n", |
1240 " OPUS_GET_DTX ................................. OK.\n") | 1289 " OPUS_GET_DTX ................................. OK.\n") |
1241 | 1290 |
| 1291 err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY((opus_int32 *)NULL)); |
| 1292 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1293 cfgs++; |
1242 CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11, | 1294 CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11, |
1243 0,10, | 1295 0,10, |
1244 " OPUS_SET_COMPLEXITY .......................... OK.\n", | 1296 " OPUS_SET_COMPLEXITY .......................... OK.\n", |
1245 " OPUS_GET_COMPLEXITY .......................... OK.\n") | 1297 " OPUS_GET_COMPLEXITY .......................... OK.\n") |
1246 | 1298 |
| 1299 err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC((opus_int32 *)NULL)); |
| 1300 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1301 cfgs++; |
1247 CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,2, | 1302 CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,2, |
1248 1,0, | 1303 1,0, |
1249 " OPUS_SET_INBAND_FEC .......................... OK.\n", | 1304 " OPUS_SET_INBAND_FEC .......................... OK.\n", |
1250 " OPUS_GET_INBAND_FEC .......................... OK.\n") | 1305 " OPUS_GET_INBAND_FEC .......................... OK.\n") |
1251 | 1306 |
| 1307 err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC((opus_int32 *)NULL)); |
| 1308 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1309 cfgs++; |
1252 CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,10
1, | 1310 CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,10
1, |
1253 100,0, | 1311 100,0, |
1254 " OPUS_SET_PACKET_LOSS_PERC .................... OK.\n", | 1312 " OPUS_SET_PACKET_LOSS_PERC .................... OK.\n", |
1255 " OPUS_GET_PACKET_LOSS_PERC .................... OK.\n") | 1313 " OPUS_GET_PACKET_LOSS_PERC .................... OK.\n") |
1256 | 1314 |
| 1315 err=opus_encoder_ctl(enc,OPUS_GET_VBR((opus_int32 *)NULL)); |
| 1316 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1317 cfgs++; |
1257 CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2, | 1318 CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2, |
1258 1,0, | 1319 1,0, |
1259 " OPUS_SET_VBR ................................. OK.\n", | 1320 " OPUS_SET_VBR ................................. OK.\n", |
1260 " OPUS_GET_VBR ................................. OK.\n") | 1321 " OPUS_GET_VBR ................................. OK.\n") |
1261 | 1322 |
1262 /*CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101, | 1323 /* err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO((opus_int32 *)NULL)); |
| 1324 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1325 cfgs++; |
| 1326 CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101, |
1263 0,50, | 1327 0,50, |
1264 " OPUS_SET_VOICE_RATIO ......................... OK.\n", | 1328 " OPUS_SET_VOICE_RATIO ......................... OK.\n", |
1265 " OPUS_GET_VOICE_RATIO ......................... OK.\n") | 1329 " OPUS_GET_VOICE_RATIO ......................... OK.\n")*/ |
1266 */ | |
1267 | 1330 |
| 1331 err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT((opus_int32 *)NULL)); |
| 1332 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1333 cfgs++; |
1268 CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2, | 1334 CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2, |
1269 1,0, | 1335 1,0, |
1270 " OPUS_SET_VBR_CONSTRAINT ...................... OK.\n", | 1336 " OPUS_SET_VBR_CONSTRAINT ...................... OK.\n", |
1271 " OPUS_GET_VBR_CONSTRAINT ...................... OK.\n") | 1337 " OPUS_GET_VBR_CONSTRAINT ...................... OK.\n") |
1272 | 1338 |
| 1339 err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL((opus_int32 *)NULL)); |
| 1340 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1341 cfgs++; |
1273 CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF, | 1342 CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF, |
1274 OPUS_SIGNAL_MUSIC,OPUS_AUTO, | 1343 OPUS_SIGNAL_MUSIC,OPUS_AUTO, |
1275 " OPUS_SET_SIGNAL .............................. OK.\n", | 1344 " OPUS_SET_SIGNAL .............................. OK.\n", |
1276 " OPUS_GET_SIGNAL .............................. OK.\n") | 1345 " OPUS_GET_SIGNAL .............................. OK.\n") |
1277 | 1346 |
| 1347 err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH((opus_int32 *)NULL)); |
| 1348 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1349 cfgs++; |
1278 CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24, | 1350 CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24, |
1279 " OPUS_SET_LSB_DEPTH ........................... OK.\n", | 1351 " OPUS_SET_LSB_DEPTH ........................... OK.\n", |
1280 " OPUS_GET_LSB_DEPTH ........................... OK.\n") | 1352 " OPUS_GET_LSB_DEPTH ........................... OK.\n") |
1281 | 1353 |
| 1354 err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION((opus_int32 *)NULL)); |
| 1355 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1356 cfgs++; |
| 1357 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_2_5_MS
)); |
| 1358 if(err!=OPUS_OK)test_failed(); |
| 1359 cfgs++; |
| 1360 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_5_MS))
; |
| 1361 if(err!=OPUS_OK)test_failed(); |
| 1362 cfgs++; |
| 1363 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_10_MS)
); |
| 1364 if(err!=OPUS_OK)test_failed(); |
| 1365 cfgs++; |
| 1366 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_20_MS)
); |
| 1367 if(err!=OPUS_OK)test_failed(); |
| 1368 cfgs++; |
| 1369 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_40_MS)
); |
| 1370 if(err!=OPUS_OK)test_failed(); |
| 1371 cfgs++; |
| 1372 err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_60_MS)
); |
| 1373 if(err!=OPUS_OK)test_failed(); |
| 1374 cfgs++; |
| 1375 CHECK_SETGET(OPUS_SET_EXPERT_FRAME_DURATION(i),OPUS_GET_EXPERT_FRAME_DURATION
(&i),0,-1, |
| 1376 OPUS_FRAMESIZE_VARIABLE,OPUS_FRAMESIZE_ARG, |
| 1377 " OPUS_SET_EXPERT_FRAME_DURATION ............... OK.\n", |
| 1378 " OPUS_GET_EXPERT_FRAME_DURATION ............... OK.\n") |
| 1379 |
1282 /*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, howev
er the encoder tests use it*/ | 1380 /*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, howev
er the encoder tests use it*/ |
1283 | 1381 |
| 1382 err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL)); |
| 1383 if(err!=OPUS_BAD_ARG)test_failed(); |
| 1384 cfgs++; |
1284 if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test
_failed(); | 1385 if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test
_failed(); |
1285 cfgs++; | 1386 cfgs++; |
1286 fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); | 1387 fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); |
1287 | 1388 |
1288 /*Reset the encoder*/ | 1389 /*Reset the encoder*/ |
1289 if(opus_encoder_ctl(enc, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); | 1390 if(opus_encoder_ctl(enc, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); |
1290 cfgs++; | 1391 cfgs++; |
1291 fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n"); | 1392 fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n"); |
1292 | 1393 |
1293 memset(sbuf,0,sizeof(short)*2*960); | 1394 memset(sbuf,0,sizeof(short)*2*960); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 total+=test_msdec_api(); | 1811 total+=test_msdec_api(); |
1711 total+=test_parse(); | 1812 total+=test_parse(); |
1712 total+=test_enc_api(); | 1813 total+=test_enc_api(); |
1713 total+=test_repacketizer_api(); | 1814 total+=test_repacketizer_api(); |
1714 total+=test_malloc_fail(); | 1815 total+=test_malloc_fail(); |
1715 | 1816 |
1716 fprintf(stderr,"\nAll API tests passed.\nThe libopus API was invoked %d times
.\n",total); | 1817 fprintf(stderr,"\nAll API tests passed.\nThe libopus API was invoked %d times
.\n",total); |
1717 | 1818 |
1718 return 0; | 1819 return 0; |
1719 } | 1820 } |
OLD | NEW |