Tool/software: Code Composer Studio
Hi,
I am using the “C66x_jpegenc_02_02_03_00_ELF\packages\ti\sdo\codecs\jpegenc\lib\jpegalg_ti.le66” for image jpeg processing. I have some questions about this lib;
First, the document(SPRUHB2) says: Quantization tables are fixed with a quality factor(1--100) adjusting the quantization level . Does this means that there are fixed 100 quantization tables correspond to 100
quality factors one by one?
I have done some tests. I set quality factor to 80. Next, i use 5 different gray images(these images are raw image data that only contains LUMA ) to do jpeg encode with C66x_jpegenc_02_02_03_00_ELF.
Then ,i get 5 different jpeg files . Last ,i find that the quantization tables in the 5 different jpeg files are same. So ,i think that the quantization tables incuded by the C66x_jpegenc_02_02_03_00_ELF are fixed .
When i specify a quality factor ,the quantization table used by the lib is fixed no matter what the content of the image is. Arm i right?
Second, the document(SPRUHB2) says: Supports custon quantization tables.
But ,when i set the quantTable fied of IDMJPEG_TIGEM_DynamicParams, it does not work as what i expect. Here are some piece of my codes:
IDMJPGE_TIGEM_CustomQuantTables * IDMJPGE_TIGEM_CustomQuantTablesObj = 0;
unsigned short DQT_table[128] = {
/* LUMA (Y) */
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99,
/* CHROMA (Cb Cr) */
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
...
IDMJPGE_TIGEM_CustomQuantTablesObj = (IDMJPGE_TIGEM_CustomQuantTables *)malloc(sizeof(IDMJPGE_TIGEM_CustomQuantTables));
for(ii = 0; ii < 64; ii++)
{
IDMJPGE_TIGEM_CustomQuantTablesObj->lum_quant_tab[ii] = DQT_table[ii];
IDMJPGE_TIGEM_CustomQuantTablesObj->chm_quant_tab[ii] = DQT_table[ii+64];
}
for(ii = 0; ii < 7; ii++)
{
JPGEDynamicParams[ii].params.size = sizeof(IDMJPGE_TIGEM_DynamicParams);
JPGEDynamicParams[ii].params.inputWidth = IMAGE_WIDTH;
if (ii == 6)
{
JPGEDynamicParams[ii].params.inputHeight = SECTION_6_HEIGHT;
}
else
{
JPGEDynamicParams[ii].params.inputHeight = SECTION_0_to_5_HEIGHT;
}
JPGEDynamicParams[ii].params.inputChromaFormat = XDM_GRAY;
JPGEDynamicParams[ii].params.qValue = 100;
JPGEDynamicParams[ii].params.numAU = XDM_DEFAULT;
JPGEDynamicParams[ii].params.captureWidth = 0;
JPGEDynamicParams[ii].captureHeight = 0;
JPGEDynamicParams[ii].DRI_Interval = 0;
JPGEDynamicParams[ii].quantTable = IDMJPGE_TIGEM_CustomQuantTablesObj;//NULL
JPGEDynamicParams[ii].Thumbnail_Index_App0 = 0;
JPGEDynamicParams[ii].Thumbnail_Index_App1 = 0;
JPGEDynamicParams[ii].Thumbnail_Index_App13 = 0;
JPGEDynamicParams[ii].Thumbnail_H_size_App1 = 0;
JPGEDynamicParams[ii].Thumbnail_V_size_App1 = 0;
JPGEDynamicParams[ii].Thumbnail_H_size_App0 = 0;
JPGEDynamicParams[ii].Thumbnail_V_size_App0 = 0;
JPGEDynamicParams[ii].Thumbnail_H_size_App13 = 0;
JPGEDynamicParams[ii].Thumbnail_V_size_App13 = 0;
JPGEDynamicParams[ii].APPN0_numBufs = 0;
JPGEDynamicParams[ii].APPN1_numBufs = 0;
JPGEDynamicParams[ii].APPN13_numBufs = 0;
JPGEDynamicParams[ii].APPN0_startBuf = 0;
JPGEDynamicParams[ii].APPN1_startBuf = 0;
JPGEDynamicParams[ii].APPN13_startBuf = 0;
JPGEDynamicParams[ii].COMMENT_insert = 0;
JPGEDynamicParams[ii].COMMENT_startBuf = 0;
dynamicParams[ii] = (IIMGENC1_DynamicParams *)&JPGEDynamicParams[ii];
dynamicParams[ii]->generateHeader = XDM_ENCODE_AU;
}
...
for(ii = 0; ii < 7; ii++)
{
if ((handle[ii] = (IALG_Handle)ALG_create ( (IALG_Fxns *) &DMJPGE_TIGEM_IDMJPGE, (IALG_Handle) NULL, (IALG_Params *) params[ii])) == NULL)
{
printf("Failed to Create Instance... Exiting for this configuration..\n\n");
return -1;
}
IIMGENC1fxns = (IIMGENC1_Fxns *)handle[ii]->fxns ;
handle[ii]->fxns->algActivate(handle[ii]);
IIMGENC1fxns->control((IIMGENC1_Handle)handle[ii], XDM_SETPARAMS, (IIMGENC1_DynamicParams *)dynamicParams[ii], (IIMGENC1_Status *)status[ii]);
IIMGENC1fxns->control((IIMGENC1_Handle)handle[ii], XDM_GETBUFINFO,(IIMGENC1_DynamicParams *)dynamicParams[ii], (IIMGENC1_Status *)status[ii]);
handle[ii]->fxns->algDeactivate(handle[ii]);
}
Cache_wbAll();
...
But quantization table in the result jpeg file is not the same as DQT_table. It looks like that the custom quantization table have no affect about the lib. Who can point out where is wrong?
Third, I have a issue and i can not find what happened when i use this lib to do jpeg encode process with IPC.
1. capture camera raw data to core 0; //data format : Y Y Y Y...
2.split the raw data to 8 piece( vertical dirction,for example if the origion image size is 1024*800, then the size of every piece is 1024*100);
3.Send 8 pieces of data to 8 cores (one piece of data correspond to one core) using ipc.
4.Every core do its jpeg encode task with its own piece of data. The quality factor for every core is 80.
5. Every core sends its result (jpeg file) to core 0 using ipc.
6. core 0 merge these jpeg files to a big, complete jpeg file, then send it to PC.
Initially, the steps described above work fine, but when i change the camera's resolution, the result is not correct. For example, core 0 generates 0.jpg, core 1 generates 1.jpg and so on.
It often happens that the quantization tables in these 8 jpeg files is not the same. For example ,0.jpg , 1.jpg, 2.jpg,3.jpg, 5.jpg, 6.jpg,7.jpg have the save quantization table,and 4.jpg has another quantization table. Who can tell me what happened?
Thanks!