ffmpeg:将AVPixelFormat视为Int?

时间:2014-03-16 04:46:03

标签: c++ c ffmpeg

我想使用函数ff_load_image

program.c

#include "../ffmpeg/libavfilter/lavfutils.h"

int main ()
{
  uint8_t* data;

  int linesize, width, height, log_ctx;

  int i = ff_load_image(&data, &linesize, &width, &height, AV_PIX_FMT_RGB24, "blue.jpg", &log_ctx);
}

编译,但会发出警告。

program.c: In function 'main':
program.c:11: warning: passing argument 5 of 'ff_load_image' makes pointer from integer without a cast
../ffmpeg/libavfilter/lavfutils.h:39: note: expected 'enum AVPixelFormat *' but argument is of type 'int'

当我运行程序时,它会分段错误。我想不出任何其他方式来指定像素格式。为什么ffmpeg认为AV_PIX_FMT_RGB8是一个整数?这显然是AVPixelFormat

1 个答案:

答案 0 :(得分:1)

ff_load_image()需要enum AVPixelFormat *ffmpeg认为它是一个整数,因为它是AVPixelFormatenum元素。而且,in C,枚举常量的类型为int

您应该使用:

enum AVPixelFormat pix_fmt = AV_PIX_FMT_RGB24;
int i = ff_load_image(&data, &linesize, &width, &height
                           , &pix_fmt, "blue.jpg", &log_ctx);