I am trying to get MPEG4 720p at 24 FPS working on a DM355. It correctly encodes and I get an output stream I can play in VLC, but I drop many frames per second to keep up with the encoding rate. Should I be building the codec configuration in release mode? I noticed this message when the codec configuration gets built:
/opt/xdctools_3_10_03/xs xdc.tools.configuro -r debug -t gnu.targets.MVArm9 -c "/opt/montavista/pro/devkit/arm/v5t_le" codecscfg.cfg
Here is the configuration I am using:
/*
* ======== codecscfg.cfg ========
*/
var osalGlobal = xdc.useModule('ti.sdo.ce.osal.Global');
osalGlobal.runtimeEnv = osalGlobal.LINUX;
/*
* ======== Engine Configuration ========
*/
var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.dm355.ce.MPEG4ENC');
var Engine = xdc.useModule('ti.sdo.ce.Engine');
var myEngine = Engine.create("video", [
{name: "mpeg4enc", mod: MPEG4ENC, local: true, groupId: 1},
]);
var JPEGENC = xdc.useModule('ti.sdo.codecs.jpegenc.dm355.ce.JPEGENC');
var Engine = xdc.useModule('ti.sdo.ce.Engine');
var myEngine = Engine.create("image", [
{name: "jpegenc", mod: JPEGENC, local: true, groupId: 1},
]);
/*
* ======== DMAN3 Configuration ========
*/
var DMAN3 = xdc.useModule('ti.sdo.fc.dman3.DMAN3');
/* give DMAN3 all TCCs except those hard-coded by The JPEG & MPEG Enc & Decs */
/*
* For the 32-63 range, configure tccAllocationMaskH to exclude used channels
* JPEG Dec: {33-47, 52-57}
* JPEG Enc: {34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49}
* MPEG Dec: {32-63}
* MPEG Enc: {12, 13, 34, 35, 40,41,42,43,44,45,46,47,48,49,50,52,53,
* 54,55,56,57,63}
*/
DMAN3.tccAllocationMaskH = 0x0; /* everthing 32-63 hardcoded and unavailable */
/* Give DMAN3 all lower TCCs except what's taken by Linux kernel and a Codec:
* Based on the info from montavista: {2, 3, 8, 9, 26, 27, 30, 31}
* and MPEG Enc taking up: {12, 13}
*/
DMAN3.tccAllocationMaskL = 0x33ffccf3;
/* Following assignments will give DMAN3 control of PaRAMs above 78: */
DMAN3.paRamBaseIndex = 64;
DMAN3.numPaRamEntries = 48;
DMAN3.nullPaRamIndex = 127;
/* Configure Scratch Group's DMAN3 resources */
DMAN3.numTccGroup[1] = 0;
DMAN3.numPaRamGroup[1] = 32;
DMAN3.qdmaChannels = [0, 1, 2, 3, 4, 5, 6, 7];
DMAN3.maxQdmaChannels = 8;
DMAN3.numQdmaChannels = 8;
DMAN3.maxTCs = 2;
Here are the parameters I use for the VIDENC1_Create function:
memset(&_encoderParams,0, sizeof(_encoderParams));
_encoderParams.size = sizeof(VIDENC1_Params);
_encoderParams.encodingPreset = XDM_HIGH_SPEED;
_encoderParams.rateControlPreset = IVIDEO_STORAGE;
_encoderParams.maxHeight = _config.ImageHeight; // 720
_encoderParams.maxWidth = _config.ImageWidth; // 1280
_encoderParams.maxFrameRate = _config.FrameRate * 1000; // 24
_encoderParams.maxBitRate = _config.MaxBitRate; // 2500000
_encoderParams.dataEndianness = XDM_BYTE;
_encoderParams.maxInterFrameInterval = XDM_DEFAULT;
_encoderParams.inputChromaFormat = XDM_YUV_422ILE; // pixelFormat;
_encoderParams.inputContentType = IVIDEO_PROGRESSIVE;
_encoderParams.reconChromaFormat = XDM_DEFAULT;
Here are the dynamic parameters. I copied these from venc program:
memset(&_dynamicParams,0, sizeof(VIDENC1_DynamicParams));
_dynamicParams.size = sizeof(VIDENC1_DynamicParams);
_dynamicParams.inputHeight = _config.ImageHeight;
_dynamicParams.inputWidth = _config.ImageWidth;
I call VIDENC1_process for each frame. I tried to queue up several frames and then call VIDENC1_process. This seemed to work, but the output video looks like the same frame is encoded several times. It doesn't appear that the VIDENC1_process function correctly walks the pointer array. I have logic in my code to drop frames if a encode queue fills up. Currently I'm seeing about a 10% drop frame loss.
Finally, the output stream that the codec creates seems correct according to ffmpeg. I can't extract the data into seperate images or recompress them. I can play the video with VLC and I can recompress in VLC, but I would prefer to use ffmpeg. Also, we can't import the file in standard video editing tools. Has anyone had any luck reading the data with other tools?
Thanks.