Files
monibuca/pkg/codec/h265.go
2025-06-03 17:20:58 +08:00

52 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package codec
import (
"fmt"
"github.com/deepch/vdk/codec/h265parser"
)
type H265NALUType byte
func (H265NALUType) Parse(b byte) H265NALUType {
return H265NALUType(b & 0x7E >> 1)
}
func ParseH265NALUType(b byte) H265NALUType {
return H265NALUType(b & 0x7E >> 1)
}
var AudNalu = []byte{0x00, 0x00, 0x00, 0x01, 0x46, 0x01, 0x10}
type (
H265Ctx struct {
h265parser.CodecData
}
)
func (ctx *H265Ctx) GetInfo() string {
return fmt.Sprintf("fps: %d, resolution: %s", ctx.FPS(), ctx.Resolution())
}
func (*H265Ctx) FourCC() FourCC {
return FourCC_H265
}
func (h265 *H265Ctx) GetBase() ICodecCtx {
return h265
}
func (h265 *H265Ctx) GetRecord() []byte {
return h265.Record
}
func (h265 *H265Ctx) String() string {
// 根据 HEVC 标准格式hvc1.profile.compatibility.level.constraints
profile := h265.RecordInfo.AVCProfileIndication
compatibility := h265.RecordInfo.ProfileCompatibility
level := h265.RecordInfo.AVCLevelIndication
// 简单实现,使用可用字段模拟 HEVC 格式
return fmt.Sprintf("hvc1.%d.%X.L%d.00", profile, compatibility, level)
}