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.

frame-rate non-integer

Guru 20755 points

Hello,

Is it possible to use non-integer frame-rate in capture/encode/decode/display ? I didn't find divisors or anything similiar for the frame-rate...

And Another question on the same issue... Can we decode frame with any resolution and frame-rate and deliver it to video output (display) with another resolution (by scaling) and another frame-rate (upscale or downscale frame-rate) ? are there no limitation of frame-rate change or resolution change ?

Thank you very much !!

Ran

  • Hi Ran,

     

    this atleast can be done in capture and display by changing pclk appropriately. For example, we support 59.96 frame rate by changing pclk.

     

    Thx,

    Brijesh

  • Hi Brijesh,

    Are you refering to :  UInt32                          inpClk;     /**< input clock*/ ?


    Is there any example how to decode-display or capture-encode such frame rates ?

    Regards,

    Ran
     

  • Hi Ran,

     

    From where did you get this variable?

    What i was trying to say is

    let's NTSC input needs 27.027MHz pclk for 60fps, if you need 59.94, you can configure pclk to 27MHz. I believe sysfs attribute "timings" in Linux accepts pclk.

     

    Thx,

    Brijesh

  • Ran,

    We are not clear on your question.

    Do you want to know if each McFW module support a variable frame rate which is not really an integral number link 60->30. If so, this is the answer.

    Each link has inputFrameRate & outputFrameRate and down scaling of frame rate is possible to any ratio. Eg - McFW Capture provides Vcap_setFrameRate() which enables discarding of frames to any ratio. This is dependent on the use case.

     "inpClk" is not used in this context explained above.

    --- Please click "Verify Answer" if this post has answered your question

  • Hi Sivagamy,

    Thanks you very much for the reply.
    I meant  frame-rate which is fractional like NTSC 29.97. Brijesh answered my question, and I understand that there is a way to change timing for the display with vpss timing parameter. But there is still an issue here...
    If the decoder/encoder can work only in integral (not-fractional) frame-rate there will be loss of frames , right ?

    Thanks,

    Ran

  • Ran,

    There is no good solution as all links dont run at specified timings & output frames.

    We need to extrapolate the numbers & set inputFrameRate / outputFrameRate to those numbers to get some nearest ratio - ie. convert the ratio to numerator / denominator to some bigger integer.

     

     

  • Sivagamy,

    Thank  you very much for clarifications on the issue,

    Ran

  • Hi Sivagamy,

    Supposed the input frame is 29.97, and we also want to encode the bitstream as 29.97. But the encoder frame-rate is integer (it will get 30 fps I suppose).
    How does the encoder use this and will it change the original frame-rate ?

    Thanks,

    Ran

  • Is your question in relation to meeting the encoder target bitrate accurately ? Encoder does not consider the frame rate.If a full frame is given to encoder link it will encode and will not consider the frame rate.Frame rate is used only in meeting the target bit rate.At the h264 encoder level & encoder link level we can set fraction value to encoder to as FPS X 1000 so that bitrate calculations are correct. Mcfw API level assume framerate to be a integer this can be fixed with minor code change

  • Hi Badri

    >Encoder does not consider the frame rate. Frame rate is used only in meeting the target bit rate.

    What does the codec actually do with the frame-rate  ? Does it calculate the encoded-frame-rate size (should be equal to traget_bit_rate/frame_rate) ? 

    Thanks,

    Ran

  • Not exactly. Suppose target bit rate is 2 Mbps. Since the encoder has no concept of time elapsed, it needs to know how many frames constitute one second. If input frame rate is 30 fps, the encoder will try to generate 2 Mbps of encoded data over 30 frames.The H264_Encoder_HDVICP2_UserGuide.pdf part of RDK release (under ti_tools) has details of bitrate configuration and various modes supported by encoder to meet target bitrate.

  • Hi Badri Narayanan:

    I tried to set the frame rate to 29.97(I removed fps x 1000, so I set 29970 to enc link).

    But enc link will have some error as below:

    [m3video] Channel:0 inputframerate:30 targetfps:29
    [m3video] 217024:!ERROR!:ENCLINK::links_m3video/iva_enc/encLink_h264.c:[232]::INTERNAL ERROR:-1
    [m3video] ALGCONTROL FAILED:CMD:1
    [m3video] ERROR: IH264ENC_LEVEL_INCOMPLAINT_PARAMETER , 0,
    [m3video] 217025:WARN
    [m3video] ENCLINK: ERROR in Run time parameters changes, Extended Error code:1

    Can enc link support this code change?

    I just modified source code as below and I set the frame rate to 29970.

    case VENC_FRAMERATE:
    {
    EncLink_ChFpsParams params;
    params.chId = vencChnId;

    /* New fps vaule in fps x 1000 formate */
    // params.targetFps = (1000 * ptEncDynamicParam->frameRate);
    params.targetFps = ptEncDynamicParam->frameRate;

    /* Corresponding bitrate value */
    params.targetBitRate = ptEncDynamicParam->targetBitRate;
    System_linkControl(gVencModuleContext.encId, ENC_LINK_CMD_SET_CODEC_FPS,
    &params, sizeof(params), TRUE);
    break;
    }

  • If you want to set encode to 29.97 it is better to do the following change:

    1. Undo all changes you have done so far.

    2. Modify

    /dvr_rdk/mcfw/src_bios6/links_m3video/iva_enc/encLink_h264.c

    static Int enclink_h264_set_static_params(IH264ENC_Params * staticParams,
                                              EncLink_AlgCreateParams *
                                              algCreateParams)
    Add

    staticParams->vuiCodingParams.numUnitsInTicks = 1001;

  • Hi Badri Narayanan:

    Is it possible to set the numUnitsInTicks on A8? 

    the fps of output video must depend on video input( for example, 50i->25p ,59.94i->29.97p), so to change numUnitsInTicks  will not meet this request. 

    Do you any comment for this request?

    Thanks

  • numUnitInTicks is a encoder create time param.Do you want to chnage the frame rate dynamically or is it okay to be a creat time param

  • I want to set the frame rate dynamically and frame rate must support 29.97, 23.98 and 25.

    Thanks

  • Hi, All frame rates should be handled in application. There is no hardware for framerate conversion. Further regarding setting up of framerate.\\

    1. Capture frame is totally based on what external decoder/sensor is sendig.

    2. display frame rate can be controlled using the timing sysfs entry on Linux.

    3. For all other drivers, framerate doestn matter they will just take the frame and sends out the frame once processing completes

  • Hi, 

    1. Did  you mean that DVR RDK cannot handle frame rate(dei,scl, nsf) ?  

    2. When I modified the enc link's target fps, I can see the changed fps (30-->29.97)in VLC player. I think enc link should be handle frame rate.

    Thanks

    Chuan-Hsiu Lee

     

  • FPS rate change is supported only in Encoder link where you can change the rate at which buffers get encoded.

  • How do I set the FPS to 29.97? Is is possible in Enc link? Can I change FPS dynamically ?

    Thanks

  • Is  your requirement that the encoded bitstream VUI info has the fractional frame rate set correctly ? I understand the 29.97 and 25 fps cases. Can you explain the 23.xx case.Is capture at this rate or do you want to convert 29.97 capture fps to this frame rate ? Anyhow support for fractional frame rate is not present in encLink currently. Pls explain your requirement clearly so that we can evaluate if it possible to do the changes to support fractional framerates.We need to know  1. The data flow in terms of what will be the capture frame rate

    2. What will be the input fps to encLink

    3. What is the info you expect to be set in the h264 vui info in terms of frame rate.

  • Hi,

    Is  your requirement that the encoded bitstream VUI info has the fractional frame rate set correctly ?

    Yes.

    I understand the 29.97 and 25 fps cases. Can you explain the 23.xx case.Is capture at this rate or do you want to convert 29.97 capture fps to this frame rate ?

    yes, capture is at the rate,more detail, you can refer to  http://en.wikipedia.org/wiki/24p.

    Anyhow support for fractional frame rate is not present in encLink currently. Pls explain your requirement clearly so that we can evaluate if it possible to do the changes to support fractional framerates.We need to know 

    1. The data flow in terms of what will be the capture frame rate

     We need to support 59.94i(29.97p), 50i(25p), 23.98PsF, 59.94p, 50p and 25PsF.

    2. What will be the input fps to encLink

    the frame rate will be 1:1 ratio(input frame rate:output frame rate) or 2:1 (59.94p to 29.97p).

    3. What is the info you expect to be set in the h264 vui info in terms of frame rate.

     29.97p, 25p and 23.98p.

    Thanks

  • I looked at the encLink code and there are some  changes required to correctly handle fractional framerate configuration. Is this a critical requirement for you ? If so can you make a new thread post (dont reply to this thread) copy-pasting the above info. I can provide you a patch end of next week.

  • Hi Badri,

    If the case is that the input frame-rate in VIP is always 30fps , and we are required to change encoded frame-rate of video (only down scaling), so that a remote decoder will decode new frame-rate video:

    1. As I understand, we can dynamically configure scalers Link input/output fps, so that we down scale frame-rate to any new required value (as long as it is down scale). If this is not right, please comment.

    2. encoder Link frame-rate should actually be the real input frame-rate. We can't do down scale frame-rate using encoder link. This raise a question, what is the reason to use different target frame-rate in encoder link, than the input frame-rate into encoder link if this does not change the video frame-rate anyway ?

    Can you please verify the above ?

    Best Regards,

    Ran

  • 1. As I understand, we can dynamically configure scalers Link input/output fps, so that we down scale frame-rate to any new required value (as long as it is down scale). If this is not right, please comment.

       -- This is correct. All links other than capture link support down scaling frame rate.

    2. encoder Link frame-rate should actually be the real input frame-rate. We can't do down scale frame-rate using encoder link. This raise a question, what is the reason to use different target frame-rate in encoder link, than the input frame-rate into encoder link if this does not change the video frame-rate anyway ?

       -- This is not correct. Encoder also support down scaling frame rate . The encoder link will down scale from inputFrameRate to TargetFrameRate,

    There is a difference between the frame rate down scaling for all the links  and encoder link.

    For other links like DEI/Scaler the parameters for the frame rate down scaling (inputFrameRate/outputFrameRate) are used exclusively for the purpose of frame rate scaling. This means what matters is the ratio of inputFrameRate: outputFrameRate. The absolute value of framerate provided do not matter.

    So giving In = 60 Out = 30 is same as In = 6000 , Out = 3000.

    This allows flexibility in frame rate conversion like converting from 59.97 NTSC field rate to 30 fps for display on HDMI. Setting could be

     IN = 5997, Out = 3000.

    For encoder link the absolute value of the frame rate is important as the bitrate calculation for the encoder are based on the target frame rate. Also the VUI info encodes the target frame rate as part of the bitstream . As mentioned above the code in the encoder link also doesnt support fractional framerate for target frame rate . Fixing this will require change in encLink API and code changes in the encLink which are currently not present in DVR RDK.

  • Hi Badri,

    So If the chain is capture->scaler>encoder , I can chose if the down frame-rate will be done in scaler or in encoder, right ?
    Regarding the fractional frame-rate:

    1. As I remember, the encoder frame-rate units are  1000*frame-rate, so doesn't that deals with fractional frame-rates such as 59.97 ?
    2. If 1. is not a valid solution, Is there another patch that you can provide for dealing with fractional frame-rate in encoded video ? Without the VUI valid information regarding the frame-rate the remote decoder/display might provide uncorrect decoding/display ?

    Best Regards,

    Ran

  • So If the chain is capture->scaler>encoder , I can chose if the down frame-rate will be done in scaler or in encoder, right ?

      - Yes correct.

    1. As I remember, the encoder frame-rate units are  1000*frame-rate, so doesn't that deals with fractional frame-rates such as 59.97 ?

        - TargetFrameRate us a x1000 value but the input frame rate is not a x1000 value. Support for fractional frame rate requires that input frame rate also be a x1000 value and fixes in encLink to handle this correctly.

    If 1. is not a valid solution, Is there another patch that you can provide for dealing with fractional frame-rate in encoded video ?

     - Yes I am working on a patch and will provide it when done.

     Without the VUI valid information regarding the frame-rate the remote decoder/display might provide uncorrect decoding/display ?

       - This depends on the playback system but I am very doubtful that vui info will be used for playback as it is not mandatory for a h264 stream to have vui info.The transport layer presentation timestamp will be usually used for playback and is derived from the capture timestamp and not frame rate info.

  • Hi Badri,

    I've started testing, and I see that When I set the targetframerate in encoder to any rate X frame per second, and I open a vlc receiving the stream in PC, I see in vlc "codec information" that the frame rate is 2*X (frames per second), for example setting targetframerate to 1 fps, I see in vlc information 2 fps. Why Is that ? Is it relate to the de-interlacing done before encoding ?

    Regards,

    Ran

  • This is not expected.Pls share logs of Vsys_printDetailedStatistics and Venc_getDynamicParam .

  • hi badri,

    Q1. how did I get the following value?

    staticParams->vuiCodingParams.numUnitsInTicks = 1001;

    Q2. does it mean that I can generate many kinds of fractional fps? is there any restriction?

  • Hi,

    is there already a patch for fractional inputFramRate available?

    I also Need fractional Input FrameRate of 12,5fps.

    Regards

    Andy

  • Pls check this post which has patch for fractional frame rate support in encoder. Patch will apply on top of DVRRDK 4.1

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/p/316144/1100136.aspx#1100136

  • Ok thanks for the reply.

    I have DVRRDK 4.0 and will try to merge it there.

    Regards

    Andy