summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/libyami/libyami/0010-h26xparser-Fix-build-error-with-GCC9.patch
blob: be69ab71811ab9a684860ebed9f5e15fda1ecfc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From fdb8185749098eaf55050c4ec5c0f21c5be1e326 Mon Sep 17 00:00:00 2001
From: Naveen Saini <naveen.kumar.saini@intel.com>
Date: Tue, 4 Jun 2019 16:53:16 +0800
Subject: [PATCH] h26xparser: Fix build error with GCC9

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 {
|       |            ^~~~~~~~~~~
| ../../git/codecparsers/mpeg2_parser.cpp: In constructor 'YamiParser::MPEG2::SeqHeader::SeqHeader()':
| ../../git/codecparsers/mpeg2_parser.cpp:163:59: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct YamiParser::MPEG2::SeqHeader'; use assignment or value-initialization instead [-Werror=class-memaccess]
|   163 |     SeqHeader::SeqHeader() { memset(this, 0, sizeof(*this)); }
|       |                                                           ^
| In file included from ../../git/codecparsers/mpeg2_parser.cpp:34:
| ../../git/codecparsers/mpeg2_parser.h:153:12: note: 'struct YamiParser::MPEG2::SeqHeader' declared here
|   153 |     struct SeqHeader {
|       |            ^~~~~~~~~
| 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.

Status: Submitted [https://github.com/intel/libyami/pull/876]

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
 codecparsers/h264Parser.cpp   | 4 ++--
 codecparsers/h265Parser.cpp   | 8 ++++----
 codecparsers/mpeg2_parser.cpp | 3 ++-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/codecparsers/h264Parser.cpp b/codecparsers/h264Parser.cpp
index 22117a1..6f7959e 100644
--- a/codecparsers/h264Parser.cpp
+++ b/codecparsers/h264Parser.cpp
@@ -137,7 +137,7 @@ static bool scalingList(NalReader& br, uint8_t* sl, uint32_t size, uint32_t inde
 
 PPS::PPS()
 {
-    memset(this, 0, offsetof(PPS, m_sps));
+    memset((void*)this, 0, offsetof(PPS, m_sps));
 }
 
 PPS::~PPS()
@@ -683,7 +683,7 @@ Parser::searchSps(uint8_t id) const
 
 SliceHeader::SliceHeader()
 {
-    memset(this, 0, offsetof(SliceHeader, m_pps));
+    memset((void*)this, 0, offsetof(SliceHeader, m_pps));
 }
 
 bool SliceHeader::refPicListModification(NalReader& br, RefPicListModification* pm0,
diff --git a/codecparsers/h265Parser.cpp b/codecparsers/h265Parser.cpp
index 0dea3a6..d7e6740 100644
--- a/codecparsers/h265Parser.cpp
+++ b/codecparsers/h265Parser.cpp
@@ -162,7 +162,7 @@ static const uint8_t DefaultScalingList2[64] = {
 
 VPS::VPS()
 {
-    memset(this, 0, offsetof(VPS, hrd_layer_set_idx));
+    memset((void*)this, 0, offsetof(VPS, hrd_layer_set_idx));
 }
 
 VPS::~VPS()
@@ -171,17 +171,17 @@ VPS::~VPS()
 
 SPS::SPS()
 {
-    memset(this, 0, offsetof(SPS, vps));
+    memset((void*)this, 0, offsetof(SPS, vps));
 }
 
 PPS::PPS()
 {
-    memset(this, 0, offsetof(PPS, sps));
+    memset((void*)this, 0, offsetof(PPS, sps));
 }
 
 SliceHeader::SliceHeader()
 {
-    memset(this, 0, offsetof(SliceHeader, pps));
+    memset((void*)this, 0, offsetof(SliceHeader, pps));
 }
 
 SliceHeader::~SliceHeader()
diff --git a/codecparsers/mpeg2_parser.cpp b/codecparsers/mpeg2_parser.cpp
index 21032b1..173da39 100644
--- a/codecparsers/mpeg2_parser.cpp
+++ b/codecparsers/mpeg2_parser.cpp
@@ -33,6 +33,7 @@
 #include "common/log.h"
 #include "mpeg2_parser.h"
 #include <inttypes.h>
+#include <cstddef>
 
 namespace YamiParser {
 namespace MPEG2 {
@@ -160,7 +161,7 @@ namespace MPEG2 {
 
     SeqExtension::SeqExtension() { memset(this, 0, sizeof(*this)); }
 
-    SeqHeader::SeqHeader() { memset(this, 0, sizeof(*this)); }
+    SeqHeader::SeqHeader() { memset((void*)this, 0, offsetof(SeqHeader, quantizationMatrices)); }
 
     StreamHeader::StreamHeader() { memset(this, 0, sizeof(*this)); }
 
-- 
2.17.0