Skip to content

Commit

Permalink
Implementing Codacy improvements, removing some unused or pointless code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph committed Feb 19, 2021
1 parent 6012fc9 commit 8280e20
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 32 deletions.
4 changes: 0 additions & 4 deletions examples/Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ int main(int argc, char* argv[]) {
using s = std::chrono::seconds;
using double_ms = std::chrono::duration<double, ms::period>;

// Track total time
const auto total_time = double_ms(0.0);

// FFmpeg Reader performance test
const auto total_1 = std::chrono::high_resolution_clock::now();
FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-1080p.mp4");
Expand All @@ -64,7 +61,6 @@ int main(int argc, char* argv[]) {
r9.Close();



// Timeline Reader performance test
Timeline tm(r9.info.width, r9.info.height, r9.info.fps, r9.info.sample_rate, r9.info.channels, r9.info.channel_layout);
Clip *c = new Clip(&r9);
Expand Down
25 changes: 0 additions & 25 deletions src/Clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,6 @@ std::shared_ptr<Frame> Clip::GetFrame(std::shared_ptr<openshot::Frame> backgroun
// Adjust out of bounds frame number
frame_number = adjust_frame_number_minimum(frame_number);

// Adjust has_video and has_audio overrides
int enabled_audio = has_audio.GetInt(frame_number);
if (enabled_audio == -1 && reader && reader->info.has_audio)
enabled_audio = 1;
else if (enabled_audio == -1 && reader && !reader->info.has_audio)
enabled_audio = 0;
int enabled_video = has_video.GetInt(frame_number);
if (enabled_video == -1 && reader && reader->info.has_video)
enabled_video = 1;
else if (enabled_video == -1 && reader && !reader->info.has_video)
enabled_video = 0;

// Is a time map detected
int64_t new_frame_number = frame_number;
int64_t time_mapped_number = adjust_frame_number_minimum(time.GetLong(frame_number));
Expand All @@ -382,19 +370,6 @@ std::shared_ptr<Frame> Clip::GetFrame(std::shared_ptr<openshot::Frame> backgroun
// Apply effects to the frame (if any)
apply_effects(original_frame);

// Determine size of image (from Timeline or Reader)
int width = 0;
int height = 0;
if (timeline) {
// Use timeline size (if available)
width = timeline->preview_width;
height = timeline->preview_height;
} else {
// Fallback to clip size
width = reader->info.width;
height = reader->info.height;
}

// Apply keyframe / transforms
apply_keyframes(original_frame, background_frame->GetImage());

Expand Down
4 changes: 1 addition & 3 deletions src/FFmpegReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,6 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {

// Create variables for a RGB Frame (since most videos are not in RGB, we must convert it)
AVFrame *pFrameRGB = NULL;
int numBytes;
uint8_t *buffer = NULL;

// Allocate an AVFrame structure
Expand Down Expand Up @@ -1318,7 +1317,6 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
}

// Determine required buffer size and allocate buffer
numBytes = AV_GET_IMAGE_SIZE(PIX_FMT_RGBA, width, height);
const int bytes_per_pixel = 4;
int buffer_size = width * height * bytes_per_pixel;
buffer = new unsigned char[buffer_size]();
Expand Down Expand Up @@ -2169,7 +2167,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, int64_t requested_fram
break;

// Remove frames which are too old
if (f && f->number < (requested_frame - (max_concurrent_frames * 2))) {
if (f->number < (requested_frame - (max_concurrent_frames * 2))) {
working_cache.Remove(f->number);
}

Expand Down

0 comments on commit 8280e20

Please sign in to comment.