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

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更合理一点,将两者的优势结合一下,可以更合理。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值