From 552f7533fac35c6f41f1335c8fbcb97f3af9217a Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 15:13:40 -0400 Subject: [PATCH 01/36] Prefix all string types with std:: It confuses Doxygen if they're not prefixed, since they don't match the declarations in `Frame.h`. --- src/Frame.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index 49fb7358..dcc140e5 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -46,7 +46,7 @@ Frame::Frame() : number(1), pixel_ratio(1,1), channels(2), width(1), height(1), }; // Constructor - image only (48kHz audio silence) -Frame::Frame(int64_t number, int width, int height, string color) +Frame::Frame(int64_t number, int width, int height, std::string color) : number(number), pixel_ratio(1,1), channels(2), width(width), height(height), color(color), channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false), max_audio_sample(0) @@ -72,7 +72,7 @@ Frame::Frame(int64_t number, int samples, int channels) : }; // Constructor - image & audio -Frame::Frame(int64_t number, int width, int height, string color, int samples, int channels) +Frame::Frame(int64_t number, int width, int height, std::string color, int samples, int channels) : number(number), pixel_ratio(1,1), channels(channels), width(width), height(height), color(color), channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false), max_audio_sample(0) @@ -574,7 +574,7 @@ ChannelLayout Frame::ChannelsLayout() // Save the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG) -void Frame::Save(string path, float scale, string format, int quality) +void Frame::Save(std::string path, float scale, std::string format, int quality) { // Get preview image std::shared_ptr previewImage = GetImage(); @@ -605,8 +605,8 @@ void Frame::Save(string path, float scale, string format, int quality) } // Thumbnail the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG) -void Frame::Thumbnail(string path, int new_width, int new_height, string mask_path, string overlay_path, - string background_color, bool ignore_aspect, string format, int quality, float rotate) { +void Frame::Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path, + std::string background_color, bool ignore_aspect, std::string format, int quality, float rotate) { // Create blank thumbnail image & fill background color std::shared_ptr thumbnail = std::shared_ptr(new QImage(new_width, new_height, QImage::Format_RGBA8888)); @@ -729,7 +729,7 @@ int Frame::constrain(int color_value) } // Add (or replace) pixel data to the frame (based on a solid color) -void Frame::AddColor(int new_width, int new_height, string new_color) +void Frame::AddColor(int new_width, int new_height, std::string new_color) { // Set color color = new_color; From 0dbbe942d2b08c6014812bd74ac2cdfb60e2f93f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 21:53:29 -0400 Subject: [PATCH 02/36] Use std:: in WriterBase --- include/WriterBase.h | 12 +++++------- src/WriterBase.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/WriterBase.h b/include/WriterBase.h index 7620da64..7387d613 100644 --- a/include/WriterBase.h +++ b/include/WriterBase.h @@ -39,8 +39,6 @@ #include "ReaderBase.h" #include "ZmqLogger.h" -using namespace std; - namespace openshot { /** @@ -63,20 +61,20 @@ namespace openshot int video_bit_rate; ///< The bit rate of the video stream (in bytes) Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) - string vcodec; ///< The name of the video codec used to encode / decode the video stream + std::string vcodec; ///< The name of the video codec used to encode / decode the video stream int64_t video_length; ///< The number of frames in the video stream int video_stream_index; ///< The index of the video stream Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen bool interlaced_frame; ///< Are the contents of this frame interlaced bool top_field_first; ///< Which interlaced field should be displayed first - string acodec; ///< The name of the audio codec used to encode / decode the video stream + std::string acodec; ///< The name of the audio codec used to encode / decode the video stream int audio_bit_rate; ///< The bit rate of the audio stream (in bytes) int sample_rate; ///< The number of audio samples per second (44100 is a common sample rate) int channels; ///< The number of audio channels used in the audio stream ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) int audio_stream_index; ///< The index of the audio stream Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played - std::map metadata; ///< An optional map/dictionary of video & audio metadata + std::map metadata; ///< An optional map/dictionary of video & audio metadata }; /** @@ -109,9 +107,9 @@ namespace openshot virtual void WriteFrame(ReaderBase* reader, int64_t start, int64_t length) = 0; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Display file information in the standard output stream (stdout) diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index f677215a..147ee9c0 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -139,7 +139,7 @@ void WriterBase::DisplayInfo() { } // Generate JSON string of this object -string WriterBase::Json() { +std::string WriterBase::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -154,7 +154,7 @@ Json::Value WriterBase::JsonValue() { root["has_audio"] = info.has_audio; root["has_single_image"] = info.has_single_image; root["duration"] = info.duration; - stringstream filesize_stream; + std::stringstream filesize_stream; filesize_stream << info.file_size; root["file_size"] = filesize_stream.str(); root["height"] = info.height; @@ -171,7 +171,7 @@ Json::Value WriterBase::JsonValue() { root["display_ratio"]["num"] = info.display_ratio.num; root["display_ratio"]["den"] = info.display_ratio.den; root["vcodec"] = info.vcodec; - stringstream video_length_stream; + std::stringstream video_length_stream; video_length_stream << info.video_length; root["video_length"] = video_length_stream.str(); root["video_stream_index"] = info.video_stream_index; @@ -195,14 +195,14 @@ Json::Value WriterBase::JsonValue() { } // Load JSON string into this object -void WriterBase::SetJson(string value) { +void WriterBase::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From e49039d568ebb7925e640474cf39baa939e50d3a Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:23:06 -0400 Subject: [PATCH 03/36] std:: prefixes for Timeline.h/.cpp --- include/Timeline.h | 25 ++++++++----------- src/Timeline.cpp | 62 +++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/include/Timeline.h b/include/Timeline.h index 3793f301..e1dcb349 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -54,9 +54,6 @@ #include "ReaderBase.h" #include "Settings.h" -using namespace std; -using namespace openshot; - namespace openshot { /// Comparison method for sorting clip pointers (by Layer and then Position). Clips are sorted @@ -152,12 +149,12 @@ namespace openshot { private: bool is_open; /// clips; /// closing_clips; /// open_clips; /// effects; /// clips; /// closing_clips; /// open_clips; /// effects; /// allocated_frame_mappers; ///< all the frame mappers we allocated and must free + std::set allocated_frame_mappers; ///< all the frame mappers we allocated and must free bool managed_cache; ///< Does this timeline instance manage the cache object /// Process a new layer of video or audio @@ -181,7 +178,7 @@ namespace openshot { /// @param requested_frame The frame number that is requested. /// @param number_of_frames The number of frames to check /// @param include Include or Exclude intersecting clips - vector find_intersecting_clips(int64_t requested_frame, int number_of_frames, bool include); + std::vector find_intersecting_clips(int64_t requested_frame, int number_of_frames, bool include); /// Get or generate a blank frame std::shared_ptr GetOrCreateFrame(Clip* clip, int64_t number); @@ -235,7 +232,7 @@ namespace openshot { void ClearAllCache(); /// Return a list of clips on the timeline - list Clips() { return clips; }; + std::list Clips() { return clips; }; /// Close the timeline reader (and any resources it was consuming) void Close(); @@ -268,11 +265,11 @@ namespace openshot { bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "Timeline"; }; + std::string Name() { return "Timeline"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object @@ -284,7 +281,7 @@ namespace openshot { /// This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync /// with another application... such as OpenShot Video Editor (http://www.openshot.org). /// @param value A JSON string containing a key, value, and type of change. - void ApplyJsonDiff(string value); + void ApplyJsonDiff(std::string value); /// Open the reader (and start consuming resources) void Open(); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 296e7a93..269066e9 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -79,7 +79,7 @@ Timeline::~Timeline() { Close(); // Free all allocated frame mappers - set::iterator frame_mapper_itr; + std::set::iterator frame_mapper_itr; for (frame_mapper_itr = allocated_frame_mappers.begin(); frame_mapper_itr != allocated_frame_mappers.end(); ++frame_mapper_itr) { // Get frame mapper object from the iterator FrameMapper *frame_mapper = (*frame_mapper_itr); @@ -169,7 +169,7 @@ void Timeline::ApplyMapperToClips() ClearAllCache(); // Loop through all clips - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator @@ -197,7 +197,7 @@ std::shared_ptr Timeline::apply_effects(std::shared_ptr frame, int ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects", "frame->number", frame->number, "timeline_frame_number", timeline_frame_number, "layer", layer); // Find Effects at this position and layer - list::iterator effect_itr; + std::list::iterator effect_itr; for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr) { // Get effect object from the iterator @@ -608,7 +608,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Draw frame #'s on top of image (if needed) if (source_clip->display != FRAME_DISPLAY_NONE) { - stringstream frame_number_str; + std::stringstream frame_number_str; switch (source_clip->display) { case (FRAME_DISPLAY_CLIP): @@ -692,7 +692,7 @@ void Timeline::Close() ZmqLogger::Instance()->AppendDebugMethod("Timeline::Close"); // Close all open clips - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator @@ -764,7 +764,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) // Get a list of clips that intersect with the requested section of timeline // This also opens the readers for intersecting clips, and marks non-intersecting clips as 'needs closing' - vector nearby_clips; + std::vector nearby_clips; #pragma omp critical (T_GetFrame) nearby_clips = find_intersecting_clips(requested_frame, minimum_frames, true); @@ -914,10 +914,10 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) // Find intersecting clips (or non intersecting clips) -vector Timeline::find_intersecting_clips(int64_t requested_frame, int number_of_frames, bool include) +std::vector Timeline::find_intersecting_clips(int64_t requested_frame, int number_of_frames, bool include) { // Find matching clips - vector matching_clips; + std::vector matching_clips; // Calculate time of frame float min_requested_frame = requested_frame; @@ -927,7 +927,7 @@ vector Timeline::find_intersecting_clips(int64_t requested_frame, int num sort_clips(); // Find Clips at this time - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator @@ -977,7 +977,7 @@ void Timeline::SetCache(CacheBase* new_cache) { } // Generate JSON string of this object -string Timeline::Json() { +std::string Timeline::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -998,7 +998,7 @@ Json::Value Timeline::JsonValue() { root["clips"] = Json::Value(Json::arrayValue); // Find Clips at this time - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator @@ -1010,7 +1010,7 @@ Json::Value Timeline::JsonValue() { root["effects"] = Json::Value(Json::arrayValue); // loop through effects - list::iterator effect_itr; + std::list::iterator effect_itr; for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr) { // Get clip object from the iterator @@ -1033,7 +1033,7 @@ void Timeline::SetJson(string value) { Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -1122,7 +1122,7 @@ void Timeline::SetJsonValue(Json::Value root) { } // Apply a special formatted JSON object, which represents a change to the timeline (insert, update, delete) -void Timeline::ApplyJsonDiff(string value) { +void Timeline::ApplyJsonDiff(std::string value) { // Get lock (prevent getting frames while this happens) const GenericScopedLock lock(getFrameCriticalSection); @@ -1132,7 +1132,7 @@ void Timeline::ApplyJsonDiff(string value) { Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -1147,7 +1147,7 @@ void Timeline::ApplyJsonDiff(string value) { for (int x = 0; x < root.size(); x++) { // Get each change Json::Value change = root[x]; - string root_key = change["key"][(uint)0].asString(); + std::string root_key = change["key"][(uint)0].asString(); // Process each type of change if (root_key == "clips") @@ -1175,8 +1175,8 @@ void Timeline::ApplyJsonDiff(string value) { void Timeline::apply_json_to_clips(Json::Value change) { // Get key and type of change - string change_type = change["type"].asString(); - string clip_id = ""; + std::string change_type = change["type"].asString(); + std::string clip_id = ""; Clip *existing_clip = NULL; // Find id of clip (if any) @@ -1191,7 +1191,7 @@ void Timeline::apply_json_to_clips(Json::Value change) { clip_id = key_part["id"].asString(); // Find matching clip in timeline (if any) - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator @@ -1218,11 +1218,11 @@ void Timeline::apply_json_to_clips(Json::Value change) { if (!key_part["id"].isNull()) { // Set the id - string effect_id = key_part["id"].asString(); + std::string effect_id = key_part["id"].asString(); // Find matching effect in timeline (if any) - list effect_list = existing_clip->Effects(); - list::iterator effect_itr; + std::list effect_list = existing_clip->Effects(); + std::list::iterator effect_itr; for (effect_itr=effect_list.begin(); effect_itr != effect_list.end(); ++effect_itr) { // Get effect object from the iterator @@ -1304,7 +1304,7 @@ void Timeline::apply_json_to_clips(Json::Value change) { void Timeline::apply_json_to_effects(Json::Value change) { // Get key and type of change - string change_type = change["type"].asString(); + std::string change_type = change["type"].asString(); EffectBase *existing_effect = NULL; // Find id of an effect (if any) @@ -1317,10 +1317,10 @@ void Timeline::apply_json_to_effects(Json::Value change) { if (!key_part["id"].isNull()) { // Set the id - string effect_id = key_part["id"].asString(); + std::string effect_id = key_part["id"].asString(); // Find matching effect in timeline (if any) - list::iterator effect_itr; + std::list::iterator effect_itr; for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr) { // Get effect object from the iterator @@ -1345,7 +1345,7 @@ void Timeline::apply_json_to_effects(Json::Value change) { void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_effect) { // Get key and type of change - string change_type = change["type"].asString(); + std::string change_type = change["type"].asString(); // Calculate start and end frames that this impacts, and remove those frames from the cache if (!change["value"].isArray() && !change["value"]["position"].isNull()) { @@ -1358,7 +1358,7 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef if (change_type == "insert") { // Determine type of effect - string effect_type = change["value"]["type"].asString(); + std::string effect_type = change["value"]["type"].asString(); // Create Effect EffectBase *e = NULL; @@ -1408,9 +1408,9 @@ void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_ef void Timeline::apply_json_to_timeline(Json::Value change) { // Get key and type of change - string change_type = change["type"].asString(); - string root_key = change["key"][(uint)0].asString(); - string sub_key = ""; + std::string change_type = change["type"].asString(); + std::string root_key = change["key"][(uint)0].asString(); + std::string sub_key = ""; if (change["key"].size() >= 2) sub_key = change["key"][(uint)1].asString(); @@ -1533,7 +1533,7 @@ void Timeline::ClearAllCache() { final_cache->Clear(); // Loop through all clips - list::iterator clip_itr; + std::list::iterator clip_itr; for (clip_itr=clips.begin(); clip_itr != clips.end(); ++clip_itr) { // Get clip object from the iterator From b4b6223e892a4f5e4a7b74c358805e6ddb5c6bb8 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:23:33 -0400 Subject: [PATCH 04/36] std:: prefixes for FFmpegReader.h/.cpp --- include/FFmpegReader.h | 30 +++++++++++++++--------------- src/FFmpegReader.cpp | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index 894d3e5d..611ca9a8 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -95,7 +95,7 @@ namespace openshot { */ class FFmpegReader : public ReaderBase { private: - string path; + std::string path; AVFormatContext *pFormatCtx; int i, videoStream, audioStream; @@ -114,15 +114,15 @@ namespace openshot { CacheMemory working_cache; CacheMemory missing_frames; - map processing_video_frames; - multimap processing_audio_frames; - map processed_video_frames; - map processed_audio_frames; - multimap missing_video_frames; - multimap missing_video_frames_source; - multimap missing_audio_frames; - multimap missing_audio_frames_source; - map checked_frames; + std::map processing_video_frames; + std::multimap processing_audio_frames; + std::map processed_video_frames; + std::map processed_audio_frames; + std::multimap missing_video_frames; + std::multimap missing_video_frames_source; + std::multimap missing_audio_frames; + std::multimap missing_audio_frames_source; + std::map checked_frames; AudioLocation previous_packet_location; // DEBUG VARIABLES (FOR AUDIO ISSUES) @@ -238,12 +238,12 @@ namespace openshot { /// Constructor for FFmpegReader. This automatically opens the media file and loads /// frame 1, or it throws one of the following exceptions. - FFmpegReader(string path); + FFmpegReader(std::string path); /// Constructor for FFmpegReader. This only opens the media file to inspect its properties /// if inspect_reader=true. When not inspecting the media file, it's much faster, and useful /// when you are inflating the object using JSON after instantiating it. - FFmpegReader(string path, bool inspect_reader); + FFmpegReader(std::string path, bool inspect_reader); /// Destructor virtual ~FFmpegReader(); @@ -264,11 +264,11 @@ namespace openshot { bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "FFmpegReader"; }; + std::string Name() { return "FFmpegReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 511a3183..65015893 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -83,7 +83,7 @@ int hw_de_on = 0; AVHWDeviceType hw_de_av_device_type_global = AV_HWDEVICE_TYPE_NONE; #endif -FFmpegReader::FFmpegReader(string path) +FFmpegReader::FFmpegReader(std::string path) : last_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0), seek_count(0), audio_pts_offset(99999), video_pts_offset(99999), path(path), is_video_seek(true), check_interlace(false), check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0), @@ -105,7 +105,7 @@ FFmpegReader::FFmpegReader(string path) Close(); } -FFmpegReader::FFmpegReader(string path, bool inspect_reader) +FFmpegReader::FFmpegReader(std::string path, bool inspect_reader) : last_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0), seek_count(0), audio_pts_offset(99999), video_pts_offset(99999), path(path), is_video_seek(true), check_interlace(false), check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0), @@ -1455,7 +1455,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr // Add audio frame to list of processing audio frames { const GenericScopedLock lock(processingCriticalSection); - processing_audio_frames.insert(pair(previous_packet_location.frame, previous_packet_location.frame)); + processing_audio_frames.insert(std::pair(previous_packet_location.frame, previous_packet_location.frame)); } while (pts_remaining_samples) { @@ -1478,7 +1478,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr // Add audio frame to list of processing audio frames { const GenericScopedLock lock(processingCriticalSection); - processing_audio_frames.insert(pair(previous_packet_location.frame, previous_packet_location.frame)); + processing_audio_frames.insert(std::pair(previous_packet_location.frame, previous_packet_location.frame)); } } else { @@ -1882,8 +1882,8 @@ int64_t FFmpegReader::ConvertVideoPTStoFrame(int64_t pts) { while (current_video_frame < frame) { if (!missing_video_frames.count(current_video_frame)) { ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (tracking missing frame)", "current_video_frame", current_video_frame, "previous_video_frame", previous_video_frame); - missing_video_frames.insert(pair(current_video_frame, previous_video_frame)); - missing_video_frames_source.insert(pair(previous_video_frame, current_video_frame)); + missing_video_frames.insert(std::pair(current_video_frame, previous_video_frame)); + missing_video_frames_source.insert(std::pair(previous_video_frame, current_video_frame)); } // Mark this reader as containing missing frames @@ -1975,7 +1975,7 @@ AudioLocation FFmpegReader::GetAudioPTSLocation(int64_t pts) { for (int64_t audio_frame = previous_packet_location.frame; audio_frame < location.frame; audio_frame++) { if (!missing_audio_frames.count(audio_frame)) { ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (tracking missing frame)", "missing_audio_frame", audio_frame, "previous_audio_frame", previous_packet_location.frame, "new location frame", location.frame); - missing_audio_frames.insert(pair(audio_frame, previous_packet_location.frame - 1)); + missing_audio_frames.insert(std::pair(audio_frame, previous_packet_location.frame - 1)); } } } @@ -2046,7 +2046,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) { ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame", "requested_frame", requested_frame, "has_missing_frames", has_missing_frames, "missing_video_frames.size()", missing_video_frames.size(), "checked_count", checked_count); // Missing frames (sometimes frame #'s are skipped due to invalid or missing timestamps) - map::iterator itr; + std::map::iterator itr; bool found_missing_frame = false; // Special MP3 Handling (ignore more than 1 video frame) @@ -2059,8 +2059,8 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) { if (checked_count > 8 && !missing_video_frames.count(requested_frame) && !processing_audio_frames.count(requested_frame) && processed_audio_frames.count(requested_frame) && last_frame && last_video_frame->has_image_data && aCodecId == AV_CODEC_ID_MP3 && (vCodecId == AV_CODEC_ID_MJPEGB || vCodecId == AV_CODEC_ID_MJPEG)) { - missing_video_frames.insert(pair(requested_frame, last_video_frame->number)); - missing_video_frames_source.insert(pair(last_video_frame->number, requested_frame)); + missing_video_frames.insert(std::pair(requested_frame, last_video_frame->number)); + missing_video_frames_source.insert(std::pair(last_video_frame->number, requested_frame)); missing_frames.Add(last_video_frame); } } @@ -2374,7 +2374,7 @@ void FFmpegReader::RemoveAVPacket(AVPacket *remove_packet) { /// Get the smallest video frame that is still being processed int64_t FFmpegReader::GetSmallestVideoFrame() { // Loop through frame numbers - map::iterator itr; + std::map::iterator itr; int64_t smallest_frame = -1; const GenericScopedLock lock(processingCriticalSection); for (itr = processing_video_frames.begin(); itr != processing_video_frames.end(); ++itr) { @@ -2389,7 +2389,7 @@ int64_t FFmpegReader::GetSmallestVideoFrame() { /// Get the smallest audio frame that is still being processed int64_t FFmpegReader::GetSmallestAudioFrame() { // Loop through frame numbers - map::iterator itr; + std::map::iterator itr; int64_t smallest_frame = -1; const GenericScopedLock lock(processingCriticalSection); for (itr = processing_audio_frames.begin(); itr != processing_audio_frames.end(); ++itr) { @@ -2402,7 +2402,7 @@ int64_t FFmpegReader::GetSmallestAudioFrame() { } // Generate JSON string of this object -string FFmpegReader::Json() { +std::string FFmpegReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -2421,14 +2421,14 @@ Json::Value FFmpegReader::JsonValue() { } // Load JSON string into this object -void FFmpegReader::SetJson(string value) { +void FFmpegReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse(value.c_str(), value.c_str() + value.size(), &root, &errors); delete reader; From 0b6f9ff5bdc7973362aef0b763b80271e80e4349 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:25:36 -0400 Subject: [PATCH 05/36] AudioReaderSource.h: Remove 'using...std' --- include/AudioReaderSource.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/AudioReaderSource.h b/include/AudioReaderSource.h index 679aed61..edf900d2 100644 --- a/include/AudioReaderSource.h +++ b/include/AudioReaderSource.h @@ -43,8 +43,6 @@ #include "ReaderBase.h" #include "JuceHeader.h" -using namespace std; - /// This namespace is the default namespace for all code in the openshot library namespace openshot { From b6b832fb8127ce2b90bdd267680cfad2ff8252f2 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:34:24 -0400 Subject: [PATCH 06/36] std:: prefixes for CacheBase/Disk/Memory --- include/CacheBase.h | 6 +++--- include/CacheDisk.h | 22 +++++++++++----------- include/CacheMemory.h | 14 +++++++------- src/CacheBase.cpp | 2 +- src/CacheDisk.cpp | 36 ++++++++++++++++++------------------ src/CacheMemory.cpp | 30 +++++++++++++++--------------- 6 files changed, 55 insertions(+), 55 deletions(-) diff --git a/include/CacheBase.h b/include/CacheBase.h index 3760e84b..d09cb114 100644 --- a/include/CacheBase.h +++ b/include/CacheBase.h @@ -48,7 +48,7 @@ namespace openshot { class CacheBase { protected: - string cache_type; ///< This is a friendly type name of the derived cache instance + std::string cache_type; ///< This is a friendly type name of the derived cache instance int64_t max_bytes; ///< This is the max number of bytes to cache (0 = no limit) /// Section lock for multiple threads @@ -108,8 +108,8 @@ namespace openshot { void SetMaxBytesFromInfo(int64_t number_of_frames, int width, int height, int sample_rate, int channels); /// Get and Set JSON methods - virtual string Json() = 0; ///< Generate JSON string of this object - virtual void SetJson(string value) = 0; ///< Load JSON string into this object + virtual std::string Json() = 0; ///< Generate JSON string of this object + virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object virtual ~CacheBase() = default; diff --git a/include/CacheDisk.h b/include/CacheDisk.h index 11a8808c..82c4c80e 100644 --- a/include/CacheDisk.h +++ b/include/CacheDisk.h @@ -53,24 +53,24 @@ namespace openshot { class CacheDisk : public CacheBase { private: QDir path; ///< This is the folder path of the cache directory - map frames; ///< This map holds the frame number and Frame objects - deque frame_numbers; ///< This queue holds a sequential list of cached Frame numbers - string image_format; + std::map frames; ///< This map holds the frame number and Frame objects + std::deque frame_numbers; ///< This queue holds a sequential list of cached Frame numbers + std::string image_format; float image_quality; float image_scale; int64_t frame_size_bytes; ///< The size of the cached frame in bytes bool needs_range_processing; ///< Something has changed, and the range data needs to be re-calculated - string json_ranges; ///< JSON ranges of frame numbers - vector ordered_frame_numbers; ///< Ordered list of frame numbers used by cache - map frame_ranges; ///< This map holds the ranges of frames, useful for quickly displaying the contents of the cache + std::string json_ranges; ///< JSON ranges of frame numbers + std::vector ordered_frame_numbers; ///< Ordered list of frame numbers used by cache + std::map frame_ranges; ///< This map holds the ranges of frames, useful for quickly displaying the contents of the cache int64_t range_version; ///< The version of the JSON range data (incremented with each change) /// Clean up cached frames that exceed the max number of bytes void CleanUp(); /// Init path directory - void InitPath(string cache_path); + void InitPath(std::string cache_path); /// Calculate ranges of frames void CalculateRanges(); @@ -81,7 +81,7 @@ namespace openshot { /// @param format The image format for disk caching (ppm, jpg, png) /// @param quality The quality of the image (1.0=highest quality/slowest speed, 0.0=worst quality/fastest speed) /// @param scale The scale factor for the preview images (1.0 = original size, 0.5=half size, 0.25=quarter size, etc...) - CacheDisk(string cache_path, string format, float quality, float scale); + CacheDisk(std::string cache_path, std::string format, float quality, float scale); /// @brief Constructor that sets the max bytes to cache /// @param cache_path The folder path of the cache directory (empty string = /tmp/preview-cache/) @@ -89,7 +89,7 @@ namespace openshot { /// @param quality The quality of the image (1.0=highest quality/slowest speed, 0.0=worst quality/fastest speed) /// @param scale The scale factor for the preview images (1.0 = original size, 0.5=half size, 0.25=quarter size, etc...) /// @param max_bytes The maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames. - CacheDisk(string cache_path, string format, float quality, float scale, int64_t max_bytes); + CacheDisk(std::string cache_path, std::string format, float quality, float scale, int64_t max_bytes); // Default destructor ~CacheDisk(); @@ -128,8 +128,8 @@ namespace openshot { void Remove(int64_t start_frame_number, int64_t end_frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/include/CacheMemory.h b/include/CacheMemory.h index eb11f273..7ac77537 100644 --- a/include/CacheMemory.h +++ b/include/CacheMemory.h @@ -50,13 +50,13 @@ namespace openshot { */ class CacheMemory : public CacheBase { private: - map > frames; ///< This map holds the frame number and Frame objects - deque frame_numbers; ///< This queue holds a sequential list of cached Frame numbers + std::map > frames; ///< This map holds the frame number and Frame objects + std::deque frame_numbers; ///< This queue holds a sequential list of cached Frame numbers bool needs_range_processing; ///< Something has changed, and the range data needs to be re-calculated - string json_ranges; ///< JSON ranges of frame numbers - vector ordered_frame_numbers; ///< Ordered list of frame numbers used by cache - map frame_ranges; ///< This map holds the ranges of frames, useful for quickly displaying the contents of the cache + std::string json_ranges; ///< JSON ranges of frame numbers + std::vector ordered_frame_numbers; ///< Ordered list of frame numbers used by cache + std::map frame_ranges; ///< This map holds the ranges of frames, useful for quickly displaying the contents of the cache int64_t range_version; ///< The version of the JSON range data (incremented with each change) /// Clean up cached frames that exceed the max number of bytes @@ -110,8 +110,8 @@ namespace openshot { void Remove(int64_t start_frame_number, int64_t end_frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/src/CacheBase.cpp b/src/CacheBase.cpp index 0016694a..b5627e8b 100644 --- a/src/CacheBase.cpp +++ b/src/CacheBase.cpp @@ -58,7 +58,7 @@ Json::Value CacheBase::JsonValue() { // Create root json object Json::Value root; - stringstream max_bytes_stream; + std::stringstream max_bytes_stream; max_bytes_stream << max_bytes; root["max_bytes"] = max_bytes_stream.str(); diff --git a/src/CacheDisk.cpp b/src/CacheDisk.cpp index b1b1876b..41b40aef 100644 --- a/src/CacheDisk.cpp +++ b/src/CacheDisk.cpp @@ -34,7 +34,7 @@ using namespace std; using namespace openshot; // Default constructor, no max bytes -CacheDisk::CacheDisk(string cache_path, string format, float quality, float scale) : CacheBase(0) { +CacheDisk::CacheDisk(std::string cache_path, std::string format, float quality, float scale) : CacheBase(0) { // Set cache type name cache_type = "CacheDisk"; range_version = 0; @@ -50,7 +50,7 @@ CacheDisk::CacheDisk(string cache_path, string format, float quality, float scal }; // Constructor that sets the max bytes to cache -CacheDisk::CacheDisk(string cache_path, string format, float quality, float scale, int64_t max_bytes) : CacheBase(max_bytes) { +CacheDisk::CacheDisk(std::string cache_path, std::string format, float quality, float scale, int64_t max_bytes) : CacheBase(max_bytes) { // Set cache type name cache_type = "CacheDisk"; range_version = 0; @@ -65,7 +65,7 @@ CacheDisk::CacheDisk(string cache_path, string format, float quality, float scal }; // Initialize cache directory -void CacheDisk::InitPath(string cache_path) { +void CacheDisk::InitPath(std::string cache_path) { QString qpath; if (!cache_path.empty()) { @@ -103,7 +103,7 @@ void CacheDisk::CalculateRanges() { // Increment range version range_version++; - vector::iterator itr_ordered; + std::vector::iterator itr_ordered; int64_t starting_frame = *ordered_frame_numbers.begin(); int64_t ending_frame = *ordered_frame_numbers.begin(); @@ -116,9 +116,9 @@ void CacheDisk::CalculateRanges() { // Add JSON object with start/end attributes // Use strings, since int64_ts are supported in JSON - stringstream start_str; + std::stringstream start_str; start_str << starting_frame; - stringstream end_str; + std::stringstream end_str; end_str << ending_frame; range["start"] = start_str.str(); range["end"] = end_str.str(); @@ -137,9 +137,9 @@ void CacheDisk::CalculateRanges() { // Add JSON object with start/end attributes // Use strings, since int64_ts are supported in JSON - stringstream start_str; + std::stringstream start_str; start_str << starting_frame; - stringstream end_str; + std::stringstream end_str; end_str << ending_frame; range["start"] = start_str.str(); range["end"] = end_str.str(); @@ -302,7 +302,7 @@ std::shared_ptr CacheDisk::GetSmallestFrame() std::shared_ptr f; // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; int64_t smallest_frame = -1; for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) { @@ -325,7 +325,7 @@ int64_t CacheDisk::GetBytes() int64_t total_bytes = 0; // Loop through frames, and calculate total bytes - deque::reverse_iterator itr; + std::deque::reverse_iterator itr; for(itr = frame_numbers.rbegin(); itr != frame_numbers.rend(); ++itr) total_bytes += frame_size_bytes; @@ -345,7 +345,7 @@ void CacheDisk::Remove(int64_t start_frame_number, int64_t end_frame_number) const GenericScopedLock lock(*cacheCriticalSection); // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; for(itr = frame_numbers.begin(); itr != frame_numbers.end();) { //deque::iterator current = itr++; @@ -358,7 +358,7 @@ void CacheDisk::Remove(int64_t start_frame_number, int64_t end_frame_number) } // Loop through ordered frame numbers - vector::iterator itr_ordered; + std::vector::iterator itr_ordered; for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end();) { if (*itr_ordered >= start_frame_number && *itr_ordered <= end_frame_number) @@ -397,7 +397,7 @@ void CacheDisk::MoveToFront(int64_t frame_number) const GenericScopedLock lock(*cacheCriticalSection); // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) { if (*itr == frame_number) @@ -465,7 +465,7 @@ void CacheDisk::CleanUp() } // Generate JSON string of this object -string CacheDisk::Json() { +std::string CacheDisk::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -483,7 +483,7 @@ Json::Value CacheDisk::JsonValue() { root["path"] = path.path().toStdString(); Json::Value version; - stringstream range_version_str; + std::stringstream range_version_str; range_version_str << range_version; root["version"] = range_version_str.str(); @@ -492,7 +492,7 @@ Json::Value CacheDisk::JsonValue() { Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( json_ranges.c_str(), json_ranges.c_str() + json_ranges.size(), &ranges, &errors ); delete reader; @@ -505,14 +505,14 @@ Json::Value CacheDisk::JsonValue() { } // Load JSON string into this object -void CacheDisk::SetJson(string value) { +void CacheDisk::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/CacheMemory.cpp b/src/CacheMemory.cpp index 7bd480e4..2673f68b 100644 --- a/src/CacheMemory.cpp +++ b/src/CacheMemory.cpp @@ -79,7 +79,7 @@ void CacheMemory::CalculateRanges() { // Increment range version range_version++; - vector::iterator itr_ordered; + std::vector::iterator itr_ordered; int64_t starting_frame = *ordered_frame_numbers.begin(); int64_t ending_frame = *ordered_frame_numbers.begin(); @@ -92,9 +92,9 @@ void CacheMemory::CalculateRanges() { // Add JSON object with start/end attributes // Use strings, since int64_ts are supported in JSON - stringstream start_str; + std::stringstream start_str; start_str << starting_frame; - stringstream end_str; + std::stringstream end_str; end_str << ending_frame; range["start"] = start_str.str(); range["end"] = end_str.str(); @@ -113,9 +113,9 @@ void CacheMemory::CalculateRanges() { // Add JSON object with start/end attributes // Use strings, since int64_ts are not supported in JSON - stringstream start_str; + std::stringstream start_str; start_str << starting_frame; - stringstream end_str; + std::stringstream end_str; end_str << ending_frame; range["start"] = start_str.str(); range["end"] = end_str.str(); @@ -178,7 +178,7 @@ std::shared_ptr CacheMemory::GetSmallestFrame() std::shared_ptr f; // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; int64_t smallest_frame = -1; for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) { @@ -201,7 +201,7 @@ int64_t CacheMemory::GetBytes() int64_t total_bytes = 0; // Loop through frames, and calculate total bytes - deque::reverse_iterator itr; + std::deque::reverse_iterator itr; for(itr = frame_numbers.rbegin(); itr != frame_numbers.rend(); ++itr) { total_bytes += frames[*itr]->GetBytes(); @@ -223,7 +223,7 @@ void CacheMemory::Remove(int64_t start_frame_number, int64_t end_frame_number) const GenericScopedLock lock(*cacheCriticalSection); // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; for(itr = frame_numbers.begin(); itr != frame_numbers.end();) { if (*itr >= start_frame_number && *itr <= end_frame_number) @@ -235,7 +235,7 @@ void CacheMemory::Remove(int64_t start_frame_number, int64_t end_frame_number) } // Loop through ordered frame numbers - vector::iterator itr_ordered; + std::vector::iterator itr_ordered; for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end();) { if (*itr_ordered >= start_frame_number && *itr_ordered <= end_frame_number) @@ -261,7 +261,7 @@ void CacheMemory::MoveToFront(int64_t frame_number) if (frames.count(frame_number)) { // Loop through frame numbers - deque::iterator itr; + std::deque::iterator itr; for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) { if (*itr == frame_number) @@ -321,7 +321,7 @@ void CacheMemory::CleanUp() // Generate JSON string of this object -string CacheMemory::Json() { +std::string CacheMemory::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -337,7 +337,7 @@ Json::Value CacheMemory::JsonValue() { Json::Value root = CacheBase::JsonValue(); // get parent properties root["type"] = cache_type; - stringstream range_version_str; + std::stringstream range_version_str; range_version_str << range_version; root["version"] = range_version_str.str(); @@ -346,7 +346,7 @@ Json::Value CacheMemory::JsonValue() { Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( json_ranges.c_str(), json_ranges.c_str() + json_ranges.size(), &ranges, &errors ); delete reader; @@ -359,14 +359,14 @@ Json::Value CacheMemory::JsonValue() { } // Load JSON string into this object -void CacheMemory::SetJson(string value) { +void CacheMemory::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From cb567e44d0e6fc8ffc178a2be26100b8b77eaff8 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:34:56 -0400 Subject: [PATCH 07/36] std:: prefixes for AudioBufferSource/AudioDeviceInfo --- include/AudioBufferSource.h | 2 -- include/AudioDeviceInfo.h | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/AudioBufferSource.h b/include/AudioBufferSource.h index 4addb37d..903172f7 100644 --- a/include/AudioBufferSource.h +++ b/include/AudioBufferSource.h @@ -42,8 +42,6 @@ #include #include "JuceHeader.h" -using namespace std; - /// This namespace is the default namespace for all code in the openshot library namespace openshot { diff --git a/include/AudioDeviceInfo.h b/include/AudioDeviceInfo.h index 4099430e..bbdbd81b 100644 --- a/include/AudioDeviceInfo.h +++ b/include/AudioDeviceInfo.h @@ -39,8 +39,8 @@ */ struct AudioDeviceInfo { - string name; - string type; + std::string name; + std::string type; }; -#endif \ No newline at end of file +#endif From 5746cd7b8b0ed135bfcf7d8d07cc8099b714bf22 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:39:13 -0400 Subject: [PATCH 08/36] std:: prefixes for TextReader.h/.cpp --- include/TextReader.h | 22 ++++++++++------------ src/TextReader.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/TextReader.h b/include/TextReader.h index 7b276f7f..59b0aeed 100644 --- a/include/TextReader.h +++ b/include/TextReader.h @@ -47,8 +47,6 @@ #include "Exceptions.h" #include "MagickUtilities.h" -using namespace std; - namespace openshot { @@ -91,12 +89,12 @@ namespace openshot int height; int x_offset; int y_offset; - string text; - string font; + std::string text; + std::string font; double size; - string text_color; - string background_color; - string text_background_color; + std::string text_color; + std::string background_color; + std::string text_background_color; std::shared_ptr image; MAGICK_DRAWABLE lines; bool is_open; @@ -118,11 +116,11 @@ namespace openshot /// @param size The size of the text /// @param text_color The color of the text /// @param background_color The background color of the text frame image (also supports Transparent) - TextReader(int width, int height, int x_offset, int y_offset, GravityType gravity, string text, string font, double size, string text_color, string background_color); + TextReader(int width, int height, int x_offset, int y_offset, GravityType gravity, std::string text, std::string font, double size, std::string text_color, std::string background_color); /// Draw a box under rendered text using the specified color. /// @param text_background_color The background color behind the text - void SetTextBackgroundColor(string color); + void SetTextBackgroundColor(std::string color); /// Close Reader void Close(); @@ -141,11 +139,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "TextReader"; }; + std::string Name() { return "TextReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/src/TextReader.cpp b/src/TextReader.cpp index 27f503e1..6037ae3d 100644 --- a/src/TextReader.cpp +++ b/src/TextReader.cpp @@ -43,7 +43,7 @@ TextReader::TextReader() : width(1024), height(768), x_offset(0), y_offset(0), t Close(); } -TextReader::TextReader(int width, int height, int x_offset, int y_offset, GravityType gravity, string text, string font, double size, string text_color, string background_color) +TextReader::TextReader(int width, int height, int x_offset, int y_offset, GravityType gravity, std::string text, std::string font, double size, std::string text_color, std::string background_color) : width(width), height(height), x_offset(x_offset), y_offset(y_offset), text(text), font(font), size(size), text_color(text_color), background_color(background_color), is_open(false), gravity(gravity) { // Open and Close the reader, to populate its attributes (such as height, width, etc...) @@ -51,7 +51,7 @@ TextReader::TextReader(int width, int height, int x_offset, int y_offset, Gravit Close(); } -void TextReader::SetTextBackgroundColor(string color) { +void TextReader::SetTextBackgroundColor(std::string color) { text_background_color = color; // Open and Close the reader, to populate it's attributes (such as height, width, etc...) plus the text background color @@ -187,7 +187,7 @@ std::shared_ptr TextReader::GetFrame(int64_t requested_frame) } // Generate JSON string of this object -string TextReader::Json() { +std::string TextReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -216,14 +216,14 @@ Json::Value TextReader::JsonValue() { } // Load JSON string into this object -void TextReader::SetJson(string value) { +void TextReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From b64a100da21f6e9ff51157bb48b603586eac7498 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:41:51 -0400 Subject: [PATCH 09/36] std:: prefixes for ReaderBase --- include/ReaderBase.h | 14 ++++++-------- src/ReaderBase.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/ReaderBase.h b/include/ReaderBase.h index 0d14ea19..f33158a7 100644 --- a/include/ReaderBase.h +++ b/include/ReaderBase.h @@ -49,8 +49,6 @@ #include #include -using namespace std; - namespace openshot { /** @@ -74,20 +72,20 @@ namespace openshot int video_bit_rate; ///< The bit rate of the video stream (in bytes) Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) - string vcodec; ///< The name of the video codec used to encode / decode the video stream + std::string vcodec; ///< The name of the video codec used to encode / decode the video stream int64_t video_length; ///< The number of frames in the video stream int video_stream_index; ///< The index of the video stream Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen bool interlaced_frame; // Are the contents of this frame interlaced bool top_field_first; // Which interlaced field should be displayed first - string acodec; ///< The name of the audio codec used to encode / decode the video stream + std::string acodec; ///< The name of the audio codec used to encode / decode the video stream int audio_bit_rate; ///< The bit rate of the audio stream (in bytes) int sample_rate; ///< The number of audio samples per second (44100 is a common sample rate) int channels; ///< The number of audio channels used in the audio stream ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) int audio_stream_index; ///< The index of the audio stream Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played - std::map metadata; ///< An optional map/dictionary of metadata for this reader + std::map metadata; ///< An optional map/dictionary of metadata for this reader }; /** @@ -140,11 +138,11 @@ namespace openshot virtual bool IsOpen() = 0; /// Return the type name of the class - virtual string Name() = 0; + virtual std::string Name() = 0; /// Get and Set JSON methods - virtual string Json() = 0; ///< Generate JSON string of this object - virtual void SetJson(string value) = 0; ///< Load JSON string into this object + virtual std::string Json() = 0; ///< Generate JSON string of this object + virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object diff --git a/src/ReaderBase.cpp b/src/ReaderBase.cpp index 30706866..36fb458a 100644 --- a/src/ReaderBase.cpp +++ b/src/ReaderBase.cpp @@ -108,7 +108,7 @@ void ReaderBase::DisplayInfo() { cout << "----------------------------" << endl; // Iterate through metadata - map::iterator it; + std::map::iterator it; for (it = info.metadata.begin(); it != info.metadata.end(); it++) cout << "--> " << it->first << ": " << it->second << endl; } @@ -122,7 +122,7 @@ Json::Value ReaderBase::JsonValue() { root["has_audio"] = info.has_audio; root["has_single_image"] = info.has_single_image; root["duration"] = info.duration; - stringstream filesize_stream; + std::stringstream filesize_stream; filesize_stream << info.file_size; root["file_size"] = filesize_stream.str(); root["height"] = info.height; @@ -139,7 +139,7 @@ Json::Value ReaderBase::JsonValue() { root["display_ratio"]["num"] = info.display_ratio.num; root["display_ratio"]["den"] = info.display_ratio.den; root["vcodec"] = info.vcodec; - stringstream video_length_stream; + std::stringstream video_length_stream; video_length_stream << info.video_length; root["video_length"] = video_length_stream.str(); root["video_stream_index"] = info.video_stream_index; @@ -160,7 +160,7 @@ Json::Value ReaderBase::JsonValue() { // Append metadata map root["metadata"] = Json::Value(Json::objectValue); - map::iterator it; + std::map::iterator it; for (it = info.metadata.begin(); it != info.metadata.end(); it++) root["metadata"][it->first] = it->second; @@ -245,7 +245,7 @@ void ReaderBase::SetJsonValue(Json::Value root) { } if (!root["metadata"].isNull() && root["metadata"].isObject()) { for( Json::Value::iterator itr = root["metadata"].begin() ; itr != root["metadata"].end() ; itr++ ) { - string key = itr.key().asString(); + std::string key = itr.key().asString(); info.metadata[key] = root["metadata"][key].asString(); } } From 9f32f5e064cd374087a5e6a128f03c526ddf321d Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:43:24 -0400 Subject: [PATCH 10/36] std:: prefixes for ClipBase --- include/ClipBase.h | 20 +++++++++----------- src/ClipBase.cpp | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/ClipBase.h b/include/ClipBase.h index ab3f0637..2890f5d8 100644 --- a/include/ClipBase.h +++ b/include/ClipBase.h @@ -43,8 +43,6 @@ #include "KeyFrame.h" #include "Json.h" -using namespace std; - namespace openshot { /** @@ -55,18 +53,18 @@ namespace openshot { */ class ClipBase { protected: - string id; ///< ID Property for all derived Clip and Effect classes. + std::string id; ///< ID Property for all derived Clip and Effect classes. float position; ///< The position on the timeline where this clip should start playing int layer; ///< The layer this clip is on. Lower clips are covered up by higher clips. float start; ///< The position in seconds to start playing (used to trim the beginning of a clip) float end; ///< The position in seconds to end playing (used to trim the ending of a clip) - string previous_properties; ///< This string contains the previous JSON properties + std::string previous_properties; ///< This string contains the previous JSON properties /// Generate JSON for a property - Json::Value add_property_json(string name, float value, string type, string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame); + Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame); /// Generate JSON choice for a property (dropdown properties) - Json::Value add_property_choice_json(string name, int value, int selected_value); + Json::Value add_property_choice_json(std::string name, int value, int selected_value); public: @@ -80,7 +78,7 @@ namespace openshot { bool operator>= ( ClipBase& a) { return (Position() >= a.Position()); } /// Get basic properties - string Id() { return id; } ///< Get the Id of this clip object + std::string Id() { return id; } ///< Get the Id of this clip object float Position() { return position; } ///< Get position on timeline (in seconds) int Layer() { return layer; } ///< Get layer of clip on timeline (lower number is covered by higher numbers) float Start() { return start; } ///< Get start position (in seconds) of clip (trim start of video) @@ -88,21 +86,21 @@ namespace openshot { float Duration() { return end - start; } ///< Get the length of this clip (in seconds) /// Set basic properties - void Id(string value) { id = value; } ///> Set the Id of this clip object + void Id(std::string value) { id = value; } ///> Set the Id of this clip object void Position(float value) { position = value; } ///< Set position on timeline (in seconds) void Layer(int value) { layer = value; } ///< Set layer of clip on timeline (lower number is covered by higher numbers) void Start(float value) { start = value; } ///< Set start position (in seconds) of clip (trim start of video) void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video) /// Get and Set JSON methods - virtual string Json() = 0; ///< Generate JSON string of this object - virtual void SetJson(string value) = 0; ///< Load JSON string into this object + virtual std::string Json() = 0; ///< Generate JSON string of this object + virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - virtual string PropertiesJSON(int64_t requested_frame) = 0; + virtual std::string PropertiesJSON(int64_t requested_frame) = 0; virtual ~ClipBase() = default; }; diff --git a/src/ClipBase.cpp b/src/ClipBase.cpp index 60bdb633..d1370205 100644 --- a/src/ClipBase.cpp +++ b/src/ClipBase.cpp @@ -65,7 +65,7 @@ void ClipBase::SetJsonValue(Json::Value root) { } // Generate JSON for a property -Json::Value ClipBase::add_property_json(string name, float value, string type, string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) { +Json::Value ClipBase::add_property_json(std::string name, float value, std::string type, std::string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) { // Requested Point Point requested_point(requested_frame, requested_frame); @@ -101,7 +101,7 @@ Json::Value ClipBase::add_property_json(string name, float value, string type, s return prop; } -Json::Value ClipBase::add_property_choice_json(string name, int value, int selected_value) { +Json::Value ClipBase::add_property_choice_json(std::string name, int value, int selected_value) { // Create choice Json::Value new_choice = Json::Value(Json::objectValue); From 4f38ac9c66b4677ad9476b795dcac7fed8cac126 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:46:57 -0400 Subject: [PATCH 11/36] ChunkReader/ChunkWriter: std:: prefixes --- include/ChunkReader.h | 16 +++++++--------- include/ChunkWriter.h | 16 +++++++--------- src/ChunkReader.cpp | 28 ++++++++++++++-------------- src/ChunkWriter.cpp | 12 +++++------- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/include/ChunkReader.h b/include/ChunkReader.h index 5b330b70..4290df81 100644 --- a/include/ChunkReader.h +++ b/include/ChunkReader.h @@ -45,8 +45,6 @@ #include "CacheMemory.h" #include "Exceptions.h" -using namespace std; - namespace openshot { @@ -105,7 +103,7 @@ namespace openshot class ChunkReader : public ReaderBase { private: - string path; + std::string path; bool is_open; int64_t chunk_size; ReaderBase *local_reader; @@ -114,13 +112,13 @@ namespace openshot std::shared_ptr last_frame; /// Check if folder path existing - bool does_folder_exist(string path); + bool does_folder_exist(std::string path); /// Find the location of a frame in a chunk ChunkLocation find_chunk_frame(int64_t requested_frame); /// get a formatted path of a specific chunk - string get_chunk_path(int64_t chunk_number, string folder, string extension); + std::string get_chunk_path(int64_t chunk_number, std::string folder, std::string extension); /// Load JSON meta data about this chunk folder void load_json(); @@ -131,7 +129,7 @@ namespace openshot /// frame 1, or it throws one of the following exceptions. /// @param path The folder path / location of a chunk (chunks are stored as folders) /// @param chunk_version Choose the video version / quality (THUMBNAIL, PREVIEW, or FINAL) - ChunkReader(string path, ChunkVersion chunk_version); + ChunkReader(std::string path, ChunkVersion chunk_version); /// Close the reader void Close(); @@ -156,11 +154,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "ChunkReader"; }; + std::string Name() { return "ChunkReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/include/ChunkWriter.h b/include/ChunkWriter.h index 5ac9be4a..c96c118a 100644 --- a/include/ChunkWriter.h +++ b/include/ChunkWriter.h @@ -49,8 +49,6 @@ #include "Json.h" -using namespace std; - namespace openshot { /** @@ -83,7 +81,7 @@ namespace openshot class ChunkWriter : public WriterBase { private: - string path; + std::string path; int64_t chunk_count; int64_t chunk_size; int64_t frame_count; @@ -95,15 +93,15 @@ namespace openshot FFmpegWriter *writer_final; std::shared_ptr last_frame; bool last_frame_needed; - string default_extension; - string default_vcodec; - string default_acodec; + std::string default_extension; + std::string default_vcodec; + std::string default_acodec; /// check for chunk folder - void create_folder(string path); + void create_folder(std::string path); /// get a formatted path of a specific chunk - string get_chunk_path(int64_t chunk_number, string folder, string extension); + std::string get_chunk_path(int64_t chunk_number, std::string folder, std::string extension); /// check for valid chunk json bool is_chunk_valid(); @@ -116,7 +114,7 @@ namespace openshot /// @brief Constructor for ChunkWriter. Throws one of the following exceptions. /// @param path The folder path of the chunk file to be created /// @param reader The initial reader to base this chunk file's meta data on (such as fps, height, width, etc...) - ChunkWriter(string path, ReaderBase *reader); + ChunkWriter(std::string path, ReaderBase *reader); /// Close the writer void Close(); diff --git a/src/ChunkReader.cpp b/src/ChunkReader.cpp index 9fc8756c..809ce714 100644 --- a/src/ChunkReader.cpp +++ b/src/ChunkReader.cpp @@ -33,7 +33,7 @@ using namespace openshot; -ChunkReader::ChunkReader(string path, ChunkVersion chunk_version) +ChunkReader::ChunkReader(std::string path, ChunkVersion chunk_version) : path(path), chunk_size(24 * 3), is_open(false), version(chunk_version), local_reader(NULL) { // Check if folder exists? @@ -51,7 +51,7 @@ ChunkReader::ChunkReader(string path, ChunkVersion chunk_version) } // Check if folder path existing -bool ChunkReader::does_folder_exist(string path) +bool ChunkReader::does_folder_exist(std::string path) { QDir dir(path.c_str()); return dir.exists(); @@ -61,12 +61,12 @@ bool ChunkReader::does_folder_exist(string path) void ChunkReader::load_json() { // Load path of chunk folder - string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString(); - stringstream json_string; + std::string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString(); + std::stringstream json_string; // Read the JSON file ifstream myfile (json_path.c_str()); - string line = ""; + std::string line = ""; if (myfile.is_open()) { while (myfile.good()) @@ -81,7 +81,7 @@ void ChunkReader::load_json() Json::Value root; Json::CharReaderBuilder rbuilder; - string errors; + std::string errors; bool success = Json::parseFromStream(rbuilder, json_string, &root, &errors); if (!success) // Raise exception @@ -170,10 +170,10 @@ void ChunkReader::Close() } // get a formatted path of a specific chunk -string ChunkReader::get_chunk_path(int64_t chunk_number, string folder, string extension) +std::string ChunkReader::get_chunk_path(int64_t chunk_number, std::string folder, std::string extension) { // Create path of new chunk video - stringstream chunk_count_string; + std::stringstream chunk_count_string; chunk_count_string << chunk_number; QString padded_count = "%1"; //chunk_count_string.str().c_str(); padded_count = padded_count.arg(chunk_count_string.str().c_str(), 6, '0'); @@ -202,7 +202,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) if (previous_location.number != location.number) { // Determine version of chunk - string folder_name = ""; + std::string folder_name = ""; switch (version) { case THUMBNAIL: @@ -217,7 +217,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) } // Load path of chunk video - string chunk_video_path = get_chunk_path(location.number, folder_name, ".webm"); + std::string chunk_video_path = get_chunk_path(location.number, folder_name, ".webm"); // Close existing reader (if needed) if (local_reader) @@ -256,7 +256,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) } // Generate JSON string of this object -string ChunkReader::Json() { +std::string ChunkReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -269,7 +269,7 @@ Json::Value ChunkReader::JsonValue() { Json::Value root = ReaderBase::JsonValue(); // get parent properties root["type"] = "ChunkReader"; root["path"] = path; - stringstream chunk_size_stream; + std::stringstream chunk_size_stream; chunk_size_stream << chunk_size; root["chunk_size"] = chunk_size_stream.str(); root["chunk_version"] = version; @@ -279,14 +279,14 @@ Json::Value ChunkReader::JsonValue() { } // Load JSON string into this object -void ChunkReader::SetJson(string value) { +void ChunkReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/ChunkWriter.cpp b/src/ChunkWriter.cpp index 5dad4df3..f7400953 100644 --- a/src/ChunkWriter.cpp +++ b/src/ChunkWriter.cpp @@ -32,7 +32,7 @@ using namespace openshot; -ChunkWriter::ChunkWriter(string path, ReaderBase *reader) : +ChunkWriter::ChunkWriter(std::string path, ReaderBase *reader) : local_reader(reader), path(path), chunk_size(24*3), chunk_count(1), frame_count(1), is_writing(false), default_extension(".webm"), default_vcodec("libvpx"), default_acodec("libvorbis"), last_frame_needed(false), is_open(false) { @@ -54,10 +54,10 @@ ChunkWriter::ChunkWriter(string path, ReaderBase *reader) : } // get a formatted path of a specific chunk -string ChunkWriter::get_chunk_path(int64_t chunk_number, string folder, string extension) +std::string ChunkWriter::get_chunk_path(int64_t chunk_number, std::string folder, std::string extension) { // Create path of new chunk video - stringstream chunk_count_string; + std::stringstream chunk_count_string; chunk_count_string << chunk_number; QString padded_count = "%1"; //chunk_count_string.str().c_str(); padded_count = padded_count.arg(chunk_count_string.str().c_str(), 6, '0'); @@ -274,7 +274,7 @@ void ChunkWriter::Close() void ChunkWriter::write_json_meta_data() { // Load path of chunk folder - string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString(); + std::string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString(); // Write JSON file ofstream myfile; @@ -284,7 +284,7 @@ void ChunkWriter::write_json_meta_data() } // check for chunk folder -void ChunkWriter::create_folder(string path) +void ChunkWriter::create_folder(std::string path) { QDir dir(path.c_str()); if (!dir.exists()) { @@ -303,5 +303,3 @@ void ChunkWriter::Open() { is_open = true; } - - From f927cc0c3cb78a72cc2ff6f5747603e224537c4c Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:48:57 -0400 Subject: [PATCH 12/36] Color/Coordinate: std:: prefixes --- include/Color.h | 8 ++++---- include/Coordinate.h | 4 ++-- src/Color.cpp | 10 +++++----- src/Coordinate.cpp | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/Color.h b/include/Color.h index d06bee91..33b05574 100644 --- a/include/Color.h +++ b/include/Color.h @@ -54,7 +54,7 @@ namespace openshot { Color() {}; /// Constructor which takes a HEX color code - Color(string color_hex); + Color(std::string color_hex); /// Constructor which takes R,G,B,A Color(unsigned char Red, unsigned char Green, unsigned char Blue, unsigned char Alpha); @@ -63,15 +63,15 @@ namespace openshot { Color(Keyframe Red, Keyframe Green, Keyframe Blue, Keyframe Alpha); /// Get the HEX value of a color at a specific frame - string GetColorHex(int64_t frame_number); + std::string GetColorHex(int64_t frame_number); /// Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different colors) static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/include/Coordinate.h b/include/Coordinate.h index 6ab296dc..6379d485 100644 --- a/include/Coordinate.h +++ b/include/Coordinate.h @@ -68,9 +68,9 @@ namespace openshot { Coordinate(double x, double y); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/src/Color.cpp b/src/Color.cpp index b219e695..9266800d 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -53,7 +53,7 @@ Color::Color(Keyframe Red, Keyframe Green, Keyframe Blue, Keyframe Alpha) } // Constructor which takes a HEX color code -Color::Color(string color_hex) +Color::Color(std::string color_hex) { // Create a QColor from hex QColor color(QString::fromStdString(color_hex)); @@ -64,7 +64,7 @@ Color::Color(string color_hex) } // Get the HEX value of a color at a specific frame -string Color::GetColorHex(int64_t frame_number) { +std::string Color::GetColorHex(int64_t frame_number) { int r = red.GetInt(frame_number); int g = green.GetInt(frame_number); @@ -85,7 +85,7 @@ long Color::GetDistance(long R1, long G1, long B1, long R2, long G2, long B2) } // Generate JSON string of this object -string Color::Json() { +std::string Color::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -106,14 +106,14 @@ Json::Value Color::JsonValue() { } // Load JSON string into this object -void Color::SetJson(string value) { +void Color::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/Coordinate.cpp b/src/Coordinate.cpp index 739d693f..0a8349b7 100644 --- a/src/Coordinate.cpp +++ b/src/Coordinate.cpp @@ -45,7 +45,7 @@ Coordinate::Coordinate(double x, double y) : // Generate JSON string of this object -string Coordinate::Json() { +std::string Coordinate::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -69,14 +69,14 @@ Json::Value Coordinate::JsonValue() { } // Load JSON string into this object -void Coordinate::SetJson(string value) { +void Coordinate::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From 3879b0904700aff8fe511653b8011336a0a36cb3 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:54:06 -0400 Subject: [PATCH 13/36] FrameMapper/KeyFrame/Point: std:: prefixes --- include/FrameMapper.h | 13 +++++-------- include/KeyFrame.h | 11 ++++------- include/Point.h | 6 ++---- src/FrameMapper.cpp | 8 ++++---- src/KeyFrame.cpp | 28 ++++++++++++++-------------- src/Point.cpp | 6 +++--- 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/include/FrameMapper.h b/include/FrameMapper.h index 78e8944e..f2b030a3 100644 --- a/include/FrameMapper.h +++ b/include/FrameMapper.h @@ -49,9 +49,6 @@ #include "OpenMPUtilities.h" - -using namespace std; - namespace openshot { /** @@ -166,8 +163,8 @@ namespace openshot public: // Init some containers - vector fields; // List of all fields - vector frames; // List of all frames + std::vector fields; // List of all fields + std::vector frames; // List of all frames /// Default constructor for openshot::FrameMapper class FrameMapper(ReaderBase *reader, Fraction target_fps, PulldownType target_pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout); @@ -199,11 +196,11 @@ namespace openshot bool IsOpen(); /// Return the type name of the class - string Name() { return "FrameMapper"; }; + std::string Name() { return "FrameMapper"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/include/KeyFrame.h b/include/KeyFrame.h index 14f519a1..af8a9f3e 100644 --- a/include/KeyFrame.h +++ b/include/KeyFrame.h @@ -42,9 +42,6 @@ #include "Point.h" #include "Json.h" -using namespace std; -using namespace openshot; - namespace openshot { /** @@ -92,8 +89,8 @@ namespace openshot { double Bernstein(int64_t n, int64_t i, double t); public: - vector Points; ///< Vector of all Points - vector Values; ///< Vector of all Values (i.e. the processed coordinates from the curve) + std::vector Points; ///< Vector of all Points + std::vector Values; ///< Vector of all Values (i.e. the processed coordinates from the curve) /// Default constructor for the Keyframe class Keyframe(); @@ -160,9 +157,9 @@ namespace openshot { bool IsIncreasing(int index); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /** diff --git a/include/Point.h b/include/Point.h index d9a5e33d..3fdcd917 100644 --- a/include/Point.h +++ b/include/Point.h @@ -35,8 +35,6 @@ #include "Exceptions.h" #include "Json.h" -using namespace std; - namespace openshot { /** @@ -121,9 +119,9 @@ namespace openshot void Initialize_RightHandle(float x, float y); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index ff7cf1ce..df8d37b1 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -675,7 +675,7 @@ void FrameMapper::Close() // Generate JSON string of this object -string FrameMapper::Json() { +std::string FrameMapper::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -693,14 +693,14 @@ Json::Value FrameMapper::JsonValue() { } // Load JSON string into this object -void FrameMapper::SetJson(string value) { +void FrameMapper::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -820,7 +820,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr frame, int64_t orig if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code); throw ErrorEncodingVideo("Error while resampling audio in frame mapper", frame->number); } diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 94618135..895104d7 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -307,7 +307,7 @@ bool Keyframe::IsIncreasing(int index) int64_t next_repeats = 0; // Loop backwards and look for the next unique value - for (vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { + for (std::vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { previous_value = long(round((*backwards_it).Y)); if (previous_value == current_value) { // Found same value @@ -319,7 +319,7 @@ bool Keyframe::IsIncreasing(int index) } // Loop forwards and look for the next unique value - for (vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { + for (std::vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { next_value = long(round((*forwards_it).Y)); if (next_value == current_value) { // Found same value @@ -340,7 +340,7 @@ bool Keyframe::IsIncreasing(int index) } // Generate JSON string of this object -string Keyframe::Json() { +std::string Keyframe::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -365,14 +365,14 @@ Json::Value Keyframe::JsonValue() { } // Load JSON string into this object -void Keyframe::SetJson(string value) { +void Keyframe::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -436,7 +436,7 @@ Fraction Keyframe::GetRepeatFraction(int64_t index) int64_t next_repeats = 0; // Loop backwards and look for the next unique value - for (vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { + for (std::vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { previous_value = long(round((*backwards_it).Y)); if (previous_value == current_value) { // Found same value @@ -448,7 +448,7 @@ Fraction Keyframe::GetRepeatFraction(int64_t index) } // Loop forwards and look for the next unique value - for (vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { + for (std::vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { next_value = long(round((*forwards_it).Y)); if (next_value == current_value) { // Found same value @@ -483,7 +483,7 @@ double Keyframe::GetDelta(int64_t index) int64_t next_repeats = 0; // Loop backwards and look for the next unique value - for (vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { + for (std::vector::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) { previous_value = long(round((*backwards_it).Y)); if (previous_value == current_value) { // Found same value @@ -495,7 +495,7 @@ double Keyframe::GetDelta(int64_t index) } // Loop forwards and look for the next unique value - for (vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { + for (std::vector::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) { next_value = long(round((*forwards_it).Y)); if (next_value == current_value) { // Found same value @@ -605,7 +605,7 @@ void Keyframe::PrintPoints() { Process(); cout << fixed << setprecision(4); - for (vector::iterator it = Points.begin(); it != Points.end(); it++) { + for (std::vector::iterator it = Points.begin(); it != Points.end(); it++) { Point p = *it; cout << p.co.X << "\t" << p.co.Y << endl; } @@ -619,7 +619,7 @@ void Keyframe::PrintValues() { cout << fixed << setprecision(4); cout << "Frame Number (X)\tValue (Y)\tIs Increasing\tRepeat Numerator\tRepeat Denominator\tDelta (Y Difference)" << endl; - for (vector::iterator it = Values.begin() + 1; it != Values.end(); it++) { + for (std::vector::iterator it = Values.begin() + 1; it != Values.end(); it++) { Coordinate c = *it; cout << long(round(c.X)) << "\t" << c.Y << "\t" << IsIncreasing(c.X) << "\t" << GetRepeatFraction(c.X).num << "\t" << GetRepeatFraction(c.X).den << "\t" << GetDelta(c.X) << endl; } @@ -722,13 +722,13 @@ void Keyframe::ProcessSegment(int Segment, Point p1, Point p2) { double X_diff = p2.co.X - p1.co.X; double Y_diff = p2.co.Y - p1.co.Y; - vector segment_coordinates; + std::vector segment_coordinates; segment_coordinates.push_back(p1.co); segment_coordinates.push_back(Coordinate(p1.co.X + (p1.handle_right.X * X_diff), p1.co.Y + (p1.handle_right.Y * Y_diff))); segment_coordinates.push_back(Coordinate(p1.co.X + (p2.handle_left.X * X_diff), p1.co.Y + (p2.handle_left.Y * Y_diff))); segment_coordinates.push_back(p2.co); - vector raw_coordinates; + std::vector raw_coordinates; int64_t npts = segment_coordinates.size(); int64_t icount, jcount; double step, t; @@ -904,7 +904,7 @@ void Keyframe::ScalePoints(double scale) void Keyframe::FlipPoints() { // Loop through each point - vector FlippedPoints; + std::vector FlippedPoints; for (int64_t point_index = 0, reverse_index = Points.size() - 1; point_index < Points.size(); point_index++, reverse_index--) { // Flip the points Point p = Points[point_index]; diff --git a/src/Point.cpp b/src/Point.cpp index fd23da55..0ff340d3 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -108,7 +108,7 @@ void Point::Initialize_RightHandle(float x, float y) { } // Generate JSON string of this object -string Point::Json() { +std::string Point::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -132,14 +132,14 @@ Json::Value Point::JsonValue() { } // Load JSON string into this object -void Point::SetJson(string value) { +void Point::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From ed895f05b9a590d44a8484882d0ea3ea502381b7 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:56:52 -0400 Subject: [PATCH 14/36] Profiles/Settings: std:: prefixes --- include/Profiles.h | 10 ++++------ include/Settings.h | 4 +--- src/Profiles.cpp | 32 ++++++++++++++++---------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/Profiles.h b/include/Profiles.h index a6e3d22d..bc5fe3e0 100644 --- a/include/Profiles.h +++ b/include/Profiles.h @@ -45,8 +45,6 @@ #include "Fraction.h" #include "Json.h" -using namespace std; - namespace openshot { @@ -58,7 +56,7 @@ namespace openshot */ struct ProfileInfo { - string description; ///< The description of this profile. + std::string description; ///< The description of this profile. int height; ///< The height of the video (in pixels) int width; ///< The width of the video (in pixels) int pixel_format; ///< The pixel format (i.e. YUV420P, RGB24, etc...) @@ -89,12 +87,12 @@ namespace openshot /// @brief Constructor for Profile. /// @param path The folder path / location of a profile file - Profile(string path); + Profile(std::string path); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object + std::string Json(); ///< Generate JSON string of this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object }; diff --git a/include/Settings.h b/include/Settings.h index 11d7f76c..56a84fd7 100644 --- a/include/Settings.h +++ b/include/Settings.h @@ -45,8 +45,6 @@ #include "JuceHeader.h" -using namespace std; - namespace openshot { /** @@ -124,7 +122,7 @@ namespace openshot { int HW_EN_DEVICE_SET = 0; /// The audio device name to use during playback - string PLAYBACK_AUDIO_DEVICE_NAME = ""; + std::string PLAYBACK_AUDIO_DEVICE_NAME = ""; /// Create or get an instance of this logger singleton (invoke the class with this method) static Settings * Instance(); diff --git a/src/Profiles.cpp b/src/Profiles.cpp index e57f7aa3..1c1f493b 100644 --- a/src/Profiles.cpp +++ b/src/Profiles.cpp @@ -35,7 +35,7 @@ using namespace openshot; // @brief Constructor for Profile. // @param path The folder path / location of a profile file -Profile::Profile(string path) { +Profile::Profile(std::string path) { bool read_file = false; @@ -67,51 +67,51 @@ Profile::Profile(string path) { // Split current line QStringList parts = line.split( "=" ); - string setting = parts[0].toStdString(); - string value = parts[1].toStdString(); + std::string setting = parts[0].toStdString(); + std::string value = parts[1].toStdString(); int value_int = 0; // update struct (based on line number) if (setting == "description") info.description = value; else if (setting == "frame_rate_num") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.fps.num = value_int; } else if (setting == "frame_rate_den") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.fps.den = value_int; } else if (setting == "width") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.width = value_int; } else if (setting == "height") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.height = value_int; } else if (setting == "progressive") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.interlaced_frame = !(bool)value_int; } else if (setting == "sample_aspect_num") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.pixel_ratio.num = value_int; } else if (setting == "sample_aspect_den") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.pixel_ratio.den = value_int; } else if (setting == "display_aspect_num") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.display_ratio.num = value_int; } else if (setting == "display_aspect_den") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.display_ratio.den = value_int; } else if (setting == "colorspace") { - stringstream(value) >> value_int; + std::stringstream(value) >> value_int; info.pixel_format = value_int; } } @@ -133,7 +133,7 @@ Profile::Profile(string path) { } // Generate JSON string of this object -string Profile::Json() { +std::string Profile::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -163,14 +163,14 @@ Json::Value Profile::JsonValue() { } // Load JSON string into this object -void Profile::SetJson(string value) { +void Profile::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From b56ebf5765a443b41de9ff9949464a5921e0ddb0 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 22:59:56 -0400 Subject: [PATCH 15/36] QtPlayer/QtImageReader: std:: prefixes --- include/QtImageReader.h | 14 ++++++-------- include/QtPlayer.h | 14 ++++++-------- src/QtImageReader.cpp | 10 +++++----- src/QtPlayer.cpp | 6 +++--- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/include/QtImageReader.h b/include/QtImageReader.h index 814e3cb3..49a15fbd 100644 --- a/include/QtImageReader.h +++ b/include/QtImageReader.h @@ -40,8 +40,6 @@ #include "Exceptions.h" #include "ReaderBase.h" -using namespace std; - namespace openshot { @@ -67,7 +65,7 @@ namespace openshot class QtImageReader : public ReaderBase { private: - string path; + std::string path; std::shared_ptr image; ///> Original image (full quality) std::shared_ptr cached_image; ///> Scaled for performance bool is_open; ///> Is Reader opened @@ -77,12 +75,12 @@ namespace openshot /// Constructor for QtImageReader. This automatically opens the media file and loads /// frame 1, or it throws one of the following exceptions. - QtImageReader(string path); + QtImageReader(std::string path); /// Constructor for QtImageReader. This only opens the media file to inspect its properties /// if inspect_reader=true. When not inspecting the media file, it's much faster, and useful /// when you are inflating the object using JSON after instantiating it. - QtImageReader(string path, bool inspect_reader); + QtImageReader(std::string path, bool inspect_reader); virtual ~QtImageReader(); @@ -103,11 +101,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "QtImageReader"; }; + std::string Name() { return "QtImageReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/include/QtPlayer.h b/include/QtPlayer.h index 5d0beba6..b3cd9d05 100644 --- a/include/QtPlayer.h +++ b/include/QtPlayer.h @@ -38,8 +38,6 @@ #include "Qt/PlayerPrivate.h" #include "RendererBase.h" -using namespace std; - namespace openshot { /** @@ -63,26 +61,26 @@ namespace openshot void CloseAudioDevice(); /// Get Error (if any) - string GetError(); + std::string GetError(); /// Get Audio Devices from JUCE - vector GetAudioDeviceNames(); + std::vector GetAudioDeviceNames(); /// Play the video void Play(); - + /// Display a loading animation void Loading(); - + /// Get the current mode PlaybackMode Mode(); /// Pause the video void Pause(); - + /// Get the current frame number being played int Position(); - + /// Seek to a specific frame in the player void Seek(int64_t new_frame); diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index 9107e51f..95a99536 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -44,14 +44,14 @@ using namespace openshot; -QtImageReader::QtImageReader(string path) : path(path), is_open(false) +QtImageReader::QtImageReader(std::string path) : path(path), is_open(false) { // Open and Close the reader, to populate its attributes (such as height, width, etc...) Open(); Close(); } -QtImageReader::QtImageReader(string path, bool inspect_reader) : path(path), is_open(false) +QtImageReader::QtImageReader(std::string path, bool inspect_reader) : path(path), is_open(false) { // Open and Close the reader, to populate its attributes (such as height, width, etc...) if (inspect_reader) { @@ -277,7 +277,7 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) } // Generate JSON string of this object -string QtImageReader::Json() { +std::string QtImageReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -296,14 +296,14 @@ Json::Value QtImageReader::JsonValue() { } // Load JSON string into this object -void QtImageReader::SetJson(string value) { +void QtImageReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/QtPlayer.cpp b/src/QtPlayer.cpp index c53de79d..35cfe2b1 100644 --- a/src/QtPlayer.cpp +++ b/src/QtPlayer.cpp @@ -63,7 +63,7 @@ void QtPlayer::CloseAudioDevice() } // Return any error string during initialization -string QtPlayer::GetError() { +std::string QtPlayer::GetError() { if (reader && threads_started) { // Get error from audio thread (if any) return p->audioPlayback->getError(); @@ -73,11 +73,11 @@ string QtPlayer::GetError() { } /// Get Audio Devices from JUCE -vector QtPlayer::GetAudioDeviceNames() { +std::vector QtPlayer::GetAudioDeviceNames() { if (reader && threads_started) { return p->audioPlayback->getAudioDeviceNames(); } else { - return vector(); + return std::vector(); } } From 071fc8caadf64b6276eb23ddf7350dc683f53f1a Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:02:36 -0400 Subject: [PATCH 16/36] ImageReader/ImageWriter: std:: prefixes --- include/ImageReader.h | 12 ++++++------ include/ImageWriter.h | 10 ++++------ src/ImageReader.cpp | 10 +++++----- src/ImageWriter.cpp | 4 ++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/ImageReader.h b/include/ImageReader.h index b02d2f04..a081b03d 100644 --- a/include/ImageReader.h +++ b/include/ImageReader.h @@ -73,7 +73,7 @@ namespace openshot class ImageReader : public ReaderBase { private: - string path; + std::string path; std::shared_ptr image; bool is_open; @@ -81,12 +81,12 @@ namespace openshot /// Constructor for ImageReader. This automatically opens the media file and loads /// frame 1, or it throws one of the following exceptions. - ImageReader(string path); + ImageReader(std::string path); /// Constructor for ImageReader. This only opens the media file to inspect its properties /// if inspect_reader=true. When not inspecting the media file, it's much faster, and useful /// when you are inflating the object using JSON after instantiating it. - ImageReader(string path, bool inspect_reader); + ImageReader(std::string path, bool inspect_reader); /// Close File void Close(); @@ -105,11 +105,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "ImageReader"; }; + std::string Name() { return "ImageReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/include/ImageWriter.h b/include/ImageWriter.h index c1d2726a..87e8a9a9 100644 --- a/include/ImageWriter.h +++ b/include/ImageWriter.h @@ -53,8 +53,6 @@ #include "OpenMPUtilities.h" #include "MagickUtilities.h" -using namespace std; - namespace openshot { @@ -88,12 +86,12 @@ namespace openshot class ImageWriter : public WriterBase { private: - string path; + std::string path; int cache_size; bool is_writing; bool is_open; int64_t write_video_count; - vector frames; + std::vector frames; int image_quality; int number_of_loops; bool combine_frames; @@ -104,7 +102,7 @@ namespace openshot /// @brief Constructor for ImageWriter. Throws one of the following exceptions. /// @param path The path of the file you want to create - ImageWriter(string path); + ImageWriter(std::string path); /// @brief Close the writer and encode/output final image to the disk. This is a requirement of ImageMagick, /// which writes all frames of a multi-frame image at one time. @@ -131,7 +129,7 @@ namespace openshot /// @param quality Quality of image (0 to 100, 70 is default) /// @param loops Number of times to repeat the image (used on certain multi-frame image formats, such as GIF) /// @param combine Combine frames into a single image (if possible), or save each frame as its own image - void SetVideoOptions(string format, Fraction fps, int width, int height, + void SetVideoOptions(std::string format, Fraction fps, int width, int height, int quality, int loops, bool combine); /// @brief Add a frame to the stack waiting to be encoded. diff --git a/src/ImageReader.cpp b/src/ImageReader.cpp index a0b7e8f3..42dd58d6 100644 --- a/src/ImageReader.cpp +++ b/src/ImageReader.cpp @@ -35,14 +35,14 @@ using namespace openshot; -ImageReader::ImageReader(string path) : path(path), is_open(false) +ImageReader::ImageReader(std::string path) : path(path), is_open(false) { // Open and Close the reader, to populate its attributes (such as height, width, etc...) Open(); Close(); } -ImageReader::ImageReader(string path, bool inspect_reader) : path(path), is_open(false) +ImageReader::ImageReader(std::string path, bool inspect_reader) : path(path), is_open(false) { // Open and Close the reader, to populate its attributes (such as height, width, etc...) if (inspect_reader) { @@ -136,7 +136,7 @@ std::shared_ptr ImageReader::GetFrame(int64_t requested_frame) } // Generate JSON string of this object -string ImageReader::Json() { +std::string ImageReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -155,14 +155,14 @@ Json::Value ImageReader::JsonValue() { } // Load JSON string into this object -void ImageReader::SetJson(string value) { +void ImageReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/ImageWriter.cpp b/src/ImageWriter.cpp index 2b1e3fc0..376feb62 100644 --- a/src/ImageWriter.cpp +++ b/src/ImageWriter.cpp @@ -38,7 +38,7 @@ using namespace openshot; -ImageWriter::ImageWriter(string path) : +ImageWriter::ImageWriter(std::string path) : path(path), cache_size(8), is_writing(false), write_video_count(0), image_quality(75), number_of_loops(1), combine_frames(true), is_open(false) { @@ -48,7 +48,7 @@ ImageWriter::ImageWriter(string path) : } // Set video export options -void ImageWriter::SetVideoOptions(string format, Fraction fps, int width, int height, +void ImageWriter::SetVideoOptions(std::string format, Fraction fps, int width, int height, int quality, int loops, bool combine) { // Set frames per second (if provided) From 38e82e7a9de9d573e0a2c51f60610c241ef0d6bc Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:04:19 -0400 Subject: [PATCH 17/36] EffectBase/EffectInfo: std:: prefixes --- include/EffectBase.h | 14 ++++++-------- include/EffectInfo.h | 6 ++---- src/EffectBase.cpp | 6 +++--- src/EffectInfo.cpp | 4 ++-- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/EffectBase.h b/include/EffectBase.h index a16b6620..8d0326c6 100644 --- a/include/EffectBase.h +++ b/include/EffectBase.h @@ -38,8 +38,6 @@ #include "Json.h" #include "Frame.h" -using namespace std; - namespace openshot { /** @@ -51,10 +49,10 @@ namespace openshot */ struct EffectInfoStruct { - string class_name; ///< The class name of the effect - string short_name; ///< A short name of the effect, commonly used for icon names, etc... - string name; ///< The name of the effect - string description; ///< The description of this effect and what it does + std::string class_name; ///< The class name of the effect + std::string short_name; ///< A short name of the effect, commonly used for icon names, etc... + std::string name; ///< The name of the effect + std::string description; ///< The description of this effect and what it does bool has_video; ///< Determines if this effect manipulates the image of a frame bool has_audio; ///< Determines if this effect manipulates the audio of a frame }; @@ -97,8 +95,8 @@ namespace openshot void InitEffectInfo(); /// Get and Set JSON methods - virtual string Json() = 0; ///< Generate JSON string of this object - virtual void SetJson(string value) = 0; ///< Load JSON string into this object + virtual std::string Json() = 0; ///< Generate JSON string of this object + virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object Json::Value JsonInfo(); ///< Generate JSON object of meta data / info diff --git a/include/EffectInfo.h b/include/EffectInfo.h index 7806f096..1015b0da 100644 --- a/include/EffectInfo.h +++ b/include/EffectInfo.h @@ -34,8 +34,6 @@ #include "Effects.h" -using namespace std; - namespace openshot { @@ -49,10 +47,10 @@ namespace openshot { public: // Create an instance of an effect (factory style) - EffectBase* CreateEffect(string effect_type); + EffectBase* CreateEffect(std::string effect_type); /// JSON methods - static string Json(); ///< Generate JSON string of this object + static std::string Json(); ///< Generate JSON string of this object static Json::Value JsonValue(); ///< Generate Json::JsonValue for this object }; diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index 463a2c2c..caa5e722 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -74,7 +74,7 @@ int EffectBase::constrain(int color_value) } // Generate JSON string of this object -string EffectBase::Json() { +std::string EffectBase::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -98,14 +98,14 @@ Json::Value EffectBase::JsonValue() { } // Load JSON string into this object -void EffectBase::SetJson(string value) { +void EffectBase::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; diff --git a/src/EffectInfo.cpp b/src/EffectInfo.cpp index 0b9c360d..8fb8a4fe 100644 --- a/src/EffectInfo.cpp +++ b/src/EffectInfo.cpp @@ -35,14 +35,14 @@ using namespace openshot; // Generate JSON string of this object -string EffectInfo::Json() { +std::string EffectInfo::Json() { // Return formatted string return JsonValue().toStyledString(); } // Create a new effect instance -EffectBase* EffectInfo::CreateEffect(string effect_type) { +EffectBase* EffectInfo::CreateEffect(std::string effect_type) { // Init the matching effect object if (effect_type == "Bars") return new Bars(); From 33cfb8b3dc7c1800c9b81099708b0c347d935b30 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:08:19 -0400 Subject: [PATCH 18/36] Clip/DummyReader: std:: prefixes --- include/Clip.h | 17 +++++++---------- include/DummyReader.h | 8 +++----- src/Clip.cpp | 20 ++++++++++---------- src/DummyReader.cpp | 6 +++--- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/include/Clip.h b/include/Clip.h index c092c2ad..3e978429 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -51,9 +51,6 @@ #include "ReaderBase.h" #include "JuceHeader.h" -using namespace std; -using namespace openshot; - namespace openshot { /// Comparison method for sorting effect pointers (by Position, Layer, and Order). Effects are sorted @@ -107,7 +104,7 @@ namespace openshot { private: bool waveform; ///< Should a waveform be used instead of the clip's image - list effects; /// effects; /// apply_effects(std::shared_ptr frame); /// Get file extension - string get_file_extension(string path); + std::string get_file_extension(std::string path); /// Get a frame object or create a blank one std::shared_ptr GetOrCreateFrame(int64_t number); @@ -159,7 +156,7 @@ namespace openshot { /// @brief Constructor with filepath (reader is automatically created... by guessing file extensions) /// @param path The path of a reader (video file, image file, etc...). The correct reader will be used automatically. - Clip(string path); + Clip(std::string path); /// @brief Constructor with reader /// @param new_reader The reader to be used by this clip @@ -176,7 +173,7 @@ namespace openshot { void Close(); /// Return the list of effects on the timeline - list Effects() { return effects; }; + std::list Effects() { return effects; }; /// @brief Get an openshot::Frame object for a specific frame number of this timeline. /// @@ -199,14 +196,14 @@ namespace openshot { void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video) /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); /// @brief Remove an effect from the clip /// @param effect Remove an effect from the clip. diff --git a/include/DummyReader.h b/include/DummyReader.h index adae512f..00046857 100644 --- a/include/DummyReader.h +++ b/include/DummyReader.h @@ -43,8 +43,6 @@ #include "Exceptions.h" #include "Fraction.h" -using namespace std; - namespace openshot { /** @@ -86,11 +84,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "DummyReader"; }; + std::string Name() { return "DummyReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/src/Clip.cpp b/src/Clip.cpp index 653cb667..842f789f 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -152,13 +152,13 @@ Clip::Clip(ReaderBase* new_reader) : resampler(NULL), audio_cache(NULL), reader( } // Constructor with filepath -Clip::Clip(string path) : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL) +Clip::Clip(std::string path) : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL) { // Init all default settings init_settings(); // Get file extension (and convert to lower case) - string ext = get_file_extension(path); + std::string ext = get_file_extension(path); transform(ext.begin(), ext.end(), ext.begin(), ::tolower); // Determine if common video formats @@ -354,7 +354,7 @@ std::shared_ptr Clip::GetFrame(int64_t requested_frame) } // Get file extension -string Clip::get_file_extension(string path) +std::string Clip::get_file_extension(std::string path) { // return last part of path return path.substr(path.find_last_of(".") + 1); @@ -645,14 +645,14 @@ std::shared_ptr Clip::GetOrCreateFrame(int64_t number) } // Generate JSON string of this object -string Clip::Json() { +std::string Clip::Json() { // Return formatted string return JsonValue().toStyledString(); } // Get all properties for a specific frame -string Clip::PropertiesJSON(int64_t requested_frame) { +std::string Clip::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; @@ -782,7 +782,7 @@ Json::Value Clip::JsonValue() { root["effects"] = Json::Value(Json::arrayValue); // loop through effects - list::iterator effect_itr; + std::list::iterator effect_itr; for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr) { // Get clip object from the iterator @@ -798,14 +798,14 @@ Json::Value Clip::JsonValue() { } // Load JSON string into this object -void Clip::SetJson(string value) { +void Clip::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -943,7 +943,7 @@ void Clip::SetJsonValue(Json::Value root) { } // Create new reader (and load properties) - string type = root["reader"]["type"].asString(); + std::string type = root["reader"]["type"].asString(); if (type == "FFmpegReader") { @@ -1025,7 +1025,7 @@ void Clip::RemoveEffect(EffectBase* effect) std::shared_ptr Clip::apply_effects(std::shared_ptr frame) { // Find Effects at this position and layer - list::iterator effect_itr; + std::list::iterator effect_itr; for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr) { // Get clip object from the iterator diff --git a/src/DummyReader.cpp b/src/DummyReader.cpp index 346430dc..8b2abedf 100644 --- a/src/DummyReader.cpp +++ b/src/DummyReader.cpp @@ -124,7 +124,7 @@ std::shared_ptr DummyReader::GetFrame(int64_t requested_frame) } // Generate JSON string of this object -string DummyReader::Json() { +std::string DummyReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -142,14 +142,14 @@ Json::Value DummyReader::JsonValue() { } // Load JSON string into this object -void DummyReader::SetJson(string value) { +void DummyReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From f88fd7a47a9e602b97756a128fd91bb2d32ba1e7 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:10:59 -0400 Subject: [PATCH 19/36] FFmpegWriter: std:: prefixes --- include/FFmpegWriter.h | 30 ++++++++++++++---------------- src/FFmpegWriter.cpp | 40 ++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index 8b3a4673..97fd7726 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -57,8 +57,6 @@ #include "Settings.h" -using namespace std; - namespace openshot { /// This enumeration designates the type of stream when encoding (video or audio) @@ -144,7 +142,7 @@ namespace openshot { */ class FFmpegWriter : public WriterBase { private: - string path; + std::string path; int cache_size; bool is_writing; bool is_open; @@ -168,7 +166,7 @@ namespace openshot { int num_of_rescalers; int rescaler_position; - vector image_rescalers; + std::vector image_rescalers; int audio_outbuf_size; int audio_input_frame_size; @@ -183,16 +181,16 @@ namespace openshot { int original_channels; std::shared_ptr last_frame; - deque > spooled_audio_frames; - deque > spooled_video_frames; + std::deque > spooled_audio_frames; + std::deque > spooled_video_frames; - deque > queued_audio_frames; - deque > queued_video_frames; + std::deque > queued_audio_frames; + std::deque > queued_video_frames; - deque > processed_frames; - deque > deallocate_frames; + std::deque > processed_frames; + std::deque > deallocate_frames; - map, AVFrame *> av_frames; + std::map, AVFrame *> av_frames; /// Add an AVFrame to the cache void add_avframe(std::shared_ptr frame, AVFrame *av_frame); @@ -248,7 +246,7 @@ namespace openshot { /// @brief Constructor for FFmpegWriter. Throws one of the following exceptions. /// @param path The file path of the video file you want to open and read - FFmpegWriter(string path); + FFmpegWriter(std::string path); /// Close the writer void Close(); @@ -260,7 +258,7 @@ namespace openshot { bool IsOpen() { return is_open; }; /// Determine if codec name is valid - static bool IsValidCodec(string codec_name); + static bool IsValidCodec(std::string codec_name); /// Open writer void Open(); @@ -287,7 +285,7 @@ namespace openshot { /// @param channels The number of audio channels needed in this file /// @param channel_layout The 'layout' of audio channels (i.e. mono, stereo, surround, etc...) /// @param bit_rate The audio bit rate used during encoding - void SetAudioOptions(bool has_audio, string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate); + void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate); /// @brief Set the cache size /// @param new_size The number of frames to queue before writing to the file @@ -303,14 +301,14 @@ namespace openshot { /// @param interlaced Does this video need to be interlaced? /// @param top_field_first Which frame should be used as the top field? /// @param bit_rate The video bit rate used during encoding - void SetVideoOptions(bool has_video, string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate); + void SetVideoOptions(bool has_video, std::string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate); /// @brief Set custom options (some codecs accept additional params). This must be called after the /// PrepareStreams() method, otherwise the streams have not been initialized yet. /// @param stream The stream (openshot::StreamType) this option should apply to /// @param name The name of the option you want to set (i.e. qmin, qmax, etc...) /// @param value The new value of this option - void SetOption(StreamType stream, string name, string value); + void SetOption(StreamType stream, std::string name, std::string value); /// @brief Write the file header (after the options are set). This method is called automatically /// by the Open() method if this method has not yet been called. diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 37f3016a..1a4628df 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -83,7 +83,7 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int6 } #endif -FFmpegWriter::FFmpegWriter(string path) : +FFmpegWriter::FFmpegWriter(std::string path) : path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), audio_pts(0), video_pts(0), samples(NULL), audio_outbuf(NULL), audio_outbuf_size(0), audio_input_frame_size(0), audio_input_position(0), initial_audio_input_frame_size(0), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32), @@ -166,7 +166,7 @@ void FFmpegWriter::initialize_streams() { } // Set video export options -void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate) { +void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate) { // Set the video options if (codec.length() > 0) { AVCodec *new_codec; @@ -287,7 +287,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i } // Set audio export options -void FFmpegWriter::SetAudioOptions(bool has_audio, string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) { +void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) { // Set audio options if (codec.length() > 0) { AVCodec *new_codec = avcodec_find_encoder_by_name(codec.c_str()); @@ -322,11 +322,11 @@ void FFmpegWriter::SetAudioOptions(bool has_audio, string codec, int sample_rate } // Set custom options (some codecs accept additional params) -void FFmpegWriter::SetOption(StreamType stream, string name, string value) { +void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string value) { // Declare codec context AVCodecContext *c = NULL; AVStream *st = NULL; - stringstream convert(value); + std::stringstream convert(value); if (info.has_video && stream == VIDEO_STREAM && video_st) { st = video_st; @@ -468,7 +468,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) { AV_OPTION_SET(st, c->priv_data, name.c_str(), value.c_str(), c); } - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (std::string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM); // Muxing dictionary is not part of the codec context. // Just reusing SetOption function to set popular multiplexing presets. @@ -488,7 +488,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) { } /// Determine if codec name is valid -bool FFmpegWriter::IsValidCodec(string codec_name) { +bool FFmpegWriter::IsValidCodec(std::string codec_name) { // Initialize FFMpeg, and register all formats and codecs AV_REGISTER_ALL @@ -530,7 +530,7 @@ void FFmpegWriter::WriteHeader() { // Write the stream header, if any // Add general metadata (if any) - for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { + for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { av_dict_set(&oc->metadata, iter->first.c_str(), iter->second.c_str(), 0); } @@ -818,7 +818,7 @@ void FFmpegWriter::flush_encoders() { #endif // IS_FFMPEG_3_2 if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code); } if (!got_packet) { stop_encoding = 1; @@ -840,7 +840,7 @@ void FFmpegWriter::flush_encoders() { // Write packet error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code); } // Deallocate memory (if needed) @@ -875,7 +875,7 @@ void FFmpegWriter::flush_encoders() { error_code = avcodec_encode_audio2(audio_codec, &pkt, NULL, &got_packet); #endif if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code); } if (!got_packet) { stop_encoding = 1; @@ -901,7 +901,7 @@ void FFmpegWriter::flush_encoders() { // Write packet error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code); } // deallocate memory for packet @@ -1213,9 +1213,9 @@ AVStream *FFmpegWriter::add_video_stream() { AV_COPY_PARAMS_FROM_CONTEXT(st, c); #if (LIBAVFORMAT_VERSION_MAJOR < 58) - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (std::string)fmt->name + " : " + (std::string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE); #else - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (std::string)fmt->name + " : " + (std::string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags); #endif return st; @@ -1285,7 +1285,7 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) { audio_encoder_buffer = new uint8_t[audio_encoder_buffer_size]; // Add audio metadata (if any) - for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { + for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0); } @@ -1385,7 +1385,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { av_dict_free(&opts); // Add video metadata (if any) - for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { + for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0); } @@ -1720,12 +1720,12 @@ void FFmpegWriter::write_audio_packets(bool is_final) { /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code); } } if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code); } // deallocate AVFrame @@ -1868,7 +1868,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code); return false; } @@ -2000,7 +2000,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code); return false; } } From 1334450eec60e166efb7d00fd28d82c2cace43c3 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:14:38 -0400 Subject: [PATCH 20/36] Decklink*: std:: prefixes --- include/DecklinkInput.h | 2 +- include/DecklinkOutput.h | 6 +++--- include/DecklinkReader.h | 8 +++----- include/DecklinkWriter.h | 2 -- src/DecklinkReader.cpp | 6 +++--- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/DecklinkInput.h b/include/DecklinkInput.h index 87207505..3541811e 100644 --- a/include/DecklinkInput.h +++ b/include/DecklinkInput.h @@ -79,7 +79,7 @@ public: unsigned long final_frameCount; // Queue of raw video frames - deque raw_video_frames; + std::deque raw_video_frames; openshot::CacheMemory final_frames; // Convert between YUV and RGB diff --git a/include/DecklinkOutput.h b/include/DecklinkOutput.h index ebaa9ab4..9b1618b0 100644 --- a/include/DecklinkOutput.h +++ b/include/DecklinkOutput.h @@ -93,14 +93,14 @@ protected: unsigned long frameCount; //map temp_cache; - map temp_cache; + std::map temp_cache; BMDTimeValue frameRateDuration, frameRateScale; // Queue of raw video frames //deque final_frames; - deque final_frames; - deque > raw_video_frames; + std::deque final_frames; + std::deque > raw_video_frames; // Convert between YUV and RGB IDeckLinkOutput *deckLinkOutput; diff --git a/include/DecklinkReader.h b/include/DecklinkReader.h index 3dc7e23d..de077bdf 100644 --- a/include/DecklinkReader.h +++ b/include/DecklinkReader.h @@ -50,8 +50,6 @@ #include "Frame.h" #include "DecklinkInput.h" -using namespace std; - namespace openshot { @@ -117,11 +115,11 @@ namespace openshot bool IsOpen() { return is_open; }; /// Return the type name of the class - string Name() { return "DecklinkReader"; }; + std::string Name() { return "DecklinkReader"; }; /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/include/DecklinkWriter.h b/include/DecklinkWriter.h index 809890f3..84117d0e 100644 --- a/include/DecklinkWriter.h +++ b/include/DecklinkWriter.h @@ -50,8 +50,6 @@ #include "Frame.h" #include "DecklinkOutput.h" -using namespace std; - namespace openshot { diff --git a/src/DecklinkReader.cpp b/src/DecklinkReader.cpp index 3af5e3fc..6d727da1 100644 --- a/src/DecklinkReader.cpp +++ b/src/DecklinkReader.cpp @@ -246,7 +246,7 @@ std::shared_ptr DecklinkReader::GetFrame(int64_t requested_frame) // Generate JSON string of this object -string DecklinkReader::Json() { +std::string DecklinkReader::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -264,14 +264,14 @@ Json::Value DecklinkReader::JsonValue() { } // Load JSON string into this object -void DecklinkReader::SetJson(string value) { +void DecklinkReader::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; From be9a32c65aa9e70bab2799d67e5fd168640af102 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:18:04 -0400 Subject: [PATCH 21/36] *.h: Eliminate remaining 'using' statements --- include/Coordinate.h | 2 -- include/FFmpegReader.h | 2 -- include/ImageReader.h | 2 -- include/OpenMPUtilities.h | 3 --- include/PlayerBase.h | 2 -- 5 files changed, 11 deletions(-) diff --git a/include/Coordinate.h b/include/Coordinate.h index 6379d485..5bfd893a 100644 --- a/include/Coordinate.h +++ b/include/Coordinate.h @@ -36,8 +36,6 @@ #include "Fraction.h" #include "Json.h" -using namespace std; - namespace openshot { /** diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index 611ca9a8..a8b1740b 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -51,8 +51,6 @@ #include "Settings.h" -using namespace std; - namespace openshot { /** * @brief This struct holds the associated video frame and starting sample # for an audio packet. diff --git a/include/ImageReader.h b/include/ImageReader.h index a081b03d..8da450eb 100644 --- a/include/ImageReader.h +++ b/include/ImageReader.h @@ -46,8 +46,6 @@ #include "Exceptions.h" #include "MagickUtilities.h" -using namespace std; - namespace openshot { diff --git a/include/OpenMPUtilities.h b/include/OpenMPUtilities.h index e0087064..2dceb5bf 100644 --- a/include/OpenMPUtilities.h +++ b/include/OpenMPUtilities.h @@ -37,9 +37,6 @@ #include "Settings.h" -using namespace std; -using namespace openshot; - // 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) )) diff --git a/include/PlayerBase.h b/include/PlayerBase.h index f017c3f2..d5170562 100644 --- a/include/PlayerBase.h +++ b/include/PlayerBase.h @@ -34,8 +34,6 @@ #include #include "ReaderBase.h" -using namespace std; - namespace openshot { /** From 182db742deab9a252f0a74ac662588526c554bd8 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:22:04 -0400 Subject: [PATCH 22/36] ChunkWriter.cpp: std:: prefixes --- src/ChunkWriter.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ChunkWriter.cpp b/src/ChunkWriter.cpp index f7400953..f9d653b0 100644 --- a/src/ChunkWriter.cpp +++ b/src/ChunkWriter.cpp @@ -157,9 +157,9 @@ void ChunkWriter::WriteFrame(std::shared_ptr frame) // Write the frames once it reaches the correct chunk size if (frame_count % chunk_size == 0 && frame_count >= chunk_size) { - cout << "Done with chunk" << endl; - cout << "frame_count: " << frame_count << endl; - cout << "chunk_size: " << chunk_size << endl; + std::cout << "Done with chunk" << std::endl; + std::cout << "frame_count: " << frame_count << std::endl; + std::cout << "chunk_size: " << chunk_size << std::endl; // Pad an additional 12 frames for (int z = 0; z<12; z++) @@ -229,9 +229,9 @@ void ChunkWriter::Close() // Write the frames once it reaches the correct chunk size if (is_writing) { - cout << "Final chunk" << endl; - cout << "frame_count: " << frame_count << endl; - cout << "chunk_size: " << chunk_size << endl; + std::cout << "Final chunk" << std::endl; + std::cout << "frame_count: " << frame_count << std::endl; + std::cout << "chunk_size: " << chunk_size << std::endl; // Pad an additional 12 frames for (int z = 0; z<12; z++) @@ -277,9 +277,9 @@ void ChunkWriter::write_json_meta_data() std::string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString(); // Write JSON file - ofstream myfile; + std::ofstream myfile; myfile.open (json_path.c_str()); - myfile << local_reader->Json() << endl; + myfile << local_reader->Json() << std::endl; myfile.close(); } From 44076854ad165ced7540fdb8c724e3ac836b6b12 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:25:05 -0400 Subject: [PATCH 23/36] (Reader,Writer,Effect)Base.cpp: std:: prefixes --- src/EffectBase.cpp | 18 +++++------ src/ReaderBase.cpp | 78 +++++++++++++++++++++++----------------------- src/WriterBase.cpp | 72 +++++++++++++++++++++--------------------- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index caa5e722..8615bd69 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -50,15 +50,15 @@ void EffectBase::InitEffectInfo() // Display file information void EffectBase::DisplayInfo() { - cout << fixed << setprecision(2) << boolalpha; - cout << "----------------------------" << endl; - cout << "----- Effect Information -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Name: " << info.name << endl; - cout << "--> Description: " << info.description << endl; - cout << "--> Has Video: " << info.has_video << endl; - cout << "--> Has Audio: " << info.has_audio << endl; - cout << "----------------------------" << endl; + std::cout << std::fixed << std::setprecision(2) << std::boolalpha; + std::cout << "----------------------------" << std::endl; + std::cout << "----- Effect Information -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Name: " << info.name << std::endl; + std::cout << "--> Description: " << info.description << std::endl; + std::cout << "--> Has Video: " << info.has_video << std::endl; + std::cout << "--> Has Audio: " << info.has_audio << std::endl; + std::cout << "----------------------------" << std::endl; } // Constrain a color value from 0 to 255 diff --git a/src/ReaderBase.cpp b/src/ReaderBase.cpp index 36fb458a..ab651a9f 100644 --- a/src/ReaderBase.cpp +++ b/src/ReaderBase.cpp @@ -68,49 +68,49 @@ ReaderBase::ReaderBase() // Display file information void ReaderBase::DisplayInfo() { - cout << fixed << setprecision(2) << boolalpha; - cout << "----------------------------" << endl; - cout << "----- File Information -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Has Video: " << info.has_video << endl; - cout << "--> Has Audio: " << info.has_audio << endl; - cout << "--> Has Single Image: " << info.has_single_image << endl; - cout << "--> Duration: " << info.duration << " Seconds" << endl; - cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << endl; - cout << "----------------------------" << endl; - cout << "----- Video Attributes -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Width: " << info.width << endl; - cout << "--> Height: " << info.height << endl; - cout << "--> Pixel Format: " << info.pixel_format << endl; - cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << endl; - cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << endl; - cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << endl; - cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << endl; - cout << "--> Video Codec: " << info.vcodec << endl; - cout << "--> Video Length: " << info.video_length << " Frames" << endl; - cout << "--> Video Stream Index: " << info.video_stream_index << endl; - cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << endl; - cout << "--> Interlaced: " << info.interlaced_frame << endl; - cout << "--> Interlaced: Top Field First: " << info.top_field_first << endl; - cout << "----------------------------" << endl; - cout << "----- Audio Attributes -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Audio Codec: " << info.acodec << endl; - cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << endl; - cout << "--> Sample Rate: " << info.sample_rate << " Hz" << endl; - cout << "--> # of Channels: " << info.channels << endl; - cout << "--> Channel Layout: " << info.channel_layout << endl; - cout << "--> Audio Stream Index: " << info.audio_stream_index << endl; - cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << endl; - cout << "----------------------------" << endl; - cout << "--------- Metadata ---------" << endl; - cout << "----------------------------" << endl; + std::cout << std::fixed << std::setprecision(2) << std::boolalpha; + std::cout << "----------------------------" << std::endl; + std::cout << "----- File Information -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Has Video: " << info.has_video << std::endl; + std::cout << "--> Has Audio: " << info.has_audio << std::endl; + std::cout << "--> Has Single Image: " << info.has_single_image << std::endl; + std::cout << "--> Duration: " << info.duration << " Seconds" << std::endl; + std::cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "----- Video Attributes -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Width: " << info.width << std::endl; + std::cout << "--> Height: " << info.height << std::endl; + std::cout << "--> Pixel Format: " << info.pixel_format << std::endl; + std::cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << std::endl; + std::cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << std::endl; + std::cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << std::endl; + std::cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << std::endl; + std::cout << "--> Video Codec: " << info.vcodec << std::endl; + std::cout << "--> Video Length: " << info.video_length << " Frames" << std::endl; + std::cout << "--> Video Stream Index: " << info.video_stream_index << std::endl; + std::cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << std::endl; + std::cout << "--> Interlaced: " << info.interlaced_frame << std::endl; + std::cout << "--> Interlaced: Top Field First: " << info.top_field_first << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "----- Audio Attributes -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Audio Codec: " << info.acodec << std::endl; + std::cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << std::endl; + std::cout << "--> Sample Rate: " << info.sample_rate << " Hz" << std::endl; + std::cout << "--> # of Channels: " << info.channels << std::endl; + std::cout << "--> Channel Layout: " << info.channel_layout << std::endl; + std::cout << "--> Audio Stream Index: " << info.audio_stream_index << std::endl; + std::cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--------- Metadata ---------" << std::endl; + std::cout << "----------------------------" << std::endl; // Iterate through metadata std::map::iterator it; for (it = info.metadata.begin(); it != info.metadata.end(); it++) - cout << "--> " << it->first << ": " << it->second << endl; + std::cout << "--> " << it->first << ": " << it->second << std::endl; } // Generate Json::JsonValue for this object diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index 147ee9c0..56723352 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -100,42 +100,42 @@ void WriterBase::CopyReaderInfo(ReaderBase* reader) // Display file information void WriterBase::DisplayInfo() { - cout << fixed << setprecision(2) << boolalpha; - cout << "----------------------------" << endl; - cout << "----- File Information -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Has Video: " << info.has_video << endl; - cout << "--> Has Audio: " << info.has_audio << endl; - cout << "--> Has Single Image: " << info.has_single_image << endl; - cout << "--> Duration: " << info.duration << " Seconds" << endl; - cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << endl; - cout << "----------------------------" << endl; - cout << "----- Video Attributes -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Width: " << info.width << endl; - cout << "--> Height: " << info.height << endl; - cout << "--> Pixel Format: " << info.pixel_format << endl; - cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << endl; - cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << endl; - cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << endl; - cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << endl; - cout << "--> Video Codec: " << info.vcodec << endl; - cout << "--> Video Length: " << info.video_length << " Frames" << endl; - cout << "--> Video Stream Index: " << info.video_stream_index << endl; - cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << endl; - cout << "--> Interlaced: " << info.interlaced_frame << endl; - cout << "--> Interlaced: Top Field First: " << info.top_field_first << endl; - cout << "----------------------------" << endl; - cout << "----- Audio Attributes -----" << endl; - cout << "----------------------------" << endl; - cout << "--> Audio Codec: " << info.acodec << endl; - cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << endl; - cout << "--> Sample Rate: " << info.sample_rate << " Hz" << endl; - cout << "--> # of Channels: " << info.channels << endl; - cout << "--> Channel Layout: " << info.channel_layout << endl; - cout << "--> Audio Stream Index: " << info.audio_stream_index << endl; - cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << endl; - cout << "----------------------------" << endl; + std::cout << std::fixed << std::setprecision(2) << std::boolalpha; + std::cout << "----------------------------" << std::endl; + std::cout << "----- File Information -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Has Video: " << info.has_video << std::endl; + std::cout << "--> Has Audio: " << info.has_audio << std::endl; + std::cout << "--> Has Single Image: " << info.has_single_image << std::endl; + std::cout << "--> Duration: " << info.duration << " Seconds" << std::endl; + std::cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "----- Video Attributes -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Width: " << info.width << std::endl; + std::cout << "--> Height: " << info.height << std::endl; + std::cout << "--> Pixel Format: " << info.pixel_format << std::endl; + std::cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << std::endl; + std::cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << std::endl; + std::cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << std::endl; + std::cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << std::endl; + std::cout << "--> Video Codec: " << info.vcodec << std::endl; + std::cout << "--> Video Length: " << info.video_length << " Frames" << std::endl; + std::cout << "--> Video Stream Index: " << info.video_stream_index << std::endl; + std::cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << std::endl; + std::cout << "--> Interlaced: " << info.interlaced_frame << std::endl; + std::cout << "--> Interlaced: Top Field First: " << info.top_field_first << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "----- Audio Attributes -----" << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "--> Audio Codec: " << info.acodec << std::endl; + std::cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << std::endl; + std::cout << "--> Sample Rate: " << info.sample_rate << " Hz" << std::endl; + std::cout << "--> # of Channels: " << info.channels << std::endl; + std::cout << "--> Channel Layout: " << info.channel_layout << std::endl; + std::cout << "--> Audio Stream Index: " << info.audio_stream_index << std::endl; + std::cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << std::endl; + std::cout << "----------------------------" << std::endl; } // Generate JSON string of this object From 352fd6629aae253f62fa14b3ab7bb62558fa71fa Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 23:51:02 -0400 Subject: [PATCH 24/36] Remaining std:: prefixes --- include/MagickUtilities.h | 4 ++-- include/OpenMPUtilities.h | 4 ++-- include/Qt/AudioPlaybackThread.h | 8 ++++---- include/Timeline.h | 2 +- src/ChunkReader.cpp | 6 +++--- src/FFmpegReader.cpp | 22 +++++++++++----------- src/FFmpegWriter.cpp | 22 +++++++++++----------- src/Qt/PlayerDemo.cpp | 10 +++++----- src/QtImageReader.cpp | 12 ++++++------ src/Timeline.cpp | 4 ++-- 10 files changed, 47 insertions(+), 47 deletions(-) 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); From 45cfda413df93a9cdf5d10bd6af6db9d543a3a2e Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 01:08:03 -0400 Subject: [PATCH 25/36] (include/src)/effects/: std::prefixes --- include/effects/Bars.h | 8 +++----- include/effects/Blur.h | 8 +++----- include/effects/Brightness.h | 8 +++----- include/effects/ChromaKey.h | 8 +++----- include/effects/ColorShift.h | 8 +++----- include/effects/Crop.h | 8 +++----- include/effects/Deinterlace.h | 8 +++----- include/effects/Hue.h | 8 +++----- include/effects/Mask.h | 8 +++----- include/effects/Negate.h | 8 +++----- include/effects/Pixelate.h | 8 +++----- include/effects/Saturation.h | 8 +++----- include/effects/Shift.h | 8 +++----- include/effects/Wave.h | 8 +++----- src/effects/Bars.cpp | 8 ++++---- src/effects/Blur.cpp | 8 ++++---- src/effects/Brightness.cpp | 8 ++++---- src/effects/ChromaKey.cpp | 8 ++++---- src/effects/ColorShift.cpp | 8 ++++---- src/effects/Crop.cpp | 8 ++++---- src/effects/Deinterlace.cpp | 8 ++++---- src/effects/Hue.cpp | 8 ++++---- src/effects/Mask.cpp | 10 +++++----- src/effects/Negate.cpp | 8 ++++---- src/effects/Pixelate.cpp | 12 ++++++------ src/effects/Saturation.cpp | 8 ++++---- src/effects/Shift.cpp | 8 ++++---- src/effects/Wave.cpp | 8 ++++---- 28 files changed, 101 insertions(+), 129 deletions(-) diff --git a/include/effects/Bars.h b/include/effects/Bars.h index 515d2f11..43a77a2f 100644 --- a/include/effects/Bars.h +++ b/include/effects/Bars.h @@ -41,8 +41,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -91,14 +89,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Blur.h b/include/effects/Blur.h index 6d48c172..167e9303 100644 --- a/include/effects/Blur.h +++ b/include/effects/Blur.h @@ -49,8 +49,6 @@ #include "../QtImageReader.h" #include "../ChunkReader.h" -using namespace std; - namespace openshot { @@ -104,14 +102,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Brightness.h b/include/effects/Brightness.h index eb33d338..2a6ab912 100644 --- a/include/effects/Brightness.h +++ b/include/effects/Brightness.h @@ -48,8 +48,6 @@ #include "../QtImageReader.h" #include "../ChunkReader.h" -using namespace std; - namespace openshot { @@ -91,14 +89,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/ChromaKey.h b/include/effects/ChromaKey.h index 4440302b..d0fa31d8 100644 --- a/include/effects/ChromaKey.h +++ b/include/effects/ChromaKey.h @@ -43,8 +43,6 @@ #include "../Exceptions.h" #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -88,13 +86,13 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object // Get all properties for a specific frame - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/ColorShift.h b/include/effects/ColorShift.h index 44c7269b..e9c11d68 100644 --- a/include/effects/ColorShift.h +++ b/include/effects/ColorShift.h @@ -40,8 +40,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -95,14 +93,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Crop.h b/include/effects/Crop.h index 93b54e31..34cea89f 100644 --- a/include/effects/Crop.h +++ b/include/effects/Crop.h @@ -41,8 +41,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -90,14 +88,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Deinterlace.h b/include/effects/Deinterlace.h index 1559a09e..b411b023 100644 --- a/include/effects/Deinterlace.h +++ b/include/effects/Deinterlace.h @@ -44,8 +44,6 @@ #include "../Json.h" #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -84,13 +82,13 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object // Get all properties for a specific frame - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Hue.h b/include/effects/Hue.h index e6652391..4670b6bf 100644 --- a/include/effects/Hue.h +++ b/include/effects/Hue.h @@ -40,8 +40,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -81,14 +79,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Mask.h b/include/effects/Mask.h index de48219c..dba3b2d8 100644 --- a/include/effects/Mask.h +++ b/include/effects/Mask.h @@ -52,8 +52,6 @@ #include "../ImageReader.h" #endif -using namespace std; - namespace openshot { @@ -103,14 +101,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); /// Get the reader object of the mask grayscale image ReaderBase* Reader() { return reader; }; diff --git a/include/effects/Negate.h b/include/effects/Negate.h index f2437fee..3cbc7988 100644 --- a/include/effects/Negate.h +++ b/include/effects/Negate.h @@ -43,8 +43,6 @@ #include "../Exceptions.h" #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -72,13 +70,13 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object // Get all properties for a specific frame - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Pixelate.h b/include/effects/Pixelate.h index 06509894..3146d456 100644 --- a/include/effects/Pixelate.h +++ b/include/effects/Pixelate.h @@ -41,8 +41,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -90,14 +88,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Saturation.h b/include/effects/Saturation.h index a24d01ee..de3cc771 100644 --- a/include/effects/Saturation.h +++ b/include/effects/Saturation.h @@ -48,8 +48,6 @@ #include "../QtImageReader.h" #include "../ChunkReader.h" -using namespace std; - namespace openshot { @@ -88,14 +86,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Shift.h b/include/effects/Shift.h index db974ae2..243e442e 100644 --- a/include/effects/Shift.h +++ b/include/effects/Shift.h @@ -40,8 +40,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -84,14 +82,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/include/effects/Wave.h b/include/effects/Wave.h index 022173ea..62b08d1f 100644 --- a/include/effects/Wave.h +++ b/include/effects/Wave.h @@ -40,8 +40,6 @@ #include "../KeyFrame.h" -using namespace std; - namespace openshot { @@ -90,14 +88,14 @@ namespace openshot std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number); /// Get and Set JSON methods - string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + std::string Json(); ///< Generate JSON string of this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) - string PropertiesJSON(int64_t requested_frame); + std::string PropertiesJSON(int64_t requested_frame); }; } diff --git a/src/effects/Bars.cpp b/src/effects/Bars.cpp index 6d731d9c..544160c9 100644 --- a/src/effects/Bars.cpp +++ b/src/effects/Bars.cpp @@ -114,7 +114,7 @@ std::shared_ptr Bars::GetFrame(std::shared_ptr frame, int64_t fram } // Generate JSON string of this object -string Bars::Json() { +std::string Bars::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -137,14 +137,14 @@ Json::Value Bars::JsonValue() { } // Load JSON string into this object -void Bars::SetJson(string value) { +void Bars::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -185,7 +185,7 @@ void Bars::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Bars::PropertiesJSON(int64_t requested_frame) { +std::string Bars::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Blur.cpp b/src/effects/Blur.cpp index 7946e249..8bfdad11 100644 --- a/src/effects/Blur.cpp +++ b/src/effects/Blur.cpp @@ -252,7 +252,7 @@ void Blur::boxBlurT(unsigned char *scl, unsigned char *tcl, int w, int h, int r) } // Generate JSON string of this object -string Blur::Json() { +std::string Blur::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -274,14 +274,14 @@ Json::Value Blur::JsonValue() { } // Load JSON string into this object -void Blur::SetJson(string value) { +void Blur::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -320,7 +320,7 @@ void Blur::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Blur::PropertiesJSON(int64_t requested_frame) { +std::string Blur::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index 3a1a4bdb..b25727b7 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -108,7 +108,7 @@ std::shared_ptr Brightness::GetFrame(std::shared_ptr frame, int64_ } // Generate JSON string of this object -string Brightness::Json() { +std::string Brightness::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -128,14 +128,14 @@ Json::Value Brightness::JsonValue() { } // Load JSON string into this object -void Brightness::SetJson(string value) { +void Brightness::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -170,7 +170,7 @@ void Brightness::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Brightness::PropertiesJSON(int64_t requested_frame) { +std::string Brightness::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index 2e2dc511..d06ce739 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -101,7 +101,7 @@ std::shared_ptr ChromaKey::GetFrame(std::shared_ptr frame, int64_t } // Generate JSON string of this object -string ChromaKey::Json() { +std::string ChromaKey::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -121,14 +121,14 @@ Json::Value ChromaKey::JsonValue() { } // Load JSON string into this object -void ChromaKey::SetJson(string value) { +void ChromaKey::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -163,7 +163,7 @@ void ChromaKey::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string ChromaKey::PropertiesJSON(int64_t requested_frame) { +std::string ChromaKey::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/ColorShift.cpp b/src/effects/ColorShift.cpp index 10f22217..94d53d22 100644 --- a/src/effects/ColorShift.cpp +++ b/src/effects/ColorShift.cpp @@ -194,7 +194,7 @@ std::shared_ptr ColorShift::GetFrame(std::shared_ptr frame, int64_ } // Generate JSON string of this object -string ColorShift::Json() { +std::string ColorShift::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -220,14 +220,14 @@ Json::Value ColorShift::JsonValue() { } // Load JSON string into this object -void ColorShift::SetJson(string value) { +void ColorShift::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -274,7 +274,7 @@ void ColorShift::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string ColorShift::PropertiesJSON(int64_t requested_frame) { +std::string ColorShift::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Crop.cpp b/src/effects/Crop.cpp index 7ff6ec0b..aa35f05f 100644 --- a/src/effects/Crop.cpp +++ b/src/effects/Crop.cpp @@ -114,7 +114,7 @@ std::shared_ptr Crop::GetFrame(std::shared_ptr frame, int64_t fram } // Generate JSON string of this object -string Crop::Json() { +std::string Crop::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -136,14 +136,14 @@ Json::Value Crop::JsonValue() { } // Load JSON string into this object -void Crop::SetJson(string value) { +void Crop::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -182,7 +182,7 @@ void Crop::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Crop::PropertiesJSON(int64_t requested_frame) { +std::string Crop::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index 65f00ff6..b7a88e0b 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -96,7 +96,7 @@ std::shared_ptr Deinterlace::GetFrame(std::shared_ptr frame, int64 } // Generate JSON string of this object -string Deinterlace::Json() { +std::string Deinterlace::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -115,14 +115,14 @@ Json::Value Deinterlace::JsonValue() { } // Load JSON string into this object -void Deinterlace::SetJson(string value) { +void Deinterlace::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -155,7 +155,7 @@ void Deinterlace::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Deinterlace::PropertiesJSON(int64_t requested_frame) { +std::string Deinterlace::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Hue.cpp b/src/effects/Hue.cpp index fd33272d..7a581616 100644 --- a/src/effects/Hue.cpp +++ b/src/effects/Hue.cpp @@ -103,7 +103,7 @@ std::shared_ptr Hue::GetFrame(std::shared_ptr frame, int64_t frame } // Generate JSON string of this object -string Hue::Json() { +std::string Hue::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -122,14 +122,14 @@ Json::Value Hue::JsonValue() { } // Load JSON string into this object -void Hue::SetJson(string value) { +void Hue::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -162,7 +162,7 @@ void Hue::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Hue::PropertiesJSON(int64_t requested_frame) { +std::string Hue::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index 9f19475d..3749e14f 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -150,7 +150,7 @@ std::shared_ptr Mask::GetFrame(std::shared_ptr frame, int64_t fram } // Generate JSON string of this object -string Mask::Json() { +std::string Mask::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -175,14 +175,14 @@ Json::Value Mask::JsonValue() { } // Load JSON string into this object -void Mask::SetJson(string value) { +void Mask::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -234,7 +234,7 @@ void Mask::SetJsonValue(Json::Value root) { } // Create new reader (and load properties) - string type = root["reader"]["type"].asString(); + std::string type = root["reader"]["type"].asString(); if (type == "FFmpegReader") { @@ -271,7 +271,7 @@ void Mask::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Mask::PropertiesJSON(int64_t requested_frame) { +std::string Mask::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Negate.cpp b/src/effects/Negate.cpp index 938030bc..690cd19e 100644 --- a/src/effects/Negate.cpp +++ b/src/effects/Negate.cpp @@ -58,7 +58,7 @@ std::shared_ptr Negate::GetFrame(std::shared_ptr frame, int64_t fr } // Generate JSON string of this object -string Negate::Json() { +std::string Negate::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -76,14 +76,14 @@ Json::Value Negate::JsonValue() { } // Load JSON string into this object -void Negate::SetJson(string value) { +void Negate::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -113,7 +113,7 @@ void Negate::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Negate::PropertiesJSON(int64_t requested_frame) { +std::string Negate::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Pixelate.cpp b/src/effects/Pixelate.cpp index d7c3fa12..f61e4686 100644 --- a/src/effects/Pixelate.cpp +++ b/src/effects/Pixelate.cpp @@ -68,7 +68,7 @@ std::shared_ptr Pixelate::GetFrame(std::shared_ptr frame, int64_t std::shared_ptr frame_image = frame->GetImage(); // Get current keyframe values - double pixelization_value = 1.0 - min(fabs(pixelization.GetValue(frame_number)), 1.0); + double pixelization_value = 1.0 - std::min(fabs(pixelization.GetValue(frame_number)), 1.0); double left_value = left.GetValue(frame_number); double top_value = top.GetValue(frame_number); double right_value = right.GetValue(frame_number); @@ -76,7 +76,7 @@ std::shared_ptr Pixelate::GetFrame(std::shared_ptr frame, int64_t if (pixelization_value > 0.0) { // Resize frame image smaller (based on pixelization value) - std::shared_ptr smaller_frame_image = std::shared_ptr(new QImage(frame_image->scaledToWidth(max(frame_image->width() * pixelization_value, 2.0), Qt::SmoothTransformation))); + std::shared_ptr smaller_frame_image = std::shared_ptr(new QImage(frame_image->scaledToWidth(std::max(frame_image->width() * pixelization_value, 2.0), Qt::SmoothTransformation))); // Resize image back to original size (with no smoothing to create pixelated image) std::shared_ptr pixelated_image = std::shared_ptr(new QImage(smaller_frame_image->scaledToWidth(frame_image->width(), Qt::FastTransformation).convertToFormat(QImage::Format_RGBA8888))); @@ -110,7 +110,7 @@ std::shared_ptr Pixelate::GetFrame(std::shared_ptr frame, int64_t } // Generate JSON string of this object -string Pixelate::Json() { +std::string Pixelate::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -133,14 +133,14 @@ Json::Value Pixelate::JsonValue() { } // Load JSON string into this object -void Pixelate::SetJson(string value) { +void Pixelate::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -181,7 +181,7 @@ void Pixelate::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Pixelate::PropertiesJSON(int64_t requested_frame) { +std::string Pixelate::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index 98818127..9c941b76 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -114,7 +114,7 @@ std::shared_ptr Saturation::GetFrame(std::shared_ptr frame, int64_ } // Generate JSON string of this object -string Saturation::Json() { +std::string Saturation::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -133,14 +133,14 @@ Json::Value Saturation::JsonValue() { } // Load JSON string into this object -void Saturation::SetJson(string value) { +void Saturation::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -173,7 +173,7 @@ void Saturation::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Saturation::PropertiesJSON(int64_t requested_frame) { +std::string Saturation::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Shift.cpp b/src/effects/Shift.cpp index c22844e7..a204157a 100644 --- a/src/effects/Shift.cpp +++ b/src/effects/Shift.cpp @@ -133,7 +133,7 @@ std::shared_ptr Shift::GetFrame(std::shared_ptr frame, int64_t fra } // Generate JSON string of this object -string Shift::Json() { +std::string Shift::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -153,14 +153,14 @@ Json::Value Shift::JsonValue() { } // Load JSON string into this object -void Shift::SetJson(string value) { +void Shift::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -195,7 +195,7 @@ void Shift::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Shift::PropertiesJSON(int64_t requested_frame) { +std::string Shift::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; diff --git a/src/effects/Wave.cpp b/src/effects/Wave.cpp index 6e3bd48a..d6aa61b5 100644 --- a/src/effects/Wave.cpp +++ b/src/effects/Wave.cpp @@ -113,7 +113,7 @@ std::shared_ptr Wave::GetFrame(std::shared_ptr frame, int64_t fram } // Generate JSON string of this object -string Wave::Json() { +std::string Wave::Json() { // Return formatted string return JsonValue().toStyledString(); @@ -136,14 +136,14 @@ Json::Value Wave::JsonValue() { } // Load JSON string into this object -void Wave::SetJson(string value) { +void Wave::SetJson(std::string value) { // Parse JSON string into JSON objects Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - string errors; + std::string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); delete reader; @@ -184,7 +184,7 @@ void Wave::SetJsonValue(Json::Value root) { } // Get all properties for a specific frame -string Wave::PropertiesJSON(int64_t requested_frame) { +std::string Wave::PropertiesJSON(int64_t requested_frame) { // Generate JSON properties list Json::Value root; From 91dbcbc7eff21535ecc4657467fd654c7624d741 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:11:22 -0400 Subject: [PATCH 26/36] OpenShotVersion.h.in: std:: prefixes --- include/OpenShotVersion.h.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/OpenShotVersion.h.in b/include/OpenShotVersion.h.in index 89f4ed52..e6b907ff 100644 --- a/include/OpenShotVersion.h.in +++ b/include/OpenShotVersion.h.in @@ -43,7 +43,6 @@ #define OPENSHOT_VERSION_SO @PROJECT_SO_VERSION@ /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) #include -using namespace std; namespace openshot { @@ -55,8 +54,8 @@ namespace openshot int so; /// Shared Object Number (incremented when API or ABI changes) /// Get a string version of the version (i.e. "Major.Minor.Build") - string ToString() { - stringstream version_string; + std::string ToString() { + std::stringstream version_string; version_string << major << "." << minor << "." << build; return version_string.str(); } From bf078a928e57e8d662aa69271e8fca49da76b358 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:12:44 -0400 Subject: [PATCH 27/36] AudioDeviceInfo.h: Add `namespace openshot {}` --- include/AudioDeviceInfo.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/AudioDeviceInfo.h b/include/AudioDeviceInfo.h index bbdbd81b..454bf923 100644 --- a/include/AudioDeviceInfo.h +++ b/include/AudioDeviceInfo.h @@ -37,10 +37,11 @@ * * The type and name of the audio device. */ -struct AudioDeviceInfo -{ - std::string name; - std::string type; -}; - +namespace openshot { + struct AudioDeviceInfo + { + std::string name; + std::string type; + }; +} #endif From ce8ff07fd360c3b8e833604748d0a66d20948815 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:15:01 -0400 Subject: [PATCH 28/36] Audio headers: juce:: prefixing as needed --- include/AudioBufferSource.h | 10 +++++----- include/AudioResampler.h | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/AudioBufferSource.h b/include/AudioBufferSource.h index 903172f7..a16780c2 100644 --- a/include/AudioBufferSource.h +++ b/include/AudioBufferSource.h @@ -52,25 +52,25 @@ namespace openshot * The JUCE library cannot play audio directly from an AudioSampleBuffer, so this class exposes * an AudioSampleBuffer as a AudioSource, so that JUCE can play the audio. */ - class AudioBufferSource : public PositionableAudioSource + class AudioBufferSource : public juce::PositionableAudioSource { private: int position; int start; bool repeat; - AudioSampleBuffer *buffer; + juce::AudioSampleBuffer *buffer; public: /// @brief Default constructor /// @param audio_buffer This buffer contains the samples you want to play through JUCE. - AudioBufferSource(AudioSampleBuffer *audio_buffer); + AudioBufferSource(juce::AudioSampleBuffer *audio_buffer); /// Destructor ~AudioBufferSource(); /// @brief Get the next block of audio samples /// @param info This struct informs us of which samples are needed next. - void getNextAudioBlock (const AudioSourceChannelInfo& info); + void getNextAudioBlock (const juce::AudioSourceChannelInfo& info); /// Prepare to play this audio source void prepareToPlay(int, double); @@ -96,7 +96,7 @@ namespace openshot void setLooping (bool shouldLoop); /// Update the internal buffer used by this source - void setBuffer (AudioSampleBuffer *audio_buffer); + void setBuffer (juce::AudioSampleBuffer *audio_buffer); }; } diff --git a/include/AudioResampler.h b/include/AudioResampler.h index 85a44b1f..96615cb3 100644 --- a/include/AudioResampler.h +++ b/include/AudioResampler.h @@ -55,11 +55,11 @@ namespace openshot { */ class AudioResampler { private: - AudioSampleBuffer *buffer; - AudioSampleBuffer *resampled_buffer; - AudioBufferSource *buffer_source; - ResamplingAudioSource *resample_source; - AudioSourceChannelInfo resample_callback_buffer; + juce::AudioSampleBuffer *buffer; + juce::AudioSampleBuffer *resampled_buffer; + openshot::AudioBufferSource *buffer_source; + juce::ResamplingAudioSource *resample_source; + juce::AudioSourceChannelInfo resample_callback_buffer; int num_of_samples; int new_num_of_samples; @@ -78,15 +78,15 @@ namespace openshot { /// @param new_buffer The buffer of audio samples needing to be resampled /// @param sample_rate The original sample rate of the buffered samples /// @param new_sample_rate The requested sample rate you need - void SetBuffer(AudioSampleBuffer *new_buffer, double sample_rate, double new_sample_rate); + void SetBuffer(juce::AudioSampleBuffer *new_buffer, double sample_rate, double new_sample_rate); /// @brief Sets the audio buffer and key settings /// @param new_buffer The buffer of audio samples needing to be resampled /// @param ratio The multiplier that needs to be applied to the sample rate (this is how resampling happens) - void SetBuffer(AudioSampleBuffer *new_buffer, double ratio); + void SetBuffer(juce::AudioSampleBuffer *new_buffer, double ratio); /// Get the resampled audio buffer - AudioSampleBuffer* GetResampledBuffer(); + juce::AudioSampleBuffer* GetResampledBuffer(); }; } From 3ce85d0fffddf6f7927713758da9342e111b11ac Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:17:22 -0400 Subject: [PATCH 29/36] openshot:: prefixing as needed for SWIG It turns out SWIG is a lot pickier than GCC about namespaces, and requires a lot more `openshot::` prefixing in our headers, if we eliminate the `using namespace...` statements from them. --- include/CacheBase.h | 6 +-- include/CacheDisk.h | 6 +-- include/CacheMemory.h | 8 ++-- include/ChunkReader.h | 8 ++-- include/ChunkWriter.h | 14 +++--- include/Clip.h | 104 ++++++++++++++++++++--------------------- include/Color.h | 10 ++-- include/DummyReader.h | 6 +-- include/EffectBase.h | 2 +- include/FFmpegReader.h | 8 ++-- include/FFmpegWriter.h | 32 ++++++------- include/Frame.h | 18 +++---- include/PlayerBase.h | 4 +- include/QtPlayer.h | 10 ++-- include/ReaderBase.h | 24 +++++----- include/RendererBase.h | 4 +- include/TextReader.h | 6 +-- include/WriterBase.h | 18 +++---- src/ReaderBase.cpp | 4 +- 19 files changed, 146 insertions(+), 146 deletions(-) diff --git a/include/CacheBase.h b/include/CacheBase.h index d09cb114..31cfad51 100644 --- a/include/CacheBase.h +++ b/include/CacheBase.h @@ -65,7 +65,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - virtual void Add(std::shared_ptr frame) = 0; + virtual void Add(std::shared_ptr frame) = 0; /// Clear the cache of all frames virtual void Clear() = 0; @@ -75,13 +75,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - virtual std::shared_ptr GetFrame(int64_t frame_number) = 0; + virtual std::shared_ptr GetFrame(int64_t frame_number) = 0; /// Gets the maximum bytes value virtual int64_t GetBytes() = 0; /// Get the smallest frame number - virtual std::shared_ptr GetSmallestFrame() = 0; + virtual std::shared_ptr GetSmallestFrame() = 0; /// @brief Remove a specific frame /// @param frame_number The frame number of the cached frame diff --git a/include/CacheDisk.h b/include/CacheDisk.h index 82c4c80e..e69cc357 100644 --- a/include/CacheDisk.h +++ b/include/CacheDisk.h @@ -96,7 +96,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - void Add(std::shared_ptr frame); + void Add(std::shared_ptr frame); /// Clear the cache of all frames void Clear(); @@ -106,13 +106,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - std::shared_ptr GetFrame(int64_t frame_number); + std::shared_ptr GetFrame(int64_t frame_number); /// Gets the maximum bytes value int64_t GetBytes(); /// Get the smallest frame number - std::shared_ptr GetSmallestFrame(); + std::shared_ptr GetSmallestFrame(); /// @brief Move frame to front of queue (so it lasts longer) /// @param frame_number The frame number of the cached frame diff --git a/include/CacheMemory.h b/include/CacheMemory.h index 7ac77537..fb3c75f6 100644 --- a/include/CacheMemory.h +++ b/include/CacheMemory.h @@ -50,7 +50,7 @@ namespace openshot { */ class CacheMemory : public CacheBase { private: - std::map > frames; ///< This map holds the frame number and Frame objects + std::map > frames; ///< This map holds the frame number and Frame objects std::deque frame_numbers; ///< This queue holds a sequential list of cached Frame numbers bool needs_range_processing; ///< Something has changed, and the range data needs to be re-calculated @@ -78,7 +78,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - void Add(std::shared_ptr frame); + void Add(std::shared_ptr frame); /// Clear the cache of all frames void Clear(); @@ -88,13 +88,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - std::shared_ptr GetFrame(int64_t frame_number); + std::shared_ptr GetFrame(int64_t frame_number); /// Gets the maximum bytes value int64_t GetBytes(); /// Get the smallest frame number - std::shared_ptr GetSmallestFrame(); + std::shared_ptr GetSmallestFrame(); /// @brief Move frame to front of queue (so it lasts longer) /// @param frame_number The frame number of the cached frame diff --git a/include/ChunkReader.h b/include/ChunkReader.h index 4290df81..35e3af4e 100644 --- a/include/ChunkReader.h +++ b/include/ChunkReader.h @@ -106,10 +106,10 @@ namespace openshot std::string path; bool is_open; int64_t chunk_size; - ReaderBase *local_reader; + openshot::ReaderBase *local_reader; ChunkLocation previous_location; ChunkVersion version; - std::shared_ptr last_frame; + std::shared_ptr last_frame; /// Check if folder path existing bool does_folder_exist(std::string path); @@ -143,12 +143,12 @@ namespace openshot void SetChunkSize(int64_t new_size) { chunk_size = new_size; }; /// Get the cache object used by this reader (always return NULL for this reader) - CacheMemory* GetCache() { return NULL; }; + openshot::CacheMemory* GetCache() { return NULL; }; /// @brief Get an openshot::Frame object for a specific frame number of this reader. /// @returns The requested frame (containing the image and audio) /// @param requested_frame The frame number you want to retrieve - std::shared_ptr GetFrame(int64_t requested_frame); + std::shared_ptr GetFrame(int64_t requested_frame); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/ChunkWriter.h b/include/ChunkWriter.h index c96c118a..5fee5a37 100644 --- a/include/ChunkWriter.h +++ b/include/ChunkWriter.h @@ -87,10 +87,10 @@ namespace openshot int64_t frame_count; bool is_open; bool is_writing; - ReaderBase *local_reader; - FFmpegWriter *writer_thumb; - FFmpegWriter *writer_preview; - FFmpegWriter *writer_final; + openshot::ReaderBase *local_reader; + openshot::FFmpegWriter *writer_thumb; + openshot::FFmpegWriter *writer_preview; + openshot::FFmpegWriter *writer_final; std::shared_ptr last_frame; bool last_frame_needed; std::string default_extension; @@ -114,7 +114,7 @@ namespace openshot /// @brief Constructor for ChunkWriter. Throws one of the following exceptions. /// @param path The folder path of the chunk file to be created /// @param reader The initial reader to base this chunk file's meta data on (such as fps, height, width, etc...) - ChunkWriter(std::string path, ReaderBase *reader); + ChunkWriter(std::string path, openshot::ReaderBase *reader); /// Close the writer void Close(); @@ -134,7 +134,7 @@ namespace openshot /// @brief Add a frame to the stack waiting to be encoded. /// @param frame The openshot::Frame object that needs to be written to this chunk file. - void WriteFrame(std::shared_ptr frame); + void WriteFrame(std::shared_ptr frame); /// @brief Write a block of frames from a reader /// @param start The starting frame number to write (of the reader passed into the constructor) @@ -145,7 +145,7 @@ namespace openshot /// @param reader The reader containing the frames you need /// @param start The starting frame number to write /// @param length The number of frames to write - void WriteFrame(ReaderBase* reader, int64_t start, int64_t length); + void WriteFrame(openshot::ReaderBase* reader, int64_t start, int64_t length); }; diff --git a/include/Clip.h b/include/Clip.h index 3e978429..76bfb923 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -57,7 +57,7 @@ namespace openshot { /// from lowest layer to top layer (since that is sequence clips are combined), and then by /// position, and then by effect order. struct CompareClipEffects{ - bool operator()( EffectBase* lhs, EffectBase* rhs){ + bool operator()( openshot::EffectBase* lhs, openshot::EffectBase* rhs){ if( lhs->Layer() < rhs->Layer() ) return true; if( lhs->Layer() == rhs->Layer() && lhs->Position() < rhs->Position() ) return true; if( lhs->Layer() == rhs->Layer() && lhs->Position() == rhs->Position() && lhs->Order() > rhs->Order() ) return true; @@ -76,7 +76,7 @@ namespace openshot { * Clip c1(new ImageReader("MyAwesomeLogo.jpeg")); * Clip c2(new FFmpegReader("BackgroundVideo.webm")); * - * // CLIP 1 (logo) - Set some clip properties (with Keyframes) + * // CLIP 1 (logo) - Set some clip properties (with openshot::Keyframes) * c1.Position(0.0); // Set the position or location (in seconds) on the timeline * c1.gravity = GRAVITY_LEFT; // Set the alignment / gravity of the clip (position on the screen) * c1.scale = SCALE_CROP; // Set the scale mode (how the image is resized to fill the screen) @@ -87,7 +87,7 @@ namespace openshot { * c1.alpha.AddPoint(500, 0.0); // Keep the alpha transparent until frame #500 * c1.alpha.AddPoint(565, 1.0); // Animate the alpha from transparent to visible (between frame #501 and #565) * - * // CLIP 2 (background video) - Set some clip properties (with Keyframes) + * // CLIP 2 (background video) - Set some clip properties (with openshot::Keyframes) * c2.Position(0.0); // Set the position or location (in seconds) on the timeline * c2.Start(10.0); // Set the starting position of the video (trim the left side of the video) * c2.Layer(0); // Set the layer of the timeline (higher layers cover up images of lower layers) @@ -97,40 +97,40 @@ namespace openshot { * c2.alpha.AddPoint(384, 1.0); // Animate the alpha to visible (between frame #360 and frame #384) * @endcode */ - class Clip : public ClipBase { + class Clip : public openshot::ClipBase { protected: /// Section lock for multiple threads CriticalSection getFrameCriticalSection; private: bool waveform; ///< Should a waveform be used instead of the clip's image - std::list effects; /// effects; /// apply_effects(std::shared_ptr frame); + std::shared_ptr apply_effects(std::shared_ptr frame); /// Get file extension std::string get_file_extension(std::string path); /// Get a frame object or create a blank one - std::shared_ptr GetOrCreateFrame(int64_t number); + std::shared_ptr GetOrCreateFrame(int64_t number); /// Adjust the audio and image of a time mapped frame - void get_time_mapped_frame(std::shared_ptr frame, int64_t frame_number); + void get_time_mapped_frame(std::shared_ptr frame, int64_t frame_number); /// Init default settings for a clip void init_settings(); @@ -145,11 +145,11 @@ namespace openshot { void reverse_buffer(juce::AudioSampleBuffer* buffer); public: - GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent - ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent - AnchorType anchor; ///< The anchor determines what parent a clip should snap to - FrameDisplayType display; ///< The format to display the frame number (if any) - VolumeMixType mixing; ///< What strategy should be followed when mixing audio with other clips + openshot::GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent + openshot::ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent + openshot::AnchorType anchor; ///< The anchor determines what parent a clip should snap to + openshot::FrameDisplayType display; ///< The format to display the frame number (if any) + openshot::VolumeMixType mixing; ///< What strategy should be followed when mixing audio with other clips /// Default Constructor Clip(); @@ -160,36 +160,36 @@ namespace openshot { /// @brief Constructor with reader /// @param new_reader The reader to be used by this clip - Clip(ReaderBase* new_reader); + Clip(openshot::ReaderBase* new_reader); /// Destructor virtual ~Clip(); /// @brief Add an effect to the clip /// @param effect Add an effect to the clip. An effect can modify the audio or video of an openshot::Frame. - void AddEffect(EffectBase* effect); + void AddEffect(openshot::EffectBase* effect); /// Close the internal reader void Close(); /// Return the list of effects on the timeline - std::list Effects() { return effects; }; + std::list Effects() { return effects; }; /// @brief Get an openshot::Frame object for a specific frame number of this timeline. /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested - std::shared_ptr GetFrame(int64_t requested_frame); + std::shared_ptr GetFrame(int64_t requested_frame); /// Open the internal reader void Open(); /// @brief Set the current reader /// @param new_reader The reader to be used by this clip - void Reader(ReaderBase* new_reader); + void Reader(openshot::ReaderBase* new_reader); /// Get the current reader - ReaderBase* Reader(); + openshot::ReaderBase* Reader(); /// Override End() method float End(); ///< Get end position (in seconds) of clip (trim end of video), which can be affected by the time curve. @@ -207,55 +207,55 @@ namespace openshot { /// @brief Remove an effect from the clip /// @param effect Remove an effect from the clip. - void RemoveEffect(EffectBase* effect); + void RemoveEffect(openshot::EffectBase* effect); /// Waveform property bool Waveform() { return waveform; } ///< Get the waveform property of this clip void Waveform(bool value) { waveform = value; } ///< Set the waveform property of this clip // Scale and Location curves - Keyframe scale_x; ///< Curve representing the horizontal scaling in percent (0 to 1) - Keyframe scale_y; ///< Curve representing the vertical scaling in percent (0 to 1) - Keyframe location_x; ///< Curve representing the relative X position in percent based on the gravity (-1 to 1) - Keyframe location_y; ///< Curve representing the relative Y position in percent based on the gravity (-1 to 1) + openshot::Keyframe scale_x; ///< Curve representing the horizontal scaling in percent (0 to 1) + openshot::Keyframe scale_y; ///< Curve representing the vertical scaling in percent (0 to 1) + openshot::Keyframe location_x; ///< Curve representing the relative X position in percent based on the gravity (-1 to 1) + openshot::Keyframe location_y; ///< Curve representing the relative Y position in percent based on the gravity (-1 to 1) // Alpha and Rotation curves - Keyframe alpha; ///< Curve representing the alpha (1 to 0) - Keyframe rotation; ///< Curve representing the rotation (0 to 360) + openshot::Keyframe alpha; ///< Curve representing the alpha (1 to 0) + openshot::Keyframe rotation; ///< Curve representing the rotation (0 to 360) // Time and Volume curves - Keyframe time; ///< Curve representing the frames over time to play (used for speed and direction of video) - Keyframe volume; ///< Curve representing the volume (0 to 1) + openshot::Keyframe time; ///< Curve representing the frames over time to play (used for speed and direction of video) + openshot::Keyframe volume; ///< Curve representing the volume (0 to 1) /// Curve representing the color of the audio wave form - Color wave_color; + openshot::Color wave_color; // Crop settings and curves - GravityType crop_gravity; ///< Cropping needs to have a gravity to determine what side we are cropping - Keyframe crop_width; ///< Curve representing width in percent (0.0=0%, 1.0=100%) - Keyframe crop_height; ///< Curve representing height in percent (0.0=0%, 1.0=100%) - Keyframe crop_x; ///< Curve representing X offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%) - Keyframe crop_y; ///< Curve representing Y offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%) + openshot::GravityType crop_gravity; ///< Cropping needs to have a gravity to determine what side we are cropping + openshot::Keyframe crop_width; ///< Curve representing width in percent (0.0=0%, 1.0=100%) + openshot::Keyframe crop_height; ///< Curve representing height in percent (0.0=0%, 1.0=100%) + openshot::Keyframe crop_x; ///< Curve representing X offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%) + openshot::Keyframe crop_y; ///< Curve representing Y offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%) // Shear and perspective curves - Keyframe shear_x; ///< Curve representing X shear angle in degrees (-45.0=left, 45.0=right) - Keyframe shear_y; ///< Curve representing Y shear angle in degrees (-45.0=down, 45.0=up) - Keyframe perspective_c1_x; ///< Curves representing X for coordinate 1 - Keyframe perspective_c1_y; ///< Curves representing Y for coordinate 1 - Keyframe perspective_c2_x; ///< Curves representing X for coordinate 2 - Keyframe perspective_c2_y; ///< Curves representing Y for coordinate 2 - Keyframe perspective_c3_x; ///< Curves representing X for coordinate 3 - Keyframe perspective_c3_y; ///< Curves representing Y for coordinate 3 - Keyframe perspective_c4_x; ///< Curves representing X for coordinate 4 - Keyframe perspective_c4_y; ///< Curves representing Y for coordinate 4 + openshot::Keyframe shear_x; ///< Curve representing X shear angle in degrees (-45.0=left, 45.0=right) + openshot::Keyframe shear_y; ///< Curve representing Y shear angle in degrees (-45.0=down, 45.0=up) + openshot::Keyframe perspective_c1_x; ///< Curves representing X for coordinate 1 + openshot::Keyframe perspective_c1_y; ///< Curves representing Y for coordinate 1 + openshot::Keyframe perspective_c2_x; ///< Curves representing X for coordinate 2 + openshot::Keyframe perspective_c2_y; ///< Curves representing Y for coordinate 2 + openshot::Keyframe perspective_c3_x; ///< Curves representing X for coordinate 3 + openshot::Keyframe perspective_c3_y; ///< Curves representing Y for coordinate 3 + openshot::Keyframe perspective_c4_x; ///< Curves representing X for coordinate 4 + openshot::Keyframe perspective_c4_y; ///< Curves representing Y for coordinate 4 /// Audio channel filter and mappings - Keyframe channel_filter; ///< A number representing an audio channel to filter (clears all other channels) - Keyframe channel_mapping; ///< A number representing an audio channel to output (only works when filtering a channel) + openshot::Keyframe channel_filter; ///< A number representing an audio channel to filter (clears all other channels) + openshot::Keyframe channel_mapping; ///< A number representing an audio channel to output (only works when filtering a channel) /// Override has_video and has_audio properties of clip (and their readers) - Keyframe has_audio; ///< An optional override to determine if this clip has audio (-1=undefined, 0=no, 1=yes) - Keyframe has_video; ///< An optional override to determine if this clip has video (-1=undefined, 0=no, 1=yes) + openshot::Keyframe has_audio; ///< An optional override to determine if this clip has audio (-1=undefined, 0=no, 1=yes) + openshot::Keyframe has_video; ///< An optional override to determine if this clip has video (-1=undefined, 0=no, 1=yes) }; diff --git a/include/Color.h b/include/Color.h index 33b05574..47db29a7 100644 --- a/include/Color.h +++ b/include/Color.h @@ -45,10 +45,10 @@ namespace openshot { class Color{ public: - Keyframe red; /// image_frame; + std::shared_ptr image_frame; bool is_open; public: @@ -63,7 +63,7 @@ namespace openshot DummyReader(); /// Constructor for DummyReader. - DummyReader(Fraction fps, int width, int height, int sample_rate, int channels, float duration); + DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration); virtual ~DummyReader(); @@ -78,7 +78,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - std::shared_ptr GetFrame(int64_t requested_frame); + std::shared_ptr GetFrame(int64_t requested_frame); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/EffectBase.h b/include/EffectBase.h index 8d0326c6..29e98b58 100644 --- a/include/EffectBase.h +++ b/include/EffectBase.h @@ -88,7 +88,7 @@ namespace openshot /// @returns The modified openshot::Frame object /// @param frame The frame object that needs the effect applied to it /// @param frame_number The frame number (starting at 1) of the effect on the timeline. - virtual std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number) = 0; + virtual std::shared_ptr GetFrame(std::shared_ptr frame, int64_t frame_number) = 0; /// Initialize the values of the EffectInfo struct. It is important for derived classes to call /// this method, or the EffectInfo struct values will not be initialized. diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index a8b1740b..9faa86a3 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -130,7 +130,7 @@ namespace openshot { int64_t pts_counter; int64_t num_packets_since_video_frame; int64_t num_checks_since_final; - std::shared_ptr last_video_frame; + std::shared_ptr last_video_frame; bool is_seeking; int64_t seeking_pts; @@ -176,7 +176,7 @@ namespace openshot { int64_t ConvertVideoPTStoFrame(int64_t pts); /// Create a new Frame (or return an existing one) and add it to the working queue. - std::shared_ptr CreateFrame(int64_t requested_frame); + std::shared_ptr CreateFrame(int64_t requested_frame); /// Calculate Starting video frame and sample # for an audio PTS AudioLocation GetAudioPTSLocation(int64_t pts); @@ -206,7 +206,7 @@ namespace openshot { void ProcessAudioPacket(int64_t requested_frame, int64_t target_frame, int starting_sample); /// Read the stream until we find the requested Frame - std::shared_ptr ReadStream(int64_t requested_frame); + std::shared_ptr ReadStream(int64_t requested_frame); /// Remove AVFrame from cache (and deallocate its memory) void RemoveAVFrame(AVFrame *); @@ -256,7 +256,7 @@ namespace openshot { /// /// @returns The requested frame of video /// @param requested_frame The frame number that is requested. - std::shared_ptr GetFrame(int64_t requested_frame); + std::shared_ptr GetFrame(int64_t requested_frame); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index 97fd7726..dc3a2cf7 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -180,20 +180,20 @@ namespace openshot { int original_sample_rate; int original_channels; - std::shared_ptr last_frame; - std::deque > spooled_audio_frames; - std::deque > spooled_video_frames; + std::shared_ptr last_frame; + std::deque > spooled_audio_frames; + std::deque > spooled_video_frames; - std::deque > queued_audio_frames; - std::deque > queued_video_frames; + std::deque > queued_audio_frames; + std::deque > queued_video_frames; - std::deque > processed_frames; - std::deque > deallocate_frames; + std::deque > processed_frames; + std::deque > deallocate_frames; - std::map, AVFrame *> av_frames; + std::map, AVFrame *> av_frames; /// Add an AVFrame to the cache - void add_avframe(std::shared_ptr frame, AVFrame *av_frame); + void add_avframe(std::shared_ptr frame, AVFrame *av_frame); /// Add an audio output stream AVStream *add_audio_stream(); @@ -231,13 +231,13 @@ namespace openshot { void open_video(AVFormatContext *oc, AVStream *st); /// process video frame - void process_video_packet(std::shared_ptr frame); + void process_video_packet(std::shared_ptr frame); /// write all queued frames' audio to the video file void write_audio_packets(bool is_final); /// write video frame - bool write_video_packet(std::shared_ptr frame, AVFrame *frame_final); + bool write_video_packet(std::shared_ptr frame, AVFrame *frame_final); /// write all queued frames void write_queued_frames(); @@ -285,7 +285,7 @@ namespace openshot { /// @param channels The number of audio channels needed in this file /// @param channel_layout The 'layout' of audio channels (i.e. mono, stereo, surround, etc...) /// @param bit_rate The audio bit rate used during encoding - void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate); + void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, openshot::ChannelLayout channel_layout, int bit_rate); /// @brief Set the cache size /// @param new_size The number of frames to queue before writing to the file @@ -301,14 +301,14 @@ namespace openshot { /// @param interlaced Does this video need to be interlaced? /// @param top_field_first Which frame should be used as the top field? /// @param bit_rate The video bit rate used during encoding - void SetVideoOptions(bool has_video, std::string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate); + void SetVideoOptions(bool has_video, std::string codec, openshot::Fraction fps, int width, int height, openshot::Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate); /// @brief Set custom options (some codecs accept additional params). This must be called after the /// PrepareStreams() method, otherwise the streams have not been initialized yet. /// @param stream The stream (openshot::StreamType) this option should apply to /// @param name The name of the option you want to set (i.e. qmin, qmax, etc...) /// @param value The new value of this option - void SetOption(StreamType stream, std::string name, std::string value); + void SetOption(openshot::StreamType stream, std::string name, std::string value); /// @brief Write the file header (after the options are set). This method is called automatically /// by the Open() method if this method has not yet been called. @@ -316,13 +316,13 @@ namespace openshot { /// @brief Add a frame to the stack waiting to be encoded. /// @param frame The openshot::Frame object to write to this image - void WriteFrame(std::shared_ptr frame); + void WriteFrame(std::shared_ptr frame); /// @brief Write a block of frames from a reader /// @param reader A openshot::ReaderBase object which will provide frames to be written /// @param start The starting frame number of the reader /// @param length The number of frames to write - void WriteFrame(ReaderBase *reader, int64_t start, int64_t length); + void WriteFrame(openshot::ReaderBase *reader, int64_t start, int64_t length); /// @brief Write the file trailer (after all frames are written). This is called automatically /// by the Close() method if this method has not yet been called. diff --git a/include/Frame.h b/include/Frame.h index 1048c9cf..e1997485 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -122,7 +122,7 @@ namespace openshot CriticalSection addingImageSection; CriticalSection addingAudioSection; const unsigned char *qbuffer; - Fraction pixel_ratio; + openshot::Fraction pixel_ratio; int channels; ChannelLayout channel_layout; int width; @@ -189,10 +189,10 @@ namespace openshot /// Channel Layout of audio samples. A frame needs to keep track of this, since Writers do not always /// know the original channel layout of a frame's audio samples (i.e. mono, stereo, 5 point surround, etc...) - ChannelLayout ChannelsLayout(); + openshot::ChannelLayout ChannelsLayout(); // Set the channel layout of audio samples (i.e. mono, stereo, 5 point surround, etc...) - void ChannelsLayout(ChannelLayout new_channel_layout) { channel_layout = new_channel_layout; }; + void ChannelsLayout(openshot::ChannelLayout new_channel_layout) { channel_layout = new_channel_layout; }; /// Clean up buffer after QImage is deleted static void cleanUpBuffer(void *info); @@ -216,10 +216,10 @@ namespace openshot float* GetAudioSamples(int channel); /// Get an array of sample data (all channels interleaved together), using any sample rate - float* GetInterleavedAudioSamples(int new_sample_rate, AudioResampler* resampler, int* sample_count); + float* GetInterleavedAudioSamples(int new_sample_rate, openshot::AudioResampler* resampler, int* sample_count); // Get a planar array of sample data, using any sample rate - float* GetPlanarAudioSamples(int new_sample_rate, AudioResampler* resampler, int* sample_count); + float* GetPlanarAudioSamples(int new_sample_rate, openshot::AudioResampler* resampler, int* sample_count); /// Get number of audio channels int GetAudioChannelsCount(); @@ -241,7 +241,7 @@ namespace openshot #endif /// Set Pixel Aspect Ratio - Fraction GetPixelRatio() { return pixel_ratio; }; + openshot::Fraction GetPixelRatio() { return pixel_ratio; }; /// Get pixel data (as packets) const unsigned char* GetPixels(); @@ -256,10 +256,10 @@ namespace openshot int GetHeight(); /// Calculate the # of samples per video frame (for the current frame number) - int GetSamplesPerFrame(Fraction fps, int sample_rate, int channels); + int GetSamplesPerFrame(openshot::Fraction fps, int sample_rate, int channels); /// Calculate the # of samples per video frame (for a specific frame number and frame rate) - static int GetSamplesPerFrame(int64_t frame_number, Fraction fps, int sample_rate, int channels); + static int GetSamplesPerFrame(int64_t frame_number, openshot::Fraction fps, int sample_rate, int channels); /// Get an audio waveform image std::shared_ptr GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha); @@ -271,7 +271,7 @@ namespace openshot int GetWidth(); /// Resize audio container to hold more (or less) samples and channels - void ResizeAudio(int channels, int length, int sample_rate, ChannelLayout channel_layout); + void ResizeAudio(int channels, int length, int sample_rate, openshot::ChannelLayout channel_layout); /// Get the original sample rate of this frame's audio data int SampleRate(); diff --git a/include/PlayerBase.h b/include/PlayerBase.h index d5170562..bf23f576 100644 --- a/include/PlayerBase.h +++ b/include/PlayerBase.h @@ -61,7 +61,7 @@ namespace openshot protected: float speed; float volume; - ReaderBase *reader; + openshot::ReaderBase *reader; PlaybackMode mode; public: @@ -97,7 +97,7 @@ namespace openshot virtual ReaderBase* Reader() = 0; /// Set the current reader, such as a FFmpegReader - virtual void Reader(ReaderBase *new_reader) = 0; + virtual void Reader(openshot::ReaderBase *new_reader) = 0; /// Get the Volume virtual float Volume() = 0; diff --git a/include/QtPlayer.h b/include/QtPlayer.h index b3cd9d05..fc8f2a3d 100644 --- a/include/QtPlayer.h +++ b/include/QtPlayer.h @@ -52,7 +52,7 @@ namespace openshot public: /// Default constructor explicit QtPlayer(); - explicit QtPlayer(RendererBase *rb); + explicit QtPlayer(openshot::RendererBase *rb); /// Default destructor virtual ~QtPlayer(); @@ -64,7 +64,7 @@ namespace openshot std::string GetError(); /// Get Audio Devices from JUCE - std::vector GetAudioDeviceNames(); + std::vector GetAudioDeviceNames(); /// Play the video void Play(); @@ -73,7 +73,7 @@ namespace openshot void Loading(); /// Get the current mode - PlaybackMode Mode(); + openshot::PlaybackMode Mode(); /// Pause the video void Pause(); @@ -105,10 +105,10 @@ namespace openshot void Stop(); /// Set the current reader - void Reader(ReaderBase *new_reader); + void Reader(openshot::ReaderBase *new_reader); /// Get the current reader, such as a FFmpegReader - ReaderBase* Reader(); + openshot::ReaderBase* Reader(); /// Get the Volume float Volume(); diff --git a/include/ReaderBase.h b/include/ReaderBase.h index f33158a7..0ec93ede 100644 --- a/include/ReaderBase.h +++ b/include/ReaderBase.h @@ -68,23 +68,23 @@ namespace openshot int height; ///< The height of the video (in pixels) int width; ///< The width of the video (in pixesl) int pixel_format; ///< The pixel format (i.e. YUV420P, RGB24, etc...) - Fraction fps; ///< Frames per second, as a fraction (i.e. 24/1 = 24 fps) + openshot::Fraction fps; ///< Frames per second, as a fraction (i.e. 24/1 = 24 fps) int video_bit_rate; ///< The bit rate of the video stream (in bytes) - Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) - Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) + openshot::Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) + openshot::Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) std::string vcodec; ///< The name of the video codec used to encode / decode the video stream int64_t video_length; ///< The number of frames in the video stream int video_stream_index; ///< The index of the video stream - Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen + openshot::Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen bool interlaced_frame; // Are the contents of this frame interlaced bool top_field_first; // Which interlaced field should be displayed first std::string acodec; ///< The name of the audio codec used to encode / decode the video stream int audio_bit_rate; ///< The bit rate of the audio stream (in bytes) int sample_rate; ///< The number of audio samples per second (44100 is a common sample rate) int channels; ///< The number of audio channels used in the audio stream - ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) + openshot::ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) int audio_stream_index; ///< The index of the audio stream - Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played + openshot::Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played std::map metadata; ///< An optional map/dictionary of metadata for this reader }; @@ -101,7 +101,7 @@ namespace openshot /// Section lock for multiple threads CriticalSection getFrameCriticalSection; CriticalSection processingCriticalSection; - ClipBase* parent; + openshot::ClipBase* parent; public: @@ -109,13 +109,13 @@ namespace openshot ReaderBase(); /// Information about the current media file - ReaderInfo info; + openshot::ReaderInfo info; /// Parent clip object of this reader (which can be unparented and NULL) - ClipBase* GetClip(); + openshot::ClipBase* GetClip(); /// Set parent clip object of this reader - void SetClip(ClipBase* clip); + void SetClip(openshot::ClipBase* clip); /// Close the reader (and any resources it was consuming) virtual void Close() = 0; @@ -124,7 +124,7 @@ namespace openshot void DisplayInfo(); /// Get the cache object used by this reader (note: not all readers use cache) - virtual CacheBase* GetCache() = 0; + virtual openshot::CacheBase* GetCache() = 0; /// This method is required for all derived classes of ReaderBase, and returns the /// openshot::Frame object, which contains the image and audio information for that @@ -132,7 +132,7 @@ namespace openshot /// /// @returns The requested frame of video /// @param[in] number The frame number that is requested. - virtual std::shared_ptr GetFrame(int64_t number) = 0; + virtual std::shared_ptr GetFrame(int64_t number) = 0; /// Determine if reader is open or closed virtual bool IsOpen() = 0; diff --git a/include/RendererBase.h b/include/RendererBase.h index 2638d336..1c526937 100644 --- a/include/RendererBase.h +++ b/include/RendererBase.h @@ -50,7 +50,7 @@ namespace openshot public: /// Paint(render) a video Frame. - void paint(const std::shared_ptr & frame); + void paint(const std::shared_ptr & frame); /// Allow manual override of the QWidget that is used to display virtual void OverrideWidget(int64_t qwidget_address) = 0; @@ -58,7 +58,7 @@ namespace openshot protected: RendererBase(); virtual ~RendererBase(); - + virtual void render(std::shared_ptr image) = 0; }; diff --git a/include/TextReader.h b/include/TextReader.h index 59b0aeed..2d54fdc2 100644 --- a/include/TextReader.h +++ b/include/TextReader.h @@ -98,7 +98,7 @@ namespace openshot std::shared_ptr image; MAGICK_DRAWABLE lines; bool is_open; - GravityType gravity; + openshot::GravityType gravity; public: @@ -126,14 +126,14 @@ namespace openshot void Close(); /// Get the cache object used by this reader (always returns NULL for this object) - CacheMemory* GetCache() { return NULL; }; + openshot::CacheMemory* GetCache() { return NULL; }; /// Get an openshot::Frame object for a specific frame number of this reader. All numbers /// return the same Frame, since they all share the same image data. /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - std::shared_ptr GetFrame(int64_t requested_frame); + std::shared_ptr GetFrame(int64_t requested_frame); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/WriterBase.h b/include/WriterBase.h index 7387d613..503be6bf 100644 --- a/include/WriterBase.h +++ b/include/WriterBase.h @@ -57,23 +57,23 @@ namespace openshot int height; ///< The height of the video (in pixels) int width; ///< The width of the video (in pixels) int pixel_format; ///< The pixel format (i.e. YUV420P, RGB24, etc...) - Fraction fps; ///< Frames per second, as a fraction (i.e. 24/1 = 24 fps) + openshot::Fraction fps; ///< Frames per second, as a fraction (i.e. 24/1 = 24 fps) int video_bit_rate; ///< The bit rate of the video stream (in bytes) - Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) - Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) + openshot::Fraction pixel_ratio; ///< The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) + openshot::Fraction display_ratio; ///< The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) std::string vcodec; ///< The name of the video codec used to encode / decode the video stream int64_t video_length; ///< The number of frames in the video stream int video_stream_index; ///< The index of the video stream - Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen + openshot::Fraction video_timebase; ///< The video timebase determines how long each frame stays on the screen bool interlaced_frame; ///< Are the contents of this frame interlaced bool top_field_first; ///< Which interlaced field should be displayed first std::string acodec; ///< The name of the audio codec used to encode / decode the video stream int audio_bit_rate; ///< The bit rate of the audio stream (in bytes) int sample_rate; ///< The number of audio samples per second (44100 is a common sample rate) int channels; ///< The number of audio channels used in the audio stream - ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) + openshot::ChannelLayout channel_layout; ///< The channel layout (mono, stereo, 5 point surround, etc...) int audio_stream_index; ///< The index of the audio stream - Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played + openshot::Fraction audio_timebase; ///< The audio timebase determines how long each audio packet should be played std::map metadata; ///< An optional map/dictionary of video & audio metadata }; @@ -95,16 +95,16 @@ namespace openshot /// @brief This method copy's the info struct of a reader, and sets the writer with the same info /// @param reader The source reader to copy - void CopyReaderInfo(ReaderBase* reader); + void CopyReaderInfo(openshot::ReaderBase* reader); /// Determine if writer is open or closed virtual bool IsOpen() = 0; /// This method is required for all derived classes of WriterBase. Write a Frame to the video file. - virtual void WriteFrame(std::shared_ptr frame) = 0; + virtual void WriteFrame(std::shared_ptr frame) = 0; /// This method is required for all derived classes of WriterBase. Write a block of frames from a reader. - virtual void WriteFrame(ReaderBase* reader, int64_t start, int64_t length) = 0; + virtual void WriteFrame(openshot::ReaderBase* reader, int64_t start, int64_t length) = 0; /// Get and Set JSON methods std::string Json(); ///< Generate JSON string of this object diff --git a/src/ReaderBase.cpp b/src/ReaderBase.cpp index ab651a9f..1966614c 100644 --- a/src/ReaderBase.cpp +++ b/src/ReaderBase.cpp @@ -252,11 +252,11 @@ void ReaderBase::SetJsonValue(Json::Value root) { } /// Parent clip object of this reader (which can be unparented and NULL) -ClipBase* ReaderBase::GetClip() { +openshot::ClipBase* ReaderBase::GetClip() { return parent; } /// Set parent clip object of this reader -void ReaderBase::SetClip(ClipBase* clip) { +void ReaderBase::SetClip(openshot::ClipBase* clip) { parent = clip; } From dd74fa3af83472478f52fb8b52945d3e23cbb121 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:19:52 -0400 Subject: [PATCH 30/36] ruby openshot.i: namespace fixes - Remove `std::shared_ptr` wrapper - Don't place templates in std:: namespace --- src/bindings/ruby/openshot.i | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 1f3e0d99..1b9b4969 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -6,8 +6,8 @@ # # Copyright (c) 2008-2019 OpenShot Studios, LLC # . This file is part of -# OpenShot Library (libopenshot), an open-source project dedicated to -# delivering high quality video editing and animation solutions to the +# OpenShot Library (libopenshot), an open-source project dedicated to +# delivering high quality video editing and animation solutions to the # world. For more information visit . # # OpenShot Library (libopenshot) is free software: you can redistribute it @@ -56,8 +56,6 @@ namespace std { #endif %template(SPtrAudioBuffer) std::shared_ptr; %template(SPtrOpenFrame) std::shared_ptr; -%template(SPtrFrame) std::shared_ptr; - %{ /* Ruby and FFmpeg define competing RSHIFT macros, @@ -216,13 +214,11 @@ namespace std { /* Wrap std templates (list, vector, etc...) */ -namespace std { - %template(ClipList) list; - %template(EffectBaseList) list; - %template(CoordinateVector) vector; - %template(PointsVector) vector; - %template(FieldVector) vector; - %template(MappedFrameVector) vector; - %template(MappedMetadata) map; - %template(AudioDeviceInfoVector) vector; -} +%template(ClipList) std::list; +%template(EffectBaseList) std::list; +%template(CoordinateVector) std::vector; +%template(PointsVector) std::vector; +%template(FieldVector) std::vector; +%template(MappedFrameVector) std::vector; +%template(MappedMetadata) std::map; +%template(AudioDeviceInfoVector) std::vector; From b03a7011ed521eafff1e80bd31bcbd4b6262ee34 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:21:25 -0400 Subject: [PATCH 31/36] Python openshot.i: Namespace fixes - Remove `%shared_ptr(Frame)` wrapper - Don't place templates in std:: namespace --- src/bindings/python/openshot.i | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index 512224ef..84d6e5eb 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -6,8 +6,8 @@ # # Copyright (c) 2008-2019 OpenShot Studios, LLC # . This file is part of -# OpenShot Library (libopenshot), an open-source project dedicated to -# delivering high quality video editing and animation solutions to the +# OpenShot Library (libopenshot), an open-source project dedicated to +# delivering high quality video editing and animation solutions to the # world. For more information visit . # # OpenShot Library (libopenshot) is free software: you can redistribute it @@ -53,7 +53,6 @@ #endif %shared_ptr(juce::AudioSampleBuffer) %shared_ptr(openshot::Frame) -%shared_ptr(Frame) %{ #include "OpenShotVersion.h" @@ -184,13 +183,11 @@ /* Wrap std templates (list, vector, etc...) */ -namespace std { - %template(ClipList) list; - %template(EffectBaseList) list; - %template(CoordinateVector) vector; - %template(PointsVector) vector; - %template(FieldVector) vector; - %template(MappedFrameVector) vector; - %template(MappedMetadata) map; - %template(AudioDeviceInfoVector) vector; -} +%template(ClipList) std::list; +%template(EffectBaseList) std::list; +%template(CoordinateVector) std::vector; +%template(PointsVector) std::vector; +%template(FieldVector) std::vector; +%template(MappedFrameVector) std::vector; +%template(MappedMetadata) std::map; +%template(AudioDeviceInfoVector) std::vector; From 9ba18d678f710339df04fa7db5cae4e61850cf19 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 02:54:59 -0400 Subject: [PATCH 32/36] std:: prefixing for Example.cpp --- src/examples/Example.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index eec8d00e..ebda6b3f 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) { // Close timeline r9.Close(); - cout << "Completed successfully!" << endl; + std::cout << "Completed successfully!" << std::endl; return 0; -} \ No newline at end of file +} From 066e2558eee55c8b48ed3ed0e8e055f8e61eb3bf Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 03:52:15 -0400 Subject: [PATCH 33/36] AudioResampler: Add juce:: prefixing --- src/AudioResampler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AudioResampler.cpp b/src/AudioResampler.cpp index d9c5a609..cacd7e5b 100644 --- a/src/AudioResampler.cpp +++ b/src/AudioResampler.cpp @@ -74,7 +74,7 @@ AudioResampler::~AudioResampler() } // Sets the audio buffer and updates the key settings -void AudioResampler::SetBuffer(AudioSampleBuffer *new_buffer, double sample_rate, double new_sample_rate) +void AudioResampler::SetBuffer(juce::AudioSampleBuffer *new_buffer, double sample_rate, double new_sample_rate) { if (sample_rate <= 0) sample_rate = 44100; @@ -89,7 +89,7 @@ void AudioResampler::SetBuffer(AudioSampleBuffer *new_buffer, double sample_rate } // Sets the audio buffer and key settings -void AudioResampler::SetBuffer(AudioSampleBuffer *new_buffer, double ratio) +void AudioResampler::SetBuffer(juce::AudioSampleBuffer *new_buffer, double ratio) { // Update buffer & buffer source buffer = new_buffer; @@ -120,7 +120,7 @@ void AudioResampler::SetBuffer(AudioSampleBuffer *new_buffer, double ratio) } // Get the resampled audio buffer -AudioSampleBuffer* AudioResampler::GetResampledBuffer() +juce::AudioSampleBuffer* AudioResampler::GetResampledBuffer() { // Resample the current frame's audio buffer (into the temp callback buffer) resample_source->getNextAudioBlock(resample_callback_buffer); From 6aebb10cea6c4e0cf7abd43108d42340da8f82e3 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sat, 21 Sep 2019 00:14:32 -0400 Subject: [PATCH 34/36] More explicit prefixing in Qt/ and Player classes --- include/PlayerBase.h | 2 +- include/Qt/AudioPlaybackThread.h | 35 ++-- include/Qt/PlayerDemo.h | 4 +- include/Qt/PlayerPrivate.h | 20 +- include/Qt/VideoRenderWidget.h | 2 +- include/QtPlayer.h | 5 +- src/PlayerBase.cpp | 4 +- src/Qt/AudioPlaybackThread.cpp | 12 +- src/Qt/PlayerDemo.cpp | 2 +- src/Qt/PlayerPrivate.cpp | 56 +++--- src/QtPlayer.cpp | 301 ++++++++++++++++--------------- 11 files changed, 222 insertions(+), 221 deletions(-) diff --git a/include/PlayerBase.h b/include/PlayerBase.h index a66458ed..aa34c5d2 100644 --- a/include/PlayerBase.h +++ b/include/PlayerBase.h @@ -94,7 +94,7 @@ namespace openshot virtual void Stop() = 0; /// Get the current reader, such as a FFmpegReader - virtual ReaderBase* Reader() = 0; + virtual openshot::ReaderBase* Reader() = 0; /// Set the current reader, such as a FFmpegReader virtual void Reader(openshot::ReaderBase *new_reader) = 0; diff --git a/include/Qt/AudioPlaybackThread.h b/include/Qt/AudioPlaybackThread.h index 54bd490b..348a0f48 100644 --- a/include/Qt/AudioPlaybackThread.h +++ b/include/Qt/AudioPlaybackThread.h @@ -40,16 +40,13 @@ namespace openshot { - using juce::Thread; - using juce::WaitableEvent; - - struct SafeTimeSliceThread : TimeSliceThread + struct SafeTimeSliceThread : juce::TimeSliceThread { - SafeTimeSliceThread(const String & s) : TimeSliceThread(s) {} + SafeTimeSliceThread(const String & s) : juce::TimeSliceThread(s) {} void run() { try { - TimeSliceThread::run(); + juce::TimeSliceThread::run(); } catch (const TooManySeeks & e) { // ... } @@ -72,7 +69,7 @@ namespace openshot std::string initialise_error; /// List of valid audio device names - std::vector audio_device_names; + std::vector audio_device_names; /// Override with no channels and no preferred audio device static AudioDeviceManagerSingleton * Instance(); @@ -87,7 +84,7 @@ namespace openshot /** * @brief The audio playback thread */ - class AudioPlaybackThread : Thread + class AudioPlaybackThread : juce::Thread { AudioSourcePlayer player; AudioTransportSource transport; @@ -95,8 +92,8 @@ namespace openshot AudioReaderSource *source; double sampleRate; int numChannels; - WaitableEvent play; - WaitableEvent played; + juce::WaitableEvent play; + juce::WaitableEvent played; int buffer_size; bool is_playing; SafeTimeSliceThread time_thread; @@ -107,10 +104,10 @@ namespace openshot ~AudioPlaybackThread(); /// Set the current thread's reader - void Reader(ReaderBase *reader); + void Reader(openshot::ReaderBase *reader); /// Get the current frame object (which is filling the buffer) - std::shared_ptr getFrame(); + std::shared_ptr getFrame(); /// Get the current frame number being played int64_t getCurrentFramePosition(); @@ -133,11 +130,17 @@ namespace openshot /// Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...) int getSpeed() const { if (source) return source->getSpeed(); else return 1; } - /// Get Audio Error (if any) - std::string getError() { return AudioDeviceManagerSingleton::Instance()->initialise_error; } + /// Get Audio Error (if any) + std::string getError() + { + return AudioDeviceManagerSingleton::Instance()->initialise_error; + } - /// Get Audio Device Names (if any) - std::vector getAudioDeviceNames() { return AudioDeviceManagerSingleton::Instance()->audio_device_names; }; + /// Get Audio Device Names (if any) + std::vector getAudioDeviceNames() + { + return AudioDeviceManagerSingleton::Instance()->audio_device_names; + }; friend class PlayerPrivate; friend class QtPlayer; diff --git a/include/Qt/PlayerDemo.h b/include/Qt/PlayerDemo.h index cfed78bd..f444334b 100644 --- a/include/Qt/PlayerDemo.h +++ b/include/Qt/PlayerDemo.h @@ -46,8 +46,6 @@ namespace openshot class QtPlayer; } -using openshot::QtPlayer; - class PlayerDemo : public QWidget { Q_OBJECT @@ -67,7 +65,7 @@ private: QVBoxLayout *vbox; QMenuBar *menu; VideoRenderWidget *video; - QtPlayer *player; + openshot::QtPlayer *player; }; #endif // OPENSHOT_PLAYER_H diff --git a/include/Qt/PlayerPrivate.h b/include/Qt/PlayerPrivate.h index f846fb2a..e403c10e 100644 --- a/include/Qt/PlayerPrivate.h +++ b/include/Qt/PlayerPrivate.h @@ -41,27 +41,25 @@ namespace openshot { - using juce::Thread; - /** * @brief The private part of QtPlayer class, which contains an audio thread and video thread, * and controls the video timing and audio synchronization code. */ - class PlayerPrivate : Thread + class PlayerPrivate : juce::Thread { - std::shared_ptr frame; /// The current frame + std::shared_ptr frame; /// The current frame int64_t video_position; /// The current frame position. int64_t audio_position; /// The current frame position. - ReaderBase *reader; /// The reader which powers this player - AudioPlaybackThread *audioPlayback; /// The audio thread - VideoPlaybackThread *videoPlayback; /// The video thread - VideoCacheThread *videoCache; /// The cache thread + openshot::ReaderBase *reader; /// The reader which powers this player + openshot::AudioPlaybackThread *audioPlayback; /// The audio thread + openshot::VideoPlaybackThread *videoPlayback; /// The video thread + openshot::VideoCacheThread *videoCache; /// The cache thread int speed; /// The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...) - RendererBase *renderer; + openshot::RendererBase *renderer; int64_t last_video_position; /// The last frame actually displayed /// Constructor - PlayerPrivate(RendererBase *rb); + PlayerPrivate(openshot::RendererBase *rb); /// Destructor virtual ~PlayerPrivate(); @@ -75,7 +73,7 @@ namespace openshot void stopPlayback(int timeOutMilliseconds = -1); /// Get the next frame (based on speed and direction) - std::shared_ptr getFrame(); + std::shared_ptr getFrame(); /// The parent class of PlayerPrivate friend class QtPlayer; diff --git a/include/Qt/VideoRenderWidget.h b/include/Qt/VideoRenderWidget.h index 429940e7..07c61037 100644 --- a/include/Qt/VideoRenderWidget.h +++ b/include/Qt/VideoRenderWidget.h @@ -60,7 +60,7 @@ protected: QRect centeredViewport(int width, int height); private slots: - void present(const QImage &image); + void present(const QImage &image); }; diff --git a/include/QtPlayer.h b/include/QtPlayer.h index 8bb77060..7ddf6ada 100644 --- a/include/QtPlayer.h +++ b/include/QtPlayer.h @@ -44,9 +44,9 @@ namespace openshot * @brief This class is used to playback a video from a reader. * */ - class QtPlayer : public PlayerBase + class QtPlayer : public openshot::PlayerBase { - PlayerPrivate *p; + openshot::PlayerPrivate *p; bool threads_started; public: @@ -116,7 +116,6 @@ namespace openshot /// Set the Volume (1.0 = normal volume, <1.0 = quieter, >1.0 louder) void Volume(float new_volume); }; - } #endif diff --git a/src/PlayerBase.cpp b/src/PlayerBase.cpp index 3c904afd..f152fbbb 100644 --- a/src/PlayerBase.cpp +++ b/src/PlayerBase.cpp @@ -63,12 +63,12 @@ void PlayerBase::Stop() { } // Get the current reader, such as a FFmpegReader -ReaderBase* PlayerBase::Reader() { +openshot::ReaderBase* PlayerBase::Reader() { return reader; } // Set the current reader, such as a FFmpegReader -void PlayerBase::Reader(ReaderBase *new_reader) { +void PlayerBase::Reader(openshot::ReaderBase *new_reader) { reader = new_reader; } diff --git a/src/Qt/AudioPlaybackThread.cpp b/src/Qt/AudioPlaybackThread.cpp index 7a6e4569..44c837e7 100644 --- a/src/Qt/AudioPlaybackThread.cpp +++ b/src/Qt/AudioPlaybackThread.cpp @@ -66,13 +66,13 @@ namespace openshot for (int i = 0; i < m_pInstance->audioDeviceManager.getAvailableDeviceTypes().size(); ++i) { const AudioIODeviceType* t = m_pInstance->audioDeviceManager.getAvailableDeviceTypes()[i]; - const StringArray deviceNames = t->getDeviceNames (); + const juce::StringArray deviceNames = t->getDeviceNames (); for (int j = 0; j < deviceNames.size (); ++j ) { juce::String deviceName = deviceNames[j]; juce::String typeName = t->getTypeName(); - AudioDeviceInfo deviceInfo = {deviceName.toRawUTF8(), typeName.toRawUTF8()}; + openshot::AudioDeviceInfo deviceInfo = {deviceName.toRawUTF8(), typeName.toRawUTF8()}; m_pInstance->audio_device_names.push_back(deviceInfo); } } @@ -92,7 +92,7 @@ namespace openshot // Constructor AudioPlaybackThread::AudioPlaybackThread() - : Thread("audio-playback") + : juce::Thread("audio-playback") , player() , transport() , mixer() @@ -111,7 +111,7 @@ namespace openshot } // Set the reader object - void AudioPlaybackThread::Reader(ReaderBase *reader) { + void AudioPlaybackThread::Reader(openshot::ReaderBase *reader) { if (source) source->Reader(reader); else { @@ -132,10 +132,10 @@ namespace openshot } // Get the current frame object (which is filling the buffer) - std::shared_ptr AudioPlaybackThread::getFrame() + std::shared_ptr AudioPlaybackThread::getFrame() { if (source) return source->getFrame(); - return std::shared_ptr(); + return std::shared_ptr(); } // Get the currently playing frame number diff --git a/src/Qt/PlayerDemo.cpp b/src/Qt/PlayerDemo.cpp index 9b369b6d..ba20e5cf 100644 --- a/src/Qt/PlayerDemo.cpp +++ b/src/Qt/PlayerDemo.cpp @@ -39,7 +39,7 @@ PlayerDemo::PlayerDemo(QWidget *parent) , vbox(new QVBoxLayout(this)) , menu(new QMenuBar(this)) , video(new VideoRenderWidget(this)) - , player(new QtPlayer(video->GetRenderer())) + , player(new openshot::QtPlayer(video->GetRenderer())) { setWindowTitle("OpenShot Player"); diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index d0f17842..e7c881f8 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -33,22 +33,22 @@ namespace openshot { - // Constructor - PlayerPrivate::PlayerPrivate(RendererBase *rb) - : renderer(rb), Thread("player"), video_position(1), audio_position(0) - , audioPlayback(new AudioPlaybackThread()) - , videoPlayback(new VideoPlaybackThread(rb)) - , videoCache(new VideoCacheThread()) + // Constructor + PlayerPrivate::PlayerPrivate(openshot::RendererBase *rb) + : renderer(rb), Thread("player"), video_position(1), audio_position(0) + , audioPlayback(new openshot::AudioPlaybackThread()) + , videoPlayback(new openshot::VideoPlaybackThread(rb)) + , videoCache(new openshot::VideoCacheThread()) , speed(1), reader(NULL), last_video_position(1) { } // Destructor PlayerPrivate::~PlayerPrivate() { - stopPlayback(1000); - delete audioPlayback; - delete videoCache; - delete videoPlayback; + stopPlayback(1000); + delete audioPlayback; + delete videoCache; + delete videoPlayback; } // Start thread @@ -138,7 +138,7 @@ namespace openshot } // Get the next displayed frame (based on speed and direction) - std::shared_ptr PlayerPrivate::getFrame() + std::shared_ptr PlayerPrivate::getFrame() { try { // Get the next frame (based on speed) @@ -158,35 +158,33 @@ namespace openshot return reader->GetFrame(video_position); } - } catch (const ReaderClosed & e) { - // ... - } catch (const TooManySeeks & e) { - // ... - } catch (const OutOfBoundsFrame & e) { - // ... - } - return std::shared_ptr(); + } catch (const ReaderClosed & e) { + // ... + } catch (const TooManySeeks & e) { + // ... + } catch (const OutOfBoundsFrame & e) { + // ... + } + return std::shared_ptr(); } // Start video/audio playback bool PlayerPrivate::startPlayback() { - if (video_position < 0) return false; + if (video_position < 0) return false; - stopPlayback(-1); - startThread(1); - return true; + stopPlayback(-1); + startThread(1); + return true; } // Stop video/audio playback void PlayerPrivate::stopPlayback(int timeOutMilliseconds) { - if (isThreadRunning()) stopThread(timeOutMilliseconds); - if (audioPlayback->isThreadRunning() && reader->info.has_audio) audioPlayback->stopThread(timeOutMilliseconds); - if (videoCache->isThreadRunning() && reader->info.has_video) videoCache->stopThread(timeOutMilliseconds); - if (videoPlayback->isThreadRunning() && reader->info.has_video) videoPlayback->stopThread(timeOutMilliseconds); - + if (isThreadRunning()) stopThread(timeOutMilliseconds); + if (audioPlayback->isThreadRunning() && reader->info.has_audio) audioPlayback->stopThread(timeOutMilliseconds); + if (videoCache->isThreadRunning() && reader->info.has_video) videoCache->stopThread(timeOutMilliseconds); + if (videoPlayback->isThreadRunning() && reader->info.has_video) videoPlayback->stopThread(timeOutMilliseconds); } - } diff --git a/src/QtPlayer.cpp b/src/QtPlayer.cpp index dc43b3d5..e4d862d1 100644 --- a/src/QtPlayer.cpp +++ b/src/QtPlayer.cpp @@ -36,184 +36,189 @@ #include "../include/Qt/PlayerPrivate.h" #include "../include/Qt/VideoRenderer.h" -using namespace openshot; - -QtPlayer::QtPlayer() : PlayerBase(), p(new PlayerPrivate(new VideoRenderer())), threads_started(false) +namespace openshot { - reader = NULL; -} + // Delegating constructor + QtPlayer::QtPlayer() + : QtPlayer::QtPlayer(new VideoRenderer()) + { } -QtPlayer::QtPlayer(RendererBase *rb) : PlayerBase(), p(new PlayerPrivate(rb)), threads_started(false) -{ - reader = NULL; -} + // Constructor + QtPlayer::QtPlayer(openshot::RendererBase *rb) + : PlayerBase() + , p(new openshot::PlayerPrivate(rb)) + , threads_started(false) + { + reader = NULL; + } -QtPlayer::~QtPlayer() -{ - if (mode != PLAYBACK_STOPPED) - Stop(); + QtPlayer::~QtPlayer() + { + if (mode != PLAYBACK_STOPPED) + Stop(); - delete p; -} + delete p; + } -void QtPlayer::CloseAudioDevice() -{ - // Close audio device (only do this once, when all audio playback is finished) - AudioDeviceManagerSingleton::Instance()->CloseAudioDevice(); -} + void QtPlayer::CloseAudioDevice() + { + // Close audio device (only do this once, when all audio playback is finished) + openshot::AudioDeviceManagerSingleton::Instance()->CloseAudioDevice(); + } -// Return any error string during initialization -std::string QtPlayer::GetError() { - if (reader && threads_started) { - // Get error from audio thread (if any) - return p->audioPlayback->getError(); - } else { - return ""; - } -} + // Return any error string during initialization + std::string QtPlayer::GetError() { + if (reader && threads_started) { + // Get error from audio thread (if any) + return p->audioPlayback->getError(); + } else { + return ""; + } + } -/// Get Audio Devices from JUCE -std::vector QtPlayer::GetAudioDeviceNames() { - if (reader && threads_started) { - return p->audioPlayback->getAudioDeviceNames(); - } else { - return std::vector(); - } -} + /// Get Audio Devices from JUCE + std::vector QtPlayer::GetAudioDeviceNames() { + if (reader && threads_started) { + return p->audioPlayback->getAudioDeviceNames(); + } else { + return std::vector(); + } + } -void QtPlayer::SetSource(const std::string &source) -{ - FFmpegReader *ffreader = new FFmpegReader(source); - ffreader->DisplayInfo(); + void QtPlayer::SetSource(const std::string &source) + { + FFmpegReader *ffreader = new FFmpegReader(source); + ffreader->DisplayInfo(); - reader = new Timeline(ffreader->info.width, ffreader->info.height, ffreader->info.fps, ffreader->info.sample_rate, ffreader->info.channels, ffreader->info.channel_layout); - Clip *c = new Clip(source); + reader = new Timeline(ffreader->info.width, ffreader->info.height, ffreader->info.fps, ffreader->info.sample_rate, ffreader->info.channels, ffreader->info.channel_layout); + Clip *c = new Clip(source); - Timeline* tm = (Timeline*)reader; - tm->AddClip(c); - tm->Open(); + Timeline* tm = (Timeline*)reader; + tm->AddClip(c); + tm->Open(); - // Set the reader - Reader(reader); -} + // Set the reader + Reader(reader); + } -void QtPlayer::Play() -{ - // Set mode to playing, and speed to normal - mode = PLAYBACK_PLAY; - Speed(1); + void QtPlayer::Play() + { + // Set mode to playing, and speed to normal + mode = PLAYBACK_PLAY; + Speed(1); - if (reader && !threads_started) { - // Start thread only once - p->startPlayback(); - threads_started = true; - } -} + if (reader && !threads_started) { + // Start thread only once + p->startPlayback(); + threads_started = true; + } + } -void QtPlayer::Loading() -{ - mode = PLAYBACK_LOADING; -} + void QtPlayer::Loading() + { + mode = PLAYBACK_LOADING; + } -/// Get the current mode -PlaybackMode QtPlayer::Mode() -{ - return mode; -} + /// Get the current mode + openshot::PlaybackMode QtPlayer::Mode() + { + return mode; + } -void QtPlayer::Pause() -{ - mode = PLAYBACK_PAUSED; - Speed(0); -} + void QtPlayer::Pause() + { + mode = PLAYBACK_PAUSED; + Speed(0); + } -int64_t QtPlayer::Position() -{ - return p->video_position; -} + int64_t QtPlayer::Position() + { + return p->video_position; + } -void QtPlayer::Seek(int64_t new_frame) -{ - // Check for seek - if (reader && threads_started && new_frame > 0) { - // Notify cache thread that seek has occurred - p->videoCache->Seek(new_frame); + void QtPlayer::Seek(int64_t new_frame) + { + // Check for seek + if (reader && threads_started && new_frame > 0) { + // Notify cache thread that seek has occurred + p->videoCache->Seek(new_frame); - // Update current position - p->video_position = new_frame; + // Update current position + p->video_position = new_frame; - // Clear last position (to force refresh) - p->last_video_position = 0; + // Clear last position (to force refresh) + p->last_video_position = 0; - // Notify audio thread that seek has occurred - p->audioPlayback->Seek(new_frame); - } -} + // Notify audio thread that seek has occurred + p->audioPlayback->Seek(new_frame); + } + } -void QtPlayer::Stop() -{ - // Change mode to stopped - mode = PLAYBACK_STOPPED; + void QtPlayer::Stop() + { + // Change mode to stopped + mode = PLAYBACK_STOPPED; - // Notify threads of stopping - if (reader && threads_started) { - p->videoCache->Stop(); - p->audioPlayback->Stop(); + // Notify threads of stopping + if (reader && threads_started) { + p->videoCache->Stop(); + p->audioPlayback->Stop(); - // Kill all threads - p->stopPlayback(); - } + // Kill all threads + p->stopPlayback(); + } - p->video_position = 0; - threads_started = false; -} + p->video_position = 0; + threads_started = false; + } -// Set the reader object -void QtPlayer::Reader(ReaderBase *new_reader) -{ - // Set new reader. Note: Be sure to close and dispose of the old reader after calling this - reader = new_reader; - p->reader = new_reader; - p->videoCache->Reader(new_reader); - p->audioPlayback->Reader(new_reader); -} + // Set the reader object + void QtPlayer::Reader(openshot::ReaderBase *new_reader) + { + // Set new reader. Note: Be sure to close and dispose of the old reader after calling this + reader = new_reader; + p->reader = new_reader; + p->videoCache->Reader(new_reader); + p->audioPlayback->Reader(new_reader); + } -// Get the current reader, such as a FFmpegReader -ReaderBase* QtPlayer::Reader() { - return reader; -} + // Get the current reader, such as a FFmpegReader + openshot::ReaderBase* QtPlayer::Reader() { + return reader; + } -// Set the QWidget pointer to display the video on (as a LONG pointer id) -void QtPlayer::SetQWidget(int64_t qwidget_address) { - // Update override QWidget address on the video renderer - p->renderer->OverrideWidget(qwidget_address); -} + // Set the QWidget pointer to display the video on (as a LONG pointer id) + void QtPlayer::SetQWidget(int64_t qwidget_address) { + // Update override QWidget address on the video renderer + p->renderer->OverrideWidget(qwidget_address); + } -// Get the Renderer pointer address (for Python to cast back into a QObject) -int64_t QtPlayer::GetRendererQObject() { - return (int64_t)(VideoRenderer*)p->renderer; -} + // Get the Renderer pointer address (for Python to cast back into a QObject) + int64_t QtPlayer::GetRendererQObject() { + return (int64_t)(VideoRenderer*)p->renderer; + } -// Get the Playback speed -float QtPlayer::Speed() { - return speed; -} + // Get the Playback speed + float QtPlayer::Speed() { + return speed; + } -// Set the Playback speed multiplier (1.0 = normal speed, <1.0 = slower, >1.0 faster) -void QtPlayer::Speed(float new_speed) { - speed = new_speed; - p->speed = new_speed; - p->videoCache->setSpeed(new_speed); - if (p->reader->info.has_audio) - p->audioPlayback->setSpeed(new_speed); -} + // Set the Playback speed multiplier (1.0 = normal speed, <1.0 = slower, >1.0 faster) + void QtPlayer::Speed(float new_speed) { + speed = new_speed; + p->speed = new_speed; + p->videoCache->setSpeed(new_speed); + if (p->reader->info.has_audio) + p->audioPlayback->setSpeed(new_speed); + } -// Get the Volume -float QtPlayer::Volume() { - return volume; -} + // Get the Volume + float QtPlayer::Volume() { + return volume; + } -// Set the Volume multiplier (1.0 = normal volume, <1.0 = quieter, >1.0 louder) -void QtPlayer::Volume(float new_volume) { - volume = new_volume; -} + // Set the Volume multiplier (1.0 = normal volume, <1.0 = quieter, >1.0 louder) + void QtPlayer::Volume(float new_volume) { + volume = new_volume; + } +} \ No newline at end of file From 60f6ad652a88b6b974e36fd377bc6581043ef4c6 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Tue, 29 Oct 2019 16:31:36 -0400 Subject: [PATCH 35/36] FFmpegWriter.cpp: add std:: prefixes New code added uses of `std::min`, `std::max`, `std::stoi`, and `std::pow` --- src/FFmpegWriter.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 5865d3bb..0a258284 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -394,7 +394,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 39, 101) #if IS_FFMPEG_3_2 if (hw_en_on) { - av_opt_set_int(c->priv_data, "qp", min(stoi(value),63), 0); // 0-63 + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); // 0-63 } else #endif { @@ -402,37 +402,37 @@ 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, "qp", min(stoi(value),63), 0); // 0-63 + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); // 0-63 break; #endif case AV_CODEC_ID_VP8 : c->bit_rate = 10000000; - av_opt_set_int(c->priv_data, "qp", max(min(stoi(value), 63), 4), 0); // 4-63 + av_opt_set_int(c->priv_data, "qp", std::max(std::min(std::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, "qp", min(stoi(value), 63), 0); // 0-63 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 63), 0); // 0-63 + if (std::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, "qp", min(stoi(value), 51), 0); // 0-51 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 51), 0); // 0-51 + if (std::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, "qp", min(stoi(value), 51), 0); // 0-51 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 51), 0); // 0-51 + if (std::stoi(value) == 0) { av_opt_set(c->priv_data, "preset", "veryslow", 0); av_opt_set_int(c->priv_data, "lossless", 1, 0); } break; default: // For all other codecs assume a range of 0-63 - av_opt_set_int(c->priv_data, "qp", min(stoi(value), 63), 0); // 0-63 + av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 63), 0); // 0-63 c->bit_rate = 0; } } @@ -450,7 +450,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va mbs = 380000.0; } else { - mbs *= pow(0.912,info.video_bit_rate); + mbs *= std::pow(0.912,info.video_bit_rate); } } c->bit_rate = (int)(mbs); @@ -461,30 +461,30 @@ 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", std::min(stoi(value),63), 0); + av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value),63), 0); break; #endif case AV_CODEC_ID_VP8 : c->bit_rate = 10000000; - av_opt_set_int(c->priv_data, "crf", std::max(std::min(stoi(value), 63), 4), 0); // 4-63 + av_opt_set_int(c->priv_data, "crf", std::max(std::min(std::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", std::min(stoi(value), 63), 0); // 0-63 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 63), 0); // 0-63 + if (std::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", std::min(stoi(value), 51), 0); // 0-51 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 51), 0); // 0-51 + if (std::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", std::min(stoi(value), 51), 0); // 0-51 - if (stoi(value) == 0) { + av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 51), 0); // 0-51 + if (std::stoi(value) == 0) { av_opt_set(c->priv_data, "preset", "veryslow", 0); av_opt_set_int(c->priv_data, "lossless", 1, 0); } @@ -497,7 +497,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va if (info.video_bit_rate > 42) { mbs = 380000.0; } else { - mbs *= pow(0.912, info.video_bit_rate); + mbs *= std::pow(0.912, info.video_bit_rate); } } c->bit_rate = (int) (mbs); From 2535588ad8f47673f0752fa1161378e6e5600097 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 30 Oct 2019 03:43:11 -0400 Subject: [PATCH 36/36] Prefixing fixes for QtHtml/QtText Readers --- include/QtTextReader.h | 2 +- src/QtHtmlReader.cpp | 6 +++--- src/QtTextReader.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/QtTextReader.h b/include/QtTextReader.h index 3bcb2236..11348d18 100644 --- a/include/QtTextReader.h +++ b/include/QtTextReader.h @@ -146,7 +146,7 @@ namespace openshot /// Get and Set JSON methods std::string Json(); ///< Generate JSON string of this object - void SetJson(string value); ///< Load JSON string into this object + void SetJson(std::string value); ///< Load JSON string into this object Json::Value JsonValue(); ///< Generate Json::JsonValue for this object void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object diff --git a/src/QtHtmlReader.cpp b/src/QtHtmlReader.cpp index e3cdc602..cfdde9f3 100644 --- a/src/QtHtmlReader.cpp +++ b/src/QtHtmlReader.cpp @@ -220,17 +220,17 @@ void QtHtmlReader::SetJson(std::string value) { if (!success) // Raise exception - throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); + throw InvalidJSON("JSON could not be parsed (or is invalid)"); try { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) - throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); + throw InvalidJSON("JSON is invalid (missing keys or invalid data types)"); } } diff --git a/src/QtTextReader.cpp b/src/QtTextReader.cpp index 38240c96..ee0c598a 100644 --- a/src/QtTextReader.cpp +++ b/src/QtTextReader.cpp @@ -52,7 +52,7 @@ QtTextReader::QtTextReader(int width, int height, int x_offset, int y_offset, Gr Close(); } -void QtTextReader::SetTextBackgroundColor(string color) { +void QtTextReader::SetTextBackgroundColor(std::string color) { text_background_color = color; // Open and Close the reader, to populate it's attributes (such as height, width, etc...) plus the text background color @@ -239,17 +239,17 @@ void QtTextReader::SetJson(std::string value) { if (!success) // Raise exception - throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); + throw InvalidJSON("JSON could not be parsed (or is invalid)"); try { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) - throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); + throw InvalidJSON("JSON is invalid (missing keys or invalid data types)"); } }