Skip to content

Commit

Permalink
patch for #353
Browse files Browse the repository at this point in the history
  • Loading branch information
q191201771 committed May 11, 2024
1 parent 5cd3fa9 commit 5a35570
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/hevc/hevc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package hevc

import (
"bytes"

"github.com/q191201771/naza/pkg/nazaerrors"

"github.com/q191201771/lal/pkg/base"
Expand Down Expand Up @@ -252,13 +251,15 @@ func ParseVpsSpsPpsFromSeqHeaderWithoutMalloc(payload []byte) (vps, sps, pps []b
}

vps, sps, pps, err = parseVpsSpsPpsFromRecord(payload)
if err != nil {
if err != nil && StrategyTryAnnexbWhenParseVspFromSeqHeaderFailed {
//Log.Warnf("parse vps sps pps from seq header failed. try parse from annexb. payload=%s, err=%+v", hex.Dump(payload), err)
vps, sps, pps, err = parseVpsSpsPpsAnnexbFromRecord(payload)
}

return
}

// TODO(chef): 函数中 vps 等变量指向的为新申请的内存块,与调用它的函数 ParseVpsSpsPpsFromSeqHeaderWithoutMalloc 语义不相符 202405
func parseVpsSpsPpsAnnexbFromRecord(payload []byte) (vps, sps, pps []byte, err error) {
for i := 0; i < len(payload)-4; {
start := bytes.Index(payload[i:], NaluStartCode4)
Expand Down
5 changes: 5 additions & 0 deletions pkg/hevc/var.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ package hevc
import "github.com/q191201771/naza/pkg/nazalog"

var Log = nazalog.GetGlobalLogger()

// StrategyTryAnnexbWhenParseVspFromSeqHeaderFailed 从seq header中解析vps/sps/pps失败时,尝试按annexb格式解析
//
// https://github.com/q191201771/lal/pull/353
var StrategyTryAnnexbWhenParseVspFromSeqHeaderFailed = false

0 comments on commit 5a35570

Please sign in to comment.