From 42ce53aa09c7eb401ee098075d1a4dc3b1abab29 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 9 May 2025 04:28:17 +0200 Subject: [PATCH] XV-Display: investigate and fix some problems with this XV code Generally speaking, this experiment shows that we need some additional know-how regarding the XVideo standard. And we should re-think the means of integration. From some further debugging end experimenting with this code, the following conlusions can be drawn: - the code retrieves the GDK-Window, to which the widget was mapped - it uses this to access an underlying X-Window - seemingly the docking panel uses a separate X-Window, which also hosts the header area of the panel - this whole underlying X-Window is treated with some compositing method, presumably (just guessing from the code) we use keying with a marker-colour. This explains why the whole area of the panel is no longer updated regularly - furthermore, we need to take into account that the actual display widget area uses some part of this window, which can be found out from the VideoWidget's ''Allocation'' - when correcting the origin of the video display by using this allocation's origin, at least the display of the video is precisely at the right location and size Furthermore, the code takes quite some shortcut and basically looks for one specific display format, and uses the corresponding configuration for the "port" it got. This Format has the Abbreviation "YUY2" (packed) --- src/stage/output/xv-displayer.cpp | 28 ++++++++++------ src/stage/output/xv-displayer.hpp | 11 +++---- wiki/thinkPad.ichthyo.mm | 53 ++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 17 deletions(-) diff --git a/src/stage/output/xv-displayer.cpp b/src/stage/output/xv-displayer.cpp index 231a7f14e..63112da22 100644 --- a/src/stage/output/xv-displayer.cpp +++ b/src/stage/output/xv-displayer.cpp @@ -23,27 +23,32 @@ #include "stage/gtk-base.hpp" #include "stage/output/xv-displayer.hpp" #include "include/logging.h" +//#include "lib/format-cout.hpp" #include namespace stage { namespace output { + namespace { + const uint32_t FORMAT_ID_YUY2 = 0x32595559; + } + XvDisplayer::XvDisplayer(Gtk::Widget& drawing_area - ,int width, int height) + ,uint width, uint height) : Displayer{width,height} , gotPort{false} , drawingArea_{drawing_area} , xvImage{nullptr} { - REQUIRE (width > 0); - REQUIRE (height > 0); + REQUIRE (videoWidth > 0); + REQUIRE (videoHeight > 0); - INFO(stage, "Trying XVideo at %d x %d", width, height); + INFO(stage, "Trying XVideo at %d x %d", videoWidth, videoHeight); shmInfo.shmaddr = NULL; - Glib::RefPtr area_window = drawing_area.get_window(); + Glib::RefPtr area_window = drawingArea_.get_window(); window = GDK_WINDOW_XID (area_window->gobj()); display = GDK_WINDOW_XDISPLAY (area_window->gobj()); @@ -82,7 +87,7 @@ namespace output { ( list[ i ].id >> 16 ) & 0xff, ( list[ i ].id >> 24 ) & 0xff, ( list[ i ].format == XvPacked ) ? "packed" : "planar" ); - if ( list[ i ].id == 0x32595559 && !gotPort ) + if ( list[ i ].id == FORMAT_ID_YUY2 && !gotPort ) gotPort = true; } @@ -143,7 +148,7 @@ namespace output { memset(&values, 0, sizeof(XGCValues)); gc = XCreateGC( display, window, 0, NULL ); - xvImage = ( XvImage * ) XvShmCreateImage( display, grabbedPort, 0x32595559, 0, width, height, &shmInfo ); + xvImage = ( XvImage * ) XvShmCreateImage( display, grabbedPort, FORMAT_ID_YUY2, 0, videoWidth, videoHeight, &shmInfo ); shmInfo.shmid = shmget( IPC_PRIVATE, xvImage->data_size, IPC_CREAT | 0777 ); if (shmInfo.shmid < 0) { @@ -210,14 +215,19 @@ namespace output { if (xvImage != NULL) { - REQUIRE(display != NULL); + REQUIRE (display != NULL); + REQUIRE (drawingArea_.get_mapped()); int org_x = 0, org_y = 0, destW = 0, destH = 0; calculateVideoLayout( drawingArea_.get_width(), drawingArea_.get_height(), org_x, org_y, destW, destH ); - + + auto spaceAlloc = drawingArea_.get_allocation(); + org_x += spaceAlloc.get_x(); + org_y += spaceAlloc.get_y(); + memcpy (xvImage->data, image, xvImage->data_size); XvShmPutImage (display, grabbedPort, window, gc, xvImage, diff --git a/src/stage/output/xv-displayer.hpp b/src/stage/output/xv-displayer.hpp index 84b0cea11..5ba0e33f7 100644 --- a/src/stage/output/xv-displayer.hpp +++ b/src/stage/output/xv-displayer.hpp @@ -52,14 +52,11 @@ namespace output { public: /** * Constructor - * @param drawing_area The widget into which the video image will be - * drawn. This value must not be NULL. - * @param width The width of the video image in pixels. This value - * must be greater than zero. - * @param height The height of the video image in pixels. This value - * must be greater than zero. + * @param drawing_area The widget into which the video image will be drawn. + * @param width of the video image image to be displayed, in pixels. + * @param height of the video image in pixels to be displayed. */ - XvDisplayer (Gtk::Widget& drawing_area, int width, int height); + XvDisplayer (Gtk::Widget& drawing_area, uint width, uint height); ~XvDisplayer(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3dd9048a8..d32879297 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -130051,12 +130051,63 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ beziehe mich hier per Gedächtnis auf Sachverhalte, die ich irgenwann irgendwo mal gelesen habe; demnach kann XV mit irgend einer Art von »Compositor« zusammenarbeiten, notfalls aber seine sichtbare (clipping)-Region auch per Colour-Key herausfinden; dabei geht es um die Frage, welcher Teil des Videobildes tatsächlich auf dem Desktop zu sehen ist, denn das Fenster könnte partiell verdeckt sein +

+ + +
+
+ + + + +
+ + + + + + + +