Commit 50b81b09 authored by Laurent Aimar's avatar Laurent Aimar

Added video_format/es_format_IsSimilar helper.

parent 1df51e7c
...@@ -177,6 +177,12 @@ static inline void video_format_Clean( video_format_t *p_src ) ...@@ -177,6 +177,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 ) ); 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 * subtitles format description
*/ */
...@@ -293,4 +299,12 @@ VLC_EXPORT( int, es_format_Copy, ( es_format_t *p_dst, const es_format_t *p_src ...@@ -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 ) ); 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 #endif
...@@ -121,6 +121,7 @@ EnsureUTF8 ...@@ -121,6 +121,7 @@ EnsureUTF8
es_format_Clean es_format_Clean
es_format_Copy es_format_Copy
es_format_Init es_format_Init
es_format_IsSimilar
filename_sanitize filename_sanitize
filter_Blend filter_Blend
filter_chain_AppendFilter filter_chain_AppendFilter
...@@ -442,6 +443,7 @@ var_SetChecked ...@@ -442,6 +443,7 @@ var_SetChecked
__var_TriggerCallback __var_TriggerCallback
__var_Type __var_Type
video_format_FixRgb video_format_FixRgb
video_format_IsSimilar
video_format_Setup video_format_Setup
vlc_avcodec_mutex vlc_avcodec_mutex
vlc_b64_decode vlc_b64_decode
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_es.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 ...@@ -201,6 +202,35 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma, int i_wid
break; 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, void es_format_Init( es_format_t *fmt,
int i_cat, vlc_fourcc_t i_codec ) int i_cat, vlc_fourcc_t i_codec )
...@@ -313,3 +343,43 @@ void es_format_Clean( es_format_t *fmt ) ...@@ -313,3 +343,43 @@ void es_format_Clean( es_format_t *fmt )
memset( fmt, 0, sizeof(*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;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment