您尚未登录。

楼主 # 2024-05-17 11:42:15

memory
会员
注册时间: 2021-08-11
已发帖子: 458
积分: 434

硬件解码器API接口对比(google decoder,allwinner decoder)

转载: https://geek.csdn.net/65e5982f9a0b6f536f0c0e36.html

Google Decoder API

/* Decoder client interface. */
typedef void* ClientInst; /* Opaque pointer to the client. */

/* Function to notify the client that decoder has successfully initialized. */
typedef void ClientInitialized(ClientInst inst);
/* Function to notify about successful decoding of the stream parameters.
 * Decoder expects client to provide needed buffers through DecSetPictureBuffers
 * function to continue decoding the actual stream. */
typedef void ClientHeadersDecoded(ClientInst inst,
                                  struct DecSequenceInfo sequence_info);
/* Function to notify client that a buffer has been consumed by the decoder and
 * it can be handled freely by the client. */
typedef void ClientBufferDecoded(ClientInst inst, struct DecInput* input);
typedef void ClientStreamDecoded(ClientInst inst);
/* Function to notify about successful decoding of a picture.
 * This is just a notification, no action expected from client. */
typedef void ClientPictureDecoded(ClientInst inst,
                                  struct DecDecodedPictureInfo info);
/* Function to notify about picture that is ready to be output. Client is
 * expected to notify the decoder when it has finished processing the picture,
 * so decoder can reuse the picture buffer for another picture.
 * picture_secondary may be used again with show_existing_frame so it should
 * not be modified in the callback function */
typedef void ClientPictureReady(ClientInst inst, struct DecPicture picture,
                                struct DecPicture picture_secondary);
/* Function to notify the client that all the pending pictures have been
 * outputted and decoder can be safely shut down. */
typedef void ClientEndOfStream(ClientInst inst);
/* Function to notify the client that decoder has shut down. */
typedef void ClientReleased(ClientInst inst);
/* Function to notify client about error in the decoding process. */
typedef void ClientNotifyError(ClientInst inst, u32 pic_id, enum DecRet rv);

/* Datatype to package information about client instance for decoder's use. */
struct DecClientHandle {
  ClientInst client;
  ClientInitialized* Initialized;
  ClientHeadersDecoded* HeadersDecoded;
  ClientBufferDecoded* BufferDecoded;
  ClientStreamDecoded* StreamDecoded;
  ClientPictureDecoded* PictureDecoded;
  ClientPictureReady* PictureReady;
  ClientEndOfStream* EndOfStream;
  ClientReleased* Released;
  ClientNotifyError* NotifyError;
};

/* Decoder interface. */
typedef const void* DecInst; /* Opaque pointer to the decoder instance. */

/* Function to query build information about the software and hardware build of
 * the underlying hardware decoder. */
struct DecSwHwBuild DecGetBuild(void);

/* Function to initialize the decoder. Functionality provided by the client to
 * the component are collected into the callbacks parameter. Client is expected
 * to outlive the decoder component, i.e. the callbacks and instance given in
 * callbacks parameter must be valid until client has successfully executed
 * a call to DecRelease function. */
enum DecRet DecInit(enum DecCodec codec, DecInst* decoder,
                    struct DecConfig config, struct DecClientHandle callbacks,
                    void *cwl);

/* Function to dispatch a buffer containing video bitstream to be decoded by the
 * component. Buffer can be reused after the function has returned, during the
 * call the buffer must not be written into. */
enum DecRet DecDecode(DecInst dec_inst, const struct DecInput* input);

/* Function to assign picture buffers for the decoder. When decoder has finished
 * decoding the stream headers and knows which types of buffers and how many of
 * them it will need, it will inform that through the HeadersDecoded callback.
 * Buffers must not be written into until client has successfully called
 * DecRelease or decoder has requested new set of buffers through HeadersDecoded
 * callback. */
enum DecRet DecSetPictureBuffers(DecInst dec_inst,
                                 const struct CWLLinearMem* buffers,
                                 u32 num_of_buffers);

