예제 #1
0
파일: blendbench.c 프로젝트: videolan/vlc
static int blendbench_LoadImage( vlc_object_t *p_this, picture_t **pp_pic,
                                 vlc_fourcc_t i_chroma, char *psz_file, const char *psz_name )
{
    image_handler_t *p_image;
    video_format_t fmt_out;

    video_format_Init( &fmt_out, i_chroma );

    p_image = image_HandlerCreate( p_this );
    *pp_pic = image_ReadUrl( p_image, psz_file, &fmt_out );
    video_format_Clean( &fmt_out );
    image_HandlerDelete( p_image );

    if( *pp_pic == NULL )
    {
        msg_Err( p_this, "Unable to load %s image", psz_name );
        return VLC_EGENERIC;
    }

    msg_Dbg( p_this, "%s image has dim %d x %d (Y plane)", psz_name,
             (*pp_pic)->p[Y_PLANE].i_visible_pitch,
             (*pp_pic)->p[Y_PLANE].i_visible_lines );

    return VLC_SUCCESS;
}
예제 #2
0
파일: fake.c 프로젝트: Kafay/vlc
/*****************************************************************************
 * FakeCallback: Image source change callback.
 *****************************************************************************/
static int FakeCallback( vlc_object_t *p_this, char const *psz_var,
                         vlc_value_t oldval, vlc_value_t newval,
                         void *p_data )
{
    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
    decoder_t *p_dec = (decoder_t *)p_data;

    if( !strcmp( psz_var, "fake-file" ) )
    {
        image_handler_t *p_handler;
        picture_t *p_new_image;
        video_format_t fmt_in, fmt_out;
        char *psz_file = newval.psz_string;
        picture_t *p_image;

        vlc_mutex_lock( &p_dec->p_sys->lock );
        p_image = p_dec->p_sys->p_image;

        if( !psz_file || !*psz_file )
        {
            msg_Err( p_dec, "fake-file value must be non empty." );
            vlc_mutex_unlock( &p_dec->p_sys->lock );
            return VLC_EGENERIC;
        }
        msg_Dbg( p_dec, "Changing fake-file to %s.", psz_file );

        memset( &fmt_in, 0, sizeof(fmt_in) );
        fmt_out = p_dec->fmt_out.video;
        p_handler = image_HandlerCreate( p_dec );
        p_new_image = image_ReadUrl( p_handler, psz_file, &fmt_in, &fmt_out );
        image_HandlerDelete( p_handler );

        if( !p_new_image )
        {
            msg_Err( p_dec, "error while reading image (%s)", psz_file );
            vlc_mutex_unlock( &p_dec->p_sys->lock );
            return VLC_EGENERIC;
        }

        p_dec->p_sys->p_image = p_new_image;
        picture_Release( p_image );
        vlc_mutex_unlock( &p_dec->p_sys->lock );
    }
    else if( !strcmp( psz_var, "fake-file-reload" ) )
    {
        if( newval.i_int > 0)
        {
            p_dec->p_sys->b_reload = true;
            p_dec->p_sys->i_reload = (mtime_t)(newval.i_int * 1000000);
            p_dec->p_sys->i_next   = (mtime_t)(p_dec->p_sys->i_reload + mdate());
        }
        else
        {
            p_dec->p_sys->b_reload = false;
        }
    }

    return VLC_SUCCESS;
}
예제 #3
0
파일: alphamask.c 프로젝트: FLYKingdom/vlc
/* copied from video_filters/erase.c . Gruik ? */
static void LoadMask( filter_t *p_filter, const char *psz_filename )
{
    image_handler_t *p_image;
    video_format_t fmt_in, fmt_out;
    memset( &fmt_in, 0, sizeof( video_format_t ) );
    memset( &fmt_out, 0, sizeof( video_format_t ) );
    fmt_out.i_chroma = VLC_CODEC_YUVA;
    if( p_filter->p_sys->p_mask )
        picture_Release( p_filter->p_sys->p_mask );
    p_image = image_HandlerCreate( p_filter );
    p_filter->p_sys->p_mask =
        image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
    image_HandlerDelete( p_image );
}
예제 #4
0
파일: alphamask.c 프로젝트: IAPark/vlc
/* copied from video_filters/erase.c . Gruik ? */
static void LoadMask( filter_t *p_filter, const char *psz_filename )
{
    image_handler_t *p_image;
    video_format_t fmt_in, fmt_out;
    video_format_Init( &fmt_in, 0 );
    video_format_Init( &fmt_out, VLC_CODEC_YUVA );
    if( p_filter->p_sys->p_mask )
        picture_Release( p_filter->p_sys->p_mask );
    p_image = image_HandlerCreate( p_filter );
    char *psz_url = vlc_path2uri( psz_filename, NULL );
    p_filter->p_sys->p_mask =
        image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
    free( psz_url );
    video_format_Clean( &fmt_in );
    video_format_Clean( &fmt_out );
    image_HandlerDelete( p_image );
}
예제 #5
0
파일: rss.c 프로젝트: 12307/VLC-for-VS2010
/****************************************************************************
 * download and resize image located at psz_url
 ***************************************************************************/
