Skip to content

Commit 08e37ac

Browse files
committed
cleanup and rename for clarity
1 parent 106bbb8 commit 08e37ac

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

readersampleprovider.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ func (p *ReaderSampleProvider) NextSample(ctx context.Context) (media.Sample, er
389389
var (
390390
// haveVCL tracks whether we've started a picture (any VCL NAL seen).
391391
haveVCL bool
392-
// haveAnnexB tracks whether sample.Data is in AnnexB format yet.
393-
haveAnnexB bool
392+
// sampleIsAnnexB tracks whether sample.Data is in AnnexB format yet.
393+
sampleIsAnnexB bool
394394
)
395395

396396
for {
@@ -459,14 +459,14 @@ func (p *ReaderSampleProvider) NextSample(ctx context.Context) (media.Sample, er
459459

460460
// Aggregate VPS/SPS/PPS before the next access unit.
461461
if nal.NalUnitType == 32 || nal.NalUnitType == 33 || nal.NalUnitType == 34 {
462-
haveAnnexB = true
462+
sampleIsAnnexB = true
463463
sample.Data = append(sample.Data, []byte{0, 0, 0, 1}...) // add NAL prefix
464464
sample.Data = append(sample.Data, nal.Data...)
465465
continue
466466
}
467467

468468
// Append this NAL to the current access unit payload.
469-
sample.Data = appendH265NAL(sample.Data, nal.Data, &haveAnnexB)
469+
sample.Data = appendH265NAL(sample.Data, nal.Data, &sampleIsAnnexB)
470470

471471
if nal.NalUnitType < 32 {
472472
haveVCL = true
@@ -749,16 +749,16 @@ func h265FirstSliceInPic(nalData []byte) (bool, bool) {
749749
return (nalData[2] & 0x80) != 0, true
750750
}
751751

752-
func appendH265NAL(dst []byte, nalData []byte, haveAnnexB *bool) []byte {
752+
func appendH265NAL(dst []byte, nalData []byte, sampleIsAnnexB *bool) []byte {
753753
// Ensure AnnexB start codes and append in-place for AU aggregation.
754-
if *haveAnnexB || len(dst) > 0 {
755-
if !*haveAnnexB && len(dst) > 0 {
754+
if *sampleIsAnnexB || len(dst) > 0 {
755+
if !*sampleIsAnnexB && len(dst) > 0 {
756756
dst = append([]byte{0, 0, 0, 1}, dst...)
757-
*haveAnnexB = true
757+
*sampleIsAnnexB = true
758758
}
759759
dst = append(dst, []byte{0, 0, 0, 1}...)
760760
dst = append(dst, nalData...)
761-
*haveAnnexB = true
761+
*sampleIsAnnexB = true
762762
return dst
763763
}
764764
return nalData

0 commit comments

Comments
 (0)