rendered paste bodyIndex: libhb/deinterlace.c===================================================================--- libhb/deinterlace.c (revision 1474)+++ libhb/deinterlace.c (working copy)@@ -34,6 +34,7 @@ struct hb_filter_private_s {+ int cpu_count; int pix_fmt; int width[3]; int height[3];@@ -84,6 +85,17 @@ hb_deinterlace_close, }; +struct yadif_arguments{+ uint8_t **dst;+ int parity;+ int tff;+ int plane;+ hb_filter_private_t * pv;+ int y;+};++struct yadif_arguments yadif_arguments_array[4];+ static void yadif_store_ref( const uint8_t ** pic, hb_filter_private_t * pv ) {@@ -185,11 +197,61 @@ } } +void yadif_filter_segment( void *yadif_args )+{+ struct yadif_arguments *segment_data;+ segment_data = (struct yadif_arguments *) yadif_args;++ uint8_t **dst = segment_data->dst;+ int parity = segment_data->parity;+ int tff = segment_data->tff;+ int i = segment_data->plane;+ hb_filter_private_t * pv = segment_data->pv;+ int y;++ int w = pv->width[i];+ int h = pv->height[i];+ int ref_stride = pv->yadif_ref_stride[i];++ for( y = 0 ; y < h; y = y++ )+ {+ if( (y ^ parity) & 1 )+ {+ uint8_t *prev = &pv->yadif_ref[0][i][y*ref_stride];+ uint8_t *cur = &pv->yadif_ref[1][i][y*ref_stride];+ uint8_t *next = &pv->yadif_ref[2][i][y*ref_stride];+ uint8_t *dst2 = &dst[i][y*w];++ yadif_filter_line( dst2, prev, cur, next, i, parity ^ tff, pv );++ }+ else+ {+ memcpy( &dst[i][y*w],+ &pv->yadif_ref[1][i][y*ref_stride],+ w * sizeof(uint8_t) );+ }+ }+}+ static void yadif_filter( uint8_t ** dst, int parity, int tff, hb_filter_private_t * pv ) {++ int thread_count = 3;+ hb_thread_t * yadif_threads[thread_count];++ int j;+ for( j = 0; j < thread_count; j++)+ {+ yadif_arguments_array[j].parity = parity;+ yadif_arguments_array[j].pv = pv;+ yadif_arguments_array[j].tff = tff;+ yadif_arguments_array[j].dst = dst;+ }+ int i; for( i = 0; i < 3; i++ ) {@@ -197,26 +259,15 @@ int h = pv->height[i]; int ref_stride = pv->yadif_ref_stride[i]; - int y;- for( y = 0; y < h; y++ )- {- if( (y ^ parity) & 1 )- {- uint8_t *prev = &pv->yadif_ref[0][i][y*ref_stride];- uint8_t *cur = &pv->yadif_ref[1][i][y*ref_stride];- uint8_t *next = &pv->yadif_ref[2][i][y*ref_stride];- uint8_t *dst2 = &dst[i][y*w];+ yadif_arguments_array[i].plane = i; - yadif_filter_line( dst2, prev, cur, next, i, parity ^ tff, pv );- }- else- {- memcpy( &dst[i][y*w],- &pv->yadif_ref[1][i][y*ref_stride],- w * sizeof(uint8_t) );- }- }+ yadif_threads[i] = hb_thread_init( "yadif_segment", yadif_filter_segment, &yadif_arguments_array[i], HB_NORMAL_PRIORITY ); }++ for(j = 0; j < thread_count; j++)+ {+ hb_thread_close( &yadif_threads[j]);+ } } static void mcdeint_filter( uint8_t ** dst,@@ -344,6 +395,8 @@ hb_filter_private_t * pv = calloc( 1, sizeof(struct hb_filter_private_s) ); + pv->cpu_count = hb_get_cpu_count();+ pv->pix_fmt = pix_fmt; pv->width[0] = width;