Ejemplo n.º 1
0
static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt )
{
    int ret = 0;
    FILE *tcfile_in;
    timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) );
    if( !h )
    {
        fprintf( stderr, "timecode [error]: malloc failed\n" );
        return -1;
    }
    h->input = input;
    h->p_handle = *p_handle;
    h->frame_total = input.get_frame_total( h->p_handle );
    h->seek = opt->seek;
    if( opt->timebase )
        ret = sscanf( opt->timebase, "%d/%d", &h->timebase_num, &h->timebase_den );
    if( ret == 1 )
        h->timebase_num = atoi( opt->timebase );
    h->auto_timebase_num = !ret;
    h->auto_timebase_den = ret < 2;
    if( h->auto_timebase_num )
        h->timebase_num = info->fps_den; /* can be changed later by auto timebase generation */
    if( h->auto_timebase_den )
        h->timebase_den = 0;             /* set later by auto timebase generation */
    timecode_input.picture_alloc = h->input.picture_alloc;
    timecode_input.picture_clean = h->input.picture_clean;

    *p_handle = h;

    tcfile_in = fopen( psz_filename, "rb" );
    if( !tcfile_in )
    {
        fprintf( stderr, "timecode [error]: can't open `%s'\n", psz_filename );
        return -1;
    }
    else if( !x264_is_regular_file( tcfile_in ) )
    {
        fprintf( stderr, "timecode [error]: tcfile input incompatible with non-regular file `%s'\n", psz_filename );
        fclose( tcfile_in );
        return -1;
    }

    if( parse_tcfile( tcfile_in, h, info ) < 0 )
    {
        if( h->pts )
            free( h->pts );
        fclose( tcfile_in );
        return -1;
    }
    fclose( tcfile_in );

    info->timebase_num = h->timebase_num;
    info->timebase_den = h->timebase_den;
    info->vfr = 1;

    return 0;
}
Ejemplo n.º 2
0
static int open_file( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param )
{
    thread_hnd_t *h = malloc( sizeof(thread_hnd_t) );
    if( !h || input.picture_alloc( &h->pic, p_param->i_csp, p_param->i_width, p_param->i_height ) )
    {
        fprintf( stderr, "x264 [error]: malloc failed\n" );
        return -1;
    }
    h->input = input;
    h->p_handle = *p_handle;
    h->in_progress = 0;
    h->next_frame = -1;
    h->next_args = malloc( sizeof(thread_input_arg_t) );
    if( !h->next_args )
        return -1;
    h->next_args->h = h;
    h->next_args->status = 0;
    h->frame_total = input.get_frame_total( h->p_handle );
    thread_input.picture_alloc = h->input.picture_alloc;
    thread_input.picture_clean = h->input.picture_clean;

    *p_handle = h;
    return 0;
}