mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
applemedia: corevideobuffer: make mapping the CVPixelBuffer in CPU optional
Mapping is not necessary and impacts performance when doing texture sharing with downstream
This commit is contained in:
parent
c7284a6390
commit
e91989136a
5 changed files with 22 additions and 13 deletions
|
@ -59,7 +59,8 @@ gst_core_video_meta_get_info (void)
|
|||
}
|
||||
|
||||
GstBuffer *
|
||||
gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
|
||||
gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo,
|
||||
gboolean map)
|
||||
{
|
||||
CVPixelBufferRef pixbuf = NULL;
|
||||
GstBuffer *buf;
|
||||
|
@ -74,7 +75,7 @@ gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
|
|||
|
||||
pixbuf = (CVPixelBufferRef) cvbuf;
|
||||
|
||||
if (CVPixelBufferLockBaseAddress (pixbuf, 0) != kCVReturnSuccess) {
|
||||
if (map && CVPixelBufferLockBaseAddress (pixbuf, 0) != kCVReturnSuccess) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -101,11 +102,13 @@ gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
|
|||
offset[i] = off;
|
||||
off += size;
|
||||
|
||||
if (map) {
|
||||
gst_buffer_append_memory (buf,
|
||||
gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE,
|
||||
CVPixelBufferGetBaseAddressOfPlane (pixbuf, i), size, 0, size,
|
||||
NULL, NULL));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int size;
|
||||
|
||||
|
@ -114,10 +117,12 @@ gst_core_video_buffer_new (CVBufferRef cvbuf, GstVideoInfo * vinfo)
|
|||
offset[0] = 0;
|
||||
size = stride[0] * CVPixelBufferGetHeight (pixbuf);
|
||||
|
||||
if (map) {
|
||||
gst_buffer_append_memory (buf,
|
||||
gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE,
|
||||
CVPixelBufferGetBaseAddress (pixbuf), size, 0, size, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
if (vinfo) {
|
||||
GstVideoMeta *video_meta;
|
||||
|
|
|
@ -41,7 +41,8 @@ typedef struct _GstCoreVideoMeta
|
|||
} GstCoreVideoMeta;
|
||||
|
||||
GstBuffer * gst_core_video_buffer_new (CVBufferRef cvbuf,
|
||||
GstVideoInfo *info);
|
||||
GstVideoInfo *info,
|
||||
gboolean map);
|
||||
GType gst_core_video_meta_api_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -434,7 +434,7 @@ openFailed:
|
|||
[queueLock unlockWithCondition:
|
||||
([queue count] == 0) ? NO_FRAMES : HAS_FRAME_OR_STOP_REQUEST];
|
||||
|
||||
*buf = gst_core_video_buffer_new ((CVBufferRef)frame, NULL);
|
||||
*buf = gst_core_video_buffer_new ((CVBufferRef)frame, NULL, TRUE);
|
||||
CVBufferRelease (frame);
|
||||
|
||||
[self timestampBuffer:*buf];
|
||||
|
|
|
@ -640,7 +640,9 @@ gst_vtdec_session_output_callback (void *decompression_output_ref_con,
|
|||
* segment.format being undefined */
|
||||
goto release;
|
||||
}
|
||||
buf = gst_core_video_buffer_new (image_buffer, &state->info);
|
||||
buf =
|
||||
gst_core_video_buffer_new (image_buffer, &state->info,
|
||||
vtdec->texture_cache == NULL);
|
||||
gst_video_codec_state_unref (state);
|
||||
|
||||
gst_buffer_copy_into (buf, frame->input_buffer,
|
||||
|
|
|
@ -1098,7 +1098,8 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstVideoCodecFrame * frame)
|
|||
goto cv_error;
|
||||
}
|
||||
|
||||
outbuf = gst_core_video_buffer_new ((CVBufferRef) pbuf, &self->video_info);
|
||||
outbuf =
|
||||
gst_core_video_buffer_new ((CVBufferRef) pbuf, &self->video_info, TRUE);
|
||||
if (!gst_video_frame_map (&outframe, &self->video_info, outbuf,
|
||||
GST_MAP_WRITE)) {
|
||||
gst_video_frame_unmap (&inframe);
|
||||
|
|
Loading…
Reference in a new issue