1. 02 Feb, 2018 1 commit
    • Debargha Mukherjee's avatar
      Don't use extra lines for r=2 guided filter · f7d1ff49
      Debargha Mukherjee authored
      Changes the CONFIG_FAST_SGR=1 strategy to not use any
      subsampling for the r=1 filter, but for the r=2 filter
      sub-sample vertically but combine only by filtering
      horizontally in the last stage for odd rows.
      
      Coding efficiency loss sems quite minimal.
      
      Change-Id: I5644ac400b387c37a2d278db7f6ad3ac0a6b5e93
      f7d1ff49
  2. 31 Jan, 2018 1 commit
    • Debargha Mukherjee's avatar
      Merge in STRIPED_LOOP_RESTORATION flag · 5105f7ac
      Debargha Mukherjee authored
      CONFIG_LOOP_RESTORATION still exists.
      Only CONFIG_STRIPED_LOOP_RESTORATION has been merged into
      CONFIG_LOOP_RESTORATION as always 1.
      
      Change-Id: I37d7a1fcd4cbb56e2fc037b1568ae63f72ed6a66
      5105f7ac
  3. 29 Jan, 2018 1 commit
  4. 24 Jan, 2018 1 commit
    • Debargha Mukherjee's avatar
      Add a config flag/code for fast sgr computation · ed5e9673
      Debargha Mukherjee authored
      Adds an experiment for fast sgr computation where for the r=2
      filter, computation of the A, B stats are computed for every
      other row and averaged in between.
      The motivation is to improve software performance with hopefully
      minimal loss.
      
      Change-Id: Ie36687826524dc18c1fbb7f6becff244187bf8da
      ed5e9673
  5. 23 Jan, 2018 2 commits
    • Imdad Sardharwalla's avatar
      Don't calculate chroma data in monochrome mode · af8e2648
      Imdad Sardharwalla authored
      Encoder: Prior to this patch, some chroma data was calculated and
      later discarded when in monochrome mode. This patch ensures that
      the chroma planes are left uninitialised and that chroma
      calculations are not performed.
      
      Decoder: Prior to this patch, some chroma calculations were still
      being performed in monochrome mode (e.g. loop filtering). This
      patch ensures that calculations are only performed on the y
      plane, with the chroma planes being set to a constant.
      
      Change-Id: I394c0c9fc50f884e76a65e6131bd6598b8b21b10
      af8e2648
    • Imdad Sardharwalla's avatar
      Fix Valgrind warning in av1_pick_filter_restoration · b08544de
      Imdad Sardharwalla authored
      Some array elements were defined and left uninitialised. This wasn't causing a
      problem, as the elements were later ignored, but it did cause Valgrind to
      produce warnings.
      
      The function now initialises the full array immediately after its definition in
      order to quiet these warnings.
      
      BUG=aomedia:1244
      
      Change-Id: I5083f1f4008cb3ab70a4af4d1d2573dee8793303
      b08544de
  6. 16 Jan, 2018 1 commit
    • David Barker's avatar
      loop-restoration: Only use upscaled height · 21f43073
      David Barker authored
      The superres upscale process only generates cm->height many rows
      of pixels, but we were previously using cm->mi_rows*MI_SIZE many.
      The latter number are easily available before upscaling, but we
      ideally don't want to have to upscale extra rows. So we switch
      to only using cm->height many rows inside loop-restoration.
      
      While making this change, I found and fixed an issue with
      av1_get_tile_rect() when using horizontal subsampling + horizontal
      superres.
      
      Finally, note that this change does introduce an edge case which
      isn't obvious from the source code. This has been annotated as a
      comment in save_deblock_boundary_lines().
      
      Change-Id: Ide2bd433d45baa0fb1198353d05eb21b9a903157
      21f43073
  7. 27 Dec, 2017 1 commit
  8. 19 Dec, 2017 1 commit
    • Lei's avatar
      add new experiment loopfiltering_across_tiles_ext · 7bb501d5
      Lei authored
      based on the latest discussion in the HW working group about how loop
      filter should be integrated with tiles, the following decisions have been
      made:
      1. two seperated flages should be added for
      loop_filter_across_tiles_enabled for horizontal tile boundary and
      vertical tile boundary.
      2. encoder and decoder should only check these two flags to determine
      whether loop filtering (including deblocking, CDEF and loop restoration)
      should cross tile boundaries (vertical and/or horizontal) or not
      regardless the horitontal depepdent tile flag.
      
      This change list implemented the support for two seperated
      loop_filter_across_tiles_enabled flags for vertical and horizontal tile
      boundaries. The new experiment is disabled as default before it is
      adopted.
      
      Change-Id: I814377947517f5419c08b004a3b71b950d01eadd
      7bb501d5
  9. 28 Nov, 2017 1 commit
  10. 23 Nov, 2017 3 commits
    • Rupert Swarbrick's avatar
      Refactor to allow optimization in SGR code · 13927866
      Rupert Swarbrick authored
      The first stage of the selfguided filter is to generate box sums of
      the input image (and its squares). This is done with a pair of
      integral images, which are the same for both calls in
      apply_selfguided_restoration.
      
      This patch refactors things so that av1_selfguided_restoration
      calculates both "flt" buffers, allowing it to reuse the integral
      images that it calculated.
      
      Change-Id: Ica2f6f66e41bea38eb1a135c78c1d7ddab434d8e
      13927866
    • Rupert Swarbrick's avatar
      Get rid of the highbd versions of the SGR code · 625e50bd
      Rupert Swarbrick authored
      This doesn't have a big performance impact, and it's rather simpler
      just having one version of everything.
      
      Change-Id: I5fa5e7640a63d0ccb0c371f266c6eee99d9520f9
      625e50bd
    • Rupert Swarbrick's avatar
      Remove unused highpass filter from SGR code · 7cf60961
      Rupert Swarbrick authored
      Change-Id: Ifac3a3bf620061865b82b986d6b16bcabd96a187
      7cf60961
  11. 17 Nov, 2017 1 commit
    • David Barker's avatar
      striped-loop-restoration: Use consistent frame height · 9cf9e28c
      David Barker authored
      The stripes are intended to extend down to the full decoded
      height of the frame, which is always a multiple of 8 luma pixels,
      in order to avoid some nasty edge cases.
      
      This change was partially implemented in previous patches, but
      not everywhere was modified, leading to slightly inconsistent code.
      This patch finishes making the relevant changes, along with a
      slight bit of refactoring.
      
      Change-Id: Ibc8e2f5ace5415815625edbc224557a7c548c38a
      9cf9e28c
  12. 12 Nov, 2017 1 commit
  13. 07 Nov, 2017 1 commit
    • Rupert Swarbrick's avatar
      striped-loop-restoration: Respect tile experiments · 921b334f
      Rupert Swarbrick authored
      As of patch https://aomedia-review.googlesource.com/c/aom/+/28821 ,
      loop-restoration units cannot cross tile borders. But the context
      around each processing unit was still allowed to cross tile borders.
      This is fine in the usual case - but, when loop filtering across tiles
      is switched off, we're supposed to be able to decode each tile completely
      independently (each tile column, if dependent-horztiles is on).
      
      Roughly, the change we need to make is:
      When loop filtering across tiles is switched off, we treat each tile
      as if it were a full frame, and extend the CDEF output for that tile
      to form a 3-pixel border around the tile. We only use deblocked
      above/below pixels for processing unit boundaries which lie inside
      a tile.
      
      In terms of the code, this is implemented in two parts. This only
      applies when the loop_filter_across_tiles_flag is false; otherwise,
      we keep the old behaviour.
      
      * For processing units at the top edge of a tile, fill the above context
        with copies of the topmost line of CDEF output *from the same tile*,
        rather than using deblocked pixels from the tile above.
        The below context of processing units at the bottom edge of a tile
        is treated analogously.
      
      * When setting up the boundary for a processing stripe at the left edge
        of a tile, fill the stripe's left boundary with copies of the
        leftmost column of CDEF output from the same tile. Again, processing
        stripes at the right edge of a tile are treated analogously.
      
        Similarly to the above/below boundaries, we store the overwritten
        pixels into a pair of left/right context buffers, and restore them
        to their original values once we've dealt with that processing stripe.
      
      Change-Id: I53a0932793c1c56dc037683c6a4353a3f5dc4539
      921b334f
  14. 02 Nov, 2017 4 commits
    • Rupert Swarbrick's avatar
      Correct striped-loop-restoration with multiple tile rows · dee00eb0
      Rupert Swarbrick authored
      Before this patch, striped loop restoration didn't restart correctly
      on each tile row. Now, the loop restoration stripes start at the top
      of a tile row in the same way as if it were the top of the entire
      frame.
      
      Change-Id: I0a88a28d7804b2f09d792ecbbf4f22f666f67012
      dee00eb0
    • Rupert Swarbrick's avatar
      Get rid of RestorationInfo::procunit_height and width · cb493d82
      Rupert Swarbrick authored
      These are just RESTORATION_PROC_UNIT_SIZE shifted right by the
      vertical or horizontal subsampling for this plane and it's easier not
      to have to pass them around.
      
      Change-Id: I86441d6cd86bb146f3e5dcdf2c89e34dd9fed0e1
      cb493d82
    • David Barker's avatar
      Refactor search_selfguided_restoration · bfbd8b39
      David Barker authored
      Pull the per-unit processing out into a couple of new functions,
      to make the overall logic of search_selfguided_restoration()
      a bit more obvious
      
      Change-Id: Ib4ed9be7d4c76e22dc56f933f3f9d09160242f71
      bfbd8b39
    • Rupert Swarbrick's avatar
      Refactor border treatment in loop restoration · 5b401364
      Rupert Swarbrick authored
      Previously we were calling aom_extend_frame_borders to generate
      extended pixels for use in loop-restoration. This generates quite a
      large border, when we only need 3 pixels.
      
      In addition, we were also calling extend_frame, which does the same
      thing but with a smaller border, once (in the decoder) or multiple
      times (in the encoder) per plane.
      
      This patch tidies all of this up so that we only call extend_frame
      once per plane, with the largest border size we need (3px).
      
      It also adds two new #defines. RESTORATION_BORDER is the 3 pixel
      border needed to do filtering for a processing
      unit. RESTORATION_CTX_VERT is the number of rows saved for each stripe
      when doing striped loop restoration.
      
      Change-Id: I2c3ffcc19808f79db195f76d857e2f23da5d8a84
      5b401364
  15. 26 Oct, 2017 1 commit
    • Rupert Swarbrick's avatar
      Stop loop rest units from straddling tile boundaries · bcb65fe6
      Rupert Swarbrick authored
      With this patch, restoration units are allocated within each tile as
      if it were its own image. Arrays of information that need one entry
      per restoration unit are laid out in tiles, with rsi->units_per_tile
      units for each tile.
      
      Change-Id: I485c17166f33e24d281079b3138b76f98f0fe081
      bcb65fe6
  16. 25 Oct, 2017 2 commits
    • Rupert Swarbrick's avatar
      Define av1_foreach_rest_unit_in_frame · 33ed9e69
      Rupert Swarbrick authored
      This is the last stage in a quest to move all knowledge of the layout
      of restoration units across the frame into restoration.c. Now this is
      done, we can change how they are laid out (to split them properly at
      tile boundaries) without having to change code in any other file.
      
      Change-Id: Id5108d787d342f5070580d0e34d84b5ddcc53a86
      33ed9e69
    • Rupert Swarbrick's avatar
      Simplify the search in pickrst.c · 1a96c3f5
      Rupert Swarbrick authored
      The end results should be essentially the same, except hopefully a
      little better because the previous code got the costing slightly
      wrong if there were multiple tiles.
      
      The code was doing something quite complicated to search for the best
      restoration types; this patch makes it much simpler. Basically,
      av1_pick_filter_restoration loops over the planes in the image. For
      each plane, it loops over the possible restoration types, calling
      search_rest_type for each one.
      
      search_rest_type iterates over the restoration units in the image,
      resetting the current context on tile boundaries and calling
      search_<rest_type> for each restoration unit.
      
      The search_norestore function just computes the SSE error with no
      restoration. The search_wiener and search_sgrproj functions compute
      the best set of coefficients and then the resulting SSE error with
      those coefficients (ignoring the bit cost, so the result can be
      re-used for switchable restoration).
      
      In all cases but search_norestore, the search function has to decide
      what restoration type is best for each restoration unit. For example,
      search_wiener could choose to enable or disable Wiener filtering on
      this unit.
      
      Eventually, search_rest_type calculates the RDCOST after summing bit
      rates and SSE errors over the restoration units. This cost gets
      returned to av1_pick_filter_restoration which can then choose the best
      frame-level restoration type.
      
      Change-Id: I9bc17eb47cc46413adae749a43a440825c41bba6
      1a96c3f5
  17. 24 Oct, 2017 2 commits
    • Rupert Swarbrick's avatar
      Make pickrst.c more efficient · 2ec2a6f1
      Rupert Swarbrick authored
      The try_restoration_tile function now works by calling
      av1_loop_restoration_filter_unit rather than
      av1_loop_restoration_filter_frame. This is rather more efficient,
      because it only works on the unit in question, rather than memcpy-ing
      the rest of the frame.
      
      Change-Id: I7cda078523202bec77e933e7b5bd2f34daae5865
      2ec2a6f1
    • Rupert Swarbrick's avatar
      Expose av1_loop_restoration_filter_unit in restoration.h · dd6f09ab
      Rupert Swarbrick authored
      This patch also does a certain amount of rejigging for loop
      restoration coefficients, grouping the information for a given
      restoration unit into a structure called RestorationUnitInfo. The end
      result is to completely dispense with the RestorationInternal
      structure.
      
      The copy_tile functions in restoration.c, together with those
      functions that operate on a single stripe, have been changed so that
      they take pointers to the top-left corner of the area on which they
      should work, together with a width and height.
      
      The same isn't true of av1_loop_restoration_filter_unit, which still
      takes pointers to the top-left of the tile. This is because you
      actually need the absolute position in the tile in order to do striped
      loop restoration properly.
      
      Change-Id: I768c182cd15c9b2d6cfabb5ffca697cd2a3ff9e1
      dd6f09ab
  18. 20 Oct, 2017 1 commit
  19. 19 Oct, 2017 4 commits
    • Rupert Swarbrick's avatar
      General tidy-ups in loop restoration code · d3d0615e
      Rupert Swarbrick authored
      This refactors the iteration in restoration.c so that all the scary
      stuff lies in a pair of general functions, filter_frame and
      filter_rest_unit.
      
      filter_frame is currently very simple, iterating over the restoration
      units in the frame. Once we've made it so that restoration units don't
      span tile boundaries, this function is the one we'll need to update to
      iterate over tiles and then restoration units within the tile.
      
      filter_rest_unit replaces the outer loop of the loop_*_filter_tile*
      functions. It deals with chopping the restoration unit into stripes of
      height procunit_height. When CONFIG_STRIPED_LOOP_RESTORATION is true,
      it also deals with calling setup_processing_stripe_boundary and
      restore_processing_stripe_boundary to use boundary data from the
      deblocked output.
      
      Some of the ugly #if/#endif blocks have been elided in the wiener
      filter code (both low and high bit depth), by defining a convolve
      alias based on USE_WIENER_HIGH_INTERMEDIATE_PRECISION.
      
      There are also changes to extend const-ness for the source frame. I've
      adopted the convention that the frame input is called "data" (as it
      was before) while it's non-const. This is true as far as
      filter_rest_unit. Then each "process one stripe" function takes a
      const pointer to the source frame, at which point it's called "src".
      
      The intention is that, once filter_rest_unit no longer needs a
      RestorationInternal pointer, this function can be exposed in
      restoration.h and can be used by pickrst.c
      
      Change-Id: I18043a172ef0ca1154d87cf7f63e3a80944627cd
      d3d0615e
    • Rupert Swarbrick's avatar
      Remove partial_frame support from loop restoration · 146a060a
      Rupert Swarbrick authored
      This flag comes from the loop filter's speed features and (I think)
      tells the encoder to make decisions about the filter by looking at a
      narrow strip in the middle of the frame.
      
      That's reasonable enough, but doesn't make any sense for loop
      restoration, where we were calling av1_loop_restoration_frame from
      pickrst.c in order to calculate what restoration parameters to use for
      a given restoration unit (which might not be in the narrow strip in
      the middle!)
      
      As it turns out, the LPF_PICK_FROM_SUBIMAGE method is never actually
      signalled in the reference encoder, which is presumably why we haven't
      spotted this before.
      
      Change-Id: I745e2eab873c0b33920caca40e338af9d078d25e
      146a060a
    • Rupert Swarbrick's avatar
      Remove RestorationInternal from AV1_COMMON · f88bc049
      Rupert Swarbrick authored
      The bits needed by striped loop restoration are now in
      RestorationInfo (which also gets rid of a rather ugly extra
      index).
      
      The scratch buffer that's used for self-guided restoration has been
      moved up to its own variable (rst_tmpbuf).
      
      All the rest of the fields are now safely hidden inside restoration.c
      
      This patch also does a big cleanup of the initialisation code in
      loop_restoration_rows: it doesn't need to be as repetitive now that
      the fields of YV12_BUFFER_CONFIG can be accessed by plane index.
      
      Change-Id: Iba7edc0f94041fa053cdeb3d6cf35d84a05dbfaf
      f88bc049
    • Rupert Swarbrick's avatar
      Don't compute rtile width/height in av1_get_rest_ntiles · 64b8bbdf
      Rupert Swarbrick authored
      Restoration units are a fixed square size (in cm->rst_info[plane]) for
      almost the entire image. The only special case is for tiles at the
      right hand edge or the bottom row, which might expand or be cropped.
      
      The av1_get_rest_ntiles function was implementing the cropping
      behaviour when the image happened to be less than one restoration unit
      wide or high (but not the expansion behaviour), but the result was
      never useful: if you want to get the size of a restoration tile in
      order to divide by it to work out what tile you're on, the fixed
      square size is what you want. If you need to know how big this
      particular tile is, call av1_get_rest_tile_limits.
      
      As well as removing the output arguments from
      av1_get_rest_tile_limits, this patch also removes the tile_width and
      tile_height fields from the RestorationInternal structure. Note that
      the tile size which is what you actually need is accessible as
      rst->rsi->restoration_tilesize. (In practice, these were almost always
      the same anyway).
      
      This patch also has a couple of other small cleanups. Firstly, it
      moves the subsampling_y field out of
      CONFIG_STRIPED_LOOP_RESTORATION. It's not actually needed when you're
      not doing striped loop restoration, but this gets rid of lots of
      horrible #if/#endif lines at callsites for av1_get_rest_tile_limits.
      
      Secondly, it simplifies the code in init_rest_search_ctxt (and fixes
      some tautologous assertions). Now that YV12_BUFFER_CONFIG has a more
      uniform layout, there's a simpler way to set things up, so we use
      that.
      
      Change-Id: I3c32d8ea0abe119dc86b9efa7564b27dde2151dc
      64b8bbdf
  20. 13 Oct, 2017 1 commit
  21. 10 Oct, 2017 1 commit
  22. 08 Oct, 2017 1 commit
  23. 07 Oct, 2017 2 commits
    • Urvang Joshi's avatar
      FRAME_SUPERRES: Rework to use scale factor of 8/D · de71d142
      Urvang Joshi authored
      Earlier, the superres scale was in the form of:
      N/16, where N ranged from 8 to 16.
      
      We change this to the form:
      8/D, where D ranges from 8 to 16.
      
      This helps on the decoder side, by making it possible to work on 8x8
      blocks at a time.
      
      Change-Id: I6c72d4b3e8d1c830e61d4bb8d7f6337a100c3064
      de71d142
    • Rupert Swarbrick's avatar
      Upscale frame correctly in foreach_rtile_in_tile · b66894ac
      Rupert Swarbrick authored
      The restoration tiles (rtiles) divide the upscaled frame, not the
      encoded one.
      
      Change-Id: I2d08fe926d694fee7064461685289d3fd1c1de0c
      b66894ac
  24. 05 Oct, 2017 1 commit
  25. 04 Oct, 2017 1 commit
    • Dominic Symes's avatar
      Fix for issue 844 · c27f5424
      Dominic Symes authored
      Change the foreach_rtile_in_tile() function to call av1_tile_set_row/col
      to calculate tile borders, rather than calculate tile borders itself.
      This will then allow variable sized tiles.
      
      Also remove some unused set tile width/height defines from aomcx.h
      
      BUG=aomedia:844
      
      Change-Id: I356c90cb4189b904ca1d6e57939582b2e92f3162
      c27f5424
  26. 01 Oct, 2017 1 commit
  27. 28 Sep, 2017 1 commit
    • Ola Hugosson's avatar
      Add striped_loop_restoration experiment · 1e7f2d0c
      Ola Hugosson authored
      This experiment offset the filter tile grid 8 pixels upwards.
      Deblocked pixels (rather than CDEFed pixels) are used for the
      2 lines above and below the filter processing unit. The 8 pixel
      offset is the offset produced by deblock/cdef. This way the
      loop_restoration does not need additional line buffers in a
      single pass hardware implementation.
      
      Change-Id: I89e0831dc28413a5d3e02d7a426ce2885ab629d7
      1e7f2d0c
  28. 26 Sep, 2017 1 commit
    • Rupert Swarbrick's avatar
      Simplify av1_get_rest_tile_limits · 5d2e729e
      Rupert Swarbrick authored
      The subtile and clamping features are no longer used. This patch
      removes the dead code that implemented them and the parameters to
      support them.
      
      It also changes the return format. Instead of having return type void
      and passing data out through 4 output pointers, the function now just
      returns a RestorationTileLimits structure. Since the function is
      defined inline in a header, I suspect that most callsites will
      actually compile to identical code.
      
      There should be no functional change from this patch.
      
      Change-Id: I6ebc4da66a00676bd988f939a4b4957f743e8004
      5d2e729e