Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build against kernel 5.11.x #35

Open
rathann opened this issue May 13, 2021 · 35 comments
Open

Fails to build against kernel 5.11.x #35

rathann opened this issue May 13, 2021 · 35 comments

Comments

@rathann
Copy link

rathann commented May 13, 2021

It looks like nearly all of the structs defined in include/h264-ctrls.h are defined in /usr/include/linux/v4l2-controls.h already:

$ /usr/bin/meson compile -C aarch64-redhat-linux-gnu --verbose
Found runner: ['/usr/bin/ninja']
ninja: Entering directory `aarch64-redhat-linux-gnu'
[1/4] gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/h264.c.o -MF src/v4l2_request_drv_video.so.p/h264.c.o.d -o src/v4l2_request_drv_video.so.p/h264.c.o -c ../src/h264.c
FAILED: src/v4l2_request_drv_video.so.p/h264.c.o 
gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/h264.c.o -MF src/v4l2_request_drv_video.so.p/h264.c.o.d -o src/v4l2_request_drv_video.so.p/h264.c.o -c ../src/h264.c
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:52:8: error: redefinition of ‘struct v4l2_ctrl_h264_sps’
   52 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1273:8: note: originally defined here
 1273 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:82:8: error: redefinition of ‘struct v4l2_ctrl_h264_pps’
   82 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1329:8: note: originally defined here
 1329 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:96:8: error: redefinition of ‘struct v4l2_ctrl_h264_scaling_matrix’
   96 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1361:8: note: originally defined here
 1361 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:101:8: error: redefinition of ‘struct v4l2_h264_weight_factors’
  101 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1366:8: note: originally defined here
 1366 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:122: warning: "V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED" redefined
  122 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x04
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1403: note: this is the location of the previous definition
 1403 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x01
      | 
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:123: warning: "V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH" redefined
  123 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x08
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1404: note: this is the location of the previous definition
 1404 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x02
      | 
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:125:8: error: redefinition of ‘struct v4l2_ctrl_h264_slice_params’
  125 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1464:8: note: originally defined here
 1464 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:173:8: error: redefinition of ‘struct v4l2_h264_dpb_entry’
  173 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1509:8: note: originally defined here
 1509 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from ../src/h264.c:36:
../include/h264-ctrls.h:185:8: error: redefinition of ‘struct v4l2_ctrl_h264_decode_params’
  185 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/h264.c:35:
/usr/include/linux/v4l2-controls.h:1546:8: note: originally defined here
 1546 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[2/4] gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/context.c.o -MF src/v4l2_request_drv_video.so.p/context.c.o.d -o src/v4l2_request_drv_video.so.p/context.c.o -c ../src/context.c
FAILED: src/v4l2_request_drv_video.so.p/context.c.o 
gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/context.c.o -MF src/v4l2_request_drv_video.so.p/context.c.o.d -o src/v4l2_request_drv_video.so.p/context.c.o -c ../src/context.c
In file included from ../src/context.c:43:
../include/h264-ctrls.h:52:8: error: redefinition of ‘struct v4l2_ctrl_h264_sps’
   52 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1273:8: note: originally defined here
 1273 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:82:8: error: redefinition of ‘struct v4l2_ctrl_h264_pps’
   82 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1329:8: note: originally defined here
 1329 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:96:8: error: redefinition of ‘struct v4l2_ctrl_h264_scaling_matrix’
   96 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1361:8: note: originally defined here
 1361 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:101:8: error: redefinition of ‘struct v4l2_h264_weight_factors’
  101 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1366:8: note: originally defined here
 1366 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:122: warning: "V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED" redefined
  122 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x04
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1403: note: this is the location of the previous definition
 1403 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x01
      | 
In file included from ../src/context.c:43:
../include/h264-ctrls.h:123: warning: "V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH" redefined
  123 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x08
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1404: note: this is the location of the previous definition
 1404 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x02
      | 
In file included from ../src/context.c:43:
../include/h264-ctrls.h:125:8: error: redefinition of ‘struct v4l2_ctrl_h264_slice_params’
  125 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1464:8: note: originally defined here
 1464 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:173:8: error: redefinition of ‘struct v4l2_h264_dpb_entry’
  173 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1509:8: note: originally defined here
 1509 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from ../src/context.c:43:
../include/h264-ctrls.h:185:8: error: redefinition of ‘struct v4l2_ctrl_h264_decode_params’
  185 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/context.c:28:
/usr/include/linux/v4l2-controls.h:1546:8: note: originally defined here
 1546 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[3/4] gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/config.c.o -MF src/v4l2_request_drv_video.so.p/config.c.o.d -o src/v4l2_request_drv_video.so.p/config.c.o -c ../src/config.c
FAILED: src/v4l2_request_drv_video.so.p/config.c.o 
gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/config.c.o -MF src/v4l2_request_drv_video.so.p/config.c.o.d -o src/v4l2_request_drv_video.so.p/config.c.o -c ../src/config.c
In file included from ../src/config.c:38:
../include/h264-ctrls.h:52:8: error: redefinition of ‘struct v4l2_ctrl_h264_sps’
   52 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1273:8: note: originally defined here
 1273 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:82:8: error: redefinition of ‘struct v4l2_ctrl_h264_pps’
   82 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1329:8: note: originally defined here
 1329 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:96:8: error: redefinition of ‘struct v4l2_ctrl_h264_scaling_matrix’
   96 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1361:8: note: originally defined here
 1361 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:101:8: error: redefinition of ‘struct v4l2_h264_weight_factors’
  101 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1366:8: note: originally defined here
 1366 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:122: warning: "V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED" redefined
  122 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x04
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1403: note: this is the location of the previous definition
 1403 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED     0x01
      | 
In file included from ../src/config.c:38:
../include/h264-ctrls.h:123: warning: "V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH" redefined
  123 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x08
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1404: note: this is the location of the previous definition
 1404 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH              0x02
      | 
In file included from ../src/config.c:38:
../include/h264-ctrls.h:125:8: error: redefinition of ‘struct v4l2_ctrl_h264_slice_params’
  125 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1464:8: note: originally defined here
 1464 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:173:8: error: redefinition of ‘struct v4l2_h264_dpb_entry’
  173 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1509:8: note: originally defined here
 1509 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from ../src/config.c:38:
../include/h264-ctrls.h:185:8: error: redefinition of ‘struct v4l2_ctrl_h264_decode_params’
  185 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from ../src/request.h:37,
                 from ../src/config.h:33,
                 from ../src/config.c:27:
/usr/include/linux/v4l2-controls.h:1546:8: note: originally defined here
 1546 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

If I patch out all the struct definitions, I get this error:

[13/18] gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/h264.c.o -MF src/v4l2_request_drv_video.so.p/h264.c.o.d -o src/v4l2_request_drv_video.so.p/h264.c.o -c ../src/h264.c
FAILED: src/v4l2_request_drv_video.so.p/h264.c.o 
gcc -Isrc/v4l2_request_drv_video.so.p -Isrc -I../src -I../include -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -Wall -fvisibility=hidden -MD -MQ src/v4l2_request_drv_video.so.p/h264.c.o -MF src/v4l2_request_drv_video.so.p/h264.c.o.d -o src/v4l2_request_drv_video.so.p/h264.c.o -c ../src/h264.c
../src/h264.c: In function ‘h264_va_picture_to_v4l2’:
../src/h264.c:223:15: error: ‘struct v4l2_ctrl_h264_decode_params’ has no member named ‘num_slices’
  223 |         decode->num_slices = surface->slices_count;
      |               ^~
../src/h264.c: In function ‘h264_va_slice_to_v4l2’:
../src/h264.c:332:14: error: ‘struct v4l2_ctrl_h264_slice_params’ has no member named ‘size’
  332 |         slice->size = VASlice->slice_data_size;
      |              ^~
../src/h264.c:359:51: error: incompatible types when assigning to type ‘struct v4l2_h264_reference’ from type ‘unsigned int’
  359 |                         slice->ref_pic_list0[i] = idx;
      |                                                   ^~~
../src/h264.c:378:51: error: incompatible types when assigning to type ‘struct v4l2_h264_reference’ from type ‘unsigned int’
  378 |                         slice->ref_pic_list1[i] = idx;
      |                                                   ^~~
../src/h264.c:385:14: error: ‘struct v4l2_ctrl_h264_slice_params’ has no member named ‘pred_weight_table’
  385 |         slice->pred_weight_table.chroma_log2_weight_denom =
      |              ^~
../src/h264.c:387:14: error: ‘struct v4l2_ctrl_h264_slice_params’ has no member named ‘pred_weight_table’
  387 |         slice->pred_weight_table.luma_log2_weight_denom =
      |              ^~
../src/h264.c:392:44: error: ‘struct v4l2_ctrl_h264_slice_params’ has no member named ‘pred_weight_table’
  392 |                 h264_copy_pred_table(&slice->pred_weight_table.weight_factors[0],
      |                                            ^~
../src/h264.c:400:44: error: ‘struct v4l2_ctrl_h264_slice_params’ has no member named ‘pred_weight_table’
  400 |                 h264_copy_pred_table(&slice->pred_weight_table.weight_factors[1],
      |                                            ^~
@bjharper
Copy link

bjharper commented May 15, 2021

Im having the same problem and looks like h264 definitions in the kernel have been updated for example https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.11.21&id=2287c5e65cbcc99633c412dbfe1d39bd9f7bf1ce

I did try to hack in some changes too see if I could sync up the api changes and use the headers from the 5.11 kernel but getting too deep for me to understand. At runtime I was left with:

$ LIBVA_DRIVER_NAME=v4l2_request LIBVA_DRIVERS_PATH=/usr/local/lib/aarch64-linux-gnu/dri vainfo libva info: VA-API version 1.8.0 libva info: User environment variable requested driver 'v4l2_request' libva info: Trying to open /usr/local/lib/aarch64-linux-gnu/dri/v4l2_request_drv_video.so libva error: dlopen of /usr/local/lib/aarch64-linux-gnu/dri/v4l2_request_drv_video.so failed: /usr/local/lib/aarch64-linux-gnu/dri/v4l2_request_drv_video.so: undefined symbol: tiled_to_planar libva info: va_openDriver() returns -1 vaInitialize failed with error code -1 (unknown libva error),exit .
Would be great if someone with more experiance could take a look at the new kernel changes

Edit: The tiled_to_planar issue seems resolved in this pull request #32 for aarch64 but still vaInitialize errors that I don't have the expertise to understand:

$ LIBVA_DRIVER_NAME=v4l2_request LIBVA_DRIVERS_PATH=/usr/local/lib/aarch64-linux-gnu/dri vainfo libva info: VA-API version 1.8.0 libva info: User environment variable requested driver 'v4l2_request' libva info: Trying to open /usr/local/lib/aarch64-linux-gnu/dri/v4l2_request_drv_video.so libva info: Found init function __vaDriverInit_1_8 libva error: /usr/local/lib/aarch64-linux-gnu/dri/v4l2_request_drv_video.so init failed libva info: va_openDriver() returns 1 vaInitialize failed with error code 1 (operation failed),exit

@wolfallein
Copy link

I can confirm that I cannot compile it for kernel 5.12. In the past, I was able to get it working for kernel 5.7, making small changes to the kernel source to revert the new h264 definitions that @bjharper mentioned, see #31. Now the kernel sources are much more complicated to follow what changed in the h264 def. and I could not revert it, although it would be much better to modify the libva-v4l2-request to follow the kernel modifications. Unfortunately, I have no idea how to do it and already spent many hours on it.

It is a pity that a lot of work was done to get Cedrus working in the past, and we cannot use it after 2 years that the development stopped. I'm afraid that Cedrus will never go from stagging and may be dropped from the kernel sources entirely.

@jernejsk
Copy link
Contributor

There is no intention to drop Cedrus. In fact, there is a talk to promote it to stable in near future, together with Hantro. This library is not maintained though. Easy way to use it would be 5.12 kernel and gstreamer build from latest development sources. Another possibility would be ffmpeg with additional patches...

@wolfallein
Copy link

@jernejsk That is very good news! I'm already using kernel 5.12. Can you point me to the GStreamer version that would work? I heard about this patched ffmpeg version, is this patch from LibreELEC you are referring to? Should I use it the same way as in:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/video1 -hwaccel_output_format vaapi -i video.mp4 -f null /dev/null

would this work? I'll try it fast :)

Thank you!

@jernejsk
Copy link
Contributor

As I said, use latest gstreamer development sources from git. Latest stable version doesn't include necessary improvements yet. And I don't know what command would be needed to actually use Cedrus. Check #linux-sunxi IRC log.

Regarding ffmpeg, that patchset is for kernel 5.10 and it presumes that additional kernel patches are applied for codecs other than H264. And no, that line won't work. Those patches have nothing to do with VAAPI.

Something like this may work:
ffmpeg -hwaccel drm -hwaccel_device /dev/dri/card0 -hwaccel_output_format drm_prime -i video.mkv -f null -

Both approaches were already discussed on #linux-sunxi IRC and Armbian forum, so I suggest you check there for further info.

@rathann
Copy link
Author

rathann commented May 18, 2021

That won't help with Firefox, which is using VA-API for hardware video decoding. Or Chromium with the unofficial patch that most distributions are using. We really need a working VA-API driver for the most common use case here. Regarding the FFmpeg patch, I have seen no response from its author to initial review on the developer mailing list, so I don't think it's going to be included any time soon.

@bjharper
Copy link

Yes I'm looking for VA-API solution for amlogic platforms (particularly for firefox / chromium). . I might have another go at resolving some of the issues interfacing with the newer kernel but it will be a big learning curve for me. ffmpeg with v4l2 decoder is working ok on my platform.

@jernejsk
Copy link
Contributor

@rathann The thing is: development is driven by developer needs or contracts. In my case, I only care about Cedrus and ffmpeg (I'm co-author of ffmpeg patches) since I need them for Kodi on LibreELEC. Collabora mostly works only on Hantro and gstreamer. You can still check status of forks of this repo - at least one updated some codecs in the past.

Regarding ffmpeg patches - there is still plan to send updated version but some parts need redesign (apart from addressing comments). Since V4L2 request API is still evolving and we don't have much spare time for this, it will take a while longer.

@bjharper Amlogic V4L2 codecs don't use request API, so this is useless. They expect to receive full frames, while VA-API and V4L2 request API codecs expect to get parsed frames (extracted information from frame header). This is not a driver thing - it's how HW is designed. Technically it would be possible to restore full frames from VA-API data, but it's complicated.

@wolfallein
Copy link

Looking for more information, I found this video on YouTube from Collabora, they explain the actual status of the decoder. At 31:11, Nicolas Dufresne (one of the developers behind Cedrus and Gstreamer Cedrus support) said they stopped developing this VA-API driver since FFmpeg, GStreamer and Chromium already have support.

Any further development on this VA-API driver needs to come from the community. I believe they assume that there is no need for the VA-API if the application can directly access the decoder with the recent kernel development. This means that it will take a while for everything to get patched (or maybe never will).

It is a pity because Firefox took so long to support VA-API, and now that it finally supports hardware video decoding on Linux, Cedrus doesn't support it anymore. I know Firefox uses FFmpeg for some tasks, but I don't know if it uses (or can use) for video decoding.

@jernejsk Thank you for your work on the FFmpeg patches :). I can also confirm that Gstreamer works with hardware acceleration. I needed to compile it (version 1.19.0.1), and I used the following to test:

gst-launch-1.0 filesrc location=video.MP4 ! qtdemux ! h264parse ! v4l2slh264dec ! autovideosink

It works even on top of Wayland, very nice. However, I had some problems with 60fps 1080p videos, everything lower than this works without problems (maybe I need to add more CMA). To test with software decoding, I used avdec_h264 instead of v4l2slh264dec. With hardware decoding, the CPU load is very small, amazing.

@wolfallein
Copy link

Hi,

I got the libva-v4l2-request to compile and run on Linux 5.12.
The library had some initialization issues because the way the driver works changed recently in the newer kernel. I tried to follow what is written in the stateless decoder initialization documentation: Memory-to-memory Stateless Video Decoder Interface.

It turns out we need to free the capture buffers. Apart from that, there are a couple of structs that changed, and some definition names as well, for instance: the control V4L2_CID_MPEG_VIDEO_H264_SPS changed to V4L2_CID_STATELESS_H264_SPS.

I also tried to follow what the people from GStreamer did to get it to work on the merge-request that added cedrus support.

when I run:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/video1 -hwaccel_output_format vaapi -i video.mp4 -f null -

Everything seems fine, I don't get any driver errors, and the decoding speed is around 10x with a small load on the CPU, in line with what I would expect for hardware decoding. With software decoding for the same video, I get around 2x with all the cores at 100%.

when I run cvlc or ffmpeg with output to fbdev, like in:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/video1 -i video.mp4 -pix_fmt bgra -f fbdev /dev/fb0

The video image is not correct. It seems that we still need to set the video output format, or there is still something missing in the initialization. Maybe it is now that the problem really starts :-) The noisy image is dynamic, and it seems that the hardware decoding is going on but in the wrong video format.

image

Since I'm not a developer by any means, and I know nothing about video decoding/encoding, v4l2 implementation... And I don't get any error to debug. I don't really know where to look to find the cause of this problem. It would be very good if someone can point me in a direction and indicate an example to follow. Any help is welcome. @jernejsk do you have any idea where I could look to fix it?

I think libva on Cedrus is very important because it would make the driver compatible with much more software already developed.

You can see the changes I made to get to this stage on my fork, on this commit. I adapted a few changes from pH5 on #29 and the Tile format fix from Kwizart on #32.

Thank you all,
Best regards

@jernejsk
Copy link
Contributor

Not really, no. Most probably some field in some control is not set correctly. Now comes the hard part - dumping register values (on kernel side) or dumping control values (on userspace side) and comparing them...

@wolfallein
Copy link

@jernejsk thank you. The problem also happens with MPEG2 videos. Most of the changes in the kernel were for h264...

So, maybe it is something before we send the slices. I noticed that on the GStreamer patch that they set a single control (V4L2_CID_STATELESS_H264_SPS) before sending a VIDIOC_STREAMON.

On the MPEG2 decoding, we set only two controls: V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS and V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION.

@openedev
Copy link

openedev commented Jul 29, 2021

@wolfallein Thanks for testing it on gstreamer.

I'm trying the same where I've built the gstreamer master since there seems to be some changes related to v4l2codes/h264 has been merged recently.

It is not playing while I've used the below pipeline, one you mentioned on the same thread.

# gst-launch-1.0 filesrc location=video.MP4 ! qtdemux ! h264parse ! v4l2slh264dec ! autovideosink
0:00:00.127261534   311   0x557440 DEBUG             v4l2codecs gstv4l2codecdevice.c:331:gst_v4l2_codec_find_devices: Analysing media device '/dev/media0'
0:00:00.127394571   311   0x557440 DEBUG             v4l2codecs gstv4l2codecdevice.c:347:gst_v4l2_codec_find_devices: Found CODEC entities
0:00:00.127462984   311   0x557440 DEBUG             v4l2codecs gstv4l2codecdevice.c:357:gst_v4l2_codec_find_devices: Analysing entity cedrus-proc
0:00:00.127501774   311   0x557440 DEBUG             v4l2codecs gstv4l2codecdevice.c:362:gst_v4l2_codec_find_devices: Found source and sink pads
0:00:00.127536731   311   0x557440 DEBUG             v4l2codecs gstv4l2codecdevice.c:370:gst_v4l2_codec_find_devices: Found source and sink V4L IO entities
0:00:00.127926840   311   0x557440 INFO              v4l2codecs gstv4l2codecdevice.c:388:gst_v4l2_codec_find_devices: Found decoder device cedrus-proc
0:00:00.128658268   311   0x557440 DEBUG     v4l2codecs-decoder gstv4l2decoder.c:306:gst_v4l2_decoder_enum_sink_fmt:<v4l2decoder0> Found format MG2S (MPEG-2 Parsed Slice Data)
0:00:00.128730682   311   0x557440 FIXME             v4l2codecs plugin.c:62:register_video_decoder:<v4l2decoder0> MG2S is not supported.
0:00:00.128797263   311   0x557440 DEBUG     v4l2codecs-decoder gstv4l2decoder.c:306:gst_v4l2_decoder_enum_sink_fmt:<v4l2decoder0> Found format S264 (H.264 Parsed Slice Data)
0:00:00.128842052   311   0x557440 INFO              v4l2codecs plugin.c:50:register_video_decoder:<v4l2decoder0> Registering cedrus-proc as H264 Decoder
0:00:00.129259827   311   0x557440 DEBUG     v4l2codecs-decoder gstv4l2decoder.c:306:gst_v4l2_decoder_enum_sink_fmt:<v4l2decoder0> Found format S265 (HEVC Parsed Slice Data)
0:00:00.129324532   311   0x557440 FIXME             v4l2codecs plugin.c:62:register_video_decoder:<v4l2decoder0> S265 is not supported.
0:00:00.129385280   311   0x557440 DEBUG     v4l2codecs-decoder gstv4l2decoder.c:306:gst_v4l2_decoder_enum_sink_fmt:<v4l2decoder0> Found format VP8F (VP8 Frame)
0:00:00.129428820   311   0x557440 INFO              v4l2codecs plugin.c:56:register_video_decoder:<v4l2decoder0> Registering cedrus-proc as VP8 Decoder
Setting pipeline to PAUSED ...
0:00:00.341702592   311   0x557440 INFO      v4l2codecs-h264dec gstv4l2codech264dec.c:221:gst_v4l2_codec_h264_dec_open:<v4l2slh264dec0> Opened H264 slice based decoder without start-codes
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstQTDemux:qtdemux0: Delayed linking failed.
Additional debug info:
gst/parse/grammar.y(540): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstQTDemux:qtdemux0:
failed delayed linking some pad of GstQTDemux named qtdemux0 to some pad of GstH264Parse named h264parse0
ERROR: from element /GstPipeline:pipeline0/GstQTDemux:qtdemux0: Internal data stream error.
Additional debug info:
../git/gst/isomp4/qtdemux.c(6650): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstQTDemux:qtdemux0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

However it is playing while I have passed the videoconvert in between decoder and autovideosink but it is playing slow even for 720p video.

# gst-launch-1.0 filesrc location=video.MP4 ! qtdemux ! h264parse ! v4l2slh264dec ! videoconvert ! autovideosink

These are my systems details:

Allwinner H3 SoC
Linux-5.13 Stable
Gstreamer (master branch)
# gst-inspect-1.0 --version
gst-inspect-1.0 version 1.19.1
GStreamer 1.19.1 (GIT)
Unknown package origin

Please let me know if I miss anything? May be sharing your root can cross-check if anything missing on my gst configuration?

Jagan.

@danboid
Copy link

danboid commented Feb 3, 2022

Hi @jernejsk

I want to try to get v4l2-request working with ffmpeg under Armbian buster on my T95 Max H6 TV box as the stepping stone to mpv.

Which version or commit of ffmpeg is your patch for? It doesn't seem to apply cleanly to ffmpeg 5.0 nor the latest git version and it seems you only updated it 10 days ago.

Thanks

@jernejsk
Copy link
Contributor

jernejsk commented Feb 4, 2022

I only update patches for LibreELEC/Kodi use. In order to use them, you need ffmpeg 4.4 and kernel >= 5.14 (no other combination currently supported nor planned). HEVC support won't work without additional kernel patches. mpv can currently use ffmpeg v4l2 request api acceleration only in gbm mode (no desktop running).

@danboid
Copy link

danboid commented Feb 4, 2022

Thanks @jernejsk

@danboid
Copy link

danboid commented Feb 8, 2022

I've tried a couple of times now to build your patched ffmpeg 4.4 under Armbian bullseye with a 5.15 kernel and headers on my H6 TV box. Your patch applied cleanly and the last ffmpeg configure command I tried was:

./configure --enable-v4l2-request --enable-libdrm --enable-libudev --prefix=/usr --enable-gpl --disable-stripping --disable-filter=resample --enable-gnutls --enable-libtheora --enable-libtwolame --enable-libvorbis --disable-libvpx --enable-libx265 --enable-libxml2 --enable-libxvid --enable-sdl2

I installed all of the ffmpeg build deps by running apt build-dep ffmpeg before running configure and make. The end of the build looks like:

libavcodec/v4l2_request_vp9.c:232:19: error: ‘V4L2_CID_STATELESS_VP9_FRAME’ undeclared (first use in this function); did you mean ‘V4L2_CID_STATELESS_VP8_FRAME’?
  232 |             .id = V4L2_CID_STATELESS_VP9_FRAME,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   V4L2_CID_STATELESS_VP8_FRAME
libavcodec/v4l2_request_vp9.c:232:19: warning: initialization of ‘unsigned int’ from ‘struct v4l2_ext_control *’ makes integer from pointer without a cast [-Wint-conversion]
libavcodec/v4l2_request_vp9.c:232:19: note: (near initialization for ‘control[0].id’)
libavcodec/v4l2_request_vp9.c:234:21: warning: initialization of ‘unsigned int’ from ‘struct v4l2_ext_control *’ makes integer from pointer without a cast [-Wint-conversion]
  234 |             .size = sizeof(controls->decode_params),
      |                     ^~~~~~
libavcodec/v4l2_request_vp9.c:234:21: note: (near initialization for ‘control[0].size’)
libavcodec/v4l2_request_vp9.c: In function ‘v4l2_request_vp9_init’:
libavcodec/v4l2_request_vp9.c:251:40: error: ‘V4L2_PIX_FMT_VP9_FRAME’ undeclared (first use in this function); did you mean ‘V4L2_PIX_FMT_VP8_FRAME’?
  251 |     return ff_v4l2_request_init(avctx, V4L2_PIX_FMT_VP9_FRAME, 3 * 1024 * 1024, NULL, 0);
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
      |                                        V4L2_PIX_FMT_VP8_FRAME
libavcodec/v4l2_request_vp9.c:251:40: warning: passing argument 2 of ‘ff_v4l2_request_init’ makes integer from pointer without a cast [-Wint-conversion]
In file included from libavcodec/v4l2_request_vp9.c:20:
libavcodec/v4l2_request.h:71:58: note: expected ‘uint32_t’ {aka ‘unsigned int’} but argument is of type ‘struct v4l2_ext_control *’
   71 | int ff_v4l2_request_init(AVCodecContext *avctx, uint32_t pixelformat, uint32_t buffersize, struct v4l2_ext_control *control, int count);
      |                                                 ~~~~~~~~~^~~~~~~~~~~
make: *** [ffbuild/common.mak:67: libavcodec/v4l2_request_vp9.o] Error 1

As you can see I've tried using --disable-libvpx hoping that might fix this error but sadly not.

What configure options do you use to build ffmpeg for LE?

@jernejsk
Copy link
Contributor

jernejsk commented Feb 9, 2022

--disable-libvpx --enable-libx265 are options for disabling libvpx and enabling libx265 libraries and have nothing to do with request api. Anyway, LE kernel has additional patches for VP9 support. You have several options - drop VP9 ffmpeg patches, patch kernel to support VP9 or simply find correct argument to disable VP9 request api. Hint: it can be found in VP9 ffmpeg patch.

@danboid
Copy link

danboid commented Feb 11, 2022

Thanks @jernejsk ! I left ffmpeg building last night and I'm happy to say it did build successfully but I've not had time to test it yet, I will do that tonight.

I don't need VP9 support and I couldn't be bothered to rebuild my kernel so, for those following along at home, the missing configure option I required for a successful build was --disable-hwaccel=vp9_v4l2request

Under mpv I use the option video-rotate=no to ignore video rotation metadata to always play videos 'full screen'. Can I expect this option to work with v4l2request? I noticed there is a sunxi rotate kernel module so I thought that was a promising sign.

@jernejsk
Copy link
Contributor

Note that this really works with GBM mode only (no desktop environment), so full screen is kinda assumed. H6 doesn't have rotation core. Even if it had, there is no ffmpeg filter which would take advantage of it. Some Cedrus variants support rotation for some codecs, but it's not implemented. In short, no HW accelerated rotation on Allwinner SoCs for now.

@danboid
Copy link

danboid commented Feb 11, 2022

Yes I know about the GBM only bit and I put 'full screen' in quotes because what I meant is not playing a landscape video in portrait mode which leads to big borders and so its not 'full screen'.

Shame to hear about the lack of hw accelerated rotation in the cedrus driver. Have you got any plans to work on adding hw accel rotation?

@jernejsk
Copy link
Contributor

No and even if it would be added, I'm not sure it would be easy to expose it in ffmpeg API. Even if that was done, I'm not sure mpv would automatically work with it. This is pretty unexplored territory, at least from my side, since I don't need it.

@danboid
Copy link

danboid commented Feb 12, 2022

After considerable effort, I think I should have all my ducks in a row now for v4l2-request playback yet instead I'm getting this error:

ffmpeg-v4l2-request-error

When trying to play a UHD h264 on my T95 MAX H6 TV box running file under Armbian bullseye w/ kernel 5.15 and your patched ffmpeg.

I have been trying this command, based on a command posted in an earlier comment:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/video0 -hwaccel_output_format vaapi -i video.mp4 -f null -

I only have a /dev/video0 and a /dev/media0, no /dev/video1 device here.

I found this page so I also tried exporting these:

export LIBVA_DRIVER_NAME=v4l2_request
export LIBVA_V4L2_REQUEST_VIDEO_PATH=/dev/video0
export LIBVA_V4L2_REQUEST_MEDIA_PATH=/dev/media0

What command should I be using to play a h264 file with ffmpeg or ffplay from the console using v4l2-request hwaccel?

@danboid
Copy link

danboid commented Feb 12, 2022

After building and installing your patched ffmpeg, I built and installed the latest git version of mpv and tried using the command used in the link in my previous post but I get this error:

mpv-error

@jernejsk
Copy link
Contributor

I guess you misunderstand something. LE ffmpeg patches have nothing to do with VA-API. They are meant to directly talk to Cedrus driver, without intermediate lib like libva-v4l2-request. This lib is not maintained, so it doesn't work with latest uAPI.

@danboid
Copy link

danboid commented Feb 13, 2022

I did try to build libva-v4l2-request but I didn't think it was necessary or used by your patched ffmpeg. It failed to build.

It would seem from the comments in this and the other ticket that people have got both ffmpeg and mpv working outside of LE with their Allwinner devices so I suppose I need to know:

  • What EVs need to be exported before running ffmpeg or mpv using v4l2-request?

  • It looks like I have the cedrus kernel module loaded but a checklist of modules would be handy

  • What ffmpeg or mpv command should work for v4l2-request playback of a h264 file in the GBM console?

Thanks v.much for your help Jernej! I will document (and package) this on the Armbian forums if I get it working so you can send someone to my link in the future, hopefully.

If I get mpv working I'm going to write a simple dialog based interface for it.

@jernejsk
Copy link
Contributor

I work only with built-in drivers due to my dev setup, so I can't really tell you which modules should be loaded. Anyway, if you have cedrus among them, it should be good.

No EVs are necessary for ffmpeg nor mpv, just make sure ffmpeg libs are installed system wide and mpv was compiled for same ffmpeg version (mpv will complain otherwise).

you can test with ffmpeg commands:
ffmpeg -loglevel debug -hwaccel drm -i video.mp4 -pix_fmt bgra -f fbdev /dev/fb0 (assuming you enabed fbdev in ffmpeg and in kernel, but this will do CPU colour space conversion and CPU rendering, which is slow)
ffmpeg -hwaccel drm -hwaccel_output_format drm_prime -i video.mp4 -f null - (no output, decoding speed test)

I forgot mpv command, but if you enable debug output, it should be pretty obvious, if request api is used. I guess you can set hwdec to auto and see if that works.

Note, gstreamer 1.20 was just released, which supports request api decoding of MPEG2, VP8 and H264 out of the box (maybe even VP9), without patching anything. However, I have very little experience there, so I can't help you with that.

@danboid
Copy link

danboid commented Feb 13, 2022

I was miles off with my ffmpeg command so I'm glad I asked someone who knows whats going on here!

fbdev output is enabled by default in ffmpeg and it would seem my kernel has fbdev support enabled because I have a /dev/fb0 but your ffmpeg command hasn't worked with my test files. Maybe I'd need to transcode them to use bgra instead because I noticed the swscaler warning about no accelerated colorspace conversion. Is that likely to make videos unwatchable ie less than 24 fps when they should be ~30 fps, if I could get one to play?

If I have to transcode videos, what are the optimal h264 or h265 encoding options for playback on cedrus?

These videos play fine with ffmpeg and mpv on the Jetson Nano and under amd64 Intel/Nvidia Linux etc.

dan@aw-h6-tv:~/src/ffmpeg-4.4$ uname -a
Linux aw-h6-tv 5.15.23-station #trunk SMP PREEMPT Sat Feb 12 20:15:36 CET 2022 aarch64 GNU/Linux
dan@aw-h6-tv:~/src/ffmpeg-4.4$ lsmod
Module                  Size  Used by
cpufreq_userspace      16384  0
cpufreq_powersave      16384  0
cpufreq_conservative    16384  0
snd_soc_hdmi_codec     20480  1
ir_nec_decoder         16384  0
crct10dif_ce           20480  1
xradio_wlan           139264  1
snd_soc_simple_card    20480  0
rc_tanix_tx5max        16384  0
snd_soc_simple_card_utils    24576  1 snd_soc_simple_card
sunxi_cir              16384  0
rc_core                49152  4 rc_tanix_tx5max,sunxi_cir,ir_nec_decoder
mac80211              569344  1 xradio_wlan
dw_hdmi_i2s_audio      16384  0
dw_hdmi_cec            16384  0
cfg80211              389120  2 xradio_wlan,mac80211
rfkill                 36864  3 cfg80211
libarc4                16384  1 mac80211
sunxi_cedrus           53248  0
v4l2_mem2mem           40960  1 sunxi_cedrus
videobuf2_dma_contig    24576  1 sunxi_cedrus
videobuf2_memops       20480  1 videobuf2_dma_contig
videobuf2_v4l2         32768  2 sunxi_cedrus,v4l2_mem2mem
videobuf2_common       61440  5 sunxi_cedrus,videobuf2_dma_contig,videobuf2_v4l2,v4l2_mem2mem,videobuf2_memops
videodev              237568  4 sunxi_cedrus,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem
mc                     53248  5 sunxi_cedrus,videodev,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem
panfrost               69632  0
gpu_sched              36864  1 panfrost
display_connector      16384  0
zram                   40960  3
fuse                  131072  1
ip_tables              32768  0
x_tables               45056  1 ip_tables
ipv6                  593920  44
sunxi                  24576  0
musb_hdrc              94208  1 sunxi
dwmac_sun8i            24576  0
dan@aw-h6-tv:~/src/ffmpeg-4.4$ 

@jernejsk
Copy link
Contributor

You can't avoid swscaler, as I already told you. Cedrus decodes to NV12 format, which is form of YUV 4:2:0, fbdev needs bgra, which is form of 8-bit RGB with alpha channel. Only DRM plane rendering can directly show that and even then HW will internally convert it to RGB (at least with current drivers).

I suggest you use h264 video for testing purposes. uAPI is stable for some time now and it should be able to decode any H264 video out there. HEVC needs patching on kernel side to properly work. I'm not aware of any H264 video that can't be properly decoded, assuming it conforms to specs (many DVB sources don't always conform). While in theory you could put together HEVC video which couldn't be decoded on Cedrus, you would actually need to know how to do that. Practically, all HEVC videos work.

Also make sure CMA size is set to at least 256 MB, 384 MB if you want 10-bit 4K HEVC. Also disable H6 IOMMU driver, because currently doesn't work well with Cedrus. If that doesn't help, I don't know.

@danboid
Copy link

danboid commented Feb 13, 2022

I'm more interested in mpv than gstreamer because I've not found any gstreamer based video player that offers the amount of playback options that mpv has

BUT

Will this latest gstreamer release allow for 4K h26X playback using v4l2-request under X or Wayland or both? That would be very cool if that works, even if only in full screen mode.

Will update you on the CMA testing etc later.

@jernejsk
Copy link
Contributor

As I said, I have not much experience with gstreamer, I only tested VP9 without any desktop environment. But HEVC won't work since gstreamer is using only current uAPI, which doesn't cover everything. If you applied HEVC kernel patches, gstreamer won't work at all for HEVC.

@jernejsk
Copy link
Contributor

Note, I don't care about desktop environments on ARM, so I don't have much experience with video decoding there. But I know that mpv would need to be extended to work with request API on desktop environment. mpv renders such buffers only with DRM planes, but there is no reason why they couldn't be rendered via GPU. Somebody just needs to add code which imports dmabuf buffers to OpenGL ES.

@danboid
Copy link

danboid commented Feb 13, 2022

I have tried again but with a cma=256M kernel boot argument and I'm still getting the same errors.

IOMMU is enabled in the kernel I'm using so I will try to rebuild the kernel without IOMMU.

This is how my current ffmpeg build is configured:

/configure --enable-v4l2-request --enable-libdrm --enable-libudev --prefix=/usr --enable-gpl --disable-filter=resample --enable-gnutls --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libx265 --enable-libxml2 --enable-libxvid --disable-hwaccel=vp9_v4l2request

@danboid
Copy link

danboid commented Feb 15, 2022

I installed a different kernel and ffmpeg isn't giving any errors now but I've not worked out the correct command to get a picture out of it yet.

Under mpv, which I've only got to work with software decoding so far (I presume mpv must need libva-v4l2-request for HW decoding) I have to use the option --drm-connector=1.HDMI-A-1 to get a picture out of it.

Whilst I'm talking about HDMI pictures, if I disconnect the HDMI from my H6 TV box (running Linux 5.15) the picture doesn't return under X when I re-connect the HDMI cable. The non-X console doesn't have this issue but it picks one of two resolutions to use seemingly at random so sometimes I have to unplug and re-plug it in a few times to get the 4K res back. This has been the case for all of the kernels and distros I've used on it over the last year or so.

Is this a known bug with AW H6?

@jernejsk
Copy link
Contributor

jernejsk commented Feb 15, 2022

I presume mpv must need libva-v4l2-request for HW decoding

No, mpv works fine for me with modified ffmpeg libraries installed system wide. I tested this about 2 months ago, but I already forgot exact command used for that. You can try command from Kwiboo/mpv@9c39a05 commit message (changes are already present in latest mpv).

I have to use the option --drm-connector=1.HDMI-A-1 to get a picture out of it.

That's not unusual and it depends on driver loading order for GPU and display. One way to guarantee often assumed order (card0 display and card1 GPU) is to build panfrost as a module and sun4i-drm as built in.

Regarding 4K resolution, make sure you have this patch: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Allwinner/patches/linux/0065-wip-fix-H6-4k-60.patch Other than that, I don't know.

EasyIP2023 added a commit to EasyIP2023/meta-raspberrypi that referenced this issue Jan 11, 2023
When building with latest OE-Core master. Running into
bellow issue. After further research issue appears to
be similar to

bootlin/libva-v4l2-request#35

| src/libavcodec/hevc-ctrls-v2.h:59:8: error: redefinition of 'struct
v4l2_ctrl_hevc_sps'
|    59 | struct v4l2_ctrl_hevc_sps {
|       |        ^~~~~~~~~~~~~~~~~~
| In file included from
/../../../recipe-sysroot/usr/include/linux/videodev2.h:65,
|                  from src/libavcodec/hevc-ctrls-v2.h:14:

Disable ffmpeg libva-v4l2-request so that master builds
and until better investigation can be done to fix
issue.

Signed-off-by: Vincent Davis Jr <[email protected]>
agherzan pushed a commit to agherzan/meta-raspberrypi that referenced this issue Jan 12, 2023
When building with latest OE-Core master. Running into
bellow issue. After further research issue appears to
be similar to

bootlin/libva-v4l2-request#35

| src/libavcodec/hevc-ctrls-v2.h:59:8: error: redefinition of 'struct
v4l2_ctrl_hevc_sps'
|    59 | struct v4l2_ctrl_hevc_sps {
|       |        ^~~~~~~~~~~~~~~~~~
| In file included from
/../../../recipe-sysroot/usr/include/linux/videodev2.h:65,
|                  from src/libavcodec/hevc-ctrls-v2.h:14:

Disable ffmpeg libva-v4l2-request so that master builds
and until better investigation can be done to fix
issue.

Signed-off-by: Vincent Davis Jr <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
When building with latest OE-Core master. Running into
bellow issue. After further research issue appears to
be similar to

bootlin/libva-v4l2-request#35

| src/libavcodec/hevc-ctrls-v2.h:59:8: error: redefinition of 'struct
v4l2_ctrl_hevc_sps'
|    59 | struct v4l2_ctrl_hevc_sps {
|       |        ^~~~~~~~~~~~~~~~~~
| In file included from
/../../../recipe-sysroot/usr/include/linux/videodev2.h:65,
|                  from src/libavcodec/hevc-ctrls-v2.h:14:

Disable ffmpeg libva-v4l2-request so that master builds
and until better investigation can be done to fix
issue.

Signed-off-by: Vincent Davis Jr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants