//**************** // AddPulldownRef() // AAFRESULT STDMETHODCALLTYPE ImplAAFSourceMob::AddPulldownRef (aafAppendOption_t /* addType !!!*/, const aafRational_t & editrate, aafSlotID_t aMobSlot, ImplAAFDataDef * pEssenceKind, aafSourceRef_t ref, aafLength_t srcRefLength, aafPulldownKind_t pulldownKind, aafPhaseFrame_t phaseFrame, aafPulldownDir_t direction) { ImplAAFSourceClip *sclp = NULL; ImplAAFTimelineMobSlot *trkd = NULL; aafPosition_t zeroPos; aafSlotID_t tmpSlotID; ImplAAFMobSlot * slot = NULL; aafBool isOneToOne; ImplAAFPulldown *pdwn = NULL; ImplAAFSequence * sequence = NULL; ImplAAFDictionary* dict = NULL; aafLength_t outLength, zero; aafInt32 patternLen; AAFRESULT status = AAFRESULT_SUCCESS; aafUInt32 mask; if (! pEssenceKind) return AAFRESULT_NULL_PARAM; XPROTECT() { GetDictionary(&dict); zero = 0; XASSERT(direction == kAAFFilmToTapeSpeed || direction == kAAFTapeToFilmSpeed, AAFRESULT_PULLDOWN_DIRECTION); zeroPos = 0; { CHECK(dict->GetBuiltinDefs()->cdPulldown()-> CreateInstance((ImplAAFObject **)&pdwn)); CHECK(pdwn->SetDataDef(pEssenceKind)); CHECK(pdwn->SetPulldownKind(pulldownKind)); CHECK(pdwn->SetPhaseFrame(phaseFrame)); CHECK(pdwn->SetPulldownDirection(direction)); CHECK(pdwn->aafPvtGetPulldownMask(pulldownKind, &mask, &patternLen, &isOneToOne)); if(isOneToOne) { CHECK(pdwn->SetLength(srcRefLength)); } else { /* Remember, this routine is given the OUTPUT length, and must determine * the input length (so the ratios look backwards) */ CHECK(pdwn->MapOffset(srcRefLength, kAAFTrue, &outLength, NULL)); CHECK(pdwn->SetLength(outLength)); } } /* If the slot exists, and there is a SCLP, extract it so that it can be appended * to the mask or pullown object later */ status = FindSlotBySlotID(aMobSlot, &slot); if (status == AAFRESULT_SUCCESS) { ImplAAFSegment *seg; CHECK(slot->GetSlotID(&tmpSlotID)); CHECK(slot->GetSegment(&seg)); sequence = dynamic_cast<ImplAAFSequence*>(seg); if(sequence != NULL) { aafLength_t foundLen; aafUInt32 numSegments; aafUInt32 n; ImplAAFComponent *subSeg; CHECK(sequence->CountComponents(&numSegments)); if(numSegments == 0) { CHECK(sequence->AppendComponent(pdwn)); CHECK(dict->GetBuiltinDefs()->cdSourceClip()-> CreateInstance((ImplAAFObject **)&sclp)); CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref)); } for(n = 0; n < numSegments; n++) { CHECK(sequence->GetNthComponent (0, &subSeg)); CHECK(subSeg->GetLength(&foundLen)); if(foundLen != zero) { CHECK(sequence->SetNthComponent(n, pdwn)); sclp = dynamic_cast<ImplAAFSourceClip*>(subSeg); break; } subSeg->ReleaseReference(); subSeg = NULL; } } else { CHECK(slot->SetSegment(pdwn)); sclp = dynamic_cast<ImplAAFSourceClip*>(seg); } XASSERT(sclp != NULL, AAFRESULT_NOT_SOURCE_CLIP); CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref)); } else { CHECK(dict->GetBuiltinDefs()->cdSourceClip()-> CreateInstance((ImplAAFObject **)&sclp)); CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref)); CHECK(AppendNewTimelineSlot(editrate, pdwn, aMobSlot, NULL, zeroPos, &trkd) ); } /* Patch the MASK into the file mob if this is a Film Editrate */ /* NOTE: This is assuming that there is a source clip on * the file mob - if it is a nested structure (i.e., SEQU), * this code is not patching the nested elements with the new * editrate and length. */ { if(pdwn != NULL) { CHECK(pdwn->SetInputSegment(sclp)); } } dict->ReleaseReference(); dict = NULL; } /* XPROTECT */ XEXCEPT { if(dict) dict->ReleaseReference(); dict = 0; } XEND; return (AAFRESULT_SUCCESS); }
//**************** // ValidateTimecodeRange() // AAFRESULT STDMETHODCALLTYPE ImplAAFSourceMob::SpecifyValidCodeRange (ImplAAFDataDef * /* pEssenceKind !!!*/, aafSlotID_t slotID, aafRational_t editrate, aafFrameOffset_t startOffset, aafFrameLength_t length64) { ImplAAFSourceClip *sclp = NULL; ImplAAFTimecode *timecodeClip = NULL; ImplAAFSequence * aSequ = NULL, *segSequ = NULL; ImplAAFFiller * filler1 = NULL, *filler2 = NULL; ImplAAFSegment * seg = NULL; ImplAAFComponent * subSegment = NULL; ImplAAFDictionary * pDict = NULL; aafPosition_t pos, zeroPos, sequPos, begPos, endPos; aafLength_t length, zeroLen, tcLen, endFillLen, firstFillLen, oldFillLen, segLen; aafLength_t tcSlotLen, sequLen; aafSourceRef_t sourceRef; ImplAAFTimelineMobSlot *newSlot, *slot; aafFrameOffset_t tcStartPos; aafTimecode_t timecode; aafUInt32 sequLoop; aafUInt32 numSegs; ImplEnumAAFComponents *sequIter = NULL; XPROTECT() { CHECK(FindTimecodeClip(startOffset, &timecodeClip, &tcStartPos, &tcSlotLen)); CHECK(timecodeClip->GetLength(&tcLen)); CHECK(timecodeClip->GetTimecode(&timecode)); if(length64 == FULL_LENGTH) { CHECK(PvtTimecodeToOffset(timecode.fps, 24, 0, 0, 0, timecode.drop, &length64)); } length = length64; zeroLen = 0; pos = startOffset; zeroPos = 0; endFillLen = tcSlotLen; endFillLen -= pos; endFillLen -= length; memset(&sourceRef, 0, sizeof(sourceRef)); CHECK(GetDictionary(&pDict)); CHECK(pDict->GetBuiltinDefs()->cdSourceClip()-> CreateInstance((ImplAAFObject **)&sclp)); if(FindSlotBySlotID(slotID, (ImplAAFMobSlot **)&slot) != AAFRESULT_SUCCESS) { CHECK(pDict->GetBuiltinDefs()->cdSequence()-> CreateInstance((ImplAAFObject **)&aSequ)); CHECK(pDict->GetBuiltinDefs()->cdFiller()-> CreateInstance((ImplAAFObject **)&filler1)); if(aSequ == NULL || filler1 == NULL) RAISE(E_FAIL); CHECK(aSequ->AppendComponent(filler1)); CHECK(aSequ->AppendComponent(sclp)); CHECK(pDict->GetBuiltinDefs()->cdFiller()-> CreateInstance((ImplAAFObject **)&filler2)); CHECK(aSequ->AppendComponent(filler2)); /* (SPR#343) Change to validate multiple ranges */ CHECK(AppendNewTimelineSlot(editrate, aSequ, slotID, NULL, zeroPos, &newSlot)); } else { CHECK(slot->GetSegment(&seg)); CHECK(seg->GenerateSequence(&segSequ)); CHECK(segSequ->GetComponents(&sequIter)); CHECK(segSequ->CountComponents(&numSegs)); for (sequLoop=0, sequPos = 0; sequLoop < numSegs; sequLoop++, sequPos += segLen) { CHECK(sequIter->NextOne(&subSegment)); CHECK(subSegment->GetLength(&segLen)); /* Skip zero-length clips, sometimes found in MC files */ if (segLen == zeroLen) continue; begPos = sequPos; endPos = sequPos + segLen; if (pos < endPos && begPos <= pos) { ImplAAFFiller *test; // Used only in test of type test = dynamic_cast<ImplAAFFiller*>(subSegment); if(test != NULL && (sequLoop == (numSegs-1))) { firstFillLen = pos; firstFillLen -= sequPos; CHECK(subSegment->GetLength(&oldFillLen)); endFillLen = oldFillLen; endFillLen -= length; endFillLen -= firstFillLen; /****/ CHECK(subSegment->SetLength(firstFillLen)); /* 1.x does not have a Sequence Length property */ CHECK(segSequ->GetLength(&sequLen)); sequLen -= oldFillLen; sequLen += firstFillLen; CHECK(segSequ->SetLength(sequLen)); CHECK(pDict->GetBuiltinDefs()->cdFiller()-> CreateInstance((ImplAAFObject **)&filler2)); //!!! filler2 = CreateImpl(CLSID_AAFFiller(_file, mediaKind, endFillLen); CHECK(segSequ->AppendComponent(sclp)); CHECK(segSequ->AppendComponent(filler2)); break; } else RAISE(AAFRESULT_NOT_IN_CURRENT_VERSION); } } /* for */ sequIter->ReleaseReference(); sequIter = NULL; //!!! /* Release reference, so the useCount is decremented */ // if (subSegment) // { // subSegment->ReleaseObject(); // subSegment = NULL; // } } if(aSequ!= NULL) { aSequ->ReleaseReference(); aSequ = NULL; } if(segSequ!= NULL) { segSequ->ReleaseReference(); segSequ = NULL; } if(filler1!= NULL) { filler1->ReleaseReference(); filler1 = NULL; } if(filler2!= NULL) { filler2->ReleaseReference(); filler2 = NULL; } if(seg!= NULL) { seg->ReleaseReference(); seg = NULL; } if(subSegment!= NULL) { subSegment->ReleaseReference(); subSegment = NULL; } if(pDict!= NULL) { pDict->ReleaseReference(); pDict = NULL; } if(sclp!= NULL) { sclp->ReleaseReference(); sclp = NULL; } if(timecodeClip!= NULL) { timecodeClip->ReleaseReference(); timecodeClip = NULL; } } XEXCEPT { if(aSequ!= NULL) aSequ->ReleaseReference(); aSequ = 0; if(segSequ!= NULL) segSequ->ReleaseReference(); segSequ = 0; if(filler1!= NULL) filler1->ReleaseReference(); filler1 = 0; if(filler2!= NULL) filler2->ReleaseReference(); filler2 = 0; if(seg!= NULL) seg->ReleaseReference(); seg = 0; if(subSegment!= NULL) subSegment->ReleaseReference(); subSegment = 0; if(pDict!= NULL) pDict->ReleaseReference(); pDict = 0; if(sclp!= NULL) sclp->ReleaseReference(); sclp = 0; if(timecodeClip!= NULL) timecodeClip->ReleaseReference(); timecodeClip = 0; } XEND; return (AAFRESULT_SUCCESS); }