Skip to content

Commit

Permalink
Various: Remove unused variables (#467)
Browse files Browse the repository at this point in the history
Several data members and local variables were flagged by static
analysis tools as never being used anywhere in the code.
  • Loading branch information
ferdnyc committed Apr 22, 2020
1 parent f36bb33 commit 6336f30
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 27 deletions.
1 change: 0 additions & 1 deletion include/AudioBufferSource.h
Expand Up @@ -48,7 +48,6 @@ namespace openshot
{
private:
int position;
int start;
bool repeat;
juce::AudioSampleBuffer *buffer;

Expand Down
1 change: 0 additions & 1 deletion include/AudioReaderSource.h
Expand Up @@ -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> frame; /// The current frame object that is being read
int64_t frame_position; /// The position of the current frame's buffer
Expand Down
1 change: 0 additions & 1 deletion include/Clip.h
Expand Up @@ -103,7 +103,6 @@ namespace openshot {

// Audio resampler (if time mapping)
openshot::AudioResampler *resampler;
juce::AudioSampleBuffer *audio_cache;

// File Reader object
openshot::ReaderBase* reader;
Expand Down
1 change: 0 additions & 1 deletion include/FFmpegWriter.h
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion include/ImageWriter.h
Expand Up @@ -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<Magick::Image> frames;
Expand Down
2 changes: 1 addition & 1 deletion src/AudioBufferSource.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/AudioReaderSource.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/CacheDisk.cpp
Expand Up @@ -228,7 +228,7 @@ std::shared_ptr<Frame> CacheDisk::GetFrame(int64_t frame_number)

// Load image file
std::shared_ptr<QImage> image = std::shared_ptr<QImage>(new QImage());
bool success = image->load(QString::fromStdString(frame_path.toStdString()));
image->load(frame_path);

// Set pixel formatimage->
image = std::shared_ptr<QImage>(new QImage(image->convertToFormat(QImage::Format_RGBA8888)));
Expand Down
12 changes: 3 additions & 9 deletions src/Clip.cpp
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -422,7 +422,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr<Frame> 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();

Expand All @@ -433,7 +432,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr<Frame> 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);
Expand All @@ -455,9 +453,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr<Frame> 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)
Expand Down Expand Up @@ -567,7 +562,6 @@ void Clip::get_time_mapped_frame(std::shared_ptr<Frame> 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++)
Expand Down
5 changes: 1 addition & 4 deletions src/FFmpegReader.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/FFmpegWriter.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -2030,7 +2030,6 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> 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
Expand Down
2 changes: 1 addition & 1 deletion src/ImageWriter.cpp
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/Timeline.cpp
Expand Up @@ -524,9 +524,6 @@ void Timeline::add_layer(std::shared_ptr<Frame> 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;
}
Expand Down
File renamed without changes.

0 comments on commit 6336f30

Please sign in to comment.