pull/358/head
q191201771 9 months ago
parent 5cd3fa9348
commit 5a3557066f

@ -10,7 +10,6 @@ package hevc
import ( import (
"bytes" "bytes"
"github.com/q191201771/naza/pkg/nazaerrors" "github.com/q191201771/naza/pkg/nazaerrors"
"github.com/q191201771/lal/pkg/base" "github.com/q191201771/lal/pkg/base"
@ -252,13 +251,15 @@ func ParseVpsSpsPpsFromSeqHeaderWithoutMalloc(payload []byte) (vps, sps, pps []b
} }
vps, sps, pps, err = parseVpsSpsPpsFromRecord(payload) 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) vps, sps, pps, err = parseVpsSpsPpsAnnexbFromRecord(payload)
} }
return return
} }
// TODO(chef): 函数中 vps 等变量指向的为新申请的内存块,与调用它的函数 ParseVpsSpsPpsFromSeqHeaderWithoutMalloc 语义不相符 202405
func parseVpsSpsPpsAnnexbFromRecord(payload []byte) (vps, sps, pps []byte, err error) { func parseVpsSpsPpsAnnexbFromRecord(payload []byte) (vps, sps, pps []byte, err error) {
for i := 0; i < len(payload)-4; { for i := 0; i < len(payload)-4; {
start := bytes.Index(payload[i:], NaluStartCode4) start := bytes.Index(payload[i:], NaluStartCode4)

@ -11,3 +11,8 @@ package hevc
import "github.com/q191201771/naza/pkg/nazalog" import "github.com/q191201771/naza/pkg/nazalog"
var Log = nazalog.GetGlobalLogger() var Log = nazalog.GetGlobalLogger()
// StrategyTryAnnexbWhenParseVspFromSeqHeaderFailed 从seq header中解析vps/sps/pps失败时尝试按annexb格式解析
//
// https://github.com/q191201771/lal/pull/353
var StrategyTryAnnexbWhenParseVspFromSeqHeaderFailed = false

Loading…
Cancel
Save