From 779fa193b6433f0afadc3fe3c3a6ad72dce54b2c Mon Sep 17 00:00:00 2001 From: jstebbins Date: Tue, 26 Nov 2013 22:12:55 +0000 Subject: libhb: fix a bunch of compiler warnings git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5905 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/cropscale.c | 17 ----------------- libhb/fifo.c | 22 +++++++++++++++------- libhb/hb.c | 2 +- libhb/internal.h | 2 +- libhb/oclscale.c | 32 ++++++++++++++++---------------- libhb/opencl.h | 4 ++++ libhb/openclwrapper.c | 4 +--- libhb/stream.c | 2 ++ libhb/work.c | 4 ++-- 9 files changed, 42 insertions(+), 47 deletions(-) diff --git a/libhb/cropscale.c b/libhb/cropscale.c index f9227562a..7f74a10d7 100644 --- a/libhb/cropscale.c +++ b/libhb/cropscale.c @@ -156,23 +156,6 @@ static void hb_crop_scale_close( hb_filter_object_t * filter ) } /* OpenCL */ -static uint8_t *copy_plane( uint8_t *dst, uint8_t* src, int dstride, int sstride, int h ) -{ - if( dstride == sstride ) - { - memcpy( dst, src, dstride * h ); - return dst + dstride * h; - } - int lbytes = dstride <= sstride ? dstride : sstride; - while( --h >= 0 ) - { - memcpy( dst, src, lbytes ); - src += sstride; - dst += dstride; - } - return dst; -} - static hb_buffer_t* crop_scale( hb_filter_private_t * pv, hb_buffer_t * in ) { AVPicture pic_in; diff --git a/libhb/fifo.c b/libhb/fifo.c index 6887e43c7..a30d66e9a 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -8,6 +8,7 @@ */ #include "hb.h" +#include "openclwrapper.h" #ifndef SYS_DARWIN #include @@ -256,7 +257,7 @@ void hb_buffer_pool_free( void ) /* OpenCL */ if (hb_cl_free_mapped_buffer(b->cl.buffer, b->data) == 0) { - hb_log("hb_buffer_pool_free: bad free: %.16x -> buffer %.16x map %.16x", + hb_log("hb_buffer_pool_free: bad free: %p -> buffer %p map %p", b, b->cl.buffer, b->data); } } @@ -312,7 +313,8 @@ hb_buffer_t * hb_buffer_init_internal( int size , int needsMapped ) /* OpenCL */ if (b != NULL && needsMapped && b->cl.buffer == NULL) { - // We need a mapped OpenCL buffer and that is not what we got out of the pool. + // We need a mapped OpenCL buffer and that is not + // what we got out of the pool. // Ditch it; it will get replaced with what we need. if (b->data != NULL) { @@ -374,18 +376,24 @@ hb_buffer_t * hb_buffer_init_internal( int size , int needsMapped ) if (needsMapped) { int status = hb_cl_create_mapped_buffer(&b->cl.buffer, &b->data, b->alloc); + if (!status) + { + hb_error("Failed to map CL buffer"); + free(b); + return NULL; + } } else { b->cl.buffer = NULL; #if defined( SYS_DARWIN ) || defined( SYS_FREEBSD ) || defined( SYS_MINGW ) - b->data = malloc( b->alloc ); + b->data = malloc( b->alloc ); #elif defined( SYS_CYGWIN ) - /* FIXME */ - b->data = malloc( b->alloc + 17 ); + /* FIXME */ + b->data = malloc( b->alloc + 17 ); #else - b->data = memalign( 16, b->alloc ); + b->data = memalign( 16, b->alloc ); #endif } @@ -642,7 +650,7 @@ void hb_buffer_close( hb_buffer_t ** _b ) /* OpenCL */ if (hb_cl_free_mapped_buffer(b->cl.buffer, b->data) == 0) { - hb_log("hb_buffer_pool_free: bad free %.16x -> buffer %.16x map %.16x", + hb_log("hb_buffer_pool_free: bad free %p -> buffer %p map %p", b, b->cl.buffer, b->data); } } diff --git a/libhb/hb.c b/libhb/hb.c index 73356595e..760683d76 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -51,7 +51,7 @@ struct hb_handle_s int job_count; int job_count_permanent; volatile int work_die; - int work_error; + hb_error_code work_error; hb_thread_t * work_thread; hb_lock_t * state_lock; diff --git a/libhb/internal.h b/libhb/internal.h index 3920cf025..643deb9a2 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -246,7 +246,7 @@ hb_thread_t * hb_scan_init( hb_handle_t *, volatile int * die, hb_title_set_t * title_set, int preview_count, int store_previews, uint64_t min_duration ); hb_thread_t * hb_work_init( hb_list_t * jobs, - volatile int * die, int * error, hb_job_t ** job ); + volatile int * die, hb_error_code * error, hb_job_t ** job ); void ReadLoop( void * _w ); hb_work_object_t * hb_muxer_init( hb_job_t * ); hb_work_object_t * hb_get_work( int ); diff --git a/libhb/oclscale.c b/libhb/oclscale.c index eb59eaa66..00fff9904 100644 --- a/libhb/oclscale.c +++ b/libhb/oclscale.c @@ -67,14 +67,14 @@ int hb_ocl_scale_func( void **data, KernelEnv *kenv ) cl_mem in_buf = data[0]; cl_mem out_buf = data[1]; - int crop_top = data[2]; - int crop_bottom = data[3]; - int crop_left = data[4]; - int crop_right = data[5]; - cl_int in_frame_w = (int)data[6]; - cl_int in_frame_h = (int)data[7]; - cl_int out_frame_w = (int)data[8]; - cl_int out_frame_h = (int)data[9]; + int crop_top = (intptr_t)data[2]; + int crop_bottom = (intptr_t)data[3]; + int crop_left = (intptr_t)data[4]; + int crop_right = (intptr_t)data[5]; + cl_int in_frame_w = (intptr_t)data[6]; + cl_int in_frame_h = (intptr_t)data[7]; + cl_int out_frame_w = (intptr_t)data[8]; + cl_int out_frame_h = (intptr_t)data[9]; hb_oclscale_t *os = data[10]; hb_buffer_t *in = data[11]; hb_buffer_t *out = data[12]; @@ -284,14 +284,14 @@ int hb_ocl_scale(hb_buffer_t *in, hb_buffer_t *out, int *crop, hb_oclscale_t *os data[0] = in->cl.buffer; data[1] = out->cl.buffer; - data[2] = (void*)(crop[0]); - data[3] = (void*)(crop[1]); - data[4] = (void*)(crop[2]); - data[5] = (void*)(crop[3]); - data[6] = (void*)(in->f.width); - data[7] = (void*)(in->f.height); - data[8] = (void*)(out->f.width); - data[9] = (void*)(out->f.height); + data[2] = (void*)(intptr_t)(crop[0]); + data[3] = (void*)(intptr_t)(crop[1]); + data[4] = (void*)(intptr_t)(crop[2]); + data[5] = (void*)(intptr_t)(crop[3]); + data[6] = (void*)(intptr_t)(in->f.width); + data[7] = (void*)(intptr_t)(in->f.height); + data[8] = (void*)(intptr_t)(out->f.width); + data[9] = (void*)(intptr_t)(out->f.height); data[10] = os; data[11] = in; data[12] = out; diff --git a/libhb/opencl.h b/libhb/opencl.h index 2791e1618..5548a9eb6 100644 --- a/libhb/opencl.h +++ b/libhb/opencl.h @@ -21,8 +21,10 @@ #define HB_OCL_FUNC_DECL(name) HB_OCL_FUNC_TYPE(name) name #define HB_OCL_API(ret, attr, name) typedef ret (attr* HB_OCL_FUNC_TYPE(name)) +#ifdef __APPLE__ #pragma mark - #pragma mark OpenCL API +#endif // __APPLE__ /* Platform API */ HB_OCL_API(cl_int, CL_API_CALL, clGetPlatformIDs) @@ -622,7 +624,9 @@ HB_OCL_API(void *, CL_API_CALL, clGetExtensionFunctionAddressForPlatform) (cl_platform_id /* platform */, const char * /* func_name */); +#ifdef __APPLE__ #pragma mark - +#endif // __APPLE__ typedef struct hb_opencl_library_s { diff --git a/libhb/openclwrapper.c b/libhb/openclwrapper.c index 7fb395aba..652cf23d4 100644 --- a/libhb/openclwrapper.c +++ b/libhb/openclwrapper.c @@ -648,7 +648,7 @@ int hb_release_opencl_env( GPUEnv *gpu_info ) for( i = 0; iclReleaseProgram(gpu_env.programs[i]); gpu_env.programs[i] = NULL; @@ -1177,8 +1177,6 @@ int hb_read_opencl_frame_buffer(cl_mem cl_inBuf,unsigned char *Ybuf,unsigned cha int hb_write_opencl_frame_buffer(cl_mem cl_inBuf,unsigned char *Ybuf,unsigned char *Ubuf,unsigned char *Vbuf,int linesize0,int linesize1,int linesize2,int height,int offset) { - int status; - if (hb_ocl == NULL) { hb_error("hb_write_opencl_frame_buffer: OpenCL support not available"); diff --git a/libhb/stream.c b/libhb/stream.c index 5d6ec7f4c..936637147 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -5678,6 +5678,8 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) if ( hb_check_hwd_fmt(pix_fmt) == 0) title->hwd_support = 0; #else + // Eliminate compiler warning "pix_fmt set but not used" + (void)pix_fmt; title->hwd_support = 0; #endif diff --git a/libhb/work.c b/libhb/work.c index 43dbdeaaa..b03ce13e2 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -22,7 +22,7 @@ typedef struct { hb_list_t * jobs; hb_job_t ** current_job; - int * error; + hb_error_code * error; volatile int * die; } hb_work_t; @@ -47,7 +47,7 @@ static void filter_loop( void * ); * @param die Handle to user inititated exit indicator. * @param error Handle to error indicator. */ -hb_thread_t * hb_work_init( hb_list_t * jobs, volatile int * die, int * error, hb_job_t ** job ) +hb_thread_t * hb_work_init( hb_list_t * jobs, volatile int * die, hb_error_code * error, hb_job_t ** job ) { hb_work_t * work = calloc( sizeof( hb_work_t ), 1 ); -- cgit v1.2.3