Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/media/libwebp/src/dec/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 22 kB image not shown  

Quelle  tree_dec.c

  Sprache: C
 

// Copyright 2010 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Coding trees and probas
//
// Author: Skal (pascal.massimino@gmail.com)

#include "src/dec/vp8i_dec.h"
#include "src/dsp/cpu.h"
#include "src/utils/bit_reader_inl_utils.h"

#if !defined(USE_GENERIC_TREE)
#if !defined(__arm__) && !defined(_M_ARM) && !WEBP_AARCH64 && \
    !defined(__wasm__)
// using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
#define USE_GENERIC_TREE 1   // ALTERNATE_CODE
#else
#define USE_GENERIC_TREE 0
#endif
#endif  // USE_GENERIC_TREE

#if (USE_GENERIC_TREE == 1)
static const int8_t kYModesIntra4[18] = {
  -B_DC_PRED, 1,
    -B_TM_PRED, 2,
      -B_VE_PRED, 3,
        46,
          -B_HE_PRED, 5,
            -B_RD_PRED, -B_VR_PRED,
        -B_LD_PRED, 7,
          -B_VL_PRED, 8,
            -B_HD_PRED, -B_HU_PRED
};
#endif

//------------------------------------------------------------------------------
// Default probabilities

// Paragraph 13.5
static const uint8_t
  CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
  { { { 128128128128128128128128128128128 },
      { 128128128128128128128128128128128 },
      { 128128128128128128128128128128128 }
    },
    { { 253136254255228219128128128128128 },
      { 189129242255227213255219128128128 },
      { 106126227252214209255255128128128 }
    },
    { { 198248255236226255255128128128 },
      { 181133238254221234255154128128128 },
      { 78134202247198180255219128128128 },
    },
    { { 1185249255243255128128128128128 },
      { 184150247255236224128128128128128 },
      { 77110216255236230128128128128128 },
    },
    { { 1101251255241255128128128128128 },
      { 170139241252236209255255128128128 },
      { 37116196243228255255255128128128 }
    },
    { { 1204254255245255128128128128128 },
      { 207160250255238128128128128128128 },
      { 102103231255211171128128128128128 }
    },
    { { 1152252255240255128128128128128 },
      { 177135243255234225128128128128128 },
      { 80129211255194224128128128128128 }
    },
    { { 11255128128128128128128128128 },
      { 2461255128128128128128128128128 },
      { 255128128128128128128128128128128 }
    }
  },
  { { { 1983523722319318716216014515562 },
      { 131451982211721762201572522211 },
      { 6847146208149167221162255223128 }
    },
    { { 1149241255221224255255128128128 },
      { 184141234253222220255199128128128 },
      { 8199181242176190249202255255128 }
    },
    { { 1129232253214197242196255255128 },
      { 99121210250201198255202128128128 },
      { 2391163242170187247210255255128 }
    },
    { { 1200246255234255128128128128128 },
      { 109178241255231245255255128128128 },
      { 44130201253205192255255128128128 }
    },
    { { 1132239251219209255165128128128 },
      { 94136225251218190255255128128128 },
      { 22100174245186161255199128128128 }
    },
    { { 1182249255232235128128128128128 },
      { 124143241255227234128128128128128 },
      { 3577181251193211255205128128128 }
    },
    { { 1157247255236231255255128128128 },
      { 121141235255225227255255128128128 },
      { 4599188251195217255224128128128 }
    },
    { { 11251255213255128128128128128 },
      { 2031248255255128128128128128128 },
      { 1371177255224255128128128128128 }
    }
  },
  { { { 2539248251207208255192128128128 },
      { 17513224243193185249198255255128 },
      { 7317171221161179236167255234128 }
    },
    { { 195247253212183255255128128128 },
      { 23990244250211209255255128128128 },
      { 15577195248188195255255128128128 }
    },
    { { 124239251218219255205128128128 },
      { 20151219255196186128128128128128 },
      { 6946190239201218255228128128128 }
    },
    { { 1191251255255128128128128128128 },
      { 223165249255213255128128128128128 },
      { 141124248255255128128128128128128 }
    },
    { { 116248255255128128128128128128 },
      { 19036230255236255128128128128128 },
      { 1491255128128128128128128128128 }
    },
    { { 1226255128128128128128128128128 },
      { 247192255128128128128128128128128 },
      { 240128255128128128128128128128128 }
    },
    { { 1134252255255128128128128128128 },
      { 21362250255255128128128128128128 },
      { 5593255128128128128128128128128 }
    },
    { { 128128128128128128128128128128128 },
      { 128128128128128128128128128128128 },
      { 128128128128128128128128128128128 }
    }
  },
  { { { 20224213235186191220160240175255 },
      { 12638182232169184228174255187128 },
      { 6146138219151178240170255216128 }
    },
    { { 1112230250199191247159255255128 },
      { 166109228252211215255174128128128 },
      { 3977162232172180245178255255128 }
    },
    { { 152220246198199249220255255128 },
      { 12474191243183193250221255255128 },
      { 2471130219154170243182255255128 }
    },
    { { 1182225249219240255224128128128 },
      { 149150226252216205255171128128128 },
      { 28108170242183194254223255255128 }
    },
    { { 181230252204203255192128128128 },
      { 123102209247188196255233128128128 },
      { 2095153243164173255203128128128 }
    },
    { { 1222248255216213128128128128128 },
      { 168175246252235205255255128128128 },
      { 47116215255211212255255128128128 }
    },
    { { 1121236253212214255255128128128 },
      { 14184213252201202255219128128128 },
      { 4280160240162185255205128128128 }
    },
    { { 11255128128128128128128128128 },
      { 2441255128128128128128128128128 },
      { 2381255128128128128128128128128 }
    }
  }
};