/* Function to tell the decoder that client has finished processing a specific
 * picture that was previously sent to client through the PictureReady callback.
 */
enum DecRet DecPictureConsumed(DecInst dec_inst, struct DecPicture picture);

/* Function to tell the decoder that it should not be expecting any more input
 * stream and Finish decoding and outputting all the buffers that are currently
 * pending in the component. Once decoder has finished outputting the pending
 * pictures it will notify the client about it by calling the EndOfStream
 * callback. */
enum DecRet DecEndOfStream(DecInst dec_inst);

/* Function to release the decoder instance. When the function returns decoder
 * has released all the resources it has acquired. */
void DecRelease(DecInst dec_inst);

Awinner Deocder API

typedef void* VideoDecoder;
VideoDecoder* CreateVideoDecoder(void);
void DestroyVideoDecoder(VideoDecoder* pDecoder);
int InitializeVideoDecoder(VideoDecoder* pDecoder,
                     VideoStreamInfo* pVideoInfo,
                     VConfig* pVconfig);
void ResetVideoDecoder(VideoDecoder* pDecoder);
int DecodeVideoStream(VideoDecoder* pDecoder,
                      int           bEndOfStream,
                      int           bDecodeKeyFrameOnly,
                      int           bDropBFrameIfDelay,
                      int64_t       nCurrentTimeUs);
int RequestVideoStreamBuffer(VideoDecoder* pDecoder,
                             int           nRequireSize,
                             char**        ppBuf,
                             int*          pBufSize,
                             char**        ppRingBuf,
                             int*          pRingBufSize,
                             int           nStreamBufIndex);
int SubmitVideoStreamData(VideoDecoder*        pDecoder,
                          VideoStreamDataInfo* pDataInfo,
                          int                  nStreamBufIndex);
VideoPicture* RequestPicture(VideoDecoder* pDecoder, int nStreamIndex);
int ReturnPicture(VideoDecoder* pDecoder, VideoPicture* pPicture);

API对比分析

① 内存消耗
在输入数据方面,google dec内部没有缓存,allwiner dec有缓存;输出数据方面,两者都有缓存,在内部实现其他存储相同情况下,google dec需要更小的空间。

② 性能分析
在输出图像方面,google dec采用回调的方式通知用户可用的输出图像;而allwinner dec采用轮询的方式,通过轮询接口来查询是否有输出图像。
在输入数据方面,由于内部没有输入缓存,google dec同样采用回调方式通知用户输入buffer已被消费,从而实现异步操作;而allwinner dec由于有输入缓存,可直接实现异步。
为了实现异步,两者的实现有所不同:
google dec: 内部需实现deocder线程,才能使输入buffer已被消费的回调函数实现在另一线程上,实现异步。同理也需要一个output线程查询输出缓存,并回调给用户。
allwinner dec: 内部无任何线程,需要用户自己安排好各API所运行的线程,相应的同步机制也需要用户实现,由于缓存外部不可见,API接口只提供轮询机制,性能上有所损失。

③ 灵活性
google dec:输入缓存用户可自己设计,提高灵活性,但未提供复位操作,无法实现刷新内部缓存的操作,在需要跳播的场景,google dec无能为力。输出buffer地址只能由外部设置。
allwiner dec:提供复位操作,可实现跳播等场景。输出buffer地址可由内部申请,也可由外部设置。

④ 总结
总体来说google dec api更合理一点,将两者的优势结合一下,可以更合理。

离线

楼主 #1 2024-05-17 11:46:04

memory
会员
注册时间: 2021-08-11
已发帖子: 458
积分: 434

Re: 硬件解码器API接口对比(google decoder,allwinner decoder)

解码文件:
Video_Decoder_API_Guide.pdf

https://blog.csdn.net/TheDayIn_CSDN/article/details/86582797

视频编解码(五):解码器驱动代码理解



一、结构体定义的方法

   VideoStreamInfo mVideoInfo1 = 0;
   VideoStreamInfo *pVideoInfo1 = &mVideoInfo1;

  VideoStreamInfo *pp = (VideoStreamInfo *)malloc(sizeof(VideoStreamInfo));
   free(pp);

