[x265] [PATCH] Lookahead: Changed the input param type for slicetype_frame_cost()

Steve Borho steve at borho.org
Thu Aug 8 08:27:07 CEST 2013


On Thu, Aug 8, 2013 at 12:43 AM, <gopu at multicorewareinc.com> wrote:

> # HG changeset patch
> # User ggopu
> # Date 1375940585 -19800
> # Node ID 043eee697add99e2516193cf6afae2e7935b582b
> # Parent  2cc927f1dfe575f2afc34a313a9ed42eb577fef6
> Lookahead: Changed the input param type for slicetype_frame_cost()
>
> diff -r 2cc927f1dfe5 -r 043eee697add source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp      Thu Aug 08 10:45:18 2013 +0530
> +++ b/source/encoder/slicetype.cpp      Thu Aug 08 11:13:05 2013 +0530
> @@ -36,44 +36,41 @@
>  #include "lookahead.h"
>
>  #define NUM_MBS \
> -    (fenc.cuWidth > 2 && fenc.cuHeight > 2 ? \
> -     (fenc.cuWidth - 2) * (fenc.cuHeight - 2) : \
> -     fenc.cuWidth * fenc.cuHeight)
> +    (frames[b]->cuWidth > 2 && frames[b]->cuHeight > 2 ? \
> +     (frames[b]->cuWidth - 2) * (frames[b]->cuHeight - 2) : \
> +     frames[b]->cuWidth * frames[b]->cuHeight)
>
> -int slicetype_frame_cost(x265::LookaheadFrame *frames, int p0, int p1,
> int b, int bIntraPenalty);
> +int slicetype_frame_cost(x265::LookaheadFrame **frames, int p0, int p1,
> int b, int bIntraPenalty);
>
> -int slicetype_frame_cost(x265::LookaheadFrame *frames, int p0, int p1,
> int b, int bIntraPenalty)
> +int slicetype_frame_cost(x265::LookaheadFrame **frames, int p0, int p1,
> int b, int bIntraPenalty)
>  {
>      int score = 0;
>      int do_search[2];
> -    x265::LookaheadFrame fenc;
>

you can still use fenc in this function, it just needs to be declared as a
pointer


>
> -    fenc = frames[b];
> -
> -    if (fenc.costEst[b - p0][p1 - b] >= 0 && fenc.rowSatds[b - p0][p1 -
> b][0] != -1)
> -        score = fenc.costEst[b - p0][p1 - b];
> +    if (frames[b]->costEst[b - p0][p1 - b] >= 0 && frames[0]->rowSatds[b
> - p0][p1 - b][0] != -1)
> +        score = frames[b]->costEst[b - p0][p1 - b];
>      else
>      {
>          int dist_scale_factor = 128;
> -        x265::MV *we = fenc.lowresMvs[0][b - p0 - 1];
> -        int *row_satd = fenc.rowSatds[b - p0][p1 - b];
> +        x265::MV *we = frames[b]->lowresMvs[0][b - p0 - 1];
> +        int *row_satd = frames[b]->rowSatds[b - p0][p1 - b];
>
>          /* For each list, check to see whether we have lowres
> motion-searched this reference frame before. */
> -        do_search[0] = b != p0 && fenc.lowresMvs[0][b - p0 - 1][0].x ==
> 0x7FFF;
> -        do_search[1] = b != p1 && fenc.lowresMvs[1][p1 - b - 1][0].x ==
> 0x7FFF;
> +        do_search[0] = b != p0 && frames[b]->lowresMvs[0][b - p0 -
> 1][0].x == 0x7FFF;
> +        do_search[1] = b != p1 && frames[b]->lowresMvs[1][p1 - b -
> 1][0].x == 0x7FFF;
>
>          if (do_search[0])
>          {
> -            fenc.lowresMvs[0][b - p0 - 1][0] = 0;
> +            frames[b]->lowresMvs[0][b - p0 - 1][0] = 0;
>          }
>
> -        if (do_search[1]) fenc.lowresMvs[1][p1 - b - 1][0] = 0;
> +        if (do_search[1]) frames[b]->lowresMvs[1][p1 - b - 1][0] = 0;
>
>          if (p1 != p0)
>              dist_scale_factor = (((b - p0) << 8) + ((p1 - p0) >> 1)) /
> (p1 - p0);
>
> -        fenc.costEst[b - p0][p1 - b] = 0;
> -        fenc.costEst[b - p0][p1 - b] = 0;
> +        frames[b]->costEst[b - p0][p1 - b] = 0;
> +        frames[b]->costEst[b - p0][p1 - b] = 0;
>
>          /* Lowres lookahead goes backwards because the MVs are used as
> predictors in the main encode.
>          * This considerably improves MV prediction overall. */
> @@ -81,35 +78,35 @@
>          /* The edge mbs seem to reduce the predictive quality of the
>          * whole frame's score, but are needed for a spatial distribution.
> */
>
> -        if (fenc.cuWidth <= 2 || fenc.cuHeight <= 2)
> +        if (frames[b]->cuWidth <= 2 || frames[b]->cuHeight <= 2)
>          {
> -            for (int i = fenc.cuWidth - 1; i >= 0; i--)
> +            for (int i = frames[b]->cuWidth - 1; i >= 0; i--)
>              {
>                  row_satd[i] = 0;
>              }
>
> -            for (int j = fenc.cuHeight - 1; j >= 0; j--)
> +            for (int j = frames[b]->cuHeight - 1; j >= 0; j--)
>              {
>                  //call slicetype_mb_cost()
>              }
>          }
>          else
>          {
> -            for (int i = fenc.cuWidth - 1; i >= 0; i--)
> +            for (int i = frames[b]->cuWidth - 1; i >= 0; i--)
>              {
> -                for (int j = fenc.cuHeight - 1; j >= 0; j--)
> +                for (int j = frames[b]->cuHeight - 1; j >= 0; j--)
>                  {
>                      //call slicetype_mb_cost()
>                  }
>              }
>          }
>
> -        score = fenc.costEst[b - p0][p1 - b];
> +        score = frames[b]->costEst[b - p0][p1 - b];
>
>          if (b != p1)
>              score = (uint64_t)score * 100 / (120) + 0;
>
> -        fenc.costEst[b - p0][p1 - b] = score;
> +        frames[b]->costEst[b - p0][p1 - b] = score;
>          x265_emms();
>      }
>
> @@ -117,11 +114,13 @@
>      {
>          // arbitrary penalty for I-blocks after B-frames
>          int nmb = NUM_MBS;
> -        score += (uint64_t)score * fenc.intraMbs[b - p0] / (nmb * 8);
> +        score += (uint64_t)score * frames[b]->intraMbs[b - p0] / (nmb *
> 8);
>      }
>      return score;
>  }
>
> +
> +
>  #if 0
>  // Indexed by pic_struct values
>  static const uint8_t delta_tfi_divisor[10] = { 0, 2, 1, 1, 2, 2, 3, 3, 4,
> 6 };
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>



-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130808/1ec07322/attachment.html>


More information about the x265-devel mailing list