| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bxdm_pp_qm.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/22 $ |
|---|
| 12 | * $brcm_Date: 2/16/12 9:29a $ |
|---|
| 13 | * |
|---|
| 14 | * [File Description:] |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/xdm/bxdm_pp_qm.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/22 2/16/12 9:29a btosi |
|---|
| 21 | * SW7425-2255: bind the PTS offset to the picture when it is selected for |
|---|
| 22 | * display |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/21 1/12/12 12:57p btosi |
|---|
| 25 | * SW7425-1001: added support for BAVC_MFD_Picture.bLast |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/20 10/3/11 2:19p btosi |
|---|
| 28 | * SW7425-1264: support for a SW STC internal to XDM |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/19 7/20/11 10:44a btosi |
|---|
| 31 | * SW7635-51: use the SW PCR offset bound to the picture |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/18 7/20/11 9:38a btosi |
|---|
| 34 | * SW7635-51: snapshot the software PCR offset when a picture is selected |
|---|
| 35 | * for display |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/SW7635-51/1 5/11/11 9:43a btosi |
|---|
| 38 | * SW7635-51: snapshot the STC offset (uiSoftwarePCROffset) when a picture |
|---|
| 39 | * is selected for display |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/17 4/21/11 1:53p btosi |
|---|
| 42 | * SW7405-4736: moved BXDM_PPQM_P_PrintUnifiedPicture to bxdm_pp_dbg.c, |
|---|
| 43 | * tweaked the BXDM_PPQM message |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/16 1/6/11 2:21p delkert |
|---|
| 46 | * SW7405-4736: Change STC display in BXDM_PPQM and BXDM_PPDBG logs to |
|---|
| 47 | * show original STC from decoder with marker indicating JTI application |
|---|
| 48 | * Add output of Playback vs Live indication in BXDM_PPDBG logs. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/15 12/21/10 4:24p delkert |
|---|
| 51 | * SW7405-5043: Split STC stored in local state into two parts: STC from |
|---|
| 52 | * decoder and STC after JTI adjustment |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/14 12/16/10 9:12a btosi |
|---|
| 55 | * SW7422-72: fixed warnings |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/13 11/30/10 3:59p delkert |
|---|
| 58 | * SW7405-4736: Add picture type to QM message output |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/12 10/20/10 11:47a btosi |
|---|
| 61 | * SW7405-4804: deliver the SEI messages for pictures that are dropped |
|---|
| 62 | * |
|---|
| 63 | * Hydra_Software_Devel/11 10/5/10 7:34a btosi |
|---|
| 64 | * SW7405-4736: for the QM message, print characters for the TSM result |
|---|
| 65 | * |
|---|
| 66 | * Hydra_Software_Devel/10 9/24/10 11:34a btosi |
|---|
| 67 | * SW7405-4736: added a comment |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/9 9/24/10 8:38a btosi |
|---|
| 70 | * SW7405-4736: check for a null picture pointer in |
|---|
| 71 | * BXDM_PPQM_P_PrintUnifiedPicture |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/8 9/23/10 3:09p btosi |
|---|
| 74 | * SW7405-4736: add support for a XDM instance ID to help debug multi- |
|---|
| 75 | * channel issues |
|---|
| 76 | * |
|---|
| 77 | * Hydra_Software_Devel/7 8/12/10 9:38a btosi |
|---|
| 78 | * SW7405-4736: modified QM debug messages |
|---|
| 79 | * |
|---|
| 80 | * Hydra_Software_Devel/6 8/4/10 1:06p btosi |
|---|
| 81 | * SWBLURAY-21565: to aid debug, increment the picture's uiPPBIndex when |
|---|
| 82 | * the picture is validated |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/5 7/12/10 8:05a delkert |
|---|
| 85 | * SW7335-781: Output warning when forcing picture selection override to |
|---|
| 86 | * allow easier detection of conditions such as drop@decode and pcr |
|---|
| 87 | * discontinuity |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/4 6/29/10 11:25a btosi |
|---|
| 90 | * SW7405-4365: revamped the timer code to selectively enable the function |
|---|
| 91 | * and callback timing |
|---|
| 92 | * |
|---|
| 93 | * Hydra_Software_Devel/3 4/29/10 10:47a btosi |
|---|
| 94 | * SW7405-4117: added support for ...DisplayFieldMode_eAuto |
|---|
| 95 | * |
|---|
| 96 | * Hydra_Software_Devel/2 2/22/10 11:36a nilesh |
|---|
| 97 | * SW7405-2993: Added BXDM_Decoder_ReleasePictureInfo pointer to |
|---|
| 98 | * BXDM_Decoder_ReleasePicture call |
|---|
| 99 | * |
|---|
| 100 | * Hydra_Software_Devel/1 2/16/10 10:51a nilesh |
|---|
| 101 | * SW7405-2993: Initial XDM version |
|---|
| 102 | * |
|---|
| 103 | ***************************************************************************/ |
|---|
| 104 | |
|---|
| 105 | #include "bstd.h" |
|---|
| 106 | #include "bdbg.h" /* Dbglib */ |
|---|
| 107 | #include "bkni.h" |
|---|
| 108 | |
|---|
| 109 | #include "bxdm_pp.h" |
|---|
| 110 | #include "bxdm_pp_priv.h" |
|---|
| 111 | #include "bxdm_pp_qm.h" |
|---|
| 112 | #include "bxdm_pp_tsm.h" |
|---|
| 113 | #include "bxdm_pp_vtsm.h" |
|---|
| 114 | #include "bxdm_pp_callback_priv.h" |
|---|
| 115 | #include "bxdm_pp_output.h" |
|---|
| 116 | #include "bxdm_pp_clip.h" |
|---|
| 117 | |
|---|
| 118 | BDBG_MODULE(BXDM_PPQM); /* Register software module with debug interface */ |
|---|
| 119 | |
|---|
| 120 | const char BXDM_PictureProvider_P_DISPMGR_QM_NODE[]="DMQM:\t""$brcm_Revision: Hydra_Software_Devel/22 $"; |
|---|
| 121 | |
|---|
| 122 | static void BXDM_PPQM_S_ValidatePictureContext( |
|---|
| 123 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 124 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 125 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt, |
|---|
| 126 | BXDM_PictureProvider_P_Picture_Context * pstPrevPicCntxt, |
|---|
| 127 | BXDM_PictureProvider_P_Picture_Context * pstSelectedPicCntxt |
|---|
| 128 | ); |
|---|
| 129 | |
|---|
| 130 | void BXDM_PPQM_P_InvalidatePictureContext( |
|---|
| 131 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt |
|---|
| 132 | ) |
|---|
| 133 | { |
|---|
| 134 | BDBG_ENTER( BXDM_PPQM_P_InvalidatePictureContext ); |
|---|
| 135 | |
|---|
| 136 | BKNI_Memset( pstPicCntxt, 0, sizeof ( BXDM_PictureProvider_P_Picture_Context ) ); |
|---|
| 137 | |
|---|
| 138 | BDBG_LEAVE( BXDM_PPQM_P_InvalidatePictureContext ); |
|---|
| 139 | |
|---|
| 140 | return; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | static void BXDM_PPQM_S_Detect32FilmContent( |
|---|
| 144 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 145 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 146 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt |
|---|
| 147 | ) |
|---|
| 148 | { |
|---|
| 149 | uint32_t i, uiIndex; |
|---|
| 150 | BXDM_Picture_PullDown eExpected32Pulldown = 0; |
|---|
| 151 | bool bDone = false; |
|---|
| 152 | |
|---|
| 153 | BSTD_UNUSED(pLocalState); |
|---|
| 154 | |
|---|
| 155 | hXdmPP->stDMState.stDecode.ePPBPulldownHistory[hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryIndex] = pstPicCntxt->pstUnifiedPicture->stBufferInfo.ePulldown; |
|---|
| 156 | |
|---|
| 157 | if ( hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryIndex == ( BXDM_PictureProvider_P_MAX_PPB_PULLDOWN_HISTORY - 1 ) ) |
|---|
| 158 | { |
|---|
| 159 | hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryIndex = 0; |
|---|
| 160 | } |
|---|
| 161 | else |
|---|
| 162 | { |
|---|
| 163 | hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryIndex++; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | if ( hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryCount < BXDM_PictureProvider_P_MAX_PPB_PULLDOWN_HISTORY ) |
|---|
| 167 | { |
|---|
| 168 | hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryCount++; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | /* Check for 3:2 cadence */ |
|---|
| 172 | if ( hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryCount < BXDM_PictureProvider_P_MAX_PPB_PULLDOWN_HISTORY ) |
|---|
| 173 | { |
|---|
| 174 | uiIndex = 0; |
|---|
| 175 | } |
|---|
| 176 | else |
|---|
| 177 | { |
|---|
| 178 | uiIndex = hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryIndex; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | for (i = 0; (i < hXdmPP->stDMState.stDecode.uiPPBPulldownHistoryCount) && (false == bDone); i++ ) |
|---|
| 182 | { |
|---|
| 183 | /* We need to seed the initial values */ |
|---|
| 184 | if ( ( i != 0 ) |
|---|
| 185 | && ( hXdmPP->stDMState.stDecode.ePPBPulldownHistory[uiIndex] != eExpected32Pulldown ) ) |
|---|
| 186 | { |
|---|
| 187 | pstPicCntxt->stPicParms.stDisplay.stStatic.b32FilmSource = false; |
|---|
| 188 | bDone = true; |
|---|
| 189 | } |
|---|
| 190 | else |
|---|
| 191 | { |
|---|
| 192 | switch ( hXdmPP->stDMState.stDecode.ePPBPulldownHistory[uiIndex] ) |
|---|
| 193 | { |
|---|
| 194 | case BXDM_Picture_PullDown_eTopBottom: |
|---|
| 195 | eExpected32Pulldown = BXDM_Picture_PullDown_eTopBottomTop; |
|---|
| 196 | break; |
|---|
| 197 | |
|---|
| 198 | case BXDM_Picture_PullDown_eBottomTop: |
|---|
| 199 | eExpected32Pulldown = BXDM_Picture_PullDown_eBottomTopBottom; |
|---|
| 200 | break; |
|---|
| 201 | |
|---|
| 202 | case BXDM_Picture_PullDown_eTopBottomTop: |
|---|
| 203 | eExpected32Pulldown = BXDM_Picture_PullDown_eBottomTop; |
|---|
| 204 | pstPicCntxt->stPicParms.stDisplay.stStatic.b32FilmSource = true; |
|---|
| 205 | break; |
|---|
| 206 | |
|---|
| 207 | case BXDM_Picture_PullDown_eBottomTopBottom: |
|---|
| 208 | eExpected32Pulldown = BXDM_Picture_PullDown_eTopBottom; |
|---|
| 209 | pstPicCntxt->stPicParms.stDisplay.stStatic.b32FilmSource = true; |
|---|
| 210 | break; |
|---|
| 211 | |
|---|
| 212 | default: |
|---|
| 213 | bDone = true; |
|---|
| 214 | break; |
|---|
| 215 | } |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | if ( uiIndex == ( BXDM_PictureProvider_P_MAX_PPB_PULLDOWN_HISTORY - 1 ) ) |
|---|
| 219 | { |
|---|
| 220 | uiIndex = 0; |
|---|
| 221 | } |
|---|
| 222 | else |
|---|
| 223 | { |
|---|
| 224 | uiIndex++; |
|---|
| 225 | } |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | static void BXDM_PPQM_S_ValidatePictureContext( |
|---|
| 230 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 231 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 232 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt, |
|---|
| 233 | BXDM_PictureProvider_P_Picture_Context * pstPrevPicCntxt, |
|---|
| 234 | BXDM_PictureProvider_P_Picture_Context * pstSelectedPicCntxt |
|---|
| 235 | ) |
|---|
| 236 | { |
|---|
| 237 | BDBG_ENTER( BXDM_PPQM_S_ValidatePictureContext ); |
|---|
| 238 | /* |
|---|
| 239 | ** If this context has already been validated, there is nothing to do. |
|---|
| 240 | ** This logic is a precursor to having an array of picture contexts. |
|---|
| 241 | */ |
|---|
| 242 | if ( true == pstPicCntxt->bValidated ) |
|---|
| 243 | { |
|---|
| 244 | goto AllDone; |
|---|
| 245 | } |
|---|
| 246 | else |
|---|
| 247 | { |
|---|
| 248 | pstPicCntxt->bValidated = true; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eValidatePictureHead ); |
|---|
| 252 | |
|---|
| 253 | hXdmPP->stDMState.stDecode.uiPPBIndex++; |
|---|
| 254 | pstPicCntxt->stPicParms.uiPPBIndex = hXdmPP->stDMState.stDecode.uiPPBIndex; |
|---|
| 255 | |
|---|
| 256 | /* PR50196: Detect 3:2 film content and override source format as |
|---|
| 257 | * needed */ |
|---|
| 258 | BXDM_PPQM_S_Detect32FilmContent( hXdmPP, pLocalState, pstPicCntxt ); |
|---|
| 259 | |
|---|
| 260 | /* Set TSM parameters */ |
|---|
| 261 | BXDM_PPTSM_P_PtsCalculateParameters( hXdmPP, pLocalState, pstPicCntxt ); |
|---|
| 262 | |
|---|
| 263 | /* By default, set the selection mode for this picture equal to the |
|---|
| 264 | * display mode */ |
|---|
| 265 | pstPicCntxt->stPicParms.stTSM.stDynamic.eSelectionMode = pLocalState->eSelectionMode; |
|---|
| 266 | |
|---|
| 267 | /* |
|---|
| 268 | * If in playback mode, force PCR offset and all the associated |
|---|
| 269 | * flags to '0'. |
|---|
| 270 | * |
|---|
| 271 | * If "live" playback, set the offset and flags based on the |
|---|
| 272 | * data in the PPB and the system state. |
|---|
| 273 | */ |
|---|
| 274 | |
|---|
| 275 | /* Zero out local PCR copy */ |
|---|
| 276 | BKNI_Memset( |
|---|
| 277 | &pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM, |
|---|
| 278 | 0, |
|---|
| 279 | sizeof( BXDM_PictureProvider_P_PCROffset ) |
|---|
| 280 | ); |
|---|
| 281 | |
|---|
| 282 | /* Set local PCR copy to be same as coded copy */ |
|---|
| 283 | if ( false == hXdmPP->stDMConfig.bPlayback ) |
|---|
| 284 | { |
|---|
| 285 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy = pstPicCntxt->pstUnifiedPicture->stPCROffset; |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | /* Handle coded PTS related logic */ |
|---|
| 289 | if ( true == pstPicCntxt->pstUnifiedPicture->stPTS.bValid ) |
|---|
| 290 | { |
|---|
| 291 | /* used to generated the first coded PTS callback */ |
|---|
| 292 | pLocalState->bCodedPtsReceived = true; |
|---|
| 293 | |
|---|
| 294 | /* Snapshot the first coded PTS received, this value will be delivered to |
|---|
| 295 | * the application via the "BXVD_Interrupt_eFirstPTSReady" callback. |
|---|
| 296 | * Previously the value returned by this callback was "stLatestCodedPts". |
|---|
| 297 | * Testing preroll mode highlighted the need for the snapshot; preroll starts in vsync mode, |
|---|
| 298 | * the first picture received will be promoted for display. When the queue was empty, the PTS |
|---|
| 299 | * value returned by "BXVD_Interrupt_eFirstPTSReady" was from the first picture. When the queue |
|---|
| 300 | * was not empty, the PTS returned was from the second picture. |
|---|
| 301 | */ |
|---|
| 302 | if ( false == hXdmPP->stDMState.stDecode.bFirstCodedPtsReceived ) |
|---|
| 303 | { |
|---|
| 304 | hXdmPP->stDMState.stDecode.stFirstCodedPts.ui32RunningPTS = pstPicCntxt->pstUnifiedPicture->stPTS.uiValue; |
|---|
| 305 | hXdmPP->stDMState.stDecode.stFirstCodedPts.ePTSType = BXDM_PictureProvider_PTSType_eCoded; |
|---|
| 306 | hXdmPP->stDMState.stDecode.bFirstCodedPtsReceived = true; |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | /* save the PTS */ |
|---|
| 310 | hXdmPP->stDMState.stDecode.stLatestCodedPts.ui32RunningPTS = pstPicCntxt->pstUnifiedPicture->stPTS.uiValue; |
|---|
| 311 | hXdmPP->stDMState.stDecode.stLatestCodedPts.ePTSType = BXDM_PictureProvider_PTSType_eCoded; |
|---|
| 312 | |
|---|
| 313 | /* PR52901: save the PCR info. An application can use this when it receives |
|---|
| 314 | * the BXVD_Interrupt_eFirstPTSReady callback. Or when calling BXVD_GetPTS |
|---|
| 315 | * before a picture has been promoted for display. |
|---|
| 316 | */ |
|---|
| 317 | hXdmPP->stDMState.stDecode.stLatestCodedPts.uiPCROffset = pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue; |
|---|
| 318 | hXdmPP->stDMState.stDecode.stLatestCodedPts.bPcrOffsetValid = pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid; |
|---|
| 319 | hXdmPP->stDMState.stDecode.stLatestCodedPts.bPcrDiscontinuity = pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bDiscontinuity; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | /* Override local PCR copy if it is not valid. Use the previous PCR copy (if valid). */ |
|---|
| 323 | if ( ( false == hXdmPP->stDMConfig.bPlayback ) |
|---|
| 324 | && ( false == pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid ) ) |
|---|
| 325 | { |
|---|
| 326 | /* The PCR is invalid, so we set the PCR for this PPB to be the |
|---|
| 327 | * same as the previous PPB if it is valid, otherwise, we set it |
|---|
| 328 | * to zero */ |
|---|
| 329 | if ( true == pstPrevPicCntxt->bValidated ) |
|---|
| 330 | { |
|---|
| 331 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue = pstPrevPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue; |
|---|
| 332 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid = pstPrevPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid; |
|---|
| 333 | } |
|---|
| 334 | else |
|---|
| 335 | { |
|---|
| 336 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue = 0; |
|---|
| 337 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid = false; |
|---|
| 338 | } |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | if ( true == hXdmPP->stDMConfig.bPlayback ) |
|---|
| 342 | { |
|---|
| 343 | hXdmPP->stDMState.stDecode.bValidPcrOffsetReceived = true; |
|---|
| 344 | } |
|---|
| 345 | else |
|---|
| 346 | { |
|---|
| 347 | hXdmPP->stDMState.stDecode.bValidPcrOffsetReceived = pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid; |
|---|
| 348 | |
|---|
| 349 | /* PR50623: If the application has specified to NOT use |
|---|
| 350 | * the HW PCR offset set the overloaded flags accordingly. |
|---|
| 351 | * Otherwise load them with the derived values. |
|---|
| 352 | */ |
|---|
| 353 | if ( false == hXdmPP->stDMConfig.bUseHardwarePCROffset ) |
|---|
| 354 | { |
|---|
| 355 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.bValidOverloaded = true; |
|---|
| 356 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.bDiscontinuityOverloaded = false; |
|---|
| 357 | } |
|---|
| 358 | else |
|---|
| 359 | { |
|---|
| 360 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.bValidOverloaded = |
|---|
| 361 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bValid; |
|---|
| 362 | |
|---|
| 363 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.bDiscontinuityOverloaded = |
|---|
| 364 | pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.bDiscontinuity; |
|---|
| 365 | } |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | /* If an error, bump the error count. */ |
|---|
| 369 | if( true == pstPicCntxt->pstUnifiedPicture->stError.bThisPicture ) |
|---|
| 370 | { |
|---|
| 371 | hXdmPP->stDMStatus.stCounters.uiDecodeErrorCount++; |
|---|
| 372 | pLocalState->bDecodeError = true; |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | /* Check for dummy PPB */ |
|---|
| 376 | if ( true == pstPicCntxt->pstUnifiedPicture->stBufferInfo.bValid ) |
|---|
| 377 | { |
|---|
| 378 | hXdmPP->stDMState.stDecode.bFirstPPBSeen = true; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | /* |
|---|
| 382 | * Count the number of I-Frames. Informational only, for use by an application. |
|---|
| 383 | */ |
|---|
| 384 | if ( BXDM_Picture_Coding_eI == pstPicCntxt->pstUnifiedPicture->stPictureType.eCoding ) |
|---|
| 385 | { |
|---|
| 386 | hXdmPP->stDMStatus.stCounters.uiIFrameCount++; |
|---|
| 387 | |
|---|
| 388 | if ( true == pstPicCntxt->pstUnifiedPicture->stError.bThisPicture ) |
|---|
| 389 | { |
|---|
| 390 | hXdmPP->stDMStatus.stCounters.uiErrorIFrameCount++; |
|---|
| 391 | } |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | /* SW7425-1001: check for "bLastPicture" being set, effectively an EOS flag. |
|---|
| 395 | * Currently defined to only be delivered with a "picture-less" picture. |
|---|
| 396 | * |
|---|
| 397 | * If the flag is set for a "picture-less" picture, the picture currently |
|---|
| 398 | * selected for display is the last one of this video. When the selected picture |
|---|
| 399 | * has been displayed completely, "bLast" should be set in the MFD picture structure. |
|---|
| 400 | * This is done in BXDM_PPOUT_P_CalculateVdcData. |
|---|
| 401 | * |
|---|
| 402 | * It is an error condition if "bLastPicture" is set for a "standard" picture. The flag |
|---|
| 403 | * will be ignored in this instance. |
|---|
| 404 | */ |
|---|
| 405 | if ( true == pstPicCntxt->pstUnifiedPicture->stPictureType.bLastPicture ) |
|---|
| 406 | { |
|---|
| 407 | /* "stBufferInfo.bValid" being "false" means that this is a "picture-less" picture. |
|---|
| 408 | * Mark the currently selected picture as the last one. |
|---|
| 409 | */ |
|---|
| 410 | if ( false == pstPicCntxt->pstUnifiedPicture->stBufferInfo.bValid ) |
|---|
| 411 | { |
|---|
| 412 | pstSelectedPicCntxt->stPicParms.stDisplay.stDynamic.bLastPictureSeen = true; |
|---|
| 413 | } |
|---|
| 414 | else |
|---|
| 415 | { |
|---|
| 416 | BDBG_ERR(("BXDM_PPQM_S_ValidatePictureContext:: bLastPicture is set for a standard picture.")); |
|---|
| 417 | } |
|---|
| 418 | } |
|---|
| 419 | |
|---|
| 420 | |
|---|
| 421 | /* |
|---|
| 422 | * Bump the running count of pictures seen by the video decoder. |
|---|
| 423 | */ |
|---|
| 424 | hXdmPP->stDMStatus.stCounters.uiPicturesReceivedCount += pstPicCntxt->pstUnifiedPicture->stStats.uiDeltaPicturesSeen; |
|---|
| 425 | |
|---|
| 426 | BXDM_PPOUT_P_CalculateStaticVdcData( hXdmPP, pstPicCntxt ); |
|---|
| 427 | |
|---|
| 428 | /* Conditionally execute the PPB parameters callback. */ |
|---|
| 429 | pLocalState->bPictureUnderEvaluation = true; |
|---|
| 430 | BXDM_PPCB_P_ExecuteSingleCallback( hXdmPP, pLocalState, BXDM_PictureProvider_Callback_ePictureUnderEvaluation ); |
|---|
| 431 | |
|---|
| 432 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eValidatePictureHead ); |
|---|
| 433 | |
|---|
| 434 | AllDone: |
|---|
| 435 | |
|---|
| 436 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eValidatePictureTail ); |
|---|
| 437 | |
|---|
| 438 | /* PR52898: Remember the current eDisplayFieldMode setting for this |
|---|
| 439 | * picture to prevent a change to the display field mode affecting |
|---|
| 440 | * the picture after it's been displayed on the screen |
|---|
| 441 | * |
|---|
| 442 | * SW7405-4117: when BXDM_PictureProvider_DisplayFieldMode_eAuto is specified, the stream |
|---|
| 443 | * height is used in conjunction with uiMaxHeightSupportedByDeinterlacer |
|---|
| 444 | * to choose either eSingleField or eBothField slow motion (and preroll). |
|---|
| 445 | */ |
|---|
| 446 | if ( BXDM_PictureProvider_DisplayFieldMode_eAuto == hXdmPP->stDMConfig.eDisplayFieldMode ) |
|---|
| 447 | { |
|---|
| 448 | bool bPausedOrSlowMotion; |
|---|
| 449 | |
|---|
| 450 | /* Check for a STC trick mode of pause or slow motion. |
|---|
| 451 | */ |
|---|
| 452 | bPausedOrSlowMotion = ( BXDM_PictureProvider_P_STCTrickMode_ePause == pLocalState->eSTCTrickMode ); |
|---|
| 453 | bPausedOrSlowMotion |= ( BXDM_PictureProvider_P_STCTrickMode_eSlowMotion == pLocalState->eSTCTrickMode ); |
|---|
| 454 | bPausedOrSlowMotion |= ( BXDM_PictureProvider_P_STCTrickMode_eSlowRewind == pLocalState->eSTCTrickMode ); |
|---|
| 455 | |
|---|
| 456 | /* Check for a decoder trick mode of pause or slow motion. This check encompasses preroll. |
|---|
| 457 | */ |
|---|
| 458 | bPausedOrSlowMotion |= ( pLocalState->uiSlowMotionRate < BXDM_PICTUREPROVIDER_NORMAL_PLAYBACK_RATE ); |
|---|
| 459 | |
|---|
| 460 | /* Default to eBothField */ |
|---|
| 461 | pstPicCntxt->stPicParms.stDisplay.stDynamic.eDisplayFieldMode = BXDM_PictureProvider_DisplayFieldMode_eBothField; |
|---|
| 462 | |
|---|
| 463 | /* When paused or in slow motion, revert to eSingleField if the deinterlacer cannot support the stream. */ |
|---|
| 464 | if ( pstPicCntxt->pstUnifiedPicture->stBufferInfo.stSource.uiHeight > hXdmPP->stDMConfig.uiMaxHeightSupportedByDeinterlacer |
|---|
| 465 | && true == bPausedOrSlowMotion |
|---|
| 466 | ) |
|---|
| 467 | { |
|---|
| 468 | pstPicCntxt->stPicParms.stDisplay.stDynamic.eDisplayFieldMode = BXDM_PictureProvider_DisplayFieldMode_eSingleField; |
|---|
| 469 | } |
|---|
| 470 | } |
|---|
| 471 | else |
|---|
| 472 | { |
|---|
| 473 | pstPicCntxt->stPicParms.stDisplay.stDynamic.eDisplayFieldMode = hXdmPP->stDMConfig.eDisplayFieldMode; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | BXDM_PPCLIP_P_ClipTimeQueueTransitionHandler( |
|---|
| 477 | hXdmPP, |
|---|
| 478 | pLocalState, |
|---|
| 479 | pstPicCntxt |
|---|
| 480 | ); |
|---|
| 481 | |
|---|
| 482 | /* We enter auto-vsync mode when ALL of the following are true: |
|---|
| 483 | * |
|---|
| 484 | * 1) We're in live mode (PCR is invalid during playback) |
|---|
| 485 | * 2) The STC is NOT invalid (STC has been valid at least once |
|---|
| 486 | * during the decode) |
|---|
| 487 | * 3) The "bVsyncModeOnPcrDiscontinuity" is set. |
|---|
| 488 | * 4) The currently selected picture indicates a PCR discontinuity. |
|---|
| 489 | * (This is the trigger for auto-vsync mode) |
|---|
| 490 | * (Note: if the HW PCR offset is being ignored, discontinuity will |
|---|
| 491 | * be ignored as well. Hence the use of "bDiscontinuityOverloaded") |
|---|
| 492 | */ |
|---|
| 493 | if ( false == hXdmPP->stDMConfig.bPlayback |
|---|
| 494 | && true == hXdmPP->stDMConfig.bSTCValid |
|---|
| 495 | && true == hXdmPP->stDMConfig.bVirtualTSMOnPCRDiscontinuity |
|---|
| 496 | && true == pstPicCntxt->stPicParms.stTSM.stStatic.stPCROffsetXDM.bDiscontinuityOverloaded |
|---|
| 497 | ) |
|---|
| 498 | { |
|---|
| 499 | /* SW7335-781: Output warning when forcing picture selection override */ |
|---|
| 500 | BXDM_PPDBG_P_PrintSelectionModeOverride("PCR Discontinuity", hXdmPP, pstPicCntxt); |
|---|
| 501 | pstPicCntxt->stPicParms.stTSM.stDynamic.eSelectionMode = BXDM_PictureProvider_DisplayMode_eVirtualTSM; |
|---|
| 502 | |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | if ( BXDM_PictureProvider_DisplayMode_eVirtualTSM != pstPicCntxt->stPicParms.stTSM.stDynamic.eSelectionMode ) |
|---|
| 506 | { |
|---|
| 507 | /* Handle auto-vsync mode for this picture */ |
|---|
| 508 | pstPicCntxt->stPicParms.stTSM.stDynamic.eSelectionMode = pLocalState->eSelectionMode; |
|---|
| 509 | |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | /* Now that all the necessary parameters have been dereferenced, |
|---|
| 513 | * calculate the appropriate PTS values. |
|---|
| 514 | */ |
|---|
| 515 | BXDM_PPTSM_P_PtsInterpolate( hXdmPP, pLocalState, pstPicCntxt, pstPrevPicCntxt ); |
|---|
| 516 | BXDM_PPVTSM_P_VirtualPtsInterpolate( hXdmPP, pLocalState, pstPicCntxt, pstPrevPicCntxt, pstSelectedPicCntxt ); |
|---|
| 517 | |
|---|
| 518 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eValidatePictureTail ); |
|---|
| 519 | |
|---|
| 520 | BDBG_LEAVE( BXDM_PPQM_S_ValidatePictureContext ); |
|---|
| 521 | |
|---|
| 522 | return; |
|---|
| 523 | |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | /******************************************************************************* |
|---|
| 527 | ** |
|---|
| 528 | ** end "private" display queue management routines. |
|---|
| 529 | ** |
|---|
| 530 | *******************************************************************************/ |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | /******************************************************************************* |
|---|
| 534 | ** |
|---|
| 535 | ** Routines for manipulating picture context. |
|---|
| 536 | ** |
|---|
| 537 | *******************************************************************************/ |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | void BXDM_PPQM_P_GetHwPcrOffset( |
|---|
| 541 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 542 | uint32_t * puiPcrOffset |
|---|
| 543 | ) |
|---|
| 544 | { |
|---|
| 545 | *puiPcrOffset = pstPicture->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue; |
|---|
| 546 | return; |
|---|
| 547 | } |
|---|
| 548 | |
|---|
| 549 | /* PR50623: return the "cooked" PCR offset, i.e. the sum |
|---|
| 550 | * of the HW and SW PCR offsets. |
|---|
| 551 | */ |
|---|
| 552 | void BXDM_PPQM_P_GetCookedPcrOffset( |
|---|
| 553 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 554 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 555 | uint32_t * puiPcrOffset |
|---|
| 556 | ) |
|---|
| 557 | { |
|---|
| 558 | /* The "returned" PCR offset always includes the software value. |
|---|
| 559 | * ( This is '0' by default. It is optionally set by the |
|---|
| 560 | * application or PCRLib.) |
|---|
| 561 | * |
|---|
| 562 | * SW7635-51: when a picture is selected for display, uiSoftwarePCROffset is bound |
|---|
| 563 | * to the picture and "bSwPcrOffsetValid" is set true. Prior to selecting a picture, |
|---|
| 564 | * "uiSoftwarePCROffset" will be false. |
|---|
| 565 | */ |
|---|
| 566 | if ( true == pstPicture->stPicParms.stDisplay.stDynamic.bSwPcrOffsetValid ) |
|---|
| 567 | { |
|---|
| 568 | *puiPcrOffset = pstPicture->stPicParms.stDisplay.stDynamic.uiSoftwarePCROffset; |
|---|
| 569 | } |
|---|
| 570 | else |
|---|
| 571 | { |
|---|
| 572 | *puiPcrOffset = hXdmPP->stDMConfig.uiSoftwarePCROffset; |
|---|
| 573 | } |
|---|
| 574 | |
|---|
| 575 | /* Conditionally add the hardware PCR offset. The default behavior |
|---|
| 576 | * at channel open is to set "bUseHwPcrOffset" to true. |
|---|
| 577 | */ |
|---|
| 578 | if ( true == hXdmPP->stDMConfig.bUseHardwarePCROffset ) |
|---|
| 579 | { |
|---|
| 580 | *puiPcrOffset += pstPicture->stPicParms.stTSM.stStatic.stPCROffsetXDM.stPCROffsetCopy.uiValue; |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | return; |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | /* SW7425-2255: return the appropriate display offset. |
|---|
| 587 | */ |
|---|
| 588 | void BXDM_PPQM_P_GetPtsOffset( |
|---|
| 589 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 590 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 591 | uint32_t * puiPtsOffset |
|---|
| 592 | ) |
|---|
| 593 | { |
|---|
| 594 | /* SW7425-2255: when a picture is selected for display, uiPTSOffset is bound |
|---|
| 595 | * to the picture and "bPtsOffsetValid" is set true. Prior to selecting a picture, |
|---|
| 596 | * "bPtsOffsetValid" will be false. |
|---|
| 597 | */ |
|---|
| 598 | if ( true == pstPicture->stPicParms.stDisplay.stDynamic.bPtsOffsetValid ) |
|---|
| 599 | { |
|---|
| 600 | *puiPtsOffset = pstPicture->stPicParms.stDisplay.stDynamic.uiPtsOffset; |
|---|
| 601 | } |
|---|
| 602 | else |
|---|
| 603 | { |
|---|
| 604 | *puiPtsOffset = hXdmPP->stDMConfig.uiPTSOffset; |
|---|
| 605 | } |
|---|
| 606 | |
|---|
| 607 | return; |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | |
|---|
| 611 | /* |
|---|
| 612 | ** Public functions. |
|---|
| 613 | */ |
|---|
| 614 | void BXDM_PPQM_P_GetPredictedPts( |
|---|
| 615 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 616 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 617 | uint32_t * puiPts |
|---|
| 618 | ) |
|---|
| 619 | { |
|---|
| 620 | BDBG_ASSERT(puiPts); |
|---|
| 621 | |
|---|
| 622 | if ( false == pstPicture->bValidated ) |
|---|
| 623 | { |
|---|
| 624 | *puiPts = 0; |
|---|
| 625 | } |
|---|
| 626 | else |
|---|
| 627 | { |
|---|
| 628 | *puiPts = pstPicture->stPicParms.stTSM.stStatic.stPTSOfNextPPB[ePTSIndex].uiWhole; |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | return; |
|---|
| 632 | |
|---|
| 633 | } |
|---|
| 634 | |
|---|
| 635 | void BXDM_PPQM_P_GetPredictedPtsWithFrac( |
|---|
| 636 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 637 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 638 | BXDM_PPFP_P_DataType *pstPTS |
|---|
| 639 | ) |
|---|
| 640 | { |
|---|
| 641 | BDBG_ASSERT(pstPTS); |
|---|
| 642 | |
|---|
| 643 | if ( false == pstPicture->bValidated ) |
|---|
| 644 | { |
|---|
| 645 | pstPTS->uiWhole = 0; |
|---|
| 646 | pstPTS->uiFractional = 0; |
|---|
| 647 | } |
|---|
| 648 | else |
|---|
| 649 | { |
|---|
| 650 | *pstPTS = pstPicture->stPicParms.stTSM.stStatic.stPTSOfNextPPB[ePTSIndex]; |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | return; |
|---|
| 654 | |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | void BXDM_PPQM_P_SetPredictedPtsWithFrac( |
|---|
| 658 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 659 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 660 | BXDM_PPFP_P_DataType stPTS |
|---|
| 661 | ) |
|---|
| 662 | { |
|---|
| 663 | |
|---|
| 664 | pstPicture->stPicParms.stTSM.stStatic.stPTSOfNextPPB[ePTSIndex] = stPTS; |
|---|
| 665 | |
|---|
| 666 | return; |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | void BXDM_PPQM_P_GetPtsType( |
|---|
| 670 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 671 | BXDM_PictureProvider_PTSType * pePtsType |
|---|
| 672 | ) |
|---|
| 673 | { |
|---|
| 674 | |
|---|
| 675 | if ( false == pstPicture->bValidated ) |
|---|
| 676 | { |
|---|
| 677 | *pePtsType = BXDM_PictureProvider_PTSType_eInterpolatedFromInvalidPTS; |
|---|
| 678 | } |
|---|
| 679 | else |
|---|
| 680 | { |
|---|
| 681 | *pePtsType = pstPicture->stPicParms.stTSM.stStatic.ePtsType; |
|---|
| 682 | } |
|---|
| 683 | |
|---|
| 684 | return; |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | void BXDM_PPQM_P_GetPtsTypeUnfiltered( |
|---|
| 688 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 689 | BXDM_PictureProvider_PTSType * pePtsType |
|---|
| 690 | ) |
|---|
| 691 | { |
|---|
| 692 | *pePtsType = pstPicture->stPicParms.stTSM.stStatic.ePtsType; |
|---|
| 693 | |
|---|
| 694 | return; |
|---|
| 695 | } |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | void BXDM_PPQM_P_SetPtsWithFrac( |
|---|
| 699 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 700 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 701 | uint32_t uiIndex, |
|---|
| 702 | BXDM_PPFP_P_DataType stPTS |
|---|
| 703 | ) |
|---|
| 704 | { |
|---|
| 705 | BDBG_ASSERT( uiIndex < BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ); |
|---|
| 706 | |
|---|
| 707 | /* A runtime check to keep Coverity happy. */ |
|---|
| 708 | if ( uiIndex >= BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ) |
|---|
| 709 | { |
|---|
| 710 | uiIndex = BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB - 1; |
|---|
| 711 | } |
|---|
| 712 | |
|---|
| 713 | pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiIndex ].stPTS[ePTSIndex] = stPTS; |
|---|
| 714 | |
|---|
| 715 | return; |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | void BXDM_PPQM_P_GetPtsWithFrac( |
|---|
| 719 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 720 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 721 | uint32_t uiIndex, |
|---|
| 722 | BXDM_PPFP_P_DataType *pstPTS |
|---|
| 723 | ) |
|---|
| 724 | { |
|---|
| 725 | BDBG_ASSERT( uiIndex < BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ); |
|---|
| 726 | |
|---|
| 727 | /* A runtime check to keep Coverity happy. */ |
|---|
| 728 | if ( uiIndex >= BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ) |
|---|
| 729 | { |
|---|
| 730 | uiIndex = BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB - 1; |
|---|
| 731 | } |
|---|
| 732 | |
|---|
| 733 | if ( false == pstPicture->bValidated ) |
|---|
| 734 | { |
|---|
| 735 | pstPTS->uiWhole = 0; |
|---|
| 736 | pstPTS->uiFractional = 0; |
|---|
| 737 | } |
|---|
| 738 | else |
|---|
| 739 | { |
|---|
| 740 | *pstPTS = pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiIndex ].stPTS[ePTSIndex]; |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | return; |
|---|
| 744 | } |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | void BXDM_PPQM_P_GetPts( |
|---|
| 748 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 749 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 750 | uint32_t uiIndex, |
|---|
| 751 | uint32_t * puiPts |
|---|
| 752 | ) |
|---|
| 753 | { |
|---|
| 754 | BDBG_ASSERT( uiIndex < BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ); |
|---|
| 755 | |
|---|
| 756 | /* A runtime check to keep Coverity happy. */ |
|---|
| 757 | if ( uiIndex >= BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ) |
|---|
| 758 | { |
|---|
| 759 | uiIndex = BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB - 1; |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | if ( false == pstPicture->bValidated ) |
|---|
| 764 | { |
|---|
| 765 | *puiPts = 0; |
|---|
| 766 | } |
|---|
| 767 | else |
|---|
| 768 | { |
|---|
| 769 | *puiPts = pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiIndex ].stPTS[ePTSIndex].uiWhole; |
|---|
| 770 | } |
|---|
| 771 | |
|---|
| 772 | return; |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | void BXDM_PPQM_P_GetPtsUnfiltered( |
|---|
| 776 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 777 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 778 | uint32_t uiIndex, |
|---|
| 779 | uint32_t * puiPts |
|---|
| 780 | ) |
|---|
| 781 | { |
|---|
| 782 | BDBG_ASSERT( uiIndex < BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ); |
|---|
| 783 | |
|---|
| 784 | /* A runtime check to keep Coverity happy. */ |
|---|
| 785 | if ( uiIndex >= BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB ) |
|---|
| 786 | { |
|---|
| 787 | uiIndex = BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB - 1; |
|---|
| 788 | } |
|---|
| 789 | |
|---|
| 790 | *puiPts = pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiIndex ].stPTS[ePTSIndex].uiWhole; |
|---|
| 791 | |
|---|
| 792 | return; |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | void BXDM_PPQM_P_GetLastPts( |
|---|
| 796 | BXDM_PictureProvider_P_Picture_Context * pstPicture, |
|---|
| 797 | BXDM_PictureProvider_P_PTSIndex ePTSIndex, |
|---|
| 798 | uint32_t * puiPts |
|---|
| 799 | ) |
|---|
| 800 | { |
|---|
| 801 | uint32_t uiIndex; |
|---|
| 802 | |
|---|
| 803 | if ( false == pstPicture->bValidated ) |
|---|
| 804 | { |
|---|
| 805 | *puiPts = 0; |
|---|
| 806 | } |
|---|
| 807 | else |
|---|
| 808 | { |
|---|
| 809 | /* This range checking probably isn't required. */ |
|---|
| 810 | |
|---|
| 811 | if ( BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB <= pstPicture->stPicParms.stTSM.stStatic.uiNumElements ) |
|---|
| 812 | { |
|---|
| 813 | uiIndex = ( BXDM_PictureProvider_P_MAX_ELEMENTS_PER_PPB - 1 ); |
|---|
| 814 | } |
|---|
| 815 | else if ( 0 >= pstPicture->stPicParms.stTSM.stStatic.uiNumElements ) |
|---|
| 816 | { |
|---|
| 817 | uiIndex = 0; |
|---|
| 818 | } |
|---|
| 819 | else |
|---|
| 820 | { |
|---|
| 821 | uiIndex = ( pstPicture->stPicParms.stTSM.stStatic.uiNumElements - 1 ); |
|---|
| 822 | } |
|---|
| 823 | |
|---|
| 824 | BXDM_PPQM_P_GetPts( |
|---|
| 825 | pstPicture, |
|---|
| 826 | ePTSIndex, |
|---|
| 827 | uiIndex, |
|---|
| 828 | puiPts |
|---|
| 829 | ); |
|---|
| 830 | |
|---|
| 831 | } |
|---|
| 832 | |
|---|
| 833 | return; |
|---|
| 834 | |
|---|
| 835 | } |
|---|
| 836 | |
|---|
| 837 | void BXDM_PPQM_P_SetElementPolarity( |
|---|
| 838 | BXDM_PictureProvider_P_Picture_Context *pstPicture, |
|---|
| 839 | uint32_t uiElementIndex, |
|---|
| 840 | BAVC_Polarity ePolarity) |
|---|
| 841 | { |
|---|
| 842 | |
|---|
| 843 | pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiElementIndex ].ePolarity = ePolarity; |
|---|
| 844 | |
|---|
| 845 | return; |
|---|
| 846 | } |
|---|
| 847 | |
|---|
| 848 | void BXDM_PPQM_P_GetElementPolarity( |
|---|
| 849 | BXDM_PictureProvider_P_Picture_Context *pstPicture, |
|---|
| 850 | uint32_t uiElementIndex, |
|---|
| 851 | BAVC_Polarity *pePolarity) |
|---|
| 852 | { |
|---|
| 853 | |
|---|
| 854 | BDBG_ASSERT(pePolarity); |
|---|
| 855 | |
|---|
| 856 | *pePolarity = pstPicture->stPicParms.stTSM.stStatic.astElmts[ uiElementIndex ].ePolarity; |
|---|
| 857 | |
|---|
| 858 | return; |
|---|
| 859 | } |
|---|
| 860 | |
|---|
| 861 | |
|---|
| 862 | /******************************************************************************* |
|---|
| 863 | ** |
|---|
| 864 | ** End routines for manipulating picture context. |
|---|
| 865 | ** |
|---|
| 866 | *******************************************************************************/ |
|---|
| 867 | |
|---|
| 868 | |
|---|
| 869 | /******************************************************************************* |
|---|
| 870 | ** |
|---|
| 871 | ** "public" display queue management routines. |
|---|
| 872 | ** |
|---|
| 873 | *******************************************************************************/ |
|---|
| 874 | bool BXDM_PPQM_P_PeekAtNextPicture( |
|---|
| 875 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 876 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 877 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt, |
|---|
| 878 | BXDM_PictureProvider_P_Picture_Context * pstPrevPicCntxt, |
|---|
| 879 | BXDM_PictureProvider_P_Picture_Context * pstSelectedPicCntxt |
|---|
| 880 | ) |
|---|
| 881 | { |
|---|
| 882 | uint32_t uiPictureCount = 0; |
|---|
| 883 | |
|---|
| 884 | BDBG_ENTER( BXDM_PPQM_P_PeekAtNextPicture ); |
|---|
| 885 | |
|---|
| 886 | /* Snapshot the start time. */ |
|---|
| 887 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderGetPictureCountIsr ); |
|---|
| 888 | |
|---|
| 889 | hXdmPP->stDMConfig.stDecoderInterface.getPictureCount_isr( |
|---|
| 890 | hXdmPP->stDMConfig.pDecoderPrivateContext, |
|---|
| 891 | &uiPictureCount |
|---|
| 892 | ); |
|---|
| 893 | |
|---|
| 894 | /* Snapshot the end time. */ |
|---|
| 895 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP,BXDM_PPTIMER_P_Function_eDecoderGetPictureCountIsr ); |
|---|
| 896 | |
|---|
| 897 | if ( 0 != uiPictureCount ) |
|---|
| 898 | { |
|---|
| 899 | /* Used to conditionally generated the "first PTS ready" callback. |
|---|
| 900 | * Which is really the "first PPB received" callback. |
|---|
| 901 | */ |
|---|
| 902 | pLocalState->bFirstPPBReceived = true; |
|---|
| 903 | |
|---|
| 904 | /* Snapshot the start time. */ |
|---|
| 905 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderPeekAtPictureIsr ); |
|---|
| 906 | |
|---|
| 907 | hXdmPP->stDMConfig.stDecoderInterface.peekAtPicture_isr( |
|---|
| 908 | hXdmPP->stDMConfig.pDecoderPrivateContext, |
|---|
| 909 | 0, |
|---|
| 910 | &pstPicCntxt->pstUnifiedPicture |
|---|
| 911 | ); |
|---|
| 912 | |
|---|
| 913 | /* Snapshot the end time. */ |
|---|
| 914 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderPeekAtPictureIsr ); |
|---|
| 915 | |
|---|
| 916 | /* Update the dynamic context associate with this PPB. */ |
|---|
| 917 | BXDM_PPQM_S_ValidatePictureContext( hXdmPP, pLocalState, pstPicCntxt, pstPrevPicCntxt, pstSelectedPicCntxt ); |
|---|
| 918 | } |
|---|
| 919 | |
|---|
| 920 | BDBG_LEAVE( BXDM_PPQM_P_PeekAtNextPicture ); |
|---|
| 921 | |
|---|
| 922 | return ( 0 != uiPictureCount ); |
|---|
| 923 | } |
|---|
| 924 | |
|---|
| 925 | void BXDM_PPQM_P_GetNextPicture( |
|---|
| 926 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 927 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 928 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt |
|---|
| 929 | ) |
|---|
| 930 | { |
|---|
| 931 | uint32_t uiPictureCount = 0; |
|---|
| 932 | |
|---|
| 933 | BDBG_ENTER( BXDM_PPQM_P_GetNextPicture ); |
|---|
| 934 | BSTD_UNUSED(pLocalState); |
|---|
| 935 | |
|---|
| 936 | /* This routine assumes that there is data in the queue. |
|---|
| 937 | * The following check is to help with debug. |
|---|
| 938 | */ |
|---|
| 939 | |
|---|
| 940 | /* Snapshot the start time. */ |
|---|
| 941 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderGetPictureCountIsr ); |
|---|
| 942 | |
|---|
| 943 | hXdmPP->stDMConfig.stDecoderInterface.getPictureCount_isr( |
|---|
| 944 | hXdmPP->stDMConfig.pDecoderPrivateContext, |
|---|
| 945 | &uiPictureCount |
|---|
| 946 | ); |
|---|
| 947 | |
|---|
| 948 | /* Snapshot the end time. */ |
|---|
| 949 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderGetPictureCountIsr ); |
|---|
| 950 | |
|---|
| 951 | BDBG_ASSERT( 0 != uiPictureCount ); |
|---|
| 952 | |
|---|
| 953 | /* Snapshot the start time. */ |
|---|
| 954 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderGetNextPictureIsr ); |
|---|
| 955 | |
|---|
| 956 | hXdmPP->stDMConfig.stDecoderInterface.getNextPicture_isr( |
|---|
| 957 | hXdmPP->stDMConfig.pDecoderPrivateContext, |
|---|
| 958 | &pstPicCntxt->pstUnifiedPicture |
|---|
| 959 | ); |
|---|
| 960 | |
|---|
| 961 | /* Snapshot the end time. */ |
|---|
| 962 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderGetNextPictureIsr ); |
|---|
| 963 | |
|---|
| 964 | /* Since the PPB has been "removed" from the delivery queue, update the "PPBReceived" count. */ |
|---|
| 965 | hXdmPP->stDMStatus.stCounters.uiPicturesDecodedCount++; |
|---|
| 966 | |
|---|
| 967 | BXDM_PPDBG_P_PrintUnifiedPicture( hXdmPP, pLocalState, pstPicCntxt ); |
|---|
| 968 | |
|---|
| 969 | BDBG_LEAVE( BXDM_PPQM_P_GetNextPicture ); |
|---|
| 970 | |
|---|
| 971 | return; |
|---|
| 972 | |
|---|
| 973 | } /* end of BXDM_PPQM_P_GetNextPicture() */ |
|---|
| 974 | |
|---|
| 975 | void BXDM_PPQM_P_ReleasePicture( |
|---|
| 976 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 977 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt |
|---|
| 978 | ) |
|---|
| 979 | { |
|---|
| 980 | BDBG_ENTER( BXDM_PPQM_P_ReleasePicture ); |
|---|
| 981 | |
|---|
| 982 | /* Snapshot the start time. */ |
|---|
| 983 | BXDM_PPTMR_P_SnapshotFunctionStartTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderReleasePictureIsr ); |
|---|
| 984 | |
|---|
| 985 | if ( NULL != pstPicCntxt->pstUnifiedPicture ) |
|---|
| 986 | { |
|---|
| 987 | hXdmPP->stDMConfig.stDecoderInterface.releasePicture_isr( |
|---|
| 988 | hXdmPP->stDMConfig.pDecoderPrivateContext, |
|---|
| 989 | pstPicCntxt->pstUnifiedPicture, |
|---|
| 990 | NULL |
|---|
| 991 | ); |
|---|
| 992 | } |
|---|
| 993 | |
|---|
| 994 | /* Snapshot the end time. */ |
|---|
| 995 | BXDM_PPTMR_P_SnapshotFunctionEndTime( hXdmPP, BXDM_PPTIMER_P_Function_eDecoderReleasePictureIsr ); |
|---|
| 996 | |
|---|
| 997 | /* Bump the PPB released count. */ |
|---|
| 998 | hXdmPP->stDMStatus.stCounters.uiPicturesReleasedCount++; |
|---|
| 999 | |
|---|
| 1000 | /* Invalidate context */ |
|---|
| 1001 | pstPicCntxt->pstUnifiedPicture = NULL; |
|---|
| 1002 | pstPicCntxt->bValidated = false; |
|---|
| 1003 | |
|---|
| 1004 | BDBG_LEAVE( BXDM_PPQM_P_ReleasePicture ); |
|---|
| 1005 | |
|---|
| 1006 | return; |
|---|
| 1007 | |
|---|
| 1008 | } |
|---|
| 1009 | |
|---|
| 1010 | void BXDM_PPQM_P_ReleasePictureExt( |
|---|
| 1011 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 1012 | BXDM_PictureProvider_P_LocalState* pLocalState, |
|---|
| 1013 | BXDM_PictureProvider_P_Picture_Context * pstPicCntxt |
|---|
| 1014 | ) |
|---|
| 1015 | { |
|---|
| 1016 | BDBG_ENTER( BXDM_PPQM_P_ReleasePictureExt ); |
|---|
| 1017 | |
|---|
| 1018 | /* SW7405-4804: Typically the extension data callback will be executed when a |
|---|
| 1019 | * picture is delivered to VDC via the "BXDM_PPCB_P_ExecuteCallbacks" function. |
|---|
| 1020 | * However this does not happen for pictures that are dropped. This case is |
|---|
| 1021 | * now handled by calling "BXDM_PPCB_P_ExecuteSingleCallbackExt" whenever a |
|---|
| 1022 | * picture is released. The flag "bExtensionDataDelivered" ensures that the |
|---|
| 1023 | * callback is only executed once per picture. |
|---|
| 1024 | */ |
|---|
| 1025 | BXDM_PPCB_P_ExecuteSingleCallbackExt( |
|---|
| 1026 | hXdmPP, |
|---|
| 1027 | pLocalState, |
|---|
| 1028 | pstPicCntxt, |
|---|
| 1029 | BXDM_PictureProvider_Callback_ePictureExtensionData |
|---|
| 1030 | ); |
|---|
| 1031 | |
|---|
| 1032 | BXDM_PPQM_P_ReleasePicture( hXdmPP, pstPicCntxt ); |
|---|
| 1033 | |
|---|
| 1034 | BDBG_LEAVE( BXDM_PPQM_P_ReleasePictureExt ); |
|---|
| 1035 | |
|---|
| 1036 | return; |
|---|
| 1037 | } |
|---|
| 1038 | |
|---|
| 1039 | void BXDM_PPQM_P_PromotePictureToDisplayStatus( |
|---|
| 1040 | BXDM_PictureProvider_Handle hXdmPP, |
|---|
| 1041 | BXDM_PictureProvider_P_LocalState * pLocalState, |
|---|
| 1042 | BXDM_PictureProvider_P_Picture_Context * pstNewPicture |
|---|
| 1043 | ) |
|---|
| 1044 | { |
|---|
| 1045 | BXDM_PictureProvider_P_Picture_Context * pstSelectedPicture; |
|---|
| 1046 | |
|---|
| 1047 | BDBG_ENTER( BXDM_PPQM_P_PromotePictureToDisplayStatus ); |
|---|
| 1048 | |
|---|
| 1049 | pstSelectedPicture = &(hXdmPP->stDMState.stChannel.stSelectedPicture); |
|---|
| 1050 | |
|---|
| 1051 | /* copy the context on the new picture */ |
|---|
| 1052 | |
|---|
| 1053 | *pstSelectedPicture = *pstNewPicture; |
|---|
| 1054 | |
|---|
| 1055 | /* |
|---|
| 1056 | * The following logic is esentially cloned from DM V1. |
|---|
| 1057 | * "bThisIsTheFirstPPB" will only be true the first time a picture |
|---|
| 1058 | * is promoted to display status. |
|---|
| 1059 | * "bFirstPPBHasBeenDisplayed" will remain true once a picture is |
|---|
| 1060 | * promoted to display status. |
|---|
| 1061 | */ |
|---|
| 1062 | if ( false == hXdmPP->stDMState.stDecode.bFirstPPBHasBeenDisplayed ) |
|---|
| 1063 | { |
|---|
| 1064 | hXdmPP->stDMState.stDecode.bThisIsTheFirstPPB = true; |
|---|
| 1065 | } |
|---|
| 1066 | else |
|---|
| 1067 | { |
|---|
| 1068 | hXdmPP->stDMState.stDecode.bThisIsTheFirstPPB = false; |
|---|
| 1069 | } |
|---|
| 1070 | |
|---|
| 1071 | hXdmPP->stDMState.stDecode.bFirstPPBHasBeenDisplayed = true; |
|---|
| 1072 | |
|---|
| 1073 | /* If the picture is the first I frame, generate the BXVD_Interrupt_eIFrame callback */ |
|---|
| 1074 | |
|---|
| 1075 | BXDM_PPCB_P_EvaluateCriteria_IFrame( hXdmPP, pLocalState, pstSelectedPicture ); |
|---|
| 1076 | |
|---|
| 1077 | /* Since we've promoted a new PPB, we need to reset the PPB and |
|---|
| 1078 | * Element repeated flags to false */ |
|---|
| 1079 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.bPPBRepeated = false; |
|---|
| 1080 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.bElementRepeated = false; |
|---|
| 1081 | |
|---|
| 1082 | /* Remember the SPIM setting for this picture to handle cases where |
|---|
| 1083 | * SPIM is changed from "both" to "default" during a trick mode |
|---|
| 1084 | * transition (e.g. pause -> play */ |
|---|
| 1085 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.eSourceFormatOverride = hXdmPP->stDMConfig.eSourceFormatOverride; |
|---|
| 1086 | |
|---|
| 1087 | /* SW7635-51: snapshot the STC offset (uiSoftwarePCROffset) when a |
|---|
| 1088 | * picture is selected for display. |
|---|
| 1089 | */ |
|---|
| 1090 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.uiSoftwarePCROffset = hXdmPP->stDMConfig.uiSoftwarePCROffset; |
|---|
| 1091 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.bSwPcrOffsetValid = true; |
|---|
| 1092 | |
|---|
| 1093 | /* SW7425-2255: snapshot the display offset (uiPTSOffset) when a |
|---|
| 1094 | * picture is selected for display. |
|---|
| 1095 | */ |
|---|
| 1096 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.uiPtsOffset = hXdmPP->stDMConfig.uiPTSOffset; |
|---|
| 1097 | pstSelectedPicture->stPicParms.stDisplay.stDynamic.bPtsOffsetValid = true; |
|---|
| 1098 | |
|---|
| 1099 | /* If the PPB contained a coded PTS, save it for the application. */ |
|---|
| 1100 | |
|---|
| 1101 | if ( true == pstSelectedPicture->pstUnifiedPicture->stPTS.bValid ) |
|---|
| 1102 | { |
|---|
| 1103 | hXdmPP->stDMStatus.stCodedPTS.ui32RunningPTS = pstSelectedPicture->pstUnifiedPicture->stPTS.uiValue; |
|---|
| 1104 | hXdmPP->stDMStatus.stCodedPTS.ePTSType = BXDM_PictureProvider_PTSType_eCoded; |
|---|
| 1105 | } |
|---|
| 1106 | |
|---|
| 1107 | /* Update the public copy with the current GOP time code. */ |
|---|
| 1108 | |
|---|
| 1109 | hXdmPP->stDMStatus.stGOPTimeCode = pstSelectedPicture->pstUnifiedPicture->stGOPTimeCode; |
|---|
| 1110 | |
|---|
| 1111 | BDBG_LEAVE( BXDM_PPQM_P_PromotePictureToDisplayStatus ); |
|---|
| 1112 | |
|---|
| 1113 | return; |
|---|
| 1114 | } |
|---|
| 1115 | |
|---|
| 1116 | BXDM_PictureProvider_P_Picture_Context * BXDM_PPQM_P_GetFirstPictureContext( BXDM_PictureProvider_Handle hXdmPP ) |
|---|
| 1117 | { |
|---|
| 1118 | return &(hXdmPP->stDMState.stChannel.stPictureUnderEvaluation); |
|---|
| 1119 | } |
|---|
| 1120 | |
|---|
| 1121 | /******************************************************************************* |
|---|
| 1122 | ** |
|---|
| 1123 | ** end "public" display queue management routines. |
|---|
| 1124 | ** |
|---|
| 1125 | *******************************************************************************/ |
|---|