Hi,
I want to know how to set the output resolution of the encoder used in EVM c6678 (in sv04 demo...).
e.g i am using 1080 p input video resolution and i want cif video @30fps at output...
Thanks & Regards
Tushar
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I want to know how to set the output resolution of the encoder used in EVM c6678 (in sv04 demo...).
e.g i am using 1080 p input video resolution and i want cif video @30fps at output...
Thanks & Regards
Tushar
Hi Tushar, In order to scale the image you will need to use the TSU component. On the other hand if you want to change encoder parameters, unfortunately currently they are not exposed so you need to modify the dynamic params in the client.c file (ex: vctH264EncClient.c which is located in mcsdk_video_2_0_0_10\dsp\siu\vct\codec\encoder\h264). After modifications you will need to rebuild sv04. Make instruction for rebuilding could be found at: http://processors.wiki.ti.com/index.php/MCSDK_VIDEO_2.0_CODEC_TEST_FW_User_Guide
Below a code snapshot of the dynamic params :
void h264SetDynamicParams(void *h264EncInst, void *dynParams)
{
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
IH264VENC_DynamicParams *extn_dynpar = &inst->extn_dynamicParams;
IVIDENC_DynamicParams *dynamicParams = &extn_dynpar->videncDynamicParams;
IVIDENC_Params *params = (IVIDENC_Params *)dynParams;
memset((void *)dynamicParams, 0, sizeof(IH264VENC_DynamicParams));
dynamicParams->size =sizeof (IH264VENC_DynamicParams);
dynamicParams->inputHeight = params->maxHeight ;
dynamicParams->inputWidth = params->maxWidth ;
dynamicParams->refFrameRate = params->maxFrameRate ;
dynamicParams->targetFrameRate = params->maxFrameRate ;
dynamicParams->targetBitRate = params->maxBitRate ;
dynamicParams->intraFrameInterval = 30;
dynamicParams->generateHeader = 0;
dynamicParams->captureWidth = 0;
dynamicParams->forceIFrame = IVIDEO_I_FRAME;
Thank you
Paula
Hi Paula,
I had tried to make changes in params->maxHeight, params->maxWidth but i got output distorted i.e there was no change in resolution but only some part of video was some what clear.
I think i dint understand were to make changes in order to set encoded video resolution to cif.
Thanks
Tushar
Hi Tushar, I am attaching a modified vctH264EncClient.c, please look for //PC--
/******************************************************************************
* FILE PURPOSE: Client Wrapper to integrate XDM0.9 Compliant Encoder to TVCT
******************************************************************************
* FILE NAME: vctH264EncClient.c
*
* DESCRIPTION: Client Wrapper to integrate XDM0.9 Compliant Encoder to TVCT
*
* TABS: NONE
*
*
* (C) Copyright 2010, Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "vctH264EncClient.h"
#include <string.h>
void *h264GetStaticParams(void *h264EncInst) {
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->extn_params);
}
void *h264GetDynamicParams(void *h264EncInst){
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->extn_dynamicParams);
}
void *h264GetInArgs(void *h264EncInst) {
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->inArgs);
}
void *h264GetOutArgs(void *h264EncInst) {
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->outArgs);
}
void *h264GetStatus(void *h264EncInst) {
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->status);
}
void *h264GetFxns(void *h264EncInst) {
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
return((void *)&inst->IALG_Fxns);
}
void h264InitInstance(void *h264EncInst)
{
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
memset(inst, 0, sizeof(h264EncInst_t));
inst->IALG_Fxns = H264VENC_TI_IH264VENC;
inst->status.videncStatus.size = sizeof(IH264VENC_Status);
inst->inArgs.videncInArgs.size = sizeof(IH264VENC_InArgs);
inst->outArgs.videncOutArgs.size = sizeof(IH264VENC_OutArgs);
return;
}
extern volatile tulong hdResolution;
void h264SetStaticParams(void *h264EncInst, void *codecParams)
{
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
IH264VENC_Params *ext_params = &(inst->extn_params);
IVIDENC_Params *params = &ext_params->videncParams;
params->size = sizeof(IH264VENC_Params);
if(codecParams != NULL) {
memcpy(ext_params,codecParams,sizeof(IH264VENC_Params));
} else {
params->encodingPreset = 3;
params->rateControlPreset = 1;
params->maxHeight = 1088;
params->maxWidth = 1920;
//PC-- original
//params->maxFrameRate = 30000;
params->maxFrameRate = 60000;
params->maxBitRate = 15000000;
params->dataEndianness = 1;
params->maxInterFrameInterval = 0;
params->inputChromaFormat = 1;
params->inputContentType = 0;
ext_params->profileIdc = 66;
ext_params->rcAlgo = 4;
ext_params->mcVidEncParams = &(inst->mcParams);
if(hdResolution == 1080) {
ext_params->levelIdc = 40;
ext_params->searchRange = 64;
} else if(hdResolution == 720) {
ext_params->levelIdc = 31;
ext_params->searchRange = 64;
} else {
ext_params->searchRange = 16;
ext_params->levelIdc = 30;
}
}
return;
}
extern void shipOutNal ( XDAS_Int32 *pNalu, XDAS_Int32 *pPacketSizeInBytes);
//PC-- Commented by
//volatile tuint image_height = 360;
//volatile tuint image_width = 640;
//volatile tuint frame_rate = 59940;
//volatile tuint intra_frame_interval=15;
//volatile tulong bit_rate = 3000000;
void h264SetDynamicParams(void *h264EncInst, void *dynParams)
{
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
IH264VENC_DynamicParams *extn_dynpar = &inst->extn_dynamicParams;
IVIDENC_DynamicParams *dynamicParams = &extn_dynpar->videncDynamicParams;
IVIDENC_Params *params = (IVIDENC_Params *)dynParams;
memset((void *)dynamicParams, 0, sizeof(IH264VENC_DynamicParams));
dynamicParams->size = sizeof(IH264VENC_DynamicParams);
//PC-- test
dynamicParams->inputHeight = 360;
dynamicParams->inputWidth = 640;
dynamicParams->refFrameRate = 25000;
dynamicParams->targetFrameRate = 25000;
dynamicParams->targetBitRate = 2500000;
dynamicParams->intraFrameInterval = 12;
//PC-- original, commented by
//dynamicParams->inputHeight = image_height ;
//dynamicParams->inputWidth = image_width ;
//dynamicParams->refFrameRate = frame_rate ;
//dynamicParams->targetFrameRate = frame_rate ;
//dynamicParams->targetBitRate = bit_rate ;
//dynamicParams->intraFrameInterval = intra_frame_interval;
dynamicParams->generateHeader = 0;
dynamicParams->captureWidth = 0;
dynamicParams->forceIFrame = 0;
extn_dynpar->qpIntra = 28;
extn_dynpar->qpInter = 28;
extn_dynpar->qpMax = 51;
extn_dynpar->qpMin = 0;
extn_dynpar->lfDisableIdc = 0;
extn_dynpar->quartPelDisable = 0;
extn_dynpar->airMbPeriod = 0;
extn_dynpar->maxBytesPerSlice = 0;
extn_dynpar->sliceRefreshRowStartNumber = 0;
extn_dynpar->sliceRefreshRowNumber = 0;
extn_dynpar->filterOffsetA = 0;
extn_dynpar->filterOffsetB = 0;
extn_dynpar->log2MaxFNumMinus4 = 0;
extn_dynpar->chromaQPIndexOffset = 0;
extn_dynpar->constrainedIntraPredEnable = 0;
extn_dynpar->picOrderCountType = 0;
extn_dynpar->mvDataEnable = 0;
extn_dynpar->streamFormat = 0;
extn_dynpar->intraRefreshMethod = 0;
extn_dynpar->pfNalUnitCallBack = shipOutNal;
extn_dynpar->top_slice_line = inst->topSliceLine;
extn_dynpar->bottom_slice_line = inst->bottomSliceLine;
extn_dynpar->Intra_QP_modulation = 1;
extn_dynpar->Max_delay = 3;
extn_dynpar->idrEnable = 1;
extn_dynpar->maxMBsPerSlice = 0;
extn_dynpar->hierCodingEnable = 0;
extn_dynpar->numSliceASO = 0;
extn_dynpar->numSliceGroups = 0;
extn_dynpar->sliceGroupMapType = 0;
extn_dynpar->sliceGroupChangeDirectionFlag = 0;
extn_dynpar->sliceGroupChangeRate = 0;
extn_dynpar->sliceGroupChangeCycle = 0;
if(hdResolution == 1080) {
extn_dynpar->maxMBsPerSlice = 8160;
extn_dynpar->maxMVperMB = 4;
extn_dynpar->intra4x4EnableIdc = 1;
} else if(hdResolution == 720) {
extn_dynpar->maxMVperMB = 4;
extn_dynpar->intra4x4EnableIdc = 1;
} else {
extn_dynpar->maxMVperMB = 1;
extn_dynpar->intra4x4EnableIdc = 0;
}
return;
}
void h264SetMcParams(void *h264EncInst, IVIDMC_t *params, XDAS_UInt32 topSliceLine, XDAS_UInt32 bottomSliceLine)
{
h264EncInst_t *inst = (h264EncInst_t *)h264EncInst;
memcpy(&(inst->mcParams), params, sizeof(IVIDMC_t));
inst->topSliceLine = topSliceLine;
inst->bottomSliceLine = bottomSliceLine;
return;
}
void *h264GetIresFxns(void) {
return((void *)&H264VENC_TI_IRES); /* When integrating with FC-based codec library*/
}
/* nothing past this point */
This file was modified for 640x360 @25 GOP=12. Also if you are going to test clips which FPS are higher than 30 please modify
params->maxFrameRate = 30000; to params->maxFrameRate = 60000;
Thanks,
Paula
Hi Tushar,
As Paula mentioned earlier, sv04 is not supporting resolution change, i.e., sv04 cannot create CIF output when the input is 1080p.
MCSDK Video provides a TSU component for resizing YUV data: a unit test application has been provided along with some details @ http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/196569.aspx?pi24928=1. TSU is integrated in sv01, but not sv04.
Thanks,
Hongmei
Tushar, your previous post was deleted, I think due to size of your attachment, but any case below some few sanity test question
it is original (no modified) SV04 working ok for HD resolutions (720 or 1080)? is the output correct? If not, it is your YUV input 420 planar (YYYYUUVV)?
On the other hand the file that I shared with you was an example for 640x360 so you would need to modify your client.c for CIF resolution (in case you haven't done it yet). Please confirm it and if possible share your modified file with me.
thanks,
Paula
Tushar, Please made another change that I was pointed out that is required.
H264BP CIF encoding. In siuVctEncode_xdm0p9.c, function tvct_test_entry_encode_xdm0p9(), Please initialize two variables as shown below:
XDAS_UInt32 topSliceline=0, bottomSliceline=0;
Thanks and please let us know if this works,
Paula
Hi Paula,
I have tried same but whatever i got at output is the video of CIF Resolution as i have set it. But this video is not visible.
I think we telling to encoder that the video (Input provided to encoder) has CIF resolution, and encoder encode this video considering this as CIF YUV input so that we are getting Distorted output video.(I have attached screen shot of my desktop)
I think that as Hongmei suggested it is better to impliment TSU in sv04 demo for resizing. So please tell what way should i do it.
Thanks and regards
Tushar
Hi Tushar, Apologize if I was not clear, the changes that I sent was for showing how to modify the encoder configuration parameters, but the encoder does not any resizing, resizing has to be done before. You can resize your image with a computer tool in order to test the encoder or you can use TSU component as Hongmei point it out.
Thank you,
Paula
Thanks paula for your help at leat i got that i will need to change encoder parameter when i will apply CIF in input side.
Thanks for your help, I will need your help in further too.
Thanks and Regards
Tushar