2019-09-08 07:22:58 +03:00
|
|
|
/*
|
|
|
|
DESCRIPTION
|
|
|
|
decode.go provides slice decoding functionality.
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
Copyright (C) 2019 the Australian Ocean Lab (AusOcean).
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package h264dec
|
2019-09-09 04:58:43 +03:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|