All,
I'm running into problems when I'm trying to change some of the settings of an
open and created video encoder. I'm working with the encode demo am trying to
use the _control method to change some of the dynamic parameters but it's
failing. I've made some changes to the videoEncodeAlgCreate() function,
removing the call to _control and putting it into it's own function. This
function call works fine when it's made from *AlgCreate, but if it's called
from anywhere else, it fails with a status of -1. I've verified that the
encoder instance that it's trying to work with is correct, yet still the
function fails. There aren't multiple threads accessing the encoder instance
so that shouldn't be the problem either but I'm out of ideas.
I've included the two functions, and how they're called below. Any ideas would
be great. Thanks
/******************************************************************************
* videoEncodeAlgControl
******************************************************************************/
static int videoEncodeAlgControl(VIDENC_Handle hEncodePtr,
int
headerType,
int width,
int height, int bitrate)
{
VIDENC_DynamicParams dynamicParams;
VIDENC_Status encStatus;
XDAS_Int32 status;
VIDENC_Handle hEncode;
dynamicParams.size = sizeof(VIDENC_DynamicParams);
dynamicParams.inputHeight = height;
dynamicParams.inputWidth = width;
dynamicParams.targetBitRate = bitrate < 0 ? 0 : bitrate;
dynamicParams.intraFrameInterval = 30;
// dynamicParams.generateHeader = XDM_ENCODE_AU;
dynamicParams.generateHeader = headerType;
dynamicParams.captureWidth = 0;
dynamicParams.forceIFrame = 0;
if (gblGetYFactor() == NTSCSTD) {
dynamicParams.targetFrameRate = 30000;
dynamicParams.refFrameRate = 30000;
}
else {
dynamicParams.targetFrameRate = 25000;
dynamicParams.refFrameRate = 25000;
}
/* Set video encoder dynamic parameters */
encStatus.size = sizeof(VIDENC_Status);
status = VIDENC_control(hEncodePtr, XDM_SETPARAMS, &dynamicParams,
&encStatus);
// DBG("Inside AlgControl: address=%d\n",hEncodePtr);
if (status != VIDENC_EOK) {
ERR("XDM_SETPARAMS failed, status=%ld\n", status);
return FAILURE;
}
return SUCCESS;
}
/******************************************************************************
* videoEncodeAlgCreate
******************************************************************************/
static int videoEncodeAlgCreate(Engine_Handle hEngine,
VIDENC_Handle *hEncodePtr,
VideoEncoder videoEncoder,
int width, int height, int bitrate)
{
/* VIDENC_DynamicParams dynamicParams; */
/* VIDENC_Status encStatus; */
VIDENC_Params params;
XDAS_Int32 status;
char *algName;
VIDENC_Handle hEncode;
algName = videoEncodeAlgNames[videoEncoder];
params.size = sizeof(VIDENC_Params);
params.encodingPreset = XDM_DEFAULT;
params.rateControlPreset = bitrate < 0 ? IVIDEO_NONE : IVIDEO_LOW_DELAY;
params.maxHeight = D1_HEIGHT;
params.maxWidth = D1_WIDTH;
params.maxFrameRate = gblGetYFactor() == NTSCSTD ? 30000 : 25000;
params.maxBitRate = bitrate < 0 ? 0 : bitrate;
params.dataEndianness = XDM_BYTE;
params.maxInterFrameInterval = 0;
params.inputChromaFormat = XDM_YUV_422ILE;
params.inputContentType = IVIDEO_PROGRESSIVE;
/* Create video encoder instance */
hEncode = VIDENC_create(hEngine, algName, ¶ms);
if (hEncode == NULL) {
ERR("Failed to open video encode algorithm\n");
return FAILURE;
}
if (videoEncodeAlgControl(hEncode, XDM_ENCODE_AU, width, height,
bitrate) == FAILURE) {
ERR("Failed to set control\n");
return FAILURE;
}
*hEncodePtr = hEncode;
return SUCCESS;
}
-----------------------------------------------------
The following is the code that calls the Create function, and the call to
*AlgControl fails. hEncode is the proper instance
-----------------------------------------------------
/* Allocate and initialize video encoder on the engine */
DBG("Value of hEncode before call: %d\n",(int)hEncode);
if (videoEncodeAlgCreate(hEngine, &hEncode, envp->videoEncoder,
envp->imageWidth, envp->imageHeight,
envp->videoBitRate) == FAILURE) {
cleanup(THREAD_FAILURE);
}
DBG("hEncode value = %d\n",(int)hEncode);
videoEncodeAlgControl(hEncode, XDM_ENCODE_AU, 480,720,-1);
<==============****** FAILS ******==================
Thanks for any help or ideas.
-BJ
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source