Merge tag 'v3.10.0' into main branch
2024-08-27 v3.10.0
This release includes new codec interfaces, compression efficiency and
perceptual improvements, speedup and memory optimizations and many bug
fixes. This release is ABI compatible with the last release.
The definitions of the internal macros AOM_INLINE and AOM_FORCE_INLINE
have been removed from the public header aom/aom_integer.h.
- New Features
* New codec controls:
* AV1E_SET_AUTO_TILES
* AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC
* AV1E_SET_POSTENCODE_DROP_RTC: Post encode frame drop feature.
* AV1E_SET_MAX_CONSEC_FRAME_DROP_MS_CBR
* New key-value pair for aom_codec_set_option():
* "auto-tiles": equivalent to the new codec control
AV1E_SET_AUTO_TILES.
- Deprecated Features
* Deprecated codec control:
* AV1E_SET_MAX_CONSEC_FRAME_DROP_CBR: Use the new codec control
AV1E_SET_MAX_CONSEC_FRAME_DROP_MS_CBR instead.
* The sframe_mode field in the aom_codec_enc_cfg_t struct is not
implemented.
- Compression Efficiency Improvements
* BD-rate gain of 0.7 - 1.3% (by enabling global motion tool) for
speed 5 and speed 6 with ~5% encode time increase.
* RTC speed 11 video: ~3-5% BD-rate gain for VGA and QVGA.
- Perceptual Quality Improvements
* RTC quality improvements for slide changes and scrolling content.
- Speedup and Memory Optimizations
* RTC screen content speedups:
* ~2x speedup for high motion content for speed 11.
* ~2x speedup on key frame coding for speed >= 10.
* Arm: Significant uplifts in speed in this release (vs v3.9.1) have
come from tuning the various convolutions according to filter size
(doing 8-tap when only 2-tap is required is inefficient) and also
deploying Armv8.6 USMMLA instructions in 6-tap and 12-tap standard
bitdepth convolutions.
* Standard bitdepth RTC:
* speed 5: +5%
* speed 6: +4%
* speed 7: +5%
* speed 8: +4%
* speed 9: +6%
* speed 10: +6%
* Standard bitdepth VoD:
* speed 0: +9%
* speed 1: +12%
* speed 2: +9%
* speed 3: +3%
* speed 4: +3%
* speed 5: -9% (expected due to global motion changes)
* speed 6: -3% (expected due to global motion changes)
* High bitdepth VoD:
* speed 0: +4%
* speed 1: +19%
* speed 2: +23%
* speed 3: +1%
* speed 4: +1%
* speed 5: -8% (expected due to global motion changes)
* speed 6: -3% (expected due to global motion changes)
* Standard bitdepth 2x1 horizontal super-resolution/scaling
encoding: +101%
- Other Improvements
* Reduce bit rate overshoot on slide content.
- Bug Fixes
* rtc: Bug fix for active_maps with sb_size=128.
* b:343429036: rtc: Fix source_sad setting near boundary.
* Fix to QP for temporal enhancement after key frame.
* b:343429192: rtc: Condition QP adjustment on rc->q_1/2_frame > 0.
Bug: 361339153
Change-Id: Ie5f80965f5516d24b235bd6a7d3f4defce508a8c
diff --git a/README.md b/README.md
index 814ee89..db7ad37 100644
--- a/README.md
+++ b/README.md
@@ -700,4 +700,5 @@
## Bug reports {#bug-reports}
Bug reports can be filed in the Alliance for Open Media
-[issue tracker](https://aomedia.issues.chromium.org/).
+[issue tracker](https://aomedia.issues.chromium.org/). For security reports,
+select 'Security report' from the Template dropdown.
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake
index e5f9698..f875456 100644
--- a/aom_dsp/aom_dsp.cmake
+++ b/aom_dsp/aom_dsp.cmake
@@ -47,11 +47,14 @@
"${AOM_ROOT}/aom_dsp/x86/convolve_common_intrin.h")
list(APPEND AOM_DSP_COMMON_ASM_SSE2
- "${AOM_ROOT}/aom_dsp/x86/aom_high_subpixel_8t_sse2.asm"
- "${AOM_ROOT}/aom_dsp/x86/aom_high_subpixel_bilinear_sse2.asm"
- "${AOM_ROOT}/aom_dsp/x86/highbd_intrapred_asm_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/intrapred_asm_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/inv_wht_sse2.asm")
+if(CONFIG_AV1_HIGHBITDEPTH)
+ list(APPEND AOM_DSP_COMMON_ASM_SSE2
+ "${AOM_ROOT}/aom_dsp/x86/aom_high_subpixel_8t_sse2.asm"
+ "${AOM_ROOT}/aom_dsp/x86/aom_high_subpixel_bilinear_sse2.asm"
+ "${AOM_ROOT}/aom_dsp/x86/highbd_intrapred_asm_sse2.asm")
+endif()
list(APPEND AOM_DSP_COMMON_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/aom_convolve_copy_sse2.c"
@@ -157,8 +160,6 @@
if(CONFIG_AV1_ENCODER)
list(APPEND AOM_DSP_ENCODER_SOURCES
"${AOM_ROOT}/aom_dsp/avg.c"
- "${AOM_ROOT}/aom_dsp/binary_codes_writer.c"
- "${AOM_ROOT}/aom_dsp/binary_codes_writer.h"
"${AOM_ROOT}/aom_dsp/bitwriter.c"
"${AOM_ROOT}/aom_dsp/bitwriter.h"
"${AOM_ROOT}/aom_dsp/blk_sse_sum.c"
@@ -190,6 +191,8 @@
# Flow estimation library
if(NOT CONFIG_REALTIME_ONLY)
list(APPEND AOM_DSP_ENCODER_SOURCES "${AOM_ROOT}/aom_dsp/pyramid.c"
+ "${AOM_ROOT}/aom_dsp/binary_codes_writer.c"
+ "${AOM_ROOT}/aom_dsp/binary_codes_writer.h"
"${AOM_ROOT}/aom_dsp/flow_estimation/corner_detect.c"
"${AOM_ROOT}/aom_dsp/flow_estimation/corner_match.c"
"${AOM_ROOT}/aom_dsp/flow_estimation/disflow.c"
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index a7f74ee..5d4dce1 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -1283,11 +1283,6 @@
add_proto qw/void aom_ssim_parms_8x8/, "const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr";
specialize qw/aom_ssim_parms_8x8/, "$sse2_x86_64";
- if (aom_config("CONFIG_INTERNAL_STATS") eq "yes") {
- add_proto qw/void aom_ssim_parms_16x16/, "const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr";
- specialize qw/aom_ssim_parms_16x16/, "$sse2_x86_64";
- }
-
if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
add_proto qw/void aom_highbd_ssim_parms_8x8/, "const uint16_t *s, int sp, const uint16_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr";
}
@@ -1341,11 +1336,10 @@
}
}
- #
- #
- #
- add_proto qw/unsigned int aom_get_mb_ss/, "const int16_t *";
- specialize qw/aom_get_mb_ss sse2 neon/;
+ if (aom_config("CONFIG_REALTIME_ONLY") ne "yes") {
+ add_proto qw/unsigned int aom_get_mb_ss/, "const int16_t *";
+ specialize qw/aom_get_mb_ss sse2 neon/;
+ }
#
# Variance / Subpixel Variance / Subpixel Avg Variance
diff --git a/aom_dsp/arm/intrapred_neon.c b/aom_dsp/arm/intrapred_neon.c
index a81fb1c..e44e186 100644
--- a/aom_dsp/arm/intrapred_neon.c
+++ b/aom_dsp/arm/intrapred_neon.c
@@ -1050,7 +1050,7 @@
/* ---------------------P R E D I C T I O N Z 1--------------------------- */
// Low bit depth functions
-static DECLARE_ALIGNED(32, uint8_t, BaseMask[33][32]) = {
+static DECLARE_ALIGNED(32, const uint8_t, BaseMask[33][32]) = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1489,7 +1489,7 @@
/* ---------------------P R E D I C T I O N Z 2--------------------------- */
#if !AOM_ARCH_AARCH64
-static DECLARE_ALIGNED(16, uint8_t, LoadMaskz2[4][16]) = {
+static DECLARE_ALIGNED(16, const uint8_t, LoadMaskz2[4][16]) = {
{ 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0,
@@ -2352,7 +2352,7 @@
const uint8_t *left, int upsample_left,
int dy);
-static dr_prediction_z3_fn dr_prediction_z3_arr[7][7] = {
+static const dr_prediction_z3_fn dr_prediction_z3_arr[7][7] = {
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL },
{ NULL, NULL, dr_prediction_z3_4x4_neon, dr_prediction_z3_4x8_neon,
diff --git a/aom_dsp/arm/variance_neon.c b/aom_dsp/arm/variance_neon.c
index 74524ad..fb46857 100644
--- a/aom_dsp/arm/variance_neon.c
+++ b/aom_dsp/arm/variance_neon.c
@@ -445,6 +445,7 @@
return horizontal_add_u64x2(mse_wxh_16bit(dst, dstride, src, sstride, w, h));
}
+#if !CONFIG_REALTIME_ONLY
uint32_t aom_get_mb_ss_neon(const int16_t *a) {
int32x4_t sse[2] = { vdupq_n_s32(0), vdupq_n_s32(0) };
@@ -457,6 +458,7 @@
return horizontal_add_s32x4(vaddq_s32(sse[0], sse[1]));
}
+#endif // !CONFIG_REALTIME_ONLY
uint64_t aom_mse_16xh_16bit_neon(uint8_t *dst, int dstride, uint16_t *src,
int w, int h) {
diff --git a/aom_dsp/bitwriter_buffer.c b/aom_dsp/bitwriter_buffer.c
index e6e03cc..4df2d15 100644
--- a/aom_dsp/bitwriter_buffer.c
+++ b/aom_dsp/bitwriter_buffer.c
@@ -41,7 +41,7 @@
wb->bit_offset = off + 1;
}
-void aom_wb_overwrite_bit(struct aom_write_bit_buffer *wb, int bit) {
+static void overwrite_bit(struct aom_write_bit_buffer *wb, int bit) {
// Do not zero bytes but overwrite exisiting values
const int off = (int)wb->bit_offset;
const int p = off / CHAR_BIT;
@@ -67,8 +67,7 @@
void aom_wb_overwrite_literal(struct aom_write_bit_buffer *wb, int data,
int bits) {
int bit;
- for (bit = bits - 1; bit >= 0; bit--)
- aom_wb_overwrite_bit(wb, (data >> bit) & 1);
+ for (bit = bits - 1; bit >= 0; bit--) overwrite_bit(wb, (data >> bit) & 1);
}
void aom_wb_write_inv_signed_literal(struct aom_write_bit_buffer *wb, int data,
diff --git a/aom_dsp/bitwriter_buffer.h b/aom_dsp/bitwriter_buffer.h
index 1d61e86..31d87c1 100644
--- a/aom_dsp/bitwriter_buffer.h
+++ b/aom_dsp/bitwriter_buffer.h
@@ -29,8 +29,6 @@
void aom_wb_write_bit(struct aom_write_bit_buffer *wb, int bit);
-void aom_wb_overwrite_bit(struct aom_write_bit_buffer *wb, int bit);
-
void aom_wb_write_literal(struct aom_write_bit_buffer *wb, int data, int bits);
void aom_wb_write_unsigned_literal(struct aom_write_bit_buffer *wb,
diff --git a/aom_dsp/ssim.c b/aom_dsp/ssim.c
index c6edbcb..3dc0ae7 100644
--- a/aom_dsp/ssim.c
+++ b/aom_dsp/ssim.c
@@ -17,24 +17,6 @@
#include "aom_dsp/ssim.h"
#include "aom_ports/mem.h"
-#if CONFIG_INTERNAL_STATS
-void aom_ssim_parms_16x16_c(const uint8_t *s, int sp, const uint8_t *r, int rp,
- uint32_t *sum_s, uint32_t *sum_r,
- uint32_t *sum_sq_s, uint32_t *sum_sq_r,
- uint32_t *sum_sxr) {
- int i, j;
- for (i = 0; i < 16; i++, s += sp, r += rp) {
- for (j = 0; j < 16; j++) {
- *sum_s += s[j];
- *sum_r += r[j];
- *sum_sq_s += s[j] * s[j];
- *sum_sq_r += r[j] * r[j];
- *sum_sxr += s[j] * r[j];
- }
- }
-}
-#endif // CONFIG_INTERNAL_STATS
-
void aom_ssim_parms_8x8_c(const uint8_t *s, int sp, const uint8_t *r, int rp,
uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s,
uint32_t *sum_sq_r, uint32_t *sum_sxr) {
diff --git a/aom_dsp/variance.c b/aom_dsp/variance.c
index e1cc07a..6481cf7 100644
--- a/aom_dsp/variance.c
+++ b/aom_dsp/variance.c
@@ -24,6 +24,7 @@
#include "av1/common/filter.h"
#include "av1/common/reconinter.h"
+#if !CONFIG_REALTIME_ONLY
uint32_t aom_get_mb_ss_c(const int16_t *a) {
unsigned int i, sum = 0;
@@ -33,6 +34,7 @@
return sum;
}
+#endif // !CONFIG_REALTIME_ONLY
static void variance(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int w, int h, uint32_t *sse, int *sum) {
diff --git a/aom_dsp/x86/ssim_sse2_x86_64.asm b/aom_dsp/x86/ssim_sse2_x86_64.asm
index f95e834..51dc311 100644
--- a/aom_dsp/x86/ssim_sse2_x86_64.asm
+++ b/aom_dsp/x86/ssim_sse2_x86_64.asm
@@ -50,97 +50,7 @@
SECTION .text
-;void ssim_parms_sse2(
-; unsigned char *s,
-; int sp,
-; unsigned char *r,
-; int rp
-; uint32_t *sum_s,
-; uint32_t *sum_r,
-; uint32_t *sum_sq_s,
-; uint32_t *sum_sq_r,
-; uint32_t *sum_sxr);
-;
-; TODO: Use parm passing through structure, probably don't need the pxors
-; ( calling app will initialize to 0 ) could easily fit everything in sse2
-; without too much hastle, and can probably do better estimates with psadw
-; or pavgb At this point this is just meant to be first pass for calculating
-; all the parms needed for 16x16 ssim so we can play with dssim as distortion
-; in mode selection code.
-globalsym(aom_ssim_parms_16x16_sse2)
-sym(aom_ssim_parms_16x16_sse2):
- push rbp
- mov rbp, rsp
- SHADOW_ARGS_TO_STACK 9
- SAVE_XMM 15
- push rsi
- push rdi
- ; end prolog
-
- mov rsi, arg(0) ;s
- mov rcx, arg(1) ;sp
- mov rdi, arg(2) ;r
- mov rax, arg(3) ;rp
-
- pxor xmm0, xmm0
- pxor xmm15,xmm15 ;sum_s
- pxor xmm14,xmm14 ;sum_r
- pxor xmm13,xmm13 ;sum_sq_s
- pxor xmm12,xmm12 ;sum_sq_r
- pxor xmm11,xmm11 ;sum_sxr
-
- mov rdx, 16 ;row counter
-.NextRow:
-
- ;grab source and reference pixels
- movdqu xmm5, [rsi]
- movdqu xmm6, [rdi]
- movdqa xmm3, xmm5
- movdqa xmm4, xmm6
- punpckhbw xmm3, xmm0 ; high_s
- punpckhbw xmm4, xmm0 ; high_r
-
- TABULATE_SSIM
-
- movdqa xmm3, xmm5
- movdqa xmm4, xmm6
- punpcklbw xmm3, xmm0 ; low_s
- punpcklbw xmm4, xmm0 ; low_r
-
- TABULATE_SSIM
-
- add rsi, rcx ; next s row
- add rdi, rax ; next r row
-
- dec rdx ; counter
- jnz .NextRow
-
- SUM_ACROSS_W xmm15
- SUM_ACROSS_W xmm14
- SUM_ACROSS_Q xmm13
- SUM_ACROSS_Q xmm12
- SUM_ACROSS_Q xmm11
-
- mov rdi,arg(4)
- movd [rdi], xmm15;
- mov rdi,arg(5)
- movd [rdi], xmm14;
- mov rdi,arg(6)
- movd [rdi], xmm13;
- mov rdi,arg(7)
- movd [rdi], xmm12;
- mov rdi,arg(8)
- movd [rdi], xmm11;
-
- ; begin epilog
- pop rdi
- pop rsi
- RESTORE_XMM
- UNSHADOW_ARGS
- pop rbp
- ret
-
-;void ssim_parms_sse2(
+;void aom_ssim_parms_8x8_sse2(
; unsigned char *s,
; int sp,
; unsigned char *r,
diff --git a/aom_dsp/x86/variance_sse2.c b/aom_dsp/x86/variance_sse2.c
index 9d6a238..8731e95 100644
--- a/aom_dsp/x86/variance_sse2.c
+++ b/aom_dsp/x86/variance_sse2.c
@@ -20,6 +20,7 @@
#include "aom_dsp/x86/synonyms.h"
#include "aom_ports/mem.h"
+#if !CONFIG_REALTIME_ONLY
unsigned int aom_get_mb_ss_sse2(const int16_t *src) {
__m128i vsum = _mm_setzero_si128();
int i;
@@ -34,6 +35,7 @@
vsum = _mm_add_epi32(vsum, _mm_srli_si128(vsum, 4));
return (unsigned int)_mm_cvtsi128_si32(vsum);
}
+#endif // !CONFIG_REALTIME_ONLY
static inline __m128i load4x2_sse2(const uint8_t *const p, const int stride) {
const __m128i p0 = _mm_cvtsi32_si128(loadu_int32(p + 0 * stride));
diff --git a/av1/av1.cmake b/av1/av1.cmake
index cdb97af..14873da 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -232,8 +232,6 @@
"${AOM_ROOT}/av1/encoder/svc_layercontext.h"
"${AOM_ROOT}/av1/encoder/temporal_filter.c"
"${AOM_ROOT}/av1/encoder/temporal_filter.h"
- "${AOM_ROOT}/av1/encoder/thirdpass.c"
- "${AOM_ROOT}/av1/encoder/thirdpass.h"
"${AOM_ROOT}/av1/encoder/tokenize.c"
"${AOM_ROOT}/av1/encoder/tokenize.h"
"${AOM_ROOT}/av1/encoder/tpl_model.c"
@@ -440,6 +438,11 @@
list(APPEND AOM_AV1_COMMON_INTRIN_VSX "${AOM_ROOT}/av1/common/ppc/cfl_ppc.c")
+if(CONFIG_THREE_PASS)
+ list(APPEND AOM_AV1_ENCODER_SOURCES "${AOM_ROOT}/av1/encoder/thirdpass.c"
+ "${AOM_ROOT}/av1/encoder/thirdpass.h")
+endif()
+
if(CONFIG_TUNE_VMAF)
list(APPEND AOM_AV1_ENCODER_SOURCES "${AOM_ROOT}/av1/encoder/tune_vmaf.c"
"${AOM_ROOT}/av1/encoder/tune_vmaf.h")
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index a13ba51..ba13020 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -48,6 +48,7 @@
#include "common/args_helper.h"
struct av1_extracfg {
+ unsigned int usage; // Same as g_usage in aom_codec_enc_cfg_t
int cpu_used;
unsigned int enable_auto_alt_ref;
unsigned int enable_auto_bwd_ref;
@@ -213,322 +214,314 @@
int sb_qp_sweep;
};
-#if CONFIG_REALTIME_ONLY
-// Settings changed for realtime only build:
-// cpu_used: 7
-// enable_tpl_model: 0
-// enable_restoration: 0
-// enable_obmc: 0
-// deltaq_mode: NO_DELTA_Q
-// enable_global_motion usage: 0
-// enable_warped_motion at sequence level: 0
-// allow_warped_motion at frame level: 0
-// coeff_cost_upd_freq: COST_UPD_OFF
-// mode_cost_upd_freq: COST_UPD_OFF
-// mv_cost_upd_freq: COST_UPD_OFF
-// dv_cost_upd_freq: COST_UPD_OFF
-static const struct av1_extracfg default_extra_cfg = {
- 7, // cpu_used
- 1, // enable_auto_alt_ref
- 0, // enable_auto_bwd_ref
- 0, // noise_sensitivity
- 0, // sharpness
- 0, // static_thresh
- 1, // row_mt
- 0, // fp_mt
- 0, // tile_columns
- 0, // tile_rows
- 0, // auto_tiles
- 0, // enable_tpl_model
- 1, // enable_keyframe_filtering
- 7, // arnr_max_frames
- 5, // arnr_strength
- 0, // min_gf_interval; 0 -> default decision
- 0, // max_gf_interval; 0 -> default decision
- 0, // gf_min_pyr_height
- 5, // gf_max_pyr_height
- AOM_TUNE_PSNR, // tuning
- "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path
- ".", // partition info path
- 0, // enable rate guide deltaq
- "./rate_map.txt", // rate distribution input
- AOM_DIST_METRIC_PSNR, // dist_metric
- 10, // cq_level
- 0, // rc_max_intra_bitrate_pct
- 0, // rc_max_inter_bitrate_pct
- 0, // gf_cbr_boost_pct
- 0, // lossless
- 1, // enable_cdef
- 0, // enable_restoration
- 0, // force_video_mode
- 0, // enable_obmc
- 3, // disable_trellis_quant
- 0, // enable_qm
- DEFAULT_QM_Y, // qm_y
- DEFAULT_QM_U, // qm_u
- DEFAULT_QM_V, // qm_v
- DEFAULT_QM_FIRST, // qm_min
- DEFAULT_QM_LAST, // qm_max
- 1, // max number of tile groups
- 0, // mtu_size
- AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream
- 0, // frame_parallel_decoding_mode
- 1, // enable dual filter
- 0, // enable delta quant in chroma planes
- NO_AQ, // aq_mode
- NO_DELTA_Q, // deltaq_mode
- 100, // deltaq_strength
- 0, // delta lf mode
- 0, // frame_periodic_boost
- AOM_CONTENT_DEFAULT, // content
- AOM_CICP_CP_UNSPECIFIED, // CICP color primaries
- AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics
- AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients
- AOM_CSP_UNKNOWN, // chroma sample position
- 0, // color range
- 0, // render width
- 0, // render height
- AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size
- 1, // this depends on large_scale_tile.
- 0, // error_resilient_mode off by default.
- 0, // s_frame_mode off by default.
- 0, // film_grain_test_vector
- NULL, // film_grain_table_filename
- 0, // motion_vector_unit_test
-#if CONFIG_FPMT_TEST
- 0, // fpmt_unit_test
-#endif
- 1, // CDF update mode
- 1, // enable rectangular partitions
- 1, // enable ab shape partitions
- 1, // enable 1:4 and 4:1 partitions
- 4, // min_partition_size
- 128, // max_partition_size
- 1, // enable intra edge filter
- 1, // frame order hint
- 1, // enable 64-pt transform usage
- 1, // enable flip and identity transform
- 1, // enable rectangular transform usage
- 1, // dist-wtd compound
- 7, // max_reference_frames
- 0, // enable_reduced_reference_set
- 1, // enable_ref_frame_mvs sequence level
- 1, // allow ref_frame_mvs frame level
- 1, // enable masked compound at sequence level
- 1, // enable one sided compound at sequence level
- 1, // enable interintra compound at sequence level
- 1, // enable smooth interintra mode
- 1, // enable difference-weighted compound
- 1, // enable interinter wedge compound
- 1, // enable interintra wedge compound
- 0, // enable_global_motion usage
- 0, // enable_warped_motion at sequence level
- 0, // allow_warped_motion at frame level
- 1, // enable filter intra at sequence level
- 1, // enable smooth intra modes usage for sequence
- 1, // enable Paeth intra mode usage for sequence
- 1, // enable CFL uv intra mode usage for sequence
- 1, // enable directional intra mode usage for sequence
- 1, // enable D45 to D203 intra mode usage for sequence
- 1, // superres
- 1, // enable overlay
- 1, // enable palette
- 1, // enable intrabc
- 1, // enable angle delta
-#if CONFIG_DENOISE
- 0, // noise_level
- 32, // noise_block_size
- 1, // enable_dnl_denoising
-#endif
- 0, // chroma_subsampling_x
- 0, // chroma_subsampling_y
- 0, // reduced_tx_type_set
- 0, // use_intra_dct_only
- 0, // use_inter_dct_only
- 0, // use_intra_default_tx_only
- 1, // enable_tx_size_search
- 0, // quant_b_adapt
- 0, // vbr_corpus_complexity_lap
+static const struct av1_extracfg default_extra_cfg[] = {
+#if !CONFIG_REALTIME_ONLY
{
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- }, // target_seq_level_idx
- 0, // tier_mask
- 0, // min_cr
- COST_UPD_OFF, // coeff_cost_upd_freq
- COST_UPD_OFF, // mode_cost_upd_freq
- COST_UPD_OFF, // mv_cost_upd_freq
- COST_UPD_OFF, // dv_cost_upd_freq
- 0, // ext_tile_debug
- 0, // sb_multipass_unit_test
- -1, // passes
- -1, // fwd_kf_dist
- LOOPFILTER_ALL, // loopfilter_control
- 0, // skip_postproc_filtering
- NULL, // two_pass_output
- NULL, // second_pass_log
- 0, // auto_intra_tools_off
- 0, // strict_level_conformance
- -1, // kf_max_pyr_height
- 0, // sb_qp_sweep
-};
-#else
-static const struct av1_extracfg default_extra_cfg = {
- 0, // cpu_used
- 1, // enable_auto_alt_ref
- 0, // enable_auto_bwd_ref
- 0, // noise_sensitivity
- 0, // sharpness
- 0, // static_thresh
- 1, // row_mt
- 0, // fp_mt
- 0, // tile_columns
- 0, // tile_rows
- 0, // auto_tiles
- 1, // enable_tpl_model
- 1, // enable_keyframe_filtering
- 7, // arnr_max_frames
- 5, // arnr_strength
- 0, // min_gf_interval; 0 -> default decision
- 0, // max_gf_interval; 0 -> default decision
- 0, // gf_min_pyr_height
- 5, // gf_max_pyr_height
- AOM_TUNE_PSNR, // tuning
- "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path
- ".", // partition info path
- 0, // enable rate guide deltaq
- "./rate_map.txt", // rate distribution input
- AOM_DIST_METRIC_PSNR, // dist_metric
- 10, // cq_level
- 0, // rc_max_intra_bitrate_pct
- 0, // rc_max_inter_bitrate_pct
- 0, // gf_cbr_boost_pct
- 0, // lossless
- 1, // enable_cdef
- 1, // enable_restoration
- 0, // force_video_mode
- 1, // enable_obmc
- 3, // disable_trellis_quant
- 0, // enable_qm
- DEFAULT_QM_Y, // qm_y
- DEFAULT_QM_U, // qm_u
- DEFAULT_QM_V, // qm_v
- DEFAULT_QM_FIRST, // qm_min
- DEFAULT_QM_LAST, // qm_max
- 1, // max number of tile groups
- 0, // mtu_size
- AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream
- 0, // frame_parallel_decoding_mode
- 1, // enable dual filter
- 0, // enable delta quant in chroma planes
- NO_AQ, // aq_mode
- DELTA_Q_OBJECTIVE, // deltaq_mode
- 100, // deltaq_strength
- 0, // delta lf mode
- 0, // frame_periodic_boost
- AOM_CONTENT_DEFAULT, // content
- AOM_CICP_CP_UNSPECIFIED, // CICP color primaries
- AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics
- AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients
- AOM_CSP_UNKNOWN, // chroma sample position
- 0, // color range
- 0, // render width
- 0, // render height
- AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size
- 1, // this depends on large_scale_tile.
- 0, // error_resilient_mode off by default.
- 0, // s_frame_mode off by default.
- 0, // film_grain_test_vector
- NULL, // film_grain_table_filename
- 0, // motion_vector_unit_test
+ AOM_USAGE_GOOD_QUALITY, // usage
+ 0, // cpu_used
+ 1, // enable_auto_alt_ref
+ 0, // enable_auto_bwd_ref
+ 0, // noise_sensitivity
+ 0, // sharpness
+ 0, // static_thresh
+ 1, // row_mt
+ 0, // fp_mt
+ 0, // tile_columns
+ 0, // tile_rows
+ 0, // auto_tiles
+ 1, // enable_tpl_model
+ 1, // enable_keyframe_filtering
+ 7, // arnr_max_frames
+ 5, // arnr_strength
+ 0, // min_gf_interval; 0 -> default decision
+ 0, // max_gf_interval; 0 -> default decision
+ 0, // gf_min_pyr_height
+ 5, // gf_max_pyr_height
+ AOM_TUNE_PSNR, // tuning
+ "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path
+ ".", // partition info path
+ 0, // enable rate guide deltaq
+ "./rate_map.txt", // rate distribution input
+ AOM_DIST_METRIC_PSNR, // dist_metric
+ 10, // cq_level
+ 0, // rc_max_intra_bitrate_pct
+ 0, // rc_max_inter_bitrate_pct
+ 0, // gf_cbr_boost_pct
+ 0, // lossless
+ 1, // enable_cdef
+ 1, // enable_restoration
+ 0, // force_video_mode
+ 1, // enable_obmc
+ 3, // disable_trellis_quant
+ 0, // enable_qm
+ DEFAULT_QM_Y, // qm_y
+ DEFAULT_QM_U, // qm_u
+ DEFAULT_QM_V, // qm_v
+ DEFAULT_QM_FIRST, // qm_min
+ DEFAULT_QM_LAST, // qm_max
+ 1, // max number of tile groups
+ 0, // mtu_size
+ AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream
+ 0, // frame_parallel_decoding_mode
+ 1, // enable dual filter
+ 0, // enable delta quant in chroma planes
+ NO_AQ, // aq_mode
+ DELTA_Q_OBJECTIVE, // deltaq_mode
+ 100, // deltaq_strength
+ 0, // delta lf mode
+ 0, // frame_periodic_boost
+ AOM_CONTENT_DEFAULT, // content
+ AOM_CICP_CP_UNSPECIFIED, // CICP color primaries
+ AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics
+ AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients
+ AOM_CSP_UNKNOWN, // chroma sample position
+ 0, // color range
+ 0, // render width
+ 0, // render height
+ AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size
+ 1, // this depends on large_scale_tile.
+ 0, // error_resilient_mode off by default.
+ 0, // s_frame_mode off by default.
+ 0, // film_grain_test_vector
+ NULL, // film_grain_table_filename
+ 0, // motion_vector_unit_test
#if CONFIG_FPMT_TEST
- 0, // fpmt_unit_test
+ 0, // fpmt_unit_test
#endif
- 1, // CDF update mode
- 1, // enable rectangular partitions
- 1, // enable ab shape partitions
- 1, // enable 1:4 and 4:1 partitions
- 4, // min_partition_size
- 128, // max_partition_size
- 1, // enable intra edge filter
- 1, // frame order hint
- 1, // enable 64-pt transform usage
- 1, // enable flip and identity transform
- 1, // enable rectangular transform usage
- 1, // dist-wtd compound
- 7, // max_reference_frames
- 0, // enable_reduced_reference_set
- 1, // enable_ref_frame_mvs sequence level
- 1, // allow ref_frame_mvs frame level
- 1, // enable masked compound at sequence level
- 1, // enable one sided compound at sequence level
- 1, // enable interintra compound at sequence level
- 1, // enable smooth interintra mode
- 1, // enable difference-weighted compound
- 1, // enable interinter wedge compound
- 1, // enable interintra wedge compound
- 1, // enable_global_motion usage
- 1, // enable_warped_motion at sequence level
- 1, // allow_warped_motion at frame level
- 1, // enable filter intra at sequence level
- 1, // enable smooth intra modes usage for sequence
- 1, // enable Paeth intra mode usage for sequence
- 1, // enable CFL uv intra mode usage for sequence
- 1, // enable directional intra mode usage for sequence
- 1, // enable D45 to D203 intra mode usage for sequence
- 1, // superres
- 1, // enable overlay
- 1, // enable palette
- 1, // enable intrabc
- 1, // enable angle delta
+ 1, // CDF update mode
+ 1, // enable rectangular partitions
+ 1, // enable ab shape partitions
+ 1, // enable 1:4 and 4:1 partitions
+ 4, // min_partition_size
+ 128, // max_partition_size
+ 1, // enable intra edge filter
+ 1, // frame order hint
+ 1, // enable 64-pt transform usage
+ 1, // enable flip and identity transform
+ 1, // enable rectangular transform usage
+ 1, // dist-wtd compound
+ 7, // max_reference_frames
+ 0, // enable_reduced_reference_set
+ 1, // enable_ref_frame_mvs sequence level
+ 1, // allow ref_frame_mvs frame level
+ 1, // enable masked compound at sequence level
+ 1, // enable one sided compound at sequence level
+ 1, // enable interintra compound at sequence level
+ 1, // enable smooth interintra mode
+ 1, // enable difference-weighted compound
+ 1, // enable interinter wedge compound
+ 1, // enable interintra wedge compound
+ 1, // enable_global_motion usage
+ 1, // enable_warped_motion at sequence level
+ 1, // allow_warped_motion at frame level
+ 1, // enable filter intra at sequence level
+ 1, // enable smooth intra modes usage for sequence
+ 1, // enable Paeth intra mode usage for sequence
+ 1, // enable CFL uv intra mode usage for sequence
+ 1, // enable directional intra mode usage for sequence
+ 1, // enable D45 to D203 intra mode usage for sequence
+ 1, // superres
+ 1, // enable overlay
+ 1, // enable palette
+ 1, // enable intrabc
+ 1, // enable angle delta
#if CONFIG_DENOISE
- 0, // noise_level
- 32, // noise_block_size
- 1, // enable_dnl_denoising
+ 0, // noise_level
+ 32, // noise_block_size
+ 1, // enable_dnl_denoising
#endif
- 0, // chroma_subsampling_x
- 0, // chroma_subsampling_y
- 0, // reduced_tx_type_set
- 0, // use_intra_dct_only
- 0, // use_inter_dct_only
- 0, // use_intra_default_tx_only
- 1, // enable_tx_size_search
- 0, // quant_b_adapt
- 0, // vbr_corpus_complexity_lap
+ 0, // chroma_subsampling_x
+ 0, // chroma_subsampling_y
+ 0, // reduced_tx_type_set
+ 0, // use_intra_dct_only
+ 0, // use_inter_dct_only
+ 0, // use_intra_default_tx_only
+ 1, // enable_tx_size_search
+ 0, // quant_b_adapt
+ 0, // vbr_corpus_complexity_lap
+ {
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ }, // target_seq_level_idx
+ 0, // tier_mask
+ 0, // min_cr
+ COST_UPD_SB, // coeff_cost_upd_freq
+ COST_UPD_SB, // mode_cost_upd_freq
+ COST_UPD_SB, // mv_cost_upd_freq
+ COST_UPD_SB, // dv_cost_upd_freq
+ 0, // ext_tile_debug
+ 0, // sb_multipass_unit_test
+ -1, // passes
+ -1, // fwd_kf_dist
+ LOOPFILTER_ALL, // loopfilter_control
+ 0, // skip_postproc_filtering
+ NULL, // two_pass_output
+ NULL, // second_pass_log
+ 0, // auto_intra_tools_off
+ 0, // strict_level_conformance
+ -1, // kf_max_pyr_height
+ 0, // sb_qp_sweep
+ },
+#endif // !CONFIG_REALTIME_ONLY
{
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
- }, // target_seq_level_idx
- 0, // tier_mask
- 0, // min_cr
- COST_UPD_SB, // coeff_cost_upd_freq
- COST_UPD_SB, // mode_cost_upd_freq
- COST_UPD_SB, // mv_cost_upd_freq
- COST_UPD_SB, // dv_cost_upd_freq
- 0, // ext_tile_debug
- 0, // sb_multipass_unit_test
- -1, // passes
- -1, // fwd_kf_dist
- LOOPFILTER_ALL, // loopfilter_control
- 0, // skip_postproc_filtering
- NULL, // two_pass_output
- NULL, // second_pass_log
- 0, // auto_intra_tools_off
- 0, // strict_level_conformance
- -1, // kf_max_pyr_height
- 0, // sb_qp_sweep
-};
+ AOM_USAGE_REALTIME, // usage
+ 10, // cpu_used
+ 1, // enable_auto_alt_ref
+ 0, // enable_auto_bwd_ref
+ 0, // noise_sensitivity
+ 0, // sharpness
+ 0, // static_thresh
+ 1, // row_mt
+ 0, // fp_mt
+ 0, // tile_columns
+ 0, // tile_rows
+ 0, // auto_tiles
+ 0, // enable_tpl_model
+ 0, // enable_keyframe_filtering
+ 7, // arnr_max_frames
+ 5, // arnr_strength
+ 0, // min_gf_interval; 0 -> default decision
+ 0, // max_gf_interval; 0 -> default decision
+ 0, // gf_min_pyr_height
+ 5, // gf_max_pyr_height
+ AOM_TUNE_PSNR, // tuning
+ "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path
+ ".", // partition info path
+ 0, // enable rate guide deltaq
+ "./rate_map.txt", // rate distribution input
+ AOM_DIST_METRIC_PSNR, // dist_metric
+ 10, // cq_level
+ 300, // rc_max_intra_bitrate_pct
+ 0, // rc_max_inter_bitrate_pct
+ 0, // gf_cbr_boost_pct
+ 0, // lossless
+ 1, // enable_cdef
+ 0, // enable_restoration
+ 0, // force_video_mode
+ 0, // enable_obmc
+ 3, // disable_trellis_quant
+ 0, // enable_qm
+ DEFAULT_QM_Y, // qm_y
+ DEFAULT_QM_U, // qm_u
+ DEFAULT_QM_V, // qm_v
+ DEFAULT_QM_FIRST, // qm_min
+ DEFAULT_QM_LAST, // qm_max
+ 1, // max number of tile groups
+ 0, // mtu_size
+ AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream
+ 0, // frame_parallel_decoding_mode
+ 0, // enable dual filter
+ 0, // enable delta quant in chroma planes
+ CYCLIC_REFRESH_AQ, // aq_mode
+ NO_DELTA_Q, // deltaq_mode
+ 100, // deltaq_strength
+ 0, // delta lf mode
+ 0, // frame_periodic_boost
+ AOM_CONTENT_DEFAULT, // content
+ AOM_CICP_CP_UNSPECIFIED, // CICP color primaries
+ AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics
+ AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients
+ AOM_CSP_UNKNOWN, // chroma sample position
+ 0, // color range
+ 0, // render width
+ 0, // render height
+ AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size
+ 1, // this depends on large_scale_tile.
+ 0, // error_resilient_mode off by default.
+ 0, // s_frame_mode off by default.
+ 0, // film_grain_test_vector
+ NULL, // film_grain_table_filename
+ 0, // motion_vector_unit_test
+#if CONFIG_FPMT_TEST
+ 0, // fpmt_unit_test
#endif
+ 1, // CDF update mode
+ 0, // enable rectangular partitions
+ 0, // enable ab shape partitions
+ 0, // enable 1:4 and 4:1 partitions
+ 4, // min_partition_size
+ 128, // max_partition_size
+ 0, // enable intra edge filter
+ 0, // frame order hint
+ 0, // enable 64-pt transform usage
+ 1, // enable flip and identity transform
+ 1, // enable rectangular transform usage
+ 0, // dist-wtd compound
+ 3, // max_reference_frames
+ 0, // enable_reduced_reference_set
+ 0, // enable_ref_frame_mvs sequence level
+ 0, // allow ref_frame_mvs frame level
+ 0, // enable masked compound at sequence level
+ 0, // enable one sided compound at sequence level
+ 0, // enable interintra compound at sequence level
+ 0, // enable smooth interintra mode
+ 0, // enable difference-weighted compound
+ 0, // enable interinter wedge compound
+ 0, // enable interintra wedge compound
+ 0, // enable_global_motion usage
+ 0, // enable_warped_motion at sequence level
+ 0, // allow_warped_motion at frame level
+ 0, // enable filter intra at sequence level
+ 0, // enable smooth intra modes usage for sequence
+ 0, // enable Paeth intra mode usage for sequence
+ 0, // enable CFL uv intra mode usage for sequence
+ 1, // enable directional intra mode usage for sequence
+ 1, // enable D45 to D203 intra mode usage for sequence
+ 0, // superres
+ 0, // enable overlay
+ 1, // enable palette
+ 0, // enable intrabc
+ 0, // enable angle delta
+#if CONFIG_DENOISE
+ 0, // noise_level
+ 32, // noise_block_size
+ 1, // enable_dnl_denoising
+#endif
+ 0, // chroma_subsampling_x
+ 0, // chroma_subsampling_y
+ 0, // reduced_tx_type_set
+ 0, // use_intra_dct_only
+ 0, // use_inter_dct_only
+ 1, // use_intra_default_tx_only
+ 1, // enable_tx_size_search
+ 0, // quant_b_adapt
+ 0, // vbr_corpus_complexity_lap
+ {
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX,
+ }, // target_seq_level_idx
+ 0, // tier_mask
+ 0, // min_cr
+ COST_UPD_OFF, // coeff_cost_upd_freq
+ COST_UPD_OFF, // mode_cost_upd_freq
+ COST_UPD_OFF, // mv_cost_upd_freq
+ COST_UPD_OFF, // dv_cost_upd_freq
+ 0, // ext_tile_debug
+ 0, // sb_multipass_unit_test
+ -1, // passes
+ -1, // fwd_kf_dist
+ LOOPFILTER_ALL, // loopfilter_control
+ 0, // skip_postproc_filtering
+ NULL, // two_pass_output
+ NULL, // second_pass_log
+ 0, // auto_intra_tools_off
+ 0, // strict_level_conformance
+ -1, // kf_max_pyr_height
+ 0, // sb_qp_sweep
+ },
+};
struct aom_codec_alg_priv {
aom_codec_priv_t base;
@@ -1531,7 +1524,7 @@
AV1EncoderConfig av1_get_encoder_config(const aom_codec_enc_cfg_t *cfg) {
AV1EncoderConfig oxcf;
- struct av1_extracfg extra_cfg = default_extra_cfg;
+ struct av1_extracfg extra_cfg = default_extra_cfg[0];
set_encoder_config(&oxcf, cfg, &extra_cfg);
return oxcf;
}
@@ -2356,7 +2349,7 @@
struct av1_extracfg extra_cfg = ctx->extra_cfg;
const char *str = CAST(AV1E_SET_VMAF_MODEL_PATH, args);
const aom_codec_err_t ret = allocate_and_set_string(
- str, default_extra_cfg.vmaf_model_path, &extra_cfg.vmaf_model_path,
+ str, default_extra_cfg[0].vmaf_model_path, &extra_cfg.vmaf_model_path,
ctx->ppi->error.detail);
if (ret != AOM_CODEC_OK) return ret;
return update_extra_cfg(ctx, &extra_cfg);
@@ -2367,7 +2360,7 @@
struct av1_extracfg extra_cfg = ctx->extra_cfg;
const char *str = CAST(AV1E_SET_PARTITION_INFO_PATH, args);
const aom_codec_err_t ret = allocate_and_set_string(
- str, default_extra_cfg.partition_info_path,
+ str, default_extra_cfg[0].partition_info_path,
&extra_cfg.partition_info_path, ctx->ppi->error.detail);
if (ret != AOM_CODEC_OK) return ret;
return update_extra_cfg(ctx, &extra_cfg);
@@ -2386,7 +2379,7 @@
struct av1_extracfg extra_cfg = ctx->extra_cfg;
const char *str = CAST(AV1E_SET_RATE_DISTRIBUTION_INFO, args);
const aom_codec_err_t ret = allocate_and_set_string(
- str, default_extra_cfg.rate_distribution_info,
+ str, default_extra_cfg[0].rate_distribution_info,
&extra_cfg.rate_distribution_info, ctx->ppi->error.detail);
if (ret != AOM_CODEC_OK) return ret;
return update_extra_cfg(ctx, &extra_cfg);
@@ -2409,7 +2402,7 @@
extra_cfg.film_grain_table_filename = str;
} else {
const aom_codec_err_t ret = allocate_and_set_string(
- str, default_extra_cfg.film_grain_table_filename,
+ str, default_extra_cfg[0].film_grain_table_filename,
&extra_cfg.film_grain_table_filename, ctx->ppi->error.detail);
if (ret != AOM_CODEC_OK) return ret;
}
@@ -2838,7 +2831,7 @@
priv->cfg = *ctx->config.enc;
ctx->config.enc = &priv->cfg;
- priv->extra_cfg = default_extra_cfg;
+ priv->extra_cfg = default_extra_cfg[0];
// Special handling:
// By default, if omitted, --enable-cdef = 1.
// Here we set its default value to 0 when --allintra is turned on.
@@ -2952,18 +2945,18 @@
static void destroy_extra_config(struct av1_extracfg *extra_cfg) {
#if CONFIG_TUNE_VMAF
- check_and_free_string(default_extra_cfg.vmaf_model_path,
+ check_and_free_string(default_extra_cfg[0].vmaf_model_path,
&extra_cfg->vmaf_model_path);
#endif
- check_and_free_string(default_extra_cfg.two_pass_output,
+ check_and_free_string(default_extra_cfg[0].two_pass_output,
&extra_cfg->two_pass_output);
- check_and_free_string(default_extra_cfg.two_pass_output,
+ check_and_free_string(default_extra_cfg[0].two_pass_output,
&extra_cfg->second_pass_log);
- check_and_free_string(default_extra_cfg.partition_info_path,
+ check_and_free_string(default_extra_cfg[0].partition_info_path,
&extra_cfg->partition_info_path);
- check_and_free_string(default_extra_cfg.rate_distribution_info,
+ check_and_free_string(default_extra_cfg[0].rate_distribution_info,
&extra_cfg->rate_distribution_info);
- check_and_free_string(default_extra_cfg.film_grain_table_filename,
+ check_and_free_string(default_extra_cfg[0].film_grain_table_filename,
&extra_cfg->film_grain_table_filename);
}
@@ -3453,7 +3446,8 @@
// OBUs are preceded/succeeded by an unsigned leb128 coded integer.
if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
- ctx->cx_data) != AOM_CODEC_OK) {
+ ctx->cx_data,
+ ctx->cx_data_sz) != AOM_CODEC_OK) {
aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL);
}
@@ -3475,7 +3469,8 @@
memmove(cpi_data.cx_data + length_field_size, cpi_data.cx_data,
cpi_data.frame_size);
if (av1_write_uleb_obu_size(0, (uint32_t)cpi_data.frame_size,
- cpi_data.cx_data) != AOM_CODEC_OK) {
+ cpi_data.cx_data,
+ cpi_data.cx_data_sz) != AOM_CODEC_OK) {
aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL);
}
cpi_data.frame_size += length_field_size;
@@ -3503,8 +3498,8 @@
size_t tu_size = ctx->pending_cx_data_sz;
const size_t length_field_size = aom_uleb_size_in_bytes(tu_size);
memmove(ctx->cx_data + length_field_size, ctx->cx_data, tu_size);
- if (av1_write_uleb_obu_size(0, (uint32_t)tu_size, ctx->cx_data) !=
- AOM_CODEC_OK) {
+ if (av1_write_uleb_obu_size(0, (uint32_t)tu_size, ctx->cx_data,
+ ctx->cx_data_sz) != AOM_CODEC_OK) {
aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL);
}
ctx->pending_cx_data_sz += length_field_size;
@@ -4041,14 +4036,15 @@
#if CONFIG_TUNE_VMAF
else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.vmaf_model_path, argv,
err_string)) {
- err = allocate_and_set_string(value, default_extra_cfg.vmaf_model_path,
+ err = allocate_and_set_string(value, default_extra_cfg[0].vmaf_model_path,
&extra_cfg.vmaf_model_path, err_string);
}
#endif
else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.partition_info_path,
argv, err_string)) {
- err = allocate_and_set_string(value, default_extra_cfg.partition_info_path,
- &extra_cfg.partition_info_path, err_string);
+ err =
+ allocate_and_set_string(value, default_extra_cfg[0].partition_info_path,
+ &extra_cfg.partition_info_path, err_string);
} else if (arg_match_helper(&arg,
&g_av1_codec_arg_defs.enable_rate_guide_deltaq,
argv, err_string)) {
@@ -4057,9 +4053,9 @@
} else if (arg_match_helper(&arg,
&g_av1_codec_arg_defs.rate_distribution_info,
argv, err_string)) {
- err =
- allocate_and_set_string(value, default_extra_cfg.rate_distribution_info,
- &extra_cfg.rate_distribution_info, err_string);
+ err = allocate_and_set_string(
+ value, default_extra_cfg[0].rate_distribution_info,
+ &extra_cfg.rate_distribution_info, err_string);
} else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.dist_metric, argv,
err_string)) {
extra_cfg.dist_metric = arg_parse_enum_helper(&arg, err_string);
@@ -4177,7 +4173,7 @@
extra_cfg.film_grain_table_filename = value;
} else {
err = allocate_and_set_string(
- value, default_extra_cfg.film_grain_table_filename,
+ value, default_extra_cfg[0].film_grain_table_filename,
&extra_cfg.film_grain_table_filename, err_string);
}
} else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cdf_update_mode, argv,
@@ -4375,11 +4371,11 @@
extra_cfg.fwd_kf_dist = arg_parse_int_helper(&arg, err_string);
} else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.two_pass_output, argv,
err_string)) {
- err = allocate_and_set_string(value, default_extra_cfg.two_pass_output,
+ err = allocate_and_set_string(value, default_extra_cfg[0].two_pass_output,
&extra_cfg.two_pass_output, err_string);
} else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.second_pass_log, argv,
err_string)) {
- err = allocate_and_set_string(value, default_extra_cfg.second_pass_log,
+ err = allocate_and_set_string(value, default_extra_cfg[0].second_pass_log,
&extra_cfg.second_pass_log, err_string);
} else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.loopfilter_control,
argv, err_string)) {
@@ -4757,12 +4753,12 @@
256, // rc_target_bitrate
0, // rc_min_quantizer
63, // rc_max_quantizer
- 25, // rc_undershoot_pct
- 25, // rc_overshoot_pct
+ 50, // rc_undershoot_pct
+ 50, // rc_overshoot_pct
- 6000, // rc_buf_sz
- 4000, // rc_buf_initial_sz
- 5000, // rc_buf_optimal_sz
+ 1000, // rc_buf_sz
+ 600, // rc_buf_initial_sz
+ 600, // rc_buf_optimal_sz
50, // rc_2pass_vbr_bias_pct
0, // rc_2pass_vbr_minsection_pct
diff --git a/av1/common/arm/cdef_block_neon.c b/av1/common/arm/cdef_block_neon.c
index be6df92..4183144 100644
--- a/av1/common/arm/cdef_block_neon.c
+++ b/av1/common/arm/cdef_block_neon.c
@@ -50,6 +50,7 @@
} while (--height != 0);
}
+#if CONFIG_AV1_HIGHBITDEPTH
void cdef_copy_rect8_16bit_to_16bit_neon(uint16_t *dst, int dstride,
const uint16_t *src, int sstride,
int width, int height) {
@@ -73,6 +74,7 @@
dst += dstride;
} while (--height != 0);
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
// partial A is a 16-bit vector of the form:
// [x8 x7 x6 x5 x4 x3 x2 x1] and partial B has the form:
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 1254715..a8a01f1 100644
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -488,7 +488,9 @@
add_proto qw/void cdef_filter_16_3/, "void *dst16, int dstride, const uint16_t *in, int pri_strength, int sec_strength, int dir, int pri_damping, int sec_damping, int coeff_shift, int block_width, int block_height";
add_proto qw/void cdef_copy_rect8_8bit_to_16bit/, "uint16_t *dst, int dstride, const uint8_t *src, int sstride, int width, int height";
-add_proto qw/void cdef_copy_rect8_16bit_to_16bit/, "uint16_t *dst, int dstride, const uint16_t *src, int sstride, int width, int height";
+if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+ add_proto qw/void cdef_copy_rect8_16bit_to_16bit/, "uint16_t *dst, int dstride, const uint16_t *src, int sstride, int width, int height";
+}
# VS compiling for 32 bit targets does not support vector types in
# structs as arguments, which makes the v256 type of the intrinsics
@@ -508,7 +510,9 @@
specialize qw/cdef_filter_16_3 sse4_1 avx2 neon/, "$ssse3_x86";
specialize qw/cdef_copy_rect8_8bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
- specialize qw/cdef_copy_rect8_16bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
+ if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+ specialize qw/cdef_copy_rect8_16bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
+ }
}
# WARPED_MOTION / GLOBAL_MOTION functions
diff --git a/av1/common/cdef.c b/av1/common/cdef.c
index 02de17a..c39fca3 100644
--- a/av1/common/cdef.c
+++ b/av1/common/cdef.c
@@ -82,6 +82,7 @@
}
}
+#if CONFIG_AV1_HIGHBITDEPTH
void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride,
const uint16_t *src, int sstride,
int width, int height) {
@@ -91,6 +92,7 @@
}
}
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
void av1_cdef_copy_sb8_16_lowbd(uint16_t *const dst, int dstride,
const uint8_t *src, int src_voffset,
@@ -100,6 +102,7 @@
cdef_copy_rect8_8bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
}
+#if CONFIG_AV1_HIGHBITDEPTH
void av1_cdef_copy_sb8_16_highbd(uint16_t *const dst, int dstride,
const uint8_t *src, int src_voffset,
int src_hoffset, int sstride, int vsize,
@@ -108,17 +111,22 @@
&CONVERT_TO_SHORTPTR(src)[src_voffset * (ptrdiff_t)sstride + src_hoffset];
cdef_copy_rect8_16bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
void av1_cdef_copy_sb8_16(const AV1_COMMON *const cm, uint16_t *const dst,
int dstride, const uint8_t *src, int src_voffset,
int src_hoffset, int sstride, int vsize, int hsize) {
+#if CONFIG_AV1_HIGHBITDEPTH
if (cm->seq_params->use_highbitdepth) {
av1_cdef_copy_sb8_16_highbd(dst, dstride, src, src_voffset, src_hoffset,
sstride, vsize, hsize);
- } else {
- av1_cdef_copy_sb8_16_lowbd(dst, dstride, src, src_voffset, src_hoffset,
- sstride, vsize, hsize);
+ return;
}
+#else
+ (void)cm;
+#endif // CONFIG_AV1_HIGHBITDEPTH
+ av1_cdef_copy_sb8_16_lowbd(dst, dstride, src, src_voffset, src_hoffset,
+ sstride, vsize, hsize);
}
static inline void copy_rect(uint16_t *dst, int dstride, const uint16_t *src,
diff --git a/av1/common/cdef_block.c b/av1/common/cdef_block.c
index 318779b..3822ba1 100644
--- a/av1/common/cdef_block.c
+++ b/av1/common/cdef_block.c
@@ -22,7 +22,7 @@
first index is offset +/-2. This removes the need to constrain the first
index to the same range using e.g., & 7.
*/
-DECLARE_ALIGNED(16, const int, cdef_directions_padded[12][2]) = {
+DECLARE_ALIGNED(16, static const int, cdef_directions_padded[12][2]) = {
/* Padding: cdef_directions[6] */
{ 1 * CDEF_BSTRIDE + 0, 2 * CDEF_BSTRIDE + 0 },
/* Padding: cdef_directions[7] */
diff --git a/av1/common/cdef_block_simd.h b/av1/common/cdef_block_simd.h
index 56c5baa..35a729d 100644
--- a/av1/common/cdef_block_simd.h
+++ b/av1/common/cdef_block_simd.h
@@ -12,6 +12,7 @@
#ifndef AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
#define AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
+#include "config/aom_config.h"
#include "config/av1_rtcd.h"
#include "av1/common/cdef_block.h"
@@ -824,6 +825,7 @@
}
}
+#if CONFIG_AV1_HIGHBITDEPTH
void SIMD_FUNC(cdef_copy_rect8_16bit_to_16bit)(uint16_t *dst, int dstride,
const uint16_t *src, int sstride,
int width, int height) {
@@ -838,6 +840,7 @@
}
}
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
#undef CDEF_INLINE
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index ec43bec..eec2343 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -832,7 +832,7 @@
}
}
-void av1_modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi) {
+static void modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi) {
mbmi->ref_frame[1] = NONE_FRAME;
mbmi->interinter_comp.type = COMPOUND_AVERAGE;
}
@@ -976,7 +976,7 @@
const BLOCK_SIZE a_bsize = AOMMAX(BLOCK_8X8, above_mbmi->bsize);
const int above_mi_col = xd->mi_col + rel_mi_col;
- av1_modify_neighbor_predictor_for_obmc(above_mbmi);
+ modify_neighbor_predictor_for_obmc(above_mbmi);
for (int j = 0; j < num_planes; ++j) {
struct macroblockd_plane *const pd = &xd->plane[j];
@@ -1015,7 +1015,7 @@
const BLOCK_SIZE l_bsize = AOMMAX(BLOCK_8X8, left_mbmi->bsize);
const int left_mi_row = xd->mi_row + rel_mi_row;
- av1_modify_neighbor_predictor_for_obmc(left_mbmi);
+ modify_neighbor_predictor_for_obmc(left_mbmi);
for (int j = 0; j < num_planes; ++j) {
struct macroblockd_plane *const pd = &xd->plane[j];
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index ed06ee0..0a33c93 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -293,7 +293,6 @@
}
}
-void av1_modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi);
int av1_skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize,
const struct macroblockd_plane *pd, int dir);
diff --git a/av1/common/resize.c b/av1/common/resize.c
index 839a7e3..c74136b 100644
--- a/av1/common/resize.c
+++ b/av1/common/resize.c
@@ -1046,82 +1046,6 @@
abort();
}
-bool av1_resize_frame422(const uint8_t *y, int y_stride, const uint8_t *u,
- const uint8_t *v, int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou, uint8_t *ov,
- int ouv_stride, int oheight, int owidth) {
- if (!av1_resize_plane(y, height, width, y_stride, oy, oheight, owidth,
- oy_stride))
- return false;
- if (!av1_resize_plane(u, height, width / 2, uv_stride, ou, oheight,
- owidth / 2, ouv_stride))
- return false;
- if (!av1_resize_plane(v, height, width / 2, uv_stride, ov, oheight,
- owidth / 2, ouv_stride))
- return false;
- return true;
-}
-
-bool av1_resize_frame444(const uint8_t *y, int y_stride, const uint8_t *u,
- const uint8_t *v, int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou, uint8_t *ov,
- int ouv_stride, int oheight, int owidth) {
- if (!av1_resize_plane(y, height, width, y_stride, oy, oheight, owidth,
- oy_stride))
- return false;
- if (!av1_resize_plane(u, height, width, uv_stride, ou, oheight, owidth,
- ouv_stride))
- return false;
- if (!av1_resize_plane(v, height, width, uv_stride, ov, oheight, owidth,
- ouv_stride))
- return false;
- return true;
-}
-
-#if CONFIG_AV1_HIGHBITDEPTH
-void av1_highbd_resize_frame420(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd) {
- av1_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth,
- oy_stride, bd);
- av1_highbd_resize_plane(u, height / 2, width / 2, uv_stride, ou, oheight / 2,
- owidth / 2, ouv_stride, bd);
- av1_highbd_resize_plane(v, height / 2, width / 2, uv_stride, ov, oheight / 2,
- owidth / 2, ouv_stride, bd);
-}
-
-void av1_highbd_resize_frame422(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd) {
- av1_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth,
- oy_stride, bd);
- av1_highbd_resize_plane(u, height, width / 2, uv_stride, ou, oheight,
- owidth / 2, ouv_stride, bd);
- av1_highbd_resize_plane(v, height, width / 2, uv_stride, ov, oheight,
- owidth / 2, ouv_stride, bd);
-}
-
-void av1_highbd_resize_frame444(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd) {
- av1_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth,
- oy_stride, bd);
- av1_highbd_resize_plane(u, height, width, uv_stride, ou, oheight, owidth,
- ouv_stride, bd);
- av1_highbd_resize_plane(v, height, width, uv_stride, ov, oheight, owidth,
- ouv_stride, bd);
-}
-#endif // CONFIG_AV1_HIGHBITDEPTH
-
void av1_resize_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
const InterpFilter filter,
diff --git a/av1/common/resize.h b/av1/common/resize.h
index 489ad81..c68e4ac2 100644
--- a/av1/common/resize.h
+++ b/av1/common/resize.h
@@ -33,36 +33,10 @@
const uint8_t *v, int uv_stride, int height, int width,
uint8_t *oy, int oy_stride, uint8_t *ou, uint8_t *ov,
int ouv_stride, int oheight, int owidth);
-bool av1_resize_frame422(const uint8_t *y, int y_stride, const uint8_t *u,
- const uint8_t *v, int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou, uint8_t *ov,
- int ouv_stride, int oheight, int owidth);
-bool av1_resize_frame444(const uint8_t *y, int y_stride, const uint8_t *u,
- const uint8_t *v, int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou, uint8_t *ov,
- int ouv_stride, int oheight, int owidth);
void av1_highbd_resize_plane(const uint8_t *input, int height, int width,
int in_stride, uint8_t *output, int height2,
int width2, int out_stride, int bd);
-void av1_highbd_resize_frame420(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd);
-void av1_highbd_resize_frame422(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd);
-void av1_highbd_resize_frame444(const uint8_t *y, int y_stride,
- const uint8_t *u, const uint8_t *v,
- int uv_stride, int height, int width,
- uint8_t *oy, int oy_stride, uint8_t *ou,
- uint8_t *ov, int ouv_stride, int oheight,
- int owidth, int bd);
void av1_upscale_normative_rows(const AV1_COMMON *cm, const uint8_t *src,
int src_stride, uint8_t *dst, int dst_stride,
diff --git a/av1/common/thread_common.h b/av1/common/thread_common.h
index 0c27e12..90b869b 100644
--- a/av1/common/thread_common.h
+++ b/av1/common/thread_common.h
@@ -164,10 +164,12 @@
const uint8_t *src, int src_voffset,
int src_hoffset, int sstride, int vsize,
int hsize);
+#if CONFIG_AV1_HIGHBITDEPTH
void av1_cdef_copy_sb8_16_highbd(uint16_t *const dst, int dstride,
const uint8_t *src, int src_voffset,
int src_hoffset, int sstride, int vsize,
int hsize);
+#endif // CONFIG_AV1_HIGHBITDEPTH
void av1_alloc_cdef_sync(AV1_COMMON *const cm, AV1CdefSync *cdef_sync,
int num_workers);
void av1_free_cdef_sync(AV1CdefSync *cdef_sync);
diff --git a/av1/common/txb_common.c b/av1/common/txb_common.c
index a6c2c33..ed35726 100644
--- a/av1/common/txb_common.c
+++ b/av1/common/txb_common.c
@@ -15,18 +15,18 @@
// The ctx offset table when TX is TX_CLASS_2D.
// TX col and row indices are clamped to 4
-const int8_t av1_nz_map_ctx_offset_4x4[16] = {
+static const int8_t av1_nz_map_ctx_offset_4x4[16] = {
0, 1, 6, 6, 1, 6, 6, 21, 6, 6, 21, 21, 6, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_8x8[64] = {
+static const int8_t av1_nz_map_ctx_offset_8x8[64] = {
0, 1, 6, 6, 21, 21, 21, 21, 1, 6, 6, 21, 21, 21, 21, 21,
6, 6, 21, 21, 21, 21, 21, 21, 6, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_16x16[256] = {
+static const int8_t av1_nz_map_ctx_offset_16x16[256] = {
0, 1, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 6, 6,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 6, 6, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 6, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -43,7 +43,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_32x32[1024] = {
+static const int8_t av1_nz_map_ctx_offset_32x32[1024] = {
0, 1, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 6, 6, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -100,12 +100,12 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_4x8[32] = {
+static const int8_t av1_nz_map_ctx_offset_4x8[32] = {
0, 11, 6, 6, 21, 21, 21, 21, 11, 11, 6, 21, 21, 21, 21, 21,
11, 11, 21, 21, 21, 21, 21, 21, 11, 11, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_8x16[128] = {
+static const int8_t av1_nz_map_ctx_offset_8x16[128] = {
0, 11, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 6,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 21, 21, 21, 21, 21, 21, 21,
@@ -115,7 +115,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_16x32[512] = {
+static const int8_t av1_nz_map_ctx_offset_16x32[512] = {
0, 11, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 6, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -145,7 +145,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_32x16[512] = {
+static const int8_t av1_nz_map_ctx_offset_32x16[512] = {
0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 6, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 6, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -175,7 +175,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_32x64[1024] = {
+static const int8_t av1_nz_map_ctx_offset_32x64[1024] = {
0, 11, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 6, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -232,7 +232,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_64x32[1024] = {
+static const int8_t av1_nz_map_ctx_offset_64x32[1024] = {
0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
@@ -289,21 +289,21 @@
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_4x16[64] = {
+static const int8_t av1_nz_map_ctx_offset_4x16[64] = {
0, 11, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
11, 11, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
11, 11, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
11, 11, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_16x4[64] = {
+static const int8_t av1_nz_map_ctx_offset_16x4[64] = {
0, 16, 16, 16, 16, 16, 16, 16, 6, 6, 21, 21, 6, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_8x32[256] = {
+static const int8_t av1_nz_map_ctx_offset_8x32[256] = {
0, 11, 6, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 6, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -320,7 +320,7 @@
21, 21, 21, 21, 21, 21, 21, 21, 21,
};
-const int8_t av1_nz_map_ctx_offset_32x8[256] = {
+static const int8_t av1_nz_map_ctx_offset_32x8[256] = {
0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 6, 21,
21, 21, 21, 21, 21, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
diff --git a/av1/encoder/aq_variance.c b/av1/encoder/aq_variance.c
index 66e02c0..2dc2cd0 100644
--- a/av1/encoder/aq_variance.c
+++ b/av1/encoder/aq_variance.c
@@ -20,7 +20,9 @@
#include "av1/encoder/rd.h"
#include "av1/encoder/segmentation.h"
#include "av1/encoder/dwt.h"
+#include "config/aom_config.h"
+#if !CONFIG_REALTIME_ONLY
static const double rate_ratio[MAX_SEGMENTS] = { 2.2, 1.7, 1.3, 1.0,
0.9, .8, .7, .6 };
@@ -32,11 +34,6 @@
#define ENERGY_IN_BOUNDS(energy) \
assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX)
-DECLARE_ALIGNED(16, static const uint8_t, av1_all_zeros[MAX_SB_SIZE]) = { 0 };
-
-DECLARE_ALIGNED(16, static const uint16_t,
- av1_highbd_all_zeros[MAX_SB_SIZE]) = { 0 };
-
static const int segment_id[ENERGY_SPAN] = { 0, 1, 1, 2, 3, 4 };
#define SEGMENT_ID(i) segment_id[(i)-ENERGY_MIN]
@@ -92,52 +89,6 @@
}
}
-int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
- // This functions returns a score for the blocks local variance as calculated
- // by: sum of the log of the (4x4 variances) of each subblock to the current
- // block (x,bs)
- // * 32 / number of pixels in the block_size.
- // This is used for segmentation because to avoid situations in which a large
- // block with a gentle gradient gets marked high variance even though each
- // subblock has a low variance. This allows us to assign the same segment
- // number for the same sorts of area regardless of how the partitioning goes.
-
- MACROBLOCKD *xd = &x->e_mbd;
- double var = 0;
- unsigned int sse;
- int i, j;
-
- int right_overflow =
- (xd->mb_to_right_edge < 0) ? ((-xd->mb_to_right_edge) >> 3) : 0;
- int bottom_overflow =
- (xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
-
- const int bw = MI_SIZE * mi_size_wide[bs] - right_overflow;
- const int bh = MI_SIZE * mi_size_high[bs] - bottom_overflow;
-
- for (i = 0; i < bh; i += 4) {
- for (j = 0; j < bw; j += 4) {
- if (is_cur_buf_hbd(xd)) {
- var += log1p(cpi->ppi->fn_ptr[BLOCK_4X4].vf(
- x->plane[0].src.buf + i * x->plane[0].src.stride + j,
- x->plane[0].src.stride,
- CONVERT_TO_BYTEPTR(av1_highbd_all_zeros), 0, &sse) /
- 16.0);
- } else {
- var += log1p(cpi->ppi->fn_ptr[BLOCK_4X4].vf(
- x->plane[0].src.buf + i * x->plane[0].src.stride + j,
- x->plane[0].src.stride, av1_all_zeros, 0, &sse) /
- 16.0);
- }
- }
- }
- // Use average of 4x4 log variance. The range for 8 bit 0 - 9.704121561.
- var /= (bw / 4 * bh / 4);
- if (var > 7) var = 7;
-
- return (int)(var);
-}
-
int av1_log_block_avg(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs,
int mi_row, int mi_col) {
// This functions returns the block average of luma block
@@ -218,3 +169,54 @@
}
return base_qindex + qindex_delta;
}
+#endif // !CONFIG_REALTIME_ONLY
+
+int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
+ DECLARE_ALIGNED(16, static const uint16_t,
+ av1_highbd_all_zeros[MAX_SB_SIZE]) = { 0 };
+ DECLARE_ALIGNED(16, static const uint8_t, av1_all_zeros[MAX_SB_SIZE]) = { 0 };
+
+ // This function returns a score for the blocks local variance as calculated
+ // by: sum of the log of the (4x4 variances) of each subblock to the current
+ // block (x,bs)
+ // * 32 / number of pixels in the block_size.
+ // This is used for segmentation because to avoid situations in which a large
+ // block with a gentle gradient gets marked high variance even though each
+ // subblock has a low variance. This allows us to assign the same segment
+ // number for the same sorts of area regardless of how the partitioning goes.
+
+ MACROBLOCKD *xd = &x->e_mbd;
+ double var = 0;
+ unsigned int sse;
+ int i, j;
+
+ int right_overflow =
+ (xd->mb_to_right_edge < 0) ? ((-xd->mb_to_right_edge) >> 3) : 0;
+ int bottom_overflow =
+ (xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
+
+ const int bw = MI_SIZE * mi_size_wide[bs] - right_overflow;
+ const int bh = MI_SIZE * mi_size_high[bs] - bottom_overflow;
+
+ for (i = 0; i < bh; i += 4) {
+ for (j = 0; j < bw; j += 4) {
+ if (is_cur_buf_hbd(xd)) {
+ var += log1p(cpi->ppi->fn_ptr[BLOCK_4X4].vf(
+ x->plane[0].src.buf + i * x->plane[0].src.stride + j,
+ x->plane[0].src.stride,
+ CONVERT_TO_BYTEPTR(av1_highbd_all_zeros), 0, &sse) /
+ 16.0);
+ } else {
+ var += log1p(cpi->ppi->fn_ptr[BLOCK_4X4].vf(
+ x->plane[0].src.buf + i * x->plane[0].src.stride + j,
+ x->plane[0].src.stride, av1_all_zeros, 0, &sse) /
+ 16.0);
+ }
+ }
+ }
+ // Use average of 4x4 log variance. The range for 8 bit 0 - 9.704121561.
+ var /= (bw / 4 * bh / 4);
+ if (var > 7) var = 7;
+
+ return (int)(var);
+}
diff --git a/av1/encoder/aq_variance.h b/av1/encoder/aq_variance.h
index 8d07cd9..2e9a73a 100644
--- a/av1/encoder/aq_variance.h
+++ b/av1/encoder/aq_variance.h
@@ -13,20 +13,24 @@
#define AOM_AV1_ENCODER_AQ_VARIANCE_H_
#include "av1/encoder/encoder.h"
+#include "config/aom_config.h"
#ifdef __cplusplus
extern "C" {
#endif
+#if !CONFIG_REALTIME_ONLY
void av1_vaq_frame_setup(AV1_COMP *cpi);
-int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
int av1_log_block_avg(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs,
int mi_row, int mi_col);
int av1_compute_q_from_energy_level_deltaq_mode(const AV1_COMP *const cpi,
int block_var_level);
int av1_block_wavelet_energy_level(const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bs);
+#endif // !CONFIG_REALTIME_ONLY
+
+int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
#ifdef __cplusplus
} // extern "C"
diff --git a/av1/encoder/av1_quantize.c b/av1/encoder/av1_quantize.c
index b39be5b..d44795d 100644
--- a/av1/encoder/av1_quantize.c
+++ b/av1/encoder/av1_quantize.c
@@ -708,8 +708,18 @@
prev_deltaq_params->v_ac_delta_q = quant_params->v_ac_delta_q;
}
-void av1_set_q_index(const EncQuantDequantParams *enc_quant_dequant_params,
- int qindex, MACROBLOCK *x) {
+/*!\brief Update quantize parameters in MACROBLOCK
+ *
+ * \param[in] enc_quant_dequant_params This parameter cached the quantize and
+ * dequantize parameters for all q
+ * indices.
+ * \param[in] qindex Quantize index used for the current
+ * superblock.
+ * \param[out] x A superblock data structure for
+ * encoder.
+ */
+static void set_q_index(const EncQuantDequantParams *enc_quant_dequant_params,
+ int qindex, MACROBLOCK *x) {
const QUANTS *const quants = &enc_quant_dequant_params->quants;
const Dequants *const dequants = &enc_quant_dequant_params->dequants;
x->qindex = qindex;
@@ -744,8 +754,15 @@
x->plane[2].dequant_QTX = dequants->v_dequant_QTX[qindex];
}
-void av1_set_qmatrix(const CommonQuantParams *quant_params, int segment_id,
- MACROBLOCKD *xd) {
+/*!\brief Update quantize matrix in MACROBLOCKD based on segment id
+ *
+ * \param[in] quant_params Quantize parameters used by encoder and decoder
+ * \param[in] segment_id Segment id.
+ * \param[out] xd A superblock data structure used by encoder and
+ * decoder.
+ */
+static void set_qmatrix(const CommonQuantParams *quant_params, int segment_id,
+ MACROBLOCKD *xd) {
const int use_qmatrix = av1_use_qmatrix(quant_params, xd, segment_id);
const int qmlevel_y =
use_qmatrix ? quant_params->qmatrix_level_y : NUM_QM_LEVELS - 1;
@@ -802,13 +819,13 @@
const int qindex_change = x->qindex != qindex;
if (qindex_change || do_update) {
- av1_set_q_index(&cpi->enc_quant_dequant_params, qindex, x);
+ set_q_index(&cpi->enc_quant_dequant_params, qindex, x);
}
MACROBLOCKD *const xd = &x->e_mbd;
if ((segment_id != x->prev_segment_id) ||
av1_use_qmatrix(quant_params, xd, segment_id)) {
- av1_set_qmatrix(quant_params, segment_id, xd);
+ set_qmatrix(quant_params, segment_id, xd);
}
x->seg_skip_block = segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP);
diff --git a/av1/encoder/av1_quantize.h b/av1/encoder/av1_quantize.h
index 3dea441..35b0fa8 100644
--- a/av1/encoder/av1_quantize.h
+++ b/av1/encoder/av1_quantize.h
@@ -170,29 +170,6 @@
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
-/*!\brief Update quantize parameters in MACROBLOCK
- *
- * \param[in] enc_quant_dequant_params This parameter cached the quantize and
- * dequantize parameters for all q
- * indices.
- * \param[in] qindex Quantize index used for the current
- * superblock.
- * \param[out] x A superblock data structure for
- * encoder.
- */
-void av1_set_q_index(const EncQuantDequantParams *enc_quant_dequant_params,
- int qindex, MACROBLOCK *x);
-
-/*!\brief Update quantize matrix in MACROBLOCKD based on segment id
- *
- * \param[in] quant_params Quantize parameters used by encoder and decoder
- * \param[in] segment_id Segment id.
- * \param[out] xd A superblock data structure used by encoder and
- * decoder.
- */
-void av1_set_qmatrix(const CommonQuantParams *quant_params, int segment_id,
- MACROBLOCKD *xd);
-
#if CONFIG_AV1_HIGHBITDEPTH
void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 4b9f3f7..a6e213b 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -12,7 +12,9 @@
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "aom/aom_encoder.h"
#include "aom_dsp/aom_dsp_common.h"
@@ -3362,7 +3364,6 @@
(obu_type == OBU_FRAME || obu_type == OBU_FRAME_HEADER))
++(*frame_header_count);
- struct aom_write_bit_buffer wb = { dst, 0 };
uint32_t size = 0;
// The AV1 spec Version 1.0.0 with Errata 1 has the following requirements on
@@ -3388,29 +3389,29 @@
(obu_type == OBU_FRAME_HEADER || obu_type == OBU_TILE_GROUP ||
obu_type == OBU_FRAME || obu_type == OBU_REDUNDANT_FRAME_HEADER);
}
+ const int obu_has_size_field = 1;
- aom_wb_write_literal(&wb, 0, 1); // forbidden bit.
- aom_wb_write_literal(&wb, (int)obu_type, 4);
- aom_wb_write_literal(&wb, obu_extension_flag, 1);
- aom_wb_write_literal(&wb, 1, 1); // obu_has_size_field
- aom_wb_write_literal(&wb, 0, 1); // reserved
+ dst[0] = ((int)obu_type << 3) | (obu_extension_flag << 2) |
+ (obu_has_size_field << 1);
+ size++;
if (obu_extension_flag) {
- aom_wb_write_literal(&wb, obu_extension & 0xFF, 8);
+ dst[1] = obu_extension & 0xFF;
+ size++;
}
- size = aom_wb_bytes_written(&wb);
return size;
}
int av1_write_uleb_obu_size(size_t obu_header_size, size_t obu_payload_size,
- uint8_t *dest) {
+ uint8_t *dest, size_t dest_size) {
const size_t offset = obu_header_size;
size_t coded_obu_size = 0;
- const uint32_t obu_size = (uint32_t)obu_payload_size;
- assert(obu_size == obu_payload_size);
- if (aom_uleb_encode(obu_size, sizeof(obu_size), dest + offset,
+ if (offset > dest_size) {
+ return AOM_CODEC_ERROR;
+ }
+ if (aom_uleb_encode(obu_payload_size, dest_size - offset, dest + offset,
&coded_obu_size) != 0) {
return AOM_CODEC_ERROR;
}
@@ -3418,8 +3419,36 @@
return AOM_CODEC_OK;
}
+int av1_write_uleb_obu_size_unsafe(size_t obu_header_size,
+ size_t obu_payload_size, uint8_t *dest) {
+ const size_t offset = obu_header_size;
+ size_t coded_obu_size = 0;
+
+ if (aom_uleb_encode(obu_payload_size, sizeof(uint32_t), dest + offset,
+ &coded_obu_size) != 0) {
+ return AOM_CODEC_ERROR;
+ }
+
+ return AOM_CODEC_OK;
+}
+
+// Returns 0 on failure.
static size_t obu_memmove(size_t obu_header_size, size_t obu_payload_size,
- uint8_t *data) {
+ uint8_t *data, size_t data_size) {
+ const size_t length_field_size = aom_uleb_size_in_bytes(obu_payload_size);
+ const size_t move_dst_offset = length_field_size + obu_header_size;
+ const size_t move_src_offset = obu_header_size;
+ const size_t move_size = obu_payload_size;
+ if (move_dst_offset + move_size > data_size) {
+ return 0;
+ }
+ memmove(data + move_dst_offset, data + move_src_offset, move_size);
+ return length_field_size;
+}
+
+// Deprecated. Use obu_memmove() instead.
+static size_t obu_memmove_unsafe(size_t obu_header_size,
+ size_t obu_payload_size, uint8_t *data) {
const size_t length_field_size = aom_uleb_size_in_bytes(obu_payload_size);
const size_t move_dst_offset = length_field_size + obu_header_size;
const size_t move_src_offset = obu_header_size;
@@ -3444,7 +3473,9 @@
}
uint32_t av1_write_sequence_header_obu(const SequenceHeader *seq_params,
- uint8_t *const dst) {
+ uint8_t *const dst, size_t dst_size) {
+ // TODO: bug 42302568 - Use dst_size.
+ (void)dst_size;
struct aom_write_bit_buffer wb = { dst, 0 };
uint32_t size = 0;
@@ -3607,9 +3638,9 @@
*total_size += lst_obu->tg_hdr_size;
const uint32_t obu_payload_size = *total_size - lst_obu->tg_hdr_size;
const size_t length_field_size =
- obu_memmove(lst_obu->tg_hdr_size, obu_payload_size, dst);
- if (av1_write_uleb_obu_size(lst_obu->tg_hdr_size, obu_payload_size, dst) !=
- AOM_CODEC_OK)
+ obu_memmove_unsafe(lst_obu->tg_hdr_size, obu_payload_size, dst);
+ if (av1_write_uleb_obu_size_unsafe(lst_obu->tg_hdr_size, obu_payload_size,
+ dst) != AOM_CODEC_OK)
assert(0);
*total_size += (uint32_t)length_field_size;
@@ -3831,15 +3862,15 @@
uint8_t **tile_data_start, int *const largest_tile_id,
int *const is_first_tg, uint32_t obu_header_size, uint8_t obu_extn_header) {
// write current tile group size
- const uint32_t obu_payload_size =
- (uint32_t)(*curr_tg_data_size) - obu_header_size;
+ const size_t obu_payload_size = *curr_tg_data_size - obu_header_size;
const size_t length_field_size =
- obu_memmove(obu_header_size, obu_payload_size, curr_tg_start);
- if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
- curr_tg_start) != AOM_CODEC_OK) {
- assert(0);
+ obu_memmove_unsafe(obu_header_size, obu_payload_size, curr_tg_start);
+ if (av1_write_uleb_obu_size_unsafe(obu_header_size, obu_payload_size,
+ curr_tg_start) != AOM_CODEC_OK) {
+ aom_internal_error(cpi->common.error, AOM_CODEC_ERROR,
+ "av1_write_last_tile_info: output buffer full");
}
- *curr_tg_data_size += (int)length_field_size;
+ *curr_tg_data_size += length_field_size;
*total_size += (uint32_t)length_field_size;
*tile_data_start += length_field_size;
if (cpi->num_tg == 1) {
@@ -3869,8 +3900,8 @@
cpi->common.seq_params->has_nonzero_operating_point_idc,
obu_extn_header, &curr_tg_start[fh_info->obu_header_byte_offset]);
- *curr_tg_data_size += (int)(fh_info->total_length);
- *total_size += (uint32_t)(fh_info->total_length);
+ *curr_tg_data_size += fh_info->total_length;
+ *total_size += (uint32_t)fh_info->total_length;
}
*is_first_tg = 0;
}
@@ -4107,10 +4138,13 @@
}
static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
+ size_t dst_size,
struct aom_write_bit_buffer *saved_wb,
uint8_t obu_extension_header,
const FrameHeaderInfo *fh_info,
int *const largest_tile_id) {
+ // TODO: bug 42302568 - Use dst_size.
+ (void)dst_size;
AV1_COMMON *const cm = &cpi->common;
const CommonTileParams *const tiles = &cm->tiles;
*largest_tile_id = 0;
@@ -4135,21 +4169,26 @@
fh_info, largest_tile_id);
}
+// Returns the number of bytes written on success. Returns 0 on failure.
static size_t av1_write_metadata_obu(const aom_metadata_t *metadata,
- uint8_t *const dst) {
+ uint8_t *const dst, size_t dst_size) {
size_t coded_metadata_size = 0;
const uint64_t metadata_type = (uint64_t)metadata->type;
- if (aom_uleb_encode(metadata_type, sizeof(metadata_type), dst,
- &coded_metadata_size) != 0) {
+ if (aom_uleb_encode(metadata_type, dst_size, dst, &coded_metadata_size) !=
+ 0) {
+ return 0;
+ }
+ if (coded_metadata_size + metadata->sz + 1 > dst_size) {
return 0;
}
memcpy(dst + coded_metadata_size, metadata->payload, metadata->sz);
// Add trailing bits.
dst[coded_metadata_size + metadata->sz] = 0x80;
- return (uint32_t)(coded_metadata_size + metadata->sz + 1);
+ return coded_metadata_size + metadata->sz + 1;
}
-static size_t av1_write_metadata_array(AV1_COMP *const cpi, uint8_t *dst) {
+static size_t av1_write_metadata_array(AV1_COMP *const cpi, uint8_t *dst,
+ size_t dst_size) {
if (!cpi->source) return 0;
AV1_COMMON *const cm = &cpi->common;
aom_metadata_array_t *arr = cpi->source->metadata;
@@ -4166,20 +4205,38 @@
(cm->current_frame.frame_type != KEY_FRAME &&
current_metadata->insert_flag == AOM_MIF_NON_KEY_FRAME) ||
current_metadata->insert_flag == AOM_MIF_ANY_FRAME) {
+ // OBU header is either one or two bytes.
+ if (dst_size < 2) {
+ aom_internal_error(cm->error, AOM_CODEC_ERROR,
+ "av1_write_metadata_array: output buffer full");
+ }
obu_header_size = av1_write_obu_header(
&cpi->ppi->level_params, &cpi->frame_header_count, OBU_METADATA,
cm->seq_params->has_nonzero_operating_point_idc, 0, dst);
+ assert(obu_header_size <= 2);
obu_payload_size =
- av1_write_metadata_obu(current_metadata, dst + obu_header_size);
- length_field_size = obu_memmove(obu_header_size, obu_payload_size, dst);
- if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, dst) ==
- AOM_CODEC_OK) {
- const size_t obu_size = obu_header_size + obu_payload_size;
- dst += obu_size + length_field_size;
- total_bytes_written += obu_size + length_field_size;
+ av1_write_metadata_obu(current_metadata, dst + obu_header_size,
+ dst_size - obu_header_size);
+ if (obu_payload_size == 0) {
+ aom_internal_error(cm->error, AOM_CODEC_ERROR,
+ "av1_write_metadata_array: output buffer full");
+ }
+ length_field_size =
+ obu_memmove(obu_header_size, obu_payload_size, dst, dst_size);
+ if (length_field_size == 0) {
+ aom_internal_error(cm->error, AOM_CODEC_ERROR,
+ "av1_write_metadata_array: output buffer full");
+ }
+ if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, dst,
+ dst_size) == AOM_CODEC_OK) {
+ const size_t obu_size =
+ obu_header_size + obu_payload_size + length_field_size;
+ dst += obu_size;
+ dst_size -= obu_size;
+ total_bytes_written += obu_size;
} else {
aom_internal_error(cpi->common.error, AOM_CODEC_ERROR,
- "Error writing metadata OBU size");
+ "av1_write_metadata_array: output buffer full");
}
}
}
@@ -4187,10 +4244,10 @@
return total_bytes_written;
}
-int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size,
- int *const largest_tile_id) {
+int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t dst_size,
+ size_t *size, int *const largest_tile_id) {
uint8_t *data = dst;
- uint32_t data_size;
+ size_t data_size = dst_size;
AV1_COMMON *const cm = &cpi->common;
AV1LevelParams *const level_params = &cpi->ppi->level_params;
uint32_t obu_header_size = 0;
@@ -4216,23 +4273,38 @@
// preceded by 4-byte size
if (cm->current_frame.frame_type == INTRA_ONLY_FRAME ||
cm->current_frame.frame_type == KEY_FRAME) {
+ // OBU header is either one or two bytes.
+ if (data_size < 2) {
+ return AOM_CODEC_ERROR;
+ }
obu_header_size = av1_write_obu_header(
level_params, &cpi->frame_header_count, OBU_SEQUENCE_HEADER,
cm->seq_params->has_nonzero_operating_point_idc, 0, data);
- obu_payload_size =
- av1_write_sequence_header_obu(cm->seq_params, data + obu_header_size);
+ assert(obu_header_size <= 2);
+ obu_payload_size = av1_write_sequence_header_obu(
+ cm->seq_params, data + obu_header_size, data_size - obu_header_size);
const size_t length_field_size =
- obu_memmove(obu_header_size, obu_payload_size, data);
- if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, data) !=
- AOM_CODEC_OK) {
+ obu_memmove(obu_header_size, obu_payload_size, data, data_size);
+ if (length_field_size == 0) {
+ return AOM_CODEC_ERROR;
+ }
+ if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, data,
+ data_size) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
- data += obu_header_size + obu_payload_size + length_field_size;
+ const size_t bytes_written =
+ obu_header_size + obu_payload_size + length_field_size;
+ data += bytes_written;
+ data_size -= bytes_written;
}
// write metadata obus before the frame obu that has the show_frame flag set
- if (cm->show_frame) data += av1_write_metadata_array(cpi, data);
+ if (cm->show_frame) {
+ const size_t bytes_written = av1_write_metadata_array(cpi, data, data_size);
+ data += bytes_written;
+ data_size -= bytes_written;
+ }
const int write_frame_header =
(cpi->num_tg > 1 || encode_show_existing_frame(cm));
@@ -4241,27 +4313,40 @@
if (write_frame_header) {
// Write Frame Header OBU.
fh_info.frame_header = data;
+ // OBU header is either one or two bytes.
+ if (data_size < 2) {
+ return AOM_CODEC_ERROR;
+ }
obu_header_size = av1_write_obu_header(
level_params, &cpi->frame_header_count, OBU_FRAME_HEADER,
cm->seq_params->has_nonzero_operating_point_idc, obu_extension_header,
data);
+ // TODO: bug 42302568 - Pass data_size - obu_header_size to
+ // write_frame_header_obu().
obu_payload_size = write_frame_header_obu(cpi, &cpi->td.mb.e_mbd, &saved_wb,
data + obu_header_size, 1);
- length_field = obu_memmove(obu_header_size, obu_payload_size, data);
- if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, data) !=
- AOM_CODEC_OK) {
+ length_field =
+ obu_memmove(obu_header_size, obu_payload_size, data, data_size);
+ if (length_field == 0) {
+ return AOM_CODEC_ERROR;
+ }
+ if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, data,
+ data_size) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
fh_info.obu_header_byte_offset = 0;
fh_info.total_length = obu_header_size + obu_payload_size + length_field;
+ // Make sure it is safe to cast fh_info.total_length to uint32_t.
+ if (fh_info.total_length > UINT32_MAX) {
+ return AOM_CODEC_ERROR;
+ }
data += fh_info.total_length;
+ data_size -= fh_info.total_length;
}
- if (encode_show_existing_frame(cm)) {
- data_size = 0;
- } else {
+ if (!encode_show_existing_frame(cm)) {
// Since length_field is determined adaptively after frame header
// encoding, saved_wb must be adjusted accordingly.
if (saved_wb.bit_buffer != NULL) {
@@ -4270,10 +4355,13 @@
// Each tile group obu will be preceded by 4-byte size of the tile group
// obu
- data_size = write_tiles_in_tg_obus(
- cpi, data, &saved_wb, obu_extension_header, &fh_info, largest_tile_id);
+ const size_t bytes_written =
+ write_tiles_in_tg_obus(cpi, data, data_size, &saved_wb,
+ obu_extension_header, &fh_info, largest_tile_id);
+ data += bytes_written;
+ data_size -= bytes_written;
}
- data += data_size;
*size = data - dst;
+ (void)data_size;
return AOM_CODEC_OK;
}
diff --git a/av1/encoder/bitstream.h b/av1/encoder/bitstream.h
index a8f3cc5..0a45b5f 100644
--- a/av1/encoder/bitstream.h
+++ b/av1/encoder/bitstream.h
@@ -17,6 +17,8 @@
#endif
#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
@@ -88,7 +90,7 @@
// payload written to 'dst'. This function does not write the OBU header, the
// optional extension, or the OBU size to 'dst'.
uint32_t av1_write_sequence_header_obu(const SequenceHeader *seq_params,
- uint8_t *const dst);
+ uint8_t *const dst, size_t dst_size);
// Writes the OBU header byte, and the OBU header extension byte when
// has_nonzero_operating_point_idc is true and the OBU is part of a frame.
@@ -99,7 +101,11 @@
int obu_extension, uint8_t *const dst);
int av1_write_uleb_obu_size(size_t obu_header_size, size_t obu_payload_size,
- uint8_t *dest);
+ uint8_t *dest, size_t dest_size);
+
+// Deprecated. Use av1_write_uleb_obu_size() instead.
+int av1_write_uleb_obu_size_unsafe(size_t obu_header_size,
+ size_t obu_payload_size, uint8_t *dest);
// Pack tile data in the bitstream with tile_group, frame
// and OBU header.
@@ -118,7 +124,8 @@
* \ingroup high_level_algo
* \callgraph
*/
-int av1_pack_bitstream(struct AV1_COMP *const cpi, uint8_t *dst, size_t *size,
+int av1_pack_bitstream(struct AV1_COMP *const cpi, uint8_t *dst,
+ size_t dst_size, size_t *size,
int *const largest_tile_id);
void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index d34a84c..b6dcba6 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -716,6 +716,7 @@
// If the current frame does not require filtering, this function is identical
// to av1_encode() except that tpl is not performed.
static int denoise_and_encode(AV1_COMP *const cpi, uint8_t *const dest,
+ size_t dest_size,
EncodeFrameInput *const frame_input,
const EncodeFrameParams *const frame_params,
EncodeFrameResults *const frame_results) {
@@ -900,8 +901,8 @@
#endif // CONFIG_BITRATE_ACCURACY && CONFIG_THREE_PASS
}
- if (av1_encode(cpi, dest, frame_input, frame_params, frame_results) !=
- AOM_CODEC_OK) {
+ if (av1_encode(cpi, dest, dest_size, frame_input, frame_params,
+ frame_results) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
@@ -1213,8 +1214,9 @@
}
int av1_encode_strategy(AV1_COMP *const cpi, size_t *const size,
- uint8_t *const dest, unsigned int *frame_flags,
- int64_t *const time_stamp, int64_t *const time_end,
+ uint8_t *const dest, size_t dest_size,
+ unsigned int *frame_flags, int64_t *const time_stamp,
+ int64_t *const time_end,
const aom_rational64_t *const timestamp_ratio,
int *const pop_lookahead, int flush) {
AV1EncoderConfig *const oxcf = &cpi->oxcf;
@@ -1669,18 +1671,19 @@
}
#if CONFIG_REALTIME_ONLY
- if (av1_encode(cpi, dest, &frame_input, &frame_params, &frame_results) !=
- AOM_CODEC_OK) {
+ if (av1_encode(cpi, dest, dest_size, &frame_input, &frame_params,
+ &frame_results) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
#else
if (has_no_stats_stage(cpi) && oxcf->mode == REALTIME &&
gf_cfg->lag_in_frames == 0) {
- if (av1_encode(cpi, dest, &frame_input, &frame_params, &frame_results) !=
- AOM_CODEC_OK) {
+ if (av1_encode(cpi, dest, dest_size, &frame_input, &frame_params,
+ &frame_results) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
- } else if (denoise_and_encode(cpi, dest, &frame_input, &frame_params,
+ } else if (denoise_and_encode(cpi, dest, dest_size, &frame_input,
+ &frame_params,
&frame_results) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
diff --git a/av1/encoder/encode_strategy.h b/av1/encoder/encode_strategy.h
index 79615be..f6c6aa0 100644
--- a/av1/encoder/encode_strategy.h
+++ b/av1/encoder/encode_strategy.h
@@ -38,8 +38,9 @@
* returns AOM_CODEC_OK.
*
* \param[in] cpi Top-level encoder structure
- * \param[in] size Bitstream size
- * \param[in] dest Bitstream output
+ * \param[out] size Bitstream size
+ * \param[out] dest Bitstream output buffer
+ * \param[in] dest_size Bitstream output buffer size
* \param[in] frame_flags Flags to decide how to encoding the frame
* \param[out] time_stamp Time stamp of the frame
* \param[out] time_end Time end
@@ -53,8 +54,9 @@
* \retval #AOM_CODEC_ERROR
*/
int av1_encode_strategy(AV1_COMP *const cpi, size_t *const size,
- uint8_t *const dest, unsigned int *frame_flags,
- int64_t *const time_stamp, int64_t *const time_end,
+ uint8_t *const dest, size_t dest_size,
+ unsigned int *frame_flags, int64_t *const time_stamp,
+ int64_t *const time_end,
const aom_rational64_t *const timestamp_ratio,
int *const pop_lookahead, int flush);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 60be4c8..bbca48a 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -88,7 +88,9 @@
#include "av1/encoder/segmentation.h"
#include "av1/encoder/speed_features.h"
#include "av1/encoder/superres_scale.h"
+#if CONFIG_THREE_PASS
#include "av1/encoder/thirdpass.h"
+#endif
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/reconinter_enc.h"
#include "av1/encoder/var_based_part.h"
@@ -485,9 +487,9 @@
}
}
-void av1_init_seq_coding_tools(AV1_PRIMARY *const ppi,
- const AV1EncoderConfig *oxcf,
- int disable_frame_id_numbers) {
+static void init_seq_coding_tools(AV1_PRIMARY *const ppi,
+ const AV1EncoderConfig *oxcf,
+ int disable_frame_id_numbers) {
SequenceHeader *const seq = &ppi->seq_params;
const FrameDimensionCfg *const frm_dim_cfg = &oxcf->frm_dim_cfg;
const ToolCfg *const tool_cfg = &oxcf->tool_cfg;
@@ -770,8 +772,8 @@
(ppi->number_spatial_layers > 1 || ppi->number_temporal_layers > 1)
? ppi->number_spatial_layers * ppi->number_temporal_layers - 1
: 0;
- av1_init_seq_coding_tools(
- ppi, oxcf, ppi->use_svc || ppi->rtc_ref.set_ref_frame_config);
+ init_seq_coding_tools(ppi, oxcf,
+ ppi->use_svc || ppi->rtc_ref.set_ref_frame_config);
}
seq_params->timing_info_present &= !seq_params->reduced_still_picture_hdr;
@@ -1613,10 +1615,12 @@
av1_loop_restoration_precal();
#endif
+#if CONFIG_THREE_PASS
cpi->third_pass_ctx = NULL;
if (cpi->oxcf.pass == AOM_RC_THIRD_PASS) {
av1_init_thirdpass_ctx(cm, &cpi->third_pass_ctx, NULL);
}
+#endif
cpi->second_pass_log_stream = NULL;
cpi->use_ducky_encode = 0;
@@ -1746,9 +1750,11 @@
#endif
}
+#if CONFIG_THREE_PASS
av1_free_thirdpass_ctx(cpi->third_pass_ctx);
av1_close_second_pass_log(cpi);
+#endif
dealloc_compressor_data(cpi);
@@ -2403,10 +2409,7 @@
const int use_loopfilter =
is_loopfilter_used(cm) && !cpi->mt_info.pipeline_lpf_mt_with_enc;
- const int use_cdef =
- is_cdef_used(cm) && (!cpi->active_map.enabled ||
- cpi->rc.percent_blocks_inactive <=
- cpi->sf.rt_sf.thresh_active_maps_skip_lf_cdef);
+ const int use_cdef = is_cdef_used(cm);
const int use_superres = av1_superres_scaled(cm);
const int use_restoration = is_restoration_used(cm);
@@ -2767,14 +2770,16 @@
*
* \param[in] cpi Top-level encoder structure
* \param[in] size Bitstream size
- * \param[in] dest Bitstream output
+ * \param[out] dest Bitstream output buffer
+ * \param[in] dest_size Bitstream output buffer size
*
* \return Returns a value to indicate if the encoding is done successfully.
* \retval #AOM_CODEC_OK
* \retval -1
* \retval #AOM_CODEC_ERROR
*/
-static int encode_with_recode_loop(AV1_COMP *cpi, size_t *size, uint8_t *dest) {
+static int encode_with_recode_loop(AV1_COMP *cpi, size_t *size, uint8_t *dest,
+ size_t dest_size) {
AV1_COMMON *const cm = &cpi->common;
RATE_CONTROL *const rc = &cpi->rc;
GlobalMotionInfo *const gm_info = &cpi->gm_info;
@@ -3051,7 +3056,7 @@
av1_finalize_encoded_frame(cpi);
int largest_tile_id = 0; // Output from bitstream: unused here
rc->coefficient_size = 0;
- if (av1_pack_bitstream(cpi, dest, size, &largest_tile_id) !=
+ if (av1_pack_bitstream(cpi, dest, dest_size, size, &largest_tile_id) !=
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
@@ -3171,7 +3176,8 @@
*
* \param[in] cpi Top-level encoder structure
* \param[in] size Bitstream size
- * \param[in] dest Bitstream output
+ * \param[out] dest Bitstream output buffer
+ * \param[in] dest_size Bitstream output buffer size
* \param[in] sse Total distortion of the frame
* \param[in] rate Total rate of the frame
* \param[in] largest_tile_id Tile id of the last tile
@@ -3181,8 +3187,8 @@
* \retval #AOM_CODEC_ERROR
*/
static int encode_with_recode_loop_and_filter(AV1_COMP *cpi, size_t *size,
- uint8_t *dest, int64_t *sse,
- int64_t *rate,
+ uint8_t *dest, size_t dest_size,
+ int64_t *sse, int64_t *rate,
int *largest_tile_id) {
#if CONFIG_COLLECT_COMPONENT_TIMING
start_timing(cpi, encode_with_or_without_recode_time);
@@ -3202,7 +3208,7 @@
if (cpi->sf.hl_sf.recode_loop == DISALLOW_RECODE)
err = encode_without_recode(cpi);
else
- err = encode_with_recode_loop(cpi, size, dest);
+ err = encode_with_recode_loop(cpi, size, dest, dest_size);
#endif
#if CONFIG_COLLECT_COMPONENT_TIMING
end_timing(cpi, encode_with_or_without_recode_time);
@@ -3281,7 +3287,8 @@
start_timing(cpi, av1_pack_bitstream_final_time);
#endif
cpi->rc.coefficient_size = 0;
- if (av1_pack_bitstream(cpi, dest, size, largest_tile_id) != AOM_CODEC_OK)
+ if (av1_pack_bitstream(cpi, dest, dest_size, size, largest_tile_id) !=
+ AOM_CODEC_OK)
return AOM_CODEC_ERROR;
#if CONFIG_COLLECT_COMPONENT_TIMING
end_timing(cpi, av1_pack_bitstream_final_time);
@@ -3325,7 +3332,7 @@
}
static int encode_with_and_without_superres(AV1_COMP *cpi, size_t *size,
- uint8_t *dest,
+ uint8_t *dest, size_t dest_size,
int *largest_tile_id) {
const AV1_COMMON *const cm = &cpi->common;
assert(cm->seq_params->enable_superres);
@@ -3361,7 +3368,7 @@
cpi->superres_mode = AOM_SUPERRES_AUTO; // Super-res on for this loop.
err = encode_with_recode_loop_and_filter(
- cpi, size, dest, &superres_sses[this_index],
+ cpi, size, dest, dest_size, &superres_sses[this_index],
&superres_rates[this_index],
&superres_largest_tile_ids[this_index]);
cpi->superres_mode = AOM_SUPERRES_NONE; // Reset to default (full-res).
@@ -3381,8 +3388,8 @@
}
// Encode without superres.
assert(cpi->superres_mode == AOM_SUPERRES_NONE);
- err = encode_with_recode_loop_and_filter(cpi, size, dest, &sse2, &rate2,
- &largest_tile_id2);
+ err = encode_with_recode_loop_and_filter(cpi, size, dest, dest_size, &sse2,
+ &rate2, &largest_tile_id2);
if (err != AOM_CODEC_OK) return err;
// Note: Both use common rdmult based on base qindex of fullres.
@@ -3422,8 +3429,8 @@
int64_t rate3 = INT64_MAX;
cpi->superres_mode =
AOM_SUPERRES_AUTO; // Super-res on for this recode loop.
- err = encode_with_recode_loop_and_filter(cpi, size, dest, &sse3, &rate3,
- largest_tile_id);
+ err = encode_with_recode_loop_and_filter(cpi, size, dest, dest_size,
+ &sse3, &rate3, largest_tile_id);
cpi->superres_mode = AOM_SUPERRES_NONE; // Reset to default (full-res).
assert(sse1 == sse3);
assert(rate1 == rate3);
@@ -3438,15 +3445,15 @@
assert(cpi->sf.hl_sf.superres_auto_search_type == SUPERRES_AUTO_DUAL);
cpi->superres_mode =
AOM_SUPERRES_AUTO; // Super-res on for this recode loop.
- err = encode_with_recode_loop_and_filter(cpi, size, dest, &sse1, &rate1,
- &largest_tile_id1);
+ err = encode_with_recode_loop_and_filter(cpi, size, dest, dest_size, &sse1,
+ &rate1, &largest_tile_id1);
cpi->superres_mode = AOM_SUPERRES_NONE; // Reset to default (full-res).
if (err != AOM_CODEC_OK) return err;
restore_all_coding_context(cpi);
// Encode without superres.
assert(cpi->superres_mode == AOM_SUPERRES_NONE);
- err = encode_with_recode_loop_and_filter(cpi, size, dest, &sse2, &rate2,
- &largest_tile_id2);
+ err = encode_with_recode_loop_and_filter(cpi, size, dest, dest_size, &sse2,
+ &rate2, &largest_tile_id2);
if (err != AOM_CODEC_OK) return err;
// Note: Both use common rdmult based on base qindex of fullres.
@@ -3466,8 +3473,8 @@
int64_t rate3 = INT64_MAX;
cpi->superres_mode =
AOM_SUPERRES_AUTO; // Super-res on for this recode loop.
- err = encode_with_recode_loop_and_filter(cpi, size, dest, &sse3, &rate3,
- largest_tile_id);
+ err = encode_with_recode_loop_and_filter(cpi, size, dest, dest_size,
+ &sse3, &rate3, largest_tile_id);
cpi->superres_mode = AOM_SUPERRES_NONE; // Reset to default (full-res).
assert(sse1 == sse3);
assert(rate1 == rate3);
@@ -3579,14 +3586,15 @@
*
* \param[in] cpi Top-level encoder structure
* \param[in] size Bitstream size
- * \param[in] dest Bitstream output
+ * \param[out] dest Bitstream output buffer
+ * \param[in] dest_size Bitstream output buffer size
*
* \return Returns a value to indicate if the encoding is done successfully.
* \retval #AOM_CODEC_OK
* \retval #AOM_CODEC_ERROR
*/
-static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
- uint8_t *dest) {
+static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
+ size_t dest_size) {
AV1_COMMON *const cm = &cpi->common;
SequenceHeader *const seq_params = cm->seq_params;
CurrentFrame *const current_frame = &cm->current_frame;
@@ -3648,7 +3656,8 @@
// Build the bitstream
int largest_tile_id = 0; // Output from bitstream: unused here
cpi->rc.coefficient_size = 0;
- if (av1_pack_bitstream(cpi, dest, size, &largest_tile_id) != AOM_CODEC_OK)
+ if (av1_pack_bitstream(cpi, dest, dest_size, size, &largest_tile_id) !=
+ AOM_CODEC_OK)
return AOM_CODEC_ERROR;
if (seq_params->frame_id_numbers_present_flag &&
@@ -3891,14 +3900,15 @@
int largest_tile_id = 0;
if (av1_superres_in_recode_allowed(cpi)) {
- if (encode_with_and_without_superres(cpi, size, dest, &largest_tile_id) !=
- AOM_CODEC_OK) {
+ if (encode_with_and_without_superres(cpi, size, dest, dest_size,
+ &largest_tile_id) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
} else {
const aom_superres_mode orig_superres_mode = cpi->superres_mode; // save
cpi->superres_mode = cpi->oxcf.superres_cfg.superres_mode;
- if (encode_with_recode_loop_and_filter(cpi, size, dest, NULL, NULL,
+ if (encode_with_recode_loop_and_filter(cpi, size, dest, dest_size, NULL,
+ NULL,
&largest_tile_id) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
@@ -3997,7 +4007,7 @@
return AOM_CODEC_OK;
}
-int av1_encode(AV1_COMP *const cpi, uint8_t *const dest,
+int av1_encode(AV1_COMP *const cpi, uint8_t *const dest, size_t dest_size,
const EncodeFrameInput *const frame_input,
const EncodeFrameParams *const frame_params,
EncodeFrameResults *const frame_results) {
@@ -4049,7 +4059,7 @@
#endif
} else if (cpi->oxcf.pass == AOM_RC_ONE_PASS ||
cpi->oxcf.pass >= AOM_RC_SECOND_PASS) {
- if (encode_frame_to_data_rate(cpi, &frame_results->size, dest) !=
+ if (encode_frame_to_data_rate(cpi, &frame_results->size, dest, dest_size) !=
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
@@ -4671,9 +4681,11 @@
update_end_of_frame_stats(cpi);
}
+#if CONFIG_THREE_PASS
if (cpi->oxcf.pass == AOM_RC_THIRD_PASS && cpi->third_pass_ctx) {
av1_pop_third_pass_info(cpi->third_pass_ctx);
}
+#endif
if (ppi->rtc_ref.set_ref_frame_config) {
av1_svc_update_buffer_slot_refreshed(cpi);
@@ -4696,9 +4708,11 @@
}
#endif // CONFIG_INTERNAL_STATS
+#if CONFIG_THREE_PASS
// Write frame info. Subtract 1 from frame index since if was incremented in
// update_rc_counts.
av1_write_second_pass_per_frame_info(cpi, cpi->gf_frame_index - 1);
+#endif
}
int av1_get_compressed_data(AV1_COMP *cpi, AV1_COMP_DATA *const cpi_data) {
@@ -4772,8 +4786,8 @@
#endif
const int result = av1_encode_strategy(
- cpi, &cpi_data->frame_size, cpi_data->cx_data, &cpi_data->lib_flags,
- &cpi_data->ts_frame_start, &cpi_data->ts_frame_end,
+ cpi, &cpi_data->frame_size, cpi_data->cx_data, cpi_data->cx_data_sz,
+ &cpi_data->lib_flags, &cpi_data->ts_frame_start, &cpi_data->ts_frame_end,
cpi_data->timestamp_ratio, &cpi_data->pop_lookahead, cpi_data->flush);
#if CONFIG_COLLECT_COMPONENT_TIMING
@@ -4847,7 +4861,7 @@
// Populates cpi->scaled_ref_buf corresponding to frames in a parallel encode
// set. Also sets the bitmask 'ref_buffers_used_map'.
-void av1_scale_references_fpmt(AV1_COMP *cpi, int *ref_buffers_used_map) {
+static void scale_references_fpmt(AV1_COMP *cpi, int *ref_buffers_used_map) {
AV1_COMMON *cm = &cpi->common;
MV_REFERENCE_FRAME ref_frame;
@@ -4881,8 +4895,8 @@
// Increments the ref_count of frame buffers referenced by cpi->scaled_ref_buf
// corresponding to frames in a parallel encode set.
-void av1_increment_scaled_ref_counts_fpmt(BufferPool *buffer_pool,
- int ref_buffers_used_map) {
+static void increment_scaled_ref_counts_fpmt(BufferPool *buffer_pool,
+ int ref_buffers_used_map) {
for (int i = 0; i < buffer_pool->num_frame_bufs; ++i) {
if (ref_buffers_used_map & (1 << i)) {
++buffer_pool->frame_bufs[i].ref_count;
@@ -5029,7 +5043,7 @@
av1_get_ref_frames(first_ref_frame_map_pairs, cur_frame_disp, first_cpi,
gf_index_start, 1, first_cpi->common.remapped_ref_idx);
- av1_scale_references_fpmt(first_cpi, ref_buffers_used_map);
+ scale_references_fpmt(first_cpi, ref_buffers_used_map);
parallel_frame_count++;
// Iterate through the GF_GROUP to find the remaining frame_parallel_level 2
@@ -5118,7 +5132,7 @@
av1_get_ref_frames(first_ref_frame_map_pairs, cur_frame_disp, cur_cpi, i,
1, cur_cpi->common.remapped_ref_idx);
- av1_scale_references_fpmt(cur_cpi, ref_buffers_used_map);
+ scale_references_fpmt(cur_cpi, ref_buffers_used_map);
parallel_frame_count++;
}
@@ -5134,8 +5148,8 @@
}
}
- av1_increment_scaled_ref_counts_fpmt(first_cpi->common.buffer_pool,
- *ref_buffers_used_map);
+ increment_scaled_ref_counts_fpmt(first_cpi->common.buffer_pool,
+ *ref_buffers_used_map);
// Return the number of frames in the parallel encode set.
return parallel_frame_count;
@@ -5386,8 +5400,8 @@
if (!ppi) return NULL;
uint8_t header_buf[512] = { 0 };
- const uint32_t sequence_header_size =
- av1_write_sequence_header_obu(&ppi->seq_params, &header_buf[0]);
+ const uint32_t sequence_header_size = av1_write_sequence_header_obu(
+ &ppi->seq_params, &header_buf[0], sizeof(header_buf));
assert(sequence_header_size <= sizeof(header_buf));
if (sequence_header_size == 0) return NULL;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index a50188c..1a1d059 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -51,7 +51,9 @@
#include "av1/encoder/speed_features.h"
#include "av1/encoder/svc_layercontext.h"
#include "av1/encoder/temporal_filter.h"
+#if CONFIG_THREE_PASS
#include "av1/encoder/thirdpass.h"
+#endif
#include "av1/encoder/tokenize.h"
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/av1_noise_estimate.h"
@@ -3593,10 +3595,12 @@
*/
TWO_PASS_FRAME twopass_frame;
+#if CONFIG_THREE_PASS
/*!
* Context needed for third pass encoding.
*/
THIRD_PASS_DEC_CTX *third_pass_ctx;
+#endif
/*!
* File pointer to second pass log
@@ -3773,17 +3777,9 @@
aom_codec_err_t av1_check_initial_width(AV1_COMP *cpi, int use_highbitdepth,
int subsampling_x, int subsampling_y);
-void av1_init_seq_coding_tools(AV1_PRIMARY *const ppi,
- const AV1EncoderConfig *oxcf, int use_svc);
-
void av1_post_encode_updates(AV1_COMP *const cpi,
const AV1_COMP_DATA *const cpi_data);
-void av1_scale_references_fpmt(AV1_COMP *cpi, int *ref_buffers_used_map);
-
-void av1_increment_scaled_ref_counts_fpmt(BufferPool *buffer_pool,
- int ref_buffers_used_map);
-
void av1_release_scaled_references_fpmt(AV1_COMP *cpi);
void av1_decrement_ref_counts_fpmt(BufferPool *buffer_pool,
@@ -3849,7 +3845,7 @@
* \callgraph
* \callergraph
*/
-int av1_encode(AV1_COMP *const cpi, uint8_t *const dest,
+int av1_encode(AV1_COMP *const cpi, uint8_t *const dest, size_t dest_size,
const EncodeFrameInput *const frame_input,
const EncodeFrameParams *const frame_params,
EncodeFrameResults *const frame_results);
diff --git a/av1/encoder/hash_motion.c b/av1/encoder/hash_motion.c
index 78403a6..1f4131e 100644
--- a/av1/encoder/hash_motion.c
+++ b/av1/encoder/hash_motion.c
@@ -102,7 +102,7 @@
intrabc_hash_info->intrabc_hash_table.p_lookup_table = NULL;
}
-void av1_hash_table_clear_all(hash_table *p_hash_table) {
+static void clear_all(hash_table *p_hash_table) {
if (p_hash_table->p_lookup_table == NULL) {
return;
}
@@ -116,14 +116,14 @@
}
void av1_hash_table_destroy(hash_table *p_hash_table) {
- av1_hash_table_clear_all(p_hash_table);
+ clear_all(p_hash_table);
aom_free(p_hash_table->p_lookup_table);
p_hash_table->p_lookup_table = NULL;
}
bool av1_hash_table_create(hash_table *p_hash_table) {
if (p_hash_table->p_lookup_table != NULL) {
- av1_hash_table_clear_all(p_hash_table);
+ clear_all(p_hash_table);
return true;
}
p_hash_table->p_lookup_table =
@@ -170,24 +170,6 @@
return aom_vector_begin(p_hash_table->p_lookup_table[hash_value]);
}
-int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1,
- uint32_t hash_value2) {
- if (p_hash_table->p_lookup_table[hash_value1] == NULL) {
- return 0;
- }
- Iterator iterator =
- aom_vector_begin(p_hash_table->p_lookup_table[hash_value1]);
- Iterator last = aom_vector_end(p_hash_table->p_lookup_table[hash_value1]);
- for (; !aom_iterator_equals(&iterator, &last);
- aom_iterator_increment(&iterator)) {
- if ((*(block_hash *)aom_iterator_get(&iterator)).hash_value2 ==
- hash_value2) {
- return 1;
- }
- }
- return 0;
-}
-
void av1_generate_block_2x2_hash_value(IntraBCHashInfo *intrabc_hash_info,
const YV12_BUFFER_CONFIG *picture,
uint32_t *pic_block_hash[2],
diff --git a/av1/encoder/hash_motion.h b/av1/encoder/hash_motion.h
index f78b0f6..f9686dc 100644
--- a/av1/encoder/hash_motion.h
+++ b/av1/encoder/hash_motion.h
@@ -56,15 +56,12 @@
} IntraBCHashInfo;
void av1_hash_table_init(IntraBCHashInfo *intra_bc_hash_info);
-void av1_hash_table_clear_all(hash_table *p_hash_table);
void av1_hash_table_destroy(hash_table *p_hash_table);
bool av1_hash_table_create(hash_table *p_hash_table);
int32_t av1_hash_table_count(const hash_table *p_hash_table,
uint32_t hash_value);
Iterator av1_hash_get_first_iterator(hash_table *p_hash_table,
uint32_t hash_value);
-int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1,
- uint32_t hash_value2);
void av1_generate_block_2x2_hash_value(IntraBCHashInfo *intra_bc_hash_info,
const YV12_BUFFER_CONFIG *picture,
uint32_t *pic_block_hash[2],
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 1a5e5c5..0709e9b 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -350,8 +350,8 @@
// Search site initialization for DIAMOND / CLAMPED_DIAMOND search methods.
// level = 0: DIAMOND, level = 1: CLAMPED_DIAMOND.
-void av1_init_dsmotion_compensation(search_site_config *cfg, int stride,
- int level) {
+static void init_dsmotion_compensation(search_site_config *cfg, int stride,
+ int level) {
int num_search_steps = 0;
int stage_index = MAX_MVSEARCH_STEPS - 1;
@@ -433,8 +433,8 @@
// Search site initialization for NSTEP / NSTEP_8PT search methods.
// level = 0: NSTEP, level = 1: NSTEP_8PT.
-void av1_init_motion_compensation_nstep(search_site_config *cfg, int stride,
- int level) {
+static void init_motion_compensation_nstep(search_site_config *cfg, int stride,
+ int level) {
int num_search_steps = 0;
int stage_index = 0;
cfg->stride = stride;
@@ -479,8 +479,8 @@
// Search site initialization for BIGDIA / FAST_BIGDIA / FAST_DIAMOND
// search methods.
-void av1_init_motion_compensation_bigdia(search_site_config *cfg, int stride,
- int level) {
+static void init_motion_compensation_bigdia(search_site_config *cfg, int stride,
+ int level) {
(void)level;
cfg->stride = stride;
// First scale has 4-closest points, the rest have 8 points in diamond
@@ -534,8 +534,8 @@
}
// Search site initialization for SQUARE search method.
-void av1_init_motion_compensation_square(search_site_config *cfg, int stride,
- int level) {
+static void init_motion_compensation_square(search_site_config *cfg, int stride,
+ int level) {
(void)level;
cfg->stride = stride;
// All scales have 8 closest points in square shape.
@@ -588,8 +588,8 @@
}
// Search site initialization for HEX / FAST_HEX search methods.
-void av1_init_motion_compensation_hex(search_site_config *cfg, int stride,
- int level) {
+static void init_motion_compensation_hex(search_site_config *cfg, int stride,
+ int level) {
(void)level;
cfg->stride = stride;
// First scale has 8-closest points, the rest have 6 points in hex shape
@@ -638,10 +638,10 @@
const av1_init_search_site_config
av1_init_motion_compensation[NUM_DISTINCT_SEARCH_METHODS] = {
- av1_init_dsmotion_compensation, av1_init_motion_compensation_nstep,
- av1_init_motion_compensation_nstep, av1_init_dsmotion_compensation,
- av1_init_motion_compensation_hex, av1_init_motion_compensation_bigdia,
- av1_init_motion_compensation_square
+ init_dsmotion_compensation, init_motion_compensation_nstep,
+ init_motion_compensation_nstep, init_dsmotion_compensation,
+ init_motion_compensation_hex, init_motion_compensation_bigdia,
+ init_motion_compensation_square
};
// Checks whether the mv is within range of the mv_limits
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index f55d869..05cbf87 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -151,24 +151,8 @@
void av1_set_ms_to_intra_mode(FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const IntraBCMVCosts *dv_costs);
-// Sets up configs for fullpixel DIAMOND / CLAMPED_DIAMOND search method.
-void av1_init_dsmotion_compensation(search_site_config *cfg, int stride,
- int level);
// Sets up configs for firstpass motion search.
void av1_init_motion_fpf(search_site_config *cfg, int stride);
-// Sets up configs for NSTEP / NSTEP_8PT motion search method.
-void av1_init_motion_compensation_nstep(search_site_config *cfg, int stride,
- int level);
-// Sets up configs for BIGDIA / FAST_DIAMOND / FAST_BIGDIA
-// motion search method.
-void av1_init_motion_compensation_bigdia(search_site_config *cfg, int stride,
- int level);
-// Sets up configs for HEX or FAST_HEX motion search method.
-void av1_init_motion_compensation_hex(search_site_config *cfg, int stride,
- int level);
-// Sets up configs for SQUARE motion search method.
-void av1_init_motion_compensation_square(search_site_config *cfg, int stride,
- int level);
/*! Function pointer to search site config initialization of different search
* method functions. */
diff --git a/av1/encoder/palette.c b/av1/encoder/palette.c
index a3e3fbf..c1ceb8c 100644
--- a/av1/encoder/palette.c
+++ b/av1/encoder/palette.c
@@ -35,7 +35,19 @@
return (*(int16_t *)a - *(int16_t *)b);
}
-int av1_remove_duplicates(int16_t *centroids, int num_centroids) {
+/*!\brief Removes duplicated centroid indices.
+ *
+ * \ingroup palette_mode_search
+ * \param[in] centroids A list of centroids index.
+ * \param[in] num_centroids Number of centroids.
+ *
+ * \return Returns the number of unique centroids and saves the unique centroids
+ * in beginning of the centroids array.
+ *
+ * \attention The centroids should be rounded to integers before calling this
+ * method.
+ */
+static int remove_duplicates(int16_t *centroids, int num_centroids) {
int num_unique; // number of unique centroids
int i;
qsort(centroids, num_centroids, sizeof(*centroids), int16_comparer);
@@ -225,7 +237,7 @@
if (do_header_rd_based_breakout != NULL) *do_header_rd_based_breakout = false;
optimize_palette_colors(color_cache, n_cache, n, 1, centroids,
cpi->common.seq_params->bit_depth);
- const int num_unique_colors = av1_remove_duplicates(centroids, n);
+ const int num_unique_colors = remove_duplicates(centroids, n);
if (num_unique_colors < PALETTE_MIN_SIZE) {
// Too few unique colors to create a palette. And DC_PRED will work
// well for that case anyway. So skip.
diff --git a/av1/encoder/palette.h b/av1/encoder/palette.h
index a0c428b..ce10949 100644
--- a/av1/encoder/palette.h
+++ b/av1/encoder/palette.h
@@ -99,20 +99,6 @@
}
}
-/*!\brief Removes duplicated centroid indices.
- *
- * \ingroup palette_mode_search
- * \param[in] centroids A list of centroids index.
- * \param[in] num_centroids Number of centroids.
- *
- * \return Returns the number of unique centroids and saves the unique centroids
- * in beginning of the centroids array.
- *
- * \attention The centroids should be rounded to integers before calling this
- * method.
- */
-int av1_remove_duplicates(int16_t *centroids, int num_centroids);
-
/*!\brief Checks what colors are in the color cache.
*
* \ingroup palette_mode_search
diff --git a/av1/encoder/partition_strategy.c b/av1/encoder/partition_strategy.c
index d756113..c1d3e3e 100644
--- a/av1/encoder/partition_strategy.c
+++ b/av1/encoder/partition_strategy.c
@@ -11,8 +11,12 @@
#include <float.h>
+#include "config/aom_config.h"
+
#include "av1/encoder/encodeframe_utils.h"
+#if CONFIG_THREE_PASS
#include "av1/encoder/thirdpass.h"
+#endif
#include "config/aom_dsp_rtcd.h"
#include "av1/common/enums.h"
@@ -135,10 +139,10 @@
// -- add support for pruning rectangular partitions
// -- use reconstructed pixels instead of source pixels for padding
// -- use chroma pixels in addition to luma pixels
-void av1_intra_mode_cnn_partition(const AV1_COMMON *const cm, MACROBLOCK *x,
- int quad_tree_idx,
- int intra_cnn_based_part_prune_level,
- PartitionSearchState *part_state) {
+static void intra_mode_cnn_partition(const AV1_COMMON *const cm, MACROBLOCK *x,
+ int quad_tree_idx,
+ int intra_cnn_based_part_prune_level,
+ PartitionSearchState *part_state) {
assert(cm->seq_params->sb_size >= BLOCK_64X64 &&
"Invalid sb_size for intra_cnn!");
const PartitionBlkParams *blk_params = &part_state->part_blk_params;
@@ -364,9 +368,12 @@
return sms_prune_agg_qindex_based[qband];
}
-void av1_simple_motion_search_based_split(AV1_COMP *const cpi, MACROBLOCK *x,
- SIMPLE_MOTION_DATA_TREE *sms_tree,
- PartitionSearchState *part_state) {
+// Performs a simple_motion_search with a single reference frame and extract
+// the variance of residues. Then use the features to determine whether we want
+// to go straight to splitting without trying PARTITION_NONE
+static void simple_motion_search_based_split(AV1_COMP *const cpi, MACROBLOCK *x,
+ SIMPLE_MOTION_DATA_TREE *sms_tree,
+ PartitionSearchState *part_state) {
const AV1_COMMON *const cm = &cpi->common;
const PartitionBlkParams *blk_params = &part_state->part_blk_params;
const int mi_row = blk_params->mi_row, mi_col = blk_params->mi_col;
@@ -636,9 +643,12 @@
features[f_idx++] = (float)mi_size_high_log2[left_bsize];
}
-void av1_simple_motion_search_prune_rect(AV1_COMP *const cpi, MACROBLOCK *x,
- SIMPLE_MOTION_DATA_TREE *sms_tree,
- PartitionSearchState *part_state) {
+// Performs a simple_motion_search with two reference frames and extract
+// the variance of residues. Then use the features to determine whether we want
+// to prune some partitions.
+static void simple_motion_search_prune_rect(AV1_COMP *const cpi, MACROBLOCK *x,
+ SIMPLE_MOTION_DATA_TREE *sms_tree,
+ PartitionSearchState *part_state) {
const AV1_COMMON *const cm = &cpi->common;
const PartitionBlkParams *blk_params = &part_state->part_blk_params;
const int mi_row = blk_params->mi_row, mi_col = blk_params->mi_col;
@@ -1206,10 +1216,10 @@
// Use a ML model to predict if horz_a, horz_b, vert_a, and vert_b should be
// considered.
-void av1_ml_prune_ab_partition(AV1_COMP *const cpi, int part_ctx, int var_ctx,
- int64_t best_rd,
- PartitionSearchState *part_state,
- int *ab_partitions_allowed) {
+static void ml_prune_ab_partition(AV1_COMP *const cpi, int part_ctx,
+ int var_ctx, int64_t best_rd,
+ PartitionSearchState *part_state,
+ int *ab_partitions_allowed) {
const PartitionBlkParams blk_params = part_state->part_blk_params;
const int mi_row = blk_params.mi_row;
const int mi_col = blk_params.mi_col;
@@ -1552,6 +1562,7 @@
const PartitionBlkParams *blk_params = &part_state->part_blk_params;
const BLOCK_SIZE bsize = blk_params->bsize;
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx) {
int mi_row = blk_params->mi_row;
int mi_col = blk_params->mi_col;
@@ -1621,6 +1632,7 @@
}
}
}
+#endif // CONFIG_THREE_PASS
// Prune rectangular partitions for larger blocks.
if (bsize > cpi->sf.part_sf.rect_partition_eval_thresh) {
@@ -1679,9 +1691,9 @@
av1_is_whole_blk_in_frame(blk_params, mi_params);
if (try_intra_cnn_based_part_prune) {
- av1_intra_mode_cnn_partition(
- &cpi->common, x, x->part_search_info.quad_tree_idx,
- cpi->sf.part_sf.intra_cnn_based_part_prune_level, part_state);
+ intra_mode_cnn_partition(&cpi->common, x, x->part_search_info.quad_tree_idx,
+ cpi->sf.part_sf.intra_cnn_based_part_prune_level,
+ part_state);
}
// Use simple motion search to prune out split or non-split partitions. This
@@ -1694,7 +1706,7 @@
!frame_is_intra_only(cm) && !av1_superres_scaled(cm);
if (try_split_only) {
- av1_simple_motion_search_based_split(cpi, x, sms_tree, part_state);
+ simple_motion_search_based_split(cpi, x, sms_tree, part_state);
}
// Use simple motion search to prune out rectangular partition in some
@@ -1718,7 +1730,7 @@
!av1_superres_scaled(cm);
if (try_prune_rect) {
- av1_simple_motion_search_prune_rect(cpi, x, sms_tree, part_state);
+ simple_motion_search_prune_rect(cpi, x, sms_tree, part_state);
}
}
@@ -1892,9 +1904,9 @@
// TODO(huisu@google.com): x->source_variance may not be the current
// block's variance. The correct one to use is pb_source_variance. Need to
// re-train the model to fix it.
- av1_ml_prune_ab_partition(cpi, pc_tree->partitioning,
- get_unsigned_bits(x->source_variance),
- best_rdcost, part_state, ab_partitions_allowed);
+ ml_prune_ab_partition(cpi, pc_tree->partitioning,
+ get_unsigned_bits(x->source_variance), best_rdcost,
+ part_state, ab_partitions_allowed);
}
// Pruning: pruning AB partitions based on the number of horz/vert wins
diff --git a/av1/encoder/partition_strategy.h b/av1/encoder/partition_strategy.h
index 2597ded..b95e967 100644
--- a/av1/encoder/partition_strategy.h
+++ b/av1/encoder/partition_strategy.h
@@ -17,25 +17,6 @@
#include "av1/encoder/encodemb.h"
#include "av1/encoder/encoder.h"
-void av1_intra_mode_cnn_partition(const AV1_COMMON *const cm, MACROBLOCK *x,
- int label_idx,
- int intra_cnn_based_part_prune_level,
- PartitionSearchState *part_state);
-
-// Performs a simple_motion_search with a single reference frame and extract
-// the variance of residues. Then use the features to determine whether we want
-// to go straight to splitting without trying PARTITION_NONE
-void av1_simple_motion_search_based_split(AV1_COMP *const cpi, MACROBLOCK *x,
- SIMPLE_MOTION_DATA_TREE *sms_tree,
- PartitionSearchState *part_state);
-
-// Performs a simple_motion_search with two reference frames and extract
-// the variance of residues. Then use the features to determine whether we want
-// to prune some partitions.
-void av1_simple_motion_search_prune_rect(AV1_COMP *const cpi, MACROBLOCK *x,
- SIMPLE_MOTION_DATA_TREE *sms_tree,
- PartitionSearchState *part_state);
-
#if !CONFIG_REALTIME_ONLY
// Early terminates PARTITION_NONE using simple_motion_search features and the
// rate, distortion, and rdcost of PARTITION_NONE. This is only called when:
@@ -80,13 +61,6 @@
const int64_t *split_rd,
PartitionSearchState *part_state);
-// Use a ML model to predict if horz_a, horz_b, vert_a, and vert_b should be
-// considered.
-void av1_ml_prune_ab_partition(AV1_COMP *const cpi, int part_ctx, int var_ctx,
- int64_t best_rd,
- PartitionSearchState *part_state,
- int *ab_partitions_allowed);
-
// Use a ML model to predict if horz4 and vert4 should be considered.
void av1_ml_prune_4_partition(AV1_COMP *const cpi, MACROBLOCK *const x,
int part_ctx, int64_t best_rd,
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index beff033..194019b 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -38,7 +38,9 @@
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rc_utils.h"
#include "av1/encoder/temporal_filter.h"
+#if CONFIG_THREE_PASS
#include "av1/encoder/thirdpass.h"
+#endif
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/encode_strategy.h"
@@ -47,8 +49,10 @@
#define GROUP_ADAPTIVE_MAXQ 1
static void init_gf_stats(GF_GROUP_STATS *gf_stats);
+#if CONFIG_THREE_PASS
static int define_gf_group_pass3(AV1_COMP *cpi, EncodeFrameParams *frame_params,
int is_final_pass);
+#endif
// Calculate an active area of the image that discounts formatting
// bars and partially discounts other 0 energy areas.
@@ -171,6 +175,7 @@
const double min_fac = 1.0 - adj_limit;
const double max_fac = 1.0 + adj_limit;
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx && cpi->third_pass_ctx->frame_info_count > 0) {
int64_t actual_bits = 0;
int64_t target_bits = 0;
@@ -198,6 +203,7 @@
AOMMAX(min_fac, AOMMIN(max_fac, twopass->bpm_factor));
}
}
+#endif // CONFIG_THREE_PASS
int err_estimate = p_rc->rate_error_estimate;
int64_t total_actual_bits = p_rc->total_actual_bits;
@@ -254,16 +260,18 @@
}
}
-static const double q_div_term[(QINDEX_RANGE >> 5) + 1] = { 32.0, 40.0, 46.0,
- 52.0, 56.0, 60.0,
- 64.0, 68.0, 72.0 };
+static const double q_div_term[(QINDEX_RANGE >> 4) + 1] = {
+ 18.0, 30.0, 38.0, 44.0, 47.0, 50.0, 52.0, 54.0, 56.0,
+ 58.0, 60.0, 62.0, 64.0, 66.0, 68.0, 70.0, 72.0
+};
+
#define EPMB_SCALER 1250000
static double calc_correction_factor(double err_per_mb, int q) {
double power_term = 0.90;
- const int index = q >> 5;
+ const int index = q >> 4;
const double divisor =
q_div_term[index] +
- (((q_div_term[index + 1] - q_div_term[index]) * (q % 32)) / 32.0);
+ (((q_div_term[index + 1] - q_div_term[index]) * (q % 16)) / 16.0);
double error_term = EPMB_SCALER * pow(err_per_mb, power_term);
return error_term / divisor;
}
@@ -337,6 +345,10 @@
const uint64_t target_norm_bits_per_mb =
((uint64_t)av_target_bandwidth << BPER_MB_NORMBITS) / active_mbs;
int rate_err_tol = AOMMIN(rc_cfg->under_shoot_pct, rc_cfg->over_shoot_pct);
+ const double size_factor =
+ (active_mbs < 500) ? 0.925 : ((active_mbs > 3000) ? 1.05 : 1.0);
+ const double speed_factor =
+ AOMMIN(1.02, (0.975 + (0.005 * cpi->oxcf.speed)));
// Update bpm correction factor based on previous GOP rate error.
twopass_update_bpm_factor(cpi, rate_err_tol);
@@ -345,8 +357,9 @@
// content at the given rate.
int q = find_qindex_by_rate_with_correction(
target_norm_bits_per_mb, cpi->common.seq_params->bit_depth,
- av_err_per_mb, cpi->ppi->twopass.bpm_factor, rc->best_quality,
- rc->worst_quality);
+ av_err_per_mb,
+ cpi->ppi->twopass.bpm_factor * speed_factor * size_factor,
+ rc->best_quality, rc->worst_quality);
// Restriction on active max q for constrained quality mode.
if (rc_cfg->mode == AOM_CQ) q = AOMMAX(q, rc_cfg->cq_level);
@@ -2481,6 +2494,7 @@
return;
}
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx && oxcf->pass == AOM_RC_THIRD_PASS) {
int ret = define_gf_group_pass3(cpi, frame_params, is_final_pass);
if (ret == 0) return;
@@ -2488,6 +2502,7 @@
av1_free_thirdpass_ctx(cpi->third_pass_ctx);
cpi->third_pass_ctx = NULL;
}
+#endif // CONFIG_THREE_PASS
// correct frames_to_key when lookahead queue is emptying
if (cpi->ppi->lap_enabled) {
@@ -2588,6 +2603,7 @@
gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE);
}
+#if CONFIG_THREE_PASS
/*!\brief Define a GF group for the third apss.
*
* \ingroup gf_group_algo
@@ -2660,6 +2676,7 @@
frame_params->show_frame = cpi->third_pass_ctx->frame_info[0].is_show_frame;
return 0;
}
+#endif // CONFIG_THREE_PASS
// #define FIXED_ARF_BITS
#ifdef FIXED_ARF_BITS
@@ -3851,6 +3868,7 @@
}
int need_gf_len = 1;
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx && oxcf->pass == AOM_RC_THIRD_PASS) {
// set up bitstream to read
if (!cpi->third_pass_ctx->input_file_name && oxcf->two_pass_output) {
@@ -3884,6 +3902,7 @@
p_rc->gf_intervals[0] = cpi->third_pass_ctx->gop_info.gf_length;
need_gf_len = 0;
}
+#endif // CONFIG_THREE_PASS
if (need_gf_len) {
// If we cannot obtain GF group length from second_pass_file
@@ -3943,9 +3962,11 @@
define_gf_group(cpi, frame_params, 1);
+#if CONFIG_THREE_PASS
// write gop info if needed for third pass. Per-frame info is written after
// each frame is encoded.
av1_write_second_pass_gop_info(cpi);
+#endif // CONFIG_THREE_PASS
av1_tf_info_filtering(&cpi->ppi->tf_info, cpi, gf_group);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 0c6a008..5aa38a3 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -256,7 +256,7 @@
(int)((uint64_t)bpm * mbs) >> BPER_MB_NORMBITS);
}
-int av1_rc_clamp_pframe_target_size(const AV1_COMP *const cpi, int64_t target,
+static int clamp_pframe_target_size(const AV1_COMP *const cpi, int64_t target,
FRAME_UPDATE_TYPE frame_update_type) {
const RATE_CONTROL *rc = &cpi->rc;
const RateControlCfg *const rc_cfg = &cpi->oxcf.rc_cfg;
@@ -285,7 +285,7 @@
return (int)target;
}
-int av1_rc_clamp_iframe_target_size(const AV1_COMP *const cpi, int64_t target) {
+static int clamp_iframe_target_size(const AV1_COMP *const cpi, int64_t target) {
const RATE_CONTROL *rc = &cpi->rc;
const RateControlCfg *const rc_cfg = &cpi->oxcf.rc_cfg;
if (rc_cfg->max_intra_bitrate_pct) {
@@ -390,7 +390,10 @@
// 4K60: 12
}
-int av1_rc_get_default_max_gf_interval(double framerate, int min_gf_interval) {
+// Note get_default_max_gf_interval() requires the min_gf_interval to
+// be passed in to ensure that the max_gf_interval returned is at least as bis
+// as that.
+static int get_default_max_gf_interval(double framerate, int min_gf_interval) {
int interval = AOMMIN(MAX_GF_INTERVAL, (int)(framerate * 0.75));
interval += (interval & 0x01); // Round to even value
interval = AOMMAX(MAX_GF_INTERVAL, interval);
@@ -410,7 +413,7 @@
oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height,
oxcf->input_cfg.init_framerate);
if (max_gf_interval == 0)
- max_gf_interval = av1_rc_get_default_max_gf_interval(
+ max_gf_interval = get_default_max_gf_interval(
oxcf->input_cfg.init_framerate, min_gf_interval);
p_rc->baseline_gf_interval = (min_gf_interval + max_gf_interval) / 2;
p_rc->this_key_frame_forced = 0;
@@ -468,7 +471,7 @@
oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height,
oxcf->input_cfg.init_framerate);
if (rc->max_gf_interval == 0)
- rc->max_gf_interval = av1_rc_get_default_max_gf_interval(
+ rc->max_gf_interval = get_default_max_gf_interval(
oxcf->input_cfg.init_framerate, rc->min_gf_interval);
rc->avg_frame_low_motion = 0;
@@ -2289,8 +2292,9 @@
}
// Target rate per SB64 (including partial SB64s.
- rc->sb64_target_rate =
- (int)(((int64_t)rc->this_frame_target << 12) / (width * height));
+ const int64_t sb64_target_rate =
+ ((int64_t)rc->this_frame_target << 12) / (width * height);
+ rc->sb64_target_rate = (int)AOMMIN(sb64_target_rate, INT_MAX);
}
static void update_alt_ref_frame_stats(AV1_COMP *cpi) {
@@ -2556,7 +2560,7 @@
return target_index - qindex;
}
-void av1_rc_set_gf_interval_range(const AV1_COMP *const cpi,
+static void set_gf_interval_range(const AV1_COMP *const cpi,
RATE_CONTROL *const rc) {
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
@@ -2573,8 +2577,8 @@
rc->min_gf_interval = av1_rc_get_default_min_gf_interval(
oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height, cpi->framerate);
if (rc->max_gf_interval == 0)
- rc->max_gf_interval = av1_rc_get_default_max_gf_interval(
- cpi->framerate, rc->min_gf_interval);
+ rc->max_gf_interval =
+ get_default_max_gf_interval(cpi->framerate, rc->min_gf_interval);
/*
* Extended max interval for genuinely static scenes like slide shows.
* The no.of.stats available in the case of LAP is limited,
@@ -2621,7 +2625,7 @@
rc->max_frame_bandwidth =
AOMMAX(AOMMAX((MBs * MAX_MB_RATE), MAXRATE_1080P), (int)vbr_max_bits);
- av1_rc_set_gf_interval_range(cpi, rc);
+ set_gf_interval_range(cpi, rc);
}
#define VBR_PCT_ADJUSTMENT_LIMIT 50
@@ -2732,14 +2736,14 @@
#else
target = rc->avg_frame_bandwidth;
#endif
- return av1_rc_clamp_pframe_target_size(cpi, target, frame_update_type);
+ return clamp_pframe_target_size(cpi, target, frame_update_type);
}
int av1_calc_iframe_target_size_one_pass_vbr(const AV1_COMP *const cpi) {
static const int kf_ratio = 25;
const RATE_CONTROL *rc = &cpi->rc;
const int64_t target = (int64_t)rc->avg_frame_bandwidth * kf_ratio;
- return av1_rc_clamp_iframe_target_size(cpi, target);
+ return clamp_iframe_target_size(cpi, target);
}
int av1_calc_pframe_target_size_one_pass_cbr(
@@ -2820,7 +2824,7 @@
}
target = ((int64_t)(16 + kf_boost) * rc->avg_frame_bandwidth) >> 4;
}
- return av1_rc_clamp_iframe_target_size(cpi, target);
+ return clamp_iframe_target_size(cpi, target);
}
static void set_golden_update(AV1_COMP *const cpi) {
@@ -3711,23 +3715,24 @@
svc->spatial_layer_id == 0
? 0
: svc->layer_context[svc->temporal_layer_id].is_key_frame;
- // If the user is setting the reference structure with
- // set_ref_frame_config and did not set any references, set the
- // frame type to Intra-only.
- if (cpi->ppi->rtc_ref.set_ref_frame_config) {
- int no_references_set = 1;
- for (int i = 0; i < INTER_REFS_PER_FRAME; i++) {
- if (cpi->ppi->rtc_ref.reference[i]) {
- no_references_set = 0;
- break;
- }
+ }
+ // If the user is setting the reference structure with
+ // set_ref_frame_config and did not set any references, set the
+ // frame type to Intra-only.
+ if (cpi->ppi->rtc_ref.set_ref_frame_config) {
+ int no_references_set = 1;
+ for (int i = 0; i < INTER_REFS_PER_FRAME; i++) {
+ if (cpi->ppi->rtc_ref.reference[i]) {
+ no_references_set = 0;
+ break;
}
- // Set to intra_only_frame if no references are set.
- // The stream can start decoding on INTRA_ONLY_FRAME so long as the
- // layer with the intra_only_frame doesn't signal a reference to a slot
- // that hasn't been set yet.
- if (no_references_set) *frame_type = INTRA_ONLY_FRAME;
}
+
+ // Set to intra_only_frame if no references are set.
+ // The stream can start decoding on INTRA_ONLY_FRAME so long as the
+ // layer with the intra_only_frame doesn't signal a reference to a slot
+ // that hasn't been set yet.
+ if (no_references_set) *frame_type = INTRA_ONLY_FRAME;
}
}
if (cpi->active_map.enabled && cpi->rc.percent_blocks_inactive == 100) {
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h
index 21c7568..1d159ae 100644
--- a/av1/encoder/ratectrl.h
+++ b/av1/encoder/ratectrl.h
@@ -590,10 +590,6 @@
void av1_rc_init_minq_luts(void);
int av1_rc_get_default_min_gf_interval(int width, int height, double framerate);
-// Note av1_rc_get_default_max_gf_interval() requires the min_gf_interval to
-// be passed in to ensure that the max_gf_interval returned is at least as bis
-// as that.
-int av1_rc_get_default_max_gf_interval(double framerate, int min_gf_interval);
// Generally at the high level, the following flow is expected
// to be enforced for rate control:
@@ -691,12 +687,6 @@
int qindex, double correction_factor,
int accurate_estimate);
-// Clamping utilities for bitrate targets for iframes and pframes.
-int av1_rc_clamp_iframe_target_size(const struct AV1_COMP *const cpi,
- int64_t target);
-int av1_rc_clamp_pframe_target_size(const struct AV1_COMP *const cpi,
- int64_t target, uint8_t frame_update_type);
-
// Find q_index corresponding to desired_q, within [best_qindex, worst_qindex].
// To be precise, 'q_index' is the smallest integer, for which the corresponding
// q >= desired_q.
@@ -717,9 +707,6 @@
void av1_rc_update_framerate(struct AV1_COMP *cpi, int width, int height);
-void av1_rc_set_gf_interval_range(const struct AV1_COMP *const cpi,
- RATE_CONTROL *const rc);
-
void av1_set_target_rate(struct AV1_COMP *cpi, int width, int height);
int av1_resize_one_pass_cbr(struct AV1_COMP *cpi);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 403d12a..e77dbc7 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -35,6 +35,7 @@
#include "av1/encoder/nonrd_opt.h"
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rd.h"
+#include "config/aom_config.h"
#define RD_THRESH_POW 1.25
@@ -319,6 +320,7 @@
}
}
+#if !CONFIG_REALTIME_ONLY
void av1_fill_lr_rates(ModeCosts *mode_costs, FRAME_CONTEXT *fc) {
av1_cost_tokens_from_cdf(mode_costs->switchable_restore_cost,
fc->switchable_restore_cdf, NULL);
@@ -327,6 +329,7 @@
av1_cost_tokens_from_cdf(mode_costs->sgrproj_restore_cost,
fc->sgrproj_restore_cdf, NULL);
}
+#endif // !CONFIG_REALTIME_ONLY
// Values are now correlated to quantizer.
static int sad_per_bit_lut_8[QINDEX_RANGE];
@@ -467,6 +470,7 @@
return adjust_qindex;
}
+#if !CONFIG_REALTIME_ONLY
int av1_get_adaptive_rdmult(const AV1_COMP *cpi, double beta) {
assert(beta > 0.0);
const AV1_COMMON *cm = &cpi->common;
@@ -485,6 +489,7 @@
is_stat_consumption_stage(cpi)) /
beta);
}
+#endif // !CONFIG_REALTIME_ONLY
static int compute_rd_thresh_factor(int qindex, aom_bit_depth_t bit_depth) {
double q;
@@ -936,114 +941,6 @@
return (sse_norm > 16.0);
}
-// Models distortion by sse using a logistic function on
-// l = log2(sse / q^2) as:
-// dbysse = 16 / (1 + k exp(l + c))
-static double get_dbysse_logistic(double l, double c, double k) {
- const double A = 16.0;
- const double dbysse = A / (1 + k * exp(l + c));
- return dbysse;
-}
-
-// Models rate using a clamped linear function on
-// l = log2(sse / q^2) as:
-// rate = max(0, a + b * l)
-static double get_rate_clamplinear(double l, double a, double b) {
- const double rate = a + b * l;
- return (rate < 0 ? 0 : rate);
-}
-
-static const uint8_t bsize_surffit_model_cat_lookup[BLOCK_SIZES_ALL] = {
- 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 0, 0, 2, 2, 4, 4
-};
-
-static const double surffit_rate_params[9][4] = {
- {
- 638.390212,
- 2.253108,
- 166.585650,
- -3.939401,
- },
- {
- 5.256905,
- 81.997240,
- -1.321771,
- 17.694216,
- },
- {
- -74.193045,
- 72.431868,
- -19.033152,
- 15.407276,
- },
- {
- 416.770113,
- 14.794188,
- 167.686830,
- -6.997756,
- },
- {
- 378.511276,
- 9.558376,
- 154.658843,
- -6.635663,
- },
- {
- 277.818787,
- 4.413180,
- 150.317637,
- -9.893038,
- },
- {
- 142.212132,
- 11.542038,
- 94.393964,
- -5.518517,
- },
- {
- 219.100256,
- 4.007421,
- 108.932852,
- -6.981310,
- },
- {
- 222.261971,
- 3.251049,
- 95.972916,
- -5.609789,
- },
-};
-
-static const double surffit_dist_params[7] = { 1.475844, 4.328362, -5.680233,
- -0.500994, 0.554585, 4.839478,
- -0.695837 };
-
-static void rate_surffit_model_params_lookup(BLOCK_SIZE bsize, double xm,
- double *rpar) {
- const int cat = bsize_surffit_model_cat_lookup[bsize];
- rpar[0] = surffit_rate_params[cat][0] + surffit_rate_params[cat][1] * xm;
- rpar[1] = surffit_rate_params[cat][2] + surffit_rate_params[cat][3] * xm;
-}
-
-static void dist_surffit_model_params_lookup(BLOCK_SIZE bsize, double xm,
- double *dpar) {
- (void)bsize;
- const double *params = surffit_dist_params;
- dpar[0] = params[0] + params[1] / (1 + exp((xm + params[2]) * params[3]));
- dpar[1] = params[4] + params[5] * exp(params[6] * xm);
-}
-
-void av1_model_rd_surffit(BLOCK_SIZE bsize, double sse_norm, double xm,
- double yl, double *rate_f, double *distbysse_f) {
- (void)sse_norm;
- double rpar[2], dpar[2];
- rate_surffit_model_params_lookup(bsize, xm, rpar);
- dist_surffit_model_params_lookup(bsize, xm, dpar);
-
- *rate_f = get_rate_clamplinear(yl, rpar[0], rpar[1]);
- *distbysse_f = get_dbysse_logistic(yl, dpar[0], dpar[1]);
-}
-
static const double interp_rgrid_curv[4][65] = {
{
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index a616e7e..d4db276 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -20,6 +20,7 @@
#include "av1/encoder/context_tree.h"
#include "av1/encoder/cost.h"
#include "av1/encoder/ratectrl.h"
+#include "config/aom_config.h"
#ifdef __cplusplus
extern "C" {
@@ -256,8 +257,6 @@
void av1_model_rd_curvfit(BLOCK_SIZE bsize, double sse_norm, double xqr,
double *rate_f, double *distbysse_f);
-void av1_model_rd_surffit(BLOCK_SIZE bsize, double sse_norm, double xm,
- double yl, double *rate_f, double *distbysse_f);
int av1_get_switchable_rate(const MACROBLOCK *x, const MACROBLOCKD *xd,
InterpFilter interp_filter, int dual_filter);
@@ -358,7 +357,9 @@
void av1_fill_mode_rates(AV1_COMMON *const cm, ModeCosts *mode_costs,
FRAME_CONTEXT *fc);
+#if !CONFIG_REALTIME_ONLY
void av1_fill_lr_rates(ModeCosts *mode_costs, FRAME_CONTEXT *fc);
+#endif
void av1_fill_coeff_costs(CoeffCosts *coeff_costs, FRAME_CONTEXT *fc,
const int num_planes);
@@ -368,7 +369,9 @@
void av1_fill_dv_costs(const nmv_context *ndvc, IntraBCMVCosts *dv_costs);
+#if !CONFIG_REALTIME_ONLY
int av1_get_adaptive_rdmult(const struct AV1_COMP *cpi, double beta);
+#endif
int av1_get_deltaq_offset(aom_bit_depth_t bit_depth, int qindex, double beta);
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index e9319b1..582d1be 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -13,8 +13,11 @@
#include <float.h>
#include <stdint.h>
-#include "av1/encoder/thirdpass.h"
#include "config/aom_config.h"
+
+#if CONFIG_THREE_PASS
+#include "av1/encoder/thirdpass.h"
+#endif
#include "config/aom_dsp_rtcd.h"
#include "config/aom_scale_rtcd.h"
@@ -538,8 +541,6 @@
const int bw = 4 << mi_size_wide_log2[bsize];
const int bh = 4 << mi_size_high_log2[bsize];
- int frame_offset = tpl_data->frame_idx - cpi->gf_frame_index;
-
int32_t best_intra_cost = INT32_MAX;
int32_t intra_cost;
PREDICTION_MODE best_mode = DC_PRED;
@@ -670,6 +671,9 @@
tpl_stats->intra_rate = rate_cost;
}
+#if CONFIG_THREE_PASS
+ const int frame_offset = tpl_data->frame_idx - cpi->gf_frame_index;
+
if (cpi->third_pass_ctx &&
frame_offset < cpi->third_pass_ctx->frame_info_count &&
tpl_data->frame_idx < gf_group->size) {
@@ -699,6 +703,7 @@
}
}
}
+#endif // CONFIG_THREE_PASS
// Motion compensated prediction
xd->mi[0]->ref_frame[0] = INTRA_FRAME;
@@ -771,6 +776,7 @@
}
}
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx &&
frame_offset < cpi->third_pass_ctx->frame_info_count &&
tpl_data->frame_idx < gf_group->size) {
@@ -788,6 +794,7 @@
center_mvs[0].mv = tp_mv;
}
}
+#endif // CONFIG_THREE_PASS
// Prune starting mvs
if (tpl_sf->prune_starting_mv && refmv_count > 1) {
@@ -866,6 +873,7 @@
int start_rf = 0;
int end_rf = 3;
if (!tpl_sf->allow_compound_pred) end_rf = 0;
+#if CONFIG_THREE_PASS
if (cpi->third_pass_ctx &&
frame_offset < cpi->third_pass_ctx->frame_info_count &&
tpl_data->frame_idx < gf_group->size) {
@@ -895,6 +903,7 @@
}
}
}
+#endif // CONFIG_THREE_PASS
xd->mi_row = mi_row;
xd->mi_col = mi_col;
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c
index e3fd129..48d5f12 100644
--- a/av1/encoder/tx_search.c
+++ b/av1/encoder/tx_search.c
@@ -2818,6 +2818,87 @@
}
#endif // !CONFIG_REALTIME_ONLY
+/*!\brief Transform type search for luma macroblock with fixed transform size.
+ *
+ * \ingroup transform_search
+ * Search for the best transform type and return the transform coefficients RD
+ * cost of current luma macroblock with the given uniform transform size.
+ *
+ * \param[in] x Pointer to structure holding the data for the
+ current encoding macroblock
+ * \param[in] cpi Top-level encoder structure
+ * \param[in] rd_stats Pointer to struct to keep track of the RD stats
+ * \param[in] ref_best_rd Best RD cost seen for this block so far
+ * \param[in] bs Size of the current macroblock
+ * \param[in] tx_size The given transform size
+ * \param[in] ftxs_mode Transform search mode specifying desired speed
+ and quality tradeoff
+ * \param[in] skip_trellis Binary flag indicating if trellis optimization
+ should be skipped
+ * \return An int64_t value that is the best RD cost found.
+ */
+static int64_t uniform_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
+ RD_STATS *rd_stats, int64_t ref_best_rd,
+ BLOCK_SIZE bs, TX_SIZE tx_size,
+ FAST_TX_SEARCH_MODE ftxs_mode,
+ int skip_trellis) {
+ assert(IMPLIES(is_rect_tx(tx_size), is_rect_tx_allowed_bsize(bs)));
+ MACROBLOCKD *const xd = &x->e_mbd;
+ MB_MODE_INFO *const mbmi = xd->mi[0];
+ const TxfmSearchParams *txfm_params = &x->txfm_search_params;
+ const ModeCosts *mode_costs = &x->mode_costs;
+ const int is_inter = is_inter_block(mbmi);
+ const int tx_select = txfm_params->tx_mode_search_type == TX_MODE_SELECT &&
+ block_signals_txsize(mbmi->bsize);
+ int tx_size_rate = 0;
+ if (tx_select) {
+ const int ctx = txfm_partition_context(
+ xd->above_txfm_context, xd->left_txfm_context, mbmi->bsize, tx_size);
+ tx_size_rate = is_inter ? mode_costs->txfm_partition_cost[ctx][0]
+ : tx_size_cost(x, bs, tx_size);
+ }
+ const int skip_ctx = av1_get_skip_txfm_context(xd);
+ const int no_skip_txfm_rate = mode_costs->skip_txfm_cost[skip_ctx][0];
+ const int skip_txfm_rate = mode_costs->skip_txfm_cost[skip_ctx][1];
+ const int64_t skip_txfm_rd =
+ is_inter ? RDCOST(x->rdmult, skip_txfm_rate, 0) : INT64_MAX;
+ const int64_t no_this_rd =
+ RDCOST(x->rdmult, no_skip_txfm_rate + tx_size_rate, 0);
+
+ mbmi->tx_size = tx_size;
+ av1_txfm_rd_in_plane(x, cpi, rd_stats, ref_best_rd,
+ AOMMIN(no_this_rd, skip_txfm_rd), AOM_PLANE_Y, bs,
+ tx_size, ftxs_mode, skip_trellis);
+ if (rd_stats->rate == INT_MAX) return INT64_MAX;
+
+ int64_t rd;
+ // rdstats->rate should include all the rate except skip/non-skip cost as the
+ // same is accounted in the caller functions after rd evaluation of all
+ // planes. However the decisions should be done after considering the
+ // skip/non-skip header cost
+ if (rd_stats->skip_txfm && is_inter) {
+ rd = RDCOST(x->rdmult, skip_txfm_rate, rd_stats->sse);
+ } else {
+ // Intra blocks are always signalled as non-skip
+ rd = RDCOST(x->rdmult, rd_stats->rate + no_skip_txfm_rate + tx_size_rate,
+ rd_stats->dist);
+ rd_stats->rate += tx_size_rate;
+ }
+ // Check if forcing the block to skip transform leads to smaller RD cost.
+ if (is_inter && !rd_stats->skip_txfm && !xd->lossless[mbmi->segment_id]) {
+ int64_t temp_skip_txfm_rd =
+ RDCOST(x->rdmult, skip_txfm_rate, rd_stats->sse);
+ if (temp_skip_txfm_rd <= rd) {
+ rd = temp_skip_txfm_rd;
+ rd_stats->rate = 0;
+ rd_stats->dist = rd_stats->sse;
+ rd_stats->skip_txfm = 1;
+ }
+ }
+
+ return rd;
+}
+
// Search for the best uniform transform size and type for current coding block.
static inline void choose_tx_size_type_from_rd(const AV1_COMP *const cpi,
MACROBLOCK *x,
@@ -2888,8 +2969,8 @@
cpi->sf.tx_sf.use_rd_based_breakout_for_intra_tx_search
? AOMMIN(ref_best_rd, best_rd)
: ref_best_rd;
- rd[depth] = av1_uniform_txfm_yrd(cpi, x, &this_rd_stats, rd_thresh, bs,
- tx_size, FTXS_NONE, skip_trellis);
+ rd[depth] = uniform_txfm_yrd(cpi, x, &this_rd_stats, rd_thresh, bs, tx_size,
+ FTXS_NONE, skip_trellis);
if (rd[depth] < best_rd) {
av1_copy_array(best_blk_skip, txfm_info->blk_skip, num_blks);
av1_copy_array(best_txk_type_map, xd->tx_type_map, num_blks);
@@ -3127,67 +3208,6 @@
return rd;
}
-int64_t av1_uniform_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
- RD_STATS *rd_stats, int64_t ref_best_rd,
- BLOCK_SIZE bs, TX_SIZE tx_size,
- FAST_TX_SEARCH_MODE ftxs_mode, int skip_trellis) {
- assert(IMPLIES(is_rect_tx(tx_size), is_rect_tx_allowed_bsize(bs)));
- MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = xd->mi[0];
- const TxfmSearchParams *txfm_params = &x->txfm_search_params;
- const ModeCosts *mode_costs = &x->mode_costs;
- const int is_inter = is_inter_block(mbmi);
- const int tx_select = txfm_params->tx_mode_search_type == TX_MODE_SELECT &&
- block_signals_txsize(mbmi->bsize);
- int tx_size_rate = 0;
- if (tx_select) {
- const int ctx = txfm_partition_context(
- xd->above_txfm_context, xd->left_txfm_context, mbmi->bsize, tx_size);
- tx_size_rate = is_inter ? mode_costs->txfm_partition_cost[ctx][0]
- : tx_size_cost(x, bs, tx_size);
- }
- const int skip_ctx = av1_get_skip_txfm_context(xd);
- const int no_skip_txfm_rate = mode_costs->skip_txfm_cost[skip_ctx][0];
- const int skip_txfm_rate = mode_costs->skip_txfm_cost[skip_ctx][1];
- const int64_t skip_txfm_rd =
- is_inter ? RDCOST(x->rdmult, skip_txfm_rate, 0) : INT64_MAX;
- const int64_t no_this_rd =
- RDCOST(x->rdmult, no_skip_txfm_rate + tx_size_rate, 0);
-
- mbmi->tx_size = tx_size;
- av1_txfm_rd_in_plane(x, cpi, rd_stats, ref_best_rd,
- AOMMIN(no_this_rd, skip_txfm_rd), AOM_PLANE_Y, bs,
- tx_size, ftxs_mode, skip_trellis);
- if (rd_stats->rate == INT_MAX) return INT64_MAX;
-
- int64_t rd;
- // rdstats->rate should include all the rate except skip/non-skip cost as the
- // same is accounted in the caller functions after rd evaluation of all
- // planes. However the decisions should be done after considering the
- // skip/non-skip header cost
- if (rd_stats->skip_txfm && is_inter) {
- rd = RDCOST(x->rdmult, skip_txfm_rate, rd_stats->sse);
- } else {
- // Intra blocks are always signalled as non-skip
- rd = RDCOST(x->rdmult, rd_stats->rate + no_skip_txfm_rate + tx_size_rate,
- rd_stats->dist);
- rd_stats->rate += tx_size_rate;
- }
- // Check if forcing the block to skip transform leads to smaller RD cost.
- if (is_inter && !rd_stats->skip_txfm && !xd->lossless[mbmi->segment_id]) {
- int64_t temp_skip_txfm_rd =
- RDCOST(x->rdmult, skip_txfm_rate, rd_stats->sse);
- if (temp_skip_txfm_rd <= rd) {
- rd = temp_skip_txfm_rd;
- rd_stats->rate = 0;
- rd_stats->dist = rd_stats->sse;
- rd_stats->skip_txfm = 1;
- }
- }
-
- return rd;
-}
-
// Search for the best transform type for a luma inter-predicted block, given
// the transform block partitions.
// This function is used only when some speed features are enabled.
diff --git a/av1/encoder/tx_search.h b/av1/encoder/tx_search.h
index 78efdb4..9181304 100644
--- a/av1/encoder/tx_search.h
+++ b/av1/encoder/tx_search.h
@@ -72,30 +72,6 @@
RD_STATS *rd_stats, int64_t ref_best_rd,
BLOCK_SIZE bs, TX_SIZE tx_size);
-/*!\brief Transform type search for luma macroblock with fixed transform size.
- *
- * \ingroup transform_search
- * Search for the best transform type and return the transform coefficients RD
- * cost of current luma macroblock with the given uniform transform size.
- *
- * \param[in] x Pointer to structure holding the data for the
- current encoding macroblock
- * \param[in] cpi Top-level encoder structure
- * \param[in] rd_stats Pointer to struct to keep track of the RD stats
- * \param[in] ref_best_rd Best RD cost seen for this block so far
- * \param[in] bs Size of the current macroblock
- * \param[in] tx_size The given transform size
- * \param[in] ftxs_mode Transform search mode specifying desired speed
- and quality tradeoff
- * \param[in] skip_trellis Binary flag indicating if trellis optimization
- should be skipped
- * \return An int64_t value that is the best RD cost found.
- */
-int64_t av1_uniform_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
- RD_STATS *rd_stats, int64_t ref_best_rd,
- BLOCK_SIZE bs, TX_SIZE tx_size,
- FAST_TX_SEARCH_MODE ftxs_mode, int skip_trellis);
-
/*!\brief Recursive transform size and type search.
*
* \ingroup transform_search
diff --git a/build/cmake/rtcd.pl b/build/cmake/rtcd.pl
index 5d889cb..464d198 100755
--- a/build/cmake/rtcd.pl
+++ b/build/cmake/rtcd.pl
@@ -264,13 +264,14 @@
}
sub common_bottom() {
+ my $include_guard = uc($opts{sym})."_H_";
print <<EOF;
#ifdef __cplusplus
} // extern "C"
#endif
-#endif
+#endif // ${include_guard}
EOF
}
diff --git a/build/cmake/version.pl b/build/cmake/version.pl
index 400107c..e611418 100755
--- a/build/cmake/version.pl
+++ b/build/cmake/version.pl
@@ -89,6 +89,8 @@
if (length($git_desc)) {
print << "EOF";
$lic_block
+#ifndef AOM_VERSION_H_
+#define AOM_VERSION_H_
#define VERSION_MAJOR $version_major
#define VERSION_MINOR $version_minor
#define VERSION_PATCH $version_patch
@@ -97,10 +99,13 @@
$version_packed
#define VERSION_STRING_NOSP \"$git_desc\"
#define VERSION_STRING \" $git_desc\"
+#endif // AOM_VERSION_H_
EOF
} else {
print << "EOF";
$lic_block
+#ifndef AOM_VERSION_H_
+#define AOM_VERSION_H_
#define VERSION_MAJOR $version_major
#define VERSION_MINOR $version_minor
#define VERSION_PATCH $version_patch
@@ -109,6 +114,7 @@
$version_packed
#define VERSION_STRING_NOSP \"v$version_string\"
#define VERSION_STRING \" v$version_string\"
+#endif // AOM_VERSION_H_
EOF
}
close($version_file);
diff --git a/test/av1_c_vs_simd_encode.sh b/test/av1_c_vs_simd_encode.sh
index a55db5e..4fc481a 100755
--- a/test/av1_c_vs_simd_encode.sh
+++ b/test/av1_c_vs_simd_encode.sh
@@ -299,7 +299,7 @@
mkdir -p $tmp_build_dir
cd $tmp_build_dir
- local cmake_common_args="-DCONFIG_EXCLUDE_SIMD_MISMATCH=1 \
+ local cmake_common_args="--fresh -DCONFIG_EXCLUDE_SIMD_MISMATCH=1 \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CCACHE=1 \
'-DCMAKE_C_FLAGS_RELEASE=-O3 -g' \
diff --git a/test/cdef_test.cc b/test/cdef_test.cc
index 7ce278c..772cc6f 100644
--- a/test/cdef_test.cc
+++ b/test/cdef_test.cc
@@ -488,6 +488,7 @@
};
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CDEFCopyRect8to16Test);
+#if CONFIG_AV1_HIGHBITDEPTH
using CDEFCopyRect16To16 = void (*)(uint16_t *dst, int dstride,
const uint16_t *src, int sstride, int width,
int height);
@@ -571,6 +572,7 @@
CDEFCopyRect16To16 ref_func_;
};
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CDEFCopyRect16to16Test);
+#endif // CONFIG_AV1_HIGHBITDEPTH
TEST_P(CDEFBlockTest, TestSIMDNoMismatch) {
test_cdef(bsize, 1, cdef, ref_cdef, boundary, depth);
@@ -608,9 +610,11 @@
test_copy_rect_8_to_16(test_func_, ref_func_);
}
+#if CONFIG_AV1_HIGHBITDEPTH
TEST_P(CDEFCopyRect16to16Test, TestSIMDNoMismatch) {
test_copy_rect_16_to_16(test_func_, ref_func_);
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
using std::make_tuple;
@@ -663,10 +667,12 @@
::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
&cdef_copy_rect8_8bit_to_16bit_ssse3)));
+#if CONFIG_AV1_HIGHBITDEPTH
INSTANTIATE_TEST_SUITE_P(
SSSE3, CDEFCopyRect16to16Test,
::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
&cdef_copy_rect8_16bit_to_16bit_ssse3)));
+#endif // CONFIG_AV1_HIGHBITDEPTH
#endif
#if HAVE_SSE4_1
@@ -707,10 +713,12 @@
::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
&cdef_copy_rect8_8bit_to_16bit_sse4_1)));
+#if CONFIG_AV1_HIGHBITDEPTH
INSTANTIATE_TEST_SUITE_P(
SSE4_1, CDEFCopyRect16to16Test,
::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
&cdef_copy_rect8_16bit_to_16bit_sse4_1)));
+#endif // CONFIG_AV1_HIGHBITDEPTH
#endif
#if HAVE_AVX2
@@ -750,10 +758,12 @@
::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
&cdef_copy_rect8_8bit_to_16bit_avx2)));
+#if CONFIG_AV1_HIGHBITDEPTH
INSTANTIATE_TEST_SUITE_P(
AVX2, CDEFCopyRect16to16Test,
::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
&cdef_copy_rect8_16bit_to_16bit_avx2)));
+#endif // CONFIG_AV1_HIGHBITDEPTH
#endif
#if HAVE_NEON
@@ -793,10 +803,12 @@
::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
&cdef_copy_rect8_8bit_to_16bit_neon)));
+#if CONFIG_AV1_HIGHBITDEPTH
INSTANTIATE_TEST_SUITE_P(
NEON, CDEFCopyRect16to16Test,
::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
&cdef_copy_rect8_16bit_to_16bit_neon)));
+#endif // CONFIG_AV1_HIGHBITDEPTH
#endif
// Test speed for all supported architectures
diff --git a/test/datarate_test.cc b/test/datarate_test.cc
index a66c90e..e1d6a1d 100644
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -110,7 +110,7 @@
<< " The datarate for the file is lower than target by too much!";
ASSERT_LE(effective_datarate_, cfg_.rc_target_bitrate * 1.19)
<< " The datarate for the file is greater than target by too much!";
- ASSERT_LE(num_spikes_, 8);
+ ASSERT_LE(num_spikes_, 10);
ASSERT_LT(num_spikes_high_, 1);
}
diff --git a/test/loopfilter_control_test.cc b/test/loopfilter_control_test.cc
index 04afa5b..30f04b2 100644
--- a/test/loopfilter_control_test.cc
+++ b/test/loopfilter_control_test.cc
@@ -31,20 +31,20 @@
std::unordered_map<std::string,
std::unordered_map<int, std::unordered_map<int, double>>>
kPsnrThreshold = { { "park_joy_90p_8_420.y4m",
- { { 0, { { 0, 35.0 }, { 3, 35.8 } } },
- { 1, { { 0, 35.1 }, { 3, 35.9 } } },
- { 2, { { 0, 35.1 }, { 3, 36.1 } } },
- { 3, { { 0, 35.1 }, { 3, 36.1 } } } } },
+ { { 0, { { 0, 33.0 }, { 3, 33.0 } } },
+ { 1, { { 0, 33.0 }, { 3, 33.0 } } },
+ { 2, { { 0, 33.0 }, { 3, 33.0 } } },
+ { 3, { { 0, 33.0 }, { 3, 33.0 } } } } },
{ "paris_352_288_30.y4m",
- { { 0, { { 0, 35.40 }, { 3, 36.0 } } },
- { 1, { { 0, 35.50 }, { 3, 36.0 } } },
- { 2, { { 0, 35.50 }, { 3, 36.0 } } },
- { 3, { { 0, 35.50 }, { 3, 36.0 } } } } },
+ { { 0, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 1, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 2, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 3, { { 0, 33.0 }, { 3, 34.0 } } } } },
{ "niklas_1280_720_30.y4m",
- { { 0, { { 0, 33.20 }, { 3, 32.90 } } },
- { 1, { { 0, 33.57 }, { 3, 33.22 } } },
- { 2, { { 0, 33.57 }, { 3, 33.22 } } },
- { 3, { { 0, 33.45 }, { 3, 33.10 } } } } } };
+ { { 0, { { 0, 31.0 }, { 3, 30.0 } } },
+ { 1, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 2, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 3, { { 0, 31.0 }, { 3, 31.0 } } } } } };
typedef struct {
const char *filename;
diff --git a/test/monochrome_test.cc b/test/monochrome_test.cc
index c157275..ca180f6 100644
--- a/test/monochrome_test.cc
+++ b/test/monochrome_test.cc
@@ -31,7 +31,7 @@
// kPsnrFluctuation represents the maximum allowed psnr fluctuation w.r.t first
// frame. The indices correspond to one/two-pass, allintra and realtime
// encoding modes.
-const double kPsnrFluctuation[3] = { 2.5, 0.3, 16.0 };
+const double kPsnrFluctuation[3] = { 2.5, 0.3, 17.0 };
class MonochromeTest
: public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
@@ -183,6 +183,9 @@
cfg_.monochrome = 1;
// Run at low bitrate.
cfg_.rc_target_bitrate = 40;
+ cfg_.rc_buf_sz = 6000;
+ cfg_.rc_buf_initial_sz = 4000;
+ cfg_.rc_buf_optimal_sz = 5000;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
// Check that the chroma planes are equal across all frames
diff --git a/test/rt_end_to_end_test.cc b/test/rt_end_to_end_test.cc
index 1e9238c..dced915 100644
--- a/test/rt_end_to_end_test.cc
+++ b/test/rt_end_to_end_test.cc
@@ -32,33 +32,33 @@
std::unordered_map<std::string,
std::unordered_map<int, std::unordered_map<int, double>>>
kPsnrThreshold = { { "park_joy_90p_8_420.y4m",
- { { 5, { { 0, 35.4 }, { 3, 36.3 } } },
- { 6, { { 0, 35.3 }, { 3, 36.2 } } },
- { 7, { { 0, 34.9 }, { 3, 35.8 } } },
- { 8, { { 0, 35.0 }, { 3, 35.8 } } },
- { 9, { { 0, 34.9 }, { 3, 35.5 } } },
- { 10, { { 0, 34.7 }, { 3, 35.3 } } } } },
+ { { 5, { { 0, 34.0 }, { 3, 35.0 } } },
+ { 6, { { 0, 34.0 }, { 3, 35.0 } } },
+ { 7, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 8, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 9, { { 0, 33.0 }, { 3, 34.0 } } },
+ { 10, { { 0, 33.0 }, { 3, 34.0 } } } } },
{ "paris_352_288_30.y4m",
- { { 5, { { 0, 36.2 }, { 3, 36.7 } } },
- { 6, { { 0, 36.1 }, { 3, 36.48 } } },
- { 7, { { 0, 35.5 }, { 3, 36.0 } } },
- { 8, { { 0, 35.8 }, { 3, 36.4 } } },
- { 9, { { 0, 35.5 }, { 3, 36.0 } } },
- { 10, { { 0, 35.3 }, { 3, 35.9 } } } } },
+ { { 5, { { 0, 35.0 }, { 3, 35.0 } } },
+ { 6, { { 0, 35.0 }, { 3, 35.0 } } },
+ { 7, { { 0, 34.0 }, { 3, 34.0 } } },
+ { 8, { { 0, 34.0 }, { 3, 35.0 } } },
+ { 9, { { 0, 34.0 }, { 3, 34.0 } } },
+ { 10, { { 0, 34.0 }, { 3, 34.0 } } } } },
{ "niklas_1280_720_30.y4m",
- { { 5, { { 0, 34.4 }, { 3, 34.2 } } },
- { 6, { { 0, 34.1 }, { 3, 34.0 } } },
- { 7, { { 0, 33.5 }, { 3, 33.1 } } },
- { 8, { { 0, 33.3 }, { 3, 33.3 } } },
- { 9, { { 0, 33.3 }, { 3, 33.3 } } },
- { 10, { { 0, 33.1 }, { 3, 33.1 } } } } },
+ { { 5, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 6, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 7, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 8, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 9, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 10, { { 0, 31.0 }, { 3, 31.0 } } } } },
{ "hantro_collage_w352h288_nv12.yuv",
- { { 5, { { 0, 34.4 }, { 3, 34.2 } } },
- { 6, { { 0, 34.1 }, { 3, 34.1 } } },
- { 7, { { 0, 33.6 }, { 3, 33.6 } } },
- { 8, { { 0, 33.3 }, { 3, 33.3 } } },
- { 9, { { 0, 33.3 }, { 3, 33.3 } } },
- { 10, { { 0, 33.1 }, { 3, 33.1 } } } } } };
+ { { 5, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 6, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 7, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 8, { { 0, 32.0 }, { 3, 32.0 } } },
+ { 9, { { 0, 31.0 }, { 3, 31.0 } } },
+ { 10, { { 0, 31.0 }, { 3, 31.0 } } } } } };
typedef struct {
const char *filename;
diff --git a/test/svc_datarate_test.cc b/test/svc_datarate_test.cc
index 7da2160..a1b7136 100644
--- a/test/svc_datarate_test.cc
+++ b/test/svc_datarate_test.cc
@@ -86,6 +86,7 @@
comp_pred_ = 0;
dynamic_enable_disable_mode_ = 0;
intra_only_ = 0;
+ intra_only_single_layer_ = false;
frame_to_start_decoding_ = 0;
layer_to_decode_ = 0;
frame_sync_ = 0;
@@ -675,9 +676,20 @@
// Always reference LAST.
ref_frame_config->reference[0] = 1;
if (number_temporal_layers_ == 1 && number_spatial_layers_ == 1) {
+ layer_id->temporal_layer_id = 0;
ref_frame_config->refresh[0] = 1;
if (rps_mode)
ref_config_rps(ref_frame_config, frame_cnt, rps_recovery_frame);
+ if (intra_only_single_layer_) {
+ // This repros the crash in Bug: 363016123.
+ ref_frame_config->ref_idx[0] = 0;
+ ref_frame_config->ref_idx[3] = 1;
+ ref_frame_config->ref_idx[6] = 2;
+ if (frame_cnt == 1) {
+ for (int i = 0; i < INTER_REFS_PER_FRAME; i++)
+ ref_frame_config->reference[i] = 0;
+ }
+ }
}
if (number_temporal_layers_ == 2 && number_spatial_layers_ == 1) {
// 2-temporal layer.
@@ -1369,6 +1381,32 @@
}
}
+ virtual void BasicRateTargetingSVC1TL1SLIntraOnlyTest() {
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_buf_optimal_sz = 500;
+ cfg_.rc_buf_sz = 1000;
+ cfg_.rc_dropframe_thresh = 0;
+ cfg_.rc_min_quantizer = 0;
+ cfg_.rc_max_quantizer = 63;
+ cfg_.rc_end_usage = AOM_CBR;
+ cfg_.g_lag_in_frames = 0;
+ cfg_.g_error_resilient = 0;
+
+ ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, 300);
+ const int bitrate_array[2] = { 300, 600 };
+ cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
+ ResetModel();
+ intra_only_single_layer_ = true;
+ number_temporal_layers_ = 1;
+ number_spatial_layers_ = 1;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(effective_datarate_tl[0], cfg_.rc_target_bitrate * 0.80)
+ << " The datarate for the file is lower than target by too much!";
+ ASSERT_LE(effective_datarate_tl[0], cfg_.rc_target_bitrate * 1.60)
+ << " The datarate for the file is greater than target by too much!";
+ }
+
virtual void BasicRateTargetingSVC1TL3SLTest() {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
@@ -2442,6 +2480,7 @@
int comp_pred_;
int dynamic_enable_disable_mode_;
int intra_only_;
+ int intra_only_single_layer_;
unsigned int frame_to_start_decoding_;
unsigned int layer_to_decode_;
unsigned int frame_sync_;
@@ -2532,6 +2571,12 @@
BasicRateTargetingSVC1TL2SLIntraOnlyTest();
}
+// Check basic rate targeting for CBR, for 1 spatial layers, 1 temporal,
+// with Intra-only frame (frame with no references) inserted in the stream.
+TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL1SLIntraOnly) {
+ BasicRateTargetingSVC1TL1SLIntraOnlyTest();
+}
+
// Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal.
TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SL) {
BasicRateTargetingSVC1TL3SLTest();
diff --git a/test/test.cmake b/test/test.cmake
index 68caf0c..7f0123e 100644
--- a/test/test.cmake
+++ b/test/test.cmake
@@ -282,6 +282,7 @@
"${AOM_ROOT}/test/altref_test.cc"
"${AOM_ROOT}/test/av1_encoder_parms_get_to_decoder.cc"
"${AOM_ROOT}/test/av1_ext_tile_test.cc"
+ "${AOM_ROOT}/test/binary_codes_test.cc"
"${AOM_ROOT}/test/cnn_test.cc"
"${AOM_ROOT}/test/decode_multithreaded_test.cc"
"${AOM_ROOT}/test/error_resilience_test.cc"
diff --git a/test/variance_test.cc b/test/variance_test.cc
index 6f98ae4..c61c12c 100644
--- a/test/variance_test.cc
+++ b/test/variance_test.cc
@@ -89,14 +89,6 @@
}
}
-static unsigned int mb_ss_ref(const int16_t *src) {
- unsigned int res = 0;
- for (int i = 0; i < 256; ++i) {
- res += src[i] * src[i];
- }
- return res;
-}
-
/* Note:
* Our codebase calculates the "diff" value in the variance algorithm by
* (src - ref).
@@ -344,6 +336,7 @@
////////////////////////////////////////////////////////////////////////////////
+#if !CONFIG_REALTIME_ONLY
class SumOfSquaresTest : public ::testing::TestWithParam<SumOfSquaresFunction> {
public:
SumOfSquaresTest() : func_(GetParam()) {}
@@ -370,6 +363,14 @@
}
}
+unsigned int mb_ss_ref(const int16_t *src) {
+ unsigned int res = 0;
+ for (int i = 0; i < 256; ++i) {
+ res += src[i] * src[i];
+ }
+ return res;
+}
+
void SumOfSquaresTest::RefTest() {
int16_t mem[256];
for (int i = 0; i < 100; ++i) {
@@ -383,6 +384,7 @@
EXPECT_EQ(expected, res);
}
}
+#endif // !CONFIG_REALTIME_ONLY
////////////////////////////////////////////////////////////////////////////////
// Encapsulating struct to store the function to test along with
@@ -1729,8 +1731,10 @@
TEST_P(GetSseSum16x16DualTest, MinSseSum) { MinTestSseSumDual(); }
TEST_P(GetSseSum16x16DualTest, MaxMseSum) { MaxTestSseSumDual(); }
TEST_P(GetSseSum16x16DualTest, DISABLED_Speed) { SseSum_SpeedTestDual(); }
+#if !CONFIG_REALTIME_ONLY
TEST_P(SumOfSquaresTest, Const) { ConstTest(); }
TEST_P(SumOfSquaresTest, Ref) { RefTest(); }
+#endif // !CONFIG_REALTIME_ONLY
TEST_P(AvxSubpelVarianceTest, Ref) { RefTest(); }
TEST_P(AvxSubpelVarianceTest, ExtremeRef) { ExtremeRefTest(); }
TEST_P(AvxSubpelVarianceTest, DISABLED_Speed) { SpeedTest(); }
@@ -1756,8 +1760,10 @@
Mse16xHParams(2, 3, &aom_mse_16xh_16bit_c, 8),
Mse16xHParams(2, 2, &aom_mse_16xh_16bit_c, 8)));
+#if !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(C, SumOfSquaresTest,
::testing::Values(aom_get_mb_ss_c));
+#endif // !CONFIG_REALTIME_ONLY
typedef TestParams<VarianceMxNFunc> MseParams;
INSTANTIATE_TEST_SUITE_P(C, AvxMseTest,
@@ -2729,8 +2735,10 @@
Mse16xHParams(2, 3, &aom_mse_16xh_16bit_sse2, 8),
Mse16xHParams(2, 2, &aom_mse_16xh_16bit_sse2, 8)));
+#if !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(SSE2, SumOfSquaresTest,
::testing::Values(aom_get_mb_ss_sse2));
+#endif // !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(SSE2, AvxMseTest,
::testing::Values(MseParams(4, 4, &aom_mse16x16_sse2),
@@ -3411,8 +3419,10 @@
Mse16xHParams(2, 3, &aom_mse_16xh_16bit_neon, 8),
Mse16xHParams(2, 2, &aom_mse_16xh_16bit_neon, 8)));
+#if !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(NEON, SumOfSquaresTest,
::testing::Values(aom_get_mb_ss_neon));
+#endif // !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(NEON, AvxMseTest,
::testing::Values(MseParams(3, 3, &aom_mse8x8_neon),