jcsyshc пре 2 година
родитељ
комит
bba23ba912
5 измењених фајлова са 24 додато и 16 уклоњено
  1. 1 1
      CMakeLists.txt
  2. 3 1
      src/main.cpp
  3. 3 1
      src/nv12_renderer.cpp
  4. 13 11
      src/third_party/rs.c
  5. 4 2
      src/video_decoder.cpp

+ 1 - 1
CMakeLists.txt

@@ -58,7 +58,7 @@ target_link_libraries(${PROJECT_NAME} spdlog::spdlog)
 target_compile_definitions(${PROJECT_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
 
 # Boost config
-find_package(Boost REQUIRED)
+find_package(Boost REQUIRED COMPONENTS filesystem)
 target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
 target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
 

+ 3 - 1
src/main.cpp

@@ -92,7 +92,8 @@ void controller_main(const char *this_name) {
             if (ImGui::BeginCombo("Monitor", monitor_name_preview)) { // let user select monitors
                 for (int k = 0; k < monitor_count; ++k) {
                     auto is_selected = (monitor_index == k);
-                    if (ImGui::Selectable(glfwGetMonitorName(monitors[k]), is_selected)) {
+                    auto monitor_name = fmt::format("{} - {}", k, glfwGetMonitorName(monitors[k]));
+                    if (ImGui::Selectable(monitor_name.c_str(), is_selected)) {
                         monitor_index = k;
                     }
                     if (is_selected) {
@@ -191,6 +192,7 @@ int main(int argc, char *argv[]) {
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+    glfwWindowHint(GLFW_REFRESH_RATE, 60);
 
     // setup window
     if (is_controller) {

+ 3 - 1
src/nv12_renderer.cpp

@@ -47,6 +47,7 @@ struct nv12_renderer::impl {
 
     // frame related
     int frame_width = 0, frame_height = 0;
+    float frame_wh_ratio = 1;
     GLuint luma_pbo = 0, chroma_pbo = 0;
     GLuint luma_tex = 0, chroma_tex = 0;
     cudaGraphicsResource *luma_res = nullptr, *chroma_res = nullptr;
@@ -248,11 +249,12 @@ void nv12_renderer::config_frame(int frame_width, int frame_height) {
     assert((frame_width & 1) == 0 && (frame_height & 1) == 0);
     pimpl->frame_width = frame_width;
     pimpl->frame_height = frame_height;
+    pimpl->frame_wh_ratio = 1.0f * frame_width / frame_height;
     pimpl->config_frame();
 }
 
 void nv12_renderer::render(float factor) {
-    pimpl->render(factor);
+    pimpl->render(pimpl->frame_wh_ratio / factor);
 }
 
 void nv12_renderer::get_frame_res(cudaGraphicsResource **luma_res,

+ 13 - 11
src/third_party/rs.c

@@ -169,13 +169,7 @@ modnn(int x)
  * A value related to the multiplication is held in a local variable
  * declared with USE_GF_MULC . See usage in addmul1().
  */
-static gf gf_mul_table[(GF_SIZE + 1)*(GF_SIZE + 1)]
-#ifdef WINDOWS
-        __attribute__((aligned (16)))
-#else
-        __attribute__((aligned (256)))
-#endif
-;
+__declspec(align(16)) static gf gf_mul_table[(GF_SIZE + 1)*(GF_SIZE + 1)];
 
 #define gf_mul(x,y) gf_mul_table[(x<<8)+y]
 
@@ -415,10 +409,14 @@ invert_mat(gf *src, int k)
     int irow, icol, row, col, i, ix ;
 
     int error = 1 ;
-    int indxc[k];
-    int indxr[k];
-    int ipiv[k];
-    gf id_row[k];
+    int *indxc = malloc(k*sizeof(int));
+    int *indxr = malloc(k*sizeof(int));
+    int *ipiv = malloc(k*sizeof(int));
+    gf *id_row = malloc(k*sizeof(gf));
+//    int indxc[k];
+//    int indxr[k];
+//    int ipiv[k];
+//    gf id_row[k];
 
     memset(id_row, 0, k*sizeof(gf));
     DEB( pivloops=0; pivswaps=0 ; /* diagnostic */ )
@@ -525,6 +523,10 @@ invert_mat(gf *src, int k)
     }
     error = 0 ;
     fail:
+    free(indxc);
+    free(indxr);
+    free(ipiv);
+    free(id_row);
     return error ;
 }
 

+ 4 - 2
src/video_decoder.cpp

@@ -157,9 +157,11 @@ struct video_decoder::impl {
         // upload frame
         void *pbo_ptr;
         size_t pbo_size;
-        CUDA_API_CHECK(cudaGraphicsMapResources(2, &luma_res));
+        CUDA_API_CHECK(cudaGraphicsMapResources(1, &luma_res));
+        CUDA_API_CHECK(cudaGraphicsMapResources(1, &chroma_res));
         auto res_closer = sg::make_scope_guard([&]() {
-            cudaGraphicsUnmapResources(2, &luma_res);
+            cudaGraphicsUnmapResources(1, &luma_res);
+            cudaGraphicsUnmapResources(1, &chroma_res);
         });
 
         auto luma_ptr = (void *) frame_ptr;