mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-06 06:22:29 +00:00
libs: remove gstbitwriter
Since it is deployed in gstreamer-core, there is no need to use our custom version. https://bugzilla.gnome.org/show_bug.cgi?id=795848
This commit is contained in:
parent
2d95089a8d
commit
77527d67ab
14 changed files with 112 additions and 816 deletions
|
@ -1,3 +1,3 @@
|
|||
SUBDIRS = base vaapi
|
||||
SUBDIRS = vaapi
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
noinst_LTLIBRARIES = \
|
||||
libgstvaapi-baseutils.la \
|
||||
$(NULL)
|
||||
|
||||
source_c = \
|
||||
gstbitwriter.c \
|
||||
$(NULL)
|
||||
|
||||
source_h = \
|
||||
gstbitwriter.h \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_baseutils_cflags = \
|
||||
-DGST_USE_UNSTABLE_API \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
-I$(top_builddir)/gst-libs \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_baseutils_libs = \
|
||||
$(GST_BASE_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
nodist_libgstvaapi_baseutils_la_SOURCES = \
|
||||
$(source_c) \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_baseutils_la_CFLAGS = \
|
||||
$(libgstvaapi_baseutils_cflags) \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_baseutils_la_LIBADD = \
|
||||
$(libgstvaapi_baseutils_libs) \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_baseutils_la_LDFLAGS = \
|
||||
$(GST_ALL_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(source_c) \
|
||||
$(source_h) \
|
||||
$(NULL)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,278 +0,0 @@
|
|||
/*
|
||||
* gstbitwriter.c - bitstream writer
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define GST_BIT_WRITER_DISABLE_INLINES
|
||||
|
||||
#include "gstbitwriter.h"
|
||||
|
||||
/**
|
||||
* gst_bit_writer_init:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @reserved_bits: reserved bits to allocate data
|
||||
*
|
||||
* Initializes a #GstBitWriter instance and allocate @reserved_bits
|
||||
* data inside.
|
||||
*
|
||||
* Cleanup function: gst_bit_writer_clear
|
||||
*/
|
||||
void
|
||||
gst_bit_writer_init (GstBitWriter * bitwriter, guint32 reserved_bits)
|
||||
{
|
||||
bitwriter->bit_size = 0;
|
||||
bitwriter->data = NULL;
|
||||
bitwriter->bit_capacity = 0;
|
||||
bitwriter->auto_grow = TRUE;
|
||||
if (reserved_bits)
|
||||
_gst_bit_writer_check_space (bitwriter, reserved_bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_init_fill:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @data: allocated data
|
||||
* @bits: size of allocated @data in bits
|
||||
*
|
||||
* Initializes a #GstBitWriter instance with alocated @data and @bit outside.
|
||||
*
|
||||
* Cleanup function: gst_bit_writer_clear
|
||||
*/
|
||||
void
|
||||
gst_bit_writer_init_fill (GstBitWriter * bitwriter, guint8 * data, guint bits)
|
||||
{
|
||||
bitwriter->bit_size = 0;
|
||||
bitwriter->data = data;
|
||||
bitwriter->bit_capacity = bits;
|
||||
bitwriter->auto_grow = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_clear:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @free_data: flag to free #GstBitWriter allocated data
|
||||
*
|
||||
* Clear a #GstBitWriter instance and destroy allocated data inside
|
||||
* if @free_data is %TRUE.
|
||||
*/
|
||||
void
|
||||
gst_bit_writer_clear (GstBitWriter * bitwriter, gboolean free_data)
|
||||
{
|
||||
if (bitwriter->auto_grow && bitwriter->data && free_data)
|
||||
g_free (bitwriter->data);
|
||||
|
||||
bitwriter->data = NULL;
|
||||
bitwriter->bit_size = 0;
|
||||
bitwriter->bit_capacity = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_new:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @reserved_bits: reserved bits to allocate data
|
||||
*
|
||||
* Create a #GstBitWriter instance and allocate @reserved_bits data inside.
|
||||
*
|
||||
* Free-function: gst_bit_writer_free
|
||||
*
|
||||
* Returns: a new #GstBitWriter instance
|
||||
*/
|
||||
GstBitWriter *
|
||||
gst_bit_writer_new (guint32 reserved_bits)
|
||||
{
|
||||
GstBitWriter *ret = g_slice_new0 (GstBitWriter);
|
||||
|
||||
gst_bit_writer_init (ret, reserved_bits);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_new_fill:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @data: allocated data
|
||||
* @bits: size of allocated @data in bits
|
||||
*
|
||||
* Create a #GstBitWriter instance with allocated @data and @bit outside.
|
||||
*
|
||||
* Free-function: gst_bit_writer_free
|
||||
*
|
||||
* Returns: a new #GstBitWriter instance
|
||||
*/
|
||||
GstBitWriter *
|
||||
gst_bit_writer_new_fill (guint8 * data, guint bits)
|
||||
{
|
||||
GstBitWriter *ret = g_slice_new0 (GstBitWriter);
|
||||
|
||||
gst_bit_writer_init_fill (ret, data, bits);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_free:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @free_data: flag to free @data which is allocated inside
|
||||
*
|
||||
* Clear a #GstBitWriter instance and destroy allocated data inside if
|
||||
* @free_data is %TRUE
|
||||
*/
|
||||
void
|
||||
gst_bit_writer_free (GstBitWriter * writer, gboolean free_data)
|
||||
{
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
gst_bit_writer_clear (writer, free_data);
|
||||
|
||||
g_slice_free (GstBitWriter, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_get_size:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
*
|
||||
* Get size of written @data
|
||||
*
|
||||
* Returns: size of bits written in @data
|
||||
*/
|
||||
guint
|
||||
gst_bit_writer_get_size (GstBitWriter * bitwriter)
|
||||
{
|
||||
return _gst_bit_writer_get_size_inline (bitwriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_get_data:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
*
|
||||
* Get written @data pointer
|
||||
*
|
||||
* Returns: @data pointer
|
||||
*/
|
||||
guint8 *
|
||||
gst_bit_writer_get_data (GstBitWriter * bitwriter)
|
||||
{
|
||||
return _gst_bit_writer_get_data_inline (bitwriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_get_data:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @pos: new position of data end
|
||||
*
|
||||
* Set the new postion of data end which should be the new size of @data.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_writer_set_pos (GstBitWriter * bitwriter, guint pos)
|
||||
{
|
||||
return _gst_bit_writer_set_pos_inline (bitwriter, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_put_bits_uint8:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @value: value of #guint8 to write
|
||||
* @nbits: number of bits to write
|
||||
*
|
||||
* Write @nbits bits of @value to #GstBitWriter.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_writer_put_bits_uint16:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @value: value of #guint16 to write
|
||||
* @nbits: number of bits to write
|
||||
*
|
||||
* Write @nbits bits of @value to #GstBitWriter.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_writer_put_bits_uint32:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @value: value of #guint32 to write
|
||||
* @nbits: number of bits to write
|
||||
*
|
||||
* Write @nbits bits of @value to #GstBitWriter.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_writer_put_bits_uint64:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @value: value of #guint64 to write
|
||||
* @nbits: number of bits to write
|
||||
*
|
||||
* Write @nbits bits of @value to #GstBitWriter.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
|
||||
#define GST_BIT_WRITER_WRITE_BITS(bits) \
|
||||
gboolean \
|
||||
gst_bit_writer_put_bits_uint##bits (GstBitWriter *bitwriter, guint##bits value, guint nbits) \
|
||||
{ \
|
||||
return _gst_bit_writer_put_bits_uint##bits##_inline (bitwriter, value, nbits); \
|
||||
}
|
||||
|
||||
GST_BIT_WRITER_WRITE_BITS (8)
|
||||
GST_BIT_WRITER_WRITE_BITS (16)
|
||||
GST_BIT_WRITER_WRITE_BITS (32)
|
||||
GST_BIT_WRITER_WRITE_BITS (64)
|
||||
|
||||
#undef GST_BIT_WRITER_WRITE_BITS
|
||||
|
||||
/**
|
||||
* gst_bit_writer_put_bytes:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @data: pointer of data to write
|
||||
* @nbytes: number of bytes to write
|
||||
*
|
||||
* Write @nbytes bytes of @data to #GstBitWriter.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_writer_put_bytes (GstBitWriter * bitwriter,
|
||||
const guint8 * data, guint nbytes)
|
||||
{
|
||||
return _gst_bit_writer_put_bytes_inline (bitwriter, data, nbytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_writer_align_bytes:
|
||||
* @bitwriter: a #GstBitWriter instance
|
||||
* @trailing_bit: trailing bits of last byte, 0 or 1
|
||||
*
|
||||
* Write trailing bit to align last byte of @data. @trailing_bit can
|
||||
* only be 1 or 0.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_writer_align_bytes (GstBitWriter * bitwriter, guint8 trailing_bit)
|
||||
{
|
||||
return _gst_bit_writer_align_bytes_inline (bitwriter, trailing_bit);
|
||||
}
|
|
@ -1,361 +0,0 @@
|
|||
/*
|
||||
* gstbitwriter.h - bitstream writer
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_BIT_WRITER_H
|
||||
#define GST_BIT_WRITER_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <string.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_BIT_WRITER_DATA(writer) ((writer)->data)
|
||||
#define GST_BIT_WRITER_BIT_SIZE(writer) ((writer)->bit_size)
|
||||
#define GST_BIT_WRITER(writer) ((GstBitWriter *) (writer))
|
||||
|
||||
typedef struct _GstBitWriter GstBitWriter;
|
||||
|
||||
/**
|
||||
* GstBitWriter:
|
||||
* @data: Allocated @data for bit writer to write
|
||||
* @bit_size: Size of written @data in bits
|
||||
*
|
||||
* Private:
|
||||
* @bit_capacity: Capacity of the allocated @data
|
||||
* @auto_grow: @data space can auto grow
|
||||
*
|
||||
* A bit writer instance.
|
||||
*/
|
||||
struct _GstBitWriter
|
||||
{
|
||||
guint8 *data;
|
||||
guint bit_size;
|
||||
|
||||
/*< private >*/
|
||||
guint bit_capacity;
|
||||
gboolean auto_grow;
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GstBitWriter *
|
||||
gst_bit_writer_new (guint32 reserved_bits) G_GNUC_MALLOC;
|
||||
|
||||
GstBitWriter *
|
||||
gst_bit_writer_new_fill (guint8 * data, guint bits) G_GNUC_MALLOC;
|
||||
|
||||
void
|
||||
gst_bit_writer_free (GstBitWriter * writer, gboolean free_data);
|
||||
|
||||
void
|
||||
gst_bit_writer_init (GstBitWriter * bitwriter, guint32 reserved_bits);
|
||||
|
||||
void
|
||||
gst_bit_writer_init_fill (GstBitWriter * bitwriter, guint8 * data, guint bits);
|
||||
|
||||
void
|
||||
gst_bit_writer_clear (GstBitWriter * bitwriter, gboolean free_data);
|
||||
|
||||
guint
|
||||
gst_bit_writer_get_size (GstBitWriter * bitwriter);
|
||||
|
||||
guint8 *
|
||||
gst_bit_writer_get_data (GstBitWriter * bitwriter);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_set_pos (GstBitWriter * bitwriter, guint pos);
|
||||
|
||||
guint
|
||||
gst_bit_writer_get_space (GstBitWriter * bitwriter);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_put_bits_uint8 (GstBitWriter * bitwriter,
|
||||
guint8 value, guint nbits);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_put_bits_uint16 (GstBitWriter * bitwriter,
|
||||
guint16 value, guint nbits);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_put_bits_uint32 (GstBitWriter * bitwriter,
|
||||
guint32 value, guint nbits);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_put_bits_uint64 (GstBitWriter * bitwriter,
|
||||
guint64 value, guint nbits);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_put_bytes (GstBitWriter * bitwriter, const guint8 * data,
|
||||
guint nbytes);
|
||||
|
||||
gboolean
|
||||
gst_bit_writer_align_bytes (GstBitWriter * bitwriter, guint8 trailing_bit);
|
||||
|
||||
static const guint8 _gst_bit_writer_bit_filling_mask[9] = {
|
||||
0x00, 0x01, 0x03, 0x07,
|
||||
0x0F, 0x1F, 0x3F, 0x7F,
|
||||
0xFF
|
||||
};
|
||||
|
||||
/* Aligned to 256 bytes */
|
||||
#define __GST_BITS_WRITER_ALIGNMENT_MASK 2047
|
||||
#define __GST_BITS_WRITER_ALIGNED(bitsize) \
|
||||
(((bitsize) + __GST_BITS_WRITER_ALIGNMENT_MASK)&(~__GST_BITS_WRITER_ALIGNMENT_MASK))
|
||||
|
||||
static inline gboolean
|
||||
_gst_bit_writer_check_space (GstBitWriter * bitwriter, guint32 bits)
|
||||
{
|
||||
guint32 new_bit_size = bits + bitwriter->bit_size;
|
||||
guint32 clear_pos;
|
||||
|
||||
g_assert (bitwriter->bit_size <= bitwriter->bit_capacity);
|
||||
if (new_bit_size <= bitwriter->bit_capacity)
|
||||
return TRUE;
|
||||
|
||||
if (!bitwriter->auto_grow)
|
||||
return FALSE;
|
||||
|
||||
/* auto grow space */
|
||||
new_bit_size = __GST_BITS_WRITER_ALIGNED (new_bit_size);
|
||||
g_assert (new_bit_size
|
||||
&& ((new_bit_size & __GST_BITS_WRITER_ALIGNMENT_MASK) == 0));
|
||||
clear_pos = ((bitwriter->bit_size + 7) >> 3);
|
||||
bitwriter->data = g_realloc (bitwriter->data, (new_bit_size >> 3));
|
||||
memset (bitwriter->data + clear_pos, 0, (new_bit_size >> 3) - clear_pos);
|
||||
bitwriter->bit_capacity = new_bit_size;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#undef __GST_BITS_WRITER_ALIGNMENT_MASK
|
||||
#undef __GST_BITS_WRITER_ALIGNED
|
||||
|
||||
#define __GST_BIT_WRITER_WRITE_BITS_UNCHECKED(bits) \
|
||||
static inline void \
|
||||
gst_bit_writer_put_bits_uint##bits##_unchecked( \
|
||||
GstBitWriter *bitwriter, \
|
||||
guint##bits value, \
|
||||
guint nbits \
|
||||
) \
|
||||
{ \
|
||||
guint byte_pos, bit_offset; \
|
||||
guint8 *cur_byte; \
|
||||
guint fill_bits; \
|
||||
\
|
||||
byte_pos = (bitwriter->bit_size >> 3); \
|
||||
bit_offset = (bitwriter->bit_size & 0x07); \
|
||||
cur_byte = bitwriter->data + byte_pos; \
|
||||
g_assert (nbits <= bits); \
|
||||
g_assert( bit_offset < 8 && \
|
||||
bitwriter->bit_size <= bitwriter->bit_capacity); \
|
||||
\
|
||||
while (nbits) { \
|
||||
fill_bits = ((8 - bit_offset) < nbits ? (8 - bit_offset) : nbits); \
|
||||
nbits -= fill_bits; \
|
||||
bitwriter->bit_size += fill_bits; \
|
||||
\
|
||||
*cur_byte |= (((value >> nbits) & _gst_bit_writer_bit_filling_mask[fill_bits]) \
|
||||
<< (8 - bit_offset - fill_bits)); \
|
||||
++cur_byte; \
|
||||
bit_offset = 0; \
|
||||
} \
|
||||
g_assert(cur_byte <= \
|
||||
(bitwriter->data + (bitwriter->bit_capacity >> 3))); \
|
||||
}
|
||||
|
||||
__GST_BIT_WRITER_WRITE_BITS_UNCHECKED (8)
|
||||
__GST_BIT_WRITER_WRITE_BITS_UNCHECKED (16)
|
||||
__GST_BIT_WRITER_WRITE_BITS_UNCHECKED (32)
|
||||
__GST_BIT_WRITER_WRITE_BITS_UNCHECKED (64)
|
||||
#undef __GST_BIT_WRITER_WRITE_BITS_UNCHECKED
|
||||
|
||||
static inline guint
|
||||
gst_bit_writer_get_size_unchecked (GstBitWriter * bitwriter)
|
||||
{
|
||||
return GST_BIT_WRITER_BIT_SIZE (bitwriter);
|
||||
}
|
||||
|
||||
static inline guint8 *
|
||||
gst_bit_writer_get_data_unchecked (GstBitWriter * bitwriter)
|
||||
{
|
||||
return GST_BIT_WRITER_DATA (bitwriter);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gst_bit_writer_set_pos_unchecked (GstBitWriter * bitwriter, guint pos)
|
||||
{
|
||||
GST_BIT_WRITER_BIT_SIZE (bitwriter) = pos;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
gst_bit_writer_get_space_unchecked (GstBitWriter * bitwriter)
|
||||
{
|
||||
return bitwriter->bit_capacity - bitwriter->bit_size;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_bit_writer_put_bytes_unchecked (GstBitWriter * bitwriter,
|
||||
const guint8 * data, guint nbytes)
|
||||
{
|
||||
if ((bitwriter->bit_size & 0x07) == 0) {
|
||||
memcpy (&bitwriter->data[bitwriter->bit_size >> 3], data, nbytes);
|
||||
bitwriter->bit_size += (nbytes << 3);
|
||||
} else {
|
||||
g_assert (0);
|
||||
while (nbytes) {
|
||||
gst_bit_writer_put_bits_uint8_unchecked (bitwriter, *data, 8);
|
||||
--nbytes;
|
||||
++data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_bit_writer_align_bytes_unchecked (GstBitWriter * bitwriter,
|
||||
guint8 trailing_bit)
|
||||
{
|
||||
guint32 bit_offset, bit_left;
|
||||
guint8 value = 0;
|
||||
|
||||
bit_offset = (bitwriter->bit_size & 0x07);
|
||||
if (!bit_offset)
|
||||
return;
|
||||
|
||||
bit_left = 8 - bit_offset;
|
||||
if (trailing_bit)
|
||||
value = _gst_bit_writer_bit_filling_mask[bit_left];
|
||||
return gst_bit_writer_put_bits_uint8_unchecked (bitwriter, value, bit_left);
|
||||
}
|
||||
|
||||
#define __GST_BIT_WRITER_WRITE_BITS_INLINE(bits) \
|
||||
static inline gboolean \
|
||||
_gst_bit_writer_put_bits_uint##bits##_inline( \
|
||||
GstBitWriter *bitwriter, \
|
||||
guint##bits value, \
|
||||
guint nbits \
|
||||
) \
|
||||
{ \
|
||||
g_return_val_if_fail(bitwriter != NULL, FALSE); \
|
||||
g_return_val_if_fail(nbits != 0, FALSE); \
|
||||
g_return_val_if_fail(nbits <= bits, FALSE); \
|
||||
\
|
||||
if (!_gst_bit_writer_check_space(bitwriter, nbits)) \
|
||||
return FALSE; \
|
||||
gst_bit_writer_put_bits_uint##bits##_unchecked(bitwriter, value, nbits); \
|
||||
return TRUE; \
|
||||
}
|
||||
|
||||
__GST_BIT_WRITER_WRITE_BITS_INLINE (8)
|
||||
__GST_BIT_WRITER_WRITE_BITS_INLINE (16)
|
||||
__GST_BIT_WRITER_WRITE_BITS_INLINE (32)
|
||||
__GST_BIT_WRITER_WRITE_BITS_INLINE (64)
|
||||
#undef __GST_BIT_WRITER_WRITE_BITS_INLINE
|
||||
|
||||
static inline guint
|
||||
_gst_bit_writer_get_size_inline (GstBitWriter * bitwriter)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, 0);
|
||||
|
||||
return gst_bit_writer_get_size_unchecked (bitwriter);
|
||||
}
|
||||
|
||||
static inline guint8 *
|
||||
_gst_bit_writer_get_data_inline (GstBitWriter * bitwriter)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, NULL);
|
||||
|
||||
return gst_bit_writer_get_data_unchecked (bitwriter);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gst_bit_writer_set_pos_inline (GstBitWriter * bitwriter, guint pos)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, FALSE);
|
||||
g_return_val_if_fail (pos <= bitwriter->bit_capacity, FALSE);
|
||||
|
||||
return gst_bit_writer_set_pos_unchecked (bitwriter, pos);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
_gst_bit_writer_get_space_inline (GstBitWriter * bitwriter)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, 0);
|
||||
g_return_val_if_fail (bitwriter->bit_size < bitwriter->bit_capacity, 0);
|
||||
|
||||
return gst_bit_writer_get_space_unchecked (bitwriter);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gst_bit_writer_put_bytes_inline (GstBitWriter * bitwriter,
|
||||
const guint8 * data, guint nbytes)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (nbytes, FALSE);
|
||||
|
||||
if (!_gst_bit_writer_check_space (bitwriter, nbytes * 8))
|
||||
return FALSE;
|
||||
|
||||
gst_bit_writer_put_bytes_unchecked (bitwriter, data, nbytes);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gst_bit_writer_align_bytes_inline (GstBitWriter * bitwriter,
|
||||
guint8 trailing_bit)
|
||||
{
|
||||
g_return_val_if_fail (bitwriter != NULL, FALSE);
|
||||
g_return_val_if_fail ((trailing_bit == 0 || trailing_bit == 1), FALSE);
|
||||
g_return_val_if_fail (((bitwriter->bit_size + 7) & (~7)) <=
|
||||
bitwriter->bit_capacity, FALSE);
|
||||
|
||||
gst_bit_writer_align_bytes_unchecked (bitwriter, trailing_bit);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef GST_BIT_WRITER_DISABLE_INLINES
|
||||
#define gst_bit_writer_get_size(bitwriter) \
|
||||
_gst_bit_writer_get_size_inline(bitwriter)
|
||||
#define gst_bit_writer_get_data(bitwriter) \
|
||||
_gst_bit_writer_get_data_inline(bitwriter)
|
||||
#define gst_bit_writer_set_pos(bitwriter, pos) \
|
||||
G_LIKELY (_gst_bit_writer_set_pos_inline (bitwriter, pos))
|
||||
#define gst_bit_writer_get_space(bitwriter) \
|
||||
_gst_bit_writer_get_space_inline(bitwriter)
|
||||
|
||||
#define gst_bit_writer_put_bits_uint8(bitwriter, value, nbits) \
|
||||
G_LIKELY (_gst_bit_writer_put_bits_uint8_inline (bitwriter, value, nbits))
|
||||
#define gst_bit_writer_put_bits_uint16(bitwriter, value, nbits) \
|
||||
G_LIKELY (_gst_bit_writer_put_bits_uint16_inline (bitwriter, value, nbits))
|
||||
#define gst_bit_writer_put_bits_uint32(bitwriter, value, nbits) \
|
||||
G_LIKELY (_gst_bit_writer_put_bits_uint32_inline (bitwriter, value, nbits))
|
||||
#define gst_bit_writer_put_bits_uint64(bitwriter, value, nbits) \
|
||||
G_LIKELY (_gst_bit_writer_put_bits_uint64_inline (bitwriter, value, nbits))
|
||||
|
||||
#define gst_bit_writer_put_bytes(bitwriter, data, nbytes) \
|
||||
G_LIKELY (_gst_bit_writer_put_bytes_inline (bitwriter, data, nbytes))
|
||||
|
||||
#define gst_bit_writer_align_bytes(bitwriter, trailing_bit) \
|
||||
G_LIKELY (_gst_bit_writer_align_bytes_inline(bitwriter, trailing_bit))
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_BIT_WRITER_H */
|
|
@ -1,20 +0,0 @@
|
|||
gstvaapi_baseutils_sources = [
|
||||
'gstbitwriter.c',
|
||||
]
|
||||
|
||||
gstvaapi_baseutils_headers = [
|
||||
'gstbitwriter.h',
|
||||
]
|
||||
|
||||
gstvaapi_baseutils_deps = [gstbase_dep]
|
||||
|
||||
gstvaapi_baseutils = static_library('gstvaapi-baseutils-@0@'.format(api_version),
|
||||
gstvaapi_baseutils_sources,
|
||||
c_args : gstreamer_vaapi_args,
|
||||
include_directories: [configinc, libsinc],
|
||||
dependencies : gstvaapi_baseutils_deps,
|
||||
)
|
||||
|
||||
gstvaapi_baseutils_dep = declare_dependency(link_with: gstvaapi_baseutils,
|
||||
include_directories : [libsinc],
|
||||
dependencies : gstvaapi_baseutils_deps)
|
|
@ -1,2 +1 @@
|
|||
subdir('base')
|
||||
subdir('vaapi')
|
||||
|
|
|
@ -40,7 +40,6 @@ libgstvaapi_libs = \
|
|||
$(GST_VIDEO_LIBS) \
|
||||
$(GST_CODEC_PARSERS_LIBS) \
|
||||
$(LIBVA_LIBS) \
|
||||
$(top_builddir)/gst-libs/gst/base/libgstvaapi-baseutils.la \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_source_c = \
|
||||
|
|
|
@ -1432,7 +1432,7 @@ add_packed_au_delimiter (GstVaapiEncoderH264 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_NONE,
|
||||
GST_H264_NAL_AU_DELIMITER);
|
||||
|
@ -1456,14 +1456,14 @@ add_packed_au_delimiter (GstVaapiEncoderH264 * encoder,
|
|||
gst_vaapi_enc_picture_add_packed_header (picture, packed_aud);
|
||||
gst_vaapi_codec_object_replace (&packed_aud, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write AU Delimiter NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1486,7 +1486,7 @@ add_packed_sequence_header (GstVaapiEncoderH264 * encoder,
|
|||
|
||||
fill_hrd_params (encoder, &hrd_params);
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SPS);
|
||||
|
||||
|
@ -1517,14 +1517,14 @@ add_packed_sequence_header (GstVaapiEncoderH264 * encoder,
|
|||
|
||||
/* store sps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1544,7 +1544,7 @@ add_packed_sequence_header_mvc (GstVaapiEncoderH264 * encoder,
|
|||
fill_hrd_params (encoder, &hrd_params);
|
||||
|
||||
/* non-base layer, pack one subset sps */
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SUBSET_SPS);
|
||||
|
||||
|
@ -1569,14 +1569,14 @@ add_packed_sequence_header_mvc (GstVaapiEncoderH264 * encoder,
|
|||
|
||||
/* store subset sps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1594,7 +1594,7 @@ add_packed_picture_header (GstVaapiEncoderH264 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_PPS);
|
||||
bs_write_pps (&bs, pic_param, encoder->profile);
|
||||
|
@ -1616,14 +1616,14 @@ add_packed_picture_header (GstVaapiEncoderH264 * encoder,
|
|||
|
||||
/* store pps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write PPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1640,9 +1640,9 @@ add_packed_sei_header (GstVaapiEncoderH264 * encoder,
|
|||
guint8 *data, *buf_period_payload = NULL, *pic_timing_payload = NULL;
|
||||
gboolean need_buf_period, need_pic_timing;
|
||||
|
||||
gst_bit_writer_init (&bs_buf_period, 128 * 8);
|
||||
gst_bit_writer_init (&bs_pic_timing, 128 * 8);
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs_buf_period, 128, FALSE);
|
||||
gst_bit_writer_init_with_size (&bs_pic_timing, 128, FALSE);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
|
||||
need_buf_period = GST_VAAPI_H264_SEI_BUF_PERIOD & payloadtype;
|
||||
need_pic_timing = GST_VAAPI_H264_SEI_PIC_TIMING & payloadtype;
|
||||
|
@ -1705,18 +1705,18 @@ add_packed_sei_header (GstVaapiEncoderH264 * encoder,
|
|||
gst_vaapi_enc_picture_add_packed_header (picture, packed_sei);
|
||||
gst_vaapi_codec_object_replace (&packed_sei, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs_buf_period, TRUE);
|
||||
gst_bit_writer_clear (&bs_pic_timing, TRUE);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs_buf_period);
|
||||
gst_bit_writer_reset (&bs_pic_timing);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SEI NAL unit");
|
||||
gst_bit_writer_clear (&bs_buf_period, TRUE);
|
||||
gst_bit_writer_clear (&bs_pic_timing, TRUE);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs_buf_period);
|
||||
gst_bit_writer_reset (&bs_pic_timing);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1768,7 +1768,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264 * encoder,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1794,7 +1794,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264 * encoder,
|
|||
gst_vaapi_enc_slice_add_packed_header (slice, packed_prefix_nal);
|
||||
gst_vaapi_codec_object_replace (&packed_prefix_nal, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -1802,7 +1802,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264 * encoder,
|
|||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Prefix NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1821,7 +1821,7 @@ add_packed_slice_header (GstVaapiEncoderH264 * encoder,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1850,14 +1850,14 @@ add_packed_slice_header (GstVaapiEncoderH264 * encoder,
|
|||
gst_vaapi_enc_slice_add_packed_header (slice, packed_slice);
|
||||
gst_vaapi_codec_object_replace (&packed_slice, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Slice NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -2944,7 +2944,8 @@ gst_vaapi_encoder_h264_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
level_idc = sps_info.data[3];
|
||||
|
||||
/* Header */
|
||||
gst_bit_writer_init (&bs, (sps_info.size + pps_info.size + 64) * 8);
|
||||
gst_bit_writer_init_with_size (&bs, (sps_info.size + pps_info.size + 64),
|
||||
FALSE);
|
||||
WRITE_UINT32 (&bs, configuration_version, 8);
|
||||
WRITE_UINT32 (&bs, profile_idc, 8);
|
||||
WRITE_UINT32 (&bs, profile_comp, 8);
|
||||
|
@ -2969,13 +2970,15 @@ gst_vaapi_encoder_h264_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
|
||||
buffer = gst_buffer_new_wrapped (GST_BIT_WRITER_DATA (&bs),
|
||||
GST_BIT_WRITER_BIT_SIZE (&bs) / 8);
|
||||
buffer = gst_bit_writer_reset_and_get_buffer (&bs);
|
||||
if (!buffer)
|
||||
goto error_alloc_buffer;
|
||||
if (gst_buffer_n_memory (buffer) == 0) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto error_alloc_buffer;
|
||||
}
|
||||
*out_buffer_ptr = buffer;
|
||||
|
||||
gst_bit_writer_clear (&bs, FALSE);
|
||||
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -2984,7 +2987,7 @@ bs_error:
|
|||
GST_ERROR ("failed to write codec-data");
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
nal_to_byte_stream_error:
|
||||
|
@ -2992,7 +2995,7 @@ nal_to_byte_stream_error:
|
|||
GST_ERROR ("failed to write nal unit");
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
error_map_sps_buffer:
|
||||
|
@ -3009,7 +3012,7 @@ error_map_pps_buffer:
|
|||
error_alloc_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to allocate codec-data buffer");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1405,7 +1405,7 @@ add_packed_sequence_header (GstVaapiEncoderH264Fei * encoder,
|
|||
|
||||
fill_hrd_params (encoder, &hrd_params);
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SPS);
|
||||
|
||||
|
@ -1436,14 +1436,14 @@ add_packed_sequence_header (GstVaapiEncoderH264Fei * encoder,
|
|||
|
||||
/* store sps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1463,7 +1463,7 @@ add_packed_sequence_header_mvc (GstVaapiEncoderH264Fei * encoder,
|
|||
fill_hrd_params (encoder, &hrd_params);
|
||||
|
||||
/* non-base layer, pack one subset sps */
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SUBSET_SPS);
|
||||
|
||||
|
@ -1488,14 +1488,14 @@ add_packed_sequence_header_mvc (GstVaapiEncoderH264Fei * encoder,
|
|||
|
||||
/* store subset sps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1513,7 +1513,7 @@ add_packed_picture_header (GstVaapiEncoderH264Fei * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_PPS);
|
||||
bs_write_pps (&bs, pic_param, encoder->profile);
|
||||
|
@ -1535,14 +1535,14 @@ add_packed_picture_header (GstVaapiEncoderH264Fei * encoder,
|
|||
|
||||
/* store pps data */
|
||||
_check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write PPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1559,9 +1559,9 @@ add_packed_sei_header (GstVaapiEncoderH264Fei * encoder,
|
|||
guint8 *data, *buf_period_payload = NULL, *pic_timing_payload = NULL;
|
||||
gboolean need_buf_period, need_pic_timing;
|
||||
|
||||
gst_bit_writer_init (&bs_buf_period, 128 * 8);
|
||||
gst_bit_writer_init (&bs_pic_timing, 128 * 8);
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs_buf_period, 128, FALSE);
|
||||
gst_bit_writer_init_with_size (&bs_pic_timing, 128, FALSE);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
|
||||
need_buf_period = GST_VAAPI_H264_SEI_BUF_PERIOD & payloadtype;
|
||||
need_pic_timing = GST_VAAPI_H264_SEI_PIC_TIMING & payloadtype;
|
||||
|
@ -1624,18 +1624,18 @@ add_packed_sei_header (GstVaapiEncoderH264Fei * encoder,
|
|||
gst_vaapi_enc_picture_add_packed_header (picture, packed_sei);
|
||||
gst_vaapi_codec_object_replace ((GstVaapiCodecObject **) & packed_sei, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs_buf_period, TRUE);
|
||||
gst_bit_writer_clear (&bs_pic_timing, TRUE);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs_buf_period);
|
||||
gst_bit_writer_reset (&bs_pic_timing);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SEI NAL unit");
|
||||
gst_bit_writer_clear (&bs_buf_period, TRUE);
|
||||
gst_bit_writer_clear (&bs_pic_timing, TRUE);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs_buf_period);
|
||||
gst_bit_writer_reset (&bs_pic_timing);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1679,7 +1679,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264Fei * encoder,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1706,7 +1706,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264Fei * encoder,
|
|||
gst_vaapi_codec_object_replace ((GstVaapiCodecObject **) & packed_prefix_nal,
|
||||
NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -1714,7 +1714,7 @@ add_packed_prefix_nal_header (GstVaapiEncoderH264Fei * encoder,
|
|||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Prefix NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1733,7 +1733,7 @@ add_packed_slice_header (GstVaapiEncoderH264Fei * encoder,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1763,14 +1763,14 @@ add_packed_slice_header (GstVaapiEncoderH264Fei * encoder,
|
|||
gst_vaapi_codec_object_replace ((GstVaapiCodecObject **) & packed_slice,
|
||||
NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Slice NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -2911,7 +2911,8 @@ gst_vaapi_encoder_h264_fei_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
level_idc = sps_info.data[3];
|
||||
|
||||
/* Header */
|
||||
gst_bit_writer_init (&bs, (sps_info.size + pps_info.size + 64) * 8);
|
||||
gst_bit_writer_init_with_size (&bs, (sps_info.size + pps_info.size + 64),
|
||||
FALSE);
|
||||
WRITE_UINT32 (&bs, configuration_version, 8);
|
||||
WRITE_UINT32 (&bs, profile_idc, 8);
|
||||
WRITE_UINT32 (&bs, profile_comp, 8);
|
||||
|
@ -2934,13 +2935,12 @@ gst_vaapi_encoder_h264_fei_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
|
||||
buffer = gst_buffer_new_wrapped (GST_BIT_WRITER_DATA (&bs),
|
||||
GST_BIT_WRITER_BIT_SIZE (&bs) / 8);
|
||||
buffer = gst_bit_writer_reset_and_get_buffer (&bs);
|
||||
if (!buffer)
|
||||
goto error_alloc_buffer;
|
||||
*out_buffer_ptr = buffer;
|
||||
|
||||
gst_bit_writer_clear (&bs, FALSE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -2949,7 +2949,7 @@ bs_error:
|
|||
GST_ERROR ("failed to write codec-data");
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
error_map_sps_buffer:
|
||||
|
@ -2966,7 +2966,7 @@ error_map_pps_buffer:
|
|||
error_alloc_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to allocate codec-data buffer");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1166,7 +1166,7 @@ add_packed_vps_header (GstVaapiEncoderH265 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H265_NAL_VPS);
|
||||
|
||||
|
@ -1190,14 +1190,14 @@ add_packed_vps_header (GstVaapiEncoderH265 * encoder,
|
|||
|
||||
/* store vps data */
|
||||
_check_vps_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write VPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1220,7 +1220,7 @@ add_packed_sequence_header (GstVaapiEncoderH265 * encoder,
|
|||
|
||||
fill_hrd_params (encoder, &hrd_params);
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H265_NAL_SPS);
|
||||
|
||||
|
@ -1244,14 +1244,14 @@ add_packed_sequence_header (GstVaapiEncoderH265 * encoder,
|
|||
|
||||
/* store sps data */
|
||||
_check_vps_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1269,7 +1269,7 @@ add_packed_picture_header (GstVaapiEncoderH265 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H265_NAL_PPS);
|
||||
bs_write_pps (&bs, pic_param);
|
||||
|
@ -1291,14 +1291,14 @@ add_packed_picture_header (GstVaapiEncoderH265 * encoder,
|
|||
|
||||
/* store pps data */
|
||||
_check_vps_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write PPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ add_packed_slice_header (GstVaapiEncoderH265 * encoder,
|
|||
guint8 *data;
|
||||
guint8 nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_unit_type (picture, &nal_unit_type))
|
||||
|
@ -1362,14 +1362,14 @@ add_packed_slice_header (GstVaapiEncoderH265 * encoder,
|
|||
gst_vaapi_enc_slice_add_packed_header (slice, packed_slice);
|
||||
gst_vaapi_codec_object_replace (&packed_slice, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Slice NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -2173,8 +2173,8 @@ gst_vaapi_encoder_h265_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
goto error_map_pps_buffer;
|
||||
|
||||
/* Header */
|
||||
gst_bit_writer_init (&bs,
|
||||
(vps_info.size + sps_info.size + pps_info.size + 64) * 8);
|
||||
gst_bit_writer_init_with_size (&bs,
|
||||
(vps_info.size + sps_info.size + pps_info.size + 64), FALSE);
|
||||
WRITE_UINT32 (&bs, configuration_version, 8);
|
||||
WRITE_UINT32 (&bs, sps_info.data[4], 8); /* profile_space | tier_flag | profile_idc */
|
||||
WRITE_UINT32 (&bs, sps_info.data[5], 32); /* profile_compatibility_flag [0-31] */
|
||||
|
@ -2235,13 +2235,15 @@ gst_vaapi_encoder_h265_get_codec_data (GstVaapiEncoder * base_encoder,
|
|||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->vps_data, &vps_info);
|
||||
|
||||
buffer = gst_buffer_new_wrapped (GST_BIT_WRITER_DATA (&bs),
|
||||
GST_BIT_WRITER_BIT_SIZE (&bs) / 8);
|
||||
buffer = gst_bit_writer_reset_and_get_buffer (&bs);
|
||||
if (!buffer)
|
||||
goto error_alloc_buffer;
|
||||
if (gst_buffer_n_memory (buffer) == 0) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto error_alloc_buffer;
|
||||
}
|
||||
*out_buffer_ptr = buffer;
|
||||
|
||||
gst_bit_writer_clear (&bs, FALSE);
|
||||
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -2251,7 +2253,7 @@ bs_error:
|
|||
gst_buffer_unmap (encoder->vps_data, &vps_info);
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
nal_to_byte_stream_error:
|
||||
|
@ -2260,7 +2262,7 @@ nal_to_byte_stream_error:
|
|||
gst_buffer_unmap (encoder->vps_data, &vps_info);
|
||||
gst_buffer_unmap (encoder->sps_data, &sps_info);
|
||||
gst_buffer_unmap (encoder->pps_data, &pps_info);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
error_map_vps_buffer:
|
||||
|
@ -2282,7 +2284,7 @@ error_map_pps_buffer:
|
|||
error_alloc_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to allocate codec-data buffer");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ add_packed_header (GstVaapiEncoderJpeg * encoder, GstVaapiEncPicture * picture)
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
bs_write_jpeg_header (&bs, encoder, picture);
|
||||
data_bit_size = GST_BIT_WRITER_BIT_SIZE (&bs);
|
||||
data = GST_BIT_WRITER_DATA (&bs);
|
||||
|
@ -629,7 +629,7 @@ add_packed_header (GstVaapiEncoderJpeg * encoder, GstVaapiEncPicture * picture)
|
|||
gst_vaapi_enc_picture_add_packed_header (picture, packed_raw_data_hdr);
|
||||
gst_vaapi_codec_object_replace (&packed_raw_data_hdr, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ set_sequence_packed_header (GstVaapiEncoderMpeg2 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&writer, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&writer, 128, FALSE);
|
||||
if (encoder->new_gop)
|
||||
gst_bit_writer_write_sps (&writer, seq_param);
|
||||
g_assert (GST_BIT_WRITER_BIT_SIZE (&writer) % 8 == 0);
|
||||
|
@ -365,7 +365,7 @@ set_sequence_packed_header (GstVaapiEncoderMpeg2 * encoder,
|
|||
|
||||
gst_vaapi_enc_picture_add_packed_header (picture, packed_seq);
|
||||
gst_vaapi_codec_object_replace (&packed_seq, NULL);
|
||||
gst_bit_writer_clear (&writer, TRUE);
|
||||
gst_bit_writer_reset (&writer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ set_picture_packed_header (GstVaapiEncoderMpeg2 * encoder,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&writer, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&writer, 128, FALSE);
|
||||
gst_bit_writer_write_pps (&writer, pic_param);
|
||||
g_assert (GST_BIT_WRITER_BIT_SIZE (&writer) % 8 == 0);
|
||||
data_bit_size = GST_BIT_WRITER_BIT_SIZE (&writer);
|
||||
|
@ -398,7 +398,7 @@ set_picture_packed_header (GstVaapiEncoderMpeg2 * encoder,
|
|||
|
||||
gst_vaapi_enc_picture_add_packed_header (picture, packed_pic);
|
||||
gst_vaapi_codec_object_replace (&packed_pic, NULL);
|
||||
gst_bit_writer_clear (&writer, TRUE);
|
||||
gst_bit_writer_reset (&writer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -909,7 +909,7 @@ add_packed_sequence_header (GstVaapiFEIPakH264 * feipak,
|
|||
guint8 *data;
|
||||
|
||||
fill_hrd_params (feipak, &hrd_params);
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SPS);
|
||||
/* Set High profile for encoding the MVC base view. Otherwise, some
|
||||
|
@ -939,14 +939,14 @@ add_packed_sequence_header (GstVaapiFEIPakH264 * feipak,
|
|||
|
||||
/* store sps data */
|
||||
_check_sps_pps_status (feipak, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ add_packed_sequence_header_mvc (GstVaapiFEIPakH264 * feipak,
|
|||
fill_hrd_params (feipak, &hrd_params);
|
||||
|
||||
/* non-base layer, pack one subset sps */
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_SUBSET_SPS);
|
||||
|
||||
|
@ -992,14 +992,14 @@ add_packed_sequence_header_mvc (GstVaapiFEIPakH264 * feipak,
|
|||
|
||||
/* store subset sps data */
|
||||
_check_sps_pps_status (feipak, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write SPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ add_packed_picture_header (GstVaapiFEIPakH264 * feipak,
|
|||
guint32 data_bit_size;
|
||||
guint8 *data;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
bs_write_nal_header (&bs, GST_H264_NAL_REF_IDC_HIGH, GST_H264_NAL_PPS);
|
||||
bs_write_pps (&bs, pic_param, feipak->profile);
|
||||
|
@ -1040,14 +1040,14 @@ add_packed_picture_header (GstVaapiFEIPakH264 * feipak,
|
|||
|
||||
/* store pps data */
|
||||
_check_sps_pps_status (feipak, data + 4, data_bit_size / 8 - 4);
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write PPS NAL unit");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ add_packed_prefix_nal_header (GstVaapiFEIPakH264 * feipak,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1117,7 +1117,7 @@ add_packed_prefix_nal_header (GstVaapiFEIPakH264 * feipak,
|
|||
gst_vaapi_enc_slice_add_packed_header (slice, packed_prefix_nal);
|
||||
gst_vaapi_codec_object_replace (&packed_prefix_nal, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ add_packed_prefix_nal_header (GstVaapiFEIPakH264 * feipak,
|
|||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Prefix NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ add_packed_slice_header (GstVaapiFEIPakH264 * feipak,
|
|||
guint8 *data;
|
||||
guint8 nal_ref_idc, nal_unit_type;
|
||||
|
||||
gst_bit_writer_init (&bs, 128 * 8);
|
||||
gst_bit_writer_init_with_size (&bs, 128, FALSE);
|
||||
WRITE_UINT32 (&bs, 0x00000001, 32); /* start code */
|
||||
|
||||
if (!get_nal_hdr_attributes (picture, &nal_ref_idc, &nal_unit_type))
|
||||
|
@ -1174,14 +1174,14 @@ add_packed_slice_header (GstVaapiFEIPakH264 * feipak,
|
|||
gst_vaapi_enc_slice_add_packed_header (slice, packed_slice);
|
||||
gst_vaapi_codec_object_replace (&packed_slice, NULL);
|
||||
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
bs_error:
|
||||
{
|
||||
GST_WARNING ("failed to write Slice NAL unit header");
|
||||
gst_bit_writer_clear (&bs, TRUE);
|
||||
gst_bit_writer_reset (&bs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,8 +202,7 @@ gstlibvaapi_deps = [ gstbase_dep,
|
|||
gstvideo_dep,
|
||||
gstgl_dep,
|
||||
gstcodecparsers_dep,
|
||||
libva_dep,
|
||||
gstvaapi_baseutils_dep ]
|
||||
libva_dep ]
|
||||
if USE_DRM
|
||||
gstlibvaapi_deps += [libva_drm_dep, libdrm_dep, libudev_dep]
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue