]> git.sesse.net Git - vlc/blobdiff - modules/video_output/kva.c
sftp: change item b_net
[vlc] / modules / video_output / kva.c
index 6a44cb3237a9e0b32ac7aaea0424f71e521624ad..eb9aed4a991d15b277f07b1c8a426fde8299ee69 100644 (file)
@@ -101,7 +101,6 @@ struct vout_display_sys_t
     HWND               parent;
     RECTL              parent_rect;
     picture_pool_t    *pool;
-    picture_resource_t resource;
     unsigned           button_pressed;
     bool               is_mouse_hidden;
     bool               is_on_top;
@@ -152,7 +151,8 @@ static void PMThread( void *arg )
     ULONG i_kva_mode;
 
     /* */
-    video_format_t fmt = vd->fmt;
+    video_format_t fmt;
+    video_format_ApplyRotation(&fmt, &vd->fmt);
 
     /* */
     vout_display_info_t info = vd->info;
@@ -175,32 +175,14 @@ static void PMThread( void *arg )
     sys->b_fixt23 = var_CreateGetBool( vd, "kva-fixt23");
 
     if( !sys->b_fixt23 )
-    {
-        vout_window_cfg_t wnd_cfg;
-
-        wnd_cfg.is_standalone = false;
-        wnd_cfg.type          = VOUT_WINDOW_TYPE_HWND;
-        wnd_cfg.x             = var_InheritInteger(vd, "video-x");
-        wnd_cfg.y             = var_InheritInteger(vd, "video-y");
-        wnd_cfg.width         = vd->cfg->display.width;
-        wnd_cfg.height        = vd->cfg->display.height;
-
         /* If an external window was specified, we'll draw in it. */
         sys->parent_window =
-            vout_display_NewWindow( vd, &wnd_cfg );
-    }
+            vout_display_NewWindow( vd, VOUT_WINDOW_TYPE_HWND );
 
     if( sys->parent_window )
     {
         sys->parent = ( HWND )sys->parent_window->handle.hwnd;
 
-        /* Workaround :
-         * When an embedded window opened first, it is not positioned
-         * correctly. So reposition it here, again.
-         */
-        WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
-                         HWND_TOP, 0, 0, 0, 0, SWP_MOVE );
-
         ULONG i_style = WinQueryWindowULong( sys->parent, QWL_STYLE );
         WinSetWindowULong( sys->parent, QWL_STYLE,
                            i_style | WS_CLIPCHILDREN );
@@ -274,14 +256,9 @@ static void PMThread( void *arg )
         goto exit_open_display;
     }
 
-    if( vd->cfg->is_fullscreen )
-    {
-        if( sys->parent_window )
-            vout_window_SetFullScreen(sys->parent_window, true);
-        else
-            WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE,
-                        MPFROMLONG( true ), 0 );
-    }
+    if( vd->cfg->is_fullscreen && !sys->parent_window )
+        WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE,
+                    MPFROMLONG( true ), 0 );
 
     kvaDisableScreenSaver();
 
@@ -382,7 +359,7 @@ static void Close ( vlc_object_t *object )
     DosWaitThread( &sys->tid, DCWW_WAIT );
 
     if( sys->pool )
-        picture_pool_Delete( sys->pool );
+        picture_pool_Release( sys->pool );
 
     DosCloseEventSem( sys->ack_event );
 
@@ -456,14 +433,9 @@ static int Control( vout_display_t *vd, int query, va_list args )
 
     case VOUT_DISPLAY_CHANGE_FULLSCREEN:
     {
-        vout_display_cfg_t cfg = *va_arg(args, const vout_display_cfg_t *);
-
-        if( sys->parent_window )
-            vout_window_SetFullScreen(sys->parent_window, cfg.is_fullscreen);
-        else
-            WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE,
-                        MPFROMLONG( cfg.is_fullscreen ), 0 );
+        bool fs = va_arg(args, int);
 
+        WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE, MPFROMLONG(fs), 0 );
         return VLC_SUCCESS;
     }
 
@@ -472,12 +444,7 @@ static int Control( vout_display_t *vd, int query, va_list args )
         const unsigned state = va_arg( args, unsigned );
         const bool is_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
 
-        if( sys->parent_window )
-        {
-            if( vout_window_SetState( sys->parent_window, state ))
-                return VLC_EGENERIC;
-        }
-        else if( is_on_top )
+        if( is_on_top )
             WinSetWindowPos( sys->frame, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
 
         sys->is_on_top = is_on_top;
@@ -486,54 +453,40 @@ static int Control( vout_display_t *vd, int query, va_list args )
     }
 
     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+    case VOUT_DISPLAY_CHANGE_ZOOM:
     {
         const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
-        bool  is_forced = va_arg(args, int);
-
-        if( is_forced )
-        {
-            if( sys->parent_window )
-            {
-                vout_window_SetSize(sys->parent_window,
-                                    cfg->display.width, cfg->display.height);
-
-                /* Workaround :
-                 * If changing aspect ratio after resizing a main window,
-                 * an embedded window is misplaced. So reposition it, here.
-                 */
-                WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
-                                 HWND_TOP, 0, 1, 0, 0, SWP_MOVE );
-                WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
-                                 HWND_TOP, 0, 0, 0, 0, SWP_MOVE );
-            }
-            else
-                WinPostMsg( sys->client, WM_VLC_SIZE_CHANGE,
-                            MPFROMLONG( cfg->display.width ),
-                            MPFROMLONG( cfg->display.height ));
-        }
 
