[x264-devel] Delete the huge memory leak in x264.

alexander tian tian.alexandertian at gmail.com
Thu Sep 4 11:17:04 CEST 2008


Hi Prashanth

I advise that you'd better to change the function
"x264_mb_analyse_load_costs". I changed the function from
"x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a )" to
"x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a, int i_end )".

In the origin function you should set parameter "i_end" to 0. At the end of
the encoding you should call the function and set the "i_end" to 1. Belows
are new function:
static void x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a,
int i_end )
{
    static int16_t *p_cost_mv[52];

    if(i_end == 1)
    {
        int j;
        for(j=0; j<52; j++)
            if(p_cost_mv[j])
            {
                x264_free(p_cost_mv[j] - 2*4*2048);
                p_cost_mv[j] = NULL;
            }

        return;
    }

    if( !p_cost_mv[a->i_qp] )
    {
        /* could be faster, but isn't called many times */
        /* factor of 4 from qpel, 2 from sign, and 2 because mv can be
opposite from mvp */
        int i;
        p_cost_mv[a->i_qp] = x264_malloc( (4*4*2048 + 1) * sizeof(int16_t)
);
        p_cost_mv[a->i_qp] += 2*4*2048;
        for( i = 0; i <= 2*4*2048; i++ )
        {
            p_cost_mv[a->i_qp][-i] =
            p_cost_mv[a->i_qp][i]  = a->i_lambda * bs_size_se( i );
        }
    }

    a->p_cost_mv = p_cost_mv[a->i_qp];
}

Best wishes,
Alexander tian



2008/8/27 Prashanth Nandala <prashanth.nandala at patni.com>

>  Hi tian and Everyone
>
>
>
> Can you tell me how to free "*p_cost_mv[52]" this variable.
>
>
>
> Thanks & regards
>
> Prashanth
>
> http://www.patni.com
> World-Wide Partnerships. World-Class Solutions.
> _____________________________________________________________________
>
> This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to whom this
> message was originally addressed. Any review, e-transmission dissemination
> or other use of or taking of any action in reliance upon this information by
> persons or entities other than the intended recipient is prohibited. If you
> have received this e-mail in error kindly delete this e-mail from your
> records. If it appears that this mail has been forwarded to you without
> proper authority, please notify us immediately at netadmin at patni.com and
> delete this mail.
> _____________________________________________________________________
>
> _______________________________________________
> x264-devel mailing list
> x264-devel at videolan.org
> http://mailman.videolan.org/listinfo/x264-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.videolan.org/pipermail/x264-devel/attachments/20080904/6a8ec25e/attachment.htm 


More information about the x264-devel mailing list