// Paragraph 11.5
static const uint8_t kBModesProba[NUM_BMODES][NUM_BMODES][NUM_BMODES - 1] = {
  { { 2311204889115113120152112 },
    { 15217964126170118467095 },
    { 1756914380858272155103 },
    { 5658101712181891713152 },
    { 1142617163441952110173 },
    { 12124801952662446485 },
    { 1447110381712131443426 },
    { 1704655191361603320671 },
    { 63208114114208129226 },
    { 8140119618284291636 } },
  { { 1341838913798101106165148 },
    { 72187100130157111327580 },
    { 6610216799746240234128 },
    { 41539178241141268107 },
    { 744326146731664923157 },
    { 6538105160515231115128 },
    { 10479122721725587177 },
    { 87687144114511518623 },
    { 4741141101821832117194 },
    { 664525102197189231822 } },
  { { 8888147150424645196205 },
    { 439718311785383517961 },
    { 395320087262143232171 },
    { 563451104114102299377 },
    { 39288517158165909864 },
    { 342211620623344316673 },
    { 107543226511814331 },
    { 6825106226417136225114 },
    { 3419211021321881676124 },
    { 621878958557504851 } },
  { { 193101351592151118946111 },
    { 60148311722192282118111 },
    { 112113778517925538120114 },
    { 404211962452091025109 },
    { 8843291401662133743154 },
    { 6163301556745681209 },
    { 100808431541512671 },
    { 14278781625512834197171 },
    { 4140510221118341221 },
    { 515017168209192232582 } },
  { { 1383136171271663844229 },
    { 678758169821152659179 },
    { 635990180591669373154 },
    { 4040211161432093439175 },
    { 471516183342234945183 },
    { 4617331836981532183 },
    { 574622241281541737 },
    { 6532731152812823128205 },
    { 403911551192186223 },
    { 873791155977642147 } },
  { { 104554421895453130226 },
    { 6490702054041232657 },
    { 545711218454138166213 },
    { 3034261331521161032134 },
    { 391953221261143273255 },
    { 31965234215111873 },
    { 753212511922551604351 },
    { 88313567102855518685 },
    { 562123111592054537192 },
    { 5538701247310213498 } },
  { { 1259842881048511717582 },
    { 9584538912810011310145 },
    { 75791234751128811711 },
    { 571757110257534149 },
    { 383313121577326185 },
    { 411067138771109047114 },
    { 11521210102255166236 },
    { 1012916108512810119626 },
    { 571810102102213342043 },
    { 11720153616312868126 } },
  { { 102617137345331243192 },
    { 69607138731192822237 },
    { 68451283414711245171 },
    { 6217197014685556270 },
    { 374337154100163851601 },
    { 6399213628643220185 },
    { 7515996425518411916 },
    { 86628564255252481 },
    { 5681713213725555116128 },
    { 58152082135572612140 } },
  { { 16450311371541332535218 },
    { 5110344131131123316158 },
    { 86406413514822445183128 },
    { 222617131240154141209 },
    { 451621916422271197 },
    { 5621391556013823102213 },
    { 83121354192255684728 },
    { 8526858512812832146171 },
    { 181176314417144246 },
    { 3527101461741711226128 } },
  { { 190803599180801265445 },
    { 85126478717651412032 },
    { 1017512813911814611612885 },
    { 5641151762368537962 },
    { 7130171191182551718138 },
    { 101386013855704326142 },
    { 146361930171255972720 },
    { 13845616221918118864 },
    { 3241201171511422021163 },
    { 11219126119512848424 } }
};

void VP8ResetProba(VP8Proba* const proba) {
  memset(proba->segments_, 255u, sizeof(proba->segments_));
  // proba->bands_[][] is initialized later
}

static void ParseIntraMode(VP8BitReader* const br,
                           VP8Decoder* const dec, int mb_x) {
  uint8_t* const top = dec->intra_t_ + 4 * mb_x;
  uint8_t* const left = dec->intra_l_;
  VP8MBData* const block = dec->mb_data_ + mb_x;

  // Note: we don't save segment map (yet), as we don't expect
  // to decode more than 1 keyframe.
  if (dec->segment_hdr_.update_map_) {
    // Hardcoded tree parsing
    block->segment_ = !VP8GetBit(br, dec->proba_.segments_[0], "segments")
                    ?  VP8GetBit(br, dec->proba_.segments_[1], "segments")
                    :  VP8GetBit(br, dec->proba_.segments_[2], "segments") + 2;
  } else {
    block->segment_ = 0;  // default for intra
  }
  if (dec->use_skip_proba_) block->skip_ = VP8GetBit(br, dec->skip_p_, "skip");

  block->is_i4x4_ = !VP8GetBit(br, 145"block-size");
  if (!block->is_i4x4_) {
    // Hardcoded 16x16 intra-mode decision tree.
    const int ymode =
        VP8GetBit(br, 156"pred-modes") ?
            (VP8GetBit(br, 128"pred-modes") ? TM_PRED : H_PRED) :
            (VP8GetBit(br, 163"pred-modes") ? V_PRED : DC_PRED);
    block->imodes_[0] = ymode;
    memset(top, ymode, 4 * sizeof(*top));
    memset(left, ymode, 4 * sizeof(*left));
  } else {
    uint8_t* modes = block->imodes_;
    int y;
    for (y = 0; y < 4; ++y) {
      int ymode = left[y];
      int x;
      for (x = 0; x < 4; ++x) {
        const uint8_t* const prob = kBModesProba[top[x]][ymode];
#if (USE_GENERIC_TREE == 1)
        // Generic tree-parsing
        int i = kYModesIntra4[VP8GetBit(br, prob[0], "pred-modes")];
        while (i > 0) {
          i = kYModesIntra4[2 * i + VP8GetBit(br, prob[i], "pred-modes")];
        }
        ymode = -i;
#else
        // Hardcoded tree parsing
        ymode = !VP8GetBit(br, prob[0], "pred-modes") ? B_DC_PRED :
                  !VP8GetBit(br, prob[1], "pred-modes") ? B_TM_PRED :
                    !VP8GetBit(br, prob[2], "pred-modes") ? B_VE_PRED :
                      !VP8GetBit(br, prob[3], "pred-modes") ?
                        (!VP8GetBit(br, prob[4], "pred-modes") ? B_HE_PRED :
                          (!VP8GetBit(br, prob[5], "pred-modes") ? B_RD_PRED
                                                                 : B_VR_PRED)) :
                        (!VP8GetBit(br, prob[6], "pred-modes") ? B_LD_PRED :
                          (!VP8GetBit(br, prob[7], "pred-modes") ? B_VL_PRED :
                            (!VP8GetBit(br, prob[8], "pred-modes") ? B_HD_PRED
                                                                   : B_HU_PRED))
                        );
#endif  // USE_GENERIC_TREE
        top[x] = ymode;
      }
      memcpy(modes, top, 4 * sizeof(*top));
      modes += 4;
      left[y] = ymode;
    }
  }
  // Hardcoded UVMode decision tree
  block->uvmode_ = !VP8GetBit(br, 142"pred-modes-uv") ? DC_PRED
                 : !VP8GetBit(br, 114"pred-modes-uv") ? V_PRED
                 : VP8GetBit(br, 183"pred-modes-uv") ? TM_PRED : H_PRED;
}

