Skip to content

Commit

Permalink
Improve user interface (#24)
Browse files Browse the repository at this point in the history
* Fix side bar resize controls function

* Save the last directory in conversion

* Fix append reverse logic

* Always remove session before exit

* Move geometry classes to geometry directory

* Rename Player class to Decoder

* Fix typo

* Rename FifoBuffer to StackBuffer

* Rename PlayerWrapper to Player class

Also add support to frame changing notifications

* Add an callback to notify when the frame is changed

* Remove google mocks due it's not in use for now
  • Loading branch information
rodjjo authored Dec 7, 2018
1 parent c348e09 commit 58e8455
Show file tree
Hide file tree
Showing 117 changed files with 268 additions and 52,538 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-mod
set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_CXX_STANDARD 14)
set(FLTK_SKIP_FLUID true)
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE Release)

find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
find_library(AVCODEC_LIBRARY avcodec)
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ file(GLOB Sources
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/vstream/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/geometry/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/controls/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/clippings/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/data/*.cpp"
Expand All @@ -11,7 +12,7 @@ file(GLOB Sources
"${CMAKE_CURRENT_SOURCE_DIR}/wnd_cutter/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/wnd_main/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/wnd_tools/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/wrappers/*.cpp")
"${CMAKE_CURRENT_SOURCE_DIR}/player/*.cpp")

if(WIN32)
add_executable(smart-vcutter WIN32 ${Sources})
Expand Down
2 changes: 1 addition & 1 deletion src/clippings/clipping_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void ClippingConversion::combine_buffers(uint8_t *primary_buffer, uint8_t *secon
}

void ClippingConversion::encode_frame(uint8_t *buffer) {
last_encoded_buffer_.store(buffer); // the clipping iterator does not release any buffer before it destroy itself.
last_encoded_buffer_.store(buffer); // the clipping iterator does not release any buffer before it destroys itself.
encoder_->frame(buffer);
++current_position_;
}
Expand Down
2 changes: 1 addition & 1 deletion src/clippings/clipping_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ClippingConversion: private boost::noncopyable {
const char * error() const;
private:
void encode_frame(uint8_t *buffer);
void copy_buffer(vs::Player *player, uint8_t *buffer);
void copy_buffer(vs::Decoder *player, uint8_t *buffer);
float transparency_increment();
void combine_buffers(uint8_t *primary_buffer, uint8_t *secondary_buffer);
void define_transition_settings(uint8_t *transition_frames);
Expand Down
4 changes: 2 additions & 2 deletions src/clippings/clipping_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void ClippingFrame::video_open() {
return;
}

player_.reset(new PlayerWrapper(video_path().c_str()));
player_.reset(new Player(video_path().c_str()));

if (!good()){
return;
Expand Down Expand Up @@ -54,7 +54,7 @@ bool ClippingFrame::good() {
return false;
}

PlayerWrapper *ClippingFrame::player() {
Player *ClippingFrame::player() {
return player_.get();
}

Expand Down
6 changes: 3 additions & 3 deletions src/clippings/clipping_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <inttypes.h>

#include "src/wrappers/video_player.h"
#include "src/player/player.h"
#include "src/clippings/clipping_data.h"
#include "src/clippings/clipping_ref.h"

Expand All @@ -18,7 +18,7 @@ class ClippingFrame: public ClippingData {
explicit ClippingFrame(const Json::Value * root);
ClippingFrame(const char *path, bool path_is_video);
virtual ~ClippingFrame(){}
PlayerWrapper *player();
Player *player();
bool good();
ClippingKey current_key();
void positionate_left(uint32_t frame);
Expand All @@ -43,7 +43,7 @@ class ClippingFrame: public ClippingData {
void video_open();

private:
std::unique_ptr<PlayerWrapper> player_;
std::unique_ptr<Player> player_;
};

} // namespace vcutter
Expand Down
16 changes: 8 additions & 8 deletions src/clippings/clipping_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ void ClippingIterator::iterate(bool from_start, bool append_reverse, frame_itera
uint32_t from_frame = from_start ? clipping_->first_frame() : clipping_->last_frame();
uint32_t to_frame = from_start ? clipping_->last_frame() : clipping_->first_frame();

clipping_->player()->async_context([
clipping_->player()->execute([
this,
from_frame,
to_frame,
append_reverse,
cb
] (vs::Player *player) {
] (vs::Decoder *player) {
uint32_t frame_count = (from_frame > to_frame) ? from_frame - to_frame : to_frame - from_frame;

if (frame_count < 1) {
Expand All @@ -52,7 +52,7 @@ void ClippingIterator::iterate(bool from_start, bool append_reverse, frame_itera
return;
}

buffers_.reset(new FifoBuffer(clipping_->req_buffer_size(), count));
buffers_.reset(new StackBuffer(clipping_->req_buffer_size(), count));
}

render_buffer_.reset(new CharBuffer(clipping_->req_buffer_size()));
Expand All @@ -65,7 +65,7 @@ void ClippingIterator::iterate(bool from_start, bool append_reverse, frame_itera
});
}

void ClippingIterator::from_begin(vs::Player *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb) {
void ClippingIterator::from_begin(vs::Decoder *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb) {
uint32_t frame_count = (to_frame - from_frame) + 1;

player->seek_frame(from_frame);
Expand All @@ -83,7 +83,7 @@ void ClippingIterator::from_begin(vs::Player *player, bool append_reverse, uint3
}
}

void ClippingIterator::from_end(vs::Player *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb) {
void ClippingIterator::from_end(vs::Decoder *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb) {
uint32_t frame_count = (to_frame - from_frame) + 1;
uint32_t position = to_frame;
bool flushing = false;
Expand All @@ -100,7 +100,7 @@ void ClippingIterator::from_end(vs::Player *player, bool append_reverse, uint32_

player->seek_frame(position);

while (!flushing) {
while (!flushing && frame_count > 0) {
--frame_count;
render_frame(render_buffer_->data);
player->next();
Expand Down Expand Up @@ -139,7 +139,7 @@ bool ClippingIterator::flush_buffers(frame_iteration_cb_t cb) {
return true;
}

void ClippingIterator::grab_all(vs::Player *player, uint32_t from_frame, uint32_t to_frame, bool append_reverse, frame_iteration_cb_t cb) {
void ClippingIterator::grab_all(vs::Decoder *player, uint32_t from_frame, uint32_t to_frame, bool append_reverse, frame_iteration_cb_t cb) {
bool forward = from_frame <= to_frame;
frames_.clear();

Expand Down Expand Up @@ -192,7 +192,7 @@ void ClippingIterator::render_frame(uint8_t *buffer) {
}

bool ClippingIterator::finished() {
return clipping_->player()->context_finished();
return clipping_->player()->execution_finished();
}

} // namespace vcutter
8 changes: 4 additions & 4 deletions src/clippings/clipping_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class ClippingIterator {
bool finished();
private:
uint32_t buffer_count(uint32_t frame_count);
void grab_all(vs::Player *player, uint32_t from_frame, uint32_t to_frame, bool append_reverse, frame_iteration_cb_t cb);
void from_begin(vs::Player *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb);
void from_end(vs::Player *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb);
void grab_all(vs::Decoder *player, uint32_t from_frame, uint32_t to_frame, bool append_reverse, frame_iteration_cb_t cb);
void from_begin(vs::Decoder *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb);
void from_end(vs::Decoder *player, bool append_reverse, uint32_t from_frame, uint32_t to_frame, frame_iteration_cb_t cb);
void render_frame(uint8_t *buffer);
void report_frames(bool forward, bool append_reverse, frame_iteration_cb_t cb);
bool flush_buffers(frame_iteration_cb_t cb);

private:
ClippingRender *clipping_;
std::unique_ptr<FifoBuffer> buffers_;
std::unique_ptr<StackBuffer> buffers_;
std::unique_ptr<CharBuffer> render_buffer_;
std::list<std::shared_ptr<CharBuffer> > frames_;
uint32_t max_memory_;
Expand Down
2 changes: 1 addition & 1 deletion src/clippings/clipping_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define SRC_CLIPPINGS_CLIPPING_KEY_H_

#include <jsoncpp/json/json.h>
#include "src/common/box.h"
#include "src/geometry/box.h"

namespace vcutter {

Expand Down
2 changes: 1 addition & 1 deletion src/clippings/clipping_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <inttypes.h>
#include <memory>

#include "src/wrappers/video_player.h"
#include "src/player/player.h"
#include "src/clippings/clipping_frame.h"

namespace vcutter {
Expand Down
8 changes: 1 addition & 7 deletions src/clippings/clipping_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ const char *kCLIPPING_SESSION_NAME = "-clipping-session.vcutter";

ClippingSession::ClippingSession(const char *session_name, const char *path, bool path_is_video)
: Clipping(path, path_is_video), session_name_(session_name) {
should_clear_session_ = false;
Fl::add_timeout(1.0, &ClippingSession::fltk_timeout_handler, this);
}

ClippingSession::ClippingSession(const char *session_name, const Json::Value * root)
: Clipping(root), session_name_(session_name) {
should_clear_session_ = false;
}

ClippingSession::~ClippingSession() {
Fl::remove_timeout(&ClippingSession::fltk_timeout_handler, this);
if (should_clear_session_) {
remove_session();
}
remove_session();
}

void ClippingSession::fltk_timeout_handler(void* clipping_session) {
Expand All @@ -52,8 +48,6 @@ std::unique_ptr<ClippingSession> ClippingSession::restore_session(const char *se
new ClippingSession(session_name, path.c_str(), false)
);

result->should_clear_session_ = true;

if (!result->good()) {
result.reset();
}
Expand Down
1 change: 0 additions & 1 deletion src/clippings/clipping_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ClippingSession: public Clipping {
void remove_session();
private:
uint64_t last_version_;
bool should_clear_session_;
std::string session_name_;
};

Expand Down
8 changes: 4 additions & 4 deletions src/common/buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace vcutter {

FifoBuffer::FifoBuffer(uint32_t individual_size, uint32_t buffer_count) {
StackBuffer::StackBuffer(uint32_t individual_size, uint32_t buffer_count) {
buffer_index_ = 0;
individual_size_ = individual_size;
buffers_.reserve(buffer_count);
Expand All @@ -16,7 +16,7 @@ FifoBuffer::FifoBuffer(uint32_t individual_size, uint32_t buffer_count) {
}
}

bool FifoBuffer::push(uint8_t *buffer) {
bool StackBuffer::push(uint8_t *buffer) {
if (buffer_index_ < buffers_.size()) {
memcpy(buffers_[buffer_index_]->data, buffer, individual_size_);
++buffer_index_;
Expand All @@ -25,15 +25,15 @@ bool FifoBuffer::push(uint8_t *buffer) {
return false;
}

uint8_t *FifoBuffer::pop() {
uint8_t *StackBuffer::pop() {
if (buffer_index_) {
--buffer_index_;
return buffers_[buffer_index_]->data;
}
return NULL;
}

uint32_t FifoBuffer::count() {
uint32_t StackBuffer::count() {
return buffers_.size();
}

Expand Down
6 changes: 3 additions & 3 deletions src/common/buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class CharBuffer: private boost::noncopyable {
};


class FifoBuffer: private boost::noncopyable {
class StackBuffer: private boost::noncopyable {
public:
FifoBuffer(uint32_t individual_size, uint32_t buffer_count);
virtual ~FifoBuffer(){}
StackBuffer(uint32_t individual_size, uint32_t buffer_count);
virtual ~StackBuffer(){}
bool push(uint8_t *buffer);
uint8_t * pop();
uint32_t count();
Expand Down
4 changes: 2 additions & 2 deletions src/common/view_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#define SRC_COMMON_VIEW_PORT_H_

#include <inttypes.h>
#include "src/common/point.h"
#include "src/common/box.h"
#include "src/geometry/point.h"
#include "src/geometry/box.h"


namespace vcutter {
Expand Down
2 changes: 1 addition & 1 deletion src/common/box.cpp → src/geometry/box.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2018 by Rodrigo Antonio de Araujo
*/
#include "src/common/box.h"
#include "src/geometry/box.h"

namespace vcutter {

Expand Down
8 changes: 4 additions & 4 deletions src/common/box.h → src/geometry/box.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2018 by Rodrigo Antonio de Araujo
*/
#ifndef SRC_COMMON_BOX_H_
#define SRC_COMMON_BOX_H_
#ifndef SRC_GEOMETRY_BOX_H_
#define SRC_GEOMETRY_BOX_H_

#include "src/common/point.h"
#include "src/geometry/point.h"

namespace vcutter {

Expand Down Expand Up @@ -61,4 +61,4 @@ class box_t {

} // namespace vcutter

#endif // SRC_COMMON_BOX_H_
#endif // SRC_GEOMETRY_BOX_H_
2 changes: 1 addition & 1 deletion src/common/point.cpp → src/geometry/point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2018 by Rodrigo Antonio de Araujo
*/
#include <cmath>
#include "src/common/point.h"
#include "src/geometry/point.h"

#define ALMOST_INFINITE 99999999

Expand Down
6 changes: 3 additions & 3 deletions src/common/point.h → src/geometry/point.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2018 by Rodrigo Antonio de Araujo
*/
#ifndef SRC_COMMON_POINT_H_
#define SRC_COMMON_POINT_H_
#ifndef SRC_GEOMETRY_POINT_H_
#define SRC_GEOMETRY_POINT_H_

#define PI 3.1415926535897
#define DEGS (PI / 180.0)
Expand Down Expand Up @@ -46,4 +46,4 @@ class point_t {

} // namespace vcutter

#endif // SRC_COMMON_POINT_H_
#endif // SRC_GEOMETRY_POINT_H_
Loading

0 comments on commit 58e8455

Please sign in to comment.