intel / libyami

Yet Another Media Infrastructure. it is core part of media codec with hardware acceleration, it is yummy to your video experience on Linux like platform.
Apache License 2.0
146 stars 106 forks source link

h26xparser: Fix build error with GCC9 #876

Closed saininav closed 4 years ago

saininav commented 5 years ago

GCC9 causing build failure:

| ../../git/codecparsers/h264Parser.cpp: In constructor 'YamiParser::H264::PPS::PPS()': | ../../git/codecparsers/h264Parser.cpp:140:41: error: 'void memset(void, int, size_t)' clearing an object of type 'struct YamiParser::H264::PPS' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 140 | memset(this, 0, offsetof(PPS, m_sps)); | | ^ | In file included from ../../git/codecparsers/h264Parser.cpp:21: | ../../git/codecparsers/h264Parser.h:292:8: note: 'struct YamiParser::H264::PPS' declared here | 292 | struct PPS { | | ^~~ | ../../git/codecparsers/h264Parser.cpp: In constructor 'YamiParser::H264::SliceHeader::SliceHeader()': | ../../git/codecparsers/h264Parser.cpp:686:49: error: 'void memset(void, int, size_t)' clearing an object of type 'class YamiParser::H264::SliceHeader' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 686 | memset(this, 0, offsetof(SliceHeader, m_pps)); | | ^ | In file included from ../../git/codecparsers/h264Parser.cpp:21: | ../../git/codecparsers/h264Parser.h:371:7: note: 'class YamiParser::H264::SliceHeader' declared here | 371 | class SliceHeader { | | ^~~ | ../../git/codecparsers/h265Parser.cpp: In constructor 'YamiParser::H265::VPS::VPS()': | ../../git/codecparsers/h265Parser.cpp:165:53: error: 'void memset(void, int, size_t)' clearing an object of type 'struct YamiParser::H265::VPS' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 165 | memset(this, 0, offsetof(VPS, hrd_layer_set_idx)); | | ^ | In file included from ../../git/codecparsers/h265Parser.cpp:21: | ../../git/codecparsers/h265Parser.h:256:12: note: 'struct YamiParser::H265::VPS' declared here | 256 | struct VPS { | | ^~~ | ../../git/codecparsers/h265Parser.cpp: In constructor 'YamiParser::H265::SPS::SPS()': | ../../git/codecparsers/h265Parser.cpp:174:39: error: 'void memset(void, int, size_t)' clearing an object of type 'struct YamiParser::H265::SPS' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 174 | memset(this, 0, offsetof(SPS, vps)); | | ^ | In file included from ../../git/codecparsers/h265Parser.cpp:21: | ../../git/codecparsers/h265Parser.h:290:12: note: 'struct YamiParser::H265::SPS' declared here | 290 | struct SPS { | | ^~~ | ../../git/codecparsers/h265Parser.cpp: In constructor 'YamiParser::H265::PPS::PPS()': | ../../git/codecparsers/h265Parser.cpp:179:39: error: 'void memset(void, int, size_t)' clearing an object of type 'struct YamiParser::H265::PPS' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 179 | memset(this, 0, offsetof(PPS, sps)); | | ^ | In file included from ../../git/codecparsers/h265Parser.cpp:21: | ../../git/codecparsers/h265Parser.h:362:12: note: 'struct YamiParser::H265::PPS' declared here | 362 | struct PPS { | | ^~~ | ../../git/codecparsers/h265Parser.cpp: In constructor 'YamiParser::H265::SliceHeader::SliceHeader()': | ../../git/codecparsers/h265Parser.cpp:184:47: error: 'void memset(void, int, size_t)' clearing an object of type 'struct YamiParser::H265::SliceHeader' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] | 184 | memset(this, 0, offsetof(SliceHeader, pps)); | | ^ | In file included from ../../git/codecparsers/h265Parser.cpp:21: | ../../git/codecparsers/h265Parser.h:499:12: note: 'struct YamiParser::H265::SliceHeader' declared here | 499 | struct SliceHeader { | | ^~~ | cc1plus: all warnings being treated as errors

By typecasting structure pointer to void pointer, GCC9 does normal memset operation where offsetof() give correct number of bytes to set.

Signed-off-by: Naveen Saini naveen.kumar.saini@intel.com

xuguangxin commented 5 years ago

@saininav thanks for your patch. It's very helpful. I think it will fix https://github.com/intel/libyami/issues/875 too. Could you help with it too? Full configuration can be enabled by

autogen.sh --enable-h264enc --enable-jpegenc --enable-vp8enc --enable-vp9enc --enable-h265enc --enable-mpeg2dec --enable-vp8dec --enable-vp9dec --enable-jpegdec --enable-h264dec --enable-h265dec --enable-vc1dec --enable-v4l2 --enable-tests

thanks for help.

xuguangxin commented 5 years ago

@saininav , thanks for the update. looks pretty. Just one questions listed above

thanks

xuguangxin commented 5 years ago

@saininav , seems CI build failed, you may need #include <cstddef>

https://travis-ci.org/intel/libyami/builds/544025956#L1433

thanks

xuguangxin commented 5 years ago

@wangzj0601 , could you help run regression test for this too. thanks

xuguangxin commented 5 years ago

@wangzj0601 , any feedback on this? thanks

xuguangxin commented 4 years ago

thanks @saininav for this.