diff --git a/codec/h264/h264dec/decode.go b/codec/h264/h264dec/decode.go index a777c73f..bd686efc 100644 --- a/codec/h264/h264dec/decode.go +++ b/codec/h264/h264dec/decode.go @@ -178,24 +178,21 @@ func decodePicOrderCntType2(vid *VideoStream, ctx *SliceContext) (topFieldOrderC panic("not implemented") } - var tempPicOrderCnt int - switch { - case vid.idrPicFlag: + tempPicOrderCnt := 2 * (vid.frameNumOffset + ctx.FrameNum) + if vid.idrPicFlag { tempPicOrderCnt = 0 - case ctx.RefIdc == 0: + } else if ctx.RefIdc == 0 { tempPicOrderCnt = 2*(vid.frameNumOffset+ctx.FrameNum) - 1 - default: - tempPicOrderCnt = 2 * (vid.frameNumOffset + ctx.FrameNum) } - switch { - case ctx.FieldPic: + if !ctx.FieldPic { topFieldOrderCnt = tempPicOrderCnt bottomFieldOrderCnt = tempPicOrderCnt - case ctx.BottomField: + } else if ctx.BottomField { bottomFieldOrderCnt = tempPicOrderCnt - default: + } else { topFieldOrderCnt = tempPicOrderCnt } + return }