Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5编码AWVideoEncoder 新接口异常问题 #20

Open
lion117 opened this issue Jul 25, 2023 · 0 comments
Open

T5编码AWVideoEncoder 新接口异常问题 #20

lion117 opened this issue Jul 25, 2023 · 0 comments

Comments

@lion117
Copy link

lion117 commented Jul 25, 2023

背景

  1. 使用T517 AWCodec进行编码H264
  2. 旧的接口可正常编码, 新的接口异常
#旧接口--可正常使用
DPRCT_W virtual int encode(const void* inputBuf, unsigned int inputLen,
                               void* outputBuf, unsigned int outputLen) = 0;

# 新接口---编码H264异常
virtual int encode(AVPacket* inPacket) = 0;

使用上述接口编码NV12->H264. 可以正常工作. 但根据官方提示, 该接口已废弃. 推荐使用新的接口

新接口代码演示

// init part

 if (!m_avPacket )
    {
        m_avPacket = (AVPacket*)calloc(1,sizeof(AVPacket));
        if (!m_avPacket->pAddrVir0)
        {
            int32_t frameSize = encode_param_.srcW * encode_param_.srcH *1.5;
            m_avPacket->pAddrVir0 = (unsigned char* )calloc(frameSize, sizeof(int8_t));
            m_avPacket->pAddrVir1 = m_avPacket->pAddrVir0+ encode_param_.srcW * encode_param_.srcH;
        }    
    }

 p_encoder_ = AWVideoEncoder::create();
  p_encoder_->init(&encode_param_,this);


int32_t Encoder::EncodeFrame(int8_t *buff, uint32_t buffSize, int64_t pts, int32_t format)
{

    if (buff == NULL || !m_avPacket)
    {
    	PLOGE.printf("raw image data is null and return!\n");
    	return -1;
    }
    static int64_t frameIndex  =0;
    m_avPacket->id = frameIndex ++;
    m_avPacket->pts = pts;
    int32_t frameUint = encode_param_.srcW * encode_param_.srcH ;
    m_avPacket->dataLen0  = frameUint;
    m_avPacket->dataLen1  = frameUint/2;
    memcpy(m_avPacket->pAddrVir0 ,  buff,frameUint*1.5);
    // memcpy(m_avPacket->pAddrVir1 ,  buff+frameUint,frameUint/2);
    int32_t ret =  p_encoder_->encode(m_avPacket);
    LOGI("encode input    pts:%d , index:%d result:%d", buffSize, pts, m_avPacket->id,ret);
    
}

替换使用新的接口, 编码第二帧数据的时候, 编码器内部一直提示一下错误

编码器内部报错

ERROR  : cedarc <ReturnOneAllocateInputBuffer:424>: this buffer isn't allocate buffer,can't return
ERROR  : cedarc <ReturnOneAllocInputBuffer:390>: ReturnOneAllocInputBuffer failed

根据提示信息大意为未分配内存. 但实际输入的avpacket已经正常分配内存.

1. 这个问题是SDKbug? 还是外部接口调用需要修改?

2. 官方提供的是一个jpg编码的demo, 能否提供一个H264编码的用法?

@lion117 lion117 changed the title T5编码AWCodec 新接口异常问题 T5编码AWVideoEncoder 新接口异常问题 Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant