* @sps: the sps of #GstH264SPS to write
* @start_code: whether adding the nal start code
* @data: (out): the bit stream generated by the sps
- * @size: (inout): the size in bits of the output
+ * @size: (inout): the size in bytes of the input and output
*
* Generating the according h264 bit stream by providing the sps.
*
**/
GstH264BitWriterResult
gst_h264_bit_writer_sps (const GstH264SPS * sps, gboolean start_code,
- guint8 * data, gsize * size)
+ guint8 * data, guint * size)
{
gboolean have_space = TRUE;
GstBitWriter bw;
goto error;
}
- *size = gst_bit_writer_get_size (&bw);
+ *size = (gst_bit_writer_get_size (&bw)) / 8;
gst_bit_writer_reset (&bw);
return GST_H264_BIT_WRITER_OK;
* @pps: the pps of #GstH264PPS to write
* @start_code: whether adding the nal start code
* @data: (out): the bit stream generated by the pps
- * @size: (inout): the size in bits of the output
+ * @size: (inout): the size in bytes of the input and output
*
* Generating the according h264 bit stream by providing the pps.
*
**/
GstH264BitWriterResult
gst_h264_bit_writer_pps (const GstH264PPS * pps, gboolean start_code,
- guint8 * data, gsize * size)
+ guint8 * data, guint * size)
{
gboolean have_space = TRUE;
GstBitWriter bw;
goto error;
}
- *size = gst_bit_writer_get_size (&bw);
+ *size = (gst_bit_writer_get_size (&bw)) / 8;
gst_bit_writer_reset (&bw);
return GST_H264_BIT_WRITER_OK;
* @nal_type: the slice's nal type of #GstH264NalUnitType
* @is_ref: whether the slice is a reference
* @data: (out): the bit stream generated by the slice header
- * @size: (inout): the size in bits of the output
+ * @size: (inout): the size in bytes of the input and output
+ * @trail_bits_num: (out): the trail bits number which is not byte aligned.
*
* Generating the according h264 bit stream by providing the slice header.
*
GstH264BitWriterResult
gst_h264_bit_writer_slice_hdr (const GstH264SliceHdr * slice,
gboolean start_code, GstH264NalUnitType nal_type, gboolean is_ref,
- guint8 * data, gsize * size)
+ guint8 * data, guint * size, guint * trail_bits_num)
{
gboolean have_space = TRUE;
GstBitWriter bw;
g_return_val_if_fail (data != NULL, GST_H264_BIT_WRITER_ERROR);
g_return_val_if_fail (size != NULL, GST_H264_BIT_WRITER_ERROR);
g_return_val_if_fail (*size > 0, GST_H264_BIT_WRITER_ERROR);
+ g_return_val_if_fail (trail_bits_num != NULL, GST_H264_BIT_WRITER_ERROR);
if (nal_type == GST_H264_NAL_SLICE_IDR)
g_return_val_if_fail (is_ref, GST_H264_BIT_WRITER_ERROR);
/* We do not add trailing bits here, the slice data should follow it. */
- *size = gst_bit_writer_get_size (&bw);
+ *size = gst_bit_writer_get_size (&bw) / 8;
+ *trail_bits_num = gst_bit_writer_get_size (&bw) % 8;
gst_bit_writer_reset (&bw);
return GST_H264_BIT_WRITER_OK;
* @sei_messages: An array of #GstH264SEIMessage to write
* @start_code: whether adding the nal start code
* @data: (out): the bit stream generated by the sei messages
- * @size: (inout): the size in bits of the output
+ * @size: (inout): the size in bytes of the input and output
*
* Generating the according h264 bit stream by providing sei messages.
*
**/
GstH264BitWriterResult
gst_h264_bit_writer_sei (GArray * sei_messages, gboolean start_code,
- guint8 * data, gsize * size)
+ guint8 * data, guint * size)
{
gboolean have_space = TRUE;
GstBitWriter bw;
goto error;
}
- *size = gst_bit_writer_get_size (&bw);
+ *size = (gst_bit_writer_get_size (&bw)) / 8;
gst_bit_writer_reset (&bw);
return GST_H264_BIT_WRITER_OK;
* as the H264 spec defines
* @start_code: whether adding the nal start code
* @data: (out): the bit stream generated by the aud
- * @size: (inout): the size in bits of the output
+ * @size: (inout): the size in bytes of the input and output
*
* Generating the according h264 bit stream of an aud.
*
**/
GstH264BitWriterResult
gst_h264_bit_writer_aud (guint8 primary_pic_type, gboolean start_code,
- guint8 * data, gsize * size)
+ guint8 * data, guint * size)
{
gboolean have_space = TRUE;
GstBitWriter bw;
goto error;
}
- *size = gst_bit_writer_get_size (&bw);
+ *size = (gst_bit_writer_get_size (&bw)) / 8;
gst_bit_writer_reset (&bw);
return GST_H264_BIT_WRITER_OK;
GstH264BitWriterResult
gst_h264_bit_writer_convert_to_nal (guint nal_prefix_size, gboolean packetized,
gboolean has_startcode, gboolean add_trailings, const guint8 * raw_data,
- gsize raw_size, guint8 * nal_data, guint32 * nal_size)
+ gsize raw_size, guint8 * nal_data, guint * nal_size)
{
NalWriter nw;
guint8 *data;
GstH264BitWriterResult gst_h264_bit_writer_sps (const GstH264SPS * sps,
gboolean start_code,
guint8 * data,
- gsize * size);
+ guint * size);
GST_CODEC_PARSERS_API
GstH264BitWriterResult gst_h264_bit_writer_pps (const GstH264PPS * pps,
gboolean start_code,
guint8 * data,
- gsize * size);
+ guint * size);
GST_CODEC_PARSERS_API
GstH264BitWriterResult gst_h264_bit_writer_slice_hdr (const GstH264SliceHdr * slice,
gboolean start_code,
GstH264NalUnitType nal_type,
gboolean is_ref,
guint8 * data,
- gsize * size);
+ guint * size,
+ guint * trail_bits_num);
GST_CODEC_PARSERS_API
GstH264BitWriterResult gst_h264_bit_writer_sei (GArray * sei_messages,
gboolean start_code,
guint8 * data,
- gsize * size);
+ guint * size);
GST_CODEC_PARSERS_API
GstH264BitWriterResult gst_h264_bit_writer_aud (guint8 primary_pic_type,
gboolean start_code,
guint8 * data,
- gsize * size);
+ guint * size);
GST_CODEC_PARSERS_API
GstH264BitWriterResult gst_h264_bit_writer_convert_to_nal (guint nal_prefix_size,
gboolean packetized,
const guint8 * raw_data,
gsize raw_size,
guint8 * nal_data,
- guint32 * nal_size);
+ guint * nal_size);
G_END_DECLS
_add_sequence_header (GstVaH264Enc * self, GstVaH264EncFrame * frame)
{
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
- gsize size;
+ guint size;
#define SPS_SIZE 4 + GST_ROUND_UP_8 (MAX_SPS_HDR_SIZE + MAX_VUI_PARAMS_SIZE + \
2 * MAX_HRD_PARAMS_SIZE) / 8
guint8 packed_sps[SPS_SIZE] = { 0, };
}
if (!gst_va_encoder_add_packed_header (base->encoder, frame->picture,
- VAEncPackedHeaderSequence, packed_sps, size, FALSE)) {
+ VAEncPackedHeaderSequence, packed_sps, size * 8, FALSE)) {
GST_ERROR_OBJECT (self, "Failed to add the packed sequence header");
return FALSE;
}
#define PPS_SIZE 4 + GST_ROUND_UP_8 (MAX_PPS_HDR_SIZE) / 8
guint8 packed_pps[PPS_SIZE] = { 0, };
#undef PPS_SIZE
- gsize size;
+ guint size;
size = sizeof (packed_pps);
if (gst_h264_bit_writer_pps (pps, TRUE, packed_pps,
}
if (!gst_va_encoder_add_packed_header (base->encoder, frame->picture,
- VAEncPackedHeaderPicture, packed_pps, size, FALSE)) {
+ VAEncPackedHeaderPicture, packed_pps, size * 8, FALSE)) {
GST_ERROR_OBJECT (self, "Failed to add the packed picture header");
return FALSE;
}
{
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
GstH264SliceHdr slice_hdr;
- gsize size;
+ guint size, trail_bits;
GstH264NalUnitType nal_type = GST_H264_NAL_SLICE;
#define SLICE_HDR_SIZE 4 + GST_ROUND_UP_8 (MAX_SLICE_HDR_SIZE) / 8
guint8 packed_slice_hdr[SLICE_HDR_SIZE] = { 0, };
}
size = sizeof (packed_slice_hdr);
+ trail_bits = 0;
if (gst_h264_bit_writer_slice_hdr (&slice_hdr, TRUE, nal_type, frame->is_ref,
- packed_slice_hdr, &size) != GST_H264_BIT_WRITER_OK) {
+ packed_slice_hdr, &size, &trail_bits) != GST_H264_BIT_WRITER_OK) {
GST_ERROR_OBJECT (self, "Failed to generate the slice header");
return FALSE;
}
if (!gst_va_encoder_add_packed_header (base->encoder, frame->picture,
- VAEncPackedHeaderSlice, packed_slice_hdr, size, FALSE)) {
+ VAEncPackedHeaderSlice, packed_slice_hdr, size * 8 + trail_bits,
+ FALSE)) {
GST_ERROR_OBJECT (self, "Failed to add the packed slice header");
return FALSE;
}
{
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
guint8 aud_data[8] = { };
- gsize size;
+ guint size;
guint8 primary_pic_type = 0;
switch (frame->type) {
}
if (!gst_va_encoder_add_packed_header (base->encoder, frame->picture,
- VAEncPackedHeaderRawData, aud_data, size, FALSE)) {
+ VAEncPackedHeaderRawData, aud_data, size * 8, FALSE)) {
GST_ERROR_OBJECT (self, "Failed to add the AUD");
return FALSE;
}
GstH264SliceHdr slice_parsed;
guint8 header_data[128] = { 0, };
guint8 header_nal[128] = { 0, };
- gsize size;
- guint32 nal_size;
+ guint size, trail_bits;
+ guint nal_size;
guint i;
size = sizeof (header_data);
nal_size = sizeof (header_nal);
ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
- header_data, size, header_nal, &nal_size);
+ header_data, size * 8, header_nal, &nal_size);
fail_if (ret != GST_H264_BIT_WRITER_OK);
- fail_if (nal_size < GST_ROUND_UP_8 (size) / 8);
+ fail_if (nal_size < size);
/* Parse it again */
res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
nal_size = sizeof (header_nal);
ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
- header_data, size, header_nal, &nal_size);
+ header_data, size * 8, header_nal, &nal_size);
fail_if (ret != GST_H264_BIT_WRITER_OK);
- fail_if (nal_size < GST_ROUND_UP_8 (size) / 8);
+ fail_if (nal_size < size);
/* Parse it again */
res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
memset (header_nal, 0, sizeof (header_nal));
size = sizeof (header_data);
+ trail_bits = 0;
ret = gst_h264_bit_writer_slice_hdr (&slice_hdr, TRUE, GST_H264_NAL_SLICE,
- FALSE, header_data, &size);
+ FALSE, header_data, &size, &trail_bits);
fail_if (ret != GST_H264_BIT_WRITER_OK);
nal_size = sizeof (header_nal);
- ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
- header_data, GST_ROUND_UP_8 (size), header_nal, &nal_size);
+ ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, TRUE,
+ header_data, size * 8 + trail_bits, header_nal, &nal_size);
fail_if (ret != GST_H264_BIT_WRITER_OK);
- fail_if (nal_size < GST_ROUND_UP_8 (size) / 8);
+ fail_if (nal_size < size);
/* Parse it again */
res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
GArray *msg_array;
GArray *sei_parsed = NULL;
GstH264SEIMessage *sei_msg_parsed;
- gsize size;
- guint32 size_nal;
+ guint size;
+ guint size_nal;
guint8 sei_data[128] = { 0, };
guint8 sei_nal[128] = { 0, };
size_nal = sizeof (sei_nal);
ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
- sei_data, size, sei_nal, &size_nal);
+ sei_data, size * 8, sei_nal, &size_nal);
fail_if (ret != GST_H264_BIT_WRITER_OK);
/* Parse it again. */