ffmpeg库的sws_scale函数中的srcSliceY参数

时间:2017-06-21 07:12:03

标签: ffmpeg scale

几乎在我看的每个地方,srcSliceY值都设置为0。 在文档中,它是wrriten:

c            the scaling context previously created with sws_getContext()
srcSlice    the array containing the pointers to the planes of the source slice
srcStride   the array containing the strides for each plane of the source image
srcSliceY   the position in the source image of the slice to process, that is the number (counted starting from zero) in the image of the first row of the slice
...

我不清楚这是什么意思"源图像"。这是否意味着源切片?没有名为"源图像"。

的参数

我写了这段代码:

SwsContext *ctx = sws_getContext(width, height, AV_PIX_FMT_GRAY8,
                                         dwidth, dheight, AV_PIX_FMT_GRAY8,
                                         SWS_BILINEAR, NULL, NULL, NULL);


const uint8_t* srcSlice[1] = { pSrc};
const int srcStride[1] = { width };
int srcSliceH = height;
const int   dstStride[1] = { dwidth };

printf("srcStride=%d, height =%d\n",srcStride[0],srcSliceH);
for(int i=0;i<100;i++){
  int t = sws_scale(ctx, srcSlice, srcStride, i, srcSliceH, &pDst, dstStride);
  if(t != 0)
    printf("i=%d t= %d\n",i,t);
}

我得到了输出:

srcStride=384, height =30
[swscaler @ 0x1b0ba60] Warning: data is not aligned! This can lead to a speedloss
i=0 t= 2
i=4 t= 1
i=14 t= 1
i=24 t= 1
i=33 t= 1
i=43 t= 1
i=52 t= 1
i=62 t= 1
i=72 t= 1
i=81 t= 1
i=91 t= 1

查看sws_scale的源代码,它会在出错或输入无效时返回0。所以我得出结论,对于迭代中srcSliceY的大多数值,sws_returns错误。但目前还不清楚什么是有效的。

0 个答案:

没有答案