本文整理汇总了C++中sp::data方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::data方法的具体用法?C++ sp::data怎么用?C++ sp::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reassembleAVCC
static size_t reassembleAVCC(const sp<ABuffer> &csd0, const sp<ABuffer> csd1, char *avcc) {
avcc[0] = 1; // version
avcc[1] = 0x64; // profile
avcc[2] = 0; // unused (?)
avcc[3] = 0xd; // level
avcc[4] = 0xff; // reserved+size
size_t i = 0;
int numparams = 0;
int lastparamoffset = 0;
int avccidx = 6;
do {
if (i >= csd0->size() - 4 ||
memcmp(csd0->data() + i, "\x00\x00\x00\x01", 4) == 0) {
if (i >= csd0->size() - 4) {
// there can't be another param here, so use all the rest
i = csd0->size();
}
ALOGV("block at %d, last was %d", i, lastparamoffset);
if (lastparamoffset > 0) {
int size = i - lastparamoffset;
avcc[avccidx++] = size >> 8;
avcc[avccidx++] = size & 0xff;
memcpy(avcc+avccidx, csd0->data() + lastparamoffset, size);
avccidx += size;
numparams++;
}
i += 4;
lastparamoffset = i;
} else {
i++;
}
} while(i < csd0->size());
示例2: processBuffers
status_t SaturationFilter::processBuffers(
const sp<ABuffer> &srcBuffer, const sp<ABuffer> &outBuffer) {
mAllocIn->copy1DRangeFrom(0, mWidth * mHeight, srcBuffer->data());
mScript->forEach_root(mAllocIn, mAllocOut);
mAllocOut->copy1DRangeTo(0, mWidth * mHeight, outBuffer->data());
return OK;
}
示例3: ALOGE
void AH263Assembler::insertPacket(const sp<ABuffer> &buffer){
size_t skip;
if ((skip = getOffsetOfHeader(buffer)) == 1){
ALOGE("Malformed packet in insertPacket");
return;
}
buffer->setRange(buffer->offset() + skip, buffer->size() - skip);
if (skip == 0) {
buffer->data()[0] = 0x00;
buffer->data()[1] = 0x00;
}
uint32_t seqNum = (uint32_t)buffer->int32Data();
List<sp<ABuffer> >::iterator it = mPackets.begin();
while (it != mPackets.end() && (uint32_t)(*it)->int32Data() < seqNum){
++it;
}
if (it != mPackets.end() && (uint32_t)(*it)->int32Data() == seqNum) {
ALOGE("Discarding duplicate buffer in mPackets");
return;
}
ALOGV("insert the buffer into the current packets");
mPackets.insert(it, buffer);
}
示例4: IsAVCReferenceFrame
bool IsAVCReferenceFrame(const sp<ABuffer> &accessUnit) {
const uint8_t *data = accessUnit->data();
size_t size = accessUnit->size();
if (data == NULL) {
ALOGE("IsAVCReferenceFrame: called on NULL data (%p, %zu)", accessUnit.get(), size);
return false;
}
const uint8_t *nalStart;
size_t nalSize;
while (getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) {
if (nalSize == 0) {
ALOGE("IsAVCReferenceFrame: invalid nalSize: 0 (%p, %zu)", accessUnit.get(), size);
return false;
}
unsigned nalType = nalStart[0] & 0x1f;
if (nalType == 5) {
return true;
} else if (nalType == 1) {
unsigned nal_ref_idc = (nalStart[0] >> 5) & 3;
return nal_ref_idc != 0;
}
}
示例5: MakeMPEGVideoESDS
static sp<ABuffer> MakeMPEGVideoESDS(const sp<ABuffer> &csd) {
sp<ABuffer> esds = new ABuffer(csd->size() + 25);
uint8_t *ptr = esds->data();
*ptr++ = 0x03;
EncodeSize14(&ptr, 22 + csd->size());
*ptr++ = 0x00; // ES_ID
*ptr++ = 0x00;
*ptr++ = 0x00; // streamDependenceFlag, URL_Flag, OCRstreamFlag
*ptr++ = 0x04;
EncodeSize14(&ptr, 16 + csd->size());
*ptr++ = 0x40; // Audio ISO/IEC 14496-3
for (size_t i = 0; i < 12; ++i) {
*ptr++ = 0x00;
}
*ptr++ = 0x05;
EncodeSize14(&ptr, csd->size());
memcpy(ptr, csd->data(), csd->size());
return esds;
}
示例6: ABuffer
sp<ABuffer> NuPlayer::DecoderPassThrough::aggregateBuffer(
const sp<ABuffer> &accessUnit) {
sp<ABuffer> aggregate;
if (accessUnit == NULL) {
// accessUnit is saved to mPendingAudioAccessUnit
// return current mAggregateBuffer
aggregate = mAggregateBuffer;
mAggregateBuffer.clear();
return aggregate;
}
size_t smallSize = accessUnit->size();
if ((mAggregateBuffer == NULL)
// Don't bother if only room for a few small buffers.
&& (smallSize < (kAggregateBufferSizeBytes / 3))) {
// Create a larger buffer for combining smaller buffers from the extractor.
mAggregateBuffer = new ABuffer(kAggregateBufferSizeBytes);
mAggregateBuffer->setRange(0, 0); // start empty
}
if (mAggregateBuffer != NULL) {
int64_t timeUs;
int64_t dummy;
bool smallTimestampValid = accessUnit->meta()->findInt64("timeUs", &timeUs);
bool bigTimestampValid = mAggregateBuffer->meta()->findInt64("timeUs", &dummy);
// Will the smaller buffer fit?
size_t bigSize = mAggregateBuffer->size();
size_t roomLeft = mAggregateBuffer->capacity() - bigSize;
// Should we save this small buffer for the next big buffer?
// If the first small buffer did not have a timestamp then save
// any buffer that does have a timestamp until the next big buffer.
if ((smallSize > roomLeft)
|| (!bigTimestampValid && (bigSize > 0) && smallTimestampValid)) {
mPendingAudioErr = OK;
mPendingAudioAccessUnit = accessUnit;
aggregate = mAggregateBuffer;
mAggregateBuffer.clear();
} else {
// Grab time from first small buffer if available.
if ((bigSize == 0) && smallTimestampValid) {
mAggregateBuffer->meta()->setInt64("timeUs", timeUs);
}
// Append small buffer to the bigger buffer.
memcpy(mAggregateBuffer->base() + bigSize, accessUnit->data(), smallSize);
bigSize += smallSize;
mAggregateBuffer->setRange(0, bigSize);
ALOGV("feedDecoderInputData() smallSize = %zu, bigSize = %zu, capacity = %zu",
smallSize, bigSize, mAggregateBuffer->capacity());
}
} else {
// decided not to aggregate
aggregate = accessUnit;
}
return aggregate;
}
示例7: readSampleData
status_t NuMediaExtractor::readSampleData(const sp<ABuffer> &buffer) {
Mutex::Autolock autoLock(mLock);
ssize_t minIndex = fetchTrackSamples();
if (minIndex < 0) {
return ERROR_END_OF_STREAM;
}
TrackInfo *info = &mSelectedTracks.editItemAt(minIndex);
size_t sampleSize = info->mSample->range_length();
if (info->mTrackFlags & kIsVorbis) {
// Each sample's data is suffixed by the number of page samples
// or -1 if not available.
sampleSize += sizeof(int32_t);
}
if (buffer->capacity() < sampleSize) {
return -ENOMEM;
}
const uint8_t *src =
(const uint8_t *)info->mSample->data()
+ info->mSample->range_offset();
memcpy((uint8_t *)buffer->data(), src, info->mSample->range_length());
if (info->mTrackFlags & kIsVorbis) {
int32_t numPageSamples;
if (!info->mSample->meta_data()->findInt32(
kKeyValidSamples, &numPageSamples)) {
numPageSamples = -1;
}
memcpy((uint8_t *)buffer->data() + info->mSample->range_length(),
&numPageSamples,
sizeof(numPageSamples));
}
buffer->setRange(0, sampleSize);
return OK;
}
示例8: IsSilence
// static
bool Converter::IsSilence(const sp<ABuffer> &accessUnit) {
const uint8_t *ptr = accessUnit->data();
const uint8_t *end = ptr + accessUnit->size();
while (ptr < end) {
if (*ptr != 0) {
return false;
}
++ptr;
}
return true;
}
示例9: mObserver
MediaBuffer::MediaBuffer(const sp<ABuffer> &buffer)
: mObserver(NULL),
mRefCount(0),
mData(buffer->data()),
mSize(buffer->size()),
mRangeOffset(0),
mRangeLength(mSize),
mBuffer(buffer),
mOwnsData(false),
mMetaData(new MetaData),
mOriginal(NULL) {
}
示例10: CHECK
sp<ABuffer> Converter::prependCSD(const sp<ABuffer> &accessUnit) const {
CHECK(mCSD0 != NULL);
sp<ABuffer> dup = new ABuffer(accessUnit->size() + mCSD0->size());
memcpy(dup->data(), mCSD0->data(), mCSD0->size());
memcpy(dup->data() + mCSD0->size(), accessUnit->data(), accessUnit->size());
int64_t timeUs;
CHECK(accessUnit->meta()->findInt64("timeUs", &timeUs));
dup->meta()->setInt64("timeUs", timeUs);
return dup;
}
示例11: queueBuffer
void LiveDataSource::queueBuffer(const sp<ABuffer> &buffer) {
Mutex::Autolock autoLock(mLock);
if (mFinalResult != OK) {
return;
}
#if SAVE_BACKUP
if (mBackupFile != NULL) {
CHECK_EQ(fwrite(buffer->data(), 1, buffer->size(), mBackupFile),
buffer->size());
}
#endif
mBufferQueue.push_back(buffer);
mCondition.broadcast();
}
示例12: IsAVCReferenceFrame
bool IsAVCReferenceFrame(const sp<ABuffer> &accessUnit) {
const uint8_t *data = accessUnit->data();
size_t size = accessUnit->size();
const uint8_t *nalStart;
size_t nalSize;
while (getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) {
CHECK_GT(nalSize, 0u);
unsigned nalType = nalStart[0] & 0x1f;
if (nalType == 5) {
return true;
} else if (nalType == 1) {
unsigned nal_ref_idc = (nalStart[0] >> 5) & 3;
return nal_ref_idc != 0;
}
}
示例13: queueAccessUnit
void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) {
int32_t damaged;
#ifndef ANDROID_DEFAULT_CODE
if(mIsEOS)
{
return ;
}
// mtk80902: porting from APacketSource
// wait IDR for 264
if (mIsAVC && mNeedScanForIDR && mScanForIDR) {
if ((buffer->data()[0] & 0x1f) != 5) {
ALOGD("skipping AU while scanning for next IDR frame.");
return;
}
mScanForIDR = false;
}
#endif
if (buffer->meta()->findInt32("damaged", &damaged) && damaged) {
// LOG(VERBOSE) << "discarding damaged AU";
return;
}
int64_t lastQueuedTimeUs;
CHECK(buffer->meta()->findInt64("timeUs", &lastQueuedTimeUs));
mLastQueuedTimeUs = lastQueuedTimeUs;
ALOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", mLastQueuedTimeUs, mLastQueuedTimeUs / 1E6);
Mutex::Autolock autoLock(mLock);
mBuffers.push_back(buffer);
mCondition.signal();
if (!mLatestEnqueuedMeta.get()) {
mLatestEnqueuedMeta = buffer->meta();
} else {
int64_t latestTimeUs = 0;
CHECK(mLatestEnqueuedMeta->findInt64("timeUs", &latestTimeUs));
if (lastQueuedTimeUs > latestTimeUs) {
mLatestEnqueuedMeta = buffer->meta();
}
}
}
示例14: IsIDR
bool IsIDR(const sp<ABuffer> &buffer) {
const uint8_t *data = buffer->data();
size_t size = buffer->size();
bool foundIDR = false;
const uint8_t *nalStart;
size_t nalSize;
while (getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) {
CHECK_GT(nalSize, 0u);
unsigned nalType = nalStart[0] & 0x1f;
if (nalType == 5) {
foundIDR = true;
break;
}
}
return foundIDR;
}
示例15: safeConvert
status_t AudioConverter::safeConvert(const sp<MediaCodecBuffer> &src, sp<MediaCodecBuffer> &tgt) {
if (mTo == kAudioEncodingPcm8bit && mFrom == kAudioEncodingPcm16bit) {
memcpy_to_u8_from_i16((uint8_t*)tgt->base(), (const int16_t*)src->data(), src->size() / 2);
} else if (mTo == kAudioEncodingPcm8bit && mFrom == kAudioEncodingPcmFloat) {
memcpy_to_u8_from_float((uint8_t*)tgt->base(), (const float*)src->data(), src->size() / 4);
} else if (mTo == kAudioEncodingPcm16bit && mFrom == kAudioEncodingPcm8bit) {
memcpy_to_i16_from_u8((int16_t*)tgt->base(), (const uint8_t*)src->data(), src->size());
} else if (mTo == kAudioEncodingPcm16bit && mFrom == kAudioEncodingPcmFloat) {
memcpy_to_i16_from_float((int16_t*)tgt->base(), (const float*)src->data(), src->size() / 4);
} else if (mTo == kAudioEncodingPcmFloat && mFrom == kAudioEncodingPcm8bit) {
memcpy_to_float_from_u8((float*)tgt->base(), (const uint8_t*)src->data(), src->size());
} else if (mTo == kAudioEncodingPcmFloat && mFrom == kAudioEncodingPcm16bit) {
memcpy_to_float_from_i16((float*)tgt->base(), (const int16_t*)src->data(), src->size() / 2);
} else {
return INVALID_OPERATION;
}
return OK;
}