Skip to content

Commit 14a547e

Browse files
committed
fix: add test for VVC Annex B
1 parent bec4b63 commit 14a547e

5 files changed

Lines changed: 43 additions & 13 deletions

File tree

cmd/mp4ff-nallister/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,9 @@ func printSEINALus(w io.Writer, seiNALUs [][]byte, codec string, seiLevel int, a
491491
case "avc":
492492
seiCodec = sei.AVC
493493
hdrLen = 1
494-
case "hevc":
494+
case "hevc", "vvc": // VVC uses same SEI format as HEVC
495495
seiCodec = sei.HEVC
496496
hdrLen = 2
497-
case "vvc":
498-
seiCodec = sei.HEVC // VVC uses same SEI format as HEVC
499-
hdrLen = 2
500497
}
501498
if len(seiNALUs) > 0 {
502499
for _, seiNALU := range seiNALUs {

cmd/mp4ff-nallister/main_test.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"bytes"
55
"os"
66
"testing"
7+
8+
"github.com/Eyevinn/mp4ff/avc"
9+
"github.com/Eyevinn/mp4ff/mp4"
710
)
811

912
func TestOptions(t *testing.T) {
@@ -13,8 +16,6 @@ func TestOptions(t *testing.T) {
1316
expectedErr bool
1417
goldenOut string
1518
}{
16-
{desc: "vvc 2s", args: []string{appName, "../../mp4/testdata/vvc_400kbps_2s.mp4"}, expectedErr: false,
17-
goldenOut: "testdata/golden_vvc_2s.txt"},
1819
{desc: "no args", args: []string{appName}, expectedErr: true},
1920
{desc: "unknown args", args: []string{appName, "-x"}, expectedErr: true},
2021
{desc: "non-existing file", args: []string{appName, "infile.mp4"}, expectedErr: true},
@@ -40,7 +41,10 @@ func TestOptions(t *testing.T) {
4041
goldenOut: "testdata/golden_h264_frag_raw.txt", expectedErr: false},
4142
{desc: "avcSeiTime", args: []string{appName, "-sei", "2", "-annexb", "testdata/4pics.264"},
4243
goldenOut: "testdata/golden_4pic_sei_264.txt", expectedErr: false},
43-
44+
{desc: "vvc 2s", args: []string{appName, "../../mp4/testdata/vvc_400kbps_2s.mp4"}, expectedErr: false,
45+
goldenOut: "testdata/golden_vvc_2s.txt"},
46+
{desc: "vvc annexB", args: []string{appName, "-annexb", "-c", "vvc", "testdata/annexB.vvc"}, expectedErr: false,
47+
goldenOut: "testdata/golden_vvc_annexb.txt"},
4448
{desc: "version", args: []string{appName, "-version"}, expectedErr: false},
4549
{desc: "help", args: []string{appName, "-h"}, expectedErr: false},
4650
}
@@ -78,3 +82,29 @@ func getExpected(t *testing.T, filename string) string {
7882
r := bytes.ReplaceAll(b, []byte("\r\n"), []byte("\n"))
7983
return string(r)
8084
}
85+
86+
func MakeByteStream(t *testing.T, inFile, outFile string) {
87+
t.Helper()
88+
ifd, err := os.Open(inFile)
89+
if err != nil {
90+
t.Fatalf("could not open file %s: %s", inFile, err)
91+
}
92+
d, err := mp4.DecodeFile(ifd)
93+
if err != nil {
94+
t.Fatalf("could not decode file %s: %s", inFile, err)
95+
}
96+
fullSamples, err := d.Segments[0].Fragments[0].GetFullSamples(nil)
97+
if err != nil {
98+
t.Fatalf("could not get full samples: %s", err)
99+
}
100+
byteStream := make([]byte, 0, 1024)
101+
for i := 0; i <= 5; i++ {
102+
fs := fullSamples[i]
103+
bs := avc.ConvertSampleToByteStream(fs.Data)
104+
byteStream = append(byteStream, bs...)
105+
}
106+
err = os.WriteFile(outFile, byteStream, 0644)
107+
if err != nil {
108+
t.Fatalf("could not write file %s: %s", outFile, err)
109+
}
110+
}
17.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Sample 1, pts=0 (11051B): AUD_20 (3B), SPS_15 (176B), PPS_16 (13B), PREFIX_APS_17 (118B), IDR_W_RADL_7 (10721B)
2+
Sample 2, pts=0 (2192B): AUD_20 (3B), PREFIX_APS_17 (62B), RADL_2 (2115B)
3+
Sample 3, pts=0 (1846B): AUD_20 (3B), PREFIX_APS_17 (21B), RADL_2 (1810B)
4+
Sample 4, pts=0 (1404B): AUD_20 (3B), PREFIX_APS_17 (41B), RADL_2 (1348B)
5+
Sample 5, pts=0 (683B): AUD_20 (3B), PREFIX_APS_17 (19B), RADL_2 (649B)
6+
Sample 6, pts=0 (655B): AUD_20 (3B), PREFIX_APS_17 (53B), RADL_2 (587B)

cmd/mp4ff-subslister/main.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,15 @@ func parseProgressiveMp4(f *mp4.File, w io.Writer, trackID uint32, maxNrSamples
152152
}
153153
size := stbl.Stsz.GetSampleSize(sampleNr)
154154
decTime, dur := stbl.Stts.GetDecodeTime(uint32(sampleNr))
155-
var cto int64 = 0
156-
if stbl.Ctts != nil {
157-
cto = int64(stbl.Ctts.GetCompositionTimeOffset(uint32(sampleNr)))
158-
}
155+
// Skip checking compositionTimeOffset since not uset for subtitles
159156
// Next find sample bytes as slice in mdat
160157
offsetInMdatData := uint64(offset) - mdatPayloadStart
161158
sample := mdat.Data[offsetInMdatData : offsetInMdatData+uint64(size)]
162159
switch subsTrak.variant {
163160
case "wvtt":
164-
err = printWvttSample(w, sample, sampleNr, int64(decTime)+cto, dur)
161+
err = printWvttSample(w, sample, sampleNr, int64(decTime), dur)
165162
case "stpp":
166-
err = printStppSample(w, sample, sampleNr, int64(decTime)+cto, dur)
163+
err = printStppSample(w, sample, sampleNr, int64(decTime), dur)
167164
}
168165
if err != nil {
169166
return err

0 commit comments

Comments
 (0)