📄 fbm_synchro_vs.c
字号:
/*==========================================================================*/
/* (Copyright (C) 2003 Koninklijke Philips Electronics N.V. */
/* All rights reserved. */
/* This source code and any compilation or derivative thereof is the */
/* proprietary information of Koninklijke Philips Electronics N.V. */
/* and is confidential in nature. */
/* Under no circumstances is this software to be exposed to or placed */
/* under an Open Source License of any type without the expressed */
/* written permission of Koninklijke Philips Electronics N.V. */
/*==========================================================================*/
/*==========================================================================*/
/*
SOURCE_FILE: FBM_SYNCHRO_VS.C
PACKAGE: FBM
COMPONENT: MV
(C) 1998: Philips Semiconductors
*/
/*==========================================================================*/
/*==========================================================================*/
/* I N C L U D E S */
/*==========================================================================*/
#include "standard.h"
#include "tmosal.h"
# include "mv_drv.h"
# include "dv_dbg.h"
# include "dv_syn.h"
# include "ipvd_dbgl.h"
# include "fbm_sw.h"
# include "fbm_msg.h"
# include "fbm_api.h"
# include "mv_dec.h"
# include "mv_decl.h"
# include "mv_inpl.h"
#include "mv_itvl.h"
# include "disp_api.h"
# include "disp_io.h"
/*==========================================================================*/
/* G L O B A L D A T A D E C L A R A T I O N S */
/*==========================================================================*/
/*==========================================================================*/
/* L O C A L S Y M B O L D E F I N I T I O N S */
/*==========================================================================*/
#define MV_FBM_LINE_NB_IN_MB 16
#define MV_FBM_MAX_STC_VALUE 0xFFFFFFL
#define MV_FBM_DISCONTINUITY_MARGIN 3600L
/*==========================================================================*/
/* L O C A L D A T A D E C L A R A T I O N S */
/*==========================================================================*/
static MV_BIT LV_prev_P_or_I_rep_first_field = MV_BIT_OFF;
static unsigned long LV_last_picture_number_after_change_channel = 0;
static BOOLEAN LV_waiting_for_eopd_counter_to_be_reset = FALSE;
static BOOLEAN LV_cleanup_and_restart_on_I_requested = FALSE;
/*==========================================================================*/
/* L O C A L F U N C T I O N S P R O T O T Y P E S */
/*==========================================================================*/
static void LF_FBM_check_discontinuity(void);
static MV_DEC_DTS LF_FBM_dts_inc_calculation(void);
static void LF_FBM_set_pes_seq_gop_pict_hdr (UInt32 *io_wr_pos,UInt32 *io_bfm);
/*==========================================================================*/
/* G L O B A L F U N C T I O N S */
/*==========================================================================*/
//JI START 2005-06-20
static int cleanCount = 0;
static int timeoutCount = 0;
int GV_Delta_VIDEO_DTS_PTS = 0;
#define MAX_VBV_DELAY 27000 // 300ms*90
// suppose the abs is smaller than round/2[93.20675s]
static BOOLEAN round_abs(int round, int first, int second, int *result)
{
int temp;
temp = (first > second) ? (first - second) : (second - first);
if (temp > round/2)
{
*result = round - temp;
return TRUE;
}
else
{
*result = temp;
return FALSE;
}
}
static BOOLEAN get_delta(int iStc, int iStc_emendation, int *ipDelta)
{
*ipDelta = (iStc > iStc_emendation) ? (-(iStc - iStc_emendation)) : (iStc_emendation - iStc);
return TRUE;
}
static BOOLEAN acquire_delta(int stc, int dts, int vbv_delay, int *delta)
{
int stc_emendation, interval_abs;
BOOLEAN round;
if (vbv_delay != 0xFFFF)
/* vbv_delay is valid
* STC = DTS - VBV_DELAY
*/
{
/*
* assumably vbv_delay is non longer than 300ms
* just to decrease zapping time
*/
if (vbv_delay > MAX_VBV_DELAY)
vbv_delay = MAX_VBV_DELAY;
stc_emendation = (dts > vbv_delay) ? (dts - vbv_delay) : (dts + 0x1000000 - vbv_delay);
round = round_abs(0xFFFFFF, stc, stc_emendation, &interval_abs);
if (interval_abs > 5400)//60ms
{
if (round == FALSE)
{
get_delta(stc, stc_emendation, delta);
}
else
{
get_delta(stc, stc_emendation, delta);
}
return TRUE;
}
else
/* compliant TS stream
* do not emendation
*/
{
*delta = 1;
return FALSE;
}
}
/* vbv_delay is invalid
* STC = DTS - some_defined_value[MAX_VBV_DELAY==300ms]
*/
else
{
round = round_abs(0xFFFFFF, stc, dts, &interval_abs);
if ((interval_abs < 13500) || (interval_abs > 36000))
{
stc_emendation = (dts > MAX_VBV_DELAY) ? (dts - MAX_VBV_DELAY) : (dts + 0x1000000 - MAX_VBV_DELAY);
if (round == FALSE)
{
get_delta(stc, stc_emendation, delta);
}
else
{
get_delta(stc, stc_emendation, delta);
}
return TRUE;
}
else
/* buffer can abide it [150ms,400ms]
* do not emendation
*/
{
*delta = 1;
return FALSE;
}
}
}
//JI END 2005-06-20
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_FBM_synchro_VS
DESCRIPTION:
RETURNS:
CALLING SEQUENCE:
*/
int
MV_FBM_synchro_VS(
ULONG msg_buf[4],
FBM_STATUS* p
)
/*EMP=======================================================================*/
{
/****************-----------------------------------------------!*********
****************! Variable declarations !*********
****************!-----------------------------------------------*********/
static char lv_change_channel_time_out_cnt;
static FBM_PICTURE lv_next_displayed_picture_N1_backup;
static FBM_PICTURE lv_next_recov_picture_N1_backup;
BOOLEAN lv_decoding_launched = FALSE;
BOOLEAN lv_decode_picture;
BOOLEAN lv_discard_picture;
BOOLEAN lv_gop_found;
ULONG lv_decoded_line_nb;
BOOLEAN lv_next_picture_is_new_frame;
BOOLEAN lv_switch_to_disp_recov_mode_allowed;
BOOLEAN lv_second_field_P_picture_with_first_field_I_picture;
BOOLEAN lv_recov_mode_N1_dummy ;
UCHAR lv_field_top_still_to_display_cnt_dummy ;
UCHAR lv_field_bot_still_to_display_cnt_dummy ;
MV_FBM_FRAME_STORE lv_forbidden_frame_store;
BOOLEAN lv_run_play_dec_algo;
BOOLEAN lv_picture_found_for_freeze_at_display;
BOOLEAN lv_same_picture;
BOOLEAN lv_picture_in_sync_sw_event;
BOOLEAN lv_abort_time_out = FALSE;
UInt32 lv_protection_level;
#ifdef DV_DEBUG
unsigned long lv_info0;
unsigned long lv_info1;
unsigned long lv_info2;
unsigned long lv_info3;
#endif
UInt32 lv_modulo_hrz_size;
UInt32 lv_remainder_hrz_size;
/****************-----------------------------------------------!*********
****************! Execution !*********
****************!------------------------------------------------********/
/*--------------------------------------!
! Loop on received messages !
!--------------------------------------*/
switch(msg_buf[0])
{
case FBM_MSG_SOFT_RESET:
p->soft_reset_requested = TRUE;
break;
case FBM_MSG_CHANGE_CHANNEL:
p->change_channel_requested = TRUE;
lv_change_channel_time_out_cnt = MV_FBM_CHANGE_CHANNEL_TIME_OUT_VS;
DV_DBG_STORE_EVENT(IPVD_DBG_EV_CHANGE_CHANNEL_REQUESTED,IPVD_DBG_MAJOR_BEHAVIOR_LEVEL,0,0,0,0);
GV_MV_DEC_status.dec_dts_found = FALSE;
GV_MV_DEC_status.dec_pts_found = FALSE;
GV_Delta_VIDEO_DTS_PTS = 0;
break;
case FBM_MSG_ABORT_DECODING:
/*------------------------!
! Abort Decoding !
!------------------------*/
lv_switch_to_disp_recov_mode_allowed = TRUE;
MV_FBM_abort_decoding(lv_switch_to_disp_recov_mode_allowed,p);
DV_DBG_STORE_EVENT( IPVD_DBG_EV_FBM_ABORT_DECODING_BY_USER,IPVD_DBG_MAJOR_BEHAVIOR_LEVEL,
p->cur_picture.picture_coding_type,p->cur_picture.temporal_reference,0,0);
if (GV_MV_DEC_status.dec_event_enabled & MV_DEC_ABORT_DECODING_EVENT)
{
/* Notify the application. */
GV_MV_DEC_status.function_ptr(MV_DEC_ABORT_DECODING_EVENT);
}
break;
case FBM_MSG_EOPH:
/*----------------------------------------!
! Log End Of Picture Header event !
!----------------------------------------*/
// DV_DBG_STORE_EVENT(IPVD_DBG_EV_FBM_EOPH,IPVD_DBG_MAJOR_BEHAVIOR_LEVEL,0,0,0,0);
/*----------------------------------------!
! Picture in picture mode : !
!----------------------------------------*/
if (GV_MV_DEC_status.dec_pip_enabled == TRUE)
{
if (GV_MV_DEC_status.dec_shc_found == TRUE)
{
/*-----------------------------------------------------!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -