【问题标题】:Scaling YUV420P with libswscale - getting gray image out使用 libswscale 缩放 YUV420P - 输出灰色图像
【发布时间】:2013-04-23 14:22:56
【问题描述】:

我对YUV420p数据的格式有了基本的了解。我知道它在平面上,并且 Y 数据基本上是黑白亮度,长度应该是宽度*高度像素。

我认为每个平面的 U 和 V 平面的尺寸为宽*高/4。

因此,有了所有这些知识,我正在尝试使用 libswscale 缩放 yuv420p 图像。输出图像是灰色的,就像我缺少 U 和 V 平面一样。

这就是我正在做的事情:

  int src_stride[3] = {0, 0, 0};
  src_stride[0] = mInputWidth;
  src_stride[1] = mInputWidth / 4;
  src_stride[2] = mInputWidth / 4;


  const uint8_t *input_planes[3];
  input_planes[0] = input.GetData(); // returns pointer to image data
  input_planes[1] = input_planes[0] + (mInputWidth * mInputHeight);
  input_planes[2] = input_planes[0] + (mInputWidth * mInputHeight) + (mInputWidth * mInputHeight / 4); 


  int scale_rc = sws_scale(mSwsEncodeContext, input_planes,
                       src_stride, 0, mInputHeight, mEncodeAvFrame->data,
                       mEncodeAvFrame->linesize);

知道我是在搞砸 src_stride 还是 input_planes?

【问题讨论】:

  • 通常,如果问题是空洞的、没有提供足够的信息或没有正确的标签,问题就会得不到解答。这里是这样吗?

标签: image-processing ffmpeg yuv libavcodec


【解决方案1】:

上面的代码对于缩放 YUV420P 数据是正确的。原来我的数据不是 YUV420P 而是 NV21,它的大小相同,但是 U 和 V 数据不在不同的平面上,它们在 1 个平面上并且是交错的。

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 1970-01-01
    • 2013-01-31
    • 2014-12-12
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    相关资源
    最近更新 更多