va: encoder: Add copy_output_data() helper function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3015>
This commit is contained in:
parent
39144f612e
commit
726cc895d8
@ -330,6 +330,53 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return 0 means error and -1 means not enough data. */
|
||||||
|
gint
|
||||||
|
gst_va_base_enc_copy_output_data (GstVaBaseEnc * base,
|
||||||
|
GstVaEncodePicture * picture, guint8 * data, gint size)
|
||||||
|
{
|
||||||
|
guint coded_size;
|
||||||
|
VASurfaceID surface;
|
||||||
|
VACodedBufferSegment *seg, *seg_list;
|
||||||
|
gint ret_sz = 0;
|
||||||
|
|
||||||
|
/* Wait for encoding to finish */
|
||||||
|
surface = gst_va_encode_picture_get_raw_surface (picture);
|
||||||
|
if (!va_sync_surface (base->display, surface))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
seg_list = NULL;
|
||||||
|
if (!va_map_buffer (base->display, GST_MAP_READ, picture->coded_buffer,
|
||||||
|
(gpointer *) & seg_list))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!seg_list) {
|
||||||
|
va_unmap_buffer (base->display, picture->coded_buffer);
|
||||||
|
GST_WARNING_OBJECT (base, "coded buffer has no segment list");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
coded_size = 0;
|
||||||
|
for (seg = seg_list; seg; seg = seg->next)
|
||||||
|
coded_size += seg->size;
|
||||||
|
|
||||||
|
if (coded_size > size) {
|
||||||
|
GST_DEBUG_OBJECT (base, "Not enough space for coded data");
|
||||||
|
ret_sz = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (seg = seg_list; seg; seg = seg->next) {
|
||||||
|
memcpy (data + ret_sz, seg->buf, seg->size);
|
||||||
|
ret_sz += seg->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_unmap_buffer (base->display, picture->coded_buffer);
|
||||||
|
|
||||||
|
out:
|
||||||
|
return ret_sz;
|
||||||
|
}
|
||||||
|
|
||||||
static GstAllocator *
|
static GstAllocator *
|
||||||
_allocator_from_caps (GstVaBaseEnc * base, GstCaps * caps)
|
_allocator_from_caps (GstVaBaseEnc * base, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,10 @@ void gst_va_base_enc_add_codec_tag (GstVaBaseEnc * base,
|
|||||||
void gst_va_base_enc_reset_state (GstVaBaseEnc * base);
|
void gst_va_base_enc_reset_state (GstVaBaseEnc * base);
|
||||||
GstBuffer * gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
|
GstBuffer * gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
|
||||||
GstVaEncodePicture * picture);
|
GstVaEncodePicture * picture);
|
||||||
|
gint gst_va_base_enc_copy_output_data (GstVaBaseEnc * base,
|
||||||
|
GstVaEncodePicture * picture,
|
||||||
|
guint8 * data,
|
||||||
|
gint size);
|
||||||
void gst_va_base_enc_update_property_uint (GstVaBaseEnc * base,
|
void gst_va_base_enc_update_property_uint (GstVaBaseEnc * base,
|
||||||
guint32 * old_val,
|
guint32 * old_val,
|
||||||
guint32 new_val,
|
guint32 new_val,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user