[x265] [PATCH] analysis: Intra picture estimation information sharing

Steve Borho steve at borho.org
Tue Sep 16 11:40:30 CEST 2014


On 09/16, Gopu Govindaswamy wrote:
> On Mon, Sep 15, 2014 at 4:10 PM, Steve Borho <steve at borho.org> wrote:
> > We should probably also be setting the analysis pointers to NULL in the
> > input picture structure prior to returning from x265_encoder_encode() so
> > they do not accidentally re-use the same buffers for more than one
> > picture.  In short, we need to be a lot more defensive about API abuses.
> >
> 
> i will make the separate patch for this, but still i need to verify on
> this, the analysis buffer is getting used to dump the analysis data into
> file after x265_encoder_encode(),

You can think of this in terms of ownership.

1. user calls x265_alloc_analysis_data(x265_picture*), the user now owns
   these buffers in the x265_picture.

2. user calls x265_encoder_encode() and the encoder copies the analysis
   pointers into the internal Frame structure. Now the encoder owns
   those buffers. The pointers in the input x265_picture are now
   redundant, the user should not read/write/or modify those buffers
   while the encoder owns them

3. Once the frame is encoded, the buffer pointers are copied into the
   output picture structure. Now the user owns them again. They can do
   what the wish, possibly release them.

this is true of both load and save

> > > +        }
> > > +        else
> > > +        {
> > > +            compressIntraCU(m_bestCU[0], m_tempCU[0], false, cu,
> > cu->m_CULocalData);
> > > +            if (m_param->analysisMode == 1)
> > > +            {
> > > +
> > memcpy(&m_bestCU[0]->m_pic->m_intraData->depth[cu->getAddr() *
> > cu->m_numPartitions], m_bestCU[0]->getDepth(), sizeof(uint8_t) *
> > cu->getTotalNumPart());
> > > +
> > memcpy(&m_bestCU[0]->m_pic->m_intraData->modes[cu->getAddr() *
> > cu->m_numPartitions], m_bestCU[0]->getLumaIntraDir(), sizeof(uint8_t) *
> > cu->getTotalNumPart());
> > > +
> > memcpy(&m_bestCU[0]->m_pic->m_intraData->partSizes[cu->getAddr() *
> > cu->m_numPartitions], m_bestCU[0]->getPartitionSize(), sizeof(char) *
> > cu->getTotalNumPart());
> > > +                m_bestCU[0]->m_pic->m_intraData->cuAddr[cu->getAddr()]
> > = cu->getAddr();
> > > +                m_bestCU[0]->m_pic->m_intraData->poc[cu->getAddr()]
> > = cu->m_pic->m_POC;
> > > +            }
> > >          }
> > >          if (m_param->bLogCuStats || m_param->rc.bStatWrite)
> > >          {
> > > @@ -533,7 +543,142 @@
> > >  #endif
> > >  }
> > >
> > > -void Analysis::checkIntra(TComDataCU*& outBestCU, TComDataCU*&
> > outTempCU, PartSize partSize, CU *cu)
> > > +void Analysis::sharedCompressIntraCU(TComDataCU*& outBestCU,
> > TComDataCU*& outTempCU, uint32_t depth, TComDataCU* cuPicsym, CU *cu,
> > uint8_t* sharedDepth, char* sharedPartSizes, uint8_t* sharedModes)
> > > +{
> > > +    Frame* pic = outBestCU->m_pic;
> > > +
> > > +    // if current depth == shared depth then skip further splitting.
> > > +    bool bSubBranch = true;
> > > +
> > > +    if (depth == 0)
> >
> > !depth
> >
> > > +    {
> > > +        // offset to next best depth in sharedDepth buffer
> > > +        m_zorder = 0;
> > > +
> > > +        // index to g_depthInc array to increment m_zorder offset to
> > next depth
> > > +        m_ctuToDepthIndex = m_param->maxCUSize / 22;
> >
> > this math is pretty magical. my guess is there's already a table
> > somewhere that does this more cleanly? Does this code work with
> > --ctu 16?
> >
> 
> i have verified and i don't find any such a table, but this logic works
> well for ctu size 64, 32 and 16, verified on this

I'm not doubting that it works, it's just not clear what it's doing. it
probably wants to be 1 << (g_maxCUDepth - 2) or something similar.

-- 
Steve Borho


More information about the x265-devel mailing list