[vlc-commits] vlcplugin_mac: don' t ask libvlc to scale the video - CA is way more efficient at this

Felix Paul Kühne git at videolan.org
Sat May 18 10:23:39 CEST 2013


npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat May 18 09:45:31 2013 +0200| [92612cb07a0d85874b0093671facc2a3e9a56aef] | committer: Felix Paul Kühne

vlcplugin_mac: don't ask libvlc to scale the video - CA is way more efficient at this

This leads to a 20 to 50 % speedup depending on sample

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=92612cb07a0d85874b0093671facc2a3e9a56aef
---

 npapi/vlcplugin_mac.h  |    4 ++--
 npapi/vlcplugin_mac.mm |   39 ++++++++++++---------------------------
 2 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/npapi/vlcplugin_mac.h b/npapi/vlcplugin_mac.h
index 7cc6d4f..c8fbc8e 100644
--- a/npapi/vlcplugin_mac.h
+++ b/npapi/vlcplugin_mac.h
@@ -81,8 +81,8 @@ public:
     NPError get_root_layer(void *value);
 
     std::vector<char> m_frame_buf;
-    unsigned int m_media_width;
-    unsigned int m_media_height;
+    float m_media_width;
+    float m_media_height;
 
 private:
     void set_player_window();
diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index 146b1d0..350cd1a 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -148,30 +148,15 @@ unsigned VlcPluginMac::video_format_cb(char *chroma,
                                        unsigned *width, unsigned *height,
                                        unsigned *pitches, unsigned *lines)
 {
-    if ( p_browser ) {
-        /* request video in fullscreen size. scaling will be done by CA */
-        NSSize screenSize = [[NSScreen mainScreen] visibleFrame].size;
-        float src_aspect = (float)(*width) / (*height);
-        float dst_aspect = (float)screenSize.width/screenSize.height;
-        if ( src_aspect > dst_aspect ) {
-            if( screenSize.width != (*width) ) { //don't scale if size equal
-                (*width) = screenSize.width;
-                (*height) = static_cast<unsigned>( (*width) / src_aspect + 0.5);
-            }
-        } else {
-            if( screenSize.height != (*height) ) { //don't scale if size equal
-                (*height) = screenSize.height;
-                (*width) = static_cast<unsigned>( (*height) * src_aspect + 0.5);
-            }
-        }
-    }
-
-    m_media_width = (*width);
-    m_media_height = (*height);
+    /* store native video resolution and use it
+     * scaling will be performed by CA, which is more efficient */
+    m_media_width = (float)(*width);
+    m_media_height = (float)(*height);
 
     memcpy(chroma, "RGBA", sizeof("RGBA")-1);
-    (*pitches) = m_media_width * 4;
-    (*lines) = m_media_height;
+
+    (*pitches) = (*width) * 4;
+    (*lines) = (*height);
 
     //+1 for vlc 2.0.3/2.1 bug workaround.
     //They writes after buffer end boundary by some reason unknown to me...
@@ -183,8 +168,8 @@ unsigned VlcPluginMac::video_format_cb(char *chroma,
 void VlcPluginMac::video_cleanup_cb()
 {
     m_frame_buf.resize(0);
-    m_media_width = 0;
-    m_media_height = 0;
+    m_media_width = 0.;
+    m_media_height = 0.;
     [fullscreenWindow orderOut: nil];
 }
 
@@ -212,7 +197,7 @@ void VlcPluginMac::toggle_fullscreen()
 
     if (get_fullscreen() == 0) {
         if (!fullscreenWindow) {
-            /* this window is kind of useless. however, we need to support 10.5, since enterFullScreenMode depends on the 
+            /* this window is kind of useless. however, we need to support 10.5, since enterFullScreenMode depends on the
              * existance of a parent window. This is solved in 10.6 and we should remove the window once we require it. */
             fullscreenWindow = [[VLCFullscreenWindow alloc] initWithContentRect: NSMakeRect(npwindow.x, npwindow.y, npwindow.width, npwindow.height)];
             [fullscreenWindow setLevel: CGShieldingWindowLevel()];
@@ -465,8 +450,8 @@ bool VlcPluginMac::handle_event(void *event)
     if (![self cppPlugin]->playlist_isplaying() || ![self cppPlugin]->player_has_vout())
         return;
 
-    float media_width = (float)[self cppPlugin]->m_media_width;
-    float media_height = (float)[self cppPlugin]->m_media_height;
+    float media_width = [self cppPlugin]->m_media_width;
+    float media_height = [self cppPlugin]->m_media_height;
 
     if (media_width == 0. || media_height == 0.)
         return;



More information about the vlc-commits mailing list