From 28cc591faf4d6b6558fa0662e582dae035f9ed86 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 15 Aug 2016 00:44:51 -0500 Subject: [PATCH] Implementing a small memory bug fix with regards to AV_FREE_FRAME and audio_frame. Also adding in support for duration to be set by JSON, to support long videos from openshot-qt. --- src/FFmpegReader.cpp | 4 +++- src/Timeline.cpp | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index b42db72b..c82f6980 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -1050,7 +1050,6 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ avr = NULL; // Free AVFrames - AV_FREE_FRAME(&audio_frame); av_free(audio_converted->data[0]); AV_FREE_FRAME(&audio_converted); @@ -1183,6 +1182,9 @@ void FFmpegReader::ProcessAudioPacket(long int requested_frame, long int target_ // 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 + + // Free audio frame + AV_FREE_FRAME(&audio_frame); } diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 990d260d..2645d1c3 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -941,6 +941,12 @@ void Timeline::SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed) { AddEffect(e); } } + + if (!root["duration"].isNull()) { + // Update duration of timeline + info.duration = root["duration"].asDouble(); + info.video_length = info.fps.ToFloat() * info.duration; + } } // Apply a special formatted JSON object, which represents a change to the timeline (insert, update, delete) @@ -1208,8 +1214,11 @@ void Timeline::apply_json_to_timeline(Json::Value change) throw(InvalidJSONKey) else if (root_key == "viewport_y") // Set viewport y offset viewport_y.SetJsonValue(change["value"]); - else if (root_key == "duration") { } - // Ignore for now + else if (root_key == "duration") { + // Update duration of timeline + info.duration = change["value"].asDouble(); + info.video_length = info.fps.ToFloat() * info.duration; + } else if (root_key == "width") // Set width info.width = change["value"].asInt();