2015-08-06 05:00:31 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-08-13 19:25:39 +03:00
|
|
|
#ifndef VP10_ENCODER_AQ_CYCLICREFRESH_H_
|
|
|
|
#define VP10_ENCODER_AQ_CYCLICREFRESH_H_
|
2015-08-06 05:00:31 +03:00
|
|
|
|
2015-08-07 07:14:07 +03:00
|
|
|
#include "vp10/common/blockd.h"
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// The segment ids used in cyclic refresh: from base (no boost) to increasing
|
|
|
|
// boost (higher delta-qp).
|
|
|
|
#define CR_SEGMENT_ID_BASE 0
|
|
|
|
#define CR_SEGMENT_ID_BOOST1 1
|
|
|
|
#define CR_SEGMENT_ID_BOOST2 2
|
|
|
|
|
|
|
|
// Maximum rate target ratio for setting segment delta-qp.
|
|
|
|
#define CR_MAX_RATE_TARGET_RATIO 4.0
|
|
|
|
|
2015-08-13 19:42:27 +03:00
|
|
|
struct VP10_COMP;
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
struct CYCLIC_REFRESH;
|
|
|
|
typedef struct CYCLIC_REFRESH CYCLIC_REFRESH;
|
|
|
|
|
|
|
|
CYCLIC_REFRESH *vp10_cyclic_refresh_alloc(int mi_rows, int mi_cols);
|
|
|
|
|
|
|
|
void vp10_cyclic_refresh_free(CYCLIC_REFRESH *cr);
|
|
|
|
|
|
|
|
// Estimate the bits, incorporating the delta-q from segment 1, after encoding
|
|
|
|
// the frame.
|
2015-08-13 19:42:27 +03:00
|
|
|
int vp10_cyclic_refresh_estimate_bits_at_q(const struct VP10_COMP *cpi,
|
2015-08-06 05:00:31 +03:00
|
|
|
double correction_factor);
|
|
|
|
|
|
|
|
// Estimate the bits per mb, for a given q = i and a corresponding delta-q
|
|
|
|
// (for segment 1), prior to encoding the frame.
|
2015-08-13 19:42:27 +03:00
|
|
|
int vp10_cyclic_refresh_rc_bits_per_mb(const struct VP10_COMP *cpi, int i,
|
2015-08-06 05:00:31 +03:00
|
|
|
double correction_factor);
|
|
|
|
|
|
|
|
// Prior to coding a given prediction block, of size bsize at (mi_row, mi_col),
|
|
|
|
// check if we should reset the segment_id, and update the cyclic_refresh map
|
|
|
|
// and segmentation map.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_update_segment(struct VP10_COMP *const cpi,
|
2015-08-06 05:00:31 +03:00
|
|
|
MB_MODE_INFO *const mbmi,
|
|
|
|
int mi_row, int mi_col, BLOCK_SIZE bsize,
|
|
|
|
int64_t rate, int64_t dist, int skip);
|
|
|
|
|
|
|
|
// Update the segmentation map, and related quantities: cyclic refresh map,
|
|
|
|
// refresh sb_index, and target number of blocks to be refreshed.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_update__map(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
// Update the actual number of blocks that were applied the segment delta q.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_postencode(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
2015-08-28 01:11:38 +03:00
|
|
|
// Set golden frame update interval, for 1 pass CBR mode.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_set_golden_update(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
// Check if we should not update golden reference, based on past refresh stats.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_check_golden_update(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
// Set/update global/frame level refresh parameters.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_update_parameters(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
// Setup cyclic background refresh: set delta q and segmentation map.
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_setup(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
int vp10_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
|
|
|
|
|
2015-08-13 19:42:27 +03:00
|
|
|
void vp10_cyclic_refresh_reset_resize(struct VP10_COMP *const cpi);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
static INLINE int cyclic_refresh_segment_id_boosted(int segment_id) {
|
|
|
|
return segment_id == CR_SEGMENT_ID_BOOST1 ||
|
|
|
|
segment_id == CR_SEGMENT_ID_BOOST2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE int cyclic_refresh_segment_id(int segment_id) {
|
|
|
|
if (segment_id == CR_SEGMENT_ID_BOOST1)
|
|
|
|
return CR_SEGMENT_ID_BOOST1;
|
|
|
|
else if (segment_id == CR_SEGMENT_ID_BOOST2)
|
|
|
|
return CR_SEGMENT_ID_BOOST2;
|
|
|
|
else
|
|
|
|
return CR_SEGMENT_ID_BASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2015-08-13 19:25:39 +03:00
|
|
|
#endif // VP10_ENCODER_AQ_CYCLICREFRESH_H_
|