Skip to content

Commit

Permalink
libhb: fix a bunch of compiler warnings
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5905 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
jstebbins committed Nov 26, 2013
1 parent 58f4654 commit 779fa19
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 47 deletions.
17 changes: 0 additions & 17 deletions libhb/cropscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 15 additions & 7 deletions libhb/fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include "hb.h"
#include "openclwrapper.h"

#ifndef SYS_DARWIN
#include <malloc.h>
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libhb/hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libhb/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
32 changes: 16 additions & 16 deletions libhb/oclscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions libhb/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 1 addition & 3 deletions libhb/openclwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ int hb_release_opencl_env( GPUEnv *gpu_info )

for( i = 0; i<gpu_env.file_count; i++ )
{
if( gpu_env.programs[i] ) ;
if( gpu_env.programs[i] )
{
hb_ocl->clReleaseProgram(gpu_env.programs[i]);
gpu_env.programs[i] = NULL;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions libhb/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions libhb/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 );

Expand Down

0 comments on commit 779fa19

Please sign in to comment.