mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec: addressing PR feedback.
Updated comment. Put a space between file header and package declaration. Not dereferencing things
This commit is contained in:
parent
344d37cd29
commit
dab94f6ae2
|
@ -263,9 +263,9 @@ func NewNALUnit(br *bits.BitReader) (*NALUnit, error) {
|
||||||
next3Bytes, err := br.PeekBits(24)
|
next3Bytes, err := br.PeekBits(24)
|
||||||
|
|
||||||
// If PeekBits cannot get 3 bytes, but there still might be 2 bytes left in
|
// If PeekBits cannot get 3 bytes, but there still might be 2 bytes left in
|
||||||
// the source, we will get an io.EOF; we wish to ignore this and continue.
|
// the source, we will get an io.ErrUnexpectedEOF; we wish to ignore this
|
||||||
// The call to moreRBSPData will determine when we have reached the end of
|
// and continue. The call to moreRBSPData will determine when we have
|
||||||
// the NAL unit.
|
// reached the end of the NAL unit.
|
||||||
if err != nil && errors.Cause(err) != io.ErrUnexpectedEOF {
|
if err != nil && errors.Cause(err) != io.ErrUnexpectedEOF {
|
||||||
return nil, errors.Wrap(err, "could not Peek next 3 bytes")
|
return nil, errors.Wrap(err, "could not Peek next 3 bytes")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,27 @@
|
||||||
/*
|
/*
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
nalunit_test.go provides testing for NAL unit parsing utilities in nalunit.go.
|
nalunit_test.go provides testing for functionality in nalunit.go.
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
Saxon Nelson-Milton <saxon@ausocean.org>, The Australian Ocean Laboratory (AusOcean)
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
Copyright (C) 2017-2019 the Australian Ocean Lab (AusOcean)
|
||||||
|
|
||||||
|
It is free software: you can redistribute it and/or modify them
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
It is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package h264dec
|
package h264dec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -18,7 +35,7 @@ import (
|
||||||
func TestNewMVCExtension(t *testing.T) {
|
func TestNewMVCExtension(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in string
|
in string
|
||||||
want MVCExtension
|
want *MVCExtension
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -30,7 +47,7 @@ func TestNewMVCExtension(t *testing.T) {
|
||||||
"0" + // u(1) inter_view_flag = false
|
"0" + // u(1) inter_view_flag = false
|
||||||
"1" + // u(1) reserved_one_bit = 1
|
"1" + // u(1) reserved_one_bit = 1
|
||||||
"0", // Some padding
|
"0", // Some padding
|
||||||
want: MVCExtension{
|
want: &MVCExtension{
|
||||||
NonIdrFlag: false,
|
NonIdrFlag: false,
|
||||||
PriorityID: 2,
|
PriorityID: 2,
|
||||||
ViewID: 24,
|
ViewID: 24,
|
||||||
|
@ -53,7 +70,7 @@ func TestNewMVCExtension(t *testing.T) {
|
||||||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(*got, test.want) {
|
if !reflect.DeepEqual(got, test.want) {
|
||||||
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +79,7 @@ func TestNewMVCExtension(t *testing.T) {
|
||||||
func TestNewThreeDAVCExtension(t *testing.T) {
|
func TestNewThreeDAVCExtension(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in string
|
in string
|
||||||
want ThreeDAVCExtension
|
want *ThreeDAVCExtension
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -73,7 +90,7 @@ func TestNewThreeDAVCExtension(t *testing.T) {
|
||||||
"1" + // u(1) anchor_pic_flag = true
|
"1" + // u(1) anchor_pic_flag = true
|
||||||
"1" + // u(1) inter_view_flag = true
|
"1" + // u(1) inter_view_flag = true
|
||||||
"000", // Some padding
|
"000", // Some padding
|
||||||
want: ThreeDAVCExtension{
|
want: &ThreeDAVCExtension{
|
||||||
ViewIdx: 16,
|
ViewIdx: 16,
|
||||||
DepthFlag: true,
|
DepthFlag: true,
|
||||||
NonIdrFlag: false,
|
NonIdrFlag: false,
|
||||||
|
@ -95,7 +112,7 @@ func TestNewThreeDAVCExtension(t *testing.T) {
|
||||||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(*got, test.want) {
|
if !reflect.DeepEqual(got, test.want) {
|
||||||
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +121,7 @@ func TestNewThreeDAVCExtension(t *testing.T) {
|
||||||
func TestSVCExtension(t *testing.T) {
|
func TestSVCExtension(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in string
|
in string
|
||||||
want SVCExtension
|
want *SVCExtension
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -119,7 +136,7 @@ func TestSVCExtension(t *testing.T) {
|
||||||
"0" + // u(1) output_flag = false
|
"0" + // u(1) output_flag = false
|
||||||
"11" + // ReservedThree2Bits
|
"11" + // ReservedThree2Bits
|
||||||
"0", // padding
|
"0", // padding
|
||||||
want: SVCExtension{
|
want: &SVCExtension{
|
||||||
IdrFlag: false,
|
IdrFlag: false,
|
||||||
PriorityID: 32,
|
PriorityID: 32,
|
||||||
NoInterLayerPredFlag: false,
|
NoInterLayerPredFlag: false,
|
||||||
|
@ -145,7 +162,7 @@ func TestSVCExtension(t *testing.T) {
|
||||||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(*got, test.want) {
|
if !reflect.DeepEqual(got, test.want) {
|
||||||
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +171,7 @@ func TestSVCExtension(t *testing.T) {
|
||||||
func TestNewNALUnit(t *testing.T) {
|
func TestNewNALUnit(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in string
|
in string
|
||||||
want NALUnit
|
want *NALUnit
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -182,7 +199,7 @@ func TestNewNALUnit(t *testing.T) {
|
||||||
"0000 1000" +
|
"0000 1000" +
|
||||||
"1000 0000", // trailing bits
|
"1000 0000", // trailing bits
|
||||||
|
|
||||||
want: NALUnit{
|
want: &NALUnit{
|
||||||
ForbiddenZeroBit: 0,
|
ForbiddenZeroBit: 0,
|
||||||
RefIdc: 1,
|
RefIdc: 1,
|
||||||
Type: 14,
|
Type: 14,
|
||||||
|
@ -221,21 +238,16 @@ func TestNewNALUnit(t *testing.T) {
|
||||||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !nalEqual(*got, test.want) {
|
if !nalEqual(got, test.want) {
|
||||||
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nalEqual returns true if two NALUnits are equal.
|
// nalEqual returns true if two NALUnits are equal.
|
||||||
func nalEqual(a, b NALUnit) bool {
|
func nalEqual(a, b *NALUnit) bool {
|
||||||
aCopy := a
|
aCopy := nalWithoutExtensions(*a)
|
||||||
bCopy := b
|
bCopy := nalWithoutExtensions(*b)
|
||||||
for _, n := range [](*NALUnit){&aCopy, &bCopy} {
|
|
||||||
n.SVCExtension = nil
|
|
||||||
n.MVCExtension = nil
|
|
||||||
n.ThreeDAVCExtension = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(aCopy, bCopy) {
|
if !reflect.DeepEqual(aCopy, bCopy) {
|
||||||
return false
|
return false
|
||||||
|
@ -263,3 +275,10 @@ func nalEqual(a, b NALUnit) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func nalWithoutExtensions(n NALUnit) NALUnit {
|
||||||
|
n.SVCExtension = nil
|
||||||
|
n.MVCExtension = nil
|
||||||
|
n.ThreeDAVCExtension = nil
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue