#include "config.h"
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
#include "dav1d/data.h"
#include "common/frame.h"
#include "common/intops.h"
#include "src/ctx.h"
#include "src/decode.h"
#include "src/dequant_tables.h"
#include "src/env.h"
#include "src/filmgrain.h"
#include "src/log.h"
#include "src/qm.h"
#include "src/recon.h"
#include "src/ref.h"
#include "src/tables.h"
#include "src/thread_task.h"
#include "src/warpmv.h"
static void init_quant_tables(const Dav1dSequenceHeader *const seq_hdr,
const Dav1dFrameHeader *const frame_hdr,
const int qidx, uint16_t (*dq)[3][2])
{ … }
static int read_mv_component_diff(MsacContext *const msac,
CdfMvComponent *const mv_comp,
const int mv_prec)
{ … }
static void read_mv_residual(Dav1dTileState *const ts, mv *const ref_mv,
const int mv_prec)
{ … }
static void read_tx_tree(Dav1dTaskContext *const t,
const enum RectTxfmSize from,
const int depth, uint16_t *const masks,
const int x_off, const int y_off)
{ … }
static int neg_deinterleave(int diff, int ref, int max) { … }
static void find_matching_ref(const Dav1dTaskContext *const t,
const enum EdgeFlags intra_edge_flags,
const int bw4, const int bh4,
const int w4, const int h4,
const int have_left, const int have_top,
const int ref, uint64_t masks[2])
{ … }
static void derive_warpmv(const Dav1dTaskContext *const t,
const int bw4, const int bh4,
const uint64_t masks[2], const union mv mv,
Dav1dWarpedMotionParams *const wmp)
{ … }
static inline int findoddzero(const uint8_t *buf, int len) { … }
static void order_palette(const uint8_t *pal_idx, const ptrdiff_t stride,
const int i, const int first, const int last,
uint8_t (*const order)[8], uint8_t *const ctx)
{ … }
static void read_pal_indices(Dav1dTaskContext *const t,
uint8_t *const pal_idx,
const Av1Block *const b, const int pl,
const int w4, const int h4,
const int bw4, const int bh4)
{ … }
static void read_vartx_tree(Dav1dTaskContext *const t,
Av1Block *const b, const enum BlockSize bs,
const int bx4, const int by4)
{ … }
static inline unsigned get_prev_frame_segid(const Dav1dFrameContext *const f,
const int by, const int bx,
const int w4, int h4,
const uint8_t *ref_seg_map,
const ptrdiff_t stride)
{ … }
static inline void splat_oneref_mv(const Dav1dContext *const c,
Dav1dTaskContext *const t,
const enum BlockSize bs,
const Av1Block *const b,
const int bw4, const int bh4)
{ … }
static inline void splat_intrabc_mv(const Dav1dContext *const c,
Dav1dTaskContext *const t,
const enum BlockSize bs,
const Av1Block *const b,
const int bw4, const int bh4)
{ … }
static inline void splat_tworef_mv(const Dav1dContext *const c,
Dav1dTaskContext *const t,
const enum BlockSize bs,
const Av1Block *const b,
const int bw4, const int bh4)
{ … }
static inline void splat_intraref(const Dav1dContext *const c,
Dav1dTaskContext *const t,
const enum BlockSize bs,
const int bw4, const int bh4)
{ … }
static void mc_lowest_px(int *const dst, const int by4, const int bh4,
const int mvy, const int ss_ver,
const struct ScalableMotionParams *const smp)
{ … }
static ALWAYS_INLINE void affine_lowest_px(Dav1dTaskContext *const t, int *const dst,
const uint8_t *const b_dim,
const Dav1dWarpedMotionParams *const wmp,
const int ss_ver, const int ss_hor)
{ … }
static NOINLINE void affine_lowest_px_luma(Dav1dTaskContext *const t, int *const dst,
const uint8_t *const b_dim,
const Dav1dWarpedMotionParams *const wmp)
{ … }
static NOINLINE void affine_lowest_px_chroma(Dav1dTaskContext *const t, int *const dst,
const uint8_t *const b_dim,
const Dav1dWarpedMotionParams *const wmp)
{ … }
static void obmc_lowest_px(Dav1dTaskContext *const t,
int (*const dst)[2], const int is_chroma,
const uint8_t *const b_dim,
const int bx4, const int by4, const int w4, const int h4)
{ … }
static int decode_b(Dav1dTaskContext *const t,
const enum BlockLevel bl,
const enum BlockSize bs,
const enum BlockPartition bp,
const enum EdgeFlags intra_edge_flags)
{ … }
#if __has_feature(memory_sanitizer)
#include <sanitizer/msan_interface.h>
static int checked_decode_b(Dav1dTaskContext *const t,
const enum BlockLevel bl,
const enum BlockSize bs,
const enum BlockPartition bp,
const enum EdgeFlags intra_edge_flags)
{
const Dav1dFrameContext *const f = t->f;
const int err = decode_b(t, bl, bs, bp, intra_edge_flags);
if (err == 0 && !(t->frame_thread.pass & 1)) {
const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const uint8_t *const b_dim = dav1d_block_dimensions[bs];
const int bw4 = b_dim[0], bh4 = b_dim[1];
const int w4 = imin(bw4, f->bw - t->bx), h4 = imin(bh4, f->bh - t->by);
const int has_chroma = f->seq_hdr->layout != DAV1D_PIXEL_LAYOUT_I400 &&
(bw4 > ss_hor || t->bx & 1) &&
(bh4 > ss_ver || t->by & 1);
for (int p = 0; p < 1 + 2 * has_chroma; p++) {
const int ss_ver = p && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
const int ss_hor = p && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const ptrdiff_t stride = f->cur.stride[!!p];
const int bx = t->bx & ~ss_hor;
const int by = t->by & ~ss_ver;
const int width = w4 << (2 - ss_hor + (bw4 == ss_hor));
const int height = h4 << (2 - ss_ver + (bh4 == ss_ver));
const uint8_t *data = f->cur.data[p] + (by << (2 - ss_ver)) * stride +
(bx << (2 - ss_hor + !!f->seq_hdr->hbd));
for (int y = 0; y < height; data += stride, y++) {
const size_t line_sz = width << !!f->seq_hdr->hbd;
if (__msan_test_shadow(data, line_sz) != -1) {
fprintf(stderr, "B[%d](%d, %d) w4:%d, h4:%d, row:%d\n",
p, bx, by, w4, h4, y);
__msan_check_mem_is_initialized(data, line_sz);
}
}
}
}
return err;
}
#define decode_b …
#endif
static int decode_sb(Dav1dTaskContext *const t, const enum BlockLevel bl,
const EdgeNode *const node)
{ … }
static void reset_context(BlockContext *const ctx, const int keyframe, const int pass) { … }
static const uint8_t ss_size_mul[4][2] = …;
static void setup_tile(Dav1dTileState *const ts,
const Dav1dFrameContext *const f,
const uint8_t *const data, const size_t sz,
const int tile_row, const int tile_col,
const unsigned tile_start_off)
{ … }
static void read_restoration_info(Dav1dTaskContext *const t,
Av1RestorationUnit *const lr, const int p,
const enum Dav1dRestorationType frame_type)
{ … }
static int check_trailing_bits_after_symbol_coder(const MsacContext *const msac) { … }
int dav1d_decode_tile_sbrow(Dav1dTaskContext *const t) { … }
int dav1d_decode_frame_init(Dav1dFrameContext *const f) { … }
int dav1d_decode_frame_init_cdf(Dav1dFrameContext *const f) { … }
int dav1d_decode_frame_main(Dav1dFrameContext *const f) { … }
void dav1d_decode_frame_exit(Dav1dFrameContext *const f, int retval) { … }
int dav1d_decode_frame(Dav1dFrameContext *const f) { … }
static int get_upscale_x0(const int in_w, const int out_w, const int step) { … }
int dav1d_submit_frame(Dav1dContext *const c) { … }