]> git.sesse.net Git - nageru/commitdiff
Move VADisplayWithCleanup into its own header file, in shared/.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 May 2020 09:38:22 +0000 (11:38 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 May 2020 09:39:08 +0000 (11:39 +0200)
This is the first step on trying to unify the initialization code
a bit between Nageru and Futatabi.

futatabi/vaapi_jpeg_decoder.cpp
nageru/mixer.cpp
nageru/mjpeg_encoder.cpp
nageru/pbo_frame_allocator.cpp
nageru/quicksync_encoder.cpp
nageru/quicksync_encoder_impl.h
shared/meson.build
shared/va_display.cpp [new file with mode: 0644]
shared/va_display.h [moved from nageru/va_display_with_cleanup.h with 65% similarity]

index 0441514a8b815efe62509e45490b595cc0a4562b..452e61c3d13647b3c8f3204f75d9d882aa715bdd 100644 (file)
@@ -138,19 +138,6 @@ private:
        bool committed = false;
 };
 
-VADisplayWithCleanup::~VADisplayWithCleanup()
-{
-       if (va_dpy != nullptr) {
-               vaTerminate(va_dpy);
-       }
-       if (x11_display != nullptr) {
-               XCloseDisplay(x11_display);
-       }
-       if (drm_fd != -1) {
-               close(drm_fd);
-       }
-}
-
 unique_ptr<VADisplayWithCleanup> va_open_display(const string &va_display)
 {
        if (va_display.empty() || va_display[0] != '/') {  // An X display.
index ba1f3347f4876d209fdd18a6d836a7f05969482d..a5206c9b3ea48edf27c9d8db2462a8933465927f 100644 (file)
@@ -48,6 +48,7 @@
 #include "image_input.h"
 #include "input_mapping.h"
 #include "shared/metrics.h"
+#include "shared/va_display.h"
 #include "mjpeg_encoder.h"
 #include "pbo_frame_allocator.h"
 #include "shared/ref_counted_gl_sync.h"
@@ -55,7 +56,6 @@
 #include "shared/timebase.h"
 #include "timecode_renderer.h"
 #include "v210_converter.h"
-#include "va_display_with_cleanup.h"
 #include "video_encoder.h"
 
 #undef Status
index 03afac9e1df27fb10bd12bc8bc8d7a1a8183279c..857346db7592d67a79305cef7a1c643b167912bf 100644 (file)
@@ -20,7 +20,7 @@ extern "C" {
 #include "shared/metrics.h"
 #include "pbo_frame_allocator.h"
 #include "shared/timebase.h"
-#include "va_display_with_cleanup.h"
+#include "shared/va_display.h"
 
 #include <movit/colorspace_conversion_effect.h>
 
index ba5322602a47e4f0903fda950a96e597bd6c5660..d7cd818d15d614ba96d1d049e9bb36afbdc01e36 100644 (file)
@@ -10,7 +10,7 @@
 #include "flags.h"
 #include "mjpeg_encoder.h"
 #include "v210_converter.h"
-#include "va_display_with_cleanup.h"
+#include "shared/va_display.h"
 
 using namespace std;
 
index 70bf8002073d64aba40f2aa6021c3e19ddf9a352..7ec9f71c5eced50096af99bd4baed2a433cd8a2b 100644 (file)
@@ -728,19 +728,6 @@ void QuickSyncEncoderImpl::enable_zerocopy_if_possible()
        global_flags.use_zerocopy = use_zerocopy;
 }
 
-VADisplayWithCleanup::~VADisplayWithCleanup()
-{
-       if (va_dpy != nullptr) {
-               vaTerminate(va_dpy);
-       }
-       if (x11_display != nullptr) {
-               XCloseDisplay(x11_display);
-       }
-       if (drm_fd != -1) {
-               close(drm_fd);
-       }
-}
-
 unique_ptr<VADisplayWithCleanup> va_open_display(const string &va_display)
 {
        if (va_display.empty() || va_display[0] != '/') {  // An X display.
index 0800c5956b758466234560fba3b24ec79fd37585..53f88ecd4be8c9fe98d51cfeaf72eebb34fe4afe 100644 (file)
@@ -20,7 +20,7 @@
 #include "shared/timebase.h"
 #include "print_latency.h"
 #include "shared/ref_counted_gl_sync.h"
-#include "va_display_with_cleanup.h"
+#include "shared/va_display.h"
 #include "v4l_output.h"
 
 #define SURFACE_NUM 16 /* 16 surfaces for source YUV */
index c7ef06c410ea32464c91ecb21f45d24c268499b3..28586c61267582f8dabdb6c9046f506637080c1f 100644 (file)
@@ -4,6 +4,8 @@ libmicrohttpddep = dependency('libmicrohttpd')
 protobufdep = dependency('protobuf')
 alsadep = dependency('alsa')
 movitdep = dependency('movit')
+vadrmdep = dependency('libva-drm')
+vax11dep = dependency('libva-x11')
 
 # Preprocess Qt as needed.
 qt_files = qt5.preprocess(
@@ -19,14 +21,14 @@ proto_generated = gen.process(['midi_mapping.proto'])
 protobuf_lib = static_library('protobufs', proto_generated, dependencies: [protobufdep])
 protobuf_hdrs = declare_dependency(sources: proto_generated)
 
-srcs = ['memcpy_interleaved.cpp', 'metacube2.cpp', 'ffmpeg_raii.cpp', 'mux.cpp', 'metrics.cpp', 'context.cpp', 'httpd.cpp', 'disk_space_estimator.cpp', 'read_file.cpp', 'text_proto.cpp', 'midi_device.cpp', 'ref_counted_texture.cpp']
+srcs = ['memcpy_interleaved.cpp', 'metacube2.cpp', 'ffmpeg_raii.cpp', 'mux.cpp', 'metrics.cpp', 'context.cpp', 'httpd.cpp', 'disk_space_estimator.cpp', 'read_file.cpp', 'text_proto.cpp', 'midi_device.cpp', 'ref_counted_texture.cpp', 'va_display.cpp']
 srcs += proto_generated
 
 # Qt objects.
 srcs += qt_files
 srcs += ['aboutdialog.cpp']
 
-shared = static_library('shared', srcs, include_directories: top_include, dependencies: [shared_qt5deps, libmicrohttpddep, protobufdep, alsadep, movitdep])
+shared = static_library('shared', srcs, include_directories: top_include, dependencies: [shared_qt5deps, libmicrohttpddep, protobufdep, alsadep, movitdep, vadrmdep, vax11dep])
 shareddep = declare_dependency(
    sources: proto_generated,
    include_directories: top_include,
diff --git a/shared/va_display.cpp b/shared/va_display.cpp
new file mode 100644 (file)
index 0000000..36c8f17
--- /dev/null
@@ -0,0 +1,16 @@
+#include "shared/va_display.h"
+#include <unistd.h>
+
+VADisplayWithCleanup::~VADisplayWithCleanup()
+{
+       if (va_dpy != nullptr) {
+               vaTerminate(va_dpy);
+       }
+       if (x11_display != nullptr) {
+               XCloseDisplay(x11_display);
+       }
+       if (drm_fd != -1) {
+               close(drm_fd);
+       }
+}
+
similarity index 65%
rename from nageru/va_display_with_cleanup.h
rename to shared/va_display.h
index 3f9b1c56ebaba2790432bbd956b88545a6e75038..395ecbb5f1f007412e2605440bb1a59c88502d83 100644 (file)
@@ -1,19 +1,20 @@
-#ifndef _VA_DISPLAY_WITH_CLEANUP
-#define _VA_DISPLAY_WITH_CLEANUP 1
+#ifndef _VA_DISPLAY_H
+#define _VA_DISPLAY _H1
 
 #include <va/va.h>
 #include <X11/Xlib.h>
 
 #include <memory>
+#include <string.h>
 
 struct VADisplayWithCleanup {
        ~VADisplayWithCleanup();
 
        VADisplay va_dpy;
        Display *x11_display = nullptr;
-       bool can_use_zerocopy = true;
+       bool can_use_zerocopy = true;  // For H.264 encoding in Nageru.
        int drm_fd = -1;
 };
 std::unique_ptr<VADisplayWithCleanup> va_open_display(const std::string &va_display);  // Can return nullptr on failure.
 
-#endif  // !defined(_VA_DISPLAY_WITH_CLEANUP)
+#endif  // !defined(_VA_DISPLAY_H)