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.

H264 streaming

Hello All,

   a question about H264. Suppose I use the H264 encoder to stream over the network, for instance sending multicast packets. Can I start to receive and decode  from an arbitrary point of the stream OR the decoder must start with the first encoded packet?

I ask this because it seems that starting decoding from an arbitrary point of the stream, after providing the encoded input buffers to the decoder, the

hOutBuf = Vdec2_getDisplayBuf(hVd2);

always returns null pointers.

The Vdec2_process(...)  sometimes returns Dmai_EBITERROR (4), i.e. the values returned are more or less like this 0,0,0,4,0,4,4...

I am also interested in the behaviour of the decoder when some packet is lost by the network.

Thank you.

 

  • Hi,

    You have to start decoding with a keyframe, preceded by SPS+PPS.
    http://e2e.ti.com/support/embedded/f/356/p/73235/274755.aspx#274755.
    By my experience lost packets are not too big problem.
    Only current frame, or current GOP (until the next key frame) is affected.

    Regards,
    Marko.

     

     

  • In my design I copy the SPS/PPS into the stream before every I frame.  So if you had a decoder that could pull them from the stream for setup it would be available.  VLC uses the SPS/PPS as retreived from RTSP.  So it isn't necessary.  But if you wanted to use the DM365 as a decoder without the hassle of an RTSP setup you could uses the duplicated SPS/PPS headers right from the stream.

    John A

  • Thank you Sirs,

        you were right, the problem was in the lack of the SPS at the beginning. I fixed this issue telling the encoder to put a keyframe with SPS and PPS each 25 frames (idrFrameInterval = 25). Then, when I start receiving I wait for the NAL with the SPS which should be the first the decoder feeds.

     

  • Does anyone know where I can find this idrFrameInterval?

    I'm not able to find this in the omap35xx codecs of the DVSDK version 4.

  • Rudger,

    I am using the DVSDK 2.10 however I think this does not change:

    IH264VENC_DynamicParams extnDynParams;

    ....

    extnDynParams.idrFrameInterval = 25; // for instance

    ...

    hVe1 = Venc1_create(hEngine, envp->videoEncoder, EncParams, (VIDENC1_DynamicParams*)&extnDynParams);

     

    Hope this helps.

  • I've looked around in the codecs-omap3530_4_00_00_00/packages/ti/sdo/codecs/h264enc/ih264venc.h where the struct IH264VENC_DynamicParams is defined but the option is not there anymore....

    Maybe it's replaced with some other option but none of the variables nor the user manual states anything about IDR frames.

    Thanks.

  • Yes your field should be there. I am using the latest version of the encoder (for DM365/368) Version 2.10.00.06. Maybe the codec for OMAP is different.

    My structure looks like this:

    typedef struct IH264VENC_DynamicParams
    {
      /*!
       * Mandatory fields of the DynamicParams structure - Base class
       */
      IVIDENC1_DynamicParams videncDynamicParams;
     
      /*!
       * Additional elements specific to H.264 Encoder - Extensions to base class
       */
      XDAS_Int32 sliceSize;        /*!< No. of MB rows per Slice */
      XDAS_Int32 airRate;          /*!< Adaptive Intra Refresh MB Period */
      XDAS_Int32 intraFrameQP;     /*!< Quant. param for I Slices (0-51) */
      XDAS_Int32 interPFrameQP;    /*!< Quant. Param for non - I Slices  */
      XDAS_Int32 initQ;           /*!< Initial QP for RC */
      XDAS_Int32 rcQMax;          /*!< Maximum QP to be used  Range[0,51] */
      XDAS_Int32 rcQMin;          /*!< Minimum QP to be used  Range[0,51] */
      XDAS_Int32 rcQMaxI;          /*!< Maximum QP to be used  Range[0,51] */
      XDAS_Int32 rcQMinI;          /*!< Minimum QP to be used  Range[0,51] */
      XDAS_Int32 rcAlgo;           /*!< Algorithm to be used by Rate Ctrl Scheme*/
                                   /*!< 0 -> CBR, 1 -> VBR */
      XDAS_Int32 maxDelay;         /*!< max delay for rate control interms of ms,*/
                                   /*!< set it to 1000 for 1 second delay  */
      XDAS_Int32 intraSliceNum;    /*!< MB Row number for forced intra slice */
      XDAS_Int32 lfDisableIdc;     /*!< Loop Filter enable/disable control */
      XDAS_Int32 meMultiPart;      /*!< Enable Multiple MB Partitions */
      XDAS_Int32 enableBufSEI;     /*!< Enable Buffering period SEI */
      XDAS_Int32 enablePicTimSEI;  /*!< Enable Picture Timing SEI */
      XDAS_Int32 intraThrQF;       /*!< Quality factor for Intra Thresholding */
      XDAS_Int32 perceptualRC;     /*!< Flag for enabling/disabling PRC */
      XDAS_Int32 idrFrameInterval;  /* IDR Frame Interval */
      XDAS_Int32 mvSADoutFlag;      /* Flag for enable/disable MVSAD out to the app*/
      XDAS_Int32 resetHDVICPeveryFrame; /* Flag for resetting hdvicp */
                                        /* after every frame encode */
      XDAS_Int32 enableROI;      /*!< 0 -> do not enable ROI, 1 -> enable ROI */
      XDAS_Int32 metaDataGenerateConsume; /* Flag to indicate Generate or Consume metaData*/
      XDAS_Int32 disableMVDCostFactor;  /* Reserved */
      IH264VENC_TI_DataSyncPutGetFxn putDataGetSpaceFxn;   /* Pointer to callback module */
      IH264VENC_TI_DataSyncHandle    dataSyncHandle;  /* Handle to datSyncDesc */
    } IH264VENC_DynamicParams;

     

  • This is mine...so they are different!

    Taken from DVSDK v4 for omap h264 codec version is 2.01.013

     

    typedef struct IH264VENC_DynamicParams {
      IVIDENC1_DynamicParams videncDynamicParams ; //!< must be followed for all video encoders
      XDAS_Int32      qpIntra                   ; //!< initial QP of I frames Range[-1,51]. -1 is for auto initialization

      XDAS_Int32      qpInter                   ; //!< initial QP of P frames Range[-1,51]. -1 is for auto initialization.
      XDAS_Int32      qpMax                     ; //!< Maximum QP to be used  Range[0,51]
      XDAS_Int32      qpMin                     ; //!< Minimum QP to be used  Range[0,51]
      XDAS_Int32      lfDisableIdc              ; //!< Controls enable/disable loop filter, See IH264VENC_LoopFilterParams for more details
      XDAS_Int32      quartPelDisable           ; //!< enable/disable Quarter Pel Interpolation
      XDAS_Int32      airMbPeriod               ; //!< Adaptive Intra Refesh MB Period: Period at which intra macro blocks should be insterted in a frame
      XDAS_Int32      maxMBsPerSlice            ; //!< Maximum number of macro block in a slice <minimum value is 8>
      XDAS_Int32      maxBytesPerSlice          ; //!< Maximum number of bytes in a slice
      XDAS_Int32      sliceRefreshRowStartNumber; //!< Row number from which slice needs to be intra coded
      XDAS_Int32      sliceRefreshRowNumber     ; //!< Number of rows to be coded as intra slice
      XDAS_Int32      filterOffsetA             ; //!< alpha offset for loop filter [-12, 12] even number
      XDAS_Int32      filterOffsetB             ; //!< beta offset for loop filter [-12, 12] even number
      XDAS_Int32      log2MaxFNumMinus4         ; //!< Limits the maximum frame number in the bit-stream to (1<< (log2MaxFNumMinus4 + 4)) Range[0,12]
      XDAS_Int32      chromaQPIndexOffset       ; //!< Specifies offset to be added to luma QP for addressing QPC values table for chroma components. Valid value is between -12 and 12, (inclusive)
      XDAS_Int32      constrainedIntraPredEnable; //!< Controls the intra macroblock coding in P slices [0,1]
      XDAS_Int32      picOrderCountType         ; //!< Picture Order count type Valid values 0, 2
      XDAS_Int32      maxMVperMB                ; //!< enable/Disable Multiple Motion vector per MB, valid values are [1, 4] [For DM6446, allowed value is only 1]
      XDAS_Int32      intra4x4EnableIdc         ; //!< See IH264VENC_Intra4x4Params for more details
      XDAS_Int32      mvDataEnable              ; //!< enable/Disable Motion vector access
      XDAS_Int32      hierCodingEnable          ; //!< Enable/Disable Hierarchical P Frame (non-reference P frame) Coding. [Not useful for DM6446]
      XDAS_Int32      streamFormat              ; //!< Signals the type of stream generated with Call-back
      XDAS_Int32      intraRefreshMethod        ; //!< Mechanism to do intra Refresh, see IH264VENC_IntraRefreshMethods for valid values
      XDAS_Int32      perceptualQuant           ; //!< Enable Perceptual Quantization a.k.a. Perceptual Rate Control
      XDAS_Int32      sceneChangeDet            ; //!< Enable Scene Change Detection
    //  XDAS_Int32      enableFrameSkip           ; //!< frameSkip control for VBR RC. (For CBR frame skip is always on) [0, 1].

      void   (*pfNalUnitCallBack)(
          XDAS_Int32    *pNalu,
          XDAS_Int32    *pPacketSizeInBytes,
          void *pContext
          )    ; //!< Function pointer of the call-back function to be used by Encoder

      void *pContext                            ; //!< pointer to context structure used during callback

      //!< Following Parameter are related to Arbitrary Slice Ordering (ASO)
      XDAS_Int32 numSliceASO                    ; //!< Number of valid enteries in asoSliceOrder array valid range is [0,8],
                                                  //!< where 0 and 1 doesn't have any effect
      XDAS_Int32 asoSliceOrder[MAXNUMSLCGPS]    ; //!< Array containing the order of slices in which they should
                                                  //!< be present in bit-stream. vaild enteries are [0, any entry lesser than numSlicesASO]

      //!< Following Parameter are related to Flexible macro block ordering (FMO)
      XDAS_Int32 numSliceGroups                 ; //!< Total Number of slice groups, valid enteries are [0,8]
      XDAS_Int32 sliceGroupMapType              ; //!< Slice GroupMapType : For Valid enteries see IH264VENC_SliceGroupMapType
      XDAS_Int32 sliceGroupChangeDirectionFlag  ; //!< Slice Group Change Direction Flag: Only valid when sliceGroupMapType
                                                  //!< is equal to IH264_RASTER_SCAN_SLICE_GRP.
                                                  //!< For valid values refer IH264VENC_SliceGroupChangeDirection
      XDAS_Int32 sliceGroupChangeRate           ; //!< Slice Group Change Rate: Only valid when sliceGroupMapType
                                                  //!< is equal to IH264_RASTER_SCAN_SLICE_GRP.
                                                  //!< valid values are : [0, factor of number of Mbs in a row]
      XDAS_Int32 sliceGroupChangeCycle          ; //!< Slice Group Change Cycle: Only valid when sliceGroupMapType
                                                  //!< is equal to IH264_RASTER_SCAN_SLICE_GRP.
                                                  //!< Valid values can be 0 to numMbsRowsInPicture, also constrained
                                                  //!< by sliceGroupChangeRate*sliceGroupChangeCycle < totalMbsInFrame
      XDAS_Int32 sliceGroupParams[MAXNUMSLCGPS] ; //!< This field is useful in case of sliceGroupMapType equal to either
                                                  //!< IH264_INTERLEAVED_SLICE_GRP or IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP
                                                  //!< In both cases it has different meaning:
                                                  //!< In case of IH264_INTERLEAVED_SLICE_GRP:
                                                  //!< The i-th entery in this array is used to specify the number of consecutive
                                                  //!< slice group macroblocks to be assigned to the i-th slice group in
                                                  //!< raster scan order of slice group macroblock units.
                                                  //!< Valid values are 0 to totalMbsInFrame again constrained by sum of all the elements
                                                  //!< shouldn't exceed totalMbsInFrame
                                                  //!< In case of IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP:
                                                  //!< First entry in the array specify the start position of foreground region in terms
                                                  //!< of macroblock number, valid values are [0, totalMbsInFrame-1]
                                                  //!< Second entry in the array specify the end position of foreground region in terms
                                                  //!< of macroblock number, valid values are [0, totalMbsInFrame-1] with following constrains:
                                                  //!< endPos > startPos && endPos%mbsInOneRow > startPos%mbsInOneRow
    } IH264VENC_DynamicParams;