diff --git a/include/MagickUtilities.h b/include/MagickUtilities.h index f3b7ea12..74365904 100644 --- a/include/MagickUtilities.h +++ b/include/MagickUtilities.h @@ -52,9 +52,9 @@ // IM6: list // (both have the push_back() method which is all we use) #if NEW_MAGICK - #define MAGICK_DRAWABLE vector + #define MAGICK_DRAWABLE std::vector #else - #define MAGICK_DRAWABLE list + #define MAGICK_DRAWABLE std::list #endif #endif diff --git a/include/OpenMPUtilities.h b/include/OpenMPUtilities.h index 2dceb5bf..9810d636 100644 --- a/include/OpenMPUtilities.h +++ b/include/OpenMPUtilities.h @@ -38,8 +38,8 @@ #include "Settings.h" // Calculate the # of OpenMP Threads to allow -#define OPEN_MP_NUM_PROCESSORS (min(omp_get_num_procs(), max(2, openshot::Settings::Instance()->OMP_THREADS) )) -#define FF_NUM_PROCESSORS (min(omp_get_num_procs(), max(2, openshot::Settings::Instance()->FF_THREADS) )) +#define OPEN_MP_NUM_PROCESSORS (std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->OMP_THREADS) )) +#define FF_NUM_PROCESSORS (std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->FF_THREADS) )) #endif diff --git a/include/Qt/AudioPlaybackThread.h b/include/Qt/AudioPlaybackThread.h index 94abf806..54bd490b 100644 --- a/include/Qt/AudioPlaybackThread.h +++ b/include/Qt/AudioPlaybackThread.h @@ -69,10 +69,10 @@ namespace openshot public: /// Error found during JUCE initialise method - string initialise_error; + std::string initialise_error; /// List of valid audio device names - vector audio_device_names; + std::vector audio_device_names; /// Override with no channels and no preferred audio device static AudioDeviceManagerSingleton * Instance(); @@ -134,10 +134,10 @@ namespace openshot int getSpeed() const { if (source) return source->getSpeed(); else return 1; } /// Get Audio Error (if any) - string getError() { return AudioDeviceManagerSingleton::Instance()->initialise_error; } + std::string getError() { return AudioDeviceManagerSingleton::Instance()->initialise_error; } /// Get Audio Device Names (if any) - vector getAudioDeviceNames() { return AudioDeviceManagerSingleton::Instance()->audio_device_names; }; + std::vector getAudioDeviceNames() { return AudioDeviceManagerSingleton::Instance()->audio_device_names; }; friend class PlayerPrivate; friend class QtPlayer; diff --git a/include/Timeline.h b/include/Timeline.h index e1dcb349..2ff03d91 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -238,7 +238,7 @@ namespace openshot { void Close(); /// Return the list of effects on the timeline - list Effects() { return effects; }; + std::list Effects() { return effects; }; /// Get the cache object used by this reader CacheBase* GetCache() { return final_cache; }; diff --git a/src/ChunkReader.cpp b/src/ChunkReader.cpp index 809ce714..983f8d58 100644 --- a/src/ChunkReader.cpp +++ b/src/ChunkReader.cpp @@ -65,7 +65,7 @@ void ChunkReader::load_json() std::stringstream json_string; // Read the JSON file - ifstream myfile (json_path.c_str()); + std::ifstream myfile (json_path.c_str()); std::string line = ""; if (myfile.is_open()) { @@ -222,7 +222,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) // Close existing reader (if needed) if (local_reader) { - cout << "Close READER" << endl; + std::cout << "Close READER" << std::endl; // Close and delete old reader local_reader->Close(); delete local_reader; @@ -230,7 +230,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) try { - cout << "Load READER: " << chunk_video_path << endl; + std::cout << "Load READER: " << chunk_video_path << std::endl; // Load new FFmpegReader local_reader = new FFmpegReader(chunk_video_path); local_reader->Open(); // open reader diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 65015893..e3cf351d 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -293,7 +293,7 @@ void FFmpegReader::Open() { retry_decode_open = 0; // Set number of threads equal to number of processors (not to exceed 16) - pCodecCtx->thread_count = min(FF_NUM_PROCESSORS, 16); + pCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16); if (pCodec == NULL) { throw InvalidCodec("A valid video codec could not be found for this file.", path); @@ -528,7 +528,7 @@ void FFmpegReader::Open() { aCodecCtx = AV_GET_CODEC_CONTEXT(aStream, aCodec); // Set number of threads equal to number of processors (not to exceed 16) - aCodecCtx->thread_count = min(FF_NUM_PROCESSORS, 16); + aCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16); if (aCodec == NULL) { throw InvalidCodec("A valid audio codec could not be found for this file.", path); @@ -1257,8 +1257,8 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) { // Best fit or Stretch scaling (based on max timeline size * scaling keyframes) float max_scale_x = parent->scale_x.GetMaxPoint().co.Y; float max_scale_y = parent->scale_y.GetMaxPoint().co.Y; - max_width = max(float(max_width), max_width * max_scale_x); - max_height = max(float(max_height), max_height * max_scale_y); + max_width = std::max(float(max_width), max_width * max_scale_x); + max_height = std::max(float(max_height), max_height * max_scale_y); } else if (parent->scale == SCALE_CROP) { // Cropping scale mode (based on max timeline size * cropped size * scaling keyframes) @@ -1270,11 +1270,11 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) { max_height * max_scale_y); // respect aspect ratio if (width_size.width() >= max_width && width_size.height() >= max_height) { - max_width = max(max_width, width_size.width()); - max_height = max(max_height, width_size.height()); + max_width = std::max(max_width, width_size.width()); + max_height = std::max(max_height, width_size.height()); } else { - max_width = max(max_width, height_size.width()); - max_height = max(max_height, height_size.height()); + max_width = std::max(max_width, height_size.width()); + max_height = std::max(max_height, height_size.height()); } } else { @@ -1716,7 +1716,7 @@ void FFmpegReader::Seek(int64_t requested_frame) { seek_count++; // If seeking near frame 1, we need to close and re-open the file (this is more reliable than seeking) - int buffer_amount = max(OPEN_MP_NUM_PROCESSORS, 8); + int buffer_amount = std::max(OPEN_MP_NUM_PROCESSORS, 8); if (requested_frame - buffer_amount < 20) { // Close and re-open file (basically seeking to frame 1) Close(); @@ -1828,7 +1828,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) { if (video_pts_offset == 99999) // Has the offset been set yet? { // Find the difference between PTS and frame number (no more than 10 timebase units allowed) - video_pts_offset = 0 - max(GetVideoPTS(), (int64_t) info.video_timebase.ToInt() * 10); + video_pts_offset = 0 - std::max(GetVideoPTS(), (int64_t) info.video_timebase.ToInt() * 10); // debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Video)", "video_pts_offset", video_pts_offset, "is_video", is_video); @@ -1838,7 +1838,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) { if (audio_pts_offset == 99999) // Has the offset been set yet? { // Find the difference between PTS and frame number (no more than 10 timebase units allowed) - audio_pts_offset = 0 - max(packet->pts, (int64_t) info.audio_timebase.ToInt() * 10); + audio_pts_offset = 0 - std::max(packet->pts, (int64_t) info.audio_timebase.ToInt() * 10); // debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Audio)", "audio_pts_offset", audio_pts_offset, "is_video", is_video); diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 1a4628df..1dd1364d 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -420,29 +420,29 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va #if (LIBAVCODEC_VERSION_MAJOR >= 58) case AV_CODEC_ID_AV1 : c->bit_rate = 0; - av_opt_set_int(c->priv_data, "crf", min(stoi(value),63), 0); + av_opt_set_int(c->priv_data, "crf", std::min(stoi(value),63), 0); break; #endif case AV_CODEC_ID_VP8 : c->bit_rate = 10000000; - av_opt_set_int(c->priv_data, "crf", max(min(stoi(value), 63), 4), 0); // 4-63 + av_opt_set_int(c->priv_data, "crf", std::max(std::min(stoi(value), 63), 4), 0); // 4-63 break; case AV_CODEC_ID_VP9 : c->bit_rate = 0; // Must be zero! - av_opt_set_int(c->priv_data, "crf", min(stoi(value), 63), 0); // 0-63 + av_opt_set_int(c->priv_data, "crf", std::min(stoi(value), 63), 0); // 0-63 if (stoi(value) == 0) { av_opt_set(c->priv_data, "preset", "veryslow", 0); av_opt_set_int(c->priv_data, "lossless", 1, 0); } break; case AV_CODEC_ID_H264 : - av_opt_set_int(c->priv_data, "crf", min(stoi(value), 51), 0); // 0-51 + av_opt_set_int(c->priv_data, "crf", std::min(stoi(value), 51), 0); // 0-51 if (stoi(value) == 0) { av_opt_set(c->priv_data, "preset", "veryslow", 0); } break; case AV_CODEC_ID_H265 : - av_opt_set_int(c->priv_data, "crf", min(stoi(value), 51), 0); // 0-51 + av_opt_set_int(c->priv_data, "crf", std::min(stoi(value), 51), 0); // 0-51 if (stoi(value) == 0) { av_opt_set(c->priv_data, "preset", "veryslow", 0); av_opt_set_int(c->priv_data, "lossless", 1, 0); @@ -1227,7 +1227,7 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) { AV_GET_CODEC_FROM_STREAM(st, audio_codec) // Set number of threads equal to number of processors (not to exceed 16) - audio_codec->thread_count = min(FF_NUM_PROCESSORS, 16); + audio_codec->thread_count = std::min(FF_NUM_PROCESSORS, 16); // Find the audio encoder codec = avcodec_find_encoder_by_name(info.acodec.c_str()); @@ -1298,7 +1298,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { AV_GET_CODEC_FROM_STREAM(st, video_codec) // Set number of threads equal to number of processors (not to exceed 16) - video_codec->thread_count = min(FF_NUM_PROCESSORS, 16); + video_codec->thread_count = std::min(FF_NUM_PROCESSORS, 16); #if IS_FFMPEG_3_2 if (hw_en_on && hw_en_supported) { @@ -1928,10 +1928,10 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra if (ret < 0 ) { ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet (Frame not sent)"); if (ret == AVERROR(EAGAIN) ) { - cerr << "Frame EAGAIN" << "\n"; + std::cerr << "Frame EAGAIN" << "\n"; } if (ret == AVERROR_EOF ) { - cerr << "Frame AVERROR_EOF" << "\n"; + std::cerr << "Frame AVERROR_EOF" << "\n"; } avcodec_send_frame(video_codec, NULL); } @@ -1955,10 +1955,10 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra // Write video packet (older than FFmpeg 3.2) error_code = avcodec_encode_video2(video_codec, &pkt, frame_final, &got_packet_ptr); if (error_code != 0) { - cerr << "Frame AVERROR_EOF" << "\n"; + std::cerr << "Frame AVERROR_EOF" << "\n"; } if (got_packet_ptr == 0) { - cerr << "Frame gotpacket error" << "\n"; + std::cerr << "Frame gotpacket error" << "\n"; } #else // Write video packet (even older versions of FFmpeg) diff --git a/src/Qt/PlayerDemo.cpp b/src/Qt/PlayerDemo.cpp index 110b69dc..9b369b6d 100644 --- a/src/Qt/PlayerDemo.cpp +++ b/src/Qt/PlayerDemo.cpp @@ -98,7 +98,7 @@ void PlayerDemo::keyPressEvent(QKeyEvent *event) } else if (event->key() == Qt::Key_J) { - cout << "BACKWARD" << player->Speed() - 1 << endl; + std::cout << "BACKWARD" << player->Speed() - 1 << std::endl; if (player->Speed() - 1 != 0) player->Speed(player->Speed() - 1); else @@ -108,7 +108,7 @@ void PlayerDemo::keyPressEvent(QKeyEvent *event) player->Play(); } else if (event->key() == Qt::Key_L) { - cout << "FORWARD" << player->Speed() + 1 << endl; + std::cout << "FORWARD" << player->Speed() + 1 << std::endl; if (player->Speed() + 1 != 0) player->Speed(player->Speed() + 1); else @@ -119,19 +119,19 @@ void PlayerDemo::keyPressEvent(QKeyEvent *event) } else if (event->key() == Qt::Key_Left) { - cout << "FRAME STEP -1" << endl; + std::cout << "FRAME STEP -1" << std::endl; if (player->Speed() != 0) player->Speed(0); player->Seek(player->Position() - 1); } else if (event->key() == Qt::Key_Right) { - cout << "FRAME STEP +1" << endl; + std::cout << "FRAME STEP +1" << std::endl; if (player->Speed() != 0) player->Speed(0); player->Seek(player->Position() + 1); } else if (event->key() == Qt::Key_Escape) { - cout << "QUIT PLAYER" << endl; + std::cout << "QUIT PLAYER" << std::endl; QWidget *pWin = QApplication::activeWindow(); pWin->hide(); diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index 95a99536..929a417d 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -194,8 +194,8 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) // Best fit or Stretch scaling (based on max timeline size * scaling keyframes) float max_scale_x = parent->scale_x.GetMaxPoint().co.Y; float max_scale_y = parent->scale_y.GetMaxPoint().co.Y; - max_width = max(float(max_width), max_width * max_scale_x); - max_height = max(float(max_height), max_height * max_scale_y); + max_width = std::max(float(max_width), max_width * max_scale_x); + max_height = std::max(float(max_height), max_height * max_scale_y); } else if (parent->scale == SCALE_CROP) { // Cropping scale mode (based on max timeline size * cropped size * scaling keyframes) @@ -207,12 +207,12 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) max_height * max_scale_y); // respect aspect ratio if (width_size.width() >= max_width && width_size.height() >= max_height) { - max_width = max(max_width, width_size.width()); - max_height = max(max_height, width_size.height()); + max_width = std::max(max_width, width_size.width()); + max_height = std::max(max_height, width_size.height()); } else { - max_width = max(max_width, height_size.width()); - max_height = max(max_height, height_size.height()); + max_width = std::max(max_width, height_size.width()); + max_height = std::max(max_height, height_size.height()); } } else { diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 269066e9..7b656b36 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -1023,7 +1023,7 @@ Json::Value Timeline::JsonValue() { } // Load JSON string into this object -void Timeline::SetJson(string value) { +void Timeline::SetJson(std::string value) { // Get lock (prevent getting frames while this happens) const GenericScopedLock lock(getFrameCriticalSection); @@ -1557,7 +1557,7 @@ void Timeline::ClearAllCache() { void Timeline::SetMaxSize(int width, int height) { // Maintain aspect ratio regardless of what size is passed in QSize display_ratio_size = QSize(info.display_ratio.num * info.pixel_ratio.ToFloat(), info.display_ratio.den * info.pixel_ratio.ToFloat()); - QSize proposed_size = QSize(min(width, info.width), min(height, info.height)); + QSize proposed_size = QSize(std::min(width, info.width), std::min(height, info.height)); // Scale QSize up to proposed size display_ratio_size.scale(proposed_size, Qt::KeepAspectRatio);