// Constants and Macros used by all idct/dct functions
#define DCT_CONST_BITS 14
#define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1))
-// Constants are 16384 * cos(kPi/64) where k = 1 to 31.
-// Note: sin(kPi/64) = cos((32-k)Pi/64)
+// Constants are round(16384 * cos(k*Pi/64)) where k = 1 to 31.
+// Note: sin(k*Pi/64) = cos((32-k)*Pi/64)
static const int cospi_1_64 = 16364;
static const int cospi_2_64 = 16305;
static const int cospi_3_64 = 16207;
temp_in[j] = out[j * 8 + i];
idct8_1d(temp_in, temp_out);
for (j = 0; j < 8; ++j)
- output[j * short_pitch + i] = (temp_out[j] + 16) >> 5;
- }
+ output[j * short_pitch + i] = (temp_out[j] + 16) >> 5;
+ }
}
#if CONFIG_INTHT4X4
temp_in[j] = out[j * 8 + i];
idct8_1d(temp_in, temp_out);
for (j = 0; j < 8; ++j)
- output[j * short_pitch + i] = (temp_out[j] + 16) >> 5;
- }
+ output[j * short_pitch + i] = (temp_out[j] + 16) >> 5;
+ }
}
void vp9_short_idct1_8x8_c(int16_t *input, int16_t *output) {
- int tmp;
- int16_t out;
- tmp = input[0] * cospi_16_64;
- out = dct_const_round_shift(tmp);
- tmp = out * cospi_16_64;
- out = dct_const_round_shift(tmp);
- *output = (out + 16) >> 5;
+ int16_t out = dct_const_round_shift(input[0] * cospi_16_64);
+ out = dct_const_round_shift(out * cospi_16_64);
+ output[0] = (out + 16) >> 5;
}
void idct16_1d(int16_t *input, int16_t *output) {
temp_in[j] = out[j * 16 + i];
idct16_1d(temp_in, temp_out);
for (j = 0; j < 16; ++j)
- output[j * 16 + i] = (temp_out[j] + 32) >> 6;
- }
+ output[j * 16 + i] = (temp_out[j] + 32) >> 6;
+ }
}
#if CONFIG_INTHT16X16
}
void vp9_short_idct1_32x32_c(int16_t *input, int16_t *output) {
- int tmp;
- int16_t out;
- tmp = input[0] * cospi_16_64;
- out = dct_const_round_shift(tmp);
- tmp = out * cospi_16_64;
- out = dct_const_round_shift(tmp);
- *output = (out + 32) >> 6;
+ int16_t out = dct_const_round_shift(input[0] * cospi_16_64);
+ out = dct_const_round_shift(out * cospi_16_64);
+ output[0] = (out + 32) >> 6;
}
#include "vp9/common/vp9_textblit.h"
+static const int font[] = {
+ 0x0, 0x5C00, 0x8020, 0xAFABEA, 0xD7EC0, 0x1111111, 0x1855740, 0x18000,
+ 0x45C0, 0x74400, 0x51140, 0x23880, 0xC4000, 0x21080, 0x80000, 0x111110,
+ 0xE9D72E, 0x87E40, 0x12AD732, 0xAAD62A, 0x4F94C4, 0x4D6B7, 0x456AA,
+ 0x3E8423, 0xAAD6AA, 0xAAD6A2, 0x2800, 0x2A00, 0x8A880, 0x52940, 0x22A20,
+ 0x15422, 0x6AD62E, 0x1E4A53E, 0xAAD6BF, 0x8C62E, 0xE8C63F, 0x118D6BF,
+ 0x1094BF, 0xCAC62E, 0x1F2109F, 0x118FE31, 0xF8C628, 0x8A89F, 0x108421F,
+ 0x1F1105F, 0x1F4105F, 0xE8C62E, 0x2294BF, 0x164C62E, 0x12694BF, 0x8AD6A2,
+ 0x10FC21, 0x1F8421F, 0x744107, 0xF8220F, 0x1151151, 0x117041, 0x119D731,
+ 0x47E0, 0x1041041, 0xFC400, 0x10440, 0x1084210, 0x820
+};
+
+static void plot(int x, int y, unsigned char *image, int pitch) {
+ image[x + y * pitch] ^= 255;
+}
+
void vp9_blit_text(const char *msg, unsigned char *address, const int pitch) {
int letter_bitmap;
unsigned char *output_pos = address;
- int colpos;
- const int font[] = {
- 0x0, 0x5C00, 0x8020, 0xAFABEA, 0xD7EC0, 0x1111111, 0x1855740, 0x18000,
- 0x45C0, 0x74400, 0x51140, 0x23880, 0xC4000, 0x21080, 0x80000, 0x111110,
- 0xE9D72E, 0x87E40, 0x12AD732, 0xAAD62A, 0x4F94C4, 0x4D6B7, 0x456AA,
- 0x3E8423, 0xAAD6AA, 0xAAD6A2, 0x2800, 0x2A00, 0x8A880, 0x52940, 0x22A20,
- 0x15422, 0x6AD62E, 0x1E4A53E, 0xAAD6BF, 0x8C62E, 0xE8C63F, 0x118D6BF,
- 0x1094BF, 0xCAC62E, 0x1F2109F, 0x118FE31, 0xF8C628, 0x8A89F, 0x108421F,
- 0x1F1105F, 0x1F4105F, 0xE8C62E, 0x2294BF, 0x164C62E, 0x12694BF, 0x8AD6A2,
- 0x10FC21, 0x1F8421F, 0x744107, 0xF8220F, 0x1151151, 0x117041, 0x119D731,
- 0x47E0, 0x1041041, 0xFC400, 0x10440, 0x1084210, 0x820
- };
- colpos = 0;
+ int colpos = 0;
while (msg[colpos] != 0) {
char letter = msg[colpos];
}
}
-static void plot(const int x, const int y, unsigned char *image, const int pitch) {
- image [x + y * pitch] ^= 255;
-}
+
/* Bresenham line algorithm */
-void vp9_blit_line(int x0, int x1, int y0, int y1, unsigned char *image, const int pitch) {
+void vp9_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
+ int pitch) {
int steep = abs(y1 - y0) > abs(x1 - x0);
int deltax, deltay;
int error, ystep, y, x;
#ifndef VP9_COMMON_VP9_TEXTBLIT_H_
#define VP9_COMMON_VP9_TEXTBLIT_H_
-extern void vp9_blit_text(const char *msg, unsigned char *address,
- const int pitch);
-extern void vp9_blit_line(int x0, int x1, int y0, int y1,
- unsigned char *image, const int pitch);
+void vp9_blit_text(const char *msg, unsigned char *address, int pitch);
+
+void vp9_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
+ int pitch);
#endif // VP9_COMMON_VP9_TEXTBLIT_H_
#define MIN_TILE_WIDTH 256
#define MAX_TILE_WIDTH 4096
-extern void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx);
+void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx);
-extern void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx);
+void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx);
-extern void vp9_get_tile_n_bits(VP9_COMMON *cm, int *min_log2_n_tiles,
- int *delta_log2_n_tiles);
+void vp9_get_tile_n_bits(VP9_COMMON *cm, int *min_log2_n_tiles,
+ int *delta_log2_n_tiles);
#endif // VP9_COMMON_VP9_TILE_COMMON_H_
static int get_unsigned_bits(unsigned num_values) {
int cat = 0;
- if ((num_values--) <= 1) return 0;
+ if (num_values <= 1)
+ return 0;
+ num_values--;
while (num_values > 0) {
cat++;
num_values >>= 1;
}
int vp9_inv_recenter_nonneg(int v, int m) {
- if (v > (m << 1)) return v;
- else if ((v & 1) == 0) return (v >> 1) + m;
- else return m - ((v + 1) >> 1);
+ if (v > (m << 1))
+ return v;
+ else if ((v & 1) == 0)
+ return (v >> 1) + m;
+ else
+ return m - ((v + 1) >> 1);
}
int vp9_decode_uniform(BOOL_DECODER *br, int n) {
int vp9_decode_term_subexp(BOOL_DECODER *br, int k, int num_syms);
int vp9_inv_recenter_nonneg(int v, int m);
-/*The refill loop is used in several places, so define it in a macro to make
- sure they're all consistent.
- An inline function would be cleaner, but has a significant penalty, because
- multiple BOOL_DECODER fields must be modified, and the compiler is not smart
- enough to eliminate the stores to those fields and the subsequent reloads
- from them when inlining the function.*/
-#define VP9DX_BOOL_DECODER_FILL(_count,_value,_bufptr,_bufend) \
- do \
- { \
- int shift = VP9_BD_VALUE_SIZE - 8 - ((_count) + 8); \
- int loop_end, x; \
- int bits_left = (int)(((_bufend)-(_bufptr))*CHAR_BIT); \
- \
- x = shift + CHAR_BIT - bits_left; \
- loop_end = 0; \
- if(x >= 0) \
- { \
- (_count) += VP9_LOTS_OF_BITS; \
- loop_end = x; \
- if(!bits_left) break; \
- } \
- while(shift >= loop_end) \
- { \
- (_count) += CHAR_BIT; \
- (_value) |= (VP9_BD_VALUE)*(_bufptr)++ << shift; \
- shift -= CHAR_BIT; \
- } \
- } \
- while(0) \
-
-
static int decode_bool(BOOL_DECODER *br, int probability) {
unsigned int bit = 0;
VP9_BD_VALUE value;
- unsigned int split;
VP9_BD_VALUE bigsplit;
int count;
unsigned int range;
-
- split = 1 + (((br->range - 1) * probability) >> 8);
+ unsigned int split = 1 + (((br->range - 1) * probability) >> 8);
if (br->count < 0)
vp9_bool_decoder_fill(br);
}
void vp9_dequantize_b_c(BLOCKD *d) {
-
int i;
- int16_t *DQ = d->dqcoeff;
- const int16_t *Q = d->qcoeff;
- const int16_t *DQC = d->dequant;
+ int16_t *dq = d->dqcoeff;
+ const int16_t *q = d->qcoeff;
+ const int16_t *dqc = d->dequant;
for (i = 0; i < 16; i++) {
- DQ[i] = Q[i] * DQC[i];
+ dq[i] = q[i] * dqc[i];
}
}
/* All 0 DCT coefficient */
vp9_copy_mem8x8(pred, pitch, dest, stride);
} else if (eob > 0) {
- input[0] = dq[0] * input[0];
+ input[0] *= dq[0];
for (i = 1; i < 64; i++) {
- input[i] = dq[1] * input[i];
+ input[i] *= dq[1];
}
#if CONFIG_INTHT
int i;
for (i = 0; i < 16; i++) {
- input[i] = dq[i] * input[i];
+ input[i] *= dq[i];
}
/* the idct halves ( >> 1) the pitch */
}
void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
- uint8_t *dest, int pitch, int stride, int Dc) {
+ uint8_t *dest, int pitch, int stride, int dc) {
int i;
int16_t output[16];
int16_t *diff_ptr = output;
- input[0] = (int16_t)Dc;
+ input[0] = dc;
for (i = 1; i < 16; i++) {
- input[i] = dq[i] * input[i];
+ input[i] *= dq[i];
}
/* the idct halves ( >> 1) the pitch */
int i;
for (i = 0; i < 16; i++) {
- input[i] = dq[i] * input[i];
+ input[i] *= dq[i];
}
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
input[0] = (int16_t)dc;
for (i = 1; i < 16; i++) {
- input[i] = dq[i] * input[i];
+ input[i] *= dq[i];
}
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
} else {
// recover quantizer for 4 4x4 blocks
for (i = 1; i < 64; i++) {
- input[i] = input[i] * dq[1];
+ input[i] *= dq[1];
}
// the idct halves ( >> 1) the pitch
vp9_short_idct8x8_c(input, output, 16);
/* All 0 DCT coefficient */
vp9_copy_mem16x16(pred, pitch, dest, stride);
} else if (eob > 0) {
- input[0]= input[0] * dq[0];
+ input[0] *= dq[0];
// recover quantizer for 4 4x4 blocks
for (i = 1; i < 256; i++)
- input[i] = input[i] * dq[1];
+ input[i] *= dq[1];
// inverse hybrid transform
#if CONFIG_INTHT16X16
add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
} else {
- input[0]= input[0] * dq[0];
+ input[0] *= dq[0];
// recover quantizer for 4 4x4 blocks
for (i = 1; i < 256; i++)
- input[i] = input[i] * dq[1];
+ input[i] *= dq[1];
// the idct halves ( >> 1) the pitch
vp9_short_idct16x16_c(input, output, 32);
#include <string.h>
#include <limits.h>
#include <assert.h>
+#include <math.h>
-#include "math.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_modecont.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_quant_common.h"
#include "vp9/common/vp9_seg_common.h"
-#define MIN_BPB_FACTOR 0.005
-#define MAX_BPB_FACTOR 50
+#define MIN_BPB_FACTOR 0.005
+#define MAX_BPB_FACTOR 50
#ifdef MODE_STATS
extern unsigned int y_modes[VP9_YMODES];
#define FRAME_OVERHEAD_BITS 200
-extern void vp9_save_coding_context(VP9_COMP *cpi);
-extern void vp9_restore_coding_context(VP9_COMP *cpi);
+void vp9_save_coding_context(VP9_COMP *cpi);
+void vp9_restore_coding_context(VP9_COMP *cpi);
-extern void vp9_setup_key_frame(VP9_COMP *cpi);
-extern void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var);
-extern int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame);
-extern void vp9_adjust_key_frame_context(VP9_COMP *cpi);
-extern void vp9_compute_frame_size_bounds(VP9_COMP *cpi,
- int *frame_under_shoot_limit,
- int *frame_over_shoot_limit);
+void vp9_setup_key_frame(VP9_COMP *cpi);
+void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var);
+int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame);
+void vp9_adjust_key_frame_context(VP9_COMP *cpi);
+void vp9_compute_frame_size_bounds(VP9_COMP *cpi,
+ int *frame_under_shoot_limit,
+ int *frame_over_shoot_limit);
// return of 0 means drop frame
-extern int vp9_pick_frame_size(VP9_COMP *cpi);
+int vp9_pick_frame_size(VP9_COMP *cpi);
-extern double vp9_convert_qindex_to_q(int qindex);
-extern int vp9_gfboost_qadjust(int qindex);
-extern int vp9_bits_per_mb(FRAME_TYPE frame_type, int qindex);
+double vp9_convert_qindex_to_q(int qindex);
+int vp9_gfboost_qadjust(int qindex);
+int vp9_bits_per_mb(FRAME_TYPE frame_type, int qindex);
void vp9_setup_inter_frame(VP9_COMP *cpi);
#endif // VP9_ENCODER_VP9_RATECTRL_H_
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <math.h>
+#include <limits.h>
#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/common/vp9_swapyv12buffer.h"
#include "vpx_ports/vpx_timer.h"
-#include <math.h>
-#include <limits.h>
-
#define ALT_REF_MC_ENABLED 1 // dis/enable MC in AltRef filtering
#define ALT_REF_SUBPEL_ENABLED 1 // dis/enable subpel in MC AltRef filtering
mbd->pre.v_buffer = v_buffer;
}
-void vp9_temporal_filter_prepare
-(
- VP9_COMP *cpi,
- int distance
-) {
+void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) {
int frame = 0;
int num_frames_backward = 0;
#ifndef VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
#define VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
-extern void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance);
+void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance);
#endif // VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
typedef int64_t vp9_coeff_accum[COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
-extern int vp9_mby_is_skippable_4x4(MACROBLOCKD *xd);
-extern int vp9_mbuv_is_skippable_4x4(MACROBLOCKD *xd);
-extern int vp9_mby_is_skippable_8x8(MACROBLOCKD *xd);
-extern int vp9_mbuv_is_skippable_8x8(MACROBLOCKD *xd);
-extern int vp9_mby_is_skippable_16x16(MACROBLOCKD *xd);
-extern int vp9_sby_is_skippable_32x32(MACROBLOCKD *xd);
-extern int vp9_sbuv_is_skippable_16x16(MACROBLOCKD *xd);
+int vp9_mby_is_skippable_4x4(MACROBLOCKD *xd);
+int vp9_mbuv_is_skippable_4x4(MACROBLOCKD *xd);
+int vp9_mby_is_skippable_8x8(MACROBLOCKD *xd);
+int vp9_mbuv_is_skippable_8x8(MACROBLOCKD *xd);
+int vp9_mby_is_skippable_16x16(MACROBLOCKD *xd);
+int vp9_sby_is_skippable_32x32(MACROBLOCKD *xd);
+int vp9_sbuv_is_skippable_16x16(MACROBLOCKD *xd);
struct VP9_COMP;
-extern void vp9_tokenize_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run);
-extern void vp9_tokenize_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run);
+void vp9_tokenize_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
+ TOKENEXTRA **t, int dry_run);
+void vp9_tokenize_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
+ TOKENEXTRA **t, int dry_run);
-extern void vp9_stuff_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run);
-extern void vp9_stuff_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
- TOKENEXTRA **t, int dry_run);
+void vp9_stuff_mb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
+ TOKENEXTRA **t, int dry_run);
+void vp9_stuff_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
+ TOKENEXTRA **t, int dry_run);
+
+void vp9_fix_contexts_sb(MACROBLOCKD *xd);
-extern void vp9_fix_contexts_sb(MACROBLOCKD *xd);
#ifdef ENTROPY_STATS
void init_context_counters();
void print_context_counters();
/* Both of these return bits, not scaled bits. */
+static INLINE unsigned int cost_branch256(const unsigned int ct[2],
+ vp9_prob p) {
+ /* Imitate existing calculation */
+ return ct[0] * vp9_cost_zero(p) + ct[1] * vp9_cost_one(p);
+}
static INLINE unsigned int cost_branch(const unsigned int ct[2],
vp9_prob p) {
/* Imitate existing calculation */
- return ((ct[0] * vp9_cost_zero(p))
- + (ct[1] * vp9_cost_one(p))) >> 8;
+ return cost_branch256(ct, p) >> 8;
}
-static INLINE unsigned int cost_branch256(const unsigned int ct[2],
- vp9_prob p) {
- /* Imitate existing calculation */
- return ((ct[0] * vp9_cost_zero(p))
- + (ct[1] * vp9_cost_one(p)));
-}
/* Small functions to write explicit values and tokens, as well as
estimate their lengths. */