]> git.sesse.net Git - nageru/blobdiff - quicksync_encoder.cpp
Add an option to control the mapping of streams to export to MJPEG (or turn it off...
[nageru] / quicksync_encoder.cpp
index f664157b3d4ff67158a537ac24eb9c734a60c751..bca7ffd91983e73ed819d7889c9925cd58acae2f 100644 (file)
@@ -1939,8 +1939,6 @@ void QuickSyncEncoderImpl::add_packet_for_uncompressed_frame(int64_t pts, int64_
        stream_mux->add_packet(pkt, pts, pts);
 }
 
-namespace {
-
 void memcpy_with_pitch(uint8_t *dst, const uint8_t *src, size_t src_width, size_t dst_pitch, size_t height)
 {
        if (src_width == dst_pitch) {
@@ -1954,8 +1952,6 @@ void memcpy_with_pitch(uint8_t *dst, const uint8_t *src, size_t src_width, size_
        }
 }
 
-}  // namespace
-
 void QuickSyncEncoderImpl::pass_frame(QuickSyncEncoderImpl::PendingFrame frame, int display_frame_num, int64_t pts, int64_t duration)
 {
        // Wait for the GPU to be done with the frame.
@@ -2133,9 +2129,20 @@ int64_t QuickSyncEncoder::global_delay() const {
 
 string QuickSyncEncoder::get_usable_va_display()
 {
+       // Reduce the amount of chatter while probing,
+       // unless the user has specified otherwise.
+       bool need_env_reset = false;
+       if (getenv("LIBVA_MESSAGING_LEVEL") == nullptr) {
+               setenv("LIBVA_MESSAGING_LEVEL", "0", true);
+               need_env_reset = true;
+       }
+
        // First try the default (ie., whatever $DISPLAY is set to).
        unique_ptr<VADisplayWithCleanup> va_dpy = try_open_va("", nullptr, nullptr);
        if (va_dpy != nullptr) {
+               if (need_env_reset) {
+                       unsetenv("LIBVA_MESSAGING_LEVEL");
+               }
                return "";
        }
 
@@ -2154,6 +2161,9 @@ string QuickSyncEncoder::get_usable_va_display()
                                fprintf(stderr, "Autodetected %s as a suitable replacement; using it.\n",
                                        path.c_str());
                                globfree(&g);
+                               if (need_env_reset) {
+                                       unsetenv("LIBVA_MESSAGING_LEVEL");
+                               }
                                return path;
                        }
                }