DM365 Dynamic Image Size Change Problem
E-Mail: ykjung@seyeon.co.kr
Name: YongKil JUNG
The test environment====
H/W : DM36X EVM REV-D
Video Input Source: NTSC
SDK Version: dvsdk_2_10_01_18
Application: Network Camera
Base code: dvsdk_2_10_01_18\dvsdk_demos_2_10_00_17\dm365\encode
Application Code Process: Capture [Video (H.264) & Image (JPEG)] Encode
Test Case 1
I create the Capture(Resizer) & Encoders for the size of 720x480
No dynamic change case:
The Result
No Problem: I can get the normal H.264 & JPEG image of the size 720x480
JPEG(720x480) H.264(720x480)
Test Case 2
I create the Capture(Resizer) & Encoders for the size of 352x240
No dynamic change case:
The Result
No Problem: I can get the normal H.264 & JPEG image of the size 352x240
JPEG(352x240) H.264(352x240)
Test Case 3
I create the Capture(Resizer) & Encoders for the size of 720x480
I try to dynamic change from 720x480 to 352x240 for the Capture(Resizer) & Encoders.
The Result
I got the abnormal JPEG & H.264 image of the size 352x240
I think the Y is normal but the color is not correct to image.
JPEG(352x240) H.264(352x240)
Test Case 4
I create the Capture(Resizer) & Encoders for the size of 720x480
I try to dynamic change from 720x480 to 352x240 for the Capture(Resizer) & Encoders.
I try to delete & create for JPEG & H.264 encoders when the image size is changed.
The Result
No Problem & Problem:
I can get the normal JPEG image of the size 352x240
But I can get the abnormal H.264 image of the size 352x240
I think the Y is normal but the color is not correct to image.
JPEG(352x240) H.264(352x240)
Test Case 5
Confirming the capture Data.
I try to the capture data( 4:2:0) save to file. After that, I transfer the the format to normal YUV 4:2:0
Using YUVviewer : YUVviewer-seasound79.exe
The transfer method is followed
YYYYYYYYYYYYY YYYYYYYYYYYYY
YYYYYYYYYYYYY --> YYYYYYYYYYYYY
YYYYYYYYYYYYY YYYYYYYYYYYYY
YYYYYYYYYYYYY YYYYYYYYYYYYY
CbCrCbCr CbCbCbCb
CbCrCbCr CrCrCrCr
YYYYYYYY... --> YYYYYYYY...
CbCrCbCr.... --> CbCb..... CrCr......
The Result
No Problem: I can get the normal YUV image of the size 352x240.
I can see the data is correct with color.
YUV(352x240)
My opinion.
I think the dynamic change function for image size of JPEG & H.264 Encoder has some problem.
I have the test code for this which is modified from the project "dvsdk_2_10_01_18\dvsdk_demos_2_10_00_17\dm365\encode".
So If anyone can help me, I will send the project files.
The dynamic change code for the Capture(resizer) part.
hRszOutBufCh[portId] = BufTab_getBuf(hRsBufTab[portId], bufIdx);
gfxAttrsRs.dim.width = width;
gfxAttrsRs.dim.height = height;
gfxAttrsRs.dim.x = 0;
gfxAttrsRs.dim.y = 0;
BufferGfx_setDimensions(hRszOutBufCh[portId], &gfxAttrsRs.dim));
Resize_config_2channel( hResizer,
BufTab_getBuf(Capture_getBufTab(hCapture), 0),
hRszOutBufCh[0],hRszOutBufCh[1]);
The dynamic change code for the Video(H.264) part.
h264DynParams.videncDynamicParams.inputWidth = currDim.width;
h264DynParams.videncDynamicParams.inputHeight = currDim.height;
h264DynParams.videncDynamicParams.captureWidth =
((h264DynParams.videncDynamicParams.inputWidth+31)/32)*32;
encStatus.data.buf = NULL;
encStatus.size=sizeof(VIDENC1_Status);
VIDENC1_control(hVe1->hEncode, XDM_RESET, &h264DynParams.videncDynamicParams, &encStatus);
VIDENC1_control(hVe1->hEncode, XDM_SETPARAMS, &h264DynParams.videncDynamicParams, &encStatus);
The dynamic change code for the Image(JPEG) part.
imageDynParams.inputWidth = currDim.width;
imageDynParams.inputHeight = currDim.height;
imageDynParams.captureWidth = ((imageDynParams.inputWidth+31)/32)*32;
encStatus.data.buf = NULL;
encStatus.size = sizeof(IMGENC1_Status);
IMGENC1_control(hIe1->hEncode, XDM_RESET, &imageDynParams, &encStatus);
IMGENC1_control(hIe1->hEncode, XDM_SETPARAMS, &imageDynParams, &encStatus);
END
///////////////////////////////////////////////////////////////////////////////////////////
// tiyuvconvert.c : This program is made for TI 4:2:0 YUV to normal 4:2:0 YUV
//
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char* argv[])
{
FILE *inputfp = NULL;
FILE *outputfp = NULL;
int width;
int height;
int pixels;
int idx;
unsigned char * pBuffer;
if (argc!=5)
{
fprintf(stderr, "Usage : %s <input file name> <output file name> <width> <height>\n",argv[0]);
return -1;
}
width = atoi(argv[3]);
height = atoi(argv[4]);
if(width <= 0 || height <= 0)
{
fprintf(stderr, "parameter error [width = %d, height=%d]\n",width, height);
return -1;
}
inputfp = fopen(argv[1], "rb");
outputfp = fopen(argv[2], "wb");
if (!inputfp)
{
fprintf(stderr, "fopen failed for input file[%s]\n",argv[1]);
return -1;
}
if (!outputfp)
{
fprintf(stderr, "fopen failed for output file[%s]\n",argv[2]);
return -1;
}
pixels = width * height;
pBuffer = (unsigned char *)malloc(pixels);
// Read Y
fread (pBuffer, pixels, sizeof(unsigned char), inputfp);
// Write Y
fwrite(pBuffer, pixels, sizeof(unsigned char), outputfp);
// Read Cb Cr
fread (pBuffer, (pixels/2), sizeof(unsigned char), inputfp);
// Write Cb
for(idx = 0; idx < (pixels/2); idx+=2)
{
fwrite((pBuffer + idx), 1, sizeof(unsigned char), outputfp);
}
// Write Cr
for(idx = 1; idx < (pixels/2); idx+=2)
{
fwrite((pBuffer + idx), 1, sizeof(unsigned char), outputfp);
}
fclose(inputfp);
fclose(outputfp);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////