[Bug]: The HEVC encoder produces B-frames even when configured with a maximum of zero B-frames
- Dominant language
- C
- Stars
- 1.2k
- Forks
- 383
- Avg merge
- 8d 18h
- Merged PRs (30d)
- 4
Description
### Which component impacted?
_No response_
### Is it regression? Good in old configuration?
None
### What happened?
> NOTE: In other computers this issue does not happen, even in another with the same CPU.
1. In Linux or Browser or Applications...
**Hardware:** 13th Gen Intel(R) Core(TM) i7-1355U
[cpuinfo.txt](https://github.com/user-attachments/files/23936709/cpuinfo.txt)
**OS:** 24.04.1 LTS (Noble Numbat)
**Application:** [hevcencode](https://github.com/intel/libva-utils/blame/master/encode/hevcencode.c) from libva-utils @ b4abf4e2 and GStreamer 1.24.2
2. With libva/libva-utils/gmmlib/media-driver version
**libva-utils version:** b4abf4e2 (master)
**libva version**: 2.23.0.pre1
**gmmlib version:** 3a256e6762eedd971a56f67804d8a57eb4239c6e (master)
**media-driver version:** intel-media-25.4.5
3. Run '...'
In all the cases, B frames are generated, even if the programs are instructed to use 0 B frames
With hevcencode
```
$ ffmpeg -y -f lavfi -i testsrc=size=1920x1080:rate=30 -t 10 -pix_fmt nv12 output_nv12.yuv
$ ./encode/hevcencode --srcyuv output_nv12.yuv -w 1920 -h 1080 --fourcc NV12 -n 300 --ip_period 1 --intra_period 15 -o output.h265
$ ffprobe output.h265 -select_streams v -show_frames -show_entries frame=key_frame,pict_type,coded_picture_number -of csv |& grep "frame," | grep ",B" | wc -l
275
```
With GStreamer's vah265enc
```
forccon@forccon-T14:~/checkout/misc/libva-utils/b$ LD_LIBRARY_PATH=/home/forccon/checkout/fluendo/iHD_docker/build/lib/ LIBVA_DRIVERS_PATH=/home/forccon/checkout/fluendo/iHD_docker/build/lib/dri/ LIBVA_DRIVER_NAME=iHD gst-launch-1.0 filesrc location=output_nv12.yuv ! videoparse width=1920 height=1080 format=23 framerate=30/1 ! videoconvert ! vaapih265enc max-bframes=0 ! filesink location=out_vah265enc.h265
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'vaapiencodeh265-0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0", gst.vaapi.Display.GObject=(GstObject)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:01.299220726
Setting pipeline to NULL ...
Freeing pipeline ...
forccon@forccon-T14:~/checkout/misc/libva-utils/b$ ffprobe out_vah265enc.h265 -select_streams v -show_frames -show_entries frame=key_frame,pict_type,coded_picture_number -of csv |& grep "frame," | grep ",B" | wc -l
290
```
With GStreamer's vaapih265enc
```
forccon@forccon-T14:~/checkout/misc/libva-utils/b$ LD_LIBRARY_PATH=/home/forccon/checkout/fluendo/iHD_docker/build/lib/ LIBVA_DRIVERS_PATH=/home/forccon/checkout/fluendo/iHD_docker/build/lib/dri/ LIBVA_DRIVER_NAME=iHD gst-launch-1.0 filesrc location=output_nv12.yuv ! videoparse width=1920 height=1080 format=23 framerate=30/1 ! videoconvert ! vaapih265enc max-bframes=0 ! filesink location=out_vaapih265enc.h265
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'vaapiencodeh265-0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0", gst.vaapi.Display.GObject=(GstObject)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:01.278701051
Setting pipeline to NULL ...
Freeing pipeline ...
forccon@forccon-T14:~/checkout/misc/libva-utils/b$ ffprobe out_vaapih265enc.h265 -select_streams v -show_frames -show_entries frame=key_frame,pict_type,coded_picture_number -of csv |& grep "frame," | grep ",B" | wc -l
290
```
Expected output: 0 (b-frames)
### What's the usage scenario when you are seeing the problem?
Others, Transcode for media delivery
### What impacted?
_No response_
### Debug Information
[hevcencode_libva_logs.zip](https://github.com/user-attachments/files/23937770/hevcencode_libva_logs.zip)
### Do you want to contribute a patch to fix the issue?
None
Contributor guide
Assessment
This issue has not been assessed yet.