From 6336f30ee3ea24ccc8fb85c26e8a3d2135cb4545 Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Wed, 22 Apr 2020 02:02:55 -0400 Subject: [PATCH] Various: Remove unused variables (#467) Several data members and local variables were flagged by static analysis tools as never being used anywhere in the code. --- include/AudioBufferSource.h | 1 - include/AudioReaderSource.h | 1 - include/Clip.h | 1 - include/FFmpegWriter.h | 1 - include/ImageWriter.h | 1 - src/AudioBufferSource.cpp | 2 +- src/AudioReaderSource.cpp | 2 +- src/CacheDisk.cpp | 2 +- src/Clip.cpp | 12 +++--------- src/FFmpegReader.cpp | 5 +---- src/FFmpegWriter.cpp | 3 +-- src/ImageWriter.cpp | 2 +- src/Timeline.cpp | 3 --- src/{bindings/ruby/test.rb => examples/Example.rb} | 0 14 files changed, 9 insertions(+), 27 deletions(-) rename src/{bindings/ruby/test.rb => examples/Example.rb} (100%) diff --git a/include/AudioBufferSource.h b/include/AudioBufferSource.h index 3a17feb3c..ae5ce014f 100644 --- a/include/AudioBufferSource.h +++ b/include/AudioBufferSource.h @@ -48,7 +48,6 @@ namespace openshot { private: int position; - int start; bool repeat; juce::AudioSampleBuffer *buffer; diff --git a/include/AudioReaderSource.h b/include/AudioReaderSource.h index c4e2d2480..d049e1b37 100644 --- a/include/AudioReaderSource.h +++ b/include/AudioReaderSource.h @@ -54,7 +54,6 @@ namespace openshot int speed; /// The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...) ReaderBase *reader; /// The reader to pull samples from - int64_t original_frame_number; /// The current frame to read from int64_t frame_number; /// The current frame number std::shared_ptr frame; /// The current frame object that is being read int64_t frame_position; /// The position of the current frame's buffer diff --git a/include/Clip.h b/include/Clip.h index 1f4cd3859..e153acb4d 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -103,7 +103,6 @@ namespace openshot { // Audio resampler (if time mapping) openshot::AudioResampler *resampler; - juce::AudioSampleBuffer *audio_cache; // File Reader object openshot::ReaderBase* reader; diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index 1dfb21a93..37fa22dce 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -167,7 +167,6 @@ namespace openshot { AVCodecContext *video_codec; AVCodecContext *audio_codec; SwsContext *img_convert_ctx; - double audio_pts, video_pts; int16_t *samples; uint8_t *audio_outbuf; uint8_t *audio_encoder_buffer; diff --git a/include/ImageWriter.h b/include/ImageWriter.h index 87e8a9a95..e483cb10f 100644 --- a/include/ImageWriter.h +++ b/include/ImageWriter.h @@ -88,7 +88,6 @@ namespace openshot private: std::string path; int cache_size; - bool is_writing; bool is_open; int64_t write_video_count; std::vector frames; diff --git a/src/AudioBufferSource.cpp b/src/AudioBufferSource.cpp index 2f3d14ca3..69e5713ad 100644 --- a/src/AudioBufferSource.cpp +++ b/src/AudioBufferSource.cpp @@ -35,7 +35,7 @@ using namespace openshot; // Default constructor AudioBufferSource::AudioBufferSource(juce::AudioSampleBuffer *audio_buffer) - : position(0), start(0), repeat(false), buffer(audio_buffer) + : position(0), repeat(false), buffer(audio_buffer) { } // Destructor diff --git a/src/AudioReaderSource.cpp b/src/AudioReaderSource.cpp index c96d0bcc3..999d109d2 100644 --- a/src/AudioReaderSource.cpp +++ b/src/AudioReaderSource.cpp @@ -35,7 +35,7 @@ using namespace openshot; // Constructor that reads samples from a reader AudioReaderSource::AudioReaderSource(ReaderBase *audio_reader, int64_t starting_frame_number, int buffer_size) - : reader(audio_reader), frame_number(starting_frame_number), original_frame_number(starting_frame_number), + : reader(audio_reader), frame_number(starting_frame_number), size(buffer_size), position(0), frame_position(0), estimated_frame(0), speed(1) { // Initialize an audio buffer (based on reader) diff --git a/src/CacheDisk.cpp b/src/CacheDisk.cpp index 9f67ce994..bb2e12c42 100644 --- a/src/CacheDisk.cpp +++ b/src/CacheDisk.cpp @@ -228,7 +228,7 @@ std::shared_ptr CacheDisk::GetFrame(int64_t frame_number) // Load image file std::shared_ptr image = std::shared_ptr(new QImage()); - bool success = image->load(QString::fromStdString(frame_path.toStdString())); + image->load(frame_path); // Set pixel formatimage-> image = std::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); diff --git a/src/Clip.cpp b/src/Clip.cpp index 1968bb3b1..39aad35dd 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -132,14 +132,14 @@ void Clip::init_reader_rotation() { } // Default Constructor for a clip -Clip::Clip() : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL) +Clip::Clip() : resampler(NULL), reader(NULL), allocated_reader(NULL) { // Init all default settings init_settings(); } // Constructor with reader -Clip::Clip(ReaderBase* new_reader) : resampler(NULL), audio_cache(NULL), reader(new_reader), allocated_reader(NULL) +Clip::Clip(ReaderBase* new_reader) : resampler(NULL), reader(new_reader), allocated_reader(NULL) { // Init all default settings init_settings(); @@ -153,7 +153,7 @@ Clip::Clip(ReaderBase* new_reader) : resampler(NULL), audio_cache(NULL), reader( } // Constructor with filepath -Clip::Clip(std::string path) : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL) +Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(NULL) { // Init all default settings init_settings(); @@ -422,7 +422,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr frame, int64_t frame_num int delta = int(round(time.GetDelta(frame_number))); // Init audio vars - int sample_rate = reader->info.sample_rate; int channels = reader->info.channels; int number_of_samples = GetOrCreateFrame(new_frame_number)->GetAudioSamplesCount(); @@ -433,7 +432,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr frame, int64_t frame_num // SLOWING DOWN AUDIO // Resample data, and return new buffer pointer juce::AudioSampleBuffer *resampled_buffer = NULL; - int resampled_buffer_size = 0; // SLOW DOWN audio (split audio) samples = new juce::AudioSampleBuffer(channels, number_of_samples); @@ -455,9 +453,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr frame, int64_t frame_num // Resample the data (since it's the 1st slice) resampled_buffer = resampler->GetResampledBuffer(); - // Get the length of the resampled buffer (if one exists) - resampled_buffer_size = resampled_buffer->getNumSamples(); - // Just take the samples we need for the requested frame int start = (number_of_samples * (time.GetRepeatFraction(frame_number).num - 1)); if (start > 0) @@ -567,7 +562,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr frame, int64_t frame_num // Resample data, and return new buffer pointer juce::AudioSampleBuffer *buffer = resampler->GetResampledBuffer(); - int resampled_buffer_size = buffer->getNumSamples(); // Add the newly resized audio samples to the current frame for (int channel = 0; channel < channels; channel++) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 550648a18..c8ce141fe 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -1426,8 +1426,6 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr int packet_samples = 0; int data_size = 0; - // re-initialize buffer size (it gets changed in the avcodec_decode_audio2 method call) - int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + MY_INPUT_BUFFER_PADDING_SIZE; #pragma omp critical (ProcessAudioPacket) { #if IS_FFMPEG_3_2 @@ -1465,7 +1463,6 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr if (frame_finished) { // determine how many samples were decoded - int planar = av_sample_fmt_is_planar((AVSampleFormat) AV_GET_CODEC_PIXEL_FORMAT(aStream, aCodecCtx)); int plane_size = -1; data_size = av_samples_get_buffer_size(&plane_size, AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels, @@ -1554,7 +1551,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr 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 = SWR_INIT(avr); + SWR_INIT(avr); // Convert audio samples nb_samples = SWR_CONVERT(avr, // audio resample context diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 2b97ba915..ce8f65573 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -84,7 +84,7 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int6 #endif // HAVE_HW_ACCEL FFmpegWriter::FFmpegWriter(std::string path) : - path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), audio_pts(0), video_pts(0), samples(NULL), + path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), samples(NULL), audio_outbuf(NULL), audio_outbuf_size(0), audio_input_frame_size(0), audio_input_position(0), initial_audio_input_frame_size(0), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32), rescaler_position(0), video_codec(NULL), audio_codec(NULL), is_writing(false), write_video_count(0), write_audio_count(0), @@ -2030,7 +2030,6 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra int error_code = 0; #if IS_FFMPEG_3_2 // Write video packet (latest version of FFmpeg) - int frameFinished = 0; int ret; #if HAVE_HW_ACCEL diff --git a/src/ImageWriter.cpp b/src/ImageWriter.cpp index 376feb62a..1b7a01e9b 100644 --- a/src/ImageWriter.cpp +++ b/src/ImageWriter.cpp @@ -39,7 +39,7 @@ using namespace openshot; ImageWriter::ImageWriter(std::string path) : - path(path), cache_size(8), is_writing(false), write_video_count(0), image_quality(75), number_of_loops(1), + path(path), cache_size(8), write_video_count(0), image_quality(75), number_of_loops(1), combine_frames(true), is_open(false) { // Disable audio & video (so they can be independently enabled) diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 61ce31e33..0a0806b15 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -524,9 +524,6 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Loop through pixels for (int pixel = 0, byte_index=0; pixel < source_image->width() * source_image->height(); pixel++, byte_index+=4) { - // Get the alpha values from the pixel - int A = pixels[byte_index + 3]; - // Apply alpha to pixel pixels[byte_index + 3] *= alpha; } diff --git a/src/bindings/ruby/test.rb b/src/examples/Example.rb similarity index 100% rename from src/bindings/ruby/test.rb rename to src/examples/Example.rb