[vlc-commits] es_format: avoid copy in video_format_IsSimilar() if possible

Rémi Denis-Courmont git at videolan.org
Tue Dec 16 19:00:36 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Dec 16 19:59:57 2014 +0200| [68ead3cb1ecdc4affb88c86a14777884b3e6ac2f] | committer: Rémi Denis-Courmont

es_format: avoid copy in video_format_IsSimilar() if possible

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=68ead3cb1ecdc4affb88c86a14777884b3e6ac2f
---

 src/misc/es_format.c |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/misc/es_format.c b/src/misc/es_format.c
index 27622bc..9060b69 100644
--- a/src/misc/es_format.c
+++ b/src/misc/es_format.c
@@ -373,30 +373,31 @@ void video_format_ApplyRotation( video_format_t *restrict out,
     video_format_TransformTo(out, ORIENT_NORMAL);
 }
 
-bool video_format_IsSimilar( const video_format_t *p_fmt1, const video_format_t *p_fmt2 )
+bool video_format_IsSimilar( const video_format_t *f1,
+                             const video_format_t *f2 )
 {
-    video_format_t v1 = *p_fmt1;
-    video_format_t v2 = *p_fmt2;
-
-    if( v1.i_chroma != v2.i_chroma )
+    if( f1->i_chroma != f2->i_chroma )
         return false;
 
-    if( v1.i_width != v2.i_width || v1.i_height != v2.i_height ||
-        v1.i_visible_width != v2.i_visible_width ||
-        v1.i_visible_height != v2.i_visible_height ||
-        v1.i_x_offset != v2.i_x_offset || v1.i_y_offset != v2.i_y_offset )
+    if( f1->i_width != f2->i_width || f1->i_height != f2->i_height ||
+        f1->i_visible_width != f2->i_visible_width ||
+        f1->i_visible_height != f2->i_visible_height ||
+        f1->i_x_offset != f2->i_x_offset || f1->i_y_offset != f2->i_y_offset )
         return false;
-    if( v1.i_sar_num * v2.i_sar_den != v2.i_sar_num * v1.i_sar_den )
+    if( f1->i_sar_num * f2->i_sar_den != f2->i_sar_num * f1->i_sar_den )
         return false;
 
-    if( v1.orientation != v2.orientation)
+    if( f1->orientation != f2->orientation)
         return false;
 
-    if( v1.i_chroma == VLC_CODEC_RGB15 ||
-        v1.i_chroma == VLC_CODEC_RGB16 ||
-        v1.i_chroma == VLC_CODEC_RGB24 ||
-        v1.i_chroma == VLC_CODEC_RGB32 )
+    if( f1->i_chroma == VLC_CODEC_RGB15 ||
+        f1->i_chroma == VLC_CODEC_RGB16 ||
+        f1->i_chroma == VLC_CODEC_RGB24 ||
+        f1->i_chroma == VLC_CODEC_RGB32 )
     {
+        video_format_t v1 = *f1;
+        video_format_t v2 = *f2;
+
         video_format_FixRgb( &v1 );
         video_format_FixRgb( &v2 );
 



More information about the vlc-commits mailing list