Commit 010ddefd authored by Gildas Bazin's avatar Gildas Bazin

ALL: backport of 13001,13004,13005,13011,13012,13019,13020,13025 from trunk.

parent a80a4353
...@@ -84,7 +84,6 @@ struct vout_thread_t ...@@ -84,7 +84,6 @@ struct vout_thread_t
vlc_bool_t b_interface; /**< render interface */ vlc_bool_t b_interface; /**< render interface */
vlc_bool_t b_scale; /**< allow picture scaling */ vlc_bool_t b_scale; /**< allow picture scaling */
vlc_bool_t b_fullscreen; /**< toogle fullscreen display */ vlc_bool_t b_fullscreen; /**< toogle fullscreen display */
vlc_bool_t b_override_aspect; /**< aspect ratio overriden */
uint32_t render_time; /**< last picture render time */ uint32_t render_time; /**< last picture render time */
unsigned int i_window_width; /**< video window width */ unsigned int i_window_width; /**< video window width */
unsigned int i_window_height; /**< video window height */ unsigned int i_window_height; /**< video window height */
......
...@@ -72,6 +72,8 @@ struct decoder_sys_t ...@@ -72,6 +72,8 @@ struct decoder_sys_t
*/ */
vout_synchro_t *p_synchro; vout_synchro_t *p_synchro;
int i_aspect; int i_aspect;
int i_sar_num;
int i_sar_den;
mtime_t i_last_frame_pts; mtime_t i_last_frame_pts;
}; };
...@@ -581,6 +583,8 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf ) ...@@ -581,6 +583,8 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf )
p_dec->fmt_out.video.i_visible_height = p_dec->fmt_out.video.i_visible_height =
p_sys->p_info->sequence->picture_height; p_sys->p_info->sequence->picture_height;
p_dec->fmt_out.video.i_aspect = p_sys->i_aspect; p_dec->fmt_out.video.i_aspect = p_sys->i_aspect;
p_dec->fmt_out.video.i_sar_num = p_sys->i_sar_num;
p_dec->fmt_out.video.i_sar_den = p_sys->i_sar_den;
if( p_sys->p_info->sequence->frame_period > 0 ) if( p_sys->p_info->sequence->frame_period > 0 )
{ {
...@@ -632,17 +636,24 @@ static void GetAR( decoder_t *p_dec ) ...@@ -632,17 +636,24 @@ static void GetAR( decoder_t *p_dec )
{ {
case AR_3_4_PICTURE: case AR_3_4_PICTURE:
p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3; p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
p_sys->i_sar_num = p_sys->p_info->sequence->display_height * 4;
p_sys->i_sar_den = p_sys->p_info->sequence->display_width * 3;
break; break;
case AR_16_9_PICTURE: case AR_16_9_PICTURE:
p_sys->i_aspect = VOUT_ASPECT_FACTOR * 16 / 9; p_sys->i_aspect = VOUT_ASPECT_FACTOR * 16 / 9;
p_sys->i_sar_num = p_sys->p_info->sequence->display_height * 16;
p_sys->i_sar_den = p_sys->p_info->sequence->display_width * 9;
break; break;
case AR_221_1_PICTURE: case AR_221_1_PICTURE:
p_sys->i_aspect = VOUT_ASPECT_FACTOR * 221 / 100; p_sys->i_aspect = VOUT_ASPECT_FACTOR * 221 / 100;
p_sys->i_sar_num = p_sys->p_info->sequence->display_height * 221;
p_sys->i_sar_den = p_sys->p_info->sequence->display_width * 100;
break; break;
case AR_SQUARE_PICTURE: case AR_SQUARE_PICTURE:
p_sys->i_aspect = VOUT_ASPECT_FACTOR * p_sys->i_aspect = VOUT_ASPECT_FACTOR *
p_sys->p_info->sequence->width / p_sys->p_info->sequence->width /
p_sys->p_info->sequence->height; p_sys->p_info->sequence->height;
p_sys->i_sar_num = p_sys->i_sar_den = 1;
break; break;
} }
} }
...@@ -657,6 +668,8 @@ static void GetAR( decoder_t *p_dec ) ...@@ -657,6 +668,8 @@ static void GetAR( decoder_t *p_dec )
VOUT_ASPECT_FACTOR / VOUT_ASPECT_FACTOR /
p_sys->p_info->sequence->display_height / p_sys->p_info->sequence->display_height /
p_sys->p_info->sequence->pixel_height; p_sys->p_info->sequence->pixel_height;
p_sys->i_sar_num = p_sys->p_info->sequence->pixel_width;
p_sys->i_sar_den = p_sys->p_info->sequence->pixel_height;
} }
else else
{ {
...@@ -664,12 +677,15 @@ static void GetAR( decoder_t *p_dec ) ...@@ -664,12 +677,15 @@ static void GetAR( decoder_t *p_dec )
* This shouldn't happen and if it does it is a bug * This shouldn't happen and if it does it is a bug
* in libmpeg2 (likely triggered by an invalid stream) */ * in libmpeg2 (likely triggered by an invalid stream) */
p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3; p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
p_sys->i_sar_num = p_sys->p_info->sequence->display_height * 4;
p_sys->i_sar_den = p_sys->p_info->sequence->display_width * 3;
} }
} }
msg_Dbg( p_dec, "%dx%d, aspect %d, %u.%03u fps", msg_Dbg( p_dec, "%dx%d, aspect %d, sar %i:%i, %u.%03u fps",
p_sys->p_info->sequence->display_width, p_sys->p_info->sequence->display_width,
p_sys->p_info->sequence->display_height, p_sys->i_aspect, p_sys->p_info->sequence->display_height,
p_sys->i_aspect, p_sys->i_sar_num, p_sys->i_sar_den,
(uint32_t)((uint64_t)1001000000 * 27 / (uint32_t)((uint64_t)1001000000 * 27 /
p_sys->p_info->sequence->frame_period / 1001), p_sys->p_info->sequence->frame_period / 1001),
(uint32_t)((uint64_t)1001000000 * 27 / (uint32_t)((uint64_t)1001000000 * 27 /
......
...@@ -420,7 +420,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -420,7 +420,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
for( y = 1; y < (int)fmt.i_height - 1; y++ ) for( y = 1; y < (int)fmt.i_height - 1; y++ )
{ {
memcpy( p_top, p_dst, fmt.i_width ); if( y > 1 ) memcpy( p_top, p_dst, fmt.i_width );
p_dst += p_region->picture.Y_PITCH; p_dst += p_region->picture.Y_PITCH;
left = 0; left = 0;
...@@ -615,7 +615,11 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, ...@@ -615,7 +615,11 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
} }
FT_Glyph_Get_CBox( tmp_glyph, ft_glyph_bbox_pixels, &glyph_size ); FT_Glyph_Get_CBox( tmp_glyph, ft_glyph_bbox_pixels, &glyph_size );
i_error = FT_Glyph_To_Bitmap( &tmp_glyph, ft_render_mode_normal, 0, 1); i_error = FT_Glyph_To_Bitmap( &tmp_glyph, ft_render_mode_normal, 0, 1);
if( i_error ) continue; if( i_error )
{
FT_Done_Glyph( tmp_glyph );
continue;
}
p_line->pp_glyphs[ i ] = (FT_BitmapGlyph)tmp_glyph; p_line->pp_glyphs[ i ] = (FT_BitmapGlyph)tmp_glyph;
/* Do rest */ /* Do rest */
......
...@@ -144,11 +144,13 @@ void E_(DirectXEventThread)( event_thread_t *p_event ) ...@@ -144,11 +144,13 @@ void E_(DirectXEventThread)( event_thread_t *p_event )
if( i_width && i_height ) if( i_width && i_height )
{ {
val.i_int = ( GET_X_LPARAM(msg.lParam) - i_x ) val.i_int = ( GET_X_LPARAM(msg.lParam) - i_x ) *
* p_event->p_vout->render.i_width / i_width; p_event->p_vout->fmt_in.i_visible_width / i_width +
p_event->p_vout->fmt_in.i_x_offset;
var_Set( p_event->p_vout, "mouse-x", val ); var_Set( p_event->p_vout, "mouse-x", val );
val.i_int = ( GET_Y_LPARAM(msg.lParam) - i_y ) val.i_int = ( GET_Y_LPARAM(msg.lParam) - i_y ) *
* p_event->p_vout->render.i_height / i_height; p_event->p_vout->fmt_in.i_visible_height / i_height +
p_event->p_vout->fmt_in.i_y_offset;
var_Set( p_event->p_vout, "mouse-y", val ); var_Set( p_event->p_vout, "mouse-y", val );
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h> #include <vlc/vout.h>
#include <commctrl.h> #include <commctrl.h>
...@@ -92,6 +93,7 @@ ...@@ -92,6 +93,7 @@
#define SetWindowLongPtr SetWindowLong #define SetWindowLongPtr SetWindowLong
#define GetWindowLongPtr GetWindowLong #define GetWindowLongPtr GetWindowLong
#define GWLP_USERDATA GWL_USERDATA #define GWLP_USERDATA GWL_USERDATA
#define AdjustWindowRect(a,b,c)
#endif //UNDER_CE #endif //UNDER_CE
#ifndef WS_NONAVDONEBUTTON #ifndef WS_NONAVDONEBUTTON
...@@ -146,6 +148,7 @@ struct vout_sys_t ...@@ -146,6 +148,7 @@ struct vout_sys_t
int i_window_y; int i_window_y;
int i_window_width; int i_window_width;
int i_window_height; int i_window_height;
int i_window_style;
int render_width; int render_width;
int render_height; int render_height;
...@@ -404,7 +407,11 @@ static int Init( vout_thread_t *p_vout ) ...@@ -404,7 +407,11 @@ static int Init( vout_thread_t *p_vout )
#else #else
p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_height = p_vout->render.i_height;
p_vout->fmt_out = p_vout->fmt_in;
p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
#endif #endif
p_vout->output.i_aspect = p_vout->render.i_aspect; p_vout->output.i_aspect = p_vout->render.i_aspect;
p_pic->p->p_pixels = p_vout->p_sys->p_pic_buffer; p_pic->p->p_pixels = p_vout->p_sys->p_pic_buffer;
...@@ -801,6 +808,8 @@ static void EventThread ( vlc_object_t *p_event ) ...@@ -801,6 +808,8 @@ static void EventThread ( vlc_object_t *p_event )
else else
i_style = WS_OVERLAPPEDWINDOW|WS_SIZEBOX|WS_VISIBLE|WS_CLIPCHILDREN; i_style = WS_OVERLAPPEDWINDOW|WS_SIZEBOX|WS_VISIBLE|WS_CLIPCHILDREN;
p_vout->p_sys->i_window_style = i_style;
p_vout->p_sys->hwnd = p_vout->p_sys->hwnd =
CreateWindow( _T("VLC WinGDI"), _T(VOUT_TITLE), i_style, CreateWindow( _T("VLC WinGDI"), _T(VOUT_TITLE), i_style,
(p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT : (p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT :
...@@ -1150,6 +1159,19 @@ static long FAR PASCAL WndProc( HWND hWnd, UINT message, ...@@ -1150,6 +1159,19 @@ static long FAR PASCAL WndProc( HWND hWnd, UINT message,
p_vout->p_sys->b_video_display = VLC_TRUE; p_vout->p_sys->b_video_display = VLC_TRUE;
break; break;
/* the user wants to close the window */
case WM_CLOSE:
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL ) return 0;
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
return 0;
}
case WM_DESTROY: case WM_DESTROY:
msg_Dbg( p_vout, "WinProc WM_DESTROY" ); msg_Dbg( p_vout, "WinProc WM_DESTROY" );
PostQuitMessage( 0 ); PostQuitMessage( 0 );
...@@ -1261,9 +1283,55 @@ static void InitBuffers( vout_thread_t *p_vout ) ...@@ -1261,9 +1283,55 @@ static void InitBuffers( vout_thread_t *p_vout )
static int Control( vout_thread_t *p_vout, int i_query, va_list args ) static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{ {
vlc_bool_t b_bool; vlc_bool_t b_bool;
double f_arg;
RECT rect_window;
POINT point;
switch( i_query ) switch( i_query )
{ {
case VOUT_SET_ZOOM:
if( p_vout->p_sys->hparent )
return vout_ControlWindow( p_vout,
(void *)p_vout->p_sys->hparent, i_query, args );
f_arg = va_arg( args, double );
/* Update dimensions */
rect_window.top = rect_window.left = 0;
rect_window.right = p_vout->i_window_width * f_arg;
rect_window.bottom = p_vout->i_window_height * f_arg;
AdjustWindowRect( &rect_window, p_vout->p_sys->i_window_style, 0 );
SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
rect_window.right - rect_window.left,
rect_window.bottom - rect_window.top, SWP_NOMOVE );
return VLC_SUCCESS;
case VOUT_CLOSE:
ShowWindow( p_vout->p_sys->hwnd, SW_HIDE );
case VOUT_REPARENT:
/* Change window style, borders and title bar */
//vlc_mutex_lock( &p_vout->p_sys->lock );
p_vout->p_sys->hparent = 0;
//vlc_mutex_unlock( &p_vout->p_sys->lock );
/* Retrieve the window position */
point.x = point.y = 0;
ClientToScreen( p_vout->p_sys->hwnd, &point );
SetParent( p_vout->p_sys->hwnd, 0 );
p_vout->p_sys->i_window_style =
WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
p_vout->p_sys->i_window_style |
(i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
return vout_vaControlDefault( p_vout, i_query, args );
case VOUT_SET_FOCUS: case VOUT_SET_FOCUS:
b_bool = va_arg( args, vlc_bool_t ); b_bool = va_arg( args, vlc_bool_t );
......
...@@ -405,11 +405,33 @@ static int InitVideo( vout_thread_t *p_vout ) ...@@ -405,11 +405,33 @@ static int InitVideo( vout_thread_t *p_vout )
vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width, vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width,
p_vout->p_sys->p_win->i_height, p_vout->p_sys->p_win->i_height,
&i_index, &i_index, &i_index, &i_index,
&p_vout->output.i_width, &p_vout->output.i_height ); &p_vout->fmt_out.i_visible_width,
&p_vout->fmt_out.i_visible_height );
/* Assume we have square pixels */ p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
p_vout->output.i_aspect = p_vout->output.i_width
* VOUT_ASPECT_FACTOR / p_vout->output.i_height; p_vout->output.i_width = p_vout->fmt_out.i_width =
p_vout->fmt_out.i_visible_width * p_vout->fmt_in.i_width /
p_vout->fmt_in.i_visible_width;
p_vout->output.i_height = p_vout->fmt_out.i_height =
p_vout->fmt_out.i_visible_height * p_vout->fmt_in.i_height /
p_vout->fmt_in.i_visible_height;
p_vout->fmt_out.i_x_offset =
p_vout->fmt_out.i_visible_width * p_vout->fmt_in.i_x_offset /
p_vout->fmt_in.i_visible_width;
p_vout->fmt_out.i_y_offset =
p_vout->fmt_out.i_visible_height * p_vout->fmt_in.i_y_offset /
p_vout->fmt_in.i_visible_height;
p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_sar_den = 1;
p_vout->output.i_aspect = p_vout->fmt_out.i_aspect =
p_vout->fmt_out.i_width * VOUT_ASPECT_FACTOR /p_vout->fmt_out.i_height;
msg_Dbg( p_vout, "x11 image size %ix%i (%i,%i,%ix%i)",
p_vout->fmt_out.i_width, p_vout->fmt_out.i_height,
p_vout->fmt_out.i_x_offset, p_vout->fmt_out.i_y_offset,
p_vout->fmt_out.i_visible_width,
p_vout->fmt_out.i_visible_height );
#endif #endif
/* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */ /* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */
...@@ -486,8 +508,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -486,8 +508,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
XShmPutImage( p_vout->p_sys->p_display, XShmPutImage( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->video_window, p_vout->p_sys->p_win->video_window,
p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image, p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image,
0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/, p_vout->fmt_out.i_x_offset,
p_vout->output.i_width, p_vout->output.i_height, p_vout->fmt_out.i_y_offset,
0 /*dest_x*/, 0 /*dest_y*/,
p_vout->fmt_out.i_visible_width,
p_vout->fmt_out.i_visible_height,
False /* Don't put True here ! */ ); False /* Don't put True here ! */ );
# endif # endif
} }
...@@ -508,8 +533,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -508,8 +533,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
XPutImage( p_vout->p_sys->p_display, XPutImage( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->video_window, p_vout->p_sys->p_win->video_window,
p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image, p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image,
0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/, p_vout->fmt_out.i_x_offset,
p_vout->output.i_width, p_vout->output.i_height ); p_vout->fmt_out.i_y_offset,
0 /*dest_x*/, 0 /*dest_y*/,
p_vout->fmt_out.i_visible_width,
p_vout->fmt_out.i_visible_height );
#endif #endif
} }
...@@ -757,11 +785,13 @@ static int ManageVideo( vout_thread_t *p_vout ) ...@@ -757,11 +785,13 @@ static int ManageVideo( vout_thread_t *p_vout )
p_vout->p_sys->p_win->i_height, p_vout->p_sys->p_win->i_height,
&i_x, &i_y, &i_width, &i_height ); &i_x, &i_y, &i_width, &i_height );
val.i_int = ( xevent.xmotion.x - i_x ) val.i_int = ( xevent.xmotion.x - i_x ) *
* p_vout->render.i_width / i_width; p_vout->fmt_in.i_visible_width / i_width +
p_vout->fmt_in.i_x_offset;
var_Set( p_vout, "mouse-x", val ); var_Set( p_vout, "mouse-x", val );
val.i_int = ( xevent.xmotion.y - i_y ) val.i_int = ( xevent.xmotion.y - i_y ) *
* p_vout->render.i_height / i_height; p_vout->fmt_in.i_visible_height / i_height +
p_vout->fmt_in.i_y_offset;
var_Set( p_vout, "mouse-y", val ); var_Set( p_vout, "mouse-y", val );
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
...@@ -847,7 +877,6 @@ static int ManageVideo( vout_thread_t *p_vout ) ...@@ -847,7 +877,6 @@ static int ManageVideo( vout_thread_t *p_vout )
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
} }
#ifndef MODULE_NAME_IS_x11
if( p_vout->i_changes & VOUT_CROP_CHANGE || if( p_vout->i_changes & VOUT_CROP_CHANGE ||
p_vout->i_changes & VOUT_ASPECT_CHANGE ) p_vout->i_changes & VOUT_ASPECT_CHANGE )
{ {
...@@ -862,9 +891,9 @@ static int ManageVideo( vout_thread_t *p_vout ) ...@@ -862,9 +891,9 @@ static int ManageVideo( vout_thread_t *p_vout )
p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num; p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den; p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
p_vout->output.i_aspect = p_vout->fmt_in.i_aspect; p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
p_vout->i_changes |= VOUT_SIZE_CHANGE; p_vout->i_changes |= VOUT_SIZE_CHANGE;
} }
#endif
/* /*
* Size change * Size change
......
...@@ -946,7 +946,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) ...@@ -946,7 +946,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
vlc_ureduce( &p_dec->fmt_out.video.i_sar_num, vlc_ureduce( &p_dec->fmt_out.video.i_sar_num,
&p_dec->fmt_out.video.i_sar_den, &p_dec->fmt_out.video.i_sar_den,
p_dec->fmt_out.video.i_sar_num, p_dec->fmt_out.video.i_sar_num,
p_dec->fmt_out.video.i_sar_den, 0 ); p_dec->fmt_out.video.i_sar_den, 50000 );
p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec; p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
p_sys->video = p_dec->fmt_out.video; p_sys->video = p_dec->fmt_out.video;
......
...@@ -59,7 +59,6 @@ static void DestroyThread ( vout_thread_t * ); ...@@ -59,7 +59,6 @@ static void DestroyThread ( vout_thread_t * );
static void AspectRatio ( int, int *, int * ); static void AspectRatio ( int, int *, int * );
static int BinaryLog ( uint32_t ); static int BinaryLog ( uint32_t );
static void MaskToShift ( int *, int *, uint32_t ); static void MaskToShift ( int *, int *, uint32_t );
static void InitWindowSize ( vout_thread_t *, unsigned *, unsigned * );
/* Object variables callbacks */ /* Object variables callbacks */
static int DeinterlaceCallback( vlc_object_t *, char const *, static int DeinterlaceCallback( vlc_object_t *, char const *,
...@@ -174,8 +173,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout, ...@@ -174,8 +173,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
if( ( p_vout->fmt_render.i_width != p_fmt->i_width ) || if( ( p_vout->fmt_render.i_width != p_fmt->i_width ) ||
( p_vout->fmt_render.i_height != p_fmt->i_height ) || ( p_vout->fmt_render.i_height != p_fmt->i_height ) ||
( p_vout->fmt_render.i_chroma != p_fmt->i_chroma ) || ( p_vout->fmt_render.i_chroma != p_fmt->i_chroma ) ||
( p_vout->fmt_render.i_aspect != p_fmt->i_aspect ( p_vout->fmt_render.i_aspect != p_fmt->i_aspect ) ||
&& !p_vout->b_override_aspect ) ||
p_vout->b_filter_change ) p_vout->b_filter_change )
{ {
/* We are not interested in this format, close this vout */ /* We are not interested in this format, close this vout */
...@@ -247,12 +245,11 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -247,12 +245,11 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
/* Initialize the rendering heap */ /* Initialize the rendering heap */
I_RENDERPICTURES = 0; I_RENDERPICTURES = 0;
vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
p_vout->fmt_render = *p_fmt; /* FIXME palette */ p_vout->fmt_render = *p_fmt; /* FIXME palette */
p_vout->fmt_in = *p_fmt; /* FIXME palette */ p_vout->fmt_in = *p_fmt; /* FIXME palette */
vlc_ureduce( &p_vout->fmt_render.i_sar_num, &p_vout->fmt_render.i_sar_den,
p_vout->fmt_render.i_sar_num, p_vout->fmt_render.i_sar_den, 0 );
vlc_ureduce( &p_vout->fmt_in.i_sar_num, &p_vout->fmt_in.i_sar_den,
p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den, 0 );
p_vout->render.i_width = i_width; p_vout->render.i_width = i_width;
p_vout->render.i_height = i_height; p_vout->render.i_height = i_height;
...@@ -316,8 +313,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -316,8 +313,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
/* Take care of some "interface/control" related initialisations */ /* Take care of some "interface/control" related initialisations */
vout_IntfInit( p_vout ); vout_IntfInit( p_vout );
p_vout->b_override_aspect = VLC_FALSE;
/* If the parent is not a VOUT object, that means we are at the start of /* If the parent is not a VOUT object, that means we are at the start of
* the video output pipe */ * the video output pipe */
if( p_parent->i_object_type != VLC_OBJECT_VOUT ) if( p_parent->i_object_type != VLC_OBJECT_VOUT )
...@@ -358,12 +353,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -358,12 +353,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
else psz_plugin = strdup( p_vout->psz_filter_chain ); else psz_plugin = strdup( p_vout->psz_filter_chain );
} }
/* Initialize the dimensions of the video window */
InitWindowSize( p_vout, &p_vout->i_window_width,
&p_vout->i_window_height );
msg_Dbg( p_vout, "Window size: %dx%d", p_vout->i_window_width,
p_vout->i_window_height );
/* Create the vout thread */ /* Create the vout thread */
p_vout->p_module = module_Need( p_vout, p_vout->p_module = module_Need( p_vout,
( p_vout->psz_filter_chain && *p_vout->psz_filter_chain ) ? ( p_vout->psz_filter_chain && *p_vout->psz_filter_chain ) ?
...@@ -1228,71 +1217,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask ) ...@@ -1228,71 +1217,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
*pi_right = (8 - i_high + i_low); *pi_right = (8 - i_high + i_low);
} }
/*****************************************************************************
* InitWindowSize: find the initial dimensions the video window should have.
*****************************************************************************
* This function will check the "width", "height" and "zoom" config options and
* will calculate the size that the video window should have.
*****************************************************************************/
static void InitWindowSize( vout_thread_t *p_vout, unsigned *pi_width,
unsigned *pi_height )
{
vlc_value_t val;
int i_width, i_height;
uint64_t ll_zoom;
#define FP_FACTOR 1000 /* our fixed point factor */
var_Get( p_vout, "align", &val );
p_vout->i_alignment = val.i_int;
var_Get( p_vout, "width", &val );
i_width = val.i_int;
var_Get( p_vout, "height", &val );
i_height = val.i_int;
var_Get( p_vout, "zoom", &val );
ll_zoom = (uint64_t)( FP_FACTOR * val.f_float );
if( i_width > 0 && i_height > 0)
{
*pi_width = (int)( i_width * ll_zoom / FP_FACTOR );
*pi_height = (int)( i_height * ll_zoom / FP_FACTOR );
return;
}
else if( i_width > 0 )
{
*pi_width = (int)( i_width * ll_zoom / FP_FACTOR );
*pi_height = (int)( i_width * ll_zoom * VOUT_ASPECT_FACTOR /
p_vout->fmt_in.i_aspect / FP_FACTOR );
return;
}
else if( i_height > 0 )
{
*pi_height = (int)( i_height * ll_zoom / FP_FACTOR );
*pi_width = (int)( i_height * ll_zoom * p_vout->fmt_in.i_aspect /
VOUT_ASPECT_FACTOR / FP_FACTOR );
return;
}
if( p_vout->fmt_in.i_visible_height * p_vout->fmt_in.i_aspect
>= p_vout->fmt_in.i_visible_width * VOUT_ASPECT_FACTOR )
{
*pi_width = (int)( p_vout->fmt_in.i_visible_height * ll_zoom
* p_vout->fmt_in.i_aspect / VOUT_ASPECT_FACTOR / FP_FACTOR );
*pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom
/ FP_FACTOR );
}
else
{
*pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom
/ FP_FACTOR );
*pi_height = (int)( p_vout->fmt_in.i_visible_width * ll_zoom
* VOUT_ASPECT_FACTOR / p_vout->fmt_in.i_aspect / FP_FACTOR );
}
#undef FP_FACTOR
}
/***************************************************************************** /*****************************************************************************
* vout_VarCallback: generic callback for intf variables * vout_VarCallback: generic callback for intf variables
*****************************************************************************/ *****************************************************************************/
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static void InitWindowSize( vout_thread_t *, unsigned *, unsigned * );
/* Object variables callbacks */ /* Object variables callbacks */
static int ZoomCallback( vlc_object_t *, char const *, static int ZoomCallback( vlc_object_t *, char const *,
...@@ -184,6 +185,9 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -184,6 +185,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_vout, "align", &val );
p_vout->i_alignment = val.i_int;
var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
...@@ -261,7 +265,6 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -261,7 +265,6 @@ void vout_IntfInit( vout_thread_t *p_vout )
vlc_ureduce( &i_aspect_num, &i_aspect_den, vlc_ureduce( &i_aspect_num, &i_aspect_den,
i_aspect *VOUT_ASPECT_FACTOR, VOUT_ASPECT_FACTOR, 0 ); i_aspect *VOUT_ASPECT_FACTOR, VOUT_ASPECT_FACTOR, 0 );
} }
free( val.psz_string );
if( !i_aspect_num || !i_aspect_den ) i_aspect_num = i_aspect_den = 1; if( !i_aspect_num || !i_aspect_den ) i_aspect_num = i_aspect_den = 1;
p_vout->i_par_num = i_aspect_num; p_vout->i_par_num = i_aspect_num;
...@@ -274,6 +277,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -274,6 +277,7 @@ void vout_IntfInit( vout_thread_t *p_vout )
p_vout->i_par_num, p_vout->i_par_den ); p_vout->i_par_num, p_vout->i_par_den );
b_force_par = VLC_TRUE; b_force_par = VLC_TRUE;
} }
if( val.psz_string ) free( val.psz_string );
/* Aspect-ratio object var */ /* Aspect-ratio object var */
var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING |
...@@ -301,6 +305,12 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -301,6 +305,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 ); var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 );
if( old_val.psz_string ) free( old_val.psz_string ); if( old_val.psz_string ) free( old_val.psz_string );
/* Initialize the dimensions of the video window */
InitWindowSize( p_vout, &p_vout->i_window_width,
&p_vout->i_window_height );
msg_Dbg( p_vout, "window size: %dx%d", p_vout->i_window_width,
p_vout->i_window_height );
/* Add a variable to indicate if the window should be on top of others */ /* Add a variable to indicate if the window should be on top of others */
var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
text.psz_string = _("Always on top"); text.psz_string = _("Always on top");
...@@ -524,6 +534,69 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -524,6 +534,69 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args )
} }
} }
/*****************************************************************************
* InitWindowSize: find the initial dimensions the video window should have.
*****************************************************************************
* This function will check the "width", "height" and "zoom" config options and
* will calculate the size that the video window should have.
*****************************************************************************/
static void InitWindowSize( vout_thread_t *p_vout, unsigned *pi_width,
unsigned *pi_height )
{
vlc_value_t val;
int i_width, i_height;
uint64_t ll_zoom;
#define FP_FACTOR 1000 /* our fixed point factor */
var_Get( p_vout, "width", &val );
i_width = val.i_int;
var_Get( p_vout, "height", &val );
i_height = val.i_int;
var_Get( p_vout, "zoom", &val );
ll_zoom = (uint64_t)( FP_FACTOR * val.f_float );
if( i_width > 0 && i_height > 0)
{
*pi_width = (int)( i_width * ll_zoom / FP_FACTOR );
*pi_height = (int)( i_height * ll_zoom / FP_FACTOR );
return;
}
else if( i_width > 0 )
{
*pi_width = (int)( i_width * ll_zoom / FP_FACTOR );
*pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom *
p_vout->fmt_in.i_sar_den * i_width / p_vout->fmt_in.i_sar_num /
FP_FACTOR / p_vout->fmt_in.i_visible_width );
return;
}
else if( i_height > 0 )
{
*pi_height = (int)( i_height * ll_zoom / FP_FACTOR );
*pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom *
p_vout->fmt_in.i_sar_num * i_height / p_vout->fmt_in.i_sar_den /
FP_FACTOR / p_vout->fmt_in.i_visible_height );
return;
}
if( p_vout->fmt_in.i_sar_num >= p_vout->fmt_in.i_sar_den )
{
*pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom *
p_vout->fmt_in.i_sar_num / p_vout->fmt_in.i_sar_den / FP_FACTOR );
*pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom
/ FP_FACTOR );
}
else
{
*pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom
/ FP_FACTOR );
*pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom *
p_vout->fmt_in.i_sar_den / p_vout->fmt_in.i_sar_num / FP_FACTOR );
}
#undef FP_FACTOR
}
/***************************************************************************** /*****************************************************************************
* Object variables callbacks * Object variables callbacks
*****************************************************************************/ *****************************************************************************/
...@@ -577,6 +650,9 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -577,6 +650,9 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
} }
crop_end: crop_end:
InitWindowSize( p_vout, &p_vout->i_window_width,
&p_vout->i_window_height );
p_vout->i_changes |= VOUT_CROP_CHANGE; p_vout->i_changes |= VOUT_CROP_CHANGE;
msg_Dbg( p_vout, "cropping picture %ix%i to %i,%i,%ix%i", msg_Dbg( p_vout, "cropping picture %ix%i to %i,%i,%ix%i",
......
...@@ -445,19 +445,18 @@ void vout_PlacePicture( vout_thread_t *p_vout, ...@@ -445,19 +445,18 @@ void vout_PlacePicture( vout_thread_t *p_vout,
} }
if( p_vout->fmt_in.i_visible_width * (int64_t)p_vout->fmt_in.i_sar_num * if( p_vout->fmt_in.i_visible_width * (int64_t)p_vout->fmt_in.i_sar_num *
*pi_height / *pi_height / p_vout->fmt_in.i_visible_height /
(p_vout->fmt_in.i_visible_height * p_vout->fmt_in.i_sar_den) > p_vout->fmt_in.i_sar_den > *pi_width )
*pi_width )
{ {
*pi_height = p_vout->fmt_in.i_visible_height * *pi_height = p_vout->fmt_in.i_visible_height *
(int64_t)p_vout->fmt_in.i_sar_den * *pi_width / (int64_t)p_vout->fmt_in.i_sar_den * *pi_width /
(p_vout->fmt_in.i_visible_width * p_vout->fmt_in.i_sar_num); p_vout->fmt_in.i_visible_width / p_vout->fmt_in.i_sar_num;
} }
else else
{ {
*pi_width = p_vout->fmt_in.i_visible_width * *pi_width = p_vout->fmt_in.i_visible_width *
(int64_t)p_vout->fmt_in.i_sar_num * *pi_height / (int64_t)p_vout->fmt_in.i_sar_num * *pi_height /
(p_vout->fmt_in.i_visible_height * p_vout->fmt_in.i_sar_den); p_vout->fmt_in.i_visible_height / p_vout->fmt_in.i_sar_den;
} }
switch( p_vout->i_alignment & VOUT_ALIGN_HMASK ) switch( p_vout->i_alignment & VOUT_ALIGN_HMASK )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment