va: baseenc: Extend the create_output_buffer() to accept prefix data

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3015>
This commit is contained in:
He Junyan 2023-06-11 20:17:19 +08:00 committed by GStreamer Marge Bot
parent 726cc895d8
commit f4779f1fab
4 changed files with 16 additions and 5 deletions

View file

@ -271,7 +271,8 @@ gst_va_base_enc_import_input_buffer (GstVaBaseEnc * base,
GstBuffer *
gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
GstVaEncodePicture * picture)
GstVaEncodePicture * picture, const guint8 * prefix_data,
guint prefix_data_len)
{
guint coded_size;
goffset offset;
@ -300,7 +301,7 @@ gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
coded_size += seg->size;
buf = gst_video_encoder_allocate_output_buffer (GST_VIDEO_ENCODER_CAST (base),
coded_size);
coded_size + prefix_data_len);
if (!buf) {
va_unmap_buffer (base->display, picture->coded_buffer);
GST_ERROR_OBJECT (base, "Failed to allocate output buffer, size %d",
@ -309,6 +310,12 @@ gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
}
offset = 0;
if (prefix_data) {
g_assert (prefix_data_len > 0);
gst_buffer_fill (buf, offset, prefix_data, prefix_data_len);
offset += prefix_data_len;
}
for (seg = seg_list; seg; seg = seg->next) {
gsize write_size;

View file

@ -138,7 +138,9 @@ void gst_va_base_enc_add_codec_tag (GstVaBaseEnc * base,
const gchar * codec_name);
void gst_va_base_enc_reset_state (GstVaBaseEnc * base);
GstBuffer * gst_va_base_enc_create_output_buffer (GstVaBaseEnc * base,
GstVaEncodePicture * picture);
GstVaEncodePicture * picture,
const guint8 * prefix_data,
guint prefix_data_len);
gint gst_va_base_enc_copy_output_data (GstVaBaseEnc * base,
GstVaEncodePicture * picture,
guint8 * data,

View file

@ -3057,7 +3057,8 @@ gst_va_h264_enc_prepare_output (GstVaBaseEnc * base,
base->output_frame_count++;
frame->duration = base->frame_duration;
buf = gst_va_base_enc_create_output_buffer (base, frame_enc->picture);
buf = gst_va_base_enc_create_output_buffer (base,
frame_enc->picture, NULL, 0);
if (!buf) {
GST_ERROR_OBJECT (base, "Failed to create output buffer");
return FALSE;

View file

@ -4630,7 +4630,8 @@ gst_va_h265_enc_prepare_output (GstVaBaseEnc * base,
base->output_frame_count++;
frame->duration = base->frame_duration;
buf = gst_va_base_enc_create_output_buffer (base, frame_enc->picture);
buf = gst_va_base_enc_create_output_buffer (base,
frame_enc->picture, NULL, 0);
if (!buf) {
GST_ERROR_OBJECT (base, "Failed to create output buffer");
return FALSE;