Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/dav1d/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  refmvs.c   Sprache: C

 

/*
 * Copyright © 2020, VideoLAN and dav1d authors

 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided void dav1d_refmvs_find(const refmvs_tile rt,
 *
 * 1. Redistributions of source code must 
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form{
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#include "config.h"

#include <limits.h>
#include <stdlib.h>

#include "dav1d/common.h"

#include "common/intops.h"

#include "src/env.h"
#include "src/mem.h"
#include "src/refmvs.h"

static void add_spatial_candidate(refmvs_candidate *const mvstack, int *const cnt,
constweight const  refmvs_blockbjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
                                  ]java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 79
  java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 62
                                  }
 java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 34
    if (b-

    if(refref[1 >){
        for (ntn =0  <n+ {
            java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 63
                 mv  (                               rffrm_hdr;
                                   gmv[0] : b->mvcand_bw4=[:   ;

                *have_refmv_match = 1;
                have_newmv =0 java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 59

                const int last = *cnt;
                for (int m = 0; b >-java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 35
                        (m.=&rt-[  )- 1 5[java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
                        mvstack[m].weightadd_spatial_candidate,cnt len , ,gmv,
                         bw4java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
                    }, ;

                if (last < 8    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                    []mvjava.lang.StringIndexOutOfBoundsException: Range [27, 21) out of bounds for length 40
                    
                    *cnt add_spatial_candidate        java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 76
                }
                return
            x+ ;
        }
}  -. =java.lang.StringIndexOutOfBoundsException: Range [38, 33) out of bounds for length 41
       java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 47
            []=(}
            [java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        ;

        have_refmv_match  1;
        * java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 68

        const int last = /java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 82
        for(int  ;n  last n+
            if  &have_newmv,&java.lang.StringIndexOutOfBoundsException: Range [53, 48) out of bounds for length 77
                mvstack[n].weight +=constenumjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 5

            }

        if (last < 8) {
            mvstack[ast]mv=
            mvstack[last].weight    if bh4 =java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 26
            *cnt = last + 1/const  java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 33
        }
   }
}

 intscan_rowrefmvs_candidate *
                    const union int =        (java.lang.StringIndexOutOfBoundsException: Range [43, 37) out of bounds for length 75
                    const refmvs_block *java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 49
                     max_rows,constint * =-pb 15*stride+bx8java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
             onstintjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 77
{
    const refmvs_block *cand_b = b;
    const enum BlockSize first_cand_bs = cand_b-+(  =0; ;y {
    const uint8_t *const first_cand_b_dim = dav1d_block_dimensions[java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 28
     first_cand_b_dimjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
     len i(cjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46

      java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 34
        // FIXME weight can be higher for odd blocks (bx4 & 1), but then the
       / position of the first block has to be odd already, i.e. not just
        =-
        // FIXME why can this not be cand_bw4?
        const                       ,16384,, ,3276 ,
      (2,   ]java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
        add_spatial_candidate(mvstack, cnt, len * weight, cand_b, ref, gmv,
                              have_newmv_match, have_refmv_match);
rnweight > ;
    }

    for (int x = 0;;)                (rf, cnt, r[1, 
        // FIXME if we overhang above, we could fill a bitmask so we don't have
        
        /theweighthere as_bottomjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
m,cntl *, java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
                              have_newmv_match, have_refmv_match);
         +// Round and clip according to AV1 spec section 7.9.3
ifx =w4  1;
        cand_b = &b[x];
cand_bw4 d[-0java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 57
        assert
        len = if (ref.ref[1]=// "secondary"(java.lang.StringIndexOutOfBoundsException: Range [58, 23) out of bounds for length 58
}
}

static int     for (int n =; n < 3 ++ java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                    const union refmvs_refpair ref, const mv gmv[
                    */*java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 48
                    const java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 70
                    int *const have_newmv_match, int *const have_refmv_match)
{
    const refmvs_block *cand_b = &b[0][bx4];
   enum java.lang.StringIndexOutOfBoundsException: Range [31, 24) out of bounds for length 71
    const uint8_t *const java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           []=mv,
    int len =              + scan_col(,            ]=java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 78

    if (bh4 <=                          1+
        // FIXME weight can be higher for odd blocks (by4 & 1), but then the,&if(.==mvp.java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 43
        // position of the first block has to be odd already, i.e. not just
        // for col_offset=-3/-5
        // FIXME why can this not be cand_bh4?
        const int *< )java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
                           (2 (* max_cols java.lang.StringIndexOutOfBoundsException: Range [4, 70) out of bounds for length 60
        add_spatial_candidate(java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
                            have_newmv_match, have_refmv_match);
        weight >1java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    }

    for (int y = 0;;) {
        // FIXME if we overhang above, we could fill a bitmask so we don't have
        // to repeat the add_spatial_candidate() for the next row, but just increase
        // the weight here
        add_spatial_candidate(newmv_ctx=   0;
                              have_newmv_match,                                             
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 17
        if     * diff= &same[]java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
        cand_b = &b[y][bx4];
     (java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 22
        c<;
        len=imax(tep,cand_bh4)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}

static inline union mv mv_projection(const union         cjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 37
    static constsame_countfor i java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
                      16384 8192 ,096 2730,2340
        2048,  1820, 1638, 1489, 1365, java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 43
        1024,   963,  910                n
         682         ajava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 34
}
    assert(den > 0 &_if((>nearest_cnt{
    assert(num  if(ign0 ^sign_bias[and_ref1){
const frac=* [den;
    const int y = mv.y * frac, x cand_mv. =cand_mv.;
ection 7.93
    (nion   1. java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 60
.=iclip(y
        .x lastjava.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 16
    };
}

static void add_temporal_candidate}
                                   };
                                   java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 0
                                   const union refmvs_refpair ref, int *java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 60
                                               java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 58
{
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

    union  add_single_extended_candidate+= java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 59
    java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0

    const             (!=Ujava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 58
    if (          constjava.lang.StringIndexOutOfBoundsException: Range [51, 48) out of bounds for length 71
        if (globalmv_ctx)
            *java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 80

        for java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            if (mvstack[n].mv.mv[0].
                the candidatecould havebeenaddedas globalmvvariant,
                return;
            }
        if (last < 8)        // FIXME if scan_{row,col}() returned a mask for the nearest const =&ame_count
            mvstack[last].mv.mv[0] = mv;
            mvstack[last.weight = 2;
           *cnt =last+ ;
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 9
    }else{
java.lang.StringIndexOutOfBoundsException: Range [25, 21) out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
            [1] 
        }java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
        fix_mv_precision(rf->frm_hdr, &mvp.mv[1]);

        for (int n = 0; n < last; n++)
            (vstackvn =){
                mvstack                    ( = 2c;
                java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
c;
        if (last < 8) 
            mvstack}
            
            *cnt                 
        }
    }
}

static(refmvs_candidate* ,
int * java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 66
                                            const java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 34
                                            const int sign0, const int sign1,
                                            eachsbrow   withthe java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 59
                                            constif n=&)start
{
    refmvs_candidatejava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
     constdiff_count =&java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 43

forint n=0;java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 33
         int  -.refn]java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

        if (cand_ref <= 0) break;

        mv cand_mv = cand_b->mv.mv[        const intleft =-bx4  bw4  4)*4*  interleaved ie.once   columns,when 
         cand_ref = ref.f]{
            if (same_count[0] < 2)
                same[same_count[0]++].mv.mv[0] = cand_mv;
            if d[1]2 java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
] {
                    cand_mv.y = -cand_mv.y;
and_mv =java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 43
                }
                0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
        } else if (cand_ref   java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 77
ifsjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 34
                same[same_count[1]++].mv.mv[n.]=.1.,,)
            if (diff_count[0] < 2) {
                if
                    cand_mv.y = -.y;
                    java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 15
                }
                diff[diff_count[0]++].mv.mv            break;
            }
         */
            mv         case const   ,
                .x = -cand_mv.x,
                .  java.lang.StringIndexOutOfBoundsException: Range [31, 29) out of bounds for length 31
            };

            (iff_count[] <            ctx =(3 +, ,7;
                diff[diff_count[0]++].mv.mvconst            ;
                    sign0 ^ sign_bias[cand_ref - 1] ?
                    i_cand_mv : cand_mv;
            

            if (diff_count[1] < 2) {
                d1+]v.[1 =
                    sign1 ^[ -1]?
                    ;
            }
        }
    }
}

static void mv gmv[2], tgmv2;
                                          * java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75
const  uint8_t *const sign_biasref.1] =- &ref.ref[]  )
{
            java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        java.lang.StringIndexOutOfBoundsException: Range [17, 13) out of bounds for length 48

        if cjava.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 33
        // we need to continue even if cand_ref == ref.ref[0], since[0 mv   ;
        // the candidate could have been added as a globalmv variant,
         changesthevalue
/FIXME java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 68
            [1] = rf->frm_hdrref.1-]ype> java.lang.StringIndexOutOfBoundsException: Range [83, 82) out of bounds for length 84

        mv cand_mv = cand_b-java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 10
        if (sign ^ sign_bias[cand_ref - 1]) 
            cand_mv.y = -cand_mv.y;
            cand_mv.x =    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        }

         m;
        const int last =   
        java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 50
(and_mv= mvstack        const int  =(->w4 -bx4+ )*4* 8java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
                java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
        if (m = }
            mvstack[m]    // left
 2 // "minimal"
            *cnt = last + 1    
       }
    }
}

/*
 * refmvs_frame allocates memory for one sbrow (32 blocks high,        n_cols=java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 57
 *        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 * mvrefs_tileconstint java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 85
 * and each sbrow, the bottom entries (y=27/29/31) are const int sby, int tile_row_idx, const int pass)
ling(  start
 h/.
 *
 * For temporal -r             ,  >java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 * each tile/sbrowrt-off+                add_tempojava.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 69
 * each interleaved#efinea )do    tmp  a;          java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 * column threading is 
 *                >tile_row.end = imin(tile_row_end4)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 ofeach sbrow(   rtile_col.d  imin -iw4)
 * enabled) or at the java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 59
 *   java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 77
 * java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 50


java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 51
                       refmvs_candidatejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                        java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
                       union java.lang.StringIndexOutOfBoundsException: Range [50, 47) out of bounds for length 78
                         edge_flagsjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
                       const int by4 x]n  java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 41
{
     refmvs_frame=rt-r  java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Range [18, 9) out of bounds for length 60
    const int bw4 = java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 79
 int bh4=b_dim],              java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 42
    mv[2,tgmv[2;

    *cnt = 0;
    assert(ref.ref[0] >=  0    }
           ref.java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
    if (ref.ref[ const 0
        tgmv[0] = get_gmv_2d        newmv_ctx =                 pos_x = x + apply_sign(abs(offset.x) >> 6,
                             bx4 last =n if+ = 
        gmv[                     
                 tgmvf (   java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Range [16, 12) out of bounds for length 12
        0  ()r+ ;;
        mv[        
    }}
}
        tgmv
                             bx4, by4, bw4, bh4, rfdrjava.lang.StringIndexOutOfBoundsException: Range [49, 45) out of bounds for length 74
        gmv[1] = rf->frm_hdr->gmv[ref.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 1
                 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
             java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 61
    // top
    int have_newmv             
    java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 71
    const refmvs_block *java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
    if (by4 > rt->tile_row.start) {
        max_rows = imin((by4 - rt->tile_row.} (>.0 -ref0
        b_top =                        [.  java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 (java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 5
                          ,w4,max_rows,bw4 =16   ,
                           hjava.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 54
    }

    // left
    java.lang.StringIndexOutOfBoundsException: Range [12, 9) out of bounds for length 21
    refmvs_block *const 
    java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 35
        max_cols = imin((bx4 - rt->tile_col
        b_left          {
        java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 57
bh4 h4,bx4 -1,max_colsjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 78
            &,&)
    -> =16< ->java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36

    // top/right
        rf-case 1:
        imax(bw4, bh4) <=            ctx  1 + -r  
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        if (n_blocks != rf>b)
                              java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 58
    }

    constintjava.lang.StringIndexOutOfBoundsException: Range [30, 27) out of bounds for length 58
     int         > =(,   ,64)
     (  = ;n  ; n+)
        mvstack[n]    const int poc=->;

    // temporal(=8                                           poc;
        if (java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 19
    if (rf->use_ref_frame_mvs                                            ,ref_poc[) 31,31;
        const ptrdiff_t _rame_mvs& -order_hint_n_bits) java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
        const int by8 = by4 >> 1, bx8 = bx4 >> 1;
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 89
        const                                      fconst int tile_col_start4java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
        const int step_h = bw4 >= 16 ? 2 : 1, step_v = bh4 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
         +)> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        for (int y = 0; y < h8; 
;  +  java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
               java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 69
                                       !+                    ojava.lang.StringIndexOutOfBoundsException: Range [78, 77) out of bounds for length 78
            #ndef
            rb        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        }
        if (imin(bw4, bh4) >= 2 &&     0
              > java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 53
            rb = &rbi[bh8 *  tile_threa =)java.lang.StringIndexOutOfBoundsException: Range [48, 45) out of bounds for length 50
            =+ - >1,
                                                    
            ifr>16*java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
                add_temporal_candidate(rf,c-ljava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 31
NULL,NULL)c-java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 29
            }
            if (bx8 + bw8 < imin    }
                if (has_bottomconst int -mfmv_ref2curn]java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
                    (c)
                                           
                
                (     (>end > 1 (y8 &~)8){
                    add_temporal_candidate(rf, mvstack, cnt, &rb[bw8                   java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 42
                                           ref, NULL, NULL);
                }
            }
        }
    }
    assert(*cnt <= 8);

    // top/left (which, confusingly, is part of "secondary" references)
    int have_dummy_newmv_match;
    if ((n_rows | n_cols) != ~0U) {
        add_spatial_candidaterb+java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
                              &have_dummy_newmv_match, &have_row_mvs);
    }

    // "secondary" (non-direct neighbour) top & left edges
    // what is different about secondary is that everything is now in 8x8 resolution
    for (int n = 2; n <= 3; if +x   ;
        ( n   &(nsigned)n=max_rows){
 =scan_row cnt,  gmv
                               &rt->r[(((by4 & 31) - 2 * n + 1){
bw4,w4,1+max_rows n >  ?4 2java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
                               &have_dummy_newmv_match, &have_row_mvs);
        }

        if ((unsigned) n > n_cols && (unsigned) n <= max_cols) {
            n_cols += scan_col(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 9
                               bh4, h4, (bx4 - n * 2 + 1) |  onst  const seq_hdr,
                               1 + max_cols - n, bh4 >= 16 ? 4 : 2,
    have_dummy_newmv_match &have_col_mvs);
        }
    }
    assertrf>java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 30

    if (n_blocks!=rf>) {

    // context build-up
    int refmv_ctx, newmv_ctxjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    switch (nearest_match) 
    case 0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
        refmv_ctx = imin(2, ref_match_count);
  ;
        break;
    const    -frame_offsetjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
                -s[]   0
newmv_ctx=3 -have_newmv;
        break;
    case 2poc ref_poci) 31,)
        refmv_ctx = 5;
        newmv_ctx = 5 - have_newmv;
        break;
    }

    // sorting (nearest, then "secondary")
    int len = nearest_cnt;
    while (len)         java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        int last = 0;
        for (int n = 1; n < len; n++            >rf>java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 55
            if (mvstack[n - 1].weight 
#define EXCHANGE(a, b) const int diff1 get_poc_diffs-,
               (n - 1] mvstack[n])
                 =n;
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
        }
        len = last;
    }
    len = *cnt;
    while (len > nearest_cnt) {
        int]]=(unsigned) diff2 >31?0  diff2;
        for (int n    -ujava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 44
            if (mvstack[n - 1].weight < mvstack[nstatic  ( *rr java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 72
EXCHANGE 1, [];
#undef EXCHANGE
                last = n;
            }
        }
        len = last;
    }

    if (refref[1]  0 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        if (*cnt < 2) {
            const int sign0 = rf->sign_bias[ref.ref[0] - 1];
            const int sign1 = rf
            const int sz4 = imin(w4, h4);
            refmvs_candidate *const same = &mvstack[*cnt];
            int same_count[4] = { 0 };

            // non-self references in top
            if (n_rows != ~0U) for (int x = 0; x < sz4;) {
                const refmvs_block *const cand_b = &b_top[x];
                add_compound_extended_candidate(same, same_count, cand_b,
                                                sign0, sign1, ref, rf->sign_bias);
                x += dav1d_block_dimensions[cand_b->bs][0];
            }

            // non-self references in left
            if (n_cols != ~0U) for (int y = 0; y < sz4;) {
                const refmvs_block *const cand_b = &b_left[y][bx4 - 1];
                add_compound_extended_candidate(same, same_count, cand_b,
                                                sign0, sign1, ref, rf->sign_bias);
                y += dav1d_block_dimensions[cand_b->bs][1];
            }

            refmvs_candidate *const diff = &same[2];
            const int *const diff_count = &same_count[2];

            // merge together
            for (int n = 0; n < 2; n++) {
                int m = same_count[n];

                if (m >= 2) continue;

                const int l = diff_count[n];
                if (l) {
                    same[m].mv.mv[n] = diff[0].mv.mv[n];
                    if (++m == 2) continue;
                    if (l == 2) {
                        same[1].mv.mv[n] = diff[1].mv.mv[n];
                        continue;
                    }
                }
                do {
                    same[m].mv.mv[n] = tgmv[n];
                } while (++m < 2);
            }

            // if the first extended was the same as the non-extended one,
            // then replace it with the second extended one
            int n = *cnt;
            if (n == 1 && mvstack[0].mv.n == same[0].mv.n)
                mvstack[1].mv = mvstack[2].mv;
            do {
                mvstack[n].weight = 2;
            } while (++n < 2);
            *cnt = 2;
        }

        // clamping
        const int left = -(bx4 + bw4 + 4) * 4 * 8;
        const int right = (rf->iw4 - bx4 + 4) * 4 * 8;
        const int top = -(by4 + bh4 + 4) * 4 * 8;
        const int bottom = (rf->ih4 - by4 + 4) * 4 * 8;

        const int n_refmvs = *cnt;
        int n = 0;
        do {
            mvstack[n].mv.mv[0].x = iclip(mvstack[n].mv.mv[0].x, left, right);
            mvstack[n].mv.mv[0].y = iclip(mvstack[n].mv.mv[0].y, top, bottom);
            mvstack[n].mv.mv[1].x = iclip(mvstack[n].mv.mv[1].x, left, right);
            mvstack[n].mv.mv[1].y = iclip(mvstack[n].mv.mv[1].y, top, bottom);
        } while (++n < n_refmvs);

        switch (refmv_ctx >> 1) {
        case 0:
            *ctx = imin(newmv_ctx, 1);
            break;
        case 1:
            *ctx = 1 + imin(newmv_ctx, 3);
            break;
        case 2:
            *ctx = iclip(3 + newmv_ctx, 4, 7);
            break;
        }

        return;
    } else if (*cnt < 2 && ref.ref[0] > 0) {
        const int sign = rf->sign_bias[ref.ref[0] - 1];
        const int sz4 = imin(w4, h4);

        // non-self references in top
        if (n_rows != ~0U) for (int x = 0; x < sz4 && *cnt < 2;) {
            const refmvs_block *const cand_b = &b_top[x];
            add_single_extended_candidate(mvstack, cnt, cand_b, sign, rf->sign_bias);
            x += dav1d_block_dimensions[cand_b->bs][0];
        }

        // non-self references in left
        if (n_cols != ~0U) for (int y = 0; y < sz4 && *cnt < 2;) {
            const refmvs_block *const cand_b = &b_left[y][bx4 - 1];
            add_single_extended_candidate(mvstack, cnt, cand_b, sign, rf->sign_bias);
            y += dav1d_block_dimensions[cand_b->bs][1];
        }
    }
    assert(*cnt <= 8);

    // clamping
    int n_refmvs = *cnt;
    if (n_refmvs) {
        const int left = -(bx4 + bw4 + 4) * 4 * 8;
        const int right = (rf->iw4 - bx4 + 4) * 4 * 8;
        const int top = -(by4 + bh4 + 4) * 4 * 8;
        const int bottom = (rf->ih4 - by4 + 4) * 4 * 8;

        int n = 0;
        do {
            mvstack[n].mv.mv[0].x = iclip(mvstack[n].mv.mv[0].x, left, right);
            mvstack[n].mv.mv[0].y = iclip(mvstack[n].mv.mv[0].y, top, bottom);
        } while (++n < n_refmvs);
    }

    for (int n = *cnt; n < 2; n++)
        mvstack[n].mv.mv[0] = tgmv[0];

    *ctx = (refmv_ctx << 4) | (globalmv_ctx << 3) | newmv_ctx;
}

void dav1d_refmvs_tile_sbrow_init(refmvs_tile *const rt, const refmvs_frame *const rf,
                                  const int tile_col_start4, const int tile_col_end4,
                                  const int tile_row_start4, const int tile_row_end4,
                                  const int sby, int tile_row_idx, const int pass)
{
    if (rf->n_tile_threads == 1) tile_row_idx = 0;
    rt->rp_proj = &rf->rp_proj[16 * rf->rp_stride * tile_row_idx];
    const ptrdiff_t r_stride = rf->rp_stride * 2;
    const ptrdiff_t pass_off = (rf->n_frame_threads > 1 && pass == 2) ?
        35 * 2 * rf->n_blocks : 0;
    refmvs_block *r = &rf->r[35 * r_stride * tile_row_idx + pass_off];
    const int sbsz = rf->sbsz;
    const int off = (sbsz * sby) & 16;
    for (int i = 0; i < sbsz; i++, r += r_stride)
        rt->r[off + 5 + i] = r;
    rt->r[off + 0] = r;
    r += r_stride;
    rt->r[off + 1] = NULL;
    rt->r[off + 2] = r;
    r += r_stride;
    rt->r[off + 3] = NULL;
    rt->r[off + 4] = r;
    if (sby & 1) {
#define EXCHANGE(a, b) do { void *const tmp = a; a = b; b = tmp; } while (0)
        EXCHANGE(rt->r[off + 0], rt->r[off + sbsz + 0]);
        EXCHANGE(rt->r[off + 2], rt->r[off + sbsz + 2]);
        EXCHANGE(rt->r[off + 4], rt->r[off + sbsz + 4]);
#undef EXCHANGE
    }

    rt->rf = rf;
    rt->tile_row.start = tile_row_start4;
    rt->tile_row.end = imin(tile_row_end4, rf->ih4);
    rt->tile_col.start = tile_col_start4;
    rt->tile_col.end = imin(tile_col_end4, rf->iw4);
}

static void load_tmvs_c(const refmvs_frame *const rf, int tile_row_idx,
                        const int col_start8, const int col_end8,
                        const int row_start8, int row_end8)
{
    if (rf->n_tile_threads == 1) tile_row_idx = 0;
    assert(row_start8 >= 0);
    assert((unsigned) (row_end8 - row_start8) <= 16U);
    row_end8 = imin(row_end8, rf->ih8);
    const int col_start8i = imax(col_start8 - 8, 0);
    const int col_end8i = imin(col_end8 + 8, rf->iw8);

    const ptrdiff_t stride = rf->rp_stride;
    refmvs_temporal_block *rp_proj =
        &rf->rp_proj[16 * stride * tile_row_idx + (row_start8 & 15) * stride];
    for (int y = row_start8; y < row_end8; y++) {
        for (int x = col_start8; x < col_end8; x++)
            rp_proj[x].mv.n = INVALID_MV;
        rp_proj += stride;
    }

    rp_proj = &rf->rp_proj[16 * stride * tile_row_idx];
    for (int n = 0; n < rf->n_mfmvs; n++) {
        const int ref2cur = rf->mfmv_ref2cur[n];
        if (ref2cur == INVALID_REF2CUR) continue;

        const int ref = rf->mfmv_ref[n];
        const int ref_sign = ref - 4;
        const refmvs_temporal_block *r = &rf->rp_ref[ref][row_start8 * stride];
        for (int y = row_start8; y < row_end8; y++) {
            const int y_sb_align = y & ~7;
            const int y_proj_start = imax(y_sb_align, row_start8);
            const int y_proj_end = imin(y_sb_align + 8, row_end8);
            for (int x = col_start8i; x < col_end8i; x++) {
                const refmvs_temporal_block *rb = &r[x];
                const int b_ref = rb->ref;
                if (!b_ref) continue;
                const int ref2ref = rf->mfmv_ref2ref[n][b_ref - 1];
                if (!ref2ref) continue;
                const mv b_mv = rb->mv;
                const mv offset = mv_projection(b_mv, ref2cur, ref2ref);
                int pos_x = x + apply_sign(abs(offset.x) >> 6,
                                           offset.x ^ ref_sign);
                const int pos_y = y + apply_sign(abs(offset.y) >> 6,
                                                 offset.y ^ ref_sign);
                if (pos_y >= y_proj_start && pos_y < y_proj_end) {
                    const ptrdiff_t pos = (pos_y & 15) * stride;
                    for (;;) {
                        const int x_sb_align = x & ~7;
                        if (pos_x >= imax(x_sb_align - 8, col_start8) &&
                            pos_x < imin(x_sb_align + 16, col_end8))
                        {
                            rp_proj[pos + pos_x].mv = rb->mv;
                            rp_proj[pos + pos_x].ref = ref2ref;
                        }
                        if (++x >= col_end8i) break;
                        rb++;
                        if (rb->ref != b_ref || rb->mv.n != b_mv.n) break;
                        pos_x++;
                    }
                } else {
                    for (;;) {
                        if (++x >= col_end8i) break;
                        rb++;
                        if (rb->ref != b_ref || rb->mv.n != b_mv.n) break;
                    }
                }
                x--;
            }
            r += stride;
        }
    }
}

static void save_tmvs_c(refmvs_temporal_block *rp, const ptrdiff_t stride,
                        refmvs_block *const *const rr,
                        const uint8_t *const ref_sign,
                        const int col_end8, const int row_end8,
                        const int col_start8, const int row_start8)
{
    for (int y = row_start8; y < row_end8; y++) {
        const refmvs_block *const b = rr[(y & 15) * 2];

        for (int x = col_start8; x < col_end8;) {
            const refmvs_block *const cand_b = &b[x * 2 + 1];
            const int bw8 = (dav1d_block_dimensions[cand_b->bs][0] + 1) >> 1;

            if (cand_b->ref.ref[1] > 0 && ref_sign[cand_b->ref.ref[1] - 1] &&
                (abs(cand_b->mv.mv[1].y) | abs(cand_b->mv.mv[1].x)) < 4096)
            {
                for (int n = 0; n < bw8; n++, x++)
                    rp[x] = (refmvs_temporal_block) { .mv = cand_b->mv.mv[1],
                                                      .ref = cand_b->ref.ref[1] };
            } else if (cand_b->ref.ref[0] > 0 && ref_sign[cand_b->ref.ref[0] - 1] &&
                       (abs(cand_b->mv.mv[0].y) | abs(cand_b->mv.mv[0].x)) < 4096)
            {
                for (int n = 0; n < bw8; n++, x++)
                    rp[x] = (refmvs_temporal_block) { .mv = cand_b->mv.mv[0],
                                                      .ref = cand_b->ref.ref[0] };
            } else {
                for (int n = 0; n < bw8; n++, x++) {
                    rp[x].mv.n = 0;
                    rp[x].ref = 0; // "invalid"
                }
            }
        }
        rp += stride;
    }
}

int dav1d_refmvs_init_frame(refmvs_frame *const rf,
                            const Dav1dSequenceHeader *const seq_hdr,
                            const Dav1dFrameHeader *const frm_hdr,
                            const uint8_t ref_poc[7],
                            refmvs_temporal_block *const rp,
                            const uint8_t ref_ref_poc[7][7],
                            /*const*/
 refmvs_temporal_block *const rp_ref[7],
                            const int n_tile_threads, const int n_frame_threads)
{
    const int rp_stride = ((frm_hdr->width[0] + 127) & ~127) >> 3;
    const int n_tile_rows = n_tile_threads > 1 ? frm_hdr->tiling.rows : 1;
    const int n_blocks = rp_stride * n_tile_rows;

    rf->sbsz = 16 << seq_hdr->sb128;
    rf->frm_hdr = frm_hdr;
    rf->iw8 = (frm_hdr->width[0] + 7) >> 3;
    rf->ih8 = (frm_hdr->height + 7) >> 3;
    rf->iw4 = rf->iw8 << 1;
    rf->ih4 = rf->ih8 << 1;
    rf->rp = rp;
    rf->rp_stride = rp_stride;
    rf->n_tile_threads = n_tile_threads;
    rf->n_frame_threads = n_frame_threads;

    if (n_blocks != rf->n_blocks) {
        const size_t r_sz = sizeof(*rf->r) * 35 * 2 * n_blocks * (1 + (n_frame_threads > 1));
        const size_t rp_proj_sz = sizeof(*rf->rp_proj) * 16 * n_blocks;
        /* Note that sizeof(*rf->r) == 12, but it's accessed using 16-byte unaligned
         * loads in save_tmvs() asm which can overread 4 bytes into rp_proj. */

        dav1d_free_aligned(rf->r);
        rf->r = dav1d_alloc_aligned(ALLOC_REFMVS, r_sz + rp_proj_sz, 64);
        if (!rf->r) {
            rf->n_blocks = 0;
            return DAV1D_ERR(ENOMEM);
        }

        rf->rp_proj = (refmvs_temporal_block*)((uintptr_t)rf->r + r_sz);
        rf->n_blocks = n_blocks;
    }

    const int poc = frm_hdr->frame_offset;
    for (int i = 0; i < 7; i++) {
        const int poc_diff = get_poc_diff(seq_hdr->order_hint_n_bits,
                                          ref_poc[i], poc);
        rf->sign_bias[i] = poc_diff > 0;
        rf->mfmv_sign[i] = poc_diff < 0;
        rf->pocdiff[i] = iclip(get_poc_diff(seq_hdr->order_hint_n_bits,
                                            poc, ref_poc[i]), -31, 31);
    }

    // temporal MV setup
    rf->n_mfmvs = 0;
    rf->rp_ref = rp_ref;
    if (frm_hdr->use_ref_frame_mvs && seq_hdr->order_hint_n_bits) {
        int total = 2;
        if (rp_ref[0] && ref_ref_poc[0][6] != ref_poc[3] /* alt-of-last != gold */) {
            rf->mfmv_ref[rf->n_mfmvs++] = 0; // last
            total = 3;
        }
        if (rp_ref[4] && get_poc_diff(seq_hdr->order_hint_n_bits, ref_poc[4],
                                      frm_hdr->frame_offset) > 0)
        {
            rf->mfmv_ref[rf->n_mfmvs++] = 4; // bwd
        }
        if (rp_ref[5] && get_poc_diff(seq_hdr->order_hint_n_bits, ref_poc[5],
                                      frm_hdr->frame_offset) > 0)
        {
            rf->mfmv_ref[rf->n_mfmvs++] = 5; // altref2
        }
        if (rf->n_mfmvs < total && rp_ref[6] &&
            get_poc_diff(seq_hdr->order_hint_n_bits, ref_poc[6],
                         frm_hdr->frame_offset) > 0)
        {
            rf->mfmv_ref[rf->n_mfmvs++] = 6; // altref
        }
        if (rf->n_mfmvs < total && rp_ref[1])
            rf->mfmv_ref[rf->n_mfmvs++] = 1; // last2

        for (int n = 0; n < rf->n_mfmvs; n++) {
            const int rpoc = ref_poc[rf->mfmv_ref[n]];
            const int diff1 = get_poc_diff(seq_hdr->order_hint_n_bits,
                                           rpoc, frm_hdr->frame_offset);
            if (abs(diff1) > 31) {
                rf->mfmv_ref2cur[n] = INVALID_REF2CUR;
            } else {
                rf->mfmv_ref2cur[n] = rf->mfmv_ref[n] < 4 ? -diff1 : diff1;
                for (int m = 0; m < 7; m++) {
                    const int rrpoc = ref_ref_poc[rf->mfmv_ref[n]][m];
                    const int diff2 = get_poc_diff(seq_hdr->order_hint_n_bits,
                                                   rpoc, rrpoc);
                    // unsigned comparison also catches the < 0 case
                    rf->mfmv_ref2ref[n][m] = (unsigned) diff2 > 31U ? 0 : diff2;
                }
            }
        }
    }
    rf->use_ref_frame_mvs = rf->n_mfmvs > 0;

    return 0;
}

