Commit c302e989 authored by Christophe Massiot's avatar Christophe Massiot

* include/video.h include/video_output.h src/video_output/vout_pictures.c:

  In vout_CreatePicture() replace i_repeat_first_field by the more useful
  i_nb_fields
* modules/gui/macosx/intf.m: Fixed a warning
* modules/codec/libmpeg2.c include/vout_synchro.h src/video_output/vout_synchro.c:
  Re-added support for slice-I streams, plus miscellaneous tweakings
parent 6a1d15a4
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.62 2003/03/28 17:02:25 gbazin Exp $
* $Id: video.h,v 1.63 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -74,7 +74,7 @@ struct picture_t
/* Picture dynamic properties - those properties can be changed by the
* decoder */
vlc_bool_t b_progressive; /* is it a progressive frame ? */
vlc_bool_t b_repeat_first_field; /* RFF bit */
unsigned int i_nb_fields; /* # of displayed fields */
vlc_bool_t b_top_field_first; /* which field is first */
/* The picture heap we are attached to */
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously opened video output thread.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.94 2003/04/27 23:16:35 gbazin Exp $
* $Id: video_output.h,v 1.95 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -154,7 +154,7 @@ VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t,
VLC_EXPORT( int, vout_ChromaCmp, ( uint32_t, uint32_t ) );
VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, vlc_bool_t, vlc_bool_t, vlc_bool_t ) );
VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, vlc_bool_t, vlc_bool_t, unsigned int ) );
VLC_EXPORT( void, vout_InitPicture, ( vlc_object_t *, picture_t *, int, int, uint32_t ) );
VLC_EXPORT( void, vout_AllocatePicture,( vout_thread_t *, picture_t *, int, int, uint32_t ) );
VLC_EXPORT( void, vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
......
......@@ -2,7 +2,7 @@
* vout_synchro.h: frame-dropping structures
*****************************************************************************
* Copyright (C) 1999-2003 VideoLAN
* $Id: vout_synchro.h,v 1.1 2003/04/14 22:22:32 massiot Exp $
* $Id: vout_synchro.h,v 1.2 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Jean-Marc Dressler <polux@via.ecp.fr>
......@@ -49,7 +49,11 @@ struct vout_synchro_t
/* and p_vout->render_time (read with p_vout->change_lock) */
/* stream context */
vlc_bool_t i_nb_ref; /* Number of reference pictures */
int i_nb_ref; /* Number of reference pictures */
int i_dec_nb_ref; /* Number of reference pictures we'll *
* have if we decode the current pic */
int i_trash_nb_ref; /* Number of reference pictures we'll *
* have if we trash the current pic */
unsigned int i_eta_p, i_eta_b;
mtime_t backward_pts, current_pts;
int i_current_period; /* period to add to the next picture */
......
......@@ -2,7 +2,7 @@
* libmpeg2.c: mpeg2 video decoder module making use of libmpeg2.
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: libmpeg2.c,v 1.19 2003/06/02 12:42:15 hartman Exp $
* $Id: libmpeg2.c,v 1.20 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -65,6 +65,10 @@ typedef struct dec_thread_t
mtime_t i_period_remainder;
int i_current_rate;
picture_t * p_picture_to_destroy;
vlc_bool_t b_garbage_pic;
vlc_bool_t b_after_sequence_header; /* is it the next frame after
* the sequence header ? */
vlc_bool_t b_slice_i; /* intra-slice refresh stream */
/*
* Output properties
......@@ -141,6 +145,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
p_dec->i_previous_pts = 0;
p_dec->i_period_remainder = 0;
p_dec->p_picture_to_destroy = NULL;
p_dec->b_garbage_pic = 0;
p_dec->b_slice_i = 0;
p_dec->b_skip = 0;
/* Initialize decoder */
......@@ -177,8 +183,37 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
{
vout_SynchroReset( p_dec->p_synchro );
if ( p_dec->p_info->current_fbuf != NULL )
p_dec->p_picture_to_destroy
= p_dec->p_info->current_fbuf->id;
{
p_dec->b_garbage_pic = 1;
p_pic = p_dec->p_info->current_fbuf->id;
}
else
{
uint8_t *buf[3];
buf[0] = buf[1] = buf[2] = NULL;
if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
break;
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, p_pic );
}
p_dec->p_picture_to_destroy = p_pic;
memset( p_pic->p[0].p_pixels, 0,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height );
memset( p_pic->p[1].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
memset( p_pic->p[2].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
if ( p_dec->b_slice_i )
{
vout_SynchroNewPicture( p_dec->p_synchro,
I_CODING_TYPE, 2, 0, 0, p_dec->i_current_rate );
vout_SynchroDecode( p_dec->p_synchro );
vout_SynchroEnd( p_dec->p_synchro, I_CODING_TYPE, 0 );
}
}
if( p_dec->p_pes->i_pts )
......@@ -259,7 +294,24 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
/* Set the first 2 reference frames */
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, NULL );
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, NULL );
if( (p_pic = GetNewPicture( p_dec, buf )) == NULL ) break;
memset( p_pic->p[0].p_pixels, 0,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height );
memset( p_pic->p[1].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
memset( p_pic->p[2].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, p_pic );
/* This picture will never go through display_picture. */
vout_DatePicture( p_dec->p_vout, p_pic, 0 );
vout_DisplayPicture( p_dec->p_vout, p_pic );
/* For some reason, libmpeg2 will put this pic twice in
* discard_picture. This can be considered a bug in libmpeg2. */
vout_LinkPicture( p_dec->p_vout, p_pic );
if ( p_dec->p_synchro )
{
......@@ -267,6 +319,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
}
p_dec->p_synchro = vout_SynchroInit( p_dec->p_fifo, p_dec->p_vout,
(u32)((u64)1001000000 * 27 / p_dec->p_info->sequence->frame_period) );
p_dec->b_after_sequence_header = 1;
}
break;
......@@ -292,6 +345,21 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
uint8_t *buf[3];
buf[0] = buf[1] = buf[2] = NULL;
if ( p_dec->b_after_sequence_header
&& ((p_dec->p_info->current_picture->flags
& PIC_MASK_CODING_TYPE)
== PIC_FLAG_CODING_TYPE_P) )
{
/* Intra-slice refresh. Simulate a blank I picture. */
msg_Dbg( p_dec->p_fifo, "intra-slice refresh stream" );
vout_SynchroNewPicture( p_dec->p_synchro,
I_CODING_TYPE, 2, 0, 0, p_dec->i_current_rate );
vout_SynchroDecode( p_dec->p_synchro );
vout_SynchroEnd( p_dec->p_synchro, I_CODING_TYPE, 0 );
p_dec->b_slice_i = 1;
}
p_dec->b_after_sequence_header = 0;
vout_SynchroNewPicture( p_dec->p_synchro,
p_dec->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
p_dec->p_info->current_picture->nb_fields,
......@@ -302,8 +370,12 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
0,
p_dec->i_current_rate );
if ( !vout_SynchroChoose( p_dec->p_synchro,
p_dec->p_info->current_picture->flags & PIC_MASK_CODING_TYPE ) )
if ( !(p_dec->b_slice_i
&& ((p_dec->p_info->current_picture->flags
& PIC_MASK_CODING_TYPE) == P_CODING_TYPE))
&& !vout_SynchroChoose( p_dec->p_synchro,
p_dec->p_info->current_picture->flags
& PIC_MASK_CODING_TYPE ) )
{
mpeg2_skip( p_dec->p_mpeg2dec, 1 );
p_dec->b_skip = 1;
......@@ -328,28 +400,22 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
{
p_pic = (picture_t *)p_dec->p_info->display_fbuf->id;
if ( p_pic != NULL )
{
if ( p_dec->p_picture_to_destroy != p_pic )
{
vout_SynchroEnd( p_dec->p_synchro,
vout_SynchroEnd( p_dec->p_synchro,
p_dec->p_info->display_picture->flags
& PIC_MASK_CODING_TYPE,
0 );
vout_DatePicture( p_dec->p_vout, p_pic,
vout_SynchroDate( p_dec->p_synchro ) );
vout_DisplayPicture( p_dec->p_vout, p_pic );
}
else
{
p_dec->p_picture_to_destroy = NULL;
vout_SynchroEnd( p_dec->p_synchro,
p_dec->p_info->display_picture->flags
& PIC_MASK_CODING_TYPE,
1 );
vout_DatePicture( p_dec->p_vout, p_pic, 0 );
vout_DisplayPicture( p_dec->p_vout, p_pic );
}
p_dec->b_garbage_pic );
p_dec->b_garbage_pic = 0;
vout_DisplayPicture( p_dec->p_vout, p_pic );
if ( p_dec->p_picture_to_destroy != p_pic )
{
vout_DatePicture( p_dec->p_vout, p_pic,
vout_SynchroDate( p_dec->p_synchro ) );
}
else
{
p_dec->p_picture_to_destroy = NULL;
vout_DatePicture( p_dec->p_vout, p_pic, 0 );
}
}
......@@ -379,11 +445,34 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
if( p_dec->p_info->current_fbuf &&
p_dec->p_info->current_fbuf->id )
{
p_pic = (picture_t *)p_dec->p_info->current_fbuf->id;
vout_UnlinkPicture( p_dec->p_vout, p_pic );
vout_DestroyPicture( p_dec->p_vout, p_pic );
p_dec->b_garbage_pic = 1;
p_pic = p_dec->p_info->current_fbuf->id;
}
else
{
if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
break;
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, p_pic );
}
p_dec->p_picture_to_destroy = p_pic;
memset( p_pic->p[0].p_pixels, 0,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height );
memset( p_pic->p[1].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
memset( p_pic->p[2].p_pixels, 0x80,
p_dec->p_info->sequence->width
* p_dec->p_info->sequence->height / 4 );
if ( p_dec->b_slice_i )
{
vout_SynchroNewPicture( p_dec->p_synchro,
I_CODING_TYPE, 2, 0, 0, p_dec->i_current_rate );
vout_SynchroDecode( p_dec->p_synchro );
vout_SynchroEnd( p_dec->p_synchro, I_CODING_TYPE, 0 );
}
mpeg2_set_buf( p_dec->p_mpeg2dec, buf, NULL );
break;
}
......@@ -461,9 +550,18 @@ static void CloseDecoder( dec_thread_t * p_dec )
static picture_t *GetNewPicture( dec_thread_t *p_dec, uint8_t **pp_buf )
{
picture_t *p_pic;
vlc_bool_t b_progressive = p_dec->p_info->current_picture != NULL ?
p_dec->p_info->current_picture->flags & PIC_FLAG_PROGRESSIVE_FRAME :
1;
vlc_bool_t b_top_field_first = p_dec->p_info->current_picture != NULL ?
p_dec->p_info->current_picture->flags & PIC_FLAG_TOP_FIELD_FIRST :
1;
unsigned int i_nb_fields = p_dec->p_info->current_picture != NULL ?
p_dec->p_info->current_picture->nb_fields : 2;
/* Get a new picture */
while( !(p_pic = vout_CreatePicture( p_dec->p_vout, 0, 0, 0 ) ) )
while( !(p_pic = vout_CreatePicture( p_dec->p_vout,
b_progressive, b_top_field_first, i_nb_fields )) )
{
if( p_dec->p_fifo->b_die || p_dec->p_fifo->b_error )
break;
......
......@@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: intf.m,v 1.88 2003/06/01 23:48:17 hartman Exp $
* $Id: intf.m,v 1.89 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -35,6 +35,7 @@
#include "prefs.h"
#include "playlist.h"
#include "info.h"
#include "controls.h"
/*****************************************************************************
* Local prototypes.
......
......@@ -2,7 +2,7 @@
* vout_pictures.c : picture management functions
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: vout_pictures.c,v 1.39 2003/04/27 23:16:35 gbazin Exp $
* $Id: vout_pictures.c,v 1.40 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -108,7 +108,7 @@ void vout_DatePicture( vout_thread_t *p_vout,
picture_t *vout_CreatePicture( vout_thread_t *p_vout,
vlc_bool_t b_progressive,
vlc_bool_t b_top_field_first,
vlc_bool_t b_repeat_first_field )
unsigned int i_nb_fields )
{
int i_pic; /* picture index */
picture_t * p_pic;
......@@ -136,7 +136,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
p_pic->b_force = 0;
p_pic->b_progressive = b_progressive;
p_pic->b_repeat_first_field = b_repeat_first_field;
p_pic->i_nb_fields = i_nb_fields;
p_pic->b_top_field_first = b_top_field_first;
p_vout->i_heap_size++;
......@@ -178,7 +178,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
p_freepic->b_force = 0;
p_freepic->b_progressive = b_progressive;
p_freepic->b_repeat_first_field = b_repeat_first_field;
p_freepic->i_nb_fields = i_nb_fields;
p_freepic->b_top_field_first = b_top_field_first;
p_freepic->i_matrix_coefficients = 1;
......
......@@ -2,7 +2,7 @@
* vout_synchro.c : frame dropping routines
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: vout_synchro.c,v 1.2 2003/05/04 22:33:35 massiot Exp $
* $Id: vout_synchro.c,v 1.3 2003/06/09 00:33:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -134,6 +134,7 @@ vout_synchro_t * __vout_SynchroInit( vlc_object_t * p_object,
memset( p_synchro->p_tau, 0, 4 * sizeof(mtime_t) );
memset( p_synchro->pi_meaningful, 0, 4 * sizeof(unsigned int) );
p_synchro->i_nb_ref = 0;
p_synchro->i_trash_nb_ref = p_synchro->i_dec_nb_ref = 0;
p_synchro->current_pts = mdate() + DEFAULT_PTS_DELAY;
p_synchro->backward_pts = 0;
p_synchro->i_current_period = p_synchro->i_backward_period = 0;
......@@ -161,6 +162,7 @@ void vout_SynchroRelease( vout_synchro_t * p_synchro )
void vout_SynchroReset( vout_synchro_t * p_synchro )
{
p_synchro->i_nb_ref = 0;
p_synchro->i_trash_nb_ref = p_synchro->i_dec_nb_ref = 0;
}
/*****************************************************************************
......@@ -215,10 +217,7 @@ vlc_bool_t vout_SynchroChoose( vout_synchro_t * p_synchro, int i_coding_type )
{
msg_Warn( p_synchro,
"synchro trashing I ("I64Fd")", pts - now );
p_synchro->i_nb_ref = 0;
}
else if( p_synchro->i_nb_ref < 2 )
p_synchro->i_nb_ref++;
break;
case P_CODING_TYPE:
......@@ -258,10 +257,6 @@ vlc_bool_t vout_SynchroChoose( vout_synchro_t * p_synchro, int i_coding_type )
{
b_decode = 0;
}
if( b_decode )
p_synchro->i_nb_ref = 2;
else
p_synchro->i_nb_ref = 0;
break;
case B_CODING_TYPE:
......@@ -296,6 +291,7 @@ vlc_bool_t vout_SynchroChoose( vout_synchro_t * p_synchro, int i_coding_type )
void vout_SynchroTrash( vout_synchro_t * p_synchro )
{
p_synchro->i_trashed_pic++;
p_synchro->i_nb_ref = p_synchro->i_trash_nb_ref;
}
/*****************************************************************************
......@@ -304,6 +300,7 @@ void vout_SynchroTrash( vout_synchro_t * p_synchro )
void vout_SynchroDecode( vout_synchro_t * p_synchro )
{
p_synchro->decoding_start = mdate();
p_synchro->i_nb_ref = p_synchro->i_dec_nb_ref;
}
/*****************************************************************************
......@@ -365,14 +362,17 @@ void vout_SynchroNewPicture( vout_synchro_t * p_synchro, int i_coding_type,
if( p_synchro->i_eta_p
&& p_synchro->i_eta_p != p_synchro->i_n_p )
{
#if 0
msg_Dbg( p_synchro,
"stream periodicity changed from P[%d] to P[%d]",
p_synchro->i_n_p, p_synchro->i_eta_p );
#endif
p_synchro->i_n_p = p_synchro->i_eta_p;
}
p_synchro->i_eta_p = p_synchro->i_eta_b = 0;
p_synchro->i_trash_nb_ref = 0;
if( p_synchro->i_nb_ref < 2 )
p_synchro->i_dec_nb_ref = p_synchro->i_nb_ref + 1;
else
p_synchro->i_dec_nb_ref = p_synchro->i_nb_ref;
#if 0
msg_Dbg( p_synchro, "I("I64Fd") P("I64Fd")[%d] B("I64Fd")"
......@@ -407,15 +407,20 @@ void vout_SynchroNewPicture( vout_synchro_t * p_synchro, int i_coding_type,
if( p_synchro->i_eta_b
&& p_synchro->i_eta_b != p_synchro->i_n_b )
{
msg_Warn( p_synchro,
"stream periodicity changed from B[%d] to B[%d]",
p_synchro->i_n_b, p_synchro->i_eta_b );
msg_Dbg( p_synchro,
"stream periodicity changed from B[%d] to B[%d]",
p_synchro->i_n_b, p_synchro->i_eta_b );
p_synchro->i_n_b = p_synchro->i_eta_b;
}
p_synchro->i_eta_b = 0;
p_synchro->i_dec_nb_ref = 2;
p_synchro->i_trash_nb_ref = 0;
break;
case B_CODING_TYPE:
p_synchro->i_eta_b++;
p_synchro->i_dec_nb_ref = p_synchro->i_trash_nb_ref
= p_synchro->i_nb_ref;
break;
}
......
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