Add '-Wall' or '-fstack-protector' compilation flags
In addition, this fixes all warnings reported by -Wall
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
diff --git a/common/loadsurface.h b/common/loadsurface.h
index 82cf61c..c5cb9d4 100755
--- a/common/loadsurface.h
+++ b/common/loadsurface.h
@@ -306,6 +306,8 @@
return 0;
}
+#ifdef LIBVA_UTILS_UPLOAD_DOWNLOAD_YUV_SURFACE
+
/*
* Upload YUV data from memory into a surface
* if src_fourcc == NV12, assume the buffer pointed by src_U
@@ -487,3 +489,5 @@
return 0;
}
+
+#endif /* LIBVA_UTILS_UPLOAD_DOWNLOAD_YUV_SURFACE */
diff --git a/decode/Makefile.am b/decode/Makefile.am
index b80ff19..febc50d 100644
--- a/decode/Makefile.am
+++ b/decode/Makefile.am
@@ -23,6 +23,8 @@
bin_PROGRAMS = mpeg2vldemo loadjpeg
AM_CPPFLAGS = \
+ -Wall \
+ -fstack-protector \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
$(NULL)
diff --git a/decode/tinyjpeg.c b/decode/tinyjpeg.c
index 571716c..fa69c5c 100644
--- a/decode/tinyjpeg.c
+++ b/decode/tinyjpeg.c
@@ -176,8 +176,8 @@
static void print_SOF(const unsigned char *stream)
{
- int width, height, nr_components, precision;
#if DEBUG
+ int width, height, nr_components, precision;
const char *nr_components_to_string[] = {
"????",
"Grayscale",
@@ -185,12 +185,12 @@
"YCbCr",
"CYMK"
};
-#endif
precision = stream[2];
height = be16_to_cpu(stream+3);
width = be16_to_cpu(stream+5);
nr_components = stream[7];
+#endif
trace("> SOF marker\n");
trace("Size:%dx%d nr_components:%d (%s) precision:%d\n",
@@ -578,8 +578,6 @@
unsigned int i, j;
int surface_type;
- char *type;
- int ChromaTypeIndex;
VASurfaceAttrib forcc;
forcc.type =VASurfaceAttribPixelFormat;
@@ -644,62 +642,46 @@
//surface_type = VA_RT_FORMAT_IMC3;
surface_type = VA_RT_FORMAT_YUV420;
forcc.value.value.i = VA_FOURCC_IMC3;
- ChromaTypeIndex = 1;
- type = "VA_FOURCC_IMC3";
}
else if (h1 == 2 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
//surface_type = VA_RT_FORMAT_YUV422H;
surface_type = VA_RT_FORMAT_YUV422;
forcc.value.value.i = VA_FOURCC_422H;
- ChromaTypeIndex = 2;
- type = "VA_FOURCC_422H";
}
else if (h1 == 1 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
surface_type = VA_RT_FORMAT_YUV444;
forcc.value.value.i = VA_FOURCC_444P;
//forcc.value.value.i = VA_FOURCC_RGBP;
- ChromaTypeIndex = 3;
- type = "VA_FOURCC_444P";
}
else if (h1 == 4 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
surface_type = VA_RT_FORMAT_YUV411;
forcc.value.value.i = VA_FOURCC_411P;
- ChromaTypeIndex = 4;
- type = "VA_FOURCC_411P";
}
else if (h1 == 1 && h2 == 1 && h3 == 1 &&
v1 == 2 && v2 == 1 && v3 == 1) {
//surface_type = VA_RT_FORMAT_YUV422V;
surface_type = VA_RT_FORMAT_YUV422;
forcc.value.value.i = VA_FOURCC_422V;
- ChromaTypeIndex = 5;
- type = "VA_FOURCC_422V";
}
else if (h1 == 2 && h2 == 1 && h3 == 1 &&
v1 == 2 && v2 == 2 && v3 == 2) {
//surface_type = VA_RT_FORMAT_YUV422H;
surface_type = VA_RT_FORMAT_YUV422;
forcc.value.value.i = VA_FOURCC_422H;
- ChromaTypeIndex = 6;
- type = "VA_FOURCC_422H";
}
else if (h2 == 2 && h2 == 2 && h3 == 2 &&
v1 == 2 && v2 == 1 && v3 == 1) {
//surface_type = VA_RT_FORMAT_YUV422V;
surface_type = VA_RT_FORMAT_YUV422;
forcc.value.value.i = VA_FOURCC_422V;
- ChromaTypeIndex = 7;
- type = "VA_FOURCC_422V";
}
else
{
surface_type = VA_RT_FORMAT_YUV400;
forcc.value.value.i = VA_FOURCC('Y','8','0','0');
- ChromaTypeIndex = 0;
- type = "Format_400P";
}
va_status = vaCreateSurfaces(va_dpy,surface_type,
diff --git a/encode/Makefile.am b/encode/Makefile.am
index 7327a35..149f1ad 100644
--- a/encode/Makefile.am
+++ b/encode/Makefile.am
@@ -25,6 +25,7 @@
AM_CPPFLAGS = \
-Wall \
+ -fstack-protector \
$(LIBVA_CFLAGS) \
$(NULL)
diff --git a/encode/h264encode.c b/encode/h264encode.c
index 328013b..4bb1f12 100644
--- a/encode/h264encode.c
+++ b/encode/h264encode.c
@@ -21,6 +21,8 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#define LIBVA_UTILS_UPLOAD_DOWNLOAD_YUV_SURFACE 1
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -564,6 +566,8 @@
return bs.bit_offset;
}
+#if 0
+
static int
build_packed_sei_buffer_timing(unsigned int init_cpb_removal_length,
unsigned int init_cpb_removal_delay,
@@ -630,6 +634,8 @@
return nal_bs.bit_offset;
}
+#endif
+
static int build_packed_slice_buffer(unsigned char **header_buffer)
{
bitstream bs;
@@ -1666,6 +1672,8 @@
return 0;
}
+#if 0
+
static void render_packedsei(void)
{
VAEncPackedHeaderParameterBuffer packed_header_param_buffer;
@@ -1728,7 +1736,6 @@
return;
}
-
static int render_hrd(void)
{
VABufferID misc_parameter_hrd_buf_id;
@@ -1765,6 +1772,8 @@
return 0;
}
+#endif
+
static void render_packedslice()
{
VAEncPackedHeaderParameterBuffer packedheader_param_buffer;
diff --git a/putsurface/Makefile.am b/putsurface/Makefile.am
index b764a70..e7b62a1 100644
--- a/putsurface/Makefile.am
+++ b/putsurface/Makefile.am
@@ -25,6 +25,8 @@
TEST_CFLAGS = \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
+ -Wall \
+ -fstack-protector \
$(NULL)
TEST_LIBS = \
diff --git a/vainfo/Makefile.am b/vainfo/Makefile.am
index 46c09ed..aff201f 100644
--- a/vainfo/Makefile.am
+++ b/vainfo/Makefile.am
@@ -26,6 +26,8 @@
-I$(top_srcdir)/common \
$(LIBVA_CFLAGS) \
-DLIBVA_VERSION_S="\"$(LIBVA_VERSION)\"" \
+ -Wall \
+ -fstack-protector \
$(NULL)
vainfo_libs = \
diff --git a/videoprocess/Makefile.am b/videoprocess/Makefile.am
index 18a2ec6..eb79bc3 100644
--- a/videoprocess/Makefile.am
+++ b/videoprocess/Makefile.am
@@ -23,6 +23,8 @@
bin_PROGRAMS = vavpp
AM_CPPFLAGS = \
+ -Wall \
+ -fstack-protector \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
$(NULL)
diff --git a/videoprocess/vavpp.cpp b/videoprocess/vavpp.cpp
index e61e7cd..a525e1c 100644
--- a/videoprocess/vavpp.cpp
+++ b/videoprocess/vavpp.cpp
@@ -215,7 +215,7 @@
VAStatus va_status;
VAImage surface_image;
void *surface_p = NULL;
- unsigned char *y_dst, *u_dst, *v_dst;
+ unsigned char *y_dst, *u_dst;
uint32_t row, col;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -226,7 +226,6 @@
y_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[0]);
u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
- v_dst = u_dst;
/* fill Y plane, the luma values of some pixels is in the range of min_luma~max_luma,
* and others are out side of it, in luma key blending case, the pixels with Y value
@@ -265,7 +264,7 @@
unsigned char *y_src, *u_src, *v_src;
unsigned char *y_dst, *u_dst, *v_dst;
void *surface_p = NULL;
- uint32_t frame_size, i, row, col;
+ uint32_t frame_size, row, col;
size_t n_items;
unsigned char * newImageBuffer = NULL;
@@ -406,25 +405,8 @@
} while (n_items != 1);
y_src = newImageBuffer;
-
- if (g_src_file_fourcc == VA_FOURCC_I010) {
- u_src = newImageBuffer + surface_image.width * surface_image.height * 2;
- v_src = newImageBuffer + surface_image.width * surface_image.height * 5 / 2;
- } else if (g_src_file_fourcc == VA_FOURCC_P010) {
- u_src = newImageBuffer + surface_image.width * surface_image.height * 2;
- v_src = u_src;
- }
-
y_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[0]);
- if (surface_image.format.fourcc == VA_FOURCC_I010) {
- u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
- v_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
- } else if (surface_image.format.fourcc == VA_FOURCC_P010) {
- u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
- v_dst = u_dst;
- }
-
/* plane 0, directly copy */
for (row = 0; row < surface_image.height; row++) {
memcpy(y_dst, y_src, surface_image.width * 2);
@@ -436,6 +418,12 @@
if (surface_image.format.fourcc == VA_FOURCC_I010) {
assert(g_src_file_fourcc == VA_FOURCC_I010);
+ u_src = newImageBuffer + surface_image.width * surface_image.height * 2;
+ v_src = newImageBuffer + surface_image.width * surface_image.height * 5 / 2;
+
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
+
for (row = 0; row < surface_image.height / 2; row++) {
memcpy(u_dst, u_src, surface_image.width);
memcpy(v_dst, v_src, surface_image.width);
@@ -449,6 +437,12 @@
} else if (surface_image.format.fourcc == VA_FOURCC_P010){
assert(g_src_file_fourcc == VA_FOURCC_P010);
+ u_src = newImageBuffer + surface_image.width * surface_image.height * 2;
+ v_src = u_src;
+
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_dst = u_dst;
+
for (row = 0; row < surface_image.height / 2; row++) {
memcpy(u_dst, u_src, surface_image.width * 2);
@@ -506,13 +500,12 @@
VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src, *u_src, *v_src;
unsigned char *y_dst, *u_dst, *v_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t row, col;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -613,13 +606,12 @@
VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src, *u_src, *v_src;
unsigned char *y_dst, *u_dst, *v_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t row, col;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -720,13 +712,12 @@
VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src, *u_src, *v_src;
unsigned char *y_dst, *u_dst, *v_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t row, col;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -741,7 +732,6 @@
surface_image.format.fourcc == VA_FOURCC_NV12){
uint32_t y_size = surface_image.width * surface_image.height;
- uint32_t u_size = y_size/4;
newImageBuffer = (unsigned char*)malloc(y_size * 3 / 2);
assert(newImageBuffer);
@@ -823,13 +813,12 @@
VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src;
unsigned char *y_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t row;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -884,13 +873,12 @@
store_yuv_surface_to_10bit_file(FILE *fp, VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src, *u_src, *v_src;
unsigned char *y_dst, *u_dst, *v_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t row;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -971,13 +959,12 @@
store_rgb_surface_to_rgb_file(FILE *fp, VASurfaceID surface_id)
{
VAStatus va_status;
- VAImageFormat image_format;
VAImage surface_image;
void *surface_p = NULL;
unsigned char *y_src;
unsigned char *y_dst;
- uint32_t frame_size, row, col;
- int32_t ret, n_items;
+ uint32_t frame_size, row;
+ int32_t n_items;
unsigned char * newImageBuffer = NULL;
va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
@@ -1453,6 +1440,7 @@
{
VAStatus va_status = VA_STATUS_SUCCESS;
uint32_t i;
+ int32_t j;
/* VA driver initialization */
va_dpy = va_open_display();
@@ -1470,12 +1458,12 @@
&num_entrypoints);
CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
- for (i = 0; i < num_entrypoints; i++) {
- if (entrypoints[i] == VAEntrypointVideoProc)
+ for (j = 0; j < num_entrypoints; j++) {
+ if (entrypoints[j] == VAEntrypointVideoProc)
break;
}
- if (i == num_entrypoints) {
+ if (j == num_entrypoints) {
printf("VPP is not supported by driver\n");
assert(0);
}
@@ -1537,7 +1525,7 @@
for (i = 0; i < num_surf_attribs; i++) {
if (surf_attribs[i].type == VASurfaceAttribPixelFormat &&
- surf_attribs[i].value.value.i == g_in_fourcc)
+ surf_attribs[i].value.value.i == (int)g_in_fourcc)
break;
}
free(surf_attribs);