msdk: return the right pointer

The first channel in memory for MFX_FOURCC_RGB4 (VA_FOURCC_ARGB or
GST_VIDEO_FORMAT_BGRA) is B, not A. In MSDK, channle B is used to access
data for RGB4 surface. In addition, the returned pointers for
MFX_FOURCC_AYUV and MFX_FOURCC_Y410 in gst_msdk_video_memory_map_full
were wrong too before this fix.
This commit is contained in:
Haihao Xiang 2019-10-09 14:00:01 +08:00 committed by Víctor Manuel Jáquez Leal
parent f2c75d548d
commit e5279cd97a
3 changed files with 58 additions and 23 deletions

View file

@ -343,10 +343,10 @@ gst_msdk_frame_lock (mfxHDL pthis, mfxMemId mid, mfxFrameData * data)
break; break;
case VA_FOURCC_ARGB: case VA_FOURCC_ARGB:
data->Pitch = mem_id->image.pitches[0]; data->Pitch = mem_id->image.pitches[0];
data->R = buf + mem_id->image.offsets[0]; data->B = buf + mem_id->image.offsets[0];
data->G = data->R + 1; data->G = data->B + 1;
data->B = data->R + 2; data->R = data->B + 2;
data->A = data->R + 3; data->A = data->B + 3;
break; break;
#if (MFX_VERSION >= 1028) #if (MFX_VERSION >= 1028)
case VA_FOURCC_RGB565: case VA_FOURCC_RGB565:

View file

@ -109,9 +109,10 @@ ensure_data (GstMsdkSystemMemory * mem)
mem->surface->Data.Pitch = mem->destination_pitches[0]; mem->surface->Data.Pitch = mem->destination_pitches[0];
break; break;
case GST_VIDEO_FORMAT_BGRA: case GST_VIDEO_FORMAT_BGRA:
mem->surface->Data.R = mem->cached_data[0]; mem->surface->Data.B = mem->cached_data[0];
mem->surface->Data.G = mem->surface->Data.R + 1; mem->surface->Data.G = mem->surface->Data.B + 1;
mem->surface->Data.B = mem->surface->Data.R + 2; mem->surface->Data.R = mem->surface->Data.B + 2;
mem->surface->Data.A = mem->surface->Data.B + 3;
mem->surface->Data.Pitch = mem->destination_pitches[0]; mem->surface->Data.Pitch = mem->destination_pitches[0];
break; break;
#if (MFX_VERSION >= 1028) #if (MFX_VERSION >= 1028)
@ -237,15 +238,22 @@ gst_msdk_system_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
return NULL; return NULL;
} }
/* The first channel in memory is V for MFX_FOURCC_AYUV (GST_VIDEO_FORMAT_VUYA) format */ switch (mem->surface->Info.FourCC) {
if (mem->surface->Info.FourCC == MFX_FOURCC_AYUV) case MFX_FOURCC_RGB4:
return mem->surface->Data.V; return mem->surface->Data.B; /* The first channel is B */
/* The first channel in memory is V for MFX_FOURCC_AYUV (GST_VIDEO_FORMAT_VUYA) format */
case MFX_FOURCC_AYUV:
return mem->surface->Data.V;
#if (MFX_VERSION >= 1027) #if (MFX_VERSION >= 1027)
else if (mem->surface->Info.FourCC == MFX_FOURCC_Y410) case MFX_FOURCC_Y410:
return mem->surface->Data.U; /* Data.Y410 */ return mem->surface->Data.U; /* Data.Y410 */
#endif #endif
else
return mem->surface->Data.Y; default:
return mem->surface->Data.Y;
}
} }
static void static void

View file

@ -237,15 +237,26 @@ gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
pitch = mem_id->pitch; pitch = mem_id->pitch;
#endif #endif
/* The first channel in memory is V for GST_VIDEO_FORMAT_VUYA */ switch (meta->format) {
if (meta->format == GST_VIDEO_FORMAT_VUYA) case GST_VIDEO_FORMAT_BGRA:
*data = mem->surface->Data.V + offset; *data = mem->surface->Data.B + offset;
else if (meta->format == GST_VIDEO_FORMAT_Y410) break;
*data = mem->surface->Data.U + offset; /* Data.Y410 */
else
*data = mem->surface->Data.Y + offset;
*stride = pitch;
/* The first channel in memory is V for GST_VIDEO_FORMAT_VUYA */
case GST_VIDEO_FORMAT_VUYA:
*data = mem->surface->Data.V + offset;
break;
case GST_VIDEO_FORMAT_Y410:
*data = mem->surface->Data.U + offset; /* Data.Y410 */
break;
default:
*data = mem->surface->Data.Y + offset;
break;
}
*stride = pitch;
info->flags = flags; info->flags = flags;
ret = (*data != NULL); ret = (*data != NULL);
@ -300,7 +311,23 @@ gst_msdk_video_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
gst_msdk_frame_lock (msdk_video_allocator->context, mem->surface->Data.MemId, gst_msdk_frame_lock (msdk_video_allocator->context, mem->surface->Data.MemId,
&mem->surface->Data); &mem->surface->Data);
return mem->surface->Data.Y;
switch (mem->surface->Info.FourCC) {
case MFX_FOURCC_RGB4:
return mem->surface->Data.B; /* The first channel is B */
/* The first channel in memory is V for MFX_FOURCC_AYUV (GST_VIDEO_FORMAT_VUYA) format */
case MFX_FOURCC_AYUV:
return mem->surface->Data.V;
#if (MFX_VERSION >= 1027)
case MFX_FOURCC_Y410:
return mem->surface->Data.U; /* Data.Y410 */
#endif
default:
return mem->surface->Data.Y;
}
} }
static void static void