static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
{
    filter_sys_t *p_sys = p_filter->p_sys;
    video_format_t fmt_in;
    video_format_t fmt_out;
    picture_t *p_orig;
    picture_t *p_pic = NULL;
    image_handler_t *p_handler = image_HandlerCreate( p_filter );

    memset( &fmt_in, 0, sizeof(video_format_t) );
    memset( &fmt_out, 0, sizeof(video_format_t) );

    fmt_out.i_chroma = VLC_CODEC_YUVA;
    p_orig = image_ReadUrl( p_handler, psz_url, &fmt_in, &fmt_out );

    if( !p_orig )
    {
        msg_Warn( p_filter, "Unable to read image %s", psz_url );
    }
    else if( p_sys->p_style->i_font_size > 0 )
    {

        fmt_in.i_chroma = VLC_CODEC_YUVA;
        fmt_in.i_height = p_orig->p[Y_PLANE].i_visible_lines;
        fmt_in.i_width = p_orig->p[Y_PLANE].i_visible_pitch;
        fmt_out.i_width = p_orig->p[Y_PLANE].i_visible_pitch
            *p_sys->p_style->i_font_size/p_orig->p[Y_PLANE].i_visible_lines;
        fmt_out.i_height = p_sys->p_style->i_font_size;

        p_pic = image_Convert( p_handler, p_orig, &fmt_in, &fmt_out );
        picture_Release( p_orig );
        if( !p_pic )
        {
            msg_Warn( p_filter, "Error while converting %s", psz_url );
        }
    }
    else
    {
        p_pic = p_orig;
    }

    image_HandlerDelete( p_handler );

    return p_pic;
}
예제 #6
0
/**
 * It loads the logo image into memory.
 */
