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.

Configuring H.263 in MPEG4 Encoder

Hi all,

according to specs, MP4ENC codec supports both H.263 and MP4 codings.

We're trying to configure TI MPEG4 Encoder to work with H.263 profile but as soon as we change default config we get an error "Invalid Params" (0x80008008) from Codec Engine. Following the piece of code we execute with comments:

...

                        case CODEC_VIDEO_H263: {
                                // codec config
                                IMP4VENC_Params params;                                                                  //extended VIDENC_Params;
                                CLEAR(params);                                                                                       // clear the buffer: #define CLEAR(x) memset (&(x), 0, sizeof (x))

                                params.encodeMode = 0;                                                                        // we want to encode video with H.263 codec, we suppose this value is ignored
                                                                                                                                                      // if default size (BASIC) is passed to VIDENC_Create function

                                params.videncParams.size = sizeof(VIDENC_Params);                   // success, algo is created successfully but, according to specs,
                                                                                                                                                      // standard values are used to configure MPEG4 Encoder

                                //params.videncParams.size = sizeof(IMP4VENC_Params);           // fail, algo is not created if we set this field to
                                                                                                                                                     // the size of the IMP4VENC_Params

                                params.videncParams.encodingPreset        =  XDM_HIGH_QUALITY; //XDM_DEFAULT;
                                params.videncParams.dataEndianness        = XDM_BYTE;
                                params.videncParams.inputContentType      = IVIDEO_PROGRESSIVE;
                                params.videncParams.inputChromaFormat     = XDM_YUV_422ILE;
                                params.videncParams.rateControlPreset     = IVIDEO_LOW_DELAY; //bitrate < 0 ? IVIDEO_NONE : IVIDEO_LOW_DELAY;
                                params.videncParams.maxFrameRate          = framerate;
                                params.videncParams.maxBitRate            = bitrate < 0 ? 0 : bitrate;
                                params.videncParams.maxInterFrameInterval = framerate;
                                params.videncParams.maxHeight             = height;
                                params.videncParams.maxWidth              = width;
                                // create algo
                                hEncode = VIDENC_create(hEngine, "mpeg4enc", (VIDENC_Params *)&params);

                                if (hEncode == NULL) {
                                       ERR("Can't open encode algorithm: %s\n", algo);
                                       return FAILURE;
                                }
...

 

If we change params.videncParams.size from sizeof(VIDENC_Params) to sizeof(IMP4VENC_Params), that shuld be the extended params as per SPREUA2B document - pg. 4-13, we obtain the above mentioned error.

Any suggestion will be appreciated.

Regards,

--j

  • Hello,

    I wonder if you still have this problem. Feb 2009 is a long time ago!!!

    But, I had this issue for a very long time. In the end, I found that dm355_codecs_1_12_003 (this came with the eval baord), didn't have support for extended params.

    Please move to dm355_codecs_1_13_000 and all will be well...!!

     

  • Hi amjad,

    to be true I really forgot the issue and how we solved it.......btw thanks a lot for your answer.

    Regards,

    --j

  • Hi Jake, 

    now I'm facing same issue. Maybe you remember something...

    many thanks.

    Andrea

  • Hi Andrea,

    it has been a long time ago, but we had some hint from TI's support (something like playing with config values in a non-documented way...).

    I'll try to better investigate (...then I'll be back to you hopefully !!! )

    Not much I suppose, sorry,

    --j

  • Hi jake9645,
       

         Do you solve your problem now?I account the same problem now .......

         Hopefully your answer!

    liuliang

     

  • Hi all,

    we faced two issue at the time jake posted the message while we were trying to encode H263 with MPEG4 codec, the first was the one related to the "invalid param" error, later, once we overcame the first issue, we were still not able to have an H263 bitstream even setting encodeMode = 0 in the IMP4VENC Params (the encoder produced always an MPEG4 bitstream).

    TI support provided us a config to generate an H263 bitstream by means of the test app found in: dm6446_dvsdk_combos_1_35/packages/ti.sdo/codecs/mpeg4enc/app/client/

    These settings provided by TI are the following:

    # New Input File Format is as follows
    # <ParameterName> = <ParameterValue> # Comment
    #
    ##########################################################################################
    # Parameters
    ##########################################################################################
    EncodingPreset = 1 #encoding preset 0: DEFAULT, 1:HIGH_QUALITY , 2:HIGH_SPEED , 3:USER_DEFINED
    ImageWidth = 352 #Image width in Pels
    ImageHeight = 288 #Image height in Pels
    FrameRate = 30000 #Frame Rate per second*1000 (1-100)
    Bitrate = 4000000 #Bitrate(bps) #Must be greater than ZERO
    ChromaFormat = 4 #1 => XMI_YUV_420P, 3 => XMI_YUV_422IBE, 4 => XMI_YUV_422ILE
    IntraPeriod = 30 #Period of I-Frames
    FramesToEncode = 2 #Number of frames to be coded
    RateControlPreset = 5 #rateControlPreset , 1: LOW_DELAY , 2: STORAGE, 3: TWOPASS, 4: NONE, 5:USER_DEFINED
    EncodeMode = 0 #Encoding mode, 0: H.263 mode, 1 : MPEG4 mode
    LevelIdc = 5 #Profile level indication for MPEG4, 0-5 for setting Level 0 to 5
    RateControlMethod = 8 #Rate Control Method, 0: disable rate control, 1:TM5, 2:Not supported,3:PLR1, 4:PLR3, 5:Not supported, 6:Not supported, 7:Constrained VBR, 8:PLR4
    VBVBufSize = 112 #vbv_buffer_size (in multiples of 16 kbit)
    MaxDelay = 1000 #Maximum allowable delay (Only applicable for RateControlMethod = 7, ignored for other RC methods)
    UseVOS = 1 #VOS header insertion, 0 = off, 1 = on
    UseGOV = 0 #GOV header insertion, 0 = off, 1 = on
    DPEnable = 0 #Data partioning, 0 = off , 1 = on
    RVLCEnable = 0 #RVLC, 0 = off , 1 = on
    ResyncInterval = 2000 #Insert resync marker (RM) after given specified bits, 0 implies do not insert
    HECInterval = 0 #Insert HEC after given specified packets insertion, 0 means do not insert
    AIRRate = 0 # Adaptive intra refresh in MB's per frame
    MIRRate = 0 #Mandatory intra refresh rate in MB's per frame
    QpIntra = 12 #default QP for I frame : QPI, range 2 to 31
    QpInter = 12 #default QP for P frame : QPI, range 2 to 31
    Fcode = 3 #f_code: ME search area = 1<<f_code-1, set to 1 in case of H.263
    UseHpi = 1 #Half pixel interpolation, 0 : off, 1 = on
    UseAcPred = 0 #AC prediction enable/disable 0: off , 1 = on
    LatFrameFlag = 0 #Last frame flag, 1 = Last Frame, 0 = Not Last Frame. This need to be dynamically set: only for the last frame
    EncodeHeaderOnly = 0 #Generate only header, 1= generates VOL header ,0 = Normal Encoding
    EnableMVAccess = 0 #Enable Motion vector access, 0: Disbale, 1: Enable
    EnableUMV = 1 #Enable UMV flag, 0 = Disable, 1 = Enable

    In our production code we were able to encode an H263 bitstream using the following code (at that time with dvsdk 1.30.00.40):

    VIDENC_DynamicParams  dynamicParams;
    CLEAR(dynamicParams);

    //Set basic dynamic params used by all encode/decode algoritms 
    VIDENC_Params          params;
    CLEAR(params);
    params.size = sizeof(VIDENC_Params);
    params.encodingPreset            = XDM_USER_DEFINED;
    params.dataEndianness            = XDM_BYTE;
    params.inputContentType          = IVIDEO_PROGRESSIVE;
    params.inputChromaFormat         = XDM_YUV_422ILE;
    params.rateControlPreset         = IVIDEO_LOW_DELAY;
    params.maxFrameRate              = framerate;
    params.maxBitRate                = bitrate;
    params.maxInterFrameInterval     = 1;
    params.maxHeight                 = D1_HEIGHT;
    params.maxWidth                  = D1_WIDTH;

    //Set extended VIDENC_Params; 
    IMP4VENC_Params exH263params;
    CLEAR(exH263params); 
    exH263params.videncParams.size                        = sizeof(IMP4VENC_Params);
    exH263params.videncParams.encodingPreset              = params.encodingPreset;
    exH263params.videncParams.dataEndianness              = params.dataEndianness;
    exH263params.videncParams.inputContentType            = params.inputContentType;
    exH263params.videncParams.inputChromaFormat           = params.inputChromaFormat;
    exH263params.videncParams.rateControlPreset           = params.rateControlPreset;
    exH263params.videncParams.maxFrameRate                = params.maxFrameRate;
    exH263params.videncParams.maxBitRate                  = params.maxBitRate;
    exH263params.videncParams.maxInterFrameInterval       = params.maxInterFrameInterval;
    exH263params.videncParams.maxHeight                   = params.maxHeight;
    exH263params.videncParams.maxWidth                    = params.maxWidth;;   
    exH263params.encodeMode                               = 0; // Encoding mode, 0: H.263 mode, 1 : MPEG4 mode
    exH263params.levelIdc                                 = 5; // Profile level indication for MPEG4
    exH263params.numFrames                                = 0x7fffffff; // Number of frames to be encoded. This parameter is used only for VM4 rate control inside encoder
    exH263params.rcAlgo                                   = 0; // Rate Control Method, 0: disable rate control, 1-TM5,  2-modified TMN5, 4-PLR3, 5-VM4, 6 : mod TM5
    exH263params.vbvBufferSize                            = 112; // vbv_buffer_size (in multiples of 16 kbit)
    exH263params.useVOS                                   = 0;  // VOS header insertion, 0 = off, 1 = on
    exH263params.useGOV                                   = 0; // GOV header insertion, 0 = off, 1 = on
    exH263params.useDataPartition                         = 0; // Data partioning, 0 = off , 1 = on
    exH263params.useRVLC                                  = 0; // RVLC, 0 = off , 1 = on
    exH263params.maxDelay                                 = 1000; // max delay for rate control interms of ms, set it to 1000 for 1 second delay

     //Set basic dynamic params used by all encode/decode algoritms
    VIDENC_DynamicParams  dynamicParams;
    CLEAR(dynamicParams); 

    dynamicParams.size                                    = sizeof(VIDENC_DynamicParams);
    dynamicParams.inputHeight                             = height;
    dynamicParams.inputWidth                              = width;
    dynamicParams.targetBitRate                           = bitrate;
    dynamicParams.intraFrameInterval                      = 30;
    dynamicParams.generateHeader                          = XDM_ENCODE_AU;
    dynamicParams.captureWidth                            = 0;
    dynamicParams.forceIFrame                             = 1;
    dynamicParams.targetFrameRate                         = framerate;
    dynamicParams.refFrameRate                            = framerate;

    //set extendended dynamic params for H263 encoder 
    IMP4VENC_DynamicParams     exh263dynamicParams;
    CLEAR(exh263dynamicParams);          
    exh263dynamicParams.videncDynamicParams.size          = sizeof(IMP4VENC_DynamicParams);
    exh263dynamicParams.videncDynamicParams.inputHeight   = dynamicParams.inputHeight;
    exh263dynamicParams.videncDynamicParams.inputWidth    = dynamicParams.inputWidth;
    exh263dynamicParams.videncDynamicParams.targetBitRate = dynamicParams.targetBitRate;
    exh263dynamicParams.videncDynamicParams.intraFrameInterval          = dynamicParams.intraFrameInterval;
    exh263dynamicParams.videncDynamicParams.generateHeader              = dynamicParams.generateHeader;
    exh263dynamicParams.videncDynamicParams.captureWidth                = dynamicParams.captureWidth;
    exh263dynamicParams.videncDynamicParams.forceIFrame                 = dynamicParams.forceIFrame;
    exh263dynamicParams.videncDynamicParams.targetFrameRate             = dynamicParams.targetFrameRate;
    exh263dynamicParams.videncDynamicParams.refFrameRate                = dynamicParams.refFrameRate;
    exh263dynamicParams.resyncInterval                                  = 2000; // Insert resync marker (RM) after given specified bits, 0 means do not insert
    exh263dynamicParams.hecInterval                                     = 0; // Insert HEC after given specified packets insertion, 0 means do not insert
    exh263dynamicParams.airRate                                         = 0; // Adaptive Intra refresh of n MBs per frame
    exh263dynamicParams.mirRate                                         = 0; // Mandatory Intra refresh rate: at least 1 in 132 time MB coded
    exh263dynamicParams.qpIntra                                         = 8; // default QP for I frame : QPI,  range 1 to 31
    exh263dynamicParams.qpInter                                         = 8; // default QP for P frame, range 1 to 31 
    exh263dynamicParams.fCode                                           = 1; // f_code(as per MPEG4 spec)(max MV length): 1<<f_code-1, set to 1 when using H.263
    exh263dynamicParams.useHpi                                          = 1; // Half pixel Interpolation, 0 : off, 1 = onn
    exh263dynamicParams.useAcPred                                       = 0; // AC prediction Flag, 0 : off, 1 = on
    exh263dynamicParams.lastFrame                                       = 0; // Last frame flag, 0 : NOT Last frame, 1 = Last Frame
    exh263dynamicParams.MVDataEnable                                    = 0; // Flag to enable Motion vector access
    exh263dynamicParams.useUMV                                          = 0; // UMV Flag, 0 : off, 1 = on

    Moreover, I found a note we exchanged in our development team in which it is said that it looks like the encodingPreset field of VIDENC_Params seems to affect the encoded bitstream and that we were not able to obtain an H263 bitstream using XDM_DEFAULT preset.

    I hope the information provided are useful to solve your issues.

    Regards,

    Alberto

  • Hi Alberto,

          My problem is that my platform is DM6467 and other software modules  version are configed  according to  the document   mpeg4enc_encoder_dm6467_relaese .

      I config the params according to the document   mpeg4enc_encoder_dm6467_userguide and your answer above as follow,

        IMP4VENC_Params        m4vEncParam;
        IMP4VENC_DynamicParams m4vEncdynParams;
        memset(&m4vEncParam,0 , sizeof(m4vEncParam));
        memset(&m4vEncdynParams,0 , sizeof(m4vEncdynParams));

        m4vEncParam.videncParams.size                  = sizeof(IMP4VENC_Params);
        m4vEncParam.videncParams.encodingPreset        = XDM_HIGH_QUALITY;//XDM_DEFAULT;
        m4vEncParam.videncParams.rateControlPreset     = IVIDEO_LOW_DELAY;
        m4vEncParam.videncParams.maxHeight             = 576;
        m4vEncParam.videncParams.maxWidth              = 720;
        m4vEncParam.videncParams.maxFrameRate          = 30000;
        m4vEncParam.videncParams.maxBitRate            = 8192000;//6000000;
        m4vEncParam.videncParams.dataEndianness        = XDM_BYTE;
        m4vEncParam.videncParams.maxInterFrameInterval = 1;
        m4vEncParam.videncParams.inputChromaFormat     = XDM_YUV_420SP;
        m4vEncParam.videncParams.inputContentType      = IVIDEO_PROGRESSIVE;
        m4vEncParam.videncParams.reconChromaFormat     = XDM_CHROMA_NA;

        m4vEncParam.MPEG4_mode               = 0;     /* MPEG4 = 1, H.263 = 0*/
     m4vEncParam.levelIdc                 = 30;
     m4vEncParam.profileIdc               = 0;
     m4vEncParam.useVOS                   = 0;
     m4vEncParam.useGOV                   = 0;
     m4vEncParam.useVOLatGOV              = 0;
     m4vEncParam.useQpel                  = 0;
     m4vEncParam.useInterlace             = 0;
        m4vEncParam.aspectRatio              = IMP4VENC_AR_DEFAULT;
     m4vEncParam.pixelRange               = IMP4VENC_PR_DEFAULT;
        m4vEncParam.timerResolution          = 30000;
     m4vEncParam.reset_vIMCOP_every_frame = 0;
     m4vEncParam.UMV                      = 0;

        m4vEncdynParams.videncDynamicParams.size                 =sizeof(IMP4VENC_DynamicParams);
        m4vEncdynParams.videncDynamicParams.inputHeight          = 576;
        m4vEncdynParams.videncDynamicParams.inputWidth           = 720;
        m4vEncdynParams.videncDynamicParams.refFrameRate         = 30000;
        m4vEncdynParams.videncDynamicParams.targetFrameRate      = 30000;
        m4vEncdynParams.videncDynamicParams.targetBitRate        = 2000000;
        m4vEncdynParams.videncDynamicParams.intraFrameInterval   = 150;
        m4vEncdynParams.videncDynamicParams.generateHeader       = 0;//XDM_ENCODE_AU;
        m4vEncdynParams.videncDynamicParams.captureWidth         = 0;
        m4vEncdynParams.videncDynamicParams.forceFrame           = IVIDEO_NA_FRAME;//IVIDEO_I_FRAME;
        m4vEncdynParams.videncDynamicParams.interFrameInterval   = 0;
        m4vEncdynParams.videncDynamicParams.mbDataFlag           = 0;

     m4vEncdynParams.Four_MV_mode          = 0;
     m4vEncdynParams.PacketSize            = 0;
     m4vEncdynParams.qpIntra               = 8;
     m4vEncdynParams.qpInter               = 8;
     m4vEncdynParams.useHEC                = 0;
     m4vEncdynParams.useGOBSync            = 0;
     m4vEncdynParams.RcAlgo                = IMP4VENC_RC_DEFAULT;
     m4vEncdynParams.QPMax                 = 31;
     m4vEncdynParams.QPMin                 = 8;
     m4vEncdynParams.maxDelay              = 1000;
     m4vEncdynParams.qpInit                = 8;
     m4vEncdynParams.MVaccessFlag          = 0;
     m4vEncdynParams.ME_Type               = 1;
     m4vEncdynParams.PerceptualRC          = 0;
     m4vEncdynParams.Insert_End_Seq_code   = 0;

    I obtain the error message as follow,

     ti.sdo.dmai - [Venc1] XDM_SETPARAMS failed, status=-1

    If I set     m4vEncParam.MPEG4_mode  = 0;     /* MPEG4 = 1, H.263 = 0*/   and   m4vEncParam.levelIdc = 5   , so it can obtain the mpeg4 bitstream.

     

    Additionally, I find carefully the mpeg4enc params config in         cs2dm6467_1_00_00_10\packages\ti\sdo\codecs\mpeg4enc\app\Client\Test\Src,

    but I cann't find the config for h263  bitstream.

     

           But the document mpeg4enc_encoder_dm6467_userguide and mpeg4enc_encoder_dm6467_datasheet declare definitely that   H.263 baseline profile levels 10, 20, 30 and 45 supported . So, the results confuse me very much.

           Hopefully, I want to get  your help !

    Regards,

    LL

     

  • Hi Alberto,

          My the other problem is whether the mpeg4enc and mpeg4dec in cs2dm6467_1_00_00_10\packages\ti\sdo\codecs  can  loop. Because I try to let mpeg4enc and mpeg4dec to loop , if I create the encoder and decoder in tne same time, the progamm will dead, and if I create encoder or decoder only,the progamm will run.

       Hopefully, I want to get  your help also about this problem!

    Regards,

    LL

  • Hi Liuliang,

    I don't have specific knowledge of DM6467 architecture, in general I think you must take care of all the parameters when you change the profile level, I mean each profile has its own acceptable values for the encoder parameters, probably when you set level 30 you have also to fix/change other params in order to match the specific level configuration.

    With respect to the mpeg4enc params config in app/Client application, also for DM6446 there's no H263 config, I posted the config I got from TI to run the app in order to generate an H263 config, I think you have to edit the default config for DM6467 found in this directory by yourself hoping you find a similar definitions for parameters there (from the code you posted it looks like codec params are quite different among the two architectures).

    Regarding your last problem, we got a similar behavior when we arranged a custom codec engine with both encoder and decoder and a couple of other algorithms, in our case the problem was due to the memory available in the different segments (L1 cache, IRam, etc.), each codec/algorithm has its own requirements and when you run together several algorithms you must ensure the overall available space is enough for all of them.

    Regards,

    Alberto

  • Hi All,

          My first problem has solved.Because my image width and height is incorrect. H.263 surport 4CIF resolution but not 576P.

          The  second problem is same as always.

    Regards.

    LL

  • Hi Alberto,

         Thanks you for your answer very much.

          It is as you said my resolution setted error.Now this problem is solved.

    Regards,

    LL


  • Hi Alberto,

        First of all, thanks very much for you giving me so much help before. 

        Lately, I study DM6467 MPEG4 encoder and decoder for h.263 because the item  need.

        The DM6467 MPEG4 encoder and decoder come from TI official  website. the encoder version is 01.00.00.09 , the decoder version is 01.00.00.05.

        So,I need to confirm the declare in the encoder and decoder userguide document because I encount some problems when I test the encoder and decoder.

        First, I can get mpeg4 bitstream and h.263 bitstream by setting the MPEG4 encoder, but the MPEG4 decoder can decode the mpeg4 bitstream but not decode the h.263 bitstream.

        Second,  I use the third software play the h.263 bitstream and can find some information about the bitstteam.  I can see the value of short_video_header In the VideoObjectLayer  is 0.  At the same time, the MPEG4 decoder userguide document declares that surport short video header h.263 and the value of short_video_header is 1 at this staus.

        Third, I cann't find param about setting the value of short_video_header in MPEG4 encoder userguide document.

         So, my first problem is whether the MPEG4 encoder can only encode  un_short_video_header h.263 bitstream but not short_video_header h.263 bitstream.

          And the second problem is whether the MPEG4 decoder can only decode short_video_header h.263 bitstream but not un_short_video_header h.263 bitstream.

          Further more, my third problem is whether the MPEG4 decoder  cann't decode the h.263 bitstream that generated from the MPEG4 encoder.

         Hopefully you can give me some help.

     Regards,

    LL

  • Hi Liuliang,

    We were able to encode and decode H263 bitstreams with TI codecs I can confirm they work fine on DM6446, I wonder you're experiencing this kind of problems: usually the decoder is much more simpler to configure than the encoder. As for my experience I suggest you to double check the decoder params (run tests with simpler encoder/decoder configs at first) and, if you didn't solve your issue I think you need to refer directly to TI: you're talking about very specific details of the encoded bitstream and I guess only people from TI has a so deep knowledge of inner logic of the MPEG4 decoder algorithm.

    Regards,

    Alberto