mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
amc: Don't map input buffer with write mode
When copying data out of a GStreamer buffer, we don't need to map it writable. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2492>
This commit is contained in:
parent
eefd793011
commit
6c0423b861
1 changed files with 19 additions and 5 deletions
|
@ -798,13 +798,16 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
guint8 *cptr = NULL, *vptr = NULL;
|
guint8 *cptr = NULL, *vptr = NULL;
|
||||||
|
GstMapFlags vmap_mode;
|
||||||
guint8 **src, **dest;
|
guint8 **src, **dest;
|
||||||
|
|
||||||
if (direction == COLOR_FORMAT_COPY_OUT) {
|
if (direction == COLOR_FORMAT_COPY_OUT) {
|
||||||
src = &cptr;
|
src = &cptr;
|
||||||
dest = &vptr;
|
dest = &vptr;
|
||||||
|
vmap_mode = GST_MAP_WRITE;
|
||||||
} else {
|
} else {
|
||||||
src = &vptr;
|
src = &vptr;
|
||||||
|
vmap_mode = GST_MAP_READ;
|
||||||
dest = &cptr;
|
dest = &cptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,7 +816,8 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
GstMapInfo minfo;
|
GstMapInfo minfo;
|
||||||
|
|
||||||
GST_DEBUG ("Buffer sizes equal, doing fast copy");
|
GST_DEBUG ("Buffer sizes equal, doing fast copy");
|
||||||
gst_buffer_map (vbuffer, &minfo, GST_MAP_WRITE);
|
if (!gst_buffer_map (vbuffer, &minfo, vmap_mode))
|
||||||
|
goto fail_map;
|
||||||
|
|
||||||
cptr = cbuffer->data + cbuffer_info->offset;
|
cptr = cbuffer->data + cbuffer_info->offset;
|
||||||
vptr = minfo.data;
|
vptr = minfo.data;
|
||||||
|
@ -841,7 +845,8 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
slice_height = cinfo->slice_height;
|
slice_height = cinfo->slice_height;
|
||||||
g_assert (stride > 0 && slice_height > 0);
|
g_assert (stride > 0 && slice_height > 0);
|
||||||
|
|
||||||
gst_video_frame_map (&vframe, vinfo, vbuffer, GST_MAP_WRITE);
|
if (!gst_video_frame_map (&vframe, vinfo, vbuffer, vmap_mode))
|
||||||
|
goto fail_map;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -899,7 +904,9 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
|
|
||||||
/* FIXME: This does not work for odd widths or heights
|
/* FIXME: This does not work for odd widths or heights
|
||||||
* but might as well be a bug in the codec */
|
* but might as well be a bug in the codec */
|
||||||
gst_video_frame_map (&vframe, vinfo, vbuffer, GST_MAP_WRITE);
|
if (!gst_video_frame_map (&vframe, vinfo, vbuffer, vmap_mode))
|
||||||
|
goto fail_map;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
c_stride = cinfo->stride;
|
c_stride = cinfo->stride;
|
||||||
|
@ -942,7 +949,8 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
/* This should always be set */
|
/* This should always be set */
|
||||||
g_assert (cinfo->stride > 0 && cinfo->slice_height > 0);
|
g_assert (cinfo->stride > 0 && cinfo->slice_height > 0);
|
||||||
|
|
||||||
gst_video_frame_map (&vframe, vinfo, vbuffer, GST_MAP_WRITE);
|
if (!gst_video_frame_map (&vframe, vinfo, vbuffer, vmap_mode))
|
||||||
|
goto fail_map;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
c_stride = cinfo->stride;
|
c_stride = cinfo->stride;
|
||||||
|
@ -988,7 +996,9 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
const size_t tile_h_chroma = (height / 2 - 1) / TILE_HEIGHT + 1;
|
const size_t tile_h_chroma = (height / 2 - 1) / TILE_HEIGHT + 1;
|
||||||
size_t luma_size = tile_w_align * tile_h_luma * TILE_SIZE;
|
size_t luma_size = tile_w_align * tile_h_luma * TILE_SIZE;
|
||||||
|
|
||||||
gst_video_frame_map (&vframe, vinfo, vbuffer, GST_MAP_WRITE);
|
if (!gst_video_frame_map (&vframe, vinfo, vbuffer, vmap_mode))
|
||||||
|
goto fail_map;
|
||||||
|
|
||||||
v_luma = GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0);
|
v_luma = GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0);
|
||||||
v_chroma = GST_VIDEO_FRAME_PLANE_DATA (&vframe, 1);
|
v_chroma = GST_VIDEO_FRAME_PLANE_DATA (&vframe, 1);
|
||||||
v_luma_stride = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 0);
|
v_luma_stride = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 0);
|
||||||
|
@ -1069,6 +1079,10 @@ gst_amc_color_format_copy (GstAmcColorFormatInfo * cinfo,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
fail_map:
|
||||||
|
GST_ERROR ("Failed to map GStreamer buffer memory in mode %d", vmap_mode);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
|
|
Loading…
Reference in a new issue