int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec) {
  int mb_x;
  for (mb_x = 0; mb_x < dec->mb_w_; ++mb_x) {
    ParseIntraMode(br, dec, mb_x);
  }
  return !dec->br_.eof_;
}

//------------------------------------------------------------------------------
// Paragraph 13

static const uint8_t
    CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
  { { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 176246255255255255255255255255255 },
      { 223241252255255255255255255255255 },
      { 249253253255255255255255255255255 }
    },
    { { 255244252255255255255255255255255 },
      { 234254254255255255255255255255255 },
      { 253255255255255255255255255255255 }
    },
    { { 255246254255255255255255255255255 },
      { 239253254255255255255255255255255 },
      { 254255254255255255255255255255255 }
    },
    { { 255248254255255255255255255255255 },
      { 251255254255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255253254255255255255255255255255 },
      { 251254254255255255255255255255255 },
      { 254255254255255255255255255255255 }
    },
    { { 255254253255254255255255255255255 },
      { 250255254255254255255255255255255 },
      { 254255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    }
  },
  { { { 217255255255255255255255255255255 },
      { 225252241253255255254255255255255 },
      { 234250241250253255253254255255255 }
    },
    { { 255254255255255255255255255255255 },
      { 223254254255255255255255255255255 },
      { 238253254254255255255255255255255 }
    },
    { { 255248254255255255255255255255255 },
      { 249254255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255253255255255255255255255255255 },
      { 247254255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255253254255255255255255255255255 },
      { 252255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255254254255255255255255255255255 },
      { 253255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255254253255255255255255255255255 },
      { 250255255255255255255255255255255 },
      { 254255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    }
  },
  { { { 186251250255255255255255255255255 },
      { 234251244254255255255255255255255 },
      { 251251243253254255254255255255255 }
    },
    { { 255253254255255255255255255255255 },
      { 236253254255255255255255255255255 },
      { 251253253254254255255255255255255 }
    },
    { { 255254254255255255255255255255255 },
      { 254254254255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255254255255255255255255255255255 },
      { 254254255255255255255255255255255 },
      { 254255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 254255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    }
  },
  { { { 248255255255255255255255255255255 },
      { 250254252254255255255255255255255 },
      { 248254249253255255255255255255255 }
    },
    { { 255253253255255255255255255255255 },
      { 246253253255255255255255255255255 },
      { 252254251254254255255255255255255 }
    },
    { { 255254252255255255255255255255255 },
      { 248254253255255255255255255255255 },
      { 253255254254255255255255255255255 }
    },
    { { 255251254255255255255255255255255 },
      { 245251254255255255255255255255255 },
      { 253253254255255255255255255255255 }
    },
    { { 255251253255255255255255255255255 },
      { 252253254255255255255255255255255 },
      { 255254255255255255255255255255255 }
    },
    { { 255252255255255255255255255255255 },
      { 249255254255255255255255255255255 },
      { 255255254255255255255255255255255 }
    },
    { { 255255253255255255255255255255255 },
      { 250255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    },
    { { 255255255255255255255255255255255 },
      { 254255255255255255255255255255255 },
      { 255255255255255255255255255255255 }
    }
  }
};

// Paragraph 9.9

static const uint8_t kBands[16 + 1] = {
  0123645666666667,
  0  // extra entry as sentinel
};

void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
  VP8Proba* const proba = &dec->proba_;
  int t, b, c, p;
  for (t = 0; t < NUM_TYPES; ++t) {
    for (b = 0; b < NUM_BANDS; ++b) {
      for (c = 0; c < NUM_CTX; ++c) {
        for (p = 0; p < NUM_PROBAS; ++p) {
          const int v =
              VP8GetBit(br, CoeffsUpdateProba[t][b][c][p], "global-header") ?
                        VP8GetValue(br, 8"global-header") :
                        CoeffsProba0[t][b][c][p];
          proba->bands_[t][b].probas_[c][p] = v;
        }
      }
    }
    for (b = 0; b < 16 + 1; ++b) {
      proba->bands_ptr_[t][b] = &proba->bands_[t][kBands[b]];
    }
  }
  dec->use_skip_proba_ = VP8Get(br, "global-header");
  if (dec->use_skip_proba_) {
    dec->skip_p_ = VP8GetValue(br, 8"global-header");
  }
}

Messung V0.5 in Prozent
C=78 H=91 G=84

¤ Dauer der Verarbeitung: 0.3 Sekunden  (vorverarbeitet am  2026-06-05) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.