diff --git a/BDMatch/BDMatch.aps b/BDMatch/BDMatch.aps index 5c99642..5af0eb3 100644 Binary files a/BDMatch/BDMatch.aps and b/BDMatch/BDMatch.aps differ diff --git a/BDMatch/BDMatch.rc b/BDMatch/BDMatch.rc index 2a68f34..ed9b30a 100644 Binary files a/BDMatch/BDMatch.rc and b/BDMatch/BDMatch.rc differ diff --git a/BDMatch/MyForm.cpp b/BDMatch/MyForm.cpp index 587f673..47090d6 100644 --- a/BDMatch/MyForm.cpp +++ b/BDMatch/MyForm.cpp @@ -5,7 +5,7 @@ #pragma managed #include -#define appversion "1.5.18" +#define appversion "1.5.19" #define secpurple 45 #define setintnum 5 #define MaxdB 20.0 @@ -106,8 +106,8 @@ int BDMatch::MyForm::write_ass(const char* sub_path, const char* output_path) int nb_timeline = static_cast(BDMatchCoreAPI::get_nb_timeline()); //绘图相关 if (setting->draw) { - tv_draw.time_list = gcnew array(nb_timeline, 2); - bd_draw.time_list = gcnew array(nb_timeline, 2); + tv_draw.time_list = gcnew array(nb_timeline, 2); + bd_draw.time_list = gcnew array(nb_timeline, 2); tv_draw.line_num = nb_timeline; bd_draw.line_num = nb_timeline; LineSel->Maximum = nb_timeline; @@ -169,18 +169,18 @@ int BDMatch::MyForm::draw_pre(const int &re) bd_draw.spec = BDMatchCoreAPI::get_decode_spec(Decode::Decode_File::BD_Decode); tv_draw.num = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::FFT_Samp_Num); bd_draw.num = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::FFT_Samp_Num); - tv_draw.ch = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::Channels); - bd_draw.ch = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::Channels); + tv_draw.ch = static_cast(BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::Channels)); + bd_draw.ch = static_cast(BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::Channels)); tv_draw.milisec = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::Milisec); bd_draw.milisec = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::Milisec); - tv_draw.fft_num = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::FFT_Num); - bd_draw.fft_num = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::FFT_Num); + tv_draw.fft_num = static_cast(BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::FFT_Num)); + bd_draw.fft_num = static_cast(BDMatchCoreAPI::get_decode_info(Decode::Decode_File::BD_Decode, Decode::Decode_Info::FFT_Num)); tv_draw.ttf = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::Samp_Rate) / (static_cast(tv_draw.fft_num) * 100.0); bd_draw.ttf = BDMatchCoreAPI::get_decode_info(Decode::Decode_File::TV_Decode, Decode::Decode_Info::Samp_Rate) / (static_cast(bd_draw.fft_num) * 100.0); ViewSel->SelectedIndex = 0; ChSelect->SelectedIndex = 0; ChSelect->Enabled = true; - TimeRoll->Maximum = max(tv_draw.milisec, bd_draw.milisec); + TimeRoll->Maximum = static_cast(max(tv_draw.milisec, bd_draw.milisec)); TimeRoll->Value = 0; TimeRoll->Enabled = true; if (setting->match_ass)ViewSel->Enabled = true; @@ -203,8 +203,8 @@ int BDMatch::MyForm::draw_chart() { using namespace System::Drawing; Match->Enabled = false; - int maxsampnum = max(tv_draw.num, bd_draw.num); - int milisec = max(tv_draw.milisec, bd_draw.milisec); + int64_t maxsampnum = max(tv_draw.num, bd_draw.num); + int64_t milisec = max(tv_draw.milisec, bd_draw.milisec); int offset = 0; if (milisec < 10000) offset = 150; else if (milisec < 100000)offset = 250; @@ -212,11 +212,11 @@ int BDMatch::MyForm::draw_chart() TimeRoll->TickFrequency = offset; TimeRoll->LargeChange = offset; TimeRoll->SmallChange = offset / 4; - int tvstart = 0, tvend = 0, bdstart = 0; + int64_t tvstart = 0, tvend = 0, bdstart = 0; if (ViewSel->SelectedIndex == 0) { - tvstart = static_cast(round((TimeRoll->Value - offset)* tv_draw.ttf)); - tvend = static_cast(round((TimeRoll->Value + offset)* tv_draw.ttf)); - bdstart = static_cast(round((TimeRoll->Value - offset)* bd_draw.ttf)); + tvstart = static_cast(round((TimeRoll->Value - offset)* tv_draw.ttf)); + tvend = static_cast(round((TimeRoll->Value + offset)* tv_draw.ttf)); + bdstart = static_cast(round((TimeRoll->Value - offset)* bd_draw.ttf)); ChartTime->Text = ms2time(TimeRoll->Value); } else { @@ -237,7 +237,7 @@ int BDMatch::MyForm::draw_chart() else ChartTime->Text = ms2time(static_cast(round(tv_draw.time_list[static_cast(LineSel->Value) - 1, 0] / tv_draw.ttf)) + 1) + "\n" + ms2time(static_cast(round(bd_draw.time_list[static_cast(LineSel->Value) - 1, 0] / bd_draw.ttf))); } - int duration = tvend - tvstart + 1; + int duration = static_cast(tvend - tvstart + 1); if (ChSelect->SelectedIndex > min(tv_draw.ch, bd_draw.ch) - 1) { ChartTime->Text = "无该声道!"; @@ -286,8 +286,8 @@ int BDMatch::MyForm::draw_chart() } } } - int bd_spec_offset = (x + bdstart) * bd_draw.fft_num / 2 + bd_draw.fft_num - 1; - int tv_spec_offset = (x + tvstart) * tv_draw.fft_num / 2 + tv_draw.fft_num / 2 - 1; + int64_t bd_spec_offset = (x + bdstart) * bd_draw.fft_num / 2 + bd_draw.fft_num - 1; + int64_t tv_spec_offset = (x + tvstart) * tv_draw.fft_num / 2 + tv_draw.fft_num / 2 - 1; int pos_offset = 0; for (y = 0; y < tv_draw.fft_num; y++) { int color = -128; diff --git a/BDMatch/MyForm.h b/BDMatch/MyForm.h index cd977ac..b35e0e9 100644 --- a/BDMatch/MyForm.h +++ b/BDMatch/MyForm.h @@ -3,6 +3,7 @@ #include "Settings.h" #pragma unmanaged #include "headers/user interface.h" +#include #pragma managed namespace BDMatch { @@ -40,14 +41,14 @@ namespace BDMatch { } } private: ref struct drawpara { - int num = 0; + int64_t num = 0; int ch = 0; - int milisec = 0; - int line_num = 0; + int64_t milisec = 0; + int64_t line_num = 0; int fft_num = 0; double ttf = 1.0;//Time to Frequency char** spec = nullptr; - array^ time_list = nullptr; + array^ time_list = nullptr; }; private: SettingVals ^ setting = gcnew SettingVals; diff --git a/BDMatchCore/BDMatchCore.aps b/BDMatchCore/BDMatchCore.aps index aa37d47..2e6b5c9 100644 Binary files a/BDMatchCore/BDMatchCore.aps and b/BDMatchCore/BDMatchCore.aps differ diff --git a/BDMatchCore/BDMatchCore.cpp b/BDMatchCore/BDMatchCore.cpp index 38c9574..91ebd71 100644 --- a/BDMatchCore/BDMatchCore.cpp +++ b/BDMatchCore/BDMatchCore.cpp @@ -208,13 +208,13 @@ size_t BDMatchCore::get_nb_timeline() if (match)return match->get_nb_timeline(); else return 0; } -int BDMatchCore::get_timeline(const int & index, const Match::Timeline_Time_Type& type) +int64_t BDMatchCore::get_timeline(const int & index, const Match::Timeline_Time_Type& type) { if (match)return match->get_timeline(index, type); else return -1; } -int BDMatchCore::get_decode_info(const Decode::Decode_File & file, const Decode::Decode_Info & type) +int64_t BDMatchCore::get_decode_info(const Decode::Decode_File & file, const Decode::Decode_Info & type) { Decode::Decode *decode_ptr; if (file == Decode::Decode_File::BD_Decode)decode_ptr = bd_decode.get(); diff --git a/BDMatchCore/BDMatchCore.rc b/BDMatchCore/BDMatchCore.rc index 276bcfa..46c5044 100644 Binary files a/BDMatchCore/BDMatchCore.rc and b/BDMatchCore/BDMatchCore.rc differ diff --git a/BDMatchCore/BDMatchCoreAPI.cpp b/BDMatchCore/BDMatchCoreAPI.cpp index f169a49..721e569 100644 --- a/BDMatchCore/BDMatchCoreAPI.cpp +++ b/BDMatchCore/BDMatchCoreAPI.cpp @@ -1,7 +1,7 @@ // No need for platform other than Windows -#include "include/BDMatchCoreAPI.h" #include "headers/BDMatchCore.h" #include "include/instructionset.h" +#include "include/BDMatchCoreAPI.h" std::unique_ptr match_core; const InstructionSet::InstructionSet_Internal InstructionSet::CPU_Rep; @@ -65,12 +65,12 @@ BDMatchCore_API size_t BDMatchCoreAPI::get_nb_timeline() return match_core->get_nb_timeline(); } -BDMatchCore_API int BDMatchCoreAPI::get_timeline(const int& index, const Match::Timeline_Time_Type& type) +BDMatchCore_API int64_t BDMatchCoreAPI::get_timeline(const int& index, const Match::Timeline_Time_Type& type) { return match_core->get_timeline(index, type); } -BDMatchCore_API int BDMatchCoreAPI::get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type) +BDMatchCore_API int64_t BDMatchCoreAPI::get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type) { return match_core->get_decode_info(file, type); } diff --git a/BDMatchCore/CLI.cpp b/BDMatchCore/CLI.cpp index 4f525b8..1b3a7cc 100644 --- a/BDMatchCore/CLI.cpp +++ b/BDMatchCore/CLI.cpp @@ -8,9 +8,9 @@ A simple example of command line usage of BDMatchCore #include #include "headers/BDMatchCore.h" -constexpr const char* version = "1.0.18"; +constexpr const char* version = "1.0.19"; -void print(const char* in, const long long len) { +void print(const char* in, const int64_t len) { std::cout << in; } diff --git a/BDMatchCore/datastruct.cpp b/BDMatchCore/datastruct.cpp index 70567aa..55f028a 100644 --- a/BDMatchCore/datastruct.cpp +++ b/BDMatchCore/datastruct.cpp @@ -22,7 +22,7 @@ char * DataStruct::node::getdata() int DataStruct::node::sum() { - if (sumval == -2147483647) { + if (sumval == std::numeric_limits::min()) { sumval = 0; for (int i = 0; i < count; i++) { sumval += data[i]; diff --git a/BDMatchCore/decoder.cpp b/BDMatchCore/decoder.cpp index bf2ced7..f582ea6 100644 --- a/BDMatchCore/decoder.cpp +++ b/BDMatchCore/decoder.cpp @@ -134,7 +134,7 @@ int Decode::Decode::initialize(const std::string & file_name0) else if (audio_stream == 0) { audio_only = true; } - milisec = static_cast(ceil(ffmpeg->filefm->duration / 10000)); + milisec = static_cast(ffmpeg->filefm->duration / 10000); ffmpeg->codec = avcodec_find_decoder(ffmpeg->filefm->streams[audio_stream]->codecpar->codec_id);//寻找解码器 if (!ffmpeg->codec) { @@ -262,7 +262,7 @@ int Decode::Decode::decode_audio() { if (ffmpeg->codecfm->sample_fmt == AV_SAMPLE_FMT_FLT || ffmpeg->codecfm->sample_fmt == AV_SAMPLE_FMT_FLTP) sample_type = 1; else if (ffmpeg->codecfm->sample_fmt == AV_SAMPLE_FMT_DBL || ffmpeg->codecfm->sample_fmt == AV_SAMPLE_FMT_DBLP) sample_type = 2; //采样变量 - int samplenum = 0; + int64_t samplenum = 0; c_min_db = 256.0 / (MaxdB - static_cast(min_db)); //重采样变量2 ffmpeg->dst_data = nullptr; @@ -296,9 +296,9 @@ int Decode::Decode::decode_audio() { } } else { - samplenum = static_cast(ceil(sample_rate / 1000.0*ffmpeg->filefm->duration / 1000.0)); + samplenum = static_cast(ceil(sample_rate / 1000.0 * ffmpeg->filefm->duration / 1000.0)); } - e_fft_num = static_cast(ceil(samplenum / float(fft_num)));//estimated_fft_num + e_fft_num = static_cast(ceil(samplenum / static_cast(fft_num)));//estimated_fft_num //查询音频封装格式 ffmpeg->packet = av_packet_alloc(); std::string chfmt = "Packed"; @@ -320,7 +320,7 @@ int Decode::Decode::decode_audio() { fft_data[i] = fft_data_mem + i * size_t(e_fft_num); fft_spec[i] = fft_spec_mem + i * size_t(e_fft_num) * spectrum_size; char* index = fft_spec[i]; - for (int j = 0; j < e_fft_num; j++, index += spectrum_size) { + for (int64_t j = 0; j < e_fft_num; j++, index += spectrum_size) { fft_data[i][j].init_data(spectrum_size, index); } } @@ -427,9 +427,9 @@ int Decode::Decode::decode_audio() { } if (vol_mode != 1) { if (nb_fft_sample > 0) { - int fft_index = fft_samp_num; + int64_t fft_index = fft_samp_num; if (fft_index < e_fft_num) { - if (fft_index + nb_fft_sample > e_fft_num)nb_fft_sample = e_fft_num - fft_index; + if (fft_index + nb_fft_sample > e_fft_num)nb_fft_sample = static_cast(e_fft_num - fft_index); fft_samp_num += nb_fft_sample; pool.execute(std::bind(&Decode::Decode::FFT, this, fft_data, normalized_samples, fft_index, nb_fft_sample)); } @@ -514,11 +514,11 @@ int Decode::Decode::get_return() { return return_val; } -int Decode::Decode::get_fft_samp_num() +int64_t Decode::Decode::get_fft_samp_num() { return fft_samp_num; } -int Decode::Decode::get_milisec() +int64_t Decode::Decode::get_milisec() { return milisec; } @@ -627,7 +627,7 @@ int Decode::Decode::normalize(uint8_t ** const &audiodata, double **&normalized_ transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; case 64: - transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); + transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; default: break; @@ -654,7 +654,7 @@ int Decode::Decode::normalize(uint8_t ** const &audiodata, double **&normalized_ transfer_audio_data_packed(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; case 64: - transfer_audio_data_packed(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); + transfer_audio_data_packed(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; default: break; @@ -719,9 +719,9 @@ int Decode::Decode::FD8(double * inseq, DataStruct::node * outseq) addx = 10.0 * log10(addx); addx -= MaxdB; addx *= c_min_db; - addx += 127.0; - addx = std::min(addx, 127.0); - addx = std::max(addx, -128.0); + addx += static_cast(std::numeric_limits::max()); + addx = std::min(addx, static_cast(std::numeric_limits::max())); + addx = std::max(addx, static_cast(std::numeric_limits::min())); addx = round(addx); out[i] = static_cast(addx); } @@ -758,8 +758,8 @@ int Decode::Decode_SSE::FD8(double * inseq, DataStruct::node * outseq) __m128d const10 = _mm_set1_pd(10.0); __m128d const_maxdb = _mm_set1_pd(MaxdB); __m128d const_mindb = _mm_set1_pd(c_min_db); - __m128d const127 = _mm_set1_pd(127.0); - __m128d constm128 = _mm_set1_pd(-128.0); + __m128d const127 = _mm_set1_pd(static_cast(std::numeric_limits::max())); + __m128d constm128 = _mm_set1_pd(static_cast(std::numeric_limits::min())); for (int i = 0; i < fft_num / 4; i++) { __m128d seq1 = _mm_load_pd(inseq); __m128d seq2 = _mm_load_pd(inseq + 2); @@ -812,8 +812,8 @@ int Decode::Decode_AVX::FD8(double * inseq, DataStruct::node * outseq) __m256d const10 = _mm256_set1_pd(10.0); __m256d const_maxdb = _mm256_set1_pd(MaxdB); __m256d const_mindb = _mm256_set1_pd(c_min_db); - __m256d const127 = _mm256_set1_pd(127.0); - __m256d constm128 = _mm256_set1_pd(-128.0); + __m256d const127 = _mm256_set1_pd(static_cast(std::numeric_limits::max())); // 127 + __m256d constm128 = _mm256_set1_pd(static_cast(std::numeric_limits::min())); // -128 for (int i = 0; i < fft_num / 8; i++) { __m256d seq1 = _mm256_load_pd(inseq); __m256d seq2 = _mm256_load_pd(inseq + 4); @@ -858,7 +858,8 @@ inline int Decode::Decode_AVX2::transfer_audio_data_planar_float(uint8_t** const int threshold = nb_to_norm / 8; int remainder = nb_to_norm % 8; float* tempf = reinterpret_cast(audiodata[ch]); - double* tempd = normalized_samples[ch] + index; + double* tempd = nullptr; + if (normalized_samples)tempd = normalized_samples[ch] + index; double* temp_seq = seqs[ch] + index2; for (int i = 0; i < threshold; i++) { __m256 temp256 = _mm256_load_ps(tempf); @@ -1297,7 +1298,7 @@ inline int Decode::Decode_AVX2::transfer_audio_data_packed_int32(uint8_t** const int ch = 0; int* tempi32 = reinterpret_cast(audiodata[0]); __m256i* temp256 = reinterpret_cast<__m256i*>(audiodata[0]); - __m256d const32 = _mm256_set1_pd(1.0 / 2147483647.0); + __m256d const32 = _mm256_set1_pd(1.0 / static_cast(std::numeric_limits::max())); int avxlength = nb_samples * channels / 8; int avx_last = (nb_samples * channels) % 8; int nb_to_norm = std::max(length - nb_last, 0); @@ -1394,14 +1395,14 @@ inline int Decode::Decode_AVX2::transfer_audio_data_packed_int32(uint8_t** const } for (int i = 0; i < avx_last; i++) { if (index < length) { - normalized_samples[ch++][index] = static_cast(*(tempi32++)) / 2147483647.0; + normalized_samples[ch++][index] = static_cast(*(tempi32++)) / static_cast(std::numeric_limits::max()); if (ch == channels) { ch = 0; index++; } } else { - seqs[ch++][index2] = static_cast(*(tempi32++)) / 2147483647.0; + seqs[ch++][index2] = static_cast(*(tempi32++)) / static_cast(std::numeric_limits::max()); if (ch == channels) { ch = 0; index2++; @@ -1442,7 +1443,7 @@ int Decode::Decode_AVX2::normalize(uint8_t** const& audiodata, double**& normali transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; case 64: - transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); + transfer_audio_data_planar(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; default: break; @@ -1469,7 +1470,7 @@ int Decode::Decode_AVX2::normalize(uint8_t** const& audiodata, double**& normali transfer_audio_data_packed_int32(audiodata, normalized_samples, seqs, nb_last, length, nb_samples); break; case 64: - transfer_audio_data_packed(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); + transfer_audio_data_packed(audiodata, normalized_samples, seqs, nb_last, nb_last_next, length); break; default: break; @@ -1538,8 +1539,8 @@ int Decode::Decode_AVX2::FD8(double * inseq, DataStruct::node * outseq) __m256d const10 = _mm256_set1_pd(10.0); __m256d const_maxdb = _mm256_set1_pd(MaxdB); __m256d const_mindb = _mm256_set1_pd(c_min_db); - __m256d const127 = _mm256_set1_pd(127.0); - __m256d constm128 = _mm256_set1_pd(-128.0); + __m256d const127 = _mm256_set1_pd(static_cast(std::numeric_limits::max())); // 127 + __m256d constm128 = _mm256_set1_pd(static_cast(std::numeric_limits::min())); // -128 for (int i = 0; i < fft_num / 8; i++) { __m256d seq1 = _mm256_load_pd(inseq); __m256d seq2 = _mm256_load_pd(inseq + 4); diff --git a/BDMatchCore/headers/BDMatchCore.h b/BDMatchCore/headers/BDMatchCore.h index 5a6eaa8..c303458 100644 --- a/BDMatchCore/headers/BDMatchCore.h +++ b/BDMatchCore/headers/BDMatchCore.h @@ -6,7 +6,7 @@ #include "language_pack.h" typedef void(*prog_func)(int, double); -typedef void(*feedback_func)(const char*, const long long len); +typedef void(*feedback_func)(const char*, const int64_t len); enum class Procedure { Decode = 4, Match = 6 }; @@ -25,8 +25,8 @@ class BDMatchCore { int match_2(const char* output_path0); int clear_match(); size_t get_nb_timeline(); - int get_timeline(const int& index, const Match::Timeline_Time_Type& type); - int get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type); + int64_t get_timeline(const int& index, const Match::Timeline_Time_Type& type); + int64_t get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type); char** get_decode_spec(const Decode::Decode_File& file); int start_process(); int stop_process(); diff --git a/BDMatchCore/headers/datastruct.h b/BDMatchCore/headers/datastruct.h index dedea64..96aba12 100644 --- a/BDMatchCore/headers/datastruct.h +++ b/BDMatchCore/headers/datastruct.h @@ -1,9 +1,11 @@ #pragma once #include "targetver.h" +#include +#include +#ifndef _EXPORT_ namespace DataStruct { - class node { public: @@ -17,10 +19,10 @@ namespace DataStruct { private: char *data = nullptr; int count = 0; - int sumval = -2147483647; + int sumval = std::numeric_limits::min(); }; - } +#endif namespace Decode { enum class Decode_File { TV_Decode, BD_Decode }; diff --git a/BDMatchCore/headers/decoder.h b/BDMatchCore/headers/decoder.h index 45924b0..c983a8b 100644 --- a/BDMatchCore/headers/decoder.h +++ b/BDMatchCore/headers/decoder.h @@ -3,7 +3,6 @@ #include #include #include -#include #include "language_pack.h" extern"C" { #include "libavcodec/avcodec.h" @@ -56,8 +55,8 @@ namespace Decode { std::string get_feedback(); std::string get_file_name(); int get_return(); - int get_fft_samp_num(); - int get_milisec(); + int64_t get_fft_samp_num(); + int64_t get_milisec(); int get_channels(); int get_samp_rate(); int get_fft_num(); @@ -100,13 +99,13 @@ namespace Decode { std::string file_name; int out_bit_depth = 0; int audio_stream = 0; - int milisec = 0; - int fft_samp_num = 0; - int e_fft_num = 0; + int64_t milisec = 0; + int64_t fft_samp_num = 0; + int64_t e_fft_num = 0; int channels = 0;//audio channels int data_channels = 0;//audio data channels int real_ch = 0;//Planar: channels, Linear: 1 - long long start_time = 0; + int64_t start_time = 0; bool audio_only = false; //sample info int sample_type = 0; diff --git a/BDMatchCore/headers/match.h b/BDMatchCore/headers/match.h index 5d5bb1f..450f35a 100644 --- a/BDMatchCore/headers/match.h +++ b/BDMatchCore/headers/match.h @@ -18,21 +18,21 @@ namespace Match { class timeline { public: - timeline(int start0, int end0, bool iscom0, + timeline(const int64_t& start0, const int64_t& end0, const bool& iscom0, const std::string &head0, const std::string &text0); - int start(); - int end(); - int duration(); + int64_t start(); + int64_t end(); + int64_t duration(); bool iscom(); std::string head(); std::string former_text(); - int start(const int &start0); - int end(const int &end0); - int iscom(const bool&iscom0); - int head(std::string &head0); + int start(const int64_t& start0); + int end(const int64_t& end0); + int iscom(const bool& iscom0); + int head(std::string & head0); private: - int start_; - int end_; + int64_t start_; + int64_t end_; bool iscom_; std::string head_; std::string former_text_; @@ -42,31 +42,31 @@ namespace Match { { public: bdsearch(); - int reserve(const int &num); - int push(const int &time, const int &diff); - int read(const int &pos); - int find(const int &searchnum, const int &retype); + int reserve(const int& num); + int push(const int64_t& time, const int64_t& diff); + int64_t read(const size_t& pos); + int64_t find(const int& searchnum, const int& retype); int sort(); size_t size(); int clear(); private: - std::vector>bditem; + std::vector>bditem; }; class se_re { public: se_re(); - long long& operator[](const int &index); + int64_t& operator[](const int &index); se_re(se_re &in); int init(); private: - long long data[2] = { 922372036854775808,0 }; + int64_t data[2] = { std::numeric_limits::max(),0 }; }; struct debug_info {//debug info in matching double ave_index = 0.0, max_index = 0.0, diffa_consis = 0.0; - long long max_delta = 0, max_line = 0, nb_line = 0; + int64_t max_delta = 0, max_line = 0, nb_line = 0; }; class Match { @@ -76,27 +76,27 @@ namespace Match { int load_settings(const int &min_check_num0, const int &find_field0, const int &sub_offset0, const int &max_length0, const bool &fast_match0, const bool &debug_mode0, const prog_func &prog_single0 = nullptr); - int load_decode_info(node ** const &tv_fft_data0, node ** const &bd_fft_data0, - const int &tv_ch0, const int &bd_ch0, const int &tv_fft_samp_num0, const int &bd_fft_samp_num0, - const int &tv_milisec0, const int &bd_milisec0, const int &tv_samp_rate, - const std::string &tv_file_name0, const std::string &bd_file_name0, - const bool &bd_audio_only0); + int load_decode_info(node** const& tv_fft_data0, node** const& bd_fft_data0, + const int& tv_ch0, const int& bd_ch0, const int64_t& tv_fft_samp_num0, const int64_t& bd_fft_samp_num0, + const int64_t& tv_milisec0, const int64_t& bd_milisec0, const int& tv_samp_rate, + const std::string& tv_file_name0, const std::string& bd_file_name0, + const bool& bd_audio_only0); int load_sub(const std::string &sub_path0);//load subtitle file int match();//match ass lines int output(const std::string &output_path);//write and check results at specific address int output();//write and check results at auto address - long long get_nb_timeline();//return num of timeline - int get_timeline(const int& line, const Timeline_Time_Type& type);//return timeline info + int64_t get_nb_timeline();//return num of timeline + int64_t get_timeline(const int& line, const Timeline_Time_Type& type);//return timeline info std::string get_feedback();//return timeline info protected: int load_ass(const std::string& ass_path0);//load ass file int load_srt(const std::string& srt_path0);//load srt file - int add_timeline(const int &start, const int &end, const bool &iscom, - const std::string &header, const std::string &text);//add and check timeline + int add_timeline(const int64_t& start, const int64_t& end, const bool& iscom, + const std::string& header, const std::string& text);//add and check timeline std::string cs2time(const int &cs0); int time2cs(const std::string &time); - virtual int caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re); + virtual int caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re); debug_info deb_info;//debug info in matching prog_func prog_single = nullptr;//func_ptr for progress bar std::shared_ptr const keep_processing;//multithreading cancel token @@ -107,12 +107,12 @@ namespace Match { std::string tv_sub_text; std::string head, content; std::vector timeline_list; - long long nb_timeline = 0; + int64_t nb_timeline = 0; //decode info node** tv_fft_data = nullptr, ** bd_fft_data = nullptr; int tv_ch = 0, bd_ch = 0; - int tv_fft_samp_num = 0, bd_fft_samp_num = 0; - int tv_milisec = 0, bd_milisec = 0; + int64_t tv_fft_samp_num = 0, bd_fft_samp_num = 0; + int64_t tv_milisec = 0, bd_milisec = 0; std::string tv_file_name, bd_file_name; bool bd_audio_only = false; //settings of matching @@ -120,18 +120,18 @@ namespace Match { bool fast_match = false, debug_mode = false; //vars for searching bdsearch bd_se; - std::vector tv_time, bd_time; + std::vector tv_time, bd_time; int ch = 0; // num of audio channels - int interval = 1; //search interval - int overlap_interval = 1; //interval to judge overlap - int find_range = 10; + int64_t interval = 1; //search interval + int64_t overlap_interval = 1; //interval to judge overlap + int64_t find_range = 10; int fft_size = 256;//size of single fft data size_t nb_threads = 0, nb_per_task = 0, nb_tasks = 0;//parameters of multithreading int rightshift = 0; - int duration = 0; + int64_t duration = 0; double t2f = 1.0;//Time to Frequency double f2t = 1.0;//Frequency to Time - long long diffa[3];//Not to initialize and no need to make atomic + int64_t diffa[3];//Not to initialize and no need to make atomic se_re *search_result = nullptr; std::string feedback; }; @@ -140,15 +140,15 @@ namespace Match { public: Match_SSE(language_pack& lang_pack0, std::shared_ptr keep_processing0 = nullptr) :Match(lang_pack0, keep_processing0) {} - int caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re); + int caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re); }; class Match_AVX2 : public Match { public: Match_AVX2(language_pack& lang_pack0, std::shared_ptr keep_processing0 = nullptr) :Match(lang_pack0, keep_processing0) {} - int caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re); + int caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re); }; } \ No newline at end of file diff --git a/BDMatchCore/include/BDMatchCoreAPI.h b/BDMatchCore/include/BDMatchCoreAPI.h index f30ff26..a3d3637 100644 --- a/BDMatchCore/include/BDMatchCoreAPI.h +++ b/BDMatchCore/include/BDMatchCoreAPI.h @@ -1,4 +1,7 @@ #pragma once + +#define _EXPORT_ + // No need for platform other than Windows #include #include "headers/datastruct.h" @@ -9,7 +12,7 @@ #endif typedef void(__stdcall* prog_func)(int, double); -typedef void(__stdcall* feedback_func)(const char*, const long long len); +typedef void(__stdcall* feedback_func)(const char*, const int64_t len); namespace BDMatchCoreAPI { BDMatchCore_API int new_BDMatchCore(); @@ -24,8 +27,8 @@ namespace BDMatchCoreAPI { BDMatchCore_API int match_2(const char* output_path); BDMatchCore_API int clear_match(); BDMatchCore_API size_t get_nb_timeline(); - BDMatchCore_API int get_timeline(const int& index, const Match::Timeline_Time_Type& type); - BDMatchCore_API int get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type); + BDMatchCore_API int64_t get_timeline(const int& index, const Match::Timeline_Time_Type& type); + BDMatchCore_API int64_t get_decode_info(const Decode::Decode_File& file, const Decode::Decode_Info& type); BDMatchCore_API char** get_decode_spec(const Decode::Decode_File& file); BDMatchCore_API int search_ISA_mode(); BDMatchCore_API const char* get_CPU_brand(); diff --git a/BDMatchCore/match.cpp b/BDMatchCore/match.cpp index 3c55d6e..f17841d 100644 --- a/BDMatchCore/match.cpp +++ b/BDMatchCore/match.cpp @@ -13,7 +13,7 @@ using namespace DataStruct; using std::min; using std::max; -Match::timeline::timeline(int start0, int end0, bool iscom0, +Match::timeline::timeline(const int64_t& start0, const int64_t& end0, const bool& iscom0, const std::string &head0, const std::string &text0) { start_ = start0; @@ -22,15 +22,15 @@ Match::timeline::timeline(int start0, int end0, bool iscom0, head_ = head0; former_text_ = text0; } -int Match::timeline::start() +int64_t Match::timeline::start() { return start_; } -int Match::timeline::end() +int64_t Match::timeline::end() { return end_; } -int Match::timeline::duration() +int64_t Match::timeline::duration() { return end_ - start_; } @@ -46,12 +46,12 @@ std::string Match::timeline::former_text() { return former_text_; } -int Match::timeline::start(const int &start0) +int Match::timeline::start(const int64_t&start0) { start_ = start0; return 0; } -int Match::timeline::end(const int &end0) +int Match::timeline::end(const int64_t&end0) { end_ = end0; return 0; @@ -75,16 +75,16 @@ int Match::bdsearch::reserve(const int &num) bditem.reserve(num); return 0; } -int Match::bdsearch::push(const int &time, const int &diff) +int Match::bdsearch::push(const int64_t& time, const int64_t& diff) { - bditem.emplace_back(std::array({ time, diff })); + bditem.emplace_back(std::array({ time, diff })); return 0; } -int Match::bdsearch::read(const int &pos) +int64_t Match::bdsearch::read(const size_t &pos) { return bditem[pos][0]; } -int Match::bdsearch::find(const int &searchnum, const int &retype) +int64_t Match::bdsearch::find(const int &searchnum, const int &retype) { int index = 0; for (auto &i : bditem) { @@ -99,7 +99,7 @@ int Match::bdsearch::find(const int &searchnum, const int &retype) } int Match::bdsearch::sort() { - std::sort(bditem.begin(), bditem.end(), [](std::array &a, std::array&b) { + std::sort(bditem.begin(), bditem.end(), [](std::array &a, std::array&b) { return a[1] < b[1]; }); return 0; @@ -118,7 +118,7 @@ int Match::bdsearch::clear() Match::se_re::se_re() { } -long long& Match::se_re::operator[](const int & index) +int64_t& Match::se_re::operator[](const int & index) { return data[index]; } @@ -160,8 +160,8 @@ int Match::Match::load_settings(const int & min_check_num0, const int & find_fie } int Match::Match::load_decode_info(node ** const & tv_fft_data0, node ** const & bd_fft_data0, - const int & tv_ch0, const int & bd_ch0, const int & tv_fft_samp_num0, const int & bd_fft_samp_num0, - const int & tv_milisec0, const int & bd_milisec0, const int & tv_samp_rate, + const int & tv_ch0, const int & bd_ch0, const int64_t& tv_fft_samp_num0, const int64_t& bd_fft_samp_num0, + const int64_t& tv_milisec0, const int64_t& bd_milisec0, const int & tv_samp_rate, const std::string & tv_file_name0, const std::string & bd_file_name0, const bool & bd_audio_only0) { @@ -195,7 +195,7 @@ int Match::Match::load_decode_info(node ** const & tv_fft_data0, node ** const & //multithreading parameters nb_threads = std::thread::hardware_concurrency(); nb_per_task = min(25ULL, 2ULL * find_range / nb_threads / interval); - nb_tasks = static_cast(ceil(static_cast(2 * find_range / interval) / static_cast(nb_per_task))); + nb_tasks = static_cast(ceil(static_cast(2LL * find_range / interval) / static_cast(nb_per_task))); //other info bd_audio_only = bd_audio_only0; return 0; @@ -338,7 +338,7 @@ int Match::Match::load_ass(const std::string &ass_path0) } return 0; } -int Match::Match::add_timeline(const int &start, const int &end, const bool &iscom, const std::string &header, const std::string &text) +int Match::Match::add_timeline(const int64_t& start, const int64_t& end, const bool& iscom, const std::string& header, const std::string& text) { timeline_list.emplace_back(timeline(start, end, iscom, header, text)); if (iscom) { @@ -378,7 +378,7 @@ int Match::Match::add_timeline(const int &start, const int &end, const bool &isc return -1; } int maxdb = -128; - for (int j = start; j <= end; j++) { + for (int64_t j = start; j <= end; j++) { if (tv_fft_data[0][j].maxv() > maxdb) { maxdb = tv_fft_data[0][j].maxv(); } @@ -393,7 +393,7 @@ int Match::Match::add_timeline(const int &start, const int &end, const bool &isc return -1; } bool existed = false; - int same_line; + int64_t same_line; for (same_line = 0; same_line < nb_timeline - 1; same_line++) { if (start == tv_time[same_line] && end == timeline_list[same_line].end()) { existed = true; @@ -420,32 +420,32 @@ int Match::Match::match() //search vars search_result = new se_re[nb_tasks]; //fast matching parameters - int offset = 0; int fivesec = 0; int lastlinetime = 0; + int64_t offset = 0; int64_t fivesec = 0; int64_t lastlinetime = 0; if (fast_match) { - fivesec = static_cast(500 * t2f); + fivesec = static_cast(500 * t2f); feedback += lang_pack.get_text(Lang_Type::Match_Sub, 9);//"\r\n信息:使用快速匹配。" } - for (long long i = 0; i < nb_timeline; i++) { + for (int64_t i = 0; i < nb_timeline; i++) { if (tv_time[i] >= 0) { - if (fast_match && offset && lastlinetime > fivesec && tv_time[i - 1] > 0 && labs(tv_time[i] - lastlinetime) < fivesec) { + if (fast_match && offset && lastlinetime > fivesec && tv_time[i - 1] > 0 && llabs(tv_time[i] - lastlinetime) < fivesec) { bd_time[i] = tv_time[i] + offset; lastlinetime = tv_time[i]; continue; } - int findstart = static_cast(tv_time[i] - find_range); - int findend = static_cast(tv_time[i] + find_range); + int64_t findstart = static_cast(tv_time[i] - find_range); + int64_t findend = static_cast(tv_time[i] + find_range); duration = timeline_list[i].duration(); - findstart = max(0, findstart); - findend = static_cast(min(bd_fft_samp_num - duration - 1, findend)); - int find_num = (findend - findstart) / interval; + findstart = max(static_cast(0), findstart); + findend = static_cast(min(bd_fft_samp_num - duration - 1, findend)); + int find_num = static_cast((findend - findstart) / interval); //初筛 - int tvmax[tvmax_num], tvmaxtime[tvmax_num]; - int tvmin[tvmin_num], tvmintime[tvmin_num]; + int tvmax[tvmax_num]; int64_t tvmaxtime[tvmax_num]; + int tvmin[tvmin_num]; int64_t tvmintime[tvmin_num]; for (auto& j : tvmax) j = -128 * fft_size; for (auto& j : tvmaxtime) j = 0; for (auto& j : tvmin) j = 128 * fft_size; for (auto& j : tvmintime) j = 0; - for (int j = 0; j <= duration; j++) { + for (int64_t j = 0; j <= duration; j++) { for (int k = 0; k < tvmax_num; k++) { if (tv_fft_data[0][j + tv_time[i]].sum() > tvmax[k] || j == 0) { for (int m = tvmax_num - 1; m > k; m--) { @@ -471,7 +471,7 @@ int Match::Match::match() } bd_se.clear(); for (int j = 0; j <= find_num; j++) { - int bdtimein = findstart + j * interval; + int64_t bdtimein = findstart + j * interval; int delta = 0; for (int k = 0; k < tvmax_num; k++) { delta += labs(bd_fft_data[0][bdtimein + tvmaxtime[k]].sum() - tvmax[k]); @@ -485,12 +485,12 @@ int Match::Match::match() } bd_se.sort(); //accurate match - diffa[0] = 922372036854775808; + diffa[0] = std::numeric_limits::max(); diffa[1] = 0; int min_check_num_cal = min_check_num; if (duration <= 75 * overlap_interval)min_check_num_cal = find_num; else if (fast_match)min_check_num_cal = min_check_num / 2 * 3; - int check_field = min_check_num_cal * interval; + int64_t check_field = min_check_num_cal * interval; diffa[2] = min_check_num_cal; se_re *se_re_ptr = search_result; for (size_t j = 0; j < nb_tasks; j++) { @@ -503,10 +503,10 @@ int Match::Match::match() pool.execute_batch(tasks); pool.wait(); tasks.clear(); - long long minsum = 922372036854775808; + int64_t minsum = std::numeric_limits::max(); int besttime = 0; for (size_t j = 0; j < nb_tasks; j++) { - long long sum = search_result[j][0]; + int64_t sum = search_result[j][0]; if (sum < minsum) { besttime = static_cast(search_result[j][1]); minsum = sum; @@ -522,7 +522,7 @@ int Match::Match::match() int fftindex = static_cast(time2cs(time) * t2f); fftindex += 1; volatile int pos1 = bd_se.find(fftindex, 0); - volatile long long lsfeedback = -1; + volatile int64_t lsfeedback = -1; volatile int task_id = static_cast(ceil(pos1 / double(nb_per_task)) - 1.0); if (pos1 > 0)lsfeedback = search_result[task_id][0]; volatile std::string besttimestr2 = cs2time(search_result[task_id][1] * f2t); @@ -531,7 +531,7 @@ int Match::Match::match() //cal debug info if (debug_mode) { deb_info.nb_line++; - int delta1 = bd_se.find(besttime, 1); + int64_t delta1 = bd_se.find(besttime, 1); if (delta1 > deb_info.max_delta)deb_info.max_delta = delta1; feedback += lang_pack.get_text(Lang_Type::General, 0) + std::to_string(i + 1) + lang_pack.get_text(Lang_Type::General, 4) + std::to_string(delta1);//"\r\n i, delta" @@ -540,7 +540,7 @@ int Match::Match::match() + lang_pack.get_text(Lang_Type::General, 4) + std::to_string(diffa[0]);//", minsum, diffa[0]" double foundindex = bd_se.find(besttime, 0) / (double)find_num; deb_info.ave_index = deb_info.ave_index + foundindex; - if (foundindex > deb_info.max_index&&duration > 75 * interval) { + if (foundindex > deb_info.max_index && duration > 75 * interval) { deb_info.max_index = foundindex; deb_info.max_line = i + 1; } @@ -583,20 +583,20 @@ int Match::Match::output(const std::string &output_path) using std::vector, std::string, std::fstream, std::ios; feedback = ""; //check feedbacks - vectortime_diff(nb_timeline); + vectortime_diff(nb_timeline); vectorcheck_feedbacks(nb_timeline); - for (long long i = 0; i < nb_timeline; i++) { + for (int64_t i = 0; i < nb_timeline; i++) { if (tv_time[i] >= 0)time_diff.push_back(bd_time[i] - tv_time[i]); else if (tv_time[i] == -1)time_diff[i] = 0; - else time_diff[i] = time_diff[-static_cast(tv_time[i]) - 2]; + else time_diff[i] = time_diff[-static_cast(tv_time[i]) - 2]; } - for (long long i = 0; i < nb_timeline; i++) { + for (int64_t i = 0; i < nb_timeline; i++) { if (tv_time[i] == -1) { check_feedbacks[i] = -1; continue; }; if (tv_time[i] < 0) { - int line_num = -tv_time[i] - 2; + int64_t line_num = -tv_time[i] - 2; int check_feedback = check_feedbacks[line_num]; check_feedbacks[i] = check_feedback; if (check_feedback > 0) @@ -612,13 +612,13 @@ int Match::Match::output(const std::string &output_path) temp = tv_time[i] - tv_time[i - 1] >= 0 ? 1 : -1; temp *= bd_time[i] - bd_time[i - 1] >= 0 ? 1 : -1; if (temp < 0) check = 1; - if (labs(time_diff[i] - time_diff[i - 1]) > allowed_offset * interval) check2 = false; + if (llabs(time_diff[i] - time_diff[i - 1]) > allowed_offset * interval) check2 = false; } if (check == 0 && i < nb_timeline - 1 && tv_time[i + 1] != -1) { temp = tv_time[i + 1] - tv_time[i] >= 0 ? 1 : -1; temp *= bd_time[i + 1] - bd_time[i] >= 0 ? 1 : -1; if (temp < 0) check = 2; - if (labs(time_diff[i] - time_diff[i + 1]) > allowed_offset * interval && !check2) check = 3; + if (llabs(time_diff[i] - time_diff[i + 1]) > allowed_offset * interval && !check2) check = 3; } switch (check) { case 1: @@ -637,10 +637,10 @@ int Match::Match::output(const std::string &output_path) check_feedbacks[i] = check; } //write subtitle - for (long long i = 0; i < nb_timeline; i++) { + for (int64_t i = 0; i < nb_timeline; i++) { if (tv_time[i] != -1) { if (tv_time[i] >= 0) { - int duration = timeline_list[i].duration(); + int64_t duration = timeline_list[i].duration(); timeline_list[i].start(bd_time[i]); timeline_list[i].end(bd_time[i] + duration); if (i < nb_timeline - 1 && timeline_list[i].end() > bd_time[i + 1] @@ -652,8 +652,8 @@ int Match::Match::output(const std::string &output_path) } } else { - timeline_list[i].start(timeline_list[-static_cast(tv_time[i]) - 2].start()); - timeline_list[i].end(timeline_list[-static_cast(tv_time[i]) - 2].end()); + timeline_list[i].start(timeline_list[-static_cast(tv_time[i]) - 2].start()); + timeline_list[i].end(timeline_list[-static_cast(tv_time[i]) - 2].end()); } int start = static_cast(round(static_cast(timeline_list[i].start()) * f2t)); int end = static_cast(round(static_cast(timeline_list[i].end()) * f2t)); @@ -708,11 +708,11 @@ int Match::Match::output() return 0; } -long long Match::Match::get_nb_timeline() +int64_t Match::Match::get_nb_timeline() { return nb_timeline; } -int Match::Match::get_timeline(const int& line, const Timeline_Time_Type& type) +int64_t Match::Match::get_timeline(const int& line, const Timeline_Time_Type& type) { switch (type) { case Timeline_Time_Type::Start_Time: @@ -791,28 +791,28 @@ int Match::Match::time2cs(const std::string &time) return cs; } -int Match::Match::caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re) +int Match::Match::caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re) { se_re feedback; if (diffa[2] <= 0) { *re = feedback; return -1; } - long long sum = 0; + int64_t sum = 0; char* tvdata[8], * bddata[8]; - for (int seindex = se_start; seindex < se_end; seindex++) { - int bd_start = bd_se.read(seindex); + for (size_t seindex = se_start; seindex < se_end; seindex++) { + int64_t bd_start = bd_se.read(seindex); sum = 0; for (int i = 0; i < ch; i++) { tvdata[i] = tv_fft_data[i][tv_start].getdata(); bddata[i] = bd_fft_data[i][bd_start].getdata(); } - for (int i = 0; i <= duration; i++) { + for (int64_t i = 0; i <= duration; i++) { for (int j = 0; j < ch; j++) { for (int k = 0; k < fft_size; k++) { - sum += llabs(static_cast(tvdata[j][k]) - static_cast(bddata[j][k])) - * (static_cast(tvdata[j][k]) + 129LL); + sum += llabs(static_cast(tvdata[j][k]) - static_cast(bddata[j][k])) + * (static_cast(tvdata[j][k]) + 129LL); } tvdata[j] += fft_size; bddata[j] += fft_size; @@ -829,7 +829,7 @@ int Match::Match::caldiff(const int tv_start, const int se_start, const int se_e diffa[1] = feedback[1]; diffa[2] = min_check_num; } - else if (labs(bd_start - static_cast(diffa[1])) <= check_field) diffa[2]--; + else if (llabs(bd_start - diffa[1]) <= check_field) diffa[2]--; if (diffa[2] <= 0) { *re = feedback; return -1; @@ -838,28 +838,28 @@ int Match::Match::caldiff(const int tv_start, const int se_start, const int se_e *re = feedback; return 0; } -int Match::Match_SSE::caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re) +int Match::Match_SSE::caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re) { se_re feedback; if (diffa[2] <= 0) { *re = feedback; return -1; } - long long sum = 0; + int64_t sum = 0; int vectornum = fft_size / 8; char* tvdata[8], * bddata[8]; __m128i tvvector, bdvector, difvector[2]; __m128i sumvector[2] = { _mm_setzero_si128(),_mm_setzero_si128() }; const __m128i w1vector = _mm_set1_epi16(129); - for (int seindex = se_start; seindex < se_end; seindex++) { - int bd_start = bd_se.read(seindex); + for (size_t seindex = se_start; seindex < se_end; seindex++) { + int64_t bd_start = bd_se.read(seindex); sum = 0; for (int i = 0; i < ch; i++) { tvdata[i] = tv_fft_data[i][tv_start].getdata(); bddata[i] = bd_fft_data[i][bd_start].getdata(); } - for (int i = 0; i <= duration; i++) { + for (int64_t i = 0; i <= duration; i++) { sumvector[0] = _mm_setzero_si128(); sumvector[1] = _mm_setzero_si128(); for (int j = 0; j < ch; j++) { @@ -878,8 +878,8 @@ int Match::Match_SSE::caldiff(const int tv_start, const int se_start, const int } sumvector[0] = _mm_add_epi32(sumvector[0], sumvector[1]); sumvector[0] = _mm_add_epi32(_mm_srli_epi64(sumvector[0], 32), sumvector[0]); - sum += static_cast(_mm_extract_epi32(sumvector[0], 0)) + - static_cast(_mm_extract_epi32(sumvector[0], 2)); + sum += static_cast(_mm_extract_epi32(sumvector[0], 0)) + + static_cast(_mm_extract_epi32(sumvector[0], 2)); if (sum > diffa[0])break; } if (sum < feedback[0]) @@ -892,7 +892,7 @@ int Match::Match_SSE::caldiff(const int tv_start, const int se_start, const int diffa[1] = feedback[1]; diffa[2] = min_check_num; } - else if (labs(bd_start - static_cast(diffa[1])) <= check_field) diffa[2]--; + else if (llabs(bd_start - diffa[1]) <= check_field) diffa[2]--; if (diffa[2] <= 0) { *re = feedback; return -1; @@ -901,29 +901,29 @@ int Match::Match_SSE::caldiff(const int tv_start, const int se_start, const int *re = feedback; return 0; } -int Match::Match_AVX2::caldiff(const int tv_start, const int se_start, const int se_end, const int min_check_num, - const int check_field, se_re *re) +int Match::Match_AVX2::caldiff(const int64_t tv_start, const size_t se_start, const size_t se_end, const int min_check_num, + const int64_t check_field, se_re* re) { se_re feedback; if (diffa[2] <= 0) { *re = feedback; return -1; } - long long sum = 0; + int64_t sum = 0; int vectornum = fft_size / 16; __m128i* tvdata[8], * bddata[8]; __m256i tvvector, bdvector, difvector[2]; __m256i sumvector[2] = { _mm256_setzero_si256(),_mm256_setzero_si256() }; __m128i sumvector8[2]; const __m256i w1vector = _mm256_set1_epi16(129); - for (int seindex = se_start; seindex < se_end; seindex++) { - int bd_start = bd_se.read(seindex); + for (size_t seindex = se_start; seindex < se_end; seindex++) { + int64_t bd_start = bd_se.read(seindex); sum = 0; for (int i = 0; i < ch; i++) { tvdata[i] = reinterpret_cast<__m128i*>(tv_fft_data[i][tv_start].getdata()); bddata[i] = reinterpret_cast<__m128i*>(bd_fft_data[i][bd_start].getdata()); } - for (int i = 0; i <= duration; i++) { + for (int64_t i = 0; i <= duration; i++) { sumvector[0] = _mm256_setzero_si256(); sumvector[1] = _mm256_setzero_si256(); for (int j = 0; j < ch; j++) { @@ -959,7 +959,7 @@ int Match::Match_AVX2::caldiff(const int tv_start, const int se_start, const int diffa[1] = feedback[1]; diffa[2] = min_check_num; } - else if (labs(bd_start - static_cast(diffa[1])) <= check_field) diffa[2]--; + else if (llabs(bd_start - diffa[1]) <= check_field) diffa[2]--; if (diffa[2] <= 0) { *re = feedback; return -1;