2

我有一个解码器代码。我正在尝试将其集成到ffmpeg framework.

我指的是这里给出的 HOW TO:http ://wiki.multimedia.cx/index.php?title=FFmpeg_codec_howto

根据那篇文章,我需要在我的decoder_name.c文件中定义一个结构。

示例结构如下所示:

AVCodec sample_decoder =
{
    .name           = "sample",
    .type           = AVCODEC_TYPE_VIDEO,
    .id             = AVCODEC_ID_SAMPLE,
   // .priv_data_size = sizeof(COOKContext),
    .init           = sample_decode_init,
    .close          = sample_decode_close,
    .decode         = sample_decode_frame,
};

在哪里,

.name -> specifies the short name of my decoder.

.type -> is used to specify that it is a video decoder.

.id -> is an unique id that i'm assigning to my video decoder.

.init -> is a function pointer to the function in my decoder code that performs decoder related initializations

.decode -> is a function pointer to the function in my decoder code that decodes a single frame, given the input data (elementary stream).

.close -> is a function pointer to the function in my decoder that frees all allocated memory i.e. the memory allocated in init.

但是,我的怀疑是根据上面提到的文章,还有另一个名为的字段.priv_data_size包含某些上下文的大小。

是否必须有这个字段.priv_data_size,因为根据上面的文章,我不需要定义结构的所有参数AVCodec。此外,我的解码器没有任何此类上下文。

但是,当我浏览libavcodecffmpeg 中其他可用解码器的代码时,我发现每个解码器都定义了这一点。如果我不指定,我的解码器会工作吗?因此,我无法继续。请提供一些相同的指导。

- 提前致谢。

4

1 回答 1

3

我维护您链接到的 MultimediaWiki,我可以证明编解码器 HOWTO 已过时,特别是因为 FFmpeg 一直在发展其内部接口。最好通过获取最新的 FFmpeg 源代码并研究一些最简单的编解码器来理解接口来开始您的旅程(听起来您已经这样做了)。

关于 priv_data_size:是否设置完全取决于您的编解码器是否关心维护调用之间的任何状态。大多数编解码器都关心这一点,并在其主源文件中定义了一个名为 MyCodecContext 的结构。然后sizeof()这个结构作为 priv_data_size 传递。在您发布的示例中,它是sizeof(COOKContext),因为此示例显然是从 RealAudio COOK 编解码器文件中复制的。

大多数编解码器需要维护某种状态(如指向先前帧或各种表的指针)。priv_data_size 成员告诉核心引擎为此结构分配多少空间,然后核心将该结构传递给所有编解码器调用。

于 2013-11-28T18:56:32.937 回答