Opened 5 years ago

Closed 5 years ago

#297 closed enhancement (fixed)

some TMVP code that can be cleaned up

Reported by: LGE_VCC Owned by:
Priority: minor Milestone:
Component: VTM Version: VTM-5.0
Keywords: Cc: ksuehring, XiangLi, fbossen, jvet@…

Description (last modified by ksuehring)

This ticket is reporting that some TMVP code in VTM can be cleaned up without change of performance. (It’s not a bug.)

The following piece of TMVP code appeared four times in VTM5.0 (in getInterMergeCandidates, fillMvpCand, fillAffineMvpCand, getAffineMergeCand).
The four if/else branches below can be reduced to only one if statement and get identical result.

        Position posInCtu( posRB.x & pcv.maxCUWidthMask, posRB.y & pcv.maxCUHeightMask );

        if( ( posInCtu.x + 4 < pcv.maxCUWidth ) &&           / / is not at the last column of CTU
            ( posInCtu.y + 4 < pcv.maxCUHeight ) )           / / is not at the last row    of CTU
        {
          posC0 = posRB.offset( 4, 4 );
          C0Avail = true;
        }
        else if( posInCtu.x + 4 < pcv.maxCUWidth )           / / is not at the last column of CTU But is last row of CTU
        {
          posC0 = posRB.offset( 4, 4 );
          / / in the reference the CTU address is not set - thus probably resulting in no using this C0 possibility
        }
        else if( posInCtu.y + 4 < pcv.maxCUHeight )          / / is not at the last row of CTU But is last column of CTU
        {
          posC0 = posRB.offset( 4, 4 );
          C0Avail = true;
        }
        else / / is the right bottom corner of CTU
        {
          posC0 = posRB.offset( 4, 4 );
          / / same as for last column but not last row
        }

In the above code, the 4 branches and the resulting C0Avail are as follows:

     posInCtu.x+4<pcv.maxCUWidth      posInCtu.y+4<pcv.maxCUHeight     C0Avail
(1)  true                             true                             true
(2)  true                             false                            false
(3)  false                            true                             true
(4)  false                            false                            false

As can be seen from the combinations, given posInCtu.y , the true/false branches with posInCtu.x can be merged together, so the check on posInCtu.x is unnecessary, and above logic is identical to

      int posYInCtu = posRB.y & pcv.maxCUHeightMask;
      if (posYInCtu + 4 < pcv.maxCUHeight)
      {
        posC0 = posRB.offset(4, 4);
        C0Avail = true;
      }

I already tested this simplification, and got identical results on the top of VTM5.0.

In addition, TMVP code appeared many times in VTM. It would be desirable to put it into a function.

Best.

Jane

Change history (4)

comment:1 Changed 5 years ago by ksuehring

  • Description modified (diff)

comment:2 Changed 5 years ago by ksuehring

Can you please submit a merge request for the change?

comment:4 Changed 5 years ago by XiangLi

  • Resolution set to fixed
  • Status changed from new to closed

Cleaned as suggested in https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM/merge_requests/581. No impact on coding performance.

Note: See TracTickets for help on using tickets.