本文整理汇总了C++中CJNIByteBuffer::capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CJNIByteBuffer::capacity方法的具体用法?C++ CJNIByteBuffer::capacity怎么用?C++ CJNIByteBuffer::capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJNIByteBuffer
的用法示例。
在下文中一共展示了CJNIByteBuffer::capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Decode
int CDVDVideoCodecAndroidMediaCodec::Decode(uint8_t *pData, int iSize, double dts, double pts)
{
if (!m_opened)
return VC_ERROR;
if (m_state != MEDIACODEC_STATE_RUNNING)
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Decode current state (%d)", m_state);
if (m_hints.ptsinvalid)
pts = DVD_NOPTS_VALUE;
// Handle input, add demuxer packet to input queue, we must accept it or
// it will be discarded as VideoPlayerVideo has no concept of "try again".
// we must return VC_BUFFER or VC_PICTURE, default to VC_BUFFER.
bool drain = (m_codecControlFlags & DVD_CODEC_CTRL_DRAIN) ? true : false;
m_dec_retcode = (drain) ? 0 : VC_BUFFER;
if (!pData)
{
// Check if we have a saved buffer
if (m_demux_pkt.pData && m_state != MEDIACODEC_STATE_ENDOFSTREAM)
{
pData = m_demux_pkt.pData;
iSize = m_demux_pkt.iSize;
pts = m_demux_pkt.pts;
dts = m_demux_pkt.dts;
}
}
else if (m_state == MEDIACODEC_STATE_ENDOFSTREAM)
{
// We received a packet but already reached EOS. Flush...
FlushInternal();
m_codec->flush();
m_state = MEDIACODEC_STATE_FLUSHED;
m_dec_retcode |= VC_BUFFER;
}
// must check for an output picture 1st,
// otherwise, mediacodec can stall on some devices.
int retgp = GetOutputPicture();
if (retgp > 0)
{
m_dec_retcode |= VC_PICTURE;
m_noPictureLoop = 0;
}
else if (retgp == -1 || (drain && ++m_noPictureLoop == 10)) // EOS
{
m_state = MEDIACODEC_STATE_ENDOFSTREAM;
m_dec_retcode |= VC_BUFFER;
m_noPictureLoop = 0;
}
if (pData)
{
// try to fetch an input buffer
int64_t timeout_us = 5000;
int index = m_codec->dequeueInputBuffer(timeout_us);
if (xbmc_jnienv()->ExceptionCheck())
{
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode ExceptionCheck");
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear();
m_dec_retcode = VC_ERROR;
}
else if (index >= 0)
{
if (m_state == MEDIACODEC_STATE_FLUSHED)
m_state = MEDIACODEC_STATE_RUNNING;
if (!(m_state == MEDIACODEC_STATE_FLUSHED || m_state == MEDIACODEC_STATE_RUNNING))
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode Dequeue: Wrong state (%d)", m_state);
// we have an input buffer, fill it.
if (pData && m_bitstream)
{
m_bitstream->Convert(pData, iSize);
iSize = m_bitstream->GetConvertSize();
pData = m_bitstream->GetConvertBuffer();
}
CJNIByteBuffer buffer = m_codec->getInputBuffer(index);
int size = buffer.capacity();
if (iSize > size)
{
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode, iSize(%d) > size(%d)", iSize, size);
iSize = size;
}
// fetch a pointer to the ByteBuffer backing store
uint8_t *dst_ptr = (uint8_t*)xbmc_jnienv()->GetDirectBufferAddress(buffer.get_raw());
if (pData && dst_ptr)
{
// Codec specifics
switch(m_hints.codec)
{
case AV_CODEC_ID_VC1:
{
if (iSize >= 4 && pData[0] == 0x00 && pData[1] == 0x00 && pData[2] == 0x01 && (pData[3] == 0x0d || pData[3] == 0x0f))
memcpy(dst_ptr, pData, iSize);
else
{
dst_ptr[0] = 0x00;
//.........这里部分代码省略.........
示例2: GetOutputPicture
int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void)
{
int rtn = 0;
int64_t timeout_us = 10000;
CJNIMediaCodecBufferInfo bufferInfo;
int index = m_codec->dequeueOutputBuffer(bufferInfo, timeout_us);
if (xbmc_jnienv()->ExceptionCheck())
{
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck; dequeueOutputBuffer");
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear();
return -2;
}
if (index >= 0)
{
int64_t pts= bufferInfo.presentationTimeUs();
m_videobuffer.dts = DVD_NOPTS_VALUE;
m_videobuffer.pts = DVD_NOPTS_VALUE;
if (pts != AV_NOPTS_VALUE)
m_videobuffer.pts = pts;
int flags = bufferInfo.flags();
if (flags & CJNIMediaCodec::BUFFER_FLAG_SYNC_FRAME)
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_SYNC_FRAME");
if (flags & CJNIMediaCodec::BUFFER_FLAG_CODEC_CONFIG)
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_CODEC_CONFIG");
if (flags & CJNIMediaCodec::BUFFER_FLAG_END_OF_STREAM)
{
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_END_OF_STREAM");
m_codec->releaseOutputBuffer(index, false);
if (xbmc_jnienv()->ExceptionCheck())
{
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: releaseOutputBuffer");
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear();
return -2;
}
return -1;
}
if (m_drop)
{
m_codec->releaseOutputBuffer(index, false);
if (xbmc_jnienv()->ExceptionCheck())
{
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: releaseOutputBuffer");
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear();
return -2;
}
m_videobuffer.mediacodec = nullptr;
return 1;
}
if (!m_render_sw)
{
size_t i = 0;
for (; i < m_inflight.size(); ++i)
{
if (m_inflight[i]->GetIndex() == index)
break;
}
if (i == m_inflight.size())
m_inflight.push_back(
new CDVDMediaCodecInfo(index, m_textureId, m_codec, m_surfaceTexture, m_frameAvailable)
);
m_videobuffer.mediacodec = m_inflight[i]->Retain();
m_videobuffer.mediacodec->Validate(true);
}
else
{
int size = bufferInfo.size();
int offset = bufferInfo.offset();
CJNIByteBuffer buffer = m_codec->getOutputBuffer(index);;
if (!buffer.isDirect())
CLog::Log(LOGWARNING, "CDVDVideoCodecAndroidMediaCodec:: buffer.isDirect == false");
if (!buffer.isDirect())
CLog::Log(LOGWARNING, "CDVDVideoCodecAndroidMediaCodec:: m_output[index].isDirect == false");
if (size && buffer.capacity())
{
uint8_t *src_ptr = (uint8_t*)xbmc_jnienv()->GetDirectBufferAddress(buffer.get_raw());
src_ptr += offset;
int loop_end = 0;
if (m_videobuffer.format == RENDER_FMT_NV12)
loop_end = 2;
else if (m_videobuffer.format == RENDER_FMT_YUV420P)
loop_end = 3;
for (int i = 0; i < loop_end; i++)
{
uint8_t *src = src_ptr + m_src_offset[i];
int src_stride = m_src_stride[i];
uint8_t *dst = m_videobuffer.data[i];
//.........这里部分代码省略.........