I’m developing a video streaming server on TX1,
and making a function to change the image resolution using NvVideoConverter.
Then I’m refering a MMAPI sample.
To analyze a sample code, I suspect that this code of initializing has a bug.
video_convert_main.cpp (MMAPI sample)
int main(int argc, char *argv)
// Set conv0 output plane format
ret = ctx.conv0->setOutputPlaneFormat(ctx.in_pixfmt, ctx.in_width,
ctx.in_height, V4L2_NV_BUFFER_LAYOUT_PITCH);
TEST_ERROR(ret < 0, "Could not set output plane format for conv0", cleanup);
if (ctx.in_buftype == BUF_TYPE_NVBL)
{
// Set conv0 capture plane format
ret = ctx.conv0->setCapturePlaneFormat(ctx.in_pixfmt, ctx.in_width,
ctx.in_height, V4L2_NV_BUFFER_LAYOUT_BLOCKLINEAR);
}
else if (ctx.out_buftype == BUF_TYPE_NVBL)
{
ret = ctx.conv0->setCapturePlaneFormat(ctx.out_pixfmt, ctx.out_width,
ctx.out_height, V4L2_NV_BUFFER_LAYOUT_BLOCKLINEAR);
}
else
{
ret = ctx.conv0->setCapturePlaneFormat(ctx.out_pixfmt, ctx.out_width,
ctx.out_height, V4L2_NV_BUFFER_LAYOUT_PITCH);
}
TEST_ERROR(ret < 0, "Could not set capture plane format for conv0", cleanup);
if (ctx.in_buftype == BUF_TYPE_NVBL)
{
// Set conv1 output plane format
ret =
ctx.conv1->setOutputPlaneFormat(ctx.in_pixfmt, ctx.in_width,
ctx.in_height, V4L2_NV_BUFFER_LAYOUT_BLOCKLINEAR);
}
else if (ctx.out_buftype == BUF_TYPE_NVBL)
{
ret =
ctx.conv1->setOutputPlaneFormat(ctx.out_pixfmt, ctx.out_width,
ctx.out_height, V4L2_NV_BUFFER_LAYOUT_BLOCKLINEAR);
}
TEST_ERROR(ret < 0, "Could not set output plane format for conv1", cleanup);
if (ctx.conv1)
{
// Set conv1 capture plane format
ret =
ctx.conv1->setCapturePlaneFormat(ctx.out_pixfmt, ctx.out_width,
ctx.out_height, V4L2_NV_BUFFER_LAYOUT_PITCH);
TEST_ERROR(ret < 0, "Could not set capture plane format for conv1",
cleanup);
}
This code:
- When the input format is BL, capturePlane of conv0 and outputPlane of conv1 are set as BL.
- When the output format is BL, capturePlane of conv0 and outputPlane of conv1 are set as BL.
- Always outputPlane of conv0 and capturePlane of conv1 are set as PITCH.
I understand that the NvVideoConverter has some limitation about BLOCK_LINEAR(BL) format.
Then this sample code use 2 NvVideoConverter objects, and one of them is used for conversion between BL and pitch.
When input and/or output format is BL, 2 NvVideoConverter are connected bellow:
Input → conv0 → conv1 → Output
Question 1:
- What is the limitation of BLOCK_LINEAR format ?
Question 2:
- Does the sample code have a bug ?
I think
- When the input format is BL, outputPlane of conv0 will be set as BL.
- When the output format is BL, capturePlane of conv1 will be set as BL.
- The other planes will be set as PITCH.