[vlc-devel] commit: Added video_format/es_format_IsSimilar helper. (Laurent Aimar )
git version control
git at videolan.org
Sat Jun 6 00:57:58 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jun 6 00:37:13 2009 +0200| [50b81b0917707e975c9e3d7d765b27ffb82033ef] | committer: Laurent Aimar
Added video_format/es_format_IsSimilar helper.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=50b81b0917707e975c9e3d7d765b27ffb82033ef
---
include/vlc_es.h | 14 ++++++++++
src/libvlccore.sym | 2 +
src/misc/es_format.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/include/vlc_es.h b/include/vlc_es.h
index c315c5f..7c5846f 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -178,6 +178,12 @@ static inline void video_format_Clean( video_format_t *p_src )
VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect ) );
/**
+ * This function will check if the first video format is similar
+ * to the second one.
+ */
+VLC_EXPORT( bool, video_format_IsSimilar, ( const video_format_t *, const video_format_t * ) );
+
+/**
* subtitles format description
*/
struct subs_format_t
@@ -293,4 +299,12 @@ VLC_EXPORT( int, es_format_Copy, ( es_format_t *p_dst, const es_format_t *p_src
*/
VLC_EXPORT( void, es_format_Clean, ( es_format_t *fmt ) );
+/**
+ * This function will check if the first ES format is similar
+ * to the second one.
+ *
+ * All descriptive fields are ignored.
+ */
+VLC_EXPORT( bool, es_format_IsSimilar, ( const es_format_t *, const es_format_t * ) );
+
#endif
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index c2f2688..8c81d00 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -121,6 +121,7 @@ EnsureUTF8
es_format_Clean
es_format_Copy
es_format_Init
+es_format_IsSimilar
filename_sanitize
filter_Blend
filter_chain_AppendFilter
@@ -442,6 +443,7 @@ var_SetChecked
__var_TriggerCallback
__var_Type
video_format_FixRgb
+video_format_IsSimilar
video_format_Setup
vlc_avcodec_mutex
vlc_b64_decode
diff --git a/src/misc/es_format.c b/src/misc/es_format.c
index d5eaa47..201b004 100644
--- a/src/misc/es_format.c
+++ b/src/misc/es_format.c
@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_es.h>
+#include <vlc_aout.h>
/*****************************************************************************
@@ -201,6 +202,35 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma, int i_wid
break;
}
}
+bool video_format_IsSimilar( const video_format_t *p_fmt1, const video_format_t *p_fmt2 )
+{
+ video_format_t v1 = *p_fmt1;
+ video_format_t v2 = *p_fmt2;
+
+ if( v1.i_chroma != v2.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 )
+ 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 )
+ {
+ video_format_FixRgb( &v1 );
+ video_format_FixRgb( &v2 );
+
+ if( v1.i_rmask != v2.i_rmask ||
+ v1.i_gmask != v2.i_gmask ||
+ v1.i_bmask != v2.i_bmask )
+ return false;
+ }
+ return true;
+}
void es_format_Init( es_format_t *fmt,
int i_cat, vlc_fourcc_t i_codec )
@@ -313,3 +343,43 @@ void es_format_Clean( es_format_t *fmt )
memset( fmt, 0, sizeof(*fmt) );
}
+bool es_format_IsSimilar( const es_format_t *p_fmt1, const es_format_t *p_fmt2 )
+{
+ if( p_fmt1->i_cat != p_fmt2->i_cat ||
+ vlc_fourcc_GetCodec( p_fmt1->i_cat, p_fmt1->i_codec ) !=
+ vlc_fourcc_GetCodec( p_fmt2->i_cat, p_fmt2->i_codec ) )
+ return false;
+
+ switch( p_fmt1->i_cat )
+ {
+ case AUDIO_ES:
+ {
+ audio_format_t a1 = p_fmt1->audio;
+ audio_format_t a2 = p_fmt2->audio;
+
+ if( a1.i_format && a2.i_format && a1.i_format != a2.i_format )
+ return false;
+ if( a1.i_rate != a2.i_rate ||
+ a1.i_physical_channels != a2.i_physical_channels ||
+ a1.i_original_channels != a2.i_original_channels )
+ return false;
+ return true;
+ }
+
+ case VIDEO_ES:
+ {
+ video_format_t v1 = p_fmt1->video;
+ video_format_t v2 = p_fmt2->video;
+ if( !v1.i_chroma )
+ v1.i_chroma = vlc_fourcc_GetCodec( p_fmt1->i_cat, p_fmt1->i_codec );
+ if( !v2.i_chroma )
+ v2.i_chroma = vlc_fourcc_GetCodec( p_fmt1->i_cat, p_fmt2->i_codec );
+ return video_format_IsSimilar( &p_fmt1->video, &p_fmt2->video );
+ }
+
+ case SPU_ES:
+ default:
+ return true;
+ }
+}
+
More information about the vlc-devel
mailing list