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.

229 lines
5.8 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1997 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //
  11. // History:
  12. // 22-Aug-97 TKB Created Initial Interface Version
  13. //
  14. //==========================================================================;
  15. #include <ccdecode.h>
  16. #pragma warning(disable:4355)
  17. //////////////////////////////////////////////////////////////
  18. // Closed captioning KSDATAFORMAT definitions
  19. //////////////////////////////////////////////////////////////
  20. #define CCSamples 2
  21. #define CC_FORMAT_PIN_NUMBER 1
  22. KSDATARANGE StreamFormatCC =
  23. {
  24. // Definition of the CC stream (MUST match the output pin of the decoder)
  25. {
  26. sizeof (KSDATARANGE), // FormatSize
  27. 0, // Flags
  28. CCSamples, // SampleSize
  29. 0, // Reserved
  30. { STATIC_KSDATAFORMAT_TYPE_AUXLine21Data }, // MajorFormat
  31. { STATIC_KSDATAFORMAT_SUBTYPE_Line21_BytePair }, // Subtype
  32. { STATIC_KSDATAFORMAT_SPECIFIER_NONE },
  33. }
  34. };
  35. //////////////////////////////////////////////////////////////
  36. // ICCOutputPin
  37. //////////////////////////////////////////////////////////////
  38. ICCOutputPin::~ICCOutputPin()
  39. {
  40. }
  41. //////////////////////////////////////////////////////////////
  42. // ICCDecode:: ctors & dtors
  43. //////////////////////////////////////////////////////////////
  44. ICCDecode::ICCDecode() :
  45. IVBICodec("Closed Caption Decoder", sizeof(VBICODECFILTERING_CC_SUBSTREAMS) ),
  46. m_Statistics(*this, KSPROPERTY_VBICODECFILTERING_STATISTICS, sizeof(VBICODECFILTERING_STATISTICS_CC)),
  47. m_OutputPin(*this, CC_FORMAT_PIN_NUMBER, &StreamFormatCC )
  48. {
  49. }
  50. ICCDecode::~ICCDecode()
  51. {
  52. }
  53. //////////////////////////////////////////////////////////////
  54. // ICCDecode Scanline routines
  55. //////////////////////////////////////////////////////////////
  56. int
  57. ICCDecode::AddRequestedScanline(int nScanline)
  58. {
  59. int nStatus = -1;
  60. VBICODECFILTERING_SCANLINES ScanlineBitArray;
  61. if ( m_OutputPin.m_ScanlinesRequested.GetValue(&ScanlineBitArray) )
  62. {
  63. DWORD nBitsPerElement = sizeof(*ScanlineBitArray.DwordBitArray)*8;
  64. ScanlineBitArray.DwordBitArray[ nScanline / nBitsPerElement ]
  65. |= 1L << (nScanline % nBitsPerElement);
  66. if ( m_OutputPin.m_ScanlinesRequested.SetValue(&ScanlineBitArray) )
  67. nStatus = 0;
  68. }
  69. return nStatus;
  70. }
  71. int
  72. ICCDecode::ClearRequestedScanlines()
  73. {
  74. int nStatus = -1;
  75. VBICODECFILTERING_SCANLINES ScanlineBitArray;
  76. ZeroMemory(&ScanlineBitArray,sizeof(ScanlineBitArray));
  77. if ( m_OutputPin.m_ScanlinesRequested.SetValue(&ScanlineBitArray) )
  78. nStatus = 0;
  79. return nStatus;
  80. }
  81. int
  82. ICCDecode::GetDiscoveredScanlines(VBICODECFILTERING_SCANLINES &ScanlineBitArray )
  83. {
  84. int nStatus = -1;
  85. if ( m_OutputPin.m_ScanlinesDiscovered.GetValue(&ScanlineBitArray) )
  86. {
  87. nStatus = 0;
  88. }
  89. return nStatus;
  90. }
  91. //////////////////////////////////////////////////////////////
  92. // ICCDecode VideoField routines
  93. //////////////////////////////////////////////////////////////
  94. int
  95. ICCDecode::AddRequestedVideoField(int nField)
  96. {
  97. int nStatus = -1;
  98. VBICODECFILTERING_CC_SUBSTREAMS FieldBitArray;
  99. if ( m_OutputPin.m_SubstreamsRequested.GetValue(&FieldBitArray) )
  100. {
  101. DWORD nBitsPerElement = sizeof(FieldBitArray.SubstreamMask)*8;
  102. // Note, fields numbers start with number 1, this is mapped to bit number 0.
  103. FieldBitArray.SubstreamMask |= 1L << ((nField-1) % nBitsPerElement);
  104. if ( m_OutputPin.m_SubstreamsRequested.SetValue(&FieldBitArray) )
  105. nStatus = 0;
  106. }
  107. return nStatus;
  108. }
  109. int
  110. ICCDecode::ClearRequestedVideoFields()
  111. {
  112. int nStatus = -1;
  113. VBICODECFILTERING_CC_SUBSTREAMS FieldBitArray;
  114. ZeroMemory(&FieldBitArray,sizeof(FieldBitArray));
  115. if ( m_OutputPin.m_SubstreamsRequested.SetValue(&FieldBitArray) )
  116. nStatus = 0;
  117. return nStatus;
  118. }
  119. int
  120. ICCDecode::GetDiscoveredVideoFields(VBICODECFILTERING_CC_SUBSTREAMS &bitArray)
  121. {
  122. int nStatus = -1;
  123. if ( m_OutputPin.m_SubstreamsDiscovered.GetValue(&bitArray) )
  124. {
  125. nStatus = 0;
  126. }
  127. return nStatus;
  128. }
  129. //////////////////////////////////////////////////////////////
  130. // Global Statistics Property Control
  131. //////////////////////////////////////////////////////////////
  132. int
  133. ICCDecode::GetCodecStatistics(VBICODECFILTERING_STATISTICS_CC &CodecStatistics)
  134. {
  135. int nStatus = -1;
  136. if ( m_Statistics.GetValue( &CodecStatistics ) )
  137. {
  138. nStatus = 0;
  139. }
  140. return nStatus;
  141. }
  142. int
  143. ICCDecode::SetCodecStatistics(VBICODECFILTERING_STATISTICS_CC &CodecStatistics)
  144. {
  145. int nStatus = -1;
  146. if ( m_Statistics.SetValue( &CodecStatistics ) )
  147. {
  148. nStatus = 0;
  149. }
  150. return nStatus;
  151. }
  152. int
  153. ICCDecode::GetPinStatistics(VBICODECFILTERING_STATISTICS_CC_PIN &PinStatistics)
  154. {
  155. int nStatus = -1;
  156. if ( m_OutputPin.m_Statistics.GetValue( &PinStatistics ) )
  157. {
  158. nStatus = 0;
  159. }
  160. return nStatus;
  161. }
  162. int
  163. ICCDecode::SetPinStatistics(VBICODECFILTERING_STATISTICS_CC_PIN &PinStatistics)
  164. {
  165. int nStatus = -1;
  166. if ( m_OutputPin.m_Statistics.SetValue( &PinStatistics ) )
  167. {
  168. nStatus = 0;
  169. }
  170. return nStatus;
  171. }
  172. //////////////////////////////////////////////////////////////
  173. // Embedded class tests
  174. //////////////////////////////////////////////////////////////
  175. #if defined(_CLASSTESTS)
  176. ICCDecode CCDecode();
  177. #endif
  178. #pragma warning(default:4355)
  179. /*EOF*/