Skip to content

Commit 5ed56d0

Browse files
committed
Removed AllocImage and AllocSamples
1 parent 27082bb commit 5ed56d0

File tree

7 files changed

+4
-32
lines changed

7 files changed

+4
-32
lines changed

BREAKING_CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.31.0
2+
3+
- removed `AllocImage` and `AllocSamples` that are considered useless using CGO until proven otherwise
4+
15
# v0.30.0
26

37
- `HardwareFrameContext` has been renamed to `HardwareFramesContext`

examples/frame_data_manipulation/main.go

-10
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ func main() {
4444
log.Fatal(fmt.Errorf("main: allocating buffer failed: %w", err))
4545
}
4646

47-
// Allocate samples
48-
if err := audioFrame.AllocSamples(align); err != nil {
49-
log.Fatal(fmt.Errorf("main: allocating image failed: %w", err))
50-
}
51-
5247
// When writing data manually into a frame, you need to make sure the frame is writable
5348
if err := audioFrame.MakeWritable(); err != nil {
5449
log.Fatal(fmt.Errorf("main: making frame writable failed: %w", err))
@@ -86,11 +81,6 @@ func main() {
8681
log.Fatal(fmt.Errorf("main: allocating buffer failed: %w", err))
8782
}
8883

89-
// Allocate image
90-
if err := videoFrame.AllocImage(align); err != nil {
91-
log.Fatal(fmt.Errorf("main: allocating image failed: %w", err))
92-
}
93-
9484
// When writing data manually into a frame, you need to make sure the frame is writable
9585
if err := videoFrame.MakeWritable(); err != nil {
9686
log.Fatal(fmt.Errorf("main: making frame writable failed: %w", err))

examples/resampling_audio/main.go

-6
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ func main() {
131131
if err := resampledFrame.AllocBuffer(align); err != nil {
132132
log.Fatal(fmt.Errorf("main: allocating buffer failed: %w", err))
133133
}
134-
if err := resampledFrame.AllocSamples(align); err != nil {
135-
log.Fatal(fmt.Errorf("main: allocating samples failed: %w", err))
136-
}
137134

138135
// For the sake of the example we use an audio FIFO to ensure final frames have an exact constant
139136
// number of samples except for the last one. However this is optional and it depends on your use case
@@ -146,9 +143,6 @@ func main() {
146143
if err := finalFrame.AllocBuffer(align); err != nil {
147144
log.Fatal(fmt.Errorf("main: allocating buffer failed: %w", err))
148145
}
149-
if err := finalFrame.AllocSamples(align); err != nil {
150-
log.Fatal(fmt.Errorf("main: allocating samples failed: %w", err))
151-
}
152146
af = astiav.AllocAudioFifo(finalFrame.SampleFormat(), finalFrame.ChannelLayout().Channels(), finalFrame.NbSamples())
153147
defer af.Free()
154148

frame.go

-10
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ func (f *Frame) AllocHardwareBuffer(hfc *HardwareFramesContext) error {
4141
return newError(C.av_hwframe_get_buffer(hfc.c, f.c, 0))
4242
}
4343

44-
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga841e0a89a642e24141af1918a2c10448
45-
func (f *Frame) AllocImage(align int) error {
46-
return newError(C.av_image_alloc(&f.c.data[0], &f.c.linesize[0], f.c.width, f.c.height, (C.enum_AVPixelFormat)(f.c.format), C.int(align)))
47-
}
48-
49-
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampmanip.html#ga4db4c77f928d32c7d8854732f50b8c04
50-
func (f *Frame) AllocSamples(align int) error {
51-
return newError(C.av_samples_alloc(&f.c.data[0], &f.c.linesize[0], f.c.ch_layout.nb_channels, f.c.nb_samples, (C.enum_AVSampleFormat)(f.c.format), C.int(align)))
52-
}
53-
5444
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#ae291cdec7758599e765bc9e3edbb3065
5545
func (f *Frame) ChannelLayout() ChannelLayout {
5646
l, _ := newChannelLayoutFromC(&f.c.ch_layout).clone()

frame_data_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,12 @@ func TestFrameData(t *testing.T) {
521521
f2.SetSampleFormat(f1.SampleFormat())
522522
f2.SetSampleRate(f1.SampleRate())
523523
require.NoError(t, f2.AllocBuffer(align))
524-
require.NoError(t, f2.AllocSamples(align))
525524
case MediaTypeVideo:
526525
align = 1
527526
f2.SetHeight(f1.Height())
528527
f2.SetPixelFormat(f1.PixelFormat())
529528
f2.SetWidth(f1.Width())
530529
require.NoError(t, f2.AllocBuffer(align))
531-
require.NoError(t, f2.AllocImage(align))
532530
}
533531

534532
switch v.md {

frame_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func TestFrame(t *testing.T) {
7777
f4.SetSampleRate(48000)
7878
align := 0
7979
require.NoError(t, f4.AllocBuffer(align))
80-
require.NoError(t, f4.AllocSamples(align))
8180
require.NoError(t, f4.SamplesFillSilence())
8281
n, err := f4.SamplesBufferSize(align)
8382
require.NoError(t, err)
@@ -113,7 +112,6 @@ func TestFrame(t *testing.T) {
113112
f6.SetWidth(4)
114113
align = 1
115114
require.NoError(t, f6.AllocBuffer(align))
116-
require.NoError(t, f6.AllocImage(align))
117115
require.NoError(t, f6.ImageFillBlack())
118116
n, err = f6.ImageBufferSize(align)
119117
require.NoError(t, err)
@@ -138,7 +136,6 @@ func TestFrame(t *testing.T) {
138136
f7.SetPixelFormat(f6.PixelFormat())
139137
f7.SetWidth(f6.Width())
140138
require.NoError(t, f7.AllocBuffer(align))
141-
require.NoError(t, f7.AllocImage(align))
142139
require.NoError(t, f6.Copy(f7))
143140
f6b, err := f6.Data().Bytes(align)
144141
require.NoError(t, err)

software_resample_context_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func TestSoftwareResampleContext(t *testing.T) {
2020
f2.SetSampleFormat(SampleFormatS16)
2121
f2.SetSampleRate(24000)
2222
require.NoError(t, f2.AllocBuffer(0))
23-
require.NoError(t, f2.AllocSamples(0))
2423

2524
for _, v := range []struct {
2625
expectedDelay int64

0 commit comments

Comments
 (0)