diff --git a/CMakeLists.txt b/CMakeLists.txt index 35055a06..eaf7d65f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,9 @@ PROJECT(openshot) MESSAGE("--------------------------------------------------------------") MESSAGE("Generating build files for ${PROJECT_NAME} (${PROJECT_VERSION})") +#### Enable C++11 (for std::shared_ptr support) +set(CMAKE_CXX_FLAGS "-std=c++11") + IF (WIN32) SET_PROPERTY(GLOBAL PROPERTY WIN32 "WIN32") ENDIF(WIN32) diff --git a/include/AudioReaderSource.h b/include/AudioReaderSource.h index 92fd6db4..4505426a 100644 --- a/include/AudioReaderSource.h +++ b/include/AudioReaderSource.h @@ -63,7 +63,7 @@ namespace openshot ReaderBase *reader; /// The reader to pull samples from int64 original_frame_number; /// The current frame to read from int64 frame_number; /// The current frame number - tr1::shared_ptr frame; /// The current frame object that is being read + std::shared_ptr frame; /// The current frame object that is being read long int frame_position; /// The position of the current frame's buffer double estimated_frame; /// The estimated frame position of the currently playing buffer int estimated_samples_per_frame; /// The estimated samples per frame of video @@ -118,7 +118,7 @@ namespace openshot const ReaderInfo & getReaderInfo() const { return reader->info; } /// Return the current frame object - tr1::shared_ptr getFrame() const { return frame; } + std::shared_ptr getFrame() const { return frame; } /// Get the estimate frame that is playing at this moment long int getEstimatedFrame() const { return long(estimated_frame); } diff --git a/include/CacheBase.h b/include/CacheBase.h index c3c46164..41c7d1f9 100644 --- a/include/CacheBase.h +++ b/include/CacheBase.h @@ -28,7 +28,7 @@ #ifndef OPENSHOT_CACHE_BASE_H #define OPENSHOT_CACHE_BASE_H -#include +#include #include "Frame.h" #include "Exceptions.h" #include "Json.h" @@ -62,7 +62,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - virtual void Add(tr1::shared_ptr frame) = 0; + virtual void Add(std::shared_ptr frame) = 0; /// Clear the cache of all frames virtual void Clear() = 0; @@ -72,13 +72,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - virtual tr1::shared_ptr GetFrame(long int frame_number) = 0; + virtual std::shared_ptr GetFrame(long int frame_number) = 0; /// Gets the maximum bytes value virtual long long int GetBytes() = 0; /// Get the smallest frame number - virtual tr1::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 4ea47077..3a13dcf2 100644 --- a/include/CacheDisk.h +++ b/include/CacheDisk.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include "CacheBase.h" #include "Frame.h" #include "Exceptions.h" @@ -93,7 +93,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - void Add(tr1::shared_ptr frame); + void Add(std::shared_ptr frame); /// Clear the cache of all frames void Clear(); @@ -103,13 +103,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - tr1::shared_ptr GetFrame(long int frame_number); + std::shared_ptr GetFrame(long int frame_number); /// Gets the maximum bytes value long long int GetBytes(); /// Get the smallest frame number - tr1::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 d22eab29..7002c36e 100644 --- a/include/CacheMemory.h +++ b/include/CacheMemory.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include "CacheBase.h" #include "Frame.h" #include "Exceptions.h" @@ -47,7 +47,7 @@ namespace openshot { */ class CacheMemory : public CacheBase { private: - map > frames; ///< This map holds the frame number and Frame objects + map > frames; ///< This map holds the frame number and Frame objects 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 @@ -75,7 +75,7 @@ namespace openshot { /// @brief Add a Frame to the cache /// @param frame The openshot::Frame object needing to be cached. - void Add(tr1::shared_ptr frame); + void Add(std::shared_ptr frame); /// Clear the cache of all frames void Clear(); @@ -85,13 +85,13 @@ namespace openshot { /// @brief Get a frame from the cache /// @param frame_number The frame number of the cached frame - tr1::shared_ptr GetFrame(long int frame_number); + std::shared_ptr GetFrame(long int frame_number); /// Gets the maximum bytes value long long int GetBytes(); /// Get the smallest frame number - tr1::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 8a52f56e..5e87837f 100644 --- a/include/ChunkReader.h +++ b/include/ChunkReader.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include "Json.h" #include "CacheMemory.h" #include "Exceptions.h" @@ -110,7 +110,7 @@ namespace openshot FFmpegReader *local_reader; ChunkLocation previous_location; ChunkVersion version; - tr1::shared_ptr last_frame; + std::shared_ptr last_frame; /// Check if folder path existing bool does_folder_exist(string path); @@ -149,7 +149,7 @@ namespace openshot /// @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 - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed, ChunkNotFound); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed, ChunkNotFound); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/ChunkWriter.h b/include/ChunkWriter.h index 5246719a..80a52986 100644 --- a/include/ChunkWriter.h +++ b/include/ChunkWriter.h @@ -90,7 +90,7 @@ namespace openshot FFmpegWriter *writer_thumb; FFmpegWriter *writer_preview; FFmpegWriter *writer_final; - tr1::shared_ptr last_frame; + std::shared_ptr last_frame; bool last_frame_needed; string default_extension; string default_vcodec; @@ -133,7 +133,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(tr1::shared_ptr frame) throw(WriterClosed); + void WriteFrame(std::shared_ptr frame) throw(WriterClosed); /// @brief Write a block of frames from a reader /// @param start The starting frame number to write (of the reader passed into the constructor) diff --git a/include/Clip.h b/include/Clip.h index 7e9012e5..4b35a868 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -33,7 +33,7 @@ #define __JUCE_UNITTEST_JUCEHEADER__ #endif -#include +#include #include #include #include "JuceLibraryCode/JuceHeader.h" @@ -127,16 +127,16 @@ namespace openshot { long int adjust_frame_number_minimum(long int frame_number); /// Apply effects to the source frame (if any) - tr1::shared_ptr apply_effects(tr1::shared_ptr frame); + std::shared_ptr apply_effects(std::shared_ptr frame); /// Get file extension string get_file_extension(string path); /// Get a frame object or create a blank one - tr1::shared_ptr GetOrCreateFrame(long int number); + std::shared_ptr GetOrCreateFrame(long int number); /// Adjust the audio and image of a time mapped frame - tr1::shared_ptr get_time_mapped_frame(tr1::shared_ptr frame, long int frame_number) throw(ReaderClosed); + std::shared_ptr get_time_mapped_frame(std::shared_ptr frame, long int frame_number) throw(ReaderClosed); /// Init default settings for a clip void init_settings(); @@ -181,7 +181,7 @@ namespace openshot { /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Open the internal reader void Open() throw(InvalidFile, ReaderClosed); diff --git a/include/ClipBase.h b/include/ClipBase.h index 8a4e2763..fa170bb9 100644 --- a/include/ClipBase.h +++ b/include/ClipBase.h @@ -33,7 +33,7 @@ #define __JUCE_UNITTEST_JUCEHEADER__ #endif -#include +#include #include #include "Exceptions.h" #include "Point.h" diff --git a/include/DecklinkInput.h b/include/DecklinkInput.h index 8fb5930a..3f2daf87 100644 --- a/include/DecklinkInput.h +++ b/include/DecklinkInput.h @@ -93,7 +93,7 @@ public: virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*); // Extra methods - tr1::shared_ptr GetFrame(long int requested_frame); + std::shared_ptr GetFrame(long int requested_frame); unsigned long GetCurrentFrameNumber(); private: diff --git a/include/DecklinkOutput.h b/include/DecklinkOutput.h index 6eab8107..fb461438 100644 --- a/include/DecklinkOutput.h +++ b/include/DecklinkOutput.h @@ -97,7 +97,7 @@ protected: // Queue of raw video frames //deque final_frames; deque final_frames; - deque > raw_video_frames; + deque > raw_video_frames; // Convert between YUV and RGB IDeckLinkOutput *deckLinkOutput; @@ -125,7 +125,7 @@ public: void ScheduleNextFrame(bool prerolling); /// Custom method to write new frames - void WriteFrame(tr1::shared_ptr frame); + void WriteFrame(std::shared_ptr frame); private: ULONG m_refCount; diff --git a/include/DecklinkReader.h b/include/DecklinkReader.h index 70e41711..d3de4586 100644 --- a/include/DecklinkReader.h +++ b/include/DecklinkReader.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include "CacheMemory.h" @@ -107,7 +107,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); unsigned long GetCurrentFrameNumber(); /// Determine if reader is open or closed diff --git a/include/DecklinkWriter.h b/include/DecklinkWriter.h index 6094b05f..a603a33b 100644 --- a/include/DecklinkWriter.h +++ b/include/DecklinkWriter.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include "CacheMemory.h" @@ -96,7 +96,7 @@ namespace openshot void Close(); /// This method is required for all derived classes of WriterBase. Write a Frame to the video file. - void WriteFrame(tr1::shared_ptr frame) throw(WriterClosed); + void WriteFrame(std::shared_ptr frame) throw(WriterClosed); /// This method is required for all derived classes of WriterBase. Write a block of frames from a reader. void WriteFrame(ReaderBase* reader, int start, int length) throw(WriterClosed); diff --git a/include/DummyReader.h b/include/DummyReader.h index 3ddf7bff..ab606696 100644 --- a/include/DummyReader.h +++ b/include/DummyReader.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "CacheMemory.h" #include "Exceptions.h" #include "Fraction.h" @@ -53,7 +53,7 @@ namespace openshot class DummyReader : public ReaderBase { private: - tr1::shared_ptr image_frame; + std::shared_ptr image_frame; bool is_open; public: @@ -75,7 +75,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/EffectBase.h b/include/EffectBase.h index eef29287..e28d2ee8 100644 --- a/include/EffectBase.h +++ b/include/EffectBase.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include "ClipBase.h" #include "Frame.h" #include "Json.h" @@ -84,7 +84,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 tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number) = 0; + virtual std::shared_ptr GetFrame(std::shared_ptr frame, long int 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 1250a459..ed65ea20 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include "CacheMemory.h" #include "Exceptions.h" #include "OpenMPUtilities.h" @@ -78,7 +78,7 @@ namespace openshot * r.Open(); // Open the reader * * // Get frame number 1 from the video - * tr1::shared_ptr f = r.GetFrame(1); + * std::shared_ptr f = r.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen @@ -108,7 +108,6 @@ namespace openshot CacheMemory working_cache; CacheMemory missing_frames; - map frames; map processing_video_frames; multimap processing_audio_frames; map processed_video_frames; @@ -117,7 +116,6 @@ namespace openshot multimap missing_video_frames_source; multimap missing_audio_frames; multimap missing_audio_frames_source; - multimap duplicate_video_frames; map checked_frames; AudioLocation previous_packet_location; @@ -128,7 +126,7 @@ namespace openshot long int pts_counter; long int num_packets_since_video_frame; long int num_checks_since_final; - tr1::shared_ptr last_video_frame; + std::shared_ptr last_video_frame; bool is_seeking; long int seeking_pts; @@ -169,7 +167,7 @@ namespace openshot long int ConvertVideoPTStoFrame(long int pts); /// Create a new Frame (or return an existing one) and add it to the working queue. - tr1::shared_ptr CreateFrame(long int requested_frame); + std::shared_ptr CreateFrame(long int requested_frame); /// Calculate Starting video frame and sample # for an audio PTS AudioLocation GetAudioPTSLocation(long int pts); @@ -199,7 +197,7 @@ namespace openshot void ProcessAudioPacket(long int requested_frame, long int target_frame, int starting_sample); /// Read the stream until we find the requested Frame - tr1::shared_ptr ReadStream(long int requested_frame); + std::shared_ptr ReadStream(long int requested_frame); /// Remove AVFrame from cache (and deallocate it's memory) void RemoveAVFrame(AVPicture*); @@ -249,7 +247,7 @@ namespace openshot /// /// @returns The requested frame of video /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(OutOfBoundsFrame, ReaderClosed, TooManySeeks); + std::shared_ptr GetFrame(long int requested_frame) throw(OutOfBoundsFrame, ReaderClosed, TooManySeeks); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/FFmpegUtilities.h b/include/FFmpegUtilities.h index 40000b78..103aceb9 100644 --- a/include/FFmpegUtilities.h +++ b/include/FFmpegUtilities.h @@ -102,11 +102,13 @@ #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame) #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) + #define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet) #else #define AV_ALLOCATE_FRAME() avcodec_alloc_frame() #define AV_RESET_FRAME(av_frame) avcodec_get_frame_defaults(av_frame) #define AV_FREE_FRAME(av_frame) avcodec_free_frame(av_frame) - #endif + #define AV_FREE_PACKET(av_packet) av_free_packet(av_packet) + #endif #endif diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index ca5c8dda..2fbb8479 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -181,20 +181,20 @@ namespace openshot int original_sample_rate; int original_channels; - tr1::shared_ptr last_frame; - deque > spooled_audio_frames; - deque > spooled_video_frames; + std::shared_ptr last_frame; + deque > spooled_audio_frames; + deque > spooled_video_frames; - deque > queued_audio_frames; - deque > queued_video_frames; + deque > queued_audio_frames; + deque > queued_video_frames; - deque > processed_frames; - deque > deallocate_frames; + deque > processed_frames; + deque > deallocate_frames; - map, AVFrame*> av_frames; + map, AVFrame*> av_frames; /// Add an AVFrame to the cache - void add_avframe(tr1::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(); @@ -232,13 +232,13 @@ namespace openshot void open_video(AVFormatContext *oc, AVStream *st); /// process video frame - void process_video_packet(tr1::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 final); /// write video frame - bool write_video_packet(tr1::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() throw (ErrorEncodingVideo); @@ -316,7 +316,7 @@ 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(tr1::shared_ptr frame) throw(ErrorEncodingVideo, WriterClosed); + void WriteFrame(std::shared_ptr frame) throw(ErrorEncodingVideo, WriterClosed); /// @brief Write a block of frames from a reader /// @param reader A openshot::ReaderBase object which will provide frames to be written diff --git a/include/Frame.h b/include/Frame.h index cc68492d..844280e0 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include "ZmqLogger.h" #ifdef USE_IMAGEMAGICK @@ -108,17 +108,17 @@ namespace openshot * ); * * // Some methods require a shared pointer to an openshot::Frame object. - * tr1::shared_ptr f(new Frame(1, 720, 480, "#000000", 44100, 2)); + * std::shared_ptr f(new Frame(1, 720, 480, "#000000", 44100, 2)); * * @endcode */ class Frame { private: - tr1::shared_ptr image; - tr1::shared_ptr wave_image; - tr1::shared_ptr audio; - tr1::shared_ptr previewApp; + std::shared_ptr image; + std::shared_ptr wave_image; + std::shared_ptr audio; + std::shared_ptr previewApp; CriticalSection addingImageSection; CriticalSection addingAudioSection; const unsigned char *qbuffer; @@ -165,14 +165,14 @@ namespace openshot void AddImage(int new_width, int new_height, int bytes_per_pixel, QImage::Format type, const unsigned char *pixels_); /// Add (or replace) pixel data to the frame - void AddImage(tr1::shared_ptr new_image); + void AddImage(std::shared_ptr new_image); /// Add (or replace) pixel data to the frame (for only the odd or even lines) - void AddImage(tr1::shared_ptr new_image, bool only_odd_lines); + void AddImage(std::shared_ptr new_image, bool only_odd_lines); #ifdef USE_IMAGEMAGICK /// Add (or replace) pixel data to the frame from an ImageMagick Image - void AddMagickImage(tr1::shared_ptr new_image); + void AddMagickImage(std::shared_ptr new_image); #endif /// Add audio samples to a specific channel @@ -230,11 +230,11 @@ namespace openshot int64 GetBytes(); /// Get pointer to Qt QImage image object - tr1::shared_ptr GetImage(); + std::shared_ptr GetImage(); #ifdef USE_IMAGEMAGICK /// Get pointer to ImageMagick image object - tr1::shared_ptr GetMagickImage(); + std::shared_ptr GetMagickImage(); #endif /// Set Pixel Aspect Ratio @@ -256,7 +256,7 @@ namespace openshot static int GetSamplesPerFrame(long int frame_number, Fraction fps, int sample_rate, int channels); /// Get an audio waveform image - tr1::shared_ptr GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha); + std::shared_ptr GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha); /// Get an audio waveform image pixels const unsigned char* GetWaveformPixels(int width, int height, int Red, int Green, int Blue, int Alpha); diff --git a/include/FrameMapper.h b/include/FrameMapper.h index 58ed4dc7..69451f4f 100644 --- a/include/FrameMapper.h +++ b/include/FrameMapper.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include "CacheMemory.h" #include "../include/ReaderBase.h" #include "../include/Frame.h" @@ -130,7 +130,7 @@ namespace openshot * \code * // Create a frame mapper for a reader, and convert the frame rate (from 24 fps to 29.97 fps) * FrameMapper mapping(reader, Fraction(30000, 1001), PULLDOWN_CLASSIC, 44100, 2, LAYOUT_STEREO); - * tr1::shared_ptr frame2 = mapping.GetFrame(2); + * std::shared_ptr frame2 = mapping.GetFrame(2); * // If you need to change the mapping... * mapping.ChangeMapping(Fraction(24, 1), PULLDOWN_CLASSIC, 48000, 2, LAYOUT_MONO) @@ -154,7 +154,7 @@ namespace openshot void AddField(Field field); // Get Frame or Generate Blank Frame - tr1::shared_ptr GetOrCreateFrame(long int number); + std::shared_ptr GetOrCreateFrame(long int number); // Use the original and target frame rates and a pull-down technique to create // a mapping between the original fields and frames or a video to a new frame rate. @@ -194,7 +194,7 @@ namespace openshot /// /// @returns The requested frame of video /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Determine if reader is open or closed bool IsOpen(); @@ -218,7 +218,7 @@ namespace openshot ReaderBase* Reader() throw(ReaderClosed); /// Resample audio and map channels (if needed) - void ResampleMappedAudio(tr1::shared_ptr frame, long int original_frame_number); + void ResampleMappedAudio(std::shared_ptr frame, long int original_frame_number); }; } diff --git a/include/ImageReader.h b/include/ImageReader.h index 2ee98e15..ca747d97 100644 --- a/include/ImageReader.h +++ b/include/ImageReader.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "Magick++.h" #include "CacheMemory.h" #include "Exceptions.h" @@ -55,7 +55,7 @@ namespace openshot * r.Open(); // Open the reader * * // Get frame number 1 from the video - * tr1::shared_ptr f = r.GetFrame(1); + * std::shared_ptr f = r.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen @@ -68,7 +68,7 @@ namespace openshot { private: string path; - tr1::shared_ptr image; + std::shared_ptr image; bool is_open; public: @@ -93,7 +93,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/ImageWriter.h b/include/ImageWriter.h index c1884712..003aad3e 100644 --- a/include/ImageWriter.h +++ b/include/ImageWriter.h @@ -95,7 +95,7 @@ namespace openshot int number_of_loops; bool combine_frames; - tr1::shared_ptr last_frame; + std::shared_ptr last_frame; public: @@ -133,7 +133,7 @@ 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(tr1::shared_ptr frame) throw(WriterClosed); + void WriteFrame(std::shared_ptr frame) throw(WriterClosed); /// @brief Write a block of frames from a reader /// @param reader A openshot::ReaderBase object which will provide frames to be written diff --git a/include/OpenShot.h b/include/OpenShot.h index b57d191e..e4b60f3e 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.h @@ -47,7 +47,7 @@ * r.Open(); // Open the reader * * // Get frame number 1 from the video - * tr1::shared_ptr f = r.GetFrame(1); + * std::shared_ptr f = r.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen diff --git a/include/Qt/AudioPlaybackThread.h b/include/Qt/AudioPlaybackThread.h index 862d6173..fce7b045 100644 --- a/include/Qt/AudioPlaybackThread.h +++ b/include/Qt/AudioPlaybackThread.h @@ -99,7 +99,7 @@ namespace openshot void Reader(ReaderBase *reader); /// Get the current frame object (which is filling the buffer) - tr1::shared_ptr getFrame(); + std::shared_ptr getFrame(); /// Get the current frame number being played long int getCurrentFramePosition(); diff --git a/include/Qt/PlayerPrivate.h b/include/Qt/PlayerPrivate.h index 6a326849..83f5ec48 100644 --- a/include/Qt/PlayerPrivate.h +++ b/include/Qt/PlayerPrivate.h @@ -46,7 +46,7 @@ namespace openshot */ class PlayerPrivate : Thread { - tr1::shared_ptr frame; /// The current frame + std::shared_ptr frame; /// The current frame long int video_position; /// The current frame position. long int audio_position; /// The current frame position. ReaderBase *reader; /// The reader which powers this player @@ -72,7 +72,7 @@ namespace openshot void stopPlayback(int timeOutMilliseconds = -1); /// Get the next frame (based on speed and direction) - tr1::shared_ptr getFrame(); + std::shared_ptr getFrame(); /// The parent class of PlayerPrivate friend class QtPlayer; diff --git a/include/Qt/VideoCacheThread.h b/include/Qt/VideoCacheThread.h index e90d0fa7..db48caa4 100644 --- a/include/Qt/VideoCacheThread.h +++ b/include/Qt/VideoCacheThread.h @@ -42,7 +42,7 @@ namespace openshot */ class VideoCacheThread : Thread { - std::tr1::shared_ptr frame; + std::shared_ptr frame; int speed; bool is_playing; long int position; diff --git a/include/Qt/VideoPlaybackThread.h b/include/Qt/VideoPlaybackThread.h index 86f6a598..44d2af78 100644 --- a/include/Qt/VideoPlaybackThread.h +++ b/include/Qt/VideoPlaybackThread.h @@ -43,7 +43,7 @@ namespace openshot class VideoPlaybackThread : Thread { RendererBase *renderer; - std::tr1::shared_ptr frame; + std::shared_ptr frame; WaitableEvent render; WaitableEvent rendered; bool reset; diff --git a/include/Qt/VideoRenderer.h b/include/Qt/VideoRenderer.h index 8158c947..18da9ae7 100644 --- a/include/Qt/VideoRenderer.h +++ b/include/Qt/VideoRenderer.h @@ -31,7 +31,7 @@ #include "../RendererBase.h" #include #include -#include +#include class QPainter; @@ -52,7 +52,7 @@ signals: protected: //void render(openshot::OSPixelFormat format, int width, int height, int bytesPerLine, unsigned char *data); - void render(tr1::shared_ptr image); + void render(std::shared_ptr image); private slots: diff --git a/include/QtImageReader.h b/include/QtImageReader.h index e022a52f..c45de4dc 100644 --- a/include/QtImageReader.h +++ b/include/QtImageReader.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,7 +57,7 @@ namespace openshot * r.Open(); // Open the reader * * // Get frame number 1 from the video - * tr1::shared_ptr f = r.GetFrame(1); + * std::shared_ptr f = r.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen @@ -70,8 +70,8 @@ namespace openshot { private: string path; - tr1::shared_ptr image; ///> Original image (full quality) - tr1::shared_ptr cached_image; ///> Scaled for performance + std::shared_ptr image; ///> Original image (full quality) + std::shared_ptr cached_image; ///> Scaled for performance bool is_open; public: @@ -96,7 +96,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/ReaderBase.h b/include/ReaderBase.h index 1163839e..27de85cd 100644 --- a/include/ReaderBase.h +++ b/include/ReaderBase.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include "CacheMemory.h" @@ -125,7 +125,7 @@ namespace openshot /// /// @returns The requested frame of video /// @param[in] number The frame number that is requested. - virtual tr1::shared_ptr GetFrame(long int number) = 0; + virtual std::shared_ptr GetFrame(long int number) = 0; /// Determine if reader is open or closed virtual bool IsOpen() = 0; diff --git a/include/RendererBase.h b/include/RendererBase.h index b346436b..2bd2d1a9 100644 --- a/include/RendererBase.h +++ b/include/RendererBase.h @@ -30,7 +30,7 @@ #include "../include/Frame.h" #include // for realloc -#include +#include namespace openshot { @@ -47,7 +47,7 @@ namespace openshot public: /// Paint(render) a video Frame. - void paint(const std::tr1::shared_ptr & frame); + void paint(const std::shared_ptr & frame); /// Allow manual override of the QWidget that is used to display virtual void OverrideWidget(long long qwidget_address) = 0; @@ -56,7 +56,7 @@ namespace openshot RendererBase(); virtual ~RendererBase(); - virtual void render(tr1::shared_ptr image) = 0; + virtual void render(std::shared_ptr image) = 0; }; } diff --git a/include/TextReader.h b/include/TextReader.h index edee2be3..8d6c1200 100644 --- a/include/TextReader.h +++ b/include/TextReader.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "Magick++.h" #include "CacheMemory.h" #include "Enums.h" @@ -69,7 +69,7 @@ namespace openshot * r.Open(); // Open the reader * * // Get frame number 1 from the video (in fact, any frame # you request will return the same frame) - * tr1::shared_ptr f = r.GetFrame(1); + * std::shared_ptr f = r.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen @@ -90,7 +90,7 @@ namespace openshot double size; string text_color; string background_color; - tr1::shared_ptr image; + std::shared_ptr image; list lines; bool is_open; GravityType gravity; @@ -124,7 +124,7 @@ namespace openshot /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed); /// Determine if reader is open or closed bool IsOpen() { return is_open; }; diff --git a/include/Timeline.h b/include/Timeline.h index f6bf6a1f..88a89832 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -29,7 +29,7 @@ #define OPENSHOT_TIMELINE_H #include -#include +#include #include #include #include "CacheBase.h" @@ -133,7 +133,7 @@ namespace openshot { * t.Open(); * * // Get frame number 1 from the timeline (This will generate a new frame, made up from the previous clips and settings) - * tr1::shared_ptr f = t.GetFrame(1); + * std::shared_ptr f = t.GetFrame(1); * * // Now that we have an openshot::Frame object, lets have some fun! * f->Display(); // Display the frame on the screen @@ -153,7 +153,7 @@ namespace openshot { CacheBase *final_cache; /// new_frame, Clip* source_clip, long int clip_frame_number, long int timeline_frame_number, bool is_top_clip); + void add_layer(std::shared_ptr new_frame, Clip* source_clip, long int clip_frame_number, long int timeline_frame_number, bool is_top_clip); /// Apply a FrameMapper to a clip which matches the settings of this timeline void apply_mapper_to_clip(Clip* clip); @@ -176,10 +176,10 @@ namespace openshot { vector find_intersecting_clips(long int requested_frame, int number_of_frames, bool include); /// Get or generate a blank frame - tr1::shared_ptr GetOrCreateFrame(Clip* clip, long int number); + std::shared_ptr GetOrCreateFrame(Clip* clip, long int number); /// Apply effects to the source frame (if any) - tr1::shared_ptr apply_effects(tr1::shared_ptr frame, long int timeline_frame_number, int layer); + std::shared_ptr apply_effects(std::shared_ptr frame, long int timeline_frame_number, int layer); /// Compare 2 floating point numbers for equality bool isEqual(double a, double b); @@ -243,7 +243,7 @@ namespace openshot { /// /// @returns The requested frame (containing the image) /// @param requested_frame The frame number that is requested. - tr1::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed, OutOfBoundsFrame); + std::shared_ptr GetFrame(long int requested_frame) throw(ReaderClosed, OutOfBoundsFrame); // Curves for the viewport Keyframe viewport_scale; /// frame) throw(ErrorEncodingVideo, WriterClosed) = 0; + virtual void WriteFrame(std::shared_ptr frame) throw(ErrorEncodingVideo, WriterClosed) = 0; /// This method is required for all derived classes of WriterBase. Write a block of frames from a reader. virtual void WriteFrame(ReaderBase* reader, long int start, long int length) throw(ErrorEncodingVideo, WriterClosed) = 0; diff --git a/include/effects/Blur.h b/include/effects/Blur.h index 02799bde..3ce2ddfc 100644 --- a/include/effects/Blur.h +++ b/include/effects/Blur.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include "../Color.h" #include "../Exceptions.h" @@ -98,7 +98,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/Brightness.h b/include/effects/Brightness.h index 801cf405..e8307a32 100644 --- a/include/effects/Brightness.h +++ b/include/effects/Brightness.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../Json.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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/ChromaKey.h b/include/effects/ChromaKey.h index f2710ad4..bd4db01f 100644 --- a/include/effects/ChromaKey.h +++ b/include/effects/ChromaKey.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../KeyFrame.h" @@ -82,7 +82,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/Deinterlace.h b/include/effects/Deinterlace.h index 82103998..1bf53ef7 100644 --- a/include/effects/Deinterlace.h +++ b/include/effects/Deinterlace.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../Json.h" @@ -78,7 +78,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/Mask.h b/include/effects/Mask.h index 005ab19b..8b9ea3ff 100644 --- a/include/effects/Mask.h +++ b/include/effects/Mask.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../Json.h" @@ -64,13 +64,13 @@ namespace openshot { private: ReaderBase *reader; - tr1::shared_ptr original_mask; + std::shared_ptr original_mask; /// Constrain a color value from 0 to 255 int constrain(int color_value); /// Get grayscale mask image - void set_grayscale_mask(tr1::shared_ptr mask_frame_image, int width, int height, float brightness, float contrast); + void set_grayscale_mask(std::shared_ptr mask_frame_image, int width, int height, float brightness, float contrast); /// Init effect settings void init_effect_details(); @@ -101,7 +101,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/Negate.h b/include/effects/Negate.h index d8a85f27..4eca024f 100644 --- a/include/effects/Negate.h +++ b/include/effects/Negate.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../KeyFrame.h" @@ -66,7 +66,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/include/effects/Saturation.h b/include/effects/Saturation.h index 35bff035..8d115bf3 100644 --- a/include/effects/Saturation.h +++ b/include/effects/Saturation.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "../Color.h" #include "../Exceptions.h" #include "../Json.h" @@ -85,7 +85,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. - tr1::shared_ptr GetFrame(tr1::shared_ptr frame, long int frame_number); + std::shared_ptr GetFrame(std::shared_ptr frame, long int frame_number); /// Get and Set JSON methods string Json(); ///< Generate JSON string of this object diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b377fa4f..41d74914 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,7 @@ OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF) # required for libopenshot-audio headers IF (WIN32) add_definitions( -DIGNORE_JUCE_HYPOT=1 ) - SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath -std=c++0x") + SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath") ENDIF(WIN32) IF (APPLE) # If you still get errors compiling with GCC 4.8, mac headers need to be patched: http://hamelot.co.uk/programming/osx-gcc-dispatch_block_t-has-not-been-declared-invalid-typedef/ @@ -43,8 +43,6 @@ IF (APPLE) SET(JUCE_PLATFORM_SPECIFIC_DIR build/macosx/platform_specific_code) SET(JUCE_PLATFORM_SPECIFIC_LIBRARIES "-framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreAudio -framework CoreMidi -framework IOKit -framework AGL -framework AudioToolbox -framework QuartzCore -lobjc -framework Accelerate") - - SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -std=c++0x") ENDIF(APPLE) ################ IMAGE MAGICK ################## diff --git a/src/CacheDisk.cpp b/src/CacheDisk.cpp index 5e0c76df..23b82a6e 100644 --- a/src/CacheDisk.cpp +++ b/src/CacheDisk.cpp @@ -163,7 +163,7 @@ CacheDisk::~CacheDisk() } // Add a Frame to the cache -void CacheDisk::Add(tr1::shared_ptr frame) +void CacheDisk::Add(std::shared_ptr frame) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -222,7 +222,7 @@ void CacheDisk::Add(tr1::shared_ptr frame) } // Get a frame from the cache (or NULL shared_ptr if no frame is found) -tr1::shared_ptr CacheDisk::GetFrame(long int frame_number) +std::shared_ptr CacheDisk::GetFrame(long int frame_number) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -234,14 +234,14 @@ tr1::shared_ptr CacheDisk::GetFrame(long int frame_number) if (path.exists(frame_path)) { // Load image file - tr1::shared_ptr image = tr1::shared_ptr(new QImage()); + std::shared_ptr image = std::shared_ptr(new QImage()); bool success = image->load(QString::fromStdString(frame_path.toStdString())); // Set pixel formatimage-> - image = tr1::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); + image = std::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); // Create frame object - tr1::shared_ptr frame(new Frame()); + std::shared_ptr frame(new Frame()); frame->number = frame_number; frame->AddImage(image); @@ -288,15 +288,15 @@ tr1::shared_ptr CacheDisk::GetFrame(long int frame_number) } // no Frame found - return tr1::shared_ptr(); + return std::shared_ptr(); } // Get the smallest frame number (or NULL shared_ptr if no frame is found) -tr1::shared_ptr CacheDisk::GetSmallestFrame() +std::shared_ptr CacheDisk::GetSmallestFrame() { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); - tr1::shared_ptr f; + std::shared_ptr f; // Loop through frame numbers deque::iterator itr; diff --git a/src/CacheMemory.cpp b/src/CacheMemory.cpp index f41948d5..61cf54e8 100644 --- a/src/CacheMemory.cpp +++ b/src/CacheMemory.cpp @@ -127,7 +127,7 @@ void CacheMemory::CalculateRanges() { } // Add a Frame to the cache -void CacheMemory::Add(tr1::shared_ptr frame) +void CacheMemory::Add(std::shared_ptr frame) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -152,7 +152,7 @@ void CacheMemory::Add(tr1::shared_ptr frame) } // Get a frame from the cache (or NULL shared_ptr if no frame is found) -tr1::shared_ptr CacheMemory::GetFrame(long int frame_number) +std::shared_ptr CacheMemory::GetFrame(long int frame_number) { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); @@ -164,15 +164,15 @@ tr1::shared_ptr CacheMemory::GetFrame(long int frame_number) else // no Frame found - return tr1::shared_ptr(); + return std::shared_ptr(); } // Get the smallest frame number (or NULL shared_ptr if no frame is found) -tr1::shared_ptr CacheMemory::GetSmallestFrame() +std::shared_ptr CacheMemory::GetSmallestFrame() { // Create a scoped lock, to protect the cache from multiple threads const GenericScopedLock lock(*cacheCriticalSection); - tr1::shared_ptr f; + std::shared_ptr f; // Loop through frame numbers deque::iterator itr; @@ -251,12 +251,12 @@ void CacheMemory::Remove(long int start_frame_number, long int end_frame_number) // Move frame to front of queue (so it lasts longer) void CacheMemory::MoveToFront(long int frame_number) { + // Create a scoped lock, to protect the cache from multiple threads + const GenericScopedLock lock(*cacheCriticalSection); + // Does frame exists in cache? if (frames.count(frame_number)) { - // Create a scoped lock, to protect the cache from multiple threads - const GenericScopedLock lock(*cacheCriticalSection); - // Loop through frame numbers deque::iterator itr; for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) diff --git a/src/ChunkReader.cpp b/src/ChunkReader.cpp index 6c241add..3e13d05b 100644 --- a/src/ChunkReader.cpp +++ b/src/ChunkReader.cpp @@ -187,7 +187,7 @@ string ChunkReader::get_chunk_path(int chunk_number, string folder, string exten } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr ChunkReader::GetFrame(long int requested_frame) throw(ReaderClosed, ChunkNotFound) +std::shared_ptr ChunkReader::GetFrame(long int requested_frame) throw(ReaderClosed, ChunkNotFound) { // Determine what chunk contains this frame ChunkLocation location = find_chunk_frame(requested_frame); diff --git a/src/ChunkWriter.cpp b/src/ChunkWriter.cpp index 50325726..aad8d2b1 100644 --- a/src/ChunkWriter.cpp +++ b/src/ChunkWriter.cpp @@ -74,7 +74,7 @@ string ChunkWriter::get_chunk_path(int chunk_number, string folder, string exten } // Add a frame to the queue waiting to be encoded. -void ChunkWriter::WriteFrame(tr1::shared_ptr frame) throw(WriterClosed) +void ChunkWriter::WriteFrame(std::shared_ptr frame) throw(WriterClosed) { // Check for open reader (or throw exception) if (!is_open) @@ -131,7 +131,7 @@ void ChunkWriter::WriteFrame(tr1::shared_ptr frame) throw(WriterClosed) writer_thumb->WriteFrame(last_frame); } else { // Write the 1st frame (of the 1st chunk)... since no previous chunk is available - tr1::shared_ptr blank_frame(new Frame(1, info.width, info.height, "#000000", info.sample_rate, info.channels)); + std::shared_ptr blank_frame(new Frame(1, info.width, info.height, "#000000", info.sample_rate, info.channels)); blank_frame->AddColor(info.width, info.height, "#000000"); writer_final->WriteFrame(blank_frame); writer_preview->WriteFrame(blank_frame); @@ -199,7 +199,7 @@ void ChunkWriter::WriteFrame(ReaderBase* reader, int start, int length) throw(Wr for (int number = start; number <= length; number++) { // Get the frame - tr1::shared_ptr f = reader->GetFrame(number); + std::shared_ptr f = reader->GetFrame(number); // Encode frame WriteFrame(f); @@ -213,7 +213,7 @@ void ChunkWriter::WriteFrame(int start, int length) throw(WriterClosed) for (int number = start; number <= length; number++) { // Get the frame - tr1::shared_ptr f = local_reader->GetFrame(number); + std::shared_ptr f = local_reader->GetFrame(number); // Encode frame WriteFrame(f); diff --git a/src/Clip.cpp b/src/Clip.cpp index 5c5bfe8b..27106bc0 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -255,7 +255,7 @@ float Clip::End() throw(ReaderClosed) } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr Clip::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr Clip::GetFrame(long int requested_frame) throw(ReaderClosed) { if (reader) { @@ -281,16 +281,16 @@ tr1::shared_ptr Clip::GetFrame(long int requested_frame) throw(ReaderClos new_frame_number = time_mapped_number; // Now that we have re-mapped what frame number is needed, go and get the frame pointer - tr1::shared_ptr original_frame = GetOrCreateFrame(new_frame_number); + std::shared_ptr original_frame = GetOrCreateFrame(new_frame_number); // Create a new frame - tr1::shared_ptr frame(new Frame(new_frame_number, 1, 1, "#000000", original_frame->GetAudioSamplesCount(), original_frame->GetAudioChannelsCount())); + std::shared_ptr frame(new Frame(new_frame_number, 1, 1, "#000000", original_frame->GetAudioSamplesCount(), original_frame->GetAudioChannelsCount())); frame->SampleRate(original_frame->SampleRate()); frame->ChannelsLayout(original_frame->ChannelsLayout()); // Copy the image from the odd field if (enabled_video) - frame->AddImage(tr1::shared_ptr(new QImage(*original_frame->GetImage()))); + frame->AddImage(std::shared_ptr(new QImage(*original_frame->GetImage()))); // Loop through each channel, add audio if (enabled_audio && reader->info.has_audio) @@ -298,7 +298,7 @@ tr1::shared_ptr Clip::GetFrame(long int requested_frame) throw(ReaderClos frame->AddAudio(true, channel, 0, original_frame->GetAudioSamples(channel), original_frame->GetAudioSamplesCount(), 1.0); // Get time mapped frame number (used to increase speed, change direction, etc...) - tr1::shared_ptr new_frame = get_time_mapped_frame(frame, requested_frame); + std::shared_ptr new_frame = get_time_mapped_frame(frame, requested_frame); // Apply effects to the frame (if any) apply_effects(new_frame); @@ -347,7 +347,7 @@ void Clip::reverse_buffer(juce::AudioSampleBuffer* buffer) } // Adjust the audio and image of a time mapped frame -tr1::shared_ptr Clip::get_time_mapped_frame(tr1::shared_ptr frame, long int frame_number) throw(ReaderClosed) +std::shared_ptr Clip::get_time_mapped_frame(std::shared_ptr frame, long int frame_number) throw(ReaderClosed) { // Check for valid reader if (!reader) @@ -358,7 +358,7 @@ tr1::shared_ptr Clip::get_time_mapped_frame(tr1::shared_ptr frame, if (time.Values.size() > 1) { const GenericScopedLock lock(getFrameCriticalSection); - tr1::shared_ptr new_frame; + std::shared_ptr new_frame; // create buffer and resampler juce::AudioSampleBuffer *samples = NULL; @@ -370,7 +370,7 @@ tr1::shared_ptr Clip::get_time_mapped_frame(tr1::shared_ptr frame, // Create a new frame int samples_in_frame = Frame::GetSamplesPerFrame(new_frame_number, reader->info.fps, reader->info.sample_rate, frame->GetAudioChannelsCount()); - new_frame = tr1::shared_ptr(new Frame(new_frame_number, 1, 1, "#000000", samples_in_frame, frame->GetAudioChannelsCount())); + new_frame = std::make_shared(new_frame_number, 1, 1, "#000000", samples_in_frame, frame->GetAudioChannelsCount()); // Copy the image from the new frame new_frame->AddImage(GetOrCreateFrame(new_frame_number)->GetImage()); @@ -580,9 +580,9 @@ long int Clip::adjust_frame_number_minimum(long int frame_number) } // Get or generate a blank frame -tr1::shared_ptr Clip::GetOrCreateFrame(long int number) +std::shared_ptr Clip::GetOrCreateFrame(long int number) { - tr1::shared_ptr new_frame; + std::shared_ptr new_frame; // Init some basic properties about this frame int samples_in_frame = Frame::GetSamplesPerFrame(number, reader->info.fps, reader->info.sample_rate, reader->info.channels); @@ -639,7 +639,7 @@ tr1::shared_ptr Clip::GetOrCreateFrame(long int number) ZmqLogger::Instance()->AppendDebugMethod("Clip::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); // Create blank frame - new_frame = tr1::shared_ptr(new Frame(number, reader->info.width, reader->info.height, "#000000", samples_in_frame, reader->info.channels)); + new_frame = std::make_shared(number, reader->info.width, reader->info.height, "#000000", samples_in_frame, reader->info.channels); new_frame->SampleRate(reader->info.sample_rate); new_frame->ChannelsLayout(reader->info.channel_layout); return new_frame; @@ -997,7 +997,7 @@ void Clip::RemoveEffect(EffectBase* effect) } // Apply effects to the source frame (if any) -tr1::shared_ptr Clip::apply_effects(tr1::shared_ptr frame) +std::shared_ptr Clip::apply_effects(std::shared_ptr frame) { // Find Effects at this position and layer list::iterator effect_itr; diff --git a/src/DecklinkInput.cpp b/src/DecklinkInput.cpp index 7d692300..b447f7e9 100644 --- a/src/DecklinkInput.cpp +++ b/src/DecklinkInput.cpp @@ -104,9 +104,9 @@ unsigned long DeckLinkInputDelegate::GetCurrentFrameNumber() return 0; } -tr1::shared_ptr DeckLinkInputDelegate::GetFrame(long int requested_frame) +std::shared_ptr DeckLinkInputDelegate::GetFrame(long int requested_frame) { - tr1::shared_ptr f; + std::shared_ptr f; // Is this frame for the future? while (requested_frame > GetCurrentFrameNumber()) @@ -242,7 +242,7 @@ omp_set_nested(true); m_rgbFrame->GetBytes(&frameBytes); // *********** CREATE OPENSHOT FRAME ********** - tr1::shared_ptr f(new openshot::Frame(copy_frameCount, width, height, "#000000", 2048, 2)); + std::shared_ptr f(new openshot::Frame(copy_frameCount, width, height, "#000000", 2048, 2)); // Add Image data to openshot frame // TODO: Fix Decklink support with QImage Upgrade diff --git a/src/DecklinkOutput.cpp b/src/DecklinkOutput.cpp index dfd99c04..8606420a 100644 --- a/src/DecklinkOutput.cpp +++ b/src/DecklinkOutput.cpp @@ -195,7 +195,7 @@ void DeckLinkOutputDelegate::ScheduleNextFrame(bool prerolling) } -void DeckLinkOutputDelegate::WriteFrame(tr1::shared_ptr frame) +void DeckLinkOutputDelegate::WriteFrame(std::shared_ptr frame) { #pragma omp critical (blackmagic_output_queue) @@ -220,7 +220,7 @@ void DeckLinkOutputDelegate::WriteFrame(tr1::shared_ptr frame) while (!raw_video_frames.empty()) { // Get front frame (from the queue) - tr1::shared_ptr frame = raw_video_frames.front(); + std::shared_ptr frame = raw_video_frames.front(); raw_video_frames.pop_front(); // copy of frame count diff --git a/src/DecklinkReader.cpp b/src/DecklinkReader.cpp index 76a846d3..b7754255 100644 --- a/src/DecklinkReader.cpp +++ b/src/DecklinkReader.cpp @@ -231,10 +231,10 @@ unsigned long DecklinkReader::GetCurrentFrameNumber() } // Get an openshot::Frame object for the next available LIVE frame -tr1::shared_ptr DecklinkReader::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr DecklinkReader::GetFrame(long int requested_frame) throw(ReaderClosed) { // Get a frame from the delegate decklink class (which is collecting them on another thread) - tr1::shared_ptr f = delegate->GetFrame(requested_frame); + std::shared_ptr f = delegate->GetFrame(requested_frame); // cout << "Change the frame number to " << requested_frame << endl; // f->SetFrameNumber(requested_frame); diff --git a/src/DecklinkWriter.cpp b/src/DecklinkWriter.cpp index 14db96ed..ae684565 100644 --- a/src/DecklinkWriter.cpp +++ b/src/DecklinkWriter.cpp @@ -139,7 +139,7 @@ void DecklinkWriter::Open() throw(DecklinkError) // throw DecklinkError("Failed to enable audio output. Is another application using the card?"); // Begin video preroll by scheduling a second of frames in hardware - //tr1::shared_ptr f(new Frame(1, displayMode->GetWidth(), displayMode->GetHeight(), "Blue")); + //std::shared_ptr f(new Frame(1, displayMode->GetWidth(), displayMode->GetHeight(), "Blue")); //f->AddColor(displayMode->GetWidth(), displayMode->GetHeight(), "Blue"); // Preroll 1 second of video @@ -227,7 +227,7 @@ void DecklinkWriter::Close() } // This method is required for all derived classes of WriterBase. Write a Frame to the video file. -void DecklinkWriter::WriteFrame(tr1::shared_ptr frame) throw(WriterClosed) +void DecklinkWriter::WriteFrame(std::shared_ptr frame) throw(WriterClosed) { // Check for open reader (or throw exception) if (!is_open) @@ -243,7 +243,7 @@ void DecklinkWriter::WriteFrame(ReaderBase* reader, int start, int length) throw for (int number = start; number <= length; number++) { // Get the frame - tr1::shared_ptr f = reader->GetFrame(number); + std::shared_ptr f = reader->GetFrame(number); // Encode frame WriteFrame(f); diff --git a/src/DummyReader.cpp b/src/DummyReader.cpp index cfdb12b3..9237e6a0 100644 --- a/src/DummyReader.cpp +++ b/src/DummyReader.cpp @@ -78,7 +78,7 @@ void DummyReader::Open() throw(InvalidFile) if (!is_open) { // Create or get frame object - image_frame = tr1::shared_ptr(new Frame(1, info.width, info.height, "#000000", info.sample_rate, info.channels)); + image_frame = std::make_shared(1, info.width, info.height, "#000000", info.sample_rate, info.channels); // Mark as "open" is_open = true; @@ -97,7 +97,7 @@ void DummyReader::Close() } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr DummyReader::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr DummyReader::GetFrame(long int requested_frame) throw(ReaderClosed) { // Check for open reader (or throw exception) if (!is_open) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index b5af90fa..5fd1bcf0 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -37,7 +37,7 @@ FFmpegReader::FFmpegReader(string path) throw(InvalidFile, NoStreamsFound, Inval 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), prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0), - current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0) { + current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0), packet(NULL) { // Initialize FFMpeg, and register all formats and codecs av_register_all(); @@ -58,7 +58,7 @@ FFmpegReader::FFmpegReader(string path, bool inspect_reader) throw(InvalidFile, 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), prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0), - current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0) { + current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0), packet(NULL) { // Initialize FFMpeg, and register all formats and codecs av_register_all(); @@ -393,7 +393,7 @@ void FFmpegReader::UpdateVideoInfo() } -tr1::shared_ptr FFmpegReader::GetFrame(long int requested_frame) throw(OutOfBoundsFrame, ReaderClosed, TooManySeeks) +std::shared_ptr FFmpegReader::GetFrame(long int requested_frame) throw(OutOfBoundsFrame, ReaderClosed, TooManySeeks) { // Check for open reader (or throw exception) if (!is_open) @@ -412,7 +412,7 @@ tr1::shared_ptr FFmpegReader::GetFrame(long int requested_frame) throw(Ou ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "requested_frame", requested_frame, "last_frame", last_frame, "", -1, "", -1, "", -1, "", -1); // Check the cache for this frame - tr1::shared_ptr frame = final_cache.GetFrame(requested_frame); + std::shared_ptr frame = final_cache.GetFrame(requested_frame); if (frame) { // Debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "returned cached frame", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); @@ -475,7 +475,7 @@ tr1::shared_ptr FFmpegReader::GetFrame(long int requested_frame) throw(Ou } // Read the stream until we find the requested Frame -tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) +std::shared_ptr FFmpegReader::ReadStream(long int requested_frame) { // Allocate video frame bool end_of_stream = false; @@ -506,9 +506,21 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) // Get the next packet into a local variable called packet packet_error = GetNextPacket(); + int processing_video_frames_size = 0; + int processing_audio_frames_size = 0; + { + const GenericScopedLock lock(processingCriticalSection); + processing_video_frames_size = processing_video_frames.size(); + processing_audio_frames_size = processing_audio_frames.size(); + } + // Wait if too many frames are being processed - while (processing_video_frames.size() + processing_audio_frames.size() >= minimum_packets) + while (processing_video_frames_size + processing_audio_frames_size >= minimum_packets) { usleep(2500); + const GenericScopedLock lock(processingCriticalSection); + processing_video_frames_size = processing_video_frames.size(); + processing_audio_frames_size = processing_audio_frames.size(); + } // Get the next packet (if any) if (packet_error < 0) @@ -519,7 +531,7 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (GetNextPacket)", "requested_frame", requested_frame, "processing_video_frames.size()", processing_video_frames.size(), "processing_audio_frames.size()", processing_audio_frames.size(), "minimum_packets", minimum_packets, "packets_processed", packets_processed, "is_seeking", is_seeking); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (GetNextPacket)", "requested_frame", requested_frame, "processing_video_frames_size", processing_video_frames_size, "processing_audio_frames_size", processing_audio_frames_size, "minimum_packets", minimum_packets, "packets_processed", packets_processed, "is_seeking", is_seeking); // Video packet if (info.has_video && packet->stream_index == videoStream) @@ -535,9 +547,6 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) check_seek = false; if (check_seek) { - // Remove packet (since this packet is pointless) - RemoveAVPacket(packet); - // Jump to the next iteration of this loop continue; } @@ -570,9 +579,6 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) check_seek = false; if (check_seek) { - // Remove packet (since this packet is pointless) - RemoveAVPacket(packet); - // Jump to the next iteration of this loop continue; } @@ -621,7 +627,7 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) CheckWorkingFrames(end_of_stream, requested_frame); // Return requested frame (if found) - tr1::shared_ptr frame = final_cache.GetFrame(requested_frame); + std::shared_ptr frame = final_cache.GetFrame(requested_frame); if (frame) // Return prepared frame return frame; @@ -635,7 +641,7 @@ tr1::shared_ptr FFmpegReader::ReadStream(long int requested_frame) } else { // The largest processed frame is no longer in cache, return a blank frame - tr1::shared_ptr f = CreateFrame(largest_frame_processed); + std::shared_ptr f = CreateFrame(largest_frame_processed); f->AddColor(info.width, info.height, "#000"); return f; } @@ -650,17 +656,17 @@ int FFmpegReader::GetNextPacket() AVPacket *next_packet = new AVPacket(); found_packet = av_read_frame(pFormatCtx, next_packet); + if (packet) { + // Remove previous packet before getting next one + RemoveAVPacket(packet); + packet = NULL; + } + if (found_packet >= 0) { // Update current packet pointer packet = next_packet; } - else - { - // Free packet, since it's unused - av_free_packet(next_packet); - delete next_packet; - } // Return if packet was found (or error number) return found_packet; @@ -681,16 +687,9 @@ bool FFmpegReader::GetAVFrame() { // AVFrames are clobbered on the each call to avcodec_decode_video, so we // must make a copy of the image data before this method is called again. - AVPicture *copyFrame = new AVPicture(); - avpicture_alloc(copyFrame, pCodecCtx->pix_fmt, info.width, info.height); - av_picture_copy(copyFrame, (AVPicture *) next_frame, pCodecCtx->pix_fmt, info.width, info.height); - - #pragma omp critical (packet_cache) - { - // add to AVFrame cache (if frame finished) - frames[copyFrame] = copyFrame; - pFrame = frames[copyFrame]; - } + pFrame = new AVPicture(); + avpicture_alloc(pFrame, pCodecCtx->pix_fmt, info.width, info.height); + av_picture_copy(pFrame, (AVPicture *) next_frame, pCodecCtx->pix_fmt, info.width, info.height); // Detect interlaced frame (only once) if (!check_interlace) @@ -699,12 +698,6 @@ bool FFmpegReader::GetAVFrame() info.interlaced_frame = next_frame->interlaced_frame; info.top_field_first = next_frame->top_field_first; } - - } - else - { - // Remove packet (since this packet is pointless) - RemoveAVPacket(packet); } // deallocate the frame @@ -774,7 +767,6 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) { // Remove frame and packet RemoveAVFrame(pFrame); - RemoveAVPacket(packet); // Debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (Skipped)", "requested_frame", requested_frame, "current_frame", current_frame, "", -1, "", -1, "", -1, "", -1); @@ -791,14 +783,13 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) int height = info.height; int width = info.width; long int video_length = info.video_length; - AVPacket *my_packet = packet; - AVPicture *my_frame = frames[pFrame]; + AVPicture *my_frame = pFrame; // Add video frame to list of processing video frames const GenericScopedLock lock(processingCriticalSection); processing_video_frames[current_frame] = current_frame; - #pragma omp task firstprivate(current_frame, my_packet, my_frame, height, width, video_length, pix_fmt) + #pragma omp task firstprivate(current_frame, my_frame, height, width, video_length, pix_fmt) { // Create variables for a RGB Frame (since most videos are not in RGB, we must convert it) AVFrame *pFrameRGB = NULL; @@ -833,6 +824,7 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) // Determine required buffer size and allocate buffer numBytes = avpicture_get_size(PIX_FMT_RGBA, width, height); + #pragma omp critical (video_buffer) buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t)); // Assign appropriate parts of buffer to image planes in pFrameRGB @@ -848,7 +840,7 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) original_height, pFrameRGB->data, pFrameRGB->linesize); // Create or get the existing frame object - tr1::shared_ptr f = CreateFrame(current_frame); + std::shared_ptr f = CreateFrame(current_frame); // Add Image data to frame f->AddImage(width, height, 4, QImage::Format_RGBA8888, buffer); @@ -857,6 +849,7 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) working_cache.Add(f); // Keep track of last last_video_frame + #pragma omp critical (video_buffer) last_video_frame = f; // Free the RGB image @@ -865,7 +858,6 @@ void FFmpegReader::ProcessVideoPacket(long int requested_frame) // Remove frame and packet RemoveAVFrame(my_frame); - RemoveAVPacket(my_packet); sws_freeContext(img_convert_ctx); // Remove video frame from list of processing video frames @@ -892,9 +884,6 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ // Are we close enough to decode the frame's audio? if (target_frame < (requested_frame - 20)) { - // Remove packet - RemoveAVPacket(packet); - // Debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Skipped)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample, "", -1, "", -1, "", -1); @@ -902,9 +891,6 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ return; } - // Init some local variables (for OpenMP) - AVPacket *my_packet = packet; - // Debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Before)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample, "", -1, "", -1, "", -1); @@ -918,7 +904,7 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ // re-initialize buffer size (it gets changed in the avcodec_decode_audio2 method call) int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; - int used = avcodec_decode_audio4(aCodecCtx, audio_frame, &frame_finished, my_packet); + int used = avcodec_decode_audio4(aCodecCtx, audio_frame, &frame_finished, packet); if (frame_finished) { @@ -989,192 +975,176 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ } + // Allocate audio buffer + int16_t *audio_buf = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; - // Process the audio samples in a separate thread (this includes resampling to 16 bit integer, and storing - // in a openshot::Frame object). - #pragma omp task firstprivate(requested_frame, target_frame, starting_sample, my_packet, audio_frame) + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (ReSample)", "packet_samples", packet_samples, "info.channels", info.channels, "info.sample_rate", info.sample_rate, "aCodecCtx->sample_fmt", aCodecCtx->sample_fmt, "AV_SAMPLE_FMT_S16", AV_SAMPLE_FMT_S16, "", -1); + + // Create output frame + AVFrame *audio_converted = AV_ALLOCATE_FRAME(); + AV_RESET_FRAME(audio_converted); + audio_converted->nb_samples = audio_frame->nb_samples; + av_samples_alloc(audio_converted->data, audio_converted->linesize, info.channels, audio_frame->nb_samples, AV_SAMPLE_FMT_S16, 0); + + AVAudioResampleContext *avr = NULL; + int nb_samples = 0; + + // setup resample context + avr = avresample_alloc_context(); + av_opt_set_int(avr, "in_channel_layout", aCodecCtx->channel_layout, 0); + av_opt_set_int(avr, "out_channel_layout", aCodecCtx->channel_layout, 0); + av_opt_set_int(avr, "in_sample_fmt", aCodecCtx->sample_fmt, 0); + av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + av_opt_set_int(avr, "in_sample_rate", info.sample_rate, 0); + av_opt_set_int(avr, "out_sample_rate", info.sample_rate, 0); + av_opt_set_int(avr, "in_channels", info.channels, 0); + av_opt_set_int(avr, "out_channels", info.channels, 0); + int r = avresample_open(avr); + + // Convert audio samples + nb_samples = avresample_convert(avr, // audio resample context + audio_converted->data, // output data pointers + audio_converted->linesize[0], // output plane size, in bytes. (0 if unknown) + audio_converted->nb_samples, // maximum number of samples that the output buffer can hold + audio_frame->data, // input data pointers + audio_frame->linesize[0], // input plane size, in bytes (0 if unknown) + audio_frame->nb_samples); // number of input samples to convert + + // Copy audio samples over original samples + memcpy(audio_buf, audio_converted->data[0], audio_converted->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * info.channels); + + // Deallocate resample buffer + avresample_close(avr); + avresample_free(&avr); + avr = NULL; + + // Free AVFrames + av_free(audio_converted->data[0]); + AV_FREE_FRAME(&audio_converted); + + long int starting_frame_number = -1; + bool partial_frame = true; + for (int channel_filter = 0; channel_filter < info.channels; channel_filter++) { - // Allocate audio buffer - int16_t *audio_buf = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + // Array of floats (to hold samples for each channel) + starting_frame_number = target_frame; + int channel_buffer_size = packet_samples / info.channels; + float *channel_buffer = new float[channel_buffer_size]; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (ReSample)", "packet_samples", packet_samples, "info.channels", info.channels, "info.sample_rate", info.sample_rate, "aCodecCtx->sample_fmt", aCodecCtx->sample_fmt, "AV_SAMPLE_FMT_S16", AV_SAMPLE_FMT_S16, "", -1); + // Init buffer array + for (int z = 0; z < channel_buffer_size; z++) + channel_buffer[z] = 0.0f; - // Create output frame - AVFrame *audio_converted = AV_ALLOCATE_FRAME(); - AV_RESET_FRAME(audio_converted); - audio_converted->nb_samples = audio_frame->nb_samples; - av_samples_alloc(audio_converted->data, audio_converted->linesize, info.channels, audio_frame->nb_samples, AV_SAMPLE_FMT_S16, 0); - - AVAudioResampleContext *avr = NULL; - int nb_samples = 0; - #pragma ordered + // Loop through all samples and add them to our Frame based on channel. + // Toggle through each channel number, since channel data is stored like (left right left right) + int channel = 0; + int position = 0; + for (int sample = 0; sample < packet_samples; sample++) { - // setup resample context - avr = avresample_alloc_context(); - av_opt_set_int(avr, "in_channel_layout", aCodecCtx->channel_layout, 0); - av_opt_set_int(avr, "out_channel_layout", aCodecCtx->channel_layout, 0); - av_opt_set_int(avr, "in_sample_fmt", aCodecCtx->sample_fmt, 0); - av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); - av_opt_set_int(avr, "in_sample_rate", info.sample_rate, 0); - av_opt_set_int(avr, "out_sample_rate", info.sample_rate, 0); - av_opt_set_int(avr, "in_channels", info.channels, 0); - av_opt_set_int(avr, "out_channels", info.channels, 0); - int r = avresample_open(avr); - - // Convert audio samples - nb_samples = avresample_convert(avr, // audio resample context - audio_converted->data, // output data pointers - audio_converted->linesize[0], // output plane size, in bytes. (0 if unknown) - audio_converted->nb_samples, // maximum number of samples that the output buffer can hold - audio_frame->data, // input data pointers - audio_frame->linesize[0], // input plane size, in bytes (0 if unknown) - audio_frame->nb_samples); // number of input samples to convert - } - - // Copy audio samples over original samples - memcpy(audio_buf, audio_converted->data[0], audio_converted->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * info.channels); - - // Deallocate resample buffer - avresample_close(avr); - avresample_free(&avr); - avr = NULL; - - // Free AVFrames - av_free(audio_converted->data[0]); - AV_FREE_FRAME(&audio_converted); - - long int starting_frame_number = -1; - bool partial_frame = true; - for (int channel_filter = 0; channel_filter < info.channels; channel_filter++) - { - // Array of floats (to hold samples for each channel) - starting_frame_number = target_frame; - int channel_buffer_size = packet_samples / info.channels; - float *channel_buffer = new float[channel_buffer_size]; - - // Init buffer array - for (int z = 0; z < channel_buffer_size; z++) - channel_buffer[z] = 0.0f; - - // Loop through all samples and add them to our Frame based on channel. - // Toggle through each channel number, since channel data is stored like (left right left right) - int channel = 0; - int position = 0; - for (int sample = 0; sample < packet_samples; sample++) + // Only add samples for current channel + if (channel_filter == channel) { - // Only add samples for current channel - if (channel_filter == channel) - { - // Add sample (convert from (-32768 to 32768) to (-1.0 to 1.0)) - channel_buffer[position] = audio_buf[sample] * (1.0f / (1 << 15)); + // Add sample (convert from (-32768 to 32768) to (-1.0 to 1.0)) + channel_buffer[position] = audio_buf[sample] * (1.0f / (1 << 15)); - // Increment audio position - position++; - } - - // increment channel (if needed) - if ((channel + 1) < info.channels) - // move to next channel - channel ++; - else - // reset channel - channel = 0; + // Increment audio position + position++; } - // Loop through samples, and add them to the correct frames - int start = starting_sample; - int remaining_samples = channel_buffer_size; - float *iterate_channel_buffer = channel_buffer; // pointer to channel buffer - while (remaining_samples > 0) - { - // Get Samples per frame (for this frame number) - int samples_per_frame = Frame::GetSamplesPerFrame(starting_frame_number, info.fps, info.sample_rate, info.channels); - - // Calculate # of samples to add to this frame - int samples = samples_per_frame - start; - if (samples > remaining_samples) - samples = remaining_samples; - - // Create or get the existing frame object - tr1::shared_ptr f = CreateFrame(starting_frame_number); - - // Determine if this frame was "partially" filled in - if (samples_per_frame == start + samples) - partial_frame = false; - else - partial_frame = true; - - // Add samples for current channel to the frame. Reduce the volume to 98%, to prevent - // some louder samples from maxing out at 1.0 (not sure why this happens) - f->AddAudio(true, channel_filter, start, iterate_channel_buffer, samples, 0.98f); - - // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (f->AddAudio)", "frame", starting_frame_number, "start", start, "samples", samples, "channel", channel_filter, "partial_frame", partial_frame, "samples_per_frame", samples_per_frame); - - // Add or update cache - working_cache.Add(f); - - // Decrement remaining samples - remaining_samples -= samples; - - // Increment buffer (to next set of samples) - if (remaining_samples > 0) - iterate_channel_buffer += samples; - - // Increment frame number - starting_frame_number++; - - // Reset starting sample # - start = 0; - } - - // clear channel buffer - delete[] channel_buffer; - channel_buffer = NULL; - iterate_channel_buffer = NULL; + // increment channel (if needed) + if ((channel + 1) < info.channels) + // move to next channel + channel ++; + else + // reset channel + channel = 0; } - // Clean up some arrays - delete[] audio_buf; - audio_buf = NULL; - - // Remove audio frame from list of processing audio frames + // Loop through samples, and add them to the correct frames + int start = starting_sample; + int remaining_samples = channel_buffer_size; + float *iterate_channel_buffer = channel_buffer; // pointer to channel buffer + while (remaining_samples > 0) { - const GenericScopedLock lock(processingCriticalSection); - // Update all frames as completed - for (long int f = target_frame; f < starting_frame_number; f++) { - // Remove the frame # from the processing list. NOTE: If more than one thread is - // processing this frame, the frame # will be in this list multiple times. We are only - // removing a single instance of it here. - processing_audio_frames.erase(processing_audio_frames.find(f)); + // Get Samples per frame (for this frame number) + int samples_per_frame = Frame::GetSamplesPerFrame(starting_frame_number, info.fps, info.sample_rate, info.channels); - // Check and see if this frame is also being processed by another thread - if (processing_audio_frames.count(f) == 0) - // No other thread is processing it. Mark the audio as processed (final) - processed_audio_frames[f] = f; - } + // Calculate # of samples to add to this frame + int samples = samples_per_frame - start; + if (samples > remaining_samples) + samples = remaining_samples; - if (target_frame == starting_frame_number) { - // This typically never happens, but just in case, remove the currently processing number - processing_audio_frames.erase(processing_audio_frames.find(target_frame)); - } + // Create or get the existing frame object + std::shared_ptr f = CreateFrame(starting_frame_number); + + // Determine if this frame was "partially" filled in + if (samples_per_frame == start + samples) + partial_frame = false; + else + partial_frame = true; + + // Add samples for current channel to the frame. Reduce the volume to 98%, to prevent + // some louder samples from maxing out at 1.0 (not sure why this happens) + f->AddAudio(true, channel_filter, start, iterate_channel_buffer, samples, 0.98f); + + // Debug output + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (f->AddAudio)", "frame", starting_frame_number, "start", start, "samples", samples, "channel", channel_filter, "partial_frame", partial_frame, "samples_per_frame", samples_per_frame); + + // Add or update cache + working_cache.Add(f); + + // Decrement remaining samples + remaining_samples -= samples; + + // Increment buffer (to next set of samples) + if (remaining_samples > 0) + iterate_channel_buffer += samples; + + // Increment frame number + starting_frame_number++; + + // Reset starting sample # + start = 0; } - // Remove this packet - RemoveAVPacket(my_packet); + // clear channel buffer + delete[] channel_buffer; + channel_buffer = NULL; + iterate_channel_buffer = NULL; + } - // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (After)", "requested_frame", requested_frame, "starting_frame", target_frame, "end_frame", starting_frame_number - 1, "", -1, "", -1, "", -1); + // Clean up some arrays + delete[] audio_buf; + audio_buf = NULL; - } // end task + // Remove audio frame from list of processing audio frames + { + const GenericScopedLock lock(processingCriticalSection); + // Update all frames as completed + for (long int f = target_frame; f < starting_frame_number; f++) { + // Remove the frame # from the processing list. NOTE: If more than one thread is + // processing this frame, the frame # will be in this list multiple times. We are only + // removing a single instance of it here. + processing_audio_frames.erase(processing_audio_frames.find(f)); + // Check and see if this frame is also being processed by another thread + if (processing_audio_frames.count(f) == 0) + // No other thread is processing it. Mark the audio as processed (final) + processed_audio_frames[f] = f; + } - // TODO: Fix this bug. Wait on the task to complete. This is not ideal, but solves an issue with the - // audio_frame being modified by the next call to this method. I think this is a scope issue with OpenMP. - #pragma omp taskwait + if (target_frame == starting_frame_number) { + // This typically never happens, but just in case, remove the currently processing number + processing_audio_frames.erase(processing_audio_frames.find(target_frame)); + } + } // Free audio frame AV_FREE_FRAME(&audio_frame); + + // Debug output + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (After)", "requested_frame", requested_frame, "starting_frame", target_frame, "end_frame", starting_frame_number - 1, "", -1, "", -1, "", -1); + } @@ -1188,12 +1158,24 @@ void FFmpegReader::Seek(long int requested_frame) throw(TooManySeeks) if (requested_frame > info.video_length) requested_frame = info.video_length; + int processing_video_frames_size = 0; + int processing_audio_frames_size = 0; + { + const GenericScopedLock lock(processingCriticalSection); + processing_video_frames_size = processing_video_frames.size(); + processing_audio_frames_size = processing_audio_frames.size(); + } + // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::Seek", "requested_frame", requested_frame, "seek_count", seek_count, "last_frame", last_frame, "processing_video_frames.size()", processing_video_frames.size(), "processing_audio_frames.size()", processing_audio_frames.size(), "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::Seek", "requested_frame", requested_frame, "seek_count", seek_count, "last_frame", last_frame, "processing_video_frames_size", processing_video_frames_size, "processing_audio_frames_size", processing_audio_frames_size, "", -1); // Wait for any processing frames to complete - while (processing_video_frames.size() + processing_audio_frames.size() > 0) + while (processing_video_frames_size + processing_audio_frames_size > 0) { usleep(2500); + const GenericScopedLock lock(processingCriticalSection); + processing_video_frames_size = processing_video_frames.size(); + processing_audio_frames_size = processing_audio_frames.size(); + } // Clear working cache (since we are seeking to another location in the file) working_cache.Clear(); @@ -1206,7 +1188,6 @@ void FFmpegReader::Seek(long int requested_frame) throw(TooManySeeks) processing_video_frames.clear(); processed_video_frames.clear(); processed_audio_frames.clear(); - duplicate_video_frames.clear(); missing_audio_frames.clear(); missing_video_frames.clear(); missing_audio_frames_source.clear(); @@ -1392,8 +1373,6 @@ long int FFmpegReader::ConvertVideoPTStoFrame(long int pts) // Sometimes frames are duplicated due to identical (or similar) timestamps if (frame == previous_video_frame) { - duplicate_video_frames.insert(pair(frame, frame)); - // return -1 frame number frame = -1; } @@ -1522,14 +1501,14 @@ AudioLocation FFmpegReader::GetAudioPTSLocation(long int pts) } // Create a new Frame (or return an existing one) and add it to the working queue. -tr1::shared_ptr FFmpegReader::CreateFrame(long int requested_frame) +std::shared_ptr FFmpegReader::CreateFrame(long int requested_frame) { // Check working cache - tr1::shared_ptr output = working_cache.GetFrame(requested_frame); + std::shared_ptr output = working_cache.GetFrame(requested_frame); if (!output) { // Create a new frame on the working cache - output = tr1::shared_ptr(new Frame(requested_frame, info.width, info.height, "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels)); + output = std::make_shared(requested_frame, info.width, info.height, "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels); output->SetPixelRatio(info.pixel_ratio.num, info.pixel_ratio.den); // update pixel ratio output->ChannelsLayout(info.channel_layout); // update audio channel layout from the parent reader output->SampleRate(info.sample_rate); // update the frame's sample rate of the parent reader @@ -1599,7 +1578,7 @@ bool FFmpegReader::CheckMissingFrame(long int requested_frame) checked_frames[missing_source_frame]++; // Get the previous frame of this missing frame (if it's available in missing cache) - tr1::shared_ptr parent_frame = missing_frames.GetFrame(missing_source_frame); + std::shared_ptr parent_frame = missing_frames.GetFrame(missing_source_frame); if (parent_frame == NULL) { parent_frame = final_cache.GetFrame(missing_source_frame); if (parent_frame != NULL) { @@ -1609,7 +1588,7 @@ bool FFmpegReader::CheckMissingFrame(long int requested_frame) } // Create blank missing frame - tr1::shared_ptr missing_frame = CreateFrame(requested_frame); + std::shared_ptr missing_frame = CreateFrame(requested_frame); // Debug output ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (Is Previous Video Frame Final)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame, "", -1, "", -1, "", -1); @@ -1620,19 +1599,22 @@ bool FFmpegReader::CheckMissingFrame(long int requested_frame) ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (AddImage from Previous Video Frame)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame, "", -1, "", -1, "", -1); // Add this frame to the processed map (since it's already done) - missing_frame->AddImage(tr1::shared_ptr(new QImage(*parent_frame->GetImage()))); + std::shared_ptr parent_image = parent_frame->GetImage(); + if (parent_image) { + missing_frame->AddImage(std::shared_ptr(new QImage(*parent_image))); - processed_video_frames[missing_frame->number] = missing_frame->number; - processed_audio_frames[missing_frame->number] = missing_frame->number; + processed_video_frames[missing_frame->number] = missing_frame->number; + processed_audio_frames[missing_frame->number] = missing_frame->number; - // Move frame to final cache - final_cache.Add(missing_frame); + // Move frame to final cache + final_cache.Add(missing_frame); - // Remove frame from working cache - working_cache.Remove(missing_frame->number); + // Remove frame from working cache + working_cache.Remove(missing_frame->number); - // Update last_frame processed - last_frame = missing_frame->number; + // Update last_frame processed + last_frame = missing_frame->number; + } } } @@ -1650,7 +1632,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, long int requested_fra while (true) { // Get the front frame of working cache - tr1::shared_ptr f(working_cache.GetSmallestFrame()); + std::shared_ptr f(working_cache.GetSmallestFrame()); // Was a frame found? if (!f) @@ -1662,6 +1644,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, long int requested_fra // Init # of times this frame has been checked so far int checked_count = 0; + int checked_frames_size = 0; bool is_video_ready = false; bool is_audio_ready = false; @@ -1671,6 +1654,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, long int requested_fra is_audio_ready = processed_audio_frames.count(f->number); // Get check count for this frame + checked_frames_size = checked_frames.size(); if (!checked_count_tripped || f->number >= requested_frame) checked_count = checked_frames[f->number]; else @@ -1689,14 +1673,14 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, long int requested_fra // Make final any frames that get stuck (for whatever reason) if (checked_count >= max_checked_count && (!is_video_ready || !is_audio_ready)) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames (exceeded checked_count)", "requested_frame", requested_frame, "frame_number", f->number, "is_video_ready", is_video_ready, "is_audio_ready", is_audio_ready, "checked_count", checked_count, "checked_frames.size()", checked_frames.size()); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames (exceeded checked_count)", "requested_frame", requested_frame, "frame_number", f->number, "is_video_ready", is_video_ready, "is_audio_ready", is_audio_ready, "checked_count", checked_count, "checked_frames_size", checked_frames_size); // Trigger checked count tripped mode (clear out all frames before requested frame) checked_count_tripped = true; if (info.has_video && !is_video_ready && last_video_frame) { // Copy image from last frame - f->AddImage(tr1::shared_ptr(new QImage(*last_video_frame->GetImage()))); + f->AddImage(std::shared_ptr(new QImage(*last_video_frame->GetImage()))); is_video_ready = true; } @@ -1708,7 +1692,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, long int requested_fra } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames", "requested_frame", requested_frame, "frame_number", f->number, "is_video_ready", is_video_ready, "is_audio_ready", is_audio_ready, "checked_count", checked_count, "checked_frames.size()", checked_frames.size()); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames", "requested_frame", requested_frame, "frame_number", f->number, "is_video_ready", is_video_ready, "is_audio_ready", is_audio_ready, "checked_count", checked_count, "checked_frames_size", checked_frames_size); // Check if working frame is final if ((!end_of_stream && is_video_ready && is_audio_ready) || end_of_stream || is_seek_trash) @@ -1792,9 +1776,6 @@ void FFmpegReader::CheckFPS() // Remove pFrame RemoveAVFrame(pFrame); - // remove packet - RemoveAVPacket(packet); - // Apply PTS offset pts += video_pts_offset; @@ -1816,13 +1797,7 @@ void FFmpegReader::CheckFPS() // Too far break; } - else - // remove packet - RemoveAVPacket(packet); } - else - // remove packet - RemoveAVPacket(packet); // Increment counters iterations++; @@ -1880,29 +1855,22 @@ void FFmpegReader::CheckFPS() // Remove AVFrame from cache (and deallocate it's memory) void FFmpegReader::RemoveAVFrame(AVPicture* remove_frame) { - #pragma omp critical (packet_cache) - { - // Remove pFrame (if exists) - if (frames.count(remove_frame)) - { - // Free memory - avpicture_free(frames[remove_frame]); + // Remove pFrame (if exists) + if (remove_frame) + { + // Free memory + avpicture_free(remove_frame); - // Remove from cache - frames.erase(remove_frame); - - // Delete the object - delete remove_frame; - } - - } // end omp critical + // Delete the object + delete remove_frame; + } } // Remove AVPacket from cache (and deallocate it's memory) void FFmpegReader::RemoveAVPacket(AVPacket* remove_packet) { // deallocate memory for packet - av_free_packet(remove_packet); + AV_FREE_PACKET(remove_packet); // Delete the object delete remove_packet; @@ -1914,6 +1882,7 @@ long int FFmpegReader::GetSmallestVideoFrame() // Loop through frame numbers map::iterator itr; long int smallest_frame = -1; + const GenericScopedLock lock(processingCriticalSection); for(itr = processing_video_frames.begin(); itr != processing_video_frames.end(); ++itr) { if (itr->first < smallest_frame || smallest_frame == -1) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index a5cbefba..59e985c6 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -346,7 +346,7 @@ void FFmpegWriter::WriteHeader() } // Add a frame to the queue waiting to be encoded. -void FFmpegWriter::WriteFrame(tr1::shared_ptr frame) throw(ErrorEncodingVideo, WriterClosed) +void FFmpegWriter::WriteFrame(std::shared_ptr frame) throw(ErrorEncodingVideo, WriterClosed) { // Check for open reader (or throw exception) if (!is_open) @@ -421,7 +421,7 @@ void FFmpegWriter::write_queued_frames() throw (ErrorEncodingVideo) while (!queued_video_frames.empty()) { // Get front frame (from the queue) - tr1::shared_ptr frame = queued_video_frames.front(); + std::shared_ptr frame = queued_video_frames.front(); // Add to processed queue processed_frames.push_back(frame); @@ -442,7 +442,7 @@ void FFmpegWriter::write_queued_frames() throw (ErrorEncodingVideo) while (!processed_frames.empty()) { // Get front frame (from the queue) - tr1::shared_ptr frame = processed_frames.front(); + std::shared_ptr frame = processed_frames.front(); if (info.has_video && video_st) { @@ -470,7 +470,7 @@ void FFmpegWriter::write_queued_frames() throw (ErrorEncodingVideo) while (!deallocate_frames.empty()) { // Get front frame (from the queue) - tr1::shared_ptr frame = deallocate_frames.front(); + std::shared_ptr frame = deallocate_frames.front(); // Does this frame's AVFrame still exist if (av_frames.count(frame)) @@ -508,7 +508,7 @@ void FFmpegWriter::WriteFrame(ReaderBase* reader, long int start, long int lengt for (long int number = start; number <= length; number++) { // Get the frame - tr1::shared_ptr f = reader->GetFrame(number); + std::shared_ptr f = reader->GetFrame(number); // Encode frame WriteFrame(f); @@ -678,7 +678,7 @@ void FFmpegWriter::flush_encoders() } // deallocate memory for packet - av_free_packet(&pkt); + AV_FREE_PACKET(&pkt); } @@ -764,7 +764,7 @@ void FFmpegWriter::Close() } // Add an AVFrame to the cache -void FFmpegWriter::add_avframe(tr1::shared_ptr frame, AVFrame* av_frame) +void FFmpegWriter::add_avframe(std::shared_ptr frame, AVFrame* av_frame) { // Add AVFrame to map (if it does not already exist) if (!av_frames.count(frame)) @@ -1063,7 +1063,7 @@ void FFmpegWriter::write_audio_packets(bool final) while (!queued_audio_frames.empty()) { // Get front frame (from the queue) - tr1::shared_ptr frame = queued_audio_frames.front(); + std::shared_ptr frame = queued_audio_frames.front(); // Get the audio details from this frame sample_rate_in_frame = frame->SampleRate(); @@ -1355,7 +1355,7 @@ void FFmpegWriter::write_audio_packets(bool final) AV_FREE_FRAME(&frame_final); // deallocate memory for packet - av_free_packet(&pkt); + AV_FREE_PACKET(&pkt); // Reset position audio_input_position = 0; @@ -1406,7 +1406,7 @@ AVFrame* FFmpegWriter::allocate_avframe(PixelFormat pix_fmt, int width, int heig } // process video frame -void FFmpegWriter::process_video_packet(tr1::shared_ptr frame) +void FFmpegWriter::process_video_packet(std::shared_ptr frame) { // Determine the height & width of the source image int source_image_width = frame->GetWidth(); @@ -1461,7 +1461,7 @@ void FFmpegWriter::process_video_packet(tr1::shared_ptr frame) } // write video frame -bool FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* frame_final) +bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame* frame_final) { ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags & AVFMT_RAWPICTURE", oc->oformat->flags & AVFMT_RAWPICTURE, "", -1, "", -1, "", -1, "", -1); @@ -1488,7 +1488,7 @@ bool FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* fra } // Deallocate packet - av_free_packet(&pkt); + AV_FREE_PACKET(&pkt); } else { @@ -1566,7 +1566,7 @@ bool FFmpegWriter::write_video_packet(tr1::shared_ptr frame, AVFrame* fra delete[] video_outbuf; // Deallocate packet - av_free_packet(&pkt); + AV_FREE_PACKET(&pkt); } // Success diff --git a/src/Frame.cpp b/src/Frame.cpp index 9fca6615..cac828f2 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -35,7 +35,7 @@ Frame::Frame() : number(1), pixel_ratio(1,1), channels(2), width(1), height(1), channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false) { // Init the image magic and audio buffer - audio = tr1::shared_ptr(new juce::AudioSampleBuffer(channels, 0)); + audio = std::shared_ptr(new juce::AudioSampleBuffer(channels, 0)); // initialize the audio samples to zero (silence) audio->clear(); @@ -47,7 +47,7 @@ Frame::Frame(long int number, int width, int height, string color) channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false) { // Init the image magic and audio buffer - audio = tr1::shared_ptr(new juce::AudioSampleBuffer(channels, 0)); + audio = std::shared_ptr(new juce::AudioSampleBuffer(channels, 0)); // initialize the audio samples to zero (silence) audio->clear(); @@ -59,7 +59,7 @@ Frame::Frame(long int number, int samples, int channels) : channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false) { // Init the image magic and audio buffer - audio = tr1::shared_ptr(new juce::AudioSampleBuffer(channels, samples)); + audio = std::shared_ptr(new juce::AudioSampleBuffer(channels, samples)); // initialize the audio samples to zero (silence) audio->clear(); @@ -71,7 +71,7 @@ Frame::Frame(long int number, int width, int height, string color, int samples, channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false) { // Init the image magic and audio buffer - audio = tr1::shared_ptr(new juce::AudioSampleBuffer(channels, samples)); + audio = std::shared_ptr(new juce::AudioSampleBuffer(channels, samples)); // initialize the audio samples to zero (silence) audio->clear(); @@ -89,8 +89,8 @@ Frame::Frame ( const Frame &other ) void Frame::DeepCopy(const Frame& other) { number = other.number; - image = tr1::shared_ptr(new QImage(*(other.image))); - audio = tr1::shared_ptr(new juce::AudioSampleBuffer(*(other.audio))); + image = std::shared_ptr(new QImage(*(other.image))); + audio = std::shared_ptr(new juce::AudioSampleBuffer(*(other.audio))); pixel_ratio = Fraction(other.pixel_ratio.num, other.pixel_ratio.den); channels = other.channels; channel_layout = other.channel_layout; @@ -100,7 +100,7 @@ void Frame::DeepCopy(const Frame& other) if (other.wave_image) - wave_image = tr1::shared_ptr(new QImage(*(other.wave_image))); + wave_image = std::shared_ptr(new QImage(*(other.wave_image))); } // Descructor @@ -117,11 +117,11 @@ void Frame::Display() // Only create the QApplication once static int argc = 1; static char* argv[1] = {NULL}; - previewApp = tr1::shared_ptr(new QApplication(argc, argv)); + previewApp = std::shared_ptr(new QApplication(argc, argv)); } // Get preview image - tr1::shared_ptr previewImage = GetImage(); + std::shared_ptr previewImage = GetImage(); // Update the image to reflect the correct pixel aspect ration (i.e. to fix non-squar pixels) if (pixel_ratio.num != 1 || pixel_ratio.den != 1) @@ -131,7 +131,7 @@ void Frame::Display() int new_height = previewImage->size().height() * pixel_ratio.Reciprocal().ToDouble(); // Resize to fix DAR - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); } // Create window @@ -152,7 +152,7 @@ void Frame::Display() } // Get an audio waveform image -tr1::shared_ptr Frame::GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha) +std::shared_ptr Frame::GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha) { // Clear any existing waveform image ClearWaveform(); @@ -207,7 +207,7 @@ tr1::shared_ptr Frame::GetWaveform(int width, int height, int Red, int G } // Create blank image - wave_image = tr1::shared_ptr(new QImage(total_width, total_height, QImage::Format_RGBA8888)); + wave_image = std::shared_ptr(new QImage(total_width, total_height, QImage::Format_RGBA8888)); wave_image->fill(QColor(0,0,0,0)); // Load QPainter with wave_image device @@ -232,13 +232,13 @@ tr1::shared_ptr Frame::GetWaveform(int width, int height, int Red, int G // Resize Image (if requested) if (width != total_width || height != total_height) { QImage scaled_wave_image = wave_image->scaled(width, height, Qt::IgnoreAspectRatio, Qt::FastTransformation); - wave_image = tr1::shared_ptr(new QImage(scaled_wave_image)); + wave_image = std::shared_ptr(new QImage(scaled_wave_image)); } } else { // No audio samples present - wave_image = tr1::shared_ptr(new QImage(width, height, QImage::Format_RGBA8888)); + wave_image = std::shared_ptr(new QImage(width, height, QImage::Format_RGBA8888)); wave_image->fill(QColor(QString::fromStdString("#000000"))); } @@ -273,7 +273,7 @@ void Frame::DisplayWaveform() // Only create the QApplication once static int argc = 1; static char* argv[1] = {NULL}; - previewApp = tr1::shared_ptr(new QApplication(argc, argv)); + previewApp = std::shared_ptr(new QApplication(argc, argv)); } // Create window @@ -536,7 +536,7 @@ ChannelLayout Frame::ChannelsLayout() void Frame::Save(string path, float scale, string format, int quality) { // Get preview image - tr1::shared_ptr previewImage = GetImage(); + std::shared_ptr previewImage = GetImage(); // scale image if needed if (abs(scale) > 1.001 || abs(scale) < 0.999) @@ -552,11 +552,11 @@ void Frame::Save(string path, float scale, string format, int quality) int new_height = previewImage->size().height() * pixel_ratio.Reciprocal().ToDouble(); // Resize to fix DAR - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); } // Resize image - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(new_width * scale, new_height * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(new_width * scale, new_height * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation))); } // Save image @@ -568,7 +568,7 @@ void Frame::Thumbnail(string path, int new_width, int new_height, string mask_pa string background_color, bool ignore_aspect, string format, int quality) throw(InvalidFile) { // Create blank thumbnail image & fill background color - tr1::shared_ptr thumbnail = tr1::shared_ptr(new QImage(new_width, new_height, QImage::Format_RGBA8888)); + std::shared_ptr thumbnail = std::shared_ptr(new QImage(new_width, new_height, QImage::Format_RGBA8888)); thumbnail->fill(QColor(QString::fromStdString(background_color))); // Create transform and painter @@ -578,7 +578,7 @@ void Frame::Thumbnail(string path, int new_width, int new_height, string mask_pa // Get preview image - tr1::shared_ptr previewImage = GetImage(); + std::shared_ptr previewImage = GetImage(); // Update the image to reflect the correct pixel aspect ration (i.e. to fix non-squar pixels) if (pixel_ratio.num != 1 || pixel_ratio.den != 1) @@ -588,16 +588,16 @@ void Frame::Thumbnail(string path, int new_width, int new_height, string mask_pa int aspect_height = previewImage->size().height() * pixel_ratio.Reciprocal().ToDouble(); // Resize to fix DAR - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(aspect_width, aspect_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(aspect_width, aspect_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); } // Resize frame image if (ignore_aspect) // Ignore aspect ratio - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); else // Maintain aspect ratio - previewImage = tr1::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + previewImage = std::shared_ptr(new QImage(previewImage->scaled(new_width, new_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); // Composite frame image onto background (centered) int x = (new_width - previewImage->size().width()) / 2.0; // center @@ -609,14 +609,14 @@ void Frame::Thumbnail(string path, int new_width, int new_height, string mask_pa // Overlay Image (if any) if (overlay_path != "") { // Open overlay - tr1::shared_ptr overlay = tr1::shared_ptr(new QImage()); + std::shared_ptr overlay = std::shared_ptr(new QImage()); overlay->load(QString::fromStdString(overlay_path)); // Set pixel format - overlay = tr1::shared_ptr(new QImage(overlay->convertToFormat(QImage::Format_RGBA8888))); + overlay = std::shared_ptr(new QImage(overlay->convertToFormat(QImage::Format_RGBA8888))); // Resize to fit - overlay = tr1::shared_ptr(new QImage(overlay->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + overlay = std::shared_ptr(new QImage(overlay->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); // Composite onto thumbnail painter.setCompositionMode(QPainter::CompositionMode_SourceOver); @@ -627,14 +627,14 @@ void Frame::Thumbnail(string path, int new_width, int new_height, string mask_pa // Mask Image (if any) if (mask_path != "") { // Open mask - tr1::shared_ptr mask = tr1::shared_ptr(new QImage()); + std::shared_ptr mask = std::shared_ptr(new QImage()); mask->load(QString::fromStdString(mask_path)); // Set pixel format - mask = tr1::shared_ptr(new QImage(mask->convertToFormat(QImage::Format_RGBA8888))); + mask = std::shared_ptr(new QImage(mask->convertToFormat(QImage::Format_RGBA8888))); // Resize to fit - mask = tr1::shared_ptr(new QImage(mask->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + mask = std::shared_ptr(new QImage(mask->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); // Negate mask mask->invertPixels(); @@ -682,7 +682,7 @@ void Frame::AddColor(int new_width, int new_height, string color) { // Create new image object, and fill with pixel data const GenericScopedLock lock(addingImageSection); - image = tr1::shared_ptr(new QImage(new_width, new_height, QImage::Format_RGBA8888)); + image = std::shared_ptr(new QImage(new_width, new_height, QImage::Format_RGBA8888)); // Fill with solid color image->fill(QColor(QString::fromStdString(color))); @@ -705,7 +705,7 @@ void Frame::AddImage(int new_width, int new_height, int bytes_per_pixel, QImage: memcpy((unsigned char*)qbuffer, pixels_, buffer_size); // Create new image object, and fill with pixel data - image = tr1::shared_ptr(new QImage(qbuffer, new_width, new_height, new_width * bytes_per_pixel, type, (QImageCleanupFunction) &openshot::Frame::cleanUpBuffer, (void*) qbuffer)); + image = std::shared_ptr(new QImage(qbuffer, new_width, new_height, new_width * bytes_per_pixel, type, (QImageCleanupFunction) &openshot::Frame::cleanUpBuffer, (void*) qbuffer)); // Always convert to RGBA8888 (if different) if (image->format() != QImage::Format_RGBA8888) @@ -718,7 +718,7 @@ void Frame::AddImage(int new_width, int new_height, int bytes_per_pixel, QImage: } // Add (or replace) pixel data to the frame -void Frame::AddImage(tr1::shared_ptr new_image) +void Frame::AddImage(std::shared_ptr new_image) { // Ignore blank images if (!new_image) @@ -739,7 +739,7 @@ void Frame::AddImage(tr1::shared_ptr new_image) } // Add (or replace) pixel data to the frame (for only the odd or even lines) -void Frame::AddImage(tr1::shared_ptr new_image, bool only_odd_lines) +void Frame::AddImage(std::shared_ptr new_image, bool only_odd_lines) { // Ignore blank new_image if (!new_image) @@ -822,7 +822,7 @@ void Frame::ApplyGainRamp(int destChannel, int destStartSample, int numSamples, } // Get pointer to Magick++ image object -tr1::shared_ptr Frame::GetImage() +std::shared_ptr Frame::GetImage() { // Check for blank image if (!image) @@ -834,7 +834,7 @@ tr1::shared_ptr Frame::GetImage() #ifdef USE_IMAGEMAGICK // Get pointer to ImageMagick image object -tr1::shared_ptr Frame::GetMagickImage() +std::shared_ptr Frame::GetMagickImage() { // Check for blank image if (!image) @@ -845,7 +845,7 @@ tr1::shared_ptr Frame::GetMagickImage() QRgb const *tmpBits = (const QRgb*)image->bits(); // Create new image object, and fill with pixel data - tr1::shared_ptr magick_image = tr1::shared_ptr(new Magick::Image(image->width(), image->height(),"RGBA", Magick::CharPixel, tmpBits)); + std::shared_ptr magick_image = std::shared_ptr(new Magick::Image(image->width(), image->height(),"RGBA", Magick::CharPixel, tmpBits)); // Give image a transparent background color magick_image->backgroundColor(Magick::Color("none")); @@ -858,7 +858,7 @@ tr1::shared_ptr Frame::GetMagickImage() #ifdef USE_IMAGEMAGICK // Get pointer to QImage of frame -void Frame::AddMagickImage(tr1::shared_ptr new_image) +void Frame::AddMagickImage(std::shared_ptr new_image) { const int BPP = 4; const std::size_t bufferSize = new_image->columns() * new_image->rows() * BPP; @@ -882,7 +882,7 @@ void Frame::AddMagickImage(tr1::shared_ptr new_image) } // Create QImage of frame data - image = tr1::shared_ptr(new QImage(qbuffer, width, height, width * BPP, QImage::Format_RGBA8888, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer)); + image = std::shared_ptr(new QImage(qbuffer, width, height, width * BPP, QImage::Format_RGBA8888, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer)); // Update height and width width = image->width(); diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 1ce6946b..a1f044b2 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -341,9 +341,9 @@ MappedFrame FrameMapper::GetMappedFrame(long int TargetFrameNumber) throw(OutOfB } // Get or generate a blank frame -tr1::shared_ptr FrameMapper::GetOrCreateFrame(long int number) +std::shared_ptr FrameMapper::GetOrCreateFrame(long int number) { - tr1::shared_ptr new_frame; + std::shared_ptr new_frame; // Init some basic properties about this frame (keep sample rate and # channels the same as the original reader for now) int samples_in_frame = Frame::GetSamplesPerFrame(number + timeline_frame_offset, target, reader->info.sample_rate, reader->info.channels); @@ -373,17 +373,17 @@ tr1::shared_ptr FrameMapper::GetOrCreateFrame(long int number) ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); // Create blank frame - new_frame = tr1::shared_ptr(new Frame(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels)); + new_frame = std::make_shared(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels); new_frame->SampleRate(reader->info.sample_rate); new_frame->ChannelsLayout(info.channel_layout); return new_frame; } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(ReaderClosed) { // Check final cache, and just return the frame (if it's available) - tr1::shared_ptr final_frame = final_cache.GetFrame(requested_frame); + std::shared_ptr final_frame = final_cache.GetFrame(requested_frame); if (final_frame) return final_frame; // Create a scoped lock, allowing only a single thread to run the following code at one time @@ -414,7 +414,7 @@ tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(Rea // Get the mapped frame MappedFrame mapped = GetMappedFrame(frame_number); - tr1::shared_ptr mapped_frame; + std::shared_ptr mapped_frame; // Get the mapped frame (keeping the sample rate and channels the same as the original... for the moment) mapped_frame = GetOrCreateFrame(mapped.Odd.Frame); @@ -444,23 +444,23 @@ tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(Rea } // Create a new frame - tr1::shared_ptr frame = tr1::shared_ptr(new Frame(frame_number, 1, 1, "#000000", samples_in_frame, channels_in_frame)); + std::shared_ptr frame = std::make_shared(frame_number, 1, 1, "#000000", samples_in_frame, channels_in_frame); frame->SampleRate(mapped_frame->SampleRate()); frame->ChannelsLayout(mapped_frame->ChannelsLayout()); // Copy the image from the odd field - tr1::shared_ptr odd_frame; + std::shared_ptr odd_frame; odd_frame = GetOrCreateFrame(mapped.Odd.Frame); if (odd_frame) - frame->AddImage(tr1::shared_ptr(new QImage(*odd_frame->GetImage())), true); + frame->AddImage(std::shared_ptr(new QImage(*odd_frame->GetImage())), true); if (mapped.Odd.Frame != mapped.Even.Frame) { // Add even lines (if different than the previous image) - tr1::shared_ptr even_frame; + std::shared_ptr even_frame; even_frame = GetOrCreateFrame(mapped.Even.Frame); if (even_frame) - frame->AddImage(tr1::shared_ptr(new QImage(*even_frame->GetImage())), false); + frame->AddImage(std::shared_ptr(new QImage(*even_frame->GetImage())), false); } // Resample audio on frame (if needed) @@ -524,7 +524,7 @@ tr1::shared_ptr FrameMapper::GetFrame(long int requested_frame) throw(Rea int number_to_copy = 0; // number of original samples on this frame - tr1::shared_ptr original_frame = GetOrCreateFrame(starting_frame); + std::shared_ptr original_frame = GetOrCreateFrame(starting_frame); int original_samples = original_frame->GetAudioSamplesCount(); // Loop through each channel @@ -763,7 +763,7 @@ void FrameMapper::SetTimelineFrameOffset(long int offset) } // Resample audio and map channels (if needed) -void FrameMapper::ResampleMappedAudio(tr1::shared_ptr frame, long int original_frame_number) +void FrameMapper::ResampleMappedAudio(std::shared_ptr frame, long int original_frame_number) { // Init audio buffers / variables int total_frame_samples = 0; diff --git a/src/ImageReader.cpp b/src/ImageReader.cpp index abf0583a..5e7e820d 100644 --- a/src/ImageReader.cpp +++ b/src/ImageReader.cpp @@ -55,7 +55,7 @@ void ImageReader::Open() throw(InvalidFile) try { // load image - image = tr1::shared_ptr(new Magick::Image(path)); + image = std::shared_ptr(new Magick::Image(path)); // Give image a transparent background color image->backgroundColor(Magick::Color("none")); @@ -113,14 +113,14 @@ void ImageReader::Close() } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr ImageReader::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr ImageReader::GetFrame(long int requested_frame) throw(ReaderClosed) { // Check for open reader (or throw exception) if (!is_open) throw ReaderClosed("The FFmpegReader is closed. Call Open() before calling this method.", path); // Create or get frame object - tr1::shared_ptr image_frame(new Frame(requested_frame, image->size().width(), image->size().height(), "#000000", 0, 2)); + std::shared_ptr image_frame(new Frame(requested_frame, image->size().width(), image->size().height(), "#000000", 0, 2)); // Add Image data to frame image_frame->AddMagickImage(image); diff --git a/src/ImageWriter.cpp b/src/ImageWriter.cpp index a2bccc6d..f8099c87 100644 --- a/src/ImageWriter.cpp +++ b/src/ImageWriter.cpp @@ -86,7 +86,7 @@ void ImageWriter::Open() throw(InvalidFile, InvalidCodec) } // Add a frame to the queue waiting to be encoded. -void ImageWriter::WriteFrame(tr1::shared_ptr frame) throw(WriterClosed) +void ImageWriter::WriteFrame(std::shared_ptr frame) throw(WriterClosed) { // Check for open reader (or throw exception) if (!is_open) @@ -94,7 +94,7 @@ void ImageWriter::WriteFrame(tr1::shared_ptr frame) throw(WriterClosed) // Copy and resize image - tr1::shared_ptr frame_image = frame->GetMagickImage(); + std::shared_ptr frame_image = frame->GetMagickImage(); frame_image->magick( info.vcodec ); frame_image->backgroundColor(Magick::Color("none")); frame_image->matte(true); @@ -128,7 +128,7 @@ void ImageWriter::WriteFrame(ReaderBase* reader, long int start, long int length for (long int number = start; number <= length; number++) { // Get the frame - tr1::shared_ptr f = reader->GetFrame(number); + std::shared_ptr f = reader->GetFrame(number); // Encode frame WriteFrame(f); diff --git a/src/Qt/AudioPlaybackThread.cpp b/src/Qt/AudioPlaybackThread.cpp index 2db116a4..55d40446 100644 --- a/src/Qt/AudioPlaybackThread.cpp +++ b/src/Qt/AudioPlaybackThread.cpp @@ -103,10 +103,10 @@ namespace openshot } // Get the current frame object (which is filling the buffer) - tr1::shared_ptr AudioPlaybackThread::getFrame() + std::shared_ptr AudioPlaybackThread::getFrame() { if (source) return source->getFrame(); - return tr1::shared_ptr(); + return std::shared_ptr(); } // Get the currently playing frame number diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index ad742437..98b3b7f1 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -135,7 +135,7 @@ namespace openshot } // Get the next displayed frame (based on speed and direction) - tr1::shared_ptr PlayerPrivate::getFrame() + std::shared_ptr PlayerPrivate::getFrame() { try { // Get the next frame (based on speed) @@ -162,7 +162,7 @@ namespace openshot } catch (const OutOfBoundsFrame & e) { // ... } - return tr1::shared_ptr(); + return std::shared_ptr(); } // Start video/audio playback diff --git a/src/Qt/VideoRenderer.cpp b/src/Qt/VideoRenderer.cpp index 4eec8140..1b5e47c6 100644 --- a/src/Qt/VideoRenderer.cpp +++ b/src/Qt/VideoRenderer.cpp @@ -45,7 +45,7 @@ void VideoRenderer::OverrideWidget(long long qwidget_address) } -void VideoRenderer::render(tr1::shared_ptr image) +void VideoRenderer::render(std::shared_ptr image) { if (image) emit present(*image); diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index a738c47c..66597f96 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -52,11 +52,11 @@ void QtImageReader::Open() throw(InvalidFile) if (!is_open) { // Attempt to open file - image = tr1::shared_ptr(new QImage()); + image = std::shared_ptr(new QImage()); bool success = image->load(QString::fromStdString(path)); // Set pixel format - image = tr1::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); + image = std::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); if (!success) // raise exception @@ -127,7 +127,7 @@ void QtImageReader::SetMaxSize(int width, int height) } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr QtImageReader::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr QtImageReader::GetFrame(long int requested_frame) throw(ReaderClosed) { // Check for open reader (or throw exception) if (!is_open) @@ -142,12 +142,12 @@ tr1::shared_ptr QtImageReader::GetFrame(long int requested_frame) throw(R // We need to resize the original image to a smaller image (for performance reasons) // Only do this once, to prevent tons of unneeded scaling operations - cached_image = tr1::shared_ptr(new QImage(image->scaled(max_width, max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); - cached_image = tr1::shared_ptr(new QImage(cached_image->convertToFormat(QImage::Format_RGBA8888))); + cached_image = std::shared_ptr(new QImage(image->scaled(max_width, max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + cached_image = std::shared_ptr(new QImage(cached_image->convertToFormat(QImage::Format_RGBA8888))); } // Create or get frame object - tr1::shared_ptr image_frame(new Frame(requested_frame, cached_image->width(), cached_image->height(), "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels)); + std::shared_ptr image_frame(new Frame(requested_frame, cached_image->width(), cached_image->height(), "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels)); // Add Image data to frame image_frame->AddImage(cached_image); @@ -158,7 +158,7 @@ tr1::shared_ptr QtImageReader::GetFrame(long int requested_frame) throw(R } else { // Use original image (higher quality but slower) // Create or get frame object - tr1::shared_ptr image_frame(new Frame(requested_frame, info.width, info.height, "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels)); + std::shared_ptr image_frame(new Frame(requested_frame, info.width, info.height, "#000000", Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels), info.channels)); // Add Image data to frame image_frame->AddImage(image); diff --git a/src/RendererBase.cpp b/src/RendererBase.cpp index 50fb1572..e21d984b 100644 --- a/src/RendererBase.cpp +++ b/src/RendererBase.cpp @@ -36,7 +36,7 @@ RendererBase::~RendererBase() { } -void RendererBase::paint(const std::tr1::shared_ptr & frame) +void RendererBase::paint(const std::shared_ptr & frame) { if (frame) this->render(frame->GetImage()); diff --git a/src/TextReader.cpp b/src/TextReader.cpp index 7791ddf7..a6a703aa 100644 --- a/src/TextReader.cpp +++ b/src/TextReader.cpp @@ -52,7 +52,7 @@ void TextReader::Open() if (!is_open) { // create image - image = tr1::shared_ptr(new Magick::Image(Magick::Geometry(width,height), Magick::Color(background_color))); + image = std::shared_ptr(new Magick::Image(Magick::Geometry(width,height), Magick::Color(background_color))); // Give image a transparent background color image->backgroundColor(Magick::Color("none")); @@ -143,15 +143,15 @@ void TextReader::Close() } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr TextReader::GetFrame(long int requested_frame) throw(ReaderClosed) +std::shared_ptr TextReader::GetFrame(long int requested_frame) throw(ReaderClosed) { if (image) { // Create or get frame object - tr1::shared_ptr image_frame(new Frame(requested_frame, image->size().width(), image->size().height(), "#000000", 0, 2)); + std::shared_ptr image_frame(new Frame(requested_frame, image->size().width(), image->size().height(), "#000000", 0, 2)); // Add Image data to frame - tr1::shared_ptr copy_image(new Magick::Image(*image.get())); + std::shared_ptr copy_image(new Magick::Image(*image.get())); copy_image->modifyImage(); // actually copy the image data to this object //TODO: Reimplement this with QImage //image_frame->AddImage(copy_image); @@ -160,7 +160,7 @@ tr1::shared_ptr TextReader::GetFrame(long int requested_frame) throw(Read return image_frame; } else { // return empty frame - tr1::shared_ptr image_frame(new Frame(1, 640, 480, "#000000", 0, 2)); + std::shared_ptr image_frame(new Frame(1, 640, 480, "#000000", 0, 2)); // return frame object return image_frame; diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 59cc0f45..ef928a31 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -170,7 +170,7 @@ double Timeline::calculate_time(long int number, Fraction rate) } // Apply effects to the source frame (if any) -tr1::shared_ptr Timeline::apply_effects(tr1::shared_ptr frame, long int timeline_frame_number, int layer) +std::shared_ptr Timeline::apply_effects(std::shared_ptr frame, long int timeline_frame_number, int layer) { // Debug output ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects", "frame->number", frame->number, "timeline_frame_number", timeline_frame_number, "layer", layer, "", -1, "", -1, "", -1); @@ -212,9 +212,9 @@ tr1::shared_ptr Timeline::apply_effects(tr1::shared_ptr frame, lon } // Get or generate a blank frame -tr1::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, long int number) +std::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, long int number) { - tr1::shared_ptr new_frame; + std::shared_ptr new_frame; // Init some basic properties about this frame int samples_in_frame = Frame::GetSamplesPerFrame(number, info.fps, info.sample_rate, info.channels); @@ -227,7 +227,7 @@ tr1::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, long int number) clip->SetMaxSize(info.width, info.height); // Attempt to get a frame (but this could fail if a reader has just been closed) - new_frame = tr1::shared_ptr(clip->GetFrame(number)); + new_frame = std::shared_ptr(clip->GetFrame(number)); // Return real frame return new_frame; @@ -244,17 +244,17 @@ tr1::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, long int number) ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); // Create blank frame - new_frame = tr1::shared_ptr(new Frame(number, max_width, max_height, "#000000", samples_in_frame, info.channels)); + new_frame = std::make_shared(number, max_width, max_height, "#000000", samples_in_frame, info.channels); new_frame->SampleRate(info.sample_rate); new_frame->ChannelsLayout(info.channel_layout); return new_frame; } // Process a new layer of video or audio -void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, long int clip_frame_number, long int timeline_frame_number, bool is_top_clip) +void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, long int clip_frame_number, long int timeline_frame_number, bool is_top_clip) { // Get the clip's frame & image - tr1::shared_ptr source_frame = GetOrCreateFrame(source_clip, clip_frame_number); + std::shared_ptr source_frame = GetOrCreateFrame(source_clip, clip_frame_number); // No frame found... so bail if (!source_frame) @@ -276,8 +276,8 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo int alpha = source_clip->wave_color.alpha.GetInt(clip_frame_number); // Generate Waveform Dynamically (the size of the timeline) - tr1::shared_ptr source_image = source_frame->GetWaveform(max_width, max_height, red, green, blue, alpha); - source_frame->AddImage(tr1::shared_ptr(source_image)); + std::shared_ptr source_image = source_frame->GetWaveform(max_width, max_height, red, green, blue, alpha); + source_frame->AddImage(std::shared_ptr(source_image)); } /* Apply effects to the source frame (if any). If multiple clips are overlapping, only process the @@ -286,7 +286,7 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo source_frame = apply_effects(source_frame, timeline_frame_number, source_clip->Layer()); // Declare an image to hold the source frame's image - tr1::shared_ptr source_image; + std::shared_ptr source_image; /* COPY AUDIO - with correct volume */ if (source_clip->Reader()->info.has_audio) { @@ -380,7 +380,7 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo { case (SCALE_FIT): // keep aspect ratio - source_image = tr1::shared_ptr(new QImage(source_image->scaled(max_width, max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + source_image = std::shared_ptr(new QImage(source_image->scaled(max_width, max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); source_width = source_image->width(); source_height = source_image->height(); @@ -390,7 +390,7 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo case (SCALE_STRETCH): // ignore aspect ratio - source_image = tr1::shared_ptr(new QImage(source_image->scaled(max_width, max_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); + source_image = std::shared_ptr(new QImage(source_image->scaled(max_width, max_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); source_width = source_image->width(); source_height = source_image->height(); @@ -404,9 +404,9 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo // respect aspect ratio if (width_size.width() >= max_width && width_size.height() >= max_height) - source_image = tr1::shared_ptr(new QImage(source_image->scaled(width_size.width(), width_size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); + source_image = std::shared_ptr(new QImage(source_image->scaled(width_size.width(), width_size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); else - source_image = tr1::shared_ptr(new QImage(source_image->scaled(height_size.width(), height_size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); // height is larger, so resize to it + source_image = std::shared_ptr(new QImage(source_image->scaled(height_size.width(), height_size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); // height is larger, so resize to it source_width = source_image->width(); source_height = source_image->height(); @@ -509,7 +509,7 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, lo ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Prepare)", "source_frame->number", source_frame->number, "offset_x", offset_x, "offset_y", offset_y, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "transformed", transformed, "", -1); /* COMPOSITE SOURCE IMAGE (LAYER) ONTO FINAL IMAGE */ - tr1::shared_ptr new_image = new_frame->GetImage(); + std::shared_ptr new_image = new_frame->GetImage(); // Load timeline's new frame image into a QPainter QPainter painter(new_image.get()); @@ -634,14 +634,14 @@ bool Timeline::isEqual(double a, double b) } // Get an openshot::Frame object for a specific frame number of this reader. -tr1::shared_ptr Timeline::GetFrame(long int requested_frame) throw(ReaderClosed, OutOfBoundsFrame) +std::shared_ptr Timeline::GetFrame(long int requested_frame) throw(ReaderClosed, OutOfBoundsFrame) { // Adjust out of bounds frame number if (requested_frame < 1) requested_frame = 1; // Check cache - tr1::shared_ptr frame = final_cache->GetFrame(requested_frame); + std::shared_ptr frame = final_cache->GetFrame(requested_frame); if (frame) { // Debug output ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Cached frame found)", "requested_frame", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); @@ -719,7 +719,7 @@ tr1::shared_ptr Timeline::GetFrame(long int requested_frame) throw(Reader int samples_in_frame = Frame::GetSamplesPerFrame(frame_number, info.fps, info.sample_rate, info.channels); // Create blank frame (which will become the requested frame) - tr1::shared_ptr new_frame(tr1::shared_ptr(new Frame(frame_number, max_width, max_height, "#000000", samples_in_frame, info.channels))); + std::shared_ptr new_frame(std::make_shared(frame_number, max_width, max_height, "#000000", samples_in_frame, info.channels)); new_frame->AddAudioSilence(samples_in_frame); new_frame->SampleRate(info.sample_rate); new_frame->ChannelsLayout(info.channel_layout); diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index de0bfd3d..8a1b6586 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -40,7 +40,6 @@ %include /* Include shared pointer code */ -#define SWIG_SHARED_PTR_SUBNAMESPACE tr1 %include /* Mark these classes as shared_ptr classes */ diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index f704287c..78cf1337 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -40,7 +40,6 @@ %include namespace std { -namespace tr1 { template class shared_ptr { public: @@ -50,11 +49,11 @@ namespace tr1 /* Mark these classes as shared_ptr classes */ #ifdef USE_IMAGEMAGICK - %template(SPtrImage) std::tr1::shared_ptr; + %template(SPtrImage) std::shared_ptr; #endif -%template(SPtrAudioBuffer) std::tr1::shared_ptr; -%template(SPtrOpenFrame) std::tr1::shared_ptr; -%template(SPtrFrame) std::tr1::shared_ptr; +%template(SPtrAudioBuffer) std::shared_ptr; +%template(SPtrOpenFrame) std::shared_ptr; +%template(SPtrFrame) std::shared_ptr; %{ diff --git a/src/effects/Blur.cpp b/src/effects/Blur.cpp index f47cf303..b806307b 100644 --- a/src/effects/Blur.cpp +++ b/src/effects/Blur.cpp @@ -60,10 +60,10 @@ void Blur::init_effect_details() // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Blur::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Blur::GetFrame(std::shared_ptr frame, long int frame_number) { // Get the frame's image - tr1::shared_ptr frame_image = frame->GetImage(); + std::shared_ptr frame_image = frame->GetImage(); // Get the current blur radius int horizontal_radius_value = horizontal_radius.GetValue(frame_number); diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index daf9a09a..3f119d08 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -71,10 +71,10 @@ int Brightness::constrain(int color_value) // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Brightness::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Brightness::GetFrame(std::shared_ptr frame, long int frame_number) { // Get the frame's image - tr1::shared_ptr frame_image = frame->GetImage(); + std::shared_ptr frame_image = frame->GetImage(); // Get keyframe values for this frame float brightness_value = brightness.GetValue(frame_number); diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index ae59dfc4..176524b1 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -63,7 +63,7 @@ void ChromaKey::init_effect_details() // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr ChromaKey::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr ChromaKey::GetFrame(std::shared_ptr frame, long int frame_number) { // Determine the current HSL (Hue, Saturation, Lightness) for the Chrome int threshold = fuzz.GetInt(frame_number); @@ -72,7 +72,7 @@ tr1::shared_ptr ChromaKey::GetFrame(tr1::shared_ptr frame, long in long mask_B = color.blue.GetInt(frame_number); // Get source image's pixels - tr1::shared_ptr image = frame->GetImage(); + std::shared_ptr image = frame->GetImage(); unsigned char *pixels = (unsigned char *) image->bits(); // Loop through pixels diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index c78b5b3f..08b180fa 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -59,14 +59,14 @@ void Deinterlace::init_effect_details() // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Deinterlace::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Deinterlace::GetFrame(std::shared_ptr frame, long int frame_number) { // Get original size of frame's image int original_width = frame->GetImage()->width(); int original_height = frame->GetImage()->height(); // Get the frame's image - tr1::shared_ptr image = frame->GetImage(); + std::shared_ptr image = frame->GetImage(); const unsigned char* pixels = image->bits(); // Create a smaller, new image @@ -83,7 +83,7 @@ tr1::shared_ptr Deinterlace::GetFrame(tr1::shared_ptr frame, long } // Resize deinterlaced image back to original size, and update frame's image - image = tr1::shared_ptr(new QImage(deinterlaced_image.scaled(original_width, original_height, Qt::IgnoreAspectRatio, Qt::FastTransformation))); + image = std::shared_ptr(new QImage(deinterlaced_image.scaled(original_width, original_height, Qt::IgnoreAspectRatio, Qt::FastTransformation))); // Update image on frame frame->AddImage(image); diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index fb7b98ec..de6757d8 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -70,7 +70,7 @@ int Mask::constrain(int color_value) } // Get grayscale mask image -void Mask::set_grayscale_mask(tr1::shared_ptr mask_frame_image, int width, int height, float brightness, float contrast) +void Mask::set_grayscale_mask(std::shared_ptr mask_frame_image, int width, int height, float brightness, float contrast) { // Get pixels for mask image unsigned char *pixels = (unsigned char *) mask_frame_image->bits(); @@ -107,10 +107,10 @@ void Mask::set_grayscale_mask(tr1::shared_ptr mask_frame_image, int widt // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Mask::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Mask::GetFrame(std::shared_ptr frame, long int frame_number) { // Get the mask image (from the mask reader) - tr1::shared_ptr frame_image = frame->GetImage(); + std::shared_ptr frame_image = frame->GetImage(); // Check if mask reader is open if (reader && !reader->IsOpen()) @@ -127,17 +127,17 @@ tr1::shared_ptr Mask::GetFrame(tr1::shared_ptr frame, long int fra #pragma omp critical (open_mask_reader) { // Only get mask if needed - tr1::shared_ptr mask_without_sizing = tr1::shared_ptr(new QImage(*reader->GetFrame(frame_number)->GetImage())); + std::shared_ptr mask_without_sizing = std::shared_ptr(new QImage(*reader->GetFrame(frame_number)->GetImage())); // Resize mask image to match frame size - original_mask = tr1::shared_ptr(new QImage( + original_mask = std::shared_ptr(new QImage( mask_without_sizing->scaled(frame_image->width(), frame_image->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); } } // Convert mask to grayscale and resize to frame size - tr1::shared_ptr mask = tr1::shared_ptr(new QImage(*original_mask)); + std::shared_ptr mask = std::shared_ptr(new QImage(*original_mask)); set_grayscale_mask(mask, frame_image->width(), frame_image->height(), brightness.GetValue(frame_number), contrast.GetValue(frame_number)); // Get pixels for frame image diff --git a/src/effects/Negate.cpp b/src/effects/Negate.cpp index fa3eae35..bf6ab2d6 100644 --- a/src/effects/Negate.cpp +++ b/src/effects/Negate.cpp @@ -45,7 +45,7 @@ Negate::Negate() // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Negate::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Negate::GetFrame(std::shared_ptr frame, long int frame_number) { // Make a negative of the images pixels frame->GetImage()->invertPixels(); diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index 03c487fa..1c4ac90a 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -70,10 +70,10 @@ int Saturation::constrain(int color_value) // This method is required for all derived classes of EffectBase, and returns a // modified openshot::Frame object -tr1::shared_ptr Saturation::GetFrame(tr1::shared_ptr frame, long int frame_number) +std::shared_ptr Saturation::GetFrame(std::shared_ptr frame, long int frame_number) { // Get the frame's image - tr1::shared_ptr frame_image = frame->GetImage(); + std::shared_ptr frame_image = frame->GetImage(); if (!frame_image) return frame; diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index 7f7e5e50..71b7447e 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -27,47 +27,43 @@ #include #include -#include +#include #include "../../include/OpenShot.h" +#include "../../include/CrashHandler.h" using namespace openshot; -using namespace tr1; int main(int argc, char* argv[]) { - FFmpegReader rTest("/home/jonathan/Videos/sintel_trailer-720p.mp4"); - rTest.Open(); - /* WRITER ---------------- */ - FFmpegWriter w("/home/jonathan/output%05d.jpg"); + // Create and open reader + FFmpegReader r("/home/jonathan/sintel-120fps-crash.mp4"); + r.Open(); - // Set options - w.SetVideoOptions(true, "mjpeg", Fraction(24, 1), 1280, 720, Fraction(1, 1), false, false, 3000000); + // Enable debug logging + ZmqLogger::Instance()->Enable(false); + ZmqLogger::Instance()->Path("/home/jonathan/.openshot_qt/libopenshot2.log"); + CrashHandler::Instance(); -// w.SetOption(VIDEO_STREAM, "qmin", "2" ); -// w.SetOption(VIDEO_STREAM, "qmax", "30" ); -// w.SetOption(VIDEO_STREAM, "crf", "10" ); -// w.SetOption(VIDEO_STREAM, "rc_min_rate", "2000000" ); -// w.SetOption(VIDEO_STREAM, "rc_max_rate", "4000000" ); -// w.SetOption(VIDEO_STREAM, "max_b_frames", "0" ); -// w.SetOption(VIDEO_STREAM, "b_frames", "0" ); + // Loop a few times + for (int attempt = 1; attempt < 10; attempt++) { + cout << "** Attempt " << attempt << " **" << endl; - // Open writer - w.Open(); + // Read every frame in reader as fast as possible + for (int frame_number = 1; frame_number < r.info.video_length; frame_number++) { + // Get frame object + std::shared_ptr f = r.GetFrame(frame_number); - // Prepare Streams - w.PrepareStreams(); + // Print frame numbers + cout << frame_number << " [" << f->number << "], " << flush; + if (frame_number % 10 == 0) + cout << endl; + } + } + cout << "Completed successfully!" << endl; - - // Write header - w.WriteHeader(); - - // Write some frames - w.WriteFrame(&rTest, 500, 505); - - // Close writer & reader - w.Close(); - rTest.Close(); + // Close reader + r.Close(); return 0; } \ No newline at end of file diff --git a/src/examples/ExampleBlackmagic.cpp b/src/examples/ExampleBlackmagic.cpp index 232df182..0af6c9b4 100644 --- a/src/examples/ExampleBlackmagic.cpp +++ b/src/examples/ExampleBlackmagic.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "../../include/OpenShot.h" #include #include @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) int x = 0; while (true) { - tr1::shared_ptr f = t.GetFrame(x); + std::shared_ptr f = t.GetFrame(x); if (f) { if (x != 0 && x % 30 == 0) @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) // Image Reader // ImageReader r1("/home/jonathan/Pictures/Screenshot from 2013-02-10 15:06:38.png"); // r1.Open(); -// tr1::shared_ptr f1 = r1.GetFrame(1); +// std::shared_ptr f1 = r1.GetFrame(1); // r1.Close(); // f1->TransparentColors("#8fa09a", 20.0); // f1->Display(); @@ -191,7 +191,7 @@ int main(int argc, char *argv[]) // ImageReader r2("/home/jonathan/Pictures/trees.jpg"); // r2.Open(); -// tr1::shared_ptr f2 = r2.GetFrame(1); +// std::shared_ptr f2 = r2.GetFrame(1); // r2.Close(); // DecklinkReader dr(1, 11, 0, 2, 16); @@ -207,7 +207,7 @@ int main(int argc, char *argv[]) // if (x % 30 == 0) // cout << "30 frames..." << endl; // -// tr1::shared_ptr f = dr.GetFrame(0); +// std::shared_ptr f = dr.GetFrame(0); // if (f) // { // //f->Display(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 29fbe452..431987b4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,7 +31,7 @@ IF (WIN32) STRING(REPLACE "/" "\\\\" TEST_MEDIA_PATH "${openshot_SOURCE_DIR}/src/examples/") add_definitions( -DIGNORE_JUCE_HYPOT=1 -DTEST_MEDIA_PATH="${TEST_MEDIA_PATH}" ) - SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath -std=c++0x") + SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -include cmath") ENDIF(WIN32) ################### UNITTEST++ ##################### diff --git a/tests/Cache_Tests.cpp b/tests/Cache_Tests.cpp index 419d4c55..8cf64c40 100644 --- a/tests/Cache_Tests.cpp +++ b/tests/Cache_Tests.cpp @@ -41,7 +41,7 @@ TEST(Cache_Default_Constructor) for (int i = 0; i < 50; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; c.Add(f); } @@ -59,7 +59,7 @@ TEST(Cache_Max_Bytes_Constructor) for (int i = 30; i > 0; i--) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame(i, 320, 240, "#000000")); + std::shared_ptr f(new Frame(i, 320, 240, "#000000")); f->AddColor(320, 240, "#000000"); c.Add(f); } @@ -71,7 +71,7 @@ TEST(Cache_Max_Bytes_Constructor) for (int i = 10; i > 0; i--) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame(i, 320, 240, "#000000")); + std::shared_ptr f(new Frame(i, 320, 240, "#000000")); f->AddColor(320, 240, "#000000"); c.Add(f); } @@ -98,7 +98,7 @@ TEST(Cache_Clear) for (int i = 0; i < 10; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; c.Add(f); } @@ -122,7 +122,7 @@ TEST(Cache_Add_Duplicate_Frames) for (int i = 0; i < 10; i++) { // Add blank frame to the cache (each frame is #1) - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); c.Add(f); } @@ -139,7 +139,7 @@ TEST(Cache_Check_If_Frame_Exists) for (int i = 1; i < 6; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; c.Add(f); } @@ -165,9 +165,9 @@ TEST(Cache_GetFrame) Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(tr1::shared_ptr(red)); - c.Add(tr1::shared_ptr(blue)); - c.Add(tr1::shared_ptr(green)); + c.Add(std::shared_ptr(red)); + c.Add(std::shared_ptr(blue)); + c.Add(std::shared_ptr(green)); // Get frames CHECK_EQUAL(true, c.GetFrame(0) == NULL); @@ -190,9 +190,9 @@ TEST(Cache_GetSmallest) Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(tr1::shared_ptr(red)); - c.Add(tr1::shared_ptr(blue)); - c.Add(tr1::shared_ptr(green)); + c.Add(std::shared_ptr(red)); + c.Add(std::shared_ptr(blue)); + c.Add(std::shared_ptr(green)); // Check if frame 1 is the front CHECK_EQUAL(1, c.GetSmallestFrame()->number); @@ -218,9 +218,9 @@ TEST(Cache_Remove) Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(tr1::shared_ptr(red)); - c.Add(tr1::shared_ptr(blue)); - c.Add(tr1::shared_ptr(green)); + c.Add(std::shared_ptr(red)); + c.Add(std::shared_ptr(blue)); + c.Add(std::shared_ptr(green)); // Check if count is 3 CHECK_EQUAL(3, c.Count()); @@ -256,7 +256,7 @@ TEST(Cache_Set_Max_Bytes) for (int i = 0; i < 20; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; c.Add(f); } @@ -281,7 +281,7 @@ TEST(Cache_Multiple_Remove) for (int i = 1; i <= 20; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; // Add some picture data f->AddColor(1280, 720, "Blue"); @@ -309,7 +309,7 @@ TEST(CacheDisk_Set_Max_Bytes) for (int i = 0; i < 20; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; // Add some picture data f->AddColor(1280, 720, "Blue"); @@ -329,7 +329,7 @@ TEST(CacheDisk_Set_Max_Bytes) CHECK_EQUAL(4 * 1024, c.GetMaxBytes()); // Read frames from disk cache - tr1::shared_ptr f = c.GetFrame(5); + std::shared_ptr f = c.GetFrame(5); CHECK_EQUAL(320, f->GetWidth()); CHECK_EQUAL(180, f->GetHeight()); CHECK_EQUAL(2, f->GetAudioChannelsCount()); @@ -360,7 +360,7 @@ TEST(CacheDisk_Multiple_Remove) for (int i = 1; i <= 20; i++) { // Add blank frame to the cache - tr1::shared_ptr f(new Frame()); + std::shared_ptr f(new Frame()); f->number = i; // Add some picture data f->AddColor(1280, 720, "Blue"); @@ -389,31 +389,31 @@ TEST(CacheDisk_JSON) CacheDisk c("", "PPM", 1.0, 0.25); // Add some frames (out of order) - tr1::shared_ptr f3(new Frame(3, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f3(new Frame(3, 1280, 720, "Blue", 500, 2)); c.Add(f3); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("1", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f1(new Frame(1, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f1(new Frame(1, 1280, 720, "Blue", 500, 2)); c.Add(f1); CHECK_EQUAL(2, c.JsonValue()["ranges"].size()); CHECK_EQUAL("2", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f2(new Frame(2, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f2(new Frame(2, 1280, 720, "Blue", 500, 2)); c.Add(f2); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("3", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f5(new Frame(5, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f5(new Frame(5, 1280, 720, "Blue", 500, 2)); c.Add(f5); CHECK_EQUAL(2, c.JsonValue()["ranges"].size()); CHECK_EQUAL("4", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f4(new Frame(4, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f4(new Frame(4, 1280, 720, "Blue", 500, 2)); c.Add(f4); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("5", c.JsonValue()["version"].asString()); @@ -429,31 +429,31 @@ TEST(CacheMemory_JSON) CacheMemory c; // Add some frames (out of order) - tr1::shared_ptr f3(new Frame(3, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f3(new Frame(3, 1280, 720, "Blue", 500, 2)); c.Add(f3); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("1", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f1(new Frame(1, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f1(new Frame(1, 1280, 720, "Blue", 500, 2)); c.Add(f1); CHECK_EQUAL(2, c.JsonValue()["ranges"].size()); CHECK_EQUAL("2", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f2(new Frame(2, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f2(new Frame(2, 1280, 720, "Blue", 500, 2)); c.Add(f2); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("3", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f5(new Frame(5, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f5(new Frame(5, 1280, 720, "Blue", 500, 2)); c.Add(f5); CHECK_EQUAL(2, c.JsonValue()["ranges"].size()); CHECK_EQUAL("4", c.JsonValue()["version"].asString()); // Add some frames (out of order) - tr1::shared_ptr f4(new Frame(4, 1280, 720, "Blue", 500, 2)); + std::shared_ptr f4(new Frame(4, 1280, 720, "Blue", 500, 2)); c.Add(f4); CHECK_EQUAL(1, c.JsonValue()["ranges"].size()); CHECK_EQUAL("5", c.JsonValue()["version"].asString()); diff --git a/tests/Clip_Tests.cpp b/tests/Clip_Tests.cpp index 3f4c65c3..1134e8ab 100644 --- a/tests/Clip_Tests.cpp +++ b/tests/Clip_Tests.cpp @@ -214,7 +214,7 @@ TEST(Clip_Effects) c10.AddEffect(&n); // Get frame 1 - tr1::shared_ptr f = c10.GetFrame(500); + std::shared_ptr f = c10.GetFrame(500); // Get the image data const unsigned char* pixels = f->GetPixels(10); diff --git a/tests/FFmpegReader_Tests.cpp b/tests/FFmpegReader_Tests.cpp index e6b170eb..54017e83 100644 --- a/tests/FFmpegReader_Tests.cpp +++ b/tests/FFmpegReader_Tests.cpp @@ -58,7 +58,7 @@ TEST(FFmpegReader_Check_Audio_File) r.Open(); // Get frame 1 - tr1::shared_ptr f = r.GetFrame(1); + std::shared_ptr f = r.GetFrame(1); // Get the number of channels and samples float *samples = f->GetAudioSamples(0); @@ -88,7 +88,7 @@ TEST(FFmpegReader_Check_Video_File) r.Open(); // Get frame 1 - tr1::shared_ptr f = r.GetFrame(1); + std::shared_ptr f = r.GetFrame(1); // Get the image data const unsigned char* pixels = f->GetPixels(10); @@ -126,7 +126,7 @@ TEST(FFmpegReader_Seek) r.Open(); // Get frame - tr1::shared_ptr f = r.GetFrame(1); + std::shared_ptr f = r.GetFrame(1); CHECK_EQUAL(1, f->number); // Get frame @@ -183,7 +183,7 @@ TEST(FFmpegReader_Multiple_Open_and_Close) r.Open(); // Get frame that requires a seek - tr1::shared_ptr f = r.GetFrame(1200); + std::shared_ptr f = r.GetFrame(1200); CHECK_EQUAL(1200, f->number); // Close and Re-open the reader diff --git a/tests/FFmpegWriter_Tests.cpp b/tests/FFmpegWriter_Tests.cpp index 99cee7b0..73357f21 100644 --- a/tests/FFmpegWriter_Tests.cpp +++ b/tests/FFmpegWriter_Tests.cpp @@ -66,7 +66,7 @@ TEST(FFmpegWriter_Test_Webm) CHECK_EQUAL(1, r1.info.fps.den); // Get a specific frame - tr1::shared_ptr f = r1.GetFrame(8); + std::shared_ptr f = r1.GetFrame(8); // Get the image data for row 500 const unsigned char* pixels = f->GetPixels(500); diff --git a/tests/ImageWriter_Tests.cpp b/tests/ImageWriter_Tests.cpp index fdf4429b..107ee399 100644 --- a/tests/ImageWriter_Tests.cpp +++ b/tests/ImageWriter_Tests.cpp @@ -66,7 +66,7 @@ TEST(ImageWriter_Test_Gif) CHECK_EQUAL(r.info.height, r1.info.height); // Get a specific frame - tr1::shared_ptr f = r1.GetFrame(8); + std::shared_ptr f = r1.GetFrame(8); // Get the image data for row 500 const unsigned char* pixels = f->GetPixels(500); diff --git a/tests/ReaderBase_Tests.cpp b/tests/ReaderBase_Tests.cpp index 6c4b31d5..9277eadf 100644 --- a/tests/ReaderBase_Tests.cpp +++ b/tests/ReaderBase_Tests.cpp @@ -41,7 +41,7 @@ TEST(ReaderBase_Derived_Class) public: TestReader() { }; CacheBase* GetCache() { return NULL; }; - tr1::shared_ptr GetFrame(long int number) { tr1::shared_ptr f(new Frame()); return f; } + std::shared_ptr GetFrame(long int number) { std::shared_ptr f(new Frame()); return f; } void Close() { }; void Open() { }; string Json() { }; diff --git a/tests/Timeline_Tests.cpp b/tests/Timeline_Tests.cpp index 18181ede..70acd179 100644 --- a/tests/Timeline_Tests.cpp +++ b/tests/Timeline_Tests.cpp @@ -112,7 +112,7 @@ TEST(Timeline_Check_Two_Track_Video) t.Open(); // Get frame - tr1::shared_ptr f = t.GetFrame(1); + std::shared_ptr f = t.GetFrame(1); // Get the image data int pixel_row = 200; @@ -435,7 +435,7 @@ TEST(Timeline_Effect_Blur) t.Open(); // Get frame - tr1::shared_ptr f = t.GetFrame(1); + std::shared_ptr f = t.GetFrame(1); // Close reader t.Close();