Commit 24a26dde authored by Rocky Bernstein's avatar Rocky Bernstein

Add vout_AspectRatio routine to get retrieve a vout's aspect ratio.

Some bugs when 16:9 scaling in ogt_parse.c and cvd_parse.c
parent 701342a1
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: vlc_video.h,v 1.7 2003/11/20 22:10:55 fenrir Exp $
* $Id: vlc_video.h,v 1.8 2004/01/10 13:59:25 rocky Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -240,6 +240,19 @@ struct subpicture_t
#define RESERVED_SUBPICTURE 1 /* allocated and reserved */
#define READY_SUBPICTURE 2 /* ready for display */
/*****************************************************************************
* Prototypes
*****************************************************************************/
/**
* vout_AspectRatio
*
* Set the i_aspect_x and i_aspect_y from the encoded aspect ratio i_aspect.
* \param i_aspect the encoded aspect ratio
* \param i_aspect_x the decoded x-axis portion of i_aspect. This is set.
* \param i_aspect_y the decoded y-axis portion of i_aspect This is set.
*/
VLC_EXPORT( void, vout_AspectRatio, ( unsigned int i_aspect, unsigned int *i_aspect_x, unsigned int *i_aspect_y ) );
/**@}*/
#endif /* _VLC_VIDEO_H */
......@@ -2,7 +2,7 @@
* Common SVCD and VCD subtitle routines.
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
* $Id: common.c,v 1.3 2004/01/03 12:54:56 rocky Exp $
* $Id: common.c,v 1.4 2004/01/10 13:59:25 rocky Exp $
*
* Author: Rocky Bernstein
* based on code from:
......@@ -211,8 +211,8 @@ VCDSubScaleX( decoder_t *p_dec, subpicture_t *p_spu,
unsigned int used=0; /* Number of bytes used up in p_src1. */
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_TRANSFORM) ,
"Old width: %d, new width: %d",
p_spu->i_width, i_new_width);
"aspect ratio %i:%i, Old width: %d, new width: %d",
i_scale_x, i_scale_y, p_spu->i_width, i_new_width);
for ( i_row=0; i_row <= p_spu->i_height - 1; i_row++ ) {
......
......@@ -2,7 +2,7 @@
* parse.c: Philips OGT (SVCD subtitle) packet parser
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
* $Id: cvd_parse.c,v 1.8 2004/01/04 22:22:10 gbazin Exp $
* $Id: cvd_parse.c,v 1.9 2004/01/10 13:59:25 rocky Exp $
*
* Authors: Rocky Bernstein
* based on code from:
......@@ -527,9 +527,22 @@ ParseImage( decoder_t *p_dec, subpicture_t * p_spu )
/* The video is automatically scaled. However subtitle bitmaps
assume a 1:1 aspect ratio. So we need to scale to compensate for
or undo the effects of video output scaling.
Perhaps this should go in the Render routine? The advantage would
be that it will deal with a dynamically changing aspect ratio.
The downside is having to scale many times for each render call.
*/
/* FIXME do the right scaling depending on vout. It may not be 4:3 */
VCDSubScaleX( p_dec, p_spu, 3, 4 );
{
vout_thread_t *p_vout = vlc_object_find( p_spu->p_sys->p_input,
VLC_OBJECT_VOUT,
FIND_CHILD );
unsigned int i_aspect_x, i_aspect_y;
if (p_vout) {
vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
VCDSubScaleX( p_dec, p_spu, i_aspect_y, i_aspect_x );
}
}
/* To be finished...*/
return VLC_SUCCESS;
......
......@@ -2,7 +2,7 @@
* Philips OGT (SVCD subtitle) packet parser
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
* $Id: ogt_parse.c,v 1.6 2004/01/04 22:22:10 gbazin Exp $
* $Id: ogt_parse.c,v 1.7 2004/01/10 13:59:25 rocky Exp $
*
* Author: Rocky Bernstein
* based on code from:
......@@ -372,9 +372,23 @@ ParseImage( decoder_t *p_dec, subpicture_t * p_spu )
/* The video is automatically scaled. However subtitle bitmaps
assume a 1:1 aspect ratio. So we need to scale to compensate for
or undo the effects of video output scaling.
Perhaps this should go in the Render routine? The advantage would
be that it will deal with a dynamically changing aspect ratio.
The downside is having to scale many times for each render call.
*/
/* FIXME do the right scaling depending on vout. It may not be 4:3 */
{
vout_thread_t *p_vout = vlc_object_find( p_spu->p_sys->p_input,
VLC_OBJECT_VOUT,
FIND_CHILD );
unsigned int i_aspect_x, i_aspect_y;
if (p_vout) {
vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
VCDSubScaleX( p_dec, p_spu, 3, 4 );
}
}
return VLC_SUCCESS;
}
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread.
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: video_output.c,v 1.243 2004/01/06 12:02:06 zorglub Exp $
* $Id: video_output.c,v 1.244 2004/01/10 13:59:25 rocky Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -65,6 +65,20 @@ static int DeinterlaceCallback( vlc_object_t *, char const *,
static int FilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/**
* vout_AspectRatio
*
* Set the i_aspect_x and i_aspect_y from i_aspect.
*/
void vout_AspectRatio( unsigned int i_aspect,
/*out*/ unsigned int *i_aspect_x,
/*out*/ unsigned int *i_aspect_y )
{
unsigned int i_pgcd = ReduceHeight( i_aspect );
*i_aspect_x = i_aspect / i_pgcd;
*i_aspect_y = VOUT_ASPECT_FACTOR / i_pgcd;
}
/*****************************************************************************
* vout_Request: find a video output thread, create one, or destroy one.
*****************************************************************************
......@@ -334,10 +348,12 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
if( i_new_aspect && i_new_aspect != i_aspect )
{
int i_pgcd = ReduceHeight( i_new_aspect );
unsigned int i_aspect_x, i_aspect_y;
vout_AspectRatio( i_new_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout, "overriding source aspect ratio to %i:%i",
i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
i_aspect_x, i_aspect_y );
p_vout->render.i_aspect = i_new_aspect;
......@@ -533,7 +549,8 @@ void vout_Destroy( vout_thread_t *p_vout )
*****************************************************************************/
static int InitThread( vout_thread_t *p_vout )
{
int i, i_pgcd;
int i;
unsigned int i_aspect_x, i_aspect_y;
vlc_mutex_lock( &p_vout->change_lock );
......@@ -582,28 +599,29 @@ static int InitThread( vout_thread_t *p_vout )
if( i_new_aspect && i_new_aspect != p_vout->output.i_aspect )
{
int i_pgcd = ReduceHeight( i_new_aspect );
vout_AspectRatio( i_new_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout, "output ratio forced to %i:%i\n",
i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
i_aspect_x, i_aspect_y );
p_vout->output.i_aspect = i_new_aspect;
}
}
}
#endif
i_pgcd = ReduceHeight( p_vout->render.i_aspect );
vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout,
"picture in %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
p_vout->render.i_width, p_vout->render.i_height,
p_vout->render.i_chroma, (char*)&p_vout->render.i_chroma,
p_vout->render.i_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
i_aspect_x, i_aspect_y );
i_pgcd = ReduceHeight( p_vout->output.i_aspect );
vout_AspectRatio( p_vout->output.i_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout,
"picture out %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_chroma, (char*)&p_vout->output.i_chroma,
p_vout->output.i_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
i_aspect_x, i_aspect_y );
/* Calculate shifts from system-updated masks */
MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift,
......
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