Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

712 lines
18 KiB

  1. /******************************************************************************\
  2. * *
  3. * VIDSTRM.C - Video stream control related code. *
  4. * *
  5. * Copyright (c) C-Cube Microsystems 1996 *
  6. * All Rights Reserved. *
  7. * *
  8. * Use of C-Cube Microsystems code is governed by terms and conditions *
  9. * stated in the accompanying licensing statement. *
  10. * *
  11. \******************************************************************************/
  12. #include "Headers.h"
  13. #pragma hdrstop
  14. #include "vidstrm.h"
  15. #include "copyprot.h"
  16. #include "bmaster.h"
  17. #include "vpestrm.h"
  18. #include "ccaption.h"
  19. extern BOOL bJustHighLight;
  20. extern GUID MY_KSEVENTSETID_VPNOTIFY ;
  21. typedef struct _STREAMEX {
  22. BOOL EventCount;
  23. KSSTATE state;
  24. HANDLE hClk;
  25. }STREAMEX, *PSTREAMEX;
  26. //*****************************************************************************
  27. // STATIC FUNCTIONS DECLARATION
  28. //*****************************************************************************
  29. static VOID GetVideoProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  30. static VOID SetVideoProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  31. static void GetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb );
  32. static void SetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb );
  33. static VOID VideoSendPacket( PHW_STREAM_REQUEST_BLOCK pSrb );
  34. static void VideoQueryAccept( PHW_STREAM_REQUEST_BLOCK pSrb );
  35. /*
  36. ** VideoReceiveCtrlPacket()
  37. **
  38. ** Receives packet commands that control the video stream
  39. **
  40. ** Arguments:
  41. **
  42. ** pSrb - The stream request block for the video stream
  43. **
  44. ** Returns:
  45. **
  46. ** Side Effects: none
  47. */
  48. VOID STREAMAPI VideoReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  49. {
  50. PHW_DEVICE_EXTENSION pdevext = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  51. DebugPrint(( DebugLevelVerbose, "ZiVA: Begin VideoReceiveCtrlPacket->" ));
  52. switch( pSrb->Command )
  53. {
  54. case SRB_SET_STREAM_STATE:
  55. DebugPrint(( DebugLevelVerbose, "SRB_SET_STREAM_STATE\n" ));
  56. AdapterSetState( pSrb );
  57. break;
  58. case SRB_GET_STREAM_PROPERTY:
  59. DebugPrint(( DebugLevelVerbose, "SRB_GET_STREAM_PROPERTY\n" ));
  60. GetVideoProperty( pSrb );
  61. break;
  62. case SRB_SET_STREAM_PROPERTY:
  63. DebugPrint(( DebugLevelVerbose, "SRB_SET_STREAM_PROPERTY\n" ));
  64. SetVideoProperty( pSrb );
  65. break;
  66. case SRB_PROPOSE_DATA_FORMAT:
  67. DebugPrint(( DebugLevelVerbose, "SRB_PROPOSE_DATA_FORMAT\n" ));
  68. VideoQueryAccept( pSrb );
  69. break;
  70. case SRB_OPEN_MASTER_CLOCK:
  71. case SRB_CLOSE_MASTER_CLOCK:
  72. case SRB_INDICATE_MASTER_CLOCK:
  73. //
  74. // these should be stored individually on a per stream basis
  75. //
  76. //hMaster = pSrb->CommandData.MasterClockHandle;
  77. pSrb->Status = STATUS_SUCCESS;
  78. break;
  79. case SRB_BEGIN_FLUSH : // beginning flush state
  80. MonoOutStr(" Vid : SRB_BEGIN_FLUSH ");
  81. #ifndef DECODE_DVDPC
  82. pdevext->bInterruptPending = FALSE;
  83. #endif
  84. if (pdevext->pCurrentVideoSrb != NULL)
  85. {
  86. ZivaHw_Abort();
  87. // adapterUpdateNextSrbOrderNumberOnDiscardSrb(pdevext->pCurrentVideoSrb);
  88. pdevext->pCurrentVideoSrb->Status = STATUS_SUCCESS;
  89. AdapterReleaseRequest( pdevext->pCurrentVideoSrb );
  90. pdevext->pCurrentVideoSrb = NULL;
  91. pdevext->dwCurrentVideoSample = 0;
  92. pdevext->dwCurrentVideoPage = 0;
  93. }
  94. pSrb->Status = STATUS_SUCCESS;
  95. break;
  96. case SRB_END_FLUSH : // ending flush state
  97. MonoOutStr(" Vid : SRB_END_FLUSH ");
  98. pSrb->Status = STATUS_SUCCESS;
  99. if (pdevext->pCurrentVideoSrb != NULL)
  100. {
  101. // adapterUpdateNextSrbOrderNumberOnDiscardSrb(pdevext->pCurrentVideoSrb);
  102. pdevext->pCurrentVideoSrb->Status = STATUS_SUCCESS;
  103. AdapterReleaseRequest( pdevext->pCurrentVideoSrb );
  104. pdevext->pCurrentVideoSrb = NULL;
  105. pdevext->dwCurrentVideoSample = 0;
  106. pdevext->dwCurrentVideoPage = 0;
  107. }
  108. // ZivaHw_Play();
  109. pdevext->bPlayCommandPending = TRUE;
  110. pdevext->bEndFlush = TRUE;
  111. // FinishCurrentPacketAndSendNextOne( pdevext );
  112. break;
  113. default:
  114. //TRAP
  115. DebugPrint(( DebugLevelVerbose, "!!!! UNKNOWN COMMAND !!!! :::> %X\n", pSrb->Command ));
  116. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  117. }
  118. AdapterReleaseRequest( pSrb );
  119. DebugPrint(( DebugLevelVerbose, "ZiVA: End VideoReceiveCtrlPacket\n" ));
  120. }
  121. /*
  122. ** VideoReceiveDataPacket()
  123. **
  124. ** Receives video data packets
  125. **
  126. ** Arguments:
  127. **
  128. ** pSrb - Stream request block for the video device
  129. **
  130. ** Returns:
  131. **
  132. ** Side Effects: none
  133. */
  134. VOID STREAMAPI VideoReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  135. {
  136. PHW_DEVICE_EXTENSION pdevext = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  137. switch( pSrb->Command )
  138. {
  139. case SRB_WRITE_DATA:
  140. if(bJustHighLight)
  141. {
  142. pSrb->TimeoutCounter = pSrb->TimeoutOriginal = pSrb->TimeoutCounter / 5;
  143. bJustHighLight = FALSE;
  144. MonoOutStr("Video TimeOut Counter Reduced");
  145. }
  146. VideoSendPacket( pSrb );
  147. break;
  148. default:
  149. DebugPrint(( DebugLevelWarning, "!!!! UNKNOWN COMMAND !!!! :::> %X\n", pSrb->Command ));
  150. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  151. MonoOutStr("!!!! UNKNOWN COMMAND !!!!");
  152. AdapterReleaseRequest( pSrb );
  153. }
  154. }
  155. /*
  156. ** GetVideoProperty()
  157. **
  158. ** Routine to process video property requests
  159. **
  160. ** Arguments:
  161. **
  162. ** pSrb - pointer to the stream request block for properties
  163. **
  164. ** Returns:
  165. **
  166. ** Side Effects: none
  167. */
  168. static VOID GetVideoProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
  169. {
  170. PHW_DEVICE_EXTENSION phwdevext = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  171. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  172. DebugPrint(( DebugLevelVerbose, "ZiVA: Begin GetVideoProperty()\n" ));
  173. if( IsEqualGUID( &KSPROPSETID_CopyProt, &pSPD->Property->Set ) )
  174. { // this is a copy protection property go handle it there
  175. CopyProtGetProp( pSrb );
  176. }
  177. else if( IsEqualGUID( &KSPROPSETID_TSRateChange, &pSPD->Property->Set ) )
  178. { // this is a transfer rate change property go handle it there
  179. GetVideoRateChange( pSrb );
  180. }
  181. DebugPrint(( DebugLevelVerbose, "ZiVA: End GetVideoProperty()\n" ));
  182. }
  183. /*
  184. ** SetVideoProperty()
  185. **
  186. ** Routine to process video property requests
  187. **
  188. ** Arguments:
  189. **
  190. ** pSrb - pointer to the stream request block for properties
  191. **
  192. ** Returns:
  193. **
  194. ** Side Effects: none
  195. */
  196. static VOID SetVideoProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  197. {
  198. PHW_DEVICE_EXTENSION phwdevext = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  199. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  200. DebugPrint(( DebugLevelVerbose, "ZiVA: Begin GetVideoProperty()\n" ));
  201. if( IsEqualGUID( &KSPROPSETID_CopyProt, &pSPD->Property->Set ) )
  202. { // this is a copy protection property go handle it there
  203. CopyProtSetPropIfAdapterReady( pSrb );
  204. }
  205. else if( IsEqualGUID( &KSPROPSETID_TSRateChange, &pSPD->Property->Set ) )
  206. { // this is a transfer rate change property go handle it there
  207. SetVideoRateChange( pSrb );
  208. }
  209. DebugPrint(( DebugLevelVerbose, "ZiVA: End GetVideoProperty()\n" ));
  210. }
  211. static void GetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  212. {
  213. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  214. DebugPrint(( DebugLevelVerbose, "ZiVA: GetVideoRateChange()->" ));
  215. switch( pSrb->CommandData.PropertyInfo->Property->Id )
  216. {
  217. case KS_AM_RATE_SimpleRateChange:
  218. {
  219. KS_AM_SimpleRateChange* pRateChange;
  220. DebugPrint(( DebugLevelVerbose, "KS_AM_RATE_SimpleRateChange\n" ));
  221. pSrb->ActualBytesTransferred = sizeof( KS_AM_RATE_SimpleRateChange );
  222. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  223. pRateChange->StartTime = 0/*pHwDevExt->VideoStartTime*/;
  224. pRateChange->Rate = 10000 /*pHwDevExt->VideoRate*/;
  225. }
  226. pSrb->Status = STATUS_SUCCESS;
  227. break;
  228. case KS_AM_RATE_ExactRateChange:
  229. DebugPrint(( DebugLevelVerbose, "KS_AM_RATE_ExactRateChange (NOT IMPLEMENTED)\n" ));
  230. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  231. break;
  232. case KS_AM_RATE_MaxFullDataRate:
  233. {
  234. KS_AM_MaxFullDataRate* pMaxRate;
  235. DebugPrint(( DebugLevelVerbose, "KS_AM_RATE_MaxFullDataRate\n" ));
  236. pSrb->ActualBytesTransferred = sizeof( KS_AM_RATE_MaxFullDataRate );
  237. pMaxRate = (KS_AM_MaxFullDataRate*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  238. *pMaxRate = 10000 /*pHwDevExt->VideoMaxFullRate*/;
  239. }
  240. pSrb->Status = STATUS_SUCCESS;
  241. break;
  242. case KS_AM_RATE_Step:
  243. DebugPrint(( DebugLevelVerbose, "KS_AM_RATE_Step (NOT IMPLEMENTED)\n" ));
  244. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  245. }
  246. }
  247. static void SetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  248. {
  249. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  250. DebugPrint(( DebugLevelVerbose, "ZiVA: SetVideoRateChange()->" ));
  251. switch( pSrb->CommandData.PropertyInfo->Property->Id )
  252. {
  253. case KS_AM_RATE_SimpleRateChange:
  254. {
  255. KS_AM_SimpleRateChange* pRateChange;
  256. REFERENCE_TIME NewStartTime;
  257. LONG NewRate;
  258. DebugPrint(( DebugLevelVerbose, "KS_AM_RATE_SimpleRateChange\n" ));
  259. MonoOutStr("KS_AM_RATE_SimpleRateChange"); //sri
  260. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  261. NewStartTime = pRateChange->StartTime;
  262. NewRate = (pRateChange->Rate < 0) ? -pRateChange->Rate : pRateChange->Rate;
  263. DebugPrint(( DebugLevelVerbose, "ZiVA: Received Data\r\n" ));
  264. DebugPrint(( DebugLevelVerbose, "ZiVA: StartTime = 0x%08x\r\n", NewStartTime ));
  265. DebugPrint(( DebugLevelVerbose, "ZiVA: Rate = 0x%08x\r\n", NewRate ));
  266. pHwDevExt->bScanCommandPending = TRUE;
  267. if( pHwDevExt->NewRate > 10000)
  268. pHwDevExt->bRateChangeFromSlowMotion = TRUE;
  269. pHwDevExt->NewRate = NewRate;
  270. }
  271. pSrb->Status = STATUS_SUCCESS;
  272. break;
  273. case KS_AM_RATE_ExactRateChange :
  274. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  275. break;
  276. case KS_AM_RATE_MaxFullDataRate :
  277. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  278. break;
  279. case KS_AM_RATE_Step :
  280. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  281. break;
  282. }
  283. }
  284. #if 0
  285. static BOOLEAN PreparePageTable(PHW_STREAM_REQUEST_BLOCK pSrb)
  286. {
  287. DWORD i = 0;
  288. DWORD k = 0;
  289. DWORD j = 0;
  290. PKSSCATTER_GATHER pSGList;
  291. DWORD dwSum = 0;
  292. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  293. if(pSrb == NULL)
  294. {
  295. #ifdef DEBUG
  296. MonoOutStr("PreparePageTable::pSrb is NULL");
  297. #endif
  298. return FALSE;
  299. }
  300. pSGList = pSrb->ScatterGatherBuffer;
  301. if(pSGList == NULL)
  302. {
  303. #ifdef DEBUG
  304. MonoOutStr("PreparePageTable::pSGList is NULL");
  305. #endif
  306. return FALSE;
  307. }
  308. while( j < pSrb->NumberOfBuffers)
  309. {
  310. dwSum = 0;
  311. k = 0;
  312. do
  313. {
  314. dwSum += pSGList[i].Length;
  315. i++;
  316. k++;
  317. }while(dwSum < pHwDevExt->VidBufferSize[j]);
  318. pHwDevExt->VideoPageTable[j] = k;
  319. j++;
  320. if(j > 50)
  321. {
  322. #ifdef DEBUG
  323. MonoOutStr("PreparePageTable::ArrayCrossingLimit");
  324. #endif
  325. return FALSE;
  326. }
  327. }
  328. return TRUE;
  329. }
  330. #endif
  331. /*
  332. ** VideoSendPacket()
  333. **
  334. ** Routine to initialise the stream data packet handling
  335. **
  336. ** Arguments:
  337. **
  338. ** pSrb - Pointer to the stream request block
  339. **
  340. ** Returns:
  341. **
  342. ** Side Effects: none
  343. */
  344. static VOID VideoSendPacket(PHW_STREAM_REQUEST_BLOCK pSrb)
  345. {
  346. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  347. ULONG ulSample;
  348. KSSTREAM_HEADER* pHeader;
  349. if (CheckAndReleaseIfCtrlPkt(pSrb))
  350. return;
  351. pHeader = (PKSSTREAM_HEADER)pSrb->CommandData.DataBufferArray;
  352. for( ulSample = 0; ulSample < pSrb->NumberOfBuffers; ulSample++, pHeader++ )
  353. {
  354. // Check header flags
  355. #ifdef DEBUG
  356. if( pHeader->OptionsFlags & ~(KSSTREAM_HEADER_OPTIONSF_SPLICEPOINT |
  357. KSSTREAM_HEADER_OPTIONSF_PREROLL |
  358. KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY |
  359. KSSTREAM_HEADER_OPTIONSF_TYPECHANGED |
  360. KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
  361. KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY |
  362. KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE |
  363. KSSTREAM_HEADER_OPTIONSF_DURATIONVALID |
  364. KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA) )
  365. DebugPrint(( DebugLevelWarning, "ZiVA: !!!!!!!!! NEW KSSTREAM_HEADER_OPTIONSF_ ADDED !!!!!!!!!\n" ));
  366. //tmp MonoOutChar('V');
  367. //tmp MonoOutULong( (pHeader->TypeSpecificFlags) >> 16 );
  368. //tmp MonoOutChar( '.' );
  369. // MonoOutStr("PHTime");
  370. // MonoOutULong( pHeader->PresentationTime );
  371. pHwDevExt->VideoSTC = pHeader->PresentationTime.Time;
  372. #endif
  373. if(pHwDevExt->dwFirstVideoOrdNum == -1)
  374. {
  375. pHwDevExt->dwFirstVideoOrdNum = (pHeader->TypeSpecificFlags) >> 16;
  376. MonoOutStr("FirstVidioBuffer");
  377. MonoOutULong( (pHeader->TypeSpecificFlags) >> 16 );
  378. }
  379. // pHwDevExt->VidBufferSize[ulSample] = pHeader->DataUsed;
  380. if(pHwDevExt->bToBeDiscontinued)
  381. {
  382. // wVideoDiscOrderNumber = (pHeader->TypeSpecificFlags) >> 16;
  383. pHwDevExt->bToBeDiscontinued = FALSE;
  384. pHwDevExt->bDiscontinued = TRUE;
  385. }
  386. // #ifdef DEBUG
  387. if( pHeader->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE )
  388. {
  389. MonoOutStr(" V->FLUSHONPAUSE ");
  390. }
  391. if( pHeader->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY )
  392. {
  393. MonoOutStr(" V->DISCONT ");
  394. // wVideoDiscOrderNumber = (pHeader->TypeSpecificFlags) >> 16;
  395. pHwDevExt->bToBeDiscontinued = TRUE;
  396. pHwDevExt->bDiscontinued = TRUE;
  397. CCSendDiscontinuity(pHwDevExt);
  398. }
  399. if( pHeader->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED )
  400. {
  401. DebugPrint(( DebugLevelVerbose, "ZiVA: Processing video stream format.\n" ));
  402. MonoOutStr( " V->TYPECHANGED " );
  403. //#if defined (DECODER_DVDPC) || defined(EZDVD)
  404. if ( pHeader->DataUsed >= sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2) )
  405. {
  406. ProcessVideoFormat( (PKSDATAFORMAT)pHeader->Data, pHwDevExt );
  407. }
  408. //#endif
  409. }
  410. }
  411. // Register this Srb
  412. #ifdef DEBUG
  413. if( pHwDevExt->pCurrentVideoSrb )
  414. {
  415. MonoOutStr("!!!!!!!VideoSlotNotEmpty!!!!!");
  416. DebugPrint(( DebugLevelWarning, "ZiVA: !!!!!!!!!!! ERROR: Video slot is not empty !!!!!!!!!!\n" ));
  417. }
  418. #endif // DEBUG
  419. pHwDevExt->pCurrentVideoSrb = pSrb;
  420. AdapterSendData( pHwDevExt );
  421. }
  422. /*
  423. ** VideoQueryAccept()
  424. **
  425. **
  426. **
  427. ** Arguments:
  428. **
  429. ** pSrb - Pointer to the stream request block
  430. **
  431. ** Returns:
  432. **
  433. ** Side Effects: none
  434. */
  435. static void VideoQueryAccept( PHW_STREAM_REQUEST_BLOCK pSrb )
  436. {
  437. PKSDATAFORMAT pfmt = pSrb->CommandData.OpenFormat;
  438. KS_MPEGVIDEOINFO2* pblock = (KS_MPEGVIDEOINFO2*)((BYTE*)pfmt + sizeof( KSDATAFORMAT ));
  439. DebugPrint(( DebugLevelVerbose, "ZiVA: Begin VideoQueryAccept()\n" ));
  440. // pick up the format block and examine it. Default to not implemented
  441. pSrb->Status = STATUS_SUCCESS;
  442. if( pfmt->FormatSize != sizeof( KSDATAFORMAT ) + sizeof( KS_MPEGVIDEOINFO2 ) )
  443. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  444. DebugPrint(( DebugLevelVerbose, "ZiVA: End VideoQueryAccept()\n" ));
  445. }
  446. void SetDisplayModeAndAspectRatio(PHW_DEVICE_EXTENSION pHwDevExt,KS_MPEGVIDEOINFO2 * VidFmt)
  447. {
  448. if( pHwDevExt->VPFmt.dwPictAspectRatioX == 4 && pHwDevExt->VPFmt.dwPictAspectRatioY == 3 )
  449. {
  450. ZivaHW_ForceCodedAspectRatio(0);
  451. if( VidFmt->dwFlags & KS_MPEG2_SourceIsLetterboxed )
  452. {
  453. if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  454. {
  455. ZivaHw_SetDisplayMode( 0,1);
  456. }
  457. else
  458. {
  459. ZivaHw_SetDisplayMode( 0,2);
  460. }
  461. }
  462. else if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  463. {
  464. ZivaHw_SetDisplayMode( 0,1);
  465. }
  466. else
  467. {
  468. ZivaHw_SetDisplayMode( 0,2);
  469. }
  470. }
  471. else if (pHwDevExt->VPFmt.dwPictAspectRatioX == 16 && pHwDevExt->VPFmt.dwPictAspectRatioY == 9 )
  472. {
  473. ZivaHW_ForceCodedAspectRatio(3);
  474. if( VidFmt->dwFlags & KS_MPEG2_SourceIsLetterboxed )
  475. {
  476. if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  477. {
  478. ZivaHw_SetDisplayMode( 0,1);
  479. }
  480. else
  481. {
  482. ZivaHw_SetDisplayMode( 0,2);
  483. }
  484. }
  485. else if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  486. {
  487. ZivaHw_SetDisplayMode( 0,1);
  488. }
  489. else
  490. {
  491. ZivaHw_SetDisplayMode( 0,2);
  492. }
  493. }
  494. }
  495. void SetVideoSystem(PHW_DEVICE_EXTENSION pHwDevExt, DWORD biHeight)
  496. {
  497. static WORD VidSystem=-1;
  498. if((biHeight == 576)||(biHeight == 288))
  499. pHwDevExt->VidSystem = PAL;
  500. else
  501. pHwDevExt->VidSystem = NTSC;
  502. if(VidSystem != pHwDevExt->VidSystem)
  503. ZivaHw_SetVideoMode(pHwDevExt);
  504. VidSystem = pHwDevExt->VidSystem;
  505. }
  506. void ProcessVideoFormat( PKSDATAFORMAT pfmt, PHW_DEVICE_EXTENSION pHwDevExt )
  507. {
  508. KS_MPEGVIDEOINFO2 * VidFmt = (KS_MPEGVIDEOINFO2 *)((ULONG)pfmt + sizeof (KSDATAFORMAT));
  509. if( pfmt->FormatSize != sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2) )
  510. return;
  511. pHwDevExt->VPFmt.dwPictAspectRatioX = VidFmt->hdr.dwPictAspectRatioX;
  512. pHwDevExt->VPFmt.dwPictAspectRatioY = VidFmt->hdr.dwPictAspectRatioY;
  513. SetDisplayModeAndAspectRatio(pHwDevExt,VidFmt);
  514. SetVideoSystem(pHwDevExt,VidFmt->hdr.bmiHeader.biHeight);
  515. if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  516. DebugPrint(( DebugLevelTrace, "KS_MPEG2_DoPanScan\r\n" ));
  517. if( VidFmt->dwFlags & KS_MPEG2_DVDLine21Field1 )
  518. DebugPrint(( DebugLevelTrace, "KS_MPEG2_DVDLine21Field1\r\n" ));
  519. if( VidFmt->dwFlags & KS_MPEG2_DVDLine21Field2 )
  520. DebugPrint(( DebugLevelTrace, "KS_MPEG2_DVDLine21Field2\r\n" ));
  521. if( VidFmt->dwFlags & KS_MPEG2_SourceIsLetterboxed )
  522. DebugPrint(( DebugLevelTrace, "KS_MPEG2_SourceIsLetterboxed\r\n" ));
  523. if( VidFmt->dwFlags & KS_MPEG2_FilmCameraMode )
  524. DebugPrint(( DebugLevelTrace, "KS_MPEG2_FilmCameraMode\r\n" ));
  525. if (VidFmt->dwFlags & KS_MPEG2_DoPanScan)
  526. {
  527. // TRAP;
  528. //
  529. // under pan scan for DVD for NTSC, we must be going to a 540 by
  530. // 480 bit image, from a 720 x 480 (or 704 x 480) We will
  531. // use this as the base starting dimensions. If the Sequence
  532. // header provides other sizes, then those should be updated,
  533. // and the Video port connection should be updated when the
  534. // sequence header is received.
  535. //
  536. //
  537. // change the picture aspect ratio. Since we will be stretching
  538. // from 540 to 720 in the horizontal direction, our aspect ratio
  539. // will
  540. //
  541. pHwDevExt->VPFmt.dwPictAspectRatioX = (VidFmt->hdr.dwPictAspectRatioX * (54000 / 72));
  542. pHwDevExt->VPFmt.dwPictAspectRatioY = VidFmt->hdr.dwPictAspectRatioY * 1000;
  543. }
  544. //
  545. // call the IVPConfig interface here
  546. //
  547. #if defined(DECODER_DVDPC) || defined(EZDVD)
  548. if (pHwDevExt->pstroYUV &&
  549. ((PSTREAMEX)(pHwDevExt->pstroYUV->HwStreamExtension))->EventCount)
  550. {
  551. StreamClassStreamNotification(
  552. SignalMultipleStreamEvents,
  553. pHwDevExt->pstroYUV,
  554. &MY_KSEVENTSETID_VPNOTIFY,
  555. KSEVENT_VPNOTIFY_FORMATCHANGE
  556. );
  557. }
  558. #endif
  559. }
  560. /*
  561. ** CycEvent ()
  562. **
  563. ** receives notification for stream event enable/ disable
  564. **
  565. ** Arguments:}
  566. **
  567. **
  568. **
  569. ** Returns:
  570. **
  571. ** Side Effects:
  572. */
  573. #if defined(DECODER_DVDPC) || defined(EZDVD)
  574. NTSTATUS STREAMAPI CycEvent( PHW_EVENT_DESCRIPTOR pEvent )
  575. {
  576. PSTREAMEX pstrm = (PSTREAMEX)( pEvent->StreamObject->HwStreamExtension );
  577. //DebugPrint( (DebugLevelTrace, "CycEvent\r\n") );
  578. if( pEvent->Enable ) {
  579. pstrm ->EventCount++;
  580. }
  581. else {
  582. pstrm ->EventCount--;
  583. }
  584. return( STATUS_SUCCESS );
  585. }
  586. #endif