Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pointers FFMPEG:将YUV数据映射到解码函数的输出缓冲区_Pointers_Video_Ffmpeg_Yuv - Fatal编程技术网

Pointers FFMPEG:将YUV数据映射到解码函数的输出缓冲区

Pointers FFMPEG:将YUV数据映射到解码函数的输出缓冲区,pointers,video,ffmpeg,yuv,Pointers,Video,Ffmpeg,Yuv,我正在修改FFMPEG的视频解码器代码。解码代码的格式为YUV420。我有3个指针,每个指针指向Y、U和V数据,即: yPtr-> is a pointer pointing to the Luma uPtr-> is a pointer pointing to the Chroma Cb vPtr-> is a pointer pointing to the Chroma Cr 但是,我需要映射YUV数据的输出指针的类型是void。输出指针只有一个 i、 e:void*da

我正在修改FFMPEG的视频解码器代码。解码代码的格式为YUV420。我有3个指针,每个指针指向Y、U和V数据,即:

yPtr-> is a pointer pointing to the Luma
uPtr-> is a pointer pointing to the Chroma Cb
vPtr-> is a pointer pointing to the Chroma Cr
但是,我需要映射YUV数据的输出指针的类型是void。输出指针只有一个

i、 e:
void*data
是我需要指向其
yPtr、uPtr和vPtr
的输出指针。我该怎么做

我尝试过的一种方法是,创建一个新的缓冲区,其大小等于Y、U和V数据之和,并将yPtr、uPtr和vPtr的内容复制到新分配的缓冲区,并将指向该缓冲区的指针分配到
*data
输出指针

但是,这种方法并不可取,因为需要执行memcpy和其他性能缺陷

谁能为这个问题提出一个替代方案。这可能与FFMPEG没有直接关系,但因为我正在修改FFMPEG的libavcodec的解码器代码,所以我在FFMPEG中标记它

编辑:我正在尝试做什么:

实际上,我的理解是,如果我将此指针指向任何解码器的任何解码函数的
void*data
指针,并将
*got_frame\u ptr
设置为1,框架将负责将此数据转储到yuv文件中。我的理解正确吗

我的自定义视频解码器或ffmpeg中的任何视频解码器的功能原型如下所示:

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

我指的是这篇文章,假设我需要将*数据指向我的YUV数据指针,而转储内容将由ffmpeg处理。请提供重新评分的建议。

您做错了什么。您没有解释为什么需要将平面映射到单个指针。你想通过这样做来完成什么,因为没有理由需要这样做。您是否正在尝试将平面格式转换为非平面格式(如YUYV或RGB)?如果是这样,则比memcpy更复杂,需要对字节进行交织。您可以使用libswscale实现这一点

更新:

首先,你的原型是错误的。正确的答案是

static int cook_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
这在您链接的问题中得到了回答。 接下来,void*数据指向一个AVFrame

static int decode_frame(AVCodecContext *avctx, void *data,
                        int *got_frame, AVPacket *avpkt)
{
    ...
    AVFrame *pict      = data;
    ...
}
和vorbidec.c

static int vorbis_decode_frame(AVCodecContext *avctx, void *data,
                               int *got_frame_ptr, AVPacket *avpkt)
{
    ...
    AVFrame *frame     = data;
    ...
}
这个例子把你提到的问题联系起来

static int cook_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
{
      AVFrame *frame     = data;
...
}

谢谢你的回答。但我这么做的原因是,ffmpeg框架提供的指针只是其中之一。我需要使这个指针指向我的输出帧数据。uotput帧是Y、U和V数据的组合。Ffmpeg从不只是“提供”指针。您需要分配一个包含一个的结构。你想填充什么指针?数据包?你错过了一个步骤,如果没有说清楚你想要完成什么,你的问题是不可能回答的。