Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

Can HEVC software encoder encode interlaced frames

koby_s_
Beginner
2,210 Views

Hi

I am trying to encode an interlaced HEVC stream using the software HEVC plugin.
When I configure the PicStruct to MFX_PICSTRURCT_PROGRESSIVE the output is ok and the resolution is correct
When I configure the PicStruct to MFX_PICSTRUCT_FIELD_TFF the output height is half of the expected resolution.

It happens in sample_encode.exe
The command line I used:
For progressive output : sample_encode.exe h265 -i in.yuv -w 1920 -h 1080 -b 2000 -sw -o out.265
For interlaced output : sample_encode.exe h265 -i in.yuv -w 1920 -h 1080 -tff -b 2000 -sw -o out.265

Attached are the outputs from the encoder.

Another question that I have is: Is there any way to tell if HEVC stream is interlaced or progressive by looking in the elementary stream?

Thank you

Koby

0 Kudos
1 Solution
Nikolay_S_3
Beginner
2,210 Views

Koby,

Half-height is expected in TFF (or BFF) case.

When PicStruct is MFX_PICSTRUCT_FIELD_TFF/BFF HEVC encoder interprets input mfxFrameSurface as a pair of interleaved fields. Each field is processes as a picture of resolution Width x (Height/2).

To the second question: in elementary stream you may check SPS.VUI.field_seq_flag. If it is 0 then video sequence is progressive, otherwise it is interlaced. Also when field_seq_flag=1 "pic_struct" syntax element will present in every PicTiming SEI indicating if particular picture is Top Field or Bottom Field.

Also checked your bitstreams. "out-i.256" is actually TFF interlaced. It may be decoded with HM reference decoder (I used version 16.7). It parses pic_struct and interleaves Top and Bottom field pairs. So output YUV has original resolution Width x Height.

Thank you for asking.

-Nik

 

View solution in original post

0 Kudos
5 Replies
Nikolay_S_3
Beginner
2,211 Views

Koby,

Half-height is expected in TFF (or BFF) case.

When PicStruct is MFX_PICSTRUCT_FIELD_TFF/BFF HEVC encoder interprets input mfxFrameSurface as a pair of interleaved fields. Each field is processes as a picture of resolution Width x (Height/2).

To the second question: in elementary stream you may check SPS.VUI.field_seq_flag. If it is 0 then video sequence is progressive, otherwise it is interlaced. Also when field_seq_flag=1 "pic_struct" syntax element will present in every PicTiming SEI indicating if particular picture is Top Field or Bottom Field.

Also checked your bitstreams. "out-i.256" is actually TFF interlaced. It may be decoded with HM reference decoder (I used version 16.7). It parses pic_struct and interleaves Top and Bottom field pairs. So output YUV has original resolution Width x Height.

Thank you for asking.

-Nik

 

0 Kudos
koby_s_
Beginner
2,210 Views

Hi Nikolay

Thank you for the response and explaination!

This is the first time that I'm encoding interlaced HEVC streams.

Another question that I have regarding HEVC interlaced stream is about the frame rate.

I configured the encoder to 29.97 but I see in the SPS.VUI.timing_info frame rate of 59.94 (60000/1001).

I assume it's not a frame rate, but the field rate. Am I correct ?

Thank you

Koby

0 Kudos
Surbhi_M_Intel
Employee
2,210 Views

Hi Koby, your understanding is correct, it is representing field rate instead of frame rate.

Hi Nikolay, thanks for the great explanation before.

0 Kudos
koby_s_
Beginner
2,210 Views

Hi Nikolay,
Sorry for bringing this old post but I still have a question regarding Interlaced HEVC stream.
As you said in your reply, the HM reference decoder does generate a correct frame size (1920x1080).
I noticed a problem (or a bug?) when I tried to decode the interlaced HEVC sample that I uploaded using sample_decode.
Unfortunatelly, sample_decode decodes the stream incorrectly. I was expecting sample_decode to output yuv file with a frame size of 1920x1080 but as you can see, it outputs 1/2 of the frame size and doubles the frame rate.

My source was MPEG2 video, 1920x1080 interlaced, 60 fields per second
I encoded it to HEVC, 1920x1080 interlaced (output attached in the original post). The encoder generated 1920x544 stream, 60 fields per second
Decoding the HEVC output generated 1920x540, 60 fps, yuv file.
I was expecting to get a yuv file of 1920x1080 30 fps (with interleaved fields).
Am I wrong?
Can you explain the behaviour of the decoder?

C:\Users\koby\Documents\Samples for Intel(R) Media Server Studio 201 for Windows 6.0.0.206\_bin\x64>sample_decode.exe h265 -i out-i.265 -sw -r
plugin_loader.h :170 [INFO] Plugin was loaded from GUID: { 0x15, 0xdd, 0x93, 0x68, 0x25, 0xad, 0x47, 0x5e, 0xa3, 0x4e, 0x35, 0xf3, 0xf5, 0x42, 0x17, 0xa6 } (Intel (R) Media SDK plugin for HEVC DECODE)
pretending that aspect ratio is 1:1
Decoding Sample Version 6.0.0.206

Input video     HEVC
Output format   NV12
Input:
  Resolution    1920x544
  Crop X,Y,W,H  0,0,0,0
Output:
  Resolution    1920x544
Frame rate      60.00
Memory type             d3d
MediaSDK impl           sw
MediaSDK version        1.19

Decoding started
Frame number:  166, fps: 57.896, fread_fps: 0.000, fwrite_fps: 78.1713
Decoding finished
plugin_loader.h :196 [INFO] MFXBaseUSER_UnLoad(session=0x0000000002DB93C0), sts=0

I am using latest Media Server Studio Professional 2017

Thank you

Koby

0 Kudos
JONAS_O_
Beginner
2,210 Views

 

Is this supposed to be working on the HW accelerated encoder as well using skylake and the 2017R3-release?
If not, how is that supposed to be done?

0 Kudos
Reply