示例#1
0
SampleMap::iterator SampleMap::findSyncSampleAfterPresentationTime(const MediaTime& time, const MediaTime& threshold)
{
    iterator currentSamplePTS = findSampleAfterPresentationTime(time);
    if (currentSamplePTS == presentationEnd())
        return decodeEnd();

    iterator currentSampleDTS = findSampleWithDecodeTime(currentSamplePTS->second->decodeTime());
    
    MediaTime upperBound = time + threshold;
    iterator foundSample = std::find_if(currentSampleDTS, decodeEnd(), SampleIsRandomAccess());
    if (foundSample == decodeEnd())
        return decodeEnd();
    if (foundSample->second->presentationTime() > upperBound)
        return decodeEnd();
    return foundSample;
}
示例#2
0
SampleMap::reverse_iterator SampleMap::reverseFindSampleWithDecodeTime(const MediaTime& time)
{
    SampleMap::iterator found = findSampleWithDecodeTime(time);
    if (found == decodeEnd())
        return reverseDecodeEnd();
    return --reverse_iterator(found);
}
示例#3
0
		Ref<Result> UPCEANReader::decodeRow(int rowNumber, Ref<BitArray> row, int startGuardRange[]){
			
			std::string tmpResultString;
			std::string& tmpResultStringRef = tmpResultString;
			int endStart;
			try {
				endStart = decodeMiddle(row, startGuardRange, 2 /*reference findGuardPattern*/ , tmpResultStringRef);
			} catch (ReaderException re) {
				if (startGuardRange!=NULL) {
					delete [] startGuardRange;
					startGuardRange = NULL;
				}
				throw re;
			}
			
			int* endRange = decodeEnd(row, endStart);
						
#pragma mark QuietZone needs some change
			// Make sure there is a quiet zone at least as big as the end pattern after the barcode. The
			// spec might want more whitespace, but in practice this is the maximum we can count on.
//			int end = endRange[1];
//			int quietEnd = end + (end - endRange[0]);
//			if (quietEnd >= row->getSize() || !row->isRange(end, quietEnd, false)) {
//				throw ReaderException("Quiet zone asserrt fail.");
//			}
			
			if (!checkChecksum(tmpResultString)) {
				if (startGuardRange!=NULL) {
					delete [] startGuardRange;
					startGuardRange = NULL;
				}
				if (endRange!=NULL) {
					delete [] endRange;
					endRange = NULL;
				}
				throw ReaderException("Checksum fail.");
			}
			
			Ref<String> resultString(new String(tmpResultString));
			
			float left = (float) (startGuardRange[1] + startGuardRange[0]) / 2.0f;
			float right = (float) (endRange[1] + endRange[0]) / 2.0f;
			
			std::vector< Ref<ResultPoint> > resultPoints(2);
			Ref<OneDResultPoint> resultPoint1(new OneDResultPoint(left, (float) rowNumber));
			Ref<OneDResultPoint> resultPoint2(new OneDResultPoint(right, (float) rowNumber));
			resultPoints[0] = resultPoint1;
			resultPoints[1] = resultPoint2;
			
			ArrayRef<unsigned char> resultBytes(1);
			
			if (startGuardRange!=NULL) {
				delete [] startGuardRange;
				startGuardRange = NULL;
			}
			if (endRange!=NULL) {
				delete [] endRange;
				endRange = NULL;
			}
			
			Ref<Result> res(new Result(resultString, resultBytes, resultPoints, getBarcodeFormat()));
			return res;
		}
示例#4
0
SampleMap::iterator SampleMap::findSyncSampleAfterDecodeIterator(iterator currentSampleDTS)
{
    return std::find_if(currentSampleDTS, decodeEnd(), SampleIsRandomAccess());
}