Skip to content

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

@lion117

Description

@lion117

背景

  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编码的用法?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions