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.

How to improve video quality of H.264 Encoder on DM365

Hi,

We are trying to develop an H.264 encoder application on DM365. When compared to other encoded bitstreams subjectively, I have seen that our encoder has worse quality than the others. In order to verify this observation, I have performed some objective tests and share the results here. So, I want to learn your ideas about how to improve the video quality. My test procedure is as follows;

1) I have downloaded some YUV test files and convert them to NV12 (YUV 4:2:0 semi-planar format) in order to use them on DM365.

2) I have used Digital video test bench (DVTB) in order to compress these YUV files to H.264 format.

3) I have compressed the same files by using "ffmpeg" in order to make a comparison. The bitrate used on DM365 and ffmpeg are almost same.

4) Both of the compressed files obtained by using DVTB on DM365 and ffmpeg are converted to YUV files (YUV 4:2:0 planar format).

5) The MSU video quality measurement tool is used to perform some objective measurements (PSNR and SSIM) on the original file and the files obtained in step 4. Also, Bitrate Viewer software is used to see the bitrates of the compressed files.

The test results and the obtained observations are given as follows;

The average bitrates of both compressed files are around 3300 kb/s as shown below.

The PSNR measurement is given below;

The SSIM measurement is given in figure below, as well.

As seen from both PSNR and SSIM measurements, ffmpeg is better and very consistent among all frames. TI encoder has worse quality than ffmpeg and the values are always changing, sometimes strange peaks and sometimes dips. The ffmpeg measurements are more stable.

This quality difference can be seen visually in a sample frame, as well. If you look at frame 110, which the cursor exists in the SSIM measurement in figure above, you can see that the original, ffmpeg coded and DM365 TI DVTB coded images are very different. All three images are given below.

Original image;

The encoded image with ffmpeg;

The encoded image with TI DVTB on DM365

If you compare the images visually, it is seen that the encoded image with ffmpeg is very close to the original one and these images are clear. But the encoded image with TI DVTB on DM365 has visible distortions. Especially, if you look at the face of the man with moustache in the right, it is very blurry. In general, the image is blurry and the image quality is low when compared to original or ffmpeg coded image. I have also tried to increase the bitrate to 5-6 mb/s for TI encoder, it is still blurry. I want to learn the reason this and I want to learn what I can.

Below, you can find the encoder parameters I set before encoding. The problem is most likely due to encoder parameters, I guess. So, please share your ideas with me on how to improve the video quality. Thanks in advance.

** DVTB Encoder commands for settings

setp engine name encodedecode
setp h264enc1 codec h264enc1
setp h264enc1 encodingPreset 3
setp h264enc1 rateControlPreset 5
setp h264enc1 maxHeight 576
setp h264enc1 maxWidth 704
setp h264enc1 maxFrameRate 30000
setp h264enc1 maxBitRate 4000000
setp h264enc1 dataEndianness 1
setp h264enc1 maxInterFrameInterval 0
setp h264enc1 inputChromaFormat 9
setp h264enc1 inputContentType 0
setp h264enc1 reconChromaFormat 9
setp h264enc1 topFieldFirstFlag 1
setp h264enc1 inputHeight 576
setp h264enc1 inputWidth 704
setp h264enc1 refFrameRate 30000
setp h264enc1 targetFrameRate 30000
setp h264enc1 targetBitRate 4000000
setp h264enc1 intraFrameInterval 30
setp h264enc1 generateHeader 0
setp h264enc1 captureWidth 0
setp h264enc1 forceFrame 0
setp h264enc1 interFrameInterval 0
setp h264enc1 mbDataFlag 0
setp h264enc1 profileIdc 100
setp h264enc1 levelIdc 40
setp h264enc1 meAlgo 0
setp h264enc1 enableVUIparams 0
setp h264enc1 EntropyMode 1
setp h264enc1 Transform8x8FlagIntraFrame 1
setp h264enc1 Transform8x8FlagInterFrame 0
setp h264enc1 EnableLongTermFrame 0
setp h264enc1 ConstraintSetFlag 0
setp h264enc1 Log2MaxFrameNumMinus4 0
setp h264enc1 svcSyntaxEnable 0
setp h264enc1 numTemporalLayers 0
setp h264enc1 resetHDVICPeveryFrame 0
setp h264enc1 SeqScalingFlag 1
setp h264enc1 EncQuality 0
setp h264enc1 enableARM926Tcm 1
setp h264enc1 enableDDRbuff 0
setp h264enc1 sliceMode 0
setp h264enc1 outputDataMode 1
setp h264enc1 sliceFormat 1
setp h264enc1 sliceSize 28
setp h264enc1 airRate 28
setp h264enc1 initQ -1
setp h264enc1 intraFrameQP 0
setp h264enc1 interPFrameQP 0
setp h264enc1 rcQMax 44
setp h264enc1 rcQMin 8
setp h264enc1 rcAlgo 1
setp h264enc1 maxDelay 2000
setp h264enc1 lfDisableIdc 0
setp h264enc1 aspectRatioX 1
setp h264enc1 aspectRatioY 1
setp h264enc1 enableBufSEI 0
setp h264enc1 enablePicTimSEI 0
setp h264enc1 perceptualRC 1
setp h264enc1 idrFrameInterval 100
setp h264enc1 mvSADoutFlag 0
setp h264enc1 enableROI 0
setp h264enc1 metaDataGenerateConsume 0
setp h264enc1 maxBitrateCVBR 768000
setp h264enc1 maxHighCmpxIntCVBR 0
setp h264enc1 CVBRsensitivity 0
setp h264enc1 LBRmaxpicsize 0
setp h264enc1 LBRminpicsize 0
setp h264enc1 LBRskipcontrol 0
setp h264enc1 interlaceRefMode 0
setp h264enc1 LongTermRefreshInterval 0
setp h264enc1 UseLongTermFrame 0
setp h264enc1 SetLongTermFrame 0
setp h264enc1 enableGDR 0
setp h264enc1 GDRduration 5
setp h264enc1 GDRinterval 30
setp h264enc1 numOfROI 0
setp h264enc1 numFrames 300
func h264enc1 -s crew_nv12.yuv -t crew_cmp_dm365.h264

**ffmpeg encoding command

ffmpeg -s 704x576 -pix_fmt yuv420p -i CREW_704x576_30_orig_01.yuv -vcodec libx264 -b 3300k -preset slow crew_cmp_ffmpeg.h264

  • 0755.h264_files.rar

    I don't know why but there has been a problem while uploading the h264 compressed files.

    I am attaching the files now; you can find the encoded files by both TI encoder and ffmpeg encoder.

    Thanks in advance,
    Fikret

  • Hi Fikret,

    You are comparing PC encoder with DM365, There will be lot of things matters like DM365 will use less resources and minimal power and achieves realtime encoding.In realtime encoding there will always compromise between speed performance Vs Quality. For ex: motion search range  and number of ref frames matters in P frame encoding.

    And we seen your 2 videos from ffmpeg and DM365, ffmpeg video encoded with B frames and 5 ref frames while DM365 has single ref and no B frames. Try by encoding ffmpeg video IPP, single ref, and reduced search range encoding. With this you may minimal diff but not same quality.

    Thanks,

    Veeranna

  • Dear Veeranna,

    Thank you for your answer. Ok, you are right, one of them is real-time and the other is a PC encoder, but before this comparison with the exactly same video frontend (input),  I have compared TI encoder and another embedded encoder from another company. The encoded video with TI encoder is blurry while the encoded video with the other embedded encoder is more sharper and clear for the same bitrate. That's why I made this comparison.

    Let me ask in a different way. I don't wait exactly the same quality with ffmpeg, but if you notice the quality difference is very obvious and according to me there is a sharpness problem or blurriness problem in the encoded video with TI encoder. What can I do to solve this problem? Did you check my encoder parameters, are they correct? Or do you have some recommendations for the encoder parameters? 

    I have also seen a document SPRAB83 - Smart Codec Features of DM365 which explains some enhancements such as multi-pass encoding, does it help to me? Please share your recommendations with me.

    Thanks&Best Regards,

    Fikret

  • Hi Fikert,

    Can you try by setting below params. And hope you are using latest encoder (02.30.00.04), if not download it from

    http://software-dl.ti.com/dsps/dsps_public_sw/codecs/DM36x/index_FDS.html

    Params

    setp h264enc1 EncQuality 1

    setp h264enc1 airRate 0

    setp h264enc1 perceptualRC 0

    setp h264enc1 idrFrameInterval 0 or make it overlap to intraframe interval

    Thanks,

    Veeranna

  • Dear Veeranna,

    We were not using the latest encoder version, the version was 02.20.00.01. So I have updated the codec version and the parameters you recommended. Now, there is an enhancement in the video quality. It can be seen by visually or with the measurements. Here is the bitrate of the new encoded file with DM365;

    The PSNR measurement of newly encoded file and ffmpeg is given below;

    The SSIM measurement of dm365 and ffmpeg is given below;

    The measurements for the previously encoded file and the newly encoded file are given for a comparison as follows;

    The PSNR;

    The SSIM;

    And the frame 110 of the new encoded file is given below;

    As it can be seen both visually and by measurements, there is an improvement in the video quality with these new settings. But when I compare the video quality with the other embedded encoder, it is still sharper and clearer. The blurring problem of TI encoder is improved when compared to the previous one, but as I said still the other one is better. I am going to share two clips from both TI encoder and the other embedded encoder.

    What I want to ask is if there is a possibility for further improvement of the video quality? In my previous post, I asked about the smart encoder features; multi-pass encoding or region based encoding, do they help to us for a better video quality? Or any other parameter tuning? Or the last possibility, this is all that we can do for the quality? :) 

    Thank you for your support Veerena.

    Best Regards,

    Fikret

  • 1321.encoded_video.rar

    Hi again,

    Here are the sample encoded video clips for the benchmark product and dm365 encoder. As it can be seen, the video is sharper and clearer in the benchmark. The edges are noisy in DM365 encoded video and still there is a blurriness problem. Movie player can be used to watch the videos. Are there anything we can do in order to prevent this problem?

    Thanks &Best Regards,

    Fikret

  • Hi,

    We are looking into videos shared by you. Just to conform can you please tell how you generated the dm365 video? because it has B frames.(I guess you recorded the video while displaying the DM365 output)

  • Hi Veerana,

    I have recorded both videos by using VLC over RTSP, but I've only recorded, not displayed. Do you want me to record both encoders with an NVR?

    Thanks&Best Regards,

    Fikret

  • Hi Fikret,

    Recording with VLC will actually do re-encoding. Pls try to give the original encoded content of DM365 and the benchmark device, I think the NVR will do that job.

    regards

    Yashwant

  • Dear Yashwant,

    Attached, you can find the new clips that are directly recorded for DM365 and benchmark product. Thank you for your helps.

    Best Regards,

    Fikret

    5633.new_h264clips.rar

  • Dear Yashwant and Veerenna,

    Did you check the clips? Any recommendations?

    Thanks&Best Regards,

    Fikret

  • Hi Fikret,

    Thanks, we are looking into the issue. Can you also tell the data flow in both the cases ? Wanted to understand if there are other module before video encoding which are different in these two platforms.

    regards

    Yashwant

  • Dear Yashwant,

    For TI platform, we do not perform anything before or after video encoding; just simple video encoding operation is performed, no analytics or any kind of enhancements.

    For the other platform, there is an SoC from another company. So I don't know if they have used extra modules or not. But if you want, I can share the IC part number of the SoC.

    Best Regards,

    Fikret

  • Dear Yashwant,

    Any updates or recommendations?  We are waitin for your answer in order to proceed. Thanks in advance.

    Best Regards,

    Fikret Alim

  • According to the encoding skill of your bitstream, I think the benchmark encoder should be Amba's encoder.