ref: 9c4bf181e0871d73cceb6e166447cfc3c6c7ca42
parent: 144063388dbd11c5b95d0ec128238bff401f5b95
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Fri Nov 23 15:45:09 EST 2018
Add some more constants from section 3
--- a/include/dav1d/headers.h
+++ b/include/dav1d/headers.h
@@ -29,8 +29,15 @@
#define __DAV1D_HEADERS_H__
// Constants from Section 3. "Symbols and abbreviated terms"
+#define DAV1D_MAX_CDEF_STRENGTHS 8
+#define DAV1D_MAX_OPERATING_POINTS 32
#define DAV1D_MAX_TILE_COLS 64
#define DAV1D_MAX_TILE_ROWS 64
+#define DAV1D_MAX_SEGMENTS 8
+#define DAV1D_NUM_REF_FRAMES 8
+#define DAV1D_PRIMARY_REF_NONE 7
+#define DAV1D_REFS_PER_FRAME 7
+#define DAV1D_TOTAL_REFS_PER_FRAME (DAV1D_REFS_PER_FRAME + 1)
enum Dav1dTxfmMode {
DAV1D_TX_4X4_ONLY,
@@ -179,7 +186,7 @@
int low_delay_mode;
int display_model_param_present;
int initial_display_delay;
- } operating_points[32];
+ } operating_points[DAV1D_MAX_OPERATING_POINTS];
int max_width, max_height, width_n_bits, height_n_bits;
int frame_id_numbers_present;
int delta_frame_id_n_bits;
@@ -213,8 +220,6 @@
int film_grain_present;
} Dav1dSequenceHeader;
-#define DAV1D_NUM_SEGMENTS 8
-
typedef struct Dav1dSegmentationData {
int delta_q;
int delta_lf_y_v, delta_lf_y_h, delta_lf_u, delta_lf_v;
@@ -224,14 +229,14 @@
} Dav1dSegmentationData;
typedef struct Dav1dSegmentationDataSet {
- Dav1dSegmentationData d[DAV1D_NUM_SEGMENTS];
+ Dav1dSegmentationData d[DAV1D_MAX_SEGMENTS];
int preskip;
int last_active_segid;
} Dav1dSegmentationDataSet;
typedef struct Dav1dLoopfilterModeRefDeltas {
- int mode_delta[2];
- int ref_delta[8];
+ int mode_delta[2 /* is_zeromv */];
+ int ref_delta[DAV1D_TOTAL_REFS_PER_FRAME];
} Dav1dLoopfilterModeRefDeltas;
typedef struct Dav1dFilmGrainData {
@@ -267,12 +272,11 @@
int allow_screen_content_tools;
int force_integer_mv;
int frame_size_override;
-#define DAV1D_PRIMARY_REF_NONE 7
int primary_ref_frame;
int buffer_removal_time_present;
struct Dav1dFrameHeaderOperatingPoint {
int buffer_removal_time;
- } operating_points[32];
+ } operating_points[DAV1D_MAX_OPERATING_POINTS];
int frame_offset;
int refresh_frame_flags;
int width[2 /* { coded_width, superresolution_upscaled_width } */], height;
@@ -284,7 +288,7 @@
int have_render_size;
int allow_intrabc;
int frame_ref_short_signaling;
- int refidx[7];
+ int refidx[DAV1D_REFS_PER_FRAME];
int hp;
enum Dav1dFilterMode subpel_filter_mode;
int switchable_motion_mode;
@@ -308,7 +312,7 @@
struct {
int enabled, update_map, temporal, update_data;
Dav1dSegmentationDataSet seg_data;
- int lossless[DAV1D_NUM_SEGMENTS], qidx[DAV1D_NUM_SEGMENTS];
+ int lossless[DAV1D_MAX_SEGMENTS], qidx[DAV1D_MAX_SEGMENTS];
} segmentation;
struct {
struct {
@@ -323,7 +327,7 @@
} delta;
int all_lossless;
struct {
- int level_y[2];
+ int level_y[2 /* dir */];
int level_u, level_v;
int mode_ref_delta_enabled;
int mode_ref_delta_update;
@@ -333,12 +337,12 @@
struct {
int damping;
int n_bits;
- int y_strength[8];
- int uv_strength[8];
+ int y_strength[DAV1D_MAX_CDEF_STRENGTHS];
+ int uv_strength[DAV1D_MAX_CDEF_STRENGTHS];
} cdef;
struct {
- enum Dav1dRestorationType type[3];
- int unit_size[2];
+ enum Dav1dRestorationType type[3 /* plane */];
+ int unit_size[2 /* y, uv */];
} restoration;
enum Dav1dTxfmMode txfm_mode;
int switchable_comp_refs;
@@ -345,7 +349,7 @@
int skip_mode_allowed, skip_mode_enabled, skip_mode_refs[2];
int warp_motion;
int reduced_txtp_set;
- Dav1dWarpedMotionParams gmv[7];
+ Dav1dWarpedMotionParams gmv[DAV1D_REFS_PER_FRAME];
struct {
int present, update;
Dav1dFilmGrainData data;
--- a/src/cdf.c
+++ b/src/cdf.c
@@ -4138,7 +4138,7 @@
update_cdf_4d(N_TX_SIZES, 2, 41 /*42*/, 4, coef.base_tok);
update_bit_2d(2, 3, coef.dc_sign);
update_cdf_4d(4, 2, 21, 4, coef.br_tok);
- update_cdf_2d(3, DAV1D_NUM_SEGMENTS, m.seg_id);
+ update_cdf_2d(3, DAV1D_MAX_SEGMENTS, m.seg_id);
update_cdf_1d(8, m.cfl_sign);
update_cdf_2d(6, 16, m.cfl_alpha);
update_bit_0d(m.restore_wiener);
--- a/src/cdf.h
+++ b/src/cdf.h
@@ -68,7 +68,7 @@
uint16_t skip_mode[3][2];
uint16_t partition[N_BL_LEVELS][4][N_PARTITIONS + 1];
uint16_t seg_pred[3][2];
- uint16_t seg_id[3][DAV1D_NUM_SEGMENTS + 1];
+ uint16_t seg_id[3][DAV1D_MAX_SEGMENTS + 1];
uint16_t cfl_sign[8 + 1];
uint16_t cfl_alpha[6][16 + 1];
uint16_t restore_wiener[2];
--- a/src/decode.c
+++ b/src/decode.c
@@ -803,13 +803,13 @@
&seg_ctx, f->cur_segmap, f->b4_stride);
const unsigned diff = msac_decode_symbol_adapt(&ts->msac,
ts->cdf.m.seg_id[seg_ctx],
- DAV1D_NUM_SEGMENTS);
+ DAV1D_MAX_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
last_active_seg_id + 1);
if (b->seg_id > last_active_seg_id) b->seg_id = 0; // error?
- if (b->seg_id >= DAV1D_NUM_SEGMENTS) b->seg_id = 0; // error?
+ if (b->seg_id >= DAV1D_MAX_SEGMENTS) b->seg_id = 0; // error?
}
if (DEBUG_BLOCK_INFO)
@@ -875,7 +875,7 @@
} else {
const unsigned diff = msac_decode_symbol_adapt(&ts->msac,
ts->cdf.m.seg_id[seg_ctx],
- DAV1D_NUM_SEGMENTS);
+ DAV1D_MAX_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
@@ -882,7 +882,7 @@
last_active_seg_id + 1);
if (b->seg_id > last_active_seg_id) b->seg_id = 0; // error?
}
- if (b->seg_id >= DAV1D_NUM_SEGMENTS) b->seg_id = 0; // error?
+ if (b->seg_id >= DAV1D_MAX_SEGMENTS) b->seg_id = 0; // error?
}
seg = &f->frame_hdr->segmentation.seg_data.d[b->seg_id];
--- a/src/internal.h
+++ b/src/internal.h
@@ -165,7 +165,7 @@
pixel *ipred_edge[3];
ptrdiff_t b4_stride;
int w4, h4, bw, bh, sb128w, sb128h, sbh, sb_shift, sb_step, sr_sb128w;
- uint16_t dq[DAV1D_NUM_SEGMENTS][3 /* plane */][2 /* dc/ac */];
+ uint16_t dq[DAV1D_MAX_SEGMENTS][3 /* plane */][2 /* dc/ac */];
const uint8_t *qm[2 /* is_1d */][N_RECT_TX_SIZES][3 /* plane */];
BlockContext *a;
int a_sz /* w*tile_rows */;
@@ -243,7 +243,7 @@
coef *cf;
} frame_thread;
- uint16_t dqmem[DAV1D_NUM_SEGMENTS][3 /* plane */][2 /* dc/ac */];
+ uint16_t dqmem[DAV1D_MAX_SEGMENTS][3 /* plane */][2 /* dc/ac */];
const uint16_t (*dq)[3][2];
int last_qidx;
--- a/src/obu.c
+++ b/src/obu.c
@@ -682,7 +682,7 @@
if (hdr->segmentation.update_data) {
hdr->segmentation.seg_data.preskip = 0;
hdr->segmentation.seg_data.last_active_segid = -1;
- for (int i = 0; i < DAV1D_NUM_SEGMENTS; i++) {
+ for (int i = 0; i < DAV1D_MAX_SEGMENTS; i++) {
Dav1dSegmentationData *const seg =
&hdr->segmentation.seg_data.d[i];
if (dav1d_get_bits(gb, 1)) {
@@ -742,7 +742,7 @@
}
} else {
memset(&hdr->segmentation.seg_data, 0, sizeof(Dav1dSegmentationDataSet));
- for (int i = 0; i < DAV1D_NUM_SEGMENTS; i++)
+ for (int i = 0; i < DAV1D_MAX_SEGMENTS; i++)
hdr->segmentation.seg_data.d[i].ref = -1;
}
#if DEBUG_FRAME_HDR
@@ -766,7 +766,7 @@
const int delta_lossless = !hdr->quant.ydc_delta && !hdr->quant.udc_delta &&
!hdr->quant.uac_delta && !hdr->quant.vdc_delta && !hdr->quant.vac_delta;
hdr->all_lossless = 1;
- for (int i = 0; i < DAV1D_NUM_SEGMENTS; i++) {
+ for (int i = 0; i < DAV1D_MAX_SEGMENTS; i++) {
hdr->segmentation.qidx[i] = hdr->segmentation.enabled ?
iclip_u8(hdr->quant.yac + hdr->segmentation.seg_data.d[i].delta_q) :
hdr->quant.yac;