+        WinPostMsg( sys->client, WM_VLC_SIZE_CHANGE,
+                    MPFROMLONG( cfg->display.width ),
+                    MPFROMLONG( cfg->display.height ));
         return VLC_SUCCESS;
     }
 
     case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
     case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
     {
-        const video_format_t *source = va_arg(args, const video_format_t *);
+        const video_format_t *src = va_arg(args, const video_format_t *);
 
         if( query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT )
         {
-            sys->kvas.ulAspectWidth  = ( int64_t )source->i_width *
-                                       source->i_sar_num / source->i_sar_den;
-            sys->kvas.ulAspectHeight = source->i_height;
+            vout_display_place_t place;
+            vout_display_PlacePicture(&place, src, vd->cfg, false);
+
+            sys->kvas.ulAspectWidth  = place.width;
+            sys->kvas.ulAspectHeight = place.height;
         }
         else
         {
-            sys->kvas.rclSrcRect.xLeft   = source->i_x_offset;
-            sys->kvas.rclSrcRect.yTop    = source->i_y_offset;
-            sys->kvas.rclSrcRect.xRight  = source->i_x_offset +
-                                           source->i_visible_width;
-            sys->kvas.rclSrcRect.yBottom = source->i_y_offset +
-                                           source->i_visible_height;
+            video_format_t src_rot;
+            video_format_ApplyRotation(&src_rot, src);
+
+            sys->kvas.rclSrcRect.xLeft   = src_rot.i_x_offset;
+            sys->kvas.rclSrcRect.yTop    = src_rot.i_y_offset;
+            sys->kvas.rclSrcRect.xRight  = src_rot.i_x_offset +
+                                           src_rot.i_visible_width;
+            sys->kvas.rclSrcRect.yBottom = src_rot.i_y_offset +
+                                           src_rot.i_visible_height;
         }
 
         kvaSetup( &sys->kvas );
@@ -543,8 +496,6 @@ static int Control( vout_display_t *vd, int query, va_list args )
 
     case VOUT_DISPLAY_RESET_PICTURES:
     case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
-    case VOUT_DISPLAY_CHANGE_ZOOM:
-    case VOUT_DISPLAY_GET_OPENGL:
         /* TODO */
         break;
     }
@@ -649,16 +600,16 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
     msg_Dbg( vd, "output chroma = %4.4s", ( const char * )&fmt->i_chroma );
     msg_Dbg( vd, "KVA chroma = %4.4s", ( const char * )&i_kva_fourcc );
 
-    w = vd->source.i_width;
-    h = vd->source.i_height;
+    w = fmt->i_width;
+    h = fmt->i_height;
 
     sys->kvas.ulLength           = sizeof( KVASETUP );
     sys->kvas.szlSrcSize.cx      = w;
     sys->kvas.szlSrcSize.cy      = h;
-    sys->kvas.rclSrcRect.xLeft   = 0;
-    sys->kvas.rclSrcRect.yTop    = 0;
-    sys->kvas.rclSrcRect.xRight  = w;
-    sys->kvas.rclSrcRect.yBottom = h;
+    sys->kvas.rclSrcRect.xLeft   = fmt->i_x_offset;
+    sys->kvas.rclSrcRect.yTop    = fmt->i_y_offset;
+    sys->kvas.rclSrcRect.xRight  = fmt->i_x_offset + fmt->i_visible_width;
+    sys->kvas.rclSrcRect.yBottom = fmt->i_y_offset + fmt->i_visible_height;
     sys->kvas.ulRatio            = KVAR_FORCEANY;
     sys->kvas.ulAspectWidth      = w;
     sys->kvas.ulAspectHeight     = h;
@@ -673,24 +624,19 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
     }
 
     /* Create the associated picture */
-    picture_resource_t *rsc = &sys->resource;
-    rsc->p_sys = malloc( sizeof( *rsc->p_sys ));
-    if( !rsc->p_sys )
-        return VLC_EGENERIC;
-
-    rsc->p_sys->i_chroma_shift = i_chroma_shift;
+    picture_sys_t *picsys = malloc( sizeof( *picsys ) );
+    if( picsys == NULL )
+        return VLC_ENOMEM;
+    picsys->i_chroma_shift = i_chroma_shift;
 
-    for( int i = 0; i < PICTURE_PLANE_MAX; i++ )
+    picture_resource_t resource = { .p_sys = picsys };
+    picture_t *picture = picture_NewFromResource( fmt, &resource );
+    if( !picture )
     {
-        rsc->p[ i ].p_pixels = NULL;
-        rsc->p[ i ].i_pitch  = 0;
-        rsc->p[ i ].i_lines  = 0;
+        free( picsys );
+        return VLC_ENOMEM;
     }
 
-    picture_t *picture = picture_NewFromResource( fmt, rsc );
-    if( !picture )
-        goto exit_picture;
-
     /* Wrap it into a picture pool */
     picture_pool_configuration_t pool_cfg;
     memset( &pool_cfg, 0, sizeof( pool_cfg ));
@@ -703,8 +649,7 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
     if( !sys->pool )
     {
         picture_Release( picture );
-
-        goto exit_picture;
+        return VLC_ENOMEM;
     }
 
     if (vd->cfg->display.title)
@@ -742,11 +687,6 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
                      SWP_ACTIVATE );
 
     return VLC_SUCCESS;
-
-exit_picture:
-    free( rsc->p_sys );
-
-    return VLC_EGENERIC;
 }
 
 /*****************************************************************************