c5fbc5bf04
Vendored gsth265parser + nalutils + gstbitreader + gstbytereader (the
Step 1 commit) compile cleanly against libc + libv4l2 only after
adding 1 compat translation unit + 5 stub headers, no edits to the
vendored .c/.h files themselves.
src/h265_parser/gst_compat.{h,c} — new files (MIT, original work):
- GLib type aliases (gboolean, gchar, gint*, guint*, gsize, gpointer)
- Memory helpers (g_malloc/g_free as #define free, g_memdup2 inline)
- Asserts as no-op + parser-return-code-propagation
- All GST_DEBUG/INFO/WARNING/ERROR/LOG/FIXME as no-ops (the parser
is heavy on debug logging; we compile it all out)
- GArray implementation (~100 LOC, just enough for gsth265parser.c's
24 call sites)
- GList full struct with .data/.next/.prev so callers compile;
list-manipulation functions abort() — dead code paths only
- Byte-order read/write macros (GST_READ_UINT8/16/24/32/64_LE/BE,
GST_WRITE_UINT8/16/24/32_BE) — aarch64 LE inlines
- g_once_init_enter/leave as simple gate
- G_MAXUINT*, G_MAXINT*, G_MINxxx, G_GNUC_* attribute macros, etc.
- Opaque GstBuffer/GstMemory/GstMapInfo + abort-stub functions for
the encoder-side SEI-insertion paths the libva backend never invokes
- gst_util_ceil_log2 real impl (used by slice-header parser; dead
for our SPS-only call path but cheaper to implement than stub)
src/h265_parser/gst/{gst.h,base/base-prelude.h,base/gstbitwriter.h,
codecparsers/codecparsers-prelude.h,glib-compat-private.h} — 5 new
stub headers (MIT). All include gst_compat.h. gstbitwriter.h adds
abort-stub functions for the bit-writer API (used by nalutils.c's NAL
emulation-prevention encoder path — dead code for the parse-only
libva backend).
src/meson.build — added the 5 new .c source files and 10 new .h
headers; added include_directories('h265_parser') to the include path
so the vendored files' '#include <gst/base/...>' style references
resolve to the stub headers + actual vendored files in the local
tree.
Build verified: ninja -C build produces v4l2_request_drv_video.so
(682 KB, up from 485 KB pre-vendor — the +200 KB is the vendored
parser code). nm shows gst_h265_parse_sps, gst_h265_parse_sps_ext,
gst_h265_parser_identify_nalu, and the other functions we need for
Step 4 are present in the binary.
Two #warning messages from gsth265parser.h about API stability are
upstream-intentional and harmless ('The H.265 parsing library is
unstable API and may change in future').
This commit completes Step 2 of ampere-kernel-decoders iter2 Phase 6.
Backend remains functionally identical to pre-iter2 — the new code
compiles + links but is not yet called from h265_set_controls (that's
Step 4). Existing 5 codecs continue to work as before.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
/* Stub for <gst/base/gstbitwriter.h>.
|
|
*
|
|
* The vendored nalutils.c uses GstBitWriter for NAL emulation-prevention
|
|
* byte INSERTION during write-side (encoder) operations. The libva
|
|
* backend never invokes those paths — we only PARSE NAL units, never
|
|
* write them. The functions must still compile + link though, so we
|
|
* stub them with abort() runtime guards: if any future code path
|
|
* accidentally invokes a writer function, we fail-fast instead of
|
|
* silently corrupting.
|
|
*
|
|
* Header surface mirrors upstream gstbitwriter.h minimally — enough
|
|
* for nalutils.c to compile.
|
|
*/
|
|
#ifndef LIBVA_V4L2_REQUEST_FOURIER_GSTBITWRITER_STUB
|
|
#define LIBVA_V4L2_REQUEST_FOURIER_GSTBITWRITER_STUB
|
|
|
|
#include "gst_compat.h"
|
|
|
|
typedef struct {
|
|
guint8 *data;
|
|
guint bit_size;
|
|
guint bit_capacity;
|
|
gboolean auto_grow;
|
|
gboolean owned;
|
|
} GstBitWriter;
|
|
|
|
static inline void
|
|
gst_bit_writer_init(GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline void
|
|
gst_bit_writer_init_with_size(GstBitWriter *bw, guint size, gboolean fixed) {
|
|
(void)bw; (void)size; (void)fixed; abort();
|
|
}
|
|
static inline void
|
|
gst_bit_writer_reset(GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline gboolean
|
|
gst_bit_writer_put_bits_uint8(GstBitWriter *bw, guint8 value, guint nbits) {
|
|
(void)bw; (void)value; (void)nbits; abort();
|
|
}
|
|
static inline gboolean
|
|
gst_bit_writer_align_bytes(GstBitWriter *bw, guint8 trailing_bit) {
|
|
(void)bw; (void)trailing_bit; abort();
|
|
}
|
|
static inline guint8 *
|
|
gst_bit_writer_get_data(GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline guint
|
|
gst_bit_writer_get_size(const GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline guint
|
|
gst_bit_writer_reset_and_get_size(GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline guint8 *
|
|
gst_bit_writer_reset_and_get_data(GstBitWriter *bw) { (void)bw; abort(); }
|
|
static inline gboolean
|
|
gst_bit_writer_put_bits_uint16(GstBitWriter *bw, guint16 value, guint nbits) {
|
|
(void)bw; (void)value; (void)nbits; abort();
|
|
}
|
|
static inline gboolean
|
|
gst_bit_writer_put_bits_uint32(GstBitWriter *bw, guint32 value, guint nbits) {
|
|
(void)bw; (void)value; (void)nbits; abort();
|
|
}
|
|
static inline gboolean
|
|
gst_bit_writer_put_bytes(GstBitWriter *bw, const guint8 *data, guint nbytes) {
|
|
(void)bw; (void)data; (void)nbytes; abort();
|
|
}
|
|
|
|
#define GST_BIT_WRITER_BIT_SIZE(bw) ((bw)->bit_size)
|
|
#define GST_BIT_WRITER_DATA(bw) ((bw)->data)
|
|
|
|
#endif
|