summaryrefslogtreecommitdiff
path: root/chromium/third_party/dav1d/libdav1d/src/decode.c
diff options
context:
space:
mode:
authorDale Curtis <dalecurtis@chromium.org>2022-12-16 22:37:46 +0000
committerMichael BrĂ¼ning <michael.bruning@qt.io>2023-03-27 08:12:03 +0000
commitc885ec409f9b6ffa25e03851729b1bc2ad2005b3 (patch)
tree0c9f205efc231ede87d2704b2780d1569caf5111 /chromium/third_party/dav1d/libdav1d/src/decode.c
parent0d63fc949d16f3e37ed7ab43d335b9d81cc6fdf7 (diff)
downloadqtwebengine-chromium-c885ec409f9b6ffa25e03851729b1bc2ad2005b3.tar.gz
[Backport] Security bug 1401571102-based
Manual update of libdav1d to match the version introduced by patch https://chromium-review.googlesource.com/c/chromium/src/+/4114163: Roll src/third_party/dav1d/libdav1d/ 87f9a81cd..ed63a7459 (104 commits) This roll required a few changes to get working: - "properties" => "built in options" crossfile configuration change due to Meson deprecation. - generic config creation never worked, so fixed. - PPC64 configs were never checked in, so switched to generic. - copyright header changes for generate_sources. - Updated readme.chromium with potential issues that can arise. https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/87f9a81cd770..ed63a7459376 $ git log 87f9a81cd..ed63a7459 --date=short --no-merges --format='%ad %ae %s' 2022-12-09 jamrial dav1d: add an option to skip decoding some frame types 2022-12-08 jamrial picture: support creating and freeing refs without tile data 2022-12-07 gramner x86: Add 10bpc 8x32/32x8 itx AVX-512 (Ice Lake) asm 2022-12-07 gramner x86: Add minor DC-only IDCT optimizations 2022-12-13 gramner getbits: Fix assertion failure 2022-12-13 gramner checkasm: Fix integer overflow in refmvs test 2022-01-26 gramner dav1dplay: Update to new libplacebo API 2022-12-09 gramner Add minor getbits improvements 2022-12-09 gramner Add a separate getbits function for getting a single bit 2022-12-09 gramner Remove redundant zeroing in sequence header parsing 2022-12-09 gramner Set the correct default value of initial_display_delay 2022-12-09 jamrial tools: remove the null last entry in inloop_filters_tbl 2022-12-04 lu_zero Do not assume the picture allocation starts as the left edge 2022-11-21 lu_zero ppc: Allocate the correct temp buffer size 2022-11-21 lu_zero ppc: Do not use static const with vec_splats 2022-11-02 charlie.c.hayden Add info to dav1d_send_data docs 2022-10-30 jbeich build: drop -D_DARWIN_C_SOURCE on macOS/iOS after 6b611d36acab 2022-10-30 jbeich build: drop -D_POSIX_C_SOURCE on non-Linux after 6b611d36acab 2022-06-28 victorien threading: Add a pending list for async task insertion 2022-10-26 martin Implement atomic_compare_exchange_strong in the atomic compat headers 2022-10-06 victorien threading: Fix a race around frame completion (frame-mt) 2022-10-07 sebastian Handle host_machine.system() 'ios' and 'tvos' the same way as 'darwin' 2022-09-23 gramner x86: Add 10-bit 8x8/8x16/16x8/16x16 itx AVX-512 (Ice Lake) asm 2022-09-30 gramner Specify hidden visibility for global data symbol declarations 2022-09-28 gramner build: strip() the result of cc.get_define() 2022-09-26 gramner checkasm: Move printf format string to .rodata on x86 2022-09-26 gramner checkasm: Improve 32-bit parameter clobbering on x86-64 2022-09-26 gramner x86: Fix incorrect 32-bit parameter usage in high bit-depth AVX-512 mc 2022-09-09 martin arm: itx: Add clipping to row_clip_min/max in the 10 bpc codepaths 2022-09-15 gramner x86: Fix overflows in 12bpc AVX2 IDCT/IADST 2022-09-15 gramner x86: Fix overflows in 12bpc AVX2 DC-only IDCT 2022-09-15 gramner x86: Fix clipping in high bit-depth AVX2 4x16 IDCT 2022-03-21 martin Don't use gas-preprocessor with clang-cl for arm targets 2022-06-07 david_conrad Fix checking the reference dimesions for the projection process 2022-06-07 david_conrad Fix calculation of OBMC lap dimensions 2022-06-07 david_conrad Support film grain application whose only effect is clipping to video range 2022-06-07 david_conrad Ignore T.35 metadata if the OBU contains no payload 2022-06-07 david_conrad Fix chroma deblock filter size calculation for lossless 2022-06-07 david_conrad Fix rounding in the calculation of initialSubpelX 2022-06-07 david_conrad Fix overflow when saturating dequantized coefficients clipped to 0 2022-06-08 david_conrad Fix overflow in 8-bit NEON ADST 2022-09-14 martin tools: Allocate the priv structs with proper alignment 2022-09-08 gramner x86: Fix clipping in 10bpc SSE4.1 IDCT asm 2022-09-08 gramner build: Improve Windows linking options 2022-09-08 gramner tools: Improve demuxer probing 2022-08-30 code CI: Disable trimming on some tests 2022-08-30 code CI: Remove git 'safe.directory' config 2022-08-30 code gcovr: Ignore parsing errors 2022-08-30 code crossfiles: Update Android toolchains 2022-08-30 code CI: Update images (...) 2022-09-01 victorien checkasm: Add short options 2022-09-01 victorien checkasm: Add pattern matching to --test 2022-09-01 victorien checkasm: Remove pattern matching from --bench 2022-08-29 victorien checkasm: Add a --function option 2022-08-30 victorien threading: Fix copy_lpf_progress initialization 2022-08-19 jamrial data: don't overwrite the Dav1dDataProps size value 2022-07-18 gramner Adjust inlining attributes on some functions 2022-07-19 gramner x86: Remove leftover instruction in loopfilter AVX2 asm 2022-06-07 david_conrad Enable pointer authentication in assembly when building arm64e 2022-06-07 david_conrad Don't trash the return stack buffer in the NEON loop filter 2022-07-03 thresh CI: Removed snap package generation 2022-07-06 gramner Eliminate unused C DSP functions at compile time 2022-07-06 gramner cpu: Inline dav1d_get_cpu_flags() 2022-06-22 gramner x86: Add minor loopfilter asm improvements 2022-06-15 gramner checkasm: Speed up signal handling 2022-06-15 gramner checkasm: Improve seed generation on Windows 2022-06-20 gramner ci: Don't specify a specific MacOS version 2022-06-14 gramner x86: Add high bit-depth loopfilter AVX-512 (Ice Lake) asm 2022-06-13 victorien checkasm/lpf: Use operating dimensions 2022-06-03 gramner checkasm: Print the cpu model and cpuid signature on x86 2022-06-03 gramner checkasm: Add a vzeroupper check on x86 2022-06-02 gramner x86: Add a workaround for quirky AVX-512 hardware behavior 2022-05-31 victorien checkasm: Fix uninitialized variable 2022-05-14 code CI: Update coverage collecting 2022-05-05 code CI: Add a build with the minimum requirements 2022-05-05 code CI: Deactivate git 'safe.directory' 2022-03-24 code CI: Update images 2022-05-25 victorien Fix typo 2022-05-19 gramner x86: Add high bit-depth cdef_filter AVX-512 (Ice Lake) asm 2022-05-20 gramner checkasm: Print --help message to stderr instead of stdout 2022-05-20 gramner checkasm: Split cdef test into separate pri/sec/pri+sec parts 2022-05-20 gramner checkasm: Improve benchmarking of functions that modify their input 2022-05-18 b x86/itx_avx2: fix typo 2022-04-22 code CI: Add gcc12 and clang14 builds with mold linker 2022-04-26 code CI: Trigger documentation rebuild if configuration changes 2022-04-24 code meson/doc: Fix doxygen config 2022-04-28 gramner Use a relaxed memory ordering in dav1d_ref_inc() 2022-04-28 gramner Remove redundant code in dav1d_cdf_thread_unref() 2022-04-28 gramner Inline dav1d_ref_inc() 2022-04-24 code x86/itx: Add 32x8 12bpc AVX2 transforms 2022-04-24 code x86/itx: Add 8x32 12bpc AVX2 transforms 2022-04-24 code x86/itx: Deduplicate dconly code 2022-04-23 code lib: Fix typo in documentation 2022-04-07 jamrial obu: don't output invisible but showable key frames more than once 2022-04-07 jamrial obu: check that the frame referenced by existing_frame_idx is showable 2022-04-07 jamrial obu: check refresh_frame_flags is not equal to allFrames on Intra Only frames 2022-03-29 robux4 remove multipass wait from dav1d_decode_frame 2022-04-07 jamrial picture: ensure the new seq header and op param info flags are attached to the next visible picture in display order 2022-03-31 jamrial lib: add a function to query the decoder frame delay 2022-03-31 jamrial lib: split calculating thread count to its own function Created with: roll-dep src/third_party/dav1d/libdav1d Fixed: 1401571 Change-Id: Ic3cef540a87a2cf411abe6071fd4c9963ea61f75 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4114163 Reviewed-by: Wan-Teh Chang <wtc@google.com> Commit-Queue: Dale Curtis <dalecurtis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1084574} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/468619 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/dav1d/libdav1d/src/decode.c')
-rw-r--r--chromium/third_party/dav1d/libdav1d/src/decode.c95
1 files changed, 59 insertions, 36 deletions
diff --git a/chromium/third_party/dav1d/libdav1d/src/decode.c b/chromium/third_party/dav1d/libdav1d/src/decode.c
index 13d57060710..2c816338a9e 100644
--- a/chromium/third_party/dav1d/libdav1d/src/decode.c
+++ b/chromium/third_party/dav1d/libdav1d/src/decode.c
@@ -749,9 +749,9 @@ static inline void splat_intraref(const Dav1dContext *const c,
c->refmvs_dsp.splat_mv(&t->rt.r[(t->by & 31) + 5], &tmpl, t->bx, bw4, bh4);
}
-static inline 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 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)
{
const int v_mul = 4 >> ss_ver;
if (!smp->scale) {
@@ -766,14 +766,11 @@ static inline void mc_lowest_px(int *const dst, const int by4, const int bh4,
}
}
-static inline void affine_lowest_px(Dav1dTaskContext *const t,
- int *const dst, const int is_chroma,
- const uint8_t *const b_dim,
- const Dav1dWarpedMotionParams *const wmp)
+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)
{
- const Dav1dFrameContext *const f = t->f;
- const int ss_ver = is_chroma && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
- const int ss_hor = is_chroma && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const int h_mul = 4 >> ss_hor, v_mul = 4 >> ss_ver;
assert(!((b_dim[0] * h_mul) & 7) && !((b_dim[1] * v_mul) & 7));
const int32_t *const mat = wmp->matrix;
@@ -792,6 +789,25 @@ static inline void affine_lowest_px(Dav1dTaskContext *const t,
}
}
+static NOINLINE void affine_lowest_px_luma(Dav1dTaskContext *const t, int *const dst,
+ const uint8_t *const b_dim,
+ const Dav1dWarpedMotionParams *const wmp)
+{
+ affine_lowest_px(t, dst, b_dim, wmp, 0, 0);
+}
+
+static NOINLINE void affine_lowest_px_chroma(Dav1dTaskContext *const t, int *const dst,
+ const uint8_t *const b_dim,
+ const Dav1dWarpedMotionParams *const wmp)
+{
+ const Dav1dFrameContext *const f = t->f;
+ assert(f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400);
+ if (f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I444)
+ affine_lowest_px_luma(t, dst, b_dim, wmp);
+ else
+ affine_lowest_px(t, dst, b_dim, wmp, f->cur.p.layout & DAV1D_PIXEL_LAYOUT_I420, 1);
+}
+
static void obmc_lowest_px(Dav1dTaskContext *const t,
int (*const dst)[2], const int is_chroma,
const uint8_t *const b_dim,
@@ -2071,11 +2087,14 @@ static int decode_b(Dav1dTaskContext *const t,
const uint8_t (*const lf_lvls)[8][2] = (const uint8_t (*)[8][2])
&ts->lflvl[b->seg_id][0][b->ref[0] + 1][!is_globalmv];
const uint16_t tx_split[2] = { b->tx_split0, b->tx_split1 };
+ enum RectTxfmSize ytx = b->max_ytx, uvtx = b->uvtx;
+ if (f->frame_hdr->segmentation.lossless[b->seg_id]) {
+ ytx = (enum RectTxfmSize) TX_4X4;
+ uvtx = (enum RectTxfmSize) TX_4X4;
+ }
dav1d_create_lf_mask_inter(t->lf_mask, f->lf.level, f->b4_stride, lf_lvls,
t->bx, t->by, f->w4, f->h4, b->skip, bs,
- f->frame_hdr->segmentation.lossless[b->seg_id] ?
- (enum RectTxfmSize) TX_4X4 : b->max_ytx,
- tx_split, b->uvtx, f->cur.p.layout,
+ ytx, tx_split, uvtx, f->cur.p.layout,
&t->a->tx_lpf_y[bx4], &t->l.tx_lpf_y[by4],
has_chroma ? &t->a->tx_lpf_uv[cbx4] : NULL,
has_chroma ? &t->l.tx_lpf_uv[cby4] : NULL);
@@ -2150,9 +2169,9 @@ static int decode_b(Dav1dTaskContext *const t,
((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) ||
(b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION)))
{
- affine_lowest_px(t, &lowest_px[b->ref[0]][0], 0, b_dim,
- b->motion_mode == MM_WARP ? &t->warpmv :
- &f->frame_hdr->gmv[b->ref[0]]);
+ affine_lowest_px_luma(t, &lowest_px[b->ref[0]][0], b_dim,
+ b->motion_mode == MM_WARP ? &t->warpmv :
+ &f->frame_hdr->gmv[b->ref[0]]);
} else {
mc_lowest_px(&lowest_px[b->ref[0]][0], t->by, bh4, b->mv[0].y,
0, &f->svc[b->ref[0]][1]);
@@ -2203,9 +2222,9 @@ static int decode_b(Dav1dTaskContext *const t,
((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) ||
(b->motion_mode == MM_WARP && t->warpmv.type > DAV1D_WM_TYPE_TRANSLATION)))
{
- affine_lowest_px(t, &lowest_px[b->ref[0]][1], 1, b_dim,
- b->motion_mode == MM_WARP ? &t->warpmv :
- &f->frame_hdr->gmv[b->ref[0]]);
+ affine_lowest_px_chroma(t, &lowest_px[b->ref[0]][1], b_dim,
+ b->motion_mode == MM_WARP ? &t->warpmv :
+ &f->frame_hdr->gmv[b->ref[0]]);
} else {
mc_lowest_px(&lowest_px[b->ref[0]][1],
t->by & ~ss_ver, bh4 << (bh4 == ss_ver),
@@ -2220,8 +2239,8 @@ static int decode_b(Dav1dTaskContext *const t,
// y
for (int i = 0; i < 2; i++) {
if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) {
- affine_lowest_px(t, &lowest_px[b->ref[i]][0], 0, b_dim,
- &f->frame_hdr->gmv[b->ref[i]]);
+ affine_lowest_px_luma(t, &lowest_px[b->ref[i]][0], b_dim,
+ &f->frame_hdr->gmv[b->ref[i]]);
} else {
mc_lowest_px(&lowest_px[b->ref[i]][0], t->by, bh4,
b->mv[i].y, 0, &f->svc[b->ref[i]][1]);
@@ -2233,8 +2252,8 @@ static int decode_b(Dav1dTaskContext *const t,
if (b->inter_mode == GLOBALMV_GLOBALMV &&
imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]])
{
- affine_lowest_px(t, &lowest_px[b->ref[i]][1], 1, b_dim,
- &f->frame_hdr->gmv[b->ref[i]]);
+ affine_lowest_px_chroma(t, &lowest_px[b->ref[i]][1], b_dim,
+ &f->frame_hdr->gmv[b->ref[i]]);
} else {
mc_lowest_px(&lowest_px[b->ref[i]][1], t->by, bh4,
b->mv[i].y, ss_ver, &f->svc[b->ref[i]][1]);
@@ -3407,7 +3426,7 @@ void dav1d_decode_frame_exit(Dav1dFrameContext *const f, const int retval) {
(size_t)f->frame_thread.cf_sz * 128 * 128 / 2);
}
for (int i = 0; i < 7; i++) {
- if (f->refp[i].p.data[0])
+ if (f->refp[i].p.frame_hdr)
dav1d_thread_picture_unref(&f->refp[i]);
dav1d_ref_dec(&f->ref_mvs_ref[i]);
}
@@ -3440,13 +3459,12 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
// wait until all threads have completed
if (!res) {
if (f->c->n_tc > 1) {
- pthread_mutex_lock(&f->task_thread.ttd->lock);
res = dav1d_task_create_tile_sbrow(f, 0, 1);
+ pthread_mutex_lock(&f->task_thread.ttd->lock);
+ pthread_cond_signal(&f->task_thread.ttd->cond);
if (!res) {
- const int uses_2pass = f->c->n_fc > 1;
while (!f->task_thread.done[0] ||
- (uses_2pass && !f->task_thread.done[1]) ||
- f->task_thread.task_counter > 0)
+ atomic_load(&f->task_thread.task_counter) > 0)
{
pthread_cond_wait(&f->task_thread.cond,
&f->task_thread.ttd->lock);
@@ -3469,7 +3487,7 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
static int get_upscale_x0(const int in_w, const int out_w, const int step) {
const int err = out_w * step - (in_w << 14);
- const int x0 = (-((out_w - in_w) << 13) + (out_w >> 1)) / out_w + 128 - (err >> 1);
+ const int x0 = (-((out_w - in_w) << 13) + (out_w >> 1)) / out_w + 128 - (err / 2);
return x0 & 0x3fff;
}
@@ -3491,10 +3509,13 @@ int dav1d_submit_frame(Dav1dContext *const c) {
&c->task_thread.lock);
out_delayed = &c->frame_thread.out_delayed[next];
if (out_delayed->p.data[0] || atomic_load(&f->task_thread.error)) {
- if (atomic_load(&c->task_thread.first) + 1U < c->n_fc)
+ unsigned first = atomic_load(&c->task_thread.first);
+ if (first + 1U < c->n_fc)
atomic_fetch_add(&c->task_thread.first, 1U);
else
atomic_store(&c->task_thread.first, 0);
+ atomic_compare_exchange_strong(&c->task_thread.reset_task_cur,
+ &first, UINT_MAX);
if (c->task_thread.cur && c->task_thread.cur < c->n_fc)
c->task_thread.cur--;
}
@@ -3706,7 +3727,8 @@ int dav1d_submit_frame(Dav1dContext *const c) {
const int uses_2pass = c->n_fc > 1;
const int cols = f->frame_hdr->tiling.cols;
const int rows = f->frame_hdr->tiling.rows;
- f->task_thread.task_counter = (cols * rows + f->sbh) << uses_2pass;
+ atomic_store(&f->task_thread.task_counter,
+ (cols * rows + f->sbh) << uses_2pass);
// ref_mvs
if (IS_INTER_OR_SWITCH(f->frame_hdr) || f->frame_hdr->allow_intrabc) {
@@ -3726,9 +3748,10 @@ int dav1d_submit_frame(Dav1dContext *const c) {
if (f->frame_hdr->use_ref_frame_mvs) {
for (int i = 0; i < 7; i++) {
const int refidx = f->frame_hdr->refidx[i];
+ const int ref_w = ((ref_coded_width[i] + 7) >> 3) << 1;
+ const int ref_h = ((f->refp[i].p.p.h + 7) >> 3) << 1;
if (c->refs[refidx].refmvs != NULL &&
- ref_coded_width[i] == f->cur.p.w &&
- f->refp[i].p.p.h == f->cur.p.h)
+ ref_w == f->bw && ref_h == f->bh)
{
f->ref_mvs_ref[i] = c->refs[refidx].refmvs;
dav1d_ref_inc(f->ref_mvs_ref[i]);
@@ -3809,7 +3832,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
const unsigned refresh_frame_flags = f->frame_hdr->refresh_frame_flags;
for (int i = 0; i < 8; i++) {
if (refresh_frame_flags & (1 << i)) {
- if (c->refs[i].p.p.data[0])
+ if (c->refs[i].p.p.frame_hdr)
dav1d_thread_picture_unref(&c->refs[i].p);
dav1d_thread_picture_ref(&c->refs[i].p, &f->sr_cur);
@@ -3839,7 +3862,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
dav1d_thread_picture_unref(&c->out);
for (int i = 0; i < 8; i++) {
if (refresh_frame_flags & (1 << i)) {
- if (c->refs[i].p.p.data[0])
+ if (c->refs[i].p.p.frame_hdr)
dav1d_thread_picture_unref(&c->refs[i].p);
dav1d_cdf_thread_unref(&c->cdf[i]);
dav1d_ref_dec(&c->refs[i].segmap);
@@ -3860,7 +3883,7 @@ error:
if (f->frame_hdr->refresh_context)
dav1d_cdf_thread_unref(&f->out_cdf);
for (int i = 0; i < 7; i++) {
- if (f->refp[i].p.data[0])
+ if (f->refp[i].p.frame_hdr)
dav1d_thread_picture_unref(&f->refp[i]);
dav1d_ref_dec(&f->ref_mvs_ref[i]);
}