Loading media/codec2/components/flac/C2SoftFlacDec.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,11 @@ void C2SoftFlacDec::process( uint8_t *input = const_cast<uint8_t *>(rView.data() + inOffset); if (codecConfig) { if (mHasStreamInfo) { ALOGV("Ignore Codec Config"); fillEmptyWork(work); return; } status_t decoderErr = mFLACDecoder->parseMetadata(input, inSize); if (decoderErr != OK && decoderErr != WOULD_BLOCK) { ALOGE("process: FLACDecoder parseMetaData returns error %d", decoderErr); Loading media/codec2/sfplugin/CCodec.cpp +45 −4 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include <media/omx/1.0/WOmxNode.h> #include <media/openmax/OMX_Core.h> #include <media/openmax/OMX_IndexExt.h> #include <media/stagefright/foundation/avc_utils.h> #include <media/stagefright/omx/1.0/WGraphicBufferSource.h> #include <media/stagefright/omx/OmxGraphicBufferSource.h> #include <media/stagefright/CCodec.h> Loading Loading @@ -521,6 +522,44 @@ void RevertOutputFormatIfNeeded( } } void AmendOutputFormatWithCodecSpecificData( const uint8_t *data, size_t size, const std::string mediaType, const sp<AMessage> &outputFormat) { if (mediaType == MIMETYPE_VIDEO_AVC) { // Codec specific data should be SPS and PPS in a single buffer, // each prefixed by a startcode (0x00 0x00 0x00 0x01). // We separate the two and put them into the output format // under the keys "csd-0" and "csd-1". unsigned csdIndex = 0; const uint8_t *nalStart; size_t nalSize; while (getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) { sp<ABuffer> csd = new ABuffer(nalSize + 4); memcpy(csd->data(), "\x00\x00\x00\x01", 4); memcpy(csd->data() + 4, nalStart, nalSize); outputFormat->setBuffer( AStringPrintf("csd-%u", csdIndex).c_str(), csd); ++csdIndex; } if (csdIndex != 2) { ALOGW("Expected two NAL units from AVC codec config, but %u found", csdIndex); } } else { // For everything else we just stash the codec specific data into // the output format as a single piece of csd under "csd-0". sp<ABuffer> csd = new ABuffer(size); memcpy(csd->data(), data, size); csd->setRange(0, size); outputFormat->setBuffer("csd-0", csd); } } } // namespace // CCodec::ClientListener Loading Loading @@ -2170,7 +2209,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done std::unique_ptr<C2Param> initData; std::shared_ptr<const C2StreamInitDataInfo::output> initData; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2249,13 +2288,15 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } if (initDataWatcher.hasChanged()) { initData = C2Param::Copy(*initDataWatcher.update().get()); initData = initDataWatcher.update(); AmendOutputFormatWithCodecSpecificData( initData->m.value, initData->flexCount(), config->mCodingMediaType, config->mOutputFormat); } outputFormat = config->mOutputFormat; } mChannel->onWorkDone( std::move(work), outputFormat, initData ? (C2StreamInitDataInfo::output *)initData.get() : nullptr); std::move(work), outputFormat, initData ? initData.get() : nullptr); break; } case kWhatWatch: { Loading media/extractors/mp4/MPEG4Extractor.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -2587,7 +2587,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { case FOURCC("dvcC"): case FOURCC("dvvC"): { CHECK_EQ(chunk_data_size, 24); if (chunk_data_size != 24) { return ERROR_MALFORMED; } auto buffer = heapbuffer<uint8_t>(chunk_data_size); Loading media/libmediaformatshaper/CodecSeeding.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -44,8 +44,7 @@ typedef struct { } preloadTunings_t; /* * 240 = 2.4 bits per pixel-per-second == 5mbps@1080, 2.3mbps@720p, which is about where * we want our initial floor for now. * bpp == bits per pixel per second, for 30fps. */ static preloadTuning_t featuresAvc[] = { Loading @@ -69,11 +68,12 @@ static preloadTuning_t featuresHevc[] = { {true, "vq-target-bpp-1080p", "1.50"}, {true, "vq-target-bpp-720p", "1.80"}, {true, "vq-target-bpp-540p", "2.10"}, {true, "vq-target-bpp-480p", "2.30"}, {true, "vq-target-qpmax", "-1"}, {true, "vq-target-qpmax-1080p", "45"}, {true, "vq-target-qpmax-720p", "43"}, {true, "vq-target-qpmax-540p", "42"}, {true, "vq-target-qpmax-480p", "39"}, {true, "vq-target-qpmax-720p", "44"}, {true, "vq-target-qpmax-540p", "43"}, {true, "vq-target-qpmax-480p", "42"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} Loading media/libstagefright/MediaCodec.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -1579,16 +1579,12 @@ status_t MediaCodec::configure( // the reclaimResource call doesn't consider the requester's buffer size for now. resources.push_back(MediaResource::GraphicMemoryResource(1)); for (int i = 0; i <= kMaxRetry; ++i) { if (i > 0) { // Don't try to reclaim resource for the first time. if (!mResourceManagerProxy->reclaimResource(resources)) { break; } } sp<AMessage> response; err = PostAndAwaitResponse(msg, &response); if (err != OK && err != INVALID_OPERATION) { if (isResourceError(err) && !mResourceManagerProxy->reclaimResource(resources)) { break; } // MediaCodec now set state to UNINITIALIZED upon any fatal error. // To maintain backward-compatibility, do a reset() to put codec // back into INITIALIZED state. Loading Loading @@ -4329,7 +4325,8 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu // format as necessary. int32_t flags = 0; (void) buffer->meta()->findInt32("flags", &flags); if ((flags & BUFFER_FLAG_CODECCONFIG) && !(mFlags & kFlagIsSecure)) { if ((flags & BUFFER_FLAG_CODECCONFIG) && !(mFlags & kFlagIsSecure) && !mOwnerName.startsWith("codec2::")) { status_t err = amendOutputFormatWithCodecSpecificData(buffer); Loading Loading
media/codec2/components/flac/C2SoftFlacDec.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,11 @@ void C2SoftFlacDec::process( uint8_t *input = const_cast<uint8_t *>(rView.data() + inOffset); if (codecConfig) { if (mHasStreamInfo) { ALOGV("Ignore Codec Config"); fillEmptyWork(work); return; } status_t decoderErr = mFLACDecoder->parseMetadata(input, inSize); if (decoderErr != OK && decoderErr != WOULD_BLOCK) { ALOGE("process: FLACDecoder parseMetaData returns error %d", decoderErr); Loading
media/codec2/sfplugin/CCodec.cpp +45 −4 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include <media/omx/1.0/WOmxNode.h> #include <media/openmax/OMX_Core.h> #include <media/openmax/OMX_IndexExt.h> #include <media/stagefright/foundation/avc_utils.h> #include <media/stagefright/omx/1.0/WGraphicBufferSource.h> #include <media/stagefright/omx/OmxGraphicBufferSource.h> #include <media/stagefright/CCodec.h> Loading Loading @@ -521,6 +522,44 @@ void RevertOutputFormatIfNeeded( } } void AmendOutputFormatWithCodecSpecificData( const uint8_t *data, size_t size, const std::string mediaType, const sp<AMessage> &outputFormat) { if (mediaType == MIMETYPE_VIDEO_AVC) { // Codec specific data should be SPS and PPS in a single buffer, // each prefixed by a startcode (0x00 0x00 0x00 0x01). // We separate the two and put them into the output format // under the keys "csd-0" and "csd-1". unsigned csdIndex = 0; const uint8_t *nalStart; size_t nalSize; while (getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) { sp<ABuffer> csd = new ABuffer(nalSize + 4); memcpy(csd->data(), "\x00\x00\x00\x01", 4); memcpy(csd->data() + 4, nalStart, nalSize); outputFormat->setBuffer( AStringPrintf("csd-%u", csdIndex).c_str(), csd); ++csdIndex; } if (csdIndex != 2) { ALOGW("Expected two NAL units from AVC codec config, but %u found", csdIndex); } } else { // For everything else we just stash the codec specific data into // the output format as a single piece of csd under "csd-0". sp<ABuffer> csd = new ABuffer(size); memcpy(csd->data(), data, size); csd->setRange(0, size); outputFormat->setBuffer("csd-0", csd); } } } // namespace // CCodec::ClientListener Loading Loading @@ -2170,7 +2209,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done std::unique_ptr<C2Param> initData; std::shared_ptr<const C2StreamInitDataInfo::output> initData; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2249,13 +2288,15 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } if (initDataWatcher.hasChanged()) { initData = C2Param::Copy(*initDataWatcher.update().get()); initData = initDataWatcher.update(); AmendOutputFormatWithCodecSpecificData( initData->m.value, initData->flexCount(), config->mCodingMediaType, config->mOutputFormat); } outputFormat = config->mOutputFormat; } mChannel->onWorkDone( std::move(work), outputFormat, initData ? (C2StreamInitDataInfo::output *)initData.get() : nullptr); std::move(work), outputFormat, initData ? initData.get() : nullptr); break; } case kWhatWatch: { Loading
media/extractors/mp4/MPEG4Extractor.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -2587,7 +2587,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { case FOURCC("dvcC"): case FOURCC("dvvC"): { CHECK_EQ(chunk_data_size, 24); if (chunk_data_size != 24) { return ERROR_MALFORMED; } auto buffer = heapbuffer<uint8_t>(chunk_data_size); Loading
media/libmediaformatshaper/CodecSeeding.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -44,8 +44,7 @@ typedef struct { } preloadTunings_t; /* * 240 = 2.4 bits per pixel-per-second == 5mbps@1080, 2.3mbps@720p, which is about where * we want our initial floor for now. * bpp == bits per pixel per second, for 30fps. */ static preloadTuning_t featuresAvc[] = { Loading @@ -69,11 +68,12 @@ static preloadTuning_t featuresHevc[] = { {true, "vq-target-bpp-1080p", "1.50"}, {true, "vq-target-bpp-720p", "1.80"}, {true, "vq-target-bpp-540p", "2.10"}, {true, "vq-target-bpp-480p", "2.30"}, {true, "vq-target-qpmax", "-1"}, {true, "vq-target-qpmax-1080p", "45"}, {true, "vq-target-qpmax-720p", "43"}, {true, "vq-target-qpmax-540p", "42"}, {true, "vq-target-qpmax-480p", "39"}, {true, "vq-target-qpmax-720p", "44"}, {true, "vq-target-qpmax-540p", "43"}, {true, "vq-target-qpmax-480p", "42"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} Loading
media/libstagefright/MediaCodec.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -1579,16 +1579,12 @@ status_t MediaCodec::configure( // the reclaimResource call doesn't consider the requester's buffer size for now. resources.push_back(MediaResource::GraphicMemoryResource(1)); for (int i = 0; i <= kMaxRetry; ++i) { if (i > 0) { // Don't try to reclaim resource for the first time. if (!mResourceManagerProxy->reclaimResource(resources)) { break; } } sp<AMessage> response; err = PostAndAwaitResponse(msg, &response); if (err != OK && err != INVALID_OPERATION) { if (isResourceError(err) && !mResourceManagerProxy->reclaimResource(resources)) { break; } // MediaCodec now set state to UNINITIALIZED upon any fatal error. // To maintain backward-compatibility, do a reset() to put codec // back into INITIALIZED state. Loading Loading @@ -4329,7 +4325,8 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu // format as necessary. int32_t flags = 0; (void) buffer->meta()->findInt32("flags", &flags); if ((flags & BUFFER_FLAG_CODECCONFIG) && !(mFlags & kFlagIsSecure)) { if ((flags & BUFFER_FLAG_CODECCONFIG) && !(mFlags & kFlagIsSecure) && !mOwnerName.startsWith("codec2::")) { status_t err = amendOutputFormatWithCodecSpecificData(buffer); Loading