[x265] [PATCH] cli: rewrite pts_queue to use new/delete

Steve Borho steve at borho.org
Tue Apr 7 02:27:08 CEST 2015


On 04/06, Xinyue Lu wrote:
> # HG changeset patch
> # User Xinyue Lu <i at 7086.in>
> # Date 1428359964 25200
> #      Mon Apr 06 15:39:24 2015 -0700
> # Branch Yuuki
> # Node ID 6de8cdf3795b7fbdfc2df5ae34cbc211676a561a
> # Parent  ebe5e57c4b45b45338035a1009b64585f21d66d5
> cli: rewrite pts_queue to use new/delete, not to confuse the leak tool

queued, this should resolve the false-positives reported by the leak
tool, thanks.

> diff -r ebe5e57c4b45 -r 6de8cdf3795b source/x265.cpp
> --- a/source/x265.cpp	Sat Apr 04 15:11:39 2015 -0500
> +++ b/source/x265.cpp	Mon Apr 06 15:39:24 2015 -0700
> @@ -507,8 +507,8 @@
>      x265_picture pic_orig, pic_out;
>      x265_picture *pic_in = &pic_orig;
>      /* Allocate recon picture if analysisMode is enabled */
> -    bool usePTS = cliopt.output->needPTS();
> -    x265_picture *pic_recon = (cliopt.recon || !!param->analysisMode || usePTS) ? &pic_out : NULL;
> +    std::priority_queue<int64_t>* pts_queue = cliopt.output->needPTS() ? new std::priority_queue<int64_t>() : NULL;
> +    x265_picture *pic_recon = (cliopt.recon || !!param->analysisMode || pts_queue) ? &pic_out : NULL;
>      uint32_t inFrameCount = 0;
>      uint32_t outFrameCount = 0;
>      x265_nal *p_nal;
> @@ -516,7 +516,6 @@
>      uint32_t nal;
>      int16_t *errorBuf = NULL;
>      int ret = 0;
> -    std::priority_queue<int64_t> pts_queue;
> 
>      if (!param->bRepeatHeaders)
>      {
> @@ -590,11 +589,11 @@
>          if (nal)
>          {
>              cliopt.totalbytes += cliopt.output->writeFrame(p_nal, nal, pic_out);
> -            if (usePTS)
> +            if (pts_queue)
>              {
> -                pts_queue.push(-pic_out.pts);
> -                if (pts_queue.size() > 2)
> -                    pts_queue.pop();
> +                pts_queue->push(-pic_out.pts);
> +                if (pts_queue->size() > 2)
> +                    pts_queue->pop();
>              }
>          }
> 
> @@ -616,11 +615,11 @@
>          if (nal)
>          {
>              cliopt.totalbytes += cliopt.output->writeFrame(p_nal, nal, pic_out);
> -            if (usePTS)
> +            if (pts_queue)
>              {
> -                pts_queue.push(-pic_out.pts);
> -                if (pts_queue.size() > 2)
> -                    pts_queue.pop();
> +                pts_queue->push(-pic_out.pts);
> +                if (pts_queue->size() > 2)
> +                    pts_queue->pop();
>              }
>          }
> 
> @@ -642,12 +641,14 @@
> 
>      int64_t second_largest_pts = 0;
>      int64_t largest_pts = 0;
> -    if (usePTS && pts_queue.size() >= 2)
> +    if (pts_queue && pts_queue->size() >= 2)
>      {
> -        second_largest_pts = -pts_queue.top();
> -        pts_queue.pop();
> -        largest_pts = -pts_queue.top();
> -        pts_queue.pop();
> +        second_largest_pts = -pts_queue->top();
> +        pts_queue->pop();
> +        largest_pts = -pts_queue->top();
> +        pts_queue->pop();
> +        delete pts_queue;
> +        pts_queue = NULL;
>      }
>      cliopt.output->closeFile(largest_pts, second_largest_pts);
> 
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel

-- 
Steve Borho


More information about the x265-devel mailing list