File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -122,9 +122,9 @@ func (r *Reader) ReadUEGolomb() uint32 {
122
122
// ReadSEGolomb - ReadSignedExponentialGolomb
123
123
func (r * Reader ) ReadSEGolomb () int32 {
124
124
if b := r .ReadUEGolomb (); b % 2 == 0 {
125
- return - int32 (b >> 1 )
125
+ return - int32 (b / 2 )
126
126
} else {
127
- return int32 (b >> 1 )
127
+ return int32 (( b + 1 ) / 2 )
128
128
}
129
129
}
130
130
Original file line number Diff line number Diff line change 5
5
"encoding/hex"
6
6
"testing"
7
7
8
- "github.com/stretchr/testify/assert"
9
8
"github.com/stretchr/testify/require"
10
9
)
11
10
@@ -91,5 +90,14 @@ func TestDecodeSPS2(t *testing.T) {
91
90
require .Nil (t , err )
92
91
93
92
sps := DecodeSPS (b )
94
- assert .Nil (t , sps ) // broken SPS?
93
+ require .Equal (t , uint16 (928 ), sps .Width ())
94
+ require .Equal (t , uint16 (576 ), sps .Height ())
95
+
96
+ s = "Z2QAHq2EAQwgCGEAQwgCGEAQwgCEO1BQF/yzcBAQFAAAD6AAAXcCEA==" // unknown
97
+ b , err = base64 .StdEncoding .DecodeString (s )
98
+ require .Nil (t , err )
99
+
100
+ sps = DecodeSPS (b )
101
+ require .Equal (t , uint16 (640 ), sps .Width ())
102
+ require .Equal (t , uint16 (360 ), sps .Height ())
95
103
}
Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ func (s *SPS) Height() uint16 {
88
88
}
89
89
90
90
func DecodeSPS (sps []byte ) * SPS {
91
+ // https://developer.ridgerun.com/wiki/index.php/H264_Analysis_Tools
92
+ // ffmpeg -i file.h264 -c copy -bsf:v trace_headers -f null -
91
93
r := bits .NewReader (sps )
92
94
93
95
hdr := r .ReadByte ()
You can’t perform that action at this time.
0 commit comments