mirror of
https://gitee.com/openharmony/multimedia_av_codec
synced 2024-11-23 15:00:51 +00:00
buffer mode dynamic
Signed-off-by: suxiaosu007 <sxs233333@163.com>
This commit is contained in:
parent
7533ac07fd
commit
bd82f6cf4a
@ -24,6 +24,6 @@ group("av_codec_services_package") {
|
||||
"utils:av_codec_service_utils",
|
||||
]
|
||||
if (av_codec_support_hcodec) {
|
||||
deps += [ "engine/codec/video/hcodec:hcodec" ]
|
||||
deps += [ "engine/codec/video/hcodec:hcodec_group" ]
|
||||
}
|
||||
}
|
||||
|
@ -85,3 +85,10 @@ ohos_shared_library("hcodec") {
|
||||
defines = [ "BUILD_ENG_VERSION" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("hcodec_group") {
|
||||
deps = [ ":hcodec" ]
|
||||
if (build_variant != "user") {
|
||||
deps += [ "$av_codec_root_dir/test/unittest/hcodec_test/demo:hcodec_demo" ]
|
||||
}
|
||||
}
|
||||
|
@ -1015,7 +1015,7 @@ void HCodec::OnOMXFillBufferDone(BufferOperationMode mode, BufferInfo& info, siz
|
||||
}
|
||||
bool eos = (info.omxBuffer->flag & OMX_BUFFERFLAG_EOS);
|
||||
if (!eos && info.omxBuffer->filledLen == 0) {
|
||||
HLOGI("it's not a eos buffer but not filled, ask omx to re-fill it");
|
||||
HLOGW("it's not a eos buffer but not filled, ask omx to re-fill it");
|
||||
NotifyOmxToFillThisOutBuffer(info);
|
||||
return;
|
||||
}
|
||||
@ -1340,7 +1340,7 @@ void HCodec::CleanUpOmxNode()
|
||||
int32_t HCodec::OnAllocateComponent()
|
||||
{
|
||||
HitraceScoped trace(HITRACE_TAG_ZMEDIA, "hcodec_AllocateComponent_" + caps_.compName);
|
||||
compMgr_ = GetManager(false, caps_.port.video.isSupportPassthrough);
|
||||
compMgr_ = GetManager(false, caps_.port.video.isSupportPassthrough, isSecure_);
|
||||
if (compMgr_ == nullptr) {
|
||||
HLOGE("GetCodecComponentManager failed");
|
||||
return AVCS_ERR_UNKNOWN;
|
||||
|
@ -45,31 +45,36 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static std::optional<bool> IsPassthroughFromParam()
|
||||
static bool DecideMode(bool supportPassthrough, bool isSecure)
|
||||
{
|
||||
#ifdef BUILD_ENG_VERSION
|
||||
string para = OHOS::system::GetParameter("hcodec.usePassthrough", "-1");
|
||||
if (para == "1") {
|
||||
string mode = OHOS::system::GetParameter("hcodec.usePassthrough", "");
|
||||
if (mode == "1") {
|
||||
LOGI("force passthrough");
|
||||
return true;
|
||||
}
|
||||
if (para == "0") {
|
||||
} else if (mode == "0") {
|
||||
LOGI("force ipc");
|
||||
return false;
|
||||
} else if (mode == "-1") {
|
||||
if (isSecure) {
|
||||
LOGI("secure, supportPassthrough = %d", supportPassthrough);
|
||||
return supportPassthrough;
|
||||
} else {
|
||||
static int g_cnt = 0;
|
||||
bool passthrough = (g_cnt++ % 3 == 0);
|
||||
LOGI("g_cnt=%d, %s mode", g_cnt, passthrough ? "passthrough" : "ipc");
|
||||
return passthrough;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return std::nullopt;
|
||||
LOGI("supportPassthrough = %d", supportPassthrough);
|
||||
return supportPassthrough;
|
||||
}
|
||||
|
||||
sptr<ICodecComponentManager> GetManager(bool getCap, bool supportPassthrough)
|
||||
sptr<ICodecComponentManager> GetManager(bool getCap, bool supportPassthrough, bool isSecure)
|
||||
{
|
||||
lock_guard<mutex> lk(g_mtx);
|
||||
bool isPassthrough = false;
|
||||
if (getCap) {
|
||||
isPassthrough = true;
|
||||
} else {
|
||||
optional<bool> para = IsPassthroughFromParam();
|
||||
isPassthrough = para.has_value() ? para.value() : supportPassthrough;
|
||||
LOGI("%s mode", isPassthrough ? "passthrough" : "ipc");
|
||||
}
|
||||
bool isPassthrough = getCap ? true : DecideMode(supportPassthrough, isSecure);
|
||||
sptr<ICodecComponentManager>& mng = (isPassthrough ? g_compMgrPassthru : g_compMgrIpc);
|
||||
if (mng) {
|
||||
return mng;
|
||||
|
@ -36,7 +36,8 @@ private:
|
||||
CapabilityData& userCap);
|
||||
};
|
||||
|
||||
sptr<CodecHDI::ICodecComponentManager> GetManager(bool getCap, bool supportPassthrough = false);
|
||||
sptr<CodecHDI::ICodecComponentManager> GetManager(bool getCap,
|
||||
bool supportPassthrough = false, bool isSecure = false);
|
||||
std::vector<CodecHDI::CodecCompCapability> GetCapList();
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,21 @@ int32_t HDecoder::OnConfigure(const Format &format)
|
||||
{
|
||||
configFormat_ = make_shared<Format>(format);
|
||||
|
||||
SupportBufferType type;
|
||||
InitOMXParamExt(type);
|
||||
type.portIndex = OMX_DirOutput;
|
||||
if (GetParameter(OMX_IndexParamSupportBufferType, type) &&
|
||||
(type.bufferTypes & CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) &&
|
||||
UseHandleOnOutputPort(true)) {
|
||||
HLOGI("dynamic mode");
|
||||
isDynamic_ = true;
|
||||
} else if (UseHandleOnOutputPort(false)) {
|
||||
HLOGI("normal mode");
|
||||
isDynamic_ = false;
|
||||
} else {
|
||||
HLOGE("invalid output buffer type");
|
||||
return AVCS_ERR_UNKNOWN;
|
||||
}
|
||||
int32_t ret = SetLowLatency(format);
|
||||
if (ret != AVCS_ERR_OK) {
|
||||
return ret;
|
||||
@ -415,32 +430,13 @@ bool HDecoder::ReadyToStart()
|
||||
if (callback_ == nullptr || outputFormat_ == nullptr || inputFormat_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (currSurface_.surface_ == nullptr) {
|
||||
if (!UseHandleOnOutputPort(false)) {
|
||||
HLOGE("invalid output buffer type");
|
||||
return false;
|
||||
}
|
||||
HLOGI("buffer mode");
|
||||
return true;
|
||||
}
|
||||
// has surface
|
||||
SupportBufferType type;
|
||||
InitOMXParamExt(type);
|
||||
type.portIndex = OMX_DirOutput;
|
||||
if (GetParameter(OMX_IndexParamSupportBufferType, type) &&
|
||||
(type.bufferTypes & CODEC_BUFFER_TYPE_DYNAMIC_HANDLE) &&
|
||||
UseHandleOnOutputPort(true)) {
|
||||
HLOGI("surface dynamic mode");
|
||||
isDynamic_ = true;
|
||||
} else if (UseHandleOnOutputPort(false)) {
|
||||
HLOGI("surface normal mode");
|
||||
isDynamic_ = false;
|
||||
if (currSurface_.surface_) {
|
||||
HLOGI("surface mode");
|
||||
SetTransform();
|
||||
SetScaleMode();
|
||||
} else {
|
||||
HLOGE("invalid output buffer type");
|
||||
return false;
|
||||
HLOGI("buffer mode");
|
||||
}
|
||||
SetTransform();
|
||||
SetScaleMode();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -450,10 +446,10 @@ int32_t HDecoder::AllocateBuffersOnPort(OMX_DIRTYPE portIndex)
|
||||
return AllocateAvLinearBuffers(portIndex);
|
||||
}
|
||||
int32_t ret;
|
||||
if (currSurface_.surface_) {
|
||||
ret = isDynamic_ ? AllocOutDynamicSurfaceBuf() : AllocateOutputBuffersFromSurface();
|
||||
if (isDynamic_) {
|
||||
ret = AllocOutDynamicSurfaceBuf();
|
||||
} else {
|
||||
ret = AllocateAvSurfaceBuffers(portIndex);
|
||||
ret = (currSurface_.surface_ ? AllocateOutputBuffersFromSurface() : AllocateAvSurfaceBuffers(portIndex));
|
||||
}
|
||||
if (ret == AVCS_ERR_OK) {
|
||||
UpdateFormatFromSurfaceBuffer();
|
||||
@ -600,17 +596,19 @@ int32_t HDecoder::SetQueueSize(const sptr<Surface> &surface, uint32_t targetSize
|
||||
int32_t HDecoder::AllocOutDynamicSurfaceBuf()
|
||||
{
|
||||
SCOPED_TRACE();
|
||||
currSurface_.surface_->CleanCache();
|
||||
int32_t ret = SetQueueSize(currSurface_.surface_, outBufferCnt_);
|
||||
if (ret != AVCS_ERR_OK) {
|
||||
return ret;
|
||||
if (currSurface_.surface_) {
|
||||
currSurface_.surface_->CleanCache();
|
||||
int32_t ret = SetQueueSize(currSurface_.surface_, outBufferCnt_);
|
||||
if (ret != AVCS_ERR_OK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
outputBufferPool_.clear();
|
||||
|
||||
for (uint32_t i = 0; i < outBufferCnt_; ++i) {
|
||||
shared_ptr<OmxCodecBuffer> omxBuffer = DynamicSurfaceBufferToOmxBuffer();
|
||||
shared_ptr<OmxCodecBuffer> outBuffer = make_shared<OmxCodecBuffer>();
|
||||
ret = compNode_->UseBuffer(OMX_DirOutput, *omxBuffer, *outBuffer);
|
||||
int32_t ret = compNode_->UseBuffer(OMX_DirOutput, *omxBuffer, *outBuffer);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HLOGE("Failed to UseBuffer on input port");
|
||||
return AVCS_ERR_UNKNOWN;
|
||||
@ -619,7 +617,7 @@ int32_t HDecoder::AllocOutDynamicSurfaceBuf()
|
||||
info.isInput = false;
|
||||
info.owner = BufferOwner::OWNED_BY_US;
|
||||
info.surfaceBuffer = nullptr;
|
||||
info.avBuffer = AVBuffer::CreateAVBuffer();
|
||||
info.avBuffer = (currSurface_.surface_ ? AVBuffer::CreateAVBuffer() : nullptr);
|
||||
info.omxBuffer = outBuffer;
|
||||
info.bufferId = outBuffer->bufferId;
|
||||
outputBufferPool_.push_back(info);
|
||||
@ -695,7 +693,7 @@ int32_t HDecoder::RegisterListenerToSurface(const sptr<Surface> &surface)
|
||||
GSError err = surface->RegisterReleaseListener([weakThis, surfaceId](sptr<SurfaceBuffer>&) {
|
||||
std::shared_ptr<HCodec> codec = weakThis.lock();
|
||||
if (codec == nullptr) {
|
||||
LOGI("decoder is gone");
|
||||
LOGD("decoder is gone");
|
||||
return GSERROR_OK;
|
||||
}
|
||||
return codec->OnBufferReleasedByConsumer(surfaceId);
|
||||
@ -750,7 +748,7 @@ void HDecoder::OnGetBufferFromSurface(const ParamSP& param)
|
||||
ScopedTrace tracePoint("requested:" + std::to_string(item.buffer->GetSeqNum()));
|
||||
freeList_.push_back(item); // push to list, retrive it later, to avoid wait fence too early
|
||||
static constexpr size_t MAX_CACHE_CNT = 2;
|
||||
if (freeList_.size() > MAX_CACHE_CNT) {
|
||||
if (item.fence == nullptr || !item.fence->IsValid() || freeList_.size() > MAX_CACHE_CNT) {
|
||||
SubmitBufferToDecoder();
|
||||
}
|
||||
}
|
||||
@ -770,7 +768,7 @@ void HDecoder::SubmitBufferToDecoder()
|
||||
SubmitOneBufferFromFreeList();
|
||||
return;
|
||||
}
|
||||
SubmitOneDynamicBuffer(nullSlot);
|
||||
SurfaceModeSubmitOneDynamicBuffer(nullSlot);
|
||||
}
|
||||
|
||||
void HDecoder::SubmitOneBufferFromFreeList()
|
||||
@ -800,7 +798,7 @@ bool HDecoder::SubmitOneItem(SurfaceBufferItem& item)
|
||||
|
||||
void HDecoder::SubmitDynamicBufferIfPossible()
|
||||
{
|
||||
if (!currSurface_.surface_ || !isDynamic_) {
|
||||
if (!isDynamic_) {
|
||||
return;
|
||||
}
|
||||
auto nullSlot = std::find_if(outputBufferPool_.begin(), outputBufferPool_.end(), [](const BufferInfo& info) {
|
||||
@ -809,10 +807,14 @@ void HDecoder::SubmitDynamicBufferIfPossible()
|
||||
if (nullSlot == outputBufferPool_.end()) {
|
||||
return;
|
||||
}
|
||||
SubmitOneDynamicBuffer(nullSlot);
|
||||
if (currSurface_.surface_) {
|
||||
SurfaceModeSubmitOneDynamicBuffer(nullSlot);
|
||||
} else {
|
||||
BufferModeSubmitOneDynamicBuffer(nullSlot);
|
||||
}
|
||||
}
|
||||
|
||||
void HDecoder::SubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot)
|
||||
void HDecoder::SurfaceModeSubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot)
|
||||
{
|
||||
SCOPED_TRACE();
|
||||
for (size_t i = 0; i < outputBufferPool_.size(); i++) {
|
||||
@ -847,6 +849,30 @@ void HDecoder::SubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot
|
||||
}
|
||||
}
|
||||
|
||||
void HDecoder::BufferModeSubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot)
|
||||
{
|
||||
SCOPED_TRACE();
|
||||
sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create();
|
||||
IF_TRUE_RETURN_VOID_WITH_MSG(buffer == nullptr, "CreateSurfaceBuffer failed");
|
||||
GSError err = buffer->Alloc(requestCfg_);
|
||||
IF_TRUE_RETURN_VOID_WITH_MSG(err != GSERROR_OK, "AllocSurfaceBuffer failed");
|
||||
std::shared_ptr<AVBuffer> avBuffer = AVBuffer::CreateAVBuffer(buffer);
|
||||
if (avBuffer == nullptr || avBuffer->memory_ == nullptr) {
|
||||
HLOGE("CreateAVBuffer failed");
|
||||
return;
|
||||
}
|
||||
SetCallerToBuffer(buffer->GetFileDescriptor());
|
||||
HLOGI("bufferId=%u, seq=%u", nullSlot->bufferId, buffer->GetSeqNum());
|
||||
WrapSurfaceBufferToSlot(*nullSlot, buffer, 0, 0);
|
||||
nullSlot->avBuffer = avBuffer;
|
||||
nullSlot->needDealWithCache = (requestCfg_.usage & BUFFER_USAGE_MEM_MMZ_CACHE);
|
||||
if (nullSlot == outputBufferPool_.begin()) {
|
||||
UpdateFormatFromSurfaceBuffer();
|
||||
}
|
||||
NotifyOmxToFillThisOutBuffer(*nullSlot);
|
||||
nullSlot->omxBuffer->bufferhandle = nullptr;
|
||||
}
|
||||
|
||||
int32_t HDecoder::NotifySurfaceToRenderOutputBuffer(BufferInfo &info)
|
||||
{
|
||||
SCOPED_TRACE_WITH_ID(info.omxBuffer->pts);
|
||||
|
@ -78,7 +78,8 @@ private:
|
||||
void SubmitOneBufferFromFreeList();
|
||||
bool SubmitOneItem(SurfaceBufferItem& item);
|
||||
void SubmitDynamicBufferIfPossible() override;
|
||||
void SubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot);
|
||||
void SurfaceModeSubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot);
|
||||
void BufferModeSubmitOneDynamicBuffer(std::vector<BufferInfo>::iterator nullSlot);
|
||||
|
||||
// switch surface
|
||||
void OnSetOutputSurfaceWhenRunning(const sptr<Surface> &newSurface,
|
||||
|
@ -751,7 +751,7 @@ bool HEncoder::ReadyToStart()
|
||||
return false;
|
||||
}
|
||||
if (inputSurface_) {
|
||||
HLOGI("surface mode");
|
||||
HLOGI("surface mode, surface id = " PRIu64, inputSurface_->GetUniqueId());
|
||||
} else {
|
||||
HLOGI("buffer mode");
|
||||
}
|
||||
@ -867,7 +867,8 @@ sptr<Surface> HEncoder::OnCreateInputSurface()
|
||||
if (inBufferCnt_ > inputSurface_->GetQueueSize()) {
|
||||
inputSurface_->SetQueueSize(inBufferCnt_);
|
||||
}
|
||||
HLOGI("queue size %u", inputSurface_->GetQueueSize());
|
||||
HLOGI("succ, surface id = " PRIu64 ", queue size %u",
|
||||
inputSurface_->GetUniqueId(), inputSurface_->GetQueueSize());
|
||||
return producerSurface;
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ private:
|
||||
int32_t EnableEncoderParamsFeedback(const Format &format);
|
||||
int32_t SetQpRange(const Format &format, bool isCfg);
|
||||
int32_t SetRepeat(const Format &format);
|
||||
int32_t SetConstantQualityMode(int32_t quality);
|
||||
int32_t SetTemperalLayer(const Format &format);
|
||||
int32_t SetConstantQualityMode(int32_t quality);
|
||||
|
||||
// start
|
||||
int32_t AllocateBuffersOnPort(OMX_DIRTYPE portIndex) override;
|
||||
|
@ -15,7 +15,8 @@ import("//build/ohos.gni")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
|
||||
ohos_executable("hcodec_demo") {
|
||||
install_enable = false
|
||||
install_enable = true
|
||||
install_images = [ "system" ]
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
sources = [ "hcodec_demo.cpp" ]
|
||||
@ -24,7 +25,6 @@ ohos_executable("hcodec_demo") {
|
||||
"$av_codec_root_dir/interfaces/inner_api/native/",
|
||||
"$av_codec_root_dir/interfaces/kits/c/",
|
||||
"$av_codec_root_dir/test/unittest/hcodec_test/helper/",
|
||||
"//foundation/window/window_manager/interfaces/innerkits/",
|
||||
]
|
||||
deps = [
|
||||
"$av_codec_root_dir/test/unittest/hcodec_test/helper:hcodec_test_helper",
|
||||
@ -32,12 +32,10 @@ ohos_executable("hcodec_demo") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"drivers_interface_codec:libcodec_proxy_3.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hilog:libhilog",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ ohos_static_library("hcodec_test_helper") {
|
||||
include_dirs = [
|
||||
"//third_party/openmax/api/1.1.2",
|
||||
"//drivers/peripheral/codec/interfaces/include/",
|
||||
"//foundation/window/window_manager/interfaces/innerkits/",
|
||||
"$av_codec_root_dir/services/engine/codec/video/hcodec/",
|
||||
"$av_codec_root_dir/services/engine/base/include/",
|
||||
"$av_codec_root_dir/interfaces/inner_api/native/",
|
||||
@ -43,12 +42,10 @@ ohos_static_library("hcodec_test_helper") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"drivers_interface_codec:libcodec_proxy_3.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hilog:libhilog",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ enum ShortOption {
|
||||
OPT_WATERMARK,
|
||||
OPT_ENABLE_PARAMS_FEEDBACK,
|
||||
// decoder only
|
||||
OPT_RENDER,
|
||||
OPT_DEC_THEN_ENC,
|
||||
OPT_ROTATION,
|
||||
OPT_FLUSH_CNT,
|
||||
@ -106,7 +105,6 @@ static struct option g_longOptions[] = {
|
||||
{"paramsFeedback", required_argument, nullptr, OPT_ENABLE_PARAMS_FEEDBACK},
|
||||
// decoder only
|
||||
{"rotation", required_argument, nullptr, OPT_ROTATION},
|
||||
{"render", required_argument, nullptr, OPT_RENDER},
|
||||
{"decThenEnc", required_argument, nullptr, OPT_DEC_THEN_ENC},
|
||||
{"flushCnt", required_argument, nullptr, OPT_FLUSH_CNT},
|
||||
{"scaleMode", required_argument, nullptr, OPT_SCALE_MODE},
|
||||
@ -157,7 +155,6 @@ void ShowUsage()
|
||||
std::cout << " --waterMark eg. /data/test/a.rgba,1280,720,2:16,16,1280,720" << std::endl;
|
||||
std::cout << " [decoder only]" << std::endl;
|
||||
std::cout << " --rotation rotation angle after decode, eg. 0/90/180/270" << std::endl;
|
||||
std::cout << " --render 0 means don't render, 1 means render to window" << std::endl;
|
||||
std::cout << " --paramsFeedback 0 means don't feedback, 1 means feedback" << std::endl;
|
||||
std::cout << " --decThenEnc do surface encode after surface decode" << std::endl;
|
||||
std::cout << " --flushCnt total flush count during decoding" << std::endl;
|
||||
@ -279,9 +276,6 @@ CommandOpt Parse(int argc, char *argv[])
|
||||
opt.paramsFeedback = stol(optarg);
|
||||
break;
|
||||
// decoder only
|
||||
case OPT_RENDER:
|
||||
opt.render = stol(optarg);
|
||||
break;
|
||||
case OPT_DEC_THEN_ENC:
|
||||
opt.decThenEnc = stol(optarg);
|
||||
break;
|
||||
@ -293,6 +287,7 @@ CommandOpt Parse(int argc, char *argv[])
|
||||
break;
|
||||
case OPT_SCALE_MODE:
|
||||
opt.scaleMode = static_cast<OH_ScalingMode>(stol(optarg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -429,9 +424,9 @@ void CommandOpt::ParseWaterMark(const char *cmd) // "/data/test/a.rgba,1280,720,
|
||||
void CommandOpt::Print() const
|
||||
{
|
||||
TLOGI("-----------------------------");
|
||||
TLOGI("api type=%d, %s, %s mode, render = %d", apiType,
|
||||
TLOGI("api type=%d, %s, %s mode", apiType,
|
||||
(isEncoder ? "encoder" : (decThenEnc ? "dec + enc" : "decoder")),
|
||||
isBufferMode ? "buffer" : "surface", render);
|
||||
isBufferMode ? "buffer" : "surface");
|
||||
TLOGI("read inputFile %s up to %u frames", inputFile.c_str(), maxReadFrameCnt);
|
||||
TLOGI("%u x %u @ %u fps", dispW, dispH, frameRate);
|
||||
TLOGI("protocol = %d, pixFmt = %d", protocol, pixFmt);
|
||||
|
@ -127,7 +127,6 @@ struct CommandOpt {
|
||||
bool paramsFeedback;
|
||||
|
||||
// decoder only
|
||||
bool render = false;
|
||||
bool decThenEnc = false;
|
||||
VideoRotation rotation = VIDEO_ROTATION_0;
|
||||
int flushCnt = 0;
|
||||
|
@ -21,11 +21,9 @@
|
||||
#include "tester_capi.h"
|
||||
#include "tester_codecbase.h"
|
||||
#include "type_converter.h"
|
||||
#include "ui/rs_surface_node.h" // foundation/graphic/graphic_2d/rosen/modules/render_service_client/core/
|
||||
|
||||
namespace OHOS::MediaAVCodec {
|
||||
using namespace std;
|
||||
using namespace OHOS::Rosen;
|
||||
using namespace Media;
|
||||
|
||||
std::mutex TesterCommon::vividMtx_;
|
||||
@ -580,7 +578,7 @@ bool TesterCommon::RunDecoder()
|
||||
ret = ConfigureDecoder();
|
||||
IF_TRUE_RETURN_VAL(!ret, false);
|
||||
if (!opt_.isBufferMode) {
|
||||
sptr<Surface> surface = opt_.render ? CreateSurfaceFromWindow() : CreateSurfaceNormal();
|
||||
sptr<Surface> surface = CreateSurfaceNormal();
|
||||
if (surface == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -602,38 +600,9 @@ bool TesterCommon::RunDecoder()
|
||||
IF_TRUE_RETURN_VAL(!ret, false);
|
||||
ret = Release();
|
||||
IF_TRUE_RETURN_VAL(!ret, false);
|
||||
if (window_ != nullptr) {
|
||||
window_->Destroy();
|
||||
window_ = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<Surface> TesterCommon::CreateSurfaceFromWindow()
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<Window> window = Window::Create("DemoWindow", option);
|
||||
if (window == nullptr) {
|
||||
TLOGE("Create Window failed");
|
||||
return nullptr;
|
||||
}
|
||||
shared_ptr<RSSurfaceNode> node = window->GetSurfaceNode();
|
||||
if (node == nullptr) {
|
||||
TLOGE("GetSurfaceNode failed");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<Surface> surface = node->GetSurface();
|
||||
if (surface == nullptr) {
|
||||
TLOGE("GetSurface failed");
|
||||
return nullptr;
|
||||
}
|
||||
window->Show();
|
||||
window_ = window;
|
||||
return surface;
|
||||
}
|
||||
|
||||
sptr<Surface> TesterCommon::CreateSurfaceNormal()
|
||||
{
|
||||
sptr<Surface> consumerSurface = Surface::CreateSurfaceAsConsumer();
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include "surface.h"
|
||||
#include "wm/window.h" // foundation/window/window_manager/interfaces/innerkits/
|
||||
#include "native_avbuffer.h" // foundation/multimedia/media_foundation/interface/kits/c
|
||||
#include "buffer/avbuffer.h" // foundation/multimedia/media_foundation/interface/inner_api
|
||||
#include "native_avcodec_base.h" // foundation/multimedia/av_codec/interfaces/kits/c/
|
||||
@ -134,7 +133,6 @@ protected:
|
||||
|
||||
bool RunDecoder();
|
||||
bool InitDemuxer();
|
||||
sptr<Surface> CreateSurfaceFromWindow();
|
||||
sptr<Surface> CreateSurfaceNormal();
|
||||
virtual bool SetOutputSurface(sptr<Surface> &surface) = 0;
|
||||
void PrepareSeek();
|
||||
@ -142,7 +140,6 @@ protected:
|
||||
virtual bool ConfigureDecoder() = 0;
|
||||
int GetNextSample(const Span &dstSpan, size_t &sampleIdx, bool &isCsd); // return filledLen
|
||||
sptr<Surface> surface_; // consumer
|
||||
sptr<OHOS::Rosen::Window> window_;
|
||||
std::shared_ptr<StartCodeDetector> demuxer_;
|
||||
size_t totalSampleCnt_ = 0;
|
||||
size_t currSampleIdx_ = 0;
|
||||
|
@ -20,7 +20,6 @@ config("hcodec_unittest_cfg") {
|
||||
include_dirs = [
|
||||
"$av_codec_root_dir/../../../commonlibrary/c_utils/base/include/",
|
||||
"$av_codec_root_dir/../../../drivers/peripheral/codec/interfaces/include/",
|
||||
"$av_codec_root_dir/../../../foundation/window/window_manager/interfaces/innerkits/",
|
||||
"//third_party/openmax/api/1.1.2",
|
||||
"$av_codec_root_dir/services/engine/codec/video/hcodec/",
|
||||
"$av_codec_root_dir/test/unittest/hcodec_test/helper/",
|
||||
@ -47,7 +46,6 @@ ohos_unittest("hdecoder_unit_test") {
|
||||
"hilog:libhilog",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
|
||||
@ -69,7 +67,6 @@ ohos_unittest("hencoder_unit_test") {
|
||||
"hilog:libhilog",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
|
||||
@ -103,14 +100,12 @@ ohos_unittest("hencoder_buffer_unit_test") {
|
||||
]
|
||||
external_deps = [
|
||||
"drivers_interface_codec:libcodec_proxy_3.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
resource_config_file =
|
||||
@ -128,14 +123,12 @@ ohos_unittest("hdecoder_buffer_unit_test") {
|
||||
]
|
||||
external_deps = [
|
||||
"drivers_interface_codec:libcodec_proxy_3.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_surface:surface",
|
||||
"graphic_surface:sync_fence",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"media_foundation:media_foundation",
|
||||
"media_foundation:native_media_core",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
resource_config_file =
|
||||
|
Loading…
Reference in New Issue
Block a user