static InnerAccessUnit insertDecodingTime(InnerAccessUnit current, InnerAccessUnit previous) { int DeltaTfiDivisorIdx; if (!current.sliceHeaders.get(0).sps.vuiParams.pic_struct_present_flag) { DeltaTfiDivisorIdx = 1 + (1 - (!current.sliceHeaders.get(0).field_pic_flag ? 0 : 1)); } else { throw new UnsupportedOperationException("Hmm I cannot deal with picTimingSei"); // get details here // D.1.2 Picture timing SEI message syntax /*SEI.SEIMessage picTimingSei = null; for (SEI.SEIMessage message : current.sei.messages) { if (message.payloadType == 1) { picTimingSei = message; } } if (picTimingSei != null) { if (!avc.sei.pic_timing.pic_struct) DeltaTfiDivisorIdx = 2; else if (avc.sei.pic_timing.pic_struct == 8) DeltaTfiDivisorIdx = 6; else DeltaTfiDivisorIdx = (avc.sei.pic_timing.pic_struct + 1) / 2; } */ } current.decodingTime = previous.decodingTime + 2 * current.sliceHeaders.get(0).sps.vuiParams.num_units_in_tick * DeltaTfiDivisorIdx; // System.err.print("FPS: " + 2 * current.sliceHeaders.get(0).sps.vuiParams.time_scale); return current; }
static InnerAccessUnit decodePocType0(InnerAccessUnit current, InnerAccessUnit prev) { int TopFieldOrderCnt = Integer.MAX_VALUE; int BottomFieldOrderCnt = Integer.MAX_VALUE; int prevPicOrderCntMsb; int prevPicOrderCntLsb; if (current.sliceHeaders.get(0).slice_type == SliceType.I || current.sliceHeaders.get(0).slice_type == SliceType.SI) { prevPicOrderCntMsb = 0; prevPicOrderCntLsb = 0; } else { // if memory management dunno if (current.sei != null) { for (SEI.SEIMessage message : current.sei.messages) { if (message.payloadType == SEI.PIC_TIMING) { throw new RuntimeException("That needs to be implemented. 7687526897568234."); } } } prevPicOrderCntMsb = prev.picOrderCntMsb; prevPicOrderCntLsb = prev.sliceHeaders.get(0).pic_order_cnt_lsb; } int MaxPicOrderCntLsb = 1 << (current.sliceHeaders.get(0).sps.log2_max_pic_order_cnt_lsb_minus4 + 4); int picOrderCntMsb; if ((current.sliceHeaders.get(0).pic_order_cnt_lsb < prevPicOrderCntLsb) && ((prevPicOrderCntLsb - current.sliceHeaders.get(0).pic_order_cnt_lsb) >= (MaxPicOrderCntLsb / 2))) { picOrderCntMsb = prevPicOrderCntMsb + MaxPicOrderCntLsb; } else if ((current.sliceHeaders.get(0).pic_order_cnt_lsb > prevPicOrderCntLsb) && ((current.sliceHeaders.get(0).pic_order_cnt_lsb - prevPicOrderCntLsb) > (MaxPicOrderCntLsb / 2))) { picOrderCntMsb = prevPicOrderCntMsb - MaxPicOrderCntLsb; } else { picOrderCntMsb = prevPicOrderCntMsb; } if (!current.sliceHeaders.get(0).bottom_field_flag) { TopFieldOrderCnt = picOrderCntMsb + current.sliceHeaders.get(0).pic_order_cnt_lsb; } if (current.sliceHeaders.get(0).bottom_field_flag) { if (!current.sliceHeaders.get(0).field_pic_flag) { BottomFieldOrderCnt = TopFieldOrderCnt + current.sliceHeaders.get(0).delta_pic_order_cnt_bottom; } else { BottomFieldOrderCnt = picOrderCntMsb + current.sliceHeaders.get(0).pic_order_cnt_lsb; } } if (current.sliceHeaders.get(0).sps.frame_mbs_only_flag || !current.sliceHeaders.get(0).field_pic_flag) current.poc = Math.min(TopFieldOrderCnt, BottomFieldOrderCnt); else if (current.sliceHeaders.get(0).bottom_field_flag) current.poc = BottomFieldOrderCnt; else current.poc = TopFieldOrderCnt; // System.err.println("poc : " + current.poc); // System.err.println("poc-diff: " + (current.poc - prev.poc)); return current; }