mirror of
https://gitee.com/openharmony/multimedia_av_codec
synced 2025-03-01 12:55:36 +00:00
告警修改、多余日志清理
Signed-off-by: lzm <linziming2@huawei.com> Change-Id: I5b741353c53efd624343163d178db0aa1220c2e3
This commit is contained in:
parent
e4eeaa6d0c
commit
8c84370ed6
@ -17,7 +17,6 @@
|
||||
#include "avcodec_trace.h"
|
||||
#include "avcodec_errors.h"
|
||||
#include "avcodec_log.h"
|
||||
#include "common/log.h"
|
||||
#include "i_avcodec_service.h"
|
||||
|
||||
namespace {
|
||||
@ -156,7 +155,6 @@ int32_t AVCodecVideoDecoderImpl::Release()
|
||||
|
||||
int32_t AVCodecVideoDecoderImpl::SetOutputSurface(sptr<Surface> surface)
|
||||
{
|
||||
MEDIA_LOG_I("AVCodecVideoDecoderImpl::SetOutputSurface");
|
||||
CHECK_AND_RETURN_RET_LOG(codecClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "Codec service is nullptr");
|
||||
|
||||
AVCODEC_SYNC_TRACE;
|
||||
|
@ -281,7 +281,7 @@ void BufferConverter::SetFormat(const Format &format)
|
||||
AVCODEC_LOGW("Invalid format:%{public}s", format.Stringify().c_str());
|
||||
return;
|
||||
}
|
||||
AVCODEC_LOGI(
|
||||
AVCODEC_LOGD(
|
||||
"Actual:(%{public}d x %{public}d), Converter:(%{public}d x %{public}d), Hardware:(%{public}d x %{public}d).",
|
||||
width, rect_.hStride, usrRect_.wStride, usrRect_.hStride, hwRect_.wStride, hwRect_.hStride);
|
||||
}
|
||||
@ -366,6 +366,7 @@ bool BufferConverter::SetBufferFormat(std::shared_ptr<AVBuffer> &buffer)
|
||||
{
|
||||
CHECK_AND_RETURN_RET_LOG(buffer != nullptr, false, "buffer is nullptr");
|
||||
if (buffer->memory_ == nullptr) {
|
||||
isSharedMemory_ = true;
|
||||
AVCODEC_LOGW("memory is nullptr");
|
||||
return true;
|
||||
}
|
||||
@ -417,7 +418,7 @@ inline int32_t BufferConverter::CalculateUserStride(const int32_t widthHeight)
|
||||
return modVal ? (widthHeight + OFFSET_16 - modVal) : widthHeight;
|
||||
}
|
||||
|
||||
int32_t BufferConverter::GetSliceHeightFromSurfaceBuffer(sptr<SurfaceBuffer> &surfaceBuffer)
|
||||
int32_t BufferConverter::GetSliceHeightFromSurfaceBuffer(sptr<SurfaceBuffer> &surfaceBuffer) const
|
||||
{
|
||||
int32_t height = surfaceBuffer->GetHeight();
|
||||
if (isEncoder_) {
|
||||
@ -429,9 +430,9 @@ int32_t BufferConverter::GetSliceHeightFromSurfaceBuffer(sptr<SurfaceBuffer> &su
|
||||
AVCODEC_LOGW("get plane info failed, GSError=%{public}d", err);
|
||||
return height;
|
||||
}
|
||||
int32_t count = planes->planeCount;
|
||||
uint32_t count = planes->planeCount;
|
||||
if (count <= 1) {
|
||||
AVCODEC_LOGW("planes count is %{public}d", count);
|
||||
AVCODEC_LOGW("planes count is %{public}u", count);
|
||||
return height;
|
||||
}
|
||||
return static_cast<int32_t>(static_cast<int64_t>(planes->planes[1].offset) / surfaceBuffer->GetStride());
|
||||
|
@ -55,8 +55,9 @@ private:
|
||||
bool SetBufferFormat(std::shared_ptr<AVBuffer> &buffer);
|
||||
bool SetRectValue(const int32_t width, const int32_t height, const int32_t wStride,
|
||||
const int32_t hStride);
|
||||
int32_t CalculateUserStride(const int32_t widthHeight);
|
||||
int32_t GetSliceHeightFromSurfaceBuffer(sptr<SurfaceBuffer> &surfaceBuffer);
|
||||
int32_t GetSliceHeightFromSurfaceBuffer(sptr<SurfaceBuffer> &surfaceBuffer) const;
|
||||
|
||||
static int32_t CalculateUserStride(const int32_t widthHeight);
|
||||
std::function<int32_t(uint8_t *, uint8_t *, AVCodecRect *, int32_t)> func_;
|
||||
AVCodecRect rect_;
|
||||
AVCodecRect hwRect_;
|
||||
|
@ -82,7 +82,13 @@ public:
|
||||
void ClearCaches()
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> lock(mutex_);
|
||||
caches_.clear();
|
||||
for (auto iter = caches_.begin(); iter != caches_.end();) {
|
||||
if (iter->second.expired()) {
|
||||
iter = caches_.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -60,21 +60,19 @@ public:
|
||||
CodecBufferCache() = default;
|
||||
~CodecBufferCache() = default;
|
||||
|
||||
void ReadFromParcel(uint32_t index, MessageParcel &parcel, BufferElem &elem,
|
||||
bool ReadFromParcel(uint32_t index, MessageParcel &parcel, BufferElem &elem,
|
||||
const UpdateFilter filter = ELEM_GET_AVBUFFER)
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> lock(mutex_);
|
||||
auto iter = caches_.find(index);
|
||||
flag_ = static_cast<CacheFlag>(parcel.ReadUint8());
|
||||
if (flag_ == CacheFlag::HIT_CACHE) {
|
||||
if (iter == caches_.end()) {
|
||||
AVCODEC_LOGE("Mark hit cache, but can find the index's cache, index: %{public}u", index);
|
||||
return;
|
||||
}
|
||||
CHECK_AND_RETURN_RET_LOG(iter != caches_.end(), false,
|
||||
"Mark hit cache, but can find the index's cache, index: %{public}u", index);
|
||||
iter->second.owner = OWNED_BY_USER;
|
||||
isOutput_ ? HitOutputCache(iter->second, parcel, filter) : HitInputCache(iter->second, parcel, filter);
|
||||
elem = iter->second;
|
||||
return;
|
||||
return CheckReadFromParcelResult(elem, filter);
|
||||
}
|
||||
if (flag_ == CacheFlag::UPDATE_CACHE) {
|
||||
elem.owner = OWNED_BY_USER;
|
||||
@ -86,14 +84,14 @@ public:
|
||||
iter->second = elem;
|
||||
PrintLogOnUpdateBuffer(index);
|
||||
}
|
||||
return;
|
||||
return CheckReadFromParcelResult(elem, filter);
|
||||
}
|
||||
// invalidate cache flag_
|
||||
if (iter != caches_.end()) {
|
||||
caches_.erase(iter);
|
||||
}
|
||||
AVCODEC_LOGE("Invalidate cache for index: %{public}u, flag: %{public}hhu", index, flag_);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetBufferElem(uint32_t index, BufferElem &elem)
|
||||
@ -271,6 +269,25 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckReadFromParcelResult(const BufferElem &elem, const UpdateFilter filter)
|
||||
{
|
||||
switch (filter) {
|
||||
case ELEM_GET_AVBUFFER:
|
||||
return true;
|
||||
case ELEM_GET_AVMEMORY:
|
||||
return elem.buffer != nullptr;
|
||||
case ELEM_GET_PARAMETER:
|
||||
return elem.buffer != nullptr && elem.parameter != nullptr;
|
||||
case ELEM_GET_ATRRIBUTE:
|
||||
return elem.buffer != nullptr && elem.parameter != nullptr && elem.attribute != nullptr;
|
||||
default:
|
||||
AVCODEC_LOGE("unknown filter:%{public}d", static_cast<int32_t>(filter));
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
enum class CacheFlag : uint8_t {
|
||||
HIT_CACHE = 1,
|
||||
UPDATE_CACHE,
|
||||
@ -396,27 +413,31 @@ void CodecListenerStub::OnInputBufferAvailable(uint32_t index, MessageParcel &da
|
||||
BufferElem elem;
|
||||
std::shared_ptr<MediaCodecParameterCallback> paramCb = paramCallback_.lock();
|
||||
if (paramCb != nullptr) {
|
||||
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_PARAMETER);
|
||||
bool ret = inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_PARAMETER);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
paramCb->OnInputParameterAvailable(index, elem.parameter);
|
||||
elem.buffer->meta_ = elem.parameter->GetMeta();
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<MediaCodecParameterWithAttrCallback> attrCb = paramWithAttrCallback_.lock();
|
||||
if (attrCb != nullptr) {
|
||||
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_ATRRIBUTE);
|
||||
bool ret = inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_ATRRIBUTE);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
attrCb->OnInputParameterWithAttrAvailable(index, elem.attribute, elem.parameter);
|
||||
elem.buffer->meta_ = elem.parameter->GetMeta();
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<MediaCodecCallback> mediaCb = videoCallback_.lock();
|
||||
if (mediaCb != nullptr) {
|
||||
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
|
||||
bool ret = inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
mediaCb->OnInputBufferAvailable(index, elem.buffer);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
|
||||
if (cb != nullptr) {
|
||||
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
|
||||
bool ret = inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
cb->OnInputBufferAvailable(index, elem.memory);
|
||||
return;
|
||||
}
|
||||
@ -427,13 +448,15 @@ void CodecListenerStub::OnOutputBufferAvailable(uint32_t index, MessageParcel &d
|
||||
BufferElem elem;
|
||||
std::shared_ptr<MediaCodecCallback> mediaCb = videoCallback_.lock();
|
||||
if (mediaCb != nullptr) {
|
||||
outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
|
||||
bool ret = outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
mediaCb->OnOutputBufferAvailable(index, elem.buffer);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
|
||||
if (cb != nullptr) {
|
||||
outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
|
||||
bool ret = outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
|
||||
CHECK_AND_RETURN_LOG(ret, "read from parel failed");
|
||||
std::shared_ptr<AVBuffer> &buffer = elem.buffer;
|
||||
AVCodecBufferInfo info;
|
||||
info.presentationTimeUs = buffer->pts_;
|
||||
@ -473,6 +496,12 @@ void CodecListenerStub::ClearListenerCache()
|
||||
outputBufferCache_->ClearCaches();
|
||||
}
|
||||
|
||||
void CodecListenerStub::PrintListenerCache()
|
||||
{
|
||||
inputBufferCache_->PrintCachesInfo();
|
||||
outputBufferCache_->PrintCachesInfo();
|
||||
}
|
||||
|
||||
bool CodecListenerStub::WriteInputMemoryToParcel(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag,
|
||||
MessageParcel &data)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
void SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback);
|
||||
|
||||
void ClearListenerCache();
|
||||
void PrintListenerCache();
|
||||
bool WriteInputParameterToParcel(uint32_t index, MessageParcel &data);
|
||||
bool WriteInputBufferToParcel(uint32_t index, MessageParcel &data);
|
||||
bool WriteInputMemoryToParcel(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, MessageParcel &data);
|
||||
|
@ -140,6 +140,7 @@ int32_t CodecServiceProxy::Flush()
|
||||
|
||||
int32_t ret = Remote()->SendRequest(static_cast<uint32_t>(CodecServiceInterfaceCode::FLUSH), data, reply, option);
|
||||
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "Send request failed");
|
||||
static_cast<CodecListenerStub *>(listener_.GetRefPtr())->PrintListenerCache();
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user