-
Notifications
You must be signed in to change notification settings - Fork 6
Pranay Code Review #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
0e68809
219ebef
c57f8b6
6fd1b89
f4f3682
988772c
434bcc5
c53e035
2dede26
242a3f5
829f038
8609a99
18f2a4c
541ba35
d81b2d8
c7a0260
d0c46aa
ab30969
7bcb70b
f76f67b
a46ab1e
8d7db64
693a786
e8bd9c5
5ebe19d
ccf86c9
c0426df
244ed09
2c04eff
207128c
883bf72
6702dcd
3a70b76
0dcec19
fe9f502
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Find the Intel IPP (Integrated Performance Primitives) | ||
| # | ||
| # IPP_FOUND - System has IPP | ||
| # IPP_INCLUDE_DIRS - IPP include files directories | ||
| # IPP_LIBRARIES - The IPP libraries | ||
| # | ||
| # The environment variable IPPROOT is used to find the installation location. | ||
| # If the environment variable is not set we'll look for it in the default installation locations. | ||
| # | ||
| # Usage: | ||
| # | ||
| # find_package(IPP) | ||
| # if(IPP_FOUND) | ||
| # target_link_libraries(TARGET ${IPP_LIBRARIES}) | ||
| # endif() | ||
|
|
||
| find_path(IPP_ROOT_DIR | ||
| include/ipp.h | ||
| PATHS | ||
| $ENV{IPPROOT} | ||
| /opt/intel/compilers_and_libraries/linux/ipp | ||
| /opt/intel/compilers_and_libraries/mac/ipp | ||
| "C:/IntelSWTools/compilers_and_libraries/windows/ipp/" | ||
| "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/ipp" | ||
| $ENV{HOME}/intel/ipp | ||
| $ENV{HOME}/miniconda3 | ||
| $ENV{USERPROFILE}/miniconda3/Library | ||
| "C:/Miniconda37-x64/Library" # Making AppVeyor happy | ||
| ) | ||
|
|
||
| find_path(IPP_INCLUDE_DIR | ||
| ipp.h | ||
| PATHS | ||
| ${IPP_ROOT_DIR}/include | ||
| ) | ||
|
|
||
| if(WIN32) | ||
| set(IPP_SEARCH_LIB ippcoremt.lib) | ||
| set(IPP_LIBS ippcoremt.lib ippsmt.lib ippdcmt.lib) | ||
| elseif(APPLE) | ||
| set(IPP_SEARCH_LIB libippcore.a) | ||
| set(IPP_LIBS libipps.a libippdc.a libippcore.a) | ||
| else() # Linux | ||
| set(IPP_SEARCH_LIB libippcore.so) | ||
| set(IPP_LIBS ipps ippdc ippcore) | ||
| endif() | ||
|
|
||
|
|
||
| find_path(IPP_LIB_SEARCHPATH | ||
| ${IPP_SEARCH_LIB} | ||
| PATHS | ||
| ${IPP_ROOT_DIR}/lib/intel64 | ||
| ${IPP_ROOT_DIR}/lib | ||
| ) | ||
|
|
||
| foreach(LIB ${IPP_LIBS}) | ||
| find_library(${LIB}_PATH ${LIB} PATHS ${IPP_LIB_SEARCHPATH}) | ||
| if(${LIB}_PATH) | ||
| set(IPP_LIBRARIES ${IPP_LIBRARIES} ${${LIB}_PATH}) | ||
| set(IPP_FOUND TRUE) | ||
| else() | ||
| # message(STATUS "Could not find ${LIB}: disabling IPP") | ||
| set(IPP_NOTFOUND TRUE) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| if(IPP_FOUND AND NOT IPP_NOTFOUND) | ||
| set(IPP_INCLUDE_DIRS ${IPP_INCLUDE_DIR}) | ||
| include_directories(${IPP_INCLUDE_DIRS}) | ||
| message(STATUS "Found IPP libraries in: ${IPP_LIBRARIES}") | ||
| else() | ||
| message(STATUS "No IPP libraries found.") | ||
| set(IPP_FOUND FALSE) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,33 @@ | ||
| #include "PythonUnary.h" | ||
| #include "npp.h" | ||
|
mundrapranay marked this conversation as resolved.
Outdated
|
||
| #include "Format.h" | ||
| #include <boost/python/numpy.hpp> | ||
| #include <iostream> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Project then dependencies then system includes (I think this is in Google's C++ style guide) |
||
| #include <vector> | ||
| #include "PythonGreyscale.h" | ||
| #include "npp.h" | ||
| #include "ipp.h" | ||
| #include "Format.h" | ||
|
|
||
| namespace np = boost::python::numpy; | ||
|
|
||
| namespace lightdb::python { | ||
| shared_reference <LightField> PythonGreyscale::CPU::operator()(LightField &input) { | ||
| shared_reference <LightField> PythonUnary::CPU::operator()(LightField &input) { | ||
| np::initialize(); | ||
| const auto channels = 3u; | ||
| auto &data = dynamic_cast<lightdb::physical::CPUDecodedFrameData&>(input); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add precondition check on input being of the right type |
||
| lightdb::physical::CPUDecodedFrameData output(data.configuration(), data.geometry()); | ||
|
|
||
| for(auto& frame: data.frames()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably const |
||
|
|
||
| //ToDo: add equality operator | ||
| // frame->format() == lightdb::video::Format::nv12() | ||
| Allocate(frame->height(), frame->width(), channels); | ||
| IppiSize size{static_cast<int>(frame->width()), static_cast<int>(frame->height())}; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const |
||
| auto y_in = reinterpret_cast<const unsigned char*>(frame->data().data()); | ||
| auto uv_in = y_in + frameSize_; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check frame format before assuming NV12; throw if in an unexpected form |
||
| output.frames().emplace_back(LocalFrameReference::make<LocalFrame>(*frame, frame->data().size(), lightdb::video::Format::nv12())); | ||
| output.frames().emplace_back(LocalFrameReference::make<LocalFrame>(*frame, frame->data().size(), frame->format())); | ||
| auto y_out = output.frames().back()->data().data(); | ||
| auto uv_out = y_out + frameSize_; | ||
|
|
||
| // NV12 -> RGB | ||
| CHECK_EQ(ippiYCbCr420ToRGB_8u_P2C3R((Ipp8u*)y_in, frame->width(), (Ipp8u*)uv_in, frame->width(), rgb_.data(), channels * frame->width(), size), ippStsNoErr); | ||
|
|
||
| nv12ToRgb(frame, y_in, uv_in, channels, size); | ||
| // RGB --> Numpy | ||
| np::dtype dtype = np::dtype::get_builtin<unsigned char>(); | ||
| np::ndarray py_array = np::from_data( | ||
|
|
@@ -40,8 +41,14 @@ namespace lightdb::python { | |
| boost::python::call<void>(callable_, swap); | ||
|
|
||
| // RGB -> NV12 | ||
| CHECK_EQ(ippiRGBToYCbCr420_8u_C3P2R(rgb_.data(), channels * frame->width(), (Ipp8u*)y_out, frame->width(), (Ipp8u*)uv_out, frame->width(), size), ippStsNoErr); | ||
| CHECK_EQ(ippiRGBToYCbCr420_8u_C3P2R(rgb_.data(), channels * frame->width(), const_cast<Ipp8u*>(reinterpret_cast<const Ipp8u*>(y_out)), frame->width(), | ||
| const_cast<Ipp8u*>(reinterpret_cast<const Ipp8u*>(uv_out)), frame->width(), size), ippStsNoErr); | ||
| } | ||
| return output; | ||
| } | ||
|
|
||
| void PythonUnary::CPU::nv12ToRgb(auto& frame, auto y_in, auto uv_in, const auto channels, const IppiSize& size) { | ||
| CHECK_EQ(ippiYCbCr420ToRGB_8u_P2C3R(const_cast<Ipp8u*>(reinterpret_cast<const Ipp8u*>(y_in)), frame->width(), const_cast<Ipp8u*>(reinterpret_cast<const Ipp8u*>(uv_in)), | ||
| frame->width(), rgb_.data(), channels * frame->width(), size), ippStsNoErr); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.