⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 puzzle.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
    DEL_PARENT_CALLBACKS( SendEventsToChild );    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );    /* Free the fake output buffers we allocated */    for( i_index = I_OUTPUTPICTURES ; i_index ; )    {        i_index--;        free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );    }    var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);    var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);    var_DelCallback( p_vout->p_sys->p_vout, "mouse-clicked", MouseEvent, p_vout);    vout_CloseAndRelease( p_vout->p_sys->p_vout );}#define SHUFFLE_WIDTH 81#define SHUFFLE_HEIGHT 13static const char *shuffle_button[] ={".................................................................................","..............  ............................   ........   ......  ...............","..............  ...........................  .........  ........  ...............","..............  ...........................  .........  ........  ...............","..     .......  .    .......  ....  ......     ......     ......  ........    ...",".  .... ......   ...  ......  ....  .......  .........  ........  .......  ..  ..",".  ...........  ....  ......  ....  .......  .........  ........  ......  ....  .",".      .......  ....  ......  ....  .......  .........  ........  ......        .","..      ......  ....  ......  ....  .......  .........  ........  ......  .......","......  ......  ....  ......  ....  .......  .........  ........  ......  .......",". ....  ......  ....  ......  ...   .......  .........  ........  .......  .... .","..     .......  ....  .......    .  .......  .........  ........  ........     ..","................................................................................."};/***************************************************************************** * Destroy: destroy Magnify video thread output method *****************************************************************************/static void Destroy( vlc_object_t *p_this ){    vout_thread_t *p_vout = (vout_thread_t *)p_this;    image_HandlerDelete( p_vout->p_sys->p_image );    free( p_vout->p_sys->pi_order );    free( p_vout->p_sys );}/***************************************************************************** * Render: displays previously rendered output *****************************************************************************/static void Render( vout_thread_t *p_vout, picture_t *p_pic ){    picture_t *p_outpic;    //video_format_t fmt_out;    // memset( &fmt_out, 0, sizeof(video_format_t) );    //picture_t *p_converted;    int i_plane;    int i_rows = p_vout->p_sys->i_rows;    int i_cols = p_vout->p_sys->i_cols;    /* This is a new frame. Get a structure from the video_output. */    while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )              == NULL )    {        if( !vlc_object_alive (p_vout) || p_vout->b_error )        {            return;        }        msleep( VOUT_OUTMEM_SLEEP );    }    vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );    for( i_plane = 0; i_plane < p_outpic->i_planes; i_plane++ )    {        plane_t *p_in = p_pic->p+i_plane;        plane_t *p_out = p_outpic->p+i_plane;        int i_pitch = p_in->i_pitch;        int i;        for( i = 0; i < i_cols * i_rows; i++ )        {            int i_col = i % i_cols;            int i_row = i / i_cols;            int i_ocol = p_vout->p_sys->pi_order[i] % i_cols;            int i_orow = p_vout->p_sys->pi_order[i] / i_cols;            int i_last_row = i_row + 1;            i_orow *= p_in->i_lines / i_rows;            i_row *= p_in->i_lines / i_rows;            i_last_row *= p_in->i_lines / i_rows;            if( p_vout->p_sys->b_blackslot == true                && p_vout->p_sys->b_finished == false                && i == p_vout->p_sys->i_selected )            {                uint8_t color = ( i_plane == Y_PLANE ? 0x0 : 0x80 );                for( ; i_row < i_last_row; i_row++, i_orow++ )                {                    vlc_memset( p_out->p_pixels + i_row * i_pitch                                               + i_col * i_pitch / i_cols,                               color, i_pitch / i_cols );                }            }            else            {                for( ; i_row < i_last_row; i_row++, i_orow++ )                {                    vlc_memcpy( p_out->p_pixels + i_row * i_pitch                                               + i_col * i_pitch / i_cols,                               p_in->p_pixels + i_orow * i_pitch                                              + i_ocol * i_pitch / i_cols,                               i_pitch / i_cols );                }            }        }    }    if(    p_vout->p_sys->i_selected != -1        && p_vout->p_sys->b_blackslot == false )    {        plane_t *p_in = p_pic->p+Y_PLANE;        plane_t *p_out = p_outpic->p+Y_PLANE;        int i_pitch = p_in->i_pitch;        int i_col = p_vout->p_sys->i_selected % i_cols;        int i_row = p_vout->p_sys->i_selected / i_cols;        int i_last_row = i_row + 1;        i_row *= p_in->i_lines / i_rows;        i_last_row *= p_in->i_lines / i_rows;        vlc_memset( p_out->p_pixels + i_row * i_pitch                                   + i_col * i_pitch / i_cols,                   0xff, i_pitch / i_cols );        for( ; i_row < i_last_row; i_row++ )        {            p_out->p_pixels[   i_row * i_pitch                             + i_col * i_pitch / i_cols ] = 0xff;            p_out->p_pixels[ i_row * i_pitch                             + (i_col+1) * i_pitch / i_cols - 1 ] = 0xff;        }        i_row--;        vlc_memset( p_out->p_pixels + i_row * i_pitch                                   + i_col * i_pitch / i_cols,                   0xff, i_pitch / i_cols );    }    if( p_vout->p_sys->b_finished == true )    {        int i, j;        plane_t *p_out = p_outpic->p+Y_PLANE;        int i_pitch = p_out->i_pitch;        for( i = 0; i < SHUFFLE_HEIGHT; i++ )        {            for( j = 0; j < SHUFFLE_WIDTH; j++ )            {                if( shuffle_button[i][j] == '.' )                   p_out->p_pixels[ i * i_pitch + j ] = 0xff;            }        }    }    vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );}/***************************************************************************** * SendEvents: forward mouse and keyboard events to the parent p_vout *****************************************************************************/static int SendEvents( 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);    var_Set( (vlc_object_t *)p_data, psz_var, newval );    return VLC_SUCCESS;}/***************************************************************************** * SendEventsToChild: forward events to the child/children vout *****************************************************************************/static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,                       vlc_value_t oldval, vlc_value_t newval, void *p_data ){    VLC_UNUSED(p_data); VLC_UNUSED(oldval);    vout_thread_t *p_vout = (vout_thread_t *)p_this;    var_Set( p_vout->p_sys->p_vout, psz_var, newval );    return VLC_SUCCESS;}/***************************************************************************** * MouseEvent: callback for mouse events *****************************************************************************/static int MouseEvent( 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); VLC_UNUSED(newval);    vout_thread_t *p_vout = (vout_thread_t*)p_data;    int i_x, i_y;    int i_v;#define MOUSE_DOWN    1#define MOUSE_CLICKED 2#define MOUSE_MOVE_X  4#define MOUSE_MOVE_Y  8#define MOUSE_MOVE    12    uint8_t mouse= 0;    int v_h = p_vout->output.i_height;    int v_w = p_vout->output.i_width;    int i_pos;    if( psz_var[6] == 'x' ) mouse |= MOUSE_MOVE_X;    if( psz_var[6] == 'y' ) mouse |= MOUSE_MOVE_Y;    if( psz_var[6] == 'c' ) mouse |= MOUSE_CLICKED;    i_v = var_GetInteger( p_vout->p_sys->p_vout, "mouse-button-down" );    if( i_v & 0x1 ) mouse |= MOUSE_DOWN;    i_y = var_GetInteger( p_vout->p_sys->p_vout, "mouse-y" );    i_x = var_GetInteger( p_vout->p_sys->p_vout, "mouse-x" );    if( i_y < 0 || i_x < 0 || i_y >= v_h || i_x >= v_w )        return VLC_SUCCESS;    if( mouse & MOUSE_CLICKED )    {        i_pos = p_vout->p_sys->i_cols * ( ( p_vout->p_sys->i_rows * i_y ) / v_h ) + (p_vout->p_sys->i_cols * i_x ) / v_w;        if( p_vout->p_sys->b_finished == true            && i_x < SHUFFLE_WIDTH && i_y < SHUFFLE_HEIGHT )        {            shuffle( p_vout->p_sys );        }        else if( p_vout->p_sys->i_selected == -1 )        {            p_vout->p_sys->i_selected = i_pos;        }        else if( p_vout->p_sys->i_selected == i_pos                 && p_vout->p_sys->b_blackslot == false )        {            p_vout->p_sys->i_selected = -1;        }        else if(    ( p_vout->p_sys->i_selected == i_pos + 1                      && p_vout->p_sys->i_selected%p_vout->p_sys->i_cols != 0 )                 || ( p_vout->p_sys->i_selected == i_pos - 1                      && i_pos % p_vout->p_sys->i_cols != 0 )                 || p_vout->p_sys->i_selected == i_pos + p_vout->p_sys->i_cols                 || p_vout->p_sys->i_selected == i_pos - p_vout->p_sys->i_cols )        {            int a = p_vout->p_sys->pi_order[ p_vout->p_sys->i_selected ];            p_vout->p_sys->pi_order[ p_vout->p_sys->i_selected ] =                p_vout->p_sys->pi_order[ i_pos ];            p_vout->p_sys->pi_order[ i_pos ] = a;            if( p_vout->p_sys->b_blackslot == true )                p_vout->p_sys->i_selected = i_pos;            else                p_vout->p_sys->i_selected = -1;            p_vout->p_sys->b_finished = finished( p_vout->p_sys );        }    }    return VLC_SUCCESS;}static int PuzzleCallback( 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);    vout_sys_t *p_sys = (vout_sys_t *)p_data;    if( !strcmp( psz_var, CFG_PREFIX "rows" ) )    {        p_sys->i_rows = __MAX( 1, newval.i_int );    }    else if( !strcmp( psz_var, CFG_PREFIX "cols" ) )    {        p_sys->i_cols = __MAX( 1, newval.i_int );    }    else if( !strcmp( psz_var, CFG_PREFIX "black-slot" ) )    {        p_sys->b_blackslot = newval.b_bool;    }    shuffle( p_sys );    return VLC_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -