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.

Runtime Parameter Configuration

Im using DM8168 board using h.264 encoder ( ver. 01_00_04_00_production) . I want to change certain dynamic parameters like QP at runtime. I tied using OMX_Get_Config and OMX_Set_Config but the encoder application hangs when a change is made to any parameter . If these params are not changed/ set to original values the application runs normally. Can someone help me with this issue

  

  • Manu,

    most likely parameters are not correct and it returns errors. Which indices you are using to change the parameters. OMX_VENC wiki shows examples to change the parameters.

    Regards

    Vimal

    http://processors.wiki.ti.com/index.php/OMX_VENC

  • Vimal,

    Thank you for showing interest in solving this issue. I'll try to be more specific. I've now tried changing bitrate and GOP size at runtime. I've found that these changes are taking effect. But when I try to change QP settings on similar lines, the encoder hangs at the point where I change them. For eg. if I change them after 10 frames, the encoder runs fine till 10 frames are encoded and hangs after that. If I keep my QP settings same as that at init time the encoder works properly. My question now is whether changing QP settings during runtime are supported and if yes, how ?

    Regards,

    Manu 

  • Manu,

    please reefer to codec user guides for checking all static and dynamic parameters. Also which index are you using for changing parameter.

    Regards

    Vimal

  • Vimal,

    Here is the code snippet where I'm facing problem. This function, present in ilclient.c file, has been modified as below .

    The expected outcome is change in QP settings at runtime.

    void IL_ClientOutputBitStreamWriteTask (void *threadsArg)
    {
      unsigned int dataRead = 0, frame_counter = 0 ;
      OMX_ERRORTYPE err = OMX_ErrorNone;
      IL_CLIENT_COMP_PRIVATE *encILComp = NULL;
      OMX_BUFFERHEADERTYPE *pBufferOut = NULL;
     
      printf("\n\n Initialisation Done....\n\n");

      encILComp = ((IL_Client *) threadsArg)->encILComp;

      /* use the initial i/p buffers and make empty this buffer calls */
      err = IL_ClientEncUseInitialOutputResources (encILComp);

      printf("\n\n initial output resources function called...\n\n");

      while (1)
      {

                if(15 == frame_counter)                                                                                  // check if current frame number is 15
                {                                                                                                                           // if true, change QP settings to following 
                                      OMX_ERRORTYPE eError = OMX_ErrorNone;

                                      OMX_VIDEO_CONFIG_QPSETTINGSTYPE s_dyn ;

                                      IL_Client *pAppData = NULL;

                                      pAppData = gpAppData_val ;

                                      OMX_INIT_PARAM (&s_dyn);

                                      s_dyn.nPortIndex      = OMX_VIDENC_OUTPUT_PORT;

                                      eError = OMX_GetConfig(gpAppData_val->pEncHandle,
                                                             OMX_TI_IndexConfigVideoQPSettings,
                                                             &s_dyn);

                                            s_dyn.nQpI      = 38 ; // 36       // initial settings are commented
                                            s_dyn.nQpMaxI   = 38 ; // 36
                                            s_dyn.nQpMinI   = 40 ; // 36
                                            s_dyn.nQpP      = 38 ; // 36
                                            s_dyn.nQpMaxP   = 38 ; //36
                                            s_dyn.nQpMinP   = 40 ; //36
                                            s_dyn.nQpOffsetB = 4 ; // 4
                                            s_dyn.nQpMaxB   = 26 ; // 26
                                            s_dyn.nQpMinB   = 51 ; // 51

                                      eError = OMX_SetConfig(gpAppData_val->pEncHandle,
                                                             OMX_TI_IndexConfigVideoQPSettings,//OMX_TI_IndexParamVideoDynamicParams,
                                                             &s_dyn);
                                      if(eError != OMX_ErrorNone)
                                      {
                                             printf("\n Error in OMX_SetConfig: %x\n", eError);
                                      }
                                      else
                                      {
                                             printf("\n Success in OMX_SetConfig \n");
                                      }
                }


        /* Read filled buffer pointer from the pipe */
        read (encILComp->outPortParams->opBufPipe[0],
              &pBufferOut, sizeof (pBufferOut)); 
       
        /* write data to output file */
        fwrite (pBufferOut->pBuffer,
                sizeof (char),
                pBufferOut->nFilledLen, ((IL_Client *) threadsArg)->fOut);

        fflush(((IL_Client *) threadsArg)->fOut);
     
        frame_counter++;
     
        if((frame_counter == encILComp->numFrames) || (g_EXIT_TASK == 1))
        {
           printf(" write task exited \n");
           semp_post(encILComp->eos);
           pthread_exit(NULL);
           break;
        }
        
        
        /* Pass the input buffer to the component */
        err = OMX_FillThisBuffer (encILComp->handle, pBufferOut);
     
        if (OMX_ErrorNone != err)
        {
           /* put back the frame in pipe and wait for state change */
           write (encILComp->outPortParams->opBufPipe[1],
                  &pBufferOut, sizeof (pBufferOut));
           printf (" waiting for action from IL Client \n");
     
           /* since in this example we are changing states in other thread it will
              return error for giving ETB/FTB calls in non-execute state. Since
              example is shutting down, we exit the thread */
     
           pthread_exit (encILComp);
     
        }
     
       }
     
     }

     The encoder application was run in cbr mode ( rateControlPreset =  IVIDEO_LOW_DELAY). As explained in my earlier post, the encoder stops working after 14 frames. This is happening only when I change QP from initial settings. Also in constant QP mode, ( rateControlPreset = IVIDEO_NONE) , same effect is seen when i change nQpI and nQpP(init_QP) which is evident from the way the modes consider QP settings. Please let me know if I'm using wrong parameters, settings, etc.

    Regards,

    Manu 

  • Manu,

    please use omx indices - 

    OMX_TI_IndexParamVideoStaticParams

    OMX_TI_IndexParamVideoDynamicParams

    to change the parameters, you can refer encode il client to see the usage of this.

    Regards

    Vimal

  • Vimal,

    Thank you very much for the suggestion :) . I could successfully change QP settings using OMX_TI_IndexParamVideoDynamicParams omx index !

    Regards,

    Manu

  • Hello Manu/Vimal,

    I am facing similar kind of problem. I am doing similar QP Parameter settings in my IL Client encode application of ezsdk. It seems that my settings applied successfully but i am not getting any difference in encoded file. As far as my knowledge it will reflect at least size of file as on varying QP parameter settings.

    Do i need to do any other settings other then this ?

    Have you used same (OMX_VIDEO_CONFIG_QPSETTINGSTYPE) structure with OMX_TI_IndexParamVideoDynamicParams index or OMX_VIDEO_CONFIG_DYNAMICPARAMS structure and QP parameters available as part of OMX_VIDEO_CONFIG_DYNAMICPARAMS structure along with the OMX_TI_IndexParamVideoDynamicParams index ?

    I am stuck here, Quicker response will be help me to move ahead.

    Regards,

    Hitesh

  • Hello Guys,

    Any update on this ? Can anyone help me here..... ?

    Regards,

    Hitesh

  • Hello Guys,

    I got the solution for this. Anyway, many thanks for all your support.

    Regards,

    Hitesh