X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=input%2Fthread.c;h=a89c8a885385f5fe090067da3cbc25f3f1fe1771;hb=c58954cc7c2516dd5f704a506da9fe824f34d9df;hp=c4b07fa08a4abea96cb4760b1e36f85625c7c7dc;hpb=81cada8effc3e91eec3f413772b3c1629e8beb4d;p=x264 diff --git a/input/thread.c b/input/thread.c index c4b07fa0..a89c8a88 100644 --- a/input/thread.c +++ b/input/thread.c @@ -21,15 +21,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#include "muxers.h" - -extern cli_input_t input; +#include "input.h" typedef struct { cli_input_t input; hnd_t p_handle; - x264_picture_t pic; + cli_pic_t pic; x264_threadpool_t *pool; int next_frame; int frame_total; @@ -39,7 +37,7 @@ typedef struct typedef struct thread_input_arg_t { thread_hnd_t *h; - x264_picture_t *pic; + cli_pic_t *pic; int i_frame; int status; } thread_input_arg_t; @@ -47,11 +45,8 @@ typedef struct thread_input_arg_t static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt ) { thread_hnd_t *h = malloc( sizeof(thread_hnd_t) ); - if( !h || input.picture_alloc( &h->pic, info->csp, info->width, info->height ) ) - { - fprintf( stderr, "x264 [error]: malloc failed\n" ); - return -1; - } + FAIL_IF_ERR( !h || input.picture_alloc( &h->pic, info->csp, info->width, info->height ), + "x264", "malloc failed\n" ) h->input = input; h->p_handle = *p_handle; h->next_frame = -1; @@ -60,7 +55,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c return -1; h->next_args->h = h; h->next_args->status = 0; - h->frame_total = input.get_frame_total( h->p_handle ); + h->frame_total = info->num_frames; thread_input.picture_alloc = h->input.picture_alloc; thread_input.picture_clean = h->input.picture_clean; @@ -71,18 +66,12 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c return 0; } -static int get_frame_total( hnd_t handle ) -{ - thread_hnd_t *h = handle; - return h->frame_total; -} - static void read_frame_thread_int( thread_input_arg_t *i ) { i->status = i->h->input.read_frame( i->pic, i->h->p_handle, i->i_frame ); } -static int read_frame( x264_picture_t *p_pic, hnd_t handle, int i_frame ) +static int read_frame( cli_pic_t *p_pic, hnd_t handle, int i_frame ) { thread_hnd_t *h = handle; int ret = 0; @@ -94,7 +83,7 @@ static int read_frame( x264_picture_t *p_pic, hnd_t handle, int i_frame ) } if( h->next_frame == i_frame ) - XCHG( x264_picture_t, *p_pic, h->pic ); + XCHG( cli_pic_t, *p_pic, h->pic ); else ret |= h->input.read_frame( p_pic, h->p_handle, i_frame ); @@ -111,7 +100,7 @@ static int read_frame( x264_picture_t *p_pic, hnd_t handle, int i_frame ) return ret; } -static int release_frame( x264_picture_t *pic, hnd_t handle ) +static int release_frame( cli_pic_t *pic, hnd_t handle ) { thread_hnd_t *h = handle; if( h->input.release_frame ) @@ -130,4 +119,4 @@ static int close_file( hnd_t handle ) return 0; } -cli_input_t thread_input = { open_file, get_frame_total, NULL, read_frame, release_frame, NULL, close_file }; +cli_input_t thread_input = { open_file, NULL, read_frame, release_frame, NULL, close_file };