extern const PixFmtInfo pix_fmt_info[] 的链接问题

在ffmpeg中,大量使用了c99中的结构体成员初始化方式,如libavcodec\imgconvert.c中的一个定义:

/* this table gives more information about formats */

static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {

    /* YUV formats */

    [PIX_FMT_YUV420P] = {

        .name = "yuv420p",

        .nb_channels = 3,

        .color_type = FF_COLOR_YUV,

        .pixel_type = FF_PIXEL_PLANAR,

        .depth = 8,

        .x_chroma_shift = 1, .y_chroma_shift = 1,

    },

    [PIX_FMT_YUV422P] = {

        .name = "yuv422p",

        .nb_channels = 3,

        .color_type = FF_COLOR_YUV,

        .pixel_type = FF_PIXEL_PLANAR,

        .depth = 8,

        .x_chroma_shift = 1, .y_chroma_shift = 0,

    },

………..

};

这一段代码在vs2008下编译将产生很多语法错误,首先在这个结构体数组中,它使用了[PIX_FMT_*]这样的方式指定序号,这样数组的成员可以不必要按照顺序排列,但是在vs2008下,必须调整数组成员的顺序,使之按递增的顺序排列。此外,vs2008也不支持.name = “”这样的定义,因此可以做出如下修改:

/* this table gives more information about formats */

static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {

    /* YUV formats */

    /*[PIX_FMT_YUV420P] =*/ { // PIX_FMT_YUV420P = 0

        /*.name = */"yuv420p",

        /*.nb_channels = */3,

        /*.color_type = */FF_COLOR_YUV,

        /*.pixel_type = */FF_PIXEL_PLANAR,

         /*.is_alpha = */0,

        /*.x_chroma_shift = */1,

         /*.y_chroma_shift = */1,

        /*.depth = */8,

    },

    /*[PIX_FMT_YUYV422] =*/ {    // PIX_FMT_YUYV422 = 1

        /*.name = */"yuyv422",

        /*.nb_channels = */1,

        /*.color_type = */FF_COLOR_YUV,

        /*.pixel_type = */FF_PIXEL_PACKED,

         /*.is_alpha = */0,

        /*.x_chroma_shift = */1,

         /*.y_chroma_shift = */0,

        /*.depth = */8,

    },

    /*[PIX_FMT_RGB24] =*/ {      // PIX_FMT_RGB24 = 2

        /*.name = */"rgb24",

        /*.nb_channels = */3,

        /*.color_type = */FF_COLOR_RGB,

        /*.pixel_type = */FF_PIXEL_PACKED,

         /*.is_alpha = */0,

        /*.x_chroma_shift = */0,

         /*.y_chroma_shift = */0,

        /*.depth = */8,

    },

………….

};

转载请标明出处: http://blog.csdn.net/lights_joy/archive/2008/12/11/3500595.aspx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Qt中,sws_scale是FFmpeg库中的一个函数,用于图像的缩放和颜色空间转换。它可以将一个输入图像在不同的尺寸和格式之间进行转换。通过使用sws_scale函数,你可以实现图像的大小变换、裁剪和颜色空间转换等操作。 下面是一个使用sws_scale函数进行简单图像缩放的示例代码: ```cpp #include <QCoreApplication> #include <QImage> extern "C" { #include <libswscale/swscale.h> } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // 加载输入图像 QImage inputImage("input.jpg"); // 设置输出图像的宽度和高度 int outputWidth = 640; int outputHeight = 480; // 创建输出图像 QImage outputImage(outputWidth, outputHeight, QImage::Format_RGB888); // 创建SwScale上下文 SwsContext* swsContext = sws_getContext(inputImage.width(), inputImage.height(), AV_PIX_FMT_RGB24, outputWidth, outputHeight, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr); // 输入和输出图像数据指针 const uchar* inputBuffer[1] = { inputImage.bits() }; uchar* outputBuffer[1] = { outputImage.bits() }; // 输入和输出图像每行的步长 int inputLinesize[1] = { inputImage.width() * 3 }; int outputLinesize[1] = { outputImage.width() * 3 }; // 执行图像缩放和颜色空间转换 sws_scale(swsContext, inputBuffer, inputLinesize, 0, inputImage.height(), outputBuffer, outputLinesize); // 保存输出图像 outputImage.save("output.jpg"); // 释放SwScale上下文 sws_freeContext(swsContext); return a.exec(); } ``` 在这个例子中,我们使用了libswscale库中的sws_getContext函数创建了一个SwScale上下文,然后使用sws_scale函数进行图像的缩放和颜色空间转换。最后,我们将输出图像保存到了output.jpg文件中。 请注意,上述示例代码仅展示了一个基本的图像缩放操作,实际应用中可能还需要进行更多的参数设置和错误处理。另外,你需要在项目中添加FFmpeg和libswscale的依赖库,并在代码中引入相关的头文件。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值