new sample entry implementation for avc1

This commit is contained in:
Martin Riedl 2024-12-03 19:29:14 +01:00
parent aa3548a299
commit 0eedf34735
Signed by: martinr92
GPG key ID: FB68DA65516A804C
2 changed files with 40 additions and 2 deletions

View file

@ -1,10 +1,12 @@
# goMP4 # goMP4
[![pipeline status](https://gitlab.com/martinr92/gomp4/badges/main/pipeline.svg)](https://gitlab.com/martinr92/gomp4/commits/main) [![pipeline status](https://gitlab.com/martinr92/gomp4/badges/main/pipeline.svg)](https://gitlab.com/martinr92/gomp4/commits/main)
[![coverage report](https://gitlab.com/martinr92/gomp4/badges/main/coverage.svg)](https://gitlab.com/martinr92/gomp4/commits/main) [![coverage report](https://gitlab.com/martinr92/gomp4/badges/main/coverage.svg)](https://gitlab.com/martinr92/gomp4/commits/main)
mp4 implementation in golang based on spec ISO ICE 14496-12:2015 mp4 implementation in golang based on spec ISO ICE 14496-12:2015
## Parser ## Parser
```go ```go
parser := gomp4.NewParser(file) parser := gomp4.NewParser(file)
if err := parser.Parse(); err != nil { if err := parser.Parse(); err != nil {
@ -13,7 +15,8 @@ if err := parser.Parse(); err != nil {
``` ```
## Progress ## Progress
Implementation progress
Implementation progress of ISO ICE 14496-12:2015:
| Chapter | Box Types | Parser | | Chapter | Box Types | Parser |
|----------------------------------------------------|----------------|-------:| |----------------------------------------------------|----------------|-------:|
@ -34,7 +37,7 @@ Implementation progress
| 8.4.5.2 Null Media Header Box | nmhd | - | | 8.4.5.2 Null Media Header Box | nmhd | - |
| 8.4.6 Extended language tag | elng | - | | 8.4.6 Extended language tag | elng | - |
| 8.5.1 Sample Table Box | stbl | 100% | | 8.5.1 Sample Table Box | stbl | 100% |
| 8.5.2 Sample Description Box | stsd | 20% | | 8.5.2 Sample Description Box | stsd | 100% |
| 8.5.3 Degradation Priority Box | stdp | - | | 8.5.3 Degradation Priority Box | stdp | - |
| 8.6.1.2 Decoding Time to Sample Box | stts | - | | 8.6.1.2 Decoding Time to Sample Box | stts | - |
| 8.6.1.3 Composition Time to Sample Box | ctts | - | | 8.6.1.3 Composition Time to Sample Box | ctts | - |

View file

@ -89,5 +89,40 @@ func ParseSampleDescriptionBox(parser *Parser, filePosition uint64, headerSize u
// entry counter // entry counter
box.EntryCount = binary.BigEndian.Uint32(content[4:8]) box.EntryCount = binary.BigEndian.Uint32(content[4:8])
// parse child boxes
var err error
box.ChildBoxes, err = box.parseChildBoxes(parser, BoxTypeSampleDescription, filePosition, content[8:])
if err != nil {
return box, err
}
// validate entry count
if int(box.EntryCount) != len(box.ChildBoxes) {
return box, fmt.Errorf("invalid amount of boxes at %d; found %d but expected %d", filePosition, len(box.ChildBoxes), box.EntryCount)
}
return box, nil
}
type SampleEntry struct {
*Box
// is an integer that contains the index of the data reference to use to
// retrieve data associated with samples that use this sample description. Data references are
// stored in Data Reference Boxes. The index ranges from 1 to the number of data references.
DataReferenceIndex uint16
}
func ParseSampleEntry(filePosition uint64, headerSize uint32, content []byte) *SampleEntry {
box := &SampleEntry{
Box: &Box{filePosition, headerSize},
}
// skip reserved
position := 2 * 8
// parse reference index
box.DataReferenceIndex = binary.BigEndian.Uint16(content[position : position+2])
log.Println("data reference index", box.DataReferenceIndex) // TODO: remove me
return box return box
} }