00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "stdafx.h"
00033
00034 #include "TheoraDecodeFilter.h"
00035
00036
00037
00038
00039 CFactoryTemplate g_Templates[] =
00040 {
00041 {
00042 L"Theora Decode Filter",
00043 &CLSID_TheoraDecodeFilter,
00044 TheoraDecodeFilter::CreateInstance,
00045 NULL,
00046 NULL
00047 }
00048
00049 };
00050
00051
00052 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
00053
00054
00055
00056 TheoraDecodeFilter::TheoraDecodeFilter()
00057 : CTransformFilter( NAME("Theora Decode Filter"), NULL, CLSID_TheoraDecodeFilter)
00058 , mHeight(0)
00059 , mWidth(0)
00060 , mFrameSize(0)
00061 , mFrameCount(0)
00062 , mYOffset(0)
00063 , mXOffset(0)
00064 , mFrameDuration(0)
00065 , mBegun(false)
00066 , mSeekTimeBase(0)
00067 , mLastSeenStartGranPos(0)
00068
00069 , mSegStart(0)
00070 , mSegEnd(0)
00071 , mPlaybackRate(0.0)
00072 , mTheoraFormatInfo(NULL)
00073 {
00074 #ifdef OGGCODECS_LOGGING
00075 debugLog.open("G:\\logs\\newtheofilter.log", ios_base::out);
00076 #endif
00077 mTheoraDecoder = new TheoraDecoder;
00078 mTheoraDecoder->initCodec();
00079
00080 }
00081
00082 TheoraDecodeFilter::~TheoraDecodeFilter() {
00083 delete mTheoraDecoder;
00084 mTheoraDecoder = NULL;
00085
00086 delete mTheoraFormatInfo;
00087 mTheoraFormatInfo = NULL;
00088 debugLog.close();
00089
00090 }
00091
00092 CUnknown* WINAPI TheoraDecodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
00093 {
00094
00095 TheoraDecodeFilter *pNewObject = new TheoraDecodeFilter();
00096 if (pNewObject == NULL) {
00097 *pHr = E_OUTOFMEMORY;
00098 }
00099 return pNewObject;
00100 }
00101 void TheoraDecodeFilter::FillMediaType(CMediaType* outMediaType, unsigned long inSampleSize) {
00102 outMediaType->SetType(&MEDIATYPE_Video);
00103 outMediaType->SetSubtype(&MEDIASUBTYPE_YV12);
00104 outMediaType->SetFormatType(&FORMAT_VideoInfo);
00105 outMediaType->SetTemporalCompression(FALSE);
00106 outMediaType->SetSampleSize(inSampleSize);
00107
00108 }
00109 bool TheoraDecodeFilter::FillVideoInfoHeader(VIDEOINFOHEADER* inFormatBuffer) {
00110 TheoraDecodeFilter* locFilter = this;
00111
00112 inFormatBuffer->AvgTimePerFrame = (UNITS * locFilter->mTheoraFormatInfo->frameRateDenominator) / locFilter->mTheoraFormatInfo->frameRateNumerator;
00113 inFormatBuffer->dwBitRate = locFilter->mTheoraFormatInfo->targetBitrate;
00114
00115 inFormatBuffer->bmiHeader.biBitCount = 12;
00116 inFormatBuffer->bmiHeader.biClrImportant = 0;
00117 inFormatBuffer->bmiHeader.biClrUsed = 0;
00118 inFormatBuffer->bmiHeader.biCompression = MAKEFOURCC('Y','V','1','2');
00119 inFormatBuffer->bmiHeader.biHeight = locFilter->mTheoraFormatInfo->pictureHeight;
00120 inFormatBuffer->bmiHeader.biPlanes = 1;
00121 inFormatBuffer->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
00122 inFormatBuffer->bmiHeader.biSizeImage = ((locFilter->mTheoraFormatInfo->pictureHeight * locFilter->mTheoraFormatInfo->pictureWidth) * 3)/2;
00123 inFormatBuffer->bmiHeader.biWidth = locFilter->mTheoraFormatInfo->pictureWidth;
00124 inFormatBuffer->bmiHeader.biXPelsPerMeter = 2000;
00125 inFormatBuffer->bmiHeader.biYPelsPerMeter = 2000;
00126
00127 inFormatBuffer->rcSource.top = 0;
00128 inFormatBuffer->rcSource.bottom = locFilter->mTheoraFormatInfo->pictureHeight;
00129 inFormatBuffer->rcSource.left = 0;
00130 inFormatBuffer->rcSource.right = locFilter->mTheoraFormatInfo->pictureWidth;
00131
00132 inFormatBuffer->rcTarget.top = 0;
00133 inFormatBuffer->rcTarget.bottom = locFilter->mTheoraFormatInfo->pictureHeight;
00134 inFormatBuffer->rcTarget.left = 0;
00135 inFormatBuffer->rcTarget.right = locFilter->mTheoraFormatInfo->pictureWidth;
00136
00137 inFormatBuffer->dwBitErrorRate=0;
00138 return true;
00139 }
00140
00141 HRESULT TheoraDecodeFilter::CheckInputType(const CMediaType* inMediaType)
00142 {
00143
00144
00145 if ( (inMediaType->majortype == MEDIATYPE_OggPacketStream) &&
00146 (inMediaType->subtype == MEDIASUBTYPE_None) && (inMediaType->formattype == FORMAT_OggIdentHeader)
00147 )
00148 {
00149 if (inMediaType->cbFormat == THEORA_IDENT_HEADER_SIZE) {
00150 if (strncmp((char*)inMediaType->pbFormat, "\200theora", 7) == 0) {
00151
00152 return S_OK;
00153 }
00154 }
00155
00156 }
00157 return S_FALSE;
00158
00159 }
00160 HRESULT TheoraDecodeFilter::CheckTransform(const CMediaType* inInputMediaType, const CMediaType* inOutputMediaType) {
00161 if ((CheckInputType(inInputMediaType) == S_OK) &&
00162 ((inOutputMediaType->majortype == MEDIATYPE_Video) && (inOutputMediaType->subtype == MEDIASUBTYPE_YV12) && (inOutputMediaType->formattype == FORMAT_VideoInfo)
00163 )) {
00164 VIDEOINFOHEADER* locVideoHeader = (VIDEOINFOHEADER*)inOutputMediaType->Format();
00165
00166
00167
00168 mHeight = (unsigned long)abs(locVideoHeader->bmiHeader.biHeight);
00169 mWidth = (unsigned long)abs(locVideoHeader->bmiHeader.biWidth);
00170 return S_OK;
00171
00172
00173
00174 } else {
00175 return S_FALSE;
00176 }
00177 }
00178 HRESULT TheoraDecodeFilter::DecideBufferSize(IMemAllocator* inAllocator, ALLOCATOR_PROPERTIES* inPropertyRequest) {
00179
00180
00181
00182
00183
00184
00185 HRESULT locHR = S_OK;
00186
00187
00188 ALLOCATOR_PROPERTIES locReqAlloc;
00189 ALLOCATOR_PROPERTIES locActualAlloc;
00190
00191
00192
00193
00194
00195
00196
00197
00198 const unsigned long MIN_BUFFER_SIZE = 16*16;
00199 const unsigned long DEFAULT_BUFFER_SIZE = 1024*1024 * 2;
00200 const unsigned long MIN_NUM_BUFFERS = 1;
00201 const unsigned long DEFAULT_NUM_BUFFERS = 1;
00202
00203
00204
00205
00206 if (inPropertyRequest->cbAlign <= 0) {
00207 locReqAlloc.cbAlign = 1;
00208 } else {
00209 locReqAlloc.cbAlign = inPropertyRequest->cbAlign;
00210 }
00211
00212
00213 if (inPropertyRequest->cbBuffer < MIN_BUFFER_SIZE) {
00214 locReqAlloc.cbBuffer = DEFAULT_BUFFER_SIZE;
00215 } else {
00216 locReqAlloc.cbBuffer = inPropertyRequest->cbBuffer;
00217 }
00218
00219
00220 if (inPropertyRequest->cbPrefix < 0) {
00221 locReqAlloc.cbPrefix = 0;
00222 } else {
00223 locReqAlloc.cbPrefix = inPropertyRequest->cbPrefix;
00224 }
00225
00226
00227 if (inPropertyRequest->cBuffers < MIN_NUM_BUFFERS) {
00228 locReqAlloc.cBuffers = DEFAULT_NUM_BUFFERS;
00229 } else {
00230
00231 locReqAlloc.cBuffers = inPropertyRequest->cBuffers;
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 locHR = inAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 switch (locHR) {
00253 case E_POINTER:
00254
00255 return locHR;
00256
00257
00258 case VFW_E_ALREADY_COMMITTED:
00259
00260 return locHR;
00261
00262 case VFW_E_BADALIGN:
00263
00264 return locHR;
00265
00266 case VFW_E_BUFFERS_OUTSTANDING:
00267
00268 return locHR;
00269
00270
00271 case S_OK:
00272
00273 break;
00274 default:
00275
00276 break;
00277
00278 }
00279
00280
00281
00282
00283
00284 locHR = inAllocator->Commit();
00285
00286
00287
00288 switch (locHR) {
00289 case E_FAIL:
00290
00291 return locHR;
00292 case E_POINTER:
00293
00294 return locHR;
00295 case E_INVALIDARG:
00296
00297 return locHR;
00298 case E_NOTIMPL:
00299
00300 return locHR;
00301 case S_OK:
00302
00303 break;
00304 default:
00305
00306 return locHR;
00307 }
00308
00309
00310 return S_OK;
00311 }
00312 HRESULT TheoraDecodeFilter::GetMediaType(int inPosition, CMediaType* outOutputMediaType) {
00313 if (inPosition < 0) {
00314 return E_INVALIDARG;
00315 }
00316
00317 if (inPosition == 0) {
00318
00319 VIDEOINFOHEADER* locVideoFormat = (VIDEOINFOHEADER*)outOutputMediaType->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
00320 FillVideoInfoHeader(locVideoFormat);
00321 FillMediaType(outOutputMediaType, locVideoFormat->bmiHeader.biSizeImage);
00322
00323
00324
00325 return S_OK;
00326 } else {
00327 return VFW_S_NO_MORE_ITEMS;
00328 }
00329 }
00330
00331 void TheoraDecodeFilter::ResetFrameCount()
00332 {
00333
00334 mFrameCount = 0;
00335
00336 }
00337
00338 HRESULT TheoraDecodeFilter::NewSegment(REFERENCE_TIME inStart, REFERENCE_TIME inEnd, double inRate)
00339 {
00340 debugLog<<"Resetting frame count"<<endl;
00341 ResetFrameCount();
00342 mSegStart = inStart;
00343 mSegEnd = inEnd;
00344 mPlaybackRate = inRate;
00345 return CTransformFilter::NewSegment(inStart, inEnd, inRate);
00346
00347 }
00348
00349 HRESULT TheoraDecodeFilter::Receive(IMediaSample* inInputSample)
00350 {
00351
00352
00353 BYTE* locBuff = NULL;
00354
00355 HRESULT locHR = inInputSample->GetPointer(&locBuff);
00356
00357 if (locHR != S_OK) {
00358
00359 return S_FALSE;
00360 } else {
00361
00362 if ((inInputSample->GetActualDataLength() > 0) && ((locBuff[0] & 128) != 0)) {
00363
00364
00365
00366 return S_OK;
00367 }
00368
00369 BYTE* locNewBuff = new unsigned char[inInputSample->GetActualDataLength()];
00370 memcpy((void*)locNewBuff, (const void*)locBuff, inInputSample->GetActualDataLength());
00371
00372
00373 REFERENCE_TIME locStart = 0;
00374 REFERENCE_TIME locEnd = 0;
00375 inInputSample->GetTime(&locStart, &locEnd);
00376
00377 debugLog<<"Theora::Receive - Sample: Size = "<<inInputSample->GetActualDataLength()<<" Time: "<<locStart<<" - "<<locEnd<<endl;
00378
00379
00380 StampedOggPacket* locPacket = new StampedOggPacket(locNewBuff, inInputSample->GetActualDataLength(), false, false, locStart, locEnd, StampedOggPacket::OGG_END_ONLY);
00381
00382
00383 mBufferedPackets.push_back(locPacket);
00384
00385 if (locEnd < 0) {
00386
00387
00388 return S_OK;
00389 } else {
00390
00391 TheoraDecodeInputPin* locInputPin = (TheoraDecodeInputPin*)m_pInput;
00392 REFERENCE_TIME locGlobalEnd = locInputPin->convertGranuleToTime(locEnd);
00393 unsigned long locNumBufferedFrames = mBufferedPackets.size();
00394 REFERENCE_TIME locGlobalStart = locGlobalEnd - (locNumBufferedFrames * mFrameDuration);
00395
00396 locStart = locGlobalStart;
00397
00398
00399
00400 REFERENCE_TIME locGlobalOffset = 0;
00401
00402 if (!locInputPin->getSentStreamOffset() && (locInputPin->getOutputPinInterface() != NULL)) {
00403 locInputPin->getOutputPinInterface()->notifyStreamBaseTime(locStart);
00404 locInputPin->setSentStreamOffset(true);
00405
00406 }
00407
00408 if (locInputPin->getOutputPinInterface() != NULL) {
00409 locGlobalOffset = locInputPin->getOutputPinInterface()->getGlobalBaseTime();
00410 }
00411
00412 debugLog<<"Theora::Receive - "<<locNumBufferedFrames<<" frames buffered"<<endl;
00413 for (unsigned long i = 0; i < locNumBufferedFrames; i++) {
00414 debugLog<<"Theora::Receive - Processing buffered frame "<<i<<endl;
00415 bool locIsKeyFrame = mTheoraDecoder->isKeyFrame(mBufferedPackets[i]);
00416 yuv_buffer* locYUV = mTheoraDecoder->decodeTheora(mBufferedPackets[i]);
00417 locEnd = locStart + mFrameDuration;
00418 REFERENCE_TIME locAdjustedStart = locStart - mSegStart - locGlobalOffset;
00419 REFERENCE_TIME locAdjustedEnd = locEnd - mSegStart - locGlobalOffset;
00420
00421 if (locAdjustedStart < 0) {
00422 locAdjustedStart = 0;
00423 }
00424
00425 if (locAdjustedEnd >= 0) {
00426 if (locYUV != NULL) {
00427 IMediaSample* locOutSample = NULL;
00428 debugLog<<"Theora::Receive - Pre output sample initialisation"<<endl;
00429 locHR = InitializeOutputSample(inInputSample, &locOutSample);
00430 if (locHR != S_OK) {
00431
00432 debugLog<<"Theora::Receive - Output sample initialisation failed"<<endl;
00433
00434 deleteBufferedPacketsAfter(i);
00435
00436 return S_FALSE;
00437 }
00438 debugLog<<"Theora::Receive - Output sample initialisation suceeded"<<endl;
00439
00440
00441
00442
00443
00444
00445 if (TheoraDecoded(locYUV, locOutSample, locIsKeyFrame, locAdjustedStart, locAdjustedEnd) != S_OK) {
00446
00447
00448 locOutSample->Release();
00449 deleteBufferedPacketsAfter(i);
00450 return S_FALSE;
00451 } else {
00452
00453 debugLog<<"Theora::Receive - Delivering: "<<locAdjustedStart<<" to "<<locAdjustedEnd<<(locIsKeyFrame ? "KEYFRAME": " ")<<endl;
00454
00455 locHR = m_pOutput->Deliver(locOutSample);
00456 locOutSample->Release();
00457 debugLog<<"Theora::Receive - Post delivery"<<endl;
00458 if (locHR != S_OK) {
00459
00460 debugLog<<"Theora::Receive - Delivery failed"<<endl;
00461 locOutSample->Release();
00462 deleteBufferedPacketsAfter(i);
00463 return S_FALSE;
00464 }
00465 debugLog<<"Theora::Receive - Delivery Suceeded"<<endl;
00466
00467 }
00468 } else {
00469
00470 deleteBufferedPacketsAfter(i);
00471 return S_FALSE;
00472 }
00473 }
00474 locStart = locEnd;
00475 }
00476
00477 mBufferedPackets.clear();
00478
00479
00480
00481 return S_OK;
00482
00483 }
00484
00485 }
00486 }
00487
00488 void TheoraDecodeFilter::deleteBufferedPacketsAfter(unsigned long inPacketIndex)
00489 {
00490 for (size_t i = inPacketIndex + 1; i < mBufferedPackets.size(); i++) {
00491 delete mBufferedPackets[i];
00492 }
00493
00494 mBufferedPackets.clear();
00495 }
00496 HRESULT TheoraDecodeFilter::Transform(IMediaSample* inInputSample, IMediaSample* outOutputSample)
00497 {
00498
00499
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00570
00571
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640 debugLog<<"Theora::Transform NOT IMPLEMENTED"<<endl;
00641
00642 return E_NOTIMPL;
00643
00644 }
00645
00646 HRESULT TheoraDecodeFilter::TheoraDecoded (yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd)
00647 {
00648
00650 BYTE* locBuffer = NULL;
00651
00652
00654 outSample->GetPointer(&locBuffer);
00655
00656
00657
00658
00659 REFERENCE_TIME locStart = inStart;
00660 REFERENCE_TIME locEnd = inEnd;
00661
00662
00663
00664 unsigned char* locDestUptoPtr = locBuffer;
00665 char* locSourceUptoPtr = inYUVBuffer->y;
00666
00667
00668 long locYStride = inYUVBuffer->y_stride;
00669 long locUVStride = inYUVBuffer->uv_stride;
00670
00671
00672
00673
00674
00675
00676
00677
00678 long locTopPad = inYUVBuffer->y_height - mHeight - mYOffset;
00679
00680
00681
00682
00683 if (locTopPad < 0) {
00684 locTopPad = 0;
00685 } else {
00686
00687 }
00688
00689
00690 locSourceUptoPtr += (mYOffset * locYStride);
00691
00692 for (unsigned long line = 0; line < mHeight; line++) {
00693 memcpy((void*)(locDestUptoPtr), (const void*)(locSourceUptoPtr + mXOffset), mWidth);
00694 locSourceUptoPtr += locYStride;
00695 locDestUptoPtr += mWidth;
00696 }
00697
00698 locSourceUptoPtr += (locTopPad * locYStride);
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710 locTopPad = locTopPad /2;
00711
00712 locSourceUptoPtr = inYUVBuffer->v;
00713
00714
00715 locSourceUptoPtr += ((mYOffset/2) * locYStride);
00716
00717 for (unsigned long line = 0; line < mHeight / 2; line++) {
00718 memcpy((void*)(locDestUptoPtr), (const void*)(locSourceUptoPtr + (mXOffset / 2)), mWidth / 2);
00719 locSourceUptoPtr += locUVStride;
00720 locDestUptoPtr += (mWidth / 2);
00721 }
00722 locSourceUptoPtr += (locTopPad * locUVStride);
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 locSourceUptoPtr = inYUVBuffer->u;
00737
00738
00739 locSourceUptoPtr += ((mYOffset/2) * locYStride);
00740
00741 for (unsigned long line = 0; line < mHeight / 2; line++) {
00742 memcpy((void*)(locDestUptoPtr), (const void*)(locSourceUptoPtr + (mXOffset / 2)), mWidth / 2);
00743 locSourceUptoPtr += locUVStride;
00744 locDestUptoPtr += (mWidth / 2);
00745 }
00746 locSourceUptoPtr += (locTopPad * locUVStride);
00747
00748
00749
00750
00751
00752
00753 BOOL locIsKeyFrame = FALSE;
00754 if (inIsKeyFrame) {
00755 locIsKeyFrame = TRUE;
00756 };
00757 SetSampleParams(outSample, mFrameSize, &locStart, &locEnd, locIsKeyFrame);
00758
00759
00760
00761 return S_OK;
00762
00763
00764 }
00765
00766
00767 HRESULT TheoraDecodeFilter::SetMediaType(PIN_DIRECTION inDirection, const CMediaType* inMediaType) {
00768
00769 if (inDirection == PINDIR_INPUT) {
00770 if (CheckInputType(inMediaType) == S_OK) {
00771
00772 setTheoraFormat(inMediaType->pbFormat);
00773
00774
00775 mXOffset = mTheoraFormatInfo->xOffset;
00776 mYOffset = mTheoraFormatInfo->xOffset;
00777
00778
00779 mFrameDuration = (UNITS * mTheoraFormatInfo->frameRateDenominator) / (mTheoraFormatInfo->frameRateNumerator);
00780
00781 mFrameSize = (mHeight * mWidth * 3) / 2;
00782 mFrameCount = 0;
00783 } else {
00784
00785 throw 0;
00786 }
00787 return CTransformFilter::SetMediaType(PINDIR_INPUT, inMediaType);
00788 } else {
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800 return CTransformFilter::SetMediaType(PINDIR_OUTPUT, inMediaType);
00801 }
00802 }
00803
00804
00805 bool TheoraDecodeFilter::SetSampleParams(IMediaSample* outMediaSample, unsigned long inDataSize, REFERENCE_TIME* inStartTime, REFERENCE_TIME* inEndTime, BOOL inIsSync)
00806 {
00807 outMediaSample->SetTime(inStartTime, inEndTime);
00808 outMediaSample->SetMediaTime(NULL, NULL);
00809 outMediaSample->SetActualDataLength(inDataSize);
00810 outMediaSample->SetPreroll(FALSE);
00811 outMediaSample->SetDiscontinuity(FALSE);
00812 outMediaSample->SetSyncPoint(inIsSync);
00813 return true;
00814 }
00815
00816
00817
00818
00819
00820
00821 sTheoraFormatBlock* TheoraDecodeFilter::getTheoraFormatBlock()
00822 {
00823 return mTheoraFormatInfo;
00824 }
00825 void TheoraDecodeFilter::setTheoraFormat(BYTE* inFormatBlock)
00826 {
00827
00828 delete mTheoraFormatInfo;
00829 mTheoraFormatInfo = new sTheoraFormatBlock;
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850 unsigned char* locIdentHeader = inFormatBlock;
00851 mTheoraFormatInfo->theoraVersion = (iBE_Math::charArrToULong(locIdentHeader + 7)) >>8;
00852 mTheoraFormatInfo->outerFrameWidth = (iBE_Math::charArrToUShort(locIdentHeader + 10)) * 16;
00853 mTheoraFormatInfo->outerFrameHeight = (iBE_Math::charArrToUShort(locIdentHeader + 12)) * 16;
00854 mTheoraFormatInfo->pictureWidth = (iBE_Math::charArrToULong(locIdentHeader + 14)) >>8;
00855 mTheoraFormatInfo->pictureHeight = (iBE_Math::charArrToULong(locIdentHeader + 17)) >>8;
00856 mTheoraFormatInfo->xOffset = locIdentHeader[20];
00857 mTheoraFormatInfo->yOffset = locIdentHeader[21];
00858 mTheoraFormatInfo->frameRateNumerator = iBE_Math::charArrToULong(locIdentHeader + 22);
00859 mTheoraFormatInfo->frameRateDenominator = iBE_Math::charArrToULong(locIdentHeader + 26);
00860 mTheoraFormatInfo->aspectNumerator = (iBE_Math::charArrToULong(locIdentHeader + 30)) >>8;
00861 mTheoraFormatInfo->aspectDenominator = (iBE_Math::charArrToULong(locIdentHeader + 33)) >>8;
00862 mTheoraFormatInfo->colourSpace = locIdentHeader[36];
00863 mTheoraFormatInfo->targetBitrate = (iBE_Math::charArrToULong(locIdentHeader + 37)) >>8;
00864 mTheoraFormatInfo->targetQuality = (locIdentHeader[40]) >> 2;
00865
00866 mTheoraFormatInfo->maxKeyframeInterval= (((locIdentHeader[40]) % 4) << 3) + (locIdentHeader[41] >> 5);
00867 }
00868
00869 CBasePin* TheoraDecodeFilter::GetPin(int inPinNo)
00870 {
00871 HRESULT locHR = S_OK;
00872
00873
00874
00875 if (m_pInput == NULL) {
00876
00877 m_pInput = new TheoraDecodeInputPin(this, &locHR);
00878
00879
00880 if (m_pInput == NULL) {
00881 return NULL;
00882 }
00883 m_pOutput = new TheoraDecodeOutputPin(this, &locHR);
00884
00885
00886 if (m_pOutput == NULL) {
00887 delete m_pInput;
00888 m_pInput = NULL;
00889 }
00890 }
00891
00892
00893
00894 if (inPinNo == 0) {
00895 return m_pInput;
00896 } else if (inPinNo == 1) {
00897 return m_pOutput;
00898 } else {
00899 return NULL;
00900 }
00901 }