二、指针分配内存方法:

  int *data_count1;
  data_count1 = (int*)malloc(sizeof(int));
  memset(data_count1, 0, sizeof(int));

三、码流提取
  指针
  动态内存非配
  命名规则
  fread()/fseek()指针跳转
  fseek()

  fseek(fp,0L,SEEK_END);末尾   0L代表偏移位数(可以为负)
  fseek(fp,0L,SEEK_CUR);当前
  fseek(fp,0L,SEEK_SET);开始

  fopen(w)和fopen(ab)  ab 代表连续写


四、解码器申请内存

VideoStreamInfo mVideoInfo1;
VideoStreamInfo* pVideoInfo1 = &mVideoInfo1 ; 
pSpecilData1 = (char*)malloc(SPEC_DATA_SIZE);

五、读取码流文件

   fread(&pVideoInfo1->eCodecFormat, 1, sizeof(int), fp);

六、解码器基本数据结构

  VideoStreamInfo mVideoInfo1;
  mVideoInfo1.eCodecFormat =  VIDEO_CODEC_FORMAT_H263;  编码格式
  VConfig vConfig;
  extra frame buffer=
    vConfig.nDisplayHoldingFrameBufferNum = 5;          
    vConfig.nRotateHoldingFrameBufferNum = 5;
    vConfig.nDecodeSmoothFrameBufferNum = 5;

七、申请内存

   struct ScMemOpsS* memops = MemAdapterGetOpsS();
    vConfig.memops = memops;

八、基本数据结构
码流基本信息 :mVideoInfo1
解码器配置信息:  vConfig
InitializeVideoDecoder(pVideo, &mVideoInfo1, &vConfig)

九、请求码流

datalen: 码流数据一笔一笔
RequestVideoStreamBuffer(pVideo,
                                    dataLen,
                                    (char**)&buf,
                                    &buflen,
                                    (char**)&ringBuf,
                                    &ringBufLen,
                                    0)

buffer循环方法

 if(buflen >= dataLen)
{
   memcpy(buf,AwspData,dataLen);      //copy data to buf
}
else{
   memcpy(buf,AwspData,buflen);       //the first part of data
   memcpy(ringBuf,AwspData+buflen,dataLen - buflen);     //the left part of data
}

一笔码流数据是否开始结束

 DataInfo.bIsFirstPart = 1;
 DataInfo.bIsLastPart = 1;

VideoStreamDataInfo DataInfo; 码流数据信息
SubmitVideoStreamData(pVideo, &DataInfo, 0)
DecodeVideoStream(pVideo, endofstream, decodekeyframeonly,
                            dropBFrameifdelay, currenttimeus);

十、返回值

    VDECODE_RESULT_UNSUPPORTED       = -1,
    VDECODE_RESULT_OK                = 0,
    VDECODE_RESULT_FRAME_DECODED     = 1,
    VDECODE_RESULT_CONTINUE          = 2,
    VDECODE_RESULT_KEYFRAME_DECODED  = 3,
    VDECODE_RESULT_NO_FRAME_BUFFER   = 4,
    VDECODE_RESULT_NO_BITSTREAM      = 5,
    VDECODE_RESULT_RESOLUTION_CHANGE = 6,

(11)内存:
#ifdef  #else  #endif (如果定义执行1) 只能判断一个宏
#ifndef  #else  #endif (如果定义执行1)
DMA_HEAP(连续内存)、SYSTEM_HEAP(非连续内存)
CACHED_FLAG(自动同步)、SUNC_FLAG(手动同步)
#if  #elif  #else  #endif (判断多个宏)

离线

#2 2024-05-18 20:42:55

19chan19
会员
注册时间: 2023-04-07
已发帖子: 12
积分: 12

Re: 硬件解码器API接口对比(google decoder,allwinner decoder)

我测到,全志占用内存要20兆左右,
你测到占用多少

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn