Commit 7295c009 authored by Jean-Marc Dressler's avatar Jean-Marc Dressler

Avancement du debuggage du motion.

parent 784b971f
......@@ -127,6 +127,8 @@ static void __inline__ MotionComponent( yuv_data_t * p_src, yuv_data_t * p_dest,
>> 1;
}
}
p_dest += i_x_step;
p_src += i_x_step;
}
}
break;
......@@ -168,6 +170,8 @@ static void __inline__ MotionComponent( yuv_data_t * p_src, yuv_data_t * p_dest,
>> 1;
}
}
p_dest += i_x_step;
p_src += i_x_step;
}
}
break;
......@@ -475,19 +479,20 @@ void vdec_MotionFrameField( macroblock_t * p_mb )
if( p_mb->i_mb_type & MB_MOTION_FORWARD )
{
args.p_source = p_mb->p_forward;
#if 1
args.b_source_field = p_mb->ppi_field_select[0][0];
args.b_dest_field = 0;
args.i_mv_x = p_mb->pppi_motion_vectors[0][0][0];
args.i_mv_y = p_mb->pppi_motion_vectors[0][0][1] >> 1;
p_mb->pf_chroma_motion( p_mb, &args );
#endif
#if 1
args.b_source_field = p_mb->ppi_field_select[1][0];
args.b_dest_field = 1;
args.i_mv_x = p_mb->pppi_motion_vectors[1][0][0];
args.i_mv_y = p_mb->pppi_motion_vectors[1][0][1] >> 1;
args.i_mv_x = p_mb->pppi_motion_vectors[0][0][0];
args.i_mv_y = p_mb->pppi_motion_vectors[0][0][1] >> 1;
p_mb->pf_chroma_motion( p_mb, &args );
#endif
args.b_average = 1;
}
......@@ -564,7 +569,8 @@ void vdec_MotionFrameDMV( macroblock_t * p_mb )
*****************************************************************************/
void vdec_Motion420( macroblock_t * p_mb, motion_arg_t * p_motion )
{
p_motion->i_mv_x = p_motion->i_mv_y = 0;
// p_motion->i_mv_x = p_motion->i_mv_y = 0;
//fprintf( stderr, " x %d, y %d \n", p_motion->i_mv_x, p_motion->i_mv_y );
/* Luminance */
MotionComponent( /* source */
p_motion->p_source->p_y
......@@ -618,7 +624,6 @@ void vdec_Motion420( macroblock_t * p_mb, motion_arg_t * p_motion )
(p_motion->b_average << 2)
| (((p_motion->i_mv_y/2) & 1) << 1)
| ((p_motion->i_mv_x/2) & 1) );
}
/*****************************************************************************
......
......@@ -256,7 +256,7 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
* Motion Compensation (ISO/IEC 13818-2 section 7.6)
*/
(*p_mb->pf_motion)( p_mb );
if( !p_mb->b_P_coding_type ) {
/* luminance */
for( i_b = 0; i_b < 4; i_b++ )
{
......@@ -288,7 +288,7 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
(p_mb->pf_addb[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_addb_c_stride );
}
}
/*
* Decoding is finished, release the macroblock and free
* unneeded memory.
......@@ -320,26 +320,17 @@ void vdec_AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, yuv_data_t * p_
void vdec_CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, yuv_data_t * p_data, int i_incr )
{
int i_y;
//fprintf(stderr, "%d ", i_incr );
for( i_y = 0; i_y < 8; i_y++ )
{
#if 0
/* dctelem_t and yuv_data_t are the same */
memcpy( p_data, p_block, 8*sizeof(yuv_data_t) );
p_data += i_incr+8;
p_block += 8;
#else
int i_x;
for( i_x = 0; i_x < 8; i_x++ )
{
/* ??? Need clip to be MPEG-2 compliant */
/* ??? Why does the reference decoder add 128 ??? */
*p_data++ = p_vdec->pi_crop[*p_block++];
}
p_data += i_incr;
#endif
}
}
......
......@@ -183,7 +183,7 @@ void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
/* Unlink picture buffer */
vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
p_mb->p_picture->i_deccount--;
b_finished = (p_mb->p_picture->i_deccount == 1);
b_finished = (p_mb->p_picture->i_deccount == 0);
vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
/* Test if it was the last block of the picture */
......
......@@ -590,9 +590,13 @@ static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
if( (p_vpar->picture.i_coding_type == P_CODING_TYPE) ||
(p_vpar->picture.i_coding_type == B_CODING_TYPE) )
p_mb->p_forward = p_vpar->sequence.p_forward;
p_mb->p_forward = p_vpar->sequence.p_forward;
else
p_mb->p_forward = NULL;
if( p_vpar->picture.i_coding_type == B_CODING_TYPE )
p_mb->p_backward = p_vpar->sequence.p_backward;
else
p_mb->p_backward = NULL;
p_mb->i_addb_l_stride = (p_mb->i_l_stride = p_vpar->picture.i_l_stride) - 8;
p_mb->i_addb_c_stride = (p_mb->i_c_stride = p_vpar->picture.i_c_stride) - 8;
......@@ -1236,7 +1240,7 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
: i_level;
break;
case DCT_EOB:
if( i_nc <= 1 )
if( i_nc <= 0 )
{
p_mb->pf_idct[i_b] = vdec_SparseIDCT;
p_mb->pi_sparse_pos[i_b] = i_coef;
......
......@@ -203,9 +203,8 @@ static void __inline__ ReferenceReplace( vpar_thread_t * p_vpar,
{
if( i_coding_type != B_CODING_TYPE )
{
if( p_vpar->sequence.p_forward != NULL )
vout_UnlinkPicture( p_vpar->p_vout, p_vpar->sequence.p_forward );
p_vpar->sequence.p_forward = p_vpar->sequence.p_backward;
if( p_vpar->sequence.p_backward != NULL )
vout_UnlinkPicture( p_vpar->p_vout, p_vpar->sequence.p_backward );
p_vpar->sequence.p_backward = p_newref;
if( p_newref != NULL )
vout_LinkPicture( p_vpar->p_vout, p_newref );
......@@ -525,7 +524,9 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->picture.pf_macroblock_type = ppf_macroblock_type
[p_vpar->picture.i_coding_type];
RemoveBits( &p_vpar->bit_stream, 16 ); /* vbv_delay */
fprintf( stderr, "coding type: %d\n", p_vpar->picture.i_coding_type );
if( p_vpar->picture.i_coding_type == P_CODING_TYPE || p_vpar->picture.i_coding_type == B_CODING_TYPE )
{
p_vpar->picture.pb_full_pel_vector[0] = GetBits( &p_vpar->bit_stream, 1 );
......
/*****************************************************************************
* vpar_motion.c : motion vectors parsing
* (c)1999 VideoLAN
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "vdec_idct.h"
#include "video_decoder.h"
#include "vdec_motion.h"
#include "vpar_blocks.h"
#include "vpar_headers.h"
#include "video_fifo.h"
#include "vpar_synchro.h"
#include "video_parser.h"
#include "vpar_motion.h"
/*
* Local prototypes
*/
/****************************************************************************
* vpar_MotionCode : Parse the next motion code
****************************************************************************/
static __inline__ int vpar_MotionCode( vpar_thread_t * p_vpar )
{
int i_code;
static lookup_t pl_mv_tab0[8] =
{ {-1,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1} };
/* Table B-10, motion_code, codes 0000011 ... 000011x */
static lookup_t pl_mv_tab1[8] =
{ {-1,0}, {-1,0}, {-1,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5} };
/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
static lookup_t pl_mv_tab2[12] = {
{16,9}, {15,9}, {14,9}, {13,9},
{12,9}, {11,9}, {10,8}, {10,8},
{9,8}, {9,8}, {8,8}, {8,8} };
if( GetBits(&p_vpar->bit_stream, 1) )
{
return 0;
}
if( (i_code = ShowBits(&p_vpar->bit_stream, 9)) >= 64 )
{
i_code >>= 6;
RemoveBits( &p_vpar->bit_stream, pl_mv_tab0[i_code].i_length );
return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab0[i_code].i_value : pl_mv_tab0[i_code].i_value );
}
if( i_code >= 24 )
{
i_code >>= 3;
RemoveBits( &p_vpar->bit_stream, pl_mv_tab1[i_code].i_length );
return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab1[i_code].i_value : pl_mv_tab1[i_code].i_value );
}
if( (i_code -= 12) < 0 )
{
p_vpar->picture.b_error = 1;
intf_DbgMsg( "vpar debug: Invalid motion_vector code\n" );
return 0;
}
RemoveBits( &p_vpar->bit_stream, pl_mv_tab2[i_code].i_length );
return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab2[i_code].i_value : pl_mv_tab2[i_code].i_value );
}
/****************************************************************************
* vpar_DecodeMotionVector : decode a motion_vector
****************************************************************************/
static __inline__ void vpar_DecodeMotionVector( int * pi_prediction, int i_r_size,
int i_motion_code, int i_motion_residual, int i_full_pel )
{
int i_limit, i_vector;
/* ISO/IEC 13818-1 section 7.6.3.1 */
i_limit = 16 << i_r_size;
i_vector = *pi_prediction >> i_full_pel;
if( i_motion_code > 0 )
{
i_vector += ((i_motion_code-1) << i_r_size) + i_motion_residual + 1;
if( i_vector >= i_limit )
i_vector -= i_limit + i_limit;
}
else if( i_motion_code < 0 )
{
i_vector -= ((-i_motion_code-1) << i_r_size) + i_motion_residual + 1;
if( i_vector < -i_limit )
i_vector += i_limit + i_limit;
}
*pi_prediction = i_vector << i_full_pel;
}
/****************************************************************************
* vpar_MotionVector : Parse the next motion_vector field
****************************************************************************/
void vpar_MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_r,
int i_s, int i_full_pel )
{
int i_motion_code, i_motion_residual;
int i_r_size;
i_r_size = p_vpar->picture.ppi_f_code[i_s][0]-1;
i_motion_code = vpar_MotionCode( p_vpar );
i_motion_residual = (i_r_size != 0 && i_motion_code != 0) ?
GetBits( &p_vpar->bit_stream, i_r_size) : 0;
vpar_DecodeMotionVector( &p_vpar->slice.pppi_pmv[i_r][i_s][0], i_r_size,
i_motion_code, i_motion_residual, i_full_pel );
p_mb->pppi_motion_vectors[i_r][i_s][0] = p_vpar->slice.pppi_pmv[i_r][i_s][0];
if( p_vpar->mb.b_dmv )
{
if( GetBits(&p_vpar->bit_stream, 1) )
{
p_mb->pi_dm_vector[0] = GetBits( &p_vpar->bit_stream, 1 ) ? -1 : 1;
}
else
{
p_mb->pi_dm_vector[0] = 0;
}
}
i_r_size = p_vpar->picture.ppi_f_code[i_s][1]-1;
i_motion_code = vpar_MotionCode( p_vpar );
i_motion_residual = (i_r_size != 0 && i_motion_code != 0) ?
GetBits( &p_vpar->bit_stream, i_r_size) : 0;
if( (p_vpar->mb.i_mv_format == MOTION_FIELD) && (p_vpar->picture.i_structure == FRAME_STRUCTURE) )
{
p_vpar->slice.pppi_pmv[i_r][i_s][1] >>= 1;
}
vpar_DecodeMotionVector( &p_vpar->slice.pppi_pmv[i_r][i_s][1], i_r_size,
i_motion_code, i_motion_residual, i_full_pel );
if( (p_vpar->mb.i_mv_format == MOTION_FIELD) && (p_vpar->picture.i_structure == FRAME_STRUCTURE) )
p_vpar->slice.pppi_pmv[i_r][i_s][1] <<= 1;
p_mb->pppi_motion_vectors[i_r][i_s][1] = p_vpar->slice.pppi_pmv[i_r][i_s][1];
if( p_vpar->mb.b_dmv )
{
if( GetBits(&p_vpar->bit_stream, 1) )
{
p_mb->pi_dm_vector[1] = GetBits( &p_vpar->bit_stream, 1 ) ? -1 : 1;
}
else
{
p_mb->pi_dm_vector[1] = 0;
}
}
}
/*****************************************************************************
* vpar_MPEG1MotionVector : Parse the next MPEG-1 motion vectors
*****************************************************************************/
void vpar_MPEG1MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_s )
{
vpar_MotionVector( p_vpar, p_mb, 0, i_s, p_vpar->picture.pb_full_pel_vector[i_s] );
}
/*****************************************************************************
* vpar_MPEG2MotionVector : Parse the next MPEG-2 motion_vectors field
*****************************************************************************/
void vpar_MPEG2MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_s )
{
if( p_vpar->mb.i_mv_count == 1 )
{
if( p_vpar->mb.i_mv_format == MOTION_FIELD && !p_vpar->mb.b_dmv )
{
p_mb->ppi_field_select[0][i_s] = p_mb->ppi_field_select[1][i_s]
= GetBits( &p_vpar->bit_stream, 1 );
}
vpar_MotionVector( p_vpar, p_mb, 0, i_s, 0 );
p_vpar->slice.pppi_pmv[1][i_s][0] = p_vpar->slice.pppi_pmv[0][i_s][0];
p_vpar->slice.pppi_pmv[1][i_s][1] = p_vpar->slice.pppi_pmv[0][i_s][1];
}
else
{
p_mb->ppi_field_select[0][i_s] = GetBits( &p_vpar->bit_stream, 1 );
vpar_MotionVector( p_vpar, p_mb, 0, i_s, 0 );
p_mb->ppi_field_select[1][i_s] = GetBits( &p_vpar->bit_stream, 1 );
vpar_MotionVector( p_vpar, p_mb, 1, i_s, 0 );
}
}
#if 0
/*****************************************************************************
* vpar_motion.c : motion vectors parsing
* (c)1999 VideoLAN
......@@ -108,13 +328,13 @@ static __inline__ void vpar_DecodeMotionVector( int * pi_prediction, int i_r_siz
{
i_vector += ((i_motion_code-1) << i_r_size) + i_motion_residual + 1;
if( i_vector >= i_limit )
i_vector -= i_limit << 1;
i_vector -= i_limit + i_limit;
}
else if( i_motion_code < 0 )
{
i_vector -= ((-i_motion_code-1) << i_r_size) + i_motion_residual + 1;
if( i_vector < i_limit )
i_vector += i_limit << 1;
if( i_vector < -i_limit )
i_vector += i_limit + i_limit;
}
*pi_prediction = i_vector << i_full_pel;
......@@ -153,8 +373,16 @@ void vpar_MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_r,
i_motion_code = vpar_MotionCode( p_vpar );
i_motion_residual = (i_r_size != 0 && i_motion_code != 0) ?
GetBits( &p_vpar->bit_stream, i_r_size) : 0;
if( (p_vpar->mb.i_mv_format == MOTION_FIELD) && (p_vpar->picture.b_frame_structure) )
p_vpar->slice.pppi_pmv[i_r][i_s][1] >>= 1;
vpar_DecodeMotionVector( &p_vpar->slice.pppi_pmv[i_r][i_s][1], i_r_size,
i_motion_code, i_motion_residual, i_full_pel );
if( (p_vpar->mb.i_mv_format == MOTION_FIELD) && (p_vpar->picture.b_frame_structure) )
p_vpar->slice.pppi_pmv[i_r][i_s][1] <<= 1;
p_mb->pppi_motion_vectors[i_r][i_s][1] = p_vpar->slice.pppi_pmv[i_r][i_s][1];
if( p_vpar->mb.b_dmv )
......@@ -191,6 +419,8 @@ void vpar_MPEG2MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_
= GetBits( &p_vpar->bit_stream, 1 );
}
vpar_MotionVector( p_vpar, p_mb, 0, i_s, 0 );
p_vpar->slice.pppi_pmv[1][i_s][0] = p_vpar->slice.pppi_pmv[0][i_s][0];
p_vpar->slice.pppi_pmv[1][i_s][1] = p_vpar->slice.pppi_pmv[0][i_s][1];
}
else
{
......@@ -200,3 +430,5 @@ void vpar_MPEG2MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_
vpar_MotionVector( p_vpar, p_mb, 1, i_s, 0 );
}
}
#endif
......@@ -145,8 +145,19 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
static int meuh = 0;
static int truc = 0;
// return( 1 );
return( i_coding_type == I_CODING_TYPE || i_coding_type == P_CODING_TYPE );
if( i_coding_type == 1 )
meuh = 0;
if( i_coding_type == 2 )
meuh++;
truc++;
if( truc == 3 )
{
// while(1);
}
return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE && meuh == 1) );
intf_DbgMsg("vpar debug: synchro image %i - modulo is %i\n", i_coding_type, p_vpar->synchro.modulo);
intf_DbgMsg("vpar debug: synchro predict P %e - predict B %e\n", p_vpar->synchro.p_count_predict, p_vpar->synchro.b_count_predict);
......@@ -171,7 +182,6 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
}
/*****************************************************************************
......
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