diff --git a/libde265/deblock.cc b/libde265/deblock.cc index 60fd2ca1..fd32aab7 100644 --- a/libde265/deblock.cc +++ b/libde265/deblock.cc @@ -256,6 +256,8 @@ void derive_boundaryStrength(de265_image* img, bool vertical, int yStart,int yEn int TUShift = img->get_sps().Log2MinTrafoSize; int TUStride= img->get_sps().PicWidthInTbsY; + printf("bs1\n"); + for (int y=yStart;yget_mv_info(xDiOpp,yDiOpp); const PBMotion& mviQ = img->get_mv_info(xDi ,yDi); slice_segment_header* shdrP = img->get_SliceHeader(xDiOpp,yDiOpp); slice_segment_header* shdrQ = img->get_SliceHeader(xDi ,yDi); + printf("bs6\n"); + if (shdrP && shdrQ) { + + if (mviP.refIdx[0] > MAX_NUM_REF_PICS || + mviP.refIdx[1] > MAX_NUM_REF_PICS || + mviQ.refIdx[0] > MAX_NUM_REF_PICS || + mviQ.refIdx[1] > MAX_NUM_REF_PICS) { + // we cannot return an error from here, so just set a valid boundaryStrength value and continue; + img->set_deblk_bS(xDi, yDi, 0); + continue; + } + int refPicP0 = mviP.predFlag[0] ? shdrP->RefPicList[0][ mviP.refIdx[0] ] : -1; int refPicP1 = mviP.predFlag[1] ? shdrP->RefPicList[1][ mviP.refIdx[1] ] : -1; int refPicQ0 = mviQ.predFlag[0] ? shdrQ->RefPicList[0][ mviQ.refIdx[0] ] : -1; int refPicQ1 = mviQ.predFlag[1] ? shdrQ->RefPicList[1][ mviQ.refIdx[1] ] : -1; + printf("bs7\n"); + bool samePics = ((refPicP0==refPicQ0 && refPicP1==refPicQ1) || (refPicP0==refPicQ1 && refPicP1==refPicQ0)); @@ -371,9 +389,11 @@ void derive_boundaryStrength(de265_image* img, bool vertical, int yStart,int yEn } } + printf("bs10\n"); img->set_deblk_bS(xDi,yDi, bS); } else { + printf("bs11\n"); img->set_deblk_bS(xDi,yDi, 0); } } diff --git a/libde265/motion.cc b/libde265/motion.cc index b35343a7..9df146b8 100644 --- a/libde265/motion.cc +++ b/libde265/motion.cc @@ -1615,6 +1615,17 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, uint8_t out_availableFlagLXN[2], MotionVector out_mvLXN[2]) { + if (refIdxLX >= MAX_NUM_REF_PICS) { + ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false); + img->integrity = INTEGRITY_DECODING_ERRORS; + + out_availableFlagLXN[0] = false; + out_availableFlagLXN[1] = false; + out_mvLXN[0] = MotionVector{}; + out_mvLXN[1] = MotionVector{}; + return; + } + int isScaledFlagLX = 0; const int A=0; @@ -1642,6 +1653,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, // 3. / 4. + printf("ds1\n"); + bool availableA[2]; availableA[0] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[0],yA[0]); availableA[1] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[1],yA[1]); @@ -1656,22 +1669,36 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, int refIdxA=-1; + printf("ds2\n"); + printf("shdr: %p X:%d refIdxLx:%d\n", shdr, X, refIdxLX); + printf("image idx: %d\n", shdr->RefPicList[X][ refIdxLX ]); + // the POC we want to reference in this PB const de265_image* tmpimg = ctx->get_image(shdr->RefPicList[X][ refIdxLX ]); + printf("ds2.1\n"); + if (tmpimg==NULL) { return; } const int referenced_POC = tmpimg->PicOrderCntVal; for (int k=0;k<=1;k++) { + + printf("xA[k],yA[k]=%d %d\n",xA[k], yA[k]); + printf("get_pred_mode: %d\n", img->get_pred_mode(xA[k],yA[k])); + if (availableA[k] && out_availableFlagLXN[A]==0 && // no A?-predictor so far img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) { int Y=1-X; + printf("ds2.5\n"); + const PBMotion& vi = img->get_mv_info(xA[k],yA[k]); logtrace(LogMotion,"MVP A%d=\n",k); logmvcand(vi); + printf("ds3\n"); + const de265_image* imgX = NULL; if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); const de265_image* imgY = NULL; @@ -1698,6 +1725,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, } } + printf("ds4\n"); + // 7. If there is no predictor referencing the same POC, we take any other reference as // long as it is the same type of reference (long-term / short-term) @@ -1733,6 +1762,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, } } + printf("ds5\n"); + if (out_availableFlagLXN[A]==1) { if (refIdxA<0) { out_availableFlagLXN[0] = out_availableFlagLXN[1] = false; @@ -1771,6 +1802,7 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, } } + printf("ds6\n"); // --- B --- @@ -1806,6 +1838,7 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, logtrace(LogMotion,"MVP B%d=\n",k); logmvcand(vi); + printf("ds7\n"); const de265_image* imgX = NULL; if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); @@ -1831,6 +1864,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, // 4. + printf("ds8\n"); + if (isScaledFlagLX==0 && // no A predictor, out_availableFlagLXN[B]) // but an unscaled B predictor { @@ -1845,6 +1880,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, // 5. + printf("ds9\n"); + // If no A predictor, we output the unscaled B as the A predictor (above) // and also add a scaled B predictor here. // If there is (probably) an A predictor, no differing-POC B predictor is generated. @@ -1875,6 +1912,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, } } + printf("ds10\n"); + if (out_availableFlagLXN[B]==1) { if (refIdxB<0) { out_availableFlagLXN[0] = out_availableFlagLXN[1] = false; @@ -1909,6 +1948,8 @@ void derive_spatial_luma_vector_prediction(base_context* ctx, } } } + + printf("ds end\n"); }