From patchwork Thu Jan 3 22:29:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Muresan X-Patchwork-Id: 16100 Received: from localhost ([127.0.0.1] helo=www.linuxtv.org) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TqtIb-0006hI-1P; Thu, 03 Jan 2013 23:30:05 +0100 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TqtIY-0006hD-HV for vdr@linuxtv.org; Thu, 03 Jan 2013 23:30:03 +0100 X-tubIT-Incoming-IP: 74.125.83.48 Received: from mail-ee0-f48.google.com ([74.125.83.48]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtps [TLSv1:RC4-SHA:128] for id 1TqtIY-0002WA-E4; Thu, 03 Jan 2013 23:30:02 +0100 Received: by mail-ee0-f48.google.com with SMTP id b57so7570301eek.7 for ; Thu, 03 Jan 2013 14:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type; bh=7ZWLSPtWpWtwnY+N5H7MZLIcDBWxRhZ+/ENuf7+QTW4=; b=dl1b17KP4uDvGC0sOGEivHmTDsKTcrQfmdBQn9hzAqFww2PpXEnXwCfS8ADHOt7k+P gEBxitPQ2r2InuKTZGcL3wLjeuFCSzReS1os39RvAHN/xVvrX+apjTPLocnYYHvl3wke 8wCjWTRnJoGbDmHy1eYi9PXA1XPudVtbtdmzaDd1tTI7Uhxd2MJxY2UrsiYWqgqRzSjW KrYUyFSc2uveGfB+0H8or2k4d662cRoycBo1zgtFdxYtQU7sv82sazTwDhdz00WLffPJ RkxRsW8NWvftyleBIZB8LJscNCueahxbD5vruZR22KP5EP7lOscrwTpVJa8FP1HwDDmZ OYBg== X-Received: by 10.14.173.69 with SMTP id u45mr137774303eel.21.1357252201543; Thu, 03 Jan 2013 14:30:01 -0800 (PST) Received: from [192.168.178.24] (p549553A5.dip.t-dialin.net. [84.149.83.165]) by mx.google.com with ESMTPS id f6sm106761701eeo.7.2013.01.03.14.29.59 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 14:30:00 -0800 (PST) Message-ID: <50E60666.8090300@users.sourceforge.net> Date: Thu, 03 Jan 2013 23:29:58 +0100 From: Lucian Muresan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.1 MIME-Version: 1.0 To: VDR Mailing List References: <50D77F4A.8060004@users.sourceforge.net> <50DA063D.3030402@gmx.de> In-Reply-To: <50DA063D.3030402@gmx.de> X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2013.1.3.222129 X-PMX-Spam: Gauge=X, Probability=10%, Report=' WEBMAIL_REPLYTO_NOT_FROM 0.5, HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, NO_URI_FOUND 0, RATWARE_LC_DIGITS_MSGID 0, WEBMAIL_SOURCE 0, __BAT_BOUNDARY 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_MEDIA_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_SENDER 0, __HAS_FROM 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __PHISH_SPEAR_STRUCTURE_1 0, __RDNS_GMAIL 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __USER_AGENT 0, __YOUTUBE_RCVD 0' X-LSpam-Score: -0.8 (/) X-LSpam-Report: No, score=-0.8 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RDNS_NONE=0.793, T_DKIM_INVALID=0.01 autolearn=no Subject: Re: [vdr] [PATCH] (v2) vdr-xine-0.9.4 vdr-1.7.33 video scaling API (YAEPG-Hack now obsolete) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: vdr-bounces@linuxtv.org Errors-To: vdr-bounces@linuxtv.org Hello, On 12/25/2012 09:02 PM, Reinhard Nissl wrote: > Hi, > [..] > > I appreciate your patches and will have a look at it during the next days. after some clarifications of the new API, thanks to Klaus and "Johns" the author of the softhddevice output device plugin, here is a new version of the scaling API patch for vdr-xine. Regards, Lucian diff -Naur xine-0.9.4_orig/xineDevice.c xine-0.9.4/xineDevice.c --- xine-0.9.4_orig/xineDevice.c 2011-02-27 19:14:19.000000000 +0100 +++ xine-0.9.4/xineDevice.c 2013-01-03 21:54:57.585874032 +0100 @@ -4405,5 +4405,83 @@ { return theXineDevice; } +#if APIVERSNUM >= 10733 + ///< Asks the output device whether it can scale the currently shown video in + ///< such a way that it fits into the given Rect, while retaining its proper + ///< aspect ratio. If the scaled video doesn't exactly fit into Rect, Alignment + ///< is used to determine how to align the actual rectangle with the requested + ///< one. The actual rectangle can be smaller, larger or the same size as the + ///< given Rect, and its location may differ, depending on the capabilities of + ///< the output device, which may not be able to display a scaled video at + ///< arbitrary sizes and locations. The device shall, however, do its best to + ///< match the requested Rect as closely as possible, preferring a size and + ///< location that fits completely into the requested Rect if possible. + ///< Returns the rectangle that can actually be used when scaling the video. + ///< A skin plugin using this function should rearrange its content according + ///< to the rectangle returned from calling this function, and should especially + ///< be prepared for cases where the returned rectangle is way off the requested + ///< Rect, or even Null. In such cases, the skin may want to fall back to + ///< working with full screen video. + ///< If this device can't scale the video, a Null rectangle is returned (this + ///< is also the default implementation). + cRect cXineDevice::CanScaleVideo(const cRect &Rect, int Alignment/* = taCenter*/) + { + // first implementation: we can always scale, we're a soft device ;-), ignore alignment for now + + // we need to store the value for the case we have to call ScaleVideo ourselves in vdr-xine + vidWinRect = Rect; + return vidWinRect; + } + + ///< Scales the currently shown video in such a way that it fits into the given + ///< Rect. Rect should be one retrieved through a previous call to + ///< CanScaleVideo() (otherwise results may be undefined). + ///< Even if video output is scaled, the functions GetVideoSize() and + ///< GetOsdSize() must still return the same values as if in full screen mode! + ///< If this device can't scale the video, nothing happens. + ///< To restore full screen video, call this function with a Null rectangle. + void cXineDevice::ScaleVideo(const cRect &Rect/* = cRect::Null*/) + { + // refresh stored value + vidWinRect = Rect; + // let our specialized code do the actual resizing / repositioning, get accurate parameters first + int videoLeft, videoTop, videoWidth, videoHeight, videoZoomX, videoZoomY, osdWidth, osdHeight; + double videoAspect, pixelAspect; + m_xineLib.execFuncVideoSize(videoLeft, videoTop, videoWidth, videoHeight, videoZoomX, videoZoomY, &videoAspect); + GetOsdSize(osdWidth, osdHeight, pixelAspect); + tArea vidWinArea; + vidWinArea.x1 = vidWinRect.X(); + vidWinArea.y1 = vidWinRect.Y(); + vidWinArea.x2 = vidWinRect.X() + vidWinRect.Width(); + vidWinArea.y2 = vidWinRect.Y() + vidWinRect.Height(); + if (vidWinRect == cRect::Null) { + // will just resize to full size + vidWinArea.bpp = 0; + } else { + vidWinArea.bpp = 12; + // make corrections + double aspectFactor = (double(osdWidth) / double(osdHeight)) / videoAspect; + int output_width = vidWinRect.Height() * (videoAspect * aspectFactor); + int output_height = vidWinRect.Width() / (videoAspect * aspectFactor); + if (double(vidWinRect.Width())/double(vidWinRect.Height()) > videoAspect * aspectFactor) { + output_height = vidWinRect.Height(); + vidWinArea.x1 += (vidWinRect.Width() - output_width) / 2; + } + else if (double(vidWinRect.Width())/double(vidWinRect.Height()) < videoAspect * aspectFactor) { + output_width = vidWinRect.Width(); + vidWinArea.y1 += (vidWinRect.Height() - output_height) / 2; + } + vidWinArea.x2 = vidWinArea.x1 + output_width; + vidWinArea.y2 = vidWinArea.y1 + output_height; + } + m_xineLib.SetVideoWindow(videoWidth, videoHeight, vidWinArea); + } + + const cRect & cXineDevice::GetScaleRect() + { + // just return the stored value + return vidWinRect; + } +#endif // APIVERSNUM >= 10733 }; diff -Naur xine-0.9.4_orig/xineDevice.h xine-0.9.4/xineDevice.h --- xine-0.9.4_orig/xineDevice.h 2011-02-27 15:28:58.000000000 +0100 +++ xine-0.9.4/xineDevice.h 2013-01-03 21:55:07.480878044 +0100 @@ -162,7 +162,14 @@ #else void OnFreeOsd(cOsd *const osd); #endif - +#if APIVERSNUM >= 10733 + virtual cRect CanScaleVideo(const cRect &Rect, int Alignment = taCenter); + virtual void ScaleVideo(const cRect &Rect = cRect::Null); + const cRect & GetScaleRect(); + private: + cRect vidWinRect; + public: +#endif // APIVERSNUM >= 10733 cXineLib m_xineLib; cMutex m_osdMutex; diff -Naur xine-0.9.4_orig/xineOsd.c xine-0.9.4/xineOsd.c --- xine-0.9.4_orig/xineOsd.c 2011-03-15 21:00:18.000000000 +0100 +++ xine-0.9.4/xineOsd.c 2013-01-03 21:54:10.282851266 +0100 @@ -105,11 +105,20 @@ #else +#if APIVERSNUM >= 10733 + + // scale to the size and position stored by the last call to cDevice::CanScaleVideo + m_xineDevice.ScaleVideo(m_xineDevice.GetScaleRect()); + +#else + #ifdef SET_VIDEO_WINDOW m_xineLib.SetVideoWindow(maxOsdWidth, maxOsdHeight, vidWin, dontOptimize); #endif + +#endif // APIVERSNUM >= 10733 int videoLeft = frameLeft; int videoTop = frameTop; @@ -175,6 +184,7 @@ cXineOsd::~cXineOsd() { + #if APIVERSNUM < 10509 HideOsd(); #else