From a9238532f6b39c37248ef1a962a7ffd67c8445a4 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sat, 10 Sep 2022 15:17:09 +0200 Subject: [PATCH] WiP: update to latest fdk-aac library --- .drone.yml | 6 +++--- fdkaac/enc.go | 21 ++++++++++++++++++++- fdkaac/enc_test.go | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9c714ed..9615a2d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,7 +19,7 @@ steps: commands: - apk update - apk add --no-cache git gcc g++ musl-dev bash autoconf automake cmake make libtool gettext fdk-aac-dev --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community - - go test -p 1 -failfast -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... + - go test -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... --- kind: pipeline type: docker @@ -57,7 +57,7 @@ steps: commands: - apk update - apk add --no-cache git gcc musl-dev pkgconfig - - go test -p 1 -failfast -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... + - go test -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... --- kind: pipeline type: docker @@ -94,6 +94,6 @@ steps: commands: - apk update - apk add --no-cache git gcc musl-dev pkgconfig - - go test -p 1 -failfast -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... + - go test -timeout 20m -cover -race -gcflags=-d=checkptr -v ./... ... diff --git a/fdkaac/enc.go b/fdkaac/enc.go index 7a6a010..c2c7050 100644 --- a/fdkaac/enc.go +++ b/fdkaac/enc.go @@ -25,6 +25,7 @@ package fdkaac /* #cgo pkg-config: fdk-aac #include +#include typedef struct { // the encoder handler. @@ -88,22 +89,31 @@ int aacenc_init(aacenc_t* h, int aot, int channels, int sample_rate, int bitrate case 5: mode = MODE_1_2_2; sce = 1; cpe = 2; break; case 6: mode = MODE_1_2_2_1; sce = 2; cpe = 2; break; default: - return -1; + return AACENC_INIT_ERROR; } if ((err = aacEncOpen(&h->enc, 0, channels)) != AACENC_OK) { + printf("aacEncOpen\n"); + return err; + } + + if ((err = aacEncoder_SetParam(h->enc, AACENC_GRANULE_LENGTH, 1024)) != AACENC_OK) { + printf("AACENC_GRANULE_LENGTH\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_AOT, aot)) != AACENC_OK) { + printf("AACENC_AOT\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_SAMPLERATE, sample_rate)) != AACENC_OK) { + printf("AACENC_SAMPLERATE\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_CHANNELMODE, mode)) != AACENC_OK) { + printf("AACENC_CHANNELMODE\n"); return err; } @@ -111,42 +121,51 @@ int aacenc_init(aacenc_t* h, int aot, int channels, int sample_rate, int bitrate // - 0: MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE). (default) // - 1: WAVE file format channel ordering (e. g. 5.1: L, R, C, LFE, SL, SR). if ((err = aacEncoder_SetParam(h->enc, AACENC_CHANNELORDER, 1)) != AACENC_OK) { + printf("AACENC_CHANNELORDER\n"); return err; } if (bitrate >= 0) { //CBR mode if ((err = aacEncoder_SetParam(h->enc, AACENC_BITRATEMODE, 0)) != AACENC_OK) { + printf("AACENC_BITRATEMODE 1\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_BITRATE, bitrate)) != AACENC_OK) { + printf("AACENC_BITRATE\n"); return err; } } else { //VBR mode if ((err = aacEncoder_SetParam(h->enc, AACENC_BITRATEMODE, -bitrate)) != AACENC_OK) { + printf("AACENC_BITRATEMODE 2\n"); return err; } } if ((err = aacEncoder_SetParam(h->enc, AACENC_TRANSMUX, trans_mux)) != AACENC_OK) { + printf("AACENC_TRANSMUX\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_SIGNALING_MODE, signaling)) != AACENC_OK) { + printf("AACENC_SIGNALING_MODE\n"); return err; } if ((err = aacEncoder_SetParam(h->enc, AACENC_AFTERBURNER, afterburner)) != AACENC_OK) { + printf("AACENC_AFTERBURNER\n"); return err; } if ((err = aacEncEncode(h->enc, NULL, NULL, NULL, NULL)) != AACENC_OK) { + printf("aacEncEncode\n"); return err; } AACENC_InfoStruct info; if ((err = aacEncInfo(h->enc, &info)) != AACENC_OK) { + printf("aacEncInfo\n"); return err; } diff --git a/fdkaac/enc_test.go b/fdkaac/enc_test.go index cceb13f..41a7d10 100644 --- a/fdkaac/enc_test.go +++ b/fdkaac/enc_test.go @@ -243,7 +243,7 @@ func TestHev2Encode(t *testing.T) { // flush got the last packets. // @remark user should flush util frame is nil. - expectedFlushSizes := []int{279, 356, 298, 279} + expectedFlushSizes := []int{279, 358, 359, 120} for { if frame, err = e.Flush(); err != nil { @@ -300,7 +300,7 @@ func TestHev2Flush(t *testing.T) { // flush got the last packets. // @remark user should flush util frame is nil. - expectedFlushSizes := []int{279, 356, 298, 279} + expectedFlushSizes := []int{279, 358, 359, 120} for { if frame, err = e.Flush(); err != nil {