mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec/decode.go: wrote function picOrderCntType0 to handle derivation of TopFieldOrderCnt and BottomFieldOrderCnt when pic_order_cnt_type == 0
This commit is contained in:
parent
5261f82ef7
commit
d92e0bfb5e
|
@ -23,3 +23,38 @@ LICENSE
|
|||
*/
|
||||
|
||||
package h264dec
|
||||
|
||||
// picOrderCntType0 is used to return topFieldOrderCnt and bottomFieldOrderCnt
|
||||
// when pic_order_cnt_type i.e vid.PicOrderCntType == 0, using the process
|
||||
// defined in section 8.2.1.1 of the specifications.
|
||||
func picOrderCntType0(vid VideoStream, ctx SliceContext) (topFieldOrderCnt, bottomFieldOrderCnt int) {
|
||||
prevPicOrderCntMsb, prevPicOrderCntLsb := 0, 0
|
||||
topFieldOrderCnt, bottomFieldOrderCnt = -1, -1
|
||||
|
||||
// NB: We're currently only handling IDRs so panic.
|
||||
if !vid.currPic.isIDR {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
switch {
|
||||
case (ctx.PicOrderCntLsb < prevPicOrderCntLsb) && ((prevPicOrderCntLsb - ctx.PicOrderCntLsb) >= (vid.maxPicOrderCntLsb / 2)):
|
||||
vid.picOrderCntMsb = prevPicOrderCntMsb + vid.maxPicOrderCntLsb
|
||||
case (ctx.PicOrderCntLsb > prevPicOrderCntLsb) && ((ctx.PicOrderCntLsb - prevPicOrderCntLsb) > (vid.maxPicOrderCntLsb / 2)):
|
||||
vid.picOrderCntMsb = prevPicOrderCntMsb - vid.maxPicOrderCntLsb
|
||||
default:
|
||||
vid.picOrderCntMsb = prevPicOrderCntMsb
|
||||
}
|
||||
|
||||
if !vid.currPic.isBottomField {
|
||||
topFieldOrderCnt = vid.picOrderCntMsb + ctx.PicOrderCntLsb
|
||||
}
|
||||
|
||||
if !vid.currPic.isTopField {
|
||||
if !ctx.FieldPic {
|
||||
bottomFieldOrderCnt = topFieldOrderCnt + ctx.DeltaPicOrderCntBottom
|
||||
} else {
|
||||
bottomFieldOrderCnt = vid.picOrderCntMsb + ctx.PicOrderCntLsb
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -35,12 +35,21 @@ const (
|
|||
chroma444
|
||||
)
|
||||
|
||||
type picture struct {
|
||||
isIDR bool
|
||||
isBottomField bool
|
||||
isTopField bool
|
||||
}
|
||||
|
||||
type VideoStream struct {
|
||||
*SPS
|
||||
*PPS
|
||||
Slices []*SliceContext
|
||||
|
||||
ChromaArrayType int
|
||||
ChromaArrayType int
|
||||
currPic picture
|
||||
maxPicOrderCntLsb int
|
||||
picOrderCntMsb int
|
||||
}
|
||||
|
||||
type SliceContext struct {
|
||||
|
|
Loading…
Reference in New Issue