static void splat_mv_c(refmvs_block **rr, const refmvs_block *const rmv,
                       const int bx4, const int bw4, int bh4)
{
    do {
        refmvs_block *const r = *rr++ + bx4;
        for (int x = 0; x < bw4; x++)
            r[x] = *rmv;
    } while (--bh4);
}

#if HAVE_ASM
#if ARCH_AARCH64 || ARCH_ARM
#include "src/arm/refmvs.h"
#elif ARCH_LOONGARCH64
#include "src/loongarch/refmvs.h"
#elif ARCH_X86
#include "src/x86/refmvs.h"
#endif
#endif

COLD void dav1d_refmvs_dsp_init(Dav1dRefmvsDSPContext *const c)
{
    c->load_tmvs = load_tmvs_c;
    c->save_tmvs = save_tmvs_c;
    c->splat_mv = splat_mv_c;

#if HAVE_ASM
#if ARCH_AARCH64 || ARCH_ARM
    refmvs_dsp_init_arm(c);
#elif ARCH_LOONGARCH64
    refmvs_dsp_init_loongarch(c);
#elif ARCH_X86
    refmvs_dsp_init_x86(c);
#endif
#endif
}

Messung V0.5 in Prozent
C=95 H=85 G=90

¤ Dauer der Verarbeitung: 0.64 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.