diff --git a/modules/video_filter/deinterlace/algo_yadif.c b/modules/video_filter/deinterlace/algo_yadif.c
index 0a9efdb..aaf48e4 100644
--- a/modules/video_filter/deinterlace/algo_yadif.c
+++ b/modules/video_filter/deinterlace/algo_yadif.c
@@ -108,19 +108,33 @@ int RenderYadif( filter_t *p_filter, picture_t *p_dst, picture_t *p_src,
void (*filter)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next,
int w, int prefs, int mrefs, int parity, int mode);
- filter = yadif_filter_line_c;
-#if defined(HAVE_YADIF_MMX)
- if( vlc_CPU() & CPU_CAPABILITY_MMX )
- filter = yadif_filter_line_mmx;
+ bool b_bit_depth_not_8bit =
+ ( p_filter->fmt_in.video.i_chroma == VLC_CODEC_I420_10L ||
+ p_filter->fmt_in.video.i_chroma == VLC_CODEC_I422_10L );
+
+#if defined(HAVE_YADIF_SSSE3)
+ if( vlc_CPU() & CPU_CAPABILITY_SSSE3 )
+ filter = yadif_filter_line_ssse3;
+ else
#endif
#if defined(HAVE_YADIF_SSE2)
if( vlc_CPU() & CPU_CAPABILITY_SSE2 )
filter = yadif_filter_line_sse2;
+ else
#endif
-#if defined(HAVE_YADIF_SSSE3)
- if( vlc_CPU() & CPU_CAPABILITY_SSSE3 )
- filter = yadif_filter_line_ssse3;
+#if defined(HAVE_YADIF_MMX)
+ if( vlc_CPU() & CPU_CAPABILITY_MMX )
+ filter = yadif_filter_line_mmx;
+ else
#endif
+ {
+ filter = yadif_filter_line_c;
+ }
+
+ // FIXME: Currenyly filter method for 10-bit and 16-bit chroma
+ // implemented in C, asm code needed!
+ if( b_bit_depth_not_8bit )
+ filter = yadif_filter_line_c_16bit;
for( int n = 0; n < p_dst->i_planes; n++ )
{
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 60b5f45..743982a 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -280,13 +280,51 @@ void GetOutputFormat( filter_t *p_filter,
bool IsChromaSupported( vlc_fourcc_t i_chroma )
{
return i_chroma == VLC_CODEC_I420 ||
+ i_chroma == VLC_CODEC_I420_10L ||
i_chroma == VLC_CODEC_J420 ||
i_chroma == VLC_CODEC_YV12 ||
i_chroma == VLC_CODEC_I422 ||
+ i_chroma == VLC_CODEC_I422_10L ||
i_chroma == VLC_CODEC_J422;
}
/*****************************************************************************
+ * IsChromaSupportedForMode:
+ * return whether the specified chroma is implemented in the specific
+ * deinterlace filter.
+ *****************************************************************************/
+
+bool IsChromaSupportedForMode( vlc_fourcc_t i_chroma, int i_mode )
+{
+ switch( i_mode )
+ {
+ case DEINTERLACE_YADIF:
+ case DEINTERLACE_YADIF2X:
+ return ( i_chroma == VLC_CODEC_I420 ||
+ i_chroma == VLC_CODEC_I420_10L ||
+ i_chroma == VLC_CODEC_J420 ||
+ i_chroma == VLC_CODEC_YV12 ||
+ i_chroma == VLC_CODEC_I422 ||
+ i_chroma == VLC_CODEC_I422_10L ||
+ i_chroma == VLC_CODEC_J422 );
+ case DEINTERLACE_DISCARD:
+ case DEINTERLACE_MEAN:
+ case DEINTERLACE_BLEND:
+ case DEINTERLACE_BOB:
+ case DEINTERLACE_LINEAR:
+ case DEINTERLACE_X:
+ case DEINTERLACE_PHOSPHOR:
+ case DEINTERLACE_IVTC:
+ default:
+ return ( i_chroma == VLC_CODEC_I420 ||
+ i_chroma == VLC_CODEC_J420 ||
+ i_chroma == VLC_CODEC_YV12 ||
+ i_chroma == VLC_CODEC_I422 ||
+ i_chroma == VLC_CODEC_J422 );
+ }
+}
+
+/*****************************************************************************
* video filter2 functions
*****************************************************************************/
@@ -701,6 +739,14 @@ int Open( vlc_object_t *p_this )
char *psz_mode = var_GetNonEmptyString( p_filter, FILTER_CFG_PREFIX "mode" );
SetFilterMethod( p_filter, psz_mode, p_filter->fmt_in.video.i_chroma );
+ if( !IsChromaSupportedForMode( p_filter->fmt_in.video.i_chroma, p_sys->i_mode ) )
+ {
+ char chroma[5] = { 0 };
+ vlc_fourcc_to_char( p_filter->fmt_in.video.i_chroma, chroma );
+ msg_Err( p_filter, "%s is not supported for %s.", psz_mode, chroma );
+ free( psz_mode );
+ return VLC_EGENERIC;
+ }
free( psz_mode );
if( p_sys->i_mode == DEINTERLACE_PHOSPHOR )
diff --git a/modules/video_filter/deinterlace/deinterlace.h b/modules/video_filter/deinterlace/deinterlace.h
index 844a59d..8068b54 100644
--- a/modules/video_filter/deinterlace/deinterlace.h
+++ b/modules/video_filter/deinterlace/deinterlace.h
@@ -158,6 +158,8 @@ void GetOutputFormat( filter_t *p_filter,
*
* Currently, supported chromas are I420, J420 (4:2:0 full scale),
* YV12 (like I420, but YVU), I422 and J422.
+ * Additionaly, I0AL (YUV 4:2:0 10-bit) and I2AL (YUV 4:2:2 10-bit) are
+ * supported for yadif/yadif2x deinerlace filter.
*
* Note for deinterlace hackers: adding support for a new chroma typically
* requires changes to all low-level functions across all the algorithms.
@@ -166,6 +168,16 @@ void GetOutputFormat( filter_t *p_filter,
*/
bool IsChromaSupported( vlc_fourcc_t i_chroma );
+/**
+ * Returns whether the specified chroma is implemented in the specified
+ * deinterlace filter.
+ *
+ * Currently, I0AL (YUV 4:2:0 10-bit) and I2AL (YUV 4:2:2 10-bit) are
+ * only supported for yadif/yadif2x deinterlace filter.
+ *
+ */
+bool IsChromaSupportedForMode( vlc_fourcc_t i_chroma, int i_mode );
+
/*****************************************************************************
* video filter2 functions
*****************************************************************************/
diff --git a/modules/video_filter/deinterlace/yadif.h b/modules/video_filter/deinterlace/yadif.h
index a2fccac..ec4c2ca 100644
--- a/modules/video_filter/deinterlace/yadif.h
+++ b/modules/video_filter/deinterlace/yadif.h
@@ -80,62 +80,68 @@ DECLARE_ASM_CONST(16, const xmm_reg, pw_1) = {0x0001000100010001ULL, 0x000100010
#endif
#endif
+#define CHECK(j)\
+ { int score = FFABS(cur[mrefs-1+(j)] - cur[prefs-1-(j)])\
+ + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
+ + FFABS(cur[mrefs+1+(j)] - cur[prefs+1-(j)]);\
+ if (score < spatial_score) {\
+ spatial_score= score;\
+ spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
+
+#define FILTER \
+ for (x = 0; x < w; x++) { \
+ int c = cur[mrefs]; \
+ int d = (prev2[0] + next2[0])>>1; \
+ int e = cur[prefs]; \
+ int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
+ int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
+ int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
+ int diff = FFMAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2); \
+ int spatial_pred = (c+e)>>1; \
+ int spatial_score = FFABS(cur[mrefs-1] - cur[prefs-1]) + FFABS(c-e) \
+ + FFABS(cur[mrefs+1] - cur[prefs+1]) - 1; \
+ \
+ CHECK(-1) CHECK(-2) }} }} \
+ CHECK( 1) CHECK( 2) }} }} \
+ \
+ if (mode < 2) { \
+ int b = (prev2[2*mrefs] + next2[2*mrefs])>>1; \
+ int f = (prev2[2*prefs] + next2[2*prefs])>>1; \
+ int max = FFMAX3(d-e, d-c, FFMIN(b-c, f-e)); \
+ int min = FFMIN3(d-e, d-c, FFMAX(b-c, f-e)); \
+ \
+ diff = FFMAX3(diff, min, -max); \
+ } \
+ \
+ if (spatial_pred > d + diff) \
+ spatial_pred = d + diff; \
+ else if (spatial_pred < d - diff) \
+ spatial_pred = d - diff; \
+ \
+ dst[0] = spatial_pred; \
+ \
+ dst++; \
+ cur++; \
+ prev++; \
+ next++; \
+ prev2++; \
+ next2++; \
+ }
+
static void yadif_filter_line_c(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode) {
int x;
uint8_t *prev2= parity ? prev : cur ;
uint8_t *next2= parity ? cur : next;
- for(x=0; x<w; x++){
- int c= cur[mrefs];
- int d= (prev2[0] + next2[0])>>1;
- int e= cur[prefs];
- int temporal_diff0= FFABS(prev2[0] - next2[0]);
- int temporal_diff1=( FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1;
- int temporal_diff2=( FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1;
- int diff= FFMAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2);
- int spatial_pred= (c+e)>>1;
- int spatial_score= FFABS(cur[mrefs-1] - cur[prefs-1]) + FFABS(c-e)
- + FFABS(cur[mrefs+1] - cur[prefs+1]) - 1;
-
-#define CHECK(j)\
- { int score= FFABS(cur[mrefs-1+j] - cur[prefs-1-j])\
- + FFABS(cur[mrefs +j] - cur[prefs -j])\
- + FFABS(cur[mrefs+1+j] - cur[prefs+1-j]);\
- if(score < spatial_score){\
- spatial_score= score;\
- spatial_pred= (cur[mrefs +j] + cur[prefs -j])>>1;\
-
- CHECK(-1) CHECK(-2) }} }}
- CHECK( 1) CHECK( 2) }} }}
- if(mode<2){
- int b= (prev2[2*mrefs] + next2[2*mrefs])>>1;
- int f= (prev2[2*prefs] + next2[2*prefs])>>1;
-#if 0
- int a= cur[3*mrefs];
- int g= cur[3*prefs];
- int max= FFMAX3(d-e, d-c, FFMIN3(FFMAX(b-c,f-e),FFMAX(b-c,b-a),FFMAX(f-g,f-e)) );
- int min= FFMIN3(d-e, d-c, FFMAX3(FFMIN(b-c,f-e),FFMIN(b-c,b-a),FFMIN(f-g,f-e)) );
-#else
- int max= FFMAX3(d-e, d-c, FFMIN(b-c, f-e));
- int min= FFMIN3(d-e, d-c, FFMAX(b-c, f-e));
-#endif
-
- diff= FFMAX3(diff, min, -max);
- }
-
- if(spatial_pred > d + diff)
- spatial_pred = d + diff;
- else if(spatial_pred < d - diff)
- spatial_pred = d - diff;
+ FILTER
+}
- dst[0] = spatial_pred;
+static void yadif_filter_line_c_16bit(uint16_t *dst, uint16_t *prev, uint16_t *cur, uint16_t *next, int w, int prefs, int mrefs, int parity, int mode) {
+ int x;
+ uint16_t *prev2= parity ? prev : cur ;
+ uint16_t *next2= parity ? cur : next;
+ mrefs /= 2;
+ prefs /= 2;
- dst++;
- cur++;
- prev++;
- next++;
- prev2++;
- next2++;
- }
+ FILTER
}
-