summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/batch.c10
-rw-r--r--libhb/bd.c6
-rw-r--r--libhb/common.c1
-rw-r--r--libhb/common.h9
-rw-r--r--libhb/cropscale.c10
-rw-r--r--libhb/decavcodec.c2
-rw-r--r--libhb/decomb.c2
-rw-r--r--libhb/detelecine.c2
-rw-r--r--libhb/hb.c24
-rw-r--r--libhb/hb.h4
-rw-r--r--libhb/internal.h23
-rw-r--r--libhb/muxcommon.c6
-rw-r--r--libhb/reader.c6
-rw-r--r--libhb/scan.c26
-rw-r--r--libhb/stream.c27
-rw-r--r--libhb/sync.c4
-rw-r--r--libhb/work.c49
-rw-r--r--test/test.c10
18 files changed, 135 insertions, 86 deletions
diff --git a/libhb/batch.c b/libhb/batch.c
index 3a08152bb..cf751c6d0 100644
--- a/libhb/batch.c
+++ b/libhb/batch.c
@@ -12,8 +12,9 @@
struct hb_batch_s
{
- char * path;
- hb_list_t * list_file;
+ char * path;
+ hb_list_t * list_file;
+ hb_handle_t * h;
};
static int compare_str(const void *a, const void *b)
@@ -26,7 +27,7 @@ static int compare_str(const void *a, const void *b)
***********************************************************************
*
**********************************************************************/
-hb_batch_t * hb_batch_init( char * path )
+hb_batch_t * hb_batch_init( hb_handle_t *h, char * path )
{
hb_batch_t * d;
hb_stat_t sb;
@@ -81,6 +82,7 @@ hb_batch_t * hb_batch_init( char * path )
// Create file list
d = calloc( sizeof( hb_batch_t ), 1 );
+ d->h = h;
d->list_file = hb_list_init();
for (ii = 0; ii < count; ii++)
{
@@ -128,7 +130,7 @@ hb_title_t * hb_batch_title_scan( hb_batch_t * d, int t )
hb_log( "batch: scanning %s", filename );
title = hb_title_init( filename, t );
- stream = hb_stream_open( filename, title, 1 );
+ stream = hb_stream_open(d->h, filename, title, 1);
if ( stream == NULL )
{
hb_title_close( &title );
diff --git a/libhb/bd.c b/libhb/bd.c
index 20979e397..abe13fa5d 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -23,6 +23,7 @@ struct hb_bd_s
hb_stream_t * stream;
int chapter;
int next_chap;
+ hb_handle_t * h;
};
/***********************************************************************
@@ -36,12 +37,13 @@ static int title_info_compare_mpls(const void *, const void *);
***********************************************************************
*
**********************************************************************/
-hb_bd_t * hb_bd_init( char * path )
+hb_bd_t * hb_bd_init( hb_handle_t *h, char * path )
{
hb_bd_t * d;
int ii;
d = calloc( sizeof( hb_bd_t ), 1 );
+ d->h = h;
/* Open device */
d->bd = bd_open( path, NULL );
@@ -635,7 +637,7 @@ int hb_bd_start( hb_bd_t * d, hb_title_t *title )
bd_select_title( d->bd, d->title_info[title->index - 1]->idx );
bd_get_event( d->bd, &event );
d->chapter = 1;
- d->stream = hb_bd_stream_open( title );
+ d->stream = hb_bd_stream_open( d->h, title );
if ( d->stream == NULL )
{
return 0;
diff --git a/libhb/common.c b/libhb/common.c
index 339c3919f..f38444648 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -4387,7 +4387,6 @@ void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * dat
}
}
-int hb_gui_use_hwd_flag = 0;
int hb_use_dxva( hb_title_t * title )
{
return ( (title->video_codec_param == AV_CODEC_ID_MPEG2VIDEO
diff --git a/libhb/common.h b/libhb/common.h
index a8a699387..08e073296 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -71,6 +71,7 @@
#define HB_DVD_READ_BUFFER_SIZE 2048
typedef struct hb_handle_s hb_handle_t;
+typedef struct hb_hwd_s hb_hwd_t;
typedef struct hb_list_s hb_list_t;
typedef struct hb_rate_s hb_rate_t;
typedef struct hb_dither_s hb_dither_t;
@@ -430,8 +431,6 @@ struct hb_title_set_s
int feature; // Detected DVD feature title
};
-extern int hb_gui_use_hwd_flag;
-
typedef enum
{
HB_ANAMORPHIC_NONE,
@@ -581,8 +580,8 @@ struct hb_job_s
// to non-I frames).
int use_opencl;
int use_hwd;
- int use_decomb;
- int use_detelecine;
+ PRIVATE int use_decomb;
+ PRIVATE int use_detelecine;
#ifdef USE_QSV
// QSV-specific settings
@@ -1099,6 +1098,8 @@ struct hb_work_object_s
hb_work_object_t * next;
int thread_sleep_interval;
+
+ hb_handle_t * h;
#endif
};
diff --git a/libhb/cropscale.c b/libhb/cropscale.c
index 15c04c4bb..d1ef0f9bb 100644
--- a/libhb/cropscale.c
+++ b/libhb/cropscale.c
@@ -245,19 +245,19 @@ static int hb_crop_scale_work( hb_filter_object_t * filter,
}
/* OpenCL/DXVA2 */
- if ((!pv->use_decomb && !pv->use_detelecine &&
+ if ((!pv->use_dxva &&
!pv->crop[0] && !pv->crop[1] && !pv->crop[2] && !pv->crop[3] &&
in->f.fmt == pv->pix_fmt_out && in->f.width == pv->width_out &&
- in->f.height == pv->height_out) || (pv->use_dxva &&
- in->f.width == pv->width_out &&
- in->f.height == pv->height_out))
+ in->f.height == pv->height_out) ||
+ (pv->use_dxva && !pv->use_decomb && !pv->use_detelecine &&
+ in->f.width == pv->width_out && in->f.height == pv->height_out))
{
*buf_out = in;
*buf_in = NULL;
return HB_FILTER_OK;
}
- *buf_out = crop_scale( pv, in );
+ *buf_out = crop_scale(pv, in);
return HB_FILTER_OK;
}
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index dffb23a84..32eb4a21a 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1327,7 +1327,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
#endif
// If there was no pts for this frame, assume constant frame rate
// video & estimate the next frame time from the last & duration.
- if (pv->frame->pkt_pts == AV_NOPTS_VALUE || hb_gui_use_hwd_flag == 1)
+ if (pv->frame->pkt_pts == AV_NOPTS_VALUE || hb_hwd_enabled(w->h))
{
pts = pv->pts_next;
}
diff --git a/libhb/decomb.c b/libhb/decomb.c
index ff1d566fa..7a1b4bf66 100644
--- a/libhb/decomb.c
+++ b/libhb/decomb.c
@@ -2432,6 +2432,8 @@ static int hb_decomb_init( hb_filter_object_t * filter,
}
}
+ init->job->use_decomb = 1;
+
return 0;
}
diff --git a/libhb/detelecine.c b/libhb/detelecine.c
index d0eb60344..019286011 100644
--- a/libhb/detelecine.c
+++ b/libhb/detelecine.c
@@ -872,6 +872,8 @@ static int hb_detelecine_init( hb_filter_object_t * filter,
pv->pullup_fakecount = 1;
pv->pullup_skipflag = 0;
+ init->job->use_detelecine = 1;
+
return 0;
}
diff --git a/libhb/hb.c b/libhb/hb.c
index be4d75b9b..7a7429153 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -68,12 +68,32 @@ struct hb_handle_s
hb_interjob_t * interjob;
// power management opaque pointer
- void *system_sleep_opaque;
-} ;
+ void * system_sleep_opaque;
+
+ // When hardware decoding, scan must also use hardware so that
+ // libav hardware decode contest is used. So set hardware
+ // decoding as a global property on the hb instance.
+ hb_hwd_t hwd;
+};
hb_work_object_t * hb_objects = NULL;
int hb_instance_counter = 0;
+void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable )
+{
+ h->hwd.enable = enable;
+}
+
+int hb_hwd_enabled( hb_handle_t *h )
+{
+ return h->hwd.enable;
+}
+
+hb_hwd_t * hb_hwd_get_context( hb_handle_t *h )
+{
+ return &h->hwd;
+}
+
static void thread_func( void * );
static int ff_lockmgr_cb(void **mutex, enum AVLockOp op)
diff --git a/libhb/hb.h b/libhb/hb.h
index 739f16b3f..8f85fa5e9 100644
--- a/libhb/hb.h
+++ b/libhb/hb.h
@@ -29,6 +29,10 @@ void hb_register_logger( void (*log_cb)(const char* message) );
hb_handle_t * hb_init( int verbose, int update_check );
hb_handle_t * hb_init_dl ( int verbose, int update_check ); // hb_init for use with dylib
+void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable );
+int hb_hwd_enabled( hb_handle_t *h );
+hb_hwd_t * hb_hwd_get_context();
+
/* hb_get_version() */
char * hb_get_version( hb_handle_t * );
int hb_get_build( hb_handle_t * );
diff --git a/libhb/internal.h b/libhb/internal.h
index 759f1beb8..727bf8ce3 100644
--- a/libhb/internal.h
+++ b/libhb/internal.h
@@ -11,6 +11,14 @@
#include "extras/cl.h"
/***********************************************************************
+ * Hardware Decode Context
+ **********************************************************************/
+struct hb_hwd_s
+{
+ uint8_t enable;
+};
+
+/***********************************************************************
* common.c
**********************************************************************/
void hb_log( char * log, ... ) HB_WPRINTF(1,2);
@@ -259,9 +267,9 @@ hb_thread_t * hb_work_init( hb_list_t * jobs,
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 );
-hb_work_object_t * hb_codec_decoder( int );
-hb_work_object_t * hb_codec_encoder( int );
+hb_work_object_t * hb_get_work( hb_handle_t *, int );
+hb_work_object_t * hb_codec_decoder( hb_handle_t *, int );
+hb_work_object_t * hb_codec_encoder( hb_handle_t *, int );
/***********************************************************************
* sync.c
@@ -293,7 +301,7 @@ extern const hb_muxer_t hb_demux[];
**********************************************************************/
typedef struct hb_batch_s hb_batch_t;
-hb_batch_t * hb_batch_init( char * path );
+hb_batch_t * hb_batch_init( hb_handle_t *h, char * path );
void hb_batch_close( hb_batch_t ** _d );
int hb_batch_title_count( hb_batch_t * d );
hb_title_t * hb_batch_title_scan( hb_batch_t * d, int t );
@@ -319,7 +327,7 @@ int hb_dvd_angle_count( hb_dvd_t * d );
void hb_dvd_set_angle( hb_dvd_t * d, int angle );
int hb_dvd_main_feature( hb_dvd_t * d, hb_list_t * list_title );
-hb_bd_t * hb_bd_init( char * path );
+hb_bd_t * hb_bd_init( hb_handle_t *h, char * path );
int hb_bd_title_count( hb_bd_t * d );
hb_title_t * hb_bd_title_scan( hb_bd_t * d, int t, uint64_t min_duration );
int hb_bd_start( hb_bd_t * d, hb_title_t *title );
@@ -333,9 +341,10 @@ void hb_bd_close( hb_bd_t ** _d );
void hb_bd_set_angle( hb_bd_t * d, int angle );
int hb_bd_main_feature( hb_bd_t * d, hb_list_t * list_title );
-hb_stream_t * hb_bd_stream_open( hb_title_t *title );
+hb_stream_t * hb_bd_stream_open( hb_handle_t *h, hb_title_t *title );
void hb_ts_stream_reset(hb_stream_t *stream);
-hb_stream_t * hb_stream_open( char * path, hb_title_t *title, int scan );
+hb_stream_t * hb_stream_open(hb_handle_t *h, char * path,
+ hb_title_t *title, int scan);
void hb_stream_close( hb_stream_t ** );
hb_title_t * hb_stream_title_scan( hb_stream_t *, hb_title_t *);
hb_buffer_t * hb_stream_read( hb_stream_t * );
diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c
index ca9502e4c..9b15ee97a 100644
--- a/libhb/muxcommon.c
+++ b/libhb/muxcommon.c
@@ -638,7 +638,7 @@ hb_work_object_t * hb_muxer_init( hb_job_t * job )
/* Initialize the work objects that will receive fifo data */
- muxer = hb_get_work( WORK_MUX );
+ muxer = hb_get_work( job->h, WORK_MUX );
muxer->private_data = calloc( sizeof( hb_work_private_t ), 1 );
muxer->private_data->job = job;
muxer->private_data->mux = mux;
@@ -652,7 +652,7 @@ hb_work_object_t * hb_muxer_init( hb_job_t * job )
{
hb_audio_t *audio = hb_list_item( job->list_audio, i );
- w = hb_get_work( WORK_MUX );
+ w = hb_get_work( job->h, WORK_MUX );
w->private_data = calloc( sizeof( hb_work_private_t ), 1 );
w->private_data->job = job;
w->private_data->mux = mux;
@@ -672,7 +672,7 @@ hb_work_object_t * hb_muxer_init( hb_job_t * job )
if (subtitle->config.dest != PASSTHRUSUB)
continue;
- w = hb_get_work( WORK_MUX );
+ w = hb_get_work( job->h, WORK_MUX );
w->private_data = calloc( sizeof( hb_work_private_t ), 1 );
w->private_data->job = job;
w->private_data->mux = mux;
diff --git a/libhb/reader.c b/libhb/reader.c
index 530196e48..66b5cc617 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -35,6 +35,7 @@ typedef struct
struct hb_work_private_s
{
+ hb_handle_t * h;
hb_job_t * job;
hb_title_t * title;
volatile int * die;
@@ -74,7 +75,7 @@ static int hb_reader_open( hb_work_private_t * r )
{
if ( r->title->type == HB_BD_TYPE )
{
- if ( !( r->bd = hb_bd_init( r->title->path ) ) )
+ if ( !( r->bd = hb_bd_init( r->h, r->title->path ) ) )
return 1;
}
else if ( r->title->type == HB_DVD_TYPE )
@@ -85,7 +86,7 @@ static int hb_reader_open( hb_work_private_t * r )
else if ( r->title->type == HB_STREAM_TYPE ||
r->title->type == HB_FF_STREAM_TYPE )
{
- if ( !( r->stream = hb_stream_open( r->title->path, r->title, 0 ) ) )
+ if (!(r->stream = hb_stream_open(r->h, r->title->path, r->title, 0)))
return 1;
}
else
@@ -103,6 +104,7 @@ static int hb_reader_init( hb_work_object_t * w, hb_job_t * job )
r = calloc( sizeof( hb_work_private_t ), 1 );
w->private_data = r;
+ r->h = job->h;
r->job = job;
r->title = job->title;
r->die = job->die;
diff --git a/libhb/scan.c b/libhb/scan.c
index 32a5c60bb..1ab175765 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -29,14 +29,13 @@ typedef struct
int store_previews;
uint64_t min_title_duration;
-
} hb_scan_t;
#define PREVIEW_READ_THRESH (1024 * 1024 * 10)
static void ScanFunc( void * );
static int DecodePreviews( hb_scan_t *, hb_title_t * title, int flush );
-static void LookForAudio( hb_title_t * title, hb_buffer_t * b );
+static void LookForAudio(hb_scan_t *scan, hb_title_t *title, hb_buffer_t *b);
static int AllAudioOK( hb_title_t * title );
static void UpdateState1(hb_scan_t *scan, int title);
static void UpdateState2(hb_scan_t *scan, int title);
@@ -102,7 +101,7 @@ static void ScanFunc( void * _data )
data->stream = NULL;
/* Try to open the path as a DVD. If it fails, try as a file */
- if( ( data->bd = hb_bd_init( data->path ) ) )
+ if( ( data->bd = hb_bd_init( data->h, data->path ) ) )
{
hb_log( "scan: BD has %d title(s)",
hb_bd_title_count( data->bd ) );
@@ -152,12 +151,12 @@ static void ScanFunc( void * _data )
data->title_set->list_title );
}
}
- else if ( ( data->batch = hb_batch_init( data->path ) ) )
+ else if ( ( data->batch = hb_batch_init( data->h, data->path ) ) )
{
if( data->title_index )
{
/* Scan this title only */
- title = hb_batch_title_scan( data->batch, data->title_index );
+ title = hb_batch_title_scan(data->batch, data->title_index);
if ( title )
{
hb_list_add( data->title_set->list_title, title );
@@ -171,7 +170,7 @@ static void ScanFunc( void * _data )
hb_title_t * title;
UpdateState1(data, i + 1);
- title = hb_batch_title_scan( data->batch, i + 1 );
+ title = hb_batch_title_scan(data->batch, i + 1);
if ( title != NULL )
{
hb_list_add( data->title_set->list_title, title );
@@ -190,7 +189,8 @@ static void ScanFunc( void * _data )
if (data->title_index == 0)
data->title_index = 1;
hb_title_t * title = hb_title_init( data->path, data->title_index );
- if ( (data->stream = hb_stream_open( data->path, title, 1 ) ) != NULL )
+ data->stream = hb_stream_open(data->h, data->path, title, 1);
+ if (data->stream != NULL)
{
title = hb_stream_title_scan( data->stream, title );
if ( title )
@@ -545,11 +545,11 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
}
else if (data->batch)
{
- stream = hb_stream_open( title->path, title, 0 );
+ stream = hb_stream_open(data->h, title->path, title, 0);
}
else if (data->stream)
{
- stream = hb_stream_open( data->path, title, 0 );
+ stream = hb_stream_open(data->h, data->path, title, 0);
}
if (title->video_codec == WORK_NONE)
@@ -557,7 +557,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
hb_error("No video decoder set!");
return 0;
}
- hb_work_object_t *vid_decoder = hb_get_work(title->video_codec);
+ hb_work_object_t *vid_decoder = hb_get_work(data->h, title->video_codec);
vid_decoder->codec_param = title->video_codec_param;
vid_decoder->title = title;
vid_decoder->init( vid_decoder, NULL );
@@ -734,7 +734,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
}
else if( ! AllAudioOK( title ) )
{
- LookForAudio( title, buf_es );
+ LookForAudio( data, title, buf_es );
buf_es = NULL;
}
if ( buf_es )
@@ -1072,7 +1072,7 @@ skip_preview:
* aren't (e.g., some European DVD Teletext streams use the same IDs as US ATSC
* AC-3 audio).
*/
-static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
+static void LookForAudio(hb_scan_t *scan, hb_title_t * title, hb_buffer_t * b)
{
int i;
@@ -1108,7 +1108,7 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
}
hb_fifo_push( audio->priv.scan_cache, b );
- hb_work_object_t *w = hb_codec_decoder( audio->config.in.codec );
+ hb_work_object_t *w = hb_codec_decoder(scan->h, audio->config.in.codec);
if ( w == NULL || w->bsinfo == NULL )
{
diff --git a/libhb/stream.c b/libhb/stream.c
index 9d01c1d00..d8da41153 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -144,6 +144,8 @@ typedef struct {
struct hb_stream_s
{
+ hb_handle_t * h;
+
int scan;
int frames; /* video frames so far */
int errors; /* total errors so far */
@@ -609,10 +611,6 @@ static int hb_stream_get_type(hb_stream_t *stream)
if ( fread(buf, 1, sizeof(buf), stream->file_handle) == sizeof(buf) )
{
-#ifdef USE_HWD
- if ( hb_gui_use_hwd_flag == 1 )
- return 0;
-#endif
int psize;
if ( ( psize = hb_stream_check_for_ts(buf) ) != 0 )
{
@@ -813,7 +811,8 @@ static void prune_streams(hb_stream_t *d)
***********************************************************************
*
**********************************************************************/
-hb_stream_t * hb_stream_open( char *path, hb_title_t *title, int scan )
+hb_stream_t *
+hb_stream_open(hb_handle_t *h, char *path, hb_title_t *title, int scan)
{
FILE *f = hb_fopen(path, "rb");
if ( f == NULL )
@@ -839,13 +838,14 @@ hb_stream_t * hb_stream_open( char *path, hb_title_t *title, int scan )
* If it's something we can deal with (MPEG2 PS or TS) return a stream
* reference structure & null otherwise.
*/
+ d->h = h;
d->file_handle = f;
d->title = title;
d->scan = scan;
d->path = strdup( path );
if (d->path != NULL )
{
- if ( hb_stream_get_type( d ) != 0 )
+ if (!hb_hwd_enabled(d->h) && hb_stream_get_type( d ) != 0 )
{
if( !scan )
{
@@ -925,7 +925,7 @@ static int new_pes( hb_stream_t * stream )
return num;
}
-hb_stream_t * hb_bd_stream_open( hb_title_t *title )
+hb_stream_t * hb_bd_stream_open( hb_handle_t *h, hb_title_t *title )
{
int ii;
@@ -936,6 +936,7 @@ hb_stream_t * hb_bd_stream_open( hb_title_t *title )
return NULL;
}
+ d->h = h;
d->file_handle = NULL;
d->title = title;
d->path = NULL;
@@ -3924,10 +3925,10 @@ static void hb_ps_stream_find_streams(hb_stream_t *stream)
hb_buffer_close( &buf );
}
-static int probe_dts_profile( hb_pes_stream_t *pes )
+static int probe_dts_profile( hb_stream_t *stream, hb_pes_stream_t *pes )
{
hb_work_info_t info;
- hb_work_object_t *w = hb_codec_decoder( pes->codec );
+ hb_work_object_t *w = hb_codec_decoder( stream->h, pes->codec );
w->codec_param = pes->codec_param;
int ret = w->bsinfo( w, pes->probe_buf, &info );
@@ -3967,7 +3968,7 @@ static int probe_dts_profile( hb_pes_stream_t *pes )
return 1;
}
-static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf )
+static int do_probe(hb_stream_t *stream, hb_pes_stream_t *pes, hb_buffer_t *buf)
{
// Check upper limit of per stream data to probe
if ( pes->probe_buf == NULL )
@@ -3994,7 +3995,7 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf )
if ( pes->codec == HB_ACODEC_DCA_HD )
{
// We need to probe for the profile of DTS audio in this stream.
- return probe_dts_profile( pes );
+ return probe_dts_profile( stream, pes );
}
// Probing is slow, so we don't want to re-probe the probe
@@ -4258,7 +4259,7 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream)
hb_pes_stream_t *pes = &stream->pes.list[idx];
- if ( do_probe( pes, buf ) )
+ if ( do_probe( stream, pes, buf ) )
{
probe--;
if ( pes->stream_kind != N )
@@ -4336,7 +4337,7 @@ static void hb_ps_resolve_stream_types(hb_stream_t *stream)
hb_pes_stream_t *pes = &stream->pes.list[idx];
- if ( do_probe( pes, buf ) )
+ if ( do_probe( stream, pes, buf ) )
{
probe--;
if ( pes->stream_kind != N )
diff --git a/libhb/sync.c b/libhb/sync.c
index ac826584e..c672b3d4a 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -141,7 +141,7 @@ hb_work_object_t * hb_sync_init( hb_job_t * job )
pv->common->start_found = 1;
}
- ret = w = hb_get_work( WORK_SYNC_VIDEO );
+ ret = w = hb_get_work( job->h, WORK_SYNC_VIDEO );
w->private_data = pv;
w->fifo_in = job->fifo_raw;
@@ -1246,7 +1246,7 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
pv->common->ref++;
pv->common->pts_count++;
- w = hb_get_work( WORK_SYNC_AUDIO );
+ w = hb_get_work( job->h, WORK_SYNC_AUDIO );
w->private_data = pv;
w->audio = hb_list_item( job->list_audio, i );
w->fifo_in = w->audio->priv.fifo_raw;
diff --git a/libhb/work.c b/libhb/work.c
index b3d0744d7..f456deb4a 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -144,7 +144,7 @@ static void work_func( void * _work )
free( work );
}
-hb_work_object_t * hb_get_work( int id )
+hb_work_object_t * hb_get_work( hb_handle_t *h, int id )
{
hb_work_object_t * w;
for( w = hb_objects; w; w = w->next )
@@ -153,39 +153,40 @@ hb_work_object_t * hb_get_work( int id )
{
hb_work_object_t *wc = malloc( sizeof(*w) );
*wc = *w;
+ wc->h = h;
return wc;
}
}
return NULL;
}
-hb_work_object_t* hb_codec_decoder(int codec)
+hb_work_object_t* hb_codec_decoder(hb_handle_t *h, int codec)
{
if (codec & HB_ACODEC_FF_MASK)
{
- return hb_get_work(WORK_DECAVCODEC);
+ return hb_get_work(h, WORK_DECAVCODEC);
}
switch (codec)
{
- case HB_ACODEC_LPCM: return hb_get_work(WORK_DECLPCM);
+ case HB_ACODEC_LPCM: return hb_get_work(h, WORK_DECLPCM);
default: break;
}
return NULL;
}
-hb_work_object_t* hb_codec_encoder(int codec)
+hb_work_object_t* hb_codec_encoder(hb_handle_t *h, int codec)
{
if (codec & HB_ACODEC_FF_MASK)
{
- return hb_get_work(WORK_ENCAVCODEC_AUDIO);
+ return hb_get_work(h, WORK_ENCAVCODEC_AUDIO);
}
switch (codec)
{
- case HB_ACODEC_AC3: return hb_get_work(WORK_ENCAVCODEC_AUDIO);
- case HB_ACODEC_LAME: return hb_get_work(WORK_ENCLAME);
- case HB_ACODEC_VORBIS: return hb_get_work(WORK_ENCVORBIS);
- case HB_ACODEC_CA_AAC: return hb_get_work(WORK_ENC_CA_AAC);
- case HB_ACODEC_CA_HAAC: return hb_get_work(WORK_ENC_CA_HAAC);
+ case HB_ACODEC_AC3: return hb_get_work(h, WORK_ENCAVCODEC_AUDIO);
+ case HB_ACODEC_LAME: return hb_get_work(h, WORK_ENCLAME);
+ case HB_ACODEC_VORBIS: return hb_get_work(h, WORK_ENCVORBIS);
+ case HB_ACODEC_CA_AAC: return hb_get_work(h, WORK_ENC_CA_AAC);
+ case HB_ACODEC_CA_HAAC: return hb_get_work(h, WORK_ENC_CA_HAAC);
default: break;
}
return NULL;
@@ -567,7 +568,7 @@ static void do_job(hb_job_t *job)
hb_work_object_t *w;
hb_work_object_t *sync;
hb_work_object_t *muxer;
- hb_work_object_t *reader = hb_get_work(WORK_READER);
+ hb_work_object_t *reader = hb_get_work(job->h, WORK_READER);
hb_audio_t *audio;
hb_subtitle_t *subtitle;
@@ -1225,7 +1226,7 @@ static void do_job(hb_job_t *job)
hb_error("No video decoder set!");
goto cleanup;
}
- hb_list_add(job->list_work, (w = hb_get_work(title->video_codec)));
+ hb_list_add(job->list_work, (w = hb_get_work(job->h, title->video_codec)));
w->codec_param = title->video_codec_param;
w->fifo_in = job->fifo_mpeg2;
w->fifo_out = job->fifo_raw;
@@ -1249,7 +1250,7 @@ static void do_job(hb_job_t *job)
subtitle->fifo_sync = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
subtitle->fifo_out = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
- w = hb_get_work( subtitle->codec );
+ w = hb_get_work( job->h, subtitle->codec );
w->fifo_in = subtitle->fifo_in;
w->fifo_out = subtitle->fifo_raw;
w->subtitle = subtitle;
@@ -1286,29 +1287,29 @@ static void do_job(hb_job_t *job)
switch( job->vcodec )
{
case HB_VCODEC_FFMPEG_MPEG4:
- w = hb_get_work( WORK_ENCAVCODEC );
+ w = hb_get_work( job->h, WORK_ENCAVCODEC );
w->codec_param = AV_CODEC_ID_MPEG4;
break;
case HB_VCODEC_FFMPEG_MPEG2:
- w = hb_get_work( WORK_ENCAVCODEC );
+ w = hb_get_work( job->h, WORK_ENCAVCODEC );
w->codec_param = AV_CODEC_ID_MPEG2VIDEO;
break;
case HB_VCODEC_FFMPEG_VP8:
- w = hb_get_work( WORK_ENCAVCODEC );
+ w = hb_get_work( job->h, WORK_ENCAVCODEC );
w->codec_param = AV_CODEC_ID_VP8;
break;
case HB_VCODEC_X264:
- w = hb_get_work( WORK_ENCX264 );
+ w = hb_get_work( job->h, WORK_ENCX264 );
break;
case HB_VCODEC_QSV_H264:
- w = hb_get_work( WORK_ENCQSV );
+ w = hb_get_work( job->h, WORK_ENCQSV );
break;
case HB_VCODEC_THEORA:
- w = hb_get_work( WORK_ENCTHEORA );
+ w = hb_get_work( job->h, WORK_ENCTHEORA );
break;
#ifdef USE_X265
case HB_VCODEC_X265:
- w = hb_get_work( WORK_ENCX265 );
+ w = hb_get_work( job->h, WORK_ENCX265 );
break;
#endif
}
@@ -1333,7 +1334,8 @@ static void do_job(hb_job_t *job)
*/
if ( audio->priv.fifo_in )
{
- if ( ( w = hb_codec_decoder( audio->config.in.codec ) ) == NULL )
+ w = hb_codec_decoder(job->h, audio->config.in.codec);
+ if (w == NULL)
{
hb_error("Invalid input codec: %d", audio->config.in.codec);
*job->done_error = HB_ERROR_WRONG_INPUT;
@@ -1357,7 +1359,8 @@ static void do_job(hb_job_t *job)
/*
* Add the encoder thread if not doing AC-3 pass through
*/
- if ( ( w = hb_codec_encoder( audio->config.out.codec ) ) == NULL )
+ w = hb_codec_encoder( job->h, audio->config.out.codec);
+ if (w == NULL)
{
hb_error("Invalid audio codec: %#x", audio->config.out.codec);
w = NULL;
diff --git a/test/test.c b/test/test.c
index bc6670193..b750f2acd 100644
--- a/test/test.c
+++ b/test/test.c
@@ -309,7 +309,12 @@ int main( int argc, char ** argv )
hb_system_sleep_prevent(h);
- hb_gui_use_hwd_flag = use_hwd;
+
+ // FIXME: When hardware decode is enabled, the scan must be performed
+ // with hardware decode enabled because the decoder context used during
+ // encoding phase comes from the context used during scan. This is
+ // broken by design and I would very much like to fix this someday.
+ hb_hwd_set_enable(h, use_hwd);
hb_scan( h, input, titleindex, preview_count, store_previews, min_title_duration * 90000LL );
/* Wait... */
@@ -1673,9 +1678,6 @@ static int HandleEvents( hb_handle_t * h )
hb_filter_object_t * filter;
- job->use_detelecine = detelecine;
- job->use_decomb = decomb;
-
/* Add selected filters */
if( detelecine )
{