const GstVaapiContextInfo *const cip = &context->info;
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (context);
guint va_rate_control;
- VAConfigAttrib attribs[2], *attrib = attribs;
+ VAConfigAttrib attribs[3], *attrib = attribs;
VAContextID context_id;
VASurfaceID surface_id;
VAStatus status;
}
attrib->value = va_rate_control;
attrib++;
+
+ /* Packed headers */
+ if (config->packed_headers) {
+ attrib->type = VAConfigAttribEncPackedHeaders;
+ if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
+ goto cleanup;
+
+ if ((value & config->packed_headers) != config->packed_headers) {
+ GST_ERROR ("unsupported packed headers 0x%08x",
+ config->packed_headers & ~(value & config->packed_headers));
+ goto cleanup;
+ }
+ attrib->value = config->packed_headers;
+ attrib++;
+ }
break;
}
default:
config->rc_mode = new_config->rc_mode;
config_changed = TRUE;
}
+
+ if (config->packed_headers != new_config->packed_headers) {
+ config->packed_headers = new_config->packed_headers;
+ config_changed = TRUE;
+ }
return config_changed;
}
/**
* GstVaapiConfigInfoEncoder:
* @rc_mode: rate-control mode (#GstVaapiRateControl).
+ * @packed_headers: notify encoder that packed headers are submitted (mask).
*
* Extra configuration for encoding.
*/
struct _GstVaapiConfigInfoEncoder
{
GstVaapiRateControl rc_mode;
+ guint packed_headers;
};
/**
return TRUE;
}
-/* Determines the set of required packed headers */
-static void
-ensure_packed_headers (GstVaapiEncoder * encoder)
+/* Determines the set of supported packed headers */
+static guint
+get_packed_headers (GstVaapiEncoder * encoder)
{
- if (!gst_vaapi_context_get_attribute (encoder->context,
- VAConfigAttribEncPackedHeaders, &encoder->packed_headers))
- encoder->packed_headers = 0;
- GST_INFO ("packed headers mask: 0x%08x", encoder->packed_headers);
+ const GstVaapiEncoderClassData *const cdata =
+ GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data;
+ guint value;
+
+ if (encoder->got_packed_headers)
+ return encoder->packed_headers;
+
+ if (!get_config_attribute (encoder, VAConfigAttribEncPackedHeaders, &value))
+ value = 0;
+ GST_INFO ("supported packed headers: 0x%08x", value);
+
+ encoder->got_packed_headers = TRUE;
+ encoder->packed_headers = cdata->packed_headers & value;
+ return encoder->packed_headers;
}
/* Updates video context */
memset (config, 0, sizeof (*config));
config->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
+ config->packed_headers = get_packed_headers (encoder);
}
/* Ensures the underlying VA context for encoding is created */
if (!gst_vaapi_encoder_ensure_context (encoder))
goto error_reset_context;
- ensure_packed_headers (encoder);
codedbuf_size = encoder->codedbuf_pool ?
gst_vaapi_coded_buffer_pool_get_buffer_size (GST_VAAPI_CODED_BUFFER_POOL
(GST_VAAPI_ENCODER_TUNE_MASK (NONE) | \
GST_VAAPI_ENCODER_TUNE_MASK (HIGH_COMPRESSION))
+/* Supported set of VA packed headers, within this implementation */
+#define SUPPORTED_PACKED_HEADERS \
+ (VA_ENC_PACKED_HEADER_SEQUENCE | \
+ VA_ENC_PACKED_HEADER_PICTURE)
+
#define GST_VAAPI_ENCODER_H264_NAL_REF_IDC_NONE 0
#define GST_VAAPI_ENCODER_H264_NAL_REF_IDC_LOW 1
#define GST_VAAPI_ENCODER_H264_NAL_REF_IDC_MEDIUM 2
#define SUPPORTED_TUNE_OPTIONS \
(GST_VAAPI_ENCODER_TUNE_MASK (NONE))
+/* Supported set of VA packed headers, within this implementation */
+#define SUPPORTED_PACKED_HEADERS \
+ (VA_ENC_PACKED_HEADER_SEQUENCE | \
+ VA_ENC_PACKED_HEADER_PICTURE)
+
static gboolean
gst_bit_writer_write_sps (GstBitWriter * bitwriter,
const VAEncSequenceParameterBufferMPEG2 * seq_param);
GAsyncQueue *codedbuf_queue;
guint32 num_codedbuf_queued;
+ guint got_packed_headers:1;
guint got_rate_control_mask:1;
};
{
/*< private >*/
GstVaapiCodec codec;
+ guint32 packed_headers;
GType (*rate_control_get_type)(void);
GstVaapiRateControl default_rate_control;
\
static const GstVaapiEncoderClassData g_class_data = { \
.codec = G_PASTE (GST_VAAPI_CODEC_, CODEC), \
+ .packed_headers = SUPPORTED_PACKED_HEADERS, \
.rate_control_get_type = \
G_PASTE (G_PASTE (gst_vaapi_rate_control_, CODEC), _get_type), \
.default_rate_control = DEFAULT_RATECONTROL, \