| OLD | NEW |
| 1 /* Copyright (c) 2007-2008 CSIRO | 1 /* Copyright (c) 2007-2008 CSIRO |
| 2 Copyright (c) 2007-2009 Xiph.Org Foundation | 2 Copyright (c) 2007-2009 Xiph.Org Foundation |
| 3 Written by Jean-Marc Valin */ | 3 Written by Jean-Marc Valin */ |
| 4 /* | 4 /* |
| 5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
| 6 modification, are permitted provided that the following conditions | 6 modification, are permitted provided that the following conditions |
| 7 are met: | 7 are met: |
| 8 | 8 |
| 9 - Redistributions of source code must retain the above copyright | 9 - Redistributions of source code must retain the above copyright |
| 10 notice, this list of conditions and the following disclaimer. | 10 notice, this list of conditions and the following disclaimer. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 static void check_encoder_option(int decode_only, const char *opt) | 89 static void check_encoder_option(int decode_only, const char *opt) |
| 90 { | 90 { |
| 91 if (decode_only) | 91 if (decode_only) |
| 92 { | 92 { |
| 93 fprintf(stderr, "option %s is only for encoding\n", opt); | 93 fprintf(stderr, "option %s is only for encoding\n", opt); |
| 94 exit(EXIT_FAILURE); | 94 exit(EXIT_FAILURE); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 int silk8_test[][4] = { | 98 static const int silk8_test[][4] = { |
| 99 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 1}, | 99 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 1}, |
| 100 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 1}, | 100 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 1}, |
| 101 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, | 101 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, |
| 102 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, | 102 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, |
| 103 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 2}, | 103 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 2}, |
| 104 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 2}, | 104 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 2}, |
| 105 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, | 105 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, |
| 106 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2} | 106 {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2} |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 int silk12_test[][4] = { | 109 static const int silk12_test[][4] = { |
| 110 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 1}, | 110 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 1}, |
| 111 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 1}, | 111 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 1}, |
| 112 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 1}, | 112 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 1}, |
| 113 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 1}, | 113 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 1}, |
| 114 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 2}, | 114 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 2}, |
| 115 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 2}, | 115 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 2}, |
| 116 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 2}, | 116 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 2}, |
| 117 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 2} | 117 {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 2} |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 int silk16_test[][4] = { | 120 static const int silk16_test[][4] = { |
| 121 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 1}, | 121 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 1}, |
| 122 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 1}, | 122 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 1}, |
| 123 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, | 123 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, |
| 124 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, | 124 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, |
| 125 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 2}, | 125 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 2}, |
| 126 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 2}, | 126 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 2}, |
| 127 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, | 127 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, |
| 128 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2} | 128 {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2} |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 int hybrid24_test[][4] = { | 131 static const int hybrid24_test[][4] = { |
| 132 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, | 132 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, |
| 133 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, | 133 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, |
| 134 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, | 134 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, |
| 135 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2} | 135 {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2} |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 int hybrid48_test[][4] = { | 138 static const int hybrid48_test[][4] = { |
| 139 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, | 139 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, |
| 140 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, | 140 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, |
| 141 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, | 141 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, |
| 142 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2} | 142 {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2} |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 int celt_test[][4] = { | 145 static const int celt_test[][4] = { |
| 146 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, | 146 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, |
| 147 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, | 147 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, |
| 148 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, | 148 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, |
| 149 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, | 149 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, |
| 150 | 150 |
| 151 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, | 151 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, |
| 152 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, | 152 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, |
| 153 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, | 153 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, |
| 154 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, | 154 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, |
| 155 | 155 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 178 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 2}, | 178 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 2}, |
| 179 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 2}, | 179 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 2}, |
| 180 | 180 |
| 181 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, | 181 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, |
| 182 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 2}, | 182 {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 2}, |
| 183 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 2}, | 183 {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 2}, |
| 184 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 2}, | 184 {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 2}, |
| 185 | 185 |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 int celt_hq_test[][4] = { | 188 static const int celt_hq_test[][4] = { |
| 189 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, | 189 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, |
| 190 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, | 190 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, |
| 191 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, | 191 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, |
| 192 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, | 192 {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 int main(int argc, char *argv[]) | 195 int main(int argc, char *argv[]) |
| 196 { | 196 { |
| 197 int err; | 197 int err; |
| 198 char *inFile, *outFile; | 198 char *inFile, *outFile; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 227 int toggle = 0; | 227 int toggle = 0; |
| 228 opus_uint32 enc_final_range[2]; | 228 opus_uint32 enc_final_range[2]; |
| 229 opus_uint32 dec_final_range; | 229 opus_uint32 dec_final_range; |
| 230 int encode_only=0, decode_only=0; | 230 int encode_only=0, decode_only=0; |
| 231 int max_frame_size = 960*6; | 231 int max_frame_size = 960*6; |
| 232 int curr_read=0; | 232 int curr_read=0; |
| 233 int sweep_bps = 0; | 233 int sweep_bps = 0; |
| 234 int random_framesize=0, newsize=0, delayed_celt=0; | 234 int random_framesize=0, newsize=0, delayed_celt=0; |
| 235 int sweep_max=0, sweep_min=0; | 235 int sweep_max=0, sweep_min=0; |
| 236 int random_fec=0; | 236 int random_fec=0; |
| 237 int (*mode_list)[4]=NULL; | 237 const int (*mode_list)[4]=NULL; |
| 238 int nb_modes_in_list=0; | 238 int nb_modes_in_list=0; |
| 239 int curr_mode=0; | 239 int curr_mode=0; |
| 240 int curr_mode_count=0; | 240 int curr_mode_count=0; |
| 241 int mode_switch_time = 48000; | 241 int mode_switch_time = 48000; |
| 242 | 242 |
| 243 if (argc < 5 ) | 243 if (argc < 5 ) |
| 244 { | 244 { |
| 245 print_usage( argv ); | 245 print_usage( argv ); |
| 246 return EXIT_FAILURE; | 246 return EXIT_FAILURE; |
| 247 } | 247 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 fprintf(stderr, "Error writing.\n"); | 677 fprintf(stderr, "Error writing.\n"); |
| 678 return EXIT_FAILURE; | 678 return EXIT_FAILURE; |
| 679 } | 679 } |
| 680 if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[togg
le]) { | 680 if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[togg
le]) { |
| 681 fprintf(stderr, "Error writing.\n"); | 681 fprintf(stderr, "Error writing.\n"); |
| 682 return EXIT_FAILURE; | 682 return EXIT_FAILURE; |
| 683 } | 683 } |
| 684 } else { | 684 } else { |
| 685 int output_samples; | 685 int output_samples; |
| 686 lost = len[toggle]==0 || (packet_loss_perc>0 && rand()%100 < packet_
loss_perc); | 686 lost = len[toggle]==0 || (packet_loss_perc>0 && rand()%100 < packet_
loss_perc); |
| 687 if (lost) |
| 688 opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_sampl
es)); |
| 689 else |
| 690 output_samples = max_frame_size; |
| 687 if( count >= use_inbandfec ) { | 691 if( count >= use_inbandfec ) { |
| 688 /* delay by one packet when using in-band FEC */ | 692 /* delay by one packet when using in-band FEC */ |
| 689 if( use_inbandfec ) { | 693 if( use_inbandfec ) { |
| 690 if( lost_prev ) { | 694 if( lost_prev ) { |
| 691 /* attempt to decode with in-band FEC from next packet *
/ | 695 /* attempt to decode with in-band FEC from next packet *
/ |
| 692 output_samples = opus_decode(dec, lost ? NULL : data[tog
gle], len[toggle], out, max_frame_size, 1); | 696 output_samples = opus_decode(dec, lost ? NULL : data[tog
gle], len[toggle], out, output_samples, 1); |
| 693 } else { | 697 } else { |
| 694 /* regular decode */ | 698 /* regular decode */ |
| 695 output_samples = opus_decode(dec, data[1-toggle], len[1-
toggle], out, max_frame_size, 0); | 699 output_samples = opus_decode(dec, data[1-toggle], len[1-
toggle], out, output_samples, 0); |
| 696 } | 700 } |
| 697 } else { | 701 } else { |
| 698 output_samples = opus_decode(dec, lost ? NULL : data[toggle]
, len[toggle], out, max_frame_size, 0); | 702 output_samples = opus_decode(dec, lost ? NULL : data[toggle]
, len[toggle], out, output_samples, 0); |
| 699 } | 703 } |
| 700 if (output_samples>0) | 704 if (output_samples>0) |
| 701 { | 705 { |
| 702 if (output_samples>skip) { | 706 if (output_samples>skip) { |
| 703 int i; | 707 int i; |
| 704 for(i=0;i<(output_samples-skip)*channels;i++) | 708 for(i=0;i<(output_samples-skip)*channels;i++) |
| 705 { | 709 { |
| 706 short s; | 710 short s; |
| 707 s=out[i+(skip*channels)]; | 711 s=out[i+(skip*channels)]; |
| 708 fbytes[2*i]=s&0xFF; | 712 fbytes[2*i]=s&0xFF; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 free(data[0]); | 783 free(data[0]); |
| 780 if (use_inbandfec) | 784 if (use_inbandfec) |
| 781 free(data[1]); | 785 free(data[1]); |
| 782 fclose(fin); | 786 fclose(fin); |
| 783 fclose(fout); | 787 fclose(fout); |
| 784 free(in); | 788 free(in); |
| 785 free(out); | 789 free(out); |
| 786 free(fbytes); | 790 free(fbytes); |
| 787 return EXIT_SUCCESS; | 791 return EXIT_SUCCESS; |
| 788 } | 792 } |
| OLD | NEW |