Loading media/codec2/components/vpx/C2SoftVpxEnc.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,7 @@ C2SoftVpxEnc::C2SoftVpxEnc(const char* name, c2_node_id_t id, mTemporalPatternIdx(0), mLastTimestamp(0x7FFFFFFFFFFFFFFFull), mSignalledOutputEos(false), mHeaderGenerated(false), mSignalledError(false) { for (int i = 0; i < MAXTEMPORALLAYERS; i++) { mTemporalLayerBitrateRatio[i] = 1.0f; Loading Loading @@ -494,6 +495,7 @@ void C2SoftVpxEnc::onRelease() { // this one is not allocated by us mCodecInterface = nullptr; mHeaderGenerated = false; } c2_status_t C2SoftVpxEnc::onStop() { Loading Loading @@ -558,6 +560,7 @@ status_t C2SoftVpxEnc::initEncoder() { (uint32_t)mBitrateControlMode, mTemporalLayers, mIntf->getSyncFramePeriod(), mMinQuantizer, mMaxQuantizer); mHeaderGenerated = false; mCodecConfiguration = new vpx_codec_enc_cfg_t; if (!mCodecConfiguration) goto CleanUp; codec_return = vpx_codec_enc_config_default(mCodecInterface, Loading Loading @@ -873,6 +876,27 @@ void C2SoftVpxEnc::process( return; } // Header generation is limited to Android V and above, as MediaMuxer did not handle // CSD for VP9 correctly in Android U and before. if (isAtLeastV() && !mHeaderGenerated) { vpx_fixed_buf_t* codec_private_data = vpx_codec_get_global_headers(mCodecContext); if (codec_private_data) { std::unique_ptr<C2StreamInitDataInfo::output> csd = C2StreamInitDataInfo::output::AllocUnique(codec_private_data->sz, 0u); if (!csd) { ALOGE("CSD allocation failed"); mSignalledError = true; work->result = C2_NO_MEMORY; work->workletsProcessed = 1u; return; } memcpy(csd->m.value, codec_private_data->buf, codec_private_data->sz); work->worklets.front()->output.configUpdate.push_back(std::move(csd)); ALOGV("CSD Produced of size %zu bytes", codec_private_data->sz); } mHeaderGenerated = true; } const C2ConstGraphicBlock inBuffer = inputBuffer->data().graphicBlocks().front(); if (inBuffer.width() < mSize->width || Loading media/codec2/components/vpx/C2SoftVpxEnc.h +3 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,9 @@ struct C2SoftVpxEnc : public SimpleC2Component { // Signalled EOS bool mSignalledOutputEos; // Header generated bool mHeaderGenerated; // Signalled Error bool mSignalledError; Loading Loading
media/codec2/components/vpx/C2SoftVpxEnc.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,7 @@ C2SoftVpxEnc::C2SoftVpxEnc(const char* name, c2_node_id_t id, mTemporalPatternIdx(0), mLastTimestamp(0x7FFFFFFFFFFFFFFFull), mSignalledOutputEos(false), mHeaderGenerated(false), mSignalledError(false) { for (int i = 0; i < MAXTEMPORALLAYERS; i++) { mTemporalLayerBitrateRatio[i] = 1.0f; Loading Loading @@ -494,6 +495,7 @@ void C2SoftVpxEnc::onRelease() { // this one is not allocated by us mCodecInterface = nullptr; mHeaderGenerated = false; } c2_status_t C2SoftVpxEnc::onStop() { Loading Loading @@ -558,6 +560,7 @@ status_t C2SoftVpxEnc::initEncoder() { (uint32_t)mBitrateControlMode, mTemporalLayers, mIntf->getSyncFramePeriod(), mMinQuantizer, mMaxQuantizer); mHeaderGenerated = false; mCodecConfiguration = new vpx_codec_enc_cfg_t; if (!mCodecConfiguration) goto CleanUp; codec_return = vpx_codec_enc_config_default(mCodecInterface, Loading Loading @@ -873,6 +876,27 @@ void C2SoftVpxEnc::process( return; } // Header generation is limited to Android V and above, as MediaMuxer did not handle // CSD for VP9 correctly in Android U and before. if (isAtLeastV() && !mHeaderGenerated) { vpx_fixed_buf_t* codec_private_data = vpx_codec_get_global_headers(mCodecContext); if (codec_private_data) { std::unique_ptr<C2StreamInitDataInfo::output> csd = C2StreamInitDataInfo::output::AllocUnique(codec_private_data->sz, 0u); if (!csd) { ALOGE("CSD allocation failed"); mSignalledError = true; work->result = C2_NO_MEMORY; work->workletsProcessed = 1u; return; } memcpy(csd->m.value, codec_private_data->buf, codec_private_data->sz); work->worklets.front()->output.configUpdate.push_back(std::move(csd)); ALOGV("CSD Produced of size %zu bytes", codec_private_data->sz); } mHeaderGenerated = true; } const C2ConstGraphicBlock inBuffer = inputBuffer->data().graphicBlocks().front(); if (inBuffer.width() < mSize->width || Loading
media/codec2/components/vpx/C2SoftVpxEnc.h +3 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,9 @@ struct C2SoftVpxEnc : public SimpleC2Component { // Signalled EOS bool mSignalledOutputEos; // Header generated bool mHeaderGenerated; // Signalled Error bool mSignalledError; Loading