【问题标题】:FFMPEG: Explain parameters of any codecs function pointersFFMPEG:解释任何编解码器函数指针的参数
【发布时间】:2014-07-07 18:52:05
【问题描述】:

我正在阅读这篇文章,How to integrate a codec in FFMPEG multimedia framework。 根据它,每个编解码器需要定义3个基本函数,并将这些函数分配给结构AVCodec的函数指针。

上篇文章中指定的3个函数指针分别是:

.init -> takes care of allocations and other initializations

.close -> freeing the allocated memory and de-initializations

.decode -> frame by frame decoding.

对于函数指针.decode,分配的函数为:

static int cook_decode_frame(AVCodecContext *avctx,
            void *data, int *data_size,
            uint8_t *buf, int buf_size) {
...

这些参数的细节在上面的文章中有详细说明。但是,在最新的代码中,以同样的函数为例,其声明如下:

static int cook_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)

我需要对内存进行一些映射操作。所以,我请求是否有人可以在函数声明中解释上述参数。另外,哪个参数具有用于解码帧的输入缓冲区?解码一帧后,解码后的帧映射到哪个参数?

【问题讨论】:

    标签: video ffmpeg codec decoder


    【解决方案1】:

    来自this source,看起来一般的想法是从avpkt解码音频/视频帧并将输出放入data。基本上,您的链接中 API 的最大变化就是将 buf 和 buf_size 汇总为 AVPacket。还有 got_frame_ptr 表示成功。

    【讨论】:

    • 感谢您的回答。我会接受它。还有一件事,我从哪里获取输入缓冲区?
    • 另外,我们应该在新代码的情况下返回什么?我的意思是返回类型包含哪些数据?
    • 数据将作为AVPacket结构(AVBufferRef结构)的buf成员传入。返回值是解码的数据量,可能是像 Cook 编解码器示例中的常量大小。 got_frame_ptr 看起来应该设置为 1,如果有准备好的解码帧,则设置为 0。
    猜你喜欢
    • 2013-04-14
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 2014-11-26
    • 2013-08-19
    • 1970-01-01
    相关资源
    最近更新 更多