Skip to content

Commit

Permalink
Merge pull request #188 from edgeware/v0.30.1
Browse files Browse the repository at this point in the history
v0.30.1 bug fix release
  • Loading branch information
tobbee authored Nov 6, 2022
2 parents c520a8b + fc623aa commit 25ff8a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions Versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Version | Highlight |
| ------ | --------- |
| 0.30.1 | Fix optimized sample copying introduced in v0.30.0 |
| 0.30.0 | Full AVC slice header parsing. Enhanced SEI Messages. Optimizations in ctts and sample copying. Bug fixes in HEVC nalu, tfdt, emsg |
| 0.29.0 | Improved uuid and esds box handling. Extended decryption example with cbcs and in-place cenc decryption |
| 0.28.0 | Full HEVC SPS parsing. Better video sample entry generation. More AC-3/EC-3 support. Extended EBSPWriter. Bug fixes |
Expand Down
2 changes: 1 addition & 1 deletion mp4/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (f *File) CopySampleData(w io.Writer, rs io.ReadSeeker, trak *TrakBox,
if err != nil {
return err
}
if workLen > 0 {
if workLen == 0 {
n, err := io.CopyN(w, rs, size)
if err != nil {
return fmt.Errorf("copyN: %w", err)
Expand Down
26 changes: 17 additions & 9 deletions mp4/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,29 @@ func TestDecodeFileWithNoLazyMdatOption(t *testing.T) {
}
}

// TestExtractTrackSampleData both lazily and by reading in full file
// TestCopyTrackSampleData checks that full early read and lazy with and without workSpace gives good and same result.
func TestCopyTrackSampleData(t *testing.T) {
// load a progressive file

sampleDataRead := make([][]byte, 0, 1)
work := make([]byte, 1024)
for j := 0; j < 2; j++ {
testCases := []struct {
lazy bool
workSpaceSize int
}{
{lazy: false, workSpaceSize: 0},
{lazy: true, workSpaceSize: 0},
{lazy: true, workSpaceSize: 256},
}
sampleDataRead := make([][]byte, 0, len(testCases))
for j, tc := range testCases {
fd, err := os.Open("./testdata/prog_8s.mp4")
if err != nil {
t.Error(err)
}
defer fd.Close()
var mp4f *File
if j == 0 {
var workSpace []byte
if tc.lazy {
mp4f, err = DecodeFile(fd, WithDecodeMode(DecModeLazyMdat))
workSpace = make([]byte, tc.workSpaceSize)
} else {
mp4f, err = DecodeFile(fd)
}
Expand All @@ -84,15 +92,15 @@ func TestCopyTrackSampleData(t *testing.T) {
var startSampleNr uint32 = 31
var endSampleNr uint32 = 60

for i, trak := range mp4f.Moov.Traks {
for _, trak := range mp4f.Moov.Traks {
totSize := 0
stsz := trak.Mdia.Minf.Stbl.Stsz
for i := startSampleNr; i <= endSampleNr; i++ {
totSize += int(stsz.GetSampleSize(int(i)))
}
sampleData := bytes.Buffer{}

err := mp4f.CopySampleData(&sampleData, fd, trak, startSampleNr, endSampleNr, work)
err := mp4f.CopySampleData(&sampleData, fd, trak, startSampleNr, endSampleNr, workSpace)
if err != nil {
t.Error(err)
}
Expand All @@ -102,7 +110,7 @@ func TestCopyTrackSampleData(t *testing.T) {
if trak.Tkhd.TrackID == 1 {
sampleDataRead = append(sampleDataRead, sampleData.Bytes())
if len(sampleDataRead) > 1 {
if res := bytes.Compare(sampleDataRead[i], sampleDataRead[0]); res != 0 {
if res := bytes.Compare(sampleDataRead[j], sampleDataRead[0]); res != 0 {
t.Errorf("sample data read differs %d", res)
}
}
Expand Down
4 changes: 2 additions & 2 deletions mp4/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

var (
commitVersion string = "v0.30.0" // May be updated using build flags
commitDate string = "1667572437" // commitDate in Epoch seconds (may be overridden using build flags)
commitVersion string = "v0.30.1" // May be updated using build flags
commitDate string = "1667671435" // commitDate in Epoch seconds (may be overridden using build flags)
)

// GetVersion - get version and also commitHash and commitDate if inserted via Makefile
Expand Down

0 comments on commit 25ff8a4

Please sign in to comment.