Exemplo n.º 1
0
        public int Write(IH264EntropyOutputStream stream)
        {
            var len = 0;

            len += stream.WriteUeV(firstMbInSlice);
            len += stream.WriteUeV((int)sliceType);
            len += stream.WriteUeV(picParameterSetId);
            len += stream.WriteUv(
                log2MaxFrameNumMinus4 + 4, slice.Picture.FrameNum);

            if (nalUnitType.Equals(NaluType.NaluTypeIdr))
            {
                // idr_pic_id
                len += stream.WriteUeV(slice.Picture.Number%2);
            }

            if (picOrderCntType == 0)
            {
                if (frameMbsOnlyFlag)
                {
                    const int frameSkip = 0;
                    var baseMul = slice.Picture.FrameNum;
                    var toppoc = baseMul*(2*(frameSkip + 1));
                    var maxLength = ~((-1) << (log2MaxPicOrderCntLsbMinus4 + 4));
                    picOrderCntLsb = toppoc & maxLength;
                }
                else
                {
                    // TODO Unreachable
                }
                len += stream.WriteUv(
                    log2MaxPicOrderCntLsbMinus4 + 4, picOrderCntLsb);
            }

            len += RefPicListReordering(stream);

            if (((int)nalRefIdc) != 0)
                len += DecRefPicMarking(stream);

            len += stream.WriteSeV(sliceQpDelta);

            return len;
        }
        public override int Write(IH264EntropyOutputStream  stream)
        {
            stream.WriteUeV(picParameterSetId);
            stream.WriteUeV(seqParameterSetId);
            stream.WriteU1(entropyCodingModeFlag);
            stream.WriteU1(picOrderPresentFlag);
            stream.WriteUeV(numSliceGroupsMinus1);
            // FMO stuff
            if (numSliceGroupsMinus1 > 0) {
                // TODO Unreachable
            }
            // End of FMO stuff
            stream.WriteUeV(numRefIdxL0ActiveMinus1);
            stream.WriteUeV(numRefIdxL1ActiveMinus1);
            stream.WriteU1(weightedPredFlag);
            stream.WriteUv(2, weightedBipredIdc);
            stream.WriteSeV(picInitQpMinus26);
            stream.WriteSeV(picInitQsMinus26);
            stream.WriteSeV(chromaQpIndexOffset);
            stream.WriteU1(deblockingFilterControlPresentFlag);
            stream.WriteU1(constrainedIntraPredFlag);
            stream.WriteU1(redundantPicCntPresentFlag);
            // copies the last couple of bits into the byte Buffer
            stream.Close();

            return (int)(stream.Length / 8);
        }