Commit 3861944d authored by Christophe Massiot's avatar Christophe Massiot

* Chroma 4:2:2 and 4:4:4 support in the decoder.

* Fixed bugs in the C YUV transform with 4:2:2 format.
parent bfd9535d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vdec_ext-plugins.h : structures from the video decoder exported to plug-ins * vdec_ext-plugins.h : structures from the video decoder exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vdec_ext-plugins.h,v 1.5 2001/09/25 11:46:13 massiot Exp $ * $Id: vdec_ext-plugins.h,v 1.6 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -34,8 +34,6 @@ typedef struct idct_inner_s ...@@ -34,8 +34,6 @@ typedef struct idct_inner_s
/* sparse IDCT or not, add or copy ? */ /* sparse IDCT or not, add or copy ? */
int i_sparse_pos; /* position of the int i_sparse_pos; /* position of the
* non-NULL coeff */ * non-NULL coeff */
yuv_data_t * p_dct_data; /* pointer to the position
* in the final picture */
} idct_inner_t; } idct_inner_t;
typedef struct motion_inner_s typedef struct motion_inner_s
...@@ -53,11 +51,14 @@ typedef struct macroblock_s ...@@ -53,11 +51,14 @@ typedef struct macroblock_s
int i_mb_modes; int i_mb_modes;
/* IDCT information */ /* IDCT information */
idct_inner_t p_idcts[6]; idct_inner_t p_idcts[12];
int i_coded_block_pattern; int i_coded_block_pattern;
/* which blocks are coded ? */ /* which blocks are coded ? */
int i_lum_dct_stride, i_chrom_dct_stride; yuv_data_t * p_y_data;
/* nb of coeffs to jump when changing lines */ yuv_data_t * p_u_data;
yuv_data_t * p_v_data;
/* pointers to the position
* in the final picture */
/* Motion compensation information */ /* Motion compensation information */
motion_inner_t p_motions[8]; motion_inner_t p_motions[8];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transforms_common.h: YUV transformation macros for truecolor * transforms_common.h: YUV transformation macros for truecolor
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: transforms_common.h,v 1.2 2001/03/21 13:42:34 sam Exp $ * $Id: transforms_common.h,v 1.3 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
*****************************************************************************/ *****************************************************************************/
#define SCALE_HEIGHT( CHROMA, BPP ) \ #define SCALE_HEIGHT( CHROMA, BPP ) \
/* If line is odd, rewind 4:2:0 U and V samples */ \ /* If line is odd, rewind 4:2:0 U and V samples */ \
if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \ if( (CHROMA == 420) && !(i_y & 0x1) ) \
{ \ { \
p_u -= i_chroma_width; \ p_u -= i_chroma_width; \
p_v -= i_chroma_width; \ p_v -= i_chroma_width; \
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
/* Height reduction: skip next source line */ \ /* Height reduction: skip next source line */ \
p_y += i_width; \ p_y += i_width; \
i_y++; \ i_y++; \
if( (CHROMA == 420) || (CHROMA == 422) ) \ if( CHROMA == 420 ) \
{ \ { \
if( i_y & 0x1 ) \ if( i_y & 0x1 ) \
{ \ { \
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
p_v += i_chroma_width; \ p_v += i_chroma_width; \
} \ } \
} \ } \
else if( CHROMA == 444 ) \ else if( (CHROMA == 422) || (CHROMA == 444) ) \
{ \ { \
p_u += i_width; \ p_u += i_width; \
p_v += i_width; \ p_v += i_width; \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transforms_yuv.h: C specific YUV transformation macros * transforms_yuv.h: C specific YUV transformation macros
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: transforms_yuv.h,v 1.2 2001/03/21 13:42:34 sam Exp $ * $Id: transforms_yuv.h,v 1.3 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
#define SCALE_HEIGHT_DITHER( CHROMA ) \ #define SCALE_HEIGHT_DITHER( CHROMA ) \
\ \
/* If line is odd, rewind 4:2:0 U and V samples */ \ /* If line is odd, rewind 4:2:0 U and V samples */ \
if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \ if( (CHROMA == 420) && !(i_y & 0x1) ) \
{ \ { \
p_u -= i_chroma_width; \ p_u -= i_chroma_width; \
p_v -= i_chroma_width; \ p_v -= i_chroma_width; \
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
/* Height reduction: skip next source line */ \ /* Height reduction: skip next source line */ \
p_y += i_width; \ p_y += i_width; \
i_y++; \ i_y++; \
if( (CHROMA == 420) || (CHROMA == 422) ) \ if( CHROMA == 420 ) \
{ \ { \
if( i_y & 0x1 ) \ if( i_y & 0x1 ) \
{ \ { \
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
p_v += i_chroma_width; \ p_v += i_chroma_width; \
} \ } \
} \ } \
else if( CHROMA == 444 ) \ else if( (CHROMA == 422) || (CHROMA == 444) ) \
{ \ { \
p_u += i_width; \ p_u += i_width; \
p_v += i_width; \ p_v += i_width; \
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_decoder.h : video decoder thread * video_decoder.h : video decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_decoder.h,v 1.5 2001/08/22 17:21:45 massiot Exp $ * $Id: video_decoder.h,v 1.6 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -26,10 +26,14 @@ ...@@ -26,10 +26,14 @@
*****************************************************************************/ *****************************************************************************/
void vdec_InitThread ( struct vdec_thread_s * ); void vdec_InitThread ( struct vdec_thread_s * );
void vdec_EndThread ( struct vdec_thread_s * ); void vdec_EndThread ( struct vdec_thread_s * );
void vdec_DecodeMacroblockC ( struct vdec_thread_s *,
struct macroblock_s * );
void vdec_DecodeMacroblockBW ( struct vdec_thread_s *, void vdec_DecodeMacroblockBW ( struct vdec_thread_s *,
struct macroblock_s * ); struct macroblock_s * );
void vdec_DecodeMacroblock420( struct vdec_thread_s *,
struct macroblock_s * );
void vdec_DecodeMacroblock422( struct vdec_thread_s *,
struct macroblock_s * );
void vdec_DecodeMacroblock444( struct vdec_thread_s *,
struct macroblock_s * );
struct vdec_thread_s * vdec_CreateThread( struct vdec_pool_s * ); struct vdec_thread_s * vdec_CreateThread( struct vdec_pool_s * );
void vdec_DestroyThread ( struct vdec_thread_s * ); void vdec_DestroyThread ( struct vdec_thread_s * );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.h : video parser thread * video_parser.h : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_parser.h,v 1.15 2001/10/01 16:44:07 massiot Exp $ * $Id: video_parser.h,v 1.16 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Jean-Marc Dressler <polux@via.ecp.fr> * Jean-Marc Dressler <polux@via.ecp.fr>
...@@ -116,6 +116,8 @@ typedef struct sequence_s ...@@ -116,6 +116,8 @@ typedef struct sequence_s
unsigned int i_aspect_ratio; /* height/width display ratio */ unsigned int i_aspect_ratio; /* height/width display ratio */
unsigned int i_matrix_coefficients;/* coeffs of the YUV transform */ unsigned int i_matrix_coefficients;/* coeffs of the YUV transform */
int i_chroma_format, i_scalable_mode; int i_chroma_format, i_scalable_mode;
int i_chroma_nb_blocks;
boolean_t b_chroma_h_subsampled, b_chroma_v_subsampled;
int i_frame_rate; /* theoritical frame rate in fps*1001 */ int i_frame_rate; /* theoritical frame rate in fps*1001 */
boolean_t b_mpeg2; /* guess */ boolean_t b_mpeg2; /* guess */
boolean_t b_progressive; /* progressive (ie. boolean_t b_progressive; /* progressive (ie.
...@@ -202,6 +204,7 @@ typedef struct picture_parsing_s ...@@ -202,6 +204,7 @@ typedef struct picture_parsing_s
#define SC_TEMP 4 #define SC_TEMP 4
/* Chroma types */ /* Chroma types */
#define CHROMA_NONE 0
#define CHROMA_420 1 #define CHROMA_420 1
#define CHROMA_422 2 #define CHROMA_422 2
#define CHROMA_444 3 #define CHROMA_444 3
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_headers.c : headers parsing * vpar_headers.c : headers parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_headers.c,v 1.11 2001/10/01 16:44:07 massiot Exp $ * $Id: vpar_headers.c,v 1.12 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "vdec_ext-plugins.h" #include "vdec_ext-plugins.h"
#include "vpar_pool.h" #include "vpar_pool.h"
#include "video_parser.h" #include "video_parser.h"
#include "video_decoder.h"
/* /*
* Local prototypes * Local prototypes
...@@ -397,6 +398,24 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -397,6 +398,24 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
p_vpar->sequence.i_height = (p_vpar->sequence.i_mb_height * 16); p_vpar->sequence.i_height = (p_vpar->sequence.i_mb_height * 16);
p_vpar->sequence.i_size = p_vpar->sequence.i_width p_vpar->sequence.i_size = p_vpar->sequence.i_width
* p_vpar->sequence.i_height; * p_vpar->sequence.i_height;
switch( p_vpar->sequence.i_chroma_format )
{
case CHROMA_420:
p_vpar->sequence.i_chroma_nb_blocks = 2;
p_vpar->sequence.b_chroma_h_subsampled = 1;
p_vpar->sequence.b_chroma_v_subsampled = 1;
break;
case CHROMA_422:
p_vpar->sequence.i_chroma_nb_blocks = 4;
p_vpar->sequence.b_chroma_h_subsampled = 1;
p_vpar->sequence.b_chroma_v_subsampled = 0;
break;
case CHROMA_444:
p_vpar->sequence.i_chroma_nb_blocks = 6;
p_vpar->sequence.b_chroma_h_subsampled = 0;
p_vpar->sequence.b_chroma_v_subsampled = 0;
break;
}
#if 0 #if 0
if( p_vpar->sequence.i_width != i_width_save if( p_vpar->sequence.i_width != i_width_save
...@@ -750,6 +769,28 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -750,6 +769,28 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->picture.b_current_field = p_vpar->picture.b_current_field =
(i_structure == BOTTOM_FIELD ); (i_structure == BOTTOM_FIELD );
if( !p_vpar->p_config->decoder_config.p_stream_ctrl->b_grayscale )
{
switch( p_vpar->sequence.i_chroma_format )
{
case CHROMA_422:
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblock422;
break;
case CHROMA_444:
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblock444;
break;
case CHROMA_420:
default:
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblock420;
break;
}
}
else
{
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblockBW;
}
if( p_vpar->sequence.b_mpeg2 ) if( p_vpar->sequence.b_mpeg2 )
{ {
static f_picture_data_t ppf_picture_data[4][4] = static f_picture_data_t ppf_picture_data[4][4] =
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_pool.c : management of the pool of decoder threads * vpar_pool.c : management of the pool of decoder threads
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: vpar_pool.c,v 1.3 2001/09/25 11:46:14 massiot Exp $ * $Id: vpar_pool.c,v 1.4 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -77,6 +77,7 @@ void vpar_InitPool( vpar_thread_t * p_vpar ) ...@@ -77,6 +77,7 @@ void vpar_InitPool( vpar_thread_t * p_vpar )
p_vpar->pool.p_macroblocks = NULL; p_vpar->pool.p_macroblocks = NULL;
p_vpar->pool.pp_empty_macroblocks = NULL; p_vpar->pool.pp_empty_macroblocks = NULL;
p_vpar->pool.pp_new_macroblocks = NULL; p_vpar->pool.pp_new_macroblocks = NULL;
p_vpar->pool.p_vpar = p_vpar;
vpar_SpawnPool( p_vpar ); vpar_SpawnPool( p_vpar );
/* Initialize fake video decoder structure (used when /* Initialize fake video decoder structure (used when
...@@ -92,7 +93,7 @@ void vpar_InitPool( vpar_thread_t * p_vpar ) ...@@ -92,7 +93,7 @@ void vpar_InitPool( vpar_thread_t * p_vpar )
p_vpar->pool.p_vdec->p_pool = &p_vpar->pool; p_vpar->pool.p_vdec->p_pool = &p_vpar->pool;
vdec_InitThread( p_vpar->pool.p_vdec ); vdec_InitThread( p_vpar->pool.p_vdec );
for( j = 0; j < 6; j++ ) for( j = 0; j < 12; j++ )
{ {
p_vpar->pool.mb.p_idcts[j].pi_block = p_vpar->pool.mb.p_idcts[j].pi_block =
memalign( 16, 64 * sizeof(dctelem_t) ); memalign( 16, 64 * sizeof(dctelem_t) );
...@@ -110,13 +111,11 @@ void vpar_InitPool( vpar_thread_t * p_vpar ) ...@@ -110,13 +111,11 @@ void vpar_InitPool( vpar_thread_t * p_vpar )
void vpar_SpawnPool( vpar_thread_t * p_vpar ) void vpar_SpawnPool( vpar_thread_t * p_vpar )
{ {
int i_new_smp; int i_new_smp;
boolean_t b_grayscale;
stream_ctrl_t * p_control; stream_ctrl_t * p_control;
p_control = p_vpar->p_config->decoder_config.p_stream_ctrl; p_control = p_vpar->p_config->decoder_config.p_stream_ctrl;
vlc_mutex_lock( &p_control->control_lock ); vlc_mutex_lock( &p_control->control_lock );
i_new_smp = p_control->i_smp; i_new_smp = p_control->i_smp;
b_grayscale = p_control->b_grayscale;
vlc_mutex_unlock( &p_control->control_lock ); vlc_mutex_unlock( &p_control->control_lock );
/* FIXME: No error check because I'm tired. Come back later... */ /* FIXME: No error check because I'm tired. Come back later... */
...@@ -136,7 +135,7 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar ) ...@@ -136,7 +135,7 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar )
vdec_DestroyThread( p_vpar->pool.pp_vdec[i] ); vdec_DestroyThread( p_vpar->pool.pp_vdec[i] );
for( j = 0; j < 6; j++ ) for( j = 0; j < 12; j++ )
{ {
free( p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block ); free( p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block );
} }
...@@ -172,7 +171,7 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar ) ...@@ -172,7 +171,7 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar )
{ {
int j; int j;
for( j = 0; j < 6; j++ ) for( j = 0; j < 12; j++ )
{ {
p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block = p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block =
memalign( 16, 64 * sizeof(dctelem_t) ); memalign( 16, 64 * sizeof(dctelem_t) );
...@@ -206,15 +205,6 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar ) ...@@ -206,15 +205,6 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar )
p_vpar->pool.pf_free_mb = FreeMacroblockDummy; p_vpar->pool.pf_free_mb = FreeMacroblockDummy;
p_vpar->pool.pf_decode_mb = DecodeMacroblockDummy; p_vpar->pool.pf_decode_mb = DecodeMacroblockDummy;
} }
if( !b_grayscale )
{
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblockC;
}
else
{
p_vpar->pool.pf_vdec_decode = vdec_DecodeMacroblockBW;
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -230,7 +220,7 @@ void vpar_EndPool( vpar_thread_t * p_vpar ) ...@@ -230,7 +220,7 @@ void vpar_EndPool( vpar_thread_t * p_vpar )
vdec_DestroyThread( p_vpar->pool.pp_vdec[i] ); vdec_DestroyThread( p_vpar->pool.pp_vdec[i] );
for( j = 0; j < 6; j++ ) for( j = 0; j < 12; j++ )
{ {
free( p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block ); free( p_vpar->pool.p_macroblocks[i].p_idcts[j].pi_block );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_pool.h : video parser/video decoders communication * vpar_pool.h : video parser/video decoders communication
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_pool.h,v 1.3 2001/09/05 16:07:50 massiot Exp $ * $Id: vpar_pool.h,v 1.4 2001/10/11 13:19:27 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -76,6 +76,8 @@ typedef struct vdec_pool_s ...@@ -76,6 +76,8 @@ typedef struct vdec_pool_s
void ( * pf_idct_init ) ( void ** ); void ( * pf_idct_init ) ( void ** );
void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *, void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
int, int ); int, int );
struct vpar_thread_s * p_vpar;
} vdec_pool_t; } vdec_pool_t;
/***************************************************************************** /*****************************************************************************
......
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