static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
{
    if( !psz_filename )
        return NULL;

    video_format_t fmt_in;
    video_format_Init( &fmt_in, 0 );

    video_format_t fmt_out;
    video_format_Init( &fmt_out, VLC_CODEC_YUVA );

    image_handler_t *p_image = image_HandlerCreate( p_this );
    if( !p_image )
        return NULL;

    char *psz_url = make_URI( psz_filename, NULL );
    picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
    free( psz_url );
    image_HandlerDelete( p_image );

    return p_pic;
}
예제 #7
0
파일: decklink.cpp 프로젝트: Adatan/vlc
static int OpenVideo(vlc_object_t *p_this)
{
    vout_display_t *vd = (vout_display_t *)p_this;
    vout_display_sys_t *sys;
    struct decklink_sys_t *decklink_sys;

    vd->sys = sys = (vout_display_sys_t*)malloc(sizeof(*sys));
    if (!sys)
        return VLC_ENOMEM;

    sys->tenbits = var_InheritBool(p_this, VIDEO_CFG_PREFIX "tenbits");
    sys->nosignal_delay = var_InheritInteger(p_this, VIDEO_CFG_PREFIX "nosignal-delay");
    sys->pic_nosignal = NULL;

    decklink_sys = OpenDecklink(vd);
    if (!decklink_sys) {
        if (sys->pic_nosignal)
            picture_Release(sys->pic_nosignal);
        free(sys);
        return VLC_EGENERIC;
    }

    sys->pool = NULL;

    vd->fmt.i_chroma = sys->tenbits
        ? VLC_CODEC_I422_10L /* we will convert to v210 */
        : VLC_CODEC_UYVY;
    //video_format_FixRgb(&(vd->fmt));

    vd->fmt.i_width = decklink_sys->i_width;
    vd->fmt.i_height = decklink_sys->i_height;

    char *pic_file = var_InheritString(p_this, VIDEO_CFG_PREFIX "nosignal-image");
    if (pic_file) {
        image_handler_t *img = image_HandlerCreate(p_this);
        if (!img) {
            msg_Err(p_this, "Could not create image converter");
        } else {
            video_format_t in, dummy;

            video_format_Init(&in, 0);
            video_format_Setup(&in, 0, vd->fmt.i_width, vd->fmt.i_height,
                    vd->fmt.i_width, vd->fmt.i_height, 1, 1);

            video_format_Init(&dummy, 0);

            picture_t *png = image_ReadUrl(img, pic_file, &dummy, &in);
            if (png) {
                msg_Err(p_this, "Converting");
                sys->pic_nosignal = image_Convert(img, png, &in, &vd->fmt);
                picture_Release(png);
            }

            image_HandlerDelete(img);
        }

        free(pic_file);
        if (!sys->pic_nosignal) {
            CloseVideo(p_this);
            msg_Err(p_this, "Could not create no signal picture");
            return VLC_EGENERIC;
        }
    }
    vd->info.has_hide_mouse = true;
    vd->pool    = PoolVideo;
    vd->prepare = NULL;
    vd->display = DisplayVideo;
    vd->control = ControlVideo;
    vd->manage  = NULL;
    vout_display_SendEventFullscreen(vd, false);

    return VLC_SUCCESS;
}
예제 #8
0
파일: fake.c 프로젝트: Kafay/vlc
/*****************************************************************************
 * OpenDecoder: probe the decoder and return score
 *****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
    decoder_t *p_dec = (decoder_t*)p_this;
    vlc_value_t val;
    image_handler_t *p_handler;
    video_format_t fmt_in, fmt_out;
    picture_t *p_image;
    char *psz_file, *psz_chroma;
    bool b_keep_ar;
    int i_aspect = 0;

    if( p_dec->fmt_in.i_codec != VLC_FOURCC('f','a','k','e') )
    {
        return VLC_EGENERIC;
    }

    p_dec->p_sys = calloc( 1, sizeof( *p_dec->p_sys ) );
    if( !p_dec->p_sys )
        return VLC_ENOMEM;

    psz_file = var_CreateGetNonEmptyStringCommand( p_dec, "fake-file" );
    if( !psz_file )
    {
        msg_Err( p_dec, "specify a file with --fake-file=..." );
        free( p_dec->p_sys );
        return VLC_EGENERIC;
    }
    var_AddCallback( p_dec, "fake-file", FakeCallback, p_dec );

    memset( &fmt_in, 0, sizeof(fmt_in) );
    memset( &fmt_out, 0, sizeof(fmt_out) );

    val.i_int = var_CreateGetIntegerCommand( p_dec, "fake-file-reload" );
    if( val.i_int > 0)
    {
        p_dec->p_sys->b_reload = true;
        p_dec->p_sys->i_reload = (mtime_t)(val.i_int * 1000000);
        p_dec->p_sys->i_next   = (mtime_t)(p_dec->p_sys->i_reload + mdate());
    }
    var_AddCallback( p_dec, "fake-file-reload", FakeCallback , p_dec );

    psz_chroma = var_CreateGetString( p_dec, "fake-chroma" );
    fmt_out.i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
    if( !fmt_out.i_chroma )
    {
        msg_Warn( p_dec, "Invalid chroma (%s). Using I420.", psz_chroma );
        fmt_out.i_chroma = VLC_CODEC_I420;
    }
    free( psz_chroma );

    var_Create( p_dec, "fake-keep-ar", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
    var_Get( p_dec, "fake-keep-ar", &val );
    b_keep_ar = val.b_bool;

    var_Create( p_dec, "fake-width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
    var_Create( p_dec, "fake-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
    var_Create( p_dec, "fake-aspect-ratio",
                VLC_VAR_STRING | VLC_VAR_DOINHERIT );

    var_Get( p_dec, "fake-aspect-ratio", &val );
    if ( val.psz_string )
    {
        char *psz_parser = strchr( val.psz_string, ':' );

        if( psz_parser )
        {
            *psz_parser++ = '\0';
            i_aspect = atoi( val.psz_string )
                                   * VOUT_ASPECT_FACTOR / atoi( psz_parser );
        }
        free( val.psz_string );
    }

    if ( !b_keep_ar )
    {
        var_Get( p_dec, "fake-width", &val );
        fmt_out.i_width = val.i_int;
        var_Get( p_dec, "fake-height", &val );
        fmt_out.i_height = val.i_int;
    }

    p_handler = image_HandlerCreate( p_dec );
    p_image = image_ReadUrl( p_handler, psz_file, &fmt_in, &fmt_out );
    image_HandlerDelete( p_handler );

    if ( p_image == NULL )
    {
        msg_Err( p_dec, "unable to read image file %s", psz_file );
        free( psz_file );
        free( p_dec->p_sys );
        return VLC_EGENERIC;
    }
    msg_Dbg( p_dec, "file %s loaded successfully", psz_file );

    free( psz_file );

    if ( b_keep_ar )
    {
        picture_t *p_old = p_image;
        int i_width, i_height;

        var_Get( p_dec, "fake-width", &val );
        i_width = val.i_int;
        var_Get( p_dec, "fake-height", &val );
        i_height = val.i_int;

        if ( i_width && i_height )
        {
            int i_image_ar = fmt_out.i_width * VOUT_ASPECT_FACTOR
                              / fmt_out.i_height;
            int i_region_ar = i_width * VOUT_ASPECT_FACTOR / i_height;
            fmt_in = fmt_out;

            if ( i_aspect == i_image_ar )
            {
                fmt_out.i_width = i_width;
                fmt_out.i_height = i_height;
            }
            else if ( i_image_ar > i_region_ar )
            {
                fmt_out.i_width = i_width;
                fmt_out.i_height = i_width * VOUT_ASPECT_FACTOR
                                    / i_image_ar;
                i_aspect = i_image_ar;
            }
            else
            {
                fmt_out.i_height = i_height;
                fmt_out.i_width = i_height * i_image_ar
                                    / VOUT_ASPECT_FACTOR;
                i_aspect = i_image_ar;
            }

            p_handler = image_HandlerCreate( p_dec );
            p_image = image_Convert( p_handler, p_old, &fmt_in, &fmt_out );
            image_HandlerDelete( p_handler );

            if ( p_image == NULL )
            {
                msg_Warn( p_dec, "couldn't load resizing module" );
                p_image = p_old;
                fmt_out = fmt_in;
            }
            else
            {
                picture_Release( p_old );
            }
        }
    }

    if ( i_aspect )
    {
        fmt_out.i_aspect = i_aspect;
    }
    else
    {
        fmt_out.i_aspect = fmt_out.i_width
                            * VOUT_ASPECT_FACTOR / fmt_out.i_height;
    }

    var_Create( p_dec, "fake-deinterlace", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
    var_Get( p_dec, "fake-deinterlace", &val );
    if ( val.b_bool )
    {
        picture_t *p_old = p_image;

        var_Create( p_dec, "fake-deinterlace-module",
                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
        var_Get( p_dec, "fake-deinterlace-module", &val );

        p_handler = image_HandlerCreate( p_dec );
        p_image = image_Filter( p_handler, p_old, &fmt_out, val.psz_string );
        image_HandlerDelete( p_handler );
        free( val.psz_string );

        if ( p_image == NULL )
        {
            msg_Warn( p_dec, "couldn't load deinterlace module" );
            p_image = p_old;
        }
        else
        {
            picture_Release( p_old );
        }
    }

    /* Set output properties */
    p_dec->fmt_out.i_cat = VIDEO_ES;
    p_dec->fmt_out.i_codec = fmt_out.i_chroma;
    p_dec->fmt_out.video = fmt_out;

    /* Set callbacks */
    p_dec->pf_decode_video = DecodeBlock;

    p_dec->p_sys->p_image = p_image;
    vlc_mutex_init( &p_dec->p_sys->lock );

    return VLC_SUCCESS;
}