Skip to content

Commit

Permalink
#5 added rgb2yuv and experimental sse version.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhoving committed May 27, 2018
1 parent ceb5e13 commit 957fd50
Show file tree
Hide file tree
Showing 15 changed files with 643 additions and 22 deletions.
5 changes: 3 additions & 2 deletions CamCapture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ set(CAPTURE_SOURCE
)

set(CAPTURE_INCLUDE
include/CamCapture/cam_annotarion.h
include/CamCapture/cam_capture.h
include/CamCapture/cam_color.h
include/CamCapture/cam_gdiplus.h
include/CamCapture/cam_rect.h
include/CamCapture/cam_point.h
include/CamCapture/cam_size.h
include/CamCapture/cam_gdiplus.h
include/CamCapture/cam_annotarion.h
include/CamCapture/cam_stop_watch.h
)

source_group(src FILES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class cam_annotation_cursor : public cam_iannotation
cam_annotation_cursor(bool halo_enabled, size<int> halo_size, color halo_color) noexcept;
~cam_annotation_cursor() override;

void draw(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect, const point<int> &mouse_pos) override;
void draw(Gdiplus::Graphics &canvas, const cam_draw_data &draw_data) override;
protected:
void _draw_cursor(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect, const point<int> &mouse_pos);
void _draw_extras(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect, const point<int> &mouse_pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class cam_annotation_systemtime : public cam_iannotation
cam_annotation_systemtime(point<int> systemtime_position, color systemtime_color) noexcept;
~cam_annotation_systemtime() override;

void draw(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect, const point<int> &mouse_pos) override;
void draw(Gdiplus::Graphics &canvas, const cam_draw_data &draw_data) override;
private:
point<int> systemtime_position_;
color systemtime_color_;
Expand Down
17 changes: 16 additions & 1 deletion CamCapture/include/CamCapture/cam_annotarion.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,24 @@ namespace Gdiplus
class Graphics;
} // namespace Gdiplus

class cam_draw_data
{
public:
cam_draw_data(const double frame_delta, const rect<int> &canvast_rect, const point<int> &mouse_pos)
: frame_delta_(frame_delta)
, canvast_rect_(canvast_rect)
, mouse_pos_(mouse_pos)
{
}

const double frame_delta_;
const rect<int> &canvast_rect_;
const point<int> &mouse_pos_;
};

class cam_iannotation
{
public:
virtual ~cam_iannotation() = default;
virtual void draw(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect, const point<int> &mouse_pos) = 0;
virtual void draw(Gdiplus::Graphics &canvas, const cam_draw_data &draw_data) = 0;
};
71 changes: 71 additions & 0 deletions CamCapture/include/CamCapture/cam_stop_watch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright(C) 2018 Steven Hoving
*
* This program is free software : you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.If not, see < https://www.gnu.org/licenses/>.
*/

#pragma once

#include <cstdint>

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

namespace cam
{
class stop_watch
{
public:
stop_watch() noexcept
{
int64_t freq;
if( QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER *>(&freq) ) )
{
resolution_ = 1.0 / static_cast<double>(freq);
(void)QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER *>(&start_time_) );
}
}

void time_start() noexcept
{
sampled_time_ = _get_time();
}

double time_now() noexcept
{
return _get_time();
}

double time_since() noexcept
{
return _get_time() - sampled_time_;
}

protected:
inline double _get_time() noexcept
{
int64_t t_64;
(void)QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER *>(&t_64) );

const auto t = static_cast<double>(t_64 - start_time_);
return t * resolution_;
}

private:
double resolution_{0.0};
double sampled_time_{0.0};
int64_t start_time_{0};
};

} // namespace cam
7 changes: 3 additions & 4 deletions CamCapture/src/annotations/cam_annotation_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ cam_annotation_cursor::~cam_annotation_cursor()
{
}

void cam_annotation_cursor::draw(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect,
const point<int> &mouse_pos)
void cam_annotation_cursor::draw(Gdiplus::Graphics &canvas, const cam_draw_data &draw_data)
{
_draw_extras(canvas, canvast_rect, mouse_pos);
_draw_cursor(canvas, canvast_rect, mouse_pos);
_draw_extras(canvas, draw_data.canvast_rect_, draw_data.mouse_pos_);
_draw_cursor(canvas, draw_data.canvast_rect_, draw_data.mouse_pos_);
}

void cam_annotation_cursor::_draw_cursor(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect,
Expand Down
3 changes: 1 addition & 2 deletions CamCapture/src/annotations/cam_annotation_systemtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ cam_annotation_systemtime::~cam_annotation_systemtime()
{
}

void cam_annotation_systemtime::draw(Gdiplus::Graphics &canvas, const rect<int> &canvast_rect,
const point<int> &mouse_pos)
void cam_annotation_systemtime::draw(Gdiplus::Graphics &canvas, const cam_draw_data &/*draw_data*/)
{
const auto tp = std::chrono::system_clock::now();
const auto t = std::chrono::system_clock::to_time_t(tp);
Expand Down
5 changes: 4 additions & 1 deletion CamCapture/src/cam_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ void cam_capture_source::_draw_annotations()
canvas.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias);

point<int> mouse_point(pt.x, pt.y);

cam_draw_data draw_data(0.1, dst_capture_rect_, mouse_point);

for (const auto &annotation : annotations_)
annotation->draw(canvas, dst_capture_rect_, mouse_point);
annotation->draw(canvas, draw_data);

}
1 change: 1 addition & 0 deletions CamEncoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set(ENCODER_INCLUDE
include/CamEncoder/av_video.h
include/CamEncoder/av_ffmpeg.h
include/CamEncoder/av_encoder.h
include/CamEncoder/av_rgb2yuv.h
)

set(ENCODER_CAM_ENCODER_SOURCE
Expand Down
Loading

0 comments on commit 957fd50

Please sign in to comment.