summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2018-01-05 16:32:16 +0300
committerDmitry Osipenko <digetx@gmail.com>2018-01-07 19:19:38 +0300
commit8fc683ce2524cac899869ec9b1e306fb0315c58c (patch)
tree219e54ed7e8fd1f530265c3c3161e1a7b33e9e64
parent422149e7b0efa766a6ca8bb665b4293d14fe8bd4 (diff)
Replace some of asserts with error message
-rw-r--r--src/decoder.c64
-rw-r--r--src/surface.c11
-rw-r--r--src/surface_bitmap.c5
-rw-r--r--src/surface_output.c39
-rw-r--r--src/surface_video.c24
5 files changed, 95 insertions, 48 deletions
diff --git a/src/decoder.c b/src/decoder.c
index 71464c4..78f90a2 100644
--- a/src/decoder.c
+++ b/src/decoder.c
@@ -139,9 +139,6 @@ static VdpStatus copy_bitstream_to_dmabuf(tegra_decoder *dec,
memset(bitstream, 0x0, end - bitstream);
ret = sync_dmabuf_write_end(*data_fd);
-
- assert(ret == 0);
-
if (ret) {
free_data(*bo, *data_fd);
return VDP_STATUS_ERROR;
@@ -150,23 +147,30 @@ static VdpStatus copy_bitstream_to_dmabuf(tegra_decoder *dec,
bitstream = start;
bitstream_init(reader, bitstream, total_size);
- assert(bitstream[0] == 0x00);
- assert(bitstream[1] == 0x00);
+ if (bitstream[0] != 0x00) {
+ ErrorMsg("Invalid NAL byte[0] %02X\n", bitstream[0]);
+ }
+
+ if(bitstream[1] != 0x00) {
+ ErrorMsg("Invalid NAL byte[1] %02X\n", bitstream[0]);
+ }
if (bitstream[2] == 0x01) {
bitstream_reader_inc_offset(reader, 4);
return VDP_STATUS_OK;
}
- assert(bitstream[2] == 0x00);
+ if (bitstream[2] != 0x00) {
+ ErrorMsg("Invalid NAL byte[2] %02X\n", bitstream[2]);
+ }
if (bitstream[3] == 0x01) {
bitstream_reader_inc_offset(reader, 5);
return VDP_STATUS_OK;
+ } else {
+ ErrorMsg("Invalid NAL byte[3] %02X\n", bitstream[3]);
}
- assert(0);
-
return VDP_STATUS_ERROR;
}
@@ -191,7 +195,9 @@ static int get_refs_sorted(struct tegra_vde_h264_frame *dpb_frames,
surf = get_surface(ref->surface);
if (!surf) {
- assert(ref->surface == VDP_INVALID_HANDLE);
+ if (ref->surface != VDP_INVALID_HANDLE) {
+ ErrorMsg("invalid refs list\n");
+ }
continue;
}
@@ -215,9 +221,17 @@ static int get_refs_sorted(struct tegra_vde_h264_frame *dpb_frames,
prev = NULL;
while (1) {
- assert(itr->ref_surf->pic_order_cnt != surf->pic_order_cnt);
- assert(itr->ref_surf->pic_order_cnt != delim_pic_order_cnt);
- assert(itr->ref_surf->pic_order_cnt > 0);
+ if (itr->ref_surf->pic_order_cnt == surf->pic_order_cnt) {
+ ErrorMsg("invalid pic_order_cnt\n");
+ }
+
+ if (itr->ref_surf->pic_order_cnt == delim_pic_order_cnt) {
+ ErrorMsg("invalid pic_order_cnt\n");
+ }
+
+ if (itr->ref_surf->pic_order_cnt <= 0) {
+ ErrorMsg("invalid pic_order_cnt\n");
+ }
if (surf->pic_order_cnt < delim_pic_order_cnt) {
if (surf->pic_order_cnt > itr->ref_surf->pic_order_cnt) {
@@ -255,7 +269,9 @@ insert_node:
put_surface(surf);
}
- assert(refs_num != 0);
+ if (!refs_num) {
+ ErrorMsg("invalid refs list\n");
+ }
for (i = 0, itr = list_head; itr != NULL; i++, itr = itr->next) {
dpb_frames[1 + i] = *itr->ref_surf->frame;
@@ -283,7 +299,9 @@ static int get_refs_dpb_order(struct tegra_vde_h264_frame *dpb_frames,
surf = get_surface(ref->surface);
if (!surf) {
- assert(ref->surface == VDP_INVALID_HANDLE);
+ if (ref->surface != VDP_INVALID_HANDLE) {
+ ErrorMsg("invalid DPB frames list\n");
+ }
continue;
}
@@ -298,7 +316,9 @@ static int get_refs_dpb_order(struct tegra_vde_h264_frame *dpb_frames,
put_surface(surf);
}
- assert(refs_num != 0);
+ if (!refs_num) {
+ ErrorMsg("invalid DPB frames list\n");
+ }
return refs_num;
}
@@ -340,10 +360,10 @@ static int get_slice_type(bitstream_reader *reader)
slice_type = bitstream_read_ue(reader);
- assert(slice_type < 10);
-
- if (0) {
- printf("slice_type %s\n", slice_type_str(slice_type));
+ if (slice_type >= 10) {
+ ErrorMsg("invalid slice_type %u\n", slice_type);
+ } else {
+ DebugMsg("slice_type %s\n", slice_type_str(slice_type));
}
return slice_type;
@@ -398,7 +418,11 @@ static VdpStatus tegra_decode_h264(tegra_decoder *dec, tegra_surface *surf,
delim_pic_order_cnt = surf->pic_order_cnt;
}
- assert(delim_pic_order_cnt > 0);
+ if (delim_pic_order_cnt <= 0) {
+ ErrorMsg("invalid delim_pic_order_cnt %d\n",
+ delim_pic_order_cnt);
+ return VDP_STATUS_ERROR;
+ }
refs_num = get_refs_sorted(dpb_frames, info->referenceFrames,
frame_num_wrap, max_frame_num,
diff --git a/src/surface.c b/src/surface.c
index d3deb02..5adc502 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -487,7 +487,7 @@ VdpStatus destroy_surface(tegra_surface *surf)
int sync_video_frame_dmabufs(tegra_surface *surf, enum frame_sync type)
{
- int ret;
+ int ret = 0;
switch (type) {
case READ_START:
@@ -518,9 +518,8 @@ int sync_video_frame_dmabufs(tegra_surface *surf, enum frame_sync type)
break;
}
- assert(ret == 0);
-
if (ret) {
+ ErrorMsg("dmabuf sync %u failed %d\n", type, ret);
return ret;
}
@@ -539,9 +538,8 @@ int sync_video_frame_dmabufs(tegra_surface *surf, enum frame_sync type)
break;
}
- assert(ret == 0);
-
if (ret) {
+ ErrorMsg("dmabuf sync %u failed %d\n", type, ret);
return ret;
}
@@ -560,9 +558,8 @@ int sync_video_frame_dmabufs(tegra_surface *surf, enum frame_sync type)
break;
}
- assert(ret == 0);
-
if (ret) {
+ ErrorMsg("dmabuf sync %u failed %d\n", type, ret);
return ret;
}
diff --git a/src/surface_bitmap.c b/src/surface_bitmap.c
index d7f573b..ee4e118 100644
--- a/src/surface_bitmap.c
+++ b/src/surface_bitmap.c
@@ -173,8 +173,9 @@ VdpStatus vdp_bitmap_surface_put_bits_native(VdpBitmapSurface surface,
0, 0,
x0, y0,
width, height);
-
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
host1x_pixelbuffer_check_guard(surf->pixbuf);
diff --git a/src/surface_output.c b/src/surface_output.c
index 18c27a6..e66fb67 100644
--- a/src/surface_output.c
+++ b/src/surface_output.c
@@ -249,9 +249,11 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
dst_data = pixman_image_get_data(dst_pix);
pfmt = pixman_image_get_format(dst_pix);
- ret = pixman_format_supported_destination(pfmt);
- assert(ret != 0);
+ ret = pixman_format_supported_destination(pfmt);
+ if (!ret) {
+ ErrorMsg("pixman_format_supported_destination failed\n");
+ }
if (destination_rect != NULL) {
dst_width = destination_rect->x1 - destination_rect->x0;
@@ -289,8 +291,9 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
dst_x0, dst_y0,
dst_width, dst_height,
0xFFFFFFFF);
-
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_fill failed\n");
+ }
put_surface(dst_surf);
put_surface(src_surf);
@@ -309,9 +312,11 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
src_pix = src_surf->pix;
pfmt = pixman_image_get_format(src_pix);
- ret = pixman_format_supported_destination(pfmt);
- assert(ret != 0);
+ ret = pixman_format_supported_destination(pfmt);
+ if (!ret) {
+ ErrorMsg("pixman_format_supported_destination failed\n");
+ }
if (source_rect != NULL) {
src_width = source_rect->x1 - source_rect->x0;
@@ -325,7 +330,9 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
src_y0 = 0;
}
- assert(!(flags & ~3ul));
+ if (flags & ~3ul) {
+ ErrorMsg("invalid flags %X\n", flags);
+ }
switch (flags & 3) {
case VDP_OUTPUT_SURFACE_RENDER_ROTATE_90:
@@ -381,7 +388,9 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
break;
}
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_transform_rotate failed\n");
+ }
if (need_scale) {
double scalew = (double)src_width / (double)dst_width;
@@ -390,13 +399,15 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
ret = pixman_transform_scale(&transform, NULL,
pixman_double_to_fixed(scalew),
pixman_double_to_fixed(scaleh));
-
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_transform_scale failed\n");
+ }
}
ret = pixman_image_set_transform(src_pix, &transform);
-
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_image_set_transform failed\n");
+ }
}
pixman_image_composite(PIXMAN_OP_SRC,
@@ -410,7 +421,9 @@ VdpStatus vdp_output_surface_render_bitmap_surface(
if (need_scale || need_rotate) {
ret = pixman_image_set_transform(src_pix, NULL);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_image_set_transform failed\n");
+ }
}
put_surface(dst_surf);
diff --git a/src/surface_video.c b/src/surface_video.c
index 2f03d1c..ee86383 100644
--- a/src/surface_video.c
+++ b/src/surface_video.c
@@ -170,7 +170,9 @@ VdpStatus vdp_video_surface_get_bits_y_cb_cr(
0, 0,
0, 0,
width, height);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
/* Copy chroma blue plane. */
ret = pixman_blt(surf->cb_data, dst_cb,
@@ -179,7 +181,9 @@ VdpStatus vdp_video_surface_get_bits_y_cb_cr(
0, 0,
0, 0,
width / 2, height / 2);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
/* Copy chroma red plane. */
ret = pixman_blt(surf->cr_data, dst_cr,
@@ -188,7 +192,9 @@ VdpStatus vdp_video_surface_get_bits_y_cb_cr(
0, 0,
0, 0,
width / 2, height / 2);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
ret = sync_video_frame_dmabufs(surf, READ_END);
@@ -257,7 +263,9 @@ VdpStatus vdp_video_surface_put_bits_y_cb_cr(
0, 0,
0, 0,
width, height);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
/* Copy chroma blue plane. */
ret = pixman_blt(src_cb, surf->cb_data,
@@ -266,7 +274,9 @@ VdpStatus vdp_video_surface_put_bits_y_cb_cr(
0, 0,
0, 0,
width / 2, height / 2);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
/* Copy chroma red plane. */
ret = pixman_blt(src_cr, surf->cr_data,
@@ -275,7 +285,9 @@ VdpStatus vdp_video_surface_put_bits_y_cb_cr(
0, 0,
0, 0,
width / 2, height / 2);
- assert(ret != 0);
+ if (!ret) {
+ ErrorMsg("pixman_blt failed\n");
+ }
host1x_pixelbuffer_check_guard(surf->pixbuf);