Skip to content

Commit eed62e5

Browse files
committed
feat(avutil): add support for AVBPrint functionality
- Add missing libavutil/bprint.h header to imports - Implement AVBPrint struct and related functions - Add AVBprint constants and enum values - Fix incorrect struct type references in existing code - Update function signatures to use the proper AVBPrint type - Enable bprint.h header parsing in the generator
1 parent 427209e commit eed62e5

6 files changed

Lines changed: 519 additions & 46 deletions

File tree

callbacks.gen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import "unsafe"
3535
// #include <libavutil/avutil.h>
3636
// #include <libavutil/base64.h>
3737
// #include <libavutil/blowfish.h>
38+
// #include <libavutil/bprint.h>
3839
// #include <libavutil/bswap.h>
3940
// #include <libavutil/buffer.h>
4041
// #include <libavutil/camellia.h>

constants.gen.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ package ffmpeg
3333
// #include <libavutil/avutil.h>
3434
// #include <libavutil/base64.h>
3535
// #include <libavutil/blowfish.h>
36+
// #include <libavutil/bprint.h>
3637
// #include <libavutil/bswap.h>
3738
// #include <libavutil/buffer.h>
3839
// #include <libavutil/camellia.h>
@@ -1513,6 +1514,15 @@ const AVFourccMaxStringSize = C.AV_FOURCC_MAX_STRING_SIZE
15131514
// AVBfRounds wraps AV_BF_ROUNDS.
15141515
const AVBfRounds = C.AV_BF_ROUNDS
15151516

1517+
// AVBprintSizeUnlimited wraps AV_BPRINT_SIZE_UNLIMITED.
1518+
const AVBprintSizeUnlimited = C.AV_BPRINT_SIZE_UNLIMITED
1519+
1520+
// AVBprintSizeAutomatic wraps AV_BPRINT_SIZE_AUTOMATIC.
1521+
const AVBprintSizeAutomatic = C.AV_BPRINT_SIZE_AUTOMATIC
1522+
1523+
// AVBprintSizeCountOnly wraps AV_BPRINT_SIZE_COUNT_ONLY.
1524+
const AVBprintSizeCountOnly = C.AV_BPRINT_SIZE_COUNT_ONLY
1525+
15161526
// AVBufferFlagReadonly wraps AV_BUFFER_FLAG_READONLY.
15171527
const AVBufferFlagReadonly = C.AV_BUFFER_FLAG_READONLY
15181528

enums.gen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import "unsafe"
3535
// #include <libavutil/avutil.h>
3636
// #include <libavutil/base64.h>
3737
// #include <libavutil/blowfish.h>
38+
// #include <libavutil/bprint.h>
3839
// #include <libavutil/bswap.h>
3940
// #include <libavutil/buffer.h>
4041
// #include <libavutil/camellia.h>

functions.gen.go

Lines changed: 174 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import "unsafe"
3535
// #include <libavutil/avutil.h>
3636
// #include <libavutil/base64.h>
3737
// #include <libavutil/blowfish.h>
38+
// #include <libavutil/bprint.h>
3839
// #include <libavutil/bswap.h>
3940
// #include <libavutil/buffer.h>
4041
// #include <libavutil/camellia.h>
@@ -7857,7 +7858,7 @@ func AVIOReadToBprint(h *AVIOContext, pb *AVBPrint, maxSize uint64) (int, error)
78577858
if h != nil {
78587859
tmph = h.ptr
78597860
}
7860-
var tmppb *C.struct_AVBPrint
7861+
var tmppb *C.AVBPrint
78617862
if pb != nil {
78627863
tmppb = pb.ptr
78637864
}
@@ -8976,6 +8977,175 @@ func AVBlowfishCrypt(ctx *AVBlowfish, dst unsafe.Pointer, src unsafe.Pointer, co
89768977
C.av_blowfish_crypt(tmpctx, (*C.uint8_t)(dst), (*C.uint8_t)(src), C.int(count), (*C.uint8_t)(iv), C.int(decrypt))
89778978
}
89788979

8980+
// --- Function av_bprint_init ---
8981+
8982+
// AVBprintInit wraps av_bprint_init.
8983+
/*
8984+
Init a print buffer.
8985+
8986+
@param buf buffer to init
8987+
@param size_init initial size (including the final 0)
8988+
@param size_max maximum size;
8989+
- `0` means do not write anything, just count the length
8990+
- `1` is replaced by the maximum value for automatic storage
8991+
any large value means that the internal buffer will be
8992+
reallocated as needed up to that limit
8993+
- `-1` is converted to `UINT_MAX`, the largest limit possible.
8994+
Check also `AV_BPRINT_SIZE_*` macros.
8995+
*/
8996+
func AVBprintInit(buf *AVBPrint, sizeInit uint, sizeMax uint) {
8997+
var tmpbuf *C.AVBPrint
8998+
if buf != nil {
8999+
tmpbuf = buf.ptr
9000+
}
9001+
C.av_bprint_init(tmpbuf, C.uint(sizeInit), C.uint(sizeMax))
9002+
}
9003+
9004+
// --- Function av_bprint_init_for_buffer ---
9005+
9006+
// AVBprintInitForBuffer wraps av_bprint_init_for_buffer.
9007+
/*
9008+
Init a print buffer using a pre-existing buffer.
9009+
9010+
The buffer will not be reallocated.
9011+
In case size equals zero, the AVBPrint will be initialized to use
9012+
the internal buffer as if using AV_BPRINT_SIZE_COUNT_ONLY with
9013+
av_bprint_init().
9014+
9015+
@param buf buffer structure to init
9016+
@param buffer byte buffer to use for the string data
9017+
@param size size of buffer
9018+
*/
9019+
func AVBprintInitForBuffer(buf *AVBPrint, buffer *CStr, size uint) {
9020+
var tmpbuf *C.AVBPrint
9021+
if buf != nil {
9022+
tmpbuf = buf.ptr
9023+
}
9024+
var tmpbuffer *C.char
9025+
if buffer != nil {
9026+
tmpbuffer = buffer.ptr
9027+
}
9028+
C.av_bprint_init_for_buffer(tmpbuf, tmpbuffer, C.uint(size))
9029+
}
9030+
9031+
// --- Function av_bprintf ---
9032+
9033+
// av_bprintf skipped due to variadic arg.
9034+
9035+
// --- Function av_vbprintf ---
9036+
9037+
// av_vbprintf skipped due to vl_arg.
9038+
9039+
// --- Function av_bprint_chars ---
9040+
9041+
// AVBprintChars wraps av_bprint_chars.
9042+
//
9043+
// Append char c n times to a print buffer.
9044+
func AVBprintChars(buf *AVBPrint, c uint8, n uint) {
9045+
var tmpbuf *C.AVBPrint
9046+
if buf != nil {
9047+
tmpbuf = buf.ptr
9048+
}
9049+
C.av_bprint_chars(tmpbuf, C.char(c), C.uint(n))
9050+
}
9051+
9052+
// --- Function av_bprint_append_data ---
9053+
9054+
// AVBprintAppendData wraps av_bprint_append_data.
9055+
/*
9056+
Append data to a print buffer.
9057+
9058+
@param buf bprint buffer to use
9059+
@param data pointer to data
9060+
@param size size of data
9061+
*/
9062+
func AVBprintAppendData(buf *AVBPrint, data *CStr, size uint) {
9063+
var tmpbuf *C.AVBPrint
9064+
if buf != nil {
9065+
tmpbuf = buf.ptr
9066+
}
9067+
var tmpdata *C.char
9068+
if data != nil {
9069+
tmpdata = data.ptr
9070+
}
9071+
C.av_bprint_append_data(tmpbuf, tmpdata, C.uint(size))
9072+
}
9073+
9074+
// --- Function av_bprint_strftime ---
9075+
9076+
// av_bprint_strftime skipped due to tm.
9077+
9078+
// --- Function av_bprint_get_buffer ---
9079+
9080+
// av_bprint_get_buffer skipped due to mem
9081+
9082+
// --- Function av_bprint_clear ---
9083+
9084+
// AVBprintClear wraps av_bprint_clear.
9085+
//
9086+
// Reset the string to "" but keep internal allocated data.
9087+
func AVBprintClear(buf *AVBPrint) {
9088+
var tmpbuf *C.AVBPrint
9089+
if buf != nil {
9090+
tmpbuf = buf.ptr
9091+
}
9092+
C.av_bprint_clear(tmpbuf)
9093+
}
9094+
9095+
// --- Function av_bprint_is_complete ---
9096+
9097+
// AVBprintIsComplete wraps av_bprint_is_complete.
9098+
/*
9099+
Test if the print buffer is complete (not truncated).
9100+
9101+
It may have been truncated due to a memory allocation failure
9102+
or the size_max limit (compare size and size_max if necessary).
9103+
*/
9104+
func AVBprintIsComplete(buf *AVBPrint) (int, error) {
9105+
var tmpbuf *C.AVBPrint
9106+
if buf != nil {
9107+
tmpbuf = buf.ptr
9108+
}
9109+
ret := C.av_bprint_is_complete(tmpbuf)
9110+
return int(ret), WrapErr(int(ret))
9111+
}
9112+
9113+
// --- Function av_bprint_finalize ---
9114+
9115+
// av_bprint_finalize skipped due to retStr
9116+
9117+
// --- Function av_bprint_escape ---
9118+
9119+
// AVBprintEscape wraps av_bprint_escape.
9120+
/*
9121+
Escape the content in src and append it to dstbuf.
9122+
9123+
@param dstbuf already inited destination bprint buffer
9124+
@param src string containing the text to escape
9125+
@param special_chars string containing the special characters which
9126+
need to be escaped, can be NULL
9127+
@param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
9128+
Any unknown value for mode will be considered equivalent to
9129+
AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
9130+
notice.
9131+
@param flags flags which control how to escape, see AV_ESCAPE_FLAG_* macros
9132+
*/
9133+
func AVBprintEscape(dstbuf *AVBPrint, src *CStr, specialChars *CStr, mode AVEscapeMode, flags int) {
9134+
var tmpdstbuf *C.AVBPrint
9135+
if dstbuf != nil {
9136+
tmpdstbuf = dstbuf.ptr
9137+
}
9138+
var tmpsrc *C.char
9139+
if src != nil {
9140+
tmpsrc = src.ptr
9141+
}
9142+
var tmpspecialChars *C.char
9143+
if specialChars != nil {
9144+
tmpspecialChars = specialChars.ptr
9145+
}
9146+
C.av_bprint_escape(tmpdstbuf, tmpsrc, tmpspecialChars, C.enum_AVEscapeMode(mode), C.int(flags))
9147+
}
9148+
89799149
// --- Function av_bswap16 ---
89809150

89819151
// AVBswap16 wraps av_bswap16.
@@ -9517,7 +9687,7 @@ func AVChannelName(buf *CStr, bufSize uint64, channel AVChannel) (int, error) {
95179687
@note the string will be appended to the bprint buffer.
95189688
*/
95199689
func AVChannelNameBprint(bp *AVBPrint, channelId AVChannel) {
9520-
var tmpbp *C.struct_AVBPrint
9690+
var tmpbp *C.AVBPrint
95219691
if bp != nil {
95229692
tmpbp = bp.ptr
95239693
}
@@ -9555,7 +9725,7 @@ func AVChannelDescription(buf *CStr, bufSize uint64, channel AVChannel) (int, er
95559725
@note the string will be appended to the bprint buffer.
95569726
*/
95579727
func AVChannelDescriptionBprint(bp *AVBPrint, channelId AVChannel) {
9558-
var tmpbp *C.struct_AVBPrint
9728+
var tmpbp *C.AVBPrint
95599729
if bp != nil {
95609730
tmpbp = bp.ptr
95619731
}
@@ -9773,7 +9943,7 @@ func AVChannelLayoutDescribeBprint(channelLayout *AVChannelLayout, bp *AVBPrint)
97739943
if channelLayout != nil {
97749944
tmpchannelLayout = channelLayout.ptr
97759945
}
9776-
var tmpbp *C.struct_AVBPrint
9946+
var tmpbp *C.AVBPrint
97779947
if bp != nil {
97789948
tmpbp = bp.ptr
97799949
}

internal/generator/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ var files = []string{
4343
"libavutil/aes.h",
4444
"libavutil/aes_ctr.h",
4545
"libavutil/ambient_viewing_environment.h",
46-
////"libavutil/attributes.h", // could not determine what C.attribute_deprecated refers to
46+
////"libavutil/attributes.h", // a compiler attribute macro collection, not an API header
4747
"libavutil/audio_fifo.h",
4848
"libavutil/avassert.h",
4949
"libavutil/avconfig.h",
5050
"libavutil/avstring.h",
5151
"libavutil/avutil.h",
5252
"libavutil/base64.h",
5353
"libavutil/blowfish.h",
54-
////"libavutil/bprint.h", // could not determine what C.AVEscapeMode refers to
54+
"libavutil/bprint.h",
5555
"libavutil/bswap.h",
5656
"libavutil/buffer.h",
5757
"libavutil/camellia.h",
@@ -107,7 +107,7 @@ var files = []string{
107107
"libavutil/random_seed.h",
108108
"libavutil/rational.h",
109109
"libavutil/rc4.h",
110-
////"libavutil/refstruct.h", //typedef name AVRefStructOpaque
110+
////"libavutil/refstruct.h", // reference-counted object API introduced as an alternative to AVBuffer for managing complex objects
111111
"libavutil/replaygain.h",
112112
"libavutil/ripemd.h",
113113
"libavutil/samplefmt.h",

0 commit comments

Comments
 (0)