📄 wall.c
字号:
p_vout->p_sys->i_vout = 0; msg_Dbg( p_vout, "target window (%d,%d)-(%d,%d)", i_hstart,i_vstart,i_hend,i_vend ); i_top = 0; i_height = 0; for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ ) { i_left = 0; i_top += i_height; for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ ) { i_align = 0; if( i_col*i_target_width >= i_hstart && (i_col+1)*i_target_width <= i_hend ) { i_width = i_target_width; } else if( ( i_col + 1 ) * i_target_width < i_hstart || ( i_col * i_target_width ) > i_hend ) { i_width = 0; } else { i_width = ( i_target_width - i_hstart % i_target_width ); if( i_col >= ( p_vout->p_sys->i_col / 2 ) ) { i_align |= VOUT_ALIGN_LEFT; i_width -= i_hstart_rounded ? 2: 0; } else { i_align |= VOUT_ALIGN_RIGHT; } } if( i_row * i_target_height >= i_vstart && ( i_row + 1 ) * i_target_height <= i_vend ) { i_height = i_target_height; } else if( ( i_row + 1 ) * i_target_height < i_vstart || ( i_row * i_target_height ) > i_vend ) { i_height = 0; } else { i_height = ( i_target_height - i_vstart%i_target_height ); if( i_row >= ( p_vout->p_sys->i_row / 2 ) ) { i_align |= VOUT_ALIGN_TOP; i_height -= i_vstart_rounded ? 2: 0; } else { i_align |= VOUT_ALIGN_BOTTOM; } } if( i_height == 0 || i_width == 0 ) { p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active = VLC_FALSE; } p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width; p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height; p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_left = i_left; p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_top = i_top; i_left += i_width; if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active ) { p_vout->p_sys->i_vout++; continue; } var_SetInteger( p_vout, "align", i_align ); var_SetInteger( p_vout, "video-x", i_left + i_xpos - i_width); var_SetInteger( p_vout, "video-y", i_top + i_ypos ); fmt.i_width = fmt.i_visible_width = i_width; fmt.i_height = fmt.i_visible_height = i_height; fmt.i_aspect = i_aspect * i_target_height / i_height * i_width / i_target_width; p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout = vout_Create( p_vout, &fmt ); if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ) { msg_Err( p_vout, "failed to get %ix%i vout threads", p_vout->p_sys->i_col, p_vout->p_sys->i_row ); RemoveAllVout( p_vout ); return VLC_EGENERIC; } ADD_CALLBACKS( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout, SendEvents ); p_vout->p_sys->i_vout++; } } ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES ); ADD_PARENT_CALLBACKS( SendEventsToChild ); return VLC_SUCCESS;}/***************************************************************************** * End: terminate Wall video thread output method *****************************************************************************/static void End( vout_thread_t *p_vout ){ int i_index; /* Free the fake output buffers we allocated */ for( i_index = I_OUTPUTPICTURES ; i_index ; ) { i_index--; free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig ); }}/***************************************************************************** * Destroy: destroy Wall video thread output method ***************************************************************************** * Terminate an output method created by WallCreateOutputMethod *****************************************************************************/static void Destroy( vlc_object_t *p_this ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; RemoveAllVout( p_vout ); DEL_PARENT_CALLBACKS( SendEventsToChild ); free( p_vout->p_sys->pp_vout ); free( p_vout->p_sys );}/***************************************************************************** * Render: displays previously rendered output ***************************************************************************** * This function send the currently rendered image to Wall image, waits * until it is displayed and switch the two rendering buffers, preparing next * frame. *****************************************************************************/static void Render( vout_thread_t *p_vout, picture_t *p_pic ){ picture_t *p_outpic = NULL; int i_col, i_row, i_vout, i_plane; int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES]; i_vout = 0; for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ ) { for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ ) { for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ ) { pi_left_skip[i_plane] = p_vout->p_sys->pp_vout[ i_vout ].i_left * p_pic->p[ i_plane ].i_pitch / p_vout->output.i_width; pi_top_skip[i_plane] = (p_vout->p_sys->pp_vout[ i_vout ].i_top * p_pic->p[ i_plane ].i_lines / p_vout->output.i_height)*p_pic->p[i_plane].i_pitch; } if( !p_vout->p_sys->pp_vout[ i_vout ].b_active ) { i_vout++; continue; } while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, 0, 0, 0 ) ) == NULL ) { if( p_vout->b_die || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); return; } msleep( VOUT_OUTMEM_SLEEP ); } vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic, p_pic->date ); vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ ) { uint8_t *p_in, *p_in_end, *p_out; int i_in_pitch = p_pic->p[i_plane].i_pitch; int i_out_pitch = p_outpic->p[i_plane].i_pitch; int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch; p_in = p_pic->p[i_plane].p_pixels + pi_top_skip[i_plane] + pi_left_skip[i_plane]; p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines * p_pic->p[i_plane].i_pitch; p_out = p_outpic->p[i_plane].p_pixels; while( p_in < p_in_end ) { p_vout->p_vlc->pf_memcpy( p_out, p_in, i_copy_pitch ); p_in += i_in_pitch; p_out += i_out_pitch; }// pi_left_skip[i_plane] += i_copy_pitch; } vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); i_vout++; }/* for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ ) *//* { *//* pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height *//* * p_pic->p[i_plane].i_visible_lines *//* / p_vout->output.i_height *//* * p_pic->p[i_plane].i_pitch; *//* } */ }}/***************************************************************************** * RemoveAllVout: destroy all the child video output threads *****************************************************************************/static void RemoveAllVout( vout_thread_t *p_vout ){ while( p_vout->p_sys->i_vout ) { --p_vout->p_sys->i_vout; if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active ) { DEL_CALLBACKS( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout, SendEvents ); vlc_object_detach( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ); vout_Destroy( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ); } }}/***************************************************************************** * 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_vout ){ vout_thread_t *p_vout = (vout_thread_t *)_p_vout; int i_vout; vlc_value_t sentval = newval; /* Find the video output index */ for( i_vout = 0; i_vout < p_vout->p_sys->i_vout; i_vout++ ) { if( p_this == (vlc_object_t *)p_vout->p_sys->pp_vout[ i_vout ].p_vout ) { break; } } if( i_vout == p_vout->p_sys->i_vout ) { return VLC_EGENERIC; } /* Translate the mouse coordinates */ if( !strcmp( psz_var, "mouse-x" ) ) { sentval.i_int += p_vout->output.i_width * (i_vout % p_vout->p_sys->i_col) / p_vout->p_sys->i_col; } else if( !strcmp( psz_var, "mouse-y" ) ) { sentval.i_int += p_vout->output.i_height * (i_vout / p_vout->p_sys->i_row) / p_vout->p_sys->i_row; } var_Set( p_vout, psz_var, sentval ); 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 ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; int i_row, i_col, i_vout = 0; for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ ) { for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ ) { var_Set( p_vout->p_sys->pp_vout[ i_vout ].p_vout, psz_var, newval); if( !strcmp( psz_var, "fullscreen" ) ) break; i_vout++; } } return VLC_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -