-
Notifications
You must be signed in to change notification settings - Fork 46
/
codec_test.go
81 lines (73 loc) · 2.03 KB
/
codec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package astiav
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCodec(t *testing.T) {
c := FindDecoder(CodecIDMp3)
require.NotNil(t, c)
require.Equal(t, c.ID(), CodecIDMp3)
require.Nil(t, c.ChannelLayouts())
require.True(t, c.IsDecoder())
require.False(t, c.IsEncoder())
require.Nil(t, c.PixelFormats())
require.Equal(t, []SampleFormat{SampleFormatFltp, SampleFormatFlt}, c.SampleFormats())
require.Equal(t, "mp3float", c.Name())
require.Equal(t, "mp3float", c.String())
c = FindDecoderByName("aac")
require.NotNil(t, c)
els := []ChannelLayout{
ChannelLayoutMono,
ChannelLayoutStereo,
ChannelLayoutSurround,
ChannelLayout4Point0,
ChannelLayout5Point0Back,
ChannelLayout5Point1Back,
ChannelLayout7Point1WideBack,
ChannelLayout6Point1Back,
ChannelLayout7Point1,
ChannelLayout22Point2,
ChannelLayout5Point1Point2Back,
}
gls := c.ChannelLayouts()
require.Len(t, gls, len(els))
for idx := range els {
require.True(t, els[idx].Equal(gls[idx]))
}
require.True(t, c.IsDecoder())
require.False(t, c.IsEncoder())
require.Equal(t, []SampleFormat{SampleFormatFltp}, c.SampleFormats())
require.Equal(t, "aac", c.Name())
require.Equal(t, "aac", c.String())
c = FindEncoder(CodecIDMjpeg)
require.NotNil(t, c)
require.False(t, c.IsDecoder())
require.True(t, c.IsEncoder())
require.Contains(t, c.PixelFormats(), PixelFormatYuvj420P)
require.Nil(t, c.SampleFormats())
require.Contains(t, c.Name(), "mjpeg")
require.Contains(t, c.String(), "mjpeg")
c = FindEncoderByName("mjpeg")
require.NotNil(t, c)
require.False(t, c.IsDecoder())
require.True(t, c.IsEncoder())
require.Equal(t, []PixelFormat{
PixelFormatYuvj420P,
PixelFormatYuvj422P,
PixelFormatYuvj444P,
PixelFormatYuv420P,
PixelFormatYuv422P,
PixelFormatYuv444P,
}, c.PixelFormats())
require.Equal(t, "mjpeg", c.Name())
require.Equal(t, "mjpeg", c.String())
c = FindDecoderByName("invalid")
require.Nil(t, c)
var found bool
for _, c := range Codecs() {
if c.ID() == CodecIDMjpeg {
found = true
}
}
require.True(t, found)
}