summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--args.c335
-rw-r--r--args.h33
-rw-r--r--build/make/obj_int_extract.c1449
-rw-r--r--example_xma.c313
-rw-r--r--libmkv/EbmlBufferWriter.c74
-rw-r--r--libmkv/EbmlBufferWriter.h14
-rw-r--r--libmkv/EbmlIDs.h191
-rw-r--r--libmkv/EbmlWriter.c208
-rw-r--r--libmkv/EbmlWriter.h8
-rw-r--r--libmkv/WebMElement.c182
-rw-r--r--libmkv/WebMElement.h4
-rw-r--r--libmkv/testlibmkv.c87
-rw-r--r--md5_utils.c320
-rw-r--r--md5_utils.h9
-rw-r--r--test/acm_random.h24
-rw-r--r--test/boolcoder_test.cc14
-rw-r--r--test/test_libvpx.cc15
-rw-r--r--tools_common.c9
-rw-r--r--tools_common.h2
-rw-r--r--vp8/common/alloccommon.c328
-rw-r--r--vp8/common/arm/arm_systemdependent.c144
-rw-r--r--vp8/common/arm/bilinearfilter_arm.c149
-rw-r--r--vp8/common/arm/bilinearfilter_arm.h24
-rw-r--r--vp8/common/arm/filter_arm.c285
-rw-r--r--vp8/common/arm/loopfilter_arm.c162
-rw-r--r--vp8/common/arm/neon/recon_neon.c19
-rw-r--r--vp8/common/arm/reconintra_arm.c66
-rw-r--r--vp8/common/blockd.c20
-rw-r--r--vp8/common/blockd.h422
-rw-r--r--vp8/common/common.h12
-rw-r--r--vp8/common/context.c748
-rw-r--r--vp8/common/debugmodes.c191
-rw-r--r--vp8/common/default_coef_probs.h681
-rw-r--r--vp8/common/entropy.c386
-rw-r--r--vp8/common/entropy.h13
-rw-r--r--vp8/common/entropymode.c1065
-rw-r--r--vp8/common/entropymode.h14
-rw-r--r--vp8/common/entropymv.c724
-rw-r--r--vp8/common/entropymv.h68
-rw-r--r--vp8/common/extend.c297
-rw-r--r--vp8/common/filter.c2357
-rw-r--r--vp8/common/filter.h2
-rw-r--r--vp8/common/findnearmv.c286
-rw-r--r--vp8/common/findnearmv.h263
-rw-r--r--vp8/common/g_common.h10
-rw-r--r--vp8/common/generic/systemdependent.c181
-rw-r--r--vp8/common/header.h23
-rw-r--r--vp8/common/idct.h33
-rw-r--r--vp8/common/idctllm.c847
-rw-r--r--vp8/common/implicit_segmentation.c343
-rw-r--r--vp8/common/invtrans.c193
-rw-r--r--vp8/common/loopfilter.c1233
-rw-r--r--vp8/common/loopfilter.h76
-rw-r--r--vp8/common/loopfilter_filters.c596
-rw-r--r--vp8/common/maskingmv.c1395
-rw-r--r--vp8/common/mbpitch.c172
-rw-r--r--vp8/common/modecont.c78
-rw-r--r--vp8/common/modecontext.c263
-rw-r--r--vp8/common/mv.h14
-rw-r--r--vp8/common/onyx.h322
-rw-r--r--vp8/common/onyxc_int.h343
-rw-r--r--vp8/common/onyxd.h71
-rw-r--r--vp8/common/postproc.c1623
-rw-r--r--vp8/common/postproc.h56
-rw-r--r--vp8/common/ppc/loopfilter_altivec.c124
-rw-r--r--vp8/common/ppc/systemdependent.c110
-rw-r--r--vp8/common/ppflags.h42
-rw-r--r--vp8/common/pred_common.c511
-rw-r--r--vp8/common/pred_common.h41
-rw-r--r--vp8/common/predict_rotated.c85
-rw-r--r--vp8/common/quant_common.c158
-rw-r--r--vp8/common/recon.c301
-rw-r--r--vp8/common/recon.h89
-rw-r--r--vp8/common/reconinter.c1933
-rw-r--r--vp8/common/reconintra.c1316
-rw-r--r--vp8/common/reconintra4x4.c485
-rw-r--r--vp8/common/rotate.h5654
-rw-r--r--vp8/common/rotate2.h5654
-rw-r--r--vp8/common/seg_common.c204
-rw-r--r--vp8/common/seg_common.h78
-rw-r--r--vp8/common/setupintrarecon.c25
-rw-r--r--vp8/common/subpixel.h65
-rw-r--r--vp8/common/swapyv12buffer.c29
-rw-r--r--vp8/common/textblit.c204
-rw-r--r--vp8/common/treecoder.c165
-rw-r--r--vp8/common/treecoder.h37
-rw-r--r--vp8/common/x86/loopfilter_x86.c144
-rw-r--r--vp8/common/x86/recon_wrapper_sse2.c110
-rw-r--r--vp8/common/x86/vp8_asm_stubs.c738
-rw-r--r--vp8/common/x86/x86_systemdependent.c170
-rw-r--r--vp8/decoder/arm/arm_dsystemdependent.c48
-rw-r--r--vp8/decoder/arm/armv6/idct_blk_v6.c235
-rw-r--r--vp8/decoder/arm/dequantize_arm.c22
-rw-r--r--vp8/decoder/arm/neon/idct_blk_neon.c155
-rw-r--r--vp8/decoder/dboolhuff.c142
-rw-r--r--vp8/decoder/dboolhuff.h186
-rw-r--r--vp8/decoder/decodemv.c1739
-rw-r--r--vp8/decoder/decodframe.c2416
-rw-r--r--vp8/decoder/dequantize.c532
-rw-r--r--vp8/decoder/dequantize.h81
-rw-r--r--vp8/decoder/detokenize.c556
-rw-r--r--vp8/decoder/ec_types.h26
-rw-r--r--vp8/decoder/generic/dsystemdependent.c35
-rw-r--r--vp8/decoder/idct_blk.c367
-rw-r--r--vp8/decoder/onyxd_if.c728
-rw-r--r--vp8/decoder/onyxd_int.h113
-rw-r--r--vp8/decoder/reconintra_mt.c1350
-rw-r--r--vp8/decoder/treereader.h15
-rw-r--r--vp8/decoder/x86/idct_blk_mmx.c235
-rw-r--r--vp8/decoder/x86/idct_blk_sse2.c157
-rw-r--r--vp8/decoder/x86/x86_dsystemdependent.c60
-rw-r--r--vp8/encoder/arm/arm_csystemdependent.c188
-rw-r--r--vp8/encoder/arm/boolhuff_arm.c35
-rw-r--r--vp8/encoder/arm/dct_arm.c7
-rw-r--r--vp8/encoder/arm/encodemb_arm.h18
-rw-r--r--vp8/encoder/arm/neon/picklpf_arm.c39
-rw-r--r--vp8/encoder/arm/quantize_arm.c53
-rw-r--r--vp8/encoder/arm/variance_arm.c136
-rw-r--r--vp8/encoder/arm/variance_arm.h30
-rw-r--r--vp8/encoder/bitstream.c4154
-rw-r--r--vp8/encoder/bitstream.h2
-rw-r--r--vp8/encoder/block.h260
-rw-r--r--vp8/encoder/boolhuff.c224
-rw-r--r--vp8/encoder/boolhuff.h106
-rw-r--r--vp8/encoder/dct.c817
-rw-r--r--vp8/encoder/dct.h17
-rw-r--r--vp8/encoder/encodeframe.c2709
-rw-r--r--vp8/encoder/encodeintra.c442
-rw-r--r--vp8/encoder/encodeintra.h2
-rw-r--r--vp8/encoder/encodemb.c1924
-rw-r--r--vp8/encoder/encodemb.h40
-rw-r--r--vp8/encoder/encodemv.c1097
-rw-r--r--vp8/encoder/find_rotation.c67
-rw-r--r--vp8/encoder/firstpass.c4359
-rw-r--r--vp8/encoder/generic/csystemdependent.c151
-rw-r--r--vp8/encoder/lookahead.c286
-rw-r--r--vp8/encoder/lookahead.h19
-rw-r--r--vp8/encoder/mbgraph.c932
-rw-r--r--vp8/encoder/mcomp.c3606
-rw-r--r--vp8/encoder/mcomp.h113
-rw-r--r--vp8/encoder/modecosts.c67
-rw-r--r--vp8/encoder/onyx_if.c7218
-rw-r--r--vp8/encoder/onyx_int.h1083
-rw-r--r--vp8/encoder/picklpf.c870
-rw-r--r--vp8/encoder/ppc/csystemdependent.c75
-rw-r--r--vp8/encoder/psnr.c19
-rw-r--r--vp8/encoder/quantize.c787
-rw-r--r--vp8/encoder/quantize.h6
-rw-r--r--vp8/encoder/ratectrl.c1067
-rw-r--r--vp8/encoder/ratectrl.h6
-rw-r--r--vp8/encoder/rdopt.c6539
-rw-r--r--vp8/encoder/rdopt.h16
-rw-r--r--vp8/encoder/sad_c.c583
-rw-r--r--vp8/encoder/satd_c.c51
-rw-r--r--vp8/encoder/segmentation.c502
-rw-r--r--vp8/encoder/segmentation.h6
-rw-r--r--vp8/encoder/ssim.c341
-rw-r--r--vp8/encoder/temporal_filter.c849
-rw-r--r--vp8/encoder/temporal_filter.h27
-rw-r--r--vp8/encoder/tokenize.c1591
-rw-r--r--vp8/encoder/tokenize.h22
-rw-r--r--vp8/encoder/treewriter.c43
-rw-r--r--vp8/encoder/treewriter.h106
-rw-r--r--vp8/encoder/variance.h284
-rw-r--r--vp8/encoder/variance_c.c589
-rw-r--r--vp8/encoder/x86/variance_mmx.c630
-rw-r--r--vp8/encoder/x86/variance_sse2.c825
-rw-r--r--vp8/encoder/x86/variance_ssse3.c228
-rw-r--r--vp8/encoder/x86/x86_csystemdependent.c329
-rw-r--r--vp8/vp8_cx_iface.c1775
-rw-r--r--vp8/vp8_dx_iface.c1055
-rw-r--r--vpx/internal/vpx_codec_internal.h272
-rw-r--r--vpx/src/vpx_codec.c153
-rw-r--r--vpx/src/vpx_decoder.c335
-rw-r--r--vpx/src/vpx_decoder_compat.c197
-rw-r--r--vpx/src/vpx_encoder.c409
-rw-r--r--vpx/src/vpx_image.c318
-rw-r--r--vpx/vp8.h65
-rw-r--r--vpx/vp8cx.h180
-rw-r--r--vpx/vp8dx.h25
-rw-r--r--vpx/vp8e.h15
-rw-r--r--vpx/vpx_codec.h849
-rw-r--r--vpx/vpx_decoder.h546
-rw-r--r--vpx/vpx_decoder_compat.h1025
-rw-r--r--vpx/vpx_encoder.h1407
-rw-r--r--vpx/vpx_image.h314
-rw-r--r--vpx_mem/include/vpx_mem_intrnl.h20
-rw-r--r--vpx_mem/include/vpx_mem_tracker.h287
-rw-r--r--vpx_mem/memory_manager/hmm_alloc.c64
-rw-r--r--vpx_mem/memory_manager/hmm_base.c501
-rw-r--r--vpx_mem/memory_manager/hmm_dflt_abort.c33
-rw-r--r--vpx_mem/memory_manager/hmm_grow.c41
-rw-r--r--vpx_mem/memory_manager/hmm_largest.c61
-rw-r--r--vpx_mem/memory_manager/hmm_resize.c131
-rw-r--r--vpx_mem/memory_manager/hmm_shrink.c136
-rw-r--r--vpx_mem/memory_manager/hmm_true.c19
-rw-r--r--vpx_mem/memory_manager/include/cavl_if.h57
-rw-r--r--vpx_mem/memory_manager/include/cavl_impl.h1579
-rw-r--r--vpx_mem/memory_manager/include/heapmm.h77
-rw-r--r--vpx_mem/memory_manager/include/hmm_cnfg.h10
-rw-r--r--vpx_mem/memory_manager/include/hmm_intrnl.h64
-rw-r--r--vpx_mem/vpx_mem.c807
-rw-r--r--vpx_mem/vpx_mem.h140
-rw-r--r--vpx_mem/vpx_mem_tracker.c710
-rw-r--r--vpx_ports/arm_cpudetect.c230
-rw-r--r--vpx_ports/asm_offsets.h4
-rw-r--r--vpx_ports/mem.h4
-rw-r--r--vpx_ports/mem_ops.h182
-rw-r--r--vpx_ports/mem_ops_aligned.h80
-rw-r--r--vpx_ports/vpx_timer.h65
-rw-r--r--vpx_ports/vpxtypes.h41
-rw-r--r--vpx_ports/x86.h182
-rw-r--r--vpx_ports/x86_cpuid.c60
-rw-r--r--vpx_scale/arm/neon/yv12extend_arm.c9
-rw-r--r--vpx_scale/arm/scalesystemdependent.c73
-rw-r--r--vpx_scale/generic/bicubic_scaler.c769
-rw-r--r--vpx_scale/generic/gen_scalers.c865
-rw-r--r--vpx_scale/generic/scalesystemdependent.c9
-rw-r--r--vpx_scale/generic/vpxscale.c1305
-rw-r--r--vpx_scale/generic/yv12config.c134
-rw-r--r--vpx_scale/generic/yv12extend.c430
-rw-r--r--vpx_scale/include/generic/vpxscale_arbitrary.h53
-rw-r--r--vpx_scale/scale_mode.h11
-rw-r--r--vpx_scale/vpxscale.h36
-rw-r--r--vpx_scale/win32/scaleopt.c1922
-rw-r--r--vpx_scale/win32/scalesystemdependent.c70
-rw-r--r--vpx_scale/yv12config.h75
-rw-r--r--vpx_scale/yv12extend.h8
-rw-r--r--vpxdec.c1664
-rw-r--r--vpxenc.c3328
-rw-r--r--y4minput.c719
-rw-r--r--y4minput.h8
232 files changed, 57367 insertions, 62797 deletions
diff --git a/args.c b/args.c
index 7b2cc3a10..5a885f7d8 100644
--- a/args.c
+++ b/args.c
@@ -25,241 +25,214 @@ extern void die(const char *fmt, ...);
#endif
-struct arg arg_init(char **argv)
-{
- struct arg a;
-
- a.argv = argv;
- a.argv_step = 1;
- a.name = NULL;
- a.val = NULL;
- a.def = NULL;
- return a;
+struct arg arg_init(char **argv) {
+ struct arg a;
+
+ a.argv = argv;
+ a.argv_step = 1;
+ a.name = NULL;
+ a.val = NULL;
+ a.def = NULL;
+ return a;
}
-int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
-{
- struct arg arg;
+int arg_match(struct arg *arg_, const struct arg_def *def, char **argv) {
+ struct arg arg;
- if (!argv[0] || argv[0][0] != '-')
- return 0;
+ if (!argv[0] || argv[0][0] != '-')
+ return 0;
- arg = arg_init(argv);
+ arg = arg_init(argv);
- if (def->short_name
- && strlen(arg.argv[0]) == strlen(def->short_name) + 1
- && !strcmp(arg.argv[0] + 1, def->short_name))
- {
+ if (def->short_name
+ && strlen(arg.argv[0]) == strlen(def->short_name) + 1
+ && !strcmp(arg.argv[0] + 1, def->short_name)) {
- arg.name = arg.argv[0] + 1;
- arg.val = def->has_val ? arg.argv[1] : NULL;
- arg.argv_step = def->has_val ? 2 : 1;
- }
- else if (def->long_name)
- {
- int name_len = strlen(def->long_name);
-
- if (strlen(arg.argv[0]) >= name_len + 2
- && arg.argv[0][1] == '-'
- && !strncmp(arg.argv[0] + 2, def->long_name, name_len)
- && (arg.argv[0][name_len+2] == '='
- || arg.argv[0][name_len+2] == '\0'))
- {
-
- arg.name = arg.argv[0] + 2;
- arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
- arg.argv_step = 1;
- }
+ arg.name = arg.argv[0] + 1;
+ arg.val = def->has_val ? arg.argv[1] : NULL;
+ arg.argv_step = def->has_val ? 2 : 1;
+ } else if (def->long_name) {
+ int name_len = strlen(def->long_name);
+
+ if (strlen(arg.argv[0]) >= name_len + 2
+ && arg.argv[0][1] == '-'
+ && !strncmp(arg.argv[0] + 2, def->long_name, name_len)
+ && (arg.argv[0][name_len + 2] == '='
+ || arg.argv[0][name_len + 2] == '\0')) {
+
+ arg.name = arg.argv[0] + 2;
+ arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
+ arg.argv_step = 1;
}
+ }
- if (arg.name && !arg.val && def->has_val)
- die("Error: option %s requires argument.\n", arg.name);
+ if (arg.name && !arg.val && def->has_val)
+ die("Error: option %s requires argument.\n", arg.name);
- if (arg.name && arg.val && !def->has_val)
- die("Error: option %s requires no argument.\n", arg.name);
+ if (arg.name && arg.val && !def->has_val)
+ die("Error: option %s requires no argument.\n", arg.name);
- if (arg.name
- && (arg.val || !def->has_val))
- {
- arg.def = def;
- *arg_ = arg;
- return 1;
- }
+ if (arg.name
+ && (arg.val || !def->has_val)) {
+ arg.def = def;
+ *arg_ = arg;
+ return 1;
+ }
- return 0;
+ return 0;
}
-const char *arg_next(struct arg *arg)
-{
- if (arg->argv[0])
- arg->argv += arg->argv_step;
+const char *arg_next(struct arg *arg) {
+ if (arg->argv[0])
+ arg->argv += arg->argv_step;
- return *arg->argv;
+ return *arg->argv;
}
-char **argv_dup(int argc, const char **argv)
-{
- char **new_argv = malloc((argc + 1) * sizeof(*argv));
+char **argv_dup(int argc, const char **argv) {
+ char **new_argv = malloc((argc + 1) * sizeof(*argv));
- memcpy(new_argv, argv, argc * sizeof(*argv));
- new_argv[argc] = NULL;
- return new_argv;
+ memcpy(new_argv, argv, argc * sizeof(*argv));
+ new_argv[argc] = NULL;
+ return new_argv;
}
-void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
-{
- char option_text[40] = {0};
+void arg_show_usage(FILE *fp, const struct arg_def *const *defs) {
+ char option_text[40] = {0};
- for (; *defs; defs++)
- {
- const struct arg_def *def = *defs;
- char *short_val = def->has_val ? " <arg>" : "";
- char *long_val = def->has_val ? "=<arg>" : "";
+ for (; *defs; defs++) {
+ const struct arg_def *def = *defs;
+ char *short_val = def->has_val ? " <arg>" : "";
+ char *long_val = def->has_val ? "=<arg>" : "";
- if (def->short_name && def->long_name)
- {
- char *comma = def->has_val ? "," : ", ";
+ if (def->short_name && def->long_name) {
+ char *comma = def->has_val ? "," : ", ";
- snprintf(option_text, 37, "-%s%s%s --%s%6s",
- def->short_name, short_val, comma,
- def->long_name, long_val);
- }
- else if (def->short_name)
- snprintf(option_text, 37, "-%s%s",
- def->short_name, short_val);
- else if (def->long_name)
- snprintf(option_text, 37, " --%s%s",
- def->long_name, long_val);
+ snprintf(option_text, 37, "-%s%s%s --%s%6s",
+ def->short_name, short_val, comma,
+ def->long_name, long_val);
+ } else if (def->short_name)
+ snprintf(option_text, 37, "-%s%s",
+ def->short_name, short_val);
+ else if (def->long_name)
+ snprintf(option_text, 37, " --%s%s",
+ def->long_name, long_val);
- fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
+ fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
- if(def->enums)
- {
- const struct arg_enum_list *listptr;
+ if (def->enums) {
+ const struct arg_enum_list *listptr;
- fprintf(fp, " %-37s\t ", "");
+ fprintf(fp, " %-37s\t ", "");
- for(listptr = def->enums; listptr->name; listptr++)
- fprintf(fp, "%s%s", listptr->name,
- listptr[1].name ? ", " : "\n");
- }
+ for (listptr = def->enums; listptr->name; listptr++)
+ fprintf(fp, "%s%s", listptr->name,
+ listptr[1].name ? ", " : "\n");
}
+ }
}
-unsigned int arg_parse_uint(const struct arg *arg)
-{
- long int rawval;
- char *endptr;
+unsigned int arg_parse_uint(const struct arg *arg) {
+ long int rawval;
+ char *endptr;
- rawval = strtol(arg->val, &endptr, 10);
+ rawval = strtol(arg->val, &endptr, 10);
- if (arg->val[0] != '\0' && endptr[0] == '\0')
- {
- if (rawval >= 0 && rawval <= UINT_MAX)
- return rawval;
+ if (arg->val[0] != '\0' && endptr[0] == '\0') {
+ if (rawval >= 0 && rawval <= UINT_MAX)
+ return rawval;
- die("Option %s: Value %ld out of range for unsigned int\n",
- arg->name, rawval);
- }
+ die("Option %s: Value %ld out of range for unsigned int\n",
+ arg->name, rawval);
+ }
- die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
- return 0;
+ die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+ return 0;
}
-int arg_parse_int(const struct arg *arg)
-{
- long int rawval;
- char *endptr;
+int arg_parse_int(const struct arg *arg) {
+ long int rawval;
+ char *endptr;
- rawval = strtol(arg->val, &endptr, 10);
+ rawval = strtol(arg->val, &endptr, 10);
- if (arg->val[0] != '\0' && endptr[0] == '\0')
- {
- if (rawval >= INT_MIN && rawval <= INT_MAX)
- return rawval;
+ if (arg->val[0] != '\0' && endptr[0] == '\0') {
+ if (rawval >= INT_MIN && rawval <= INT_MAX)
+ return rawval;
- die("Option %s: Value %ld out of range for signed int\n",
- arg->name, rawval);
- }
+ die("Option %s: Value %ld out of range for signed int\n",
+ arg->name, rawval);
+ }
- die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
- return 0;
+ die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+ return 0;
}
-struct vpx_rational
-{
- int num; /**< fraction numerator */
- int den; /**< fraction denominator */
+struct vpx_rational {
+ int num; /**< fraction numerator */
+ int den; /**< fraction denominator */
};
-struct vpx_rational arg_parse_rational(const struct arg *arg)
-{
- long int rawval;
- char *endptr;
- struct vpx_rational rat;
-
- /* parse numerator */
- rawval = strtol(arg->val, &endptr, 10);
-
- if (arg->val[0] != '\0' && endptr[0] == '/')
- {
- if (rawval >= INT_MIN && rawval <= INT_MAX)
- rat.num = rawval;
- else die("Option %s: Value %ld out of range for signed int\n",
- arg->name, rawval);
- }
- else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
-
- /* parse denominator */
- rawval = strtol(endptr + 1, &endptr, 10);
-
- if (arg->val[0] != '\0' && endptr[0] == '\0')
- {
- if (rawval >= INT_MIN && rawval <= INT_MAX)
- rat.den = rawval;
- else die("Option %s: Value %ld out of range for signed int\n",
- arg->name, rawval);
- }
- else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
-
- return rat;
+struct vpx_rational arg_parse_rational(const struct arg *arg) {
+ long int rawval;
+ char *endptr;
+ struct vpx_rational rat;
+
+ /* parse numerator */
+ rawval = strtol(arg->val, &endptr, 10);
+
+ if (arg->val[0] != '\0' && endptr[0] == '/') {
+ if (rawval >= INT_MIN && rawval <= INT_MAX)
+ rat.num = rawval;
+ else die("Option %s: Value %ld out of range for signed int\n",
+ arg->name, rawval);
+ } else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
+
+ /* parse denominator */
+ rawval = strtol(endptr + 1, &endptr, 10);
+
+ if (arg->val[0] != '\0' && endptr[0] == '\0') {
+ if (rawval >= INT_MIN && rawval <= INT_MAX)
+ rat.den = rawval;
+ else die("Option %s: Value %ld out of range for signed int\n",
+ arg->name, rawval);
+ } else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+
+ return rat;
}
-int arg_parse_enum(const struct arg *arg)
-{
- const struct arg_enum_list *listptr;
- long int rawval;
- char *endptr;
-
- /* First see if the value can be parsed as a raw value */
- rawval = strtol(arg->val, &endptr, 10);
- if (arg->val[0] != '\0' && endptr[0] == '\0')
- {
- /* Got a raw value, make sure it's valid */
- for(listptr = arg->def->enums; listptr->name; listptr++)
- if(listptr->val == rawval)
- return rawval;
- }
+int arg_parse_enum(const struct arg *arg) {
+ const struct arg_enum_list *listptr;
+ long int rawval;
+ char *endptr;
- /* Next see if it can be parsed as a string */
- for(listptr = arg->def->enums; listptr->name; listptr++)
- if(!strcmp(arg->val, listptr->name))
- return listptr->val;
+ /* First see if the value can be parsed as a raw value */
+ rawval = strtol(arg->val, &endptr, 10);
+ if (arg->val[0] != '\0' && endptr[0] == '\0') {
+ /* Got a raw value, make sure it's valid */
+ for (listptr = arg->def->enums; listptr->name; listptr++)
+ if (listptr->val == rawval)
+ return rawval;
+ }
- die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
- return 0;
+ /* Next see if it can be parsed as a string */
+ for (listptr = arg->def->enums; listptr->name; listptr++)
+ if (!strcmp(arg->val, listptr->name))
+ return listptr->val;
+
+ die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
+ return 0;
}
-int arg_parse_enum_or_int(const struct arg *arg)
-{
- if(arg->def->enums)
- return arg_parse_enum(arg);
- return arg_parse_int(arg);
+int arg_parse_enum_or_int(const struct arg *arg) {
+ if (arg->def->enums)
+ return arg_parse_enum(arg);
+ return arg_parse_int(arg);
}
diff --git a/args.h b/args.h
index 7963fa6b7..ad591afc8 100644
--- a/args.h
+++ b/args.h
@@ -13,29 +13,26 @@
#define ARGS_H
#include <stdio.h>
-struct arg
-{
- char **argv;
- const char *name;
- const char *val;
- unsigned int argv_step;
- const struct arg_def *def;
+struct arg {
+ char **argv;
+ const char *name;
+ const char *val;
+ unsigned int argv_step;
+ const struct arg_def *def;
};
-struct arg_enum_list
-{
- const char *name;
- int val;
+struct arg_enum_list {
+ const char *name;
+ int val;
};
#define ARG_ENUM_LIST_END {0}
-typedef struct arg_def
-{
- const char *short_name;
- const char *long_name;
- int has_val;
- const char *desc;
- const struct arg_enum_list *enums;
+typedef struct arg_def {
+ const char *short_name;
+ const char *long_name;
+ int has_val;
+ const char *desc;
+ const struct arg_enum_list *enums;
} arg_def_t;
#define ARG_DEF(s,l,v,d) {s,l,v,d, NULL}
#define ARG_DEF_ENUM(s,l,v,d,e) {s,l,v,d,e}
diff --git a/build/make/obj_int_extract.c b/build/make/obj_int_extract.c
index 04e14a6c8..fc7460050 100644
--- a/build/make/obj_int_extract.c
+++ b/build/make/obj_int_extract.c
@@ -17,21 +17,19 @@
#include "vpx_config.h"
#include "vpx/vpx_integer.h"
-typedef enum
-{
- OUTPUT_FMT_PLAIN,
- OUTPUT_FMT_RVDS,
- OUTPUT_FMT_GAS,
+typedef enum {
+ OUTPUT_FMT_PLAIN,
+ OUTPUT_FMT_RVDS,
+ OUTPUT_FMT_GAS,
} output_fmt_t;
-int log_msg(const char *fmt, ...)
-{
- int res;
- va_list ap;
- va_start(ap, fmt);
- res = vfprintf(stderr, fmt, ap);
- va_end(ap);
- return res;
+int log_msg(const char *fmt, ...) {
+ int res;
+ va_list ap;
+ va_start(ap, fmt);
+ res = vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ return res;
}
#if defined(__GNUC__) && __GNUC__
@@ -40,175 +38,148 @@ int log_msg(const char *fmt, ...)
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
-int parse_macho(uint8_t *base_buf, size_t sz)
-{
- int i, j;
- struct mach_header header;
- uint8_t *buf = base_buf;
- int base_data_section = 0;
- int bits = 0;
-
- /* We can read in mach_header for 32 and 64 bit architectures
- * because it's identical to mach_header_64 except for the last
- * element (uint32_t reserved), which we don't use. Then, when
- * we know which architecture we're looking at, increment buf
- * appropriately.
- */
- memcpy(&header, buf, sizeof(struct mach_header));
-
- if (header.magic == MH_MAGIC)
- {
- if (header.cputype == CPU_TYPE_ARM
- || header.cputype == CPU_TYPE_X86)
- {
- bits = 32;
- buf += sizeof(struct mach_header);
- }
- else
- {
- log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_[ARM|X86].\n");
- goto bail;
- }
+int parse_macho(uint8_t *base_buf, size_t sz) {
+ int i, j;
+ struct mach_header header;
+ uint8_t *buf = base_buf;
+ int base_data_section = 0;
+ int bits = 0;
+
+ /* We can read in mach_header for 32 and 64 bit architectures
+ * because it's identical to mach_header_64 except for the last
+ * element (uint32_t reserved), which we don't use. Then, when
+ * we know which architecture we're looking at, increment buf
+ * appropriately.
+ */
+ memcpy(&header, buf, sizeof(struct mach_header));
+
+ if (header.magic == MH_MAGIC) {
+ if (header.cputype == CPU_TYPE_ARM
+ || header.cputype == CPU_TYPE_X86) {
+ bits = 32;
+ buf += sizeof(struct mach_header);
+ } else {
+ log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_[ARM|X86].\n");
+ goto bail;
}
- else if (header.magic == MH_MAGIC_64)
- {
- if (header.cputype == CPU_TYPE_X86_64)
- {
- bits = 64;
- buf += sizeof(struct mach_header_64);
- }
- else
- {
- log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_X86_64.\n");
- goto bail;
- }
+ } else if (header.magic == MH_MAGIC_64) {
+ if (header.cputype == CPU_TYPE_X86_64) {
+ bits = 64;
+ buf += sizeof(struct mach_header_64);
+ } else {
+ log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_X86_64.\n");
+ goto bail;
}
- else
- {
- log_msg("Bad magic number for object file. 0x%x or 0x%x expected, 0x%x found.\n",
- MH_MAGIC, MH_MAGIC_64, header.magic);
+ } else {
+ log_msg("Bad magic number for object file. 0x%x or 0x%x expected, 0x%x found.\n",
+ MH_MAGIC, MH_MAGIC_64, header.magic);
+ goto bail;
+ }
+
+ if (header.filetype != MH_OBJECT) {
+ log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n");
+ goto bail;
+ }
+
+ for (i = 0; i < header.ncmds; i++) {
+ struct load_command lc;
+
+ memcpy(&lc, buf, sizeof(struct load_command));
+
+ if (lc.cmd == LC_SEGMENT) {
+ uint8_t *seg_buf = buf;
+ struct section s;
+ struct segment_command seg_c;
+
+ memcpy(&seg_c, seg_buf, sizeof(struct segment_command));
+ seg_buf += sizeof(struct segment_command);
+
+ /* Although each section is given it's own offset, nlist.n_value
+ * references the offset of the first section. This isn't
+ * apparent without debug information because the offset of the
+ * data section is the same as the first section. However, with
+ * debug sections mixed in, the offset of the debug section
+ * increases but n_value still references the first section.
+ */
+ if (seg_c.nsects < 1) {
+ log_msg("Not enough sections\n");
goto bail;
- }
+ }
+
+ memcpy(&s, seg_buf, sizeof(struct section));
+ base_data_section = s.offset;
+ } else if (lc.cmd == LC_SEGMENT_64) {
+ uint8_t *seg_buf = buf;
+ struct section_64 s;
+ struct segment_command_64 seg_c;
+
+ memcpy(&seg_c, seg_buf, sizeof(struct segment_command_64));
+ seg_buf += sizeof(struct segment_command_64);
- if (header.filetype != MH_OBJECT)
- {
- log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n");
+ /* Explanation in LG_SEGMENT */
+ if (seg_c.nsects < 1) {
+ log_msg("Not enough sections\n");
goto bail;
- }
+ }
- for (i = 0; i < header.ncmds; i++)
- {
- struct load_command lc;
-
- memcpy(&lc, buf, sizeof(struct load_command));
-
- if (lc.cmd == LC_SEGMENT)
- {
- uint8_t *seg_buf = buf;
- struct section s;
- struct segment_command seg_c;
-
- memcpy(&seg_c, seg_buf, sizeof(struct segment_command));
- seg_buf += sizeof(struct segment_command);
-
- /* Although each section is given it's own offset, nlist.n_value
- * references the offset of the first section. This isn't
- * apparent without debug information because the offset of the
- * data section is the same as the first section. However, with
- * debug sections mixed in, the offset of the debug section
- * increases but n_value still references the first section.
- */
- if (seg_c.nsects < 1)
- {
- log_msg("Not enough sections\n");
- goto bail;
- }
+ memcpy(&s, seg_buf, sizeof(struct section_64));
+ base_data_section = s.offset;
+ } else if (lc.cmd == LC_SYMTAB) {
+ if (base_data_section != 0) {
+ struct symtab_command sc;
+ uint8_t *sym_buf = base_buf;
+ uint8_t *str_buf = base_buf;
- memcpy(&s, seg_buf, sizeof(struct section));
- base_data_section = s.offset;
- }
- else if (lc.cmd == LC_SEGMENT_64)
- {
- uint8_t *seg_buf = buf;
- struct section_64 s;
- struct segment_command_64 seg_c;
-
- memcpy(&seg_c, seg_buf, sizeof(struct segment_command_64));
- seg_buf += sizeof(struct segment_command_64);
-
- /* Explanation in LG_SEGMENT */
- if (seg_c.nsects < 1)
- {
- log_msg("Not enough sections\n");
- goto bail;
- }
+ memcpy(&sc, buf, sizeof(struct symtab_command));
- memcpy(&s, seg_buf, sizeof(struct section_64));
- base_data_section = s.offset;
- }
- else if (lc.cmd == LC_SYMTAB)
- {
- if (base_data_section != 0)
- {
- struct symtab_command sc;
- uint8_t *sym_buf = base_buf;
- uint8_t *str_buf = base_buf;
-
- memcpy(&sc, buf, sizeof(struct symtab_command));
-
- if (sc.cmdsize != sizeof(struct symtab_command))
- {
- log_msg("Can't find symbol table!\n");
- goto bail;
- }
-
- sym_buf += sc.symoff;
- str_buf += sc.stroff;
-
- for (j = 0; j < sc.nsyms; j++)
- {
- /* Location of string is cacluated each time from the
- * start of the string buffer. On darwin the symbols
- * are prefixed by "_", so we bump the pointer by 1.
- * The target value is defined as an int in asm_*_offsets.c,
- * which is 4 bytes on all targets we currently use.
- */
- if (bits == 32)
- {
- struct nlist nl;
- int val;
-
- memcpy(&nl, sym_buf, sizeof(struct nlist));
- sym_buf += sizeof(struct nlist);
-
- memcpy(&val, base_buf + base_data_section + nl.n_value,
- sizeof(val));
- printf("%-40s EQU %5d\n",
- str_buf + nl.n_un.n_strx + 1, val);
- }
- else /* if (bits == 64) */
- {
- struct nlist_64 nl;
- int val;
-
- memcpy(&nl, sym_buf, sizeof(struct nlist_64));
- sym_buf += sizeof(struct nlist_64);
-
- memcpy(&val, base_buf + base_data_section + nl.n_value,
- sizeof(val));
- printf("%-40s EQU %5d\n",
- str_buf + nl.n_un.n_strx + 1, val);
- }
- }
- }
+ if (sc.cmdsize != sizeof(struct symtab_command)) {
+ log_msg("Can't find symbol table!\n");
+ goto bail;
}
- buf += lc.cmdsize;
+ sym_buf += sc.symoff;
+ str_buf += sc.stroff;
+
+ for (j = 0; j < sc.nsyms; j++) {
+ /* Location of string is cacluated each time from the
+ * start of the string buffer. On darwin the symbols
+ * are prefixed by "_", so we bump the pointer by 1.
+ * The target value is defined as an int in asm_*_offsets.c,
+ * which is 4 bytes on all targets we currently use.
+ */
+ if (bits == 32) {
+ struct nlist nl;
+ int val;
+
+ memcpy(&nl, sym_buf, sizeof(struct nlist));
+ sym_buf += sizeof(struct nlist);
+
+ memcpy(&val, base_buf + base_data_section + nl.n_value,
+ sizeof(val));
+ printf("%-40s EQU %5d\n",
+ str_buf + nl.n_un.n_strx + 1, val);
+ } else { /* if (bits == 64) */
+ struct nlist_64 nl;
+ int val;
+
+ memcpy(&nl, sym_buf, sizeof(struct nlist_64));
+ sym_buf += sizeof(struct nlist_64);
+
+ memcpy(&val, base_buf + base_data_section + nl.n_value,
+ sizeof(val));
+ printf("%-40s EQU %5d\n",
+ str_buf + nl.n_un.n_strx + 1, val);
+ }
+ }
+ }
}
- return 0;
+ buf += lc.cmdsize;
+ }
+
+ return 0;
bail:
- return 1;
+ return 1;
}
@@ -216,448 +187,400 @@ bail:
#include "elf.h"
#define COPY_STRUCT(dst, buf, ofst, sz) do {\
- if(ofst + sizeof((*(dst))) > sz) goto bail;\
- memcpy(dst, buf+ofst, sizeof((*(dst))));\
- } while(0)
+ if(ofst + sizeof((*(dst))) > sz) goto bail;\
+ memcpy(dst, buf+ofst, sizeof((*(dst))));\
+ } while(0)
#define ENDIAN_ASSIGN(val, memb) do {\
- if(!elf->le_data) {log_msg("Big Endian data not supported yet!\n");goto bail;}\
- (val) = (memb);\
- } while(0)
+ if(!elf->le_data) {log_msg("Big Endian data not supported yet!\n");goto bail;}\
+ (val) = (memb);\
+ } while(0)
#define ENDIAN_ASSIGN_IN_PLACE(memb) do {\
- ENDIAN_ASSIGN(memb, memb);\
- } while(0)
-
-typedef struct
-{
- uint8_t *buf; /* Buffer containing ELF data */
- size_t sz; /* Buffer size */
- int le_data; /* Data is little-endian */
- unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
- int bits; /* 32 or 64 */
- Elf32_Ehdr hdr32;
- Elf64_Ehdr hdr64;
+ ENDIAN_ASSIGN(memb, memb);\
+ } while(0)
+
+typedef struct {
+ uint8_t *buf; /* Buffer containing ELF data */
+ size_t sz; /* Buffer size */
+ int le_data; /* Data is little-endian */
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ int bits; /* 32 or 64 */
+ Elf32_Ehdr hdr32;
+ Elf64_Ehdr hdr64;
} elf_obj_t;
-int parse_elf_header(elf_obj_t *elf)
-{
- int res;
- /* Verify ELF Magic numbers */
- COPY_STRUCT(&elf->e_ident, elf->buf, 0, elf->sz);
- res = elf->e_ident[EI_MAG0] == ELFMAG0;
- res &= elf->e_ident[EI_MAG1] == ELFMAG1;
- res &= elf->e_ident[EI_MAG2] == ELFMAG2;
- res &= elf->e_ident[EI_MAG3] == ELFMAG3;
- res &= elf->e_ident[EI_CLASS] == ELFCLASS32
- || elf->e_ident[EI_CLASS] == ELFCLASS64;
- res &= elf->e_ident[EI_DATA] == ELFDATA2LSB;
-
- if (!res) goto bail;
-
- elf->le_data = elf->e_ident[EI_DATA] == ELFDATA2LSB;
-
- /* Read in relevant values */
- if (elf->e_ident[EI_CLASS] == ELFCLASS32)
- {
- elf->bits = 32;
- COPY_STRUCT(&elf->hdr32, elf->buf, 0, elf->sz);
-
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_type);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_machine);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_version);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_entry);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phoff);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shoff);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_flags);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_ehsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phentsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phnum);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shentsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shnum);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shstrndx);
- }
- else /* if (elf->e_ident[EI_CLASS] == ELFCLASS64) */
- {
- elf->bits = 64;
- COPY_STRUCT(&elf->hdr64, elf->buf, 0, elf->sz);
-
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_type);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_machine);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_version);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_entry);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phoff);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shoff);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_flags);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_ehsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phentsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phnum);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shentsize);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shnum);
- ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shstrndx);
- }
-
- return 0;
+int parse_elf_header(elf_obj_t *elf) {
+ int res;
+ /* Verify ELF Magic numbers */
+ COPY_STRUCT(&elf->e_ident, elf->buf, 0, elf->sz);
+ res = elf->e_ident[EI_MAG0] == ELFMAG0;
+ res &= elf->e_ident[EI_MAG1] == ELFMAG1;
+ res &= elf->e_ident[EI_MAG2] == ELFMAG2;
+ res &= elf->e_ident[EI_MAG3] == ELFMAG3;
+ res &= elf->e_ident[EI_CLASS] == ELFCLASS32
+ || elf->e_ident[EI_CLASS] == ELFCLASS64;
+ res &= elf->e_ident[EI_DATA] == ELFDATA2LSB;
+
+ if (!res) goto bail;
+
+ elf->le_data = elf->e_ident[EI_DATA] == ELFDATA2LSB;
+
+ /* Read in relevant values */
+ if (elf->e_ident[EI_CLASS] == ELFCLASS32) {
+ elf->bits = 32;
+ COPY_STRUCT(&elf->hdr32, elf->buf, 0, elf->sz);
+
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_type);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_machine);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_version);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_entry);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phoff);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shoff);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_flags);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_ehsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phentsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phnum);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shentsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shnum);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shstrndx);
+ } else { /* if (elf->e_ident[EI_CLASS] == ELFCLASS64) */
+ elf->bits = 64;
+ COPY_STRUCT(&elf->hdr64, elf->buf, 0, elf->sz);
+
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_type);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_machine);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_version);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_entry);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phoff);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shoff);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_flags);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_ehsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phentsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phnum);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shentsize);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shnum);
+ ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shstrndx);
+ }
+
+ return 0;
bail:
- log_msg("Failed to parse ELF file header");
- return 1;
+ log_msg("Failed to parse ELF file header");
+ return 1;
}
-int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hdr64)
-{
- if (hdr32)
- {
- if (idx >= elf->hdr32.e_shnum)
- goto bail;
-
- COPY_STRUCT(hdr32, elf->buf, elf->hdr32.e_shoff + idx * elf->hdr32.e_shentsize,
- elf->sz);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_name);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_type);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_flags);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addr);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_offset);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_size);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_link);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_info);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addralign);
- ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_entsize);
- }
- else /* if (hdr64) */
- {
- if (idx >= elf->hdr64.e_shnum)
- goto bail;
-
- COPY_STRUCT(hdr64, elf->buf, elf->hdr64.e_shoff + idx * elf->hdr64.e_shentsize,
- elf->sz);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_name);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_type);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_flags);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addr);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_offset);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_size);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_link);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_info);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addralign);
- ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_entsize);
- }
+int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hdr64) {
+ if (hdr32) {
+ if (idx >= elf->hdr32.e_shnum)
+ goto bail;
+
+ COPY_STRUCT(hdr32, elf->buf, elf->hdr32.e_shoff + idx * elf->hdr32.e_shentsize,
+ elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_name);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_type);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_flags);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addr);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_offset);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_size);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_link);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_info);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addralign);
+ ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_entsize);
+ } else { /* if (hdr64) */
+ if (idx >= elf->hdr64.e_shnum)
+ goto bail;
- return 0;
+ COPY_STRUCT(hdr64, elf->buf, elf->hdr64.e_shoff + idx * elf->hdr64.e_shentsize,
+ elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_name);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_type);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_flags);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addr);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_offset);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_size);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_link);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_info);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addralign);
+ ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_entsize);
+ }
+
+ return 0;
bail:
- return 1;
+ return 1;
}
-char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx)
-{
- if (elf->bits == 32)
- {
- Elf32_Shdr shdr;
-
- if (parse_elf_section(elf, s_idx, &shdr, NULL))
- {
- log_msg("Failed to parse ELF string table: section %d, index %d\n",
- s_idx, idx);
- return "";
- }
+char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx) {
+ if (elf->bits == 32) {
+ Elf32_Shdr shdr;
- return (char *)(elf->buf + shdr.sh_offset + idx);
+ if (parse_elf_section(elf, s_idx, &shdr, NULL)) {
+ log_msg("Failed to parse ELF string table: section %d, index %d\n",
+ s_idx, idx);
+ return "";
}
- else /* if (elf->bits == 64) */
- {
- Elf64_Shdr shdr;
-
- if (parse_elf_section(elf, s_idx, NULL, &shdr))
- {
- log_msg("Failed to parse ELF string table: section %d, index %d\n",
- s_idx, idx);
- return "";
- }
- return (char *)(elf->buf + shdr.sh_offset + idx);
+ return (char *)(elf->buf + shdr.sh_offset + idx);
+ } else { /* if (elf->bits == 64) */
+ Elf64_Shdr shdr;
+
+ if (parse_elf_section(elf, s_idx, NULL, &shdr)) {
+ log_msg("Failed to parse ELF string table: section %d, index %d\n",
+ s_idx, idx);
+ return "";
}
+
+ return (char *)(elf->buf + shdr.sh_offset + idx);
+ }
}
-int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_Sym *sym64)
-{
- if (sym32)
- {
- COPY_STRUCT(sym32, elf->buf, ofst, elf->sz);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_name);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_value);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_size);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_info);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_other);
- ENDIAN_ASSIGN_IN_PLACE(sym32->st_shndx);
- }
- else /* if (sym64) */
- {
- COPY_STRUCT(sym64, elf->buf, ofst, elf->sz);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_name);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_value);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_size);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_info);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_other);
- ENDIAN_ASSIGN_IN_PLACE(sym64->st_shndx);
- }
- return 0;
+int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_Sym *sym64) {
+ if (sym32) {
+ COPY_STRUCT(sym32, elf->buf, ofst, elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_name);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_value);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_size);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_info);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_other);
+ ENDIAN_ASSIGN_IN_PLACE(sym32->st_shndx);
+ } else { /* if (sym64) */
+ COPY_STRUCT(sym64, elf->buf, ofst, elf->sz);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_name);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_value);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_size);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_info);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_other);
+ ENDIAN_ASSIGN_IN_PLACE(sym64->st_shndx);
+ }
+ return 0;
bail:
- return 1;
+ return 1;
}
-int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
-{
- elf_obj_t elf;
- unsigned int ofst;
- int i;
- Elf32_Off strtab_off32;
- Elf64_Off strtab_off64; /* save String Table offset for later use */
+int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode) {
+ elf_obj_t elf;
+ unsigned int ofst;
+ int i;
+ Elf32_Off strtab_off32;
+ Elf64_Off strtab_off64; /* save String Table offset for later use */
- memset(&elf, 0, sizeof(elf));
- elf.buf = buf;
- elf.sz = sz;
+ memset(&elf, 0, sizeof(elf));
+ elf.buf = buf;
+ elf.sz = sz;
- /* Parse Header */
- if (parse_elf_header(&elf))
- goto bail;
+ /* Parse Header */
+ if (parse_elf_header(&elf))
+ goto bail;
- if (elf.bits == 32)
- {
- Elf32_Shdr shdr;
- for (i = 0; i < elf.hdr32.e_shnum; i++)
- {
- parse_elf_section(&elf, i, &shdr, NULL);
-
- if (shdr.sh_type == SHT_STRTAB)
- {
- char strtsb_name[128];
-
- strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
-
- if (!(strcmp(strtsb_name, ".shstrtab")))
- {
- /* log_msg("found section: %s\n", strtsb_name); */
- strtab_off32 = shdr.sh_offset;
- break;
- }
- }
+ if (elf.bits == 32) {
+ Elf32_Shdr shdr;
+ for (i = 0; i < elf.hdr32.e_shnum; i++) {
+ parse_elf_section(&elf, i, &shdr, NULL);
+
+ if (shdr.sh_type == SHT_STRTAB) {
+ char strtsb_name[128];
+
+ strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
+
+ if (!(strcmp(strtsb_name, ".shstrtab"))) {
+ /* log_msg("found section: %s\n", strtsb_name); */
+ strtab_off32 = shdr.sh_offset;
+ break;
}
+ }
}
- else /* if (elf.bits == 64) */
- {
- Elf64_Shdr shdr;
- for (i = 0; i < elf.hdr64.e_shnum; i++)
- {
- parse_elf_section(&elf, i, NULL, &shdr);
-
- if (shdr.sh_type == SHT_STRTAB)
- {
- char strtsb_name[128];
-
- strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
-
- if (!(strcmp(strtsb_name, ".shstrtab")))
- {
- /* log_msg("found section: %s\n", strtsb_name); */
- strtab_off64 = shdr.sh_offset;
- break;
- }
- }
+ } else { /* if (elf.bits == 64) */
+ Elf64_Shdr shdr;
+ for (i = 0; i < elf.hdr64.e_shnum; i++) {
+ parse_elf_section(&elf, i, NULL, &shdr);
+
+ if (shdr.sh_type == SHT_STRTAB) {
+ char strtsb_name[128];
+
+ strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
+
+ if (!(strcmp(strtsb_name, ".shstrtab"))) {
+ /* log_msg("found section: %s\n", strtsb_name); */
+ strtab_off64 = shdr.sh_offset;
+ break;
}
+ }
}
+ }
+
+ /* Parse all Symbol Tables */
+ if (elf.bits == 32) {
+ Elf32_Shdr shdr;
+ for (i = 0; i < elf.hdr32.e_shnum; i++) {
+ parse_elf_section(&elf, i, &shdr, NULL);
+
+ if (shdr.sh_type == SHT_SYMTAB) {
+ for (ofst = shdr.sh_offset;
+ ofst < shdr.sh_offset + shdr.sh_size;
+ ofst += shdr.sh_entsize) {
+ Elf32_Sym sym;
+
+ parse_elf_symbol(&elf, ofst, &sym, NULL);
+
+ /* For all OBJECTS (data objects), extract the value from the
+ * proper data segment.
+ */
+ /* if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
+ log_msg("found data object %s\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name));
+ */
+
+ if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT
+ && sym.st_size == 4) {
+ Elf32_Shdr dhdr;
+ int val = 0;
+ char section_name[128];
+
+ parse_elf_section(&elf, sym.st_shndx, &dhdr, NULL);
+
+ /* For explanition - refer to _MSC_VER version of code */
+ strcpy(section_name, (char *)(elf.buf + strtab_off32 + dhdr.sh_name));
+ /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
+
+ if (strcmp(section_name, ".bss")) {
+ if (sizeof(val) != sym.st_size) {
+ /* The target value is declared as an int in
+ * asm_*_offsets.c, which is 4 bytes on all
+ * targets we currently use. Complain loudly if
+ * this is not true.
+ */
+ log_msg("Symbol size is wrong\n");
+ goto bail;
+ }
+
+ memcpy(&val,
+ elf.buf + dhdr.sh_offset + sym.st_value,
+ sym.st_size);
+ }
+
+ if (!elf.le_data) {
+ log_msg("Big Endian data not supported yet!\n");
+ goto bail;
+ }
- /* Parse all Symbol Tables */
- if (elf.bits == 32)
- {
- Elf32_Shdr shdr;
- for (i = 0; i < elf.hdr32.e_shnum; i++)
- {
- parse_elf_section(&elf, i, &shdr, NULL);
-
- if (shdr.sh_type == SHT_SYMTAB)
- {
- for (ofst = shdr.sh_offset;
- ofst < shdr.sh_offset + shdr.sh_size;
- ofst += shdr.sh_entsize)
- {
- Elf32_Sym sym;
-
- parse_elf_symbol(&elf, ofst, &sym, NULL);
-
- /* For all OBJECTS (data objects), extract the value from the
- * proper data segment.
- */
- /* if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
- log_msg("found data object %s\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name));
- */
-
- if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT
- && sym.st_size == 4)
- {
- Elf32_Shdr dhdr;
- int val = 0;
- char section_name[128];
-
- parse_elf_section(&elf, sym.st_shndx, &dhdr, NULL);
-
- /* For explanition - refer to _MSC_VER version of code */
- strcpy(section_name, (char *)(elf.buf + strtab_off32 + dhdr.sh_name));
- /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
-
- if (strcmp(section_name, ".bss"))
- {
- if (sizeof(val) != sym.st_size)
- {
- /* The target value is declared as an int in
- * asm_*_offsets.c, which is 4 bytes on all
- * targets we currently use. Complain loudly if
- * this is not true.
- */
- log_msg("Symbol size is wrong\n");
- goto bail;
- }
-
- memcpy(&val,
- elf.buf + dhdr.sh_offset + sym.st_value,
- sym.st_size);
- }
-
- if (!elf.le_data)
- {
- log_msg("Big Endian data not supported yet!\n");
- goto bail;
- }
-
- switch (mode)
- {
- case OUTPUT_FMT_RVDS:
- printf("%-40s EQU %5d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- break;
- case OUTPUT_FMT_GAS:
- printf(".equ %-40s, %5d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- break;
- default:
- printf("%s = %d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- }
- }
- }
+ switch (mode) {
+ case OUTPUT_FMT_RVDS:
+ printf("%-40s EQU %5d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
+ break;
+ case OUTPUT_FMT_GAS:
+ printf(".equ %-40s, %5d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
+ break;
+ default:
+ printf("%s = %d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
}
+ }
}
+ }
}
- else /* if (elf.bits == 64) */
- {
- Elf64_Shdr shdr;
- for (i = 0; i < elf.hdr64.e_shnum; i++)
- {
- parse_elf_section(&elf, i, NULL, &shdr);
-
- if (shdr.sh_type == SHT_SYMTAB)
- {
- for (ofst = shdr.sh_offset;
- ofst < shdr.sh_offset + shdr.sh_size;
- ofst += shdr.sh_entsize)
- {
- Elf64_Sym sym;
-
- parse_elf_symbol(&elf, ofst, NULL, &sym);
-
- /* For all OBJECTS (data objects), extract the value from the
- * proper data segment.
- */
- /* if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
- log_msg("found data object %s\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name));
- */
-
- if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT
- && sym.st_size == 4)
- {
- Elf64_Shdr dhdr;
- int val = 0;
- char section_name[128];
-
- parse_elf_section(&elf, sym.st_shndx, NULL, &dhdr);
-
- /* For explanition - refer to _MSC_VER version of code */
- strcpy(section_name, (char *)(elf.buf + strtab_off64 + dhdr.sh_name));
- /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
-
- if ((strcmp(section_name, ".bss")))
- {
- if (sizeof(val) != sym.st_size)
- {
- /* The target value is declared as an int in
- * asm_*_offsets.c, which is 4 bytes on all
- * targets we currently use. Complain loudly if
- * this is not true.
- */
- log_msg("Symbol size is wrong\n");
- goto bail;
- }
-
- memcpy(&val,
- elf.buf + dhdr.sh_offset + sym.st_value,
- sym.st_size);
- }
-
- if (!elf.le_data)
- {
- log_msg("Big Endian data not supported yet!\n");
- goto bail;
- }
-
- switch (mode)
- {
- case OUTPUT_FMT_RVDS:
- printf("%-40s EQU %5d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- break;
- case OUTPUT_FMT_GAS:
- printf(".equ %-40s, %5d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- break;
- default:
- printf("%s = %d\n",
- parse_elf_string_table(&elf,
- shdr.sh_link,
- sym.st_name),
- val);
- }
- }
- }
+ } else { /* if (elf.bits == 64) */
+ Elf64_Shdr shdr;
+ for (i = 0; i < elf.hdr64.e_shnum; i++) {
+ parse_elf_section(&elf, i, NULL, &shdr);
+
+ if (shdr.sh_type == SHT_SYMTAB) {
+ for (ofst = shdr.sh_offset;
+ ofst < shdr.sh_offset + shdr.sh_size;
+ ofst += shdr.sh_entsize) {
+ Elf64_Sym sym;
+
+ parse_elf_symbol(&elf, ofst, NULL, &sym);
+
+ /* For all OBJECTS (data objects), extract the value from the
+ * proper data segment.
+ */
+ /* if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
+ log_msg("found data object %s\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name));
+ */
+
+ if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT
+ && sym.st_size == 4) {
+ Elf64_Shdr dhdr;
+ int val = 0;
+ char section_name[128];
+
+ parse_elf_section(&elf, sym.st_shndx, NULL, &dhdr);
+
+ /* For explanition - refer to _MSC_VER version of code */
+ strcpy(section_name, (char *)(elf.buf + strtab_off64 + dhdr.sh_name));
+ /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
+
+ if ((strcmp(section_name, ".bss"))) {
+ if (sizeof(val) != sym.st_size) {
+ /* The target value is declared as an int in
+ * asm_*_offsets.c, which is 4 bytes on all
+ * targets we currently use. Complain loudly if
+ * this is not true.
+ */
+ log_msg("Symbol size is wrong\n");
+ goto bail;
+ }
+
+ memcpy(&val,
+ elf.buf + dhdr.sh_offset + sym.st_value,
+ sym.st_size);
+ }
+
+ if (!elf.le_data) {
+ log_msg("Big Endian data not supported yet!\n");
+ goto bail;
+ }
+
+ switch (mode) {
+ case OUTPUT_FMT_RVDS:
+ printf("%-40s EQU %5d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
+ break;
+ case OUTPUT_FMT_GAS:
+ printf(".equ %-40s, %5d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
+ break;
+ default:
+ printf("%s = %d\n",
+ parse_elf_string_table(&elf,
+ shdr.sh_link,
+ sym.st_name),
+ val);
}
+ }
}
+ }
}
+ }
- if (mode == OUTPUT_FMT_RVDS)
- printf(" END\n");
+ if (mode == OUTPUT_FMT_RVDS)
+ printf(" END\n");
- return 0;
+ return 0;
bail:
- log_msg("Parse error: File does not appear to be valid ELF32 or ELF64\n");
- return 1;
+ log_msg("Parse error: File does not appear to be valid ELF32 or ELF64\n");
+ return 1;
}
#endif
@@ -671,244 +594,222 @@ bail:
#define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 )
#define get_le16(x) ((*(x)) | (*(x+1)) << 8)
-int parse_coff(uint8_t *buf, size_t sz)
-{
- unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
- unsigned int sectionrawdata_ptr;
- unsigned int i;
- uint8_t *ptr;
- uint32_t symoffset;
-
- char **sectionlist; //this array holds all section names in their correct order.
- //it is used to check if the symbol is in .bss or .data section.
-
- nsections = get_le16(buf + 2);
- symtab_ptr = get_le32(buf + 8);
- symtab_sz = get_le32(buf + 12);
- strtab_ptr = symtab_ptr + symtab_sz * 18;
-
- if (nsections > 96)
- {
- log_msg("Too many sections\n");
- return 1;
- }
+int parse_coff(uint8_t *buf, size_t sz) {
+ unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
+ unsigned int sectionrawdata_ptr;
+ unsigned int i;
+ uint8_t *ptr;
+ uint32_t symoffset;
- sectionlist = malloc(nsections * sizeof(sectionlist));
+ char **sectionlist; // this array holds all section names in their correct order.
+ // it is used to check if the symbol is in .bss or .data section.
- if (sectionlist == NULL)
- {
- log_msg("Allocating first level of section list failed\n");
- return 1;
- }
+ nsections = get_le16(buf + 2);
+ symtab_ptr = get_le32(buf + 8);
+ symtab_sz = get_le32(buf + 12);
+ strtab_ptr = symtab_ptr + symtab_sz * 18;
- //log_msg("COFF: Found %u symbols in %u sections.\n", symtab_sz, nsections);
+ if (nsections > 96) {
+ log_msg("Too many sections\n");
+ return 1;
+ }
- /*
- The size of optional header is always zero for an obj file. So, the section header
- follows the file header immediately.
- */
+ sectionlist = malloc(nsections * sizeof(sectionlist));
- ptr = buf + 20; //section header
+ if (sectionlist == NULL) {
+ log_msg("Allocating first level of section list failed\n");
+ return 1;
+ }
- for (i = 0; i < nsections; i++)
- {
- char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
- strncpy(sectionname, ptr, 8);
- //log_msg("COFF: Parsing section %s\n",sectionname);
+ // log_msg("COFF: Found %u symbols in %u sections.\n", symtab_sz, nsections);
- sectionlist[i] = malloc(strlen(sectionname) + 1);
+ /*
+ The size of optional header is always zero for an obj file. So, the section header
+ follows the file header immediately.
+ */
- if (sectionlist[i] == NULL)
- {
- log_msg("Allocating storage for %s failed\n", sectionname);
- goto bail;
- }
- strcpy(sectionlist[i], sectionname);
+ ptr = buf + 20; // section header
- if (!strcmp(sectionname, ".data")) sectionrawdata_ptr = get_le32(ptr + 20);
+ for (i = 0; i < nsections; i++) {
+ char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+ strncpy(sectionname, ptr, 8);
+ // log_msg("COFF: Parsing section %s\n",sectionname);
- ptr += 40;
- }
+ sectionlist[i] = malloc(strlen(sectionname) + 1);
- //log_msg("COFF: Symbol table at offset %u\n", symtab_ptr);
- //log_msg("COFF: raw data pointer ofset for section .data is %u\n", sectionrawdata_ptr);
-
- /* The compiler puts the data with non-zero offset in .data section, but puts the data with
- zero offset in .bss section. So, if the data in in .bss section, set offset=0.
- Note from Wiki: In an object module compiled from C, the bss section contains
- the local variables (but not functions) that were declared with the static keyword,
- except for those with non-zero initial values. (In C, static variables are initialized
- to zero by default.) It also contains the non-local (both extern and static) variables
- that are also initialized to zero (either explicitly or by default).
- */
- //move to symbol table
- /* COFF symbol table:
- offset field
- 0 Name(*)
- 8 Value
- 12 SectionNumber
- 14 Type
- 16 StorageClass
- 17 NumberOfAuxSymbols
- */
- ptr = buf + symtab_ptr;
-
- for (i = 0; i < symtab_sz; i++)
- {
- int16_t section = get_le16(ptr + 12); //section number
-
- if (section > 0 && ptr[16] == 2)
- {
- //if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) {
-
- if (get_le32(ptr))
- {
- char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
- strncpy(name, ptr, 8);
- //log_msg("COFF: Parsing symbol %s\n",name);
- /* The 64bit Windows compiler doesn't prefix with an _.
- * Check what's there, and bump if necessary
- */
- if (name[0] == '_')
- printf("%-40s EQU ", name + 1);
- else
- printf("%-40s EQU ", name);
- }
- else
- {
- //log_msg("COFF: Parsing symbol %s\n",
- // buf + strtab_ptr + get_le32(ptr+4));
- if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_')
- printf("%-40s EQU ",
- buf + strtab_ptr + get_le32(ptr + 4) + 1);
- else
- printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
- }
-
- if (!(strcmp(sectionlist[section-1], ".bss")))
- {
- symoffset = 0;
- }
- else
- {
- symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8));
- }
+ if (sectionlist[i] == NULL) {
+ log_msg("Allocating storage for %s failed\n", sectionname);
+ goto bail;
+ }
+ strcpy(sectionlist[i], sectionname);
+
+ if (!strcmp(sectionname, ".data")) sectionrawdata_ptr = get_le32(ptr + 20);
+
+ ptr += 40;
+ }
+
+ // log_msg("COFF: Symbol table at offset %u\n", symtab_ptr);
+ // log_msg("COFF: raw data pointer ofset for section .data is %u\n", sectionrawdata_ptr);
+
+ /* The compiler puts the data with non-zero offset in .data section, but puts the data with
+ zero offset in .bss section. So, if the data in in .bss section, set offset=0.
+ Note from Wiki: In an object module compiled from C, the bss section contains
+ the local variables (but not functions) that were declared with the static keyword,
+ except for those with non-zero initial values. (In C, static variables are initialized
+ to zero by default.) It also contains the non-local (both extern and static) variables
+ that are also initialized to zero (either explicitly or by default).
+ */
+ // move to symbol table
+ /* COFF symbol table:
+ offset field
+ 0 Name(*)
+ 8 Value
+ 12 SectionNumber
+ 14 Type
+ 16 StorageClass
+ 17 NumberOfAuxSymbols
+ */
+ ptr = buf + symtab_ptr;
+
+ for (i = 0; i < symtab_sz; i++) {
+ int16_t section = get_le16(ptr + 12); // section number
+
+ if (section > 0 && ptr[16] == 2) {
+ // if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) {
+
+ if (get_le32(ptr)) {
+ char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+ strncpy(name, ptr, 8);
+ // log_msg("COFF: Parsing symbol %s\n",name);
+ /* The 64bit Windows compiler doesn't prefix with an _.
+ * Check what's there, and bump if necessary
+ */
+ if (name[0] == '_')
+ printf("%-40s EQU ", name + 1);
+ else
+ printf("%-40s EQU ", name);
+ } else {
+ // log_msg("COFF: Parsing symbol %s\n",
+ // buf + strtab_ptr + get_le32(ptr+4));
+ if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_')
+ printf("%-40s EQU ",
+ buf + strtab_ptr + get_le32(ptr + 4) + 1);
+ else
+ printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
+ }
- //log_msg(" Section: %d\n",section);
- //log_msg(" Class: %d\n",ptr[16]);
- //log_msg(" Address: %u\n",get_le32(ptr+8));
- //log_msg(" Offset: %u\n", symoffset);
+ if (!(strcmp(sectionlist[section - 1], ".bss"))) {
+ symoffset = 0;
+ } else {
+ symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8));
+ }
- printf("%5d\n", symoffset);
- }
+ // log_msg(" Section: %d\n",section);
+ // log_msg(" Class: %d\n",ptr[16]);
+ // log_msg(" Address: %u\n",get_le32(ptr+8));
+ // log_msg(" Offset: %u\n", symoffset);
- ptr += 18;
+ printf("%5d\n", symoffset);
}
- printf(" END\n");
+ ptr += 18;
+ }
- for (i = 0; i < nsections; i++)
- {
- free(sectionlist[i]);
- }
+ printf(" END\n");
+
+ for (i = 0; i < nsections; i++) {
+ free(sectionlist[i]);
+ }
- free(sectionlist);
+ free(sectionlist);
- return 0;
+ return 0;
bail:
- for (i = 0; i < nsections; i++)
- {
- free(sectionlist[i]);
- }
+ for (i = 0; i < nsections; i++) {
+ free(sectionlist[i]);
+ }
- free(sectionlist);
+ free(sectionlist);
- return 1;
+ return 1;
}
#endif /* defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) */
-int main(int argc, char **argv)
-{
- output_fmt_t mode = OUTPUT_FMT_PLAIN;
- const char *f;
- uint8_t *file_buf;
- int res;
- FILE *fp;
- long int file_size;
-
- if (argc < 2 || argc > 3)
- {
- fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
- fprintf(stderr, " <obj file>\tobject file to parse\n");
- fprintf(stderr, "Output Formats:\n");
- fprintf(stderr, " gas - compatible with GNU assembler\n");
- fprintf(stderr, " rvds - compatible with armasm\n");
- goto bail;
- }
-
- f = argv[2];
-
- if (!strcmp(argv[1], "rvds"))
- mode = OUTPUT_FMT_RVDS;
- else if (!strcmp(argv[1], "gas"))
- mode = OUTPUT_FMT_GAS;
- else
- f = argv[1];
-
- fp = fopen(f, "rb");
-
- if (!fp)
- {
- perror("Unable to open file");
- goto bail;
- }
-
- if (fseek(fp, 0, SEEK_END))
- {
- perror("stat");
- goto bail;
- }
-
- file_size = ftell(fp);
- file_buf = malloc(file_size);
-
- if (!file_buf)
- {
- perror("malloc");
- goto bail;
- }
-
- rewind(fp);
-
- if (fread(file_buf, sizeof(char), file_size, fp) != file_size)
- {
- perror("read");
- goto bail;
- }
-
- if (fclose(fp))
- {
- perror("close");
- goto bail;
- }
+int main(int argc, char **argv) {
+ output_fmt_t mode = OUTPUT_FMT_PLAIN;
+ const char *f;
+ uint8_t *file_buf;
+ int res;
+ FILE *fp;
+ long int file_size;
+
+ if (argc < 2 || argc > 3) {
+ fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+ fprintf(stderr, " <obj file>\tobject file to parse\n");
+ fprintf(stderr, "Output Formats:\n");
+ fprintf(stderr, " gas - compatible with GNU assembler\n");
+ fprintf(stderr, " rvds - compatible with armasm\n");
+ goto bail;
+ }
+
+ f = argv[2];
+
+ if (!strcmp(argv[1], "rvds"))
+ mode = OUTPUT_FMT_RVDS;
+ else if (!strcmp(argv[1], "gas"))
+ mode = OUTPUT_FMT_GAS;
+ else
+ f = argv[1];
+
+ fp = fopen(f, "rb");
+
+ if (!fp) {
+ perror("Unable to open file");
+ goto bail;
+ }
+
+ if (fseek(fp, 0, SEEK_END)) {
+ perror("stat");
+ goto bail;
+ }
+
+ file_size = ftell(fp);
+ file_buf = malloc(file_size);
+
+ if (!file_buf) {
+ perror("malloc");
+ goto bail;
+ }
+
+ rewind(fp);
+
+ if (fread(file_buf, sizeof(char), file_size, fp) != file_size) {
+ perror("read");
+ goto bail;
+ }
+
+ if (fclose(fp)) {
+ perror("close");
+ goto bail;
+ }
#if defined(__GNUC__) && __GNUC__
#if defined(__MACH__)
- res = parse_macho(file_buf, file_size);
+ res = parse_macho(file_buf, file_size);
#elif defined(__ELF__)
- res = parse_elf(file_buf, file_size, mode);
+ res = parse_elf(file_buf, file_size, mode);
#endif
#endif
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
- res = parse_coff(file_buf, file_size);
+ res = parse_coff(file_buf, file_size);
#endif
- free(file_buf);
+ free(file_buf);
- if (!res)
- return EXIT_SUCCESS;
+ if (!res)
+ return EXIT_SUCCESS;
bail:
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
diff --git a/example_xma.c b/example_xma.c
index 72eb47092..f5c09162d 100644
--- a/example_xma.c
+++ b/example_xma.c
@@ -25,190 +25,167 @@
static char *exec_name;
static int verbose = 0;
-static const struct
-{
- const char *name;
- const vpx_codec_iface_t *iface;
-} ifaces[] =
-{
+static const struct {
+ const char *name;
+ const vpx_codec_iface_t *iface;
+} ifaces[] = {
#if CONFIG_VP8_DECODER
- {"vp8", &vpx_codec_vp8_dx_algo},
+ {"vp8", &vpx_codec_vp8_dx_algo},
#endif
};
-static void usage_exit(void)
-{
- int i;
-
- printf("Usage: %s <options>\n\n"
- "Options:\n"
- "\t--codec <name>\tCodec to use (default=%s)\n"
- "\t-h <height>\tHeight of the simulated video frame, in pixels\n"
- "\t-w <width> \tWidth of the simulated video frame, in pixels\n"
- "\t-v \tVerbose mode (show individual segment sizes)\n"
- "\t--help \tShow this message\n"
- "\n"
- "Included decoders:\n"
- "\n",
- exec_name,
- ifaces[0].name);
-
- for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
- printf(" %-6s - %s\n",
- ifaces[i].name,
- vpx_codec_iface_name(ifaces[i].iface));
-
- exit(EXIT_FAILURE);
+static void usage_exit(void) {
+ int i;
+
+ printf("Usage: %s <options>\n\n"
+ "Options:\n"
+ "\t--codec <name>\tCodec to use (default=%s)\n"
+ "\t-h <height>\tHeight of the simulated video frame, in pixels\n"
+ "\t-w <width> \tWidth of the simulated video frame, in pixels\n"
+ "\t-v \tVerbose mode (show individual segment sizes)\n"
+ "\t--help \tShow this message\n"
+ "\n"
+ "Included decoders:\n"
+ "\n",
+ exec_name,
+ ifaces[0].name);
+
+ for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
+ printf(" %-6s - %s\n",
+ ifaces[i].name,
+ vpx_codec_iface_name(ifaces[i].iface));
+
+ exit(EXIT_FAILURE);
}
-static void usage_error(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vprintf(fmt, ap);
- printf("\n");
- usage_exit();
+static void usage_error(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ printf("\n");
+ usage_exit();
}
-void my_mem_dtor(vpx_codec_mmap_t *mmap)
-{
- if (verbose)
- printf("freeing segment %d\n", mmap->id);
+void my_mem_dtor(vpx_codec_mmap_t *mmap) {
+ if (verbose)
+ printf("freeing segment %d\n", mmap->id);
- free(mmap->priv);
+ free(mmap->priv);
}
-int main(int argc, char **argv)
-{
- vpx_codec_ctx_t decoder;
- vpx_codec_iface_t *iface = ifaces[0].iface;
- vpx_codec_iter_t iter;
- vpx_codec_dec_cfg_t cfg;
- vpx_codec_err_t res = VPX_CODEC_OK;
- unsigned int alloc_sz = 0;
- unsigned int w = 352;
- unsigned int h = 288;
- int i;
-
- exec_name = argv[0];
-
- for (i = 1; i < argc; i++)
- {
- if (!strcmp(argv[i], "--codec"))
- {
- if (i + 1 < argc)
- {
- int j, k = -1;
-
- i++;
-
- for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
- if (!strcmp(ifaces[j].name, argv[i]))
- k = j;
-
- if (k >= 0)
- iface = ifaces[k].iface;
- else
- usage_error("Error: Unrecognized argument (%s) to --codec\n",
- argv[i]);
- }
- else
- usage_error("Error: Option --codec requires argument.\n");
- }
- else if (!strcmp(argv[i], "-v"))
- verbose = 1;
- else if (!strcmp(argv[i], "-h"))
- if (i + 1 < argc)
- {
- h = atoi(argv[++i]);
- }
- else
- usage_error("Error: Option -h requires argument.\n");
- else if (!strcmp(argv[i], "-w"))
- if (i + 1 < argc)
- {
- w = atoi(argv[++i]);
- }
- else
- usage_error("Error: Option -w requires argument.\n");
- else if (!strcmp(argv[i], "--help"))
- usage_exit();
- else
- usage_error("Error: Unrecognized option %s\n\n", argv[i]);
- }
+int main(int argc, char **argv) {
+ vpx_codec_ctx_t decoder;
+ vpx_codec_iface_t *iface = ifaces[0].iface;
+ vpx_codec_iter_t iter;
+ vpx_codec_dec_cfg_t cfg;
+ vpx_codec_err_t res = VPX_CODEC_OK;
+ unsigned int alloc_sz = 0;
+ unsigned int w = 352;
+ unsigned int h = 288;
+ int i;
- if (argc == 1)
- printf("Using built-in defaults. For options, rerun with --help\n\n");
+ exec_name = argv[0];
- /* XMA mode is not supported on all decoders! */
- if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA))
- {
- printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
- return EXIT_FAILURE;
- }
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "--codec")) {
+ if (i + 1 < argc) {
+ int j, k = -1;
- /* The codec knows how much memory to allocate based on the size of the
- * encoded frames. This data can be parsed from the bitstream with
- * vpx_codec_peek_stream_info() if a bitstream is available. Otherwise,
- * a fixed size can be used that will be the upper limit on the frame
- * size the decoder can decode.
- */
- cfg.w = w;
- cfg.h = h;
-
- /* Initialize the decoder in XMA mode. */
- if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA))
- {
- printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ i++;
+
+ for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
+ if (!strcmp(ifaces[j].name, argv[i]))
+ k = j;
- /* Iterate through the list of memory maps, allocating them with the
- * requested alignment.
- */
- iter = NULL;
-
- do
- {
- vpx_codec_mmap_t mmap;
- unsigned int align;
-
- res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
- align = mmap.align ? mmap.align - 1 : 0;
-
- if (!res)
- {
- if (verbose)
- printf("Allocating segment %u, size %lu, align %u %s\n",
- mmap.id, mmap.sz, mmap.align,
- mmap.flags & VPX_CODEC_MEM_ZERO ? "(ZEROED)" : "");
-
- if (mmap.flags & VPX_CODEC_MEM_ZERO)
- mmap.priv = calloc(1, mmap.sz + align);
- else
- mmap.priv = malloc(mmap.sz + align);
-
- mmap.base = (void *)((((uintptr_t)mmap.priv) + align) & ~(uintptr_t)align);
- mmap.dtor = my_mem_dtor;
- alloc_sz += mmap.sz + align;
-
- if (vpx_codec_set_mem_map(&decoder, &mmap, 1))
- {
- printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
- }
- else if (res != VPX_CODEC_LIST_END)
- {
- printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ if (k >= 0)
+ iface = ifaces[k].iface;
+ else
+ usage_error("Error: Unrecognized argument (%s) to --codec\n",
+ argv[i]);
+ } else
+ usage_error("Error: Option --codec requires argument.\n");
+ } else if (!strcmp(argv[i], "-v"))
+ verbose = 1;
+ else if (!strcmp(argv[i], "-h"))
+ if (i + 1 < argc) {
+ h = atoi(argv[++i]);
+ } else
+ usage_error("Error: Option -h requires argument.\n");
+ else if (!strcmp(argv[i], "-w"))
+ if (i + 1 < argc) {
+ w = atoi(argv[++i]);
+ } else
+ usage_error("Error: Option -w requires argument.\n");
+ else if (!strcmp(argv[i], "--help"))
+ usage_exit();
+ else
+ usage_error("Error: Unrecognized option %s\n\n", argv[i]);
+ }
+
+ if (argc == 1)
+ printf("Using built-in defaults. For options, rerun with --help\n\n");
+
+ /* XMA mode is not supported on all decoders! */
+ if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA)) {
+ printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
+ return EXIT_FAILURE;
+ }
+
+ /* The codec knows how much memory to allocate based on the size of the
+ * encoded frames. This data can be parsed from the bitstream with
+ * vpx_codec_peek_stream_info() if a bitstream is available. Otherwise,
+ * a fixed size can be used that will be the upper limit on the frame
+ * size the decoder can decode.
+ */
+ cfg.w = w;
+ cfg.h = h;
+
+ /* Initialize the decoder in XMA mode. */
+ if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA)) {
+ printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+
+ /* Iterate through the list of memory maps, allocating them with the
+ * requested alignment.
+ */
+ iter = NULL;
+
+ do {
+ vpx_codec_mmap_t mmap;
+ unsigned int align;
+
+ res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
+ align = mmap.align ? mmap.align - 1 : 0;
+
+ if (!res) {
+ if (verbose)
+ printf("Allocating segment %u, size %lu, align %u %s\n",
+ mmap.id, mmap.sz, mmap.align,
+ mmap.flags & VPX_CODEC_MEM_ZERO ? "(ZEROED)" : "");
+
+ if (mmap.flags & VPX_CODEC_MEM_ZERO)
+ mmap.priv = calloc(1, mmap.sz + align);
+ else
+ mmap.priv = malloc(mmap.sz + align);
+
+ mmap.base = (void *)((((uintptr_t)mmap.priv) + align) & ~(uintptr_t)align);
+ mmap.dtor = my_mem_dtor;
+ alloc_sz += mmap.sz + align;
+
+ if (vpx_codec_set_mem_map(&decoder, &mmap, 1)) {
+ printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+ } else if (res != VPX_CODEC_LIST_END) {
+ printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
}
- while (res != VPX_CODEC_LIST_END);
+ } while (res != VPX_CODEC_LIST_END);
- printf("%s\n %d bytes external memory required for %dx%d.\n",
- decoder.name, alloc_sz, cfg.w, cfg.h);
- vpx_codec_destroy(&decoder);
- return EXIT_SUCCESS;
+ printf("%s\n %d bytes external memory required for %dx%d.\n",
+ decoder.name, alloc_sz, cfg.w, cfg.h);
+ vpx_codec_destroy(&decoder);
+ return EXIT_SUCCESS;
}
diff --git a/libmkv/EbmlBufferWriter.c b/libmkv/EbmlBufferWriter.c
index d9b04a81a..574e47899 100644
--- a/libmkv/EbmlBufferWriter.c
+++ b/libmkv/EbmlBufferWriter.c
@@ -1,60 +1,54 @@
-//#include <strmif.h>
+// #include <strmif.h>
#include "EbmlBufferWriter.h"
#include "EbmlWriter.h"
-//#include <cassert>
-//#include <limits>
-//#include <malloc.h> //_alloca
+// #include <cassert>
+// #include <limits>
+// #include <malloc.h> //_alloca
#include <stdlib.h>
#include <wchar.h>
#include <string.h>
-void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
-{
- unsigned char *src = glob->buf;
- src += glob->offset;
- memcpy(src, buffer_in, len);
- glob->offset += len;
+void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
+ unsigned char *src = glob->buf;
+ src += glob->offset;
+ memcpy(src, buffer_in, len);
+ glob->offset += len;
}
-static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q)
-{
- while (q != p)
- {
- --q;
+static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q) {
+ while (q != p) {
+ --q;
- unsigned long cbWritten;
- memcpy(&(glob->buf[glob->offset]), q, 1);
- glob->offset ++;
- }
+ unsigned long cbWritten;
+ memcpy(&(glob->buf[glob->offset]), q, 1);
+ glob->offset++;
+ }
}
-void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
-{
- //assert(buf);
+void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
+ // assert(buf);
- const unsigned char *const p = (const unsigned char *)(buffer_in);
- const unsigned char *const q = p + len;
+ const unsigned char *const p = (const unsigned char *)(buffer_in);
+ const unsigned char *const q = p + len;
- _Serialize(glob, p, q);
+ _Serialize(glob, p, q);
}
-void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id)
-{
- Ebml_WriteID(glob, class_id);
- ebmlLoc->offset = glob->offset;
- //todo this is always taking 8 bytes, this may need later optimization
- unsigned long long unknownLen = 0x01FFFFFFFFFFFFFFLLU;
- Ebml_Serialize(glob, (void *)&unknownLen, 8); //this is a key that says lenght unknown
+void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id) {
+ Ebml_WriteID(glob, class_id);
+ ebmlLoc->offset = glob->offset;
+ // todo this is always taking 8 bytes, this may need later optimization
+ unsigned long long unknownLen = 0x01FFFFFFFFFFFFFFLLU;
+ Ebml_Serialize(glob, (void *)&unknownLen, 8); // this is a key that says lenght unknown
}
-void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc)
-{
- unsigned long long size = glob->offset - ebmlLoc->offset - 8;
- unsigned long long curOffset = glob->offset;
- glob->offset = ebmlLoc->offset;
- size |= 0x0100000000000000LLU;
- Ebml_Serialize(glob, &size, 8);
- glob->offset = curOffset;
+void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
+ unsigned long long size = glob->offset - ebmlLoc->offset - 8;
+ unsigned long long curOffset = glob->offset;
+ glob->offset = ebmlLoc->offset;
+ size |= 0x0100000000000000LLU;
+ Ebml_Serialize(glob, &size, 8);
+ glob->offset = curOffset;
}
diff --git a/libmkv/EbmlBufferWriter.h b/libmkv/EbmlBufferWriter.h
index ba0a9b3ab..acd5c2a28 100644
--- a/libmkv/EbmlBufferWriter.h
+++ b/libmkv/EbmlBufferWriter.h
@@ -1,16 +1,14 @@
#ifndef EBMLBUFFERWRITER_HPP
#define EBMLBUFFERWRITER_HPP
-typedef struct
-{
- unsigned long long offset;
+typedef struct {
+ unsigned long long offset;
} EbmlLoc;
-typedef struct
-{
- unsigned char *buf;
- unsigned int length;
- unsigned int offset;
+typedef struct {
+ unsigned char *buf;
+ unsigned int length;
+ unsigned int offset;
} EbmlGlobal;
diff --git a/libmkv/EbmlIDs.h b/libmkv/EbmlIDs.h
index 3418e3655..c6c4a6960 100644
--- a/libmkv/EbmlIDs.h
+++ b/libmkv/EbmlIDs.h
@@ -10,37 +10,36 @@
#ifndef MKV_DEFS_HPP
#define MKV_DEFS_HPP 1
-//Commenting out values not available in webm, but available in matroska
+// Commenting out values not available in webm, but available in matroska
-enum mkv
-{
- EBML = 0x1A45DFA3,
- EBMLVersion = 0x4286,
- EBMLReadVersion = 0x42F7,
- EBMLMaxIDLength = 0x42F2,
- EBMLMaxSizeLength = 0x42F3,
- DocType = 0x4282,
- DocTypeVersion = 0x4287,
- DocTypeReadVersion = 0x4285,
+enum mkv {
+ EBML = 0x1A45DFA3,
+ EBMLVersion = 0x4286,
+ EBMLReadVersion = 0x42F7,
+ EBMLMaxIDLength = 0x42F2,
+ EBMLMaxSizeLength = 0x42F3,
+ DocType = 0x4282,
+ DocTypeVersion = 0x4287,
+ DocTypeReadVersion = 0x4285,
// CRC_32 = 0xBF,
- Void = 0xEC,
- SignatureSlot = 0x1B538667,
- SignatureAlgo = 0x7E8A,
- SignatureHash = 0x7E9A,
- SignaturePublicKey = 0x7EA5,
- Signature = 0x7EB5,
- SignatureElements = 0x7E5B,
- SignatureElementList = 0x7E7B,
- SignedElement = 0x6532,
- //segment
- Segment = 0x18538067,
- //Meta Seek Information
- SeekHead = 0x114D9B74,
- Seek = 0x4DBB,
- SeekID = 0x53AB,
- SeekPosition = 0x53AC,
- //Segment Information
- Info = 0x1549A966,
+ Void = 0xEC,
+ SignatureSlot = 0x1B538667,
+ SignatureAlgo = 0x7E8A,
+ SignatureHash = 0x7E9A,
+ SignaturePublicKey = 0x7EA5,
+ Signature = 0x7EB5,
+ SignatureElements = 0x7E5B,
+ SignatureElementList = 0x7E7B,
+ SignedElement = 0x6532,
+ // segment
+ Segment = 0x18538067,
+ // Meta Seek Information
+ SeekHead = 0x114D9B74,
+ Seek = 0x4DBB,
+ SeekID = 0x53AB,
+ SeekPosition = 0x53AC,
+ // Segment Information
+ Info = 0x1549A966,
// SegmentUID = 0x73A4,
// SegmentFilename = 0x7384,
// PrevUID = 0x3CB923,
@@ -52,61 +51,61 @@ enum mkv
// ChapterTranslateEditionUID = 0x69FC,
// ChapterTranslateCodec = 0x69BF,
// ChapterTranslateID = 0x69A5,
- TimecodeScale = 0x2AD7B1,
- Segment_Duration = 0x4489,
- DateUTC = 0x4461,
+ TimecodeScale = 0x2AD7B1,
+ Segment_Duration = 0x4489,
+ DateUTC = 0x4461,
// Title = 0x7BA9,
- MuxingApp = 0x4D80,
- WritingApp = 0x5741,
- //Cluster
- Cluster = 0x1F43B675,
- Timecode = 0xE7,
+ MuxingApp = 0x4D80,
+ WritingApp = 0x5741,
+ // Cluster
+ Cluster = 0x1F43B675,
+ Timecode = 0xE7,
// SilentTracks = 0x5854,
// SilentTrackNumber = 0x58D7,
// Position = 0xA7,
- PrevSize = 0xAB,
- BlockGroup = 0xA0,
- Block = 0xA1,
+ PrevSize = 0xAB,
+ BlockGroup = 0xA0,
+ Block = 0xA1,
// BlockVirtual = 0xA2,
// BlockAdditions = 0x75A1,
// BlockMore = 0xA6,
// BlockAddID = 0xEE,
// BlockAdditional = 0xA5,
- BlockDuration = 0x9B,
+ BlockDuration = 0x9B,
// ReferencePriority = 0xFA,
- ReferenceBlock = 0xFB,
+ ReferenceBlock = 0xFB,
// ReferenceVirtual = 0xFD,
// CodecState = 0xA4,
// Slices = 0x8E,
// TimeSlice = 0xE8,
- LaceNumber = 0xCC,
+ LaceNumber = 0xCC,
// FrameNumber = 0xCD,
// BlockAdditionID = 0xCB,
// MkvDelay = 0xCE,
// Cluster_Duration = 0xCF,
- SimpleBlock = 0xA3,
+ SimpleBlock = 0xA3,
// EncryptedBlock = 0xAF,
- //Track
- Tracks = 0x1654AE6B,
- TrackEntry = 0xAE,
- TrackNumber = 0xD7,
- TrackUID = 0x73C5,
- TrackType = 0x83,
- FlagEnabled = 0xB9,
- FlagDefault = 0x88,
- FlagForced = 0x55AA,
- FlagLacing = 0x9C,
+ // Track
+ Tracks = 0x1654AE6B,
+ TrackEntry = 0xAE,
+ TrackNumber = 0xD7,
+ TrackUID = 0x73C5,
+ TrackType = 0x83,
+ FlagEnabled = 0xB9,
+ FlagDefault = 0x88,
+ FlagForced = 0x55AA,
+ FlagLacing = 0x9C,
// MinCache = 0x6DE7,
// MaxCache = 0x6DF8,
- DefaultDuration = 0x23E383,
+ DefaultDuration = 0x23E383,
// TrackTimecodeScale = 0x23314F,
// TrackOffset = 0x537F,
// MaxBlockAdditionID = 0x55EE,
- Name = 0x536E,
- Language = 0x22B59C,
- CodecID = 0x86,
- CodecPrivate = 0x63A2,
- CodecName = 0x258688,
+ Name = 0x536E,
+ Language = 0x22B59C,
+ CodecID = 0x86,
+ CodecPrivate = 0x63A2,
+ CodecName = 0x258688,
// AttachmentLink = 0x7446,
// CodecSettings = 0x3A9697,
// CodecInfoURL = 0x3B4040,
@@ -117,33 +116,33 @@ enum mkv
// TrackTranslateEditionUID = 0x66FC,
// TrackTranslateCodec = 0x66BF,
// TrackTranslateTrackID = 0x66A5,
- //video
- Video = 0xE0,
- FlagInterlaced = 0x9A,
- StereoMode = 0x53B8,
- PixelWidth = 0xB0,
- PixelHeight = 0xBA,
- PixelCropBottom = 0x54AA,
- PixelCropTop = 0x54BB,
- PixelCropLeft = 0x54CC,
- PixelCropRight = 0x54DD,
- DisplayWidth = 0x54B0,
- DisplayHeight = 0x54BA,
- DisplayUnit = 0x54B2,
- AspectRatioType = 0x54B3,
+ // video
+ Video = 0xE0,
+ FlagInterlaced = 0x9A,
+ StereoMode = 0x53B8,
+ PixelWidth = 0xB0,
+ PixelHeight = 0xBA,
+ PixelCropBottom = 0x54AA,
+ PixelCropTop = 0x54BB,
+ PixelCropLeft = 0x54CC,
+ PixelCropRight = 0x54DD,
+ DisplayWidth = 0x54B0,
+ DisplayHeight = 0x54BA,
+ DisplayUnit = 0x54B2,
+ AspectRatioType = 0x54B3,
// ColourSpace = 0x2EB524,
// GammaValue = 0x2FB523,
- FrameRate = 0x2383E3,
- //end video
- //audio
- Audio = 0xE1,
- SamplingFrequency = 0xB5,
- OutputSamplingFrequency = 0x78B5,
- Channels = 0x9F,
+ FrameRate = 0x2383E3,
+ // end video
+ // audio
+ Audio = 0xE1,
+ SamplingFrequency = 0xB5,
+ OutputSamplingFrequency = 0x78B5,
+ Channels = 0x9F,
// ChannelPositions = 0x7D7B,
- BitDepth = 0x6264,
- //end audio
- //content encoding
+ BitDepth = 0x6264,
+ // end audio
+ // content encoding
// ContentEncodings = 0x6d80,
// ContentEncoding = 0x6240,
// ContentEncodingOrder = 0x5031,
@@ -159,22 +158,22 @@ enum mkv
// ContentSigKeyID = 0x47e4,
// ContentSigAlgo = 0x47e5,
// ContentSigHashAlgo = 0x47e6,
- //end content encoding
- //Cueing Data
- Cues = 0x1C53BB6B,
- CuePoint = 0xBB,
- CueTime = 0xB3,
- CueTrackPositions = 0xB7,
- CueTrack = 0xF7,
- CueClusterPosition = 0xF1,
- CueBlockNumber = 0x5378,
+ // end content encoding
+ // Cueing Data
+ Cues = 0x1C53BB6B,
+ CuePoint = 0xBB,
+ CueTime = 0xB3,
+ CueTrackPositions = 0xB7,
+ CueTrack = 0xF7,
+ CueClusterPosition = 0xF1,
+ CueBlockNumber = 0x5378,
// CueCodecState = 0xEA,
// CueReference = 0xDB,
// CueRefTime = 0x96,
// CueRefCluster = 0x97,
// CueRefNumber = 0x535F,
// CueRefCodecState = 0xEB,
- //Attachment
+ // Attachment
// Attachments = 0x1941A469,
// AttachedFile = 0x61A7,
// FileDescription = 0x467E,
@@ -183,7 +182,7 @@ enum mkv
// FileData = 0x465C,
// FileUID = 0x46AE,
// FileReferral = 0x4675,
- //Chapters
+ // Chapters
// Chapters = 0x1043A770,
// EditionEntry = 0x45B9,
// EditionUID = 0x45BC,
@@ -211,7 +210,7 @@ enum mkv
// ChapProcessCommand = 0x6911,
// ChapProcessTime = 0x6922,
// ChapProcessData = 0x6933,
- //Tagging
+ // Tagging
// Tags = 0x1254C367,
// Tag = 0x7373,
// Targets = 0x63C0,
diff --git a/libmkv/EbmlWriter.c b/libmkv/EbmlWriter.c
index fbf2c66e9..69039e1bf 100644
--- a/libmkv/EbmlWriter.c
+++ b/libmkv/EbmlWriter.c
@@ -18,154 +18,136 @@
#define LITERALU64(n) n##LLU
#endif
-void Ebml_WriteLen(EbmlGlobal *glob, long long val)
-{
- //TODO check and make sure we are not > than 0x0100000000000000LLU
- unsigned char size = 8; //size in bytes to output
- unsigned long long minVal = LITERALU64(0x00000000000000ff); //mask to compare for byte size
-
- for (size = 1; size < 8; size ++)
- {
- if (val < minVal)
- break;
-
- minVal = (minVal << 7);
- }
+void Ebml_WriteLen(EbmlGlobal *glob, long long val) {
+ // TODO check and make sure we are not > than 0x0100000000000000LLU
+ unsigned char size = 8; // size in bytes to output
+ unsigned long long minVal = LITERALU64(0x00000000000000ff); // mask to compare for byte size
+
+ for (size = 1; size < 8; size ++) {
+ if (val < minVal)
+ break;
- val |= (LITERALU64(0x000000000000080) << ((size - 1) * 7));
+ minVal = (minVal << 7);
+ }
- Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
+ val |= (LITERALU64(0x000000000000080) << ((size - 1) * 7));
+
+ Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
}
-void Ebml_WriteString(EbmlGlobal *glob, const char *str)
-{
- const size_t size_ = strlen(str);
- const unsigned long long size = size_;
- Ebml_WriteLen(glob, size);
- //TODO: it's not clear from the spec whether the nul terminator
- //should be serialized too. For now we omit the null terminator.
- Ebml_Write(glob, str, size);
+void Ebml_WriteString(EbmlGlobal *glob, const char *str) {
+ const size_t size_ = strlen(str);
+ const unsigned long long size = size_;
+ Ebml_WriteLen(glob, size);
+ // TODO: it's not clear from the spec whether the nul terminator
+ // should be serialized too. For now we omit the null terminator.
+ Ebml_Write(glob, str, size);
}
-void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr)
-{
- const size_t strlen = wcslen(wstr);
+void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) {
+ const size_t strlen = wcslen(wstr);
- //TODO: it's not clear from the spec whether the nul terminator
- //should be serialized too. For now we include it.
- const unsigned long long size = strlen;
+ // TODO: it's not clear from the spec whether the nul terminator
+ // should be serialized too. For now we include it.
+ const unsigned long long size = strlen;
- Ebml_WriteLen(glob, size);
- Ebml_Write(glob, wstr, size);
+ Ebml_WriteLen(glob, size);
+ Ebml_Write(glob, wstr, size);
}
-void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id)
-{
- int len;
+void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id) {
+ int len;
- if (class_id >= 0x01000000)
- len = 4;
- else if (class_id >= 0x00010000)
- len = 3;
- else if (class_id >= 0x00000100)
- len = 2;
- else
- len = 1;
+ if (class_id >= 0x01000000)
+ len = 4;
+ else if (class_id >= 0x00010000)
+ len = 3;
+ else if (class_id >= 0x00000100)
+ len = 2;
+ else
+ len = 1;
- Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
+ Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
}
-void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui)
-{
- unsigned char sizeSerialized = 8 | 0x80;
- Ebml_WriteID(glob, class_id);
- Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
- Ebml_Serialize(glob, &ui, sizeof(ui), 8);
+void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) {
+ unsigned char sizeSerialized = 8 | 0x80;
+ Ebml_WriteID(glob, class_id);
+ Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
+ Ebml_Serialize(glob, &ui, sizeof(ui), 8);
}
-void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui)
-{
- unsigned char size = 8; //size in bytes to output
- unsigned char sizeSerialized = 0;
- unsigned long minVal;
-
- Ebml_WriteID(glob, class_id);
- minVal = 0x7fLU; //mask to compare for byte size
+void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui) {
+ unsigned char size = 8; // size in bytes to output
+ unsigned char sizeSerialized = 0;
+ unsigned long minVal;
- for (size = 1; size < 4; size ++)
- {
- if (ui < minVal)
- {
- break;
- }
+ Ebml_WriteID(glob, class_id);
+ minVal = 0x7fLU; // mask to compare for byte size
- minVal <<= 7;
+ for (size = 1; size < 4; size ++) {
+ if (ui < minVal) {
+ break;
}
- sizeSerialized = 0x80 | size;
- Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
- Ebml_Serialize(glob, &ui, sizeof(ui), size);
+ minVal <<= 7;
+ }
+
+ sizeSerialized = 0x80 | size;
+ Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
+ Ebml_Serialize(glob, &ui, sizeof(ui), size);
}
-//TODO: perhaps this is a poor name for this id serializer helper function
-void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin)
-{
- int size;
- for (size=4; size > 1; size--)
- {
- if (bin & 0x000000ff << ((size-1) * 8))
- break;
- }
- Ebml_WriteID(glob, class_id);
- Ebml_WriteLen(glob, size);
- Ebml_WriteID(glob, bin);
+// TODO: perhaps this is a poor name for this id serializer helper function
+void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin) {
+ int size;
+ for (size = 4; size > 1; size--) {
+ if (bin & 0x000000ff << ((size - 1) * 8))
+ break;
+ }
+ Ebml_WriteID(glob, class_id);
+ Ebml_WriteLen(glob, size);
+ Ebml_WriteID(glob, bin);
}
-void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d)
-{
- unsigned char len = 0x88;
+void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d) {
+ unsigned char len = 0x88;
- Ebml_WriteID(glob, class_id);
- Ebml_Serialize(glob, &len, sizeof(len), 1);
- Ebml_Serialize(glob, &d, sizeof(d), 8);
+ Ebml_WriteID(glob, class_id);
+ Ebml_Serialize(glob, &len, sizeof(len), 1);
+ Ebml_Serialize(glob, &d, sizeof(d), 8);
}
-void Ebml_WriteSigned16(EbmlGlobal *glob, short val)
-{
- signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
- Ebml_Serialize(glob, &out, sizeof(out), 3);
+void Ebml_WriteSigned16(EbmlGlobal *glob, short val) {
+ signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
+ Ebml_Serialize(glob, &out, sizeof(out), 3);
}
-void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s)
-{
- Ebml_WriteID(glob, class_id);
- Ebml_WriteString(glob, s);
+void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s) {
+ Ebml_WriteID(glob, class_id);
+ Ebml_WriteString(glob, s);
}
-void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s)
-{
- Ebml_WriteID(glob, class_id);
- Ebml_WriteUTF8(glob, s);
+void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s) {
+ Ebml_WriteID(glob, class_id);
+ Ebml_WriteUTF8(glob, s);
}
-void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length)
-{
- Ebml_WriteID(glob, class_id);
- Ebml_WriteLen(glob, data_length);
- Ebml_Write(glob, data, data_length);
+void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length) {
+ Ebml_WriteID(glob, class_id);
+ Ebml_WriteLen(glob, data_length);
+ Ebml_Write(glob, data, data_length);
}
-void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize)
-{
- unsigned char tmp = 0;
- unsigned long i = 0;
+void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) {
+ unsigned char tmp = 0;
+ unsigned long i = 0;
- Ebml_WriteID(glob, 0xEC);
- Ebml_WriteLen(glob, vSize);
+ Ebml_WriteID(glob, 0xEC);
+ Ebml_WriteLen(glob, vSize);
- for (i = 0; i < vSize; i++)
- {
- Ebml_Write(glob, &tmp, 1);
- }
+ for (i = 0; i < vSize; i++) {
+ Ebml_Write(glob, &tmp, 1);
+ }
}
-//TODO Serialize Date
+// TODO Serialize Date
diff --git a/libmkv/EbmlWriter.h b/libmkv/EbmlWriter.h
index 324c9bca0..c4822ee1c 100644
--- a/libmkv/EbmlWriter.h
+++ b/libmkv/EbmlWriter.h
@@ -9,8 +9,8 @@
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
-//note: you must define write and serialize functions as well as your own EBML_GLOBAL
-//These functions MUST be implemented
+// note: you must define write and serialize functions as well as your own EBML_GLOBAL
+// These functions MUST be implemented
#include <stddef.h>
#include "vpx/vpx_integer.h"
@@ -28,11 +28,11 @@ void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui);
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long ui);
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d);
-//TODO make this more generic to signed
+// TODO make this more generic to signed
void Ebml_WriteSigned16(EbmlGlobal *glob, short val);
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s);
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s);
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length);
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize);
-//TODO need date function
+// TODO need date function
#endif
diff --git a/libmkv/WebMElement.c b/libmkv/WebMElement.c
index 0ef5100bb..2f79a3c6a 100644
--- a/libmkv/WebMElement.c
+++ b/libmkv/WebMElement.c
@@ -14,106 +14,100 @@
#define kVorbisPrivateMaxSize 4000
-void writeHeader(EbmlGlobal *glob)
-{
- EbmlLoc start;
- Ebml_StartSubElement(glob, &start, EBML);
- Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
- Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); //EBML Read Version
- Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); //EBML Max ID Length
- Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); //EBML Max Size Length
- Ebml_SerializeString(glob, DocType, "webm"); //Doc Type
- Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); //Doc Type Version
- Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); //Doc Type Read Version
- Ebml_EndSubElement(glob, &start);
+void writeHeader(EbmlGlobal *glob) {
+ EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, EBML);
+ Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
+ Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); // EBML Read Version
+ Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); // EBML Max ID Length
+ Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); // EBML Max Size Length
+ Ebml_SerializeString(glob, DocType, "webm"); // Doc Type
+ Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); // Doc Type Version
+ Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); // Doc Type Read Version
+ Ebml_EndSubElement(glob, &start);
}
void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCode,
int isKeyframe, unsigned char lacingFlag, int discardable,
- unsigned char *data, unsigned long dataLength)
-{
- Ebml_WriteID(glob, SimpleBlock);
- unsigned long blockLength = 4 + dataLength;
- blockLength |= 0x10000000; //TODO check length < 0x0FFFFFFFF
- Ebml_Serialize(glob, &blockLength, sizeof(blockLength), 4);
- trackNumber |= 0x80; //TODO check track nubmer < 128
- Ebml_Write(glob, &trackNumber, 1);
- //Ebml_WriteSigned16(glob, timeCode,2); //this is 3 bytes
- Ebml_Serialize(glob, &timeCode, sizeof(timeCode), 2);
- unsigned char flags = 0x00 | (isKeyframe ? 0x80 : 0x00) | (lacingFlag << 1) | discardable;
- Ebml_Write(glob, &flags, 1);
- Ebml_Write(glob, data, dataLength);
-}
-
-static UInt64 generateTrackID(unsigned int trackNumber)
-{
- UInt64 t = time(NULL) * trackNumber;
- UInt64 r = rand();
- r = r << 32;
- r += rand();
- UInt64 rval = t ^ r;
- return rval;
+ unsigned char *data, unsigned long dataLength) {
+ Ebml_WriteID(glob, SimpleBlock);
+ unsigned long blockLength = 4 + dataLength;
+ blockLength |= 0x10000000; // TODO check length < 0x0FFFFFFFF
+ Ebml_Serialize(glob, &blockLength, sizeof(blockLength), 4);
+ trackNumber |= 0x80; // TODO check track nubmer < 128
+ Ebml_Write(glob, &trackNumber, 1);
+ // Ebml_WriteSigned16(glob, timeCode,2); //this is 3 bytes
+ Ebml_Serialize(glob, &timeCode, sizeof(timeCode), 2);
+ unsigned char flags = 0x00 | (isKeyframe ? 0x80 : 0x00) | (lacingFlag << 1) | discardable;
+ Ebml_Write(glob, &flags, 1);
+ Ebml_Write(glob, data, dataLength);
+}
+
+static UInt64 generateTrackID(unsigned int trackNumber) {
+ UInt64 t = time(NULL) * trackNumber;
+ UInt64 r = rand();
+ r = r << 32;
+ r += rand();
+ UInt64 rval = t ^ r;
+ return rval;
}
void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
- double frameRate)
-{
- EbmlLoc start;
- Ebml_StartSubElement(glob, &start, TrackEntry);
- Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
- UInt64 trackID = generateTrackID(trackNumber);
- Ebml_SerializeUnsigned(glob, TrackUID, trackID);
- Ebml_SerializeString(glob, CodecName, "VP8"); //TODO shouldn't be fixed
-
- Ebml_SerializeUnsigned(glob, TrackType, 1); //video is always 1
- Ebml_SerializeString(glob, CodecID, codecId);
- {
- EbmlLoc videoStart;
- Ebml_StartSubElement(glob, &videoStart, Video);
- Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
- Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
- Ebml_SerializeFloat(glob, FrameRate, frameRate);
- Ebml_EndSubElement(glob, &videoStart); //Video
- }
- Ebml_EndSubElement(glob, &start); //Track Entry
+ double frameRate) {
+ EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, TrackEntry);
+ Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
+ UInt64 trackID = generateTrackID(trackNumber);
+ Ebml_SerializeUnsigned(glob, TrackUID, trackID);
+ Ebml_SerializeString(glob, CodecName, "VP8"); // TODO shouldn't be fixed
+
+ Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1
+ Ebml_SerializeString(glob, CodecID, codecId);
+ {
+ EbmlLoc videoStart;
+ Ebml_StartSubElement(glob, &videoStart, Video);
+ Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
+ Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
+ Ebml_SerializeFloat(glob, FrameRate, frameRate);
+ Ebml_EndSubElement(glob, &videoStart); // Video
+ }
+ Ebml_EndSubElement(glob, &start); // Track Entry
}
void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
char *codecId, double samplingFrequency, unsigned int channels,
- unsigned char *private, unsigned long privateSize)
-{
- EbmlLoc start;
- Ebml_StartSubElement(glob, &start, TrackEntry);
- Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
- UInt64 trackID = generateTrackID(trackNumber);
- Ebml_SerializeUnsigned(glob, TrackUID, trackID);
- Ebml_SerializeUnsigned(glob, TrackType, 2); //audio is always 2
- //I am using defaults for thesed required fields
- /* Ebml_SerializeUnsigned(glob, FlagEnabled, 1);
- Ebml_SerializeUnsigned(glob, FlagDefault, 1);
- Ebml_SerializeUnsigned(glob, FlagForced, 1);
- Ebml_SerializeUnsigned(glob, FlagLacing, flagLacing);*/
- Ebml_SerializeString(glob, CodecID, codecId);
- Ebml_SerializeData(glob, CodecPrivate, private, privateSize);
-
- Ebml_SerializeString(glob, CodecName, "VORBIS"); //fixed for now
- {
- EbmlLoc AudioStart;
- Ebml_StartSubElement(glob, &AudioStart, Audio);
- Ebml_SerializeFloat(glob, SamplingFrequency, samplingFrequency);
- Ebml_SerializeUnsigned(glob, Channels, channels);
- Ebml_EndSubElement(glob, &AudioStart);
- }
- Ebml_EndSubElement(glob, &start);
-}
-void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc* startInfo, unsigned long timeCodeScale, double duration)
-{
- Ebml_StartSubElement(ebml, startInfo, Info);
- Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
- Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); //Currently fixed to using milliseconds
- Ebml_SerializeString(ebml, 0x4D80, "QTmuxingAppLibWebM-0.0.1");
- Ebml_SerializeString(ebml, 0x5741, "QTwritingAppLibWebM-0.0.1");
- Ebml_EndSubElement(ebml, startInfo);
+ unsigned char *private, unsigned long privateSize) {
+ EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, TrackEntry);
+ Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
+ UInt64 trackID = generateTrackID(trackNumber);
+ Ebml_SerializeUnsigned(glob, TrackUID, trackID);
+ Ebml_SerializeUnsigned(glob, TrackType, 2); // audio is always 2
+ // I am using defaults for thesed required fields
+ /* Ebml_SerializeUnsigned(glob, FlagEnabled, 1);
+ Ebml_SerializeUnsigned(glob, FlagDefault, 1);
+ Ebml_SerializeUnsigned(glob, FlagForced, 1);
+ Ebml_SerializeUnsigned(glob, FlagLacing, flagLacing);*/
+ Ebml_SerializeString(glob, CodecID, codecId);
+ Ebml_SerializeData(glob, CodecPrivate, private, privateSize);
+
+ Ebml_SerializeString(glob, CodecName, "VORBIS"); // fixed for now
+ {
+ EbmlLoc AudioStart;
+ Ebml_StartSubElement(glob, &AudioStart, Audio);
+ Ebml_SerializeFloat(glob, SamplingFrequency, samplingFrequency);
+ Ebml_SerializeUnsigned(glob, Channels, channels);
+ Ebml_EndSubElement(glob, &AudioStart);
+ }
+ Ebml_EndSubElement(glob, &start);
+}
+void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration) {
+ Ebml_StartSubElement(ebml, startInfo, Info);
+ Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
+ Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); // Currently fixed to using milliseconds
+ Ebml_SerializeString(ebml, 0x4D80, "QTmuxingAppLibWebM-0.0.1");
+ Ebml_SerializeString(ebml, 0x5741, "QTwritingAppLibWebM-0.0.1");
+ Ebml_EndSubElement(ebml, startInfo);
}
/*
@@ -142,7 +136,7 @@ void Mkv_WriteSegmentInformation(Ebml& ebml_out, SegmentInformationStruct& segme
Ebml_SerializeString(ebml_out, 0x7384, segmentInformation.filename);
Ebml_SerializeUnsigned(ebml_out, 0x2AD7B1, segmentInformation.TimecodeScale);
Ebml_SerializeUnsigned(ebml_out, 0x4489, segmentInformation.Duration);
- //TODO date
+ // TODO date
Ebml_SerializeWString(ebml_out, 0x4D80, L"MKVMUX");
Ebml_SerializeWString(ebml_out, 0x5741, segmentInformation.WritingApp);
}
@@ -173,9 +167,9 @@ static void Mkv_WriteGenericTrackData(Ebml& ebml_out, TrackStruct& track)
void Mkv_WriteVideoTrack(Ebml& ebml_out, TrackStruct & track, VideoTrackStruct& video)
{
EbmlLoc trackHeadLoc, videoHeadLoc;
- Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE); //start Track
+ Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE); // start Track
Mkv_WriteGenericTrackData(ebml_out, track);
- Ebml_StartSubElement(ebml_out, videoHeadLoc, 0xE0); //start Video
+ Ebml_StartSubElement(ebml_out, videoHeadLoc, 0xE0); // start Video
Ebml_SerializeUnsigned(ebml_out, 0x9A, video.FlagInterlaced ? 1 :0);
Ebml_SerializeUnsigned(ebml_out, 0xB0, video.PixelWidth);
Ebml_SerializeUnsigned(ebml_out, 0xBA, video.PixelHeight);
@@ -193,7 +187,7 @@ void Mkv_WriteAudioTrack(Ebml& ebml_out, TrackStruct & track, AudioTrackStruct&
EbmlLoc trackHeadLoc, audioHeadLoc;
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE);
Mkv_WriteGenericTrackData(ebml_out, track);
- Ebml_StartSubElement(ebml_out, audioHeadLoc, 0xE0); //start Audio
+ Ebml_StartSubElement(ebml_out, audioHeadLoc, 0xE0); // start Audio
Ebml_SerializeFloat(ebml_out, 0xB5, video.SamplingFrequency);
Ebml_SerializeUnsigned(ebml_out, 0x9F, video.Channels);
Ebml_SerializeUnsigned(ebml_out, 0x6264, video.BitDepth);
@@ -213,7 +207,7 @@ void Mkv_WriteSimpleBlockHead(Ebml& ebml_out, EbmlLoc& ebmlLoc, SimpleBlockStru
Ebml_Write1UInt(ebml_out, block.TrackNumber);
Ebml_WriteSigned16(ebml_out,block.TimeCode);
unsigned char flags = 0x00 | (block.iskey ? 0x80:0x00) | (block.lacing << 1) | block.discardable;
- Ebml_Write1UInt(ebml_out, flags); //TODO this may be the wrong function
+ Ebml_Write1UInt(ebml_out, flags); // TODO this may be the wrong function
Ebml_Serialize(ebml_out, block.data, block.dataLength);
Ebml_EndSubElement(ebml_out,ebmlLoc);
}
diff --git a/libmkv/WebMElement.h b/libmkv/WebMElement.h
index b4208f285..d9ad0a04f 100644
--- a/libmkv/WebMElement.h
+++ b/libmkv/WebMElement.h
@@ -17,8 +17,8 @@ void writeSimpleBock(EbmlGlobal *ebml, unsigned char trackNumber, unsigned short
// these are helper functions
void writeHeader(EbmlGlobal *ebml);
-void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc* startInfo , unsigned long timeCodeScale, double duration);
-//this function is a helper only, it assumes a lot of defaults
+void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration);
+// this function is a helper only, it assumes a lot of defaults
void writeVideoTrack(EbmlGlobal *ebml, unsigned int trackNumber, int flagLacing,
char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
double frameRate);
diff --git a/libmkv/testlibmkv.c b/libmkv/testlibmkv.c
index 7edfc4347..97bcf956a 100644
--- a/libmkv/testlibmkv.c
+++ b/libmkv/testlibmkv.c
@@ -13,51 +13,50 @@
#include "WebMElement.h"
#include <stdio.h>
-int main(int argc, char *argv[])
-{
- //init the datatype we're using for ebml output
- unsigned char data[8192];
- EbmlGlobal ebml;
- ebml.buf = data;
- ebml.offset = 0;
- ebml.length = 8192;
-
- writeHeader(&ebml);
+int main(int argc, char *argv[]) {
+ // init the datatype we're using for ebml output
+ unsigned char data[8192];
+ EbmlGlobal ebml;
+ ebml.buf = data;
+ ebml.offset = 0;
+ ebml.length = 8192;
+
+ writeHeader(&ebml);
+ {
+ EbmlLoc startSegment;
+ Ebml_StartSubElement(&ebml, &startSegment, Segment); // segment
{
- EbmlLoc startSegment;
- Ebml_StartSubElement(&ebml, &startSegment, Segment); //segment
- {
- //segment info
- EbmlLoc startInfo;
- Ebml_StartSubElement(&ebml, &startInfo, Info);
- Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
- Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
- Ebml_EndSubElement(&ebml, &startInfo);
- }
-
- {
- EbmlLoc trackStart;
- Ebml_StartSubElement(&ebml, &trackStart, Tracks);
- writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97);
- //writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0);
- Ebml_EndSubElement(&ebml, &trackStart);
- }
-
- {
- EbmlLoc clusterStart;
- Ebml_StartSubElement(&ebml, &clusterStart, Cluster); //cluster
- Ebml_SerializeUnsigned(&ebml, Timecode, 0);
-
- unsigned char someData[4] = {1, 2, 3, 4};
- writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4);
- Ebml_EndSubElement(&ebml, &clusterStart);
- } //end cluster
- Ebml_EndSubElement(&ebml, &startSegment);
+ // segment info
+ EbmlLoc startInfo;
+ Ebml_StartSubElement(&ebml, &startInfo, Info);
+ Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
+ Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
+ Ebml_EndSubElement(&ebml, &startInfo);
}
- //dump ebml stuff to the file
- FILE *file_out = fopen("test.mkv", "wb");
- size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
- fclose(file_out);
- return 0;
+ {
+ EbmlLoc trackStart;
+ Ebml_StartSubElement(&ebml, &trackStart, Tracks);
+ writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97);
+ // writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0);
+ Ebml_EndSubElement(&ebml, &trackStart);
+ }
+
+ {
+ EbmlLoc clusterStart;
+ Ebml_StartSubElement(&ebml, &clusterStart, Cluster); // cluster
+ Ebml_SerializeUnsigned(&ebml, Timecode, 0);
+
+ unsigned char someData[4] = {1, 2, 3, 4};
+ writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4);
+ Ebml_EndSubElement(&ebml, &clusterStart);
+ } // end cluster
+ Ebml_EndSubElement(&ebml, &startSegment);
+ }
+
+ // dump ebml stuff to the file
+ FILE *file_out = fopen("test.mkv", "wb");
+ size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
+ fclose(file_out);
+ return 0;
} \ No newline at end of file
diff --git a/md5_utils.c b/md5_utils.c
index 9a584fab7..8fb26e208 100644
--- a/md5_utils.c
+++ b/md5_utils.c
@@ -25,25 +25,22 @@
#include "md5_utils.h"
void
-byteSwap(UWORD32 *buf, unsigned words)
-{
- md5byte *p;
+byteSwap(UWORD32 *buf, unsigned words) {
+ md5byte *p;
- /* Only swap bytes for big endian machines */
- int i = 1;
+ /* Only swap bytes for big endian machines */
+ int i = 1;
- if (*(char *)&i == 1)
- return;
+ if (*(char *)&i == 1)
+ return;
- p = (md5byte *)buf;
+ p = (md5byte *)buf;
- do
- {
- *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
- ((unsigned)p[1] << 8 | p[0]);
- p += 4;
- }
- while (--words);
+ do {
+ *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
+ ((unsigned)p[1] << 8 | p[0]);
+ p += 4;
+ } while (--words);
}
/*
@@ -51,15 +48,14 @@ byteSwap(UWORD32 *buf, unsigned words)
* initialization constants.
*/
void
-MD5Init(struct MD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bytes[0] = 0;
- ctx->bytes[1] = 0;
+MD5Init(struct MD5Context *ctx) {
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bytes[0] = 0;
+ ctx->bytes[1] = 0;
}
/*
@@ -67,44 +63,41 @@ MD5Init(struct MD5Context *ctx)
* of bytes.
*/
void
-MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
-{
- UWORD32 t;
+MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) {
+ UWORD32 t;
- /* Update byte count */
+ /* Update byte count */
- t = ctx->bytes[0];
+ t = ctx->bytes[0];
- if ((ctx->bytes[0] = t + len) < t)
- ctx->bytes[1]++; /* Carry from low to high */
+ if ((ctx->bytes[0] = t + len) < t)
+ ctx->bytes[1]++; /* Carry from low to high */
- t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
+ t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
- if (t > len)
- {
- memcpy((md5byte *)ctx->in + 64 - t, buf, len);
- return;
- }
+ if (t > len) {
+ memcpy((md5byte *)ctx->in + 64 - t, buf, len);
+ return;
+ }
- /* First chunk is an odd size */
- memcpy((md5byte *)ctx->in + 64 - t, buf, t);
+ /* First chunk is an odd size */
+ memcpy((md5byte *)ctx->in + 64 - t, buf, t);
+ byteSwap(ctx->in, 16);
+ MD5Transform(ctx->buf, ctx->in);
+ buf += t;
+ len -= t;
+
+ /* Process data in 64-byte chunks */
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in);
- buf += t;
- len -= t;
-
- /* Process data in 64-byte chunks */
- while (len >= 64)
- {
- memcpy(ctx->in, buf, 64);
- byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
- memcpy(ctx->in, buf, len);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+ memcpy(ctx->in, buf, len);
}
/*
@@ -112,37 +105,35 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
-MD5Final(md5byte digest[16], struct MD5Context *ctx)
-{
- int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
- md5byte *p = (md5byte *)ctx->in + count;
-
- /* Set the first char of padding to 0x80. There is always room. */
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 56 bytes (-8..55) */
- count = 56 - 1 - count;
-
- if (count < 0) /* Padding forces an extra block */
- {
- memset(p, 0, count + 8);
- byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
- p = (md5byte *)ctx->in;
- count = 56;
- }
-
- memset(p, 0, count);
- byteSwap(ctx->in, 14);
-
- /* Append length in bits and transform */
- ctx->in[14] = ctx->bytes[0] << 3;
- ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
+MD5Final(md5byte digest[16], struct MD5Context *ctx) {
+ int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
+ md5byte *p = (md5byte *)ctx->in + count;
+
+ /* Set the first char of padding to 0x80. There is always room. */
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 56 bytes (-8..55) */
+ count = 56 - 1 - count;
+
+ if (count < 0) { /* Padding forces an extra block */
+ memset(p, 0, count + 8);
+ byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in);
+ p = (md5byte *)ctx->in;
+ count = 56;
+ }
+
+ memset(p, 0, count);
+ byteSwap(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ctx->in[14] = ctx->bytes[0] << 3;
+ ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
+ MD5Transform(ctx->buf, ctx->in);
- byteSwap(ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
+ byteSwap(ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
@@ -157,7 +148,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f,w,x,y,z,in,s) \
- (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
+ (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
@@ -165,87 +156,86 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
* the data and converts bytes into longwords for this routine.
*/
void
-MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
-{
- register UWORD32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) {
+ register UWORD32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
#endif
diff --git a/md5_utils.h b/md5_utils.h
index 5ca1b5f28..81792c4af 100644
--- a/md5_utils.h
+++ b/md5_utils.h
@@ -27,11 +27,10 @@
#define UWORD32 unsigned int
typedef struct MD5Context MD5Context;
-struct MD5Context
-{
- UWORD32 buf[4];
- UWORD32 bytes[2];
- UWORD32 in[16];
+struct MD5Context {
+ UWORD32 buf[4];
+ UWORD32 bytes[2];
+ UWORD32 in[16];
};
void MD5Init(struct MD5Context *context);
diff --git a/test/acm_random.h b/test/acm_random.h
index 81f764abe..dcd1bba8c 100644
--- a/test/acm_random.h
+++ b/test/acm_random.h
@@ -19,17 +19,29 @@ namespace libvpx_test {
class ACMRandom {
public:
- explicit ACMRandom(int seed) { Reset(seed); }
+ explicit ACMRandom(int seed) {
+ Reset(seed);
+ }
- void Reset(int seed) { srand(seed); }
+ void Reset(int seed) {
+ srand(seed);
+ }
- uint8_t Rand8(void) { return (rand() >> 8) & 0xff; }
+ uint8_t Rand8(void) {
+ return (rand() >> 8) & 0xff;
+ }
- int PseudoUniform(int range) { return (rand() >> 8) % range; }
+ int PseudoUniform(int range) {
+ return (rand() >> 8) % range;
+ }
- int operator()(int n) { return PseudoUniform(n); }
+ int operator()(int n) {
+ return PseudoUniform(n);
+ }
- static int DeterministicSeed(void) { return 0xbaba; }
+ static int DeterministicSeed(void) {
+ return 0xbaba;
+ }
};
} // namespace libvpx_test
diff --git a/test/boolcoder_test.cc b/test/boolcoder_test.cc
index 4c93b1686..758c8c3e5 100644
--- a/test/boolcoder_test.cc
+++ b/test/boolcoder_test.cc
@@ -38,15 +38,15 @@ TEST(VP8, TestBitIO) {
for (int i = 0; i < bits_to_test; ++i) {
const int parity = i & 1;
probas[i] =
- (method == 0) ? 0 : (method == 1) ? 255 :
- (method == 2) ? 128 :
- (method == 3) ? rnd.Rand8() :
- (method == 4) ? (parity ? 0 : 255) :
+ (method == 0) ? 0 : (method == 1) ? 255 :
+ (method == 2) ? 128 :
+ (method == 3) ? rnd.Rand8() :
+ (method == 4) ? (parity ? 0 : 255) :
// alternate between low and high proba:
(method == 5) ? (parity ? rnd(128) : 255 - rnd(128)) :
(method == 6) ?
- (parity ? rnd(64) : 255 - rnd(64)) :
- (parity ? rnd(32) : 255 - rnd(32));
+ (parity ? rnd(64) : 255 - rnd(64)) :
+ (parity ? rnd(32) : 255 - rnd(32));
}
for (int bit_method = 0; bit_method <= 3; ++bit_method) {
const int random_seed = 6432;
@@ -78,7 +78,7 @@ TEST(VP8, TestBitIO) {
bit = bit_rnd(2);
}
GTEST_ASSERT_EQ(vp8dx_decode_bool(&br, probas[i]), bit)
- << "pos: "<< i << " / " << bits_to_test
+ << "pos: " << i << " / " << bits_to_test
<< " bit_method: " << bit_method
<< " method: " << method;
}
diff --git a/test/test_libvpx.cc b/test/test_libvpx.cc
index 9b9e08c86..924aa2e2e 100644
--- a/test/test_libvpx.cc
+++ b/test/test_libvpx.cc
@@ -16,8 +16,7 @@ extern "C" {
#endif
#include "third_party/googletest/src/include/gtest/gtest.h"
-static void append_gtest_filter(const char *str)
-{
+static void append_gtest_filter(const char *str) {
std::string filter = ::testing::FLAGS_gtest_filter;
filter += str;
::testing::FLAGS_gtest_filter = filter;
@@ -28,17 +27,17 @@ int main(int argc, char **argv) {
#if ARCH_X86 || ARCH_X86_64
int simd_caps = x86_simd_caps();
- if(!(simd_caps & HAS_MMX))
+ if (!(simd_caps & HAS_MMX))
append_gtest_filter(":-MMX/*");
- if(!(simd_caps & HAS_SSE))
+ if (!(simd_caps & HAS_SSE))
append_gtest_filter(":-SSE/*");
- if(!(simd_caps & HAS_SSE2))
+ if (!(simd_caps & HAS_SSE2))
append_gtest_filter(":-SSE2/*");
- if(!(simd_caps & HAS_SSE3))
+ if (!(simd_caps & HAS_SSE3))
append_gtest_filter(":-SSE3/*");
- if(!(simd_caps & HAS_SSSE3))
+ if (!(simd_caps & HAS_SSSE3))
append_gtest_filter(":-SSSE3/*");
- if(!(simd_caps & HAS_SSE4_1))
+ if (!(simd_caps & HAS_SSE4_1))
append_gtest_filter(":-SSE4_1/*");
#endif
diff --git a/tools_common.c b/tools_common.c
index d188bbe20..fddf8611c 100644
--- a/tools_common.c
+++ b/tools_common.c
@@ -14,11 +14,10 @@
#include <fcntl.h>
#endif
-FILE* set_binary_mode(FILE *stream)
-{
- (void)stream;
+FILE *set_binary_mode(FILE *stream) {
+ (void)stream;
#ifdef _WIN32
- _setmode(_fileno(stream), _O_BINARY);
+ _setmode(_fileno(stream), _O_BINARY);
#endif
- return stream;
+ return stream;
}
diff --git a/tools_common.h b/tools_common.h
index 80c974732..9e56149a5 100644
--- a/tools_common.h
+++ b/tools_common.h
@@ -11,6 +11,6 @@
#define TOOLS_COMMON_H
/* Sets a stdio stream into binary mode */
-FILE* set_binary_mode(FILE *stream);
+FILE *set_binary_mode(FILE *stream);
#endif
diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c
index 5c7aa2e5e..7495d5e42 100644
--- a/vp8/common/alloccommon.c
+++ b/vp8/common/alloccommon.c
@@ -21,224 +21,204 @@
extern void vp8_init_scan_order_mask();
-static void update_mode_info_border( VP8_COMMON *cpi, MODE_INFO *mi_base )
-{
- int stride = cpi->mode_info_stride;
- int i;
-
- // Clear down top border row
- vpx_memset(mi_base, 0, sizeof(MODE_INFO) * cpi->mode_info_stride);
-
- // Clear left border column
- for (i = 1; i < cpi->mb_rows+1; i++)
- {
- vpx_memset(&mi_base[i*stride], 0, sizeof(MODE_INFO));
- }
+static void update_mode_info_border(VP8_COMMON *cpi, MODE_INFO *mi_base) {
+ int stride = cpi->mode_info_stride;
+ int i;
+
+ // Clear down top border row
+ vpx_memset(mi_base, 0, sizeof(MODE_INFO) * cpi->mode_info_stride);
+
+ // Clear left border column
+ for (i = 1; i < cpi->mb_rows + 1; i++) {
+ vpx_memset(&mi_base[i * stride], 0, sizeof(MODE_INFO));
+ }
}
-static void update_mode_info_in_image( VP8_COMMON *cpi, MODE_INFO *mi )
-{
- int i, j;
-
- // For each in image mode_info element set the in image flag to 1
- for (i = 0; i < cpi->mb_rows; i++)
- {
- for (j = 0; j < cpi->mb_cols; j++)
- {
- mi->mbmi.mb_in_image = 1;
- mi++; // Next element in the row
- }
-
- mi++; // Step over border element at start of next row
+static void update_mode_info_in_image(VP8_COMMON *cpi, MODE_INFO *mi) {
+ int i, j;
+
+ // For each in image mode_info element set the in image flag to 1
+ for (i = 0; i < cpi->mb_rows; i++) {
+ for (j = 0; j < cpi->mb_cols; j++) {
+ mi->mbmi.mb_in_image = 1;
+ mi++; // Next element in the row
}
+
+ mi++; // Step over border element at start of next row
+ }
}
-void vp8_de_alloc_frame_buffers(VP8_COMMON *oci)
-{
- int i;
+void vp8_de_alloc_frame_buffers(VP8_COMMON *oci) {
+ int i;
- for (i = 0; i < NUM_YV12_BUFFERS; i++)
- vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]);
+ for (i = 0; i < NUM_YV12_BUFFERS; i++)
+ vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]);
- vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
- vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
+ vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
+ vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
- vpx_free(oci->above_context);
- vpx_free(oci->mip);
- vpx_free(oci->prev_mip);
+ vpx_free(oci->above_context);
+ vpx_free(oci->mip);
+ vpx_free(oci->prev_mip);
- oci->above_context = 0;
- oci->mip = 0;
- oci->prev_mip = 0;
+ oci->above_context = 0;
+ oci->mip = 0;
+ oci->prev_mip = 0;
}
-int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
-{
- int i;
+int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) {
+ int i;
- vp8_de_alloc_frame_buffers(oci);
+ vp8_de_alloc_frame_buffers(oci);
- /* our internal buffers are always multiples of 16 */
- if ((width & 0xf) != 0)
- width += 16 - (width & 0xf);
+ /* our internal buffers are always multiples of 16 */
+ if ((width & 0xf) != 0)
+ width += 16 - (width & 0xf);
- if ((height & 0xf) != 0)
- height += 16 - (height & 0xf);
+ if ((height & 0xf) != 0)
+ height += 16 - (height & 0xf);
- for (i = 0; i < NUM_YV12_BUFFERS; i++)
- {
- oci->fb_idx_ref_cnt[i] = 0;
- oci->yv12_fb[i].flags = 0;
- if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ for (i = 0; i < NUM_YV12_BUFFERS; i++) {
+ oci->fb_idx_ref_cnt[i] = 0;
+ oci->yv12_fb[i].flags = 0;
+ if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
}
+ }
- oci->new_fb_idx = 0;
- oci->lst_fb_idx = 1;
- oci->gld_fb_idx = 2;
- oci->alt_fb_idx = 3;
+ oci->new_fb_idx = 0;
+ oci->lst_fb_idx = 1;
+ oci->gld_fb_idx = 2;
+ oci->alt_fb_idx = 3;
- oci->fb_idx_ref_cnt[0] = 1;
- oci->fb_idx_ref_cnt[1] = 1;
- oci->fb_idx_ref_cnt[2] = 1;
- oci->fb_idx_ref_cnt[3] = 1;
+ oci->fb_idx_ref_cnt[0] = 1;
+ oci->fb_idx_ref_cnt[1] = 1;
+ oci->fb_idx_ref_cnt[2] = 1;
+ oci->fb_idx_ref_cnt[3] = 1;
- if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, VP8BORDERINPIXELS) < 0)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, VP8BORDERINPIXELS) < 0) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
+ }
- if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
+ }
- oci->mb_rows = height >> 4;
- oci->mb_cols = width >> 4;
- oci->MBs = oci->mb_rows * oci->mb_cols;
- oci->mode_info_stride = oci->mb_cols + 1;
- oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
+ oci->mb_rows = height >> 4;
+ oci->mb_cols = width >> 4;
+ oci->MBs = oci->mb_rows * oci->mb_cols;
+ oci->mode_info_stride = oci->mb_cols + 1;
+ oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
- if (!oci->mip)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ if (!oci->mip) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
+ }
- oci->mi = oci->mip + oci->mode_info_stride + 1;
+ oci->mi = oci->mip + oci->mode_info_stride + 1;
- /* allocate memory for last frame MODE_INFO array */
+ /* allocate memory for last frame MODE_INFO array */
- oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
+ oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
- if (!oci->prev_mip)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ if (!oci->prev_mip) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
+ }
- oci->prev_mi = oci->prev_mip + oci->mode_info_stride + 1;
+ oci->prev_mi = oci->prev_mip + oci->mode_info_stride + 1;
- oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_cols, 1);
+ oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_cols, 1);
- if (!oci->above_context)
- {
- vp8_de_alloc_frame_buffers(oci);
- return 1;
- }
+ if (!oci->above_context) {
+ vp8_de_alloc_frame_buffers(oci);
+ return 1;
+ }
- update_mode_info_border(oci, oci->mip);
- update_mode_info_in_image(oci, oci->mi);
+ update_mode_info_border(oci, oci->mip);
+ update_mode_info_in_image(oci, oci->mi);
- return 0;
+ return 0;
}
-void vp8_setup_version(VP8_COMMON *cm)
-{
- if (cm->version & 0x4)
- {
- if (!CONFIG_EXPERIMENTAL)
- vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
- "Bitstream was created by an experimental "
- "encoder");
- cm->experimental = 1;
- }
-
- switch (cm->version & 0x3)
- {
+void vp8_setup_version(VP8_COMMON *cm) {
+ if (cm->version & 0x4) {
+ if (!CONFIG_EXPERIMENTAL)
+ vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
+ "Bitstream was created by an experimental "
+ "encoder");
+ cm->experimental = 1;
+ }
+
+ switch (cm->version & 0x3) {
case 0:
- cm->no_lpf = 0;
- cm->filter_type = NORMAL_LOOPFILTER;
- cm->use_bilinear_mc_filter = 0;
- cm->full_pixel = 0;
- break;
+ cm->no_lpf = 0;
+ cm->filter_type = NORMAL_LOOPFILTER;
+ cm->use_bilinear_mc_filter = 0;
+ cm->full_pixel = 0;
+ break;
case 1:
- cm->no_lpf = 0;
- cm->filter_type = SIMPLE_LOOPFILTER;
- cm->use_bilinear_mc_filter = 1;
- cm->full_pixel = 0;
- break;
+ cm->no_lpf = 0;
+ cm->filter_type = SIMPLE_LOOPFILTER;
+ cm->use_bilinear_mc_filter = 1;
+ cm->full_pixel = 0;
+ break;
case 2:
case 3:
- cm->no_lpf = 1;
- cm->filter_type = NORMAL_LOOPFILTER;
- cm->use_bilinear_mc_filter = 1;
- cm->full_pixel = 0;
- break;
- // Full pel only code deprecated in experimental code base
- //case 3:
- // cm->no_lpf = 1;
- // cm->filter_type = SIMPLE_LOOPFILTER;
- // cm->use_bilinear_mc_filter = 1;
- // cm->full_pixel = 1;
- // break;
- }
+ cm->no_lpf = 1;
+ cm->filter_type = NORMAL_LOOPFILTER;
+ cm->use_bilinear_mc_filter = 1;
+ cm->full_pixel = 0;
+ break;
+ // Full pel only code deprecated in experimental code base
+ // case 3:
+ // cm->no_lpf = 1;
+ // cm->filter_type = SIMPLE_LOOPFILTER;
+ // cm->use_bilinear_mc_filter = 1;
+ // cm->full_pixel = 1;
+ // break;
+ }
}
-void vp8_create_common(VP8_COMMON *oci)
-{
- vp8_machine_specific_config(oci);
-
- vp8_init_mbmode_probs(oci);
-
- vp8_default_bmode_probs(oci->fc.bmode_prob);
-
- oci->txfm_mode = ONLY_4X4;
- oci->mb_no_coeff_skip = 1;
- oci->comp_pred_mode = HYBRID_PREDICTION;
- oci->no_lpf = 0;
- oci->filter_type = NORMAL_LOOPFILTER;
- oci->use_bilinear_mc_filter = 0;
- oci->full_pixel = 0;
- oci->clr_type = REG_YUV;
- oci->clamp_type = RECON_CLAMP_REQUIRED;
-
- /* Initialise reference frame sign bias structure to defaults */
- vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
-
- /* Default disable buffer to buffer copying */
- oci->copy_buffer_to_gf = 0;
- oci->copy_buffer_to_arf = 0;
- oci->kf_ymode_probs_update = 0;
+void vp8_create_common(VP8_COMMON *oci) {
+ vp8_machine_specific_config(oci);
+
+ vp8_init_mbmode_probs(oci);
+
+ vp8_default_bmode_probs(oci->fc.bmode_prob);
+
+ oci->txfm_mode = ONLY_4X4;
+ oci->mb_no_coeff_skip = 1;
+ oci->comp_pred_mode = HYBRID_PREDICTION;
+ oci->no_lpf = 0;
+ oci->filter_type = NORMAL_LOOPFILTER;
+ oci->use_bilinear_mc_filter = 0;
+ oci->full_pixel = 0;
+ oci->clr_type = REG_YUV;
+ oci->clamp_type = RECON_CLAMP_REQUIRED;
+
+ /* Initialise reference frame sign bias structure to defaults */
+ vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
+
+ /* Default disable buffer to buffer copying */
+ oci->copy_buffer_to_gf = 0;
+ oci->copy_buffer_to_arf = 0;
+ oci->kf_ymode_probs_update = 0;
}
-void vp8_remove_common(VP8_COMMON *oci)
-{
- vp8_de_alloc_frame_buffers(oci);
+void vp8_remove_common(VP8_COMMON *oci) {
+ vp8_de_alloc_frame_buffers(oci);
}
-void vp8_initialize_common()
-{
- vp8_coef_tree_initialize();
+void vp8_initialize_common() {
+ vp8_coef_tree_initialize();
- vp8_entropy_mode_init();
+ vp8_entropy_mode_init();
- vp8_entropy_mv_init();
+ vp8_entropy_mv_init();
- vp8_init_scan_order_mask();
+ vp8_init_scan_order_mask();
}
diff --git a/vp8/common/arm/arm_systemdependent.c b/vp8/common/arm/arm_systemdependent.c
index 72f044ab6..5fd5f5b1b 100644
--- a/vp8/common/arm/arm_systemdependent.c
+++ b/vp8/common/arm/arm_systemdependent.c
@@ -19,98 +19,94 @@
#include "vp8/common/idct.h"
#include "vp8/common/onyxc_int.h"
-void vp8_arch_arm_common_init(VP8_COMMON *ctx)
-{
+void vp8_arch_arm_common_init(VP8_COMMON *ctx) {
#if CONFIG_RUNTIME_CPU_DETECT
- VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
- int flags = arm_cpu_caps();
- rtcd->flags = flags;
+ VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
+ int flags = arm_cpu_caps();
+ rtcd->flags = flags;
- /* Override default functions with fastest ones for this CPU. */
+ /* Override default functions with fastest ones for this CPU. */
#if HAVE_ARMV5TE
- if (flags & HAS_EDSP)
- {
- }
+ if (flags & HAS_EDSP) {
+ }
#endif
// The commented functions need to be re-written for vpx.
#if HAVE_ARMV6
- if (flags & HAS_MEDIA)
- {
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_armv6;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_armv6;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_armv6;
- rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_armv6;
+ if (flags & HAS_MEDIA) {
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_armv6;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_armv6;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_armv6;
+ rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_armv6;
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_armv6;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_armv6;
- rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_armv6;
- rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_armv6;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_armv6;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_armv6;
+ rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_armv6;
+ rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_armv6;
- //rtcd->idct.idct1 = vp8_short_idct4x4llm_1_v6;
- //rtcd->idct.idct16 = vp8_short_idct4x4llm_v6_dual;
- //rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_v6;
- //rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_v6;
+ // rtcd->idct.idct1 = vp8_short_idct4x4llm_1_v6;
+ // rtcd->idct.idct16 = vp8_short_idct4x4llm_v6_dual;
+ // rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_v6;
+ // rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_v6;
- rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_armv6;
- rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_armv6;
- rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_armv6;
- rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_armv6;
- rtcd->loopfilter.simple_mb_v =
- vp8_loop_filter_simple_vertical_edge_armv6;
- rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_armv6;
- rtcd->loopfilter.simple_mb_h =
- vp8_loop_filter_simple_horizontal_edge_armv6;
- rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_armv6;
+ rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_armv6;
+ rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_armv6;
+ rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_armv6;
+ rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_armv6;
+ rtcd->loopfilter.simple_mb_v =
+ vp8_loop_filter_simple_vertical_edge_armv6;
+ rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_armv6;
+ rtcd->loopfilter.simple_mb_h =
+ vp8_loop_filter_simple_horizontal_edge_armv6;
+ rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_armv6;
- rtcd->recon.copy16x16 = vp8_copy_mem16x16_v6;
- rtcd->recon.copy8x8 = vp8_copy_mem8x8_v6;
- rtcd->recon.copy8x4 = vp8_copy_mem8x4_v6;
- rtcd->recon.recon = vp8_recon_b_armv6;
- rtcd->recon.recon2 = vp8_recon2b_armv6;
- rtcd->recon.recon4 = vp8_recon4b_armv6;
- }
+ rtcd->recon.copy16x16 = vp8_copy_mem16x16_v6;
+ rtcd->recon.copy8x8 = vp8_copy_mem8x8_v6;
+ rtcd->recon.copy8x4 = vp8_copy_mem8x4_v6;
+ rtcd->recon.recon = vp8_recon_b_armv6;
+ rtcd->recon.recon2 = vp8_recon2b_armv6;
+ rtcd->recon.recon4 = vp8_recon4b_armv6;
+ }
#endif
#if HAVE_ARMV7
- if (flags & HAS_NEON)
- {
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_neon;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_neon;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_neon;
- rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_neon;
+ if (flags & HAS_NEON) {
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_neon;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_neon;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_neon;
+ rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_neon;
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_neon;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_neon;
- rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_neon;
- rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_neon;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_neon;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_neon;
+ rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_neon;
+ rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_neon;
- //rtcd->idct.idct1 = vp8_short_idct4x4llm_1_neon;
- //rtcd->idct.idct16 = vp8_short_idct4x4llm_neon;
- //rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_neon;
- //rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_neon;
+ // rtcd->idct.idct1 = vp8_short_idct4x4llm_1_neon;
+ // rtcd->idct.idct16 = vp8_short_idct4x4llm_neon;
+ // rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_neon;
+ // rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_neon;
- rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_neon;
- rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_neon;
- rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_neon;
- rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_neon;
- rtcd->loopfilter.simple_mb_v = vp8_loop_filter_mbvs_neon;
- rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_neon;
- rtcd->loopfilter.simple_mb_h = vp8_loop_filter_mbhs_neon;
- rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_neon;
+ rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_neon;
+ rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_neon;
+ rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_neon;
+ rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_neon;
+ rtcd->loopfilter.simple_mb_v = vp8_loop_filter_mbvs_neon;
+ rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_neon;
+ rtcd->loopfilter.simple_mb_h = vp8_loop_filter_mbhs_neon;
+ rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_neon;
- rtcd->recon.copy16x16 = vp8_copy_mem16x16_neon;
- rtcd->recon.copy8x8 = vp8_copy_mem8x8_neon;
- rtcd->recon.copy8x4 = vp8_copy_mem8x4_neon;
- rtcd->recon.recon = vp8_recon_b_neon;
- rtcd->recon.recon2 = vp8_recon2b_neon;
- rtcd->recon.recon4 = vp8_recon4b_neon;
- rtcd->recon.recon_mb = vp8_recon_mb_neon;
- rtcd->recon.build_intra_predictors_mby =
- vp8_build_intra_predictors_mby_neon;
- rtcd->recon.build_intra_predictors_mby_s =
- vp8_build_intra_predictors_mby_s_neon;
- }
+ rtcd->recon.copy16x16 = vp8_copy_mem16x16_neon;
+ rtcd->recon.copy8x8 = vp8_copy_mem8x8_neon;
+ rtcd->recon.copy8x4 = vp8_copy_mem8x4_neon;
+ rtcd->recon.recon = vp8_recon_b_neon;
+ rtcd->recon.recon2 = vp8_recon2b_neon;
+ rtcd->recon.recon4 = vp8_recon4b_neon;
+ rtcd->recon.recon_mb = vp8_recon_mb_neon;
+ rtcd->recon.build_intra_predictors_mby =
+ vp8_build_intra_predictors_mby_neon;
+ rtcd->recon.build_intra_predictors_mby_s =
+ vp8_build_intra_predictors_mby_s_neon;
+ }
#endif
#endif
diff --git a/vp8/common/arm/bilinearfilter_arm.c b/vp8/common/arm/bilinearfilter_arm.c
index 7340e20f3..a49f13b9e 100644
--- a/vp8/common/arm/bilinearfilter_arm.c
+++ b/vp8/common/arm/bilinearfilter_arm.c
@@ -16,98 +16,93 @@
void vp8_filter_block2d_bil_armv6
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- unsigned int src_pitch,
- unsigned int dst_pitch,
- const short *HFilter,
- const short *VFilter,
- int Width,
- int Height
-)
-{
- unsigned short FData[36*16]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- vp8_filter_block2d_bil_first_pass_armv6(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
-
- /* then 1-D vertically... */
- vp8_filter_block2d_bil_second_pass_armv6(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ unsigned int src_pitch,
+ unsigned int dst_pitch,
+ const short *HFilter,
+ const short *VFilter,
+ int Width,
+ int Height
+) {
+ unsigned short FData[36 * 16]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ vp8_filter_block2d_bil_first_pass_armv6(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
+
+ /* then 1-D vertically... */
+ vp8_filter_block2d_bil_second_pass_armv6(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
}
void vp8_bilinear_predict4x4_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
}
void vp8_bilinear_predict8x8_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
}
void vp8_bilinear_predict8x4_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
}
void vp8_bilinear_predict16x16_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
}
diff --git a/vp8/common/arm/bilinearfilter_arm.h b/vp8/common/arm/bilinearfilter_arm.h
index b7155d3f0..1e0d6d231 100644
--- a/vp8/common/arm/bilinearfilter_arm.h
+++ b/vp8/common/arm/bilinearfilter_arm.h
@@ -14,22 +14,22 @@
extern void vp8_filter_block2d_bil_first_pass_armv6
(
- const unsigned char *src_ptr,
- unsigned short *dst_ptr,
- unsigned int src_pitch,
- unsigned int height,
- unsigned int width,
- const short *vp8_filter
+ const unsigned char *src_ptr,
+ unsigned short *dst_ptr,
+ unsigned int src_pitch,
+ unsigned int height,
+ unsigned int width,
+ const short *vp8_filter
);
extern void vp8_filter_block2d_bil_second_pass_armv6
(
- const unsigned short *src_ptr,
- unsigned char *dst_ptr,
- int dst_pitch,
- unsigned int height,
- unsigned int width,
- const short *vp8_filter
+ const unsigned short *src_ptr,
+ unsigned char *dst_ptr,
+ int dst_pitch,
+ unsigned int height,
+ unsigned int width,
+ const short *vp8_filter
);
#endif /* BILINEARFILTER_ARM_H */
diff --git a/vp8/common/arm/filter_arm.c b/vp8/common/arm/filter_arm.c
index 6582fb29a..a53066836 100644
--- a/vp8/common/arm/filter_arm.c
+++ b/vp8/common/arm/filter_arm.c
@@ -17,205 +17,182 @@
extern void vp8_filter_block2d_first_pass_armv6
(
- unsigned char *src_ptr,
- short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int output_width,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int output_width,
+ unsigned int output_height,
+ const short *vp8_filter
);
// 8x8
extern void vp8_filter_block2d_first_pass_8x8_armv6
(
- unsigned char *src_ptr,
- short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int output_width,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int output_width,
+ unsigned int output_height,
+ const short *vp8_filter
);
// 16x16
extern void vp8_filter_block2d_first_pass_16x16_armv6
(
- unsigned char *src_ptr,
- short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int output_width,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int output_width,
+ unsigned int output_height,
+ const short *vp8_filter
);
extern void vp8_filter_block2d_second_pass_armv6
(
- short *src_ptr,
- unsigned char *output_ptr,
- unsigned int output_pitch,
- unsigned int cnt,
- const short *vp8_filter
+ short *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int output_pitch,
+ unsigned int cnt,
+ const short *vp8_filter
);
extern void vp8_filter4_block2d_second_pass_armv6
(
- short *src_ptr,
- unsigned char *output_ptr,
- unsigned int output_pitch,
- unsigned int cnt,
- const short *vp8_filter
+ short *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int output_pitch,
+ unsigned int cnt,
+ const short *vp8_filter
);
extern void vp8_filter_block2d_first_pass_only_armv6
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int cnt,
- unsigned int output_pitch,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int cnt,
+ unsigned int output_pitch,
+ const short *vp8_filter
);
extern void vp8_filter_block2d_second_pass_only_armv6
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int cnt,
- unsigned int output_pitch,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int cnt,
+ unsigned int output_pitch,
+ const short *vp8_filter
);
#if HAVE_ARMV6
void vp8_sixtap_predict_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- DECLARE_ALIGNED_ARRAY(4, short, FData, 12*4); /* Temp data buffer used in filtering */
-
-
- HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
-
- /* Vfilter is null. First pass only */
- if (xoffset && !yoffset)
- {
- /*vp8_filter_block2d_first_pass_armv6 ( src_ptr, FData+2, src_pixels_per_line, 4, 4, HFilter );
- vp8_filter_block2d_second_pass_armv6 ( FData+2, dst_ptr, dst_pitch, 4, VFilter );*/
-
- vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 4, dst_pitch, HFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ DECLARE_ALIGNED_ARRAY(4, short, FData, 12 * 4); /* Temp data buffer used in filtering */
+
+
+ HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
+
+ /* Vfilter is null. First pass only */
+ if (xoffset && !yoffset) {
+ /*vp8_filter_block2d_first_pass_armv6 ( src_ptr, FData+2, src_pixels_per_line, 4, 4, HFilter );
+ vp8_filter_block2d_second_pass_armv6 ( FData+2, dst_ptr, dst_pitch, 4, VFilter );*/
+
+ vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 4, dst_pitch, HFilter);
+ }
+ /* Hfilter is null. Second pass only */
+ else if (!xoffset && yoffset) {
+ vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 4, dst_pitch, VFilter);
+ } else {
+ /* Vfilter is a 4 tap filter */
+ if (yoffset & 0x1) {
+ vp8_filter_block2d_first_pass_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 4, 7, HFilter);
+ vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 4, VFilter);
}
- /* Hfilter is null. Second pass only */
- else if (!xoffset && yoffset)
- {
- vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 4, dst_pitch, VFilter);
- }
- else
- {
- /* Vfilter is a 4 tap filter */
- if (yoffset & 0x1)
- {
- vp8_filter_block2d_first_pass_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 4, 7, HFilter);
- vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 4, VFilter);
- }
- /* Vfilter is 6 tap filter */
- else
- {
- vp8_filter_block2d_first_pass_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 4, 9, HFilter);
- vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 4, VFilter);
- }
+ /* Vfilter is 6 tap filter */
+ else {
+ vp8_filter_block2d_first_pass_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 4, 9, HFilter);
+ vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 4, VFilter);
}
+ }
}
void vp8_sixtap_predict8x8_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- DECLARE_ALIGNED_ARRAY(4, short, FData, 16*8); /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
-
- if (xoffset && !yoffset)
- {
- vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 8, dst_pitch, HFilter);
- }
- /* Hfilter is null. Second pass only */
- else if (!xoffset && yoffset)
- {
- vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 8, dst_pitch, VFilter);
- }
- else
- {
- if (yoffset & 0x1)
- {
- vp8_filter_block2d_first_pass_8x8_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 8, 11, HFilter);
- vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 8, VFilter);
- }
- else
- {
- vp8_filter_block2d_first_pass_8x8_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 8, 13, HFilter);
- vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 8, VFilter);
- }
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ DECLARE_ALIGNED_ARRAY(4, short, FData, 16 * 8); /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
+
+ if (xoffset && !yoffset) {
+ vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 8, dst_pitch, HFilter);
+ }
+ /* Hfilter is null. Second pass only */
+ else if (!xoffset && yoffset) {
+ vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 8, dst_pitch, VFilter);
+ } else {
+ if (yoffset & 0x1) {
+ vp8_filter_block2d_first_pass_8x8_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 8, 11, HFilter);
+ vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 8, VFilter);
+ } else {
+ vp8_filter_block2d_first_pass_8x8_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 8, 13, HFilter);
+ vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 8, VFilter);
}
+ }
}
void vp8_sixtap_predict16x16_armv6
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- DECLARE_ALIGNED_ARRAY(4, short, FData, 24*16); /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
-
- if (xoffset && !yoffset)
- {
- vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 16, dst_pitch, HFilter);
- }
- /* Hfilter is null. Second pass only */
- else if (!xoffset && yoffset)
- {
- vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 16, dst_pitch, VFilter);
- }
- else
- {
- if (yoffset & 0x1)
- {
- vp8_filter_block2d_first_pass_16x16_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 16, 19, HFilter);
- vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 16, VFilter);
- }
- else
- {
- vp8_filter_block2d_first_pass_16x16_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 16, 21, HFilter);
- vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 16, VFilter);
- }
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ DECLARE_ALIGNED_ARRAY(4, short, FData, 24 * 16); /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters[yoffset]; /* 6 tap */
+
+ if (xoffset && !yoffset) {
+ vp8_filter_block2d_first_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 16, dst_pitch, HFilter);
+ }
+ /* Hfilter is null. Second pass only */
+ else if (!xoffset && yoffset) {
+ vp8_filter_block2d_second_pass_only_armv6(src_ptr, dst_ptr, src_pixels_per_line, 16, dst_pitch, VFilter);
+ } else {
+ if (yoffset & 0x1) {
+ vp8_filter_block2d_first_pass_16x16_armv6(src_ptr - src_pixels_per_line, FData + 1, src_pixels_per_line, 16, 19, HFilter);
+ vp8_filter4_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 16, VFilter);
+ } else {
+ vp8_filter_block2d_first_pass_16x16_armv6(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 16, 21, HFilter);
+ vp8_filter_block2d_second_pass_armv6(FData + 2, dst_ptr, dst_pitch, 16, VFilter);
}
+ }
}
#endif
diff --git a/vp8/common/arm/loopfilter_arm.c b/vp8/common/arm/loopfilter_arm.c
index c841d455a..b620d43d4 100644
--- a/vp8/common/arm/loopfilter_arm.c
+++ b/vp8/common/arm/loopfilter_arm.c
@@ -22,10 +22,10 @@ extern prototype_loopfilter(vp8_mbloop_filter_vertical_edge_armv6);
#if HAVE_ARMV7
typedef void loopfilter_y_neon(unsigned char *src, int pitch,
- unsigned char blimit, unsigned char limit, unsigned char thresh);
+ unsigned char blimit, unsigned char limit, unsigned char thresh);
typedef void loopfilter_uv_neon(unsigned char *u, int pitch,
- unsigned char blimit, unsigned char limit, unsigned char thresh,
- unsigned char *v);
+ unsigned char blimit, unsigned char limit, unsigned char thresh,
+ unsigned char *v);
extern loopfilter_y_neon vp8_loop_filter_horizontal_edge_y_neon;
extern loopfilter_y_neon vp8_loop_filter_vertical_edge_y_neon;
@@ -42,74 +42,68 @@ extern loopfilter_uv_neon vp8_mbloop_filter_vertical_edge_uv_neon;
/*ARMV6 loopfilter functions*/
/* Horizontal MB filtering */
void vp8_loop_filter_mbh_armv6(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_horizontal_edge_armv6(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_horizontal_edge_armv6(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_horizontal_edge_armv6(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_horizontal_edge_armv6(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_horizontal_edge_armv6(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_horizontal_edge_armv6(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Vertical MB Filtering */
void vp8_loop_filter_mbv_armv6(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_vertical_edge_armv6(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_vertical_edge_armv6(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_vertical_edge_armv6(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_vertical_edge_armv6(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_vertical_edge_armv6(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_vertical_edge_armv6(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Horizontal B Filtering */
void vp8_loop_filter_bh_armv6(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_horizontal_edge_armv6(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_armv6(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_armv6(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_horizontal_edge_armv6(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_armv6(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_armv6(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_horizontal_edge_armv6(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_horizontal_edge_armv6(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_horizontal_edge_armv6(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_horizontal_edge_armv6(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
void vp8_loop_filter_bhs_armv6(unsigned char *y_ptr, int y_stride,
- const unsigned char *blimit)
-{
- vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 4 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 8 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 12 * y_stride, y_stride, blimit);
+ const unsigned char *blimit) {
+ vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 4 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 8 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_armv6(y_ptr + 12 * y_stride, y_stride, blimit);
}
/* Vertical B Filtering */
void vp8_loop_filter_bv_armv6(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_vertical_edge_armv6(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_armv6(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_armv6(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_vertical_edge_armv6(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_armv6(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_armv6(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_vertical_edge_armv6(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_vertical_edge_armv6(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_vertical_edge_armv6(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_vertical_edge_armv6(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
void vp8_loop_filter_bvs_armv6(unsigned char *y_ptr, int y_stride,
- const unsigned char *blimit)
-{
- vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 4, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 8, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 12, y_stride, blimit);
+ const unsigned char *blimit) {
+ vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 4, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 8, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_armv6(y_ptr + 12, y_stride, blimit);
}
#endif
@@ -117,60 +111,56 @@ void vp8_loop_filter_bvs_armv6(unsigned char *y_ptr, int y_stride,
/* NEON loopfilter functions */
/* Horizontal MB filtering */
void vp8_loop_filter_mbh_neon(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- unsigned char mblim = *lfi->mblim;
- unsigned char lim = *lfi->lim;
- unsigned char hev_thr = *lfi->hev_thr;
- vp8_mbloop_filter_horizontal_edge_y_neon(y_ptr, y_stride, mblim, lim, hev_thr);
-
- if (u_ptr)
- vp8_mbloop_filter_horizontal_edge_uv_neon(u_ptr, uv_stride, mblim, lim, hev_thr, v_ptr);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ unsigned char mblim = *lfi->mblim;
+ unsigned char lim = *lfi->lim;
+ unsigned char hev_thr = *lfi->hev_thr;
+ vp8_mbloop_filter_horizontal_edge_y_neon(y_ptr, y_stride, mblim, lim, hev_thr);
+
+ if (u_ptr)
+ vp8_mbloop_filter_horizontal_edge_uv_neon(u_ptr, uv_stride, mblim, lim, hev_thr, v_ptr);
}
/* Vertical MB Filtering */
void vp8_loop_filter_mbv_neon(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- unsigned char mblim = *lfi->mblim;
- unsigned char lim = *lfi->lim;
- unsigned char hev_thr = *lfi->hev_thr;
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ unsigned char mblim = *lfi->mblim;
+ unsigned char lim = *lfi->lim;
+ unsigned char hev_thr = *lfi->hev_thr;
- vp8_mbloop_filter_vertical_edge_y_neon(y_ptr, y_stride, mblim, lim, hev_thr);
+ vp8_mbloop_filter_vertical_edge_y_neon(y_ptr, y_stride, mblim, lim, hev_thr);
- if (u_ptr)
- vp8_mbloop_filter_vertical_edge_uv_neon(u_ptr, uv_stride, mblim, lim, hev_thr, v_ptr);
+ if (u_ptr)
+ vp8_mbloop_filter_vertical_edge_uv_neon(u_ptr, uv_stride, mblim, lim, hev_thr, v_ptr);
}
/* Horizontal B Filtering */
void vp8_loop_filter_bh_neon(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- unsigned char blim = *lfi->blim;
- unsigned char lim = *lfi->lim;
- unsigned char hev_thr = *lfi->hev_thr;
-
- vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 4 * y_stride, y_stride, blim, lim, hev_thr);
- vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 8 * y_stride, y_stride, blim, lim, hev_thr);
- vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 12 * y_stride, y_stride, blim, lim, hev_thr);
-
- if (u_ptr)
- vp8_loop_filter_horizontal_edge_uv_neon(u_ptr + 4 * uv_stride, uv_stride, blim, lim, hev_thr, v_ptr + 4 * uv_stride);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ unsigned char blim = *lfi->blim;
+ unsigned char lim = *lfi->lim;
+ unsigned char hev_thr = *lfi->hev_thr;
+
+ vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 4 * y_stride, y_stride, blim, lim, hev_thr);
+ vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 8 * y_stride, y_stride, blim, lim, hev_thr);
+ vp8_loop_filter_horizontal_edge_y_neon(y_ptr + 12 * y_stride, y_stride, blim, lim, hev_thr);
+
+ if (u_ptr)
+ vp8_loop_filter_horizontal_edge_uv_neon(u_ptr + 4 * uv_stride, uv_stride, blim, lim, hev_thr, v_ptr + 4 * uv_stride);
}
/* Vertical B Filtering */
void vp8_loop_filter_bv_neon(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- unsigned char blim = *lfi->blim;
- unsigned char lim = *lfi->lim;
- unsigned char hev_thr = *lfi->hev_thr;
-
- vp8_loop_filter_vertical_edge_y_neon(y_ptr + 4, y_stride, blim, lim, hev_thr);
- vp8_loop_filter_vertical_edge_y_neon(y_ptr + 8, y_stride, blim, lim, hev_thr);
- vp8_loop_filter_vertical_edge_y_neon(y_ptr + 12, y_stride, blim, lim, hev_thr);
-
- if (u_ptr)
- vp8_loop_filter_vertical_edge_uv_neon(u_ptr + 4, uv_stride, blim, lim, hev_thr, v_ptr + 4);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ unsigned char blim = *lfi->blim;
+ unsigned char lim = *lfi->lim;
+ unsigned char hev_thr = *lfi->hev_thr;
+
+ vp8_loop_filter_vertical_edge_y_neon(y_ptr + 4, y_stride, blim, lim, hev_thr);
+ vp8_loop_filter_vertical_edge_y_neon(y_ptr + 8, y_stride, blim, lim, hev_thr);
+ vp8_loop_filter_vertical_edge_y_neon(y_ptr + 12, y_stride, blim, lim, hev_thr);
+
+ if (u_ptr)
+ vp8_loop_filter_vertical_edge_uv_neon(u_ptr + 4, uv_stride, blim, lim, hev_thr, v_ptr + 4);
}
#endif
diff --git a/vp8/common/arm/neon/recon_neon.c b/vp8/common/arm/neon/recon_neon.c
index 09fd2a56f..a4f601642 100644
--- a/vp8/common/arm/neon/recon_neon.c
+++ b/vp8/common/arm/neon/recon_neon.c
@@ -15,15 +15,14 @@
extern void vp8_recon16x16mb_neon(unsigned char *pred_ptr, short *diff_ptr, unsigned char *dst_ptr, int ystride, unsigned char *udst_ptr, unsigned char *vdst_ptr);
-void vp8_recon_mb_neon(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- unsigned char *pred_ptr = &x->predictor[0];
- short *diff_ptr = &x->diff[0];
- unsigned char *dst_ptr = x->dst.y_buffer;
- unsigned char *udst_ptr = x->dst.u_buffer;
- unsigned char *vdst_ptr = x->dst.v_buffer;
- int ystride = x->dst.y_stride;
- /*int uv_stride = x->dst.uv_stride;*/
+void vp8_recon_mb_neon(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ unsigned char *pred_ptr = &x->predictor[0];
+ short *diff_ptr = &x->diff[0];
+ unsigned char *dst_ptr = x->dst.y_buffer;
+ unsigned char *udst_ptr = x->dst.u_buffer;
+ unsigned char *vdst_ptr = x->dst.v_buffer;
+ int ystride = x->dst.y_stride;
+ /*int uv_stride = x->dst.uv_stride;*/
- vp8_recon16x16mb_neon(pred_ptr, diff_ptr, dst_ptr, ystride, udst_ptr, vdst_ptr);
+ vp8_recon16x16mb_neon(pred_ptr, diff_ptr, dst_ptr, ystride, udst_ptr, vdst_ptr);
}
diff --git a/vp8/common/arm/reconintra_arm.c b/vp8/common/arm/reconintra_arm.c
index f8f4dca3e..814cabd20 100644
--- a/vp8/common/arm/reconintra_arm.c
+++ b/vp8/common/arm/reconintra_arm.c
@@ -17,46 +17,44 @@
#if HAVE_ARMV7
extern void vp8_build_intra_predictors_mby_neon_func(
- unsigned char *y_buffer,
- unsigned char *ypred_ptr,
- int y_stride,
- int mode,
- int Up,
- int Left);
-
-void vp8_build_intra_predictors_mby_neon(MACROBLOCKD *x)
-{
- unsigned char *y_buffer = x->dst.y_buffer;
- unsigned char *ypred_ptr = x->predictor;
- int y_stride = x->dst.y_stride;
- int mode = x->mode_info_context->mbmi.mode;
- int Up = x->up_available;
- int Left = x->left_available;
-
- vp8_build_intra_predictors_mby_neon_func(y_buffer, ypred_ptr, y_stride, mode, Up, Left);
+ unsigned char *y_buffer,
+ unsigned char *ypred_ptr,
+ int y_stride,
+ int mode,
+ int Up,
+ int Left);
+
+void vp8_build_intra_predictors_mby_neon(MACROBLOCKD *x) {
+ unsigned char *y_buffer = x->dst.y_buffer;
+ unsigned char *ypred_ptr = x->predictor;
+ int y_stride = x->dst.y_stride;
+ int mode = x->mode_info_context->mbmi.mode;
+ int Up = x->up_available;
+ int Left = x->left_available;
+
+ vp8_build_intra_predictors_mby_neon_func(y_buffer, ypred_ptr, y_stride, mode, Up, Left);
}
#endif
#if HAVE_ARMV7
extern void vp8_build_intra_predictors_mby_s_neon_func(
- unsigned char *y_buffer,
- unsigned char *ypred_ptr,
- int y_stride,
- int mode,
- int Up,
- int Left);
-
-void vp8_build_intra_predictors_mby_s_neon(MACROBLOCKD *x)
-{
- unsigned char *y_buffer = x->dst.y_buffer;
- unsigned char *ypred_ptr = x->predictor;
- int y_stride = x->dst.y_stride;
- int mode = x->mode_info_context->mbmi.mode;
- int Up = x->up_available;
- int Left = x->left_available;
-
- vp8_build_intra_predictors_mby_s_neon_func(y_buffer, ypred_ptr, y_stride, mode, Up, Left);
+ unsigned char *y_buffer,
+ unsigned char *ypred_ptr,
+ int y_stride,
+ int mode,
+ int Up,
+ int Left);
+
+void vp8_build_intra_predictors_mby_s_neon(MACROBLOCKD *x) {
+ unsigned char *y_buffer = x->dst.y_buffer;
+ unsigned char *ypred_ptr = x->predictor;
+ int y_stride = x->dst.y_stride;
+ int mode = x->mode_info_context->mbmi.mode;
+ int Up = x->up_available;
+ int Left = x->left_available;
+
+ vp8_build_intra_predictors_mby_s_neon_func(y_buffer, ypred_ptr, y_stride, mode, Up, Left);
}
#endif
diff --git a/vp8/common/blockd.c b/vp8/common/blockd.c
index 60ef31217..2793995a0 100644
--- a/vp8/common/blockd.c
+++ b/vp8/common/blockd.c
@@ -13,21 +13,17 @@
#include "vpx_mem/vpx_mem.h"
-const unsigned char vp8_block2left[25] =
-{
- 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
+const unsigned char vp8_block2left[25] = {
+ 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
};
-const unsigned char vp8_block2above[25] =
-{
- 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8
+const unsigned char vp8_block2above[25] = {
+ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8
};
-const unsigned char vp8_block2left_8x8[25] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 8
+const unsigned char vp8_block2left_8x8[25] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 8
};
-const unsigned char vp8_block2above_8x8[25] =
-{
- 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 8
+const unsigned char vp8_block2above_8x8[25] = {
+ 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 8
};
diff --git a/vp8/common/blockd.h b/vp8/common/blockd.h
index 26ac8262d..3c60b10ae 100644
--- a/vp8/common/blockd.h
+++ b/vp8/common/blockd.h
@@ -25,7 +25,7 @@ void vpx_log(const char *format, ...);
#define TRUE 1
#define FALSE 0
-//#define MODE_STATS
+// #define MODE_STATS
/*#define DCPRED 1*/
#define DCPREDSIMTHRESH 0
@@ -47,9 +47,8 @@ void vpx_log(const char *format, ...);
#define SEGMENT_DELTADATA 0
#define SEGMENT_ABSDATA 1
-typedef struct
-{
- int r, c;
+typedef struct {
+ int r, c;
} POS;
#define PLANE_TYPE_Y_NO_DC 0
@@ -59,12 +58,11 @@ typedef struct
typedef char ENTROPY_CONTEXT;
-typedef struct
-{
- ENTROPY_CONTEXT y1[4];
- ENTROPY_CONTEXT u[2];
- ENTROPY_CONTEXT v[2];
- ENTROPY_CONTEXT y2;
+typedef struct {
+ ENTROPY_CONTEXT y1[4];
+ ENTROPY_CONTEXT u[2];
+ ENTROPY_CONTEXT v[2];
+ ENTROPY_CONTEXT y2;
} ENTROPY_CONTEXT_PLANES;
extern const unsigned char vp8_block2left[25];
@@ -73,60 +71,56 @@ extern const unsigned char vp8_block2left_8x8[25];
extern const unsigned char vp8_block2above_8x8[25];
#define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \
- Dest = ((A)!=0) + ((B)!=0);
+ Dest = ((A)!=0) + ((B)!=0);
-typedef enum
-{
- KEY_FRAME = 0,
- INTER_FRAME = 1
+typedef enum {
+ KEY_FRAME = 0,
+ INTER_FRAME = 1
} FRAME_TYPE;
-typedef enum
-{
- DC_PRED, /* average of above and left pixels */
- V_PRED, /* vertical prediction */
- H_PRED, /* horizontal prediction */
+typedef enum {
+ DC_PRED, /* average of above and left pixels */
+ V_PRED, /* vertical prediction */
+ H_PRED, /* horizontal prediction */
#if CONFIG_NEWINTRAMODES
- D45_PRED, /* Directional 45 deg prediction [anti-clockwise from 0 deg hor] */
- D135_PRED, /* Directional 135 deg prediction [anti-clockwise from 0 deg hor] */
- D117_PRED, /* Directional 112 deg prediction [anti-clockwise from 0 deg hor] */
- D153_PRED, /* Directional 157 deg prediction [anti-clockwise from 0 deg hor] */
- D27_PRED, /* Directional 22 deg prediction [anti-clockwise from 0 deg hor] */
- D63_PRED, /* Directional 67 deg prediction [anti-clockwise from 0 deg hor] */
+ D45_PRED, /* Directional 45 deg prediction [anti-clockwise from 0 deg hor] */
+ D135_PRED, /* Directional 135 deg prediction [anti-clockwise from 0 deg hor] */
+ D117_PRED, /* Directional 112 deg prediction [anti-clockwise from 0 deg hor] */
+ D153_PRED, /* Directional 157 deg prediction [anti-clockwise from 0 deg hor] */
+ D27_PRED, /* Directional 22 deg prediction [anti-clockwise from 0 deg hor] */
+ D63_PRED, /* Directional 67 deg prediction [anti-clockwise from 0 deg hor] */
#endif
- TM_PRED, /* Truemotion prediction */
- I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */
- B_PRED, /* block based prediction, each block has its own prediction mode */
+ TM_PRED, /* Truemotion prediction */
+ I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */
+ B_PRED, /* block based prediction, each block has its own prediction mode */
- NEARESTMV,
- NEARMV,
- ZEROMV,
- NEWMV,
- SPLITMV,
+ NEARESTMV,
+ NEARMV,
+ ZEROMV,
+ NEWMV,
+ SPLITMV,
- MB_MODE_COUNT
+ MB_MODE_COUNT
} MB_PREDICTION_MODE;
// Segment level features.
-typedef enum
-{
- SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
- SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
- SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
- SEG_LVL_MODE = 3, // Optional Segment mode
- SEG_LVL_EOB = 4, // EOB end stop marker.
- SEG_LVL_TRANSFORM = 5, // Block transform size.
- SEG_LVL_MAX = 6 // Number of MB level features supported
+typedef enum {
+ SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
+ SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
+ SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
+ SEG_LVL_MODE = 3, // Optional Segment mode
+ SEG_LVL_EOB = 4, // EOB end stop marker.
+ SEG_LVL_TRANSFORM = 5, // Block transform size.
+ SEG_LVL_MAX = 6 // Number of MB level features supported
} SEG_LVL_FEATURES;
// Segment level features.
-typedef enum
-{
- TX_4X4 = 0, // 4x4 dct transform
- TX_8X8 = 1, // 8x8 dct transform
+typedef enum {
+ TX_4X4 = 0, // 4x4 dct transform
+ TX_8X8 = 1, // 8x8 dct transform
- TX_SIZE_MAX = 2 // Number of differnt transforms avaialble
+ TX_SIZE_MAX = 2 // Number of differnt transforms avaialble
} TX_SIZE;
@@ -136,28 +130,27 @@ typedef enum
#define VP8_MVREFS (1 + SPLITMV - NEARESTMV)
-typedef enum
-{
- B_DC_PRED, /* average of above and left pixels */
- B_TM_PRED,
+typedef enum {
+ B_DC_PRED, /* average of above and left pixels */
+ B_TM_PRED,
- B_VE_PRED, /* vertical prediction */
- B_HE_PRED, /* horizontal prediction */
+ B_VE_PRED, /* vertical prediction */
+ B_HE_PRED, /* horizontal prediction */
- B_LD_PRED,
- B_RD_PRED,
+ B_LD_PRED,
+ B_RD_PRED,
- B_VR_PRED,
- B_VL_PRED,
- B_HD_PRED,
- B_HU_PRED,
+ B_VR_PRED,
+ B_VL_PRED,
+ B_HD_PRED,
+ B_HU_PRED,
- LEFT4X4,
- ABOVE4X4,
- ZERO4X4,
- NEW4X4,
+ LEFT4X4,
+ ABOVE4X4,
+ ZERO4X4,
+ NEW4X4,
- B_MODE_COUNT
+ B_MODE_COUNT
} B_PREDICTION_MODE;
#define VP8_BINTRAMODES (B_HU_PRED + 1) /* 10 */
@@ -167,196 +160,190 @@ typedef enum
modes for the Y blocks to the left and above us; for interframes, there
is a single probability table. */
-union b_mode_info
-{
- struct {
- B_PREDICTION_MODE first;
+union b_mode_info {
+ struct {
+ B_PREDICTION_MODE first;
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE second;
+ B_PREDICTION_MODE second;
#endif
- } as_mode;
- struct {
- int_mv first;
- int_mv second;
- } as_mv;
+ } as_mode;
+ struct {
+ int_mv first;
+ int_mv second;
+ } as_mv;
};
-typedef enum
-{
- INTRA_FRAME = 0,
- LAST_FRAME = 1,
- GOLDEN_FRAME = 2,
- ALTREF_FRAME = 3,
- MAX_REF_FRAMES = 4
+typedef enum {
+ INTRA_FRAME = 0,
+ LAST_FRAME = 1,
+ GOLDEN_FRAME = 2,
+ ALTREF_FRAME = 3,
+ MAX_REF_FRAMES = 4
} MV_REFERENCE_FRAME;
-typedef struct
-{
- MB_PREDICTION_MODE mode, uv_mode;
+typedef struct {
+ MB_PREDICTION_MODE mode, uv_mode;
#if CONFIG_COMP_INTRA_PRED
- MB_PREDICTION_MODE second_mode, second_uv_mode;
+ MB_PREDICTION_MODE second_mode, second_uv_mode;
#endif
- MV_REFERENCE_FRAME ref_frame, second_ref_frame;
- TX_SIZE txfm_size;
- int_mv mv, second_mv;
- unsigned char partitioning;
- unsigned char mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
- unsigned char need_to_clamp_mvs;
- unsigned char need_to_clamp_secondmv;
- unsigned char segment_id; /* Which set of segmentation parameters should be used for this MB */
-
- // Flags used for prediction status of various bistream signals
- unsigned char seg_id_predicted;
- unsigned char ref_predicted;
-
- // Indicates if the mb is part of the image (1) vs border (0)
- // This can be useful in determining whether the MB provides
- // a valid predictor
- unsigned char mb_in_image;
+ MV_REFERENCE_FRAME ref_frame, second_ref_frame;
+ TX_SIZE txfm_size;
+ int_mv mv, second_mv;
+ unsigned char partitioning;
+ unsigned char mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
+ unsigned char need_to_clamp_mvs;
+ unsigned char need_to_clamp_secondmv;
+ unsigned char segment_id; /* Which set of segmentation parameters should be used for this MB */
+
+ // Flags used for prediction status of various bistream signals
+ unsigned char seg_id_predicted;
+ unsigned char ref_predicted;
+
+ // Indicates if the mb is part of the image (1) vs border (0)
+ // This can be useful in determining whether the MB provides
+ // a valid predictor
+ unsigned char mb_in_image;
#if CONFIG_PRED_FILTER
- // Flag to turn prediction signal filter on(1)/off(0 ) at the MB level
- unsigned int pred_filter_enabled;
+ // Flag to turn prediction signal filter on(1)/off(0 ) at the MB level
+ unsigned int pred_filter_enabled;
#endif
} MB_MODE_INFO;
-typedef struct
-{
- MB_MODE_INFO mbmi;
- union b_mode_info bmi[16];
+typedef struct {
+ MB_MODE_INFO mbmi;
+ union b_mode_info bmi[16];
} MODE_INFO;
-typedef struct
-{
- short *qcoeff;
- short *dqcoeff;
- unsigned char *predictor;
- short *diff;
- short *dequant;
+typedef struct {
+ short *qcoeff;
+ short *dqcoeff;
+ unsigned char *predictor;
+ short *diff;
+ short *dequant;
- /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
- unsigned char **base_pre;
- unsigned char **base_second_pre;
- int pre;
- int pre_stride;
+ /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
+ unsigned char **base_pre;
+ unsigned char **base_second_pre;
+ int pre;
+ int pre_stride;
- unsigned char **base_dst;
- int dst;
- int dst_stride;
+ unsigned char **base_dst;
+ int dst;
+ int dst_stride;
- int eob;
+ int eob;
- union b_mode_info bmi;
+ union b_mode_info bmi;
} BLOCKD;
-typedef struct MacroBlockD
-{
- DECLARE_ALIGNED(16, short, diff[400]); /* from idct diff */
- DECLARE_ALIGNED(16, unsigned char, predictor[384]);
- DECLARE_ALIGNED(16, short, qcoeff[400]);
- DECLARE_ALIGNED(16, short, dqcoeff[400]);
- DECLARE_ALIGNED(16, char, eobs[25]);
+typedef struct MacroBlockD {
+ DECLARE_ALIGNED(16, short, diff[400]); /* from idct diff */
+ DECLARE_ALIGNED(16, unsigned char, predictor[384]);
+ DECLARE_ALIGNED(16, short, qcoeff[400]);
+ DECLARE_ALIGNED(16, short, dqcoeff[400]);
+ DECLARE_ALIGNED(16, char, eobs[25]);
- /* 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries. */
- BLOCKD block[25];
- int fullpixel_mask;
+ /* 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries. */
+ BLOCKD block[25];
+ int fullpixel_mask;
- YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
- struct {
- uint8_t *y_buffer, *u_buffer, *v_buffer;
- } second_pre;
- YV12_BUFFER_CONFIG dst;
+ YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
+ struct {
+ uint8_t *y_buffer, *u_buffer, *v_buffer;
+ } second_pre;
+ YV12_BUFFER_CONFIG dst;
- MODE_INFO *prev_mode_info_context;
- MODE_INFO *mode_info_context;
- int mode_info_stride;
+ MODE_INFO *prev_mode_info_context;
+ MODE_INFO *mode_info_context;
+ int mode_info_stride;
- FRAME_TYPE frame_type;
+ FRAME_TYPE frame_type;
- int up_available;
- int left_available;
+ int up_available;
+ int left_available;
- /* Y,U,V,Y2 */
- ENTROPY_CONTEXT_PLANES *above_context;
- ENTROPY_CONTEXT_PLANES *left_context;
+ /* Y,U,V,Y2 */
+ ENTROPY_CONTEXT_PLANES *above_context;
+ ENTROPY_CONTEXT_PLANES *left_context;
- /* 0 indicates segmentation at MB level is not enabled. Otherwise the individual bits indicate which features are active. */
- unsigned char segmentation_enabled;
+ /* 0 indicates segmentation at MB level is not enabled. Otherwise the individual bits indicate which features are active. */
+ unsigned char segmentation_enabled;
- /* 0 (do not update) 1 (update) the macroblock segmentation map. */
- unsigned char update_mb_segmentation_map;
+ /* 0 (do not update) 1 (update) the macroblock segmentation map. */
+ unsigned char update_mb_segmentation_map;
- /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
- unsigned char update_mb_segmentation_data;
+ /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
+ unsigned char update_mb_segmentation_data;
- /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
- unsigned char mb_segment_abs_delta;
+ /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
+ unsigned char mb_segment_abs_delta;
- /* Per frame flags that define which MB level features (such as quantizer or loop filter level) */
- /* are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO */
+ /* Per frame flags that define which MB level features (such as quantizer or loop filter level) */
+ /* are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO */
- // Probability Tree used to code Segment number
- vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS];
+ // Probability Tree used to code Segment number
+ vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS];
- // Segment features
- signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
- unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
+ // Segment features
+ signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
+ unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
#if CONFIG_FEATUREUPDATES
- // keep around the last set so we can figure out what updates...
- unsigned int old_segment_feature_mask[MAX_MB_SEGMENTS];
- signed char old_segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
+ // keep around the last set so we can figure out what updates...
+ unsigned int old_segment_feature_mask[MAX_MB_SEGMENTS];
+ signed char old_segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
#endif
- /* mode_based Loop filter adjustment */
- unsigned char mode_ref_lf_delta_enabled;
- unsigned char mode_ref_lf_delta_update;
-
- /* Delta values have the range +/- MAX_LOOP_FILTER */
- signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */
- signed char ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */
- signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */
- signed char mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */
-
- /* Distance of MB away from frame edges */
- int mb_to_left_edge;
- int mb_to_right_edge;
- int mb_to_top_edge;
- int mb_to_bottom_edge;
-
- unsigned int frames_since_golden;
- unsigned int frames_till_alt_ref_frame;
- vp8_subpix_fn_t subpixel_predict;
- vp8_subpix_fn_t subpixel_predict8x4;
- vp8_subpix_fn_t subpixel_predict8x8;
- vp8_subpix_fn_t subpixel_predict16x16;
- vp8_subpix_fn_t subpixel_predict_avg;
- vp8_subpix_fn_t subpixel_predict_avg8x4;
- vp8_subpix_fn_t subpixel_predict_avg8x8;
- vp8_subpix_fn_t subpixel_predict_avg16x16;
+ /* mode_based Loop filter adjustment */
+ unsigned char mode_ref_lf_delta_enabled;
+ unsigned char mode_ref_lf_delta_update;
+
+ /* Delta values have the range +/- MAX_LOOP_FILTER */
+ signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */
+ signed char ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */
+ signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */
+ signed char mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */
+
+ /* Distance of MB away from frame edges */
+ int mb_to_left_edge;
+ int mb_to_right_edge;
+ int mb_to_top_edge;
+ int mb_to_bottom_edge;
+
+ unsigned int frames_since_golden;
+ unsigned int frames_till_alt_ref_frame;
+ vp8_subpix_fn_t subpixel_predict;
+ vp8_subpix_fn_t subpixel_predict8x4;
+ vp8_subpix_fn_t subpixel_predict8x8;
+ vp8_subpix_fn_t subpixel_predict16x16;
+ vp8_subpix_fn_t subpixel_predict_avg;
+ vp8_subpix_fn_t subpixel_predict_avg8x4;
+ vp8_subpix_fn_t subpixel_predict_avg8x8;
+ vp8_subpix_fn_t subpixel_predict_avg16x16;
#if CONFIG_HIGH_PRECISION_MV
- int allow_high_precision_mv;
+ int allow_high_precision_mv;
#endif /* CONFIG_HIGH_PRECISION_MV */
- void *current_bc;
+ void *current_bc;
- int corrupted;
+ int corrupted;
#if ARCH_X86 || ARCH_X86_64
- /* This is an intermediate buffer currently used in sub-pixel motion search
- * to keep a copy of the reference area. This buffer can be used for other
- * purpose.
- */
- DECLARE_ALIGNED(32, unsigned char, y_buf[22*32]);
+ /* This is an intermediate buffer currently used in sub-pixel motion search
+ * to keep a copy of the reference area. This buffer can be used for other
+ * purpose.
+ */
+ DECLARE_ALIGNED(32, unsigned char, y_buf[22 * 32]);
#endif
#if CONFIG_RUNTIME_CPU_DETECT
- struct VP8_COMMON_RTCD *rtcd;
+ struct VP8_COMMON_RTCD *rtcd;
#endif
- int mb_index; // Index of the MB in the SB (0..3)
+ int mb_index; // Index of the MB in the SB (0..3)
} MACROBLOCKD;
@@ -364,20 +351,17 @@ typedef struct MacroBlockD
extern void vp8_build_block_doffsets(MACROBLOCKD *x);
extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
-static void update_blockd_bmi(MACROBLOCKD *xd)
-{
- int i;
- int is_4x4;
- is_4x4 = (xd->mode_info_context->mbmi.mode == SPLITMV) ||
- (xd->mode_info_context->mbmi.mode == I8X8_PRED) ||
- (xd->mode_info_context->mbmi.mode == B_PRED);
-
- if (is_4x4)
- {
- for (i = 0; i < 16; i++)
- {
- xd->block[i].bmi = xd->mode_info_context->bmi[i];
- }
+static void update_blockd_bmi(MACROBLOCKD *xd) {
+ int i;
+ int is_4x4;
+ is_4x4 = (xd->mode_info_context->mbmi.mode == SPLITMV) ||
+ (xd->mode_info_context->mbmi.mode == I8X8_PRED) ||
+ (xd->mode_info_context->mbmi.mode == B_PRED);
+
+ if (is_4x4) {
+ for (i = 0; i < 16; i++) {
+ xd->block[i].bmi = xd->mode_info_context->bmi[i];
}
+ }
}
#endif /* __INC_BLOCKD_H */
diff --git a/vp8/common/common.h b/vp8/common/common.h
index 999f79f2f..c6e6fcb7c 100644
--- a/vp8/common/common.h
+++ b/vp8/common/common.h
@@ -23,16 +23,16 @@
/* Only need this for fixed-size arrays, for structs just assign. */
#define vp8_copy( Dest, Src) { \
- assert( sizeof( Dest) == sizeof( Src)); \
- vpx_memcpy( Dest, Src, sizeof( Src)); \
- }
+ assert( sizeof( Dest) == sizeof( Src)); \
+ vpx_memcpy( Dest, Src, sizeof( Src)); \
+ }
/* Use this for variably-sized arrays. */
#define vp8_copy_array( Dest, Src, N) { \
- assert( sizeof( *Dest) == sizeof( *Src)); \
- vpx_memcpy( Dest, Src, N * sizeof( *Src)); \
- }
+ assert( sizeof( *Dest) == sizeof( *Src)); \
+ vpx_memcpy( Dest, Src, N * sizeof( *Src)); \
+ }
#define vp8_zero( Dest) vpx_memset( &Dest, 0, sizeof( Dest));
diff --git a/vp8/common/context.c b/vp8/common/context.c
index 99e95d30f..27ad6a42d 100644
--- a/vp8/common/context.c
+++ b/vp8/common/context.c
@@ -16,384 +16,382 @@
#if 0
int Contexts[vp8_coef_counter_dimen];
-const int default_contexts[vp8_coef_counter_dimen] =
-{
- {
- // Block Type ( 0 )
- {
- // Coeff Band ( 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, 0, 0, 0, 0, 0,},
- },
- {
- // Coeff Band ( 1 )
- {30190, 26544, 225, 24, 4, 0, 0, 0, 0, 0, 0, 4171593,},
- {26846, 25157, 1241, 130, 26, 6, 1, 0, 0, 0, 0, 149987,},
- {10484, 9538, 1006, 160, 36, 18, 0, 0, 0, 0, 0, 15104,},
- },
- {
- // Coeff Band ( 2 )
- {25842, 40456, 1126, 83, 11, 2, 0, 0, 0, 0, 0, 0,},
- {9338, 8010, 512, 73, 7, 3, 2, 0, 0, 0, 0, 43294,},
- {1047, 751, 149, 31, 13, 6, 1, 0, 0, 0, 0, 879,},
- },
- {
- // Coeff Band ( 3 )
- {26136, 9826, 252, 13, 0, 0, 0, 0, 0, 0, 0, 0,},
- {8134, 5574, 191, 14, 2, 0, 0, 0, 0, 0, 0, 35302,},
- { 605, 677, 116, 9, 1, 0, 0, 0, 0, 0, 0, 611,},
- },
- {
- // Coeff Band ( 4 )
- {10263, 15463, 283, 17, 0, 0, 0, 0, 0, 0, 0, 0,},
- {2773, 2191, 128, 9, 2, 2, 0, 0, 0, 0, 0, 10073,},
- { 134, 125, 32, 4, 0, 2, 0, 0, 0, 0, 0, 50,},
- },
- {
- // Coeff Band ( 5 )
- {10483, 2663, 23, 1, 0, 0, 0, 0, 0, 0, 0, 0,},
- {2137, 1251, 27, 1, 1, 0, 0, 0, 0, 0, 0, 14362,},
- { 116, 156, 14, 2, 1, 0, 0, 0, 0, 0, 0, 190,},
- },
- {
- // Coeff Band ( 6 )
- {40977, 27614, 412, 28, 0, 0, 0, 0, 0, 0, 0, 0,},
- {6113, 5213, 261, 22, 3, 0, 0, 0, 0, 0, 0, 26164,},
- { 382, 312, 50, 14, 2, 0, 0, 0, 0, 0, 0, 345,},
- },
- {
- // Coeff Band ( 7 )
- { 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 319,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,},
- },
- },
- {
- // Block Type ( 1 )
- {
- // Coeff Band ( 0 )
- {3268, 19382, 1043, 250, 93, 82, 49, 26, 17, 8, 25, 82289,},
- {8758, 32110, 5436, 1832, 827, 668, 420, 153, 24, 0, 3, 52914,},
- {9337, 23725, 8487, 3954, 2107, 1836, 1069, 399, 59, 0, 0, 18620,},
- },
- {
- // Coeff Band ( 1 )
- {12419, 8420, 452, 62, 9, 1, 0, 0, 0, 0, 0, 0,},
- {11715, 8705, 693, 92, 15, 7, 2, 0, 0, 0, 0, 53988,},
- {7603, 8585, 2306, 778, 270, 145, 39, 5, 0, 0, 0, 9136,},
- },
- {
- // Coeff Band ( 2 )
- {15938, 14335, 1207, 184, 55, 13, 4, 1, 0, 0, 0, 0,},
- {7415, 6829, 1138, 244, 71, 26, 7, 0, 0, 0, 0, 9980,},
- {1580, 1824, 655, 241, 89, 46, 10, 2, 0, 0, 0, 429,},
- },
- {
- // Coeff Band ( 3 )
- {19453, 5260, 201, 19, 0, 0, 0, 0, 0, 0, 0, 0,},
- {9173, 3758, 213, 22, 1, 1, 0, 0, 0, 0, 0, 9820,},
- {1689, 1277, 276, 51, 17, 4, 0, 0, 0, 0, 0, 679,},
- },
- {
- // Coeff Band ( 4 )
- {12076, 10667, 620, 85, 19, 9, 5, 0, 0, 0, 0, 0,},
- {4665, 3625, 423, 55, 19, 9, 0, 0, 0, 0, 0, 5127,},
- { 415, 440, 143, 34, 20, 7, 2, 0, 0, 0, 0, 101,},
- },
- {
- // Coeff Band ( 5 )
- {12183, 4846, 115, 11, 1, 0, 0, 0, 0, 0, 0, 0,},
- {4226, 3149, 177, 21, 2, 0, 0, 0, 0, 0, 0, 7157,},
- { 375, 621, 189, 51, 11, 4, 1, 0, 0, 0, 0, 198,},
- },
- {
- // Coeff Band ( 6 )
- {61658, 37743, 1203, 94, 10, 3, 0, 0, 0, 0, 0, 0,},
- {15514, 11563, 903, 111, 14, 5, 0, 0, 0, 0, 0, 25195,},
- { 929, 1077, 291, 78, 14, 7, 1, 0, 0, 0, 0, 507,},
- },
- {
- // Coeff Band ( 7 )
- { 0, 990, 15, 3, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 0, 412, 13, 0, 0, 0, 0, 0, 0, 0, 0, 1641,},
- { 0, 18, 7, 1, 0, 0, 0, 0, 0, 0, 0, 30,},
- },
- },
- {
- // Block Type ( 2 )
- {
- // Coeff Band ( 0 )
- { 953, 24519, 628, 120, 28, 12, 4, 0, 0, 0, 0, 2248798,},
- {1525, 25654, 2647, 617, 239, 143, 42, 5, 0, 0, 0, 66837,},
- {1180, 11011, 3001, 1237, 532, 448, 239, 54, 5, 0, 0, 7122,},
- },
- {
- // Coeff Band ( 1 )
- {1356, 2220, 67, 10, 4, 1, 0, 0, 0, 0, 0, 0,},
- {1450, 2544, 102, 18, 4, 3, 0, 0, 0, 0, 0, 57063,},
- {1182, 2110, 470, 130, 41, 21, 0, 0, 0, 0, 0, 6047,},
- },
- {
- // Coeff Band ( 2 )
- { 370, 3378, 200, 30, 5, 4, 1, 0, 0, 0, 0, 0,},
- { 293, 1006, 131, 29, 11, 0, 0, 0, 0, 0, 0, 5404,},
- { 114, 387, 98, 23, 4, 8, 1, 0, 0, 0, 0, 236,},
- },
- {
- // Coeff Band ( 3 )
- { 579, 194, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 395, 213, 5, 1, 0, 0, 0, 0, 0, 0, 0, 4157,},
- { 119, 122, 4, 0, 0, 0, 0, 0, 0, 0, 0, 300,},
- },
- {
- // Coeff Band ( 4 )
- { 38, 557, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 21, 114, 12, 1, 0, 0, 0, 0, 0, 0, 0, 427,},
- { 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,},
- },
- {
- // Coeff Band ( 5 )
- { 52, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 18, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 652,},
- { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30,},
- },
- {
- // Coeff Band ( 6 )
- { 640, 569, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 25, 77, 2, 0, 0, 0, 0, 0, 0, 0, 0, 517,},
- { 4, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,},
- },
- {
- // Coeff Band ( 7 )
- { 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, 0, 0, 0, 0,},
- },
- },
- {
- // Block Type ( 3 )
- {
- // Coeff Band ( 0 )
- {2506, 20161, 2707, 767, 261, 178, 107, 30, 14, 3, 0, 100694,},
- {8806, 36478, 8817, 3268, 1280, 850, 401, 114, 42, 0, 0, 58572,},
- {11003, 27214, 11798, 5716, 2482, 2072, 1048, 175, 32, 0, 0, 19284,},
- },
- {
- // Coeff Band ( 1 )
- {9738, 11313, 959, 205, 70, 18, 11, 1, 0, 0, 0, 0,},
- {12628, 15085, 1507, 273, 52, 19, 9, 0, 0, 0, 0, 54280,},
- {10701, 15846, 5561, 1926, 813, 570, 249, 36, 0, 0, 0, 6460,},
- },
- {
- // Coeff Band ( 2 )
- {6781, 22539, 2784, 634, 182, 123, 20, 4, 0, 0, 0, 0,},
- {6263, 11544, 2649, 790, 259, 168, 27, 5, 0, 0, 0, 20539,},
- {3109, 4075, 2031, 896, 457, 386, 158, 29, 0, 0, 0, 1138,},
- },
- {
- // Coeff Band ( 3 )
- {11515, 4079, 465, 73, 5, 14, 2, 0, 0, 0, 0, 0,},
- {9361, 5834, 650, 96, 24, 8, 4, 0, 0, 0, 0, 22181,},
- {4343, 3974, 1360, 415, 132, 96, 14, 1, 0, 0, 0, 1267,},
- },
- {
- // Coeff Band ( 4 )
- {4787, 9297, 823, 168, 44, 12, 4, 0, 0, 0, 0, 0,},
- {3619, 4472, 719, 198, 60, 31, 3, 0, 0, 0, 0, 8401,},
- {1157, 1175, 483, 182, 88, 31, 8, 0, 0, 0, 0, 268,},
- },
- {
- // Coeff Band ( 5 )
- {8299, 1226, 32, 5, 1, 0, 0, 0, 0, 0, 0, 0,},
- {3502, 1568, 57, 4, 1, 1, 0, 0, 0, 0, 0, 9811,},
- {1055, 1070, 166, 29, 6, 1, 0, 0, 0, 0, 0, 527,},
- },
- {
- // Coeff Band ( 6 )
- {27414, 27927, 1989, 347, 69, 26, 0, 0, 0, 0, 0, 0,},
- {5876, 10074, 1574, 341, 91, 24, 4, 0, 0, 0, 0, 21954,},
- {1571, 2171, 778, 324, 124, 65, 16, 0, 0, 0, 0, 979,},
- },
- {
- // Coeff Band ( 7 )
- { 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
- { 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 459,},
- { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13,},
- },
+const int default_contexts[vp8_coef_counter_dimen] = {
+ {
+ // Block Type ( 0 )
+ {
+ // Coeff Band ( 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, 0, 0, 0, 0, 0},
+ },
+ {
+ // Coeff Band ( 1 )
+ {30190, 26544, 225, 24, 4, 0, 0, 0, 0, 0, 0, 4171593},
+ {26846, 25157, 1241, 130, 26, 6, 1, 0, 0, 0, 0, 149987},
+ {10484, 9538, 1006, 160, 36, 18, 0, 0, 0, 0, 0, 15104},
+ },
+ {
+ // Coeff Band ( 2 )
+ {25842, 40456, 1126, 83, 11, 2, 0, 0, 0, 0, 0, 0},
+ {9338, 8010, 512, 73, 7, 3, 2, 0, 0, 0, 0, 43294},
+ {1047, 751, 149, 31, 13, 6, 1, 0, 0, 0, 0, 879},
+ },
+ {
+ // Coeff Band ( 3 )
+ {26136, 9826, 252, 13, 0, 0, 0, 0, 0, 0, 0, 0},
+ {8134, 5574, 191, 14, 2, 0, 0, 0, 0, 0, 0, 35302},
+ { 605, 677, 116, 9, 1, 0, 0, 0, 0, 0, 0, 611},
+ },
+ {
+ // Coeff Band ( 4 )
+ {10263, 15463, 283, 17, 0, 0, 0, 0, 0, 0, 0, 0},
+ {2773, 2191, 128, 9, 2, 2, 0, 0, 0, 0, 0, 10073},
+ { 134, 125, 32, 4, 0, 2, 0, 0, 0, 0, 0, 50},
+ },
+ {
+ // Coeff Band ( 5 )
+ {10483, 2663, 23, 1, 0, 0, 0, 0, 0, 0, 0, 0},
+ {2137, 1251, 27, 1, 1, 0, 0, 0, 0, 0, 0, 14362},
+ { 116, 156, 14, 2, 1, 0, 0, 0, 0, 0, 0, 190},
+ },
+ {
+ // Coeff Band ( 6 )
+ {40977, 27614, 412, 28, 0, 0, 0, 0, 0, 0, 0, 0},
+ {6113, 5213, 261, 22, 3, 0, 0, 0, 0, 0, 0, 26164},
+ { 382, 312, 50, 14, 2, 0, 0, 0, 0, 0, 0, 345},
+ },
+ {
+ // Coeff Band ( 7 )
+ { 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 319},
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8},
+ },
+ },
+ {
+ // Block Type ( 1 )
+ {
+ // Coeff Band ( 0 )
+ {3268, 19382, 1043, 250, 93, 82, 49, 26, 17, 8, 25, 82289},
+ {8758, 32110, 5436, 1832, 827, 668, 420, 153, 24, 0, 3, 52914},
+ {9337, 23725, 8487, 3954, 2107, 1836, 1069, 399, 59, 0, 0, 18620},
+ },
+ {
+ // Coeff Band ( 1 )
+ {12419, 8420, 452, 62, 9, 1, 0, 0, 0, 0, 0, 0},
+ {11715, 8705, 693, 92, 15, 7, 2, 0, 0, 0, 0, 53988},
+ {7603, 8585, 2306, 778, 270, 145, 39, 5, 0, 0, 0, 9136},
+ },
+ {
+ // Coeff Band ( 2 )
+ {15938, 14335, 1207, 184, 55, 13, 4, 1, 0, 0, 0, 0},
+ {7415, 6829, 1138, 244, 71, 26, 7, 0, 0, 0, 0, 9980},
+ {1580, 1824, 655, 241, 89, 46, 10, 2, 0, 0, 0, 429},
+ },
+ {
+ // Coeff Band ( 3 )
+ {19453, 5260, 201, 19, 0, 0, 0, 0, 0, 0, 0, 0},
+ {9173, 3758, 213, 22, 1, 1, 0, 0, 0, 0, 0, 9820},
+ {1689, 1277, 276, 51, 17, 4, 0, 0, 0, 0, 0, 679},
+ },
+ {
+ // Coeff Band ( 4 )
+ {12076, 10667, 620, 85, 19, 9, 5, 0, 0, 0, 0, 0},
+ {4665, 3625, 423, 55, 19, 9, 0, 0, 0, 0, 0, 5127},
+ { 415, 440, 143, 34, 20, 7, 2, 0, 0, 0, 0, 101},
+ },
+ {
+ // Coeff Band ( 5 )
+ {12183, 4846, 115, 11, 1, 0, 0, 0, 0, 0, 0, 0},
+ {4226, 3149, 177, 21, 2, 0, 0, 0, 0, 0, 0, 7157},
+ { 375, 621, 189, 51, 11, 4, 1, 0, 0, 0, 0, 198},
+ },
+ {
+ // Coeff Band ( 6 )
+ {61658, 37743, 1203, 94, 10, 3, 0, 0, 0, 0, 0, 0},
+ {15514, 11563, 903, 111, 14, 5, 0, 0, 0, 0, 0, 25195},
+ { 929, 1077, 291, 78, 14, 7, 1, 0, 0, 0, 0, 507},
+ },
+ {
+ // Coeff Band ( 7 )
+ { 0, 990, 15, 3, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 412, 13, 0, 0, 0, 0, 0, 0, 0, 0, 1641},
+ { 0, 18, 7, 1, 0, 0, 0, 0, 0, 0, 0, 30},
+ },
+ },
+ {
+ // Block Type ( 2 )
+ {
+ // Coeff Band ( 0 )
+ { 953, 24519, 628, 120, 28, 12, 4, 0, 0, 0, 0, 2248798},
+ {1525, 25654, 2647, 617, 239, 143, 42, 5, 0, 0, 0, 66837},
+ {1180, 11011, 3001, 1237, 532, 448, 239, 54, 5, 0, 0, 7122},
+ },
+ {
+ // Coeff Band ( 1 )
+ {1356, 2220, 67, 10, 4, 1, 0, 0, 0, 0, 0, 0},
+ {1450, 2544, 102, 18, 4, 3, 0, 0, 0, 0, 0, 57063},
+ {1182, 2110, 470, 130, 41, 21, 0, 0, 0, 0, 0, 6047},
+ },
+ {
+ // Coeff Band ( 2 )
+ { 370, 3378, 200, 30, 5, 4, 1, 0, 0, 0, 0, 0},
+ { 293, 1006, 131, 29, 11, 0, 0, 0, 0, 0, 0, 5404},
+ { 114, 387, 98, 23, 4, 8, 1, 0, 0, 0, 0, 236},
+ },
+ {
+ // Coeff Band ( 3 )
+ { 579, 194, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 395, 213, 5, 1, 0, 0, 0, 0, 0, 0, 0, 4157},
+ { 119, 122, 4, 0, 0, 0, 0, 0, 0, 0, 0, 300},
+ },
+ {
+ // Coeff Band ( 4 )
+ { 38, 557, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 21, 114, 12, 1, 0, 0, 0, 0, 0, 0, 0, 427},
+ { 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7},
+ },
+ {
+ // Coeff Band ( 5 )
+ { 52, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 18, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 652},
+ { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30},
+ },
+ {
+ // Coeff Band ( 6 )
+ { 640, 569, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 25, 77, 2, 0, 0, 0, 0, 0, 0, 0, 0, 517},
+ { 4, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
+ },
+ {
+ // Coeff Band ( 7 )
+ { 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, 0, 0, 0, 0},
+ },
+ },
+ {
+ // Block Type ( 3 )
+ {
+ // Coeff Band ( 0 )
+ {2506, 20161, 2707, 767, 261, 178, 107, 30, 14, 3, 0, 100694},
+ {8806, 36478, 8817, 3268, 1280, 850, 401, 114, 42, 0, 0, 58572},
+ {11003, 27214, 11798, 5716, 2482, 2072, 1048, 175, 32, 0, 0, 19284},
+ },
+ {
+ // Coeff Band ( 1 )
+ {9738, 11313, 959, 205, 70, 18, 11, 1, 0, 0, 0, 0},
+ {12628, 15085, 1507, 273, 52, 19, 9, 0, 0, 0, 0, 54280},
+ {10701, 15846, 5561, 1926, 813, 570, 249, 36, 0, 0, 0, 6460},
+ },
+ {
+ // Coeff Band ( 2 )
+ {6781, 22539, 2784, 634, 182, 123, 20, 4, 0, 0, 0, 0},
+ {6263, 11544, 2649, 790, 259, 168, 27, 5, 0, 0, 0, 20539},
+ {3109, 4075, 2031, 896, 457, 386, 158, 29, 0, 0, 0, 1138},
+ },
+ {
+ // Coeff Band ( 3 )
+ {11515, 4079, 465, 73, 5, 14, 2, 0, 0, 0, 0, 0},
+ {9361, 5834, 650, 96, 24, 8, 4, 0, 0, 0, 0, 22181},
+ {4343, 3974, 1360, 415, 132, 96, 14, 1, 0, 0, 0, 1267},
+ },
+ {
+ // Coeff Band ( 4 )
+ {4787, 9297, 823, 168, 44, 12, 4, 0, 0, 0, 0, 0},
+ {3619, 4472, 719, 198, 60, 31, 3, 0, 0, 0, 0, 8401},
+ {1157, 1175, 483, 182, 88, 31, 8, 0, 0, 0, 0, 268},
+ },
+ {
+ // Coeff Band ( 5 )
+ {8299, 1226, 32, 5, 1, 0, 0, 0, 0, 0, 0, 0},
+ {3502, 1568, 57, 4, 1, 1, 0, 0, 0, 0, 0, 9811},
+ {1055, 1070, 166, 29, 6, 1, 0, 0, 0, 0, 0, 527},
+ },
+ {
+ // Coeff Band ( 6 )
+ {27414, 27927, 1989, 347, 69, 26, 0, 0, 0, 0, 0, 0},
+ {5876, 10074, 1574, 341, 91, 24, 4, 0, 0, 0, 0, 21954},
+ {1571, 2171, 778, 324, 124, 65, 16, 0, 0, 0, 0, 979},
+ },
+ {
+ // Coeff Band ( 7 )
+ { 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 459},
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13},
},
+ },
};
-//Update probabilities for the nodes in the token entropy tree.
-const vp8_prob tree_update_probs[vp8_coef_tree_dimen] =
-{
- {
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
- {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
- {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255, },
- {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255, },
- {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- },
- {
- {
- {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255, },
- {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255, },
- },
- {
- {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- },
- {
- {
- {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255, },
- {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255, },
- {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255, },
- },
- {
- {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- },
- {
- {
- {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255, },
- {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
- {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
- {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
- {
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
- },
+// Update probabilities for the nodes in the token entropy tree.
+const vp8_prob tree_update_probs[vp8_coef_tree_dimen] = {
+ {
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255, },
+ {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ },
+ {
+ {
+ {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255, },
+ {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255, },
+ },
+ {
+ {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ },
+ {
+ {
+ {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255, },
+ {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255, },
+ },
+ {
+ {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ },
+ {
+ {
+ {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255, },
+ {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ },
+ {
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
},
+ },
};
#endif
diff --git a/vp8/common/debugmodes.c b/vp8/common/debugmodes.c
index 9bbf1235d..32e947bdc 100644
--- a/vp8/common/debugmodes.c
+++ b/vp8/common/debugmodes.c
@@ -13,152 +13,137 @@
#include "blockd.h"
-void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int frame)
-{
+void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int frame) {
- int mb_row;
- int mb_col;
- int mb_index = 0;
- FILE *mvs = fopen("mvs.stt", "a");
+ int mb_row;
+ int mb_col;
+ int mb_index = 0;
+ FILE *mvs = fopen("mvs.stt", "a");
- /* print out the macroblock Y modes */
- mb_index = 0;
- fprintf(mvs, "Mb Modes for Frame %d\n", frame);
+ /* print out the macroblock Y modes */
+ mb_index = 0;
+ fprintf(mvs, "Mb Modes for Frame %d\n", frame);
- for (mb_row = 0; mb_row < rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cols; mb_col++)
- {
+ for (mb_row = 0; mb_row < rows; mb_row++) {
+ for (mb_col = 0; mb_col < cols; mb_col++) {
- fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
+ fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
- mb_index++;
- }
-
- fprintf(mvs, "\n");
- mb_index++;
+ mb_index++;
}
fprintf(mvs, "\n");
+ mb_index++;
+ }
- mb_index = 0;
- fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
+ fprintf(mvs, "\n");
- for (mb_row = 0; mb_row < rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cols; mb_col++)
- {
+ mb_index = 0;
+ fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
- fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
+ for (mb_row = 0; mb_row < rows; mb_row++) {
+ for (mb_col = 0; mb_col < cols; mb_col++) {
- mb_index++;
- }
+ fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
- fprintf(mvs, "\n");
- mb_index++;
+ mb_index++;
}
fprintf(mvs, "\n");
+ mb_index++;
+ }
- /* print out the macroblock UV modes */
- mb_index = 0;
- fprintf(mvs, "UV Modes for Frame %d\n", frame);
+ fprintf(mvs, "\n");
- for (mb_row = 0; mb_row < rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cols; mb_col++)
- {
+ /* print out the macroblock UV modes */
+ mb_index = 0;
+ fprintf(mvs, "UV Modes for Frame %d\n", frame);
- fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
+ for (mb_row = 0; mb_row < rows; mb_row++) {
+ for (mb_col = 0; mb_col < cols; mb_col++) {
- mb_index++;
- }
+ fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
- mb_index++;
- fprintf(mvs, "\n");
+ mb_index++;
}
+ mb_index++;
fprintf(mvs, "\n");
+ }
+
+ fprintf(mvs, "\n");
+
+ /* print out the block modes */
+ mb_index = 0;
+ fprintf(mvs, "Mbs for Frame %d\n", frame);
+ {
+ int b_row;
+
+ for (b_row = 0; b_row < 4 * rows; b_row++) {
+ int b_col;
+ int bindex;
+
+ for (b_col = 0; b_col < 4 * cols; b_col++) {
+ mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
+ bindex = (b_row & 3) * 4 + (b_col & 3);
- /* print out the block modes */
- mb_index = 0;
- fprintf(mvs, "Mbs for Frame %d\n", frame);
- {
- int b_row;
-
- for (b_row = 0; b_row < 4 * rows; b_row++)
- {
- int b_col;
- int bindex;
-
- for (b_col = 0; b_col < 4 * cols; b_col++)
- {
- mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
- bindex = (b_row & 3) * 4 + (b_col & 3);
-
- if (mi[mb_index].mbmi.mode == B_PRED)
- {
- fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.first);
+ if (mi[mb_index].mbmi.mode == B_PRED) {
+ fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.first);
#if CONFIG_COMP_INTRA_PRED
- fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.second);
+ fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.second);
#endif
- }
- else
- fprintf(mvs, "xx ");
+ } else
+ fprintf(mvs, "xx ");
- }
+ }
- fprintf(mvs, "\n");
- }
+ fprintf(mvs, "\n");
}
- fprintf(mvs, "\n");
-
- /* print out the macroblock mvs */
- mb_index = 0;
- fprintf(mvs, "MVs for Frame %d\n", frame);
+ }
+ fprintf(mvs, "\n");
- for (mb_row = 0; mb_row < rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cols; mb_col++)
- {
- fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2, mi[mb_index].mbmi.mv.as_mv.col / 2);
+ /* print out the macroblock mvs */
+ mb_index = 0;
+ fprintf(mvs, "MVs for Frame %d\n", frame);
- mb_index++;
- }
+ for (mb_row = 0; mb_row < rows; mb_row++) {
+ for (mb_col = 0; mb_col < cols; mb_col++) {
+ fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2, mi[mb_index].mbmi.mv.as_mv.col / 2);
- mb_index++;
- fprintf(mvs, "\n");
+ mb_index++;
}
+ mb_index++;
fprintf(mvs, "\n");
+ }
+ fprintf(mvs, "\n");
- /* print out the block modes */
- mb_index = 0;
- fprintf(mvs, "MVs for Frame %d\n", frame);
- {
- int b_row;
- for (b_row = 0; b_row < 4 * rows; b_row++)
- {
- int b_col;
- int bindex;
+ /* print out the block modes */
+ mb_index = 0;
+ fprintf(mvs, "MVs for Frame %d\n", frame);
+ {
+ int b_row;
- for (b_col = 0; b_col < 4 * cols; b_col++)
- {
- mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
- bindex = (b_row & 3) * 4 + (b_col & 3);
- fprintf(mvs, "%3d:%-3d ",
- mi[mb_index].bmi[bindex].as_mv.first.as_mv.row,
- mi[mb_index].bmi[bindex].as_mv.first.as_mv.col);
+ for (b_row = 0; b_row < 4 * rows; b_row++) {
+ int b_col;
+ int bindex;
- }
+ for (b_col = 0; b_col < 4 * cols; b_col++) {
+ mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
+ bindex = (b_row & 3) * 4 + (b_col & 3);
+ fprintf(mvs, "%3d:%-3d ",
+ mi[mb_index].bmi[bindex].as_mv.first.as_mv.row,
+ mi[mb_index].bmi[bindex].as_mv.first.as_mv.col);
- fprintf(mvs, "\n");
- }
+ }
+
+ fprintf(mvs, "\n");
}
- fprintf(mvs, "\n");
+ }
+ fprintf(mvs, "\n");
- fclose(mvs);
+ fclose(mvs);
}
diff --git a/vp8/common/default_coef_probs.h b/vp8/common/default_coef_probs.h
index 380f2c0c0..10248cc6f 100644
--- a/vp8/common/default_coef_probs.h
+++ b/vp8/common/default_coef_probs.h
@@ -13,489 +13,550 @@
static const vp8_prob default_coef_probs [BLOCK_TYPES]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES] =
-{
- { /* Block Type ( 0 ) */
- { /* Coeff Band ( 0 )*/
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES] = {
+ {
+ /* Block Type ( 0 ) */
+ {
+ /* Coeff Band ( 0 )*/
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
#endif
- },
- { /* Coeff Band ( 1 )*/
- { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 },
- { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 },
-#if CONFIG_EXPANDED_COEF_CONTEXT
- { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
- { 90, 116, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
-#else
- { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
-#endif
- },
- { /* Coeff Band ( 2 )*/
- { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
- { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 1 )*/
+ { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 },
+ { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
- { 64, 128, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
+ { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
+ { 90, 116, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
#else
- { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
+ { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 3 )*/
- { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
- { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 2 )*/
+ { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
+ { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
- { 64, 100, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
+ { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
+ { 64, 128, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
#else
- { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
+ { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 4 )*/
- { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
- { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 3 )*/
+ { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
+ { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
- { 28, 110, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
+ { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
+ { 64, 100, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
#else
- { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
+ { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 5 )*/
- { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
- { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 4 )*/
+ { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
+ { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
- { 90, 90, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
+ { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
+ { 28, 110, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
#else
- { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
+ { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 6 )*/
- { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
- { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 5 )*/
+ { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
+ { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
- { 64, 120, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
+ { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
+ { 90, 90, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
#else
- { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
+ { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 7 )*/
- { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 6 )*/
+ { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
+ { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
+ { 64, 120, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
#else
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
#endif
- }
},
- { /* Block Type ( 1 ) */
- { /* Coeff Band ( 0 )*/
- { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 },
- { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 },
+ {
+ /* Coeff Band ( 7 )*/
+ { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
- { 48, 32, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
+ { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
+ { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 1 )*/
- { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
- { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 },
+ }
+ },
+ {
+ /* Block Type ( 1 ) */
+ {
+ /* Coeff Band ( 0 )*/
+ { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 },
+ { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
- { 66, 90, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
+ { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
+ { 48, 32, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
#else
- { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
+ { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
#endif
- },
- { /* Coeff Band ( 2 )*/
- { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
- { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 1 )*/
+ { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
+ { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
- { 18, 80, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
+ { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
+ { 66, 90, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
#else
- { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
+ { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
#endif
- },
- { /* Coeff Band ( 3 )*/
- { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
- { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 2 )*/
+ { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
+ { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
- { 36, 120, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
+ { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
+ { 18, 80, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
#else
- { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
+ { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
#endif
- },
- { /* Coeff Band ( 4 )*/
- { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
- { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 3 )*/
+ { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
+ { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
- { 18, 90, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
+ { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
+ { 36, 120, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
#else
- { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
+ { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 5 )*/
- { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
- { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 4 )*/
+ { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
+ { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
- { 28, 70, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
+ { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
+ { 18, 90, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
#else
- { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
+ { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 6 )*/
- { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
- { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 5 )*/
+ { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
+ { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
- { 40, 90, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
+ { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
+ { 28, 70, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
#else
- { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
+ { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 7 )*/
- { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 6 )*/
+ { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
+ { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
+ { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
+ { 40, 90, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
#else
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
+ { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
#endif
- }
},
- { /* Block Type ( 2 ) */
- { /* Coeff Band ( 0 )*/
- { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 },
- { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 },
+ {
+ /* Coeff Band ( 7 )*/
+ { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
+ { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
- { 64, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
+ { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
+ { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
#else
- { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
+ { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 1 )*/
- { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
- { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 },
+ }
+ },
+ {
+ /* Block Type ( 2 ) */
+ {
+ /* Coeff Band ( 0 )*/
+ { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 },
+ { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
- { 140, 70, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
+ { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
+ { 64, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
#else
- { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
+ { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
#endif
- },
- { /* Coeff Band ( 2 )*/
- { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
- { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 1 )*/
+ { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
+ { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
- { 60, 40, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
+ { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
+ { 140, 70, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
#else
- { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
+ { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 3 )*/
- { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 2 )*/
+ { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
+ { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 132, 118, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
+ { 60, 40, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
#else
- { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 4 )*/
- { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 3 )*/
+ { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 132, 118, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
#else
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 5 )*/
- { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 4 )*/
+ { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 6 )*/
- { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 5 )*/
+ { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 48, 85, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 7 )*/
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 6 )*/
+ { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
+ { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 48, 85, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- }
},
- { /* Block Type ( 3 ) */
- { /* Coeff Band ( 0 )*/
- { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 },
- { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 },
+ {
+ /* Coeff Band ( 7 )*/
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 63, 48, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
- { 54, 40, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#else
- { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
+ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 1 )*/
- { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
- { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 },
+ }
+ },
+ {
+ /* Block Type ( 3 ) */
+ {
+ /* Coeff Band ( 0 )*/
+ { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 },
+ { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 44, 84, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
- { 32, 70, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
+ { 63, 48, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
+ { 54, 40, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
#else
- { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
+ { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
#endif
- },
- { /* Coeff Band ( 2 )*/
- { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
- { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 },
+ },
+ {
+ /* Coeff Band ( 1 )*/
+ { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
+ { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
+ { 44, 84, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
+ { 32, 70, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
#else
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
+ { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
#endif
- },
- { /* Coeff Band ( 3 )*/
- { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
- { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 2 )*/
+ { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
+ { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
- { 26, 104, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
+ { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
+ { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
#else
- { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
+ { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
#endif
- },
- { /* Coeff Band ( 4 )*/
- { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
- { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 3 )*/
+ { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
+ { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
+ { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
+ { 26, 104, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
#else
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
+ { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
#endif
- },
- { /* Coeff Band ( 5 )*/
- { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
- { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 4 )*/
+ { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
+ { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
+ { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
+ { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
#else
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
+ { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 6 )*/
- { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
- { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 5 )*/
+ { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
+ { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
+ { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
+ { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
#else
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
+ { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
#endif
- },
- { /* Coeff Band ( 7 )*/
- { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ },
+ {
+ /* Coeff Band ( 6 )*/
+ { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
+ { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 },
#if CONFIG_EXPANDED_COEF_CONTEXT
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
+ { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
#else
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
+#endif
+ },
+ {
+ /* Coeff Band ( 7 )*/
+ { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+#if CONFIG_EXPANDED_COEF_CONTEXT
+ { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+ { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
+#else
+ { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
#endif
- }
}
+ }
};
#if CONFIG_EXPANDED_COEF_CONTEXT
static const vp8_prob
vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES] =
-{
- { /* block Type 0 */
- { /* Coeff Band 0 */
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES] = {
+ {
+ /* block Type 0 */
+ {
+ /* Coeff Band 0 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 60, 140, 195, 255, 212, 214, 128, 128, 128, 128, 128},
{ 75, 221, 231, 255, 203, 255, 128, 128, 128, 128, 128},
{ 9, 212, 196, 251, 197, 207, 255, 185, 128, 128, 128},
{ 9, 212, 196, 251, 197, 207, 255, 185, 128, 128, 128}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 227, 226, 255, 215, 215, 128, 128, 128, 128, 128},
{ 5, 163, 209, 255, 212, 212, 255, 255, 128, 128, 128},
{ 1, 133, 203, 255, 210, 220, 255, 255, 128, 128, 128},
{ 1, 133, 203, 255, 210, 220, 255, 255, 128, 128, 128}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 226, 225, 255, 228, 236, 128, 128, 128, 128, 128},
{ 6, 163, 208, 255, 224, 234, 255, 255, 128, 128, 128},
{ 1, 122, 196, 253, 212, 248, 255, 255, 128, 128, 128},
{ 1, 122, 196, 253, 212, 248, 255, 255, 128, 128, 128}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 1, 222, 197, 254, 193, 216, 255, 236, 128, 128, 128},
{ 7, 140, 163, 251, 195, 211, 255, 238, 128, 128, 128},
{ 1, 91, 152, 249, 181, 197, 255, 239, 128, 128, 128},
{ 1, 91, 152, 249, 181, 197, 255, 239, 128, 128, 128}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 1, 226, 218, 255, 216, 241, 255, 255, 128, 128, 128},
{ 6, 154, 191, 255, 218, 240, 255, 255, 128, 128, 128},
{ 1, 110, 171, 252, 191, 204, 255, 236, 128, 128, 128},
{ 1, 110, 171, 252, 191, 204, 255, 236, 128, 128, 128}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 1, 221, 217, 255, 208, 217, 255, 232, 128, 128, 128},
{ 11, 155, 189, 254, 203, 211, 255, 249, 128, 128, 128},
{ 1, 110, 171, 252, 191, 204, 255, 236, 128, 128, 128},
{ 1, 110, 171, 252, 191, 204, 255, 236, 128, 128, 128}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 1, 207, 235, 255, 232, 240, 128, 128, 128, 128, 128},
{ 58, 161, 216, 255, 229, 235, 255, 255, 128, 128, 128},
{ 8, 133, 204, 255, 219, 231, 255, 255, 128, 128, 128},
{ 8, 133, 204, 255, 219, 231, 255, 255, 128, 128, 128}
}
},
- { /* block Type 1 */
- { /* Coeff Band 0 */
+ {
+ /* block Type 1 */
+ {
+ /* Coeff Band 0 */
{ 134, 152, 233, 224, 234, 52, 255, 166, 128, 128, 128},
{ 97, 132, 185, 234, 186, 189, 197, 171, 255, 212, 128},
{ 84, 110, 185, 237, 182, 182, 145, 145, 255, 255, 128}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 1, 124, 213, 247, 192, 212, 255, 255, 128, 128, 128},
{ 88, 111, 178, 254, 189, 211, 255, 255, 128, 128, 128},
{ 12, 59, 129, 236, 150, 179, 239, 195, 255, 255, 128},
{ 12, 59, 129, 236, 150, 179, 239, 195, 255, 255, 128}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 102, 225, 255, 210, 240, 128, 128, 128, 128, 128},
{ 110, 78, 195, 254, 200, 191, 255, 255, 128, 128, 128},
{ 37, 63, 177, 255, 194, 195, 128, 128, 128, 128, 128},
{ 37, 63, 177, 255, 194, 195, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 1, 229, 255, 202, 224, 128, 128, 128, 128, 128},
{ 150, 1, 192, 255, 206, 226, 128, 128, 128, 128, 128},
{ 75, 1, 138, 255, 172, 228, 128, 128, 128, 128, 128},
{ 75, 1, 138, 255, 172, 228, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
}
},
- { /* block Type 2 */
- { /* Coeff Band 0 */
+ {
+ /* block Type 2 */
+ {
+ /* Coeff Band 0 */
{ 11, 181, 226, 199, 183, 255, 255, 255, 128, 128, 128},
{ 2, 147, 185, 248, 163, 180, 255, 236, 128, 128, 128},
{ 1, 123, 157, 238, 154, 176, 255, 226, 255, 255, 128},
{ 1, 123, 157, 238, 154, 176, 255, 226, 255, 255, 128}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 1, 150, 191, 246, 174, 188, 255, 235, 128, 128, 128},
{ 1, 125, 166, 245, 165, 185, 255, 234, 128, 128, 128},
{ 1, 79, 125, 240, 148, 179, 255, 234, 255, 255, 128},
{ 1, 79, 125, 240, 148, 179, 255, 234, 255, 255, 128}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 146, 184, 242, 167, 183, 255, 230, 255, 255, 128},
{ 1, 119, 160, 239, 156, 178, 255, 231, 255, 255, 128},
{ 1, 75, 115, 234, 142, 173, 255, 225, 255, 255, 128},
{ 1, 75, 115, 234, 142, 173, 255, 225, 255, 255, 128}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 150, 188, 244, 169, 183, 255, 233, 255, 255, 128},
{ 1, 123, 162, 243, 161, 180, 255, 233, 128, 128, 128},
{ 1, 76, 120, 238, 148, 178, 255, 230, 255, 255, 128},
{ 1, 76, 120, 238, 148, 178, 255, 230, 255, 255, 128}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 1, 163, 202, 252, 188, 204, 255, 248, 128, 128, 128},
{ 1, 136, 180, 251, 181, 201, 255, 246, 128, 128, 128},
{ 1, 92, 146, 249, 170, 197, 255, 245, 128, 128, 128},
{ 1, 92, 146, 249, 170, 197, 255, 245, 128, 128, 128}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 1, 156, 195, 249, 179, 193, 255, 241, 255, 255, 128},
{ 1, 128, 169, 248, 171, 192, 255, 242, 255, 255, 128},
{ 1, 84, 132, 245, 158, 187, 255, 240, 255, 255, 128},
{ 1, 84, 132, 245, 158, 187, 255, 240, 255, 255, 128}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 1, 36, 71, 251, 192, 201, 255, 243, 255, 255, 128},
{ 1, 49, 185, 250, 184, 199, 255, 242, 128, 128, 128},
{ 1, 95, 147, 247, 168, 190, 255, 239, 255, 255, 128},
{ 1, 95, 147, 247, 168, 190, 255, 239, 255, 255, 128}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 1, 19, 98, 255, 218, 222, 255, 255, 128, 128, 128},
{ 36, 50, 210, 255, 212, 221, 255, 255, 128, 128, 128},
{ 6, 117, 180, 254, 199, 216, 255, 251, 128, 128, 128},
@@ -506,131 +567,157 @@ vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8]
#else
static const vp8_prob
vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES] =
-{
- { /* block Type 0 */
- { /* Coeff Band 0 */
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES] = {
+ {
+ /* block Type 0 */
+ {
+ /* Coeff Band 0 */
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 60, 140, 195, 255, 212, 214, 234, 244, 249, 252, 253},
{ 75, 221, 231, 255, 203, 255, 255, 255, 255, 255, 255},
{ 9, 212, 196, 251, 197, 207, 255, 185, 220, 237, 246}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 227, 226, 255, 215, 215, 235, 245, 250, 252, 253},
{ 5, 163, 209, 255, 212, 212, 255, 255, 255, 255, 255},
{ 1, 133, 203, 255, 210, 220, 255, 255, 255, 255, 255}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 226, 225, 255, 228, 237, 246, 250, 252, 253, 254},
{ 6, 163, 208, 255, 224, 234, 255, 255, 255, 255, 255},
{ 1, 122, 196, 253, 212, 248, 255, 255, 255, 255, 255}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 1, 222, 198, 254, 193, 216, 255, 242, 248, 251, 253},
{ 7, 140, 163, 251, 195, 211, 255, 238, 246, 250, 252},
{ 1, 91, 152, 249, 181, 197, 255, 239, 247, 251, 253}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 1, 226, 218, 255, 216, 242, 255, 255, 255, 255, 255},
{ 6, 154, 191, 255, 218, 240, 255, 255, 255, 255, 255},
{ 1, 111, 184, 255, 210, 225, 255, 255, 255, 255, 255}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 1, 221, 217, 255, 208, 217, 255, 255, 255, 255, 255},
{ 11, 155, 189, 254, 203, 211, 255, 249, 252, 253, 254},
{ 1, 110, 171, 252, 191, 204, 255, 237, 246, 250, 252}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 1, 207, 235, 255, 232, 241, 248, 251, 253, 254, 254},
{ 58, 161, 216, 255, 230, 235, 255, 255, 255, 255, 255},
{ 8, 133, 204, 255, 219, 231, 255, 255, 255, 255, 255}
}
},
- { /* block Type 1 */
- { /* Coeff Band 0 */
+ {
+ /* block Type 1 */
+ {
+ /* Coeff Band 0 */
{ 134, 152, 233, 224, 234, 52, 255, 166, 210, 232, 243},
{ 97, 132, 185, 234, 186, 189, 197, 171, 255, 212, 233},
{ 84, 110, 185, 237, 182, 182, 145, 145, 255, 255, 255}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 1, 124, 213, 247, 192, 212, 255, 255, 255, 255, 255},
{ 88, 111, 178, 254, 189, 211, 255, 255, 255, 255, 255},
{ 12, 59, 129, 236, 150, 179, 239, 195, 255, 255, 255}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 102, 225, 255, 210, 240, 247, 251, 253, 254, 254},
{ 110, 78, 195, 254, 200, 191, 255, 255, 255, 255, 255},
{ 37, 63, 177, 255, 194, 195, 225, 240, 247, 251, 253}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 1, 229, 255, 202, 224, 239, 247, 251, 253, 254},
{ 150, 1, 192, 255, 206, 226, 240, 247, 251, 253, 254},
{ 75, 1, 138, 255, 172, 228, 241, 248, 251, 253, 254}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254},
{ 128, 191, 223, 239, 247, 251, 253, 254, 254, 254, 254}
}
},
- { /* block Type 2 */
- { /* Coeff Band 0 */
+ {
+ /* block Type 2 */
+ {
+ /* Coeff Band 0 */
{ 11, 181, 226, 199, 183, 255, 255, 255, 255, 255, 255},
{ 2, 147, 185, 248, 163, 180, 255, 236, 245, 250, 252},
{ 1, 123, 157, 238, 154, 176, 255, 226, 255, 255, 255}
},
- { /* Coeff Band 1 */
+ {
+ /* Coeff Band 1 */
{ 1, 150, 191, 246, 174, 188, 255, 235, 245, 250, 252},
{ 1, 125, 166, 245, 165, 185, 255, 234, 244, 249, 252},
{ 1, 79, 125, 240, 148, 179, 255, 234, 255, 255, 255}
},
- { /* Coeff Band 2 */
+ {
+ /* Coeff Band 2 */
{ 1, 146, 184, 242, 167, 183, 255, 231, 243, 249, 252},
{ 1, 119, 160, 239, 156, 178, 255, 231, 255, 255, 255},
{ 1, 75, 115, 234, 142, 173, 255, 225, 255, 255, 255}
},
- { /* Coeff Band 3 */
+ {
+ /* Coeff Band 3 */
{ 1, 150, 189, 244, 169, 183, 255, 234, 244, 249, 252},
{ 1, 123, 162, 243, 161, 180, 255, 233, 244, 249, 252},
{ 1, 76, 120, 238, 148, 178, 255, 230, 255, 255, 255}
},
- { /* Coeff Band 4 */
+ {
+ /* Coeff Band 4 */
{ 1, 163, 202, 252, 188, 204, 255, 249, 252, 253, 254},
{ 1, 136, 180, 251, 181, 201, 255, 247, 251, 253, 254},
{ 1, 92, 146, 249, 170, 197, 255, 246, 250, 252, 253}
},
- { /* Coeff Band 5 */
+ {
+ /* Coeff Band 5 */
{ 1, 156, 195, 249, 179, 193, 255, 242, 248, 251, 253},
{ 1, 128, 169, 248, 171, 192, 255, 242, 248, 251, 253},
{ 1, 84, 132, 245, 158, 187, 255, 240, 247, 251, 253}
},
- { /* Coeff Band 6 */
+ {
+ /* Coeff Band 6 */
{ 1, 172, 209, 251, 192, 201, 255, 243, 249, 252, 253},
{ 1, 143, 185, 250, 184, 199, 255, 242, 248, 251, 253},
{ 1, 95, 147, 247, 168, 190, 255, 240, 247, 251, 253}
},
- { /* Coeff Band 7 */
+ {
+ /* Coeff Band 7 */
{ 1, 178, 229, 255, 218, 223, 255, 255, 255, 255, 255},
{ 36, 155, 210, 255, 212, 221, 255, 255, 255, 255, 255},
{ 6, 117, 180, 254, 199, 216, 255, 252, 253, 254, 254}
diff --git a/vp8/common/entropy.c b/vp8/common/entropy.c
index 387742266..4c7caef82 100644
--- a/vp8/common/entropy.c
+++ b/vp8/common/entropy.c
@@ -28,24 +28,23 @@ typedef vp8_prob Prob;
#include "coefupdateprobs.h"
-DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) =
-{
- 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 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,
- 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,
- 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,
- 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
+DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) = {
+ 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 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,
+ 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,
+ 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,
+ 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
};
DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) =
@@ -55,15 +54,16 @@ DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) =
#if CONFIG_EXPANDED_COEF_CONTEXT
{ 0, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0};
#else
-{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
+ {
+ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0
+ };
#endif
-DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) =
-{
- 0, 1, 4, 8,
- 5, 2, 3, 6,
- 9, 12, 13, 10,
- 7, 11, 14, 15,
+DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) = {
+ 0, 1, 4, 8,
+ 5, 2, 3, 6,
+ 9, 12, 13, 10,
+ 7, 11, 14, 15,
};
DECLARE_ALIGNED(64, cuchar, vp8_coef_bands_8x8[64]) = { 0, 1, 2, 3, 5, 4, 4, 5,
5, 3, 6, 3, 5, 4, 6, 6,
@@ -73,34 +73,33 @@ DECLARE_ALIGNED(64, cuchar, vp8_coef_bands_8x8[64]) = { 0, 1, 2, 3, 5, 4, 4, 5,
7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7
-};
-DECLARE_ALIGNED(64, const int, vp8_default_zig_zag1d_8x8[64]) =
-{
- 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
+ };
+DECLARE_ALIGNED(64, const int, vp8_default_zig_zag1d_8x8[64]) = {
+ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
};
DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask[16]);
-DECLARE_ALIGNED(64, short, vp8_default_zig_zag_mask_8x8[64]);//int64_t
+DECLARE_ALIGNED(64, short, vp8_default_zig_zag_mask_8x8[64]);// int64_t
/* Array indices are identical to previously-existing CONTEXT_NODE indices */
const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */
{
- -DCT_EOB_TOKEN, 2, /* 0 = EOB */
- -ZERO_TOKEN, 4, /* 1 = ZERO */
- -ONE_TOKEN, 6, /* 2 = ONE */
- 8, 12, /* 3 = LOW_VAL */
- -TWO_TOKEN, 10, /* 4 = TWO */
- -THREE_TOKEN, -FOUR_TOKEN, /* 5 = THREE */
- 14, 16, /* 6 = HIGH_LOW */
- -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2, /* 7 = CAT_ONE */
- 18, 20, /* 8 = CAT_THREEFOUR */
- -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4, /* 9 = CAT_THREE */
- -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */
+ -DCT_EOB_TOKEN, 2, /* 0 = EOB */
+ -ZERO_TOKEN, 4, /* 1 = ZERO */
+ -ONE_TOKEN, 6, /* 2 = ONE */
+ 8, 12, /* 3 = LOW_VAL */
+ -TWO_TOKEN, 10, /* 4 = TWO */
+ -THREE_TOKEN, -FOUR_TOKEN, /* 5 = THREE */
+ 14, 16, /* 6 = HIGH_LOW */
+ -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2, /* 7 = CAT_ONE */
+ 18, 20, /* 8 = CAT_THREEFOUR */
+ -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4, /* 9 = CAT_THREE */
+ -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */
};
struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
@@ -118,57 +117,50 @@ static const Prob Pcat6[] =
static vp8_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[26];
-void vp8_init_scan_order_mask()
-{
- int i;
+void vp8_init_scan_order_mask() {
+ int i;
- for (i = 0; i < 16; i++)
- {
- vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
- }
- for (i = 0; i < 64; i++)
- {
- vp8_default_zig_zag_mask_8x8[vp8_default_zig_zag1d_8x8[i]] = 1 << i;
- }
+ for (i = 0; i < 16; i++) {
+ vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
+ }
+ for (i = 0; i < 64; i++) {
+ vp8_default_zig_zag_mask_8x8[vp8_default_zig_zag1d_8x8[i]] = 1 << i;
+ }
}
-static void init_bit_tree(vp8_tree_index *p, int n)
-{
- int i = 0;
+static void init_bit_tree(vp8_tree_index *p, int n) {
+ int i = 0;
- while (++i < n)
- {
- p[0] = p[1] = i << 1;
- p += 2;
- }
+ while (++i < n) {
+ p[0] = p[1] = i << 1;
+ p += 2;
+ }
- p[0] = p[1] = 0;
+ p[0] = p[1] = 0;
}
-static void init_bit_trees()
-{
- init_bit_tree(cat1, 1);
- init_bit_tree(cat2, 2);
- init_bit_tree(cat3, 3);
- init_bit_tree(cat4, 4);
- init_bit_tree(cat5, 5);
- init_bit_tree(cat6, 13);
+static void init_bit_trees() {
+ init_bit_tree(cat1, 1);
+ init_bit_tree(cat2, 2);
+ init_bit_tree(cat3, 3);
+ init_bit_tree(cat4, 4);
+ init_bit_tree(cat5, 5);
+ init_bit_tree(cat6, 13);
}
-vp8_extra_bit_struct vp8_extra_bits[12] =
-{
- { 0, 0, 0, 0},
- { 0, 0, 0, 1},
- { 0, 0, 0, 2},
- { 0, 0, 0, 3},
- { 0, 0, 0, 4},
- { cat1, Pcat1, 1, 5},
- { cat2, Pcat2, 2, 7},
- { cat3, Pcat3, 3, 11},
- { cat4, Pcat4, 4, 19},
- { cat5, Pcat5, 5, 35},
- { cat6, Pcat6, 13, 67},
- { 0, 0, 0, 0}
+vp8_extra_bit_struct vp8_extra_bits[12] = {
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 1},
+ { 0, 0, 0, 2},
+ { 0, 0, 0, 3},
+ { 0, 0, 0, 4},
+ { cat1, Pcat1, 1, 5},
+ { cat2, Pcat2, 2, 7},
+ { cat3, Pcat3, 3, 11},
+ { cat4, Pcat4, 4, 19},
+ { cat5, Pcat5, 5, 35},
+ { cat6, Pcat6, 13, 67},
+ { 0, 0, 0, 0}
};
#if CONFIG_NEWUPDATE
@@ -177,25 +169,23 @@ const vp8_prob updprobs[4] = {128, 136, 120, 112};
#include "default_coef_probs.h"
-void vp8_default_coef_probs(VP8_COMMON *pc)
-{
- vpx_memcpy(pc->fc.coef_probs, default_coef_probs,
- sizeof(default_coef_probs));
+void vp8_default_coef_probs(VP8_COMMON *pc) {
+ vpx_memcpy(pc->fc.coef_probs, default_coef_probs,
+ sizeof(default_coef_probs));
- vpx_memcpy(pc->fc.coef_probs_8x8, vp8_default_coef_probs_8x8,
- sizeof(vp8_default_coef_probs_8x8));
+ vpx_memcpy(pc->fc.coef_probs_8x8, vp8_default_coef_probs_8x8,
+ sizeof(vp8_default_coef_probs_8x8));
}
-void vp8_coef_tree_initialize()
-{
- init_bit_trees();
- vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
+void vp8_coef_tree_initialize() {
+ init_bit_trees();
+ vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
}
#if CONFIG_ADAPTIVE_ENTROPY
-//#define COEF_COUNT_TESTING
+// #define COEF_COUNT_TESTING
#define COEF_COUNT_SAT 24
#define COEF_MAX_UPDATE_FACTOR 112
@@ -204,127 +194,111 @@ void vp8_coef_tree_initialize()
#define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
-void vp8_adapt_coef_probs(VP8_COMMON *cm)
-{
- int t, i, j, k, count;
- unsigned int branch_ct[ENTROPY_NODES][2];
- vp8_prob coef_probs[ENTROPY_NODES];
- int update_factor; /* denominator 256 */
- int factor;
- int count_sat;
-
- //printf("Frame type: %d\n", cm->frame_type);
- if (cm->frame_type == KEY_FRAME)
- {
- update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
- count_sat = COEF_COUNT_SAT_KEY;
- }
- else if (cm->last_frame_type == KEY_FRAME)
- {
- update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
- count_sat = COEF_COUNT_SAT_AFTER_KEY;
- }
- else
- {
- update_factor = COEF_MAX_UPDATE_FACTOR;
- count_sat = COEF_COUNT_SAT;
- }
+void vp8_adapt_coef_probs(VP8_COMMON *cm) {
+ int t, i, j, k, count;
+ unsigned int branch_ct[ENTROPY_NODES][2];
+ vp8_prob coef_probs[ENTROPY_NODES];
+ int update_factor; /* denominator 256 */
+ int factor;
+ int count_sat;
+
+ // printf("Frame type: %d\n", cm->frame_type);
+ if (cm->frame_type == KEY_FRAME) {
+ update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
+ count_sat = COEF_COUNT_SAT_KEY;
+ } else if (cm->last_frame_type == KEY_FRAME) {
+ update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
+ count_sat = COEF_COUNT_SAT_AFTER_KEY;
+ } else {
+ update_factor = COEF_MAX_UPDATE_FACTOR;
+ count_sat = COEF_COUNT_SAT;
+ }
#ifdef COEF_COUNT_TESTING
- {
- printf("static const unsigned int\ncoef_counts"
- "[BLOCK_TYPES] [COEF_BANDS]"
- "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
- for (i = 0; i<BLOCK_TYPES; ++i)
- {
- printf(" {\n");
- for (j = 0; j<COEF_BANDS; ++j)
- {
- printf(" {\n");
- for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
- {
- printf(" {");
- for (t = 0; t<MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
- printf("},\n");
- }
- printf(" },\n");
+ {
+ printf("static const unsigned int\ncoef_counts"
+ "[BLOCK_TYPES] [COEF_BANDS]"
+ "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ printf(" {\n");
+ for (j = 0; j < COEF_BANDS; ++j) {
+ printf(" {\n");
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ printf(" {");
+ for (t = 0; t < MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
+ printf("},\n");
}
- printf(" },\n");
+ printf(" },\n");
}
- printf("};\n");
- printf("static const unsigned int\ncoef_counts_8x8"
- "[BLOCK_TYPES_8X8] [COEF_BANDS]"
- "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
- for (i = 0; i<BLOCK_TYPES_8X8; ++i)
- {
- printf(" {\n");
- for (j = 0; j<COEF_BANDS; ++j)
- {
- printf(" {\n");
- for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
- {
- printf(" {");
- for (t = 0; t<MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
- printf("},\n");
- }
- printf(" },\n");
+ printf(" },\n");
+ }
+ printf("};\n");
+ printf("static const unsigned int\ncoef_counts_8x8"
+ "[BLOCK_TYPES_8X8] [COEF_BANDS]"
+ "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
+ for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
+ printf(" {\n");
+ for (j = 0; j < COEF_BANDS; ++j) {
+ printf(" {\n");
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ printf(" {");
+ for (t = 0; t < MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
+ printf("},\n");
}
- printf(" },\n");
+ printf(" },\n");
}
- printf("};\n");
+ printf(" },\n");
}
+ printf("};\n");
+ }
#endif
- for (i = 0; i<BLOCK_TYPES; ++i)
- for (j = 0; j<COEF_BANDS; ++j)
- for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
- {
+ for (i = 0; i < BLOCK_TYPES; ++i)
+ for (j = 0; j < COEF_BANDS; ++j)
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- coef_probs, branch_ct, cm->fc.coef_counts [i][j][k],
- 256, 1);
- for (t=0; t<ENTROPY_NODES; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
- prob = ((int)cm->fc.pre_coef_probs[i][j][k][t] * (256-factor) +
- (int)coef_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1;
- else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255;
- else cm->fc.coef_probs[i][j][k][t] = prob;
- }
- }
-
- for (i = 0; i<BLOCK_TYPES_8X8; ++i)
- for (j = 0; j<COEF_BANDS; ++j)
- for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
- {
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ coef_probs, branch_ct, cm->fc.coef_counts [i][j][k],
+ 256, 1);
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > count_sat ? count_sat : count;
+ factor = (update_factor * count / count_sat);
+ prob = ((int)cm->fc.pre_coef_probs[i][j][k][t] * (256 - factor) +
+ (int)coef_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1;
+ else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255;
+ else cm->fc.coef_probs[i][j][k][t] = prob;
+ }
+ }
+
+ for (i = 0; i < BLOCK_TYPES_8X8; ++i)
+ for (j = 0; j < COEF_BANDS; ++j)
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- coef_probs, branch_ct, cm->fc.coef_counts_8x8 [i][j][k],
- 256, 1);
- for (t=0; t<ENTROPY_NODES; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
- prob = ((int)cm->fc.pre_coef_probs_8x8[i][j][k][t] * (256-factor) +
- (int)coef_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.coef_probs_8x8[i][j][k][t] = 1;
- else if (prob > 255) cm->fc.coef_probs_8x8[i][j][k][t] = 255;
- else cm->fc.coef_probs_8x8[i][j][k][t] = prob;
- }
- }
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ coef_probs, branch_ct, cm->fc.coef_counts_8x8 [i][j][k],
+ 256, 1);
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > count_sat ? count_sat : count;
+ factor = (update_factor * count / count_sat);
+ prob = ((int)cm->fc.pre_coef_probs_8x8[i][j][k][t] * (256 - factor) +
+ (int)coef_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.coef_probs_8x8[i][j][k][t] = 1;
+ else if (prob > 255) cm->fc.coef_probs_8x8[i][j][k][t] = 255;
+ else cm->fc.coef_probs_8x8[i][j][k][t] = prob;
+ }
+ }
}
#endif
diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h
index 04339742b..bc6f16c5f 100644
--- a/vp8/common/entropy.h
+++ b/vp8/common/entropy.h
@@ -43,12 +43,11 @@ extern const vp8_tree_index vp8_coef_tree[];
extern struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
-typedef struct
-{
- vp8_tree_p tree;
- const vp8_prob *prob;
- int Len;
- int base_val;
+typedef struct {
+ vp8_tree_p tree;
+ const vp8_prob *prob;
+ int Len;
+ int base_val;
} vp8_extra_bit_struct;
extern vp8_extra_bit_struct vp8_extra_bits[12]; /* indexed by token value */
@@ -110,7 +109,7 @@ void vp8_default_coef_probs(struct VP8Common *);
extern DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]);
extern short vp8_default_zig_zag_mask[16];
extern DECLARE_ALIGNED(64, const int, vp8_default_zig_zag1d_8x8[64]);
-extern short vp8_default_zig_zag_mask_8x8[64];//int64_t
+extern short vp8_default_zig_zag_mask_8x8[64];// int64_t
void vp8_coef_tree_initialize(void);
#if CONFIG_ADAPTIVE_ENTROPY
diff --git a/vp8/common/entropymode.c b/vp8/common/entropymode.c
index 26179bef2..9edfe2eda 100644
--- a/vp8/common/entropymode.c
+++ b/vp8/common/entropymode.c
@@ -16,309 +16,296 @@
#include "vpx_mem/vpx_mem.h"
-const unsigned int kf_y_mode_cts[8][VP8_YMODES] =
-{
+const unsigned int kf_y_mode_cts[8][VP8_YMODES] = {
#if CONFIG_NEWINTRAMODES
- /* DC V H D45 135 117 153 D27 D63 TM i8x8 BPRED */
- {12, 6, 5, 5, 5, 5, 5, 5, 5, 2, 22, 200},
- {25, 13, 13, 7, 7, 7, 7, 7, 7, 6, 27, 160},
- {31, 17, 18, 8, 8, 8, 8, 8, 8, 9, 26, 139},
- {40, 22, 23, 8, 8, 8, 8, 8, 8, 12, 27, 116},
- {53, 26, 28, 8, 8, 8, 8, 8, 8, 13, 26, 94},
- {68, 33, 35, 8, 8, 8, 8, 8, 8, 17, 20, 68},
- {78, 38, 38, 8, 8, 8, 8, 8, 8, 19, 16, 52},
- {89, 42, 42, 8, 8, 8, 8, 8, 8, 21, 12, 34},
+ /* DC V H D45 135 117 153 D27 D63 TM i8x8 BPRED */
+ {12, 6, 5, 5, 5, 5, 5, 5, 5, 2, 22, 200},
+ {25, 13, 13, 7, 7, 7, 7, 7, 7, 6, 27, 160},
+ {31, 17, 18, 8, 8, 8, 8, 8, 8, 9, 26, 139},
+ {40, 22, 23, 8, 8, 8, 8, 8, 8, 12, 27, 116},
+ {53, 26, 28, 8, 8, 8, 8, 8, 8, 13, 26, 94},
+ {68, 33, 35, 8, 8, 8, 8, 8, 8, 17, 20, 68},
+ {78, 38, 38, 8, 8, 8, 8, 8, 8, 19, 16, 52},
+ {89, 42, 42, 8, 8, 8, 8, 8, 8, 21, 12, 34},
#else
- {17, 6, 5, 2, 22, 203},
- {27, 13, 13, 6, 27, 170},
- {35, 17, 18, 9, 26, 152},
- {45, 22, 24, 12, 27, 126},
- {58, 26, 29, 13, 26, 104},
- {73, 33, 36, 17, 20, 78},
- {88, 38, 39, 19, 16, 57},
- {99, 42, 43, 21, 12, 39},
+ {17, 6, 5, 2, 22, 203},
+ {27, 13, 13, 6, 27, 170},
+ {35, 17, 18, 9, 26, 152},
+ {45, 22, 24, 12, 27, 126},
+ {58, 26, 29, 13, 26, 104},
+ {73, 33, 36, 17, 20, 78},
+ {88, 38, 39, 19, 16, 57},
+ {99, 42, 43, 21, 12, 39},
#endif
};
static const unsigned int y_mode_cts [VP8_YMODES] =
#if CONFIG_NEWINTRAMODES
- /* DC V H D45 135 117 153 D27 D63 TM i8x8 BPRED */
- {98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 16, 70};
+ /* DC V H D45 135 117 153 D27 D63 TM i8x8 BPRED */
+{98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 16, 70};
#else
- {106, 25, 21, 13, 16, 74};
+ {
+ 106, 25, 21, 13, 16, 74
+ };
#endif
-static const unsigned int uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] ={
+static const unsigned int uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] = {
#if CONFIG_NEWINTRAMODES
- /* DC V H D45 135 117 153 D27 D63 TM */
- { 200, 15, 15, 10, 10, 10, 10, 10, 10, 6}, /* DC */
- { 130, 75, 10, 10, 10, 10, 10, 10, 10, 6}, /* V */
- { 130, 10, 75, 10, 10, 10, 10, 10, 10, 6}, /* H */
- { 130, 15, 10, 75, 10, 10, 10, 10, 10, 6}, /* D45 */
- { 150, 15, 10, 10, 75, 10, 10, 10, 10, 6}, /* D135 */
- { 150, 15, 10, 10, 10, 75, 10, 10, 10, 6}, /* D117 */
- { 150, 15, 10, 10, 10, 10, 75, 10, 10, 6}, /* D153 */
- { 150, 15, 10, 10, 10, 10, 10, 75, 10, 6}, /* D27 */
- { 150, 15, 10, 10, 10, 10, 10, 10, 75, 6}, /* D63 */
- { 160, 30, 30, 10, 10, 10, 10, 10, 10, 16}, /* TM */
- { 132, 46, 40, 10, 10, 10, 10, 10, 10, 18}, /* i8x8 - never used */
- { 150, 35, 41, 10, 10, 10, 10, 10, 10, 10}, /* BPRED */
+ /* DC V H D45 135 117 153 D27 D63 TM */
+ { 200, 15, 15, 10, 10, 10, 10, 10, 10, 6}, /* DC */
+ { 130, 75, 10, 10, 10, 10, 10, 10, 10, 6}, /* V */
+ { 130, 10, 75, 10, 10, 10, 10, 10, 10, 6}, /* H */
+ { 130, 15, 10, 75, 10, 10, 10, 10, 10, 6}, /* D45 */
+ { 150, 15, 10, 10, 75, 10, 10, 10, 10, 6}, /* D135 */
+ { 150, 15, 10, 10, 10, 75, 10, 10, 10, 6}, /* D117 */
+ { 150, 15, 10, 10, 10, 10, 75, 10, 10, 6}, /* D153 */
+ { 150, 15, 10, 10, 10, 10, 10, 75, 10, 6}, /* D27 */
+ { 150, 15, 10, 10, 10, 10, 10, 10, 75, 6}, /* D63 */
+ { 160, 30, 30, 10, 10, 10, 10, 10, 10, 16}, /* TM */
+ { 132, 46, 40, 10, 10, 10, 10, 10, 10, 18}, /* i8x8 - never used */
+ { 150, 35, 41, 10, 10, 10, 10, 10, 10, 10}, /* BPRED */
#else
- { 210, 20, 20, 6},
- { 180, 60, 10, 6},
- { 150, 20, 80, 6},
- { 170, 35, 35, 16},
- { 142, 51, 45, 18}, /* never used */
- { 160, 40, 46, 10},
+ { 210, 20, 20, 6},
+ { 180, 60, 10, 6},
+ { 150, 20, 80, 6},
+ { 170, 35, 35, 16},
+ { 142, 51, 45, 18}, /* never used */
+ { 160, 40, 46, 10},
#endif
};
static const unsigned int i8x8_mode_cts [VP8_I8X8_MODES] =
#if CONFIG_NEWINTRAMODES
- /* DC V H D45 135 117 153 D27 D63 TM */
- {73, 49, 61, 30, 30, 30, 30, 30, 30, 13};
+ /* DC V H D45 135 117 153 D27 D63 TM */
+{73, 49, 61, 30, 30, 30, 30, 30, 30, 13};
#else
- {93, 69, 81, 13};
+ {
+ 93, 69, 81, 13
+ };
#endif
-static const unsigned int kf_uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] ={
+static const unsigned int kf_uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] = {
#if CONFIG_NEWINTRAMODES
- // DC V H D45 135 117 153 D27 D63 TM
- { 160, 24, 24, 20, 20, 20, 20, 20, 20, 8}, /* DC */
- { 102, 64, 30, 20, 20, 20, 20, 20, 20, 10}, /* V */
- { 102, 30, 64, 20, 20, 20, 20, 20, 20, 10}, /* H */
- { 102, 33, 20, 64, 20, 20, 20, 20, 20, 14}, /* D45 */
- { 102, 33, 20, 20, 64, 20, 20, 20, 20, 14}, /* D135 */
- { 122, 33, 20, 20, 20, 64, 20, 20, 20, 14}, /* D117 */
- { 102, 33, 20, 20, 20, 20, 64, 20, 20, 14}, /* D153 */
- { 102, 33, 20, 20, 20, 20, 20, 64, 20, 14}, /* D27 */
- { 102, 33, 20, 20, 20, 20, 20, 20, 64, 14}, /* D63 */
- { 132, 36, 30, 20, 20, 20, 20, 20, 20, 18}, /* TM */
- { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* i8x8 - never used */
- { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* BPRED */
+ // DC V H D45 135 117 153 D27 D63 TM
+ { 160, 24, 24, 20, 20, 20, 20, 20, 20, 8}, /* DC */
+ { 102, 64, 30, 20, 20, 20, 20, 20, 20, 10}, /* V */
+ { 102, 30, 64, 20, 20, 20, 20, 20, 20, 10}, /* H */
+ { 102, 33, 20, 64, 20, 20, 20, 20, 20, 14}, /* D45 */
+ { 102, 33, 20, 20, 64, 20, 20, 20, 20, 14}, /* D135 */
+ { 122, 33, 20, 20, 20, 64, 20, 20, 20, 14}, /* D117 */
+ { 102, 33, 20, 20, 20, 20, 64, 20, 20, 14}, /* D153 */
+ { 102, 33, 20, 20, 20, 20, 20, 64, 20, 14}, /* D27 */
+ { 102, 33, 20, 20, 20, 20, 20, 20, 64, 14}, /* D63 */
+ { 132, 36, 30, 20, 20, 20, 20, 20, 20, 18}, /* TM */
+ { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* i8x8 - never used */
+ { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* BPRED */
#else
- { 180, 34, 34, 8},
- { 132, 74, 40, 10},
- { 132, 40, 74, 10},
- { 152, 46, 40, 18},
- { 142, 51, 45, 18}, /* never used */
- { 142, 51, 45, 18},
+ { 180, 34, 34, 8},
+ { 132, 74, 40, 10},
+ { 132, 40, 74, 10},
+ { 152, 46, 40, 18},
+ { 142, 51, 45, 18}, /* never used */
+ { 142, 51, 45, 18},
#endif
};
-static const unsigned int bmode_cts[VP8_BINTRAMODES] =
-{
- /* DC TM VE HE LD RD VR VL HD HU */
- 43891, 17694, 10036, 3920, 3363, 2546, 5119, 3221, 2471, 1723
+static const unsigned int bmode_cts[VP8_BINTRAMODES] = {
+ /* DC TM VE HE LD RD VR VL HD HU */
+ 43891, 17694, 10036, 3920, 3363, 2546, 5119, 3221, 2471, 1723
};
-typedef enum
-{
- SUBMVREF_NORMAL,
- SUBMVREF_LEFT_ZED,
- SUBMVREF_ABOVE_ZED,
- SUBMVREF_LEFT_ABOVE_SAME,
- SUBMVREF_LEFT_ABOVE_ZED
+typedef enum {
+ SUBMVREF_NORMAL,
+ SUBMVREF_LEFT_ZED,
+ SUBMVREF_ABOVE_ZED,
+ SUBMVREF_LEFT_ABOVE_SAME,
+ SUBMVREF_LEFT_ABOVE_ZED
} sumvfref_t;
-int vp8_mv_cont(const int_mv *l, const int_mv *a)
-{
- int lez = (l->as_int == 0);
- int aez = (a->as_int == 0);
- int lea = (l->as_int == a->as_int);
+int vp8_mv_cont(const int_mv *l, const int_mv *a) {
+ int lez = (l->as_int == 0);
+ int aez = (a->as_int == 0);
+ int lea = (l->as_int == a->as_int);
- if (lea && lez)
- return SUBMVREF_LEFT_ABOVE_ZED;
+ if (lea && lez)
+ return SUBMVREF_LEFT_ABOVE_ZED;
- if (lea)
- return SUBMVREF_LEFT_ABOVE_SAME;
+ if (lea)
+ return SUBMVREF_LEFT_ABOVE_SAME;
- if (aez)
- return SUBMVREF_ABOVE_ZED;
+ if (aez)
+ return SUBMVREF_ABOVE_ZED;
- if (lez)
- return SUBMVREF_LEFT_ZED;
+ if (lez)
+ return SUBMVREF_LEFT_ZED;
- return SUBMVREF_NORMAL;
+ return SUBMVREF_NORMAL;
}
-const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
+const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS - 1] = { 180, 162, 25};
-const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] =
-{
- { 147, 136, 18 },
- { 106, 145, 1 },
- { 179, 121, 1 },
- { 223, 1 , 34 },
- { 208, 1 , 1 }
+const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS - 1] = {
+ { 147, 136, 18 },
+ { 106, 145, 1 },
+ { 179, 121, 1 },
+ { 223, 1, 34 },
+ { 208, 1, 1 }
};
-vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] =
-{
- {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 1, 1, 1, 1,
- 1, 1, 1, 1,
- },
- {
- 0, 0, 1, 1,
- 0, 0, 1, 1,
- 0, 0, 1, 1,
- 0, 0, 1, 1,
- },
- {
- 0, 0, 1, 1,
- 0, 0, 1, 1,
- 2, 2, 3, 3,
- 2, 2, 3, 3,
- },
- {
- 0, 1, 2, 3,
- 4, 5, 6, 7,
- 8, 9, 10, 11,
- 12, 13, 14, 15,
- },
+vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] = {
+ {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 1, 1, 1, 1,
+ 1, 1, 1, 1,
+ },
+ {
+ 0, 0, 1, 1,
+ 0, 0, 1, 1,
+ 0, 0, 1, 1,
+ 0, 0, 1, 1,
+ },
+ {
+ 0, 0, 1, 1,
+ 0, 0, 1, 1,
+ 2, 2, 3, 3,
+ 2, 2, 3, 3,
+ },
+ {
+ 0, 1, 2, 3,
+ 4, 5, 6, 7,
+ 8, 9, 10, 11,
+ 12, 13, 14, 15,
+ },
};
const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16};
-const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150};
+const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS - 1] = { 110, 111, 150};
/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
-const vp8_tree_index vp8_bmode_tree[VP8_BINTRAMODES*2-2] = /* INTRAMODECONTEXTNODE value */
+const vp8_tree_index vp8_bmode_tree[VP8_BINTRAMODES * 2 - 2] = /* INTRAMODECONTEXTNODE value */
{
- -B_DC_PRED, 2, /* 0 = DC_NODE */
- -B_TM_PRED, 4, /* 1 = TM_NODE */
- -B_VE_PRED, 6, /* 2 = VE_NODE */
- 8, 12, /* 3 = COM_NODE */
- -B_HE_PRED, 10, /* 4 = HE_NODE */
- -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */
- -B_LD_PRED, 14, /* 6 = LD_NODE */
- -B_VL_PRED, 16, /* 7 = VL_NODE */
- -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */
+ -B_DC_PRED, 2, /* 0 = DC_NODE */
+ -B_TM_PRED, 4, /* 1 = TM_NODE */
+ -B_VE_PRED, 6, /* 2 = VE_NODE */
+ 8, 12, /* 3 = COM_NODE */
+ -B_HE_PRED, 10, /* 4 = HE_NODE */
+ -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */
+ -B_LD_PRED, 14, /* 6 = LD_NODE */
+ -B_VL_PRED, 16, /* 7 = VL_NODE */
+ -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */
};
#if CONFIG_NEWINTRAMODES
/* Again, these trees use the same probability indices as their
explicitly-programmed predecessors. */
-const vp8_tree_index vp8_ymode_tree[VP8_YMODES*2-2] =
-{
- 2, 14,
- -DC_PRED, 4,
- 6, 8,
- -D45_PRED, -D135_PRED,
- 10, 12,
- -D117_PRED, -D153_PRED,
- -D27_PRED, -D63_PRED,
- 16, 18,
- -V_PRED, -H_PRED,
- -TM_PRED, 20,
- -B_PRED, -I8X8_PRED
+const vp8_tree_index vp8_ymode_tree[VP8_YMODES * 2 - 2] = {
+ 2, 14,
+ -DC_PRED, 4,
+ 6, 8,
+ -D45_PRED, -D135_PRED,
+ 10, 12,
+ -D117_PRED, -D153_PRED,
+ -D27_PRED, -D63_PRED,
+ 16, 18,
+ -V_PRED, -H_PRED,
+ -TM_PRED, 20,
+ -B_PRED, -I8X8_PRED
};
-const vp8_tree_index vp8_kf_ymode_tree[VP8_YMODES*2-2] =
-{
- 2, 14,
- -DC_PRED, 4,
- 6, 8,
- -D45_PRED, -D135_PRED,
- 10, 12,
- -D117_PRED, -D153_PRED,
- -D27_PRED, -D63_PRED,
- 16, 18,
- -V_PRED, -H_PRED,
- -TM_PRED, 20,
- -B_PRED, -I8X8_PRED
+const vp8_tree_index vp8_kf_ymode_tree[VP8_YMODES * 2 - 2] = {
+ 2, 14,
+ -DC_PRED, 4,
+ 6, 8,
+ -D45_PRED, -D135_PRED,
+ 10, 12,
+ -D117_PRED, -D153_PRED,
+ -D27_PRED, -D63_PRED,
+ 16, 18,
+ -V_PRED, -H_PRED,
+ -TM_PRED, 20,
+ -B_PRED, -I8X8_PRED
};
-const vp8_tree_index vp8_i8x8_mode_tree[VP8_I8X8_MODES*2-2] =
-{
- 2, 14,
- -DC_PRED, 4,
- 6, 8,
- -D45_PRED, -D135_PRED,
- 10, 12,
- -D117_PRED, -D153_PRED,
- -D27_PRED, -D63_PRED,
- -V_PRED, 16,
- -H_PRED, -TM_PRED
+const vp8_tree_index vp8_i8x8_mode_tree[VP8_I8X8_MODES * 2 - 2] = {
+ 2, 14,
+ -DC_PRED, 4,
+ 6, 8,
+ -D45_PRED, -D135_PRED,
+ 10, 12,
+ -D117_PRED, -D153_PRED,
+ -D27_PRED, -D63_PRED,
+ -V_PRED, 16,
+ -H_PRED, -TM_PRED
};
-const vp8_tree_index vp8_uv_mode_tree[VP8_UV_MODES*2-2] =
-{
- 2, 14,
- -DC_PRED, 4,
- 6, 8,
- -D45_PRED, -D135_PRED,
- 10, 12,
- -D117_PRED, -D153_PRED,
- -D27_PRED, -D63_PRED,
- -V_PRED, 16,
- -H_PRED, -TM_PRED
+const vp8_tree_index vp8_uv_mode_tree[VP8_UV_MODES * 2 - 2] = {
+ 2, 14,
+ -DC_PRED, 4,
+ 6, 8,
+ -D45_PRED, -D135_PRED,
+ 10, 12,
+ -D117_PRED, -D153_PRED,
+ -D27_PRED, -D63_PRED,
+ -V_PRED, 16,
+ -H_PRED, -TM_PRED
};
#else /* CONFIG_NEWINTRAMODES */
/* Again, these trees use the same probability indices as their
explicitly-programmed predecessors. */
-const vp8_tree_index vp8_ymode_tree[10] =
-{
- -DC_PRED, 2,
- 4, 6,
- -V_PRED, -H_PRED,
- -TM_PRED, 8,
- -B_PRED, -I8X8_PRED
+const vp8_tree_index vp8_ymode_tree[10] = {
+ -DC_PRED, 2,
+ 4, 6,
+ -V_PRED, -H_PRED,
+ -TM_PRED, 8,
+ -B_PRED, -I8X8_PRED
};
-const vp8_tree_index vp8_kf_ymode_tree[10] =
-{
- -B_PRED, 2,
- 4, 6,
- -DC_PRED, -V_PRED,
- -H_PRED, 8,
- -TM_PRED, -I8X8_PRED
+const vp8_tree_index vp8_kf_ymode_tree[10] = {
+ -B_PRED, 2,
+ 4, 6,
+ -DC_PRED, -V_PRED,
+ -H_PRED, 8,
+ -TM_PRED, -I8X8_PRED
};
-const vp8_tree_index vp8_i8x8_mode_tree[6] =
-{
- -DC_PRED, 2,
- -V_PRED, 4,
- -H_PRED, -TM_PRED
+const vp8_tree_index vp8_i8x8_mode_tree[6] = {
+ -DC_PRED, 2,
+ -V_PRED, 4,
+ -H_PRED, -TM_PRED
};
-const vp8_tree_index vp8_uv_mode_tree[6] =
-{
- -DC_PRED, 2,
- -V_PRED, 4,
- -H_PRED, -TM_PRED
+const vp8_tree_index vp8_uv_mode_tree[6] = {
+ -DC_PRED, 2,
+ -V_PRED, 4,
+ -H_PRED, -TM_PRED
};
#endif /* CONFIG_NEWINTRAMODES */
-const vp8_tree_index vp8_mbsplit_tree[6] =
-{
- -3, 2,
- -2, 4,
- -0, -1
+const vp8_tree_index vp8_mbsplit_tree[6] = {
+ -3, 2,
+ -2, 4,
+ -0, -1
};
-const vp8_tree_index vp8_mv_ref_tree[8] =
-{
- -ZEROMV, 2,
- -NEARESTMV, 4,
- -NEARMV, 6,
- -NEWMV, -SPLITMV
+const vp8_tree_index vp8_mv_ref_tree[8] = {
+ -ZEROMV, 2,
+ -NEARESTMV, 4,
+ -NEARMV, 6,
+ -NEWMV, -SPLITMV
};
-const vp8_tree_index vp8_sub_mv_ref_tree[6] =
-{
- -LEFT4X4, 2,
- -ABOVE4X4, 4,
- -ZERO4X4, -NEW4X4
+const vp8_tree_index vp8_sub_mv_ref_tree[6] = {
+ -LEFT4X4, 2,
+ -ABOVE4X4, 4,
+ -ZERO4X4, -NEW4X4
};
@@ -334,404 +321,354 @@ struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
-void vp8_init_mbmode_probs(VP8_COMMON *x)
-{
- unsigned int bct [VP8_YMODES] [2]; /* num Ymodes > num UV modes */
+void vp8_init_mbmode_probs(VP8_COMMON *x) {
+ unsigned int bct [VP8_YMODES] [2]; /* num Ymodes > num UV modes */
- vp8_tree_probs_from_distribution(
- VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
- x->fc.ymode_prob, bct, y_mode_cts,
+ vp8_tree_probs_from_distribution(
+ VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
+ x->fc.ymode_prob, bct, y_mode_cts,
+ 256, 1
+ );
+ {
+ int i;
+ for (i = 0; i < 8; i++)
+ vp8_tree_probs_from_distribution(
+ VP8_YMODES, vp8_kf_ymode_encodings, vp8_kf_ymode_tree,
+ x->kf_ymode_prob[i], bct, kf_y_mode_cts[i],
256, 1
- );
- {
- int i;
- for (i=0;i<8;i++)
- vp8_tree_probs_from_distribution(
- VP8_YMODES, vp8_kf_ymode_encodings, vp8_kf_ymode_tree,
- x->kf_ymode_prob[i], bct, kf_y_mode_cts[i],
- 256, 1
- );
- }
- {
- int i;
- for (i=0;i<VP8_YMODES;i++)
- {
- vp8_tree_probs_from_distribution(
- VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
- x->kf_uv_mode_prob[i], bct, kf_uv_mode_cts[i],
- 256, 1);
- vp8_tree_probs_from_distribution(
- VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
- x->fc.uv_mode_prob[i], bct, uv_mode_cts[i],
- 256, 1);
- }
+ );
+ }
+ {
+ int i;
+ for (i = 0; i < VP8_YMODES; i++) {
+ vp8_tree_probs_from_distribution(
+ VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
+ x->kf_uv_mode_prob[i], bct, kf_uv_mode_cts[i],
+ 256, 1);
+ vp8_tree_probs_from_distribution(
+ VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
+ x->fc.uv_mode_prob[i], bct, uv_mode_cts[i],
+ 256, 1);
}
+ }
- vp8_tree_probs_from_distribution(
- VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
- x->fc.i8x8_mode_prob, bct, i8x8_mode_cts,
- 256, 1);
+ vp8_tree_probs_from_distribution(
+ VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
+ x->fc.i8x8_mode_prob, bct, i8x8_mode_cts,
+ 256, 1);
- vpx_memcpy(x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_prob2, sizeof(vp8_sub_mv_ref_prob2));
- vpx_memcpy(x->fc.mbsplit_prob, vp8_mbsplit_probs, sizeof(vp8_mbsplit_probs));
+ vpx_memcpy(x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_prob2, sizeof(vp8_sub_mv_ref_prob2));
+ vpx_memcpy(x->fc.mbsplit_prob, vp8_mbsplit_probs, sizeof(vp8_mbsplit_probs));
}
static void intra_bmode_probs_from_distribution(
- vp8_prob p [VP8_BINTRAMODES-1],
- unsigned int branch_ct [VP8_BINTRAMODES-1] [2],
- const unsigned int events [VP8_BINTRAMODES]
-)
-{
- vp8_tree_probs_from_distribution(
- VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
- p, branch_ct, events,
- 256, 1
- );
+ vp8_prob p [VP8_BINTRAMODES - 1],
+ unsigned int branch_ct [VP8_BINTRAMODES - 1] [2],
+ const unsigned int events [VP8_BINTRAMODES]
+) {
+ vp8_tree_probs_from_distribution(
+ VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
+ p, branch_ct, events,
+ 256, 1
+ );
}
-void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1])
-{
- unsigned int branch_ct [VP8_BINTRAMODES-1] [2];
- intra_bmode_probs_from_distribution(p, branch_ct, bmode_cts);
+void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES - 1]) {
+ unsigned int branch_ct [VP8_BINTRAMODES - 1] [2];
+ intra_bmode_probs_from_distribution(p, branch_ct, bmode_cts);
}
-void vp8_kf_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1])
-{
- unsigned int branch_ct [VP8_BINTRAMODES-1] [2];
+void vp8_kf_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES - 1]) {
+ unsigned int branch_ct [VP8_BINTRAMODES - 1] [2];
- int i = 0;
+ int i = 0;
- do
- {
- int j = 0;
+ do {
+ int j = 0;
- do
- {
- intra_bmode_probs_from_distribution(
- p[i][j], branch_ct, vp8_kf_default_bmode_counts[i][j]);
+ do {
+ intra_bmode_probs_from_distribution(
+ p[i][j], branch_ct, vp8_kf_default_bmode_counts[i][j]);
- }
- while (++j < VP8_BINTRAMODES);
- }
- while (++i < VP8_BINTRAMODES);
+ } while (++j < VP8_BINTRAMODES);
+ } while (++i < VP8_BINTRAMODES);
}
-void vp8_entropy_mode_init()
-{
- vp8_tokens_from_tree(vp8_bmode_encodings, vp8_bmode_tree);
- vp8_tokens_from_tree(vp8_ymode_encodings, vp8_ymode_tree);
- vp8_tokens_from_tree(vp8_kf_ymode_encodings, vp8_kf_ymode_tree);
- vp8_tokens_from_tree(vp8_uv_mode_encodings, vp8_uv_mode_tree);
- vp8_tokens_from_tree(vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree);
- vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
-
- vp8_tokens_from_tree_offset(vp8_mv_ref_encoding_array,
- vp8_mv_ref_tree, NEARESTMV);
- vp8_tokens_from_tree_offset(vp8_sub_mv_ref_encoding_array,
- vp8_sub_mv_ref_tree, LEFT4X4);
+void vp8_entropy_mode_init() {
+ vp8_tokens_from_tree(vp8_bmode_encodings, vp8_bmode_tree);
+ vp8_tokens_from_tree(vp8_ymode_encodings, vp8_ymode_tree);
+ vp8_tokens_from_tree(vp8_kf_ymode_encodings, vp8_kf_ymode_tree);
+ vp8_tokens_from_tree(vp8_uv_mode_encodings, vp8_uv_mode_tree);
+ vp8_tokens_from_tree(vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree);
+ vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
+
+ vp8_tokens_from_tree_offset(vp8_mv_ref_encoding_array,
+ vp8_mv_ref_tree, NEARESTMV);
+ vp8_tokens_from_tree_offset(vp8_sub_mv_ref_encoding_array,
+ vp8_sub_mv_ref_tree, LEFT4X4);
}
-void vp8_init_mode_contexts(VP8_COMMON *pc)
-{
- vpx_memset(pc->fc.mv_ref_ct, 0, sizeof(pc->fc.mv_ref_ct));
- vpx_memset(pc->fc.mv_ref_ct_a, 0, sizeof(pc->fc.mv_ref_ct_a));
+void vp8_init_mode_contexts(VP8_COMMON *pc) {
+ vpx_memset(pc->fc.mv_ref_ct, 0, sizeof(pc->fc.mv_ref_ct));
+ vpx_memset(pc->fc.mv_ref_ct_a, 0, sizeof(pc->fc.mv_ref_ct_a));
- vpx_memcpy( pc->fc.mode_context,
- default_vp8_mode_contexts,
- sizeof (pc->fc.mode_context));
- vpx_memcpy( pc->fc.mode_context_a,
- default_vp8_mode_contexts,
- sizeof (pc->fc.mode_context_a));
+ vpx_memcpy(pc->fc.mode_context,
+ default_vp8_mode_contexts,
+ sizeof(pc->fc.mode_context));
+ vpx_memcpy(pc->fc.mode_context_a,
+ default_vp8_mode_contexts,
+ sizeof(pc->fc.mode_context_a));
}
void vp8_accum_mv_refs(VP8_COMMON *pc,
MB_PREDICTION_MODE m,
- const int ct[4])
-{
- int (*mv_ref_ct)[4][2];
-
- if(pc->refresh_alt_ref_frame)
- mv_ref_ct = pc->fc.mv_ref_ct_a;
- else
- mv_ref_ct = pc->fc.mv_ref_ct;
-
- if (m == ZEROMV)
- {
- ++mv_ref_ct [ct[0]] [0] [0];
- }
- else
- {
- ++mv_ref_ct [ct[0]] [0] [1];
- if (m == NEARESTMV)
- {
- ++mv_ref_ct [ct[1]] [1] [0];
- }
- else
- {
- ++mv_ref_ct [ct[1]] [1] [1];
- if (m == NEARMV)
- {
- ++mv_ref_ct [ct[2]] [2] [0];
- }
- else
- {
- ++mv_ref_ct [ct[2]] [2] [1];
- if (m == NEWMV)
- {
- ++mv_ref_ct [ct[3]] [3] [0];
- }
- else
- {
- ++mv_ref_ct [ct[3]] [3] [1];
- }
- }
+ const int ct[4]) {
+ int (*mv_ref_ct)[4][2];
+
+ if (pc->refresh_alt_ref_frame)
+ mv_ref_ct = pc->fc.mv_ref_ct_a;
+ else
+ mv_ref_ct = pc->fc.mv_ref_ct;
+
+ if (m == ZEROMV) {
+ ++mv_ref_ct [ct[0]] [0] [0];
+ } else {
+ ++mv_ref_ct [ct[0]] [0] [1];
+ if (m == NEARESTMV) {
+ ++mv_ref_ct [ct[1]] [1] [0];
+ } else {
+ ++mv_ref_ct [ct[1]] [1] [1];
+ if (m == NEARMV) {
+ ++mv_ref_ct [ct[2]] [2] [0];
+ } else {
+ ++mv_ref_ct [ct[2]] [2] [1];
+ if (m == NEWMV) {
+ ++mv_ref_ct [ct[3]] [3] [0];
+ } else {
+ ++mv_ref_ct [ct[3]] [3] [1];
}
+ }
}
+ }
}
#define MVREF_COUNT_SAT 20
#define MVREF_MAX_UPDATE_FACTOR 128
-void vp8_update_mode_context(VP8_COMMON *pc)
-{
- int i, j;
- int (*mv_ref_ct)[4][2];
- int (*mode_context)[4];
-
- if(pc->refresh_alt_ref_frame)
- {
- mv_ref_ct = pc->fc.mv_ref_ct_a;
- mode_context = pc->fc.mode_context_a;
- }
- else
- {
- mv_ref_ct = pc->fc.mv_ref_ct;
- mode_context = pc->fc.mode_context;
- }
-
- for (j = 0; j < 6; j++)
- {
- for (i = 0; i < 4; i++)
- {
- int this_prob;
- int count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
+void vp8_update_mode_context(VP8_COMMON *pc) {
+ int i, j;
+ int (*mv_ref_ct)[4][2];
+ int (*mode_context)[4];
+
+ if (pc->refresh_alt_ref_frame) {
+ mv_ref_ct = pc->fc.mv_ref_ct_a;
+ mode_context = pc->fc.mode_context_a;
+ } else {
+ mv_ref_ct = pc->fc.mv_ref_ct;
+ mode_context = pc->fc.mode_context;
+ }
+
+ for (j = 0; j < 6; j++) {
+ for (i = 0; i < 4; i++) {
+ int this_prob;
+ int count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
#if CONFIG_ADAPTIVE_ENTROPY
- int factor;
- {
- this_prob = count > 0 ? 256 * mv_ref_ct[j][i][0] / count : 128;
- count = count > MVREF_COUNT_SAT ? MVREF_COUNT_SAT : count;
- factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT);
- this_prob = (pc->fc.vp8_mode_contexts[j][i] * (256 - factor) +
- this_prob * factor + 128) >> 8;
- this_prob = this_prob? (this_prob<255?this_prob:255):1;
- mode_context[j][i] = this_prob;
- }
+ int factor;
+ {
+ this_prob = count > 0 ? 256 * mv_ref_ct[j][i][0] / count : 128;
+ count = count > MVREF_COUNT_SAT ? MVREF_COUNT_SAT : count;
+ factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT);
+ this_prob = (pc->fc.vp8_mode_contexts[j][i] * (256 - factor) +
+ this_prob * factor + 128) >> 8;
+ this_prob = this_prob ? (this_prob < 255 ? this_prob : 255) : 1;
+ mode_context[j][i] = this_prob;
+ }
#else
- /* preventing rare occurances from skewing the probs */
- if (count>=4)
- {
- this_prob = 256 * mv_ref_ct[j][i][0] / count;
- this_prob = this_prob? (this_prob<255?this_prob:255):1;
- mode_context[j][i] = this_prob;
- }
+ /* preventing rare occurances from skewing the probs */
+ if (count >= 4) {
+ this_prob = 256 * mv_ref_ct[j][i][0] / count;
+ this_prob = this_prob ? (this_prob < 255 ? this_prob : 255) : 1;
+ mode_context[j][i] = this_prob;
+ }
#endif
- }
}
+ }
}
#include "vp8/common/modecont.h"
-void print_mode_contexts(VP8_COMMON *pc)
-{
- int j, i;
- printf("\n====================\n");
- for(j=0; j<6; j++)
- {
- for (i = 0; i < 4; i++)
- {
- printf( "%4d ", pc->fc.mode_context[j][i]);
- }
- printf("\n");
+void print_mode_contexts(VP8_COMMON *pc) {
+ int j, i;
+ printf("\n====================\n");
+ for (j = 0; j < 6; j++) {
+ for (i = 0; i < 4; i++) {
+ printf("%4d ", pc->fc.mode_context[j][i]);
}
- printf("====================\n");
- for(j=0; j<6; j++)
- {
- for (i = 0; i < 4; i++)
- {
- printf( "%4d ", pc->fc.mode_context_a[j][i]);
- }
- printf("\n");
+ printf("\n");
+ }
+ printf("====================\n");
+ for (j = 0; j < 6; j++) {
+ for (i = 0; i < 4; i++) {
+ printf("%4d ", pc->fc.mode_context_a[j][i]);
}
+ printf("\n");
+ }
}
-void print_mv_ref_cts(VP8_COMMON *pc)
-{
- int j, i;
- for(j=0; j<6; j++)
- {
- for (i = 0; i < 4; i++)
- {
- printf("(%4d:%4d) ",
- pc->fc.mv_ref_ct[j][i][0],
- pc->fc.mv_ref_ct[j][i][1]);
- }
- printf("\n");
+void print_mv_ref_cts(VP8_COMMON *pc) {
+ int j, i;
+ for (j = 0; j < 6; j++) {
+ for (i = 0; i < 4; i++) {
+ printf("(%4d:%4d) ",
+ pc->fc.mv_ref_ct[j][i][0],
+ pc->fc.mv_ref_ct[j][i][1]);
}
+ printf("\n");
+ }
}
#if CONFIG_ADAPTIVE_ENTROPY
-//#define MODE_COUNT_TESTING
+// #define MODE_COUNT_TESTING
#define MODE_COUNT_SAT 16
#define MODE_MAX_UPDATE_FACTOR 128
-void vp8_adapt_mode_probs(VP8_COMMON *cm)
-{
- int i, t, count, factor;
- unsigned int branch_ct[32][2];
- vp8_prob ymode_probs[VP8_YMODES-1];
- vp8_prob uvmode_probs[VP8_UV_MODES-1];
- vp8_prob bmode_probs[VP8_BINTRAMODES-1];
- vp8_prob i8x8_mode_probs[VP8_I8X8_MODES-1];
- vp8_prob sub_mv_ref_probs[VP8_SUBMVREFS-1];
- vp8_prob mbsplit_probs[VP8_NUMMBSPLITS-1];
+void vp8_adapt_mode_probs(VP8_COMMON *cm) {
+ int i, t, count, factor;
+ unsigned int branch_ct[32][2];
+ vp8_prob ymode_probs[VP8_YMODES - 1];
+ vp8_prob uvmode_probs[VP8_UV_MODES - 1];
+ vp8_prob bmode_probs[VP8_BINTRAMODES - 1];
+ vp8_prob i8x8_mode_probs[VP8_I8X8_MODES - 1];
+ vp8_prob sub_mv_ref_probs[VP8_SUBMVREFS - 1];
+ vp8_prob mbsplit_probs[VP8_NUMMBSPLITS - 1];
#ifdef MODE_COUNT_TESTING
- printf("static const unsigned int\nymode_counts"
- "[VP8_YMODES] = {\n");
- for (t = 0; t<VP8_YMODES; ++t) printf("%d, ", cm->fc.ymode_counts[t]);
- printf("};\n");
- printf("static const unsigned int\nuv_mode_counts"
- "[VP8_YMODES] [VP8_UV_MODES] = {\n");
- for (i = 0; i < VP8_YMODES; ++i)
- {
- printf(" {");
- for (t = 0; t < VP8_UV_MODES; ++t) printf("%d, ", cm->fc.uv_mode_counts[i][t]);
- printf("},\n");
- }
- printf("};\n");
- printf("static const unsigned int\nbmode_counts"
- "[VP8_BINTRAMODES] = {\n");
- for (t = 0; t<VP8_BINTRAMODES; ++t) printf("%d, ", cm->fc.bmode_counts[t]);
- printf("};\n");
- printf("static const unsigned int\ni8x8_mode_counts"
- "[VP8_I8X8_MODES] = {\n");
- for (t = 0; t<VP8_I8X8_MODES; ++t) printf("%d, ", cm->fc.i8x8_mode_counts[t]);
- printf("};\n");
- printf("static const unsigned int\nsub_mv_ref_counts"
- "[SUBMVREF_COUNT] [VP8_SUBMVREFS] = {\n");
- for (i = 0; i < SUBMVREF_COUNT; ++i)
- {
- printf(" {");
- for (t = 0; t < VP8_SUBMVREFS; ++t) printf("%d, ", cm->fc.sub_mv_ref_counts[i][t]);
- printf("},\n");
- }
- printf("};\n");
- printf("static const unsigned int\nmbsplit_counts"
- "[VP8_NUMMBSPLITS] = {\n");
- for (t = 0; t<VP8_NUMMBSPLITS; ++t) printf("%d, ", cm->fc.mbsplit_counts[t]);
- printf("};\n");
+ printf("static const unsigned int\nymode_counts"
+ "[VP8_YMODES] = {\n");
+ for (t = 0; t < VP8_YMODES; ++t) printf("%d, ", cm->fc.ymode_counts[t]);
+ printf("};\n");
+ printf("static const unsigned int\nuv_mode_counts"
+ "[VP8_YMODES] [VP8_UV_MODES] = {\n");
+ for (i = 0; i < VP8_YMODES; ++i) {
+ printf(" {");
+ for (t = 0; t < VP8_UV_MODES; ++t) printf("%d, ", cm->fc.uv_mode_counts[i][t]);
+ printf("},\n");
+ }
+ printf("};\n");
+ printf("static const unsigned int\nbmode_counts"
+ "[VP8_BINTRAMODES] = {\n");
+ for (t = 0; t < VP8_BINTRAMODES; ++t) printf("%d, ", cm->fc.bmode_counts[t]);
+ printf("};\n");
+ printf("static const unsigned int\ni8x8_mode_counts"
+ "[VP8_I8X8_MODES] = {\n");
+ for (t = 0; t < VP8_I8X8_MODES; ++t) printf("%d, ", cm->fc.i8x8_mode_counts[t]);
+ printf("};\n");
+ printf("static const unsigned int\nsub_mv_ref_counts"
+ "[SUBMVREF_COUNT] [VP8_SUBMVREFS] = {\n");
+ for (i = 0; i < SUBMVREF_COUNT; ++i) {
+ printf(" {");
+ for (t = 0; t < VP8_SUBMVREFS; ++t) printf("%d, ", cm->fc.sub_mv_ref_counts[i][t]);
+ printf("},\n");
+ }
+ printf("};\n");
+ printf("static const unsigned int\nmbsplit_counts"
+ "[VP8_NUMMBSPLITS] = {\n");
+ for (t = 0; t < VP8_NUMMBSPLITS; ++t) printf("%d, ", cm->fc.mbsplit_counts[t]);
+ printf("};\n");
#endif
+ vp8_tree_probs_from_distribution(
+ VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
+ ymode_probs, branch_ct, cm->fc.ymode_counts,
+ 256, 1);
+ for (t = 0; t < VP8_YMODES - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_ymode_prob[t] * (256 - factor) +
+ (int)ymode_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.ymode_prob[t] = 1;
+ else if (prob > 255) cm->fc.ymode_prob[t] = 255;
+ else cm->fc.ymode_prob[t] = prob;
+ }
+ for (i = 0; i < VP8_YMODES; ++i) {
vp8_tree_probs_from_distribution(
- VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
- ymode_probs, branch_ct, cm->fc.ymode_counts,
- 256, 1);
- for (t=0; t<VP8_YMODES-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_ymode_prob[t] * (256-factor) +
- (int)ymode_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.ymode_prob[t] = 1;
- else if (prob > 255) cm->fc.ymode_prob[t] = 255;
- else cm->fc.ymode_prob[t] = prob;
- }
- for (i = 0; i < VP8_YMODES; ++i)
- {
- vp8_tree_probs_from_distribution(
- VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
- uvmode_probs, branch_ct, cm->fc.uv_mode_counts[i],
- 256, 1);
- for (t = 0; t < VP8_UV_MODES-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256-factor) +
- (int)uvmode_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.uv_mode_prob[i][t] = 1;
- else if (prob > 255) cm->fc.uv_mode_prob[i][t] = 255;
- else cm->fc.uv_mode_prob[i][t] = prob;
- }
- }
- vp8_tree_probs_from_distribution(
- VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
- bmode_probs, branch_ct, cm->fc.bmode_counts,
- 256, 1);
- for (t=0; t<VP8_BINTRAMODES-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_bmode_prob[t] * (256-factor) +
- (int)bmode_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.bmode_prob[t] = 1;
- else if (prob > 255) cm->fc.bmode_prob[t] = 255;
- else cm->fc.bmode_prob[t] = prob;
- }
- vp8_tree_probs_from_distribution(
- VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
- i8x8_mode_probs, branch_ct, cm->fc.i8x8_mode_counts,
- 256, 1);
- for (t=0; t<VP8_I8X8_MODES-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256-factor) +
- (int)i8x8_mode_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.i8x8_mode_prob[t] = 1;
- else if (prob > 255) cm->fc.i8x8_mode_prob[t] = 255;
- else cm->fc.i8x8_mode_prob[t] = prob;
- }
- for (i = 0; i < SUBMVREF_COUNT; ++i)
- {
- vp8_tree_probs_from_distribution(
- VP8_SUBMVREFS, vp8_sub_mv_ref_encoding_array, vp8_sub_mv_ref_tree,
- sub_mv_ref_probs, branch_ct, cm->fc.sub_mv_ref_counts[i],
- 256, 1);
- for (t = 0; t < VP8_SUBMVREFS-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256-factor) +
- (int)sub_mv_ref_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.sub_mv_ref_prob[i][t] = 1;
- else if (prob > 255) cm->fc.sub_mv_ref_prob[i][t] = 255;
- else cm->fc.sub_mv_ref_prob[i][t] = prob;
- }
+ VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
+ uvmode_probs, branch_ct, cm->fc.uv_mode_counts[i],
+ 256, 1);
+ for (t = 0; t < VP8_UV_MODES - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256 - factor) +
+ (int)uvmode_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.uv_mode_prob[i][t] = 1;
+ else if (prob > 255) cm->fc.uv_mode_prob[i][t] = 255;
+ else cm->fc.uv_mode_prob[i][t] = prob;
}
+ }
+ vp8_tree_probs_from_distribution(
+ VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
+ bmode_probs, branch_ct, cm->fc.bmode_counts,
+ 256, 1);
+ for (t = 0; t < VP8_BINTRAMODES - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_bmode_prob[t] * (256 - factor) +
+ (int)bmode_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.bmode_prob[t] = 1;
+ else if (prob > 255) cm->fc.bmode_prob[t] = 255;
+ else cm->fc.bmode_prob[t] = prob;
+ }
+ vp8_tree_probs_from_distribution(
+ VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
+ i8x8_mode_probs, branch_ct, cm->fc.i8x8_mode_counts,
+ 256, 1);
+ for (t = 0; t < VP8_I8X8_MODES - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256 - factor) +
+ (int)i8x8_mode_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.i8x8_mode_prob[t] = 1;
+ else if (prob > 255) cm->fc.i8x8_mode_prob[t] = 255;
+ else cm->fc.i8x8_mode_prob[t] = prob;
+ }
+ for (i = 0; i < SUBMVREF_COUNT; ++i) {
vp8_tree_probs_from_distribution(
- VP8_NUMMBSPLITS, vp8_mbsplit_encodings, vp8_mbsplit_tree,
- mbsplit_probs, branch_ct, cm->fc.mbsplit_counts,
- 256, 1);
- for (t = 0; t < VP8_NUMMBSPLITS-1; ++t)
- {
- int prob;
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
- factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
- prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) +
- (int)mbsplit_probs[t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mbsplit_prob[t] = 1;
- else if (prob > 255) cm->fc.mbsplit_prob[t] = 255;
- else cm->fc.mbsplit_prob[t] = prob;
+ VP8_SUBMVREFS, vp8_sub_mv_ref_encoding_array, vp8_sub_mv_ref_tree,
+ sub_mv_ref_probs, branch_ct, cm->fc.sub_mv_ref_counts[i],
+ 256, 1);
+ for (t = 0; t < VP8_SUBMVREFS - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256 - factor) +
+ (int)sub_mv_ref_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.sub_mv_ref_prob[i][t] = 1;
+ else if (prob > 255) cm->fc.sub_mv_ref_prob[i][t] = 255;
+ else cm->fc.sub_mv_ref_prob[i][t] = prob;
}
+ }
+ vp8_tree_probs_from_distribution(
+ VP8_NUMMBSPLITS, vp8_mbsplit_encodings, vp8_mbsplit_tree,
+ mbsplit_probs, branch_ct, cm->fc.mbsplit_counts,
+ 256, 1);
+ for (t = 0; t < VP8_NUMMBSPLITS - 1; ++t) {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) +
+ (int)mbsplit_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mbsplit_prob[t] = 1;
+ else if (prob > 255) cm->fc.mbsplit_prob[t] = 255;
+ else cm->fc.mbsplit_prob[t] = prob;
+ }
}
#endif
diff --git a/vp8/common/entropymode.h b/vp8/common/entropymode.h
index e8f22df9b..5d753f7e3 100644
--- a/vp8/common/entropymode.h
+++ b/vp8/common/entropymode.h
@@ -21,12 +21,12 @@ extern vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS];
extern const int vp8_mbsplit_count [VP8_NUMMBSPLITS]; /* # of subsets */
-extern const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1];
+extern const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS - 1];
extern int vp8_mv_cont(const int_mv *l, const int_mv *a);
-extern const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS-1];
-extern const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
+extern const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS - 1];
+extern const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS - 1];
extern const unsigned int vp8_kf_default_bmode_counts [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES];
@@ -60,11 +60,11 @@ void vp8_init_mbmode_probs(VP8_COMMON *x);
extern void vp8_init_mode_contexts(VP8_COMMON *pc);
extern void vp8_update_mode_context(VP8_COMMON *pc);;
extern void vp8_accum_mv_refs(VP8_COMMON *pc,
- MB_PREDICTION_MODE m,
- const int ct[4]);
+ MB_PREDICTION_MODE m,
+ const int ct[4]);
-void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
-void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]);
+void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES - 1]);
+void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES - 1]);
#if CONFIG_ADAPTIVE_ENTROPY
void vp8_adapt_mode_probs(struct VP8Common *);
diff --git a/vp8/common/entropymv.c b/vp8/common/entropymv.c
index 2c27b0913..6c91e364a 100644
--- a/vp8/common/entropymv.c
+++ b/vp8/common/entropymv.c
@@ -13,427 +13,403 @@
#include "entropymv.h"
#if CONFIG_HIGH_PRECISION_MV
-const MV_CONTEXT_HP vp8_mv_update_probs_hp[2] =
-{
- {{
- 237,
- 246,
- 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 250, 250, 252, 254, 254, 254
- }},
- {{
- 231,
- 243,
- 245, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 251, 251, 254, 254, 254, 254
- }}
+const MV_CONTEXT_HP vp8_mv_update_probs_hp[2] = {
+ {{
+ 237,
+ 246,
+ 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 250, 250, 252, 254, 254, 254
+ }
+ },
+ {{
+ 231,
+ 243,
+ 245, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 251, 251, 254, 254, 254, 254
+ }
+ }
};
-const MV_CONTEXT_HP vp8_default_mv_context_hp[2] =
-{
- {{
- /* row */
- 162, /* is short */
- 128, /* sign */
- 220, 204, 180, 192, 192, 119, 192, 192, 180, 140, 192, 192, 224, 224, 224, /* short tree */
- 128, 129, 132, 75, 145, 178, 206, 239, 254, 254, 254 /* long bits */
- }},
- {{
- /* same for column */
- 164, /* is short */
- 128,
- 220, 204, 180, 192, 192, 119, 192, 192, 180, 140, 192, 192, 224, 224, 224, /* short tree */
- 128, 130, 130, 74, 148, 180, 203, 236, 254, 254, 254 /* long bits */
- }}
+const MV_CONTEXT_HP vp8_default_mv_context_hp[2] = {
+ {{
+ /* row */
+ 162, /* is short */
+ 128, /* sign */
+ 220, 204, 180, 192, 192, 119, 192, 192, 180, 140, 192, 192, 224, 224, 224, /* short tree */
+ 128, 129, 132, 75, 145, 178, 206, 239, 254, 254, 254 /* long bits */
+ }
+ },
+ {{
+ /* same for column */
+ 164, /* is short */
+ 128,
+ 220, 204, 180, 192, 192, 119, 192, 192, 180, 140, 192, 192, 224, 224, 224, /* short tree */
+ 128, 130, 130, 74, 148, 180, 203, 236, 254, 254, 254 /* long bits */
+ }
+ }
};
#endif /* CONFIG_HIGH_PRECISION_MV */
-const MV_CONTEXT vp8_mv_update_probs[2] =
-{
- {{
- 237,
- 246,
- 253, 253, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 250, 250, 252, 254, 254
- }},
- {{
- 231,
- 243,
- 245, 253, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 251, 251, 254, 254, 254
- }}
+const MV_CONTEXT vp8_mv_update_probs[2] = {
+ {{
+ 237,
+ 246,
+ 253, 253, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 250, 250, 252, 254, 254
+ }
+ },
+ {{
+ 231,
+ 243,
+ 245, 253, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 251, 251, 254, 254, 254
+ }
+ }
};
-const MV_CONTEXT vp8_default_mv_context[2] =
-{
- {{
- /* row */
- 162, /* is short */
- 128, /* sign */
- 225, 146, 172, 147, 214, 39, 156, /* short tree */
- 128, 129, 132, 75, 145, 178, 206, 239, 254, 254 /* long bits */
- }},
- {{
- /* same for column */
- 164, /* is short */
- 128,
- 204, 170, 119, 235, 140, 230, 228,
- 128, 130, 130, 74, 148, 180, 203, 236, 254, 254 /* long bits */
- }}
+const MV_CONTEXT vp8_default_mv_context[2] = {
+ {{
+ /* row */
+ 162, /* is short */
+ 128, /* sign */
+ 225, 146, 172, 147, 214, 39, 156, /* short tree */
+ 128, 129, 132, 75, 145, 178, 206, 239, 254, 254 /* long bits */
+ }
+ },
+ {{
+ /* same for column */
+ 164, /* is short */
+ 128,
+ 204, 170, 119, 235, 140, 230, 228,
+ 128, 130, 130, 74, 148, 180, 203, 236, 254, 254 /* long bits */
+ }
+ }
};
#if CONFIG_HIGH_PRECISION_MV
-const vp8_tree_index vp8_small_mvtree_hp [30] =
-{
- 2, 16,
- 4, 10,
- 6, 8,
- -0, -1,
- -2, -3,
- 12, 14,
- -4, -5,
- -6, -7,
- 18, 24,
- 20, 22,
- -8, -9,
- -10, -11,
- 26, 28,
- -12, -13,
- -14, -15
+const vp8_tree_index vp8_small_mvtree_hp [30] = {
+ 2, 16,
+ 4, 10,
+ 6, 8,
+ -0, -1,
+ -2, -3,
+ 12, 14,
+ -4, -5,
+ -6, -7,
+ 18, 24,
+ 20, 22,
+ -8, -9,
+ -10, -11,
+ 26, 28,
+ -12, -13,
+ -14, -15
};
struct vp8_token_struct vp8_small_mvencodings_hp [16];
#endif /* CONFIG_HIGH_PRECISION_MV */
-const vp8_tree_index vp8_small_mvtree [14] =
-{
- 2, 8,
- 4, 6,
- -0, -1,
- -2, -3,
- 10, 12,
- -4, -5,
- -6, -7
+const vp8_tree_index vp8_small_mvtree [14] = {
+ 2, 8,
+ 4, 6,
+ -0, -1,
+ -2, -3,
+ 10, 12,
+ -4, -5,
+ -6, -7
};
struct vp8_token_struct vp8_small_mvencodings [8];
-__inline static void calc_prob(vp8_prob *p, const unsigned int ct[2], int pbits)
-{
- const unsigned int tot = ct[0] + ct[1];
- if (tot)
- {
- const vp8_prob x = ((ct[0] * 255) / tot) & -(1<<(8-pbits));
- *p = x ? x : 1;
- }
+__inline static void calc_prob(vp8_prob *p, const unsigned int ct[2], int pbits) {
+ const unsigned int tot = ct[0] + ct[1];
+ if (tot) {
+ const vp8_prob x = ((ct[0] * 255) / tot) & -(1 << (8 - pbits));
+ *p = x ? x : 1;
+ }
}
static void compute_component_probs(
- const unsigned int events [MVvals],
- vp8_prob Pnew [MVPcount],
- unsigned int is_short_ct[2],
- unsigned int sign_ct[2],
- unsigned int bit_ct [mvlong_width] [2],
- unsigned int short_ct [mvnum_short],
- unsigned int short_bct [mvnum_short-1] [2]
-)
-{
- is_short_ct[0] = is_short_ct[1] = 0;
- sign_ct[0] = sign_ct[1] = 0;
- vpx_memset(bit_ct, 0, sizeof(unsigned int)*mvlong_width*2);
- vpx_memset(short_ct, 0, sizeof(unsigned int)*mvnum_short);
- vpx_memset(short_bct, 0, sizeof(unsigned int)*(mvnum_short-1)*2);
-
- {
- const int c = events [mv_max];
- is_short_ct [0] += c; // Short vector
- short_ct [0] += c; // Magnitude distribution
- }
- {
- int j = 1;
- do
- {
- const int c1 = events [mv_max + j]; //positive
- const int c2 = events [mv_max - j]; //negative
- const int c = c1 + c2;
- int a = j;
-
- sign_ct [0] += c1;
- sign_ct [1] += c2;
-
- if (a < mvnum_short)
- {
- is_short_ct [0] += c; // Short vector
- short_ct [a] += c; // Magnitude distribution
- }
- else
- {
- int k = mvlong_width - 1;
- is_short_ct [1] += c; // Long vector
-
- do
- bit_ct [k] [(a >> k) & 1] += c;
-
- while (--k >= 0);
- }
- }
- while (++j <= mv_max);
- }
- calc_prob(Pnew + mvpis_short, is_short_ct, 8);
-
- calc_prob(Pnew + MVPsign, sign_ct, 8);
-
- {
- vp8_prob p [mvnum_short - 1]; /* actually only need branch ct */
- int j = 0;
-
- vp8_tree_probs_from_distribution(
- mvnum_short, vp8_small_mvencodings, vp8_small_mvtree,
- p, short_bct, short_ct,
- 256, 1
- );
+ const unsigned int events [MVvals],
+ vp8_prob Pnew [MVPcount],
+ unsigned int is_short_ct[2],
+ unsigned int sign_ct[2],
+ unsigned int bit_ct [mvlong_width] [2],
+ unsigned int short_ct [mvnum_short],
+ unsigned int short_bct [mvnum_short - 1] [2]
+) {
+ is_short_ct[0] = is_short_ct[1] = 0;
+ sign_ct[0] = sign_ct[1] = 0;
+ vpx_memset(bit_ct, 0, sizeof(unsigned int)*mvlong_width * 2);
+ vpx_memset(short_ct, 0, sizeof(unsigned int)*mvnum_short);
+ vpx_memset(short_bct, 0, sizeof(unsigned int) * (mvnum_short - 1) * 2);
+
+ {
+ const int c = events [mv_max];
+ is_short_ct [0] += c; // Short vector
+ short_ct [0] += c; // Magnitude distribution
+ }
+ {
+ int j = 1;
+ do {
+ const int c1 = events [mv_max + j]; // positive
+ const int c2 = events [mv_max - j]; // negative
+ const int c = c1 + c2;
+ int a = j;
+
+ sign_ct [0] += c1;
+ sign_ct [1] += c2;
+
+ if (a < mvnum_short) {
+ is_short_ct [0] += c; // Short vector
+ short_ct [a] += c; // Magnitude distribution
+ } else {
+ int k = mvlong_width - 1;
+ is_short_ct [1] += c; // Long vector
do
- calc_prob(Pnew + MVPshort + j, short_bct[j], 8);
- while (++j < mvnum_short - 1);
- }
-
- {
- int j = 0;
- do
- calc_prob(Pnew + MVPbits + j, bit_ct[j], 8);
- while (++j < mvlong_width);
- }
+ bit_ct [k] [(a >> k) & 1] += c;
+
+ while (--k >= 0);
+ }
+ } while (++j <= mv_max);
+ }
+ calc_prob(Pnew + mvpis_short, is_short_ct, 8);
+
+ calc_prob(Pnew + MVPsign, sign_ct, 8);
+
+ {
+ vp8_prob p [mvnum_short - 1]; /* actually only need branch ct */
+ int j = 0;
+
+ vp8_tree_probs_from_distribution(
+ mvnum_short, vp8_small_mvencodings, vp8_small_mvtree,
+ p, short_bct, short_ct,
+ 256, 1
+ );
+
+ do
+ calc_prob(Pnew + MVPshort + j, short_bct[j], 8);
+ while (++j < mvnum_short - 1);
+ }
+
+ {
+ int j = 0;
+ do
+ calc_prob(Pnew + MVPbits + j, bit_ct[j], 8);
+ while (++j < mvlong_width);
+ }
}
#if CONFIG_HIGH_PRECISION_MV
static void compute_component_probs_hp(
- const unsigned int events [MVvals_hp],
- vp8_prob Pnew [MVPcount_hp],
- unsigned int is_short_ct[2],
- unsigned int sign_ct[2],
- unsigned int bit_ct [mvlong_width_hp] [2],
- unsigned int short_ct [mvnum_short_hp],
- unsigned int short_bct [mvnum_short_hp-1] [2]
-)
-{
- is_short_ct[0] = is_short_ct[1] = 0;
- sign_ct[0] = sign_ct[1] = 0;
- vpx_memset(bit_ct, 0, sizeof(unsigned int)*mvlong_width_hp*2);
- vpx_memset(short_ct, 0, sizeof(unsigned int)*mvnum_short_hp);
- vpx_memset(short_bct, 0, sizeof(unsigned int)*(mvnum_short_hp-1)*2);
-
- {
- const int c = events [mv_max_hp];
- is_short_ct [0] += c; // Short vector
- short_ct [0] += c; // Magnitude distribution
- }
- {
- int j = 1;
- do
- {
- const int c1 = events [mv_max_hp + j]; //positive
- const int c2 = events [mv_max_hp - j]; //negative
- const int c = c1 + c2;
- int a = j;
-
- sign_ct [0] += c1;
- sign_ct [1] += c2;
-
- if (a < mvnum_short_hp)
- {
- is_short_ct [0] += c; // Short vector
- short_ct [a] += c; // Magnitude distribution
- }
- else
- {
- int k = mvlong_width_hp - 1;
- is_short_ct [1] += c; // Long vector
-
- do
- bit_ct [k] [(a >> k) & 1] += c;
-
- while (--k >= 0);
- }
- }
- while (++j <= mv_max_hp);
- }
- calc_prob(Pnew + mvpis_short_hp, is_short_ct, 8);
-
- calc_prob(Pnew + MVPsign_hp, sign_ct, 8);
-
- {
- vp8_prob p [mvnum_short_hp - 1]; /* actually only need branch ct */
- int j = 0;
+ const unsigned int events [MVvals_hp],
+ vp8_prob Pnew [MVPcount_hp],
+ unsigned int is_short_ct[2],
+ unsigned int sign_ct[2],
+ unsigned int bit_ct [mvlong_width_hp] [2],
+ unsigned int short_ct [mvnum_short_hp],
+ unsigned int short_bct [mvnum_short_hp - 1] [2]
+) {
+ is_short_ct[0] = is_short_ct[1] = 0;
+ sign_ct[0] = sign_ct[1] = 0;
+ vpx_memset(bit_ct, 0, sizeof(unsigned int)*mvlong_width_hp * 2);
+ vpx_memset(short_ct, 0, sizeof(unsigned int)*mvnum_short_hp);
+ vpx_memset(short_bct, 0, sizeof(unsigned int) * (mvnum_short_hp - 1) * 2);
+
+ {
+ const int c = events [mv_max_hp];
+ is_short_ct [0] += c; // Short vector
+ short_ct [0] += c; // Magnitude distribution
+ }
+ {
+ int j = 1;
+ do {
+ const int c1 = events [mv_max_hp + j]; // positive
+ const int c2 = events [mv_max_hp - j]; // negative
+ const int c = c1 + c2;
+ int a = j;
+
+ sign_ct [0] += c1;
+ sign_ct [1] += c2;
+
+ if (a < mvnum_short_hp) {
+ is_short_ct [0] += c; // Short vector
+ short_ct [a] += c; // Magnitude distribution
+ } else {
+ int k = mvlong_width_hp - 1;
+ is_short_ct [1] += c; // Long vector
- vp8_tree_probs_from_distribution(
- mvnum_short_hp, vp8_small_mvencodings_hp, vp8_small_mvtree_hp,
- p, short_bct, short_ct,
- 256, 1
- );
-
- do
- calc_prob(Pnew + MVPshort_hp + j, short_bct[j], 8);
- while (++j < mvnum_short_hp - 1);
- }
-
- {
- int j = 0;
do
- calc_prob(Pnew + MVPbits_hp + j, bit_ct[j], 8);
- while (++j < mvlong_width_hp);
- }
+ bit_ct [k] [(a >> k) & 1] += c;
+
+ while (--k >= 0);
+ }
+ } while (++j <= mv_max_hp);
+ }
+ calc_prob(Pnew + mvpis_short_hp, is_short_ct, 8);
+
+ calc_prob(Pnew + MVPsign_hp, sign_ct, 8);
+
+ {
+ vp8_prob p [mvnum_short_hp - 1]; /* actually only need branch ct */
+ int j = 0;
+
+ vp8_tree_probs_from_distribution(
+ mvnum_short_hp, vp8_small_mvencodings_hp, vp8_small_mvtree_hp,
+ p, short_bct, short_ct,
+ 256, 1
+ );
+
+ do
+ calc_prob(Pnew + MVPshort_hp + j, short_bct[j], 8);
+ while (++j < mvnum_short_hp - 1);
+ }
+
+ {
+ int j = 0;
+ do
+ calc_prob(Pnew + MVPbits_hp + j, bit_ct[j], 8);
+ while (++j < mvlong_width_hp);
+ }
}
#endif /* CONFIG_HIGH_PRECISION_MV */
-void vp8_entropy_mv_init()
-{
- vp8_tokens_from_tree(vp8_small_mvencodings, vp8_small_mvtree);
+void vp8_entropy_mv_init() {
+ vp8_tokens_from_tree(vp8_small_mvencodings, vp8_small_mvtree);
#if CONFIG_HIGH_PRECISION_MV
- vp8_tokens_from_tree(vp8_small_mvencodings_hp, vp8_small_mvtree_hp);
+ vp8_tokens_from_tree(vp8_small_mvencodings_hp, vp8_small_mvtree_hp);
#endif
}
#if CONFIG_ADAPTIVE_ENTROPY
-//#define MV_COUNT_TESTING
+// #define MV_COUNT_TESTING
#define MV_COUNT_SAT 16
#define MV_MAX_UPDATE_FACTOR 128
-void vp8_adapt_mv_probs(VP8_COMMON *cm)
-{
- int i, t, count, factor;
+void vp8_adapt_mv_probs(VP8_COMMON *cm) {
+ int i, t, count, factor;
#ifdef MV_COUNT_TESTING
- printf("static const unsigned int\nMVcount[2][MVvals]={\n");
- for (i = 0; i < 2; ++i)
- {
- printf(" { ");
- for (t = 0; t < MVvals; t++)
- {
- printf("%d, ", cm->fc.MVcount[i][t]);
- if (t%16 == 15 && t!=MVvals-1) printf("\n ");
- }
- printf("},\n");
+ printf("static const unsigned int\nMVcount[2][MVvals]={\n");
+ for (i = 0; i < 2; ++i) {
+ printf(" { ");
+ for (t = 0; t < MVvals; t++) {
+ printf("%d, ", cm->fc.MVcount[i][t]);
+ if (t % 16 == 15 && t != MVvals - 1) printf("\n ");
}
- printf("};\n");
+ printf("},\n");
+ }
+ printf("};\n");
#if CONFIG_HIGH_PRECISION_MV
- printf("static const unsigned int\nMVcount_hp[2][MVvals_hp]={\n");
- for (i = 0; i < 2; ++i)
- {
- printf(" { ");
- for (t = 0; t < MVvals_hp; t++)
- {
- printf("%d, ", cm->fc.MVcount_hp[i][t]);
- if (t%16 == 15 && t!=MVvals_hp-1) printf("\n ");
- }
- printf("},\n");
+ printf("static const unsigned int\nMVcount_hp[2][MVvals_hp]={\n");
+ for (i = 0; i < 2; ++i) {
+ printf(" { ");
+ for (t = 0; t < MVvals_hp; t++) {
+ printf("%d, ", cm->fc.MVcount_hp[i][t]);
+ if (t % 16 == 15 && t != MVvals_hp - 1) printf("\n ");
}
- printf("};\n");
+ printf("},\n");
+ }
+ printf("};\n");
#endif
#endif /* MV_COUNT_TESTING */
- for (i = 0; i < 2; ++i)
- {
- int prob;
- unsigned int is_short_ct[2];
- unsigned int sign_ct[2];
- unsigned int bit_ct [mvlong_width] [2];
- unsigned int short_ct [mvnum_short];
- unsigned int short_bct [mvnum_short-1] [2];
- vp8_prob Pnew [MVPcount];
- compute_component_probs(cm->fc.MVcount[i], Pnew,
- is_short_ct, sign_ct,
- bit_ct, short_ct, short_bct);
- count = is_short_ct[0] + is_short_ct[1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc[i].prob[mvpis_short] * (256-factor) +
- (int)Pnew[mvpis_short] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc[i].prob[mvpis_short] = 1;
- else if (prob > 255) cm->fc.mvc[i].prob[mvpis_short] = 255;
- else cm->fc.mvc[i].prob[mvpis_short] = prob;
-
- count = sign_ct[0] + sign_ct[1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc[i].prob[MVPsign] * (256-factor) +
- (int)Pnew[MVPsign] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc[i].prob[MVPsign] = 1;
- else if (prob > 255) cm->fc.mvc[i].prob[MVPsign] = 255;
- else cm->fc.mvc[i].prob[MVPsign] = prob;
-
- for (t = 0; t < mvnum_short - 1; ++t)
- {
- count = short_bct[t][0] + short_bct[t][1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc[i].prob[MVPshort+t] * (256-factor) +
- (int)Pnew[MVPshort+t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc[i].prob[MVPshort+t] = 1;
- else if (prob > 255) cm->fc.mvc[i].prob[MVPshort+t] = 255;
- else cm->fc.mvc[i].prob[MVPshort+t] = prob;
- }
- for (t = 0; t < mvlong_width; ++t)
- {
- count = bit_ct[t][0] + bit_ct[t][1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc[i].prob[MVPbits+t] * (256-factor) +
- (int)Pnew[MVPbits+t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc[i].prob[MVPbits+t] = 1;
- else if (prob > 255) cm->fc.mvc[i].prob[MVPbits+t] = 255;
- else cm->fc.mvc[i].prob[MVPbits+t] = prob;
- }
+ for (i = 0; i < 2; ++i) {
+ int prob;
+ unsigned int is_short_ct[2];
+ unsigned int sign_ct[2];
+ unsigned int bit_ct [mvlong_width] [2];
+ unsigned int short_ct [mvnum_short];
+ unsigned int short_bct [mvnum_short - 1] [2];
+ vp8_prob Pnew [MVPcount];
+ compute_component_probs(cm->fc.MVcount[i], Pnew,
+ is_short_ct, sign_ct,
+ bit_ct, short_ct, short_bct);
+ count = is_short_ct[0] + is_short_ct[1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc[i].prob[mvpis_short] * (256 - factor) +
+ (int)Pnew[mvpis_short] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc[i].prob[mvpis_short] = 1;
+ else if (prob > 255) cm->fc.mvc[i].prob[mvpis_short] = 255;
+ else cm->fc.mvc[i].prob[mvpis_short] = prob;
+
+ count = sign_ct[0] + sign_ct[1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc[i].prob[MVPsign] * (256 - factor) +
+ (int)Pnew[MVPsign] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc[i].prob[MVPsign] = 1;
+ else if (prob > 255) cm->fc.mvc[i].prob[MVPsign] = 255;
+ else cm->fc.mvc[i].prob[MVPsign] = prob;
+
+ for (t = 0; t < mvnum_short - 1; ++t) {
+ count = short_bct[t][0] + short_bct[t][1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc[i].prob[MVPshort + t] * (256 - factor) +
+ (int)Pnew[MVPshort + t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc[i].prob[MVPshort + t] = 1;
+ else if (prob > 255) cm->fc.mvc[i].prob[MVPshort + t] = 255;
+ else cm->fc.mvc[i].prob[MVPshort + t] = prob;
+ }
+ for (t = 0; t < mvlong_width; ++t) {
+ count = bit_ct[t][0] + bit_ct[t][1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc[i].prob[MVPbits + t] * (256 - factor) +
+ (int)Pnew[MVPbits + t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc[i].prob[MVPbits + t] = 1;
+ else if (prob > 255) cm->fc.mvc[i].prob[MVPbits + t] = 255;
+ else cm->fc.mvc[i].prob[MVPbits + t] = prob;
}
+ }
#if CONFIG_HIGH_PRECISION_MV
- for (i = 0; i < 2; ++i)
- {
- int prob;
- unsigned int is_short_ct[2];
- unsigned int sign_ct[2];
- unsigned int bit_ct [mvlong_width_hp] [2];
- unsigned int short_ct [mvnum_short_hp];
- unsigned int short_bct [mvnum_short_hp-1] [2];
- vp8_prob Pnew [MVPcount_hp];
- compute_component_probs_hp(cm->fc.MVcount_hp[i], Pnew,
- is_short_ct, sign_ct,
- bit_ct, short_ct, short_bct);
- count = is_short_ct[0] + is_short_ct[1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc_hp[i].prob[mvpis_short_hp] * (256-factor) +
- (int)Pnew[mvpis_short_hp] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc_hp[i].prob[mvpis_short_hp] = 1;
- else if (prob > 255) cm->fc.mvc_hp[i].prob[mvpis_short_hp] = 255;
- else cm->fc.mvc_hp[i].prob[mvpis_short_hp] = prob;
-
- count = sign_ct[0] + sign_ct[1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPsign_hp] * (256-factor) +
- (int)Pnew[MVPsign_hp] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPsign_hp] = 1;
- else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPsign_hp] = 255;
- else cm->fc.mvc_hp[i].prob[MVPsign_hp] = prob;
-
- for (t = 0; t < mvnum_short_hp - 1; ++t)
- {
- count = short_bct[t][0] + short_bct[t][1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPshort_hp+t] * (256-factor) +
- (int)Pnew[MVPshort_hp+t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPshort_hp+t] = 1;
- else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPshort_hp+t] = 255;
- else cm->fc.mvc_hp[i].prob[MVPshort_hp+t] = prob;
- }
- for (t = 0; t < mvlong_width_hp; ++t)
- {
- count = bit_ct[t][0] + bit_ct[t][1];
- count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
- factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
- prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPbits_hp+t] * (256-factor) +
- (int)Pnew[MVPbits_hp+t] * factor + 128) >> 8;
- if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPbits_hp+t] = 1;
- else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPbits_hp+t] = 255;
- else cm->fc.mvc_hp[i].prob[MVPbits_hp+t] = prob;
- }
+ for (i = 0; i < 2; ++i) {
+ int prob;
+ unsigned int is_short_ct[2];
+ unsigned int sign_ct[2];
+ unsigned int bit_ct [mvlong_width_hp] [2];
+ unsigned int short_ct [mvnum_short_hp];
+ unsigned int short_bct [mvnum_short_hp - 1] [2];
+ vp8_prob Pnew [MVPcount_hp];
+ compute_component_probs_hp(cm->fc.MVcount_hp[i], Pnew,
+ is_short_ct, sign_ct,
+ bit_ct, short_ct, short_bct);
+ count = is_short_ct[0] + is_short_ct[1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc_hp[i].prob[mvpis_short_hp] * (256 - factor) +
+ (int)Pnew[mvpis_short_hp] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc_hp[i].prob[mvpis_short_hp] = 1;
+ else if (prob > 255) cm->fc.mvc_hp[i].prob[mvpis_short_hp] = 255;
+ else cm->fc.mvc_hp[i].prob[mvpis_short_hp] = prob;
+
+ count = sign_ct[0] + sign_ct[1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPsign_hp] * (256 - factor) +
+ (int)Pnew[MVPsign_hp] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPsign_hp] = 1;
+ else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPsign_hp] = 255;
+ else cm->fc.mvc_hp[i].prob[MVPsign_hp] = prob;
+
+ for (t = 0; t < mvnum_short_hp - 1; ++t) {
+ count = short_bct[t][0] + short_bct[t][1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPshort_hp + t] * (256 - factor) +
+ (int)Pnew[MVPshort_hp + t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPshort_hp + t] = 1;
+ else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPshort_hp + t] = 255;
+ else cm->fc.mvc_hp[i].prob[MVPshort_hp + t] = prob;
+ }
+ for (t = 0; t < mvlong_width_hp; ++t) {
+ count = bit_ct[t][0] + bit_ct[t][1];
+ count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count;
+ factor = (MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mvc_hp[i].prob[MVPbits_hp + t] * (256 - factor) +
+ (int)Pnew[MVPbits_hp + t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mvc_hp[i].prob[MVPbits_hp + t] = 1;
+ else if (prob > 255) cm->fc.mvc_hp[i].prob[MVPbits_hp + t] = 255;
+ else cm->fc.mvc_hp[i].prob[MVPbits_hp + t] = prob;
}
+ }
#endif
}
#endif /* CONFIG_ADAPTIVE_ENTROPY */
diff --git a/vp8/common/entropymv.h b/vp8/common/entropymv.h
index 09c2587d2..96ea7ffae 100644
--- a/vp8/common/entropymv.h
+++ b/vp8/common/entropymv.h
@@ -15,59 +15,55 @@
#include "treecoder.h"
#include "vpx_config.h"
-enum
-{
- mv_max = 1023, /* max absolute value of a MV component */
- MVvals = (2 * mv_max) + 1, /* # possible values "" */
- mvlong_width = 10, /* Large MVs have 9 bit magnitudes */
- mvnum_short = 8, /* magnitudes 0 through 7 */
- mvnum_short_bits = 3, /* number of bits for short mvs */
+enum {
+ mv_max = 1023, /* max absolute value of a MV component */
+ MVvals = (2 * mv_max) + 1, /* # possible values "" */
+ mvlong_width = 10, /* Large MVs have 9 bit magnitudes */
+ mvnum_short = 8, /* magnitudes 0 through 7 */
+ mvnum_short_bits = 3, /* number of bits for short mvs */
- mvfp_max = 255, /* max absolute value of a full pixel MV component */
- MVfpvals = (2 * mvfp_max) + 1, /* # possible full pixel MV values */
+ mvfp_max = 255, /* max absolute value of a full pixel MV component */
+ MVfpvals = (2 * mvfp_max) + 1, /* # possible full pixel MV values */
- /* probability offsets for coding each MV component */
+ /* probability offsets for coding each MV component */
- mvpis_short = 0, /* short (<= 7) vs long (>= 8) */
- MVPsign, /* sign for non-zero */
- MVPshort, /* 8 short values = 7-position tree */
+ mvpis_short = 0, /* short (<= 7) vs long (>= 8) */
+ MVPsign, /* sign for non-zero */
+ MVPshort, /* 8 short values = 7-position tree */
- MVPbits = MVPshort + mvnum_short - 1, /* mvlong_width long value bits */
- MVPcount = MVPbits + mvlong_width /* (with independent probabilities) */
+ MVPbits = MVPshort + mvnum_short - 1, /* mvlong_width long value bits */
+ MVPcount = MVPbits + mvlong_width /* (with independent probabilities) */
};
-typedef struct mv_context
-{
- vp8_prob prob[MVPcount]; /* often come in row, col pairs */
+typedef struct mv_context {
+ vp8_prob prob[MVPcount]; /* often come in row, col pairs */
} MV_CONTEXT;
extern const MV_CONTEXT vp8_mv_update_probs[2], vp8_default_mv_context[2];
#if CONFIG_HIGH_PRECISION_MV
-enum
-{
- mv_max_hp = 2047, /* max absolute value of a MV component */
- MVvals_hp = (2 * mv_max_hp) + 1, /* # possible values "" */
- mvlong_width_hp = 11, /* Large MVs have 9 bit magnitudes */
- mvnum_short_hp = 16, /* magnitudes 0 through 15 */
- mvnum_short_bits_hp = 4, /* number of bits for short mvs */
+enum {
+ mv_max_hp = 2047, /* max absolute value of a MV component */
+ MVvals_hp = (2 * mv_max_hp) + 1, /* # possible values "" */
+ mvlong_width_hp = 11, /* Large MVs have 9 bit magnitudes */
+ mvnum_short_hp = 16, /* magnitudes 0 through 15 */
+ mvnum_short_bits_hp = 4, /* number of bits for short mvs */
- mvfp_max_hp = 255, /* max absolute value of a full pixel MV component */
- MVfpvals_hp = (2 * mvfp_max_hp) + 1, /* # possible full pixel MV values */
+ mvfp_max_hp = 255, /* max absolute value of a full pixel MV component */
+ MVfpvals_hp = (2 * mvfp_max_hp) + 1, /* # possible full pixel MV values */
- /* probability offsets for coding each MV component */
+ /* probability offsets for coding each MV component */
- mvpis_short_hp = 0, /* short (<= 7) vs long (>= 8) */
- MVPsign_hp, /* sign for non-zero */
- MVPshort_hp, /* 8 short values = 7-position tree */
+ mvpis_short_hp = 0, /* short (<= 7) vs long (>= 8) */
+ MVPsign_hp, /* sign for non-zero */
+ MVPshort_hp, /* 8 short values = 7-position tree */
- MVPbits_hp = MVPshort_hp + mvnum_short_hp - 1, /* mvlong_width long value bits */
- MVPcount_hp = MVPbits_hp + mvlong_width_hp /* (with independent probabilities) */
+ MVPbits_hp = MVPshort_hp + mvnum_short_hp - 1, /* mvlong_width long value bits */
+ MVPcount_hp = MVPbits_hp + mvlong_width_hp /* (with independent probabilities) */
};
-typedef struct mv_context_hp
-{
- vp8_prob prob[MVPcount_hp]; /* often come in row, col pairs */
+typedef struct mv_context_hp {
+ vp8_prob prob[MVPcount_hp]; /* often come in row, col pairs */
} MV_CONTEXT_HP;
extern const MV_CONTEXT_HP vp8_mv_update_probs_hp[2], vp8_default_mv_context_hp[2];
diff --git a/vp8/common/extend.c b/vp8/common/extend.c
index 9089e1629..6ea745605 100644
--- a/vp8/common/extend.c
+++ b/vp8/common/extend.c
@@ -15,171 +15,162 @@
static void copy_and_extend_plane
(
- unsigned char *s, /* source */
- int sp, /* source pitch */
- unsigned char *d, /* destination */
- int dp, /* destination pitch */
- int h, /* height */
- int w, /* width */
- int et, /* extend top border */
- int el, /* extend left border */
- int eb, /* extend bottom border */
- int er /* extend right border */
-)
-{
- int i;
- unsigned char *src_ptr1, *src_ptr2;
- unsigned char *dest_ptr1, *dest_ptr2;
- int linesize;
-
- /* copy the left and right most columns out */
- src_ptr1 = s;
- src_ptr2 = s + w - 1;
- dest_ptr1 = d - el;
- dest_ptr2 = d + w;
-
- for (i = 0; i < h; i++)
- {
- vpx_memset(dest_ptr1, src_ptr1[0], el);
- vpx_memcpy(dest_ptr1 + el, src_ptr1, w);
- vpx_memset(dest_ptr2, src_ptr2[0], er);
- src_ptr1 += sp;
- src_ptr2 += sp;
- dest_ptr1 += dp;
- dest_ptr2 += dp;
- }
-
- /* Now copy the top and bottom lines into each line of the respective
- * borders
- */
- src_ptr1 = d - el;
- src_ptr2 = d + dp * (h - 1) - el;
- dest_ptr1 = d + dp * (-et) - el;
- dest_ptr2 = d + dp * (h) - el;
- linesize = el + er + w;
-
- for (i = 0; i < et; i++)
- {
- vpx_memcpy(dest_ptr1, src_ptr1, linesize);
- dest_ptr1 += dp;
- }
-
- for (i = 0; i < eb; i++)
- {
- vpx_memcpy(dest_ptr2, src_ptr2, linesize);
- dest_ptr2 += dp;
- }
+ unsigned char *s, /* source */
+ int sp, /* source pitch */
+ unsigned char *d, /* destination */
+ int dp, /* destination pitch */
+ int h, /* height */
+ int w, /* width */
+ int et, /* extend top border */
+ int el, /* extend left border */
+ int eb, /* extend bottom border */
+ int er /* extend right border */
+) {
+ int i;
+ unsigned char *src_ptr1, *src_ptr2;
+ unsigned char *dest_ptr1, *dest_ptr2;
+ int linesize;
+
+ /* copy the left and right most columns out */
+ src_ptr1 = s;
+ src_ptr2 = s + w - 1;
+ dest_ptr1 = d - el;
+ dest_ptr2 = d + w;
+
+ for (i = 0; i < h; i++) {
+ vpx_memset(dest_ptr1, src_ptr1[0], el);
+ vpx_memcpy(dest_ptr1 + el, src_ptr1, w);
+ vpx_memset(dest_ptr2, src_ptr2[0], er);
+ src_ptr1 += sp;
+ src_ptr2 += sp;
+ dest_ptr1 += dp;
+ dest_ptr2 += dp;
+ }
+
+ /* Now copy the top and bottom lines into each line of the respective
+ * borders
+ */
+ src_ptr1 = d - el;
+ src_ptr2 = d + dp * (h - 1) - el;
+ dest_ptr1 = d + dp * (-et) - el;
+ dest_ptr2 = d + dp * (h) - el;
+ linesize = el + er + w;
+
+ for (i = 0; i < et; i++) {
+ vpx_memcpy(dest_ptr1, src_ptr1, linesize);
+ dest_ptr1 += dp;
+ }
+
+ for (i = 0; i < eb; i++) {
+ vpx_memcpy(dest_ptr2, src_ptr2, linesize);
+ dest_ptr2 += dp;
+ }
}
void vp8_copy_and_extend_frame(YV12_BUFFER_CONFIG *src,
- YV12_BUFFER_CONFIG *dst)
-{
- int et = dst->border;
- int el = dst->border;
- int eb = dst->border + dst->y_height - src->y_height;
- int er = dst->border + dst->y_width - src->y_width;
-
- copy_and_extend_plane(src->y_buffer, src->y_stride,
- dst->y_buffer, dst->y_stride,
- src->y_height, src->y_width,
- et, el, eb, er);
-
- et = dst->border >> 1;
- el = dst->border >> 1;
- eb = (dst->border >> 1) + dst->uv_height - src->uv_height;
- er = (dst->border >> 1) + dst->uv_width - src->uv_width;
-
- copy_and_extend_plane(src->u_buffer, src->uv_stride,
- dst->u_buffer, dst->uv_stride,
- src->uv_height, src->uv_width,
- et, el, eb, er);
-
- copy_and_extend_plane(src->v_buffer, src->uv_stride,
- dst->v_buffer, dst->uv_stride,
- src->uv_height, src->uv_width,
- et, el, eb, er);
+ YV12_BUFFER_CONFIG *dst) {
+ int et = dst->border;
+ int el = dst->border;
+ int eb = dst->border + dst->y_height - src->y_height;
+ int er = dst->border + dst->y_width - src->y_width;
+
+ copy_and_extend_plane(src->y_buffer, src->y_stride,
+ dst->y_buffer, dst->y_stride,
+ src->y_height, src->y_width,
+ et, el, eb, er);
+
+ et = dst->border >> 1;
+ el = dst->border >> 1;
+ eb = (dst->border >> 1) + dst->uv_height - src->uv_height;
+ er = (dst->border >> 1) + dst->uv_width - src->uv_width;
+
+ copy_and_extend_plane(src->u_buffer, src->uv_stride,
+ dst->u_buffer, dst->uv_stride,
+ src->uv_height, src->uv_width,
+ et, el, eb, er);
+
+ copy_and_extend_plane(src->v_buffer, src->uv_stride,
+ dst->v_buffer, dst->uv_stride,
+ src->uv_height, src->uv_width,
+ et, el, eb, er);
}
void vp8_copy_and_extend_frame_with_rect(YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
int srcy, int srcx,
- int srch, int srcw)
-{
- int et = dst->border;
- int el = dst->border;
- int eb = dst->border + dst->y_height - src->y_height;
- int er = dst->border + dst->y_width - src->y_width;
- int src_y_offset = srcy * src->y_stride + srcx;
- int dst_y_offset = srcy * dst->y_stride + srcx;
- int src_uv_offset = ((srcy * src->uv_stride) >> 1) + (srcx >> 1);
- int dst_uv_offset = ((srcy * dst->uv_stride) >> 1) + (srcx >> 1);
-
- // If the side is not touching the bounder then don't extend.
- if (srcy)
- et = 0;
- if (srcx)
- el = 0;
- if (srcy + srch != src->y_height)
- eb = 0;
- if (srcx + srcw != src->y_width)
- er = 0;
-
- copy_and_extend_plane(src->y_buffer + src_y_offset,
- src->y_stride,
- dst->y_buffer + dst_y_offset,
- dst->y_stride,
- srch, srcw,
- et, el, eb, er);
-
- et = (et + 1) >> 1;
- el = (el + 1) >> 1;
- eb = (eb + 1) >> 1;
- er = (er + 1) >> 1;
- srch = (srch + 1) >> 1;
- srcw = (srcw + 1) >> 1;
-
- copy_and_extend_plane(src->u_buffer + src_uv_offset,
- src->uv_stride,
- dst->u_buffer + dst_uv_offset,
- dst->uv_stride,
- srch, srcw,
- et, el, eb, er);
-
- copy_and_extend_plane(src->v_buffer + src_uv_offset,
- src->uv_stride,
- dst->v_buffer + dst_uv_offset,
- dst->uv_stride,
- srch, srcw,
- et, el, eb, er);
+ int srch, int srcw) {
+ int et = dst->border;
+ int el = dst->border;
+ int eb = dst->border + dst->y_height - src->y_height;
+ int er = dst->border + dst->y_width - src->y_width;
+ int src_y_offset = srcy * src->y_stride + srcx;
+ int dst_y_offset = srcy * dst->y_stride + srcx;
+ int src_uv_offset = ((srcy * src->uv_stride) >> 1) + (srcx >> 1);
+ int dst_uv_offset = ((srcy * dst->uv_stride) >> 1) + (srcx >> 1);
+
+ // If the side is not touching the bounder then don't extend.
+ if (srcy)
+ et = 0;
+ if (srcx)
+ el = 0;
+ if (srcy + srch != src->y_height)
+ eb = 0;
+ if (srcx + srcw != src->y_width)
+ er = 0;
+
+ copy_and_extend_plane(src->y_buffer + src_y_offset,
+ src->y_stride,
+ dst->y_buffer + dst_y_offset,
+ dst->y_stride,
+ srch, srcw,
+ et, el, eb, er);
+
+ et = (et + 1) >> 1;
+ el = (el + 1) >> 1;
+ eb = (eb + 1) >> 1;
+ er = (er + 1) >> 1;
+ srch = (srch + 1) >> 1;
+ srcw = (srcw + 1) >> 1;
+
+ copy_and_extend_plane(src->u_buffer + src_uv_offset,
+ src->uv_stride,
+ dst->u_buffer + dst_uv_offset,
+ dst->uv_stride,
+ srch, srcw,
+ et, el, eb, er);
+
+ copy_and_extend_plane(src->v_buffer + src_uv_offset,
+ src->uv_stride,
+ dst->v_buffer + dst_uv_offset,
+ dst->uv_stride,
+ srch, srcw,
+ et, el, eb, er);
}
/* note the extension is only for the last row, for intra prediction purpose */
-void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr)
-{
- int i;
-
- YPtr += ybf->y_stride * 14;
- UPtr += ybf->uv_stride * 6;
- VPtr += ybf->uv_stride * 6;
-
- for (i = 0; i < 4; i++)
- {
- YPtr[i] = YPtr[-1];
- UPtr[i] = UPtr[-1];
- VPtr[i] = VPtr[-1];
- }
-
- YPtr += ybf->y_stride;
- UPtr += ybf->uv_stride;
- VPtr += ybf->uv_stride;
-
- for (i = 0; i < 4; i++)
- {
- YPtr[i] = YPtr[-1];
- UPtr[i] = UPtr[-1];
- VPtr[i] = VPtr[-1];
- }
+void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr) {
+ int i;
+
+ YPtr += ybf->y_stride * 14;
+ UPtr += ybf->uv_stride * 6;
+ VPtr += ybf->uv_stride * 6;
+
+ for (i = 0; i < 4; i++) {
+ YPtr[i] = YPtr[-1];
+ UPtr[i] = UPtr[-1];
+ VPtr[i] = VPtr[-1];
+ }
+
+ YPtr += ybf->y_stride;
+ UPtr += ybf->uv_stride;
+ VPtr += ybf->uv_stride;
+
+ for (i = 0; i < 4; i++) {
+ YPtr[i] = YPtr[-1];
+ UPtr[i] = UPtr[-1];
+ VPtr[i] = VPtr[-1];
+ }
}
diff --git a/vp8/common/filter.c b/vp8/common/filter.c
index 55e84e4c5..856bad5a6 100644
--- a/vp8/common/filter.c
+++ b/vp8/common/filter.c
@@ -13,34 +13,33 @@
#include "filter.h"
#include "vpx_ports/mem.h"
-DECLARE_ALIGNED(16, const short, vp8_bilinear_filters[SUBPEL_SHIFTS][2]) =
-{
+DECLARE_ALIGNED(16, const short, vp8_bilinear_filters[SUBPEL_SHIFTS][2]) = {
#if SUBPEL_SHIFTS==16
- { 128, 0 },
- { 120, 8 },
- { 112, 16 },
- { 104, 24 },
- { 96, 32 },
- { 88, 40 },
- { 80, 48 },
- { 72, 56 },
- { 64, 64 },
- { 56, 72 },
- { 48, 80 },
- { 40, 88 },
- { 32, 96 },
- { 24, 104 },
- { 16, 112 },
- { 8, 120 }
+ { 128, 0 },
+ { 120, 8 },
+ { 112, 16 },
+ { 104, 24 },
+ { 96, 32 },
+ { 88, 40 },
+ { 80, 48 },
+ { 72, 56 },
+ { 64, 64 },
+ { 56, 72 },
+ { 48, 80 },
+ { 40, 88 },
+ { 32, 96 },
+ { 24, 104 },
+ { 16, 112 },
+ { 8, 120 }
#else
- { 128, 0 },
- { 112, 16 },
- { 96, 32 },
- { 80, 48 },
- { 64, 64 },
- { 48, 80 },
- { 32, 96 },
- { 16, 112 }
+ { 128, 0 },
+ { 112, 16 },
+ { 96, 32 },
+ { 80, 48 },
+ { 64, 64 },
+ { 48, 80 },
+ { 32, 96 },
+ { 16, 112 }
#endif /* SUBPEL_SHIFTS==16 */
};
@@ -48,318 +47,309 @@ DECLARE_ALIGNED(16, const short, vp8_bilinear_filters[SUBPEL_SHIFTS][2]) =
#define FILTER_ALPHA 0
#define FILTER_ALPHA_SHARP 60
-DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_8[SUBPEL_SHIFTS][2*INTERP_EXTEND]) =
-{
+DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_8[SUBPEL_SHIFTS][2 * INTERP_EXTEND]) = {
#if SUBPEL_SHIFTS==16
#if FILTER_ALPHA == 0
- /* Lagrangian interpolation filter */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 1, -5, 126, 8, -3, 1, 0},
- {-1, 3, -10, 122, 18, -6, 2, 0},
- {-1, 4, -13, 118, 27, -9, 3, -1},
- {-1, 4, -16, 112, 37, -11, 4, -1},
- {-1, 5, -18, 105, 48, -14, 4, -1},
- {-1, 5, -19, 97, 58, -16, 5, -1},
- {-1, 6, -19, 88, 68, -18, 5, -1},
- {-1, 6, -19, 78, 78, -19, 6, -1},
- {-1, 5, -18, 68, 88, -19, 6, -1},
- {-1, 5, -16, 58, 97, -19, 5, -1},
- {-1, 4, -14, 48, 105, -18, 5, -1},
- {-1, 4, -11, 37, 112, -16, 4, -1},
- {-1, 3, -9, 27, 118, -13, 4, -1},
- { 0, 2, -6, 18, 122, -10, 3, -1},
- { 0, 1, -3, 8, 126, -5, 1, 0}
+ /* Lagrangian interpolation filter */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 1, -5, 126, 8, -3, 1, 0},
+ { -1, 3, -10, 122, 18, -6, 2, 0},
+ { -1, 4, -13, 118, 27, -9, 3, -1},
+ { -1, 4, -16, 112, 37, -11, 4, -1},
+ { -1, 5, -18, 105, 48, -14, 4, -1},
+ { -1, 5, -19, 97, 58, -16, 5, -1},
+ { -1, 6, -19, 88, 68, -18, 5, -1},
+ { -1, 6, -19, 78, 78, -19, 6, -1},
+ { -1, 5, -18, 68, 88, -19, 6, -1},
+ { -1, 5, -16, 58, 97, -19, 5, -1},
+ { -1, 4, -14, 48, 105, -18, 5, -1},
+ { -1, 4, -11, 37, 112, -16, 4, -1},
+ { -1, 3, -9, 27, 118, -13, 4, -1},
+ { 0, 2, -6, 18, 122, -10, 3, -1},
+ { 0, 1, -3, 8, 126, -5, 1, 0}
#elif FILTER_ALPHA == 50
- /* Generated using MATLAB:
- * alpha = 0.5;
- * b=intfilt(8,4,alpha);
- * bi=round(128*b);
- * ba=flipud(reshape([bi 0], 8, 8));
- * disp(num2str(ba, '%d,'))
- */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 1, -5, 126, 8, -3, 1, 0},
- { 0, 2, -10, 122, 18, -6, 2, 0},
- {-1, 3, -13, 118, 27, -9, 3, 0},
- {-1, 4, -16, 112, 37, -11, 3, 0},
- {-1, 5, -17, 104, 48, -14, 4, -1},
- {-1, 5, -18, 96, 58, -16, 5, -1},
- {-1, 5, -19, 88, 68, -17, 5, -1},
- {-1, 5, -18, 78, 78, -18, 5, -1},
- {-1, 5, -17, 68, 88, -19, 5, -1},
- {-1, 5, -16, 58, 96, -18, 5, -1},
- {-1, 4, -14, 48, 104, -17, 5, -1},
- { 0, 3, -11, 37, 112, -16, 4, -1},
- { 0, 3, -9, 27, 118, -13, 3, -1},
- { 0, 2, -6, 18, 122, -10, 2, 0},
- { 0, 1, -3, 8, 126, -5, 1, 0}
+ /* Generated using MATLAB:
+ * alpha = 0.5;
+ * b=intfilt(8,4,alpha);
+ * bi=round(128*b);
+ * ba=flipud(reshape([bi 0], 8, 8));
+ * disp(num2str(ba, '%d,'))
+ */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 1, -5, 126, 8, -3, 1, 0},
+ { 0, 2, -10, 122, 18, -6, 2, 0},
+ { -1, 3, -13, 118, 27, -9, 3, 0},
+ { -1, 4, -16, 112, 37, -11, 3, 0},
+ { -1, 5, -17, 104, 48, -14, 4, -1},
+ { -1, 5, -18, 96, 58, -16, 5, -1},
+ { -1, 5, -19, 88, 68, -17, 5, -1},
+ { -1, 5, -18, 78, 78, -18, 5, -1},
+ { -1, 5, -17, 68, 88, -19, 5, -1},
+ { -1, 5, -16, 58, 96, -18, 5, -1},
+ { -1, 4, -14, 48, 104, -17, 5, -1},
+ { 0, 3, -11, 37, 112, -16, 4, -1},
+ { 0, 3, -9, 27, 118, -13, 3, -1},
+ { 0, 2, -6, 18, 122, -10, 2, 0},
+ { 0, 1, -3, 8, 126, -5, 1, 0}
#elif FILTER_ALPHA == 45
- /* alpha = 0.45 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 1, -5, 126, 8, -3, 1, 0},
- { 0, 2, -9, 122, 17, -6, 2, 0},
- { 0, 3, -13, 117, 27, -8, 2, 0},
- {-1, 4, -15, 111, 37, -11, 3, 0},
- {-1, 4, -17, 104, 47, -13, 4, 0},
- {-1, 5, -18, 96, 58, -15, 4, -1},
- {-1, 5, -18, 87, 68, -17, 5, -1},
- {-1, 5, -18, 78, 78, -18, 5, -1},
- {-1, 5, -17, 68, 87, -18, 5, -1},
- {-1, 4, -15, 58, 96, -18, 5, -1},
- { 0, 4, -13, 47, 104, -17, 4, -1},
- { 0, 3, -11, 37, 111, -15, 4, -1},
- { 0, 2, -8, 27, 117, -13, 3, 0},
- { 0, 2, -6, 17, 122, -9, 2, 0},
- { 0, 1, -3, 8, 126, -5, 1, 0}
+ /* alpha = 0.45 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 1, -5, 126, 8, -3, 1, 0},
+ { 0, 2, -9, 122, 17, -6, 2, 0},
+ { 0, 3, -13, 117, 27, -8, 2, 0},
+ { -1, 4, -15, 111, 37, -11, 3, 0},
+ { -1, 4, -17, 104, 47, -13, 4, 0},
+ { -1, 5, -18, 96, 58, -15, 4, -1},
+ { -1, 5, -18, 87, 68, -17, 5, -1},
+ { -1, 5, -18, 78, 78, -18, 5, -1},
+ { -1, 5, -17, 68, 87, -18, 5, -1},
+ { -1, 4, -15, 58, 96, -18, 5, -1},
+ { 0, 4, -13, 47, 104, -17, 4, -1},
+ { 0, 3, -11, 37, 111, -15, 4, -1},
+ { 0, 2, -8, 27, 117, -13, 3, 0},
+ { 0, 2, -6, 17, 122, -9, 2, 0},
+ { 0, 1, -3, 8, 126, -5, 1, 0}
#endif /* FILTER_ALPHA */
#else /* SUBPEL_SHIFTS==16 */
#if FILTER_ALPHA == 0
- { 0, 0, 0, 128, 0, 0, 0, 0},
- {-1, 3, -10, 122, 18, -6, 2, 0},
- {-1, 4, -16, 112, 37, -11, 4, -1},
- {-1, 5, -19, 97, 58, -16, 5, -1},
- {-1, 6, -19, 78, 78, -19, 6, -1},
- {-1, 5, -16, 58, 97, -19, 5, -1},
- {-1, 4, -11, 37, 112, -16, 4, -1},
- { 0, 2, -6, 18, 122, -10, 3, -1},
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { -1, 3, -10, 122, 18, -6, 2, 0},
+ { -1, 4, -16, 112, 37, -11, 4, -1},
+ { -1, 5, -19, 97, 58, -16, 5, -1},
+ { -1, 6, -19, 78, 78, -19, 6, -1},
+ { -1, 5, -16, 58, 97, -19, 5, -1},
+ { -1, 4, -11, 37, 112, -16, 4, -1},
+ { 0, 2, -6, 18, 122, -10, 3, -1},
#elif FILTER_ALPHA == 50
- /* alpha = 0.50 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 2, -10, 122, 18, -6, 2, 0},
- {-1, 4, -16, 112, 37, -11, 3, 0},
- {-1, 5, -18, 96, 58, -16, 5, -1},
- {-1, 5, -18, 78, 78, -18, 5, -1},
- {-1, 5, -16, 58, 96, -18, 5, -1},
- { 0, 3, -11, 37, 112, -16, 4, -1},
- { 0, 2, -6, 18, 122, -10, 2, 0}
+ /* alpha = 0.50 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 2, -10, 122, 18, -6, 2, 0},
+ { -1, 4, -16, 112, 37, -11, 3, 0},
+ { -1, 5, -18, 96, 58, -16, 5, -1},
+ { -1, 5, -18, 78, 78, -18, 5, -1},
+ { -1, 5, -16, 58, 96, -18, 5, -1},
+ { 0, 3, -11, 37, 112, -16, 4, -1},
+ { 0, 2, -6, 18, 122, -10, 2, 0}
#elif FILTER_ALPHA == 45
- /* alpha = 0.45 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 2, -9, 122, 17, -6, 2, 0},
- {-1, 4, -15, 111, 37, -11, 3, 0},
- {-1, 5, -18, 96, 58, -15, 4, -1},
- {-1, 5, -18, 78, 78, -18, 5, -1},
- {-1, 4, -15, 58, 96, -18, 5, -1},
- { 0, 3, -11, 37, 111, -15, 4, -1},
- { 0, 2, -6, 17, 122, -9, 2, 0},
+ /* alpha = 0.45 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 2, -9, 122, 17, -6, 2, 0},
+ { -1, 4, -15, 111, 37, -11, 3, 0},
+ { -1, 5, -18, 96, 58, -15, 4, -1},
+ { -1, 5, -18, 78, 78, -18, 5, -1},
+ { -1, 4, -15, 58, 96, -18, 5, -1},
+ { 0, 3, -11, 37, 111, -15, 4, -1},
+ { 0, 2, -6, 17, 122, -9, 2, 0},
#endif /* FILTER_ALPHA */
#endif /* SUBPEL_SHIFTS==16 */
};
-DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_8s[SUBPEL_SHIFTS][2*INTERP_EXTEND]) =
-{
+DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_8s[SUBPEL_SHIFTS][2 * INTERP_EXTEND]) = {
#if SUBPEL_SHIFTS==16
#if FILTER_ALPHA_SHARP == 65
- /* alpha = 0.65 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 2, -6, 126, 8, -3, 1, 0},
- {-1, 3, -10, 123, 18, -6, 2, -1},
- {-1, 5, -14, 118, 27, -10, 4, -1},
- {-1, 5, -17, 112, 38, -13, 5, -1},
- {-2, 6, -19, 106, 48, -15, 5, -1},
- {-2, 7, -21, 98, 59, -17, 6, -2},
- {-2, 7, -21, 89, 69, -19, 7, -2},
- {-2, 7, -20, 79, 79, -20, 7, -2},
- {-2, 7, -19, 69, 89, -21, 7, -2},
- {-2, 6, -17, 59, 98, -21, 7, -2},
- {-1, 5, -15, 48, 106, -19, 6, -2},
- {-1, 5, -13, 38, 112, -17, 5, -1},
- {-1, 4, -10, 27, 118, -14, 5, -1},
- {-1, 2, -6, 18, 123, -10, 3, -1},
- { 0, 1, -3, 8, 126, -6, 2, 0}
+ /* alpha = 0.65 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 2, -6, 126, 8, -3, 1, 0},
+ { -1, 3, -10, 123, 18, -6, 2, -1},
+ { -1, 5, -14, 118, 27, -10, 4, -1},
+ { -1, 5, -17, 112, 38, -13, 5, -1},
+ { -2, 6, -19, 106, 48, -15, 5, -1},
+ { -2, 7, -21, 98, 59, -17, 6, -2},
+ { -2, 7, -21, 89, 69, -19, 7, -2},
+ { -2, 7, -20, 79, 79, -20, 7, -2},
+ { -2, 7, -19, 69, 89, -21, 7, -2},
+ { -2, 6, -17, 59, 98, -21, 7, -2},
+ { -1, 5, -15, 48, 106, -19, 6, -2},
+ { -1, 5, -13, 38, 112, -17, 5, -1},
+ { -1, 4, -10, 27, 118, -14, 5, -1},
+ { -1, 2, -6, 18, 123, -10, 3, -1},
+ { 0, 1, -3, 8, 126, -6, 2, 0}
#elif FILTER_ALPHA_SHARP == 60
- /* alpha = 0.60 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 2, -6, 126, 8, -3, 1, 0},
- {-1, 3, -10, 123, 18, -6, 2, -1},
- {-1, 4, -14, 118, 28, -9, 3, -1},
- {-1, 5, -17, 112, 38, -12, 4, -1},
- {-1, 6, -19, 105, 48, -15, 5, -1},
- {-1, 6, -20, 97, 58, -17, 6, -1},
- {-1, 6, -20, 88, 69, -19, 6, -1},
- {-1, 6, -20, 79, 79, -20, 6, -1},
- {-1, 6, -19, 69, 88, -20, 6, -1},
- {-1, 6, -17, 58, 97, -20, 6, -1},
- {-1, 5, -15, 48, 105, -19, 6, -1},
- {-1, 4, -12, 38, 112, -17, 5, -1},
- {-1, 3, -9, 28, 118, -14, 4, -1},
- {-1, 2, -6, 18, 123, -10, 3, -1},
- { 0, 1, -3, 8, 126, -6, 2, 0}
+ /* alpha = 0.60 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 2, -6, 126, 8, -3, 1, 0},
+ { -1, 3, -10, 123, 18, -6, 2, -1},
+ { -1, 4, -14, 118, 28, -9, 3, -1},
+ { -1, 5, -17, 112, 38, -12, 4, -1},
+ { -1, 6, -19, 105, 48, -15, 5, -1},
+ { -1, 6, -20, 97, 58, -17, 6, -1},
+ { -1, 6, -20, 88, 69, -19, 6, -1},
+ { -1, 6, -20, 79, 79, -20, 6, -1},
+ { -1, 6, -19, 69, 88, -20, 6, -1},
+ { -1, 6, -17, 58, 97, -20, 6, -1},
+ { -1, 5, -15, 48, 105, -19, 6, -1},
+ { -1, 4, -12, 38, 112, -17, 5, -1},
+ { -1, 3, -9, 28, 118, -14, 4, -1},
+ { -1, 2, -6, 18, 123, -10, 3, -1},
+ { 0, 1, -3, 8, 126, -6, 2, 0}
#elif FILTER_ALPHA_SHARP == 55
- /* alpha = 0.55 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- { 0, 1, -5, 126, 8, -3, 1, 0},
- {-1, 2, -10, 123, 18, -6, 2, 0},
- {-1, 4, -13, 118, 27, -9, 3, -1},
- {-1, 5, -16, 112, 37, -12, 4, -1},
- {-1, 5, -18, 105, 48, -14, 4, -1},
- {-1, 5, -19, 97, 58, -16, 5, -1},
- {-1, 6, -19, 88, 68, -18, 5, -1},
- {-1, 6, -19, 78, 78, -19, 6, -1},
- {-1, 5, -18, 68, 88, -19, 6, -1},
- {-1, 5, -16, 58, 97, -19, 5, -1},
- {-1, 4, -14, 48, 105, -18, 5, -1},
- {-1, 4, -12, 37, 112, -16, 5, -1},
- {-1, 3, -9, 27, 118, -13, 4, -1},
- { 0, 2, -6, 18, 123, -10, 2, -1},
- { 0, 1, -3, 8, 126, -5, 1, 0}
+ /* alpha = 0.55 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { 0, 1, -5, 126, 8, -3, 1, 0},
+ { -1, 2, -10, 123, 18, -6, 2, 0},
+ { -1, 4, -13, 118, 27, -9, 3, -1},
+ { -1, 5, -16, 112, 37, -12, 4, -1},
+ { -1, 5, -18, 105, 48, -14, 4, -1},
+ { -1, 5, -19, 97, 58, -16, 5, -1},
+ { -1, 6, -19, 88, 68, -18, 5, -1},
+ { -1, 6, -19, 78, 78, -19, 6, -1},
+ { -1, 5, -18, 68, 88, -19, 6, -1},
+ { -1, 5, -16, 58, 97, -19, 5, -1},
+ { -1, 4, -14, 48, 105, -18, 5, -1},
+ { -1, 4, -12, 37, 112, -16, 5, -1},
+ { -1, 3, -9, 27, 118, -13, 4, -1},
+ { 0, 2, -6, 18, 123, -10, 2, -1},
+ { 0, 1, -3, 8, 126, -5, 1, 0}
#endif /* FILTER_ALPHA_SHARP */
#else /* SUBPEL_SHIFTS==16 */
#if FILTER_ALPHA_SHARP == 65
- /* alpha = 0.65 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- {-1, 3, -10, 123, 18, -6, 2, -1},
- {-1, 5, -17, 112, 38, -13, 5, -1},
- {-2, 7, -21, 98, 59, -17, 6, -2},
- {-2, 7, -20, 79, 79, -20, 7, -2},
- {-2, 6, -17, 59, 98, -21, 7, -2},
- {-1, 5, -13, 38, 112, -17, 5, -1},
- {-1, 2, -6, 18, 123, -10, 3, -1}
+ /* alpha = 0.65 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { -1, 3, -10, 123, 18, -6, 2, -1},
+ { -1, 5, -17, 112, 38, -13, 5, -1},
+ { -2, 7, -21, 98, 59, -17, 6, -2},
+ { -2, 7, -20, 79, 79, -20, 7, -2},
+ { -2, 6, -17, 59, 98, -21, 7, -2},
+ { -1, 5, -13, 38, 112, -17, 5, -1},
+ { -1, 2, -6, 18, 123, -10, 3, -1}
#elif FILTER_ALPHA_SHARP == 60
- /* alpha = 0.60 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- {-1, 3, -10, 123, 18, -6, 2, -1},
- {-1, 5, -17, 112, 38, -12, 4, -1},
- {-1, 6, -20, 97, 58, -17, 6, -1},
- {-1, 6, -20, 79, 79, -20, 6, -1},
- {-1, 6, -17, 58, 97, -20, 6, -1},
- {-1, 4, -12, 38, 112, -17, 5, -1},
- {-1, 2, -6, 18, 123, -10, 3, -1}
+ /* alpha = 0.60 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { -1, 3, -10, 123, 18, -6, 2, -1},
+ { -1, 5, -17, 112, 38, -12, 4, -1},
+ { -1, 6, -20, 97, 58, -17, 6, -1},
+ { -1, 6, -20, 79, 79, -20, 6, -1},
+ { -1, 6, -17, 58, 97, -20, 6, -1},
+ { -1, 4, -12, 38, 112, -17, 5, -1},
+ { -1, 2, -6, 18, 123, -10, 3, -1}
#elif FILTER_ALPHA_SHARP == 55
- /* alpha = 0.55 */
- { 0, 0, 0, 128, 0, 0, 0, 0},
- {-1, 2, -10, 123, 18, -6, 2, 0},
- {-1, 5, -16, 112, 37, -12, 4, -1},
- {-1, 5, -19, 97, 58, -16, 5, -1},
- {-1, 6, -19, 78, 78, -19, 6, -1},
- {-1, 5, -16, 58, 97, -19, 5, -1},
- {-1, 4, -12, 37, 112, -16, 5, -1},
- { 0, 2, -6, 18, 123, -10, 2, -1}
+ /* alpha = 0.55 */
+ { 0, 0, 0, 128, 0, 0, 0, 0},
+ { -1, 2, -10, 123, 18, -6, 2, 0},
+ { -1, 5, -16, 112, 37, -12, 4, -1},
+ { -1, 5, -19, 97, 58, -16, 5, -1},
+ { -1, 6, -19, 78, 78, -19, 6, -1},
+ { -1, 5, -16, 58, 97, -19, 5, -1},
+ { -1, 4, -12, 37, 112, -16, 5, -1},
+ { 0, 2, -6, 18, 123, -10, 2, -1}
#endif /* FILTER_ALPHA_SHARP */
#endif /* SUBPEL_SHIFTS==16 */
};
#endif // CONFIG_ENHANCED_INTERP
-DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_6[SUBPEL_SHIFTS][6]) =
-{
+DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters_6[SUBPEL_SHIFTS][6]) = {
#if SUBPEL_SHIFTS==16
- {0, 0, 128, 0, 0, 0},
- {1, -5, 125, 8, -2, 1},
- {1, -8, 122, 17, -5, 1},
- {2, -11, 116, 27, -8, 2},
- {3, -14, 110, 37, -10, 2},
- {3, -15, 103, 47, -12, 2},
- {3, -16, 95, 57, -14, 3},
- {3, -16, 86, 67, -15, 3},
- {3, -16, 77, 77, -16, 3},
- {3, -15, 67, 86, -16, 3},
- {3, -14, 57, 95, -16, 3},
- {2, -12, 47, 103, -15, 3},
- {2, -10, 37, 110, -14, 3},
- {2, -8, 27, 116, -11, 2},
- {1, -5, 17, 122, -8, 1},
- {1, -2, 8, 125, -5, 1}
+ {0, 0, 128, 0, 0, 0},
+ {1, -5, 125, 8, -2, 1},
+ {1, -8, 122, 17, -5, 1},
+ {2, -11, 116, 27, -8, 2},
+ {3, -14, 110, 37, -10, 2},
+ {3, -15, 103, 47, -12, 2},
+ {3, -16, 95, 57, -14, 3},
+ {3, -16, 86, 67, -15, 3},
+ {3, -16, 77, 77, -16, 3},
+ {3, -15, 67, 86, -16, 3},
+ {3, -14, 57, 95, -16, 3},
+ {2, -12, 47, 103, -15, 3},
+ {2, -10, 37, 110, -14, 3},
+ {2, -8, 27, 116, -11, 2},
+ {1, -5, 17, 122, -8, 1},
+ {1, -2, 8, 125, -5, 1}
#else
- { 0, 0, 128, 0, 0, 0 }, /* note that 1/8 pel positions are just as per alpha -0.5 bicubic */
- { 0, -6, 123, 12, -1, 0 },
- { 2, -11, 108, 36, -8, 1 }, /* New 1/4 pel 6 tap filter */
- { 0, -9, 93, 50, -6, 0 },
- { 3, -16, 77, 77, -16, 3 }, /* New 1/2 pel 6 tap filter */
- { 0, -6, 50, 93, -9, 0 },
- { 1, -8, 36, 108, -11, 2 }, /* New 1/4 pel 6 tap filter */
- { 0, -1, 12, 123, -6, 0 },
+ { 0, 0, 128, 0, 0, 0 }, /* note that 1/8 pel positions are just as per alpha -0.5 bicubic */
+ { 0, -6, 123, 12, -1, 0 },
+ { 2, -11, 108, 36, -8, 1 }, /* New 1/4 pel 6 tap filter */
+ { 0, -9, 93, 50, -6, 0 },
+ { 3, -16, 77, 77, -16, 3 }, /* New 1/2 pel 6 tap filter */
+ { 0, -6, 50, 93, -9, 0 },
+ { 1, -8, 36, 108, -11, 2 }, /* New 1/4 pel 6 tap filter */
+ { 0, -1, 12, 123, -6, 0 },
#endif /* SUBPEL_SHIFTS==16 */
};
static void filter_block2d_first_pass_6
(
- unsigned char *src_ptr,
- int *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[0] * vp8_filter[2]) +
- ((int)src_ptr[pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[2*pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[3*pixel_step] * vp8_filter[5]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
-
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
-
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
-
- output_ptr[j] = Temp;
- src_ptr++;
- }
-
- /* Next row... */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_width;
+ unsigned char *src_ptr,
+ int *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[0] * vp8_filter[2]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[5]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
+
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
+
+ output_ptr[j] = Temp;
+ src_ptr++;
}
+
+ /* Next row... */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_width;
+ }
}
static void filter_block2d_second_pass_6
(
- int *src_ptr,
- unsigned char *output_ptr,
- int output_pitch,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- /* Apply filter */
- Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[0] * vp8_filter[2]) +
- ((int)src_ptr[pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[2*pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[3*pixel_step] * vp8_filter[5]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
-
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
-
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
-
- output_ptr[j] = (unsigned char)Temp;
- src_ptr++;
- }
-
- /* Start next row */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_pitch;
+ int *src_ptr,
+ unsigned char *output_ptr,
+ int output_pitch,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ /* Apply filter */
+ Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[0] * vp8_filter[2]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[5]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
+
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
+
+ output_ptr[j] = (unsigned char)Temp;
+ src_ptr++;
}
+
+ /* Start next row */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_pitch;
+ }
}
/*
@@ -372,89 +362,84 @@ static void filter_block2d_second_pass_6
*/
static void filter_block2d_second_pass_avg_6
(
- int *src_ptr,
- unsigned char *output_ptr,
- int output_pitch,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- /* Apply filter */
- Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[0] * vp8_filter[2]) +
- ((int)src_ptr[pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[2*pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[3*pixel_step] * vp8_filter[5]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
-
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
-
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
-
- output_ptr[j] = (unsigned char) ((output_ptr[j] + Temp + 1) >> 1);
- src_ptr++;
- }
-
- /* Start next row */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_pitch;
+ int *src_ptr,
+ unsigned char *output_ptr,
+ int output_pitch,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ /* Apply filter */
+ Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[0] * vp8_filter[2]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[5]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
+
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
+
+ output_ptr[j] = (unsigned char)((output_ptr[j] + Temp + 1) >> 1);
+ src_ptr++;
}
+
+ /* Start next row */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_pitch;
+ }
}
#define Interp_Extend 3
static void filter_block2d_6
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- int output_pitch,
- const short *HFilter,
- const short *VFilter
-)
-{
- int FData[(3+Interp_Extend*2)*4]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 4, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_6(FData + 4*(Interp_Extend-1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ int output_pitch,
+ const short *HFilter,
+ const short *VFilter
+) {
+ int FData[(3 + Interp_Extend * 2) * 4]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 4, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_6(FData + 4 * (Interp_Extend - 1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
}
void vp8_sixtap_predict_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- filter_block2d_6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ filter_block2d_6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
}
/*
@@ -466,180 +451,173 @@ void vp8_sixtap_predict_c
*/
static void filter_block2d_avg_6
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- int output_pitch,
- const short *HFilter,
- const short *VFilter
-)
-{
- int FData[(3+Interp_Extend*2)*4]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line),
- FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 4, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_6(FData + 4*(Interp_Extend-1), output_ptr,
- output_pitch, 4, 4, 4, 4, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ int output_pitch,
+ const short *HFilter,
+ const short *VFilter
+) {
+ int FData[(3 + Interp_Extend * 2) * 4]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line),
+ FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 4, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_6(FData + 4 * (Interp_Extend - 1), output_ptr,
+ output_pitch, 4, 4, 4, 4, VFilter);
}
void vp8_sixtap_predict_avg_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- filter_block2d_avg_6(src_ptr, dst_ptr, src_pixels_per_line,
- dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ filter_block2d_avg_6(src_ptr, dst_ptr, src_pixels_per_line,
+ dst_pitch, HFilter, VFilter);
}
void vp8_sixtap_predict8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
-
- /* then filter verticaly... */
- filter_block2d_second_pass_6(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_6(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_sixtap_predict_avg8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_6(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_6(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_sixtap_predict8x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(3+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 8, HFilter);
-
-
- /* then filter verticaly... */
- filter_block2d_second_pass_6(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(3 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 8, HFilter);
+
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_6(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
}
void vp8_sixtap_predict16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_6(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_6(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
}
void vp8_sixtap_predict_avg16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_6(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData,
- src_pixels_per_line, 1, 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_6(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch,
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_6[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_6[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_6(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData,
+ src_pixels_per_line, 1, 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_6(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch,
16, 16, 16, 16, VFilter);
}
@@ -650,124 +628,118 @@ void vp8_sixtap_predict_avg16x16_c
static void filter_block2d_first_pass_8
(
- unsigned char *src_ptr,
- int *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
+ unsigned char *src_ptr,
+ int *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
#if Interp_Extend == 4
- Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[0] * vp8_filter[3]) +
- ((int)src_ptr[pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[0] * vp8_filter[3]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#elif Interp_Extend == 5
- Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[0] * vp8_filter[4]) +
- ((int)src_ptr[pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
- ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[0] * vp8_filter[4]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
+ ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#endif
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
- output_ptr[j] = Temp;
- src_ptr++;
- }
-
- /* Next row... */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_width;
+ output_ptr[j] = Temp;
+ src_ptr++;
}
+
+ /* Next row... */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_width;
+ }
}
static void filter_block2d_second_pass_8
(
- int *src_ptr,
- unsigned char *output_ptr,
- int output_pitch,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- /* Apply filter */
+ int *src_ptr,
+ unsigned char *output_ptr,
+ int output_pitch,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ /* Apply filter */
#if Interp_Extend == 4
- Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[0] * vp8_filter[3]) +
- ((int)src_ptr[pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[0] * vp8_filter[3]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#elif Interp_Extend == 5
- Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[0] * vp8_filter[4]) +
- ((int)src_ptr[pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
- ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[0] * vp8_filter[4]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
+ ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#endif
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
-
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
- output_ptr[j] = (unsigned char)Temp;
- src_ptr++;
- }
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
- /* Start next row */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_pitch;
+ output_ptr[j] = (unsigned char)Temp;
+ src_ptr++;
}
+
+ /* Start next row */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_pitch;
+ }
}
/*
@@ -780,449 +752,430 @@ static void filter_block2d_second_pass_8
*/
static void filter_block2d_second_pass_avg_8
(
- int *src_ptr,
- unsigned char *output_ptr,
- int output_pitch,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- /* Apply filter */
+ int *src_ptr,
+ unsigned char *output_ptr,
+ int output_pitch,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ /* Apply filter */
#if Interp_Extend == 4
- Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[0] * vp8_filter[3]) +
- ((int)src_ptr[pixel_step] * vp8_filter[4]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[0] * vp8_filter[3]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[4]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[7]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#elif Interp_Extend == 5
- Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
- ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
- ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
- ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
- ((int)src_ptr[0] * vp8_filter[4]) +
- ((int)src_ptr[pixel_step] * vp8_filter[5]) +
- ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
- ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
- ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
- ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
- (VP8_FILTER_WEIGHT >> 1); /* Rounding */
+ Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
+ ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
+ ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
+ ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
+ ((int)src_ptr[0] * vp8_filter[4]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[5]) +
+ ((int)src_ptr[2 * pixel_step] * vp8_filter[6]) +
+ ((int)src_ptr[3 * pixel_step] * vp8_filter[7]) +
+ ((int)src_ptr[4 * pixel_step] * vp8_filter[8]) +
+ ((int)src_ptr[5 * pixel_step] * vp8_filter[9]) +
+ (VP8_FILTER_WEIGHT >> 1); /* Rounding */
#endif
- /* Normalize back to 0-255 */
- Temp = Temp >> VP8_FILTER_SHIFT;
-
- if (Temp < 0)
- Temp = 0;
- else if (Temp > 255)
- Temp = 255;
+ /* Normalize back to 0-255 */
+ Temp = Temp >> VP8_FILTER_SHIFT;
- output_ptr[j] = (unsigned char) ((output_ptr[j] + Temp + 1) >> 1);
- src_ptr++;
- }
+ if (Temp < 0)
+ Temp = 0;
+ else if (Temp > 255)
+ Temp = 255;
- /* Start next row */
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_pitch;
+ output_ptr[j] = (unsigned char)((output_ptr[j] + Temp + 1) >> 1);
+ src_ptr++;
}
+
+ /* Start next row */
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_pitch;
+ }
}
static void filter_block2d_8
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- int output_pitch,
- const short *HFilter,
- const short *VFilter
-)
-{
- int FData[(3+Interp_Extend*2)*4]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 4, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 4*(Interp_Extend-1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ int output_pitch,
+ const short *HFilter,
+ const short *VFilter
+) {
+ int FData[(3 + Interp_Extend * 2) * 4]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 4, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 4 * (Interp_Extend - 1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
}
static void filter_block2d_avg_8
(
- unsigned char *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- int output_pitch,
- const short *HFilter,
- const short *VFilter
-)
-{
- int FData[(3+Interp_Extend*2)*4]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 4, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_8(FData + 4*(Interp_Extend-1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ int output_pitch,
+ const short *HFilter,
+ const short *VFilter
+) {
+ int FData[(3 + Interp_Extend * 2) * 4]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 4, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_8(FData + 4 * (Interp_Extend - 1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
}
void vp8_eighttap_predict_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 8 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 8 tap */
-
- filter_block2d_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 8 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 8 tap */
+
+ filter_block2d_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
}
void vp8_eighttap_predict_avg4x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 8 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 8 tap */
-
- filter_block2d_avg_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 8 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 8 tap */
+
+ filter_block2d_avg_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
}
void vp8_eighttap_predict_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 8 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 8 tap */
-
- filter_block2d_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 8 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 8 tap */
+
+ filter_block2d_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
}
void vp8_eighttap_predict_avg4x4_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 8 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 8 tap */
-
- filter_block2d_avg_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 8 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 8 tap */
+
+ filter_block2d_avg_8(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
}
void vp8_eighttap_predict8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_eighttap_predict8x8_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_eighttap_predict_avg8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_eighttap_predict_avg8x8_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(7+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 7+Interp_Extend*2, 8, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(7 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 7 + Interp_Extend * 2, 8, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
}
void vp8_eighttap_predict8x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(3+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 8, HFilter);
-
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(3 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 8, HFilter);
+
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
}
void vp8_eighttap_predict8x4_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
- int FData[(3+Interp_Extend*2)*8]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 3+Interp_Extend*2, 8, HFilter);
-
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 8*(Interp_Extend-1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(7+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
+ int FData[(3 + Interp_Extend * 2) * 8]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 3 + Interp_Extend * 2, 8, HFilter);
+
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 8 * (Interp_Extend - 1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
}
void vp8_eighttap_predict16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
}
void vp8_eighttap_predict16x16_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
- 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_8(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
+ 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_8(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
}
void vp8_eighttap_predict_avg16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData,
- src_pixels_per_line, 1, 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_8(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch,
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData,
+ src_pixels_per_line, 1, 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_8(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch,
16, 16, 16, 16, VFilter);
}
void vp8_eighttap_predict_avg16x16_sharp_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
- // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
- int FData[(15+Interp_Extend*2)*16]; /* Temp data buffer used in filtering */
-
- HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
- VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
-
- /* First filter 1-D horizontally... */
- filter_block2d_first_pass_8(src_ptr - ((Interp_Extend-1) * src_pixels_per_line), FData,
- src_pixels_per_line, 1, 15+Interp_Extend*2, 16, HFilter);
-
- /* then filter verticaly... */
- filter_block2d_second_pass_avg_8(FData + 16*(Interp_Extend-1), dst_ptr, dst_pitch,
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+ // int FData[(15+Interp_Extend*2)*24]; /* Temp data buffer used in filtering */
+ int FData[(15 + Interp_Extend * 2) * 16]; /* Temp data buffer used in filtering */
+
+ HFilter = vp8_sub_pel_filters_8s[xoffset]; /* 6 tap */
+ VFilter = vp8_sub_pel_filters_8s[yoffset]; /* 6 tap */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_first_pass_8(src_ptr - ((Interp_Extend - 1) * src_pixels_per_line), FData,
+ src_pixels_per_line, 1, 15 + Interp_Extend * 2, 16, HFilter);
+
+ /* then filter verticaly... */
+ filter_block2d_second_pass_avg_8(FData + 16 * (Interp_Extend - 1), dst_ptr, dst_pitch,
16, 16, 16, 16, VFilter);
}
@@ -1252,31 +1205,28 @@ void vp8_eighttap_predict_avg16x16_sharp_c
****************************************************************************/
static void filter_block2d_bil_first_pass
(
- unsigned char *src_ptr,
- unsigned short *dst_ptr,
- unsigned int src_stride,
- unsigned int height,
- unsigned int width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- /* Apply bilinear filter */
- dst_ptr[j] = (((int)src_ptr[0] * vp8_filter[0]) +
- ((int)src_ptr[1] * vp8_filter[1]) +
- (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
- src_ptr++;
- }
-
- /* Next row... */
- src_ptr += src_stride - width;
- dst_ptr += width;
+ unsigned char *src_ptr,
+ unsigned short *dst_ptr,
+ unsigned int src_stride,
+ unsigned int height,
+ unsigned int width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ /* Apply bilinear filter */
+ dst_ptr[j] = (((int)src_ptr[0] * vp8_filter[0]) +
+ ((int)src_ptr[1] * vp8_filter[1]) +
+ (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
+ src_ptr++;
}
+
+ /* Next row... */
+ src_ptr += src_stride - width;
+ dst_ptr += width;
+ }
}
/****************************************************************************
@@ -1303,32 +1253,29 @@ static void filter_block2d_bil_first_pass
****************************************************************************/
static void filter_block2d_bil_second_pass
(
- unsigned short *src_ptr,
- unsigned char *dst_ptr,
- int dst_pitch,
- unsigned int height,
- unsigned int width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- /* Apply filter */
- Temp = ((int)src_ptr[0] * vp8_filter[0]) +
- ((int)src_ptr[width] * vp8_filter[1]) +
- (VP8_FILTER_WEIGHT / 2);
- dst_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
- src_ptr++;
- }
-
- /* Next row... */
- dst_ptr += dst_pitch;
+ unsigned short *src_ptr,
+ unsigned char *dst_ptr,
+ int dst_pitch,
+ unsigned int height,
+ unsigned int width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ /* Apply filter */
+ Temp = ((int)src_ptr[0] * vp8_filter[0]) +
+ ((int)src_ptr[width] * vp8_filter[1]) +
+ (VP8_FILTER_WEIGHT / 2);
+ dst_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
+ src_ptr++;
}
+
+ /* Next row... */
+ dst_ptr += dst_pitch;
+ }
}
/*
@@ -1342,32 +1289,29 @@ static void filter_block2d_bil_second_pass
*/
static void filter_block2d_bil_second_pass_avg
(
- unsigned short *src_ptr,
- unsigned char *dst_ptr,
- int dst_pitch,
- unsigned int height,
- unsigned int width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- /* Apply filter */
- Temp = ((int)src_ptr[0] * vp8_filter[0]) +
- ((int)src_ptr[width] * vp8_filter[1]) +
- (VP8_FILTER_WEIGHT / 2);
- dst_ptr[j] = (unsigned int)(((Temp >> VP8_FILTER_SHIFT) + dst_ptr[j] + 1) >> 1);
- src_ptr++;
- }
-
- /* Next row... */
- dst_ptr += dst_pitch;
+ unsigned short *src_ptr,
+ unsigned char *dst_ptr,
+ int dst_pitch,
+ unsigned int height,
+ unsigned int width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ /* Apply filter */
+ Temp = ((int)src_ptr[0] * vp8_filter[0]) +
+ ((int)src_ptr[width] * vp8_filter[1]) +
+ (VP8_FILTER_WEIGHT / 2);
+ dst_ptr[j] = (unsigned int)(((Temp >> VP8_FILTER_SHIFT) + dst_ptr[j] + 1) >> 1);
+ src_ptr++;
}
+
+ /* Next row... */
+ dst_ptr += dst_pitch;
+ }
}
/****************************************************************************
@@ -1395,200 +1339,189 @@ static void filter_block2d_bil_second_pass_avg
****************************************************************************/
static void filter_block2d_bil
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- unsigned int src_pitch,
- unsigned int dst_pitch,
- const short *HFilter,
- const short *VFilter,
- int Width,
- int Height
-)
-{
-
- unsigned short FData[17*16]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
-
- /* then 1-D vertically... */
- filter_block2d_bil_second_pass(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ unsigned int src_pitch,
+ unsigned int dst_pitch,
+ const short *HFilter,
+ const short *VFilter,
+ int Width,
+ int Height
+) {
+
+ unsigned short FData[17 * 16]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
+
+ /* then 1-D vertically... */
+ filter_block2d_bil_second_pass(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
}
static void filter_block2d_bil_avg
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- unsigned int src_pitch,
- unsigned int dst_pitch,
- const short *HFilter,
- const short *VFilter,
- int Width,
- int Height
-)
-{
- unsigned short FData[17*16]; /* Temp data buffer used in filtering */
-
- /* First filter 1-D horizontally... */
- filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
-
- /* then 1-D vertically... */
- filter_block2d_bil_second_pass_avg(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ unsigned int src_pitch,
+ unsigned int dst_pitch,
+ const short *HFilter,
+ const short *VFilter,
+ int Width,
+ int Height
+) {
+ unsigned short FData[17 * 16]; /* Temp data buffer used in filtering */
+
+ /* First filter 1-D horizontally... */
+ filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
+
+ /* then 1-D vertically... */
+ filter_block2d_bil_second_pass_avg(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
}
void vp8_bilinear_predict4x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
#if 0
- {
- int i;
- unsigned char temp1[16];
- unsigned char temp2[16];
+ {
+ int i;
+ unsigned char temp1[16];
+ unsigned char temp2[16];
+
+ bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
+ filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
+ for (i = 0; i < 16; i++) {
+ if (temp1[i] != temp2[i]) {
bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
-
- for (i = 0; i < 16; i++)
- {
- if (temp1[i] != temp2[i])
- {
- bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
- filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
- }
- }
+ }
}
+ }
#endif
- filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
+ filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
}
void vp8_bilinear_predict_avg4x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
- dst_pitch, HFilter, VFilter, 4, 4);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
+ dst_pitch, HFilter, VFilter, 4, 4);
}
void vp8_bilinear_predict8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
}
void vp8_bilinear_predict_avg8x8_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
- dst_pitch, HFilter, VFilter, 8, 8);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
+ dst_pitch, HFilter, VFilter, 8, 8);
}
void vp8_bilinear_predict8x4_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
}
void vp8_bilinear_predict16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
}
void vp8_bilinear_predict_avg16x16_c
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- const short *HFilter;
- const short *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
- dst_pitch, HFilter, VFilter, 16, 16);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ const short *HFilter;
+ const short *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
+ dst_pitch, HFilter, VFilter, 16, 16);
}
diff --git a/vp8/common/filter.h b/vp8/common/filter.h
index d1be97549..db97d1afc 100644
--- a/vp8/common/filter.h
+++ b/vp8/common/filter.h
@@ -29,4 +29,4 @@ extern const short vp8_sub_pel_filters_6[SUBPEL_SHIFTS][6];
extern const short vp8_sub_pel_filters_8[SUBPEL_SHIFTS][8];
extern const short vp8_sub_pel_filters_8s[SUBPEL_SHIFTS][8];
-#endif //FILTER_H
+#endif // FILTER_H
diff --git a/vp8/common/findnearmv.c b/vp8/common/findnearmv.c
index ada9d3aca..8a67162bd 100644
--- a/vp8/common/findnearmv.c
+++ b/vp8/common/findnearmv.c
@@ -12,10 +12,10 @@
#include "findnearmv.h"
const unsigned char vp8_mbsplit_offset[4][16] = {
- { 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- { 0, 2, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
+ { 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 2, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
};
/* Predict motion vectors using those from already-decoded nearby blocks.
@@ -24,162 +24,144 @@ const unsigned char vp8_mbsplit_offset[4][16] = {
void vp8_find_near_mvs
(
- MACROBLOCKD *xd,
- const MODE_INFO *here,
- const MODE_INFO *lf_here,
- int_mv *nearest,
- int_mv *nearby,
- int_mv *best_mv,
- int cnt[4],
- int refframe,
- int *ref_frame_sign_bias
-)
-{
- const MODE_INFO *above = here - xd->mode_info_stride;
- const MODE_INFO *left = here - 1;
- const MODE_INFO *aboveleft = above - 1;
- const MODE_INFO *third = NULL;
- int_mv near_mvs[4];
- int_mv *mv = near_mvs;
- int *cntx = cnt;
- enum {CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV};
-
- /* Zero accumulators */
- mv[0].as_int = mv[1].as_int = mv[2].as_int = 0;
- cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
-
- /* Process above */
- if (above->mbmi.ref_frame != INTRA_FRAME)
- {
- if (above->mbmi.mv.as_int)
- {
- (++mv)->as_int = above->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame],
- refframe, mv, ref_frame_sign_bias);
- ++cntx;
- }
- *cntx += 2;
+ MACROBLOCKD *xd,
+ const MODE_INFO *here,
+ const MODE_INFO *lf_here,
+ int_mv *nearest,
+ int_mv *nearby,
+ int_mv *best_mv,
+ int cnt[4],
+ int refframe,
+ int *ref_frame_sign_bias
+) {
+ const MODE_INFO *above = here - xd->mode_info_stride;
+ const MODE_INFO *left = here - 1;
+ const MODE_INFO *aboveleft = above - 1;
+ const MODE_INFO *third = NULL;
+ int_mv near_mvs[4];
+ int_mv *mv = near_mvs;
+ int *cntx = cnt;
+ enum {CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV};
+
+ /* Zero accumulators */
+ mv[0].as_int = mv[1].as_int = mv[2].as_int = 0;
+ cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
+
+ /* Process above */
+ if (above->mbmi.ref_frame != INTRA_FRAME) {
+ if (above->mbmi.mv.as_int) {
+ (++mv)->as_int = above->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame],
+ refframe, mv, ref_frame_sign_bias);
+ ++cntx;
}
-
- /* Process left */
- if (left->mbmi.ref_frame != INTRA_FRAME)
- {
- if (left->mbmi.mv.as_int)
- {
- int_mv this_mv;
- this_mv.as_int = left->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame],
- refframe, &this_mv, ref_frame_sign_bias);
-
- if (this_mv.as_int != mv->as_int)
- {
- (++mv)->as_int = this_mv.as_int;
- ++cntx;
- }
- *cntx += 2;
- }
- else
- cnt[CNT_INTRA] += 2;
- }
- /* Process above left or the one from last frame */
- if ( aboveleft->mbmi.ref_frame != INTRA_FRAME||
- (lf_here->mbmi.ref_frame==LAST_FRAME && refframe == LAST_FRAME))
- {
- if (aboveleft->mbmi.mv.as_int)
- {
- third = aboveleft;
- }
- else if(lf_here->mbmi.mv.as_int)
- {
- third = lf_here;
- }
- if(third)
- {
- int_mv this_mv;
- this_mv.as_int = third->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[third->mbmi.ref_frame],
- refframe, &this_mv, ref_frame_sign_bias);
-
- if (this_mv.as_int != mv->as_int)
- {
- (++mv)->as_int = this_mv.as_int;
- ++cntx;
- }
- *cntx += 1;
- }
- else
- cnt[CNT_INTRA] += 1;
+ *cntx += 2;
+ }
+
+ /* Process left */
+ if (left->mbmi.ref_frame != INTRA_FRAME) {
+ if (left->mbmi.mv.as_int) {
+ int_mv this_mv;
+ this_mv.as_int = left->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame],
+ refframe, &this_mv, ref_frame_sign_bias);
+
+ if (this_mv.as_int != mv->as_int) {
+ (++mv)->as_int = this_mv.as_int;
+ ++cntx;
+ }
+ *cntx += 2;
+ } else
+ cnt[CNT_INTRA] += 2;
+ }
+ /* Process above left or the one from last frame */
+ if (aboveleft->mbmi.ref_frame != INTRA_FRAME ||
+ (lf_here->mbmi.ref_frame == LAST_FRAME && refframe == LAST_FRAME)) {
+ if (aboveleft->mbmi.mv.as_int) {
+ third = aboveleft;
+ } else if (lf_here->mbmi.mv.as_int) {
+ third = lf_here;
}
-
- /* If we have three distinct MV's ... */
- if (cnt[CNT_SPLITMV])
- {
- /* See if the third MV can be merged with NEAREST */
- if (mv->as_int == near_mvs[CNT_NEAREST].as_int)
- cnt[CNT_NEAREST] += 1;
- }
-
- cnt[CNT_SPLITMV] = ((above->mbmi.mode == SPLITMV)
- + (left->mbmi.mode == SPLITMV)) * 2
- + (
- lf_here->mbmi.mode == SPLITMV ||
+ if (third) {
+ int_mv this_mv;
+ this_mv.as_int = third->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[third->mbmi.ref_frame],
+ refframe, &this_mv, ref_frame_sign_bias);
+
+ if (this_mv.as_int != mv->as_int) {
+ (++mv)->as_int = this_mv.as_int;
+ ++cntx;
+ }
+ *cntx += 1;
+ } else
+ cnt[CNT_INTRA] += 1;
+ }
+
+ /* If we have three distinct MV's ... */
+ if (cnt[CNT_SPLITMV]) {
+ /* See if the third MV can be merged with NEAREST */
+ if (mv->as_int == near_mvs[CNT_NEAREST].as_int)
+ cnt[CNT_NEAREST] += 1;
+ }
+
+ cnt[CNT_SPLITMV] = ((above->mbmi.mode == SPLITMV)
+ + (left->mbmi.mode == SPLITMV)) * 2
+ + (
+ lf_here->mbmi.mode == SPLITMV ||
aboveleft->mbmi.mode == SPLITMV);
- /* Swap near and nearest if necessary */
- if (cnt[CNT_NEAR] > cnt[CNT_NEAREST])
- {
- int tmp;
- tmp = cnt[CNT_NEAREST];
- cnt[CNT_NEAREST] = cnt[CNT_NEAR];
- cnt[CNT_NEAR] = tmp;
- tmp = near_mvs[CNT_NEAREST].as_int;
- near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
- near_mvs[CNT_NEAR].as_int = tmp;
- }
-
- /* Use near_mvs[0] to store the "best" MV */
- if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA])
- near_mvs[CNT_INTRA] = near_mvs[CNT_NEAREST];
-
- /* Set up return values */
- best_mv->as_int = near_mvs[0].as_int;
- nearest->as_int = near_mvs[CNT_NEAREST].as_int;
- nearby->as_int = near_mvs[CNT_NEAR].as_int;
-
- /* Make sure that the 1/8th bits of the Mvs are zero if high_precision
- * is not being used, by truncating the last bit towards 0
- */
+ /* Swap near and nearest if necessary */
+ if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
+ int tmp;
+ tmp = cnt[CNT_NEAREST];
+ cnt[CNT_NEAREST] = cnt[CNT_NEAR];
+ cnt[CNT_NEAR] = tmp;
+ tmp = near_mvs[CNT_NEAREST].as_int;
+ near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
+ near_mvs[CNT_NEAR].as_int = tmp;
+ }
+
+ /* Use near_mvs[0] to store the "best" MV */
+ if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA])
+ near_mvs[CNT_INTRA] = near_mvs[CNT_NEAREST];
+
+ /* Set up return values */
+ best_mv->as_int = near_mvs[0].as_int;
+ nearest->as_int = near_mvs[CNT_NEAREST].as_int;
+ nearby->as_int = near_mvs[CNT_NEAR].as_int;
+
+ /* Make sure that the 1/8th bits of the Mvs are zero if high_precision
+ * is not being used, by truncating the last bit towards 0
+ */
#if CONFIG_HIGH_PRECISION_MV
- if (!xd->allow_high_precision_mv)
- {
- if (best_mv->as_mv.row & 1)
- best_mv->as_mv.row += (best_mv->as_mv.row > 0 ? -1 : 1);
- if (best_mv->as_mv.col & 1)
- best_mv->as_mv.col += (best_mv->as_mv.col > 0 ? -1 : 1);
- if (nearest->as_mv.row & 1)
- nearest->as_mv.row += (nearest->as_mv.row > 0 ? -1 : 1);
- if (nearest->as_mv.col & 1)
- nearest->as_mv.col += (nearest->as_mv.col > 0 ? -1 : 1);
- if (nearby->as_mv.row & 1)
- nearby->as_mv.row += (nearby->as_mv.row > 0 ? -1 : 1);
- if (nearby->as_mv.col & 1)
- nearby->as_mv.col += (nearby->as_mv.col > 0 ? -1 : 1);
- }
+ if (!xd->allow_high_precision_mv) {
+ if (best_mv->as_mv.row & 1)
+ best_mv->as_mv.row += (best_mv->as_mv.row > 0 ? -1 : 1);
+ if (best_mv->as_mv.col & 1)
+ best_mv->as_mv.col += (best_mv->as_mv.col > 0 ? -1 : 1);
+ if (nearest->as_mv.row & 1)
+ nearest->as_mv.row += (nearest->as_mv.row > 0 ? -1 : 1);
+ if (nearest->as_mv.col & 1)
+ nearest->as_mv.col += (nearest->as_mv.col > 0 ? -1 : 1);
+ if (nearby->as_mv.row & 1)
+ nearby->as_mv.row += (nearby->as_mv.row > 0 ? -1 : 1);
+ if (nearby->as_mv.col & 1)
+ nearby->as_mv.col += (nearby->as_mv.col > 0 ? -1 : 1);
+ }
#endif
- //TODO: move clamp outside findnearmv
- vp8_clamp_mv2(nearest, xd);
- vp8_clamp_mv2(nearby, xd);
- vp8_clamp_mv2(best_mv, xd);
+ // TODO: move clamp outside findnearmv
+ vp8_clamp_mv2(nearest, xd);
+ vp8_clamp_mv2(nearby, xd);
+ vp8_clamp_mv2(best_mv, xd);
}
vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc,
- vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
-)
-{
- p[0] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[0]] [0];
- p[1] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[1]] [1];
- p[2] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[2]] [2];
- p[3] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[3]] [3];
- return p;
+ vp8_prob p[VP8_MVREFS - 1], const int near_mv_ref_ct[4]
+ ) {
+ p[0] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[0]] [0];
+ p[1] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[1]] [1];
+ p[2] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[2]] [2];
+ p[3] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[3]] [3];
+ return p;
}
diff --git a/vp8/common/findnearmv.h b/vp8/common/findnearmv.h
index 849de2ea1..d4769e608 100644
--- a/vp8/common/findnearmv.h
+++ b/vp8/common/findnearmv.h
@@ -19,190 +19,171 @@
#include "onyxc_int.h"
-static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, const int *ref_frame_sign_bias)
-{
- MV xmv;
- xmv = mvp->as_mv;
-
- if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe])
- {
- xmv.row *= -1;
- xmv.col *= -1;
- }
+static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, const int *ref_frame_sign_bias) {
+ MV xmv;
+ xmv = mvp->as_mv;
+
+ if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe]) {
+ xmv.row *= -1;
+ xmv.col *= -1;
+ }
- mvp->as_mv = xmv;
+ mvp->as_mv = xmv;
}
#define LEFT_TOP_MARGIN (16 << 3)
#define RIGHT_BOTTOM_MARGIN (16 << 3)
-static void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd)
-{
- if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
- mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
- else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
- mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
-
- if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
- mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
- else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
- mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
+static void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd) {
+ if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
+ mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
+ else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
+ mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
+
+ if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
+ mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
+ else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
+ mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
}
static void vp8_clamp_mv(int_mv *mv, int mb_to_left_edge, int mb_to_right_edge,
- int mb_to_top_edge, int mb_to_bottom_edge)
-{
- mv->as_mv.col = (mv->as_mv.col < mb_to_left_edge) ?
- mb_to_left_edge : mv->as_mv.col;
- mv->as_mv.col = (mv->as_mv.col > mb_to_right_edge) ?
- mb_to_right_edge : mv->as_mv.col;
- mv->as_mv.row = (mv->as_mv.row < mb_to_top_edge) ?
- mb_to_top_edge : mv->as_mv.row;
- mv->as_mv.row = (mv->as_mv.row > mb_to_bottom_edge) ?
- mb_to_bottom_edge : mv->as_mv.row;
+ int mb_to_top_edge, int mb_to_bottom_edge) {
+ mv->as_mv.col = (mv->as_mv.col < mb_to_left_edge) ?
+ mb_to_left_edge : mv->as_mv.col;
+ mv->as_mv.col = (mv->as_mv.col > mb_to_right_edge) ?
+ mb_to_right_edge : mv->as_mv.col;
+ mv->as_mv.row = (mv->as_mv.row < mb_to_top_edge) ?
+ mb_to_top_edge : mv->as_mv.row;
+ mv->as_mv.row = (mv->as_mv.row > mb_to_bottom_edge) ?
+ mb_to_bottom_edge : mv->as_mv.row;
}
static unsigned int vp8_check_mv_bounds(int_mv *mv, int mb_to_left_edge,
- int mb_to_right_edge, int mb_to_top_edge,
- int mb_to_bottom_edge)
-{
- unsigned int need_to_clamp;
- need_to_clamp = (mv->as_mv.col < mb_to_left_edge) ? 1 : 0;
- need_to_clamp |= (mv->as_mv.col > mb_to_right_edge) ? 1 : 0;
- need_to_clamp |= (mv->as_mv.row < mb_to_top_edge) ? 1 : 0;
- need_to_clamp |= (mv->as_mv.row > mb_to_bottom_edge) ? 1 : 0;
- return need_to_clamp;
+ int mb_to_right_edge, int mb_to_top_edge,
+ int mb_to_bottom_edge) {
+ unsigned int need_to_clamp;
+ need_to_clamp = (mv->as_mv.col < mb_to_left_edge) ? 1 : 0;
+ need_to_clamp |= (mv->as_mv.col > mb_to_right_edge) ? 1 : 0;
+ need_to_clamp |= (mv->as_mv.row < mb_to_top_edge) ? 1 : 0;
+ need_to_clamp |= (mv->as_mv.row > mb_to_bottom_edge) ? 1 : 0;
+ return need_to_clamp;
}
void vp8_find_near_mvs
(
- MACROBLOCKD *xd,
- const MODE_INFO *here,
- const MODE_INFO *lfhere,
- int_mv *nearest, int_mv *nearby, int_mv *best,
- int near_mv_ref_cts[4],
- int refframe,
- int *ref_frame_sign_bias
+ MACROBLOCKD *xd,
+ const MODE_INFO *here,
+ const MODE_INFO *lfhere,
+ int_mv *nearest, int_mv *nearby, int_mv *best,
+ int near_mv_ref_cts[4],
+ int refframe,
+ int *ref_frame_sign_bias
);
vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc,
- vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
-);
+ vp8_prob p[VP8_MVREFS - 1], const int near_mv_ref_ct[4]
+ );
extern const unsigned char vp8_mbsplit_offset[4][16];
-static int left_block_mv(const MODE_INFO *cur_mb, int b)
-{
- if (!(b & 3))
- {
- /* On L edge, get from MB to left of us */
- --cur_mb;
+static int left_block_mv(const MODE_INFO *cur_mb, int b) {
+ if (!(b & 3)) {
+ /* On L edge, get from MB to left of us */
+ --cur_mb;
- if(cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.mv.as_int;
- b += 4;
- }
+ if (cur_mb->mbmi.mode != SPLITMV)
+ return cur_mb->mbmi.mv.as_int;
+ b += 4;
+ }
- return (cur_mb->bmi + b - 1)->as_mv.first.as_int;
+ return (cur_mb->bmi + b - 1)->as_mv.first.as_int;
}
-static int left_block_second_mv(const MODE_INFO *cur_mb, int b)
-{
- if (!(b & 3))
- {
- /* On L edge, get from MB to left of us */
- --cur_mb;
+static int left_block_second_mv(const MODE_INFO *cur_mb, int b) {
+ if (!(b & 3)) {
+ /* On L edge, get from MB to left of us */
+ --cur_mb;
- if(cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
- b += 4;
- }
+ if (cur_mb->mbmi.mode != SPLITMV)
+ return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
+ b += 4;
+ }
- return cur_mb->mbmi.second_ref_frame ? (cur_mb->bmi + b - 1)->as_mv.second.as_int : (cur_mb->bmi + b - 1)->as_mv.first.as_int;
+ return cur_mb->mbmi.second_ref_frame ? (cur_mb->bmi + b - 1)->as_mv.second.as_int : (cur_mb->bmi + b - 1)->as_mv.first.as_int;
}
-static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride)
-{
- if (!(b >> 2))
- {
- /* On top edge, get from MB above us */
- cur_mb -= mi_stride;
+static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride) {
+ if (!(b >> 2)) {
+ /* On top edge, get from MB above us */
+ cur_mb -= mi_stride;
- if(cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.mv.as_int;
- b += 16;
- }
+ if (cur_mb->mbmi.mode != SPLITMV)
+ return cur_mb->mbmi.mv.as_int;
+ b += 16;
+ }
- return (cur_mb->bmi + b - 4)->as_mv.first.as_int;
+ return (cur_mb->bmi + b - 4)->as_mv.first.as_int;
}
-static int above_block_second_mv(const MODE_INFO *cur_mb, int b, int mi_stride)
-{
- if (!(b >> 2))
- {
- /* On top edge, get from MB above us */
- cur_mb -= mi_stride;
+static int above_block_second_mv(const MODE_INFO *cur_mb, int b, int mi_stride) {
+ if (!(b >> 2)) {
+ /* On top edge, get from MB above us */
+ cur_mb -= mi_stride;
- if(cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
- b += 16;
- }
+ if (cur_mb->mbmi.mode != SPLITMV)
+ return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
+ b += 16;
+ }
- return cur_mb->mbmi.second_ref_frame ? (cur_mb->bmi + b - 4)->as_mv.second.as_int : (cur_mb->bmi + b - 4)->as_mv.first.as_int;
+ return cur_mb->mbmi.second_ref_frame ? (cur_mb->bmi + b - 4)->as_mv.second.as_int : (cur_mb->bmi + b - 4)->as_mv.first.as_int;
}
-static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b)
-{
- if (!(b & 3))
- {
- /* On L edge, get from MB to left of us */
- --cur_mb;
- switch (cur_mb->mbmi.mode)
- {
- case DC_PRED:
- return B_DC_PRED;
- case V_PRED:
- return B_VE_PRED;
- case H_PRED:
- return B_HE_PRED;
- case TM_PRED:
- return B_TM_PRED;
- case I8X8_PRED:
- case B_PRED:
- return (cur_mb->bmi + b + 3)->as_mode.first;
- default:
- return B_DC_PRED;
- }
+static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
+ if (!(b & 3)) {
+ /* On L edge, get from MB to left of us */
+ --cur_mb;
+ switch (cur_mb->mbmi.mode) {
+ case DC_PRED:
+ return B_DC_PRED;
+ case V_PRED:
+ return B_VE_PRED;
+ case H_PRED:
+ return B_HE_PRED;
+ case TM_PRED:
+ return B_TM_PRED;
+ case I8X8_PRED:
+ case B_PRED:
+ return (cur_mb->bmi + b + 3)->as_mode.first;
+ default:
+ return B_DC_PRED;
}
- return (cur_mb->bmi + b - 1)->as_mode.first;
+ }
+ return (cur_mb->bmi + b - 1)->as_mode.first;
}
static B_PREDICTION_MODE above_block_mode(const MODE_INFO
- *cur_mb, int b, int mi_stride)
-{
- if (!(b >> 2))
- {
- /* On top edge, get from MB above us */
- cur_mb -= mi_stride;
-
- switch (cur_mb->mbmi.mode)
- {
- case DC_PRED:
- return B_DC_PRED;
- case V_PRED:
- return B_VE_PRED;
- case H_PRED:
- return B_HE_PRED;
- case TM_PRED:
- return B_TM_PRED;
- case I8X8_PRED:
- case B_PRED:
- return (cur_mb->bmi + b + 12)->as_mode.first;
- default:
- return B_DC_PRED;
- }
+ *cur_mb, int b, int mi_stride) {
+ if (!(b >> 2)) {
+ /* On top edge, get from MB above us */
+ cur_mb -= mi_stride;
+
+ switch (cur_mb->mbmi.mode) {
+ case DC_PRED:
+ return B_DC_PRED;
+ case V_PRED:
+ return B_VE_PRED;
+ case H_PRED:
+ return B_HE_PRED;
+ case TM_PRED:
+ return B_TM_PRED;
+ case I8X8_PRED:
+ case B_PRED:
+ return (cur_mb->bmi + b + 12)->as_mode.first;
+ default:
+ return B_DC_PRED;
}
+ }
- return (cur_mb->bmi + b - 4)->as_mode.first;
+ return (cur_mb->bmi + b - 4)->as_mode.first;
}
#endif
diff --git a/vp8/common/g_common.h b/vp8/common/g_common.h
index 5f523980b..0955aa619 100644
--- a/vp8/common/g_common.h
+++ b/vp8/common/g_common.h
@@ -13,9 +13,9 @@ extern void (*vp8_clear_system_state)(void);
extern void (*vp8_plane_add_noise)(unsigned char *Start, unsigned int Width, unsigned int Height, int Pitch, int DPitch, int q);
extern void (*de_interlace)
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- int Width,
- int Height,
- int Stride
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ int Width,
+ int Height,
+ int Stride
);
diff --git a/vp8/common/generic/systemdependent.c b/vp8/common/generic/systemdependent.c
index e6ae6b5ed..df162234c 100644
--- a/vp8/common/generic/systemdependent.c
+++ b/vp8/common/generic/systemdependent.c
@@ -20,123 +20,122 @@
extern void vp8_arch_x86_common_init(VP8_COMMON *ctx);
extern void vp8_arch_arm_common_init(VP8_COMMON *ctx);
-void vp8_machine_specific_config(VP8_COMMON *ctx)
-{
+void vp8_machine_specific_config(VP8_COMMON *ctx) {
#if CONFIG_RUNTIME_CPU_DETECT
- VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
+ VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
- rtcd->idct.idct1 = vp8_short_idct4x4llm_1_c;
- rtcd->idct.idct16 = vp8_short_idct4x4llm_c;
- rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
- rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
- rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_c;
- rtcd->idct.idct8 = vp8_short_idct8x8_c;
- rtcd->idct.idct1_scalar_add_8x8 = vp8_dc_only_idct_add_8x8_c;
- rtcd->idct.ihaar2 = vp8_short_ihaar2x2_c;
- rtcd->recon.copy16x16 = vp8_copy_mem16x16_c;
- rtcd->recon.copy8x8 = vp8_copy_mem8x8_c;
- rtcd->recon.avg16x16 = vp8_avg_mem16x16_c;
- rtcd->recon.avg8x8 = vp8_avg_mem8x8_c;
- rtcd->recon.copy8x4 = vp8_copy_mem8x4_c;
- rtcd->recon.recon = vp8_recon_b_c;
- rtcd->recon.recon_uv = vp8_recon_uv_b_c;
- rtcd->recon.recon2 = vp8_recon2b_c;
- rtcd->recon.recon4 = vp8_recon4b_c;
- rtcd->recon.recon_mb = vp8_recon_mb_c;
- rtcd->recon.recon_mby = vp8_recon_mby_c;
- rtcd->recon.build_intra_predictors_mby =
- vp8_build_intra_predictors_mby;
+ rtcd->idct.idct1 = vp8_short_idct4x4llm_1_c;
+ rtcd->idct.idct16 = vp8_short_idct4x4llm_c;
+ rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
+ rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
+ rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_c;
+ rtcd->idct.idct8 = vp8_short_idct8x8_c;
+ rtcd->idct.idct1_scalar_add_8x8 = vp8_dc_only_idct_add_8x8_c;
+ rtcd->idct.ihaar2 = vp8_short_ihaar2x2_c;
+ rtcd->recon.copy16x16 = vp8_copy_mem16x16_c;
+ rtcd->recon.copy8x8 = vp8_copy_mem8x8_c;
+ rtcd->recon.avg16x16 = vp8_avg_mem16x16_c;
+ rtcd->recon.avg8x8 = vp8_avg_mem8x8_c;
+ rtcd->recon.copy8x4 = vp8_copy_mem8x4_c;
+ rtcd->recon.recon = vp8_recon_b_c;
+ rtcd->recon.recon_uv = vp8_recon_uv_b_c;
+ rtcd->recon.recon2 = vp8_recon2b_c;
+ rtcd->recon.recon4 = vp8_recon4b_c;
+ rtcd->recon.recon_mb = vp8_recon_mb_c;
+ rtcd->recon.recon_mby = vp8_recon_mby_c;
+ rtcd->recon.build_intra_predictors_mby =
+ vp8_build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
- rtcd->recon.build_comp_intra_predictors_mby =
- vp8_build_comp_intra_predictors_mby;
+ rtcd->recon.build_comp_intra_predictors_mby =
+ vp8_build_comp_intra_predictors_mby;
#endif
- rtcd->recon.build_intra_predictors_mby_s =
- vp8_build_intra_predictors_mby_s;
- rtcd->recon.build_intra_predictors_mbuv =
- vp8_build_intra_predictors_mbuv;
- rtcd->recon.build_intra_predictors_mbuv_s =
- vp8_build_intra_predictors_mbuv_s;
+ rtcd->recon.build_intra_predictors_mby_s =
+ vp8_build_intra_predictors_mby_s;
+ rtcd->recon.build_intra_predictors_mbuv =
+ vp8_build_intra_predictors_mbuv;
+ rtcd->recon.build_intra_predictors_mbuv_s =
+ vp8_build_intra_predictors_mbuv_s;
#if CONFIG_COMP_INTRA_PRED
- rtcd->recon.build_comp_intra_predictors_mbuv =
- vp8_build_comp_intra_predictors_mbuv;
+ rtcd->recon.build_comp_intra_predictors_mbuv =
+ vp8_build_comp_intra_predictors_mbuv;
#endif
- rtcd->recon.intra4x4_predict =
- vp8_intra4x4_predict;
+ rtcd->recon.intra4x4_predict =
+ vp8_intra4x4_predict;
#if CONFIG_COMP_INTRA_PRED
- rtcd->recon.comp_intra4x4_predict =
- vp8_comp_intra4x4_predict;
+ rtcd->recon.comp_intra4x4_predict =
+ vp8_comp_intra4x4_predict;
#endif
- rtcd->recon.intra8x8_predict =
- vp8_intra8x8_predict;
+ rtcd->recon.intra8x8_predict =
+ vp8_intra8x8_predict;
#if CONFIG_COMP_INTRA_PRED
- rtcd->recon.comp_intra8x8_predict =
- vp8_comp_intra8x8_predict;
+ rtcd->recon.comp_intra8x8_predict =
+ vp8_comp_intra8x8_predict;
#endif
- rtcd->recon.intra_uv4x4_predict =
- vp8_intra_uv4x4_predict;
+ rtcd->recon.intra_uv4x4_predict =
+ vp8_intra_uv4x4_predict;
#if CONFIG_COMP_INTRA_PRED
- rtcd->recon.comp_intra_uv4x4_predict =
- vp8_comp_intra_uv4x4_predict;
+ rtcd->recon.comp_intra_uv4x4_predict =
+ vp8_comp_intra_uv4x4_predict;
#endif
#if CONFIG_ENHANCED_INTERP
- rtcd->subpix.eighttap16x16 = vp8_eighttap_predict16x16_c;
- rtcd->subpix.eighttap8x8 = vp8_eighttap_predict8x8_c;
- rtcd->subpix.eighttap_avg16x16 = vp8_eighttap_predict_avg16x16_c;
- rtcd->subpix.eighttap_avg8x8 = vp8_eighttap_predict_avg8x8_c;
- rtcd->subpix.eighttap_avg4x4 = vp8_eighttap_predict_avg4x4_c;
- rtcd->subpix.eighttap8x4 = vp8_eighttap_predict8x4_c;
- rtcd->subpix.eighttap4x4 = vp8_eighttap_predict_c;
- rtcd->subpix.eighttap16x16_sharp = vp8_eighttap_predict16x16_sharp_c;
- rtcd->subpix.eighttap8x8_sharp = vp8_eighttap_predict8x8_sharp_c;
- rtcd->subpix.eighttap_avg16x16_sharp = vp8_eighttap_predict_avg16x16_sharp_c;
- rtcd->subpix.eighttap_avg8x8_sharp = vp8_eighttap_predict_avg8x8_sharp_c;
- rtcd->subpix.eighttap_avg4x4_sharp = vp8_eighttap_predict_avg4x4_sharp_c;
- rtcd->subpix.eighttap8x4_sharp = vp8_eighttap_predict8x4_sharp_c;
- rtcd->subpix.eighttap4x4_sharp = vp8_eighttap_predict_sharp_c;
+ rtcd->subpix.eighttap16x16 = vp8_eighttap_predict16x16_c;
+ rtcd->subpix.eighttap8x8 = vp8_eighttap_predict8x8_c;
+ rtcd->subpix.eighttap_avg16x16 = vp8_eighttap_predict_avg16x16_c;
+ rtcd->subpix.eighttap_avg8x8 = vp8_eighttap_predict_avg8x8_c;
+ rtcd->subpix.eighttap_avg4x4 = vp8_eighttap_predict_avg4x4_c;
+ rtcd->subpix.eighttap8x4 = vp8_eighttap_predict8x4_c;
+ rtcd->subpix.eighttap4x4 = vp8_eighttap_predict_c;
+ rtcd->subpix.eighttap16x16_sharp = vp8_eighttap_predict16x16_sharp_c;
+ rtcd->subpix.eighttap8x8_sharp = vp8_eighttap_predict8x8_sharp_c;
+ rtcd->subpix.eighttap_avg16x16_sharp = vp8_eighttap_predict_avg16x16_sharp_c;
+ rtcd->subpix.eighttap_avg8x8_sharp = vp8_eighttap_predict_avg8x8_sharp_c;
+ rtcd->subpix.eighttap_avg4x4_sharp = vp8_eighttap_predict_avg4x4_sharp_c;
+ rtcd->subpix.eighttap8x4_sharp = vp8_eighttap_predict8x4_sharp_c;
+ rtcd->subpix.eighttap4x4_sharp = vp8_eighttap_predict_sharp_c;
#endif
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_c;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_c;
- rtcd->subpix.sixtap_avg16x16 = vp8_sixtap_predict_avg16x16_c;
- rtcd->subpix.sixtap_avg8x8 = vp8_sixtap_predict_avg8x8_c;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_c;
- rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_c;
- rtcd->subpix.sixtap_avg4x4 = vp8_sixtap_predict_avg_c;
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_c;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_c;
- rtcd->subpix.bilinear_avg16x16 = vp8_bilinear_predict_avg16x16_c;
- rtcd->subpix.bilinear_avg8x8 = vp8_bilinear_predict_avg8x8_c;
- rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_c;
- rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_c;
- rtcd->subpix.bilinear_avg4x4 = vp8_bilinear_predict_avg4x4_c;
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_c;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_c;
+ rtcd->subpix.sixtap_avg16x16 = vp8_sixtap_predict_avg16x16_c;
+ rtcd->subpix.sixtap_avg8x8 = vp8_sixtap_predict_avg8x8_c;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_c;
+ rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_c;
+ rtcd->subpix.sixtap_avg4x4 = vp8_sixtap_predict_avg_c;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_c;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_c;
+ rtcd->subpix.bilinear_avg16x16 = vp8_bilinear_predict_avg16x16_c;
+ rtcd->subpix.bilinear_avg8x8 = vp8_bilinear_predict_avg8x8_c;
+ rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_c;
+ rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_c;
+ rtcd->subpix.bilinear_avg4x4 = vp8_bilinear_predict_avg4x4_c;
- rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c;
- rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_c;
- rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c;
- rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_c;
- rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_c;
- rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_c;
- rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_c;
- rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_c;
+ rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c;
+ rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_c;
+ rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c;
+ rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_c;
+ rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_c;
+ rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_c;
+ rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_c;
+ rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_c;
#if CONFIG_POSTPROC || (CONFIG_VP8_ENCODER && CONFIG_INTERNAL_STATS)
- rtcd->postproc.down = vp8_mbpost_proc_down_c;
- rtcd->postproc.across = vp8_mbpost_proc_across_ip_c;
- rtcd->postproc.downacross = vp8_post_proc_down_and_across_c;
- rtcd->postproc.addnoise = vp8_plane_add_noise_c;
- rtcd->postproc.blend_mb_inner = vp8_blend_mb_inner_c;
- rtcd->postproc.blend_mb_outer = vp8_blend_mb_outer_c;
- rtcd->postproc.blend_b = vp8_blend_b_c;
+ rtcd->postproc.down = vp8_mbpost_proc_down_c;
+ rtcd->postproc.across = vp8_mbpost_proc_across_ip_c;
+ rtcd->postproc.downacross = vp8_post_proc_down_and_across_c;
+ rtcd->postproc.addnoise = vp8_plane_add_noise_c;
+ rtcd->postproc.blend_mb_inner = vp8_blend_mb_inner_c;
+ rtcd->postproc.blend_mb_outer = vp8_blend_mb_outer_c;
+ rtcd->postproc.blend_b = vp8_blend_b_c;
#endif
#endif
#if ARCH_X86 || ARCH_X86_64
- vp8_arch_x86_common_init(ctx);
+ vp8_arch_x86_common_init(ctx);
#endif
#if ARCH_ARM
- vp8_arch_arm_common_init(ctx);
+ vp8_arch_arm_common_init(ctx);
#endif
}
diff --git a/vp8/common/header.h b/vp8/common/header.h
index 3e98eeb3c..6fe0ca4e0 100644
--- a/vp8/common/header.h
+++ b/vp8/common/header.h
@@ -13,22 +13,21 @@
#define __INC_HEADER_H
/* 24 bits total */
-typedef struct
-{
- unsigned int type: 1;
- unsigned int version: 3;
- unsigned int show_frame: 1;
+typedef struct {
+ unsigned int type: 1;
+ unsigned int version: 3;
+ unsigned int show_frame: 1;
- /* Allow 2^20 bytes = 8 megabits for first partition */
+ /* Allow 2^20 bytes = 8 megabits for first partition */
- unsigned int first_partition_length_in_bytes: 19;
+ unsigned int first_partition_length_in_bytes: 19;
#ifdef PACKET_TESTING
- unsigned int frame_number;
- unsigned int update_gold: 1;
- unsigned int uses_gold: 1;
- unsigned int update_last: 1;
- unsigned int uses_last: 1;
+ unsigned int frame_number;
+ unsigned int update_gold: 1;
+ unsigned int uses_gold: 1;
+ unsigned int update_last: 1;
+ unsigned int uses_last: 1;
#endif
} VP8_HEADER;
diff --git a/vp8/common/idct.h b/vp8/common/idct.h
index bafa662e6..433f57745 100644
--- a/vp8/common/idct.h
+++ b/vp8/common/idct.h
@@ -13,15 +13,15 @@
#define __INC_IDCT_H
#define prototype_second_order(sym) \
- void sym(short *input, short *output)
+ void sym(short *input, short *output)
#define prototype_idct(sym) \
- void sym(short *input, short *output, int pitch)
+ void sym(short *input, short *output, int pitch)
#define prototype_idct_scalar_add(sym) \
- void sym(short input, \
- unsigned char *pred, unsigned char *output, \
- int pitch, int stride)
+ void sym(short input, \
+ unsigned char *pred, unsigned char *output, \
+ int pitch, int stride)
#if ARCH_X86 || ARCH_X86_64
#include "x86/idct_x86.h"
@@ -101,20 +101,19 @@ typedef prototype_idct((*vp8_idct_fn_t));
typedef prototype_idct_scalar_add((*vp8_idct_scalar_add_fn_t));
typedef prototype_second_order((*vp8_second_order_fn_t));
-typedef struct
-{
- vp8_idct_fn_t idct1;
- vp8_idct_fn_t idct16;
- vp8_idct_scalar_add_fn_t idct1_scalar_add;
+typedef struct {
+ vp8_idct_fn_t idct1;
+ vp8_idct_fn_t idct16;
+ vp8_idct_scalar_add_fn_t idct1_scalar_add;
- vp8_second_order_fn_t iwalsh1;
- vp8_second_order_fn_t iwalsh16;
+ vp8_second_order_fn_t iwalsh1;
+ vp8_second_order_fn_t iwalsh16;
- vp8_idct_fn_t idct8;
- vp8_idct_fn_t idct8_1;
- vp8_idct_scalar_add_fn_t idct1_scalar_add_8x8;
- vp8_idct_fn_t ihaar2;
- vp8_idct_fn_t ihaar2_1;
+ vp8_idct_fn_t idct8;
+ vp8_idct_fn_t idct8_1;
+ vp8_idct_scalar_add_fn_t idct1_scalar_add_8x8;
+ vp8_idct_fn_t ihaar2;
+ vp8_idct_fn_t ihaar2_1;
} vp8_idct_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/common/idctllm.c b/vp8/common/idctllm.c
index acb856d53..684868cb2 100644
--- a/vp8/common/idctllm.c
+++ b/vp8/common/idctllm.c
@@ -32,360 +32,330 @@ static const int cospi8sqrt2minus1 = 20091;
static const int sinpi8sqrt2 = 35468;
static const int rounding = 0;
-void vp8_short_idct4x4llm_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
+void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
- int temp1, temp2;
- int shortpitch = pitch >> 1;
+ short *ip = input;
+ short *op = output;
+ int temp1, temp2;
+ int shortpitch = pitch >> 1;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[8];
- b1 = ip[0] - ip[8];
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[8];
+ b1 = ip[0] - ip[8];
- temp1 = (ip[4] * sinpi8sqrt2 + rounding) >> 16;
- temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1 + rounding) >> 16);
- c1 = temp1 - temp2;
+ temp1 = (ip[4] * sinpi8sqrt2 + rounding) >> 16;
+ temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1 + rounding) >> 16);
+ c1 = temp1 - temp2;
- temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1 + rounding) >> 16);
- temp2 = (ip[12] * sinpi8sqrt2 + rounding) >> 16;
- d1 = temp1 + temp2;
+ temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1 + rounding) >> 16);
+ temp2 = (ip[12] * sinpi8sqrt2 + rounding) >> 16;
+ d1 = temp1 + temp2;
- op[shortpitch*0] = a1 + d1;
- op[shortpitch*3] = a1 - d1;
+ op[shortpitch * 0] = a1 + d1;
+ op[shortpitch * 3] = a1 - d1;
- op[shortpitch*1] = b1 + c1;
- op[shortpitch*2] = b1 - c1;
+ op[shortpitch * 1] = b1 + c1;
+ op[shortpitch * 2] = b1 - c1;
- ip++;
- op++;
- }
+ ip++;
+ op++;
+ }
- ip = output;
- op = output;
+ ip = output;
+ op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[2];
- b1 = ip[0] - ip[2];
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[2];
+ b1 = ip[0] - ip[2];
- temp1 = (ip[1] * sinpi8sqrt2 + rounding) >> 16;
- temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1 + rounding) >> 16);
- c1 = temp1 - temp2;
+ temp1 = (ip[1] * sinpi8sqrt2 + rounding) >> 16;
+ temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1 + rounding) >> 16);
+ c1 = temp1 - temp2;
- temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1 + rounding) >> 16);
- temp2 = (ip[3] * sinpi8sqrt2 + rounding) >> 16;
- d1 = temp1 + temp2;
+ temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1 + rounding) >> 16);
+ temp2 = (ip[3] * sinpi8sqrt2 + rounding) >> 16;
+ d1 = temp1 + temp2;
- op[0] = (a1 + d1 + 16) >> 5;
- op[3] = (a1 - d1 + 16) >> 5;
+ op[0] = (a1 + d1 + 16) >> 5;
+ op[3] = (a1 - d1 + 16) >> 5;
- op[1] = (b1 + c1 + 16) >> 5;
- op[2] = (b1 - c1 + 16) >> 5;
+ op[1] = (b1 + c1 + 16) >> 5;
+ op[2] = (b1 - c1 + 16) >> 5;
- ip += shortpitch;
- op += shortpitch;
- }
+ ip += shortpitch;
+ op += shortpitch;
+ }
}
-void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch)
-{
- int i;
- int a1;
- short *op = output;
- int shortpitch = pitch >> 1;
- a1 = ((input[0] + 16) >> 5);
- for (i = 0; i < 4; i++)
- {
- op[0] = a1;
- op[1] = a1;
- op[2] = a1;
- op[3] = a1;
- op += shortpitch;
- }
+void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch) {
+ int i;
+ int a1;
+ short *op = output;
+ int shortpitch = pitch >> 1;
+ a1 = ((input[0] + 16) >> 5);
+ for (i = 0; i < 4; i++) {
+ op[0] = a1;
+ op[1] = a1;
+ op[2] = a1;
+ op[3] = a1;
+ op += shortpitch;
+ }
}
-void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr, unsigned char *dst_ptr, int pitch, int stride)
-{
- int a1 = ((input_dc + 16) >> 5);
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = a1 + pred_ptr[c] ;
+void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr, unsigned char *dst_ptr, int pitch, int stride) {
+ int a1 = ((input_dc + 16) >> 5);
+ int r, c;
- if (a < 0)
- a = 0;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = a1 + pred_ptr[c];
- if (a > 255)
- a = 255;
+ if (a < 0)
+ a = 0;
- dst_ptr[c] = (unsigned char) a ;
- }
+ if (a > 255)
+ a = 255;
- dst_ptr += stride;
- pred_ptr += pitch;
+ dst_ptr[c] = (unsigned char) a;
}
-}
+ dst_ptr += stride;
+ pred_ptr += pitch;
+ }
-void vp8_short_inv_walsh4x4_c(short *input, short *output)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ((ip[0] + ip[3]));
- b1 = ((ip[1] + ip[2]));
- c1 = ((ip[1] - ip[2]));
- d1 = ((ip[0] - ip[3]));
-
- op[0] = (a1 + b1 + 1)>>1;
- op[1] = (c1 + d1)>>1;
- op[2] = (a1 - b1)>>1;
- op[3] = (d1 - c1)>>1;
-
- ip += 4;
- op += 4;
- }
+}
- ip = output;
- op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[12];
- b1 = ip[4] + ip[8];
- c1 = ip[4] - ip[8];
- d1 = ip[0] - ip[12];
- op[0] = (a1 + b1 + 1)>>1;
- op[4] = (c1 + d1)>>1;
- op[8] = (a1 - b1)>>1;
- op[12]= (d1 - c1)>>1;
- ip++;
- op++;
- }
+void vp8_short_inv_walsh4x4_c(short *input, short *output) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ((ip[0] + ip[3]));
+ b1 = ((ip[1] + ip[2]));
+ c1 = ((ip[1] - ip[2]));
+ d1 = ((ip[0] - ip[3]));
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[1] = (c1 + d1) >> 1;
+ op[2] = (a1 - b1) >> 1;
+ op[3] = (d1 - c1) >> 1;
+
+ ip += 4;
+ op += 4;
+ }
+
+ ip = output;
+ op = output;
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[12];
+ b1 = ip[4] + ip[8];
+ c1 = ip[4] - ip[8];
+ d1 = ip[0] - ip[12];
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[4] = (c1 + d1) >> 1;
+ op[8] = (a1 - b1) >> 1;
+ op[12] = (d1 - c1) >> 1;
+ ip++;
+ op++;
+ }
}
-void vp8_short_inv_walsh4x4_1_c(short *in, short *out)
-{
- int i;
- short tmp[4];
- short *ip = in;
- short *op = tmp;
-
- op[0] =(ip[0]+ 1)>>1;
- op[1] = op[2] = op[3] = (ip[0]>>1);
-
- ip = tmp;
- op = out;
- for(i = 0; i<4; i++)
- {
- op[0] =(ip[0]+ 1)>>1;
- op[4] = op[8] = op[12] = (ip[0]>>1);
- ip ++;
- op ++;
- }
+void vp8_short_inv_walsh4x4_1_c(short *in, short *out) {
+ int i;
+ short tmp[4];
+ short *ip = in;
+ short *op = tmp;
+
+ op[0] = (ip[0] + 1) >> 1;
+ op[1] = op[2] = op[3] = (ip[0] >> 1);
+
+ ip = tmp;
+ op = out;
+ for (i = 0; i < 4; i++) {
+ op[0] = (ip[0] + 1) >> 1;
+ op[4] = op[8] = op[12] = (ip[0] >> 1);
+ ip++;
+ op++;
+ }
}
#if CONFIG_LOSSLESS
-void vp8_short_inv_walsh4x4_lossless_c(short *input, short *output)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ((ip[0] + ip[3]))>>Y2_WHT_UPSCALE_FACTOR;
- b1 = ((ip[1] + ip[2]))>>Y2_WHT_UPSCALE_FACTOR;
- c1 = ((ip[1] - ip[2]))>>Y2_WHT_UPSCALE_FACTOR;
- d1 = ((ip[0] - ip[3]))>>Y2_WHT_UPSCALE_FACTOR;
-
- op[0] = (a1 + b1 + 1)>>1;
- op[1] = (c1 + d1)>>1;
- op[2] = (a1 - b1)>>1;
- op[3] = (d1 - c1)>>1;
-
- ip += 4;
- op += 4;
- }
-
- ip = output;
- op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[12];
- b1 = ip[4] + ip[8];
- c1 = ip[4] - ip[8];
- d1 = ip[0] - ip[12];
-
-
- op[0] = ((a1 + b1 + 1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[4] = ((c1 + d1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[8] = ((a1 - b1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[12]= ((d1 - c1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
-
- ip++;
- op++;
- }
+void vp8_short_inv_walsh4x4_lossless_c(short *input, short *output) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ((ip[0] + ip[3])) >> Y2_WHT_UPSCALE_FACTOR;
+ b1 = ((ip[1] + ip[2])) >> Y2_WHT_UPSCALE_FACTOR;
+ c1 = ((ip[1] - ip[2])) >> Y2_WHT_UPSCALE_FACTOR;
+ d1 = ((ip[0] - ip[3])) >> Y2_WHT_UPSCALE_FACTOR;
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[1] = (c1 + d1) >> 1;
+ op[2] = (a1 - b1) >> 1;
+ op[3] = (d1 - c1) >> 1;
+
+ ip += 4;
+ op += 4;
+ }
+
+ ip = output;
+ op = output;
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[12];
+ b1 = ip[4] + ip[8];
+ c1 = ip[4] - ip[8];
+ d1 = ip[0] - ip[12];
+
+
+ op[0] = ((a1 + b1 + 1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[4] = ((c1 + d1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[8] = ((a1 - b1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[12] = ((d1 - c1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+
+ ip++;
+ op++;
+ }
}
-void vp8_short_inv_walsh4x4_1_lossless_c(short *in, short *out)
-{
- int i;
- short tmp[4];
- short *ip = in;
- short *op = tmp;
-
- op[0] =((ip[0]>>Y2_WHT_UPSCALE_FACTOR)+ 1)>>1;
- op[1] = op[2] = op[3] = ((ip[0]>>Y2_WHT_UPSCALE_FACTOR)>>1);
-
- ip = tmp;
- op = out;
- for(i = 0; i<4; i++)
- {
- op[0] =((ip[0]+ 1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[4] = op[8] = op[12] = ((ip[0]>>1))<<Y2_WHT_UPSCALE_FACTOR;
- ip ++;
- op ++;
- }
+void vp8_short_inv_walsh4x4_1_lossless_c(short *in, short *out) {
+ int i;
+ short tmp[4];
+ short *ip = in;
+ short *op = tmp;
+
+ op[0] = ((ip[0] >> Y2_WHT_UPSCALE_FACTOR) + 1) >> 1;
+ op[1] = op[2] = op[3] = ((ip[0] >> Y2_WHT_UPSCALE_FACTOR) >> 1);
+
+ ip = tmp;
+ op = out;
+ for (i = 0; i < 4; i++) {
+ op[0] = ((ip[0] + 1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[4] = op[8] = op[12] = ((ip[0] >> 1)) << Y2_WHT_UPSCALE_FACTOR;
+ ip++;
+ op++;
+ }
}
-void vp8_short_inv_walsh4x4_x8_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
- int shortpitch = pitch >> 1;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ((ip[0] + ip[3]))>>WHT_UPSCALE_FACTOR;
- b1 = ((ip[1] + ip[2]))>>WHT_UPSCALE_FACTOR;
- c1 = ((ip[1] - ip[2]))>>WHT_UPSCALE_FACTOR;
- d1 = ((ip[0] - ip[3]))>>WHT_UPSCALE_FACTOR;
-
- op[0] = (a1 + b1 + 1)>>1;
- op[1] = (c1 + d1)>>1;
- op[2] = (a1 - b1)>>1;
- op[3] = (d1 - c1)>>1;
-
- ip += 4;
- op += shortpitch;
- }
+void vp8_short_inv_walsh4x4_x8_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+ int shortpitch = pitch >> 1;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ((ip[0] + ip[3])) >> WHT_UPSCALE_FACTOR;
+ b1 = ((ip[1] + ip[2])) >> WHT_UPSCALE_FACTOR;
+ c1 = ((ip[1] - ip[2])) >> WHT_UPSCALE_FACTOR;
+ d1 = ((ip[0] - ip[3])) >> WHT_UPSCALE_FACTOR;
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[1] = (c1 + d1) >> 1;
+ op[2] = (a1 - b1) >> 1;
+ op[3] = (d1 - c1) >> 1;
+
+ ip += 4;
+ op += shortpitch;
+ }
+
+ ip = output;
+ op = output;
+ for (i = 0; i < 4; i++) {
+ a1 = ip[shortpitch * 0] + ip[shortpitch * 3];
+ b1 = ip[shortpitch * 1] + ip[shortpitch * 2];
+ c1 = ip[shortpitch * 1] - ip[shortpitch * 2];
+ d1 = ip[shortpitch * 0] - ip[shortpitch * 3];
+
+
+ op[shortpitch * 0] = (a1 + b1 + 1) >> 1;
+ op[shortpitch * 1] = (c1 + d1) >> 1;
+ op[shortpitch * 2] = (a1 - b1) >> 1;
+ op[shortpitch * 3] = (d1 - c1) >> 1;
+
+ ip++;
+ op++;
+ }
+}
- ip = output;
- op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[shortpitch*0] + ip[shortpitch*3];
- b1 = ip[shortpitch*1] + ip[shortpitch*2];
- c1 = ip[shortpitch*1] - ip[shortpitch*2];
- d1 = ip[shortpitch*0] - ip[shortpitch*3];
+void vp8_short_inv_walsh4x4_1_x8_c(short *in, short *out, int pitch) {
+ int i;
+ short tmp[4];
+ short *ip = in;
+ short *op = tmp;
+ int shortpitch = pitch >> 1;
+
+ op[0] = ((ip[0] >> WHT_UPSCALE_FACTOR) + 1) >> 1;
+ op[1] = op[2] = op[3] = ((ip[0] >> WHT_UPSCALE_FACTOR) >> 1);
+
+
+ ip = tmp;
+ op = out;
+ for (i = 0; i < 4; i++) {
+ op[shortpitch * 0] = (ip[0] + 1) >> 1;
+ op[shortpitch * 1] = op[shortpitch * 2] = op[shortpitch * 3] = ip[0] >> 1;
+ ip++;
+ op++;
+ }
+}
+void vp8_dc_only_inv_walsh_add_c(short input_dc, unsigned char *pred_ptr, unsigned char *dst_ptr, int pitch, int stride) {
+ int r, c;
+ short tmp[16];
+ vp8_short_inv_walsh4x4_1_x8_c(&input_dc, tmp, 4 << 1);
- op[shortpitch*0] = (a1 + b1 + 1)>>1;
- op[shortpitch*1] = (c1 + d1)>>1;
- op[shortpitch*2] = (a1 - b1)>>1;
- op[shortpitch*3] = (d1 - c1)>>1;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = tmp[r * 4 + c] + pred_ptr[c];
+ if (a < 0)
+ a = 0;
- ip++;
- op++;
- }
-}
+ if (a > 255)
+ a = 255;
-void vp8_short_inv_walsh4x4_1_x8_c(short *in, short *out, int pitch)
-{
- int i;
- short tmp[4];
- short *ip = in;
- short *op = tmp;
- int shortpitch = pitch >> 1;
-
- op[0] =((ip[0]>>WHT_UPSCALE_FACTOR) + 1)>>1;
- op[1] = op[2] = op[3] = ((ip[0]>>WHT_UPSCALE_FACTOR)>>1);
-
-
- ip = tmp;
- op = out;
- for(i = 0; i<4; i++)
- {
- op[shortpitch*0] =(ip[0]+ 1)>>1;
- op[shortpitch*1] = op[shortpitch*2] = op[shortpitch*3] = ip[0]>>1;
- ip ++;
- op ++;
+ dst_ptr[c] = (unsigned char) a;
}
-}
-void vp8_dc_only_inv_walsh_add_c(short input_dc, unsigned char *pred_ptr, unsigned char *dst_ptr, int pitch, int stride)
-{
- int r, c;
- short tmp[16];
- vp8_short_inv_walsh4x4_1_x8_c( &input_dc, tmp, 4<<1);
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = tmp[r*4 + c] + pred_ptr[c] ;
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- pred_ptr += pitch;
- }
+ dst_ptr += stride;
+ pred_ptr += pitch;
+ }
}
#endif
void vp8_dc_only_idct_add_8x8_c(short input_dc,
unsigned char *pred_ptr,
unsigned char *dst_ptr,
- int pitch, int stride)
-{
- int a1 = ((input_dc + 16) >> 5);
- int r, c, b;
- unsigned char *orig_pred = pred_ptr;
- unsigned char *orig_dst = dst_ptr;
- for (b = 0; b < 4; b++)
- {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = a1 + pred_ptr[c] ;
-
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- pred_ptr += pitch;
- }
- dst_ptr = orig_dst + (b+1)%2*4 + (b+1)/2*4*stride;
- pred_ptr = orig_pred + (b+1)%2*4 + (b+1)/2*4*pitch;
+ int pitch, int stride) {
+ int a1 = ((input_dc + 16) >> 5);
+ int r, c, b;
+ unsigned char *orig_pred = pred_ptr;
+ unsigned char *orig_dst = dst_ptr;
+ for (b = 0; b < 4; b++) {
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = a1 + pred_ptr[c];
+
+ if (a < 0)
+ a = 0;
+
+ if (a > 255)
+ a = 255;
+
+ dst_ptr[c] = (unsigned char) a;
+ }
+
+ dst_ptr += stride;
+ pred_ptr += pitch;
}
+ dst_ptr = orig_dst + (b + 1) % 2 * 4 + (b + 1) / 2 * 4 * stride;
+ pred_ptr = orig_pred + (b + 1) % 2 * 4 + (b + 1) / 2 * 4 * pitch;
+ }
}
#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
@@ -402,55 +372,53 @@ void vp8_dc_only_idct_add_8x8_c(short input_dc,
*
* where: c[0] = 128 c[1..7] = 128*sqrt(2) */
-static void idctrow (int *blk)
-{
- int x0, x1, x2, x3, x4, x5, x6, x7, x8;
- /* shortcut */
- if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
- (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
- {
- blk[0] = blk[1] = blk[2] = blk[3] = blk[4]
- = blk[5] = blk[6] = blk[7] = blk[0] << 3;
- return;
- }
-
- x0 = (blk[0] << 11) + 128; /* for proper rounding in the fourth stage */
- /* first stage */
- x8 = W7 * (x4 + x5);
- x4 = x8 + (W1 - W7) * x4;
- x5 = x8 - (W1 + W7) * x5;
- x8 = W3 * (x6 + x7);
- x6 = x8 - (W3 - W5) * x6;
- x7 = x8 - (W3 + W5) * x7;
-
- /* second stage */
- x8 = x0 + x1;
- x0 -= x1;
- x1 = W6 * (x3 + x2);
- x2 = x1 - (W2 + W6) * x2;
- x3 = x1 + (W2 - W6) * x3;
- x1 = x4 + x6;
- x4 -= x6;
- x6 = x5 + x7;
- x5 -= x7;
-
- /* third stage */
- x7 = x8 + x3;
- x8 -= x3;
- x3 = x0 + x2;
- x0 -= x2;
- x2 = (181 * (x4 + x5) + 128) >> 8;
- x4 = (181 * (x4 - x5) + 128) >> 8;
-
- /* fourth stage */
- blk[0] = (x7 + x1) >> 8;
- blk[1] = (x3 + x2) >> 8;
- blk[2] = (x0 + x4) >> 8;
- blk[3] = (x8 + x6) >> 8;
- blk[4] = (x8 - x6) >> 8;
- blk[5] = (x0 - x4) >> 8;
- blk[6] = (x3 - x2) >> 8;
- blk[7] = (x7 - x1) >> 8;
+static void idctrow(int *blk) {
+ int x0, x1, x2, x3, x4, x5, x6, x7, x8;
+ /* shortcut */
+ if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
+ (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) {
+ blk[0] = blk[1] = blk[2] = blk[3] = blk[4]
+ = blk[5] = blk[6] = blk[7] = blk[0] << 3;
+ return;
+ }
+
+ x0 = (blk[0] << 11) + 128; /* for proper rounding in the fourth stage */
+ /* first stage */
+ x8 = W7 * (x4 + x5);
+ x4 = x8 + (W1 - W7) * x4;
+ x5 = x8 - (W1 + W7) * x5;
+ x8 = W3 * (x6 + x7);
+ x6 = x8 - (W3 - W5) * x6;
+ x7 = x8 - (W3 + W5) * x7;
+
+ /* second stage */
+ x8 = x0 + x1;
+ x0 -= x1;
+ x1 = W6 * (x3 + x2);
+ x2 = x1 - (W2 + W6) * x2;
+ x3 = x1 + (W2 - W6) * x3;
+ x1 = x4 + x6;
+ x4 -= x6;
+ x6 = x5 + x7;
+ x5 -= x7;
+
+ /* third stage */
+ x7 = x8 + x3;
+ x8 -= x3;
+ x3 = x0 + x2;
+ x0 -= x2;
+ x2 = (181 * (x4 + x5) + 128) >> 8;
+ x4 = (181 * (x4 - x5) + 128) >> 8;
+
+ /* fourth stage */
+ blk[0] = (x7 + x1) >> 8;
+ blk[1] = (x3 + x2) >> 8;
+ blk[2] = (x0 + x4) >> 8;
+ blk[3] = (x8 + x6) >> 8;
+ blk[4] = (x8 - x6) >> 8;
+ blk[5] = (x0 - x4) >> 8;
+ blk[6] = (x3 - x2) >> 8;
+ blk[7] = (x7 - x1) >> 8;
}
/* column (vertical) IDCT
@@ -459,105 +427,96 @@ static void idctrow (int *blk)
* cos( -- * ( k + - ) * l ) l=0 8 2
*
* where: c[0] = 1/1024 c[1..7] = (1/1024)*sqrt(2) */
-static void idctcol (int *blk)
-{
- int x0, x1, x2, x3, x4, x5, x6, x7, x8;
+static void idctcol(int *blk) {
+ int x0, x1, x2, x3, x4, x5, x6, x7, x8;
- /* shortcut */
- if (!((x1 = (blk[8 * 4] << 8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
+ /* shortcut */
+ if (!((x1 = (blk[8 * 4] << 8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
(x4 = blk[8 * 1]) | (x5 = blk[8 * 7]) | (x6 = blk[8 * 5]) |
- (x7 = blk[8 * 3])))
- {
- blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3]
- = blk[8 * 4] = blk[8 * 5] = blk[8 * 6]
- = blk[8 * 7] = ((blk[8 * 0] + 32) >>6);
- return;
- }
-
- x0 = (blk[8 * 0] << 8) + 16384;
-
- /* first stage */
- x8 = W7 * (x4 + x5) + 4;
- x4 = (x8 + (W1 - W7) * x4) >> 3;
- x5 = (x8 - (W1 + W7) * x5) >> 3;
- x8 = W3 * (x6 + x7) + 4;
- x6 = (x8 - (W3 - W5) * x6) >> 3;
- x7 = (x8 - (W3 + W5) * x7) >> 3;
-
- /* second stage */
- x8 = x0 + x1;
- x0 -= x1;
- x1 = W6 * (x3 + x2) + 4;
- x2 = (x1 - (W2 + W6) * x2) >> 3;
- x3 = (x1 + (W2 - W6) * x3) >> 3;
- x1 = x4 + x6;
- x4 -= x6;
- x6 = x5 + x7;
- x5 -= x7;
-
- /* third stage */
- x7 = x8 + x3;
- x8 -= x3;
- x3 = x0 + x2;
- x0 -= x2;
- x2 = (181 * (x4 + x5) + 128) >> 8;
- x4 = (181 * (x4 - x5) + 128) >> 8;
-
- /* fourth stage */
- blk[8 * 0] = (x7 + x1 ) >> 14;
- blk[8 * 1] = (x3 + x2 ) >> 14;
- blk[8 * 2] = (x0 + x4 ) >> 14;
- blk[8 * 3] = (x8 + x6 ) >> 14;
- blk[8 * 4] = (x8 - x6 ) >> 14;
- blk[8 * 5] = (x0 - x4 ) >> 14;
- blk[8 * 6] = (x3 - x2 ) >> 14;
- blk[8 * 7] = (x7 - x1 ) >> 14;
+ (x7 = blk[8 * 3]))) {
+ blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3]
+ = blk[8 * 4] = blk[8 * 5] = blk[8 * 6]
+ = blk[8 * 7] = ((blk[8 * 0] + 32) >> 6);
+ return;
+ }
+
+ x0 = (blk[8 * 0] << 8) + 16384;
+
+ /* first stage */
+ x8 = W7 * (x4 + x5) + 4;
+ x4 = (x8 + (W1 - W7) * x4) >> 3;
+ x5 = (x8 - (W1 + W7) * x5) >> 3;
+ x8 = W3 * (x6 + x7) + 4;
+ x6 = (x8 - (W3 - W5) * x6) >> 3;
+ x7 = (x8 - (W3 + W5) * x7) >> 3;
+
+ /* second stage */
+ x8 = x0 + x1;
+ x0 -= x1;
+ x1 = W6 * (x3 + x2) + 4;
+ x2 = (x1 - (W2 + W6) * x2) >> 3;
+ x3 = (x1 + (W2 - W6) * x3) >> 3;
+ x1 = x4 + x6;
+ x4 -= x6;
+ x6 = x5 + x7;
+ x5 -= x7;
+
+ /* third stage */
+ x7 = x8 + x3;
+ x8 -= x3;
+ x3 = x0 + x2;
+ x0 -= x2;
+ x2 = (181 * (x4 + x5) + 128) >> 8;
+ x4 = (181 * (x4 - x5) + 128) >> 8;
+
+ /* fourth stage */
+ blk[8 * 0] = (x7 + x1) >> 14;
+ blk[8 * 1] = (x3 + x2) >> 14;
+ blk[8 * 2] = (x0 + x4) >> 14;
+ blk[8 * 3] = (x8 + x6) >> 14;
+ blk[8 * 4] = (x8 - x6) >> 14;
+ blk[8 * 5] = (x0 - x4) >> 14;
+ blk[8 * 6] = (x3 - x2) >> 14;
+ blk[8 * 7] = (x7 - x1) >> 14;
}
#define TX_DIM 8
-void vp8_short_idct8x8_c(short *coefs, short *block, int pitch)
-{
- int X[TX_DIM*TX_DIM];
- int i,j;
- int shortpitch = pitch >> 1;
-
- for (i = 0; i < TX_DIM; i++)
- {
- for (j = 0; j < TX_DIM; j++)
- {
- X[i * TX_DIM + j] = (int)(coefs[i * TX_DIM + j]+1
- + (coefs[i * TX_DIM + j]<0))>>2;
- }
+void vp8_short_idct8x8_c(short *coefs, short *block, int pitch) {
+ int X[TX_DIM * TX_DIM];
+ int i, j;
+ int shortpitch = pitch >> 1;
+
+ for (i = 0; i < TX_DIM; i++) {
+ for (j = 0; j < TX_DIM; j++) {
+ X[i * TX_DIM + j] = (int)(coefs[i * TX_DIM + j] + 1
+ + (coefs[i * TX_DIM + j] < 0)) >> 2;
}
- for (i = 0; i < 8; i++)
- idctrow (X + 8 * i);
-
- for (i = 0; i < 8; i++)
- idctcol (X + i);
-
- for (i = 0; i < TX_DIM; i++)
- {
- for (j = 0; j < TX_DIM; j++)
- {
- block[i*shortpitch+j] = X[i * TX_DIM + j]>>1;
- }
+ }
+ for (i = 0; i < 8; i++)
+ idctrow(X + 8 * i);
+
+ for (i = 0; i < 8; i++)
+ idctcol(X + i);
+
+ for (i = 0; i < TX_DIM; i++) {
+ for (j = 0; j < TX_DIM; j++) {
+ block[i * shortpitch + j] = X[i * TX_DIM + j] >> 1;
}
+ }
}
-void vp8_short_ihaar2x2_c(short *input, short *output, int pitch)
-{
- int i;
- short *ip = input; //0,1, 4, 8
- short *op = output;
- for (i = 0; i < 16; i++)
- {
- op[i] = 0;
- }
-
- op[0] = (ip[0] + ip[1] + ip[4] + ip[8] + 1)>>1;
- op[1] = (ip[0] - ip[1] + ip[4] - ip[8])>>1;
- op[4] = (ip[0] + ip[1] - ip[4] - ip[8])>>1;
- op[8] = (ip[0] - ip[1] - ip[4] + ip[8])>>1;
+void vp8_short_ihaar2x2_c(short *input, short *output, int pitch) {
+ int i;
+ short *ip = input; // 0,1, 4, 8
+ short *op = output;
+ for (i = 0; i < 16; i++) {
+ op[i] = 0;
+ }
+
+ op[0] = (ip[0] + ip[1] + ip[4] + ip[8] + 1) >> 1;
+ op[1] = (ip[0] - ip[1] + ip[4] - ip[8]) >> 1;
+ op[4] = (ip[0] + ip[1] - ip[4] - ip[8]) >> 1;
+ op[8] = (ip[0] - ip[1] - ip[4] + ip[8]) >> 1;
}
diff --git a/vp8/common/implicit_segmentation.c b/vp8/common/implicit_segmentation.c
index 68bb31cca..24d4ec8b9 100644
--- a/vp8/common/implicit_segmentation.c
+++ b/vp8/common/implicit_segmentation.c
@@ -20,16 +20,15 @@
// this linked list structure holds equivalences for connected
// component labeling
struct list_el {
- int label;
- int seg_value;
- int count;
- struct list_el * next;
+ int label;
+ int seg_value;
+ int count;
+ struct list_el *next;
};
typedef struct list_el item;
// connected colorsegments
-typedef struct
-{
+typedef struct {
int min_x;
int min_y;
int max_x;
@@ -42,8 +41,7 @@ typedef struct
} segment_info;
-typedef enum
-{
+typedef enum {
SEGMENT_MODE,
SEGMENT_MV,
SEGMENT_REFFRAME,
@@ -54,8 +52,7 @@ typedef enum
// this merges the two equivalence lists and
// then makes sure that every label points to the same
// equivalence list
-void merge ( item *labels, int u, int v )
-{
+void merge(item *labels, int u, int v) {
item *a = labels[u].next;
item *b = labels[v].next;
item c;
@@ -63,21 +60,17 @@ void merge ( item *labels, int u, int v )
int count;
// check if they are already merged
- if(u==v || a==b)
+ if (u == v || a == b)
return;
count = a->count + b->count;
// merge 2 sorted linked lists.
- while ( a != NULL && b != NULL )
- {
- if ( a->label < b->label)
- {
+ while (a != NULL && b != NULL) {
+ if (a->label < b->label) {
it->next = a;
a = a->next;
- }
- else
- {
+ } else {
it->next = b;
b = b->next;
}
@@ -85,7 +78,7 @@ void merge ( item *labels, int u, int v )
it = it->next;
}
- if ( a == NULL )
+ if (a == NULL)
it->next = b;
else
it->next = a;
@@ -93,187 +86,169 @@ void merge ( item *labels, int u, int v )
it = c.next;
// make sure every equivalence in the linked list points to this new ll
- while( it != NULL)
- {
+ while (it != NULL) {
labels[it->label].next = c.next;
- it=it->next;
+ it = it->next;
}
c.next->count = count;
}
-void segment_via_mode_info( VP8_COMMON *oci, int how)
-{
- MODE_INFO *mi = oci->mi;
- int i,j;
- int mb_index = 0;
-
- int label=1;
- int pitch = oci->mb_cols;
-
- // holds linked list equivalences
- // the max should probably be allocated at a higher level in oci
- item equivalences[MAX_REGIONS];
- int eq_ptr = 0;
- item labels[MAX_REGIONS];
- segment_info segments[MAX_REGIONS];
- int label_count = 1;
- int labeling[400*300];
- int *lp = labeling;
-
- label_count = 1;
- memset(labels,0,sizeof(labels));
- memset(segments,0,sizeof(segments));
-
- /* Go through each macroblock first pass labelling */
- for (i = 0; i < oci->mb_rows; i++,lp+=pitch)
- {
- for (j = 0; j < oci->mb_cols; j++)
- {
- // int above seg_value, left seg_value, this seg_value...
- int a=-1,l=-1,n=-1;
-
- // above label, left label
- int al=-1,ll=-1;
- if(i)
- {
- al=lp[j-pitch];
- a = labels[al].next->seg_value;
- }
- if(j)
- {
- ll=lp[j-1];
- l = labels[ll].next->seg_value;
- }
-
- // what setting are we going to do the implicit segmentation on
- switch (how)
- {
- case SEGMENT_MODE:
- n= mi[mb_index].mbmi.mode;
- break;
- case SEGMENT_MV:
- n = mi[mb_index].mbmi.mv.as_int;
- if(mi[mb_index].mbmi.ref_frame == INTRA_FRAME)
- n=-9999999;
- break;
- case SEGMENT_REFFRAME:
- n = mi[mb_index].mbmi.ref_frame;
- break;
- case SEGMENT_SKIPPED:
- n = mi[mb_index].mbmi.mb_skip_coeff;
- break;
- }
-
- // above and left both have the same seg_value
- if(n==a&&n==l)
- {
- // pick the lowest label
- lp[j] = (al<ll?al:ll);
- labels[lp[j]].next->count++;
-
- // merge the above and left equivalencies
- merge( labels, al, ll );
- }
- // this matches above seg_value
- else if(n==a)
- {
- // give it the same label as above
- lp[j]=al;
- labels[al].next->count++;
- }
- // this matches left seg_value
- else if(n==l)
- {
- // give it the same label as above
- lp[j]=ll;
- labels[ll].next->count++;
- }
- else
- {
- // new label doesn't match either
- item *e = &labels[label];
- item *nl = &equivalences[eq_ptr++];
- lp[j]=label;
- nl->label = label;
- nl->next = 0;
- nl->seg_value = n;
- nl->count = 1;
- e->next = nl;
- label++;
- }
- mb_index++;
+void segment_via_mode_info(VP8_COMMON *oci, int how) {
+ MODE_INFO *mi = oci->mi;
+ int i, j;
+ int mb_index = 0;
+
+ int label = 1;
+ int pitch = oci->mb_cols;
+
+ // holds linked list equivalences
+ // the max should probably be allocated at a higher level in oci
+ item equivalences[MAX_REGIONS];
+ int eq_ptr = 0;
+ item labels[MAX_REGIONS];
+ segment_info segments[MAX_REGIONS];
+ int label_count = 1;
+ int labeling[400 * 300];
+ int *lp = labeling;
+
+ label_count = 1;
+ memset(labels, 0, sizeof(labels));
+ memset(segments, 0, sizeof(segments));
+
+ /* Go through each macroblock first pass labelling */
+ for (i = 0; i < oci->mb_rows; i++, lp += pitch) {
+ for (j = 0; j < oci->mb_cols; j++) {
+ // int above seg_value, left seg_value, this seg_value...
+ int a = -1, l = -1, n = -1;
+
+ // above label, left label
+ int al = -1, ll = -1;
+ if (i) {
+ al = lp[j - pitch];
+ a = labels[al].next->seg_value;
+ }
+ if (j) {
+ ll = lp[j - 1];
+ l = labels[ll].next->seg_value;
}
- mb_index++;
- }
- lp = labeling;
-
- // give new labels to regions
- for(i=1;i<label;i++)
- if(labels[i].next->count >min_mbs_in_region && labels[labels[i].next->label].label == 0 )
- {
- segment_info *cs= &segments[label_count];
- cs->label = label_count;
- labels[labels[i].next->label].label = label_count++;
- labels[labels[i].next->label].seg_value = labels[i].next->seg_value;
- cs->seg_value = labels[labels[i].next->label].seg_value;
- cs->min_x = oci->mb_cols;
- cs->min_y = oci->mb_rows;
- cs->max_x = 0;
- cs->max_y = 0;
- cs->sum_x = 0;
- cs->sum_y = 0;
- cs->pixels= 0;
+ // what setting are we going to do the implicit segmentation on
+ switch (how) {
+ case SEGMENT_MODE:
+ n = mi[mb_index].mbmi.mode;
+ break;
+ case SEGMENT_MV:
+ n = mi[mb_index].mbmi.mv.as_int;
+ if (mi[mb_index].mbmi.ref_frame == INTRA_FRAME)
+ n = -9999999;
+ break;
+ case SEGMENT_REFFRAME:
+ n = mi[mb_index].mbmi.ref_frame;
+ break;
+ case SEGMENT_SKIPPED:
+ n = mi[mb_index].mbmi.mb_skip_coeff;
+ break;
}
- lp = labeling;
- // this is just to gather stats...
- for(i=0;i<oci->mb_rows;i++,lp+=pitch)
- {
- for(j=0;j<oci->mb_cols;j++)
- {
- segment_info *cs;
- int oldlab = labels[lp[j]].next->label;
- int lab = labels[oldlab].label;
- lp[j] = lab;
-
- cs= &segments[lab];
-
- cs->min_x = (j<cs->min_x?j:cs->min_x);
- cs->max_x = (j>cs->max_x?j:cs->max_x);
- cs->min_y = (i<cs->min_y?i:cs->min_y);
- cs->max_y = (i>cs->max_y?i:cs->max_y);
- cs->sum_x += j;
- cs->sum_y += i;
- cs->pixels ++;
-
- lp[j] = lab;
- mb_index++;
+ // above and left both have the same seg_value
+ if (n == a && n == l) {
+ // pick the lowest label
+ lp[j] = (al < ll ? al : ll);
+ labels[lp[j]].next->count++;
+
+ // merge the above and left equivalencies
+ merge(labels, al, ll);
+ }
+ // this matches above seg_value
+ else if (n == a) {
+ // give it the same label as above
+ lp[j] = al;
+ labels[al].next->count++;
+ }
+ // this matches left seg_value
+ else if (n == l) {
+ // give it the same label as above
+ lp[j] = ll;
+ labels[ll].next->count++;
+ } else {
+ // new label doesn't match either
+ item *e = &labels[label];
+ item *nl = &equivalences[eq_ptr++];
+ lp[j] = label;
+ nl->label = label;
+ nl->next = 0;
+ nl->seg_value = n;
+ nl->count = 1;
+ e->next = nl;
+ label++;
}
mb_index++;
}
+ mb_index++;
+ }
+ lp = labeling;
+
+ // give new labels to regions
+ for (i = 1; i < label; i++)
+ if (labels[i].next->count > min_mbs_in_region && labels[labels[i].next->label].label == 0) {
+ segment_info *cs = &segments[label_count];
+ cs->label = label_count;
+ labels[labels[i].next->label].label = label_count++;
+ labels[labels[i].next->label].seg_value = labels[i].next->seg_value;
+ cs->seg_value = labels[labels[i].next->label].seg_value;
+ cs->min_x = oci->mb_cols;
+ cs->min_y = oci->mb_rows;
+ cs->max_x = 0;
+ cs->max_y = 0;
+ cs->sum_x = 0;
+ cs->sum_y = 0;
+ cs->pixels = 0;
- {
- lp = labeling;
- printf("labelling \n");
- mb_index = 0;
- for(i=0;i<oci->mb_rows;i++,lp+=pitch)
- {
- for(j=0;j<oci->mb_cols;j++)
- {
- printf("%4d",lp[j]);
- }
- printf(" ");
- for(j=0;j<oci->mb_cols;j++,mb_index++)
- {
- //printf("%3d",mi[mb_index].mbmi.mode );
- printf("%4d:%4d",mi[mb_index].mbmi.mv.as_mv.row,mi[mb_index].mbmi.mv.as_mv.col );
- }
- printf("\n");
- ++mb_index;
+ }
+ lp = labeling;
+
+ // this is just to gather stats...
+ for (i = 0; i < oci->mb_rows; i++, lp += pitch) {
+ for (j = 0; j < oci->mb_cols; j++) {
+ segment_info *cs;
+ int oldlab = labels[lp[j]].next->label;
+ int lab = labels[oldlab].label;
+ lp[j] = lab;
+
+ cs = &segments[lab];
+
+ cs->min_x = (j < cs->min_x ? j : cs->min_x);
+ cs->max_x = (j > cs->max_x ? j : cs->max_x);
+ cs->min_y = (i < cs->min_y ? i : cs->min_y);
+ cs->max_y = (i > cs->max_y ? i : cs->max_y);
+ cs->sum_x += j;
+ cs->sum_y += i;
+ cs->pixels++;
+
+ lp[j] = lab;
+ mb_index++;
+ }
+ mb_index++;
+ }
+
+ {
+ lp = labeling;
+ printf("labelling \n");
+ mb_index = 0;
+ for (i = 0; i < oci->mb_rows; i++, lp += pitch) {
+ for (j = 0; j < oci->mb_cols; j++) {
+ printf("%4d", lp[j]);
+ }
+ printf(" ");
+ for (j = 0; j < oci->mb_cols; j++, mb_index++) {
+ // printf("%3d",mi[mb_index].mbmi.mode );
+ printf("%4d:%4d", mi[mb_index].mbmi.mv.as_mv.row, mi[mb_index].mbmi.mv.as_mv.col);
}
printf("\n");
+ ++mb_index;
}
+ printf("\n");
+ }
}
diff --git a/vp8/common/invtrans.c b/vp8/common/invtrans.c
index eed8363a3..aea453648 100644
--- a/vp8/common/invtrans.c
+++ b/vp8/common/invtrans.c
@@ -13,161 +13,138 @@
-static void recon_dcblock(MACROBLOCKD *x)
-{
- BLOCKD *b = &x->block[24];
- int i;
+static void recon_dcblock(MACROBLOCKD *x) {
+ BLOCKD *b = &x->block[24];
+ int i;
- for (i = 0; i < 16; i++)
- {
- x->block[i].dqcoeff[0] = b->diff[i];
- }
+ for (i = 0; i < 16; i++) {
+ x->block[i].dqcoeff[0] = b->diff[i];
+ }
}
-static void recon_dcblock_8x8(MACROBLOCKD *x)
-{
- BLOCKD *b = &x->block[24]; //for coeff 0, 2, 8, 10
- x->block[0].dqcoeff[0] = b->diff[0];
- x->block[4].dqcoeff[0] = b->diff[1];
- x->block[8].dqcoeff[0] = b->diff[4];
- x->block[12].dqcoeff[0] = b->diff[8];
+static void recon_dcblock_8x8(MACROBLOCKD *x) {
+ BLOCKD *b = &x->block[24]; // for coeff 0, 2, 8, 10
+ x->block[0].dqcoeff[0] = b->diff[0];
+ x->block[4].dqcoeff[0] = b->diff[1];
+ x->block[8].dqcoeff[0] = b->diff[4];
+ x->block[12].dqcoeff[0] = b->diff[8];
}
-void vp8_inverse_transform_b(const vp8_idct_rtcd_vtable_t *rtcd, BLOCKD *b, int pitch)
-{
- if (b->eob <= 1)
- IDCT_INVOKE(rtcd, idct1)(b->dqcoeff, b->diff, pitch);
- else
- IDCT_INVOKE(rtcd, idct16)(b->dqcoeff, b->diff, pitch);
+void vp8_inverse_transform_b(const vp8_idct_rtcd_vtable_t *rtcd, BLOCKD *b, int pitch) {
+ if (b->eob <= 1)
+ IDCT_INVOKE(rtcd, idct1)(b->dqcoeff, b->diff, pitch);
+ else
+ IDCT_INVOKE(rtcd, idct16)(b->dqcoeff, b->diff, pitch);
}
-void vp8_inverse_transform_mby(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mby(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- /* do 2nd order transform on the dc block */
- IDCT_INVOKE(rtcd, iwalsh16)(x->block[24].dqcoeff, x->block[24].diff);
+ /* do 2nd order transform on the dc block */
+ IDCT_INVOKE(rtcd, iwalsh16)(x->block[24].dqcoeff, x->block[24].diff);
- recon_dcblock(x);
+ recon_dcblock(x);
- for (i = 0; i < 16; i++)
- {
- vp8_inverse_transform_b(rtcd, &x->block[i], 32);
- }
+ for (i = 0; i < 16; i++) {
+ vp8_inverse_transform_b(rtcd, &x->block[i], 32);
+ }
}
-void vp8_inverse_transform_mbuv(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mbuv(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- for (i = 16; i < 24; i++)
- {
- vp8_inverse_transform_b(rtcd, &x->block[i], 16);
- }
+ for (i = 16; i < 24; i++) {
+ vp8_inverse_transform_b(rtcd, &x->block[i], 16);
+ }
}
-void vp8_inverse_transform_mb(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mb(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- if (x->mode_info_context->mbmi.mode != B_PRED &&
- x->mode_info_context->mbmi.mode != I8X8_PRED &&
- x->mode_info_context->mbmi.mode != SPLITMV)
- {
- /* do 2nd order transform on the dc block */
+ if (x->mode_info_context->mbmi.mode != B_PRED &&
+ x->mode_info_context->mbmi.mode != I8X8_PRED &&
+ x->mode_info_context->mbmi.mode != SPLITMV) {
+ /* do 2nd order transform on the dc block */
- IDCT_INVOKE(rtcd, iwalsh16)(&x->block[24].dqcoeff[0], x->block[24].diff);
- recon_dcblock(x);
- }
+ IDCT_INVOKE(rtcd, iwalsh16)(&x->block[24].dqcoeff[0], x->block[24].diff);
+ recon_dcblock(x);
+ }
- for (i = 0; i < 16; i++)
- {
- vp8_inverse_transform_b(rtcd, &x->block[i], 32);
- }
+ for (i = 0; i < 16; i++) {
+ vp8_inverse_transform_b(rtcd, &x->block[i], 32);
+ }
- for (i = 16; i < 24; i++)
- {
- vp8_inverse_transform_b(rtcd, &x->block[i], 16);
- }
+ for (i = 16; i < 24; i++) {
+ vp8_inverse_transform_b(rtcd, &x->block[i], 16);
+ }
}
-void vp8_inverse_transform_b_8x8(const vp8_idct_rtcd_vtable_t *rtcd, short *input_dqcoeff, short *output_coeff, int pitch)//pay attention to use when 8x8
-{
- // int b,i;
- //if (b->eob > 1)
- IDCT_INVOKE(rtcd, idct8)(input_dqcoeff, output_coeff, pitch);
- //else
- //IDCT_INVOKE(rtcd, idct8_1)(b->dqcoeff, b->diff, pitch);//pitch
+void vp8_inverse_transform_b_8x8(const vp8_idct_rtcd_vtable_t *rtcd, short *input_dqcoeff, short *output_coeff, int pitch) { // pay attention to use when 8x8
+ // int b,i;
+ // if (b->eob > 1)
+ IDCT_INVOKE(rtcd, idct8)(input_dqcoeff, output_coeff, pitch);
+ // else
+ // IDCT_INVOKE(rtcd, idct8_1)(b->dqcoeff, b->diff, pitch);//pitch
}
-void vp8_inverse_transform_mby_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mby_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- // do 2nd order transform on the dc block
- IDCT_INVOKE(rtcd, ihaar2)(x->block[24].dqcoeff, x->block[24].diff, 8);
-
- recon_dcblock_8x8(x); //need to change for 8x8
- for (i = 0; i < 9; i += 8)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 32);
- }
- for (i = 2; i < 11; i += 8)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i+2].dqcoeff[0], &x->block[i].diff[0], 32);
- }
+ // do 2nd order transform on the dc block
+ IDCT_INVOKE(rtcd, ihaar2)(x->block[24].dqcoeff, x->block[24].diff, 8);
+
+ recon_dcblock_8x8(x); // need to change for 8x8
+ for (i = 0; i < 9; i += 8) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 32);
+ }
+ for (i = 2; i < 11; i += 8) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i + 2].dqcoeff[0], &x->block[i].diff[0], 32);
+ }
}
-void vp8_inverse_transform_mbuv_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mbuv_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- for (i = 16; i < 24; i += 4)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 16);
- }
+ for (i = 16; i < 24; i += 4) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 16);
+ }
}
-void vp8_inverse_transform_mb_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_inverse_transform_mb_8x8(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- if (x->mode_info_context->mbmi.mode != B_PRED &&
- x->mode_info_context->mbmi.mode != SPLITMV)
- {
- // do 2nd order transform on the dc block
+ if (x->mode_info_context->mbmi.mode != B_PRED &&
+ x->mode_info_context->mbmi.mode != SPLITMV) {
+ // do 2nd order transform on the dc block
- IDCT_INVOKE(rtcd, ihaar2)(&x->block[24].dqcoeff[0], x->block[24].diff, 8);//dqcoeff[0]
- recon_dcblock_8x8(x); //need to change for 8x8
+ IDCT_INVOKE(rtcd, ihaar2)(&x->block[24].dqcoeff[0], x->block[24].diff, 8);// dqcoeff[0]
+ recon_dcblock_8x8(x); // need to change for 8x8
- }
+ }
- for (i = 0; i < 9; i += 8)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 32);
- }
- for (i = 2; i < 11; i += 8)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i+2].dqcoeff[0], &x->block[i].diff[0], 32);
- }
+ for (i = 0; i < 9; i += 8) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 32);
+ }
+ for (i = 2; i < 11; i += 8) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i + 2].dqcoeff[0], &x->block[i].diff[0], 32);
+ }
- for (i = 16; i < 24; i += 4)
- {
- vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 16);
- }
+ for (i = 16; i < 24; i += 4) {
+ vp8_inverse_transform_b_8x8(rtcd, &x->block[i].dqcoeff[0], &x->block[i].diff[0], 16);
+ }
}
diff --git a/vp8/common/loopfilter.c b/vp8/common/loopfilter.c
index 6f57d49b4..70565ee68 100644
--- a/vp8/common/loopfilter.c
+++ b/vp8/common/loopfilter.c
@@ -31,776 +31,709 @@ prototype_simple_loopfilter(vp8_loop_filter_simple_vertical_edge_c);
/* Horizontal MB filtering */
void vp8_loop_filter_mbh_c(unsigned char *y_ptr, unsigned char *u_ptr,
unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ loop_filter_info *lfi) {
+ vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Vertical MB Filtering */
void vp8_loop_filter_mbv_c(unsigned char *y_ptr, unsigned char *u_ptr,
unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ loop_filter_info *lfi) {
+ vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Horizontal B Filtering */
void vp8_loop_filter_bh_c(unsigned char *y_ptr, unsigned char *u_ptr,
unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ loop_filter_info *lfi) {
+ vp8_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
void vp8_loop_filter_bh8x8_c(unsigned char *y_ptr, unsigned char *u_ptr,
- unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_mbloop_filter_horizontal_edge_c(
- y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ unsigned char *v_ptr, int y_stride, int uv_stride,
+ loop_filter_info *lfi) {
+ vp8_mbloop_filter_horizontal_edge_c(
+ y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
}
void vp8_loop_filter_bhs_c(unsigned char *y_ptr, int y_stride,
- const unsigned char *blimit)
-{
- vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, blimit);
+ const unsigned char *blimit) {
+ vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, blimit);
}
/* Vertical B Filtering */
void vp8_loop_filter_bv_c(unsigned char *y_ptr, unsigned char *u_ptr,
unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_loop_filter_vertical_edge_c(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_c(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ loop_filter_info *lfi) {
+ vp8_loop_filter_vertical_edge_c(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_c(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
void vp8_loop_filter_bv8x8_c(unsigned char *y_ptr, unsigned char *u_ptr,
- unsigned char *v_ptr, int y_stride, int uv_stride,
- loop_filter_info *lfi)
-{
- vp8_mbloop_filter_vertical_edge_c(
- y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ unsigned char *v_ptr, int y_stride, int uv_stride,
+ loop_filter_info *lfi) {
+ vp8_mbloop_filter_vertical_edge_c(
+ y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
}
void vp8_loop_filter_bvs_c(unsigned char *y_ptr, int y_stride,
- const unsigned char *blimit)
-{
- vp8_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, blimit);
+ const unsigned char *blimit) {
+ vp8_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, blimit);
}
-static void lf_init_lut(loop_filter_info_n *lfi)
-{
- int filt_lvl;
-
- for (filt_lvl = 0; filt_lvl <= MAX_LOOP_FILTER; filt_lvl++)
- {
- if (filt_lvl >= 40)
- {
- lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 2;
- lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 3;
- }
- else if (filt_lvl >= 20)
- {
- lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
- lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 2;
- }
- else if (filt_lvl >= 15)
- {
- lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
- lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 1;
- }
- else
- {
- lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 0;
- lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 0;
- }
+static void lf_init_lut(loop_filter_info_n *lfi) {
+ int filt_lvl;
+
+ for (filt_lvl = 0; filt_lvl <= MAX_LOOP_FILTER; filt_lvl++) {
+ if (filt_lvl >= 40) {
+ lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 2;
+ lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 3;
+ } else if (filt_lvl >= 20) {
+ lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
+ lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 2;
+ } else if (filt_lvl >= 15) {
+ lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
+ lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 1;
+ } else {
+ lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 0;
+ lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 0;
}
+ }
- lfi->mode_lf_lut[DC_PRED] = 1;
+ lfi->mode_lf_lut[DC_PRED] = 1;
#if CONFIG_NEWINTRAMODES
- lfi->mode_lf_lut[D45_PRED] = 1;
- lfi->mode_lf_lut[D135_PRED] = 1;
- lfi->mode_lf_lut[D117_PRED] = 1;
- lfi->mode_lf_lut[D153_PRED] = 1;
- lfi->mode_lf_lut[D27_PRED] = 1;
- lfi->mode_lf_lut[D63_PRED] = 1;
+ lfi->mode_lf_lut[D45_PRED] = 1;
+ lfi->mode_lf_lut[D135_PRED] = 1;
+ lfi->mode_lf_lut[D117_PRED] = 1;
+ lfi->mode_lf_lut[D153_PRED] = 1;
+ lfi->mode_lf_lut[D27_PRED] = 1;
+ lfi->mode_lf_lut[D63_PRED] = 1;
#endif
- lfi->mode_lf_lut[V_PRED] = 1;
- lfi->mode_lf_lut[H_PRED] = 1;
- lfi->mode_lf_lut[TM_PRED] = 1;
- lfi->mode_lf_lut[B_PRED] = 0;
- lfi->mode_lf_lut[I8X8_PRED]=0;
- lfi->mode_lf_lut[ZEROMV] = 1;
- lfi->mode_lf_lut[NEARESTMV] = 2;
- lfi->mode_lf_lut[NEARMV] = 2;
- lfi->mode_lf_lut[NEWMV] = 2;
- lfi->mode_lf_lut[SPLITMV] = 3;
+ lfi->mode_lf_lut[V_PRED] = 1;
+ lfi->mode_lf_lut[H_PRED] = 1;
+ lfi->mode_lf_lut[TM_PRED] = 1;
+ lfi->mode_lf_lut[B_PRED] = 0;
+ lfi->mode_lf_lut[I8X8_PRED] = 0;
+ lfi->mode_lf_lut[ZEROMV] = 1;
+ lfi->mode_lf_lut[NEARESTMV] = 2;
+ lfi->mode_lf_lut[NEARMV] = 2;
+ lfi->mode_lf_lut[NEWMV] = 2;
+ lfi->mode_lf_lut[SPLITMV] = 3;
}
void vp8_loop_filter_update_sharpness(loop_filter_info_n *lfi,
- int sharpness_lvl)
-{
- int i;
-
- /* For each possible value for the loop filter fill out limits */
- for (i = 0; i <= MAX_LOOP_FILTER; i++)
- {
- int filt_lvl = i;
- int block_inside_limit = 0;
-
- /* Set loop filter paramaeters that control sharpness. */
- block_inside_limit = filt_lvl >> (sharpness_lvl > 0);
- block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
-
- if (sharpness_lvl > 0)
- {
- if (block_inside_limit > (9 - sharpness_lvl))
- block_inside_limit = (9 - sharpness_lvl);
- }
+ int sharpness_lvl) {
+ int i;
+
+ /* For each possible value for the loop filter fill out limits */
+ for (i = 0; i <= MAX_LOOP_FILTER; i++) {
+ int filt_lvl = i;
+ int block_inside_limit = 0;
- if (block_inside_limit < 1)
- block_inside_limit = 1;
+ /* Set loop filter paramaeters that control sharpness. */
+ block_inside_limit = filt_lvl >> (sharpness_lvl > 0);
+ block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
- vpx_memset(lfi->lim[i], block_inside_limit, SIMD_WIDTH);
- vpx_memset(lfi->blim[i], (2 * filt_lvl + block_inside_limit),
- SIMD_WIDTH);
- vpx_memset(lfi->mblim[i], (2 * (filt_lvl + 2) + block_inside_limit),
- SIMD_WIDTH);
+ if (sharpness_lvl > 0) {
+ if (block_inside_limit > (9 - sharpness_lvl))
+ block_inside_limit = (9 - sharpness_lvl);
}
+
+ if (block_inside_limit < 1)
+ block_inside_limit = 1;
+
+ vpx_memset(lfi->lim[i], block_inside_limit, SIMD_WIDTH);
+ vpx_memset(lfi->blim[i], (2 * filt_lvl + block_inside_limit),
+ SIMD_WIDTH);
+ vpx_memset(lfi->mblim[i], (2 * (filt_lvl + 2) + block_inside_limit),
+ SIMD_WIDTH);
+ }
}
-void vp8_loop_filter_init(VP8_COMMON *cm)
-{
- loop_filter_info_n *lfi = &cm->lf_info;
- int i;
+void vp8_loop_filter_init(VP8_COMMON *cm) {
+ loop_filter_info_n *lfi = &cm->lf_info;
+ int i;
- /* init limits for given sharpness*/
- vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
- cm->last_sharpness_level = cm->sharpness_level;
+ /* init limits for given sharpness*/
+ vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
+ cm->last_sharpness_level = cm->sharpness_level;
- /* init LUT for lvl and hev thr picking */
- lf_init_lut(lfi);
+ /* init LUT for lvl and hev thr picking */
+ lf_init_lut(lfi);
- /* init hev threshold const vectors */
- for(i = 0; i < 4 ; i++)
- {
- vpx_memset(lfi->hev_thr[i], i, SIMD_WIDTH);
- }
+ /* init hev threshold const vectors */
+ for (i = 0; i < 4; i++) {
+ vpx_memset(lfi->hev_thr[i], i, SIMD_WIDTH);
+ }
}
void vp8_loop_filter_frame_init(VP8_COMMON *cm,
MACROBLOCKD *xd,
- int default_filt_lvl)
-{
- int seg, /* segment number */
- ref, /* index in ref_lf_deltas */
- mode; /* index in mode_lf_deltas */
-
- loop_filter_info_n *lfi = &cm->lf_info;
-
- /* update limits if sharpness has changed */
- if(cm->last_sharpness_level != cm->sharpness_level)
- {
- vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
- cm->last_sharpness_level = cm->sharpness_level;
- }
+ int default_filt_lvl) {
+ int seg, /* segment number */
+ ref, /* index in ref_lf_deltas */
+ mode; /* index in mode_lf_deltas */
- for(seg = 0; seg < MAX_MB_SEGMENTS; seg++)
- {
- int lvl_seg = default_filt_lvl;
- int lvl_ref, lvl_mode;
-
-
- // Set the baseline filter values for each segment
- if ( segfeature_active( xd, seg, SEG_LVL_ALT_LF ) )
- {
- /* Abs value */
- if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
- {
- lvl_seg = get_segdata( xd, seg, SEG_LVL_ALT_LF );
- }
- else /* Delta Value */
- {
- lvl_seg += get_segdata( xd, seg, SEG_LVL_ALT_LF );;
- lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
- }
- }
+ loop_filter_info_n *lfi = &cm->lf_info;
- if (!xd->mode_ref_lf_delta_enabled)
- {
- /* we could get rid of this if we assume that deltas are set to
- * zero when not in use; encoder always uses deltas
- */
- vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4 );
- continue;
- }
+ /* update limits if sharpness has changed */
+ if (cm->last_sharpness_level != cm->sharpness_level) {
+ vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
+ cm->last_sharpness_level = cm->sharpness_level;
+ }
+
+ for (seg = 0; seg < MAX_MB_SEGMENTS; seg++) {
+ int lvl_seg = default_filt_lvl;
+ int lvl_ref, lvl_mode;
+
+
+ // Set the baseline filter values for each segment
+ if (segfeature_active(xd, seg, SEG_LVL_ALT_LF)) {
+ /* Abs value */
+ if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
+ lvl_seg = get_segdata(xd, seg, SEG_LVL_ALT_LF);
+ } else { /* Delta Value */
+ lvl_seg += get_segdata(xd, seg, SEG_LVL_ALT_LF);;
+ lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63 : lvl_seg) : 0;
+ }
+ }
- lvl_ref = lvl_seg;
+ if (!xd->mode_ref_lf_delta_enabled) {
+ /* we could get rid of this if we assume that deltas are set to
+ * zero when not in use; encoder always uses deltas
+ */
+ vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4);
+ continue;
+ }
- /* INTRA_FRAME */
- ref = INTRA_FRAME;
+ lvl_ref = lvl_seg;
- /* Apply delta for reference frame */
- lvl_ref += xd->ref_lf_deltas[ref];
+ /* INTRA_FRAME */
+ ref = INTRA_FRAME;
- /* Apply delta for Intra modes */
- mode = 0; /* B_PRED */
- /* Only the split mode BPRED has a further special case */
- lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
- lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
+ /* Apply delta for reference frame */
+ lvl_ref += xd->ref_lf_deltas[ref];
- lfi->lvl[seg][ref][mode] = lvl_mode;
+ /* Apply delta for Intra modes */
+ mode = 0; /* B_PRED */
+ /* Only the split mode BPRED has a further special case */
+ lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
+ lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
- mode = 1; /* all the rest of Intra modes */
- lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref) : 0; /* clamp */
- lfi->lvl[seg][ref][mode] = lvl_mode;
+ lfi->lvl[seg][ref][mode] = lvl_mode;
- /* LAST, GOLDEN, ALT */
- for(ref = 1; ref < MAX_REF_FRAMES; ref++)
- {
- int lvl_ref = lvl_seg;
+ mode = 1; /* all the rest of Intra modes */
+ lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref) : 0; /* clamp */
+ lfi->lvl[seg][ref][mode] = lvl_mode;
- /* Apply delta for reference frame */
- lvl_ref += xd->ref_lf_deltas[ref];
+ /* LAST, GOLDEN, ALT */
+ for (ref = 1; ref < MAX_REF_FRAMES; ref++) {
+ int lvl_ref = lvl_seg;
- /* Apply delta for Inter modes */
- for (mode = 1; mode < 4; mode++)
- {
- lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
- lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
+ /* Apply delta for reference frame */
+ lvl_ref += xd->ref_lf_deltas[ref];
- lfi->lvl[seg][ref][mode] = lvl_mode;
- }
- }
+ /* Apply delta for Inter modes */
+ for (mode = 1; mode < 4; mode++) {
+ lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
+ lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
+
+ lfi->lvl[seg][ref][mode] = lvl_mode;
+ }
}
+ }
}
void vp8_loop_filter_frame
(
- VP8_COMMON *cm,
- MACROBLOCKD *xd
-)
-{
- YV12_BUFFER_CONFIG *post = cm->frame_to_show;
- loop_filter_info_n *lfi_n = &cm->lf_info;
- loop_filter_info lfi;
-
- FRAME_TYPE frame_type = cm->frame_type;
-
- int mb_row;
- int mb_col;
-
- int filter_level;
-
- unsigned char *y_ptr, *u_ptr, *v_ptr;
-
- /* Point at base of Mb MODE_INFO list */
- const MODE_INFO *mode_info_context = cm->mi;
-
- /* Initialize the loop filter for this frame. */
- vp8_loop_filter_frame_init(cm, xd, cm->filter_level);
-
- /* Set up the buffer pointers */
- y_ptr = post->y_buffer;
- u_ptr = post->u_buffer;
- v_ptr = post->v_buffer;
-
- /* vp8_filter each macro block */
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
- mode_info_context->mbmi.mode != I8X8_PRED &&
- mode_info_context->mbmi.mode != SPLITMV &&
- mode_info_context->mbmi.mb_skip_coeff);
-
- const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
- const int seg = mode_info_context->mbmi.segment_id;
- const int ref_frame = mode_info_context->mbmi.ref_frame;
- int tx_type = mode_info_context->mbmi.txfm_size;
- filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
-
- if (filter_level)
- {
- if (cm->filter_type == NORMAL_LOOPFILTER)
- {
- const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
- lfi.mblim = lfi_n->mblim[filter_level];
- lfi.blim = lfi_n->blim[filter_level];
- lfi.lim = lfi_n->lim[filter_level];
- lfi.hev_thr = lfi_n->hev_thr[hev_index];
-
- if (mb_col > 0)
- vp8_loop_filter_mbv_c
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
-
- if (!skip_lf)
- {
- if(tx_type == TX_8X8)
- vp8_loop_filter_bv8x8_c
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
- else
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
-
- }
-
- /* don't apply across umv border */
- if (mb_row > 0)
- vp8_loop_filter_mbh_c
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
-
- if (!skip_lf)
- {
- if(tx_type == TX_8X8)
- vp8_loop_filter_bh8x8_c
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
- else
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
- (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
- }
- }
- else
- {
- if (mb_col > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
- }
- }
-
- y_ptr += 16;
- u_ptr += 8;
- v_ptr += 8;
-
- mode_info_context++; /* step to next MB */
+ VP8_COMMON *cm,
+ MACROBLOCKD *xd
+) {
+ YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+ loop_filter_info_n *lfi_n = &cm->lf_info;
+ loop_filter_info lfi;
+
+ FRAME_TYPE frame_type = cm->frame_type;
+
+ int mb_row;
+ int mb_col;
+
+ int filter_level;
+
+ unsigned char *y_ptr, *u_ptr, *v_ptr;
+
+ /* Point at base of Mb MODE_INFO list */
+ const MODE_INFO *mode_info_context = cm->mi;
+
+ /* Initialize the loop filter for this frame. */
+ vp8_loop_filter_frame_init(cm, xd, cm->filter_level);
+
+ /* Set up the buffer pointers */
+ y_ptr = post->y_buffer;
+ u_ptr = post->u_buffer;
+ v_ptr = post->v_buffer;
+
+ /* vp8_filter each macro block */
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+ mode_info_context->mbmi.mode != SPLITMV &&
+ mode_info_context->mbmi.mb_skip_coeff);
+
+ const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
+ const int seg = mode_info_context->mbmi.segment_id;
+ const int ref_frame = mode_info_context->mbmi.ref_frame;
+ int tx_type = mode_info_context->mbmi.txfm_size;
+ filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
+
+ if (filter_level) {
+ if (cm->filter_type == NORMAL_LOOPFILTER) {
+ const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
+ lfi.mblim = lfi_n->mblim[filter_level];
+ lfi.blim = lfi_n->blim[filter_level];
+ lfi.lim = lfi_n->lim[filter_level];
+ lfi.hev_thr = lfi_n->hev_thr[hev_index];
+
+ if (mb_col > 0)
+ vp8_loop_filter_mbv_c
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+
+ if (!skip_lf) {
+ if (tx_type == TX_8X8)
+ vp8_loop_filter_bv8x8_c
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+ else
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+
+ }
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ vp8_loop_filter_mbh_c
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+
+ if (!skip_lf) {
+ if (tx_type == TX_8X8)
+ vp8_loop_filter_bh8x8_c
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+ else
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
+ (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
+ }
+ } else {
+ if (mb_col > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
}
+ }
- y_ptr += post->y_stride * 16 - post->y_width;
- u_ptr += post->uv_stride * 8 - post->uv_width;
- v_ptr += post->uv_stride * 8 - post->uv_width;
+ y_ptr += 16;
+ u_ptr += 8;
+ v_ptr += 8;
- mode_info_context++; /* Skip border mb */
+ mode_info_context++; /* step to next MB */
}
+
+ y_ptr += post->y_stride * 16 - post->y_width;
+ u_ptr += post->uv_stride * 8 - post->uv_width;
+ v_ptr += post->uv_stride * 8 - post->uv_width;
+
+ mode_info_context++; /* Skip border mb */
+ }
}
void vp8_loop_filter_frame_yonly
(
- VP8_COMMON *cm,
- MACROBLOCKD *xd,
- int default_filt_lvl
-)
-{
- YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+ VP8_COMMON *cm,
+ MACROBLOCKD *xd,
+ int default_filt_lvl
+) {
+ YV12_BUFFER_CONFIG *post = cm->frame_to_show;
- unsigned char *y_ptr;
- int mb_row;
- int mb_col;
+ unsigned char *y_ptr;
+ int mb_row;
+ int mb_col;
- loop_filter_info_n *lfi_n = &cm->lf_info;
- loop_filter_info lfi;
+ loop_filter_info_n *lfi_n = &cm->lf_info;
+ loop_filter_info lfi;
- int filter_level;
- FRAME_TYPE frame_type = cm->frame_type;
+ int filter_level;
+ FRAME_TYPE frame_type = cm->frame_type;
- /* Point at base of Mb MODE_INFO list */
- const MODE_INFO *mode_info_context = cm->mi;
+ /* Point at base of Mb MODE_INFO list */
+ const MODE_INFO *mode_info_context = cm->mi;
#if 0
- if(default_filt_lvl == 0) /* no filter applied */
- return;
+ if (default_filt_lvl == 0) /* no filter applied */
+ return;
#endif
- /* Initialize the loop filter for this frame. */
- vp8_loop_filter_frame_init( cm, xd, default_filt_lvl);
-
- /* Set up the buffer pointers */
- y_ptr = post->y_buffer;
-
- /* vp8_filter each macro block */
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
- mode_info_context->mbmi.mode != I8X8_PRED &&
- mode_info_context->mbmi.mode != SPLITMV &&
- mode_info_context->mbmi.mb_skip_coeff);
-
- const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
- const int seg = mode_info_context->mbmi.segment_id;
- const int ref_frame = mode_info_context->mbmi.ref_frame;
- int tx_type = mode_info_context->mbmi.txfm_size;
-
- filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
-
- if (filter_level)
- {
- if (cm->filter_type == NORMAL_LOOPFILTER)
- {
- const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
- lfi.mblim = lfi_n->mblim[filter_level];
- lfi.blim = lfi_n->blim[filter_level];
- lfi.lim = lfi_n->lim[filter_level];
- lfi.hev_thr = lfi_n->hev_thr[hev_index];
-
- if (mb_col > 0)
- vp8_loop_filter_mbv_c
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- if (!skip_lf)
- {
- if(tx_type == TX_8X8)
- vp8_loop_filter_bv8x8_c
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
- else
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
- }
-
- /* don't apply across umv border */
- if (mb_row > 0)
- vp8_loop_filter_mbh_c
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- if (!skip_lf)
- {
- if(tx_type == TX_8X8)
- vp8_loop_filter_bh8x8_c
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
- else
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
- }
- }
- else
- {
- if (mb_col > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
- }
- }
-
- y_ptr += 16;
- mode_info_context ++; /* step to next MB */
-
+ /* Initialize the loop filter for this frame. */
+ vp8_loop_filter_frame_init(cm, xd, default_filt_lvl);
+
+ /* Set up the buffer pointers */
+ y_ptr = post->y_buffer;
+
+ /* vp8_filter each macro block */
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+ mode_info_context->mbmi.mode != SPLITMV &&
+ mode_info_context->mbmi.mb_skip_coeff);
+
+ const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
+ const int seg = mode_info_context->mbmi.segment_id;
+ const int ref_frame = mode_info_context->mbmi.ref_frame;
+ int tx_type = mode_info_context->mbmi.txfm_size;
+
+ filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
+
+ if (filter_level) {
+ if (cm->filter_type == NORMAL_LOOPFILTER) {
+ const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
+ lfi.mblim = lfi_n->mblim[filter_level];
+ lfi.blim = lfi_n->blim[filter_level];
+ lfi.lim = lfi_n->lim[filter_level];
+ lfi.hev_thr = lfi_n->hev_thr[hev_index];
+
+ if (mb_col > 0)
+ vp8_loop_filter_mbv_c
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ if (!skip_lf) {
+ if (tx_type == TX_8X8)
+ vp8_loop_filter_bv8x8_c
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ else
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ }
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ vp8_loop_filter_mbh_c
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ if (!skip_lf) {
+ if (tx_type == TX_8X8)
+ vp8_loop_filter_bh8x8_c
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ else
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ }
+ } else {
+ if (mb_col > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
}
+ }
+
+ y_ptr += 16;
+ mode_info_context++; /* step to next MB */
- y_ptr += post->y_stride * 16 - post->y_width;
- mode_info_context ++; /* Skip border mb */
}
+ y_ptr += post->y_stride * 16 - post->y_width;
+ mode_info_context++; /* Skip border mb */
+ }
+
}
#if CONFIG_FEATUREUPDATES
// TODO: Multiple copies of loop filtering code should be pruned and
// cut down. This just adds yet another so that I can do an if
// on segment.
void vp8_loop_filter_frame_segment(VP8_COMMON *cm, MACROBLOCKD *xd,
- int default_filt_lvl, int segment)
-{
- YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+ int default_filt_lvl, int segment) {
+ YV12_BUFFER_CONFIG *post = cm->frame_to_show;
- unsigned char *y_ptr;
- int mb_row;
- int mb_col;
+ unsigned char *y_ptr;
+ int mb_row;
+ int mb_col;
- loop_filter_info_n *lfi_n = &cm->lf_info;
- loop_filter_info lfi;
+ loop_filter_info_n *lfi_n = &cm->lf_info;
+ loop_filter_info lfi;
- int filter_level;
- FRAME_TYPE frame_type = cm->frame_type;
+ int filter_level;
+ FRAME_TYPE frame_type = cm->frame_type;
- /* Point at base of Mb MODE_INFO list */
- const MODE_INFO *mode_info_context = cm->mi;
+ /* Point at base of Mb MODE_INFO list */
+ const MODE_INFO *mode_info_context = cm->mi;
#if 0
- if(default_filt_lvl == 0) /* no filter applied */
+ if (default_filt_lvl == 0) /* no filter applied */
return;
#endif
- /* Initialize the loop filter for this frame. */
- vp8_loop_filter_frame_init(cm, xd, default_filt_lvl);
-
- /* Set up the buffer pointers */
- y_ptr = post->y_buffer;
-
- /* vp8_filter each macro block */
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- int skip_lf = (mode_info_context->mbmi.mode != B_PRED
- && mode_info_context->mbmi.mode != I8X8_PRED
- && mode_info_context->mbmi.mode != SPLITMV
- && mode_info_context->mbmi.mb_skip_coeff);
-
- const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi
- .mode];
- const int seg = mode_info_context->mbmi.segment_id;
- const int ref_frame = mode_info_context->mbmi.ref_frame;
-
- filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
-
- // check if this mb has filtering applied
- // and then whether it is the right segment or
- // if not whether the passed in segment is 0 and this
- // segment has no alt lf
-
- // TODO: Make this work for when segment 0 has the alt lv enabled
- if (filter_level
- && (seg == segment
- || (!segfeature_active(xd, seg, SEG_LVL_ALT_LF)
- && segment == 0)))
- {
- if (cm->filter_type == NORMAL_LOOPFILTER)
- {
- const int hev_index =
- lfi_n->hev_thr_lut[frame_type][filter_level];
- lfi.mblim = lfi_n->mblim[filter_level];
- lfi.blim = lfi_n->blim[filter_level];
- lfi.lim = lfi_n->lim[filter_level];
- lfi.hev_thr = lfi_n->hev_thr[hev_index];
-
- if (mb_col > 0)
- vp8_loop_filter_mbv_c(y_ptr, 0, 0, post->y_stride, 0,
- &lfi);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)(
- y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- vp8_loop_filter_mbh_c(y_ptr, 0, 0, post->y_stride, 0,
- &lfi);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)(
- y_ptr, 0, 0, post->y_stride, 0, &lfi);
- }
- else
- {
- if (mb_col > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)(
- y_ptr, post->y_stride,
- lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)(
- y_ptr, post->y_stride,
- lfi_n->blim[filter_level]);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)(
- y_ptr, post->y_stride,
- lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)(
- y_ptr, post->y_stride,
- lfi_n->blim[filter_level]);
- }
- }
-
- y_ptr += 16;
- mode_info_context++; /* step to next MB */
-
+ /* Initialize the loop filter for this frame. */
+ vp8_loop_filter_frame_init(cm, xd, default_filt_lvl);
+
+ /* Set up the buffer pointers */
+ y_ptr = post->y_buffer;
+
+ /* vp8_filter each macro block */
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ int skip_lf = (mode_info_context->mbmi.mode != B_PRED
+ && mode_info_context->mbmi.mode != I8X8_PRED
+ && mode_info_context->mbmi.mode != SPLITMV
+ && mode_info_context->mbmi.mb_skip_coeff);
+
+ const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi
+ .mode];
+ const int seg = mode_info_context->mbmi.segment_id;
+ const int ref_frame = mode_info_context->mbmi.ref_frame;
+
+ filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
+
+ // check if this mb has filtering applied
+ // and then whether it is the right segment or
+ // if not whether the passed in segment is 0 and this
+ // segment has no alt lf
+
+ // TODO: Make this work for when segment 0 has the alt lv enabled
+ if (filter_level
+ && (seg == segment
+ || (!segfeature_active(xd, seg, SEG_LVL_ALT_LF)
+ && segment == 0))) {
+ if (cm->filter_type == NORMAL_LOOPFILTER) {
+ const int hev_index =
+ lfi_n->hev_thr_lut[frame_type][filter_level];
+ lfi.mblim = lfi_n->mblim[filter_level];
+ lfi.blim = lfi_n->blim[filter_level];
+ lfi.lim = lfi_n->lim[filter_level];
+ lfi.hev_thr = lfi_n->hev_thr[hev_index];
+
+ if (mb_col > 0)
+ vp8_loop_filter_mbv_c(y_ptr, 0, 0, post->y_stride, 0,
+ &lfi);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)(
+ y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ vp8_loop_filter_mbh_c(y_ptr, 0, 0, post->y_stride, 0,
+ &lfi);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)(
+ y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ } else {
+ if (mb_col > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)(
+ y_ptr, post->y_stride,
+ lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)(
+ y_ptr, post->y_stride,
+ lfi_n->blim[filter_level]);
+
+ /* don't apply across umv border */
+ if (mb_row > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)(
+ y_ptr, post->y_stride,
+ lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)(
+ y_ptr, post->y_stride,
+ lfi_n->blim[filter_level]);
}
+ }
+
+ y_ptr += 16;
+ mode_info_context++; /* step to next MB */
- y_ptr += post->y_stride * 16 - post->y_width;
- mode_info_context++; /* Skip border mb */
}
+ y_ptr += post->y_stride * 16 - post->y_width;
+ mode_info_context++; /* Skip border mb */
+ }
+
}
#endif
void vp8_loop_filter_partial_frame
(
- VP8_COMMON *cm,
- MACROBLOCKD *xd,
- int default_filt_lvl
-)
-{
- YV12_BUFFER_CONFIG *post = cm->frame_to_show;
-
- unsigned char *y_ptr;
- int mb_row;
- int mb_col;
- int mb_cols = post->y_width >> 4;
-
- int linestocopy, i;
-
- loop_filter_info_n *lfi_n = &cm->lf_info;
- loop_filter_info lfi;
-
- int filter_level;
- int alt_flt_enabled = xd->segmentation_enabled;
- FRAME_TYPE frame_type = cm->frame_type;
-
- const MODE_INFO *mode_info_context;
-
- int lvl_seg[MAX_MB_SEGMENTS];
-
- mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);
-
- /* 3 is a magic number. 4 is probably magic too */
- linestocopy = (post->y_height >> (4 + 3));
-
- if (linestocopy < 1)
- linestocopy = 1;
-
- linestocopy <<= 4;
-
- /* Note the baseline filter values for each segment */
- /* See vp8_loop_filter_frame_init. Rather than call that for each change
- * to default_filt_lvl, copy the relevant calculation here.
- */
- if (alt_flt_enabled)
- {
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- { /* Abs value */
- if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
- {
- lvl_seg[i] = get_segdata( xd, i, SEG_LVL_ALT_LF );
- }
- /* Delta Value */
- else
- {
- lvl_seg[i] = default_filt_lvl +
- get_segdata( xd, i, SEG_LVL_ALT_LF );
- lvl_seg[i] = (lvl_seg[i] > 0) ?
- ((lvl_seg[i] > 63) ? 63: lvl_seg[i]) : 0;
- }
- }
+ VP8_COMMON *cm,
+ MACROBLOCKD *xd,
+ int default_filt_lvl
+) {
+ YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+
+ unsigned char *y_ptr;
+ int mb_row;
+ int mb_col;
+ int mb_cols = post->y_width >> 4;
+
+ int linestocopy, i;
+
+ loop_filter_info_n *lfi_n = &cm->lf_info;
+ loop_filter_info lfi;
+
+ int filter_level;
+ int alt_flt_enabled = xd->segmentation_enabled;
+ FRAME_TYPE frame_type = cm->frame_type;
+
+ const MODE_INFO *mode_info_context;
+
+ int lvl_seg[MAX_MB_SEGMENTS];
+
+ mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);
+
+ /* 3 is a magic number. 4 is probably magic too */
+ linestocopy = (post->y_height >> (4 + 3));
+
+ if (linestocopy < 1)
+ linestocopy = 1;
+
+ linestocopy <<= 4;
+
+ /* Note the baseline filter values for each segment */
+ /* See vp8_loop_filter_frame_init. Rather than call that for each change
+ * to default_filt_lvl, copy the relevant calculation here.
+ */
+ if (alt_flt_enabled) {
+ for (i = 0; i < MAX_MB_SEGMENTS; i++) {
+ /* Abs value */
+ if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
+ lvl_seg[i] = get_segdata(xd, i, SEG_LVL_ALT_LF);
+ }
+ /* Delta Value */
+ else {
+ lvl_seg[i] = default_filt_lvl +
+ get_segdata(xd, i, SEG_LVL_ALT_LF);
+ lvl_seg[i] = (lvl_seg[i] > 0) ?
+ ((lvl_seg[i] > 63) ? 63 : lvl_seg[i]) : 0;
+ }
}
-
- /* Set up the buffer pointers */
- y_ptr = post->y_buffer + (post->y_height >> 5) * 16 * post->y_stride;
-
- /* vp8_filter each macro block */
- for (mb_row = 0; mb_row<(linestocopy >> 4); mb_row++)
- {
- for (mb_col = 0; mb_col < mb_cols; mb_col++)
- {
- int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
- mode_info_context->mbmi.mode != I8X8_PRED &&
- mode_info_context->mbmi.mode != SPLITMV &&
- mode_info_context->mbmi.mb_skip_coeff);
-
- if (alt_flt_enabled)
- filter_level = lvl_seg[mode_info_context->mbmi.segment_id];
- else
- filter_level = default_filt_lvl;
-
- if (filter_level)
- {
- if (cm->filter_type == NORMAL_LOOPFILTER)
- {
- const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
- lfi.mblim = lfi_n->mblim[filter_level];
- lfi.blim = lfi_n->blim[filter_level];
- lfi.lim = lfi_n->lim[filter_level];
- lfi.hev_thr = lfi_n->hev_thr[hev_index];
-
- if (mb_col > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
- (y_ptr, 0, 0, post->y_stride, 0, &lfi);
- }
- else
- {
- if (mb_col > 0)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
-
- LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
- (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
- (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
- }
- }
-
- y_ptr += 16;
- mode_info_context += 1; /* step to next MB */
+ }
+
+ /* Set up the buffer pointers */
+ y_ptr = post->y_buffer + (post->y_height >> 5) * 16 * post->y_stride;
+
+ /* vp8_filter each macro block */
+ for (mb_row = 0; mb_row < (linestocopy >> 4); mb_row++) {
+ for (mb_col = 0; mb_col < mb_cols; mb_col++) {
+ int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+ mode_info_context->mbmi.mode != SPLITMV &&
+ mode_info_context->mbmi.mb_skip_coeff);
+
+ if (alt_flt_enabled)
+ filter_level = lvl_seg[mode_info_context->mbmi.segment_id];
+ else
+ filter_level = default_filt_lvl;
+
+ if (filter_level) {
+ if (cm->filter_type == NORMAL_LOOPFILTER) {
+ const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
+ lfi.mblim = lfi_n->mblim[filter_level];
+ lfi.blim = lfi_n->blim[filter_level];
+ lfi.lim = lfi_n->lim[filter_level];
+ lfi.hev_thr = lfi_n->hev_thr[hev_index];
+
+ if (mb_col > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h)
+ (y_ptr, 0, 0, post->y_stride, 0, &lfi);
+ } else {
+ if (mb_col > 0)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
+
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
+ (y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
+
+ if (!skip_lf)
+ LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h)
+ (y_ptr, post->y_stride, lfi_n->blim[filter_level]);
}
+ }
- y_ptr += post->y_stride * 16 - post->y_width;
- mode_info_context += 1; /* Skip border mb */
+ y_ptr += 16;
+ mode_info_context += 1; /* step to next MB */
}
+
+ y_ptr += post->y_stride * 16 - post->y_width;
+ mode_info_context += 1; /* Skip border mb */
+ }
}
diff --git a/vp8/common/loopfilter.h b/vp8/common/loopfilter.h
index 0ae2b9a1b..b2ba95d5f 100644
--- a/vp8/common/loopfilter.h
+++ b/vp8/common/loopfilter.h
@@ -18,10 +18,9 @@
#define MAX_LOOP_FILTER 63
-typedef enum
-{
- NORMAL_LOOPFILTER = 0,
- SIMPLE_LOOPFILTER = 1
+typedef enum {
+ NORMAL_LOOPFILTER = 0,
+ SIMPLE_LOOPFILTER = 1
} LOOPFILTERTYPE;
#if ARCH_ARM
@@ -33,36 +32,34 @@ typedef enum
/* Need to align this structure so when it is declared and
* passed it can be loaded into vector registers.
*/
-typedef struct
-{
- DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
- DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, blim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
- DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
- DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, hev_thr[4][SIMD_WIDTH]);
- unsigned char lvl[4][4][4];
- unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
- unsigned char mode_lf_lut[MB_MODE_COUNT];
+typedef struct {
+ DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
+ DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, blim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
+ DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
+ DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, hev_thr[4][SIMD_WIDTH]);
+ unsigned char lvl[4][4][4];
+ unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
+ unsigned char mode_lf_lut[MB_MODE_COUNT];
} loop_filter_info_n;
-typedef struct
-{
- const unsigned char * mblim;
- const unsigned char * blim;
- const unsigned char * lim;
- const unsigned char * hev_thr;
+typedef struct {
+ const unsigned char *mblim;
+ const unsigned char *blim;
+ const unsigned char *lim;
+ const unsigned char *hev_thr;
} loop_filter_info;
#define prototype_loopfilter(sym) \
- void sym(unsigned char *src, int pitch, const unsigned char *blimit,\
- const unsigned char *limit, const unsigned char *thresh, int count)
+ void sym(unsigned char *src, int pitch, const unsigned char *blimit,\
+ const unsigned char *limit, const unsigned char *thresh, int count)
#define prototype_loopfilter_block(sym) \
- void sym(unsigned char *y, unsigned char *u, unsigned char *v, \
- int ystride, int uv_stride, loop_filter_info *lfi)
+ void sym(unsigned char *y, unsigned char *u, unsigned char *v, \
+ int ystride, int uv_stride, loop_filter_info *lfi)
#define prototype_simple_loopfilter(sym) \
- void sym(unsigned char *y, int ystride, const unsigned char *blimit)
+ void sym(unsigned char *y, int ystride, const unsigned char *blimit)
#if ARCH_X86 || ARCH_X86_64
#include "x86/loopfilter_x86.h"
@@ -115,16 +112,15 @@ extern prototype_simple_loopfilter(vp8_lf_simple_b_h);
typedef prototype_loopfilter_block((*vp8_lf_block_fn_t));
typedef prototype_simple_loopfilter((*vp8_slf_block_fn_t));
-typedef struct
-{
- vp8_lf_block_fn_t normal_mb_v;
- vp8_lf_block_fn_t normal_b_v;
- vp8_lf_block_fn_t normal_mb_h;
- vp8_lf_block_fn_t normal_b_h;
- vp8_slf_block_fn_t simple_mb_v;
- vp8_slf_block_fn_t simple_b_v;
- vp8_slf_block_fn_t simple_mb_h;
- vp8_slf_block_fn_t simple_b_h;
+typedef struct {
+ vp8_lf_block_fn_t normal_mb_v;
+ vp8_lf_block_fn_t normal_b_v;
+ vp8_lf_block_fn_t normal_mb_h;
+ vp8_lf_block_fn_t normal_b_h;
+ vp8_slf_block_fn_t simple_mb_v;
+ vp8_slf_block_fn_t simple_b_v;
+ vp8_slf_block_fn_t simple_mb_h;
+ vp8_slf_block_fn_t simple_b_h;
} vp8_loopfilter_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
@@ -135,12 +131,12 @@ typedef struct
typedef void loop_filter_uvfunction
(
- unsigned char *u, /* source pointer */
- int p, /* pitch */
- const unsigned char *blimit,
- const unsigned char *limit,
- const unsigned char *thresh,
- unsigned char *v
+ unsigned char *u, /* source pointer */
+ int p, /* pitch */
+ const unsigned char *blimit,
+ const unsigned char *limit,
+ const unsigned char *thresh,
+ unsigned char *v
);
/* assorted loopfilter functions which get used elsewhere */
diff --git a/vp8/common/loopfilter_filters.c b/vp8/common/loopfilter_filters.c
index dbfd3c96f..ef69ffecc 100644
--- a/vp8/common/loopfilter_filters.c
+++ b/vp8/common/loopfilter_filters.c
@@ -16,44 +16,186 @@
typedef unsigned char uc;
-static __inline signed char vp8_signed_char_clamp(int t)
-{
- t = (t < -128 ? -128 : t);
- t = (t > 127 ? 127 : t);
- return (signed char) t;
+static __inline signed char vp8_signed_char_clamp(int t) {
+ t = (t < -128 ? -128 : t);
+ t = (t > 127 ? 127 : t);
+ return (signed char) t;
}
/* should we apply any filter at all ( 11111111 yes, 00000000 no) */
static __inline signed char vp8_filter_mask(uc limit, uc blimit,
- uc p3, uc p2, uc p1, uc p0,
- uc q0, uc q1, uc q2, uc q3)
-{
- signed char mask = 0;
- mask |= (abs(p3 - p2) > limit) * -1;
- mask |= (abs(p2 - p1) > limit) * -1;
- mask |= (abs(p1 - p0) > limit) * -1;
- mask |= (abs(q1 - q0) > limit) * -1;
- mask |= (abs(q2 - q1) > limit) * -1;
- mask |= (abs(q3 - q2) > limit) * -1;
- mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1;
- mask = ~mask;
- return mask;
+ uc p3, uc p2, uc p1, uc p0,
+ uc q0, uc q1, uc q2, uc q3) {
+ signed char mask = 0;
+ mask |= (abs(p3 - p2) > limit) * -1;
+ mask |= (abs(p2 - p1) > limit) * -1;
+ mask |= (abs(p1 - p0) > limit) * -1;
+ mask |= (abs(q1 - q0) > limit) * -1;
+ mask |= (abs(q2 - q1) > limit) * -1;
+ mask |= (abs(q3 - q2) > limit) * -1;
+ mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1;
+ mask = ~mask;
+ return mask;
}
/* is there high variance internal edge ( 11111111 yes, 00000000 no) */
-static __inline signed char vp8_hevmask(uc thresh, uc p1, uc p0, uc q0, uc q1)
-{
- signed char hev = 0;
- hev |= (abs(p1 - p0) > thresh) * -1;
- hev |= (abs(q1 - q0) > thresh) * -1;
- return hev;
+static __inline signed char vp8_hevmask(uc thresh, uc p1, uc p0, uc q0, uc q1) {
+ signed char hev = 0;
+ hev |= (abs(p1 - p0) > thresh) * -1;
+ hev |= (abs(q1 - q0) > thresh) * -1;
+ return hev;
}
static __inline void vp8_filter(signed char mask, uc hev, uc *op1,
- uc *op0, uc *oq0, uc *oq1)
+ uc *op0, uc *oq0, uc *oq1)
{
+ signed char ps0, qs0;
+ signed char ps1, qs1;
+ signed char vp8_filter, Filter1, Filter2;
+ signed char u;
+
+ ps1 = (signed char) * op1 ^ 0x80;
+ ps0 = (signed char) * op0 ^ 0x80;
+ qs0 = (signed char) * oq0 ^ 0x80;
+ qs1 = (signed char) * oq1 ^ 0x80;
+
+ /* add outer taps if we have high edge variance */
+ vp8_filter = vp8_signed_char_clamp(ps1 - qs1);
+ vp8_filter &= hev;
+
+ /* inner taps */
+ vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (qs0 - ps0));
+ vp8_filter &= mask;
+
+ /* save bottom 3 bits so that we round one side +4 and the other +3
+ * if it equals 4 we'll set to adjust by -1 to account for the fact
+ * we'd round 3 the other way
+ */
+ Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
+ Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
+ Filter1 >>= 3;
+ Filter2 >>= 3;
+ u = vp8_signed_char_clamp(qs0 - Filter1);
+ *oq0 = u ^ 0x80;
+ u = vp8_signed_char_clamp(ps0 + Filter2);
+ *op0 = u ^ 0x80;
+ vp8_filter = Filter1;
+
+ /* outer tap adjustments */
+ vp8_filter += 1;
+ vp8_filter >>= 1;
+ vp8_filter &= ~hev;
+
+ u = vp8_signed_char_clamp(qs1 - vp8_filter);
+ *oq1 = u ^ 0x80;
+ u = vp8_signed_char_clamp(ps1 + vp8_filter);
+ *op1 = u ^ 0x80;
+
+}
+void vp8_loop_filter_horizontal_edge_c
+(
+ unsigned char *s,
+ int p, /* pitch */
+ const unsigned char *blimit,
+ const unsigned char *limit,
+ const unsigned char *thresh,
+ int count
+) {
+ int hev = 0; /* high edge variance */
+ signed char mask = 0;
+ int i = 0;
+
+ /* loop filter designed to work using chars so that we can make maximum use
+ * of 8 bit simd instructions.
+ */
+ do {
+ mask = vp8_filter_mask(limit[0], blimit[0],
+ s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
+ s[0 * p], s[1 * p], s[2 * p], s[3 * p]);
+
+ hev = vp8_hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
+
+ vp8_filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p);
+
+ ++s;
+ } while (++i < count * 8);
+}
+
+void vp8_loop_filter_vertical_edge_c
+(
+ unsigned char *s,
+ int p,
+ const unsigned char *blimit,
+ const unsigned char *limit,
+ const unsigned char *thresh,
+ int count
+) {
+ int hev = 0; /* high edge variance */
+ signed char mask = 0;
+ int i = 0;
+
+ /* loop filter designed to work using chars so that we can make maximum use
+ * of 8 bit simd instructions.
+ */
+ do {
+ mask = vp8_filter_mask(limit[0], blimit[0],
+ s[-4], s[-3], s[-2], s[-1],
+ s[0], s[1], s[2], s[3]);
+
+ hev = vp8_hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
+
+ vp8_filter(mask, hev, s - 2, s - 1, s, s + 1);
+
+ s += p;
+ } while (++i < count * 8);
+}
+static __inline signed char vp8_flatmask(uc thresh,
+ uc p4, uc p3, uc p2, uc p1, uc p0,
+ uc q0, uc q1, uc q2, uc q3, uc q4) {
+ signed char flat = 0;
+ flat |= (abs(p1 - p0) > 1) * -1;
+ flat |= (abs(q1 - q0) > 1) * -1;
+ flat |= (abs(p0 - p2) > 1) * -1;
+ flat |= (abs(q0 - q2) > 1) * -1;
+ flat |= (abs(p3 - p0) > 1) * -1;
+ flat |= (abs(q3 - q0) > 1) * -1;
+ flat |= (abs(p4 - p0) > 1) * -1;
+ flat |= (abs(q4 - q0) > 1) * -1;
+ flat = ~flat;
+ return flat;
+}
+
+static __inline void vp8_mbfilter(signed char mask, uc hev, uc flat,
+ uc *op4, uc *op3, uc *op2, uc *op1, uc *op0,
+ uc *oq0, uc *oq1, uc *oq2, uc *oq3, uc *oq4) {
+ /* use a 7 tap filter [1, 1, 1, 2, 1, 1, 1] for flat line */
+ if (flat && mask) {
+ unsigned char p0, q0;
+ unsigned char p1, q1;
+ unsigned char p2, q2;
+ unsigned char p3, q3;
+ unsigned char p4, q4;
+
+ p4 = *op4;
+ p3 = *op3;
+ p2 = *op2;
+ p1 = *op1;
+ p0 = *op0;
+ q0 = *oq0;
+ q1 = *oq1;
+ q2 = *oq2;
+ q3 = *oq3;
+ q4 = *oq4;
+
+ *op2 = (p4 + p4 + p3 + p2 + p2 + p1 + p0 + q0 + 4) >> 3;
+ *op1 = (p4 + p3 + p2 + p1 + p1 + p0 + q0 + q1 + 4) >> 3;
+ *op0 = (p3 + p2 + p1 + p0 + p0 + q0 + q1 + q2 + 4) >> 3;
+ *oq0 = (p2 + p1 + p0 + q0 + q0 + q1 + q2 + q3 + 4) >> 3;
+ *oq1 = (p1 + p0 + q0 + q1 + q1 + q2 + q3 + q4 + 4) >> 3;
+ *oq2 = (p0 + q0 + q1 + q2 + q2 + q3 + q4 + q4 + 4) >> 3;
+ } else {
signed char ps0, qs0;
signed char ps1, qs1;
signed char vp8_filter, Filter1, Filter2;
@@ -72,10 +214,6 @@ static __inline void vp8_filter(signed char mask, uc hev, uc *op1,
vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (qs0 - ps0));
vp8_filter &= mask;
- /* save bottom 3 bits so that we round one side +4 and the other +3
- * if it equals 4 we'll set to adjust by -1 to account for the fact
- * we'd round 3 the other way
- */
Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
Filter1 >>= 3;
@@ -95,315 +233,149 @@ static __inline void vp8_filter(signed char mask, uc hev, uc *op1,
*oq1 = u ^ 0x80;
u = vp8_signed_char_clamp(ps1 + vp8_filter);
*op1 = u ^ 0x80;
-
-}
-void vp8_loop_filter_horizontal_edge_c
-(
- unsigned char *s,
- int p, /* pitch */
- const unsigned char *blimit,
- const unsigned char *limit,
- const unsigned char *thresh,
- int count
-)
-{
- int hev = 0; /* high edge variance */
- signed char mask = 0;
- int i = 0;
-
- /* loop filter designed to work using chars so that we can make maximum use
- * of 8 bit simd instructions.
- */
- do
- {
- mask = vp8_filter_mask(limit[0], blimit[0],
- s[-4*p], s[-3*p], s[-2*p], s[-1*p],
- s[0*p], s[1*p], s[2*p], s[3*p]);
-
- hev = vp8_hevmask(thresh[0], s[-2*p], s[-1*p], s[0*p], s[1*p]);
-
- vp8_filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p);
-
- ++s;
- }
- while (++i < count * 8);
-}
-
-void vp8_loop_filter_vertical_edge_c
-(
- unsigned char *s,
- int p,
- const unsigned char *blimit,
- const unsigned char *limit,
- const unsigned char *thresh,
- int count
-)
-{
- int hev = 0; /* high edge variance */
- signed char mask = 0;
- int i = 0;
-
- /* loop filter designed to work using chars so that we can make maximum use
- * of 8 bit simd instructions.
- */
- do
- {
- mask = vp8_filter_mask(limit[0], blimit[0],
- s[-4], s[-3], s[-2], s[-1],
- s[0], s[1], s[2], s[3]);
-
- hev = vp8_hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
-
- vp8_filter(mask, hev, s - 2, s - 1, s, s + 1);
-
- s += p;
- }
- while (++i < count * 8);
-}
-static __inline signed char vp8_flatmask(uc thresh,
- uc p4, uc p3, uc p2, uc p1, uc p0,
- uc q0, uc q1, uc q2, uc q3, uc q4)
-{
- signed char flat = 0;
- flat |= (abs(p1 - p0) > 1) * -1;
- flat |= (abs(q1 - q0) > 1) * -1;
- flat |= (abs(p0 - p2) > 1) * -1;
- flat |= (abs(q0 - q2) > 1) * -1;
- flat |= (abs(p3 - p0) > 1) * -1;
- flat |= (abs(q3 - q0) > 1) * -1;
- flat |= (abs(p4 - p0) > 1) * -1;
- flat |= (abs(q4 - q0) > 1) * -1;
- flat = ~flat;
- return flat;
-}
-
-static __inline void vp8_mbfilter(signed char mask, uc hev, uc flat,
- uc *op4, uc *op3, uc *op2, uc *op1, uc *op0,
- uc *oq0, uc *oq1, uc *oq2, uc *oq3, uc *oq4)
-{
- /* use a 7 tap filter [1, 1, 1, 2, 1, 1, 1] for flat line */
- if(flat && mask)
- {
- unsigned char p0, q0;
- unsigned char p1, q1;
- unsigned char p2, q2;
- unsigned char p3, q3;
- unsigned char p4, q4;
-
- p4 = *op4;
- p3 = *op3;
- p2 = *op2;
- p1 = *op1;
- p0 = *op0;
- q0 = *oq0;
- q1 = *oq1;
- q2 = *oq2;
- q3 = *oq3;
- q4 = *oq4;
-
- *op2 = ( p4 + p4 + p3 + p2 + p2 + p1 + p0 + q0 + 4)>>3;
- *op1 = ( p4 + p3 + p2 + p1 + p1 + p0 + q0 + q1 + 4)>>3;
- *op0 = ( p3 + p2 + p1 + p0 + p0 + q0 + q1 + q2 + 4)>>3;
- *oq0 = ( p2 + p1 + p0 + q0 + q0 + q1 + q2 + q3 + 4)>>3;
- *oq1 = ( p1 + p0 + q0 + q1 + q1 + q2 + q3 + q4 + 4)>>3;
- *oq2 = ( p0 + q0 + q1 + q2 + q2 + q3 + q4 + q4 + 4)>>3;
- }
- else
- {
- signed char ps0, qs0;
- signed char ps1, qs1;
- signed char vp8_filter, Filter1, Filter2;
- signed char u;
-
- ps1 = (signed char) * op1 ^ 0x80;
- ps0 = (signed char) * op0 ^ 0x80;
- qs0 = (signed char) * oq0 ^ 0x80;
- qs1 = (signed char) * oq1 ^ 0x80;
-
- /* add outer taps if we have high edge variance */
- vp8_filter = vp8_signed_char_clamp(ps1 - qs1);
- vp8_filter &= hev;
-
- /* inner taps */
- vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (qs0 - ps0));
- vp8_filter &= mask;
-
- Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
- Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
- Filter1 >>= 3;
- Filter2 >>= 3;
- u = vp8_signed_char_clamp(qs0 - Filter1);
- *oq0 = u ^ 0x80;
- u = vp8_signed_char_clamp(ps0 + Filter2);
- *op0 = u ^ 0x80;
- vp8_filter = Filter1;
-
- /* outer tap adjustments */
- vp8_filter += 1;
- vp8_filter >>= 1;
- vp8_filter &= ~hev;
-
- u = vp8_signed_char_clamp(qs1 - vp8_filter);
- *oq1 = u ^ 0x80;
- u = vp8_signed_char_clamp(ps1 + vp8_filter);
- *op1 = u ^ 0x80;
- }
+ }
}
void vp8_mbloop_filter_horizontal_edge_c
(
- unsigned char *s,
- int p,
- const unsigned char *blimit,
- const unsigned char *limit,
- const unsigned char *thresh,
- int count
-)
-{
- signed char hev = 0; /* high edge variance */
- signed char mask = 0;
- signed char flat = 0;
- int i = 0;
-
- /* loop filter designed to work using chars so that we can make maximum use
- * of 8 bit simd instructions.
- */
- do
- {
-
- mask = vp8_filter_mask(limit[0], blimit[0],
- s[-4*p], s[-3*p], s[-2*p], s[-1*p],
- s[ 0*p], s[ 1*p], s[ 2*p], s[ 3*p]);
-
- hev = vp8_hevmask(thresh[0], s[-2*p], s[-1*p], s[0*p], s[1*p]);
-
- flat = vp8_flatmask(thresh[0],
- s[-5*p], s[-4*p], s[-3*p], s[-2*p], s[-1*p],
- s[ 0*p], s[ 1*p], s[ 2*p], s[ 3*p], s[ 4*p]);
- vp8_mbfilter(mask, hev, flat,
- s - 5*p, s - 4*p, s- 3*p, s - 2*p, s - 1*p,
- s, s + 1*p, s+ 2*p, s + 3*p, s + 4*p );
-
- ++s;
- }
- while (++i < count * 8);
+ unsigned char *s,
+ int p,
+ const unsigned char *blimit,
+ const unsigned char *limit,
+ const unsigned char *thresh,
+ int count
+) {
+ signed char hev = 0; /* high edge variance */
+ signed char mask = 0;
+ signed char flat = 0;
+ int i = 0;
+
+ /* loop filter designed to work using chars so that we can make maximum use
+ * of 8 bit simd instructions.
+ */
+ do {
+
+ mask = vp8_filter_mask(limit[0], blimit[0],
+ s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
+ s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]);
+
+ hev = vp8_hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
+
+ flat = vp8_flatmask(thresh[0],
+ s[-5 * p], s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
+ s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p], s[ 4 * p]);
+ vp8_mbfilter(mask, hev, flat,
+ s - 5 * p, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p,
+ s, s + 1 * p, s + 2 * p, s + 3 * p, s + 4 * p);
+
+ ++s;
+ } while (++i < count * 8);
}
void vp8_mbloop_filter_vertical_edge_c
(
- unsigned char *s,
- int p,
- const unsigned char *blimit,
- const unsigned char *limit,
- const unsigned char *thresh,
- int count
-)
-{
- signed char hev = 0; /* high edge variance */
- signed char mask = 0;
- signed char flat = 0;
- int i = 0;
-
- do
- {
-
- mask = vp8_filter_mask(limit[0], blimit[0],
- s[-4], s[-3], s[-2], s[-1],
- s[0], s[1], s[2], s[3]);
-
- hev = vp8_hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
- flat = vp8_flatmask(thresh[0],
- s[-5],s[-4],s[-3],s[-2],s[-1],
- s[ 0],s[ 1],s[ 2],s[ 3],s[ 4]);
- vp8_mbfilter(mask, hev, flat,
- s - 5, s - 4, s - 3, s - 2, s - 1,
- s, s + 1, s + 2, s + 3, s + 4);
- s += p;
- }
- while (++i < count * 8);
+ unsigned char *s,
+ int p,
+ const unsigned char *blimit,
+ const unsigned char *limit,
+ const unsigned char *thresh,
+ int count
+) {
+ signed char hev = 0; /* high edge variance */
+ signed char mask = 0;
+ signed char flat = 0;
+ int i = 0;
+
+ do {
+
+ mask = vp8_filter_mask(limit[0], blimit[0],
+ s[-4], s[-3], s[-2], s[-1],
+ s[0], s[1], s[2], s[3]);
+
+ hev = vp8_hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
+ flat = vp8_flatmask(thresh[0],
+ s[-5], s[-4], s[-3], s[-2], s[-1],
+ s[ 0], s[ 1], s[ 2], s[ 3], s[ 4]);
+ vp8_mbfilter(mask, hev, flat,
+ s - 5, s - 4, s - 3, s - 2, s - 1,
+ s, s + 1, s + 2, s + 3, s + 4);
+ s += p;
+ } while (++i < count * 8);
}
/* should we apply any filter at all ( 11111111 yes, 00000000 no) */
static __inline signed char vp8_simple_filter_mask(uc blimit,
uc p1, uc p0,
- uc q0, uc q1)
-{
-/* Why does this cause problems for win32?
- * error C2143: syntax error : missing ';' before 'type'
- * (void) limit;
- */
- signed char mask = (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 <= blimit) * -1;
- return mask;
+ uc q0, uc q1) {
+ /* Why does this cause problems for win32?
+ * error C2143: syntax error : missing ';' before 'type'
+ * (void) limit;
+ */
+ signed char mask = (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 <= blimit) * -1;
+ return mask;
}
static __inline void vp8_simple_filter(signed char mask,
uc *op1, uc *op0,
- uc *oq0, uc *oq1)
-{
- signed char vp8_filter, Filter1, Filter2;
- signed char p1 = (signed char) * op1 ^ 0x80;
- signed char p0 = (signed char) * op0 ^ 0x80;
- signed char q0 = (signed char) * oq0 ^ 0x80;
- signed char q1 = (signed char) * oq1 ^ 0x80;
- signed char u;
-
- vp8_filter = vp8_signed_char_clamp(p1 - q1);
- vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (q0 - p0));
- vp8_filter &= mask;
-
- /* save bottom 3 bits so that we round one side +4 and the other +3 */
- Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
- Filter1 >>= 3;
- u = vp8_signed_char_clamp(q0 - Filter1);
- *oq0 = u ^ 0x80;
-
- Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
- Filter2 >>= 3;
- u = vp8_signed_char_clamp(p0 + Filter2);
- *op0 = u ^ 0x80;
+ uc *oq0, uc *oq1) {
+ signed char vp8_filter, Filter1, Filter2;
+ signed char p1 = (signed char) * op1 ^ 0x80;
+ signed char p0 = (signed char) * op0 ^ 0x80;
+ signed char q0 = (signed char) * oq0 ^ 0x80;
+ signed char q1 = (signed char) * oq1 ^ 0x80;
+ signed char u;
+
+ vp8_filter = vp8_signed_char_clamp(p1 - q1);
+ vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (q0 - p0));
+ vp8_filter &= mask;
+
+ /* save bottom 3 bits so that we round one side +4 and the other +3 */
+ Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
+ Filter1 >>= 3;
+ u = vp8_signed_char_clamp(q0 - Filter1);
+ *oq0 = u ^ 0x80;
+
+ Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
+ Filter2 >>= 3;
+ u = vp8_signed_char_clamp(p0 + Filter2);
+ *op0 = u ^ 0x80;
}
void vp8_loop_filter_simple_horizontal_edge_c
(
- unsigned char *s,
- int p,
- const unsigned char *blimit
-)
-{
- signed char mask = 0;
- int i = 0;
-
- do
- {
- mask = vp8_simple_filter_mask(blimit[0],
- s[-2*p], s[-1*p],
- s[0*p], s[1*p]);
- vp8_simple_filter(mask,
- s - 2 * p, s - 1 * p,
- s, s + 1 * p);
- ++s;
- }
- while (++i < 16);
+ unsigned char *s,
+ int p,
+ const unsigned char *blimit
+) {
+ signed char mask = 0;
+ int i = 0;
+
+ do {
+ mask = vp8_simple_filter_mask(blimit[0],
+ s[-2 * p], s[-1 * p],
+ s[0 * p], s[1 * p]);
+ vp8_simple_filter(mask,
+ s - 2 * p, s - 1 * p,
+ s, s + 1 * p);
+ ++s;
+ } while (++i < 16);
}
void vp8_loop_filter_simple_vertical_edge_c
(
- unsigned char *s,
- int p,
- const unsigned char *blimit
-)
-{
- signed char mask = 0;
- int i = 0;
-
- do
- {
- mask = vp8_simple_filter_mask(blimit[0], s[-2], s[-1], s[0], s[1]);
- vp8_simple_filter(mask, s - 2, s - 1, s, s + 1);
- s += p;
- }
- while (++i < 16);
+ unsigned char *s,
+ int p,
+ const unsigned char *blimit
+) {
+ signed char mask = 0;
+ int i = 0;
+
+ do {
+ mask = vp8_simple_filter_mask(blimit[0], s[-2], s[-1], s[0], s[1]);
+ vp8_simple_filter(mask, s - 2, s - 1, s, s + 1);
+ s += p;
+ } while (++i < 16);
}
diff --git a/vp8/common/maskingmv.c b/vp8/common/maskingmv.c
index d01a18fc8..72109378d 100644
--- a/vp8/common/maskingmv.c
+++ b/vp8/common/maskingmv.c
@@ -12,183 +12,176 @@
#include <stdlib.h>
#include <string.h>
extern unsigned int vp8_sad16x16_sse3(
- unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr,
- int ref_stride,
- int max_err);
+ unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr,
+ int ref_stride,
+ int max_err);
extern void vp8_sad16x16x3_sse3(
- unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr,
- int ref_stride,
- int *results);
+ unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr,
+ int ref_stride,
+ int *results);
extern int vp8_growmaskmb_sse3(
- unsigned char *om,
- unsigned char *nm);
+ unsigned char *om,
+ unsigned char *nm);
extern void vp8_makemask_sse3(
- unsigned char *y,
- unsigned char *u,
- unsigned char *v,
- unsigned char *ym,
- int yp,
- int uvp,
- int ys,
- int us,
- int vs,
- int yt,
- int ut,
- int vt);
+ unsigned char *y,
+ unsigned char *u,
+ unsigned char *v,
+ unsigned char *ym,
+ int yp,
+ int uvp,
+ int ys,
+ int us,
+ int vs,
+ int yt,
+ int ut,
+ int vt);
unsigned int vp8_sad16x16_unmasked_wmt(
- unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr,
- int ref_stride,
- unsigned char *mask);
+ unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned char *mask);
unsigned int vp8_sad16x16_masked_wmt(
- unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr,
- int ref_stride,
- unsigned char *mask);
+ unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned char *mask);
unsigned int vp8_masked_predictor_wmt(
- unsigned char *masked,
- unsigned char *unmasked,
- int src_stride,
- unsigned char *dst_ptr,
- int dst_stride,
- unsigned char *mask);
+ unsigned char *masked,
+ unsigned char *unmasked,
+ int src_stride,
+ unsigned char *dst_ptr,
+ int dst_stride,
+ unsigned char *mask);
unsigned int vp8_masked_predictor_uv_wmt(
- unsigned char *masked,
- unsigned char *unmasked,
- int src_stride,
- unsigned char *dst_ptr,
- int dst_stride,
- unsigned char *mask);
+ unsigned char *masked,
+ unsigned char *unmasked,
+ int src_stride,
+ unsigned char *dst_ptr,
+ int dst_stride,
+ unsigned char *mask);
unsigned int vp8_uv_from_y_mask(
- unsigned char *ymask,
- unsigned char *uvmask);
-int yp=16;
-unsigned char sxy[]=
-{
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,80,120,120,90,90,90,90,90,80,120,120,90,90,90,90,90
+ unsigned char *ymask,
+ unsigned char *uvmask);
+int yp = 16;
+unsigned char sxy[] = {
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 80, 120, 120, 90, 90, 90, 90, 90, 80, 120, 120, 90, 90, 90, 90, 90
};
-unsigned char sts[]=
-{
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+unsigned char sts[] = {
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
};
-unsigned char str[]=
-{
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
+unsigned char str[] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
-unsigned char y[]=
-{
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,
-60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,40,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,
-40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,40,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,
-40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,40,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40,
-40,40,40,60,60,60,60,40,40,40,40,60,60,60,60,40
+unsigned char y[] = {
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40,
+ 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40,
+ 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40, 40,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40,
+ 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40, 40,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40,
+ 40, 40, 40, 60, 60, 60, 60, 40, 40, 40, 40, 60, 60, 60, 60, 40
};
-int uvp=8;
-unsigned char u[]=
-{
-90,80,70,70,90,90,90,17,
-90,80,70,70,90,90,90,17,
-84,70,70,90,90,90,17,17,
-84,70,70,90,90,90,17,17,
-80,70,70,90,90,90,17,17,
-90,80,70,70,90,90,90,17,
-90,80,70,70,90,90,90,17,
-90,80,70,70,90,90,90,17
+int uvp = 8;
+unsigned char u[] = {
+ 90, 80, 70, 70, 90, 90, 90, 17,
+ 90, 80, 70, 70, 90, 90, 90, 17,
+ 84, 70, 70, 90, 90, 90, 17, 17,
+ 84, 70, 70, 90, 90, 90, 17, 17,
+ 80, 70, 70, 90, 90, 90, 17, 17,
+ 90, 80, 70, 70, 90, 90, 90, 17,
+ 90, 80, 70, 70, 90, 90, 90, 17,
+ 90, 80, 70, 70, 90, 90, 90, 17
};
-unsigned char v[]=
-{
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80,
-80,80,80,80,80,80,80,80
+unsigned char v[] = {
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80
};
unsigned char ym[256];
unsigned char uvm[64];
-typedef struct
-{
- unsigned char y;
- unsigned char yt;
- unsigned char u;
- unsigned char ut;
- unsigned char v;
- unsigned char vt;
- unsigned char use;
+typedef struct {
+ unsigned char y;
+ unsigned char yt;
+ unsigned char u;
+ unsigned char ut;
+ unsigned char v;
+ unsigned char vt;
+ unsigned char use;
} COLOR_SEG_ELEMENT;
/*
@@ -199,474 +192,430 @@ COLOR_SEG_ELEMENT segmentation[]=
};
*/
-COLOR_SEG_ELEMENT segmentation[]=
-{
- { 79,44,92,44, 237,60, 1},
+COLOR_SEG_ELEMENT segmentation[] = {
+ { 79, 44, 92, 44, 237, 60, 1},
};
-unsigned char pixel_mask(unsigned char y,unsigned char u,unsigned char v,
- COLOR_SEG_ELEMENT sgm[],
- int c)
-{
- COLOR_SEG_ELEMENT *s=sgm;
- unsigned char m =0;
- int i;
- for(i=0;i<c;i++,s++)
- m |= ( abs(y-s->y)< s->yt &&
- abs(u-s->u)< s->ut &&
- abs(v-s->v)< s->vt ? 255 : 0 );
-
- return m;
+unsigned char pixel_mask(unsigned char y, unsigned char u, unsigned char v,
+ COLOR_SEG_ELEMENT sgm[],
+ int c) {
+ COLOR_SEG_ELEMENT *s = sgm;
+ unsigned char m = 0;
+ int i;
+ for (i = 0; i < c; i++, s++)
+ m |= (abs(y - s->y) < s->yt &&
+ abs(u - s->u) < s->ut &&
+ abs(v - s->v) < s->vt ? 255 : 0);
+
+ return m;
}
int neighbors[256][8];
-int makeneighbors(void)
-{
- int i,j;
- for(i=0;i<256;i++)
- {
- int r=(i>>4),c=(i&15);
- int ni=0;
- for(j=0;j<8;j++)
- neighbors[i][j]=i;
- for(j=0;j<256;j++)
- {
- int nr=(j>>4),nc=(j&15);
- if(abs(nr-r)<2&&abs(nc-c)<2)
- neighbors[i][ni++]=j;
- }
+int makeneighbors(void) {
+ int i, j;
+ for (i = 0; i < 256; i++) {
+ int r = (i >> 4), c = (i & 15);
+ int ni = 0;
+ for (j = 0; j < 8; j++)
+ neighbors[i][j] = i;
+ for (j = 0; j < 256; j++) {
+ int nr = (j >> 4), nc = (j & 15);
+ if (abs(nr - r) < 2 && abs(nc - c) < 2)
+ neighbors[i][ni++] = j;
}
- return 0;
+ }
+ return 0;
}
-void grow_ymask(unsigned char *ym)
-{
- unsigned char nym[256];
- int i,j;
-
- for(i=0;i<256;i++)
- {
- nym[i]=ym[i];
- for(j=0;j<8;j++)
- {
- nym[i]|=ym[neighbors[i][j]];
- }
+void grow_ymask(unsigned char *ym) {
+ unsigned char nym[256];
+ int i, j;
+
+ for (i = 0; i < 256; i++) {
+ nym[i] = ym[i];
+ for (j = 0; j < 8; j++) {
+ nym[i] |= ym[neighbors[i][j]];
}
- for(i=0;i<256;i++)
- ym[i]=nym[i];
+ }
+ for (i = 0; i < 256; i++)
+ ym[i] = nym[i];
}
void make_mb_mask(unsigned char *y, unsigned char *u, unsigned char *v,
unsigned char *ym, unsigned char *uvm,
int yp, int uvp,
COLOR_SEG_ELEMENT sgm[],
- int count)
-{
- int r,c;
- unsigned char *oym = ym;
-
- memset(ym,20,256);
- for(r=0;r<8;r++,uvm+=8,u+=uvp,v+=uvp,y+=(yp+yp),ym+=32)
- for(c=0;c<8;c++)
- {
- int y1=y[c<<1];
- int u1=u[c];
- int v1=v[c];
- int m = pixel_mask(y1,u1,v1,sgm,count);
- uvm[c] = m;
- ym[c<<1] = uvm[c];// = pixel_mask(y[c<<1],u[c],v[c],sgm,count);
- ym[(c<<1)+1] = pixel_mask(y[1+(c<<1)],u[c],v[c],sgm,count);
- ym[(c<<1)+16] = pixel_mask(y[yp+(c<<1)],u[c],v[c],sgm,count);
- ym[(c<<1)+17] = pixel_mask(y[1+yp+(c<<1)],u[c],v[c],sgm,count);
- }
- grow_ymask(oym);
+ int count) {
+ int r, c;
+ unsigned char *oym = ym;
+
+ memset(ym, 20, 256);
+ for (r = 0; r < 8; r++, uvm += 8, u += uvp, v += uvp, y += (yp + yp), ym += 32)
+ for (c = 0; c < 8; c++) {
+ int y1 = y[c << 1];
+ int u1 = u[c];
+ int v1 = v[c];
+ int m = pixel_mask(y1, u1, v1, sgm, count);
+ uvm[c] = m;
+ ym[c << 1] = uvm[c]; // = pixel_mask(y[c<<1],u[c],v[c],sgm,count);
+ ym[(c << 1) + 1] = pixel_mask(y[1 + (c << 1)], u[c], v[c], sgm, count);
+ ym[(c << 1) + 16] = pixel_mask(y[yp + (c << 1)], u[c], v[c], sgm, count);
+ ym[(c << 1) + 17] = pixel_mask(y[1 + yp + (c << 1)], u[c], v[c], sgm, count);
+ }
+ grow_ymask(oym);
}
int masked_sad(unsigned char *src, int p, unsigned char *dst, int dp,
- unsigned char *ym )
-{
- int i,j;
- unsigned sad = 0;
- for(i=0;i<16;i++,src+=p,dst+=dp,ym+=16)
- for(j=0;j<16;j++)
- if(ym[j])
- sad+= abs(src[j]-dst[j]);
-
- return sad;
+ unsigned char *ym) {
+ int i, j;
+ unsigned sad = 0;
+ for (i = 0; i < 16; i++, src += p, dst += dp, ym += 16)
+ for (j = 0; j < 16; j++)
+ if (ym[j])
+ sad += abs(src[j] - dst[j]);
+
+ return sad;
}
-int compare_masks(unsigned char *sym, unsigned char *ym)
-{
- int i,j;
- unsigned sad = 0;
- for(i=0;i<16;i++,sym += 16,ym+=16)
- for(j=0;j<16;j++)
- sad+= (sym[j]!=ym[j]?1:0);
+int compare_masks(unsigned char *sym, unsigned char *ym) {
+ int i, j;
+ unsigned sad = 0;
+ for (i = 0; i < 16; i++, sym += 16, ym += 16)
+ for (j = 0; j < 16; j++)
+ sad += (sym[j] != ym[j] ? 1 : 0);
- return sad;
+ return sad;
}
int unmasked_sad(unsigned char *src, int p, unsigned char *dst, int dp,
- unsigned char *ym)
-{
- int i,j;
- unsigned sad = 0;
- for(i=0;i<16;i++,src+=p,dst+=dp,ym+=16)
- for(j=0;j<16;j++)
- if(!ym[j])
- sad+= abs(src[j]-dst[j]);
-
- return sad;
+ unsigned char *ym) {
+ int i, j;
+ unsigned sad = 0;
+ for (i = 0; i < 16; i++, src += p, dst += dp, ym += 16)
+ for (j = 0; j < 16; j++)
+ if (!ym[j])
+ sad += abs(src[j] - dst[j]);
+
+ return sad;
}
-int masked_motion_search( unsigned char *y, unsigned char *u, unsigned char *v,
- int yp, int uvp,
- unsigned char *dy, unsigned char *du, unsigned char *dv,
- int dyp, int duvp,
- COLOR_SEG_ELEMENT sgm[],
- int count,
- int *mi,
- int *mj,
- int *ui,
- int *uj,
- int *wm)
-{
- int i,j;
-
- unsigned char ym[256];
- unsigned char uvm[64];
- unsigned char dym[256];
- unsigned char duvm[64];
- unsigned int e = 0 ;
- int beste=256;
- int bmi=-32,bmj=-32;
- int bui=-32,buj=-32;
- int beste1=256;
- int bmi1=-32,bmj1=-32;
- int bui1=-32,buj1=-32;
- int obeste;
-
- // first try finding best mask and then unmasked
- beste = 0xffffffff;
-
- // find best unmasked mv
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- unsigned char *duz = i/2*duvp + du;
- unsigned char *dvz = i/2*duvp + dv;
- for(j=-32;j<32;j++)
- {
- // 0,0 masked destination
- make_mb_mask(dyz+j,duz+j/2, dvz+j/2, dym, duvm, dyp, duvp,sgm,count);
-
- e = unmasked_sad(y, yp, dyz+j, dyp, dym );
-
- if(e<beste)
- {
- bui=i;
- buj=j;
- beste=e;
- }
- }
+int masked_motion_search(unsigned char *y, unsigned char *u, unsigned char *v,
+ int yp, int uvp,
+ unsigned char *dy, unsigned char *du, unsigned char *dv,
+ int dyp, int duvp,
+ COLOR_SEG_ELEMENT sgm[],
+ int count,
+ int *mi,
+ int *mj,
+ int *ui,
+ int *uj,
+ int *wm) {
+ int i, j;
+
+ unsigned char ym[256];
+ unsigned char uvm[64];
+ unsigned char dym[256];
+ unsigned char duvm[64];
+ unsigned int e = 0;
+ int beste = 256;
+ int bmi = -32, bmj = -32;
+ int bui = -32, buj = -32;
+ int beste1 = 256;
+ int bmi1 = -32, bmj1 = -32;
+ int bui1 = -32, buj1 = -32;
+ int obeste;
+
+ // first try finding best mask and then unmasked
+ beste = 0xffffffff;
+
+ // find best unmasked mv
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ unsigned char *duz = i / 2 * duvp + du;
+ unsigned char *dvz = i / 2 * duvp + dv;
+ for (j = -32; j < 32; j++) {
+ // 0,0 masked destination
+ make_mb_mask(dyz + j, duz + j / 2, dvz + j / 2, dym, duvm, dyp, duvp, sgm, count);
+
+ e = unmasked_sad(y, yp, dyz + j, dyp, dym);
+
+ if (e < beste) {
+ bui = i;
+ buj = j;
+ beste = e;
+ }
}
- //bui=0;buj=0;
- // best mv masked destination
- make_mb_mask(dy+bui*dyp+buj,du+bui/2*duvp+buj/2, dv+bui/2*duvp+buj/2,
- dym, duvm, dyp, duvp,sgm,count);
-
- obeste = beste;
- beste = 0xffffffff;
-
- // find best masked
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- for(j=-32;j<32;j++)
- {
- e = masked_sad(y, yp, dyz+j, dyp, dym );
-
- if(e<beste)
- {
- bmi=i;
- bmj=j;
- beste=e;
- }
- }
+ }
+ // bui=0;buj=0;
+ // best mv masked destination
+ make_mb_mask(dy + bui * dyp + buj, du + bui / 2 * duvp + buj / 2, dv + bui / 2 * duvp + buj / 2,
+ dym, duvm, dyp, duvp, sgm, count);
+
+ obeste = beste;
+ beste = 0xffffffff;
+
+ // find best masked
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ for (j = -32; j < 32; j++) {
+ e = masked_sad(y, yp, dyz + j, dyp, dym);
+
+ if (e < beste) {
+ bmi = i;
+ bmj = j;
+ beste = e;
+ }
}
- beste1=beste+obeste;
- bmi1=bmi;bmj1=bmj;
- bui1=bui;buj1=buj;
-
- beste = 0xffffffff;
- // source mask
- make_mb_mask(y,u, v, ym, uvm, yp, uvp,sgm,count);
-
- // find best mask
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- unsigned char *duz = i/2*duvp + du;
- unsigned char *dvz = i/2*duvp + dv;
- for(j=-32;j<32;j++)
- {
- // 0,0 masked destination
- make_mb_mask(dyz+j,duz+j/2, dvz+j/2, dym, duvm, dyp, duvp,sgm,count);
-
- e = compare_masks(ym, dym);
-
- if(e<beste)
- {
- bmi=i;
- bmj=j;
- beste=e;
- }
- }
+ }
+ beste1 = beste + obeste;
+ bmi1 = bmi;
+ bmj1 = bmj;
+ bui1 = bui;
+ buj1 = buj;
+
+ beste = 0xffffffff;
+ // source mask
+ make_mb_mask(y, u, v, ym, uvm, yp, uvp, sgm, count);
+
+ // find best mask
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ unsigned char *duz = i / 2 * duvp + du;
+ unsigned char *dvz = i / 2 * duvp + dv;
+ for (j = -32; j < 32; j++) {
+ // 0,0 masked destination
+ make_mb_mask(dyz + j, duz + j / 2, dvz + j / 2, dym, duvm, dyp, duvp, sgm, count);
+
+ e = compare_masks(ym, dym);
+
+ if (e < beste) {
+ bmi = i;
+ bmj = j;
+ beste = e;
+ }
}
+ }
- // best mv masked destination
- make_mb_mask(dy+bmi*dyp+bmj,du+bmi/2*duvp+bmj/2, dv+bmi/2*duvp+bmj/2,
- dym, duvm, dyp, duvp,sgm,count);
+ // best mv masked destination
+ make_mb_mask(dy + bmi * dyp + bmj, du + bmi / 2 * duvp + bmj / 2, dv + bmi / 2 * duvp + bmj / 2,
+ dym, duvm, dyp, duvp, sgm, count);
- obeste = masked_sad(y, yp, dy+bmi*dyp+bmj, dyp, dym );
+ obeste = masked_sad(y, yp, dy + bmi * dyp + bmj, dyp, dym);
- beste = 0xffffffff;
+ beste = 0xffffffff;
- // find best unmasked mv
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- for(j=-32;j<32;j++)
- {
- e = unmasked_sad(y, yp, dyz+j, dyp, dym );
+ // find best unmasked mv
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ for (j = -32; j < 32; j++) {
+ e = unmasked_sad(y, yp, dyz + j, dyp, dym);
- if(e<beste)
- {
- bui=i;
- buj=j;
- beste=e;
- }
- }
+ if (e < beste) {
+ bui = i;
+ buj = j;
+ beste = e;
+ }
}
- beste += obeste;
-
-
- if(beste<beste1)
- {
- *mi = bmi;
- *mj = bmj;
- *ui = bui;
- *uj = buj;
- *wm = 1;
- }
- else
- {
- *mi = bmi1;
- *mj = bmj1;
- *ui = bui1;
- *uj = buj1;
- *wm = 0;
-
- }
- return 0;
+ }
+ beste += obeste;
+
+
+ if (beste < beste1) {
+ *mi = bmi;
+ *mj = bmj;
+ *ui = bui;
+ *uj = buj;
+ *wm = 1;
+ } else {
+ *mi = bmi1;
+ *mj = bmj1;
+ *ui = bui1;
+ *uj = buj1;
+ *wm = 0;
+
+ }
+ return 0;
}
int predict(unsigned char *src, int p, unsigned char *dst, int dp,
- unsigned char *ym, unsigned char *prd )
-{
- int i,j;
- for(i=0;i<16;i++,src+=p,dst+=dp,ym+=16, prd+=16)
- for(j=0;j<16;j++)
- prd[j]=(ym[j] ? src[j]:dst[j]);
- return 0;
+ unsigned char *ym, unsigned char *prd) {
+ int i, j;
+ for (i = 0; i < 16; i++, src += p, dst += dp, ym += 16, prd += 16)
+ for (j = 0; j < 16; j++)
+ prd[j] = (ym[j] ? src[j] : dst[j]);
+ return 0;
}
-int fast_masked_motion_search( unsigned char *y, unsigned char *u, unsigned char *v,
- int yp, int uvp,
- unsigned char *dy, unsigned char *du, unsigned char *dv,
- int dyp, int duvp,
- COLOR_SEG_ELEMENT sgm[],
- int count,
- int *mi,
- int *mj,
- int *ui,
- int *uj,
- int *wm)
-{
- int i,j;
-
- unsigned char ym[256];
- unsigned char ym2[256];
- unsigned char uvm[64];
- unsigned char dym2[256];
- unsigned char dym[256];
- unsigned char duvm[64];
- unsigned int e = 0 ;
- int beste=256;
- int bmi=-32,bmj=-32;
- int bui=-32,buj=-32;
- int beste1=256;
- int bmi1=-32,bmj1=-32;
- int bui1=-32,buj1=-32;
- int obeste;
-
- // first try finding best mask and then unmasked
- beste = 0xffffffff;
+int fast_masked_motion_search(unsigned char *y, unsigned char *u, unsigned char *v,
+ int yp, int uvp,
+ unsigned char *dy, unsigned char *du, unsigned char *dv,
+ int dyp, int duvp,
+ COLOR_SEG_ELEMENT sgm[],
+ int count,
+ int *mi,
+ int *mj,
+ int *ui,
+ int *uj,
+ int *wm) {
+ int i, j;
+
+ unsigned char ym[256];
+ unsigned char ym2[256];
+ unsigned char uvm[64];
+ unsigned char dym2[256];
+ unsigned char dym[256];
+ unsigned char duvm[64];
+ unsigned int e = 0;
+ int beste = 256;
+ int bmi = -32, bmj = -32;
+ int bui = -32, buj = -32;
+ int beste1 = 256;
+ int bmi1 = -32, bmj1 = -32;
+ int bui1 = -32, buj1 = -32;
+ int obeste;
+
+ // first try finding best mask and then unmasked
+ beste = 0xffffffff;
#if 0
- for(i=0;i<16;i++)
- {
- unsigned char *dy = i*yp + y;
- for(j=0;j<16;j++)
- printf("%2x",dy[j]);
- printf("\n");
- }
+ for (i = 0; i < 16; i++) {
+ unsigned char *dy = i * yp + y;
+ for (j = 0; j < 16; j++)
+ printf("%2x", dy[j]);
printf("\n");
+ }
+ printf("\n");
- for(i=-32;i<48;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- for(j=-32;j<48;j++)
- printf("%2x",dyz[j]);
- printf("\n");
- }
+ for (i = -32; i < 48; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ for (j = -32; j < 48; j++)
+ printf("%2x", dyz[j]);
+ printf("\n");
+ }
#endif
- // find best unmasked mv
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- unsigned char *duz = i/2*duvp + du;
- unsigned char *dvz = i/2*duvp + dv;
- for(j=-32;j<32;j++)
- {
- // 0,0 masked destination
- vp8_makemask_sse3(dyz+j,duz+j/2, dvz+j/2, dym, dyp, duvp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
-
- vp8_growmaskmb_sse3(dym,dym2);
-
- e = vp8_sad16x16_unmasked_wmt(y, yp, dyz+j, dyp, dym2 );
-
- if(e<beste)
- {
- bui=i;
- buj=j;
- beste=e;
- }
- }
+ // find best unmasked mv
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ unsigned char *duz = i / 2 * duvp + du;
+ unsigned char *dvz = i / 2 * duvp + dv;
+ for (j = -32; j < 32; j++) {
+ // 0,0 masked destination
+ vp8_makemask_sse3(dyz + j, duz + j / 2, dvz + j / 2, dym, dyp, duvp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+
+ vp8_growmaskmb_sse3(dym, dym2);
+
+ e = vp8_sad16x16_unmasked_wmt(y, yp, dyz + j, dyp, dym2);
+
+ if (e < beste) {
+ bui = i;
+ buj = j;
+ beste = e;
+ }
}
- //bui=0;buj=0;
- // best mv masked destination
-
- vp8_makemask_sse3(dy+bui*dyp+buj,du+bui/2*duvp+buj/2, dv+bui/2*duvp+buj/2,
- dym, dyp, duvp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
-
- vp8_growmaskmb_sse3(dym,dym2);
-
- obeste = beste;
- beste = 0xffffffff;
-
- // find best masked
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- for(j=-32;j<32;j++)
- {
- e = vp8_sad16x16_masked_wmt(y, yp, dyz+j, dyp, dym2 );
- if(e<beste)
- {
- bmi=i;
- bmj=j;
- beste=e;
- }
- }
+ }
+ // bui=0;buj=0;
+ // best mv masked destination
+
+ vp8_makemask_sse3(dy + bui * dyp + buj, du + bui / 2 * duvp + buj / 2, dv + bui / 2 * duvp + buj / 2,
+ dym, dyp, duvp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+
+ vp8_growmaskmb_sse3(dym, dym2);
+
+ obeste = beste;
+ beste = 0xffffffff;
+
+ // find best masked
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ for (j = -32; j < 32; j++) {
+ e = vp8_sad16x16_masked_wmt(y, yp, dyz + j, dyp, dym2);
+ if (e < beste) {
+ bmi = i;
+ bmj = j;
+ beste = e;
+ }
}
- beste1=beste+obeste;
- bmi1=bmi;bmj1=bmj;
- bui1=bui;buj1=buj;
-
- // source mask
- vp8_makemask_sse3(y,u, v,
- ym, yp, uvp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
-
- vp8_growmaskmb_sse3(ym,ym2);
-
- // find best mask
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- unsigned char *duz = i/2*duvp + du;
- unsigned char *dvz = i/2*duvp + dv;
- for(j=-32;j<32;j++)
- {
- // 0,0 masked destination
- vp8_makemask_sse3(dyz+j,duz+j/2, dvz+j/2, dym, dyp, duvp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
-
- vp8_growmaskmb_sse3(dym,dym2);
-
- e = compare_masks(ym2, dym2);
-
- if(e<beste)
- {
- bmi=i;
- bmj=j;
- beste=e;
- }
- }
+ }
+ beste1 = beste + obeste;
+ bmi1 = bmi;
+ bmj1 = bmj;
+ bui1 = bui;
+ buj1 = buj;
+
+ // source mask
+ vp8_makemask_sse3(y, u, v,
+ ym, yp, uvp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+
+ vp8_growmaskmb_sse3(ym, ym2);
+
+ // find best mask
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ unsigned char *duz = i / 2 * duvp + du;
+ unsigned char *dvz = i / 2 * duvp + dv;
+ for (j = -32; j < 32; j++) {
+ // 0,0 masked destination
+ vp8_makemask_sse3(dyz + j, duz + j / 2, dvz + j / 2, dym, dyp, duvp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+
+ vp8_growmaskmb_sse3(dym, dym2);
+
+ e = compare_masks(ym2, dym2);
+
+ if (e < beste) {
+ bmi = i;
+ bmj = j;
+ beste = e;
+ }
}
+ }
- vp8_makemask_sse3(dy+bmi*dyp+bmj,du+bmi/2*duvp+bmj/2, dv+bmi/2*duvp+bmj/2,
- dym, dyp, duvp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
+ vp8_makemask_sse3(dy + bmi * dyp + bmj, du + bmi / 2 * duvp + bmj / 2, dv + bmi / 2 * duvp + bmj / 2,
+ dym, dyp, duvp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
- vp8_growmaskmb_sse3(dym,dym2);
+ vp8_growmaskmb_sse3(dym, dym2);
- obeste = vp8_sad16x16_masked_wmt(y, yp, dy+bmi*dyp+bmj, dyp, dym2 );
+ obeste = vp8_sad16x16_masked_wmt(y, yp, dy + bmi * dyp + bmj, dyp, dym2);
- beste = 0xffffffff;
+ beste = 0xffffffff;
- // find best unmasked mv
- for(i=-32;i<32;i++)
- {
- unsigned char *dyz = i*dyp + dy;
- for(j=-32;j<32;j++)
- {
- e = vp8_sad16x16_unmasked_wmt(y, yp, dyz+j, dyp, dym2 );
-
- if(e<beste)
- {
- bui=i;
- buj=j;
- beste=e;
- }
- }
- }
- beste += obeste;
-
- if(beste<beste1)
- {
- *mi = bmi;
- *mj = bmj;
- *ui = bui;
- *uj = buj;
- *wm = 1;
- }
- else
- {
- *mi = bmi1;
- *mj = bmj1;
- *ui = bui1;
- *uj = buj1;
- *wm = 0;
- beste=beste1;
+ // find best unmasked mv
+ for (i = -32; i < 32; i++) {
+ unsigned char *dyz = i * dyp + dy;
+ for (j = -32; j < 32; j++) {
+ e = vp8_sad16x16_unmasked_wmt(y, yp, dyz + j, dyp, dym2);
+ if (e < beste) {
+ bui = i;
+ buj = j;
+ beste = e;
+ }
}
- return beste;
+ }
+ beste += obeste;
+
+ if (beste < beste1) {
+ *mi = bmi;
+ *mj = bmj;
+ *ui = bui;
+ *uj = buj;
+ *wm = 1;
+ } else {
+ *mi = bmi1;
+ *mj = bmj1;
+ *ui = bui1;
+ *uj = buj1;
+ *wm = 0;
+ beste = beste1;
+
+ }
+ return beste;
}
int predict_all(unsigned char *ym, unsigned char *um, unsigned char *vm,
@@ -679,177 +628,179 @@ int predict_all(unsigned char *ym, unsigned char *um, unsigned char *vm,
int mj,
int ui,
int uj,
- int wm)
-{
- int i,j;
- unsigned char dym[256];
- unsigned char dym2[256];
- unsigned char duvm[64];
- unsigned char *yu=ym,*uu=um, *vu=vm;
-
- unsigned char *dym3=dym2;
-
- ym+=mi*ymp+mj;
- um+=mi/2*uvmp+mj/2;
- vm+=mi/2*uvmp+mj/2;
-
- yu+=ui*ymp+uj;
- uu+=ui/2*uvmp+uj/2;
- vu+=ui/2*uvmp+uj/2;
-
- // best mv masked destination
- if(wm)
- vp8_makemask_sse3(ym,um, vm, dym, ymp, uvmp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
- else
- vp8_makemask_sse3(yu,uu, vu, dym, ymp, uvmp,
- sgm[0].y,sgm[0].u,sgm[0].v,
- sgm[0].yt,sgm[0].ut,sgm[0].vt);
-
- vp8_growmaskmb_sse3(dym,dym2);
- vp8_masked_predictor_wmt(ym,yu,ymp,yp,ypp,dym3);
- vp8_uv_from_y_mask(dym3,duvm);
- vp8_masked_predictor_uv_wmt(um,uu,uvmp,up,uvpp,duvm);
- vp8_masked_predictor_uv_wmt(vm,vu,uvmp,vp,uvpp,duvm);
-
- return 0;
+ int wm) {
+ int i, j;
+ unsigned char dym[256];
+ unsigned char dym2[256];
+ unsigned char duvm[64];
+ unsigned char *yu = ym, *uu = um, *vu = vm;
+
+ unsigned char *dym3 = dym2;
+
+ ym += mi * ymp + mj;
+ um += mi / 2 * uvmp + mj / 2;
+ vm += mi / 2 * uvmp + mj / 2;
+
+ yu += ui * ymp + uj;
+ uu += ui / 2 * uvmp + uj / 2;
+ vu += ui / 2 * uvmp + uj / 2;
+
+ // best mv masked destination
+ if (wm)
+ vp8_makemask_sse3(ym, um, vm, dym, ymp, uvmp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+ else
+ vp8_makemask_sse3(yu, uu, vu, dym, ymp, uvmp,
+ sgm[0].y, sgm[0].u, sgm[0].v,
+ sgm[0].yt, sgm[0].ut, sgm[0].vt);
+
+ vp8_growmaskmb_sse3(dym, dym2);
+ vp8_masked_predictor_wmt(ym, yu, ymp, yp, ypp, dym3);
+ vp8_uv_from_y_mask(dym3, duvm);
+ vp8_masked_predictor_uv_wmt(um, uu, uvmp, up, uvpp, duvm);
+ vp8_masked_predictor_uv_wmt(vm, vu, uvmp, vp, uvpp, duvm);
+
+ return 0;
}
-unsigned char f0p[1280*720*3/2];
-unsigned char f1p[1280*720*3/2];
-unsigned char prd[1280*720*3/2];
-unsigned char msk[1280*720*3/2];
+unsigned char f0p[1280 * 720 * 3 / 2];
+unsigned char f1p[1280 * 720 * 3 / 2];
+unsigned char prd[1280 * 720 * 3 / 2];
+unsigned char msk[1280 * 720 * 3 / 2];
int mainz(int argc, char *argv[]) {
- FILE *f=fopen(argv[1],"rb");
- FILE *g=fopen(argv[2],"wb");
- int w=atoi(argv[3]),h=atoi(argv[4]);
- int y_stride=w,uv_stride=w/2;
- int r,c;
- unsigned char *f0=f0p,*f1=f1p,*t;
- unsigned char ym[256],uvm[64];
- unsigned char ym2[256],uvm2[64];
- unsigned char ym3[256],uvm3[64];
- int a,b;
-
- COLOR_SEG_ELEMENT last={ 20,20,20,20, 230,20, 1},best;
+ FILE *f = fopen(argv[1], "rb");
+ FILE *g = fopen(argv[2], "wb");
+ int w = atoi(argv[3]), h = atoi(argv[4]);
+ int y_stride = w, uv_stride = w / 2;
+ int r, c;
+ unsigned char *f0 = f0p, *f1 = f1p, *t;
+ unsigned char ym[256], uvm[64];
+ unsigned char ym2[256], uvm2[64];
+ unsigned char ym3[256], uvm3[64];
+ int a, b;
+
+ COLOR_SEG_ELEMENT last = { 20, 20, 20, 20, 230, 20, 1}, best;
#if 0
- makeneighbors();
- COLOR_SEG_ELEMENT segmentation[]=
- {
- { 60,4,80,17,80,10, 1},
- { 40,4,15,10,80,10, 1},
- };
- make_mb_mask(y, u, v,ym2,uvm2,16,8,segmentation,1);
+ makeneighbors();
+ COLOR_SEG_ELEMENT segmentation[] = {
+ { 60, 4, 80, 17, 80, 10, 1},
+ { 40, 4, 15, 10, 80, 10, 1},
+ };
+ make_mb_mask(y, u, v, ym2, uvm2, 16, 8, segmentation, 1);
- vp8_makemask_sse3(y,u,v,ym, (int) 16,(int) 8,
- (int) segmentation[0].y,(int) segmentation[0].u,(int) segmentation[0].v,
- segmentation[0].yt,segmentation[0].ut,segmentation[0].vt);
+ vp8_makemask_sse3(y, u, v, ym, (int) 16, (int) 8,
+ (int) segmentation[0].y, (int) segmentation[0].u, (int) segmentation[0].v,
+ segmentation[0].yt, segmentation[0].ut, segmentation[0].vt);
- vp8_growmaskmb_sse3(ym,ym3);
+ vp8_growmaskmb_sse3(ym, ym3);
- a = vp8_sad16x16_masked_wmt(str,16,sts,16,ym3);
- b = vp8_sad16x16_unmasked_wmt(str,16,sts,16,ym3);
+ a = vp8_sad16x16_masked_wmt(str, 16, sts, 16, ym3);
+ b = vp8_sad16x16_unmasked_wmt(str, 16, sts, 16, ym3);
- vp8_masked_predictor_wmt(str,sts,16,ym,16,ym3);
+ vp8_masked_predictor_wmt(str, sts, 16, ym, 16, ym3);
- vp8_uv_from_y_mask(ym3,uvm3);
+ vp8_uv_from_y_mask(ym3, uvm3);
- return 4;
+ return 4;
#endif
- makeneighbors();
-
-
- memset(prd,128,w*h*3/2);
-
- fread(f0,w*h*3/2,1,f);
-
- while(!feof(f))
- {
- unsigned char *ys=f1,*yd=f0,*yp=prd;
- unsigned char *us=f1+w*h,*ud=f0+w*h,*up=prd+w*h;
- unsigned char *vs=f1+w*h*5/4,*vd=f0+w*h*5/4,*vp=prd+w*h*5/4;
- fread(f1,w*h*3/2,1,f);
-
- ys+=32*y_stride;yd+=32*y_stride;yp+=32*y_stride;
- us+=16*uv_stride;ud+=16*uv_stride;up+=16*uv_stride;
- vs+=16*uv_stride;vd+=16*uv_stride;vp+=16*uv_stride;
- for(r=32;r<h-32;r+=16,
- ys+=16*w,yd+=16*w,yp+=16*w,
- us+=8*uv_stride,ud+=8*uv_stride,up+=8*uv_stride,
- vs+=8*uv_stride,vd+=8*uv_stride,vp+=8*uv_stride)
- {
- for(c=32;c<w-32;c+=16)
- {
- int mi,mj,ui,uj,wm;
- int bmi,bmj,bui,buj,bwm;
- unsigned char ym[256];
-
- if(vp8_sad16x16_sse3( ys+c,y_stride, yd+c,y_stride,0xffff) == 0)
- bmi=bmj=bui=buj=bwm=0;
- else
- {
- COLOR_SEG_ELEMENT cs[5];
- int j;
- unsigned int beste=0xfffffff;
- unsigned int bestj=0;
-
- // try color from last mb segmentation
- cs[0] = last;
-
- // try color segs from 4 pixels in mb recon as segmentation
- cs[1].y = yd[c + y_stride + 1];cs[1].u = ud[c/2 + uv_stride];
- cs[1].v = vd[c/2 + uv_stride];
- cs[1].yt = cs[1].ut = cs[1].vt = 20;
- cs[2].y = yd[c + w + 14];
- cs[2].u = ud[c/2 + uv_stride+7];
- cs[2].v = vd[c/2 + uv_stride+7];
- cs[2].yt = cs[2].ut = cs[2].vt = 20;
- cs[3].y = yd[c + w*14 + 1];
- cs[3].u = ud[c/2 + uv_stride*7];
- cs[3].v = vd[c/2 + uv_stride*7];
- cs[3].yt = cs[3].ut = cs[3].vt = 20;
- cs[4].y = yd[c + w*14 + 14];
- cs[4].u = ud[c/2 + uv_stride*7+7];
- cs[4].v = vd[c/2 + uv_stride*7+7];
- cs[4].yt = cs[4].ut = cs[4].vt = 20;
-
- for(j=0;j<5;j++)
- {
- int e;
-
- e = fast_masked_motion_search(
- ys+c, us+c/2, vs+c/2, y_stride, uv_stride,
- yd+c, ud+c/2, vd+c/2, y_stride, uv_stride,
- &cs[j], 1, &mi,&mj,&ui,&uj,&wm);
-
- if(e<beste)
- {
- bmi=mi;bmj=mj;bui=ui;buj=uj,bwm=wm;
- bestj=j;
- beste=e;
- }
- }
- best = cs[bestj];
- //best = segmentation[0];
- last = best;
- }
- predict_all(yd+c, ud+c/2, vd+c/2, w, uv_stride,
- yp+c, up+c/2, vp+c/2, w, uv_stride,
- &best, 1, bmi,bmj,bui,buj,bwm);
-
+ makeneighbors();
+
+
+ memset(prd, 128, w * h * 3 / 2);
+
+ fread(f0, w * h * 3 / 2, 1, f);
+
+ while (!feof(f)) {
+ unsigned char *ys = f1, *yd = f0, *yp = prd;
+ unsigned char *us = f1 + w * h, *ud = f0 + w * h, *up = prd + w * h;
+ unsigned char *vs = f1 + w * h * 5 / 4, *vd = f0 + w * h * 5 / 4, *vp = prd + w * h * 5 / 4;
+ fread(f1, w * h * 3 / 2, 1, f);
+
+ ys += 32 * y_stride;
+ yd += 32 * y_stride;
+ yp += 32 * y_stride;
+ us += 16 * uv_stride;
+ ud += 16 * uv_stride;
+ up += 16 * uv_stride;
+ vs += 16 * uv_stride;
+ vd += 16 * uv_stride;
+ vp += 16 * uv_stride;
+ for (r = 32; r < h - 32; r += 16,
+ ys += 16 * w, yd += 16 * w, yp += 16 * w,
+ us += 8 * uv_stride, ud += 8 * uv_stride, up += 8 * uv_stride,
+ vs += 8 * uv_stride, vd += 8 * uv_stride, vp += 8 * uv_stride) {
+ for (c = 32; c < w - 32; c += 16) {
+ int mi, mj, ui, uj, wm;
+ int bmi, bmj, bui, buj, bwm;
+ unsigned char ym[256];
+
+ if (vp8_sad16x16_sse3(ys + c, y_stride, yd + c, y_stride, 0xffff) == 0)
+ bmi = bmj = bui = buj = bwm = 0;
+ else {
+ COLOR_SEG_ELEMENT cs[5];
+ int j;
+ unsigned int beste = 0xfffffff;
+ unsigned int bestj = 0;
+
+ // try color from last mb segmentation
+ cs[0] = last;
+
+ // try color segs from 4 pixels in mb recon as segmentation
+ cs[1].y = yd[c + y_stride + 1];
+ cs[1].u = ud[c / 2 + uv_stride];
+ cs[1].v = vd[c / 2 + uv_stride];
+ cs[1].yt = cs[1].ut = cs[1].vt = 20;
+ cs[2].y = yd[c + w + 14];
+ cs[2].u = ud[c / 2 + uv_stride + 7];
+ cs[2].v = vd[c / 2 + uv_stride + 7];
+ cs[2].yt = cs[2].ut = cs[2].vt = 20;
+ cs[3].y = yd[c + w * 14 + 1];
+ cs[3].u = ud[c / 2 + uv_stride * 7];
+ cs[3].v = vd[c / 2 + uv_stride * 7];
+ cs[3].yt = cs[3].ut = cs[3].vt = 20;
+ cs[4].y = yd[c + w * 14 + 14];
+ cs[4].u = ud[c / 2 + uv_stride * 7 + 7];
+ cs[4].v = vd[c / 2 + uv_stride * 7 + 7];
+ cs[4].yt = cs[4].ut = cs[4].vt = 20;
+
+ for (j = 0; j < 5; j++) {
+ int e;
+
+ e = fast_masked_motion_search(
+ ys + c, us + c / 2, vs + c / 2, y_stride, uv_stride,
+ yd + c, ud + c / 2, vd + c / 2, y_stride, uv_stride,
+ &cs[j], 1, &mi, &mj, &ui, &uj, &wm);
+
+ if (e < beste) {
+ bmi = mi;
+ bmj = mj;
+ bui = ui;
+ buj = uj, bwm = wm;
+ bestj = j;
+ beste = e;
}
+ }
+ best = cs[bestj];
+ // best = segmentation[0];
+ last = best;
}
- fwrite(prd,w*h*3/2,1,g);
- t=f0;
- f0=f1;
- f1=t;
+ predict_all(yd + c, ud + c / 2, vd + c / 2, w, uv_stride,
+ yp + c, up + c / 2, vp + c / 2, w, uv_stride,
+ &best, 1, bmi, bmj, bui, buj, bwm);
+ }
}
- fclose(f);
- fclose(g);
- return;
+ fwrite(prd, w * h * 3 / 2, 1, g);
+ t = f0;
+ f0 = f1;
+ f1 = t;
+
+ }
+ fclose(f);
+ fclose(g);
+ return;
}
diff --git a/vp8/common/mbpitch.c b/vp8/common/mbpitch.c
index b23cbbe2c..1a8431742 100644
--- a/vp8/common/mbpitch.c
+++ b/vp8/common/mbpitch.c
@@ -11,127 +11,107 @@
#include "blockd.h"
-typedef enum
-{
- PRED = 0,
- DEST = 1
+typedef enum {
+ PRED = 0,
+ DEST = 1
} BLOCKSET;
static void setup_block
(
- BLOCKD *b,
- int mv_stride,
- unsigned char **base,
- unsigned char **base2,
- int Stride,
- int offset,
- BLOCKSET bs
-)
-{
-
- if (bs == DEST)
- {
- b->dst_stride = Stride;
- b->dst = offset;
- b->base_dst = base;
- }
- else
- {
- b->pre_stride = Stride;
- b->pre = offset;
- b->base_pre = base;
- b->base_second_pre = base2;
- }
+ BLOCKD *b,
+ int mv_stride,
+ unsigned char **base,
+ unsigned char **base2,
+ int Stride,
+ int offset,
+ BLOCKSET bs
+) {
+
+ if (bs == DEST) {
+ b->dst_stride = Stride;
+ b->dst = offset;
+ b->base_dst = base;
+ } else {
+ b->pre_stride = Stride;
+ b->pre = offset;
+ b->base_pre = base;
+ b->base_second_pre = base2;
+ }
}
-static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs)
-{
- int block;
+static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) {
+ int block;
- unsigned char **y, **u, **v;
- unsigned char **y2, **u2, **v2;
+ unsigned char **y, **u, **v;
+ unsigned char **y2, **u2, **v2;
- if (bs == DEST)
- {
- y = &x->dst.y_buffer;
- u = &x->dst.u_buffer;
- v = &x->dst.v_buffer;
- }
- else
- {
- y = &x->pre.y_buffer;
- u = &x->pre.u_buffer;
- v = &x->pre.v_buffer;
-
- y2 = &x->second_pre.y_buffer;
- u2 = &x->second_pre.u_buffer;
- v2 = &x->second_pre.v_buffer;
- }
+ if (bs == DEST) {
+ y = &x->dst.y_buffer;
+ u = &x->dst.u_buffer;
+ v = &x->dst.v_buffer;
+ } else {
+ y = &x->pre.y_buffer;
+ u = &x->pre.u_buffer;
+ v = &x->pre.v_buffer;
- for (block = 0; block < 16; block++) /* y blocks */
- {
- setup_block(&x->block[block], x->dst.y_stride, y, y2, x->dst.y_stride,
- (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
- }
+ y2 = &x->second_pre.y_buffer;
+ u2 = &x->second_pre.u_buffer;
+ v2 = &x->second_pre.v_buffer;
+ }
- for (block = 16; block < 20; block++) /* U and V blocks */
- {
- setup_block(&x->block[block], x->dst.uv_stride, u, u2, x->dst.uv_stride,
- ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
+ for (block = 0; block < 16; block++) { /* y blocks */
+ setup_block(&x->block[block], x->dst.y_stride, y, y2, x->dst.y_stride,
+ (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
+ }
- setup_block(&x->block[block+4], x->dst.uv_stride, v, v2, x->dst.uv_stride,
- ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
- }
+ for (block = 16; block < 20; block++) { /* U and V blocks */
+ setup_block(&x->block[block], x->dst.uv_stride, u, u2, x->dst.uv_stride,
+ ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
+
+ setup_block(&x->block[block + 4], x->dst.uv_stride, v, v2, x->dst.uv_stride,
+ ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
+ }
}
-void vp8_setup_block_dptrs(MACROBLOCKD *x)
-{
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- x->block[r*4+c].diff = &x->diff[r * 4 * 16 + c * 4];
- x->block[r*4+c].predictor = x->predictor + r * 4 * 16 + c * 4;
- }
+void vp8_setup_block_dptrs(MACROBLOCKD *x) {
+ int r, c;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ x->block[r * 4 + c].diff = &x->diff[r * 4 * 16 + c * 4];
+ x->block[r * 4 + c].predictor = x->predictor + r * 4 * 16 + c * 4;
}
+ }
- for (r = 0; r < 2; r++)
- {
- for (c = 0; c < 2; c++)
- {
- x->block[16+r*2+c].diff = &x->diff[256 + r * 4 * 8 + c * 4];
- x->block[16+r*2+c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4;
+ for (r = 0; r < 2; r++) {
+ for (c = 0; c < 2; c++) {
+ x->block[16 + r * 2 + c].diff = &x->diff[256 + r * 4 * 8 + c * 4];
+ x->block[16 + r * 2 + c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4;
- }
}
+ }
- for (r = 0; r < 2; r++)
- {
- for (c = 0; c < 2; c++)
- {
- x->block[20+r*2+c].diff = &x->diff[320+ r * 4 * 8 + c * 4];
- x->block[20+r*2+c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4;
+ for (r = 0; r < 2; r++) {
+ for (c = 0; c < 2; c++) {
+ x->block[20 + r * 2 + c].diff = &x->diff[320 + r * 4 * 8 + c * 4];
+ x->block[20 + r * 2 + c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4;
- }
}
+ }
- x->block[24].diff = &x->diff[384];
+ x->block[24].diff = &x->diff[384];
- for (r = 0; r < 25; r++)
- {
- x->block[r].qcoeff = x->qcoeff + r * 16;
- x->block[r].dqcoeff = x->dqcoeff + r * 16;
- }
+ for (r = 0; r < 25; r++) {
+ x->block[r].qcoeff = x->qcoeff + r * 16;
+ x->block[r].dqcoeff = x->dqcoeff + r * 16;
+ }
}
-void vp8_build_block_doffsets(MACROBLOCKD *x)
-{
+void vp8_build_block_doffsets(MACROBLOCKD *x) {
- /* handle the destination pitch features */
- setup_macroblock(x, DEST);
- setup_macroblock(x, PRED);
+ /* handle the destination pitch features */
+ setup_macroblock(x, DEST);
+ setup_macroblock(x, PRED);
}
diff --git a/vp8/common/modecont.c b/vp8/common/modecont.c
index d80e16ee5..5995f5732 100644
--- a/vp8/common/modecont.c
+++ b/vp8/common/modecont.c
@@ -10,33 +10,55 @@
#include "entropy.h"
-const int default_vp8_mode_contexts[6][4] =
-{
- { /* 0 */
- 7, 1, 1, 183},
- { /* 1 */
- 14, 18, 14, 147},
- {/* 2 */
- 135, 64, 57, 68},
- { /* 3 */
- 60, 56, 128, 65},
- {/* 4 */
- 159, 134, 128, 34},
- { /* 5 */
- 234, 188, 128, 28},
+const int default_vp8_mode_contexts[6][4] = {
+ {
+ /* 0 */
+ 7, 1, 1, 183
+ },
+ {
+ /* 1 */
+ 14, 18, 14, 147
+ },
+ {
+ /* 2 */
+ 135, 64, 57, 68
+ },
+ {
+ /* 3 */
+ 60, 56, 128, 65
+ },
+ {
+ /* 4 */
+ 159, 134, 128, 34
+ },
+ {
+ /* 5 */
+ 234, 188, 128, 28
+ },
};
-const int default_vp8_mode_contexts_a[6][4] =
-{
- { /* 0 */
- 4, 1, 1, 143},
- { /* 1 */
- 7, 9, 7, 107},
- {/* 2 */
- 95, 34, 57, 68},
- { /* 3 */
- 95, 56, 128, 65},
- {/* 4 */
- 159, 67, 128, 34},
- { /* 5 */
- 234, 94, 128, 28},
+const int default_vp8_mode_contexts_a[6][4] = {
+ {
+ /* 0 */
+ 4, 1, 1, 143
+ },
+ {
+ /* 1 */
+ 7, 9, 7, 107
+ },
+ {
+ /* 2 */
+ 95, 34, 57, 68
+ },
+ {
+ /* 3 */
+ 95, 56, 128, 65
+ },
+ {
+ /* 4 */
+ 159, 67, 128, 34
+ },
+ {
+ /* 5 */
+ 234, 94, 128, 28
+ },
};
diff --git a/vp8/common/modecontext.c b/vp8/common/modecontext.c
index a31a561c8..47b4596ed 100644
--- a/vp8/common/modecontext.c
+++ b/vp8/common/modecontext.c
@@ -11,136 +11,135 @@
#include "entropymode.h"
-const unsigned int vp8_kf_default_bmode_counts [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES] =
-{
- {
- /*Above Mode : 0*/
- { 43438, 2195, 470, 316, 615, 171, 217, 412, 124, 160, }, /* left_mode 0 */
- { 5722, 2751, 296, 291, 81, 68, 80, 101, 100, 170, }, /* left_mode 1 */
- { 1629, 201, 307, 25, 47, 16, 34, 72, 19, 28, }, /* left_mode 2 */
- { 332, 266, 36, 500, 20, 65, 23, 14, 154, 106, }, /* left_mode 3 */
- { 450, 97, 10, 24, 117, 10, 2, 12, 8, 71, }, /* left_mode 4 */
- { 384, 49, 29, 44, 12, 162, 51, 5, 87, 42, }, /* left_mode 5 */
- { 495, 53, 157, 27, 14, 57, 180, 17, 17, 34, }, /* left_mode 6 */
- { 695, 64, 62, 9, 27, 5, 3, 147, 10, 26, }, /* left_mode 7 */
- { 230, 54, 20, 124, 16, 125, 29, 12, 283, 37, }, /* left_mode 8 */
- { 260, 87, 21, 120, 32, 16, 33, 16, 33, 203, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 1*/
- { 3934, 2573, 355, 137, 128, 87, 133, 117, 37, 27, }, /* left_mode 0 */
- { 1036, 1929, 278, 135, 27, 37, 48, 55, 41, 91, }, /* left_mode 1 */
- { 223, 256, 253, 15, 13, 9, 28, 64, 3, 3, }, /* left_mode 2 */
- { 120, 129, 17, 316, 15, 11, 9, 4, 53, 74, }, /* left_mode 3 */
- { 129, 58, 6, 11, 38, 2, 0, 5, 2, 67, }, /* left_mode 4 */
- { 53, 22, 11, 16, 8, 26, 14, 3, 19, 12, }, /* left_mode 5 */
- { 59, 26, 61, 11, 4, 9, 35, 13, 8, 8, }, /* left_mode 6 */
- { 101, 52, 40, 8, 5, 2, 8, 59, 2, 20, }, /* left_mode 7 */
- { 48, 34, 10, 52, 8, 15, 6, 6, 63, 20, }, /* left_mode 8 */
- { 96, 48, 22, 63, 11, 14, 5, 8, 9, 96, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 2*/
- { 709, 461, 506, 36, 27, 33, 151, 98, 24, 6, }, /* left_mode 0 */
- { 201, 375, 442, 27, 13, 8, 46, 58, 6, 19, }, /* left_mode 1 */
- { 122, 140, 417, 4, 13, 3, 33, 59, 4, 2, }, /* left_mode 2 */
- { 36, 17, 22, 16, 6, 8, 12, 17, 9, 21, }, /* left_mode 3 */
- { 51, 15, 7, 1, 14, 0, 4, 5, 3, 22, }, /* left_mode 4 */
- { 18, 11, 30, 9, 7, 20, 11, 5, 2, 6, }, /* left_mode 5 */
- { 38, 21, 103, 9, 4, 12, 79, 13, 2, 5, }, /* left_mode 6 */
- { 64, 17, 66, 2, 12, 4, 2, 65, 4, 5, }, /* left_mode 7 */
- { 14, 7, 7, 16, 3, 11, 4, 13, 15, 16, }, /* left_mode 8 */
- { 36, 8, 32, 9, 9, 4, 14, 7, 6, 24, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 3*/
- { 1340, 173, 36, 119, 30, 10, 13, 10, 20, 26, }, /* left_mode 0 */
- { 156, 293, 26, 108, 5, 16, 2, 4, 23, 30, }, /* left_mode 1 */
- { 60, 34, 13, 7, 3, 3, 0, 8, 4, 5, }, /* left_mode 2 */
- { 72, 64, 1, 235, 3, 9, 2, 7, 28, 38, }, /* left_mode 3 */
- { 29, 14, 1, 3, 5, 0, 2, 2, 5, 13, }, /* left_mode 4 */
- { 22, 7, 4, 11, 2, 5, 1, 2, 6, 4, }, /* left_mode 5 */
- { 18, 14, 5, 6, 4, 3, 14, 0, 9, 2, }, /* left_mode 6 */
- { 41, 10, 7, 1, 2, 0, 0, 10, 2, 1, }, /* left_mode 7 */
- { 23, 19, 2, 33, 1, 5, 2, 0, 51, 8, }, /* left_mode 8 */
- { 33, 26, 7, 53, 3, 9, 3, 3, 9, 19, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 4*/
- { 410, 165, 43, 31, 66, 15, 30, 54, 8, 17, }, /* left_mode 0 */
- { 115, 64, 27, 18, 30, 7, 11, 15, 4, 19, }, /* left_mode 1 */
- { 31, 23, 25, 1, 7, 2, 2, 10, 0, 5, }, /* left_mode 2 */
- { 17, 4, 1, 6, 8, 2, 7, 5, 5, 21, }, /* left_mode 3 */
- { 120, 12, 1, 2, 83, 3, 0, 4, 1, 40, }, /* left_mode 4 */
- { 4, 3, 1, 2, 1, 2, 5, 0, 3, 6, }, /* left_mode 5 */
- { 10, 2, 13, 6, 6, 6, 8, 2, 4, 5, }, /* left_mode 6 */
- { 58, 10, 5, 1, 28, 1, 1, 33, 1, 9, }, /* left_mode 7 */
- { 8, 2, 1, 4, 2, 5, 1, 1, 2, 10, }, /* left_mode 8 */
- { 76, 7, 5, 7, 18, 2, 2, 0, 5, 45, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 5*/
- { 444, 46, 47, 20, 14, 110, 60, 14, 60, 7, }, /* left_mode 0 */
- { 59, 57, 25, 18, 3, 17, 21, 6, 14, 6, }, /* left_mode 1 */
- { 24, 17, 20, 6, 4, 13, 7, 2, 3, 2, }, /* left_mode 2 */
- { 13, 11, 5, 14, 4, 9, 2, 4, 15, 7, }, /* left_mode 3 */
- { 8, 5, 2, 1, 4, 0, 1, 1, 2, 12, }, /* left_mode 4 */
- { 19, 5, 5, 7, 4, 40, 6, 3, 10, 4, }, /* left_mode 5 */
- { 16, 5, 9, 1, 1, 16, 26, 2, 10, 4, }, /* left_mode 6 */
- { 11, 4, 8, 1, 1, 4, 4, 5, 4, 1, }, /* left_mode 7 */
- { 15, 1, 3, 7, 3, 21, 7, 1, 34, 5, }, /* left_mode 8 */
- { 18, 5, 1, 3, 4, 3, 7, 1, 2, 9, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 6*/
- { 476, 149, 94, 13, 14, 77, 291, 27, 23, 3, }, /* left_mode 0 */
- { 79, 83, 42, 14, 2, 12, 63, 2, 4, 14, }, /* left_mode 1 */
- { 43, 36, 55, 1, 3, 8, 42, 11, 5, 1, }, /* left_mode 2 */
- { 9, 9, 6, 16, 1, 5, 6, 3, 11, 10, }, /* left_mode 3 */
- { 10, 3, 1, 3, 10, 1, 0, 1, 1, 4, }, /* left_mode 4 */
- { 14, 6, 15, 5, 1, 20, 25, 2, 5, 0, }, /* left_mode 5 */
- { 28, 7, 51, 1, 0, 8, 127, 6, 2, 5, }, /* left_mode 6 */
- { 13, 3, 3, 2, 3, 1, 2, 8, 1, 2, }, /* left_mode 7 */
- { 10, 3, 3, 3, 3, 8, 2, 2, 9, 3, }, /* left_mode 8 */
- { 13, 7, 11, 4, 0, 4, 6, 2, 5, 8, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 7*/
- { 376, 135, 119, 6, 32, 8, 31, 224, 9, 3, }, /* left_mode 0 */
- { 93, 60, 54, 6, 13, 7, 8, 92, 2, 12, }, /* left_mode 1 */
- { 74, 36, 84, 0, 3, 2, 9, 67, 2, 1, }, /* left_mode 2 */
- { 19, 4, 4, 8, 8, 2, 4, 7, 6, 16, }, /* left_mode 3 */
- { 51, 7, 4, 1, 77, 3, 0, 14, 1, 15, }, /* left_mode 4 */
- { 7, 7, 5, 7, 4, 7, 4, 5, 0, 3, }, /* left_mode 5 */
- { 18, 2, 19, 2, 2, 4, 12, 11, 1, 2, }, /* left_mode 6 */
- { 129, 6, 27, 1, 21, 3, 0, 189, 0, 6, }, /* left_mode 7 */
- { 9, 1, 2, 8, 3, 7, 0, 5, 3, 3, }, /* left_mode 8 */
- { 20, 4, 5, 10, 4, 2, 7, 17, 3, 16, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 8*/
- { 617, 68, 34, 79, 11, 27, 25, 14, 75, 13, }, /* left_mode 0 */
- { 51, 82, 21, 26, 6, 12, 13, 1, 26, 16, }, /* left_mode 1 */
- { 29, 9, 12, 11, 3, 7, 1, 10, 2, 2, }, /* left_mode 2 */
- { 17, 19, 11, 74, 4, 3, 2, 0, 58, 13, }, /* left_mode 3 */
- { 10, 1, 1, 3, 4, 1, 0, 2, 1, 8, }, /* left_mode 4 */
- { 14, 4, 5, 5, 1, 13, 2, 0, 27, 8, }, /* left_mode 5 */
- { 10, 3, 5, 4, 1, 7, 6, 4, 5, 1, }, /* left_mode 6 */
- { 10, 2, 6, 2, 1, 1, 1, 4, 2, 1, }, /* left_mode 7 */
- { 14, 8, 5, 23, 2, 12, 6, 2, 117, 5, }, /* left_mode 8 */
- { 9, 6, 2, 19, 1, 6, 3, 2, 9, 9, }, /* left_mode 9 */
- },
- {
- /*Above Mode : 9*/
- { 680, 73, 22, 38, 42, 5, 11, 9, 6, 28, }, /* left_mode 0 */
- { 113, 112, 21, 22, 10, 2, 8, 4, 6, 42, }, /* left_mode 1 */
- { 44, 20, 24, 6, 5, 4, 3, 3, 1, 2, }, /* left_mode 2 */
- { 40, 23, 7, 71, 5, 2, 4, 1, 7, 22, }, /* left_mode 3 */
- { 85, 9, 4, 4, 17, 2, 0, 3, 2, 23, }, /* left_mode 4 */
- { 13, 4, 2, 6, 1, 7, 0, 1, 7, 6, }, /* left_mode 5 */
- { 26, 6, 8, 3, 2, 3, 8, 1, 5, 4, }, /* left_mode 6 */
- { 54, 8, 9, 6, 7, 0, 1, 11, 1, 3, }, /* left_mode 7 */
- { 9, 10, 4, 13, 2, 5, 4, 2, 14, 8, }, /* left_mode 8 */
- { 92, 9, 5, 19, 15, 3, 3, 1, 6, 58, }, /* left_mode 9 */
- },
+const unsigned int vp8_kf_default_bmode_counts [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES] = {
+ {
+ /*Above Mode : 0*/
+ { 43438, 2195, 470, 316, 615, 171, 217, 412, 124, 160, }, /* left_mode 0 */
+ { 5722, 2751, 296, 291, 81, 68, 80, 101, 100, 170, }, /* left_mode 1 */
+ { 1629, 201, 307, 25, 47, 16, 34, 72, 19, 28, }, /* left_mode 2 */
+ { 332, 266, 36, 500, 20, 65, 23, 14, 154, 106, }, /* left_mode 3 */
+ { 450, 97, 10, 24, 117, 10, 2, 12, 8, 71, }, /* left_mode 4 */
+ { 384, 49, 29, 44, 12, 162, 51, 5, 87, 42, }, /* left_mode 5 */
+ { 495, 53, 157, 27, 14, 57, 180, 17, 17, 34, }, /* left_mode 6 */
+ { 695, 64, 62, 9, 27, 5, 3, 147, 10, 26, }, /* left_mode 7 */
+ { 230, 54, 20, 124, 16, 125, 29, 12, 283, 37, }, /* left_mode 8 */
+ { 260, 87, 21, 120, 32, 16, 33, 16, 33, 203, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 1*/
+ { 3934, 2573, 355, 137, 128, 87, 133, 117, 37, 27, }, /* left_mode 0 */
+ { 1036, 1929, 278, 135, 27, 37, 48, 55, 41, 91, }, /* left_mode 1 */
+ { 223, 256, 253, 15, 13, 9, 28, 64, 3, 3, }, /* left_mode 2 */
+ { 120, 129, 17, 316, 15, 11, 9, 4, 53, 74, }, /* left_mode 3 */
+ { 129, 58, 6, 11, 38, 2, 0, 5, 2, 67, }, /* left_mode 4 */
+ { 53, 22, 11, 16, 8, 26, 14, 3, 19, 12, }, /* left_mode 5 */
+ { 59, 26, 61, 11, 4, 9, 35, 13, 8, 8, }, /* left_mode 6 */
+ { 101, 52, 40, 8, 5, 2, 8, 59, 2, 20, }, /* left_mode 7 */
+ { 48, 34, 10, 52, 8, 15, 6, 6, 63, 20, }, /* left_mode 8 */
+ { 96, 48, 22, 63, 11, 14, 5, 8, 9, 96, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 2*/
+ { 709, 461, 506, 36, 27, 33, 151, 98, 24, 6, }, /* left_mode 0 */
+ { 201, 375, 442, 27, 13, 8, 46, 58, 6, 19, }, /* left_mode 1 */
+ { 122, 140, 417, 4, 13, 3, 33, 59, 4, 2, }, /* left_mode 2 */
+ { 36, 17, 22, 16, 6, 8, 12, 17, 9, 21, }, /* left_mode 3 */
+ { 51, 15, 7, 1, 14, 0, 4, 5, 3, 22, }, /* left_mode 4 */
+ { 18, 11, 30, 9, 7, 20, 11, 5, 2, 6, }, /* left_mode 5 */
+ { 38, 21, 103, 9, 4, 12, 79, 13, 2, 5, }, /* left_mode 6 */
+ { 64, 17, 66, 2, 12, 4, 2, 65, 4, 5, }, /* left_mode 7 */
+ { 14, 7, 7, 16, 3, 11, 4, 13, 15, 16, }, /* left_mode 8 */
+ { 36, 8, 32, 9, 9, 4, 14, 7, 6, 24, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 3*/
+ { 1340, 173, 36, 119, 30, 10, 13, 10, 20, 26, }, /* left_mode 0 */
+ { 156, 293, 26, 108, 5, 16, 2, 4, 23, 30, }, /* left_mode 1 */
+ { 60, 34, 13, 7, 3, 3, 0, 8, 4, 5, }, /* left_mode 2 */
+ { 72, 64, 1, 235, 3, 9, 2, 7, 28, 38, }, /* left_mode 3 */
+ { 29, 14, 1, 3, 5, 0, 2, 2, 5, 13, }, /* left_mode 4 */
+ { 22, 7, 4, 11, 2, 5, 1, 2, 6, 4, }, /* left_mode 5 */
+ { 18, 14, 5, 6, 4, 3, 14, 0, 9, 2, }, /* left_mode 6 */
+ { 41, 10, 7, 1, 2, 0, 0, 10, 2, 1, }, /* left_mode 7 */
+ { 23, 19, 2, 33, 1, 5, 2, 0, 51, 8, }, /* left_mode 8 */
+ { 33, 26, 7, 53, 3, 9, 3, 3, 9, 19, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 4*/
+ { 410, 165, 43, 31, 66, 15, 30, 54, 8, 17, }, /* left_mode 0 */
+ { 115, 64, 27, 18, 30, 7, 11, 15, 4, 19, }, /* left_mode 1 */
+ { 31, 23, 25, 1, 7, 2, 2, 10, 0, 5, }, /* left_mode 2 */
+ { 17, 4, 1, 6, 8, 2, 7, 5, 5, 21, }, /* left_mode 3 */
+ { 120, 12, 1, 2, 83, 3, 0, 4, 1, 40, }, /* left_mode 4 */
+ { 4, 3, 1, 2, 1, 2, 5, 0, 3, 6, }, /* left_mode 5 */
+ { 10, 2, 13, 6, 6, 6, 8, 2, 4, 5, }, /* left_mode 6 */
+ { 58, 10, 5, 1, 28, 1, 1, 33, 1, 9, }, /* left_mode 7 */
+ { 8, 2, 1, 4, 2, 5, 1, 1, 2, 10, }, /* left_mode 8 */
+ { 76, 7, 5, 7, 18, 2, 2, 0, 5, 45, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 5*/
+ { 444, 46, 47, 20, 14, 110, 60, 14, 60, 7, }, /* left_mode 0 */
+ { 59, 57, 25, 18, 3, 17, 21, 6, 14, 6, }, /* left_mode 1 */
+ { 24, 17, 20, 6, 4, 13, 7, 2, 3, 2, }, /* left_mode 2 */
+ { 13, 11, 5, 14, 4, 9, 2, 4, 15, 7, }, /* left_mode 3 */
+ { 8, 5, 2, 1, 4, 0, 1, 1, 2, 12, }, /* left_mode 4 */
+ { 19, 5, 5, 7, 4, 40, 6, 3, 10, 4, }, /* left_mode 5 */
+ { 16, 5, 9, 1, 1, 16, 26, 2, 10, 4, }, /* left_mode 6 */
+ { 11, 4, 8, 1, 1, 4, 4, 5, 4, 1, }, /* left_mode 7 */
+ { 15, 1, 3, 7, 3, 21, 7, 1, 34, 5, }, /* left_mode 8 */
+ { 18, 5, 1, 3, 4, 3, 7, 1, 2, 9, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 6*/
+ { 476, 149, 94, 13, 14, 77, 291, 27, 23, 3, }, /* left_mode 0 */
+ { 79, 83, 42, 14, 2, 12, 63, 2, 4, 14, }, /* left_mode 1 */
+ { 43, 36, 55, 1, 3, 8, 42, 11, 5, 1, }, /* left_mode 2 */
+ { 9, 9, 6, 16, 1, 5, 6, 3, 11, 10, }, /* left_mode 3 */
+ { 10, 3, 1, 3, 10, 1, 0, 1, 1, 4, }, /* left_mode 4 */
+ { 14, 6, 15, 5, 1, 20, 25, 2, 5, 0, }, /* left_mode 5 */
+ { 28, 7, 51, 1, 0, 8, 127, 6, 2, 5, }, /* left_mode 6 */
+ { 13, 3, 3, 2, 3, 1, 2, 8, 1, 2, }, /* left_mode 7 */
+ { 10, 3, 3, 3, 3, 8, 2, 2, 9, 3, }, /* left_mode 8 */
+ { 13, 7, 11, 4, 0, 4, 6, 2, 5, 8, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 7*/
+ { 376, 135, 119, 6, 32, 8, 31, 224, 9, 3, }, /* left_mode 0 */
+ { 93, 60, 54, 6, 13, 7, 8, 92, 2, 12, }, /* left_mode 1 */
+ { 74, 36, 84, 0, 3, 2, 9, 67, 2, 1, }, /* left_mode 2 */
+ { 19, 4, 4, 8, 8, 2, 4, 7, 6, 16, }, /* left_mode 3 */
+ { 51, 7, 4, 1, 77, 3, 0, 14, 1, 15, }, /* left_mode 4 */
+ { 7, 7, 5, 7, 4, 7, 4, 5, 0, 3, }, /* left_mode 5 */
+ { 18, 2, 19, 2, 2, 4, 12, 11, 1, 2, }, /* left_mode 6 */
+ { 129, 6, 27, 1, 21, 3, 0, 189, 0, 6, }, /* left_mode 7 */
+ { 9, 1, 2, 8, 3, 7, 0, 5, 3, 3, }, /* left_mode 8 */
+ { 20, 4, 5, 10, 4, 2, 7, 17, 3, 16, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 8*/
+ { 617, 68, 34, 79, 11, 27, 25, 14, 75, 13, }, /* left_mode 0 */
+ { 51, 82, 21, 26, 6, 12, 13, 1, 26, 16, }, /* left_mode 1 */
+ { 29, 9, 12, 11, 3, 7, 1, 10, 2, 2, }, /* left_mode 2 */
+ { 17, 19, 11, 74, 4, 3, 2, 0, 58, 13, }, /* left_mode 3 */
+ { 10, 1, 1, 3, 4, 1, 0, 2, 1, 8, }, /* left_mode 4 */
+ { 14, 4, 5, 5, 1, 13, 2, 0, 27, 8, }, /* left_mode 5 */
+ { 10, 3, 5, 4, 1, 7, 6, 4, 5, 1, }, /* left_mode 6 */
+ { 10, 2, 6, 2, 1, 1, 1, 4, 2, 1, }, /* left_mode 7 */
+ { 14, 8, 5, 23, 2, 12, 6, 2, 117, 5, }, /* left_mode 8 */
+ { 9, 6, 2, 19, 1, 6, 3, 2, 9, 9, }, /* left_mode 9 */
+ },
+ {
+ /*Above Mode : 9*/
+ { 680, 73, 22, 38, 42, 5, 11, 9, 6, 28, }, /* left_mode 0 */
+ { 113, 112, 21, 22, 10, 2, 8, 4, 6, 42, }, /* left_mode 1 */
+ { 44, 20, 24, 6, 5, 4, 3, 3, 1, 2, }, /* left_mode 2 */
+ { 40, 23, 7, 71, 5, 2, 4, 1, 7, 22, }, /* left_mode 3 */
+ { 85, 9, 4, 4, 17, 2, 0, 3, 2, 23, }, /* left_mode 4 */
+ { 13, 4, 2, 6, 1, 7, 0, 1, 7, 6, }, /* left_mode 5 */
+ { 26, 6, 8, 3, 2, 3, 8, 1, 5, 4, }, /* left_mode 6 */
+ { 54, 8, 9, 6, 7, 0, 1, 11, 1, 3, }, /* left_mode 7 */
+ { 9, 10, 4, 13, 2, 5, 4, 2, 14, 8, }, /* left_mode 8 */
+ { 92, 9, 5, 19, 15, 3, 3, 1, 6, 58, }, /* left_mode 9 */
+ },
};
diff --git a/vp8/common/mv.h b/vp8/common/mv.h
index 35c4fe947..48c92f958 100644
--- a/vp8/common/mv.h
+++ b/vp8/common/mv.h
@@ -13,16 +13,14 @@
#define __INC_MV_H
#include "vpx/vpx_integer.h"
-typedef struct
-{
- short row;
- short col;
+typedef struct {
+ short row;
+ short col;
} MV;
-typedef union
-{
- uint32_t as_int;
- MV as_mv;
+typedef union {
+ uint32_t as_int;
+ MV as_mv;
} int_mv; /* facilitates faster equality tests and copies */
#endif
diff --git a/vp8/common/onyx.h b/vp8/common/onyx.h
index 8d4cb3e97..3d8f565e5 100644
--- a/vp8/common/onyx.h
+++ b/vp8/common/onyx.h
@@ -22,187 +22,179 @@ extern "C"
#include "vpx_scale/yv12config.h"
#include "type_aliases.h"
#include "ppflags.h"
- typedef int *VP8_PTR;
+ typedef int *VP8_PTR;
- /* Create/destroy static data structures. */
+ /* Create/destroy static data structures. */
- typedef enum
- {
- NORMAL = 0,
- FOURFIVE = 1,
- THREEFIVE = 2,
- ONETWO = 3
+ typedef enum {
+ NORMAL = 0,
+ FOURFIVE = 1,
+ THREEFIVE = 2,
+ ONETWO = 3
- } VPX_SCALING;
+ } VPX_SCALING;
- typedef enum
- {
- VP8_LAST_FLAG = 1,
- VP8_GOLD_FLAG = 2,
- VP8_ALT_FLAG = 4
- } VP8_REFFRAME;
+ typedef enum {
+ VP8_LAST_FLAG = 1,
+ VP8_GOLD_FLAG = 2,
+ VP8_ALT_FLAG = 4
+ } VP8_REFFRAME;
- typedef enum
- {
- USAGE_STREAM_FROM_SERVER = 0x0,
- USAGE_LOCAL_FILE_PLAYBACK = 0x1,
- USAGE_CONSTRAINED_QUALITY = 0x2
- } END_USAGE;
+ typedef enum {
+ USAGE_STREAM_FROM_SERVER = 0x0,
+ USAGE_LOCAL_FILE_PLAYBACK = 0x1,
+ USAGE_CONSTRAINED_QUALITY = 0x2
+ } END_USAGE;
- typedef enum
- {
- MODE_GOODQUALITY = 0x1,
- MODE_BESTQUALITY = 0x2,
- MODE_FIRSTPASS = 0x3,
- MODE_SECONDPASS = 0x4,
- MODE_SECONDPASS_BEST = 0x5,
- } MODE;
+ typedef enum {
+ MODE_GOODQUALITY = 0x1,
+ MODE_BESTQUALITY = 0x2,
+ MODE_FIRSTPASS = 0x3,
+ MODE_SECONDPASS = 0x4,
+ MODE_SECONDPASS_BEST = 0x5,
+ } MODE;
- typedef enum
- {
- FRAMEFLAGS_KEY = 1,
- FRAMEFLAGS_GOLDEN = 2,
- FRAMEFLAGS_ALTREF = 4,
- } FRAMETYPE_FLAGS;
+ typedef enum {
+ FRAMEFLAGS_KEY = 1,
+ FRAMEFLAGS_GOLDEN = 2,
+ FRAMEFLAGS_ALTREF = 4,
+ } FRAMETYPE_FLAGS;
#include <assert.h>
- static __inline void Scale2Ratio(int mode, int *hr, int *hs)
- {
- switch (mode)
- {
- case NORMAL:
- *hr = 1;
- *hs = 1;
- break;
- case FOURFIVE:
- *hr = 4;
- *hs = 5;
- break;
- case THREEFIVE:
- *hr = 3;
- *hs = 5;
- break;
- case ONETWO:
- *hr = 1;
- *hs = 2;
- break;
- default:
- *hr = 1;
- *hs = 1;
- assert(0);
- break;
- }
+ static __inline void Scale2Ratio(int mode, int *hr, int *hs) {
+ switch (mode) {
+ case NORMAL:
+ *hr = 1;
+ *hs = 1;
+ break;
+ case FOURFIVE:
+ *hr = 4;
+ *hs = 5;
+ break;
+ case THREEFIVE:
+ *hr = 3;
+ *hs = 5;
+ break;
+ case ONETWO:
+ *hr = 1;
+ *hs = 2;
+ break;
+ default:
+ *hr = 1;
+ *hs = 1;
+ assert(0);
+ break;
}
-
- typedef struct
- {
- int Version; // 4 versions of bitstream defined 0 best quality/slowest decode, 3 lowest quality/fastest decode
- int Width; // width of data passed to the compressor
- int Height; // height of data passed to the compressor
- double frame_rate; // set to passed in framerate
- int target_bandwidth; // bandwidth to be used in kilobits per second
-
- int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
- int Sharpness; // parameter used for sharpening output: recommendation 0:
- int cpu_used;
- unsigned int rc_max_intra_bitrate_pct;
-
- // mode ->
- //(0)=Realtime/Live Encoding. This mode is optimized for realtim encoding (for example, capturing
- // a television signal or feed from a live camera). ( speed setting controls how fast )
- //(1)=Good Quality Fast Encoding. The encoder balances quality with the amount of time it takes to
- // encode the output. ( speed setting controls how fast )
- //(2)=One Pass - Best Quality. The encoder places priority on the quality of the output over encoding
- // speed. The output is compressed at the highest possible quality. This option takes the longest
- // amount of time to encode. ( speed setting ignored )
- //(3)=Two Pass - First Pass. The encoder generates a file of statistics for use in the second encoding
- // pass. ( speed setting controls how fast )
- //(4)=Two Pass - Second Pass. The encoder uses the statistics that were generated in the first encoding
- // pass to create the compressed output. ( speed setting controls how fast )
- //(5)=Two Pass - Second Pass Best. The encoder uses the statistics that were generated in the first
- // encoding pass to create the compressed output using the highest possible quality, and taking a
- // longer amount of time to encode.. ( speed setting ignored )
- int Mode; //
-
- // Key Framing Operations
- int auto_key; // automatically detect cut scenes and set the keyframes
- int key_freq; // maximum distance to key frame.
-
- int allow_lag; // allow lagged compression (if 0 lagin frames is ignored)
- int lag_in_frames; // how many frames lag before we start encoding
-
- //----------------------------------------------------------------
- // DATARATE CONTROL OPTIONS
-
- int end_usage; // vbr or cbr
-
- // buffer targeting aggressiveness
- int under_shoot_pct;
- int over_shoot_pct;
-
- // buffering parameters
- int starting_buffer_level; // in seconds
- int optimal_buffer_level;
- int maximum_buffer_size;
-
- // controlling quality
- int fixed_q;
- int worst_allowed_q;
- int best_allowed_q;
- int cq_level;
- int lossless;
-
- // two pass datarate control
- int two_pass_vbrbias; // two pass datarate control tweaks
- int two_pass_vbrmin_section;
- int two_pass_vbrmax_section;
- // END DATARATE CONTROL OPTIONS
- //----------------------------------------------------------------
-
-
- // these parameters aren't to be used in final build don't use!!!
- int play_alternate;
- int alt_freq;
-
- int encode_breakout; // early breakout encode threshold : for video conf recommend 800
-
- int arnr_max_frames;
- int arnr_strength ;
- int arnr_type ;
-
- struct vpx_fixed_buf two_pass_stats_in;
- struct vpx_codec_pkt_list *output_pkt_list;
-
- vp8e_tuning tuning;
- } VP8_CONFIG;
-
-
- void vp8_initialize();
-
- VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
- void vp8_remove_compressor(VP8_PTR *comp);
-
- void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
- void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
+ }
+
+ typedef struct {
+ int Version; // 4 versions of bitstream defined 0 best quality/slowest decode, 3 lowest quality/fastest decode
+ int Width; // width of data passed to the compressor
+ int Height; // height of data passed to the compressor
+ double frame_rate; // set to passed in framerate
+ int target_bandwidth; // bandwidth to be used in kilobits per second
+
+ int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
+ int Sharpness; // parameter used for sharpening output: recommendation 0:
+ int cpu_used;
+ unsigned int rc_max_intra_bitrate_pct;
+
+ // mode ->
+ // (0)=Realtime/Live Encoding. This mode is optimized for realtim encoding (for example, capturing
+ // a television signal or feed from a live camera). ( speed setting controls how fast )
+ // (1)=Good Quality Fast Encoding. The encoder balances quality with the amount of time it takes to
+ // encode the output. ( speed setting controls how fast )
+ // (2)=One Pass - Best Quality. The encoder places priority on the quality of the output over encoding
+ // speed. The output is compressed at the highest possible quality. This option takes the longest
+ // amount of time to encode. ( speed setting ignored )
+ // (3)=Two Pass - First Pass. The encoder generates a file of statistics for use in the second encoding
+ // pass. ( speed setting controls how fast )
+ // (4)=Two Pass - Second Pass. The encoder uses the statistics that were generated in the first encoding
+ // pass to create the compressed output. ( speed setting controls how fast )
+ // (5)=Two Pass - Second Pass Best. The encoder uses the statistics that were generated in the first
+ // encoding pass to create the compressed output using the highest possible quality, and taking a
+ // longer amount of time to encode.. ( speed setting ignored )
+ int Mode; //
+
+ // Key Framing Operations
+ int auto_key; // automatically detect cut scenes and set the keyframes
+ int key_freq; // maximum distance to key frame.
+
+ int allow_lag; // allow lagged compression (if 0 lagin frames is ignored)
+ int lag_in_frames; // how many frames lag before we start encoding
+
+ // ----------------------------------------------------------------
+ // DATARATE CONTROL OPTIONS
+
+ int end_usage; // vbr or cbr
+
+ // buffer targeting aggressiveness
+ int under_shoot_pct;
+ int over_shoot_pct;
+
+ // buffering parameters
+ int starting_buffer_level; // in seconds
+ int optimal_buffer_level;
+ int maximum_buffer_size;
+
+ // controlling quality
+ int fixed_q;
+ int worst_allowed_q;
+ int best_allowed_q;
+ int cq_level;
+ int lossless;
+
+ // two pass datarate control
+ int two_pass_vbrbias; // two pass datarate control tweaks
+ int two_pass_vbrmin_section;
+ int two_pass_vbrmax_section;
+ // END DATARATE CONTROL OPTIONS
+ // ----------------------------------------------------------------
+
+
+ // these parameters aren't to be used in final build don't use!!!
+ int play_alternate;
+ int alt_freq;
+
+ int encode_breakout; // early breakout encode threshold : for video conf recommend 800
+
+ int arnr_max_frames;
+ int arnr_strength;
+ int arnr_type;
+
+ struct vpx_fixed_buf two_pass_stats_in;
+ struct vpx_codec_pkt_list *output_pkt_list;
+
+ vp8e_tuning tuning;
+ } VP8_CONFIG;
+
+
+ void vp8_initialize();
+
+ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
+ void vp8_remove_compressor(VP8_PTR *comp);
+
+ void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
+ void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
// receive a frames worth of data caller can assume that a copy of this frame is made
// and not just a copy of the pointer..
- int vp8_receive_raw_frame(VP8_PTR comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp);
- int vp8_get_compressed_data(VP8_PTR comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush);
- int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags);
-
- int vp8_use_as_reference(VP8_PTR comp, int ref_frame_flags);
- int vp8_update_reference(VP8_PTR comp, int ref_frame_flags);
- int vp8_get_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
- int vp8_set_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
- int vp8_update_entropy(VP8_PTR comp, int update);
- int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]);
- int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols);
- int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
- int vp8_get_quantizer(VP8_PTR c);
+ int vp8_receive_raw_frame(VP8_PTR comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp);
+ int vp8_get_compressed_data(VP8_PTR comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush);
+ int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags);
+
+ int vp8_use_as_reference(VP8_PTR comp, int ref_frame_flags);
+ int vp8_update_reference(VP8_PTR comp, int ref_frame_flags);
+ int vp8_get_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+ int vp8_set_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+ int vp8_update_entropy(VP8_PTR comp, int update);
+ int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]);
+ int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols);
+ int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
+ int vp8_get_quantizer(VP8_PTR c);
#ifdef __cplusplus
}
diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h
index 93c2fee54..16f52d697 100644
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -42,258 +42,251 @@ void vp8_initialize_common(void);
#define COMP_PRED_CONTEXTS 2
-typedef struct frame_contexts
-{
- vp8_prob bmode_prob [VP8_BINTRAMODES-1];
- vp8_prob ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */
- vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
- vp8_prob i8x8_mode_prob [VP8_I8X8_MODES-1];
- vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
- vp8_prob mbsplit_prob [VP8_NUMMBSPLITS-1];
- vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- vp8_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- MV_CONTEXT mvc[2];
+typedef struct frame_contexts {
+ vp8_prob bmode_prob [VP8_BINTRAMODES - 1];
+ vp8_prob ymode_prob [VP8_YMODES - 1]; /* interframe intra mode probs */
+ vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES - 1];
+ vp8_prob i8x8_mode_prob [VP8_I8X8_MODES - 1];
+ vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS - 1];
+ vp8_prob mbsplit_prob [VP8_NUMMBSPLITS - 1];
+ vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ vp8_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ MV_CONTEXT mvc[2];
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP mvc_hp[2];
+ MV_CONTEXT_HP mvc_hp[2];
#endif
#if CONFIG_ADAPTIVE_ENTROPY
- MV_CONTEXT pre_mvc[2];
+ MV_CONTEXT pre_mvc[2];
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP pre_mvc_hp[2];
+ MV_CONTEXT_HP pre_mvc_hp[2];
#endif
- vp8_prob pre_bmode_prob [VP8_BINTRAMODES-1];
- vp8_prob pre_ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */
- vp8_prob pre_uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
- vp8_prob pre_i8x8_mode_prob [VP8_I8X8_MODES-1];
- vp8_prob pre_sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
- vp8_prob pre_mbsplit_prob [VP8_NUMMBSPLITS-1];
- unsigned int bmode_counts [VP8_BINTRAMODES];
- unsigned int ymode_counts [VP8_YMODES]; /* interframe intra mode probs */
- unsigned int uv_mode_counts [VP8_YMODES][VP8_UV_MODES];
- unsigned int i8x8_mode_counts [VP8_I8X8_MODES]; /* interframe intra mode probs */
- unsigned int sub_mv_ref_counts [SUBMVREF_COUNT][VP8_SUBMVREFS];
- unsigned int mbsplit_counts [VP8_NUMMBSPLITS];
-
- vp8_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- vp8_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS]
- [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
- unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
- [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
- unsigned int MVcount [2] [MVvals];
+ vp8_prob pre_bmode_prob [VP8_BINTRAMODES - 1];
+ vp8_prob pre_ymode_prob [VP8_YMODES - 1]; /* interframe intra mode probs */
+ vp8_prob pre_uv_mode_prob [VP8_YMODES][VP8_UV_MODES - 1];
+ vp8_prob pre_i8x8_mode_prob [VP8_I8X8_MODES - 1];
+ vp8_prob pre_sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS - 1];
+ vp8_prob pre_mbsplit_prob [VP8_NUMMBSPLITS - 1];
+ unsigned int bmode_counts [VP8_BINTRAMODES];
+ unsigned int ymode_counts [VP8_YMODES]; /* interframe intra mode probs */
+ unsigned int uv_mode_counts [VP8_YMODES][VP8_UV_MODES];
+ unsigned int i8x8_mode_counts [VP8_I8X8_MODES]; /* interframe intra mode probs */
+ unsigned int sub_mv_ref_counts [SUBMVREF_COUNT][VP8_SUBMVREFS];
+ unsigned int mbsplit_counts [VP8_NUMMBSPLITS];
+
+ vp8_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ vp8_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS]
+ [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
+ unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
+ [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
+ unsigned int MVcount [2] [MVvals];
#if CONFIG_HIGH_PRECISION_MV
- unsigned int MVcount_hp [2] [MVvals_hp];
+ unsigned int MVcount_hp [2] [MVvals_hp];
#endif
#endif /* CONFIG_ADAPTIVE_ENTROPY */
- int mode_context[6][4];
- int mode_context_a[6][4];
- int vp8_mode_contexts[6][4];
- int mv_ref_ct[6][4][2];
- int mv_ref_ct_a[6][4][2];
+ int mode_context[6][4];
+ int mode_context_a[6][4];
+ int vp8_mode_contexts[6][4];
+ int mv_ref_ct[6][4][2];
+ int mv_ref_ct_a[6][4][2];
} FRAME_CONTEXT;
-typedef enum
-{
- RECON_CLAMP_REQUIRED = 0,
- RECON_CLAMP_NOTREQUIRED = 1
+typedef enum {
+ RECON_CLAMP_REQUIRED = 0,
+ RECON_CLAMP_NOTREQUIRED = 1
} CLAMP_TYPE;
-typedef enum
-{
- SIXTAP = 0,
- BILINEAR = 1,
+typedef enum {
+ SIXTAP = 0,
+ BILINEAR = 1,
#if CONFIG_ENHANCED_INTERP
- EIGHTTAP = 2,
- EIGHTTAP_SHARP = 3,
+ EIGHTTAP = 2,
+ EIGHTTAP_SHARP = 3,
#endif
} INTERPOLATIONFILTERTYPE;
-typedef enum
-{
- SINGLE_PREDICTION_ONLY = 0,
- COMP_PREDICTION_ONLY = 1,
- HYBRID_PREDICTION = 2,
- NB_PREDICTION_TYPES = 3,
+typedef enum {
+ SINGLE_PREDICTION_ONLY = 0,
+ COMP_PREDICTION_ONLY = 1,
+ HYBRID_PREDICTION = 2,
+ NB_PREDICTION_TYPES = 3,
} COMPPREDMODE_TYPE;
/* TODO: allows larger transform */
-typedef enum
-{
- ONLY_4X4 = 0,
- ALLOW_8X8 = 1
+typedef enum {
+ ONLY_4X4 = 0,
+ ALLOW_8X8 = 1
} TXFM_MODE;
-typedef struct VP8_COMMON_RTCD
-{
+typedef struct VP8_COMMON_RTCD {
#if CONFIG_RUNTIME_CPU_DETECT
- vp8_idct_rtcd_vtable_t idct;
- vp8_recon_rtcd_vtable_t recon;
- vp8_subpix_rtcd_vtable_t subpix;
- vp8_loopfilter_rtcd_vtable_t loopfilter;
+ vp8_idct_rtcd_vtable_t idct;
+ vp8_recon_rtcd_vtable_t recon;
+ vp8_subpix_rtcd_vtable_t subpix;
+ vp8_loopfilter_rtcd_vtable_t loopfilter;
#if CONFIG_POSTPROC
- vp8_postproc_rtcd_vtable_t postproc;
+ vp8_postproc_rtcd_vtable_t postproc;
#endif
- int flags;
+ int flags;
#else
- int unused;
+ int unused;
#endif
} VP8_COMMON_RTCD;
-typedef struct VP8Common
-{
- struct vpx_internal_error_info error;
+typedef struct VP8Common {
+ struct vpx_internal_error_info error;
- DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]);
- int Width;
- int Height;
- int horiz_scale;
- int vert_scale;
+ int Width;
+ int Height;
+ int horiz_scale;
+ int vert_scale;
- YUV_TYPE clr_type;
- CLAMP_TYPE clamp_type;
+ YUV_TYPE clr_type;
+ CLAMP_TYPE clamp_type;
- YV12_BUFFER_CONFIG *frame_to_show;
+ YV12_BUFFER_CONFIG *frame_to_show;
- YV12_BUFFER_CONFIG yv12_fb[NUM_YV12_BUFFERS];
- int fb_idx_ref_cnt[NUM_YV12_BUFFERS];
- int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx;
+ YV12_BUFFER_CONFIG yv12_fb[NUM_YV12_BUFFERS];
+ int fb_idx_ref_cnt[NUM_YV12_BUFFERS];
+ int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx;
- YV12_BUFFER_CONFIG post_proc_buffer;
- YV12_BUFFER_CONFIG temp_scale_frame;
+ YV12_BUFFER_CONFIG post_proc_buffer;
+ YV12_BUFFER_CONFIG temp_scale_frame;
- FRAME_TYPE last_frame_type; /* Save last frame's frame type for motion search. */
- FRAME_TYPE frame_type;
+ FRAME_TYPE last_frame_type; /* Save last frame's frame type for motion search. */
+ FRAME_TYPE frame_type;
- int show_frame;
+ int show_frame;
- int frame_flags;
- int MBs;
- int mb_rows;
- int mb_cols;
- int mode_info_stride;
+ int frame_flags;
+ int MBs;
+ int mb_rows;
+ int mb_cols;
+ int mode_info_stride;
- /* profile settings */
- int experimental;
- int mb_no_coeff_skip;
- TXFM_MODE txfm_mode;
- COMPPREDMODE_TYPE comp_pred_mode;
- int no_lpf;
- int use_bilinear_mc_filter;
- int full_pixel;
+ /* profile settings */
+ int experimental;
+ int mb_no_coeff_skip;
+ TXFM_MODE txfm_mode;
+ COMPPREDMODE_TYPE comp_pred_mode;
+ int no_lpf;
+ int use_bilinear_mc_filter;
+ int full_pixel;
- int base_qindex;
- int last_kf_gf_q; /* Q used on the last GF or KF */
+ int base_qindex;
+ int last_kf_gf_q; /* Q used on the last GF or KF */
- int y1dc_delta_q;
- int y2dc_delta_q;
- int y2ac_delta_q;
- int uvdc_delta_q;
- int uvac_delta_q;
+ int y1dc_delta_q;
+ int y2dc_delta_q;
+ int y2ac_delta_q;
+ int uvdc_delta_q;
+ int uvac_delta_q;
- unsigned int frames_since_golden;
- unsigned int frames_till_alt_ref_frame;
+ unsigned int frames_since_golden;
+ unsigned int frames_till_alt_ref_frame;
- /* We allocate a MODE_INFO struct for each macroblock, together with
- an extra row on top and column on the left to simplify prediction. */
+ /* We allocate a MODE_INFO struct for each macroblock, together with
+ an extra row on top and column on the left to simplify prediction. */
- MODE_INFO *mip; /* Base of allocated array */
- MODE_INFO *mi; /* Corresponds to upper left visible macroblock */
- MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */
- MODE_INFO *prev_mi; /* 'mi' from last frame (points into prev_mip) */
+ MODE_INFO *mip; /* Base of allocated array */
+ MODE_INFO *mi; /* Corresponds to upper left visible macroblock */
+ MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */
+ MODE_INFO *prev_mi; /* 'mi' from last frame (points into prev_mip) */
- // Persistent mb segment id map used in prediction.
- unsigned char * last_frame_seg_map;
+ // Persistent mb segment id map used in prediction.
+ unsigned char *last_frame_seg_map;
- INTERPOLATIONFILTERTYPE mcomp_filter_type;
- LOOPFILTERTYPE filter_type;
+ INTERPOLATIONFILTERTYPE mcomp_filter_type;
+ LOOPFILTERTYPE filter_type;
- loop_filter_info_n lf_info;
+ loop_filter_info_n lf_info;
- int filter_level;
- int last_sharpness_level;
- int sharpness_level;
+ int filter_level;
+ int last_sharpness_level;
+ int sharpness_level;
- int refresh_last_frame; /* Two state 0 = NO, 1 = YES */
- int refresh_golden_frame; /* Two state 0 = NO, 1 = YES */
- int refresh_alt_ref_frame; /* Two state 0 = NO, 1 = YES */
+ int refresh_last_frame; /* Two state 0 = NO, 1 = YES */
+ int refresh_golden_frame; /* Two state 0 = NO, 1 = YES */
+ int refresh_alt_ref_frame; /* Two state 0 = NO, 1 = YES */
- int copy_buffer_to_gf; /* 0 none, 1 Last to GF, 2 ARF to GF */
- int copy_buffer_to_arf; /* 0 none, 1 Last to ARF, 2 GF to ARF */
+ int copy_buffer_to_gf; /* 0 none, 1 Last to GF, 2 ARF to GF */
+ int copy_buffer_to_arf; /* 0 none, 1 Last to ARF, 2 GF to ARF */
- int refresh_entropy_probs; /* Two state 0 = NO, 1 = YES */
+ int refresh_entropy_probs; /* Two state 0 = NO, 1 = YES */
- int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
+ int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
- /* Y,U,V,Y2 */
- ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */
- ENTROPY_CONTEXT_PLANES left_context; /* (up to) 4 contexts "" */
+ /* Y,U,V,Y2 */
+ ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */
+ ENTROPY_CONTEXT_PLANES left_context; /* (up to) 4 contexts "" */
- /* keyframe block modes are predicted by their above, left neighbors */
+ /* keyframe block modes are predicted by their above, left neighbors */
- vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1];
- vp8_prob kf_ymode_prob[8][VP8_YMODES-1]; /* keyframe "" */
- int kf_ymode_probs_index;
- int kf_ymode_probs_update;
- vp8_prob kf_uv_mode_prob[VP8_YMODES] [VP8_UV_MODES-1];
+ vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES - 1];
+ vp8_prob kf_ymode_prob[8][VP8_YMODES - 1]; /* keyframe "" */
+ int kf_ymode_probs_index;
+ int kf_ymode_probs_update;
+ vp8_prob kf_uv_mode_prob[VP8_YMODES] [VP8_UV_MODES - 1];
- vp8_prob prob_intra_coded;
- vp8_prob prob_last_coded;
- vp8_prob prob_gf_coded;
+ vp8_prob prob_intra_coded;
+ vp8_prob prob_last_coded;
+ vp8_prob prob_gf_coded;
- // Context probabilities when using predictive coding of segment id
- vp8_prob segment_pred_probs[PREDICTION_PROBS];
- unsigned char temporal_update;
+ // Context probabilities when using predictive coding of segment id
+ vp8_prob segment_pred_probs[PREDICTION_PROBS];
+ unsigned char temporal_update;
- // Context probabilities for reference frame prediction
- unsigned char ref_scores[MAX_REF_FRAMES];
- vp8_prob ref_pred_probs[PREDICTION_PROBS];
- vp8_prob mod_refprobs[MAX_REF_FRAMES][PREDICTION_PROBS];
+ // Context probabilities for reference frame prediction
+ unsigned char ref_scores[MAX_REF_FRAMES];
+ vp8_prob ref_pred_probs[PREDICTION_PROBS];
+ vp8_prob mod_refprobs[MAX_REF_FRAMES][PREDICTION_PROBS];
- vp8_prob prob_comppred[COMP_PRED_CONTEXTS];
+ vp8_prob prob_comppred[COMP_PRED_CONTEXTS];
#if CONFIG_NEWENTROPY
- vp8_prob mbskip_pred_probs[MBSKIP_CONTEXTS];
+ vp8_prob mbskip_pred_probs[MBSKIP_CONTEXTS];
#endif
- FRAME_CONTEXT lfc_a; /* last alt ref entropy */
- FRAME_CONTEXT lfc; /* last frame entropy */
- FRAME_CONTEXT fc; /* this frame entropy */
+ FRAME_CONTEXT lfc_a; /* last alt ref entropy */
+ FRAME_CONTEXT lfc; /* last frame entropy */
+ FRAME_CONTEXT fc; /* this frame entropy */
- //int mv_ref_ct[6][4][2];
- //int mv_ref_ct_a[6][4][2];
- //int mode_context[6][4];
- //int mode_context_a[6][4];
- //int vp8_mode_contexts[6][4];
+ // int mv_ref_ct[6][4][2];
+ // int mv_ref_ct_a[6][4][2];
+ // int mode_context[6][4];
+ // int mode_context_a[6][4];
+ // int vp8_mode_contexts[6][4];
- unsigned int current_video_frame;
- int near_boffset[3];
- int version;
+ unsigned int current_video_frame;
+ int near_boffset[3];
+ int version;
#ifdef PACKET_TESTING
- VP8_HEADER oh;
+ VP8_HEADER oh;
#endif
- double bitrate;
- double framerate;
+ double bitrate;
+ double framerate;
#if CONFIG_RUNTIME_CPU_DETECT
- VP8_COMMON_RTCD rtcd;
+ VP8_COMMON_RTCD rtcd;
#endif
#if CONFIG_POSTPROC
- struct postproc_state postproc_state;
+ struct postproc_state postproc_state;
#endif
#if CONFIG_PRED_FILTER
- /* Prediction filter variables */
- int pred_filter_mode; // 0=disabled at the frame level (no MB filtered)
- // 1=enabled at the frame level (all MB filtered)
- // 2=specified per MB (1=filtered, 0=non-filtered)
- vp8_prob prob_pred_filter_off;
+ /* Prediction filter variables */
+ int pred_filter_mode; // 0=disabled at the frame level (no MB filtered)
+ // 1=enabled at the frame level (all MB filtered)
+ // 2=specified per MB (1=filtered, 0=non-filtered)
+ vp8_prob prob_pred_filter_off;
#endif
} VP8_COMMON;
diff --git a/vp8/common/onyxd.h b/vp8/common/onyxd.h
index d3b2c18d1..3c9968fb5 100644
--- a/vp8/common/onyxd.h
+++ b/vp8/common/onyxd.h
@@ -24,43 +24,40 @@ extern "C"
#include "vpx_ports/mem.h"
#include "vpx/vpx_codec.h"
- typedef void *VP8D_PTR;
- typedef struct
- {
- int Width;
- int Height;
- int Version;
- int postprocess;
- int max_threads;
- int input_partition;
- } VP8D_CONFIG;
- typedef enum
- {
- VP8_LAST_FLAG = 1,
- VP8_GOLD_FLAG = 2,
- VP8_ALT_FLAG = 4
- } VP8_REFFRAME;
-
- typedef enum
- {
- VP8D_OK = 0
- } VP8D_SETTING;
-
- void vp8dx_initialize(void);
-
- void vp8dx_set_setting(VP8D_PTR comp, VP8D_SETTING oxst, int x);
-
- int vp8dx_get_setting(VP8D_PTR comp, VP8D_SETTING oxst);
-
- int vp8dx_receive_compressed_data(VP8D_PTR comp, unsigned long size, const unsigned char *dest, int64_t time_stamp);
- int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, int64_t *time_stamp, int64_t *time_end_stamp, vp8_ppflags_t *flags);
-
- vpx_codec_err_t vp8dx_get_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
- vpx_codec_err_t vp8dx_set_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
-
- VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf);
-
- void vp8dx_remove_decompressor(VP8D_PTR comp);
+ typedef void *VP8D_PTR;
+ typedef struct {
+ int Width;
+ int Height;
+ int Version;
+ int postprocess;
+ int max_threads;
+ int input_partition;
+ } VP8D_CONFIG;
+ typedef enum {
+ VP8_LAST_FLAG = 1,
+ VP8_GOLD_FLAG = 2,
+ VP8_ALT_FLAG = 4
+ } VP8_REFFRAME;
+
+ typedef enum {
+ VP8D_OK = 0
+ } VP8D_SETTING;
+
+ void vp8dx_initialize(void);
+
+ void vp8dx_set_setting(VP8D_PTR comp, VP8D_SETTING oxst, int x);
+
+ int vp8dx_get_setting(VP8D_PTR comp, VP8D_SETTING oxst);
+
+ int vp8dx_receive_compressed_data(VP8D_PTR comp, unsigned long size, const unsigned char *dest, int64_t time_stamp);
+ int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, int64_t *time_stamp, int64_t *time_end_stamp, vp8_ppflags_t *flags);
+
+ vpx_codec_err_t vp8dx_get_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+ vpx_codec_err_t vp8dx_set_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+
+ VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf);
+
+ void vp8dx_remove_decompressor(VP8D_PTR comp);
#ifdef __cplusplus
}
diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c
index 7e7ed3cb7..66bd539d1 100644
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -21,113 +21,108 @@
#include <stdio.h>
#define RGB_TO_YUV(t) \
- ( (0.257*(float)(t>>16)) + (0.504*(float)(t>>8&0xff)) + (0.098*(float)(t&0xff)) + 16), \
- (-(0.148*(float)(t>>16)) - (0.291*(float)(t>>8&0xff)) + (0.439*(float)(t&0xff)) + 128), \
- ( (0.439*(float)(t>>16)) - (0.368*(float)(t>>8&0xff)) - (0.071*(float)(t&0xff)) + 128)
+ ( (0.257*(float)(t>>16)) + (0.504*(float)(t>>8&0xff)) + (0.098*(float)(t&0xff)) + 16), \
+ (-(0.148*(float)(t>>16)) - (0.291*(float)(t>>8&0xff)) + (0.439*(float)(t&0xff)) + 128), \
+ ( (0.439*(float)(t>>16)) - (0.368*(float)(t>>8&0xff)) - (0.071*(float)(t&0xff)) + 128)
/* global constants */
#if CONFIG_POSTPROC_VISUALIZER
-static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] =
-{
- { RGB_TO_YUV(0x98FB98) }, /* PaleGreen */
- { RGB_TO_YUV(0x00FF00) }, /* Green */
- { RGB_TO_YUV(0xADFF2F) }, /* GreenYellow */
+static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = {
+ { RGB_TO_YUV(0x98FB98) }, /* PaleGreen */
+ { RGB_TO_YUV(0x00FF00) }, /* Green */
+ { RGB_TO_YUV(0xADFF2F) }, /* GreenYellow */
#if CONFIG_NEWINTRAMODES
- { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
- { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
- { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
- { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
- { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
- { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
+ { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
+ { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
+ { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
+ { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
+ { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
+ { RGB_TO_YUV(0x8F0000) }, /* Dark Red */
#endif
- { RGB_TO_YUV(0x228B22) }, /* ForestGreen */
- { RGB_TO_YUV(0x006400) }, /* DarkGreen */
- { RGB_TO_YUV(0x98F5FF) }, /* Cadet Blue */
- { RGB_TO_YUV(0x6CA6CD) }, /* Sky Blue */
- { RGB_TO_YUV(0x00008B) }, /* Dark blue */
- { RGB_TO_YUV(0x551A8B) }, /* Purple */
- { RGB_TO_YUV(0xFF0000) } /* Red */
- { RGB_TO_YUV(0xCC33FF) }, /* Magenta */
+ { RGB_TO_YUV(0x228B22) }, /* ForestGreen */
+ { RGB_TO_YUV(0x006400) }, /* DarkGreen */
+ { RGB_TO_YUV(0x98F5FF) }, /* Cadet Blue */
+ { RGB_TO_YUV(0x6CA6CD) }, /* Sky Blue */
+ { RGB_TO_YUV(0x00008B) }, /* Dark blue */
+ { RGB_TO_YUV(0x551A8B) }, /* Purple */
+ { RGB_TO_YUV(0xFF0000) } /* Red */
+ { RGB_TO_YUV(0xCC33FF) }, /* Magenta */
};
-static const unsigned char B_PREDICTION_MODE_colors[B_MODE_COUNT][3] =
-{
- { RGB_TO_YUV(0x6633ff) }, /* Purple */
- { RGB_TO_YUV(0xcc33ff) }, /* Magenta */
- { RGB_TO_YUV(0xff33cc) }, /* Pink */
- { RGB_TO_YUV(0xff3366) }, /* Coral */
- { RGB_TO_YUV(0x3366ff) }, /* Blue */
- { RGB_TO_YUV(0xed00f5) }, /* Dark Blue */
- { RGB_TO_YUV(0x2e00b8) }, /* Dark Purple */
- { RGB_TO_YUV(0xff6633) }, /* Orange */
- { RGB_TO_YUV(0x33ccff) }, /* Light Blue */
- { RGB_TO_YUV(0x8ab800) }, /* Green */
- { RGB_TO_YUV(0xffcc33) }, /* Light Orange */
- { RGB_TO_YUV(0x33ffcc) }, /* Aqua */
- { RGB_TO_YUV(0x66ff33) }, /* Light Green */
- { RGB_TO_YUV(0xccff33) }, /* Yellow */
+static const unsigned char B_PREDICTION_MODE_colors[B_MODE_COUNT][3] = {
+ { RGB_TO_YUV(0x6633ff) }, /* Purple */
+ { RGB_TO_YUV(0xcc33ff) }, /* Magenta */
+ { RGB_TO_YUV(0xff33cc) }, /* Pink */
+ { RGB_TO_YUV(0xff3366) }, /* Coral */
+ { RGB_TO_YUV(0x3366ff) }, /* Blue */
+ { RGB_TO_YUV(0xed00f5) }, /* Dark Blue */
+ { RGB_TO_YUV(0x2e00b8) }, /* Dark Purple */
+ { RGB_TO_YUV(0xff6633) }, /* Orange */
+ { RGB_TO_YUV(0x33ccff) }, /* Light Blue */
+ { RGB_TO_YUV(0x8ab800) }, /* Green */
+ { RGB_TO_YUV(0xffcc33) }, /* Light Orange */
+ { RGB_TO_YUV(0x33ffcc) }, /* Aqua */
+ { RGB_TO_YUV(0x66ff33) }, /* Light Green */
+ { RGB_TO_YUV(0xccff33) }, /* Yellow */
};
-static const unsigned char MV_REFERENCE_FRAME_colors[MAX_REF_FRAMES][3] =
-{
- { RGB_TO_YUV(0x00ff00) }, /* Blue */
- { RGB_TO_YUV(0x0000ff) }, /* Green */
- { RGB_TO_YUV(0xffff00) }, /* Yellow */
- { RGB_TO_YUV(0xff0000) }, /* Red */
+static const unsigned char MV_REFERENCE_FRAME_colors[MAX_REF_FRAMES][3] = {
+ { RGB_TO_YUV(0x00ff00) }, /* Blue */
+ { RGB_TO_YUV(0x0000ff) }, /* Green */
+ { RGB_TO_YUV(0xffff00) }, /* Yellow */
+ { RGB_TO_YUV(0xff0000) }, /* Red */
};
#endif
-static const short kernel5[] =
-{
- 1, 1, 4, 1, 1
+static const short kernel5[] = {
+ 1, 1, 4, 1, 1
};
-const short vp8_rv[] =
-{
- 8, 5, 2, 2, 8, 12, 4, 9, 8, 3,
- 0, 3, 9, 0, 0, 0, 8, 3, 14, 4,
- 10, 1, 11, 14, 1, 14, 9, 6, 12, 11,
- 8, 6, 10, 0, 0, 8, 9, 0, 3, 14,
- 8, 11, 13, 4, 2, 9, 0, 3, 9, 6,
- 1, 2, 3, 14, 13, 1, 8, 2, 9, 7,
- 3, 3, 1, 13, 13, 6, 6, 5, 2, 7,
- 11, 9, 11, 8, 7, 3, 2, 0, 13, 13,
- 14, 4, 12, 5, 12, 10, 8, 10, 13, 10,
- 4, 14, 4, 10, 0, 8, 11, 1, 13, 7,
- 7, 14, 6, 14, 13, 2, 13, 5, 4, 4,
- 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
- 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
- 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
- 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
- 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
- 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
- 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
- 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
- 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
- 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
- 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
- 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
- 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
- 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
- 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
- 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
- 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
- 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
- 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
- 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
- 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
- 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
- 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
- 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
- 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
- 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
- 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
- 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
- 3, 8, 3, 7, 8, 5, 11, 4, 12, 3,
- 11, 9, 14, 8, 14, 13, 4, 3, 1, 2,
- 14, 6, 5, 4, 4, 11, 4, 6, 2, 1,
- 5, 8, 8, 12, 13, 5, 14, 10, 12, 13,
- 0, 9, 5, 5, 11, 10, 13, 9, 10, 13,
+const short vp8_rv[] = {
+ 8, 5, 2, 2, 8, 12, 4, 9, 8, 3,
+ 0, 3, 9, 0, 0, 0, 8, 3, 14, 4,
+ 10, 1, 11, 14, 1, 14, 9, 6, 12, 11,
+ 8, 6, 10, 0, 0, 8, 9, 0, 3, 14,
+ 8, 11, 13, 4, 2, 9, 0, 3, 9, 6,
+ 1, 2, 3, 14, 13, 1, 8, 2, 9, 7,
+ 3, 3, 1, 13, 13, 6, 6, 5, 2, 7,
+ 11, 9, 11, 8, 7, 3, 2, 0, 13, 13,
+ 14, 4, 12, 5, 12, 10, 8, 10, 13, 10,
+ 4, 14, 4, 10, 0, 8, 11, 1, 13, 7,
+ 7, 14, 6, 14, 13, 2, 13, 5, 4, 4,
+ 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
+ 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
+ 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
+ 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
+ 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
+ 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
+ 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
+ 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
+ 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
+ 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
+ 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
+ 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
+ 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
+ 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
+ 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
+ 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
+ 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
+ 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
+ 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
+ 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
+ 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
+ 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
+ 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
+ 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
+ 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
+ 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
+ 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
+ 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
+ 3, 8, 3, 7, 8, 5, 11, 4, 12, 3,
+ 11, 9, 14, 8, 14, 13, 4, 3, 1, 2,
+ 14, 6, 5, 4, 4, 11, 4, 6, 2, 1,
+ 5, 8, 8, 12, 13, 5, 14, 10, 12, 13,
+ 0, 9, 5, 5, 11, 10, 13, 9, 10, 13,
};
@@ -137,215 +132,196 @@ extern void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
*/
void vp8_post_proc_down_and_across_c
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- int src_pixels_per_line,
- int dst_pixels_per_line,
- int rows,
- int cols,
- int flimit
-)
-{
- unsigned char *p_src, *p_dst;
- int row;
- int col;
- int i;
- int v;
- int pitch = src_pixels_per_line;
- unsigned char d[8];
- (void)dst_pixels_per_line;
-
- for (row = 0; row < rows; row++)
- {
- /* post_proc_down for one row */
- p_src = src_ptr;
- p_dst = dst_ptr;
-
- for (col = 0; col < cols; col++)
- {
-
- int kernel = 4;
- int v = p_src[col];
-
- for (i = -2; i <= 2; i++)
- {
- if (abs(v - p_src[col+i*pitch]) > flimit)
- goto down_skip_convolve;
-
- kernel += kernel5[2+i] * p_src[col+i*pitch];
- }
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ int src_pixels_per_line,
+ int dst_pixels_per_line,
+ int rows,
+ int cols,
+ int flimit
+) {
+ unsigned char *p_src, *p_dst;
+ int row;
+ int col;
+ int i;
+ int v;
+ int pitch = src_pixels_per_line;
+ unsigned char d[8];
+ (void)dst_pixels_per_line;
- v = (kernel >> 3);
- down_skip_convolve:
- p_dst[col] = v;
- }
+ for (row = 0; row < rows; row++) {
+ /* post_proc_down for one row */
+ p_src = src_ptr;
+ p_dst = dst_ptr;
- /* now post_proc_across */
- p_src = dst_ptr;
- p_dst = dst_ptr;
+ for (col = 0; col < cols; col++) {
- for (i = 0; i < 8; i++)
- d[i] = p_src[i];
+ int kernel = 4;
+ int v = p_src[col];
- for (col = 0; col < cols; col++)
- {
- int kernel = 4;
- v = p_src[col];
+ for (i = -2; i <= 2; i++) {
+ if (abs(v - p_src[col + i * pitch]) > flimit)
+ goto down_skip_convolve;
- d[col&7] = v;
+ kernel += kernel5[2 + i] * p_src[col + i * pitch];
+ }
- for (i = -2; i <= 2; i++)
- {
- if (abs(v - p_src[col+i]) > flimit)
- goto across_skip_convolve;
+ v = (kernel >> 3);
+ down_skip_convolve:
+ p_dst[col] = v;
+ }
- kernel += kernel5[2+i] * p_src[col+i];
- }
+ /* now post_proc_across */
+ p_src = dst_ptr;
+ p_dst = dst_ptr;
- d[col&7] = (kernel >> 3);
- across_skip_convolve:
+ for (i = 0; i < 8; i++)
+ d[i] = p_src[i];
- if (col >= 2)
- p_dst[col-2] = d[(col-2)&7];
- }
+ for (col = 0; col < cols; col++) {
+ int kernel = 4;
+ v = p_src[col];
+
+ d[col & 7] = v;
+
+ for (i = -2; i <= 2; i++) {
+ if (abs(v - p_src[col + i]) > flimit)
+ goto across_skip_convolve;
- /* handle the last two pixels */
- p_dst[col-2] = d[(col-2)&7];
- p_dst[col-1] = d[(col-1)&7];
+ kernel += kernel5[2 + i] * p_src[col + i];
+ }
+ d[col & 7] = (kernel >> 3);
+ across_skip_convolve:
- /* next row */
- src_ptr += pitch;
- dst_ptr += pitch;
+ if (col >= 2)
+ p_dst[col - 2] = d[(col - 2) & 7];
}
-}
-static int q2mbl(int x)
-{
- if (x < 20) x = 20;
+ /* handle the last two pixels */
+ p_dst[col - 2] = d[(col - 2) & 7];
+ p_dst[col - 1] = d[(col - 1) & 7];
+
- x = 50 + (x - 50) * 10 / 8;
- return x * x / 3;
+ /* next row */
+ src_ptr += pitch;
+ dst_ptr += pitch;
+ }
}
-void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows, int cols, int flimit)
-{
- int r, c, i;
- unsigned char *s = src;
- unsigned char d[16];
+static int q2mbl(int x) {
+ if (x < 20) x = 20;
+ x = 50 + (x - 50) * 10 / 8;
+ return x * x / 3;
+}
+void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows, int cols, int flimit) {
+ int r, c, i;
- for (r = 0; r < rows; r++)
- {
- int sumsq = 0;
- int sum = 0;
+ unsigned char *s = src;
+ unsigned char d[16];
- for (i = -8; i <= 6; i++)
- {
- sumsq += s[i] * s[i];
- sum += s[i];
- d[i+8] = 0;
- }
- for (c = 0; c < cols + 8; c++)
- {
- int x = s[c+7] - s[c-8];
- int y = s[c+7] + s[c-8];
+ for (r = 0; r < rows; r++) {
+ int sumsq = 0;
+ int sum = 0;
- sum += x;
- sumsq += x * y;
+ for (i = -8; i <= 6; i++) {
+ sumsq += s[i] * s[i];
+ sum += s[i];
+ d[i + 8] = 0;
+ }
- d[c&15] = s[c];
+ for (c = 0; c < cols + 8; c++) {
+ int x = s[c + 7] - s[c - 8];
+ int y = s[c + 7] + s[c - 8];
- if (sumsq * 15 - sum * sum < flimit)
- {
- d[c&15] = (8 + sum + s[c]) >> 4;
- }
+ sum += x;
+ sumsq += x * y;
- s[c-8] = d[(c-8)&15];
- }
+ d[c & 15] = s[c];
+
+ if (sumsq * 15 - sum * sum < flimit) {
+ d[c & 15] = (8 + sum + s[c]) >> 4;
+ }
- s += pitch;
+ s[c - 8] = d[(c - 8) & 15];
}
+
+ s += pitch;
+ }
}
-void vp8_mbpost_proc_down_c(unsigned char *dst, int pitch, int rows, int cols, int flimit)
-{
- int r, c, i;
- const short *rv3 = &vp8_rv[63&rand()];
+void vp8_mbpost_proc_down_c(unsigned char *dst, int pitch, int rows, int cols, int flimit) {
+ int r, c, i;
+ const short *rv3 = &vp8_rv[63 & rand()];
- for (c = 0; c < cols; c++)
- {
- unsigned char *s = &dst[c];
- int sumsq = 0;
- int sum = 0;
- unsigned char d[16];
- const short *rv2 = rv3 + ((c * 17) & 127);
+ for (c = 0; c < cols; c++) {
+ unsigned char *s = &dst[c];
+ int sumsq = 0;
+ int sum = 0;
+ unsigned char d[16];
+ const short *rv2 = rv3 + ((c * 17) & 127);
- for (i = -8; i <= 6; i++)
- {
- sumsq += s[i*pitch] * s[i*pitch];
- sum += s[i*pitch];
- }
+ for (i = -8; i <= 6; i++) {
+ sumsq += s[i * pitch] * s[i * pitch];
+ sum += s[i * pitch];
+ }
- for (r = 0; r < rows + 8; r++)
- {
- sumsq += s[7*pitch] * s[ 7*pitch] - s[-8*pitch] * s[-8*pitch];
- sum += s[7*pitch] - s[-8*pitch];
- d[r&15] = s[0];
+ for (r = 0; r < rows + 8; r++) {
+ sumsq += s[7 * pitch] * s[ 7 * pitch] - s[-8 * pitch] * s[-8 * pitch];
+ sum += s[7 * pitch] - s[-8 * pitch];
+ d[r & 15] = s[0];
- if (sumsq * 15 - sum * sum < flimit)
- {
- d[r&15] = (rv2[r&127] + sum + s[0]) >> 4;
- }
+ if (sumsq * 15 - sum * sum < flimit) {
+ d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4;
+ }
- s[-8*pitch] = d[(r-8)&15];
- s += pitch;
- }
+ s[-8 * pitch] = d[(r - 8) & 15];
+ s += pitch;
}
+ }
}
static void vp8_deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *post,
- int q,
- int low_var_thresh,
- int flag,
- vp8_postproc_rtcd_vtable_t *rtcd)
-{
- double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
- int ppl = (int)(level + .5);
- (void) low_var_thresh;
- (void) flag;
-
- POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride, post->y_stride, source->y_height, source->y_width, ppl);
- POSTPROC_INVOKE(rtcd, across)(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q));
- POSTPROC_INVOKE(rtcd, down)(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q));
-
- POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
- POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+ YV12_BUFFER_CONFIG *post,
+ int q,
+ int low_var_thresh,
+ int flag,
+ vp8_postproc_rtcd_vtable_t *rtcd) {
+ double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+ int ppl = (int)(level + .5);
+ (void) low_var_thresh;
+ (void) flag;
+
+ POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride, post->y_stride, source->y_height, source->y_width, ppl);
+ POSTPROC_INVOKE(rtcd, across)(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q));
+ POSTPROC_INVOKE(rtcd, down)(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q));
+
+ POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+ POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
}
void vp8_deblock(YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *post,
- int q,
- int low_var_thresh,
- int flag,
- vp8_postproc_rtcd_vtable_t *rtcd)
-{
- double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
- int ppl = (int)(level + .5);
- (void) low_var_thresh;
- (void) flag;
-
- POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride, post->y_stride, source->y_height, source->y_width, ppl);
- POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
- POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+ YV12_BUFFER_CONFIG *post,
+ int q,
+ int low_var_thresh,
+ int flag,
+ vp8_postproc_rtcd_vtable_t *rtcd) {
+ double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+ int ppl = (int)(level + .5);
+ (void) low_var_thresh;
+ (void) flag;
+
+ POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride, post->y_stride, source->y_height, source->y_width, ppl);
+ POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+ POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
}
void vp8_de_noise(YV12_BUFFER_CONFIG *source,
@@ -353,104 +329,96 @@ void vp8_de_noise(YV12_BUFFER_CONFIG *source,
int q,
int low_var_thresh,
int flag,
- vp8_postproc_rtcd_vtable_t *rtcd)
-{
- double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
- int ppl = (int)(level + .5);
- (void) post;
- (void) low_var_thresh;
- (void) flag;
-
- POSTPROC_INVOKE(rtcd, downacross)(
- source->y_buffer + 2 * source->y_stride + 2,
- source->y_buffer + 2 * source->y_stride + 2,
- source->y_stride,
- source->y_stride,
- source->y_height - 4,
- source->y_width - 4,
- ppl);
- POSTPROC_INVOKE(rtcd, downacross)(
- source->u_buffer + 2 * source->uv_stride + 2,
- source->u_buffer + 2 * source->uv_stride + 2,
- source->uv_stride,
- source->uv_stride,
- source->uv_height - 4,
- source->uv_width - 4, ppl);
- POSTPROC_INVOKE(rtcd, downacross)(
- source->v_buffer + 2 * source->uv_stride + 2,
- source->v_buffer + 2 * source->uv_stride + 2,
- source->uv_stride,
- source->uv_stride,
- source->uv_height - 4,
- source->uv_width - 4, ppl);
+ vp8_postproc_rtcd_vtable_t *rtcd) {
+ double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+ int ppl = (int)(level + .5);
+ (void) post;
+ (void) low_var_thresh;
+ (void) flag;
+
+ POSTPROC_INVOKE(rtcd, downacross)(
+ source->y_buffer + 2 * source->y_stride + 2,
+ source->y_buffer + 2 * source->y_stride + 2,
+ source->y_stride,
+ source->y_stride,
+ source->y_height - 4,
+ source->y_width - 4,
+ ppl);
+ POSTPROC_INVOKE(rtcd, downacross)(
+ source->u_buffer + 2 * source->uv_stride + 2,
+ source->u_buffer + 2 * source->uv_stride + 2,
+ source->uv_stride,
+ source->uv_stride,
+ source->uv_height - 4,
+ source->uv_width - 4, ppl);
+ POSTPROC_INVOKE(rtcd, downacross)(
+ source->v_buffer + 2 * source->uv_stride + 2,
+ source->v_buffer + 2 * source->uv_stride + 2,
+ source->uv_stride,
+ source->uv_stride,
+ source->uv_height - 4,
+ source->uv_width - 4, ppl);
}
-double vp8_gaussian(double sigma, double mu, double x)
-{
- return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
- (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
+double vp8_gaussian(double sigma, double mu, double x) {
+ return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
+ (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
}
extern void (*vp8_clear_system_state)(void);
-static void fillrd(struct postproc_state *state, int q, int a)
-{
- char char_dist[300];
-
- double sigma;
- int ai = a, qi = q, i;
-
- vp8_clear_system_state();
+static void fillrd(struct postproc_state *state, int q, int a) {
+ char char_dist[300];
+ double sigma;
+ int ai = a, qi = q, i;
- sigma = ai + .5 + .6 * (63 - qi) / 63.0;
+ vp8_clear_system_state();
- /* set up a lookup table of 256 entries that matches
- * a gaussian distribution with sigma determined by q.
- */
- {
- double i;
- int next, j;
- next = 0;
+ sigma = ai + .5 + .6 * (63 - qi) / 63.0;
- for (i = -32; i < 32; i++)
- {
- int a = (int)(.5 + 256 * vp8_gaussian(sigma, 0, i));
+ /* set up a lookup table of 256 entries that matches
+ * a gaussian distribution with sigma determined by q.
+ */
+ {
+ double i;
+ int next, j;
- if (a)
- {
- for (j = 0; j < a; j++)
- {
- char_dist[next+j] = (char) i;
- }
+ next = 0;
- next = next + j;
- }
+ for (i = -32; i < 32; i++) {
+ int a = (int)(.5 + 256 * vp8_gaussian(sigma, 0, i));
+ if (a) {
+ for (j = 0; j < a; j++) {
+ char_dist[next + j] = (char) i;
}
- for (next = next; next < 256; next++)
- char_dist[next] = 0;
+ next = next + j;
+ }
}
- for (i = 0; i < 3072; i++)
- {
- state->noise[i] = char_dist[rand() & 0xff];
- }
+ for (next = next; next < 256; next++)
+ char_dist[next] = 0;
- for (i = 0; i < 16; i++)
- {
- state->blackclamp[i] = -char_dist[0];
- state->whiteclamp[i] = -char_dist[0];
- state->bothclamp[i] = -2 * char_dist[0];
- }
+ }
+
+ for (i = 0; i < 3072; i++) {
+ state->noise[i] = char_dist[rand() & 0xff];
+ }
- state->last_q = q;
- state->last_noise = a;
+ for (i = 0; i < 16; i++) {
+ state->blackclamp[i] = -char_dist[0];
+ state->whiteclamp[i] = -char_dist[0];
+ state->bothclamp[i] = -2 * char_dist[0];
+ }
+
+ state->last_q = q;
+ state->last_noise = a;
}
/****************************************************************************
@@ -478,206 +446,179 @@ void vp8_plane_add_noise_c(unsigned char *Start, char *noise,
char blackclamp[16],
char whiteclamp[16],
char bothclamp[16],
- unsigned int Width, unsigned int Height, int Pitch)
-{
- unsigned int i, j;
+ unsigned int Width, unsigned int Height, int Pitch) {
+ unsigned int i, j;
- for (i = 0; i < Height; i++)
- {
- unsigned char *Pos = Start + i * Pitch;
- char *Ref = (char *)(noise + (rand() & 0xff));
+ for (i = 0; i < Height; i++) {
+ unsigned char *Pos = Start + i * Pitch;
+ char *Ref = (char *)(noise + (rand() & 0xff));
- for (j = 0; j < Width; j++)
- {
- if (Pos[j] < blackclamp[0])
- Pos[j] = blackclamp[0];
+ for (j = 0; j < Width; j++) {
+ if (Pos[j] < blackclamp[0])
+ Pos[j] = blackclamp[0];
- if (Pos[j] > 255 + whiteclamp[0])
- Pos[j] = 255 + whiteclamp[0];
+ if (Pos[j] > 255 + whiteclamp[0])
+ Pos[j] = 255 + whiteclamp[0];
- Pos[j] += Ref[j];
- }
+ Pos[j] += Ref[j];
}
+ }
}
/* Blend the macro block with a solid colored square. Leave the
* edges unblended to give distinction to macro blocks in areas
* filled with the same color block.
*/
-void vp8_blend_mb_inner_c (unsigned char *y, unsigned char *u, unsigned char *v,
- int y1, int u1, int v1, int alpha, int stride)
-{
- int i, j;
- int y1_const = y1*((1<<16)-alpha);
- int u1_const = u1*((1<<16)-alpha);
- int v1_const = v1*((1<<16)-alpha);
-
- y += 2*stride + 2;
- for (i = 0; i < 12; i++)
- {
- for (j = 0; j < 12; j++)
- {
- y[j] = (y[j]*alpha + y1_const)>>16;
- }
- y += stride;
+void vp8_blend_mb_inner_c(unsigned char *y, unsigned char *u, unsigned char *v,
+ int y1, int u1, int v1, int alpha, int stride) {
+ int i, j;
+ int y1_const = y1 * ((1 << 16) - alpha);
+ int u1_const = u1 * ((1 << 16) - alpha);
+ int v1_const = v1 * ((1 << 16) - alpha);
+
+ y += 2 * stride + 2;
+ for (i = 0; i < 12; i++) {
+ for (j = 0; j < 12; j++) {
+ y[j] = (y[j] * alpha + y1_const) >> 16;
}
+ y += stride;
+ }
- stride >>= 1;
+ stride >>= 1;
- u += stride + 1;
- v += stride + 1;
+ u += stride + 1;
+ v += stride + 1;
- for (i = 0; i < 6; i++)
- {
- for (j = 0; j < 6; j++)
- {
- u[j] = (u[j]*alpha + u1_const)>>16;
- v[j] = (v[j]*alpha + v1_const)>>16;
- }
- u += stride;
- v += stride;
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 6; j++) {
+ u[j] = (u[j] * alpha + u1_const) >> 16;
+ v[j] = (v[j] * alpha + v1_const) >> 16;
}
+ u += stride;
+ v += stride;
+ }
}
/* Blend only the edge of the macro block. Leave center
* unblended to allow for other visualizations to be layered.
*/
-void vp8_blend_mb_outer_c (unsigned char *y, unsigned char *u, unsigned char *v,
- int y1, int u1, int v1, int alpha, int stride)
-{
- int i, j;
- int y1_const = y1*((1<<16)-alpha);
- int u1_const = u1*((1<<16)-alpha);
- int v1_const = v1*((1<<16)-alpha);
-
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 16; j++)
- {
- y[j] = (y[j]*alpha + y1_const)>>16;
- }
- y += stride;
- }
+void vp8_blend_mb_outer_c(unsigned char *y, unsigned char *u, unsigned char *v,
+ int y1, int u1, int v1, int alpha, int stride) {
+ int i, j;
+ int y1_const = y1 * ((1 << 16) - alpha);
+ int u1_const = u1 * ((1 << 16) - alpha);
+ int v1_const = v1 * ((1 << 16) - alpha);
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 16; j++) {
+ y[j] = (y[j] * alpha + y1_const) >> 16;
+ }
+ y += stride;
+ }
+
+ for (i = 0; i < 12; i++) {
+ y[0] = (y[0] * alpha + y1_const) >> 16;
+ y[1] = (y[1] * alpha + y1_const) >> 16;
+ y[14] = (y[14] * alpha + y1_const) >> 16;
+ y[15] = (y[15] * alpha + y1_const) >> 16;
+ y += stride;
+ }
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 16; j++) {
+ y[j] = (y[j] * alpha + y1_const) >> 16;
+ }
+ y += stride;
+ }
+
+ stride >>= 1;
+
+ for (j = 0; j < 8; j++) {
+ u[j] = (u[j] * alpha + u1_const) >> 16;
+ v[j] = (v[j] * alpha + v1_const) >> 16;
+ }
+ u += stride;
+ v += stride;
+
+ for (i = 0; i < 6; i++) {
+ u[0] = (u[0] * alpha + u1_const) >> 16;
+ v[0] = (v[0] * alpha + v1_const) >> 16;
+
+ u[7] = (u[7] * alpha + u1_const) >> 16;
+ v[7] = (v[7] * alpha + v1_const) >> 16;
- for (i = 0; i < 12; i++)
- {
- y[0] = (y[0]*alpha + y1_const)>>16;
- y[1] = (y[1]*alpha + y1_const)>>16;
- y[14] = (y[14]*alpha + y1_const)>>16;
- y[15] = (y[15]*alpha + y1_const)>>16;
- y += stride;
- }
-
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 16; j++)
- {
- y[j] = (y[j]*alpha + y1_const)>>16;
- }
- y += stride;
- }
-
- stride >>= 1;
-
- for (j = 0; j < 8; j++)
- {
- u[j] = (u[j]*alpha + u1_const)>>16;
- v[j] = (v[j]*alpha + v1_const)>>16;
- }
u += stride;
v += stride;
+ }
- for (i = 0; i < 6; i++)
- {
- u[0] = (u[0]*alpha + u1_const)>>16;
- v[0] = (v[0]*alpha + v1_const)>>16;
-
- u[7] = (u[7]*alpha + u1_const)>>16;
- v[7] = (v[7]*alpha + v1_const)>>16;
-
- u += stride;
- v += stride;
- }
-
- for (j = 0; j < 8; j++)
- {
- u[j] = (u[j]*alpha + u1_const)>>16;
- v[j] = (v[j]*alpha + v1_const)>>16;
- }
+ for (j = 0; j < 8; j++) {
+ u[j] = (u[j] * alpha + u1_const) >> 16;
+ v[j] = (v[j] * alpha + v1_const) >> 16;
+ }
}
-void vp8_blend_b_c (unsigned char *y, unsigned char *u, unsigned char *v,
- int y1, int u1, int v1, int alpha, int stride)
-{
- int i, j;
- int y1_const = y1*((1<<16)-alpha);
- int u1_const = u1*((1<<16)-alpha);
- int v1_const = v1*((1<<16)-alpha);
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- y[j] = (y[j]*alpha + y1_const)>>16;
- }
- y += stride;
+void vp8_blend_b_c(unsigned char *y, unsigned char *u, unsigned char *v,
+ int y1, int u1, int v1, int alpha, int stride) {
+ int i, j;
+ int y1_const = y1 * ((1 << 16) - alpha);
+ int u1_const = u1 * ((1 << 16) - alpha);
+ int v1_const = v1 * ((1 << 16) - alpha);
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ y[j] = (y[j] * alpha + y1_const) >> 16;
}
+ y += stride;
+ }
- stride >>= 1;
+ stride >>= 1;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- u[j] = (u[j]*alpha + u1_const)>>16;
- v[j] = (v[j]*alpha + v1_const)>>16;
- }
- u += stride;
- v += stride;
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ u[j] = (u[j] * alpha + u1_const) >> 16;
+ v[j] = (v[j] * alpha + v1_const) >> 16;
}
+ u += stride;
+ v += stride;
+ }
}
-static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int height)
-{
- int dx;
- int dy;
-
- if (*x1 > width)
- {
- dx = *x1 - x0;
- dy = *y1 - y0;
-
- *x1 = width;
- if (dx)
- *y1 = ((width-x0)*dy)/dx + y0;
- }
- if (*x1 < 0)
- {
- dx = *x1 - x0;
- dy = *y1 - y0;
-
- *x1 = 0;
- if (dx)
- *y1 = ((0-x0)*dy)/dx + y0;
- }
- if (*y1 > height)
- {
- dx = *x1 - x0;
- dy = *y1 - y0;
-
- *y1 = height;
- if (dy)
- *x1 = ((height-y0)*dx)/dy + x0;
- }
- if (*y1 < 0)
- {
- dx = *x1 - x0;
- dy = *y1 - y0;
-
- *y1 = 0;
- if (dy)
- *x1 = ((0-y0)*dx)/dy + x0;
- }
+static void constrain_line(int x0, int *x1, int y0, int *y1, int width, int height) {
+ int dx;
+ int dy;
+
+ if (*x1 > width) {
+ dx = *x1 - x0;
+ dy = *y1 - y0;
+
+ *x1 = width;
+ if (dx)
+ *y1 = ((width - x0) * dy) / dx + y0;
+ }
+ if (*x1 < 0) {
+ dx = *x1 - x0;
+ dy = *y1 - y0;
+
+ *x1 = 0;
+ if (dx)
+ *y1 = ((0 - x0) * dy) / dx + y0;
+ }
+ if (*y1 > height) {
+ dx = *x1 - x0;
+ dy = *y1 - y0;
+
+ *y1 = height;
+ if (dy)
+ *x1 = ((height - y0) * dx) / dy + x0;
+ }
+ if (*y1 < 0) {
+ dx = *x1 - x0;
+ dy = *y1 - y0;
+
+ *y1 = 0;
+ if (dy)
+ *x1 = ((0 - y0) * dx) / dy + x0;
+ }
}
@@ -687,432 +628,386 @@ static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int hei
#define RTCD_VTABLE(oci) NULL
#endif
-int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *ppflags)
-{
- int q = oci->filter_level * 10 / 6;
- int flags = ppflags->post_proc_flag;
- int deblock_level = ppflags->deblocking_level;
- int noise_level = ppflags->noise_level;
+int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *ppflags) {
+ int q = oci->filter_level * 10 / 6;
+ int flags = ppflags->post_proc_flag;
+ int deblock_level = ppflags->deblocking_level;
+ int noise_level = ppflags->noise_level;
- if (!oci->frame_to_show)
- return -1;
+ if (!oci->frame_to_show)
+ return -1;
- if (q > 63)
- q = 63;
+ if (q > 63)
+ q = 63;
- if (!flags)
- {
- *dest = *oci->frame_to_show;
+ if (!flags) {
+ *dest = *oci->frame_to_show;
- /* handle problem with extending borders */
- dest->y_width = oci->Width;
- dest->y_height = oci->Height;
- dest->uv_height = dest->y_height / 2;
- return 0;
+ /* handle problem with extending borders */
+ dest->y_width = oci->Width;
+ dest->y_height = oci->Height;
+ dest->uv_height = dest->y_height / 2;
+ return 0;
- }
+ }
#if ARCH_X86||ARCH_X86_64
- vpx_reset_mmx_state();
+ vpx_reset_mmx_state();
#endif
- if (flags & VP8D_DEMACROBLOCK)
- {
- vp8_deblock_and_de_macro_block(oci->frame_to_show, &oci->post_proc_buffer,
- q + (deblock_level - 5) * 10, 1, 0, RTCD_VTABLE(oci));
- }
- else if (flags & VP8D_DEBLOCK)
- {
- vp8_deblock(oci->frame_to_show, &oci->post_proc_buffer,
- q, 1, 0, RTCD_VTABLE(oci));
- }
- else
- {
- vp8_yv12_copy_frame_ptr(oci->frame_to_show, &oci->post_proc_buffer);
- }
-
- if (flags & VP8D_ADDNOISE)
- {
- if (oci->postproc_state.last_q != q
- || oci->postproc_state.last_noise != noise_level)
- {
- fillrd(&oci->postproc_state, 63 - q, noise_level);
- }
-
- POSTPROC_INVOKE(RTCD_VTABLE(oci), addnoise)
- (oci->post_proc_buffer.y_buffer,
- oci->postproc_state.noise,
- oci->postproc_state.blackclamp,
- oci->postproc_state.whiteclamp,
- oci->postproc_state.bothclamp,
- oci->post_proc_buffer.y_width, oci->post_proc_buffer.y_height,
- oci->post_proc_buffer.y_stride);
- }
+ if (flags & VP8D_DEMACROBLOCK) {
+ vp8_deblock_and_de_macro_block(oci->frame_to_show, &oci->post_proc_buffer,
+ q + (deblock_level - 5) * 10, 1, 0, RTCD_VTABLE(oci));
+ } else if (flags & VP8D_DEBLOCK) {
+ vp8_deblock(oci->frame_to_show, &oci->post_proc_buffer,
+ q, 1, 0, RTCD_VTABLE(oci));
+ } else {
+ vp8_yv12_copy_frame_ptr(oci->frame_to_show, &oci->post_proc_buffer);
+ }
+
+ if (flags & VP8D_ADDNOISE) {
+ if (oci->postproc_state.last_q != q
+ || oci->postproc_state.last_noise != noise_level) {
+ fillrd(&oci->postproc_state, 63 - q, noise_level);
+ }
+
+ POSTPROC_INVOKE(RTCD_VTABLE(oci), addnoise)
+ (oci->post_proc_buffer.y_buffer,
+ oci->postproc_state.noise,
+ oci->postproc_state.blackclamp,
+ oci->postproc_state.whiteclamp,
+ oci->postproc_state.bothclamp,
+ oci->post_proc_buffer.y_width, oci->post_proc_buffer.y_height,
+ oci->post_proc_buffer.y_stride);
+ }
#if CONFIG_POSTPROC_VISUALIZER
- if (flags & VP8D_DEBUG_TXT_FRAME_INFO)
- {
- char message[512];
- sprintf(message, "F%1dG%1dQ%3dF%3dP%d_s%dx%d",
- (oci->frame_type == KEY_FRAME),
- oci->refresh_golden_frame,
- oci->base_qindex,
- oci->filter_level,
- flags,
- oci->mb_cols, oci->mb_rows);
- vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
- }
-
- if (flags & VP8D_DEBUG_TXT_MBLK_MODES)
- {
- int i, j;
- unsigned char *y_ptr;
- YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
- int mb_rows = post->y_height >> 4;
- int mb_cols = post->y_width >> 4;
- int mb_index = 0;
- MODE_INFO *mi = oci->mi;
-
- y_ptr = post->y_buffer + 4 * post->y_stride + 4;
-
- /* vp8_filter each macro block */
- for (i = 0; i < mb_rows; i++)
- {
- for (j = 0; j < mb_cols; j++)
- {
- char zz[4];
-
- sprintf(zz, "%c", mi[mb_index].mbmi.mode + 'a');
-
- vp8_blit_text(zz, y_ptr, post->y_stride);
- mb_index ++;
- y_ptr += 16;
- }
+ if (flags & VP8D_DEBUG_TXT_FRAME_INFO) {
+ char message[512];
+ sprintf(message, "F%1dG%1dQ%3dF%3dP%d_s%dx%d",
+ (oci->frame_type == KEY_FRAME),
+ oci->refresh_golden_frame,
+ oci->base_qindex,
+ oci->filter_level,
+ flags,
+ oci->mb_cols, oci->mb_rows);
+ vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
+ }
+
+ if (flags & VP8D_DEBUG_TXT_MBLK_MODES) {
+ int i, j;
+ unsigned char *y_ptr;
+ YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+ int mb_rows = post->y_height >> 4;
+ int mb_cols = post->y_width >> 4;
+ int mb_index = 0;
+ MODE_INFO *mi = oci->mi;
- mb_index ++; /* border */
- y_ptr += post->y_stride * 16 - post->y_width;
+ y_ptr = post->y_buffer + 4 * post->y_stride + 4;
- }
- }
+ /* vp8_filter each macro block */
+ for (i = 0; i < mb_rows; i++) {
+ for (j = 0; j < mb_cols; j++) {
+ char zz[4];
- if (flags & VP8D_DEBUG_TXT_DC_DIFF)
- {
- int i, j;
- unsigned char *y_ptr;
- YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
- int mb_rows = post->y_height >> 4;
- int mb_cols = post->y_width >> 4;
- int mb_index = 0;
- MODE_INFO *mi = oci->mi;
-
- y_ptr = post->y_buffer + 4 * post->y_stride + 4;
-
- /* vp8_filter each macro block */
- for (i = 0; i < mb_rows; i++)
- {
- for (j = 0; j < mb_cols; j++)
- {
- char zz[4];
- int dc_diff = !(mi[mb_index].mbmi.mode != B_PRED &&
- mi[mb_index].mbmi.mode != SPLITMV &&
- mi[mb_index].mbmi.mb_skip_coeff);
-
- if (oci->frame_type == KEY_FRAME)
- sprintf(zz, "a");
- else
- sprintf(zz, "%c", dc_diff + '0');
-
- vp8_blit_text(zz, y_ptr, post->y_stride);
- mb_index ++;
- y_ptr += 16;
- }
+ sprintf(zz, "%c", mi[mb_index].mbmi.mode + 'a');
- mb_index ++; /* border */
- y_ptr += post->y_stride * 16 - post->y_width;
+ vp8_blit_text(zz, y_ptr, post->y_stride);
+ mb_index++;
+ y_ptr += 16;
+ }
- }
- }
+ mb_index++; /* border */
+ y_ptr += post->y_stride * 16 - post->y_width;
- if (flags & VP8D_DEBUG_TXT_RATE_INFO)
- {
- char message[512];
- sprintf(message, "Bitrate: %10.2f frame_rate: %10.2f ", oci->bitrate, oci->framerate);
- vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
}
+ }
- /* Draw motion vectors */
- if ((flags & VP8D_DEBUG_DRAW_MV) && ppflags->display_mv_flag)
- {
- YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
- int width = post->y_width;
- int height = post->y_height;
- unsigned char *y_buffer = oci->post_proc_buffer.y_buffer;
- int y_stride = oci->post_proc_buffer.y_stride;
- MODE_INFO *mi = oci->mi;
- int x0, y0;
-
- for (y0 = 0; y0 < height; y0 += 16)
- {
- for (x0 = 0; x0 < width; x0 += 16)
- {
- int x1, y1;
-
- if (!(ppflags->display_mv_flag & (1<<mi->mbmi.mode)))
- {
- mi++;
- continue;
- }
+ if (flags & VP8D_DEBUG_TXT_DC_DIFF) {
+ int i, j;
+ unsigned char *y_ptr;
+ YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+ int mb_rows = post->y_height >> 4;
+ int mb_cols = post->y_width >> 4;
+ int mb_index = 0;
+ MODE_INFO *mi = oci->mi;
+
+ y_ptr = post->y_buffer + 4 * post->y_stride + 4;
+
+ /* vp8_filter each macro block */
+ for (i = 0; i < mb_rows; i++) {
+ for (j = 0; j < mb_cols; j++) {
+ char zz[4];
+ int dc_diff = !(mi[mb_index].mbmi.mode != B_PRED &&
+ mi[mb_index].mbmi.mode != SPLITMV &&
+ mi[mb_index].mbmi.mb_skip_coeff);
+
+ if (oci->frame_type == KEY_FRAME)
+ sprintf(zz, "a");
+ else
+ sprintf(zz, "%c", dc_diff + '0');
+
+ vp8_blit_text(zz, y_ptr, post->y_stride);
+ mb_index++;
+ y_ptr += 16;
+ }
+
+ mb_index++; /* border */
+ y_ptr += post->y_stride * 16 - post->y_width;
+
+ }
+ }
+
+ if (flags & VP8D_DEBUG_TXT_RATE_INFO) {
+ char message[512];
+ sprintf(message, "Bitrate: %10.2f frame_rate: %10.2f ", oci->bitrate, oci->framerate);
+ vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
+ }
+
+ /* Draw motion vectors */
+ if ((flags & VP8D_DEBUG_DRAW_MV) && ppflags->display_mv_flag) {
+ YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+ int width = post->y_width;
+ int height = post->y_height;
+ unsigned char *y_buffer = oci->post_proc_buffer.y_buffer;
+ int y_stride = oci->post_proc_buffer.y_stride;
+ MODE_INFO *mi = oci->mi;
+ int x0, y0;
+
+ for (y0 = 0; y0 < height; y0 += 16) {
+ for (x0 = 0; x0 < width; x0 += 16) {
+ int x1, y1;
+
+ if (!(ppflags->display_mv_flag & (1 << mi->mbmi.mode))) {
+ mi++;
+ continue;
+ }
- if (mi->mbmi.mode == SPLITMV)
- {
- switch (mi->mbmi.partitioning)
- {
- case 0 : /* mv_top_bottom */
- {
- union b_mode_info *bmi = &mi->bmi[0];
- MV *mv = &bmi->mv.as_mv;
+ if (mi->mbmi.mode == SPLITMV) {
+ switch (mi->mbmi.partitioning) {
+ case 0 : { /* mv_top_bottom */
+ union b_mode_info *bmi = &mi->bmi[0];
+ MV *mv = &bmi->mv.as_mv;
- x1 = x0 + 8 + (mv->col >> 3);
- y1 = y0 + 4 + (mv->row >> 3);
+ x1 = x0 + 8 + (mv->col >> 3);
+ y1 = y0 + 4 + (mv->row >> 3);
- constrain_line (x0+8, &x1, y0+4, &y1, width, height);
- vp8_blit_line (x0+8, x1, y0+4, y1, y_buffer, y_stride);
+ constrain_line(x0 + 8, &x1, y0 + 4, &y1, width, height);
+ vp8_blit_line(x0 + 8, x1, y0 + 4, y1, y_buffer, y_stride);
- bmi = &mi->bmi[8];
+ bmi = &mi->bmi[8];
- x1 = x0 + 8 + (mv->col >> 3);
- y1 = y0 +12 + (mv->row >> 3);
+ x1 = x0 + 8 + (mv->col >> 3);
+ y1 = y0 + 12 + (mv->row >> 3);
- constrain_line (x0+8, &x1, y0+12, &y1, width, height);
- vp8_blit_line (x0+8, x1, y0+12, y1, y_buffer, y_stride);
+ constrain_line(x0 + 8, &x1, y0 + 12, &y1, width, height);
+ vp8_blit_line(x0 + 8, x1, y0 + 12, y1, y_buffer, y_stride);
- break;
- }
- case 1 : /* mv_left_right */
- {
- union b_mode_info *bmi = &mi->bmi[0];
- MV *mv = &bmi->mv.as_mv;
+ break;
+ }
+ case 1 : { /* mv_left_right */
+ union b_mode_info *bmi = &mi->bmi[0];
+ MV *mv = &bmi->mv.as_mv;
- x1 = x0 + 4 + (mv->col >> 3);
- y1 = y0 + 8 + (mv->row >> 3);
+ x1 = x0 + 4 + (mv->col >> 3);
+ y1 = y0 + 8 + (mv->row >> 3);
- constrain_line (x0+4, &x1, y0+8, &y1, width, height);
- vp8_blit_line (x0+4, x1, y0+8, y1, y_buffer, y_stride);
+ constrain_line(x0 + 4, &x1, y0 + 8, &y1, width, height);
+ vp8_blit_line(x0 + 4, x1, y0 + 8, y1, y_buffer, y_stride);
- bmi = &mi->bmi[2];
+ bmi = &mi->bmi[2];
- x1 = x0 +12 + (mv->col >> 3);
- y1 = y0 + 8 + (mv->row >> 3);
+ x1 = x0 + 12 + (mv->col >> 3);
+ y1 = y0 + 8 + (mv->row >> 3);
- constrain_line (x0+12, &x1, y0+8, &y1, width, height);
- vp8_blit_line (x0+12, x1, y0+8, y1, y_buffer, y_stride);
+ constrain_line(x0 + 12, &x1, y0 + 8, &y1, width, height);
+ vp8_blit_line(x0 + 12, x1, y0 + 8, y1, y_buffer, y_stride);
- break;
- }
- case 2 : /* mv_quarters */
- {
- union b_mode_info *bmi = &mi->bmi[0];
- MV *mv = &bmi->mv.as_mv;
+ break;
+ }
+ case 2 : { /* mv_quarters */
+ union b_mode_info *bmi = &mi->bmi[0];
+ MV *mv = &bmi->mv.as_mv;
- x1 = x0 + 4 + (mv->col >> 3);
- y1 = y0 + 4 + (mv->row >> 3);
+ x1 = x0 + 4 + (mv->col >> 3);
+ y1 = y0 + 4 + (mv->row >> 3);
- constrain_line (x0+4, &x1, y0+4, &y1, width, height);
- vp8_blit_line (x0+4, x1, y0+4, y1, y_buffer, y_stride);
+ constrain_line(x0 + 4, &x1, y0 + 4, &y1, width, height);
+ vp8_blit_line(x0 + 4, x1, y0 + 4, y1, y_buffer, y_stride);
- bmi = &mi->bmi[2];
+ bmi = &mi->bmi[2];
- x1 = x0 +12 + (mv->col >> 3);
- y1 = y0 + 4 + (mv->row >> 3);
+ x1 = x0 + 12 + (mv->col >> 3);
+ y1 = y0 + 4 + (mv->row >> 3);
- constrain_line (x0+12, &x1, y0+4, &y1, width, height);
- vp8_blit_line (x0+12, x1, y0+4, y1, y_buffer, y_stride);
+ constrain_line(x0 + 12, &x1, y0 + 4, &y1, width, height);
+ vp8_blit_line(x0 + 12, x1, y0 + 4, y1, y_buffer, y_stride);
- bmi = &mi->bmi[8];
+ bmi = &mi->bmi[8];
- x1 = x0 + 4 + (mv->col >> 3);
- y1 = y0 +12 + (mv->row >> 3);
+ x1 = x0 + 4 + (mv->col >> 3);
+ y1 = y0 + 12 + (mv->row >> 3);
- constrain_line (x0+4, &x1, y0+12, &y1, width, height);
- vp8_blit_line (x0+4, x1, y0+12, y1, y_buffer, y_stride);
+ constrain_line(x0 + 4, &x1, y0 + 12, &y1, width, height);
+ vp8_blit_line(x0 + 4, x1, y0 + 12, y1, y_buffer, y_stride);
- bmi = &mi->bmi[10];
+ bmi = &mi->bmi[10];
- x1 = x0 +12 + (mv->col >> 3);
- y1 = y0 +12 + (mv->row >> 3);
+ x1 = x0 + 12 + (mv->col >> 3);
+ y1 = y0 + 12 + (mv->row >> 3);
- constrain_line (x0+12, &x1, y0+12, &y1, width, height);
- vp8_blit_line (x0+12, x1, y0+12, y1, y_buffer, y_stride);
- break;
- }
- default :
- {
- union b_mode_info *bmi = mi->bmi;
- int bx0, by0;
+ constrain_line(x0 + 12, &x1, y0 + 12, &y1, width, height);
+ vp8_blit_line(x0 + 12, x1, y0 + 12, y1, y_buffer, y_stride);
+ break;
+ }
+ default : {
+ union b_mode_info *bmi = mi->bmi;
+ int bx0, by0;
- for (by0 = y0; by0 < (y0+16); by0 += 4)
- {
- for (bx0 = x0; bx0 < (x0+16); bx0 += 4)
- {
- MV *mv = &bmi->mv.as_mv;
+ for (by0 = y0; by0 < (y0 + 16); by0 += 4) {
+ for (bx0 = x0; bx0 < (x0 + 16); bx0 += 4) {
+ MV *mv = &bmi->mv.as_mv;
- x1 = bx0 + 2 + (mv->col >> 3);
- y1 = by0 + 2 + (mv->row >> 3);
+ x1 = bx0 + 2 + (mv->col >> 3);
+ y1 = by0 + 2 + (mv->row >> 3);
- constrain_line (bx0+2, &x1, by0+2, &y1, width, height);
- vp8_blit_line (bx0+2, x1, by0+2, y1, y_buffer, y_stride);
+ constrain_line(bx0 + 2, &x1, by0 + 2, &y1, width, height);
+ vp8_blit_line(bx0 + 2, x1, by0 + 2, y1, y_buffer, y_stride);
- bmi++;
- }
- }
- }
- }
+ bmi++;
}
- else if (mi->mbmi.mode >= NEARESTMV)
- {
- MV *mv = &mi->mbmi.mv.as_mv;
- const int lx0 = x0 + 8;
- const int ly0 = y0 + 8;
-
- x1 = lx0 + (mv->col >> 3);
- y1 = ly0 + (mv->row >> 3);
-
- if (x1 != lx0 && y1 != ly0)
- {
- constrain_line (lx0, &x1, ly0-1, &y1, width, height);
- vp8_blit_line (lx0, x1, ly0-1, y1, y_buffer, y_stride);
-
- constrain_line (lx0, &x1, ly0+1, &y1, width, height);
- vp8_blit_line (lx0, x1, ly0+1, y1, y_buffer, y_stride);
- }
- else
- vp8_blit_line (lx0, x1, ly0, y1, y_buffer, y_stride);
- }
-
- mi++;
+ }
}
- mi++;
+ }
+ } else if (mi->mbmi.mode >= NEARESTMV) {
+ MV *mv = &mi->mbmi.mv.as_mv;
+ const int lx0 = x0 + 8;
+ const int ly0 = y0 + 8;
+
+ x1 = lx0 + (mv->col >> 3);
+ y1 = ly0 + (mv->row >> 3);
+
+ if (x1 != lx0 && y1 != ly0) {
+ constrain_line(lx0, &x1, ly0 - 1, &y1, width, height);
+ vp8_blit_line(lx0, x1, ly0 - 1, y1, y_buffer, y_stride);
+
+ constrain_line(lx0, &x1, ly0 + 1, &y1, width, height);
+ vp8_blit_line(lx0, x1, ly0 + 1, y1, y_buffer, y_stride);
+ } else
+ vp8_blit_line(lx0, x1, ly0, y1, y_buffer, y_stride);
}
- }
- /* Color in block modes */
- if ((flags & VP8D_DEBUG_CLR_BLK_MODES)
- && (ppflags->display_mb_modes_flag || ppflags->display_b_modes_flag))
- {
- int y, x;
- YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
- int width = post->y_width;
- int height = post->y_height;
- unsigned char *y_ptr = oci->post_proc_buffer.y_buffer;
- unsigned char *u_ptr = oci->post_proc_buffer.u_buffer;
- unsigned char *v_ptr = oci->post_proc_buffer.v_buffer;
- int y_stride = oci->post_proc_buffer.y_stride;
- MODE_INFO *mi = oci->mi;
-
- for (y = 0; y < height; y += 16)
- {
- for (x = 0; x < width; x += 16)
- {
- int Y = 0, U = 0, V = 0;
-
- if (mi->mbmi.mode == B_PRED &&
- ((ppflags->display_mb_modes_flag & B_PRED) || ppflags->display_b_modes_flag))
- {
- int by, bx;
- unsigned char *yl, *ul, *vl;
- union b_mode_info *bmi = mi->bmi;
-
- yl = y_ptr + x;
- ul = u_ptr + (x>>1);
- vl = v_ptr + (x>>1);
-
- for (by = 0; by < 16; by += 4)
- {
- for (bx = 0; bx < 16; bx += 4)
- {
- if ((ppflags->display_b_modes_flag & (1<<mi->mbmi.mode))
- || (ppflags->display_mb_modes_flag & B_PRED))
- {
- Y = B_PREDICTION_MODE_colors[bmi->as_mode.first][0];
- U = B_PREDICTION_MODE_colors[bmi->as_mode.first][1];
- V = B_PREDICTION_MODE_colors[bmi->as_mode.first][2];
-
- POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_b)
- (yl+bx, ul+(bx>>1), vl+(bx>>1), Y, U, V, 0xc000, y_stride);
- }
- bmi++;
- }
-
- yl += y_stride*4;
- ul += y_stride*1;
- vl += y_stride*1;
- }
- }
- else if (ppflags->display_mb_modes_flag & (1<<mi->mbmi.mode))
- {
- Y = MB_PREDICTION_MODE_colors[mi->mbmi.mode][0];
- U = MB_PREDICTION_MODE_colors[mi->mbmi.mode][1];
- V = MB_PREDICTION_MODE_colors[mi->mbmi.mode][2];
-
- POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb_inner)
- (y_ptr+x, u_ptr+(x>>1), v_ptr+(x>>1), Y, U, V, 0xc000, y_stride);
- }
-
- mi++;
+ mi++;
+ }
+ mi++;
+ }
+ }
+
+ /* Color in block modes */
+ if ((flags & VP8D_DEBUG_CLR_BLK_MODES)
+ && (ppflags->display_mb_modes_flag || ppflags->display_b_modes_flag)) {
+ int y, x;
+ YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+ int width = post->y_width;
+ int height = post->y_height;
+ unsigned char *y_ptr = oci->post_proc_buffer.y_buffer;
+ unsigned char *u_ptr = oci->post_proc_buffer.u_buffer;
+ unsigned char *v_ptr = oci->post_proc_buffer.v_buffer;
+ int y_stride = oci->post_proc_buffer.y_stride;
+ MODE_INFO *mi = oci->mi;
+
+ for (y = 0; y < height; y += 16) {
+ for (x = 0; x < width; x += 16) {
+ int Y = 0, U = 0, V = 0;
+
+ if (mi->mbmi.mode == B_PRED &&
+ ((ppflags->display_mb_modes_flag & B_PRED) || ppflags->display_b_modes_flag)) {
+ int by, bx;
+ unsigned char *yl, *ul, *vl;
+ union b_mode_info *bmi = mi->bmi;
+
+ yl = y_ptr + x;
+ ul = u_ptr + (x >> 1);
+ vl = v_ptr + (x >> 1);
+
+ for (by = 0; by < 16; by += 4) {
+ for (bx = 0; bx < 16; bx += 4) {
+ if ((ppflags->display_b_modes_flag & (1 << mi->mbmi.mode))
+ || (ppflags->display_mb_modes_flag & B_PRED)) {
+ Y = B_PREDICTION_MODE_colors[bmi->as_mode.first][0];
+ U = B_PREDICTION_MODE_colors[bmi->as_mode.first][1];
+ V = B_PREDICTION_MODE_colors[bmi->as_mode.first][2];
+
+ POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_b)
+ (yl + bx, ul + (bx >> 1), vl + (bx >> 1), Y, U, V, 0xc000, y_stride);
+ }
+ bmi++;
}
- y_ptr += y_stride*16;
- u_ptr += y_stride*4;
- v_ptr += y_stride*4;
- mi++;
+ yl += y_stride * 4;
+ ul += y_stride * 1;
+ vl += y_stride * 1;
+ }
+ } else if (ppflags->display_mb_modes_flag & (1 << mi->mbmi.mode)) {
+ Y = MB_PREDICTION_MODE_colors[mi->mbmi.mode][0];
+ U = MB_PREDICTION_MODE_colors[mi->mbmi.mode][1];
+ V = MB_PREDICTION_MODE_colors[mi->mbmi.mode][2];
+
+ POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb_inner)
+ (y_ptr + x, u_ptr + (x >> 1), v_ptr + (x >> 1), Y, U, V, 0xc000, y_stride);
}
- }
- /* Color in frame reference blocks */
- if ((flags & VP8D_DEBUG_CLR_FRM_REF_BLKS) && ppflags->display_ref_frame_flag)
- {
- int y, x;
- YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
- int width = post->y_width;
- int height = post->y_height;
- unsigned char *y_ptr = oci->post_proc_buffer.y_buffer;
- unsigned char *u_ptr = oci->post_proc_buffer.u_buffer;
- unsigned char *v_ptr = oci->post_proc_buffer.v_buffer;
- int y_stride = oci->post_proc_buffer.y_stride;
- MODE_INFO *mi = oci->mi;
-
- for (y = 0; y < height; y += 16)
- {
- for (x = 0; x < width; x +=16)
- {
- int Y = 0, U = 0, V = 0;
-
- if (ppflags->display_ref_frame_flag & (1<<mi->mbmi.ref_frame))
- {
- Y = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][0];
- U = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][1];
- V = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][2];
-
- POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb_outer)
- (y_ptr+x, u_ptr+(x>>1), v_ptr+(x>>1), Y, U, V, 0xc000, y_stride);
- }
+ mi++;
+ }
+ y_ptr += y_stride * 16;
+ u_ptr += y_stride * 4;
+ v_ptr += y_stride * 4;
+
+ mi++;
+ }
+ }
+
+ /* Color in frame reference blocks */
+ if ((flags & VP8D_DEBUG_CLR_FRM_REF_BLKS) && ppflags->display_ref_frame_flag) {
+ int y, x;
+ YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+ int width = post->y_width;
+ int height = post->y_height;
+ unsigned char *y_ptr = oci->post_proc_buffer.y_buffer;
+ unsigned char *u_ptr = oci->post_proc_buffer.u_buffer;
+ unsigned char *v_ptr = oci->post_proc_buffer.v_buffer;
+ int y_stride = oci->post_proc_buffer.y_stride;
+ MODE_INFO *mi = oci->mi;
+
+ for (y = 0; y < height; y += 16) {
+ for (x = 0; x < width; x += 16) {
+ int Y = 0, U = 0, V = 0;
+
+ if (ppflags->display_ref_frame_flag & (1 << mi->mbmi.ref_frame)) {
+ Y = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][0];
+ U = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][1];
+ V = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][2];
+
+ POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb_outer)
+ (y_ptr + x, u_ptr + (x >> 1), v_ptr + (x >> 1), Y, U, V, 0xc000, y_stride);
+ }
- mi++;
- }
- y_ptr += y_stride*16;
- u_ptr += y_stride*4;
- v_ptr += y_stride*4;
+ mi++;
+ }
+ y_ptr += y_stride * 16;
+ u_ptr += y_stride * 4;
+ v_ptr += y_stride * 4;
- mi++;
- }
+ mi++;
}
+ }
#endif
- *dest = oci->post_proc_buffer;
+ *dest = oci->post_proc_buffer;
- /* handle problem with extending borders */
- dest->y_width = oci->Width;
- dest->y_height = oci->Height;
- dest->uv_height = dest->y_height / 2;
- return 0;
+ /* handle problem with extending borders */
+ dest->y_width = oci->Width;
+ dest->y_height = oci->Height;
+ dest->uv_height = dest->y_height / 2;
+ return 0;
}
diff --git a/vp8/common/postproc.h b/vp8/common/postproc.h
index c641b9ca5..322089210 100644
--- a/vp8/common/postproc.h
+++ b/vp8/common/postproc.h
@@ -13,28 +13,28 @@
#define POSTPROC_H
#define prototype_postproc_inplace(sym)\
- void sym (unsigned char *dst, int pitch, int rows, int cols,int flimit)
+ void sym (unsigned char *dst, int pitch, int rows, int cols,int flimit)
#define prototype_postproc(sym)\
- void sym (unsigned char *src, unsigned char *dst, int src_pitch,\
- int dst_pitch, int rows, int cols, int flimit)
+ void sym (unsigned char *src, unsigned char *dst, int src_pitch,\
+ int dst_pitch, int rows, int cols, int flimit)
#define prototype_postproc_addnoise(sym) \
- void sym (unsigned char *s, char *noise, char blackclamp[16],\
- char whiteclamp[16], char bothclamp[16],\
- unsigned int w, unsigned int h, int pitch)
+ void sym (unsigned char *s, char *noise, char blackclamp[16],\
+ char whiteclamp[16], char bothclamp[16],\
+ unsigned int w, unsigned int h, int pitch)
#define prototype_postproc_blend_mb_inner(sym)\
- void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
- int y1, int u1, int v1, int alpha, int stride)
+ void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
+ int y1, int u1, int v1, int alpha, int stride)
#define prototype_postproc_blend_mb_outer(sym)\
- void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
- int y1, int u1, int v1, int alpha, int stride)
+ void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
+ int y1, int u1, int v1, int alpha, int stride)
#define prototype_postproc_blend_b(sym)\
- void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
- int y1, int u1, int v1, int alpha, int stride)
+ void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
+ int y1, int u1, int v1, int alpha, int stride)
#if ARCH_X86 || ARCH_X86_64
#include "x86/postproc_x86.h"
@@ -81,15 +81,14 @@ typedef prototype_postproc_addnoise((*vp8_postproc_addnoise_fn_t));
typedef prototype_postproc_blend_mb_inner((*vp8_postproc_blend_mb_inner_fn_t));
typedef prototype_postproc_blend_mb_outer((*vp8_postproc_blend_mb_outer_fn_t));
typedef prototype_postproc_blend_b((*vp8_postproc_blend_b_fn_t));
-typedef struct
-{
- vp8_postproc_inplace_fn_t down;
- vp8_postproc_inplace_fn_t across;
- vp8_postproc_fn_t downacross;
- vp8_postproc_addnoise_fn_t addnoise;
- vp8_postproc_blend_mb_inner_fn_t blend_mb_inner;
- vp8_postproc_blend_mb_outer_fn_t blend_mb_outer;
- vp8_postproc_blend_b_fn_t blend_b;
+typedef struct {
+ vp8_postproc_inplace_fn_t down;
+ vp8_postproc_inplace_fn_t across;
+ vp8_postproc_fn_t downacross;
+ vp8_postproc_addnoise_fn_t addnoise;
+ vp8_postproc_blend_mb_inner_fn_t blend_mb_inner;
+ vp8_postproc_blend_mb_outer_fn_t blend_mb_outer;
+ vp8_postproc_blend_b_fn_t blend_b;
} vp8_postproc_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
@@ -99,14 +98,13 @@ typedef struct
#endif
#include "vpx_ports/mem.h"
-struct postproc_state
-{
- int last_q;
- int last_noise;
- char noise[3072];
- DECLARE_ALIGNED(16, char, blackclamp[16]);
- DECLARE_ALIGNED(16, char, whiteclamp[16]);
- DECLARE_ALIGNED(16, char, bothclamp[16]);
+struct postproc_state {
+ int last_q;
+ int last_noise;
+ char noise[3072];
+ DECLARE_ALIGNED(16, char, blackclamp[16]);
+ DECLARE_ALIGNED(16, char, whiteclamp[16]);
+ DECLARE_ALIGNED(16, char, bothclamp[16]);
};
#include "onyxc_int.h"
#include "ppflags.h"
diff --git a/vp8/common/ppc/loopfilter_altivec.c b/vp8/common/ppc/loopfilter_altivec.c
index 71bf6e2d7..962da2319 100644
--- a/vp8/common/ppc/loopfilter_altivec.c
+++ b/vp8/common/ppc/loopfilter_altivec.c
@@ -14,28 +14,28 @@
typedef void loop_filter_function_y_ppc
(
- unsigned char *s, // source pointer
- int p, // pitch
- const signed char *flimit,
- const signed char *limit,
- const signed char *thresh
+ unsigned char *s, // source pointer
+ int p, // pitch
+ const signed char *flimit,
+ const signed char *limit,
+ const signed char *thresh
);
typedef void loop_filter_function_uv_ppc
(
- unsigned char *u, // source pointer
- unsigned char *v, // source pointer
- int p, // pitch
- const signed char *flimit,
- const signed char *limit,
- const signed char *thresh
+ unsigned char *u, // source pointer
+ unsigned char *v, // source pointer
+ int p, // pitch
+ const signed char *flimit,
+ const signed char *limit,
+ const signed char *thresh
);
typedef void loop_filter_function_s_ppc
(
- unsigned char *s, // source pointer
- int p, // pitch
- const signed char *flimit
+ unsigned char *s, // source pointer
+ int p, // pitch
+ const signed char *flimit
);
loop_filter_function_y_ppc mbloop_filter_horizontal_edge_y_ppc;
@@ -53,83 +53,75 @@ loop_filter_function_s_ppc loop_filter_simple_vertical_edge_ppc;
// Horizontal MB filtering
void loop_filter_mbh_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- mbloop_filter_horizontal_edge_y_ppc(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->thr);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ mbloop_filter_horizontal_edge_y_ppc(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->thr);
- if (u_ptr)
- mbloop_filter_horizontal_edge_uv_ppc(u_ptr, v_ptr, uv_stride, lfi->mbflim, lfi->lim, lfi->thr);
+ if (u_ptr)
+ mbloop_filter_horizontal_edge_uv_ppc(u_ptr, v_ptr, uv_stride, lfi->mbflim, lfi->lim, lfi->thr);
}
void loop_filter_mbhs_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- (void)u_ptr;
- (void)v_ptr;
- (void)uv_stride;
- loop_filter_simple_horizontal_edge_ppc(y_ptr, y_stride, lfi->mbflim);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ (void)u_ptr;
+ (void)v_ptr;
+ (void)uv_stride;
+ loop_filter_simple_horizontal_edge_ppc(y_ptr, y_stride, lfi->mbflim);
}
// Vertical MB Filtering
void loop_filter_mbv_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- mbloop_filter_vertical_edge_y_ppc(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->thr);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ mbloop_filter_vertical_edge_y_ppc(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->thr);
- if (u_ptr)
- mbloop_filter_vertical_edge_uv_ppc(u_ptr, v_ptr, uv_stride, lfi->mbflim, lfi->lim, lfi->thr);
+ if (u_ptr)
+ mbloop_filter_vertical_edge_uv_ppc(u_ptr, v_ptr, uv_stride, lfi->mbflim, lfi->lim, lfi->thr);
}
void loop_filter_mbvs_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- (void)u_ptr;
- (void)v_ptr;
- (void)uv_stride;
- loop_filter_simple_vertical_edge_ppc(y_ptr, y_stride, lfi->mbflim);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ (void)u_ptr;
+ (void)v_ptr;
+ (void)uv_stride;
+ loop_filter_simple_vertical_edge_ppc(y_ptr, y_stride, lfi->mbflim);
}
// Horizontal B Filtering
void loop_filter_bh_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- // These should all be done at once with one call, instead of 3
- loop_filter_horizontal_edge_y_ppc(y_ptr + 4 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
- loop_filter_horizontal_edge_y_ppc(y_ptr + 8 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
- loop_filter_horizontal_edge_y_ppc(y_ptr + 12 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
-
- if (u_ptr)
- loop_filter_horizontal_edge_uv_ppc(u_ptr + 4 * uv_stride, v_ptr + 4 * uv_stride, uv_stride, lfi->flim, lfi->lim, lfi->thr);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ // These should all be done at once with one call, instead of 3
+ loop_filter_horizontal_edge_y_ppc(y_ptr + 4 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
+ loop_filter_horizontal_edge_y_ppc(y_ptr + 8 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
+ loop_filter_horizontal_edge_y_ppc(y_ptr + 12 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr);
+
+ if (u_ptr)
+ loop_filter_horizontal_edge_uv_ppc(u_ptr + 4 * uv_stride, v_ptr + 4 * uv_stride, uv_stride, lfi->flim, lfi->lim, lfi->thr);
}
void loop_filter_bhs_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- (void)u_ptr;
- (void)v_ptr;
- (void)uv_stride;
- loop_filter_simple_horizontal_edge_ppc(y_ptr + 4 * y_stride, y_stride, lfi->flim);
- loop_filter_simple_horizontal_edge_ppc(y_ptr + 8 * y_stride, y_stride, lfi->flim);
- loop_filter_simple_horizontal_edge_ppc(y_ptr + 12 * y_stride, y_stride, lfi->flim);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ (void)u_ptr;
+ (void)v_ptr;
+ (void)uv_stride;
+ loop_filter_simple_horizontal_edge_ppc(y_ptr + 4 * y_stride, y_stride, lfi->flim);
+ loop_filter_simple_horizontal_edge_ppc(y_ptr + 8 * y_stride, y_stride, lfi->flim);
+ loop_filter_simple_horizontal_edge_ppc(y_ptr + 12 * y_stride, y_stride, lfi->flim);
}
// Vertical B Filtering
void loop_filter_bv_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- loop_filter_vertical_edge_y_ppc(y_ptr, y_stride, lfi->flim, lfi->lim, lfi->thr);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ loop_filter_vertical_edge_y_ppc(y_ptr, y_stride, lfi->flim, lfi->lim, lfi->thr);
- if (u_ptr)
- loop_filter_vertical_edge_uv_ppc(u_ptr + 4, v_ptr + 4, uv_stride, lfi->flim, lfi->lim, lfi->thr);
+ if (u_ptr)
+ loop_filter_vertical_edge_uv_ppc(u_ptr + 4, v_ptr + 4, uv_stride, lfi->flim, lfi->lim, lfi->thr);
}
void loop_filter_bvs_ppc(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- (void)u_ptr;
- (void)v_ptr;
- (void)uv_stride;
- loop_filter_simple_vertical_edge_ppc(y_ptr + 4, y_stride, lfi->flim);
- loop_filter_simple_vertical_edge_ppc(y_ptr + 8, y_stride, lfi->flim);
- loop_filter_simple_vertical_edge_ppc(y_ptr + 12, y_stride, lfi->flim);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ (void)u_ptr;
+ (void)v_ptr;
+ (void)uv_stride;
+ loop_filter_simple_vertical_edge_ppc(y_ptr + 4, y_stride, lfi->flim);
+ loop_filter_simple_vertical_edge_ppc(y_ptr + 8, y_stride, lfi->flim);
+ loop_filter_simple_vertical_edge_ppc(y_ptr + 12, y_stride, lfi->flim);
}
diff --git a/vp8/common/ppc/systemdependent.c b/vp8/common/ppc/systemdependent.c
index 1f5d79068..6d68b9a03 100644
--- a/vp8/common/ppc/systemdependent.c
+++ b/vp8/common/ppc/systemdependent.c
@@ -21,13 +21,13 @@ void (*vp8_short_idct4x4_1)(short *input, short *output, int pitch);
void (*vp8_dc_only_idct)(short input_dc, short *output, int pitch);
extern void (*vp8_post_proc_down_and_across)(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- int src_pixels_per_line,
- int dst_pixels_per_line,
- int rows,
- int cols,
- int flimit
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ int src_pixels_per_line,
+ int dst_pixels_per_line,
+ int rows,
+ int cols,
+ int flimit
);
extern void (*vp8_mbpost_proc_down)(unsigned char *dst, int pitch, int rows, int cols, int flimit);
@@ -37,13 +37,13 @@ extern void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows,
extern void vp8_post_proc_down_and_across_c
(
- unsigned char *src_ptr,
- unsigned char *dst_ptr,
- int src_pixels_per_line,
- int dst_pixels_per_line,
- int rows,
- int cols,
- int flimit
+ unsigned char *src_ptr,
+ unsigned char *dst_ptr,
+ int src_pixels_per_line,
+ int dst_pixels_per_line,
+ int rows,
+ int cols,
+ int flimit
);
void vp8_plane_add_noise_c(unsigned char *Start, unsigned int Width, unsigned int Height, int Pitch, int q, int a);
@@ -123,49 +123,47 @@ extern loop_filter_block_function *vp8_lf_mbhsimple;
extern loop_filter_block_function *vp8_lf_bvsimple;
extern loop_filter_block_function *vp8_lf_bhsimple;
-void vp8_clear_c(void)
-{
+void vp8_clear_c(void) {
}
-void vp8_machine_specific_config(void)
-{
- // Pure C:
- vp8_clear_system_state = vp8_clear_c;
- vp8_recon_b = vp8_recon_b_c;
- vp8_recon4b = vp8_recon4b_c;
- vp8_recon2b = vp8_recon2b_c;
-
- vp8_bilinear_predict16x16 = bilinear_predict16x16_ppc;
- vp8_bilinear_predict8x8 = bilinear_predict8x8_ppc;
- vp8_bilinear_predict8x4 = bilinear_predict8x4_ppc;
- vp8_bilinear_predict = bilinear_predict4x4_ppc;
-
- vp8_sixtap_predict16x16 = sixtap_predict16x16_ppc;
- vp8_sixtap_predict8x8 = sixtap_predict8x8_ppc;
- vp8_sixtap_predict8x4 = sixtap_predict8x4_ppc;
- vp8_sixtap_predict = sixtap_predict_ppc;
-
- vp8_short_idct4x4_1 = vp8_short_idct4x4llm_1_c;
- vp8_short_idct4x4 = short_idct4x4llm_ppc;
- vp8_dc_only_idct = vp8_dc_only_idct_c;
-
- vp8_lf_mbvfull = loop_filter_mbv_ppc;
- vp8_lf_bvfull = loop_filter_bv_ppc;
- vp8_lf_mbhfull = loop_filter_mbh_ppc;
- vp8_lf_bhfull = loop_filter_bh_ppc;
-
- vp8_lf_mbvsimple = loop_filter_mbvs_ppc;
- vp8_lf_bvsimple = loop_filter_bvs_ppc;
- vp8_lf_mbhsimple = loop_filter_mbhs_ppc;
- vp8_lf_bhsimple = loop_filter_bhs_ppc;
-
- vp8_post_proc_down_and_across = vp8_post_proc_down_and_across_c;
- vp8_mbpost_proc_down = vp8_mbpost_proc_down_c;
- vp8_mbpost_proc_across_ip = vp8_mbpost_proc_across_ip_c;
- vp8_plane_add_noise = vp8_plane_add_noise_c;
-
- vp8_copy_mem16x16 = copy_mem16x16_ppc;
- vp8_copy_mem8x8 = vp8_copy_mem8x8_c;
- vp8_copy_mem8x4 = vp8_copy_mem8x4_c;
+void vp8_machine_specific_config(void) {
+ // Pure C:
+ vp8_clear_system_state = vp8_clear_c;
+ vp8_recon_b = vp8_recon_b_c;
+ vp8_recon4b = vp8_recon4b_c;
+ vp8_recon2b = vp8_recon2b_c;
+
+ vp8_bilinear_predict16x16 = bilinear_predict16x16_ppc;
+ vp8_bilinear_predict8x8 = bilinear_predict8x8_ppc;
+ vp8_bilinear_predict8x4 = bilinear_predict8x4_ppc;
+ vp8_bilinear_predict = bilinear_predict4x4_ppc;
+
+ vp8_sixtap_predict16x16 = sixtap_predict16x16_ppc;
+ vp8_sixtap_predict8x8 = sixtap_predict8x8_ppc;
+ vp8_sixtap_predict8x4 = sixtap_predict8x4_ppc;
+ vp8_sixtap_predict = sixtap_predict_ppc;
+
+ vp8_short_idct4x4_1 = vp8_short_idct4x4llm_1_c;
+ vp8_short_idct4x4 = short_idct4x4llm_ppc;
+ vp8_dc_only_idct = vp8_dc_only_idct_c;
+
+ vp8_lf_mbvfull = loop_filter_mbv_ppc;
+ vp8_lf_bvfull = loop_filter_bv_ppc;
+ vp8_lf_mbhfull = loop_filter_mbh_ppc;
+ vp8_lf_bhfull = loop_filter_bh_ppc;
+
+ vp8_lf_mbvsimple = loop_filter_mbvs_ppc;
+ vp8_lf_bvsimple = loop_filter_bvs_ppc;
+ vp8_lf_mbhsimple = loop_filter_mbhs_ppc;
+ vp8_lf_bhsimple = loop_filter_bhs_ppc;
+
+ vp8_post_proc_down_and_across = vp8_post_proc_down_and_across_c;
+ vp8_mbpost_proc_down = vp8_mbpost_proc_down_c;
+ vp8_mbpost_proc_across_ip = vp8_mbpost_proc_across_ip_c;
+ vp8_plane_add_noise = vp8_plane_add_noise_c;
+
+ vp8_copy_mem16x16 = copy_mem16x16_ppc;
+ vp8_copy_mem8x8 = vp8_copy_mem8x8_c;
+ vp8_copy_mem8x4 = vp8_copy_mem8x4_c;
}
diff --git a/vp8/common/ppflags.h b/vp8/common/ppflags.h
index 65b0cab6a..9d3f1a8af 100644
--- a/vp8/common/ppflags.h
+++ b/vp8/common/ppflags.h
@@ -11,30 +11,28 @@
#ifndef __INC_PPFLAGS_H
#define __INC_PPFLAGS_H
-enum
-{
- VP8D_NOFILTERING = 0,
- VP8D_DEBLOCK = 1<<0,
- VP8D_DEMACROBLOCK = 1<<1,
- VP8D_ADDNOISE = 1<<2,
- VP8D_DEBUG_TXT_FRAME_INFO = 1<<3,
- VP8D_DEBUG_TXT_MBLK_MODES = 1<<4,
- VP8D_DEBUG_TXT_DC_DIFF = 1<<5,
- VP8D_DEBUG_TXT_RATE_INFO = 1<<6,
- VP8D_DEBUG_DRAW_MV = 1<<7,
- VP8D_DEBUG_CLR_BLK_MODES = 1<<8,
- VP8D_DEBUG_CLR_FRM_REF_BLKS = 1<<9
+enum {
+ VP8D_NOFILTERING = 0,
+ VP8D_DEBLOCK = 1 << 0,
+ VP8D_DEMACROBLOCK = 1 << 1,
+ VP8D_ADDNOISE = 1 << 2,
+ VP8D_DEBUG_TXT_FRAME_INFO = 1 << 3,
+ VP8D_DEBUG_TXT_MBLK_MODES = 1 << 4,
+ VP8D_DEBUG_TXT_DC_DIFF = 1 << 5,
+ VP8D_DEBUG_TXT_RATE_INFO = 1 << 6,
+ VP8D_DEBUG_DRAW_MV = 1 << 7,
+ VP8D_DEBUG_CLR_BLK_MODES = 1 << 8,
+ VP8D_DEBUG_CLR_FRM_REF_BLKS = 1 << 9
};
-typedef struct
-{
- int post_proc_flag;
- int deblocking_level;
- int noise_level;
- int display_ref_frame_flag;
- int display_mb_modes_flag;
- int display_b_modes_flag;
- int display_mv_flag;
+typedef struct {
+ int post_proc_flag;
+ int deblocking_level;
+ int noise_level;
+ int display_ref_frame_flag;
+ int display_mb_modes_flag;
+ int display_b_modes_flag;
+ int display_mv_flag;
} vp8_ppflags_t;
#endif
diff --git a/vp8/common/pred_common.c b/vp8/common/pred_common.c
index 02a626575..f617a0fb4 100644
--- a/vp8/common/pred_common.c
+++ b/vp8/common/pred_common.c
@@ -14,169 +14,161 @@
// TBD prediction functions for various bitstream signals
// Returns a context number for the given MB prediction signal
-unsigned char get_pred_context( VP8_COMMON *const cm,
- MACROBLOCKD *const xd,
- PRED_ID pred_id )
-{
- int pred_context;
- MODE_INFO *m = xd->mode_info_context;
-
- // Note:
- // The mode info data structure has a one element border above and to the
- // left of the entries correpsonding to real macroblocks.
- // The prediction flags in these dummy entries are initialised to 0.
- switch (pred_id)
- {
+unsigned char get_pred_context(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd,
+ PRED_ID pred_id) {
+ int pred_context;
+ MODE_INFO *m = xd->mode_info_context;
+
+ // Note:
+ // The mode info data structure has a one element border above and to the
+ // left of the entries correpsonding to real macroblocks.
+ // The prediction flags in these dummy entries are initialised to 0.
+ switch (pred_id) {
case PRED_SEG_ID:
- pred_context = (m - 1)->mbmi.seg_id_predicted +
- (m - cm->mode_info_stride)->mbmi.seg_id_predicted;
- break;
+ pred_context = (m - 1)->mbmi.seg_id_predicted +
+ (m - cm->mode_info_stride)->mbmi.seg_id_predicted;
+ break;
case PRED_REF:
- pred_context = (m - 1)->mbmi.ref_predicted +
- (m - cm->mode_info_stride)->mbmi.ref_predicted;
- break;
+ pred_context = (m - 1)->mbmi.ref_predicted +
+ (m - cm->mode_info_stride)->mbmi.ref_predicted;
+ break;
case PRED_COMP:
- // Context based on use of comp pred flag by neighbours
- //pred_context =
- // ((m - 1)->mbmi.second_ref_frame != INTRA_FRAME) +
- // ((m - cm->mode_info_stride)->mbmi.second_ref_frame != INTRA_FRAME);
-
- // Context based on mode and reference frame
- //if ( m->mbmi.ref_frame == LAST_FRAME )
- // pred_context = 0 + (m->mbmi.mode != ZEROMV);
- //else if ( m->mbmi.ref_frame == GOLDEN_FRAME )
- // pred_context = 2 + (m->mbmi.mode != ZEROMV);
- //else
- // pred_context = 4 + (m->mbmi.mode != ZEROMV);
-
- if ( m->mbmi.ref_frame == LAST_FRAME )
- pred_context = 0;
- else
- pred_context = 1;
-
- break;
+ // Context based on use of comp pred flag by neighbours
+ // pred_context =
+ // ((m - 1)->mbmi.second_ref_frame != INTRA_FRAME) +
+ // ((m - cm->mode_info_stride)->mbmi.second_ref_frame != INTRA_FRAME);
+
+ // Context based on mode and reference frame
+ // if ( m->mbmi.ref_frame == LAST_FRAME )
+ // pred_context = 0 + (m->mbmi.mode != ZEROMV);
+ // else if ( m->mbmi.ref_frame == GOLDEN_FRAME )
+ // pred_context = 2 + (m->mbmi.mode != ZEROMV);
+ // else
+ // pred_context = 4 + (m->mbmi.mode != ZEROMV);
+
+ if (m->mbmi.ref_frame == LAST_FRAME)
+ pred_context = 0;
+ else
+ pred_context = 1;
+
+ break;
#if CONFIG_NEWENTROPY
case PRED_MBSKIP:
- pred_context = (m - 1)->mbmi.mb_skip_coeff +
- (m - cm->mode_info_stride)->mbmi.mb_skip_coeff;
- break;
+ pred_context = (m - 1)->mbmi.mb_skip_coeff +
+ (m - cm->mode_info_stride)->mbmi.mb_skip_coeff;
+ break;
#endif
default:
- // TODO *** add error trap code.
- pred_context = 0;
- break;
- }
+ // TODO *** add error trap code.
+ pred_context = 0;
+ break;
+ }
- return pred_context;
+ return pred_context;
}
// This function returns a context probability for coding a given
// prediction signal
-vp8_prob get_pred_prob( VP8_COMMON *const cm,
- MACROBLOCKD *const xd,
- PRED_ID pred_id )
-{
- vp8_prob pred_probability;
- int pred_context;
-
- // Get the appropriate prediction context
- pred_context = get_pred_context( cm, xd, pred_id );
-
- switch (pred_id)
- {
+vp8_prob get_pred_prob(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd,
+ PRED_ID pred_id) {
+ vp8_prob pred_probability;
+ int pred_context;
+
+ // Get the appropriate prediction context
+ pred_context = get_pred_context(cm, xd, pred_id);
+
+ switch (pred_id) {
case PRED_SEG_ID:
- pred_probability = cm->segment_pred_probs[pred_context];
- break;
+ pred_probability = cm->segment_pred_probs[pred_context];
+ break;
case PRED_REF:
- pred_probability = cm->ref_pred_probs[pred_context];
- break;
+ pred_probability = cm->ref_pred_probs[pred_context];
+ break;
case PRED_COMP:
- // In keeping with convention elsewhre the probability returned is
- // the probability of a "0" outcome which in this case means the
- // probability of comp pred off.
- pred_probability = cm->prob_comppred[pred_context];
- break;
+ // In keeping with convention elsewhre the probability returned is
+ // the probability of a "0" outcome which in this case means the
+ // probability of comp pred off.
+ pred_probability = cm->prob_comppred[pred_context];
+ break;
#if CONFIG_NEWENTROPY
case PRED_MBSKIP:
- pred_probability = cm->mbskip_pred_probs[pred_context];
- break;
+ pred_probability = cm->mbskip_pred_probs[pred_context];
+ break;
#endif
default:
- // TODO *** add error trap code.
- pred_probability = 128;
- break;
- }
+ // TODO *** add error trap code.
+ pred_probability = 128;
+ break;
+ }
- return pred_probability;
+ return pred_probability;
}
// This function returns the status of the given prediction signal.
// I.e. is the predicted value for the given signal correct.
-unsigned char get_pred_flag( MACROBLOCKD *const xd,
- PRED_ID pred_id )
-{
- unsigned char pred_flag = 0;
+unsigned char get_pred_flag(MACROBLOCKD *const xd,
+ PRED_ID pred_id) {
+ unsigned char pred_flag = 0;
- switch (pred_id)
- {
+ switch (pred_id) {
case PRED_SEG_ID:
- pred_flag = xd->mode_info_context->mbmi.seg_id_predicted;
- break;
+ pred_flag = xd->mode_info_context->mbmi.seg_id_predicted;
+ break;
case PRED_REF:
- pred_flag = xd->mode_info_context->mbmi.ref_predicted;
- break;
+ pred_flag = xd->mode_info_context->mbmi.ref_predicted;
+ break;
#if CONFIG_NEWENTROPY
case PRED_MBSKIP:
- pred_flag = xd->mode_info_context->mbmi.mb_skip_coeff;
- break;
+ pred_flag = xd->mode_info_context->mbmi.mb_skip_coeff;
+ break;
#endif
default:
- // TODO *** add error trap code.
- pred_flag = 0;
- break;
- }
+ // TODO *** add error trap code.
+ pred_flag = 0;
+ break;
+ }
- return pred_flag;
+ return pred_flag;
}
// This function sets the status of the given prediction signal.
// I.e. is the predicted value for the given signal correct.
-void set_pred_flag( MACROBLOCKD *const xd,
- PRED_ID pred_id,
- unsigned char pred_flag)
-{
- switch (pred_id)
- {
+void set_pred_flag(MACROBLOCKD *const xd,
+ PRED_ID pred_id,
+ unsigned char pred_flag) {
+ switch (pred_id) {
case PRED_SEG_ID:
- xd->mode_info_context->mbmi.seg_id_predicted = pred_flag;
- break;
+ xd->mode_info_context->mbmi.seg_id_predicted = pred_flag;
+ break;
case PRED_REF:
- xd->mode_info_context->mbmi.ref_predicted = pred_flag;
- break;
+ xd->mode_info_context->mbmi.ref_predicted = pred_flag;
+ break;
#if CONFIG_NEWENTROPY
case PRED_MBSKIP:
- xd->mode_info_context->mbmi.mb_skip_coeff = pred_flag;
- break;
+ xd->mode_info_context->mbmi.mb_skip_coeff = pred_flag;
+ break;
#endif
default:
- // TODO *** add error trap code.
- break;
- }
+ // TODO *** add error trap code.
+ break;
+ }
}
@@ -184,123 +176,107 @@ void set_pred_flag( MACROBLOCKD *const xd,
// peredict various bitstream signals.
// Macroblock segment id prediction function
-unsigned char get_pred_mb_segid( VP8_COMMON *const cm, int MbIndex )
-{
- // Currently the prediction for the macroblock segment ID is
- // the value stored for this macroblock in the previous frame.
- return cm->last_frame_seg_map[MbIndex];
+unsigned char get_pred_mb_segid(VP8_COMMON *const cm, int MbIndex) {
+ // Currently the prediction for the macroblock segment ID is
+ // the value stored for this macroblock in the previous frame.
+ return cm->last_frame_seg_map[MbIndex];
}
-MV_REFERENCE_FRAME get_pred_ref( VP8_COMMON *const cm,
- MACROBLOCKD *const xd )
-{
- MODE_INFO *m = xd->mode_info_context;
-
- MV_REFERENCE_FRAME left;
- MV_REFERENCE_FRAME above;
- MV_REFERENCE_FRAME above_left;
- MV_REFERENCE_FRAME pred_ref = LAST_FRAME;
-
- int segment_id = xd->mode_info_context->mbmi.segment_id;
- int seg_ref_active;
- int i;
-
- unsigned char frame_allowed[MAX_REF_FRAMES] = {1,1,1,1};
- unsigned char ref_score[MAX_REF_FRAMES];
- unsigned char best_score = 0;
- unsigned char left_in_image;
- unsigned char above_in_image;
- unsigned char above_left_in_image;
-
- // Is segment coding ennabled
- seg_ref_active = segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME );
-
- // Special case treatment if segment coding is enabled.
- // Dont allow prediction of a reference frame that the segment
- // does not allow
- if ( seg_ref_active )
- {
- for ( i = 0; i < MAX_REF_FRAMES; i++ )
- {
- frame_allowed[i] =
- check_segref( xd, segment_id, i );
-
- // Score set to 0 if ref frame not allowed
- ref_score[i] = cm->ref_scores[i] * frame_allowed[i];
- }
- }
- else
- vpx_memcpy( ref_score, cm->ref_scores, sizeof(ref_score) );
-
- // Reference frames used by neighbours
- left = (m - 1)->mbmi.ref_frame;
- above = (m - cm->mode_info_stride)->mbmi.ref_frame;
- above_left = (m - 1 - cm->mode_info_stride)->mbmi.ref_frame;
-
- // Are neighbours in image
- left_in_image = (m - 1)->mbmi.mb_in_image;
- above_in_image = (m - cm->mode_info_stride)->mbmi.mb_in_image;
- above_left_in_image = (m - 1 - cm->mode_info_stride)->mbmi.mb_in_image;
-
- // Adjust scores for candidate reference frames based on neigbours
- if ( frame_allowed[left] && left_in_image )
- {
- ref_score[left] += 16;
- if ( above_left_in_image && (left == above_left) )
- ref_score[left] += 4;
+MV_REFERENCE_FRAME get_pred_ref(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd) {
+ MODE_INFO *m = xd->mode_info_context;
+
+ MV_REFERENCE_FRAME left;
+ MV_REFERENCE_FRAME above;
+ MV_REFERENCE_FRAME above_left;
+ MV_REFERENCE_FRAME pred_ref = LAST_FRAME;
+
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+ int seg_ref_active;
+ int i;
+
+ unsigned char frame_allowed[MAX_REF_FRAMES] = {1, 1, 1, 1};
+ unsigned char ref_score[MAX_REF_FRAMES];
+ unsigned char best_score = 0;
+ unsigned char left_in_image;
+ unsigned char above_in_image;
+ unsigned char above_left_in_image;
+
+ // Is segment coding ennabled
+ seg_ref_active = segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME);
+
+ // Special case treatment if segment coding is enabled.
+ // Dont allow prediction of a reference frame that the segment
+ // does not allow
+ if (seg_ref_active) {
+ for (i = 0; i < MAX_REF_FRAMES; i++) {
+ frame_allowed[i] =
+ check_segref(xd, segment_id, i);
+
+ // Score set to 0 if ref frame not allowed
+ ref_score[i] = cm->ref_scores[i] * frame_allowed[i];
}
- if ( frame_allowed[above] && above_in_image )
- {
- ref_score[above] += 16;
- if ( above_left_in_image && (above == above_left) )
- ref_score[above] += 4;
- }
-
- // Now choose the candidate with the highest score
- for ( i = 0; i < MAX_REF_FRAMES; i++ )
- {
- if ( ref_score[i] > best_score )
- {
- pred_ref = i;
- best_score = ref_score[i];
- }
+ } else
+ vpx_memcpy(ref_score, cm->ref_scores, sizeof(ref_score));
+
+ // Reference frames used by neighbours
+ left = (m - 1)->mbmi.ref_frame;
+ above = (m - cm->mode_info_stride)->mbmi.ref_frame;
+ above_left = (m - 1 - cm->mode_info_stride)->mbmi.ref_frame;
+
+ // Are neighbours in image
+ left_in_image = (m - 1)->mbmi.mb_in_image;
+ above_in_image = (m - cm->mode_info_stride)->mbmi.mb_in_image;
+ above_left_in_image = (m - 1 - cm->mode_info_stride)->mbmi.mb_in_image;
+
+ // Adjust scores for candidate reference frames based on neigbours
+ if (frame_allowed[left] && left_in_image) {
+ ref_score[left] += 16;
+ if (above_left_in_image && (left == above_left))
+ ref_score[left] += 4;
+ }
+ if (frame_allowed[above] && above_in_image) {
+ ref_score[above] += 16;
+ if (above_left_in_image && (above == above_left))
+ ref_score[above] += 4;
+ }
+
+ // Now choose the candidate with the highest score
+ for (i = 0; i < MAX_REF_FRAMES; i++) {
+ if (ref_score[i] > best_score) {
+ pred_ref = i;
+ best_score = ref_score[i];
}
+ }
- return pred_ref;
+ return pred_ref;
}
// Functions to computes a set of modified reference frame probabilities
// to use when the prediction of the reference frame value fails
-void calc_ref_probs( int * count, vp8_prob * probs )
-{
- int tot_count;
-
- tot_count = count[0] + count[1] + count[2] + count[3];
- if ( tot_count )
- {
- probs[0] = (vp8_prob)((count[0] * 255 + (tot_count >> 1)) / tot_count);
- probs[0] += !probs[0];
- }
- else
- probs[0] = 128;
-
- tot_count -= count[0];
- if ( tot_count )
- {
- probs[1] = (vp8_prob)((count[1] * 255 + (tot_count >> 1)) / tot_count);
- probs[1] += !probs[1];
- }
- else
- probs[1] = 128;
-
- tot_count -= count[1];
- if ( tot_count )
- {
- probs[2] = (vp8_prob)((count[2] * 255 + (tot_count >> 1)) / tot_count);
- probs[2] += !probs[2];
- }
- else
- probs[2] = 128;
+void calc_ref_probs(int *count, vp8_prob *probs) {
+ int tot_count;
+
+ tot_count = count[0] + count[1] + count[2] + count[3];
+ if (tot_count) {
+ probs[0] = (vp8_prob)((count[0] * 255 + (tot_count >> 1)) / tot_count);
+ probs[0] += !probs[0];
+ } else
+ probs[0] = 128;
+
+ tot_count -= count[0];
+ if (tot_count) {
+ probs[1] = (vp8_prob)((count[1] * 255 + (tot_count >> 1)) / tot_count);
+ probs[1] += !probs[1];
+ } else
+ probs[1] = 128;
+
+ tot_count -= count[1];
+ if (tot_count) {
+ probs[2] = (vp8_prob)((count[2] * 255 + (tot_count >> 1)) / tot_count);
+ probs[2] += !probs[2];
+ } else
+ probs[2] = 128;
}
@@ -308,58 +284,57 @@ void calc_ref_probs( int * count, vp8_prob * probs )
// Values willbe set to 0 for reference frame options that are not possible
// because wither they were predicted and prediction has failed or because
// they are not allowed for a given segment.
-void compute_mod_refprobs( VP8_COMMON *const cm )
-{
- int norm_cnt[MAX_REF_FRAMES];
- int intra_count;
- int inter_count;
- int last_count;
- int gfarf_count;
- int gf_count;
- int arf_count;
-
- intra_count = cm->prob_intra_coded;
- inter_count = (255 - intra_count);
- last_count = (inter_count * cm->prob_last_coded)/255;
- gfarf_count = inter_count - last_count;
- gf_count = (gfarf_count * cm->prob_gf_coded)/255;
- arf_count = gfarf_count - gf_count;
-
- // Work out modified reference frame probabilities to use where prediction
- // of the reference frame fails
- norm_cnt[0] = 0;
- norm_cnt[1] = last_count;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, cm->mod_refprobs[INTRA_FRAME] );
- cm->mod_refprobs[INTRA_FRAME][0] = 0; // This branch implicit
-
- norm_cnt[0] = intra_count;
- norm_cnt[1] = 0;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, cm->mod_refprobs[LAST_FRAME]);
- cm->mod_refprobs[LAST_FRAME][1] = 0; // This branch implicit
-
- norm_cnt[0] = intra_count;
- norm_cnt[1] = last_count;
- norm_cnt[2] = 0;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, cm->mod_refprobs[GOLDEN_FRAME] );
- cm->mod_refprobs[GOLDEN_FRAME][2] = 0; // This branch implicit
-
- norm_cnt[0] = intra_count;
- norm_cnt[1] = last_count;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = 0;
- calc_ref_probs( norm_cnt, cm->mod_refprobs[ALTREF_FRAME] );
- cm->mod_refprobs[ALTREF_FRAME][2] = 0; // This branch implicit
-
- // Score the reference frames based on overal frequency.
- // These scores contribute to the prediction choices.
- // Max score 17 min 1
- cm->ref_scores[INTRA_FRAME] = 1 + (intra_count * 16 / 255);
- cm->ref_scores[LAST_FRAME] = 1 + (last_count * 16 / 255);
- cm->ref_scores[GOLDEN_FRAME] = 1 + (gf_count * 16 / 255);
- cm->ref_scores[ALTREF_FRAME] = 1 + (arf_count * 16 / 255);
+void compute_mod_refprobs(VP8_COMMON *const cm) {
+ int norm_cnt[MAX_REF_FRAMES];
+ int intra_count;
+ int inter_count;
+ int last_count;
+ int gfarf_count;
+ int gf_count;
+ int arf_count;
+
+ intra_count = cm->prob_intra_coded;
+ inter_count = (255 - intra_count);
+ last_count = (inter_count * cm->prob_last_coded) / 255;
+ gfarf_count = inter_count - last_count;
+ gf_count = (gfarf_count * cm->prob_gf_coded) / 255;
+ arf_count = gfarf_count - gf_count;
+
+ // Work out modified reference frame probabilities to use where prediction
+ // of the reference frame fails
+ norm_cnt[0] = 0;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, cm->mod_refprobs[INTRA_FRAME]);
+ cm->mod_refprobs[INTRA_FRAME][0] = 0; // This branch implicit
+
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = 0;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, cm->mod_refprobs[LAST_FRAME]);
+ cm->mod_refprobs[LAST_FRAME][1] = 0; // This branch implicit
+
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = 0;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, cm->mod_refprobs[GOLDEN_FRAME]);
+ cm->mod_refprobs[GOLDEN_FRAME][2] = 0; // This branch implicit
+
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = 0;
+ calc_ref_probs(norm_cnt, cm->mod_refprobs[ALTREF_FRAME]);
+ cm->mod_refprobs[ALTREF_FRAME][2] = 0; // This branch implicit
+
+ // Score the reference frames based on overal frequency.
+ // These scores contribute to the prediction choices.
+ // Max score 17 min 1
+ cm->ref_scores[INTRA_FRAME] = 1 + (intra_count * 16 / 255);
+ cm->ref_scores[LAST_FRAME] = 1 + (last_count * 16 / 255);
+ cm->ref_scores[GOLDEN_FRAME] = 1 + (gf_count * 16 / 255);
+ cm->ref_scores[ALTREF_FRAME] = 1 + (arf_count * 16 / 255);
}
diff --git a/vp8/common/pred_common.h b/vp8/common/pred_common.h
index 3499b0d41..9a7c13cc8 100644
--- a/vp8/common/pred_common.h
+++ b/vp8/common/pred_common.h
@@ -17,38 +17,37 @@
// Predicted items
-typedef enum
-{
- PRED_SEG_ID = 0, // Segment identifier
- PRED_REF = 1,
- PRED_COMP = 2,
+typedef enum {
+ PRED_SEG_ID = 0, // Segment identifier
+ PRED_REF = 1,
+ PRED_COMP = 2,
#if CONFIG_NEWENTROPY
- PRED_MBSKIP = 3,
+ PRED_MBSKIP = 3,
#endif
} PRED_ID;
-extern unsigned char get_pred_context( VP8_COMMON *const cm,
- MACROBLOCKD *const xd,
- PRED_ID pred_id );
+extern unsigned char get_pred_context(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd,
+ PRED_ID pred_id);
-extern vp8_prob get_pred_prob( VP8_COMMON *const cm,
- MACROBLOCKD *const xd,
- PRED_ID pred_id );
+extern vp8_prob get_pred_prob(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd,
+ PRED_ID pred_id);
-extern unsigned char get_pred_flag( MACROBLOCKD *const xd,
- PRED_ID pred_id );
+extern unsigned char get_pred_flag(MACROBLOCKD *const xd,
+ PRED_ID pred_id);
-extern void set_pred_flag( MACROBLOCKD *const xd,
- PRED_ID pred_id,
- unsigned char pred_flag);
+extern void set_pred_flag(MACROBLOCKD *const xd,
+ PRED_ID pred_id,
+ unsigned char pred_flag);
-extern unsigned char get_pred_mb_segid( VP8_COMMON *const cm, int MbIndex );
+extern unsigned char get_pred_mb_segid(VP8_COMMON *const cm, int MbIndex);
-extern MV_REFERENCE_FRAME get_pred_ref( VP8_COMMON *const cm,
- MACROBLOCKD *const xd );
-extern void compute_mod_refprobs( VP8_COMMON *const cm );
+extern MV_REFERENCE_FRAME get_pred_ref(VP8_COMMON *const cm,
+ MACROBLOCKD *const xd);
+extern void compute_mod_refprobs(VP8_COMMON *const cm);
#endif /* __INC_PRED_COMMON_H__ */
diff --git a/vp8/common/predict_rotated.c b/vp8/common/predict_rotated.c
index 0880bfb4c..29ef65cea 100644
--- a/vp8/common/predict_rotated.c
+++ b/vp8/common/predict_rotated.c
@@ -9,74 +9,61 @@
*/
#if CONFIG_ROTATION
-typedef struct
-{
- int y;
- int x;
- unsigned long t;
+typedef struct {
+ int y;
+ int x;
+ unsigned long t;
} tap;
-typedef struct
-{
- tap pt[4];
+typedef struct {
+ tap pt[4];
} point_taps;
-typedef struct
-{
- point_taps pt[256];
+typedef struct {
+ point_taps pt[256];
} mb_taps;
-mb_taps mt_8x8[] =
-{
- #include "rotate2.h"
+mb_taps mt_8x8[] = {
+#include "rotate2.h"
};
-mb_taps mt[] =
-{
- #include "rotate.h"
+mb_taps mt[] = {
+#include "rotate.h"
};
void predict_rotated_16x16(int rotation_index, unsigned char *src, int sp,
- unsigned char *dst, int dp)
-{
- int i, j, k, p = 0;
+ unsigned char *dst, int dp) {
+ int i, j, k, p = 0;
- for (i = 0; i < 16; i++, dst += dp)
- {
- for (j = 0; j < 16; j++, p++)
- {
- unsigned int sum = 32768;
+ for (i = 0; i < 16; i++, dst += dp) {
+ for (j = 0; j < 16; j++, p++) {
+ unsigned int sum = 32768;
- for (k = 0; k < 4; k++)
- {
- tap *tp = &mt[rotation_index].pt[p].pt[k];
- sum += src[tp->y * sp + tp->x] * tp->t;
- }
- sum >>= 16;
- dst[j] = sum;
- }
+ for (k = 0; k < 4; k++) {
+ tap *tp = &mt[rotation_index].pt[p].pt[k];
+ sum += src[tp->y * sp + tp->x] * tp->t;
+ }
+ sum >>= 16;
+ dst[j] = sum;
}
+ }
}
void predict_rotated_8x8(int rotation_index, unsigned char *src, int sp,
- unsigned char *dst, int dp)
-{
- int i, j, k, p = 0;
+ unsigned char *dst, int dp) {
+ int i, j, k, p = 0;
- for (i = 0; i < 8; i++, dst += dp)
- {
- for (j = 0; j < 8; j++, p++)
- {
- unsigned int sum = 32768;
+ for (i = 0; i < 8; i++, dst += dp) {
+ for (j = 0; j < 8; j++, p++) {
+ unsigned int sum = 32768;
- for (k = 0; k < 4; k++)
- {
- tap *tp = &mt_8x8[rotation_index].pt[p].pt[k];
- sum += src[tp->y * sp + tp->x] * tp->t;
- }
- sum >>= 16;
- dst[j] = sum;
- }
+ for (k = 0; k < 4; k++) {
+ tap *tp = &mt_8x8[rotation_index].pt[p].pt[k];
+ sum += src[tp->y * sp + tp->x] * tp->t;
+ }
+ sum >>= 16;
+ dst[j] = sum;
}
+ }
}
#endif
diff --git a/vp8/common/quant_common.c b/vp8/common/quant_common.c
index 0bb44f588..65453d88c 100644
--- a/vp8/common/quant_common.c
+++ b/vp8/common/quant_common.c
@@ -16,118 +16,110 @@ static int ac_qlookup[QINDEX_RANGE];
#define ACDC_MIN 4
-void vp8_init_quant_tables()
-{
- int i;
- int current_val = 4;
- int last_val = 4;
- int ac_val;
-
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- ac_qlookup[i] = current_val;
- current_val = (int)((double)current_val * 1.02);
- if ( current_val == last_val )
- current_val++;
- last_val = current_val;
-
- ac_val = ac_qlookup[i];
- dc_qlookup[i] = (0.000000305 * ac_val * ac_val * ac_val) +
- (-0.00065 * ac_val * ac_val) +
- (0.9 * ac_val) + 0.5;
- if ( dc_qlookup[i] < ACDC_MIN )
- dc_qlookup[i] = ACDC_MIN;
- }
+void vp8_init_quant_tables() {
+ int i;
+ int current_val = 4;
+ int last_val = 4;
+ int ac_val;
+
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ ac_qlookup[i] = current_val;
+ current_val = (int)((double)current_val * 1.02);
+ if (current_val == last_val)
+ current_val++;
+ last_val = current_val;
+
+ ac_val = ac_qlookup[i];
+ dc_qlookup[i] = (0.000000305 * ac_val * ac_val * ac_val) +
+ (-0.00065 * ac_val * ac_val) +
+ (0.9 * ac_val) + 0.5;
+ if (dc_qlookup[i] < ACDC_MIN)
+ dc_qlookup[i] = ACDC_MIN;
+ }
}
-int vp8_dc_quant(int QIndex, int Delta)
-{
- int retval;
+int vp8_dc_quant(int QIndex, int Delta) {
+ int retval;
- QIndex = QIndex + Delta;
+ QIndex = QIndex + Delta;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = dc_qlookup[ QIndex ];
- return retval;
+ retval = dc_qlookup[ QIndex ];
+ return retval;
}
-int vp8_dc2quant(int QIndex, int Delta)
-{
- int retval;
+int vp8_dc2quant(int QIndex, int Delta) {
+ int retval;
- QIndex = QIndex + Delta;
+ QIndex = QIndex + Delta;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = dc_qlookup[ QIndex ];
+ retval = dc_qlookup[ QIndex ];
- return retval;
+ return retval;
}
-int vp8_dc_uv_quant(int QIndex, int Delta)
-{
- int retval;
+int vp8_dc_uv_quant(int QIndex, int Delta) {
+ int retval;
- QIndex = QIndex + Delta;
+ QIndex = QIndex + Delta;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = dc_qlookup[ QIndex ];
+ retval = dc_qlookup[ QIndex ];
- return retval;
+ return retval;
}
-int vp8_ac_yquant(int QIndex)
-{
- int retval;
+int vp8_ac_yquant(int QIndex) {
+ int retval;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = ac_qlookup[ QIndex ];
- return retval;
+ retval = ac_qlookup[ QIndex ];
+ return retval;
}
-int vp8_ac2quant(int QIndex, int Delta)
-{
- int retval;
+int vp8_ac2quant(int QIndex, int Delta) {
+ int retval;
- QIndex = QIndex + Delta;
+ QIndex = QIndex + Delta;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = (ac_qlookup[ QIndex ] * 775) / 1000;
- if (retval < 4)
- retval = 4;
+ retval = (ac_qlookup[ QIndex ] * 775) / 1000;
+ if (retval < 4)
+ retval = 4;
- return retval;
+ return retval;
}
-int vp8_ac_uv_quant(int QIndex, int Delta)
-{
- int retval;
+int vp8_ac_uv_quant(int QIndex, int Delta) {
+ int retval;
- QIndex = QIndex + Delta;
+ QIndex = QIndex + Delta;
- if (QIndex > MAXQ)
- QIndex = MAXQ;
- else if (QIndex < 0)
- QIndex = 0;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
+ else if (QIndex < 0)
+ QIndex = 0;
- retval = ac_qlookup[ QIndex ];
- return retval;
+ retval = ac_qlookup[ QIndex ];
+ return retval;
}
diff --git a/vp8/common/recon.c b/vp8/common/recon.c
index 279fbe82f..943faeef2 100644
--- a/vp8/common/recon.c
+++ b/vp8/common/recon.c
@@ -15,197 +15,180 @@
void vp8_recon_b_c
(
- unsigned char *pred_ptr,
- short *diff_ptr,
- unsigned char *dst_ptr,
- int stride
-)
-{
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred_ptr[c] ;
-
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- diff_ptr += 16;
- pred_ptr += 16;
+ unsigned char *pred_ptr,
+ short *diff_ptr,
+ unsigned char *dst_ptr,
+ int stride
+) {
+ int r, c;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred_ptr[c];
+
+ if (a < 0)
+ a = 0;
+
+ if (a > 255)
+ a = 255;
+
+ dst_ptr[c] = (unsigned char) a;
}
+
+ dst_ptr += stride;
+ diff_ptr += 16;
+ pred_ptr += 16;
+ }
}
void vp8_recon_uv_b_c
(
- unsigned char *pred_ptr,
- short *diff_ptr,
- unsigned char *dst_ptr,
- int stride
-)
-{
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred_ptr[c] ;
-
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- diff_ptr += 8;
- pred_ptr += 8;
+ unsigned char *pred_ptr,
+ short *diff_ptr,
+ unsigned char *dst_ptr,
+ int stride
+) {
+ int r, c;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred_ptr[c];
+
+ if (a < 0)
+ a = 0;
+
+ if (a > 255)
+ a = 255;
+
+ dst_ptr[c] = (unsigned char) a;
}
+
+ dst_ptr += stride;
+ diff_ptr += 8;
+ pred_ptr += 8;
+ }
}
void vp8_recon4b_c
(
- unsigned char *pred_ptr,
- short *diff_ptr,
- unsigned char *dst_ptr,
- int stride
-)
-{
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 16; c++)
- {
- int a = diff_ptr[c] + pred_ptr[c] ;
-
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- diff_ptr += 16;
- pred_ptr += 16;
+ unsigned char *pred_ptr,
+ short *diff_ptr,
+ unsigned char *dst_ptr,
+ int stride
+) {
+ int r, c;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 16; c++) {
+ int a = diff_ptr[c] + pred_ptr[c];
+
+ if (a < 0)
+ a = 0;
+
+ if (a > 255)
+ a = 255;
+
+ dst_ptr[c] = (unsigned char) a;
}
+
+ dst_ptr += stride;
+ diff_ptr += 16;
+ pred_ptr += 16;
+ }
}
void vp8_recon2b_c
(
- unsigned char *pred_ptr,
- short *diff_ptr,
- unsigned char *dst_ptr,
- int stride
-)
-{
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 8; c++)
- {
- int a = diff_ptr[c] + pred_ptr[c] ;
-
- if (a < 0)
- a = 0;
-
- if (a > 255)
- a = 255;
-
- dst_ptr[c] = (unsigned char) a ;
- }
-
- dst_ptr += stride;
- diff_ptr += 8;
- pred_ptr += 8;
+ unsigned char *pred_ptr,
+ short *diff_ptr,
+ unsigned char *dst_ptr,
+ int stride
+) {
+ int r, c;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 8; c++) {
+ int a = diff_ptr[c] + pred_ptr[c];
+
+ if (a < 0)
+ a = 0;
+
+ if (a > 255)
+ a = 255;
+
+ dst_ptr[c] = (unsigned char) a;
}
+
+ dst_ptr += stride;
+ diff_ptr += 8;
+ pred_ptr += 8;
+ }
}
-void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
+void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
#if ARCH_ARM
- BLOCKD *b = &x->block[0];
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ BLOCKD *b = &x->block[0];
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- /*b = &x->block[4];*/
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ /*b = &x->block[4];*/
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- /*b = &x->block[8];*/
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ /*b = &x->block[8];*/
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- /*b = &x->block[12];*/
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ /*b = &x->block[12];*/
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
#else
- int i;
+ int i;
- for (i = 0; i < 16; i += 4)
- {
- BLOCKD *b = &x->block[i];
+ for (i = 0; i < 16; i += 4) {
+ BLOCKD *b = &x->block[i];
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- }
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ }
#endif
}
-void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
+void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
#if ARCH_ARM
- BLOCKD *b = &x->block[0];
-
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b += 4;
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b += 4;
-
- /*b = &x->block[16];*/
-
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b++;
- b++;
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b++;
- b++;
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- b++;
- b++;
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ BLOCKD *b = &x->block[0];
+
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b += 4;
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b += 4;
+
+ /*b = &x->block[16];*/
+
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b++;
+ b++;
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b++;
+ b++;
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ b++;
+ b++;
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
#else
- int i;
+ int i;
- for (i = 0; i < 16; i += 4)
- {
- BLOCKD *b = &x->block[i];
+ for (i = 0; i < 16; i += 4) {
+ BLOCKD *b = &x->block[i];
- RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- }
+ RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ }
- for (i = 16; i < 24; i += 2)
- {
- BLOCKD *b = &x->block[i];
+ for (i = 16; i < 24; i += 2) {
+ BLOCKD *b = &x->block[i];
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- }
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ }
#endif
}
diff --git a/vp8/common/recon.h b/vp8/common/recon.h
index 9fb12c85d..665fec3c4 100644
--- a/vp8/common/recon.h
+++ b/vp8/common/recon.h
@@ -15,23 +15,23 @@
#include "blockd.h"
#define prototype_copy_block(sym) \
- void sym(unsigned char *src, int src_pitch, unsigned char *dst, int dst_pitch)
+ void sym(unsigned char *src, int src_pitch, unsigned char *dst, int dst_pitch)
#define prototype_recon_block(sym) \
- void sym(unsigned char *pred, short *diff, unsigned char *dst, int pitch)
+ void sym(unsigned char *pred, short *diff, unsigned char *dst, int pitch)
#define prototype_recon_macroblock(sym) \
- void sym(const struct vp8_recon_rtcd_vtable *rtcd, MACROBLOCKD *x)
+ void sym(const struct vp8_recon_rtcd_vtable *rtcd, MACROBLOCKD *x)
#define prototype_build_intra_predictors(sym) \
- void sym(MACROBLOCKD *x)
+ void sym(MACROBLOCKD *x)
#define prototype_intra4x4_predict(sym) \
- void sym(BLOCKD *x, int b_mode, unsigned char *predictor)
+ void sym(BLOCKD *x, int b_mode, unsigned char *predictor)
#if CONFIG_COMP_INTRA_PRED
#define prototype_comp_intra4x4_predict(sym) \
- void sym(BLOCKD *x, int b_mode, int mode2, unsigned char *predictor)
+ void sym(BLOCKD *x, int b_mode, int mode2, unsigned char *predictor)
#endif
struct vp8_recon_rtcd_vtable;
@@ -104,94 +104,94 @@ extern prototype_recon_macroblock(vp8_recon_recon_mby);
#define vp8_recon_build_intra_predictors_mby vp8_build_intra_predictors_mby
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra_predictors_mby);
+(vp8_recon_build_intra_predictors_mby);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_build_comp_intra_predictors_mby
#define vp8_recon_build_comp_intra_predictors_mby vp8_build_comp_intra_predictors_mby
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_comp_intra_predictors_mby);
+(vp8_recon_build_comp_intra_predictors_mby);
#endif
#ifndef vp8_recon_build_intra8x8_predictors_mby
#define vp8_recon_build_intra8x8_predictors_mby vp8_build_intra8x8_predictors_mby
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra8x8_predictors_mby);
+(vp8_recon_build_intra8x8_predictors_mby);
#ifndef vp8_recon_build_intra_predictors_mby_s
#define vp8_recon_build_intra_predictors_mby_s vp8_build_intra_predictors_mby_s
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra_predictors_mby_s);
+(vp8_recon_build_intra_predictors_mby_s);
#ifndef vp8_recon_build_intra_predictors_mbuv
#define vp8_recon_build_intra_predictors_mbuv vp8_build_intra_predictors_mbuv
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra_predictors_mbuv);
+(vp8_recon_build_intra_predictors_mbuv);
#ifndef vp8_recon_build_intra8x8_predictors_mbuv
#define vp8_recon_build_intra8x8_predictors_mbuv vp8_build_intra8x8_predictors_mbuv
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra8x8_predictors_mbuv);
+(vp8_recon_build_intra8x8_predictors_mbuv);
#ifndef vp8_recon_build_intra_predictors_mbuv_s
#define vp8_recon_build_intra_predictors_mbuv_s vp8_build_intra_predictors_mbuv_s
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_intra_predictors_mbuv_s);
+(vp8_recon_build_intra_predictors_mbuv_s);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_build_comp_intra_predictors_mbuv
#define vp8_recon_build_comp_intra_predictors_mbuv vp8_build_comp_intra_predictors_mbuv
#endif
extern prototype_build_intra_predictors\
- (vp8_recon_build_comp_intra_predictors_mbuv);
+(vp8_recon_build_comp_intra_predictors_mbuv);
#endif
#ifndef vp8_recon_intra4x4_predict
#define vp8_recon_intra4x4_predict vp8_intra4x4_predict
#endif
extern prototype_intra4x4_predict\
- (vp8_recon_intra4x4_predict);
+(vp8_recon_intra4x4_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra4x4_predict
#define vp8_recon_comp_intra4x4_predict vp8_comp_intra4x4_predict
#endif
extern prototype_comp_intra4x4_predict\
- (vp8_recon_comp_intra4x4_predict);
+(vp8_recon_comp_intra4x4_predict);
#endif
#ifndef vp8_recon_intra8x8_predict
#define vp8_recon_intra8x8_predict vp8_intra8x8_predict
#endif
extern prototype_intra4x4_predict\
- (vp8_recon_intra8x8_predict);
+(vp8_recon_intra8x8_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra8x8_predict
#define vp8_recon_comp_intra8x8_predict vp8_comp_intra8x8_predict
#endif
extern prototype_comp_intra4x4_predict\
- (vp8_recon_comp_intra8x8_predict);
+(vp8_recon_comp_intra8x8_predict);
#endif
#ifndef vp8_recon_intra_uv4x4_predict
#define vp8_recon_intra_uv4x4_predict vp8_intra_uv4x4_predict
#endif
extern prototype_intra4x4_predict\
- (vp8_recon_intra_uv4x4_predict);
+(vp8_recon_intra_uv4x4_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra_uv4x4_predict
#define vp8_recon_comp_intra_uv4x4_predict vp8_comp_intra_uv4x4_predict
#endif
extern prototype_comp_intra4x4_predict\
- (vp8_recon_comp_intra_uv4x4_predict);
+(vp8_recon_comp_intra_uv4x4_predict);
#endif
typedef prototype_copy_block((*vp8_copy_block_fn_t));
@@ -202,40 +202,39 @@ typedef prototype_intra4x4_predict((*vp8_intra4x4_pred_fn_t));
#if CONFIG_COMP_INTRA_PRED
typedef prototype_comp_intra4x4_predict((*vp8_comp_intra4x4_pred_fn_t));
#endif
-typedef struct vp8_recon_rtcd_vtable
-{
- vp8_copy_block_fn_t copy16x16;
- vp8_copy_block_fn_t copy8x8;
- vp8_copy_block_fn_t avg16x16;
- vp8_copy_block_fn_t avg8x8;
- vp8_copy_block_fn_t copy8x4;
- vp8_recon_fn_t recon;
- vp8_recon_fn_t recon_uv;
- vp8_recon_fn_t recon2;
- vp8_recon_fn_t recon4;
- vp8_recon_mb_fn_t recon_mb;
- vp8_recon_mb_fn_t recon_mby;
- vp8_build_intra_pred_fn_t build_intra_predictors_mby_s;
- vp8_build_intra_pred_fn_t build_intra_predictors_mby;
+typedef struct vp8_recon_rtcd_vtable {
+ vp8_copy_block_fn_t copy16x16;
+ vp8_copy_block_fn_t copy8x8;
+ vp8_copy_block_fn_t avg16x16;
+ vp8_copy_block_fn_t avg8x8;
+ vp8_copy_block_fn_t copy8x4;
+ vp8_recon_fn_t recon;
+ vp8_recon_fn_t recon_uv;
+ vp8_recon_fn_t recon2;
+ vp8_recon_fn_t recon4;
+ vp8_recon_mb_fn_t recon_mb;
+ vp8_recon_mb_fn_t recon_mby;
+ vp8_build_intra_pred_fn_t build_intra_predictors_mby_s;
+ vp8_build_intra_pred_fn_t build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
- vp8_build_intra_pred_fn_t build_comp_intra_predictors_mby;
+ vp8_build_intra_pred_fn_t build_comp_intra_predictors_mby;
#endif
- vp8_build_intra_pred_fn_t build_intra_predictors_mbuv_s;
- vp8_build_intra_pred_fn_t build_intra_predictors_mbuv;
+ vp8_build_intra_pred_fn_t build_intra_predictors_mbuv_s;
+ vp8_build_intra_pred_fn_t build_intra_predictors_mbuv;
#if CONFIG_COMP_INTRA_PRED
- vp8_build_intra_pred_fn_t build_comp_intra_predictors_mbuv;
+ vp8_build_intra_pred_fn_t build_comp_intra_predictors_mbuv;
#endif
- vp8_intra4x4_pred_fn_t intra4x4_predict;
+ vp8_intra4x4_pred_fn_t intra4x4_predict;
#if CONFIG_COMP_INTRA_PRED
- vp8_comp_intra4x4_pred_fn_t comp_intra4x4_predict;
+ vp8_comp_intra4x4_pred_fn_t comp_intra4x4_predict;
#endif
- vp8_intra4x4_pred_fn_t intra8x8_predict;
+ vp8_intra4x4_pred_fn_t intra8x8_predict;
#if CONFIG_COMP_INTRA_PRED
- vp8_comp_intra4x4_pred_fn_t comp_intra8x8_predict;
+ vp8_comp_intra4x4_pred_fn_t comp_intra8x8_predict;
#endif
- vp8_intra4x4_pred_fn_t intra_uv4x4_predict;
+ vp8_intra4x4_pred_fn_t intra_uv4x4_predict;
#if CONFIG_COMP_INTRA_PRED
- vp8_comp_intra4x4_pred_fn_t comp_intra_uv4x4_predict;
+ vp8_comp_intra4x4_pred_fn_t comp_intra_uv4x4_predict;
#endif
} vp8_recon_rtcd_vtable_t;
diff --git a/vp8/common/reconinter.c b/vp8/common/reconinter.c
index 71a54e29e..853429e4c 100644
--- a/vp8/common/reconinter.c
+++ b/vp8/common/reconinter.c
@@ -20,193 +20,176 @@
#endif
void vp8_copy_mem16x16_c(
- unsigned char *src,
- int src_stride,
- unsigned char *dst,
- int dst_stride)
-{
+ unsigned char *src,
+ int src_stride,
+ unsigned char *dst,
+ int dst_stride) {
- int r;
+ int r;
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
#if !(CONFIG_FAST_UNALIGNED)
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst[4] = src[4];
- dst[5] = src[5];
- dst[6] = src[6];
- dst[7] = src[7];
- dst[8] = src[8];
- dst[9] = src[9];
- dst[10] = src[10];
- dst[11] = src[11];
- dst[12] = src[12];
- dst[13] = src[13];
- dst[14] = src[14];
- dst[15] = src[15];
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst[3] = src[3];
+ dst[4] = src[4];
+ dst[5] = src[5];
+ dst[6] = src[6];
+ dst[7] = src[7];
+ dst[8] = src[8];
+ dst[9] = src[9];
+ dst[10] = src[10];
+ dst[11] = src[11];
+ dst[12] = src[12];
+ dst[13] = src[13];
+ dst[14] = src[14];
+ dst[15] = src[15];
#else
- ((uint32_t *)dst)[0] = ((uint32_t *)src)[0] ;
- ((uint32_t *)dst)[1] = ((uint32_t *)src)[1] ;
- ((uint32_t *)dst)[2] = ((uint32_t *)src)[2] ;
- ((uint32_t *)dst)[3] = ((uint32_t *)src)[3] ;
+ ((uint32_t *)dst)[0] = ((uint32_t *)src)[0];
+ ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
+ ((uint32_t *)dst)[2] = ((uint32_t *)src)[2];
+ ((uint32_t *)dst)[3] = ((uint32_t *)src)[3];
#endif
- src += src_stride;
- dst += dst_stride;
+ src += src_stride;
+ dst += dst_stride;
- }
+ }
}
void vp8_avg_mem16x16_c(
- unsigned char *src,
- int src_stride,
- unsigned char *dst,
- int dst_stride)
-{
- int r;
-
- for (r = 0; r < 16; r++)
- {
- int n;
-
- for (n = 0; n < 16; n++)
- {
- dst[n] = (dst[n] + src[n] + 1) >> 1;
- }
+ unsigned char *src,
+ int src_stride,
+ unsigned char *dst,
+ int dst_stride) {
+ int r;
- src += src_stride;
- dst += dst_stride;
+ for (r = 0; r < 16; r++) {
+ int n;
+
+ for (n = 0; n < 16; n++) {
+ dst[n] = (dst[n] + src[n] + 1) >> 1;
}
+
+ src += src_stride;
+ dst += dst_stride;
+ }
}
void vp8_copy_mem8x8_c(
- unsigned char *src,
- int src_stride,
- unsigned char *dst,
- int dst_stride)
-{
- int r;
-
- for (r = 0; r < 8; r++)
- {
+ unsigned char *src,
+ int src_stride,
+ unsigned char *dst,
+ int dst_stride) {
+ int r;
+
+ for (r = 0; r < 8; r++) {
#if !(CONFIG_FAST_UNALIGNED)
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst[4] = src[4];
- dst[5] = src[5];
- dst[6] = src[6];
- dst[7] = src[7];
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst[3] = src[3];
+ dst[4] = src[4];
+ dst[5] = src[5];
+ dst[6] = src[6];
+ dst[7] = src[7];
#else
- ((uint32_t *)dst)[0] = ((uint32_t *)src)[0] ;
- ((uint32_t *)dst)[1] = ((uint32_t *)src)[1] ;
+ ((uint32_t *)dst)[0] = ((uint32_t *)src)[0];
+ ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
#endif
- src += src_stride;
- dst += dst_stride;
+ src += src_stride;
+ dst += dst_stride;
- }
+ }
}
void vp8_avg_mem8x8_c(
- unsigned char *src,
- int src_stride,
- unsigned char *dst,
- int dst_stride)
-{
- int r;
-
- for (r = 0; r < 8; r++)
- {
- int n;
-
- for (n = 0; n < 8; n++)
- {
- dst[n] = (dst[n] + src[n] + 1) >> 1;
- }
+ unsigned char *src,
+ int src_stride,
+ unsigned char *dst,
+ int dst_stride) {
+ int r;
- src += src_stride;
- dst += dst_stride;
+ for (r = 0; r < 8; r++) {
+ int n;
+
+ for (n = 0; n < 8; n++) {
+ dst[n] = (dst[n] + src[n] + 1) >> 1;
}
+
+ src += src_stride;
+ dst += dst_stride;
+ }
}
void vp8_copy_mem8x4_c(
- unsigned char *src,
- int src_stride,
- unsigned char *dst,
- int dst_stride)
-{
- int r;
-
- for (r = 0; r < 4; r++)
- {
+ unsigned char *src,
+ int src_stride,
+ unsigned char *dst,
+ int dst_stride) {
+ int r;
+
+ for (r = 0; r < 4; r++) {
#if !(CONFIG_FAST_UNALIGNED)
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst[4] = src[4];
- dst[5] = src[5];
- dst[6] = src[6];
- dst[7] = src[7];
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst[3] = src[3];
+ dst[4] = src[4];
+ dst[5] = src[5];
+ dst[6] = src[6];
+ dst[7] = src[7];
#else
- ((uint32_t *)dst)[0] = ((uint32_t *)src)[0] ;
- ((uint32_t *)dst)[1] = ((uint32_t *)src)[1] ;
+ ((uint32_t *)dst)[0] = ((uint32_t *)src)[0];
+ ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
#endif
- src += src_stride;
- dst += dst_stride;
+ src += src_stride;
+ dst += dst_stride;
- }
+ }
}
-void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf)
-{
- int r;
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = d->predictor;
- int_mv mv;
+void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf) {
+ int r;
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = d->predictor;
+ int_mv mv;
- ptr_base = *(d->base_pre);
- mv.as_int = d->bmi.as_mv.first.as_int;
+ ptr_base = *(d->base_pre);
+ mv.as_int = d->bmi.as_mv.first.as_int;
- if (mv.as_mv.row & 7 || mv.as_mv.col & 7)
- {
- ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+ if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
+ ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
#if CONFIG_SIXTEENTH_SUBPEL_UV
- sppf(ptr, d->pre_stride, (mv.as_mv.col & 7)<<1, (mv.as_mv.row & 7)<<1, pred_ptr, pitch);
+ sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
#else
- sppf(ptr, d->pre_stride, mv.as_mv.col & 7,mv.as_mv.row & 7, pred_ptr, pitch);
+ sppf(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
#endif
- }
- else
- {
- ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
- ptr = ptr_base;
+ } else {
+ ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+ ptr = ptr_base;
- for (r = 0; r < 4; r++)
- {
+ for (r = 0; r < 4; r++) {
#if !(CONFIG_FAST_UNALIGNED)
- pred_ptr[0] = ptr[0];
- pred_ptr[1] = ptr[1];
- pred_ptr[2] = ptr[2];
- pred_ptr[3] = ptr[3];
+ pred_ptr[0] = ptr[0];
+ pred_ptr[1] = ptr[1];
+ pred_ptr[2] = ptr[2];
+ pred_ptr[3] = ptr[3];
#else
- *(uint32_t *)pred_ptr = *(uint32_t *)ptr ;
+ *(uint32_t *)pred_ptr = *(uint32_t *)ptr;
#endif
- pred_ptr += pitch;
- ptr += d->pre_stride;
- }
+ pred_ptr += pitch;
+ ptr += d->pre_stride;
}
+ }
}
/*
@@ -215,66 +198,57 @@ void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf)
* come from an earlier call to vp8_build_inter_predictors_b()) with the
* predictor of the second reference frame / motion vector.
*/
-void vp8_build_2nd_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf)
-{
- int r;
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = d->predictor;
- int_mv mv;
-
- ptr_base = *(d->base_second_pre);
- mv.as_int = d->bmi.as_mv.second.as_int;
-
- if (mv.as_mv.row & 7 || mv.as_mv.col & 7)
- {
- ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+void vp8_build_2nd_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf) {
+ int r;
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = d->predictor;
+ int_mv mv;
+
+ ptr_base = *(d->base_second_pre);
+ mv.as_int = d->bmi.as_mv.second.as_int;
+
+ if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
+ ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
#if CONFIG_SIXTEENTH_SUBPEL_UV
- sppf(ptr, d->pre_stride, (mv.as_mv.col & 7)<<1, (mv.as_mv.row & 7)<<1, pred_ptr, pitch);
+ sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
#else
- sppf(ptr, d->pre_stride, mv.as_mv.col & 7,mv.as_mv.row & 7, pred_ptr, pitch);
+ sppf(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
#endif
+ } else {
+ ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+ ptr = ptr_base;
+
+ for (r = 0; r < 4; r++) {
+ pred_ptr[0] = (pred_ptr[0] + ptr[0] + 1) >> 1;
+ pred_ptr[1] = (pred_ptr[1] + ptr[1] + 1) >> 1;
+ pred_ptr[2] = (pred_ptr[2] + ptr[2] + 1) >> 1;
+ pred_ptr[3] = (pred_ptr[3] + ptr[3] + 1) >> 1;
+ pred_ptr += pitch;
+ ptr += d->pre_stride;
}
- else
- {
- ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
- ptr = ptr_base;
-
- for (r = 0; r < 4; r++)
- {
- pred_ptr[0] = (pred_ptr[0] + ptr[0] + 1) >> 1;
- pred_ptr[1] = (pred_ptr[1] + ptr[1] + 1) >> 1;
- pred_ptr[2] = (pred_ptr[2] + ptr[2] + 1) >> 1;
- pred_ptr[3] = (pred_ptr[3] + ptr[3] + 1) >> 1;
- pred_ptr += pitch;
- ptr += d->pre_stride;
- }
- }
+ }
}
-static void build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch)
-{
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = d->predictor;
- int_mv mv;
+static void build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch) {
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = d->predictor;
+ int_mv mv;
- ptr_base = *(d->base_pre);
- mv.as_int = d->bmi.as_mv.first.as_int;
- ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+ ptr_base = *(d->base_pre);
+ mv.as_int = d->bmi.as_mv.first.as_int;
+ ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
- if (mv.as_mv.row & 7 || mv.as_mv.col & 7)
- {
+ if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict8x8(ptr, d->pre_stride, (mv.as_mv.col & 7)<<1, (mv.as_mv.row & 7)<<1, pred_ptr, pitch);
+ x->subpixel_predict8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
#else
- x->subpixel_predict8x8(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
+ x->subpixel_predict8x8(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, pred_ptr, pitch);
- }
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, pred_ptr, pitch);
+ }
}
/*
@@ -283,54 +257,46 @@ static void build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch)
* come from an earlier call to build_inter_predictors_4b()) with the
* predictor of the second reference frame / motion vector.
*/
-static void build_2nd_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch)
-{
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = d->predictor;
- int_mv mv;
-
- ptr_base = *(d->base_second_pre);
- mv.as_int = d->bmi.as_mv.second.as_int;
- ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+static void build_2nd_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch) {
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = d->predictor;
+ int_mv mv;
+
+ ptr_base = *(d->base_second_pre);
+ mv.as_int = d->bmi.as_mv.second.as_int;
+ ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
- if (mv.as_mv.row & 7 || mv.as_mv.col & 7)
- {
+ if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict_avg8x8(ptr, d->pre_stride, (mv.as_mv.col & 7)<<1, (mv.as_mv.row & 7)<<1, pred_ptr, pitch);
+ x->subpixel_predict_avg8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
#else
- x->subpixel_predict_avg8x8(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
+ x->subpixel_predict_avg8x8(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, avg8x8)(ptr, d->pre_stride, pred_ptr, pitch);
- }
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, avg8x8)(ptr, d->pre_stride, pred_ptr, pitch);
+ }
}
-static void build_inter_predictors2b(MACROBLOCKD *x, BLOCKD *d, int pitch)
-{
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = d->predictor;
- int_mv mv;
+static void build_inter_predictors2b(MACROBLOCKD *x, BLOCKD *d, int pitch) {
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = d->predictor;
+ int_mv mv;
- ptr_base = *(d->base_pre);
- mv.as_int = d->bmi.as_mv.first.as_int;
- ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
+ ptr_base = *(d->base_pre);
+ mv.as_int = d->bmi.as_mv.first.as_int;
+ ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + (mv.as_mv.col >> 3);
- if (mv.as_mv.row & 7 || mv.as_mv.col & 7)
- {
+ if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict8x4(ptr, d->pre_stride, (mv.as_mv.col & 7)<<1, (mv.as_mv.row & 7)<<1, pred_ptr, pitch);
+ x->subpixel_predict8x4(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
#else
- x->subpixel_predict8x4(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
+ x->subpixel_predict8x4(ptr, d->pre_stride, mv.as_mv.col & 7, mv.as_mv.row & 7, pred_ptr, pitch);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy8x4)(ptr, d->pre_stride, pred_ptr, pitch);
- }
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, copy8x4)(ptr, d->pre_stride, pred_ptr, pitch);
+ }
}
@@ -349,439 +315,394 @@ static const int pred_filter[PRED_FILT_LEN] = {1, 2, 10, 2, 1};
#if !USE_THRESH_FILTER
void filter_mb(unsigned char *src, int src_stride,
unsigned char *dst, int dst_stride,
- int width, int height)
-{
- int i, j, k;
- unsigned int Temp[32*32];
- unsigned int *pTmp = Temp;
- unsigned char *pSrc = src - (1 + src_stride) * (PRED_FILT_LEN/2);
-
- // Horizontal
- for (i=0; i<height+PRED_FILT_LEN-1; i++)
- {
- for (j=0; j<width; j++)
- {
- int sum=0;
- for (k=0; k<PRED_FILT_LEN; k++)
- sum += pSrc[j+k] * pred_filter[k];
- pTmp[j] = sum;
- }
-
- pSrc += src_stride;
- pTmp += width;
+ int width, int height) {
+ int i, j, k;
+ unsigned int Temp[32 * 32];
+ unsigned int *pTmp = Temp;
+ unsigned char *pSrc = src - (1 + src_stride) * (PRED_FILT_LEN / 2);
+
+ // Horizontal
+ for (i = 0; i < height + PRED_FILT_LEN - 1; i++) {
+ for (j = 0; j < width; j++) {
+ int sum = 0;
+ for (k = 0; k < PRED_FILT_LEN; k++)
+ sum += pSrc[j + k] * pred_filter[k];
+ pTmp[j] = sum;
}
- // Vertical
- pTmp = Temp;
- for (i=0; i<width; i++)
- {
- unsigned char *pDst = dst + i;
- for (j=0; j<height; j++)
- {
- int sum=0;
- for (k=0; k<PRED_FILT_LEN; k++)
- sum += pTmp[(j+k)*width] * pred_filter[k];
- // Round
- sum = (sum + ((1 << (filt_shift<<1))>>1)) >> (filt_shift << 1);
- pDst[j*dst_stride] = (sum < 0 ? 0 : sum > 255 ? 255 : sum);
- }
- ++pTmp;
+ pSrc += src_stride;
+ pTmp += width;
+ }
+
+ // Vertical
+ pTmp = Temp;
+ for (i = 0; i < width; i++) {
+ unsigned char *pDst = dst + i;
+ for (j = 0; j < height; j++) {
+ int sum = 0;
+ for (k = 0; k < PRED_FILT_LEN; k++)
+ sum += pTmp[(j + k) * width] * pred_filter[k];
+ // Round
+ sum = (sum + ((1 << (filt_shift << 1)) >> 1)) >> (filt_shift << 1);
+ pDst[j * dst_stride] = (sum < 0 ? 0 : sum > 255 ? 255 : sum);
}
+ ++pTmp;
+ }
}
#else
// Based on vp8_post_proc_down_and_across_c (postproc.c)
void filter_mb(unsigned char *src, int src_stride,
unsigned char *dst, int dst_stride,
- int width, int height)
-{
- unsigned char *pSrc, *pDst;
- int row;
- int col;
- int i;
- int v;
- unsigned char d[8];
-
- /* TODO flimit should be linked to the quantizer value */
- int flimit = 7;
-
- for (row = 0; row < height; row++)
- {
- /* post_proc_down for one row */
- pSrc = src;
- pDst = dst;
-
- for (col = 0; col < width; col++)
- {
- int kernel = (1 << (filt_shift-1));
- int v = pSrc[col];
-
- for (i = -2; i <= 2; i++)
- {
- if (abs(v - pSrc[col+i*src_stride]) > flimit)
- goto down_skip_convolve;
-
- kernel += pred_filter[2+i] * pSrc[col+i*src_stride];
- }
-
- v = (kernel >> filt_shift);
- down_skip_convolve:
- pDst[col] = v;
- }
+ int width, int height) {
+ unsigned char *pSrc, *pDst;
+ int row;
+ int col;
+ int i;
+ int v;
+ unsigned char d[8];
+
+ /* TODO flimit should be linked to the quantizer value */
+ int flimit = 7;
+
+ for (row = 0; row < height; row++) {
+ /* post_proc_down for one row */
+ pSrc = src;
+ pDst = dst;
+
+ for (col = 0; col < width; col++) {
+ int kernel = (1 << (filt_shift - 1));
+ int v = pSrc[col];
+
+ for (i = -2; i <= 2; i++) {
+ if (abs(v - pSrc[col + i * src_stride]) > flimit)
+ goto down_skip_convolve;
+
+ kernel += pred_filter[2 + i] * pSrc[col + i * src_stride];
+ }
+
+ v = (kernel >> filt_shift);
+ down_skip_convolve:
+ pDst[col] = v;
+ }
- /* now post_proc_across */
- pSrc = dst;
- pDst = dst;
+ /* now post_proc_across */
+ pSrc = dst;
+ pDst = dst;
- for (i = 0; i < 8; i++)
- d[i] = pSrc[i];
+ for (i = 0; i < 8; i++)
+ d[i] = pSrc[i];
- for (col = 0; col < width; col++)
- {
- int kernel = (1 << (filt_shift-1));
- v = pSrc[col];
+ for (col = 0; col < width; col++) {
+ int kernel = (1 << (filt_shift - 1));
+ v = pSrc[col];
- d[col&7] = v;
+ d[col & 7] = v;
- for (i = -2; i <= 2; i++)
- {
- if (abs(v - pSrc[col+i]) > flimit)
- goto across_skip_convolve;
+ for (i = -2; i <= 2; i++) {
+ if (abs(v - pSrc[col + i]) > flimit)
+ goto across_skip_convolve;
- kernel += pred_filter[2+i] * pSrc[col+i];
- }
+ kernel += pred_filter[2 + i] * pSrc[col + i];
+ }
- d[col&7] = (kernel >> filt_shift);
- across_skip_convolve:
+ d[col & 7] = (kernel >> filt_shift);
+ across_skip_convolve:
- if (col >= 2)
- pDst[col-2] = d[(col-2)&7];
- }
+ if (col >= 2)
+ pDst[col - 2] = d[(col - 2) & 7];
+ }
- /* handle the last two pixels */
- pDst[col-2] = d[(col-2)&7];
- pDst[col-1] = d[(col-1)&7];
+ /* handle the last two pixels */
+ pDst[col - 2] = d[(col - 2) & 7];
+ pDst[col - 1] = d[(col - 1) & 7];
- /* next row */
- src += src_stride;
- dst += dst_stride;
- }
+ /* next row */
+ src += src_stride;
+ dst += dst_stride;
+ }
}
#endif // !USE_THRESH_FILTER
#endif // CONFIG_PRED_FILTER
-void vp8_build_inter16x16_predictors_mbuv(MACROBLOCKD *xd)
-{
- unsigned char *uptr, *vptr;
- unsigned char *upred_ptr = &xd->predictor[256];
- unsigned char *vpred_ptr = &xd->predictor[320];
+void vp8_build_inter16x16_predictors_mbuv(MACROBLOCKD *xd) {
+ unsigned char *uptr, *vptr;
+ unsigned char *upred_ptr = &xd->predictor[256];
+ unsigned char *vpred_ptr = &xd->predictor[320];
- int omv_row = xd->mode_info_context->mbmi.mv.as_mv.row;
- int omv_col = xd->mode_info_context->mbmi.mv.as_mv.col;
- int mv_row = omv_row;
- int mv_col = omv_col;
- int offset;
- int pre_stride = xd->block[16].pre_stride;
+ int omv_row = xd->mode_info_context->mbmi.mv.as_mv.row;
+ int omv_col = xd->mode_info_context->mbmi.mv.as_mv.col;
+ int mv_row = omv_row;
+ int mv_col = omv_col;
+ int offset;
+ int pre_stride = xd->block[16].pre_stride;
- /* calc uv motion vectors */
- if (mv_row < 0)
- mv_row -= 1;
- else
- mv_row += 1;
+ /* calc uv motion vectors */
+ if (mv_row < 0)
+ mv_row -= 1;
+ else
+ mv_row += 1;
- if (mv_col < 0)
- mv_col -= 1;
- else
- mv_col += 1;
+ if (mv_col < 0)
+ mv_col -= 1;
+ else
+ mv_col += 1;
- mv_row /= 2;
- mv_col /= 2;
+ mv_row /= 2;
+ mv_col /= 2;
- mv_row &= xd->fullpixel_mask;
- mv_col &= xd->fullpixel_mask;
+ mv_row &= xd->fullpixel_mask;
+ mv_col &= xd->fullpixel_mask;
- offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
- uptr = xd->pre.u_buffer + offset;
- vptr = xd->pre.v_buffer + offset;
+ offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+ uptr = xd->pre.u_buffer + offset;
+ vptr = xd->pre.v_buffer + offset;
#if CONFIG_PRED_FILTER
- if (xd->mode_info_context->mbmi.pred_filter_enabled)
- {
- int i;
+ if (xd->mode_info_context->mbmi.pred_filter_enabled) {
+ int i;
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 7 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Input data required by sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
- unsigned char *pSrc = uptr;
- unsigned char *pDst = upred_ptr;
-
- // U & V
- for (i=0; i<2 ; i++)
- {
+ int len = 7 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Input data required by sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
+ unsigned char *pSrc = uptr;
+ unsigned char *pDst = upred_ptr;
+
+ // U & V
+ for (i = 0; i < 2; i++) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ((omv_row | omv_col) & 15)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel interpolation
- xd->subpixel_predict8x8(pTemp, len, omv_col & 15,
- omv_row & 15, pDst, 8);
- }
+ if ((omv_row | omv_col) & 15) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel interpolation
+ xd->subpixel_predict8x8(pTemp, len, omv_col & 15,
+ omv_row & 15, pDst, 8);
+ }
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ((mv_row | mv_col) & 7)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel interpolation
- xd->subpixel_predict8x8(pTemp, len, mv_col & 7,
- mv_row & 7, pDst, 8);
- }
+ if ((mv_row | mv_col) & 7) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel interpolation
+ xd->subpixel_predict8x8(pTemp, len, mv_col & 7,
+ mv_row & 7, pDst, 8);
+ }
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- // Apply prediction filter as we copy from source to destination
- filter_mb(pSrc, pre_stride, pDst, 8, 8, 8);
- }
-
- // V
- pSrc = vptr;
- pDst = vpred_ptr;
- }
+ else {
+ // Apply prediction filter as we copy from source to destination
+ filter_mb(pSrc, pre_stride, pDst, 8, 8, 8);
+ }
+
+ // V
+ pSrc = vptr;
+ pDst = vpred_ptr;
}
- else
+ } else
#endif
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ((omv_row | omv_col) & 15)
- {
- xd->subpixel_predict8x8(uptr, pre_stride, omv_col & 15, omv_row & 15, upred_ptr, 8);
- xd->subpixel_predict8x8(vptr, pre_stride, omv_col & 15, omv_row & 15, vpred_ptr, 8);
+ if ((omv_row | omv_col) & 15) {
+ xd->subpixel_predict8x8(uptr, pre_stride, omv_col & 15, omv_row & 15, upred_ptr, 8);
+ xd->subpixel_predict8x8(vptr, pre_stride, omv_col & 15, omv_row & 15, vpred_ptr, 8);
}
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ((mv_row | mv_col) & 7)
- {
- xd->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, upred_ptr, 8);
- xd->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vpred_ptr, 8);
+ if ((mv_row | mv_col) & 7) {
+ xd->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, upred_ptr, 8);
+ xd->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vpred_ptr, 8);
}
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- RECON_INVOKE(&xd->rtcd->recon, copy8x8)(uptr, pre_stride, upred_ptr, 8);
- RECON_INVOKE(&xd->rtcd->recon, copy8x8)(vptr, pre_stride, vpred_ptr, 8);
+ else {
+ RECON_INVOKE(&xd->rtcd->recon, copy8x8)(uptr, pre_stride, upred_ptr, 8);
+ RECON_INVOKE(&xd->rtcd->recon, copy8x8)(vptr, pre_stride, vpred_ptr, 8);
}
}
/*encoder only*/
-void vp8_build_inter4x4_predictors_mbuv(MACROBLOCKD *x)
-{
- int i, j;
-
- /* build uv mvs */
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- int yoffset = i * 8 + j * 2;
- int uoffset = 16 + i * 2 + j;
- int voffset = 20 + i * 2 + j;
- int temp;
-
- temp = x->block[yoffset ].bmi.as_mv.first.as_mv.row
- + x->block[yoffset+1].bmi.as_mv.first.as_mv.row
- + x->block[yoffset+4].bmi.as_mv.first.as_mv.row
- + x->block[yoffset+5].bmi.as_mv.first.as_mv.row;
-
- if (temp < 0) temp -= 4;
- else temp += 4;
-
- x->block[uoffset].bmi.as_mv.first.as_mv.row = (temp / 8) & x->fullpixel_mask;
-
- temp = x->block[yoffset ].bmi.as_mv.first.as_mv.col
- + x->block[yoffset+1].bmi.as_mv.first.as_mv.col
- + x->block[yoffset+4].bmi.as_mv.first.as_mv.col
- + x->block[yoffset+5].bmi.as_mv.first.as_mv.col;
-
- if (temp < 0) temp -= 4;
- else temp += 4;
-
- x->block[uoffset].bmi.as_mv.first.as_mv.col = (temp / 8) & x->fullpixel_mask;
-
- x->block[voffset].bmi.as_mv.first.as_mv.row =
- x->block[uoffset].bmi.as_mv.first.as_mv.row ;
- x->block[voffset].bmi.as_mv.first.as_mv.col =
- x->block[uoffset].bmi.as_mv.first.as_mv.col ;
-
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- temp = x->block[yoffset ].bmi.as_mv.second.as_mv.row
- + x->block[yoffset+1].bmi.as_mv.second.as_mv.row
- + x->block[yoffset+4].bmi.as_mv.second.as_mv.row
- + x->block[yoffset+5].bmi.as_mv.second.as_mv.row;
-
- if (temp < 0)
- {
- temp -= 4;
- }
- else
- {
- temp += 4;
- }
-
- x->block[uoffset].bmi.as_mv.second.as_mv.row = (temp / 8) & x->fullpixel_mask;
-
- temp = x->block[yoffset ].bmi.as_mv.second.as_mv.col
- + x->block[yoffset+1].bmi.as_mv.second.as_mv.col
- + x->block[yoffset+4].bmi.as_mv.second.as_mv.col
- + x->block[yoffset+5].bmi.as_mv.second.as_mv.col;
-
- if (temp < 0)
- {
- temp -= 4;
- }
- else
- {
- temp += 4;
- }
-
- x->block[uoffset].bmi.as_mv.second.as_mv.col = (temp / 8) & x->fullpixel_mask;
-
- x->block[voffset].bmi.as_mv.second.as_mv.row =
- x->block[uoffset].bmi.as_mv.second.as_mv.row ;
- x->block[voffset].bmi.as_mv.second.as_mv.col =
- x->block[uoffset].bmi.as_mv.second.as_mv.col ;
- }
+void vp8_build_inter4x4_predictors_mbuv(MACROBLOCKD *x) {
+ int i, j;
+
+ /* build uv mvs */
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ int yoffset = i * 8 + j * 2;
+ int uoffset = 16 + i * 2 + j;
+ int voffset = 20 + i * 2 + j;
+ int temp;
+
+ temp = x->block[yoffset ].bmi.as_mv.first.as_mv.row
+ + x->block[yoffset + 1].bmi.as_mv.first.as_mv.row
+ + x->block[yoffset + 4].bmi.as_mv.first.as_mv.row
+ + x->block[yoffset + 5].bmi.as_mv.first.as_mv.row;
+
+ if (temp < 0) temp -= 4;
+ else temp += 4;
+
+ x->block[uoffset].bmi.as_mv.first.as_mv.row = (temp / 8) & x->fullpixel_mask;
+
+ temp = x->block[yoffset ].bmi.as_mv.first.as_mv.col
+ + x->block[yoffset + 1].bmi.as_mv.first.as_mv.col
+ + x->block[yoffset + 4].bmi.as_mv.first.as_mv.col
+ + x->block[yoffset + 5].bmi.as_mv.first.as_mv.col;
+
+ if (temp < 0) temp -= 4;
+ else temp += 4;
+
+ x->block[uoffset].bmi.as_mv.first.as_mv.col = (temp / 8) & x->fullpixel_mask;
+
+ x->block[voffset].bmi.as_mv.first.as_mv.row =
+ x->block[uoffset].bmi.as_mv.first.as_mv.row;
+ x->block[voffset].bmi.as_mv.first.as_mv.col =
+ x->block[uoffset].bmi.as_mv.first.as_mv.col;
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ temp = x->block[yoffset ].bmi.as_mv.second.as_mv.row
+ + x->block[yoffset + 1].bmi.as_mv.second.as_mv.row
+ + x->block[yoffset + 4].bmi.as_mv.second.as_mv.row
+ + x->block[yoffset + 5].bmi.as_mv.second.as_mv.row;
+
+ if (temp < 0) {
+ temp -= 4;
+ } else {
+ temp += 4;
}
- }
- for (i = 16; i < 24; i += 2)
- {
- BLOCKD *d0 = &x->block[i];
- BLOCKD *d1 = &x->block[i+1];
-
- if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
- build_inter_predictors2b(x, d0, 8);
- else
- {
- vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
- vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
- }
+ x->block[uoffset].bmi.as_mv.second.as_mv.row = (temp / 8) & x->fullpixel_mask;
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- vp8_build_2nd_inter_predictors_b(d0, 8, x->subpixel_predict_avg);
- vp8_build_2nd_inter_predictors_b(d1, 8, x->subpixel_predict_avg);
+ temp = x->block[yoffset ].bmi.as_mv.second.as_mv.col
+ + x->block[yoffset + 1].bmi.as_mv.second.as_mv.col
+ + x->block[yoffset + 4].bmi.as_mv.second.as_mv.col
+ + x->block[yoffset + 5].bmi.as_mv.second.as_mv.col;
+
+ if (temp < 0) {
+ temp -= 4;
+ } else {
+ temp += 4;
}
+
+ x->block[uoffset].bmi.as_mv.second.as_mv.col = (temp / 8) & x->fullpixel_mask;
+
+ x->block[voffset].bmi.as_mv.second.as_mv.row =
+ x->block[uoffset].bmi.as_mv.second.as_mv.row;
+ x->block[voffset].bmi.as_mv.second.as_mv.col =
+ x->block[uoffset].bmi.as_mv.second.as_mv.col;
+ }
}
+ }
+
+ for (i = 16; i < 24; i += 2) {
+ BLOCKD *d0 = &x->block[i];
+ BLOCKD *d1 = &x->block[i + 1];
+
+ if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
+ build_inter_predictors2b(x, d0, 8);
+ else {
+ vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
+ vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
+ }
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ vp8_build_2nd_inter_predictors_b(d0, 8, x->subpixel_predict_avg);
+ vp8_build_2nd_inter_predictors_b(d1, 8, x->subpixel_predict_avg);
+ }
+ }
}
/*encoder only*/
-void vp8_build_inter16x16_predictors_mby(MACROBLOCKD *xd)
-{
- unsigned char *ptr_base;
- unsigned char *ptr;
- unsigned char *pred_ptr = xd->predictor;
- int mv_row = xd->mode_info_context->mbmi.mv.as_mv.row;
- int mv_col = xd->mode_info_context->mbmi.mv.as_mv.col;
- int pre_stride = xd->block[0].pre_stride;
-
- ptr_base = xd->pre.y_buffer;
- ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
+void vp8_build_inter16x16_predictors_mby(MACROBLOCKD *xd) {
+ unsigned char *ptr_base;
+ unsigned char *ptr;
+ unsigned char *pred_ptr = xd->predictor;
+ int mv_row = xd->mode_info_context->mbmi.mv.as_mv.row;
+ int mv_col = xd->mode_info_context->mbmi.mv.as_mv.col;
+ int pre_stride = xd->block[0].pre_stride;
+
+ ptr_base = xd->pre.y_buffer;
+ ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
#if CONFIG_PRED_FILTER
- if (xd->mode_info_context->mbmi.pred_filter_enabled)
- {
- // Produce predictor from the filtered source
- if ((mv_row | mv_col) & 7)
- {
- // Sub-pel filter needs extended input
+ if (xd->mode_info_context->mbmi.pred_filter_enabled) {
+ // Produce predictor from the filtered source
+ if ((mv_row | mv_col) & 7) {
+ // Sub-pel filter needs extended input
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 15 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Data required by sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
+ int len = 15 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Data required by sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(ptr-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(ptr - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
- // Sub-pel interpolation
+ // Sub-pel interpolation
#if CONFIG_SIXTEENTH_SUBPEL_UV
- xd->subpixel_predict16x16(pTemp, len, (mv_col & 7)<<1,
- (mv_row & 7)<<1, pred_ptr, 16);
+ xd->subpixel_predict16x16(pTemp, len, (mv_col & 7) << 1,
+ (mv_row & 7) << 1, pred_ptr, 16);
#else
- xd->subpixel_predict16x16(pTemp, len, mv_col & 7,
- mv_row & 7, pred_ptr, 16);
+ xd->subpixel_predict16x16(pTemp, len, mv_col & 7,
+ mv_row & 7, pred_ptr, 16);
#endif
- }
- else
- {
- // Apply spatial filter to create the prediction directly
- filter_mb(ptr, pre_stride, pred_ptr, 16, 16, 16);
- }
+ } else {
+ // Apply spatial filter to create the prediction directly
+ filter_mb(ptr, pre_stride, pred_ptr, 16, 16, 16);
}
- else
+ } else
#endif
- if ((mv_row | mv_col) & 7)
- {
+ if ((mv_row | mv_col) & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- xd->subpixel_predict16x16(ptr, pre_stride, (mv_col & 7)<<1,
- (mv_row & 7)<<1, pred_ptr, 16);
+ xd->subpixel_predict16x16(ptr, pre_stride, (mv_col & 7) << 1,
+ (mv_row & 7) << 1, pred_ptr, 16);
#else
- xd->subpixel_predict16x16(ptr, pre_stride, mv_col & 7,
- mv_row & 7, pred_ptr, 16);
+ xd->subpixel_predict16x16(ptr, pre_stride, mv_col & 7,
+ mv_row & 7, pred_ptr, 16);
#endif
- }
- else
- {
- RECON_INVOKE(&xd->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
+ } else {
+ RECON_INVOKE(&xd->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
}
}
-static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd)
-{
- /* If the MV points so far into the UMV border that no visible pixels
- * are used for reconstruction, the subpel part of the MV can be
- * discarded and the MV limited to 16 pixels with equivalent results.
- *
- * This limit kicks in at 19 pixels for the top and left edges, for
- * the 16 pixels plus 3 taps right of the central pixel when subpel
- * filtering. The bottom and right edges use 16 pixels plus 2 pixels
- * left of the central pixel when filtering.
- */
- if (mv->col < (xd->mb_to_left_edge - ((16+INTERP_EXTEND) << 3)))
- mv->col = xd->mb_to_left_edge - (16 << 3);
- else if (mv->col > xd->mb_to_right_edge + ((15+INTERP_EXTEND) << 3))
- mv->col = xd->mb_to_right_edge + (16 << 3);
-
- if (mv->row < (xd->mb_to_top_edge - ((16+INTERP_EXTEND) << 3)))
- mv->row = xd->mb_to_top_edge - (16 << 3);
- else if (mv->row > xd->mb_to_bottom_edge + ((15+INTERP_EXTEND) << 3))
- mv->row = xd->mb_to_bottom_edge + (16 << 3);
+static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd) {
+ /* If the MV points so far into the UMV border that no visible pixels
+ * are used for reconstruction, the subpel part of the MV can be
+ * discarded and the MV limited to 16 pixels with equivalent results.
+ *
+ * This limit kicks in at 19 pixels for the top and left edges, for
+ * the 16 pixels plus 3 taps right of the central pixel when subpel
+ * filtering. The bottom and right edges use 16 pixels plus 2 pixels
+ * left of the central pixel when filtering.
+ */
+ if (mv->col < (xd->mb_to_left_edge - ((16 + INTERP_EXTEND) << 3)))
+ mv->col = xd->mb_to_left_edge - (16 << 3);
+ else if (mv->col > xd->mb_to_right_edge + ((15 + INTERP_EXTEND) << 3))
+ mv->col = xd->mb_to_right_edge + (16 << 3);
+
+ if (mv->row < (xd->mb_to_top_edge - ((16 + INTERP_EXTEND) << 3)))
+ mv->row = xd->mb_to_top_edge - (16 << 3);
+ else if (mv->row > xd->mb_to_bottom_edge + ((15 + INTERP_EXTEND) << 3))
+ mv->row = xd->mb_to_bottom_edge + (16 << 3);
}
/* A version of the above function for chroma block MVs.*/
-static void clamp_uvmv_to_umv_border(MV *mv, const MACROBLOCKD *xd)
-{
- mv->col = (2*mv->col < (xd->mb_to_left_edge - ((16+INTERP_EXTEND) << 3))) ?
- (xd->mb_to_left_edge - (16 << 3)) >> 1 : mv->col;
- mv->col = (2*mv->col > xd->mb_to_right_edge + ((15+INTERP_EXTEND) << 3)) ?
- (xd->mb_to_right_edge + (16 << 3)) >> 1 : mv->col;
-
- mv->row = (2*mv->row < (xd->mb_to_top_edge - ((16+INTERP_EXTEND) << 3))) ?
- (xd->mb_to_top_edge - (16 << 3)) >> 1 : mv->row;
- mv->row = (2*mv->row > xd->mb_to_bottom_edge + ((15+INTERP_EXTEND) << 3)) ?
- (xd->mb_to_bottom_edge + (16 << 3)) >> 1 : mv->row;
+static void clamp_uvmv_to_umv_border(MV *mv, const MACROBLOCKD *xd) {
+ mv->col = (2 * mv->col < (xd->mb_to_left_edge - ((16 + INTERP_EXTEND) << 3))) ?
+ (xd->mb_to_left_edge - (16 << 3)) >> 1 : mv->col;
+ mv->col = (2 * mv->col > xd->mb_to_right_edge + ((15 + INTERP_EXTEND) << 3)) ?
+ (xd->mb_to_right_edge + (16 << 3)) >> 1 : mv->col;
+
+ mv->row = (2 * mv->row < (xd->mb_to_top_edge - ((16 + INTERP_EXTEND) << 3))) ?
+ (xd->mb_to_top_edge - (16 << 3)) >> 1 : mv->row;
+ mv->row = (2 * mv->row > xd->mb_to_bottom_edge + ((15 + INTERP_EXTEND) << 3)) ?
+ (xd->mb_to_bottom_edge + (16 << 3)) >> 1 : mv->row;
}
@@ -791,182 +712,163 @@ void vp8_build_inter16x16_predictors_mb(MACROBLOCKD *x,
unsigned char *dst_u,
unsigned char *dst_v,
int dst_ystride,
- int dst_uvstride)
-{
- int offset;
- unsigned char *ptr;
- unsigned char *uptr, *vptr;
+ int dst_uvstride) {
+ int offset;
+ unsigned char *ptr;
+ unsigned char *uptr, *vptr;
- int_mv _o16x16mv;
- int_mv _16x16mv;
+ int_mv _o16x16mv;
+ int_mv _16x16mv;
- unsigned char *ptr_base = x->pre.y_buffer;
- int pre_stride = x->block[0].pre_stride;
+ unsigned char *ptr_base = x->pre.y_buffer;
+ int pre_stride = x->block[0].pre_stride;
- _16x16mv.as_int = x->mode_info_context->mbmi.mv.as_int;
+ _16x16mv.as_int = x->mode_info_context->mbmi.mv.as_int;
- if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- {
- clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
- }
+ if (x->mode_info_context->mbmi.need_to_clamp_mvs) {
+ clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
+ }
- ptr = ptr_base + (_16x16mv.as_mv.row >> 3) * pre_stride +
- (_16x16mv.as_mv.col >> 3);
+ ptr = ptr_base + (_16x16mv.as_mv.row >> 3) * pre_stride +
+ (_16x16mv.as_mv.col >> 3);
#if CONFIG_PRED_FILTER
- if (x->mode_info_context->mbmi.pred_filter_enabled)
- {
- if ( _16x16mv.as_int & 0x00070007)
- {
- // Sub-pel filter needs extended input
+ if (x->mode_info_context->mbmi.pred_filter_enabled) {
+ if (_16x16mv.as_int & 0x00070007) {
+ // Sub-pel filter needs extended input
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 15 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Data required by the sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
+ int len = 15 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Data required by the sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(ptr-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(ptr - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
- // Sub-pel filter
+ // Sub-pel filter
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict16x16(pTemp, len,
- (_16x16mv.as_mv.col & 7)<<1,
- (_16x16mv.as_mv.row & 7)<<1,
- dst_y, dst_ystride);
+ x->subpixel_predict16x16(pTemp, len,
+ (_16x16mv.as_mv.col & 7) << 1,
+ (_16x16mv.as_mv.row & 7) << 1,
+ dst_y, dst_ystride);
#else
- x->subpixel_predict16x16(pTemp, len,
- _16x16mv.as_mv.col & 7,
- _16x16mv.as_mv.row & 7,
- dst_y, dst_ystride);
+ x->subpixel_predict16x16(pTemp, len,
+ _16x16mv.as_mv.col & 7,
+ _16x16mv.as_mv.row & 7,
+ dst_y, dst_ystride);
#endif
- }
- else
- {
- // Apply spatial filter to create the prediction directly
- filter_mb(ptr, pre_stride, dst_y, dst_ystride, 16, 16);
- }
+ } else {
+ // Apply spatial filter to create the prediction directly
+ filter_mb(ptr, pre_stride, dst_y, dst_ystride, 16, 16);
}
- else
+ } else
#endif
- if ( _16x16mv.as_int & 0x00070007)
- {
+ if (_16x16mv.as_int & 0x00070007) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict16x16(ptr, pre_stride, (_16x16mv.as_mv.col & 7)<<1,
- (_16x16mv.as_mv.row & 7)<<1,
- dst_y, dst_ystride);
+ x->subpixel_predict16x16(ptr, pre_stride, (_16x16mv.as_mv.col & 7) << 1,
+ (_16x16mv.as_mv.row & 7) << 1,
+ dst_y, dst_ystride);
#else
- x->subpixel_predict16x16(ptr, pre_stride, _16x16mv.as_mv.col & 7,
- _16x16mv.as_mv.row & 7, dst_y, dst_ystride);
+ x->subpixel_predict16x16(ptr, pre_stride, _16x16mv.as_mv.col & 7,
+ _16x16mv.as_mv.row & 7, dst_y, dst_ystride);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, dst_y,
- dst_ystride);
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, dst_y,
+ dst_ystride);
}
- _o16x16mv = _16x16mv;
- /* calc uv motion vectors */
- if ( _16x16mv.as_mv.row < 0)
- _16x16mv.as_mv.row -= 1;
- else
- _16x16mv.as_mv.row += 1;
+ _o16x16mv = _16x16mv;
+ /* calc uv motion vectors */
+ if (_16x16mv.as_mv.row < 0)
+ _16x16mv.as_mv.row -= 1;
+ else
+ _16x16mv.as_mv.row += 1;
- if (_16x16mv.as_mv.col < 0)
- _16x16mv.as_mv.col -= 1;
- else
- _16x16mv.as_mv.col += 1;
+ if (_16x16mv.as_mv.col < 0)
+ _16x16mv.as_mv.col -= 1;
+ else
+ _16x16mv.as_mv.col += 1;
- _16x16mv.as_mv.row /= 2;
- _16x16mv.as_mv.col /= 2;
+ _16x16mv.as_mv.row /= 2;
+ _16x16mv.as_mv.col /= 2;
- _16x16mv.as_mv.row &= x->fullpixel_mask;
- _16x16mv.as_mv.col &= x->fullpixel_mask;
+ _16x16mv.as_mv.row &= x->fullpixel_mask;
+ _16x16mv.as_mv.col &= x->fullpixel_mask;
- pre_stride >>= 1;
- offset = ( _16x16mv.as_mv.row >> 3) * pre_stride + (_16x16mv.as_mv.col >> 3);
- uptr = x->pre.u_buffer + offset;
- vptr = x->pre.v_buffer + offset;
+ pre_stride >>= 1;
+ offset = (_16x16mv.as_mv.row >> 3) * pre_stride + (_16x16mv.as_mv.col >> 3);
+ uptr = x->pre.u_buffer + offset;
+ vptr = x->pre.v_buffer + offset;
#if CONFIG_PRED_FILTER
- if (x->mode_info_context->mbmi.pred_filter_enabled)
- {
- int i;
- unsigned char *pSrc = uptr;
- unsigned char *pDst = dst_u;
+ if (x->mode_info_context->mbmi.pred_filter_enabled) {
+ int i;
+ unsigned char *pSrc = uptr;
+ unsigned char *pDst = dst_u;
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 7 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Data required by the sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
+ int len = 7 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Data required by the sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
- // U & V
- for (i=0; i<2; i++)
- {
+ // U & V
+ for (i = 0; i < 2; i++) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ( _o16x16mv.as_int & 0x000f000f)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel filter
- x->subpixel_predict8x8(pTemp, len,
- _o16x16mv.as_mv.col & 15,
- _o16x16mv.as_mv.row & 15,
- pDst, dst_uvstride);
- }
+ if (_o16x16mv.as_int & 0x000f000f) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel filter
+ x->subpixel_predict8x8(pTemp, len,
+ _o16x16mv.as_mv.col & 15,
+ _o16x16mv.as_mv.row & 15,
+ pDst, dst_uvstride);
+ }
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ( _16x16mv.as_int & 0x00070007)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel filter
- x->subpixel_predict8x8(pTemp, len,
- _16x16mv.as_mv.col & 7,
- _16x16mv.as_mv.row & 7,
- pDst, dst_uvstride);
- }
+ if (_16x16mv.as_int & 0x00070007) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel filter
+ x->subpixel_predict8x8(pTemp, len,
+ _16x16mv.as_mv.col & 7,
+ _16x16mv.as_mv.row & 7,
+ pDst, dst_uvstride);
+ }
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- filter_mb(pSrc, pre_stride, pDst, dst_uvstride, 8, 8);
- }
-
- // V
- pSrc = vptr;
- pDst = dst_v;
- }
+ else {
+ filter_mb(pSrc, pre_stride, pDst, dst_uvstride, 8, 8);
+ }
+
+ // V
+ pSrc = vptr;
+ pDst = dst_v;
}
- else
+ } else
#endif
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ( _o16x16mv.as_int & 0x000f000f)
- {
- x->subpixel_predict8x8(uptr, pre_stride, _o16x16mv.as_mv.col & 15, _o16x16mv.as_mv.row & 15, dst_u, dst_uvstride);
- x->subpixel_predict8x8(vptr, pre_stride, _o16x16mv.as_mv.col & 15, _o16x16mv.as_mv.row & 15, dst_v, dst_uvstride);
+ if (_o16x16mv.as_int & 0x000f000f) {
+ x->subpixel_predict8x8(uptr, pre_stride, _o16x16mv.as_mv.col & 15, _o16x16mv.as_mv.row & 15, dst_u, dst_uvstride);
+ x->subpixel_predict8x8(vptr, pre_stride, _o16x16mv.as_mv.col & 15, _o16x16mv.as_mv.row & 15, dst_v, dst_uvstride);
}
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ( _16x16mv.as_int & 0x00070007)
- {
- x->subpixel_predict8x8(uptr, pre_stride, _16x16mv.as_mv.col & 7, _16x16mv.as_mv.row & 7, dst_u, dst_uvstride);
- x->subpixel_predict8x8(vptr, pre_stride, _16x16mv.as_mv.col & 7, _16x16mv.as_mv.row & 7, dst_v, dst_uvstride);
+ if (_16x16mv.as_int & 0x00070007) {
+ x->subpixel_predict8x8(uptr, pre_stride, _16x16mv.as_mv.col & 7, _16x16mv.as_mv.row & 7, dst_u, dst_uvstride);
+ x->subpixel_predict8x8(vptr, pre_stride, _16x16mv.as_mv.col & 7, _16x16mv.as_mv.row & 7, dst_v, dst_uvstride);
}
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, dst_u, dst_uvstride);
- RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, dst_v, dst_uvstride);
+ else {
+ RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, dst_u, dst_uvstride);
+ RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, dst_v, dst_uvstride);
}
}
@@ -990,392 +892,343 @@ void vp8_build_2nd_inter16x16_predictors_mb(MACROBLOCKD *x,
unsigned char *dst_u,
unsigned char *dst_v,
int dst_ystride,
- int dst_uvstride)
-{
- int offset;
- unsigned char *ptr;
- unsigned char *uptr, *vptr;
+ int dst_uvstride) {
+ int offset;
+ unsigned char *ptr;
+ unsigned char *uptr, *vptr;
- int_mv _16x16mv;
- int mv_row;
- int mv_col;
+ int_mv _16x16mv;
+ int mv_row;
+ int mv_col;
- int omv_row, omv_col;
+ int omv_row, omv_col;
- unsigned char *ptr_base = x->second_pre.y_buffer;
- int pre_stride = x->block[0].pre_stride;
+ unsigned char *ptr_base = x->second_pre.y_buffer;
+ int pre_stride = x->block[0].pre_stride;
- _16x16mv.as_int = x->mode_info_context->mbmi.second_mv.as_int;
+ _16x16mv.as_int = x->mode_info_context->mbmi.second_mv.as_int;
- if (x->mode_info_context->mbmi.need_to_clamp_secondmv)
- {
- clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
- }
+ if (x->mode_info_context->mbmi.need_to_clamp_secondmv) {
+ clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
+ }
- mv_row = _16x16mv.as_mv.row;
- mv_col = _16x16mv.as_mv.col;
+ mv_row = _16x16mv.as_mv.row;
+ mv_col = _16x16mv.as_mv.col;
- ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
+ ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
#if CONFIG_PRED_FILTER
- if (x->mode_info_context->mbmi.pred_filter_enabled)
- {
- if ((mv_row | mv_col) & 7)
- {
- // Sub-pel filter needs extended input
+ if (x->mode_info_context->mbmi.pred_filter_enabled) {
+ if ((mv_row | mv_col) & 7) {
+ // Sub-pel filter needs extended input
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 15 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Data required by sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
+ int len = 15 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Data required by sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(ptr-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(ptr - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
- // Sub-pel filter
+ // Sub-pel filter
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict_avg16x16(pTemp, len, (mv_col & 7)<<1,
- (mv_row & 7)<<1, dst_y, dst_ystride);
+ x->subpixel_predict_avg16x16(pTemp, len, (mv_col & 7) << 1,
+ (mv_row & 7) << 1, dst_y, dst_ystride);
#else
- x->subpixel_predict_avg16x16(pTemp, len, mv_col & 7,
- mv_row & 7, dst_y, dst_ystride);
+ x->subpixel_predict_avg16x16(pTemp, len, mv_col & 7,
+ mv_row & 7, dst_y, dst_ystride);
#endif
- }
- else
- {
- // TODO Needs to AVERAGE with the dst_y
- // For now, do not apply the prediction filter in these cases!
- RECON_INVOKE(&x->rtcd->recon, avg16x16)(ptr, pre_stride, dst_y,
- dst_ystride);
- }
+ } else {
+ // TODO Needs to AVERAGE with the dst_y
+ // For now, do not apply the prediction filter in these cases!
+ RECON_INVOKE(&x->rtcd->recon, avg16x16)(ptr, pre_stride, dst_y,
+ dst_ystride);
}
- else
+ } else
#endif // CONFIG_PRED_FILTER
- {
- if ((mv_row | mv_col) & 7)
- {
+ {
+ if ((mv_row | mv_col) & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict_avg16x16(ptr, pre_stride, (mv_col & 7)<<1,
- (mv_row & 7)<<1, dst_y, dst_ystride);
+ x->subpixel_predict_avg16x16(ptr, pre_stride, (mv_col & 7) << 1,
+ (mv_row & 7) << 1, dst_y, dst_ystride);
#else
- x->subpixel_predict_avg16x16(ptr, pre_stride, mv_col & 7,
- mv_row & 7, dst_y, dst_ystride);
+ x->subpixel_predict_avg16x16(ptr, pre_stride, mv_col & 7,
+ mv_row & 7, dst_y, dst_ystride);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, avg16x16)(ptr, pre_stride, dst_y,
- dst_ystride);
- }
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, avg16x16)(ptr, pre_stride, dst_y,
+ dst_ystride);
}
+ }
- /* calc uv motion vectors */
- omv_row = mv_row;
- omv_col = mv_col;
- mv_row = (mv_row + (mv_row > 0)) >> 1;
- mv_col = (mv_col + (mv_col > 0)) >> 1;
+ /* calc uv motion vectors */
+ omv_row = mv_row;
+ omv_col = mv_col;
+ mv_row = (mv_row + (mv_row > 0)) >> 1;
+ mv_col = (mv_col + (mv_col > 0)) >> 1;
- mv_row &= x->fullpixel_mask;
- mv_col &= x->fullpixel_mask;
+ mv_row &= x->fullpixel_mask;
+ mv_col &= x->fullpixel_mask;
- pre_stride >>= 1;
- offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
- uptr = x->second_pre.u_buffer + offset;
- vptr = x->second_pre.v_buffer + offset;
+ pre_stride >>= 1;
+ offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+ uptr = x->second_pre.u_buffer + offset;
+ vptr = x->second_pre.v_buffer + offset;
#if CONFIG_PRED_FILTER
- if (x->mode_info_context->mbmi.pred_filter_enabled)
- {
- int i;
+ if (x->mode_info_context->mbmi.pred_filter_enabled) {
+ int i;
#if CONFIG_ENHANCED_INTERP
- int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
+ int Interp_Extend = 4; // 8-tap filter needs 3+4 pels extension
#else
- int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
+ int Interp_Extend = 3; // 6-tap filter needs 2+3 pels extension
#endif
- int len = 7 + (Interp_Extend << 1);
- unsigned char Temp[32*32]; // Data required by sub-pel filter
- unsigned char *pTemp = Temp + (Interp_Extend-1)*(len+1);
- unsigned char *pSrc = uptr;
- unsigned char *pDst = dst_u;
-
- // U & V
- for (i=0; i<2; i++)
- {
+ int len = 7 + (Interp_Extend << 1);
+ unsigned char Temp[32 * 32]; // Data required by sub-pel filter
+ unsigned char *pTemp = Temp + (Interp_Extend - 1) * (len + 1);
+ unsigned char *pSrc = uptr;
+ unsigned char *pDst = dst_u;
+
+ // U & V
+ for (i = 0; i < 2; i++) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ((omv_row | omv_col) & 15)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel filter
- x->subpixel_predict_avg8x8(pTemp, len, omv_col & 15,
- omv_row & 15, pDst, dst_uvstride);
- }
+ if ((omv_row | omv_col) & 15) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel filter
+ x->subpixel_predict_avg8x8(pTemp, len, omv_col & 15,
+ omv_row & 15, pDst, dst_uvstride);
+ }
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ((mv_row | mv_col) & 7)
- {
- // Copy extended MB into Temp array, applying the spatial filter
- filter_mb(pSrc-(Interp_Extend-1)*(pre_stride+1), pre_stride,
- Temp, len, len, len);
-
- // Sub-pel filter
- x->subpixel_predict_avg8x8(pTemp, len, mv_col & 7, mv_row & 7,
- pDst, dst_uvstride);
- }
+ if ((mv_row | mv_col) & 7) {
+ // Copy extended MB into Temp array, applying the spatial filter
+ filter_mb(pSrc - (Interp_Extend - 1) * (pre_stride + 1), pre_stride,
+ Temp, len, len, len);
+
+ // Sub-pel filter
+ x->subpixel_predict_avg8x8(pTemp, len, mv_col & 7, mv_row & 7,
+ pDst, dst_uvstride);
+ }
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- // TODO Needs to AVERAGE with the dst_[u|v]
- // For now, do not apply the prediction filter here!
- RECON_INVOKE(&x->rtcd->recon, avg8x8)(pSrc, pre_stride, pDst,
- dst_uvstride);
- }
-
- // V
- pSrc = vptr;
- pDst = dst_v;
- }
+ else {
+ // TODO Needs to AVERAGE with the dst_[u|v]
+ // For now, do not apply the prediction filter here!
+ RECON_INVOKE(&x->rtcd->recon, avg8x8)(pSrc, pre_stride, pDst,
+ dst_uvstride);
+ }
+
+ // V
+ pSrc = vptr;
+ pDst = dst_v;
}
- else
+ } else
#endif // CONFIG_PRED_FILTER
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ((omv_row | omv_col) & 15)
- {
- x->subpixel_predict_avg8x8(uptr, pre_stride, omv_col & 15, omv_row & 15, dst_u, dst_uvstride);
- x->subpixel_predict_avg8x8(vptr, pre_stride, omv_col & 15, omv_row & 15, dst_v, dst_uvstride);
+ if ((omv_row | omv_col) & 15) {
+ x->subpixel_predict_avg8x8(uptr, pre_stride, omv_col & 15, omv_row & 15, dst_u, dst_uvstride);
+ x->subpixel_predict_avg8x8(vptr, pre_stride, omv_col & 15, omv_row & 15, dst_v, dst_uvstride);
}
#else /* CONFIG_SIXTEENTH_SUBPEL_UV */
- if ((mv_row | mv_col) & 7)
- {
- x->subpixel_predict_avg8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, dst_u, dst_uvstride);
- x->subpixel_predict_avg8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, dst_v, dst_uvstride);
+ if ((mv_row | mv_col) & 7) {
+ x->subpixel_predict_avg8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, dst_u, dst_uvstride);
+ x->subpixel_predict_avg8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, dst_v, dst_uvstride);
}
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
- else
- {
- RECON_INVOKE(&x->rtcd->recon, avg8x8)(uptr, pre_stride, dst_u, dst_uvstride);
- RECON_INVOKE(&x->rtcd->recon, avg8x8)(vptr, pre_stride, dst_v, dst_uvstride);
+ else {
+ RECON_INVOKE(&x->rtcd->recon, avg8x8)(uptr, pre_stride, dst_u, dst_uvstride);
+ RECON_INVOKE(&x->rtcd->recon, avg8x8)(vptr, pre_stride, dst_v, dst_uvstride);
}
}
-static void build_inter4x4_predictors_mb(MACROBLOCKD *x)
-{
- int i;
-
- if (x->mode_info_context->mbmi.partitioning < 3)
- {
- x->block[ 0].bmi = x->mode_info_context->bmi[ 0];
- x->block[ 2].bmi = x->mode_info_context->bmi[ 2];
- x->block[ 8].bmi = x->mode_info_context->bmi[ 8];
- x->block[10].bmi = x->mode_info_context->bmi[10];
-
- if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- {
- clamp_mv_to_umv_border(&x->block[ 0].bmi.as_mv.first.as_mv, x);
- clamp_mv_to_umv_border(&x->block[ 2].bmi.as_mv.first.as_mv, x);
- clamp_mv_to_umv_border(&x->block[ 8].bmi.as_mv.first.as_mv, x);
- clamp_mv_to_umv_border(&x->block[10].bmi.as_mv.first.as_mv, x);
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- clamp_mv_to_umv_border(&x->block[ 0].bmi.as_mv.second.as_mv, x);
- clamp_mv_to_umv_border(&x->block[ 2].bmi.as_mv.second.as_mv, x);
- clamp_mv_to_umv_border(&x->block[ 8].bmi.as_mv.second.as_mv, x);
- clamp_mv_to_umv_border(&x->block[10].bmi.as_mv.second.as_mv, x);
- }
- }
+static void build_inter4x4_predictors_mb(MACROBLOCKD *x) {
+ int i;
+
+ if (x->mode_info_context->mbmi.partitioning < 3) {
+ x->block[ 0].bmi = x->mode_info_context->bmi[ 0];
+ x->block[ 2].bmi = x->mode_info_context->bmi[ 2];
+ x->block[ 8].bmi = x->mode_info_context->bmi[ 8];
+ x->block[10].bmi = x->mode_info_context->bmi[10];
+
+ if (x->mode_info_context->mbmi.need_to_clamp_mvs) {
+ clamp_mv_to_umv_border(&x->block[ 0].bmi.as_mv.first.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[ 2].bmi.as_mv.first.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[ 8].bmi.as_mv.first.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[10].bmi.as_mv.first.as_mv, x);
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ clamp_mv_to_umv_border(&x->block[ 0].bmi.as_mv.second.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[ 2].bmi.as_mv.second.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[ 8].bmi.as_mv.second.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[10].bmi.as_mv.second.as_mv, x);
+ }
+ }
- build_inter_predictors4b(x, &x->block[ 0], 16);
- build_inter_predictors4b(x, &x->block[ 2], 16);
- build_inter_predictors4b(x, &x->block[ 8], 16);
- build_inter_predictors4b(x, &x->block[10], 16);
+ build_inter_predictors4b(x, &x->block[ 0], 16);
+ build_inter_predictors4b(x, &x->block[ 2], 16);
+ build_inter_predictors4b(x, &x->block[ 8], 16);
+ build_inter_predictors4b(x, &x->block[10], 16);
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- build_2nd_inter_predictors4b(x, &x->block[ 0], 16);
- build_2nd_inter_predictors4b(x, &x->block[ 2], 16);
- build_2nd_inter_predictors4b(x, &x->block[ 8], 16);
- build_2nd_inter_predictors4b(x, &x->block[10], 16);
- }
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ build_2nd_inter_predictors4b(x, &x->block[ 0], 16);
+ build_2nd_inter_predictors4b(x, &x->block[ 2], 16);
+ build_2nd_inter_predictors4b(x, &x->block[ 8], 16);
+ build_2nd_inter_predictors4b(x, &x->block[10], 16);
}
- else
- {
- for (i = 0; i < 16; i += 2)
- {
- BLOCKD *d0 = &x->block[i];
- BLOCKD *d1 = &x->block[i+1];
-
- x->block[i+0].bmi = x->mode_info_context->bmi[i+0];
- x->block[i+1].bmi = x->mode_info_context->bmi[i+1];
-
- if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- {
- clamp_mv_to_umv_border(&x->block[i+0].bmi.as_mv.first.as_mv, x);
- clamp_mv_to_umv_border(&x->block[i+1].bmi.as_mv.first.as_mv, x);
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- clamp_mv_to_umv_border(&x->block[i+0].bmi.as_mv.second.as_mv, x);
- clamp_mv_to_umv_border(&x->block[i+1].bmi.as_mv.second.as_mv, x);
- }
- }
-
- if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
- build_inter_predictors2b(x, d0, 16);
- else
- {
- vp8_build_inter_predictors_b(d0, 16, x->subpixel_predict);
- vp8_build_inter_predictors_b(d1, 16, x->subpixel_predict);
- }
-
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- vp8_build_2nd_inter_predictors_b(d0, 16, x->subpixel_predict_avg);
- vp8_build_2nd_inter_predictors_b(d1, 16, x->subpixel_predict_avg);
- }
+ } else {
+ for (i = 0; i < 16; i += 2) {
+ BLOCKD *d0 = &x->block[i];
+ BLOCKD *d1 = &x->block[i + 1];
+
+ x->block[i + 0].bmi = x->mode_info_context->bmi[i + 0];
+ x->block[i + 1].bmi = x->mode_info_context->bmi[i + 1];
+
+ if (x->mode_info_context->mbmi.need_to_clamp_mvs) {
+ clamp_mv_to_umv_border(&x->block[i + 0].bmi.as_mv.first.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[i + 1].bmi.as_mv.first.as_mv, x);
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ clamp_mv_to_umv_border(&x->block[i + 0].bmi.as_mv.second.as_mv, x);
+ clamp_mv_to_umv_border(&x->block[i + 1].bmi.as_mv.second.as_mv, x);
}
+ }
+
+ if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
+ build_inter_predictors2b(x, d0, 16);
+ else {
+ vp8_build_inter_predictors_b(d0, 16, x->subpixel_predict);
+ vp8_build_inter_predictors_b(d1, 16, x->subpixel_predict);
+ }
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ vp8_build_2nd_inter_predictors_b(d0, 16, x->subpixel_predict_avg);
+ vp8_build_2nd_inter_predictors_b(d1, 16, x->subpixel_predict_avg);
+ }
}
+ }
- for (i = 16; i < 24; i += 2)
- {
- BLOCKD *d0 = &x->block[i];
- BLOCKD *d1 = &x->block[i+1];
-
- if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
- build_inter_predictors2b(x, d0, 8);
- else
- {
- vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
- vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
- }
+ for (i = 16; i < 24; i += 2) {
+ BLOCKD *d0 = &x->block[i];
+ BLOCKD *d1 = &x->block[i + 1];
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- vp8_build_2nd_inter_predictors_b(d0, 8, x->subpixel_predict_avg);
- vp8_build_2nd_inter_predictors_b(d1, 8, x->subpixel_predict_avg);
- }
+ if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
+ build_inter_predictors2b(x, d0, 8);
+ else {
+ vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
+ vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
}
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ vp8_build_2nd_inter_predictors_b(d0, 8, x->subpixel_predict_avg);
+ vp8_build_2nd_inter_predictors_b(d1, 8, x->subpixel_predict_avg);
+ }
+ }
}
static
-void build_4x4uvmvs(MACROBLOCKD *x)
-{
- int i, j;
-
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- int yoffset = i * 8 + j * 2;
- int uoffset = 16 + i * 2 + j;
- int voffset = 20 + i * 2 + j;
-
- int temp;
-
- temp = x->mode_info_context->bmi[yoffset + 0].as_mv.first.as_mv.row
- + x->mode_info_context->bmi[yoffset + 1].as_mv.first.as_mv.row
- + x->mode_info_context->bmi[yoffset + 4].as_mv.first.as_mv.row
- + x->mode_info_context->bmi[yoffset + 5].as_mv.first.as_mv.row;
-
- if (temp < 0) temp -= 4;
- else temp += 4;
-
- x->block[uoffset].bmi.as_mv.first.as_mv.row = (temp / 8) & x->fullpixel_mask;
-
- temp = x->mode_info_context->bmi[yoffset + 0].as_mv.first.as_mv.col
- + x->mode_info_context->bmi[yoffset + 1].as_mv.first.as_mv.col
- + x->mode_info_context->bmi[yoffset + 4].as_mv.first.as_mv.col
- + x->mode_info_context->bmi[yoffset + 5].as_mv.first.as_mv.col;
-
- if (temp < 0) temp -= 4;
- else temp += 4;
-
- x->block[uoffset].bmi.as_mv.first.as_mv.col = (temp / 8) & x->fullpixel_mask;
-
- //if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.first.as_mv, x);
-
- //if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.first.as_mv, x);
-
- x->block[voffset].bmi.as_mv.first.as_mv.row =
- x->block[uoffset].bmi.as_mv.first.as_mv.row ;
- x->block[voffset].bmi.as_mv.first.as_mv.col =
- x->block[uoffset].bmi.as_mv.first.as_mv.col ;
-
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- temp = x->mode_info_context->bmi[yoffset + 0].as_mv.second.as_mv.row
- + x->mode_info_context->bmi[yoffset + 1].as_mv.second.as_mv.row
- + x->mode_info_context->bmi[yoffset + 4].as_mv.second.as_mv.row
- + x->mode_info_context->bmi[yoffset + 5].as_mv.second.as_mv.row;
-
- if (temp < 0)
- {
- temp -= 4;
- }
- else
- {
- temp += 4;
- }
-
- x->block[uoffset].bmi.as_mv.second.as_mv.row = (temp / 8) & x->fullpixel_mask;
-
- temp = x->mode_info_context->bmi[yoffset + 0].as_mv.second.as_mv.col
- + x->mode_info_context->bmi[yoffset + 1].as_mv.second.as_mv.col
- + x->mode_info_context->bmi[yoffset + 4].as_mv.second.as_mv.col
- + x->mode_info_context->bmi[yoffset + 5].as_mv.second.as_mv.col;
-
- if (temp < 0)
- {
- temp -= 4;
- }
- else
- {
- temp += 4;
- }
-
- x->block[uoffset].bmi.as_mv.second.as_mv.col = (temp / 8) & x->fullpixel_mask;
-
- //if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.second.as_mv, x);
-
- //if (x->mode_info_context->mbmi.need_to_clamp_mvs)
- clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.second.as_mv, x);
-
- x->block[voffset].bmi.as_mv.second.as_mv.row =
- x->block[uoffset].bmi.as_mv.second.as_mv.row ;
- x->block[voffset].bmi.as_mv.second.as_mv.col =
- x->block[uoffset].bmi.as_mv.second.as_mv.col ;
- }
+void build_4x4uvmvs(MACROBLOCKD *x) {
+ int i, j;
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ int yoffset = i * 8 + j * 2;
+ int uoffset = 16 + i * 2 + j;
+ int voffset = 20 + i * 2 + j;
+
+ int temp;
+
+ temp = x->mode_info_context->bmi[yoffset + 0].as_mv.first.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 1].as_mv.first.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 4].as_mv.first.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 5].as_mv.first.as_mv.row;
+
+ if (temp < 0) temp -= 4;
+ else temp += 4;
+
+ x->block[uoffset].bmi.as_mv.first.as_mv.row = (temp / 8) & x->fullpixel_mask;
+
+ temp = x->mode_info_context->bmi[yoffset + 0].as_mv.first.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 1].as_mv.first.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 4].as_mv.first.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 5].as_mv.first.as_mv.col;
+
+ if (temp < 0) temp -= 4;
+ else temp += 4;
+
+ x->block[uoffset].bmi.as_mv.first.as_mv.col = (temp / 8) & x->fullpixel_mask;
+
+ // if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.first.as_mv, x);
+
+ // if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.first.as_mv, x);
+
+ x->block[voffset].bmi.as_mv.first.as_mv.row =
+ x->block[uoffset].bmi.as_mv.first.as_mv.row;
+ x->block[voffset].bmi.as_mv.first.as_mv.col =
+ x->block[uoffset].bmi.as_mv.first.as_mv.col;
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ temp = x->mode_info_context->bmi[yoffset + 0].as_mv.second.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 1].as_mv.second.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 4].as_mv.second.as_mv.row
+ + x->mode_info_context->bmi[yoffset + 5].as_mv.second.as_mv.row;
+
+ if (temp < 0) {
+ temp -= 4;
+ } else {
+ temp += 4;
}
- }
-}
-void vp8_build_inter_predictors_mb(MACROBLOCKD *x)
-{
- if (x->mode_info_context->mbmi.mode != SPLITMV)
- {
- vp8_build_inter16x16_predictors_mb(x, x->predictor, &x->predictor[256],
- &x->predictor[320], 16, 8);
-
- if (x->mode_info_context->mbmi.second_ref_frame)
- {
- /* 256 = offset of U plane in Y+U+V buffer;
- * 320 = offset of V plane in Y+U+V buffer.
- * (256=16x16, 320=16x16+8x8). */
- vp8_build_2nd_inter16x16_predictors_mb(x, x->predictor,
- &x->predictor[256],
- &x->predictor[320], 16, 8);
+ x->block[uoffset].bmi.as_mv.second.as_mv.row = (temp / 8) & x->fullpixel_mask;
+
+ temp = x->mode_info_context->bmi[yoffset + 0].as_mv.second.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 1].as_mv.second.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 4].as_mv.second.as_mv.col
+ + x->mode_info_context->bmi[yoffset + 5].as_mv.second.as_mv.col;
+
+ if (temp < 0) {
+ temp -= 4;
+ } else {
+ temp += 4;
}
+
+ x->block[uoffset].bmi.as_mv.second.as_mv.col = (temp / 8) & x->fullpixel_mask;
+
+ // if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.second.as_mv, x);
+
+ // if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.as_mv.second.as_mv, x);
+
+ x->block[voffset].bmi.as_mv.second.as_mv.row =
+ x->block[uoffset].bmi.as_mv.second.as_mv.row;
+ x->block[voffset].bmi.as_mv.second.as_mv.col =
+ x->block[uoffset].bmi.as_mv.second.as_mv.col;
+ }
}
- else
- {
- build_4x4uvmvs(x);
- build_inter4x4_predictors_mb(x);
+ }
+}
+
+void vp8_build_inter_predictors_mb(MACROBLOCKD *x) {
+ if (x->mode_info_context->mbmi.mode != SPLITMV) {
+ vp8_build_inter16x16_predictors_mb(x, x->predictor, &x->predictor[256],
+ &x->predictor[320], 16, 8);
+
+ if (x->mode_info_context->mbmi.second_ref_frame) {
+ /* 256 = offset of U plane in Y+U+V buffer;
+ * 320 = offset of V plane in Y+U+V buffer.
+ * (256=16x16, 320=16x16+8x8). */
+ vp8_build_2nd_inter16x16_predictors_mb(x, x->predictor,
+ &x->predictor[256],
+ &x->predictor[320], 16, 8);
}
+ } else {
+ build_4x4uvmvs(x);
+ build_inter4x4_predictors_mb(x);
+ }
}
diff --git a/vp8/common/reconintra.c b/vp8/common/reconintra.c
index 27b47926e..e06d914ba 100644
--- a/vp8/common/reconintra.c
+++ b/vp8/common/reconintra.c
@@ -20,359 +20,302 @@
#if CONFIG_NEWINTRAMODES
void d27_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c, h, w, v;
- int a, b;
- r = 0;
- for (c = 0; c < n-2; c++)
- {
- if (c&1)
- a = yleft_col[r + 1];
- else
- a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
- b = yabove_row[c + 2];
- ypred_ptr[c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3);
- }
- for (r = 1; r < n/2 - 1; r++)
- {
- for (c = 0; c < n - 2 - 2 * r; c++)
- {
- if (c&1)
- a = yleft_col[r + 1];
- else
- a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
- b = ypred_ptr[(r - 1) * y_stride + c + 2];
- ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3);
- }
- }
- for (; r < n - 1; ++r)
- {
- for (c = 0; c < n; c++)
- {
- v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1);
- h = r - c/2;
- ypred_ptr[h * y_stride + c] = v;
- }
- }
- c = 0;
- r = n - 1;
- ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] +
- yleft_col[r] + 1) >> 1;
- for (r = n - 2; r >= n/2; --r)
- {
- w = c + (n - 1 - r) * 2;
- ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
- ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
- }
- for (c = 1; c < n; c++)
- {
- for (r = n - 1; r >= n/2 + c/2; --r)
- {
- w = c + (n - 1 - r) * 2;
- ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
- ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
- }
- }
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c, h, w, v;
+ int a, b;
+ r = 0;
+ for (c = 0; c < n - 2; c++) {
+ if (c & 1)
+ a = yleft_col[r + 1];
+ else
+ a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
+ b = yabove_row[c + 2];
+ ypred_ptr[c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
+ }
+ for (r = 1; r < n / 2 - 1; r++) {
+ for (c = 0; c < n - 2 - 2 * r; c++) {
+ if (c & 1)
+ a = yleft_col[r + 1];
+ else
+ a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
+ b = ypred_ptr[(r - 1) * y_stride + c + 2];
+ ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
+ }
+ }
+ for (; r < n - 1; ++r) {
+ for (c = 0; c < n; c++) {
+ v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1);
+ h = r - c / 2;
+ ypred_ptr[h * y_stride + c] = v;
+ }
+ }
+ c = 0;
+ r = n - 1;
+ ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] +
+ yleft_col[r] + 1) >> 1;
+ for (r = n - 2; r >= n / 2; --r) {
+ w = c + (n - 1 - r) * 2;
+ ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
+ ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
+ }
+ for (c = 1; c < n; c++) {
+ for (r = n - 1; r >= n / 2 + c / 2; --r) {
+ w = c + (n - 1 - r) * 2;
+ ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
+ ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
+ }
+ }
}
void d63_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c, h, w, v;
- int a, b;
- c = 0;
- for (r = 0; r < n-2; r++)
- {
- if (r&1)
- a = yabove_row[c + 1];
- else
- a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
- b = yleft_col[r + 2];
- ypred_ptr[r * y_stride] = (2 * a + (r + 1) * b + (r + 3)/2) / (r + 3);
- }
- for (c = 1; c < n/2 - 1; c++)
- {
- for (r = 0; r < n - 2 - 2 * c; r++)
- {
- if (r&1)
- a = yabove_row[c + 1];
- else
- a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
- b = ypred_ptr[(r + 2) * y_stride + c - 1];
- ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3);
- }
- }
- for (; c < n - 1; ++c)
- {
- for (r = 0; r < n; r++)
- {
- v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1);
- w = c - r/2;
- ypred_ptr[r * y_stride + w] = v;
- }
- }
- r = 0;
- c = n - 1;
- ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1;
- for (c = n - 2; c >= n/2; --c)
- {
- h = r + (n - 1 - c) * 2;
- ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
- ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
- }
- for (r = 1; r < n; r++)
- {
- for (c = n - 1; c >= n/2 + r/2; --c)
- {
- h = r + (n - 1 - c) * 2;
- ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
- ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
- }
- }
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c, h, w, v;
+ int a, b;
+ c = 0;
+ for (r = 0; r < n - 2; r++) {
+ if (r & 1)
+ a = yabove_row[c + 1];
+ else
+ a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
+ b = yleft_col[r + 2];
+ ypred_ptr[r * y_stride] = (2 * a + (r + 1) * b + (r + 3) / 2) / (r + 3);
+ }
+ for (c = 1; c < n / 2 - 1; c++) {
+ for (r = 0; r < n - 2 - 2 * c; r++) {
+ if (r & 1)
+ a = yabove_row[c + 1];
+ else
+ a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
+ b = ypred_ptr[(r + 2) * y_stride + c - 1];
+ ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
+ }
+ }
+ for (; c < n - 1; ++c) {
+ for (r = 0; r < n; r++) {
+ v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1);
+ w = c - r / 2;
+ ypred_ptr[r * y_stride + w] = v;
+ }
+ }
+ r = 0;
+ c = n - 1;
+ ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1;
+ for (c = n - 2; c >= n / 2; --c) {
+ h = r + (n - 1 - c) * 2;
+ ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
+ ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
+ }
+ for (r = 1; r < n; r++) {
+ for (c = n - 1; c >= n / 2 + r / 2; --c) {
+ h = r + (n - 1 - c) * 2;
+ ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
+ ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
+ }
+ }
}
void d45_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c;
- for (r = 0; r < n - 1; ++r)
- {
- for (c = 0; c <= r; ++c)
- {
- ypred_ptr[(r - c) * y_stride + c] =
- (yabove_row[r+1] * (c + 1) +
- yleft_col[r+1] * (r - c + 1) + r/2 + 1) / (r + 2);
- }
- }
- for (c = 0; c <= r; ++c)
- {
- int yabove_ext = yabove_row[r]; //2*yabove_row[r] - yabove_row[r-1];
- int yleft_ext = yleft_col[r]; //2*yleft_col[r] - yleft_col[r-1];
- yabove_ext = (yabove_ext > 255 ? 255 : (yabove_ext < 0 ? 0 : yabove_ext));
- yleft_ext = (yleft_ext > 255 ? 255 : (yleft_ext < 0 ? 0 : yleft_ext));
- ypred_ptr[(r - c) * y_stride + c] =
- (yabove_ext * (c + 1) +
- yleft_ext * (r - c + 1) + r/2 + 1) / (r + 2);
- }
- for (r = 1; r < n; ++r)
- {
- for (c = n - r; c < n; ++c)
- ypred_ptr[r * y_stride + c] = (ypred_ptr[(r - 1) * y_stride + c] +
- ypred_ptr[r * y_stride + c - 1] + 1) >> 1;
- }
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c;
+ for (r = 0; r < n - 1; ++r) {
+ for (c = 0; c <= r; ++c) {
+ ypred_ptr[(r - c) * y_stride + c] =
+ (yabove_row[r + 1] * (c + 1) +
+ yleft_col[r + 1] * (r - c + 1) + r / 2 + 1) / (r + 2);
+ }
+ }
+ for (c = 0; c <= r; ++c) {
+ int yabove_ext = yabove_row[r]; // 2*yabove_row[r] - yabove_row[r-1];
+ int yleft_ext = yleft_col[r]; // 2*yleft_col[r] - yleft_col[r-1];
+ yabove_ext = (yabove_ext > 255 ? 255 : (yabove_ext < 0 ? 0 : yabove_ext));
+ yleft_ext = (yleft_ext > 255 ? 255 : (yleft_ext < 0 ? 0 : yleft_ext));
+ ypred_ptr[(r - c) * y_stride + c] =
+ (yabove_ext * (c + 1) +
+ yleft_ext * (r - c + 1) + r / 2 + 1) / (r + 2);
+ }
+ for (r = 1; r < n; ++r) {
+ for (c = n - r; c < n; ++c)
+ ypred_ptr[r * y_stride + c] = (ypred_ptr[(r - 1) * y_stride + c] +
+ ypred_ptr[r * y_stride + c - 1] + 1) >> 1;
+ }
}
void d117_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c;
- for (c = 0; c < n; c++)
- ypred_ptr[c] = (yabove_row[c-1] + yabove_row[c] + 1) >> 1;
- ypred_ptr += y_stride;
- for (c = 0; c < n; c++)
- ypred_ptr[c] = yabove_row[c-1];
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c;
+ for (c = 0; c < n; c++)
+ ypred_ptr[c] = (yabove_row[c - 1] + yabove_row[c] + 1) >> 1;
+ ypred_ptr += y_stride;
+ for (c = 0; c < n; c++)
+ ypred_ptr[c] = yabove_row[c - 1];
+ ypred_ptr += y_stride;
+ for (r = 2; r < n; ++r) {
+ ypred_ptr[0] = yleft_col[r - 2];
+ for (c = 1; c < n; c++)
+ ypred_ptr[c] = ypred_ptr[-2 * y_stride + c - 1];
ypred_ptr += y_stride;
- for (r = 2; r < n; ++r)
- {
- ypred_ptr[0] = yleft_col[r - 2];
- for (c = 1; c < n; c++)
- ypred_ptr[c] = ypred_ptr[-2*y_stride+c-1];
- ypred_ptr += y_stride;
- }
+ }
}
void d135_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c;
- ypred_ptr[0] = yabove_row[-1];
- for (c = 1; c < n; c++)
- ypred_ptr[c] = yabove_row[c - 1];
- for (r = 1; r < n; ++r)
- ypred_ptr[r * y_stride] = yleft_col[r - 1];
-
- ypred_ptr += y_stride;
- for (r = 1; r < n; ++r)
- {
- for (c = 1; c < n; c++)
- {
- ypred_ptr[c] = ypred_ptr[-y_stride + c - 1];
- }
- ypred_ptr += y_stride;
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c;
+ ypred_ptr[0] = yabove_row[-1];
+ for (c = 1; c < n; c++)
+ ypred_ptr[c] = yabove_row[c - 1];
+ for (r = 1; r < n; ++r)
+ ypred_ptr[r * y_stride] = yleft_col[r - 1];
+
+ ypred_ptr += y_stride;
+ for (r = 1; r < n; ++r) {
+ for (c = 1; c < n; c++) {
+ ypred_ptr[c] = ypred_ptr[-y_stride + c - 1];
}
+ ypred_ptr += y_stride;
+ }
}
void d153_predictor(unsigned char *ypred_ptr, int y_stride, int n,
- unsigned char *yabove_row, unsigned char *yleft_col)
-{
- int r, c;
- ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1;
- for (r = 1; r < n; r++)
- ypred_ptr[r * y_stride] = (yleft_col[r-1] + yleft_col[r] + 1) >> 1;
- ypred_ptr++;
- ypred_ptr[0] = yabove_row[-1];
- for (r = 1; r < n; r++)
- ypred_ptr[r * y_stride] = yleft_col[r-1];
- ypred_ptr++;
-
+ unsigned char *yabove_row, unsigned char *yleft_col) {
+ int r, c;
+ ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1;
+ for (r = 1; r < n; r++)
+ ypred_ptr[r * y_stride] = (yleft_col[r - 1] + yleft_col[r] + 1) >> 1;
+ ypred_ptr++;
+ ypred_ptr[0] = yabove_row[-1];
+ for (r = 1; r < n; r++)
+ ypred_ptr[r * y_stride] = yleft_col[r - 1];
+ ypred_ptr++;
+
+ for (c = 0; c < n - 2; c++)
+ ypred_ptr[c] = yabove_row[c];
+ ypred_ptr += y_stride;
+ for (r = 1; r < n; ++r) {
for (c = 0; c < n - 2; c++)
- ypred_ptr[c] = yabove_row[c];
+ ypred_ptr[c] = ypred_ptr[-y_stride + c - 2];
ypred_ptr += y_stride;
- for (r = 1; r < n; ++r)
- {
- for (c = 0; c < n - 2; c++)
- ypred_ptr[c] = ypred_ptr[-y_stride+c-2];
- ypred_ptr += y_stride;
- }
+ }
}
#endif /* CONFIG_NEWINTRAMODES */
-void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
-{
- int i;
+void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) {
+ int i;
- for (i = 16; i < 24; i += 2)
- {
- BLOCKD *b = &x->block[i];
- RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- }
+ for (i = 16; i < 24; i += 2) {
+ BLOCKD *b = &x->block[i];
+ RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ }
}
-void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypred_ptr, int y_stride, int mode)
-{
-
- unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride;
- unsigned char yleft_col[16];
- unsigned char ytop_left = yabove_row[-1];
- int r, c, i;
-
- for (i = 0; i < 16; i++)
- {
- yleft_col[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
- }
-
- /* for Y */
- switch (mode)
- {
- case DC_PRED:
- {
- int expected_dc;
- int i;
- int shift;
- int average = 0;
-
-
- if (x->up_available || x->left_available)
- {
- if (x->up_available)
- {
- for (i = 0; i < 16; i++)
- {
- average += yabove_row[i];
- }
- }
-
- if (x->left_available)
- {
- for (i = 0; i < 16; i++)
- {
- average += yleft_col[i];
- }
- }
- shift = 3 + x->up_available + x->left_available;
- expected_dc = (average + (1 << (shift - 1))) >> shift;
- }
- else
- {
- expected_dc = 128;
+void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypred_ptr, int y_stride, int mode) {
+
+ unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride;
+ unsigned char yleft_col[16];
+ unsigned char ytop_left = yabove_row[-1];
+ int r, c, i;
+
+ for (i = 0; i < 16; i++) {
+ yleft_col[i] = x->dst.y_buffer [i * x->dst.y_stride - 1];
+ }
+
+ /* for Y */
+ switch (mode) {
+ case DC_PRED: {
+ int expected_dc;
+ int i;
+ int shift;
+ int average = 0;
+
+
+ if (x->up_available || x->left_available) {
+ if (x->up_available) {
+ for (i = 0; i < 16; i++) {
+ average += yabove_row[i];
+ }
}
- for (r = 0; r < 16; r++)
- {
- vpx_memset(ypred_ptr, expected_dc, 16);
- ypred_ptr += y_stride; /*16;*/
+ if (x->left_available) {
+ for (i = 0; i < 16; i++) {
+ average += yleft_col[i];
+ }
}
+ shift = 3 + x->up_available + x->left_available;
+ expected_dc = (average + (1 << (shift - 1))) >> shift;
+ } else {
+ expected_dc = 128;
+ }
+
+ for (r = 0; r < 16; r++) {
+ vpx_memset(ypred_ptr, expected_dc, 16);
+ ypred_ptr += y_stride; /*16;*/
+ }
}
break;
- case V_PRED:
- {
+ case V_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
- ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
- ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
- ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
- ypred_ptr += y_stride;
- }
+ ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
+ ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
+ ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
+ ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
+ ypred_ptr += y_stride;
+ }
}
break;
- case H_PRED:
- {
+ case H_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- vpx_memset(ypred_ptr, yleft_col[r], 16);
- ypred_ptr += y_stride;
- }
+ vpx_memset(ypred_ptr, yleft_col[r], 16);
+ ypred_ptr += y_stride;
+ }
}
break;
- case TM_PRED:
- {
-
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
+ case TM_PRED: {
- if (pred < 0)
- pred = 0;
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
- if (pred > 255)
- pred = 255;
+ if (pred < 0)
+ pred = 0;
- ypred_ptr[c] = pred;
- }
+ if (pred > 255)
+ pred = 255;
- ypred_ptr += y_stride;
+ ypred_ptr[c] = pred;
}
+ ypred_ptr += y_stride;
+ }
+
}
break;
#if CONFIG_NEWINTRAMODES
- case D45_PRED:
- {
- d45_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D45_PRED: {
+ d45_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
- case D135_PRED:
- {
- d135_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D135_PRED: {
+ d135_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
- case D117_PRED:
- {
- d117_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D117_PRED: {
+ d117_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
- case D153_PRED:
- {
- d153_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D153_PRED: {
+ d153_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
- case D27_PRED:
- {
- d27_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D27_PRED: {
+ d27_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
- case D63_PRED:
- {
- d63_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
+ case D63_PRED: {
+ d63_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col);
}
break;
#endif
@@ -386,37 +329,33 @@ void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypre
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
-void vp8_build_intra_predictors_mby(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mby_internal(x, x->predictor, 16,
- x->mode_info_context->mbmi.mode);
+void vp8_build_intra_predictors_mby(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mby_internal(x, x->predictor, 16,
+ x->mode_info_context->mbmi.mode);
}
-void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mby_internal(x, x->dst.y_buffer, x->dst.y_stride,
- x->mode_info_context->mbmi.mode);
+void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mby_internal(x, x->dst.y_buffer, x->dst.y_stride,
+ x->mode_info_context->mbmi.mode);
}
#if CONFIG_COMP_INTRA_PRED
-void vp8_build_comp_intra_predictors_mby(MACROBLOCKD *x)
-{
- unsigned char predictor[2][256];
- int i;
-
- vp8_build_intra_predictors_mby_internal(x, predictor[0], 16,
- x->mode_info_context->mbmi.mode);
- vp8_build_intra_predictors_mby_internal(x, predictor[1], 16,
- x->mode_info_context->mbmi.second_mode);
-
- for (i = 0; i < 256; i++)
- {
- x->predictor[i] = (predictor[0][i] + predictor[1][i] + 1) >> 1;
- }
+void vp8_build_comp_intra_predictors_mby(MACROBLOCKD *x) {
+ unsigned char predictor[2][256];
+ int i;
+
+ vp8_build_intra_predictors_mby_internal(x, predictor[0], 16,
+ x->mode_info_context->mbmi.mode);
+ vp8_build_intra_predictors_mby_internal(x, predictor[1], 16,
+ x->mode_info_context->mbmi.second_mode);
+
+ for (i = 0; i < 256; i++) {
+ x->predictor[i] = (predictor[0][i] + predictor[1][i] + 1) >> 1;
+ }
}
#endif
@@ -424,172 +363,147 @@ void vp8_build_intra_predictors_mbuv_internal(MACROBLOCKD *x,
unsigned char *upred_ptr,
unsigned char *vpred_ptr,
int uv_stride,
- int mode)
-{
- unsigned char *uabove_row = x->dst.u_buffer - x->dst.uv_stride;
- unsigned char uleft_col[16];
- unsigned char utop_left = uabove_row[-1];
- unsigned char *vabove_row = x->dst.v_buffer - x->dst.uv_stride;
- unsigned char vleft_col[20];
- unsigned char vtop_left = vabove_row[-1];
-
- int i, j;
-
- for (i = 0; i < 8; i++)
- {
- uleft_col[i] = x->dst.u_buffer [i* x->dst.uv_stride -1];
- vleft_col[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
- }
-
- switch (mode)
- {
- case DC_PRED:
- {
- int expected_udc;
- int expected_vdc;
- int i;
- int shift;
- int Uaverage = 0;
- int Vaverage = 0;
-
- if (x->up_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uabove_row[i];
- Vaverage += vabove_row[i];
- }
- }
-
- if (x->left_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uleft_col[i];
- Vaverage += vleft_col[i];
- }
- }
-
- if (!x->up_available && !x->left_available)
- {
- expected_udc = 128;
- expected_vdc = 128;
- }
- else
- {
- shift = 2 + x->up_available + x->left_available;
- expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
- expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
- }
-
-
- /*vpx_memset(upred_ptr,expected_udc,64);*/
- /*vpx_memset(vpred_ptr,expected_vdc,64);*/
- for (i = 0; i < 8; i++)
- {
- vpx_memset(upred_ptr, expected_udc, 8);
- vpx_memset(vpred_ptr, expected_vdc, 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
+ int mode) {
+ unsigned char *uabove_row = x->dst.u_buffer - x->dst.uv_stride;
+ unsigned char uleft_col[16];
+ unsigned char utop_left = uabove_row[-1];
+ unsigned char *vabove_row = x->dst.v_buffer - x->dst.uv_stride;
+ unsigned char vleft_col[20];
+ unsigned char vtop_left = vabove_row[-1];
+
+ int i, j;
+
+ for (i = 0; i < 8; i++) {
+ uleft_col[i] = x->dst.u_buffer [i * x->dst.uv_stride - 1];
+ vleft_col[i] = x->dst.v_buffer [i * x->dst.uv_stride - 1];
+ }
+
+ switch (mode) {
+ case DC_PRED: {
+ int expected_udc;
+ int expected_vdc;
+ int i;
+ int shift;
+ int Uaverage = 0;
+ int Vaverage = 0;
+
+ if (x->up_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uabove_row[i];
+ Vaverage += vabove_row[i];
+ }
+ }
+
+ if (x->left_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uleft_col[i];
+ Vaverage += vleft_col[i];
+ }
+ }
+
+ if (!x->up_available && !x->left_available) {
+ expected_udc = 128;
+ expected_vdc = 128;
+ } else {
+ shift = 2 + x->up_available + x->left_available;
+ expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
+ expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
+ }
+
+
+ /*vpx_memset(upred_ptr,expected_udc,64);*/
+ /*vpx_memset(vpred_ptr,expected_vdc,64);*/
+ for (i = 0; i < 8; i++) {
+ vpx_memset(upred_ptr, expected_udc, 8);
+ vpx_memset(vpred_ptr, expected_vdc, 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
}
break;
- case V_PRED:
- {
- int i;
+ case V_PRED: {
+ int i;
- for (i = 0; i < 8; i++)
- {
- vpx_memcpy(upred_ptr, uabove_row, 8);
- vpx_memcpy(vpred_ptr, vabove_row, 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
+ for (i = 0; i < 8; i++) {
+ vpx_memcpy(upred_ptr, uabove_row, 8);
+ vpx_memcpy(vpred_ptr, vabove_row, 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
}
break;
- case H_PRED:
- {
- int i;
+ case H_PRED: {
+ int i;
- for (i = 0; i < 8; i++)
- {
- vpx_memset(upred_ptr, uleft_col[i], 8);
- vpx_memset(vpred_ptr, vleft_col[i], 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
+ for (i = 0; i < 8; i++) {
+ vpx_memset(upred_ptr, uleft_col[i], 8);
+ vpx_memset(vpred_ptr, vleft_col[i], 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
}
break;
- case TM_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 8; j++)
- {
- int predu = uleft_col[i] + uabove_row[j] - utop_left;
- int predv = vleft_col[i] + vabove_row[j] - vtop_left;
+ case TM_PRED: {
+ int i;
- if (predu < 0)
- predu = 0;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ int predu = uleft_col[i] + uabove_row[j] - utop_left;
+ int predv = vleft_col[i] + vabove_row[j] - vtop_left;
- if (predu > 255)
- predu = 255;
+ if (predu < 0)
+ predu = 0;
- if (predv < 0)
- predv = 0;
+ if (predu > 255)
+ predu = 255;
- if (predv > 255)
- predv = 255;
+ if (predv < 0)
+ predv = 0;
- upred_ptr[j] = predu;
- vpred_ptr[j] = predv;
- }
+ if (predv > 255)
+ predv = 255;
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
+ upred_ptr[j] = predu;
+ vpred_ptr[j] = predv;
}
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
+
}
break;
#if CONFIG_NEWINTRAMODES
- case D45_PRED:
- {
- d45_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d45_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D45_PRED: {
+ d45_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d45_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
- case D135_PRED:
- {
- d135_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d135_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D135_PRED: {
+ d135_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d135_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
- case D117_PRED:
- {
- d117_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d117_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D117_PRED: {
+ d117_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d117_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
- case D153_PRED:
- {
- d153_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d153_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D153_PRED: {
+ d153_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d153_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
- case D27_PRED:
- {
- d27_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d27_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D27_PRED: {
+ d27_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d27_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
- case D63_PRED:
- {
- d63_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
- d63_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
+ case D63_PRED: {
+ d63_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col);
+ d63_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col);
}
break;
#endif
@@ -600,322 +514,268 @@ void vp8_build_intra_predictors_mbuv_internal(MACROBLOCKD *x,
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
-void vp8_build_intra_predictors_mbuv(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_internal(x,
- &x->predictor[256],
- &x->predictor[320],
- 8,
- x->mode_info_context->mbmi.uv_mode);
+void vp8_build_intra_predictors_mbuv(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_internal(x,
+ &x->predictor[256],
+ &x->predictor[320],
+ 8,
+ x->mode_info_context->mbmi.uv_mode);
}
-void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_internal(x,
- x->dst.u_buffer,
- x->dst.v_buffer,
- x->dst.uv_stride,
- x->mode_info_context->mbmi.uv_mode);
+void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_internal(x,
+ x->dst.u_buffer,
+ x->dst.v_buffer,
+ x->dst.uv_stride,
+ x->mode_info_context->mbmi.uv_mode);
}
#if CONFIG_COMP_INTRA_PRED
-void vp8_build_comp_intra_predictors_mbuv(MACROBLOCKD *x)
-{
- unsigned char predictor[2][2][64];
- int i;
-
- vp8_build_intra_predictors_mbuv_internal(x, predictor[0][0], predictor[1][0], 8,
- x->mode_info_context->mbmi.uv_mode);
- vp8_build_intra_predictors_mbuv_internal(x, predictor[0][1], predictor[1][1], 8,
- x->mode_info_context->mbmi.second_uv_mode);
- for (i = 0; i < 64; i++)
- {
- x->predictor[256 + i] = (predictor[0][0][i] + predictor[0][1][i] + 1) >> 1;
- x->predictor[256 + 64 + i] = (predictor[1][0][i] + predictor[1][1][i] + 1) >> 1;
- }
+void vp8_build_comp_intra_predictors_mbuv(MACROBLOCKD *x) {
+ unsigned char predictor[2][2][64];
+ int i;
+
+ vp8_build_intra_predictors_mbuv_internal(x, predictor[0][0], predictor[1][0], 8,
+ x->mode_info_context->mbmi.uv_mode);
+ vp8_build_intra_predictors_mbuv_internal(x, predictor[0][1], predictor[1][1], 8,
+ x->mode_info_context->mbmi.second_uv_mode);
+ for (i = 0; i < 64; i++) {
+ x->predictor[256 + i] = (predictor[0][0][i] + predictor[0][1][i] + 1) >> 1;
+ x->predictor[256 + 64 + i] = (predictor[1][0][i] + predictor[1][1][i] + 1) >> 1;
+ }
}
#endif
void vp8_intra8x8_predict(BLOCKD *x,
int mode,
- unsigned char *predictor)
-{
-
- unsigned char *yabove_row = *(x->base_dst) + x->dst - x->dst_stride;
- unsigned char yleft_col[8];
- unsigned char ytop_left = yabove_row[-1];
- int r, c, i;
-
- for (i = 0; i < 8; i++)
- {
- yleft_col[i] = (*(x->base_dst))[x->dst - 1 + i * x->dst_stride];
- }
- switch (mode)
- {
- case DC_PRED:
- {
- int expected_dc = 0;
-
- for (i = 0; i < 8; i++)
- {
- expected_dc += yabove_row[i];
- expected_dc += yleft_col[i];
- }
- expected_dc = (expected_dc + 8) >> 4;
-
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- predictor[c] = expected_dc;
- }
- predictor += 16;
- }
- }
- break;
- case V_PRED:
- {
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- predictor[c] = yabove_row[c];
- }
- predictor += 16;
- }
+ unsigned char *predictor) {
+ unsigned char *yabove_row = *(x->base_dst) + x->dst - x->dst_stride;
+ unsigned char yleft_col[8];
+ unsigned char ytop_left = yabove_row[-1];
+ int r, c, i;
+
+ for (i = 0; i < 8; i++) {
+ yleft_col[i] = (*(x->base_dst))[x->dst - 1 + i * x->dst_stride];
+ }
+ switch (mode) {
+ case DC_PRED: {
+ int expected_dc = 0;
+
+ for (i = 0; i < 8; i++) {
+ expected_dc += yabove_row[i];
+ expected_dc += yleft_col[i];
+ }
+ expected_dc = (expected_dc + 8) >> 4;
+
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ predictor[c] = expected_dc;
}
- break;
- case H_PRED:
- {
-
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- predictor[c] = yleft_col[r];
- }
- predictor += 16;
- }
- }
- break;
- case TM_PRED:
- {
- /* prediction similar to true_motion prediction */
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- int pred = yabove_row[c] - ytop_left + yleft_col[r];
- if (pred < 0)
- pred = 0;
-
- if (pred > 255)
- pred = 255;
- predictor[c] = pred;
- }
-
- predictor += 16;
- }
- }
- break;
-#if CONFIG_NEWINTRAMODES
- case D45_PRED:
- {
- d45_predictor(predictor, 16, 8, yabove_row, yleft_col);
- }
- break;
- case D135_PRED:
- {
- d135_predictor(predictor, 16, 8, yabove_row, yleft_col);
- }
- break;
- case D117_PRED:
- {
- d117_predictor(predictor, 16, 8, yabove_row, yleft_col);
- }
- break;
- case D153_PRED:
- {
- d153_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ predictor += 16;
+ }
+ }
+ break;
+ case V_PRED: {
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ predictor[c] = yabove_row[c];
}
- break;
- case D27_PRED:
- {
- d27_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ predictor += 16;
+ }
+
+ }
+ break;
+ case H_PRED: {
+
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ predictor[c] = yleft_col[r];
}
- break;
- case D63_PRED:
- {
- d63_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ predictor += 16;
+ }
+ }
+ break;
+ case TM_PRED: {
+ /* prediction similar to true_motion prediction */
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ int pred = yabove_row[c] - ytop_left + yleft_col[r];
+ if (pred < 0)
+ pred = 0;
+
+ if (pred > 255)
+ pred = 255;
+ predictor[c] = pred;
}
- break;
-#endif
+
+ predictor += 16;
+ }
}
+ break;
+#if CONFIG_NEWINTRAMODES
+ case D45_PRED: {
+ d45_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+ case D135_PRED: {
+ d135_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+ case D117_PRED: {
+ d117_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+ case D153_PRED: {
+ d153_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+ case D27_PRED: {
+ d27_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+ case D63_PRED: {
+ d63_predictor(predictor, 16, 8, yabove_row, yleft_col);
+ }
+ break;
+#endif
+ }
}
#if CONFIG_COMP_INTRA_PRED
void vp8_comp_intra8x8_predict(BLOCKD *x,
int mode, int second_mode,
- unsigned char *out_predictor)
-{
- unsigned char predictor[2][8*16];
- int i, j;
-
- vp8_intra8x8_predict(x, mode, predictor[0]);
- vp8_intra8x8_predict(x, second_mode, predictor[1]);
-
- for (i = 0; i < 8*16; i += 16)
- {
- for (j = i; j < i + 8; j++)
- {
- out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
- }
+ unsigned char *out_predictor) {
+ unsigned char predictor[2][8 * 16];
+ int i, j;
+
+ vp8_intra8x8_predict(x, mode, predictor[0]);
+ vp8_intra8x8_predict(x, second_mode, predictor[1]);
+
+ for (i = 0; i < 8 * 16; i += 16) {
+ for (j = i; j < i + 8; j++) {
+ out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
}
+ }
}
#endif
void vp8_intra_uv4x4_predict(BLOCKD *x,
int mode,
- unsigned char *predictor)
-{
-
- unsigned char *above_row = *(x->base_dst) + x->dst - x->dst_stride;
- unsigned char left_col[4];
- unsigned char top_left = above_row[-1];
- int r, c, i;
-
- for (i = 0; i < 4; i++)
- {
- left_col[i] = (*(x->base_dst))[x->dst - 1 + i * x->dst_stride];
- }
- switch (mode)
- {
- case DC_PRED:
- {
- int expected_dc = 0;
-
- for (i = 0; i < 4; i++)
- {
- expected_dc += above_row[i];
- expected_dc += left_col[i];
- }
- expected_dc = (expected_dc + 4) >> 3;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = expected_dc;
- }
- predictor += 8;
- }
+ unsigned char *predictor) {
+
+ unsigned char *above_row = *(x->base_dst) + x->dst - x->dst_stride;
+ unsigned char left_col[4];
+ unsigned char top_left = above_row[-1];
+ int r, c, i;
+
+ for (i = 0; i < 4; i++) {
+ left_col[i] = (*(x->base_dst))[x->dst - 1 + i * x->dst_stride];
+ }
+ switch (mode) {
+ case DC_PRED: {
+ int expected_dc = 0;
+
+ for (i = 0; i < 4; i++) {
+ expected_dc += above_row[i];
+ expected_dc += left_col[i];
+ }
+ expected_dc = (expected_dc + 4) >> 3;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = expected_dc;
}
- break;
- case V_PRED:
- {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
-
- predictor[c] = above_row[c];
- }
- predictor += 8;
- }
+ predictor += 8;
+ }
+ }
+ break;
+ case V_PRED: {
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = above_row[c];
}
- break;
- case H_PRED:
- {
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = left_col[r];
- }
- predictor += 8;
- }
+ predictor += 8;
+ }
+
+ }
+ break;
+ case H_PRED: {
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = left_col[r];
}
- break;
- case TM_PRED:
- {
- /* prediction similar to true_motion prediction */
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int pred = above_row[c] - top_left + left_col[r];
- if (pred < 0)
- pred = 0;
-
- if (pred > 255)
- pred = 255;
- predictor[c] = pred;
- }
-
- predictor += 8;
- }
+ predictor += 8;
+ }
+ }
+ break;
+ case TM_PRED: {
+ /* prediction similar to true_motion prediction */
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int pred = above_row[c] - top_left + left_col[r];
+ if (pred < 0)
+ pred = 0;
+
+ if (pred > 255)
+ pred = 255;
+ predictor[c] = pred;
}
- break;
+
+ predictor += 8;
+ }
+ }
+ break;
#if CONFIG_NEWINTRAMODES
- case D45_PRED:
- {
- d45_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
- case D135_PRED:
- {
- d135_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
- case D117_PRED:
- {
- d117_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
- case D153_PRED:
- {
- d153_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
- case D27_PRED:
- {
- d27_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
- case D63_PRED:
- {
- d63_predictor(predictor, 8, 4, above_row, left_col);
- }
- break;
-#endif
+ case D45_PRED: {
+ d45_predictor(predictor, 8, 4, above_row, left_col);
}
+ break;
+ case D135_PRED: {
+ d135_predictor(predictor, 8, 4, above_row, left_col);
+ }
+ break;
+ case D117_PRED: {
+ d117_predictor(predictor, 8, 4, above_row, left_col);
+ }
+ break;
+ case D153_PRED: {
+ d153_predictor(predictor, 8, 4, above_row, left_col);
+ }
+ break;
+ case D27_PRED: {
+ d27_predictor(predictor, 8, 4, above_row, left_col);
+ }
+ break;
+ case D63_PRED: {
+ d63_predictor(predictor, 8, 4, above_row, left_col);
+ }
+ break;
+#endif
+ }
}
#if CONFIG_COMP_INTRA_PRED
void vp8_comp_intra_uv4x4_predict(BLOCKD *x,
int mode, int mode2,
- unsigned char *out_predictor)
-{
- unsigned char predictor[2][8*4];
- int i, j;
-
- vp8_intra_uv4x4_predict(x, mode, predictor[0]);
- vp8_intra_uv4x4_predict(x, mode2, predictor[1]);
-
- for (i = 0; i < 4*8; i += 8)
- {
- for (j = i; j < i + 4; j++)
- {
- out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
- }
+ unsigned char *out_predictor) {
+ unsigned char predictor[2][8 * 4];
+ int i, j;
+
+ vp8_intra_uv4x4_predict(x, mode, predictor[0]);
+ vp8_intra_uv4x4_predict(x, mode2, predictor[1]);
+
+ for (i = 0; i < 4 * 8; i += 8) {
+ for (j = i; j < i + 4; j++) {
+ out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
}
+ }
}
#endif
diff --git a/vp8/common/reconintra4x4.c b/vp8/common/reconintra4x4.c
index ab8be4815..c7da1c558 100644
--- a/vp8/common/reconintra4x4.c
+++ b/vp8/common/reconintra4x4.c
@@ -16,322 +16,297 @@
void vp8_intra4x4_predict(BLOCKD *x,
int b_mode,
- unsigned char *predictor)
-{
- int i, r, c;
-
- unsigned char *Above = *(x->base_dst) + x->dst - x->dst_stride;
- unsigned char Left[4];
- unsigned char top_left = Above[-1];
-
- Left[0] = (*(x->base_dst))[x->dst - 1];
- Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride];
- Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride];
- Left[3] = (*(x->base_dst))[x->dst - 1 + 3 * x->dst_stride];
-
- switch (b_mode)
- {
- case B_DC_PRED:
- {
- int expected_dc = 0;
-
- for (i = 0; i < 4; i++)
- {
- expected_dc += Above[i];
- expected_dc += Left[i];
- }
+ unsigned char *predictor) {
+ int i, r, c;
+
+ unsigned char *Above = *(x->base_dst) + x->dst - x->dst_stride;
+ unsigned char Left[4];
+ unsigned char top_left = Above[-1];
+
+ Left[0] = (*(x->base_dst))[x->dst - 1];
+ Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride];
+ Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride];
+ Left[3] = (*(x->base_dst))[x->dst - 1 + 3 * x->dst_stride];
- expected_dc = (expected_dc + 4) >> 3;
+ switch (b_mode) {
+ case B_DC_PRED: {
+ int expected_dc = 0;
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = expected_dc;
- }
+ for (i = 0; i < 4; i++) {
+ expected_dc += Above[i];
+ expected_dc += Left[i];
+ }
- predictor += 16;
+ expected_dc = (expected_dc + 4) >> 3;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = expected_dc;
}
+
+ predictor += 16;
+ }
}
break;
- case B_TM_PRED:
- {
- /* prediction similar to true_motion prediction */
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int pred = Above[c] - top_left + Left[r];
-
- if (pred < 0)
- pred = 0;
+ case B_TM_PRED: {
+ /* prediction similar to true_motion prediction */
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int pred = Above[c] - top_left + Left[r];
- if (pred > 255)
- pred = 255;
+ if (pred < 0)
+ pred = 0;
- predictor[c] = pred;
- }
+ if (pred > 255)
+ pred = 255;
- predictor += 16;
+ predictor[c] = pred;
}
+
+ predictor += 16;
+ }
}
break;
- case B_VE_PRED:
- {
-
- unsigned int ap[4];
- ap[0] = Above[0];
- ap[1] = Above[1];
- ap[2] = Above[2];
- ap[3] = Above[3];
+ case B_VE_PRED: {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
+ unsigned int ap[4];
+ ap[0] = Above[0];
+ ap[1] = Above[1];
+ ap[2] = Above[2];
+ ap[3] = Above[3];
- predictor[c] = ap[c];
- }
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
- predictor += 16;
+ predictor[c] = ap[c];
}
+ predictor += 16;
+ }
+
}
break;
- case B_HE_PRED:
- {
+ case B_HE_PRED: {
- unsigned int lp[4];
- lp[0] = Left[0];
- lp[1] = Left[1];
- lp[2] = Left[2];
- lp[3] = Left[3];
+ unsigned int lp[4];
+ lp[0] = Left[0];
+ lp[1] = Left[1];
+ lp[2] = Left[2];
+ lp[3] = Left[3];
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = lp[r];
- }
-
- predictor += 16;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = lp[r];
}
- }
- break;
- case B_LD_PRED:
- {
- unsigned char *ptr = Above;
- predictor[0 * 16 + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2;
- predictor[0 * 16 + 1] =
- predictor[1 * 16 + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2;
- predictor[0 * 16 + 2] =
- predictor[1 * 16 + 1] =
- predictor[2 * 16 + 0] = (ptr[2] + ptr[3] * 2 + ptr[4] + 2) >> 2;
- predictor[0 * 16 + 3] =
- predictor[1 * 16 + 2] =
- predictor[2 * 16 + 1] =
- predictor[3 * 16 + 0] = (ptr[3] + ptr[4] * 2 + ptr[5] + 2) >> 2;
- predictor[1 * 16 + 3] =
- predictor[2 * 16 + 2] =
- predictor[3 * 16 + 1] = (ptr[4] + ptr[5] * 2 + ptr[6] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[3 * 16 + 2] = (ptr[5] + ptr[6] * 2 + ptr[7] + 2) >> 2;
- predictor[3 * 16 + 3] = (ptr[6] + ptr[7] * 2 + ptr[7] + 2) >> 2;
+ predictor += 16;
+ }
}
break;
- case B_RD_PRED:
- {
-
- unsigned char pp[9];
-
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
- predictor[3 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[3 * 16 + 1] =
- predictor[2 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[3 * 16 + 2] =
- predictor[2 * 16 + 1] =
- predictor[1 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[3 * 16 + 3] =
- predictor[2 * 16 + 2] =
- predictor[1 * 16 + 1] =
- predictor[0 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[1 * 16 + 2] =
- predictor[0 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[1 * 16 + 3] =
- predictor[0 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
+ case B_LD_PRED: {
+ unsigned char *ptr = Above;
+ predictor[0 * 16 + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2;
+ predictor[0 * 16 + 1] =
+ predictor[1 * 16 + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2;
+ predictor[0 * 16 + 2] =
+ predictor[1 * 16 + 1] =
+ predictor[2 * 16 + 0] = (ptr[2] + ptr[3] * 2 + ptr[4] + 2) >> 2;
+ predictor[0 * 16 + 3] =
+ predictor[1 * 16 + 2] =
+ predictor[2 * 16 + 1] =
+ predictor[3 * 16 + 0] = (ptr[3] + ptr[4] * 2 + ptr[5] + 2) >> 2;
+ predictor[1 * 16 + 3] =
+ predictor[2 * 16 + 2] =
+ predictor[3 * 16 + 1] = (ptr[4] + ptr[5] * 2 + ptr[6] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[3 * 16 + 2] = (ptr[5] + ptr[6] * 2 + ptr[7] + 2) >> 2;
+ predictor[3 * 16 + 3] = (ptr[6] + ptr[7] * 2 + ptr[7] + 2) >> 2;
}
break;
- case B_VR_PRED:
- {
-
- unsigned char pp[9];
-
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
-
- predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[3 * 16 + 1] =
- predictor[1 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ case B_RD_PRED: {
+
+ unsigned char pp[9];
+
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+ predictor[3 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[3 * 16 + 1] =
+ predictor[2 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[3 * 16 + 2] =
predictor[2 * 16 + 1] =
- predictor[0 * 16 + 0] = (pp[4] + pp[5] + 1) >> 1;
- predictor[3 * 16 + 2] =
- predictor[1 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[1 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[3 * 16 + 3] =
predictor[2 * 16 + 2] =
- predictor[0 * 16 + 1] = (pp[5] + pp[6] + 1) >> 1;
- predictor[3 * 16 + 3] =
- predictor[1 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[0 * 16 + 2] = (pp[6] + pp[7] + 1) >> 1;
- predictor[1 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[7] + pp[8] + 1) >> 1;
+ predictor[1 * 16 + 1] =
+ predictor[0 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[1 * 16 + 2] =
+ predictor[0 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[1 * 16 + 3] =
+ predictor[0 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
}
break;
- case B_VL_PRED:
- {
+ case B_VR_PRED: {
+
+ unsigned char pp[9];
+
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+
+ predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[3 * 16 + 1] =
+ predictor[1 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 1] =
+ predictor[0 * 16 + 0] = (pp[4] + pp[5] + 1) >> 1;
+ predictor[3 * 16 + 2] =
+ predictor[1 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[0 * 16 + 1] = (pp[5] + pp[6] + 1) >> 1;
+ predictor[3 * 16 + 3] =
+ predictor[1 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[0 * 16 + 2] = (pp[6] + pp[7] + 1) >> 1;
+ predictor[1 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[7] + pp[8] + 1) >> 1;
- unsigned char *pp = Above;
+ }
+ break;
+ case B_VL_PRED: {
- predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[1 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[2 * 16 + 0] =
- predictor[0 * 16 + 1] = (pp[1] + pp[2] + 1) >> 1;
- predictor[1 * 16 + 1] =
- predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 1] =
- predictor[0 * 16 + 2] = (pp[2] + pp[3] + 1) >> 1;
- predictor[3 * 16 + 1] =
- predictor[1 * 16 + 2] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[0 * 16 + 3] =
- predictor[2 * 16 + 2] = (pp[3] + pp[4] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[3 * 16 + 2] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[2 * 16 + 3] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[3 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ unsigned char *pp = Above;
+
+ predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[1 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[2 * 16 + 0] =
+ predictor[0 * 16 + 1] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[1 * 16 + 1] =
+ predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 1] =
+ predictor[0 * 16 + 2] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[3 * 16 + 1] =
+ predictor[1 * 16 + 2] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[0 * 16 + 3] =
+ predictor[2 * 16 + 2] = (pp[3] + pp[4] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[3 * 16 + 2] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 3] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[3 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
}
break;
- case B_HD_PRED:
- {
- unsigned char pp[9];
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
-
- predictor[3 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[3 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[2 * 16 + 0] =
- predictor[3 * 16 + 2] = (pp[1] + pp[2] + 1) >> 1;
- predictor[2 * 16 + 1] =
- predictor[3 * 16 + 3] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 2] =
- predictor[1 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
- predictor[2 * 16 + 3] =
- predictor[1 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[1 * 16 + 2] =
- predictor[0 * 16 + 0] = (pp[3] + pp[4] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[0 * 16 + 1] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[0 * 16 + 2] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ case B_HD_PRED: {
+ unsigned char pp[9];
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+
+ predictor[3 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[3 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[2 * 16 + 0] =
+ predictor[3 * 16 + 2] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[2 * 16 + 1] =
+ predictor[3 * 16 + 3] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[1 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[2 * 16 + 3] =
+ predictor[1 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[1 * 16 + 2] =
+ predictor[0 * 16 + 0] = (pp[3] + pp[4] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[0 * 16 + 1] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[0 * 16 + 2] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
}
break;
- case B_HU_PRED:
- {
- unsigned char *pp = Left;
- predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[0 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[0 * 16 + 2] =
- predictor[1 * 16 + 0] = (pp[1] + pp[2] + 1) >> 1;
- predictor[0 * 16 + 3] =
- predictor[1 * 16 + 1] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[1 * 16 + 2] =
- predictor[2 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[2 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 2] =
- predictor[2 * 16 + 3] =
- predictor[3 * 16 + 0] =
- predictor[3 * 16 + 1] =
- predictor[3 * 16 + 2] =
- predictor[3 * 16 + 3] = pp[3];
+ case B_HU_PRED: {
+ unsigned char *pp = Left;
+ predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[0 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[0 * 16 + 2] =
+ predictor[1 * 16 + 0] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[0 * 16 + 3] =
+ predictor[1 * 16 + 1] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[1 * 16 + 2] =
+ predictor[2 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[2 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[2 * 16 + 3] =
+ predictor[3 * 16 + 0] =
+ predictor[3 * 16 + 1] =
+ predictor[3 * 16 + 2] =
+ predictor[3 * 16 + 3] = pp[3];
}
break;
- }
+ }
}
#if CONFIG_COMP_INTRA_PRED
void vp8_comp_intra4x4_predict(BLOCKD *x,
int b_mode, int b_mode2,
- unsigned char *out_predictor)
-{
- unsigned char predictor[2][4*16];
- int i, j;
-
- vp8_intra4x4_predict(x, b_mode, predictor[0]);
- vp8_intra4x4_predict(x, b_mode2, predictor[1]);
-
- for (i = 0; i < 16*4; i += 16)
- {
- for (j = i; j < i + 4; j++)
- {
- out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
- }
+ unsigned char *out_predictor) {
+ unsigned char predictor[2][4 * 16];
+ int i, j;
+
+ vp8_intra4x4_predict(x, b_mode, predictor[0]);
+ vp8_intra4x4_predict(x, b_mode2, predictor[1]);
+
+ for (i = 0; i < 16 * 4; i += 16) {
+ for (j = i; j < i + 4; j++) {
+ out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
}
+ }
}
#endif
/* copy 4 bytes from the above right down so that the 4x4 prediction modes using pixels above and
* to the right prediction have filled in pixels to use.
*/
-void vp8_intra_prediction_down_copy(MACROBLOCKD *x)
-{
- unsigned char *above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
-
- unsigned int *src_ptr = (unsigned int *)above_right;
- unsigned int *dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
- unsigned int *dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
- unsigned int *dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);
-
- *dst_ptr0 = *src_ptr;
- *dst_ptr1 = *src_ptr;
- *dst_ptr2 = *src_ptr;
+void vp8_intra_prediction_down_copy(MACROBLOCKD *x) {
+ unsigned char *above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
+
+ unsigned int *src_ptr = (unsigned int *)above_right;
+ unsigned int *dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
+ unsigned int *dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
+ unsigned int *dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);
+
+ *dst_ptr0 = *src_ptr;
+ *dst_ptr1 = *src_ptr;
+ *dst_ptr2 = *src_ptr;
}
diff --git a/vp8/common/rotate.h b/vp8/common/rotate.h
index 580f55279..50080c0ac 100644
--- a/vp8/common/rotate.h
+++ b/vp8/common/rotate.h
@@ -1,2827 +1,2827 @@
- // angle of -2.5 degrees
- -1, 0, 14696, -1, 1, 11702, 0, 0, 24063, 0, 1, 15075, // 0, 0
- -1, 1, 13787, -1, 2, 11164, 0, 1, 25366, 0, 2, 15219, // 0, 1
- -1, 2, 12938, -1, 3, 10637, 0, 2, 26660, 0, 3, 15301, // 0, 2
- -1, 3, 12159, -1, 4, 10135, 0, 3, 27912, 0, 4, 15330, // 0, 3
- -1, 4, 11461, -1, 5, 9673, 0, 4, 29078, 0, 5, 15324, // 0, 4
- -1, 5, 10855, -1, 6, 9265, 0, 5, 30105, 0, 6, 15311, // 0, 5
- -1, 6, 10351, -1, 7, 8927, 0, 6, 30939, 0, 7, 15319, // 0, 6
- -1, 7, 9959, -1, 8, 8669, 0, 7, 31532, 0, 8, 15376, // 0, 7
- 0, 8, 31444, 0, 9, 15301, 1, 8, 10065, 1, 9, 8726, // 0, 8
- 0, 9, 30876, 0, 10, 15193, 1, 9, 10482, 1, 10, 8985, // 0, 9
- 0, 10, 30064, 0, 11, 15135, 1, 10, 11013, 1, 11, 9324, // 0,10
- 0, 11, 29055, 0, 12, 15100, 1, 11, 11652, 1, 12, 9729, // 0,11
- 0, 12, 27903, 0, 13, 15060, 1, 12, 12388, 1, 13, 10185, // 0,12
- 0, 13, 26660, 0, 14, 14990, 1, 13, 13211, 1, 14, 10675, // 0,13
- 0, 14, 25368, 0, 15, 14872, 1, 14, 14109, 1, 15, 11187, // 0,14
- 0, 15, 24063, 0, 16, 14696, 1, 15, 15076, 1, 16, 11701, // 0,15
- 0, 0, 14872, 0, 1, 11187, 1, 0, 25368, 1, 1, 14109, // 1, 0
- 0, 1, 13853, 0, 2, 10644, 1, 1, 26893, 1, 2, 14146, // 1, 1
- 0, 2, 12897, 0, 3, 10102, 1, 2, 28430, 1, 3, 14107, // 1, 2
- 0, 3, 12014, 0, 4, 9575, 1, 3, 29938, 1, 4, 14009, // 1, 3
- 0, 4, 11218, 0, 5, 9082, 1, 4, 31361, 1, 5, 13875, // 1, 4
- 0, 5, 10528, 0, 6, 8645, 1, 5, 32624, 1, 6, 13739, // 1, 5
- 0, 6, 9961, 0, 7, 8286, 1, 6, 33642, 1, 7, 13647, // 1, 6
- 0, 7, 9534, 0, 8, 8024, 1, 7, 34340, 1, 8, 13638, // 1, 7
- 1, 8, 34261, 1, 9, 13582, 2, 8, 9626, 2, 9, 8067, // 1, 8
- 1, 9, 33585, 1, 10, 13548, 2, 9, 10074, 2, 10, 8329, // 1, 9
- 1, 10, 32586, 1, 11, 13600, 2, 10, 10665, 2, 11, 8685, // 1,10
- 1, 11, 31339, 1, 12, 13694, 2, 11, 11385, 2, 12, 9118, // 1,11
- 1, 12, 29928, 1, 13, 13789, 2, 12, 12216, 2, 13, 9603, // 1,12
- 1, 13, 28427, 1, 14, 13850, 2, 13, 13141, 2, 14, 10118, // 1,13
- 1, 14, 26893, 1, 15, 13853, 2, 14, 14145, 2, 15, 10645, // 1,14
- 1, 15, 25366, 1, 16, 13787, 2, 15, 15220, 2, 16, 11163, // 1,15
- 1, 0, 14990, 1, 1, 10676, 2, 0, 26660, 2, 1, 13210, // 2, 0
- 1, 1, 13850, 1, 2, 10119, 2, 1, 28427, 2, 2, 13140, // 2, 1
- 1, 2, 12769, 1, 3, 9546, 2, 2, 30239, 2, 3, 12982, // 2, 2
- 1, 3, 11760, 1, 4, 8976, 2, 3, 32052, 2, 4, 12748, // 2, 3
- 1, 4, 10842, 1, 5, 8432, 2, 4, 33795, 2, 5, 12467, // 2, 4
- 1, 5, 10041, 1, 6, 7943, 2, 5, 35364, 2, 6, 12188, // 2, 5
- 1, 6, 9390, 1, 7, 7543, 2, 6, 36631, 2, 7, 11972, // 2, 6
- 1, 7, 8918, 1, 8, 7266, 2, 7, 37470, 2, 8, 11882, // 2, 7
- 2, 8, 37402, 2, 9, 11842, 3, 8, 8994, 3, 9, 7298, // 2, 8
- 2, 9, 36582, 2, 10, 11897, 3, 9, 9484, 3, 10, 7573, // 2, 9
- 2, 10, 35332, 2, 11, 12079, 3, 10, 10156, 3, 11, 7969, // 2,10
- 2, 11, 33777, 2, 12, 12323, 3, 11, 10983, 3, 12, 8453, // 2,11
- 2, 12, 32045, 2, 13, 12569, 3, 12, 11934, 3, 13, 8988, // 2,12
- 2, 13, 30239, 2, 14, 12769, 3, 13, 12982, 3, 14, 9546, // 2,13
- 2, 14, 28430, 2, 15, 12897, 3, 14, 14107, 3, 15, 10102, // 2,14
- 2, 15, 26660, 2, 16, 12938, 3, 15, 15301, 3, 16, 10637, // 2,15
- 2, 0, 15060, 2, 1, 10185, 3, 0, 27903, 3, 1, 12388, // 3, 0
- 2, 1, 13789, 2, 2, 9603, 3, 1, 29928, 3, 2, 12216, // 3, 1
- 2, 2, 12569, 2, 3, 8988, 3, 2, 32045, 3, 3, 11934, // 3, 2
- 2, 3, 11411, 2, 4, 8358, 3, 3, 34213, 3, 4, 11554, // 3, 3
- 2, 4, 10337, 2, 5, 7737, 3, 4, 36354, 3, 5, 11108, // 3, 4
- 2, 5, 9388, 2, 6, 7165, 3, 5, 38330, 3, 6, 10653, // 3, 5
- 2, 6, 8617, 2, 7, 6695, 3, 6, 39949, 3, 7, 10275, // 3, 6
- 2, 7, 8082, 2, 8, 6381, 3, 7, 40994, 3, 8, 10079, // 3, 7
- 3, 8, 40940, 3, 9, 10051, 4, 8, 8141, 4, 9, 6404, // 3, 8
- 3, 9, 39912, 3, 10, 10221, 4, 9, 8690, 4, 10, 6713, // 3, 9
- 3, 10, 38307, 3, 11, 10569, 4, 10, 9479, 4, 11, 7181, // 3,10
- 3, 11, 36343, 3, 12, 10995, 4, 11, 10452, 4, 12, 7746, // 3,11
- 3, 12, 34213, 3, 13, 11411, 4, 12, 11554, 4, 13, 8358, // 3,12
- 3, 13, 32052, 3, 14, 11760, 4, 13, 12747, 4, 14, 8977, // 3,13
- 3, 14, 29938, 3, 15, 12014, 4, 14, 14009, 4, 15, 9575, // 3,14
- 3, 15, 27912, 3, 16, 12159, 4, 15, 15330, 4, 16, 10135, // 3,15
- 3, 0, 15100, 3, 1, 9728, 4, 0, 29055, 4, 1, 11653, // 4, 0
- 3, 1, 13694, 3, 2, 9118, 4, 1, 31339, 4, 2, 11385, // 4, 1
- 3, 2, 12323, 3, 3, 8452, 4, 2, 33777, 4, 3, 10984, // 4, 2
- 3, 3, 10995, 3, 4, 7746, 4, 3, 36343, 4, 4, 10452, // 4, 3
- 3, 4, 9730, 3, 5, 7022, 4, 4, 38966, 4, 5, 9818, // 4, 4
- 3, 5, 8578, 3, 6, 6328, 4, 5, 41487, 4, 6, 9143, // 4, 5
- 3, 6, 7626, 3, 7, 5739, 4, 6, 43626, 4, 7, 8545, // 4, 6
- 3, 7, 6987, 3, 8, 5354, 4, 7, 44999, 4, 8, 8196, // 4, 7
- 4, 8, 44962, 4, 9, 8177, 5, 8, 7029, 5, 9, 5368, // 4, 8
- 4, 9, 43602, 4, 10, 8507, 5, 9, 7678, 5, 10, 5749, // 4, 9
- 4, 10, 41475, 4, 11, 9081, 5, 10, 8646, 5, 11, 6334, // 4,10
- 4, 11, 38966, 4, 12, 9730, 5, 11, 9818, 5, 12, 7022, // 4,11
- 4, 12, 36354, 4, 13, 10337, 5, 12, 11108, 5, 13, 7737, // 4,12
- 4, 13, 33795, 4, 14, 10842, 5, 13, 12467, 5, 14, 8432, // 4,13
- 4, 14, 31361, 4, 15, 11218, 5, 14, 13875, 5, 15, 9082, // 4,14
- 4, 15, 29078, 4, 16, 11461, 5, 15, 15325, 5, 16, 9672, // 4,15
- 4, 0, 15135, 4, 1, 9323, 5, 0, 30064, 5, 1, 11014, // 5, 0
- 4, 1, 13600, 4, 2, 8685, 5, 1, 32586, 5, 2, 10665, // 5, 1
- 4, 2, 12079, 4, 3, 7969, 5, 2, 35332, 5, 3, 10156, // 5, 2
- 4, 3, 10569, 4, 4, 7180, 5, 3, 38307, 5, 4, 9480, // 5, 3
- 4, 4, 9081, 4, 5, 6334, 5, 4, 41475, 5, 5, 8646, // 5, 4
- 4, 5, 7659, 4, 6, 5472, 5, 5, 44700, 5, 6, 7705, // 5, 5
- 4, 6, 6422, 4, 7, 4690, 5, 6, 47630, 5, 7, 6794, // 5, 6
- 4, 7, 5590, 4, 8, 4164, 5, 7, 49588, 5, 8, 6194, // 5, 7
- 5, 8, 49566, 5, 9, 6183, 6, 8, 5615, 6, 9, 4172, // 5, 8
- 5, 9, 47619, 5, 10, 6768, 6, 9, 6455, 6, 10, 4694, // 5, 9
- 5, 10, 44700, 5, 11, 7659, 6, 10, 7705, 6, 11, 5472, // 5,10
- 5, 11, 41487, 5, 12, 8578, 6, 11, 9143, 6, 12, 6328, // 5,11
- 5, 12, 38330, 5, 13, 9388, 6, 12, 10653, 6, 13, 7165, // 5,12
- 5, 13, 35364, 5, 14, 10041, 6, 13, 12188, 6, 14, 7943, // 5,13
- 5, 14, 32624, 5, 15, 10528, 6, 14, 13740, 6, 15, 8644, // 5,14
- 5, 15, 30105, 5, 16, 10855, 6, 15, 15311, 6, 16, 9265, // 5,15
- 5, 0, 15193, 5, 1, 8986, 6, 0, 30876, 6, 1, 10481, // 6, 0
- 5, 1, 13548, 5, 2, 8329, 6, 1, 33585, 6, 2, 10074, // 6, 1
- 5, 2, 11897, 5, 3, 7573, 6, 2, 36582, 6, 3, 9484, // 6, 2
- 5, 3, 10221, 5, 4, 6714, 6, 3, 39912, 6, 4, 8689, // 6, 3
- 5, 4, 8507, 5, 5, 5749, 6, 4, 43602, 6, 5, 7678, // 6, 4
- 5, 5, 6768, 5, 6, 4694, 6, 5, 47619, 6, 6, 6455, // 6, 5
- 5, 6, 5099, 5, 7, 3620, 6, 6, 51701, 6, 7, 5116, // 6, 6
- 5, 7, 3853, 5, 8, 2795, 6, 7, 54839, 6, 8, 4049, // 6, 7
- 6, 8, 54831, 6, 9, 4044, 7, 8, 3864, 7, 9, 2797, // 6, 8
- 6, 9, 51701, 6, 10, 5099, 7, 9, 5116, 7, 10, 3620, // 6, 9
- 6, 10, 47630, 6, 11, 6422, 7, 10, 6794, 7, 11, 4690, // 6,10
- 6, 11, 43626, 6, 12, 7626, 7, 11, 8545, 7, 12, 5739, // 6,11
- 6, 12, 39949, 6, 13, 8617, 7, 12, 10275, 7, 13, 6695, // 6,12
- 6, 13, 36631, 6, 14, 9390, 7, 13, 11972, 7, 14, 7543, // 6,13
- 6, 14, 33642, 6, 15, 9961, 7, 14, 13647, 7, 15, 8286, // 6,14
- 6, 15, 30939, 6, 16, 10351, 7, 15, 15319, 7, 16, 8927, // 6,15
- 6, 0, 15301, 6, 1, 8727, 7, 0, 31444, 7, 1, 10064, // 7, 0
- 6, 1, 13582, 6, 2, 8068, 7, 1, 34261, 7, 2, 9625, // 7, 1
- 6, 2, 11842, 6, 3, 7298, 7, 2, 37402, 7, 3, 8994, // 7, 2
- 6, 3, 10051, 6, 4, 6403, 7, 3, 40940, 7, 4, 8142, // 7, 3
- 6, 4, 8177, 6, 5, 5368, 7, 4, 44962, 7, 5, 7029, // 7, 4
- 6, 5, 6183, 6, 6, 4172, 7, 5, 49566, 7, 6, 5615, // 7, 5
- 6, 6, 4044, 6, 7, 2797, 7, 6, 54831, 7, 7, 3864, // 7, 6
- 6, 7, 1903, 6, 8, 1347, 7, 7, 60382, 7, 8, 1904, // 7, 7
- 7, 8, 60382, 7, 9, 1903, 8, 8, 1905, 8, 9, 1346, // 7, 8
- 7, 9, 54839, 7, 10, 3853, 8, 9, 4049, 8, 10, 2795, // 7, 9
- 7, 10, 49588, 7, 11, 5590, 8, 10, 6193, 8, 11, 4165, // 7,10
- 7, 11, 44999, 7, 12, 6987, 8, 11, 8195, 8, 12, 5355, // 7,11
- 7, 12, 40994, 7, 13, 8082, 8, 12, 10079, 8, 13, 6381, // 7,12
- 7, 13, 37470, 7, 14, 8918, 8, 13, 11883, 8, 14, 7265, // 7,13
- 7, 14, 34340, 7, 15, 9534, 8, 14, 13638, 8, 15, 8024, // 7,14
- 7, 15, 31532, 7, 16, 9959, 8, 15, 15376, 8, 16, 8669, // 7,15
- 7, -1, 8669, 7, 0, 15376, 8, -1, 9959, 8, 0, 31532, // 8, 0
- 7, 0, 8024, 7, 1, 13638, 8, 0, 9534, 8, 1, 34340, // 8, 1
- 7, 1, 7266, 7, 2, 11883, 8, 1, 8918, 8, 2, 37469, // 8, 2
- 7, 2, 6381, 7, 3, 10079, 8, 2, 8082, 8, 3, 40994, // 8, 3
- 7, 3, 5354, 7, 4, 8195, 8, 3, 6987, 8, 4, 45000, // 8, 4
- 7, 4, 4164, 7, 5, 6193, 8, 4, 5590, 8, 5, 49589, // 8, 5
- 7, 5, 2795, 7, 6, 4049, 8, 5, 3853, 8, 6, 54839, // 8, 6
- 7, 6, 1347, 7, 7, 1905, 8, 6, 1903, 8, 7, 60381, // 8, 7
- 8, 7, 1905, 8, 8, 60382, 9, 7, 1347, 9, 8, 1902, // 8, 8
- 8, 8, 3864, 8, 9, 54831, 9, 8, 2797, 9, 9, 4044, // 8, 9
- 8, 9, 5615, 8, 10, 49566, 9, 9, 4172, 9, 10, 6183, // 8,10
- 8, 10, 7029, 8, 11, 44962, 9, 10, 5368, 9, 11, 8177, // 8,11
- 8, 11, 8141, 8, 12, 40940, 9, 11, 6403, 9, 12, 10052, // 8,12
- 8, 12, 8994, 8, 13, 37402, 9, 12, 7298, 9, 13, 11842, // 8,13
- 8, 13, 9626, 8, 14, 34261, 9, 13, 8068, 9, 14, 13581, // 8,14
- 8, 14, 10065, 8, 15, 31444, 9, 14, 8727, 9, 15, 15300, // 8,15
- 8, -1, 8927, 8, 0, 15319, 9, -1, 10351, 9, 0, 30939, // 9, 0
- 8, 0, 8286, 8, 1, 13647, 9, 0, 9961, 9, 1, 33642, // 9, 1
- 8, 1, 7543, 8, 2, 11972, 9, 1, 9390, 9, 2, 36631, // 9, 2
- 8, 2, 6695, 8, 3, 10275, 9, 2, 8617, 9, 3, 39949, // 9, 3
- 8, 3, 5739, 8, 4, 8545, 9, 3, 7626, 9, 4, 43626, // 9, 4
- 8, 4, 4690, 8, 5, 6794, 9, 4, 6422, 9, 5, 47630, // 9, 5
- 8, 5, 3620, 8, 6, 5116, 9, 5, 5099, 9, 6, 51701, // 9, 6
- 8, 6, 2797, 8, 7, 3864, 9, 6, 4044, 9, 7, 54831, // 9, 7
- 9, 7, 4049, 9, 8, 54839, 10, 7, 2795, 10, 8, 3853, // 9, 8
- 9, 8, 5116, 9, 9, 51701, 10, 8, 3620, 10, 9, 5099, // 9, 9
- 9, 9, 6455, 9, 10, 47619, 10, 9, 4694, 10, 10, 6768, // 9,10
- 9, 10, 7678, 9, 11, 43602, 10, 10, 5749, 10, 11, 8507, // 9,11
- 9, 11, 8690, 9, 12, 39912, 10, 11, 6714, 10, 12, 10220, // 9,12
- 9, 12, 9484, 9, 13, 36582, 10, 12, 7573, 10, 13, 11897, // 9,13
- 9, 13, 10074, 9, 14, 33585, 10, 13, 8329, 10, 14, 13548, // 9,14
- 9, 14, 10482, 9, 15, 30876, 10, 14, 8986, 10, 15, 15192, // 9,15
- 9, -1, 9265, 9, 0, 15311, 10, -1, 10855, 10, 0, 30105, // 10, 0
- 9, 0, 8645, 9, 1, 13740, 10, 0, 10528, 10, 1, 32623, // 10, 1
- 9, 1, 7943, 9, 2, 12188, 10, 1, 10041, 10, 2, 35364, // 10, 2
- 9, 2, 7165, 9, 3, 10653, 10, 2, 9388, 10, 3, 38330, // 10, 3
- 9, 3, 6328, 9, 4, 9143, 10, 3, 8578, 10, 4, 41487, // 10, 4
- 9, 4, 5472, 9, 5, 7705, 10, 4, 7659, 10, 5, 44700, // 10, 5
- 9, 5, 4694, 9, 6, 6455, 10, 5, 6768, 10, 6, 47619, // 10, 6
- 9, 6, 4172, 9, 7, 5615, 10, 6, 6183, 10, 7, 49566, // 10, 7
- 10, 7, 6193, 10, 8, 49588, 11, 7, 4164, 11, 8, 5591, // 10, 8
- 10, 8, 6794, 10, 9, 47630, 11, 8, 4690, 11, 9, 6422, // 10, 9
- 10, 9, 7705, 10, 10, 44700, 11, 9, 5472, 11, 10, 7659, // 10,10
- 10, 10, 8646, 10, 11, 41475, 11, 10, 6334, 11, 11, 9081, // 10,11
- 10, 11, 9479, 10, 12, 38307, 11, 11, 7180, 11, 12, 10570, // 10,12
- 10, 12, 10156, 10, 13, 35332, 11, 12, 7969, 11, 13, 12079, // 10,13
- 10, 13, 10665, 10, 14, 32586, 11, 13, 8685, 11, 14, 13600, // 10,14
- 10, 14, 11013, 10, 15, 30064, 11, 14, 9323, 11, 15, 15136, // 10,15
- 10, -1, 9673, 10, 0, 15325, 11, -1, 11461, 11, 0, 29077, // 11, 0
- 10, 0, 9082, 10, 1, 13875, 11, 0, 11218, 11, 1, 31361, // 11, 1
- 10, 1, 8432, 10, 2, 12467, 11, 1, 10842, 11, 2, 33795, // 11, 2
- 10, 2, 7737, 10, 3, 11108, 11, 2, 10337, 11, 3, 36354, // 11, 3
- 10, 3, 7022, 10, 4, 9818, 11, 3, 9730, 11, 4, 38966, // 11, 4
- 10, 4, 6334, 10, 5, 8646, 11, 4, 9081, 11, 5, 41475, // 11, 5
- 10, 5, 5749, 10, 6, 7678, 11, 5, 8507, 11, 6, 43602, // 11, 6
- 10, 6, 5368, 10, 7, 7029, 11, 6, 8177, 11, 7, 44962, // 11, 7
- 11, 7, 8195, 11, 8, 44999, 12, 7, 5354, 12, 8, 6988, // 11, 8
- 11, 8, 8545, 11, 9, 43626, 12, 8, 5739, 12, 9, 7626, // 11, 9
- 11, 9, 9143, 11, 10, 41487, 12, 9, 6328, 12, 10, 8578, // 11,10
- 11, 10, 9818, 11, 11, 38966, 12, 10, 7022, 12, 11, 9730, // 11,11
- 11, 11, 10452, 11, 12, 36343, 12, 11, 7746, 12, 12, 10995, // 11,12
- 11, 12, 10983, 11, 13, 33777, 12, 12, 8452, 12, 13, 12324, // 11,13
- 11, 13, 11385, 11, 14, 31339, 12, 13, 9118, 12, 14, 13694, // 11,14
- 11, 14, 11652, 11, 15, 29055, 12, 14, 9728, 12, 15, 15101, // 11,15
- 11, -1, 10135, 11, 0, 15330, 12, -1, 12159, 12, 0, 27912, // 12, 0
- 11, 0, 9575, 11, 1, 14009, 12, 0, 12014, 12, 1, 29938, // 12, 1
- 11, 1, 8976, 11, 2, 12747, 12, 1, 11760, 12, 2, 32053, // 12, 2
- 11, 2, 8358, 11, 3, 11554, 12, 2, 11411, 12, 3, 34213, // 12, 3
- 11, 3, 7746, 11, 4, 10452, 12, 3, 10995, 12, 4, 36343, // 12, 4
- 11, 4, 7180, 11, 5, 9479, 12, 4, 10569, 12, 5, 38308, // 12, 5
- 11, 5, 6714, 11, 6, 8690, 12, 5, 10221, 12, 6, 39911, // 12, 6
- 11, 6, 6403, 11, 7, 8141, 12, 6, 10051, 12, 7, 40941, // 12, 7
- 12, 7, 10079, 12, 8, 40994, 13, 7, 6381, 13, 8, 8082, // 12, 8
- 12, 8, 10275, 12, 9, 39949, 13, 8, 6695, 13, 9, 8617, // 12, 9
- 12, 9, 10653, 12, 10, 38330, 13, 9, 7165, 13, 10, 9388, // 12,10
- 12, 10, 11108, 12, 11, 36354, 13, 10, 7737, 13, 11, 10337, // 12,11
- 12, 11, 11554, 12, 12, 34213, 13, 11, 8358, 13, 12, 11411, // 12,12
- 12, 12, 11934, 12, 13, 32045, 13, 12, 8988, 13, 13, 12569, // 12,13
- 12, 13, 12216, 12, 14, 29928, 13, 13, 9603, 13, 14, 13789, // 12,14
- 12, 14, 12388, 12, 15, 27903, 13, 14, 10185, 13, 15, 15060, // 12,15
- 12, -1, 10637, 12, 0, 15301, 13, -1, 12938, 13, 0, 26660, // 13, 0
- 12, 0, 10102, 12, 1, 14107, 13, 0, 12897, 13, 1, 28430, // 13, 1
- 12, 1, 9546, 12, 2, 12982, 13, 1, 12769, 13, 2, 30239, // 13, 2
- 12, 2, 8988, 12, 3, 11934, 13, 2, 12569, 13, 3, 32045, // 13, 3
- 12, 3, 8452, 12, 4, 10983, 13, 3, 12323, 13, 4, 33778, // 13, 4
- 12, 4, 7969, 12, 5, 10156, 13, 4, 12079, 13, 5, 35332, // 13, 5
- 12, 5, 7573, 12, 6, 9484, 13, 5, 11897, 13, 6, 36582, // 13, 6
- 12, 6, 7298, 12, 7, 8994, 13, 6, 11842, 13, 7, 37402, // 13, 7
- 13, 7, 11883, 13, 8, 37470, 14, 7, 7266, 14, 8, 8917, // 13, 8
- 13, 8, 11972, 13, 9, 36631, 14, 8, 7543, 14, 9, 9390, // 13, 9
- 13, 9, 12188, 13, 10, 35364, 14, 9, 7943, 14, 10, 10041, // 13,10
- 13, 10, 12467, 13, 11, 33795, 14, 10, 8432, 14, 11, 10842, // 13,11
- 13, 11, 12747, 13, 12, 32052, 14, 11, 8976, 14, 12, 11761, // 13,12
- 13, 12, 12982, 13, 13, 30239, 14, 12, 9546, 14, 13, 12769, // 13,13
- 13, 13, 13141, 13, 14, 28427, 14, 13, 10119, 14, 14, 13849, // 13,14
- 13, 14, 13211, 13, 15, 26660, 14, 14, 10676, 14, 15, 14989, // 13,15
- 13, -1, 11164, 13, 0, 15220, 14, -1, 13787, 14, 0, 25365, // 14, 0
- 13, 0, 10644, 13, 1, 14145, 14, 0, 13853, 14, 1, 26894, // 14, 1
- 13, 1, 10119, 13, 2, 13141, 14, 1, 13850, 14, 2, 28426, // 14, 2
- 13, 2, 9603, 13, 3, 12216, 14, 2, 13789, 14, 3, 29928, // 14, 3
- 13, 3, 9118, 13, 4, 11385, 14, 3, 13694, 14, 4, 31339, // 14, 4
- 13, 4, 8685, 13, 5, 10665, 14, 4, 13600, 14, 5, 32586, // 14, 5
- 13, 5, 8329, 13, 6, 10074, 14, 5, 13548, 14, 6, 33585, // 14, 6
- 13, 6, 8068, 13, 7, 9626, 14, 6, 13582, 14, 7, 34260, // 14, 7
- 14, 7, 13638, 14, 8, 34340, 15, 7, 8024, 15, 8, 9534, // 14, 8
- 14, 8, 13647, 14, 9, 33642, 15, 8, 8286, 15, 9, 9961, // 14, 9
- 14, 9, 13740, 14, 10, 32624, 15, 9, 8645, 15, 10, 10527, // 14,10
- 14, 10, 13875, 14, 11, 31361, 15, 10, 9082, 15, 11, 11218, // 14,11
- 14, 11, 14009, 14, 12, 29938, 15, 11, 9575, 15, 12, 12014, // 14,12
- 14, 12, 14107, 14, 13, 28430, 15, 12, 10102, 15, 13, 12897, // 14,13
- 14, 13, 14145, 14, 14, 26893, 15, 13, 10644, 15, 14, 13854, // 14,14
- 14, 14, 14109, 14, 15, 25368, 15, 14, 11187, 15, 15, 14872, // 14,15
- 14, -1, 11702, 14, 0, 15076, 15, -1, 14696, 15, 0, 24062, // 15, 0
- 14, 0, 11187, 14, 1, 14109, 15, 0, 14872, 15, 1, 25368, // 15, 1
- 14, 1, 10676, 14, 2, 13211, 15, 1, 14990, 15, 2, 26659, // 15, 2
- 14, 2, 10185, 14, 3, 12388, 15, 2, 15060, 15, 3, 27903, // 15, 3
- 14, 3, 9728, 14, 4, 11652, 15, 3, 15100, 15, 4, 29056, // 15, 4
- 14, 4, 9323, 14, 5, 11013, 15, 4, 15135, 15, 5, 30065, // 15, 5
- 14, 5, 8986, 14, 6, 10482, 15, 5, 15193, 15, 6, 30875, // 15, 6
- 14, 6, 8727, 14, 7, 10065, 15, 6, 15301, 15, 7, 31443, // 15, 7
- 15, 7, 15376, 15, 8, 31532, 16, 7, 8669, 16, 8, 9959, // 15, 8
- 15, 8, 15319, 15, 9, 30939, 16, 8, 8927, 16, 9, 10351, // 15, 9
- 15, 9, 15311, 15, 10, 30105, 16, 9, 9265, 16, 10, 10855, // 15,10
- 15, 10, 15325, 15, 11, 29078, 16, 10, 9673, 16, 11, 11460, // 15,11
- 15, 11, 15330, 15, 12, 27912, 16, 11, 10135, 16, 12, 12159, // 15,12
- 15, 12, 15301, 15, 13, 26660, 16, 12, 10637, 16, 13, 12938, // 15,13
- 15, 13, 15220, 15, 14, 25366, 16, 13, 11164, 16, 14, 13786, // 15,14
- 15, 14, 15076, 15, 15, 24063, 16, 14, 11702, 16, 15, 14695, // 15,15
- // angle of -2.0 degrees
- -1, 0, 13368, -1, 1, 10104, 0, 0, 28495, 0, 1, 13569, // 0, 0
- -1, 1, 12574, -1, 2, 9662, 0, 1, 29831, 0, 2, 13469, // 0, 1
- -1, 2, 11829, -1, 3, 9229, 0, 2, 31146, 0, 3, 13332, // 0, 2
- -1, 3, 11143, -1, 4, 8816, 0, 3, 32406, 0, 4, 13171, // 0, 3
- -1, 4, 10528, -1, 5, 8438, 0, 4, 33564, 0, 5, 13006, // 0, 4
- -1, 5, 9995, -1, 6, 8107, 0, 5, 34567, 0, 6, 12867, // 0, 5
- -1, 6, 9558, -1, 7, 7839, 0, 6, 35362, 0, 7, 12777, // 0, 6
- -1, 7, 9224, -1, 8, 7643, 0, 7, 35905, 0, 8, 12764, // 0, 7
- 0, 8, 35844, 0, 9, 12728, 1, 8, 9290, 1, 9, 7674, // 0, 8
- 0, 9, 35315, 0, 10, 12717, 1, 9, 9635, 1, 10, 7869, // 0, 9
- 0, 10, 34532, 0, 11, 12783, 1, 10, 10086, 1, 11, 8135, // 0,10
- 0, 11, 33539, 0, 12, 12899, 1, 11, 10635, 1, 12, 8463, // 0,11
- 0, 12, 32391, 0, 13, 13038, 1, 12, 11269, 1, 13, 8838, // 0,12
- 0, 13, 31138, 0, 14, 13176, 1, 13, 11977, 1, 14, 9245, // 0,13
- 0, 14, 29828, 0, 15, 13291, 1, 14, 12746, 1, 15, 9671, // 0,14
- 0, 15, 28495, 0, 16, 13368, 1, 15, 13569, 1, 16, 10104, // 0,15
- 0, 0, 13291, 0, 1, 9671, 1, 0, 29828, 1, 1, 12746, // 1, 0
- 0, 1, 12412, 0, 2, 9202, 1, 1, 31358, 1, 2, 12564, // 1, 1
- 0, 2, 11580, 0, 3, 8735, 1, 2, 32886, 1, 3, 12335, // 1, 2
- 0, 3, 10808, 0, 4, 8284, 1, 3, 34369, 1, 4, 12075, // 1, 3
- 0, 4, 10111, 0, 5, 7865, 1, 4, 35750, 1, 5, 11810, // 1, 4
- 0, 5, 9509, 0, 6, 7497, 1, 5, 36955, 1, 6, 11575, // 1, 5
- 0, 6, 9020, 0, 7, 7202, 1, 6, 37906, 1, 7, 11408, // 1, 6
- 0, 7, 8662, 0, 8, 6997, 1, 7, 38534, 1, 8, 11343, // 1, 7
- 1, 8, 38481, 1, 9, 11317, 2, 8, 8718, 2, 9, 7020, // 1, 8
- 1, 9, 37866, 1, 10, 11360, 2, 9, 9086, 2, 10, 7224, // 1, 9
- 1, 10, 36926, 1, 11, 11507, 2, 10, 9587, 2, 11, 7516, // 1,10
- 1, 11, 35730, 1, 12, 11721, 2, 11, 10204, 2, 12, 7881, // 1,11
- 1, 12, 34358, 1, 13, 11964, 2, 12, 10918, 2, 13, 8296, // 1,12
- 1, 13, 32881, 1, 14, 12203, 2, 13, 11709, 2, 14, 8743, // 1,13
- 1, 14, 31358, 1, 15, 12412, 2, 14, 12564, 2, 15, 9202, // 1,14
- 1, 15, 29831, 1, 16, 12574, 2, 15, 13470, 2, 16, 9661, // 1,15
- 1, 0, 13176, 1, 1, 9245, 2, 0, 31138, 2, 1, 11977, // 2, 0
- 1, 1, 12203, 1, 2, 8742, 2, 1, 32881, 2, 2, 11710, // 2, 1
- 1, 2, 11272, 1, 3, 8232, 2, 2, 34650, 2, 3, 11382, // 2, 2
- 1, 3, 10397, 1, 4, 7728, 2, 3, 36399, 2, 4, 11012, // 2, 3
- 1, 4, 9597, 1, 5, 7252, 2, 4, 38057, 2, 5, 10630, // 2, 4
- 1, 5, 8902, 1, 6, 6829, 2, 5, 39526, 2, 6, 10279, // 2, 5
- 1, 6, 8344, 1, 7, 6491, 2, 6, 40688, 2, 7, 10013, // 2, 6
- 1, 7, 7951, 1, 8, 6266, 2, 7, 41432, 2, 8, 9887, // 2, 7
- 2, 8, 41389, 2, 9, 9867, 3, 8, 7996, 3, 9, 6284, // 2, 8
- 2, 9, 40656, 2, 10, 9977, 3, 9, 8397, 3, 10, 6506, // 2, 9
- 2, 10, 39503, 2, 11, 10226, 3, 10, 8966, 3, 11, 6841, // 2,10
- 2, 11, 38042, 2, 12, 10559, 3, 11, 9674, 3, 12, 7261, // 2,11
- 2, 12, 36392, 2, 13, 10922, 3, 12, 10488, 3, 13, 7734, // 2,12
- 2, 13, 34650, 2, 14, 11272, 3, 13, 11382, 3, 14, 8232, // 2,13
- 2, 14, 32886, 2, 15, 11580, 3, 14, 12334, 3, 15, 8736, // 2,14
- 2, 15, 31146, 2, 16, 11829, 3, 15, 13332, 3, 16, 9229, // 2,15
- 2, 0, 13038, 2, 1, 8838, 3, 0, 32391, 3, 1, 11269, // 3, 0
- 2, 1, 11964, 2, 2, 8296, 3, 1, 34358, 3, 2, 10918, // 3, 1
- 2, 2, 10922, 2, 3, 7734, 3, 2, 36392, 3, 3, 10488, // 3, 2
- 2, 3, 9924, 2, 4, 7164, 3, 3, 38450, 3, 4, 9998, // 3, 3
- 2, 4, 8995, 2, 5, 6611, 3, 4, 40452, 3, 5, 9478, // 3, 4
- 2, 5, 8175, 2, 6, 6108, 3, 5, 42271, 3, 6, 8982, // 3, 5
- 2, 6, 7516, 2, 7, 5703, 3, 6, 43733, 3, 7, 8584, // 3, 6
- 2, 7, 7072, 2, 8, 5443, 3, 7, 44649, 3, 8, 8372, // 3, 7
- 3, 8, 44616, 3, 9, 8359, 4, 8, 7106, 4, 9, 5455, // 3, 8
- 3, 9, 43710, 3, 10, 8558, 4, 9, 7556, 4, 10, 5712, // 3, 9
- 3, 10, 42256, 3, 11, 8940, 4, 10, 8224, 4, 11, 6116, // 3,10
- 3, 11, 40444, 3, 12, 9421, 4, 11, 9056, 4, 12, 6615, // 3,11
- 3, 12, 38450, 3, 13, 9924, 4, 12, 9998, 4, 13, 7164, // 3,12
- 3, 13, 36399, 3, 14, 10397, 4, 13, 11012, 4, 14, 7728, // 3,13
- 3, 14, 34369, 3, 15, 10808, 4, 14, 12074, 4, 15, 8285, // 3,14
- 3, 15, 32406, 3, 16, 11143, 4, 15, 13171, 4, 16, 8816, // 3,15
- 3, 0, 12899, 3, 1, 8463, 4, 0, 33539, 4, 1, 10635, // 4, 0
- 3, 1, 11721, 3, 2, 7881, 4, 1, 35730, 4, 2, 10204, // 4, 1
- 3, 2, 10559, 3, 3, 7261, 4, 2, 38042, 4, 3, 9674, // 4, 2
- 3, 3, 9421, 3, 4, 6615, 4, 3, 40444, 4, 4, 9056, // 4, 3
- 3, 4, 8332, 3, 5, 5965, 4, 4, 42861, 4, 5, 8378, // 4, 4
- 3, 5, 7342, 3, 6, 5350, 4, 5, 45146, 4, 6, 7698, // 4, 5
- 3, 6, 6530, 3, 7, 4838, 4, 6, 47049, 4, 7, 7119, // 4, 6
- 3, 7, 6000, 3, 8, 4513, 4, 7, 48240, 4, 8, 6783, // 4, 7
- 4, 8, 48218, 4, 9, 6774, 5, 8, 6023, 5, 9, 4521, // 4, 8
- 4, 9, 47035, 4, 10, 7100, 5, 9, 6558, 5, 10, 4843, // 4, 9
- 4, 10, 45139, 4, 11, 7667, 5, 10, 7377, 5, 11, 5353, // 4,10
- 4, 11, 42861, 4, 12, 8332, 5, 11, 8378, 5, 12, 5965, // 4,11
- 4, 12, 40452, 4, 13, 8995, 5, 12, 9478, 5, 13, 6611, // 4,12
- 4, 13, 38057, 4, 14, 9597, 5, 13, 10630, 5, 14, 7252, // 4,13
- 4, 14, 35750, 4, 15, 10111, 5, 14, 11810, 5, 15, 7865, // 4,14
- 4, 15, 33564, 4, 16, 10528, 5, 15, 13007, 5, 16, 8437, // 4,15
- 4, 0, 12783, 4, 1, 8135, 5, 0, 34532, 5, 1, 10086, // 5, 0
- 4, 1, 11507, 4, 2, 7517, 5, 1, 36926, 5, 2, 9586, // 5, 1
- 4, 2, 10226, 4, 3, 6842, 5, 2, 39503, 5, 3, 8965, // 5, 2
- 4, 3, 8940, 4, 4, 6116, 5, 3, 42256, 5, 4, 8224, // 5, 3
- 4, 4, 7667, 4, 5, 5353, 5, 4, 45139, 5, 5, 7377, // 5, 4
- 4, 5, 6451, 4, 6, 4591, 5, 5, 48019, 5, 6, 6475, // 5, 5
- 4, 6, 5400, 4, 7, 3911, 5, 6, 50587, 5, 7, 5638, // 5, 6
- 4, 7, 4708, 4, 8, 3466, 5, 7, 52266, 5, 8, 5096, // 5, 7
- 5, 8, 52253, 5, 9, 5092, 6, 8, 4721, 6, 9, 3470, // 5, 8
- 5, 9, 50581, 5, 10, 5624, 6, 9, 5418, 6, 10, 3913, // 5, 9
- 5, 10, 48019, 5, 11, 6451, 6, 10, 6475, 6, 11, 4591, // 5,10
- 5, 11, 45146, 5, 12, 7342, 6, 11, 7698, 6, 12, 5350, // 5,11
- 5, 12, 42271, 5, 13, 8175, 6, 12, 8982, 6, 13, 6108, // 5,12
- 5, 13, 39526, 5, 14, 8902, 6, 13, 10279, 6, 14, 6829, // 5,13
- 5, 14, 36955, 5, 15, 9509, 6, 14, 11575, 6, 15, 7497, // 5,14
- 5, 15, 34567, 5, 16, 9995, 6, 15, 12867, 6, 16, 8107, // 5,15
- 5, 0, 12717, 5, 1, 7868, 6, 0, 35315, 6, 1, 9636, // 6, 0
- 5, 1, 11360, 5, 2, 7224, 6, 1, 37866, 6, 2, 9086, // 6, 1
- 5, 2, 9977, 5, 3, 6506, 6, 2, 40656, 6, 3, 8397, // 6, 2
- 5, 3, 8558, 5, 4, 5712, 6, 3, 43710, 6, 4, 7556, // 6, 3
- 5, 4, 7100, 5, 5, 4843, 6, 4, 47035, 6, 5, 6558, // 6, 4
- 5, 5, 5624, 5, 6, 3913, 6, 5, 50581, 6, 6, 5418, // 6, 5
- 5, 6, 4217, 5, 7, 2989, 6, 6, 54105, 6, 7, 4225, // 6, 6
- 5, 7, 3180, 5, 8, 2294, 6, 7, 56756, 6, 8, 3306, // 6, 7
- 6, 8, 56751, 6, 9, 3303, 7, 8, 3186, 7, 9, 2296, // 6, 8
- 6, 9, 54105, 6, 10, 4217, 7, 9, 4225, 7, 10, 2989, // 6, 9
- 6, 10, 50587, 6, 11, 5400, 7, 10, 5637, 7, 11, 3912, // 6,10
- 6, 11, 47049, 6, 12, 6530, 7, 11, 7119, 7, 12, 4838, // 6,11
- 6, 12, 43733, 6, 13, 7516, 7, 12, 8584, 7, 13, 5703, // 6,12
- 6, 13, 40688, 6, 14, 8344, 7, 13, 10013, 7, 14, 6491, // 6,13
- 6, 14, 37906, 6, 15, 9020, 7, 14, 11407, 7, 15, 7203, // 6,14
- 6, 15, 35362, 6, 16, 9558, 7, 15, 12777, 7, 16, 7839, // 6,15
- 6, 0, 12728, 6, 1, 7674, 7, 0, 35844, 7, 1, 9290, // 7, 0
- 6, 1, 11317, 6, 2, 7020, 7, 1, 38481, 7, 2, 8718, // 7, 1
- 6, 2, 9867, 6, 3, 6284, 7, 2, 41389, 7, 3, 7996, // 7, 2
- 6, 3, 8359, 6, 4, 5454, 7, 3, 44616, 7, 4, 7107, // 7, 3
- 6, 4, 6774, 6, 5, 4521, 7, 4, 48218, 7, 5, 6023, // 7, 4
- 6, 5, 5092, 6, 6, 3470, 7, 5, 52253, 7, 6, 4721, // 7, 5
- 6, 6, 3303, 6, 7, 2295, 7, 6, 56751, 7, 7, 3187, // 7, 6
- 6, 7, 1541, 6, 8, 1090, 7, 7, 61364, 7, 8, 1541, // 7, 7
- 7, 8, 61364, 7, 9, 1541, 8, 8, 1542, 8, 9, 1089, // 7, 8
- 7, 9, 56756, 7, 10, 3180, 8, 9, 3306, 8, 10, 2294, // 7, 9
- 7, 10, 52266, 7, 11, 4708, 8, 10, 5097, 8, 11, 3465, // 7,10
- 7, 11, 48240, 7, 12, 6000, 8, 11, 6783, 8, 12, 4513, // 7,11
- 7, 12, 44649, 7, 13, 7072, 8, 12, 8373, 8, 13, 5442, // 7,12
- 7, 13, 41432, 7, 14, 7951, 8, 13, 9886, 8, 14, 6267, // 7,13
- 7, 14, 38534, 7, 15, 8662, 8, 14, 11344, 8, 15, 6996, // 7,14
- 7, 15, 35905, 7, 16, 9224, 8, 15, 12764, 8, 16, 7643, // 7,15
- 7, -1, 7643, 7, 0, 12764, 8, -1, 9224, 8, 0, 35905, // 8, 0
- 7, 0, 6997, 7, 1, 11344, 8, 0, 8662, 8, 1, 38533, // 8, 1
- 7, 1, 6266, 7, 2, 9886, 8, 1, 7951, 8, 2, 41433, // 8, 2
- 7, 2, 5443, 7, 3, 8373, 8, 2, 7072, 8, 3, 44648, // 8, 3
- 7, 3, 4513, 7, 4, 6783, 8, 3, 6000, 8, 4, 48240, // 8, 4
- 7, 4, 3466, 7, 5, 5097, 8, 4, 4708, 8, 5, 52265, // 8, 5
- 7, 5, 2294, 7, 6, 3306, 8, 5, 3180, 8, 6, 56756, // 8, 6
- 7, 6, 1090, 7, 7, 1542, 8, 6, 1541, 8, 7, 61363, // 8, 7
- 8, 7, 1542, 8, 8, 61364, 9, 7, 1090, 9, 8, 1540, // 8, 8
- 8, 8, 3186, 8, 9, 56751, 9, 8, 2295, 9, 9, 3304, // 8, 9
- 8, 9, 4721, 8, 10, 52253, 9, 9, 3470, 9, 10, 5092, // 8,10
- 8, 10, 6023, 8, 11, 48218, 9, 10, 4521, 9, 11, 6774, // 8,11
- 8, 11, 7106, 8, 12, 44616, 9, 11, 5454, 9, 12, 8360, // 8,12
- 8, 12, 7996, 8, 13, 41389, 9, 12, 6284, 9, 13, 9867, // 8,13
- 8, 13, 8718, 8, 14, 38481, 9, 13, 7020, 9, 14, 11317, // 8,14
- 8, 14, 9290, 8, 15, 35844, 9, 14, 7674, 9, 15, 12728, // 8,15
- 8, -1, 7839, 8, 0, 12777, 9, -1, 9558, 9, 0, 35362, // 9, 0
- 8, 0, 7202, 8, 1, 11407, 9, 0, 9020, 9, 1, 37907, // 9, 1
- 8, 1, 6491, 8, 2, 10013, 9, 1, 8344, 9, 2, 40688, // 9, 2
- 8, 2, 5703, 8, 3, 8584, 9, 2, 7516, 9, 3, 43733, // 9, 3
- 8, 3, 4838, 8, 4, 7119, 9, 3, 6530, 9, 4, 47049, // 9, 4
- 8, 4, 3911, 8, 5, 5637, 9, 4, 5400, 9, 5, 50588, // 9, 5
- 8, 5, 2989, 8, 6, 4225, 9, 5, 4217, 9, 6, 54105, // 9, 6
- 8, 6, 2295, 8, 7, 3186, 9, 6, 3303, 9, 7, 56752, // 9, 7
- 9, 7, 3306, 9, 8, 56756, 10, 7, 2294, 10, 8, 3180, // 9, 8
- 9, 8, 4225, 9, 9, 54105, 10, 8, 2989, 10, 9, 4217, // 9, 9
- 9, 9, 5418, 9, 10, 50581, 10, 9, 3913, 10, 10, 5624, // 9,10
- 9, 10, 6558, 9, 11, 47035, 10, 10, 4843, 10, 11, 7100, // 9,11
- 9, 11, 7556, 9, 12, 43710, 10, 11, 5712, 10, 12, 8558, // 9,12
- 9, 12, 8397, 9, 13, 40656, 10, 12, 6506, 10, 13, 9977, // 9,13
- 9, 13, 9086, 9, 14, 37866, 10, 13, 7224, 10, 14, 11360, // 9,14
- 9, 14, 9635, 9, 15, 35315, 10, 14, 7868, 10, 15, 12718, // 9,15
- 9, -1, 8107, 9, 0, 12867, 10, -1, 9995, 10, 0, 34567, // 10, 0
- 9, 0, 7497, 9, 1, 11575, 10, 0, 9509, 10, 1, 36955, // 10, 1
- 9, 1, 6829, 9, 2, 10279, 10, 1, 8902, 10, 2, 39526, // 10, 2
- 9, 2, 6108, 9, 3, 8982, 10, 2, 8175, 10, 3, 42271, // 10, 3
- 9, 3, 5350, 9, 4, 7698, 10, 3, 7342, 10, 4, 45146, // 10, 4
- 9, 4, 4591, 9, 5, 6475, 10, 4, 6451, 10, 5, 48019, // 10, 5
- 9, 5, 3913, 9, 6, 5418, 10, 5, 5624, 10, 6, 50581, // 10, 6
- 9, 6, 3470, 9, 7, 4721, 10, 6, 5092, 10, 7, 52253, // 10, 7
- 10, 7, 5097, 10, 8, 52266, 11, 7, 3466, 11, 8, 4707, // 10, 8
- 10, 8, 5637, 10, 9, 50587, 11, 8, 3911, 11, 9, 5401, // 10, 9
- 10, 9, 6475, 10, 10, 48019, 11, 9, 4591, 11, 10, 6451, // 10,10
- 10, 10, 7377, 10, 11, 45139, 11, 10, 5353, 11, 11, 7667, // 10,11
- 10, 11, 8224, 10, 12, 42256, 11, 11, 6116, 11, 12, 8940, // 10,12
- 10, 12, 8966, 10, 13, 39503, 11, 12, 6842, 11, 13, 10225, // 10,13
- 10, 13, 9587, 10, 14, 36926, 11, 13, 7517, 11, 14, 11506, // 10,14
- 10, 14, 10086, 10, 15, 34532, 11, 14, 8135, 11, 15, 12783, // 10,15
- 10, -1, 8438, 10, 0, 13007, 11, -1, 10528, 11, 0, 33563, // 11, 0
- 10, 0, 7865, 10, 1, 11810, 11, 0, 10111, 11, 1, 35750, // 11, 1
- 10, 1, 7252, 10, 2, 10630, 11, 1, 9597, 11, 2, 38057, // 11, 2
- 10, 2, 6611, 10, 3, 9478, 11, 2, 8995, 11, 3, 40452, // 11, 3
- 10, 3, 5965, 10, 4, 8378, 11, 3, 8332, 11, 4, 42861, // 11, 4
- 10, 4, 5353, 10, 5, 7377, 11, 4, 7667, 11, 5, 45139, // 11, 5
- 10, 5, 4843, 10, 6, 6558, 11, 5, 7100, 11, 6, 47035, // 11, 6
- 10, 6, 4521, 10, 7, 6023, 11, 6, 6774, 11, 7, 48218, // 11, 7
- 11, 7, 6783, 11, 8, 48240, 12, 7, 4513, 12, 8, 6000, // 11, 8
- 11, 8, 7119, 11, 9, 47049, 12, 8, 4838, 12, 9, 6530, // 11, 9
- 11, 9, 7698, 11, 10, 45146, 12, 9, 5350, 12, 10, 7342, // 11,10
- 11, 10, 8378, 11, 11, 42861, 12, 10, 5965, 12, 11, 8332, // 11,11
- 11, 11, 9056, 11, 12, 40444, 12, 11, 6615, 12, 12, 9421, // 11,12
- 11, 12, 9674, 11, 13, 38042, 12, 12, 7261, 12, 13, 10559, // 11,13
- 11, 13, 10204, 11, 14, 35730, 12, 13, 7881, 12, 14, 11721, // 11,14
- 11, 14, 10635, 11, 15, 33539, 12, 14, 8463, 12, 15, 12899, // 11,15
- 11, -1, 8816, 11, 0, 13171, 12, -1, 11143, 12, 0, 32406, // 12, 0
- 11, 0, 8284, 11, 1, 12074, 12, 0, 10808, 12, 1, 34370, // 12, 1
- 11, 1, 7728, 11, 2, 11012, 12, 1, 10397, 12, 2, 36399, // 12, 2
- 11, 2, 7164, 11, 3, 9998, 12, 2, 9924, 12, 3, 38450, // 12, 3
- 11, 3, 6615, 11, 4, 9056, 12, 3, 9421, 12, 4, 40444, // 12, 4
- 11, 4, 6116, 11, 5, 8224, 12, 4, 8940, 12, 5, 42256, // 12, 5
- 11, 5, 5712, 11, 6, 7556, 12, 5, 8558, 12, 6, 43710, // 12, 6
- 11, 6, 5454, 11, 7, 7106, 12, 6, 8359, 12, 7, 44617, // 12, 7
- 12, 7, 8373, 12, 8, 44649, 13, 7, 5443, 13, 8, 7071, // 12, 8
- 12, 8, 8584, 12, 9, 43733, 13, 8, 5703, 13, 9, 7516, // 12, 9
- 12, 9, 8982, 12, 10, 42271, 13, 9, 6108, 13, 10, 8175, // 12,10
- 12, 10, 9478, 12, 11, 40452, 13, 10, 6611, 13, 11, 8995, // 12,11
- 12, 11, 9998, 12, 12, 38450, 13, 11, 7164, 13, 12, 9924, // 12,12
- 12, 12, 10488, 12, 13, 36392, 13, 12, 7734, 13, 13, 10922, // 12,13
- 12, 13, 10918, 12, 14, 34358, 13, 13, 8296, 13, 14, 11964, // 12,14
- 12, 14, 11269, 12, 15, 32391, 13, 14, 8838, 13, 15, 13038, // 12,15
- 12, -1, 9229, 12, 0, 13332, 13, -1, 11829, 13, 0, 31146, // 13, 0
- 12, 0, 8735, 12, 1, 12334, 13, 0, 11580, 13, 1, 32887, // 13, 1
- 12, 1, 8232, 12, 2, 11382, 13, 1, 11272, 13, 2, 34650, // 13, 2
- 12, 2, 7734, 12, 3, 10488, 13, 2, 10922, 13, 3, 36392, // 13, 3
- 12, 3, 7261, 12, 4, 9674, 13, 3, 10559, 13, 4, 38042, // 13, 4
- 12, 4, 6842, 12, 5, 8966, 13, 4, 10226, 13, 5, 39502, // 13, 5
- 12, 5, 6506, 12, 6, 8397, 13, 5, 9977, 13, 6, 40656, // 13, 6
- 12, 6, 6284, 12, 7, 7996, 13, 6, 9867, 13, 7, 41389, // 13, 7
- 13, 7, 9886, 13, 8, 41432, 14, 7, 6266, 14, 8, 7952, // 13, 8
- 13, 8, 10013, 13, 9, 40688, 14, 8, 6491, 14, 9, 8344, // 13, 9
- 13, 9, 10279, 13, 10, 39526, 14, 9, 6829, 14, 10, 8902, // 13,10
- 13, 10, 10630, 13, 11, 38057, 14, 10, 7252, 14, 11, 9597, // 13,11
- 13, 11, 11012, 13, 12, 36399, 14, 11, 7728, 14, 12, 10397, // 13,12
- 13, 12, 11382, 13, 13, 34650, 14, 12, 8232, 14, 13, 11272, // 13,13
- 13, 13, 11709, 13, 14, 32881, 14, 13, 8742, 14, 14, 12204, // 13,14
- 13, 14, 11977, 13, 15, 31138, 14, 14, 9245, 14, 15, 13176, // 13,15
- 13, -1, 9662, 13, 0, 13470, 14, -1, 12574, 14, 0, 29830, // 14, 0
- 13, 0, 9202, 13, 1, 12564, 14, 0, 12412, 14, 1, 31358, // 14, 1
- 13, 1, 8742, 13, 2, 11709, 14, 1, 12203, 14, 2, 32882, // 14, 2
- 13, 2, 8296, 13, 3, 10918, 14, 2, 11964, 14, 3, 34358, // 14, 3
- 13, 3, 7881, 13, 4, 10204, 14, 3, 11721, 14, 4, 35730, // 14, 4
- 13, 4, 7517, 13, 5, 9587, 14, 4, 11507, 14, 5, 36925, // 14, 5
- 13, 5, 7224, 13, 6, 9086, 14, 5, 11360, 14, 6, 37866, // 14, 6
- 13, 6, 7020, 13, 7, 8718, 14, 6, 11317, 14, 7, 38481, // 14, 7
- 14, 7, 11344, 14, 8, 38534, 15, 7, 6997, 15, 8, 8661, // 14, 8
- 14, 8, 11407, 14, 9, 37906, 15, 8, 7202, 15, 9, 9021, // 14, 9
- 14, 9, 11575, 14, 10, 36955, 15, 9, 7497, 15, 10, 9509, // 14,10
- 14, 10, 11810, 14, 11, 35750, 15, 10, 7865, 15, 11, 10111, // 14,11
- 14, 11, 12074, 14, 12, 34369, 15, 11, 8284, 15, 12, 10809, // 14,12
- 14, 12, 12334, 14, 13, 32886, 15, 12, 8735, 15, 13, 11581, // 14,13
- 14, 13, 12564, 14, 14, 31358, 15, 13, 9202, 15, 14, 12412, // 14,14
- 14, 14, 12746, 14, 15, 29828, 15, 14, 9671, 15, 15, 13291, // 14,15
- 14, -1, 10104, 14, 0, 13569, 15, -1, 13368, 15, 0, 28495, // 15, 0
- 14, 0, 9671, 14, 1, 12746, 15, 0, 13291, 15, 1, 29828, // 15, 1
- 14, 1, 9245, 14, 2, 11977, 15, 1, 13176, 15, 2, 31138, // 15, 2
- 14, 2, 8838, 14, 3, 11269, 15, 2, 13038, 15, 3, 32391, // 15, 3
- 14, 3, 8463, 14, 4, 10635, 15, 3, 12899, 15, 4, 33539, // 15, 4
- 14, 4, 8135, 14, 5, 10086, 15, 4, 12783, 15, 5, 34532, // 15, 5
- 14, 5, 7868, 14, 6, 9635, 15, 5, 12717, 15, 6, 35316, // 15, 6
- 14, 6, 7674, 14, 7, 9290, 15, 6, 12728, 15, 7, 35844, // 15, 7
- 15, 7, 12764, 15, 8, 35905, 16, 7, 7643, 16, 8, 9224, // 15, 8
- 15, 8, 12777, 15, 9, 35362, 16, 8, 7839, 16, 9, 9558, // 15, 9
- 15, 9, 12867, 15, 10, 34567, 16, 9, 8107, 16, 10, 9995, // 15,10
- 15, 10, 13007, 15, 11, 33564, 16, 10, 8438, 16, 11, 10527, // 15,11
- 15, 11, 13171, 15, 12, 32406, 16, 11, 8816, 16, 12, 11143, // 15,12
- 15, 12, 13332, 15, 13, 31146, 16, 12, 9229, 16, 13, 11829, // 15,13
- 15, 13, 13470, 15, 14, 29831, 16, 13, 9662, 16, 14, 12573, // 15,14
- 15, 14, 13569, 15, 15, 28495, 16, 14, 10104, 16, 15, 13368, // 15,15
- // angle of -1.5 degrees
- -1, 0, 11440, -1, 1, 8358, 0, 0, 34212, 0, 1, 11526, // 0, 0
- -1, 1, 10780, -1, 2, 7983, 0, 1, 35506, 0, 2, 11267, // 0, 1
- -1, 2, 10158, -1, 3, 7620, 0, 2, 36764, 0, 3, 10994, // 0, 2
- -1, 3, 9585, -1, 4, 7276, 0, 3, 37951, 0, 4, 10724, // 0, 3
- -1, 4, 9072, -1, 5, 6965, 0, 4, 39026, 0, 5, 10473, // 0, 4
- -1, 5, 8632, -1, 6, 6699, 0, 5, 39940, 0, 6, 10265, // 0, 5
- -1, 6, 8278, -1, 7, 6489, 0, 6, 40646, 0, 7, 10123, // 0, 6
- -1, 7, 8018, -1, 8, 6346, 0, 7, 41106, 0, 8, 10066, // 0, 7
- 0, 8, 41072, 0, 9, 10052, 1, 8, 8052, 1, 9, 6360, // 0, 8
- 0, 9, 40618, 0, 10, 10100, 1, 9, 8316, 1, 10, 6502, // 0, 9
- 0, 10, 39918, 0, 11, 10232, 1, 10, 8676, 1, 11, 6710, // 0,10
- 0, 11, 39009, 0, 12, 10430, 1, 11, 9122, 1, 12, 6975, // 0,11
- 0, 12, 37939, 0, 13, 10670, 1, 12, 9642, 1, 13, 7285, // 0,12
- 0, 13, 36756, 0, 14, 10930, 1, 13, 10224, 1, 14, 7626, // 0,13
- 0, 14, 35502, 0, 15, 11192, 1, 14, 10855, 1, 15, 7987, // 0,14
- 0, 15, 34212, 0, 16, 11440, 1, 15, 11526, 1, 16, 8358, // 0,15
- 0, 0, 11192, 0, 1, 7987, 1, 0, 35502, 1, 1, 10855, // 1, 0
- 0, 1, 10467, 0, 2, 7579, 1, 1, 36959, 1, 2, 10531, // 1, 1
- 0, 2, 9777, 0, 3, 7177, 1, 2, 38394, 1, 3, 10188, // 1, 2
- 0, 3, 9135, 0, 4, 6792, 1, 3, 39767, 1, 4, 9842, // 1, 3
- 0, 4, 8557, 0, 5, 6440, 1, 4, 41026, 1, 5, 9513, // 1, 4
- 0, 5, 8061, 0, 6, 6137, 1, 5, 42105, 1, 6, 9233, // 1, 5
- 0, 6, 7667, 0, 7, 5900, 1, 6, 42936, 1, 7, 9033, // 1, 6
- 0, 7, 7390, 0, 8, 5745, 1, 7, 43461, 1, 8, 8940, // 1, 7
- 1, 8, 43433, 1, 9, 8929, 2, 8, 7418, 2, 9, 5756, // 1, 8
- 1, 9, 42913, 1, 10, 9014, 2, 9, 7699, 2, 10, 5910, // 1, 9
- 1, 10, 42087, 1, 11, 9206, 2, 10, 8098, 2, 11, 6145, // 1,10
- 1, 11, 41013, 1, 12, 9478, 2, 11, 8599, 2, 12, 6446, // 1,11
- 1, 12, 39759, 1, 13, 9796, 2, 12, 9184, 2, 13, 6797, // 1,12
- 1, 13, 38390, 1, 14, 10133, 2, 13, 9834, 2, 14, 7179, // 1,13
- 1, 14, 36959, 1, 15, 10467, 2, 14, 10532, 2, 15, 7578, // 1,14
- 1, 15, 35506, 1, 16, 10780, 2, 15, 11267, 2, 16, 7983, // 1,15
- 1, 0, 10930, 1, 1, 7626, 2, 0, 36756, 2, 1, 10224, // 2, 0
- 1, 1, 10133, 1, 2, 7179, 2, 1, 38390, 2, 2, 9834, // 2, 1
- 1, 2, 9366, 1, 3, 6732, 2, 2, 40025, 2, 3, 9413, // 2, 2
- 1, 3, 8641, 1, 4, 6297, 2, 3, 41618, 2, 4, 8980, // 2, 3
- 1, 4, 7981, 1, 5, 5891, 2, 4, 43105, 2, 5, 8559, // 2, 4
- 1, 5, 7411, 1, 6, 5537, 2, 5, 44399, 2, 6, 8189, // 2, 5
- 1, 6, 6961, 1, 7, 5261, 2, 6, 45401, 2, 7, 7913, // 2, 6
- 1, 7, 6658, 1, 8, 5087, 2, 7, 46017, 2, 8, 7774, // 2, 7
- 2, 8, 45995, 2, 9, 7766, 3, 8, 6680, 3, 9, 5095, // 2, 8
- 2, 9, 45383, 2, 10, 7899, 3, 9, 6986, 3, 10, 5268, // 2, 9
- 2, 10, 44386, 2, 11, 8167, 3, 10, 7440, 3, 11, 5543, // 2,10
- 2, 11, 43096, 2, 12, 8530, 3, 11, 8015, 3, 12, 5895, // 2,11
- 2, 12, 41614, 2, 13, 8941, 3, 12, 8681, 3, 13, 6300, // 2,12
- 2, 13, 40025, 2, 14, 9366, 3, 13, 9413, 3, 14, 6732, // 2,13
- 2, 14, 38394, 2, 15, 9777, 3, 14, 10188, 3, 15, 7177, // 2,14
- 2, 15, 36764, 2, 16, 10158, 3, 15, 10994, 3, 16, 7620, // 2,15
- 2, 0, 10670, 2, 1, 7285, 3, 0, 37939, 3, 1, 9642, // 3, 0
- 2, 1, 9796, 2, 2, 6797, 3, 1, 39759, 3, 2, 9184, // 3, 1
- 2, 2, 8941, 2, 3, 6299, 3, 2, 41614, 3, 3, 8682, // 3, 2
- 2, 3, 8120, 2, 4, 5804, 3, 3, 43461, 3, 4, 8151, // 3, 3
- 2, 4, 7356, 2, 5, 5330, 3, 4, 45229, 3, 5, 7621, // 3, 4
- 2, 5, 6685, 2, 6, 4906, 3, 5, 46806, 3, 6, 7139, // 3, 5
- 2, 6, 6154, 2, 7, 4572, 3, 6, 48049, 3, 7, 6761, // 3, 6
- 2, 7, 5811, 2, 8, 4366, 3, 7, 48801, 3, 8, 6558, // 3, 7
- 3, 8, 48785, 3, 9, 6552, 4, 8, 5827, 4, 9, 4372, // 3, 8
- 3, 9, 48037, 3, 10, 6750, 4, 9, 6173, 4, 10, 4576, // 3, 9
- 3, 10, 46798, 3, 11, 7121, 4, 10, 6707, 4, 11, 4910, // 3,10
- 3, 11, 45224, 3, 12, 7598, 4, 11, 7382, 4, 12, 5332, // 3,11
- 3, 12, 43461, 3, 13, 8120, 4, 12, 8151, 4, 13, 5804, // 3,12
- 3, 13, 41618, 3, 14, 8641, 4, 13, 8979, 4, 14, 6298, // 3,13
- 3, 14, 39767, 3, 15, 9135, 4, 14, 9841, 4, 15, 6793, // 3,14
- 3, 15, 37951, 3, 16, 9585, 4, 15, 10723, 4, 16, 7277, // 3,15
- 3, 0, 10430, 3, 1, 6975, 4, 0, 39009, 4, 1, 9122, // 4, 0
- 3, 1, 9478, 3, 2, 6447, 4, 1, 41013, 4, 2, 8598, // 4, 1
- 3, 2, 8530, 3, 3, 5895, 4, 2, 43096, 4, 3, 8015, // 4, 2
- 3, 3, 7598, 3, 4, 5331, 4, 3, 45224, 4, 4, 7383, // 4, 3
- 3, 4, 6708, 3, 5, 4774, 4, 4, 47328, 4, 5, 6726, // 4, 4
- 3, 5, 5901, 3, 6, 4257, 4, 5, 49279, 4, 6, 6099, // 4, 5
- 3, 6, 5248, 3, 7, 3834, 4, 6, 50873, 4, 7, 5581, // 4, 6
- 3, 7, 4835, 3, 8, 3575, 4, 7, 51842, 4, 8, 5284, // 4, 7
- 4, 8, 51832, 4, 9, 5280, 5, 8, 4846, 5, 9, 3578, // 4, 8
- 4, 9, 50865, 4, 10, 5573, 5, 9, 5261, 5, 10, 3837, // 4, 9
- 4, 10, 49275, 4, 11, 6086, 5, 10, 5917, 5, 11, 4258, // 4,10
- 4, 11, 47328, 4, 12, 6708, 5, 11, 6727, 5, 12, 4773, // 4,11
- 4, 12, 45229, 4, 13, 7356, 5, 12, 7622, 5, 13, 5329, // 4,12
- 4, 13, 43105, 4, 14, 7981, 5, 13, 8559, 5, 14, 5891, // 4,13
- 4, 14, 41026, 4, 15, 8557, 5, 14, 9513, 5, 15, 6440, // 4,14
- 4, 15, 39026, 4, 16, 9072, 5, 15, 10473, 5, 16, 6965, // 4,15
- 4, 0, 10232, 4, 1, 6710, 5, 0, 39918, 5, 1, 8676, // 5, 0
- 4, 1, 9206, 4, 2, 6145, 5, 1, 42087, 5, 2, 8098, // 5, 1
- 4, 2, 8167, 4, 3, 5543, 5, 2, 44386, 5, 3, 7440, // 5, 2
- 4, 3, 7121, 4, 4, 4909, 5, 3, 46798, 5, 4, 6708, // 5, 3
- 4, 4, 6086, 4, 5, 4258, 5, 4, 49275, 5, 5, 5917, // 5, 4
- 4, 5, 5103, 4, 6, 3621, 5, 5, 51700, 5, 6, 5112, // 5, 5
- 4, 6, 4262, 4, 7, 3064, 5, 6, 53816, 5, 7, 4394, // 5, 6
- 4, 7, 3720, 4, 8, 2708, 5, 7, 55168, 5, 8, 3940, // 5, 7
- 5, 8, 55162, 5, 9, 3938, 6, 8, 3726, 6, 9, 2710, // 5, 8
- 5, 9, 53813, 5, 10, 4388, 6, 9, 4269, 6, 10, 3066, // 5, 9
- 5, 10, 51700, 5, 11, 5103, 6, 10, 5113, 6, 11, 3620, // 5,10
- 5, 11, 49279, 5, 12, 5901, 6, 11, 6099, 6, 12, 4257, // 5,11
- 5, 12, 46806, 5, 13, 6685, 6, 12, 7138, 6, 13, 4907, // 5,12
- 5, 13, 44399, 5, 14, 7411, 6, 13, 8189, 6, 14, 5537, // 5,13
- 5, 14, 42105, 5, 15, 8061, 6, 14, 9233, 6, 15, 6137, // 5,14
- 5, 15, 39940, 5, 16, 8632, 6, 15, 10265, 6, 16, 6699, // 5,15
- 5, 0, 10100, 5, 1, 6502, 6, 0, 40618, 6, 1, 8316, // 6, 0
- 5, 1, 9014, 5, 2, 5910, 6, 1, 42913, 6, 2, 7699, // 6, 1
- 5, 2, 7899, 5, 3, 5268, 6, 2, 45383, 6, 3, 6986, // 6, 2
- 5, 3, 6750, 5, 4, 4576, 6, 3, 48037, 6, 4, 6173, // 6, 3
- 5, 4, 5573, 5, 5, 3837, 6, 4, 50865, 6, 5, 5261, // 6, 4
- 5, 5, 4388, 5, 6, 3065, 6, 5, 53813, 6, 6, 4270, // 6, 5
- 5, 6, 3271, 5, 7, 2316, 6, 6, 56673, 6, 7, 3276, // 6, 6
- 5, 7, 2462, 5, 8, 1766, 6, 7, 58775, 6, 8, 2533, // 6, 7
- 6, 8, 58773, 6, 9, 2532, 7, 8, 2464, 7, 9, 1767, // 6, 8
- 6, 9, 56673, 6, 10, 3271, 7, 9, 3275, 7, 10, 2317, // 6, 9
- 6, 10, 53816, 6, 11, 4262, 7, 10, 4394, 7, 11, 3064, // 6,10
- 6, 11, 50873, 6, 12, 5248, 7, 11, 5581, 7, 12, 3834, // 6,11
- 6, 12, 48049, 6, 13, 6154, 7, 12, 6761, 7, 13, 4572, // 6,12
- 6, 13, 45401, 6, 14, 6961, 7, 13, 7913, 7, 14, 5261, // 6,13
- 6, 14, 42936, 6, 15, 7667, 7, 14, 9032, 7, 15, 5901, // 6,14
- 6, 15, 40646, 6, 16, 8278, 7, 15, 10123, 7, 16, 6489, // 6,15
- 6, 0, 10052, 6, 1, 6360, 7, 0, 41072, 7, 1, 8052, // 7, 0
- 6, 1, 8929, 6, 2, 5756, 7, 1, 43433, 7, 2, 7418, // 7, 1
- 6, 2, 7766, 6, 3, 5095, 7, 2, 45995, 7, 3, 6680, // 7, 2
- 6, 3, 6552, 6, 4, 4372, 7, 3, 48785, 7, 4, 5827, // 7, 3
- 6, 4, 5280, 6, 5, 3579, 7, 4, 51832, 7, 5, 4845, // 7, 4
- 6, 5, 3938, 6, 6, 2710, 7, 5, 55162, 7, 6, 3726, // 7, 5
- 6, 6, 2532, 6, 7, 1767, 7, 6, 58773, 7, 7, 2464, // 7, 6
- 6, 7, 1170, 6, 8, 827, 7, 7, 62369, 7, 8, 1170, // 7, 7
- 7, 8, 62369, 7, 9, 1170, 8, 8, 1170, 8, 9, 827, // 7, 8
- 7, 9, 58775, 7, 10, 2462, 8, 9, 2533, 8, 10, 1766, // 7, 9
- 7, 10, 55168, 7, 11, 3720, 8, 10, 3940, 8, 11, 2708, // 7,10
- 7, 11, 51842, 7, 12, 4835, 8, 11, 5283, 8, 12, 3576, // 7,11
- 7, 12, 48801, 7, 13, 5811, 8, 12, 6558, 8, 13, 4366, // 7,12
- 7, 13, 46017, 7, 14, 6658, 8, 13, 7773, 8, 14, 5088, // 7,13
- 7, 14, 43461, 7, 15, 7390, 8, 14, 8939, 8, 15, 5746, // 7,14
- 7, 15, 41106, 7, 16, 8018, 8, 15, 10066, 8, 16, 6346, // 7,15
- 7, -1, 6346, 7, 0, 10066, 8, -1, 8018, 8, 0, 41106, // 8, 0
- 7, 0, 5745, 7, 1, 8939, 8, 0, 7390, 8, 1, 43462, // 8, 1
- 7, 1, 5087, 7, 2, 7773, 8, 1, 6658, 8, 2, 46018, // 8, 2
- 7, 2, 4366, 7, 3, 6558, 8, 2, 5811, 8, 3, 48801, // 8, 3
- 7, 3, 3575, 7, 4, 5283, 8, 3, 4835, 8, 4, 51843, // 8, 4
- 7, 4, 2708, 7, 5, 3940, 8, 4, 3720, 8, 5, 55168, // 8, 5
- 7, 5, 1766, 7, 6, 2533, 8, 5, 2462, 8, 6, 58775, // 8, 6
- 7, 6, 827, 7, 7, 1170, 8, 6, 1170, 8, 7, 62369, // 8, 7
- 8, 7, 1170, 8, 8, 62369, 9, 7, 827, 9, 8, 1170, // 8, 8
- 8, 8, 2464, 8, 9, 58773, 9, 8, 1767, 9, 9, 2532, // 8, 9
- 8, 9, 3726, 8, 10, 55162, 9, 9, 2710, 9, 10, 3938, // 8,10
- 8, 10, 4846, 8, 11, 51832, 9, 10, 3579, 9, 11, 5279, // 8,11
- 8, 11, 5827, 8, 12, 48785, 9, 11, 4372, 9, 12, 6552, // 8,12
- 8, 12, 6680, 8, 13, 45995, 9, 12, 5095, 9, 13, 7766, // 8,13
- 8, 13, 7418, 8, 14, 43433, 9, 13, 5756, 9, 14, 8929, // 8,14
- 8, 14, 8052, 8, 15, 41072, 9, 14, 6360, 9, 15, 10052, // 8,15
- 8, -1, 6489, 8, 0, 10123, 9, -1, 8278, 9, 0, 40646, // 9, 0
- 8, 0, 5900, 8, 1, 9032, 9, 0, 7667, 9, 1, 42937, // 9, 1
- 8, 1, 5261, 8, 2, 7913, 9, 1, 6961, 9, 2, 45401, // 9, 2
- 8, 2, 4572, 8, 3, 6761, 9, 2, 6154, 9, 3, 48049, // 9, 3
- 8, 3, 3834, 8, 4, 5581, 9, 3, 5248, 9, 4, 50873, // 9, 4
- 8, 4, 3064, 8, 5, 4394, 9, 4, 4262, 9, 5, 53816, // 9, 5
- 8, 5, 2316, 8, 6, 3275, 9, 5, 3271, 9, 6, 56674, // 9, 6
- 8, 6, 1767, 8, 7, 2464, 9, 6, 2532, 9, 7, 58773, // 9, 7
- 9, 7, 2533, 9, 8, 58775, 10, 7, 1766, 10, 8, 2462, // 9, 8
- 9, 8, 3275, 9, 9, 56673, 10, 8, 2316, 10, 9, 3272, // 9, 9
- 9, 9, 4269, 9, 10, 53813, 10, 9, 3065, 10, 10, 4389, // 9,10
- 9, 10, 5261, 9, 11, 50865, 10, 10, 3837, 10, 11, 5573, // 9,11
- 9, 11, 6173, 9, 12, 48037, 10, 11, 4576, 10, 12, 6750, // 9,12
- 9, 12, 6986, 9, 13, 45383, 10, 12, 5268, 10, 13, 7899, // 9,13
- 9, 13, 7699, 9, 14, 42913, 10, 13, 5910, 10, 14, 9014, // 9,14
- 9, 14, 8316, 9, 15, 40618, 10, 14, 6502, 10, 15, 10100, // 9,15
- 9, -1, 6699, 9, 0, 10265, 10, -1, 8632, 10, 0, 39940, // 10, 0
- 9, 0, 6137, 9, 1, 9233, 10, 0, 8061, 10, 1, 42105, // 10, 1
- 9, 1, 5537, 9, 2, 8189, 10, 1, 7411, 10, 2, 44399, // 10, 2
- 9, 2, 4906, 9, 3, 7138, 10, 2, 6685, 10, 3, 46807, // 10, 3
- 9, 3, 4257, 9, 4, 6099, 10, 3, 5901, 10, 4, 49279, // 10, 4
- 9, 4, 3621, 9, 5, 5113, 10, 4, 5103, 10, 5, 51699, // 10, 5
- 9, 5, 3065, 9, 6, 4269, 10, 5, 4388, 10, 6, 53814, // 10, 6
- 9, 6, 2710, 9, 7, 3726, 10, 6, 3938, 10, 7, 55162, // 10, 7
- 10, 7, 3940, 10, 8, 55168, 11, 7, 2708, 11, 8, 3720, // 10, 8
- 10, 8, 4394, 10, 9, 53816, 11, 8, 3064, 11, 9, 4262, // 10, 9
- 10, 9, 5113, 10, 10, 51700, 11, 9, 3621, 11, 10, 5102, // 10,10
- 10, 10, 5917, 10, 11, 49275, 11, 10, 4258, 11, 11, 6086, // 10,11
- 10, 11, 6707, 10, 12, 46798, 11, 11, 4909, 11, 12, 7122, // 10,12
- 10, 12, 7440, 10, 13, 44386, 11, 12, 5543, 11, 13, 8167, // 10,13
- 10, 13, 8098, 10, 14, 42087, 11, 13, 6145, 11, 14, 9206, // 10,14
- 10, 14, 8676, 10, 15, 39918, 11, 14, 6710, 11, 15, 10232, // 10,15
- 10, -1, 6965, 10, 0, 10473, 11, -1, 9072, 11, 0, 39026, // 11, 0
- 10, 0, 6440, 10, 1, 9513, 11, 0, 8557, 11, 1, 41026, // 11, 1
- 10, 1, 5891, 10, 2, 8559, 11, 1, 7981, 11, 2, 43105, // 11, 2
- 10, 2, 5330, 10, 3, 7622, 11, 2, 7356, 11, 3, 45228, // 11, 3
- 10, 3, 4774, 10, 4, 6727, 11, 3, 6708, 11, 4, 47327, // 11, 4
- 10, 4, 4258, 10, 5, 5917, 11, 4, 6086, 11, 5, 49275, // 11, 5
- 10, 5, 3837, 10, 6, 5261, 11, 5, 5573, 11, 6, 50865, // 11, 6
- 10, 6, 3579, 10, 7, 4846, 11, 6, 5280, 11, 7, 51831, // 11, 7
- 11, 7, 5283, 11, 8, 51842, 12, 7, 3575, 12, 8, 4836, // 11, 8
- 11, 8, 5581, 11, 9, 50873, 12, 8, 3834, 12, 9, 5248, // 11, 9
- 11, 9, 6099, 11, 10, 49279, 12, 9, 4257, 12, 10, 5901, // 11,10
- 11, 10, 6727, 11, 11, 47328, 12, 10, 4774, 12, 11, 6707, // 11,11
- 11, 11, 7382, 11, 12, 45224, 12, 11, 5331, 12, 12, 7599, // 11,12
- 11, 12, 8015, 11, 13, 43096, 12, 12, 5895, 12, 13, 8530, // 11,13
- 11, 13, 8599, 11, 14, 41013, 12, 13, 6447, 12, 14, 9477, // 11,14
- 11, 14, 9122, 11, 15, 39009, 12, 14, 6975, 12, 15, 10430, // 11,15
- 11, -1, 7276, 11, 0, 10723, 12, -1, 9585, 12, 0, 37952, // 12, 0
- 11, 0, 6792, 11, 1, 9841, 12, 0, 9135, 12, 1, 39768, // 12, 1
- 11, 1, 6297, 11, 2, 8979, 12, 1, 8641, 12, 2, 41619, // 12, 2
- 11, 2, 5804, 11, 3, 8151, 12, 2, 8120, 12, 3, 43461, // 12, 3
- 11, 3, 5331, 11, 4, 7382, 12, 3, 7598, 12, 4, 45225, // 12, 4
- 11, 4, 4909, 11, 5, 6707, 12, 4, 7121, 12, 5, 46799, // 12, 5
- 11, 5, 4576, 11, 6, 6173, 12, 5, 6750, 12, 6, 48037, // 12, 6
- 11, 6, 4372, 11, 7, 5827, 12, 6, 6552, 12, 7, 48785, // 12, 7
- 12, 7, 6558, 12, 8, 48801, 13, 7, 4366, 13, 8, 5811, // 12, 8
- 12, 8, 6761, 12, 9, 48049, 13, 8, 4572, 13, 9, 6154, // 12, 9
- 12, 9, 7138, 12, 10, 46806, 13, 9, 4906, 13, 10, 6686, // 12,10
- 12, 10, 7622, 12, 11, 45229, 13, 10, 5330, 13, 11, 7355, // 12,11
- 12, 11, 8151, 12, 12, 43461, 13, 11, 5804, 13, 12, 8120, // 12,12
- 12, 12, 8681, 12, 13, 41614, 13, 12, 6299, 13, 13, 8942, // 12,13
- 12, 13, 9184, 12, 14, 39759, 13, 13, 6797, 13, 14, 9796, // 12,14
- 12, 14, 9642, 12, 15, 37939, 13, 14, 7285, 13, 15, 10670, // 12,15
- 12, -1, 7620, 12, 0, 10994, 13, -1, 10158, 13, 0, 36764, // 13, 0
- 12, 0, 7177, 12, 1, 10188, 13, 0, 9777, 13, 1, 38394, // 13, 1
- 12, 1, 6732, 12, 2, 9413, 13, 1, 9366, 13, 2, 40025, // 13, 2
- 12, 2, 6299, 12, 3, 8681, 13, 2, 8941, 13, 3, 41615, // 13, 3
- 12, 3, 5895, 12, 4, 8015, 13, 3, 8530, 13, 4, 43096, // 13, 4
- 12, 4, 5543, 12, 5, 7440, 13, 4, 8167, 13, 5, 44386, // 13, 5
- 12, 5, 5268, 12, 6, 6986, 13, 5, 7899, 13, 6, 45383, // 13, 6
- 12, 6, 5095, 12, 7, 6680, 13, 6, 7766, 13, 7, 45995, // 13, 7
- 13, 7, 7773, 13, 8, 46017, 14, 7, 5087, 14, 8, 6659, // 13, 8
- 13, 8, 7913, 13, 9, 45401, 14, 8, 5261, 14, 9, 6961, // 13, 9
- 13, 9, 8189, 13, 10, 44399, 14, 9, 5537, 14, 10, 7411, // 13,10
- 13, 10, 8559, 13, 11, 43105, 14, 10, 5891, 14, 11, 7981, // 13,11
- 13, 11, 8979, 13, 12, 41618, 14, 11, 6297, 14, 12, 8642, // 13,12
- 13, 12, 9413, 13, 13, 40025, 14, 12, 6732, 14, 13, 9366, // 13,13
- 13, 13, 9834, 13, 14, 38390, 14, 13, 7179, 14, 14, 10133, // 13,14
- 13, 14, 10224, 13, 15, 36756, 14, 14, 7626, 14, 15, 10930, // 13,15
- 13, -1, 7983, 13, 0, 11267, 14, -1, 10780, 14, 0, 35506, // 14, 0
- 13, 0, 7579, 13, 1, 10532, 14, 0, 10467, 14, 1, 36958, // 14, 1
- 13, 1, 7179, 13, 2, 9834, 14, 1, 10133, 14, 2, 38390, // 14, 2
- 13, 2, 6797, 13, 3, 9184, 14, 2, 9796, 14, 3, 39759, // 14, 3
- 13, 3, 6447, 13, 4, 8599, 14, 3, 9478, 14, 4, 41012, // 14, 4
- 13, 4, 6145, 13, 5, 8098, 14, 4, 9206, 14, 5, 42087, // 14, 5
- 13, 5, 5910, 13, 6, 7699, 14, 5, 9014, 14, 6, 42913, // 14, 6
- 13, 6, 5756, 13, 7, 7418, 14, 6, 8929, 14, 7, 43433, // 14, 7
- 14, 7, 8939, 14, 8, 43461, 15, 7, 5745, 15, 8, 7391, // 14, 8
- 14, 8, 9032, 14, 9, 42936, 15, 8, 5900, 15, 9, 7668, // 14, 9
- 14, 9, 9233, 14, 10, 42105, 15, 9, 6137, 15, 10, 8061, // 14,10
- 14, 10, 9513, 14, 11, 41026, 15, 10, 6440, 15, 11, 8557, // 14,11
- 14, 11, 9841, 14, 12, 39767, 15, 11, 6792, 15, 12, 9136, // 14,12
- 14, 12, 10188, 14, 13, 38394, 15, 12, 7177, 15, 13, 9777, // 14,13
- 14, 13, 10532, 14, 14, 36959, 15, 13, 7579, 15, 14, 10466, // 14,14
- 14, 14, 10855, 14, 15, 35502, 15, 14, 7987, 15, 15, 11192, // 14,15
- 14, -1, 8358, 14, 0, 11526, 15, -1, 11440, 15, 0, 34212, // 15, 0
- 14, 0, 7987, 14, 1, 10855, 15, 0, 11192, 15, 1, 35502, // 15, 1
- 14, 1, 7626, 14, 2, 10224, 15, 1, 10930, 15, 2, 36756, // 15, 2
- 14, 2, 7285, 14, 3, 9642, 15, 2, 10670, 15, 3, 37939, // 15, 3
- 14, 3, 6975, 14, 4, 9122, 15, 3, 10430, 15, 4, 39009, // 15, 4
- 14, 4, 6710, 14, 5, 8676, 15, 4, 10232, 15, 5, 39918, // 15, 5
- 14, 5, 6502, 14, 6, 8316, 15, 5, 10100, 15, 6, 40618, // 15, 6
- 14, 6, 6360, 14, 7, 8052, 15, 6, 10052, 15, 7, 41072, // 15, 7
- 15, 7, 10066, 15, 8, 41106, 16, 7, 6346, 16, 8, 8018, // 15, 8
- 15, 8, 10123, 15, 9, 40646, 16, 8, 6489, 16, 9, 8278, // 15, 9
- 15, 9, 10265, 15, 10, 39940, 16, 9, 6699, 16, 10, 8632, // 15,10
- 15, 10, 10473, 15, 11, 39026, 16, 10, 6965, 16, 11, 9072, // 15,11
- 15, 11, 10723, 15, 12, 37951, 16, 11, 7276, 16, 12, 9586, // 15,12
- 15, 12, 10994, 15, 13, 36764, 16, 12, 7620, 16, 13, 10158, // 15,13
- 15, 13, 11267, 15, 14, 35506, 16, 13, 7983, 16, 14, 10780, // 15,14
- 15, 14, 11526, 15, 15, 34212, 16, 14, 8358, 16, 15, 11440, // 15,15
- // angle of -1.0 degrees
- -1, 0, 8769, -1, 1, 6280, 0, 0, 41693, 0, 1, 8794, // 0, 0
- -1, 1, 8265, -1, 2, 5974, 0, 1, 42823, 0, 2, 8474, // 0, 1
- -1, 2, 7791, -1, 3, 5682, 0, 2, 43904, 0, 3, 8159, // 0, 2
- -1, 3, 7356, -1, 4, 5410, 0, 3, 44907, 0, 4, 7863, // 0, 3
- -1, 4, 6970, -1, 5, 5169, 0, 4, 45799, 0, 5, 7598, // 0, 4
- -1, 5, 6644, -1, 6, 4967, 0, 5, 46541, 0, 6, 7384, // 0, 5
- -1, 6, 6391, -1, 7, 4814, 0, 6, 47098, 0, 7, 7233, // 0, 6
- -1, 7, 6217, -1, 8, 4718, 0, 7, 47440, 0, 8, 7161, // 0, 7
- 0, 8, 47426, 0, 9, 7158, 1, 8, 6230, 1, 9, 4722, // 0, 8
- 0, 9, 47086, 0, 10, 7227, 1, 9, 6405, 1, 10, 4818, // 0, 9
- 0, 10, 46532, 0, 11, 7374, 1, 10, 6659, 1, 11, 4971, // 0,10
- 0, 11, 45791, 0, 12, 7587, 1, 11, 6986, 1, 12, 5172, // 0,11
- 0, 12, 44901, 0, 13, 7848, 1, 12, 7374, 1, 13, 5413, // 0,12
- 0, 13, 43900, 0, 14, 8141, 1, 13, 7812, 1, 14, 5683, // 0,13
- 0, 14, 42821, 0, 15, 8452, 1, 14, 8288, 1, 15, 5975, // 0,14
- 0, 15, 41693, 0, 16, 8769, 1, 15, 8795, 1, 16, 6279, // 0,15
- 0, 0, 8452, 0, 1, 5975, 1, 0, 42821, 1, 1, 8288, // 1, 0
- 0, 1, 7901, 0, 2, 5640, 1, 1, 44074, 1, 2, 7921, // 1, 1
- 0, 2, 7378, 0, 3, 5315, 1, 2, 45288, 1, 3, 7555, // 1, 2
- 0, 3, 6892, 0, 4, 5009, 1, 3, 46430, 1, 4, 7205, // 1, 3
- 0, 4, 6458, 0, 5, 4734, 1, 4, 47458, 1, 5, 6886, // 1, 4
- 0, 5, 6092, 0, 6, 4502, 1, 5, 48322, 1, 6, 6620, // 1, 5
- 0, 6, 5809, 0, 7, 4327, 1, 6, 48969, 1, 7, 6431, // 1, 6
- 0, 7, 5623, 0, 8, 4221, 1, 7, 49358, 1, 8, 6334, // 1, 7
- 1, 8, 49347, 1, 9, 6332, 2, 8, 5633, 2, 9, 4224, // 1, 8
- 1, 9, 48960, 1, 10, 6425, 2, 9, 5820, 2, 10, 4331, // 1, 9
- 1, 10, 48314, 1, 11, 6613, 2, 10, 6104, 2, 11, 4505, // 1,10
- 1, 11, 47453, 1, 12, 6875, 2, 11, 6472, 2, 12, 4736, // 1,11
- 1, 12, 46427, 1, 13, 7191, 2, 12, 6908, 2, 13, 5010, // 1,12
- 1, 13, 45286, 1, 14, 7539, 2, 13, 7395, 2, 14, 5316, // 1,13
- 1, 14, 44074, 1, 15, 7901, 2, 14, 7921, 2, 15, 5640, // 1,14
- 1, 15, 42823, 1, 16, 8265, 2, 15, 8474, 2, 16, 5974, // 1,15
- 1, 0, 8141, 1, 1, 5684, 2, 0, 43900, 2, 1, 7811, // 2, 0
- 1, 1, 7539, 1, 2, 5316, 2, 1, 45286, 2, 2, 7395, // 2, 1
- 1, 2, 6959, 1, 3, 4954, 2, 2, 46650, 2, 3, 6973, // 2, 2
- 1, 3, 6414, 1, 4, 4607, 2, 3, 47955, 2, 4, 6560, // 2, 3
- 1, 4, 5920, 1, 5, 4290, 2, 4, 49150, 2, 5, 6176, // 2, 4
- 1, 5, 5499, 1, 6, 4019, 2, 5, 50171, 2, 6, 5847, // 2, 5
- 1, 6, 5175, 1, 7, 3813, 2, 6, 50942, 2, 7, 5606, // 2, 6
- 1, 7, 4970, 1, 8, 3691, 2, 7, 51395, 2, 8, 5480, // 2, 7
- 2, 8, 51387, 2, 9, 5478, 3, 8, 4978, 3, 9, 3693, // 2, 8
- 2, 9, 50935, 2, 10, 5602, 3, 9, 5184, 3, 10, 3815, // 2, 9
- 2, 10, 50165, 2, 11, 5842, 3, 10, 5508, 3, 11, 4021, // 2,10
- 2, 11, 49147, 2, 12, 6168, 3, 11, 5930, 3, 12, 4291, // 2,11
- 2, 12, 47953, 2, 13, 6549, 3, 12, 6426, 3, 13, 4608, // 2,12
- 2, 13, 46650, 2, 14, 6959, 3, 13, 6973, 3, 14, 4954, // 2,13
- 2, 14, 45288, 2, 15, 7378, 3, 14, 7555, 3, 15, 5315, // 2,14
- 2, 15, 43904, 2, 16, 7791, 3, 15, 8159, 3, 16, 5682, // 2,15
- 2, 0, 7848, 2, 1, 5413, 3, 0, 44901, 3, 1, 7374, // 3, 0
- 2, 1, 7191, 2, 2, 5011, 3, 1, 46427, 3, 2, 6907, // 3, 1
- 2, 2, 6549, 2, 3, 4608, 3, 2, 47953, 3, 3, 6426, // 3, 2
- 2, 3, 5934, 2, 4, 4214, 3, 3, 49445, 3, 4, 5943, // 3, 3
- 2, 4, 5365, 2, 5, 3845, 3, 4, 50844, 3, 5, 5482, // 3, 4
- 2, 5, 4872, 2, 6, 3522, 3, 5, 52069, 3, 6, 5073, // 3, 5
- 2, 6, 4489, 2, 7, 3273, 3, 6, 53012, 3, 7, 4762, // 3, 6
- 2, 7, 4254, 2, 8, 3126, 3, 7, 53562, 3, 8, 4594, // 3, 7
- 3, 8, 53557, 3, 9, 4592, 4, 8, 4259, 4, 9, 3128, // 3, 8
- 3, 9, 53008, 3, 10, 4759, 4, 9, 4495, 4, 10, 3274, // 3, 9
- 3, 10, 52066, 3, 11, 5069, 4, 10, 4879, 4, 11, 3522, // 3,10
- 3, 11, 50843, 3, 12, 5474, 4, 11, 5373, 4, 12, 3846, // 3,11
- 3, 12, 49445, 3, 13, 5934, 4, 12, 5943, 4, 13, 4214, // 3,12
- 3, 13, 47955, 3, 14, 6414, 4, 13, 6560, 4, 14, 4607, // 3,13
- 3, 14, 46430, 3, 15, 6892, 4, 14, 7204, 4, 15, 5010, // 3,14
- 3, 15, 44907, 3, 16, 7356, 4, 15, 7863, 4, 16, 5410, // 3,15
- 3, 0, 7587, 3, 1, 5172, 4, 0, 45791, 4, 1, 6986, // 4, 0
- 3, 1, 6875, 3, 2, 4736, 4, 1, 47453, 4, 2, 6472, // 4, 1
- 3, 2, 6168, 3, 3, 4291, 4, 2, 49147, 4, 3, 5930, // 4, 2
- 3, 3, 5474, 3, 4, 3846, 4, 3, 50843, 4, 4, 5373, // 4, 3
- 3, 4, 4816, 3, 5, 3415, 4, 4, 52484, 4, 5, 4821, // 4, 4
- 3, 5, 4226, 3, 6, 3023, 4, 5, 53975, 4, 6, 4312, // 4, 5
- 3, 6, 3755, 3, 7, 2710, 4, 6, 55166, 4, 7, 3905, // 4, 6
- 3, 7, 3469, 3, 8, 2524, 4, 7, 55870, 4, 8, 3673, // 4, 7
- 4, 8, 55867, 4, 9, 3671, 5, 8, 3473, 5, 9, 2525, // 4, 8
- 4, 9, 55164, 4, 10, 3902, 5, 9, 3759, 5, 10, 2711, // 4, 9
- 4, 10, 53973, 4, 11, 4309, 5, 10, 4230, 5, 11, 3024, // 4,10
- 4, 11, 52484, 4, 12, 4816, 5, 11, 4822, 5, 12, 3414, // 4,11
- 4, 12, 50844, 4, 13, 5365, 5, 12, 5481, 5, 13, 3846, // 4,12
- 4, 13, 49150, 4, 14, 5920, 5, 13, 6176, 5, 14, 4290, // 4,13
- 4, 14, 47458, 4, 15, 6458, 5, 14, 6886, 5, 15, 4734, // 4,14
- 4, 15, 45799, 4, 16, 6970, 5, 15, 7599, 5, 16, 5168, // 4,15
- 4, 0, 7374, 4, 1, 4971, 5, 0, 46532, 5, 1, 6659, // 5, 0
- 4, 1, 6613, 4, 2, 4505, 5, 1, 48314, 5, 2, 6104, // 5, 1
- 4, 2, 5842, 4, 3, 4020, 5, 2, 50165, 5, 3, 5509, // 5, 2
- 4, 3, 5069, 4, 4, 3523, 5, 3, 52066, 5, 4, 4878, // 5, 3
- 4, 4, 4309, 4, 5, 3023, 5, 4, 53973, 5, 5, 4231, // 5, 4
- 4, 5, 3595, 4, 6, 2546, 5, 5, 55798, 5, 6, 3597, // 5, 5
- 4, 6, 2993, 4, 7, 2138, 5, 6, 57354, 5, 7, 3051, // 5, 6
- 4, 7, 2615, 4, 8, 1884, 5, 7, 58324, 5, 8, 2713, // 5, 7
- 5, 8, 58322, 5, 9, 2713, 6, 8, 2616, 6, 9, 1885, // 5, 8
- 5, 9, 57353, 5, 10, 3050, 6, 9, 2995, 6, 10, 2138, // 5, 9
- 5, 10, 55798, 5, 11, 3595, 6, 10, 3598, 6, 11, 2545, // 5,10
- 5, 11, 53975, 5, 12, 4226, 6, 11, 4313, 6, 12, 3022, // 5,11
- 5, 12, 52069, 5, 13, 4872, 6, 12, 5073, 6, 13, 3522, // 5,12
- 5, 13, 50171, 5, 14, 5499, 6, 13, 5848, 6, 14, 4018, // 5,13
- 5, 14, 48322, 5, 15, 6092, 6, 14, 6620, 6, 15, 4502, // 5,14
- 5, 15, 46541, 5, 16, 6644, 6, 15, 7383, 6, 16, 4968, // 5,15
- 5, 0, 7227, 5, 1, 4818, 6, 0, 47086, 6, 1, 6405, // 6, 0
- 5, 1, 6425, 5, 2, 4330, 6, 1, 48960, 6, 2, 5821, // 6, 1
- 5, 2, 5602, 5, 3, 3815, 6, 2, 50935, 6, 3, 5184, // 6, 2
- 5, 3, 4759, 5, 4, 3274, 6, 3, 53008, 6, 4, 4495, // 6, 3
- 5, 4, 3902, 5, 5, 2711, 6, 4, 55164, 6, 5, 3759, // 6, 4
- 5, 5, 3050, 5, 6, 2138, 6, 5, 57353, 6, 6, 2995, // 6, 5
- 5, 6, 2258, 5, 7, 1597, 6, 6, 59422, 6, 7, 2259, // 6, 6
- 5, 7, 1695, 5, 8, 1209, 6, 7, 60906, 6, 8, 1726, // 6, 7
- 6, 8, 60905, 6, 9, 1726, 7, 8, 1695, 7, 9, 1210, // 6, 8
- 6, 9, 59422, 6, 10, 2258, 7, 9, 2259, 7, 10, 1597, // 6, 9
- 6, 10, 57354, 6, 11, 2993, 7, 10, 3051, 7, 11, 2138, // 6,10
- 6, 11, 55166, 6, 12, 3755, 7, 11, 3904, 7, 12, 2711, // 6,11
- 6, 12, 53012, 6, 13, 4489, 7, 12, 4762, 7, 13, 3273, // 6,12
- 6, 13, 50942, 6, 14, 5175, 7, 13, 5606, 7, 14, 3813, // 6,13
- 6, 14, 48969, 6, 15, 5809, 7, 14, 6430, 7, 15, 4328, // 6,14
- 6, 15, 47098, 6, 16, 6391, 7, 15, 7233, 7, 16, 4814, // 6,15
- 6, 0, 7158, 6, 1, 4722, 7, 0, 47426, 7, 1, 6230, // 7, 0
- 6, 1, 6332, 6, 2, 4224, 7, 1, 49347, 7, 2, 5633, // 7, 1
- 6, 2, 5478, 6, 3, 3693, 7, 2, 51387, 7, 3, 4978, // 7, 2
- 6, 3, 4592, 6, 4, 3128, 7, 3, 53557, 7, 4, 4259, // 7, 3
- 6, 4, 3671, 6, 5, 2525, 7, 4, 55867, 7, 5, 3473, // 7, 4
- 6, 5, 2713, 6, 6, 1884, 7, 5, 58322, 7, 6, 2617, // 7, 5
- 6, 6, 1726, 6, 7, 1210, 7, 6, 60905, 7, 7, 1695, // 7, 6
- 6, 7, 789, 6, 8, 558, 7, 7, 63399, 7, 8, 790, // 7, 7
- 7, 8, 63399, 7, 9, 789, 8, 8, 789, 8, 9, 559, // 7, 8
- 7, 9, 60906, 7, 10, 1695, 8, 9, 1726, 8, 10, 1209, // 7, 9
- 7, 10, 58324, 7, 11, 2615, 8, 10, 2714, 8, 11, 1883, // 7,10
- 7, 11, 55870, 7, 12, 3469, 8, 11, 3672, 8, 12, 2525, // 7,11
- 7, 12, 53562, 7, 13, 4254, 8, 12, 4594, 8, 13, 3126, // 7,12
- 7, 13, 51395, 7, 14, 4970, 8, 13, 5480, 8, 14, 3691, // 7,13
- 7, 14, 49358, 7, 15, 5623, 8, 14, 6335, 8, 15, 4220, // 7,14
- 7, 15, 47440, 7, 16, 6217, 8, 15, 7161, 8, 16, 4718, // 7,15
- 7, -1, 4718, 7, 0, 7161, 8, -1, 6217, 8, 0, 47440, // 8, 0
- 7, 0, 4221, 7, 1, 6335, 8, 0, 5623, 8, 1, 49357, // 8, 1
- 7, 1, 3691, 7, 2, 5480, 8, 1, 4970, 8, 2, 51395, // 8, 2
- 7, 2, 3126, 7, 3, 4594, 8, 2, 4254, 8, 3, 53562, // 8, 3
- 7, 3, 2524, 7, 4, 3672, 8, 3, 3469, 8, 4, 55871, // 8, 4
- 7, 4, 1884, 7, 5, 2714, 8, 4, 2615, 8, 5, 58323, // 8, 5
- 7, 5, 1209, 7, 6, 1726, 8, 5, 1695, 8, 6, 60906, // 8, 6
- 7, 6, 558, 7, 7, 789, 8, 6, 789, 8, 7, 63400, // 8, 7
- 8, 7, 789, 8, 8, 63399, 9, 7, 558, 9, 8, 790, // 8, 8
- 8, 8, 1695, 8, 9, 60905, 9, 8, 1210, 9, 9, 1726, // 8, 9
- 8, 9, 2616, 8, 10, 58322, 9, 9, 1884, 9, 10, 2714, // 8,10
- 8, 10, 3473, 8, 11, 55867, 9, 10, 2525, 9, 11, 3671, // 8,11
- 8, 11, 4259, 8, 12, 53557, 9, 11, 3128, 9, 12, 4592, // 8,12
- 8, 12, 4978, 8, 13, 51387, 9, 12, 3693, 9, 13, 5478, // 8,13
- 8, 13, 5633, 8, 14, 49347, 9, 13, 4224, 9, 14, 6332, // 8,14
- 8, 14, 6230, 8, 15, 47426, 9, 14, 4722, 9, 15, 7158, // 8,15
- 8, -1, 4814, 8, 0, 7233, 9, -1, 6391, 9, 0, 47098, // 9, 0
- 8, 0, 4327, 8, 1, 6430, 9, 0, 5809, 9, 1, 48970, // 9, 1
- 8, 1, 3813, 8, 2, 5606, 9, 1, 5175, 9, 2, 50942, // 9, 2
- 8, 2, 3273, 8, 3, 4762, 9, 2, 4489, 9, 3, 53012, // 9, 3
- 8, 3, 2710, 8, 4, 3904, 9, 3, 3755, 9, 4, 55167, // 9, 4
- 8, 4, 2138, 8, 5, 3051, 9, 4, 2993, 9, 5, 57354, // 9, 5
- 8, 5, 1597, 8, 6, 2259, 9, 5, 2258, 9, 6, 59422, // 9, 6
- 8, 6, 1210, 8, 7, 1695, 9, 6, 1726, 9, 7, 60905, // 9, 7
- 9, 7, 1726, 9, 8, 60906, 10, 7, 1209, 10, 8, 1695, // 9, 8
- 9, 8, 2259, 9, 9, 59422, 10, 8, 1597, 10, 9, 2258, // 9, 9
- 9, 9, 2995, 9, 10, 57353, 10, 9, 2138, 10, 10, 3050, // 9,10
- 9, 10, 3759, 9, 11, 55164, 10, 10, 2711, 10, 11, 3902, // 9,11
- 9, 11, 4495, 9, 12, 53008, 10, 11, 3274, 10, 12, 4759, // 9,12
- 9, 12, 5184, 9, 13, 50935, 10, 12, 3815, 10, 13, 5602, // 9,13
- 9, 13, 5820, 9, 14, 48960, 10, 13, 4330, 10, 14, 6426, // 9,14
- 9, 14, 6405, 9, 15, 47086, 10, 14, 4818, 10, 15, 7227, // 9,15
- 9, -1, 4967, 9, 0, 7383, 10, -1, 6644, 10, 0, 46542, // 10, 0
- 9, 0, 4502, 9, 1, 6620, 10, 0, 6092, 10, 1, 48322, // 10, 1
- 9, 1, 4019, 9, 2, 5848, 10, 1, 5499, 10, 2, 50170, // 10, 2
- 9, 2, 3522, 9, 3, 5073, 10, 2, 4872, 10, 3, 52069, // 10, 3
- 9, 3, 3023, 9, 4, 4313, 10, 3, 4226, 10, 4, 53974, // 10, 4
- 9, 4, 2546, 9, 5, 3598, 10, 4, 3595, 10, 5, 55797, // 10, 5
- 9, 5, 2138, 9, 6, 2995, 10, 5, 3050, 10, 6, 57353, // 10, 6
- 9, 6, 1884, 9, 7, 2616, 10, 6, 2713, 10, 7, 58323, // 10, 7
- 10, 7, 2714, 10, 8, 58324, 11, 7, 1884, 11, 8, 2614, // 10, 8
- 10, 8, 3051, 10, 9, 57354, 11, 8, 2138, 11, 9, 2993, // 10, 9
- 10, 9, 3598, 10, 10, 55798, 11, 9, 2546, 11, 10, 3594, // 10,10
- 10, 10, 4230, 10, 11, 53973, 11, 10, 3023, 11, 11, 4310, // 10,11
- 10, 11, 4879, 10, 12, 52066, 11, 11, 3523, 11, 12, 5068, // 10,12
- 10, 12, 5508, 10, 13, 50165, 11, 12, 4020, 11, 13, 5843, // 10,13
- 10, 13, 6104, 10, 14, 48314, 11, 13, 4505, 11, 14, 6613, // 10,14
- 10, 14, 6659, 10, 15, 46532, 11, 14, 4971, 11, 15, 7374, // 10,15
- 10, -1, 5169, 10, 0, 7599, 11, -1, 6970, 11, 0, 45798, // 11, 0
- 10, 0, 4734, 10, 1, 6886, 11, 0, 6458, 11, 1, 47458, // 11, 1
- 10, 1, 4290, 10, 2, 6176, 11, 1, 5920, 11, 2, 49150, // 11, 2
- 10, 2, 3845, 10, 3, 5481, 11, 2, 5365, 11, 3, 50845, // 11, 3
- 10, 3, 3415, 10, 4, 4822, 11, 3, 4816, 11, 4, 52483, // 11, 4
- 10, 4, 3023, 10, 5, 4230, 11, 4, 4309, 11, 5, 53974, // 11, 5
- 10, 5, 2711, 10, 6, 3759, 11, 5, 3902, 11, 6, 55164, // 11, 6
- 10, 6, 2525, 10, 7, 3473, 11, 6, 3671, 11, 7, 55867, // 11, 7
- 11, 7, 3672, 11, 8, 55870, 12, 7, 2524, 12, 8, 3470, // 11, 8
- 11, 8, 3904, 11, 9, 55166, 12, 8, 2710, 12, 9, 3756, // 11, 9
- 11, 9, 4313, 11, 10, 53975, 12, 9, 3023, 12, 10, 4225, // 11,10
- 11, 10, 4822, 11, 11, 52484, 12, 10, 3415, 12, 11, 4815, // 11,11
- 11, 11, 5373, 11, 12, 50843, 12, 11, 3846, 12, 12, 5474, // 11,12
- 11, 12, 5930, 11, 13, 49147, 12, 12, 4291, 12, 13, 6168, // 11,13
- 11, 13, 6472, 11, 14, 47453, 12, 13, 4736, 12, 14, 6875, // 11,14
- 11, 14, 6986, 11, 15, 45791, 12, 14, 5172, 12, 15, 7587, // 11,15
- 11, -1, 5410, 11, 0, 7863, 12, -1, 7356, 12, 0, 44907, // 12, 0
- 11, 0, 5009, 11, 1, 7204, 12, 0, 6892, 12, 1, 46431, // 12, 1
- 11, 1, 4607, 11, 2, 6560, 12, 1, 6414, 12, 2, 47955, // 12, 2
- 11, 2, 4214, 11, 3, 5943, 12, 2, 5934, 12, 3, 49445, // 12, 3
- 11, 3, 3846, 11, 4, 5373, 12, 3, 5474, 12, 4, 50843, // 12, 4
- 11, 4, 3523, 11, 5, 4879, 12, 4, 5069, 12, 5, 52065, // 12, 5
- 11, 5, 3274, 11, 6, 4495, 12, 5, 4759, 12, 6, 53008, // 12, 6
- 11, 6, 3128, 11, 7, 4259, 12, 6, 4592, 12, 7, 53557, // 12, 7
- 12, 7, 4594, 12, 8, 53562, 13, 7, 3126, 13, 8, 4254, // 12, 8
- 12, 8, 4762, 12, 9, 53012, 13, 8, 3273, 13, 9, 4489, // 12, 9
- 12, 9, 5073, 12, 10, 52069, 13, 9, 3522, 13, 10, 4872, // 12,10
- 12, 10, 5481, 12, 11, 50844, 13, 10, 3845, 13, 11, 5366, // 12,11
- 12, 11, 5943, 12, 12, 49445, 13, 11, 4214, 13, 12, 5934, // 12,12
- 12, 12, 6426, 12, 13, 47953, 13, 12, 4608, 13, 13, 6549, // 12,13
- 12, 13, 6908, 12, 14, 46427, 13, 13, 5011, 13, 14, 7190, // 12,14
- 12, 14, 7374, 12, 15, 44901, 13, 14, 5413, 13, 15, 7848, // 12,15
- 12, -1, 5682, 12, 0, 8159, 13, -1, 7791, 13, 0, 43904, // 13, 0
- 12, 0, 5315, 12, 1, 7555, 13, 0, 7378, 13, 1, 45288, // 13, 1
- 12, 1, 4954, 12, 2, 6973, 13, 1, 6959, 13, 2, 46650, // 13, 2
- 12, 2, 4608, 12, 3, 6426, 13, 2, 6549, 13, 3, 47953, // 13, 3
- 12, 3, 4291, 12, 4, 5930, 13, 3, 6168, 13, 4, 49147, // 13, 4
- 12, 4, 4020, 12, 5, 5508, 13, 4, 5842, 13, 5, 50166, // 13, 5
- 12, 5, 3815, 12, 6, 5184, 13, 5, 5602, 13, 6, 50935, // 13, 6
- 12, 6, 3693, 12, 7, 4978, 13, 6, 5478, 13, 7, 51387, // 13, 7
- 13, 7, 5480, 13, 8, 51395, 14, 7, 3691, 14, 8, 4970, // 13, 8
- 13, 8, 5606, 13, 9, 50942, 14, 8, 3813, 14, 9, 5175, // 13, 9
- 13, 9, 5848, 13, 10, 50171, 14, 9, 4019, 14, 10, 5498, // 13,10
- 13, 10, 6176, 13, 11, 49150, 14, 10, 4290, 14, 11, 5920, // 13,11
- 13, 11, 6560, 13, 12, 47955, 14, 11, 4607, 14, 12, 6414, // 13,12
- 13, 12, 6973, 13, 13, 46650, 14, 12, 4954, 14, 13, 6959, // 13,13
- 13, 13, 7395, 13, 14, 45286, 14, 13, 5316, 14, 14, 7539, // 13,14
- 13, 14, 7812, 13, 15, 43900, 14, 14, 5684, 14, 15, 8140, // 13,15
- 13, -1, 5974, 13, 0, 8474, 14, -1, 8265, 14, 0, 42823, // 14, 0
- 13, 0, 5640, 13, 1, 7921, 14, 0, 7901, 14, 1, 44074, // 14, 1
- 13, 1, 5316, 13, 2, 7395, 14, 1, 7539, 14, 2, 45286, // 14, 2
- 13, 2, 5011, 13, 3, 6908, 14, 2, 7191, 14, 3, 46426, // 14, 3
- 13, 3, 4736, 13, 4, 6472, 14, 3, 6875, 14, 4, 47453, // 14, 4
- 13, 4, 4505, 13, 5, 6104, 14, 4, 6613, 14, 5, 48314, // 14, 5
- 13, 5, 4330, 13, 6, 5820, 14, 5, 6425, 14, 6, 48961, // 14, 6
- 13, 6, 4224, 13, 7, 5633, 14, 6, 6332, 14, 7, 49347, // 14, 7
- 14, 7, 6335, 14, 8, 49358, 15, 7, 4221, 15, 8, 5622, // 14, 8
- 14, 8, 6430, 14, 9, 48969, 15, 8, 4327, 15, 9, 5810, // 14, 9
- 14, 9, 6620, 14, 10, 48322, 15, 9, 4502, 15, 10, 6092, // 14,10
- 14, 10, 6886, 14, 11, 47458, 15, 10, 4734, 15, 11, 6458, // 14,11
- 14, 11, 7204, 14, 12, 46430, 15, 11, 5009, 15, 12, 6893, // 14,12
- 14, 12, 7555, 14, 13, 45288, 15, 12, 5315, 15, 13, 7378, // 14,13
- 14, 13, 7921, 14, 14, 44074, 15, 13, 5640, 15, 14, 7901, // 14,14
- 14, 14, 8288, 14, 15, 42821, 15, 14, 5975, 15, 15, 8452, // 14,15
- 14, -1, 6280, 14, 0, 8795, 15, -1, 8769, 15, 0, 41692, // 15, 0
- 14, 0, 5975, 14, 1, 8288, 15, 0, 8452, 15, 1, 42821, // 15, 1
- 14, 1, 5684, 14, 2, 7812, 15, 1, 8141, 15, 2, 43899, // 15, 2
- 14, 2, 5413, 14, 3, 7374, 15, 2, 7848, 15, 3, 44901, // 15, 3
- 14, 3, 5172, 14, 4, 6986, 15, 3, 7587, 15, 4, 45791, // 15, 4
- 14, 4, 4971, 14, 5, 6659, 15, 4, 7374, 15, 5, 46532, // 15, 5
- 14, 5, 4818, 14, 6, 6405, 15, 5, 7227, 15, 6, 47086, // 15, 6
- 14, 6, 4722, 14, 7, 6230, 15, 6, 7158, 15, 7, 47426, // 15, 7
- 15, 7, 7161, 15, 8, 47440, 16, 7, 4718, 16, 8, 6217, // 15, 8
- 15, 8, 7233, 15, 9, 47098, 16, 8, 4814, 16, 9, 6391, // 15, 9
- 15, 9, 7383, 15, 10, 46541, 16, 9, 4967, 16, 10, 6645, // 15,10
- 15, 10, 7599, 15, 11, 45799, 16, 10, 5169, 16, 11, 6969, // 15,11
- 15, 11, 7863, 15, 12, 44907, 16, 11, 5410, 16, 12, 7356, // 15,12
- 15, 12, 8159, 15, 13, 43904, 16, 12, 5682, 16, 13, 7791, // 15,13
- 15, 13, 8474, 15, 14, 42823, 16, 13, 5974, 16, 14, 8265, // 15,14
- 15, 14, 8795, 15, 15, 41693, 16, 14, 6280, 16, 15, 8768, // 15,15
- // angle of -0.5 degrees
- -1, 0, 5106, -1, 1, 3621, 0, 0, 51699, 0, 1, 5110, // 0, 0
- -1, 1, 4803, -1, 2, 3421, 0, 1, 52457, 0, 2, 4855, // 0, 1
- -1, 2, 4521, -1, 3, 3235, 0, 2, 53168, 0, 3, 4612, // 0, 2
- -1, 3, 4264, -1, 4, 3064, 0, 3, 53815, 0, 4, 4393, // 0, 3
- -1, 4, 4041, -1, 5, 2916, 0, 4, 54378, 0, 5, 4201, // 0, 4
- -1, 5, 3858, -1, 6, 2796, 0, 5, 54835, 0, 6, 4047, // 0, 5
- -1, 6, 3722, -1, 7, 2709, 0, 6, 55166, 0, 7, 3939, // 0, 6
- -1, 7, 3638, -1, 8, 2659, 0, 7, 55354, 0, 8, 3885, // 0, 7
- 0, 8, 55352, 0, 9, 3885, 1, 8, 3640, 1, 9, 2659, // 0, 8
- 0, 9, 55164, 0, 10, 3939, 1, 9, 3724, 1, 10, 2709, // 0, 9
- 0, 10, 54833, 0, 11, 4046, 1, 10, 3860, 1, 11, 2797, // 0,10
- 0, 11, 54376, 0, 12, 4200, 1, 11, 4043, 1, 12, 2917, // 0,11
- 0, 12, 53814, 0, 13, 4390, 1, 12, 4267, 1, 13, 3065, // 0,12
- 0, 13, 53168, 0, 14, 4610, 1, 13, 4523, 1, 14, 3235, // 0,13
- 0, 14, 52457, 0, 15, 4851, 1, 14, 4806, 1, 15, 3422, // 0,14
- 0, 15, 51699, 0, 16, 5106, 1, 15, 5110, 1, 16, 3621, // 0,15
- 0, 0, 4851, 0, 1, 3422, 1, 0, 52457, 1, 1, 4806, // 1, 0
- 0, 1, 4522, 0, 2, 3204, 1, 1, 53285, 1, 2, 4525, // 1, 1
- 0, 2, 4212, 0, 3, 2998, 1, 2, 54072, 1, 3, 4254, // 1, 2
- 0, 3, 3927, 0, 4, 2808, 1, 3, 54796, 1, 4, 4005, // 1, 3
- 0, 4, 3677, 0, 5, 2640, 1, 4, 55435, 1, 5, 3784, // 1, 4
- 0, 5, 3470, 0, 6, 2502, 1, 5, 55959, 1, 6, 3605, // 1, 5
- 0, 6, 3317, 0, 7, 2402, 1, 6, 56340, 1, 7, 3477, // 1, 6
- 0, 7, 3225, 0, 8, 2346, 1, 7, 56554, 1, 8, 3411, // 1, 7
- 1, 8, 56552, 1, 9, 3411, 2, 8, 3227, 2, 9, 2346, // 1, 8
- 1, 9, 56339, 1, 10, 3476, 2, 9, 3319, 2, 10, 2402, // 1, 9
- 1, 10, 55958, 1, 11, 3604, 2, 10, 3472, 2, 11, 2502, // 1,10
- 1, 11, 55434, 1, 12, 3783, 2, 11, 3678, 2, 12, 2641, // 1,11
- 1, 12, 54796, 1, 13, 4003, 2, 12, 3929, 2, 13, 2808, // 1,12
- 1, 13, 54071, 1, 14, 4253, 2, 13, 4214, 2, 14, 2998, // 1,13
- 1, 14, 53285, 1, 15, 4522, 2, 14, 4525, 2, 15, 3204, // 1,14
- 1, 15, 52457, 1, 16, 4803, 2, 15, 4854, 2, 16, 3422, // 1,15
- 1, 0, 4610, 1, 1, 3235, 2, 0, 53168, 2, 1, 4523, // 2, 0
- 1, 1, 4253, 1, 2, 2998, 2, 1, 54071, 2, 2, 4214, // 2, 1
- 1, 2, 3911, 1, 3, 2770, 2, 2, 54941, 2, 3, 3914, // 2, 2
- 1, 3, 3594, 1, 4, 2556, 2, 3, 55756, 2, 4, 3630, // 2, 3
- 1, 4, 3310, 1, 5, 2365, 2, 4, 56487, 2, 5, 3374, // 2, 4
- 1, 5, 3073, 1, 6, 2205, 2, 5, 57096, 2, 6, 3162, // 2, 5
- 1, 6, 2897, 1, 7, 2088, 2, 6, 57545, 2, 7, 3006, // 2, 6
- 1, 7, 2794, 1, 8, 2022, 2, 7, 57795, 2, 8, 2925, // 2, 7
- 2, 8, 57793, 2, 9, 2926, 3, 8, 2795, 3, 9, 2022, // 2, 8
- 2, 9, 57544, 2, 10, 3007, 3, 9, 2898, 3, 10, 2087, // 2, 9
- 2, 10, 57095, 2, 11, 3161, 3, 10, 3074, 3, 11, 2206, // 2,10
- 2, 11, 56486, 2, 12, 3373, 3, 11, 3311, 3, 12, 2366, // 2,11
- 2, 12, 55756, 2, 13, 3628, 3, 12, 3595, 3, 13, 2557, // 2,12
- 2, 13, 54941, 2, 14, 3911, 3, 13, 3913, 3, 14, 2771, // 2,13
- 2, 14, 54072, 2, 15, 4212, 3, 14, 4255, 3, 15, 2997, // 2,14
- 2, 15, 53168, 2, 16, 4521, 3, 15, 4612, 3, 16, 3235, // 2,15
- 2, 0, 4390, 2, 1, 3065, 3, 0, 53814, 3, 1, 4267, // 3, 0
- 2, 1, 4003, 2, 2, 2808, 3, 1, 54796, 3, 2, 3929, // 3, 1
- 2, 2, 3628, 2, 3, 2557, 3, 2, 55756, 3, 3, 3595, // 3, 2
- 2, 3, 3273, 2, 4, 2317, 3, 3, 56673, 3, 4, 3273, // 3, 3
- 2, 4, 2948, 2, 5, 2096, 3, 4, 57514, 3, 5, 2978, // 3, 4
- 2, 5, 2672, 2, 6, 1908, 3, 5, 58234, 3, 6, 2722, // 3, 5
- 2, 6, 2463, 2, 7, 1766, 3, 6, 58775, 3, 7, 2532, // 3, 6
- 2, 7, 2342, 2, 8, 1687, 3, 7, 59077, 3, 8, 2430, // 3, 7
- 3, 8, 59076, 3, 9, 2430, 4, 8, 2343, 4, 9, 1687, // 3, 8
- 3, 9, 58774, 3, 10, 2532, 4, 9, 2464, 4, 10, 1766, // 3, 9
- 3, 10, 58233, 3, 11, 2722, 4, 10, 2673, 4, 11, 1908, // 3,10
- 3, 11, 57514, 3, 12, 2976, 4, 11, 2950, 4, 12, 2096, // 3,11
- 3, 12, 56673, 3, 13, 3273, 4, 12, 3274, 4, 13, 2316, // 3,12
- 3, 13, 55756, 3, 14, 3594, 4, 13, 3630, 4, 14, 2556, // 3,13
- 3, 14, 54796, 3, 15, 3927, 4, 14, 4005, 4, 15, 2808, // 3,14
- 3, 15, 53815, 3, 16, 4264, 4, 15, 4392, 4, 16, 3065, // 3,15
- 3, 0, 4200, 3, 1, 2917, 4, 0, 54376, 4, 1, 4043, // 4, 0
- 3, 1, 3783, 3, 2, 2640, 4, 1, 55434, 4, 2, 3679, // 4, 1
- 3, 2, 3373, 3, 3, 2365, 4, 2, 56486, 4, 3, 3312, // 4, 2
- 3, 3, 2976, 3, 4, 2096, 4, 3, 57514, 4, 4, 2950, // 4, 3
- 3, 4, 2604, 3, 5, 1843, 4, 4, 58484, 4, 5, 2605, // 4, 4
- 3, 5, 2276, 3, 6, 1617, 4, 5, 59346, 4, 6, 2297, // 4, 5
- 3, 6, 2020, 3, 7, 1442, 4, 6, 60018, 4, 7, 2056, // 4, 6
- 3, 7, 1871, 3, 8, 1341, 4, 7, 60402, 4, 8, 1922, // 4, 7
- 4, 8, 60402, 4, 9, 1922, 5, 8, 1871, 5, 9, 1341, // 4, 8
- 4, 9, 60017, 4, 10, 2057, 5, 9, 2020, 5, 10, 1442, // 4, 9
- 4, 10, 59345, 4, 11, 2297, 5, 10, 2276, 5, 11, 1618, // 4,10
- 4, 11, 58484, 4, 12, 2604, 5, 11, 2605, 5, 12, 1843, // 4,11
- 4, 12, 57514, 4, 13, 2948, 5, 12, 2977, 5, 13, 2097, // 4,12
- 4, 13, 56487, 4, 14, 3310, 5, 13, 3374, 5, 14, 2365, // 4,13
- 4, 14, 55435, 4, 15, 3677, 5, 14, 3785, 5, 15, 2639, // 4,14
- 4, 15, 54378, 4, 16, 4041, 5, 15, 4201, 5, 16, 2916, // 4,15
- 4, 0, 4046, 4, 1, 2797, 5, 0, 54833, 5, 1, 3860, // 5, 0
- 4, 1, 3604, 4, 2, 2503, 5, 1, 55958, 5, 2, 3471, // 5, 1
- 4, 2, 3161, 4, 3, 2205, 5, 2, 57095, 5, 3, 3075, // 5, 2
- 4, 3, 2722, 4, 4, 1908, 5, 3, 58233, 5, 4, 2673, // 5, 3
- 4, 4, 2297, 4, 5, 1617, 5, 4, 59345, 5, 5, 2277, // 5, 4
- 4, 5, 1904, 4, 6, 1347, 5, 5, 60381, 5, 6, 1904, // 5, 5
- 4, 6, 1578, 4, 7, 1121, 5, 6, 61243, 5, 7, 1594, // 5, 6
- 4, 7, 1380, 4, 8, 985, 5, 7, 61767, 5, 8, 1404, // 5, 7
- 5, 8, 61767, 5, 9, 1405, 6, 8, 1380, 6, 9, 984, // 5, 8
- 5, 9, 61243, 5, 10, 1593, 6, 9, 1579, 6, 10, 1121, // 5, 9
- 5, 10, 60381, 5, 11, 1904, 6, 10, 1904, 6, 11, 1347, // 5,10
- 5, 11, 59346, 5, 12, 2276, 6, 11, 2297, 6, 12, 1617, // 5,11
- 5, 12, 58234, 5, 13, 2672, 6, 12, 2723, 6, 13, 1907, // 5,12
- 5, 13, 57096, 5, 14, 3073, 6, 13, 3161, 6, 14, 2206, // 5,13
- 5, 14, 55959, 5, 15, 3470, 6, 14, 3605, 6, 15, 2502, // 5,14
- 5, 15, 54835, 5, 16, 3858, 6, 15, 4047, 6, 16, 2796, // 5,15
- 5, 0, 3939, 5, 1, 2709, 6, 0, 55164, 6, 1, 3724, // 6, 0
- 5, 1, 3476, 5, 2, 2403, 6, 1, 56339, 6, 2, 3318, // 6, 1
- 5, 2, 3007, 5, 3, 2088, 6, 2, 57544, 6, 3, 2897, // 6, 2
- 5, 3, 2532, 5, 4, 1767, 6, 3, 58774, 6, 4, 2463, // 6, 3
- 5, 4, 2057, 5, 5, 1442, 6, 4, 60017, 6, 5, 2020, // 6, 4
- 5, 5, 1593, 5, 6, 1121, 6, 5, 61243, 6, 6, 1579, // 6, 5
- 5, 6, 1170, 5, 7, 827, 6, 6, 62369, 6, 7, 1170, // 6, 6
- 5, 7, 875, 5, 8, 622, 6, 7, 63156, 6, 8, 883, // 6, 7
- 6, 8, 63156, 6, 9, 883, 7, 8, 875, 7, 9, 622, // 6, 8
- 6, 9, 62369, 6, 10, 1170, 7, 9, 1170, 7, 10, 827, // 6, 9
- 6, 10, 61243, 6, 11, 1578, 7, 10, 1593, 7, 11, 1122, // 6,10
- 6, 11, 60018, 6, 12, 2020, 7, 11, 2057, 7, 12, 1441, // 6,11
- 6, 12, 58775, 6, 13, 2463, 7, 12, 2532, 7, 13, 1766, // 6,12
- 6, 13, 57545, 6, 14, 2897, 7, 13, 3007, 7, 14, 2087, // 6,13
- 6, 14, 56340, 6, 15, 3317, 7, 14, 3477, 7, 15, 2402, // 6,14
- 6, 15, 55166, 6, 16, 3722, 7, 15, 3940, 7, 16, 2708, // 6,15
- 6, 0, 3885, 6, 1, 2659, 7, 0, 55352, 7, 1, 3640, // 7, 0
- 6, 1, 3411, 6, 2, 2346, 7, 1, 56552, 7, 2, 3227, // 7, 1
- 6, 2, 2926, 6, 3, 2022, 7, 2, 57793, 7, 3, 2795, // 7, 2
- 6, 3, 2430, 6, 4, 1687, 7, 3, 59076, 7, 4, 2343, // 7, 3
- 6, 4, 1922, 6, 5, 1341, 7, 4, 60402, 7, 5, 1871, // 7, 4
- 6, 5, 1405, 6, 6, 985, 7, 5, 61767, 7, 6, 1379, // 7, 5
- 6, 6, 883, 6, 7, 622, 7, 6, 63156, 7, 7, 875, // 7, 6
- 6, 7, 399, 6, 8, 282, 7, 7, 64455, 7, 8, 400, // 7, 7
- 7, 8, 64455, 7, 9, 399, 8, 8, 399, 8, 9, 283, // 7, 8
- 7, 9, 63156, 7, 10, 875, 8, 9, 883, 8, 10, 622, // 7, 9
- 7, 10, 61767, 7, 11, 1380, 8, 10, 1405, 8, 11, 984, // 7,10
- 7, 11, 60402, 7, 12, 1871, 8, 11, 1922, 8, 12, 1341, // 7,11
- 7, 12, 59077, 7, 13, 2342, 8, 12, 2430, 8, 13, 1687, // 7,12
- 7, 13, 57795, 7, 14, 2794, 8, 13, 2926, 8, 14, 2021, // 7,13
- 7, 14, 56554, 7, 15, 3225, 8, 14, 3411, 8, 15, 2346, // 7,14
- 7, 15, 55354, 7, 16, 3638, 8, 15, 3885, 8, 16, 2659, // 7,15
- 7, -1, 2659, 7, 0, 3885, 8, -1, 3638, 8, 0, 55354, // 8, 0
- 7, 0, 2346, 7, 1, 3411, 8, 0, 3225, 8, 1, 56554, // 8, 1
- 7, 1, 2022, 7, 2, 2926, 8, 1, 2794, 8, 2, 57794, // 8, 2
- 7, 2, 1687, 7, 3, 2430, 8, 2, 2342, 8, 3, 59077, // 8, 3
- 7, 3, 1341, 7, 4, 1922, 8, 3, 1871, 8, 4, 60402, // 8, 4
- 7, 4, 985, 7, 5, 1405, 8, 4, 1380, 8, 5, 61766, // 8, 5
- 7, 5, 622, 7, 6, 883, 8, 5, 875, 8, 6, 63156, // 8, 6
- 7, 6, 282, 7, 7, 399, 8, 6, 399, 8, 7, 64456, // 8, 7
- 8, 7, 399, 8, 8, 64455, 9, 7, 282, 9, 8, 400, // 8, 8
- 8, 8, 875, 8, 9, 63156, 9, 8, 622, 9, 9, 883, // 8, 9
- 8, 9, 1380, 8, 10, 61767, 9, 9, 985, 9, 10, 1404, // 8,10
- 8, 10, 1871, 8, 11, 60402, 9, 10, 1341, 9, 11, 1922, // 8,11
- 8, 11, 2343, 8, 12, 59076, 9, 11, 1687, 9, 12, 2430, // 8,12
- 8, 12, 2795, 8, 13, 57793, 9, 12, 2022, 9, 13, 2926, // 8,13
- 8, 13, 3227, 8, 14, 56552, 9, 13, 2346, 9, 14, 3411, // 8,14
- 8, 14, 3640, 8, 15, 55352, 9, 14, 2659, 9, 15, 3885, // 8,15
- 8, -1, 2709, 8, 0, 3940, 9, -1, 3722, 9, 0, 55165, // 9, 0
- 8, 0, 2402, 8, 1, 3477, 9, 0, 3317, 9, 1, 56340, // 9, 1
- 8, 1, 2088, 8, 2, 3007, 9, 1, 2897, 9, 2, 57544, // 9, 2
- 8, 2, 1766, 8, 3, 2532, 9, 2, 2463, 9, 3, 58775, // 9, 3
- 8, 3, 1442, 8, 4, 2057, 9, 3, 2020, 9, 4, 60017, // 9, 4
- 8, 4, 1121, 8, 5, 1593, 9, 4, 1578, 9, 5, 61244, // 9, 5
- 8, 5, 827, 8, 6, 1170, 9, 5, 1170, 9, 6, 62369, // 9, 6
- 8, 6, 622, 8, 7, 875, 9, 6, 883, 9, 7, 63156, // 9, 7
- 9, 7, 883, 9, 8, 63156, 10, 7, 622, 10, 8, 875, // 9, 8
- 9, 8, 1170, 9, 9, 62369, 10, 8, 827, 10, 9, 1170, // 9, 9
- 9, 9, 1579, 9, 10, 61243, 10, 9, 1121, 10, 10, 1593, // 9,10
- 9, 10, 2020, 9, 11, 60017, 10, 10, 1442, 10, 11, 2057, // 9,11
- 9, 11, 2464, 9, 12, 58774, 10, 11, 1767, 10, 12, 2531, // 9,12
- 9, 12, 2898, 9, 13, 57544, 10, 12, 2088, 10, 13, 3006, // 9,13
- 9, 13, 3319, 9, 14, 56339, 10, 13, 2403, 10, 14, 3475, // 9,14
- 9, 14, 3724, 9, 15, 55164, 10, 14, 2709, 10, 15, 3939, // 9,15
- 9, -1, 2796, 9, 0, 4047, 10, -1, 3858, 10, 0, 54835, // 10, 0
- 9, 0, 2502, 9, 1, 3605, 10, 0, 3470, 10, 1, 55959, // 10, 1
- 9, 1, 2205, 9, 2, 3161, 10, 1, 3073, 10, 2, 57097, // 10, 2
- 9, 2, 1908, 9, 3, 2723, 10, 2, 2672, 10, 3, 58233, // 10, 3
- 9, 3, 1617, 9, 4, 2297, 10, 3, 2276, 10, 4, 59346, // 10, 4
- 9, 4, 1347, 9, 5, 1904, 10, 4, 1904, 10, 5, 60381, // 10, 5
- 9, 5, 1121, 9, 6, 1579, 10, 5, 1593, 10, 6, 61243, // 10, 6
- 9, 6, 985, 9, 7, 1380, 10, 6, 1405, 10, 7, 61766, // 10, 7
- 10, 7, 1405, 10, 8, 61767, 11, 7, 985, 11, 8, 1379, // 10, 8
- 10, 8, 1593, 10, 9, 61243, 11, 8, 1121, 11, 9, 1579, // 10, 9
- 10, 9, 1904, 10, 10, 60381, 11, 9, 1347, 11, 10, 1904, // 10,10
- 10, 10, 2276, 10, 11, 59345, 11, 10, 1617, 11, 11, 2298, // 10,11
- 10, 11, 2673, 10, 12, 58233, 11, 11, 1908, 11, 12, 2722, // 10,12
- 10, 12, 3074, 10, 13, 57095, 11, 12, 2205, 11, 13, 3162, // 10,13
- 10, 13, 3472, 10, 14, 55958, 11, 13, 2503, 11, 14, 3603, // 10,14
- 10, 14, 3860, 10, 15, 54833, 11, 14, 2797, 11, 15, 4046, // 10,15
- 10, -1, 2916, 10, 0, 4201, 11, -1, 4041, 11, 0, 54378, // 11, 0
- 10, 0, 2640, 10, 1, 3785, 11, 0, 3677, 11, 1, 55434, // 11, 1
- 10, 1, 2365, 10, 2, 3374, 11, 1, 3310, 11, 2, 56487, // 11, 2
- 10, 2, 2096, 10, 3, 2977, 11, 2, 2948, 11, 3, 57515, // 11, 3
- 10, 3, 1843, 10, 4, 2605, 11, 3, 2604, 11, 4, 58484, // 11, 4
- 10, 4, 1617, 10, 5, 2276, 11, 4, 2297, 11, 5, 59346, // 11, 5
- 10, 5, 1442, 10, 6, 2020, 11, 5, 2057, 11, 6, 60017, // 11, 6
- 10, 6, 1341, 10, 7, 1871, 11, 6, 1922, 11, 7, 60402, // 11, 7
- 11, 7, 1922, 11, 8, 60402, 12, 7, 1341, 12, 8, 1871, // 11, 8
- 11, 8, 2057, 11, 9, 60018, 12, 8, 1442, 12, 9, 2019, // 11, 9
- 11, 9, 2297, 11, 10, 59346, 12, 9, 1617, 12, 10, 2276, // 11,10
- 11, 10, 2605, 11, 11, 58484, 12, 10, 1843, 12, 11, 2604, // 11,11
- 11, 11, 2950, 11, 12, 57514, 12, 11, 2096, 12, 12, 2976, // 11,12
- 11, 12, 3311, 11, 13, 56486, 12, 12, 2365, 12, 13, 3374, // 11,13
- 11, 13, 3678, 11, 14, 55434, 12, 13, 2640, 12, 14, 3784, // 11,14
- 11, 14, 4043, 11, 15, 54376, 12, 14, 2917, 12, 15, 4200, // 11,15
- 11, -1, 3064, 11, 0, 4392, 12, -1, 4264, 12, 0, 53816, // 12, 0
- 11, 0, 2808, 11, 1, 4005, 12, 0, 3927, 12, 1, 54796, // 12, 1
- 11, 1, 2556, 11, 2, 3630, 12, 1, 3594, 12, 2, 55756, // 12, 2
- 11, 2, 2317, 11, 3, 3274, 12, 2, 3273, 12, 3, 56672, // 12, 3
- 11, 3, 2096, 11, 4, 2950, 12, 3, 2976, 12, 4, 57514, // 12, 4
- 11, 4, 1908, 11, 5, 2673, 12, 4, 2722, 12, 5, 58233, // 12, 5
- 11, 5, 1767, 11, 6, 2464, 12, 5, 2532, 12, 6, 58773, // 12, 6
- 11, 6, 1687, 11, 7, 2343, 12, 6, 2430, 12, 7, 59076, // 12, 7
- 12, 7, 2430, 12, 8, 59077, 13, 7, 1687, 13, 8, 2342, // 12, 8
- 12, 8, 2532, 12, 9, 58775, 13, 8, 1766, 13, 9, 2463, // 12, 9
- 12, 9, 2723, 12, 10, 58234, 13, 9, 1908, 13, 10, 2671, // 12,10
- 12, 10, 2977, 12, 11, 57514, 13, 10, 2096, 13, 11, 2949, // 12,11
- 12, 11, 3274, 12, 12, 56673, 13, 11, 2317, 13, 12, 3272, // 12,12
- 12, 12, 3595, 12, 13, 55756, 13, 12, 2557, 13, 13, 3628, // 12,13
- 12, 13, 3929, 12, 14, 54796, 13, 13, 2808, 13, 14, 4003, // 12,14
- 12, 14, 4267, 12, 15, 53814, 13, 14, 3065, 13, 15, 4390, // 12,15
- 12, -1, 3235, 12, 0, 4612, 13, -1, 4521, 13, 0, 53168, // 13, 0
- 12, 0, 2998, 12, 1, 4255, 13, 0, 4212, 13, 1, 54071, // 13, 1
- 12, 1, 2770, 12, 2, 3913, 13, 1, 3911, 13, 2, 54942, // 13, 2
- 12, 2, 2557, 12, 3, 3595, 13, 2, 3628, 13, 3, 55756, // 13, 3
- 12, 3, 2365, 12, 4, 3311, 13, 3, 3373, 13, 4, 56487, // 13, 4
- 12, 4, 2205, 12, 5, 3074, 13, 4, 3161, 13, 5, 57096, // 13, 5
- 12, 5, 2088, 12, 6, 2898, 13, 5, 3007, 13, 6, 57543, // 13, 6
- 12, 6, 2022, 12, 7, 2795, 13, 6, 2926, 13, 7, 57793, // 13, 7
- 13, 7, 2926, 13, 8, 57795, 14, 7, 2022, 14, 8, 2793, // 13, 8
- 13, 8, 3007, 13, 9, 57545, 14, 8, 2088, 14, 9, 2896, // 13, 9
- 13, 9, 3161, 13, 10, 57096, 14, 9, 2205, 14, 10, 3074, // 13,10
- 13, 10, 3374, 13, 11, 56487, 14, 10, 2365, 14, 11, 3310, // 13,11
- 13, 11, 3630, 13, 12, 55756, 14, 11, 2556, 14, 12, 3594, // 13,12
- 13, 12, 3913, 13, 13, 54941, 14, 12, 2770, 14, 13, 3912, // 13,13
- 13, 13, 4214, 13, 14, 54071, 14, 13, 2998, 14, 14, 4253, // 13,14
- 13, 14, 4523, 13, 15, 53168, 14, 14, 3235, 14, 15, 4610, // 13,15
- 13, -1, 3421, 13, 0, 4854, 14, -1, 4803, 14, 0, 52458, // 14, 0
- 13, 0, 3204, 13, 1, 4525, 14, 0, 4522, 14, 1, 53285, // 14, 1
- 13, 1, 2998, 13, 2, 4214, 14, 1, 4253, 14, 2, 54071, // 14, 2
- 13, 2, 2808, 13, 3, 3929, 14, 2, 4003, 14, 3, 54796, // 14, 3
- 13, 3, 2640, 13, 4, 3678, 14, 3, 3783, 14, 4, 55435, // 14, 4
- 13, 4, 2503, 13, 5, 3472, 14, 4, 3604, 14, 5, 55957, // 14, 5
- 13, 5, 2403, 13, 6, 3319, 14, 5, 3476, 14, 6, 56338, // 14, 6
- 13, 6, 2346, 13, 7, 3227, 14, 6, 3411, 14, 7, 56552, // 14, 7
- 14, 7, 3411, 14, 8, 56554, 15, 7, 2346, 15, 8, 3225, // 14, 8
- 14, 8, 3477, 14, 9, 56340, 15, 8, 2402, 15, 9, 3317, // 14, 9
- 14, 9, 3605, 14, 10, 55959, 15, 9, 2502, 15, 10, 3470, // 14,10
- 14, 10, 3785, 14, 11, 55435, 15, 10, 2640, 15, 11, 3676, // 14,11
- 14, 11, 4005, 14, 12, 54796, 15, 11, 2808, 15, 12, 3927, // 14,12
- 14, 12, 4255, 14, 13, 54072, 15, 12, 2998, 15, 13, 4211, // 14,13
- 14, 13, 4525, 14, 14, 53285, 15, 13, 3204, 15, 14, 4522, // 14,14
- 14, 14, 4806, 14, 15, 52457, 15, 14, 3422, 15, 15, 4851, // 14,15
- 14, -1, 3621, 14, 0, 5110, 15, -1, 5106, 15, 0, 51699, // 15, 0
- 14, 0, 3422, 14, 1, 4806, 15, 0, 4851, 15, 1, 52457, // 15, 1
- 14, 1, 3235, 14, 2, 4523, 15, 1, 4610, 15, 2, 53168, // 15, 2
- 14, 2, 3065, 14, 3, 4267, 15, 2, 4390, 15, 3, 53814, // 15, 3
- 14, 3, 2917, 14, 4, 4043, 15, 3, 4200, 15, 4, 54376, // 15, 4
- 14, 4, 2797, 14, 5, 3860, 15, 4, 4046, 15, 5, 54833, // 15, 5
- 14, 5, 2709, 14, 6, 3724, 15, 5, 3939, 15, 6, 55164, // 15, 6
- 14, 6, 2659, 14, 7, 3640, 15, 6, 3885, 15, 7, 55352, // 15, 7
- 15, 7, 3885, 15, 8, 55354, 16, 7, 2659, 16, 8, 3638, // 15, 8
- 15, 8, 3940, 15, 9, 55166, 16, 8, 2709, 16, 9, 3721, // 15, 9
- 15, 9, 4047, 15, 10, 54835, 16, 9, 2796, 16, 10, 3858, // 15,10
- 15, 10, 4201, 15, 11, 54378, 16, 10, 2916, 16, 11, 4041, // 15,11
- 15, 11, 4392, 15, 12, 53815, 16, 11, 3064, 16, 12, 4265, // 15,12
- 15, 12, 4612, 15, 13, 53168, 16, 12, 3235, 16, 13, 4521, // 15,13
- 15, 13, 4854, 15, 14, 52457, 16, 13, 3421, 16, 14, 4804, // 15,14
- 15, 14, 5110, 15, 15, 51699, 16, 14, 3621, 16, 15, 5106, // 15,15
- // angle of 0.0 degrees
- 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, // 0, 0
- 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, // 0, 1
- 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, // 0, 2
- 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, // 0, 3
- 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, // 0, 4
- 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, // 0, 5
- 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, // 0, 6
- 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, // 0, 7
- 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, // 0, 8
- 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, // 0, 9
- 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, // 0,10
- 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, // 0,11
- 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, // 0,12
- 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, // 0,13
- 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, // 0,14
- 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, // 0,15
- 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, // 1, 0
- 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, // 1, 1
- 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, // 1, 2
- 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, // 1, 3
- 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, // 1, 4
- 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, // 1, 5
- 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, // 1, 6
- 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, // 1, 7
- 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, // 1, 8
- 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, // 1, 9
- 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, // 1,10
- 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, // 1,11
- 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, // 1,12
- 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, // 1,13
- 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, // 1,14
- 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, // 1,15
- 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, // 2, 0
- 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, // 2, 1
- 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, // 2, 2
- 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, // 2, 3
- 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, // 2, 4
- 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, // 2, 5
- 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, // 2, 6
- 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, // 2, 7
- 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, // 2, 8
- 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, // 2, 9
- 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, // 2,10
- 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, // 2,11
- 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, // 2,12
- 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, // 2,13
- 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, // 2,14
- 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, // 2,15
- 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, // 3, 0
- 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, // 3, 1
- 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, // 3, 2
- 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, // 3, 3
- 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, // 3, 4
- 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, // 3, 5
- 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, // 3, 6
- 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, // 3, 7
- 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, // 3, 8
- 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, // 3, 9
- 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, // 3,10
- 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, // 3,11
- 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, // 3,12
- 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, // 3,13
- 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, // 3,14
- 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, // 3,15
- 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, // 4, 0
- 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, // 4, 1
- 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, // 4, 2
- 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, // 4, 3
- 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, // 4, 4
- 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, // 4, 5
- 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, // 4, 6
- 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, // 4, 7
- 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, // 4, 8
- 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, // 4, 9
- 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, // 4,10
- 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, // 4,11
- 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, // 4,12
- 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, // 4,13
- 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, // 4,14
- 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, // 4,15
- 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, // 5, 0
- 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, // 5, 1
- 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, // 5, 2
- 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, // 5, 3
- 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, // 5, 4
- 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, // 5, 5
- 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, // 5, 6
- 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, // 5, 7
- 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, // 5, 8
- 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, // 5, 9
- 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, // 5,10
- 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, // 5,11
- 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, // 5,12
- 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, // 5,13
- 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, // 5,14
- 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, // 5,15
- 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, // 6, 0
- 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, // 6, 1
- 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, // 6, 2
- 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, // 6, 3
- 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, // 6, 4
- 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, // 6, 5
- 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, // 6, 6
- 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, // 6, 7
- 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, // 6, 8
- 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, // 6, 9
- 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, // 6,10
- 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, // 6,11
- 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, // 6,12
- 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, // 6,13
- 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, // 6,14
- 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, // 6,15
- 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, // 7, 0
- 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, // 7, 1
- 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, // 7, 2
- 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, // 7, 3
- 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, // 7, 4
- 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, // 7, 5
- 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, // 7, 6
- 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, // 7, 7
- 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, // 7, 8
- 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, // 7, 9
- 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, // 7,10
- 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, // 7,11
- 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, // 7,12
- 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, // 7,13
- 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, // 7,14
- 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, // 7,15
- 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, // 8, 0
- 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, // 8, 1
- 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, // 8, 2
- 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, // 8, 3
- 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, // 8, 4
- 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, // 8, 5
- 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, // 8, 6
- 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, // 8, 7
- 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, // 8, 8
- 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, // 8, 9
- 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, // 8,10
- 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, // 8,11
- 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, // 8,12
- 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, // 8,13
- 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, // 8,14
- 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, // 8,15
- 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, // 9, 0
- 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, // 9, 1
- 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, // 9, 2
- 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, // 9, 3
- 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, // 9, 4
- 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, // 9, 5
- 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, // 9, 6
- 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, // 9, 7
- 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, // 9, 8
- 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, // 9, 9
- 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, // 9,10
- 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, // 9,11
- 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, // 9,12
- 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, // 9,13
- 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, // 9,14
- 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, // 9,15
- 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, // 10, 0
- 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, // 10, 1
- 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, // 10, 2
- 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, // 10, 3
- 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, // 10, 4
- 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, // 10, 5
- 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, // 10, 6
- 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, // 10, 7
- 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, // 10, 8
- 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, // 10, 9
- 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, // 10,10
- 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, // 10,11
- 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, // 10,12
- 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, // 10,13
- 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, // 10,14
- 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, // 10,15
- 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, // 11, 0
- 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, // 11, 1
- 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, // 11, 2
- 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, // 11, 3
- 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, // 11, 4
- 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, // 11, 5
- 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, // 11, 6
- 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, // 11, 7
- 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, // 11, 8
- 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, // 11, 9
- 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, // 11,10
- 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, // 11,11
- 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, // 11,12
- 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, // 11,13
- 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, // 11,14
- 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, // 11,15
- 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, // 12, 0
- 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, // 12, 1
- 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, // 12, 2
- 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, // 12, 3
- 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, // 12, 4
- 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, // 12, 5
- 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, // 12, 6
- 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, // 12, 7
- 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, // 12, 8
- 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, // 12, 9
- 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, // 12,10
- 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, // 12,11
- 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, // 12,12
- 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, // 12,13
- 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, // 12,14
- 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, // 12,15
- 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, // 13, 0
- 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, // 13, 1
- 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, // 13, 2
- 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, // 13, 3
- 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, // 13, 4
- 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, // 13, 5
- 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, // 13, 6
- 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, // 13, 7
- 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, // 13, 8
- 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, // 13, 9
- 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, // 13,10
- 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, // 13,11
- 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, // 13,12
- 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, // 13,13
- 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, // 13,14
- 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, // 13,15
- 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, // 14, 0
- 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, // 14, 1
- 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, // 14, 2
- 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, // 14, 3
- 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, // 14, 4
- 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, // 14, 5
- 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, // 14, 6
- 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, // 14, 7
- 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, // 14, 8
- 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, // 14, 9
- 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, // 14,10
- 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, // 14,11
- 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, // 14,12
- 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, // 14,13
- 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, // 14,14
- 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, // 14,15
- 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, // 15, 0
- 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, // 15, 1
- 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, // 15, 2
- 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, // 15, 3
- 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, // 15, 4
- 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, // 15, 5
- 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, // 15, 6
- 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, // 15, 7
- 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, // 15, 8
- 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, // 15, 9
- 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, // 15,10
- 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, // 15,11
- 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, // 15,12
- 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, // 15,13
- 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, // 15,14
- 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, // 15,15
- // angle of 0.5 degrees
- 0, -1, 5106, 0, 0, 51699, 1, -1, 3621, 1, 0, 5110, // 0, 0
- 0, 0, 4851, 0, 1, 52457, 1, 0, 3422, 1, 1, 4806, // 0, 1
- 0, 1, 4610, 0, 2, 53168, 1, 1, 3235, 1, 2, 4523, // 0, 2
- 0, 2, 4390, 0, 3, 53814, 1, 2, 3065, 1, 3, 4267, // 0, 3
- 0, 3, 4200, 0, 4, 54376, 1, 3, 2917, 1, 4, 4043, // 0, 4
- 0, 4, 4046, 0, 5, 54833, 1, 4, 2797, 1, 5, 3860, // 0, 5
- 0, 5, 3939, 0, 6, 55164, 1, 5, 2709, 1, 6, 3724, // 0, 6
- 0, 6, 3885, 0, 7, 55352, 1, 6, 2659, 1, 7, 3640, // 0, 7
- -1, 7, 2659, -1, 8, 3638, 0, 7, 3885, 0, 8, 55354, // 0, 8
- -1, 8, 2709, -1, 9, 3722, 0, 8, 3940, 0, 9, 55165, // 0, 9
- -1, 9, 2796, -1, 10, 3858, 0, 9, 4047, 0, 10, 54835, // 0,10
- -1, 10, 2916, -1, 11, 4041, 0, 10, 4201, 0, 11, 54378, // 0,11
- -1, 11, 3064, -1, 12, 4264, 0, 11, 4392, 0, 12, 53816, // 0,12
- -1, 12, 3235, -1, 13, 4521, 0, 12, 4612, 0, 13, 53168, // 0,13
- -1, 13, 3421, -1, 14, 4803, 0, 13, 4854, 0, 14, 52458, // 0,14
- -1, 14, 3621, -1, 15, 5106, 0, 14, 5110, 0, 15, 51699, // 0,15
- 1, -1, 4803, 1, 0, 52457, 2, -1, 3421, 2, 0, 4855, // 1, 0
- 1, 0, 4522, 1, 1, 53285, 2, 0, 3204, 2, 1, 4525, // 1, 1
- 1, 1, 4253, 1, 2, 54071, 2, 1, 2998, 2, 2, 4214, // 1, 2
- 1, 2, 4003, 1, 3, 54796, 2, 2, 2808, 2, 3, 3929, // 1, 3
- 1, 3, 3783, 1, 4, 55434, 2, 3, 2640, 2, 4, 3679, // 1, 4
- 1, 4, 3604, 1, 5, 55958, 2, 4, 2503, 2, 5, 3471, // 1, 5
- 1, 5, 3476, 1, 6, 56339, 2, 5, 2403, 2, 6, 3318, // 1, 6
- 1, 6, 3411, 1, 7, 56552, 2, 6, 2346, 2, 7, 3227, // 1, 7
- 0, 7, 2346, 0, 8, 3225, 1, 7, 3411, 1, 8, 56554, // 1, 8
- 0, 8, 2402, 0, 9, 3317, 1, 8, 3477, 1, 9, 56340, // 1, 9
- 0, 9, 2502, 0, 10, 3470, 1, 9, 3605, 1, 10, 55959, // 1,10
- 0, 10, 2640, 0, 11, 3677, 1, 10, 3785, 1, 11, 55434, // 1,11
- 0, 11, 2808, 0, 12, 3927, 1, 11, 4005, 1, 12, 54796, // 1,12
- 0, 12, 2998, 0, 13, 4212, 1, 12, 4255, 1, 13, 54071, // 1,13
- 0, 13, 3204, 0, 14, 4522, 1, 13, 4525, 1, 14, 53285, // 1,14
- 0, 14, 3422, 0, 15, 4851, 1, 14, 4806, 1, 15, 52457, // 1,15
- 2, -1, 4521, 2, 0, 53168, 3, -1, 3235, 3, 0, 4612, // 2, 0
- 2, 0, 4212, 2, 1, 54072, 3, 0, 2998, 3, 1, 4254, // 2, 1
- 2, 1, 3911, 2, 2, 54941, 3, 1, 2770, 3, 2, 3914, // 2, 2
- 2, 2, 3628, 2, 3, 55756, 3, 2, 2557, 3, 3, 3595, // 2, 3
- 2, 3, 3373, 2, 4, 56486, 3, 3, 2365, 3, 4, 3312, // 2, 4
- 2, 4, 3161, 2, 5, 57095, 3, 4, 2205, 3, 5, 3075, // 2, 5
- 2, 5, 3007, 2, 6, 57544, 3, 5, 2088, 3, 6, 2897, // 2, 6
- 2, 6, 2926, 2, 7, 57793, 3, 6, 2022, 3, 7, 2795, // 2, 7
- 1, 7, 2022, 1, 8, 2794, 2, 7, 2926, 2, 8, 57794, // 2, 8
- 1, 8, 2088, 1, 9, 2897, 2, 8, 3007, 2, 9, 57544, // 2, 9
- 1, 9, 2205, 1, 10, 3073, 2, 9, 3161, 2, 10, 57097, // 2,10
- 1, 10, 2365, 1, 11, 3310, 2, 10, 3374, 2, 11, 56487, // 2,11
- 1, 11, 2556, 1, 12, 3594, 2, 11, 3630, 2, 12, 55756, // 2,12
- 1, 12, 2770, 1, 13, 3911, 2, 12, 3913, 2, 13, 54942, // 2,13
- 1, 13, 2998, 1, 14, 4253, 2, 13, 4214, 2, 14, 54071, // 2,14
- 1, 14, 3235, 1, 15, 4610, 2, 14, 4523, 2, 15, 53168, // 2,15
- 3, -1, 4264, 3, 0, 53815, 4, -1, 3064, 4, 0, 4393, // 3, 0
- 3, 0, 3927, 3, 1, 54796, 4, 0, 2808, 4, 1, 4005, // 3, 1
- 3, 1, 3594, 3, 2, 55756, 4, 1, 2556, 4, 2, 3630, // 3, 2
- 3, 2, 3273, 3, 3, 56673, 4, 2, 2317, 4, 3, 3273, // 3, 3
- 3, 3, 2976, 3, 4, 57514, 4, 3, 2096, 4, 4, 2950, // 3, 4
- 3, 4, 2722, 3, 5, 58233, 4, 4, 1908, 4, 5, 2673, // 3, 5
- 3, 5, 2532, 3, 6, 58774, 4, 5, 1767, 4, 6, 2463, // 3, 6
- 3, 6, 2430, 3, 7, 59076, 4, 6, 1687, 4, 7, 2343, // 3, 7
- 2, 7, 1687, 2, 8, 2342, 3, 7, 2430, 3, 8, 59077, // 3, 8
- 2, 8, 1766, 2, 9, 2463, 3, 8, 2532, 3, 9, 58775, // 3, 9
- 2, 9, 1908, 2, 10, 2672, 3, 9, 2723, 3, 10, 58233, // 3,10
- 2, 10, 2096, 2, 11, 2948, 3, 10, 2977, 3, 11, 57515, // 3,11
- 2, 11, 2317, 2, 12, 3273, 3, 11, 3274, 3, 12, 56672, // 3,12
- 2, 12, 2557, 2, 13, 3628, 3, 12, 3595, 3, 13, 55756, // 3,13
- 2, 13, 2808, 2, 14, 4003, 3, 13, 3929, 3, 14, 54796, // 3,14
- 2, 14, 3065, 2, 15, 4390, 3, 14, 4267, 3, 15, 53814, // 3,15
- 4, -1, 4041, 4, 0, 54378, 5, -1, 2916, 5, 0, 4201, // 4, 0
- 4, 0, 3677, 4, 1, 55435, 5, 0, 2640, 5, 1, 3784, // 4, 1
- 4, 1, 3310, 4, 2, 56487, 5, 1, 2365, 5, 2, 3374, // 4, 2
- 4, 2, 2948, 4, 3, 57514, 5, 2, 2096, 5, 3, 2978, // 4, 3
- 4, 3, 2604, 4, 4, 58484, 5, 3, 1843, 5, 4, 2605, // 4, 4
- 4, 4, 2297, 4, 5, 59345, 5, 4, 1617, 5, 5, 2277, // 4, 5
- 4, 5, 2057, 4, 6, 60017, 5, 5, 1442, 5, 6, 2020, // 4, 6
- 4, 6, 1922, 4, 7, 60402, 5, 6, 1341, 5, 7, 1871, // 4, 7
- 3, 7, 1341, 3, 8, 1871, 4, 7, 1922, 4, 8, 60402, // 4, 8
- 3, 8, 1442, 3, 9, 2020, 4, 8, 2057, 4, 9, 60017, // 4, 9
- 3, 9, 1617, 3, 10, 2276, 4, 9, 2297, 4, 10, 59346, // 4,10
- 3, 10, 1843, 3, 11, 2604, 4, 10, 2605, 4, 11, 58484, // 4,11
- 3, 11, 2096, 3, 12, 2976, 4, 11, 2950, 4, 12, 57514, // 4,12
- 3, 12, 2365, 3, 13, 3373, 4, 12, 3311, 4, 13, 56487, // 4,13
- 3, 13, 2640, 3, 14, 3783, 4, 13, 3678, 4, 14, 55435, // 4,14
- 3, 14, 2917, 3, 15, 4200, 4, 14, 4043, 4, 15, 54376, // 4,15
- 5, -1, 3858, 5, 0, 54835, 6, -1, 2796, 6, 0, 4047, // 5, 0
- 5, 0, 3470, 5, 1, 55959, 6, 0, 2502, 6, 1, 3605, // 5, 1
- 5, 1, 3073, 5, 2, 57096, 6, 1, 2205, 6, 2, 3162, // 5, 2
- 5, 2, 2672, 5, 3, 58234, 6, 2, 1908, 6, 3, 2722, // 5, 3
- 5, 3, 2276, 5, 4, 59346, 6, 3, 1617, 6, 4, 2297, // 5, 4
- 5, 4, 1904, 5, 5, 60381, 6, 4, 1347, 6, 5, 1904, // 5, 5
- 5, 5, 1593, 5, 6, 61243, 6, 5, 1121, 6, 6, 1579, // 5, 6
- 5, 6, 1405, 5, 7, 61767, 6, 6, 985, 6, 7, 1379, // 5, 7
- 4, 7, 985, 4, 8, 1380, 5, 7, 1405, 5, 8, 61766, // 5, 8
- 4, 8, 1121, 4, 9, 1578, 5, 8, 1593, 5, 9, 61244, // 5, 9
- 4, 9, 1347, 4, 10, 1904, 5, 9, 1904, 5, 10, 60381, // 5,10
- 4, 10, 1617, 4, 11, 2297, 5, 10, 2276, 5, 11, 59346, // 5,11
- 4, 11, 1908, 4, 12, 2722, 5, 11, 2673, 5, 12, 58233, // 5,12
- 4, 12, 2205, 4, 13, 3161, 5, 12, 3074, 5, 13, 57096, // 5,13
- 4, 13, 2503, 4, 14, 3604, 5, 13, 3472, 5, 14, 55957, // 5,14
- 4, 14, 2797, 4, 15, 4046, 5, 14, 3860, 5, 15, 54833, // 5,15
- 6, -1, 3722, 6, 0, 55166, 7, -1, 2709, 7, 0, 3939, // 6, 0
- 6, 0, 3317, 6, 1, 56340, 7, 0, 2402, 7, 1, 3477, // 6, 1
- 6, 1, 2897, 6, 2, 57545, 7, 1, 2088, 7, 2, 3006, // 6, 2
- 6, 2, 2463, 6, 3, 58775, 7, 2, 1766, 7, 3, 2532, // 6, 3
- 6, 3, 2020, 6, 4, 60018, 7, 3, 1442, 7, 4, 2056, // 6, 4
- 6, 4, 1578, 6, 5, 61243, 7, 4, 1121, 7, 5, 1594, // 6, 5
- 6, 5, 1170, 6, 6, 62369, 7, 5, 827, 7, 6, 1170, // 6, 6
- 6, 6, 883, 6, 7, 63156, 7, 6, 622, 7, 7, 875, // 6, 7
- 5, 7, 622, 5, 8, 875, 6, 7, 883, 6, 8, 63156, // 6, 8
- 5, 8, 827, 5, 9, 1170, 6, 8, 1170, 6, 9, 62369, // 6, 9
- 5, 9, 1121, 5, 10, 1593, 6, 9, 1579, 6, 10, 61243, // 6,10
- 5, 10, 1442, 5, 11, 2057, 6, 10, 2020, 6, 11, 60017, // 6,11
- 5, 11, 1767, 5, 12, 2532, 6, 11, 2464, 6, 12, 58773, // 6,12
- 5, 12, 2088, 5, 13, 3007, 6, 12, 2898, 6, 13, 57543, // 6,13
- 5, 13, 2403, 5, 14, 3476, 6, 13, 3319, 6, 14, 56338, // 6,14
- 5, 14, 2709, 5, 15, 3939, 6, 14, 3724, 6, 15, 55164, // 6,15
- 7, -1, 3638, 7, 0, 55354, 8, -1, 2659, 8, 0, 3885, // 7, 0
- 7, 0, 3225, 7, 1, 56554, 8, 0, 2346, 8, 1, 3411, // 7, 1
- 7, 1, 2794, 7, 2, 57795, 8, 1, 2022, 8, 2, 2925, // 7, 2
- 7, 2, 2342, 7, 3, 59077, 8, 2, 1687, 8, 3, 2430, // 7, 3
- 7, 3, 1871, 7, 4, 60402, 8, 3, 1341, 8, 4, 1922, // 7, 4
- 7, 4, 1380, 7, 5, 61767, 8, 4, 985, 8, 5, 1404, // 7, 5
- 7, 5, 875, 7, 6, 63156, 8, 5, 622, 8, 6, 883, // 7, 6
- 7, 6, 399, 7, 7, 64455, 8, 6, 282, 8, 7, 400, // 7, 7
- 6, 7, 282, 6, 8, 399, 7, 7, 399, 7, 8, 64456, // 7, 8
- 6, 8, 622, 6, 9, 883, 7, 8, 875, 7, 9, 63156, // 7, 9
- 6, 9, 985, 6, 10, 1405, 7, 9, 1380, 7, 10, 61766, // 7,10
- 6, 10, 1341, 6, 11, 1922, 7, 10, 1871, 7, 11, 60402, // 7,11
- 6, 11, 1687, 6, 12, 2430, 7, 11, 2343, 7, 12, 59076, // 7,12
- 6, 12, 2022, 6, 13, 2926, 7, 12, 2795, 7, 13, 57793, // 7,13
- 6, 13, 2346, 6, 14, 3411, 7, 13, 3227, 7, 14, 56552, // 7,14
- 6, 14, 2659, 6, 15, 3885, 7, 14, 3640, 7, 15, 55352, // 7,15
- 8, 0, 55352, 8, 1, 3640, 9, 0, 3885, 9, 1, 2659, // 8, 0
- 8, 1, 56552, 8, 2, 3227, 9, 1, 3411, 9, 2, 2346, // 8, 1
- 8, 2, 57793, 8, 3, 2795, 9, 2, 2926, 9, 3, 2022, // 8, 2
- 8, 3, 59076, 8, 4, 2343, 9, 3, 2430, 9, 4, 1687, // 8, 3
- 8, 4, 60402, 8, 5, 1871, 9, 4, 1922, 9, 5, 1341, // 8, 4
- 8, 5, 61767, 8, 6, 1380, 9, 5, 1405, 9, 6, 984, // 8, 5
- 8, 6, 63156, 8, 7, 875, 9, 6, 883, 9, 7, 622, // 8, 6
- 8, 7, 64455, 8, 8, 399, 9, 7, 399, 9, 8, 283, // 8, 7
- 7, 8, 399, 7, 9, 282, 8, 8, 64455, 8, 9, 400, // 8, 8
- 7, 9, 883, 7, 10, 622, 8, 9, 63156, 8, 10, 875, // 8, 9
- 7, 10, 1405, 7, 11, 985, 8, 10, 61767, 8, 11, 1379, // 8,10
- 7, 11, 1922, 7, 12, 1341, 8, 11, 60402, 8, 12, 1871, // 8,11
- 7, 12, 2430, 7, 13, 1687, 8, 12, 59077, 8, 13, 2342, // 8,12
- 7, 13, 2926, 7, 14, 2022, 8, 13, 57795, 8, 14, 2793, // 8,13
- 7, 14, 3411, 7, 15, 2346, 8, 14, 56554, 8, 15, 3225, // 8,14
- 7, 15, 3885, 7, 16, 2659, 8, 15, 55354, 8, 16, 3638, // 8,15
- 9, 0, 55164, 9, 1, 3724, 10, 0, 3939, 10, 1, 2709, // 9, 0
- 9, 1, 56339, 9, 2, 3319, 10, 1, 3476, 10, 2, 2402, // 9, 1
- 9, 2, 57544, 9, 3, 2898, 10, 2, 3007, 10, 3, 2087, // 9, 2
- 9, 3, 58774, 9, 4, 2464, 10, 3, 2532, 10, 4, 1766, // 9, 3
- 9, 4, 60017, 9, 5, 2020, 10, 4, 2057, 10, 5, 1442, // 9, 4
- 9, 5, 61243, 9, 6, 1579, 10, 5, 1593, 10, 6, 1121, // 9, 5
- 9, 6, 62369, 9, 7, 1170, 10, 6, 1170, 10, 7, 827, // 9, 6
- 9, 7, 63156, 9, 8, 883, 10, 7, 875, 10, 8, 622, // 9, 7
- 8, 8, 875, 8, 9, 622, 9, 8, 63156, 9, 9, 883, // 9, 8
- 8, 9, 1170, 8, 10, 827, 9, 9, 62369, 9, 10, 1170, // 9, 9
- 8, 10, 1593, 8, 11, 1121, 9, 10, 61243, 9, 11, 1579, // 9,10
- 8, 11, 2057, 8, 12, 1442, 9, 11, 60018, 9, 12, 2019, // 9,11
- 8, 12, 2532, 8, 13, 1766, 9, 12, 58775, 9, 13, 2463, // 9,12
- 8, 13, 3007, 8, 14, 2088, 9, 13, 57545, 9, 14, 2896, // 9,13
- 8, 14, 3477, 8, 15, 2402, 9, 14, 56340, 9, 15, 3317, // 9,14
- 8, 15, 3940, 8, 16, 2709, 9, 15, 55166, 9, 16, 3721, // 9,15
- 10, 0, 54833, 10, 1, 3860, 11, 0, 4046, 11, 1, 2797, // 10, 0
- 10, 1, 55958, 10, 2, 3472, 11, 1, 3604, 11, 2, 2502, // 10, 1
- 10, 2, 57095, 10, 3, 3074, 11, 2, 3161, 11, 3, 2206, // 10, 2
- 10, 3, 58233, 10, 4, 2673, 11, 3, 2722, 11, 4, 1908, // 10, 3
- 10, 4, 59345, 10, 5, 2276, 11, 4, 2297, 11, 5, 1618, // 10, 4
- 10, 5, 60381, 10, 6, 1904, 11, 5, 1904, 11, 6, 1347, // 10, 5
- 10, 6, 61243, 10, 7, 1593, 11, 6, 1578, 11, 7, 1122, // 10, 6
- 10, 7, 61767, 10, 8, 1405, 11, 7, 1380, 11, 8, 984, // 10, 7
- 9, 8, 1380, 9, 9, 985, 10, 8, 61767, 10, 9, 1404, // 10, 8
- 9, 9, 1579, 9, 10, 1121, 10, 9, 61243, 10, 10, 1593, // 10, 9
- 9, 10, 1904, 9, 11, 1347, 10, 10, 60381, 10, 11, 1904, // 10,10
- 9, 11, 2297, 9, 12, 1617, 10, 11, 59346, 10, 12, 2276, // 10,11
- 9, 12, 2723, 9, 13, 1908, 10, 12, 58234, 10, 13, 2671, // 10,12
- 9, 13, 3161, 9, 14, 2205, 10, 13, 57096, 10, 14, 3074, // 10,13
- 9, 14, 3605, 9, 15, 2502, 10, 14, 55959, 10, 15, 3470, // 10,14
- 9, 15, 4047, 9, 16, 2796, 10, 15, 54835, 10, 16, 3858, // 10,15
- 11, 0, 54376, 11, 1, 4043, 12, 0, 4200, 12, 1, 2917, // 11, 0
- 11, 1, 55434, 11, 2, 3678, 12, 1, 3783, 12, 2, 2641, // 11, 1
- 11, 2, 56486, 11, 3, 3311, 12, 2, 3373, 12, 3, 2366, // 11, 2
- 11, 3, 57514, 11, 4, 2950, 12, 3, 2976, 12, 4, 2096, // 11, 3
- 11, 4, 58484, 11, 5, 2605, 12, 4, 2604, 12, 5, 1843, // 11, 4
- 11, 5, 59346, 11, 6, 2297, 12, 5, 2276, 12, 6, 1617, // 11, 5
- 11, 6, 60018, 11, 7, 2057, 12, 6, 2020, 12, 7, 1441, // 11, 6
- 11, 7, 60402, 11, 8, 1922, 12, 7, 1871, 12, 8, 1341, // 11, 7
- 10, 8, 1871, 10, 9, 1341, 11, 8, 60402, 11, 9, 1922, // 11, 8
- 10, 9, 2020, 10, 10, 1442, 11, 9, 60017, 11, 10, 2057, // 11, 9
- 10, 10, 2276, 10, 11, 1617, 11, 10, 59345, 11, 11, 2298, // 11,10
- 10, 11, 2605, 10, 12, 1843, 11, 11, 58484, 11, 12, 2604, // 11,11
- 10, 12, 2977, 10, 13, 2096, 11, 12, 57514, 11, 13, 2949, // 11,12
- 10, 13, 3374, 10, 14, 2365, 11, 13, 56487, 11, 14, 3310, // 11,13
- 10, 14, 3785, 10, 15, 2640, 11, 14, 55435, 11, 15, 3676, // 11,14
- 10, 15, 4201, 10, 16, 2916, 11, 15, 54378, 11, 16, 4041, // 11,15
- 12, 0, 53814, 12, 1, 4267, 13, 0, 4390, 13, 1, 3065, // 12, 0
- 12, 1, 54796, 12, 2, 3929, 13, 1, 4003, 13, 2, 2808, // 12, 1
- 12, 2, 55756, 12, 3, 3595, 13, 2, 3628, 13, 3, 2557, // 12, 2
- 12, 3, 56673, 12, 4, 3274, 13, 3, 3273, 13, 4, 2316, // 12, 3
- 12, 4, 57514, 12, 5, 2977, 13, 4, 2948, 13, 5, 2097, // 12, 4
- 12, 5, 58234, 12, 6, 2723, 13, 5, 2672, 13, 6, 1907, // 12, 5
- 12, 6, 58775, 12, 7, 2532, 13, 6, 2463, 13, 7, 1766, // 12, 6
- 12, 7, 59077, 12, 8, 2430, 13, 7, 2342, 13, 8, 1687, // 12, 7
- 11, 8, 2343, 11, 9, 1687, 12, 8, 59076, 12, 9, 2430, // 12, 8
- 11, 9, 2464, 11, 10, 1767, 12, 9, 58774, 12, 10, 2531, // 12, 9
- 11, 10, 2673, 11, 11, 1908, 12, 10, 58233, 12, 11, 2722, // 12,10
- 11, 11, 2950, 11, 12, 2096, 12, 11, 57514, 12, 12, 2976, // 12,11
- 11, 12, 3274, 11, 13, 2317, 12, 12, 56673, 12, 13, 3272, // 12,12
- 11, 13, 3630, 11, 14, 2556, 12, 13, 55756, 12, 14, 3594, // 12,13
- 11, 14, 4005, 11, 15, 2808, 12, 14, 54796, 12, 15, 3927, // 12,14
- 11, 15, 4392, 11, 16, 3064, 12, 15, 53815, 12, 16, 4265, // 12,15
- 13, 0, 53168, 13, 1, 4523, 14, 0, 4610, 14, 1, 3235, // 13, 0
- 13, 1, 54071, 13, 2, 4214, 14, 1, 4253, 14, 2, 2998, // 13, 1
- 13, 2, 54941, 13, 3, 3913, 14, 2, 3911, 14, 3, 2771, // 13, 2
- 13, 3, 55756, 13, 4, 3630, 14, 3, 3594, 14, 4, 2556, // 13, 3
- 13, 4, 56487, 13, 5, 3374, 14, 4, 3310, 14, 5, 2365, // 13, 4
- 13, 5, 57096, 13, 6, 3161, 14, 5, 3073, 14, 6, 2206, // 13, 5
- 13, 6, 57545, 13, 7, 3007, 14, 6, 2897, 14, 7, 2087, // 13, 6
- 13, 7, 57795, 13, 8, 2926, 14, 7, 2794, 14, 8, 2021, // 13, 7
- 12, 8, 2795, 12, 9, 2022, 13, 8, 57793, 13, 9, 2926, // 13, 8
- 12, 9, 2898, 12, 10, 2088, 13, 9, 57544, 13, 10, 3006, // 13, 9
- 12, 10, 3074, 12, 11, 2205, 13, 10, 57095, 13, 11, 3162, // 13,10
- 12, 11, 3311, 12, 12, 2365, 13, 11, 56486, 13, 12, 3374, // 13,11
- 12, 12, 3595, 12, 13, 2557, 13, 12, 55756, 13, 13, 3628, // 13,12
- 12, 13, 3913, 12, 14, 2770, 13, 13, 54941, 13, 14, 3912, // 13,13
- 12, 14, 4255, 12, 15, 2998, 13, 14, 54072, 13, 15, 4211, // 13,14
- 12, 15, 4612, 12, 16, 3235, 13, 15, 53168, 13, 16, 4521, // 13,15
- 14, 0, 52457, 14, 1, 4806, 15, 0, 4851, 15, 1, 3422, // 14, 0
- 14, 1, 53285, 14, 2, 4525, 15, 1, 4522, 15, 2, 3204, // 14, 1
- 14, 2, 54072, 14, 3, 4255, 15, 2, 4212, 15, 3, 2997, // 14, 2
- 14, 3, 54796, 14, 4, 4005, 15, 3, 3927, 15, 4, 2808, // 14, 3
- 14, 4, 55435, 14, 5, 3785, 15, 4, 3677, 15, 5, 2639, // 14, 4
- 14, 5, 55959, 14, 6, 3605, 15, 5, 3470, 15, 6, 2502, // 14, 5
- 14, 6, 56340, 14, 7, 3477, 15, 6, 3317, 15, 7, 2402, // 14, 6
- 14, 7, 56554, 14, 8, 3411, 15, 7, 3225, 15, 8, 2346, // 14, 7
- 13, 8, 3227, 13, 9, 2346, 14, 8, 56552, 14, 9, 3411, // 14, 8
- 13, 9, 3319, 13, 10, 2403, 14, 9, 56339, 14, 10, 3475, // 14, 9
- 13, 10, 3472, 13, 11, 2503, 14, 10, 55958, 14, 11, 3603, // 14,10
- 13, 11, 3678, 13, 12, 2640, 14, 11, 55434, 14, 12, 3784, // 14,11
- 13, 12, 3929, 13, 13, 2808, 14, 12, 54796, 14, 13, 4003, // 14,12
- 13, 13, 4214, 13, 14, 2998, 14, 13, 54071, 14, 14, 4253, // 14,13
- 13, 14, 4525, 13, 15, 3204, 14, 14, 53285, 14, 15, 4522, // 14,14
- 13, 15, 4854, 13, 16, 3421, 14, 15, 52457, 14, 16, 4804, // 14,15
- 15, 0, 51699, 15, 1, 5110, 16, 0, 5106, 16, 1, 3621, // 15, 0
- 15, 1, 52457, 15, 2, 4854, 16, 1, 4803, 16, 2, 3422, // 15, 1
- 15, 2, 53168, 15, 3, 4612, 16, 2, 4521, 16, 3, 3235, // 15, 2
- 15, 3, 53815, 15, 4, 4392, 16, 3, 4264, 16, 4, 3065, // 15, 3
- 15, 4, 54378, 15, 5, 4201, 16, 4, 4041, 16, 5, 2916, // 15, 4
- 15, 5, 54835, 15, 6, 4047, 16, 5, 3858, 16, 6, 2796, // 15, 5
- 15, 6, 55166, 15, 7, 3940, 16, 6, 3722, 16, 7, 2708, // 15, 6
- 15, 7, 55354, 15, 8, 3885, 16, 7, 3638, 16, 8, 2659, // 15, 7
- 14, 8, 3640, 14, 9, 2659, 15, 8, 55352, 15, 9, 3885, // 15, 8
- 14, 9, 3724, 14, 10, 2709, 15, 9, 55164, 15, 10, 3939, // 15, 9
- 14, 10, 3860, 14, 11, 2797, 15, 10, 54833, 15, 11, 4046, // 15,10
- 14, 11, 4043, 14, 12, 2917, 15, 11, 54376, 15, 12, 4200, // 15,11
- 14, 12, 4267, 14, 13, 3065, 15, 12, 53814, 15, 13, 4390, // 15,12
- 14, 13, 4523, 14, 14, 3235, 15, 13, 53168, 15, 14, 4610, // 15,13
- 14, 14, 4806, 14, 15, 3422, 15, 14, 52457, 15, 15, 4851, // 15,14
- 14, 15, 5110, 14, 16, 3621, 15, 15, 51699, 15, 16, 5106, // 15,15
- // angle of 1.0 degrees
- 0, -1, 8769, 0, 0, 41693, 1, -1, 6280, 1, 0, 8794, // 0, 0
- 0, 0, 8452, 0, 1, 42821, 1, 0, 5975, 1, 1, 8288, // 0, 1
- 0, 1, 8141, 0, 2, 43900, 1, 1, 5684, 1, 2, 7811, // 0, 2
- 0, 2, 7848, 0, 3, 44901, 1, 2, 5413, 1, 3, 7374, // 0, 3
- 0, 3, 7587, 0, 4, 45791, 1, 3, 5172, 1, 4, 6986, // 0, 4
- 0, 4, 7374, 0, 5, 46532, 1, 4, 4971, 1, 5, 6659, // 0, 5
- 0, 5, 7227, 0, 6, 47086, 1, 5, 4818, 1, 6, 6405, // 0, 6
- 0, 6, 7158, 0, 7, 47426, 1, 6, 4722, 1, 7, 6230, // 0, 7
- -1, 7, 4718, -1, 8, 6217, 0, 7, 7161, 0, 8, 47440, // 0, 8
- -1, 8, 4814, -1, 9, 6391, 0, 8, 7233, 0, 9, 47098, // 0, 9
- -1, 9, 4967, -1, 10, 6644, 0, 9, 7383, 0, 10, 46542, // 0,10
- -1, 10, 5169, -1, 11, 6970, 0, 10, 7599, 0, 11, 45798, // 0,11
- -1, 11, 5410, -1, 12, 7356, 0, 11, 7863, 0, 12, 44907, // 0,12
- -1, 12, 5682, -1, 13, 7791, 0, 12, 8159, 0, 13, 43904, // 0,13
- -1, 13, 5974, -1, 14, 8265, 0, 13, 8474, 0, 14, 42823, // 0,14
- -1, 14, 6280, -1, 15, 8769, 0, 14, 8795, 0, 15, 41692, // 0,15
- 1, -1, 8265, 1, 0, 42823, 2, -1, 5974, 2, 0, 8474, // 1, 0
- 1, 0, 7901, 1, 1, 44074, 2, 0, 5640, 2, 1, 7921, // 1, 1
- 1, 1, 7539, 1, 2, 45286, 2, 1, 5316, 2, 2, 7395, // 1, 2
- 1, 2, 7191, 1, 3, 46427, 2, 2, 5011, 2, 3, 6907, // 1, 3
- 1, 3, 6875, 1, 4, 47453, 2, 3, 4736, 2, 4, 6472, // 1, 4
- 1, 4, 6613, 1, 5, 48314, 2, 4, 4505, 2, 5, 6104, // 1, 5
- 1, 5, 6425, 1, 6, 48960, 2, 5, 4330, 2, 6, 5821, // 1, 6
- 1, 6, 6332, 1, 7, 49347, 2, 6, 4224, 2, 7, 5633, // 1, 7
- 0, 7, 4221, 0, 8, 5623, 1, 7, 6335, 1, 8, 49357, // 1, 8
- 0, 8, 4327, 0, 9, 5809, 1, 8, 6430, 1, 9, 48970, // 1, 9
- 0, 9, 4502, 0, 10, 6092, 1, 9, 6620, 1, 10, 48322, // 1,10
- 0, 10, 4734, 0, 11, 6458, 1, 10, 6886, 1, 11, 47458, // 1,11
- 0, 11, 5009, 0, 12, 6892, 1, 11, 7204, 1, 12, 46431, // 1,12
- 0, 12, 5315, 0, 13, 7378, 1, 12, 7555, 1, 13, 45288, // 1,13
- 0, 13, 5640, 0, 14, 7901, 1, 13, 7921, 1, 14, 44074, // 1,14
- 0, 14, 5975, 0, 15, 8452, 1, 14, 8288, 1, 15, 42821, // 1,15
- 2, -1, 7791, 2, 0, 43904, 3, -1, 5682, 3, 0, 8159, // 2, 0
- 2, 0, 7378, 2, 1, 45288, 3, 0, 5315, 3, 1, 7555, // 2, 1
- 2, 1, 6959, 2, 2, 46650, 3, 1, 4954, 3, 2, 6973, // 2, 2
- 2, 2, 6549, 2, 3, 47953, 3, 2, 4608, 3, 3, 6426, // 2, 3
- 2, 3, 6168, 2, 4, 49147, 3, 3, 4291, 3, 4, 5930, // 2, 4
- 2, 4, 5842, 2, 5, 50165, 3, 4, 4020, 3, 5, 5509, // 2, 5
- 2, 5, 5602, 2, 6, 50935, 3, 5, 3815, 3, 6, 5184, // 2, 6
- 2, 6, 5478, 2, 7, 51387, 3, 6, 3693, 3, 7, 4978, // 2, 7
- 1, 7, 3691, 1, 8, 4970, 2, 7, 5480, 2, 8, 51395, // 2, 8
- 1, 8, 3813, 1, 9, 5175, 2, 8, 5606, 2, 9, 50942, // 2, 9
- 1, 9, 4019, 1, 10, 5499, 2, 9, 5848, 2, 10, 50170, // 2,10
- 1, 10, 4290, 1, 11, 5920, 2, 10, 6176, 2, 11, 49150, // 2,11
- 1, 11, 4607, 1, 12, 6414, 2, 11, 6560, 2, 12, 47955, // 2,12
- 1, 12, 4954, 1, 13, 6959, 2, 12, 6973, 2, 13, 46650, // 2,13
- 1, 13, 5316, 1, 14, 7539, 2, 13, 7395, 2, 14, 45286, // 2,14
- 1, 14, 5684, 1, 15, 8141, 2, 14, 7812, 2, 15, 43899, // 2,15
- 3, -1, 7356, 3, 0, 44907, 4, -1, 5410, 4, 0, 7863, // 3, 0
- 3, 0, 6892, 3, 1, 46430, 4, 0, 5009, 4, 1, 7205, // 3, 1
- 3, 1, 6414, 3, 2, 47955, 4, 1, 4607, 4, 2, 6560, // 3, 2
- 3, 2, 5934, 3, 3, 49445, 4, 2, 4214, 4, 3, 5943, // 3, 3
- 3, 3, 5474, 3, 4, 50843, 4, 3, 3846, 4, 4, 5373, // 3, 4
- 3, 4, 5069, 3, 5, 52066, 4, 4, 3523, 4, 5, 4878, // 3, 5
- 3, 5, 4759, 3, 6, 53008, 4, 5, 3274, 4, 6, 4495, // 3, 6
- 3, 6, 4592, 3, 7, 53557, 4, 6, 3128, 4, 7, 4259, // 3, 7
- 2, 7, 3126, 2, 8, 4254, 3, 7, 4594, 3, 8, 53562, // 3, 8
- 2, 8, 3273, 2, 9, 4489, 3, 8, 4762, 3, 9, 53012, // 3, 9
- 2, 9, 3522, 2, 10, 4872, 3, 9, 5073, 3, 10, 52069, // 3,10
- 2, 10, 3845, 2, 11, 5365, 3, 10, 5481, 3, 11, 50845, // 3,11
- 2, 11, 4214, 2, 12, 5934, 3, 11, 5943, 3, 12, 49445, // 3,12
- 2, 12, 4608, 2, 13, 6549, 3, 12, 6426, 3, 13, 47953, // 3,13
- 2, 13, 5011, 2, 14, 7191, 3, 13, 6908, 3, 14, 46426, // 3,14
- 2, 14, 5413, 2, 15, 7848, 3, 14, 7374, 3, 15, 44901, // 3,15
- 4, -1, 6970, 4, 0, 45799, 5, -1, 5169, 5, 0, 7598, // 4, 0
- 4, 0, 6458, 4, 1, 47458, 5, 0, 4734, 5, 1, 6886, // 4, 1
- 4, 1, 5920, 4, 2, 49150, 5, 1, 4290, 5, 2, 6176, // 4, 2
- 4, 2, 5365, 4, 3, 50844, 5, 2, 3845, 5, 3, 5482, // 4, 3
- 4, 3, 4816, 4, 4, 52484, 5, 3, 3415, 5, 4, 4821, // 4, 4
- 4, 4, 4309, 4, 5, 53973, 5, 4, 3023, 5, 5, 4231, // 4, 5
- 4, 5, 3902, 4, 6, 55164, 5, 5, 2711, 5, 6, 3759, // 4, 6
- 4, 6, 3671, 4, 7, 55867, 5, 6, 2525, 5, 7, 3473, // 4, 7
- 3, 7, 2524, 3, 8, 3469, 4, 7, 3672, 4, 8, 55871, // 4, 8
- 3, 8, 2710, 3, 9, 3755, 4, 8, 3904, 4, 9, 55167, // 4, 9
- 3, 9, 3023, 3, 10, 4226, 4, 9, 4313, 4, 10, 53974, // 4,10
- 3, 10, 3415, 3, 11, 4816, 4, 10, 4822, 4, 11, 52483, // 4,11
- 3, 11, 3846, 3, 12, 5474, 4, 11, 5373, 4, 12, 50843, // 4,12
- 3, 12, 4291, 3, 13, 6168, 4, 12, 5930, 4, 13, 49147, // 4,13
- 3, 13, 4736, 3, 14, 6875, 4, 13, 6472, 4, 14, 47453, // 4,14
- 3, 14, 5172, 3, 15, 7587, 4, 14, 6986, 4, 15, 45791, // 4,15
- 5, -1, 6644, 5, 0, 46541, 6, -1, 4967, 6, 0, 7384, // 5, 0
- 5, 0, 6092, 5, 1, 48322, 6, 0, 4502, 6, 1, 6620, // 5, 1
- 5, 1, 5499, 5, 2, 50171, 6, 1, 4019, 6, 2, 5847, // 5, 2
- 5, 2, 4872, 5, 3, 52069, 6, 2, 3522, 6, 3, 5073, // 5, 3
- 5, 3, 4226, 5, 4, 53975, 6, 3, 3023, 6, 4, 4312, // 5, 4
- 5, 4, 3595, 5, 5, 55798, 6, 4, 2546, 6, 5, 3597, // 5, 5
- 5, 5, 3050, 5, 6, 57353, 6, 5, 2138, 6, 6, 2995, // 5, 6
- 5, 6, 2713, 5, 7, 58322, 6, 6, 1884, 6, 7, 2617, // 5, 7
- 4, 7, 1884, 4, 8, 2615, 5, 7, 2714, 5, 8, 58323, // 5, 8
- 4, 8, 2138, 4, 9, 2993, 5, 8, 3051, 5, 9, 57354, // 5, 9
- 4, 9, 2546, 4, 10, 3595, 5, 9, 3598, 5, 10, 55797, // 5,10
- 4, 10, 3023, 4, 11, 4309, 5, 10, 4230, 5, 11, 53974, // 5,11
- 4, 11, 3523, 4, 12, 5069, 5, 11, 4879, 5, 12, 52065, // 5,12
- 4, 12, 4020, 4, 13, 5842, 5, 12, 5508, 5, 13, 50166, // 5,13
- 4, 13, 4505, 4, 14, 6613, 5, 13, 6104, 5, 14, 48314, // 5,14
- 4, 14, 4971, 4, 15, 7374, 5, 14, 6659, 5, 15, 46532, // 5,15
- 6, -1, 6391, 6, 0, 47098, 7, -1, 4814, 7, 0, 7233, // 6, 0
- 6, 0, 5809, 6, 1, 48969, 7, 0, 4327, 7, 1, 6431, // 6, 1
- 6, 1, 5175, 6, 2, 50942, 7, 1, 3813, 7, 2, 5606, // 6, 2
- 6, 2, 4489, 6, 3, 53012, 7, 2, 3273, 7, 3, 4762, // 6, 3
- 6, 3, 3755, 6, 4, 55166, 7, 3, 2710, 7, 4, 3905, // 6, 4
- 6, 4, 2993, 6, 5, 57354, 7, 4, 2138, 7, 5, 3051, // 6, 5
- 6, 5, 2258, 6, 6, 59422, 7, 5, 1597, 7, 6, 2259, // 6, 6
- 6, 6, 1726, 6, 7, 60905, 7, 6, 1210, 7, 7, 1695, // 6, 7
- 5, 7, 1209, 5, 8, 1695, 6, 7, 1726, 6, 8, 60906, // 6, 8
- 5, 8, 1597, 5, 9, 2258, 6, 8, 2259, 6, 9, 59422, // 6, 9
- 5, 9, 2138, 5, 10, 3050, 6, 9, 2995, 6, 10, 57353, // 6,10
- 5, 10, 2711, 5, 11, 3902, 6, 10, 3759, 6, 11, 55164, // 6,11
- 5, 11, 3274, 5, 12, 4759, 6, 11, 4495, 6, 12, 53008, // 6,12
- 5, 12, 3815, 5, 13, 5602, 6, 12, 5184, 6, 13, 50935, // 6,13
- 5, 13, 4330, 5, 14, 6425, 6, 13, 5820, 6, 14, 48961, // 6,14
- 5, 14, 4818, 5, 15, 7227, 6, 14, 6405, 6, 15, 47086, // 6,15
- 7, -1, 6217, 7, 0, 47440, 8, -1, 4718, 8, 0, 7161, // 7, 0
- 7, 0, 5623, 7, 1, 49358, 8, 0, 4221, 8, 1, 6334, // 7, 1
- 7, 1, 4970, 7, 2, 51395, 8, 1, 3691, 8, 2, 5480, // 7, 2
- 7, 2, 4254, 7, 3, 53562, 8, 2, 3126, 8, 3, 4594, // 7, 3
- 7, 3, 3469, 7, 4, 55870, 8, 3, 2524, 8, 4, 3673, // 7, 4
- 7, 4, 2615, 7, 5, 58324, 8, 4, 1884, 8, 5, 2713, // 7, 5
- 7, 5, 1695, 7, 6, 60906, 8, 5, 1209, 8, 6, 1726, // 7, 6
- 7, 6, 789, 7, 7, 63399, 8, 6, 558, 8, 7, 790, // 7, 7
- 6, 7, 558, 6, 8, 789, 7, 7, 789, 7, 8, 63400, // 7, 8
- 6, 8, 1210, 6, 9, 1726, 7, 8, 1695, 7, 9, 60905, // 7, 9
- 6, 9, 1884, 6, 10, 2713, 7, 9, 2616, 7, 10, 58323, // 7,10
- 6, 10, 2525, 6, 11, 3671, 7, 10, 3473, 7, 11, 55867, // 7,11
- 6, 11, 3128, 6, 12, 4592, 7, 11, 4259, 7, 12, 53557, // 7,12
- 6, 12, 3693, 6, 13, 5478, 7, 12, 4978, 7, 13, 51387, // 7,13
- 6, 13, 4224, 6, 14, 6332, 7, 13, 5633, 7, 14, 49347, // 7,14
- 6, 14, 4722, 6, 15, 7158, 7, 14, 6230, 7, 15, 47426, // 7,15
- 8, 0, 47426, 8, 1, 6230, 9, 0, 7158, 9, 1, 4722, // 8, 0
- 8, 1, 49347, 8, 2, 5633, 9, 1, 6332, 9, 2, 4224, // 8, 1
- 8, 2, 51387, 8, 3, 4978, 9, 2, 5478, 9, 3, 3693, // 8, 2
- 8, 3, 53557, 8, 4, 4259, 9, 3, 4592, 9, 4, 3128, // 8, 3
- 8, 4, 55867, 8, 5, 3473, 9, 4, 3671, 9, 5, 2525, // 8, 4
- 8, 5, 58322, 8, 6, 2616, 9, 5, 2713, 9, 6, 1885, // 8, 5
- 8, 6, 60905, 8, 7, 1695, 9, 6, 1726, 9, 7, 1210, // 8, 6
- 8, 7, 63399, 8, 8, 789, 9, 7, 789, 9, 8, 559, // 8, 7
- 7, 8, 789, 7, 9, 558, 8, 8, 63399, 8, 9, 790, // 8, 8
- 7, 9, 1726, 7, 10, 1209, 8, 9, 60906, 8, 10, 1695, // 8, 9
- 7, 10, 2714, 7, 11, 1884, 8, 10, 58324, 8, 11, 2614, // 8,10
- 7, 11, 3672, 7, 12, 2524, 8, 11, 55870, 8, 12, 3470, // 8,11
- 7, 12, 4594, 7, 13, 3126, 8, 12, 53562, 8, 13, 4254, // 8,12
- 7, 13, 5480, 7, 14, 3691, 8, 13, 51395, 8, 14, 4970, // 8,13
- 7, 14, 6335, 7, 15, 4221, 8, 14, 49358, 8, 15, 5622, // 8,14
- 7, 15, 7161, 7, 16, 4718, 8, 15, 47440, 8, 16, 6217, // 8,15
- 9, 0, 47086, 9, 1, 6405, 10, 0, 7227, 10, 1, 4818, // 9, 0
- 9, 1, 48960, 9, 2, 5820, 10, 1, 6425, 10, 2, 4331, // 9, 1
- 9, 2, 50935, 9, 3, 5184, 10, 2, 5602, 10, 3, 3815, // 9, 2
- 9, 3, 53008, 9, 4, 4495, 10, 3, 4759, 10, 4, 3274, // 9, 3
- 9, 4, 55164, 9, 5, 3759, 10, 4, 3902, 10, 5, 2711, // 9, 4
- 9, 5, 57353, 9, 6, 2995, 10, 5, 3050, 10, 6, 2138, // 9, 5
- 9, 6, 59422, 9, 7, 2259, 10, 6, 2258, 10, 7, 1597, // 9, 6
- 9, 7, 60906, 9, 8, 1726, 10, 7, 1695, 10, 8, 1209, // 9, 7
- 8, 8, 1695, 8, 9, 1210, 9, 8, 60905, 9, 9, 1726, // 9, 8
- 8, 9, 2259, 8, 10, 1597, 9, 9, 59422, 9, 10, 2258, // 9, 9
- 8, 10, 3051, 8, 11, 2138, 9, 10, 57354, 9, 11, 2993, // 9,10
- 8, 11, 3904, 8, 12, 2710, 9, 11, 55166, 9, 12, 3756, // 9,11
- 8, 12, 4762, 8, 13, 3273, 9, 12, 53012, 9, 13, 4489, // 9,12
- 8, 13, 5606, 8, 14, 3813, 9, 13, 50942, 9, 14, 5175, // 9,13
- 8, 14, 6430, 8, 15, 4327, 9, 14, 48969, 9, 15, 5810, // 9,14
- 8, 15, 7233, 8, 16, 4814, 9, 15, 47098, 9, 16, 6391, // 9,15
- 10, 0, 46532, 10, 1, 6659, 11, 0, 7374, 11, 1, 4971, // 10, 0
- 10, 1, 48314, 10, 2, 6104, 11, 1, 6613, 11, 2, 4505, // 10, 1
- 10, 2, 50165, 10, 3, 5508, 11, 2, 5842, 11, 3, 4021, // 10, 2
- 10, 3, 52066, 10, 4, 4879, 11, 3, 5069, 11, 4, 3522, // 10, 3
- 10, 4, 53973, 10, 5, 4230, 11, 4, 4309, 11, 5, 3024, // 10, 4
- 10, 5, 55798, 10, 6, 3598, 11, 5, 3595, 11, 6, 2545, // 10, 5
- 10, 6, 57354, 10, 7, 3051, 11, 6, 2993, 11, 7, 2138, // 10, 6
- 10, 7, 58324, 10, 8, 2714, 11, 7, 2615, 11, 8, 1883, // 10, 7
- 9, 8, 2616, 9, 9, 1884, 10, 8, 58322, 10, 9, 2714, // 10, 8
- 9, 9, 2995, 9, 10, 2138, 10, 9, 57353, 10, 10, 3050, // 10, 9
- 9, 10, 3598, 9, 11, 2546, 10, 10, 55798, 10, 11, 3594, // 10,10
- 9, 11, 4313, 9, 12, 3023, 10, 11, 53975, 10, 12, 4225, // 10,11
- 9, 12, 5073, 9, 13, 3522, 10, 12, 52069, 10, 13, 4872, // 10,12
- 9, 13, 5848, 9, 14, 4019, 10, 13, 50171, 10, 14, 5498, // 10,13
- 9, 14, 6620, 9, 15, 4502, 10, 14, 48322, 10, 15, 6092, // 10,14
- 9, 15, 7383, 9, 16, 4967, 10, 15, 46541, 10, 16, 6645, // 10,15
- 11, 0, 45791, 11, 1, 6986, 12, 0, 7587, 12, 1, 5172, // 11, 0
- 11, 1, 47453, 11, 2, 6472, 12, 1, 6875, 12, 2, 4736, // 11, 1
- 11, 2, 49147, 11, 3, 5930, 12, 2, 6168, 12, 3, 4291, // 11, 2
- 11, 3, 50843, 11, 4, 5373, 12, 3, 5474, 12, 4, 3846, // 11, 3
- 11, 4, 52484, 11, 5, 4822, 12, 4, 4816, 12, 5, 3414, // 11, 4
- 11, 5, 53975, 11, 6, 4313, 12, 5, 4226, 12, 6, 3022, // 11, 5
- 11, 6, 55166, 11, 7, 3904, 12, 6, 3755, 12, 7, 2711, // 11, 6
- 11, 7, 55870, 11, 8, 3672, 12, 7, 3469, 12, 8, 2525, // 11, 7
- 10, 8, 3473, 10, 9, 2525, 11, 8, 55867, 11, 9, 3671, // 11, 8
- 10, 9, 3759, 10, 10, 2711, 11, 9, 55164, 11, 10, 3902, // 11, 9
- 10, 10, 4230, 10, 11, 3023, 11, 10, 53973, 11, 11, 4310, // 11,10
- 10, 11, 4822, 10, 12, 3415, 11, 11, 52484, 11, 12, 4815, // 11,11
- 10, 12, 5481, 10, 13, 3845, 11, 12, 50844, 11, 13, 5366, // 11,12
- 10, 13, 6176, 10, 14, 4290, 11, 13, 49150, 11, 14, 5920, // 11,13
- 10, 14, 6886, 10, 15, 4734, 11, 14, 47458, 11, 15, 6458, // 11,14
- 10, 15, 7599, 10, 16, 5169, 11, 15, 45799, 11, 16, 6969, // 11,15
- 12, 0, 44901, 12, 1, 7374, 13, 0, 7848, 13, 1, 5413, // 12, 0
- 12, 1, 46427, 12, 2, 6908, 13, 1, 7191, 13, 2, 5010, // 12, 1
- 12, 2, 47953, 12, 3, 6426, 13, 2, 6549, 13, 3, 4608, // 12, 2
- 12, 3, 49445, 12, 4, 5943, 13, 3, 5934, 13, 4, 4214, // 12, 3
- 12, 4, 50844, 12, 5, 5481, 13, 4, 5365, 13, 5, 3846, // 12, 4
- 12, 5, 52069, 12, 6, 5073, 13, 5, 4872, 13, 6, 3522, // 12, 5
- 12, 6, 53012, 12, 7, 4762, 13, 6, 4489, 13, 7, 3273, // 12, 6
- 12, 7, 53562, 12, 8, 4594, 13, 7, 4254, 13, 8, 3126, // 12, 7
- 11, 8, 4259, 11, 9, 3128, 12, 8, 53557, 12, 9, 4592, // 12, 8
- 11, 9, 4495, 11, 10, 3274, 12, 9, 53008, 12, 10, 4759, // 12, 9
- 11, 10, 4879, 11, 11, 3523, 12, 10, 52066, 12, 11, 5068, // 12,10
- 11, 11, 5373, 11, 12, 3846, 12, 11, 50843, 12, 12, 5474, // 12,11
- 11, 12, 5943, 11, 13, 4214, 12, 12, 49445, 12, 13, 5934, // 12,12
- 11, 13, 6560, 11, 14, 4607, 12, 13, 47955, 12, 14, 6414, // 12,13
- 11, 14, 7204, 11, 15, 5009, 12, 14, 46430, 12, 15, 6893, // 12,14
- 11, 15, 7863, 11, 16, 5410, 12, 15, 44907, 12, 16, 7356, // 12,15
- 13, 0, 43900, 13, 1, 7812, 14, 0, 8141, 14, 1, 5683, // 13, 0
- 13, 1, 45286, 13, 2, 7395, 14, 1, 7539, 14, 2, 5316, // 13, 1
- 13, 2, 46650, 13, 3, 6973, 14, 2, 6959, 14, 3, 4954, // 13, 2
- 13, 3, 47955, 13, 4, 6560, 14, 3, 6414, 14, 4, 4607, // 13, 3
- 13, 4, 49150, 13, 5, 6176, 14, 4, 5920, 14, 5, 4290, // 13, 4
- 13, 5, 50171, 13, 6, 5848, 14, 5, 5499, 14, 6, 4018, // 13, 5
- 13, 6, 50942, 13, 7, 5606, 14, 6, 5175, 14, 7, 3813, // 13, 6
- 13, 7, 51395, 13, 8, 5480, 14, 7, 4970, 14, 8, 3691, // 13, 7
- 12, 8, 4978, 12, 9, 3693, 13, 8, 51387, 13, 9, 5478, // 13, 8
- 12, 9, 5184, 12, 10, 3815, 13, 9, 50935, 13, 10, 5602, // 13, 9
- 12, 10, 5508, 12, 11, 4020, 13, 10, 50165, 13, 11, 5843, // 13,10
- 12, 11, 5930, 12, 12, 4291, 13, 11, 49147, 13, 12, 6168, // 13,11
- 12, 12, 6426, 12, 13, 4608, 13, 12, 47953, 13, 13, 6549, // 13,12
- 12, 13, 6973, 12, 14, 4954, 13, 13, 46650, 13, 14, 6959, // 13,13
- 12, 14, 7555, 12, 15, 5315, 13, 14, 45288, 13, 15, 7378, // 13,14
- 12, 15, 8159, 12, 16, 5682, 13, 15, 43904, 13, 16, 7791, // 13,15
- 14, 0, 42821, 14, 1, 8288, 15, 0, 8452, 15, 1, 5975, // 14, 0
- 14, 1, 44074, 14, 2, 7921, 15, 1, 7901, 15, 2, 5640, // 14, 1
- 14, 2, 45288, 14, 3, 7555, 15, 2, 7378, 15, 3, 5315, // 14, 2
- 14, 3, 46430, 14, 4, 7204, 15, 3, 6892, 15, 4, 5010, // 14, 3
- 14, 4, 47458, 14, 5, 6886, 15, 4, 6458, 15, 5, 4734, // 14, 4
- 14, 5, 48322, 14, 6, 6620, 15, 5, 6092, 15, 6, 4502, // 14, 5
- 14, 6, 48969, 14, 7, 6430, 15, 6, 5809, 15, 7, 4328, // 14, 6
- 14, 7, 49358, 14, 8, 6335, 15, 7, 5623, 15, 8, 4220, // 14, 7
- 13, 8, 5633, 13, 9, 4224, 14, 8, 49347, 14, 9, 6332, // 14, 8
- 13, 9, 5820, 13, 10, 4330, 14, 9, 48960, 14, 10, 6426, // 14, 9
- 13, 10, 6104, 13, 11, 4505, 14, 10, 48314, 14, 11, 6613, // 14,10
- 13, 11, 6472, 13, 12, 4736, 14, 11, 47453, 14, 12, 6875, // 14,11
- 13, 12, 6908, 13, 13, 5011, 14, 12, 46427, 14, 13, 7190, // 14,12
- 13, 13, 7395, 13, 14, 5316, 14, 13, 45286, 14, 14, 7539, // 14,13
- 13, 14, 7921, 13, 15, 5640, 14, 14, 44074, 14, 15, 7901, // 14,14
- 13, 15, 8474, 13, 16, 5974, 14, 15, 42823, 14, 16, 8265, // 14,15
- 15, 0, 41693, 15, 1, 8795, 16, 0, 8769, 16, 1, 6279, // 15, 0
- 15, 1, 42823, 15, 2, 8474, 16, 1, 8265, 16, 2, 5974, // 15, 1
- 15, 2, 43904, 15, 3, 8159, 16, 2, 7791, 16, 3, 5682, // 15, 2
- 15, 3, 44907, 15, 4, 7863, 16, 3, 7356, 16, 4, 5410, // 15, 3
- 15, 4, 45799, 15, 5, 7599, 16, 4, 6970, 16, 5, 5168, // 15, 4
- 15, 5, 46541, 15, 6, 7383, 16, 5, 6644, 16, 6, 4968, // 15, 5
- 15, 6, 47098, 15, 7, 7233, 16, 6, 6391, 16, 7, 4814, // 15, 6
- 15, 7, 47440, 15, 8, 7161, 16, 7, 6217, 16, 8, 4718, // 15, 7
- 14, 8, 6230, 14, 9, 4722, 15, 8, 47426, 15, 9, 7158, // 15, 8
- 14, 9, 6405, 14, 10, 4818, 15, 9, 47086, 15, 10, 7227, // 15, 9
- 14, 10, 6659, 14, 11, 4971, 15, 10, 46532, 15, 11, 7374, // 15,10
- 14, 11, 6986, 14, 12, 5172, 15, 11, 45791, 15, 12, 7587, // 15,11
- 14, 12, 7374, 14, 13, 5413, 15, 12, 44901, 15, 13, 7848, // 15,12
- 14, 13, 7812, 14, 14, 5684, 15, 13, 43900, 15, 14, 8140, // 15,13
- 14, 14, 8288, 14, 15, 5975, 15, 14, 42821, 15, 15, 8452, // 15,14
- 14, 15, 8795, 14, 16, 6280, 15, 15, 41693, 15, 16, 8768, // 15,15
- // angle of 1.5 degrees
- 0, -1, 11440, 0, 0, 34212, 1, -1, 8358, 1, 0, 11526, // 0, 0
- 0, 0, 11192, 0, 1, 35502, 1, 0, 7987, 1, 1, 10855, // 0, 1
- 0, 1, 10930, 0, 2, 36756, 1, 1, 7626, 1, 2, 10224, // 0, 2
- 0, 2, 10670, 0, 3, 37939, 1, 2, 7285, 1, 3, 9642, // 0, 3
- 0, 3, 10430, 0, 4, 39009, 1, 3, 6975, 1, 4, 9122, // 0, 4
- 0, 4, 10232, 0, 5, 39918, 1, 4, 6710, 1, 5, 8676, // 0, 5
- 0, 5, 10100, 0, 6, 40618, 1, 5, 6502, 1, 6, 8316, // 0, 6
- 0, 6, 10052, 0, 7, 41072, 1, 6, 6360, 1, 7, 8052, // 0, 7
- -1, 7, 6346, -1, 8, 8018, 0, 7, 10066, 0, 8, 41106, // 0, 8
- -1, 8, 6489, -1, 9, 8278, 0, 8, 10123, 0, 9, 40646, // 0, 9
- -1, 9, 6699, -1, 10, 8632, 0, 9, 10265, 0, 10, 39940, // 0,10
- -1, 10, 6965, -1, 11, 9072, 0, 10, 10473, 0, 11, 39026, // 0,11
- -1, 11, 7276, -1, 12, 9585, 0, 11, 10723, 0, 12, 37952, // 0,12
- -1, 12, 7620, -1, 13, 10158, 0, 12, 10994, 0, 13, 36764, // 0,13
- -1, 13, 7983, -1, 14, 10780, 0, 13, 11267, 0, 14, 35506, // 0,14
- -1, 14, 8358, -1, 15, 11440, 0, 14, 11526, 0, 15, 34212, // 0,15
- 1, -1, 10780, 1, 0, 35506, 2, -1, 7983, 2, 0, 11267, // 1, 0
- 1, 0, 10467, 1, 1, 36959, 2, 0, 7579, 2, 1, 10531, // 1, 1
- 1, 1, 10133, 1, 2, 38390, 2, 1, 7179, 2, 2, 9834, // 1, 2
- 1, 2, 9796, 1, 3, 39759, 2, 2, 6797, 2, 3, 9184, // 1, 3
- 1, 3, 9478, 1, 4, 41013, 2, 3, 6447, 2, 4, 8598, // 1, 4
- 1, 4, 9206, 1, 5, 42087, 2, 4, 6145, 2, 5, 8098, // 1, 5
- 1, 5, 9014, 1, 6, 42913, 2, 5, 5910, 2, 6, 7699, // 1, 6
- 1, 6, 8929, 1, 7, 43433, 2, 6, 5756, 2, 7, 7418, // 1, 7
- 0, 7, 5745, 0, 8, 7390, 1, 7, 8939, 1, 8, 43462, // 1, 8
- 0, 8, 5900, 0, 9, 7667, 1, 8, 9032, 1, 9, 42937, // 1, 9
- 0, 9, 6137, 0, 10, 8061, 1, 9, 9233, 1, 10, 42105, // 1,10
- 0, 10, 6440, 0, 11, 8557, 1, 10, 9513, 1, 11, 41026, // 1,11
- 0, 11, 6792, 0, 12, 9135, 1, 11, 9841, 1, 12, 39768, // 1,12
- 0, 12, 7177, 0, 13, 9777, 1, 12, 10188, 1, 13, 38394, // 1,13
- 0, 13, 7579, 0, 14, 10467, 1, 13, 10532, 1, 14, 36958, // 1,14
- 0, 14, 7987, 0, 15, 11192, 1, 14, 10855, 1, 15, 35502, // 1,15
- 2, -1, 10158, 2, 0, 36764, 3, -1, 7620, 3, 0, 10994, // 2, 0
- 2, 0, 9777, 2, 1, 38394, 3, 0, 7177, 3, 1, 10188, // 2, 1
- 2, 1, 9366, 2, 2, 40025, 3, 1, 6732, 3, 2, 9413, // 2, 2
- 2, 2, 8941, 2, 3, 41614, 3, 2, 6299, 3, 3, 8682, // 2, 3
- 2, 3, 8530, 2, 4, 43096, 3, 3, 5895, 3, 4, 8015, // 2, 4
- 2, 4, 8167, 2, 5, 44386, 3, 4, 5543, 3, 5, 7440, // 2, 5
- 2, 5, 7899, 2, 6, 45383, 3, 5, 5268, 3, 6, 6986, // 2, 6
- 2, 6, 7766, 2, 7, 45995, 3, 6, 5095, 3, 7, 6680, // 2, 7
- 1, 7, 5087, 1, 8, 6658, 2, 7, 7773, 2, 8, 46018, // 2, 8
- 1, 8, 5261, 1, 9, 6961, 2, 8, 7913, 2, 9, 45401, // 2, 9
- 1, 9, 5537, 1, 10, 7411, 2, 9, 8189, 2, 10, 44399, // 2,10
- 1, 10, 5891, 1, 11, 7981, 2, 10, 8559, 2, 11, 43105, // 2,11
- 1, 11, 6297, 1, 12, 8641, 2, 11, 8979, 2, 12, 41619, // 2,12
- 1, 12, 6732, 1, 13, 9366, 2, 12, 9413, 2, 13, 40025, // 2,13
- 1, 13, 7179, 1, 14, 10133, 2, 13, 9834, 2, 14, 38390, // 2,14
- 1, 14, 7626, 1, 15, 10930, 2, 14, 10224, 2, 15, 36756, // 2,15
- 3, -1, 9585, 3, 0, 37951, 4, -1, 7276, 4, 0, 10724, // 3, 0
- 3, 0, 9135, 3, 1, 39767, 4, 0, 6792, 4, 1, 9842, // 3, 1
- 3, 1, 8641, 3, 2, 41618, 4, 1, 6297, 4, 2, 8980, // 3, 2
- 3, 2, 8120, 3, 3, 43461, 4, 2, 5804, 4, 3, 8151, // 3, 3
- 3, 3, 7598, 3, 4, 45224, 4, 3, 5331, 4, 4, 7383, // 3, 4
- 3, 4, 7121, 3, 5, 46798, 4, 4, 4909, 4, 5, 6708, // 3, 5
- 3, 5, 6750, 3, 6, 48037, 4, 5, 4576, 4, 6, 6173, // 3, 6
- 3, 6, 6552, 3, 7, 48785, 4, 6, 4372, 4, 7, 5827, // 3, 7
- 2, 7, 4366, 2, 8, 5811, 3, 7, 6558, 3, 8, 48801, // 3, 8
- 2, 8, 4572, 2, 9, 6154, 3, 8, 6761, 3, 9, 48049, // 3, 9
- 2, 9, 4906, 2, 10, 6685, 3, 9, 7138, 3, 10, 46807, // 3,10
- 2, 10, 5330, 2, 11, 7356, 3, 10, 7622, 3, 11, 45228, // 3,11
- 2, 11, 5804, 2, 12, 8120, 3, 11, 8151, 3, 12, 43461, // 3,12
- 2, 12, 6299, 2, 13, 8941, 3, 12, 8681, 3, 13, 41615, // 3,13
- 2, 13, 6797, 2, 14, 9796, 3, 13, 9184, 3, 14, 39759, // 3,14
- 2, 14, 7285, 2, 15, 10670, 3, 14, 9642, 3, 15, 37939, // 3,15
- 4, -1, 9072, 4, 0, 39026, 5, -1, 6965, 5, 0, 10473, // 4, 0
- 4, 0, 8557, 4, 1, 41026, 5, 0, 6440, 5, 1, 9513, // 4, 1
- 4, 1, 7981, 4, 2, 43105, 5, 1, 5891, 5, 2, 8559, // 4, 2
- 4, 2, 7356, 4, 3, 45229, 5, 2, 5330, 5, 3, 7621, // 4, 3
- 4, 3, 6708, 4, 4, 47328, 5, 3, 4774, 5, 4, 6726, // 4, 4
- 4, 4, 6086, 4, 5, 49275, 5, 4, 4258, 5, 5, 5917, // 4, 5
- 4, 5, 5573, 4, 6, 50865, 5, 5, 3837, 5, 6, 5261, // 4, 6
- 4, 6, 5280, 4, 7, 51832, 5, 6, 3579, 5, 7, 4845, // 4, 7
- 3, 7, 3575, 3, 8, 4835, 4, 7, 5283, 4, 8, 51843, // 4, 8
- 3, 8, 3834, 3, 9, 5248, 4, 8, 5581, 4, 9, 50873, // 4, 9
- 3, 9, 4257, 3, 10, 5901, 4, 9, 6099, 4, 10, 49279, // 4,10
- 3, 10, 4774, 3, 11, 6708, 4, 10, 6727, 4, 11, 47327, // 4,11
- 3, 11, 5331, 3, 12, 7598, 4, 11, 7382, 4, 12, 45225, // 4,12
- 3, 12, 5895, 3, 13, 8530, 4, 12, 8015, 4, 13, 43096, // 4,13
- 3, 13, 6447, 3, 14, 9478, 4, 13, 8599, 4, 14, 41012, // 4,14
- 3, 14, 6975, 3, 15, 10430, 4, 14, 9122, 4, 15, 39009, // 4,15
- 5, -1, 8632, 5, 0, 39940, 6, -1, 6699, 6, 0, 10265, // 5, 0
- 5, 0, 8061, 5, 1, 42105, 6, 0, 6137, 6, 1, 9233, // 5, 1
- 5, 1, 7411, 5, 2, 44399, 6, 1, 5537, 6, 2, 8189, // 5, 2
- 5, 2, 6685, 5, 3, 46806, 6, 2, 4906, 6, 3, 7139, // 5, 3
- 5, 3, 5901, 5, 4, 49279, 6, 3, 4257, 6, 4, 6099, // 5, 4
- 5, 4, 5103, 5, 5, 51700, 6, 4, 3621, 6, 5, 5112, // 5, 5
- 5, 5, 4388, 5, 6, 53813, 6, 5, 3065, 6, 6, 4270, // 5, 6
- 5, 6, 3938, 5, 7, 55162, 6, 6, 2710, 6, 7, 3726, // 5, 7
- 4, 7, 2708, 4, 8, 3720, 5, 7, 3940, 5, 8, 55168, // 5, 8
- 4, 8, 3064, 4, 9, 4262, 5, 8, 4394, 5, 9, 53816, // 5, 9
- 4, 9, 3621, 4, 10, 5103, 5, 9, 5113, 5, 10, 51699, // 5,10
- 4, 10, 4258, 4, 11, 6086, 5, 10, 5917, 5, 11, 49275, // 5,11
- 4, 11, 4909, 4, 12, 7121, 5, 11, 6707, 5, 12, 46799, // 5,12
- 4, 12, 5543, 4, 13, 8167, 5, 12, 7440, 5, 13, 44386, // 5,13
- 4, 13, 6145, 4, 14, 9206, 5, 13, 8098, 5, 14, 42087, // 5,14
- 4, 14, 6710, 4, 15, 10232, 5, 14, 8676, 5, 15, 39918, // 5,15
- 6, -1, 8278, 6, 0, 40646, 7, -1, 6489, 7, 0, 10123, // 6, 0
- 6, 0, 7667, 6, 1, 42936, 7, 0, 5900, 7, 1, 9033, // 6, 1
- 6, 1, 6961, 6, 2, 45401, 7, 1, 5261, 7, 2, 7913, // 6, 2
- 6, 2, 6154, 6, 3, 48049, 7, 2, 4572, 7, 3, 6761, // 6, 3
- 6, 3, 5248, 6, 4, 50873, 7, 3, 3834, 7, 4, 5581, // 6, 4
- 6, 4, 4262, 6, 5, 53816, 7, 4, 3064, 7, 5, 4394, // 6, 5
- 6, 5, 3271, 6, 6, 56673, 7, 5, 2316, 7, 6, 3276, // 6, 6
- 6, 6, 2532, 6, 7, 58773, 7, 6, 1767, 7, 7, 2464, // 6, 7
- 5, 7, 1766, 5, 8, 2462, 6, 7, 2533, 6, 8, 58775, // 6, 8
- 5, 8, 2316, 5, 9, 3271, 6, 8, 3275, 6, 9, 56674, // 6, 9
- 5, 9, 3065, 5, 10, 4388, 6, 9, 4269, 6, 10, 53814, // 6,10
- 5, 10, 3837, 5, 11, 5573, 6, 10, 5261, 6, 11, 50865, // 6,11
- 5, 11, 4576, 5, 12, 6750, 6, 11, 6173, 6, 12, 48037, // 6,12
- 5, 12, 5268, 5, 13, 7899, 6, 12, 6986, 6, 13, 45383, // 6,13
- 5, 13, 5910, 5, 14, 9014, 6, 13, 7699, 6, 14, 42913, // 6,14
- 5, 14, 6502, 5, 15, 10100, 6, 14, 8316, 6, 15, 40618, // 6,15
- 7, -1, 8018, 7, 0, 41106, 8, -1, 6346, 8, 0, 10066, // 7, 0
- 7, 0, 7390, 7, 1, 43461, 8, 0, 5745, 8, 1, 8940, // 7, 1
- 7, 1, 6658, 7, 2, 46017, 8, 1, 5087, 8, 2, 7774, // 7, 2
- 7, 2, 5811, 7, 3, 48801, 8, 2, 4366, 8, 3, 6558, // 7, 3
- 7, 3, 4835, 7, 4, 51842, 8, 3, 3575, 8, 4, 5284, // 7, 4
- 7, 4, 3720, 7, 5, 55168, 8, 4, 2708, 8, 5, 3940, // 7, 5
- 7, 5, 2462, 7, 6, 58775, 8, 5, 1766, 8, 6, 2533, // 7, 6
- 7, 6, 1170, 7, 7, 62369, 8, 6, 827, 8, 7, 1170, // 7, 7
- 6, 7, 827, 6, 8, 1170, 7, 7, 1170, 7, 8, 62369, // 7, 8
- 6, 8, 1767, 6, 9, 2532, 7, 8, 2464, 7, 9, 58773, // 7, 9
- 6, 9, 2710, 6, 10, 3938, 7, 9, 3726, 7, 10, 55162, // 7,10
- 6, 10, 3579, 6, 11, 5280, 7, 10, 4846, 7, 11, 51831, // 7,11
- 6, 11, 4372, 6, 12, 6552, 7, 11, 5827, 7, 12, 48785, // 7,12
- 6, 12, 5095, 6, 13, 7766, 7, 12, 6680, 7, 13, 45995, // 7,13
- 6, 13, 5756, 6, 14, 8929, 7, 13, 7418, 7, 14, 43433, // 7,14
- 6, 14, 6360, 6, 15, 10052, 7, 14, 8052, 7, 15, 41072, // 7,15
- 8, 0, 41072, 8, 1, 8052, 9, 0, 10052, 9, 1, 6360, // 8, 0
- 8, 1, 43433, 8, 2, 7418, 9, 1, 8929, 9, 2, 5756, // 8, 1
- 8, 2, 45995, 8, 3, 6680, 9, 2, 7766, 9, 3, 5095, // 8, 2
- 8, 3, 48785, 8, 4, 5827, 9, 3, 6552, 9, 4, 4372, // 8, 3
- 8, 4, 51832, 8, 5, 4846, 9, 4, 5280, 9, 5, 3578, // 8, 4
- 8, 5, 55162, 8, 6, 3726, 9, 5, 3938, 9, 6, 2710, // 8, 5
- 8, 6, 58773, 8, 7, 2464, 9, 6, 2532, 9, 7, 1767, // 8, 6
- 8, 7, 62369, 8, 8, 1170, 9, 7, 1170, 9, 8, 827, // 8, 7
- 7, 8, 1170, 7, 9, 827, 8, 8, 62369, 8, 9, 1170, // 8, 8
- 7, 9, 2533, 7, 10, 1766, 8, 9, 58775, 8, 10, 2462, // 8, 9
- 7, 10, 3940, 7, 11, 2708, 8, 10, 55168, 8, 11, 3720, // 8,10
- 7, 11, 5283, 7, 12, 3575, 8, 11, 51842, 8, 12, 4836, // 8,11
- 7, 12, 6558, 7, 13, 4366, 8, 12, 48801, 8, 13, 5811, // 8,12
- 7, 13, 7773, 7, 14, 5087, 8, 13, 46017, 8, 14, 6659, // 8,13
- 7, 14, 8939, 7, 15, 5745, 8, 14, 43461, 8, 15, 7391, // 8,14
- 7, 15, 10066, 7, 16, 6346, 8, 15, 41106, 8, 16, 8018, // 8,15
- 9, 0, 40618, 9, 1, 8316, 10, 0, 10100, 10, 1, 6502, // 9, 0
- 9, 1, 42913, 9, 2, 7699, 10, 1, 9014, 10, 2, 5910, // 9, 1
- 9, 2, 45383, 9, 3, 6986, 10, 2, 7899, 10, 3, 5268, // 9, 2
- 9, 3, 48037, 9, 4, 6173, 10, 3, 6750, 10, 4, 4576, // 9, 3
- 9, 4, 50865, 9, 5, 5261, 10, 4, 5573, 10, 5, 3837, // 9, 4
- 9, 5, 53813, 9, 6, 4269, 10, 5, 4388, 10, 6, 3066, // 9, 5
- 9, 6, 56673, 9, 7, 3275, 10, 6, 3271, 10, 7, 2317, // 9, 6
- 9, 7, 58775, 9, 8, 2533, 10, 7, 2462, 10, 8, 1766, // 9, 7
- 8, 8, 2464, 8, 9, 1767, 9, 8, 58773, 9, 9, 2532, // 9, 8
- 8, 9, 3275, 8, 10, 2316, 9, 9, 56673, 9, 10, 3272, // 9, 9
- 8, 10, 4394, 8, 11, 3064, 9, 10, 53816, 9, 11, 4262, // 9,10
- 8, 11, 5581, 8, 12, 3834, 9, 11, 50873, 9, 12, 5248, // 9,11
- 8, 12, 6761, 8, 13, 4572, 9, 12, 48049, 9, 13, 6154, // 9,12
- 8, 13, 7913, 8, 14, 5261, 9, 13, 45401, 9, 14, 6961, // 9,13
- 8, 14, 9032, 8, 15, 5900, 9, 14, 42936, 9, 15, 7668, // 9,14
- 8, 15, 10123, 8, 16, 6489, 9, 15, 40646, 9, 16, 8278, // 9,15
- 10, 0, 39918, 10, 1, 8676, 11, 0, 10232, 11, 1, 6710, // 10, 0
- 10, 1, 42087, 10, 2, 8098, 11, 1, 9206, 11, 2, 6145, // 10, 1
- 10, 2, 44386, 10, 3, 7440, 11, 2, 8167, 11, 3, 5543, // 10, 2
- 10, 3, 46798, 10, 4, 6707, 11, 3, 7121, 11, 4, 4910, // 10, 3
- 10, 4, 49275, 10, 5, 5917, 11, 4, 6086, 11, 5, 4258, // 10, 4
- 10, 5, 51700, 10, 6, 5113, 11, 5, 5103, 11, 6, 3620, // 10, 5
- 10, 6, 53816, 10, 7, 4394, 11, 6, 4262, 11, 7, 3064, // 10, 6
- 10, 7, 55168, 10, 8, 3940, 11, 7, 3720, 11, 8, 2708, // 10, 7
- 9, 8, 3726, 9, 9, 2710, 10, 8, 55162, 10, 9, 3938, // 10, 8
- 9, 9, 4269, 9, 10, 3065, 10, 9, 53813, 10, 10, 4389, // 10, 9
- 9, 10, 5113, 9, 11, 3621, 10, 10, 51700, 10, 11, 5102, // 10,10
- 9, 11, 6099, 9, 12, 4257, 10, 11, 49279, 10, 12, 5901, // 10,11
- 9, 12, 7138, 9, 13, 4906, 10, 12, 46806, 10, 13, 6686, // 10,12
- 9, 13, 8189, 9, 14, 5537, 10, 13, 44399, 10, 14, 7411, // 10,13
- 9, 14, 9233, 9, 15, 6137, 10, 14, 42105, 10, 15, 8061, // 10,14
- 9, 15, 10265, 9, 16, 6699, 10, 15, 39940, 10, 16, 8632, // 10,15
- 11, 0, 39009, 11, 1, 9122, 12, 0, 10430, 12, 1, 6975, // 11, 0
- 11, 1, 41013, 11, 2, 8599, 12, 1, 9478, 12, 2, 6446, // 11, 1
- 11, 2, 43096, 11, 3, 8015, 12, 2, 8530, 12, 3, 5895, // 11, 2
- 11, 3, 45224, 11, 4, 7382, 12, 3, 7598, 12, 4, 5332, // 11, 3
- 11, 4, 47328, 11, 5, 6727, 12, 4, 6708, 12, 5, 4773, // 11, 4
- 11, 5, 49279, 11, 6, 6099, 12, 5, 5901, 12, 6, 4257, // 11, 5
- 11, 6, 50873, 11, 7, 5581, 12, 6, 5248, 12, 7, 3834, // 11, 6
- 11, 7, 51842, 11, 8, 5283, 12, 7, 4835, 12, 8, 3576, // 11, 7
- 10, 8, 4846, 10, 9, 3579, 11, 8, 51832, 11, 9, 5279, // 11, 8
- 10, 9, 5261, 10, 10, 3837, 11, 9, 50865, 11, 10, 5573, // 11, 9
- 10, 10, 5917, 10, 11, 4258, 11, 10, 49275, 11, 11, 6086, // 11,10
- 10, 11, 6727, 10, 12, 4774, 11, 11, 47328, 11, 12, 6707, // 11,11
- 10, 12, 7622, 10, 13, 5330, 11, 12, 45229, 11, 13, 7355, // 11,12
- 10, 13, 8559, 10, 14, 5891, 11, 13, 43105, 11, 14, 7981, // 11,13
- 10, 14, 9513, 10, 15, 6440, 11, 14, 41026, 11, 15, 8557, // 11,14
- 10, 15, 10473, 10, 16, 6965, 11, 15, 39026, 11, 16, 9072, // 11,15
- 12, 0, 37939, 12, 1, 9642, 13, 0, 10670, 13, 1, 7285, // 12, 0
- 12, 1, 39759, 12, 2, 9184, 13, 1, 9796, 13, 2, 6797, // 12, 1
- 12, 2, 41614, 12, 3, 8681, 13, 2, 8941, 13, 3, 6300, // 12, 2
- 12, 3, 43461, 12, 4, 8151, 13, 3, 8120, 13, 4, 5804, // 12, 3
- 12, 4, 45229, 12, 5, 7622, 13, 4, 7356, 13, 5, 5329, // 12, 4
- 12, 5, 46806, 12, 6, 7138, 13, 5, 6685, 13, 6, 4907, // 12, 5
- 12, 6, 48049, 12, 7, 6761, 13, 6, 6154, 13, 7, 4572, // 12, 6
- 12, 7, 48801, 12, 8, 6558, 13, 7, 5811, 13, 8, 4366, // 12, 7
- 11, 8, 5827, 11, 9, 4372, 12, 8, 48785, 12, 9, 6552, // 12, 8
- 11, 9, 6173, 11, 10, 4576, 12, 9, 48037, 12, 10, 6750, // 12, 9
- 11, 10, 6707, 11, 11, 4909, 12, 10, 46798, 12, 11, 7122, // 12,10
- 11, 11, 7382, 11, 12, 5331, 12, 11, 45224, 12, 12, 7599, // 12,11
- 11, 12, 8151, 11, 13, 5804, 12, 12, 43461, 12, 13, 8120, // 12,12
- 11, 13, 8979, 11, 14, 6297, 12, 13, 41618, 12, 14, 8642, // 12,13
- 11, 14, 9841, 11, 15, 6792, 12, 14, 39767, 12, 15, 9136, // 12,14
- 11, 15, 10723, 11, 16, 7276, 12, 15, 37951, 12, 16, 9586, // 12,15
- 13, 0, 36756, 13, 1, 10224, 14, 0, 10930, 14, 1, 7626, // 13, 0
- 13, 1, 38390, 13, 2, 9834, 14, 1, 10133, 14, 2, 7179, // 13, 1
- 13, 2, 40025, 13, 3, 9413, 14, 2, 9366, 14, 3, 6732, // 13, 2
- 13, 3, 41618, 13, 4, 8979, 14, 3, 8641, 14, 4, 6298, // 13, 3
- 13, 4, 43105, 13, 5, 8559, 14, 4, 7981, 14, 5, 5891, // 13, 4
- 13, 5, 44399, 13, 6, 8189, 14, 5, 7411, 14, 6, 5537, // 13, 5
- 13, 6, 45401, 13, 7, 7913, 14, 6, 6961, 14, 7, 5261, // 13, 6
- 13, 7, 46017, 13, 8, 7773, 14, 7, 6658, 14, 8, 5088, // 13, 7
- 12, 8, 6680, 12, 9, 5095, 13, 8, 45995, 13, 9, 7766, // 13, 8
- 12, 9, 6986, 12, 10, 5268, 13, 9, 45383, 13, 10, 7899, // 13, 9
- 12, 10, 7440, 12, 11, 5543, 13, 10, 44386, 13, 11, 8167, // 13,10
- 12, 11, 8015, 12, 12, 5895, 13, 11, 43096, 13, 12, 8530, // 13,11
- 12, 12, 8681, 12, 13, 6299, 13, 12, 41614, 13, 13, 8942, // 13,12
- 12, 13, 9413, 12, 14, 6732, 13, 13, 40025, 13, 14, 9366, // 13,13
- 12, 14, 10188, 12, 15, 7177, 13, 14, 38394, 13, 15, 9777, // 13,14
- 12, 15, 10994, 12, 16, 7620, 13, 15, 36764, 13, 16, 10158, // 13,15
- 14, 0, 35502, 14, 1, 10855, 15, 0, 11192, 15, 1, 7987, // 14, 0
- 14, 1, 36959, 14, 2, 10532, 15, 1, 10467, 15, 2, 7578, // 14, 1
- 14, 2, 38394, 14, 3, 10188, 15, 2, 9777, 15, 3, 7177, // 14, 2
- 14, 3, 39767, 14, 4, 9841, 15, 3, 9135, 15, 4, 6793, // 14, 3
- 14, 4, 41026, 14, 5, 9513, 15, 4, 8557, 15, 5, 6440, // 14, 4
- 14, 5, 42105, 14, 6, 9233, 15, 5, 8061, 15, 6, 6137, // 14, 5
- 14, 6, 42936, 14, 7, 9032, 15, 6, 7667, 15, 7, 5901, // 14, 6
- 14, 7, 43461, 14, 8, 8939, 15, 7, 7390, 15, 8, 5746, // 14, 7
- 13, 8, 7418, 13, 9, 5756, 14, 8, 43433, 14, 9, 8929, // 14, 8
- 13, 9, 7699, 13, 10, 5910, 14, 9, 42913, 14, 10, 9014, // 14, 9
- 13, 10, 8098, 13, 11, 6145, 14, 10, 42087, 14, 11, 9206, // 14,10
- 13, 11, 8599, 13, 12, 6447, 14, 11, 41013, 14, 12, 9477, // 14,11
- 13, 12, 9184, 13, 13, 6797, 14, 12, 39759, 14, 13, 9796, // 14,12
- 13, 13, 9834, 13, 14, 7179, 14, 13, 38390, 14, 14, 10133, // 14,13
- 13, 14, 10532, 13, 15, 7579, 14, 14, 36959, 14, 15, 10466, // 14,14
- 13, 15, 11267, 13, 16, 7983, 14, 15, 35506, 14, 16, 10780, // 14,15
- 15, 0, 34212, 15, 1, 11526, 16, 0, 11440, 16, 1, 8358, // 15, 0
- 15, 1, 35506, 15, 2, 11267, 16, 1, 10780, 16, 2, 7983, // 15, 1
- 15, 2, 36764, 15, 3, 10994, 16, 2, 10158, 16, 3, 7620, // 15, 2
- 15, 3, 37951, 15, 4, 10723, 16, 3, 9585, 16, 4, 7277, // 15, 3
- 15, 4, 39026, 15, 5, 10473, 16, 4, 9072, 16, 5, 6965, // 15, 4
- 15, 5, 39940, 15, 6, 10265, 16, 5, 8632, 16, 6, 6699, // 15, 5
- 15, 6, 40646, 15, 7, 10123, 16, 6, 8278, 16, 7, 6489, // 15, 6
- 15, 7, 41106, 15, 8, 10066, 16, 7, 8018, 16, 8, 6346, // 15, 7
- 14, 8, 8052, 14, 9, 6360, 15, 8, 41072, 15, 9, 10052, // 15, 8
- 14, 9, 8316, 14, 10, 6502, 15, 9, 40618, 15, 10, 10100, // 15, 9
- 14, 10, 8676, 14, 11, 6710, 15, 10, 39918, 15, 11, 10232, // 15,10
- 14, 11, 9122, 14, 12, 6975, 15, 11, 39009, 15, 12, 10430, // 15,11
- 14, 12, 9642, 14, 13, 7285, 15, 12, 37939, 15, 13, 10670, // 15,12
- 14, 13, 10224, 14, 14, 7626, 15, 13, 36756, 15, 14, 10930, // 15,13
- 14, 14, 10855, 14, 15, 7987, 15, 14, 35502, 15, 15, 11192, // 15,14
- 14, 15, 11526, 14, 16, 8358, 15, 15, 34212, 15, 16, 11440, // 15,15
- // angle of 2.0 degrees
- 0, -1, 13368, 0, 0, 28495, 1, -1, 10104, 1, 0, 13569, // 0, 0
- 0, 0, 13291, 0, 1, 29828, 1, 0, 9671, 1, 1, 12746, // 0, 1
- 0, 1, 13176, 0, 2, 31138, 1, 1, 9245, 1, 2, 11977, // 0, 2
- 0, 2, 13038, 0, 3, 32391, 1, 2, 8838, 1, 3, 11269, // 0, 3
- 0, 3, 12899, 0, 4, 33539, 1, 3, 8463, 1, 4, 10635, // 0, 4
- 0, 4, 12783, 0, 5, 34532, 1, 4, 8135, 1, 5, 10086, // 0, 5
- 0, 5, 12717, 0, 6, 35315, 1, 5, 7868, 1, 6, 9636, // 0, 6
- 0, 6, 12728, 0, 7, 35844, 1, 6, 7674, 1, 7, 9290, // 0, 7
- -1, 7, 7643, -1, 8, 9224, 0, 7, 12764, 0, 8, 35905, // 0, 8
- -1, 8, 7839, -1, 9, 9558, 0, 8, 12777, 0, 9, 35362, // 0, 9
- -1, 9, 8107, -1, 10, 9995, 0, 9, 12867, 0, 10, 34567, // 0,10
- -1, 10, 8438, -1, 11, 10528, 0, 10, 13007, 0, 11, 33563, // 0,11
- -1, 11, 8816, -1, 12, 11143, 0, 11, 13171, 0, 12, 32406, // 0,12
- -1, 12, 9229, -1, 13, 11829, 0, 12, 13332, 0, 13, 31146, // 0,13
- -1, 13, 9662, -1, 14, 12574, 0, 13, 13470, 0, 14, 29830, // 0,14
- -1, 14, 10104, -1, 15, 13368, 0, 14, 13569, 0, 15, 28495, // 0,15
- 1, -1, 12574, 1, 0, 29831, 2, -1, 9662, 2, 0, 13469, // 1, 0
- 1, 0, 12412, 1, 1, 31358, 2, 0, 9202, 2, 1, 12564, // 1, 1
- 1, 1, 12203, 1, 2, 32881, 2, 1, 8742, 2, 2, 11710, // 1, 2
- 1, 2, 11964, 1, 3, 34358, 2, 2, 8296, 2, 3, 10918, // 1, 3
- 1, 3, 11721, 1, 4, 35730, 2, 3, 7881, 2, 4, 10204, // 1, 4
- 1, 4, 11507, 1, 5, 36926, 2, 4, 7517, 2, 5, 9586, // 1, 5
- 1, 5, 11360, 1, 6, 37866, 2, 5, 7224, 2, 6, 9086, // 1, 6
- 1, 6, 11317, 1, 7, 38481, 2, 6, 7020, 2, 7, 8718, // 1, 7
- 0, 7, 6997, 0, 8, 8662, 1, 7, 11344, 1, 8, 38533, // 1, 8
- 0, 8, 7202, 0, 9, 9020, 1, 8, 11407, 1, 9, 37907, // 1, 9
- 0, 9, 7497, 0, 10, 9509, 1, 9, 11575, 1, 10, 36955, // 1,10
- 0, 10, 7865, 0, 11, 10111, 1, 10, 11810, 1, 11, 35750, // 1,11
- 0, 11, 8284, 0, 12, 10808, 1, 11, 12074, 1, 12, 34370, // 1,12
- 0, 12, 8735, 0, 13, 11580, 1, 12, 12334, 1, 13, 32887, // 1,13
- 0, 13, 9202, 0, 14, 12412, 1, 13, 12564, 1, 14, 31358, // 1,14
- 0, 14, 9671, 0, 15, 13291, 1, 14, 12746, 1, 15, 29828, // 1,15
- 2, -1, 11829, 2, 0, 31146, 3, -1, 9229, 3, 0, 13332, // 2, 0
- 2, 0, 11580, 2, 1, 32886, 3, 0, 8735, 3, 1, 12335, // 2, 1
- 2, 1, 11272, 2, 2, 34650, 3, 1, 8232, 3, 2, 11382, // 2, 2
- 2, 2, 10922, 2, 3, 36392, 3, 2, 7734, 3, 3, 10488, // 2, 3
- 2, 3, 10559, 2, 4, 38042, 3, 3, 7261, 3, 4, 9674, // 2, 4
- 2, 4, 10226, 2, 5, 39503, 3, 4, 6842, 3, 5, 8965, // 2, 5
- 2, 5, 9977, 2, 6, 40656, 3, 5, 6506, 3, 6, 8397, // 2, 6
- 2, 6, 9867, 2, 7, 41389, 3, 6, 6284, 3, 7, 7996, // 2, 7
- 1, 7, 6266, 1, 8, 7951, 2, 7, 9886, 2, 8, 41433, // 2, 8
- 1, 8, 6491, 1, 9, 8344, 2, 8, 10013, 2, 9, 40688, // 2, 9
- 1, 9, 6829, 1, 10, 8902, 2, 9, 10279, 2, 10, 39526, // 2,10
- 1, 10, 7252, 1, 11, 9597, 2, 10, 10630, 2, 11, 38057, // 2,11
- 1, 11, 7728, 1, 12, 10397, 2, 11, 11012, 2, 12, 36399, // 2,12
- 1, 12, 8232, 1, 13, 11272, 2, 12, 11382, 2, 13, 34650, // 2,13
- 1, 13, 8742, 1, 14, 12203, 2, 13, 11709, 2, 14, 32882, // 2,14
- 1, 14, 9245, 1, 15, 13176, 2, 14, 11977, 2, 15, 31138, // 2,15
- 3, -1, 11143, 3, 0, 32406, 4, -1, 8816, 4, 0, 13171, // 3, 0
- 3, 0, 10808, 3, 1, 34369, 4, 0, 8284, 4, 1, 12075, // 3, 1
- 3, 1, 10397, 3, 2, 36399, 4, 1, 7728, 4, 2, 11012, // 3, 2
- 3, 2, 9924, 3, 3, 38450, 4, 2, 7164, 4, 3, 9998, // 3, 3
- 3, 3, 9421, 3, 4, 40444, 4, 3, 6615, 4, 4, 9056, // 3, 4
- 3, 4, 8940, 3, 5, 42256, 4, 4, 6116, 4, 5, 8224, // 3, 5
- 3, 5, 8558, 3, 6, 43710, 4, 5, 5712, 4, 6, 7556, // 3, 6
- 3, 6, 8359, 3, 7, 44616, 4, 6, 5454, 4, 7, 7107, // 3, 7
- 2, 7, 5443, 2, 8, 7072, 3, 7, 8373, 3, 8, 44648, // 3, 8
- 2, 8, 5703, 2, 9, 7516, 3, 8, 8584, 3, 9, 43733, // 3, 9
- 2, 9, 6108, 2, 10, 8175, 3, 9, 8982, 3, 10, 42271, // 3,10
- 2, 10, 6611, 2, 11, 8995, 3, 10, 9478, 3, 11, 40452, // 3,11
- 2, 11, 7164, 2, 12, 9924, 3, 11, 9998, 3, 12, 38450, // 3,12
- 2, 12, 7734, 2, 13, 10922, 3, 12, 10488, 3, 13, 36392, // 3,13
- 2, 13, 8296, 2, 14, 11964, 3, 13, 10918, 3, 14, 34358, // 3,14
- 2, 14, 8838, 2, 15, 13038, 3, 14, 11269, 3, 15, 32391, // 3,15
- 4, -1, 10528, 4, 0, 33564, 5, -1, 8438, 5, 0, 13006, // 4, 0
- 4, 0, 10111, 4, 1, 35750, 5, 0, 7865, 5, 1, 11810, // 4, 1
- 4, 1, 9597, 4, 2, 38057, 5, 1, 7252, 5, 2, 10630, // 4, 2
- 4, 2, 8995, 4, 3, 40452, 5, 2, 6611, 5, 3, 9478, // 4, 3
- 4, 3, 8332, 4, 4, 42861, 5, 3, 5965, 5, 4, 8378, // 4, 4
- 4, 4, 7667, 4, 5, 45139, 5, 4, 5353, 5, 5, 7377, // 4, 5
- 4, 5, 7100, 4, 6, 47035, 5, 5, 4843, 5, 6, 6558, // 4, 6
- 4, 6, 6774, 4, 7, 48218, 5, 6, 4521, 5, 7, 6023, // 4, 7
- 3, 7, 4513, 3, 8, 6000, 4, 7, 6783, 4, 8, 48240, // 4, 8
- 3, 8, 4838, 3, 9, 6530, 4, 8, 7119, 4, 9, 47049, // 4, 9
- 3, 9, 5350, 3, 10, 7342, 4, 9, 7698, 4, 10, 45146, // 4,10
- 3, 10, 5965, 3, 11, 8332, 4, 10, 8378, 4, 11, 42861, // 4,11
- 3, 11, 6615, 3, 12, 9421, 4, 11, 9056, 4, 12, 40444, // 4,12
- 3, 12, 7261, 3, 13, 10559, 4, 12, 9674, 4, 13, 38042, // 4,13
- 3, 13, 7881, 3, 14, 11721, 4, 13, 10204, 4, 14, 35730, // 4,14
- 3, 14, 8463, 3, 15, 12899, 4, 14, 10635, 4, 15, 33539, // 4,15
- 5, -1, 9995, 5, 0, 34567, 6, -1, 8107, 6, 0, 12867, // 5, 0
- 5, 0, 9509, 5, 1, 36955, 6, 0, 7497, 6, 1, 11575, // 5, 1
- 5, 1, 8902, 5, 2, 39526, 6, 1, 6829, 6, 2, 10279, // 5, 2
- 5, 2, 8175, 5, 3, 42271, 6, 2, 6108, 6, 3, 8982, // 5, 3
- 5, 3, 7342, 5, 4, 45146, 6, 3, 5350, 6, 4, 7698, // 5, 4
- 5, 4, 6451, 5, 5, 48019, 6, 4, 4591, 6, 5, 6475, // 5, 5
- 5, 5, 5624, 5, 6, 50581, 6, 5, 3913, 6, 6, 5418, // 5, 6
- 5, 6, 5092, 5, 7, 52253, 6, 6, 3470, 6, 7, 4721, // 5, 7
- 4, 7, 3466, 4, 8, 4708, 5, 7, 5097, 5, 8, 52265, // 5, 8
- 4, 8, 3911, 4, 9, 5400, 5, 8, 5637, 5, 9, 50588, // 5, 9
- 4, 9, 4591, 4, 10, 6451, 5, 9, 6475, 5, 10, 48019, // 5,10
- 4, 10, 5353, 4, 11, 7667, 5, 10, 7377, 5, 11, 45139, // 5,11
- 4, 11, 6116, 4, 12, 8940, 5, 11, 8224, 5, 12, 42256, // 5,12
- 4, 12, 6842, 4, 13, 10226, 5, 12, 8966, 5, 13, 39502, // 5,13
- 4, 13, 7517, 4, 14, 11507, 5, 13, 9587, 5, 14, 36925, // 5,14
- 4, 14, 8135, 4, 15, 12783, 5, 14, 10086, 5, 15, 34532, // 5,15
- 6, -1, 9558, 6, 0, 35362, 7, -1, 7839, 7, 0, 12777, // 6, 0
- 6, 0, 9020, 6, 1, 37906, 7, 0, 7202, 7, 1, 11408, // 6, 1
- 6, 1, 8344, 6, 2, 40688, 7, 1, 6491, 7, 2, 10013, // 6, 2
- 6, 2, 7516, 6, 3, 43733, 7, 2, 5703, 7, 3, 8584, // 6, 3
- 6, 3, 6530, 6, 4, 47049, 7, 3, 4838, 7, 4, 7119, // 6, 4
- 6, 4, 5400, 6, 5, 50587, 7, 4, 3911, 7, 5, 5638, // 6, 5
- 6, 5, 4217, 6, 6, 54105, 7, 5, 2989, 7, 6, 4225, // 6, 6
- 6, 6, 3303, 6, 7, 56751, 7, 6, 2295, 7, 7, 3187, // 6, 7
- 5, 7, 2294, 5, 8, 3180, 6, 7, 3306, 6, 8, 56756, // 6, 8
- 5, 8, 2989, 5, 9, 4217, 6, 8, 4225, 6, 9, 54105, // 6, 9
- 5, 9, 3913, 5, 10, 5624, 6, 9, 5418, 6, 10, 50581, // 6,10
- 5, 10, 4843, 5, 11, 7100, 6, 10, 6558, 6, 11, 47035, // 6,11
- 5, 11, 5712, 5, 12, 8558, 6, 11, 7556, 6, 12, 43710, // 6,12
- 5, 12, 6506, 5, 13, 9977, 6, 12, 8397, 6, 13, 40656, // 6,13
- 5, 13, 7224, 5, 14, 11360, 6, 13, 9086, 6, 14, 37866, // 6,14
- 5, 14, 7868, 5, 15, 12717, 6, 14, 9635, 6, 15, 35316, // 6,15
- 7, -1, 9224, 7, 0, 35905, 8, -1, 7643, 8, 0, 12764, // 7, 0
- 7, 0, 8662, 7, 1, 38534, 8, 0, 6997, 8, 1, 11343, // 7, 1
- 7, 1, 7951, 7, 2, 41432, 8, 1, 6266, 8, 2, 9887, // 7, 2
- 7, 2, 7072, 7, 3, 44649, 8, 2, 5443, 8, 3, 8372, // 7, 3
- 7, 3, 6000, 7, 4, 48240, 8, 3, 4513, 8, 4, 6783, // 7, 4
- 7, 4, 4708, 7, 5, 52266, 8, 4, 3466, 8, 5, 5096, // 7, 5
- 7, 5, 3180, 7, 6, 56756, 8, 5, 2294, 8, 6, 3306, // 7, 6
- 7, 6, 1541, 7, 7, 61364, 8, 6, 1090, 8, 7, 1541, // 7, 7
- 6, 7, 1090, 6, 8, 1541, 7, 7, 1542, 7, 8, 61363, // 7, 8
- 6, 8, 2295, 6, 9, 3303, 7, 8, 3186, 7, 9, 56752, // 7, 9
- 6, 9, 3470, 6, 10, 5092, 7, 9, 4721, 7, 10, 52253, // 7,10
- 6, 10, 4521, 6, 11, 6774, 7, 10, 6023, 7, 11, 48218, // 7,11
- 6, 11, 5454, 6, 12, 8359, 7, 11, 7106, 7, 12, 44617, // 7,12
- 6, 12, 6284, 6, 13, 9867, 7, 12, 7996, 7, 13, 41389, // 7,13
- 6, 13, 7020, 6, 14, 11317, 7, 13, 8718, 7, 14, 38481, // 7,14
- 6, 14, 7674, 6, 15, 12728, 7, 14, 9290, 7, 15, 35844, // 7,15
- 8, 0, 35844, 8, 1, 9290, 9, 0, 12728, 9, 1, 7674, // 8, 0
- 8, 1, 38481, 8, 2, 8718, 9, 1, 11317, 9, 2, 7020, // 8, 1
- 8, 2, 41389, 8, 3, 7996, 9, 2, 9867, 9, 3, 6284, // 8, 2
- 8, 3, 44616, 8, 4, 7106, 9, 3, 8359, 9, 4, 5455, // 8, 3
- 8, 4, 48218, 8, 5, 6023, 9, 4, 6774, 9, 5, 4521, // 8, 4
- 8, 5, 52253, 8, 6, 4721, 9, 5, 5092, 9, 6, 3470, // 8, 5
- 8, 6, 56751, 8, 7, 3186, 9, 6, 3303, 9, 7, 2296, // 8, 6
- 8, 7, 61364, 8, 8, 1542, 9, 7, 1541, 9, 8, 1089, // 8, 7
- 7, 8, 1542, 7, 9, 1090, 8, 8, 61364, 8, 9, 1540, // 8, 8
- 7, 9, 3306, 7, 10, 2294, 8, 9, 56756, 8, 10, 3180, // 8, 9
- 7, 10, 5097, 7, 11, 3466, 8, 10, 52266, 8, 11, 4707, // 8,10
- 7, 11, 6783, 7, 12, 4513, 8, 11, 48240, 8, 12, 6000, // 8,11
- 7, 12, 8373, 7, 13, 5443, 8, 12, 44649, 8, 13, 7071, // 8,12
- 7, 13, 9886, 7, 14, 6266, 8, 13, 41432, 8, 14, 7952, // 8,13
- 7, 14, 11344, 7, 15, 6997, 8, 14, 38534, 8, 15, 8661, // 8,14
- 7, 15, 12764, 7, 16, 7643, 8, 15, 35905, 8, 16, 9224, // 8,15
- 9, 0, 35315, 9, 1, 9635, 10, 0, 12717, 10, 1, 7869, // 9, 0
- 9, 1, 37866, 9, 2, 9086, 10, 1, 11360, 10, 2, 7224, // 9, 1
- 9, 2, 40656, 9, 3, 8397, 10, 2, 9977, 10, 3, 6506, // 9, 2
- 9, 3, 43710, 9, 4, 7556, 10, 3, 8558, 10, 4, 5712, // 9, 3
- 9, 4, 47035, 9, 5, 6558, 10, 4, 7100, 10, 5, 4843, // 9, 4
- 9, 5, 50581, 9, 6, 5418, 10, 5, 5624, 10, 6, 3913, // 9, 5
- 9, 6, 54105, 9, 7, 4225, 10, 6, 4217, 10, 7, 2989, // 9, 6
- 9, 7, 56756, 9, 8, 3306, 10, 7, 3180, 10, 8, 2294, // 9, 7
- 8, 8, 3186, 8, 9, 2295, 9, 8, 56751, 9, 9, 3304, // 9, 8
- 8, 9, 4225, 8, 10, 2989, 9, 9, 54105, 9, 10, 4217, // 9, 9
- 8, 10, 5637, 8, 11, 3911, 9, 10, 50587, 9, 11, 5401, // 9,10
- 8, 11, 7119, 8, 12, 4838, 9, 11, 47049, 9, 12, 6530, // 9,11
- 8, 12, 8584, 8, 13, 5703, 9, 12, 43733, 9, 13, 7516, // 9,12
- 8, 13, 10013, 8, 14, 6491, 9, 13, 40688, 9, 14, 8344, // 9,13
- 8, 14, 11407, 8, 15, 7202, 9, 14, 37906, 9, 15, 9021, // 9,14
- 8, 15, 12777, 8, 16, 7839, 9, 15, 35362, 9, 16, 9558, // 9,15
- 10, 0, 34532, 10, 1, 10086, 11, 0, 12783, 11, 1, 8135, // 10, 0
- 10, 1, 36926, 10, 2, 9587, 11, 1, 11507, 11, 2, 7516, // 10, 1
- 10, 2, 39503, 10, 3, 8966, 11, 2, 10226, 11, 3, 6841, // 10, 2
- 10, 3, 42256, 10, 4, 8224, 11, 3, 8940, 11, 4, 6116, // 10, 3
- 10, 4, 45139, 10, 5, 7377, 11, 4, 7667, 11, 5, 5353, // 10, 4
- 10, 5, 48019, 10, 6, 6475, 11, 5, 6451, 11, 6, 4591, // 10, 5
- 10, 6, 50587, 10, 7, 5637, 11, 6, 5400, 11, 7, 3912, // 10, 6
- 10, 7, 52266, 10, 8, 5097, 11, 7, 4708, 11, 8, 3465, // 10, 7
- 9, 8, 4721, 9, 9, 3470, 10, 8, 52253, 10, 9, 5092, // 10, 8
- 9, 9, 5418, 9, 10, 3913, 10, 9, 50581, 10, 10, 5624, // 10, 9
- 9, 10, 6475, 9, 11, 4591, 10, 10, 48019, 10, 11, 6451, // 10,10
- 9, 11, 7698, 9, 12, 5350, 10, 11, 45146, 10, 12, 7342, // 10,11
- 9, 12, 8982, 9, 13, 6108, 10, 12, 42271, 10, 13, 8175, // 10,12
- 9, 13, 10279, 9, 14, 6829, 10, 13, 39526, 10, 14, 8902, // 10,13
- 9, 14, 11575, 9, 15, 7497, 10, 14, 36955, 10, 15, 9509, // 10,14
- 9, 15, 12867, 9, 16, 8107, 10, 15, 34567, 10, 16, 9995, // 10,15
- 11, 0, 33539, 11, 1, 10635, 12, 0, 12899, 12, 1, 8463, // 11, 0
- 11, 1, 35730, 11, 2, 10204, 12, 1, 11721, 12, 2, 7881, // 11, 1
- 11, 2, 38042, 11, 3, 9674, 12, 2, 10559, 12, 3, 7261, // 11, 2
- 11, 3, 40444, 11, 4, 9056, 12, 3, 9421, 12, 4, 6615, // 11, 3
- 11, 4, 42861, 11, 5, 8378, 12, 4, 8332, 12, 5, 5965, // 11, 4
- 11, 5, 45146, 11, 6, 7698, 12, 5, 7342, 12, 6, 5350, // 11, 5
- 11, 6, 47049, 11, 7, 7119, 12, 6, 6530, 12, 7, 4838, // 11, 6
- 11, 7, 48240, 11, 8, 6783, 12, 7, 6000, 12, 8, 4513, // 11, 7
- 10, 8, 6023, 10, 9, 4521, 11, 8, 48218, 11, 9, 6774, // 11, 8
- 10, 9, 6558, 10, 10, 4843, 11, 9, 47035, 11, 10, 7100, // 11, 9
- 10, 10, 7377, 10, 11, 5353, 11, 10, 45139, 11, 11, 7667, // 11,10
- 10, 11, 8378, 10, 12, 5965, 11, 11, 42861, 11, 12, 8332, // 11,11
- 10, 12, 9478, 10, 13, 6611, 11, 12, 40452, 11, 13, 8995, // 11,12
- 10, 13, 10630, 10, 14, 7252, 11, 13, 38057, 11, 14, 9597, // 11,13
- 10, 14, 11810, 10, 15, 7865, 11, 14, 35750, 11, 15, 10111, // 11,14
- 10, 15, 13007, 10, 16, 8438, 11, 15, 33564, 11, 16, 10527, // 11,15
- 12, 0, 32391, 12, 1, 11269, 13, 0, 13038, 13, 1, 8838, // 12, 0
- 12, 1, 34358, 12, 2, 10918, 13, 1, 11964, 13, 2, 8296, // 12, 1
- 12, 2, 36392, 12, 3, 10488, 13, 2, 10922, 13, 3, 7734, // 12, 2
- 12, 3, 38450, 12, 4, 9998, 13, 3, 9924, 13, 4, 7164, // 12, 3
- 12, 4, 40452, 12, 5, 9478, 13, 4, 8995, 13, 5, 6611, // 12, 4
- 12, 5, 42271, 12, 6, 8982, 13, 5, 8175, 13, 6, 6108, // 12, 5
- 12, 6, 43733, 12, 7, 8584, 13, 6, 7516, 13, 7, 5703, // 12, 6
- 12, 7, 44649, 12, 8, 8373, 13, 7, 7072, 13, 8, 5442, // 12, 7
- 11, 8, 7106, 11, 9, 5454, 12, 8, 44616, 12, 9, 8360, // 12, 8
- 11, 9, 7556, 11, 10, 5712, 12, 9, 43710, 12, 10, 8558, // 12, 9
- 11, 10, 8224, 11, 11, 6116, 12, 10, 42256, 12, 11, 8940, // 12,10
- 11, 11, 9056, 11, 12, 6615, 12, 11, 40444, 12, 12, 9421, // 12,11
- 11, 12, 9998, 11, 13, 7164, 12, 12, 38450, 12, 13, 9924, // 12,12
- 11, 13, 11012, 11, 14, 7728, 12, 13, 36399, 12, 14, 10397, // 12,13
- 11, 14, 12074, 11, 15, 8284, 12, 14, 34369, 12, 15, 10809, // 12,14
- 11, 15, 13171, 11, 16, 8816, 12, 15, 32406, 12, 16, 11143, // 12,15
- 13, 0, 31138, 13, 1, 11977, 14, 0, 13176, 14, 1, 9245, // 13, 0
- 13, 1, 32881, 13, 2, 11709, 14, 1, 12203, 14, 2, 8743, // 13, 1
- 13, 2, 34650, 13, 3, 11382, 14, 2, 11272, 14, 3, 8232, // 13, 2
- 13, 3, 36399, 13, 4, 11012, 14, 3, 10397, 14, 4, 7728, // 13, 3
- 13, 4, 38057, 13, 5, 10630, 14, 4, 9597, 14, 5, 7252, // 13, 4
- 13, 5, 39526, 13, 6, 10279, 14, 5, 8902, 14, 6, 6829, // 13, 5
- 13, 6, 40688, 13, 7, 10013, 14, 6, 8344, 14, 7, 6491, // 13, 6
- 13, 7, 41432, 13, 8, 9886, 14, 7, 7951, 14, 8, 6267, // 13, 7
- 12, 8, 7996, 12, 9, 6284, 13, 8, 41389, 13, 9, 9867, // 13, 8
- 12, 9, 8397, 12, 10, 6506, 13, 9, 40656, 13, 10, 9977, // 13, 9
- 12, 10, 8966, 12, 11, 6842, 13, 10, 39503, 13, 11, 10225, // 13,10
- 12, 11, 9674, 12, 12, 7261, 13, 11, 38042, 13, 12, 10559, // 13,11
- 12, 12, 10488, 12, 13, 7734, 13, 12, 36392, 13, 13, 10922, // 13,12
- 12, 13, 11382, 12, 14, 8232, 13, 13, 34650, 13, 14, 11272, // 13,13
- 12, 14, 12334, 12, 15, 8735, 13, 14, 32886, 13, 15, 11581, // 13,14
- 12, 15, 13332, 12, 16, 9229, 13, 15, 31146, 13, 16, 11829, // 13,15
- 14, 0, 29828, 14, 1, 12746, 15, 0, 13291, 15, 1, 9671, // 14, 0
- 14, 1, 31358, 14, 2, 12564, 15, 1, 12412, 15, 2, 9202, // 14, 1
- 14, 2, 32886, 14, 3, 12334, 15, 2, 11580, 15, 3, 8736, // 14, 2
- 14, 3, 34369, 14, 4, 12074, 15, 3, 10808, 15, 4, 8285, // 14, 3
- 14, 4, 35750, 14, 5, 11810, 15, 4, 10111, 15, 5, 7865, // 14, 4
- 14, 5, 36955, 14, 6, 11575, 15, 5, 9509, 15, 6, 7497, // 14, 5
- 14, 6, 37906, 14, 7, 11407, 15, 6, 9020, 15, 7, 7203, // 14, 6
- 14, 7, 38534, 14, 8, 11344, 15, 7, 8662, 15, 8, 6996, // 14, 7
- 13, 8, 8718, 13, 9, 7020, 14, 8, 38481, 14, 9, 11317, // 14, 8
- 13, 9, 9086, 13, 10, 7224, 14, 9, 37866, 14, 10, 11360, // 14, 9
- 13, 10, 9587, 13, 11, 7517, 14, 10, 36926, 14, 11, 11506, // 14,10
- 13, 11, 10204, 13, 12, 7881, 14, 11, 35730, 14, 12, 11721, // 14,11
- 13, 12, 10918, 13, 13, 8296, 14, 12, 34358, 14, 13, 11964, // 14,12
- 13, 13, 11709, 13, 14, 8742, 14, 13, 32881, 14, 14, 12204, // 14,13
- 13, 14, 12564, 13, 15, 9202, 14, 14, 31358, 14, 15, 12412, // 14,14
- 13, 15, 13470, 13, 16, 9662, 14, 15, 29831, 14, 16, 12573, // 14,15
- 15, 0, 28495, 15, 1, 13569, 16, 0, 13368, 16, 1, 10104, // 15, 0
- 15, 1, 29831, 15, 2, 13470, 16, 1, 12574, 16, 2, 9661, // 15, 1
- 15, 2, 31146, 15, 3, 13332, 16, 2, 11829, 16, 3, 9229, // 15, 2
- 15, 3, 32406, 15, 4, 13171, 16, 3, 11143, 16, 4, 8816, // 15, 3
- 15, 4, 33564, 15, 5, 13007, 16, 4, 10528, 16, 5, 8437, // 15, 4
- 15, 5, 34567, 15, 6, 12867, 16, 5, 9995, 16, 6, 8107, // 15, 5
- 15, 6, 35362, 15, 7, 12777, 16, 6, 9558, 16, 7, 7839, // 15, 6
- 15, 7, 35905, 15, 8, 12764, 16, 7, 9224, 16, 8, 7643, // 15, 7
- 14, 8, 9290, 14, 9, 7674, 15, 8, 35844, 15, 9, 12728, // 15, 8
- 14, 9, 9635, 14, 10, 7868, 15, 9, 35315, 15, 10, 12718, // 15, 9
- 14, 10, 10086, 14, 11, 8135, 15, 10, 34532, 15, 11, 12783, // 15,10
- 14, 11, 10635, 14, 12, 8463, 15, 11, 33539, 15, 12, 12899, // 15,11
- 14, 12, 11269, 14, 13, 8838, 15, 12, 32391, 15, 13, 13038, // 15,12
- 14, 13, 11977, 14, 14, 9245, 15, 13, 31138, 15, 14, 13176, // 15,13
- 14, 14, 12746, 14, 15, 9671, 15, 14, 29828, 15, 15, 13291, // 15,14
- 14, 15, 13569, 14, 16, 10104, 15, 15, 28495, 15, 16, 13368, // 15,15
- // angle of 2.5 degrees
- 0, -1, 14696, 0, 0, 24063, 1, -1, 11702, 1, 0, 15075, // 0, 0
- 0, 0, 14872, 0, 1, 25368, 1, 0, 11187, 1, 1, 14109, // 0, 1
- 0, 1, 14990, 0, 2, 26660, 1, 1, 10676, 1, 2, 13210, // 0, 2
- 0, 2, 15060, 0, 3, 27903, 1, 2, 10185, 1, 3, 12388, // 0, 3
- 0, 3, 15100, 0, 4, 29055, 1, 3, 9728, 1, 4, 11653, // 0, 4
- 0, 4, 15135, 0, 5, 30064, 1, 4, 9323, 1, 5, 11014, // 0, 5
- 0, 5, 15193, 0, 6, 30876, 1, 5, 8986, 1, 6, 10481, // 0, 6
- 0, 6, 15301, 0, 7, 31444, 1, 6, 8727, 1, 7, 10064, // 0, 7
- -1, 7, 8669, -1, 8, 9959, 0, 7, 15376, 0, 8, 31532, // 0, 8
- -1, 8, 8927, -1, 9, 10351, 0, 8, 15319, 0, 9, 30939, // 0, 9
- -1, 9, 9265, -1, 10, 10855, 0, 9, 15311, 0, 10, 30105, // 0,10
- -1, 10, 9673, -1, 11, 11461, 0, 10, 15325, 0, 11, 29077, // 0,11
- -1, 11, 10135, -1, 12, 12159, 0, 11, 15330, 0, 12, 27912, // 0,12
- -1, 12, 10637, -1, 13, 12938, 0, 12, 15301, 0, 13, 26660, // 0,13
- -1, 13, 11164, -1, 14, 13787, 0, 13, 15220, 0, 14, 25365, // 0,14
- -1, 14, 11702, -1, 15, 14696, 0, 14, 15076, 0, 15, 24062, // 0,15
- 1, -1, 13787, 1, 0, 25366, 2, -1, 11164, 2, 0, 15219, // 1, 0
- 1, 0, 13853, 1, 1, 26893, 2, 0, 10644, 2, 1, 14146, // 1, 1
- 1, 1, 13850, 1, 2, 28427, 2, 1, 10119, 2, 2, 13140, // 1, 2
- 1, 2, 13789, 1, 3, 29928, 2, 2, 9603, 2, 3, 12216, // 1, 3
- 1, 3, 13694, 1, 4, 31339, 2, 3, 9118, 2, 4, 11385, // 1, 4
- 1, 4, 13600, 1, 5, 32586, 2, 4, 8685, 2, 5, 10665, // 1, 5
- 1, 5, 13548, 1, 6, 33585, 2, 5, 8329, 2, 6, 10074, // 1, 6
- 1, 6, 13582, 1, 7, 34261, 2, 6, 8068, 2, 7, 9625, // 1, 7
- 0, 7, 8024, 0, 8, 9534, 1, 7, 13638, 1, 8, 34340, // 1, 8
- 0, 8, 8286, 0, 9, 9961, 1, 8, 13647, 1, 9, 33642, // 1, 9
- 0, 9, 8645, 0, 10, 10528, 1, 9, 13740, 1, 10, 32623, // 1,10
- 0, 10, 9082, 0, 11, 11218, 1, 10, 13875, 1, 11, 31361, // 1,11
- 0, 11, 9575, 0, 12, 12014, 1, 11, 14009, 1, 12, 29938, // 1,12
- 0, 12, 10102, 0, 13, 12897, 1, 12, 14107, 1, 13, 28430, // 1,13
- 0, 13, 10644, 0, 14, 13853, 1, 13, 14145, 1, 14, 26894, // 1,14
- 0, 14, 11187, 0, 15, 14872, 1, 14, 14109, 1, 15, 25368, // 1,15
- 2, -1, 12938, 2, 0, 26660, 3, -1, 10637, 3, 0, 15301, // 2, 0
- 2, 0, 12897, 2, 1, 28430, 3, 0, 10102, 3, 1, 14107, // 2, 1
- 2, 1, 12769, 2, 2, 30239, 3, 1, 9546, 3, 2, 12982, // 2, 2
- 2, 2, 12569, 2, 3, 32045, 3, 2, 8988, 3, 3, 11934, // 2, 3
- 2, 3, 12323, 2, 4, 33777, 3, 3, 8452, 3, 4, 10984, // 2, 4
- 2, 4, 12079, 2, 5, 35332, 3, 4, 7969, 3, 5, 10156, // 2, 5
- 2, 5, 11897, 2, 6, 36582, 3, 5, 7573, 3, 6, 9484, // 2, 6
- 2, 6, 11842, 2, 7, 37402, 3, 6, 7298, 3, 7, 8994, // 2, 7
- 1, 7, 7266, 1, 8, 8918, 2, 7, 11883, 2, 8, 37469, // 2, 8
- 1, 8, 7543, 1, 9, 9390, 2, 8, 11972, 2, 9, 36631, // 2, 9
- 1, 9, 7943, 1, 10, 10041, 2, 9, 12188, 2, 10, 35364, // 2,10
- 1, 10, 8432, 1, 11, 10842, 2, 10, 12467, 2, 11, 33795, // 2,11
- 1, 11, 8976, 1, 12, 11760, 2, 11, 12747, 2, 12, 32053, // 2,12
- 1, 12, 9546, 1, 13, 12769, 2, 12, 12982, 2, 13, 30239, // 2,13
- 1, 13, 10119, 1, 14, 13850, 2, 13, 13141, 2, 14, 28426, // 2,14
- 1, 14, 10676, 1, 15, 14990, 2, 14, 13211, 2, 15, 26659, // 2,15
- 3, -1, 12159, 3, 0, 27912, 4, -1, 10135, 4, 0, 15330, // 3, 0
- 3, 0, 12014, 3, 1, 29938, 4, 0, 9575, 4, 1, 14009, // 3, 1
- 3, 1, 11760, 3, 2, 32052, 4, 1, 8976, 4, 2, 12748, // 3, 2
- 3, 2, 11411, 3, 3, 34213, 4, 2, 8358, 4, 3, 11554, // 3, 3
- 3, 3, 10995, 3, 4, 36343, 4, 3, 7746, 4, 4, 10452, // 3, 4
- 3, 4, 10569, 3, 5, 38307, 4, 4, 7180, 4, 5, 9480, // 3, 5
- 3, 5, 10221, 3, 6, 39912, 4, 5, 6714, 4, 6, 8689, // 3, 6
- 3, 6, 10051, 3, 7, 40940, 4, 6, 6403, 4, 7, 8142, // 3, 7
- 2, 7, 6381, 2, 8, 8082, 3, 7, 10079, 3, 8, 40994, // 3, 8
- 2, 8, 6695, 2, 9, 8617, 3, 8, 10275, 3, 9, 39949, // 3, 9
- 2, 9, 7165, 2, 10, 9388, 3, 9, 10653, 3, 10, 38330, // 3,10
- 2, 10, 7737, 2, 11, 10337, 3, 10, 11108, 3, 11, 36354, // 3,11
- 2, 11, 8358, 2, 12, 11411, 3, 11, 11554, 3, 12, 34213, // 3,12
- 2, 12, 8988, 2, 13, 12569, 3, 12, 11934, 3, 13, 32045, // 3,13
- 2, 13, 9603, 2, 14, 13789, 3, 13, 12216, 3, 14, 29928, // 3,14
- 2, 14, 10185, 2, 15, 15060, 3, 14, 12388, 3, 15, 27903, // 3,15
- 4, -1, 11461, 4, 0, 29078, 5, -1, 9673, 5, 0, 15324, // 4, 0
- 4, 0, 11218, 4, 1, 31361, 5, 0, 9082, 5, 1, 13875, // 4, 1
- 4, 1, 10842, 4, 2, 33795, 5, 1, 8432, 5, 2, 12467, // 4, 2
- 4, 2, 10337, 4, 3, 36354, 5, 2, 7737, 5, 3, 11108, // 4, 3
- 4, 3, 9730, 4, 4, 38966, 5, 3, 7022, 5, 4, 9818, // 4, 4
- 4, 4, 9081, 4, 5, 41475, 5, 4, 6334, 5, 5, 8646, // 4, 5
- 4, 5, 8507, 4, 6, 43602, 5, 5, 5749, 5, 6, 7678, // 4, 6
- 4, 6, 8177, 4, 7, 44962, 5, 6, 5368, 5, 7, 7029, // 4, 7
- 3, 7, 5354, 3, 8, 6987, 4, 7, 8195, 4, 8, 45000, // 4, 8
- 3, 8, 5739, 3, 9, 7626, 4, 8, 8545, 4, 9, 43626, // 4, 9
- 3, 9, 6328, 3, 10, 8578, 4, 9, 9143, 4, 10, 41487, // 4,10
- 3, 10, 7022, 3, 11, 9730, 4, 10, 9818, 4, 11, 38966, // 4,11
- 3, 11, 7746, 3, 12, 10995, 4, 11, 10452, 4, 12, 36343, // 4,12
- 3, 12, 8452, 3, 13, 12323, 4, 12, 10983, 4, 13, 33778, // 4,13
- 3, 13, 9118, 3, 14, 13694, 4, 13, 11385, 4, 14, 31339, // 4,14
- 3, 14, 9728, 3, 15, 15100, 4, 14, 11652, 4, 15, 29056, // 4,15
- 5, -1, 10855, 5, 0, 30105, 6, -1, 9265, 6, 0, 15311, // 5, 0
- 5, 0, 10528, 5, 1, 32624, 6, 0, 8645, 6, 1, 13739, // 5, 1
- 5, 1, 10041, 5, 2, 35364, 6, 1, 7943, 6, 2, 12188, // 5, 2
- 5, 2, 9388, 5, 3, 38330, 6, 2, 7165, 6, 3, 10653, // 5, 3
- 5, 3, 8578, 5, 4, 41487, 6, 3, 6328, 6, 4, 9143, // 5, 4
- 5, 4, 7659, 5, 5, 44700, 6, 4, 5472, 6, 5, 7705, // 5, 5
- 5, 5, 6768, 5, 6, 47619, 6, 5, 4694, 6, 6, 6455, // 5, 6
- 5, 6, 6183, 5, 7, 49566, 6, 6, 4172, 6, 7, 5615, // 5, 7
- 4, 7, 4164, 4, 8, 5590, 5, 7, 6193, 5, 8, 49589, // 5, 8
- 4, 8, 4690, 4, 9, 6422, 5, 8, 6794, 5, 9, 47630, // 5, 9
- 4, 9, 5472, 4, 10, 7659, 5, 9, 7705, 5, 10, 44700, // 5,10
- 4, 10, 6334, 4, 11, 9081, 5, 10, 8646, 5, 11, 41475, // 5,11
- 4, 11, 7180, 4, 12, 10569, 5, 11, 9479, 5, 12, 38308, // 5,12
- 4, 12, 7969, 4, 13, 12079, 5, 12, 10156, 5, 13, 35332, // 5,13
- 4, 13, 8685, 4, 14, 13600, 5, 13, 10665, 5, 14, 32586, // 5,14
- 4, 14, 9323, 4, 15, 15135, 5, 14, 11013, 5, 15, 30065, // 5,15
- 6, -1, 10351, 6, 0, 30939, 7, -1, 8927, 7, 0, 15319, // 6, 0
- 6, 0, 9961, 6, 1, 33642, 7, 0, 8286, 7, 1, 13647, // 6, 1
- 6, 1, 9390, 6, 2, 36631, 7, 1, 7543, 7, 2, 11972, // 6, 2
- 6, 2, 8617, 6, 3, 39949, 7, 2, 6695, 7, 3, 10275, // 6, 3
- 6, 3, 7626, 6, 4, 43626, 7, 3, 5739, 7, 4, 8545, // 6, 4
- 6, 4, 6422, 6, 5, 47630, 7, 4, 4690, 7, 5, 6794, // 6, 5
- 6, 5, 5099, 6, 6, 51701, 7, 5, 3620, 7, 6, 5116, // 6, 6
- 6, 6, 4044, 6, 7, 54831, 7, 6, 2797, 7, 7, 3864, // 6, 7
- 5, 7, 2795, 5, 8, 3853, 6, 7, 4049, 6, 8, 54839, // 6, 8
- 5, 8, 3620, 5, 9, 5099, 6, 8, 5116, 6, 9, 51701, // 6, 9
- 5, 9, 4694, 5, 10, 6768, 6, 9, 6455, 6, 10, 47619, // 6,10
- 5, 10, 5749, 5, 11, 8507, 6, 10, 7678, 6, 11, 43602, // 6,11
- 5, 11, 6714, 5, 12, 10221, 6, 11, 8690, 6, 12, 39911, // 6,12
- 5, 12, 7573, 5, 13, 11897, 6, 12, 9484, 6, 13, 36582, // 6,13
- 5, 13, 8329, 5, 14, 13548, 6, 13, 10074, 6, 14, 33585, // 6,14
- 5, 14, 8986, 5, 15, 15193, 6, 14, 10482, 6, 15, 30875, // 6,15
- 7, -1, 9959, 7, 0, 31532, 8, -1, 8669, 8, 0, 15376, // 7, 0
- 7, 0, 9534, 7, 1, 34340, 8, 0, 8024, 8, 1, 13638, // 7, 1
- 7, 1, 8918, 7, 2, 37470, 8, 1, 7266, 8, 2, 11882, // 7, 2
- 7, 2, 8082, 7, 3, 40994, 8, 2, 6381, 8, 3, 10079, // 7, 3
- 7, 3, 6987, 7, 4, 44999, 8, 3, 5354, 8, 4, 8196, // 7, 4
- 7, 4, 5590, 7, 5, 49588, 8, 4, 4164, 8, 5, 6194, // 7, 5
- 7, 5, 3853, 7, 6, 54839, 8, 5, 2795, 8, 6, 4049, // 7, 6
- 7, 6, 1903, 7, 7, 60382, 8, 6, 1347, 8, 7, 1904, // 7, 7
- 6, 7, 1347, 6, 8, 1903, 7, 7, 1905, 7, 8, 60381, // 7, 8
- 6, 8, 2797, 6, 9, 4044, 7, 8, 3864, 7, 9, 54831, // 7, 9
- 6, 9, 4172, 6, 10, 6183, 7, 9, 5615, 7, 10, 49566, // 7,10
- 6, 10, 5368, 6, 11, 8177, 7, 10, 7029, 7, 11, 44962, // 7,11
- 6, 11, 6403, 6, 12, 10051, 7, 11, 8141, 7, 12, 40941, // 7,12
- 6, 12, 7298, 6, 13, 11842, 7, 12, 8994, 7, 13, 37402, // 7,13
- 6, 13, 8068, 6, 14, 13582, 7, 13, 9626, 7, 14, 34260, // 7,14
- 6, 14, 8727, 6, 15, 15301, 7, 14, 10065, 7, 15, 31443, // 7,15
- 8, 0, 31444, 8, 1, 10065, 9, 0, 15301, 9, 1, 8726, // 8, 0
- 8, 1, 34261, 8, 2, 9626, 9, 1, 13582, 9, 2, 8067, // 8, 1
- 8, 2, 37402, 8, 3, 8994, 9, 2, 11842, 9, 3, 7298, // 8, 2
- 8, 3, 40940, 8, 4, 8141, 9, 3, 10051, 9, 4, 6404, // 8, 3
- 8, 4, 44962, 8, 5, 7029, 9, 4, 8177, 9, 5, 5368, // 8, 4
- 8, 5, 49566, 8, 6, 5615, 9, 5, 6183, 9, 6, 4172, // 8, 5
- 8, 6, 54831, 8, 7, 3864, 9, 6, 4044, 9, 7, 2797, // 8, 6
- 8, 7, 60382, 8, 8, 1905, 9, 7, 1903, 9, 8, 1346, // 8, 7
- 7, 8, 1905, 7, 9, 1347, 8, 8, 60382, 8, 9, 1902, // 8, 8
- 7, 9, 4049, 7, 10, 2795, 8, 9, 54839, 8, 10, 3853, // 8, 9
- 7, 10, 6193, 7, 11, 4164, 8, 10, 49588, 8, 11, 5591, // 8,10
- 7, 11, 8195, 7, 12, 5354, 8, 11, 44999, 8, 12, 6988, // 8,11
- 7, 12, 10079, 7, 13, 6381, 8, 12, 40994, 8, 13, 8082, // 8,12
- 7, 13, 11883, 7, 14, 7266, 8, 13, 37470, 8, 14, 8917, // 8,13
- 7, 14, 13638, 7, 15, 8024, 8, 14, 34340, 8, 15, 9534, // 8,14
- 7, 15, 15376, 7, 16, 8669, 8, 15, 31532, 8, 16, 9959, // 8,15
- 9, 0, 30876, 9, 1, 10482, 10, 0, 15193, 10, 1, 8985, // 9, 0
- 9, 1, 33585, 9, 2, 10074, 10, 1, 13548, 10, 2, 8329, // 9, 1
- 9, 2, 36582, 9, 3, 9484, 10, 2, 11897, 10, 3, 7573, // 9, 2
- 9, 3, 39912, 9, 4, 8690, 10, 3, 10221, 10, 4, 6713, // 9, 3
- 9, 4, 43602, 9, 5, 7678, 10, 4, 8507, 10, 5, 5749, // 9, 4
- 9, 5, 47619, 9, 6, 6455, 10, 5, 6768, 10, 6, 4694, // 9, 5
- 9, 6, 51701, 9, 7, 5116, 10, 6, 5099, 10, 7, 3620, // 9, 6
- 9, 7, 54839, 9, 8, 4049, 10, 7, 3853, 10, 8, 2795, // 9, 7
- 8, 8, 3864, 8, 9, 2797, 9, 8, 54831, 9, 9, 4044, // 9, 8
- 8, 9, 5116, 8, 10, 3620, 9, 9, 51701, 9, 10, 5099, // 9, 9
- 8, 10, 6794, 8, 11, 4690, 9, 10, 47630, 9, 11, 6422, // 9,10
- 8, 11, 8545, 8, 12, 5739, 9, 11, 43626, 9, 12, 7626, // 9,11
- 8, 12, 10275, 8, 13, 6695, 9, 12, 39949, 9, 13, 8617, // 9,12
- 8, 13, 11972, 8, 14, 7543, 9, 13, 36631, 9, 14, 9390, // 9,13
- 8, 14, 13647, 8, 15, 8286, 9, 14, 33642, 9, 15, 9961, // 9,14
- 8, 15, 15319, 8, 16, 8927, 9, 15, 30939, 9, 16, 10351, // 9,15
- 10, 0, 30064, 10, 1, 11013, 11, 0, 15135, 11, 1, 9324, // 10, 0
- 10, 1, 32586, 10, 2, 10665, 11, 1, 13600, 11, 2, 8685, // 10, 1
- 10, 2, 35332, 10, 3, 10156, 11, 2, 12079, 11, 3, 7969, // 10, 2
- 10, 3, 38307, 10, 4, 9479, 11, 3, 10569, 11, 4, 7181, // 10, 3
- 10, 4, 41475, 10, 5, 8646, 11, 4, 9081, 11, 5, 6334, // 10, 4
- 10, 5, 44700, 10, 6, 7705, 11, 5, 7659, 11, 6, 5472, // 10, 5
- 10, 6, 47630, 10, 7, 6794, 11, 6, 6422, 11, 7, 4690, // 10, 6
- 10, 7, 49588, 10, 8, 6193, 11, 7, 5590, 11, 8, 4165, // 10, 7
- 9, 8, 5615, 9, 9, 4172, 10, 8, 49566, 10, 9, 6183, // 10, 8
- 9, 9, 6455, 9, 10, 4694, 10, 9, 47619, 10, 10, 6768, // 10, 9
- 9, 10, 7705, 9, 11, 5472, 10, 10, 44700, 10, 11, 7659, // 10,10
- 9, 11, 9143, 9, 12, 6328, 10, 11, 41487, 10, 12, 8578, // 10,11
- 9, 12, 10653, 9, 13, 7165, 10, 12, 38330, 10, 13, 9388, // 10,12
- 9, 13, 12188, 9, 14, 7943, 10, 13, 35364, 10, 14, 10041, // 10,13
- 9, 14, 13740, 9, 15, 8645, 10, 14, 32624, 10, 15, 10527, // 10,14
- 9, 15, 15311, 9, 16, 9265, 10, 15, 30105, 10, 16, 10855, // 10,15
- 11, 0, 29055, 11, 1, 11652, 12, 0, 15100, 12, 1, 9729, // 11, 0
- 11, 1, 31339, 11, 2, 11385, 12, 1, 13694, 12, 2, 9118, // 11, 1
- 11, 2, 33777, 11, 3, 10983, 12, 2, 12323, 12, 3, 8453, // 11, 2
- 11, 3, 36343, 11, 4, 10452, 12, 3, 10995, 12, 4, 7746, // 11, 3
- 11, 4, 38966, 11, 5, 9818, 12, 4, 9730, 12, 5, 7022, // 11, 4
- 11, 5, 41487, 11, 6, 9143, 12, 5, 8578, 12, 6, 6328, // 11, 5
- 11, 6, 43626, 11, 7, 8545, 12, 6, 7626, 12, 7, 5739, // 11, 6
- 11, 7, 44999, 11, 8, 8195, 12, 7, 6987, 12, 8, 5355, // 11, 7
- 10, 8, 7029, 10, 9, 5368, 11, 8, 44962, 11, 9, 8177, // 11, 8
- 10, 9, 7678, 10, 10, 5749, 11, 9, 43602, 11, 10, 8507, // 11, 9
- 10, 10, 8646, 10, 11, 6334, 11, 10, 41475, 11, 11, 9081, // 11,10
- 10, 11, 9818, 10, 12, 7022, 11, 11, 38966, 11, 12, 9730, // 11,11
- 10, 12, 11108, 10, 13, 7737, 11, 12, 36354, 11, 13, 10337, // 11,12
- 10, 13, 12467, 10, 14, 8432, 11, 13, 33795, 11, 14, 10842, // 11,13
- 10, 14, 13875, 10, 15, 9082, 11, 14, 31361, 11, 15, 11218, // 11,14
- 10, 15, 15325, 10, 16, 9673, 11, 15, 29078, 11, 16, 11460, // 11,15
- 12, 0, 27903, 12, 1, 12388, 13, 0, 15060, 13, 1, 10185, // 12, 0
- 12, 1, 29928, 12, 2, 12216, 13, 1, 13789, 13, 2, 9603, // 12, 1
- 12, 2, 32045, 12, 3, 11934, 13, 2, 12569, 13, 3, 8988, // 12, 2
- 12, 3, 34213, 12, 4, 11554, 13, 3, 11411, 13, 4, 8358, // 12, 3
- 12, 4, 36354, 12, 5, 11108, 13, 4, 10337, 13, 5, 7737, // 12, 4
- 12, 5, 38330, 12, 6, 10653, 13, 5, 9388, 13, 6, 7165, // 12, 5
- 12, 6, 39949, 12, 7, 10275, 13, 6, 8617, 13, 7, 6695, // 12, 6
- 12, 7, 40994, 12, 8, 10079, 13, 7, 8082, 13, 8, 6381, // 12, 7
- 11, 8, 8141, 11, 9, 6403, 12, 8, 40940, 12, 9, 10052, // 12, 8
- 11, 9, 8690, 11, 10, 6714, 12, 9, 39912, 12, 10, 10220, // 12, 9
- 11, 10, 9479, 11, 11, 7180, 12, 10, 38307, 12, 11, 10570, // 12,10
- 11, 11, 10452, 11, 12, 7746, 12, 11, 36343, 12, 12, 10995, // 12,11
- 11, 12, 11554, 11, 13, 8358, 12, 12, 34213, 12, 13, 11411, // 12,12
- 11, 13, 12747, 11, 14, 8976, 12, 13, 32052, 12, 14, 11761, // 12,13
- 11, 14, 14009, 11, 15, 9575, 12, 14, 29938, 12, 15, 12014, // 12,14
- 11, 15, 15330, 11, 16, 10135, 12, 15, 27912, 12, 16, 12159, // 12,15
- 13, 0, 26660, 13, 1, 13211, 14, 0, 14990, 14, 1, 10675, // 13, 0
- 13, 1, 28427, 13, 2, 13141, 14, 1, 13850, 14, 2, 10118, // 13, 1
- 13, 2, 30239, 13, 3, 12982, 14, 2, 12769, 14, 3, 9546, // 13, 2
- 13, 3, 32052, 13, 4, 12747, 14, 3, 11760, 14, 4, 8977, // 13, 3
- 13, 4, 33795, 13, 5, 12467, 14, 4, 10842, 14, 5, 8432, // 13, 4
- 13, 5, 35364, 13, 6, 12188, 14, 5, 10041, 14, 6, 7943, // 13, 5
- 13, 6, 36631, 13, 7, 11972, 14, 6, 9390, 14, 7, 7543, // 13, 6
- 13, 7, 37470, 13, 8, 11883, 14, 7, 8918, 14, 8, 7265, // 13, 7
- 12, 8, 8994, 12, 9, 7298, 13, 8, 37402, 13, 9, 11842, // 13, 8
- 12, 9, 9484, 12, 10, 7573, 13, 9, 36582, 13, 10, 11897, // 13, 9
- 12, 10, 10156, 12, 11, 7969, 13, 10, 35332, 13, 11, 12079, // 13,10
- 12, 11, 10983, 12, 12, 8452, 13, 11, 33777, 13, 12, 12324, // 13,11
- 12, 12, 11934, 12, 13, 8988, 13, 12, 32045, 13, 13, 12569, // 13,12
- 12, 13, 12982, 12, 14, 9546, 13, 13, 30239, 13, 14, 12769, // 13,13
- 12, 14, 14107, 12, 15, 10102, 13, 14, 28430, 13, 15, 12897, // 13,14
- 12, 15, 15301, 12, 16, 10637, 13, 15, 26660, 13, 16, 12938, // 13,15
- 14, 0, 25368, 14, 1, 14109, 15, 0, 14872, 15, 1, 11187, // 14, 0
- 14, 1, 26893, 14, 2, 14145, 15, 1, 13853, 15, 2, 10645, // 14, 1
- 14, 2, 28430, 14, 3, 14107, 15, 2, 12897, 15, 3, 10102, // 14, 2
- 14, 3, 29938, 14, 4, 14009, 15, 3, 12014, 15, 4, 9575, // 14, 3
- 14, 4, 31361, 14, 5, 13875, 15, 4, 11218, 15, 5, 9082, // 14, 4
- 14, 5, 32624, 14, 6, 13740, 15, 5, 10528, 15, 6, 8644, // 14, 5
- 14, 6, 33642, 14, 7, 13647, 15, 6, 9961, 15, 7, 8286, // 14, 6
- 14, 7, 34340, 14, 8, 13638, 15, 7, 9534, 15, 8, 8024, // 14, 7
- 13, 8, 9626, 13, 9, 8068, 14, 8, 34261, 14, 9, 13581, // 14, 8
- 13, 9, 10074, 13, 10, 8329, 14, 9, 33585, 14, 10, 13548, // 14, 9
- 13, 10, 10665, 13, 11, 8685, 14, 10, 32586, 14, 11, 13600, // 14,10
- 13, 11, 11385, 13, 12, 9118, 14, 11, 31339, 14, 12, 13694, // 14,11
- 13, 12, 12216, 13, 13, 9603, 14, 12, 29928, 14, 13, 13789, // 14,12
- 13, 13, 13141, 13, 14, 10119, 14, 13, 28427, 14, 14, 13849, // 14,13
- 13, 14, 14145, 13, 15, 10644, 14, 14, 26893, 14, 15, 13854, // 14,14
- 13, 15, 15220, 13, 16, 11164, 14, 15, 25366, 14, 16, 13786, // 14,15
- 15, 0, 24063, 15, 1, 15076, 16, 0, 14696, 16, 1, 11701, // 15, 0
- 15, 1, 25366, 15, 2, 15220, 16, 1, 13787, 16, 2, 11163, // 15, 1
- 15, 2, 26660, 15, 3, 15301, 16, 2, 12938, 16, 3, 10637, // 15, 2
- 15, 3, 27912, 15, 4, 15330, 16, 3, 12159, 16, 4, 10135, // 15, 3
- 15, 4, 29078, 15, 5, 15325, 16, 4, 11461, 16, 5, 9672, // 15, 4
- 15, 5, 30105, 15, 6, 15311, 16, 5, 10855, 16, 6, 9265, // 15, 5
- 15, 6, 30939, 15, 7, 15319, 16, 6, 10351, 16, 7, 8927, // 15, 6
- 15, 7, 31532, 15, 8, 15376, 16, 7, 9959, 16, 8, 8669, // 15, 7
- 14, 8, 10065, 14, 9, 8727, 15, 8, 31444, 15, 9, 15300, // 15, 8
- 14, 9, 10482, 14, 10, 8986, 15, 9, 30876, 15, 10, 15192, // 15, 9
- 14, 10, 11013, 14, 11, 9323, 15, 10, 30064, 15, 11, 15136, // 15,10
- 14, 11, 11652, 14, 12, 9728, 15, 11, 29055, 15, 12, 15101, // 15,11
- 14, 12, 12388, 14, 13, 10185, 15, 12, 27903, 15, 13, 15060, // 15,12
- 14, 13, 13211, 14, 14, 10676, 15, 13, 26660, 15, 14, 14989, // 15,13
- 14, 14, 14109, 14, 15, 11187, 15, 14, 25368, 15, 15, 14872, // 15,14
- 14, 15, 15076, 14, 16, 11702, 15, 15, 24063, 15, 16, 14695, // 15,15
+// angle of -2.5 degrees
+-1, 0, 14696, -1, 1, 11702, 0, 0, 24063, 0, 1, 15075, // 0, 0
+-1, 1, 13787, -1, 2, 11164, 0, 1, 25366, 0, 2, 15219, // 0, 1
+-1, 2, 12938, -1, 3, 10637, 0, 2, 26660, 0, 3, 15301, // 0, 2
+-1, 3, 12159, -1, 4, 10135, 0, 3, 27912, 0, 4, 15330, // 0, 3
+-1, 4, 11461, -1, 5, 9673, 0, 4, 29078, 0, 5, 15324, // 0, 4
+-1, 5, 10855, -1, 6, 9265, 0, 5, 30105, 0, 6, 15311, // 0, 5
+-1, 6, 10351, -1, 7, 8927, 0, 6, 30939, 0, 7, 15319, // 0, 6
+-1, 7, 9959, -1, 8, 8669, 0, 7, 31532, 0, 8, 15376, // 0, 7
+0, 8, 31444, 0, 9, 15301, 1, 8, 10065, 1, 9, 8726, // 0, 8
+0, 9, 30876, 0, 10, 15193, 1, 9, 10482, 1, 10, 8985, // 0, 9
+0, 10, 30064, 0, 11, 15135, 1, 10, 11013, 1, 11, 9324, // 0,10
+0, 11, 29055, 0, 12, 15100, 1, 11, 11652, 1, 12, 9729, // 0,11
+0, 12, 27903, 0, 13, 15060, 1, 12, 12388, 1, 13, 10185, // 0,12
+0, 13, 26660, 0, 14, 14990, 1, 13, 13211, 1, 14, 10675, // 0,13
+0, 14, 25368, 0, 15, 14872, 1, 14, 14109, 1, 15, 11187, // 0,14
+0, 15, 24063, 0, 16, 14696, 1, 15, 15076, 1, 16, 11701, // 0,15
+0, 0, 14872, 0, 1, 11187, 1, 0, 25368, 1, 1, 14109, // 1, 0
+0, 1, 13853, 0, 2, 10644, 1, 1, 26893, 1, 2, 14146, // 1, 1
+0, 2, 12897, 0, 3, 10102, 1, 2, 28430, 1, 3, 14107, // 1, 2
+0, 3, 12014, 0, 4, 9575, 1, 3, 29938, 1, 4, 14009, // 1, 3
+0, 4, 11218, 0, 5, 9082, 1, 4, 31361, 1, 5, 13875, // 1, 4
+0, 5, 10528, 0, 6, 8645, 1, 5, 32624, 1, 6, 13739, // 1, 5
+0, 6, 9961, 0, 7, 8286, 1, 6, 33642, 1, 7, 13647, // 1, 6
+0, 7, 9534, 0, 8, 8024, 1, 7, 34340, 1, 8, 13638, // 1, 7
+1, 8, 34261, 1, 9, 13582, 2, 8, 9626, 2, 9, 8067, // 1, 8
+1, 9, 33585, 1, 10, 13548, 2, 9, 10074, 2, 10, 8329, // 1, 9
+1, 10, 32586, 1, 11, 13600, 2, 10, 10665, 2, 11, 8685, // 1,10
+1, 11, 31339, 1, 12, 13694, 2, 11, 11385, 2, 12, 9118, // 1,11
+1, 12, 29928, 1, 13, 13789, 2, 12, 12216, 2, 13, 9603, // 1,12
+1, 13, 28427, 1, 14, 13850, 2, 13, 13141, 2, 14, 10118, // 1,13
+1, 14, 26893, 1, 15, 13853, 2, 14, 14145, 2, 15, 10645, // 1,14
+1, 15, 25366, 1, 16, 13787, 2, 15, 15220, 2, 16, 11163, // 1,15
+1, 0, 14990, 1, 1, 10676, 2, 0, 26660, 2, 1, 13210, // 2, 0
+1, 1, 13850, 1, 2, 10119, 2, 1, 28427, 2, 2, 13140, // 2, 1
+1, 2, 12769, 1, 3, 9546, 2, 2, 30239, 2, 3, 12982, // 2, 2
+1, 3, 11760, 1, 4, 8976, 2, 3, 32052, 2, 4, 12748, // 2, 3
+1, 4, 10842, 1, 5, 8432, 2, 4, 33795, 2, 5, 12467, // 2, 4
+1, 5, 10041, 1, 6, 7943, 2, 5, 35364, 2, 6, 12188, // 2, 5
+1, 6, 9390, 1, 7, 7543, 2, 6, 36631, 2, 7, 11972, // 2, 6
+1, 7, 8918, 1, 8, 7266, 2, 7, 37470, 2, 8, 11882, // 2, 7
+2, 8, 37402, 2, 9, 11842, 3, 8, 8994, 3, 9, 7298, // 2, 8
+2, 9, 36582, 2, 10, 11897, 3, 9, 9484, 3, 10, 7573, // 2, 9
+2, 10, 35332, 2, 11, 12079, 3, 10, 10156, 3, 11, 7969, // 2,10
+2, 11, 33777, 2, 12, 12323, 3, 11, 10983, 3, 12, 8453, // 2,11
+2, 12, 32045, 2, 13, 12569, 3, 12, 11934, 3, 13, 8988, // 2,12
+2, 13, 30239, 2, 14, 12769, 3, 13, 12982, 3, 14, 9546, // 2,13
+2, 14, 28430, 2, 15, 12897, 3, 14, 14107, 3, 15, 10102, // 2,14
+2, 15, 26660, 2, 16, 12938, 3, 15, 15301, 3, 16, 10637, // 2,15
+2, 0, 15060, 2, 1, 10185, 3, 0, 27903, 3, 1, 12388, // 3, 0
+2, 1, 13789, 2, 2, 9603, 3, 1, 29928, 3, 2, 12216, // 3, 1
+2, 2, 12569, 2, 3, 8988, 3, 2, 32045, 3, 3, 11934, // 3, 2
+2, 3, 11411, 2, 4, 8358, 3, 3, 34213, 3, 4, 11554, // 3, 3
+2, 4, 10337, 2, 5, 7737, 3, 4, 36354, 3, 5, 11108, // 3, 4
+2, 5, 9388, 2, 6, 7165, 3, 5, 38330, 3, 6, 10653, // 3, 5
+2, 6, 8617, 2, 7, 6695, 3, 6, 39949, 3, 7, 10275, // 3, 6
+2, 7, 8082, 2, 8, 6381, 3, 7, 40994, 3, 8, 10079, // 3, 7
+3, 8, 40940, 3, 9, 10051, 4, 8, 8141, 4, 9, 6404, // 3, 8
+3, 9, 39912, 3, 10, 10221, 4, 9, 8690, 4, 10, 6713, // 3, 9
+3, 10, 38307, 3, 11, 10569, 4, 10, 9479, 4, 11, 7181, // 3,10
+3, 11, 36343, 3, 12, 10995, 4, 11, 10452, 4, 12, 7746, // 3,11
+3, 12, 34213, 3, 13, 11411, 4, 12, 11554, 4, 13, 8358, // 3,12
+3, 13, 32052, 3, 14, 11760, 4, 13, 12747, 4, 14, 8977, // 3,13
+3, 14, 29938, 3, 15, 12014, 4, 14, 14009, 4, 15, 9575, // 3,14
+3, 15, 27912, 3, 16, 12159, 4, 15, 15330, 4, 16, 10135, // 3,15
+3, 0, 15100, 3, 1, 9728, 4, 0, 29055, 4, 1, 11653, // 4, 0
+3, 1, 13694, 3, 2, 9118, 4, 1, 31339, 4, 2, 11385, // 4, 1
+3, 2, 12323, 3, 3, 8452, 4, 2, 33777, 4, 3, 10984, // 4, 2
+3, 3, 10995, 3, 4, 7746, 4, 3, 36343, 4, 4, 10452, // 4, 3
+3, 4, 9730, 3, 5, 7022, 4, 4, 38966, 4, 5, 9818, // 4, 4
+3, 5, 8578, 3, 6, 6328, 4, 5, 41487, 4, 6, 9143, // 4, 5
+3, 6, 7626, 3, 7, 5739, 4, 6, 43626, 4, 7, 8545, // 4, 6
+3, 7, 6987, 3, 8, 5354, 4, 7, 44999, 4, 8, 8196, // 4, 7
+4, 8, 44962, 4, 9, 8177, 5, 8, 7029, 5, 9, 5368, // 4, 8
+4, 9, 43602, 4, 10, 8507, 5, 9, 7678, 5, 10, 5749, // 4, 9
+4, 10, 41475, 4, 11, 9081, 5, 10, 8646, 5, 11, 6334, // 4,10
+4, 11, 38966, 4, 12, 9730, 5, 11, 9818, 5, 12, 7022, // 4,11
+4, 12, 36354, 4, 13, 10337, 5, 12, 11108, 5, 13, 7737, // 4,12
+4, 13, 33795, 4, 14, 10842, 5, 13, 12467, 5, 14, 8432, // 4,13
+4, 14, 31361, 4, 15, 11218, 5, 14, 13875, 5, 15, 9082, // 4,14
+4, 15, 29078, 4, 16, 11461, 5, 15, 15325, 5, 16, 9672, // 4,15
+4, 0, 15135, 4, 1, 9323, 5, 0, 30064, 5, 1, 11014, // 5, 0
+4, 1, 13600, 4, 2, 8685, 5, 1, 32586, 5, 2, 10665, // 5, 1
+4, 2, 12079, 4, 3, 7969, 5, 2, 35332, 5, 3, 10156, // 5, 2
+4, 3, 10569, 4, 4, 7180, 5, 3, 38307, 5, 4, 9480, // 5, 3
+4, 4, 9081, 4, 5, 6334, 5, 4, 41475, 5, 5, 8646, // 5, 4
+4, 5, 7659, 4, 6, 5472, 5, 5, 44700, 5, 6, 7705, // 5, 5
+4, 6, 6422, 4, 7, 4690, 5, 6, 47630, 5, 7, 6794, // 5, 6
+4, 7, 5590, 4, 8, 4164, 5, 7, 49588, 5, 8, 6194, // 5, 7
+5, 8, 49566, 5, 9, 6183, 6, 8, 5615, 6, 9, 4172, // 5, 8
+5, 9, 47619, 5, 10, 6768, 6, 9, 6455, 6, 10, 4694, // 5, 9
+5, 10, 44700, 5, 11, 7659, 6, 10, 7705, 6, 11, 5472, // 5,10
+5, 11, 41487, 5, 12, 8578, 6, 11, 9143, 6, 12, 6328, // 5,11
+5, 12, 38330, 5, 13, 9388, 6, 12, 10653, 6, 13, 7165, // 5,12
+5, 13, 35364, 5, 14, 10041, 6, 13, 12188, 6, 14, 7943, // 5,13
+5, 14, 32624, 5, 15, 10528, 6, 14, 13740, 6, 15, 8644, // 5,14
+5, 15, 30105, 5, 16, 10855, 6, 15, 15311, 6, 16, 9265, // 5,15
+5, 0, 15193, 5, 1, 8986, 6, 0, 30876, 6, 1, 10481, // 6, 0
+5, 1, 13548, 5, 2, 8329, 6, 1, 33585, 6, 2, 10074, // 6, 1
+5, 2, 11897, 5, 3, 7573, 6, 2, 36582, 6, 3, 9484, // 6, 2
+5, 3, 10221, 5, 4, 6714, 6, 3, 39912, 6, 4, 8689, // 6, 3
+5, 4, 8507, 5, 5, 5749, 6, 4, 43602, 6, 5, 7678, // 6, 4
+5, 5, 6768, 5, 6, 4694, 6, 5, 47619, 6, 6, 6455, // 6, 5
+5, 6, 5099, 5, 7, 3620, 6, 6, 51701, 6, 7, 5116, // 6, 6
+5, 7, 3853, 5, 8, 2795, 6, 7, 54839, 6, 8, 4049, // 6, 7
+6, 8, 54831, 6, 9, 4044, 7, 8, 3864, 7, 9, 2797, // 6, 8
+6, 9, 51701, 6, 10, 5099, 7, 9, 5116, 7, 10, 3620, // 6, 9
+6, 10, 47630, 6, 11, 6422, 7, 10, 6794, 7, 11, 4690, // 6,10
+6, 11, 43626, 6, 12, 7626, 7, 11, 8545, 7, 12, 5739, // 6,11
+6, 12, 39949, 6, 13, 8617, 7, 12, 10275, 7, 13, 6695, // 6,12
+6, 13, 36631, 6, 14, 9390, 7, 13, 11972, 7, 14, 7543, // 6,13
+6, 14, 33642, 6, 15, 9961, 7, 14, 13647, 7, 15, 8286, // 6,14
+6, 15, 30939, 6, 16, 10351, 7, 15, 15319, 7, 16, 8927, // 6,15
+6, 0, 15301, 6, 1, 8727, 7, 0, 31444, 7, 1, 10064, // 7, 0
+6, 1, 13582, 6, 2, 8068, 7, 1, 34261, 7, 2, 9625, // 7, 1
+6, 2, 11842, 6, 3, 7298, 7, 2, 37402, 7, 3, 8994, // 7, 2
+6, 3, 10051, 6, 4, 6403, 7, 3, 40940, 7, 4, 8142, // 7, 3
+6, 4, 8177, 6, 5, 5368, 7, 4, 44962, 7, 5, 7029, // 7, 4
+6, 5, 6183, 6, 6, 4172, 7, 5, 49566, 7, 6, 5615, // 7, 5
+6, 6, 4044, 6, 7, 2797, 7, 6, 54831, 7, 7, 3864, // 7, 6
+6, 7, 1903, 6, 8, 1347, 7, 7, 60382, 7, 8, 1904, // 7, 7
+7, 8, 60382, 7, 9, 1903, 8, 8, 1905, 8, 9, 1346, // 7, 8
+7, 9, 54839, 7, 10, 3853, 8, 9, 4049, 8, 10, 2795, // 7, 9
+7, 10, 49588, 7, 11, 5590, 8, 10, 6193, 8, 11, 4165, // 7,10
+7, 11, 44999, 7, 12, 6987, 8, 11, 8195, 8, 12, 5355, // 7,11
+7, 12, 40994, 7, 13, 8082, 8, 12, 10079, 8, 13, 6381, // 7,12
+7, 13, 37470, 7, 14, 8918, 8, 13, 11883, 8, 14, 7265, // 7,13
+7, 14, 34340, 7, 15, 9534, 8, 14, 13638, 8, 15, 8024, // 7,14
+7, 15, 31532, 7, 16, 9959, 8, 15, 15376, 8, 16, 8669, // 7,15
+7, -1, 8669, 7, 0, 15376, 8, -1, 9959, 8, 0, 31532, // 8, 0
+7, 0, 8024, 7, 1, 13638, 8, 0, 9534, 8, 1, 34340, // 8, 1
+7, 1, 7266, 7, 2, 11883, 8, 1, 8918, 8, 2, 37469, // 8, 2
+7, 2, 6381, 7, 3, 10079, 8, 2, 8082, 8, 3, 40994, // 8, 3
+7, 3, 5354, 7, 4, 8195, 8, 3, 6987, 8, 4, 45000, // 8, 4
+7, 4, 4164, 7, 5, 6193, 8, 4, 5590, 8, 5, 49589, // 8, 5
+7, 5, 2795, 7, 6, 4049, 8, 5, 3853, 8, 6, 54839, // 8, 6
+7, 6, 1347, 7, 7, 1905, 8, 6, 1903, 8, 7, 60381, // 8, 7
+8, 7, 1905, 8, 8, 60382, 9, 7, 1347, 9, 8, 1902, // 8, 8
+8, 8, 3864, 8, 9, 54831, 9, 8, 2797, 9, 9, 4044, // 8, 9
+8, 9, 5615, 8, 10, 49566, 9, 9, 4172, 9, 10, 6183, // 8,10
+8, 10, 7029, 8, 11, 44962, 9, 10, 5368, 9, 11, 8177, // 8,11
+8, 11, 8141, 8, 12, 40940, 9, 11, 6403, 9, 12, 10052, // 8,12
+8, 12, 8994, 8, 13, 37402, 9, 12, 7298, 9, 13, 11842, // 8,13
+8, 13, 9626, 8, 14, 34261, 9, 13, 8068, 9, 14, 13581, // 8,14
+8, 14, 10065, 8, 15, 31444, 9, 14, 8727, 9, 15, 15300, // 8,15
+8, -1, 8927, 8, 0, 15319, 9, -1, 10351, 9, 0, 30939, // 9, 0
+8, 0, 8286, 8, 1, 13647, 9, 0, 9961, 9, 1, 33642, // 9, 1
+8, 1, 7543, 8, 2, 11972, 9, 1, 9390, 9, 2, 36631, // 9, 2
+8, 2, 6695, 8, 3, 10275, 9, 2, 8617, 9, 3, 39949, // 9, 3
+8, 3, 5739, 8, 4, 8545, 9, 3, 7626, 9, 4, 43626, // 9, 4
+8, 4, 4690, 8, 5, 6794, 9, 4, 6422, 9, 5, 47630, // 9, 5
+8, 5, 3620, 8, 6, 5116, 9, 5, 5099, 9, 6, 51701, // 9, 6
+8, 6, 2797, 8, 7, 3864, 9, 6, 4044, 9, 7, 54831, // 9, 7
+9, 7, 4049, 9, 8, 54839, 10, 7, 2795, 10, 8, 3853, // 9, 8
+9, 8, 5116, 9, 9, 51701, 10, 8, 3620, 10, 9, 5099, // 9, 9
+9, 9, 6455, 9, 10, 47619, 10, 9, 4694, 10, 10, 6768, // 9,10
+9, 10, 7678, 9, 11, 43602, 10, 10, 5749, 10, 11, 8507, // 9,11
+9, 11, 8690, 9, 12, 39912, 10, 11, 6714, 10, 12, 10220, // 9,12
+9, 12, 9484, 9, 13, 36582, 10, 12, 7573, 10, 13, 11897, // 9,13
+9, 13, 10074, 9, 14, 33585, 10, 13, 8329, 10, 14, 13548, // 9,14
+9, 14, 10482, 9, 15, 30876, 10, 14, 8986, 10, 15, 15192, // 9,15
+9, -1, 9265, 9, 0, 15311, 10, -1, 10855, 10, 0, 30105, // 10, 0
+9, 0, 8645, 9, 1, 13740, 10, 0, 10528, 10, 1, 32623, // 10, 1
+9, 1, 7943, 9, 2, 12188, 10, 1, 10041, 10, 2, 35364, // 10, 2
+9, 2, 7165, 9, 3, 10653, 10, 2, 9388, 10, 3, 38330, // 10, 3
+9, 3, 6328, 9, 4, 9143, 10, 3, 8578, 10, 4, 41487, // 10, 4
+9, 4, 5472, 9, 5, 7705, 10, 4, 7659, 10, 5, 44700, // 10, 5
+9, 5, 4694, 9, 6, 6455, 10, 5, 6768, 10, 6, 47619, // 10, 6
+9, 6, 4172, 9, 7, 5615, 10, 6, 6183, 10, 7, 49566, // 10, 7
+10, 7, 6193, 10, 8, 49588, 11, 7, 4164, 11, 8, 5591, // 10, 8
+10, 8, 6794, 10, 9, 47630, 11, 8, 4690, 11, 9, 6422, // 10, 9
+10, 9, 7705, 10, 10, 44700, 11, 9, 5472, 11, 10, 7659, // 10,10
+10, 10, 8646, 10, 11, 41475, 11, 10, 6334, 11, 11, 9081, // 10,11
+10, 11, 9479, 10, 12, 38307, 11, 11, 7180, 11, 12, 10570, // 10,12
+10, 12, 10156, 10, 13, 35332, 11, 12, 7969, 11, 13, 12079, // 10,13
+10, 13, 10665, 10, 14, 32586, 11, 13, 8685, 11, 14, 13600, // 10,14
+10, 14, 11013, 10, 15, 30064, 11, 14, 9323, 11, 15, 15136, // 10,15
+10, -1, 9673, 10, 0, 15325, 11, -1, 11461, 11, 0, 29077, // 11, 0
+10, 0, 9082, 10, 1, 13875, 11, 0, 11218, 11, 1, 31361, // 11, 1
+10, 1, 8432, 10, 2, 12467, 11, 1, 10842, 11, 2, 33795, // 11, 2
+10, 2, 7737, 10, 3, 11108, 11, 2, 10337, 11, 3, 36354, // 11, 3
+10, 3, 7022, 10, 4, 9818, 11, 3, 9730, 11, 4, 38966, // 11, 4
+10, 4, 6334, 10, 5, 8646, 11, 4, 9081, 11, 5, 41475, // 11, 5
+10, 5, 5749, 10, 6, 7678, 11, 5, 8507, 11, 6, 43602, // 11, 6
+10, 6, 5368, 10, 7, 7029, 11, 6, 8177, 11, 7, 44962, // 11, 7
+11, 7, 8195, 11, 8, 44999, 12, 7, 5354, 12, 8, 6988, // 11, 8
+11, 8, 8545, 11, 9, 43626, 12, 8, 5739, 12, 9, 7626, // 11, 9
+11, 9, 9143, 11, 10, 41487, 12, 9, 6328, 12, 10, 8578, // 11,10
+11, 10, 9818, 11, 11, 38966, 12, 10, 7022, 12, 11, 9730, // 11,11
+11, 11, 10452, 11, 12, 36343, 12, 11, 7746, 12, 12, 10995, // 11,12
+11, 12, 10983, 11, 13, 33777, 12, 12, 8452, 12, 13, 12324, // 11,13
+11, 13, 11385, 11, 14, 31339, 12, 13, 9118, 12, 14, 13694, // 11,14
+11, 14, 11652, 11, 15, 29055, 12, 14, 9728, 12, 15, 15101, // 11,15
+11, -1, 10135, 11, 0, 15330, 12, -1, 12159, 12, 0, 27912, // 12, 0
+11, 0, 9575, 11, 1, 14009, 12, 0, 12014, 12, 1, 29938, // 12, 1
+11, 1, 8976, 11, 2, 12747, 12, 1, 11760, 12, 2, 32053, // 12, 2
+11, 2, 8358, 11, 3, 11554, 12, 2, 11411, 12, 3, 34213, // 12, 3
+11, 3, 7746, 11, 4, 10452, 12, 3, 10995, 12, 4, 36343, // 12, 4
+11, 4, 7180, 11, 5, 9479, 12, 4, 10569, 12, 5, 38308, // 12, 5
+11, 5, 6714, 11, 6, 8690, 12, 5, 10221, 12, 6, 39911, // 12, 6
+11, 6, 6403, 11, 7, 8141, 12, 6, 10051, 12, 7, 40941, // 12, 7
+12, 7, 10079, 12, 8, 40994, 13, 7, 6381, 13, 8, 8082, // 12, 8
+12, 8, 10275, 12, 9, 39949, 13, 8, 6695, 13, 9, 8617, // 12, 9
+12, 9, 10653, 12, 10, 38330, 13, 9, 7165, 13, 10, 9388, // 12,10
+12, 10, 11108, 12, 11, 36354, 13, 10, 7737, 13, 11, 10337, // 12,11
+12, 11, 11554, 12, 12, 34213, 13, 11, 8358, 13, 12, 11411, // 12,12
+12, 12, 11934, 12, 13, 32045, 13, 12, 8988, 13, 13, 12569, // 12,13
+12, 13, 12216, 12, 14, 29928, 13, 13, 9603, 13, 14, 13789, // 12,14
+12, 14, 12388, 12, 15, 27903, 13, 14, 10185, 13, 15, 15060, // 12,15
+12, -1, 10637, 12, 0, 15301, 13, -1, 12938, 13, 0, 26660, // 13, 0
+12, 0, 10102, 12, 1, 14107, 13, 0, 12897, 13, 1, 28430, // 13, 1
+12, 1, 9546, 12, 2, 12982, 13, 1, 12769, 13, 2, 30239, // 13, 2
+12, 2, 8988, 12, 3, 11934, 13, 2, 12569, 13, 3, 32045, // 13, 3
+12, 3, 8452, 12, 4, 10983, 13, 3, 12323, 13, 4, 33778, // 13, 4
+12, 4, 7969, 12, 5, 10156, 13, 4, 12079, 13, 5, 35332, // 13, 5
+12, 5, 7573, 12, 6, 9484, 13, 5, 11897, 13, 6, 36582, // 13, 6
+12, 6, 7298, 12, 7, 8994, 13, 6, 11842, 13, 7, 37402, // 13, 7
+13, 7, 11883, 13, 8, 37470, 14, 7, 7266, 14, 8, 8917, // 13, 8
+13, 8, 11972, 13, 9, 36631, 14, 8, 7543, 14, 9, 9390, // 13, 9
+13, 9, 12188, 13, 10, 35364, 14, 9, 7943, 14, 10, 10041, // 13,10
+13, 10, 12467, 13, 11, 33795, 14, 10, 8432, 14, 11, 10842, // 13,11
+13, 11, 12747, 13, 12, 32052, 14, 11, 8976, 14, 12, 11761, // 13,12
+13, 12, 12982, 13, 13, 30239, 14, 12, 9546, 14, 13, 12769, // 13,13
+13, 13, 13141, 13, 14, 28427, 14, 13, 10119, 14, 14, 13849, // 13,14
+13, 14, 13211, 13, 15, 26660, 14, 14, 10676, 14, 15, 14989, // 13,15
+13, -1, 11164, 13, 0, 15220, 14, -1, 13787, 14, 0, 25365, // 14, 0
+13, 0, 10644, 13, 1, 14145, 14, 0, 13853, 14, 1, 26894, // 14, 1
+13, 1, 10119, 13, 2, 13141, 14, 1, 13850, 14, 2, 28426, // 14, 2
+13, 2, 9603, 13, 3, 12216, 14, 2, 13789, 14, 3, 29928, // 14, 3
+13, 3, 9118, 13, 4, 11385, 14, 3, 13694, 14, 4, 31339, // 14, 4
+13, 4, 8685, 13, 5, 10665, 14, 4, 13600, 14, 5, 32586, // 14, 5
+13, 5, 8329, 13, 6, 10074, 14, 5, 13548, 14, 6, 33585, // 14, 6
+13, 6, 8068, 13, 7, 9626, 14, 6, 13582, 14, 7, 34260, // 14, 7
+14, 7, 13638, 14, 8, 34340, 15, 7, 8024, 15, 8, 9534, // 14, 8
+14, 8, 13647, 14, 9, 33642, 15, 8, 8286, 15, 9, 9961, // 14, 9
+14, 9, 13740, 14, 10, 32624, 15, 9, 8645, 15, 10, 10527, // 14,10
+14, 10, 13875, 14, 11, 31361, 15, 10, 9082, 15, 11, 11218, // 14,11
+14, 11, 14009, 14, 12, 29938, 15, 11, 9575, 15, 12, 12014, // 14,12
+14, 12, 14107, 14, 13, 28430, 15, 12, 10102, 15, 13, 12897, // 14,13
+14, 13, 14145, 14, 14, 26893, 15, 13, 10644, 15, 14, 13854, // 14,14
+14, 14, 14109, 14, 15, 25368, 15, 14, 11187, 15, 15, 14872, // 14,15
+14, -1, 11702, 14, 0, 15076, 15, -1, 14696, 15, 0, 24062, // 15, 0
+14, 0, 11187, 14, 1, 14109, 15, 0, 14872, 15, 1, 25368, // 15, 1
+14, 1, 10676, 14, 2, 13211, 15, 1, 14990, 15, 2, 26659, // 15, 2
+14, 2, 10185, 14, 3, 12388, 15, 2, 15060, 15, 3, 27903, // 15, 3
+14, 3, 9728, 14, 4, 11652, 15, 3, 15100, 15, 4, 29056, // 15, 4
+14, 4, 9323, 14, 5, 11013, 15, 4, 15135, 15, 5, 30065, // 15, 5
+14, 5, 8986, 14, 6, 10482, 15, 5, 15193, 15, 6, 30875, // 15, 6
+14, 6, 8727, 14, 7, 10065, 15, 6, 15301, 15, 7, 31443, // 15, 7
+15, 7, 15376, 15, 8, 31532, 16, 7, 8669, 16, 8, 9959, // 15, 8
+15, 8, 15319, 15, 9, 30939, 16, 8, 8927, 16, 9, 10351, // 15, 9
+15, 9, 15311, 15, 10, 30105, 16, 9, 9265, 16, 10, 10855, // 15,10
+15, 10, 15325, 15, 11, 29078, 16, 10, 9673, 16, 11, 11460, // 15,11
+15, 11, 15330, 15, 12, 27912, 16, 11, 10135, 16, 12, 12159, // 15,12
+15, 12, 15301, 15, 13, 26660, 16, 12, 10637, 16, 13, 12938, // 15,13
+15, 13, 15220, 15, 14, 25366, 16, 13, 11164, 16, 14, 13786, // 15,14
+15, 14, 15076, 15, 15, 24063, 16, 14, 11702, 16, 15, 14695, // 15,15
+// angle of -2.0 degrees
+-1, 0, 13368, -1, 1, 10104, 0, 0, 28495, 0, 1, 13569, // 0, 0
+-1, 1, 12574, -1, 2, 9662, 0, 1, 29831, 0, 2, 13469, // 0, 1
+-1, 2, 11829, -1, 3, 9229, 0, 2, 31146, 0, 3, 13332, // 0, 2
+-1, 3, 11143, -1, 4, 8816, 0, 3, 32406, 0, 4, 13171, // 0, 3
+-1, 4, 10528, -1, 5, 8438, 0, 4, 33564, 0, 5, 13006, // 0, 4
+-1, 5, 9995, -1, 6, 8107, 0, 5, 34567, 0, 6, 12867, // 0, 5
+-1, 6, 9558, -1, 7, 7839, 0, 6, 35362, 0, 7, 12777, // 0, 6
+-1, 7, 9224, -1, 8, 7643, 0, 7, 35905, 0, 8, 12764, // 0, 7
+0, 8, 35844, 0, 9, 12728, 1, 8, 9290, 1, 9, 7674, // 0, 8
+0, 9, 35315, 0, 10, 12717, 1, 9, 9635, 1, 10, 7869, // 0, 9
+0, 10, 34532, 0, 11, 12783, 1, 10, 10086, 1, 11, 8135, // 0,10
+0, 11, 33539, 0, 12, 12899, 1, 11, 10635, 1, 12, 8463, // 0,11
+0, 12, 32391, 0, 13, 13038, 1, 12, 11269, 1, 13, 8838, // 0,12
+0, 13, 31138, 0, 14, 13176, 1, 13, 11977, 1, 14, 9245, // 0,13
+0, 14, 29828, 0, 15, 13291, 1, 14, 12746, 1, 15, 9671, // 0,14
+0, 15, 28495, 0, 16, 13368, 1, 15, 13569, 1, 16, 10104, // 0,15
+0, 0, 13291, 0, 1, 9671, 1, 0, 29828, 1, 1, 12746, // 1, 0
+0, 1, 12412, 0, 2, 9202, 1, 1, 31358, 1, 2, 12564, // 1, 1
+0, 2, 11580, 0, 3, 8735, 1, 2, 32886, 1, 3, 12335, // 1, 2
+0, 3, 10808, 0, 4, 8284, 1, 3, 34369, 1, 4, 12075, // 1, 3
+0, 4, 10111, 0, 5, 7865, 1, 4, 35750, 1, 5, 11810, // 1, 4
+0, 5, 9509, 0, 6, 7497, 1, 5, 36955, 1, 6, 11575, // 1, 5
+0, 6, 9020, 0, 7, 7202, 1, 6, 37906, 1, 7, 11408, // 1, 6
+0, 7, 8662, 0, 8, 6997, 1, 7, 38534, 1, 8, 11343, // 1, 7
+1, 8, 38481, 1, 9, 11317, 2, 8, 8718, 2, 9, 7020, // 1, 8
+1, 9, 37866, 1, 10, 11360, 2, 9, 9086, 2, 10, 7224, // 1, 9
+1, 10, 36926, 1, 11, 11507, 2, 10, 9587, 2, 11, 7516, // 1,10
+1, 11, 35730, 1, 12, 11721, 2, 11, 10204, 2, 12, 7881, // 1,11
+1, 12, 34358, 1, 13, 11964, 2, 12, 10918, 2, 13, 8296, // 1,12
+1, 13, 32881, 1, 14, 12203, 2, 13, 11709, 2, 14, 8743, // 1,13
+1, 14, 31358, 1, 15, 12412, 2, 14, 12564, 2, 15, 9202, // 1,14
+1, 15, 29831, 1, 16, 12574, 2, 15, 13470, 2, 16, 9661, // 1,15
+1, 0, 13176, 1, 1, 9245, 2, 0, 31138, 2, 1, 11977, // 2, 0
+1, 1, 12203, 1, 2, 8742, 2, 1, 32881, 2, 2, 11710, // 2, 1
+1, 2, 11272, 1, 3, 8232, 2, 2, 34650, 2, 3, 11382, // 2, 2
+1, 3, 10397, 1, 4, 7728, 2, 3, 36399, 2, 4, 11012, // 2, 3
+1, 4, 9597, 1, 5, 7252, 2, 4, 38057, 2, 5, 10630, // 2, 4
+1, 5, 8902, 1, 6, 6829, 2, 5, 39526, 2, 6, 10279, // 2, 5
+1, 6, 8344, 1, 7, 6491, 2, 6, 40688, 2, 7, 10013, // 2, 6
+1, 7, 7951, 1, 8, 6266, 2, 7, 41432, 2, 8, 9887, // 2, 7
+2, 8, 41389, 2, 9, 9867, 3, 8, 7996, 3, 9, 6284, // 2, 8
+2, 9, 40656, 2, 10, 9977, 3, 9, 8397, 3, 10, 6506, // 2, 9
+2, 10, 39503, 2, 11, 10226, 3, 10, 8966, 3, 11, 6841, // 2,10
+2, 11, 38042, 2, 12, 10559, 3, 11, 9674, 3, 12, 7261, // 2,11
+2, 12, 36392, 2, 13, 10922, 3, 12, 10488, 3, 13, 7734, // 2,12
+2, 13, 34650, 2, 14, 11272, 3, 13, 11382, 3, 14, 8232, // 2,13
+2, 14, 32886, 2, 15, 11580, 3, 14, 12334, 3, 15, 8736, // 2,14
+2, 15, 31146, 2, 16, 11829, 3, 15, 13332, 3, 16, 9229, // 2,15
+2, 0, 13038, 2, 1, 8838, 3, 0, 32391, 3, 1, 11269, // 3, 0
+2, 1, 11964, 2, 2, 8296, 3, 1, 34358, 3, 2, 10918, // 3, 1
+2, 2, 10922, 2, 3, 7734, 3, 2, 36392, 3, 3, 10488, // 3, 2
+2, 3, 9924, 2, 4, 7164, 3, 3, 38450, 3, 4, 9998, // 3, 3
+2, 4, 8995, 2, 5, 6611, 3, 4, 40452, 3, 5, 9478, // 3, 4
+2, 5, 8175, 2, 6, 6108, 3, 5, 42271, 3, 6, 8982, // 3, 5
+2, 6, 7516, 2, 7, 5703, 3, 6, 43733, 3, 7, 8584, // 3, 6
+2, 7, 7072, 2, 8, 5443, 3, 7, 44649, 3, 8, 8372, // 3, 7
+3, 8, 44616, 3, 9, 8359, 4, 8, 7106, 4, 9, 5455, // 3, 8
+3, 9, 43710, 3, 10, 8558, 4, 9, 7556, 4, 10, 5712, // 3, 9
+3, 10, 42256, 3, 11, 8940, 4, 10, 8224, 4, 11, 6116, // 3,10
+3, 11, 40444, 3, 12, 9421, 4, 11, 9056, 4, 12, 6615, // 3,11
+3, 12, 38450, 3, 13, 9924, 4, 12, 9998, 4, 13, 7164, // 3,12
+3, 13, 36399, 3, 14, 10397, 4, 13, 11012, 4, 14, 7728, // 3,13
+3, 14, 34369, 3, 15, 10808, 4, 14, 12074, 4, 15, 8285, // 3,14
+3, 15, 32406, 3, 16, 11143, 4, 15, 13171, 4, 16, 8816, // 3,15
+3, 0, 12899, 3, 1, 8463, 4, 0, 33539, 4, 1, 10635, // 4, 0
+3, 1, 11721, 3, 2, 7881, 4, 1, 35730, 4, 2, 10204, // 4, 1
+3, 2, 10559, 3, 3, 7261, 4, 2, 38042, 4, 3, 9674, // 4, 2
+3, 3, 9421, 3, 4, 6615, 4, 3, 40444, 4, 4, 9056, // 4, 3
+3, 4, 8332, 3, 5, 5965, 4, 4, 42861, 4, 5, 8378, // 4, 4
+3, 5, 7342, 3, 6, 5350, 4, 5, 45146, 4, 6, 7698, // 4, 5
+3, 6, 6530, 3, 7, 4838, 4, 6, 47049, 4, 7, 7119, // 4, 6
+3, 7, 6000, 3, 8, 4513, 4, 7, 48240, 4, 8, 6783, // 4, 7
+4, 8, 48218, 4, 9, 6774, 5, 8, 6023, 5, 9, 4521, // 4, 8
+4, 9, 47035, 4, 10, 7100, 5, 9, 6558, 5, 10, 4843, // 4, 9
+4, 10, 45139, 4, 11, 7667, 5, 10, 7377, 5, 11, 5353, // 4,10
+4, 11, 42861, 4, 12, 8332, 5, 11, 8378, 5, 12, 5965, // 4,11
+4, 12, 40452, 4, 13, 8995, 5, 12, 9478, 5, 13, 6611, // 4,12
+4, 13, 38057, 4, 14, 9597, 5, 13, 10630, 5, 14, 7252, // 4,13
+4, 14, 35750, 4, 15, 10111, 5, 14, 11810, 5, 15, 7865, // 4,14
+4, 15, 33564, 4, 16, 10528, 5, 15, 13007, 5, 16, 8437, // 4,15
+4, 0, 12783, 4, 1, 8135, 5, 0, 34532, 5, 1, 10086, // 5, 0
+4, 1, 11507, 4, 2, 7517, 5, 1, 36926, 5, 2, 9586, // 5, 1
+4, 2, 10226, 4, 3, 6842, 5, 2, 39503, 5, 3, 8965, // 5, 2
+4, 3, 8940, 4, 4, 6116, 5, 3, 42256, 5, 4, 8224, // 5, 3
+4, 4, 7667, 4, 5, 5353, 5, 4, 45139, 5, 5, 7377, // 5, 4
+4, 5, 6451, 4, 6, 4591, 5, 5, 48019, 5, 6, 6475, // 5, 5
+4, 6, 5400, 4, 7, 3911, 5, 6, 50587, 5, 7, 5638, // 5, 6
+4, 7, 4708, 4, 8, 3466, 5, 7, 52266, 5, 8, 5096, // 5, 7
+5, 8, 52253, 5, 9, 5092, 6, 8, 4721, 6, 9, 3470, // 5, 8
+5, 9, 50581, 5, 10, 5624, 6, 9, 5418, 6, 10, 3913, // 5, 9
+5, 10, 48019, 5, 11, 6451, 6, 10, 6475, 6, 11, 4591, // 5,10
+5, 11, 45146, 5, 12, 7342, 6, 11, 7698, 6, 12, 5350, // 5,11
+5, 12, 42271, 5, 13, 8175, 6, 12, 8982, 6, 13, 6108, // 5,12
+5, 13, 39526, 5, 14, 8902, 6, 13, 10279, 6, 14, 6829, // 5,13
+5, 14, 36955, 5, 15, 9509, 6, 14, 11575, 6, 15, 7497, // 5,14
+5, 15, 34567, 5, 16, 9995, 6, 15, 12867, 6, 16, 8107, // 5,15
+5, 0, 12717, 5, 1, 7868, 6, 0, 35315, 6, 1, 9636, // 6, 0
+5, 1, 11360, 5, 2, 7224, 6, 1, 37866, 6, 2, 9086, // 6, 1
+5, 2, 9977, 5, 3, 6506, 6, 2, 40656, 6, 3, 8397, // 6, 2
+5, 3, 8558, 5, 4, 5712, 6, 3, 43710, 6, 4, 7556, // 6, 3
+5, 4, 7100, 5, 5, 4843, 6, 4, 47035, 6, 5, 6558, // 6, 4
+5, 5, 5624, 5, 6, 3913, 6, 5, 50581, 6, 6, 5418, // 6, 5
+5, 6, 4217, 5, 7, 2989, 6, 6, 54105, 6, 7, 4225, // 6, 6
+5, 7, 3180, 5, 8, 2294, 6, 7, 56756, 6, 8, 3306, // 6, 7
+6, 8, 56751, 6, 9, 3303, 7, 8, 3186, 7, 9, 2296, // 6, 8
+6, 9, 54105, 6, 10, 4217, 7, 9, 4225, 7, 10, 2989, // 6, 9
+6, 10, 50587, 6, 11, 5400, 7, 10, 5637, 7, 11, 3912, // 6,10
+6, 11, 47049, 6, 12, 6530, 7, 11, 7119, 7, 12, 4838, // 6,11
+6, 12, 43733, 6, 13, 7516, 7, 12, 8584, 7, 13, 5703, // 6,12
+6, 13, 40688, 6, 14, 8344, 7, 13, 10013, 7, 14, 6491, // 6,13
+6, 14, 37906, 6, 15, 9020, 7, 14, 11407, 7, 15, 7203, // 6,14
+6, 15, 35362, 6, 16, 9558, 7, 15, 12777, 7, 16, 7839, // 6,15
+6, 0, 12728, 6, 1, 7674, 7, 0, 35844, 7, 1, 9290, // 7, 0
+6, 1, 11317, 6, 2, 7020, 7, 1, 38481, 7, 2, 8718, // 7, 1
+6, 2, 9867, 6, 3, 6284, 7, 2, 41389, 7, 3, 7996, // 7, 2
+6, 3, 8359, 6, 4, 5454, 7, 3, 44616, 7, 4, 7107, // 7, 3
+6, 4, 6774, 6, 5, 4521, 7, 4, 48218, 7, 5, 6023, // 7, 4
+6, 5, 5092, 6, 6, 3470, 7, 5, 52253, 7, 6, 4721, // 7, 5
+6, 6, 3303, 6, 7, 2295, 7, 6, 56751, 7, 7, 3187, // 7, 6
+6, 7, 1541, 6, 8, 1090, 7, 7, 61364, 7, 8, 1541, // 7, 7
+7, 8, 61364, 7, 9, 1541, 8, 8, 1542, 8, 9, 1089, // 7, 8
+7, 9, 56756, 7, 10, 3180, 8, 9, 3306, 8, 10, 2294, // 7, 9
+7, 10, 52266, 7, 11, 4708, 8, 10, 5097, 8, 11, 3465, // 7,10
+7, 11, 48240, 7, 12, 6000, 8, 11, 6783, 8, 12, 4513, // 7,11
+7, 12, 44649, 7, 13, 7072, 8, 12, 8373, 8, 13, 5442, // 7,12
+7, 13, 41432, 7, 14, 7951, 8, 13, 9886, 8, 14, 6267, // 7,13
+7, 14, 38534, 7, 15, 8662, 8, 14, 11344, 8, 15, 6996, // 7,14
+7, 15, 35905, 7, 16, 9224, 8, 15, 12764, 8, 16, 7643, // 7,15
+7, -1, 7643, 7, 0, 12764, 8, -1, 9224, 8, 0, 35905, // 8, 0
+7, 0, 6997, 7, 1, 11344, 8, 0, 8662, 8, 1, 38533, // 8, 1
+7, 1, 6266, 7, 2, 9886, 8, 1, 7951, 8, 2, 41433, // 8, 2
+7, 2, 5443, 7, 3, 8373, 8, 2, 7072, 8, 3, 44648, // 8, 3
+7, 3, 4513, 7, 4, 6783, 8, 3, 6000, 8, 4, 48240, // 8, 4
+7, 4, 3466, 7, 5, 5097, 8, 4, 4708, 8, 5, 52265, // 8, 5
+7, 5, 2294, 7, 6, 3306, 8, 5, 3180, 8, 6, 56756, // 8, 6
+7, 6, 1090, 7, 7, 1542, 8, 6, 1541, 8, 7, 61363, // 8, 7
+8, 7, 1542, 8, 8, 61364, 9, 7, 1090, 9, 8, 1540, // 8, 8
+8, 8, 3186, 8, 9, 56751, 9, 8, 2295, 9, 9, 3304, // 8, 9
+8, 9, 4721, 8, 10, 52253, 9, 9, 3470, 9, 10, 5092, // 8,10
+8, 10, 6023, 8, 11, 48218, 9, 10, 4521, 9, 11, 6774, // 8,11
+8, 11, 7106, 8, 12, 44616, 9, 11, 5454, 9, 12, 8360, // 8,12
+8, 12, 7996, 8, 13, 41389, 9, 12, 6284, 9, 13, 9867, // 8,13
+8, 13, 8718, 8, 14, 38481, 9, 13, 7020, 9, 14, 11317, // 8,14
+8, 14, 9290, 8, 15, 35844, 9, 14, 7674, 9, 15, 12728, // 8,15
+8, -1, 7839, 8, 0, 12777, 9, -1, 9558, 9, 0, 35362, // 9, 0
+8, 0, 7202, 8, 1, 11407, 9, 0, 9020, 9, 1, 37907, // 9, 1
+8, 1, 6491, 8, 2, 10013, 9, 1, 8344, 9, 2, 40688, // 9, 2
+8, 2, 5703, 8, 3, 8584, 9, 2, 7516, 9, 3, 43733, // 9, 3
+8, 3, 4838, 8, 4, 7119, 9, 3, 6530, 9, 4, 47049, // 9, 4
+8, 4, 3911, 8, 5, 5637, 9, 4, 5400, 9, 5, 50588, // 9, 5
+8, 5, 2989, 8, 6, 4225, 9, 5, 4217, 9, 6, 54105, // 9, 6
+8, 6, 2295, 8, 7, 3186, 9, 6, 3303, 9, 7, 56752, // 9, 7
+9, 7, 3306, 9, 8, 56756, 10, 7, 2294, 10, 8, 3180, // 9, 8
+9, 8, 4225, 9, 9, 54105, 10, 8, 2989, 10, 9, 4217, // 9, 9
+9, 9, 5418, 9, 10, 50581, 10, 9, 3913, 10, 10, 5624, // 9,10
+9, 10, 6558, 9, 11, 47035, 10, 10, 4843, 10, 11, 7100, // 9,11
+9, 11, 7556, 9, 12, 43710, 10, 11, 5712, 10, 12, 8558, // 9,12
+9, 12, 8397, 9, 13, 40656, 10, 12, 6506, 10, 13, 9977, // 9,13
+9, 13, 9086, 9, 14, 37866, 10, 13, 7224, 10, 14, 11360, // 9,14
+9, 14, 9635, 9, 15, 35315, 10, 14, 7868, 10, 15, 12718, // 9,15
+9, -1, 8107, 9, 0, 12867, 10, -1, 9995, 10, 0, 34567, // 10, 0
+9, 0, 7497, 9, 1, 11575, 10, 0, 9509, 10, 1, 36955, // 10, 1
+9, 1, 6829, 9, 2, 10279, 10, 1, 8902, 10, 2, 39526, // 10, 2
+9, 2, 6108, 9, 3, 8982, 10, 2, 8175, 10, 3, 42271, // 10, 3
+9, 3, 5350, 9, 4, 7698, 10, 3, 7342, 10, 4, 45146, // 10, 4
+9, 4, 4591, 9, 5, 6475, 10, 4, 6451, 10, 5, 48019, // 10, 5
+9, 5, 3913, 9, 6, 5418, 10, 5, 5624, 10, 6, 50581, // 10, 6
+9, 6, 3470, 9, 7, 4721, 10, 6, 5092, 10, 7, 52253, // 10, 7
+10, 7, 5097, 10, 8, 52266, 11, 7, 3466, 11, 8, 4707, // 10, 8
+10, 8, 5637, 10, 9, 50587, 11, 8, 3911, 11, 9, 5401, // 10, 9
+10, 9, 6475, 10, 10, 48019, 11, 9, 4591, 11, 10, 6451, // 10,10
+10, 10, 7377, 10, 11, 45139, 11, 10, 5353, 11, 11, 7667, // 10,11
+10, 11, 8224, 10, 12, 42256, 11, 11, 6116, 11, 12, 8940, // 10,12
+10, 12, 8966, 10, 13, 39503, 11, 12, 6842, 11, 13, 10225, // 10,13
+10, 13, 9587, 10, 14, 36926, 11, 13, 7517, 11, 14, 11506, // 10,14
+10, 14, 10086, 10, 15, 34532, 11, 14, 8135, 11, 15, 12783, // 10,15
+10, -1, 8438, 10, 0, 13007, 11, -1, 10528, 11, 0, 33563, // 11, 0
+10, 0, 7865, 10, 1, 11810, 11, 0, 10111, 11, 1, 35750, // 11, 1
+10, 1, 7252, 10, 2, 10630, 11, 1, 9597, 11, 2, 38057, // 11, 2
+10, 2, 6611, 10, 3, 9478, 11, 2, 8995, 11, 3, 40452, // 11, 3
+10, 3, 5965, 10, 4, 8378, 11, 3, 8332, 11, 4, 42861, // 11, 4
+10, 4, 5353, 10, 5, 7377, 11, 4, 7667, 11, 5, 45139, // 11, 5
+10, 5, 4843, 10, 6, 6558, 11, 5, 7100, 11, 6, 47035, // 11, 6
+10, 6, 4521, 10, 7, 6023, 11, 6, 6774, 11, 7, 48218, // 11, 7
+11, 7, 6783, 11, 8, 48240, 12, 7, 4513, 12, 8, 6000, // 11, 8
+11, 8, 7119, 11, 9, 47049, 12, 8, 4838, 12, 9, 6530, // 11, 9
+11, 9, 7698, 11, 10, 45146, 12, 9, 5350, 12, 10, 7342, // 11,10
+11, 10, 8378, 11, 11, 42861, 12, 10, 5965, 12, 11, 8332, // 11,11
+11, 11, 9056, 11, 12, 40444, 12, 11, 6615, 12, 12, 9421, // 11,12
+11, 12, 9674, 11, 13, 38042, 12, 12, 7261, 12, 13, 10559, // 11,13
+11, 13, 10204, 11, 14, 35730, 12, 13, 7881, 12, 14, 11721, // 11,14
+11, 14, 10635, 11, 15, 33539, 12, 14, 8463, 12, 15, 12899, // 11,15
+11, -1, 8816, 11, 0, 13171, 12, -1, 11143, 12, 0, 32406, // 12, 0
+11, 0, 8284, 11, 1, 12074, 12, 0, 10808, 12, 1, 34370, // 12, 1
+11, 1, 7728, 11, 2, 11012, 12, 1, 10397, 12, 2, 36399, // 12, 2
+11, 2, 7164, 11, 3, 9998, 12, 2, 9924, 12, 3, 38450, // 12, 3
+11, 3, 6615, 11, 4, 9056, 12, 3, 9421, 12, 4, 40444, // 12, 4
+11, 4, 6116, 11, 5, 8224, 12, 4, 8940, 12, 5, 42256, // 12, 5
+11, 5, 5712, 11, 6, 7556, 12, 5, 8558, 12, 6, 43710, // 12, 6
+11, 6, 5454, 11, 7, 7106, 12, 6, 8359, 12, 7, 44617, // 12, 7
+12, 7, 8373, 12, 8, 44649, 13, 7, 5443, 13, 8, 7071, // 12, 8
+12, 8, 8584, 12, 9, 43733, 13, 8, 5703, 13, 9, 7516, // 12, 9
+12, 9, 8982, 12, 10, 42271, 13, 9, 6108, 13, 10, 8175, // 12,10
+12, 10, 9478, 12, 11, 40452, 13, 10, 6611, 13, 11, 8995, // 12,11
+12, 11, 9998, 12, 12, 38450, 13, 11, 7164, 13, 12, 9924, // 12,12
+12, 12, 10488, 12, 13, 36392, 13, 12, 7734, 13, 13, 10922, // 12,13
+12, 13, 10918, 12, 14, 34358, 13, 13, 8296, 13, 14, 11964, // 12,14
+12, 14, 11269, 12, 15, 32391, 13, 14, 8838, 13, 15, 13038, // 12,15
+12, -1, 9229, 12, 0, 13332, 13, -1, 11829, 13, 0, 31146, // 13, 0
+12, 0, 8735, 12, 1, 12334, 13, 0, 11580, 13, 1, 32887, // 13, 1
+12, 1, 8232, 12, 2, 11382, 13, 1, 11272, 13, 2, 34650, // 13, 2
+12, 2, 7734, 12, 3, 10488, 13, 2, 10922, 13, 3, 36392, // 13, 3
+12, 3, 7261, 12, 4, 9674, 13, 3, 10559, 13, 4, 38042, // 13, 4
+12, 4, 6842, 12, 5, 8966, 13, 4, 10226, 13, 5, 39502, // 13, 5
+12, 5, 6506, 12, 6, 8397, 13, 5, 9977, 13, 6, 40656, // 13, 6
+12, 6, 6284, 12, 7, 7996, 13, 6, 9867, 13, 7, 41389, // 13, 7
+13, 7, 9886, 13, 8, 41432, 14, 7, 6266, 14, 8, 7952, // 13, 8
+13, 8, 10013, 13, 9, 40688, 14, 8, 6491, 14, 9, 8344, // 13, 9
+13, 9, 10279, 13, 10, 39526, 14, 9, 6829, 14, 10, 8902, // 13,10
+13, 10, 10630, 13, 11, 38057, 14, 10, 7252, 14, 11, 9597, // 13,11
+13, 11, 11012, 13, 12, 36399, 14, 11, 7728, 14, 12, 10397, // 13,12
+13, 12, 11382, 13, 13, 34650, 14, 12, 8232, 14, 13, 11272, // 13,13
+13, 13, 11709, 13, 14, 32881, 14, 13, 8742, 14, 14, 12204, // 13,14
+13, 14, 11977, 13, 15, 31138, 14, 14, 9245, 14, 15, 13176, // 13,15
+13, -1, 9662, 13, 0, 13470, 14, -1, 12574, 14, 0, 29830, // 14, 0
+13, 0, 9202, 13, 1, 12564, 14, 0, 12412, 14, 1, 31358, // 14, 1
+13, 1, 8742, 13, 2, 11709, 14, 1, 12203, 14, 2, 32882, // 14, 2
+13, 2, 8296, 13, 3, 10918, 14, 2, 11964, 14, 3, 34358, // 14, 3
+13, 3, 7881, 13, 4, 10204, 14, 3, 11721, 14, 4, 35730, // 14, 4
+13, 4, 7517, 13, 5, 9587, 14, 4, 11507, 14, 5, 36925, // 14, 5
+13, 5, 7224, 13, 6, 9086, 14, 5, 11360, 14, 6, 37866, // 14, 6
+13, 6, 7020, 13, 7, 8718, 14, 6, 11317, 14, 7, 38481, // 14, 7
+14, 7, 11344, 14, 8, 38534, 15, 7, 6997, 15, 8, 8661, // 14, 8
+14, 8, 11407, 14, 9, 37906, 15, 8, 7202, 15, 9, 9021, // 14, 9
+14, 9, 11575, 14, 10, 36955, 15, 9, 7497, 15, 10, 9509, // 14,10
+14, 10, 11810, 14, 11, 35750, 15, 10, 7865, 15, 11, 10111, // 14,11
+14, 11, 12074, 14, 12, 34369, 15, 11, 8284, 15, 12, 10809, // 14,12
+14, 12, 12334, 14, 13, 32886, 15, 12, 8735, 15, 13, 11581, // 14,13
+14, 13, 12564, 14, 14, 31358, 15, 13, 9202, 15, 14, 12412, // 14,14
+14, 14, 12746, 14, 15, 29828, 15, 14, 9671, 15, 15, 13291, // 14,15
+14, -1, 10104, 14, 0, 13569, 15, -1, 13368, 15, 0, 28495, // 15, 0
+14, 0, 9671, 14, 1, 12746, 15, 0, 13291, 15, 1, 29828, // 15, 1
+14, 1, 9245, 14, 2, 11977, 15, 1, 13176, 15, 2, 31138, // 15, 2
+14, 2, 8838, 14, 3, 11269, 15, 2, 13038, 15, 3, 32391, // 15, 3
+14, 3, 8463, 14, 4, 10635, 15, 3, 12899, 15, 4, 33539, // 15, 4
+14, 4, 8135, 14, 5, 10086, 15, 4, 12783, 15, 5, 34532, // 15, 5
+14, 5, 7868, 14, 6, 9635, 15, 5, 12717, 15, 6, 35316, // 15, 6
+14, 6, 7674, 14, 7, 9290, 15, 6, 12728, 15, 7, 35844, // 15, 7
+15, 7, 12764, 15, 8, 35905, 16, 7, 7643, 16, 8, 9224, // 15, 8
+15, 8, 12777, 15, 9, 35362, 16, 8, 7839, 16, 9, 9558, // 15, 9
+15, 9, 12867, 15, 10, 34567, 16, 9, 8107, 16, 10, 9995, // 15,10
+15, 10, 13007, 15, 11, 33564, 16, 10, 8438, 16, 11, 10527, // 15,11
+15, 11, 13171, 15, 12, 32406, 16, 11, 8816, 16, 12, 11143, // 15,12
+15, 12, 13332, 15, 13, 31146, 16, 12, 9229, 16, 13, 11829, // 15,13
+15, 13, 13470, 15, 14, 29831, 16, 13, 9662, 16, 14, 12573, // 15,14
+15, 14, 13569, 15, 15, 28495, 16, 14, 10104, 16, 15, 13368, // 15,15
+// angle of -1.5 degrees
+-1, 0, 11440, -1, 1, 8358, 0, 0, 34212, 0, 1, 11526, // 0, 0
+-1, 1, 10780, -1, 2, 7983, 0, 1, 35506, 0, 2, 11267, // 0, 1
+-1, 2, 10158, -1, 3, 7620, 0, 2, 36764, 0, 3, 10994, // 0, 2
+-1, 3, 9585, -1, 4, 7276, 0, 3, 37951, 0, 4, 10724, // 0, 3
+-1, 4, 9072, -1, 5, 6965, 0, 4, 39026, 0, 5, 10473, // 0, 4
+-1, 5, 8632, -1, 6, 6699, 0, 5, 39940, 0, 6, 10265, // 0, 5
+-1, 6, 8278, -1, 7, 6489, 0, 6, 40646, 0, 7, 10123, // 0, 6
+-1, 7, 8018, -1, 8, 6346, 0, 7, 41106, 0, 8, 10066, // 0, 7
+0, 8, 41072, 0, 9, 10052, 1, 8, 8052, 1, 9, 6360, // 0, 8
+0, 9, 40618, 0, 10, 10100, 1, 9, 8316, 1, 10, 6502, // 0, 9
+0, 10, 39918, 0, 11, 10232, 1, 10, 8676, 1, 11, 6710, // 0,10
+0, 11, 39009, 0, 12, 10430, 1, 11, 9122, 1, 12, 6975, // 0,11
+0, 12, 37939, 0, 13, 10670, 1, 12, 9642, 1, 13, 7285, // 0,12
+0, 13, 36756, 0, 14, 10930, 1, 13, 10224, 1, 14, 7626, // 0,13
+0, 14, 35502, 0, 15, 11192, 1, 14, 10855, 1, 15, 7987, // 0,14
+0, 15, 34212, 0, 16, 11440, 1, 15, 11526, 1, 16, 8358, // 0,15
+0, 0, 11192, 0, 1, 7987, 1, 0, 35502, 1, 1, 10855, // 1, 0
+0, 1, 10467, 0, 2, 7579, 1, 1, 36959, 1, 2, 10531, // 1, 1
+0, 2, 9777, 0, 3, 7177, 1, 2, 38394, 1, 3, 10188, // 1, 2
+0, 3, 9135, 0, 4, 6792, 1, 3, 39767, 1, 4, 9842, // 1, 3
+0, 4, 8557, 0, 5, 6440, 1, 4, 41026, 1, 5, 9513, // 1, 4
+0, 5, 8061, 0, 6, 6137, 1, 5, 42105, 1, 6, 9233, // 1, 5
+0, 6, 7667, 0, 7, 5900, 1, 6, 42936, 1, 7, 9033, // 1, 6
+0, 7, 7390, 0, 8, 5745, 1, 7, 43461, 1, 8, 8940, // 1, 7
+1, 8, 43433, 1, 9, 8929, 2, 8, 7418, 2, 9, 5756, // 1, 8
+1, 9, 42913, 1, 10, 9014, 2, 9, 7699, 2, 10, 5910, // 1, 9
+1, 10, 42087, 1, 11, 9206, 2, 10, 8098, 2, 11, 6145, // 1,10
+1, 11, 41013, 1, 12, 9478, 2, 11, 8599, 2, 12, 6446, // 1,11
+1, 12, 39759, 1, 13, 9796, 2, 12, 9184, 2, 13, 6797, // 1,12
+1, 13, 38390, 1, 14, 10133, 2, 13, 9834, 2, 14, 7179, // 1,13
+1, 14, 36959, 1, 15, 10467, 2, 14, 10532, 2, 15, 7578, // 1,14
+1, 15, 35506, 1, 16, 10780, 2, 15, 11267, 2, 16, 7983, // 1,15
+1, 0, 10930, 1, 1, 7626, 2, 0, 36756, 2, 1, 10224, // 2, 0
+1, 1, 10133, 1, 2, 7179, 2, 1, 38390, 2, 2, 9834, // 2, 1
+1, 2, 9366, 1, 3, 6732, 2, 2, 40025, 2, 3, 9413, // 2, 2
+1, 3, 8641, 1, 4, 6297, 2, 3, 41618, 2, 4, 8980, // 2, 3
+1, 4, 7981, 1, 5, 5891, 2, 4, 43105, 2, 5, 8559, // 2, 4
+1, 5, 7411, 1, 6, 5537, 2, 5, 44399, 2, 6, 8189, // 2, 5
+1, 6, 6961, 1, 7, 5261, 2, 6, 45401, 2, 7, 7913, // 2, 6
+1, 7, 6658, 1, 8, 5087, 2, 7, 46017, 2, 8, 7774, // 2, 7
+2, 8, 45995, 2, 9, 7766, 3, 8, 6680, 3, 9, 5095, // 2, 8
+2, 9, 45383, 2, 10, 7899, 3, 9, 6986, 3, 10, 5268, // 2, 9
+2, 10, 44386, 2, 11, 8167, 3, 10, 7440, 3, 11, 5543, // 2,10
+2, 11, 43096, 2, 12, 8530, 3, 11, 8015, 3, 12, 5895, // 2,11
+2, 12, 41614, 2, 13, 8941, 3, 12, 8681, 3, 13, 6300, // 2,12
+2, 13, 40025, 2, 14, 9366, 3, 13, 9413, 3, 14, 6732, // 2,13
+2, 14, 38394, 2, 15, 9777, 3, 14, 10188, 3, 15, 7177, // 2,14
+2, 15, 36764, 2, 16, 10158, 3, 15, 10994, 3, 16, 7620, // 2,15
+2, 0, 10670, 2, 1, 7285, 3, 0, 37939, 3, 1, 9642, // 3, 0
+2, 1, 9796, 2, 2, 6797, 3, 1, 39759, 3, 2, 9184, // 3, 1
+2, 2, 8941, 2, 3, 6299, 3, 2, 41614, 3, 3, 8682, // 3, 2
+2, 3, 8120, 2, 4, 5804, 3, 3, 43461, 3, 4, 8151, // 3, 3
+2, 4, 7356, 2, 5, 5330, 3, 4, 45229, 3, 5, 7621, // 3, 4
+2, 5, 6685, 2, 6, 4906, 3, 5, 46806, 3, 6, 7139, // 3, 5
+2, 6, 6154, 2, 7, 4572, 3, 6, 48049, 3, 7, 6761, // 3, 6
+2, 7, 5811, 2, 8, 4366, 3, 7, 48801, 3, 8, 6558, // 3, 7
+3, 8, 48785, 3, 9, 6552, 4, 8, 5827, 4, 9, 4372, // 3, 8
+3, 9, 48037, 3, 10, 6750, 4, 9, 6173, 4, 10, 4576, // 3, 9
+3, 10, 46798, 3, 11, 7121, 4, 10, 6707, 4, 11, 4910, // 3,10
+3, 11, 45224, 3, 12, 7598, 4, 11, 7382, 4, 12, 5332, // 3,11
+3, 12, 43461, 3, 13, 8120, 4, 12, 8151, 4, 13, 5804, // 3,12
+3, 13, 41618, 3, 14, 8641, 4, 13, 8979, 4, 14, 6298, // 3,13
+3, 14, 39767, 3, 15, 9135, 4, 14, 9841, 4, 15, 6793, // 3,14
+3, 15, 37951, 3, 16, 9585, 4, 15, 10723, 4, 16, 7277, // 3,15
+3, 0, 10430, 3, 1, 6975, 4, 0, 39009, 4, 1, 9122, // 4, 0
+3, 1, 9478, 3, 2, 6447, 4, 1, 41013, 4, 2, 8598, // 4, 1
+3, 2, 8530, 3, 3, 5895, 4, 2, 43096, 4, 3, 8015, // 4, 2
+3, 3, 7598, 3, 4, 5331, 4, 3, 45224, 4, 4, 7383, // 4, 3
+3, 4, 6708, 3, 5, 4774, 4, 4, 47328, 4, 5, 6726, // 4, 4
+3, 5, 5901, 3, 6, 4257, 4, 5, 49279, 4, 6, 6099, // 4, 5
+3, 6, 5248, 3, 7, 3834, 4, 6, 50873, 4, 7, 5581, // 4, 6
+3, 7, 4835, 3, 8, 3575, 4, 7, 51842, 4, 8, 5284, // 4, 7
+4, 8, 51832, 4, 9, 5280, 5, 8, 4846, 5, 9, 3578, // 4, 8
+4, 9, 50865, 4, 10, 5573, 5, 9, 5261, 5, 10, 3837, // 4, 9
+4, 10, 49275, 4, 11, 6086, 5, 10, 5917, 5, 11, 4258, // 4,10
+4, 11, 47328, 4, 12, 6708, 5, 11, 6727, 5, 12, 4773, // 4,11
+4, 12, 45229, 4, 13, 7356, 5, 12, 7622, 5, 13, 5329, // 4,12
+4, 13, 43105, 4, 14, 7981, 5, 13, 8559, 5, 14, 5891, // 4,13
+4, 14, 41026, 4, 15, 8557, 5, 14, 9513, 5, 15, 6440, // 4,14
+4, 15, 39026, 4, 16, 9072, 5, 15, 10473, 5, 16, 6965, // 4,15
+4, 0, 10232, 4, 1, 6710, 5, 0, 39918, 5, 1, 8676, // 5, 0
+4, 1, 9206, 4, 2, 6145, 5, 1, 42087, 5, 2, 8098, // 5, 1
+4, 2, 8167, 4, 3, 5543, 5, 2, 44386, 5, 3, 7440, // 5, 2
+4, 3, 7121, 4, 4, 4909, 5, 3, 46798, 5, 4, 6708, // 5, 3
+4, 4, 6086, 4, 5, 4258, 5, 4, 49275, 5, 5, 5917, // 5, 4
+4, 5, 5103, 4, 6, 3621, 5, 5, 51700, 5, 6, 5112, // 5, 5
+4, 6, 4262, 4, 7, 3064, 5, 6, 53816, 5, 7, 4394, // 5, 6
+4, 7, 3720, 4, 8, 2708, 5, 7, 55168, 5, 8, 3940, // 5, 7
+5, 8, 55162, 5, 9, 3938, 6, 8, 3726, 6, 9, 2710, // 5, 8
+5, 9, 53813, 5, 10, 4388, 6, 9, 4269, 6, 10, 3066, // 5, 9
+5, 10, 51700, 5, 11, 5103, 6, 10, 5113, 6, 11, 3620, // 5,10
+5, 11, 49279, 5, 12, 5901, 6, 11, 6099, 6, 12, 4257, // 5,11
+5, 12, 46806, 5, 13, 6685, 6, 12, 7138, 6, 13, 4907, // 5,12
+5, 13, 44399, 5, 14, 7411, 6, 13, 8189, 6, 14, 5537, // 5,13
+5, 14, 42105, 5, 15, 8061, 6, 14, 9233, 6, 15, 6137, // 5,14
+5, 15, 39940, 5, 16, 8632, 6, 15, 10265, 6, 16, 6699, // 5,15
+5, 0, 10100, 5, 1, 6502, 6, 0, 40618, 6, 1, 8316, // 6, 0
+5, 1, 9014, 5, 2, 5910, 6, 1, 42913, 6, 2, 7699, // 6, 1
+5, 2, 7899, 5, 3, 5268, 6, 2, 45383, 6, 3, 6986, // 6, 2
+5, 3, 6750, 5, 4, 4576, 6, 3, 48037, 6, 4, 6173, // 6, 3
+5, 4, 5573, 5, 5, 3837, 6, 4, 50865, 6, 5, 5261, // 6, 4
+5, 5, 4388, 5, 6, 3065, 6, 5, 53813, 6, 6, 4270, // 6, 5
+5, 6, 3271, 5, 7, 2316, 6, 6, 56673, 6, 7, 3276, // 6, 6
+5, 7, 2462, 5, 8, 1766, 6, 7, 58775, 6, 8, 2533, // 6, 7
+6, 8, 58773, 6, 9, 2532, 7, 8, 2464, 7, 9, 1767, // 6, 8
+6, 9, 56673, 6, 10, 3271, 7, 9, 3275, 7, 10, 2317, // 6, 9
+6, 10, 53816, 6, 11, 4262, 7, 10, 4394, 7, 11, 3064, // 6,10
+6, 11, 50873, 6, 12, 5248, 7, 11, 5581, 7, 12, 3834, // 6,11
+6, 12, 48049, 6, 13, 6154, 7, 12, 6761, 7, 13, 4572, // 6,12
+6, 13, 45401, 6, 14, 6961, 7, 13, 7913, 7, 14, 5261, // 6,13
+6, 14, 42936, 6, 15, 7667, 7, 14, 9032, 7, 15, 5901, // 6,14
+6, 15, 40646, 6, 16, 8278, 7, 15, 10123, 7, 16, 6489, // 6,15
+6, 0, 10052, 6, 1, 6360, 7, 0, 41072, 7, 1, 8052, // 7, 0
+6, 1, 8929, 6, 2, 5756, 7, 1, 43433, 7, 2, 7418, // 7, 1
+6, 2, 7766, 6, 3, 5095, 7, 2, 45995, 7, 3, 6680, // 7, 2
+6, 3, 6552, 6, 4, 4372, 7, 3, 48785, 7, 4, 5827, // 7, 3
+6, 4, 5280, 6, 5, 3579, 7, 4, 51832, 7, 5, 4845, // 7, 4
+6, 5, 3938, 6, 6, 2710, 7, 5, 55162, 7, 6, 3726, // 7, 5
+6, 6, 2532, 6, 7, 1767, 7, 6, 58773, 7, 7, 2464, // 7, 6
+6, 7, 1170, 6, 8, 827, 7, 7, 62369, 7, 8, 1170, // 7, 7
+7, 8, 62369, 7, 9, 1170, 8, 8, 1170, 8, 9, 827, // 7, 8
+7, 9, 58775, 7, 10, 2462, 8, 9, 2533, 8, 10, 1766, // 7, 9
+7, 10, 55168, 7, 11, 3720, 8, 10, 3940, 8, 11, 2708, // 7,10
+7, 11, 51842, 7, 12, 4835, 8, 11, 5283, 8, 12, 3576, // 7,11
+7, 12, 48801, 7, 13, 5811, 8, 12, 6558, 8, 13, 4366, // 7,12
+7, 13, 46017, 7, 14, 6658, 8, 13, 7773, 8, 14, 5088, // 7,13
+7, 14, 43461, 7, 15, 7390, 8, 14, 8939, 8, 15, 5746, // 7,14
+7, 15, 41106, 7, 16, 8018, 8, 15, 10066, 8, 16, 6346, // 7,15
+7, -1, 6346, 7, 0, 10066, 8, -1, 8018, 8, 0, 41106, // 8, 0
+7, 0, 5745, 7, 1, 8939, 8, 0, 7390, 8, 1, 43462, // 8, 1
+7, 1, 5087, 7, 2, 7773, 8, 1, 6658, 8, 2, 46018, // 8, 2
+7, 2, 4366, 7, 3, 6558, 8, 2, 5811, 8, 3, 48801, // 8, 3
+7, 3, 3575, 7, 4, 5283, 8, 3, 4835, 8, 4, 51843, // 8, 4
+7, 4, 2708, 7, 5, 3940, 8, 4, 3720, 8, 5, 55168, // 8, 5
+7, 5, 1766, 7, 6, 2533, 8, 5, 2462, 8, 6, 58775, // 8, 6
+7, 6, 827, 7, 7, 1170, 8, 6, 1170, 8, 7, 62369, // 8, 7
+8, 7, 1170, 8, 8, 62369, 9, 7, 827, 9, 8, 1170, // 8, 8
+8, 8, 2464, 8, 9, 58773, 9, 8, 1767, 9, 9, 2532, // 8, 9
+8, 9, 3726, 8, 10, 55162, 9, 9, 2710, 9, 10, 3938, // 8,10
+8, 10, 4846, 8, 11, 51832, 9, 10, 3579, 9, 11, 5279, // 8,11
+8, 11, 5827, 8, 12, 48785, 9, 11, 4372, 9, 12, 6552, // 8,12
+8, 12, 6680, 8, 13, 45995, 9, 12, 5095, 9, 13, 7766, // 8,13
+8, 13, 7418, 8, 14, 43433, 9, 13, 5756, 9, 14, 8929, // 8,14
+8, 14, 8052, 8, 15, 41072, 9, 14, 6360, 9, 15, 10052, // 8,15
+8, -1, 6489, 8, 0, 10123, 9, -1, 8278, 9, 0, 40646, // 9, 0
+8, 0, 5900, 8, 1, 9032, 9, 0, 7667, 9, 1, 42937, // 9, 1
+8, 1, 5261, 8, 2, 7913, 9, 1, 6961, 9, 2, 45401, // 9, 2
+8, 2, 4572, 8, 3, 6761, 9, 2, 6154, 9, 3, 48049, // 9, 3
+8, 3, 3834, 8, 4, 5581, 9, 3, 5248, 9, 4, 50873, // 9, 4
+8, 4, 3064, 8, 5, 4394, 9, 4, 4262, 9, 5, 53816, // 9, 5
+8, 5, 2316, 8, 6, 3275, 9, 5, 3271, 9, 6, 56674, // 9, 6
+8, 6, 1767, 8, 7, 2464, 9, 6, 2532, 9, 7, 58773, // 9, 7
+9, 7, 2533, 9, 8, 58775, 10, 7, 1766, 10, 8, 2462, // 9, 8
+9, 8, 3275, 9, 9, 56673, 10, 8, 2316, 10, 9, 3272, // 9, 9
+9, 9, 4269, 9, 10, 53813, 10, 9, 3065, 10, 10, 4389, // 9,10
+9, 10, 5261, 9, 11, 50865, 10, 10, 3837, 10, 11, 5573, // 9,11
+9, 11, 6173, 9, 12, 48037, 10, 11, 4576, 10, 12, 6750, // 9,12
+9, 12, 6986, 9, 13, 45383, 10, 12, 5268, 10, 13, 7899, // 9,13
+9, 13, 7699, 9, 14, 42913, 10, 13, 5910, 10, 14, 9014, // 9,14
+9, 14, 8316, 9, 15, 40618, 10, 14, 6502, 10, 15, 10100, // 9,15
+9, -1, 6699, 9, 0, 10265, 10, -1, 8632, 10, 0, 39940, // 10, 0
+9, 0, 6137, 9, 1, 9233, 10, 0, 8061, 10, 1, 42105, // 10, 1
+9, 1, 5537, 9, 2, 8189, 10, 1, 7411, 10, 2, 44399, // 10, 2
+9, 2, 4906, 9, 3, 7138, 10, 2, 6685, 10, 3, 46807, // 10, 3
+9, 3, 4257, 9, 4, 6099, 10, 3, 5901, 10, 4, 49279, // 10, 4
+9, 4, 3621, 9, 5, 5113, 10, 4, 5103, 10, 5, 51699, // 10, 5
+9, 5, 3065, 9, 6, 4269, 10, 5, 4388, 10, 6, 53814, // 10, 6
+9, 6, 2710, 9, 7, 3726, 10, 6, 3938, 10, 7, 55162, // 10, 7
+10, 7, 3940, 10, 8, 55168, 11, 7, 2708, 11, 8, 3720, // 10, 8
+10, 8, 4394, 10, 9, 53816, 11, 8, 3064, 11, 9, 4262, // 10, 9
+10, 9, 5113, 10, 10, 51700, 11, 9, 3621, 11, 10, 5102, // 10,10
+10, 10, 5917, 10, 11, 49275, 11, 10, 4258, 11, 11, 6086, // 10,11
+10, 11, 6707, 10, 12, 46798, 11, 11, 4909, 11, 12, 7122, // 10,12
+10, 12, 7440, 10, 13, 44386, 11, 12, 5543, 11, 13, 8167, // 10,13
+10, 13, 8098, 10, 14, 42087, 11, 13, 6145, 11, 14, 9206, // 10,14
+10, 14, 8676, 10, 15, 39918, 11, 14, 6710, 11, 15, 10232, // 10,15
+10, -1, 6965, 10, 0, 10473, 11, -1, 9072, 11, 0, 39026, // 11, 0
+10, 0, 6440, 10, 1, 9513, 11, 0, 8557, 11, 1, 41026, // 11, 1
+10, 1, 5891, 10, 2, 8559, 11, 1, 7981, 11, 2, 43105, // 11, 2
+10, 2, 5330, 10, 3, 7622, 11, 2, 7356, 11, 3, 45228, // 11, 3
+10, 3, 4774, 10, 4, 6727, 11, 3, 6708, 11, 4, 47327, // 11, 4
+10, 4, 4258, 10, 5, 5917, 11, 4, 6086, 11, 5, 49275, // 11, 5
+10, 5, 3837, 10, 6, 5261, 11, 5, 5573, 11, 6, 50865, // 11, 6
+10, 6, 3579, 10, 7, 4846, 11, 6, 5280, 11, 7, 51831, // 11, 7
+11, 7, 5283, 11, 8, 51842, 12, 7, 3575, 12, 8, 4836, // 11, 8
+11, 8, 5581, 11, 9, 50873, 12, 8, 3834, 12, 9, 5248, // 11, 9
+11, 9, 6099, 11, 10, 49279, 12, 9, 4257, 12, 10, 5901, // 11,10
+11, 10, 6727, 11, 11, 47328, 12, 10, 4774, 12, 11, 6707, // 11,11
+11, 11, 7382, 11, 12, 45224, 12, 11, 5331, 12, 12, 7599, // 11,12
+11, 12, 8015, 11, 13, 43096, 12, 12, 5895, 12, 13, 8530, // 11,13
+11, 13, 8599, 11, 14, 41013, 12, 13, 6447, 12, 14, 9477, // 11,14
+11, 14, 9122, 11, 15, 39009, 12, 14, 6975, 12, 15, 10430, // 11,15
+11, -1, 7276, 11, 0, 10723, 12, -1, 9585, 12, 0, 37952, // 12, 0
+11, 0, 6792, 11, 1, 9841, 12, 0, 9135, 12, 1, 39768, // 12, 1
+11, 1, 6297, 11, 2, 8979, 12, 1, 8641, 12, 2, 41619, // 12, 2
+11, 2, 5804, 11, 3, 8151, 12, 2, 8120, 12, 3, 43461, // 12, 3
+11, 3, 5331, 11, 4, 7382, 12, 3, 7598, 12, 4, 45225, // 12, 4
+11, 4, 4909, 11, 5, 6707, 12, 4, 7121, 12, 5, 46799, // 12, 5
+11, 5, 4576, 11, 6, 6173, 12, 5, 6750, 12, 6, 48037, // 12, 6
+11, 6, 4372, 11, 7, 5827, 12, 6, 6552, 12, 7, 48785, // 12, 7
+12, 7, 6558, 12, 8, 48801, 13, 7, 4366, 13, 8, 5811, // 12, 8
+12, 8, 6761, 12, 9, 48049, 13, 8, 4572, 13, 9, 6154, // 12, 9
+12, 9, 7138, 12, 10, 46806, 13, 9, 4906, 13, 10, 6686, // 12,10
+12, 10, 7622, 12, 11, 45229, 13, 10, 5330, 13, 11, 7355, // 12,11
+12, 11, 8151, 12, 12, 43461, 13, 11, 5804, 13, 12, 8120, // 12,12
+12, 12, 8681, 12, 13, 41614, 13, 12, 6299, 13, 13, 8942, // 12,13
+12, 13, 9184, 12, 14, 39759, 13, 13, 6797, 13, 14, 9796, // 12,14
+12, 14, 9642, 12, 15, 37939, 13, 14, 7285, 13, 15, 10670, // 12,15
+12, -1, 7620, 12, 0, 10994, 13, -1, 10158, 13, 0, 36764, // 13, 0
+12, 0, 7177, 12, 1, 10188, 13, 0, 9777, 13, 1, 38394, // 13, 1
+12, 1, 6732, 12, 2, 9413, 13, 1, 9366, 13, 2, 40025, // 13, 2
+12, 2, 6299, 12, 3, 8681, 13, 2, 8941, 13, 3, 41615, // 13, 3
+12, 3, 5895, 12, 4, 8015, 13, 3, 8530, 13, 4, 43096, // 13, 4
+12, 4, 5543, 12, 5, 7440, 13, 4, 8167, 13, 5, 44386, // 13, 5
+12, 5, 5268, 12, 6, 6986, 13, 5, 7899, 13, 6, 45383, // 13, 6
+12, 6, 5095, 12, 7, 6680, 13, 6, 7766, 13, 7, 45995, // 13, 7
+13, 7, 7773, 13, 8, 46017, 14, 7, 5087, 14, 8, 6659, // 13, 8
+13, 8, 7913, 13, 9, 45401, 14, 8, 5261, 14, 9, 6961, // 13, 9
+13, 9, 8189, 13, 10, 44399, 14, 9, 5537, 14, 10, 7411, // 13,10
+13, 10, 8559, 13, 11, 43105, 14, 10, 5891, 14, 11, 7981, // 13,11
+13, 11, 8979, 13, 12, 41618, 14, 11, 6297, 14, 12, 8642, // 13,12
+13, 12, 9413, 13, 13, 40025, 14, 12, 6732, 14, 13, 9366, // 13,13
+13, 13, 9834, 13, 14, 38390, 14, 13, 7179, 14, 14, 10133, // 13,14
+13, 14, 10224, 13, 15, 36756, 14, 14, 7626, 14, 15, 10930, // 13,15
+13, -1, 7983, 13, 0, 11267, 14, -1, 10780, 14, 0, 35506, // 14, 0
+13, 0, 7579, 13, 1, 10532, 14, 0, 10467, 14, 1, 36958, // 14, 1
+13, 1, 7179, 13, 2, 9834, 14, 1, 10133, 14, 2, 38390, // 14, 2
+13, 2, 6797, 13, 3, 9184, 14, 2, 9796, 14, 3, 39759, // 14, 3
+13, 3, 6447, 13, 4, 8599, 14, 3, 9478, 14, 4, 41012, // 14, 4
+13, 4, 6145, 13, 5, 8098, 14, 4, 9206, 14, 5, 42087, // 14, 5
+13, 5, 5910, 13, 6, 7699, 14, 5, 9014, 14, 6, 42913, // 14, 6
+13, 6, 5756, 13, 7, 7418, 14, 6, 8929, 14, 7, 43433, // 14, 7
+14, 7, 8939, 14, 8, 43461, 15, 7, 5745, 15, 8, 7391, // 14, 8
+14, 8, 9032, 14, 9, 42936, 15, 8, 5900, 15, 9, 7668, // 14, 9
+14, 9, 9233, 14, 10, 42105, 15, 9, 6137, 15, 10, 8061, // 14,10
+14, 10, 9513, 14, 11, 41026, 15, 10, 6440, 15, 11, 8557, // 14,11
+14, 11, 9841, 14, 12, 39767, 15, 11, 6792, 15, 12, 9136, // 14,12
+14, 12, 10188, 14, 13, 38394, 15, 12, 7177, 15, 13, 9777, // 14,13
+14, 13, 10532, 14, 14, 36959, 15, 13, 7579, 15, 14, 10466, // 14,14
+14, 14, 10855, 14, 15, 35502, 15, 14, 7987, 15, 15, 11192, // 14,15
+14, -1, 8358, 14, 0, 11526, 15, -1, 11440, 15, 0, 34212, // 15, 0
+14, 0, 7987, 14, 1, 10855, 15, 0, 11192, 15, 1, 35502, // 15, 1
+14, 1, 7626, 14, 2, 10224, 15, 1, 10930, 15, 2, 36756, // 15, 2
+14, 2, 7285, 14, 3, 9642, 15, 2, 10670, 15, 3, 37939, // 15, 3
+14, 3, 6975, 14, 4, 9122, 15, 3, 10430, 15, 4, 39009, // 15, 4
+14, 4, 6710, 14, 5, 8676, 15, 4, 10232, 15, 5, 39918, // 15, 5
+14, 5, 6502, 14, 6, 8316, 15, 5, 10100, 15, 6, 40618, // 15, 6
+14, 6, 6360, 14, 7, 8052, 15, 6, 10052, 15, 7, 41072, // 15, 7
+15, 7, 10066, 15, 8, 41106, 16, 7, 6346, 16, 8, 8018, // 15, 8
+15, 8, 10123, 15, 9, 40646, 16, 8, 6489, 16, 9, 8278, // 15, 9
+15, 9, 10265, 15, 10, 39940, 16, 9, 6699, 16, 10, 8632, // 15,10
+15, 10, 10473, 15, 11, 39026, 16, 10, 6965, 16, 11, 9072, // 15,11
+15, 11, 10723, 15, 12, 37951, 16, 11, 7276, 16, 12, 9586, // 15,12
+15, 12, 10994, 15, 13, 36764, 16, 12, 7620, 16, 13, 10158, // 15,13
+15, 13, 11267, 15, 14, 35506, 16, 13, 7983, 16, 14, 10780, // 15,14
+15, 14, 11526, 15, 15, 34212, 16, 14, 8358, 16, 15, 11440, // 15,15
+// angle of -1.0 degrees
+-1, 0, 8769, -1, 1, 6280, 0, 0, 41693, 0, 1, 8794, // 0, 0
+-1, 1, 8265, -1, 2, 5974, 0, 1, 42823, 0, 2, 8474, // 0, 1
+-1, 2, 7791, -1, 3, 5682, 0, 2, 43904, 0, 3, 8159, // 0, 2
+-1, 3, 7356, -1, 4, 5410, 0, 3, 44907, 0, 4, 7863, // 0, 3
+-1, 4, 6970, -1, 5, 5169, 0, 4, 45799, 0, 5, 7598, // 0, 4
+-1, 5, 6644, -1, 6, 4967, 0, 5, 46541, 0, 6, 7384, // 0, 5
+-1, 6, 6391, -1, 7, 4814, 0, 6, 47098, 0, 7, 7233, // 0, 6
+-1, 7, 6217, -1, 8, 4718, 0, 7, 47440, 0, 8, 7161, // 0, 7
+0, 8, 47426, 0, 9, 7158, 1, 8, 6230, 1, 9, 4722, // 0, 8
+0, 9, 47086, 0, 10, 7227, 1, 9, 6405, 1, 10, 4818, // 0, 9
+0, 10, 46532, 0, 11, 7374, 1, 10, 6659, 1, 11, 4971, // 0,10
+0, 11, 45791, 0, 12, 7587, 1, 11, 6986, 1, 12, 5172, // 0,11
+0, 12, 44901, 0, 13, 7848, 1, 12, 7374, 1, 13, 5413, // 0,12
+0, 13, 43900, 0, 14, 8141, 1, 13, 7812, 1, 14, 5683, // 0,13
+0, 14, 42821, 0, 15, 8452, 1, 14, 8288, 1, 15, 5975, // 0,14
+0, 15, 41693, 0, 16, 8769, 1, 15, 8795, 1, 16, 6279, // 0,15
+0, 0, 8452, 0, 1, 5975, 1, 0, 42821, 1, 1, 8288, // 1, 0
+0, 1, 7901, 0, 2, 5640, 1, 1, 44074, 1, 2, 7921, // 1, 1
+0, 2, 7378, 0, 3, 5315, 1, 2, 45288, 1, 3, 7555, // 1, 2
+0, 3, 6892, 0, 4, 5009, 1, 3, 46430, 1, 4, 7205, // 1, 3
+0, 4, 6458, 0, 5, 4734, 1, 4, 47458, 1, 5, 6886, // 1, 4
+0, 5, 6092, 0, 6, 4502, 1, 5, 48322, 1, 6, 6620, // 1, 5
+0, 6, 5809, 0, 7, 4327, 1, 6, 48969, 1, 7, 6431, // 1, 6
+0, 7, 5623, 0, 8, 4221, 1, 7, 49358, 1, 8, 6334, // 1, 7
+1, 8, 49347, 1, 9, 6332, 2, 8, 5633, 2, 9, 4224, // 1, 8
+1, 9, 48960, 1, 10, 6425, 2, 9, 5820, 2, 10, 4331, // 1, 9
+1, 10, 48314, 1, 11, 6613, 2, 10, 6104, 2, 11, 4505, // 1,10
+1, 11, 47453, 1, 12, 6875, 2, 11, 6472, 2, 12, 4736, // 1,11
+1, 12, 46427, 1, 13, 7191, 2, 12, 6908, 2, 13, 5010, // 1,12
+1, 13, 45286, 1, 14, 7539, 2, 13, 7395, 2, 14, 5316, // 1,13
+1, 14, 44074, 1, 15, 7901, 2, 14, 7921, 2, 15, 5640, // 1,14
+1, 15, 42823, 1, 16, 8265, 2, 15, 8474, 2, 16, 5974, // 1,15
+1, 0, 8141, 1, 1, 5684, 2, 0, 43900, 2, 1, 7811, // 2, 0
+1, 1, 7539, 1, 2, 5316, 2, 1, 45286, 2, 2, 7395, // 2, 1
+1, 2, 6959, 1, 3, 4954, 2, 2, 46650, 2, 3, 6973, // 2, 2
+1, 3, 6414, 1, 4, 4607, 2, 3, 47955, 2, 4, 6560, // 2, 3
+1, 4, 5920, 1, 5, 4290, 2, 4, 49150, 2, 5, 6176, // 2, 4
+1, 5, 5499, 1, 6, 4019, 2, 5, 50171, 2, 6, 5847, // 2, 5
+1, 6, 5175, 1, 7, 3813, 2, 6, 50942, 2, 7, 5606, // 2, 6
+1, 7, 4970, 1, 8, 3691, 2, 7, 51395, 2, 8, 5480, // 2, 7
+2, 8, 51387, 2, 9, 5478, 3, 8, 4978, 3, 9, 3693, // 2, 8
+2, 9, 50935, 2, 10, 5602, 3, 9, 5184, 3, 10, 3815, // 2, 9
+2, 10, 50165, 2, 11, 5842, 3, 10, 5508, 3, 11, 4021, // 2,10
+2, 11, 49147, 2, 12, 6168, 3, 11, 5930, 3, 12, 4291, // 2,11
+2, 12, 47953, 2, 13, 6549, 3, 12, 6426, 3, 13, 4608, // 2,12
+2, 13, 46650, 2, 14, 6959, 3, 13, 6973, 3, 14, 4954, // 2,13
+2, 14, 45288, 2, 15, 7378, 3, 14, 7555, 3, 15, 5315, // 2,14
+2, 15, 43904, 2, 16, 7791, 3, 15, 8159, 3, 16, 5682, // 2,15
+2, 0, 7848, 2, 1, 5413, 3, 0, 44901, 3, 1, 7374, // 3, 0
+2, 1, 7191, 2, 2, 5011, 3, 1, 46427, 3, 2, 6907, // 3, 1
+2, 2, 6549, 2, 3, 4608, 3, 2, 47953, 3, 3, 6426, // 3, 2
+2, 3, 5934, 2, 4, 4214, 3, 3, 49445, 3, 4, 5943, // 3, 3
+2, 4, 5365, 2, 5, 3845, 3, 4, 50844, 3, 5, 5482, // 3, 4
+2, 5, 4872, 2, 6, 3522, 3, 5, 52069, 3, 6, 5073, // 3, 5
+2, 6, 4489, 2, 7, 3273, 3, 6, 53012, 3, 7, 4762, // 3, 6
+2, 7, 4254, 2, 8, 3126, 3, 7, 53562, 3, 8, 4594, // 3, 7
+3, 8, 53557, 3, 9, 4592, 4, 8, 4259, 4, 9, 3128, // 3, 8
+3, 9, 53008, 3, 10, 4759, 4, 9, 4495, 4, 10, 3274, // 3, 9
+3, 10, 52066, 3, 11, 5069, 4, 10, 4879, 4, 11, 3522, // 3,10
+3, 11, 50843, 3, 12, 5474, 4, 11, 5373, 4, 12, 3846, // 3,11
+3, 12, 49445, 3, 13, 5934, 4, 12, 5943, 4, 13, 4214, // 3,12
+3, 13, 47955, 3, 14, 6414, 4, 13, 6560, 4, 14, 4607, // 3,13
+3, 14, 46430, 3, 15, 6892, 4, 14, 7204, 4, 15, 5010, // 3,14
+3, 15, 44907, 3, 16, 7356, 4, 15, 7863, 4, 16, 5410, // 3,15
+3, 0, 7587, 3, 1, 5172, 4, 0, 45791, 4, 1, 6986, // 4, 0
+3, 1, 6875, 3, 2, 4736, 4, 1, 47453, 4, 2, 6472, // 4, 1
+3, 2, 6168, 3, 3, 4291, 4, 2, 49147, 4, 3, 5930, // 4, 2
+3, 3, 5474, 3, 4, 3846, 4, 3, 50843, 4, 4, 5373, // 4, 3
+3, 4, 4816, 3, 5, 3415, 4, 4, 52484, 4, 5, 4821, // 4, 4
+3, 5, 4226, 3, 6, 3023, 4, 5, 53975, 4, 6, 4312, // 4, 5
+3, 6, 3755, 3, 7, 2710, 4, 6, 55166, 4, 7, 3905, // 4, 6
+3, 7, 3469, 3, 8, 2524, 4, 7, 55870, 4, 8, 3673, // 4, 7
+4, 8, 55867, 4, 9, 3671, 5, 8, 3473, 5, 9, 2525, // 4, 8
+4, 9, 55164, 4, 10, 3902, 5, 9, 3759, 5, 10, 2711, // 4, 9
+4, 10, 53973, 4, 11, 4309, 5, 10, 4230, 5, 11, 3024, // 4,10
+4, 11, 52484, 4, 12, 4816, 5, 11, 4822, 5, 12, 3414, // 4,11
+4, 12, 50844, 4, 13, 5365, 5, 12, 5481, 5, 13, 3846, // 4,12
+4, 13, 49150, 4, 14, 5920, 5, 13, 6176, 5, 14, 4290, // 4,13
+4, 14, 47458, 4, 15, 6458, 5, 14, 6886, 5, 15, 4734, // 4,14
+4, 15, 45799, 4, 16, 6970, 5, 15, 7599, 5, 16, 5168, // 4,15
+4, 0, 7374, 4, 1, 4971, 5, 0, 46532, 5, 1, 6659, // 5, 0
+4, 1, 6613, 4, 2, 4505, 5, 1, 48314, 5, 2, 6104, // 5, 1
+4, 2, 5842, 4, 3, 4020, 5, 2, 50165, 5, 3, 5509, // 5, 2
+4, 3, 5069, 4, 4, 3523, 5, 3, 52066, 5, 4, 4878, // 5, 3
+4, 4, 4309, 4, 5, 3023, 5, 4, 53973, 5, 5, 4231, // 5, 4
+4, 5, 3595, 4, 6, 2546, 5, 5, 55798, 5, 6, 3597, // 5, 5
+4, 6, 2993, 4, 7, 2138, 5, 6, 57354, 5, 7, 3051, // 5, 6
+4, 7, 2615, 4, 8, 1884, 5, 7, 58324, 5, 8, 2713, // 5, 7
+5, 8, 58322, 5, 9, 2713, 6, 8, 2616, 6, 9, 1885, // 5, 8
+5, 9, 57353, 5, 10, 3050, 6, 9, 2995, 6, 10, 2138, // 5, 9
+5, 10, 55798, 5, 11, 3595, 6, 10, 3598, 6, 11, 2545, // 5,10
+5, 11, 53975, 5, 12, 4226, 6, 11, 4313, 6, 12, 3022, // 5,11
+5, 12, 52069, 5, 13, 4872, 6, 12, 5073, 6, 13, 3522, // 5,12
+5, 13, 50171, 5, 14, 5499, 6, 13, 5848, 6, 14, 4018, // 5,13
+5, 14, 48322, 5, 15, 6092, 6, 14, 6620, 6, 15, 4502, // 5,14
+5, 15, 46541, 5, 16, 6644, 6, 15, 7383, 6, 16, 4968, // 5,15
+5, 0, 7227, 5, 1, 4818, 6, 0, 47086, 6, 1, 6405, // 6, 0
+5, 1, 6425, 5, 2, 4330, 6, 1, 48960, 6, 2, 5821, // 6, 1
+5, 2, 5602, 5, 3, 3815, 6, 2, 50935, 6, 3, 5184, // 6, 2
+5, 3, 4759, 5, 4, 3274, 6, 3, 53008, 6, 4, 4495, // 6, 3
+5, 4, 3902, 5, 5, 2711, 6, 4, 55164, 6, 5, 3759, // 6, 4
+5, 5, 3050, 5, 6, 2138, 6, 5, 57353, 6, 6, 2995, // 6, 5
+5, 6, 2258, 5, 7, 1597, 6, 6, 59422, 6, 7, 2259, // 6, 6
+5, 7, 1695, 5, 8, 1209, 6, 7, 60906, 6, 8, 1726, // 6, 7
+6, 8, 60905, 6, 9, 1726, 7, 8, 1695, 7, 9, 1210, // 6, 8
+6, 9, 59422, 6, 10, 2258, 7, 9, 2259, 7, 10, 1597, // 6, 9
+6, 10, 57354, 6, 11, 2993, 7, 10, 3051, 7, 11, 2138, // 6,10
+6, 11, 55166, 6, 12, 3755, 7, 11, 3904, 7, 12, 2711, // 6,11
+6, 12, 53012, 6, 13, 4489, 7, 12, 4762, 7, 13, 3273, // 6,12
+6, 13, 50942, 6, 14, 5175, 7, 13, 5606, 7, 14, 3813, // 6,13
+6, 14, 48969, 6, 15, 5809, 7, 14, 6430, 7, 15, 4328, // 6,14
+6, 15, 47098, 6, 16, 6391, 7, 15, 7233, 7, 16, 4814, // 6,15
+6, 0, 7158, 6, 1, 4722, 7, 0, 47426, 7, 1, 6230, // 7, 0
+6, 1, 6332, 6, 2, 4224, 7, 1, 49347, 7, 2, 5633, // 7, 1
+6, 2, 5478, 6, 3, 3693, 7, 2, 51387, 7, 3, 4978, // 7, 2
+6, 3, 4592, 6, 4, 3128, 7, 3, 53557, 7, 4, 4259, // 7, 3
+6, 4, 3671, 6, 5, 2525, 7, 4, 55867, 7, 5, 3473, // 7, 4
+6, 5, 2713, 6, 6, 1884, 7, 5, 58322, 7, 6, 2617, // 7, 5
+6, 6, 1726, 6, 7, 1210, 7, 6, 60905, 7, 7, 1695, // 7, 6
+6, 7, 789, 6, 8, 558, 7, 7, 63399, 7, 8, 790, // 7, 7
+7, 8, 63399, 7, 9, 789, 8, 8, 789, 8, 9, 559, // 7, 8
+7, 9, 60906, 7, 10, 1695, 8, 9, 1726, 8, 10, 1209, // 7, 9
+7, 10, 58324, 7, 11, 2615, 8, 10, 2714, 8, 11, 1883, // 7,10
+7, 11, 55870, 7, 12, 3469, 8, 11, 3672, 8, 12, 2525, // 7,11
+7, 12, 53562, 7, 13, 4254, 8, 12, 4594, 8, 13, 3126, // 7,12
+7, 13, 51395, 7, 14, 4970, 8, 13, 5480, 8, 14, 3691, // 7,13
+7, 14, 49358, 7, 15, 5623, 8, 14, 6335, 8, 15, 4220, // 7,14
+7, 15, 47440, 7, 16, 6217, 8, 15, 7161, 8, 16, 4718, // 7,15
+7, -1, 4718, 7, 0, 7161, 8, -1, 6217, 8, 0, 47440, // 8, 0
+7, 0, 4221, 7, 1, 6335, 8, 0, 5623, 8, 1, 49357, // 8, 1
+7, 1, 3691, 7, 2, 5480, 8, 1, 4970, 8, 2, 51395, // 8, 2
+7, 2, 3126, 7, 3, 4594, 8, 2, 4254, 8, 3, 53562, // 8, 3
+7, 3, 2524, 7, 4, 3672, 8, 3, 3469, 8, 4, 55871, // 8, 4
+7, 4, 1884, 7, 5, 2714, 8, 4, 2615, 8, 5, 58323, // 8, 5
+7, 5, 1209, 7, 6, 1726, 8, 5, 1695, 8, 6, 60906, // 8, 6
+7, 6, 558, 7, 7, 789, 8, 6, 789, 8, 7, 63400, // 8, 7
+8, 7, 789, 8, 8, 63399, 9, 7, 558, 9, 8, 790, // 8, 8
+8, 8, 1695, 8, 9, 60905, 9, 8, 1210, 9, 9, 1726, // 8, 9
+8, 9, 2616, 8, 10, 58322, 9, 9, 1884, 9, 10, 2714, // 8,10
+8, 10, 3473, 8, 11, 55867, 9, 10, 2525, 9, 11, 3671, // 8,11
+8, 11, 4259, 8, 12, 53557, 9, 11, 3128, 9, 12, 4592, // 8,12
+8, 12, 4978, 8, 13, 51387, 9, 12, 3693, 9, 13, 5478, // 8,13
+8, 13, 5633, 8, 14, 49347, 9, 13, 4224, 9, 14, 6332, // 8,14
+8, 14, 6230, 8, 15, 47426, 9, 14, 4722, 9, 15, 7158, // 8,15
+8, -1, 4814, 8, 0, 7233, 9, -1, 6391, 9, 0, 47098, // 9, 0
+8, 0, 4327, 8, 1, 6430, 9, 0, 5809, 9, 1, 48970, // 9, 1
+8, 1, 3813, 8, 2, 5606, 9, 1, 5175, 9, 2, 50942, // 9, 2
+8, 2, 3273, 8, 3, 4762, 9, 2, 4489, 9, 3, 53012, // 9, 3
+8, 3, 2710, 8, 4, 3904, 9, 3, 3755, 9, 4, 55167, // 9, 4
+8, 4, 2138, 8, 5, 3051, 9, 4, 2993, 9, 5, 57354, // 9, 5
+8, 5, 1597, 8, 6, 2259, 9, 5, 2258, 9, 6, 59422, // 9, 6
+8, 6, 1210, 8, 7, 1695, 9, 6, 1726, 9, 7, 60905, // 9, 7
+9, 7, 1726, 9, 8, 60906, 10, 7, 1209, 10, 8, 1695, // 9, 8
+9, 8, 2259, 9, 9, 59422, 10, 8, 1597, 10, 9, 2258, // 9, 9
+9, 9, 2995, 9, 10, 57353, 10, 9, 2138, 10, 10, 3050, // 9,10
+9, 10, 3759, 9, 11, 55164, 10, 10, 2711, 10, 11, 3902, // 9,11
+9, 11, 4495, 9, 12, 53008, 10, 11, 3274, 10, 12, 4759, // 9,12
+9, 12, 5184, 9, 13, 50935, 10, 12, 3815, 10, 13, 5602, // 9,13
+9, 13, 5820, 9, 14, 48960, 10, 13, 4330, 10, 14, 6426, // 9,14
+9, 14, 6405, 9, 15, 47086, 10, 14, 4818, 10, 15, 7227, // 9,15
+9, -1, 4967, 9, 0, 7383, 10, -1, 6644, 10, 0, 46542, // 10, 0
+9, 0, 4502, 9, 1, 6620, 10, 0, 6092, 10, 1, 48322, // 10, 1
+9, 1, 4019, 9, 2, 5848, 10, 1, 5499, 10, 2, 50170, // 10, 2
+9, 2, 3522, 9, 3, 5073, 10, 2, 4872, 10, 3, 52069, // 10, 3
+9, 3, 3023, 9, 4, 4313, 10, 3, 4226, 10, 4, 53974, // 10, 4
+9, 4, 2546, 9, 5, 3598, 10, 4, 3595, 10, 5, 55797, // 10, 5
+9, 5, 2138, 9, 6, 2995, 10, 5, 3050, 10, 6, 57353, // 10, 6
+9, 6, 1884, 9, 7, 2616, 10, 6, 2713, 10, 7, 58323, // 10, 7
+10, 7, 2714, 10, 8, 58324, 11, 7, 1884, 11, 8, 2614, // 10, 8
+10, 8, 3051, 10, 9, 57354, 11, 8, 2138, 11, 9, 2993, // 10, 9
+10, 9, 3598, 10, 10, 55798, 11, 9, 2546, 11, 10, 3594, // 10,10
+10, 10, 4230, 10, 11, 53973, 11, 10, 3023, 11, 11, 4310, // 10,11
+10, 11, 4879, 10, 12, 52066, 11, 11, 3523, 11, 12, 5068, // 10,12
+10, 12, 5508, 10, 13, 50165, 11, 12, 4020, 11, 13, 5843, // 10,13
+10, 13, 6104, 10, 14, 48314, 11, 13, 4505, 11, 14, 6613, // 10,14
+10, 14, 6659, 10, 15, 46532, 11, 14, 4971, 11, 15, 7374, // 10,15
+10, -1, 5169, 10, 0, 7599, 11, -1, 6970, 11, 0, 45798, // 11, 0
+10, 0, 4734, 10, 1, 6886, 11, 0, 6458, 11, 1, 47458, // 11, 1
+10, 1, 4290, 10, 2, 6176, 11, 1, 5920, 11, 2, 49150, // 11, 2
+10, 2, 3845, 10, 3, 5481, 11, 2, 5365, 11, 3, 50845, // 11, 3
+10, 3, 3415, 10, 4, 4822, 11, 3, 4816, 11, 4, 52483, // 11, 4
+10, 4, 3023, 10, 5, 4230, 11, 4, 4309, 11, 5, 53974, // 11, 5
+10, 5, 2711, 10, 6, 3759, 11, 5, 3902, 11, 6, 55164, // 11, 6
+10, 6, 2525, 10, 7, 3473, 11, 6, 3671, 11, 7, 55867, // 11, 7
+11, 7, 3672, 11, 8, 55870, 12, 7, 2524, 12, 8, 3470, // 11, 8
+11, 8, 3904, 11, 9, 55166, 12, 8, 2710, 12, 9, 3756, // 11, 9
+11, 9, 4313, 11, 10, 53975, 12, 9, 3023, 12, 10, 4225, // 11,10
+11, 10, 4822, 11, 11, 52484, 12, 10, 3415, 12, 11, 4815, // 11,11
+11, 11, 5373, 11, 12, 50843, 12, 11, 3846, 12, 12, 5474, // 11,12
+11, 12, 5930, 11, 13, 49147, 12, 12, 4291, 12, 13, 6168, // 11,13
+11, 13, 6472, 11, 14, 47453, 12, 13, 4736, 12, 14, 6875, // 11,14
+11, 14, 6986, 11, 15, 45791, 12, 14, 5172, 12, 15, 7587, // 11,15
+11, -1, 5410, 11, 0, 7863, 12, -1, 7356, 12, 0, 44907, // 12, 0
+11, 0, 5009, 11, 1, 7204, 12, 0, 6892, 12, 1, 46431, // 12, 1
+11, 1, 4607, 11, 2, 6560, 12, 1, 6414, 12, 2, 47955, // 12, 2
+11, 2, 4214, 11, 3, 5943, 12, 2, 5934, 12, 3, 49445, // 12, 3
+11, 3, 3846, 11, 4, 5373, 12, 3, 5474, 12, 4, 50843, // 12, 4
+11, 4, 3523, 11, 5, 4879, 12, 4, 5069, 12, 5, 52065, // 12, 5
+11, 5, 3274, 11, 6, 4495, 12, 5, 4759, 12, 6, 53008, // 12, 6
+11, 6, 3128, 11, 7, 4259, 12, 6, 4592, 12, 7, 53557, // 12, 7
+12, 7, 4594, 12, 8, 53562, 13, 7, 3126, 13, 8, 4254, // 12, 8
+12, 8, 4762, 12, 9, 53012, 13, 8, 3273, 13, 9, 4489, // 12, 9
+12, 9, 5073, 12, 10, 52069, 13, 9, 3522, 13, 10, 4872, // 12,10
+12, 10, 5481, 12, 11, 50844, 13, 10, 3845, 13, 11, 5366, // 12,11
+12, 11, 5943, 12, 12, 49445, 13, 11, 4214, 13, 12, 5934, // 12,12
+12, 12, 6426, 12, 13, 47953, 13, 12, 4608, 13, 13, 6549, // 12,13
+12, 13, 6908, 12, 14, 46427, 13, 13, 5011, 13, 14, 7190, // 12,14
+12, 14, 7374, 12, 15, 44901, 13, 14, 5413, 13, 15, 7848, // 12,15
+12, -1, 5682, 12, 0, 8159, 13, -1, 7791, 13, 0, 43904, // 13, 0
+12, 0, 5315, 12, 1, 7555, 13, 0, 7378, 13, 1, 45288, // 13, 1
+12, 1, 4954, 12, 2, 6973, 13, 1, 6959, 13, 2, 46650, // 13, 2
+12, 2, 4608, 12, 3, 6426, 13, 2, 6549, 13, 3, 47953, // 13, 3
+12, 3, 4291, 12, 4, 5930, 13, 3, 6168, 13, 4, 49147, // 13, 4
+12, 4, 4020, 12, 5, 5508, 13, 4, 5842, 13, 5, 50166, // 13, 5
+12, 5, 3815, 12, 6, 5184, 13, 5, 5602, 13, 6, 50935, // 13, 6
+12, 6, 3693, 12, 7, 4978, 13, 6, 5478, 13, 7, 51387, // 13, 7
+13, 7, 5480, 13, 8, 51395, 14, 7, 3691, 14, 8, 4970, // 13, 8
+13, 8, 5606, 13, 9, 50942, 14, 8, 3813, 14, 9, 5175, // 13, 9
+13, 9, 5848, 13, 10, 50171, 14, 9, 4019, 14, 10, 5498, // 13,10
+13, 10, 6176, 13, 11, 49150, 14, 10, 4290, 14, 11, 5920, // 13,11
+13, 11, 6560, 13, 12, 47955, 14, 11, 4607, 14, 12, 6414, // 13,12
+13, 12, 6973, 13, 13, 46650, 14, 12, 4954, 14, 13, 6959, // 13,13
+13, 13, 7395, 13, 14, 45286, 14, 13, 5316, 14, 14, 7539, // 13,14
+13, 14, 7812, 13, 15, 43900, 14, 14, 5684, 14, 15, 8140, // 13,15
+13, -1, 5974, 13, 0, 8474, 14, -1, 8265, 14, 0, 42823, // 14, 0
+13, 0, 5640, 13, 1, 7921, 14, 0, 7901, 14, 1, 44074, // 14, 1
+13, 1, 5316, 13, 2, 7395, 14, 1, 7539, 14, 2, 45286, // 14, 2
+13, 2, 5011, 13, 3, 6908, 14, 2, 7191, 14, 3, 46426, // 14, 3
+13, 3, 4736, 13, 4, 6472, 14, 3, 6875, 14, 4, 47453, // 14, 4
+13, 4, 4505, 13, 5, 6104, 14, 4, 6613, 14, 5, 48314, // 14, 5
+13, 5, 4330, 13, 6, 5820, 14, 5, 6425, 14, 6, 48961, // 14, 6
+13, 6, 4224, 13, 7, 5633, 14, 6, 6332, 14, 7, 49347, // 14, 7
+14, 7, 6335, 14, 8, 49358, 15, 7, 4221, 15, 8, 5622, // 14, 8
+14, 8, 6430, 14, 9, 48969, 15, 8, 4327, 15, 9, 5810, // 14, 9
+14, 9, 6620, 14, 10, 48322, 15, 9, 4502, 15, 10, 6092, // 14,10
+14, 10, 6886, 14, 11, 47458, 15, 10, 4734, 15, 11, 6458, // 14,11
+14, 11, 7204, 14, 12, 46430, 15, 11, 5009, 15, 12, 6893, // 14,12
+14, 12, 7555, 14, 13, 45288, 15, 12, 5315, 15, 13, 7378, // 14,13
+14, 13, 7921, 14, 14, 44074, 15, 13, 5640, 15, 14, 7901, // 14,14
+14, 14, 8288, 14, 15, 42821, 15, 14, 5975, 15, 15, 8452, // 14,15
+14, -1, 6280, 14, 0, 8795, 15, -1, 8769, 15, 0, 41692, // 15, 0
+14, 0, 5975, 14, 1, 8288, 15, 0, 8452, 15, 1, 42821, // 15, 1
+14, 1, 5684, 14, 2, 7812, 15, 1, 8141, 15, 2, 43899, // 15, 2
+14, 2, 5413, 14, 3, 7374, 15, 2, 7848, 15, 3, 44901, // 15, 3
+14, 3, 5172, 14, 4, 6986, 15, 3, 7587, 15, 4, 45791, // 15, 4
+14, 4, 4971, 14, 5, 6659, 15, 4, 7374, 15, 5, 46532, // 15, 5
+14, 5, 4818, 14, 6, 6405, 15, 5, 7227, 15, 6, 47086, // 15, 6
+14, 6, 4722, 14, 7, 6230, 15, 6, 7158, 15, 7, 47426, // 15, 7
+15, 7, 7161, 15, 8, 47440, 16, 7, 4718, 16, 8, 6217, // 15, 8
+15, 8, 7233, 15, 9, 47098, 16, 8, 4814, 16, 9, 6391, // 15, 9
+15, 9, 7383, 15, 10, 46541, 16, 9, 4967, 16, 10, 6645, // 15,10
+15, 10, 7599, 15, 11, 45799, 16, 10, 5169, 16, 11, 6969, // 15,11
+15, 11, 7863, 15, 12, 44907, 16, 11, 5410, 16, 12, 7356, // 15,12
+15, 12, 8159, 15, 13, 43904, 16, 12, 5682, 16, 13, 7791, // 15,13
+15, 13, 8474, 15, 14, 42823, 16, 13, 5974, 16, 14, 8265, // 15,14
+15, 14, 8795, 15, 15, 41693, 16, 14, 6280, 16, 15, 8768, // 15,15
+// angle of -0.5 degrees
+-1, 0, 5106, -1, 1, 3621, 0, 0, 51699, 0, 1, 5110, // 0, 0
+-1, 1, 4803, -1, 2, 3421, 0, 1, 52457, 0, 2, 4855, // 0, 1
+-1, 2, 4521, -1, 3, 3235, 0, 2, 53168, 0, 3, 4612, // 0, 2
+-1, 3, 4264, -1, 4, 3064, 0, 3, 53815, 0, 4, 4393, // 0, 3
+-1, 4, 4041, -1, 5, 2916, 0, 4, 54378, 0, 5, 4201, // 0, 4
+-1, 5, 3858, -1, 6, 2796, 0, 5, 54835, 0, 6, 4047, // 0, 5
+-1, 6, 3722, -1, 7, 2709, 0, 6, 55166, 0, 7, 3939, // 0, 6
+-1, 7, 3638, -1, 8, 2659, 0, 7, 55354, 0, 8, 3885, // 0, 7
+0, 8, 55352, 0, 9, 3885, 1, 8, 3640, 1, 9, 2659, // 0, 8
+0, 9, 55164, 0, 10, 3939, 1, 9, 3724, 1, 10, 2709, // 0, 9
+0, 10, 54833, 0, 11, 4046, 1, 10, 3860, 1, 11, 2797, // 0,10
+0, 11, 54376, 0, 12, 4200, 1, 11, 4043, 1, 12, 2917, // 0,11
+0, 12, 53814, 0, 13, 4390, 1, 12, 4267, 1, 13, 3065, // 0,12
+0, 13, 53168, 0, 14, 4610, 1, 13, 4523, 1, 14, 3235, // 0,13
+0, 14, 52457, 0, 15, 4851, 1, 14, 4806, 1, 15, 3422, // 0,14
+0, 15, 51699, 0, 16, 5106, 1, 15, 5110, 1, 16, 3621, // 0,15
+0, 0, 4851, 0, 1, 3422, 1, 0, 52457, 1, 1, 4806, // 1, 0
+0, 1, 4522, 0, 2, 3204, 1, 1, 53285, 1, 2, 4525, // 1, 1
+0, 2, 4212, 0, 3, 2998, 1, 2, 54072, 1, 3, 4254, // 1, 2
+0, 3, 3927, 0, 4, 2808, 1, 3, 54796, 1, 4, 4005, // 1, 3
+0, 4, 3677, 0, 5, 2640, 1, 4, 55435, 1, 5, 3784, // 1, 4
+0, 5, 3470, 0, 6, 2502, 1, 5, 55959, 1, 6, 3605, // 1, 5
+0, 6, 3317, 0, 7, 2402, 1, 6, 56340, 1, 7, 3477, // 1, 6
+0, 7, 3225, 0, 8, 2346, 1, 7, 56554, 1, 8, 3411, // 1, 7
+1, 8, 56552, 1, 9, 3411, 2, 8, 3227, 2, 9, 2346, // 1, 8
+1, 9, 56339, 1, 10, 3476, 2, 9, 3319, 2, 10, 2402, // 1, 9
+1, 10, 55958, 1, 11, 3604, 2, 10, 3472, 2, 11, 2502, // 1,10
+1, 11, 55434, 1, 12, 3783, 2, 11, 3678, 2, 12, 2641, // 1,11
+1, 12, 54796, 1, 13, 4003, 2, 12, 3929, 2, 13, 2808, // 1,12
+1, 13, 54071, 1, 14, 4253, 2, 13, 4214, 2, 14, 2998, // 1,13
+1, 14, 53285, 1, 15, 4522, 2, 14, 4525, 2, 15, 3204, // 1,14
+1, 15, 52457, 1, 16, 4803, 2, 15, 4854, 2, 16, 3422, // 1,15
+1, 0, 4610, 1, 1, 3235, 2, 0, 53168, 2, 1, 4523, // 2, 0
+1, 1, 4253, 1, 2, 2998, 2, 1, 54071, 2, 2, 4214, // 2, 1
+1, 2, 3911, 1, 3, 2770, 2, 2, 54941, 2, 3, 3914, // 2, 2
+1, 3, 3594, 1, 4, 2556, 2, 3, 55756, 2, 4, 3630, // 2, 3
+1, 4, 3310, 1, 5, 2365, 2, 4, 56487, 2, 5, 3374, // 2, 4
+1, 5, 3073, 1, 6, 2205, 2, 5, 57096, 2, 6, 3162, // 2, 5
+1, 6, 2897, 1, 7, 2088, 2, 6, 57545, 2, 7, 3006, // 2, 6
+1, 7, 2794, 1, 8, 2022, 2, 7, 57795, 2, 8, 2925, // 2, 7
+2, 8, 57793, 2, 9, 2926, 3, 8, 2795, 3, 9, 2022, // 2, 8
+2, 9, 57544, 2, 10, 3007, 3, 9, 2898, 3, 10, 2087, // 2, 9
+2, 10, 57095, 2, 11, 3161, 3, 10, 3074, 3, 11, 2206, // 2,10
+2, 11, 56486, 2, 12, 3373, 3, 11, 3311, 3, 12, 2366, // 2,11
+2, 12, 55756, 2, 13, 3628, 3, 12, 3595, 3, 13, 2557, // 2,12
+2, 13, 54941, 2, 14, 3911, 3, 13, 3913, 3, 14, 2771, // 2,13
+2, 14, 54072, 2, 15, 4212, 3, 14, 4255, 3, 15, 2997, // 2,14
+2, 15, 53168, 2, 16, 4521, 3, 15, 4612, 3, 16, 3235, // 2,15
+2, 0, 4390, 2, 1, 3065, 3, 0, 53814, 3, 1, 4267, // 3, 0
+2, 1, 4003, 2, 2, 2808, 3, 1, 54796, 3, 2, 3929, // 3, 1
+2, 2, 3628, 2, 3, 2557, 3, 2, 55756, 3, 3, 3595, // 3, 2
+2, 3, 3273, 2, 4, 2317, 3, 3, 56673, 3, 4, 3273, // 3, 3
+2, 4, 2948, 2, 5, 2096, 3, 4, 57514, 3, 5, 2978, // 3, 4
+2, 5, 2672, 2, 6, 1908, 3, 5, 58234, 3, 6, 2722, // 3, 5
+2, 6, 2463, 2, 7, 1766, 3, 6, 58775, 3, 7, 2532, // 3, 6
+2, 7, 2342, 2, 8, 1687, 3, 7, 59077, 3, 8, 2430, // 3, 7
+3, 8, 59076, 3, 9, 2430, 4, 8, 2343, 4, 9, 1687, // 3, 8
+3, 9, 58774, 3, 10, 2532, 4, 9, 2464, 4, 10, 1766, // 3, 9
+3, 10, 58233, 3, 11, 2722, 4, 10, 2673, 4, 11, 1908, // 3,10
+3, 11, 57514, 3, 12, 2976, 4, 11, 2950, 4, 12, 2096, // 3,11
+3, 12, 56673, 3, 13, 3273, 4, 12, 3274, 4, 13, 2316, // 3,12
+3, 13, 55756, 3, 14, 3594, 4, 13, 3630, 4, 14, 2556, // 3,13
+3, 14, 54796, 3, 15, 3927, 4, 14, 4005, 4, 15, 2808, // 3,14
+3, 15, 53815, 3, 16, 4264, 4, 15, 4392, 4, 16, 3065, // 3,15
+3, 0, 4200, 3, 1, 2917, 4, 0, 54376, 4, 1, 4043, // 4, 0
+3, 1, 3783, 3, 2, 2640, 4, 1, 55434, 4, 2, 3679, // 4, 1
+3, 2, 3373, 3, 3, 2365, 4, 2, 56486, 4, 3, 3312, // 4, 2
+3, 3, 2976, 3, 4, 2096, 4, 3, 57514, 4, 4, 2950, // 4, 3
+3, 4, 2604, 3, 5, 1843, 4, 4, 58484, 4, 5, 2605, // 4, 4
+3, 5, 2276, 3, 6, 1617, 4, 5, 59346, 4, 6, 2297, // 4, 5
+3, 6, 2020, 3, 7, 1442, 4, 6, 60018, 4, 7, 2056, // 4, 6
+3, 7, 1871, 3, 8, 1341, 4, 7, 60402, 4, 8, 1922, // 4, 7
+4, 8, 60402, 4, 9, 1922, 5, 8, 1871, 5, 9, 1341, // 4, 8
+4, 9, 60017, 4, 10, 2057, 5, 9, 2020, 5, 10, 1442, // 4, 9
+4, 10, 59345, 4, 11, 2297, 5, 10, 2276, 5, 11, 1618, // 4,10
+4, 11, 58484, 4, 12, 2604, 5, 11, 2605, 5, 12, 1843, // 4,11
+4, 12, 57514, 4, 13, 2948, 5, 12, 2977, 5, 13, 2097, // 4,12
+4, 13, 56487, 4, 14, 3310, 5, 13, 3374, 5, 14, 2365, // 4,13
+4, 14, 55435, 4, 15, 3677, 5, 14, 3785, 5, 15, 2639, // 4,14
+4, 15, 54378, 4, 16, 4041, 5, 15, 4201, 5, 16, 2916, // 4,15
+4, 0, 4046, 4, 1, 2797, 5, 0, 54833, 5, 1, 3860, // 5, 0
+4, 1, 3604, 4, 2, 2503, 5, 1, 55958, 5, 2, 3471, // 5, 1
+4, 2, 3161, 4, 3, 2205, 5, 2, 57095, 5, 3, 3075, // 5, 2
+4, 3, 2722, 4, 4, 1908, 5, 3, 58233, 5, 4, 2673, // 5, 3
+4, 4, 2297, 4, 5, 1617, 5, 4, 59345, 5, 5, 2277, // 5, 4
+4, 5, 1904, 4, 6, 1347, 5, 5, 60381, 5, 6, 1904, // 5, 5
+4, 6, 1578, 4, 7, 1121, 5, 6, 61243, 5, 7, 1594, // 5, 6
+4, 7, 1380, 4, 8, 985, 5, 7, 61767, 5, 8, 1404, // 5, 7
+5, 8, 61767, 5, 9, 1405, 6, 8, 1380, 6, 9, 984, // 5, 8
+5, 9, 61243, 5, 10, 1593, 6, 9, 1579, 6, 10, 1121, // 5, 9
+5, 10, 60381, 5, 11, 1904, 6, 10, 1904, 6, 11, 1347, // 5,10
+5, 11, 59346, 5, 12, 2276, 6, 11, 2297, 6, 12, 1617, // 5,11
+5, 12, 58234, 5, 13, 2672, 6, 12, 2723, 6, 13, 1907, // 5,12
+5, 13, 57096, 5, 14, 3073, 6, 13, 3161, 6, 14, 2206, // 5,13
+5, 14, 55959, 5, 15, 3470, 6, 14, 3605, 6, 15, 2502, // 5,14
+5, 15, 54835, 5, 16, 3858, 6, 15, 4047, 6, 16, 2796, // 5,15
+5, 0, 3939, 5, 1, 2709, 6, 0, 55164, 6, 1, 3724, // 6, 0
+5, 1, 3476, 5, 2, 2403, 6, 1, 56339, 6, 2, 3318, // 6, 1
+5, 2, 3007, 5, 3, 2088, 6, 2, 57544, 6, 3, 2897, // 6, 2
+5, 3, 2532, 5, 4, 1767, 6, 3, 58774, 6, 4, 2463, // 6, 3
+5, 4, 2057, 5, 5, 1442, 6, 4, 60017, 6, 5, 2020, // 6, 4
+5, 5, 1593, 5, 6, 1121, 6, 5, 61243, 6, 6, 1579, // 6, 5
+5, 6, 1170, 5, 7, 827, 6, 6, 62369, 6, 7, 1170, // 6, 6
+5, 7, 875, 5, 8, 622, 6, 7, 63156, 6, 8, 883, // 6, 7
+6, 8, 63156, 6, 9, 883, 7, 8, 875, 7, 9, 622, // 6, 8
+6, 9, 62369, 6, 10, 1170, 7, 9, 1170, 7, 10, 827, // 6, 9
+6, 10, 61243, 6, 11, 1578, 7, 10, 1593, 7, 11, 1122, // 6,10
+6, 11, 60018, 6, 12, 2020, 7, 11, 2057, 7, 12, 1441, // 6,11
+6, 12, 58775, 6, 13, 2463, 7, 12, 2532, 7, 13, 1766, // 6,12
+6, 13, 57545, 6, 14, 2897, 7, 13, 3007, 7, 14, 2087, // 6,13
+6, 14, 56340, 6, 15, 3317, 7, 14, 3477, 7, 15, 2402, // 6,14
+6, 15, 55166, 6, 16, 3722, 7, 15, 3940, 7, 16, 2708, // 6,15
+6, 0, 3885, 6, 1, 2659, 7, 0, 55352, 7, 1, 3640, // 7, 0
+6, 1, 3411, 6, 2, 2346, 7, 1, 56552, 7, 2, 3227, // 7, 1
+6, 2, 2926, 6, 3, 2022, 7, 2, 57793, 7, 3, 2795, // 7, 2
+6, 3, 2430, 6, 4, 1687, 7, 3, 59076, 7, 4, 2343, // 7, 3
+6, 4, 1922, 6, 5, 1341, 7, 4, 60402, 7, 5, 1871, // 7, 4
+6, 5, 1405, 6, 6, 985, 7, 5, 61767, 7, 6, 1379, // 7, 5
+6, 6, 883, 6, 7, 622, 7, 6, 63156, 7, 7, 875, // 7, 6
+6, 7, 399, 6, 8, 282, 7, 7, 64455, 7, 8, 400, // 7, 7
+7, 8, 64455, 7, 9, 399, 8, 8, 399, 8, 9, 283, // 7, 8
+7, 9, 63156, 7, 10, 875, 8, 9, 883, 8, 10, 622, // 7, 9
+7, 10, 61767, 7, 11, 1380, 8, 10, 1405, 8, 11, 984, // 7,10
+7, 11, 60402, 7, 12, 1871, 8, 11, 1922, 8, 12, 1341, // 7,11
+7, 12, 59077, 7, 13, 2342, 8, 12, 2430, 8, 13, 1687, // 7,12
+7, 13, 57795, 7, 14, 2794, 8, 13, 2926, 8, 14, 2021, // 7,13
+7, 14, 56554, 7, 15, 3225, 8, 14, 3411, 8, 15, 2346, // 7,14
+7, 15, 55354, 7, 16, 3638, 8, 15, 3885, 8, 16, 2659, // 7,15
+7, -1, 2659, 7, 0, 3885, 8, -1, 3638, 8, 0, 55354, // 8, 0
+7, 0, 2346, 7, 1, 3411, 8, 0, 3225, 8, 1, 56554, // 8, 1
+7, 1, 2022, 7, 2, 2926, 8, 1, 2794, 8, 2, 57794, // 8, 2
+7, 2, 1687, 7, 3, 2430, 8, 2, 2342, 8, 3, 59077, // 8, 3
+7, 3, 1341, 7, 4, 1922, 8, 3, 1871, 8, 4, 60402, // 8, 4
+7, 4, 985, 7, 5, 1405, 8, 4, 1380, 8, 5, 61766, // 8, 5
+7, 5, 622, 7, 6, 883, 8, 5, 875, 8, 6, 63156, // 8, 6
+7, 6, 282, 7, 7, 399, 8, 6, 399, 8, 7, 64456, // 8, 7
+8, 7, 399, 8, 8, 64455, 9, 7, 282, 9, 8, 400, // 8, 8
+8, 8, 875, 8, 9, 63156, 9, 8, 622, 9, 9, 883, // 8, 9
+8, 9, 1380, 8, 10, 61767, 9, 9, 985, 9, 10, 1404, // 8,10
+8, 10, 1871, 8, 11, 60402, 9, 10, 1341, 9, 11, 1922, // 8,11
+8, 11, 2343, 8, 12, 59076, 9, 11, 1687, 9, 12, 2430, // 8,12
+8, 12, 2795, 8, 13, 57793, 9, 12, 2022, 9, 13, 2926, // 8,13
+8, 13, 3227, 8, 14, 56552, 9, 13, 2346, 9, 14, 3411, // 8,14
+8, 14, 3640, 8, 15, 55352, 9, 14, 2659, 9, 15, 3885, // 8,15
+8, -1, 2709, 8, 0, 3940, 9, -1, 3722, 9, 0, 55165, // 9, 0
+8, 0, 2402, 8, 1, 3477, 9, 0, 3317, 9, 1, 56340, // 9, 1
+8, 1, 2088, 8, 2, 3007, 9, 1, 2897, 9, 2, 57544, // 9, 2
+8, 2, 1766, 8, 3, 2532, 9, 2, 2463, 9, 3, 58775, // 9, 3
+8, 3, 1442, 8, 4, 2057, 9, 3, 2020, 9, 4, 60017, // 9, 4
+8, 4, 1121, 8, 5, 1593, 9, 4, 1578, 9, 5, 61244, // 9, 5
+8, 5, 827, 8, 6, 1170, 9, 5, 1170, 9, 6, 62369, // 9, 6
+8, 6, 622, 8, 7, 875, 9, 6, 883, 9, 7, 63156, // 9, 7
+9, 7, 883, 9, 8, 63156, 10, 7, 622, 10, 8, 875, // 9, 8
+9, 8, 1170, 9, 9, 62369, 10, 8, 827, 10, 9, 1170, // 9, 9
+9, 9, 1579, 9, 10, 61243, 10, 9, 1121, 10, 10, 1593, // 9,10
+9, 10, 2020, 9, 11, 60017, 10, 10, 1442, 10, 11, 2057, // 9,11
+9, 11, 2464, 9, 12, 58774, 10, 11, 1767, 10, 12, 2531, // 9,12
+9, 12, 2898, 9, 13, 57544, 10, 12, 2088, 10, 13, 3006, // 9,13
+9, 13, 3319, 9, 14, 56339, 10, 13, 2403, 10, 14, 3475, // 9,14
+9, 14, 3724, 9, 15, 55164, 10, 14, 2709, 10, 15, 3939, // 9,15
+9, -1, 2796, 9, 0, 4047, 10, -1, 3858, 10, 0, 54835, // 10, 0
+9, 0, 2502, 9, 1, 3605, 10, 0, 3470, 10, 1, 55959, // 10, 1
+9, 1, 2205, 9, 2, 3161, 10, 1, 3073, 10, 2, 57097, // 10, 2
+9, 2, 1908, 9, 3, 2723, 10, 2, 2672, 10, 3, 58233, // 10, 3
+9, 3, 1617, 9, 4, 2297, 10, 3, 2276, 10, 4, 59346, // 10, 4
+9, 4, 1347, 9, 5, 1904, 10, 4, 1904, 10, 5, 60381, // 10, 5
+9, 5, 1121, 9, 6, 1579, 10, 5, 1593, 10, 6, 61243, // 10, 6
+9, 6, 985, 9, 7, 1380, 10, 6, 1405, 10, 7, 61766, // 10, 7
+10, 7, 1405, 10, 8, 61767, 11, 7, 985, 11, 8, 1379, // 10, 8
+10, 8, 1593, 10, 9, 61243, 11, 8, 1121, 11, 9, 1579, // 10, 9
+10, 9, 1904, 10, 10, 60381, 11, 9, 1347, 11, 10, 1904, // 10,10
+10, 10, 2276, 10, 11, 59345, 11, 10, 1617, 11, 11, 2298, // 10,11
+10, 11, 2673, 10, 12, 58233, 11, 11, 1908, 11, 12, 2722, // 10,12
+10, 12, 3074, 10, 13, 57095, 11, 12, 2205, 11, 13, 3162, // 10,13
+10, 13, 3472, 10, 14, 55958, 11, 13, 2503, 11, 14, 3603, // 10,14
+10, 14, 3860, 10, 15, 54833, 11, 14, 2797, 11, 15, 4046, // 10,15
+10, -1, 2916, 10, 0, 4201, 11, -1, 4041, 11, 0, 54378, // 11, 0
+10, 0, 2640, 10, 1, 3785, 11, 0, 3677, 11, 1, 55434, // 11, 1
+10, 1, 2365, 10, 2, 3374, 11, 1, 3310, 11, 2, 56487, // 11, 2
+10, 2, 2096, 10, 3, 2977, 11, 2, 2948, 11, 3, 57515, // 11, 3
+10, 3, 1843, 10, 4, 2605, 11, 3, 2604, 11, 4, 58484, // 11, 4
+10, 4, 1617, 10, 5, 2276, 11, 4, 2297, 11, 5, 59346, // 11, 5
+10, 5, 1442, 10, 6, 2020, 11, 5, 2057, 11, 6, 60017, // 11, 6
+10, 6, 1341, 10, 7, 1871, 11, 6, 1922, 11, 7, 60402, // 11, 7
+11, 7, 1922, 11, 8, 60402, 12, 7, 1341, 12, 8, 1871, // 11, 8
+11, 8, 2057, 11, 9, 60018, 12, 8, 1442, 12, 9, 2019, // 11, 9
+11, 9, 2297, 11, 10, 59346, 12, 9, 1617, 12, 10, 2276, // 11,10
+11, 10, 2605, 11, 11, 58484, 12, 10, 1843, 12, 11, 2604, // 11,11
+11, 11, 2950, 11, 12, 57514, 12, 11, 2096, 12, 12, 2976, // 11,12
+11, 12, 3311, 11, 13, 56486, 12, 12, 2365, 12, 13, 3374, // 11,13
+11, 13, 3678, 11, 14, 55434, 12, 13, 2640, 12, 14, 3784, // 11,14
+11, 14, 4043, 11, 15, 54376, 12, 14, 2917, 12, 15, 4200, // 11,15
+11, -1, 3064, 11, 0, 4392, 12, -1, 4264, 12, 0, 53816, // 12, 0
+11, 0, 2808, 11, 1, 4005, 12, 0, 3927, 12, 1, 54796, // 12, 1
+11, 1, 2556, 11, 2, 3630, 12, 1, 3594, 12, 2, 55756, // 12, 2
+11, 2, 2317, 11, 3, 3274, 12, 2, 3273, 12, 3, 56672, // 12, 3
+11, 3, 2096, 11, 4, 2950, 12, 3, 2976, 12, 4, 57514, // 12, 4
+11, 4, 1908, 11, 5, 2673, 12, 4, 2722, 12, 5, 58233, // 12, 5
+11, 5, 1767, 11, 6, 2464, 12, 5, 2532, 12, 6, 58773, // 12, 6
+11, 6, 1687, 11, 7, 2343, 12, 6, 2430, 12, 7, 59076, // 12, 7
+12, 7, 2430, 12, 8, 59077, 13, 7, 1687, 13, 8, 2342, // 12, 8
+12, 8, 2532, 12, 9, 58775, 13, 8, 1766, 13, 9, 2463, // 12, 9
+12, 9, 2723, 12, 10, 58234, 13, 9, 1908, 13, 10, 2671, // 12,10
+12, 10, 2977, 12, 11, 57514, 13, 10, 2096, 13, 11, 2949, // 12,11
+12, 11, 3274, 12, 12, 56673, 13, 11, 2317, 13, 12, 3272, // 12,12
+12, 12, 3595, 12, 13, 55756, 13, 12, 2557, 13, 13, 3628, // 12,13
+12, 13, 3929, 12, 14, 54796, 13, 13, 2808, 13, 14, 4003, // 12,14
+12, 14, 4267, 12, 15, 53814, 13, 14, 3065, 13, 15, 4390, // 12,15
+12, -1, 3235, 12, 0, 4612, 13, -1, 4521, 13, 0, 53168, // 13, 0
+12, 0, 2998, 12, 1, 4255, 13, 0, 4212, 13, 1, 54071, // 13, 1
+12, 1, 2770, 12, 2, 3913, 13, 1, 3911, 13, 2, 54942, // 13, 2
+12, 2, 2557, 12, 3, 3595, 13, 2, 3628, 13, 3, 55756, // 13, 3
+12, 3, 2365, 12, 4, 3311, 13, 3, 3373, 13, 4, 56487, // 13, 4
+12, 4, 2205, 12, 5, 3074, 13, 4, 3161, 13, 5, 57096, // 13, 5
+12, 5, 2088, 12, 6, 2898, 13, 5, 3007, 13, 6, 57543, // 13, 6
+12, 6, 2022, 12, 7, 2795, 13, 6, 2926, 13, 7, 57793, // 13, 7
+13, 7, 2926, 13, 8, 57795, 14, 7, 2022, 14, 8, 2793, // 13, 8
+13, 8, 3007, 13, 9, 57545, 14, 8, 2088, 14, 9, 2896, // 13, 9
+13, 9, 3161, 13, 10, 57096, 14, 9, 2205, 14, 10, 3074, // 13,10
+13, 10, 3374, 13, 11, 56487, 14, 10, 2365, 14, 11, 3310, // 13,11
+13, 11, 3630, 13, 12, 55756, 14, 11, 2556, 14, 12, 3594, // 13,12
+13, 12, 3913, 13, 13, 54941, 14, 12, 2770, 14, 13, 3912, // 13,13
+13, 13, 4214, 13, 14, 54071, 14, 13, 2998, 14, 14, 4253, // 13,14
+13, 14, 4523, 13, 15, 53168, 14, 14, 3235, 14, 15, 4610, // 13,15
+13, -1, 3421, 13, 0, 4854, 14, -1, 4803, 14, 0, 52458, // 14, 0
+13, 0, 3204, 13, 1, 4525, 14, 0, 4522, 14, 1, 53285, // 14, 1
+13, 1, 2998, 13, 2, 4214, 14, 1, 4253, 14, 2, 54071, // 14, 2
+13, 2, 2808, 13, 3, 3929, 14, 2, 4003, 14, 3, 54796, // 14, 3
+13, 3, 2640, 13, 4, 3678, 14, 3, 3783, 14, 4, 55435, // 14, 4
+13, 4, 2503, 13, 5, 3472, 14, 4, 3604, 14, 5, 55957, // 14, 5
+13, 5, 2403, 13, 6, 3319, 14, 5, 3476, 14, 6, 56338, // 14, 6
+13, 6, 2346, 13, 7, 3227, 14, 6, 3411, 14, 7, 56552, // 14, 7
+14, 7, 3411, 14, 8, 56554, 15, 7, 2346, 15, 8, 3225, // 14, 8
+14, 8, 3477, 14, 9, 56340, 15, 8, 2402, 15, 9, 3317, // 14, 9
+14, 9, 3605, 14, 10, 55959, 15, 9, 2502, 15, 10, 3470, // 14,10
+14, 10, 3785, 14, 11, 55435, 15, 10, 2640, 15, 11, 3676, // 14,11
+14, 11, 4005, 14, 12, 54796, 15, 11, 2808, 15, 12, 3927, // 14,12
+14, 12, 4255, 14, 13, 54072, 15, 12, 2998, 15, 13, 4211, // 14,13
+14, 13, 4525, 14, 14, 53285, 15, 13, 3204, 15, 14, 4522, // 14,14
+14, 14, 4806, 14, 15, 52457, 15, 14, 3422, 15, 15, 4851, // 14,15
+14, -1, 3621, 14, 0, 5110, 15, -1, 5106, 15, 0, 51699, // 15, 0
+14, 0, 3422, 14, 1, 4806, 15, 0, 4851, 15, 1, 52457, // 15, 1
+14, 1, 3235, 14, 2, 4523, 15, 1, 4610, 15, 2, 53168, // 15, 2
+14, 2, 3065, 14, 3, 4267, 15, 2, 4390, 15, 3, 53814, // 15, 3
+14, 3, 2917, 14, 4, 4043, 15, 3, 4200, 15, 4, 54376, // 15, 4
+14, 4, 2797, 14, 5, 3860, 15, 4, 4046, 15, 5, 54833, // 15, 5
+14, 5, 2709, 14, 6, 3724, 15, 5, 3939, 15, 6, 55164, // 15, 6
+14, 6, 2659, 14, 7, 3640, 15, 6, 3885, 15, 7, 55352, // 15, 7
+15, 7, 3885, 15, 8, 55354, 16, 7, 2659, 16, 8, 3638, // 15, 8
+15, 8, 3940, 15, 9, 55166, 16, 8, 2709, 16, 9, 3721, // 15, 9
+15, 9, 4047, 15, 10, 54835, 16, 9, 2796, 16, 10, 3858, // 15,10
+15, 10, 4201, 15, 11, 54378, 16, 10, 2916, 16, 11, 4041, // 15,11
+15, 11, 4392, 15, 12, 53815, 16, 11, 3064, 16, 12, 4265, // 15,12
+15, 12, 4612, 15, 13, 53168, 16, 12, 3235, 16, 13, 4521, // 15,13
+15, 13, 4854, 15, 14, 52457, 16, 13, 3421, 16, 14, 4804, // 15,14
+15, 14, 5110, 15, 15, 51699, 16, 14, 3621, 16, 15, 5106, // 15,15
+// angle of 0.0 degrees
+0, 0, 16384, 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, // 0, 0
+0, 1, 16384, 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, // 0, 1
+0, 2, 16384, 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, // 0, 2
+0, 3, 16384, 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, // 0, 3
+0, 4, 16384, 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, // 0, 4
+0, 5, 16384, 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, // 0, 5
+0, 6, 16384, 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, // 0, 6
+0, 7, 16384, 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, // 0, 7
+0, 8, 16384, 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, // 0, 8
+0, 9, 16384, 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, // 0, 9
+0, 10, 16384, 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, // 0,10
+0, 11, 16384, 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, // 0,11
+0, 12, 16384, 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, // 0,12
+0, 13, 16384, 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, // 0,13
+0, 14, 16384, 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, // 0,14
+0, 15, 16384, 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, // 0,15
+1, 0, 16384, 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, // 1, 0
+1, 1, 16384, 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, // 1, 1
+1, 2, 16384, 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, // 1, 2
+1, 3, 16384, 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, // 1, 3
+1, 4, 16384, 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, // 1, 4
+1, 5, 16384, 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, // 1, 5
+1, 6, 16384, 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, // 1, 6
+1, 7, 16384, 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, // 1, 7
+1, 8, 16384, 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, // 1, 8
+1, 9, 16384, 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, // 1, 9
+1, 10, 16384, 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, // 1,10
+1, 11, 16384, 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, // 1,11
+1, 12, 16384, 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, // 1,12
+1, 13, 16384, 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, // 1,13
+1, 14, 16384, 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, // 1,14
+1, 15, 16384, 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, // 1,15
+2, 0, 16384, 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, // 2, 0
+2, 1, 16384, 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, // 2, 1
+2, 2, 16384, 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, // 2, 2
+2, 3, 16384, 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, // 2, 3
+2, 4, 16384, 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, // 2, 4
+2, 5, 16384, 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, // 2, 5
+2, 6, 16384, 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, // 2, 6
+2, 7, 16384, 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, // 2, 7
+2, 8, 16384, 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, // 2, 8
+2, 9, 16384, 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, // 2, 9
+2, 10, 16384, 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, // 2,10
+2, 11, 16384, 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, // 2,11
+2, 12, 16384, 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, // 2,12
+2, 13, 16384, 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, // 2,13
+2, 14, 16384, 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, // 2,14
+2, 15, 16384, 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, // 2,15
+3, 0, 16384, 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, // 3, 0
+3, 1, 16384, 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, // 3, 1
+3, 2, 16384, 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, // 3, 2
+3, 3, 16384, 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, // 3, 3
+3, 4, 16384, 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, // 3, 4
+3, 5, 16384, 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, // 3, 5
+3, 6, 16384, 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, // 3, 6
+3, 7, 16384, 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, // 3, 7
+3, 8, 16384, 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, // 3, 8
+3, 9, 16384, 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, // 3, 9
+3, 10, 16384, 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, // 3,10
+3, 11, 16384, 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, // 3,11
+3, 12, 16384, 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, // 3,12
+3, 13, 16384, 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, // 3,13
+3, 14, 16384, 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, // 3,14
+3, 15, 16384, 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, // 3,15
+4, 0, 16384, 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, // 4, 0
+4, 1, 16384, 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, // 4, 1
+4, 2, 16384, 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, // 4, 2
+4, 3, 16384, 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, // 4, 3
+4, 4, 16384, 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, // 4, 4
+4, 5, 16384, 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, // 4, 5
+4, 6, 16384, 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, // 4, 6
+4, 7, 16384, 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, // 4, 7
+4, 8, 16384, 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, // 4, 8
+4, 9, 16384, 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, // 4, 9
+4, 10, 16384, 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, // 4,10
+4, 11, 16384, 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, // 4,11
+4, 12, 16384, 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, // 4,12
+4, 13, 16384, 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, // 4,13
+4, 14, 16384, 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, // 4,14
+4, 15, 16384, 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, // 4,15
+5, 0, 16384, 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, // 5, 0
+5, 1, 16384, 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, // 5, 1
+5, 2, 16384, 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, // 5, 2
+5, 3, 16384, 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, // 5, 3
+5, 4, 16384, 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, // 5, 4
+5, 5, 16384, 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, // 5, 5
+5, 6, 16384, 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, // 5, 6
+5, 7, 16384, 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, // 5, 7
+5, 8, 16384, 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, // 5, 8
+5, 9, 16384, 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, // 5, 9
+5, 10, 16384, 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, // 5,10
+5, 11, 16384, 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, // 5,11
+5, 12, 16384, 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, // 5,12
+5, 13, 16384, 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, // 5,13
+5, 14, 16384, 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, // 5,14
+5, 15, 16384, 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, // 5,15
+6, 0, 16384, 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, // 6, 0
+6, 1, 16384, 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, // 6, 1
+6, 2, 16384, 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, // 6, 2
+6, 3, 16384, 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, // 6, 3
+6, 4, 16384, 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, // 6, 4
+6, 5, 16384, 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, // 6, 5
+6, 6, 16384, 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, // 6, 6
+6, 7, 16384, 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, // 6, 7
+6, 8, 16384, 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, // 6, 8
+6, 9, 16384, 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, // 6, 9
+6, 10, 16384, 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, // 6,10
+6, 11, 16384, 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, // 6,11
+6, 12, 16384, 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, // 6,12
+6, 13, 16384, 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, // 6,13
+6, 14, 16384, 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, // 6,14
+6, 15, 16384, 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, // 6,15
+7, 0, 16384, 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, // 7, 0
+7, 1, 16384, 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, // 7, 1
+7, 2, 16384, 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, // 7, 2
+7, 3, 16384, 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, // 7, 3
+7, 4, 16384, 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, // 7, 4
+7, 5, 16384, 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, // 7, 5
+7, 6, 16384, 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, // 7, 6
+7, 7, 16384, 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, // 7, 7
+7, 8, 16384, 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, // 7, 8
+7, 9, 16384, 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, // 7, 9
+7, 10, 16384, 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, // 7,10
+7, 11, 16384, 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, // 7,11
+7, 12, 16384, 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, // 7,12
+7, 13, 16384, 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, // 7,13
+7, 14, 16384, 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, // 7,14
+7, 15, 16384, 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, // 7,15
+8, 0, 16384, 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, // 8, 0
+8, 1, 16384, 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, // 8, 1
+8, 2, 16384, 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, // 8, 2
+8, 3, 16384, 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, // 8, 3
+8, 4, 16384, 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, // 8, 4
+8, 5, 16384, 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, // 8, 5
+8, 6, 16384, 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, // 8, 6
+8, 7, 16384, 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, // 8, 7
+8, 8, 16384, 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, // 8, 8
+8, 9, 16384, 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, // 8, 9
+8, 10, 16384, 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, // 8,10
+8, 11, 16384, 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, // 8,11
+8, 12, 16384, 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, // 8,12
+8, 13, 16384, 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, // 8,13
+8, 14, 16384, 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, // 8,14
+8, 15, 16384, 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, // 8,15
+9, 0, 16384, 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, // 9, 0
+9, 1, 16384, 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, // 9, 1
+9, 2, 16384, 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, // 9, 2
+9, 3, 16384, 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, // 9, 3
+9, 4, 16384, 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, // 9, 4
+9, 5, 16384, 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, // 9, 5
+9, 6, 16384, 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, // 9, 6
+9, 7, 16384, 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, // 9, 7
+9, 8, 16384, 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, // 9, 8
+9, 9, 16384, 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, // 9, 9
+9, 10, 16384, 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, // 9,10
+9, 11, 16384, 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, // 9,11
+9, 12, 16384, 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, // 9,12
+9, 13, 16384, 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, // 9,13
+9, 14, 16384, 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, // 9,14
+9, 15, 16384, 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, // 9,15
+10, 0, 16384, 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, // 10, 0
+10, 1, 16384, 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, // 10, 1
+10, 2, 16384, 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, // 10, 2
+10, 3, 16384, 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, // 10, 3
+10, 4, 16384, 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, // 10, 4
+10, 5, 16384, 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, // 10, 5
+10, 6, 16384, 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, // 10, 6
+10, 7, 16384, 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, // 10, 7
+10, 8, 16384, 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, // 10, 8
+10, 9, 16384, 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, // 10, 9
+10, 10, 16384, 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, // 10,10
+10, 11, 16384, 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, // 10,11
+10, 12, 16384, 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, // 10,12
+10, 13, 16384, 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, // 10,13
+10, 14, 16384, 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, // 10,14
+10, 15, 16384, 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, // 10,15
+11, 0, 16384, 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, // 11, 0
+11, 1, 16384, 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, // 11, 1
+11, 2, 16384, 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, // 11, 2
+11, 3, 16384, 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, // 11, 3
+11, 4, 16384, 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, // 11, 4
+11, 5, 16384, 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, // 11, 5
+11, 6, 16384, 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, // 11, 6
+11, 7, 16384, 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, // 11, 7
+11, 8, 16384, 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, // 11, 8
+11, 9, 16384, 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, // 11, 9
+11, 10, 16384, 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, // 11,10
+11, 11, 16384, 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, // 11,11
+11, 12, 16384, 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, // 11,12
+11, 13, 16384, 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, // 11,13
+11, 14, 16384, 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, // 11,14
+11, 15, 16384, 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, // 11,15
+12, 0, 16384, 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, // 12, 0
+12, 1, 16384, 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, // 12, 1
+12, 2, 16384, 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, // 12, 2
+12, 3, 16384, 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, // 12, 3
+12, 4, 16384, 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, // 12, 4
+12, 5, 16384, 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, // 12, 5
+12, 6, 16384, 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, // 12, 6
+12, 7, 16384, 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, // 12, 7
+12, 8, 16384, 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, // 12, 8
+12, 9, 16384, 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, // 12, 9
+12, 10, 16384, 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, // 12,10
+12, 11, 16384, 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, // 12,11
+12, 12, 16384, 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, // 12,12
+12, 13, 16384, 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, // 12,13
+12, 14, 16384, 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, // 12,14
+12, 15, 16384, 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, // 12,15
+13, 0, 16384, 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, // 13, 0
+13, 1, 16384, 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, // 13, 1
+13, 2, 16384, 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, // 13, 2
+13, 3, 16384, 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, // 13, 3
+13, 4, 16384, 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, // 13, 4
+13, 5, 16384, 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, // 13, 5
+13, 6, 16384, 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, // 13, 6
+13, 7, 16384, 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, // 13, 7
+13, 8, 16384, 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, // 13, 8
+13, 9, 16384, 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, // 13, 9
+13, 10, 16384, 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, // 13,10
+13, 11, 16384, 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, // 13,11
+13, 12, 16384, 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, // 13,12
+13, 13, 16384, 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, // 13,13
+13, 14, 16384, 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, // 13,14
+13, 15, 16384, 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, // 13,15
+14, 0, 16384, 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, // 14, 0
+14, 1, 16384, 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, // 14, 1
+14, 2, 16384, 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, // 14, 2
+14, 3, 16384, 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, // 14, 3
+14, 4, 16384, 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, // 14, 4
+14, 5, 16384, 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, // 14, 5
+14, 6, 16384, 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, // 14, 6
+14, 7, 16384, 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, // 14, 7
+14, 8, 16384, 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, // 14, 8
+14, 9, 16384, 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, // 14, 9
+14, 10, 16384, 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, // 14,10
+14, 11, 16384, 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, // 14,11
+14, 12, 16384, 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, // 14,12
+14, 13, 16384, 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, // 14,13
+14, 14, 16384, 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, // 14,14
+14, 15, 16384, 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, // 14,15
+15, 0, 16384, 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, // 15, 0
+15, 1, 16384, 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, // 15, 1
+15, 2, 16384, 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, // 15, 2
+15, 3, 16384, 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, // 15, 3
+15, 4, 16384, 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, // 15, 4
+15, 5, 16384, 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, // 15, 5
+15, 6, 16384, 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, // 15, 6
+15, 7, 16384, 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, // 15, 7
+15, 8, 16384, 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, // 15, 8
+15, 9, 16384, 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, // 15, 9
+15, 10, 16384, 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, // 15,10
+15, 11, 16384, 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, // 15,11
+15, 12, 16384, 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, // 15,12
+15, 13, 16384, 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, // 15,13
+15, 14, 16384, 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, // 15,14
+15, 15, 16384, 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, // 15,15
+// angle of 0.5 degrees
+0, -1, 5106, 0, 0, 51699, 1, -1, 3621, 1, 0, 5110, // 0, 0
+0, 0, 4851, 0, 1, 52457, 1, 0, 3422, 1, 1, 4806, // 0, 1
+0, 1, 4610, 0, 2, 53168, 1, 1, 3235, 1, 2, 4523, // 0, 2
+0, 2, 4390, 0, 3, 53814, 1, 2, 3065, 1, 3, 4267, // 0, 3
+0, 3, 4200, 0, 4, 54376, 1, 3, 2917, 1, 4, 4043, // 0, 4
+0, 4, 4046, 0, 5, 54833, 1, 4, 2797, 1, 5, 3860, // 0, 5
+0, 5, 3939, 0, 6, 55164, 1, 5, 2709, 1, 6, 3724, // 0, 6
+0, 6, 3885, 0, 7, 55352, 1, 6, 2659, 1, 7, 3640, // 0, 7
+-1, 7, 2659, -1, 8, 3638, 0, 7, 3885, 0, 8, 55354, // 0, 8
+-1, 8, 2709, -1, 9, 3722, 0, 8, 3940, 0, 9, 55165, // 0, 9
+-1, 9, 2796, -1, 10, 3858, 0, 9, 4047, 0, 10, 54835, // 0,10
+-1, 10, 2916, -1, 11, 4041, 0, 10, 4201, 0, 11, 54378, // 0,11
+-1, 11, 3064, -1, 12, 4264, 0, 11, 4392, 0, 12, 53816, // 0,12
+-1, 12, 3235, -1, 13, 4521, 0, 12, 4612, 0, 13, 53168, // 0,13
+-1, 13, 3421, -1, 14, 4803, 0, 13, 4854, 0, 14, 52458, // 0,14
+-1, 14, 3621, -1, 15, 5106, 0, 14, 5110, 0, 15, 51699, // 0,15
+1, -1, 4803, 1, 0, 52457, 2, -1, 3421, 2, 0, 4855, // 1, 0
+1, 0, 4522, 1, 1, 53285, 2, 0, 3204, 2, 1, 4525, // 1, 1
+1, 1, 4253, 1, 2, 54071, 2, 1, 2998, 2, 2, 4214, // 1, 2
+1, 2, 4003, 1, 3, 54796, 2, 2, 2808, 2, 3, 3929, // 1, 3
+1, 3, 3783, 1, 4, 55434, 2, 3, 2640, 2, 4, 3679, // 1, 4
+1, 4, 3604, 1, 5, 55958, 2, 4, 2503, 2, 5, 3471, // 1, 5
+1, 5, 3476, 1, 6, 56339, 2, 5, 2403, 2, 6, 3318, // 1, 6
+1, 6, 3411, 1, 7, 56552, 2, 6, 2346, 2, 7, 3227, // 1, 7
+0, 7, 2346, 0, 8, 3225, 1, 7, 3411, 1, 8, 56554, // 1, 8
+0, 8, 2402, 0, 9, 3317, 1, 8, 3477, 1, 9, 56340, // 1, 9
+0, 9, 2502, 0, 10, 3470, 1, 9, 3605, 1, 10, 55959, // 1,10
+0, 10, 2640, 0, 11, 3677, 1, 10, 3785, 1, 11, 55434, // 1,11
+0, 11, 2808, 0, 12, 3927, 1, 11, 4005, 1, 12, 54796, // 1,12
+0, 12, 2998, 0, 13, 4212, 1, 12, 4255, 1, 13, 54071, // 1,13
+0, 13, 3204, 0, 14, 4522, 1, 13, 4525, 1, 14, 53285, // 1,14
+0, 14, 3422, 0, 15, 4851, 1, 14, 4806, 1, 15, 52457, // 1,15
+2, -1, 4521, 2, 0, 53168, 3, -1, 3235, 3, 0, 4612, // 2, 0
+2, 0, 4212, 2, 1, 54072, 3, 0, 2998, 3, 1, 4254, // 2, 1
+2, 1, 3911, 2, 2, 54941, 3, 1, 2770, 3, 2, 3914, // 2, 2
+2, 2, 3628, 2, 3, 55756, 3, 2, 2557, 3, 3, 3595, // 2, 3
+2, 3, 3373, 2, 4, 56486, 3, 3, 2365, 3, 4, 3312, // 2, 4
+2, 4, 3161, 2, 5, 57095, 3, 4, 2205, 3, 5, 3075, // 2, 5
+2, 5, 3007, 2, 6, 57544, 3, 5, 2088, 3, 6, 2897, // 2, 6
+2, 6, 2926, 2, 7, 57793, 3, 6, 2022, 3, 7, 2795, // 2, 7
+1, 7, 2022, 1, 8, 2794, 2, 7, 2926, 2, 8, 57794, // 2, 8
+1, 8, 2088, 1, 9, 2897, 2, 8, 3007, 2, 9, 57544, // 2, 9
+1, 9, 2205, 1, 10, 3073, 2, 9, 3161, 2, 10, 57097, // 2,10
+1, 10, 2365, 1, 11, 3310, 2, 10, 3374, 2, 11, 56487, // 2,11
+1, 11, 2556, 1, 12, 3594, 2, 11, 3630, 2, 12, 55756, // 2,12
+1, 12, 2770, 1, 13, 3911, 2, 12, 3913, 2, 13, 54942, // 2,13
+1, 13, 2998, 1, 14, 4253, 2, 13, 4214, 2, 14, 54071, // 2,14
+1, 14, 3235, 1, 15, 4610, 2, 14, 4523, 2, 15, 53168, // 2,15
+3, -1, 4264, 3, 0, 53815, 4, -1, 3064, 4, 0, 4393, // 3, 0
+3, 0, 3927, 3, 1, 54796, 4, 0, 2808, 4, 1, 4005, // 3, 1
+3, 1, 3594, 3, 2, 55756, 4, 1, 2556, 4, 2, 3630, // 3, 2
+3, 2, 3273, 3, 3, 56673, 4, 2, 2317, 4, 3, 3273, // 3, 3
+3, 3, 2976, 3, 4, 57514, 4, 3, 2096, 4, 4, 2950, // 3, 4
+3, 4, 2722, 3, 5, 58233, 4, 4, 1908, 4, 5, 2673, // 3, 5
+3, 5, 2532, 3, 6, 58774, 4, 5, 1767, 4, 6, 2463, // 3, 6
+3, 6, 2430, 3, 7, 59076, 4, 6, 1687, 4, 7, 2343, // 3, 7
+2, 7, 1687, 2, 8, 2342, 3, 7, 2430, 3, 8, 59077, // 3, 8
+2, 8, 1766, 2, 9, 2463, 3, 8, 2532, 3, 9, 58775, // 3, 9
+2, 9, 1908, 2, 10, 2672, 3, 9, 2723, 3, 10, 58233, // 3,10
+2, 10, 2096, 2, 11, 2948, 3, 10, 2977, 3, 11, 57515, // 3,11
+2, 11, 2317, 2, 12, 3273, 3, 11, 3274, 3, 12, 56672, // 3,12
+2, 12, 2557, 2, 13, 3628, 3, 12, 3595, 3, 13, 55756, // 3,13
+2, 13, 2808, 2, 14, 4003, 3, 13, 3929, 3, 14, 54796, // 3,14
+2, 14, 3065, 2, 15, 4390, 3, 14, 4267, 3, 15, 53814, // 3,15
+4, -1, 4041, 4, 0, 54378, 5, -1, 2916, 5, 0, 4201, // 4, 0
+4, 0, 3677, 4, 1, 55435, 5, 0, 2640, 5, 1, 3784, // 4, 1
+4, 1, 3310, 4, 2, 56487, 5, 1, 2365, 5, 2, 3374, // 4, 2
+4, 2, 2948, 4, 3, 57514, 5, 2, 2096, 5, 3, 2978, // 4, 3
+4, 3, 2604, 4, 4, 58484, 5, 3, 1843, 5, 4, 2605, // 4, 4
+4, 4, 2297, 4, 5, 59345, 5, 4, 1617, 5, 5, 2277, // 4, 5
+4, 5, 2057, 4, 6, 60017, 5, 5, 1442, 5, 6, 2020, // 4, 6
+4, 6, 1922, 4, 7, 60402, 5, 6, 1341, 5, 7, 1871, // 4, 7
+3, 7, 1341, 3, 8, 1871, 4, 7, 1922, 4, 8, 60402, // 4, 8
+3, 8, 1442, 3, 9, 2020, 4, 8, 2057, 4, 9, 60017, // 4, 9
+3, 9, 1617, 3, 10, 2276, 4, 9, 2297, 4, 10, 59346, // 4,10
+3, 10, 1843, 3, 11, 2604, 4, 10, 2605, 4, 11, 58484, // 4,11
+3, 11, 2096, 3, 12, 2976, 4, 11, 2950, 4, 12, 57514, // 4,12
+3, 12, 2365, 3, 13, 3373, 4, 12, 3311, 4, 13, 56487, // 4,13
+3, 13, 2640, 3, 14, 3783, 4, 13, 3678, 4, 14, 55435, // 4,14
+3, 14, 2917, 3, 15, 4200, 4, 14, 4043, 4, 15, 54376, // 4,15
+5, -1, 3858, 5, 0, 54835, 6, -1, 2796, 6, 0, 4047, // 5, 0
+5, 0, 3470, 5, 1, 55959, 6, 0, 2502, 6, 1, 3605, // 5, 1
+5, 1, 3073, 5, 2, 57096, 6, 1, 2205, 6, 2, 3162, // 5, 2
+5, 2, 2672, 5, 3, 58234, 6, 2, 1908, 6, 3, 2722, // 5, 3
+5, 3, 2276, 5, 4, 59346, 6, 3, 1617, 6, 4, 2297, // 5, 4
+5, 4, 1904, 5, 5, 60381, 6, 4, 1347, 6, 5, 1904, // 5, 5
+5, 5, 1593, 5, 6, 61243, 6, 5, 1121, 6, 6, 1579, // 5, 6
+5, 6, 1405, 5, 7, 61767, 6, 6, 985, 6, 7, 1379, // 5, 7
+4, 7, 985, 4, 8, 1380, 5, 7, 1405, 5, 8, 61766, // 5, 8
+4, 8, 1121, 4, 9, 1578, 5, 8, 1593, 5, 9, 61244, // 5, 9
+4, 9, 1347, 4, 10, 1904, 5, 9, 1904, 5, 10, 60381, // 5,10
+4, 10, 1617, 4, 11, 2297, 5, 10, 2276, 5, 11, 59346, // 5,11
+4, 11, 1908, 4, 12, 2722, 5, 11, 2673, 5, 12, 58233, // 5,12
+4, 12, 2205, 4, 13, 3161, 5, 12, 3074, 5, 13, 57096, // 5,13
+4, 13, 2503, 4, 14, 3604, 5, 13, 3472, 5, 14, 55957, // 5,14
+4, 14, 2797, 4, 15, 4046, 5, 14, 3860, 5, 15, 54833, // 5,15
+6, -1, 3722, 6, 0, 55166, 7, -1, 2709, 7, 0, 3939, // 6, 0
+6, 0, 3317, 6, 1, 56340, 7, 0, 2402, 7, 1, 3477, // 6, 1
+6, 1, 2897, 6, 2, 57545, 7, 1, 2088, 7, 2, 3006, // 6, 2
+6, 2, 2463, 6, 3, 58775, 7, 2, 1766, 7, 3, 2532, // 6, 3
+6, 3, 2020, 6, 4, 60018, 7, 3, 1442, 7, 4, 2056, // 6, 4
+6, 4, 1578, 6, 5, 61243, 7, 4, 1121, 7, 5, 1594, // 6, 5
+6, 5, 1170, 6, 6, 62369, 7, 5, 827, 7, 6, 1170, // 6, 6
+6, 6, 883, 6, 7, 63156, 7, 6, 622, 7, 7, 875, // 6, 7
+5, 7, 622, 5, 8, 875, 6, 7, 883, 6, 8, 63156, // 6, 8
+5, 8, 827, 5, 9, 1170, 6, 8, 1170, 6, 9, 62369, // 6, 9
+5, 9, 1121, 5, 10, 1593, 6, 9, 1579, 6, 10, 61243, // 6,10
+5, 10, 1442, 5, 11, 2057, 6, 10, 2020, 6, 11, 60017, // 6,11
+5, 11, 1767, 5, 12, 2532, 6, 11, 2464, 6, 12, 58773, // 6,12
+5, 12, 2088, 5, 13, 3007, 6, 12, 2898, 6, 13, 57543, // 6,13
+5, 13, 2403, 5, 14, 3476, 6, 13, 3319, 6, 14, 56338, // 6,14
+5, 14, 2709, 5, 15, 3939, 6, 14, 3724, 6, 15, 55164, // 6,15
+7, -1, 3638, 7, 0, 55354, 8, -1, 2659, 8, 0, 3885, // 7, 0
+7, 0, 3225, 7, 1, 56554, 8, 0, 2346, 8, 1, 3411, // 7, 1
+7, 1, 2794, 7, 2, 57795, 8, 1, 2022, 8, 2, 2925, // 7, 2
+7, 2, 2342, 7, 3, 59077, 8, 2, 1687, 8, 3, 2430, // 7, 3
+7, 3, 1871, 7, 4, 60402, 8, 3, 1341, 8, 4, 1922, // 7, 4
+7, 4, 1380, 7, 5, 61767, 8, 4, 985, 8, 5, 1404, // 7, 5
+7, 5, 875, 7, 6, 63156, 8, 5, 622, 8, 6, 883, // 7, 6
+7, 6, 399, 7, 7, 64455, 8, 6, 282, 8, 7, 400, // 7, 7
+6, 7, 282, 6, 8, 399, 7, 7, 399, 7, 8, 64456, // 7, 8
+6, 8, 622, 6, 9, 883, 7, 8, 875, 7, 9, 63156, // 7, 9
+6, 9, 985, 6, 10, 1405, 7, 9, 1380, 7, 10, 61766, // 7,10
+6, 10, 1341, 6, 11, 1922, 7, 10, 1871, 7, 11, 60402, // 7,11
+6, 11, 1687, 6, 12, 2430, 7, 11, 2343, 7, 12, 59076, // 7,12
+6, 12, 2022, 6, 13, 2926, 7, 12, 2795, 7, 13, 57793, // 7,13
+6, 13, 2346, 6, 14, 3411, 7, 13, 3227, 7, 14, 56552, // 7,14
+6, 14, 2659, 6, 15, 3885, 7, 14, 3640, 7, 15, 55352, // 7,15
+8, 0, 55352, 8, 1, 3640, 9, 0, 3885, 9, 1, 2659, // 8, 0
+8, 1, 56552, 8, 2, 3227, 9, 1, 3411, 9, 2, 2346, // 8, 1
+8, 2, 57793, 8, 3, 2795, 9, 2, 2926, 9, 3, 2022, // 8, 2
+8, 3, 59076, 8, 4, 2343, 9, 3, 2430, 9, 4, 1687, // 8, 3
+8, 4, 60402, 8, 5, 1871, 9, 4, 1922, 9, 5, 1341, // 8, 4
+8, 5, 61767, 8, 6, 1380, 9, 5, 1405, 9, 6, 984, // 8, 5
+8, 6, 63156, 8, 7, 875, 9, 6, 883, 9, 7, 622, // 8, 6
+8, 7, 64455, 8, 8, 399, 9, 7, 399, 9, 8, 283, // 8, 7
+7, 8, 399, 7, 9, 282, 8, 8, 64455, 8, 9, 400, // 8, 8
+7, 9, 883, 7, 10, 622, 8, 9, 63156, 8, 10, 875, // 8, 9
+7, 10, 1405, 7, 11, 985, 8, 10, 61767, 8, 11, 1379, // 8,10
+7, 11, 1922, 7, 12, 1341, 8, 11, 60402, 8, 12, 1871, // 8,11
+7, 12, 2430, 7, 13, 1687, 8, 12, 59077, 8, 13, 2342, // 8,12
+7, 13, 2926, 7, 14, 2022, 8, 13, 57795, 8, 14, 2793, // 8,13
+7, 14, 3411, 7, 15, 2346, 8, 14, 56554, 8, 15, 3225, // 8,14
+7, 15, 3885, 7, 16, 2659, 8, 15, 55354, 8, 16, 3638, // 8,15
+9, 0, 55164, 9, 1, 3724, 10, 0, 3939, 10, 1, 2709, // 9, 0
+9, 1, 56339, 9, 2, 3319, 10, 1, 3476, 10, 2, 2402, // 9, 1
+9, 2, 57544, 9, 3, 2898, 10, 2, 3007, 10, 3, 2087, // 9, 2
+9, 3, 58774, 9, 4, 2464, 10, 3, 2532, 10, 4, 1766, // 9, 3
+9, 4, 60017, 9, 5, 2020, 10, 4, 2057, 10, 5, 1442, // 9, 4
+9, 5, 61243, 9, 6, 1579, 10, 5, 1593, 10, 6, 1121, // 9, 5
+9, 6, 62369, 9, 7, 1170, 10, 6, 1170, 10, 7, 827, // 9, 6
+9, 7, 63156, 9, 8, 883, 10, 7, 875, 10, 8, 622, // 9, 7
+8, 8, 875, 8, 9, 622, 9, 8, 63156, 9, 9, 883, // 9, 8
+8, 9, 1170, 8, 10, 827, 9, 9, 62369, 9, 10, 1170, // 9, 9
+8, 10, 1593, 8, 11, 1121, 9, 10, 61243, 9, 11, 1579, // 9,10
+8, 11, 2057, 8, 12, 1442, 9, 11, 60018, 9, 12, 2019, // 9,11
+8, 12, 2532, 8, 13, 1766, 9, 12, 58775, 9, 13, 2463, // 9,12
+8, 13, 3007, 8, 14, 2088, 9, 13, 57545, 9, 14, 2896, // 9,13
+8, 14, 3477, 8, 15, 2402, 9, 14, 56340, 9, 15, 3317, // 9,14
+8, 15, 3940, 8, 16, 2709, 9, 15, 55166, 9, 16, 3721, // 9,15
+10, 0, 54833, 10, 1, 3860, 11, 0, 4046, 11, 1, 2797, // 10, 0
+10, 1, 55958, 10, 2, 3472, 11, 1, 3604, 11, 2, 2502, // 10, 1
+10, 2, 57095, 10, 3, 3074, 11, 2, 3161, 11, 3, 2206, // 10, 2
+10, 3, 58233, 10, 4, 2673, 11, 3, 2722, 11, 4, 1908, // 10, 3
+10, 4, 59345, 10, 5, 2276, 11, 4, 2297, 11, 5, 1618, // 10, 4
+10, 5, 60381, 10, 6, 1904, 11, 5, 1904, 11, 6, 1347, // 10, 5
+10, 6, 61243, 10, 7, 1593, 11, 6, 1578, 11, 7, 1122, // 10, 6
+10, 7, 61767, 10, 8, 1405, 11, 7, 1380, 11, 8, 984, // 10, 7
+9, 8, 1380, 9, 9, 985, 10, 8, 61767, 10, 9, 1404, // 10, 8
+9, 9, 1579, 9, 10, 1121, 10, 9, 61243, 10, 10, 1593, // 10, 9
+9, 10, 1904, 9, 11, 1347, 10, 10, 60381, 10, 11, 1904, // 10,10
+9, 11, 2297, 9, 12, 1617, 10, 11, 59346, 10, 12, 2276, // 10,11
+9, 12, 2723, 9, 13, 1908, 10, 12, 58234, 10, 13, 2671, // 10,12
+9, 13, 3161, 9, 14, 2205, 10, 13, 57096, 10, 14, 3074, // 10,13
+9, 14, 3605, 9, 15, 2502, 10, 14, 55959, 10, 15, 3470, // 10,14
+9, 15, 4047, 9, 16, 2796, 10, 15, 54835, 10, 16, 3858, // 10,15
+11, 0, 54376, 11, 1, 4043, 12, 0, 4200, 12, 1, 2917, // 11, 0
+11, 1, 55434, 11, 2, 3678, 12, 1, 3783, 12, 2, 2641, // 11, 1
+11, 2, 56486, 11, 3, 3311, 12, 2, 3373, 12, 3, 2366, // 11, 2
+11, 3, 57514, 11, 4, 2950, 12, 3, 2976, 12, 4, 2096, // 11, 3
+11, 4, 58484, 11, 5, 2605, 12, 4, 2604, 12, 5, 1843, // 11, 4
+11, 5, 59346, 11, 6, 2297, 12, 5, 2276, 12, 6, 1617, // 11, 5
+11, 6, 60018, 11, 7, 2057, 12, 6, 2020, 12, 7, 1441, // 11, 6
+11, 7, 60402, 11, 8, 1922, 12, 7, 1871, 12, 8, 1341, // 11, 7
+10, 8, 1871, 10, 9, 1341, 11, 8, 60402, 11, 9, 1922, // 11, 8
+10, 9, 2020, 10, 10, 1442, 11, 9, 60017, 11, 10, 2057, // 11, 9
+10, 10, 2276, 10, 11, 1617, 11, 10, 59345, 11, 11, 2298, // 11,10
+10, 11, 2605, 10, 12, 1843, 11, 11, 58484, 11, 12, 2604, // 11,11
+10, 12, 2977, 10, 13, 2096, 11, 12, 57514, 11, 13, 2949, // 11,12
+10, 13, 3374, 10, 14, 2365, 11, 13, 56487, 11, 14, 3310, // 11,13
+10, 14, 3785, 10, 15, 2640, 11, 14, 55435, 11, 15, 3676, // 11,14
+10, 15, 4201, 10, 16, 2916, 11, 15, 54378, 11, 16, 4041, // 11,15
+12, 0, 53814, 12, 1, 4267, 13, 0, 4390, 13, 1, 3065, // 12, 0
+12, 1, 54796, 12, 2, 3929, 13, 1, 4003, 13, 2, 2808, // 12, 1
+12, 2, 55756, 12, 3, 3595, 13, 2, 3628, 13, 3, 2557, // 12, 2
+12, 3, 56673, 12, 4, 3274, 13, 3, 3273, 13, 4, 2316, // 12, 3
+12, 4, 57514, 12, 5, 2977, 13, 4, 2948, 13, 5, 2097, // 12, 4
+12, 5, 58234, 12, 6, 2723, 13, 5, 2672, 13, 6, 1907, // 12, 5
+12, 6, 58775, 12, 7, 2532, 13, 6, 2463, 13, 7, 1766, // 12, 6
+12, 7, 59077, 12, 8, 2430, 13, 7, 2342, 13, 8, 1687, // 12, 7
+11, 8, 2343, 11, 9, 1687, 12, 8, 59076, 12, 9, 2430, // 12, 8
+11, 9, 2464, 11, 10, 1767, 12, 9, 58774, 12, 10, 2531, // 12, 9
+11, 10, 2673, 11, 11, 1908, 12, 10, 58233, 12, 11, 2722, // 12,10
+11, 11, 2950, 11, 12, 2096, 12, 11, 57514, 12, 12, 2976, // 12,11
+11, 12, 3274, 11, 13, 2317, 12, 12, 56673, 12, 13, 3272, // 12,12
+11, 13, 3630, 11, 14, 2556, 12, 13, 55756, 12, 14, 3594, // 12,13
+11, 14, 4005, 11, 15, 2808, 12, 14, 54796, 12, 15, 3927, // 12,14
+11, 15, 4392, 11, 16, 3064, 12, 15, 53815, 12, 16, 4265, // 12,15
+13, 0, 53168, 13, 1, 4523, 14, 0, 4610, 14, 1, 3235, // 13, 0
+13, 1, 54071, 13, 2, 4214, 14, 1, 4253, 14, 2, 2998, // 13, 1
+13, 2, 54941, 13, 3, 3913, 14, 2, 3911, 14, 3, 2771, // 13, 2
+13, 3, 55756, 13, 4, 3630, 14, 3, 3594, 14, 4, 2556, // 13, 3
+13, 4, 56487, 13, 5, 3374, 14, 4, 3310, 14, 5, 2365, // 13, 4
+13, 5, 57096, 13, 6, 3161, 14, 5, 3073, 14, 6, 2206, // 13, 5
+13, 6, 57545, 13, 7, 3007, 14, 6, 2897, 14, 7, 2087, // 13, 6
+13, 7, 57795, 13, 8, 2926, 14, 7, 2794, 14, 8, 2021, // 13, 7
+12, 8, 2795, 12, 9, 2022, 13, 8, 57793, 13, 9, 2926, // 13, 8
+12, 9, 2898, 12, 10, 2088, 13, 9, 57544, 13, 10, 3006, // 13, 9
+12, 10, 3074, 12, 11, 2205, 13, 10, 57095, 13, 11, 3162, // 13,10
+12, 11, 3311, 12, 12, 2365, 13, 11, 56486, 13, 12, 3374, // 13,11
+12, 12, 3595, 12, 13, 2557, 13, 12, 55756, 13, 13, 3628, // 13,12
+12, 13, 3913, 12, 14, 2770, 13, 13, 54941, 13, 14, 3912, // 13,13
+12, 14, 4255, 12, 15, 2998, 13, 14, 54072, 13, 15, 4211, // 13,14
+12, 15, 4612, 12, 16, 3235, 13, 15, 53168, 13, 16, 4521, // 13,15
+14, 0, 52457, 14, 1, 4806, 15, 0, 4851, 15, 1, 3422, // 14, 0
+14, 1, 53285, 14, 2, 4525, 15, 1, 4522, 15, 2, 3204, // 14, 1
+14, 2, 54072, 14, 3, 4255, 15, 2, 4212, 15, 3, 2997, // 14, 2
+14, 3, 54796, 14, 4, 4005, 15, 3, 3927, 15, 4, 2808, // 14, 3
+14, 4, 55435, 14, 5, 3785, 15, 4, 3677, 15, 5, 2639, // 14, 4
+14, 5, 55959, 14, 6, 3605, 15, 5, 3470, 15, 6, 2502, // 14, 5
+14, 6, 56340, 14, 7, 3477, 15, 6, 3317, 15, 7, 2402, // 14, 6
+14, 7, 56554, 14, 8, 3411, 15, 7, 3225, 15, 8, 2346, // 14, 7
+13, 8, 3227, 13, 9, 2346, 14, 8, 56552, 14, 9, 3411, // 14, 8
+13, 9, 3319, 13, 10, 2403, 14, 9, 56339, 14, 10, 3475, // 14, 9
+13, 10, 3472, 13, 11, 2503, 14, 10, 55958, 14, 11, 3603, // 14,10
+13, 11, 3678, 13, 12, 2640, 14, 11, 55434, 14, 12, 3784, // 14,11
+13, 12, 3929, 13, 13, 2808, 14, 12, 54796, 14, 13, 4003, // 14,12
+13, 13, 4214, 13, 14, 2998, 14, 13, 54071, 14, 14, 4253, // 14,13
+13, 14, 4525, 13, 15, 3204, 14, 14, 53285, 14, 15, 4522, // 14,14
+13, 15, 4854, 13, 16, 3421, 14, 15, 52457, 14, 16, 4804, // 14,15
+15, 0, 51699, 15, 1, 5110, 16, 0, 5106, 16, 1, 3621, // 15, 0
+15, 1, 52457, 15, 2, 4854, 16, 1, 4803, 16, 2, 3422, // 15, 1
+15, 2, 53168, 15, 3, 4612, 16, 2, 4521, 16, 3, 3235, // 15, 2
+15, 3, 53815, 15, 4, 4392, 16, 3, 4264, 16, 4, 3065, // 15, 3
+15, 4, 54378, 15, 5, 4201, 16, 4, 4041, 16, 5, 2916, // 15, 4
+15, 5, 54835, 15, 6, 4047, 16, 5, 3858, 16, 6, 2796, // 15, 5
+15, 6, 55166, 15, 7, 3940, 16, 6, 3722, 16, 7, 2708, // 15, 6
+15, 7, 55354, 15, 8, 3885, 16, 7, 3638, 16, 8, 2659, // 15, 7
+14, 8, 3640, 14, 9, 2659, 15, 8, 55352, 15, 9, 3885, // 15, 8
+14, 9, 3724, 14, 10, 2709, 15, 9, 55164, 15, 10, 3939, // 15, 9
+14, 10, 3860, 14, 11, 2797, 15, 10, 54833, 15, 11, 4046, // 15,10
+14, 11, 4043, 14, 12, 2917, 15, 11, 54376, 15, 12, 4200, // 15,11
+14, 12, 4267, 14, 13, 3065, 15, 12, 53814, 15, 13, 4390, // 15,12
+14, 13, 4523, 14, 14, 3235, 15, 13, 53168, 15, 14, 4610, // 15,13
+14, 14, 4806, 14, 15, 3422, 15, 14, 52457, 15, 15, 4851, // 15,14
+14, 15, 5110, 14, 16, 3621, 15, 15, 51699, 15, 16, 5106, // 15,15
+// angle of 1.0 degrees
+0, -1, 8769, 0, 0, 41693, 1, -1, 6280, 1, 0, 8794, // 0, 0
+0, 0, 8452, 0, 1, 42821, 1, 0, 5975, 1, 1, 8288, // 0, 1
+0, 1, 8141, 0, 2, 43900, 1, 1, 5684, 1, 2, 7811, // 0, 2
+0, 2, 7848, 0, 3, 44901, 1, 2, 5413, 1, 3, 7374, // 0, 3
+0, 3, 7587, 0, 4, 45791, 1, 3, 5172, 1, 4, 6986, // 0, 4
+0, 4, 7374, 0, 5, 46532, 1, 4, 4971, 1, 5, 6659, // 0, 5
+0, 5, 7227, 0, 6, 47086, 1, 5, 4818, 1, 6, 6405, // 0, 6
+0, 6, 7158, 0, 7, 47426, 1, 6, 4722, 1, 7, 6230, // 0, 7
+-1, 7, 4718, -1, 8, 6217, 0, 7, 7161, 0, 8, 47440, // 0, 8
+-1, 8, 4814, -1, 9, 6391, 0, 8, 7233, 0, 9, 47098, // 0, 9
+-1, 9, 4967, -1, 10, 6644, 0, 9, 7383, 0, 10, 46542, // 0,10
+-1, 10, 5169, -1, 11, 6970, 0, 10, 7599, 0, 11, 45798, // 0,11
+-1, 11, 5410, -1, 12, 7356, 0, 11, 7863, 0, 12, 44907, // 0,12
+-1, 12, 5682, -1, 13, 7791, 0, 12, 8159, 0, 13, 43904, // 0,13
+-1, 13, 5974, -1, 14, 8265, 0, 13, 8474, 0, 14, 42823, // 0,14
+-1, 14, 6280, -1, 15, 8769, 0, 14, 8795, 0, 15, 41692, // 0,15
+1, -1, 8265, 1, 0, 42823, 2, -1, 5974, 2, 0, 8474, // 1, 0
+1, 0, 7901, 1, 1, 44074, 2, 0, 5640, 2, 1, 7921, // 1, 1
+1, 1, 7539, 1, 2, 45286, 2, 1, 5316, 2, 2, 7395, // 1, 2
+1, 2, 7191, 1, 3, 46427, 2, 2, 5011, 2, 3, 6907, // 1, 3
+1, 3, 6875, 1, 4, 47453, 2, 3, 4736, 2, 4, 6472, // 1, 4
+1, 4, 6613, 1, 5, 48314, 2, 4, 4505, 2, 5, 6104, // 1, 5
+1, 5, 6425, 1, 6, 48960, 2, 5, 4330, 2, 6, 5821, // 1, 6
+1, 6, 6332, 1, 7, 49347, 2, 6, 4224, 2, 7, 5633, // 1, 7
+0, 7, 4221, 0, 8, 5623, 1, 7, 6335, 1, 8, 49357, // 1, 8
+0, 8, 4327, 0, 9, 5809, 1, 8, 6430, 1, 9, 48970, // 1, 9
+0, 9, 4502, 0, 10, 6092, 1, 9, 6620, 1, 10, 48322, // 1,10
+0, 10, 4734, 0, 11, 6458, 1, 10, 6886, 1, 11, 47458, // 1,11
+0, 11, 5009, 0, 12, 6892, 1, 11, 7204, 1, 12, 46431, // 1,12
+0, 12, 5315, 0, 13, 7378, 1, 12, 7555, 1, 13, 45288, // 1,13
+0, 13, 5640, 0, 14, 7901, 1, 13, 7921, 1, 14, 44074, // 1,14
+0, 14, 5975, 0, 15, 8452, 1, 14, 8288, 1, 15, 42821, // 1,15
+2, -1, 7791, 2, 0, 43904, 3, -1, 5682, 3, 0, 8159, // 2, 0
+2, 0, 7378, 2, 1, 45288, 3, 0, 5315, 3, 1, 7555, // 2, 1
+2, 1, 6959, 2, 2, 46650, 3, 1, 4954, 3, 2, 6973, // 2, 2
+2, 2, 6549, 2, 3, 47953, 3, 2, 4608, 3, 3, 6426, // 2, 3
+2, 3, 6168, 2, 4, 49147, 3, 3, 4291, 3, 4, 5930, // 2, 4
+2, 4, 5842, 2, 5, 50165, 3, 4, 4020, 3, 5, 5509, // 2, 5
+2, 5, 5602, 2, 6, 50935, 3, 5, 3815, 3, 6, 5184, // 2, 6
+2, 6, 5478, 2, 7, 51387, 3, 6, 3693, 3, 7, 4978, // 2, 7
+1, 7, 3691, 1, 8, 4970, 2, 7, 5480, 2, 8, 51395, // 2, 8
+1, 8, 3813, 1, 9, 5175, 2, 8, 5606, 2, 9, 50942, // 2, 9
+1, 9, 4019, 1, 10, 5499, 2, 9, 5848, 2, 10, 50170, // 2,10
+1, 10, 4290, 1, 11, 5920, 2, 10, 6176, 2, 11, 49150, // 2,11
+1, 11, 4607, 1, 12, 6414, 2, 11, 6560, 2, 12, 47955, // 2,12
+1, 12, 4954, 1, 13, 6959, 2, 12, 6973, 2, 13, 46650, // 2,13
+1, 13, 5316, 1, 14, 7539, 2, 13, 7395, 2, 14, 45286, // 2,14
+1, 14, 5684, 1, 15, 8141, 2, 14, 7812, 2, 15, 43899, // 2,15
+3, -1, 7356, 3, 0, 44907, 4, -1, 5410, 4, 0, 7863, // 3, 0
+3, 0, 6892, 3, 1, 46430, 4, 0, 5009, 4, 1, 7205, // 3, 1
+3, 1, 6414, 3, 2, 47955, 4, 1, 4607, 4, 2, 6560, // 3, 2
+3, 2, 5934, 3, 3, 49445, 4, 2, 4214, 4, 3, 5943, // 3, 3
+3, 3, 5474, 3, 4, 50843, 4, 3, 3846, 4, 4, 5373, // 3, 4
+3, 4, 5069, 3, 5, 52066, 4, 4, 3523, 4, 5, 4878, // 3, 5
+3, 5, 4759, 3, 6, 53008, 4, 5, 3274, 4, 6, 4495, // 3, 6
+3, 6, 4592, 3, 7, 53557, 4, 6, 3128, 4, 7, 4259, // 3, 7
+2, 7, 3126, 2, 8, 4254, 3, 7, 4594, 3, 8, 53562, // 3, 8
+2, 8, 3273, 2, 9, 4489, 3, 8, 4762, 3, 9, 53012, // 3, 9
+2, 9, 3522, 2, 10, 4872, 3, 9, 5073, 3, 10, 52069, // 3,10
+2, 10, 3845, 2, 11, 5365, 3, 10, 5481, 3, 11, 50845, // 3,11
+2, 11, 4214, 2, 12, 5934, 3, 11, 5943, 3, 12, 49445, // 3,12
+2, 12, 4608, 2, 13, 6549, 3, 12, 6426, 3, 13, 47953, // 3,13
+2, 13, 5011, 2, 14, 7191, 3, 13, 6908, 3, 14, 46426, // 3,14
+2, 14, 5413, 2, 15, 7848, 3, 14, 7374, 3, 15, 44901, // 3,15
+4, -1, 6970, 4, 0, 45799, 5, -1, 5169, 5, 0, 7598, // 4, 0
+4, 0, 6458, 4, 1, 47458, 5, 0, 4734, 5, 1, 6886, // 4, 1
+4, 1, 5920, 4, 2, 49150, 5, 1, 4290, 5, 2, 6176, // 4, 2
+4, 2, 5365, 4, 3, 50844, 5, 2, 3845, 5, 3, 5482, // 4, 3
+4, 3, 4816, 4, 4, 52484, 5, 3, 3415, 5, 4, 4821, // 4, 4
+4, 4, 4309, 4, 5, 53973, 5, 4, 3023, 5, 5, 4231, // 4, 5
+4, 5, 3902, 4, 6, 55164, 5, 5, 2711, 5, 6, 3759, // 4, 6
+4, 6, 3671, 4, 7, 55867, 5, 6, 2525, 5, 7, 3473, // 4, 7
+3, 7, 2524, 3, 8, 3469, 4, 7, 3672, 4, 8, 55871, // 4, 8
+3, 8, 2710, 3, 9, 3755, 4, 8, 3904, 4, 9, 55167, // 4, 9
+3, 9, 3023, 3, 10, 4226, 4, 9, 4313, 4, 10, 53974, // 4,10
+3, 10, 3415, 3, 11, 4816, 4, 10, 4822, 4, 11, 52483, // 4,11
+3, 11, 3846, 3, 12, 5474, 4, 11, 5373, 4, 12, 50843, // 4,12
+3, 12, 4291, 3, 13, 6168, 4, 12, 5930, 4, 13, 49147, // 4,13
+3, 13, 4736, 3, 14, 6875, 4, 13, 6472, 4, 14, 47453, // 4,14
+3, 14, 5172, 3, 15, 7587, 4, 14, 6986, 4, 15, 45791, // 4,15
+5, -1, 6644, 5, 0, 46541, 6, -1, 4967, 6, 0, 7384, // 5, 0
+5, 0, 6092, 5, 1, 48322, 6, 0, 4502, 6, 1, 6620, // 5, 1
+5, 1, 5499, 5, 2, 50171, 6, 1, 4019, 6, 2, 5847, // 5, 2
+5, 2, 4872, 5, 3, 52069, 6, 2, 3522, 6, 3, 5073, // 5, 3
+5, 3, 4226, 5, 4, 53975, 6, 3, 3023, 6, 4, 4312, // 5, 4
+5, 4, 3595, 5, 5, 55798, 6, 4, 2546, 6, 5, 3597, // 5, 5
+5, 5, 3050, 5, 6, 57353, 6, 5, 2138, 6, 6, 2995, // 5, 6
+5, 6, 2713, 5, 7, 58322, 6, 6, 1884, 6, 7, 2617, // 5, 7
+4, 7, 1884, 4, 8, 2615, 5, 7, 2714, 5, 8, 58323, // 5, 8
+4, 8, 2138, 4, 9, 2993, 5, 8, 3051, 5, 9, 57354, // 5, 9
+4, 9, 2546, 4, 10, 3595, 5, 9, 3598, 5, 10, 55797, // 5,10
+4, 10, 3023, 4, 11, 4309, 5, 10, 4230, 5, 11, 53974, // 5,11
+4, 11, 3523, 4, 12, 5069, 5, 11, 4879, 5, 12, 52065, // 5,12
+4, 12, 4020, 4, 13, 5842, 5, 12, 5508, 5, 13, 50166, // 5,13
+4, 13, 4505, 4, 14, 6613, 5, 13, 6104, 5, 14, 48314, // 5,14
+4, 14, 4971, 4, 15, 7374, 5, 14, 6659, 5, 15, 46532, // 5,15
+6, -1, 6391, 6, 0, 47098, 7, -1, 4814, 7, 0, 7233, // 6, 0
+6, 0, 5809, 6, 1, 48969, 7, 0, 4327, 7, 1, 6431, // 6, 1
+6, 1, 5175, 6, 2, 50942, 7, 1, 3813, 7, 2, 5606, // 6, 2
+6, 2, 4489, 6, 3, 53012, 7, 2, 3273, 7, 3, 4762, // 6, 3
+6, 3, 3755, 6, 4, 55166, 7, 3, 2710, 7, 4, 3905, // 6, 4
+6, 4, 2993, 6, 5, 57354, 7, 4, 2138, 7, 5, 3051, // 6, 5
+6, 5, 2258, 6, 6, 59422, 7, 5, 1597, 7, 6, 2259, // 6, 6
+6, 6, 1726, 6, 7, 60905, 7, 6, 1210, 7, 7, 1695, // 6, 7
+5, 7, 1209, 5, 8, 1695, 6, 7, 1726, 6, 8, 60906, // 6, 8
+5, 8, 1597, 5, 9, 2258, 6, 8, 2259, 6, 9, 59422, // 6, 9
+5, 9, 2138, 5, 10, 3050, 6, 9, 2995, 6, 10, 57353, // 6,10
+5, 10, 2711, 5, 11, 3902, 6, 10, 3759, 6, 11, 55164, // 6,11
+5, 11, 3274, 5, 12, 4759, 6, 11, 4495, 6, 12, 53008, // 6,12
+5, 12, 3815, 5, 13, 5602, 6, 12, 5184, 6, 13, 50935, // 6,13
+5, 13, 4330, 5, 14, 6425, 6, 13, 5820, 6, 14, 48961, // 6,14
+5, 14, 4818, 5, 15, 7227, 6, 14, 6405, 6, 15, 47086, // 6,15
+7, -1, 6217, 7, 0, 47440, 8, -1, 4718, 8, 0, 7161, // 7, 0
+7, 0, 5623, 7, 1, 49358, 8, 0, 4221, 8, 1, 6334, // 7, 1
+7, 1, 4970, 7, 2, 51395, 8, 1, 3691, 8, 2, 5480, // 7, 2
+7, 2, 4254, 7, 3, 53562, 8, 2, 3126, 8, 3, 4594, // 7, 3
+7, 3, 3469, 7, 4, 55870, 8, 3, 2524, 8, 4, 3673, // 7, 4
+7, 4, 2615, 7, 5, 58324, 8, 4, 1884, 8, 5, 2713, // 7, 5
+7, 5, 1695, 7, 6, 60906, 8, 5, 1209, 8, 6, 1726, // 7, 6
+7, 6, 789, 7, 7, 63399, 8, 6, 558, 8, 7, 790, // 7, 7
+6, 7, 558, 6, 8, 789, 7, 7, 789, 7, 8, 63400, // 7, 8
+6, 8, 1210, 6, 9, 1726, 7, 8, 1695, 7, 9, 60905, // 7, 9
+6, 9, 1884, 6, 10, 2713, 7, 9, 2616, 7, 10, 58323, // 7,10
+6, 10, 2525, 6, 11, 3671, 7, 10, 3473, 7, 11, 55867, // 7,11
+6, 11, 3128, 6, 12, 4592, 7, 11, 4259, 7, 12, 53557, // 7,12
+6, 12, 3693, 6, 13, 5478, 7, 12, 4978, 7, 13, 51387, // 7,13
+6, 13, 4224, 6, 14, 6332, 7, 13, 5633, 7, 14, 49347, // 7,14
+6, 14, 4722, 6, 15, 7158, 7, 14, 6230, 7, 15, 47426, // 7,15
+8, 0, 47426, 8, 1, 6230, 9, 0, 7158, 9, 1, 4722, // 8, 0
+8, 1, 49347, 8, 2, 5633, 9, 1, 6332, 9, 2, 4224, // 8, 1
+8, 2, 51387, 8, 3, 4978, 9, 2, 5478, 9, 3, 3693, // 8, 2
+8, 3, 53557, 8, 4, 4259, 9, 3, 4592, 9, 4, 3128, // 8, 3
+8, 4, 55867, 8, 5, 3473, 9, 4, 3671, 9, 5, 2525, // 8, 4
+8, 5, 58322, 8, 6, 2616, 9, 5, 2713, 9, 6, 1885, // 8, 5
+8, 6, 60905, 8, 7, 1695, 9, 6, 1726, 9, 7, 1210, // 8, 6
+8, 7, 63399, 8, 8, 789, 9, 7, 789, 9, 8, 559, // 8, 7
+7, 8, 789, 7, 9, 558, 8, 8, 63399, 8, 9, 790, // 8, 8
+7, 9, 1726, 7, 10, 1209, 8, 9, 60906, 8, 10, 1695, // 8, 9
+7, 10, 2714, 7, 11, 1884, 8, 10, 58324, 8, 11, 2614, // 8,10
+7, 11, 3672, 7, 12, 2524, 8, 11, 55870, 8, 12, 3470, // 8,11
+7, 12, 4594, 7, 13, 3126, 8, 12, 53562, 8, 13, 4254, // 8,12
+7, 13, 5480, 7, 14, 3691, 8, 13, 51395, 8, 14, 4970, // 8,13
+7, 14, 6335, 7, 15, 4221, 8, 14, 49358, 8, 15, 5622, // 8,14
+7, 15, 7161, 7, 16, 4718, 8, 15, 47440, 8, 16, 6217, // 8,15
+9, 0, 47086, 9, 1, 6405, 10, 0, 7227, 10, 1, 4818, // 9, 0
+9, 1, 48960, 9, 2, 5820, 10, 1, 6425, 10, 2, 4331, // 9, 1
+9, 2, 50935, 9, 3, 5184, 10, 2, 5602, 10, 3, 3815, // 9, 2
+9, 3, 53008, 9, 4, 4495, 10, 3, 4759, 10, 4, 3274, // 9, 3
+9, 4, 55164, 9, 5, 3759, 10, 4, 3902, 10, 5, 2711, // 9, 4
+9, 5, 57353, 9, 6, 2995, 10, 5, 3050, 10, 6, 2138, // 9, 5
+9, 6, 59422, 9, 7, 2259, 10, 6, 2258, 10, 7, 1597, // 9, 6
+9, 7, 60906, 9, 8, 1726, 10, 7, 1695, 10, 8, 1209, // 9, 7
+8, 8, 1695, 8, 9, 1210, 9, 8, 60905, 9, 9, 1726, // 9, 8
+8, 9, 2259, 8, 10, 1597, 9, 9, 59422, 9, 10, 2258, // 9, 9
+8, 10, 3051, 8, 11, 2138, 9, 10, 57354, 9, 11, 2993, // 9,10
+8, 11, 3904, 8, 12, 2710, 9, 11, 55166, 9, 12, 3756, // 9,11
+8, 12, 4762, 8, 13, 3273, 9, 12, 53012, 9, 13, 4489, // 9,12
+8, 13, 5606, 8, 14, 3813, 9, 13, 50942, 9, 14, 5175, // 9,13
+8, 14, 6430, 8, 15, 4327, 9, 14, 48969, 9, 15, 5810, // 9,14
+8, 15, 7233, 8, 16, 4814, 9, 15, 47098, 9, 16, 6391, // 9,15
+10, 0, 46532, 10, 1, 6659, 11, 0, 7374, 11, 1, 4971, // 10, 0
+10, 1, 48314, 10, 2, 6104, 11, 1, 6613, 11, 2, 4505, // 10, 1
+10, 2, 50165, 10, 3, 5508, 11, 2, 5842, 11, 3, 4021, // 10, 2
+10, 3, 52066, 10, 4, 4879, 11, 3, 5069, 11, 4, 3522, // 10, 3
+10, 4, 53973, 10, 5, 4230, 11, 4, 4309, 11, 5, 3024, // 10, 4
+10, 5, 55798, 10, 6, 3598, 11, 5, 3595, 11, 6, 2545, // 10, 5
+10, 6, 57354, 10, 7, 3051, 11, 6, 2993, 11, 7, 2138, // 10, 6
+10, 7, 58324, 10, 8, 2714, 11, 7, 2615, 11, 8, 1883, // 10, 7
+9, 8, 2616, 9, 9, 1884, 10, 8, 58322, 10, 9, 2714, // 10, 8
+9, 9, 2995, 9, 10, 2138, 10, 9, 57353, 10, 10, 3050, // 10, 9
+9, 10, 3598, 9, 11, 2546, 10, 10, 55798, 10, 11, 3594, // 10,10
+9, 11, 4313, 9, 12, 3023, 10, 11, 53975, 10, 12, 4225, // 10,11
+9, 12, 5073, 9, 13, 3522, 10, 12, 52069, 10, 13, 4872, // 10,12
+9, 13, 5848, 9, 14, 4019, 10, 13, 50171, 10, 14, 5498, // 10,13
+9, 14, 6620, 9, 15, 4502, 10, 14, 48322, 10, 15, 6092, // 10,14
+9, 15, 7383, 9, 16, 4967, 10, 15, 46541, 10, 16, 6645, // 10,15
+11, 0, 45791, 11, 1, 6986, 12, 0, 7587, 12, 1, 5172, // 11, 0
+11, 1, 47453, 11, 2, 6472, 12, 1, 6875, 12, 2, 4736, // 11, 1
+11, 2, 49147, 11, 3, 5930, 12, 2, 6168, 12, 3, 4291, // 11, 2
+11, 3, 50843, 11, 4, 5373, 12, 3, 5474, 12, 4, 3846, // 11, 3
+11, 4, 52484, 11, 5, 4822, 12, 4, 4816, 12, 5, 3414, // 11, 4
+11, 5, 53975, 11, 6, 4313, 12, 5, 4226, 12, 6, 3022, // 11, 5
+11, 6, 55166, 11, 7, 3904, 12, 6, 3755, 12, 7, 2711, // 11, 6
+11, 7, 55870, 11, 8, 3672, 12, 7, 3469, 12, 8, 2525, // 11, 7
+10, 8, 3473, 10, 9, 2525, 11, 8, 55867, 11, 9, 3671, // 11, 8
+10, 9, 3759, 10, 10, 2711, 11, 9, 55164, 11, 10, 3902, // 11, 9
+10, 10, 4230, 10, 11, 3023, 11, 10, 53973, 11, 11, 4310, // 11,10
+10, 11, 4822, 10, 12, 3415, 11, 11, 52484, 11, 12, 4815, // 11,11
+10, 12, 5481, 10, 13, 3845, 11, 12, 50844, 11, 13, 5366, // 11,12
+10, 13, 6176, 10, 14, 4290, 11, 13, 49150, 11, 14, 5920, // 11,13
+10, 14, 6886, 10, 15, 4734, 11, 14, 47458, 11, 15, 6458, // 11,14
+10, 15, 7599, 10, 16, 5169, 11, 15, 45799, 11, 16, 6969, // 11,15
+12, 0, 44901, 12, 1, 7374, 13, 0, 7848, 13, 1, 5413, // 12, 0
+12, 1, 46427, 12, 2, 6908, 13, 1, 7191, 13, 2, 5010, // 12, 1
+12, 2, 47953, 12, 3, 6426, 13, 2, 6549, 13, 3, 4608, // 12, 2
+12, 3, 49445, 12, 4, 5943, 13, 3, 5934, 13, 4, 4214, // 12, 3
+12, 4, 50844, 12, 5, 5481, 13, 4, 5365, 13, 5, 3846, // 12, 4
+12, 5, 52069, 12, 6, 5073, 13, 5, 4872, 13, 6, 3522, // 12, 5
+12, 6, 53012, 12, 7, 4762, 13, 6, 4489, 13, 7, 3273, // 12, 6
+12, 7, 53562, 12, 8, 4594, 13, 7, 4254, 13, 8, 3126, // 12, 7
+11, 8, 4259, 11, 9, 3128, 12, 8, 53557, 12, 9, 4592, // 12, 8
+11, 9, 4495, 11, 10, 3274, 12, 9, 53008, 12, 10, 4759, // 12, 9
+11, 10, 4879, 11, 11, 3523, 12, 10, 52066, 12, 11, 5068, // 12,10
+11, 11, 5373, 11, 12, 3846, 12, 11, 50843, 12, 12, 5474, // 12,11
+11, 12, 5943, 11, 13, 4214, 12, 12, 49445, 12, 13, 5934, // 12,12
+11, 13, 6560, 11, 14, 4607, 12, 13, 47955, 12, 14, 6414, // 12,13
+11, 14, 7204, 11, 15, 5009, 12, 14, 46430, 12, 15, 6893, // 12,14
+11, 15, 7863, 11, 16, 5410, 12, 15, 44907, 12, 16, 7356, // 12,15
+13, 0, 43900, 13, 1, 7812, 14, 0, 8141, 14, 1, 5683, // 13, 0
+13, 1, 45286, 13, 2, 7395, 14, 1, 7539, 14, 2, 5316, // 13, 1
+13, 2, 46650, 13, 3, 6973, 14, 2, 6959, 14, 3, 4954, // 13, 2
+13, 3, 47955, 13, 4, 6560, 14, 3, 6414, 14, 4, 4607, // 13, 3
+13, 4, 49150, 13, 5, 6176, 14, 4, 5920, 14, 5, 4290, // 13, 4
+13, 5, 50171, 13, 6, 5848, 14, 5, 5499, 14, 6, 4018, // 13, 5
+13, 6, 50942, 13, 7, 5606, 14, 6, 5175, 14, 7, 3813, // 13, 6
+13, 7, 51395, 13, 8, 5480, 14, 7, 4970, 14, 8, 3691, // 13, 7
+12, 8, 4978, 12, 9, 3693, 13, 8, 51387, 13, 9, 5478, // 13, 8
+12, 9, 5184, 12, 10, 3815, 13, 9, 50935, 13, 10, 5602, // 13, 9
+12, 10, 5508, 12, 11, 4020, 13, 10, 50165, 13, 11, 5843, // 13,10
+12, 11, 5930, 12, 12, 4291, 13, 11, 49147, 13, 12, 6168, // 13,11
+12, 12, 6426, 12, 13, 4608, 13, 12, 47953, 13, 13, 6549, // 13,12
+12, 13, 6973, 12, 14, 4954, 13, 13, 46650, 13, 14, 6959, // 13,13
+12, 14, 7555, 12, 15, 5315, 13, 14, 45288, 13, 15, 7378, // 13,14
+12, 15, 8159, 12, 16, 5682, 13, 15, 43904, 13, 16, 7791, // 13,15
+14, 0, 42821, 14, 1, 8288, 15, 0, 8452, 15, 1, 5975, // 14, 0
+14, 1, 44074, 14, 2, 7921, 15, 1, 7901, 15, 2, 5640, // 14, 1
+14, 2, 45288, 14, 3, 7555, 15, 2, 7378, 15, 3, 5315, // 14, 2
+14, 3, 46430, 14, 4, 7204, 15, 3, 6892, 15, 4, 5010, // 14, 3
+14, 4, 47458, 14, 5, 6886, 15, 4, 6458, 15, 5, 4734, // 14, 4
+14, 5, 48322, 14, 6, 6620, 15, 5, 6092, 15, 6, 4502, // 14, 5
+14, 6, 48969, 14, 7, 6430, 15, 6, 5809, 15, 7, 4328, // 14, 6
+14, 7, 49358, 14, 8, 6335, 15, 7, 5623, 15, 8, 4220, // 14, 7
+13, 8, 5633, 13, 9, 4224, 14, 8, 49347, 14, 9, 6332, // 14, 8
+13, 9, 5820, 13, 10, 4330, 14, 9, 48960, 14, 10, 6426, // 14, 9
+13, 10, 6104, 13, 11, 4505, 14, 10, 48314, 14, 11, 6613, // 14,10
+13, 11, 6472, 13, 12, 4736, 14, 11, 47453, 14, 12, 6875, // 14,11
+13, 12, 6908, 13, 13, 5011, 14, 12, 46427, 14, 13, 7190, // 14,12
+13, 13, 7395, 13, 14, 5316, 14, 13, 45286, 14, 14, 7539, // 14,13
+13, 14, 7921, 13, 15, 5640, 14, 14, 44074, 14, 15, 7901, // 14,14
+13, 15, 8474, 13, 16, 5974, 14, 15, 42823, 14, 16, 8265, // 14,15
+15, 0, 41693, 15, 1, 8795, 16, 0, 8769, 16, 1, 6279, // 15, 0
+15, 1, 42823, 15, 2, 8474, 16, 1, 8265, 16, 2, 5974, // 15, 1
+15, 2, 43904, 15, 3, 8159, 16, 2, 7791, 16, 3, 5682, // 15, 2
+15, 3, 44907, 15, 4, 7863, 16, 3, 7356, 16, 4, 5410, // 15, 3
+15, 4, 45799, 15, 5, 7599, 16, 4, 6970, 16, 5, 5168, // 15, 4
+15, 5, 46541, 15, 6, 7383, 16, 5, 6644, 16, 6, 4968, // 15, 5
+15, 6, 47098, 15, 7, 7233, 16, 6, 6391, 16, 7, 4814, // 15, 6
+15, 7, 47440, 15, 8, 7161, 16, 7, 6217, 16, 8, 4718, // 15, 7
+14, 8, 6230, 14, 9, 4722, 15, 8, 47426, 15, 9, 7158, // 15, 8
+14, 9, 6405, 14, 10, 4818, 15, 9, 47086, 15, 10, 7227, // 15, 9
+14, 10, 6659, 14, 11, 4971, 15, 10, 46532, 15, 11, 7374, // 15,10
+14, 11, 6986, 14, 12, 5172, 15, 11, 45791, 15, 12, 7587, // 15,11
+14, 12, 7374, 14, 13, 5413, 15, 12, 44901, 15, 13, 7848, // 15,12
+14, 13, 7812, 14, 14, 5684, 15, 13, 43900, 15, 14, 8140, // 15,13
+14, 14, 8288, 14, 15, 5975, 15, 14, 42821, 15, 15, 8452, // 15,14
+14, 15, 8795, 14, 16, 6280, 15, 15, 41693, 15, 16, 8768, // 15,15
+// angle of 1.5 degrees
+0, -1, 11440, 0, 0, 34212, 1, -1, 8358, 1, 0, 11526, // 0, 0
+0, 0, 11192, 0, 1, 35502, 1, 0, 7987, 1, 1, 10855, // 0, 1
+0, 1, 10930, 0, 2, 36756, 1, 1, 7626, 1, 2, 10224, // 0, 2
+0, 2, 10670, 0, 3, 37939, 1, 2, 7285, 1, 3, 9642, // 0, 3
+0, 3, 10430, 0, 4, 39009, 1, 3, 6975, 1, 4, 9122, // 0, 4
+0, 4, 10232, 0, 5, 39918, 1, 4, 6710, 1, 5, 8676, // 0, 5
+0, 5, 10100, 0, 6, 40618, 1, 5, 6502, 1, 6, 8316, // 0, 6
+0, 6, 10052, 0, 7, 41072, 1, 6, 6360, 1, 7, 8052, // 0, 7
+-1, 7, 6346, -1, 8, 8018, 0, 7, 10066, 0, 8, 41106, // 0, 8
+-1, 8, 6489, -1, 9, 8278, 0, 8, 10123, 0, 9, 40646, // 0, 9
+-1, 9, 6699, -1, 10, 8632, 0, 9, 10265, 0, 10, 39940, // 0,10
+-1, 10, 6965, -1, 11, 9072, 0, 10, 10473, 0, 11, 39026, // 0,11
+-1, 11, 7276, -1, 12, 9585, 0, 11, 10723, 0, 12, 37952, // 0,12
+-1, 12, 7620, -1, 13, 10158, 0, 12, 10994, 0, 13, 36764, // 0,13
+-1, 13, 7983, -1, 14, 10780, 0, 13, 11267, 0, 14, 35506, // 0,14
+-1, 14, 8358, -1, 15, 11440, 0, 14, 11526, 0, 15, 34212, // 0,15
+1, -1, 10780, 1, 0, 35506, 2, -1, 7983, 2, 0, 11267, // 1, 0
+1, 0, 10467, 1, 1, 36959, 2, 0, 7579, 2, 1, 10531, // 1, 1
+1, 1, 10133, 1, 2, 38390, 2, 1, 7179, 2, 2, 9834, // 1, 2
+1, 2, 9796, 1, 3, 39759, 2, 2, 6797, 2, 3, 9184, // 1, 3
+1, 3, 9478, 1, 4, 41013, 2, 3, 6447, 2, 4, 8598, // 1, 4
+1, 4, 9206, 1, 5, 42087, 2, 4, 6145, 2, 5, 8098, // 1, 5
+1, 5, 9014, 1, 6, 42913, 2, 5, 5910, 2, 6, 7699, // 1, 6
+1, 6, 8929, 1, 7, 43433, 2, 6, 5756, 2, 7, 7418, // 1, 7
+0, 7, 5745, 0, 8, 7390, 1, 7, 8939, 1, 8, 43462, // 1, 8
+0, 8, 5900, 0, 9, 7667, 1, 8, 9032, 1, 9, 42937, // 1, 9
+0, 9, 6137, 0, 10, 8061, 1, 9, 9233, 1, 10, 42105, // 1,10
+0, 10, 6440, 0, 11, 8557, 1, 10, 9513, 1, 11, 41026, // 1,11
+0, 11, 6792, 0, 12, 9135, 1, 11, 9841, 1, 12, 39768, // 1,12
+0, 12, 7177, 0, 13, 9777, 1, 12, 10188, 1, 13, 38394, // 1,13
+0, 13, 7579, 0, 14, 10467, 1, 13, 10532, 1, 14, 36958, // 1,14
+0, 14, 7987, 0, 15, 11192, 1, 14, 10855, 1, 15, 35502, // 1,15
+2, -1, 10158, 2, 0, 36764, 3, -1, 7620, 3, 0, 10994, // 2, 0
+2, 0, 9777, 2, 1, 38394, 3, 0, 7177, 3, 1, 10188, // 2, 1
+2, 1, 9366, 2, 2, 40025, 3, 1, 6732, 3, 2, 9413, // 2, 2
+2, 2, 8941, 2, 3, 41614, 3, 2, 6299, 3, 3, 8682, // 2, 3
+2, 3, 8530, 2, 4, 43096, 3, 3, 5895, 3, 4, 8015, // 2, 4
+2, 4, 8167, 2, 5, 44386, 3, 4, 5543, 3, 5, 7440, // 2, 5
+2, 5, 7899, 2, 6, 45383, 3, 5, 5268, 3, 6, 6986, // 2, 6
+2, 6, 7766, 2, 7, 45995, 3, 6, 5095, 3, 7, 6680, // 2, 7
+1, 7, 5087, 1, 8, 6658, 2, 7, 7773, 2, 8, 46018, // 2, 8
+1, 8, 5261, 1, 9, 6961, 2, 8, 7913, 2, 9, 45401, // 2, 9
+1, 9, 5537, 1, 10, 7411, 2, 9, 8189, 2, 10, 44399, // 2,10
+1, 10, 5891, 1, 11, 7981, 2, 10, 8559, 2, 11, 43105, // 2,11
+1, 11, 6297, 1, 12, 8641, 2, 11, 8979, 2, 12, 41619, // 2,12
+1, 12, 6732, 1, 13, 9366, 2, 12, 9413, 2, 13, 40025, // 2,13
+1, 13, 7179, 1, 14, 10133, 2, 13, 9834, 2, 14, 38390, // 2,14
+1, 14, 7626, 1, 15, 10930, 2, 14, 10224, 2, 15, 36756, // 2,15
+3, -1, 9585, 3, 0, 37951, 4, -1, 7276, 4, 0, 10724, // 3, 0
+3, 0, 9135, 3, 1, 39767, 4, 0, 6792, 4, 1, 9842, // 3, 1
+3, 1, 8641, 3, 2, 41618, 4, 1, 6297, 4, 2, 8980, // 3, 2
+3, 2, 8120, 3, 3, 43461, 4, 2, 5804, 4, 3, 8151, // 3, 3
+3, 3, 7598, 3, 4, 45224, 4, 3, 5331, 4, 4, 7383, // 3, 4
+3, 4, 7121, 3, 5, 46798, 4, 4, 4909, 4, 5, 6708, // 3, 5
+3, 5, 6750, 3, 6, 48037, 4, 5, 4576, 4, 6, 6173, // 3, 6
+3, 6, 6552, 3, 7, 48785, 4, 6, 4372, 4, 7, 5827, // 3, 7
+2, 7, 4366, 2, 8, 5811, 3, 7, 6558, 3, 8, 48801, // 3, 8
+2, 8, 4572, 2, 9, 6154, 3, 8, 6761, 3, 9, 48049, // 3, 9
+2, 9, 4906, 2, 10, 6685, 3, 9, 7138, 3, 10, 46807, // 3,10
+2, 10, 5330, 2, 11, 7356, 3, 10, 7622, 3, 11, 45228, // 3,11
+2, 11, 5804, 2, 12, 8120, 3, 11, 8151, 3, 12, 43461, // 3,12
+2, 12, 6299, 2, 13, 8941, 3, 12, 8681, 3, 13, 41615, // 3,13
+2, 13, 6797, 2, 14, 9796, 3, 13, 9184, 3, 14, 39759, // 3,14
+2, 14, 7285, 2, 15, 10670, 3, 14, 9642, 3, 15, 37939, // 3,15
+4, -1, 9072, 4, 0, 39026, 5, -1, 6965, 5, 0, 10473, // 4, 0
+4, 0, 8557, 4, 1, 41026, 5, 0, 6440, 5, 1, 9513, // 4, 1
+4, 1, 7981, 4, 2, 43105, 5, 1, 5891, 5, 2, 8559, // 4, 2
+4, 2, 7356, 4, 3, 45229, 5, 2, 5330, 5, 3, 7621, // 4, 3
+4, 3, 6708, 4, 4, 47328, 5, 3, 4774, 5, 4, 6726, // 4, 4
+4, 4, 6086, 4, 5, 49275, 5, 4, 4258, 5, 5, 5917, // 4, 5
+4, 5, 5573, 4, 6, 50865, 5, 5, 3837, 5, 6, 5261, // 4, 6
+4, 6, 5280, 4, 7, 51832, 5, 6, 3579, 5, 7, 4845, // 4, 7
+3, 7, 3575, 3, 8, 4835, 4, 7, 5283, 4, 8, 51843, // 4, 8
+3, 8, 3834, 3, 9, 5248, 4, 8, 5581, 4, 9, 50873, // 4, 9
+3, 9, 4257, 3, 10, 5901, 4, 9, 6099, 4, 10, 49279, // 4,10
+3, 10, 4774, 3, 11, 6708, 4, 10, 6727, 4, 11, 47327, // 4,11
+3, 11, 5331, 3, 12, 7598, 4, 11, 7382, 4, 12, 45225, // 4,12
+3, 12, 5895, 3, 13, 8530, 4, 12, 8015, 4, 13, 43096, // 4,13
+3, 13, 6447, 3, 14, 9478, 4, 13, 8599, 4, 14, 41012, // 4,14
+3, 14, 6975, 3, 15, 10430, 4, 14, 9122, 4, 15, 39009, // 4,15
+5, -1, 8632, 5, 0, 39940, 6, -1, 6699, 6, 0, 10265, // 5, 0
+5, 0, 8061, 5, 1, 42105, 6, 0, 6137, 6, 1, 9233, // 5, 1
+5, 1, 7411, 5, 2, 44399, 6, 1, 5537, 6, 2, 8189, // 5, 2
+5, 2, 6685, 5, 3, 46806, 6, 2, 4906, 6, 3, 7139, // 5, 3
+5, 3, 5901, 5, 4, 49279, 6, 3, 4257, 6, 4, 6099, // 5, 4
+5, 4, 5103, 5, 5, 51700, 6, 4, 3621, 6, 5, 5112, // 5, 5
+5, 5, 4388, 5, 6, 53813, 6, 5, 3065, 6, 6, 4270, // 5, 6
+5, 6, 3938, 5, 7, 55162, 6, 6, 2710, 6, 7, 3726, // 5, 7
+4, 7, 2708, 4, 8, 3720, 5, 7, 3940, 5, 8, 55168, // 5, 8
+4, 8, 3064, 4, 9, 4262, 5, 8, 4394, 5, 9, 53816, // 5, 9
+4, 9, 3621, 4, 10, 5103, 5, 9, 5113, 5, 10, 51699, // 5,10
+4, 10, 4258, 4, 11, 6086, 5, 10, 5917, 5, 11, 49275, // 5,11
+4, 11, 4909, 4, 12, 7121, 5, 11, 6707, 5, 12, 46799, // 5,12
+4, 12, 5543, 4, 13, 8167, 5, 12, 7440, 5, 13, 44386, // 5,13
+4, 13, 6145, 4, 14, 9206, 5, 13, 8098, 5, 14, 42087, // 5,14
+4, 14, 6710, 4, 15, 10232, 5, 14, 8676, 5, 15, 39918, // 5,15
+6, -1, 8278, 6, 0, 40646, 7, -1, 6489, 7, 0, 10123, // 6, 0
+6, 0, 7667, 6, 1, 42936, 7, 0, 5900, 7, 1, 9033, // 6, 1
+6, 1, 6961, 6, 2, 45401, 7, 1, 5261, 7, 2, 7913, // 6, 2
+6, 2, 6154, 6, 3, 48049, 7, 2, 4572, 7, 3, 6761, // 6, 3
+6, 3, 5248, 6, 4, 50873, 7, 3, 3834, 7, 4, 5581, // 6, 4
+6, 4, 4262, 6, 5, 53816, 7, 4, 3064, 7, 5, 4394, // 6, 5
+6, 5, 3271, 6, 6, 56673, 7, 5, 2316, 7, 6, 3276, // 6, 6
+6, 6, 2532, 6, 7, 58773, 7, 6, 1767, 7, 7, 2464, // 6, 7
+5, 7, 1766, 5, 8, 2462, 6, 7, 2533, 6, 8, 58775, // 6, 8
+5, 8, 2316, 5, 9, 3271, 6, 8, 3275, 6, 9, 56674, // 6, 9
+5, 9, 3065, 5, 10, 4388, 6, 9, 4269, 6, 10, 53814, // 6,10
+5, 10, 3837, 5, 11, 5573, 6, 10, 5261, 6, 11, 50865, // 6,11
+5, 11, 4576, 5, 12, 6750, 6, 11, 6173, 6, 12, 48037, // 6,12
+5, 12, 5268, 5, 13, 7899, 6, 12, 6986, 6, 13, 45383, // 6,13
+5, 13, 5910, 5, 14, 9014, 6, 13, 7699, 6, 14, 42913, // 6,14
+5, 14, 6502, 5, 15, 10100, 6, 14, 8316, 6, 15, 40618, // 6,15
+7, -1, 8018, 7, 0, 41106, 8, -1, 6346, 8, 0, 10066, // 7, 0
+7, 0, 7390, 7, 1, 43461, 8, 0, 5745, 8, 1, 8940, // 7, 1
+7, 1, 6658, 7, 2, 46017, 8, 1, 5087, 8, 2, 7774, // 7, 2
+7, 2, 5811, 7, 3, 48801, 8, 2, 4366, 8, 3, 6558, // 7, 3
+7, 3, 4835, 7, 4, 51842, 8, 3, 3575, 8, 4, 5284, // 7, 4
+7, 4, 3720, 7, 5, 55168, 8, 4, 2708, 8, 5, 3940, // 7, 5
+7, 5, 2462, 7, 6, 58775, 8, 5, 1766, 8, 6, 2533, // 7, 6
+7, 6, 1170, 7, 7, 62369, 8, 6, 827, 8, 7, 1170, // 7, 7
+6, 7, 827, 6, 8, 1170, 7, 7, 1170, 7, 8, 62369, // 7, 8
+6, 8, 1767, 6, 9, 2532, 7, 8, 2464, 7, 9, 58773, // 7, 9
+6, 9, 2710, 6, 10, 3938, 7, 9, 3726, 7, 10, 55162, // 7,10
+6, 10, 3579, 6, 11, 5280, 7, 10, 4846, 7, 11, 51831, // 7,11
+6, 11, 4372, 6, 12, 6552, 7, 11, 5827, 7, 12, 48785, // 7,12
+6, 12, 5095, 6, 13, 7766, 7, 12, 6680, 7, 13, 45995, // 7,13
+6, 13, 5756, 6, 14, 8929, 7, 13, 7418, 7, 14, 43433, // 7,14
+6, 14, 6360, 6, 15, 10052, 7, 14, 8052, 7, 15, 41072, // 7,15
+8, 0, 41072, 8, 1, 8052, 9, 0, 10052, 9, 1, 6360, // 8, 0
+8, 1, 43433, 8, 2, 7418, 9, 1, 8929, 9, 2, 5756, // 8, 1
+8, 2, 45995, 8, 3, 6680, 9, 2, 7766, 9, 3, 5095, // 8, 2
+8, 3, 48785, 8, 4, 5827, 9, 3, 6552, 9, 4, 4372, // 8, 3
+8, 4, 51832, 8, 5, 4846, 9, 4, 5280, 9, 5, 3578, // 8, 4
+8, 5, 55162, 8, 6, 3726, 9, 5, 3938, 9, 6, 2710, // 8, 5
+8, 6, 58773, 8, 7, 2464, 9, 6, 2532, 9, 7, 1767, // 8, 6
+8, 7, 62369, 8, 8, 1170, 9, 7, 1170, 9, 8, 827, // 8, 7
+7, 8, 1170, 7, 9, 827, 8, 8, 62369, 8, 9, 1170, // 8, 8
+7, 9, 2533, 7, 10, 1766, 8, 9, 58775, 8, 10, 2462, // 8, 9
+7, 10, 3940, 7, 11, 2708, 8, 10, 55168, 8, 11, 3720, // 8,10
+7, 11, 5283, 7, 12, 3575, 8, 11, 51842, 8, 12, 4836, // 8,11
+7, 12, 6558, 7, 13, 4366, 8, 12, 48801, 8, 13, 5811, // 8,12
+7, 13, 7773, 7, 14, 5087, 8, 13, 46017, 8, 14, 6659, // 8,13
+7, 14, 8939, 7, 15, 5745, 8, 14, 43461, 8, 15, 7391, // 8,14
+7, 15, 10066, 7, 16, 6346, 8, 15, 41106, 8, 16, 8018, // 8,15
+9, 0, 40618, 9, 1, 8316, 10, 0, 10100, 10, 1, 6502, // 9, 0
+9, 1, 42913, 9, 2, 7699, 10, 1, 9014, 10, 2, 5910, // 9, 1
+9, 2, 45383, 9, 3, 6986, 10, 2, 7899, 10, 3, 5268, // 9, 2
+9, 3, 48037, 9, 4, 6173, 10, 3, 6750, 10, 4, 4576, // 9, 3
+9, 4, 50865, 9, 5, 5261, 10, 4, 5573, 10, 5, 3837, // 9, 4
+9, 5, 53813, 9, 6, 4269, 10, 5, 4388, 10, 6, 3066, // 9, 5
+9, 6, 56673, 9, 7, 3275, 10, 6, 3271, 10, 7, 2317, // 9, 6
+9, 7, 58775, 9, 8, 2533, 10, 7, 2462, 10, 8, 1766, // 9, 7
+8, 8, 2464, 8, 9, 1767, 9, 8, 58773, 9, 9, 2532, // 9, 8
+8, 9, 3275, 8, 10, 2316, 9, 9, 56673, 9, 10, 3272, // 9, 9
+8, 10, 4394, 8, 11, 3064, 9, 10, 53816, 9, 11, 4262, // 9,10
+8, 11, 5581, 8, 12, 3834, 9, 11, 50873, 9, 12, 5248, // 9,11
+8, 12, 6761, 8, 13, 4572, 9, 12, 48049, 9, 13, 6154, // 9,12
+8, 13, 7913, 8, 14, 5261, 9, 13, 45401, 9, 14, 6961, // 9,13
+8, 14, 9032, 8, 15, 5900, 9, 14, 42936, 9, 15, 7668, // 9,14
+8, 15, 10123, 8, 16, 6489, 9, 15, 40646, 9, 16, 8278, // 9,15
+10, 0, 39918, 10, 1, 8676, 11, 0, 10232, 11, 1, 6710, // 10, 0
+10, 1, 42087, 10, 2, 8098, 11, 1, 9206, 11, 2, 6145, // 10, 1
+10, 2, 44386, 10, 3, 7440, 11, 2, 8167, 11, 3, 5543, // 10, 2
+10, 3, 46798, 10, 4, 6707, 11, 3, 7121, 11, 4, 4910, // 10, 3
+10, 4, 49275, 10, 5, 5917, 11, 4, 6086, 11, 5, 4258, // 10, 4
+10, 5, 51700, 10, 6, 5113, 11, 5, 5103, 11, 6, 3620, // 10, 5
+10, 6, 53816, 10, 7, 4394, 11, 6, 4262, 11, 7, 3064, // 10, 6
+10, 7, 55168, 10, 8, 3940, 11, 7, 3720, 11, 8, 2708, // 10, 7
+9, 8, 3726, 9, 9, 2710, 10, 8, 55162, 10, 9, 3938, // 10, 8
+9, 9, 4269, 9, 10, 3065, 10, 9, 53813, 10, 10, 4389, // 10, 9
+9, 10, 5113, 9, 11, 3621, 10, 10, 51700, 10, 11, 5102, // 10,10
+9, 11, 6099, 9, 12, 4257, 10, 11, 49279, 10, 12, 5901, // 10,11
+9, 12, 7138, 9, 13, 4906, 10, 12, 46806, 10, 13, 6686, // 10,12
+9, 13, 8189, 9, 14, 5537, 10, 13, 44399, 10, 14, 7411, // 10,13
+9, 14, 9233, 9, 15, 6137, 10, 14, 42105, 10, 15, 8061, // 10,14
+9, 15, 10265, 9, 16, 6699, 10, 15, 39940, 10, 16, 8632, // 10,15
+11, 0, 39009, 11, 1, 9122, 12, 0, 10430, 12, 1, 6975, // 11, 0
+11, 1, 41013, 11, 2, 8599, 12, 1, 9478, 12, 2, 6446, // 11, 1
+11, 2, 43096, 11, 3, 8015, 12, 2, 8530, 12, 3, 5895, // 11, 2
+11, 3, 45224, 11, 4, 7382, 12, 3, 7598, 12, 4, 5332, // 11, 3
+11, 4, 47328, 11, 5, 6727, 12, 4, 6708, 12, 5, 4773, // 11, 4
+11, 5, 49279, 11, 6, 6099, 12, 5, 5901, 12, 6, 4257, // 11, 5
+11, 6, 50873, 11, 7, 5581, 12, 6, 5248, 12, 7, 3834, // 11, 6
+11, 7, 51842, 11, 8, 5283, 12, 7, 4835, 12, 8, 3576, // 11, 7
+10, 8, 4846, 10, 9, 3579, 11, 8, 51832, 11, 9, 5279, // 11, 8
+10, 9, 5261, 10, 10, 3837, 11, 9, 50865, 11, 10, 5573, // 11, 9
+10, 10, 5917, 10, 11, 4258, 11, 10, 49275, 11, 11, 6086, // 11,10
+10, 11, 6727, 10, 12, 4774, 11, 11, 47328, 11, 12, 6707, // 11,11
+10, 12, 7622, 10, 13, 5330, 11, 12, 45229, 11, 13, 7355, // 11,12
+10, 13, 8559, 10, 14, 5891, 11, 13, 43105, 11, 14, 7981, // 11,13
+10, 14, 9513, 10, 15, 6440, 11, 14, 41026, 11, 15, 8557, // 11,14
+10, 15, 10473, 10, 16, 6965, 11, 15, 39026, 11, 16, 9072, // 11,15
+12, 0, 37939, 12, 1, 9642, 13, 0, 10670, 13, 1, 7285, // 12, 0
+12, 1, 39759, 12, 2, 9184, 13, 1, 9796, 13, 2, 6797, // 12, 1
+12, 2, 41614, 12, 3, 8681, 13, 2, 8941, 13, 3, 6300, // 12, 2
+12, 3, 43461, 12, 4, 8151, 13, 3, 8120, 13, 4, 5804, // 12, 3
+12, 4, 45229, 12, 5, 7622, 13, 4, 7356, 13, 5, 5329, // 12, 4
+12, 5, 46806, 12, 6, 7138, 13, 5, 6685, 13, 6, 4907, // 12, 5
+12, 6, 48049, 12, 7, 6761, 13, 6, 6154, 13, 7, 4572, // 12, 6
+12, 7, 48801, 12, 8, 6558, 13, 7, 5811, 13, 8, 4366, // 12, 7
+11, 8, 5827, 11, 9, 4372, 12, 8, 48785, 12, 9, 6552, // 12, 8
+11, 9, 6173, 11, 10, 4576, 12, 9, 48037, 12, 10, 6750, // 12, 9
+11, 10, 6707, 11, 11, 4909, 12, 10, 46798, 12, 11, 7122, // 12,10
+11, 11, 7382, 11, 12, 5331, 12, 11, 45224, 12, 12, 7599, // 12,11
+11, 12, 8151, 11, 13, 5804, 12, 12, 43461, 12, 13, 8120, // 12,12
+11, 13, 8979, 11, 14, 6297, 12, 13, 41618, 12, 14, 8642, // 12,13
+11, 14, 9841, 11, 15, 6792, 12, 14, 39767, 12, 15, 9136, // 12,14
+11, 15, 10723, 11, 16, 7276, 12, 15, 37951, 12, 16, 9586, // 12,15
+13, 0, 36756, 13, 1, 10224, 14, 0, 10930, 14, 1, 7626, // 13, 0
+13, 1, 38390, 13, 2, 9834, 14, 1, 10133, 14, 2, 7179, // 13, 1
+13, 2, 40025, 13, 3, 9413, 14, 2, 9366, 14, 3, 6732, // 13, 2
+13, 3, 41618, 13, 4, 8979, 14, 3, 8641, 14, 4, 6298, // 13, 3
+13, 4, 43105, 13, 5, 8559, 14, 4, 7981, 14, 5, 5891, // 13, 4
+13, 5, 44399, 13, 6, 8189, 14, 5, 7411, 14, 6, 5537, // 13, 5
+13, 6, 45401, 13, 7, 7913, 14, 6, 6961, 14, 7, 5261, // 13, 6
+13, 7, 46017, 13, 8, 7773, 14, 7, 6658, 14, 8, 5088, // 13, 7
+12, 8, 6680, 12, 9, 5095, 13, 8, 45995, 13, 9, 7766, // 13, 8
+12, 9, 6986, 12, 10, 5268, 13, 9, 45383, 13, 10, 7899, // 13, 9
+12, 10, 7440, 12, 11, 5543, 13, 10, 44386, 13, 11, 8167, // 13,10
+12, 11, 8015, 12, 12, 5895, 13, 11, 43096, 13, 12, 8530, // 13,11
+12, 12, 8681, 12, 13, 6299, 13, 12, 41614, 13, 13, 8942, // 13,12
+12, 13, 9413, 12, 14, 6732, 13, 13, 40025, 13, 14, 9366, // 13,13
+12, 14, 10188, 12, 15, 7177, 13, 14, 38394, 13, 15, 9777, // 13,14
+12, 15, 10994, 12, 16, 7620, 13, 15, 36764, 13, 16, 10158, // 13,15
+14, 0, 35502, 14, 1, 10855, 15, 0, 11192, 15, 1, 7987, // 14, 0
+14, 1, 36959, 14, 2, 10532, 15, 1, 10467, 15, 2, 7578, // 14, 1
+14, 2, 38394, 14, 3, 10188, 15, 2, 9777, 15, 3, 7177, // 14, 2
+14, 3, 39767, 14, 4, 9841, 15, 3, 9135, 15, 4, 6793, // 14, 3
+14, 4, 41026, 14, 5, 9513, 15, 4, 8557, 15, 5, 6440, // 14, 4
+14, 5, 42105, 14, 6, 9233, 15, 5, 8061, 15, 6, 6137, // 14, 5
+14, 6, 42936, 14, 7, 9032, 15, 6, 7667, 15, 7, 5901, // 14, 6
+14, 7, 43461, 14, 8, 8939, 15, 7, 7390, 15, 8, 5746, // 14, 7
+13, 8, 7418, 13, 9, 5756, 14, 8, 43433, 14, 9, 8929, // 14, 8
+13, 9, 7699, 13, 10, 5910, 14, 9, 42913, 14, 10, 9014, // 14, 9
+13, 10, 8098, 13, 11, 6145, 14, 10, 42087, 14, 11, 9206, // 14,10
+13, 11, 8599, 13, 12, 6447, 14, 11, 41013, 14, 12, 9477, // 14,11
+13, 12, 9184, 13, 13, 6797, 14, 12, 39759, 14, 13, 9796, // 14,12
+13, 13, 9834, 13, 14, 7179, 14, 13, 38390, 14, 14, 10133, // 14,13
+13, 14, 10532, 13, 15, 7579, 14, 14, 36959, 14, 15, 10466, // 14,14
+13, 15, 11267, 13, 16, 7983, 14, 15, 35506, 14, 16, 10780, // 14,15
+15, 0, 34212, 15, 1, 11526, 16, 0, 11440, 16, 1, 8358, // 15, 0
+15, 1, 35506, 15, 2, 11267, 16, 1, 10780, 16, 2, 7983, // 15, 1
+15, 2, 36764, 15, 3, 10994, 16, 2, 10158, 16, 3, 7620, // 15, 2
+15, 3, 37951, 15, 4, 10723, 16, 3, 9585, 16, 4, 7277, // 15, 3
+15, 4, 39026, 15, 5, 10473, 16, 4, 9072, 16, 5, 6965, // 15, 4
+15, 5, 39940, 15, 6, 10265, 16, 5, 8632, 16, 6, 6699, // 15, 5
+15, 6, 40646, 15, 7, 10123, 16, 6, 8278, 16, 7, 6489, // 15, 6
+15, 7, 41106, 15, 8, 10066, 16, 7, 8018, 16, 8, 6346, // 15, 7
+14, 8, 8052, 14, 9, 6360, 15, 8, 41072, 15, 9, 10052, // 15, 8
+14, 9, 8316, 14, 10, 6502, 15, 9, 40618, 15, 10, 10100, // 15, 9
+14, 10, 8676, 14, 11, 6710, 15, 10, 39918, 15, 11, 10232, // 15,10
+14, 11, 9122, 14, 12, 6975, 15, 11, 39009, 15, 12, 10430, // 15,11
+14, 12, 9642, 14, 13, 7285, 15, 12, 37939, 15, 13, 10670, // 15,12
+14, 13, 10224, 14, 14, 7626, 15, 13, 36756, 15, 14, 10930, // 15,13
+14, 14, 10855, 14, 15, 7987, 15, 14, 35502, 15, 15, 11192, // 15,14
+14, 15, 11526, 14, 16, 8358, 15, 15, 34212, 15, 16, 11440, // 15,15
+// angle of 2.0 degrees
+0, -1, 13368, 0, 0, 28495, 1, -1, 10104, 1, 0, 13569, // 0, 0
+0, 0, 13291, 0, 1, 29828, 1, 0, 9671, 1, 1, 12746, // 0, 1
+0, 1, 13176, 0, 2, 31138, 1, 1, 9245, 1, 2, 11977, // 0, 2
+0, 2, 13038, 0, 3, 32391, 1, 2, 8838, 1, 3, 11269, // 0, 3
+0, 3, 12899, 0, 4, 33539, 1, 3, 8463, 1, 4, 10635, // 0, 4
+0, 4, 12783, 0, 5, 34532, 1, 4, 8135, 1, 5, 10086, // 0, 5
+0, 5, 12717, 0, 6, 35315, 1, 5, 7868, 1, 6, 9636, // 0, 6
+0, 6, 12728, 0, 7, 35844, 1, 6, 7674, 1, 7, 9290, // 0, 7
+-1, 7, 7643, -1, 8, 9224, 0, 7, 12764, 0, 8, 35905, // 0, 8
+-1, 8, 7839, -1, 9, 9558, 0, 8, 12777, 0, 9, 35362, // 0, 9
+-1, 9, 8107, -1, 10, 9995, 0, 9, 12867, 0, 10, 34567, // 0,10
+-1, 10, 8438, -1, 11, 10528, 0, 10, 13007, 0, 11, 33563, // 0,11
+-1, 11, 8816, -1, 12, 11143, 0, 11, 13171, 0, 12, 32406, // 0,12
+-1, 12, 9229, -1, 13, 11829, 0, 12, 13332, 0, 13, 31146, // 0,13
+-1, 13, 9662, -1, 14, 12574, 0, 13, 13470, 0, 14, 29830, // 0,14
+-1, 14, 10104, -1, 15, 13368, 0, 14, 13569, 0, 15, 28495, // 0,15
+1, -1, 12574, 1, 0, 29831, 2, -1, 9662, 2, 0, 13469, // 1, 0
+1, 0, 12412, 1, 1, 31358, 2, 0, 9202, 2, 1, 12564, // 1, 1
+1, 1, 12203, 1, 2, 32881, 2, 1, 8742, 2, 2, 11710, // 1, 2
+1, 2, 11964, 1, 3, 34358, 2, 2, 8296, 2, 3, 10918, // 1, 3
+1, 3, 11721, 1, 4, 35730, 2, 3, 7881, 2, 4, 10204, // 1, 4
+1, 4, 11507, 1, 5, 36926, 2, 4, 7517, 2, 5, 9586, // 1, 5
+1, 5, 11360, 1, 6, 37866, 2, 5, 7224, 2, 6, 9086, // 1, 6
+1, 6, 11317, 1, 7, 38481, 2, 6, 7020, 2, 7, 8718, // 1, 7
+0, 7, 6997, 0, 8, 8662, 1, 7, 11344, 1, 8, 38533, // 1, 8
+0, 8, 7202, 0, 9, 9020, 1, 8, 11407, 1, 9, 37907, // 1, 9
+0, 9, 7497, 0, 10, 9509, 1, 9, 11575, 1, 10, 36955, // 1,10
+0, 10, 7865, 0, 11, 10111, 1, 10, 11810, 1, 11, 35750, // 1,11
+0, 11, 8284, 0, 12, 10808, 1, 11, 12074, 1, 12, 34370, // 1,12
+0, 12, 8735, 0, 13, 11580, 1, 12, 12334, 1, 13, 32887, // 1,13
+0, 13, 9202, 0, 14, 12412, 1, 13, 12564, 1, 14, 31358, // 1,14
+0, 14, 9671, 0, 15, 13291, 1, 14, 12746, 1, 15, 29828, // 1,15
+2, -1, 11829, 2, 0, 31146, 3, -1, 9229, 3, 0, 13332, // 2, 0
+2, 0, 11580, 2, 1, 32886, 3, 0, 8735, 3, 1, 12335, // 2, 1
+2, 1, 11272, 2, 2, 34650, 3, 1, 8232, 3, 2, 11382, // 2, 2
+2, 2, 10922, 2, 3, 36392, 3, 2, 7734, 3, 3, 10488, // 2, 3
+2, 3, 10559, 2, 4, 38042, 3, 3, 7261, 3, 4, 9674, // 2, 4
+2, 4, 10226, 2, 5, 39503, 3, 4, 6842, 3, 5, 8965, // 2, 5
+2, 5, 9977, 2, 6, 40656, 3, 5, 6506, 3, 6, 8397, // 2, 6
+2, 6, 9867, 2, 7, 41389, 3, 6, 6284, 3, 7, 7996, // 2, 7
+1, 7, 6266, 1, 8, 7951, 2, 7, 9886, 2, 8, 41433, // 2, 8
+1, 8, 6491, 1, 9, 8344, 2, 8, 10013, 2, 9, 40688, // 2, 9
+1, 9, 6829, 1, 10, 8902, 2, 9, 10279, 2, 10, 39526, // 2,10
+1, 10, 7252, 1, 11, 9597, 2, 10, 10630, 2, 11, 38057, // 2,11
+1, 11, 7728, 1, 12, 10397, 2, 11, 11012, 2, 12, 36399, // 2,12
+1, 12, 8232, 1, 13, 11272, 2, 12, 11382, 2, 13, 34650, // 2,13
+1, 13, 8742, 1, 14, 12203, 2, 13, 11709, 2, 14, 32882, // 2,14
+1, 14, 9245, 1, 15, 13176, 2, 14, 11977, 2, 15, 31138, // 2,15
+3, -1, 11143, 3, 0, 32406, 4, -1, 8816, 4, 0, 13171, // 3, 0
+3, 0, 10808, 3, 1, 34369, 4, 0, 8284, 4, 1, 12075, // 3, 1
+3, 1, 10397, 3, 2, 36399, 4, 1, 7728, 4, 2, 11012, // 3, 2
+3, 2, 9924, 3, 3, 38450, 4, 2, 7164, 4, 3, 9998, // 3, 3
+3, 3, 9421, 3, 4, 40444, 4, 3, 6615, 4, 4, 9056, // 3, 4
+3, 4, 8940, 3, 5, 42256, 4, 4, 6116, 4, 5, 8224, // 3, 5
+3, 5, 8558, 3, 6, 43710, 4, 5, 5712, 4, 6, 7556, // 3, 6
+3, 6, 8359, 3, 7, 44616, 4, 6, 5454, 4, 7, 7107, // 3, 7
+2, 7, 5443, 2, 8, 7072, 3, 7, 8373, 3, 8, 44648, // 3, 8
+2, 8, 5703, 2, 9, 7516, 3, 8, 8584, 3, 9, 43733, // 3, 9
+2, 9, 6108, 2, 10, 8175, 3, 9, 8982, 3, 10, 42271, // 3,10
+2, 10, 6611, 2, 11, 8995, 3, 10, 9478, 3, 11, 40452, // 3,11
+2, 11, 7164, 2, 12, 9924, 3, 11, 9998, 3, 12, 38450, // 3,12
+2, 12, 7734, 2, 13, 10922, 3, 12, 10488, 3, 13, 36392, // 3,13
+2, 13, 8296, 2, 14, 11964, 3, 13, 10918, 3, 14, 34358, // 3,14
+2, 14, 8838, 2, 15, 13038, 3, 14, 11269, 3, 15, 32391, // 3,15
+4, -1, 10528, 4, 0, 33564, 5, -1, 8438, 5, 0, 13006, // 4, 0
+4, 0, 10111, 4, 1, 35750, 5, 0, 7865, 5, 1, 11810, // 4, 1
+4, 1, 9597, 4, 2, 38057, 5, 1, 7252, 5, 2, 10630, // 4, 2
+4, 2, 8995, 4, 3, 40452, 5, 2, 6611, 5, 3, 9478, // 4, 3
+4, 3, 8332, 4, 4, 42861, 5, 3, 5965, 5, 4, 8378, // 4, 4
+4, 4, 7667, 4, 5, 45139, 5, 4, 5353, 5, 5, 7377, // 4, 5
+4, 5, 7100, 4, 6, 47035, 5, 5, 4843, 5, 6, 6558, // 4, 6
+4, 6, 6774, 4, 7, 48218, 5, 6, 4521, 5, 7, 6023, // 4, 7
+3, 7, 4513, 3, 8, 6000, 4, 7, 6783, 4, 8, 48240, // 4, 8
+3, 8, 4838, 3, 9, 6530, 4, 8, 7119, 4, 9, 47049, // 4, 9
+3, 9, 5350, 3, 10, 7342, 4, 9, 7698, 4, 10, 45146, // 4,10
+3, 10, 5965, 3, 11, 8332, 4, 10, 8378, 4, 11, 42861, // 4,11
+3, 11, 6615, 3, 12, 9421, 4, 11, 9056, 4, 12, 40444, // 4,12
+3, 12, 7261, 3, 13, 10559, 4, 12, 9674, 4, 13, 38042, // 4,13
+3, 13, 7881, 3, 14, 11721, 4, 13, 10204, 4, 14, 35730, // 4,14
+3, 14, 8463, 3, 15, 12899, 4, 14, 10635, 4, 15, 33539, // 4,15
+5, -1, 9995, 5, 0, 34567, 6, -1, 8107, 6, 0, 12867, // 5, 0
+5, 0, 9509, 5, 1, 36955, 6, 0, 7497, 6, 1, 11575, // 5, 1
+5, 1, 8902, 5, 2, 39526, 6, 1, 6829, 6, 2, 10279, // 5, 2
+5, 2, 8175, 5, 3, 42271, 6, 2, 6108, 6, 3, 8982, // 5, 3
+5, 3, 7342, 5, 4, 45146, 6, 3, 5350, 6, 4, 7698, // 5, 4
+5, 4, 6451, 5, 5, 48019, 6, 4, 4591, 6, 5, 6475, // 5, 5
+5, 5, 5624, 5, 6, 50581, 6, 5, 3913, 6, 6, 5418, // 5, 6
+5, 6, 5092, 5, 7, 52253, 6, 6, 3470, 6, 7, 4721, // 5, 7
+4, 7, 3466, 4, 8, 4708, 5, 7, 5097, 5, 8, 52265, // 5, 8
+4, 8, 3911, 4, 9, 5400, 5, 8, 5637, 5, 9, 50588, // 5, 9
+4, 9, 4591, 4, 10, 6451, 5, 9, 6475, 5, 10, 48019, // 5,10
+4, 10, 5353, 4, 11, 7667, 5, 10, 7377, 5, 11, 45139, // 5,11
+4, 11, 6116, 4, 12, 8940, 5, 11, 8224, 5, 12, 42256, // 5,12
+4, 12, 6842, 4, 13, 10226, 5, 12, 8966, 5, 13, 39502, // 5,13
+4, 13, 7517, 4, 14, 11507, 5, 13, 9587, 5, 14, 36925, // 5,14
+4, 14, 8135, 4, 15, 12783, 5, 14, 10086, 5, 15, 34532, // 5,15
+6, -1, 9558, 6, 0, 35362, 7, -1, 7839, 7, 0, 12777, // 6, 0
+6, 0, 9020, 6, 1, 37906, 7, 0, 7202, 7, 1, 11408, // 6, 1
+6, 1, 8344, 6, 2, 40688, 7, 1, 6491, 7, 2, 10013, // 6, 2
+6, 2, 7516, 6, 3, 43733, 7, 2, 5703, 7, 3, 8584, // 6, 3
+6, 3, 6530, 6, 4, 47049, 7, 3, 4838, 7, 4, 7119, // 6, 4
+6, 4, 5400, 6, 5, 50587, 7, 4, 3911, 7, 5, 5638, // 6, 5
+6, 5, 4217, 6, 6, 54105, 7, 5, 2989, 7, 6, 4225, // 6, 6
+6, 6, 3303, 6, 7, 56751, 7, 6, 2295, 7, 7, 3187, // 6, 7
+5, 7, 2294, 5, 8, 3180, 6, 7, 3306, 6, 8, 56756, // 6, 8
+5, 8, 2989, 5, 9, 4217, 6, 8, 4225, 6, 9, 54105, // 6, 9
+5, 9, 3913, 5, 10, 5624, 6, 9, 5418, 6, 10, 50581, // 6,10
+5, 10, 4843, 5, 11, 7100, 6, 10, 6558, 6, 11, 47035, // 6,11
+5, 11, 5712, 5, 12, 8558, 6, 11, 7556, 6, 12, 43710, // 6,12
+5, 12, 6506, 5, 13, 9977, 6, 12, 8397, 6, 13, 40656, // 6,13
+5, 13, 7224, 5, 14, 11360, 6, 13, 9086, 6, 14, 37866, // 6,14
+5, 14, 7868, 5, 15, 12717, 6, 14, 9635, 6, 15, 35316, // 6,15
+7, -1, 9224, 7, 0, 35905, 8, -1, 7643, 8, 0, 12764, // 7, 0
+7, 0, 8662, 7, 1, 38534, 8, 0, 6997, 8, 1, 11343, // 7, 1
+7, 1, 7951, 7, 2, 41432, 8, 1, 6266, 8, 2, 9887, // 7, 2
+7, 2, 7072, 7, 3, 44649, 8, 2, 5443, 8, 3, 8372, // 7, 3
+7, 3, 6000, 7, 4, 48240, 8, 3, 4513, 8, 4, 6783, // 7, 4
+7, 4, 4708, 7, 5, 52266, 8, 4, 3466, 8, 5, 5096, // 7, 5
+7, 5, 3180, 7, 6, 56756, 8, 5, 2294, 8, 6, 3306, // 7, 6
+7, 6, 1541, 7, 7, 61364, 8, 6, 1090, 8, 7, 1541, // 7, 7
+6, 7, 1090, 6, 8, 1541, 7, 7, 1542, 7, 8, 61363, // 7, 8
+6, 8, 2295, 6, 9, 3303, 7, 8, 3186, 7, 9, 56752, // 7, 9
+6, 9, 3470, 6, 10, 5092, 7, 9, 4721, 7, 10, 52253, // 7,10
+6, 10, 4521, 6, 11, 6774, 7, 10, 6023, 7, 11, 48218, // 7,11
+6, 11, 5454, 6, 12, 8359, 7, 11, 7106, 7, 12, 44617, // 7,12
+6, 12, 6284, 6, 13, 9867, 7, 12, 7996, 7, 13, 41389, // 7,13
+6, 13, 7020, 6, 14, 11317, 7, 13, 8718, 7, 14, 38481, // 7,14
+6, 14, 7674, 6, 15, 12728, 7, 14, 9290, 7, 15, 35844, // 7,15
+8, 0, 35844, 8, 1, 9290, 9, 0, 12728, 9, 1, 7674, // 8, 0
+8, 1, 38481, 8, 2, 8718, 9, 1, 11317, 9, 2, 7020, // 8, 1
+8, 2, 41389, 8, 3, 7996, 9, 2, 9867, 9, 3, 6284, // 8, 2
+8, 3, 44616, 8, 4, 7106, 9, 3, 8359, 9, 4, 5455, // 8, 3
+8, 4, 48218, 8, 5, 6023, 9, 4, 6774, 9, 5, 4521, // 8, 4
+8, 5, 52253, 8, 6, 4721, 9, 5, 5092, 9, 6, 3470, // 8, 5
+8, 6, 56751, 8, 7, 3186, 9, 6, 3303, 9, 7, 2296, // 8, 6
+8, 7, 61364, 8, 8, 1542, 9, 7, 1541, 9, 8, 1089, // 8, 7
+7, 8, 1542, 7, 9, 1090, 8, 8, 61364, 8, 9, 1540, // 8, 8
+7, 9, 3306, 7, 10, 2294, 8, 9, 56756, 8, 10, 3180, // 8, 9
+7, 10, 5097, 7, 11, 3466, 8, 10, 52266, 8, 11, 4707, // 8,10
+7, 11, 6783, 7, 12, 4513, 8, 11, 48240, 8, 12, 6000, // 8,11
+7, 12, 8373, 7, 13, 5443, 8, 12, 44649, 8, 13, 7071, // 8,12
+7, 13, 9886, 7, 14, 6266, 8, 13, 41432, 8, 14, 7952, // 8,13
+7, 14, 11344, 7, 15, 6997, 8, 14, 38534, 8, 15, 8661, // 8,14
+7, 15, 12764, 7, 16, 7643, 8, 15, 35905, 8, 16, 9224, // 8,15
+9, 0, 35315, 9, 1, 9635, 10, 0, 12717, 10, 1, 7869, // 9, 0
+9, 1, 37866, 9, 2, 9086, 10, 1, 11360, 10, 2, 7224, // 9, 1
+9, 2, 40656, 9, 3, 8397, 10, 2, 9977, 10, 3, 6506, // 9, 2
+9, 3, 43710, 9, 4, 7556, 10, 3, 8558, 10, 4, 5712, // 9, 3
+9, 4, 47035, 9, 5, 6558, 10, 4, 7100, 10, 5, 4843, // 9, 4
+9, 5, 50581, 9, 6, 5418, 10, 5, 5624, 10, 6, 3913, // 9, 5
+9, 6, 54105, 9, 7, 4225, 10, 6, 4217, 10, 7, 2989, // 9, 6
+9, 7, 56756, 9, 8, 3306, 10, 7, 3180, 10, 8, 2294, // 9, 7
+8, 8, 3186, 8, 9, 2295, 9, 8, 56751, 9, 9, 3304, // 9, 8
+8, 9, 4225, 8, 10, 2989, 9, 9, 54105, 9, 10, 4217, // 9, 9
+8, 10, 5637, 8, 11, 3911, 9, 10, 50587, 9, 11, 5401, // 9,10
+8, 11, 7119, 8, 12, 4838, 9, 11, 47049, 9, 12, 6530, // 9,11
+8, 12, 8584, 8, 13, 5703, 9, 12, 43733, 9, 13, 7516, // 9,12
+8, 13, 10013, 8, 14, 6491, 9, 13, 40688, 9, 14, 8344, // 9,13
+8, 14, 11407, 8, 15, 7202, 9, 14, 37906, 9, 15, 9021, // 9,14
+8, 15, 12777, 8, 16, 7839, 9, 15, 35362, 9, 16, 9558, // 9,15
+10, 0, 34532, 10, 1, 10086, 11, 0, 12783, 11, 1, 8135, // 10, 0
+10, 1, 36926, 10, 2, 9587, 11, 1, 11507, 11, 2, 7516, // 10, 1
+10, 2, 39503, 10, 3, 8966, 11, 2, 10226, 11, 3, 6841, // 10, 2
+10, 3, 42256, 10, 4, 8224, 11, 3, 8940, 11, 4, 6116, // 10, 3
+10, 4, 45139, 10, 5, 7377, 11, 4, 7667, 11, 5, 5353, // 10, 4
+10, 5, 48019, 10, 6, 6475, 11, 5, 6451, 11, 6, 4591, // 10, 5
+10, 6, 50587, 10, 7, 5637, 11, 6, 5400, 11, 7, 3912, // 10, 6
+10, 7, 52266, 10, 8, 5097, 11, 7, 4708, 11, 8, 3465, // 10, 7
+9, 8, 4721, 9, 9, 3470, 10, 8, 52253, 10, 9, 5092, // 10, 8
+9, 9, 5418, 9, 10, 3913, 10, 9, 50581, 10, 10, 5624, // 10, 9
+9, 10, 6475, 9, 11, 4591, 10, 10, 48019, 10, 11, 6451, // 10,10
+9, 11, 7698, 9, 12, 5350, 10, 11, 45146, 10, 12, 7342, // 10,11
+9, 12, 8982, 9, 13, 6108, 10, 12, 42271, 10, 13, 8175, // 10,12
+9, 13, 10279, 9, 14, 6829, 10, 13, 39526, 10, 14, 8902, // 10,13
+9, 14, 11575, 9, 15, 7497, 10, 14, 36955, 10, 15, 9509, // 10,14
+9, 15, 12867, 9, 16, 8107, 10, 15, 34567, 10, 16, 9995, // 10,15
+11, 0, 33539, 11, 1, 10635, 12, 0, 12899, 12, 1, 8463, // 11, 0
+11, 1, 35730, 11, 2, 10204, 12, 1, 11721, 12, 2, 7881, // 11, 1
+11, 2, 38042, 11, 3, 9674, 12, 2, 10559, 12, 3, 7261, // 11, 2
+11, 3, 40444, 11, 4, 9056, 12, 3, 9421, 12, 4, 6615, // 11, 3
+11, 4, 42861, 11, 5, 8378, 12, 4, 8332, 12, 5, 5965, // 11, 4
+11, 5, 45146, 11, 6, 7698, 12, 5, 7342, 12, 6, 5350, // 11, 5
+11, 6, 47049, 11, 7, 7119, 12, 6, 6530, 12, 7, 4838, // 11, 6
+11, 7, 48240, 11, 8, 6783, 12, 7, 6000, 12, 8, 4513, // 11, 7
+10, 8, 6023, 10, 9, 4521, 11, 8, 48218, 11, 9, 6774, // 11, 8
+10, 9, 6558, 10, 10, 4843, 11, 9, 47035, 11, 10, 7100, // 11, 9
+10, 10, 7377, 10, 11, 5353, 11, 10, 45139, 11, 11, 7667, // 11,10
+10, 11, 8378, 10, 12, 5965, 11, 11, 42861, 11, 12, 8332, // 11,11
+10, 12, 9478, 10, 13, 6611, 11, 12, 40452, 11, 13, 8995, // 11,12
+10, 13, 10630, 10, 14, 7252, 11, 13, 38057, 11, 14, 9597, // 11,13
+10, 14, 11810, 10, 15, 7865, 11, 14, 35750, 11, 15, 10111, // 11,14
+10, 15, 13007, 10, 16, 8438, 11, 15, 33564, 11, 16, 10527, // 11,15
+12, 0, 32391, 12, 1, 11269, 13, 0, 13038, 13, 1, 8838, // 12, 0
+12, 1, 34358, 12, 2, 10918, 13, 1, 11964, 13, 2, 8296, // 12, 1
+12, 2, 36392, 12, 3, 10488, 13, 2, 10922, 13, 3, 7734, // 12, 2
+12, 3, 38450, 12, 4, 9998, 13, 3, 9924, 13, 4, 7164, // 12, 3
+12, 4, 40452, 12, 5, 9478, 13, 4, 8995, 13, 5, 6611, // 12, 4
+12, 5, 42271, 12, 6, 8982, 13, 5, 8175, 13, 6, 6108, // 12, 5
+12, 6, 43733, 12, 7, 8584, 13, 6, 7516, 13, 7, 5703, // 12, 6
+12, 7, 44649, 12, 8, 8373, 13, 7, 7072, 13, 8, 5442, // 12, 7
+11, 8, 7106, 11, 9, 5454, 12, 8, 44616, 12, 9, 8360, // 12, 8
+11, 9, 7556, 11, 10, 5712, 12, 9, 43710, 12, 10, 8558, // 12, 9
+11, 10, 8224, 11, 11, 6116, 12, 10, 42256, 12, 11, 8940, // 12,10
+11, 11, 9056, 11, 12, 6615, 12, 11, 40444, 12, 12, 9421, // 12,11
+11, 12, 9998, 11, 13, 7164, 12, 12, 38450, 12, 13, 9924, // 12,12
+11, 13, 11012, 11, 14, 7728, 12, 13, 36399, 12, 14, 10397, // 12,13
+11, 14, 12074, 11, 15, 8284, 12, 14, 34369, 12, 15, 10809, // 12,14
+11, 15, 13171, 11, 16, 8816, 12, 15, 32406, 12, 16, 11143, // 12,15
+13, 0, 31138, 13, 1, 11977, 14, 0, 13176, 14, 1, 9245, // 13, 0
+13, 1, 32881, 13, 2, 11709, 14, 1, 12203, 14, 2, 8743, // 13, 1
+13, 2, 34650, 13, 3, 11382, 14, 2, 11272, 14, 3, 8232, // 13, 2
+13, 3, 36399, 13, 4, 11012, 14, 3, 10397, 14, 4, 7728, // 13, 3
+13, 4, 38057, 13, 5, 10630, 14, 4, 9597, 14, 5, 7252, // 13, 4
+13, 5, 39526, 13, 6, 10279, 14, 5, 8902, 14, 6, 6829, // 13, 5
+13, 6, 40688, 13, 7, 10013, 14, 6, 8344, 14, 7, 6491, // 13, 6
+13, 7, 41432, 13, 8, 9886, 14, 7, 7951, 14, 8, 6267, // 13, 7
+12, 8, 7996, 12, 9, 6284, 13, 8, 41389, 13, 9, 9867, // 13, 8
+12, 9, 8397, 12, 10, 6506, 13, 9, 40656, 13, 10, 9977, // 13, 9
+12, 10, 8966, 12, 11, 6842, 13, 10, 39503, 13, 11, 10225, // 13,10
+12, 11, 9674, 12, 12, 7261, 13, 11, 38042, 13, 12, 10559, // 13,11
+12, 12, 10488, 12, 13, 7734, 13, 12, 36392, 13, 13, 10922, // 13,12
+12, 13, 11382, 12, 14, 8232, 13, 13, 34650, 13, 14, 11272, // 13,13
+12, 14, 12334, 12, 15, 8735, 13, 14, 32886, 13, 15, 11581, // 13,14
+12, 15, 13332, 12, 16, 9229, 13, 15, 31146, 13, 16, 11829, // 13,15
+14, 0, 29828, 14, 1, 12746, 15, 0, 13291, 15, 1, 9671, // 14, 0
+14, 1, 31358, 14, 2, 12564, 15, 1, 12412, 15, 2, 9202, // 14, 1
+14, 2, 32886, 14, 3, 12334, 15, 2, 11580, 15, 3, 8736, // 14, 2
+14, 3, 34369, 14, 4, 12074, 15, 3, 10808, 15, 4, 8285, // 14, 3
+14, 4, 35750, 14, 5, 11810, 15, 4, 10111, 15, 5, 7865, // 14, 4
+14, 5, 36955, 14, 6, 11575, 15, 5, 9509, 15, 6, 7497, // 14, 5
+14, 6, 37906, 14, 7, 11407, 15, 6, 9020, 15, 7, 7203, // 14, 6
+14, 7, 38534, 14, 8, 11344, 15, 7, 8662, 15, 8, 6996, // 14, 7
+13, 8, 8718, 13, 9, 7020, 14, 8, 38481, 14, 9, 11317, // 14, 8
+13, 9, 9086, 13, 10, 7224, 14, 9, 37866, 14, 10, 11360, // 14, 9
+13, 10, 9587, 13, 11, 7517, 14, 10, 36926, 14, 11, 11506, // 14,10
+13, 11, 10204, 13, 12, 7881, 14, 11, 35730, 14, 12, 11721, // 14,11
+13, 12, 10918, 13, 13, 8296, 14, 12, 34358, 14, 13, 11964, // 14,12
+13, 13, 11709, 13, 14, 8742, 14, 13, 32881, 14, 14, 12204, // 14,13
+13, 14, 12564, 13, 15, 9202, 14, 14, 31358, 14, 15, 12412, // 14,14
+13, 15, 13470, 13, 16, 9662, 14, 15, 29831, 14, 16, 12573, // 14,15
+15, 0, 28495, 15, 1, 13569, 16, 0, 13368, 16, 1, 10104, // 15, 0
+15, 1, 29831, 15, 2, 13470, 16, 1, 12574, 16, 2, 9661, // 15, 1
+15, 2, 31146, 15, 3, 13332, 16, 2, 11829, 16, 3, 9229, // 15, 2
+15, 3, 32406, 15, 4, 13171, 16, 3, 11143, 16, 4, 8816, // 15, 3
+15, 4, 33564, 15, 5, 13007, 16, 4, 10528, 16, 5, 8437, // 15, 4
+15, 5, 34567, 15, 6, 12867, 16, 5, 9995, 16, 6, 8107, // 15, 5
+15, 6, 35362, 15, 7, 12777, 16, 6, 9558, 16, 7, 7839, // 15, 6
+15, 7, 35905, 15, 8, 12764, 16, 7, 9224, 16, 8, 7643, // 15, 7
+14, 8, 9290, 14, 9, 7674, 15, 8, 35844, 15, 9, 12728, // 15, 8
+14, 9, 9635, 14, 10, 7868, 15, 9, 35315, 15, 10, 12718, // 15, 9
+14, 10, 10086, 14, 11, 8135, 15, 10, 34532, 15, 11, 12783, // 15,10
+14, 11, 10635, 14, 12, 8463, 15, 11, 33539, 15, 12, 12899, // 15,11
+14, 12, 11269, 14, 13, 8838, 15, 12, 32391, 15, 13, 13038, // 15,12
+14, 13, 11977, 14, 14, 9245, 15, 13, 31138, 15, 14, 13176, // 15,13
+14, 14, 12746, 14, 15, 9671, 15, 14, 29828, 15, 15, 13291, // 15,14
+14, 15, 13569, 14, 16, 10104, 15, 15, 28495, 15, 16, 13368, // 15,15
+// angle of 2.5 degrees
+0, -1, 14696, 0, 0, 24063, 1, -1, 11702, 1, 0, 15075, // 0, 0
+0, 0, 14872, 0, 1, 25368, 1, 0, 11187, 1, 1, 14109, // 0, 1
+0, 1, 14990, 0, 2, 26660, 1, 1, 10676, 1, 2, 13210, // 0, 2
+0, 2, 15060, 0, 3, 27903, 1, 2, 10185, 1, 3, 12388, // 0, 3
+0, 3, 15100, 0, 4, 29055, 1, 3, 9728, 1, 4, 11653, // 0, 4
+0, 4, 15135, 0, 5, 30064, 1, 4, 9323, 1, 5, 11014, // 0, 5
+0, 5, 15193, 0, 6, 30876, 1, 5, 8986, 1, 6, 10481, // 0, 6
+0, 6, 15301, 0, 7, 31444, 1, 6, 8727, 1, 7, 10064, // 0, 7
+-1, 7, 8669, -1, 8, 9959, 0, 7, 15376, 0, 8, 31532, // 0, 8
+-1, 8, 8927, -1, 9, 10351, 0, 8, 15319, 0, 9, 30939, // 0, 9
+-1, 9, 9265, -1, 10, 10855, 0, 9, 15311, 0, 10, 30105, // 0,10
+-1, 10, 9673, -1, 11, 11461, 0, 10, 15325, 0, 11, 29077, // 0,11
+-1, 11, 10135, -1, 12, 12159, 0, 11, 15330, 0, 12, 27912, // 0,12
+-1, 12, 10637, -1, 13, 12938, 0, 12, 15301, 0, 13, 26660, // 0,13
+-1, 13, 11164, -1, 14, 13787, 0, 13, 15220, 0, 14, 25365, // 0,14
+-1, 14, 11702, -1, 15, 14696, 0, 14, 15076, 0, 15, 24062, // 0,15
+1, -1, 13787, 1, 0, 25366, 2, -1, 11164, 2, 0, 15219, // 1, 0
+1, 0, 13853, 1, 1, 26893, 2, 0, 10644, 2, 1, 14146, // 1, 1
+1, 1, 13850, 1, 2, 28427, 2, 1, 10119, 2, 2, 13140, // 1, 2
+1, 2, 13789, 1, 3, 29928, 2, 2, 9603, 2, 3, 12216, // 1, 3
+1, 3, 13694, 1, 4, 31339, 2, 3, 9118, 2, 4, 11385, // 1, 4
+1, 4, 13600, 1, 5, 32586, 2, 4, 8685, 2, 5, 10665, // 1, 5
+1, 5, 13548, 1, 6, 33585, 2, 5, 8329, 2, 6, 10074, // 1, 6
+1, 6, 13582, 1, 7, 34261, 2, 6, 8068, 2, 7, 9625, // 1, 7
+0, 7, 8024, 0, 8, 9534, 1, 7, 13638, 1, 8, 34340, // 1, 8
+0, 8, 8286, 0, 9, 9961, 1, 8, 13647, 1, 9, 33642, // 1, 9
+0, 9, 8645, 0, 10, 10528, 1, 9, 13740, 1, 10, 32623, // 1,10
+0, 10, 9082, 0, 11, 11218, 1, 10, 13875, 1, 11, 31361, // 1,11
+0, 11, 9575, 0, 12, 12014, 1, 11, 14009, 1, 12, 29938, // 1,12
+0, 12, 10102, 0, 13, 12897, 1, 12, 14107, 1, 13, 28430, // 1,13
+0, 13, 10644, 0, 14, 13853, 1, 13, 14145, 1, 14, 26894, // 1,14
+0, 14, 11187, 0, 15, 14872, 1, 14, 14109, 1, 15, 25368, // 1,15
+2, -1, 12938, 2, 0, 26660, 3, -1, 10637, 3, 0, 15301, // 2, 0
+2, 0, 12897, 2, 1, 28430, 3, 0, 10102, 3, 1, 14107, // 2, 1
+2, 1, 12769, 2, 2, 30239, 3, 1, 9546, 3, 2, 12982, // 2, 2
+2, 2, 12569, 2, 3, 32045, 3, 2, 8988, 3, 3, 11934, // 2, 3
+2, 3, 12323, 2, 4, 33777, 3, 3, 8452, 3, 4, 10984, // 2, 4
+2, 4, 12079, 2, 5, 35332, 3, 4, 7969, 3, 5, 10156, // 2, 5
+2, 5, 11897, 2, 6, 36582, 3, 5, 7573, 3, 6, 9484, // 2, 6
+2, 6, 11842, 2, 7, 37402, 3, 6, 7298, 3, 7, 8994, // 2, 7
+1, 7, 7266, 1, 8, 8918, 2, 7, 11883, 2, 8, 37469, // 2, 8
+1, 8, 7543, 1, 9, 9390, 2, 8, 11972, 2, 9, 36631, // 2, 9
+1, 9, 7943, 1, 10, 10041, 2, 9, 12188, 2, 10, 35364, // 2,10
+1, 10, 8432, 1, 11, 10842, 2, 10, 12467, 2, 11, 33795, // 2,11
+1, 11, 8976, 1, 12, 11760, 2, 11, 12747, 2, 12, 32053, // 2,12
+1, 12, 9546, 1, 13, 12769, 2, 12, 12982, 2, 13, 30239, // 2,13
+1, 13, 10119, 1, 14, 13850, 2, 13, 13141, 2, 14, 28426, // 2,14
+1, 14, 10676, 1, 15, 14990, 2, 14, 13211, 2, 15, 26659, // 2,15
+3, -1, 12159, 3, 0, 27912, 4, -1, 10135, 4, 0, 15330, // 3, 0
+3, 0, 12014, 3, 1, 29938, 4, 0, 9575, 4, 1, 14009, // 3, 1
+3, 1, 11760, 3, 2, 32052, 4, 1, 8976, 4, 2, 12748, // 3, 2
+3, 2, 11411, 3, 3, 34213, 4, 2, 8358, 4, 3, 11554, // 3, 3
+3, 3, 10995, 3, 4, 36343, 4, 3, 7746, 4, 4, 10452, // 3, 4
+3, 4, 10569, 3, 5, 38307, 4, 4, 7180, 4, 5, 9480, // 3, 5
+3, 5, 10221, 3, 6, 39912, 4, 5, 6714, 4, 6, 8689, // 3, 6
+3, 6, 10051, 3, 7, 40940, 4, 6, 6403, 4, 7, 8142, // 3, 7
+2, 7, 6381, 2, 8, 8082, 3, 7, 10079, 3, 8, 40994, // 3, 8
+2, 8, 6695, 2, 9, 8617, 3, 8, 10275, 3, 9, 39949, // 3, 9
+2, 9, 7165, 2, 10, 9388, 3, 9, 10653, 3, 10, 38330, // 3,10
+2, 10, 7737, 2, 11, 10337, 3, 10, 11108, 3, 11, 36354, // 3,11
+2, 11, 8358, 2, 12, 11411, 3, 11, 11554, 3, 12, 34213, // 3,12
+2, 12, 8988, 2, 13, 12569, 3, 12, 11934, 3, 13, 32045, // 3,13
+2, 13, 9603, 2, 14, 13789, 3, 13, 12216, 3, 14, 29928, // 3,14
+2, 14, 10185, 2, 15, 15060, 3, 14, 12388, 3, 15, 27903, // 3,15
+4, -1, 11461, 4, 0, 29078, 5, -1, 9673, 5, 0, 15324, // 4, 0
+4, 0, 11218, 4, 1, 31361, 5, 0, 9082, 5, 1, 13875, // 4, 1
+4, 1, 10842, 4, 2, 33795, 5, 1, 8432, 5, 2, 12467, // 4, 2
+4, 2, 10337, 4, 3, 36354, 5, 2, 7737, 5, 3, 11108, // 4, 3
+4, 3, 9730, 4, 4, 38966, 5, 3, 7022, 5, 4, 9818, // 4, 4
+4, 4, 9081, 4, 5, 41475, 5, 4, 6334, 5, 5, 8646, // 4, 5
+4, 5, 8507, 4, 6, 43602, 5, 5, 5749, 5, 6, 7678, // 4, 6
+4, 6, 8177, 4, 7, 44962, 5, 6, 5368, 5, 7, 7029, // 4, 7
+3, 7, 5354, 3, 8, 6987, 4, 7, 8195, 4, 8, 45000, // 4, 8
+3, 8, 5739, 3, 9, 7626, 4, 8, 8545, 4, 9, 43626, // 4, 9
+3, 9, 6328, 3, 10, 8578, 4, 9, 9143, 4, 10, 41487, // 4,10
+3, 10, 7022, 3, 11, 9730, 4, 10, 9818, 4, 11, 38966, // 4,11
+3, 11, 7746, 3, 12, 10995, 4, 11, 10452, 4, 12, 36343, // 4,12
+3, 12, 8452, 3, 13, 12323, 4, 12, 10983, 4, 13, 33778, // 4,13
+3, 13, 9118, 3, 14, 13694, 4, 13, 11385, 4, 14, 31339, // 4,14
+3, 14, 9728, 3, 15, 15100, 4, 14, 11652, 4, 15, 29056, // 4,15
+5, -1, 10855, 5, 0, 30105, 6, -1, 9265, 6, 0, 15311, // 5, 0
+5, 0, 10528, 5, 1, 32624, 6, 0, 8645, 6, 1, 13739, // 5, 1
+5, 1, 10041, 5, 2, 35364, 6, 1, 7943, 6, 2, 12188, // 5, 2
+5, 2, 9388, 5, 3, 38330, 6, 2, 7165, 6, 3, 10653, // 5, 3
+5, 3, 8578, 5, 4, 41487, 6, 3, 6328, 6, 4, 9143, // 5, 4
+5, 4, 7659, 5, 5, 44700, 6, 4, 5472, 6, 5, 7705, // 5, 5
+5, 5, 6768, 5, 6, 47619, 6, 5, 4694, 6, 6, 6455, // 5, 6
+5, 6, 6183, 5, 7, 49566, 6, 6, 4172, 6, 7, 5615, // 5, 7
+4, 7, 4164, 4, 8, 5590, 5, 7, 6193, 5, 8, 49589, // 5, 8
+4, 8, 4690, 4, 9, 6422, 5, 8, 6794, 5, 9, 47630, // 5, 9
+4, 9, 5472, 4, 10, 7659, 5, 9, 7705, 5, 10, 44700, // 5,10
+4, 10, 6334, 4, 11, 9081, 5, 10, 8646, 5, 11, 41475, // 5,11
+4, 11, 7180, 4, 12, 10569, 5, 11, 9479, 5, 12, 38308, // 5,12
+4, 12, 7969, 4, 13, 12079, 5, 12, 10156, 5, 13, 35332, // 5,13
+4, 13, 8685, 4, 14, 13600, 5, 13, 10665, 5, 14, 32586, // 5,14
+4, 14, 9323, 4, 15, 15135, 5, 14, 11013, 5, 15, 30065, // 5,15
+6, -1, 10351, 6, 0, 30939, 7, -1, 8927, 7, 0, 15319, // 6, 0
+6, 0, 9961, 6, 1, 33642, 7, 0, 8286, 7, 1, 13647, // 6, 1
+6, 1, 9390, 6, 2, 36631, 7, 1, 7543, 7, 2, 11972, // 6, 2
+6, 2, 8617, 6, 3, 39949, 7, 2, 6695, 7, 3, 10275, // 6, 3
+6, 3, 7626, 6, 4, 43626, 7, 3, 5739, 7, 4, 8545, // 6, 4
+6, 4, 6422, 6, 5, 47630, 7, 4, 4690, 7, 5, 6794, // 6, 5
+6, 5, 5099, 6, 6, 51701, 7, 5, 3620, 7, 6, 5116, // 6, 6
+6, 6, 4044, 6, 7, 54831, 7, 6, 2797, 7, 7, 3864, // 6, 7
+5, 7, 2795, 5, 8, 3853, 6, 7, 4049, 6, 8, 54839, // 6, 8
+5, 8, 3620, 5, 9, 5099, 6, 8, 5116, 6, 9, 51701, // 6, 9
+5, 9, 4694, 5, 10, 6768, 6, 9, 6455, 6, 10, 47619, // 6,10
+5, 10, 5749, 5, 11, 8507, 6, 10, 7678, 6, 11, 43602, // 6,11
+5, 11, 6714, 5, 12, 10221, 6, 11, 8690, 6, 12, 39911, // 6,12
+5, 12, 7573, 5, 13, 11897, 6, 12, 9484, 6, 13, 36582, // 6,13
+5, 13, 8329, 5, 14, 13548, 6, 13, 10074, 6, 14, 33585, // 6,14
+5, 14, 8986, 5, 15, 15193, 6, 14, 10482, 6, 15, 30875, // 6,15
+7, -1, 9959, 7, 0, 31532, 8, -1, 8669, 8, 0, 15376, // 7, 0
+7, 0, 9534, 7, 1, 34340, 8, 0, 8024, 8, 1, 13638, // 7, 1
+7, 1, 8918, 7, 2, 37470, 8, 1, 7266, 8, 2, 11882, // 7, 2
+7, 2, 8082, 7, 3, 40994, 8, 2, 6381, 8, 3, 10079, // 7, 3
+7, 3, 6987, 7, 4, 44999, 8, 3, 5354, 8, 4, 8196, // 7, 4
+7, 4, 5590, 7, 5, 49588, 8, 4, 4164, 8, 5, 6194, // 7, 5
+7, 5, 3853, 7, 6, 54839, 8, 5, 2795, 8, 6, 4049, // 7, 6
+7, 6, 1903, 7, 7, 60382, 8, 6, 1347, 8, 7, 1904, // 7, 7
+6, 7, 1347, 6, 8, 1903, 7, 7, 1905, 7, 8, 60381, // 7, 8
+6, 8, 2797, 6, 9, 4044, 7, 8, 3864, 7, 9, 54831, // 7, 9
+6, 9, 4172, 6, 10, 6183, 7, 9, 5615, 7, 10, 49566, // 7,10
+6, 10, 5368, 6, 11, 8177, 7, 10, 7029, 7, 11, 44962, // 7,11
+6, 11, 6403, 6, 12, 10051, 7, 11, 8141, 7, 12, 40941, // 7,12
+6, 12, 7298, 6, 13, 11842, 7, 12, 8994, 7, 13, 37402, // 7,13
+6, 13, 8068, 6, 14, 13582, 7, 13, 9626, 7, 14, 34260, // 7,14
+6, 14, 8727, 6, 15, 15301, 7, 14, 10065, 7, 15, 31443, // 7,15
+8, 0, 31444, 8, 1, 10065, 9, 0, 15301, 9, 1, 8726, // 8, 0
+8, 1, 34261, 8, 2, 9626, 9, 1, 13582, 9, 2, 8067, // 8, 1
+8, 2, 37402, 8, 3, 8994, 9, 2, 11842, 9, 3, 7298, // 8, 2
+8, 3, 40940, 8, 4, 8141, 9, 3, 10051, 9, 4, 6404, // 8, 3
+8, 4, 44962, 8, 5, 7029, 9, 4, 8177, 9, 5, 5368, // 8, 4
+8, 5, 49566, 8, 6, 5615, 9, 5, 6183, 9, 6, 4172, // 8, 5
+8, 6, 54831, 8, 7, 3864, 9, 6, 4044, 9, 7, 2797, // 8, 6
+8, 7, 60382, 8, 8, 1905, 9, 7, 1903, 9, 8, 1346, // 8, 7
+7, 8, 1905, 7, 9, 1347, 8, 8, 60382, 8, 9, 1902, // 8, 8
+7, 9, 4049, 7, 10, 2795, 8, 9, 54839, 8, 10, 3853, // 8, 9
+7, 10, 6193, 7, 11, 4164, 8, 10, 49588, 8, 11, 5591, // 8,10
+7, 11, 8195, 7, 12, 5354, 8, 11, 44999, 8, 12, 6988, // 8,11
+7, 12, 10079, 7, 13, 6381, 8, 12, 40994, 8, 13, 8082, // 8,12
+7, 13, 11883, 7, 14, 7266, 8, 13, 37470, 8, 14, 8917, // 8,13
+7, 14, 13638, 7, 15, 8024, 8, 14, 34340, 8, 15, 9534, // 8,14
+7, 15, 15376, 7, 16, 8669, 8, 15, 31532, 8, 16, 9959, // 8,15
+9, 0, 30876, 9, 1, 10482, 10, 0, 15193, 10, 1, 8985, // 9, 0
+9, 1, 33585, 9, 2, 10074, 10, 1, 13548, 10, 2, 8329, // 9, 1
+9, 2, 36582, 9, 3, 9484, 10, 2, 11897, 10, 3, 7573, // 9, 2
+9, 3, 39912, 9, 4, 8690, 10, 3, 10221, 10, 4, 6713, // 9, 3
+9, 4, 43602, 9, 5, 7678, 10, 4, 8507, 10, 5, 5749, // 9, 4
+9, 5, 47619, 9, 6, 6455, 10, 5, 6768, 10, 6, 4694, // 9, 5
+9, 6, 51701, 9, 7, 5116, 10, 6, 5099, 10, 7, 3620, // 9, 6
+9, 7, 54839, 9, 8, 4049, 10, 7, 3853, 10, 8, 2795, // 9, 7
+8, 8, 3864, 8, 9, 2797, 9, 8, 54831, 9, 9, 4044, // 9, 8
+8, 9, 5116, 8, 10, 3620, 9, 9, 51701, 9, 10, 5099, // 9, 9
+8, 10, 6794, 8, 11, 4690, 9, 10, 47630, 9, 11, 6422, // 9,10
+8, 11, 8545, 8, 12, 5739, 9, 11, 43626, 9, 12, 7626, // 9,11
+8, 12, 10275, 8, 13, 6695, 9, 12, 39949, 9, 13, 8617, // 9,12
+8, 13, 11972, 8, 14, 7543, 9, 13, 36631, 9, 14, 9390, // 9,13
+8, 14, 13647, 8, 15, 8286, 9, 14, 33642, 9, 15, 9961, // 9,14
+8, 15, 15319, 8, 16, 8927, 9, 15, 30939, 9, 16, 10351, // 9,15
+10, 0, 30064, 10, 1, 11013, 11, 0, 15135, 11, 1, 9324, // 10, 0
+10, 1, 32586, 10, 2, 10665, 11, 1, 13600, 11, 2, 8685, // 10, 1
+10, 2, 35332, 10, 3, 10156, 11, 2, 12079, 11, 3, 7969, // 10, 2
+10, 3, 38307, 10, 4, 9479, 11, 3, 10569, 11, 4, 7181, // 10, 3
+10, 4, 41475, 10, 5, 8646, 11, 4, 9081, 11, 5, 6334, // 10, 4
+10, 5, 44700, 10, 6, 7705, 11, 5, 7659, 11, 6, 5472, // 10, 5
+10, 6, 47630, 10, 7, 6794, 11, 6, 6422, 11, 7, 4690, // 10, 6
+10, 7, 49588, 10, 8, 6193, 11, 7, 5590, 11, 8, 4165, // 10, 7
+9, 8, 5615, 9, 9, 4172, 10, 8, 49566, 10, 9, 6183, // 10, 8
+9, 9, 6455, 9, 10, 4694, 10, 9, 47619, 10, 10, 6768, // 10, 9
+9, 10, 7705, 9, 11, 5472, 10, 10, 44700, 10, 11, 7659, // 10,10
+9, 11, 9143, 9, 12, 6328, 10, 11, 41487, 10, 12, 8578, // 10,11
+9, 12, 10653, 9, 13, 7165, 10, 12, 38330, 10, 13, 9388, // 10,12
+9, 13, 12188, 9, 14, 7943, 10, 13, 35364, 10, 14, 10041, // 10,13
+9, 14, 13740, 9, 15, 8645, 10, 14, 32624, 10, 15, 10527, // 10,14
+9, 15, 15311, 9, 16, 9265, 10, 15, 30105, 10, 16, 10855, // 10,15
+11, 0, 29055, 11, 1, 11652, 12, 0, 15100, 12, 1, 9729, // 11, 0
+11, 1, 31339, 11, 2, 11385, 12, 1, 13694, 12, 2, 9118, // 11, 1
+11, 2, 33777, 11, 3, 10983, 12, 2, 12323, 12, 3, 8453, // 11, 2
+11, 3, 36343, 11, 4, 10452, 12, 3, 10995, 12, 4, 7746, // 11, 3
+11, 4, 38966, 11, 5, 9818, 12, 4, 9730, 12, 5, 7022, // 11, 4
+11, 5, 41487, 11, 6, 9143, 12, 5, 8578, 12, 6, 6328, // 11, 5
+11, 6, 43626, 11, 7, 8545, 12, 6, 7626, 12, 7, 5739, // 11, 6
+11, 7, 44999, 11, 8, 8195, 12, 7, 6987, 12, 8, 5355, // 11, 7
+10, 8, 7029, 10, 9, 5368, 11, 8, 44962, 11, 9, 8177, // 11, 8
+10, 9, 7678, 10, 10, 5749, 11, 9, 43602, 11, 10, 8507, // 11, 9
+10, 10, 8646, 10, 11, 6334, 11, 10, 41475, 11, 11, 9081, // 11,10
+10, 11, 9818, 10, 12, 7022, 11, 11, 38966, 11, 12, 9730, // 11,11
+10, 12, 11108, 10, 13, 7737, 11, 12, 36354, 11, 13, 10337, // 11,12
+10, 13, 12467, 10, 14, 8432, 11, 13, 33795, 11, 14, 10842, // 11,13
+10, 14, 13875, 10, 15, 9082, 11, 14, 31361, 11, 15, 11218, // 11,14
+10, 15, 15325, 10, 16, 9673, 11, 15, 29078, 11, 16, 11460, // 11,15
+12, 0, 27903, 12, 1, 12388, 13, 0, 15060, 13, 1, 10185, // 12, 0
+12, 1, 29928, 12, 2, 12216, 13, 1, 13789, 13, 2, 9603, // 12, 1
+12, 2, 32045, 12, 3, 11934, 13, 2, 12569, 13, 3, 8988, // 12, 2
+12, 3, 34213, 12, 4, 11554, 13, 3, 11411, 13, 4, 8358, // 12, 3
+12, 4, 36354, 12, 5, 11108, 13, 4, 10337, 13, 5, 7737, // 12, 4
+12, 5, 38330, 12, 6, 10653, 13, 5, 9388, 13, 6, 7165, // 12, 5
+12, 6, 39949, 12, 7, 10275, 13, 6, 8617, 13, 7, 6695, // 12, 6
+12, 7, 40994, 12, 8, 10079, 13, 7, 8082, 13, 8, 6381, // 12, 7
+11, 8, 8141, 11, 9, 6403, 12, 8, 40940, 12, 9, 10052, // 12, 8
+11, 9, 8690, 11, 10, 6714, 12, 9, 39912, 12, 10, 10220, // 12, 9
+11, 10, 9479, 11, 11, 7180, 12, 10, 38307, 12, 11, 10570, // 12,10
+11, 11, 10452, 11, 12, 7746, 12, 11, 36343, 12, 12, 10995, // 12,11
+11, 12, 11554, 11, 13, 8358, 12, 12, 34213, 12, 13, 11411, // 12,12
+11, 13, 12747, 11, 14, 8976, 12, 13, 32052, 12, 14, 11761, // 12,13
+11, 14, 14009, 11, 15, 9575, 12, 14, 29938, 12, 15, 12014, // 12,14
+11, 15, 15330, 11, 16, 10135, 12, 15, 27912, 12, 16, 12159, // 12,15
+13, 0, 26660, 13, 1, 13211, 14, 0, 14990, 14, 1, 10675, // 13, 0
+13, 1, 28427, 13, 2, 13141, 14, 1, 13850, 14, 2, 10118, // 13, 1
+13, 2, 30239, 13, 3, 12982, 14, 2, 12769, 14, 3, 9546, // 13, 2
+13, 3, 32052, 13, 4, 12747, 14, 3, 11760, 14, 4, 8977, // 13, 3
+13, 4, 33795, 13, 5, 12467, 14, 4, 10842, 14, 5, 8432, // 13, 4
+13, 5, 35364, 13, 6, 12188, 14, 5, 10041, 14, 6, 7943, // 13, 5
+13, 6, 36631, 13, 7, 11972, 14, 6, 9390, 14, 7, 7543, // 13, 6
+13, 7, 37470, 13, 8, 11883, 14, 7, 8918, 14, 8, 7265, // 13, 7
+12, 8, 8994, 12, 9, 7298, 13, 8, 37402, 13, 9, 11842, // 13, 8
+12, 9, 9484, 12, 10, 7573, 13, 9, 36582, 13, 10, 11897, // 13, 9
+12, 10, 10156, 12, 11, 7969, 13, 10, 35332, 13, 11, 12079, // 13,10
+12, 11, 10983, 12, 12, 8452, 13, 11, 33777, 13, 12, 12324, // 13,11
+12, 12, 11934, 12, 13, 8988, 13, 12, 32045, 13, 13, 12569, // 13,12
+12, 13, 12982, 12, 14, 9546, 13, 13, 30239, 13, 14, 12769, // 13,13
+12, 14, 14107, 12, 15, 10102, 13, 14, 28430, 13, 15, 12897, // 13,14
+12, 15, 15301, 12, 16, 10637, 13, 15, 26660, 13, 16, 12938, // 13,15
+14, 0, 25368, 14, 1, 14109, 15, 0, 14872, 15, 1, 11187, // 14, 0
+14, 1, 26893, 14, 2, 14145, 15, 1, 13853, 15, 2, 10645, // 14, 1
+14, 2, 28430, 14, 3, 14107, 15, 2, 12897, 15, 3, 10102, // 14, 2
+14, 3, 29938, 14, 4, 14009, 15, 3, 12014, 15, 4, 9575, // 14, 3
+14, 4, 31361, 14, 5, 13875, 15, 4, 11218, 15, 5, 9082, // 14, 4
+14, 5, 32624, 14, 6, 13740, 15, 5, 10528, 15, 6, 8644, // 14, 5
+14, 6, 33642, 14, 7, 13647, 15, 6, 9961, 15, 7, 8286, // 14, 6
+14, 7, 34340, 14, 8, 13638, 15, 7, 9534, 15, 8, 8024, // 14, 7
+13, 8, 9626, 13, 9, 8068, 14, 8, 34261, 14, 9, 13581, // 14, 8
+13, 9, 10074, 13, 10, 8329, 14, 9, 33585, 14, 10, 13548, // 14, 9
+13, 10, 10665, 13, 11, 8685, 14, 10, 32586, 14, 11, 13600, // 14,10
+13, 11, 11385, 13, 12, 9118, 14, 11, 31339, 14, 12, 13694, // 14,11
+13, 12, 12216, 13, 13, 9603, 14, 12, 29928, 14, 13, 13789, // 14,12
+13, 13, 13141, 13, 14, 10119, 14, 13, 28427, 14, 14, 13849, // 14,13
+13, 14, 14145, 13, 15, 10644, 14, 14, 26893, 14, 15, 13854, // 14,14
+13, 15, 15220, 13, 16, 11164, 14, 15, 25366, 14, 16, 13786, // 14,15
+15, 0, 24063, 15, 1, 15076, 16, 0, 14696, 16, 1, 11701, // 15, 0
+15, 1, 25366, 15, 2, 15220, 16, 1, 13787, 16, 2, 11163, // 15, 1
+15, 2, 26660, 15, 3, 15301, 16, 2, 12938, 16, 3, 10637, // 15, 2
+15, 3, 27912, 15, 4, 15330, 16, 3, 12159, 16, 4, 10135, // 15, 3
+15, 4, 29078, 15, 5, 15325, 16, 4, 11461, 16, 5, 9672, // 15, 4
+15, 5, 30105, 15, 6, 15311, 16, 5, 10855, 16, 6, 9265, // 15, 5
+15, 6, 30939, 15, 7, 15319, 16, 6, 10351, 16, 7, 8927, // 15, 6
+15, 7, 31532, 15, 8, 15376, 16, 7, 9959, 16, 8, 8669, // 15, 7
+14, 8, 10065, 14, 9, 8727, 15, 8, 31444, 15, 9, 15300, // 15, 8
+14, 9, 10482, 14, 10, 8986, 15, 9, 30876, 15, 10, 15192, // 15, 9
+14, 10, 11013, 14, 11, 9323, 15, 10, 30064, 15, 11, 15136, // 15,10
+14, 11, 11652, 14, 12, 9728, 15, 11, 29055, 15, 12, 15101, // 15,11
+14, 12, 12388, 14, 13, 10185, 15, 12, 27903, 15, 13, 15060, // 15,12
+14, 13, 13211, 14, 14, 10676, 15, 13, 26660, 15, 14, 14989, // 15,13
+14, 14, 14109, 14, 15, 11187, 15, 14, 25368, 15, 15, 14872, // 15,14
+14, 15, 15076, 14, 16, 11702, 15, 15, 24063, 15, 16, 14695, // 15,15
diff --git a/vp8/common/rotate2.h b/vp8/common/rotate2.h
index 580f55279..50080c0ac 100644
--- a/vp8/common/rotate2.h
+++ b/vp8/common/rotate2.h
@@ -1,2827 +1,2827 @@
- // angle of -2.5 degrees
- -1, 0, 14696, -1, 1, 11702, 0, 0, 24063, 0, 1, 15075, // 0, 0
- -1, 1, 13787, -1, 2, 11164, 0, 1, 25366, 0, 2, 15219, // 0, 1
- -1, 2, 12938, -1, 3, 10637, 0, 2, 26660, 0, 3, 15301, // 0, 2
- -1, 3, 12159, -1, 4, 10135, 0, 3, 27912, 0, 4, 15330, // 0, 3
- -1, 4, 11461, -1, 5, 9673, 0, 4, 29078, 0, 5, 15324, // 0, 4
- -1, 5, 10855, -1, 6, 9265, 0, 5, 30105, 0, 6, 15311, // 0, 5
- -1, 6, 10351, -1, 7, 8927, 0, 6, 30939, 0, 7, 15319, // 0, 6
- -1, 7, 9959, -1, 8, 8669, 0, 7, 31532, 0, 8, 15376, // 0, 7
- 0, 8, 31444, 0, 9, 15301, 1, 8, 10065, 1, 9, 8726, // 0, 8
- 0, 9, 30876, 0, 10, 15193, 1, 9, 10482, 1, 10, 8985, // 0, 9
- 0, 10, 30064, 0, 11, 15135, 1, 10, 11013, 1, 11, 9324, // 0,10
- 0, 11, 29055, 0, 12, 15100, 1, 11, 11652, 1, 12, 9729, // 0,11
- 0, 12, 27903, 0, 13, 15060, 1, 12, 12388, 1, 13, 10185, // 0,12
- 0, 13, 26660, 0, 14, 14990, 1, 13, 13211, 1, 14, 10675, // 0,13
- 0, 14, 25368, 0, 15, 14872, 1, 14, 14109, 1, 15, 11187, // 0,14
- 0, 15, 24063, 0, 16, 14696, 1, 15, 15076, 1, 16, 11701, // 0,15
- 0, 0, 14872, 0, 1, 11187, 1, 0, 25368, 1, 1, 14109, // 1, 0
- 0, 1, 13853, 0, 2, 10644, 1, 1, 26893, 1, 2, 14146, // 1, 1
- 0, 2, 12897, 0, 3, 10102, 1, 2, 28430, 1, 3, 14107, // 1, 2
- 0, 3, 12014, 0, 4, 9575, 1, 3, 29938, 1, 4, 14009, // 1, 3
- 0, 4, 11218, 0, 5, 9082, 1, 4, 31361, 1, 5, 13875, // 1, 4
- 0, 5, 10528, 0, 6, 8645, 1, 5, 32624, 1, 6, 13739, // 1, 5
- 0, 6, 9961, 0, 7, 8286, 1, 6, 33642, 1, 7, 13647, // 1, 6
- 0, 7, 9534, 0, 8, 8024, 1, 7, 34340, 1, 8, 13638, // 1, 7
- 1, 8, 34261, 1, 9, 13582, 2, 8, 9626, 2, 9, 8067, // 1, 8
- 1, 9, 33585, 1, 10, 13548, 2, 9, 10074, 2, 10, 8329, // 1, 9
- 1, 10, 32586, 1, 11, 13600, 2, 10, 10665, 2, 11, 8685, // 1,10
- 1, 11, 31339, 1, 12, 13694, 2, 11, 11385, 2, 12, 9118, // 1,11
- 1, 12, 29928, 1, 13, 13789, 2, 12, 12216, 2, 13, 9603, // 1,12
- 1, 13, 28427, 1, 14, 13850, 2, 13, 13141, 2, 14, 10118, // 1,13
- 1, 14, 26893, 1, 15, 13853, 2, 14, 14145, 2, 15, 10645, // 1,14
- 1, 15, 25366, 1, 16, 13787, 2, 15, 15220, 2, 16, 11163, // 1,15
- 1, 0, 14990, 1, 1, 10676, 2, 0, 26660, 2, 1, 13210, // 2, 0
- 1, 1, 13850, 1, 2, 10119, 2, 1, 28427, 2, 2, 13140, // 2, 1
- 1, 2, 12769, 1, 3, 9546, 2, 2, 30239, 2, 3, 12982, // 2, 2
- 1, 3, 11760, 1, 4, 8976, 2, 3, 32052, 2, 4, 12748, // 2, 3
- 1, 4, 10842, 1, 5, 8432, 2, 4, 33795, 2, 5, 12467, // 2, 4
- 1, 5, 10041, 1, 6, 7943, 2, 5, 35364, 2, 6, 12188, // 2, 5
- 1, 6, 9390, 1, 7, 7543, 2, 6, 36631, 2, 7, 11972, // 2, 6
- 1, 7, 8918, 1, 8, 7266, 2, 7, 37470, 2, 8, 11882, // 2, 7
- 2, 8, 37402, 2, 9, 11842, 3, 8, 8994, 3, 9, 7298, // 2, 8
- 2, 9, 36582, 2, 10, 11897, 3, 9, 9484, 3, 10, 7573, // 2, 9
- 2, 10, 35332, 2, 11, 12079, 3, 10, 10156, 3, 11, 7969, // 2,10
- 2, 11, 33777, 2, 12, 12323, 3, 11, 10983, 3, 12, 8453, // 2,11
- 2, 12, 32045, 2, 13, 12569, 3, 12, 11934, 3, 13, 8988, // 2,12
- 2, 13, 30239, 2, 14, 12769, 3, 13, 12982, 3, 14, 9546, // 2,13
- 2, 14, 28430, 2, 15, 12897, 3, 14, 14107, 3, 15, 10102, // 2,14
- 2, 15, 26660, 2, 16, 12938, 3, 15, 15301, 3, 16, 10637, // 2,15
- 2, 0, 15060, 2, 1, 10185, 3, 0, 27903, 3, 1, 12388, // 3, 0
- 2, 1, 13789, 2, 2, 9603, 3, 1, 29928, 3, 2, 12216, // 3, 1
- 2, 2, 12569, 2, 3, 8988, 3, 2, 32045, 3, 3, 11934, // 3, 2
- 2, 3, 11411, 2, 4, 8358, 3, 3, 34213, 3, 4, 11554, // 3, 3
- 2, 4, 10337, 2, 5, 7737, 3, 4, 36354, 3, 5, 11108, // 3, 4
- 2, 5, 9388, 2, 6, 7165, 3, 5, 38330, 3, 6, 10653, // 3, 5
- 2, 6, 8617, 2, 7, 6695, 3, 6, 39949, 3, 7, 10275, // 3, 6
- 2, 7, 8082, 2, 8, 6381, 3, 7, 40994, 3, 8, 10079, // 3, 7
- 3, 8, 40940, 3, 9, 10051, 4, 8, 8141, 4, 9, 6404, // 3, 8
- 3, 9, 39912, 3, 10, 10221, 4, 9, 8690, 4, 10, 6713, // 3, 9
- 3, 10, 38307, 3, 11, 10569, 4, 10, 9479, 4, 11, 7181, // 3,10
- 3, 11, 36343, 3, 12, 10995, 4, 11, 10452, 4, 12, 7746, // 3,11
- 3, 12, 34213, 3, 13, 11411, 4, 12, 11554, 4, 13, 8358, // 3,12
- 3, 13, 32052, 3, 14, 11760, 4, 13, 12747, 4, 14, 8977, // 3,13
- 3, 14, 29938, 3, 15, 12014, 4, 14, 14009, 4, 15, 9575, // 3,14
- 3, 15, 27912, 3, 16, 12159, 4, 15, 15330, 4, 16, 10135, // 3,15
- 3, 0, 15100, 3, 1, 9728, 4, 0, 29055, 4, 1, 11653, // 4, 0
- 3, 1, 13694, 3, 2, 9118, 4, 1, 31339, 4, 2, 11385, // 4, 1
- 3, 2, 12323, 3, 3, 8452, 4, 2, 33777, 4, 3, 10984, // 4, 2
- 3, 3, 10995, 3, 4, 7746, 4, 3, 36343, 4, 4, 10452, // 4, 3
- 3, 4, 9730, 3, 5, 7022, 4, 4, 38966, 4, 5, 9818, // 4, 4
- 3, 5, 8578, 3, 6, 6328, 4, 5, 41487, 4, 6, 9143, // 4, 5
- 3, 6, 7626, 3, 7, 5739, 4, 6, 43626, 4, 7, 8545, // 4, 6
- 3, 7, 6987, 3, 8, 5354, 4, 7, 44999, 4, 8, 8196, // 4, 7
- 4, 8, 44962, 4, 9, 8177, 5, 8, 7029, 5, 9, 5368, // 4, 8
- 4, 9, 43602, 4, 10, 8507, 5, 9, 7678, 5, 10, 5749, // 4, 9
- 4, 10, 41475, 4, 11, 9081, 5, 10, 8646, 5, 11, 6334, // 4,10
- 4, 11, 38966, 4, 12, 9730, 5, 11, 9818, 5, 12, 7022, // 4,11
- 4, 12, 36354, 4, 13, 10337, 5, 12, 11108, 5, 13, 7737, // 4,12
- 4, 13, 33795, 4, 14, 10842, 5, 13, 12467, 5, 14, 8432, // 4,13
- 4, 14, 31361, 4, 15, 11218, 5, 14, 13875, 5, 15, 9082, // 4,14
- 4, 15, 29078, 4, 16, 11461, 5, 15, 15325, 5, 16, 9672, // 4,15
- 4, 0, 15135, 4, 1, 9323, 5, 0, 30064, 5, 1, 11014, // 5, 0
- 4, 1, 13600, 4, 2, 8685, 5, 1, 32586, 5, 2, 10665, // 5, 1
- 4, 2, 12079, 4, 3, 7969, 5, 2, 35332, 5, 3, 10156, // 5, 2
- 4, 3, 10569, 4, 4, 7180, 5, 3, 38307, 5, 4, 9480, // 5, 3
- 4, 4, 9081, 4, 5, 6334, 5, 4, 41475, 5, 5, 8646, // 5, 4
- 4, 5, 7659, 4, 6, 5472, 5, 5, 44700, 5, 6, 7705, // 5, 5
- 4, 6, 6422, 4, 7, 4690, 5, 6, 47630, 5, 7, 6794, // 5, 6
- 4, 7, 5590, 4, 8, 4164, 5, 7, 49588, 5, 8, 6194, // 5, 7
- 5, 8, 49566, 5, 9, 6183, 6, 8, 5615, 6, 9, 4172, // 5, 8
- 5, 9, 47619, 5, 10, 6768, 6, 9, 6455, 6, 10, 4694, // 5, 9
- 5, 10, 44700, 5, 11, 7659, 6, 10, 7705, 6, 11, 5472, // 5,10
- 5, 11, 41487, 5, 12, 8578, 6, 11, 9143, 6, 12, 6328, // 5,11
- 5, 12, 38330, 5, 13, 9388, 6, 12, 10653, 6, 13, 7165, // 5,12
- 5, 13, 35364, 5, 14, 10041, 6, 13, 12188, 6, 14, 7943, // 5,13
- 5, 14, 32624, 5, 15, 10528, 6, 14, 13740, 6, 15, 8644, // 5,14
- 5, 15, 30105, 5, 16, 10855, 6, 15, 15311, 6, 16, 9265, // 5,15
- 5, 0, 15193, 5, 1, 8986, 6, 0, 30876, 6, 1, 10481, // 6, 0
- 5, 1, 13548, 5, 2, 8329, 6, 1, 33585, 6, 2, 10074, // 6, 1
- 5, 2, 11897, 5, 3, 7573, 6, 2, 36582, 6, 3, 9484, // 6, 2
- 5, 3, 10221, 5, 4, 6714, 6, 3, 39912, 6, 4, 8689, // 6, 3
- 5, 4, 8507, 5, 5, 5749, 6, 4, 43602, 6, 5, 7678, // 6, 4
- 5, 5, 6768, 5, 6, 4694, 6, 5, 47619, 6, 6, 6455, // 6, 5
- 5, 6, 5099, 5, 7, 3620, 6, 6, 51701, 6, 7, 5116, // 6, 6
- 5, 7, 3853, 5, 8, 2795, 6, 7, 54839, 6, 8, 4049, // 6, 7
- 6, 8, 54831, 6, 9, 4044, 7, 8, 3864, 7, 9, 2797, // 6, 8
- 6, 9, 51701, 6, 10, 5099, 7, 9, 5116, 7, 10, 3620, // 6, 9
- 6, 10, 47630, 6, 11, 6422, 7, 10, 6794, 7, 11, 4690, // 6,10
- 6, 11, 43626, 6, 12, 7626, 7, 11, 8545, 7, 12, 5739, // 6,11
- 6, 12, 39949, 6, 13, 8617, 7, 12, 10275, 7, 13, 6695, // 6,12
- 6, 13, 36631, 6, 14, 9390, 7, 13, 11972, 7, 14, 7543, // 6,13
- 6, 14, 33642, 6, 15, 9961, 7, 14, 13647, 7, 15, 8286, // 6,14
- 6, 15, 30939, 6, 16, 10351, 7, 15, 15319, 7, 16, 8927, // 6,15
- 6, 0, 15301, 6, 1, 8727, 7, 0, 31444, 7, 1, 10064, // 7, 0
- 6, 1, 13582, 6, 2, 8068, 7, 1, 34261, 7, 2, 9625, // 7, 1
- 6, 2, 11842, 6, 3, 7298, 7, 2, 37402, 7, 3, 8994, // 7, 2
- 6, 3, 10051, 6, 4, 6403, 7, 3, 40940, 7, 4, 8142, // 7, 3
- 6, 4, 8177, 6, 5, 5368, 7, 4, 44962, 7, 5, 7029, // 7, 4
- 6, 5, 6183, 6, 6, 4172, 7, 5, 49566, 7, 6, 5615, // 7, 5
- 6, 6, 4044, 6, 7, 2797, 7, 6, 54831, 7, 7, 3864, // 7, 6
- 6, 7, 1903, 6, 8, 1347, 7, 7, 60382, 7, 8, 1904, // 7, 7
- 7, 8, 60382, 7, 9, 1903, 8, 8, 1905, 8, 9, 1346, // 7, 8
- 7, 9, 54839, 7, 10, 3853, 8, 9, 4049, 8, 10, 2795, // 7, 9
- 7, 10, 49588, 7, 11, 5590, 8, 10, 6193, 8, 11, 4165, // 7,10
- 7, 11, 44999, 7, 12, 6987, 8, 11, 8195, 8, 12, 5355, // 7,11
- 7, 12, 40994, 7, 13, 8082, 8, 12, 10079, 8, 13, 6381, // 7,12
- 7, 13, 37470, 7, 14, 8918, 8, 13, 11883, 8, 14, 7265, // 7,13
- 7, 14, 34340, 7, 15, 9534, 8, 14, 13638, 8, 15, 8024, // 7,14
- 7, 15, 31532, 7, 16, 9959, 8, 15, 15376, 8, 16, 8669, // 7,15
- 7, -1, 8669, 7, 0, 15376, 8, -1, 9959, 8, 0, 31532, // 8, 0
- 7, 0, 8024, 7, 1, 13638, 8, 0, 9534, 8, 1, 34340, // 8, 1
- 7, 1, 7266, 7, 2, 11883, 8, 1, 8918, 8, 2, 37469, // 8, 2
- 7, 2, 6381, 7, 3, 10079, 8, 2, 8082, 8, 3, 40994, // 8, 3
- 7, 3, 5354, 7, 4, 8195, 8, 3, 6987, 8, 4, 45000, // 8, 4
- 7, 4, 4164, 7, 5, 6193, 8, 4, 5590, 8, 5, 49589, // 8, 5
- 7, 5, 2795, 7, 6, 4049, 8, 5, 3853, 8, 6, 54839, // 8, 6
- 7, 6, 1347, 7, 7, 1905, 8, 6, 1903, 8, 7, 60381, // 8, 7
- 8, 7, 1905, 8, 8, 60382, 9, 7, 1347, 9, 8, 1902, // 8, 8
- 8, 8, 3864, 8, 9, 54831, 9, 8, 2797, 9, 9, 4044, // 8, 9
- 8, 9, 5615, 8, 10, 49566, 9, 9, 4172, 9, 10, 6183, // 8,10
- 8, 10, 7029, 8, 11, 44962, 9, 10, 5368, 9, 11, 8177, // 8,11
- 8, 11, 8141, 8, 12, 40940, 9, 11, 6403, 9, 12, 10052, // 8,12
- 8, 12, 8994, 8, 13, 37402, 9, 12, 7298, 9, 13, 11842, // 8,13
- 8, 13, 9626, 8, 14, 34261, 9, 13, 8068, 9, 14, 13581, // 8,14
- 8, 14, 10065, 8, 15, 31444, 9, 14, 8727, 9, 15, 15300, // 8,15
- 8, -1, 8927, 8, 0, 15319, 9, -1, 10351, 9, 0, 30939, // 9, 0
- 8, 0, 8286, 8, 1, 13647, 9, 0, 9961, 9, 1, 33642, // 9, 1
- 8, 1, 7543, 8, 2, 11972, 9, 1, 9390, 9, 2, 36631, // 9, 2
- 8, 2, 6695, 8, 3, 10275, 9, 2, 8617, 9, 3, 39949, // 9, 3
- 8, 3, 5739, 8, 4, 8545, 9, 3, 7626, 9, 4, 43626, // 9, 4
- 8, 4, 4690, 8, 5, 6794, 9, 4, 6422, 9, 5, 47630, // 9, 5
- 8, 5, 3620, 8, 6, 5116, 9, 5, 5099, 9, 6, 51701, // 9, 6
- 8, 6, 2797, 8, 7, 3864, 9, 6, 4044, 9, 7, 54831, // 9, 7
- 9, 7, 4049, 9, 8, 54839, 10, 7, 2795, 10, 8, 3853, // 9, 8
- 9, 8, 5116, 9, 9, 51701, 10, 8, 3620, 10, 9, 5099, // 9, 9
- 9, 9, 6455, 9, 10, 47619, 10, 9, 4694, 10, 10, 6768, // 9,10
- 9, 10, 7678, 9, 11, 43602, 10, 10, 5749, 10, 11, 8507, // 9,11
- 9, 11, 8690, 9, 12, 39912, 10, 11, 6714, 10, 12, 10220, // 9,12
- 9, 12, 9484, 9, 13, 36582, 10, 12, 7573, 10, 13, 11897, // 9,13
- 9, 13, 10074, 9, 14, 33585, 10, 13, 8329, 10, 14, 13548, // 9,14
- 9, 14, 10482, 9, 15, 30876, 10, 14, 8986, 10, 15, 15192, // 9,15
- 9, -1, 9265, 9, 0, 15311, 10, -1, 10855, 10, 0, 30105, // 10, 0
- 9, 0, 8645, 9, 1, 13740, 10, 0, 10528, 10, 1, 32623, // 10, 1
- 9, 1, 7943, 9, 2, 12188, 10, 1, 10041, 10, 2, 35364, // 10, 2
- 9, 2, 7165, 9, 3, 10653, 10, 2, 9388, 10, 3, 38330, // 10, 3
- 9, 3, 6328, 9, 4, 9143, 10, 3, 8578, 10, 4, 41487, // 10, 4
- 9, 4, 5472, 9, 5, 7705, 10, 4, 7659, 10, 5, 44700, // 10, 5
- 9, 5, 4694, 9, 6, 6455, 10, 5, 6768, 10, 6, 47619, // 10, 6
- 9, 6, 4172, 9, 7, 5615, 10, 6, 6183, 10, 7, 49566, // 10, 7
- 10, 7, 6193, 10, 8, 49588, 11, 7, 4164, 11, 8, 5591, // 10, 8
- 10, 8, 6794, 10, 9, 47630, 11, 8, 4690, 11, 9, 6422, // 10, 9
- 10, 9, 7705, 10, 10, 44700, 11, 9, 5472, 11, 10, 7659, // 10,10
- 10, 10, 8646, 10, 11, 41475, 11, 10, 6334, 11, 11, 9081, // 10,11
- 10, 11, 9479, 10, 12, 38307, 11, 11, 7180, 11, 12, 10570, // 10,12
- 10, 12, 10156, 10, 13, 35332, 11, 12, 7969, 11, 13, 12079, // 10,13
- 10, 13, 10665, 10, 14, 32586, 11, 13, 8685, 11, 14, 13600, // 10,14
- 10, 14, 11013, 10, 15, 30064, 11, 14, 9323, 11, 15, 15136, // 10,15
- 10, -1, 9673, 10, 0, 15325, 11, -1, 11461, 11, 0, 29077, // 11, 0
- 10, 0, 9082, 10, 1, 13875, 11, 0, 11218, 11, 1, 31361, // 11, 1
- 10, 1, 8432, 10, 2, 12467, 11, 1, 10842, 11, 2, 33795, // 11, 2
- 10, 2, 7737, 10, 3, 11108, 11, 2, 10337, 11, 3, 36354, // 11, 3
- 10, 3, 7022, 10, 4, 9818, 11, 3, 9730, 11, 4, 38966, // 11, 4
- 10, 4, 6334, 10, 5, 8646, 11, 4, 9081, 11, 5, 41475, // 11, 5
- 10, 5, 5749, 10, 6, 7678, 11, 5, 8507, 11, 6, 43602, // 11, 6
- 10, 6, 5368, 10, 7, 7029, 11, 6, 8177, 11, 7, 44962, // 11, 7
- 11, 7, 8195, 11, 8, 44999, 12, 7, 5354, 12, 8, 6988, // 11, 8
- 11, 8, 8545, 11, 9, 43626, 12, 8, 5739, 12, 9, 7626, // 11, 9
- 11, 9, 9143, 11, 10, 41487, 12, 9, 6328, 12, 10, 8578, // 11,10
- 11, 10, 9818, 11, 11, 38966, 12, 10, 7022, 12, 11, 9730, // 11,11
- 11, 11, 10452, 11, 12, 36343, 12, 11, 7746, 12, 12, 10995, // 11,12
- 11, 12, 10983, 11, 13, 33777, 12, 12, 8452, 12, 13, 12324, // 11,13
- 11, 13, 11385, 11, 14, 31339, 12, 13, 9118, 12, 14, 13694, // 11,14
- 11, 14, 11652, 11, 15, 29055, 12, 14, 9728, 12, 15, 15101, // 11,15
- 11, -1, 10135, 11, 0, 15330, 12, -1, 12159, 12, 0, 27912, // 12, 0
- 11, 0, 9575, 11, 1, 14009, 12, 0, 12014, 12, 1, 29938, // 12, 1
- 11, 1, 8976, 11, 2, 12747, 12, 1, 11760, 12, 2, 32053, // 12, 2
- 11, 2, 8358, 11, 3, 11554, 12, 2, 11411, 12, 3, 34213, // 12, 3
- 11, 3, 7746, 11, 4, 10452, 12, 3, 10995, 12, 4, 36343, // 12, 4
- 11, 4, 7180, 11, 5, 9479, 12, 4, 10569, 12, 5, 38308, // 12, 5
- 11, 5, 6714, 11, 6, 8690, 12, 5, 10221, 12, 6, 39911, // 12, 6
- 11, 6, 6403, 11, 7, 8141, 12, 6, 10051, 12, 7, 40941, // 12, 7
- 12, 7, 10079, 12, 8, 40994, 13, 7, 6381, 13, 8, 8082, // 12, 8
- 12, 8, 10275, 12, 9, 39949, 13, 8, 6695, 13, 9, 8617, // 12, 9
- 12, 9, 10653, 12, 10, 38330, 13, 9, 7165, 13, 10, 9388, // 12,10
- 12, 10, 11108, 12, 11, 36354, 13, 10, 7737, 13, 11, 10337, // 12,11
- 12, 11, 11554, 12, 12, 34213, 13, 11, 8358, 13, 12, 11411, // 12,12
- 12, 12, 11934, 12, 13, 32045, 13, 12, 8988, 13, 13, 12569, // 12,13
- 12, 13, 12216, 12, 14, 29928, 13, 13, 9603, 13, 14, 13789, // 12,14
- 12, 14, 12388, 12, 15, 27903, 13, 14, 10185, 13, 15, 15060, // 12,15
- 12, -1, 10637, 12, 0, 15301, 13, -1, 12938, 13, 0, 26660, // 13, 0
- 12, 0, 10102, 12, 1, 14107, 13, 0, 12897, 13, 1, 28430, // 13, 1
- 12, 1, 9546, 12, 2, 12982, 13, 1, 12769, 13, 2, 30239, // 13, 2
- 12, 2, 8988, 12, 3, 11934, 13, 2, 12569, 13, 3, 32045, // 13, 3
- 12, 3, 8452, 12, 4, 10983, 13, 3, 12323, 13, 4, 33778, // 13, 4
- 12, 4, 7969, 12, 5, 10156, 13, 4, 12079, 13, 5, 35332, // 13, 5
- 12, 5, 7573, 12, 6, 9484, 13, 5, 11897, 13, 6, 36582, // 13, 6
- 12, 6, 7298, 12, 7, 8994, 13, 6, 11842, 13, 7, 37402, // 13, 7
- 13, 7, 11883, 13, 8, 37470, 14, 7, 7266, 14, 8, 8917, // 13, 8
- 13, 8, 11972, 13, 9, 36631, 14, 8, 7543, 14, 9, 9390, // 13, 9
- 13, 9, 12188, 13, 10, 35364, 14, 9, 7943, 14, 10, 10041, // 13,10
- 13, 10, 12467, 13, 11, 33795, 14, 10, 8432, 14, 11, 10842, // 13,11
- 13, 11, 12747, 13, 12, 32052, 14, 11, 8976, 14, 12, 11761, // 13,12
- 13, 12, 12982, 13, 13, 30239, 14, 12, 9546, 14, 13, 12769, // 13,13
- 13, 13, 13141, 13, 14, 28427, 14, 13, 10119, 14, 14, 13849, // 13,14
- 13, 14, 13211, 13, 15, 26660, 14, 14, 10676, 14, 15, 14989, // 13,15
- 13, -1, 11164, 13, 0, 15220, 14, -1, 13787, 14, 0, 25365, // 14, 0
- 13, 0, 10644, 13, 1, 14145, 14, 0, 13853, 14, 1, 26894, // 14, 1
- 13, 1, 10119, 13, 2, 13141, 14, 1, 13850, 14, 2, 28426, // 14, 2
- 13, 2, 9603, 13, 3, 12216, 14, 2, 13789, 14, 3, 29928, // 14, 3
- 13, 3, 9118, 13, 4, 11385, 14, 3, 13694, 14, 4, 31339, // 14, 4
- 13, 4, 8685, 13, 5, 10665, 14, 4, 13600, 14, 5, 32586, // 14, 5
- 13, 5, 8329, 13, 6, 10074, 14, 5, 13548, 14, 6, 33585, // 14, 6
- 13, 6, 8068, 13, 7, 9626, 14, 6, 13582, 14, 7, 34260, // 14, 7
- 14, 7, 13638, 14, 8, 34340, 15, 7, 8024, 15, 8, 9534, // 14, 8
- 14, 8, 13647, 14, 9, 33642, 15, 8, 8286, 15, 9, 9961, // 14, 9
- 14, 9, 13740, 14, 10, 32624, 15, 9, 8645, 15, 10, 10527, // 14,10
- 14, 10, 13875, 14, 11, 31361, 15, 10, 9082, 15, 11, 11218, // 14,11
- 14, 11, 14009, 14, 12, 29938, 15, 11, 9575, 15, 12, 12014, // 14,12
- 14, 12, 14107, 14, 13, 28430, 15, 12, 10102, 15, 13, 12897, // 14,13
- 14, 13, 14145, 14, 14, 26893, 15, 13, 10644, 15, 14, 13854, // 14,14
- 14, 14, 14109, 14, 15, 25368, 15, 14, 11187, 15, 15, 14872, // 14,15
- 14, -1, 11702, 14, 0, 15076, 15, -1, 14696, 15, 0, 24062, // 15, 0
- 14, 0, 11187, 14, 1, 14109, 15, 0, 14872, 15, 1, 25368, // 15, 1
- 14, 1, 10676, 14, 2, 13211, 15, 1, 14990, 15, 2, 26659, // 15, 2
- 14, 2, 10185, 14, 3, 12388, 15, 2, 15060, 15, 3, 27903, // 15, 3
- 14, 3, 9728, 14, 4, 11652, 15, 3, 15100, 15, 4, 29056, // 15, 4
- 14, 4, 9323, 14, 5, 11013, 15, 4, 15135, 15, 5, 30065, // 15, 5
- 14, 5, 8986, 14, 6, 10482, 15, 5, 15193, 15, 6, 30875, // 15, 6
- 14, 6, 8727, 14, 7, 10065, 15, 6, 15301, 15, 7, 31443, // 15, 7
- 15, 7, 15376, 15, 8, 31532, 16, 7, 8669, 16, 8, 9959, // 15, 8
- 15, 8, 15319, 15, 9, 30939, 16, 8, 8927, 16, 9, 10351, // 15, 9
- 15, 9, 15311, 15, 10, 30105, 16, 9, 9265, 16, 10, 10855, // 15,10
- 15, 10, 15325, 15, 11, 29078, 16, 10, 9673, 16, 11, 11460, // 15,11
- 15, 11, 15330, 15, 12, 27912, 16, 11, 10135, 16, 12, 12159, // 15,12
- 15, 12, 15301, 15, 13, 26660, 16, 12, 10637, 16, 13, 12938, // 15,13
- 15, 13, 15220, 15, 14, 25366, 16, 13, 11164, 16, 14, 13786, // 15,14
- 15, 14, 15076, 15, 15, 24063, 16, 14, 11702, 16, 15, 14695, // 15,15
- // angle of -2.0 degrees
- -1, 0, 13368, -1, 1, 10104, 0, 0, 28495, 0, 1, 13569, // 0, 0
- -1, 1, 12574, -1, 2, 9662, 0, 1, 29831, 0, 2, 13469, // 0, 1
- -1, 2, 11829, -1, 3, 9229, 0, 2, 31146, 0, 3, 13332, // 0, 2
- -1, 3, 11143, -1, 4, 8816, 0, 3, 32406, 0, 4, 13171, // 0, 3
- -1, 4, 10528, -1, 5, 8438, 0, 4, 33564, 0, 5, 13006, // 0, 4
- -1, 5, 9995, -1, 6, 8107, 0, 5, 34567, 0, 6, 12867, // 0, 5
- -1, 6, 9558, -1, 7, 7839, 0, 6, 35362, 0, 7, 12777, // 0, 6
- -1, 7, 9224, -1, 8, 7643, 0, 7, 35905, 0, 8, 12764, // 0, 7
- 0, 8, 35844, 0, 9, 12728, 1, 8, 9290, 1, 9, 7674, // 0, 8
- 0, 9, 35315, 0, 10, 12717, 1, 9, 9635, 1, 10, 7869, // 0, 9
- 0, 10, 34532, 0, 11, 12783, 1, 10, 10086, 1, 11, 8135, // 0,10
- 0, 11, 33539, 0, 12, 12899, 1, 11, 10635, 1, 12, 8463, // 0,11
- 0, 12, 32391, 0, 13, 13038, 1, 12, 11269, 1, 13, 8838, // 0,12
- 0, 13, 31138, 0, 14, 13176, 1, 13, 11977, 1, 14, 9245, // 0,13
- 0, 14, 29828, 0, 15, 13291, 1, 14, 12746, 1, 15, 9671, // 0,14
- 0, 15, 28495, 0, 16, 13368, 1, 15, 13569, 1, 16, 10104, // 0,15
- 0, 0, 13291, 0, 1, 9671, 1, 0, 29828, 1, 1, 12746, // 1, 0
- 0, 1, 12412, 0, 2, 9202, 1, 1, 31358, 1, 2, 12564, // 1, 1
- 0, 2, 11580, 0, 3, 8735, 1, 2, 32886, 1, 3, 12335, // 1, 2
- 0, 3, 10808, 0, 4, 8284, 1, 3, 34369, 1, 4, 12075, // 1, 3
- 0, 4, 10111, 0, 5, 7865, 1, 4, 35750, 1, 5, 11810, // 1, 4
- 0, 5, 9509, 0, 6, 7497, 1, 5, 36955, 1, 6, 11575, // 1, 5
- 0, 6, 9020, 0, 7, 7202, 1, 6, 37906, 1, 7, 11408, // 1, 6
- 0, 7, 8662, 0, 8, 6997, 1, 7, 38534, 1, 8, 11343, // 1, 7
- 1, 8, 38481, 1, 9, 11317, 2, 8, 8718, 2, 9, 7020, // 1, 8
- 1, 9, 37866, 1, 10, 11360, 2, 9, 9086, 2, 10, 7224, // 1, 9
- 1, 10, 36926, 1, 11, 11507, 2, 10, 9587, 2, 11, 7516, // 1,10
- 1, 11, 35730, 1, 12, 11721, 2, 11, 10204, 2, 12, 7881, // 1,11
- 1, 12, 34358, 1, 13, 11964, 2, 12, 10918, 2, 13, 8296, // 1,12
- 1, 13, 32881, 1, 14, 12203, 2, 13, 11709, 2, 14, 8743, // 1,13
- 1, 14, 31358, 1, 15, 12412, 2, 14, 12564, 2, 15, 9202, // 1,14
- 1, 15, 29831, 1, 16, 12574, 2, 15, 13470, 2, 16, 9661, // 1,15
- 1, 0, 13176, 1, 1, 9245, 2, 0, 31138, 2, 1, 11977, // 2, 0
- 1, 1, 12203, 1, 2, 8742, 2, 1, 32881, 2, 2, 11710, // 2, 1
- 1, 2, 11272, 1, 3, 8232, 2, 2, 34650, 2, 3, 11382, // 2, 2
- 1, 3, 10397, 1, 4, 7728, 2, 3, 36399, 2, 4, 11012, // 2, 3
- 1, 4, 9597, 1, 5, 7252, 2, 4, 38057, 2, 5, 10630, // 2, 4
- 1, 5, 8902, 1, 6, 6829, 2, 5, 39526, 2, 6, 10279, // 2, 5
- 1, 6, 8344, 1, 7, 6491, 2, 6, 40688, 2, 7, 10013, // 2, 6
- 1, 7, 7951, 1, 8, 6266, 2, 7, 41432, 2, 8, 9887, // 2, 7
- 2, 8, 41389, 2, 9, 9867, 3, 8, 7996, 3, 9, 6284, // 2, 8
- 2, 9, 40656, 2, 10, 9977, 3, 9, 8397, 3, 10, 6506, // 2, 9
- 2, 10, 39503, 2, 11, 10226, 3, 10, 8966, 3, 11, 6841, // 2,10
- 2, 11, 38042, 2, 12, 10559, 3, 11, 9674, 3, 12, 7261, // 2,11
- 2, 12, 36392, 2, 13, 10922, 3, 12, 10488, 3, 13, 7734, // 2,12
- 2, 13, 34650, 2, 14, 11272, 3, 13, 11382, 3, 14, 8232, // 2,13
- 2, 14, 32886, 2, 15, 11580, 3, 14, 12334, 3, 15, 8736, // 2,14
- 2, 15, 31146, 2, 16, 11829, 3, 15, 13332, 3, 16, 9229, // 2,15
- 2, 0, 13038, 2, 1, 8838, 3, 0, 32391, 3, 1, 11269, // 3, 0
- 2, 1, 11964, 2, 2, 8296, 3, 1, 34358, 3, 2, 10918, // 3, 1
- 2, 2, 10922, 2, 3, 7734, 3, 2, 36392, 3, 3, 10488, // 3, 2
- 2, 3, 9924, 2, 4, 7164, 3, 3, 38450, 3, 4, 9998, // 3, 3
- 2, 4, 8995, 2, 5, 6611, 3, 4, 40452, 3, 5, 9478, // 3, 4
- 2, 5, 8175, 2, 6, 6108, 3, 5, 42271, 3, 6, 8982, // 3, 5
- 2, 6, 7516, 2, 7, 5703, 3, 6, 43733, 3, 7, 8584, // 3, 6
- 2, 7, 7072, 2, 8, 5443, 3, 7, 44649, 3, 8, 8372, // 3, 7
- 3, 8, 44616, 3, 9, 8359, 4, 8, 7106, 4, 9, 5455, // 3, 8
- 3, 9, 43710, 3, 10, 8558, 4, 9, 7556, 4, 10, 5712, // 3, 9
- 3, 10, 42256, 3, 11, 8940, 4, 10, 8224, 4, 11, 6116, // 3,10
- 3, 11, 40444, 3, 12, 9421, 4, 11, 9056, 4, 12, 6615, // 3,11
- 3, 12, 38450, 3, 13, 9924, 4, 12, 9998, 4, 13, 7164, // 3,12
- 3, 13, 36399, 3, 14, 10397, 4, 13, 11012, 4, 14, 7728, // 3,13
- 3, 14, 34369, 3, 15, 10808, 4, 14, 12074, 4, 15, 8285, // 3,14
- 3, 15, 32406, 3, 16, 11143, 4, 15, 13171, 4, 16, 8816, // 3,15
- 3, 0, 12899, 3, 1, 8463, 4, 0, 33539, 4, 1, 10635, // 4, 0
- 3, 1, 11721, 3, 2, 7881, 4, 1, 35730, 4, 2, 10204, // 4, 1
- 3, 2, 10559, 3, 3, 7261, 4, 2, 38042, 4, 3, 9674, // 4, 2
- 3, 3, 9421, 3, 4, 6615, 4, 3, 40444, 4, 4, 9056, // 4, 3
- 3, 4, 8332, 3, 5, 5965, 4, 4, 42861, 4, 5, 8378, // 4, 4
- 3, 5, 7342, 3, 6, 5350, 4, 5, 45146, 4, 6, 7698, // 4, 5
- 3, 6, 6530, 3, 7, 4838, 4, 6, 47049, 4, 7, 7119, // 4, 6
- 3, 7, 6000, 3, 8, 4513, 4, 7, 48240, 4, 8, 6783, // 4, 7
- 4, 8, 48218, 4, 9, 6774, 5, 8, 6023, 5, 9, 4521, // 4, 8
- 4, 9, 47035, 4, 10, 7100, 5, 9, 6558, 5, 10, 4843, // 4, 9
- 4, 10, 45139, 4, 11, 7667, 5, 10, 7377, 5, 11, 5353, // 4,10
- 4, 11, 42861, 4, 12, 8332, 5, 11, 8378, 5, 12, 5965, // 4,11
- 4, 12, 40452, 4, 13, 8995, 5, 12, 9478, 5, 13, 6611, // 4,12
- 4, 13, 38057, 4, 14, 9597, 5, 13, 10630, 5, 14, 7252, // 4,13
- 4, 14, 35750, 4, 15, 10111, 5, 14, 11810, 5, 15, 7865, // 4,14
- 4, 15, 33564, 4, 16, 10528, 5, 15, 13007, 5, 16, 8437, // 4,15
- 4, 0, 12783, 4, 1, 8135, 5, 0, 34532, 5, 1, 10086, // 5, 0
- 4, 1, 11507, 4, 2, 7517, 5, 1, 36926, 5, 2, 9586, // 5, 1
- 4, 2, 10226, 4, 3, 6842, 5, 2, 39503, 5, 3, 8965, // 5, 2
- 4, 3, 8940, 4, 4, 6116, 5, 3, 42256, 5, 4, 8224, // 5, 3
- 4, 4, 7667, 4, 5, 5353, 5, 4, 45139, 5, 5, 7377, // 5, 4
- 4, 5, 6451, 4, 6, 4591, 5, 5, 48019, 5, 6, 6475, // 5, 5
- 4, 6, 5400, 4, 7, 3911, 5, 6, 50587, 5, 7, 5638, // 5, 6
- 4, 7, 4708, 4, 8, 3466, 5, 7, 52266, 5, 8, 5096, // 5, 7
- 5, 8, 52253, 5, 9, 5092, 6, 8, 4721, 6, 9, 3470, // 5, 8
- 5, 9, 50581, 5, 10, 5624, 6, 9, 5418, 6, 10, 3913, // 5, 9
- 5, 10, 48019, 5, 11, 6451, 6, 10, 6475, 6, 11, 4591, // 5,10
- 5, 11, 45146, 5, 12, 7342, 6, 11, 7698, 6, 12, 5350, // 5,11
- 5, 12, 42271, 5, 13, 8175, 6, 12, 8982, 6, 13, 6108, // 5,12
- 5, 13, 39526, 5, 14, 8902, 6, 13, 10279, 6, 14, 6829, // 5,13
- 5, 14, 36955, 5, 15, 9509, 6, 14, 11575, 6, 15, 7497, // 5,14
- 5, 15, 34567, 5, 16, 9995, 6, 15, 12867, 6, 16, 8107, // 5,15
- 5, 0, 12717, 5, 1, 7868, 6, 0, 35315, 6, 1, 9636, // 6, 0
- 5, 1, 11360, 5, 2, 7224, 6, 1, 37866, 6, 2, 9086, // 6, 1
- 5, 2, 9977, 5, 3, 6506, 6, 2, 40656, 6, 3, 8397, // 6, 2
- 5, 3, 8558, 5, 4, 5712, 6, 3, 43710, 6, 4, 7556, // 6, 3
- 5, 4, 7100, 5, 5, 4843, 6, 4, 47035, 6, 5, 6558, // 6, 4
- 5, 5, 5624, 5, 6, 3913, 6, 5, 50581, 6, 6, 5418, // 6, 5
- 5, 6, 4217, 5, 7, 2989, 6, 6, 54105, 6, 7, 4225, // 6, 6
- 5, 7, 3180, 5, 8, 2294, 6, 7, 56756, 6, 8, 3306, // 6, 7
- 6, 8, 56751, 6, 9, 3303, 7, 8, 3186, 7, 9, 2296, // 6, 8
- 6, 9, 54105, 6, 10, 4217, 7, 9, 4225, 7, 10, 2989, // 6, 9
- 6, 10, 50587, 6, 11, 5400, 7, 10, 5637, 7, 11, 3912, // 6,10
- 6, 11, 47049, 6, 12, 6530, 7, 11, 7119, 7, 12, 4838, // 6,11
- 6, 12, 43733, 6, 13, 7516, 7, 12, 8584, 7, 13, 5703, // 6,12
- 6, 13, 40688, 6, 14, 8344, 7, 13, 10013, 7, 14, 6491, // 6,13
- 6, 14, 37906, 6, 15, 9020, 7, 14, 11407, 7, 15, 7203, // 6,14
- 6, 15, 35362, 6, 16, 9558, 7, 15, 12777, 7, 16, 7839, // 6,15
- 6, 0, 12728, 6, 1, 7674, 7, 0, 35844, 7, 1, 9290, // 7, 0
- 6, 1, 11317, 6, 2, 7020, 7, 1, 38481, 7, 2, 8718, // 7, 1
- 6, 2, 9867, 6, 3, 6284, 7, 2, 41389, 7, 3, 7996, // 7, 2
- 6, 3, 8359, 6, 4, 5454, 7, 3, 44616, 7, 4, 7107, // 7, 3
- 6, 4, 6774, 6, 5, 4521, 7, 4, 48218, 7, 5, 6023, // 7, 4
- 6, 5, 5092, 6, 6, 3470, 7, 5, 52253, 7, 6, 4721, // 7, 5
- 6, 6, 3303, 6, 7, 2295, 7, 6, 56751, 7, 7, 3187, // 7, 6
- 6, 7, 1541, 6, 8, 1090, 7, 7, 61364, 7, 8, 1541, // 7, 7
- 7, 8, 61364, 7, 9, 1541, 8, 8, 1542, 8, 9, 1089, // 7, 8
- 7, 9, 56756, 7, 10, 3180, 8, 9, 3306, 8, 10, 2294, // 7, 9
- 7, 10, 52266, 7, 11, 4708, 8, 10, 5097, 8, 11, 3465, // 7,10
- 7, 11, 48240, 7, 12, 6000, 8, 11, 6783, 8, 12, 4513, // 7,11
- 7, 12, 44649, 7, 13, 7072, 8, 12, 8373, 8, 13, 5442, // 7,12
- 7, 13, 41432, 7, 14, 7951, 8, 13, 9886, 8, 14, 6267, // 7,13
- 7, 14, 38534, 7, 15, 8662, 8, 14, 11344, 8, 15, 6996, // 7,14
- 7, 15, 35905, 7, 16, 9224, 8, 15, 12764, 8, 16, 7643, // 7,15
- 7, -1, 7643, 7, 0, 12764, 8, -1, 9224, 8, 0, 35905, // 8, 0
- 7, 0, 6997, 7, 1, 11344, 8, 0, 8662, 8, 1, 38533, // 8, 1
- 7, 1, 6266, 7, 2, 9886, 8, 1, 7951, 8, 2, 41433, // 8, 2
- 7, 2, 5443, 7, 3, 8373, 8, 2, 7072, 8, 3, 44648, // 8, 3
- 7, 3, 4513, 7, 4, 6783, 8, 3, 6000, 8, 4, 48240, // 8, 4
- 7, 4, 3466, 7, 5, 5097, 8, 4, 4708, 8, 5, 52265, // 8, 5
- 7, 5, 2294, 7, 6, 3306, 8, 5, 3180, 8, 6, 56756, // 8, 6
- 7, 6, 1090, 7, 7, 1542, 8, 6, 1541, 8, 7, 61363, // 8, 7
- 8, 7, 1542, 8, 8, 61364, 9, 7, 1090, 9, 8, 1540, // 8, 8
- 8, 8, 3186, 8, 9, 56751, 9, 8, 2295, 9, 9, 3304, // 8, 9
- 8, 9, 4721, 8, 10, 52253, 9, 9, 3470, 9, 10, 5092, // 8,10
- 8, 10, 6023, 8, 11, 48218, 9, 10, 4521, 9, 11, 6774, // 8,11
- 8, 11, 7106, 8, 12, 44616, 9, 11, 5454, 9, 12, 8360, // 8,12
- 8, 12, 7996, 8, 13, 41389, 9, 12, 6284, 9, 13, 9867, // 8,13
- 8, 13, 8718, 8, 14, 38481, 9, 13, 7020, 9, 14, 11317, // 8,14
- 8, 14, 9290, 8, 15, 35844, 9, 14, 7674, 9, 15, 12728, // 8,15
- 8, -1, 7839, 8, 0, 12777, 9, -1, 9558, 9, 0, 35362, // 9, 0
- 8, 0, 7202, 8, 1, 11407, 9, 0, 9020, 9, 1, 37907, // 9, 1
- 8, 1, 6491, 8, 2, 10013, 9, 1, 8344, 9, 2, 40688, // 9, 2
- 8, 2, 5703, 8, 3, 8584, 9, 2, 7516, 9, 3, 43733, // 9, 3
- 8, 3, 4838, 8, 4, 7119, 9, 3, 6530, 9, 4, 47049, // 9, 4
- 8, 4, 3911, 8, 5, 5637, 9, 4, 5400, 9, 5, 50588, // 9, 5
- 8, 5, 2989, 8, 6, 4225, 9, 5, 4217, 9, 6, 54105, // 9, 6
- 8, 6, 2295, 8, 7, 3186, 9, 6, 3303, 9, 7, 56752, // 9, 7
- 9, 7, 3306, 9, 8, 56756, 10, 7, 2294, 10, 8, 3180, // 9, 8
- 9, 8, 4225, 9, 9, 54105, 10, 8, 2989, 10, 9, 4217, // 9, 9
- 9, 9, 5418, 9, 10, 50581, 10, 9, 3913, 10, 10, 5624, // 9,10
- 9, 10, 6558, 9, 11, 47035, 10, 10, 4843, 10, 11, 7100, // 9,11
- 9, 11, 7556, 9, 12, 43710, 10, 11, 5712, 10, 12, 8558, // 9,12
- 9, 12, 8397, 9, 13, 40656, 10, 12, 6506, 10, 13, 9977, // 9,13
- 9, 13, 9086, 9, 14, 37866, 10, 13, 7224, 10, 14, 11360, // 9,14
- 9, 14, 9635, 9, 15, 35315, 10, 14, 7868, 10, 15, 12718, // 9,15
- 9, -1, 8107, 9, 0, 12867, 10, -1, 9995, 10, 0, 34567, // 10, 0
- 9, 0, 7497, 9, 1, 11575, 10, 0, 9509, 10, 1, 36955, // 10, 1
- 9, 1, 6829, 9, 2, 10279, 10, 1, 8902, 10, 2, 39526, // 10, 2
- 9, 2, 6108, 9, 3, 8982, 10, 2, 8175, 10, 3, 42271, // 10, 3
- 9, 3, 5350, 9, 4, 7698, 10, 3, 7342, 10, 4, 45146, // 10, 4
- 9, 4, 4591, 9, 5, 6475, 10, 4, 6451, 10, 5, 48019, // 10, 5
- 9, 5, 3913, 9, 6, 5418, 10, 5, 5624, 10, 6, 50581, // 10, 6
- 9, 6, 3470, 9, 7, 4721, 10, 6, 5092, 10, 7, 52253, // 10, 7
- 10, 7, 5097, 10, 8, 52266, 11, 7, 3466, 11, 8, 4707, // 10, 8
- 10, 8, 5637, 10, 9, 50587, 11, 8, 3911, 11, 9, 5401, // 10, 9
- 10, 9, 6475, 10, 10, 48019, 11, 9, 4591, 11, 10, 6451, // 10,10
- 10, 10, 7377, 10, 11, 45139, 11, 10, 5353, 11, 11, 7667, // 10,11
- 10, 11, 8224, 10, 12, 42256, 11, 11, 6116, 11, 12, 8940, // 10,12
- 10, 12, 8966, 10, 13, 39503, 11, 12, 6842, 11, 13, 10225, // 10,13
- 10, 13, 9587, 10, 14, 36926, 11, 13, 7517, 11, 14, 11506, // 10,14
- 10, 14, 10086, 10, 15, 34532, 11, 14, 8135, 11, 15, 12783, // 10,15
- 10, -1, 8438, 10, 0, 13007, 11, -1, 10528, 11, 0, 33563, // 11, 0
- 10, 0, 7865, 10, 1, 11810, 11, 0, 10111, 11, 1, 35750, // 11, 1
- 10, 1, 7252, 10, 2, 10630, 11, 1, 9597, 11, 2, 38057, // 11, 2
- 10, 2, 6611, 10, 3, 9478, 11, 2, 8995, 11, 3, 40452, // 11, 3
- 10, 3, 5965, 10, 4, 8378, 11, 3, 8332, 11, 4, 42861, // 11, 4
- 10, 4, 5353, 10, 5, 7377, 11, 4, 7667, 11, 5, 45139, // 11, 5
- 10, 5, 4843, 10, 6, 6558, 11, 5, 7100, 11, 6, 47035, // 11, 6
- 10, 6, 4521, 10, 7, 6023, 11, 6, 6774, 11, 7, 48218, // 11, 7
- 11, 7, 6783, 11, 8, 48240, 12, 7, 4513, 12, 8, 6000, // 11, 8
- 11, 8, 7119, 11, 9, 47049, 12, 8, 4838, 12, 9, 6530, // 11, 9
- 11, 9, 7698, 11, 10, 45146, 12, 9, 5350, 12, 10, 7342, // 11,10
- 11, 10, 8378, 11, 11, 42861, 12, 10, 5965, 12, 11, 8332, // 11,11
- 11, 11, 9056, 11, 12, 40444, 12, 11, 6615, 12, 12, 9421, // 11,12
- 11, 12, 9674, 11, 13, 38042, 12, 12, 7261, 12, 13, 10559, // 11,13
- 11, 13, 10204, 11, 14, 35730, 12, 13, 7881, 12, 14, 11721, // 11,14
- 11, 14, 10635, 11, 15, 33539, 12, 14, 8463, 12, 15, 12899, // 11,15
- 11, -1, 8816, 11, 0, 13171, 12, -1, 11143, 12, 0, 32406, // 12, 0
- 11, 0, 8284, 11, 1, 12074, 12, 0, 10808, 12, 1, 34370, // 12, 1
- 11, 1, 7728, 11, 2, 11012, 12, 1, 10397, 12, 2, 36399, // 12, 2
- 11, 2, 7164, 11, 3, 9998, 12, 2, 9924, 12, 3, 38450, // 12, 3
- 11, 3, 6615, 11, 4, 9056, 12, 3, 9421, 12, 4, 40444, // 12, 4
- 11, 4, 6116, 11, 5, 8224, 12, 4, 8940, 12, 5, 42256, // 12, 5
- 11, 5, 5712, 11, 6, 7556, 12, 5, 8558, 12, 6, 43710, // 12, 6
- 11, 6, 5454, 11, 7, 7106, 12, 6, 8359, 12, 7, 44617, // 12, 7
- 12, 7, 8373, 12, 8, 44649, 13, 7, 5443, 13, 8, 7071, // 12, 8
- 12, 8, 8584, 12, 9, 43733, 13, 8, 5703, 13, 9, 7516, // 12, 9
- 12, 9, 8982, 12, 10, 42271, 13, 9, 6108, 13, 10, 8175, // 12,10
- 12, 10, 9478, 12, 11, 40452, 13, 10, 6611, 13, 11, 8995, // 12,11
- 12, 11, 9998, 12, 12, 38450, 13, 11, 7164, 13, 12, 9924, // 12,12
- 12, 12, 10488, 12, 13, 36392, 13, 12, 7734, 13, 13, 10922, // 12,13
- 12, 13, 10918, 12, 14, 34358, 13, 13, 8296, 13, 14, 11964, // 12,14
- 12, 14, 11269, 12, 15, 32391, 13, 14, 8838, 13, 15, 13038, // 12,15
- 12, -1, 9229, 12, 0, 13332, 13, -1, 11829, 13, 0, 31146, // 13, 0
- 12, 0, 8735, 12, 1, 12334, 13, 0, 11580, 13, 1, 32887, // 13, 1
- 12, 1, 8232, 12, 2, 11382, 13, 1, 11272, 13, 2, 34650, // 13, 2
- 12, 2, 7734, 12, 3, 10488, 13, 2, 10922, 13, 3, 36392, // 13, 3
- 12, 3, 7261, 12, 4, 9674, 13, 3, 10559, 13, 4, 38042, // 13, 4
- 12, 4, 6842, 12, 5, 8966, 13, 4, 10226, 13, 5, 39502, // 13, 5
- 12, 5, 6506, 12, 6, 8397, 13, 5, 9977, 13, 6, 40656, // 13, 6
- 12, 6, 6284, 12, 7, 7996, 13, 6, 9867, 13, 7, 41389, // 13, 7
- 13, 7, 9886, 13, 8, 41432, 14, 7, 6266, 14, 8, 7952, // 13, 8
- 13, 8, 10013, 13, 9, 40688, 14, 8, 6491, 14, 9, 8344, // 13, 9
- 13, 9, 10279, 13, 10, 39526, 14, 9, 6829, 14, 10, 8902, // 13,10
- 13, 10, 10630, 13, 11, 38057, 14, 10, 7252, 14, 11, 9597, // 13,11
- 13, 11, 11012, 13, 12, 36399, 14, 11, 7728, 14, 12, 10397, // 13,12
- 13, 12, 11382, 13, 13, 34650, 14, 12, 8232, 14, 13, 11272, // 13,13
- 13, 13, 11709, 13, 14, 32881, 14, 13, 8742, 14, 14, 12204, // 13,14
- 13, 14, 11977, 13, 15, 31138, 14, 14, 9245, 14, 15, 13176, // 13,15
- 13, -1, 9662, 13, 0, 13470, 14, -1, 12574, 14, 0, 29830, // 14, 0
- 13, 0, 9202, 13, 1, 12564, 14, 0, 12412, 14, 1, 31358, // 14, 1
- 13, 1, 8742, 13, 2, 11709, 14, 1, 12203, 14, 2, 32882, // 14, 2
- 13, 2, 8296, 13, 3, 10918, 14, 2, 11964, 14, 3, 34358, // 14, 3
- 13, 3, 7881, 13, 4, 10204, 14, 3, 11721, 14, 4, 35730, // 14, 4
- 13, 4, 7517, 13, 5, 9587, 14, 4, 11507, 14, 5, 36925, // 14, 5
- 13, 5, 7224, 13, 6, 9086, 14, 5, 11360, 14, 6, 37866, // 14, 6
- 13, 6, 7020, 13, 7, 8718, 14, 6, 11317, 14, 7, 38481, // 14, 7
- 14, 7, 11344, 14, 8, 38534, 15, 7, 6997, 15, 8, 8661, // 14, 8
- 14, 8, 11407, 14, 9, 37906, 15, 8, 7202, 15, 9, 9021, // 14, 9
- 14, 9, 11575, 14, 10, 36955, 15, 9, 7497, 15, 10, 9509, // 14,10
- 14, 10, 11810, 14, 11, 35750, 15, 10, 7865, 15, 11, 10111, // 14,11
- 14, 11, 12074, 14, 12, 34369, 15, 11, 8284, 15, 12, 10809, // 14,12
- 14, 12, 12334, 14, 13, 32886, 15, 12, 8735, 15, 13, 11581, // 14,13
- 14, 13, 12564, 14, 14, 31358, 15, 13, 9202, 15, 14, 12412, // 14,14
- 14, 14, 12746, 14, 15, 29828, 15, 14, 9671, 15, 15, 13291, // 14,15
- 14, -1, 10104, 14, 0, 13569, 15, -1, 13368, 15, 0, 28495, // 15, 0
- 14, 0, 9671, 14, 1, 12746, 15, 0, 13291, 15, 1, 29828, // 15, 1
- 14, 1, 9245, 14, 2, 11977, 15, 1, 13176, 15, 2, 31138, // 15, 2
- 14, 2, 8838, 14, 3, 11269, 15, 2, 13038, 15, 3, 32391, // 15, 3
- 14, 3, 8463, 14, 4, 10635, 15, 3, 12899, 15, 4, 33539, // 15, 4
- 14, 4, 8135, 14, 5, 10086, 15, 4, 12783, 15, 5, 34532, // 15, 5
- 14, 5, 7868, 14, 6, 9635, 15, 5, 12717, 15, 6, 35316, // 15, 6
- 14, 6, 7674, 14, 7, 9290, 15, 6, 12728, 15, 7, 35844, // 15, 7
- 15, 7, 12764, 15, 8, 35905, 16, 7, 7643, 16, 8, 9224, // 15, 8
- 15, 8, 12777, 15, 9, 35362, 16, 8, 7839, 16, 9, 9558, // 15, 9
- 15, 9, 12867, 15, 10, 34567, 16, 9, 8107, 16, 10, 9995, // 15,10
- 15, 10, 13007, 15, 11, 33564, 16, 10, 8438, 16, 11, 10527, // 15,11
- 15, 11, 13171, 15, 12, 32406, 16, 11, 8816, 16, 12, 11143, // 15,12
- 15, 12, 13332, 15, 13, 31146, 16, 12, 9229, 16, 13, 11829, // 15,13
- 15, 13, 13470, 15, 14, 29831, 16, 13, 9662, 16, 14, 12573, // 15,14
- 15, 14, 13569, 15, 15, 28495, 16, 14, 10104, 16, 15, 13368, // 15,15
- // angle of -1.5 degrees
- -1, 0, 11440, -1, 1, 8358, 0, 0, 34212, 0, 1, 11526, // 0, 0
- -1, 1, 10780, -1, 2, 7983, 0, 1, 35506, 0, 2, 11267, // 0, 1
- -1, 2, 10158, -1, 3, 7620, 0, 2, 36764, 0, 3, 10994, // 0, 2
- -1, 3, 9585, -1, 4, 7276, 0, 3, 37951, 0, 4, 10724, // 0, 3
- -1, 4, 9072, -1, 5, 6965, 0, 4, 39026, 0, 5, 10473, // 0, 4
- -1, 5, 8632, -1, 6, 6699, 0, 5, 39940, 0, 6, 10265, // 0, 5
- -1, 6, 8278, -1, 7, 6489, 0, 6, 40646, 0, 7, 10123, // 0, 6
- -1, 7, 8018, -1, 8, 6346, 0, 7, 41106, 0, 8, 10066, // 0, 7
- 0, 8, 41072, 0, 9, 10052, 1, 8, 8052, 1, 9, 6360, // 0, 8
- 0, 9, 40618, 0, 10, 10100, 1, 9, 8316, 1, 10, 6502, // 0, 9
- 0, 10, 39918, 0, 11, 10232, 1, 10, 8676, 1, 11, 6710, // 0,10
- 0, 11, 39009, 0, 12, 10430, 1, 11, 9122, 1, 12, 6975, // 0,11
- 0, 12, 37939, 0, 13, 10670, 1, 12, 9642, 1, 13, 7285, // 0,12
- 0, 13, 36756, 0, 14, 10930, 1, 13, 10224, 1, 14, 7626, // 0,13
- 0, 14, 35502, 0, 15, 11192, 1, 14, 10855, 1, 15, 7987, // 0,14
- 0, 15, 34212, 0, 16, 11440, 1, 15, 11526, 1, 16, 8358, // 0,15
- 0, 0, 11192, 0, 1, 7987, 1, 0, 35502, 1, 1, 10855, // 1, 0
- 0, 1, 10467, 0, 2, 7579, 1, 1, 36959, 1, 2, 10531, // 1, 1
- 0, 2, 9777, 0, 3, 7177, 1, 2, 38394, 1, 3, 10188, // 1, 2
- 0, 3, 9135, 0, 4, 6792, 1, 3, 39767, 1, 4, 9842, // 1, 3
- 0, 4, 8557, 0, 5, 6440, 1, 4, 41026, 1, 5, 9513, // 1, 4
- 0, 5, 8061, 0, 6, 6137, 1, 5, 42105, 1, 6, 9233, // 1, 5
- 0, 6, 7667, 0, 7, 5900, 1, 6, 42936, 1, 7, 9033, // 1, 6
- 0, 7, 7390, 0, 8, 5745, 1, 7, 43461, 1, 8, 8940, // 1, 7
- 1, 8, 43433, 1, 9, 8929, 2, 8, 7418, 2, 9, 5756, // 1, 8
- 1, 9, 42913, 1, 10, 9014, 2, 9, 7699, 2, 10, 5910, // 1, 9
- 1, 10, 42087, 1, 11, 9206, 2, 10, 8098, 2, 11, 6145, // 1,10
- 1, 11, 41013, 1, 12, 9478, 2, 11, 8599, 2, 12, 6446, // 1,11
- 1, 12, 39759, 1, 13, 9796, 2, 12, 9184, 2, 13, 6797, // 1,12
- 1, 13, 38390, 1, 14, 10133, 2, 13, 9834, 2, 14, 7179, // 1,13
- 1, 14, 36959, 1, 15, 10467, 2, 14, 10532, 2, 15, 7578, // 1,14
- 1, 15, 35506, 1, 16, 10780, 2, 15, 11267, 2, 16, 7983, // 1,15
- 1, 0, 10930, 1, 1, 7626, 2, 0, 36756, 2, 1, 10224, // 2, 0
- 1, 1, 10133, 1, 2, 7179, 2, 1, 38390, 2, 2, 9834, // 2, 1
- 1, 2, 9366, 1, 3, 6732, 2, 2, 40025, 2, 3, 9413, // 2, 2
- 1, 3, 8641, 1, 4, 6297, 2, 3, 41618, 2, 4, 8980, // 2, 3
- 1, 4, 7981, 1, 5, 5891, 2, 4, 43105, 2, 5, 8559, // 2, 4
- 1, 5, 7411, 1, 6, 5537, 2, 5, 44399, 2, 6, 8189, // 2, 5
- 1, 6, 6961, 1, 7, 5261, 2, 6, 45401, 2, 7, 7913, // 2, 6
- 1, 7, 6658, 1, 8, 5087, 2, 7, 46017, 2, 8, 7774, // 2, 7
- 2, 8, 45995, 2, 9, 7766, 3, 8, 6680, 3, 9, 5095, // 2, 8
- 2, 9, 45383, 2, 10, 7899, 3, 9, 6986, 3, 10, 5268, // 2, 9
- 2, 10, 44386, 2, 11, 8167, 3, 10, 7440, 3, 11, 5543, // 2,10
- 2, 11, 43096, 2, 12, 8530, 3, 11, 8015, 3, 12, 5895, // 2,11
- 2, 12, 41614, 2, 13, 8941, 3, 12, 8681, 3, 13, 6300, // 2,12
- 2, 13, 40025, 2, 14, 9366, 3, 13, 9413, 3, 14, 6732, // 2,13
- 2, 14, 38394, 2, 15, 9777, 3, 14, 10188, 3, 15, 7177, // 2,14
- 2, 15, 36764, 2, 16, 10158, 3, 15, 10994, 3, 16, 7620, // 2,15
- 2, 0, 10670, 2, 1, 7285, 3, 0, 37939, 3, 1, 9642, // 3, 0
- 2, 1, 9796, 2, 2, 6797, 3, 1, 39759, 3, 2, 9184, // 3, 1
- 2, 2, 8941, 2, 3, 6299, 3, 2, 41614, 3, 3, 8682, // 3, 2
- 2, 3, 8120, 2, 4, 5804, 3, 3, 43461, 3, 4, 8151, // 3, 3
- 2, 4, 7356, 2, 5, 5330, 3, 4, 45229, 3, 5, 7621, // 3, 4
- 2, 5, 6685, 2, 6, 4906, 3, 5, 46806, 3, 6, 7139, // 3, 5
- 2, 6, 6154, 2, 7, 4572, 3, 6, 48049, 3, 7, 6761, // 3, 6
- 2, 7, 5811, 2, 8, 4366, 3, 7, 48801, 3, 8, 6558, // 3, 7
- 3, 8, 48785, 3, 9, 6552, 4, 8, 5827, 4, 9, 4372, // 3, 8
- 3, 9, 48037, 3, 10, 6750, 4, 9, 6173, 4, 10, 4576, // 3, 9
- 3, 10, 46798, 3, 11, 7121, 4, 10, 6707, 4, 11, 4910, // 3,10
- 3, 11, 45224, 3, 12, 7598, 4, 11, 7382, 4, 12, 5332, // 3,11
- 3, 12, 43461, 3, 13, 8120, 4, 12, 8151, 4, 13, 5804, // 3,12
- 3, 13, 41618, 3, 14, 8641, 4, 13, 8979, 4, 14, 6298, // 3,13
- 3, 14, 39767, 3, 15, 9135, 4, 14, 9841, 4, 15, 6793, // 3,14
- 3, 15, 37951, 3, 16, 9585, 4, 15, 10723, 4, 16, 7277, // 3,15
- 3, 0, 10430, 3, 1, 6975, 4, 0, 39009, 4, 1, 9122, // 4, 0
- 3, 1, 9478, 3, 2, 6447, 4, 1, 41013, 4, 2, 8598, // 4, 1
- 3, 2, 8530, 3, 3, 5895, 4, 2, 43096, 4, 3, 8015, // 4, 2
- 3, 3, 7598, 3, 4, 5331, 4, 3, 45224, 4, 4, 7383, // 4, 3
- 3, 4, 6708, 3, 5, 4774, 4, 4, 47328, 4, 5, 6726, // 4, 4
- 3, 5, 5901, 3, 6, 4257, 4, 5, 49279, 4, 6, 6099, // 4, 5
- 3, 6, 5248, 3, 7, 3834, 4, 6, 50873, 4, 7, 5581, // 4, 6
- 3, 7, 4835, 3, 8, 3575, 4, 7, 51842, 4, 8, 5284, // 4, 7
- 4, 8, 51832, 4, 9, 5280, 5, 8, 4846, 5, 9, 3578, // 4, 8
- 4, 9, 50865, 4, 10, 5573, 5, 9, 5261, 5, 10, 3837, // 4, 9
- 4, 10, 49275, 4, 11, 6086, 5, 10, 5917, 5, 11, 4258, // 4,10
- 4, 11, 47328, 4, 12, 6708, 5, 11, 6727, 5, 12, 4773, // 4,11
- 4, 12, 45229, 4, 13, 7356, 5, 12, 7622, 5, 13, 5329, // 4,12
- 4, 13, 43105, 4, 14, 7981, 5, 13, 8559, 5, 14, 5891, // 4,13
- 4, 14, 41026, 4, 15, 8557, 5, 14, 9513, 5, 15, 6440, // 4,14
- 4, 15, 39026, 4, 16, 9072, 5, 15, 10473, 5, 16, 6965, // 4,15
- 4, 0, 10232, 4, 1, 6710, 5, 0, 39918, 5, 1, 8676, // 5, 0
- 4, 1, 9206, 4, 2, 6145, 5, 1, 42087, 5, 2, 8098, // 5, 1
- 4, 2, 8167, 4, 3, 5543, 5, 2, 44386, 5, 3, 7440, // 5, 2
- 4, 3, 7121, 4, 4, 4909, 5, 3, 46798, 5, 4, 6708, // 5, 3
- 4, 4, 6086, 4, 5, 4258, 5, 4, 49275, 5, 5, 5917, // 5, 4
- 4, 5, 5103, 4, 6, 3621, 5, 5, 51700, 5, 6, 5112, // 5, 5
- 4, 6, 4262, 4, 7, 3064, 5, 6, 53816, 5, 7, 4394, // 5, 6
- 4, 7, 3720, 4, 8, 2708, 5, 7, 55168, 5, 8, 3940, // 5, 7
- 5, 8, 55162, 5, 9, 3938, 6, 8, 3726, 6, 9, 2710, // 5, 8
- 5, 9, 53813, 5, 10, 4388, 6, 9, 4269, 6, 10, 3066, // 5, 9
- 5, 10, 51700, 5, 11, 5103, 6, 10, 5113, 6, 11, 3620, // 5,10
- 5, 11, 49279, 5, 12, 5901, 6, 11, 6099, 6, 12, 4257, // 5,11
- 5, 12, 46806, 5, 13, 6685, 6, 12, 7138, 6, 13, 4907, // 5,12
- 5, 13, 44399, 5, 14, 7411, 6, 13, 8189, 6, 14, 5537, // 5,13
- 5, 14, 42105, 5, 15, 8061, 6, 14, 9233, 6, 15, 6137, // 5,14
- 5, 15, 39940, 5, 16, 8632, 6, 15, 10265, 6, 16, 6699, // 5,15
- 5, 0, 10100, 5, 1, 6502, 6, 0, 40618, 6, 1, 8316, // 6, 0
- 5, 1, 9014, 5, 2, 5910, 6, 1, 42913, 6, 2, 7699, // 6, 1
- 5, 2, 7899, 5, 3, 5268, 6, 2, 45383, 6, 3, 6986, // 6, 2
- 5, 3, 6750, 5, 4, 4576, 6, 3, 48037, 6, 4, 6173, // 6, 3
- 5, 4, 5573, 5, 5, 3837, 6, 4, 50865, 6, 5, 5261, // 6, 4
- 5, 5, 4388, 5, 6, 3065, 6, 5, 53813, 6, 6, 4270, // 6, 5
- 5, 6, 3271, 5, 7, 2316, 6, 6, 56673, 6, 7, 3276, // 6, 6
- 5, 7, 2462, 5, 8, 1766, 6, 7, 58775, 6, 8, 2533, // 6, 7
- 6, 8, 58773, 6, 9, 2532, 7, 8, 2464, 7, 9, 1767, // 6, 8
- 6, 9, 56673, 6, 10, 3271, 7, 9, 3275, 7, 10, 2317, // 6, 9
- 6, 10, 53816, 6, 11, 4262, 7, 10, 4394, 7, 11, 3064, // 6,10
- 6, 11, 50873, 6, 12, 5248, 7, 11, 5581, 7, 12, 3834, // 6,11
- 6, 12, 48049, 6, 13, 6154, 7, 12, 6761, 7, 13, 4572, // 6,12
- 6, 13, 45401, 6, 14, 6961, 7, 13, 7913, 7, 14, 5261, // 6,13
- 6, 14, 42936, 6, 15, 7667, 7, 14, 9032, 7, 15, 5901, // 6,14
- 6, 15, 40646, 6, 16, 8278, 7, 15, 10123, 7, 16, 6489, // 6,15
- 6, 0, 10052, 6, 1, 6360, 7, 0, 41072, 7, 1, 8052, // 7, 0
- 6, 1, 8929, 6, 2, 5756, 7, 1, 43433, 7, 2, 7418, // 7, 1
- 6, 2, 7766, 6, 3, 5095, 7, 2, 45995, 7, 3, 6680, // 7, 2
- 6, 3, 6552, 6, 4, 4372, 7, 3, 48785, 7, 4, 5827, // 7, 3
- 6, 4, 5280, 6, 5, 3579, 7, 4, 51832, 7, 5, 4845, // 7, 4
- 6, 5, 3938, 6, 6, 2710, 7, 5, 55162, 7, 6, 3726, // 7, 5
- 6, 6, 2532, 6, 7, 1767, 7, 6, 58773, 7, 7, 2464, // 7, 6
- 6, 7, 1170, 6, 8, 827, 7, 7, 62369, 7, 8, 1170, // 7, 7
- 7, 8, 62369, 7, 9, 1170, 8, 8, 1170, 8, 9, 827, // 7, 8
- 7, 9, 58775, 7, 10, 2462, 8, 9, 2533, 8, 10, 1766, // 7, 9
- 7, 10, 55168, 7, 11, 3720, 8, 10, 3940, 8, 11, 2708, // 7,10
- 7, 11, 51842, 7, 12, 4835, 8, 11, 5283, 8, 12, 3576, // 7,11
- 7, 12, 48801, 7, 13, 5811, 8, 12, 6558, 8, 13, 4366, // 7,12
- 7, 13, 46017, 7, 14, 6658, 8, 13, 7773, 8, 14, 5088, // 7,13
- 7, 14, 43461, 7, 15, 7390, 8, 14, 8939, 8, 15, 5746, // 7,14
- 7, 15, 41106, 7, 16, 8018, 8, 15, 10066, 8, 16, 6346, // 7,15
- 7, -1, 6346, 7, 0, 10066, 8, -1, 8018, 8, 0, 41106, // 8, 0
- 7, 0, 5745, 7, 1, 8939, 8, 0, 7390, 8, 1, 43462, // 8, 1
- 7, 1, 5087, 7, 2, 7773, 8, 1, 6658, 8, 2, 46018, // 8, 2
- 7, 2, 4366, 7, 3, 6558, 8, 2, 5811, 8, 3, 48801, // 8, 3
- 7, 3, 3575, 7, 4, 5283, 8, 3, 4835, 8, 4, 51843, // 8, 4
- 7, 4, 2708, 7, 5, 3940, 8, 4, 3720, 8, 5, 55168, // 8, 5
- 7, 5, 1766, 7, 6, 2533, 8, 5, 2462, 8, 6, 58775, // 8, 6
- 7, 6, 827, 7, 7, 1170, 8, 6, 1170, 8, 7, 62369, // 8, 7
- 8, 7, 1170, 8, 8, 62369, 9, 7, 827, 9, 8, 1170, // 8, 8
- 8, 8, 2464, 8, 9, 58773, 9, 8, 1767, 9, 9, 2532, // 8, 9
- 8, 9, 3726, 8, 10, 55162, 9, 9, 2710, 9, 10, 3938, // 8,10
- 8, 10, 4846, 8, 11, 51832, 9, 10, 3579, 9, 11, 5279, // 8,11
- 8, 11, 5827, 8, 12, 48785, 9, 11, 4372, 9, 12, 6552, // 8,12
- 8, 12, 6680, 8, 13, 45995, 9, 12, 5095, 9, 13, 7766, // 8,13
- 8, 13, 7418, 8, 14, 43433, 9, 13, 5756, 9, 14, 8929, // 8,14
- 8, 14, 8052, 8, 15, 41072, 9, 14, 6360, 9, 15, 10052, // 8,15
- 8, -1, 6489, 8, 0, 10123, 9, -1, 8278, 9, 0, 40646, // 9, 0
- 8, 0, 5900, 8, 1, 9032, 9, 0, 7667, 9, 1, 42937, // 9, 1
- 8, 1, 5261, 8, 2, 7913, 9, 1, 6961, 9, 2, 45401, // 9, 2
- 8, 2, 4572, 8, 3, 6761, 9, 2, 6154, 9, 3, 48049, // 9, 3
- 8, 3, 3834, 8, 4, 5581, 9, 3, 5248, 9, 4, 50873, // 9, 4
- 8, 4, 3064, 8, 5, 4394, 9, 4, 4262, 9, 5, 53816, // 9, 5
- 8, 5, 2316, 8, 6, 3275, 9, 5, 3271, 9, 6, 56674, // 9, 6
- 8, 6, 1767, 8, 7, 2464, 9, 6, 2532, 9, 7, 58773, // 9, 7
- 9, 7, 2533, 9, 8, 58775, 10, 7, 1766, 10, 8, 2462, // 9, 8
- 9, 8, 3275, 9, 9, 56673, 10, 8, 2316, 10, 9, 3272, // 9, 9
- 9, 9, 4269, 9, 10, 53813, 10, 9, 3065, 10, 10, 4389, // 9,10
- 9, 10, 5261, 9, 11, 50865, 10, 10, 3837, 10, 11, 5573, // 9,11
- 9, 11, 6173, 9, 12, 48037, 10, 11, 4576, 10, 12, 6750, // 9,12
- 9, 12, 6986, 9, 13, 45383, 10, 12, 5268, 10, 13, 7899, // 9,13
- 9, 13, 7699, 9, 14, 42913, 10, 13, 5910, 10, 14, 9014, // 9,14
- 9, 14, 8316, 9, 15, 40618, 10, 14, 6502, 10, 15, 10100, // 9,15
- 9, -1, 6699, 9, 0, 10265, 10, -1, 8632, 10, 0, 39940, // 10, 0
- 9, 0, 6137, 9, 1, 9233, 10, 0, 8061, 10, 1, 42105, // 10, 1
- 9, 1, 5537, 9, 2, 8189, 10, 1, 7411, 10, 2, 44399, // 10, 2
- 9, 2, 4906, 9, 3, 7138, 10, 2, 6685, 10, 3, 46807, // 10, 3
- 9, 3, 4257, 9, 4, 6099, 10, 3, 5901, 10, 4, 49279, // 10, 4
- 9, 4, 3621, 9, 5, 5113, 10, 4, 5103, 10, 5, 51699, // 10, 5
- 9, 5, 3065, 9, 6, 4269, 10, 5, 4388, 10, 6, 53814, // 10, 6
- 9, 6, 2710, 9, 7, 3726, 10, 6, 3938, 10, 7, 55162, // 10, 7
- 10, 7, 3940, 10, 8, 55168, 11, 7, 2708, 11, 8, 3720, // 10, 8
- 10, 8, 4394, 10, 9, 53816, 11, 8, 3064, 11, 9, 4262, // 10, 9
- 10, 9, 5113, 10, 10, 51700, 11, 9, 3621, 11, 10, 5102, // 10,10
- 10, 10, 5917, 10, 11, 49275, 11, 10, 4258, 11, 11, 6086, // 10,11
- 10, 11, 6707, 10, 12, 46798, 11, 11, 4909, 11, 12, 7122, // 10,12
- 10, 12, 7440, 10, 13, 44386, 11, 12, 5543, 11, 13, 8167, // 10,13
- 10, 13, 8098, 10, 14, 42087, 11, 13, 6145, 11, 14, 9206, // 10,14
- 10, 14, 8676, 10, 15, 39918, 11, 14, 6710, 11, 15, 10232, // 10,15
- 10, -1, 6965, 10, 0, 10473, 11, -1, 9072, 11, 0, 39026, // 11, 0
- 10, 0, 6440, 10, 1, 9513, 11, 0, 8557, 11, 1, 41026, // 11, 1
- 10, 1, 5891, 10, 2, 8559, 11, 1, 7981, 11, 2, 43105, // 11, 2
- 10, 2, 5330, 10, 3, 7622, 11, 2, 7356, 11, 3, 45228, // 11, 3
- 10, 3, 4774, 10, 4, 6727, 11, 3, 6708, 11, 4, 47327, // 11, 4
- 10, 4, 4258, 10, 5, 5917, 11, 4, 6086, 11, 5, 49275, // 11, 5
- 10, 5, 3837, 10, 6, 5261, 11, 5, 5573, 11, 6, 50865, // 11, 6
- 10, 6, 3579, 10, 7, 4846, 11, 6, 5280, 11, 7, 51831, // 11, 7
- 11, 7, 5283, 11, 8, 51842, 12, 7, 3575, 12, 8, 4836, // 11, 8
- 11, 8, 5581, 11, 9, 50873, 12, 8, 3834, 12, 9, 5248, // 11, 9
- 11, 9, 6099, 11, 10, 49279, 12, 9, 4257, 12, 10, 5901, // 11,10
- 11, 10, 6727, 11, 11, 47328, 12, 10, 4774, 12, 11, 6707, // 11,11
- 11, 11, 7382, 11, 12, 45224, 12, 11, 5331, 12, 12, 7599, // 11,12
- 11, 12, 8015, 11, 13, 43096, 12, 12, 5895, 12, 13, 8530, // 11,13
- 11, 13, 8599, 11, 14, 41013, 12, 13, 6447, 12, 14, 9477, // 11,14
- 11, 14, 9122, 11, 15, 39009, 12, 14, 6975, 12, 15, 10430, // 11,15
- 11, -1, 7276, 11, 0, 10723, 12, -1, 9585, 12, 0, 37952, // 12, 0
- 11, 0, 6792, 11, 1, 9841, 12, 0, 9135, 12, 1, 39768, // 12, 1
- 11, 1, 6297, 11, 2, 8979, 12, 1, 8641, 12, 2, 41619, // 12, 2
- 11, 2, 5804, 11, 3, 8151, 12, 2, 8120, 12, 3, 43461, // 12, 3
- 11, 3, 5331, 11, 4, 7382, 12, 3, 7598, 12, 4, 45225, // 12, 4
- 11, 4, 4909, 11, 5, 6707, 12, 4, 7121, 12, 5, 46799, // 12, 5
- 11, 5, 4576, 11, 6, 6173, 12, 5, 6750, 12, 6, 48037, // 12, 6
- 11, 6, 4372, 11, 7, 5827, 12, 6, 6552, 12, 7, 48785, // 12, 7
- 12, 7, 6558, 12, 8, 48801, 13, 7, 4366, 13, 8, 5811, // 12, 8
- 12, 8, 6761, 12, 9, 48049, 13, 8, 4572, 13, 9, 6154, // 12, 9
- 12, 9, 7138, 12, 10, 46806, 13, 9, 4906, 13, 10, 6686, // 12,10
- 12, 10, 7622, 12, 11, 45229, 13, 10, 5330, 13, 11, 7355, // 12,11
- 12, 11, 8151, 12, 12, 43461, 13, 11, 5804, 13, 12, 8120, // 12,12
- 12, 12, 8681, 12, 13, 41614, 13, 12, 6299, 13, 13, 8942, // 12,13
- 12, 13, 9184, 12, 14, 39759, 13, 13, 6797, 13, 14, 9796, // 12,14
- 12, 14, 9642, 12, 15, 37939, 13, 14, 7285, 13, 15, 10670, // 12,15
- 12, -1, 7620, 12, 0, 10994, 13, -1, 10158, 13, 0, 36764, // 13, 0
- 12, 0, 7177, 12, 1, 10188, 13, 0, 9777, 13, 1, 38394, // 13, 1
- 12, 1, 6732, 12, 2, 9413, 13, 1, 9366, 13, 2, 40025, // 13, 2
- 12, 2, 6299, 12, 3, 8681, 13, 2, 8941, 13, 3, 41615, // 13, 3
- 12, 3, 5895, 12, 4, 8015, 13, 3, 8530, 13, 4, 43096, // 13, 4
- 12, 4, 5543, 12, 5, 7440, 13, 4, 8167, 13, 5, 44386, // 13, 5
- 12, 5, 5268, 12, 6, 6986, 13, 5, 7899, 13, 6, 45383, // 13, 6
- 12, 6, 5095, 12, 7, 6680, 13, 6, 7766, 13, 7, 45995, // 13, 7
- 13, 7, 7773, 13, 8, 46017, 14, 7, 5087, 14, 8, 6659, // 13, 8
- 13, 8, 7913, 13, 9, 45401, 14, 8, 5261, 14, 9, 6961, // 13, 9
- 13, 9, 8189, 13, 10, 44399, 14, 9, 5537, 14, 10, 7411, // 13,10
- 13, 10, 8559, 13, 11, 43105, 14, 10, 5891, 14, 11, 7981, // 13,11
- 13, 11, 8979, 13, 12, 41618, 14, 11, 6297, 14, 12, 8642, // 13,12
- 13, 12, 9413, 13, 13, 40025, 14, 12, 6732, 14, 13, 9366, // 13,13
- 13, 13, 9834, 13, 14, 38390, 14, 13, 7179, 14, 14, 10133, // 13,14
- 13, 14, 10224, 13, 15, 36756, 14, 14, 7626, 14, 15, 10930, // 13,15
- 13, -1, 7983, 13, 0, 11267, 14, -1, 10780, 14, 0, 35506, // 14, 0
- 13, 0, 7579, 13, 1, 10532, 14, 0, 10467, 14, 1, 36958, // 14, 1
- 13, 1, 7179, 13, 2, 9834, 14, 1, 10133, 14, 2, 38390, // 14, 2
- 13, 2, 6797, 13, 3, 9184, 14, 2, 9796, 14, 3, 39759, // 14, 3
- 13, 3, 6447, 13, 4, 8599, 14, 3, 9478, 14, 4, 41012, // 14, 4
- 13, 4, 6145, 13, 5, 8098, 14, 4, 9206, 14, 5, 42087, // 14, 5
- 13, 5, 5910, 13, 6, 7699, 14, 5, 9014, 14, 6, 42913, // 14, 6
- 13, 6, 5756, 13, 7, 7418, 14, 6, 8929, 14, 7, 43433, // 14, 7
- 14, 7, 8939, 14, 8, 43461, 15, 7, 5745, 15, 8, 7391, // 14, 8
- 14, 8, 9032, 14, 9, 42936, 15, 8, 5900, 15, 9, 7668, // 14, 9
- 14, 9, 9233, 14, 10, 42105, 15, 9, 6137, 15, 10, 8061, // 14,10
- 14, 10, 9513, 14, 11, 41026, 15, 10, 6440, 15, 11, 8557, // 14,11
- 14, 11, 9841, 14, 12, 39767, 15, 11, 6792, 15, 12, 9136, // 14,12
- 14, 12, 10188, 14, 13, 38394, 15, 12, 7177, 15, 13, 9777, // 14,13
- 14, 13, 10532, 14, 14, 36959, 15, 13, 7579, 15, 14, 10466, // 14,14
- 14, 14, 10855, 14, 15, 35502, 15, 14, 7987, 15, 15, 11192, // 14,15
- 14, -1, 8358, 14, 0, 11526, 15, -1, 11440, 15, 0, 34212, // 15, 0
- 14, 0, 7987, 14, 1, 10855, 15, 0, 11192, 15, 1, 35502, // 15, 1
- 14, 1, 7626, 14, 2, 10224, 15, 1, 10930, 15, 2, 36756, // 15, 2
- 14, 2, 7285, 14, 3, 9642, 15, 2, 10670, 15, 3, 37939, // 15, 3
- 14, 3, 6975, 14, 4, 9122, 15, 3, 10430, 15, 4, 39009, // 15, 4
- 14, 4, 6710, 14, 5, 8676, 15, 4, 10232, 15, 5, 39918, // 15, 5
- 14, 5, 6502, 14, 6, 8316, 15, 5, 10100, 15, 6, 40618, // 15, 6
- 14, 6, 6360, 14, 7, 8052, 15, 6, 10052, 15, 7, 41072, // 15, 7
- 15, 7, 10066, 15, 8, 41106, 16, 7, 6346, 16, 8, 8018, // 15, 8
- 15, 8, 10123, 15, 9, 40646, 16, 8, 6489, 16, 9, 8278, // 15, 9
- 15, 9, 10265, 15, 10, 39940, 16, 9, 6699, 16, 10, 8632, // 15,10
- 15, 10, 10473, 15, 11, 39026, 16, 10, 6965, 16, 11, 9072, // 15,11
- 15, 11, 10723, 15, 12, 37951, 16, 11, 7276, 16, 12, 9586, // 15,12
- 15, 12, 10994, 15, 13, 36764, 16, 12, 7620, 16, 13, 10158, // 15,13
- 15, 13, 11267, 15, 14, 35506, 16, 13, 7983, 16, 14, 10780, // 15,14
- 15, 14, 11526, 15, 15, 34212, 16, 14, 8358, 16, 15, 11440, // 15,15
- // angle of -1.0 degrees
- -1, 0, 8769, -1, 1, 6280, 0, 0, 41693, 0, 1, 8794, // 0, 0
- -1, 1, 8265, -1, 2, 5974, 0, 1, 42823, 0, 2, 8474, // 0, 1
- -1, 2, 7791, -1, 3, 5682, 0, 2, 43904, 0, 3, 8159, // 0, 2
- -1, 3, 7356, -1, 4, 5410, 0, 3, 44907, 0, 4, 7863, // 0, 3
- -1, 4, 6970, -1, 5, 5169, 0, 4, 45799, 0, 5, 7598, // 0, 4
- -1, 5, 6644, -1, 6, 4967, 0, 5, 46541, 0, 6, 7384, // 0, 5
- -1, 6, 6391, -1, 7, 4814, 0, 6, 47098, 0, 7, 7233, // 0, 6
- -1, 7, 6217, -1, 8, 4718, 0, 7, 47440, 0, 8, 7161, // 0, 7
- 0, 8, 47426, 0, 9, 7158, 1, 8, 6230, 1, 9, 4722, // 0, 8
- 0, 9, 47086, 0, 10, 7227, 1, 9, 6405, 1, 10, 4818, // 0, 9
- 0, 10, 46532, 0, 11, 7374, 1, 10, 6659, 1, 11, 4971, // 0,10
- 0, 11, 45791, 0, 12, 7587, 1, 11, 6986, 1, 12, 5172, // 0,11
- 0, 12, 44901, 0, 13, 7848, 1, 12, 7374, 1, 13, 5413, // 0,12
- 0, 13, 43900, 0, 14, 8141, 1, 13, 7812, 1, 14, 5683, // 0,13
- 0, 14, 42821, 0, 15, 8452, 1, 14, 8288, 1, 15, 5975, // 0,14
- 0, 15, 41693, 0, 16, 8769, 1, 15, 8795, 1, 16, 6279, // 0,15
- 0, 0, 8452, 0, 1, 5975, 1, 0, 42821, 1, 1, 8288, // 1, 0
- 0, 1, 7901, 0, 2, 5640, 1, 1, 44074, 1, 2, 7921, // 1, 1
- 0, 2, 7378, 0, 3, 5315, 1, 2, 45288, 1, 3, 7555, // 1, 2
- 0, 3, 6892, 0, 4, 5009, 1, 3, 46430, 1, 4, 7205, // 1, 3
- 0, 4, 6458, 0, 5, 4734, 1, 4, 47458, 1, 5, 6886, // 1, 4
- 0, 5, 6092, 0, 6, 4502, 1, 5, 48322, 1, 6, 6620, // 1, 5
- 0, 6, 5809, 0, 7, 4327, 1, 6, 48969, 1, 7, 6431, // 1, 6
- 0, 7, 5623, 0, 8, 4221, 1, 7, 49358, 1, 8, 6334, // 1, 7
- 1, 8, 49347, 1, 9, 6332, 2, 8, 5633, 2, 9, 4224, // 1, 8
- 1, 9, 48960, 1, 10, 6425, 2, 9, 5820, 2, 10, 4331, // 1, 9
- 1, 10, 48314, 1, 11, 6613, 2, 10, 6104, 2, 11, 4505, // 1,10
- 1, 11, 47453, 1, 12, 6875, 2, 11, 6472, 2, 12, 4736, // 1,11
- 1, 12, 46427, 1, 13, 7191, 2, 12, 6908, 2, 13, 5010, // 1,12
- 1, 13, 45286, 1, 14, 7539, 2, 13, 7395, 2, 14, 5316, // 1,13
- 1, 14, 44074, 1, 15, 7901, 2, 14, 7921, 2, 15, 5640, // 1,14
- 1, 15, 42823, 1, 16, 8265, 2, 15, 8474, 2, 16, 5974, // 1,15
- 1, 0, 8141, 1, 1, 5684, 2, 0, 43900, 2, 1, 7811, // 2, 0
- 1, 1, 7539, 1, 2, 5316, 2, 1, 45286, 2, 2, 7395, // 2, 1
- 1, 2, 6959, 1, 3, 4954, 2, 2, 46650, 2, 3, 6973, // 2, 2
- 1, 3, 6414, 1, 4, 4607, 2, 3, 47955, 2, 4, 6560, // 2, 3
- 1, 4, 5920, 1, 5, 4290, 2, 4, 49150, 2, 5, 6176, // 2, 4
- 1, 5, 5499, 1, 6, 4019, 2, 5, 50171, 2, 6, 5847, // 2, 5
- 1, 6, 5175, 1, 7, 3813, 2, 6, 50942, 2, 7, 5606, // 2, 6
- 1, 7, 4970, 1, 8, 3691, 2, 7, 51395, 2, 8, 5480, // 2, 7
- 2, 8, 51387, 2, 9, 5478, 3, 8, 4978, 3, 9, 3693, // 2, 8
- 2, 9, 50935, 2, 10, 5602, 3, 9, 5184, 3, 10, 3815, // 2, 9
- 2, 10, 50165, 2, 11, 5842, 3, 10, 5508, 3, 11, 4021, // 2,10
- 2, 11, 49147, 2, 12, 6168, 3, 11, 5930, 3, 12, 4291, // 2,11
- 2, 12, 47953, 2, 13, 6549, 3, 12, 6426, 3, 13, 4608, // 2,12
- 2, 13, 46650, 2, 14, 6959, 3, 13, 6973, 3, 14, 4954, // 2,13
- 2, 14, 45288, 2, 15, 7378, 3, 14, 7555, 3, 15, 5315, // 2,14
- 2, 15, 43904, 2, 16, 7791, 3, 15, 8159, 3, 16, 5682, // 2,15
- 2, 0, 7848, 2, 1, 5413, 3, 0, 44901, 3, 1, 7374, // 3, 0
- 2, 1, 7191, 2, 2, 5011, 3, 1, 46427, 3, 2, 6907, // 3, 1
- 2, 2, 6549, 2, 3, 4608, 3, 2, 47953, 3, 3, 6426, // 3, 2
- 2, 3, 5934, 2, 4, 4214, 3, 3, 49445, 3, 4, 5943, // 3, 3
- 2, 4, 5365, 2, 5, 3845, 3, 4, 50844, 3, 5, 5482, // 3, 4
- 2, 5, 4872, 2, 6, 3522, 3, 5, 52069, 3, 6, 5073, // 3, 5
- 2, 6, 4489, 2, 7, 3273, 3, 6, 53012, 3, 7, 4762, // 3, 6
- 2, 7, 4254, 2, 8, 3126, 3, 7, 53562, 3, 8, 4594, // 3, 7
- 3, 8, 53557, 3, 9, 4592, 4, 8, 4259, 4, 9, 3128, // 3, 8
- 3, 9, 53008, 3, 10, 4759, 4, 9, 4495, 4, 10, 3274, // 3, 9
- 3, 10, 52066, 3, 11, 5069, 4, 10, 4879, 4, 11, 3522, // 3,10
- 3, 11, 50843, 3, 12, 5474, 4, 11, 5373, 4, 12, 3846, // 3,11
- 3, 12, 49445, 3, 13, 5934, 4, 12, 5943, 4, 13, 4214, // 3,12
- 3, 13, 47955, 3, 14, 6414, 4, 13, 6560, 4, 14, 4607, // 3,13
- 3, 14, 46430, 3, 15, 6892, 4, 14, 7204, 4, 15, 5010, // 3,14
- 3, 15, 44907, 3, 16, 7356, 4, 15, 7863, 4, 16, 5410, // 3,15
- 3, 0, 7587, 3, 1, 5172, 4, 0, 45791, 4, 1, 6986, // 4, 0
- 3, 1, 6875, 3, 2, 4736, 4, 1, 47453, 4, 2, 6472, // 4, 1
- 3, 2, 6168, 3, 3, 4291, 4, 2, 49147, 4, 3, 5930, // 4, 2
- 3, 3, 5474, 3, 4, 3846, 4, 3, 50843, 4, 4, 5373, // 4, 3
- 3, 4, 4816, 3, 5, 3415, 4, 4, 52484, 4, 5, 4821, // 4, 4
- 3, 5, 4226, 3, 6, 3023, 4, 5, 53975, 4, 6, 4312, // 4, 5
- 3, 6, 3755, 3, 7, 2710, 4, 6, 55166, 4, 7, 3905, // 4, 6
- 3, 7, 3469, 3, 8, 2524, 4, 7, 55870, 4, 8, 3673, // 4, 7
- 4, 8, 55867, 4, 9, 3671, 5, 8, 3473, 5, 9, 2525, // 4, 8
- 4, 9, 55164, 4, 10, 3902, 5, 9, 3759, 5, 10, 2711, // 4, 9
- 4, 10, 53973, 4, 11, 4309, 5, 10, 4230, 5, 11, 3024, // 4,10
- 4, 11, 52484, 4, 12, 4816, 5, 11, 4822, 5, 12, 3414, // 4,11
- 4, 12, 50844, 4, 13, 5365, 5, 12, 5481, 5, 13, 3846, // 4,12
- 4, 13, 49150, 4, 14, 5920, 5, 13, 6176, 5, 14, 4290, // 4,13
- 4, 14, 47458, 4, 15, 6458, 5, 14, 6886, 5, 15, 4734, // 4,14
- 4, 15, 45799, 4, 16, 6970, 5, 15, 7599, 5, 16, 5168, // 4,15
- 4, 0, 7374, 4, 1, 4971, 5, 0, 46532, 5, 1, 6659, // 5, 0
- 4, 1, 6613, 4, 2, 4505, 5, 1, 48314, 5, 2, 6104, // 5, 1
- 4, 2, 5842, 4, 3, 4020, 5, 2, 50165, 5, 3, 5509, // 5, 2
- 4, 3, 5069, 4, 4, 3523, 5, 3, 52066, 5, 4, 4878, // 5, 3
- 4, 4, 4309, 4, 5, 3023, 5, 4, 53973, 5, 5, 4231, // 5, 4
- 4, 5, 3595, 4, 6, 2546, 5, 5, 55798, 5, 6, 3597, // 5, 5
- 4, 6, 2993, 4, 7, 2138, 5, 6, 57354, 5, 7, 3051, // 5, 6
- 4, 7, 2615, 4, 8, 1884, 5, 7, 58324, 5, 8, 2713, // 5, 7
- 5, 8, 58322, 5, 9, 2713, 6, 8, 2616, 6, 9, 1885, // 5, 8
- 5, 9, 57353, 5, 10, 3050, 6, 9, 2995, 6, 10, 2138, // 5, 9
- 5, 10, 55798, 5, 11, 3595, 6, 10, 3598, 6, 11, 2545, // 5,10
- 5, 11, 53975, 5, 12, 4226, 6, 11, 4313, 6, 12, 3022, // 5,11
- 5, 12, 52069, 5, 13, 4872, 6, 12, 5073, 6, 13, 3522, // 5,12
- 5, 13, 50171, 5, 14, 5499, 6, 13, 5848, 6, 14, 4018, // 5,13
- 5, 14, 48322, 5, 15, 6092, 6, 14, 6620, 6, 15, 4502, // 5,14
- 5, 15, 46541, 5, 16, 6644, 6, 15, 7383, 6, 16, 4968, // 5,15
- 5, 0, 7227, 5, 1, 4818, 6, 0, 47086, 6, 1, 6405, // 6, 0
- 5, 1, 6425, 5, 2, 4330, 6, 1, 48960, 6, 2, 5821, // 6, 1
- 5, 2, 5602, 5, 3, 3815, 6, 2, 50935, 6, 3, 5184, // 6, 2
- 5, 3, 4759, 5, 4, 3274, 6, 3, 53008, 6, 4, 4495, // 6, 3
- 5, 4, 3902, 5, 5, 2711, 6, 4, 55164, 6, 5, 3759, // 6, 4
- 5, 5, 3050, 5, 6, 2138, 6, 5, 57353, 6, 6, 2995, // 6, 5
- 5, 6, 2258, 5, 7, 1597, 6, 6, 59422, 6, 7, 2259, // 6, 6
- 5, 7, 1695, 5, 8, 1209, 6, 7, 60906, 6, 8, 1726, // 6, 7
- 6, 8, 60905, 6, 9, 1726, 7, 8, 1695, 7, 9, 1210, // 6, 8
- 6, 9, 59422, 6, 10, 2258, 7, 9, 2259, 7, 10, 1597, // 6, 9
- 6, 10, 57354, 6, 11, 2993, 7, 10, 3051, 7, 11, 2138, // 6,10
- 6, 11, 55166, 6, 12, 3755, 7, 11, 3904, 7, 12, 2711, // 6,11
- 6, 12, 53012, 6, 13, 4489, 7, 12, 4762, 7, 13, 3273, // 6,12
- 6, 13, 50942, 6, 14, 5175, 7, 13, 5606, 7, 14, 3813, // 6,13
- 6, 14, 48969, 6, 15, 5809, 7, 14, 6430, 7, 15, 4328, // 6,14
- 6, 15, 47098, 6, 16, 6391, 7, 15, 7233, 7, 16, 4814, // 6,15
- 6, 0, 7158, 6, 1, 4722, 7, 0, 47426, 7, 1, 6230, // 7, 0
- 6, 1, 6332, 6, 2, 4224, 7, 1, 49347, 7, 2, 5633, // 7, 1
- 6, 2, 5478, 6, 3, 3693, 7, 2, 51387, 7, 3, 4978, // 7, 2
- 6, 3, 4592, 6, 4, 3128, 7, 3, 53557, 7, 4, 4259, // 7, 3
- 6, 4, 3671, 6, 5, 2525, 7, 4, 55867, 7, 5, 3473, // 7, 4
- 6, 5, 2713, 6, 6, 1884, 7, 5, 58322, 7, 6, 2617, // 7, 5
- 6, 6, 1726, 6, 7, 1210, 7, 6, 60905, 7, 7, 1695, // 7, 6
- 6, 7, 789, 6, 8, 558, 7, 7, 63399, 7, 8, 790, // 7, 7
- 7, 8, 63399, 7, 9, 789, 8, 8, 789, 8, 9, 559, // 7, 8
- 7, 9, 60906, 7, 10, 1695, 8, 9, 1726, 8, 10, 1209, // 7, 9
- 7, 10, 58324, 7, 11, 2615, 8, 10, 2714, 8, 11, 1883, // 7,10
- 7, 11, 55870, 7, 12, 3469, 8, 11, 3672, 8, 12, 2525, // 7,11
- 7, 12, 53562, 7, 13, 4254, 8, 12, 4594, 8, 13, 3126, // 7,12
- 7, 13, 51395, 7, 14, 4970, 8, 13, 5480, 8, 14, 3691, // 7,13
- 7, 14, 49358, 7, 15, 5623, 8, 14, 6335, 8, 15, 4220, // 7,14
- 7, 15, 47440, 7, 16, 6217, 8, 15, 7161, 8, 16, 4718, // 7,15
- 7, -1, 4718, 7, 0, 7161, 8, -1, 6217, 8, 0, 47440, // 8, 0
- 7, 0, 4221, 7, 1, 6335, 8, 0, 5623, 8, 1, 49357, // 8, 1
- 7, 1, 3691, 7, 2, 5480, 8, 1, 4970, 8, 2, 51395, // 8, 2
- 7, 2, 3126, 7, 3, 4594, 8, 2, 4254, 8, 3, 53562, // 8, 3
- 7, 3, 2524, 7, 4, 3672, 8, 3, 3469, 8, 4, 55871, // 8, 4
- 7, 4, 1884, 7, 5, 2714, 8, 4, 2615, 8, 5, 58323, // 8, 5
- 7, 5, 1209, 7, 6, 1726, 8, 5, 1695, 8, 6, 60906, // 8, 6
- 7, 6, 558, 7, 7, 789, 8, 6, 789, 8, 7, 63400, // 8, 7
- 8, 7, 789, 8, 8, 63399, 9, 7, 558, 9, 8, 790, // 8, 8
- 8, 8, 1695, 8, 9, 60905, 9, 8, 1210, 9, 9, 1726, // 8, 9
- 8, 9, 2616, 8, 10, 58322, 9, 9, 1884, 9, 10, 2714, // 8,10
- 8, 10, 3473, 8, 11, 55867, 9, 10, 2525, 9, 11, 3671, // 8,11
- 8, 11, 4259, 8, 12, 53557, 9, 11, 3128, 9, 12, 4592, // 8,12
- 8, 12, 4978, 8, 13, 51387, 9, 12, 3693, 9, 13, 5478, // 8,13
- 8, 13, 5633, 8, 14, 49347, 9, 13, 4224, 9, 14, 6332, // 8,14
- 8, 14, 6230, 8, 15, 47426, 9, 14, 4722, 9, 15, 7158, // 8,15
- 8, -1, 4814, 8, 0, 7233, 9, -1, 6391, 9, 0, 47098, // 9, 0
- 8, 0, 4327, 8, 1, 6430, 9, 0, 5809, 9, 1, 48970, // 9, 1
- 8, 1, 3813, 8, 2, 5606, 9, 1, 5175, 9, 2, 50942, // 9, 2
- 8, 2, 3273, 8, 3, 4762, 9, 2, 4489, 9, 3, 53012, // 9, 3
- 8, 3, 2710, 8, 4, 3904, 9, 3, 3755, 9, 4, 55167, // 9, 4
- 8, 4, 2138, 8, 5, 3051, 9, 4, 2993, 9, 5, 57354, // 9, 5
- 8, 5, 1597, 8, 6, 2259, 9, 5, 2258, 9, 6, 59422, // 9, 6
- 8, 6, 1210, 8, 7, 1695, 9, 6, 1726, 9, 7, 60905, // 9, 7
- 9, 7, 1726, 9, 8, 60906, 10, 7, 1209, 10, 8, 1695, // 9, 8
- 9, 8, 2259, 9, 9, 59422, 10, 8, 1597, 10, 9, 2258, // 9, 9
- 9, 9, 2995, 9, 10, 57353, 10, 9, 2138, 10, 10, 3050, // 9,10
- 9, 10, 3759, 9, 11, 55164, 10, 10, 2711, 10, 11, 3902, // 9,11
- 9, 11, 4495, 9, 12, 53008, 10, 11, 3274, 10, 12, 4759, // 9,12
- 9, 12, 5184, 9, 13, 50935, 10, 12, 3815, 10, 13, 5602, // 9,13
- 9, 13, 5820, 9, 14, 48960, 10, 13, 4330, 10, 14, 6426, // 9,14
- 9, 14, 6405, 9, 15, 47086, 10, 14, 4818, 10, 15, 7227, // 9,15
- 9, -1, 4967, 9, 0, 7383, 10, -1, 6644, 10, 0, 46542, // 10, 0
- 9, 0, 4502, 9, 1, 6620, 10, 0, 6092, 10, 1, 48322, // 10, 1
- 9, 1, 4019, 9, 2, 5848, 10, 1, 5499, 10, 2, 50170, // 10, 2
- 9, 2, 3522, 9, 3, 5073, 10, 2, 4872, 10, 3, 52069, // 10, 3
- 9, 3, 3023, 9, 4, 4313, 10, 3, 4226, 10, 4, 53974, // 10, 4
- 9, 4, 2546, 9, 5, 3598, 10, 4, 3595, 10, 5, 55797, // 10, 5
- 9, 5, 2138, 9, 6, 2995, 10, 5, 3050, 10, 6, 57353, // 10, 6
- 9, 6, 1884, 9, 7, 2616, 10, 6, 2713, 10, 7, 58323, // 10, 7
- 10, 7, 2714, 10, 8, 58324, 11, 7, 1884, 11, 8, 2614, // 10, 8
- 10, 8, 3051, 10, 9, 57354, 11, 8, 2138, 11, 9, 2993, // 10, 9
- 10, 9, 3598, 10, 10, 55798, 11, 9, 2546, 11, 10, 3594, // 10,10
- 10, 10, 4230, 10, 11, 53973, 11, 10, 3023, 11, 11, 4310, // 10,11
- 10, 11, 4879, 10, 12, 52066, 11, 11, 3523, 11, 12, 5068, // 10,12
- 10, 12, 5508, 10, 13, 50165, 11, 12, 4020, 11, 13, 5843, // 10,13
- 10, 13, 6104, 10, 14, 48314, 11, 13, 4505, 11, 14, 6613, // 10,14
- 10, 14, 6659, 10, 15, 46532, 11, 14, 4971, 11, 15, 7374, // 10,15
- 10, -1, 5169, 10, 0, 7599, 11, -1, 6970, 11, 0, 45798, // 11, 0
- 10, 0, 4734, 10, 1, 6886, 11, 0, 6458, 11, 1, 47458, // 11, 1
- 10, 1, 4290, 10, 2, 6176, 11, 1, 5920, 11, 2, 49150, // 11, 2
- 10, 2, 3845, 10, 3, 5481, 11, 2, 5365, 11, 3, 50845, // 11, 3
- 10, 3, 3415, 10, 4, 4822, 11, 3, 4816, 11, 4, 52483, // 11, 4
- 10, 4, 3023, 10, 5, 4230, 11, 4, 4309, 11, 5, 53974, // 11, 5
- 10, 5, 2711, 10, 6, 3759, 11, 5, 3902, 11, 6, 55164, // 11, 6
- 10, 6, 2525, 10, 7, 3473, 11, 6, 3671, 11, 7, 55867, // 11, 7
- 11, 7, 3672, 11, 8, 55870, 12, 7, 2524, 12, 8, 3470, // 11, 8
- 11, 8, 3904, 11, 9, 55166, 12, 8, 2710, 12, 9, 3756, // 11, 9
- 11, 9, 4313, 11, 10, 53975, 12, 9, 3023, 12, 10, 4225, // 11,10
- 11, 10, 4822, 11, 11, 52484, 12, 10, 3415, 12, 11, 4815, // 11,11
- 11, 11, 5373, 11, 12, 50843, 12, 11, 3846, 12, 12, 5474, // 11,12
- 11, 12, 5930, 11, 13, 49147, 12, 12, 4291, 12, 13, 6168, // 11,13
- 11, 13, 6472, 11, 14, 47453, 12, 13, 4736, 12, 14, 6875, // 11,14
- 11, 14, 6986, 11, 15, 45791, 12, 14, 5172, 12, 15, 7587, // 11,15
- 11, -1, 5410, 11, 0, 7863, 12, -1, 7356, 12, 0, 44907, // 12, 0
- 11, 0, 5009, 11, 1, 7204, 12, 0, 6892, 12, 1, 46431, // 12, 1
- 11, 1, 4607, 11, 2, 6560, 12, 1, 6414, 12, 2, 47955, // 12, 2
- 11, 2, 4214, 11, 3, 5943, 12, 2, 5934, 12, 3, 49445, // 12, 3
- 11, 3, 3846, 11, 4, 5373, 12, 3, 5474, 12, 4, 50843, // 12, 4
- 11, 4, 3523, 11, 5, 4879, 12, 4, 5069, 12, 5, 52065, // 12, 5
- 11, 5, 3274, 11, 6, 4495, 12, 5, 4759, 12, 6, 53008, // 12, 6
- 11, 6, 3128, 11, 7, 4259, 12, 6, 4592, 12, 7, 53557, // 12, 7
- 12, 7, 4594, 12, 8, 53562, 13, 7, 3126, 13, 8, 4254, // 12, 8
- 12, 8, 4762, 12, 9, 53012, 13, 8, 3273, 13, 9, 4489, // 12, 9
- 12, 9, 5073, 12, 10, 52069, 13, 9, 3522, 13, 10, 4872, // 12,10
- 12, 10, 5481, 12, 11, 50844, 13, 10, 3845, 13, 11, 5366, // 12,11
- 12, 11, 5943, 12, 12, 49445, 13, 11, 4214, 13, 12, 5934, // 12,12
- 12, 12, 6426, 12, 13, 47953, 13, 12, 4608, 13, 13, 6549, // 12,13
- 12, 13, 6908, 12, 14, 46427, 13, 13, 5011, 13, 14, 7190, // 12,14
- 12, 14, 7374, 12, 15, 44901, 13, 14, 5413, 13, 15, 7848, // 12,15
- 12, -1, 5682, 12, 0, 8159, 13, -1, 7791, 13, 0, 43904, // 13, 0
- 12, 0, 5315, 12, 1, 7555, 13, 0, 7378, 13, 1, 45288, // 13, 1
- 12, 1, 4954, 12, 2, 6973, 13, 1, 6959, 13, 2, 46650, // 13, 2
- 12, 2, 4608, 12, 3, 6426, 13, 2, 6549, 13, 3, 47953, // 13, 3
- 12, 3, 4291, 12, 4, 5930, 13, 3, 6168, 13, 4, 49147, // 13, 4
- 12, 4, 4020, 12, 5, 5508, 13, 4, 5842, 13, 5, 50166, // 13, 5
- 12, 5, 3815, 12, 6, 5184, 13, 5, 5602, 13, 6, 50935, // 13, 6
- 12, 6, 3693, 12, 7, 4978, 13, 6, 5478, 13, 7, 51387, // 13, 7
- 13, 7, 5480, 13, 8, 51395, 14, 7, 3691, 14, 8, 4970, // 13, 8
- 13, 8, 5606, 13, 9, 50942, 14, 8, 3813, 14, 9, 5175, // 13, 9
- 13, 9, 5848, 13, 10, 50171, 14, 9, 4019, 14, 10, 5498, // 13,10
- 13, 10, 6176, 13, 11, 49150, 14, 10, 4290, 14, 11, 5920, // 13,11
- 13, 11, 6560, 13, 12, 47955, 14, 11, 4607, 14, 12, 6414, // 13,12
- 13, 12, 6973, 13, 13, 46650, 14, 12, 4954, 14, 13, 6959, // 13,13
- 13, 13, 7395, 13, 14, 45286, 14, 13, 5316, 14, 14, 7539, // 13,14
- 13, 14, 7812, 13, 15, 43900, 14, 14, 5684, 14, 15, 8140, // 13,15
- 13, -1, 5974, 13, 0, 8474, 14, -1, 8265, 14, 0, 42823, // 14, 0
- 13, 0, 5640, 13, 1, 7921, 14, 0, 7901, 14, 1, 44074, // 14, 1
- 13, 1, 5316, 13, 2, 7395, 14, 1, 7539, 14, 2, 45286, // 14, 2
- 13, 2, 5011, 13, 3, 6908, 14, 2, 7191, 14, 3, 46426, // 14, 3
- 13, 3, 4736, 13, 4, 6472, 14, 3, 6875, 14, 4, 47453, // 14, 4
- 13, 4, 4505, 13, 5, 6104, 14, 4, 6613, 14, 5, 48314, // 14, 5
- 13, 5, 4330, 13, 6, 5820, 14, 5, 6425, 14, 6, 48961, // 14, 6
- 13, 6, 4224, 13, 7, 5633, 14, 6, 6332, 14, 7, 49347, // 14, 7
- 14, 7, 6335, 14, 8, 49358, 15, 7, 4221, 15, 8, 5622, // 14, 8
- 14, 8, 6430, 14, 9, 48969, 15, 8, 4327, 15, 9, 5810, // 14, 9
- 14, 9, 6620, 14, 10, 48322, 15, 9, 4502, 15, 10, 6092, // 14,10
- 14, 10, 6886, 14, 11, 47458, 15, 10, 4734, 15, 11, 6458, // 14,11
- 14, 11, 7204, 14, 12, 46430, 15, 11, 5009, 15, 12, 6893, // 14,12
- 14, 12, 7555, 14, 13, 45288, 15, 12, 5315, 15, 13, 7378, // 14,13
- 14, 13, 7921, 14, 14, 44074, 15, 13, 5640, 15, 14, 7901, // 14,14
- 14, 14, 8288, 14, 15, 42821, 15, 14, 5975, 15, 15, 8452, // 14,15
- 14, -1, 6280, 14, 0, 8795, 15, -1, 8769, 15, 0, 41692, // 15, 0
- 14, 0, 5975, 14, 1, 8288, 15, 0, 8452, 15, 1, 42821, // 15, 1
- 14, 1, 5684, 14, 2, 7812, 15, 1, 8141, 15, 2, 43899, // 15, 2
- 14, 2, 5413, 14, 3, 7374, 15, 2, 7848, 15, 3, 44901, // 15, 3
- 14, 3, 5172, 14, 4, 6986, 15, 3, 7587, 15, 4, 45791, // 15, 4
- 14, 4, 4971, 14, 5, 6659, 15, 4, 7374, 15, 5, 46532, // 15, 5
- 14, 5, 4818, 14, 6, 6405, 15, 5, 7227, 15, 6, 47086, // 15, 6
- 14, 6, 4722, 14, 7, 6230, 15, 6, 7158, 15, 7, 47426, // 15, 7
- 15, 7, 7161, 15, 8, 47440, 16, 7, 4718, 16, 8, 6217, // 15, 8
- 15, 8, 7233, 15, 9, 47098, 16, 8, 4814, 16, 9, 6391, // 15, 9
- 15, 9, 7383, 15, 10, 46541, 16, 9, 4967, 16, 10, 6645, // 15,10
- 15, 10, 7599, 15, 11, 45799, 16, 10, 5169, 16, 11, 6969, // 15,11
- 15, 11, 7863, 15, 12, 44907, 16, 11, 5410, 16, 12, 7356, // 15,12
- 15, 12, 8159, 15, 13, 43904, 16, 12, 5682, 16, 13, 7791, // 15,13
- 15, 13, 8474, 15, 14, 42823, 16, 13, 5974, 16, 14, 8265, // 15,14
- 15, 14, 8795, 15, 15, 41693, 16, 14, 6280, 16, 15, 8768, // 15,15
- // angle of -0.5 degrees
- -1, 0, 5106, -1, 1, 3621, 0, 0, 51699, 0, 1, 5110, // 0, 0
- -1, 1, 4803, -1, 2, 3421, 0, 1, 52457, 0, 2, 4855, // 0, 1
- -1, 2, 4521, -1, 3, 3235, 0, 2, 53168, 0, 3, 4612, // 0, 2
- -1, 3, 4264, -1, 4, 3064, 0, 3, 53815, 0, 4, 4393, // 0, 3
- -1, 4, 4041, -1, 5, 2916, 0, 4, 54378, 0, 5, 4201, // 0, 4
- -1, 5, 3858, -1, 6, 2796, 0, 5, 54835, 0, 6, 4047, // 0, 5
- -1, 6, 3722, -1, 7, 2709, 0, 6, 55166, 0, 7, 3939, // 0, 6
- -1, 7, 3638, -1, 8, 2659, 0, 7, 55354, 0, 8, 3885, // 0, 7
- 0, 8, 55352, 0, 9, 3885, 1, 8, 3640, 1, 9, 2659, // 0, 8
- 0, 9, 55164, 0, 10, 3939, 1, 9, 3724, 1, 10, 2709, // 0, 9
- 0, 10, 54833, 0, 11, 4046, 1, 10, 3860, 1, 11, 2797, // 0,10
- 0, 11, 54376, 0, 12, 4200, 1, 11, 4043, 1, 12, 2917, // 0,11
- 0, 12, 53814, 0, 13, 4390, 1, 12, 4267, 1, 13, 3065, // 0,12
- 0, 13, 53168, 0, 14, 4610, 1, 13, 4523, 1, 14, 3235, // 0,13
- 0, 14, 52457, 0, 15, 4851, 1, 14, 4806, 1, 15, 3422, // 0,14
- 0, 15, 51699, 0, 16, 5106, 1, 15, 5110, 1, 16, 3621, // 0,15
- 0, 0, 4851, 0, 1, 3422, 1, 0, 52457, 1, 1, 4806, // 1, 0
- 0, 1, 4522, 0, 2, 3204, 1, 1, 53285, 1, 2, 4525, // 1, 1
- 0, 2, 4212, 0, 3, 2998, 1, 2, 54072, 1, 3, 4254, // 1, 2
- 0, 3, 3927, 0, 4, 2808, 1, 3, 54796, 1, 4, 4005, // 1, 3
- 0, 4, 3677, 0, 5, 2640, 1, 4, 55435, 1, 5, 3784, // 1, 4
- 0, 5, 3470, 0, 6, 2502, 1, 5, 55959, 1, 6, 3605, // 1, 5
- 0, 6, 3317, 0, 7, 2402, 1, 6, 56340, 1, 7, 3477, // 1, 6
- 0, 7, 3225, 0, 8, 2346, 1, 7, 56554, 1, 8, 3411, // 1, 7
- 1, 8, 56552, 1, 9, 3411, 2, 8, 3227, 2, 9, 2346, // 1, 8
- 1, 9, 56339, 1, 10, 3476, 2, 9, 3319, 2, 10, 2402, // 1, 9
- 1, 10, 55958, 1, 11, 3604, 2, 10, 3472, 2, 11, 2502, // 1,10
- 1, 11, 55434, 1, 12, 3783, 2, 11, 3678, 2, 12, 2641, // 1,11
- 1, 12, 54796, 1, 13, 4003, 2, 12, 3929, 2, 13, 2808, // 1,12
- 1, 13, 54071, 1, 14, 4253, 2, 13, 4214, 2, 14, 2998, // 1,13
- 1, 14, 53285, 1, 15, 4522, 2, 14, 4525, 2, 15, 3204, // 1,14
- 1, 15, 52457, 1, 16, 4803, 2, 15, 4854, 2, 16, 3422, // 1,15
- 1, 0, 4610, 1, 1, 3235, 2, 0, 53168, 2, 1, 4523, // 2, 0
- 1, 1, 4253, 1, 2, 2998, 2, 1, 54071, 2, 2, 4214, // 2, 1
- 1, 2, 3911, 1, 3, 2770, 2, 2, 54941, 2, 3, 3914, // 2, 2
- 1, 3, 3594, 1, 4, 2556, 2, 3, 55756, 2, 4, 3630, // 2, 3
- 1, 4, 3310, 1, 5, 2365, 2, 4, 56487, 2, 5, 3374, // 2, 4
- 1, 5, 3073, 1, 6, 2205, 2, 5, 57096, 2, 6, 3162, // 2, 5
- 1, 6, 2897, 1, 7, 2088, 2, 6, 57545, 2, 7, 3006, // 2, 6
- 1, 7, 2794, 1, 8, 2022, 2, 7, 57795, 2, 8, 2925, // 2, 7
- 2, 8, 57793, 2, 9, 2926, 3, 8, 2795, 3, 9, 2022, // 2, 8
- 2, 9, 57544, 2, 10, 3007, 3, 9, 2898, 3, 10, 2087, // 2, 9
- 2, 10, 57095, 2, 11, 3161, 3, 10, 3074, 3, 11, 2206, // 2,10
- 2, 11, 56486, 2, 12, 3373, 3, 11, 3311, 3, 12, 2366, // 2,11
- 2, 12, 55756, 2, 13, 3628, 3, 12, 3595, 3, 13, 2557, // 2,12
- 2, 13, 54941, 2, 14, 3911, 3, 13, 3913, 3, 14, 2771, // 2,13
- 2, 14, 54072, 2, 15, 4212, 3, 14, 4255, 3, 15, 2997, // 2,14
- 2, 15, 53168, 2, 16, 4521, 3, 15, 4612, 3, 16, 3235, // 2,15
- 2, 0, 4390, 2, 1, 3065, 3, 0, 53814, 3, 1, 4267, // 3, 0
- 2, 1, 4003, 2, 2, 2808, 3, 1, 54796, 3, 2, 3929, // 3, 1
- 2, 2, 3628, 2, 3, 2557, 3, 2, 55756, 3, 3, 3595, // 3, 2
- 2, 3, 3273, 2, 4, 2317, 3, 3, 56673, 3, 4, 3273, // 3, 3
- 2, 4, 2948, 2, 5, 2096, 3, 4, 57514, 3, 5, 2978, // 3, 4
- 2, 5, 2672, 2, 6, 1908, 3, 5, 58234, 3, 6, 2722, // 3, 5
- 2, 6, 2463, 2, 7, 1766, 3, 6, 58775, 3, 7, 2532, // 3, 6
- 2, 7, 2342, 2, 8, 1687, 3, 7, 59077, 3, 8, 2430, // 3, 7
- 3, 8, 59076, 3, 9, 2430, 4, 8, 2343, 4, 9, 1687, // 3, 8
- 3, 9, 58774, 3, 10, 2532, 4, 9, 2464, 4, 10, 1766, // 3, 9
- 3, 10, 58233, 3, 11, 2722, 4, 10, 2673, 4, 11, 1908, // 3,10
- 3, 11, 57514, 3, 12, 2976, 4, 11, 2950, 4, 12, 2096, // 3,11
- 3, 12, 56673, 3, 13, 3273, 4, 12, 3274, 4, 13, 2316, // 3,12
- 3, 13, 55756, 3, 14, 3594, 4, 13, 3630, 4, 14, 2556, // 3,13
- 3, 14, 54796, 3, 15, 3927, 4, 14, 4005, 4, 15, 2808, // 3,14
- 3, 15, 53815, 3, 16, 4264, 4, 15, 4392, 4, 16, 3065, // 3,15
- 3, 0, 4200, 3, 1, 2917, 4, 0, 54376, 4, 1, 4043, // 4, 0
- 3, 1, 3783, 3, 2, 2640, 4, 1, 55434, 4, 2, 3679, // 4, 1
- 3, 2, 3373, 3, 3, 2365, 4, 2, 56486, 4, 3, 3312, // 4, 2
- 3, 3, 2976, 3, 4, 2096, 4, 3, 57514, 4, 4, 2950, // 4, 3
- 3, 4, 2604, 3, 5, 1843, 4, 4, 58484, 4, 5, 2605, // 4, 4
- 3, 5, 2276, 3, 6, 1617, 4, 5, 59346, 4, 6, 2297, // 4, 5
- 3, 6, 2020, 3, 7, 1442, 4, 6, 60018, 4, 7, 2056, // 4, 6
- 3, 7, 1871, 3, 8, 1341, 4, 7, 60402, 4, 8, 1922, // 4, 7
- 4, 8, 60402, 4, 9, 1922, 5, 8, 1871, 5, 9, 1341, // 4, 8
- 4, 9, 60017, 4, 10, 2057, 5, 9, 2020, 5, 10, 1442, // 4, 9
- 4, 10, 59345, 4, 11, 2297, 5, 10, 2276, 5, 11, 1618, // 4,10
- 4, 11, 58484, 4, 12, 2604, 5, 11, 2605, 5, 12, 1843, // 4,11
- 4, 12, 57514, 4, 13, 2948, 5, 12, 2977, 5, 13, 2097, // 4,12
- 4, 13, 56487, 4, 14, 3310, 5, 13, 3374, 5, 14, 2365, // 4,13
- 4, 14, 55435, 4, 15, 3677, 5, 14, 3785, 5, 15, 2639, // 4,14
- 4, 15, 54378, 4, 16, 4041, 5, 15, 4201, 5, 16, 2916, // 4,15
- 4, 0, 4046, 4, 1, 2797, 5, 0, 54833, 5, 1, 3860, // 5, 0
- 4, 1, 3604, 4, 2, 2503, 5, 1, 55958, 5, 2, 3471, // 5, 1
- 4, 2, 3161, 4, 3, 2205, 5, 2, 57095, 5, 3, 3075, // 5, 2
- 4, 3, 2722, 4, 4, 1908, 5, 3, 58233, 5, 4, 2673, // 5, 3
- 4, 4, 2297, 4, 5, 1617, 5, 4, 59345, 5, 5, 2277, // 5, 4
- 4, 5, 1904, 4, 6, 1347, 5, 5, 60381, 5, 6, 1904, // 5, 5
- 4, 6, 1578, 4, 7, 1121, 5, 6, 61243, 5, 7, 1594, // 5, 6
- 4, 7, 1380, 4, 8, 985, 5, 7, 61767, 5, 8, 1404, // 5, 7
- 5, 8, 61767, 5, 9, 1405, 6, 8, 1380, 6, 9, 984, // 5, 8
- 5, 9, 61243, 5, 10, 1593, 6, 9, 1579, 6, 10, 1121, // 5, 9
- 5, 10, 60381, 5, 11, 1904, 6, 10, 1904, 6, 11, 1347, // 5,10
- 5, 11, 59346, 5, 12, 2276, 6, 11, 2297, 6, 12, 1617, // 5,11
- 5, 12, 58234, 5, 13, 2672, 6, 12, 2723, 6, 13, 1907, // 5,12
- 5, 13, 57096, 5, 14, 3073, 6, 13, 3161, 6, 14, 2206, // 5,13
- 5, 14, 55959, 5, 15, 3470, 6, 14, 3605, 6, 15, 2502, // 5,14
- 5, 15, 54835, 5, 16, 3858, 6, 15, 4047, 6, 16, 2796, // 5,15
- 5, 0, 3939, 5, 1, 2709, 6, 0, 55164, 6, 1, 3724, // 6, 0
- 5, 1, 3476, 5, 2, 2403, 6, 1, 56339, 6, 2, 3318, // 6, 1
- 5, 2, 3007, 5, 3, 2088, 6, 2, 57544, 6, 3, 2897, // 6, 2
- 5, 3, 2532, 5, 4, 1767, 6, 3, 58774, 6, 4, 2463, // 6, 3
- 5, 4, 2057, 5, 5, 1442, 6, 4, 60017, 6, 5, 2020, // 6, 4
- 5, 5, 1593, 5, 6, 1121, 6, 5, 61243, 6, 6, 1579, // 6, 5
- 5, 6, 1170, 5, 7, 827, 6, 6, 62369, 6, 7, 1170, // 6, 6
- 5, 7, 875, 5, 8, 622, 6, 7, 63156, 6, 8, 883, // 6, 7
- 6, 8, 63156, 6, 9, 883, 7, 8, 875, 7, 9, 622, // 6, 8
- 6, 9, 62369, 6, 10, 1170, 7, 9, 1170, 7, 10, 827, // 6, 9
- 6, 10, 61243, 6, 11, 1578, 7, 10, 1593, 7, 11, 1122, // 6,10
- 6, 11, 60018, 6, 12, 2020, 7, 11, 2057, 7, 12, 1441, // 6,11
- 6, 12, 58775, 6, 13, 2463, 7, 12, 2532, 7, 13, 1766, // 6,12
- 6, 13, 57545, 6, 14, 2897, 7, 13, 3007, 7, 14, 2087, // 6,13
- 6, 14, 56340, 6, 15, 3317, 7, 14, 3477, 7, 15, 2402, // 6,14
- 6, 15, 55166, 6, 16, 3722, 7, 15, 3940, 7, 16, 2708, // 6,15
- 6, 0, 3885, 6, 1, 2659, 7, 0, 55352, 7, 1, 3640, // 7, 0
- 6, 1, 3411, 6, 2, 2346, 7, 1, 56552, 7, 2, 3227, // 7, 1
- 6, 2, 2926, 6, 3, 2022, 7, 2, 57793, 7, 3, 2795, // 7, 2
- 6, 3, 2430, 6, 4, 1687, 7, 3, 59076, 7, 4, 2343, // 7, 3
- 6, 4, 1922, 6, 5, 1341, 7, 4, 60402, 7, 5, 1871, // 7, 4
- 6, 5, 1405, 6, 6, 985, 7, 5, 61767, 7, 6, 1379, // 7, 5
- 6, 6, 883, 6, 7, 622, 7, 6, 63156, 7, 7, 875, // 7, 6
- 6, 7, 399, 6, 8, 282, 7, 7, 64455, 7, 8, 400, // 7, 7
- 7, 8, 64455, 7, 9, 399, 8, 8, 399, 8, 9, 283, // 7, 8
- 7, 9, 63156, 7, 10, 875, 8, 9, 883, 8, 10, 622, // 7, 9
- 7, 10, 61767, 7, 11, 1380, 8, 10, 1405, 8, 11, 984, // 7,10
- 7, 11, 60402, 7, 12, 1871, 8, 11, 1922, 8, 12, 1341, // 7,11
- 7, 12, 59077, 7, 13, 2342, 8, 12, 2430, 8, 13, 1687, // 7,12
- 7, 13, 57795, 7, 14, 2794, 8, 13, 2926, 8, 14, 2021, // 7,13
- 7, 14, 56554, 7, 15, 3225, 8, 14, 3411, 8, 15, 2346, // 7,14
- 7, 15, 55354, 7, 16, 3638, 8, 15, 3885, 8, 16, 2659, // 7,15
- 7, -1, 2659, 7, 0, 3885, 8, -1, 3638, 8, 0, 55354, // 8, 0
- 7, 0, 2346, 7, 1, 3411, 8, 0, 3225, 8, 1, 56554, // 8, 1
- 7, 1, 2022, 7, 2, 2926, 8, 1, 2794, 8, 2, 57794, // 8, 2
- 7, 2, 1687, 7, 3, 2430, 8, 2, 2342, 8, 3, 59077, // 8, 3
- 7, 3, 1341, 7, 4, 1922, 8, 3, 1871, 8, 4, 60402, // 8, 4
- 7, 4, 985, 7, 5, 1405, 8, 4, 1380, 8, 5, 61766, // 8, 5
- 7, 5, 622, 7, 6, 883, 8, 5, 875, 8, 6, 63156, // 8, 6
- 7, 6, 282, 7, 7, 399, 8, 6, 399, 8, 7, 64456, // 8, 7
- 8, 7, 399, 8, 8, 64455, 9, 7, 282, 9, 8, 400, // 8, 8
- 8, 8, 875, 8, 9, 63156, 9, 8, 622, 9, 9, 883, // 8, 9
- 8, 9, 1380, 8, 10, 61767, 9, 9, 985, 9, 10, 1404, // 8,10
- 8, 10, 1871, 8, 11, 60402, 9, 10, 1341, 9, 11, 1922, // 8,11
- 8, 11, 2343, 8, 12, 59076, 9, 11, 1687, 9, 12, 2430, // 8,12
- 8, 12, 2795, 8, 13, 57793, 9, 12, 2022, 9, 13, 2926, // 8,13
- 8, 13, 3227, 8, 14, 56552, 9, 13, 2346, 9, 14, 3411, // 8,14
- 8, 14, 3640, 8, 15, 55352, 9, 14, 2659, 9, 15, 3885, // 8,15
- 8, -1, 2709, 8, 0, 3940, 9, -1, 3722, 9, 0, 55165, // 9, 0
- 8, 0, 2402, 8, 1, 3477, 9, 0, 3317, 9, 1, 56340, // 9, 1
- 8, 1, 2088, 8, 2, 3007, 9, 1, 2897, 9, 2, 57544, // 9, 2
- 8, 2, 1766, 8, 3, 2532, 9, 2, 2463, 9, 3, 58775, // 9, 3
- 8, 3, 1442, 8, 4, 2057, 9, 3, 2020, 9, 4, 60017, // 9, 4
- 8, 4, 1121, 8, 5, 1593, 9, 4, 1578, 9, 5, 61244, // 9, 5
- 8, 5, 827, 8, 6, 1170, 9, 5, 1170, 9, 6, 62369, // 9, 6
- 8, 6, 622, 8, 7, 875, 9, 6, 883, 9, 7, 63156, // 9, 7
- 9, 7, 883, 9, 8, 63156, 10, 7, 622, 10, 8, 875, // 9, 8
- 9, 8, 1170, 9, 9, 62369, 10, 8, 827, 10, 9, 1170, // 9, 9
- 9, 9, 1579, 9, 10, 61243, 10, 9, 1121, 10, 10, 1593, // 9,10
- 9, 10, 2020, 9, 11, 60017, 10, 10, 1442, 10, 11, 2057, // 9,11
- 9, 11, 2464, 9, 12, 58774, 10, 11, 1767, 10, 12, 2531, // 9,12
- 9, 12, 2898, 9, 13, 57544, 10, 12, 2088, 10, 13, 3006, // 9,13
- 9, 13, 3319, 9, 14, 56339, 10, 13, 2403, 10, 14, 3475, // 9,14
- 9, 14, 3724, 9, 15, 55164, 10, 14, 2709, 10, 15, 3939, // 9,15
- 9, -1, 2796, 9, 0, 4047, 10, -1, 3858, 10, 0, 54835, // 10, 0
- 9, 0, 2502, 9, 1, 3605, 10, 0, 3470, 10, 1, 55959, // 10, 1
- 9, 1, 2205, 9, 2, 3161, 10, 1, 3073, 10, 2, 57097, // 10, 2
- 9, 2, 1908, 9, 3, 2723, 10, 2, 2672, 10, 3, 58233, // 10, 3
- 9, 3, 1617, 9, 4, 2297, 10, 3, 2276, 10, 4, 59346, // 10, 4
- 9, 4, 1347, 9, 5, 1904, 10, 4, 1904, 10, 5, 60381, // 10, 5
- 9, 5, 1121, 9, 6, 1579, 10, 5, 1593, 10, 6, 61243, // 10, 6
- 9, 6, 985, 9, 7, 1380, 10, 6, 1405, 10, 7, 61766, // 10, 7
- 10, 7, 1405, 10, 8, 61767, 11, 7, 985, 11, 8, 1379, // 10, 8
- 10, 8, 1593, 10, 9, 61243, 11, 8, 1121, 11, 9, 1579, // 10, 9
- 10, 9, 1904, 10, 10, 60381, 11, 9, 1347, 11, 10, 1904, // 10,10
- 10, 10, 2276, 10, 11, 59345, 11, 10, 1617, 11, 11, 2298, // 10,11
- 10, 11, 2673, 10, 12, 58233, 11, 11, 1908, 11, 12, 2722, // 10,12
- 10, 12, 3074, 10, 13, 57095, 11, 12, 2205, 11, 13, 3162, // 10,13
- 10, 13, 3472, 10, 14, 55958, 11, 13, 2503, 11, 14, 3603, // 10,14
- 10, 14, 3860, 10, 15, 54833, 11, 14, 2797, 11, 15, 4046, // 10,15
- 10, -1, 2916, 10, 0, 4201, 11, -1, 4041, 11, 0, 54378, // 11, 0
- 10, 0, 2640, 10, 1, 3785, 11, 0, 3677, 11, 1, 55434, // 11, 1
- 10, 1, 2365, 10, 2, 3374, 11, 1, 3310, 11, 2, 56487, // 11, 2
- 10, 2, 2096, 10, 3, 2977, 11, 2, 2948, 11, 3, 57515, // 11, 3
- 10, 3, 1843, 10, 4, 2605, 11, 3, 2604, 11, 4, 58484, // 11, 4
- 10, 4, 1617, 10, 5, 2276, 11, 4, 2297, 11, 5, 59346, // 11, 5
- 10, 5, 1442, 10, 6, 2020, 11, 5, 2057, 11, 6, 60017, // 11, 6
- 10, 6, 1341, 10, 7, 1871, 11, 6, 1922, 11, 7, 60402, // 11, 7
- 11, 7, 1922, 11, 8, 60402, 12, 7, 1341, 12, 8, 1871, // 11, 8
- 11, 8, 2057, 11, 9, 60018, 12, 8, 1442, 12, 9, 2019, // 11, 9
- 11, 9, 2297, 11, 10, 59346, 12, 9, 1617, 12, 10, 2276, // 11,10
- 11, 10, 2605, 11, 11, 58484, 12, 10, 1843, 12, 11, 2604, // 11,11
- 11, 11, 2950, 11, 12, 57514, 12, 11, 2096, 12, 12, 2976, // 11,12
- 11, 12, 3311, 11, 13, 56486, 12, 12, 2365, 12, 13, 3374, // 11,13
- 11, 13, 3678, 11, 14, 55434, 12, 13, 2640, 12, 14, 3784, // 11,14
- 11, 14, 4043, 11, 15, 54376, 12, 14, 2917, 12, 15, 4200, // 11,15
- 11, -1, 3064, 11, 0, 4392, 12, -1, 4264, 12, 0, 53816, // 12, 0
- 11, 0, 2808, 11, 1, 4005, 12, 0, 3927, 12, 1, 54796, // 12, 1
- 11, 1, 2556, 11, 2, 3630, 12, 1, 3594, 12, 2, 55756, // 12, 2
- 11, 2, 2317, 11, 3, 3274, 12, 2, 3273, 12, 3, 56672, // 12, 3
- 11, 3, 2096, 11, 4, 2950, 12, 3, 2976, 12, 4, 57514, // 12, 4
- 11, 4, 1908, 11, 5, 2673, 12, 4, 2722, 12, 5, 58233, // 12, 5
- 11, 5, 1767, 11, 6, 2464, 12, 5, 2532, 12, 6, 58773, // 12, 6
- 11, 6, 1687, 11, 7, 2343, 12, 6, 2430, 12, 7, 59076, // 12, 7
- 12, 7, 2430, 12, 8, 59077, 13, 7, 1687, 13, 8, 2342, // 12, 8
- 12, 8, 2532, 12, 9, 58775, 13, 8, 1766, 13, 9, 2463, // 12, 9
- 12, 9, 2723, 12, 10, 58234, 13, 9, 1908, 13, 10, 2671, // 12,10
- 12, 10, 2977, 12, 11, 57514, 13, 10, 2096, 13, 11, 2949, // 12,11
- 12, 11, 3274, 12, 12, 56673, 13, 11, 2317, 13, 12, 3272, // 12,12
- 12, 12, 3595, 12, 13, 55756, 13, 12, 2557, 13, 13, 3628, // 12,13
- 12, 13, 3929, 12, 14, 54796, 13, 13, 2808, 13, 14, 4003, // 12,14
- 12, 14, 4267, 12, 15, 53814, 13, 14, 3065, 13, 15, 4390, // 12,15
- 12, -1, 3235, 12, 0, 4612, 13, -1, 4521, 13, 0, 53168, // 13, 0
- 12, 0, 2998, 12, 1, 4255, 13, 0, 4212, 13, 1, 54071, // 13, 1
- 12, 1, 2770, 12, 2, 3913, 13, 1, 3911, 13, 2, 54942, // 13, 2
- 12, 2, 2557, 12, 3, 3595, 13, 2, 3628, 13, 3, 55756, // 13, 3
- 12, 3, 2365, 12, 4, 3311, 13, 3, 3373, 13, 4, 56487, // 13, 4
- 12, 4, 2205, 12, 5, 3074, 13, 4, 3161, 13, 5, 57096, // 13, 5
- 12, 5, 2088, 12, 6, 2898, 13, 5, 3007, 13, 6, 57543, // 13, 6
- 12, 6, 2022, 12, 7, 2795, 13, 6, 2926, 13, 7, 57793, // 13, 7
- 13, 7, 2926, 13, 8, 57795, 14, 7, 2022, 14, 8, 2793, // 13, 8
- 13, 8, 3007, 13, 9, 57545, 14, 8, 2088, 14, 9, 2896, // 13, 9
- 13, 9, 3161, 13, 10, 57096, 14, 9, 2205, 14, 10, 3074, // 13,10
- 13, 10, 3374, 13, 11, 56487, 14, 10, 2365, 14, 11, 3310, // 13,11
- 13, 11, 3630, 13, 12, 55756, 14, 11, 2556, 14, 12, 3594, // 13,12
- 13, 12, 3913, 13, 13, 54941, 14, 12, 2770, 14, 13, 3912, // 13,13
- 13, 13, 4214, 13, 14, 54071, 14, 13, 2998, 14, 14, 4253, // 13,14
- 13, 14, 4523, 13, 15, 53168, 14, 14, 3235, 14, 15, 4610, // 13,15
- 13, -1, 3421, 13, 0, 4854, 14, -1, 4803, 14, 0, 52458, // 14, 0
- 13, 0, 3204, 13, 1, 4525, 14, 0, 4522, 14, 1, 53285, // 14, 1
- 13, 1, 2998, 13, 2, 4214, 14, 1, 4253, 14, 2, 54071, // 14, 2
- 13, 2, 2808, 13, 3, 3929, 14, 2, 4003, 14, 3, 54796, // 14, 3
- 13, 3, 2640, 13, 4, 3678, 14, 3, 3783, 14, 4, 55435, // 14, 4
- 13, 4, 2503, 13, 5, 3472, 14, 4, 3604, 14, 5, 55957, // 14, 5
- 13, 5, 2403, 13, 6, 3319, 14, 5, 3476, 14, 6, 56338, // 14, 6
- 13, 6, 2346, 13, 7, 3227, 14, 6, 3411, 14, 7, 56552, // 14, 7
- 14, 7, 3411, 14, 8, 56554, 15, 7, 2346, 15, 8, 3225, // 14, 8
- 14, 8, 3477, 14, 9, 56340, 15, 8, 2402, 15, 9, 3317, // 14, 9
- 14, 9, 3605, 14, 10, 55959, 15, 9, 2502, 15, 10, 3470, // 14,10
- 14, 10, 3785, 14, 11, 55435, 15, 10, 2640, 15, 11, 3676, // 14,11
- 14, 11, 4005, 14, 12, 54796, 15, 11, 2808, 15, 12, 3927, // 14,12
- 14, 12, 4255, 14, 13, 54072, 15, 12, 2998, 15, 13, 4211, // 14,13
- 14, 13, 4525, 14, 14, 53285, 15, 13, 3204, 15, 14, 4522, // 14,14
- 14, 14, 4806, 14, 15, 52457, 15, 14, 3422, 15, 15, 4851, // 14,15
- 14, -1, 3621, 14, 0, 5110, 15, -1, 5106, 15, 0, 51699, // 15, 0
- 14, 0, 3422, 14, 1, 4806, 15, 0, 4851, 15, 1, 52457, // 15, 1
- 14, 1, 3235, 14, 2, 4523, 15, 1, 4610, 15, 2, 53168, // 15, 2
- 14, 2, 3065, 14, 3, 4267, 15, 2, 4390, 15, 3, 53814, // 15, 3
- 14, 3, 2917, 14, 4, 4043, 15, 3, 4200, 15, 4, 54376, // 15, 4
- 14, 4, 2797, 14, 5, 3860, 15, 4, 4046, 15, 5, 54833, // 15, 5
- 14, 5, 2709, 14, 6, 3724, 15, 5, 3939, 15, 6, 55164, // 15, 6
- 14, 6, 2659, 14, 7, 3640, 15, 6, 3885, 15, 7, 55352, // 15, 7
- 15, 7, 3885, 15, 8, 55354, 16, 7, 2659, 16, 8, 3638, // 15, 8
- 15, 8, 3940, 15, 9, 55166, 16, 8, 2709, 16, 9, 3721, // 15, 9
- 15, 9, 4047, 15, 10, 54835, 16, 9, 2796, 16, 10, 3858, // 15,10
- 15, 10, 4201, 15, 11, 54378, 16, 10, 2916, 16, 11, 4041, // 15,11
- 15, 11, 4392, 15, 12, 53815, 16, 11, 3064, 16, 12, 4265, // 15,12
- 15, 12, 4612, 15, 13, 53168, 16, 12, 3235, 16, 13, 4521, // 15,13
- 15, 13, 4854, 15, 14, 52457, 16, 13, 3421, 16, 14, 4804, // 15,14
- 15, 14, 5110, 15, 15, 51699, 16, 14, 3621, 16, 15, 5106, // 15,15
- // angle of 0.0 degrees
- 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, // 0, 0
- 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, // 0, 1
- 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, // 0, 2
- 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, // 0, 3
- 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, // 0, 4
- 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, // 0, 5
- 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, // 0, 6
- 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, // 0, 7
- 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, // 0, 8
- 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, // 0, 9
- 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, // 0,10
- 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, // 0,11
- 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, // 0,12
- 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, // 0,13
- 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, // 0,14
- 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, // 0,15
- 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, // 1, 0
- 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, // 1, 1
- 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, // 1, 2
- 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, // 1, 3
- 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, // 1, 4
- 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, // 1, 5
- 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, // 1, 6
- 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, // 1, 7
- 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, // 1, 8
- 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, // 1, 9
- 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, // 1,10
- 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, // 1,11
- 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, // 1,12
- 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, // 1,13
- 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, // 1,14
- 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, // 1,15
- 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, // 2, 0
- 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, // 2, 1
- 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, // 2, 2
- 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, // 2, 3
- 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, // 2, 4
- 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, // 2, 5
- 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, // 2, 6
- 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, // 2, 7
- 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, // 2, 8
- 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, // 2, 9
- 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, // 2,10
- 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, // 2,11
- 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, // 2,12
- 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, // 2,13
- 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, // 2,14
- 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, // 2,15
- 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, // 3, 0
- 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, // 3, 1
- 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, // 3, 2
- 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, // 3, 3
- 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, // 3, 4
- 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, // 3, 5
- 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, // 3, 6
- 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, // 3, 7
- 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, // 3, 8
- 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, // 3, 9
- 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, // 3,10
- 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, // 3,11
- 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, // 3,12
- 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, // 3,13
- 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, // 3,14
- 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, // 3,15
- 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, // 4, 0
- 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, // 4, 1
- 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, // 4, 2
- 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, // 4, 3
- 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, // 4, 4
- 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, // 4, 5
- 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, // 4, 6
- 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, // 4, 7
- 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, // 4, 8
- 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, // 4, 9
- 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, // 4,10
- 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, // 4,11
- 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, // 4,12
- 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, // 4,13
- 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, // 4,14
- 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, // 4,15
- 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, // 5, 0
- 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, // 5, 1
- 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, // 5, 2
- 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, // 5, 3
- 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, // 5, 4
- 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, // 5, 5
- 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, // 5, 6
- 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, // 5, 7
- 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, // 5, 8
- 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, // 5, 9
- 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, // 5,10
- 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, // 5,11
- 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, // 5,12
- 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, // 5,13
- 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, // 5,14
- 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, // 5,15
- 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, // 6, 0
- 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, // 6, 1
- 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, // 6, 2
- 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, // 6, 3
- 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, // 6, 4
- 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, // 6, 5
- 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, // 6, 6
- 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, // 6, 7
- 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, // 6, 8
- 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, // 6, 9
- 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, // 6,10
- 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, // 6,11
- 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, // 6,12
- 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, // 6,13
- 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, // 6,14
- 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, // 6,15
- 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, // 7, 0
- 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, // 7, 1
- 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, // 7, 2
- 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, // 7, 3
- 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, // 7, 4
- 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, // 7, 5
- 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, // 7, 6
- 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, // 7, 7
- 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, // 7, 8
- 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, // 7, 9
- 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, // 7,10
- 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, // 7,11
- 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, // 7,12
- 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, // 7,13
- 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, // 7,14
- 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, // 7,15
- 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, // 8, 0
- 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, // 8, 1
- 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, // 8, 2
- 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, // 8, 3
- 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, // 8, 4
- 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, // 8, 5
- 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, // 8, 6
- 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, // 8, 7
- 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, // 8, 8
- 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, // 8, 9
- 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, // 8,10
- 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, // 8,11
- 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, // 8,12
- 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, // 8,13
- 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, // 8,14
- 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, // 8,15
- 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, // 9, 0
- 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, // 9, 1
- 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, // 9, 2
- 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, // 9, 3
- 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, // 9, 4
- 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, // 9, 5
- 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, // 9, 6
- 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, // 9, 7
- 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, // 9, 8
- 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, // 9, 9
- 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, // 9,10
- 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, // 9,11
- 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, // 9,12
- 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, // 9,13
- 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, // 9,14
- 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, // 9,15
- 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, // 10, 0
- 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, // 10, 1
- 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, // 10, 2
- 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, // 10, 3
- 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, // 10, 4
- 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, // 10, 5
- 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, // 10, 6
- 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, // 10, 7
- 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, // 10, 8
- 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, // 10, 9
- 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, // 10,10
- 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, // 10,11
- 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, // 10,12
- 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, // 10,13
- 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, // 10,14
- 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, // 10,15
- 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, // 11, 0
- 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, // 11, 1
- 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, // 11, 2
- 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, // 11, 3
- 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, // 11, 4
- 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, // 11, 5
- 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, // 11, 6
- 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, // 11, 7
- 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, // 11, 8
- 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, // 11, 9
- 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, // 11,10
- 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, // 11,11
- 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, // 11,12
- 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, // 11,13
- 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, // 11,14
- 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, // 11,15
- 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, // 12, 0
- 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, // 12, 1
- 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, // 12, 2
- 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, // 12, 3
- 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, // 12, 4
- 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, // 12, 5
- 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, // 12, 6
- 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, // 12, 7
- 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, // 12, 8
- 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, // 12, 9
- 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, // 12,10
- 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, // 12,11
- 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, // 12,12
- 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, // 12,13
- 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, // 12,14
- 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, // 12,15
- 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, // 13, 0
- 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, // 13, 1
- 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, // 13, 2
- 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, // 13, 3
- 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, // 13, 4
- 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, // 13, 5
- 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, // 13, 6
- 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, // 13, 7
- 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, // 13, 8
- 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, // 13, 9
- 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, // 13,10
- 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, // 13,11
- 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, // 13,12
- 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, // 13,13
- 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, // 13,14
- 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, // 13,15
- 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, // 14, 0
- 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, // 14, 1
- 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, // 14, 2
- 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, // 14, 3
- 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, // 14, 4
- 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, // 14, 5
- 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, // 14, 6
- 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, // 14, 7
- 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, // 14, 8
- 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, // 14, 9
- 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, // 14,10
- 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, // 14,11
- 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, // 14,12
- 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, // 14,13
- 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, // 14,14
- 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, // 14,15
- 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, // 15, 0
- 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, // 15, 1
- 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, // 15, 2
- 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, // 15, 3
- 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, // 15, 4
- 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, // 15, 5
- 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, // 15, 6
- 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, // 15, 7
- 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, // 15, 8
- 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, // 15, 9
- 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, // 15,10
- 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, // 15,11
- 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, // 15,12
- 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, // 15,13
- 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, // 15,14
- 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, // 15,15
- // angle of 0.5 degrees
- 0, -1, 5106, 0, 0, 51699, 1, -1, 3621, 1, 0, 5110, // 0, 0
- 0, 0, 4851, 0, 1, 52457, 1, 0, 3422, 1, 1, 4806, // 0, 1
- 0, 1, 4610, 0, 2, 53168, 1, 1, 3235, 1, 2, 4523, // 0, 2
- 0, 2, 4390, 0, 3, 53814, 1, 2, 3065, 1, 3, 4267, // 0, 3
- 0, 3, 4200, 0, 4, 54376, 1, 3, 2917, 1, 4, 4043, // 0, 4
- 0, 4, 4046, 0, 5, 54833, 1, 4, 2797, 1, 5, 3860, // 0, 5
- 0, 5, 3939, 0, 6, 55164, 1, 5, 2709, 1, 6, 3724, // 0, 6
- 0, 6, 3885, 0, 7, 55352, 1, 6, 2659, 1, 7, 3640, // 0, 7
- -1, 7, 2659, -1, 8, 3638, 0, 7, 3885, 0, 8, 55354, // 0, 8
- -1, 8, 2709, -1, 9, 3722, 0, 8, 3940, 0, 9, 55165, // 0, 9
- -1, 9, 2796, -1, 10, 3858, 0, 9, 4047, 0, 10, 54835, // 0,10
- -1, 10, 2916, -1, 11, 4041, 0, 10, 4201, 0, 11, 54378, // 0,11
- -1, 11, 3064, -1, 12, 4264, 0, 11, 4392, 0, 12, 53816, // 0,12
- -1, 12, 3235, -1, 13, 4521, 0, 12, 4612, 0, 13, 53168, // 0,13
- -1, 13, 3421, -1, 14, 4803, 0, 13, 4854, 0, 14, 52458, // 0,14
- -1, 14, 3621, -1, 15, 5106, 0, 14, 5110, 0, 15, 51699, // 0,15
- 1, -1, 4803, 1, 0, 52457, 2, -1, 3421, 2, 0, 4855, // 1, 0
- 1, 0, 4522, 1, 1, 53285, 2, 0, 3204, 2, 1, 4525, // 1, 1
- 1, 1, 4253, 1, 2, 54071, 2, 1, 2998, 2, 2, 4214, // 1, 2
- 1, 2, 4003, 1, 3, 54796, 2, 2, 2808, 2, 3, 3929, // 1, 3
- 1, 3, 3783, 1, 4, 55434, 2, 3, 2640, 2, 4, 3679, // 1, 4
- 1, 4, 3604, 1, 5, 55958, 2, 4, 2503, 2, 5, 3471, // 1, 5
- 1, 5, 3476, 1, 6, 56339, 2, 5, 2403, 2, 6, 3318, // 1, 6
- 1, 6, 3411, 1, 7, 56552, 2, 6, 2346, 2, 7, 3227, // 1, 7
- 0, 7, 2346, 0, 8, 3225, 1, 7, 3411, 1, 8, 56554, // 1, 8
- 0, 8, 2402, 0, 9, 3317, 1, 8, 3477, 1, 9, 56340, // 1, 9
- 0, 9, 2502, 0, 10, 3470, 1, 9, 3605, 1, 10, 55959, // 1,10
- 0, 10, 2640, 0, 11, 3677, 1, 10, 3785, 1, 11, 55434, // 1,11
- 0, 11, 2808, 0, 12, 3927, 1, 11, 4005, 1, 12, 54796, // 1,12
- 0, 12, 2998, 0, 13, 4212, 1, 12, 4255, 1, 13, 54071, // 1,13
- 0, 13, 3204, 0, 14, 4522, 1, 13, 4525, 1, 14, 53285, // 1,14
- 0, 14, 3422, 0, 15, 4851, 1, 14, 4806, 1, 15, 52457, // 1,15
- 2, -1, 4521, 2, 0, 53168, 3, -1, 3235, 3, 0, 4612, // 2, 0
- 2, 0, 4212, 2, 1, 54072, 3, 0, 2998, 3, 1, 4254, // 2, 1
- 2, 1, 3911, 2, 2, 54941, 3, 1, 2770, 3, 2, 3914, // 2, 2
- 2, 2, 3628, 2, 3, 55756, 3, 2, 2557, 3, 3, 3595, // 2, 3
- 2, 3, 3373, 2, 4, 56486, 3, 3, 2365, 3, 4, 3312, // 2, 4
- 2, 4, 3161, 2, 5, 57095, 3, 4, 2205, 3, 5, 3075, // 2, 5
- 2, 5, 3007, 2, 6, 57544, 3, 5, 2088, 3, 6, 2897, // 2, 6
- 2, 6, 2926, 2, 7, 57793, 3, 6, 2022, 3, 7, 2795, // 2, 7
- 1, 7, 2022, 1, 8, 2794, 2, 7, 2926, 2, 8, 57794, // 2, 8
- 1, 8, 2088, 1, 9, 2897, 2, 8, 3007, 2, 9, 57544, // 2, 9
- 1, 9, 2205, 1, 10, 3073, 2, 9, 3161, 2, 10, 57097, // 2,10
- 1, 10, 2365, 1, 11, 3310, 2, 10, 3374, 2, 11, 56487, // 2,11
- 1, 11, 2556, 1, 12, 3594, 2, 11, 3630, 2, 12, 55756, // 2,12
- 1, 12, 2770, 1, 13, 3911, 2, 12, 3913, 2, 13, 54942, // 2,13
- 1, 13, 2998, 1, 14, 4253, 2, 13, 4214, 2, 14, 54071, // 2,14
- 1, 14, 3235, 1, 15, 4610, 2, 14, 4523, 2, 15, 53168, // 2,15
- 3, -1, 4264, 3, 0, 53815, 4, -1, 3064, 4, 0, 4393, // 3, 0
- 3, 0, 3927, 3, 1, 54796, 4, 0, 2808, 4, 1, 4005, // 3, 1
- 3, 1, 3594, 3, 2, 55756, 4, 1, 2556, 4, 2, 3630, // 3, 2
- 3, 2, 3273, 3, 3, 56673, 4, 2, 2317, 4, 3, 3273, // 3, 3
- 3, 3, 2976, 3, 4, 57514, 4, 3, 2096, 4, 4, 2950, // 3, 4
- 3, 4, 2722, 3, 5, 58233, 4, 4, 1908, 4, 5, 2673, // 3, 5
- 3, 5, 2532, 3, 6, 58774, 4, 5, 1767, 4, 6, 2463, // 3, 6
- 3, 6, 2430, 3, 7, 59076, 4, 6, 1687, 4, 7, 2343, // 3, 7
- 2, 7, 1687, 2, 8, 2342, 3, 7, 2430, 3, 8, 59077, // 3, 8
- 2, 8, 1766, 2, 9, 2463, 3, 8, 2532, 3, 9, 58775, // 3, 9
- 2, 9, 1908, 2, 10, 2672, 3, 9, 2723, 3, 10, 58233, // 3,10
- 2, 10, 2096, 2, 11, 2948, 3, 10, 2977, 3, 11, 57515, // 3,11
- 2, 11, 2317, 2, 12, 3273, 3, 11, 3274, 3, 12, 56672, // 3,12
- 2, 12, 2557, 2, 13, 3628, 3, 12, 3595, 3, 13, 55756, // 3,13
- 2, 13, 2808, 2, 14, 4003, 3, 13, 3929, 3, 14, 54796, // 3,14
- 2, 14, 3065, 2, 15, 4390, 3, 14, 4267, 3, 15, 53814, // 3,15
- 4, -1, 4041, 4, 0, 54378, 5, -1, 2916, 5, 0, 4201, // 4, 0
- 4, 0, 3677, 4, 1, 55435, 5, 0, 2640, 5, 1, 3784, // 4, 1
- 4, 1, 3310, 4, 2, 56487, 5, 1, 2365, 5, 2, 3374, // 4, 2
- 4, 2, 2948, 4, 3, 57514, 5, 2, 2096, 5, 3, 2978, // 4, 3
- 4, 3, 2604, 4, 4, 58484, 5, 3, 1843, 5, 4, 2605, // 4, 4
- 4, 4, 2297, 4, 5, 59345, 5, 4, 1617, 5, 5, 2277, // 4, 5
- 4, 5, 2057, 4, 6, 60017, 5, 5, 1442, 5, 6, 2020, // 4, 6
- 4, 6, 1922, 4, 7, 60402, 5, 6, 1341, 5, 7, 1871, // 4, 7
- 3, 7, 1341, 3, 8, 1871, 4, 7, 1922, 4, 8, 60402, // 4, 8
- 3, 8, 1442, 3, 9, 2020, 4, 8, 2057, 4, 9, 60017, // 4, 9
- 3, 9, 1617, 3, 10, 2276, 4, 9, 2297, 4, 10, 59346, // 4,10
- 3, 10, 1843, 3, 11, 2604, 4, 10, 2605, 4, 11, 58484, // 4,11
- 3, 11, 2096, 3, 12, 2976, 4, 11, 2950, 4, 12, 57514, // 4,12
- 3, 12, 2365, 3, 13, 3373, 4, 12, 3311, 4, 13, 56487, // 4,13
- 3, 13, 2640, 3, 14, 3783, 4, 13, 3678, 4, 14, 55435, // 4,14
- 3, 14, 2917, 3, 15, 4200, 4, 14, 4043, 4, 15, 54376, // 4,15
- 5, -1, 3858, 5, 0, 54835, 6, -1, 2796, 6, 0, 4047, // 5, 0
- 5, 0, 3470, 5, 1, 55959, 6, 0, 2502, 6, 1, 3605, // 5, 1
- 5, 1, 3073, 5, 2, 57096, 6, 1, 2205, 6, 2, 3162, // 5, 2
- 5, 2, 2672, 5, 3, 58234, 6, 2, 1908, 6, 3, 2722, // 5, 3
- 5, 3, 2276, 5, 4, 59346, 6, 3, 1617, 6, 4, 2297, // 5, 4
- 5, 4, 1904, 5, 5, 60381, 6, 4, 1347, 6, 5, 1904, // 5, 5
- 5, 5, 1593, 5, 6, 61243, 6, 5, 1121, 6, 6, 1579, // 5, 6
- 5, 6, 1405, 5, 7, 61767, 6, 6, 985, 6, 7, 1379, // 5, 7
- 4, 7, 985, 4, 8, 1380, 5, 7, 1405, 5, 8, 61766, // 5, 8
- 4, 8, 1121, 4, 9, 1578, 5, 8, 1593, 5, 9, 61244, // 5, 9
- 4, 9, 1347, 4, 10, 1904, 5, 9, 1904, 5, 10, 60381, // 5,10
- 4, 10, 1617, 4, 11, 2297, 5, 10, 2276, 5, 11, 59346, // 5,11
- 4, 11, 1908, 4, 12, 2722, 5, 11, 2673, 5, 12, 58233, // 5,12
- 4, 12, 2205, 4, 13, 3161, 5, 12, 3074, 5, 13, 57096, // 5,13
- 4, 13, 2503, 4, 14, 3604, 5, 13, 3472, 5, 14, 55957, // 5,14
- 4, 14, 2797, 4, 15, 4046, 5, 14, 3860, 5, 15, 54833, // 5,15
- 6, -1, 3722, 6, 0, 55166, 7, -1, 2709, 7, 0, 3939, // 6, 0
- 6, 0, 3317, 6, 1, 56340, 7, 0, 2402, 7, 1, 3477, // 6, 1
- 6, 1, 2897, 6, 2, 57545, 7, 1, 2088, 7, 2, 3006, // 6, 2
- 6, 2, 2463, 6, 3, 58775, 7, 2, 1766, 7, 3, 2532, // 6, 3
- 6, 3, 2020, 6, 4, 60018, 7, 3, 1442, 7, 4, 2056, // 6, 4
- 6, 4, 1578, 6, 5, 61243, 7, 4, 1121, 7, 5, 1594, // 6, 5
- 6, 5, 1170, 6, 6, 62369, 7, 5, 827, 7, 6, 1170, // 6, 6
- 6, 6, 883, 6, 7, 63156, 7, 6, 622, 7, 7, 875, // 6, 7
- 5, 7, 622, 5, 8, 875, 6, 7, 883, 6, 8, 63156, // 6, 8
- 5, 8, 827, 5, 9, 1170, 6, 8, 1170, 6, 9, 62369, // 6, 9
- 5, 9, 1121, 5, 10, 1593, 6, 9, 1579, 6, 10, 61243, // 6,10
- 5, 10, 1442, 5, 11, 2057, 6, 10, 2020, 6, 11, 60017, // 6,11
- 5, 11, 1767, 5, 12, 2532, 6, 11, 2464, 6, 12, 58773, // 6,12
- 5, 12, 2088, 5, 13, 3007, 6, 12, 2898, 6, 13, 57543, // 6,13
- 5, 13, 2403, 5, 14, 3476, 6, 13, 3319, 6, 14, 56338, // 6,14
- 5, 14, 2709, 5, 15, 3939, 6, 14, 3724, 6, 15, 55164, // 6,15
- 7, -1, 3638, 7, 0, 55354, 8, -1, 2659, 8, 0, 3885, // 7, 0
- 7, 0, 3225, 7, 1, 56554, 8, 0, 2346, 8, 1, 3411, // 7, 1
- 7, 1, 2794, 7, 2, 57795, 8, 1, 2022, 8, 2, 2925, // 7, 2
- 7, 2, 2342, 7, 3, 59077, 8, 2, 1687, 8, 3, 2430, // 7, 3
- 7, 3, 1871, 7, 4, 60402, 8, 3, 1341, 8, 4, 1922, // 7, 4
- 7, 4, 1380, 7, 5, 61767, 8, 4, 985, 8, 5, 1404, // 7, 5
- 7, 5, 875, 7, 6, 63156, 8, 5, 622, 8, 6, 883, // 7, 6
- 7, 6, 399, 7, 7, 64455, 8, 6, 282, 8, 7, 400, // 7, 7
- 6, 7, 282, 6, 8, 399, 7, 7, 399, 7, 8, 64456, // 7, 8
- 6, 8, 622, 6, 9, 883, 7, 8, 875, 7, 9, 63156, // 7, 9
- 6, 9, 985, 6, 10, 1405, 7, 9, 1380, 7, 10, 61766, // 7,10
- 6, 10, 1341, 6, 11, 1922, 7, 10, 1871, 7, 11, 60402, // 7,11
- 6, 11, 1687, 6, 12, 2430, 7, 11, 2343, 7, 12, 59076, // 7,12
- 6, 12, 2022, 6, 13, 2926, 7, 12, 2795, 7, 13, 57793, // 7,13
- 6, 13, 2346, 6, 14, 3411, 7, 13, 3227, 7, 14, 56552, // 7,14
- 6, 14, 2659, 6, 15, 3885, 7, 14, 3640, 7, 15, 55352, // 7,15
- 8, 0, 55352, 8, 1, 3640, 9, 0, 3885, 9, 1, 2659, // 8, 0
- 8, 1, 56552, 8, 2, 3227, 9, 1, 3411, 9, 2, 2346, // 8, 1
- 8, 2, 57793, 8, 3, 2795, 9, 2, 2926, 9, 3, 2022, // 8, 2
- 8, 3, 59076, 8, 4, 2343, 9, 3, 2430, 9, 4, 1687, // 8, 3
- 8, 4, 60402, 8, 5, 1871, 9, 4, 1922, 9, 5, 1341, // 8, 4
- 8, 5, 61767, 8, 6, 1380, 9, 5, 1405, 9, 6, 984, // 8, 5
- 8, 6, 63156, 8, 7, 875, 9, 6, 883, 9, 7, 622, // 8, 6
- 8, 7, 64455, 8, 8, 399, 9, 7, 399, 9, 8, 283, // 8, 7
- 7, 8, 399, 7, 9, 282, 8, 8, 64455, 8, 9, 400, // 8, 8
- 7, 9, 883, 7, 10, 622, 8, 9, 63156, 8, 10, 875, // 8, 9
- 7, 10, 1405, 7, 11, 985, 8, 10, 61767, 8, 11, 1379, // 8,10
- 7, 11, 1922, 7, 12, 1341, 8, 11, 60402, 8, 12, 1871, // 8,11
- 7, 12, 2430, 7, 13, 1687, 8, 12, 59077, 8, 13, 2342, // 8,12
- 7, 13, 2926, 7, 14, 2022, 8, 13, 57795, 8, 14, 2793, // 8,13
- 7, 14, 3411, 7, 15, 2346, 8, 14, 56554, 8, 15, 3225, // 8,14
- 7, 15, 3885, 7, 16, 2659, 8, 15, 55354, 8, 16, 3638, // 8,15
- 9, 0, 55164, 9, 1, 3724, 10, 0, 3939, 10, 1, 2709, // 9, 0
- 9, 1, 56339, 9, 2, 3319, 10, 1, 3476, 10, 2, 2402, // 9, 1
- 9, 2, 57544, 9, 3, 2898, 10, 2, 3007, 10, 3, 2087, // 9, 2
- 9, 3, 58774, 9, 4, 2464, 10, 3, 2532, 10, 4, 1766, // 9, 3
- 9, 4, 60017, 9, 5, 2020, 10, 4, 2057, 10, 5, 1442, // 9, 4
- 9, 5, 61243, 9, 6, 1579, 10, 5, 1593, 10, 6, 1121, // 9, 5
- 9, 6, 62369, 9, 7, 1170, 10, 6, 1170, 10, 7, 827, // 9, 6
- 9, 7, 63156, 9, 8, 883, 10, 7, 875, 10, 8, 622, // 9, 7
- 8, 8, 875, 8, 9, 622, 9, 8, 63156, 9, 9, 883, // 9, 8
- 8, 9, 1170, 8, 10, 827, 9, 9, 62369, 9, 10, 1170, // 9, 9
- 8, 10, 1593, 8, 11, 1121, 9, 10, 61243, 9, 11, 1579, // 9,10
- 8, 11, 2057, 8, 12, 1442, 9, 11, 60018, 9, 12, 2019, // 9,11
- 8, 12, 2532, 8, 13, 1766, 9, 12, 58775, 9, 13, 2463, // 9,12
- 8, 13, 3007, 8, 14, 2088, 9, 13, 57545, 9, 14, 2896, // 9,13
- 8, 14, 3477, 8, 15, 2402, 9, 14, 56340, 9, 15, 3317, // 9,14
- 8, 15, 3940, 8, 16, 2709, 9, 15, 55166, 9, 16, 3721, // 9,15
- 10, 0, 54833, 10, 1, 3860, 11, 0, 4046, 11, 1, 2797, // 10, 0
- 10, 1, 55958, 10, 2, 3472, 11, 1, 3604, 11, 2, 2502, // 10, 1
- 10, 2, 57095, 10, 3, 3074, 11, 2, 3161, 11, 3, 2206, // 10, 2
- 10, 3, 58233, 10, 4, 2673, 11, 3, 2722, 11, 4, 1908, // 10, 3
- 10, 4, 59345, 10, 5, 2276, 11, 4, 2297, 11, 5, 1618, // 10, 4
- 10, 5, 60381, 10, 6, 1904, 11, 5, 1904, 11, 6, 1347, // 10, 5
- 10, 6, 61243, 10, 7, 1593, 11, 6, 1578, 11, 7, 1122, // 10, 6
- 10, 7, 61767, 10, 8, 1405, 11, 7, 1380, 11, 8, 984, // 10, 7
- 9, 8, 1380, 9, 9, 985, 10, 8, 61767, 10, 9, 1404, // 10, 8
- 9, 9, 1579, 9, 10, 1121, 10, 9, 61243, 10, 10, 1593, // 10, 9
- 9, 10, 1904, 9, 11, 1347, 10, 10, 60381, 10, 11, 1904, // 10,10
- 9, 11, 2297, 9, 12, 1617, 10, 11, 59346, 10, 12, 2276, // 10,11
- 9, 12, 2723, 9, 13, 1908, 10, 12, 58234, 10, 13, 2671, // 10,12
- 9, 13, 3161, 9, 14, 2205, 10, 13, 57096, 10, 14, 3074, // 10,13
- 9, 14, 3605, 9, 15, 2502, 10, 14, 55959, 10, 15, 3470, // 10,14
- 9, 15, 4047, 9, 16, 2796, 10, 15, 54835, 10, 16, 3858, // 10,15
- 11, 0, 54376, 11, 1, 4043, 12, 0, 4200, 12, 1, 2917, // 11, 0
- 11, 1, 55434, 11, 2, 3678, 12, 1, 3783, 12, 2, 2641, // 11, 1
- 11, 2, 56486, 11, 3, 3311, 12, 2, 3373, 12, 3, 2366, // 11, 2
- 11, 3, 57514, 11, 4, 2950, 12, 3, 2976, 12, 4, 2096, // 11, 3
- 11, 4, 58484, 11, 5, 2605, 12, 4, 2604, 12, 5, 1843, // 11, 4
- 11, 5, 59346, 11, 6, 2297, 12, 5, 2276, 12, 6, 1617, // 11, 5
- 11, 6, 60018, 11, 7, 2057, 12, 6, 2020, 12, 7, 1441, // 11, 6
- 11, 7, 60402, 11, 8, 1922, 12, 7, 1871, 12, 8, 1341, // 11, 7
- 10, 8, 1871, 10, 9, 1341, 11, 8, 60402, 11, 9, 1922, // 11, 8
- 10, 9, 2020, 10, 10, 1442, 11, 9, 60017, 11, 10, 2057, // 11, 9
- 10, 10, 2276, 10, 11, 1617, 11, 10, 59345, 11, 11, 2298, // 11,10
- 10, 11, 2605, 10, 12, 1843, 11, 11, 58484, 11, 12, 2604, // 11,11
- 10, 12, 2977, 10, 13, 2096, 11, 12, 57514, 11, 13, 2949, // 11,12
- 10, 13, 3374, 10, 14, 2365, 11, 13, 56487, 11, 14, 3310, // 11,13
- 10, 14, 3785, 10, 15, 2640, 11, 14, 55435, 11, 15, 3676, // 11,14
- 10, 15, 4201, 10, 16, 2916, 11, 15, 54378, 11, 16, 4041, // 11,15
- 12, 0, 53814, 12, 1, 4267, 13, 0, 4390, 13, 1, 3065, // 12, 0
- 12, 1, 54796, 12, 2, 3929, 13, 1, 4003, 13, 2, 2808, // 12, 1
- 12, 2, 55756, 12, 3, 3595, 13, 2, 3628, 13, 3, 2557, // 12, 2
- 12, 3, 56673, 12, 4, 3274, 13, 3, 3273, 13, 4, 2316, // 12, 3
- 12, 4, 57514, 12, 5, 2977, 13, 4, 2948, 13, 5, 2097, // 12, 4
- 12, 5, 58234, 12, 6, 2723, 13, 5, 2672, 13, 6, 1907, // 12, 5
- 12, 6, 58775, 12, 7, 2532, 13, 6, 2463, 13, 7, 1766, // 12, 6
- 12, 7, 59077, 12, 8, 2430, 13, 7, 2342, 13, 8, 1687, // 12, 7
- 11, 8, 2343, 11, 9, 1687, 12, 8, 59076, 12, 9, 2430, // 12, 8
- 11, 9, 2464, 11, 10, 1767, 12, 9, 58774, 12, 10, 2531, // 12, 9
- 11, 10, 2673, 11, 11, 1908, 12, 10, 58233, 12, 11, 2722, // 12,10
- 11, 11, 2950, 11, 12, 2096, 12, 11, 57514, 12, 12, 2976, // 12,11
- 11, 12, 3274, 11, 13, 2317, 12, 12, 56673, 12, 13, 3272, // 12,12
- 11, 13, 3630, 11, 14, 2556, 12, 13, 55756, 12, 14, 3594, // 12,13
- 11, 14, 4005, 11, 15, 2808, 12, 14, 54796, 12, 15, 3927, // 12,14
- 11, 15, 4392, 11, 16, 3064, 12, 15, 53815, 12, 16, 4265, // 12,15
- 13, 0, 53168, 13, 1, 4523, 14, 0, 4610, 14, 1, 3235, // 13, 0
- 13, 1, 54071, 13, 2, 4214, 14, 1, 4253, 14, 2, 2998, // 13, 1
- 13, 2, 54941, 13, 3, 3913, 14, 2, 3911, 14, 3, 2771, // 13, 2
- 13, 3, 55756, 13, 4, 3630, 14, 3, 3594, 14, 4, 2556, // 13, 3
- 13, 4, 56487, 13, 5, 3374, 14, 4, 3310, 14, 5, 2365, // 13, 4
- 13, 5, 57096, 13, 6, 3161, 14, 5, 3073, 14, 6, 2206, // 13, 5
- 13, 6, 57545, 13, 7, 3007, 14, 6, 2897, 14, 7, 2087, // 13, 6
- 13, 7, 57795, 13, 8, 2926, 14, 7, 2794, 14, 8, 2021, // 13, 7
- 12, 8, 2795, 12, 9, 2022, 13, 8, 57793, 13, 9, 2926, // 13, 8
- 12, 9, 2898, 12, 10, 2088, 13, 9, 57544, 13, 10, 3006, // 13, 9
- 12, 10, 3074, 12, 11, 2205, 13, 10, 57095, 13, 11, 3162, // 13,10
- 12, 11, 3311, 12, 12, 2365, 13, 11, 56486, 13, 12, 3374, // 13,11
- 12, 12, 3595, 12, 13, 2557, 13, 12, 55756, 13, 13, 3628, // 13,12
- 12, 13, 3913, 12, 14, 2770, 13, 13, 54941, 13, 14, 3912, // 13,13
- 12, 14, 4255, 12, 15, 2998, 13, 14, 54072, 13, 15, 4211, // 13,14
- 12, 15, 4612, 12, 16, 3235, 13, 15, 53168, 13, 16, 4521, // 13,15
- 14, 0, 52457, 14, 1, 4806, 15, 0, 4851, 15, 1, 3422, // 14, 0
- 14, 1, 53285, 14, 2, 4525, 15, 1, 4522, 15, 2, 3204, // 14, 1
- 14, 2, 54072, 14, 3, 4255, 15, 2, 4212, 15, 3, 2997, // 14, 2
- 14, 3, 54796, 14, 4, 4005, 15, 3, 3927, 15, 4, 2808, // 14, 3
- 14, 4, 55435, 14, 5, 3785, 15, 4, 3677, 15, 5, 2639, // 14, 4
- 14, 5, 55959, 14, 6, 3605, 15, 5, 3470, 15, 6, 2502, // 14, 5
- 14, 6, 56340, 14, 7, 3477, 15, 6, 3317, 15, 7, 2402, // 14, 6
- 14, 7, 56554, 14, 8, 3411, 15, 7, 3225, 15, 8, 2346, // 14, 7
- 13, 8, 3227, 13, 9, 2346, 14, 8, 56552, 14, 9, 3411, // 14, 8
- 13, 9, 3319, 13, 10, 2403, 14, 9, 56339, 14, 10, 3475, // 14, 9
- 13, 10, 3472, 13, 11, 2503, 14, 10, 55958, 14, 11, 3603, // 14,10
- 13, 11, 3678, 13, 12, 2640, 14, 11, 55434, 14, 12, 3784, // 14,11
- 13, 12, 3929, 13, 13, 2808, 14, 12, 54796, 14, 13, 4003, // 14,12
- 13, 13, 4214, 13, 14, 2998, 14, 13, 54071, 14, 14, 4253, // 14,13
- 13, 14, 4525, 13, 15, 3204, 14, 14, 53285, 14, 15, 4522, // 14,14
- 13, 15, 4854, 13, 16, 3421, 14, 15, 52457, 14, 16, 4804, // 14,15
- 15, 0, 51699, 15, 1, 5110, 16, 0, 5106, 16, 1, 3621, // 15, 0
- 15, 1, 52457, 15, 2, 4854, 16, 1, 4803, 16, 2, 3422, // 15, 1
- 15, 2, 53168, 15, 3, 4612, 16, 2, 4521, 16, 3, 3235, // 15, 2
- 15, 3, 53815, 15, 4, 4392, 16, 3, 4264, 16, 4, 3065, // 15, 3
- 15, 4, 54378, 15, 5, 4201, 16, 4, 4041, 16, 5, 2916, // 15, 4
- 15, 5, 54835, 15, 6, 4047, 16, 5, 3858, 16, 6, 2796, // 15, 5
- 15, 6, 55166, 15, 7, 3940, 16, 6, 3722, 16, 7, 2708, // 15, 6
- 15, 7, 55354, 15, 8, 3885, 16, 7, 3638, 16, 8, 2659, // 15, 7
- 14, 8, 3640, 14, 9, 2659, 15, 8, 55352, 15, 9, 3885, // 15, 8
- 14, 9, 3724, 14, 10, 2709, 15, 9, 55164, 15, 10, 3939, // 15, 9
- 14, 10, 3860, 14, 11, 2797, 15, 10, 54833, 15, 11, 4046, // 15,10
- 14, 11, 4043, 14, 12, 2917, 15, 11, 54376, 15, 12, 4200, // 15,11
- 14, 12, 4267, 14, 13, 3065, 15, 12, 53814, 15, 13, 4390, // 15,12
- 14, 13, 4523, 14, 14, 3235, 15, 13, 53168, 15, 14, 4610, // 15,13
- 14, 14, 4806, 14, 15, 3422, 15, 14, 52457, 15, 15, 4851, // 15,14
- 14, 15, 5110, 14, 16, 3621, 15, 15, 51699, 15, 16, 5106, // 15,15
- // angle of 1.0 degrees
- 0, -1, 8769, 0, 0, 41693, 1, -1, 6280, 1, 0, 8794, // 0, 0
- 0, 0, 8452, 0, 1, 42821, 1, 0, 5975, 1, 1, 8288, // 0, 1
- 0, 1, 8141, 0, 2, 43900, 1, 1, 5684, 1, 2, 7811, // 0, 2
- 0, 2, 7848, 0, 3, 44901, 1, 2, 5413, 1, 3, 7374, // 0, 3
- 0, 3, 7587, 0, 4, 45791, 1, 3, 5172, 1, 4, 6986, // 0, 4
- 0, 4, 7374, 0, 5, 46532, 1, 4, 4971, 1, 5, 6659, // 0, 5
- 0, 5, 7227, 0, 6, 47086, 1, 5, 4818, 1, 6, 6405, // 0, 6
- 0, 6, 7158, 0, 7, 47426, 1, 6, 4722, 1, 7, 6230, // 0, 7
- -1, 7, 4718, -1, 8, 6217, 0, 7, 7161, 0, 8, 47440, // 0, 8
- -1, 8, 4814, -1, 9, 6391, 0, 8, 7233, 0, 9, 47098, // 0, 9
- -1, 9, 4967, -1, 10, 6644, 0, 9, 7383, 0, 10, 46542, // 0,10
- -1, 10, 5169, -1, 11, 6970, 0, 10, 7599, 0, 11, 45798, // 0,11
- -1, 11, 5410, -1, 12, 7356, 0, 11, 7863, 0, 12, 44907, // 0,12
- -1, 12, 5682, -1, 13, 7791, 0, 12, 8159, 0, 13, 43904, // 0,13
- -1, 13, 5974, -1, 14, 8265, 0, 13, 8474, 0, 14, 42823, // 0,14
- -1, 14, 6280, -1, 15, 8769, 0, 14, 8795, 0, 15, 41692, // 0,15
- 1, -1, 8265, 1, 0, 42823, 2, -1, 5974, 2, 0, 8474, // 1, 0
- 1, 0, 7901, 1, 1, 44074, 2, 0, 5640, 2, 1, 7921, // 1, 1
- 1, 1, 7539, 1, 2, 45286, 2, 1, 5316, 2, 2, 7395, // 1, 2
- 1, 2, 7191, 1, 3, 46427, 2, 2, 5011, 2, 3, 6907, // 1, 3
- 1, 3, 6875, 1, 4, 47453, 2, 3, 4736, 2, 4, 6472, // 1, 4
- 1, 4, 6613, 1, 5, 48314, 2, 4, 4505, 2, 5, 6104, // 1, 5
- 1, 5, 6425, 1, 6, 48960, 2, 5, 4330, 2, 6, 5821, // 1, 6
- 1, 6, 6332, 1, 7, 49347, 2, 6, 4224, 2, 7, 5633, // 1, 7
- 0, 7, 4221, 0, 8, 5623, 1, 7, 6335, 1, 8, 49357, // 1, 8
- 0, 8, 4327, 0, 9, 5809, 1, 8, 6430, 1, 9, 48970, // 1, 9
- 0, 9, 4502, 0, 10, 6092, 1, 9, 6620, 1, 10, 48322, // 1,10
- 0, 10, 4734, 0, 11, 6458, 1, 10, 6886, 1, 11, 47458, // 1,11
- 0, 11, 5009, 0, 12, 6892, 1, 11, 7204, 1, 12, 46431, // 1,12
- 0, 12, 5315, 0, 13, 7378, 1, 12, 7555, 1, 13, 45288, // 1,13
- 0, 13, 5640, 0, 14, 7901, 1, 13, 7921, 1, 14, 44074, // 1,14
- 0, 14, 5975, 0, 15, 8452, 1, 14, 8288, 1, 15, 42821, // 1,15
- 2, -1, 7791, 2, 0, 43904, 3, -1, 5682, 3, 0, 8159, // 2, 0
- 2, 0, 7378, 2, 1, 45288, 3, 0, 5315, 3, 1, 7555, // 2, 1
- 2, 1, 6959, 2, 2, 46650, 3, 1, 4954, 3, 2, 6973, // 2, 2
- 2, 2, 6549, 2, 3, 47953, 3, 2, 4608, 3, 3, 6426, // 2, 3
- 2, 3, 6168, 2, 4, 49147, 3, 3, 4291, 3, 4, 5930, // 2, 4
- 2, 4, 5842, 2, 5, 50165, 3, 4, 4020, 3, 5, 5509, // 2, 5
- 2, 5, 5602, 2, 6, 50935, 3, 5, 3815, 3, 6, 5184, // 2, 6
- 2, 6, 5478, 2, 7, 51387, 3, 6, 3693, 3, 7, 4978, // 2, 7
- 1, 7, 3691, 1, 8, 4970, 2, 7, 5480, 2, 8, 51395, // 2, 8
- 1, 8, 3813, 1, 9, 5175, 2, 8, 5606, 2, 9, 50942, // 2, 9
- 1, 9, 4019, 1, 10, 5499, 2, 9, 5848, 2, 10, 50170, // 2,10
- 1, 10, 4290, 1, 11, 5920, 2, 10, 6176, 2, 11, 49150, // 2,11
- 1, 11, 4607, 1, 12, 6414, 2, 11, 6560, 2, 12, 47955, // 2,12
- 1, 12, 4954, 1, 13, 6959, 2, 12, 6973, 2, 13, 46650, // 2,13
- 1, 13, 5316, 1, 14, 7539, 2, 13, 7395, 2, 14, 45286, // 2,14
- 1, 14, 5684, 1, 15, 8141, 2, 14, 7812, 2, 15, 43899, // 2,15
- 3, -1, 7356, 3, 0, 44907, 4, -1, 5410, 4, 0, 7863, // 3, 0
- 3, 0, 6892, 3, 1, 46430, 4, 0, 5009, 4, 1, 7205, // 3, 1
- 3, 1, 6414, 3, 2, 47955, 4, 1, 4607, 4, 2, 6560, // 3, 2
- 3, 2, 5934, 3, 3, 49445, 4, 2, 4214, 4, 3, 5943, // 3, 3
- 3, 3, 5474, 3, 4, 50843, 4, 3, 3846, 4, 4, 5373, // 3, 4
- 3, 4, 5069, 3, 5, 52066, 4, 4, 3523, 4, 5, 4878, // 3, 5
- 3, 5, 4759, 3, 6, 53008, 4, 5, 3274, 4, 6, 4495, // 3, 6
- 3, 6, 4592, 3, 7, 53557, 4, 6, 3128, 4, 7, 4259, // 3, 7
- 2, 7, 3126, 2, 8, 4254, 3, 7, 4594, 3, 8, 53562, // 3, 8
- 2, 8, 3273, 2, 9, 4489, 3, 8, 4762, 3, 9, 53012, // 3, 9
- 2, 9, 3522, 2, 10, 4872, 3, 9, 5073, 3, 10, 52069, // 3,10
- 2, 10, 3845, 2, 11, 5365, 3, 10, 5481, 3, 11, 50845, // 3,11
- 2, 11, 4214, 2, 12, 5934, 3, 11, 5943, 3, 12, 49445, // 3,12
- 2, 12, 4608, 2, 13, 6549, 3, 12, 6426, 3, 13, 47953, // 3,13
- 2, 13, 5011, 2, 14, 7191, 3, 13, 6908, 3, 14, 46426, // 3,14
- 2, 14, 5413, 2, 15, 7848, 3, 14, 7374, 3, 15, 44901, // 3,15
- 4, -1, 6970, 4, 0, 45799, 5, -1, 5169, 5, 0, 7598, // 4, 0
- 4, 0, 6458, 4, 1, 47458, 5, 0, 4734, 5, 1, 6886, // 4, 1
- 4, 1, 5920, 4, 2, 49150, 5, 1, 4290, 5, 2, 6176, // 4, 2
- 4, 2, 5365, 4, 3, 50844, 5, 2, 3845, 5, 3, 5482, // 4, 3
- 4, 3, 4816, 4, 4, 52484, 5, 3, 3415, 5, 4, 4821, // 4, 4
- 4, 4, 4309, 4, 5, 53973, 5, 4, 3023, 5, 5, 4231, // 4, 5
- 4, 5, 3902, 4, 6, 55164, 5, 5, 2711, 5, 6, 3759, // 4, 6
- 4, 6, 3671, 4, 7, 55867, 5, 6, 2525, 5, 7, 3473, // 4, 7
- 3, 7, 2524, 3, 8, 3469, 4, 7, 3672, 4, 8, 55871, // 4, 8
- 3, 8, 2710, 3, 9, 3755, 4, 8, 3904, 4, 9, 55167, // 4, 9
- 3, 9, 3023, 3, 10, 4226, 4, 9, 4313, 4, 10, 53974, // 4,10
- 3, 10, 3415, 3, 11, 4816, 4, 10, 4822, 4, 11, 52483, // 4,11
- 3, 11, 3846, 3, 12, 5474, 4, 11, 5373, 4, 12, 50843, // 4,12
- 3, 12, 4291, 3, 13, 6168, 4, 12, 5930, 4, 13, 49147, // 4,13
- 3, 13, 4736, 3, 14, 6875, 4, 13, 6472, 4, 14, 47453, // 4,14
- 3, 14, 5172, 3, 15, 7587, 4, 14, 6986, 4, 15, 45791, // 4,15
- 5, -1, 6644, 5, 0, 46541, 6, -1, 4967, 6, 0, 7384, // 5, 0
- 5, 0, 6092, 5, 1, 48322, 6, 0, 4502, 6, 1, 6620, // 5, 1
- 5, 1, 5499, 5, 2, 50171, 6, 1, 4019, 6, 2, 5847, // 5, 2
- 5, 2, 4872, 5, 3, 52069, 6, 2, 3522, 6, 3, 5073, // 5, 3
- 5, 3, 4226, 5, 4, 53975, 6, 3, 3023, 6, 4, 4312, // 5, 4
- 5, 4, 3595, 5, 5, 55798, 6, 4, 2546, 6, 5, 3597, // 5, 5
- 5, 5, 3050, 5, 6, 57353, 6, 5, 2138, 6, 6, 2995, // 5, 6
- 5, 6, 2713, 5, 7, 58322, 6, 6, 1884, 6, 7, 2617, // 5, 7
- 4, 7, 1884, 4, 8, 2615, 5, 7, 2714, 5, 8, 58323, // 5, 8
- 4, 8, 2138, 4, 9, 2993, 5, 8, 3051, 5, 9, 57354, // 5, 9
- 4, 9, 2546, 4, 10, 3595, 5, 9, 3598, 5, 10, 55797, // 5,10
- 4, 10, 3023, 4, 11, 4309, 5, 10, 4230, 5, 11, 53974, // 5,11
- 4, 11, 3523, 4, 12, 5069, 5, 11, 4879, 5, 12, 52065, // 5,12
- 4, 12, 4020, 4, 13, 5842, 5, 12, 5508, 5, 13, 50166, // 5,13
- 4, 13, 4505, 4, 14, 6613, 5, 13, 6104, 5, 14, 48314, // 5,14
- 4, 14, 4971, 4, 15, 7374, 5, 14, 6659, 5, 15, 46532, // 5,15
- 6, -1, 6391, 6, 0, 47098, 7, -1, 4814, 7, 0, 7233, // 6, 0
- 6, 0, 5809, 6, 1, 48969, 7, 0, 4327, 7, 1, 6431, // 6, 1
- 6, 1, 5175, 6, 2, 50942, 7, 1, 3813, 7, 2, 5606, // 6, 2
- 6, 2, 4489, 6, 3, 53012, 7, 2, 3273, 7, 3, 4762, // 6, 3
- 6, 3, 3755, 6, 4, 55166, 7, 3, 2710, 7, 4, 3905, // 6, 4
- 6, 4, 2993, 6, 5, 57354, 7, 4, 2138, 7, 5, 3051, // 6, 5
- 6, 5, 2258, 6, 6, 59422, 7, 5, 1597, 7, 6, 2259, // 6, 6
- 6, 6, 1726, 6, 7, 60905, 7, 6, 1210, 7, 7, 1695, // 6, 7
- 5, 7, 1209, 5, 8, 1695, 6, 7, 1726, 6, 8, 60906, // 6, 8
- 5, 8, 1597, 5, 9, 2258, 6, 8, 2259, 6, 9, 59422, // 6, 9
- 5, 9, 2138, 5, 10, 3050, 6, 9, 2995, 6, 10, 57353, // 6,10
- 5, 10, 2711, 5, 11, 3902, 6, 10, 3759, 6, 11, 55164, // 6,11
- 5, 11, 3274, 5, 12, 4759, 6, 11, 4495, 6, 12, 53008, // 6,12
- 5, 12, 3815, 5, 13, 5602, 6, 12, 5184, 6, 13, 50935, // 6,13
- 5, 13, 4330, 5, 14, 6425, 6, 13, 5820, 6, 14, 48961, // 6,14
- 5, 14, 4818, 5, 15, 7227, 6, 14, 6405, 6, 15, 47086, // 6,15
- 7, -1, 6217, 7, 0, 47440, 8, -1, 4718, 8, 0, 7161, // 7, 0
- 7, 0, 5623, 7, 1, 49358, 8, 0, 4221, 8, 1, 6334, // 7, 1
- 7, 1, 4970, 7, 2, 51395, 8, 1, 3691, 8, 2, 5480, // 7, 2
- 7, 2, 4254, 7, 3, 53562, 8, 2, 3126, 8, 3, 4594, // 7, 3
- 7, 3, 3469, 7, 4, 55870, 8, 3, 2524, 8, 4, 3673, // 7, 4
- 7, 4, 2615, 7, 5, 58324, 8, 4, 1884, 8, 5, 2713, // 7, 5
- 7, 5, 1695, 7, 6, 60906, 8, 5, 1209, 8, 6, 1726, // 7, 6
- 7, 6, 789, 7, 7, 63399, 8, 6, 558, 8, 7, 790, // 7, 7
- 6, 7, 558, 6, 8, 789, 7, 7, 789, 7, 8, 63400, // 7, 8
- 6, 8, 1210, 6, 9, 1726, 7, 8, 1695, 7, 9, 60905, // 7, 9
- 6, 9, 1884, 6, 10, 2713, 7, 9, 2616, 7, 10, 58323, // 7,10
- 6, 10, 2525, 6, 11, 3671, 7, 10, 3473, 7, 11, 55867, // 7,11
- 6, 11, 3128, 6, 12, 4592, 7, 11, 4259, 7, 12, 53557, // 7,12
- 6, 12, 3693, 6, 13, 5478, 7, 12, 4978, 7, 13, 51387, // 7,13
- 6, 13, 4224, 6, 14, 6332, 7, 13, 5633, 7, 14, 49347, // 7,14
- 6, 14, 4722, 6, 15, 7158, 7, 14, 6230, 7, 15, 47426, // 7,15
- 8, 0, 47426, 8, 1, 6230, 9, 0, 7158, 9, 1, 4722, // 8, 0
- 8, 1, 49347, 8, 2, 5633, 9, 1, 6332, 9, 2, 4224, // 8, 1
- 8, 2, 51387, 8, 3, 4978, 9, 2, 5478, 9, 3, 3693, // 8, 2
- 8, 3, 53557, 8, 4, 4259, 9, 3, 4592, 9, 4, 3128, // 8, 3
- 8, 4, 55867, 8, 5, 3473, 9, 4, 3671, 9, 5, 2525, // 8, 4
- 8, 5, 58322, 8, 6, 2616, 9, 5, 2713, 9, 6, 1885, // 8, 5
- 8, 6, 60905, 8, 7, 1695, 9, 6, 1726, 9, 7, 1210, // 8, 6
- 8, 7, 63399, 8, 8, 789, 9, 7, 789, 9, 8, 559, // 8, 7
- 7, 8, 789, 7, 9, 558, 8, 8, 63399, 8, 9, 790, // 8, 8
- 7, 9, 1726, 7, 10, 1209, 8, 9, 60906, 8, 10, 1695, // 8, 9
- 7, 10, 2714, 7, 11, 1884, 8, 10, 58324, 8, 11, 2614, // 8,10
- 7, 11, 3672, 7, 12, 2524, 8, 11, 55870, 8, 12, 3470, // 8,11
- 7, 12, 4594, 7, 13, 3126, 8, 12, 53562, 8, 13, 4254, // 8,12
- 7, 13, 5480, 7, 14, 3691, 8, 13, 51395, 8, 14, 4970, // 8,13
- 7, 14, 6335, 7, 15, 4221, 8, 14, 49358, 8, 15, 5622, // 8,14
- 7, 15, 7161, 7, 16, 4718, 8, 15, 47440, 8, 16, 6217, // 8,15
- 9, 0, 47086, 9, 1, 6405, 10, 0, 7227, 10, 1, 4818, // 9, 0
- 9, 1, 48960, 9, 2, 5820, 10, 1, 6425, 10, 2, 4331, // 9, 1
- 9, 2, 50935, 9, 3, 5184, 10, 2, 5602, 10, 3, 3815, // 9, 2
- 9, 3, 53008, 9, 4, 4495, 10, 3, 4759, 10, 4, 3274, // 9, 3
- 9, 4, 55164, 9, 5, 3759, 10, 4, 3902, 10, 5, 2711, // 9, 4
- 9, 5, 57353, 9, 6, 2995, 10, 5, 3050, 10, 6, 2138, // 9, 5
- 9, 6, 59422, 9, 7, 2259, 10, 6, 2258, 10, 7, 1597, // 9, 6
- 9, 7, 60906, 9, 8, 1726, 10, 7, 1695, 10, 8, 1209, // 9, 7
- 8, 8, 1695, 8, 9, 1210, 9, 8, 60905, 9, 9, 1726, // 9, 8
- 8, 9, 2259, 8, 10, 1597, 9, 9, 59422, 9, 10, 2258, // 9, 9
- 8, 10, 3051, 8, 11, 2138, 9, 10, 57354, 9, 11, 2993, // 9,10
- 8, 11, 3904, 8, 12, 2710, 9, 11, 55166, 9, 12, 3756, // 9,11
- 8, 12, 4762, 8, 13, 3273, 9, 12, 53012, 9, 13, 4489, // 9,12
- 8, 13, 5606, 8, 14, 3813, 9, 13, 50942, 9, 14, 5175, // 9,13
- 8, 14, 6430, 8, 15, 4327, 9, 14, 48969, 9, 15, 5810, // 9,14
- 8, 15, 7233, 8, 16, 4814, 9, 15, 47098, 9, 16, 6391, // 9,15
- 10, 0, 46532, 10, 1, 6659, 11, 0, 7374, 11, 1, 4971, // 10, 0
- 10, 1, 48314, 10, 2, 6104, 11, 1, 6613, 11, 2, 4505, // 10, 1
- 10, 2, 50165, 10, 3, 5508, 11, 2, 5842, 11, 3, 4021, // 10, 2
- 10, 3, 52066, 10, 4, 4879, 11, 3, 5069, 11, 4, 3522, // 10, 3
- 10, 4, 53973, 10, 5, 4230, 11, 4, 4309, 11, 5, 3024, // 10, 4
- 10, 5, 55798, 10, 6, 3598, 11, 5, 3595, 11, 6, 2545, // 10, 5
- 10, 6, 57354, 10, 7, 3051, 11, 6, 2993, 11, 7, 2138, // 10, 6
- 10, 7, 58324, 10, 8, 2714, 11, 7, 2615, 11, 8, 1883, // 10, 7
- 9, 8, 2616, 9, 9, 1884, 10, 8, 58322, 10, 9, 2714, // 10, 8
- 9, 9, 2995, 9, 10, 2138, 10, 9, 57353, 10, 10, 3050, // 10, 9
- 9, 10, 3598, 9, 11, 2546, 10, 10, 55798, 10, 11, 3594, // 10,10
- 9, 11, 4313, 9, 12, 3023, 10, 11, 53975, 10, 12, 4225, // 10,11
- 9, 12, 5073, 9, 13, 3522, 10, 12, 52069, 10, 13, 4872, // 10,12
- 9, 13, 5848, 9, 14, 4019, 10, 13, 50171, 10, 14, 5498, // 10,13
- 9, 14, 6620, 9, 15, 4502, 10, 14, 48322, 10, 15, 6092, // 10,14
- 9, 15, 7383, 9, 16, 4967, 10, 15, 46541, 10, 16, 6645, // 10,15
- 11, 0, 45791, 11, 1, 6986, 12, 0, 7587, 12, 1, 5172, // 11, 0
- 11, 1, 47453, 11, 2, 6472, 12, 1, 6875, 12, 2, 4736, // 11, 1
- 11, 2, 49147, 11, 3, 5930, 12, 2, 6168, 12, 3, 4291, // 11, 2
- 11, 3, 50843, 11, 4, 5373, 12, 3, 5474, 12, 4, 3846, // 11, 3
- 11, 4, 52484, 11, 5, 4822, 12, 4, 4816, 12, 5, 3414, // 11, 4
- 11, 5, 53975, 11, 6, 4313, 12, 5, 4226, 12, 6, 3022, // 11, 5
- 11, 6, 55166, 11, 7, 3904, 12, 6, 3755, 12, 7, 2711, // 11, 6
- 11, 7, 55870, 11, 8, 3672, 12, 7, 3469, 12, 8, 2525, // 11, 7
- 10, 8, 3473, 10, 9, 2525, 11, 8, 55867, 11, 9, 3671, // 11, 8
- 10, 9, 3759, 10, 10, 2711, 11, 9, 55164, 11, 10, 3902, // 11, 9
- 10, 10, 4230, 10, 11, 3023, 11, 10, 53973, 11, 11, 4310, // 11,10
- 10, 11, 4822, 10, 12, 3415, 11, 11, 52484, 11, 12, 4815, // 11,11
- 10, 12, 5481, 10, 13, 3845, 11, 12, 50844, 11, 13, 5366, // 11,12
- 10, 13, 6176, 10, 14, 4290, 11, 13, 49150, 11, 14, 5920, // 11,13
- 10, 14, 6886, 10, 15, 4734, 11, 14, 47458, 11, 15, 6458, // 11,14
- 10, 15, 7599, 10, 16, 5169, 11, 15, 45799, 11, 16, 6969, // 11,15
- 12, 0, 44901, 12, 1, 7374, 13, 0, 7848, 13, 1, 5413, // 12, 0
- 12, 1, 46427, 12, 2, 6908, 13, 1, 7191, 13, 2, 5010, // 12, 1
- 12, 2, 47953, 12, 3, 6426, 13, 2, 6549, 13, 3, 4608, // 12, 2
- 12, 3, 49445, 12, 4, 5943, 13, 3, 5934, 13, 4, 4214, // 12, 3
- 12, 4, 50844, 12, 5, 5481, 13, 4, 5365, 13, 5, 3846, // 12, 4
- 12, 5, 52069, 12, 6, 5073, 13, 5, 4872, 13, 6, 3522, // 12, 5
- 12, 6, 53012, 12, 7, 4762, 13, 6, 4489, 13, 7, 3273, // 12, 6
- 12, 7, 53562, 12, 8, 4594, 13, 7, 4254, 13, 8, 3126, // 12, 7
- 11, 8, 4259, 11, 9, 3128, 12, 8, 53557, 12, 9, 4592, // 12, 8
- 11, 9, 4495, 11, 10, 3274, 12, 9, 53008, 12, 10, 4759, // 12, 9
- 11, 10, 4879, 11, 11, 3523, 12, 10, 52066, 12, 11, 5068, // 12,10
- 11, 11, 5373, 11, 12, 3846, 12, 11, 50843, 12, 12, 5474, // 12,11
- 11, 12, 5943, 11, 13, 4214, 12, 12, 49445, 12, 13, 5934, // 12,12
- 11, 13, 6560, 11, 14, 4607, 12, 13, 47955, 12, 14, 6414, // 12,13
- 11, 14, 7204, 11, 15, 5009, 12, 14, 46430, 12, 15, 6893, // 12,14
- 11, 15, 7863, 11, 16, 5410, 12, 15, 44907, 12, 16, 7356, // 12,15
- 13, 0, 43900, 13, 1, 7812, 14, 0, 8141, 14, 1, 5683, // 13, 0
- 13, 1, 45286, 13, 2, 7395, 14, 1, 7539, 14, 2, 5316, // 13, 1
- 13, 2, 46650, 13, 3, 6973, 14, 2, 6959, 14, 3, 4954, // 13, 2
- 13, 3, 47955, 13, 4, 6560, 14, 3, 6414, 14, 4, 4607, // 13, 3
- 13, 4, 49150, 13, 5, 6176, 14, 4, 5920, 14, 5, 4290, // 13, 4
- 13, 5, 50171, 13, 6, 5848, 14, 5, 5499, 14, 6, 4018, // 13, 5
- 13, 6, 50942, 13, 7, 5606, 14, 6, 5175, 14, 7, 3813, // 13, 6
- 13, 7, 51395, 13, 8, 5480, 14, 7, 4970, 14, 8, 3691, // 13, 7
- 12, 8, 4978, 12, 9, 3693, 13, 8, 51387, 13, 9, 5478, // 13, 8
- 12, 9, 5184, 12, 10, 3815, 13, 9, 50935, 13, 10, 5602, // 13, 9
- 12, 10, 5508, 12, 11, 4020, 13, 10, 50165, 13, 11, 5843, // 13,10
- 12, 11, 5930, 12, 12, 4291, 13, 11, 49147, 13, 12, 6168, // 13,11
- 12, 12, 6426, 12, 13, 4608, 13, 12, 47953, 13, 13, 6549, // 13,12
- 12, 13, 6973, 12, 14, 4954, 13, 13, 46650, 13, 14, 6959, // 13,13
- 12, 14, 7555, 12, 15, 5315, 13, 14, 45288, 13, 15, 7378, // 13,14
- 12, 15, 8159, 12, 16, 5682, 13, 15, 43904, 13, 16, 7791, // 13,15
- 14, 0, 42821, 14, 1, 8288, 15, 0, 8452, 15, 1, 5975, // 14, 0
- 14, 1, 44074, 14, 2, 7921, 15, 1, 7901, 15, 2, 5640, // 14, 1
- 14, 2, 45288, 14, 3, 7555, 15, 2, 7378, 15, 3, 5315, // 14, 2
- 14, 3, 46430, 14, 4, 7204, 15, 3, 6892, 15, 4, 5010, // 14, 3
- 14, 4, 47458, 14, 5, 6886, 15, 4, 6458, 15, 5, 4734, // 14, 4
- 14, 5, 48322, 14, 6, 6620, 15, 5, 6092, 15, 6, 4502, // 14, 5
- 14, 6, 48969, 14, 7, 6430, 15, 6, 5809, 15, 7, 4328, // 14, 6
- 14, 7, 49358, 14, 8, 6335, 15, 7, 5623, 15, 8, 4220, // 14, 7
- 13, 8, 5633, 13, 9, 4224, 14, 8, 49347, 14, 9, 6332, // 14, 8
- 13, 9, 5820, 13, 10, 4330, 14, 9, 48960, 14, 10, 6426, // 14, 9
- 13, 10, 6104, 13, 11, 4505, 14, 10, 48314, 14, 11, 6613, // 14,10
- 13, 11, 6472, 13, 12, 4736, 14, 11, 47453, 14, 12, 6875, // 14,11
- 13, 12, 6908, 13, 13, 5011, 14, 12, 46427, 14, 13, 7190, // 14,12
- 13, 13, 7395, 13, 14, 5316, 14, 13, 45286, 14, 14, 7539, // 14,13
- 13, 14, 7921, 13, 15, 5640, 14, 14, 44074, 14, 15, 7901, // 14,14
- 13, 15, 8474, 13, 16, 5974, 14, 15, 42823, 14, 16, 8265, // 14,15
- 15, 0, 41693, 15, 1, 8795, 16, 0, 8769, 16, 1, 6279, // 15, 0
- 15, 1, 42823, 15, 2, 8474, 16, 1, 8265, 16, 2, 5974, // 15, 1
- 15, 2, 43904, 15, 3, 8159, 16, 2, 7791, 16, 3, 5682, // 15, 2
- 15, 3, 44907, 15, 4, 7863, 16, 3, 7356, 16, 4, 5410, // 15, 3
- 15, 4, 45799, 15, 5, 7599, 16, 4, 6970, 16, 5, 5168, // 15, 4
- 15, 5, 46541, 15, 6, 7383, 16, 5, 6644, 16, 6, 4968, // 15, 5
- 15, 6, 47098, 15, 7, 7233, 16, 6, 6391, 16, 7, 4814, // 15, 6
- 15, 7, 47440, 15, 8, 7161, 16, 7, 6217, 16, 8, 4718, // 15, 7
- 14, 8, 6230, 14, 9, 4722, 15, 8, 47426, 15, 9, 7158, // 15, 8
- 14, 9, 6405, 14, 10, 4818, 15, 9, 47086, 15, 10, 7227, // 15, 9
- 14, 10, 6659, 14, 11, 4971, 15, 10, 46532, 15, 11, 7374, // 15,10
- 14, 11, 6986, 14, 12, 5172, 15, 11, 45791, 15, 12, 7587, // 15,11
- 14, 12, 7374, 14, 13, 5413, 15, 12, 44901, 15, 13, 7848, // 15,12
- 14, 13, 7812, 14, 14, 5684, 15, 13, 43900, 15, 14, 8140, // 15,13
- 14, 14, 8288, 14, 15, 5975, 15, 14, 42821, 15, 15, 8452, // 15,14
- 14, 15, 8795, 14, 16, 6280, 15, 15, 41693, 15, 16, 8768, // 15,15
- // angle of 1.5 degrees
- 0, -1, 11440, 0, 0, 34212, 1, -1, 8358, 1, 0, 11526, // 0, 0
- 0, 0, 11192, 0, 1, 35502, 1, 0, 7987, 1, 1, 10855, // 0, 1
- 0, 1, 10930, 0, 2, 36756, 1, 1, 7626, 1, 2, 10224, // 0, 2
- 0, 2, 10670, 0, 3, 37939, 1, 2, 7285, 1, 3, 9642, // 0, 3
- 0, 3, 10430, 0, 4, 39009, 1, 3, 6975, 1, 4, 9122, // 0, 4
- 0, 4, 10232, 0, 5, 39918, 1, 4, 6710, 1, 5, 8676, // 0, 5
- 0, 5, 10100, 0, 6, 40618, 1, 5, 6502, 1, 6, 8316, // 0, 6
- 0, 6, 10052, 0, 7, 41072, 1, 6, 6360, 1, 7, 8052, // 0, 7
- -1, 7, 6346, -1, 8, 8018, 0, 7, 10066, 0, 8, 41106, // 0, 8
- -1, 8, 6489, -1, 9, 8278, 0, 8, 10123, 0, 9, 40646, // 0, 9
- -1, 9, 6699, -1, 10, 8632, 0, 9, 10265, 0, 10, 39940, // 0,10
- -1, 10, 6965, -1, 11, 9072, 0, 10, 10473, 0, 11, 39026, // 0,11
- -1, 11, 7276, -1, 12, 9585, 0, 11, 10723, 0, 12, 37952, // 0,12
- -1, 12, 7620, -1, 13, 10158, 0, 12, 10994, 0, 13, 36764, // 0,13
- -1, 13, 7983, -1, 14, 10780, 0, 13, 11267, 0, 14, 35506, // 0,14
- -1, 14, 8358, -1, 15, 11440, 0, 14, 11526, 0, 15, 34212, // 0,15
- 1, -1, 10780, 1, 0, 35506, 2, -1, 7983, 2, 0, 11267, // 1, 0
- 1, 0, 10467, 1, 1, 36959, 2, 0, 7579, 2, 1, 10531, // 1, 1
- 1, 1, 10133, 1, 2, 38390, 2, 1, 7179, 2, 2, 9834, // 1, 2
- 1, 2, 9796, 1, 3, 39759, 2, 2, 6797, 2, 3, 9184, // 1, 3
- 1, 3, 9478, 1, 4, 41013, 2, 3, 6447, 2, 4, 8598, // 1, 4
- 1, 4, 9206, 1, 5, 42087, 2, 4, 6145, 2, 5, 8098, // 1, 5
- 1, 5, 9014, 1, 6, 42913, 2, 5, 5910, 2, 6, 7699, // 1, 6
- 1, 6, 8929, 1, 7, 43433, 2, 6, 5756, 2, 7, 7418, // 1, 7
- 0, 7, 5745, 0, 8, 7390, 1, 7, 8939, 1, 8, 43462, // 1, 8
- 0, 8, 5900, 0, 9, 7667, 1, 8, 9032, 1, 9, 42937, // 1, 9
- 0, 9, 6137, 0, 10, 8061, 1, 9, 9233, 1, 10, 42105, // 1,10
- 0, 10, 6440, 0, 11, 8557, 1, 10, 9513, 1, 11, 41026, // 1,11
- 0, 11, 6792, 0, 12, 9135, 1, 11, 9841, 1, 12, 39768, // 1,12
- 0, 12, 7177, 0, 13, 9777, 1, 12, 10188, 1, 13, 38394, // 1,13
- 0, 13, 7579, 0, 14, 10467, 1, 13, 10532, 1, 14, 36958, // 1,14
- 0, 14, 7987, 0, 15, 11192, 1, 14, 10855, 1, 15, 35502, // 1,15
- 2, -1, 10158, 2, 0, 36764, 3, -1, 7620, 3, 0, 10994, // 2, 0
- 2, 0, 9777, 2, 1, 38394, 3, 0, 7177, 3, 1, 10188, // 2, 1
- 2, 1, 9366, 2, 2, 40025, 3, 1, 6732, 3, 2, 9413, // 2, 2
- 2, 2, 8941, 2, 3, 41614, 3, 2, 6299, 3, 3, 8682, // 2, 3
- 2, 3, 8530, 2, 4, 43096, 3, 3, 5895, 3, 4, 8015, // 2, 4
- 2, 4, 8167, 2, 5, 44386, 3, 4, 5543, 3, 5, 7440, // 2, 5
- 2, 5, 7899, 2, 6, 45383, 3, 5, 5268, 3, 6, 6986, // 2, 6
- 2, 6, 7766, 2, 7, 45995, 3, 6, 5095, 3, 7, 6680, // 2, 7
- 1, 7, 5087, 1, 8, 6658, 2, 7, 7773, 2, 8, 46018, // 2, 8
- 1, 8, 5261, 1, 9, 6961, 2, 8, 7913, 2, 9, 45401, // 2, 9
- 1, 9, 5537, 1, 10, 7411, 2, 9, 8189, 2, 10, 44399, // 2,10
- 1, 10, 5891, 1, 11, 7981, 2, 10, 8559, 2, 11, 43105, // 2,11
- 1, 11, 6297, 1, 12, 8641, 2, 11, 8979, 2, 12, 41619, // 2,12
- 1, 12, 6732, 1, 13, 9366, 2, 12, 9413, 2, 13, 40025, // 2,13
- 1, 13, 7179, 1, 14, 10133, 2, 13, 9834, 2, 14, 38390, // 2,14
- 1, 14, 7626, 1, 15, 10930, 2, 14, 10224, 2, 15, 36756, // 2,15
- 3, -1, 9585, 3, 0, 37951, 4, -1, 7276, 4, 0, 10724, // 3, 0
- 3, 0, 9135, 3, 1, 39767, 4, 0, 6792, 4, 1, 9842, // 3, 1
- 3, 1, 8641, 3, 2, 41618, 4, 1, 6297, 4, 2, 8980, // 3, 2
- 3, 2, 8120, 3, 3, 43461, 4, 2, 5804, 4, 3, 8151, // 3, 3
- 3, 3, 7598, 3, 4, 45224, 4, 3, 5331, 4, 4, 7383, // 3, 4
- 3, 4, 7121, 3, 5, 46798, 4, 4, 4909, 4, 5, 6708, // 3, 5
- 3, 5, 6750, 3, 6, 48037, 4, 5, 4576, 4, 6, 6173, // 3, 6
- 3, 6, 6552, 3, 7, 48785, 4, 6, 4372, 4, 7, 5827, // 3, 7
- 2, 7, 4366, 2, 8, 5811, 3, 7, 6558, 3, 8, 48801, // 3, 8
- 2, 8, 4572, 2, 9, 6154, 3, 8, 6761, 3, 9, 48049, // 3, 9
- 2, 9, 4906, 2, 10, 6685, 3, 9, 7138, 3, 10, 46807, // 3,10
- 2, 10, 5330, 2, 11, 7356, 3, 10, 7622, 3, 11, 45228, // 3,11
- 2, 11, 5804, 2, 12, 8120, 3, 11, 8151, 3, 12, 43461, // 3,12
- 2, 12, 6299, 2, 13, 8941, 3, 12, 8681, 3, 13, 41615, // 3,13
- 2, 13, 6797, 2, 14, 9796, 3, 13, 9184, 3, 14, 39759, // 3,14
- 2, 14, 7285, 2, 15, 10670, 3, 14, 9642, 3, 15, 37939, // 3,15
- 4, -1, 9072, 4, 0, 39026, 5, -1, 6965, 5, 0, 10473, // 4, 0
- 4, 0, 8557, 4, 1, 41026, 5, 0, 6440, 5, 1, 9513, // 4, 1
- 4, 1, 7981, 4, 2, 43105, 5, 1, 5891, 5, 2, 8559, // 4, 2
- 4, 2, 7356, 4, 3, 45229, 5, 2, 5330, 5, 3, 7621, // 4, 3
- 4, 3, 6708, 4, 4, 47328, 5, 3, 4774, 5, 4, 6726, // 4, 4
- 4, 4, 6086, 4, 5, 49275, 5, 4, 4258, 5, 5, 5917, // 4, 5
- 4, 5, 5573, 4, 6, 50865, 5, 5, 3837, 5, 6, 5261, // 4, 6
- 4, 6, 5280, 4, 7, 51832, 5, 6, 3579, 5, 7, 4845, // 4, 7
- 3, 7, 3575, 3, 8, 4835, 4, 7, 5283, 4, 8, 51843, // 4, 8
- 3, 8, 3834, 3, 9, 5248, 4, 8, 5581, 4, 9, 50873, // 4, 9
- 3, 9, 4257, 3, 10, 5901, 4, 9, 6099, 4, 10, 49279, // 4,10
- 3, 10, 4774, 3, 11, 6708, 4, 10, 6727, 4, 11, 47327, // 4,11
- 3, 11, 5331, 3, 12, 7598, 4, 11, 7382, 4, 12, 45225, // 4,12
- 3, 12, 5895, 3, 13, 8530, 4, 12, 8015, 4, 13, 43096, // 4,13
- 3, 13, 6447, 3, 14, 9478, 4, 13, 8599, 4, 14, 41012, // 4,14
- 3, 14, 6975, 3, 15, 10430, 4, 14, 9122, 4, 15, 39009, // 4,15
- 5, -1, 8632, 5, 0, 39940, 6, -1, 6699, 6, 0, 10265, // 5, 0
- 5, 0, 8061, 5, 1, 42105, 6, 0, 6137, 6, 1, 9233, // 5, 1
- 5, 1, 7411, 5, 2, 44399, 6, 1, 5537, 6, 2, 8189, // 5, 2
- 5, 2, 6685, 5, 3, 46806, 6, 2, 4906, 6, 3, 7139, // 5, 3
- 5, 3, 5901, 5, 4, 49279, 6, 3, 4257, 6, 4, 6099, // 5, 4
- 5, 4, 5103, 5, 5, 51700, 6, 4, 3621, 6, 5, 5112, // 5, 5
- 5, 5, 4388, 5, 6, 53813, 6, 5, 3065, 6, 6, 4270, // 5, 6
- 5, 6, 3938, 5, 7, 55162, 6, 6, 2710, 6, 7, 3726, // 5, 7
- 4, 7, 2708, 4, 8, 3720, 5, 7, 3940, 5, 8, 55168, // 5, 8
- 4, 8, 3064, 4, 9, 4262, 5, 8, 4394, 5, 9, 53816, // 5, 9
- 4, 9, 3621, 4, 10, 5103, 5, 9, 5113, 5, 10, 51699, // 5,10
- 4, 10, 4258, 4, 11, 6086, 5, 10, 5917, 5, 11, 49275, // 5,11
- 4, 11, 4909, 4, 12, 7121, 5, 11, 6707, 5, 12, 46799, // 5,12
- 4, 12, 5543, 4, 13, 8167, 5, 12, 7440, 5, 13, 44386, // 5,13
- 4, 13, 6145, 4, 14, 9206, 5, 13, 8098, 5, 14, 42087, // 5,14
- 4, 14, 6710, 4, 15, 10232, 5, 14, 8676, 5, 15, 39918, // 5,15
- 6, -1, 8278, 6, 0, 40646, 7, -1, 6489, 7, 0, 10123, // 6, 0
- 6, 0, 7667, 6, 1, 42936, 7, 0, 5900, 7, 1, 9033, // 6, 1
- 6, 1, 6961, 6, 2, 45401, 7, 1, 5261, 7, 2, 7913, // 6, 2
- 6, 2, 6154, 6, 3, 48049, 7, 2, 4572, 7, 3, 6761, // 6, 3
- 6, 3, 5248, 6, 4, 50873, 7, 3, 3834, 7, 4, 5581, // 6, 4
- 6, 4, 4262, 6, 5, 53816, 7, 4, 3064, 7, 5, 4394, // 6, 5
- 6, 5, 3271, 6, 6, 56673, 7, 5, 2316, 7, 6, 3276, // 6, 6
- 6, 6, 2532, 6, 7, 58773, 7, 6, 1767, 7, 7, 2464, // 6, 7
- 5, 7, 1766, 5, 8, 2462, 6, 7, 2533, 6, 8, 58775, // 6, 8
- 5, 8, 2316, 5, 9, 3271, 6, 8, 3275, 6, 9, 56674, // 6, 9
- 5, 9, 3065, 5, 10, 4388, 6, 9, 4269, 6, 10, 53814, // 6,10
- 5, 10, 3837, 5, 11, 5573, 6, 10, 5261, 6, 11, 50865, // 6,11
- 5, 11, 4576, 5, 12, 6750, 6, 11, 6173, 6, 12, 48037, // 6,12
- 5, 12, 5268, 5, 13, 7899, 6, 12, 6986, 6, 13, 45383, // 6,13
- 5, 13, 5910, 5, 14, 9014, 6, 13, 7699, 6, 14, 42913, // 6,14
- 5, 14, 6502, 5, 15, 10100, 6, 14, 8316, 6, 15, 40618, // 6,15
- 7, -1, 8018, 7, 0, 41106, 8, -1, 6346, 8, 0, 10066, // 7, 0
- 7, 0, 7390, 7, 1, 43461, 8, 0, 5745, 8, 1, 8940, // 7, 1
- 7, 1, 6658, 7, 2, 46017, 8, 1, 5087, 8, 2, 7774, // 7, 2
- 7, 2, 5811, 7, 3, 48801, 8, 2, 4366, 8, 3, 6558, // 7, 3
- 7, 3, 4835, 7, 4, 51842, 8, 3, 3575, 8, 4, 5284, // 7, 4
- 7, 4, 3720, 7, 5, 55168, 8, 4, 2708, 8, 5, 3940, // 7, 5
- 7, 5, 2462, 7, 6, 58775, 8, 5, 1766, 8, 6, 2533, // 7, 6
- 7, 6, 1170, 7, 7, 62369, 8, 6, 827, 8, 7, 1170, // 7, 7
- 6, 7, 827, 6, 8, 1170, 7, 7, 1170, 7, 8, 62369, // 7, 8
- 6, 8, 1767, 6, 9, 2532, 7, 8, 2464, 7, 9, 58773, // 7, 9
- 6, 9, 2710, 6, 10, 3938, 7, 9, 3726, 7, 10, 55162, // 7,10
- 6, 10, 3579, 6, 11, 5280, 7, 10, 4846, 7, 11, 51831, // 7,11
- 6, 11, 4372, 6, 12, 6552, 7, 11, 5827, 7, 12, 48785, // 7,12
- 6, 12, 5095, 6, 13, 7766, 7, 12, 6680, 7, 13, 45995, // 7,13
- 6, 13, 5756, 6, 14, 8929, 7, 13, 7418, 7, 14, 43433, // 7,14
- 6, 14, 6360, 6, 15, 10052, 7, 14, 8052, 7, 15, 41072, // 7,15
- 8, 0, 41072, 8, 1, 8052, 9, 0, 10052, 9, 1, 6360, // 8, 0
- 8, 1, 43433, 8, 2, 7418, 9, 1, 8929, 9, 2, 5756, // 8, 1
- 8, 2, 45995, 8, 3, 6680, 9, 2, 7766, 9, 3, 5095, // 8, 2
- 8, 3, 48785, 8, 4, 5827, 9, 3, 6552, 9, 4, 4372, // 8, 3
- 8, 4, 51832, 8, 5, 4846, 9, 4, 5280, 9, 5, 3578, // 8, 4
- 8, 5, 55162, 8, 6, 3726, 9, 5, 3938, 9, 6, 2710, // 8, 5
- 8, 6, 58773, 8, 7, 2464, 9, 6, 2532, 9, 7, 1767, // 8, 6
- 8, 7, 62369, 8, 8, 1170, 9, 7, 1170, 9, 8, 827, // 8, 7
- 7, 8, 1170, 7, 9, 827, 8, 8, 62369, 8, 9, 1170, // 8, 8
- 7, 9, 2533, 7, 10, 1766, 8, 9, 58775, 8, 10, 2462, // 8, 9
- 7, 10, 3940, 7, 11, 2708, 8, 10, 55168, 8, 11, 3720, // 8,10
- 7, 11, 5283, 7, 12, 3575, 8, 11, 51842, 8, 12, 4836, // 8,11
- 7, 12, 6558, 7, 13, 4366, 8, 12, 48801, 8, 13, 5811, // 8,12
- 7, 13, 7773, 7, 14, 5087, 8, 13, 46017, 8, 14, 6659, // 8,13
- 7, 14, 8939, 7, 15, 5745, 8, 14, 43461, 8, 15, 7391, // 8,14
- 7, 15, 10066, 7, 16, 6346, 8, 15, 41106, 8, 16, 8018, // 8,15
- 9, 0, 40618, 9, 1, 8316, 10, 0, 10100, 10, 1, 6502, // 9, 0
- 9, 1, 42913, 9, 2, 7699, 10, 1, 9014, 10, 2, 5910, // 9, 1
- 9, 2, 45383, 9, 3, 6986, 10, 2, 7899, 10, 3, 5268, // 9, 2
- 9, 3, 48037, 9, 4, 6173, 10, 3, 6750, 10, 4, 4576, // 9, 3
- 9, 4, 50865, 9, 5, 5261, 10, 4, 5573, 10, 5, 3837, // 9, 4
- 9, 5, 53813, 9, 6, 4269, 10, 5, 4388, 10, 6, 3066, // 9, 5
- 9, 6, 56673, 9, 7, 3275, 10, 6, 3271, 10, 7, 2317, // 9, 6
- 9, 7, 58775, 9, 8, 2533, 10, 7, 2462, 10, 8, 1766, // 9, 7
- 8, 8, 2464, 8, 9, 1767, 9, 8, 58773, 9, 9, 2532, // 9, 8
- 8, 9, 3275, 8, 10, 2316, 9, 9, 56673, 9, 10, 3272, // 9, 9
- 8, 10, 4394, 8, 11, 3064, 9, 10, 53816, 9, 11, 4262, // 9,10
- 8, 11, 5581, 8, 12, 3834, 9, 11, 50873, 9, 12, 5248, // 9,11
- 8, 12, 6761, 8, 13, 4572, 9, 12, 48049, 9, 13, 6154, // 9,12
- 8, 13, 7913, 8, 14, 5261, 9, 13, 45401, 9, 14, 6961, // 9,13
- 8, 14, 9032, 8, 15, 5900, 9, 14, 42936, 9, 15, 7668, // 9,14
- 8, 15, 10123, 8, 16, 6489, 9, 15, 40646, 9, 16, 8278, // 9,15
- 10, 0, 39918, 10, 1, 8676, 11, 0, 10232, 11, 1, 6710, // 10, 0
- 10, 1, 42087, 10, 2, 8098, 11, 1, 9206, 11, 2, 6145, // 10, 1
- 10, 2, 44386, 10, 3, 7440, 11, 2, 8167, 11, 3, 5543, // 10, 2
- 10, 3, 46798, 10, 4, 6707, 11, 3, 7121, 11, 4, 4910, // 10, 3
- 10, 4, 49275, 10, 5, 5917, 11, 4, 6086, 11, 5, 4258, // 10, 4
- 10, 5, 51700, 10, 6, 5113, 11, 5, 5103, 11, 6, 3620, // 10, 5
- 10, 6, 53816, 10, 7, 4394, 11, 6, 4262, 11, 7, 3064, // 10, 6
- 10, 7, 55168, 10, 8, 3940, 11, 7, 3720, 11, 8, 2708, // 10, 7
- 9, 8, 3726, 9, 9, 2710, 10, 8, 55162, 10, 9, 3938, // 10, 8
- 9, 9, 4269, 9, 10, 3065, 10, 9, 53813, 10, 10, 4389, // 10, 9
- 9, 10, 5113, 9, 11, 3621, 10, 10, 51700, 10, 11, 5102, // 10,10
- 9, 11, 6099, 9, 12, 4257, 10, 11, 49279, 10, 12, 5901, // 10,11
- 9, 12, 7138, 9, 13, 4906, 10, 12, 46806, 10, 13, 6686, // 10,12
- 9, 13, 8189, 9, 14, 5537, 10, 13, 44399, 10, 14, 7411, // 10,13
- 9, 14, 9233, 9, 15, 6137, 10, 14, 42105, 10, 15, 8061, // 10,14
- 9, 15, 10265, 9, 16, 6699, 10, 15, 39940, 10, 16, 8632, // 10,15
- 11, 0, 39009, 11, 1, 9122, 12, 0, 10430, 12, 1, 6975, // 11, 0
- 11, 1, 41013, 11, 2, 8599, 12, 1, 9478, 12, 2, 6446, // 11, 1
- 11, 2, 43096, 11, 3, 8015, 12, 2, 8530, 12, 3, 5895, // 11, 2
- 11, 3, 45224, 11, 4, 7382, 12, 3, 7598, 12, 4, 5332, // 11, 3
- 11, 4, 47328, 11, 5, 6727, 12, 4, 6708, 12, 5, 4773, // 11, 4
- 11, 5, 49279, 11, 6, 6099, 12, 5, 5901, 12, 6, 4257, // 11, 5
- 11, 6, 50873, 11, 7, 5581, 12, 6, 5248, 12, 7, 3834, // 11, 6
- 11, 7, 51842, 11, 8, 5283, 12, 7, 4835, 12, 8, 3576, // 11, 7
- 10, 8, 4846, 10, 9, 3579, 11, 8, 51832, 11, 9, 5279, // 11, 8
- 10, 9, 5261, 10, 10, 3837, 11, 9, 50865, 11, 10, 5573, // 11, 9
- 10, 10, 5917, 10, 11, 4258, 11, 10, 49275, 11, 11, 6086, // 11,10
- 10, 11, 6727, 10, 12, 4774, 11, 11, 47328, 11, 12, 6707, // 11,11
- 10, 12, 7622, 10, 13, 5330, 11, 12, 45229, 11, 13, 7355, // 11,12
- 10, 13, 8559, 10, 14, 5891, 11, 13, 43105, 11, 14, 7981, // 11,13
- 10, 14, 9513, 10, 15, 6440, 11, 14, 41026, 11, 15, 8557, // 11,14
- 10, 15, 10473, 10, 16, 6965, 11, 15, 39026, 11, 16, 9072, // 11,15
- 12, 0, 37939, 12, 1, 9642, 13, 0, 10670, 13, 1, 7285, // 12, 0
- 12, 1, 39759, 12, 2, 9184, 13, 1, 9796, 13, 2, 6797, // 12, 1
- 12, 2, 41614, 12, 3, 8681, 13, 2, 8941, 13, 3, 6300, // 12, 2
- 12, 3, 43461, 12, 4, 8151, 13, 3, 8120, 13, 4, 5804, // 12, 3
- 12, 4, 45229, 12, 5, 7622, 13, 4, 7356, 13, 5, 5329, // 12, 4
- 12, 5, 46806, 12, 6, 7138, 13, 5, 6685, 13, 6, 4907, // 12, 5
- 12, 6, 48049, 12, 7, 6761, 13, 6, 6154, 13, 7, 4572, // 12, 6
- 12, 7, 48801, 12, 8, 6558, 13, 7, 5811, 13, 8, 4366, // 12, 7
- 11, 8, 5827, 11, 9, 4372, 12, 8, 48785, 12, 9, 6552, // 12, 8
- 11, 9, 6173, 11, 10, 4576, 12, 9, 48037, 12, 10, 6750, // 12, 9
- 11, 10, 6707, 11, 11, 4909, 12, 10, 46798, 12, 11, 7122, // 12,10
- 11, 11, 7382, 11, 12, 5331, 12, 11, 45224, 12, 12, 7599, // 12,11
- 11, 12, 8151, 11, 13, 5804, 12, 12, 43461, 12, 13, 8120, // 12,12
- 11, 13, 8979, 11, 14, 6297, 12, 13, 41618, 12, 14, 8642, // 12,13
- 11, 14, 9841, 11, 15, 6792, 12, 14, 39767, 12, 15, 9136, // 12,14
- 11, 15, 10723, 11, 16, 7276, 12, 15, 37951, 12, 16, 9586, // 12,15
- 13, 0, 36756, 13, 1, 10224, 14, 0, 10930, 14, 1, 7626, // 13, 0
- 13, 1, 38390, 13, 2, 9834, 14, 1, 10133, 14, 2, 7179, // 13, 1
- 13, 2, 40025, 13, 3, 9413, 14, 2, 9366, 14, 3, 6732, // 13, 2
- 13, 3, 41618, 13, 4, 8979, 14, 3, 8641, 14, 4, 6298, // 13, 3
- 13, 4, 43105, 13, 5, 8559, 14, 4, 7981, 14, 5, 5891, // 13, 4
- 13, 5, 44399, 13, 6, 8189, 14, 5, 7411, 14, 6, 5537, // 13, 5
- 13, 6, 45401, 13, 7, 7913, 14, 6, 6961, 14, 7, 5261, // 13, 6
- 13, 7, 46017, 13, 8, 7773, 14, 7, 6658, 14, 8, 5088, // 13, 7
- 12, 8, 6680, 12, 9, 5095, 13, 8, 45995, 13, 9, 7766, // 13, 8
- 12, 9, 6986, 12, 10, 5268, 13, 9, 45383, 13, 10, 7899, // 13, 9
- 12, 10, 7440, 12, 11, 5543, 13, 10, 44386, 13, 11, 8167, // 13,10
- 12, 11, 8015, 12, 12, 5895, 13, 11, 43096, 13, 12, 8530, // 13,11
- 12, 12, 8681, 12, 13, 6299, 13, 12, 41614, 13, 13, 8942, // 13,12
- 12, 13, 9413, 12, 14, 6732, 13, 13, 40025, 13, 14, 9366, // 13,13
- 12, 14, 10188, 12, 15, 7177, 13, 14, 38394, 13, 15, 9777, // 13,14
- 12, 15, 10994, 12, 16, 7620, 13, 15, 36764, 13, 16, 10158, // 13,15
- 14, 0, 35502, 14, 1, 10855, 15, 0, 11192, 15, 1, 7987, // 14, 0
- 14, 1, 36959, 14, 2, 10532, 15, 1, 10467, 15, 2, 7578, // 14, 1
- 14, 2, 38394, 14, 3, 10188, 15, 2, 9777, 15, 3, 7177, // 14, 2
- 14, 3, 39767, 14, 4, 9841, 15, 3, 9135, 15, 4, 6793, // 14, 3
- 14, 4, 41026, 14, 5, 9513, 15, 4, 8557, 15, 5, 6440, // 14, 4
- 14, 5, 42105, 14, 6, 9233, 15, 5, 8061, 15, 6, 6137, // 14, 5
- 14, 6, 42936, 14, 7, 9032, 15, 6, 7667, 15, 7, 5901, // 14, 6
- 14, 7, 43461, 14, 8, 8939, 15, 7, 7390, 15, 8, 5746, // 14, 7
- 13, 8, 7418, 13, 9, 5756, 14, 8, 43433, 14, 9, 8929, // 14, 8
- 13, 9, 7699, 13, 10, 5910, 14, 9, 42913, 14, 10, 9014, // 14, 9
- 13, 10, 8098, 13, 11, 6145, 14, 10, 42087, 14, 11, 9206, // 14,10
- 13, 11, 8599, 13, 12, 6447, 14, 11, 41013, 14, 12, 9477, // 14,11
- 13, 12, 9184, 13, 13, 6797, 14, 12, 39759, 14, 13, 9796, // 14,12
- 13, 13, 9834, 13, 14, 7179, 14, 13, 38390, 14, 14, 10133, // 14,13
- 13, 14, 10532, 13, 15, 7579, 14, 14, 36959, 14, 15, 10466, // 14,14
- 13, 15, 11267, 13, 16, 7983, 14, 15, 35506, 14, 16, 10780, // 14,15
- 15, 0, 34212, 15, 1, 11526, 16, 0, 11440, 16, 1, 8358, // 15, 0
- 15, 1, 35506, 15, 2, 11267, 16, 1, 10780, 16, 2, 7983, // 15, 1
- 15, 2, 36764, 15, 3, 10994, 16, 2, 10158, 16, 3, 7620, // 15, 2
- 15, 3, 37951, 15, 4, 10723, 16, 3, 9585, 16, 4, 7277, // 15, 3
- 15, 4, 39026, 15, 5, 10473, 16, 4, 9072, 16, 5, 6965, // 15, 4
- 15, 5, 39940, 15, 6, 10265, 16, 5, 8632, 16, 6, 6699, // 15, 5
- 15, 6, 40646, 15, 7, 10123, 16, 6, 8278, 16, 7, 6489, // 15, 6
- 15, 7, 41106, 15, 8, 10066, 16, 7, 8018, 16, 8, 6346, // 15, 7
- 14, 8, 8052, 14, 9, 6360, 15, 8, 41072, 15, 9, 10052, // 15, 8
- 14, 9, 8316, 14, 10, 6502, 15, 9, 40618, 15, 10, 10100, // 15, 9
- 14, 10, 8676, 14, 11, 6710, 15, 10, 39918, 15, 11, 10232, // 15,10
- 14, 11, 9122, 14, 12, 6975, 15, 11, 39009, 15, 12, 10430, // 15,11
- 14, 12, 9642, 14, 13, 7285, 15, 12, 37939, 15, 13, 10670, // 15,12
- 14, 13, 10224, 14, 14, 7626, 15, 13, 36756, 15, 14, 10930, // 15,13
- 14, 14, 10855, 14, 15, 7987, 15, 14, 35502, 15, 15, 11192, // 15,14
- 14, 15, 11526, 14, 16, 8358, 15, 15, 34212, 15, 16, 11440, // 15,15
- // angle of 2.0 degrees
- 0, -1, 13368, 0, 0, 28495, 1, -1, 10104, 1, 0, 13569, // 0, 0
- 0, 0, 13291, 0, 1, 29828, 1, 0, 9671, 1, 1, 12746, // 0, 1
- 0, 1, 13176, 0, 2, 31138, 1, 1, 9245, 1, 2, 11977, // 0, 2
- 0, 2, 13038, 0, 3, 32391, 1, 2, 8838, 1, 3, 11269, // 0, 3
- 0, 3, 12899, 0, 4, 33539, 1, 3, 8463, 1, 4, 10635, // 0, 4
- 0, 4, 12783, 0, 5, 34532, 1, 4, 8135, 1, 5, 10086, // 0, 5
- 0, 5, 12717, 0, 6, 35315, 1, 5, 7868, 1, 6, 9636, // 0, 6
- 0, 6, 12728, 0, 7, 35844, 1, 6, 7674, 1, 7, 9290, // 0, 7
- -1, 7, 7643, -1, 8, 9224, 0, 7, 12764, 0, 8, 35905, // 0, 8
- -1, 8, 7839, -1, 9, 9558, 0, 8, 12777, 0, 9, 35362, // 0, 9
- -1, 9, 8107, -1, 10, 9995, 0, 9, 12867, 0, 10, 34567, // 0,10
- -1, 10, 8438, -1, 11, 10528, 0, 10, 13007, 0, 11, 33563, // 0,11
- -1, 11, 8816, -1, 12, 11143, 0, 11, 13171, 0, 12, 32406, // 0,12
- -1, 12, 9229, -1, 13, 11829, 0, 12, 13332, 0, 13, 31146, // 0,13
- -1, 13, 9662, -1, 14, 12574, 0, 13, 13470, 0, 14, 29830, // 0,14
- -1, 14, 10104, -1, 15, 13368, 0, 14, 13569, 0, 15, 28495, // 0,15
- 1, -1, 12574, 1, 0, 29831, 2, -1, 9662, 2, 0, 13469, // 1, 0
- 1, 0, 12412, 1, 1, 31358, 2, 0, 9202, 2, 1, 12564, // 1, 1
- 1, 1, 12203, 1, 2, 32881, 2, 1, 8742, 2, 2, 11710, // 1, 2
- 1, 2, 11964, 1, 3, 34358, 2, 2, 8296, 2, 3, 10918, // 1, 3
- 1, 3, 11721, 1, 4, 35730, 2, 3, 7881, 2, 4, 10204, // 1, 4
- 1, 4, 11507, 1, 5, 36926, 2, 4, 7517, 2, 5, 9586, // 1, 5
- 1, 5, 11360, 1, 6, 37866, 2, 5, 7224, 2, 6, 9086, // 1, 6
- 1, 6, 11317, 1, 7, 38481, 2, 6, 7020, 2, 7, 8718, // 1, 7
- 0, 7, 6997, 0, 8, 8662, 1, 7, 11344, 1, 8, 38533, // 1, 8
- 0, 8, 7202, 0, 9, 9020, 1, 8, 11407, 1, 9, 37907, // 1, 9
- 0, 9, 7497, 0, 10, 9509, 1, 9, 11575, 1, 10, 36955, // 1,10
- 0, 10, 7865, 0, 11, 10111, 1, 10, 11810, 1, 11, 35750, // 1,11
- 0, 11, 8284, 0, 12, 10808, 1, 11, 12074, 1, 12, 34370, // 1,12
- 0, 12, 8735, 0, 13, 11580, 1, 12, 12334, 1, 13, 32887, // 1,13
- 0, 13, 9202, 0, 14, 12412, 1, 13, 12564, 1, 14, 31358, // 1,14
- 0, 14, 9671, 0, 15, 13291, 1, 14, 12746, 1, 15, 29828, // 1,15
- 2, -1, 11829, 2, 0, 31146, 3, -1, 9229, 3, 0, 13332, // 2, 0
- 2, 0, 11580, 2, 1, 32886, 3, 0, 8735, 3, 1, 12335, // 2, 1
- 2, 1, 11272, 2, 2, 34650, 3, 1, 8232, 3, 2, 11382, // 2, 2
- 2, 2, 10922, 2, 3, 36392, 3, 2, 7734, 3, 3, 10488, // 2, 3
- 2, 3, 10559, 2, 4, 38042, 3, 3, 7261, 3, 4, 9674, // 2, 4
- 2, 4, 10226, 2, 5, 39503, 3, 4, 6842, 3, 5, 8965, // 2, 5
- 2, 5, 9977, 2, 6, 40656, 3, 5, 6506, 3, 6, 8397, // 2, 6
- 2, 6, 9867, 2, 7, 41389, 3, 6, 6284, 3, 7, 7996, // 2, 7
- 1, 7, 6266, 1, 8, 7951, 2, 7, 9886, 2, 8, 41433, // 2, 8
- 1, 8, 6491, 1, 9, 8344, 2, 8, 10013, 2, 9, 40688, // 2, 9
- 1, 9, 6829, 1, 10, 8902, 2, 9, 10279, 2, 10, 39526, // 2,10
- 1, 10, 7252, 1, 11, 9597, 2, 10, 10630, 2, 11, 38057, // 2,11
- 1, 11, 7728, 1, 12, 10397, 2, 11, 11012, 2, 12, 36399, // 2,12
- 1, 12, 8232, 1, 13, 11272, 2, 12, 11382, 2, 13, 34650, // 2,13
- 1, 13, 8742, 1, 14, 12203, 2, 13, 11709, 2, 14, 32882, // 2,14
- 1, 14, 9245, 1, 15, 13176, 2, 14, 11977, 2, 15, 31138, // 2,15
- 3, -1, 11143, 3, 0, 32406, 4, -1, 8816, 4, 0, 13171, // 3, 0
- 3, 0, 10808, 3, 1, 34369, 4, 0, 8284, 4, 1, 12075, // 3, 1
- 3, 1, 10397, 3, 2, 36399, 4, 1, 7728, 4, 2, 11012, // 3, 2
- 3, 2, 9924, 3, 3, 38450, 4, 2, 7164, 4, 3, 9998, // 3, 3
- 3, 3, 9421, 3, 4, 40444, 4, 3, 6615, 4, 4, 9056, // 3, 4
- 3, 4, 8940, 3, 5, 42256, 4, 4, 6116, 4, 5, 8224, // 3, 5
- 3, 5, 8558, 3, 6, 43710, 4, 5, 5712, 4, 6, 7556, // 3, 6
- 3, 6, 8359, 3, 7, 44616, 4, 6, 5454, 4, 7, 7107, // 3, 7
- 2, 7, 5443, 2, 8, 7072, 3, 7, 8373, 3, 8, 44648, // 3, 8
- 2, 8, 5703, 2, 9, 7516, 3, 8, 8584, 3, 9, 43733, // 3, 9
- 2, 9, 6108, 2, 10, 8175, 3, 9, 8982, 3, 10, 42271, // 3,10
- 2, 10, 6611, 2, 11, 8995, 3, 10, 9478, 3, 11, 40452, // 3,11
- 2, 11, 7164, 2, 12, 9924, 3, 11, 9998, 3, 12, 38450, // 3,12
- 2, 12, 7734, 2, 13, 10922, 3, 12, 10488, 3, 13, 36392, // 3,13
- 2, 13, 8296, 2, 14, 11964, 3, 13, 10918, 3, 14, 34358, // 3,14
- 2, 14, 8838, 2, 15, 13038, 3, 14, 11269, 3, 15, 32391, // 3,15
- 4, -1, 10528, 4, 0, 33564, 5, -1, 8438, 5, 0, 13006, // 4, 0
- 4, 0, 10111, 4, 1, 35750, 5, 0, 7865, 5, 1, 11810, // 4, 1
- 4, 1, 9597, 4, 2, 38057, 5, 1, 7252, 5, 2, 10630, // 4, 2
- 4, 2, 8995, 4, 3, 40452, 5, 2, 6611, 5, 3, 9478, // 4, 3
- 4, 3, 8332, 4, 4, 42861, 5, 3, 5965, 5, 4, 8378, // 4, 4
- 4, 4, 7667, 4, 5, 45139, 5, 4, 5353, 5, 5, 7377, // 4, 5
- 4, 5, 7100, 4, 6, 47035, 5, 5, 4843, 5, 6, 6558, // 4, 6
- 4, 6, 6774, 4, 7, 48218, 5, 6, 4521, 5, 7, 6023, // 4, 7
- 3, 7, 4513, 3, 8, 6000, 4, 7, 6783, 4, 8, 48240, // 4, 8
- 3, 8, 4838, 3, 9, 6530, 4, 8, 7119, 4, 9, 47049, // 4, 9
- 3, 9, 5350, 3, 10, 7342, 4, 9, 7698, 4, 10, 45146, // 4,10
- 3, 10, 5965, 3, 11, 8332, 4, 10, 8378, 4, 11, 42861, // 4,11
- 3, 11, 6615, 3, 12, 9421, 4, 11, 9056, 4, 12, 40444, // 4,12
- 3, 12, 7261, 3, 13, 10559, 4, 12, 9674, 4, 13, 38042, // 4,13
- 3, 13, 7881, 3, 14, 11721, 4, 13, 10204, 4, 14, 35730, // 4,14
- 3, 14, 8463, 3, 15, 12899, 4, 14, 10635, 4, 15, 33539, // 4,15
- 5, -1, 9995, 5, 0, 34567, 6, -1, 8107, 6, 0, 12867, // 5, 0
- 5, 0, 9509, 5, 1, 36955, 6, 0, 7497, 6, 1, 11575, // 5, 1
- 5, 1, 8902, 5, 2, 39526, 6, 1, 6829, 6, 2, 10279, // 5, 2
- 5, 2, 8175, 5, 3, 42271, 6, 2, 6108, 6, 3, 8982, // 5, 3
- 5, 3, 7342, 5, 4, 45146, 6, 3, 5350, 6, 4, 7698, // 5, 4
- 5, 4, 6451, 5, 5, 48019, 6, 4, 4591, 6, 5, 6475, // 5, 5
- 5, 5, 5624, 5, 6, 50581, 6, 5, 3913, 6, 6, 5418, // 5, 6
- 5, 6, 5092, 5, 7, 52253, 6, 6, 3470, 6, 7, 4721, // 5, 7
- 4, 7, 3466, 4, 8, 4708, 5, 7, 5097, 5, 8, 52265, // 5, 8
- 4, 8, 3911, 4, 9, 5400, 5, 8, 5637, 5, 9, 50588, // 5, 9
- 4, 9, 4591, 4, 10, 6451, 5, 9, 6475, 5, 10, 48019, // 5,10
- 4, 10, 5353, 4, 11, 7667, 5, 10, 7377, 5, 11, 45139, // 5,11
- 4, 11, 6116, 4, 12, 8940, 5, 11, 8224, 5, 12, 42256, // 5,12
- 4, 12, 6842, 4, 13, 10226, 5, 12, 8966, 5, 13, 39502, // 5,13
- 4, 13, 7517, 4, 14, 11507, 5, 13, 9587, 5, 14, 36925, // 5,14
- 4, 14, 8135, 4, 15, 12783, 5, 14, 10086, 5, 15, 34532, // 5,15
- 6, -1, 9558, 6, 0, 35362, 7, -1, 7839, 7, 0, 12777, // 6, 0
- 6, 0, 9020, 6, 1, 37906, 7, 0, 7202, 7, 1, 11408, // 6, 1
- 6, 1, 8344, 6, 2, 40688, 7, 1, 6491, 7, 2, 10013, // 6, 2
- 6, 2, 7516, 6, 3, 43733, 7, 2, 5703, 7, 3, 8584, // 6, 3
- 6, 3, 6530, 6, 4, 47049, 7, 3, 4838, 7, 4, 7119, // 6, 4
- 6, 4, 5400, 6, 5, 50587, 7, 4, 3911, 7, 5, 5638, // 6, 5
- 6, 5, 4217, 6, 6, 54105, 7, 5, 2989, 7, 6, 4225, // 6, 6
- 6, 6, 3303, 6, 7, 56751, 7, 6, 2295, 7, 7, 3187, // 6, 7
- 5, 7, 2294, 5, 8, 3180, 6, 7, 3306, 6, 8, 56756, // 6, 8
- 5, 8, 2989, 5, 9, 4217, 6, 8, 4225, 6, 9, 54105, // 6, 9
- 5, 9, 3913, 5, 10, 5624, 6, 9, 5418, 6, 10, 50581, // 6,10
- 5, 10, 4843, 5, 11, 7100, 6, 10, 6558, 6, 11, 47035, // 6,11
- 5, 11, 5712, 5, 12, 8558, 6, 11, 7556, 6, 12, 43710, // 6,12
- 5, 12, 6506, 5, 13, 9977, 6, 12, 8397, 6, 13, 40656, // 6,13
- 5, 13, 7224, 5, 14, 11360, 6, 13, 9086, 6, 14, 37866, // 6,14
- 5, 14, 7868, 5, 15, 12717, 6, 14, 9635, 6, 15, 35316, // 6,15
- 7, -1, 9224, 7, 0, 35905, 8, -1, 7643, 8, 0, 12764, // 7, 0
- 7, 0, 8662, 7, 1, 38534, 8, 0, 6997, 8, 1, 11343, // 7, 1
- 7, 1, 7951, 7, 2, 41432, 8, 1, 6266, 8, 2, 9887, // 7, 2
- 7, 2, 7072, 7, 3, 44649, 8, 2, 5443, 8, 3, 8372, // 7, 3
- 7, 3, 6000, 7, 4, 48240, 8, 3, 4513, 8, 4, 6783, // 7, 4
- 7, 4, 4708, 7, 5, 52266, 8, 4, 3466, 8, 5, 5096, // 7, 5
- 7, 5, 3180, 7, 6, 56756, 8, 5, 2294, 8, 6, 3306, // 7, 6
- 7, 6, 1541, 7, 7, 61364, 8, 6, 1090, 8, 7, 1541, // 7, 7
- 6, 7, 1090, 6, 8, 1541, 7, 7, 1542, 7, 8, 61363, // 7, 8
- 6, 8, 2295, 6, 9, 3303, 7, 8, 3186, 7, 9, 56752, // 7, 9
- 6, 9, 3470, 6, 10, 5092, 7, 9, 4721, 7, 10, 52253, // 7,10
- 6, 10, 4521, 6, 11, 6774, 7, 10, 6023, 7, 11, 48218, // 7,11
- 6, 11, 5454, 6, 12, 8359, 7, 11, 7106, 7, 12, 44617, // 7,12
- 6, 12, 6284, 6, 13, 9867, 7, 12, 7996, 7, 13, 41389, // 7,13
- 6, 13, 7020, 6, 14, 11317, 7, 13, 8718, 7, 14, 38481, // 7,14
- 6, 14, 7674, 6, 15, 12728, 7, 14, 9290, 7, 15, 35844, // 7,15
- 8, 0, 35844, 8, 1, 9290, 9, 0, 12728, 9, 1, 7674, // 8, 0
- 8, 1, 38481, 8, 2, 8718, 9, 1, 11317, 9, 2, 7020, // 8, 1
- 8, 2, 41389, 8, 3, 7996, 9, 2, 9867, 9, 3, 6284, // 8, 2
- 8, 3, 44616, 8, 4, 7106, 9, 3, 8359, 9, 4, 5455, // 8, 3
- 8, 4, 48218, 8, 5, 6023, 9, 4, 6774, 9, 5, 4521, // 8, 4
- 8, 5, 52253, 8, 6, 4721, 9, 5, 5092, 9, 6, 3470, // 8, 5
- 8, 6, 56751, 8, 7, 3186, 9, 6, 3303, 9, 7, 2296, // 8, 6
- 8, 7, 61364, 8, 8, 1542, 9, 7, 1541, 9, 8, 1089, // 8, 7
- 7, 8, 1542, 7, 9, 1090, 8, 8, 61364, 8, 9, 1540, // 8, 8
- 7, 9, 3306, 7, 10, 2294, 8, 9, 56756, 8, 10, 3180, // 8, 9
- 7, 10, 5097, 7, 11, 3466, 8, 10, 52266, 8, 11, 4707, // 8,10
- 7, 11, 6783, 7, 12, 4513, 8, 11, 48240, 8, 12, 6000, // 8,11
- 7, 12, 8373, 7, 13, 5443, 8, 12, 44649, 8, 13, 7071, // 8,12
- 7, 13, 9886, 7, 14, 6266, 8, 13, 41432, 8, 14, 7952, // 8,13
- 7, 14, 11344, 7, 15, 6997, 8, 14, 38534, 8, 15, 8661, // 8,14
- 7, 15, 12764, 7, 16, 7643, 8, 15, 35905, 8, 16, 9224, // 8,15
- 9, 0, 35315, 9, 1, 9635, 10, 0, 12717, 10, 1, 7869, // 9, 0
- 9, 1, 37866, 9, 2, 9086, 10, 1, 11360, 10, 2, 7224, // 9, 1
- 9, 2, 40656, 9, 3, 8397, 10, 2, 9977, 10, 3, 6506, // 9, 2
- 9, 3, 43710, 9, 4, 7556, 10, 3, 8558, 10, 4, 5712, // 9, 3
- 9, 4, 47035, 9, 5, 6558, 10, 4, 7100, 10, 5, 4843, // 9, 4
- 9, 5, 50581, 9, 6, 5418, 10, 5, 5624, 10, 6, 3913, // 9, 5
- 9, 6, 54105, 9, 7, 4225, 10, 6, 4217, 10, 7, 2989, // 9, 6
- 9, 7, 56756, 9, 8, 3306, 10, 7, 3180, 10, 8, 2294, // 9, 7
- 8, 8, 3186, 8, 9, 2295, 9, 8, 56751, 9, 9, 3304, // 9, 8
- 8, 9, 4225, 8, 10, 2989, 9, 9, 54105, 9, 10, 4217, // 9, 9
- 8, 10, 5637, 8, 11, 3911, 9, 10, 50587, 9, 11, 5401, // 9,10
- 8, 11, 7119, 8, 12, 4838, 9, 11, 47049, 9, 12, 6530, // 9,11
- 8, 12, 8584, 8, 13, 5703, 9, 12, 43733, 9, 13, 7516, // 9,12
- 8, 13, 10013, 8, 14, 6491, 9, 13, 40688, 9, 14, 8344, // 9,13
- 8, 14, 11407, 8, 15, 7202, 9, 14, 37906, 9, 15, 9021, // 9,14
- 8, 15, 12777, 8, 16, 7839, 9, 15, 35362, 9, 16, 9558, // 9,15
- 10, 0, 34532, 10, 1, 10086, 11, 0, 12783, 11, 1, 8135, // 10, 0
- 10, 1, 36926, 10, 2, 9587, 11, 1, 11507, 11, 2, 7516, // 10, 1
- 10, 2, 39503, 10, 3, 8966, 11, 2, 10226, 11, 3, 6841, // 10, 2
- 10, 3, 42256, 10, 4, 8224, 11, 3, 8940, 11, 4, 6116, // 10, 3
- 10, 4, 45139, 10, 5, 7377, 11, 4, 7667, 11, 5, 5353, // 10, 4
- 10, 5, 48019, 10, 6, 6475, 11, 5, 6451, 11, 6, 4591, // 10, 5
- 10, 6, 50587, 10, 7, 5637, 11, 6, 5400, 11, 7, 3912, // 10, 6
- 10, 7, 52266, 10, 8, 5097, 11, 7, 4708, 11, 8, 3465, // 10, 7
- 9, 8, 4721, 9, 9, 3470, 10, 8, 52253, 10, 9, 5092, // 10, 8
- 9, 9, 5418, 9, 10, 3913, 10, 9, 50581, 10, 10, 5624, // 10, 9
- 9, 10, 6475, 9, 11, 4591, 10, 10, 48019, 10, 11, 6451, // 10,10
- 9, 11, 7698, 9, 12, 5350, 10, 11, 45146, 10, 12, 7342, // 10,11
- 9, 12, 8982, 9, 13, 6108, 10, 12, 42271, 10, 13, 8175, // 10,12
- 9, 13, 10279, 9, 14, 6829, 10, 13, 39526, 10, 14, 8902, // 10,13
- 9, 14, 11575, 9, 15, 7497, 10, 14, 36955, 10, 15, 9509, // 10,14
- 9, 15, 12867, 9, 16, 8107, 10, 15, 34567, 10, 16, 9995, // 10,15
- 11, 0, 33539, 11, 1, 10635, 12, 0, 12899, 12, 1, 8463, // 11, 0
- 11, 1, 35730, 11, 2, 10204, 12, 1, 11721, 12, 2, 7881, // 11, 1
- 11, 2, 38042, 11, 3, 9674, 12, 2, 10559, 12, 3, 7261, // 11, 2
- 11, 3, 40444, 11, 4, 9056, 12, 3, 9421, 12, 4, 6615, // 11, 3
- 11, 4, 42861, 11, 5, 8378, 12, 4, 8332, 12, 5, 5965, // 11, 4
- 11, 5, 45146, 11, 6, 7698, 12, 5, 7342, 12, 6, 5350, // 11, 5
- 11, 6, 47049, 11, 7, 7119, 12, 6, 6530, 12, 7, 4838, // 11, 6
- 11, 7, 48240, 11, 8, 6783, 12, 7, 6000, 12, 8, 4513, // 11, 7
- 10, 8, 6023, 10, 9, 4521, 11, 8, 48218, 11, 9, 6774, // 11, 8
- 10, 9, 6558, 10, 10, 4843, 11, 9, 47035, 11, 10, 7100, // 11, 9
- 10, 10, 7377, 10, 11, 5353, 11, 10, 45139, 11, 11, 7667, // 11,10
- 10, 11, 8378, 10, 12, 5965, 11, 11, 42861, 11, 12, 8332, // 11,11
- 10, 12, 9478, 10, 13, 6611, 11, 12, 40452, 11, 13, 8995, // 11,12
- 10, 13, 10630, 10, 14, 7252, 11, 13, 38057, 11, 14, 9597, // 11,13
- 10, 14, 11810, 10, 15, 7865, 11, 14, 35750, 11, 15, 10111, // 11,14
- 10, 15, 13007, 10, 16, 8438, 11, 15, 33564, 11, 16, 10527, // 11,15
- 12, 0, 32391, 12, 1, 11269, 13, 0, 13038, 13, 1, 8838, // 12, 0
- 12, 1, 34358, 12, 2, 10918, 13, 1, 11964, 13, 2, 8296, // 12, 1
- 12, 2, 36392, 12, 3, 10488, 13, 2, 10922, 13, 3, 7734, // 12, 2
- 12, 3, 38450, 12, 4, 9998, 13, 3, 9924, 13, 4, 7164, // 12, 3
- 12, 4, 40452, 12, 5, 9478, 13, 4, 8995, 13, 5, 6611, // 12, 4
- 12, 5, 42271, 12, 6, 8982, 13, 5, 8175, 13, 6, 6108, // 12, 5
- 12, 6, 43733, 12, 7, 8584, 13, 6, 7516, 13, 7, 5703, // 12, 6
- 12, 7, 44649, 12, 8, 8373, 13, 7, 7072, 13, 8, 5442, // 12, 7
- 11, 8, 7106, 11, 9, 5454, 12, 8, 44616, 12, 9, 8360, // 12, 8
- 11, 9, 7556, 11, 10, 5712, 12, 9, 43710, 12, 10, 8558, // 12, 9
- 11, 10, 8224, 11, 11, 6116, 12, 10, 42256, 12, 11, 8940, // 12,10
- 11, 11, 9056, 11, 12, 6615, 12, 11, 40444, 12, 12, 9421, // 12,11
- 11, 12, 9998, 11, 13, 7164, 12, 12, 38450, 12, 13, 9924, // 12,12
- 11, 13, 11012, 11, 14, 7728, 12, 13, 36399, 12, 14, 10397, // 12,13
- 11, 14, 12074, 11, 15, 8284, 12, 14, 34369, 12, 15, 10809, // 12,14
- 11, 15, 13171, 11, 16, 8816, 12, 15, 32406, 12, 16, 11143, // 12,15
- 13, 0, 31138, 13, 1, 11977, 14, 0, 13176, 14, 1, 9245, // 13, 0
- 13, 1, 32881, 13, 2, 11709, 14, 1, 12203, 14, 2, 8743, // 13, 1
- 13, 2, 34650, 13, 3, 11382, 14, 2, 11272, 14, 3, 8232, // 13, 2
- 13, 3, 36399, 13, 4, 11012, 14, 3, 10397, 14, 4, 7728, // 13, 3
- 13, 4, 38057, 13, 5, 10630, 14, 4, 9597, 14, 5, 7252, // 13, 4
- 13, 5, 39526, 13, 6, 10279, 14, 5, 8902, 14, 6, 6829, // 13, 5
- 13, 6, 40688, 13, 7, 10013, 14, 6, 8344, 14, 7, 6491, // 13, 6
- 13, 7, 41432, 13, 8, 9886, 14, 7, 7951, 14, 8, 6267, // 13, 7
- 12, 8, 7996, 12, 9, 6284, 13, 8, 41389, 13, 9, 9867, // 13, 8
- 12, 9, 8397, 12, 10, 6506, 13, 9, 40656, 13, 10, 9977, // 13, 9
- 12, 10, 8966, 12, 11, 6842, 13, 10, 39503, 13, 11, 10225, // 13,10
- 12, 11, 9674, 12, 12, 7261, 13, 11, 38042, 13, 12, 10559, // 13,11
- 12, 12, 10488, 12, 13, 7734, 13, 12, 36392, 13, 13, 10922, // 13,12
- 12, 13, 11382, 12, 14, 8232, 13, 13, 34650, 13, 14, 11272, // 13,13
- 12, 14, 12334, 12, 15, 8735, 13, 14, 32886, 13, 15, 11581, // 13,14
- 12, 15, 13332, 12, 16, 9229, 13, 15, 31146, 13, 16, 11829, // 13,15
- 14, 0, 29828, 14, 1, 12746, 15, 0, 13291, 15, 1, 9671, // 14, 0
- 14, 1, 31358, 14, 2, 12564, 15, 1, 12412, 15, 2, 9202, // 14, 1
- 14, 2, 32886, 14, 3, 12334, 15, 2, 11580, 15, 3, 8736, // 14, 2
- 14, 3, 34369, 14, 4, 12074, 15, 3, 10808, 15, 4, 8285, // 14, 3
- 14, 4, 35750, 14, 5, 11810, 15, 4, 10111, 15, 5, 7865, // 14, 4
- 14, 5, 36955, 14, 6, 11575, 15, 5, 9509, 15, 6, 7497, // 14, 5
- 14, 6, 37906, 14, 7, 11407, 15, 6, 9020, 15, 7, 7203, // 14, 6
- 14, 7, 38534, 14, 8, 11344, 15, 7, 8662, 15, 8, 6996, // 14, 7
- 13, 8, 8718, 13, 9, 7020, 14, 8, 38481, 14, 9, 11317, // 14, 8
- 13, 9, 9086, 13, 10, 7224, 14, 9, 37866, 14, 10, 11360, // 14, 9
- 13, 10, 9587, 13, 11, 7517, 14, 10, 36926, 14, 11, 11506, // 14,10
- 13, 11, 10204, 13, 12, 7881, 14, 11, 35730, 14, 12, 11721, // 14,11
- 13, 12, 10918, 13, 13, 8296, 14, 12, 34358, 14, 13, 11964, // 14,12
- 13, 13, 11709, 13, 14, 8742, 14, 13, 32881, 14, 14, 12204, // 14,13
- 13, 14, 12564, 13, 15, 9202, 14, 14, 31358, 14, 15, 12412, // 14,14
- 13, 15, 13470, 13, 16, 9662, 14, 15, 29831, 14, 16, 12573, // 14,15
- 15, 0, 28495, 15, 1, 13569, 16, 0, 13368, 16, 1, 10104, // 15, 0
- 15, 1, 29831, 15, 2, 13470, 16, 1, 12574, 16, 2, 9661, // 15, 1
- 15, 2, 31146, 15, 3, 13332, 16, 2, 11829, 16, 3, 9229, // 15, 2
- 15, 3, 32406, 15, 4, 13171, 16, 3, 11143, 16, 4, 8816, // 15, 3
- 15, 4, 33564, 15, 5, 13007, 16, 4, 10528, 16, 5, 8437, // 15, 4
- 15, 5, 34567, 15, 6, 12867, 16, 5, 9995, 16, 6, 8107, // 15, 5
- 15, 6, 35362, 15, 7, 12777, 16, 6, 9558, 16, 7, 7839, // 15, 6
- 15, 7, 35905, 15, 8, 12764, 16, 7, 9224, 16, 8, 7643, // 15, 7
- 14, 8, 9290, 14, 9, 7674, 15, 8, 35844, 15, 9, 12728, // 15, 8
- 14, 9, 9635, 14, 10, 7868, 15, 9, 35315, 15, 10, 12718, // 15, 9
- 14, 10, 10086, 14, 11, 8135, 15, 10, 34532, 15, 11, 12783, // 15,10
- 14, 11, 10635, 14, 12, 8463, 15, 11, 33539, 15, 12, 12899, // 15,11
- 14, 12, 11269, 14, 13, 8838, 15, 12, 32391, 15, 13, 13038, // 15,12
- 14, 13, 11977, 14, 14, 9245, 15, 13, 31138, 15, 14, 13176, // 15,13
- 14, 14, 12746, 14, 15, 9671, 15, 14, 29828, 15, 15, 13291, // 15,14
- 14, 15, 13569, 14, 16, 10104, 15, 15, 28495, 15, 16, 13368, // 15,15
- // angle of 2.5 degrees
- 0, -1, 14696, 0, 0, 24063, 1, -1, 11702, 1, 0, 15075, // 0, 0
- 0, 0, 14872, 0, 1, 25368, 1, 0, 11187, 1, 1, 14109, // 0, 1
- 0, 1, 14990, 0, 2, 26660, 1, 1, 10676, 1, 2, 13210, // 0, 2
- 0, 2, 15060, 0, 3, 27903, 1, 2, 10185, 1, 3, 12388, // 0, 3
- 0, 3, 15100, 0, 4, 29055, 1, 3, 9728, 1, 4, 11653, // 0, 4
- 0, 4, 15135, 0, 5, 30064, 1, 4, 9323, 1, 5, 11014, // 0, 5
- 0, 5, 15193, 0, 6, 30876, 1, 5, 8986, 1, 6, 10481, // 0, 6
- 0, 6, 15301, 0, 7, 31444, 1, 6, 8727, 1, 7, 10064, // 0, 7
- -1, 7, 8669, -1, 8, 9959, 0, 7, 15376, 0, 8, 31532, // 0, 8
- -1, 8, 8927, -1, 9, 10351, 0, 8, 15319, 0, 9, 30939, // 0, 9
- -1, 9, 9265, -1, 10, 10855, 0, 9, 15311, 0, 10, 30105, // 0,10
- -1, 10, 9673, -1, 11, 11461, 0, 10, 15325, 0, 11, 29077, // 0,11
- -1, 11, 10135, -1, 12, 12159, 0, 11, 15330, 0, 12, 27912, // 0,12
- -1, 12, 10637, -1, 13, 12938, 0, 12, 15301, 0, 13, 26660, // 0,13
- -1, 13, 11164, -1, 14, 13787, 0, 13, 15220, 0, 14, 25365, // 0,14
- -1, 14, 11702, -1, 15, 14696, 0, 14, 15076, 0, 15, 24062, // 0,15
- 1, -1, 13787, 1, 0, 25366, 2, -1, 11164, 2, 0, 15219, // 1, 0
- 1, 0, 13853, 1, 1, 26893, 2, 0, 10644, 2, 1, 14146, // 1, 1
- 1, 1, 13850, 1, 2, 28427, 2, 1, 10119, 2, 2, 13140, // 1, 2
- 1, 2, 13789, 1, 3, 29928, 2, 2, 9603, 2, 3, 12216, // 1, 3
- 1, 3, 13694, 1, 4, 31339, 2, 3, 9118, 2, 4, 11385, // 1, 4
- 1, 4, 13600, 1, 5, 32586, 2, 4, 8685, 2, 5, 10665, // 1, 5
- 1, 5, 13548, 1, 6, 33585, 2, 5, 8329, 2, 6, 10074, // 1, 6
- 1, 6, 13582, 1, 7, 34261, 2, 6, 8068, 2, 7, 9625, // 1, 7
- 0, 7, 8024, 0, 8, 9534, 1, 7, 13638, 1, 8, 34340, // 1, 8
- 0, 8, 8286, 0, 9, 9961, 1, 8, 13647, 1, 9, 33642, // 1, 9
- 0, 9, 8645, 0, 10, 10528, 1, 9, 13740, 1, 10, 32623, // 1,10
- 0, 10, 9082, 0, 11, 11218, 1, 10, 13875, 1, 11, 31361, // 1,11
- 0, 11, 9575, 0, 12, 12014, 1, 11, 14009, 1, 12, 29938, // 1,12
- 0, 12, 10102, 0, 13, 12897, 1, 12, 14107, 1, 13, 28430, // 1,13
- 0, 13, 10644, 0, 14, 13853, 1, 13, 14145, 1, 14, 26894, // 1,14
- 0, 14, 11187, 0, 15, 14872, 1, 14, 14109, 1, 15, 25368, // 1,15
- 2, -1, 12938, 2, 0, 26660, 3, -1, 10637, 3, 0, 15301, // 2, 0
- 2, 0, 12897, 2, 1, 28430, 3, 0, 10102, 3, 1, 14107, // 2, 1
- 2, 1, 12769, 2, 2, 30239, 3, 1, 9546, 3, 2, 12982, // 2, 2
- 2, 2, 12569, 2, 3, 32045, 3, 2, 8988, 3, 3, 11934, // 2, 3
- 2, 3, 12323, 2, 4, 33777, 3, 3, 8452, 3, 4, 10984, // 2, 4
- 2, 4, 12079, 2, 5, 35332, 3, 4, 7969, 3, 5, 10156, // 2, 5
- 2, 5, 11897, 2, 6, 36582, 3, 5, 7573, 3, 6, 9484, // 2, 6
- 2, 6, 11842, 2, 7, 37402, 3, 6, 7298, 3, 7, 8994, // 2, 7
- 1, 7, 7266, 1, 8, 8918, 2, 7, 11883, 2, 8, 37469, // 2, 8
- 1, 8, 7543, 1, 9, 9390, 2, 8, 11972, 2, 9, 36631, // 2, 9
- 1, 9, 7943, 1, 10, 10041, 2, 9, 12188, 2, 10, 35364, // 2,10
- 1, 10, 8432, 1, 11, 10842, 2, 10, 12467, 2, 11, 33795, // 2,11
- 1, 11, 8976, 1, 12, 11760, 2, 11, 12747, 2, 12, 32053, // 2,12
- 1, 12, 9546, 1, 13, 12769, 2, 12, 12982, 2, 13, 30239, // 2,13
- 1, 13, 10119, 1, 14, 13850, 2, 13, 13141, 2, 14, 28426, // 2,14
- 1, 14, 10676, 1, 15, 14990, 2, 14, 13211, 2, 15, 26659, // 2,15
- 3, -1, 12159, 3, 0, 27912, 4, -1, 10135, 4, 0, 15330, // 3, 0
- 3, 0, 12014, 3, 1, 29938, 4, 0, 9575, 4, 1, 14009, // 3, 1
- 3, 1, 11760, 3, 2, 32052, 4, 1, 8976, 4, 2, 12748, // 3, 2
- 3, 2, 11411, 3, 3, 34213, 4, 2, 8358, 4, 3, 11554, // 3, 3
- 3, 3, 10995, 3, 4, 36343, 4, 3, 7746, 4, 4, 10452, // 3, 4
- 3, 4, 10569, 3, 5, 38307, 4, 4, 7180, 4, 5, 9480, // 3, 5
- 3, 5, 10221, 3, 6, 39912, 4, 5, 6714, 4, 6, 8689, // 3, 6
- 3, 6, 10051, 3, 7, 40940, 4, 6, 6403, 4, 7, 8142, // 3, 7
- 2, 7, 6381, 2, 8, 8082, 3, 7, 10079, 3, 8, 40994, // 3, 8
- 2, 8, 6695, 2, 9, 8617, 3, 8, 10275, 3, 9, 39949, // 3, 9
- 2, 9, 7165, 2, 10, 9388, 3, 9, 10653, 3, 10, 38330, // 3,10
- 2, 10, 7737, 2, 11, 10337, 3, 10, 11108, 3, 11, 36354, // 3,11
- 2, 11, 8358, 2, 12, 11411, 3, 11, 11554, 3, 12, 34213, // 3,12
- 2, 12, 8988, 2, 13, 12569, 3, 12, 11934, 3, 13, 32045, // 3,13
- 2, 13, 9603, 2, 14, 13789, 3, 13, 12216, 3, 14, 29928, // 3,14
- 2, 14, 10185, 2, 15, 15060, 3, 14, 12388, 3, 15, 27903, // 3,15
- 4, -1, 11461, 4, 0, 29078, 5, -1, 9673, 5, 0, 15324, // 4, 0
- 4, 0, 11218, 4, 1, 31361, 5, 0, 9082, 5, 1, 13875, // 4, 1
- 4, 1, 10842, 4, 2, 33795, 5, 1, 8432, 5, 2, 12467, // 4, 2
- 4, 2, 10337, 4, 3, 36354, 5, 2, 7737, 5, 3, 11108, // 4, 3
- 4, 3, 9730, 4, 4, 38966, 5, 3, 7022, 5, 4, 9818, // 4, 4
- 4, 4, 9081, 4, 5, 41475, 5, 4, 6334, 5, 5, 8646, // 4, 5
- 4, 5, 8507, 4, 6, 43602, 5, 5, 5749, 5, 6, 7678, // 4, 6
- 4, 6, 8177, 4, 7, 44962, 5, 6, 5368, 5, 7, 7029, // 4, 7
- 3, 7, 5354, 3, 8, 6987, 4, 7, 8195, 4, 8, 45000, // 4, 8
- 3, 8, 5739, 3, 9, 7626, 4, 8, 8545, 4, 9, 43626, // 4, 9
- 3, 9, 6328, 3, 10, 8578, 4, 9, 9143, 4, 10, 41487, // 4,10
- 3, 10, 7022, 3, 11, 9730, 4, 10, 9818, 4, 11, 38966, // 4,11
- 3, 11, 7746, 3, 12, 10995, 4, 11, 10452, 4, 12, 36343, // 4,12
- 3, 12, 8452, 3, 13, 12323, 4, 12, 10983, 4, 13, 33778, // 4,13
- 3, 13, 9118, 3, 14, 13694, 4, 13, 11385, 4, 14, 31339, // 4,14
- 3, 14, 9728, 3, 15, 15100, 4, 14, 11652, 4, 15, 29056, // 4,15
- 5, -1, 10855, 5, 0, 30105, 6, -1, 9265, 6, 0, 15311, // 5, 0
- 5, 0, 10528, 5, 1, 32624, 6, 0, 8645, 6, 1, 13739, // 5, 1
- 5, 1, 10041, 5, 2, 35364, 6, 1, 7943, 6, 2, 12188, // 5, 2
- 5, 2, 9388, 5, 3, 38330, 6, 2, 7165, 6, 3, 10653, // 5, 3
- 5, 3, 8578, 5, 4, 41487, 6, 3, 6328, 6, 4, 9143, // 5, 4
- 5, 4, 7659, 5, 5, 44700, 6, 4, 5472, 6, 5, 7705, // 5, 5
- 5, 5, 6768, 5, 6, 47619, 6, 5, 4694, 6, 6, 6455, // 5, 6
- 5, 6, 6183, 5, 7, 49566, 6, 6, 4172, 6, 7, 5615, // 5, 7
- 4, 7, 4164, 4, 8, 5590, 5, 7, 6193, 5, 8, 49589, // 5, 8
- 4, 8, 4690, 4, 9, 6422, 5, 8, 6794, 5, 9, 47630, // 5, 9
- 4, 9, 5472, 4, 10, 7659, 5, 9, 7705, 5, 10, 44700, // 5,10
- 4, 10, 6334, 4, 11, 9081, 5, 10, 8646, 5, 11, 41475, // 5,11
- 4, 11, 7180, 4, 12, 10569, 5, 11, 9479, 5, 12, 38308, // 5,12
- 4, 12, 7969, 4, 13, 12079, 5, 12, 10156, 5, 13, 35332, // 5,13
- 4, 13, 8685, 4, 14, 13600, 5, 13, 10665, 5, 14, 32586, // 5,14
- 4, 14, 9323, 4, 15, 15135, 5, 14, 11013, 5, 15, 30065, // 5,15
- 6, -1, 10351, 6, 0, 30939, 7, -1, 8927, 7, 0, 15319, // 6, 0
- 6, 0, 9961, 6, 1, 33642, 7, 0, 8286, 7, 1, 13647, // 6, 1
- 6, 1, 9390, 6, 2, 36631, 7, 1, 7543, 7, 2, 11972, // 6, 2
- 6, 2, 8617, 6, 3, 39949, 7, 2, 6695, 7, 3, 10275, // 6, 3
- 6, 3, 7626, 6, 4, 43626, 7, 3, 5739, 7, 4, 8545, // 6, 4
- 6, 4, 6422, 6, 5, 47630, 7, 4, 4690, 7, 5, 6794, // 6, 5
- 6, 5, 5099, 6, 6, 51701, 7, 5, 3620, 7, 6, 5116, // 6, 6
- 6, 6, 4044, 6, 7, 54831, 7, 6, 2797, 7, 7, 3864, // 6, 7
- 5, 7, 2795, 5, 8, 3853, 6, 7, 4049, 6, 8, 54839, // 6, 8
- 5, 8, 3620, 5, 9, 5099, 6, 8, 5116, 6, 9, 51701, // 6, 9
- 5, 9, 4694, 5, 10, 6768, 6, 9, 6455, 6, 10, 47619, // 6,10
- 5, 10, 5749, 5, 11, 8507, 6, 10, 7678, 6, 11, 43602, // 6,11
- 5, 11, 6714, 5, 12, 10221, 6, 11, 8690, 6, 12, 39911, // 6,12
- 5, 12, 7573, 5, 13, 11897, 6, 12, 9484, 6, 13, 36582, // 6,13
- 5, 13, 8329, 5, 14, 13548, 6, 13, 10074, 6, 14, 33585, // 6,14
- 5, 14, 8986, 5, 15, 15193, 6, 14, 10482, 6, 15, 30875, // 6,15
- 7, -1, 9959, 7, 0, 31532, 8, -1, 8669, 8, 0, 15376, // 7, 0
- 7, 0, 9534, 7, 1, 34340, 8, 0, 8024, 8, 1, 13638, // 7, 1
- 7, 1, 8918, 7, 2, 37470, 8, 1, 7266, 8, 2, 11882, // 7, 2
- 7, 2, 8082, 7, 3, 40994, 8, 2, 6381, 8, 3, 10079, // 7, 3
- 7, 3, 6987, 7, 4, 44999, 8, 3, 5354, 8, 4, 8196, // 7, 4
- 7, 4, 5590, 7, 5, 49588, 8, 4, 4164, 8, 5, 6194, // 7, 5
- 7, 5, 3853, 7, 6, 54839, 8, 5, 2795, 8, 6, 4049, // 7, 6
- 7, 6, 1903, 7, 7, 60382, 8, 6, 1347, 8, 7, 1904, // 7, 7
- 6, 7, 1347, 6, 8, 1903, 7, 7, 1905, 7, 8, 60381, // 7, 8
- 6, 8, 2797, 6, 9, 4044, 7, 8, 3864, 7, 9, 54831, // 7, 9
- 6, 9, 4172, 6, 10, 6183, 7, 9, 5615, 7, 10, 49566, // 7,10
- 6, 10, 5368, 6, 11, 8177, 7, 10, 7029, 7, 11, 44962, // 7,11
- 6, 11, 6403, 6, 12, 10051, 7, 11, 8141, 7, 12, 40941, // 7,12
- 6, 12, 7298, 6, 13, 11842, 7, 12, 8994, 7, 13, 37402, // 7,13
- 6, 13, 8068, 6, 14, 13582, 7, 13, 9626, 7, 14, 34260, // 7,14
- 6, 14, 8727, 6, 15, 15301, 7, 14, 10065, 7, 15, 31443, // 7,15
- 8, 0, 31444, 8, 1, 10065, 9, 0, 15301, 9, 1, 8726, // 8, 0
- 8, 1, 34261, 8, 2, 9626, 9, 1, 13582, 9, 2, 8067, // 8, 1
- 8, 2, 37402, 8, 3, 8994, 9, 2, 11842, 9, 3, 7298, // 8, 2
- 8, 3, 40940, 8, 4, 8141, 9, 3, 10051, 9, 4, 6404, // 8, 3
- 8, 4, 44962, 8, 5, 7029, 9, 4, 8177, 9, 5, 5368, // 8, 4
- 8, 5, 49566, 8, 6, 5615, 9, 5, 6183, 9, 6, 4172, // 8, 5
- 8, 6, 54831, 8, 7, 3864, 9, 6, 4044, 9, 7, 2797, // 8, 6
- 8, 7, 60382, 8, 8, 1905, 9, 7, 1903, 9, 8, 1346, // 8, 7
- 7, 8, 1905, 7, 9, 1347, 8, 8, 60382, 8, 9, 1902, // 8, 8
- 7, 9, 4049, 7, 10, 2795, 8, 9, 54839, 8, 10, 3853, // 8, 9
- 7, 10, 6193, 7, 11, 4164, 8, 10, 49588, 8, 11, 5591, // 8,10
- 7, 11, 8195, 7, 12, 5354, 8, 11, 44999, 8, 12, 6988, // 8,11
- 7, 12, 10079, 7, 13, 6381, 8, 12, 40994, 8, 13, 8082, // 8,12
- 7, 13, 11883, 7, 14, 7266, 8, 13, 37470, 8, 14, 8917, // 8,13
- 7, 14, 13638, 7, 15, 8024, 8, 14, 34340, 8, 15, 9534, // 8,14
- 7, 15, 15376, 7, 16, 8669, 8, 15, 31532, 8, 16, 9959, // 8,15
- 9, 0, 30876, 9, 1, 10482, 10, 0, 15193, 10, 1, 8985, // 9, 0
- 9, 1, 33585, 9, 2, 10074, 10, 1, 13548, 10, 2, 8329, // 9, 1
- 9, 2, 36582, 9, 3, 9484, 10, 2, 11897, 10, 3, 7573, // 9, 2
- 9, 3, 39912, 9, 4, 8690, 10, 3, 10221, 10, 4, 6713, // 9, 3
- 9, 4, 43602, 9, 5, 7678, 10, 4, 8507, 10, 5, 5749, // 9, 4
- 9, 5, 47619, 9, 6, 6455, 10, 5, 6768, 10, 6, 4694, // 9, 5
- 9, 6, 51701, 9, 7, 5116, 10, 6, 5099, 10, 7, 3620, // 9, 6
- 9, 7, 54839, 9, 8, 4049, 10, 7, 3853, 10, 8, 2795, // 9, 7
- 8, 8, 3864, 8, 9, 2797, 9, 8, 54831, 9, 9, 4044, // 9, 8
- 8, 9, 5116, 8, 10, 3620, 9, 9, 51701, 9, 10, 5099, // 9, 9
- 8, 10, 6794, 8, 11, 4690, 9, 10, 47630, 9, 11, 6422, // 9,10
- 8, 11, 8545, 8, 12, 5739, 9, 11, 43626, 9, 12, 7626, // 9,11
- 8, 12, 10275, 8, 13, 6695, 9, 12, 39949, 9, 13, 8617, // 9,12
- 8, 13, 11972, 8, 14, 7543, 9, 13, 36631, 9, 14, 9390, // 9,13
- 8, 14, 13647, 8, 15, 8286, 9, 14, 33642, 9, 15, 9961, // 9,14
- 8, 15, 15319, 8, 16, 8927, 9, 15, 30939, 9, 16, 10351, // 9,15
- 10, 0, 30064, 10, 1, 11013, 11, 0, 15135, 11, 1, 9324, // 10, 0
- 10, 1, 32586, 10, 2, 10665, 11, 1, 13600, 11, 2, 8685, // 10, 1
- 10, 2, 35332, 10, 3, 10156, 11, 2, 12079, 11, 3, 7969, // 10, 2
- 10, 3, 38307, 10, 4, 9479, 11, 3, 10569, 11, 4, 7181, // 10, 3
- 10, 4, 41475, 10, 5, 8646, 11, 4, 9081, 11, 5, 6334, // 10, 4
- 10, 5, 44700, 10, 6, 7705, 11, 5, 7659, 11, 6, 5472, // 10, 5
- 10, 6, 47630, 10, 7, 6794, 11, 6, 6422, 11, 7, 4690, // 10, 6
- 10, 7, 49588, 10, 8, 6193, 11, 7, 5590, 11, 8, 4165, // 10, 7
- 9, 8, 5615, 9, 9, 4172, 10, 8, 49566, 10, 9, 6183, // 10, 8
- 9, 9, 6455, 9, 10, 4694, 10, 9, 47619, 10, 10, 6768, // 10, 9
- 9, 10, 7705, 9, 11, 5472, 10, 10, 44700, 10, 11, 7659, // 10,10
- 9, 11, 9143, 9, 12, 6328, 10, 11, 41487, 10, 12, 8578, // 10,11
- 9, 12, 10653, 9, 13, 7165, 10, 12, 38330, 10, 13, 9388, // 10,12
- 9, 13, 12188, 9, 14, 7943, 10, 13, 35364, 10, 14, 10041, // 10,13
- 9, 14, 13740, 9, 15, 8645, 10, 14, 32624, 10, 15, 10527, // 10,14
- 9, 15, 15311, 9, 16, 9265, 10, 15, 30105, 10, 16, 10855, // 10,15
- 11, 0, 29055, 11, 1, 11652, 12, 0, 15100, 12, 1, 9729, // 11, 0
- 11, 1, 31339, 11, 2, 11385, 12, 1, 13694, 12, 2, 9118, // 11, 1
- 11, 2, 33777, 11, 3, 10983, 12, 2, 12323, 12, 3, 8453, // 11, 2
- 11, 3, 36343, 11, 4, 10452, 12, 3, 10995, 12, 4, 7746, // 11, 3
- 11, 4, 38966, 11, 5, 9818, 12, 4, 9730, 12, 5, 7022, // 11, 4
- 11, 5, 41487, 11, 6, 9143, 12, 5, 8578, 12, 6, 6328, // 11, 5
- 11, 6, 43626, 11, 7, 8545, 12, 6, 7626, 12, 7, 5739, // 11, 6
- 11, 7, 44999, 11, 8, 8195, 12, 7, 6987, 12, 8, 5355, // 11, 7
- 10, 8, 7029, 10, 9, 5368, 11, 8, 44962, 11, 9, 8177, // 11, 8
- 10, 9, 7678, 10, 10, 5749, 11, 9, 43602, 11, 10, 8507, // 11, 9
- 10, 10, 8646, 10, 11, 6334, 11, 10, 41475, 11, 11, 9081, // 11,10
- 10, 11, 9818, 10, 12, 7022, 11, 11, 38966, 11, 12, 9730, // 11,11
- 10, 12, 11108, 10, 13, 7737, 11, 12, 36354, 11, 13, 10337, // 11,12
- 10, 13, 12467, 10, 14, 8432, 11, 13, 33795, 11, 14, 10842, // 11,13
- 10, 14, 13875, 10, 15, 9082, 11, 14, 31361, 11, 15, 11218, // 11,14
- 10, 15, 15325, 10, 16, 9673, 11, 15, 29078, 11, 16, 11460, // 11,15
- 12, 0, 27903, 12, 1, 12388, 13, 0, 15060, 13, 1, 10185, // 12, 0
- 12, 1, 29928, 12, 2, 12216, 13, 1, 13789, 13, 2, 9603, // 12, 1
- 12, 2, 32045, 12, 3, 11934, 13, 2, 12569, 13, 3, 8988, // 12, 2
- 12, 3, 34213, 12, 4, 11554, 13, 3, 11411, 13, 4, 8358, // 12, 3
- 12, 4, 36354, 12, 5, 11108, 13, 4, 10337, 13, 5, 7737, // 12, 4
- 12, 5, 38330, 12, 6, 10653, 13, 5, 9388, 13, 6, 7165, // 12, 5
- 12, 6, 39949, 12, 7, 10275, 13, 6, 8617, 13, 7, 6695, // 12, 6
- 12, 7, 40994, 12, 8, 10079, 13, 7, 8082, 13, 8, 6381, // 12, 7
- 11, 8, 8141, 11, 9, 6403, 12, 8, 40940, 12, 9, 10052, // 12, 8
- 11, 9, 8690, 11, 10, 6714, 12, 9, 39912, 12, 10, 10220, // 12, 9
- 11, 10, 9479, 11, 11, 7180, 12, 10, 38307, 12, 11, 10570, // 12,10
- 11, 11, 10452, 11, 12, 7746, 12, 11, 36343, 12, 12, 10995, // 12,11
- 11, 12, 11554, 11, 13, 8358, 12, 12, 34213, 12, 13, 11411, // 12,12
- 11, 13, 12747, 11, 14, 8976, 12, 13, 32052, 12, 14, 11761, // 12,13
- 11, 14, 14009, 11, 15, 9575, 12, 14, 29938, 12, 15, 12014, // 12,14
- 11, 15, 15330, 11, 16, 10135, 12, 15, 27912, 12, 16, 12159, // 12,15
- 13, 0, 26660, 13, 1, 13211, 14, 0, 14990, 14, 1, 10675, // 13, 0
- 13, 1, 28427, 13, 2, 13141, 14, 1, 13850, 14, 2, 10118, // 13, 1
- 13, 2, 30239, 13, 3, 12982, 14, 2, 12769, 14, 3, 9546, // 13, 2
- 13, 3, 32052, 13, 4, 12747, 14, 3, 11760, 14, 4, 8977, // 13, 3
- 13, 4, 33795, 13, 5, 12467, 14, 4, 10842, 14, 5, 8432, // 13, 4
- 13, 5, 35364, 13, 6, 12188, 14, 5, 10041, 14, 6, 7943, // 13, 5
- 13, 6, 36631, 13, 7, 11972, 14, 6, 9390, 14, 7, 7543, // 13, 6
- 13, 7, 37470, 13, 8, 11883, 14, 7, 8918, 14, 8, 7265, // 13, 7
- 12, 8, 8994, 12, 9, 7298, 13, 8, 37402, 13, 9, 11842, // 13, 8
- 12, 9, 9484, 12, 10, 7573, 13, 9, 36582, 13, 10, 11897, // 13, 9
- 12, 10, 10156, 12, 11, 7969, 13, 10, 35332, 13, 11, 12079, // 13,10
- 12, 11, 10983, 12, 12, 8452, 13, 11, 33777, 13, 12, 12324, // 13,11
- 12, 12, 11934, 12, 13, 8988, 13, 12, 32045, 13, 13, 12569, // 13,12
- 12, 13, 12982, 12, 14, 9546, 13, 13, 30239, 13, 14, 12769, // 13,13
- 12, 14, 14107, 12, 15, 10102, 13, 14, 28430, 13, 15, 12897, // 13,14
- 12, 15, 15301, 12, 16, 10637, 13, 15, 26660, 13, 16, 12938, // 13,15
- 14, 0, 25368, 14, 1, 14109, 15, 0, 14872, 15, 1, 11187, // 14, 0
- 14, 1, 26893, 14, 2, 14145, 15, 1, 13853, 15, 2, 10645, // 14, 1
- 14, 2, 28430, 14, 3, 14107, 15, 2, 12897, 15, 3, 10102, // 14, 2
- 14, 3, 29938, 14, 4, 14009, 15, 3, 12014, 15, 4, 9575, // 14, 3
- 14, 4, 31361, 14, 5, 13875, 15, 4, 11218, 15, 5, 9082, // 14, 4
- 14, 5, 32624, 14, 6, 13740, 15, 5, 10528, 15, 6, 8644, // 14, 5
- 14, 6, 33642, 14, 7, 13647, 15, 6, 9961, 15, 7, 8286, // 14, 6
- 14, 7, 34340, 14, 8, 13638, 15, 7, 9534, 15, 8, 8024, // 14, 7
- 13, 8, 9626, 13, 9, 8068, 14, 8, 34261, 14, 9, 13581, // 14, 8
- 13, 9, 10074, 13, 10, 8329, 14, 9, 33585, 14, 10, 13548, // 14, 9
- 13, 10, 10665, 13, 11, 8685, 14, 10, 32586, 14, 11, 13600, // 14,10
- 13, 11, 11385, 13, 12, 9118, 14, 11, 31339, 14, 12, 13694, // 14,11
- 13, 12, 12216, 13, 13, 9603, 14, 12, 29928, 14, 13, 13789, // 14,12
- 13, 13, 13141, 13, 14, 10119, 14, 13, 28427, 14, 14, 13849, // 14,13
- 13, 14, 14145, 13, 15, 10644, 14, 14, 26893, 14, 15, 13854, // 14,14
- 13, 15, 15220, 13, 16, 11164, 14, 15, 25366, 14, 16, 13786, // 14,15
- 15, 0, 24063, 15, 1, 15076, 16, 0, 14696, 16, 1, 11701, // 15, 0
- 15, 1, 25366, 15, 2, 15220, 16, 1, 13787, 16, 2, 11163, // 15, 1
- 15, 2, 26660, 15, 3, 15301, 16, 2, 12938, 16, 3, 10637, // 15, 2
- 15, 3, 27912, 15, 4, 15330, 16, 3, 12159, 16, 4, 10135, // 15, 3
- 15, 4, 29078, 15, 5, 15325, 16, 4, 11461, 16, 5, 9672, // 15, 4
- 15, 5, 30105, 15, 6, 15311, 16, 5, 10855, 16, 6, 9265, // 15, 5
- 15, 6, 30939, 15, 7, 15319, 16, 6, 10351, 16, 7, 8927, // 15, 6
- 15, 7, 31532, 15, 8, 15376, 16, 7, 9959, 16, 8, 8669, // 15, 7
- 14, 8, 10065, 14, 9, 8727, 15, 8, 31444, 15, 9, 15300, // 15, 8
- 14, 9, 10482, 14, 10, 8986, 15, 9, 30876, 15, 10, 15192, // 15, 9
- 14, 10, 11013, 14, 11, 9323, 15, 10, 30064, 15, 11, 15136, // 15,10
- 14, 11, 11652, 14, 12, 9728, 15, 11, 29055, 15, 12, 15101, // 15,11
- 14, 12, 12388, 14, 13, 10185, 15, 12, 27903, 15, 13, 15060, // 15,12
- 14, 13, 13211, 14, 14, 10676, 15, 13, 26660, 15, 14, 14989, // 15,13
- 14, 14, 14109, 14, 15, 11187, 15, 14, 25368, 15, 15, 14872, // 15,14
- 14, 15, 15076, 14, 16, 11702, 15, 15, 24063, 15, 16, 14695, // 15,15
+// angle of -2.5 degrees
+-1, 0, 14696, -1, 1, 11702, 0, 0, 24063, 0, 1, 15075, // 0, 0
+-1, 1, 13787, -1, 2, 11164, 0, 1, 25366, 0, 2, 15219, // 0, 1
+-1, 2, 12938, -1, 3, 10637, 0, 2, 26660, 0, 3, 15301, // 0, 2
+-1, 3, 12159, -1, 4, 10135, 0, 3, 27912, 0, 4, 15330, // 0, 3
+-1, 4, 11461, -1, 5, 9673, 0, 4, 29078, 0, 5, 15324, // 0, 4
+-1, 5, 10855, -1, 6, 9265, 0, 5, 30105, 0, 6, 15311, // 0, 5
+-1, 6, 10351, -1, 7, 8927, 0, 6, 30939, 0, 7, 15319, // 0, 6
+-1, 7, 9959, -1, 8, 8669, 0, 7, 31532, 0, 8, 15376, // 0, 7
+0, 8, 31444, 0, 9, 15301, 1, 8, 10065, 1, 9, 8726, // 0, 8
+0, 9, 30876, 0, 10, 15193, 1, 9, 10482, 1, 10, 8985, // 0, 9
+0, 10, 30064, 0, 11, 15135, 1, 10, 11013, 1, 11, 9324, // 0,10
+0, 11, 29055, 0, 12, 15100, 1, 11, 11652, 1, 12, 9729, // 0,11
+0, 12, 27903, 0, 13, 15060, 1, 12, 12388, 1, 13, 10185, // 0,12
+0, 13, 26660, 0, 14, 14990, 1, 13, 13211, 1, 14, 10675, // 0,13
+0, 14, 25368, 0, 15, 14872, 1, 14, 14109, 1, 15, 11187, // 0,14
+0, 15, 24063, 0, 16, 14696, 1, 15, 15076, 1, 16, 11701, // 0,15
+0, 0, 14872, 0, 1, 11187, 1, 0, 25368, 1, 1, 14109, // 1, 0
+0, 1, 13853, 0, 2, 10644, 1, 1, 26893, 1, 2, 14146, // 1, 1
+0, 2, 12897, 0, 3, 10102, 1, 2, 28430, 1, 3, 14107, // 1, 2
+0, 3, 12014, 0, 4, 9575, 1, 3, 29938, 1, 4, 14009, // 1, 3
+0, 4, 11218, 0, 5, 9082, 1, 4, 31361, 1, 5, 13875, // 1, 4
+0, 5, 10528, 0, 6, 8645, 1, 5, 32624, 1, 6, 13739, // 1, 5
+0, 6, 9961, 0, 7, 8286, 1, 6, 33642, 1, 7, 13647, // 1, 6
+0, 7, 9534, 0, 8, 8024, 1, 7, 34340, 1, 8, 13638, // 1, 7
+1, 8, 34261, 1, 9, 13582, 2, 8, 9626, 2, 9, 8067, // 1, 8
+1, 9, 33585, 1, 10, 13548, 2, 9, 10074, 2, 10, 8329, // 1, 9
+1, 10, 32586, 1, 11, 13600, 2, 10, 10665, 2, 11, 8685, // 1,10
+1, 11, 31339, 1, 12, 13694, 2, 11, 11385, 2, 12, 9118, // 1,11
+1, 12, 29928, 1, 13, 13789, 2, 12, 12216, 2, 13, 9603, // 1,12
+1, 13, 28427, 1, 14, 13850, 2, 13, 13141, 2, 14, 10118, // 1,13
+1, 14, 26893, 1, 15, 13853, 2, 14, 14145, 2, 15, 10645, // 1,14
+1, 15, 25366, 1, 16, 13787, 2, 15, 15220, 2, 16, 11163, // 1,15
+1, 0, 14990, 1, 1, 10676, 2, 0, 26660, 2, 1, 13210, // 2, 0
+1, 1, 13850, 1, 2, 10119, 2, 1, 28427, 2, 2, 13140, // 2, 1
+1, 2, 12769, 1, 3, 9546, 2, 2, 30239, 2, 3, 12982, // 2, 2
+1, 3, 11760, 1, 4, 8976, 2, 3, 32052, 2, 4, 12748, // 2, 3
+1, 4, 10842, 1, 5, 8432, 2, 4, 33795, 2, 5, 12467, // 2, 4
+1, 5, 10041, 1, 6, 7943, 2, 5, 35364, 2, 6, 12188, // 2, 5
+1, 6, 9390, 1, 7, 7543, 2, 6, 36631, 2, 7, 11972, // 2, 6
+1, 7, 8918, 1, 8, 7266, 2, 7, 37470, 2, 8, 11882, // 2, 7
+2, 8, 37402, 2, 9, 11842, 3, 8, 8994, 3, 9, 7298, // 2, 8
+2, 9, 36582, 2, 10, 11897, 3, 9, 9484, 3, 10, 7573, // 2, 9
+2, 10, 35332, 2, 11, 12079, 3, 10, 10156, 3, 11, 7969, // 2,10
+2, 11, 33777, 2, 12, 12323, 3, 11, 10983, 3, 12, 8453, // 2,11
+2, 12, 32045, 2, 13, 12569, 3, 12, 11934, 3, 13, 8988, // 2,12
+2, 13, 30239, 2, 14, 12769, 3, 13, 12982, 3, 14, 9546, // 2,13
+2, 14, 28430, 2, 15, 12897, 3, 14, 14107, 3, 15, 10102, // 2,14
+2, 15, 26660, 2, 16, 12938, 3, 15, 15301, 3, 16, 10637, // 2,15
+2, 0, 15060, 2, 1, 10185, 3, 0, 27903, 3, 1, 12388, // 3, 0
+2, 1, 13789, 2, 2, 9603, 3, 1, 29928, 3, 2, 12216, // 3, 1
+2, 2, 12569, 2, 3, 8988, 3, 2, 32045, 3, 3, 11934, // 3, 2
+2, 3, 11411, 2, 4, 8358, 3, 3, 34213, 3, 4, 11554, // 3, 3
+2, 4, 10337, 2, 5, 7737, 3, 4, 36354, 3, 5, 11108, // 3, 4
+2, 5, 9388, 2, 6, 7165, 3, 5, 38330, 3, 6, 10653, // 3, 5
+2, 6, 8617, 2, 7, 6695, 3, 6, 39949, 3, 7, 10275, // 3, 6
+2, 7, 8082, 2, 8, 6381, 3, 7, 40994, 3, 8, 10079, // 3, 7
+3, 8, 40940, 3, 9, 10051, 4, 8, 8141, 4, 9, 6404, // 3, 8
+3, 9, 39912, 3, 10, 10221, 4, 9, 8690, 4, 10, 6713, // 3, 9
+3, 10, 38307, 3, 11, 10569, 4, 10, 9479, 4, 11, 7181, // 3,10
+3, 11, 36343, 3, 12, 10995, 4, 11, 10452, 4, 12, 7746, // 3,11
+3, 12, 34213, 3, 13, 11411, 4, 12, 11554, 4, 13, 8358, // 3,12
+3, 13, 32052, 3, 14, 11760, 4, 13, 12747, 4, 14, 8977, // 3,13
+3, 14, 29938, 3, 15, 12014, 4, 14, 14009, 4, 15, 9575, // 3,14
+3, 15, 27912, 3, 16, 12159, 4, 15, 15330, 4, 16, 10135, // 3,15
+3, 0, 15100, 3, 1, 9728, 4, 0, 29055, 4, 1, 11653, // 4, 0
+3, 1, 13694, 3, 2, 9118, 4, 1, 31339, 4, 2, 11385, // 4, 1
+3, 2, 12323, 3, 3, 8452, 4, 2, 33777, 4, 3, 10984, // 4, 2
+3, 3, 10995, 3, 4, 7746, 4, 3, 36343, 4, 4, 10452, // 4, 3
+3, 4, 9730, 3, 5, 7022, 4, 4, 38966, 4, 5, 9818, // 4, 4
+3, 5, 8578, 3, 6, 6328, 4, 5, 41487, 4, 6, 9143, // 4, 5
+3, 6, 7626, 3, 7, 5739, 4, 6, 43626, 4, 7, 8545, // 4, 6
+3, 7, 6987, 3, 8, 5354, 4, 7, 44999, 4, 8, 8196, // 4, 7
+4, 8, 44962, 4, 9, 8177, 5, 8, 7029, 5, 9, 5368, // 4, 8
+4, 9, 43602, 4, 10, 8507, 5, 9, 7678, 5, 10, 5749, // 4, 9
+4, 10, 41475, 4, 11, 9081, 5, 10, 8646, 5, 11, 6334, // 4,10
+4, 11, 38966, 4, 12, 9730, 5, 11, 9818, 5, 12, 7022, // 4,11
+4, 12, 36354, 4, 13, 10337, 5, 12, 11108, 5, 13, 7737, // 4,12
+4, 13, 33795, 4, 14, 10842, 5, 13, 12467, 5, 14, 8432, // 4,13
+4, 14, 31361, 4, 15, 11218, 5, 14, 13875, 5, 15, 9082, // 4,14
+4, 15, 29078, 4, 16, 11461, 5, 15, 15325, 5, 16, 9672, // 4,15
+4, 0, 15135, 4, 1, 9323, 5, 0, 30064, 5, 1, 11014, // 5, 0
+4, 1, 13600, 4, 2, 8685, 5, 1, 32586, 5, 2, 10665, // 5, 1
+4, 2, 12079, 4, 3, 7969, 5, 2, 35332, 5, 3, 10156, // 5, 2
+4, 3, 10569, 4, 4, 7180, 5, 3, 38307, 5, 4, 9480, // 5, 3
+4, 4, 9081, 4, 5, 6334, 5, 4, 41475, 5, 5, 8646, // 5, 4
+4, 5, 7659, 4, 6, 5472, 5, 5, 44700, 5, 6, 7705, // 5, 5
+4, 6, 6422, 4, 7, 4690, 5, 6, 47630, 5, 7, 6794, // 5, 6
+4, 7, 5590, 4, 8, 4164, 5, 7, 49588, 5, 8, 6194, // 5, 7
+5, 8, 49566, 5, 9, 6183, 6, 8, 5615, 6, 9, 4172, // 5, 8
+5, 9, 47619, 5, 10, 6768, 6, 9, 6455, 6, 10, 4694, // 5, 9
+5, 10, 44700, 5, 11, 7659, 6, 10, 7705, 6, 11, 5472, // 5,10
+5, 11, 41487, 5, 12, 8578, 6, 11, 9143, 6, 12, 6328, // 5,11
+5, 12, 38330, 5, 13, 9388, 6, 12, 10653, 6, 13, 7165, // 5,12
+5, 13, 35364, 5, 14, 10041, 6, 13, 12188, 6, 14, 7943, // 5,13
+5, 14, 32624, 5, 15, 10528, 6, 14, 13740, 6, 15, 8644, // 5,14
+5, 15, 30105, 5, 16, 10855, 6, 15, 15311, 6, 16, 9265, // 5,15
+5, 0, 15193, 5, 1, 8986, 6, 0, 30876, 6, 1, 10481, // 6, 0
+5, 1, 13548, 5, 2, 8329, 6, 1, 33585, 6, 2, 10074, // 6, 1
+5, 2, 11897, 5, 3, 7573, 6, 2, 36582, 6, 3, 9484, // 6, 2
+5, 3, 10221, 5, 4, 6714, 6, 3, 39912, 6, 4, 8689, // 6, 3
+5, 4, 8507, 5, 5, 5749, 6, 4, 43602, 6, 5, 7678, // 6, 4
+5, 5, 6768, 5, 6, 4694, 6, 5, 47619, 6, 6, 6455, // 6, 5
+5, 6, 5099, 5, 7, 3620, 6, 6, 51701, 6, 7, 5116, // 6, 6
+5, 7, 3853, 5, 8, 2795, 6, 7, 54839, 6, 8, 4049, // 6, 7
+6, 8, 54831, 6, 9, 4044, 7, 8, 3864, 7, 9, 2797, // 6, 8
+6, 9, 51701, 6, 10, 5099, 7, 9, 5116, 7, 10, 3620, // 6, 9
+6, 10, 47630, 6, 11, 6422, 7, 10, 6794, 7, 11, 4690, // 6,10
+6, 11, 43626, 6, 12, 7626, 7, 11, 8545, 7, 12, 5739, // 6,11
+6, 12, 39949, 6, 13, 8617, 7, 12, 10275, 7, 13, 6695, // 6,12
+6, 13, 36631, 6, 14, 9390, 7, 13, 11972, 7, 14, 7543, // 6,13
+6, 14, 33642, 6, 15, 9961, 7, 14, 13647, 7, 15, 8286, // 6,14
+6, 15, 30939, 6, 16, 10351, 7, 15, 15319, 7, 16, 8927, // 6,15
+6, 0, 15301, 6, 1, 8727, 7, 0, 31444, 7, 1, 10064, // 7, 0
+6, 1, 13582, 6, 2, 8068, 7, 1, 34261, 7, 2, 9625, // 7, 1
+6, 2, 11842, 6, 3, 7298, 7, 2, 37402, 7, 3, 8994, // 7, 2
+6, 3, 10051, 6, 4, 6403, 7, 3, 40940, 7, 4, 8142, // 7, 3
+6, 4, 8177, 6, 5, 5368, 7, 4, 44962, 7, 5, 7029, // 7, 4
+6, 5, 6183, 6, 6, 4172, 7, 5, 49566, 7, 6, 5615, // 7, 5
+6, 6, 4044, 6, 7, 2797, 7, 6, 54831, 7, 7, 3864, // 7, 6
+6, 7, 1903, 6, 8, 1347, 7, 7, 60382, 7, 8, 1904, // 7, 7
+7, 8, 60382, 7, 9, 1903, 8, 8, 1905, 8, 9, 1346, // 7, 8
+7, 9, 54839, 7, 10, 3853, 8, 9, 4049, 8, 10, 2795, // 7, 9
+7, 10, 49588, 7, 11, 5590, 8, 10, 6193, 8, 11, 4165, // 7,10
+7, 11, 44999, 7, 12, 6987, 8, 11, 8195, 8, 12, 5355, // 7,11
+7, 12, 40994, 7, 13, 8082, 8, 12, 10079, 8, 13, 6381, // 7,12
+7, 13, 37470, 7, 14, 8918, 8, 13, 11883, 8, 14, 7265, // 7,13
+7, 14, 34340, 7, 15, 9534, 8, 14, 13638, 8, 15, 8024, // 7,14
+7, 15, 31532, 7, 16, 9959, 8, 15, 15376, 8, 16, 8669, // 7,15
+7, -1, 8669, 7, 0, 15376, 8, -1, 9959, 8, 0, 31532, // 8, 0
+7, 0, 8024, 7, 1, 13638, 8, 0, 9534, 8, 1, 34340, // 8, 1
+7, 1, 7266, 7, 2, 11883, 8, 1, 8918, 8, 2, 37469, // 8, 2
+7, 2, 6381, 7, 3, 10079, 8, 2, 8082, 8, 3, 40994, // 8, 3
+7, 3, 5354, 7, 4, 8195, 8, 3, 6987, 8, 4, 45000, // 8, 4
+7, 4, 4164, 7, 5, 6193, 8, 4, 5590, 8, 5, 49589, // 8, 5
+7, 5, 2795, 7, 6, 4049, 8, 5, 3853, 8, 6, 54839, // 8, 6
+7, 6, 1347, 7, 7, 1905, 8, 6, 1903, 8, 7, 60381, // 8, 7
+8, 7, 1905, 8, 8, 60382, 9, 7, 1347, 9, 8, 1902, // 8, 8
+8, 8, 3864, 8, 9, 54831, 9, 8, 2797, 9, 9, 4044, // 8, 9
+8, 9, 5615, 8, 10, 49566, 9, 9, 4172, 9, 10, 6183, // 8,10
+8, 10, 7029, 8, 11, 44962, 9, 10, 5368, 9, 11, 8177, // 8,11
+8, 11, 8141, 8, 12, 40940, 9, 11, 6403, 9, 12, 10052, // 8,12
+8, 12, 8994, 8, 13, 37402, 9, 12, 7298, 9, 13, 11842, // 8,13
+8, 13, 9626, 8, 14, 34261, 9, 13, 8068, 9, 14, 13581, // 8,14
+8, 14, 10065, 8, 15, 31444, 9, 14, 8727, 9, 15, 15300, // 8,15
+8, -1, 8927, 8, 0, 15319, 9, -1, 10351, 9, 0, 30939, // 9, 0
+8, 0, 8286, 8, 1, 13647, 9, 0, 9961, 9, 1, 33642, // 9, 1
+8, 1, 7543, 8, 2, 11972, 9, 1, 9390, 9, 2, 36631, // 9, 2
+8, 2, 6695, 8, 3, 10275, 9, 2, 8617, 9, 3, 39949, // 9, 3
+8, 3, 5739, 8, 4, 8545, 9, 3, 7626, 9, 4, 43626, // 9, 4
+8, 4, 4690, 8, 5, 6794, 9, 4, 6422, 9, 5, 47630, // 9, 5
+8, 5, 3620, 8, 6, 5116, 9, 5, 5099, 9, 6, 51701, // 9, 6
+8, 6, 2797, 8, 7, 3864, 9, 6, 4044, 9, 7, 54831, // 9, 7
+9, 7, 4049, 9, 8, 54839, 10, 7, 2795, 10, 8, 3853, // 9, 8
+9, 8, 5116, 9, 9, 51701, 10, 8, 3620, 10, 9, 5099, // 9, 9
+9, 9, 6455, 9, 10, 47619, 10, 9, 4694, 10, 10, 6768, // 9,10
+9, 10, 7678, 9, 11, 43602, 10, 10, 5749, 10, 11, 8507, // 9,11
+9, 11, 8690, 9, 12, 39912, 10, 11, 6714, 10, 12, 10220, // 9,12
+9, 12, 9484, 9, 13, 36582, 10, 12, 7573, 10, 13, 11897, // 9,13
+9, 13, 10074, 9, 14, 33585, 10, 13, 8329, 10, 14, 13548, // 9,14
+9, 14, 10482, 9, 15, 30876, 10, 14, 8986, 10, 15, 15192, // 9,15
+9, -1, 9265, 9, 0, 15311, 10, -1, 10855, 10, 0, 30105, // 10, 0
+9, 0, 8645, 9, 1, 13740, 10, 0, 10528, 10, 1, 32623, // 10, 1
+9, 1, 7943, 9, 2, 12188, 10, 1, 10041, 10, 2, 35364, // 10, 2
+9, 2, 7165, 9, 3, 10653, 10, 2, 9388, 10, 3, 38330, // 10, 3
+9, 3, 6328, 9, 4, 9143, 10, 3, 8578, 10, 4, 41487, // 10, 4
+9, 4, 5472, 9, 5, 7705, 10, 4, 7659, 10, 5, 44700, // 10, 5
+9, 5, 4694, 9, 6, 6455, 10, 5, 6768, 10, 6, 47619, // 10, 6
+9, 6, 4172, 9, 7, 5615, 10, 6, 6183, 10, 7, 49566, // 10, 7
+10, 7, 6193, 10, 8, 49588, 11, 7, 4164, 11, 8, 5591, // 10, 8
+10, 8, 6794, 10, 9, 47630, 11, 8, 4690, 11, 9, 6422, // 10, 9
+10, 9, 7705, 10, 10, 44700, 11, 9, 5472, 11, 10, 7659, // 10,10
+10, 10, 8646, 10, 11, 41475, 11, 10, 6334, 11, 11, 9081, // 10,11
+10, 11, 9479, 10, 12, 38307, 11, 11, 7180, 11, 12, 10570, // 10,12
+10, 12, 10156, 10, 13, 35332, 11, 12, 7969, 11, 13, 12079, // 10,13
+10, 13, 10665, 10, 14, 32586, 11, 13, 8685, 11, 14, 13600, // 10,14
+10, 14, 11013, 10, 15, 30064, 11, 14, 9323, 11, 15, 15136, // 10,15
+10, -1, 9673, 10, 0, 15325, 11, -1, 11461, 11, 0, 29077, // 11, 0
+10, 0, 9082, 10, 1, 13875, 11, 0, 11218, 11, 1, 31361, // 11, 1
+10, 1, 8432, 10, 2, 12467, 11, 1, 10842, 11, 2, 33795, // 11, 2
+10, 2, 7737, 10, 3, 11108, 11, 2, 10337, 11, 3, 36354, // 11, 3
+10, 3, 7022, 10, 4, 9818, 11, 3, 9730, 11, 4, 38966, // 11, 4
+10, 4, 6334, 10, 5, 8646, 11, 4, 9081, 11, 5, 41475, // 11, 5
+10, 5, 5749, 10, 6, 7678, 11, 5, 8507, 11, 6, 43602, // 11, 6
+10, 6, 5368, 10, 7, 7029, 11, 6, 8177, 11, 7, 44962, // 11, 7
+11, 7, 8195, 11, 8, 44999, 12, 7, 5354, 12, 8, 6988, // 11, 8
+11, 8, 8545, 11, 9, 43626, 12, 8, 5739, 12, 9, 7626, // 11, 9
+11, 9, 9143, 11, 10, 41487, 12, 9, 6328, 12, 10, 8578, // 11,10
+11, 10, 9818, 11, 11, 38966, 12, 10, 7022, 12, 11, 9730, // 11,11
+11, 11, 10452, 11, 12, 36343, 12, 11, 7746, 12, 12, 10995, // 11,12
+11, 12, 10983, 11, 13, 33777, 12, 12, 8452, 12, 13, 12324, // 11,13
+11, 13, 11385, 11, 14, 31339, 12, 13, 9118, 12, 14, 13694, // 11,14
+11, 14, 11652, 11, 15, 29055, 12, 14, 9728, 12, 15, 15101, // 11,15
+11, -1, 10135, 11, 0, 15330, 12, -1, 12159, 12, 0, 27912, // 12, 0
+11, 0, 9575, 11, 1, 14009, 12, 0, 12014, 12, 1, 29938, // 12, 1
+11, 1, 8976, 11, 2, 12747, 12, 1, 11760, 12, 2, 32053, // 12, 2
+11, 2, 8358, 11, 3, 11554, 12, 2, 11411, 12, 3, 34213, // 12, 3
+11, 3, 7746, 11, 4, 10452, 12, 3, 10995, 12, 4, 36343, // 12, 4
+11, 4, 7180, 11, 5, 9479, 12, 4, 10569, 12, 5, 38308, // 12, 5
+11, 5, 6714, 11, 6, 8690, 12, 5, 10221, 12, 6, 39911, // 12, 6
+11, 6, 6403, 11, 7, 8141, 12, 6, 10051, 12, 7, 40941, // 12, 7
+12, 7, 10079, 12, 8, 40994, 13, 7, 6381, 13, 8, 8082, // 12, 8
+12, 8, 10275, 12, 9, 39949, 13, 8, 6695, 13, 9, 8617, // 12, 9
+12, 9, 10653, 12, 10, 38330, 13, 9, 7165, 13, 10, 9388, // 12,10
+12, 10, 11108, 12, 11, 36354, 13, 10, 7737, 13, 11, 10337, // 12,11
+12, 11, 11554, 12, 12, 34213, 13, 11, 8358, 13, 12, 11411, // 12,12
+12, 12, 11934, 12, 13, 32045, 13, 12, 8988, 13, 13, 12569, // 12,13
+12, 13, 12216, 12, 14, 29928, 13, 13, 9603, 13, 14, 13789, // 12,14
+12, 14, 12388, 12, 15, 27903, 13, 14, 10185, 13, 15, 15060, // 12,15
+12, -1, 10637, 12, 0, 15301, 13, -1, 12938, 13, 0, 26660, // 13, 0
+12, 0, 10102, 12, 1, 14107, 13, 0, 12897, 13, 1, 28430, // 13, 1
+12, 1, 9546, 12, 2, 12982, 13, 1, 12769, 13, 2, 30239, // 13, 2
+12, 2, 8988, 12, 3, 11934, 13, 2, 12569, 13, 3, 32045, // 13, 3
+12, 3, 8452, 12, 4, 10983, 13, 3, 12323, 13, 4, 33778, // 13, 4
+12, 4, 7969, 12, 5, 10156, 13, 4, 12079, 13, 5, 35332, // 13, 5
+12, 5, 7573, 12, 6, 9484, 13, 5, 11897, 13, 6, 36582, // 13, 6
+12, 6, 7298, 12, 7, 8994, 13, 6, 11842, 13, 7, 37402, // 13, 7
+13, 7, 11883, 13, 8, 37470, 14, 7, 7266, 14, 8, 8917, // 13, 8
+13, 8, 11972, 13, 9, 36631, 14, 8, 7543, 14, 9, 9390, // 13, 9
+13, 9, 12188, 13, 10, 35364, 14, 9, 7943, 14, 10, 10041, // 13,10
+13, 10, 12467, 13, 11, 33795, 14, 10, 8432, 14, 11, 10842, // 13,11
+13, 11, 12747, 13, 12, 32052, 14, 11, 8976, 14, 12, 11761, // 13,12
+13, 12, 12982, 13, 13, 30239, 14, 12, 9546, 14, 13, 12769, // 13,13
+13, 13, 13141, 13, 14, 28427, 14, 13, 10119, 14, 14, 13849, // 13,14
+13, 14, 13211, 13, 15, 26660, 14, 14, 10676, 14, 15, 14989, // 13,15
+13, -1, 11164, 13, 0, 15220, 14, -1, 13787, 14, 0, 25365, // 14, 0
+13, 0, 10644, 13, 1, 14145, 14, 0, 13853, 14, 1, 26894, // 14, 1
+13, 1, 10119, 13, 2, 13141, 14, 1, 13850, 14, 2, 28426, // 14, 2
+13, 2, 9603, 13, 3, 12216, 14, 2, 13789, 14, 3, 29928, // 14, 3
+13, 3, 9118, 13, 4, 11385, 14, 3, 13694, 14, 4, 31339, // 14, 4
+13, 4, 8685, 13, 5, 10665, 14, 4, 13600, 14, 5, 32586, // 14, 5
+13, 5, 8329, 13, 6, 10074, 14, 5, 13548, 14, 6, 33585, // 14, 6
+13, 6, 8068, 13, 7, 9626, 14, 6, 13582, 14, 7, 34260, // 14, 7
+14, 7, 13638, 14, 8, 34340, 15, 7, 8024, 15, 8, 9534, // 14, 8
+14, 8, 13647, 14, 9, 33642, 15, 8, 8286, 15, 9, 9961, // 14, 9
+14, 9, 13740, 14, 10, 32624, 15, 9, 8645, 15, 10, 10527, // 14,10
+14, 10, 13875, 14, 11, 31361, 15, 10, 9082, 15, 11, 11218, // 14,11
+14, 11, 14009, 14, 12, 29938, 15, 11, 9575, 15, 12, 12014, // 14,12
+14, 12, 14107, 14, 13, 28430, 15, 12, 10102, 15, 13, 12897, // 14,13
+14, 13, 14145, 14, 14, 26893, 15, 13, 10644, 15, 14, 13854, // 14,14
+14, 14, 14109, 14, 15, 25368, 15, 14, 11187, 15, 15, 14872, // 14,15
+14, -1, 11702, 14, 0, 15076, 15, -1, 14696, 15, 0, 24062, // 15, 0
+14, 0, 11187, 14, 1, 14109, 15, 0, 14872, 15, 1, 25368, // 15, 1
+14, 1, 10676, 14, 2, 13211, 15, 1, 14990, 15, 2, 26659, // 15, 2
+14, 2, 10185, 14, 3, 12388, 15, 2, 15060, 15, 3, 27903, // 15, 3
+14, 3, 9728, 14, 4, 11652, 15, 3, 15100, 15, 4, 29056, // 15, 4
+14, 4, 9323, 14, 5, 11013, 15, 4, 15135, 15, 5, 30065, // 15, 5
+14, 5, 8986, 14, 6, 10482, 15, 5, 15193, 15, 6, 30875, // 15, 6
+14, 6, 8727, 14, 7, 10065, 15, 6, 15301, 15, 7, 31443, // 15, 7
+15, 7, 15376, 15, 8, 31532, 16, 7, 8669, 16, 8, 9959, // 15, 8
+15, 8, 15319, 15, 9, 30939, 16, 8, 8927, 16, 9, 10351, // 15, 9
+15, 9, 15311, 15, 10, 30105, 16, 9, 9265, 16, 10, 10855, // 15,10
+15, 10, 15325, 15, 11, 29078, 16, 10, 9673, 16, 11, 11460, // 15,11
+15, 11, 15330, 15, 12, 27912, 16, 11, 10135, 16, 12, 12159, // 15,12
+15, 12, 15301, 15, 13, 26660, 16, 12, 10637, 16, 13, 12938, // 15,13
+15, 13, 15220, 15, 14, 25366, 16, 13, 11164, 16, 14, 13786, // 15,14
+15, 14, 15076, 15, 15, 24063, 16, 14, 11702, 16, 15, 14695, // 15,15
+// angle of -2.0 degrees
+-1, 0, 13368, -1, 1, 10104, 0, 0, 28495, 0, 1, 13569, // 0, 0
+-1, 1, 12574, -1, 2, 9662, 0, 1, 29831, 0, 2, 13469, // 0, 1
+-1, 2, 11829, -1, 3, 9229, 0, 2, 31146, 0, 3, 13332, // 0, 2
+-1, 3, 11143, -1, 4, 8816, 0, 3, 32406, 0, 4, 13171, // 0, 3
+-1, 4, 10528, -1, 5, 8438, 0, 4, 33564, 0, 5, 13006, // 0, 4
+-1, 5, 9995, -1, 6, 8107, 0, 5, 34567, 0, 6, 12867, // 0, 5
+-1, 6, 9558, -1, 7, 7839, 0, 6, 35362, 0, 7, 12777, // 0, 6
+-1, 7, 9224, -1, 8, 7643, 0, 7, 35905, 0, 8, 12764, // 0, 7
+0, 8, 35844, 0, 9, 12728, 1, 8, 9290, 1, 9, 7674, // 0, 8
+0, 9, 35315, 0, 10, 12717, 1, 9, 9635, 1, 10, 7869, // 0, 9
+0, 10, 34532, 0, 11, 12783, 1, 10, 10086, 1, 11, 8135, // 0,10
+0, 11, 33539, 0, 12, 12899, 1, 11, 10635, 1, 12, 8463, // 0,11
+0, 12, 32391, 0, 13, 13038, 1, 12, 11269, 1, 13, 8838, // 0,12
+0, 13, 31138, 0, 14, 13176, 1, 13, 11977, 1, 14, 9245, // 0,13
+0, 14, 29828, 0, 15, 13291, 1, 14, 12746, 1, 15, 9671, // 0,14
+0, 15, 28495, 0, 16, 13368, 1, 15, 13569, 1, 16, 10104, // 0,15
+0, 0, 13291, 0, 1, 9671, 1, 0, 29828, 1, 1, 12746, // 1, 0
+0, 1, 12412, 0, 2, 9202, 1, 1, 31358, 1, 2, 12564, // 1, 1
+0, 2, 11580, 0, 3, 8735, 1, 2, 32886, 1, 3, 12335, // 1, 2
+0, 3, 10808, 0, 4, 8284, 1, 3, 34369, 1, 4, 12075, // 1, 3
+0, 4, 10111, 0, 5, 7865, 1, 4, 35750, 1, 5, 11810, // 1, 4
+0, 5, 9509, 0, 6, 7497, 1, 5, 36955, 1, 6, 11575, // 1, 5
+0, 6, 9020, 0, 7, 7202, 1, 6, 37906, 1, 7, 11408, // 1, 6
+0, 7, 8662, 0, 8, 6997, 1, 7, 38534, 1, 8, 11343, // 1, 7
+1, 8, 38481, 1, 9, 11317, 2, 8, 8718, 2, 9, 7020, // 1, 8
+1, 9, 37866, 1, 10, 11360, 2, 9, 9086, 2, 10, 7224, // 1, 9
+1, 10, 36926, 1, 11, 11507, 2, 10, 9587, 2, 11, 7516, // 1,10
+1, 11, 35730, 1, 12, 11721, 2, 11, 10204, 2, 12, 7881, // 1,11
+1, 12, 34358, 1, 13, 11964, 2, 12, 10918, 2, 13, 8296, // 1,12
+1, 13, 32881, 1, 14, 12203, 2, 13, 11709, 2, 14, 8743, // 1,13
+1, 14, 31358, 1, 15, 12412, 2, 14, 12564, 2, 15, 9202, // 1,14
+1, 15, 29831, 1, 16, 12574, 2, 15, 13470, 2, 16, 9661, // 1,15
+1, 0, 13176, 1, 1, 9245, 2, 0, 31138, 2, 1, 11977, // 2, 0
+1, 1, 12203, 1, 2, 8742, 2, 1, 32881, 2, 2, 11710, // 2, 1
+1, 2, 11272, 1, 3, 8232, 2, 2, 34650, 2, 3, 11382, // 2, 2
+1, 3, 10397, 1, 4, 7728, 2, 3, 36399, 2, 4, 11012, // 2, 3
+1, 4, 9597, 1, 5, 7252, 2, 4, 38057, 2, 5, 10630, // 2, 4
+1, 5, 8902, 1, 6, 6829, 2, 5, 39526, 2, 6, 10279, // 2, 5
+1, 6, 8344, 1, 7, 6491, 2, 6, 40688, 2, 7, 10013, // 2, 6
+1, 7, 7951, 1, 8, 6266, 2, 7, 41432, 2, 8, 9887, // 2, 7
+2, 8, 41389, 2, 9, 9867, 3, 8, 7996, 3, 9, 6284, // 2, 8
+2, 9, 40656, 2, 10, 9977, 3, 9, 8397, 3, 10, 6506, // 2, 9
+2, 10, 39503, 2, 11, 10226, 3, 10, 8966, 3, 11, 6841, // 2,10
+2, 11, 38042, 2, 12, 10559, 3, 11, 9674, 3, 12, 7261, // 2,11
+2, 12, 36392, 2, 13, 10922, 3, 12, 10488, 3, 13, 7734, // 2,12
+2, 13, 34650, 2, 14, 11272, 3, 13, 11382, 3, 14, 8232, // 2,13
+2, 14, 32886, 2, 15, 11580, 3, 14, 12334, 3, 15, 8736, // 2,14
+2, 15, 31146, 2, 16, 11829, 3, 15, 13332, 3, 16, 9229, // 2,15
+2, 0, 13038, 2, 1, 8838, 3, 0, 32391, 3, 1, 11269, // 3, 0
+2, 1, 11964, 2, 2, 8296, 3, 1, 34358, 3, 2, 10918, // 3, 1
+2, 2, 10922, 2, 3, 7734, 3, 2, 36392, 3, 3, 10488, // 3, 2
+2, 3, 9924, 2, 4, 7164, 3, 3, 38450, 3, 4, 9998, // 3, 3
+2, 4, 8995, 2, 5, 6611, 3, 4, 40452, 3, 5, 9478, // 3, 4
+2, 5, 8175, 2, 6, 6108, 3, 5, 42271, 3, 6, 8982, // 3, 5
+2, 6, 7516, 2, 7, 5703, 3, 6, 43733, 3, 7, 8584, // 3, 6
+2, 7, 7072, 2, 8, 5443, 3, 7, 44649, 3, 8, 8372, // 3, 7
+3, 8, 44616, 3, 9, 8359, 4, 8, 7106, 4, 9, 5455, // 3, 8
+3, 9, 43710, 3, 10, 8558, 4, 9, 7556, 4, 10, 5712, // 3, 9
+3, 10, 42256, 3, 11, 8940, 4, 10, 8224, 4, 11, 6116, // 3,10
+3, 11, 40444, 3, 12, 9421, 4, 11, 9056, 4, 12, 6615, // 3,11
+3, 12, 38450, 3, 13, 9924, 4, 12, 9998, 4, 13, 7164, // 3,12
+3, 13, 36399, 3, 14, 10397, 4, 13, 11012, 4, 14, 7728, // 3,13
+3, 14, 34369, 3, 15, 10808, 4, 14, 12074, 4, 15, 8285, // 3,14
+3, 15, 32406, 3, 16, 11143, 4, 15, 13171, 4, 16, 8816, // 3,15
+3, 0, 12899, 3, 1, 8463, 4, 0, 33539, 4, 1, 10635, // 4, 0
+3, 1, 11721, 3, 2, 7881, 4, 1, 35730, 4, 2, 10204, // 4, 1
+3, 2, 10559, 3, 3, 7261, 4, 2, 38042, 4, 3, 9674, // 4, 2
+3, 3, 9421, 3, 4, 6615, 4, 3, 40444, 4, 4, 9056, // 4, 3
+3, 4, 8332, 3, 5, 5965, 4, 4, 42861, 4, 5, 8378, // 4, 4
+3, 5, 7342, 3, 6, 5350, 4, 5, 45146, 4, 6, 7698, // 4, 5
+3, 6, 6530, 3, 7, 4838, 4, 6, 47049, 4, 7, 7119, // 4, 6
+3, 7, 6000, 3, 8, 4513, 4, 7, 48240, 4, 8, 6783, // 4, 7
+4, 8, 48218, 4, 9, 6774, 5, 8, 6023, 5, 9, 4521, // 4, 8
+4, 9, 47035, 4, 10, 7100, 5, 9, 6558, 5, 10, 4843, // 4, 9
+4, 10, 45139, 4, 11, 7667, 5, 10, 7377, 5, 11, 5353, // 4,10
+4, 11, 42861, 4, 12, 8332, 5, 11, 8378, 5, 12, 5965, // 4,11
+4, 12, 40452, 4, 13, 8995, 5, 12, 9478, 5, 13, 6611, // 4,12
+4, 13, 38057, 4, 14, 9597, 5, 13, 10630, 5, 14, 7252, // 4,13
+4, 14, 35750, 4, 15, 10111, 5, 14, 11810, 5, 15, 7865, // 4,14
+4, 15, 33564, 4, 16, 10528, 5, 15, 13007, 5, 16, 8437, // 4,15
+4, 0, 12783, 4, 1, 8135, 5, 0, 34532, 5, 1, 10086, // 5, 0
+4, 1, 11507, 4, 2, 7517, 5, 1, 36926, 5, 2, 9586, // 5, 1
+4, 2, 10226, 4, 3, 6842, 5, 2, 39503, 5, 3, 8965, // 5, 2
+4, 3, 8940, 4, 4, 6116, 5, 3, 42256, 5, 4, 8224, // 5, 3
+4, 4, 7667, 4, 5, 5353, 5, 4, 45139, 5, 5, 7377, // 5, 4
+4, 5, 6451, 4, 6, 4591, 5, 5, 48019, 5, 6, 6475, // 5, 5
+4, 6, 5400, 4, 7, 3911, 5, 6, 50587, 5, 7, 5638, // 5, 6
+4, 7, 4708, 4, 8, 3466, 5, 7, 52266, 5, 8, 5096, // 5, 7
+5, 8, 52253, 5, 9, 5092, 6, 8, 4721, 6, 9, 3470, // 5, 8
+5, 9, 50581, 5, 10, 5624, 6, 9, 5418, 6, 10, 3913, // 5, 9
+5, 10, 48019, 5, 11, 6451, 6, 10, 6475, 6, 11, 4591, // 5,10
+5, 11, 45146, 5, 12, 7342, 6, 11, 7698, 6, 12, 5350, // 5,11
+5, 12, 42271, 5, 13, 8175, 6, 12, 8982, 6, 13, 6108, // 5,12
+5, 13, 39526, 5, 14, 8902, 6, 13, 10279, 6, 14, 6829, // 5,13
+5, 14, 36955, 5, 15, 9509, 6, 14, 11575, 6, 15, 7497, // 5,14
+5, 15, 34567, 5, 16, 9995, 6, 15, 12867, 6, 16, 8107, // 5,15
+5, 0, 12717, 5, 1, 7868, 6, 0, 35315, 6, 1, 9636, // 6, 0
+5, 1, 11360, 5, 2, 7224, 6, 1, 37866, 6, 2, 9086, // 6, 1
+5, 2, 9977, 5, 3, 6506, 6, 2, 40656, 6, 3, 8397, // 6, 2
+5, 3, 8558, 5, 4, 5712, 6, 3, 43710, 6, 4, 7556, // 6, 3
+5, 4, 7100, 5, 5, 4843, 6, 4, 47035, 6, 5, 6558, // 6, 4
+5, 5, 5624, 5, 6, 3913, 6, 5, 50581, 6, 6, 5418, // 6, 5
+5, 6, 4217, 5, 7, 2989, 6, 6, 54105, 6, 7, 4225, // 6, 6
+5, 7, 3180, 5, 8, 2294, 6, 7, 56756, 6, 8, 3306, // 6, 7
+6, 8, 56751, 6, 9, 3303, 7, 8, 3186, 7, 9, 2296, // 6, 8
+6, 9, 54105, 6, 10, 4217, 7, 9, 4225, 7, 10, 2989, // 6, 9
+6, 10, 50587, 6, 11, 5400, 7, 10, 5637, 7, 11, 3912, // 6,10
+6, 11, 47049, 6, 12, 6530, 7, 11, 7119, 7, 12, 4838, // 6,11
+6, 12, 43733, 6, 13, 7516, 7, 12, 8584, 7, 13, 5703, // 6,12
+6, 13, 40688, 6, 14, 8344, 7, 13, 10013, 7, 14, 6491, // 6,13
+6, 14, 37906, 6, 15, 9020, 7, 14, 11407, 7, 15, 7203, // 6,14
+6, 15, 35362, 6, 16, 9558, 7, 15, 12777, 7, 16, 7839, // 6,15
+6, 0, 12728, 6, 1, 7674, 7, 0, 35844, 7, 1, 9290, // 7, 0
+6, 1, 11317, 6, 2, 7020, 7, 1, 38481, 7, 2, 8718, // 7, 1
+6, 2, 9867, 6, 3, 6284, 7, 2, 41389, 7, 3, 7996, // 7, 2
+6, 3, 8359, 6, 4, 5454, 7, 3, 44616, 7, 4, 7107, // 7, 3
+6, 4, 6774, 6, 5, 4521, 7, 4, 48218, 7, 5, 6023, // 7, 4
+6, 5, 5092, 6, 6, 3470, 7, 5, 52253, 7, 6, 4721, // 7, 5
+6, 6, 3303, 6, 7, 2295, 7, 6, 56751, 7, 7, 3187, // 7, 6
+6, 7, 1541, 6, 8, 1090, 7, 7, 61364, 7, 8, 1541, // 7, 7
+7, 8, 61364, 7, 9, 1541, 8, 8, 1542, 8, 9, 1089, // 7, 8
+7, 9, 56756, 7, 10, 3180, 8, 9, 3306, 8, 10, 2294, // 7, 9
+7, 10, 52266, 7, 11, 4708, 8, 10, 5097, 8, 11, 3465, // 7,10
+7, 11, 48240, 7, 12, 6000, 8, 11, 6783, 8, 12, 4513, // 7,11
+7, 12, 44649, 7, 13, 7072, 8, 12, 8373, 8, 13, 5442, // 7,12
+7, 13, 41432, 7, 14, 7951, 8, 13, 9886, 8, 14, 6267, // 7,13
+7, 14, 38534, 7, 15, 8662, 8, 14, 11344, 8, 15, 6996, // 7,14
+7, 15, 35905, 7, 16, 9224, 8, 15, 12764, 8, 16, 7643, // 7,15
+7, -1, 7643, 7, 0, 12764, 8, -1, 9224, 8, 0, 35905, // 8, 0
+7, 0, 6997, 7, 1, 11344, 8, 0, 8662, 8, 1, 38533, // 8, 1
+7, 1, 6266, 7, 2, 9886, 8, 1, 7951, 8, 2, 41433, // 8, 2
+7, 2, 5443, 7, 3, 8373, 8, 2, 7072, 8, 3, 44648, // 8, 3
+7, 3, 4513, 7, 4, 6783, 8, 3, 6000, 8, 4, 48240, // 8, 4
+7, 4, 3466, 7, 5, 5097, 8, 4, 4708, 8, 5, 52265, // 8, 5
+7, 5, 2294, 7, 6, 3306, 8, 5, 3180, 8, 6, 56756, // 8, 6
+7, 6, 1090, 7, 7, 1542, 8, 6, 1541, 8, 7, 61363, // 8, 7
+8, 7, 1542, 8, 8, 61364, 9, 7, 1090, 9, 8, 1540, // 8, 8
+8, 8, 3186, 8, 9, 56751, 9, 8, 2295, 9, 9, 3304, // 8, 9
+8, 9, 4721, 8, 10, 52253, 9, 9, 3470, 9, 10, 5092, // 8,10
+8, 10, 6023, 8, 11, 48218, 9, 10, 4521, 9, 11, 6774, // 8,11
+8, 11, 7106, 8, 12, 44616, 9, 11, 5454, 9, 12, 8360, // 8,12
+8, 12, 7996, 8, 13, 41389, 9, 12, 6284, 9, 13, 9867, // 8,13
+8, 13, 8718, 8, 14, 38481, 9, 13, 7020, 9, 14, 11317, // 8,14
+8, 14, 9290, 8, 15, 35844, 9, 14, 7674, 9, 15, 12728, // 8,15
+8, -1, 7839, 8, 0, 12777, 9, -1, 9558, 9, 0, 35362, // 9, 0
+8, 0, 7202, 8, 1, 11407, 9, 0, 9020, 9, 1, 37907, // 9, 1
+8, 1, 6491, 8, 2, 10013, 9, 1, 8344, 9, 2, 40688, // 9, 2
+8, 2, 5703, 8, 3, 8584, 9, 2, 7516, 9, 3, 43733, // 9, 3
+8, 3, 4838, 8, 4, 7119, 9, 3, 6530, 9, 4, 47049, // 9, 4
+8, 4, 3911, 8, 5, 5637, 9, 4, 5400, 9, 5, 50588, // 9, 5
+8, 5, 2989, 8, 6, 4225, 9, 5, 4217, 9, 6, 54105, // 9, 6
+8, 6, 2295, 8, 7, 3186, 9, 6, 3303, 9, 7, 56752, // 9, 7
+9, 7, 3306, 9, 8, 56756, 10, 7, 2294, 10, 8, 3180, // 9, 8
+9, 8, 4225, 9, 9, 54105, 10, 8, 2989, 10, 9, 4217, // 9, 9
+9, 9, 5418, 9, 10, 50581, 10, 9, 3913, 10, 10, 5624, // 9,10
+9, 10, 6558, 9, 11, 47035, 10, 10, 4843, 10, 11, 7100, // 9,11
+9, 11, 7556, 9, 12, 43710, 10, 11, 5712, 10, 12, 8558, // 9,12
+9, 12, 8397, 9, 13, 40656, 10, 12, 6506, 10, 13, 9977, // 9,13
+9, 13, 9086, 9, 14, 37866, 10, 13, 7224, 10, 14, 11360, // 9,14
+9, 14, 9635, 9, 15, 35315, 10, 14, 7868, 10, 15, 12718, // 9,15
+9, -1, 8107, 9, 0, 12867, 10, -1, 9995, 10, 0, 34567, // 10, 0
+9, 0, 7497, 9, 1, 11575, 10, 0, 9509, 10, 1, 36955, // 10, 1
+9, 1, 6829, 9, 2, 10279, 10, 1, 8902, 10, 2, 39526, // 10, 2
+9, 2, 6108, 9, 3, 8982, 10, 2, 8175, 10, 3, 42271, // 10, 3
+9, 3, 5350, 9, 4, 7698, 10, 3, 7342, 10, 4, 45146, // 10, 4
+9, 4, 4591, 9, 5, 6475, 10, 4, 6451, 10, 5, 48019, // 10, 5
+9, 5, 3913, 9, 6, 5418, 10, 5, 5624, 10, 6, 50581, // 10, 6
+9, 6, 3470, 9, 7, 4721, 10, 6, 5092, 10, 7, 52253, // 10, 7
+10, 7, 5097, 10, 8, 52266, 11, 7, 3466, 11, 8, 4707, // 10, 8
+10, 8, 5637, 10, 9, 50587, 11, 8, 3911, 11, 9, 5401, // 10, 9
+10, 9, 6475, 10, 10, 48019, 11, 9, 4591, 11, 10, 6451, // 10,10
+10, 10, 7377, 10, 11, 45139, 11, 10, 5353, 11, 11, 7667, // 10,11
+10, 11, 8224, 10, 12, 42256, 11, 11, 6116, 11, 12, 8940, // 10,12
+10, 12, 8966, 10, 13, 39503, 11, 12, 6842, 11, 13, 10225, // 10,13
+10, 13, 9587, 10, 14, 36926, 11, 13, 7517, 11, 14, 11506, // 10,14
+10, 14, 10086, 10, 15, 34532, 11, 14, 8135, 11, 15, 12783, // 10,15
+10, -1, 8438, 10, 0, 13007, 11, -1, 10528, 11, 0, 33563, // 11, 0
+10, 0, 7865, 10, 1, 11810, 11, 0, 10111, 11, 1, 35750, // 11, 1
+10, 1, 7252, 10, 2, 10630, 11, 1, 9597, 11, 2, 38057, // 11, 2
+10, 2, 6611, 10, 3, 9478, 11, 2, 8995, 11, 3, 40452, // 11, 3
+10, 3, 5965, 10, 4, 8378, 11, 3, 8332, 11, 4, 42861, // 11, 4
+10, 4, 5353, 10, 5, 7377, 11, 4, 7667, 11, 5, 45139, // 11, 5
+10, 5, 4843, 10, 6, 6558, 11, 5, 7100, 11, 6, 47035, // 11, 6
+10, 6, 4521, 10, 7, 6023, 11, 6, 6774, 11, 7, 48218, // 11, 7
+11, 7, 6783, 11, 8, 48240, 12, 7, 4513, 12, 8, 6000, // 11, 8
+11, 8, 7119, 11, 9, 47049, 12, 8, 4838, 12, 9, 6530, // 11, 9
+11, 9, 7698, 11, 10, 45146, 12, 9, 5350, 12, 10, 7342, // 11,10
+11, 10, 8378, 11, 11, 42861, 12, 10, 5965, 12, 11, 8332, // 11,11
+11, 11, 9056, 11, 12, 40444, 12, 11, 6615, 12, 12, 9421, // 11,12
+11, 12, 9674, 11, 13, 38042, 12, 12, 7261, 12, 13, 10559, // 11,13
+11, 13, 10204, 11, 14, 35730, 12, 13, 7881, 12, 14, 11721, // 11,14
+11, 14, 10635, 11, 15, 33539, 12, 14, 8463, 12, 15, 12899, // 11,15
+11, -1, 8816, 11, 0, 13171, 12, -1, 11143, 12, 0, 32406, // 12, 0
+11, 0, 8284, 11, 1, 12074, 12, 0, 10808, 12, 1, 34370, // 12, 1
+11, 1, 7728, 11, 2, 11012, 12, 1, 10397, 12, 2, 36399, // 12, 2
+11, 2, 7164, 11, 3, 9998, 12, 2, 9924, 12, 3, 38450, // 12, 3
+11, 3, 6615, 11, 4, 9056, 12, 3, 9421, 12, 4, 40444, // 12, 4
+11, 4, 6116, 11, 5, 8224, 12, 4, 8940, 12, 5, 42256, // 12, 5
+11, 5, 5712, 11, 6, 7556, 12, 5, 8558, 12, 6, 43710, // 12, 6
+11, 6, 5454, 11, 7, 7106, 12, 6, 8359, 12, 7, 44617, // 12, 7
+12, 7, 8373, 12, 8, 44649, 13, 7, 5443, 13, 8, 7071, // 12, 8
+12, 8, 8584, 12, 9, 43733, 13, 8, 5703, 13, 9, 7516, // 12, 9
+12, 9, 8982, 12, 10, 42271, 13, 9, 6108, 13, 10, 8175, // 12,10
+12, 10, 9478, 12, 11, 40452, 13, 10, 6611, 13, 11, 8995, // 12,11
+12, 11, 9998, 12, 12, 38450, 13, 11, 7164, 13, 12, 9924, // 12,12
+12, 12, 10488, 12, 13, 36392, 13, 12, 7734, 13, 13, 10922, // 12,13
+12, 13, 10918, 12, 14, 34358, 13, 13, 8296, 13, 14, 11964, // 12,14
+12, 14, 11269, 12, 15, 32391, 13, 14, 8838, 13, 15, 13038, // 12,15
+12, -1, 9229, 12, 0, 13332, 13, -1, 11829, 13, 0, 31146, // 13, 0
+12, 0, 8735, 12, 1, 12334, 13, 0, 11580, 13, 1, 32887, // 13, 1
+12, 1, 8232, 12, 2, 11382, 13, 1, 11272, 13, 2, 34650, // 13, 2
+12, 2, 7734, 12, 3, 10488, 13, 2, 10922, 13, 3, 36392, // 13, 3
+12, 3, 7261, 12, 4, 9674, 13, 3, 10559, 13, 4, 38042, // 13, 4
+12, 4, 6842, 12, 5, 8966, 13, 4, 10226, 13, 5, 39502, // 13, 5
+12, 5, 6506, 12, 6, 8397, 13, 5, 9977, 13, 6, 40656, // 13, 6
+12, 6, 6284, 12, 7, 7996, 13, 6, 9867, 13, 7, 41389, // 13, 7
+13, 7, 9886, 13, 8, 41432, 14, 7, 6266, 14, 8, 7952, // 13, 8
+13, 8, 10013, 13, 9, 40688, 14, 8, 6491, 14, 9, 8344, // 13, 9
+13, 9, 10279, 13, 10, 39526, 14, 9, 6829, 14, 10, 8902, // 13,10
+13, 10, 10630, 13, 11, 38057, 14, 10, 7252, 14, 11, 9597, // 13,11
+13, 11, 11012, 13, 12, 36399, 14, 11, 7728, 14, 12, 10397, // 13,12
+13, 12, 11382, 13, 13, 34650, 14, 12, 8232, 14, 13, 11272, // 13,13
+13, 13, 11709, 13, 14, 32881, 14, 13, 8742, 14, 14, 12204, // 13,14
+13, 14, 11977, 13, 15, 31138, 14, 14, 9245, 14, 15, 13176, // 13,15
+13, -1, 9662, 13, 0, 13470, 14, -1, 12574, 14, 0, 29830, // 14, 0
+13, 0, 9202, 13, 1, 12564, 14, 0, 12412, 14, 1, 31358, // 14, 1
+13, 1, 8742, 13, 2, 11709, 14, 1, 12203, 14, 2, 32882, // 14, 2
+13, 2, 8296, 13, 3, 10918, 14, 2, 11964, 14, 3, 34358, // 14, 3
+13, 3, 7881, 13, 4, 10204, 14, 3, 11721, 14, 4, 35730, // 14, 4
+13, 4, 7517, 13, 5, 9587, 14, 4, 11507, 14, 5, 36925, // 14, 5
+13, 5, 7224, 13, 6, 9086, 14, 5, 11360, 14, 6, 37866, // 14, 6
+13, 6, 7020, 13, 7, 8718, 14, 6, 11317, 14, 7, 38481, // 14, 7
+14, 7, 11344, 14, 8, 38534, 15, 7, 6997, 15, 8, 8661, // 14, 8
+14, 8, 11407, 14, 9, 37906, 15, 8, 7202, 15, 9, 9021, // 14, 9
+14, 9, 11575, 14, 10, 36955, 15, 9, 7497, 15, 10, 9509, // 14,10
+14, 10, 11810, 14, 11, 35750, 15, 10, 7865, 15, 11, 10111, // 14,11
+14, 11, 12074, 14, 12, 34369, 15, 11, 8284, 15, 12, 10809, // 14,12
+14, 12, 12334, 14, 13, 32886, 15, 12, 8735, 15, 13, 11581, // 14,13
+14, 13, 12564, 14, 14, 31358, 15, 13, 9202, 15, 14, 12412, // 14,14
+14, 14, 12746, 14, 15, 29828, 15, 14, 9671, 15, 15, 13291, // 14,15
+14, -1, 10104, 14, 0, 13569, 15, -1, 13368, 15, 0, 28495, // 15, 0
+14, 0, 9671, 14, 1, 12746, 15, 0, 13291, 15, 1, 29828, // 15, 1
+14, 1, 9245, 14, 2, 11977, 15, 1, 13176, 15, 2, 31138, // 15, 2
+14, 2, 8838, 14, 3, 11269, 15, 2, 13038, 15, 3, 32391, // 15, 3
+14, 3, 8463, 14, 4, 10635, 15, 3, 12899, 15, 4, 33539, // 15, 4
+14, 4, 8135, 14, 5, 10086, 15, 4, 12783, 15, 5, 34532, // 15, 5
+14, 5, 7868, 14, 6, 9635, 15, 5, 12717, 15, 6, 35316, // 15, 6
+14, 6, 7674, 14, 7, 9290, 15, 6, 12728, 15, 7, 35844, // 15, 7
+15, 7, 12764, 15, 8, 35905, 16, 7, 7643, 16, 8, 9224, // 15, 8
+15, 8, 12777, 15, 9, 35362, 16, 8, 7839, 16, 9, 9558, // 15, 9
+15, 9, 12867, 15, 10, 34567, 16, 9, 8107, 16, 10, 9995, // 15,10
+15, 10, 13007, 15, 11, 33564, 16, 10, 8438, 16, 11, 10527, // 15,11
+15, 11, 13171, 15, 12, 32406, 16, 11, 8816, 16, 12, 11143, // 15,12
+15, 12, 13332, 15, 13, 31146, 16, 12, 9229, 16, 13, 11829, // 15,13
+15, 13, 13470, 15, 14, 29831, 16, 13, 9662, 16, 14, 12573, // 15,14
+15, 14, 13569, 15, 15, 28495, 16, 14, 10104, 16, 15, 13368, // 15,15
+// angle of -1.5 degrees
+-1, 0, 11440, -1, 1, 8358, 0, 0, 34212, 0, 1, 11526, // 0, 0
+-1, 1, 10780, -1, 2, 7983, 0, 1, 35506, 0, 2, 11267, // 0, 1
+-1, 2, 10158, -1, 3, 7620, 0, 2, 36764, 0, 3, 10994, // 0, 2
+-1, 3, 9585, -1, 4, 7276, 0, 3, 37951, 0, 4, 10724, // 0, 3
+-1, 4, 9072, -1, 5, 6965, 0, 4, 39026, 0, 5, 10473, // 0, 4
+-1, 5, 8632, -1, 6, 6699, 0, 5, 39940, 0, 6, 10265, // 0, 5
+-1, 6, 8278, -1, 7, 6489, 0, 6, 40646, 0, 7, 10123, // 0, 6
+-1, 7, 8018, -1, 8, 6346, 0, 7, 41106, 0, 8, 10066, // 0, 7
+0, 8, 41072, 0, 9, 10052, 1, 8, 8052, 1, 9, 6360, // 0, 8
+0, 9, 40618, 0, 10, 10100, 1, 9, 8316, 1, 10, 6502, // 0, 9
+0, 10, 39918, 0, 11, 10232, 1, 10, 8676, 1, 11, 6710, // 0,10
+0, 11, 39009, 0, 12, 10430, 1, 11, 9122, 1, 12, 6975, // 0,11
+0, 12, 37939, 0, 13, 10670, 1, 12, 9642, 1, 13, 7285, // 0,12
+0, 13, 36756, 0, 14, 10930, 1, 13, 10224, 1, 14, 7626, // 0,13
+0, 14, 35502, 0, 15, 11192, 1, 14, 10855, 1, 15, 7987, // 0,14
+0, 15, 34212, 0, 16, 11440, 1, 15, 11526, 1, 16, 8358, // 0,15
+0, 0, 11192, 0, 1, 7987, 1, 0, 35502, 1, 1, 10855, // 1, 0
+0, 1, 10467, 0, 2, 7579, 1, 1, 36959, 1, 2, 10531, // 1, 1
+0, 2, 9777, 0, 3, 7177, 1, 2, 38394, 1, 3, 10188, // 1, 2
+0, 3, 9135, 0, 4, 6792, 1, 3, 39767, 1, 4, 9842, // 1, 3
+0, 4, 8557, 0, 5, 6440, 1, 4, 41026, 1, 5, 9513, // 1, 4
+0, 5, 8061, 0, 6, 6137, 1, 5, 42105, 1, 6, 9233, // 1, 5
+0, 6, 7667, 0, 7, 5900, 1, 6, 42936, 1, 7, 9033, // 1, 6
+0, 7, 7390, 0, 8, 5745, 1, 7, 43461, 1, 8, 8940, // 1, 7
+1, 8, 43433, 1, 9, 8929, 2, 8, 7418, 2, 9, 5756, // 1, 8
+1, 9, 42913, 1, 10, 9014, 2, 9, 7699, 2, 10, 5910, // 1, 9
+1, 10, 42087, 1, 11, 9206, 2, 10, 8098, 2, 11, 6145, // 1,10
+1, 11, 41013, 1, 12, 9478, 2, 11, 8599, 2, 12, 6446, // 1,11
+1, 12, 39759, 1, 13, 9796, 2, 12, 9184, 2, 13, 6797, // 1,12
+1, 13, 38390, 1, 14, 10133, 2, 13, 9834, 2, 14, 7179, // 1,13
+1, 14, 36959, 1, 15, 10467, 2, 14, 10532, 2, 15, 7578, // 1,14
+1, 15, 35506, 1, 16, 10780, 2, 15, 11267, 2, 16, 7983, // 1,15
+1, 0, 10930, 1, 1, 7626, 2, 0, 36756, 2, 1, 10224, // 2, 0
+1, 1, 10133, 1, 2, 7179, 2, 1, 38390, 2, 2, 9834, // 2, 1
+1, 2, 9366, 1, 3, 6732, 2, 2, 40025, 2, 3, 9413, // 2, 2
+1, 3, 8641, 1, 4, 6297, 2, 3, 41618, 2, 4, 8980, // 2, 3
+1, 4, 7981, 1, 5, 5891, 2, 4, 43105, 2, 5, 8559, // 2, 4
+1, 5, 7411, 1, 6, 5537, 2, 5, 44399, 2, 6, 8189, // 2, 5
+1, 6, 6961, 1, 7, 5261, 2, 6, 45401, 2, 7, 7913, // 2, 6
+1, 7, 6658, 1, 8, 5087, 2, 7, 46017, 2, 8, 7774, // 2, 7
+2, 8, 45995, 2, 9, 7766, 3, 8, 6680, 3, 9, 5095, // 2, 8
+2, 9, 45383, 2, 10, 7899, 3, 9, 6986, 3, 10, 5268, // 2, 9
+2, 10, 44386, 2, 11, 8167, 3, 10, 7440, 3, 11, 5543, // 2,10
+2, 11, 43096, 2, 12, 8530, 3, 11, 8015, 3, 12, 5895, // 2,11
+2, 12, 41614, 2, 13, 8941, 3, 12, 8681, 3, 13, 6300, // 2,12
+2, 13, 40025, 2, 14, 9366, 3, 13, 9413, 3, 14, 6732, // 2,13
+2, 14, 38394, 2, 15, 9777, 3, 14, 10188, 3, 15, 7177, // 2,14
+2, 15, 36764, 2, 16, 10158, 3, 15, 10994, 3, 16, 7620, // 2,15
+2, 0, 10670, 2, 1, 7285, 3, 0, 37939, 3, 1, 9642, // 3, 0
+2, 1, 9796, 2, 2, 6797, 3, 1, 39759, 3, 2, 9184, // 3, 1
+2, 2, 8941, 2, 3, 6299, 3, 2, 41614, 3, 3, 8682, // 3, 2
+2, 3, 8120, 2, 4, 5804, 3, 3, 43461, 3, 4, 8151, // 3, 3
+2, 4, 7356, 2, 5, 5330, 3, 4, 45229, 3, 5, 7621, // 3, 4
+2, 5, 6685, 2, 6, 4906, 3, 5, 46806, 3, 6, 7139, // 3, 5
+2, 6, 6154, 2, 7, 4572, 3, 6, 48049, 3, 7, 6761, // 3, 6
+2, 7, 5811, 2, 8, 4366, 3, 7, 48801, 3, 8, 6558, // 3, 7
+3, 8, 48785, 3, 9, 6552, 4, 8, 5827, 4, 9, 4372, // 3, 8
+3, 9, 48037, 3, 10, 6750, 4, 9, 6173, 4, 10, 4576, // 3, 9
+3, 10, 46798, 3, 11, 7121, 4, 10, 6707, 4, 11, 4910, // 3,10
+3, 11, 45224, 3, 12, 7598, 4, 11, 7382, 4, 12, 5332, // 3,11
+3, 12, 43461, 3, 13, 8120, 4, 12, 8151, 4, 13, 5804, // 3,12
+3, 13, 41618, 3, 14, 8641, 4, 13, 8979, 4, 14, 6298, // 3,13
+3, 14, 39767, 3, 15, 9135, 4, 14, 9841, 4, 15, 6793, // 3,14
+3, 15, 37951, 3, 16, 9585, 4, 15, 10723, 4, 16, 7277, // 3,15
+3, 0, 10430, 3, 1, 6975, 4, 0, 39009, 4, 1, 9122, // 4, 0
+3, 1, 9478, 3, 2, 6447, 4, 1, 41013, 4, 2, 8598, // 4, 1
+3, 2, 8530, 3, 3, 5895, 4, 2, 43096, 4, 3, 8015, // 4, 2
+3, 3, 7598, 3, 4, 5331, 4, 3, 45224, 4, 4, 7383, // 4, 3
+3, 4, 6708, 3, 5, 4774, 4, 4, 47328, 4, 5, 6726, // 4, 4
+3, 5, 5901, 3, 6, 4257, 4, 5, 49279, 4, 6, 6099, // 4, 5
+3, 6, 5248, 3, 7, 3834, 4, 6, 50873, 4, 7, 5581, // 4, 6
+3, 7, 4835, 3, 8, 3575, 4, 7, 51842, 4, 8, 5284, // 4, 7
+4, 8, 51832, 4, 9, 5280, 5, 8, 4846, 5, 9, 3578, // 4, 8
+4, 9, 50865, 4, 10, 5573, 5, 9, 5261, 5, 10, 3837, // 4, 9
+4, 10, 49275, 4, 11, 6086, 5, 10, 5917, 5, 11, 4258, // 4,10
+4, 11, 47328, 4, 12, 6708, 5, 11, 6727, 5, 12, 4773, // 4,11
+4, 12, 45229, 4, 13, 7356, 5, 12, 7622, 5, 13, 5329, // 4,12
+4, 13, 43105, 4, 14, 7981, 5, 13, 8559, 5, 14, 5891, // 4,13
+4, 14, 41026, 4, 15, 8557, 5, 14, 9513, 5, 15, 6440, // 4,14
+4, 15, 39026, 4, 16, 9072, 5, 15, 10473, 5, 16, 6965, // 4,15
+4, 0, 10232, 4, 1, 6710, 5, 0, 39918, 5, 1, 8676, // 5, 0
+4, 1, 9206, 4, 2, 6145, 5, 1, 42087, 5, 2, 8098, // 5, 1
+4, 2, 8167, 4, 3, 5543, 5, 2, 44386, 5, 3, 7440, // 5, 2
+4, 3, 7121, 4, 4, 4909, 5, 3, 46798, 5, 4, 6708, // 5, 3
+4, 4, 6086, 4, 5, 4258, 5, 4, 49275, 5, 5, 5917, // 5, 4
+4, 5, 5103, 4, 6, 3621, 5, 5, 51700, 5, 6, 5112, // 5, 5
+4, 6, 4262, 4, 7, 3064, 5, 6, 53816, 5, 7, 4394, // 5, 6
+4, 7, 3720, 4, 8, 2708, 5, 7, 55168, 5, 8, 3940, // 5, 7
+5, 8, 55162, 5, 9, 3938, 6, 8, 3726, 6, 9, 2710, // 5, 8
+5, 9, 53813, 5, 10, 4388, 6, 9, 4269, 6, 10, 3066, // 5, 9
+5, 10, 51700, 5, 11, 5103, 6, 10, 5113, 6, 11, 3620, // 5,10
+5, 11, 49279, 5, 12, 5901, 6, 11, 6099, 6, 12, 4257, // 5,11
+5, 12, 46806, 5, 13, 6685, 6, 12, 7138, 6, 13, 4907, // 5,12
+5, 13, 44399, 5, 14, 7411, 6, 13, 8189, 6, 14, 5537, // 5,13
+5, 14, 42105, 5, 15, 8061, 6, 14, 9233, 6, 15, 6137, // 5,14
+5, 15, 39940, 5, 16, 8632, 6, 15, 10265, 6, 16, 6699, // 5,15
+5, 0, 10100, 5, 1, 6502, 6, 0, 40618, 6, 1, 8316, // 6, 0
+5, 1, 9014, 5, 2, 5910, 6, 1, 42913, 6, 2, 7699, // 6, 1
+5, 2, 7899, 5, 3, 5268, 6, 2, 45383, 6, 3, 6986, // 6, 2
+5, 3, 6750, 5, 4, 4576, 6, 3, 48037, 6, 4, 6173, // 6, 3
+5, 4, 5573, 5, 5, 3837, 6, 4, 50865, 6, 5, 5261, // 6, 4
+5, 5, 4388, 5, 6, 3065, 6, 5, 53813, 6, 6, 4270, // 6, 5
+5, 6, 3271, 5, 7, 2316, 6, 6, 56673, 6, 7, 3276, // 6, 6
+5, 7, 2462, 5, 8, 1766, 6, 7, 58775, 6, 8, 2533, // 6, 7
+6, 8, 58773, 6, 9, 2532, 7, 8, 2464, 7, 9, 1767, // 6, 8
+6, 9, 56673, 6, 10, 3271, 7, 9, 3275, 7, 10, 2317, // 6, 9
+6, 10, 53816, 6, 11, 4262, 7, 10, 4394, 7, 11, 3064, // 6,10
+6, 11, 50873, 6, 12, 5248, 7, 11, 5581, 7, 12, 3834, // 6,11
+6, 12, 48049, 6, 13, 6154, 7, 12, 6761, 7, 13, 4572, // 6,12
+6, 13, 45401, 6, 14, 6961, 7, 13, 7913, 7, 14, 5261, // 6,13
+6, 14, 42936, 6, 15, 7667, 7, 14, 9032, 7, 15, 5901, // 6,14
+6, 15, 40646, 6, 16, 8278, 7, 15, 10123, 7, 16, 6489, // 6,15
+6, 0, 10052, 6, 1, 6360, 7, 0, 41072, 7, 1, 8052, // 7, 0
+6, 1, 8929, 6, 2, 5756, 7, 1, 43433, 7, 2, 7418, // 7, 1
+6, 2, 7766, 6, 3, 5095, 7, 2, 45995, 7, 3, 6680, // 7, 2
+6, 3, 6552, 6, 4, 4372, 7, 3, 48785, 7, 4, 5827, // 7, 3
+6, 4, 5280, 6, 5, 3579, 7, 4, 51832, 7, 5, 4845, // 7, 4
+6, 5, 3938, 6, 6, 2710, 7, 5, 55162, 7, 6, 3726, // 7, 5
+6, 6, 2532, 6, 7, 1767, 7, 6, 58773, 7, 7, 2464, // 7, 6
+6, 7, 1170, 6, 8, 827, 7, 7, 62369, 7, 8, 1170, // 7, 7
+7, 8, 62369, 7, 9, 1170, 8, 8, 1170, 8, 9, 827, // 7, 8
+7, 9, 58775, 7, 10, 2462, 8, 9, 2533, 8, 10, 1766, // 7, 9
+7, 10, 55168, 7, 11, 3720, 8, 10, 3940, 8, 11, 2708, // 7,10
+7, 11, 51842, 7, 12, 4835, 8, 11, 5283, 8, 12, 3576, // 7,11
+7, 12, 48801, 7, 13, 5811, 8, 12, 6558, 8, 13, 4366, // 7,12
+7, 13, 46017, 7, 14, 6658, 8, 13, 7773, 8, 14, 5088, // 7,13
+7, 14, 43461, 7, 15, 7390, 8, 14, 8939, 8, 15, 5746, // 7,14
+7, 15, 41106, 7, 16, 8018, 8, 15, 10066, 8, 16, 6346, // 7,15
+7, -1, 6346, 7, 0, 10066, 8, -1, 8018, 8, 0, 41106, // 8, 0
+7, 0, 5745, 7, 1, 8939, 8, 0, 7390, 8, 1, 43462, // 8, 1
+7, 1, 5087, 7, 2, 7773, 8, 1, 6658, 8, 2, 46018, // 8, 2
+7, 2, 4366, 7, 3, 6558, 8, 2, 5811, 8, 3, 48801, // 8, 3
+7, 3, 3575, 7, 4, 5283, 8, 3, 4835, 8, 4, 51843, // 8, 4
+7, 4, 2708, 7, 5, 3940, 8, 4, 3720, 8, 5, 55168, // 8, 5
+7, 5, 1766, 7, 6, 2533, 8, 5, 2462, 8, 6, 58775, // 8, 6
+7, 6, 827, 7, 7, 1170, 8, 6, 1170, 8, 7, 62369, // 8, 7
+8, 7, 1170, 8, 8, 62369, 9, 7, 827, 9, 8, 1170, // 8, 8
+8, 8, 2464, 8, 9, 58773, 9, 8, 1767, 9, 9, 2532, // 8, 9
+8, 9, 3726, 8, 10, 55162, 9, 9, 2710, 9, 10, 3938, // 8,10
+8, 10, 4846, 8, 11, 51832, 9, 10, 3579, 9, 11, 5279, // 8,11
+8, 11, 5827, 8, 12, 48785, 9, 11, 4372, 9, 12, 6552, // 8,12
+8, 12, 6680, 8, 13, 45995, 9, 12, 5095, 9, 13, 7766, // 8,13
+8, 13, 7418, 8, 14, 43433, 9, 13, 5756, 9, 14, 8929, // 8,14
+8, 14, 8052, 8, 15, 41072, 9, 14, 6360, 9, 15, 10052, // 8,15
+8, -1, 6489, 8, 0, 10123, 9, -1, 8278, 9, 0, 40646, // 9, 0
+8, 0, 5900, 8, 1, 9032, 9, 0, 7667, 9, 1, 42937, // 9, 1
+8, 1, 5261, 8, 2, 7913, 9, 1, 6961, 9, 2, 45401, // 9, 2
+8, 2, 4572, 8, 3, 6761, 9, 2, 6154, 9, 3, 48049, // 9, 3
+8, 3, 3834, 8, 4, 5581, 9, 3, 5248, 9, 4, 50873, // 9, 4
+8, 4, 3064, 8, 5, 4394, 9, 4, 4262, 9, 5, 53816, // 9, 5
+8, 5, 2316, 8, 6, 3275, 9, 5, 3271, 9, 6, 56674, // 9, 6
+8, 6, 1767, 8, 7, 2464, 9, 6, 2532, 9, 7, 58773, // 9, 7
+9, 7, 2533, 9, 8, 58775, 10, 7, 1766, 10, 8, 2462, // 9, 8
+9, 8, 3275, 9, 9, 56673, 10, 8, 2316, 10, 9, 3272, // 9, 9
+9, 9, 4269, 9, 10, 53813, 10, 9, 3065, 10, 10, 4389, // 9,10
+9, 10, 5261, 9, 11, 50865, 10, 10, 3837, 10, 11, 5573, // 9,11
+9, 11, 6173, 9, 12, 48037, 10, 11, 4576, 10, 12, 6750, // 9,12
+9, 12, 6986, 9, 13, 45383, 10, 12, 5268, 10, 13, 7899, // 9,13
+9, 13, 7699, 9, 14, 42913, 10, 13, 5910, 10, 14, 9014, // 9,14
+9, 14, 8316, 9, 15, 40618, 10, 14, 6502, 10, 15, 10100, // 9,15
+9, -1, 6699, 9, 0, 10265, 10, -1, 8632, 10, 0, 39940, // 10, 0
+9, 0, 6137, 9, 1, 9233, 10, 0, 8061, 10, 1, 42105, // 10, 1
+9, 1, 5537, 9, 2, 8189, 10, 1, 7411, 10, 2, 44399, // 10, 2
+9, 2, 4906, 9, 3, 7138, 10, 2, 6685, 10, 3, 46807, // 10, 3
+9, 3, 4257, 9, 4, 6099, 10, 3, 5901, 10, 4, 49279, // 10, 4
+9, 4, 3621, 9, 5, 5113, 10, 4, 5103, 10, 5, 51699, // 10, 5
+9, 5, 3065, 9, 6, 4269, 10, 5, 4388, 10, 6, 53814, // 10, 6
+9, 6, 2710, 9, 7, 3726, 10, 6, 3938, 10, 7, 55162, // 10, 7
+10, 7, 3940, 10, 8, 55168, 11, 7, 2708, 11, 8, 3720, // 10, 8
+10, 8, 4394, 10, 9, 53816, 11, 8, 3064, 11, 9, 4262, // 10, 9
+10, 9, 5113, 10, 10, 51700, 11, 9, 3621, 11, 10, 5102, // 10,10
+10, 10, 5917, 10, 11, 49275, 11, 10, 4258, 11, 11, 6086, // 10,11
+10, 11, 6707, 10, 12, 46798, 11, 11, 4909, 11, 12, 7122, // 10,12
+10, 12, 7440, 10, 13, 44386, 11, 12, 5543, 11, 13, 8167, // 10,13
+10, 13, 8098, 10, 14, 42087, 11, 13, 6145, 11, 14, 9206, // 10,14
+10, 14, 8676, 10, 15, 39918, 11, 14, 6710, 11, 15, 10232, // 10,15
+10, -1, 6965, 10, 0, 10473, 11, -1, 9072, 11, 0, 39026, // 11, 0
+10, 0, 6440, 10, 1, 9513, 11, 0, 8557, 11, 1, 41026, // 11, 1
+10, 1, 5891, 10, 2, 8559, 11, 1, 7981, 11, 2, 43105, // 11, 2
+10, 2, 5330, 10, 3, 7622, 11, 2, 7356, 11, 3, 45228, // 11, 3
+10, 3, 4774, 10, 4, 6727, 11, 3, 6708, 11, 4, 47327, // 11, 4
+10, 4, 4258, 10, 5, 5917, 11, 4, 6086, 11, 5, 49275, // 11, 5
+10, 5, 3837, 10, 6, 5261, 11, 5, 5573, 11, 6, 50865, // 11, 6
+10, 6, 3579, 10, 7, 4846, 11, 6, 5280, 11, 7, 51831, // 11, 7
+11, 7, 5283, 11, 8, 51842, 12, 7, 3575, 12, 8, 4836, // 11, 8
+11, 8, 5581, 11, 9, 50873, 12, 8, 3834, 12, 9, 5248, // 11, 9
+11, 9, 6099, 11, 10, 49279, 12, 9, 4257, 12, 10, 5901, // 11,10
+11, 10, 6727, 11, 11, 47328, 12, 10, 4774, 12, 11, 6707, // 11,11
+11, 11, 7382, 11, 12, 45224, 12, 11, 5331, 12, 12, 7599, // 11,12
+11, 12, 8015, 11, 13, 43096, 12, 12, 5895, 12, 13, 8530, // 11,13
+11, 13, 8599, 11, 14, 41013, 12, 13, 6447, 12, 14, 9477, // 11,14
+11, 14, 9122, 11, 15, 39009, 12, 14, 6975, 12, 15, 10430, // 11,15
+11, -1, 7276, 11, 0, 10723, 12, -1, 9585, 12, 0, 37952, // 12, 0
+11, 0, 6792, 11, 1, 9841, 12, 0, 9135, 12, 1, 39768, // 12, 1
+11, 1, 6297, 11, 2, 8979, 12, 1, 8641, 12, 2, 41619, // 12, 2
+11, 2, 5804, 11, 3, 8151, 12, 2, 8120, 12, 3, 43461, // 12, 3
+11, 3, 5331, 11, 4, 7382, 12, 3, 7598, 12, 4, 45225, // 12, 4
+11, 4, 4909, 11, 5, 6707, 12, 4, 7121, 12, 5, 46799, // 12, 5
+11, 5, 4576, 11, 6, 6173, 12, 5, 6750, 12, 6, 48037, // 12, 6
+11, 6, 4372, 11, 7, 5827, 12, 6, 6552, 12, 7, 48785, // 12, 7
+12, 7, 6558, 12, 8, 48801, 13, 7, 4366, 13, 8, 5811, // 12, 8
+12, 8, 6761, 12, 9, 48049, 13, 8, 4572, 13, 9, 6154, // 12, 9
+12, 9, 7138, 12, 10, 46806, 13, 9, 4906, 13, 10, 6686, // 12,10
+12, 10, 7622, 12, 11, 45229, 13, 10, 5330, 13, 11, 7355, // 12,11
+12, 11, 8151, 12, 12, 43461, 13, 11, 5804, 13, 12, 8120, // 12,12
+12, 12, 8681, 12, 13, 41614, 13, 12, 6299, 13, 13, 8942, // 12,13
+12, 13, 9184, 12, 14, 39759, 13, 13, 6797, 13, 14, 9796, // 12,14
+12, 14, 9642, 12, 15, 37939, 13, 14, 7285, 13, 15, 10670, // 12,15
+12, -1, 7620, 12, 0, 10994, 13, -1, 10158, 13, 0, 36764, // 13, 0
+12, 0, 7177, 12, 1, 10188, 13, 0, 9777, 13, 1, 38394, // 13, 1
+12, 1, 6732, 12, 2, 9413, 13, 1, 9366, 13, 2, 40025, // 13, 2
+12, 2, 6299, 12, 3, 8681, 13, 2, 8941, 13, 3, 41615, // 13, 3
+12, 3, 5895, 12, 4, 8015, 13, 3, 8530, 13, 4, 43096, // 13, 4
+12, 4, 5543, 12, 5, 7440, 13, 4, 8167, 13, 5, 44386, // 13, 5
+12, 5, 5268, 12, 6, 6986, 13, 5, 7899, 13, 6, 45383, // 13, 6
+12, 6, 5095, 12, 7, 6680, 13, 6, 7766, 13, 7, 45995, // 13, 7
+13, 7, 7773, 13, 8, 46017, 14, 7, 5087, 14, 8, 6659, // 13, 8
+13, 8, 7913, 13, 9, 45401, 14, 8, 5261, 14, 9, 6961, // 13, 9
+13, 9, 8189, 13, 10, 44399, 14, 9, 5537, 14, 10, 7411, // 13,10
+13, 10, 8559, 13, 11, 43105, 14, 10, 5891, 14, 11, 7981, // 13,11
+13, 11, 8979, 13, 12, 41618, 14, 11, 6297, 14, 12, 8642, // 13,12
+13, 12, 9413, 13, 13, 40025, 14, 12, 6732, 14, 13, 9366, // 13,13
+13, 13, 9834, 13, 14, 38390, 14, 13, 7179, 14, 14, 10133, // 13,14
+13, 14, 10224, 13, 15, 36756, 14, 14, 7626, 14, 15, 10930, // 13,15
+13, -1, 7983, 13, 0, 11267, 14, -1, 10780, 14, 0, 35506, // 14, 0
+13, 0, 7579, 13, 1, 10532, 14, 0, 10467, 14, 1, 36958, // 14, 1
+13, 1, 7179, 13, 2, 9834, 14, 1, 10133, 14, 2, 38390, // 14, 2
+13, 2, 6797, 13, 3, 9184, 14, 2, 9796, 14, 3, 39759, // 14, 3
+13, 3, 6447, 13, 4, 8599, 14, 3, 9478, 14, 4, 41012, // 14, 4
+13, 4, 6145, 13, 5, 8098, 14, 4, 9206, 14, 5, 42087, // 14, 5
+13, 5, 5910, 13, 6, 7699, 14, 5, 9014, 14, 6, 42913, // 14, 6
+13, 6, 5756, 13, 7, 7418, 14, 6, 8929, 14, 7, 43433, // 14, 7
+14, 7, 8939, 14, 8, 43461, 15, 7, 5745, 15, 8, 7391, // 14, 8
+14, 8, 9032, 14, 9, 42936, 15, 8, 5900, 15, 9, 7668, // 14, 9
+14, 9, 9233, 14, 10, 42105, 15, 9, 6137, 15, 10, 8061, // 14,10
+14, 10, 9513, 14, 11, 41026, 15, 10, 6440, 15, 11, 8557, // 14,11
+14, 11, 9841, 14, 12, 39767, 15, 11, 6792, 15, 12, 9136, // 14,12
+14, 12, 10188, 14, 13, 38394, 15, 12, 7177, 15, 13, 9777, // 14,13
+14, 13, 10532, 14, 14, 36959, 15, 13, 7579, 15, 14, 10466, // 14,14
+14, 14, 10855, 14, 15, 35502, 15, 14, 7987, 15, 15, 11192, // 14,15
+14, -1, 8358, 14, 0, 11526, 15, -1, 11440, 15, 0, 34212, // 15, 0
+14, 0, 7987, 14, 1, 10855, 15, 0, 11192, 15, 1, 35502, // 15, 1
+14, 1, 7626, 14, 2, 10224, 15, 1, 10930, 15, 2, 36756, // 15, 2
+14, 2, 7285, 14, 3, 9642, 15, 2, 10670, 15, 3, 37939, // 15, 3
+14, 3, 6975, 14, 4, 9122, 15, 3, 10430, 15, 4, 39009, // 15, 4
+14, 4, 6710, 14, 5, 8676, 15, 4, 10232, 15, 5, 39918, // 15, 5
+14, 5, 6502, 14, 6, 8316, 15, 5, 10100, 15, 6, 40618, // 15, 6
+14, 6, 6360, 14, 7, 8052, 15, 6, 10052, 15, 7, 41072, // 15, 7
+15, 7, 10066, 15, 8, 41106, 16, 7, 6346, 16, 8, 8018, // 15, 8
+15, 8, 10123, 15, 9, 40646, 16, 8, 6489, 16, 9, 8278, // 15, 9
+15, 9, 10265, 15, 10, 39940, 16, 9, 6699, 16, 10, 8632, // 15,10
+15, 10, 10473, 15, 11, 39026, 16, 10, 6965, 16, 11, 9072, // 15,11
+15, 11, 10723, 15, 12, 37951, 16, 11, 7276, 16, 12, 9586, // 15,12
+15, 12, 10994, 15, 13, 36764, 16, 12, 7620, 16, 13, 10158, // 15,13
+15, 13, 11267, 15, 14, 35506, 16, 13, 7983, 16, 14, 10780, // 15,14
+15, 14, 11526, 15, 15, 34212, 16, 14, 8358, 16, 15, 11440, // 15,15
+// angle of -1.0 degrees
+-1, 0, 8769, -1, 1, 6280, 0, 0, 41693, 0, 1, 8794, // 0, 0
+-1, 1, 8265, -1, 2, 5974, 0, 1, 42823, 0, 2, 8474, // 0, 1
+-1, 2, 7791, -1, 3, 5682, 0, 2, 43904, 0, 3, 8159, // 0, 2
+-1, 3, 7356, -1, 4, 5410, 0, 3, 44907, 0, 4, 7863, // 0, 3
+-1, 4, 6970, -1, 5, 5169, 0, 4, 45799, 0, 5, 7598, // 0, 4
+-1, 5, 6644, -1, 6, 4967, 0, 5, 46541, 0, 6, 7384, // 0, 5
+-1, 6, 6391, -1, 7, 4814, 0, 6, 47098, 0, 7, 7233, // 0, 6
+-1, 7, 6217, -1, 8, 4718, 0, 7, 47440, 0, 8, 7161, // 0, 7
+0, 8, 47426, 0, 9, 7158, 1, 8, 6230, 1, 9, 4722, // 0, 8
+0, 9, 47086, 0, 10, 7227, 1, 9, 6405, 1, 10, 4818, // 0, 9
+0, 10, 46532, 0, 11, 7374, 1, 10, 6659, 1, 11, 4971, // 0,10
+0, 11, 45791, 0, 12, 7587, 1, 11, 6986, 1, 12, 5172, // 0,11
+0, 12, 44901, 0, 13, 7848, 1, 12, 7374, 1, 13, 5413, // 0,12
+0, 13, 43900, 0, 14, 8141, 1, 13, 7812, 1, 14, 5683, // 0,13
+0, 14, 42821, 0, 15, 8452, 1, 14, 8288, 1, 15, 5975, // 0,14
+0, 15, 41693, 0, 16, 8769, 1, 15, 8795, 1, 16, 6279, // 0,15
+0, 0, 8452, 0, 1, 5975, 1, 0, 42821, 1, 1, 8288, // 1, 0
+0, 1, 7901, 0, 2, 5640, 1, 1, 44074, 1, 2, 7921, // 1, 1
+0, 2, 7378, 0, 3, 5315, 1, 2, 45288, 1, 3, 7555, // 1, 2
+0, 3, 6892, 0, 4, 5009, 1, 3, 46430, 1, 4, 7205, // 1, 3
+0, 4, 6458, 0, 5, 4734, 1, 4, 47458, 1, 5, 6886, // 1, 4
+0, 5, 6092, 0, 6, 4502, 1, 5, 48322, 1, 6, 6620, // 1, 5
+0, 6, 5809, 0, 7, 4327, 1, 6, 48969, 1, 7, 6431, // 1, 6
+0, 7, 5623, 0, 8, 4221, 1, 7, 49358, 1, 8, 6334, // 1, 7
+1, 8, 49347, 1, 9, 6332, 2, 8, 5633, 2, 9, 4224, // 1, 8
+1, 9, 48960, 1, 10, 6425, 2, 9, 5820, 2, 10, 4331, // 1, 9
+1, 10, 48314, 1, 11, 6613, 2, 10, 6104, 2, 11, 4505, // 1,10
+1, 11, 47453, 1, 12, 6875, 2, 11, 6472, 2, 12, 4736, // 1,11
+1, 12, 46427, 1, 13, 7191, 2, 12, 6908, 2, 13, 5010, // 1,12
+1, 13, 45286, 1, 14, 7539, 2, 13, 7395, 2, 14, 5316, // 1,13
+1, 14, 44074, 1, 15, 7901, 2, 14, 7921, 2, 15, 5640, // 1,14
+1, 15, 42823, 1, 16, 8265, 2, 15, 8474, 2, 16, 5974, // 1,15
+1, 0, 8141, 1, 1, 5684, 2, 0, 43900, 2, 1, 7811, // 2, 0
+1, 1, 7539, 1, 2, 5316, 2, 1, 45286, 2, 2, 7395, // 2, 1
+1, 2, 6959, 1, 3, 4954, 2, 2, 46650, 2, 3, 6973, // 2, 2
+1, 3, 6414, 1, 4, 4607, 2, 3, 47955, 2, 4, 6560, // 2, 3
+1, 4, 5920, 1, 5, 4290, 2, 4, 49150, 2, 5, 6176, // 2, 4
+1, 5, 5499, 1, 6, 4019, 2, 5, 50171, 2, 6, 5847, // 2, 5
+1, 6, 5175, 1, 7, 3813, 2, 6, 50942, 2, 7, 5606, // 2, 6
+1, 7, 4970, 1, 8, 3691, 2, 7, 51395, 2, 8, 5480, // 2, 7
+2, 8, 51387, 2, 9, 5478, 3, 8, 4978, 3, 9, 3693, // 2, 8
+2, 9, 50935, 2, 10, 5602, 3, 9, 5184, 3, 10, 3815, // 2, 9
+2, 10, 50165, 2, 11, 5842, 3, 10, 5508, 3, 11, 4021, // 2,10
+2, 11, 49147, 2, 12, 6168, 3, 11, 5930, 3, 12, 4291, // 2,11
+2, 12, 47953, 2, 13, 6549, 3, 12, 6426, 3, 13, 4608, // 2,12
+2, 13, 46650, 2, 14, 6959, 3, 13, 6973, 3, 14, 4954, // 2,13
+2, 14, 45288, 2, 15, 7378, 3, 14, 7555, 3, 15, 5315, // 2,14
+2, 15, 43904, 2, 16, 7791, 3, 15, 8159, 3, 16, 5682, // 2,15
+2, 0, 7848, 2, 1, 5413, 3, 0, 44901, 3, 1, 7374, // 3, 0
+2, 1, 7191, 2, 2, 5011, 3, 1, 46427, 3, 2, 6907, // 3, 1
+2, 2, 6549, 2, 3, 4608, 3, 2, 47953, 3, 3, 6426, // 3, 2
+2, 3, 5934, 2, 4, 4214, 3, 3, 49445, 3, 4, 5943, // 3, 3
+2, 4, 5365, 2, 5, 3845, 3, 4, 50844, 3, 5, 5482, // 3, 4
+2, 5, 4872, 2, 6, 3522, 3, 5, 52069, 3, 6, 5073, // 3, 5
+2, 6, 4489, 2, 7, 3273, 3, 6, 53012, 3, 7, 4762, // 3, 6
+2, 7, 4254, 2, 8, 3126, 3, 7, 53562, 3, 8, 4594, // 3, 7
+3, 8, 53557, 3, 9, 4592, 4, 8, 4259, 4, 9, 3128, // 3, 8
+3, 9, 53008, 3, 10, 4759, 4, 9, 4495, 4, 10, 3274, // 3, 9
+3, 10, 52066, 3, 11, 5069, 4, 10, 4879, 4, 11, 3522, // 3,10
+3, 11, 50843, 3, 12, 5474, 4, 11, 5373, 4, 12, 3846, // 3,11
+3, 12, 49445, 3, 13, 5934, 4, 12, 5943, 4, 13, 4214, // 3,12
+3, 13, 47955, 3, 14, 6414, 4, 13, 6560, 4, 14, 4607, // 3,13
+3, 14, 46430, 3, 15, 6892, 4, 14, 7204, 4, 15, 5010, // 3,14
+3, 15, 44907, 3, 16, 7356, 4, 15, 7863, 4, 16, 5410, // 3,15
+3, 0, 7587, 3, 1, 5172, 4, 0, 45791, 4, 1, 6986, // 4, 0
+3, 1, 6875, 3, 2, 4736, 4, 1, 47453, 4, 2, 6472, // 4, 1
+3, 2, 6168, 3, 3, 4291, 4, 2, 49147, 4, 3, 5930, // 4, 2
+3, 3, 5474, 3, 4, 3846, 4, 3, 50843, 4, 4, 5373, // 4, 3
+3, 4, 4816, 3, 5, 3415, 4, 4, 52484, 4, 5, 4821, // 4, 4
+3, 5, 4226, 3, 6, 3023, 4, 5, 53975, 4, 6, 4312, // 4, 5
+3, 6, 3755, 3, 7, 2710, 4, 6, 55166, 4, 7, 3905, // 4, 6
+3, 7, 3469, 3, 8, 2524, 4, 7, 55870, 4, 8, 3673, // 4, 7
+4, 8, 55867, 4, 9, 3671, 5, 8, 3473, 5, 9, 2525, // 4, 8
+4, 9, 55164, 4, 10, 3902, 5, 9, 3759, 5, 10, 2711, // 4, 9
+4, 10, 53973, 4, 11, 4309, 5, 10, 4230, 5, 11, 3024, // 4,10
+4, 11, 52484, 4, 12, 4816, 5, 11, 4822, 5, 12, 3414, // 4,11
+4, 12, 50844, 4, 13, 5365, 5, 12, 5481, 5, 13, 3846, // 4,12
+4, 13, 49150, 4, 14, 5920, 5, 13, 6176, 5, 14, 4290, // 4,13
+4, 14, 47458, 4, 15, 6458, 5, 14, 6886, 5, 15, 4734, // 4,14
+4, 15, 45799, 4, 16, 6970, 5, 15, 7599, 5, 16, 5168, // 4,15
+4, 0, 7374, 4, 1, 4971, 5, 0, 46532, 5, 1, 6659, // 5, 0
+4, 1, 6613, 4, 2, 4505, 5, 1, 48314, 5, 2, 6104, // 5, 1
+4, 2, 5842, 4, 3, 4020, 5, 2, 50165, 5, 3, 5509, // 5, 2
+4, 3, 5069, 4, 4, 3523, 5, 3, 52066, 5, 4, 4878, // 5, 3
+4, 4, 4309, 4, 5, 3023, 5, 4, 53973, 5, 5, 4231, // 5, 4
+4, 5, 3595, 4, 6, 2546, 5, 5, 55798, 5, 6, 3597, // 5, 5
+4, 6, 2993, 4, 7, 2138, 5, 6, 57354, 5, 7, 3051, // 5, 6
+4, 7, 2615, 4, 8, 1884, 5, 7, 58324, 5, 8, 2713, // 5, 7
+5, 8, 58322, 5, 9, 2713, 6, 8, 2616, 6, 9, 1885, // 5, 8
+5, 9, 57353, 5, 10, 3050, 6, 9, 2995, 6, 10, 2138, // 5, 9
+5, 10, 55798, 5, 11, 3595, 6, 10, 3598, 6, 11, 2545, // 5,10
+5, 11, 53975, 5, 12, 4226, 6, 11, 4313, 6, 12, 3022, // 5,11
+5, 12, 52069, 5, 13, 4872, 6, 12, 5073, 6, 13, 3522, // 5,12
+5, 13, 50171, 5, 14, 5499, 6, 13, 5848, 6, 14, 4018, // 5,13
+5, 14, 48322, 5, 15, 6092, 6, 14, 6620, 6, 15, 4502, // 5,14
+5, 15, 46541, 5, 16, 6644, 6, 15, 7383, 6, 16, 4968, // 5,15
+5, 0, 7227, 5, 1, 4818, 6, 0, 47086, 6, 1, 6405, // 6, 0
+5, 1, 6425, 5, 2, 4330, 6, 1, 48960, 6, 2, 5821, // 6, 1
+5, 2, 5602, 5, 3, 3815, 6, 2, 50935, 6, 3, 5184, // 6, 2
+5, 3, 4759, 5, 4, 3274, 6, 3, 53008, 6, 4, 4495, // 6, 3
+5, 4, 3902, 5, 5, 2711, 6, 4, 55164, 6, 5, 3759, // 6, 4
+5, 5, 3050, 5, 6, 2138, 6, 5, 57353, 6, 6, 2995, // 6, 5
+5, 6, 2258, 5, 7, 1597, 6, 6, 59422, 6, 7, 2259, // 6, 6
+5, 7, 1695, 5, 8, 1209, 6, 7, 60906, 6, 8, 1726, // 6, 7
+6, 8, 60905, 6, 9, 1726, 7, 8, 1695, 7, 9, 1210, // 6, 8
+6, 9, 59422, 6, 10, 2258, 7, 9, 2259, 7, 10, 1597, // 6, 9
+6, 10, 57354, 6, 11, 2993, 7, 10, 3051, 7, 11, 2138, // 6,10
+6, 11, 55166, 6, 12, 3755, 7, 11, 3904, 7, 12, 2711, // 6,11
+6, 12, 53012, 6, 13, 4489, 7, 12, 4762, 7, 13, 3273, // 6,12
+6, 13, 50942, 6, 14, 5175, 7, 13, 5606, 7, 14, 3813, // 6,13
+6, 14, 48969, 6, 15, 5809, 7, 14, 6430, 7, 15, 4328, // 6,14
+6, 15, 47098, 6, 16, 6391, 7, 15, 7233, 7, 16, 4814, // 6,15
+6, 0, 7158, 6, 1, 4722, 7, 0, 47426, 7, 1, 6230, // 7, 0
+6, 1, 6332, 6, 2, 4224, 7, 1, 49347, 7, 2, 5633, // 7, 1
+6, 2, 5478, 6, 3, 3693, 7, 2, 51387, 7, 3, 4978, // 7, 2
+6, 3, 4592, 6, 4, 3128, 7, 3, 53557, 7, 4, 4259, // 7, 3
+6, 4, 3671, 6, 5, 2525, 7, 4, 55867, 7, 5, 3473, // 7, 4
+6, 5, 2713, 6, 6, 1884, 7, 5, 58322, 7, 6, 2617, // 7, 5
+6, 6, 1726, 6, 7, 1210, 7, 6, 60905, 7, 7, 1695, // 7, 6
+6, 7, 789, 6, 8, 558, 7, 7, 63399, 7, 8, 790, // 7, 7
+7, 8, 63399, 7, 9, 789, 8, 8, 789, 8, 9, 559, // 7, 8
+7, 9, 60906, 7, 10, 1695, 8, 9, 1726, 8, 10, 1209, // 7, 9
+7, 10, 58324, 7, 11, 2615, 8, 10, 2714, 8, 11, 1883, // 7,10
+7, 11, 55870, 7, 12, 3469, 8, 11, 3672, 8, 12, 2525, // 7,11
+7, 12, 53562, 7, 13, 4254, 8, 12, 4594, 8, 13, 3126, // 7,12
+7, 13, 51395, 7, 14, 4970, 8, 13, 5480, 8, 14, 3691, // 7,13
+7, 14, 49358, 7, 15, 5623, 8, 14, 6335, 8, 15, 4220, // 7,14
+7, 15, 47440, 7, 16, 6217, 8, 15, 7161, 8, 16, 4718, // 7,15
+7, -1, 4718, 7, 0, 7161, 8, -1, 6217, 8, 0, 47440, // 8, 0
+7, 0, 4221, 7, 1, 6335, 8, 0, 5623, 8, 1, 49357, // 8, 1
+7, 1, 3691, 7, 2, 5480, 8, 1, 4970, 8, 2, 51395, // 8, 2
+7, 2, 3126, 7, 3, 4594, 8, 2, 4254, 8, 3, 53562, // 8, 3
+7, 3, 2524, 7, 4, 3672, 8, 3, 3469, 8, 4, 55871, // 8, 4
+7, 4, 1884, 7, 5, 2714, 8, 4, 2615, 8, 5, 58323, // 8, 5
+7, 5, 1209, 7, 6, 1726, 8, 5, 1695, 8, 6, 60906, // 8, 6
+7, 6, 558, 7, 7, 789, 8, 6, 789, 8, 7, 63400, // 8, 7
+8, 7, 789, 8, 8, 63399, 9, 7, 558, 9, 8, 790, // 8, 8
+8, 8, 1695, 8, 9, 60905, 9, 8, 1210, 9, 9, 1726, // 8, 9
+8, 9, 2616, 8, 10, 58322, 9, 9, 1884, 9, 10, 2714, // 8,10
+8, 10, 3473, 8, 11, 55867, 9, 10, 2525, 9, 11, 3671, // 8,11
+8, 11, 4259, 8, 12, 53557, 9, 11, 3128, 9, 12, 4592, // 8,12
+8, 12, 4978, 8, 13, 51387, 9, 12, 3693, 9, 13, 5478, // 8,13
+8, 13, 5633, 8, 14, 49347, 9, 13, 4224, 9, 14, 6332, // 8,14
+8, 14, 6230, 8, 15, 47426, 9, 14, 4722, 9, 15, 7158, // 8,15
+8, -1, 4814, 8, 0, 7233, 9, -1, 6391, 9, 0, 47098, // 9, 0
+8, 0, 4327, 8, 1, 6430, 9, 0, 5809, 9, 1, 48970, // 9, 1
+8, 1, 3813, 8, 2, 5606, 9, 1, 5175, 9, 2, 50942, // 9, 2
+8, 2, 3273, 8, 3, 4762, 9, 2, 4489, 9, 3, 53012, // 9, 3
+8, 3, 2710, 8, 4, 3904, 9, 3, 3755, 9, 4, 55167, // 9, 4
+8, 4, 2138, 8, 5, 3051, 9, 4, 2993, 9, 5, 57354, // 9, 5
+8, 5, 1597, 8, 6, 2259, 9, 5, 2258, 9, 6, 59422, // 9, 6
+8, 6, 1210, 8, 7, 1695, 9, 6, 1726, 9, 7, 60905, // 9, 7
+9, 7, 1726, 9, 8, 60906, 10, 7, 1209, 10, 8, 1695, // 9, 8
+9, 8, 2259, 9, 9, 59422, 10, 8, 1597, 10, 9, 2258, // 9, 9
+9, 9, 2995, 9, 10, 57353, 10, 9, 2138, 10, 10, 3050, // 9,10
+9, 10, 3759, 9, 11, 55164, 10, 10, 2711, 10, 11, 3902, // 9,11
+9, 11, 4495, 9, 12, 53008, 10, 11, 3274, 10, 12, 4759, // 9,12
+9, 12, 5184, 9, 13, 50935, 10, 12, 3815, 10, 13, 5602, // 9,13
+9, 13, 5820, 9, 14, 48960, 10, 13, 4330, 10, 14, 6426, // 9,14
+9, 14, 6405, 9, 15, 47086, 10, 14, 4818, 10, 15, 7227, // 9,15
+9, -1, 4967, 9, 0, 7383, 10, -1, 6644, 10, 0, 46542, // 10, 0
+9, 0, 4502, 9, 1, 6620, 10, 0, 6092, 10, 1, 48322, // 10, 1
+9, 1, 4019, 9, 2, 5848, 10, 1, 5499, 10, 2, 50170, // 10, 2
+9, 2, 3522, 9, 3, 5073, 10, 2, 4872, 10, 3, 52069, // 10, 3
+9, 3, 3023, 9, 4, 4313, 10, 3, 4226, 10, 4, 53974, // 10, 4
+9, 4, 2546, 9, 5, 3598, 10, 4, 3595, 10, 5, 55797, // 10, 5
+9, 5, 2138, 9, 6, 2995, 10, 5, 3050, 10, 6, 57353, // 10, 6
+9, 6, 1884, 9, 7, 2616, 10, 6, 2713, 10, 7, 58323, // 10, 7
+10, 7, 2714, 10, 8, 58324, 11, 7, 1884, 11, 8, 2614, // 10, 8
+10, 8, 3051, 10, 9, 57354, 11, 8, 2138, 11, 9, 2993, // 10, 9
+10, 9, 3598, 10, 10, 55798, 11, 9, 2546, 11, 10, 3594, // 10,10
+10, 10, 4230, 10, 11, 53973, 11, 10, 3023, 11, 11, 4310, // 10,11
+10, 11, 4879, 10, 12, 52066, 11, 11, 3523, 11, 12, 5068, // 10,12
+10, 12, 5508, 10, 13, 50165, 11, 12, 4020, 11, 13, 5843, // 10,13
+10, 13, 6104, 10, 14, 48314, 11, 13, 4505, 11, 14, 6613, // 10,14
+10, 14, 6659, 10, 15, 46532, 11, 14, 4971, 11, 15, 7374, // 10,15
+10, -1, 5169, 10, 0, 7599, 11, -1, 6970, 11, 0, 45798, // 11, 0
+10, 0, 4734, 10, 1, 6886, 11, 0, 6458, 11, 1, 47458, // 11, 1
+10, 1, 4290, 10, 2, 6176, 11, 1, 5920, 11, 2, 49150, // 11, 2
+10, 2, 3845, 10, 3, 5481, 11, 2, 5365, 11, 3, 50845, // 11, 3
+10, 3, 3415, 10, 4, 4822, 11, 3, 4816, 11, 4, 52483, // 11, 4
+10, 4, 3023, 10, 5, 4230, 11, 4, 4309, 11, 5, 53974, // 11, 5
+10, 5, 2711, 10, 6, 3759, 11, 5, 3902, 11, 6, 55164, // 11, 6
+10, 6, 2525, 10, 7, 3473, 11, 6, 3671, 11, 7, 55867, // 11, 7
+11, 7, 3672, 11, 8, 55870, 12, 7, 2524, 12, 8, 3470, // 11, 8
+11, 8, 3904, 11, 9, 55166, 12, 8, 2710, 12, 9, 3756, // 11, 9
+11, 9, 4313, 11, 10, 53975, 12, 9, 3023, 12, 10, 4225, // 11,10
+11, 10, 4822, 11, 11, 52484, 12, 10, 3415, 12, 11, 4815, // 11,11
+11, 11, 5373, 11, 12, 50843, 12, 11, 3846, 12, 12, 5474, // 11,12
+11, 12, 5930, 11, 13, 49147, 12, 12, 4291, 12, 13, 6168, // 11,13
+11, 13, 6472, 11, 14, 47453, 12, 13, 4736, 12, 14, 6875, // 11,14
+11, 14, 6986, 11, 15, 45791, 12, 14, 5172, 12, 15, 7587, // 11,15
+11, -1, 5410, 11, 0, 7863, 12, -1, 7356, 12, 0, 44907, // 12, 0
+11, 0, 5009, 11, 1, 7204, 12, 0, 6892, 12, 1, 46431, // 12, 1
+11, 1, 4607, 11, 2, 6560, 12, 1, 6414, 12, 2, 47955, // 12, 2
+11, 2, 4214, 11, 3, 5943, 12, 2, 5934, 12, 3, 49445, // 12, 3
+11, 3, 3846, 11, 4, 5373, 12, 3, 5474, 12, 4, 50843, // 12, 4
+11, 4, 3523, 11, 5, 4879, 12, 4, 5069, 12, 5, 52065, // 12, 5
+11, 5, 3274, 11, 6, 4495, 12, 5, 4759, 12, 6, 53008, // 12, 6
+11, 6, 3128, 11, 7, 4259, 12, 6, 4592, 12, 7, 53557, // 12, 7
+12, 7, 4594, 12, 8, 53562, 13, 7, 3126, 13, 8, 4254, // 12, 8
+12, 8, 4762, 12, 9, 53012, 13, 8, 3273, 13, 9, 4489, // 12, 9
+12, 9, 5073, 12, 10, 52069, 13, 9, 3522, 13, 10, 4872, // 12,10
+12, 10, 5481, 12, 11, 50844, 13, 10, 3845, 13, 11, 5366, // 12,11
+12, 11, 5943, 12, 12, 49445, 13, 11, 4214, 13, 12, 5934, // 12,12
+12, 12, 6426, 12, 13, 47953, 13, 12, 4608, 13, 13, 6549, // 12,13
+12, 13, 6908, 12, 14, 46427, 13, 13, 5011, 13, 14, 7190, // 12,14
+12, 14, 7374, 12, 15, 44901, 13, 14, 5413, 13, 15, 7848, // 12,15
+12, -1, 5682, 12, 0, 8159, 13, -1, 7791, 13, 0, 43904, // 13, 0
+12, 0, 5315, 12, 1, 7555, 13, 0, 7378, 13, 1, 45288, // 13, 1
+12, 1, 4954, 12, 2, 6973, 13, 1, 6959, 13, 2, 46650, // 13, 2
+12, 2, 4608, 12, 3, 6426, 13, 2, 6549, 13, 3, 47953, // 13, 3
+12, 3, 4291, 12, 4, 5930, 13, 3, 6168, 13, 4, 49147, // 13, 4
+12, 4, 4020, 12, 5, 5508, 13, 4, 5842, 13, 5, 50166, // 13, 5
+12, 5, 3815, 12, 6, 5184, 13, 5, 5602, 13, 6, 50935, // 13, 6
+12, 6, 3693, 12, 7, 4978, 13, 6, 5478, 13, 7, 51387, // 13, 7
+13, 7, 5480, 13, 8, 51395, 14, 7, 3691, 14, 8, 4970, // 13, 8
+13, 8, 5606, 13, 9, 50942, 14, 8, 3813, 14, 9, 5175, // 13, 9
+13, 9, 5848, 13, 10, 50171, 14, 9, 4019, 14, 10, 5498, // 13,10
+13, 10, 6176, 13, 11, 49150, 14, 10, 4290, 14, 11, 5920, // 13,11
+13, 11, 6560, 13, 12, 47955, 14, 11, 4607, 14, 12, 6414, // 13,12
+13, 12, 6973, 13, 13, 46650, 14, 12, 4954, 14, 13, 6959, // 13,13
+13, 13, 7395, 13, 14, 45286, 14, 13, 5316, 14, 14, 7539, // 13,14
+13, 14, 7812, 13, 15, 43900, 14, 14, 5684, 14, 15, 8140, // 13,15
+13, -1, 5974, 13, 0, 8474, 14, -1, 8265, 14, 0, 42823, // 14, 0
+13, 0, 5640, 13, 1, 7921, 14, 0, 7901, 14, 1, 44074, // 14, 1
+13, 1, 5316, 13, 2, 7395, 14, 1, 7539, 14, 2, 45286, // 14, 2
+13, 2, 5011, 13, 3, 6908, 14, 2, 7191, 14, 3, 46426, // 14, 3
+13, 3, 4736, 13, 4, 6472, 14, 3, 6875, 14, 4, 47453, // 14, 4
+13, 4, 4505, 13, 5, 6104, 14, 4, 6613, 14, 5, 48314, // 14, 5
+13, 5, 4330, 13, 6, 5820, 14, 5, 6425, 14, 6, 48961, // 14, 6
+13, 6, 4224, 13, 7, 5633, 14, 6, 6332, 14, 7, 49347, // 14, 7
+14, 7, 6335, 14, 8, 49358, 15, 7, 4221, 15, 8, 5622, // 14, 8
+14, 8, 6430, 14, 9, 48969, 15, 8, 4327, 15, 9, 5810, // 14, 9
+14, 9, 6620, 14, 10, 48322, 15, 9, 4502, 15, 10, 6092, // 14,10
+14, 10, 6886, 14, 11, 47458, 15, 10, 4734, 15, 11, 6458, // 14,11
+14, 11, 7204, 14, 12, 46430, 15, 11, 5009, 15, 12, 6893, // 14,12
+14, 12, 7555, 14, 13, 45288, 15, 12, 5315, 15, 13, 7378, // 14,13
+14, 13, 7921, 14, 14, 44074, 15, 13, 5640, 15, 14, 7901, // 14,14
+14, 14, 8288, 14, 15, 42821, 15, 14, 5975, 15, 15, 8452, // 14,15
+14, -1, 6280, 14, 0, 8795, 15, -1, 8769, 15, 0, 41692, // 15, 0
+14, 0, 5975, 14, 1, 8288, 15, 0, 8452, 15, 1, 42821, // 15, 1
+14, 1, 5684, 14, 2, 7812, 15, 1, 8141, 15, 2, 43899, // 15, 2
+14, 2, 5413, 14, 3, 7374, 15, 2, 7848, 15, 3, 44901, // 15, 3
+14, 3, 5172, 14, 4, 6986, 15, 3, 7587, 15, 4, 45791, // 15, 4
+14, 4, 4971, 14, 5, 6659, 15, 4, 7374, 15, 5, 46532, // 15, 5
+14, 5, 4818, 14, 6, 6405, 15, 5, 7227, 15, 6, 47086, // 15, 6
+14, 6, 4722, 14, 7, 6230, 15, 6, 7158, 15, 7, 47426, // 15, 7
+15, 7, 7161, 15, 8, 47440, 16, 7, 4718, 16, 8, 6217, // 15, 8
+15, 8, 7233, 15, 9, 47098, 16, 8, 4814, 16, 9, 6391, // 15, 9
+15, 9, 7383, 15, 10, 46541, 16, 9, 4967, 16, 10, 6645, // 15,10
+15, 10, 7599, 15, 11, 45799, 16, 10, 5169, 16, 11, 6969, // 15,11
+15, 11, 7863, 15, 12, 44907, 16, 11, 5410, 16, 12, 7356, // 15,12
+15, 12, 8159, 15, 13, 43904, 16, 12, 5682, 16, 13, 7791, // 15,13
+15, 13, 8474, 15, 14, 42823, 16, 13, 5974, 16, 14, 8265, // 15,14
+15, 14, 8795, 15, 15, 41693, 16, 14, 6280, 16, 15, 8768, // 15,15
+// angle of -0.5 degrees
+-1, 0, 5106, -1, 1, 3621, 0, 0, 51699, 0, 1, 5110, // 0, 0
+-1, 1, 4803, -1, 2, 3421, 0, 1, 52457, 0, 2, 4855, // 0, 1
+-1, 2, 4521, -1, 3, 3235, 0, 2, 53168, 0, 3, 4612, // 0, 2
+-1, 3, 4264, -1, 4, 3064, 0, 3, 53815, 0, 4, 4393, // 0, 3
+-1, 4, 4041, -1, 5, 2916, 0, 4, 54378, 0, 5, 4201, // 0, 4
+-1, 5, 3858, -1, 6, 2796, 0, 5, 54835, 0, 6, 4047, // 0, 5
+-1, 6, 3722, -1, 7, 2709, 0, 6, 55166, 0, 7, 3939, // 0, 6
+-1, 7, 3638, -1, 8, 2659, 0, 7, 55354, 0, 8, 3885, // 0, 7
+0, 8, 55352, 0, 9, 3885, 1, 8, 3640, 1, 9, 2659, // 0, 8
+0, 9, 55164, 0, 10, 3939, 1, 9, 3724, 1, 10, 2709, // 0, 9
+0, 10, 54833, 0, 11, 4046, 1, 10, 3860, 1, 11, 2797, // 0,10
+0, 11, 54376, 0, 12, 4200, 1, 11, 4043, 1, 12, 2917, // 0,11
+0, 12, 53814, 0, 13, 4390, 1, 12, 4267, 1, 13, 3065, // 0,12
+0, 13, 53168, 0, 14, 4610, 1, 13, 4523, 1, 14, 3235, // 0,13
+0, 14, 52457, 0, 15, 4851, 1, 14, 4806, 1, 15, 3422, // 0,14
+0, 15, 51699, 0, 16, 5106, 1, 15, 5110, 1, 16, 3621, // 0,15
+0, 0, 4851, 0, 1, 3422, 1, 0, 52457, 1, 1, 4806, // 1, 0
+0, 1, 4522, 0, 2, 3204, 1, 1, 53285, 1, 2, 4525, // 1, 1
+0, 2, 4212, 0, 3, 2998, 1, 2, 54072, 1, 3, 4254, // 1, 2
+0, 3, 3927, 0, 4, 2808, 1, 3, 54796, 1, 4, 4005, // 1, 3
+0, 4, 3677, 0, 5, 2640, 1, 4, 55435, 1, 5, 3784, // 1, 4
+0, 5, 3470, 0, 6, 2502, 1, 5, 55959, 1, 6, 3605, // 1, 5
+0, 6, 3317, 0, 7, 2402, 1, 6, 56340, 1, 7, 3477, // 1, 6
+0, 7, 3225, 0, 8, 2346, 1, 7, 56554, 1, 8, 3411, // 1, 7
+1, 8, 56552, 1, 9, 3411, 2, 8, 3227, 2, 9, 2346, // 1, 8
+1, 9, 56339, 1, 10, 3476, 2, 9, 3319, 2, 10, 2402, // 1, 9
+1, 10, 55958, 1, 11, 3604, 2, 10, 3472, 2, 11, 2502, // 1,10
+1, 11, 55434, 1, 12, 3783, 2, 11, 3678, 2, 12, 2641, // 1,11
+1, 12, 54796, 1, 13, 4003, 2, 12, 3929, 2, 13, 2808, // 1,12
+1, 13, 54071, 1, 14, 4253, 2, 13, 4214, 2, 14, 2998, // 1,13
+1, 14, 53285, 1, 15, 4522, 2, 14, 4525, 2, 15, 3204, // 1,14
+1, 15, 52457, 1, 16, 4803, 2, 15, 4854, 2, 16, 3422, // 1,15
+1, 0, 4610, 1, 1, 3235, 2, 0, 53168, 2, 1, 4523, // 2, 0
+1, 1, 4253, 1, 2, 2998, 2, 1, 54071, 2, 2, 4214, // 2, 1
+1, 2, 3911, 1, 3, 2770, 2, 2, 54941, 2, 3, 3914, // 2, 2
+1, 3, 3594, 1, 4, 2556, 2, 3, 55756, 2, 4, 3630, // 2, 3
+1, 4, 3310, 1, 5, 2365, 2, 4, 56487, 2, 5, 3374, // 2, 4
+1, 5, 3073, 1, 6, 2205, 2, 5, 57096, 2, 6, 3162, // 2, 5
+1, 6, 2897, 1, 7, 2088, 2, 6, 57545, 2, 7, 3006, // 2, 6
+1, 7, 2794, 1, 8, 2022, 2, 7, 57795, 2, 8, 2925, // 2, 7
+2, 8, 57793, 2, 9, 2926, 3, 8, 2795, 3, 9, 2022, // 2, 8
+2, 9, 57544, 2, 10, 3007, 3, 9, 2898, 3, 10, 2087, // 2, 9
+2, 10, 57095, 2, 11, 3161, 3, 10, 3074, 3, 11, 2206, // 2,10
+2, 11, 56486, 2, 12, 3373, 3, 11, 3311, 3, 12, 2366, // 2,11
+2, 12, 55756, 2, 13, 3628, 3, 12, 3595, 3, 13, 2557, // 2,12
+2, 13, 54941, 2, 14, 3911, 3, 13, 3913, 3, 14, 2771, // 2,13
+2, 14, 54072, 2, 15, 4212, 3, 14, 4255, 3, 15, 2997, // 2,14
+2, 15, 53168, 2, 16, 4521, 3, 15, 4612, 3, 16, 3235, // 2,15
+2, 0, 4390, 2, 1, 3065, 3, 0, 53814, 3, 1, 4267, // 3, 0
+2, 1, 4003, 2, 2, 2808, 3, 1, 54796, 3, 2, 3929, // 3, 1
+2, 2, 3628, 2, 3, 2557, 3, 2, 55756, 3, 3, 3595, // 3, 2
+2, 3, 3273, 2, 4, 2317, 3, 3, 56673, 3, 4, 3273, // 3, 3
+2, 4, 2948, 2, 5, 2096, 3, 4, 57514, 3, 5, 2978, // 3, 4
+2, 5, 2672, 2, 6, 1908, 3, 5, 58234, 3, 6, 2722, // 3, 5
+2, 6, 2463, 2, 7, 1766, 3, 6, 58775, 3, 7, 2532, // 3, 6
+2, 7, 2342, 2, 8, 1687, 3, 7, 59077, 3, 8, 2430, // 3, 7
+3, 8, 59076, 3, 9, 2430, 4, 8, 2343, 4, 9, 1687, // 3, 8
+3, 9, 58774, 3, 10, 2532, 4, 9, 2464, 4, 10, 1766, // 3, 9
+3, 10, 58233, 3, 11, 2722, 4, 10, 2673, 4, 11, 1908, // 3,10
+3, 11, 57514, 3, 12, 2976, 4, 11, 2950, 4, 12, 2096, // 3,11
+3, 12, 56673, 3, 13, 3273, 4, 12, 3274, 4, 13, 2316, // 3,12
+3, 13, 55756, 3, 14, 3594, 4, 13, 3630, 4, 14, 2556, // 3,13
+3, 14, 54796, 3, 15, 3927, 4, 14, 4005, 4, 15, 2808, // 3,14
+3, 15, 53815, 3, 16, 4264, 4, 15, 4392, 4, 16, 3065, // 3,15
+3, 0, 4200, 3, 1, 2917, 4, 0, 54376, 4, 1, 4043, // 4, 0
+3, 1, 3783, 3, 2, 2640, 4, 1, 55434, 4, 2, 3679, // 4, 1
+3, 2, 3373, 3, 3, 2365, 4, 2, 56486, 4, 3, 3312, // 4, 2
+3, 3, 2976, 3, 4, 2096, 4, 3, 57514, 4, 4, 2950, // 4, 3
+3, 4, 2604, 3, 5, 1843, 4, 4, 58484, 4, 5, 2605, // 4, 4
+3, 5, 2276, 3, 6, 1617, 4, 5, 59346, 4, 6, 2297, // 4, 5
+3, 6, 2020, 3, 7, 1442, 4, 6, 60018, 4, 7, 2056, // 4, 6
+3, 7, 1871, 3, 8, 1341, 4, 7, 60402, 4, 8, 1922, // 4, 7
+4, 8, 60402, 4, 9, 1922, 5, 8, 1871, 5, 9, 1341, // 4, 8
+4, 9, 60017, 4, 10, 2057, 5, 9, 2020, 5, 10, 1442, // 4, 9
+4, 10, 59345, 4, 11, 2297, 5, 10, 2276, 5, 11, 1618, // 4,10
+4, 11, 58484, 4, 12, 2604, 5, 11, 2605, 5, 12, 1843, // 4,11
+4, 12, 57514, 4, 13, 2948, 5, 12, 2977, 5, 13, 2097, // 4,12
+4, 13, 56487, 4, 14, 3310, 5, 13, 3374, 5, 14, 2365, // 4,13
+4, 14, 55435, 4, 15, 3677, 5, 14, 3785, 5, 15, 2639, // 4,14
+4, 15, 54378, 4, 16, 4041, 5, 15, 4201, 5, 16, 2916, // 4,15
+4, 0, 4046, 4, 1, 2797, 5, 0, 54833, 5, 1, 3860, // 5, 0
+4, 1, 3604, 4, 2, 2503, 5, 1, 55958, 5, 2, 3471, // 5, 1
+4, 2, 3161, 4, 3, 2205, 5, 2, 57095, 5, 3, 3075, // 5, 2
+4, 3, 2722, 4, 4, 1908, 5, 3, 58233, 5, 4, 2673, // 5, 3
+4, 4, 2297, 4, 5, 1617, 5, 4, 59345, 5, 5, 2277, // 5, 4
+4, 5, 1904, 4, 6, 1347, 5, 5, 60381, 5, 6, 1904, // 5, 5
+4, 6, 1578, 4, 7, 1121, 5, 6, 61243, 5, 7, 1594, // 5, 6
+4, 7, 1380, 4, 8, 985, 5, 7, 61767, 5, 8, 1404, // 5, 7
+5, 8, 61767, 5, 9, 1405, 6, 8, 1380, 6, 9, 984, // 5, 8
+5, 9, 61243, 5, 10, 1593, 6, 9, 1579, 6, 10, 1121, // 5, 9
+5, 10, 60381, 5, 11, 1904, 6, 10, 1904, 6, 11, 1347, // 5,10
+5, 11, 59346, 5, 12, 2276, 6, 11, 2297, 6, 12, 1617, // 5,11
+5, 12, 58234, 5, 13, 2672, 6, 12, 2723, 6, 13, 1907, // 5,12
+5, 13, 57096, 5, 14, 3073, 6, 13, 3161, 6, 14, 2206, // 5,13
+5, 14, 55959, 5, 15, 3470, 6, 14, 3605, 6, 15, 2502, // 5,14
+5, 15, 54835, 5, 16, 3858, 6, 15, 4047, 6, 16, 2796, // 5,15
+5, 0, 3939, 5, 1, 2709, 6, 0, 55164, 6, 1, 3724, // 6, 0
+5, 1, 3476, 5, 2, 2403, 6, 1, 56339, 6, 2, 3318, // 6, 1
+5, 2, 3007, 5, 3, 2088, 6, 2, 57544, 6, 3, 2897, // 6, 2
+5, 3, 2532, 5, 4, 1767, 6, 3, 58774, 6, 4, 2463, // 6, 3
+5, 4, 2057, 5, 5, 1442, 6, 4, 60017, 6, 5, 2020, // 6, 4
+5, 5, 1593, 5, 6, 1121, 6, 5, 61243, 6, 6, 1579, // 6, 5
+5, 6, 1170, 5, 7, 827, 6, 6, 62369, 6, 7, 1170, // 6, 6
+5, 7, 875, 5, 8, 622, 6, 7, 63156, 6, 8, 883, // 6, 7
+6, 8, 63156, 6, 9, 883, 7, 8, 875, 7, 9, 622, // 6, 8
+6, 9, 62369, 6, 10, 1170, 7, 9, 1170, 7, 10, 827, // 6, 9
+6, 10, 61243, 6, 11, 1578, 7, 10, 1593, 7, 11, 1122, // 6,10
+6, 11, 60018, 6, 12, 2020, 7, 11, 2057, 7, 12, 1441, // 6,11
+6, 12, 58775, 6, 13, 2463, 7, 12, 2532, 7, 13, 1766, // 6,12
+6, 13, 57545, 6, 14, 2897, 7, 13, 3007, 7, 14, 2087, // 6,13
+6, 14, 56340, 6, 15, 3317, 7, 14, 3477, 7, 15, 2402, // 6,14
+6, 15, 55166, 6, 16, 3722, 7, 15, 3940, 7, 16, 2708, // 6,15
+6, 0, 3885, 6, 1, 2659, 7, 0, 55352, 7, 1, 3640, // 7, 0
+6, 1, 3411, 6, 2, 2346, 7, 1, 56552, 7, 2, 3227, // 7, 1
+6, 2, 2926, 6, 3, 2022, 7, 2, 57793, 7, 3, 2795, // 7, 2
+6, 3, 2430, 6, 4, 1687, 7, 3, 59076, 7, 4, 2343, // 7, 3
+6, 4, 1922, 6, 5, 1341, 7, 4, 60402, 7, 5, 1871, // 7, 4
+6, 5, 1405, 6, 6, 985, 7, 5, 61767, 7, 6, 1379, // 7, 5
+6, 6, 883, 6, 7, 622, 7, 6, 63156, 7, 7, 875, // 7, 6
+6, 7, 399, 6, 8, 282, 7, 7, 64455, 7, 8, 400, // 7, 7
+7, 8, 64455, 7, 9, 399, 8, 8, 399, 8, 9, 283, // 7, 8
+7, 9, 63156, 7, 10, 875, 8, 9, 883, 8, 10, 622, // 7, 9
+7, 10, 61767, 7, 11, 1380, 8, 10, 1405, 8, 11, 984, // 7,10
+7, 11, 60402, 7, 12, 1871, 8, 11, 1922, 8, 12, 1341, // 7,11
+7, 12, 59077, 7, 13, 2342, 8, 12, 2430, 8, 13, 1687, // 7,12
+7, 13, 57795, 7, 14, 2794, 8, 13, 2926, 8, 14, 2021, // 7,13
+7, 14, 56554, 7, 15, 3225, 8, 14, 3411, 8, 15, 2346, // 7,14
+7, 15, 55354, 7, 16, 3638, 8, 15, 3885, 8, 16, 2659, // 7,15
+7, -1, 2659, 7, 0, 3885, 8, -1, 3638, 8, 0, 55354, // 8, 0
+7, 0, 2346, 7, 1, 3411, 8, 0, 3225, 8, 1, 56554, // 8, 1
+7, 1, 2022, 7, 2, 2926, 8, 1, 2794, 8, 2, 57794, // 8, 2
+7, 2, 1687, 7, 3, 2430, 8, 2, 2342, 8, 3, 59077, // 8, 3
+7, 3, 1341, 7, 4, 1922, 8, 3, 1871, 8, 4, 60402, // 8, 4
+7, 4, 985, 7, 5, 1405, 8, 4, 1380, 8, 5, 61766, // 8, 5
+7, 5, 622, 7, 6, 883, 8, 5, 875, 8, 6, 63156, // 8, 6
+7, 6, 282, 7, 7, 399, 8, 6, 399, 8, 7, 64456, // 8, 7
+8, 7, 399, 8, 8, 64455, 9, 7, 282, 9, 8, 400, // 8, 8
+8, 8, 875, 8, 9, 63156, 9, 8, 622, 9, 9, 883, // 8, 9
+8, 9, 1380, 8, 10, 61767, 9, 9, 985, 9, 10, 1404, // 8,10
+8, 10, 1871, 8, 11, 60402, 9, 10, 1341, 9, 11, 1922, // 8,11
+8, 11, 2343, 8, 12, 59076, 9, 11, 1687, 9, 12, 2430, // 8,12
+8, 12, 2795, 8, 13, 57793, 9, 12, 2022, 9, 13, 2926, // 8,13
+8, 13, 3227, 8, 14, 56552, 9, 13, 2346, 9, 14, 3411, // 8,14
+8, 14, 3640, 8, 15, 55352, 9, 14, 2659, 9, 15, 3885, // 8,15
+8, -1, 2709, 8, 0, 3940, 9, -1, 3722, 9, 0, 55165, // 9, 0
+8, 0, 2402, 8, 1, 3477, 9, 0, 3317, 9, 1, 56340, // 9, 1
+8, 1, 2088, 8, 2, 3007, 9, 1, 2897, 9, 2, 57544, // 9, 2
+8, 2, 1766, 8, 3, 2532, 9, 2, 2463, 9, 3, 58775, // 9, 3
+8, 3, 1442, 8, 4, 2057, 9, 3, 2020, 9, 4, 60017, // 9, 4
+8, 4, 1121, 8, 5, 1593, 9, 4, 1578, 9, 5, 61244, // 9, 5
+8, 5, 827, 8, 6, 1170, 9, 5, 1170, 9, 6, 62369, // 9, 6
+8, 6, 622, 8, 7, 875, 9, 6, 883, 9, 7, 63156, // 9, 7
+9, 7, 883, 9, 8, 63156, 10, 7, 622, 10, 8, 875, // 9, 8
+9, 8, 1170, 9, 9, 62369, 10, 8, 827, 10, 9, 1170, // 9, 9
+9, 9, 1579, 9, 10, 61243, 10, 9, 1121, 10, 10, 1593, // 9,10
+9, 10, 2020, 9, 11, 60017, 10, 10, 1442, 10, 11, 2057, // 9,11
+9, 11, 2464, 9, 12, 58774, 10, 11, 1767, 10, 12, 2531, // 9,12
+9, 12, 2898, 9, 13, 57544, 10, 12, 2088, 10, 13, 3006, // 9,13
+9, 13, 3319, 9, 14, 56339, 10, 13, 2403, 10, 14, 3475, // 9,14
+9, 14, 3724, 9, 15, 55164, 10, 14, 2709, 10, 15, 3939, // 9,15
+9, -1, 2796, 9, 0, 4047, 10, -1, 3858, 10, 0, 54835, // 10, 0
+9, 0, 2502, 9, 1, 3605, 10, 0, 3470, 10, 1, 55959, // 10, 1
+9, 1, 2205, 9, 2, 3161, 10, 1, 3073, 10, 2, 57097, // 10, 2
+9, 2, 1908, 9, 3, 2723, 10, 2, 2672, 10, 3, 58233, // 10, 3
+9, 3, 1617, 9, 4, 2297, 10, 3, 2276, 10, 4, 59346, // 10, 4
+9, 4, 1347, 9, 5, 1904, 10, 4, 1904, 10, 5, 60381, // 10, 5
+9, 5, 1121, 9, 6, 1579, 10, 5, 1593, 10, 6, 61243, // 10, 6
+9, 6, 985, 9, 7, 1380, 10, 6, 1405, 10, 7, 61766, // 10, 7
+10, 7, 1405, 10, 8, 61767, 11, 7, 985, 11, 8, 1379, // 10, 8
+10, 8, 1593, 10, 9, 61243, 11, 8, 1121, 11, 9, 1579, // 10, 9
+10, 9, 1904, 10, 10, 60381, 11, 9, 1347, 11, 10, 1904, // 10,10
+10, 10, 2276, 10, 11, 59345, 11, 10, 1617, 11, 11, 2298, // 10,11
+10, 11, 2673, 10, 12, 58233, 11, 11, 1908, 11, 12, 2722, // 10,12
+10, 12, 3074, 10, 13, 57095, 11, 12, 2205, 11, 13, 3162, // 10,13
+10, 13, 3472, 10, 14, 55958, 11, 13, 2503, 11, 14, 3603, // 10,14
+10, 14, 3860, 10, 15, 54833, 11, 14, 2797, 11, 15, 4046, // 10,15
+10, -1, 2916, 10, 0, 4201, 11, -1, 4041, 11, 0, 54378, // 11, 0
+10, 0, 2640, 10, 1, 3785, 11, 0, 3677, 11, 1, 55434, // 11, 1
+10, 1, 2365, 10, 2, 3374, 11, 1, 3310, 11, 2, 56487, // 11, 2
+10, 2, 2096, 10, 3, 2977, 11, 2, 2948, 11, 3, 57515, // 11, 3
+10, 3, 1843, 10, 4, 2605, 11, 3, 2604, 11, 4, 58484, // 11, 4
+10, 4, 1617, 10, 5, 2276, 11, 4, 2297, 11, 5, 59346, // 11, 5
+10, 5, 1442, 10, 6, 2020, 11, 5, 2057, 11, 6, 60017, // 11, 6
+10, 6, 1341, 10, 7, 1871, 11, 6, 1922, 11, 7, 60402, // 11, 7
+11, 7, 1922, 11, 8, 60402, 12, 7, 1341, 12, 8, 1871, // 11, 8
+11, 8, 2057, 11, 9, 60018, 12, 8, 1442, 12, 9, 2019, // 11, 9
+11, 9, 2297, 11, 10, 59346, 12, 9, 1617, 12, 10, 2276, // 11,10
+11, 10, 2605, 11, 11, 58484, 12, 10, 1843, 12, 11, 2604, // 11,11
+11, 11, 2950, 11, 12, 57514, 12, 11, 2096, 12, 12, 2976, // 11,12
+11, 12, 3311, 11, 13, 56486, 12, 12, 2365, 12, 13, 3374, // 11,13
+11, 13, 3678, 11, 14, 55434, 12, 13, 2640, 12, 14, 3784, // 11,14
+11, 14, 4043, 11, 15, 54376, 12, 14, 2917, 12, 15, 4200, // 11,15
+11, -1, 3064, 11, 0, 4392, 12, -1, 4264, 12, 0, 53816, // 12, 0
+11, 0, 2808, 11, 1, 4005, 12, 0, 3927, 12, 1, 54796, // 12, 1
+11, 1, 2556, 11, 2, 3630, 12, 1, 3594, 12, 2, 55756, // 12, 2
+11, 2, 2317, 11, 3, 3274, 12, 2, 3273, 12, 3, 56672, // 12, 3
+11, 3, 2096, 11, 4, 2950, 12, 3, 2976, 12, 4, 57514, // 12, 4
+11, 4, 1908, 11, 5, 2673, 12, 4, 2722, 12, 5, 58233, // 12, 5
+11, 5, 1767, 11, 6, 2464, 12, 5, 2532, 12, 6, 58773, // 12, 6
+11, 6, 1687, 11, 7, 2343, 12, 6, 2430, 12, 7, 59076, // 12, 7
+12, 7, 2430, 12, 8, 59077, 13, 7, 1687, 13, 8, 2342, // 12, 8
+12, 8, 2532, 12, 9, 58775, 13, 8, 1766, 13, 9, 2463, // 12, 9
+12, 9, 2723, 12, 10, 58234, 13, 9, 1908, 13, 10, 2671, // 12,10
+12, 10, 2977, 12, 11, 57514, 13, 10, 2096, 13, 11, 2949, // 12,11
+12, 11, 3274, 12, 12, 56673, 13, 11, 2317, 13, 12, 3272, // 12,12
+12, 12, 3595, 12, 13, 55756, 13, 12, 2557, 13, 13, 3628, // 12,13
+12, 13, 3929, 12, 14, 54796, 13, 13, 2808, 13, 14, 4003, // 12,14
+12, 14, 4267, 12, 15, 53814, 13, 14, 3065, 13, 15, 4390, // 12,15
+12, -1, 3235, 12, 0, 4612, 13, -1, 4521, 13, 0, 53168, // 13, 0
+12, 0, 2998, 12, 1, 4255, 13, 0, 4212, 13, 1, 54071, // 13, 1
+12, 1, 2770, 12, 2, 3913, 13, 1, 3911, 13, 2, 54942, // 13, 2
+12, 2, 2557, 12, 3, 3595, 13, 2, 3628, 13, 3, 55756, // 13, 3
+12, 3, 2365, 12, 4, 3311, 13, 3, 3373, 13, 4, 56487, // 13, 4
+12, 4, 2205, 12, 5, 3074, 13, 4, 3161, 13, 5, 57096, // 13, 5
+12, 5, 2088, 12, 6, 2898, 13, 5, 3007, 13, 6, 57543, // 13, 6
+12, 6, 2022, 12, 7, 2795, 13, 6, 2926, 13, 7, 57793, // 13, 7
+13, 7, 2926, 13, 8, 57795, 14, 7, 2022, 14, 8, 2793, // 13, 8
+13, 8, 3007, 13, 9, 57545, 14, 8, 2088, 14, 9, 2896, // 13, 9
+13, 9, 3161, 13, 10, 57096, 14, 9, 2205, 14, 10, 3074, // 13,10
+13, 10, 3374, 13, 11, 56487, 14, 10, 2365, 14, 11, 3310, // 13,11
+13, 11, 3630, 13, 12, 55756, 14, 11, 2556, 14, 12, 3594, // 13,12
+13, 12, 3913, 13, 13, 54941, 14, 12, 2770, 14, 13, 3912, // 13,13
+13, 13, 4214, 13, 14, 54071, 14, 13, 2998, 14, 14, 4253, // 13,14
+13, 14, 4523, 13, 15, 53168, 14, 14, 3235, 14, 15, 4610, // 13,15
+13, -1, 3421, 13, 0, 4854, 14, -1, 4803, 14, 0, 52458, // 14, 0
+13, 0, 3204, 13, 1, 4525, 14, 0, 4522, 14, 1, 53285, // 14, 1
+13, 1, 2998, 13, 2, 4214, 14, 1, 4253, 14, 2, 54071, // 14, 2
+13, 2, 2808, 13, 3, 3929, 14, 2, 4003, 14, 3, 54796, // 14, 3
+13, 3, 2640, 13, 4, 3678, 14, 3, 3783, 14, 4, 55435, // 14, 4
+13, 4, 2503, 13, 5, 3472, 14, 4, 3604, 14, 5, 55957, // 14, 5
+13, 5, 2403, 13, 6, 3319, 14, 5, 3476, 14, 6, 56338, // 14, 6
+13, 6, 2346, 13, 7, 3227, 14, 6, 3411, 14, 7, 56552, // 14, 7
+14, 7, 3411, 14, 8, 56554, 15, 7, 2346, 15, 8, 3225, // 14, 8
+14, 8, 3477, 14, 9, 56340, 15, 8, 2402, 15, 9, 3317, // 14, 9
+14, 9, 3605, 14, 10, 55959, 15, 9, 2502, 15, 10, 3470, // 14,10
+14, 10, 3785, 14, 11, 55435, 15, 10, 2640, 15, 11, 3676, // 14,11
+14, 11, 4005, 14, 12, 54796, 15, 11, 2808, 15, 12, 3927, // 14,12
+14, 12, 4255, 14, 13, 54072, 15, 12, 2998, 15, 13, 4211, // 14,13
+14, 13, 4525, 14, 14, 53285, 15, 13, 3204, 15, 14, 4522, // 14,14
+14, 14, 4806, 14, 15, 52457, 15, 14, 3422, 15, 15, 4851, // 14,15
+14, -1, 3621, 14, 0, 5110, 15, -1, 5106, 15, 0, 51699, // 15, 0
+14, 0, 3422, 14, 1, 4806, 15, 0, 4851, 15, 1, 52457, // 15, 1
+14, 1, 3235, 14, 2, 4523, 15, 1, 4610, 15, 2, 53168, // 15, 2
+14, 2, 3065, 14, 3, 4267, 15, 2, 4390, 15, 3, 53814, // 15, 3
+14, 3, 2917, 14, 4, 4043, 15, 3, 4200, 15, 4, 54376, // 15, 4
+14, 4, 2797, 14, 5, 3860, 15, 4, 4046, 15, 5, 54833, // 15, 5
+14, 5, 2709, 14, 6, 3724, 15, 5, 3939, 15, 6, 55164, // 15, 6
+14, 6, 2659, 14, 7, 3640, 15, 6, 3885, 15, 7, 55352, // 15, 7
+15, 7, 3885, 15, 8, 55354, 16, 7, 2659, 16, 8, 3638, // 15, 8
+15, 8, 3940, 15, 9, 55166, 16, 8, 2709, 16, 9, 3721, // 15, 9
+15, 9, 4047, 15, 10, 54835, 16, 9, 2796, 16, 10, 3858, // 15,10
+15, 10, 4201, 15, 11, 54378, 16, 10, 2916, 16, 11, 4041, // 15,11
+15, 11, 4392, 15, 12, 53815, 16, 11, 3064, 16, 12, 4265, // 15,12
+15, 12, 4612, 15, 13, 53168, 16, 12, 3235, 16, 13, 4521, // 15,13
+15, 13, 4854, 15, 14, 52457, 16, 13, 3421, 16, 14, 4804, // 15,14
+15, 14, 5110, 15, 15, 51699, 16, 14, 3621, 16, 15, 5106, // 15,15
+// angle of 0.0 degrees
+0, 0, 16384, 0, 0, 16384, 0, 0, 16384, 0, 0, 16384, // 0, 0
+0, 1, 16384, 0, 1, 16384, 0, 1, 16384, 0, 1, 16384, // 0, 1
+0, 2, 16384, 0, 2, 16384, 0, 2, 16384, 0, 2, 16384, // 0, 2
+0, 3, 16384, 0, 3, 16384, 0, 3, 16384, 0, 3, 16384, // 0, 3
+0, 4, 16384, 0, 4, 16384, 0, 4, 16384, 0, 4, 16384, // 0, 4
+0, 5, 16384, 0, 5, 16384, 0, 5, 16384, 0, 5, 16384, // 0, 5
+0, 6, 16384, 0, 6, 16384, 0, 6, 16384, 0, 6, 16384, // 0, 6
+0, 7, 16384, 0, 7, 16384, 0, 7, 16384, 0, 7, 16384, // 0, 7
+0, 8, 16384, 0, 8, 16384, 0, 8, 16384, 0, 8, 16384, // 0, 8
+0, 9, 16384, 0, 9, 16384, 0, 9, 16384, 0, 9, 16384, // 0, 9
+0, 10, 16384, 0, 10, 16384, 0, 10, 16384, 0, 10, 16384, // 0,10
+0, 11, 16384, 0, 11, 16384, 0, 11, 16384, 0, 11, 16384, // 0,11
+0, 12, 16384, 0, 12, 16384, 0, 12, 16384, 0, 12, 16384, // 0,12
+0, 13, 16384, 0, 13, 16384, 0, 13, 16384, 0, 13, 16384, // 0,13
+0, 14, 16384, 0, 14, 16384, 0, 14, 16384, 0, 14, 16384, // 0,14
+0, 15, 16384, 0, 15, 16384, 0, 15, 16384, 0, 15, 16384, // 0,15
+1, 0, 16384, 1, 0, 16384, 1, 0, 16384, 1, 0, 16384, // 1, 0
+1, 1, 16384, 1, 1, 16384, 1, 1, 16384, 1, 1, 16384, // 1, 1
+1, 2, 16384, 1, 2, 16384, 1, 2, 16384, 1, 2, 16384, // 1, 2
+1, 3, 16384, 1, 3, 16384, 1, 3, 16384, 1, 3, 16384, // 1, 3
+1, 4, 16384, 1, 4, 16384, 1, 4, 16384, 1, 4, 16384, // 1, 4
+1, 5, 16384, 1, 5, 16384, 1, 5, 16384, 1, 5, 16384, // 1, 5
+1, 6, 16384, 1, 6, 16384, 1, 6, 16384, 1, 6, 16384, // 1, 6
+1, 7, 16384, 1, 7, 16384, 1, 7, 16384, 1, 7, 16384, // 1, 7
+1, 8, 16384, 1, 8, 16384, 1, 8, 16384, 1, 8, 16384, // 1, 8
+1, 9, 16384, 1, 9, 16384, 1, 9, 16384, 1, 9, 16384, // 1, 9
+1, 10, 16384, 1, 10, 16384, 1, 10, 16384, 1, 10, 16384, // 1,10
+1, 11, 16384, 1, 11, 16384, 1, 11, 16384, 1, 11, 16384, // 1,11
+1, 12, 16384, 1, 12, 16384, 1, 12, 16384, 1, 12, 16384, // 1,12
+1, 13, 16384, 1, 13, 16384, 1, 13, 16384, 1, 13, 16384, // 1,13
+1, 14, 16384, 1, 14, 16384, 1, 14, 16384, 1, 14, 16384, // 1,14
+1, 15, 16384, 1, 15, 16384, 1, 15, 16384, 1, 15, 16384, // 1,15
+2, 0, 16384, 2, 0, 16384, 2, 0, 16384, 2, 0, 16384, // 2, 0
+2, 1, 16384, 2, 1, 16384, 2, 1, 16384, 2, 1, 16384, // 2, 1
+2, 2, 16384, 2, 2, 16384, 2, 2, 16384, 2, 2, 16384, // 2, 2
+2, 3, 16384, 2, 3, 16384, 2, 3, 16384, 2, 3, 16384, // 2, 3
+2, 4, 16384, 2, 4, 16384, 2, 4, 16384, 2, 4, 16384, // 2, 4
+2, 5, 16384, 2, 5, 16384, 2, 5, 16384, 2, 5, 16384, // 2, 5
+2, 6, 16384, 2, 6, 16384, 2, 6, 16384, 2, 6, 16384, // 2, 6
+2, 7, 16384, 2, 7, 16384, 2, 7, 16384, 2, 7, 16384, // 2, 7
+2, 8, 16384, 2, 8, 16384, 2, 8, 16384, 2, 8, 16384, // 2, 8
+2, 9, 16384, 2, 9, 16384, 2, 9, 16384, 2, 9, 16384, // 2, 9
+2, 10, 16384, 2, 10, 16384, 2, 10, 16384, 2, 10, 16384, // 2,10
+2, 11, 16384, 2, 11, 16384, 2, 11, 16384, 2, 11, 16384, // 2,11
+2, 12, 16384, 2, 12, 16384, 2, 12, 16384, 2, 12, 16384, // 2,12
+2, 13, 16384, 2, 13, 16384, 2, 13, 16384, 2, 13, 16384, // 2,13
+2, 14, 16384, 2, 14, 16384, 2, 14, 16384, 2, 14, 16384, // 2,14
+2, 15, 16384, 2, 15, 16384, 2, 15, 16384, 2, 15, 16384, // 2,15
+3, 0, 16384, 3, 0, 16384, 3, 0, 16384, 3, 0, 16384, // 3, 0
+3, 1, 16384, 3, 1, 16384, 3, 1, 16384, 3, 1, 16384, // 3, 1
+3, 2, 16384, 3, 2, 16384, 3, 2, 16384, 3, 2, 16384, // 3, 2
+3, 3, 16384, 3, 3, 16384, 3, 3, 16384, 3, 3, 16384, // 3, 3
+3, 4, 16384, 3, 4, 16384, 3, 4, 16384, 3, 4, 16384, // 3, 4
+3, 5, 16384, 3, 5, 16384, 3, 5, 16384, 3, 5, 16384, // 3, 5
+3, 6, 16384, 3, 6, 16384, 3, 6, 16384, 3, 6, 16384, // 3, 6
+3, 7, 16384, 3, 7, 16384, 3, 7, 16384, 3, 7, 16384, // 3, 7
+3, 8, 16384, 3, 8, 16384, 3, 8, 16384, 3, 8, 16384, // 3, 8
+3, 9, 16384, 3, 9, 16384, 3, 9, 16384, 3, 9, 16384, // 3, 9
+3, 10, 16384, 3, 10, 16384, 3, 10, 16384, 3, 10, 16384, // 3,10
+3, 11, 16384, 3, 11, 16384, 3, 11, 16384, 3, 11, 16384, // 3,11
+3, 12, 16384, 3, 12, 16384, 3, 12, 16384, 3, 12, 16384, // 3,12
+3, 13, 16384, 3, 13, 16384, 3, 13, 16384, 3, 13, 16384, // 3,13
+3, 14, 16384, 3, 14, 16384, 3, 14, 16384, 3, 14, 16384, // 3,14
+3, 15, 16384, 3, 15, 16384, 3, 15, 16384, 3, 15, 16384, // 3,15
+4, 0, 16384, 4, 0, 16384, 4, 0, 16384, 4, 0, 16384, // 4, 0
+4, 1, 16384, 4, 1, 16384, 4, 1, 16384, 4, 1, 16384, // 4, 1
+4, 2, 16384, 4, 2, 16384, 4, 2, 16384, 4, 2, 16384, // 4, 2
+4, 3, 16384, 4, 3, 16384, 4, 3, 16384, 4, 3, 16384, // 4, 3
+4, 4, 16384, 4, 4, 16384, 4, 4, 16384, 4, 4, 16384, // 4, 4
+4, 5, 16384, 4, 5, 16384, 4, 5, 16384, 4, 5, 16384, // 4, 5
+4, 6, 16384, 4, 6, 16384, 4, 6, 16384, 4, 6, 16384, // 4, 6
+4, 7, 16384, 4, 7, 16384, 4, 7, 16384, 4, 7, 16384, // 4, 7
+4, 8, 16384, 4, 8, 16384, 4, 8, 16384, 4, 8, 16384, // 4, 8
+4, 9, 16384, 4, 9, 16384, 4, 9, 16384, 4, 9, 16384, // 4, 9
+4, 10, 16384, 4, 10, 16384, 4, 10, 16384, 4, 10, 16384, // 4,10
+4, 11, 16384, 4, 11, 16384, 4, 11, 16384, 4, 11, 16384, // 4,11
+4, 12, 16384, 4, 12, 16384, 4, 12, 16384, 4, 12, 16384, // 4,12
+4, 13, 16384, 4, 13, 16384, 4, 13, 16384, 4, 13, 16384, // 4,13
+4, 14, 16384, 4, 14, 16384, 4, 14, 16384, 4, 14, 16384, // 4,14
+4, 15, 16384, 4, 15, 16384, 4, 15, 16384, 4, 15, 16384, // 4,15
+5, 0, 16384, 5, 0, 16384, 5, 0, 16384, 5, 0, 16384, // 5, 0
+5, 1, 16384, 5, 1, 16384, 5, 1, 16384, 5, 1, 16384, // 5, 1
+5, 2, 16384, 5, 2, 16384, 5, 2, 16384, 5, 2, 16384, // 5, 2
+5, 3, 16384, 5, 3, 16384, 5, 3, 16384, 5, 3, 16384, // 5, 3
+5, 4, 16384, 5, 4, 16384, 5, 4, 16384, 5, 4, 16384, // 5, 4
+5, 5, 16384, 5, 5, 16384, 5, 5, 16384, 5, 5, 16384, // 5, 5
+5, 6, 16384, 5, 6, 16384, 5, 6, 16384, 5, 6, 16384, // 5, 6
+5, 7, 16384, 5, 7, 16384, 5, 7, 16384, 5, 7, 16384, // 5, 7
+5, 8, 16384, 5, 8, 16384, 5, 8, 16384, 5, 8, 16384, // 5, 8
+5, 9, 16384, 5, 9, 16384, 5, 9, 16384, 5, 9, 16384, // 5, 9
+5, 10, 16384, 5, 10, 16384, 5, 10, 16384, 5, 10, 16384, // 5,10
+5, 11, 16384, 5, 11, 16384, 5, 11, 16384, 5, 11, 16384, // 5,11
+5, 12, 16384, 5, 12, 16384, 5, 12, 16384, 5, 12, 16384, // 5,12
+5, 13, 16384, 5, 13, 16384, 5, 13, 16384, 5, 13, 16384, // 5,13
+5, 14, 16384, 5, 14, 16384, 5, 14, 16384, 5, 14, 16384, // 5,14
+5, 15, 16384, 5, 15, 16384, 5, 15, 16384, 5, 15, 16384, // 5,15
+6, 0, 16384, 6, 0, 16384, 6, 0, 16384, 6, 0, 16384, // 6, 0
+6, 1, 16384, 6, 1, 16384, 6, 1, 16384, 6, 1, 16384, // 6, 1
+6, 2, 16384, 6, 2, 16384, 6, 2, 16384, 6, 2, 16384, // 6, 2
+6, 3, 16384, 6, 3, 16384, 6, 3, 16384, 6, 3, 16384, // 6, 3
+6, 4, 16384, 6, 4, 16384, 6, 4, 16384, 6, 4, 16384, // 6, 4
+6, 5, 16384, 6, 5, 16384, 6, 5, 16384, 6, 5, 16384, // 6, 5
+6, 6, 16384, 6, 6, 16384, 6, 6, 16384, 6, 6, 16384, // 6, 6
+6, 7, 16384, 6, 7, 16384, 6, 7, 16384, 6, 7, 16384, // 6, 7
+6, 8, 16384, 6, 8, 16384, 6, 8, 16384, 6, 8, 16384, // 6, 8
+6, 9, 16384, 6, 9, 16384, 6, 9, 16384, 6, 9, 16384, // 6, 9
+6, 10, 16384, 6, 10, 16384, 6, 10, 16384, 6, 10, 16384, // 6,10
+6, 11, 16384, 6, 11, 16384, 6, 11, 16384, 6, 11, 16384, // 6,11
+6, 12, 16384, 6, 12, 16384, 6, 12, 16384, 6, 12, 16384, // 6,12
+6, 13, 16384, 6, 13, 16384, 6, 13, 16384, 6, 13, 16384, // 6,13
+6, 14, 16384, 6, 14, 16384, 6, 14, 16384, 6, 14, 16384, // 6,14
+6, 15, 16384, 6, 15, 16384, 6, 15, 16384, 6, 15, 16384, // 6,15
+7, 0, 16384, 7, 0, 16384, 7, 0, 16384, 7, 0, 16384, // 7, 0
+7, 1, 16384, 7, 1, 16384, 7, 1, 16384, 7, 1, 16384, // 7, 1
+7, 2, 16384, 7, 2, 16384, 7, 2, 16384, 7, 2, 16384, // 7, 2
+7, 3, 16384, 7, 3, 16384, 7, 3, 16384, 7, 3, 16384, // 7, 3
+7, 4, 16384, 7, 4, 16384, 7, 4, 16384, 7, 4, 16384, // 7, 4
+7, 5, 16384, 7, 5, 16384, 7, 5, 16384, 7, 5, 16384, // 7, 5
+7, 6, 16384, 7, 6, 16384, 7, 6, 16384, 7, 6, 16384, // 7, 6
+7, 7, 16384, 7, 7, 16384, 7, 7, 16384, 7, 7, 16384, // 7, 7
+7, 8, 16384, 7, 8, 16384, 7, 8, 16384, 7, 8, 16384, // 7, 8
+7, 9, 16384, 7, 9, 16384, 7, 9, 16384, 7, 9, 16384, // 7, 9
+7, 10, 16384, 7, 10, 16384, 7, 10, 16384, 7, 10, 16384, // 7,10
+7, 11, 16384, 7, 11, 16384, 7, 11, 16384, 7, 11, 16384, // 7,11
+7, 12, 16384, 7, 12, 16384, 7, 12, 16384, 7, 12, 16384, // 7,12
+7, 13, 16384, 7, 13, 16384, 7, 13, 16384, 7, 13, 16384, // 7,13
+7, 14, 16384, 7, 14, 16384, 7, 14, 16384, 7, 14, 16384, // 7,14
+7, 15, 16384, 7, 15, 16384, 7, 15, 16384, 7, 15, 16384, // 7,15
+8, 0, 16384, 8, 0, 16384, 8, 0, 16384, 8, 0, 16384, // 8, 0
+8, 1, 16384, 8, 1, 16384, 8, 1, 16384, 8, 1, 16384, // 8, 1
+8, 2, 16384, 8, 2, 16384, 8, 2, 16384, 8, 2, 16384, // 8, 2
+8, 3, 16384, 8, 3, 16384, 8, 3, 16384, 8, 3, 16384, // 8, 3
+8, 4, 16384, 8, 4, 16384, 8, 4, 16384, 8, 4, 16384, // 8, 4
+8, 5, 16384, 8, 5, 16384, 8, 5, 16384, 8, 5, 16384, // 8, 5
+8, 6, 16384, 8, 6, 16384, 8, 6, 16384, 8, 6, 16384, // 8, 6
+8, 7, 16384, 8, 7, 16384, 8, 7, 16384, 8, 7, 16384, // 8, 7
+8, 8, 16384, 8, 8, 16384, 8, 8, 16384, 8, 8, 16384, // 8, 8
+8, 9, 16384, 8, 9, 16384, 8, 9, 16384, 8, 9, 16384, // 8, 9
+8, 10, 16384, 8, 10, 16384, 8, 10, 16384, 8, 10, 16384, // 8,10
+8, 11, 16384, 8, 11, 16384, 8, 11, 16384, 8, 11, 16384, // 8,11
+8, 12, 16384, 8, 12, 16384, 8, 12, 16384, 8, 12, 16384, // 8,12
+8, 13, 16384, 8, 13, 16384, 8, 13, 16384, 8, 13, 16384, // 8,13
+8, 14, 16384, 8, 14, 16384, 8, 14, 16384, 8, 14, 16384, // 8,14
+8, 15, 16384, 8, 15, 16384, 8, 15, 16384, 8, 15, 16384, // 8,15
+9, 0, 16384, 9, 0, 16384, 9, 0, 16384, 9, 0, 16384, // 9, 0
+9, 1, 16384, 9, 1, 16384, 9, 1, 16384, 9, 1, 16384, // 9, 1
+9, 2, 16384, 9, 2, 16384, 9, 2, 16384, 9, 2, 16384, // 9, 2
+9, 3, 16384, 9, 3, 16384, 9, 3, 16384, 9, 3, 16384, // 9, 3
+9, 4, 16384, 9, 4, 16384, 9, 4, 16384, 9, 4, 16384, // 9, 4
+9, 5, 16384, 9, 5, 16384, 9, 5, 16384, 9, 5, 16384, // 9, 5
+9, 6, 16384, 9, 6, 16384, 9, 6, 16384, 9, 6, 16384, // 9, 6
+9, 7, 16384, 9, 7, 16384, 9, 7, 16384, 9, 7, 16384, // 9, 7
+9, 8, 16384, 9, 8, 16384, 9, 8, 16384, 9, 8, 16384, // 9, 8
+9, 9, 16384, 9, 9, 16384, 9, 9, 16384, 9, 9, 16384, // 9, 9
+9, 10, 16384, 9, 10, 16384, 9, 10, 16384, 9, 10, 16384, // 9,10
+9, 11, 16384, 9, 11, 16384, 9, 11, 16384, 9, 11, 16384, // 9,11
+9, 12, 16384, 9, 12, 16384, 9, 12, 16384, 9, 12, 16384, // 9,12
+9, 13, 16384, 9, 13, 16384, 9, 13, 16384, 9, 13, 16384, // 9,13
+9, 14, 16384, 9, 14, 16384, 9, 14, 16384, 9, 14, 16384, // 9,14
+9, 15, 16384, 9, 15, 16384, 9, 15, 16384, 9, 15, 16384, // 9,15
+10, 0, 16384, 10, 0, 16384, 10, 0, 16384, 10, 0, 16384, // 10, 0
+10, 1, 16384, 10, 1, 16384, 10, 1, 16384, 10, 1, 16384, // 10, 1
+10, 2, 16384, 10, 2, 16384, 10, 2, 16384, 10, 2, 16384, // 10, 2
+10, 3, 16384, 10, 3, 16384, 10, 3, 16384, 10, 3, 16384, // 10, 3
+10, 4, 16384, 10, 4, 16384, 10, 4, 16384, 10, 4, 16384, // 10, 4
+10, 5, 16384, 10, 5, 16384, 10, 5, 16384, 10, 5, 16384, // 10, 5
+10, 6, 16384, 10, 6, 16384, 10, 6, 16384, 10, 6, 16384, // 10, 6
+10, 7, 16384, 10, 7, 16384, 10, 7, 16384, 10, 7, 16384, // 10, 7
+10, 8, 16384, 10, 8, 16384, 10, 8, 16384, 10, 8, 16384, // 10, 8
+10, 9, 16384, 10, 9, 16384, 10, 9, 16384, 10, 9, 16384, // 10, 9
+10, 10, 16384, 10, 10, 16384, 10, 10, 16384, 10, 10, 16384, // 10,10
+10, 11, 16384, 10, 11, 16384, 10, 11, 16384, 10, 11, 16384, // 10,11
+10, 12, 16384, 10, 12, 16384, 10, 12, 16384, 10, 12, 16384, // 10,12
+10, 13, 16384, 10, 13, 16384, 10, 13, 16384, 10, 13, 16384, // 10,13
+10, 14, 16384, 10, 14, 16384, 10, 14, 16384, 10, 14, 16384, // 10,14
+10, 15, 16384, 10, 15, 16384, 10, 15, 16384, 10, 15, 16384, // 10,15
+11, 0, 16384, 11, 0, 16384, 11, 0, 16384, 11, 0, 16384, // 11, 0
+11, 1, 16384, 11, 1, 16384, 11, 1, 16384, 11, 1, 16384, // 11, 1
+11, 2, 16384, 11, 2, 16384, 11, 2, 16384, 11, 2, 16384, // 11, 2
+11, 3, 16384, 11, 3, 16384, 11, 3, 16384, 11, 3, 16384, // 11, 3
+11, 4, 16384, 11, 4, 16384, 11, 4, 16384, 11, 4, 16384, // 11, 4
+11, 5, 16384, 11, 5, 16384, 11, 5, 16384, 11, 5, 16384, // 11, 5
+11, 6, 16384, 11, 6, 16384, 11, 6, 16384, 11, 6, 16384, // 11, 6
+11, 7, 16384, 11, 7, 16384, 11, 7, 16384, 11, 7, 16384, // 11, 7
+11, 8, 16384, 11, 8, 16384, 11, 8, 16384, 11, 8, 16384, // 11, 8
+11, 9, 16384, 11, 9, 16384, 11, 9, 16384, 11, 9, 16384, // 11, 9
+11, 10, 16384, 11, 10, 16384, 11, 10, 16384, 11, 10, 16384, // 11,10
+11, 11, 16384, 11, 11, 16384, 11, 11, 16384, 11, 11, 16384, // 11,11
+11, 12, 16384, 11, 12, 16384, 11, 12, 16384, 11, 12, 16384, // 11,12
+11, 13, 16384, 11, 13, 16384, 11, 13, 16384, 11, 13, 16384, // 11,13
+11, 14, 16384, 11, 14, 16384, 11, 14, 16384, 11, 14, 16384, // 11,14
+11, 15, 16384, 11, 15, 16384, 11, 15, 16384, 11, 15, 16384, // 11,15
+12, 0, 16384, 12, 0, 16384, 12, 0, 16384, 12, 0, 16384, // 12, 0
+12, 1, 16384, 12, 1, 16384, 12, 1, 16384, 12, 1, 16384, // 12, 1
+12, 2, 16384, 12, 2, 16384, 12, 2, 16384, 12, 2, 16384, // 12, 2
+12, 3, 16384, 12, 3, 16384, 12, 3, 16384, 12, 3, 16384, // 12, 3
+12, 4, 16384, 12, 4, 16384, 12, 4, 16384, 12, 4, 16384, // 12, 4
+12, 5, 16384, 12, 5, 16384, 12, 5, 16384, 12, 5, 16384, // 12, 5
+12, 6, 16384, 12, 6, 16384, 12, 6, 16384, 12, 6, 16384, // 12, 6
+12, 7, 16384, 12, 7, 16384, 12, 7, 16384, 12, 7, 16384, // 12, 7
+12, 8, 16384, 12, 8, 16384, 12, 8, 16384, 12, 8, 16384, // 12, 8
+12, 9, 16384, 12, 9, 16384, 12, 9, 16384, 12, 9, 16384, // 12, 9
+12, 10, 16384, 12, 10, 16384, 12, 10, 16384, 12, 10, 16384, // 12,10
+12, 11, 16384, 12, 11, 16384, 12, 11, 16384, 12, 11, 16384, // 12,11
+12, 12, 16384, 12, 12, 16384, 12, 12, 16384, 12, 12, 16384, // 12,12
+12, 13, 16384, 12, 13, 16384, 12, 13, 16384, 12, 13, 16384, // 12,13
+12, 14, 16384, 12, 14, 16384, 12, 14, 16384, 12, 14, 16384, // 12,14
+12, 15, 16384, 12, 15, 16384, 12, 15, 16384, 12, 15, 16384, // 12,15
+13, 0, 16384, 13, 0, 16384, 13, 0, 16384, 13, 0, 16384, // 13, 0
+13, 1, 16384, 13, 1, 16384, 13, 1, 16384, 13, 1, 16384, // 13, 1
+13, 2, 16384, 13, 2, 16384, 13, 2, 16384, 13, 2, 16384, // 13, 2
+13, 3, 16384, 13, 3, 16384, 13, 3, 16384, 13, 3, 16384, // 13, 3
+13, 4, 16384, 13, 4, 16384, 13, 4, 16384, 13, 4, 16384, // 13, 4
+13, 5, 16384, 13, 5, 16384, 13, 5, 16384, 13, 5, 16384, // 13, 5
+13, 6, 16384, 13, 6, 16384, 13, 6, 16384, 13, 6, 16384, // 13, 6
+13, 7, 16384, 13, 7, 16384, 13, 7, 16384, 13, 7, 16384, // 13, 7
+13, 8, 16384, 13, 8, 16384, 13, 8, 16384, 13, 8, 16384, // 13, 8
+13, 9, 16384, 13, 9, 16384, 13, 9, 16384, 13, 9, 16384, // 13, 9
+13, 10, 16384, 13, 10, 16384, 13, 10, 16384, 13, 10, 16384, // 13,10
+13, 11, 16384, 13, 11, 16384, 13, 11, 16384, 13, 11, 16384, // 13,11
+13, 12, 16384, 13, 12, 16384, 13, 12, 16384, 13, 12, 16384, // 13,12
+13, 13, 16384, 13, 13, 16384, 13, 13, 16384, 13, 13, 16384, // 13,13
+13, 14, 16384, 13, 14, 16384, 13, 14, 16384, 13, 14, 16384, // 13,14
+13, 15, 16384, 13, 15, 16384, 13, 15, 16384, 13, 15, 16384, // 13,15
+14, 0, 16384, 14, 0, 16384, 14, 0, 16384, 14, 0, 16384, // 14, 0
+14, 1, 16384, 14, 1, 16384, 14, 1, 16384, 14, 1, 16384, // 14, 1
+14, 2, 16384, 14, 2, 16384, 14, 2, 16384, 14, 2, 16384, // 14, 2
+14, 3, 16384, 14, 3, 16384, 14, 3, 16384, 14, 3, 16384, // 14, 3
+14, 4, 16384, 14, 4, 16384, 14, 4, 16384, 14, 4, 16384, // 14, 4
+14, 5, 16384, 14, 5, 16384, 14, 5, 16384, 14, 5, 16384, // 14, 5
+14, 6, 16384, 14, 6, 16384, 14, 6, 16384, 14, 6, 16384, // 14, 6
+14, 7, 16384, 14, 7, 16384, 14, 7, 16384, 14, 7, 16384, // 14, 7
+14, 8, 16384, 14, 8, 16384, 14, 8, 16384, 14, 8, 16384, // 14, 8
+14, 9, 16384, 14, 9, 16384, 14, 9, 16384, 14, 9, 16384, // 14, 9
+14, 10, 16384, 14, 10, 16384, 14, 10, 16384, 14, 10, 16384, // 14,10
+14, 11, 16384, 14, 11, 16384, 14, 11, 16384, 14, 11, 16384, // 14,11
+14, 12, 16384, 14, 12, 16384, 14, 12, 16384, 14, 12, 16384, // 14,12
+14, 13, 16384, 14, 13, 16384, 14, 13, 16384, 14, 13, 16384, // 14,13
+14, 14, 16384, 14, 14, 16384, 14, 14, 16384, 14, 14, 16384, // 14,14
+14, 15, 16384, 14, 15, 16384, 14, 15, 16384, 14, 15, 16384, // 14,15
+15, 0, 16384, 15, 0, 16384, 15, 0, 16384, 15, 0, 16384, // 15, 0
+15, 1, 16384, 15, 1, 16384, 15, 1, 16384, 15, 1, 16384, // 15, 1
+15, 2, 16384, 15, 2, 16384, 15, 2, 16384, 15, 2, 16384, // 15, 2
+15, 3, 16384, 15, 3, 16384, 15, 3, 16384, 15, 3, 16384, // 15, 3
+15, 4, 16384, 15, 4, 16384, 15, 4, 16384, 15, 4, 16384, // 15, 4
+15, 5, 16384, 15, 5, 16384, 15, 5, 16384, 15, 5, 16384, // 15, 5
+15, 6, 16384, 15, 6, 16384, 15, 6, 16384, 15, 6, 16384, // 15, 6
+15, 7, 16384, 15, 7, 16384, 15, 7, 16384, 15, 7, 16384, // 15, 7
+15, 8, 16384, 15, 8, 16384, 15, 8, 16384, 15, 8, 16384, // 15, 8
+15, 9, 16384, 15, 9, 16384, 15, 9, 16384, 15, 9, 16384, // 15, 9
+15, 10, 16384, 15, 10, 16384, 15, 10, 16384, 15, 10, 16384, // 15,10
+15, 11, 16384, 15, 11, 16384, 15, 11, 16384, 15, 11, 16384, // 15,11
+15, 12, 16384, 15, 12, 16384, 15, 12, 16384, 15, 12, 16384, // 15,12
+15, 13, 16384, 15, 13, 16384, 15, 13, 16384, 15, 13, 16384, // 15,13
+15, 14, 16384, 15, 14, 16384, 15, 14, 16384, 15, 14, 16384, // 15,14
+15, 15, 16384, 15, 15, 16384, 15, 15, 16384, 15, 15, 16384, // 15,15
+// angle of 0.5 degrees
+0, -1, 5106, 0, 0, 51699, 1, -1, 3621, 1, 0, 5110, // 0, 0
+0, 0, 4851, 0, 1, 52457, 1, 0, 3422, 1, 1, 4806, // 0, 1
+0, 1, 4610, 0, 2, 53168, 1, 1, 3235, 1, 2, 4523, // 0, 2
+0, 2, 4390, 0, 3, 53814, 1, 2, 3065, 1, 3, 4267, // 0, 3
+0, 3, 4200, 0, 4, 54376, 1, 3, 2917, 1, 4, 4043, // 0, 4
+0, 4, 4046, 0, 5, 54833, 1, 4, 2797, 1, 5, 3860, // 0, 5
+0, 5, 3939, 0, 6, 55164, 1, 5, 2709, 1, 6, 3724, // 0, 6
+0, 6, 3885, 0, 7, 55352, 1, 6, 2659, 1, 7, 3640, // 0, 7
+-1, 7, 2659, -1, 8, 3638, 0, 7, 3885, 0, 8, 55354, // 0, 8
+-1, 8, 2709, -1, 9, 3722, 0, 8, 3940, 0, 9, 55165, // 0, 9
+-1, 9, 2796, -1, 10, 3858, 0, 9, 4047, 0, 10, 54835, // 0,10
+-1, 10, 2916, -1, 11, 4041, 0, 10, 4201, 0, 11, 54378, // 0,11
+-1, 11, 3064, -1, 12, 4264, 0, 11, 4392, 0, 12, 53816, // 0,12
+-1, 12, 3235, -1, 13, 4521, 0, 12, 4612, 0, 13, 53168, // 0,13
+-1, 13, 3421, -1, 14, 4803, 0, 13, 4854, 0, 14, 52458, // 0,14
+-1, 14, 3621, -1, 15, 5106, 0, 14, 5110, 0, 15, 51699, // 0,15
+1, -1, 4803, 1, 0, 52457, 2, -1, 3421, 2, 0, 4855, // 1, 0
+1, 0, 4522, 1, 1, 53285, 2, 0, 3204, 2, 1, 4525, // 1, 1
+1, 1, 4253, 1, 2, 54071, 2, 1, 2998, 2, 2, 4214, // 1, 2
+1, 2, 4003, 1, 3, 54796, 2, 2, 2808, 2, 3, 3929, // 1, 3
+1, 3, 3783, 1, 4, 55434, 2, 3, 2640, 2, 4, 3679, // 1, 4
+1, 4, 3604, 1, 5, 55958, 2, 4, 2503, 2, 5, 3471, // 1, 5
+1, 5, 3476, 1, 6, 56339, 2, 5, 2403, 2, 6, 3318, // 1, 6
+1, 6, 3411, 1, 7, 56552, 2, 6, 2346, 2, 7, 3227, // 1, 7
+0, 7, 2346, 0, 8, 3225, 1, 7, 3411, 1, 8, 56554, // 1, 8
+0, 8, 2402, 0, 9, 3317, 1, 8, 3477, 1, 9, 56340, // 1, 9
+0, 9, 2502, 0, 10, 3470, 1, 9, 3605, 1, 10, 55959, // 1,10
+0, 10, 2640, 0, 11, 3677, 1, 10, 3785, 1, 11, 55434, // 1,11
+0, 11, 2808, 0, 12, 3927, 1, 11, 4005, 1, 12, 54796, // 1,12
+0, 12, 2998, 0, 13, 4212, 1, 12, 4255, 1, 13, 54071, // 1,13
+0, 13, 3204, 0, 14, 4522, 1, 13, 4525, 1, 14, 53285, // 1,14
+0, 14, 3422, 0, 15, 4851, 1, 14, 4806, 1, 15, 52457, // 1,15
+2, -1, 4521, 2, 0, 53168, 3, -1, 3235, 3, 0, 4612, // 2, 0
+2, 0, 4212, 2, 1, 54072, 3, 0, 2998, 3, 1, 4254, // 2, 1
+2, 1, 3911, 2, 2, 54941, 3, 1, 2770, 3, 2, 3914, // 2, 2
+2, 2, 3628, 2, 3, 55756, 3, 2, 2557, 3, 3, 3595, // 2, 3
+2, 3, 3373, 2, 4, 56486, 3, 3, 2365, 3, 4, 3312, // 2, 4
+2, 4, 3161, 2, 5, 57095, 3, 4, 2205, 3, 5, 3075, // 2, 5
+2, 5, 3007, 2, 6, 57544, 3, 5, 2088, 3, 6, 2897, // 2, 6
+2, 6, 2926, 2, 7, 57793, 3, 6, 2022, 3, 7, 2795, // 2, 7
+1, 7, 2022, 1, 8, 2794, 2, 7, 2926, 2, 8, 57794, // 2, 8
+1, 8, 2088, 1, 9, 2897, 2, 8, 3007, 2, 9, 57544, // 2, 9
+1, 9, 2205, 1, 10, 3073, 2, 9, 3161, 2, 10, 57097, // 2,10
+1, 10, 2365, 1, 11, 3310, 2, 10, 3374, 2, 11, 56487, // 2,11
+1, 11, 2556, 1, 12, 3594, 2, 11, 3630, 2, 12, 55756, // 2,12
+1, 12, 2770, 1, 13, 3911, 2, 12, 3913, 2, 13, 54942, // 2,13
+1, 13, 2998, 1, 14, 4253, 2, 13, 4214, 2, 14, 54071, // 2,14
+1, 14, 3235, 1, 15, 4610, 2, 14, 4523, 2, 15, 53168, // 2,15
+3, -1, 4264, 3, 0, 53815, 4, -1, 3064, 4, 0, 4393, // 3, 0
+3, 0, 3927, 3, 1, 54796, 4, 0, 2808, 4, 1, 4005, // 3, 1
+3, 1, 3594, 3, 2, 55756, 4, 1, 2556, 4, 2, 3630, // 3, 2
+3, 2, 3273, 3, 3, 56673, 4, 2, 2317, 4, 3, 3273, // 3, 3
+3, 3, 2976, 3, 4, 57514, 4, 3, 2096, 4, 4, 2950, // 3, 4
+3, 4, 2722, 3, 5, 58233, 4, 4, 1908, 4, 5, 2673, // 3, 5
+3, 5, 2532, 3, 6, 58774, 4, 5, 1767, 4, 6, 2463, // 3, 6
+3, 6, 2430, 3, 7, 59076, 4, 6, 1687, 4, 7, 2343, // 3, 7
+2, 7, 1687, 2, 8, 2342, 3, 7, 2430, 3, 8, 59077, // 3, 8
+2, 8, 1766, 2, 9, 2463, 3, 8, 2532, 3, 9, 58775, // 3, 9
+2, 9, 1908, 2, 10, 2672, 3, 9, 2723, 3, 10, 58233, // 3,10
+2, 10, 2096, 2, 11, 2948, 3, 10, 2977, 3, 11, 57515, // 3,11
+2, 11, 2317, 2, 12, 3273, 3, 11, 3274, 3, 12, 56672, // 3,12
+2, 12, 2557, 2, 13, 3628, 3, 12, 3595, 3, 13, 55756, // 3,13
+2, 13, 2808, 2, 14, 4003, 3, 13, 3929, 3, 14, 54796, // 3,14
+2, 14, 3065, 2, 15, 4390, 3, 14, 4267, 3, 15, 53814, // 3,15
+4, -1, 4041, 4, 0, 54378, 5, -1, 2916, 5, 0, 4201, // 4, 0
+4, 0, 3677, 4, 1, 55435, 5, 0, 2640, 5, 1, 3784, // 4, 1
+4, 1, 3310, 4, 2, 56487, 5, 1, 2365, 5, 2, 3374, // 4, 2
+4, 2, 2948, 4, 3, 57514, 5, 2, 2096, 5, 3, 2978, // 4, 3
+4, 3, 2604, 4, 4, 58484, 5, 3, 1843, 5, 4, 2605, // 4, 4
+4, 4, 2297, 4, 5, 59345, 5, 4, 1617, 5, 5, 2277, // 4, 5
+4, 5, 2057, 4, 6, 60017, 5, 5, 1442, 5, 6, 2020, // 4, 6
+4, 6, 1922, 4, 7, 60402, 5, 6, 1341, 5, 7, 1871, // 4, 7
+3, 7, 1341, 3, 8, 1871, 4, 7, 1922, 4, 8, 60402, // 4, 8
+3, 8, 1442, 3, 9, 2020, 4, 8, 2057, 4, 9, 60017, // 4, 9
+3, 9, 1617, 3, 10, 2276, 4, 9, 2297, 4, 10, 59346, // 4,10
+3, 10, 1843, 3, 11, 2604, 4, 10, 2605, 4, 11, 58484, // 4,11
+3, 11, 2096, 3, 12, 2976, 4, 11, 2950, 4, 12, 57514, // 4,12
+3, 12, 2365, 3, 13, 3373, 4, 12, 3311, 4, 13, 56487, // 4,13
+3, 13, 2640, 3, 14, 3783, 4, 13, 3678, 4, 14, 55435, // 4,14
+3, 14, 2917, 3, 15, 4200, 4, 14, 4043, 4, 15, 54376, // 4,15
+5, -1, 3858, 5, 0, 54835, 6, -1, 2796, 6, 0, 4047, // 5, 0
+5, 0, 3470, 5, 1, 55959, 6, 0, 2502, 6, 1, 3605, // 5, 1
+5, 1, 3073, 5, 2, 57096, 6, 1, 2205, 6, 2, 3162, // 5, 2
+5, 2, 2672, 5, 3, 58234, 6, 2, 1908, 6, 3, 2722, // 5, 3
+5, 3, 2276, 5, 4, 59346, 6, 3, 1617, 6, 4, 2297, // 5, 4
+5, 4, 1904, 5, 5, 60381, 6, 4, 1347, 6, 5, 1904, // 5, 5
+5, 5, 1593, 5, 6, 61243, 6, 5, 1121, 6, 6, 1579, // 5, 6
+5, 6, 1405, 5, 7, 61767, 6, 6, 985, 6, 7, 1379, // 5, 7
+4, 7, 985, 4, 8, 1380, 5, 7, 1405, 5, 8, 61766, // 5, 8
+4, 8, 1121, 4, 9, 1578, 5, 8, 1593, 5, 9, 61244, // 5, 9
+4, 9, 1347, 4, 10, 1904, 5, 9, 1904, 5, 10, 60381, // 5,10
+4, 10, 1617, 4, 11, 2297, 5, 10, 2276, 5, 11, 59346, // 5,11
+4, 11, 1908, 4, 12, 2722, 5, 11, 2673, 5, 12, 58233, // 5,12
+4, 12, 2205, 4, 13, 3161, 5, 12, 3074, 5, 13, 57096, // 5,13
+4, 13, 2503, 4, 14, 3604, 5, 13, 3472, 5, 14, 55957, // 5,14
+4, 14, 2797, 4, 15, 4046, 5, 14, 3860, 5, 15, 54833, // 5,15
+6, -1, 3722, 6, 0, 55166, 7, -1, 2709, 7, 0, 3939, // 6, 0
+6, 0, 3317, 6, 1, 56340, 7, 0, 2402, 7, 1, 3477, // 6, 1
+6, 1, 2897, 6, 2, 57545, 7, 1, 2088, 7, 2, 3006, // 6, 2
+6, 2, 2463, 6, 3, 58775, 7, 2, 1766, 7, 3, 2532, // 6, 3
+6, 3, 2020, 6, 4, 60018, 7, 3, 1442, 7, 4, 2056, // 6, 4
+6, 4, 1578, 6, 5, 61243, 7, 4, 1121, 7, 5, 1594, // 6, 5
+6, 5, 1170, 6, 6, 62369, 7, 5, 827, 7, 6, 1170, // 6, 6
+6, 6, 883, 6, 7, 63156, 7, 6, 622, 7, 7, 875, // 6, 7
+5, 7, 622, 5, 8, 875, 6, 7, 883, 6, 8, 63156, // 6, 8
+5, 8, 827, 5, 9, 1170, 6, 8, 1170, 6, 9, 62369, // 6, 9
+5, 9, 1121, 5, 10, 1593, 6, 9, 1579, 6, 10, 61243, // 6,10
+5, 10, 1442, 5, 11, 2057, 6, 10, 2020, 6, 11, 60017, // 6,11
+5, 11, 1767, 5, 12, 2532, 6, 11, 2464, 6, 12, 58773, // 6,12
+5, 12, 2088, 5, 13, 3007, 6, 12, 2898, 6, 13, 57543, // 6,13
+5, 13, 2403, 5, 14, 3476, 6, 13, 3319, 6, 14, 56338, // 6,14
+5, 14, 2709, 5, 15, 3939, 6, 14, 3724, 6, 15, 55164, // 6,15
+7, -1, 3638, 7, 0, 55354, 8, -1, 2659, 8, 0, 3885, // 7, 0
+7, 0, 3225, 7, 1, 56554, 8, 0, 2346, 8, 1, 3411, // 7, 1
+7, 1, 2794, 7, 2, 57795, 8, 1, 2022, 8, 2, 2925, // 7, 2
+7, 2, 2342, 7, 3, 59077, 8, 2, 1687, 8, 3, 2430, // 7, 3
+7, 3, 1871, 7, 4, 60402, 8, 3, 1341, 8, 4, 1922, // 7, 4
+7, 4, 1380, 7, 5, 61767, 8, 4, 985, 8, 5, 1404, // 7, 5
+7, 5, 875, 7, 6, 63156, 8, 5, 622, 8, 6, 883, // 7, 6
+7, 6, 399, 7, 7, 64455, 8, 6, 282, 8, 7, 400, // 7, 7
+6, 7, 282, 6, 8, 399, 7, 7, 399, 7, 8, 64456, // 7, 8
+6, 8, 622, 6, 9, 883, 7, 8, 875, 7, 9, 63156, // 7, 9
+6, 9, 985, 6, 10, 1405, 7, 9, 1380, 7, 10, 61766, // 7,10
+6, 10, 1341, 6, 11, 1922, 7, 10, 1871, 7, 11, 60402, // 7,11
+6, 11, 1687, 6, 12, 2430, 7, 11, 2343, 7, 12, 59076, // 7,12
+6, 12, 2022, 6, 13, 2926, 7, 12, 2795, 7, 13, 57793, // 7,13
+6, 13, 2346, 6, 14, 3411, 7, 13, 3227, 7, 14, 56552, // 7,14
+6, 14, 2659, 6, 15, 3885, 7, 14, 3640, 7, 15, 55352, // 7,15
+8, 0, 55352, 8, 1, 3640, 9, 0, 3885, 9, 1, 2659, // 8, 0
+8, 1, 56552, 8, 2, 3227, 9, 1, 3411, 9, 2, 2346, // 8, 1
+8, 2, 57793, 8, 3, 2795, 9, 2, 2926, 9, 3, 2022, // 8, 2
+8, 3, 59076, 8, 4, 2343, 9, 3, 2430, 9, 4, 1687, // 8, 3
+8, 4, 60402, 8, 5, 1871, 9, 4, 1922, 9, 5, 1341, // 8, 4
+8, 5, 61767, 8, 6, 1380, 9, 5, 1405, 9, 6, 984, // 8, 5
+8, 6, 63156, 8, 7, 875, 9, 6, 883, 9, 7, 622, // 8, 6
+8, 7, 64455, 8, 8, 399, 9, 7, 399, 9, 8, 283, // 8, 7
+7, 8, 399, 7, 9, 282, 8, 8, 64455, 8, 9, 400, // 8, 8
+7, 9, 883, 7, 10, 622, 8, 9, 63156, 8, 10, 875, // 8, 9
+7, 10, 1405, 7, 11, 985, 8, 10, 61767, 8, 11, 1379, // 8,10
+7, 11, 1922, 7, 12, 1341, 8, 11, 60402, 8, 12, 1871, // 8,11
+7, 12, 2430, 7, 13, 1687, 8, 12, 59077, 8, 13, 2342, // 8,12
+7, 13, 2926, 7, 14, 2022, 8, 13, 57795, 8, 14, 2793, // 8,13
+7, 14, 3411, 7, 15, 2346, 8, 14, 56554, 8, 15, 3225, // 8,14
+7, 15, 3885, 7, 16, 2659, 8, 15, 55354, 8, 16, 3638, // 8,15
+9, 0, 55164, 9, 1, 3724, 10, 0, 3939, 10, 1, 2709, // 9, 0
+9, 1, 56339, 9, 2, 3319, 10, 1, 3476, 10, 2, 2402, // 9, 1
+9, 2, 57544, 9, 3, 2898, 10, 2, 3007, 10, 3, 2087, // 9, 2
+9, 3, 58774, 9, 4, 2464, 10, 3, 2532, 10, 4, 1766, // 9, 3
+9, 4, 60017, 9, 5, 2020, 10, 4, 2057, 10, 5, 1442, // 9, 4
+9, 5, 61243, 9, 6, 1579, 10, 5, 1593, 10, 6, 1121, // 9, 5
+9, 6, 62369, 9, 7, 1170, 10, 6, 1170, 10, 7, 827, // 9, 6
+9, 7, 63156, 9, 8, 883, 10, 7, 875, 10, 8, 622, // 9, 7
+8, 8, 875, 8, 9, 622, 9, 8, 63156, 9, 9, 883, // 9, 8
+8, 9, 1170, 8, 10, 827, 9, 9, 62369, 9, 10, 1170, // 9, 9
+8, 10, 1593, 8, 11, 1121, 9, 10, 61243, 9, 11, 1579, // 9,10
+8, 11, 2057, 8, 12, 1442, 9, 11, 60018, 9, 12, 2019, // 9,11
+8, 12, 2532, 8, 13, 1766, 9, 12, 58775, 9, 13, 2463, // 9,12
+8, 13, 3007, 8, 14, 2088, 9, 13, 57545, 9, 14, 2896, // 9,13
+8, 14, 3477, 8, 15, 2402, 9, 14, 56340, 9, 15, 3317, // 9,14
+8, 15, 3940, 8, 16, 2709, 9, 15, 55166, 9, 16, 3721, // 9,15
+10, 0, 54833, 10, 1, 3860, 11, 0, 4046, 11, 1, 2797, // 10, 0
+10, 1, 55958, 10, 2, 3472, 11, 1, 3604, 11, 2, 2502, // 10, 1
+10, 2, 57095, 10, 3, 3074, 11, 2, 3161, 11, 3, 2206, // 10, 2
+10, 3, 58233, 10, 4, 2673, 11, 3, 2722, 11, 4, 1908, // 10, 3
+10, 4, 59345, 10, 5, 2276, 11, 4, 2297, 11, 5, 1618, // 10, 4
+10, 5, 60381, 10, 6, 1904, 11, 5, 1904, 11, 6, 1347, // 10, 5
+10, 6, 61243, 10, 7, 1593, 11, 6, 1578, 11, 7, 1122, // 10, 6
+10, 7, 61767, 10, 8, 1405, 11, 7, 1380, 11, 8, 984, // 10, 7
+9, 8, 1380, 9, 9, 985, 10, 8, 61767, 10, 9, 1404, // 10, 8
+9, 9, 1579, 9, 10, 1121, 10, 9, 61243, 10, 10, 1593, // 10, 9
+9, 10, 1904, 9, 11, 1347, 10, 10, 60381, 10, 11, 1904, // 10,10
+9, 11, 2297, 9, 12, 1617, 10, 11, 59346, 10, 12, 2276, // 10,11
+9, 12, 2723, 9, 13, 1908, 10, 12, 58234, 10, 13, 2671, // 10,12
+9, 13, 3161, 9, 14, 2205, 10, 13, 57096, 10, 14, 3074, // 10,13
+9, 14, 3605, 9, 15, 2502, 10, 14, 55959, 10, 15, 3470, // 10,14
+9, 15, 4047, 9, 16, 2796, 10, 15, 54835, 10, 16, 3858, // 10,15
+11, 0, 54376, 11, 1, 4043, 12, 0, 4200, 12, 1, 2917, // 11, 0
+11, 1, 55434, 11, 2, 3678, 12, 1, 3783, 12, 2, 2641, // 11, 1
+11, 2, 56486, 11, 3, 3311, 12, 2, 3373, 12, 3, 2366, // 11, 2
+11, 3, 57514, 11, 4, 2950, 12, 3, 2976, 12, 4, 2096, // 11, 3
+11, 4, 58484, 11, 5, 2605, 12, 4, 2604, 12, 5, 1843, // 11, 4
+11, 5, 59346, 11, 6, 2297, 12, 5, 2276, 12, 6, 1617, // 11, 5
+11, 6, 60018, 11, 7, 2057, 12, 6, 2020, 12, 7, 1441, // 11, 6
+11, 7, 60402, 11, 8, 1922, 12, 7, 1871, 12, 8, 1341, // 11, 7
+10, 8, 1871, 10, 9, 1341, 11, 8, 60402, 11, 9, 1922, // 11, 8
+10, 9, 2020, 10, 10, 1442, 11, 9, 60017, 11, 10, 2057, // 11, 9
+10, 10, 2276, 10, 11, 1617, 11, 10, 59345, 11, 11, 2298, // 11,10
+10, 11, 2605, 10, 12, 1843, 11, 11, 58484, 11, 12, 2604, // 11,11
+10, 12, 2977, 10, 13, 2096, 11, 12, 57514, 11, 13, 2949, // 11,12
+10, 13, 3374, 10, 14, 2365, 11, 13, 56487, 11, 14, 3310, // 11,13
+10, 14, 3785, 10, 15, 2640, 11, 14, 55435, 11, 15, 3676, // 11,14
+10, 15, 4201, 10, 16, 2916, 11, 15, 54378, 11, 16, 4041, // 11,15
+12, 0, 53814, 12, 1, 4267, 13, 0, 4390, 13, 1, 3065, // 12, 0
+12, 1, 54796, 12, 2, 3929, 13, 1, 4003, 13, 2, 2808, // 12, 1
+12, 2, 55756, 12, 3, 3595, 13, 2, 3628, 13, 3, 2557, // 12, 2
+12, 3, 56673, 12, 4, 3274, 13, 3, 3273, 13, 4, 2316, // 12, 3
+12, 4, 57514, 12, 5, 2977, 13, 4, 2948, 13, 5, 2097, // 12, 4
+12, 5, 58234, 12, 6, 2723, 13, 5, 2672, 13, 6, 1907, // 12, 5
+12, 6, 58775, 12, 7, 2532, 13, 6, 2463, 13, 7, 1766, // 12, 6
+12, 7, 59077, 12, 8, 2430, 13, 7, 2342, 13, 8, 1687, // 12, 7
+11, 8, 2343, 11, 9, 1687, 12, 8, 59076, 12, 9, 2430, // 12, 8
+11, 9, 2464, 11, 10, 1767, 12, 9, 58774, 12, 10, 2531, // 12, 9
+11, 10, 2673, 11, 11, 1908, 12, 10, 58233, 12, 11, 2722, // 12,10
+11, 11, 2950, 11, 12, 2096, 12, 11, 57514, 12, 12, 2976, // 12,11
+11, 12, 3274, 11, 13, 2317, 12, 12, 56673, 12, 13, 3272, // 12,12
+11, 13, 3630, 11, 14, 2556, 12, 13, 55756, 12, 14, 3594, // 12,13
+11, 14, 4005, 11, 15, 2808, 12, 14, 54796, 12, 15, 3927, // 12,14
+11, 15, 4392, 11, 16, 3064, 12, 15, 53815, 12, 16, 4265, // 12,15
+13, 0, 53168, 13, 1, 4523, 14, 0, 4610, 14, 1, 3235, // 13, 0
+13, 1, 54071, 13, 2, 4214, 14, 1, 4253, 14, 2, 2998, // 13, 1
+13, 2, 54941, 13, 3, 3913, 14, 2, 3911, 14, 3, 2771, // 13, 2
+13, 3, 55756, 13, 4, 3630, 14, 3, 3594, 14, 4, 2556, // 13, 3
+13, 4, 56487, 13, 5, 3374, 14, 4, 3310, 14, 5, 2365, // 13, 4
+13, 5, 57096, 13, 6, 3161, 14, 5, 3073, 14, 6, 2206, // 13, 5
+13, 6, 57545, 13, 7, 3007, 14, 6, 2897, 14, 7, 2087, // 13, 6
+13, 7, 57795, 13, 8, 2926, 14, 7, 2794, 14, 8, 2021, // 13, 7
+12, 8, 2795, 12, 9, 2022, 13, 8, 57793, 13, 9, 2926, // 13, 8
+12, 9, 2898, 12, 10, 2088, 13, 9, 57544, 13, 10, 3006, // 13, 9
+12, 10, 3074, 12, 11, 2205, 13, 10, 57095, 13, 11, 3162, // 13,10
+12, 11, 3311, 12, 12, 2365, 13, 11, 56486, 13, 12, 3374, // 13,11
+12, 12, 3595, 12, 13, 2557, 13, 12, 55756, 13, 13, 3628, // 13,12
+12, 13, 3913, 12, 14, 2770, 13, 13, 54941, 13, 14, 3912, // 13,13
+12, 14, 4255, 12, 15, 2998, 13, 14, 54072, 13, 15, 4211, // 13,14
+12, 15, 4612, 12, 16, 3235, 13, 15, 53168, 13, 16, 4521, // 13,15
+14, 0, 52457, 14, 1, 4806, 15, 0, 4851, 15, 1, 3422, // 14, 0
+14, 1, 53285, 14, 2, 4525, 15, 1, 4522, 15, 2, 3204, // 14, 1
+14, 2, 54072, 14, 3, 4255, 15, 2, 4212, 15, 3, 2997, // 14, 2
+14, 3, 54796, 14, 4, 4005, 15, 3, 3927, 15, 4, 2808, // 14, 3
+14, 4, 55435, 14, 5, 3785, 15, 4, 3677, 15, 5, 2639, // 14, 4
+14, 5, 55959, 14, 6, 3605, 15, 5, 3470, 15, 6, 2502, // 14, 5
+14, 6, 56340, 14, 7, 3477, 15, 6, 3317, 15, 7, 2402, // 14, 6
+14, 7, 56554, 14, 8, 3411, 15, 7, 3225, 15, 8, 2346, // 14, 7
+13, 8, 3227, 13, 9, 2346, 14, 8, 56552, 14, 9, 3411, // 14, 8
+13, 9, 3319, 13, 10, 2403, 14, 9, 56339, 14, 10, 3475, // 14, 9
+13, 10, 3472, 13, 11, 2503, 14, 10, 55958, 14, 11, 3603, // 14,10
+13, 11, 3678, 13, 12, 2640, 14, 11, 55434, 14, 12, 3784, // 14,11
+13, 12, 3929, 13, 13, 2808, 14, 12, 54796, 14, 13, 4003, // 14,12
+13, 13, 4214, 13, 14, 2998, 14, 13, 54071, 14, 14, 4253, // 14,13
+13, 14, 4525, 13, 15, 3204, 14, 14, 53285, 14, 15, 4522, // 14,14
+13, 15, 4854, 13, 16, 3421, 14, 15, 52457, 14, 16, 4804, // 14,15
+15, 0, 51699, 15, 1, 5110, 16, 0, 5106, 16, 1, 3621, // 15, 0
+15, 1, 52457, 15, 2, 4854, 16, 1, 4803, 16, 2, 3422, // 15, 1
+15, 2, 53168, 15, 3, 4612, 16, 2, 4521, 16, 3, 3235, // 15, 2
+15, 3, 53815, 15, 4, 4392, 16, 3, 4264, 16, 4, 3065, // 15, 3
+15, 4, 54378, 15, 5, 4201, 16, 4, 4041, 16, 5, 2916, // 15, 4
+15, 5, 54835, 15, 6, 4047, 16, 5, 3858, 16, 6, 2796, // 15, 5
+15, 6, 55166, 15, 7, 3940, 16, 6, 3722, 16, 7, 2708, // 15, 6
+15, 7, 55354, 15, 8, 3885, 16, 7, 3638, 16, 8, 2659, // 15, 7
+14, 8, 3640, 14, 9, 2659, 15, 8, 55352, 15, 9, 3885, // 15, 8
+14, 9, 3724, 14, 10, 2709, 15, 9, 55164, 15, 10, 3939, // 15, 9
+14, 10, 3860, 14, 11, 2797, 15, 10, 54833, 15, 11, 4046, // 15,10
+14, 11, 4043, 14, 12, 2917, 15, 11, 54376, 15, 12, 4200, // 15,11
+14, 12, 4267, 14, 13, 3065, 15, 12, 53814, 15, 13, 4390, // 15,12
+14, 13, 4523, 14, 14, 3235, 15, 13, 53168, 15, 14, 4610, // 15,13
+14, 14, 4806, 14, 15, 3422, 15, 14, 52457, 15, 15, 4851, // 15,14
+14, 15, 5110, 14, 16, 3621, 15, 15, 51699, 15, 16, 5106, // 15,15
+// angle of 1.0 degrees
+0, -1, 8769, 0, 0, 41693, 1, -1, 6280, 1, 0, 8794, // 0, 0
+0, 0, 8452, 0, 1, 42821, 1, 0, 5975, 1, 1, 8288, // 0, 1
+0, 1, 8141, 0, 2, 43900, 1, 1, 5684, 1, 2, 7811, // 0, 2
+0, 2, 7848, 0, 3, 44901, 1, 2, 5413, 1, 3, 7374, // 0, 3
+0, 3, 7587, 0, 4, 45791, 1, 3, 5172, 1, 4, 6986, // 0, 4
+0, 4, 7374, 0, 5, 46532, 1, 4, 4971, 1, 5, 6659, // 0, 5
+0, 5, 7227, 0, 6, 47086, 1, 5, 4818, 1, 6, 6405, // 0, 6
+0, 6, 7158, 0, 7, 47426, 1, 6, 4722, 1, 7, 6230, // 0, 7
+-1, 7, 4718, -1, 8, 6217, 0, 7, 7161, 0, 8, 47440, // 0, 8
+-1, 8, 4814, -1, 9, 6391, 0, 8, 7233, 0, 9, 47098, // 0, 9
+-1, 9, 4967, -1, 10, 6644, 0, 9, 7383, 0, 10, 46542, // 0,10
+-1, 10, 5169, -1, 11, 6970, 0, 10, 7599, 0, 11, 45798, // 0,11
+-1, 11, 5410, -1, 12, 7356, 0, 11, 7863, 0, 12, 44907, // 0,12
+-1, 12, 5682, -1, 13, 7791, 0, 12, 8159, 0, 13, 43904, // 0,13
+-1, 13, 5974, -1, 14, 8265, 0, 13, 8474, 0, 14, 42823, // 0,14
+-1, 14, 6280, -1, 15, 8769, 0, 14, 8795, 0, 15, 41692, // 0,15
+1, -1, 8265, 1, 0, 42823, 2, -1, 5974, 2, 0, 8474, // 1, 0
+1, 0, 7901, 1, 1, 44074, 2, 0, 5640, 2, 1, 7921, // 1, 1
+1, 1, 7539, 1, 2, 45286, 2, 1, 5316, 2, 2, 7395, // 1, 2
+1, 2, 7191, 1, 3, 46427, 2, 2, 5011, 2, 3, 6907, // 1, 3
+1, 3, 6875, 1, 4, 47453, 2, 3, 4736, 2, 4, 6472, // 1, 4
+1, 4, 6613, 1, 5, 48314, 2, 4, 4505, 2, 5, 6104, // 1, 5
+1, 5, 6425, 1, 6, 48960, 2, 5, 4330, 2, 6, 5821, // 1, 6
+1, 6, 6332, 1, 7, 49347, 2, 6, 4224, 2, 7, 5633, // 1, 7
+0, 7, 4221, 0, 8, 5623, 1, 7, 6335, 1, 8, 49357, // 1, 8
+0, 8, 4327, 0, 9, 5809, 1, 8, 6430, 1, 9, 48970, // 1, 9
+0, 9, 4502, 0, 10, 6092, 1, 9, 6620, 1, 10, 48322, // 1,10
+0, 10, 4734, 0, 11, 6458, 1, 10, 6886, 1, 11, 47458, // 1,11
+0, 11, 5009, 0, 12, 6892, 1, 11, 7204, 1, 12, 46431, // 1,12
+0, 12, 5315, 0, 13, 7378, 1, 12, 7555, 1, 13, 45288, // 1,13
+0, 13, 5640, 0, 14, 7901, 1, 13, 7921, 1, 14, 44074, // 1,14
+0, 14, 5975, 0, 15, 8452, 1, 14, 8288, 1, 15, 42821, // 1,15
+2, -1, 7791, 2, 0, 43904, 3, -1, 5682, 3, 0, 8159, // 2, 0
+2, 0, 7378, 2, 1, 45288, 3, 0, 5315, 3, 1, 7555, // 2, 1
+2, 1, 6959, 2, 2, 46650, 3, 1, 4954, 3, 2, 6973, // 2, 2
+2, 2, 6549, 2, 3, 47953, 3, 2, 4608, 3, 3, 6426, // 2, 3
+2, 3, 6168, 2, 4, 49147, 3, 3, 4291, 3, 4, 5930, // 2, 4
+2, 4, 5842, 2, 5, 50165, 3, 4, 4020, 3, 5, 5509, // 2, 5
+2, 5, 5602, 2, 6, 50935, 3, 5, 3815, 3, 6, 5184, // 2, 6
+2, 6, 5478, 2, 7, 51387, 3, 6, 3693, 3, 7, 4978, // 2, 7
+1, 7, 3691, 1, 8, 4970, 2, 7, 5480, 2, 8, 51395, // 2, 8
+1, 8, 3813, 1, 9, 5175, 2, 8, 5606, 2, 9, 50942, // 2, 9
+1, 9, 4019, 1, 10, 5499, 2, 9, 5848, 2, 10, 50170, // 2,10
+1, 10, 4290, 1, 11, 5920, 2, 10, 6176, 2, 11, 49150, // 2,11
+1, 11, 4607, 1, 12, 6414, 2, 11, 6560, 2, 12, 47955, // 2,12
+1, 12, 4954, 1, 13, 6959, 2, 12, 6973, 2, 13, 46650, // 2,13
+1, 13, 5316, 1, 14, 7539, 2, 13, 7395, 2, 14, 45286, // 2,14
+1, 14, 5684, 1, 15, 8141, 2, 14, 7812, 2, 15, 43899, // 2,15
+3, -1, 7356, 3, 0, 44907, 4, -1, 5410, 4, 0, 7863, // 3, 0
+3, 0, 6892, 3, 1, 46430, 4, 0, 5009, 4, 1, 7205, // 3, 1
+3, 1, 6414, 3, 2, 47955, 4, 1, 4607, 4, 2, 6560, // 3, 2
+3, 2, 5934, 3, 3, 49445, 4, 2, 4214, 4, 3, 5943, // 3, 3
+3, 3, 5474, 3, 4, 50843, 4, 3, 3846, 4, 4, 5373, // 3, 4
+3, 4, 5069, 3, 5, 52066, 4, 4, 3523, 4, 5, 4878, // 3, 5
+3, 5, 4759, 3, 6, 53008, 4, 5, 3274, 4, 6, 4495, // 3, 6
+3, 6, 4592, 3, 7, 53557, 4, 6, 3128, 4, 7, 4259, // 3, 7
+2, 7, 3126, 2, 8, 4254, 3, 7, 4594, 3, 8, 53562, // 3, 8
+2, 8, 3273, 2, 9, 4489, 3, 8, 4762, 3, 9, 53012, // 3, 9
+2, 9, 3522, 2, 10, 4872, 3, 9, 5073, 3, 10, 52069, // 3,10
+2, 10, 3845, 2, 11, 5365, 3, 10, 5481, 3, 11, 50845, // 3,11
+2, 11, 4214, 2, 12, 5934, 3, 11, 5943, 3, 12, 49445, // 3,12
+2, 12, 4608, 2, 13, 6549, 3, 12, 6426, 3, 13, 47953, // 3,13
+2, 13, 5011, 2, 14, 7191, 3, 13, 6908, 3, 14, 46426, // 3,14
+2, 14, 5413, 2, 15, 7848, 3, 14, 7374, 3, 15, 44901, // 3,15
+4, -1, 6970, 4, 0, 45799, 5, -1, 5169, 5, 0, 7598, // 4, 0
+4, 0, 6458, 4, 1, 47458, 5, 0, 4734, 5, 1, 6886, // 4, 1
+4, 1, 5920, 4, 2, 49150, 5, 1, 4290, 5, 2, 6176, // 4, 2
+4, 2, 5365, 4, 3, 50844, 5, 2, 3845, 5, 3, 5482, // 4, 3
+4, 3, 4816, 4, 4, 52484, 5, 3, 3415, 5, 4, 4821, // 4, 4
+4, 4, 4309, 4, 5, 53973, 5, 4, 3023, 5, 5, 4231, // 4, 5
+4, 5, 3902, 4, 6, 55164, 5, 5, 2711, 5, 6, 3759, // 4, 6
+4, 6, 3671, 4, 7, 55867, 5, 6, 2525, 5, 7, 3473, // 4, 7
+3, 7, 2524, 3, 8, 3469, 4, 7, 3672, 4, 8, 55871, // 4, 8
+3, 8, 2710, 3, 9, 3755, 4, 8, 3904, 4, 9, 55167, // 4, 9
+3, 9, 3023, 3, 10, 4226, 4, 9, 4313, 4, 10, 53974, // 4,10
+3, 10, 3415, 3, 11, 4816, 4, 10, 4822, 4, 11, 52483, // 4,11
+3, 11, 3846, 3, 12, 5474, 4, 11, 5373, 4, 12, 50843, // 4,12
+3, 12, 4291, 3, 13, 6168, 4, 12, 5930, 4, 13, 49147, // 4,13
+3, 13, 4736, 3, 14, 6875, 4, 13, 6472, 4, 14, 47453, // 4,14
+3, 14, 5172, 3, 15, 7587, 4, 14, 6986, 4, 15, 45791, // 4,15
+5, -1, 6644, 5, 0, 46541, 6, -1, 4967, 6, 0, 7384, // 5, 0
+5, 0, 6092, 5, 1, 48322, 6, 0, 4502, 6, 1, 6620, // 5, 1
+5, 1, 5499, 5, 2, 50171, 6, 1, 4019, 6, 2, 5847, // 5, 2
+5, 2, 4872, 5, 3, 52069, 6, 2, 3522, 6, 3, 5073, // 5, 3
+5, 3, 4226, 5, 4, 53975, 6, 3, 3023, 6, 4, 4312, // 5, 4
+5, 4, 3595, 5, 5, 55798, 6, 4, 2546, 6, 5, 3597, // 5, 5
+5, 5, 3050, 5, 6, 57353, 6, 5, 2138, 6, 6, 2995, // 5, 6
+5, 6, 2713, 5, 7, 58322, 6, 6, 1884, 6, 7, 2617, // 5, 7
+4, 7, 1884, 4, 8, 2615, 5, 7, 2714, 5, 8, 58323, // 5, 8
+4, 8, 2138, 4, 9, 2993, 5, 8, 3051, 5, 9, 57354, // 5, 9
+4, 9, 2546, 4, 10, 3595, 5, 9, 3598, 5, 10, 55797, // 5,10
+4, 10, 3023, 4, 11, 4309, 5, 10, 4230, 5, 11, 53974, // 5,11
+4, 11, 3523, 4, 12, 5069, 5, 11, 4879, 5, 12, 52065, // 5,12
+4, 12, 4020, 4, 13, 5842, 5, 12, 5508, 5, 13, 50166, // 5,13
+4, 13, 4505, 4, 14, 6613, 5, 13, 6104, 5, 14, 48314, // 5,14
+4, 14, 4971, 4, 15, 7374, 5, 14, 6659, 5, 15, 46532, // 5,15
+6, -1, 6391, 6, 0, 47098, 7, -1, 4814, 7, 0, 7233, // 6, 0
+6, 0, 5809, 6, 1, 48969, 7, 0, 4327, 7, 1, 6431, // 6, 1
+6, 1, 5175, 6, 2, 50942, 7, 1, 3813, 7, 2, 5606, // 6, 2
+6, 2, 4489, 6, 3, 53012, 7, 2, 3273, 7, 3, 4762, // 6, 3
+6, 3, 3755, 6, 4, 55166, 7, 3, 2710, 7, 4, 3905, // 6, 4
+6, 4, 2993, 6, 5, 57354, 7, 4, 2138, 7, 5, 3051, // 6, 5
+6, 5, 2258, 6, 6, 59422, 7, 5, 1597, 7, 6, 2259, // 6, 6
+6, 6, 1726, 6, 7, 60905, 7, 6, 1210, 7, 7, 1695, // 6, 7
+5, 7, 1209, 5, 8, 1695, 6, 7, 1726, 6, 8, 60906, // 6, 8
+5, 8, 1597, 5, 9, 2258, 6, 8, 2259, 6, 9, 59422, // 6, 9
+5, 9, 2138, 5, 10, 3050, 6, 9, 2995, 6, 10, 57353, // 6,10
+5, 10, 2711, 5, 11, 3902, 6, 10, 3759, 6, 11, 55164, // 6,11
+5, 11, 3274, 5, 12, 4759, 6, 11, 4495, 6, 12, 53008, // 6,12
+5, 12, 3815, 5, 13, 5602, 6, 12, 5184, 6, 13, 50935, // 6,13
+5, 13, 4330, 5, 14, 6425, 6, 13, 5820, 6, 14, 48961, // 6,14
+5, 14, 4818, 5, 15, 7227, 6, 14, 6405, 6, 15, 47086, // 6,15
+7, -1, 6217, 7, 0, 47440, 8, -1, 4718, 8, 0, 7161, // 7, 0
+7, 0, 5623, 7, 1, 49358, 8, 0, 4221, 8, 1, 6334, // 7, 1
+7, 1, 4970, 7, 2, 51395, 8, 1, 3691, 8, 2, 5480, // 7, 2
+7, 2, 4254, 7, 3, 53562, 8, 2, 3126, 8, 3, 4594, // 7, 3
+7, 3, 3469, 7, 4, 55870, 8, 3, 2524, 8, 4, 3673, // 7, 4
+7, 4, 2615, 7, 5, 58324, 8, 4, 1884, 8, 5, 2713, // 7, 5
+7, 5, 1695, 7, 6, 60906, 8, 5, 1209, 8, 6, 1726, // 7, 6
+7, 6, 789, 7, 7, 63399, 8, 6, 558, 8, 7, 790, // 7, 7
+6, 7, 558, 6, 8, 789, 7, 7, 789, 7, 8, 63400, // 7, 8
+6, 8, 1210, 6, 9, 1726, 7, 8, 1695, 7, 9, 60905, // 7, 9
+6, 9, 1884, 6, 10, 2713, 7, 9, 2616, 7, 10, 58323, // 7,10
+6, 10, 2525, 6, 11, 3671, 7, 10, 3473, 7, 11, 55867, // 7,11
+6, 11, 3128, 6, 12, 4592, 7, 11, 4259, 7, 12, 53557, // 7,12
+6, 12, 3693, 6, 13, 5478, 7, 12, 4978, 7, 13, 51387, // 7,13
+6, 13, 4224, 6, 14, 6332, 7, 13, 5633, 7, 14, 49347, // 7,14
+6, 14, 4722, 6, 15, 7158, 7, 14, 6230, 7, 15, 47426, // 7,15
+8, 0, 47426, 8, 1, 6230, 9, 0, 7158, 9, 1, 4722, // 8, 0
+8, 1, 49347, 8, 2, 5633, 9, 1, 6332, 9, 2, 4224, // 8, 1
+8, 2, 51387, 8, 3, 4978, 9, 2, 5478, 9, 3, 3693, // 8, 2
+8, 3, 53557, 8, 4, 4259, 9, 3, 4592, 9, 4, 3128, // 8, 3
+8, 4, 55867, 8, 5, 3473, 9, 4, 3671, 9, 5, 2525, // 8, 4
+8, 5, 58322, 8, 6, 2616, 9, 5, 2713, 9, 6, 1885, // 8, 5
+8, 6, 60905, 8, 7, 1695, 9, 6, 1726, 9, 7, 1210, // 8, 6
+8, 7, 63399, 8, 8, 789, 9, 7, 789, 9, 8, 559, // 8, 7
+7, 8, 789, 7, 9, 558, 8, 8, 63399, 8, 9, 790, // 8, 8
+7, 9, 1726, 7, 10, 1209, 8, 9, 60906, 8, 10, 1695, // 8, 9
+7, 10, 2714, 7, 11, 1884, 8, 10, 58324, 8, 11, 2614, // 8,10
+7, 11, 3672, 7, 12, 2524, 8, 11, 55870, 8, 12, 3470, // 8,11
+7, 12, 4594, 7, 13, 3126, 8, 12, 53562, 8, 13, 4254, // 8,12
+7, 13, 5480, 7, 14, 3691, 8, 13, 51395, 8, 14, 4970, // 8,13
+7, 14, 6335, 7, 15, 4221, 8, 14, 49358, 8, 15, 5622, // 8,14
+7, 15, 7161, 7, 16, 4718, 8, 15, 47440, 8, 16, 6217, // 8,15
+9, 0, 47086, 9, 1, 6405, 10, 0, 7227, 10, 1, 4818, // 9, 0
+9, 1, 48960, 9, 2, 5820, 10, 1, 6425, 10, 2, 4331, // 9, 1
+9, 2, 50935, 9, 3, 5184, 10, 2, 5602, 10, 3, 3815, // 9, 2
+9, 3, 53008, 9, 4, 4495, 10, 3, 4759, 10, 4, 3274, // 9, 3
+9, 4, 55164, 9, 5, 3759, 10, 4, 3902, 10, 5, 2711, // 9, 4
+9, 5, 57353, 9, 6, 2995, 10, 5, 3050, 10, 6, 2138, // 9, 5
+9, 6, 59422, 9, 7, 2259, 10, 6, 2258, 10, 7, 1597, // 9, 6
+9, 7, 60906, 9, 8, 1726, 10, 7, 1695, 10, 8, 1209, // 9, 7
+8, 8, 1695, 8, 9, 1210, 9, 8, 60905, 9, 9, 1726, // 9, 8
+8, 9, 2259, 8, 10, 1597, 9, 9, 59422, 9, 10, 2258, // 9, 9
+8, 10, 3051, 8, 11, 2138, 9, 10, 57354, 9, 11, 2993, // 9,10
+8, 11, 3904, 8, 12, 2710, 9, 11, 55166, 9, 12, 3756, // 9,11
+8, 12, 4762, 8, 13, 3273, 9, 12, 53012, 9, 13, 4489, // 9,12
+8, 13, 5606, 8, 14, 3813, 9, 13, 50942, 9, 14, 5175, // 9,13
+8, 14, 6430, 8, 15, 4327, 9, 14, 48969, 9, 15, 5810, // 9,14
+8, 15, 7233, 8, 16, 4814, 9, 15, 47098, 9, 16, 6391, // 9,15
+10, 0, 46532, 10, 1, 6659, 11, 0, 7374, 11, 1, 4971, // 10, 0
+10, 1, 48314, 10, 2, 6104, 11, 1, 6613, 11, 2, 4505, // 10, 1
+10, 2, 50165, 10, 3, 5508, 11, 2, 5842, 11, 3, 4021, // 10, 2
+10, 3, 52066, 10, 4, 4879, 11, 3, 5069, 11, 4, 3522, // 10, 3
+10, 4, 53973, 10, 5, 4230, 11, 4, 4309, 11, 5, 3024, // 10, 4
+10, 5, 55798, 10, 6, 3598, 11, 5, 3595, 11, 6, 2545, // 10, 5
+10, 6, 57354, 10, 7, 3051, 11, 6, 2993, 11, 7, 2138, // 10, 6
+10, 7, 58324, 10, 8, 2714, 11, 7, 2615, 11, 8, 1883, // 10, 7
+9, 8, 2616, 9, 9, 1884, 10, 8, 58322, 10, 9, 2714, // 10, 8
+9, 9, 2995, 9, 10, 2138, 10, 9, 57353, 10, 10, 3050, // 10, 9
+9, 10, 3598, 9, 11, 2546, 10, 10, 55798, 10, 11, 3594, // 10,10
+9, 11, 4313, 9, 12, 3023, 10, 11, 53975, 10, 12, 4225, // 10,11
+9, 12, 5073, 9, 13, 3522, 10, 12, 52069, 10, 13, 4872, // 10,12
+9, 13, 5848, 9, 14, 4019, 10, 13, 50171, 10, 14, 5498, // 10,13
+9, 14, 6620, 9, 15, 4502, 10, 14, 48322, 10, 15, 6092, // 10,14
+9, 15, 7383, 9, 16, 4967, 10, 15, 46541, 10, 16, 6645, // 10,15
+11, 0, 45791, 11, 1, 6986, 12, 0, 7587, 12, 1, 5172, // 11, 0
+11, 1, 47453, 11, 2, 6472, 12, 1, 6875, 12, 2, 4736, // 11, 1
+11, 2, 49147, 11, 3, 5930, 12, 2, 6168, 12, 3, 4291, // 11, 2
+11, 3, 50843, 11, 4, 5373, 12, 3, 5474, 12, 4, 3846, // 11, 3
+11, 4, 52484, 11, 5, 4822, 12, 4, 4816, 12, 5, 3414, // 11, 4
+11, 5, 53975, 11, 6, 4313, 12, 5, 4226, 12, 6, 3022, // 11, 5
+11, 6, 55166, 11, 7, 3904, 12, 6, 3755, 12, 7, 2711, // 11, 6
+11, 7, 55870, 11, 8, 3672, 12, 7, 3469, 12, 8, 2525, // 11, 7
+10, 8, 3473, 10, 9, 2525, 11, 8, 55867, 11, 9, 3671, // 11, 8
+10, 9, 3759, 10, 10, 2711, 11, 9, 55164, 11, 10, 3902, // 11, 9
+10, 10, 4230, 10, 11, 3023, 11, 10, 53973, 11, 11, 4310, // 11,10
+10, 11, 4822, 10, 12, 3415, 11, 11, 52484, 11, 12, 4815, // 11,11
+10, 12, 5481, 10, 13, 3845, 11, 12, 50844, 11, 13, 5366, // 11,12
+10, 13, 6176, 10, 14, 4290, 11, 13, 49150, 11, 14, 5920, // 11,13
+10, 14, 6886, 10, 15, 4734, 11, 14, 47458, 11, 15, 6458, // 11,14
+10, 15, 7599, 10, 16, 5169, 11, 15, 45799, 11, 16, 6969, // 11,15
+12, 0, 44901, 12, 1, 7374, 13, 0, 7848, 13, 1, 5413, // 12, 0
+12, 1, 46427, 12, 2, 6908, 13, 1, 7191, 13, 2, 5010, // 12, 1
+12, 2, 47953, 12, 3, 6426, 13, 2, 6549, 13, 3, 4608, // 12, 2
+12, 3, 49445, 12, 4, 5943, 13, 3, 5934, 13, 4, 4214, // 12, 3
+12, 4, 50844, 12, 5, 5481, 13, 4, 5365, 13, 5, 3846, // 12, 4
+12, 5, 52069, 12, 6, 5073, 13, 5, 4872, 13, 6, 3522, // 12, 5
+12, 6, 53012, 12, 7, 4762, 13, 6, 4489, 13, 7, 3273, // 12, 6
+12, 7, 53562, 12, 8, 4594, 13, 7, 4254, 13, 8, 3126, // 12, 7
+11, 8, 4259, 11, 9, 3128, 12, 8, 53557, 12, 9, 4592, // 12, 8
+11, 9, 4495, 11, 10, 3274, 12, 9, 53008, 12, 10, 4759, // 12, 9
+11, 10, 4879, 11, 11, 3523, 12, 10, 52066, 12, 11, 5068, // 12,10
+11, 11, 5373, 11, 12, 3846, 12, 11, 50843, 12, 12, 5474, // 12,11
+11, 12, 5943, 11, 13, 4214, 12, 12, 49445, 12, 13, 5934, // 12,12
+11, 13, 6560, 11, 14, 4607, 12, 13, 47955, 12, 14, 6414, // 12,13
+11, 14, 7204, 11, 15, 5009, 12, 14, 46430, 12, 15, 6893, // 12,14
+11, 15, 7863, 11, 16, 5410, 12, 15, 44907, 12, 16, 7356, // 12,15
+13, 0, 43900, 13, 1, 7812, 14, 0, 8141, 14, 1, 5683, // 13, 0
+13, 1, 45286, 13, 2, 7395, 14, 1, 7539, 14, 2, 5316, // 13, 1
+13, 2, 46650, 13, 3, 6973, 14, 2, 6959, 14, 3, 4954, // 13, 2
+13, 3, 47955, 13, 4, 6560, 14, 3, 6414, 14, 4, 4607, // 13, 3
+13, 4, 49150, 13, 5, 6176, 14, 4, 5920, 14, 5, 4290, // 13, 4
+13, 5, 50171, 13, 6, 5848, 14, 5, 5499, 14, 6, 4018, // 13, 5
+13, 6, 50942, 13, 7, 5606, 14, 6, 5175, 14, 7, 3813, // 13, 6
+13, 7, 51395, 13, 8, 5480, 14, 7, 4970, 14, 8, 3691, // 13, 7
+12, 8, 4978, 12, 9, 3693, 13, 8, 51387, 13, 9, 5478, // 13, 8
+12, 9, 5184, 12, 10, 3815, 13, 9, 50935, 13, 10, 5602, // 13, 9
+12, 10, 5508, 12, 11, 4020, 13, 10, 50165, 13, 11, 5843, // 13,10
+12, 11, 5930, 12, 12, 4291, 13, 11, 49147, 13, 12, 6168, // 13,11
+12, 12, 6426, 12, 13, 4608, 13, 12, 47953, 13, 13, 6549, // 13,12
+12, 13, 6973, 12, 14, 4954, 13, 13, 46650, 13, 14, 6959, // 13,13
+12, 14, 7555, 12, 15, 5315, 13, 14, 45288, 13, 15, 7378, // 13,14
+12, 15, 8159, 12, 16, 5682, 13, 15, 43904, 13, 16, 7791, // 13,15
+14, 0, 42821, 14, 1, 8288, 15, 0, 8452, 15, 1, 5975, // 14, 0
+14, 1, 44074, 14, 2, 7921, 15, 1, 7901, 15, 2, 5640, // 14, 1
+14, 2, 45288, 14, 3, 7555, 15, 2, 7378, 15, 3, 5315, // 14, 2
+14, 3, 46430, 14, 4, 7204, 15, 3, 6892, 15, 4, 5010, // 14, 3
+14, 4, 47458, 14, 5, 6886, 15, 4, 6458, 15, 5, 4734, // 14, 4
+14, 5, 48322, 14, 6, 6620, 15, 5, 6092, 15, 6, 4502, // 14, 5
+14, 6, 48969, 14, 7, 6430, 15, 6, 5809, 15, 7, 4328, // 14, 6
+14, 7, 49358, 14, 8, 6335, 15, 7, 5623, 15, 8, 4220, // 14, 7
+13, 8, 5633, 13, 9, 4224, 14, 8, 49347, 14, 9, 6332, // 14, 8
+13, 9, 5820, 13, 10, 4330, 14, 9, 48960, 14, 10, 6426, // 14, 9
+13, 10, 6104, 13, 11, 4505, 14, 10, 48314, 14, 11, 6613, // 14,10
+13, 11, 6472, 13, 12, 4736, 14, 11, 47453, 14, 12, 6875, // 14,11
+13, 12, 6908, 13, 13, 5011, 14, 12, 46427, 14, 13, 7190, // 14,12
+13, 13, 7395, 13, 14, 5316, 14, 13, 45286, 14, 14, 7539, // 14,13
+13, 14, 7921, 13, 15, 5640, 14, 14, 44074, 14, 15, 7901, // 14,14
+13, 15, 8474, 13, 16, 5974, 14, 15, 42823, 14, 16, 8265, // 14,15
+15, 0, 41693, 15, 1, 8795, 16, 0, 8769, 16, 1, 6279, // 15, 0
+15, 1, 42823, 15, 2, 8474, 16, 1, 8265, 16, 2, 5974, // 15, 1
+15, 2, 43904, 15, 3, 8159, 16, 2, 7791, 16, 3, 5682, // 15, 2
+15, 3, 44907, 15, 4, 7863, 16, 3, 7356, 16, 4, 5410, // 15, 3
+15, 4, 45799, 15, 5, 7599, 16, 4, 6970, 16, 5, 5168, // 15, 4
+15, 5, 46541, 15, 6, 7383, 16, 5, 6644, 16, 6, 4968, // 15, 5
+15, 6, 47098, 15, 7, 7233, 16, 6, 6391, 16, 7, 4814, // 15, 6
+15, 7, 47440, 15, 8, 7161, 16, 7, 6217, 16, 8, 4718, // 15, 7
+14, 8, 6230, 14, 9, 4722, 15, 8, 47426, 15, 9, 7158, // 15, 8
+14, 9, 6405, 14, 10, 4818, 15, 9, 47086, 15, 10, 7227, // 15, 9
+14, 10, 6659, 14, 11, 4971, 15, 10, 46532, 15, 11, 7374, // 15,10
+14, 11, 6986, 14, 12, 5172, 15, 11, 45791, 15, 12, 7587, // 15,11
+14, 12, 7374, 14, 13, 5413, 15, 12, 44901, 15, 13, 7848, // 15,12
+14, 13, 7812, 14, 14, 5684, 15, 13, 43900, 15, 14, 8140, // 15,13
+14, 14, 8288, 14, 15, 5975, 15, 14, 42821, 15, 15, 8452, // 15,14
+14, 15, 8795, 14, 16, 6280, 15, 15, 41693, 15, 16, 8768, // 15,15
+// angle of 1.5 degrees
+0, -1, 11440, 0, 0, 34212, 1, -1, 8358, 1, 0, 11526, // 0, 0
+0, 0, 11192, 0, 1, 35502, 1, 0, 7987, 1, 1, 10855, // 0, 1
+0, 1, 10930, 0, 2, 36756, 1, 1, 7626, 1, 2, 10224, // 0, 2
+0, 2, 10670, 0, 3, 37939, 1, 2, 7285, 1, 3, 9642, // 0, 3
+0, 3, 10430, 0, 4, 39009, 1, 3, 6975, 1, 4, 9122, // 0, 4
+0, 4, 10232, 0, 5, 39918, 1, 4, 6710, 1, 5, 8676, // 0, 5
+0, 5, 10100, 0, 6, 40618, 1, 5, 6502, 1, 6, 8316, // 0, 6
+0, 6, 10052, 0, 7, 41072, 1, 6, 6360, 1, 7, 8052, // 0, 7
+-1, 7, 6346, -1, 8, 8018, 0, 7, 10066, 0, 8, 41106, // 0, 8
+-1, 8, 6489, -1, 9, 8278, 0, 8, 10123, 0, 9, 40646, // 0, 9
+-1, 9, 6699, -1, 10, 8632, 0, 9, 10265, 0, 10, 39940, // 0,10
+-1, 10, 6965, -1, 11, 9072, 0, 10, 10473, 0, 11, 39026, // 0,11
+-1, 11, 7276, -1, 12, 9585, 0, 11, 10723, 0, 12, 37952, // 0,12
+-1, 12, 7620, -1, 13, 10158, 0, 12, 10994, 0, 13, 36764, // 0,13
+-1, 13, 7983, -1, 14, 10780, 0, 13, 11267, 0, 14, 35506, // 0,14
+-1, 14, 8358, -1, 15, 11440, 0, 14, 11526, 0, 15, 34212, // 0,15
+1, -1, 10780, 1, 0, 35506, 2, -1, 7983, 2, 0, 11267, // 1, 0
+1, 0, 10467, 1, 1, 36959, 2, 0, 7579, 2, 1, 10531, // 1, 1
+1, 1, 10133, 1, 2, 38390, 2, 1, 7179, 2, 2, 9834, // 1, 2
+1, 2, 9796, 1, 3, 39759, 2, 2, 6797, 2, 3, 9184, // 1, 3
+1, 3, 9478, 1, 4, 41013, 2, 3, 6447, 2, 4, 8598, // 1, 4
+1, 4, 9206, 1, 5, 42087, 2, 4, 6145, 2, 5, 8098, // 1, 5
+1, 5, 9014, 1, 6, 42913, 2, 5, 5910, 2, 6, 7699, // 1, 6
+1, 6, 8929, 1, 7, 43433, 2, 6, 5756, 2, 7, 7418, // 1, 7
+0, 7, 5745, 0, 8, 7390, 1, 7, 8939, 1, 8, 43462, // 1, 8
+0, 8, 5900, 0, 9, 7667, 1, 8, 9032, 1, 9, 42937, // 1, 9
+0, 9, 6137, 0, 10, 8061, 1, 9, 9233, 1, 10, 42105, // 1,10
+0, 10, 6440, 0, 11, 8557, 1, 10, 9513, 1, 11, 41026, // 1,11
+0, 11, 6792, 0, 12, 9135, 1, 11, 9841, 1, 12, 39768, // 1,12
+0, 12, 7177, 0, 13, 9777, 1, 12, 10188, 1, 13, 38394, // 1,13
+0, 13, 7579, 0, 14, 10467, 1, 13, 10532, 1, 14, 36958, // 1,14
+0, 14, 7987, 0, 15, 11192, 1, 14, 10855, 1, 15, 35502, // 1,15
+2, -1, 10158, 2, 0, 36764, 3, -1, 7620, 3, 0, 10994, // 2, 0
+2, 0, 9777, 2, 1, 38394, 3, 0, 7177, 3, 1, 10188, // 2, 1
+2, 1, 9366, 2, 2, 40025, 3, 1, 6732, 3, 2, 9413, // 2, 2
+2, 2, 8941, 2, 3, 41614, 3, 2, 6299, 3, 3, 8682, // 2, 3
+2, 3, 8530, 2, 4, 43096, 3, 3, 5895, 3, 4, 8015, // 2, 4
+2, 4, 8167, 2, 5, 44386, 3, 4, 5543, 3, 5, 7440, // 2, 5
+2, 5, 7899, 2, 6, 45383, 3, 5, 5268, 3, 6, 6986, // 2, 6
+2, 6, 7766, 2, 7, 45995, 3, 6, 5095, 3, 7, 6680, // 2, 7
+1, 7, 5087, 1, 8, 6658, 2, 7, 7773, 2, 8, 46018, // 2, 8
+1, 8, 5261, 1, 9, 6961, 2, 8, 7913, 2, 9, 45401, // 2, 9
+1, 9, 5537, 1, 10, 7411, 2, 9, 8189, 2, 10, 44399, // 2,10
+1, 10, 5891, 1, 11, 7981, 2, 10, 8559, 2, 11, 43105, // 2,11
+1, 11, 6297, 1, 12, 8641, 2, 11, 8979, 2, 12, 41619, // 2,12
+1, 12, 6732, 1, 13, 9366, 2, 12, 9413, 2, 13, 40025, // 2,13
+1, 13, 7179, 1, 14, 10133, 2, 13, 9834, 2, 14, 38390, // 2,14
+1, 14, 7626, 1, 15, 10930, 2, 14, 10224, 2, 15, 36756, // 2,15
+3, -1, 9585, 3, 0, 37951, 4, -1, 7276, 4, 0, 10724, // 3, 0
+3, 0, 9135, 3, 1, 39767, 4, 0, 6792, 4, 1, 9842, // 3, 1
+3, 1, 8641, 3, 2, 41618, 4, 1, 6297, 4, 2, 8980, // 3, 2
+3, 2, 8120, 3, 3, 43461, 4, 2, 5804, 4, 3, 8151, // 3, 3
+3, 3, 7598, 3, 4, 45224, 4, 3, 5331, 4, 4, 7383, // 3, 4
+3, 4, 7121, 3, 5, 46798, 4, 4, 4909, 4, 5, 6708, // 3, 5
+3, 5, 6750, 3, 6, 48037, 4, 5, 4576, 4, 6, 6173, // 3, 6
+3, 6, 6552, 3, 7, 48785, 4, 6, 4372, 4, 7, 5827, // 3, 7
+2, 7, 4366, 2, 8, 5811, 3, 7, 6558, 3, 8, 48801, // 3, 8
+2, 8, 4572, 2, 9, 6154, 3, 8, 6761, 3, 9, 48049, // 3, 9
+2, 9, 4906, 2, 10, 6685, 3, 9, 7138, 3, 10, 46807, // 3,10
+2, 10, 5330, 2, 11, 7356, 3, 10, 7622, 3, 11, 45228, // 3,11
+2, 11, 5804, 2, 12, 8120, 3, 11, 8151, 3, 12, 43461, // 3,12
+2, 12, 6299, 2, 13, 8941, 3, 12, 8681, 3, 13, 41615, // 3,13
+2, 13, 6797, 2, 14, 9796, 3, 13, 9184, 3, 14, 39759, // 3,14
+2, 14, 7285, 2, 15, 10670, 3, 14, 9642, 3, 15, 37939, // 3,15
+4, -1, 9072, 4, 0, 39026, 5, -1, 6965, 5, 0, 10473, // 4, 0
+4, 0, 8557, 4, 1, 41026, 5, 0, 6440, 5, 1, 9513, // 4, 1
+4, 1, 7981, 4, 2, 43105, 5, 1, 5891, 5, 2, 8559, // 4, 2
+4, 2, 7356, 4, 3, 45229, 5, 2, 5330, 5, 3, 7621, // 4, 3
+4, 3, 6708, 4, 4, 47328, 5, 3, 4774, 5, 4, 6726, // 4, 4
+4, 4, 6086, 4, 5, 49275, 5, 4, 4258, 5, 5, 5917, // 4, 5
+4, 5, 5573, 4, 6, 50865, 5, 5, 3837, 5, 6, 5261, // 4, 6
+4, 6, 5280, 4, 7, 51832, 5, 6, 3579, 5, 7, 4845, // 4, 7
+3, 7, 3575, 3, 8, 4835, 4, 7, 5283, 4, 8, 51843, // 4, 8
+3, 8, 3834, 3, 9, 5248, 4, 8, 5581, 4, 9, 50873, // 4, 9
+3, 9, 4257, 3, 10, 5901, 4, 9, 6099, 4, 10, 49279, // 4,10
+3, 10, 4774, 3, 11, 6708, 4, 10, 6727, 4, 11, 47327, // 4,11
+3, 11, 5331, 3, 12, 7598, 4, 11, 7382, 4, 12, 45225, // 4,12
+3, 12, 5895, 3, 13, 8530, 4, 12, 8015, 4, 13, 43096, // 4,13
+3, 13, 6447, 3, 14, 9478, 4, 13, 8599, 4, 14, 41012, // 4,14
+3, 14, 6975, 3, 15, 10430, 4, 14, 9122, 4, 15, 39009, // 4,15
+5, -1, 8632, 5, 0, 39940, 6, -1, 6699, 6, 0, 10265, // 5, 0
+5, 0, 8061, 5, 1, 42105, 6, 0, 6137, 6, 1, 9233, // 5, 1
+5, 1, 7411, 5, 2, 44399, 6, 1, 5537, 6, 2, 8189, // 5, 2
+5, 2, 6685, 5, 3, 46806, 6, 2, 4906, 6, 3, 7139, // 5, 3
+5, 3, 5901, 5, 4, 49279, 6, 3, 4257, 6, 4, 6099, // 5, 4
+5, 4, 5103, 5, 5, 51700, 6, 4, 3621, 6, 5, 5112, // 5, 5
+5, 5, 4388, 5, 6, 53813, 6, 5, 3065, 6, 6, 4270, // 5, 6
+5, 6, 3938, 5, 7, 55162, 6, 6, 2710, 6, 7, 3726, // 5, 7
+4, 7, 2708, 4, 8, 3720, 5, 7, 3940, 5, 8, 55168, // 5, 8
+4, 8, 3064, 4, 9, 4262, 5, 8, 4394, 5, 9, 53816, // 5, 9
+4, 9, 3621, 4, 10, 5103, 5, 9, 5113, 5, 10, 51699, // 5,10
+4, 10, 4258, 4, 11, 6086, 5, 10, 5917, 5, 11, 49275, // 5,11
+4, 11, 4909, 4, 12, 7121, 5, 11, 6707, 5, 12, 46799, // 5,12
+4, 12, 5543, 4, 13, 8167, 5, 12, 7440, 5, 13, 44386, // 5,13
+4, 13, 6145, 4, 14, 9206, 5, 13, 8098, 5, 14, 42087, // 5,14
+4, 14, 6710, 4, 15, 10232, 5, 14, 8676, 5, 15, 39918, // 5,15
+6, -1, 8278, 6, 0, 40646, 7, -1, 6489, 7, 0, 10123, // 6, 0
+6, 0, 7667, 6, 1, 42936, 7, 0, 5900, 7, 1, 9033, // 6, 1
+6, 1, 6961, 6, 2, 45401, 7, 1, 5261, 7, 2, 7913, // 6, 2
+6, 2, 6154, 6, 3, 48049, 7, 2, 4572, 7, 3, 6761, // 6, 3
+6, 3, 5248, 6, 4, 50873, 7, 3, 3834, 7, 4, 5581, // 6, 4
+6, 4, 4262, 6, 5, 53816, 7, 4, 3064, 7, 5, 4394, // 6, 5
+6, 5, 3271, 6, 6, 56673, 7, 5, 2316, 7, 6, 3276, // 6, 6
+6, 6, 2532, 6, 7, 58773, 7, 6, 1767, 7, 7, 2464, // 6, 7
+5, 7, 1766, 5, 8, 2462, 6, 7, 2533, 6, 8, 58775, // 6, 8
+5, 8, 2316, 5, 9, 3271, 6, 8, 3275, 6, 9, 56674, // 6, 9
+5, 9, 3065, 5, 10, 4388, 6, 9, 4269, 6, 10, 53814, // 6,10
+5, 10, 3837, 5, 11, 5573, 6, 10, 5261, 6, 11, 50865, // 6,11
+5, 11, 4576, 5, 12, 6750, 6, 11, 6173, 6, 12, 48037, // 6,12
+5, 12, 5268, 5, 13, 7899, 6, 12, 6986, 6, 13, 45383, // 6,13
+5, 13, 5910, 5, 14, 9014, 6, 13, 7699, 6, 14, 42913, // 6,14
+5, 14, 6502, 5, 15, 10100, 6, 14, 8316, 6, 15, 40618, // 6,15
+7, -1, 8018, 7, 0, 41106, 8, -1, 6346, 8, 0, 10066, // 7, 0
+7, 0, 7390, 7, 1, 43461, 8, 0, 5745, 8, 1, 8940, // 7, 1
+7, 1, 6658, 7, 2, 46017, 8, 1, 5087, 8, 2, 7774, // 7, 2
+7, 2, 5811, 7, 3, 48801, 8, 2, 4366, 8, 3, 6558, // 7, 3
+7, 3, 4835, 7, 4, 51842, 8, 3, 3575, 8, 4, 5284, // 7, 4
+7, 4, 3720, 7, 5, 55168, 8, 4, 2708, 8, 5, 3940, // 7, 5
+7, 5, 2462, 7, 6, 58775, 8, 5, 1766, 8, 6, 2533, // 7, 6
+7, 6, 1170, 7, 7, 62369, 8, 6, 827, 8, 7, 1170, // 7, 7
+6, 7, 827, 6, 8, 1170, 7, 7, 1170, 7, 8, 62369, // 7, 8
+6, 8, 1767, 6, 9, 2532, 7, 8, 2464, 7, 9, 58773, // 7, 9
+6, 9, 2710, 6, 10, 3938, 7, 9, 3726, 7, 10, 55162, // 7,10
+6, 10, 3579, 6, 11, 5280, 7, 10, 4846, 7, 11, 51831, // 7,11
+6, 11, 4372, 6, 12, 6552, 7, 11, 5827, 7, 12, 48785, // 7,12
+6, 12, 5095, 6, 13, 7766, 7, 12, 6680, 7, 13, 45995, // 7,13
+6, 13, 5756, 6, 14, 8929, 7, 13, 7418, 7, 14, 43433, // 7,14
+6, 14, 6360, 6, 15, 10052, 7, 14, 8052, 7, 15, 41072, // 7,15
+8, 0, 41072, 8, 1, 8052, 9, 0, 10052, 9, 1, 6360, // 8, 0
+8, 1, 43433, 8, 2, 7418, 9, 1, 8929, 9, 2, 5756, // 8, 1
+8, 2, 45995, 8, 3, 6680, 9, 2, 7766, 9, 3, 5095, // 8, 2
+8, 3, 48785, 8, 4, 5827, 9, 3, 6552, 9, 4, 4372, // 8, 3
+8, 4, 51832, 8, 5, 4846, 9, 4, 5280, 9, 5, 3578, // 8, 4
+8, 5, 55162, 8, 6, 3726, 9, 5, 3938, 9, 6, 2710, // 8, 5
+8, 6, 58773, 8, 7, 2464, 9, 6, 2532, 9, 7, 1767, // 8, 6
+8, 7, 62369, 8, 8, 1170, 9, 7, 1170, 9, 8, 827, // 8, 7
+7, 8, 1170, 7, 9, 827, 8, 8, 62369, 8, 9, 1170, // 8, 8
+7, 9, 2533, 7, 10, 1766, 8, 9, 58775, 8, 10, 2462, // 8, 9
+7, 10, 3940, 7, 11, 2708, 8, 10, 55168, 8, 11, 3720, // 8,10
+7, 11, 5283, 7, 12, 3575, 8, 11, 51842, 8, 12, 4836, // 8,11
+7, 12, 6558, 7, 13, 4366, 8, 12, 48801, 8, 13, 5811, // 8,12
+7, 13, 7773, 7, 14, 5087, 8, 13, 46017, 8, 14, 6659, // 8,13
+7, 14, 8939, 7, 15, 5745, 8, 14, 43461, 8, 15, 7391, // 8,14
+7, 15, 10066, 7, 16, 6346, 8, 15, 41106, 8, 16, 8018, // 8,15
+9, 0, 40618, 9, 1, 8316, 10, 0, 10100, 10, 1, 6502, // 9, 0
+9, 1, 42913, 9, 2, 7699, 10, 1, 9014, 10, 2, 5910, // 9, 1
+9, 2, 45383, 9, 3, 6986, 10, 2, 7899, 10, 3, 5268, // 9, 2
+9, 3, 48037, 9, 4, 6173, 10, 3, 6750, 10, 4, 4576, // 9, 3
+9, 4, 50865, 9, 5, 5261, 10, 4, 5573, 10, 5, 3837, // 9, 4
+9, 5, 53813, 9, 6, 4269, 10, 5, 4388, 10, 6, 3066, // 9, 5
+9, 6, 56673, 9, 7, 3275, 10, 6, 3271, 10, 7, 2317, // 9, 6
+9, 7, 58775, 9, 8, 2533, 10, 7, 2462, 10, 8, 1766, // 9, 7
+8, 8, 2464, 8, 9, 1767, 9, 8, 58773, 9, 9, 2532, // 9, 8
+8, 9, 3275, 8, 10, 2316, 9, 9, 56673, 9, 10, 3272, // 9, 9
+8, 10, 4394, 8, 11, 3064, 9, 10, 53816, 9, 11, 4262, // 9,10
+8, 11, 5581, 8, 12, 3834, 9, 11, 50873, 9, 12, 5248, // 9,11
+8, 12, 6761, 8, 13, 4572, 9, 12, 48049, 9, 13, 6154, // 9,12
+8, 13, 7913, 8, 14, 5261, 9, 13, 45401, 9, 14, 6961, // 9,13
+8, 14, 9032, 8, 15, 5900, 9, 14, 42936, 9, 15, 7668, // 9,14
+8, 15, 10123, 8, 16, 6489, 9, 15, 40646, 9, 16, 8278, // 9,15
+10, 0, 39918, 10, 1, 8676, 11, 0, 10232, 11, 1, 6710, // 10, 0
+10, 1, 42087, 10, 2, 8098, 11, 1, 9206, 11, 2, 6145, // 10, 1
+10, 2, 44386, 10, 3, 7440, 11, 2, 8167, 11, 3, 5543, // 10, 2
+10, 3, 46798, 10, 4, 6707, 11, 3, 7121, 11, 4, 4910, // 10, 3
+10, 4, 49275, 10, 5, 5917, 11, 4, 6086, 11, 5, 4258, // 10, 4
+10, 5, 51700, 10, 6, 5113, 11, 5, 5103, 11, 6, 3620, // 10, 5
+10, 6, 53816, 10, 7, 4394, 11, 6, 4262, 11, 7, 3064, // 10, 6
+10, 7, 55168, 10, 8, 3940, 11, 7, 3720, 11, 8, 2708, // 10, 7
+9, 8, 3726, 9, 9, 2710, 10, 8, 55162, 10, 9, 3938, // 10, 8
+9, 9, 4269, 9, 10, 3065, 10, 9, 53813, 10, 10, 4389, // 10, 9
+9, 10, 5113, 9, 11, 3621, 10, 10, 51700, 10, 11, 5102, // 10,10
+9, 11, 6099, 9, 12, 4257, 10, 11, 49279, 10, 12, 5901, // 10,11
+9, 12, 7138, 9, 13, 4906, 10, 12, 46806, 10, 13, 6686, // 10,12
+9, 13, 8189, 9, 14, 5537, 10, 13, 44399, 10, 14, 7411, // 10,13
+9, 14, 9233, 9, 15, 6137, 10, 14, 42105, 10, 15, 8061, // 10,14
+9, 15, 10265, 9, 16, 6699, 10, 15, 39940, 10, 16, 8632, // 10,15
+11, 0, 39009, 11, 1, 9122, 12, 0, 10430, 12, 1, 6975, // 11, 0
+11, 1, 41013, 11, 2, 8599, 12, 1, 9478, 12, 2, 6446, // 11, 1
+11, 2, 43096, 11, 3, 8015, 12, 2, 8530, 12, 3, 5895, // 11, 2
+11, 3, 45224, 11, 4, 7382, 12, 3, 7598, 12, 4, 5332, // 11, 3
+11, 4, 47328, 11, 5, 6727, 12, 4, 6708, 12, 5, 4773, // 11, 4
+11, 5, 49279, 11, 6, 6099, 12, 5, 5901, 12, 6, 4257, // 11, 5
+11, 6, 50873, 11, 7, 5581, 12, 6, 5248, 12, 7, 3834, // 11, 6
+11, 7, 51842, 11, 8, 5283, 12, 7, 4835, 12, 8, 3576, // 11, 7
+10, 8, 4846, 10, 9, 3579, 11, 8, 51832, 11, 9, 5279, // 11, 8
+10, 9, 5261, 10, 10, 3837, 11, 9, 50865, 11, 10, 5573, // 11, 9
+10, 10, 5917, 10, 11, 4258, 11, 10, 49275, 11, 11, 6086, // 11,10
+10, 11, 6727, 10, 12, 4774, 11, 11, 47328, 11, 12, 6707, // 11,11
+10, 12, 7622, 10, 13, 5330, 11, 12, 45229, 11, 13, 7355, // 11,12
+10, 13, 8559, 10, 14, 5891, 11, 13, 43105, 11, 14, 7981, // 11,13
+10, 14, 9513, 10, 15, 6440, 11, 14, 41026, 11, 15, 8557, // 11,14
+10, 15, 10473, 10, 16, 6965, 11, 15, 39026, 11, 16, 9072, // 11,15
+12, 0, 37939, 12, 1, 9642, 13, 0, 10670, 13, 1, 7285, // 12, 0
+12, 1, 39759, 12, 2, 9184, 13, 1, 9796, 13, 2, 6797, // 12, 1
+12, 2, 41614, 12, 3, 8681, 13, 2, 8941, 13, 3, 6300, // 12, 2
+12, 3, 43461, 12, 4, 8151, 13, 3, 8120, 13, 4, 5804, // 12, 3
+12, 4, 45229, 12, 5, 7622, 13, 4, 7356, 13, 5, 5329, // 12, 4
+12, 5, 46806, 12, 6, 7138, 13, 5, 6685, 13, 6, 4907, // 12, 5
+12, 6, 48049, 12, 7, 6761, 13, 6, 6154, 13, 7, 4572, // 12, 6
+12, 7, 48801, 12, 8, 6558, 13, 7, 5811, 13, 8, 4366, // 12, 7
+11, 8, 5827, 11, 9, 4372, 12, 8, 48785, 12, 9, 6552, // 12, 8
+11, 9, 6173, 11, 10, 4576, 12, 9, 48037, 12, 10, 6750, // 12, 9
+11, 10, 6707, 11, 11, 4909, 12, 10, 46798, 12, 11, 7122, // 12,10
+11, 11, 7382, 11, 12, 5331, 12, 11, 45224, 12, 12, 7599, // 12,11
+11, 12, 8151, 11, 13, 5804, 12, 12, 43461, 12, 13, 8120, // 12,12
+11, 13, 8979, 11, 14, 6297, 12, 13, 41618, 12, 14, 8642, // 12,13
+11, 14, 9841, 11, 15, 6792, 12, 14, 39767, 12, 15, 9136, // 12,14
+11, 15, 10723, 11, 16, 7276, 12, 15, 37951, 12, 16, 9586, // 12,15
+13, 0, 36756, 13, 1, 10224, 14, 0, 10930, 14, 1, 7626, // 13, 0
+13, 1, 38390, 13, 2, 9834, 14, 1, 10133, 14, 2, 7179, // 13, 1
+13, 2, 40025, 13, 3, 9413, 14, 2, 9366, 14, 3, 6732, // 13, 2
+13, 3, 41618, 13, 4, 8979, 14, 3, 8641, 14, 4, 6298, // 13, 3
+13, 4, 43105, 13, 5, 8559, 14, 4, 7981, 14, 5, 5891, // 13, 4
+13, 5, 44399, 13, 6, 8189, 14, 5, 7411, 14, 6, 5537, // 13, 5
+13, 6, 45401, 13, 7, 7913, 14, 6, 6961, 14, 7, 5261, // 13, 6
+13, 7, 46017, 13, 8, 7773, 14, 7, 6658, 14, 8, 5088, // 13, 7
+12, 8, 6680, 12, 9, 5095, 13, 8, 45995, 13, 9, 7766, // 13, 8
+12, 9, 6986, 12, 10, 5268, 13, 9, 45383, 13, 10, 7899, // 13, 9
+12, 10, 7440, 12, 11, 5543, 13, 10, 44386, 13, 11, 8167, // 13,10
+12, 11, 8015, 12, 12, 5895, 13, 11, 43096, 13, 12, 8530, // 13,11
+12, 12, 8681, 12, 13, 6299, 13, 12, 41614, 13, 13, 8942, // 13,12
+12, 13, 9413, 12, 14, 6732, 13, 13, 40025, 13, 14, 9366, // 13,13
+12, 14, 10188, 12, 15, 7177, 13, 14, 38394, 13, 15, 9777, // 13,14
+12, 15, 10994, 12, 16, 7620, 13, 15, 36764, 13, 16, 10158, // 13,15
+14, 0, 35502, 14, 1, 10855, 15, 0, 11192, 15, 1, 7987, // 14, 0
+14, 1, 36959, 14, 2, 10532, 15, 1, 10467, 15, 2, 7578, // 14, 1
+14, 2, 38394, 14, 3, 10188, 15, 2, 9777, 15, 3, 7177, // 14, 2
+14, 3, 39767, 14, 4, 9841, 15, 3, 9135, 15, 4, 6793, // 14, 3
+14, 4, 41026, 14, 5, 9513, 15, 4, 8557, 15, 5, 6440, // 14, 4
+14, 5, 42105, 14, 6, 9233, 15, 5, 8061, 15, 6, 6137, // 14, 5
+14, 6, 42936, 14, 7, 9032, 15, 6, 7667, 15, 7, 5901, // 14, 6
+14, 7, 43461, 14, 8, 8939, 15, 7, 7390, 15, 8, 5746, // 14, 7
+13, 8, 7418, 13, 9, 5756, 14, 8, 43433, 14, 9, 8929, // 14, 8
+13, 9, 7699, 13, 10, 5910, 14, 9, 42913, 14, 10, 9014, // 14, 9
+13, 10, 8098, 13, 11, 6145, 14, 10, 42087, 14, 11, 9206, // 14,10
+13, 11, 8599, 13, 12, 6447, 14, 11, 41013, 14, 12, 9477, // 14,11
+13, 12, 9184, 13, 13, 6797, 14, 12, 39759, 14, 13, 9796, // 14,12
+13, 13, 9834, 13, 14, 7179, 14, 13, 38390, 14, 14, 10133, // 14,13
+13, 14, 10532, 13, 15, 7579, 14, 14, 36959, 14, 15, 10466, // 14,14
+13, 15, 11267, 13, 16, 7983, 14, 15, 35506, 14, 16, 10780, // 14,15
+15, 0, 34212, 15, 1, 11526, 16, 0, 11440, 16, 1, 8358, // 15, 0
+15, 1, 35506, 15, 2, 11267, 16, 1, 10780, 16, 2, 7983, // 15, 1
+15, 2, 36764, 15, 3, 10994, 16, 2, 10158, 16, 3, 7620, // 15, 2
+15, 3, 37951, 15, 4, 10723, 16, 3, 9585, 16, 4, 7277, // 15, 3
+15, 4, 39026, 15, 5, 10473, 16, 4, 9072, 16, 5, 6965, // 15, 4
+15, 5, 39940, 15, 6, 10265, 16, 5, 8632, 16, 6, 6699, // 15, 5
+15, 6, 40646, 15, 7, 10123, 16, 6, 8278, 16, 7, 6489, // 15, 6
+15, 7, 41106, 15, 8, 10066, 16, 7, 8018, 16, 8, 6346, // 15, 7
+14, 8, 8052, 14, 9, 6360, 15, 8, 41072, 15, 9, 10052, // 15, 8
+14, 9, 8316, 14, 10, 6502, 15, 9, 40618, 15, 10, 10100, // 15, 9
+14, 10, 8676, 14, 11, 6710, 15, 10, 39918, 15, 11, 10232, // 15,10
+14, 11, 9122, 14, 12, 6975, 15, 11, 39009, 15, 12, 10430, // 15,11
+14, 12, 9642, 14, 13, 7285, 15, 12, 37939, 15, 13, 10670, // 15,12
+14, 13, 10224, 14, 14, 7626, 15, 13, 36756, 15, 14, 10930, // 15,13
+14, 14, 10855, 14, 15, 7987, 15, 14, 35502, 15, 15, 11192, // 15,14
+14, 15, 11526, 14, 16, 8358, 15, 15, 34212, 15, 16, 11440, // 15,15
+// angle of 2.0 degrees
+0, -1, 13368, 0, 0, 28495, 1, -1, 10104, 1, 0, 13569, // 0, 0
+0, 0, 13291, 0, 1, 29828, 1, 0, 9671, 1, 1, 12746, // 0, 1
+0, 1, 13176, 0, 2, 31138, 1, 1, 9245, 1, 2, 11977, // 0, 2
+0, 2, 13038, 0, 3, 32391, 1, 2, 8838, 1, 3, 11269, // 0, 3
+0, 3, 12899, 0, 4, 33539, 1, 3, 8463, 1, 4, 10635, // 0, 4
+0, 4, 12783, 0, 5, 34532, 1, 4, 8135, 1, 5, 10086, // 0, 5
+0, 5, 12717, 0, 6, 35315, 1, 5, 7868, 1, 6, 9636, // 0, 6
+0, 6, 12728, 0, 7, 35844, 1, 6, 7674, 1, 7, 9290, // 0, 7
+-1, 7, 7643, -1, 8, 9224, 0, 7, 12764, 0, 8, 35905, // 0, 8
+-1, 8, 7839, -1, 9, 9558, 0, 8, 12777, 0, 9, 35362, // 0, 9
+-1, 9, 8107, -1, 10, 9995, 0, 9, 12867, 0, 10, 34567, // 0,10
+-1, 10, 8438, -1, 11, 10528, 0, 10, 13007, 0, 11, 33563, // 0,11
+-1, 11, 8816, -1, 12, 11143, 0, 11, 13171, 0, 12, 32406, // 0,12
+-1, 12, 9229, -1, 13, 11829, 0, 12, 13332, 0, 13, 31146, // 0,13
+-1, 13, 9662, -1, 14, 12574, 0, 13, 13470, 0, 14, 29830, // 0,14
+-1, 14, 10104, -1, 15, 13368, 0, 14, 13569, 0, 15, 28495, // 0,15
+1, -1, 12574, 1, 0, 29831, 2, -1, 9662, 2, 0, 13469, // 1, 0
+1, 0, 12412, 1, 1, 31358, 2, 0, 9202, 2, 1, 12564, // 1, 1
+1, 1, 12203, 1, 2, 32881, 2, 1, 8742, 2, 2, 11710, // 1, 2
+1, 2, 11964, 1, 3, 34358, 2, 2, 8296, 2, 3, 10918, // 1, 3
+1, 3, 11721, 1, 4, 35730, 2, 3, 7881, 2, 4, 10204, // 1, 4
+1, 4, 11507, 1, 5, 36926, 2, 4, 7517, 2, 5, 9586, // 1, 5
+1, 5, 11360, 1, 6, 37866, 2, 5, 7224, 2, 6, 9086, // 1, 6
+1, 6, 11317, 1, 7, 38481, 2, 6, 7020, 2, 7, 8718, // 1, 7
+0, 7, 6997, 0, 8, 8662, 1, 7, 11344, 1, 8, 38533, // 1, 8
+0, 8, 7202, 0, 9, 9020, 1, 8, 11407, 1, 9, 37907, // 1, 9
+0, 9, 7497, 0, 10, 9509, 1, 9, 11575, 1, 10, 36955, // 1,10
+0, 10, 7865, 0, 11, 10111, 1, 10, 11810, 1, 11, 35750, // 1,11
+0, 11, 8284, 0, 12, 10808, 1, 11, 12074, 1, 12, 34370, // 1,12
+0, 12, 8735, 0, 13, 11580, 1, 12, 12334, 1, 13, 32887, // 1,13
+0, 13, 9202, 0, 14, 12412, 1, 13, 12564, 1, 14, 31358, // 1,14
+0, 14, 9671, 0, 15, 13291, 1, 14, 12746, 1, 15, 29828, // 1,15
+2, -1, 11829, 2, 0, 31146, 3, -1, 9229, 3, 0, 13332, // 2, 0
+2, 0, 11580, 2, 1, 32886, 3, 0, 8735, 3, 1, 12335, // 2, 1
+2, 1, 11272, 2, 2, 34650, 3, 1, 8232, 3, 2, 11382, // 2, 2
+2, 2, 10922, 2, 3, 36392, 3, 2, 7734, 3, 3, 10488, // 2, 3
+2, 3, 10559, 2, 4, 38042, 3, 3, 7261, 3, 4, 9674, // 2, 4
+2, 4, 10226, 2, 5, 39503, 3, 4, 6842, 3, 5, 8965, // 2, 5
+2, 5, 9977, 2, 6, 40656, 3, 5, 6506, 3, 6, 8397, // 2, 6
+2, 6, 9867, 2, 7, 41389, 3, 6, 6284, 3, 7, 7996, // 2, 7
+1, 7, 6266, 1, 8, 7951, 2, 7, 9886, 2, 8, 41433, // 2, 8
+1, 8, 6491, 1, 9, 8344, 2, 8, 10013, 2, 9, 40688, // 2, 9
+1, 9, 6829, 1, 10, 8902, 2, 9, 10279, 2, 10, 39526, // 2,10
+1, 10, 7252, 1, 11, 9597, 2, 10, 10630, 2, 11, 38057, // 2,11
+1, 11, 7728, 1, 12, 10397, 2, 11, 11012, 2, 12, 36399, // 2,12
+1, 12, 8232, 1, 13, 11272, 2, 12, 11382, 2, 13, 34650, // 2,13
+1, 13, 8742, 1, 14, 12203, 2, 13, 11709, 2, 14, 32882, // 2,14
+1, 14, 9245, 1, 15, 13176, 2, 14, 11977, 2, 15, 31138, // 2,15
+3, -1, 11143, 3, 0, 32406, 4, -1, 8816, 4, 0, 13171, // 3, 0
+3, 0, 10808, 3, 1, 34369, 4, 0, 8284, 4, 1, 12075, // 3, 1
+3, 1, 10397, 3, 2, 36399, 4, 1, 7728, 4, 2, 11012, // 3, 2
+3, 2, 9924, 3, 3, 38450, 4, 2, 7164, 4, 3, 9998, // 3, 3
+3, 3, 9421, 3, 4, 40444, 4, 3, 6615, 4, 4, 9056, // 3, 4
+3, 4, 8940, 3, 5, 42256, 4, 4, 6116, 4, 5, 8224, // 3, 5
+3, 5, 8558, 3, 6, 43710, 4, 5, 5712, 4, 6, 7556, // 3, 6
+3, 6, 8359, 3, 7, 44616, 4, 6, 5454, 4, 7, 7107, // 3, 7
+2, 7, 5443, 2, 8, 7072, 3, 7, 8373, 3, 8, 44648, // 3, 8
+2, 8, 5703, 2, 9, 7516, 3, 8, 8584, 3, 9, 43733, // 3, 9
+2, 9, 6108, 2, 10, 8175, 3, 9, 8982, 3, 10, 42271, // 3,10
+2, 10, 6611, 2, 11, 8995, 3, 10, 9478, 3, 11, 40452, // 3,11
+2, 11, 7164, 2, 12, 9924, 3, 11, 9998, 3, 12, 38450, // 3,12
+2, 12, 7734, 2, 13, 10922, 3, 12, 10488, 3, 13, 36392, // 3,13
+2, 13, 8296, 2, 14, 11964, 3, 13, 10918, 3, 14, 34358, // 3,14
+2, 14, 8838, 2, 15, 13038, 3, 14, 11269, 3, 15, 32391, // 3,15
+4, -1, 10528, 4, 0, 33564, 5, -1, 8438, 5, 0, 13006, // 4, 0
+4, 0, 10111, 4, 1, 35750, 5, 0, 7865, 5, 1, 11810, // 4, 1
+4, 1, 9597, 4, 2, 38057, 5, 1, 7252, 5, 2, 10630, // 4, 2
+4, 2, 8995, 4, 3, 40452, 5, 2, 6611, 5, 3, 9478, // 4, 3
+4, 3, 8332, 4, 4, 42861, 5, 3, 5965, 5, 4, 8378, // 4, 4
+4, 4, 7667, 4, 5, 45139, 5, 4, 5353, 5, 5, 7377, // 4, 5
+4, 5, 7100, 4, 6, 47035, 5, 5, 4843, 5, 6, 6558, // 4, 6
+4, 6, 6774, 4, 7, 48218, 5, 6, 4521, 5, 7, 6023, // 4, 7
+3, 7, 4513, 3, 8, 6000, 4, 7, 6783, 4, 8, 48240, // 4, 8
+3, 8, 4838, 3, 9, 6530, 4, 8, 7119, 4, 9, 47049, // 4, 9
+3, 9, 5350, 3, 10, 7342, 4, 9, 7698, 4, 10, 45146, // 4,10
+3, 10, 5965, 3, 11, 8332, 4, 10, 8378, 4, 11, 42861, // 4,11
+3, 11, 6615, 3, 12, 9421, 4, 11, 9056, 4, 12, 40444, // 4,12
+3, 12, 7261, 3, 13, 10559, 4, 12, 9674, 4, 13, 38042, // 4,13
+3, 13, 7881, 3, 14, 11721, 4, 13, 10204, 4, 14, 35730, // 4,14
+3, 14, 8463, 3, 15, 12899, 4, 14, 10635, 4, 15, 33539, // 4,15
+5, -1, 9995, 5, 0, 34567, 6, -1, 8107, 6, 0, 12867, // 5, 0
+5, 0, 9509, 5, 1, 36955, 6, 0, 7497, 6, 1, 11575, // 5, 1
+5, 1, 8902, 5, 2, 39526, 6, 1, 6829, 6, 2, 10279, // 5, 2
+5, 2, 8175, 5, 3, 42271, 6, 2, 6108, 6, 3, 8982, // 5, 3
+5, 3, 7342, 5, 4, 45146, 6, 3, 5350, 6, 4, 7698, // 5, 4
+5, 4, 6451, 5, 5, 48019, 6, 4, 4591, 6, 5, 6475, // 5, 5
+5, 5, 5624, 5, 6, 50581, 6, 5, 3913, 6, 6, 5418, // 5, 6
+5, 6, 5092, 5, 7, 52253, 6, 6, 3470, 6, 7, 4721, // 5, 7
+4, 7, 3466, 4, 8, 4708, 5, 7, 5097, 5, 8, 52265, // 5, 8
+4, 8, 3911, 4, 9, 5400, 5, 8, 5637, 5, 9, 50588, // 5, 9
+4, 9, 4591, 4, 10, 6451, 5, 9, 6475, 5, 10, 48019, // 5,10
+4, 10, 5353, 4, 11, 7667, 5, 10, 7377, 5, 11, 45139, // 5,11
+4, 11, 6116, 4, 12, 8940, 5, 11, 8224, 5, 12, 42256, // 5,12
+4, 12, 6842, 4, 13, 10226, 5, 12, 8966, 5, 13, 39502, // 5,13
+4, 13, 7517, 4, 14, 11507, 5, 13, 9587, 5, 14, 36925, // 5,14
+4, 14, 8135, 4, 15, 12783, 5, 14, 10086, 5, 15, 34532, // 5,15
+6, -1, 9558, 6, 0, 35362, 7, -1, 7839, 7, 0, 12777, // 6, 0
+6, 0, 9020, 6, 1, 37906, 7, 0, 7202, 7, 1, 11408, // 6, 1
+6, 1, 8344, 6, 2, 40688, 7, 1, 6491, 7, 2, 10013, // 6, 2
+6, 2, 7516, 6, 3, 43733, 7, 2, 5703, 7, 3, 8584, // 6, 3
+6, 3, 6530, 6, 4, 47049, 7, 3, 4838, 7, 4, 7119, // 6, 4
+6, 4, 5400, 6, 5, 50587, 7, 4, 3911, 7, 5, 5638, // 6, 5
+6, 5, 4217, 6, 6, 54105, 7, 5, 2989, 7, 6, 4225, // 6, 6
+6, 6, 3303, 6, 7, 56751, 7, 6, 2295, 7, 7, 3187, // 6, 7
+5, 7, 2294, 5, 8, 3180, 6, 7, 3306, 6, 8, 56756, // 6, 8
+5, 8, 2989, 5, 9, 4217, 6, 8, 4225, 6, 9, 54105, // 6, 9
+5, 9, 3913, 5, 10, 5624, 6, 9, 5418, 6, 10, 50581, // 6,10
+5, 10, 4843, 5, 11, 7100, 6, 10, 6558, 6, 11, 47035, // 6,11
+5, 11, 5712, 5, 12, 8558, 6, 11, 7556, 6, 12, 43710, // 6,12
+5, 12, 6506, 5, 13, 9977, 6, 12, 8397, 6, 13, 40656, // 6,13
+5, 13, 7224, 5, 14, 11360, 6, 13, 9086, 6, 14, 37866, // 6,14
+5, 14, 7868, 5, 15, 12717, 6, 14, 9635, 6, 15, 35316, // 6,15
+7, -1, 9224, 7, 0, 35905, 8, -1, 7643, 8, 0, 12764, // 7, 0
+7, 0, 8662, 7, 1, 38534, 8, 0, 6997, 8, 1, 11343, // 7, 1
+7, 1, 7951, 7, 2, 41432, 8, 1, 6266, 8, 2, 9887, // 7, 2
+7, 2, 7072, 7, 3, 44649, 8, 2, 5443, 8, 3, 8372, // 7, 3
+7, 3, 6000, 7, 4, 48240, 8, 3, 4513, 8, 4, 6783, // 7, 4
+7, 4, 4708, 7, 5, 52266, 8, 4, 3466, 8, 5, 5096, // 7, 5
+7, 5, 3180, 7, 6, 56756, 8, 5, 2294, 8, 6, 3306, // 7, 6
+7, 6, 1541, 7, 7, 61364, 8, 6, 1090, 8, 7, 1541, // 7, 7
+6, 7, 1090, 6, 8, 1541, 7, 7, 1542, 7, 8, 61363, // 7, 8
+6, 8, 2295, 6, 9, 3303, 7, 8, 3186, 7, 9, 56752, // 7, 9
+6, 9, 3470, 6, 10, 5092, 7, 9, 4721, 7, 10, 52253, // 7,10
+6, 10, 4521, 6, 11, 6774, 7, 10, 6023, 7, 11, 48218, // 7,11
+6, 11, 5454, 6, 12, 8359, 7, 11, 7106, 7, 12, 44617, // 7,12
+6, 12, 6284, 6, 13, 9867, 7, 12, 7996, 7, 13, 41389, // 7,13
+6, 13, 7020, 6, 14, 11317, 7, 13, 8718, 7, 14, 38481, // 7,14
+6, 14, 7674, 6, 15, 12728, 7, 14, 9290, 7, 15, 35844, // 7,15
+8, 0, 35844, 8, 1, 9290, 9, 0, 12728, 9, 1, 7674, // 8, 0
+8, 1, 38481, 8, 2, 8718, 9, 1, 11317, 9, 2, 7020, // 8, 1
+8, 2, 41389, 8, 3, 7996, 9, 2, 9867, 9, 3, 6284, // 8, 2
+8, 3, 44616, 8, 4, 7106, 9, 3, 8359, 9, 4, 5455, // 8, 3
+8, 4, 48218, 8, 5, 6023, 9, 4, 6774, 9, 5, 4521, // 8, 4
+8, 5, 52253, 8, 6, 4721, 9, 5, 5092, 9, 6, 3470, // 8, 5
+8, 6, 56751, 8, 7, 3186, 9, 6, 3303, 9, 7, 2296, // 8, 6
+8, 7, 61364, 8, 8, 1542, 9, 7, 1541, 9, 8, 1089, // 8, 7
+7, 8, 1542, 7, 9, 1090, 8, 8, 61364, 8, 9, 1540, // 8, 8
+7, 9, 3306, 7, 10, 2294, 8, 9, 56756, 8, 10, 3180, // 8, 9
+7, 10, 5097, 7, 11, 3466, 8, 10, 52266, 8, 11, 4707, // 8,10
+7, 11, 6783, 7, 12, 4513, 8, 11, 48240, 8, 12, 6000, // 8,11
+7, 12, 8373, 7, 13, 5443, 8, 12, 44649, 8, 13, 7071, // 8,12
+7, 13, 9886, 7, 14, 6266, 8, 13, 41432, 8, 14, 7952, // 8,13
+7, 14, 11344, 7, 15, 6997, 8, 14, 38534, 8, 15, 8661, // 8,14
+7, 15, 12764, 7, 16, 7643, 8, 15, 35905, 8, 16, 9224, // 8,15
+9, 0, 35315, 9, 1, 9635, 10, 0, 12717, 10, 1, 7869, // 9, 0
+9, 1, 37866, 9, 2, 9086, 10, 1, 11360, 10, 2, 7224, // 9, 1
+9, 2, 40656, 9, 3, 8397, 10, 2, 9977, 10, 3, 6506, // 9, 2
+9, 3, 43710, 9, 4, 7556, 10, 3, 8558, 10, 4, 5712, // 9, 3
+9, 4, 47035, 9, 5, 6558, 10, 4, 7100, 10, 5, 4843, // 9, 4
+9, 5, 50581, 9, 6, 5418, 10, 5, 5624, 10, 6, 3913, // 9, 5
+9, 6, 54105, 9, 7, 4225, 10, 6, 4217, 10, 7, 2989, // 9, 6
+9, 7, 56756, 9, 8, 3306, 10, 7, 3180, 10, 8, 2294, // 9, 7
+8, 8, 3186, 8, 9, 2295, 9, 8, 56751, 9, 9, 3304, // 9, 8
+8, 9, 4225, 8, 10, 2989, 9, 9, 54105, 9, 10, 4217, // 9, 9
+8, 10, 5637, 8, 11, 3911, 9, 10, 50587, 9, 11, 5401, // 9,10
+8, 11, 7119, 8, 12, 4838, 9, 11, 47049, 9, 12, 6530, // 9,11
+8, 12, 8584, 8, 13, 5703, 9, 12, 43733, 9, 13, 7516, // 9,12
+8, 13, 10013, 8, 14, 6491, 9, 13, 40688, 9, 14, 8344, // 9,13
+8, 14, 11407, 8, 15, 7202, 9, 14, 37906, 9, 15, 9021, // 9,14
+8, 15, 12777, 8, 16, 7839, 9, 15, 35362, 9, 16, 9558, // 9,15
+10, 0, 34532, 10, 1, 10086, 11, 0, 12783, 11, 1, 8135, // 10, 0
+10, 1, 36926, 10, 2, 9587, 11, 1, 11507, 11, 2, 7516, // 10, 1
+10, 2, 39503, 10, 3, 8966, 11, 2, 10226, 11, 3, 6841, // 10, 2
+10, 3, 42256, 10, 4, 8224, 11, 3, 8940, 11, 4, 6116, // 10, 3
+10, 4, 45139, 10, 5, 7377, 11, 4, 7667, 11, 5, 5353, // 10, 4
+10, 5, 48019, 10, 6, 6475, 11, 5, 6451, 11, 6, 4591, // 10, 5
+10, 6, 50587, 10, 7, 5637, 11, 6, 5400, 11, 7, 3912, // 10, 6
+10, 7, 52266, 10, 8, 5097, 11, 7, 4708, 11, 8, 3465, // 10, 7
+9, 8, 4721, 9, 9, 3470, 10, 8, 52253, 10, 9, 5092, // 10, 8
+9, 9, 5418, 9, 10, 3913, 10, 9, 50581, 10, 10, 5624, // 10, 9
+9, 10, 6475, 9, 11, 4591, 10, 10, 48019, 10, 11, 6451, // 10,10
+9, 11, 7698, 9, 12, 5350, 10, 11, 45146, 10, 12, 7342, // 10,11
+9, 12, 8982, 9, 13, 6108, 10, 12, 42271, 10, 13, 8175, // 10,12
+9, 13, 10279, 9, 14, 6829, 10, 13, 39526, 10, 14, 8902, // 10,13
+9, 14, 11575, 9, 15, 7497, 10, 14, 36955, 10, 15, 9509, // 10,14
+9, 15, 12867, 9, 16, 8107, 10, 15, 34567, 10, 16, 9995, // 10,15
+11, 0, 33539, 11, 1, 10635, 12, 0, 12899, 12, 1, 8463, // 11, 0
+11, 1, 35730, 11, 2, 10204, 12, 1, 11721, 12, 2, 7881, // 11, 1
+11, 2, 38042, 11, 3, 9674, 12, 2, 10559, 12, 3, 7261, // 11, 2
+11, 3, 40444, 11, 4, 9056, 12, 3, 9421, 12, 4, 6615, // 11, 3
+11, 4, 42861, 11, 5, 8378, 12, 4, 8332, 12, 5, 5965, // 11, 4
+11, 5, 45146, 11, 6, 7698, 12, 5, 7342, 12, 6, 5350, // 11, 5
+11, 6, 47049, 11, 7, 7119, 12, 6, 6530, 12, 7, 4838, // 11, 6
+11, 7, 48240, 11, 8, 6783, 12, 7, 6000, 12, 8, 4513, // 11, 7
+10, 8, 6023, 10, 9, 4521, 11, 8, 48218, 11, 9, 6774, // 11, 8
+10, 9, 6558, 10, 10, 4843, 11, 9, 47035, 11, 10, 7100, // 11, 9
+10, 10, 7377, 10, 11, 5353, 11, 10, 45139, 11, 11, 7667, // 11,10
+10, 11, 8378, 10, 12, 5965, 11, 11, 42861, 11, 12, 8332, // 11,11
+10, 12, 9478, 10, 13, 6611, 11, 12, 40452, 11, 13, 8995, // 11,12
+10, 13, 10630, 10, 14, 7252, 11, 13, 38057, 11, 14, 9597, // 11,13
+10, 14, 11810, 10, 15, 7865, 11, 14, 35750, 11, 15, 10111, // 11,14
+10, 15, 13007, 10, 16, 8438, 11, 15, 33564, 11, 16, 10527, // 11,15
+12, 0, 32391, 12, 1, 11269, 13, 0, 13038, 13, 1, 8838, // 12, 0
+12, 1, 34358, 12, 2, 10918, 13, 1, 11964, 13, 2, 8296, // 12, 1
+12, 2, 36392, 12, 3, 10488, 13, 2, 10922, 13, 3, 7734, // 12, 2
+12, 3, 38450, 12, 4, 9998, 13, 3, 9924, 13, 4, 7164, // 12, 3
+12, 4, 40452, 12, 5, 9478, 13, 4, 8995, 13, 5, 6611, // 12, 4
+12, 5, 42271, 12, 6, 8982, 13, 5, 8175, 13, 6, 6108, // 12, 5
+12, 6, 43733, 12, 7, 8584, 13, 6, 7516, 13, 7, 5703, // 12, 6
+12, 7, 44649, 12, 8, 8373, 13, 7, 7072, 13, 8, 5442, // 12, 7
+11, 8, 7106, 11, 9, 5454, 12, 8, 44616, 12, 9, 8360, // 12, 8
+11, 9, 7556, 11, 10, 5712, 12, 9, 43710, 12, 10, 8558, // 12, 9
+11, 10, 8224, 11, 11, 6116, 12, 10, 42256, 12, 11, 8940, // 12,10
+11, 11, 9056, 11, 12, 6615, 12, 11, 40444, 12, 12, 9421, // 12,11
+11, 12, 9998, 11, 13, 7164, 12, 12, 38450, 12, 13, 9924, // 12,12
+11, 13, 11012, 11, 14, 7728, 12, 13, 36399, 12, 14, 10397, // 12,13
+11, 14, 12074, 11, 15, 8284, 12, 14, 34369, 12, 15, 10809, // 12,14
+11, 15, 13171, 11, 16, 8816, 12, 15, 32406, 12, 16, 11143, // 12,15
+13, 0, 31138, 13, 1, 11977, 14, 0, 13176, 14, 1, 9245, // 13, 0
+13, 1, 32881, 13, 2, 11709, 14, 1, 12203, 14, 2, 8743, // 13, 1
+13, 2, 34650, 13, 3, 11382, 14, 2, 11272, 14, 3, 8232, // 13, 2
+13, 3, 36399, 13, 4, 11012, 14, 3, 10397, 14, 4, 7728, // 13, 3
+13, 4, 38057, 13, 5, 10630, 14, 4, 9597, 14, 5, 7252, // 13, 4
+13, 5, 39526, 13, 6, 10279, 14, 5, 8902, 14, 6, 6829, // 13, 5
+13, 6, 40688, 13, 7, 10013, 14, 6, 8344, 14, 7, 6491, // 13, 6
+13, 7, 41432, 13, 8, 9886, 14, 7, 7951, 14, 8, 6267, // 13, 7
+12, 8, 7996, 12, 9, 6284, 13, 8, 41389, 13, 9, 9867, // 13, 8
+12, 9, 8397, 12, 10, 6506, 13, 9, 40656, 13, 10, 9977, // 13, 9
+12, 10, 8966, 12, 11, 6842, 13, 10, 39503, 13, 11, 10225, // 13,10
+12, 11, 9674, 12, 12, 7261, 13, 11, 38042, 13, 12, 10559, // 13,11
+12, 12, 10488, 12, 13, 7734, 13, 12, 36392, 13, 13, 10922, // 13,12
+12, 13, 11382, 12, 14, 8232, 13, 13, 34650, 13, 14, 11272, // 13,13
+12, 14, 12334, 12, 15, 8735, 13, 14, 32886, 13, 15, 11581, // 13,14
+12, 15, 13332, 12, 16, 9229, 13, 15, 31146, 13, 16, 11829, // 13,15
+14, 0, 29828, 14, 1, 12746, 15, 0, 13291, 15, 1, 9671, // 14, 0
+14, 1, 31358, 14, 2, 12564, 15, 1, 12412, 15, 2, 9202, // 14, 1
+14, 2, 32886, 14, 3, 12334, 15, 2, 11580, 15, 3, 8736, // 14, 2
+14, 3, 34369, 14, 4, 12074, 15, 3, 10808, 15, 4, 8285, // 14, 3
+14, 4, 35750, 14, 5, 11810, 15, 4, 10111, 15, 5, 7865, // 14, 4
+14, 5, 36955, 14, 6, 11575, 15, 5, 9509, 15, 6, 7497, // 14, 5
+14, 6, 37906, 14, 7, 11407, 15, 6, 9020, 15, 7, 7203, // 14, 6
+14, 7, 38534, 14, 8, 11344, 15, 7, 8662, 15, 8, 6996, // 14, 7
+13, 8, 8718, 13, 9, 7020, 14, 8, 38481, 14, 9, 11317, // 14, 8
+13, 9, 9086, 13, 10, 7224, 14, 9, 37866, 14, 10, 11360, // 14, 9
+13, 10, 9587, 13, 11, 7517, 14, 10, 36926, 14, 11, 11506, // 14,10
+13, 11, 10204, 13, 12, 7881, 14, 11, 35730, 14, 12, 11721, // 14,11
+13, 12, 10918, 13, 13, 8296, 14, 12, 34358, 14, 13, 11964, // 14,12
+13, 13, 11709, 13, 14, 8742, 14, 13, 32881, 14, 14, 12204, // 14,13
+13, 14, 12564, 13, 15, 9202, 14, 14, 31358, 14, 15, 12412, // 14,14
+13, 15, 13470, 13, 16, 9662, 14, 15, 29831, 14, 16, 12573, // 14,15
+15, 0, 28495, 15, 1, 13569, 16, 0, 13368, 16, 1, 10104, // 15, 0
+15, 1, 29831, 15, 2, 13470, 16, 1, 12574, 16, 2, 9661, // 15, 1
+15, 2, 31146, 15, 3, 13332, 16, 2, 11829, 16, 3, 9229, // 15, 2
+15, 3, 32406, 15, 4, 13171, 16, 3, 11143, 16, 4, 8816, // 15, 3
+15, 4, 33564, 15, 5, 13007, 16, 4, 10528, 16, 5, 8437, // 15, 4
+15, 5, 34567, 15, 6, 12867, 16, 5, 9995, 16, 6, 8107, // 15, 5
+15, 6, 35362, 15, 7, 12777, 16, 6, 9558, 16, 7, 7839, // 15, 6
+15, 7, 35905, 15, 8, 12764, 16, 7, 9224, 16, 8, 7643, // 15, 7
+14, 8, 9290, 14, 9, 7674, 15, 8, 35844, 15, 9, 12728, // 15, 8
+14, 9, 9635, 14, 10, 7868, 15, 9, 35315, 15, 10, 12718, // 15, 9
+14, 10, 10086, 14, 11, 8135, 15, 10, 34532, 15, 11, 12783, // 15,10
+14, 11, 10635, 14, 12, 8463, 15, 11, 33539, 15, 12, 12899, // 15,11
+14, 12, 11269, 14, 13, 8838, 15, 12, 32391, 15, 13, 13038, // 15,12
+14, 13, 11977, 14, 14, 9245, 15, 13, 31138, 15, 14, 13176, // 15,13
+14, 14, 12746, 14, 15, 9671, 15, 14, 29828, 15, 15, 13291, // 15,14
+14, 15, 13569, 14, 16, 10104, 15, 15, 28495, 15, 16, 13368, // 15,15
+// angle of 2.5 degrees
+0, -1, 14696, 0, 0, 24063, 1, -1, 11702, 1, 0, 15075, // 0, 0
+0, 0, 14872, 0, 1, 25368, 1, 0, 11187, 1, 1, 14109, // 0, 1
+0, 1, 14990, 0, 2, 26660, 1, 1, 10676, 1, 2, 13210, // 0, 2
+0, 2, 15060, 0, 3, 27903, 1, 2, 10185, 1, 3, 12388, // 0, 3
+0, 3, 15100, 0, 4, 29055, 1, 3, 9728, 1, 4, 11653, // 0, 4
+0, 4, 15135, 0, 5, 30064, 1, 4, 9323, 1, 5, 11014, // 0, 5
+0, 5, 15193, 0, 6, 30876, 1, 5, 8986, 1, 6, 10481, // 0, 6
+0, 6, 15301, 0, 7, 31444, 1, 6, 8727, 1, 7, 10064, // 0, 7
+-1, 7, 8669, -1, 8, 9959, 0, 7, 15376, 0, 8, 31532, // 0, 8
+-1, 8, 8927, -1, 9, 10351, 0, 8, 15319, 0, 9, 30939, // 0, 9
+-1, 9, 9265, -1, 10, 10855, 0, 9, 15311, 0, 10, 30105, // 0,10
+-1, 10, 9673, -1, 11, 11461, 0, 10, 15325, 0, 11, 29077, // 0,11
+-1, 11, 10135, -1, 12, 12159, 0, 11, 15330, 0, 12, 27912, // 0,12
+-1, 12, 10637, -1, 13, 12938, 0, 12, 15301, 0, 13, 26660, // 0,13
+-1, 13, 11164, -1, 14, 13787, 0, 13, 15220, 0, 14, 25365, // 0,14
+-1, 14, 11702, -1, 15, 14696, 0, 14, 15076, 0, 15, 24062, // 0,15
+1, -1, 13787, 1, 0, 25366, 2, -1, 11164, 2, 0, 15219, // 1, 0
+1, 0, 13853, 1, 1, 26893, 2, 0, 10644, 2, 1, 14146, // 1, 1
+1, 1, 13850, 1, 2, 28427, 2, 1, 10119, 2, 2, 13140, // 1, 2
+1, 2, 13789, 1, 3, 29928, 2, 2, 9603, 2, 3, 12216, // 1, 3
+1, 3, 13694, 1, 4, 31339, 2, 3, 9118, 2, 4, 11385, // 1, 4
+1, 4, 13600, 1, 5, 32586, 2, 4, 8685, 2, 5, 10665, // 1, 5
+1, 5, 13548, 1, 6, 33585, 2, 5, 8329, 2, 6, 10074, // 1, 6
+1, 6, 13582, 1, 7, 34261, 2, 6, 8068, 2, 7, 9625, // 1, 7
+0, 7, 8024, 0, 8, 9534, 1, 7, 13638, 1, 8, 34340, // 1, 8
+0, 8, 8286, 0, 9, 9961, 1, 8, 13647, 1, 9, 33642, // 1, 9
+0, 9, 8645, 0, 10, 10528, 1, 9, 13740, 1, 10, 32623, // 1,10
+0, 10, 9082, 0, 11, 11218, 1, 10, 13875, 1, 11, 31361, // 1,11
+0, 11, 9575, 0, 12, 12014, 1, 11, 14009, 1, 12, 29938, // 1,12
+0, 12, 10102, 0, 13, 12897, 1, 12, 14107, 1, 13, 28430, // 1,13
+0, 13, 10644, 0, 14, 13853, 1, 13, 14145, 1, 14, 26894, // 1,14
+0, 14, 11187, 0, 15, 14872, 1, 14, 14109, 1, 15, 25368, // 1,15
+2, -1, 12938, 2, 0, 26660, 3, -1, 10637, 3, 0, 15301, // 2, 0
+2, 0, 12897, 2, 1, 28430, 3, 0, 10102, 3, 1, 14107, // 2, 1
+2, 1, 12769, 2, 2, 30239, 3, 1, 9546, 3, 2, 12982, // 2, 2
+2, 2, 12569, 2, 3, 32045, 3, 2, 8988, 3, 3, 11934, // 2, 3
+2, 3, 12323, 2, 4, 33777, 3, 3, 8452, 3, 4, 10984, // 2, 4
+2, 4, 12079, 2, 5, 35332, 3, 4, 7969, 3, 5, 10156, // 2, 5
+2, 5, 11897, 2, 6, 36582, 3, 5, 7573, 3, 6, 9484, // 2, 6
+2, 6, 11842, 2, 7, 37402, 3, 6, 7298, 3, 7, 8994, // 2, 7
+1, 7, 7266, 1, 8, 8918, 2, 7, 11883, 2, 8, 37469, // 2, 8
+1, 8, 7543, 1, 9, 9390, 2, 8, 11972, 2, 9, 36631, // 2, 9
+1, 9, 7943, 1, 10, 10041, 2, 9, 12188, 2, 10, 35364, // 2,10
+1, 10, 8432, 1, 11, 10842, 2, 10, 12467, 2, 11, 33795, // 2,11
+1, 11, 8976, 1, 12, 11760, 2, 11, 12747, 2, 12, 32053, // 2,12
+1, 12, 9546, 1, 13, 12769, 2, 12, 12982, 2, 13, 30239, // 2,13
+1, 13, 10119, 1, 14, 13850, 2, 13, 13141, 2, 14, 28426, // 2,14
+1, 14, 10676, 1, 15, 14990, 2, 14, 13211, 2, 15, 26659, // 2,15
+3, -1, 12159, 3, 0, 27912, 4, -1, 10135, 4, 0, 15330, // 3, 0
+3, 0, 12014, 3, 1, 29938, 4, 0, 9575, 4, 1, 14009, // 3, 1
+3, 1, 11760, 3, 2, 32052, 4, 1, 8976, 4, 2, 12748, // 3, 2
+3, 2, 11411, 3, 3, 34213, 4, 2, 8358, 4, 3, 11554, // 3, 3
+3, 3, 10995, 3, 4, 36343, 4, 3, 7746, 4, 4, 10452, // 3, 4
+3, 4, 10569, 3, 5, 38307, 4, 4, 7180, 4, 5, 9480, // 3, 5
+3, 5, 10221, 3, 6, 39912, 4, 5, 6714, 4, 6, 8689, // 3, 6
+3, 6, 10051, 3, 7, 40940, 4, 6, 6403, 4, 7, 8142, // 3, 7
+2, 7, 6381, 2, 8, 8082, 3, 7, 10079, 3, 8, 40994, // 3, 8
+2, 8, 6695, 2, 9, 8617, 3, 8, 10275, 3, 9, 39949, // 3, 9
+2, 9, 7165, 2, 10, 9388, 3, 9, 10653, 3, 10, 38330, // 3,10
+2, 10, 7737, 2, 11, 10337, 3, 10, 11108, 3, 11, 36354, // 3,11
+2, 11, 8358, 2, 12, 11411, 3, 11, 11554, 3, 12, 34213, // 3,12
+2, 12, 8988, 2, 13, 12569, 3, 12, 11934, 3, 13, 32045, // 3,13
+2, 13, 9603, 2, 14, 13789, 3, 13, 12216, 3, 14, 29928, // 3,14
+2, 14, 10185, 2, 15, 15060, 3, 14, 12388, 3, 15, 27903, // 3,15
+4, -1, 11461, 4, 0, 29078, 5, -1, 9673, 5, 0, 15324, // 4, 0
+4, 0, 11218, 4, 1, 31361, 5, 0, 9082, 5, 1, 13875, // 4, 1
+4, 1, 10842, 4, 2, 33795, 5, 1, 8432, 5, 2, 12467, // 4, 2
+4, 2, 10337, 4, 3, 36354, 5, 2, 7737, 5, 3, 11108, // 4, 3
+4, 3, 9730, 4, 4, 38966, 5, 3, 7022, 5, 4, 9818, // 4, 4
+4, 4, 9081, 4, 5, 41475, 5, 4, 6334, 5, 5, 8646, // 4, 5
+4, 5, 8507, 4, 6, 43602, 5, 5, 5749, 5, 6, 7678, // 4, 6
+4, 6, 8177, 4, 7, 44962, 5, 6, 5368, 5, 7, 7029, // 4, 7
+3, 7, 5354, 3, 8, 6987, 4, 7, 8195, 4, 8, 45000, // 4, 8
+3, 8, 5739, 3, 9, 7626, 4, 8, 8545, 4, 9, 43626, // 4, 9
+3, 9, 6328, 3, 10, 8578, 4, 9, 9143, 4, 10, 41487, // 4,10
+3, 10, 7022, 3, 11, 9730, 4, 10, 9818, 4, 11, 38966, // 4,11
+3, 11, 7746, 3, 12, 10995, 4, 11, 10452, 4, 12, 36343, // 4,12
+3, 12, 8452, 3, 13, 12323, 4, 12, 10983, 4, 13, 33778, // 4,13
+3, 13, 9118, 3, 14, 13694, 4, 13, 11385, 4, 14, 31339, // 4,14
+3, 14, 9728, 3, 15, 15100, 4, 14, 11652, 4, 15, 29056, // 4,15
+5, -1, 10855, 5, 0, 30105, 6, -1, 9265, 6, 0, 15311, // 5, 0
+5, 0, 10528, 5, 1, 32624, 6, 0, 8645, 6, 1, 13739, // 5, 1
+5, 1, 10041, 5, 2, 35364, 6, 1, 7943, 6, 2, 12188, // 5, 2
+5, 2, 9388, 5, 3, 38330, 6, 2, 7165, 6, 3, 10653, // 5, 3
+5, 3, 8578, 5, 4, 41487, 6, 3, 6328, 6, 4, 9143, // 5, 4
+5, 4, 7659, 5, 5, 44700, 6, 4, 5472, 6, 5, 7705, // 5, 5
+5, 5, 6768, 5, 6, 47619, 6, 5, 4694, 6, 6, 6455, // 5, 6
+5, 6, 6183, 5, 7, 49566, 6, 6, 4172, 6, 7, 5615, // 5, 7
+4, 7, 4164, 4, 8, 5590, 5, 7, 6193, 5, 8, 49589, // 5, 8
+4, 8, 4690, 4, 9, 6422, 5, 8, 6794, 5, 9, 47630, // 5, 9
+4, 9, 5472, 4, 10, 7659, 5, 9, 7705, 5, 10, 44700, // 5,10
+4, 10, 6334, 4, 11, 9081, 5, 10, 8646, 5, 11, 41475, // 5,11
+4, 11, 7180, 4, 12, 10569, 5, 11, 9479, 5, 12, 38308, // 5,12
+4, 12, 7969, 4, 13, 12079, 5, 12, 10156, 5, 13, 35332, // 5,13
+4, 13, 8685, 4, 14, 13600, 5, 13, 10665, 5, 14, 32586, // 5,14
+4, 14, 9323, 4, 15, 15135, 5, 14, 11013, 5, 15, 30065, // 5,15
+6, -1, 10351, 6, 0, 30939, 7, -1, 8927, 7, 0, 15319, // 6, 0
+6, 0, 9961, 6, 1, 33642, 7, 0, 8286, 7, 1, 13647, // 6, 1
+6, 1, 9390, 6, 2, 36631, 7, 1, 7543, 7, 2, 11972, // 6, 2
+6, 2, 8617, 6, 3, 39949, 7, 2, 6695, 7, 3, 10275, // 6, 3
+6, 3, 7626, 6, 4, 43626, 7, 3, 5739, 7, 4, 8545, // 6, 4
+6, 4, 6422, 6, 5, 47630, 7, 4, 4690, 7, 5, 6794, // 6, 5
+6, 5, 5099, 6, 6, 51701, 7, 5, 3620, 7, 6, 5116, // 6, 6
+6, 6, 4044, 6, 7, 54831, 7, 6, 2797, 7, 7, 3864, // 6, 7
+5, 7, 2795, 5, 8, 3853, 6, 7, 4049, 6, 8, 54839, // 6, 8
+5, 8, 3620, 5, 9, 5099, 6, 8, 5116, 6, 9, 51701, // 6, 9
+5, 9, 4694, 5, 10, 6768, 6, 9, 6455, 6, 10, 47619, // 6,10
+5, 10, 5749, 5, 11, 8507, 6, 10, 7678, 6, 11, 43602, // 6,11
+5, 11, 6714, 5, 12, 10221, 6, 11, 8690, 6, 12, 39911, // 6,12
+5, 12, 7573, 5, 13, 11897, 6, 12, 9484, 6, 13, 36582, // 6,13
+5, 13, 8329, 5, 14, 13548, 6, 13, 10074, 6, 14, 33585, // 6,14
+5, 14, 8986, 5, 15, 15193, 6, 14, 10482, 6, 15, 30875, // 6,15
+7, -1, 9959, 7, 0, 31532, 8, -1, 8669, 8, 0, 15376, // 7, 0
+7, 0, 9534, 7, 1, 34340, 8, 0, 8024, 8, 1, 13638, // 7, 1
+7, 1, 8918, 7, 2, 37470, 8, 1, 7266, 8, 2, 11882, // 7, 2
+7, 2, 8082, 7, 3, 40994, 8, 2, 6381, 8, 3, 10079, // 7, 3
+7, 3, 6987, 7, 4, 44999, 8, 3, 5354, 8, 4, 8196, // 7, 4
+7, 4, 5590, 7, 5, 49588, 8, 4, 4164, 8, 5, 6194, // 7, 5
+7, 5, 3853, 7, 6, 54839, 8, 5, 2795, 8, 6, 4049, // 7, 6
+7, 6, 1903, 7, 7, 60382, 8, 6, 1347, 8, 7, 1904, // 7, 7
+6, 7, 1347, 6, 8, 1903, 7, 7, 1905, 7, 8, 60381, // 7, 8
+6, 8, 2797, 6, 9, 4044, 7, 8, 3864, 7, 9, 54831, // 7, 9
+6, 9, 4172, 6, 10, 6183, 7, 9, 5615, 7, 10, 49566, // 7,10
+6, 10, 5368, 6, 11, 8177, 7, 10, 7029, 7, 11, 44962, // 7,11
+6, 11, 6403, 6, 12, 10051, 7, 11, 8141, 7, 12, 40941, // 7,12
+6, 12, 7298, 6, 13, 11842, 7, 12, 8994, 7, 13, 37402, // 7,13
+6, 13, 8068, 6, 14, 13582, 7, 13, 9626, 7, 14, 34260, // 7,14
+6, 14, 8727, 6, 15, 15301, 7, 14, 10065, 7, 15, 31443, // 7,15
+8, 0, 31444, 8, 1, 10065, 9, 0, 15301, 9, 1, 8726, // 8, 0
+8, 1, 34261, 8, 2, 9626, 9, 1, 13582, 9, 2, 8067, // 8, 1
+8, 2, 37402, 8, 3, 8994, 9, 2, 11842, 9, 3, 7298, // 8, 2
+8, 3, 40940, 8, 4, 8141, 9, 3, 10051, 9, 4, 6404, // 8, 3
+8, 4, 44962, 8, 5, 7029, 9, 4, 8177, 9, 5, 5368, // 8, 4
+8, 5, 49566, 8, 6, 5615, 9, 5, 6183, 9, 6, 4172, // 8, 5
+8, 6, 54831, 8, 7, 3864, 9, 6, 4044, 9, 7, 2797, // 8, 6
+8, 7, 60382, 8, 8, 1905, 9, 7, 1903, 9, 8, 1346, // 8, 7
+7, 8, 1905, 7, 9, 1347, 8, 8, 60382, 8, 9, 1902, // 8, 8
+7, 9, 4049, 7, 10, 2795, 8, 9, 54839, 8, 10, 3853, // 8, 9
+7, 10, 6193, 7, 11, 4164, 8, 10, 49588, 8, 11, 5591, // 8,10
+7, 11, 8195, 7, 12, 5354, 8, 11, 44999, 8, 12, 6988, // 8,11
+7, 12, 10079, 7, 13, 6381, 8, 12, 40994, 8, 13, 8082, // 8,12
+7, 13, 11883, 7, 14, 7266, 8, 13, 37470, 8, 14, 8917, // 8,13
+7, 14, 13638, 7, 15, 8024, 8, 14, 34340, 8, 15, 9534, // 8,14
+7, 15, 15376, 7, 16, 8669, 8, 15, 31532, 8, 16, 9959, // 8,15
+9, 0, 30876, 9, 1, 10482, 10, 0, 15193, 10, 1, 8985, // 9, 0
+9, 1, 33585, 9, 2, 10074, 10, 1, 13548, 10, 2, 8329, // 9, 1
+9, 2, 36582, 9, 3, 9484, 10, 2, 11897, 10, 3, 7573, // 9, 2
+9, 3, 39912, 9, 4, 8690, 10, 3, 10221, 10, 4, 6713, // 9, 3
+9, 4, 43602, 9, 5, 7678, 10, 4, 8507, 10, 5, 5749, // 9, 4
+9, 5, 47619, 9, 6, 6455, 10, 5, 6768, 10, 6, 4694, // 9, 5
+9, 6, 51701, 9, 7, 5116, 10, 6, 5099, 10, 7, 3620, // 9, 6
+9, 7, 54839, 9, 8, 4049, 10, 7, 3853, 10, 8, 2795, // 9, 7
+8, 8, 3864, 8, 9, 2797, 9, 8, 54831, 9, 9, 4044, // 9, 8
+8, 9, 5116, 8, 10, 3620, 9, 9, 51701, 9, 10, 5099, // 9, 9
+8, 10, 6794, 8, 11, 4690, 9, 10, 47630, 9, 11, 6422, // 9,10
+8, 11, 8545, 8, 12, 5739, 9, 11, 43626, 9, 12, 7626, // 9,11
+8, 12, 10275, 8, 13, 6695, 9, 12, 39949, 9, 13, 8617, // 9,12
+8, 13, 11972, 8, 14, 7543, 9, 13, 36631, 9, 14, 9390, // 9,13
+8, 14, 13647, 8, 15, 8286, 9, 14, 33642, 9, 15, 9961, // 9,14
+8, 15, 15319, 8, 16, 8927, 9, 15, 30939, 9, 16, 10351, // 9,15
+10, 0, 30064, 10, 1, 11013, 11, 0, 15135, 11, 1, 9324, // 10, 0
+10, 1, 32586, 10, 2, 10665, 11, 1, 13600, 11, 2, 8685, // 10, 1
+10, 2, 35332, 10, 3, 10156, 11, 2, 12079, 11, 3, 7969, // 10, 2
+10, 3, 38307, 10, 4, 9479, 11, 3, 10569, 11, 4, 7181, // 10, 3
+10, 4, 41475, 10, 5, 8646, 11, 4, 9081, 11, 5, 6334, // 10, 4
+10, 5, 44700, 10, 6, 7705, 11, 5, 7659, 11, 6, 5472, // 10, 5
+10, 6, 47630, 10, 7, 6794, 11, 6, 6422, 11, 7, 4690, // 10, 6
+10, 7, 49588, 10, 8, 6193, 11, 7, 5590, 11, 8, 4165, // 10, 7
+9, 8, 5615, 9, 9, 4172, 10, 8, 49566, 10, 9, 6183, // 10, 8
+9, 9, 6455, 9, 10, 4694, 10, 9, 47619, 10, 10, 6768, // 10, 9
+9, 10, 7705, 9, 11, 5472, 10, 10, 44700, 10, 11, 7659, // 10,10
+9, 11, 9143, 9, 12, 6328, 10, 11, 41487, 10, 12, 8578, // 10,11
+9, 12, 10653, 9, 13, 7165, 10, 12, 38330, 10, 13, 9388, // 10,12
+9, 13, 12188, 9, 14, 7943, 10, 13, 35364, 10, 14, 10041, // 10,13
+9, 14, 13740, 9, 15, 8645, 10, 14, 32624, 10, 15, 10527, // 10,14
+9, 15, 15311, 9, 16, 9265, 10, 15, 30105, 10, 16, 10855, // 10,15
+11, 0, 29055, 11, 1, 11652, 12, 0, 15100, 12, 1, 9729, // 11, 0
+11, 1, 31339, 11, 2, 11385, 12, 1, 13694, 12, 2, 9118, // 11, 1
+11, 2, 33777, 11, 3, 10983, 12, 2, 12323, 12, 3, 8453, // 11, 2
+11, 3, 36343, 11, 4, 10452, 12, 3, 10995, 12, 4, 7746, // 11, 3
+11, 4, 38966, 11, 5, 9818, 12, 4, 9730, 12, 5, 7022, // 11, 4
+11, 5, 41487, 11, 6, 9143, 12, 5, 8578, 12, 6, 6328, // 11, 5
+11, 6, 43626, 11, 7, 8545, 12, 6, 7626, 12, 7, 5739, // 11, 6
+11, 7, 44999, 11, 8, 8195, 12, 7, 6987, 12, 8, 5355, // 11, 7
+10, 8, 7029, 10, 9, 5368, 11, 8, 44962, 11, 9, 8177, // 11, 8
+10, 9, 7678, 10, 10, 5749, 11, 9, 43602, 11, 10, 8507, // 11, 9
+10, 10, 8646, 10, 11, 6334, 11, 10, 41475, 11, 11, 9081, // 11,10
+10, 11, 9818, 10, 12, 7022, 11, 11, 38966, 11, 12, 9730, // 11,11
+10, 12, 11108, 10, 13, 7737, 11, 12, 36354, 11, 13, 10337, // 11,12
+10, 13, 12467, 10, 14, 8432, 11, 13, 33795, 11, 14, 10842, // 11,13
+10, 14, 13875, 10, 15, 9082, 11, 14, 31361, 11, 15, 11218, // 11,14
+10, 15, 15325, 10, 16, 9673, 11, 15, 29078, 11, 16, 11460, // 11,15
+12, 0, 27903, 12, 1, 12388, 13, 0, 15060, 13, 1, 10185, // 12, 0
+12, 1, 29928, 12, 2, 12216, 13, 1, 13789, 13, 2, 9603, // 12, 1
+12, 2, 32045, 12, 3, 11934, 13, 2, 12569, 13, 3, 8988, // 12, 2
+12, 3, 34213, 12, 4, 11554, 13, 3, 11411, 13, 4, 8358, // 12, 3
+12, 4, 36354, 12, 5, 11108, 13, 4, 10337, 13, 5, 7737, // 12, 4
+12, 5, 38330, 12, 6, 10653, 13, 5, 9388, 13, 6, 7165, // 12, 5
+12, 6, 39949, 12, 7, 10275, 13, 6, 8617, 13, 7, 6695, // 12, 6
+12, 7, 40994, 12, 8, 10079, 13, 7, 8082, 13, 8, 6381, // 12, 7
+11, 8, 8141, 11, 9, 6403, 12, 8, 40940, 12, 9, 10052, // 12, 8
+11, 9, 8690, 11, 10, 6714, 12, 9, 39912, 12, 10, 10220, // 12, 9
+11, 10, 9479, 11, 11, 7180, 12, 10, 38307, 12, 11, 10570, // 12,10
+11, 11, 10452, 11, 12, 7746, 12, 11, 36343, 12, 12, 10995, // 12,11
+11, 12, 11554, 11, 13, 8358, 12, 12, 34213, 12, 13, 11411, // 12,12
+11, 13, 12747, 11, 14, 8976, 12, 13, 32052, 12, 14, 11761, // 12,13
+11, 14, 14009, 11, 15, 9575, 12, 14, 29938, 12, 15, 12014, // 12,14
+11, 15, 15330, 11, 16, 10135, 12, 15, 27912, 12, 16, 12159, // 12,15
+13, 0, 26660, 13, 1, 13211, 14, 0, 14990, 14, 1, 10675, // 13, 0
+13, 1, 28427, 13, 2, 13141, 14, 1, 13850, 14, 2, 10118, // 13, 1
+13, 2, 30239, 13, 3, 12982, 14, 2, 12769, 14, 3, 9546, // 13, 2
+13, 3, 32052, 13, 4, 12747, 14, 3, 11760, 14, 4, 8977, // 13, 3
+13, 4, 33795, 13, 5, 12467, 14, 4, 10842, 14, 5, 8432, // 13, 4
+13, 5, 35364, 13, 6, 12188, 14, 5, 10041, 14, 6, 7943, // 13, 5
+13, 6, 36631, 13, 7, 11972, 14, 6, 9390, 14, 7, 7543, // 13, 6
+13, 7, 37470, 13, 8, 11883, 14, 7, 8918, 14, 8, 7265, // 13, 7
+12, 8, 8994, 12, 9, 7298, 13, 8, 37402, 13, 9, 11842, // 13, 8
+12, 9, 9484, 12, 10, 7573, 13, 9, 36582, 13, 10, 11897, // 13, 9
+12, 10, 10156, 12, 11, 7969, 13, 10, 35332, 13, 11, 12079, // 13,10
+12, 11, 10983, 12, 12, 8452, 13, 11, 33777, 13, 12, 12324, // 13,11
+12, 12, 11934, 12, 13, 8988, 13, 12, 32045, 13, 13, 12569, // 13,12
+12, 13, 12982, 12, 14, 9546, 13, 13, 30239, 13, 14, 12769, // 13,13
+12, 14, 14107, 12, 15, 10102, 13, 14, 28430, 13, 15, 12897, // 13,14
+12, 15, 15301, 12, 16, 10637, 13, 15, 26660, 13, 16, 12938, // 13,15
+14, 0, 25368, 14, 1, 14109, 15, 0, 14872, 15, 1, 11187, // 14, 0
+14, 1, 26893, 14, 2, 14145, 15, 1, 13853, 15, 2, 10645, // 14, 1
+14, 2, 28430, 14, 3, 14107, 15, 2, 12897, 15, 3, 10102, // 14, 2
+14, 3, 29938, 14, 4, 14009, 15, 3, 12014, 15, 4, 9575, // 14, 3
+14, 4, 31361, 14, 5, 13875, 15, 4, 11218, 15, 5, 9082, // 14, 4
+14, 5, 32624, 14, 6, 13740, 15, 5, 10528, 15, 6, 8644, // 14, 5
+14, 6, 33642, 14, 7, 13647, 15, 6, 9961, 15, 7, 8286, // 14, 6
+14, 7, 34340, 14, 8, 13638, 15, 7, 9534, 15, 8, 8024, // 14, 7
+13, 8, 9626, 13, 9, 8068, 14, 8, 34261, 14, 9, 13581, // 14, 8
+13, 9, 10074, 13, 10, 8329, 14, 9, 33585, 14, 10, 13548, // 14, 9
+13, 10, 10665, 13, 11, 8685, 14, 10, 32586, 14, 11, 13600, // 14,10
+13, 11, 11385, 13, 12, 9118, 14, 11, 31339, 14, 12, 13694, // 14,11
+13, 12, 12216, 13, 13, 9603, 14, 12, 29928, 14, 13, 13789, // 14,12
+13, 13, 13141, 13, 14, 10119, 14, 13, 28427, 14, 14, 13849, // 14,13
+13, 14, 14145, 13, 15, 10644, 14, 14, 26893, 14, 15, 13854, // 14,14
+13, 15, 15220, 13, 16, 11164, 14, 15, 25366, 14, 16, 13786, // 14,15
+15, 0, 24063, 15, 1, 15076, 16, 0, 14696, 16, 1, 11701, // 15, 0
+15, 1, 25366, 15, 2, 15220, 16, 1, 13787, 16, 2, 11163, // 15, 1
+15, 2, 26660, 15, 3, 15301, 16, 2, 12938, 16, 3, 10637, // 15, 2
+15, 3, 27912, 15, 4, 15330, 16, 3, 12159, 16, 4, 10135, // 15, 3
+15, 4, 29078, 15, 5, 15325, 16, 4, 11461, 16, 5, 9672, // 15, 4
+15, 5, 30105, 15, 6, 15311, 16, 5, 10855, 16, 6, 9265, // 15, 5
+15, 6, 30939, 15, 7, 15319, 16, 6, 10351, 16, 7, 8927, // 15, 6
+15, 7, 31532, 15, 8, 15376, 16, 7, 9959, 16, 8, 8669, // 15, 7
+14, 8, 10065, 14, 9, 8727, 15, 8, 31444, 15, 9, 15300, // 15, 8
+14, 9, 10482, 14, 10, 8986, 15, 9, 30876, 15, 10, 15192, // 15, 9
+14, 10, 11013, 14, 11, 9323, 15, 10, 30064, 15, 11, 15136, // 15,10
+14, 11, 11652, 14, 12, 9728, 15, 11, 29055, 15, 12, 15101, // 15,11
+14, 12, 12388, 14, 13, 10185, 15, 12, 27903, 15, 13, 15060, // 15,12
+14, 13, 13211, 14, 14, 10676, 15, 13, 26660, 15, 14, 14989, // 15,13
+14, 14, 14109, 14, 15, 11187, 15, 14, 25368, 15, 15, 14872, // 15,14
+14, 15, 15076, 14, 16, 11702, 15, 15, 24063, 15, 16, 14695, // 15,15
diff --git a/vp8/common/seg_common.c b/vp8/common/seg_common.c
index 3ba374a49..b616391ba 100644
--- a/vp8/common/seg_common.c
+++ b/vp8/common/seg_common.c
@@ -12,156 +12,136 @@
const int segfeaturedata_signed[SEG_LVL_MAX] = {1, 1, 0, 0, 0, 0};
const int vp8_seg_feature_data_bits[SEG_LVL_MAX] =
- {QINDEX_BITS, 6, 4, 4, 6, 2};
+{QINDEX_BITS, 6, 4, 4, 6, 2};
// These functions provide access to new segment level features.
// Eventually these function may be "optimized out" but for the moment,
// the coding mechanism is still subject to change so these provide a
// convenient single point of change.
-int segfeature_active( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- // Return true if mask bit set and segmentation enabled.
- return ( xd->segmentation_enabled &&
- ( xd->segment_feature_mask[segment_id] &
- (0x01 << feature_id) ) );
+int segfeature_active(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ // Return true if mask bit set and segmentation enabled.
+ return (xd->segmentation_enabled &&
+ (xd->segment_feature_mask[segment_id] &
+ (0x01 << feature_id)));
}
-void clearall_segfeatures( MACROBLOCKD *xd )
-{
- vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
- vpx_memset(xd->segment_feature_mask, 0, sizeof(xd->segment_feature_mask));
+void clearall_segfeatures(MACROBLOCKD *xd) {
+ vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
+ vpx_memset(xd->segment_feature_mask, 0, sizeof(xd->segment_feature_mask));
}
-void enable_segfeature( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- xd->segment_feature_mask[segment_id] |= (0x01 << feature_id);
+void enable_segfeature(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ xd->segment_feature_mask[segment_id] |= (0x01 << feature_id);
}
-void disable_segfeature( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
+void disable_segfeature(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
}
-int seg_feature_data_bits( SEG_LVL_FEATURES feature_id )
-{
- return vp8_seg_feature_data_bits[feature_id];
+int seg_feature_data_bits(SEG_LVL_FEATURES feature_id) {
+ return vp8_seg_feature_data_bits[feature_id];
}
-int is_segfeature_signed( SEG_LVL_FEATURES feature_id )
-{
- return ( segfeaturedata_signed[feature_id] );
+int is_segfeature_signed(SEG_LVL_FEATURES feature_id) {
+ return (segfeaturedata_signed[feature_id]);
}
-void clear_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id)
-{
- xd->segment_feature_data[segment_id][feature_id] = 0;
+void clear_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ xd->segment_feature_data[segment_id][feature_id] = 0;
}
-void set_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id,
- int seg_data )
-{
- xd->segment_feature_data[segment_id][feature_id] = seg_data;
+void set_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id,
+ int seg_data) {
+ xd->segment_feature_data[segment_id][feature_id] = seg_data;
}
-int get_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- return xd->segment_feature_data[segment_id][feature_id];
+int get_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ return xd->segment_feature_data[segment_id][feature_id];
}
#if CONFIG_FEATUREUPDATES
-int old_segfeature_active( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- // Return true if mask bit set and segmentation enabled.
- return ( xd->segmentation_enabled &&
- ( xd->old_segment_feature_mask[segment_id] &
- (0x01 << feature_id) ) );
+int old_segfeature_active(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ // Return true if mask bit set and segmentation enabled.
+ return (xd->segmentation_enabled &&
+ (xd->old_segment_feature_mask[segment_id] &
+ (0x01 << feature_id)));
}
-int get_old_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- return xd->old_segment_feature_data[segment_id][feature_id];
+int get_old_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ return xd->old_segment_feature_data[segment_id][feature_id];
}
-int segfeature_changed( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id )
-{
- // Return true if mask bit or data is different from last time
- return
- ( xd->segmentation_enabled &&
- (
- (xd->old_segment_feature_mask[segment_id] & (1 << feature_id) ) !=
- (xd->segment_feature_mask[segment_id] & (1 << feature_id) )
- || xd->old_segment_feature_data[segment_id][feature_id] !=
- xd->segment_feature_data[segment_id][feature_id]
- )
- );
-}
-
-void save_segment_info ( MACROBLOCKD *xd )
-{
- int i,j;
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- {
- xd->old_segment_feature_mask[i] = xd->segment_feature_mask[i];
-
- // For each segmentation codable feature...
- for (j = 0; j < SEG_LVL_MAX; j++)
- {
- xd->old_segment_feature_data[i][j]=xd->segment_feature_data[i][j];
-
- }
+int segfeature_changed(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id) {
+ // Return true if mask bit or data is different from last time
+ return
+ (xd->segmentation_enabled &&
+ (
+ (xd->old_segment_feature_mask[segment_id] & (1 << feature_id)) !=
+ (xd->segment_feature_mask[segment_id] & (1 << feature_id))
+ || xd->old_segment_feature_data[segment_id][feature_id] !=
+ xd->segment_feature_data[segment_id][feature_id]
+ )
+ );
+}
+
+void save_segment_info(MACROBLOCKD *xd) {
+ int i, j;
+ for (i = 0; i < MAX_MB_SEGMENTS; i++) {
+ xd->old_segment_feature_mask[i] = xd->segment_feature_mask[i];
+
+ // For each segmentation codable feature...
+ for (j = 0; j < SEG_LVL_MAX; j++) {
+ xd->old_segment_feature_data[i][j] = xd->segment_feature_data[i][j];
+
}
+ }
}
#endif
-void clear_segref( MACROBLOCKD *xd, int segment_id )
-{
- xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] = 0;
+void clear_segref(MACROBLOCKD *xd, int segment_id) {
+ xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] = 0;
}
-void set_segref( MACROBLOCKD *xd,
- int segment_id,
- MV_REFERENCE_FRAME ref_frame )
-{
- xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] |=
- (1 << ref_frame);
+void set_segref(MACROBLOCKD *xd,
+ int segment_id,
+ MV_REFERENCE_FRAME ref_frame) {
+ xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] |=
+ (1 << ref_frame);
}
-int check_segref( MACROBLOCKD *xd,
- int segment_id,
- MV_REFERENCE_FRAME ref_frame )
-{
- return ( xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
- (1 << ref_frame) ) ? 1 : 0;
+int check_segref(MACROBLOCKD *xd,
+ int segment_id,
+ MV_REFERENCE_FRAME ref_frame) {
+ return (xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
+ (1 << ref_frame)) ? 1 : 0;
}
-int check_segref_inter(MACROBLOCKD *xd, int segment_id)
-{
- return ( xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
- ~(1 << INTRA_FRAME) ) ? 1 : 0;
+int check_segref_inter(MACROBLOCKD *xd, int segment_id) {
+ return (xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
+ ~(1 << INTRA_FRAME)) ? 1 : 0;
}
-int get_seg_tx_type(MACROBLOCKD *xd, int segment_id)
-{
- if ( segfeature_active(xd, segment_id, SEG_LVL_TRANSFORM) )
- return get_segdata(xd, segment_id, SEG_LVL_TRANSFORM);
- else
- return TX_4X4;
+int get_seg_tx_type(MACROBLOCKD *xd, int segment_id) {
+ if (segfeature_active(xd, segment_id, SEG_LVL_TRANSFORM))
+ return get_segdata(xd, segment_id, SEG_LVL_TRANSFORM);
+ else
+ return TX_4X4;
}
// TBD? Functions to read and write segment data with range / validity checking
diff --git a/vp8/common/seg_common.h b/vp8/common/seg_common.h
index bfd364e6d..74131926f 100644
--- a/vp8/common/seg_common.h
+++ b/vp8/common/seg_common.h
@@ -15,67 +15,67 @@
#ifndef __INC_SEG_COMMON_H__
#define __INC_SEG_COMMON_H__ 1
-int segfeature_active( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
-
-void clearall_segfeatures( MACROBLOCKD *xd );
+int segfeature_active(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-void enable_segfeature( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
+void clearall_segfeatures(MACROBLOCKD *xd);
-void disable_segfeature( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
+void enable_segfeature(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-int seg_feature_data_bits( SEG_LVL_FEATURES feature_id );
+void disable_segfeature(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-int is_segfeature_signed( SEG_LVL_FEATURES feature_id );
+int seg_feature_data_bits(SEG_LVL_FEATURES feature_id);
-void clear_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id);
+int is_segfeature_signed(SEG_LVL_FEATURES feature_id);
-void set_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id,
- int seg_data );
+void clear_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-int get_segdata( MACROBLOCKD *xd,
+void set_segdata(MACROBLOCKD *xd,
int segment_id,
- SEG_LVL_FEATURES feature_id );
+ SEG_LVL_FEATURES feature_id,
+ int seg_data);
+
+int get_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
#if CONFIG_FEATUREUPDATES
-int old_segfeature_active( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
+int old_segfeature_active(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-int get_old_segdata( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
+int get_old_segdata(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
-void save_segment_info ( MACROBLOCKD *xd );
+void save_segment_info(MACROBLOCKD *xd);
-int segfeature_changed( MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id );
+int segfeature_changed(MACROBLOCKD *xd,
+ int segment_id,
+ SEG_LVL_FEATURES feature_id);
#endif
-void clear_segref( MACROBLOCKD *xd, int segment_id );
+void clear_segref(MACROBLOCKD *xd, int segment_id);
-void set_segref( MACROBLOCKD *xd,
- int segment_id,
- MV_REFERENCE_FRAME ref_frame );
+void set_segref(MACROBLOCKD *xd,
+ int segment_id,
+ MV_REFERENCE_FRAME ref_frame);
-int check_segref( MACROBLOCKD *xd,
- int segment_id,
- MV_REFERENCE_FRAME ref_frame );
+int check_segref(MACROBLOCKD *xd,
+ int segment_id,
+ MV_REFERENCE_FRAME ref_frame);
int check_segref_inter(MACROBLOCKD *xd, int segment_id);
diff --git a/vp8/common/setupintrarecon.c b/vp8/common/setupintrarecon.c
index 7976e252b..bc6c832ca 100644
--- a/vp8/common/setupintrarecon.c
+++ b/vp8/common/setupintrarecon.c
@@ -12,21 +12,20 @@
#include "setupintrarecon.h"
#include "vpx_mem/vpx_mem.h"
-void vp8_setup_intra_recon(YV12_BUFFER_CONFIG *ybf)
-{
- int i;
+void vp8_setup_intra_recon(YV12_BUFFER_CONFIG *ybf) {
+ int i;
- /* set up frame new frame for intra coded blocks */
- vpx_memset(ybf->y_buffer - 1 - ybf->y_stride, 127, ybf->y_width + 5);
- for (i = 0; i < ybf->y_height; i++)
- ybf->y_buffer[ybf->y_stride *i - 1] = (unsigned char) 129;
+ /* set up frame new frame for intra coded blocks */
+ vpx_memset(ybf->y_buffer - 1 - ybf->y_stride, 127, ybf->y_width + 5);
+ for (i = 0; i < ybf->y_height; i++)
+ ybf->y_buffer[ybf->y_stride * i - 1] = (unsigned char) 129;
- vpx_memset(ybf->u_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
- for (i = 0; i < ybf->uv_height; i++)
- ybf->u_buffer[ybf->uv_stride *i - 1] = (unsigned char) 129;
+ vpx_memset(ybf->u_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
+ for (i = 0; i < ybf->uv_height; i++)
+ ybf->u_buffer[ybf->uv_stride * i - 1] = (unsigned char) 129;
- vpx_memset(ybf->v_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
- for (i = 0; i < ybf->uv_height; i++)
- ybf->v_buffer[ybf->uv_stride *i - 1] = (unsigned char) 129;
+ vpx_memset(ybf->v_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
+ for (i = 0; i < ybf->uv_height; i++)
+ ybf->v_buffer[ybf->uv_stride * i - 1] = (unsigned char) 129;
}
diff --git a/vp8/common/subpixel.h b/vp8/common/subpixel.h
index 1812bed03..c2dae7275 100644
--- a/vp8/common/subpixel.h
+++ b/vp8/common/subpixel.h
@@ -13,8 +13,8 @@
#define SUBPIXEL_H
#define prototype_subpixel_predict(sym) \
- void sym(unsigned char *src, int src_pitch, int xofst, int yofst, \
- unsigned char *dst, int dst_pitch)
+ void sym(unsigned char *src, int src_pitch, int xofst, int yofst, \
+ unsigned char *dst, int dst_pitch)
#if ARCH_X86 || ARCH_X86_64
#include "x86/subpixel_x86.h"
@@ -166,38 +166,37 @@ extern prototype_subpixel_predict(vp8_subpix_bilinear4x4);
extern prototype_subpixel_predict(vp8_subpix_bilinear_avg4x4);
typedef prototype_subpixel_predict((*vp8_subpix_fn_t));
-typedef struct
-{
+typedef struct {
#if CONFIG_ENHANCED_INTERP
- vp8_subpix_fn_t eighttap16x16;
- vp8_subpix_fn_t eighttap8x8;
- vp8_subpix_fn_t eighttap_avg16x16;
- vp8_subpix_fn_t eighttap_avg8x8;
- vp8_subpix_fn_t eighttap_avg4x4;
- vp8_subpix_fn_t eighttap8x4;
- vp8_subpix_fn_t eighttap4x4;
- vp8_subpix_fn_t eighttap16x16_sharp;
- vp8_subpix_fn_t eighttap8x8_sharp;
- vp8_subpix_fn_t eighttap_avg16x16_sharp;
- vp8_subpix_fn_t eighttap_avg8x8_sharp;
- vp8_subpix_fn_t eighttap_avg4x4_sharp;
- vp8_subpix_fn_t eighttap8x4_sharp;
- vp8_subpix_fn_t eighttap4x4_sharp;
-#endif
- vp8_subpix_fn_t sixtap16x16;
- vp8_subpix_fn_t sixtap8x8;
- vp8_subpix_fn_t sixtap_avg16x16;
- vp8_subpix_fn_t sixtap_avg8x8;
- vp8_subpix_fn_t sixtap8x4;
- vp8_subpix_fn_t sixtap4x4;
- vp8_subpix_fn_t sixtap_avg4x4;
- vp8_subpix_fn_t bilinear16x16;
- vp8_subpix_fn_t bilinear8x8;
- vp8_subpix_fn_t bilinear_avg16x16;
- vp8_subpix_fn_t bilinear_avg8x8;
- vp8_subpix_fn_t bilinear8x4;
- vp8_subpix_fn_t bilinear4x4;
- vp8_subpix_fn_t bilinear_avg4x4;
+ vp8_subpix_fn_t eighttap16x16;
+ vp8_subpix_fn_t eighttap8x8;
+ vp8_subpix_fn_t eighttap_avg16x16;
+ vp8_subpix_fn_t eighttap_avg8x8;
+ vp8_subpix_fn_t eighttap_avg4x4;
+ vp8_subpix_fn_t eighttap8x4;
+ vp8_subpix_fn_t eighttap4x4;
+ vp8_subpix_fn_t eighttap16x16_sharp;
+ vp8_subpix_fn_t eighttap8x8_sharp;
+ vp8_subpix_fn_t eighttap_avg16x16_sharp;
+ vp8_subpix_fn_t eighttap_avg8x8_sharp;
+ vp8_subpix_fn_t eighttap_avg4x4_sharp;
+ vp8_subpix_fn_t eighttap8x4_sharp;
+ vp8_subpix_fn_t eighttap4x4_sharp;
+#endif
+ vp8_subpix_fn_t sixtap16x16;
+ vp8_subpix_fn_t sixtap8x8;
+ vp8_subpix_fn_t sixtap_avg16x16;
+ vp8_subpix_fn_t sixtap_avg8x8;
+ vp8_subpix_fn_t sixtap8x4;
+ vp8_subpix_fn_t sixtap4x4;
+ vp8_subpix_fn_t sixtap_avg4x4;
+ vp8_subpix_fn_t bilinear16x16;
+ vp8_subpix_fn_t bilinear8x8;
+ vp8_subpix_fn_t bilinear_avg16x16;
+ vp8_subpix_fn_t bilinear_avg8x8;
+ vp8_subpix_fn_t bilinear8x4;
+ vp8_subpix_fn_t bilinear4x4;
+ vp8_subpix_fn_t bilinear_avg4x4;
} vp8_subpix_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/common/swapyv12buffer.c b/vp8/common/swapyv12buffer.c
index 73656b3d7..dec8de2a7 100644
--- a/vp8/common/swapyv12buffer.c
+++ b/vp8/common/swapyv12buffer.c
@@ -11,24 +11,23 @@
#include "swapyv12buffer.h"
-void vp8_swap_yv12_buffer(YV12_BUFFER_CONFIG *new_frame, YV12_BUFFER_CONFIG *last_frame)
-{
- unsigned char *temp;
+void vp8_swap_yv12_buffer(YV12_BUFFER_CONFIG *new_frame, YV12_BUFFER_CONFIG *last_frame) {
+ unsigned char *temp;
- temp = last_frame->buffer_alloc;
- last_frame->buffer_alloc = new_frame->buffer_alloc;
- new_frame->buffer_alloc = temp;
+ temp = last_frame->buffer_alloc;
+ last_frame->buffer_alloc = new_frame->buffer_alloc;
+ new_frame->buffer_alloc = temp;
- temp = last_frame->y_buffer;
- last_frame->y_buffer = new_frame->y_buffer;
- new_frame->y_buffer = temp;
+ temp = last_frame->y_buffer;
+ last_frame->y_buffer = new_frame->y_buffer;
+ new_frame->y_buffer = temp;
- temp = last_frame->u_buffer;
- last_frame->u_buffer = new_frame->u_buffer;
- new_frame->u_buffer = temp;
+ temp = last_frame->u_buffer;
+ last_frame->u_buffer = new_frame->u_buffer;
+ new_frame->u_buffer = temp;
- temp = last_frame->v_buffer;
- last_frame->v_buffer = new_frame->v_buffer;
- new_frame->v_buffer = temp;
+ temp = last_frame->v_buffer;
+ last_frame->v_buffer = new_frame->v_buffer;
+ new_frame->v_buffer = temp;
}
diff --git a/vp8/common/textblit.c b/vp8/common/textblit.c
index 1756100a7..2a704ea91 100644
--- a/vp8/common/textblit.c
+++ b/vp8/common/textblit.c
@@ -11,120 +11,106 @@
#include <stdlib.h>
-void vp8_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;
-
- while (msg[colpos] != 0)
- {
- char letter = msg[colpos];
- int fontcol, fontrow;
-
- if (letter <= 'Z' && letter >= ' ')
- letter_bitmap = font[letter-' '];
- else if (letter <= 'z' && letter >= 'a')
- letter_bitmap = font[letter-'a'+'A' - ' '];
- else
- letter_bitmap = font[0];
-
- for (fontcol = 6; fontcol >= 0 ; fontcol--)
- for (fontrow = 0; fontrow < 5; fontrow++)
- output_pos[fontrow *pitch + fontcol] =
- ((letter_bitmap >> (fontcol * 5)) & (1 << fontrow) ? 255 : 0);
-
- output_pos += 7;
- colpos++;
- }
+void vp8_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;
+
+ while (msg[colpos] != 0) {
+ char letter = msg[colpos];
+ int fontcol, fontrow;
+
+ if (letter <= 'Z' && letter >= ' ')
+ letter_bitmap = font[letter - ' '];
+ else if (letter <= 'z' && letter >= 'a')
+ letter_bitmap = font[letter - 'a' + 'A' - ' '];
+ else
+ letter_bitmap = font[0];
+
+ for (fontcol = 6; fontcol >= 0; fontcol--)
+ for (fontrow = 0; fontrow < 5; fontrow++)
+ output_pos[fontrow * pitch + fontcol] =
+ ((letter_bitmap >> (fontcol * 5)) & (1 << fontrow) ? 255 : 0);
+
+ output_pos += 7;
+ colpos++;
+ }
}
-static void plot (const int x, const int y, unsigned char *image, const int pitch)
-{
- image [x+y*pitch] ^= 255;
+static void plot(const int x, const int y, unsigned char *image, const int pitch) {
+ image [x + y * pitch] ^= 255;
}
/* Bresenham line algorithm */
-void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image, const int pitch)
-{
- int steep = abs(y1 - y0) > abs(x1 - x0);
- int deltax, deltay;
- int error, ystep, y, x;
-
- if (steep)
- {
- int t;
- t = x0;
- x0 = y0;
- y0 = t;
-
- t = x1;
- x1 = y1;
- y1 = t;
- }
-
- if (x0 > x1)
- {
- int t;
- t = x0;
- x0 = x1;
- x1 = t;
-
- t = y0;
- y0 = y1;
- y1 = t;
+void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image, const int pitch) {
+ int steep = abs(y1 - y0) > abs(x1 - x0);
+ int deltax, deltay;
+ int error, ystep, y, x;
+
+ if (steep) {
+ int t;
+ t = x0;
+ x0 = y0;
+ y0 = t;
+
+ t = x1;
+ x1 = y1;
+ y1 = t;
+ }
+
+ if (x0 > x1) {
+ int t;
+ t = x0;
+ x0 = x1;
+ x1 = t;
+
+ t = y0;
+ y0 = y1;
+ y1 = t;
+ }
+
+ deltax = x1 - x0;
+ deltay = abs(y1 - y0);
+ error = deltax / 2;
+
+ y = y0;
+
+ if (y0 < y1)
+ ystep = 1;
+ else
+ ystep = -1;
+
+ if (steep) {
+ for (x = x0; x <= x1; x++) {
+ plot(y, x, image, pitch);
+
+ error = error - deltay;
+ if (error < 0) {
+ y = y + ystep;
+ error = error + deltax;
+ }
}
-
- deltax = x1 - x0;
- deltay = abs(y1 - y0);
- error = deltax / 2;
-
- y = y0;
-
- if (y0 < y1)
- ystep = 1;
- else
- ystep = -1;
-
- if (steep)
- {
- for (x = x0; x <= x1; x++)
- {
- plot(y,x, image, pitch);
-
- error = error - deltay;
- if (error < 0)
- {
- y = y + ystep;
- error = error + deltax;
- }
- }
- }
- else
- {
- for (x = x0; x <= x1; x++)
- {
- plot(x,y, image, pitch);
-
- error = error - deltay;
- if (error < 0)
- {
- y = y + ystep;
- error = error + deltax;
- }
- }
+ } else {
+ for (x = x0; x <= x1; x++) {
+ plot(x, y, image, pitch);
+
+ error = error - deltay;
+ if (error < 0) {
+ y = y + ystep;
+ error = error + deltax;
+ }
}
+ }
}
diff --git a/vp8/common/treecoder.c b/vp8/common/treecoder.c
index d80c64bdf..0bb8a0d19 100644
--- a/vp8/common/treecoder.c
+++ b/vp8/common/treecoder.c
@@ -17,127 +17,108 @@
#include "treecoder.h"
static void tree2tok(
- struct vp8_token_struct *const p,
- vp8_tree t,
- int i,
- int v,
- int L
-)
-{
- v += v;
- ++L;
-
- do
- {
- const vp8_tree_index j = t[i++];
-
- if (j <= 0)
- {
- p[-j].value = v;
- p[-j].Len = L;
- }
- else
- tree2tok(p, t, j, v, L);
- }
- while (++v & 1);
+ struct vp8_token_struct *const p,
+ vp8_tree t,
+ int i,
+ int v,
+ int L
+) {
+ v += v;
+ ++L;
+
+ do {
+ const vp8_tree_index j = t[i++];
+
+ if (j <= 0) {
+ p[-j].value = v;
+ p[-j].Len = L;
+ } else
+ tree2tok(p, t, j, v, L);
+ } while (++v & 1);
}
-void vp8_tokens_from_tree(struct vp8_token_struct *p, vp8_tree t)
-{
- tree2tok(p, t, 0, 0, 0);
+void vp8_tokens_from_tree(struct vp8_token_struct *p, vp8_tree t) {
+ tree2tok(p, t, 0, 0, 0);
}
void vp8_tokens_from_tree_offset(struct vp8_token_struct *p, vp8_tree t,
- int offset)
-{
- tree2tok(p - offset, t, 0, 0, 0);
+ int offset) {
+ tree2tok(p - offset, t, 0, 0, 0);
}
static void branch_counts(
- int n, /* n = size of alphabet */
- vp8_token tok [ /* n */ ],
- vp8_tree tree,
- unsigned int branch_ct [ /* n-1 */ ] [2],
- const unsigned int num_events[ /* n */ ]
-)
-{
- const int tree_len = n - 1;
- int t = 0;
+ int n, /* n = size of alphabet */
+ vp8_token tok [ /* n */ ],
+ vp8_tree tree,
+ unsigned int branch_ct [ /* n-1 */ ] [2],
+ const unsigned int num_events[ /* n */ ]
+) {
+ const int tree_len = n - 1;
+ int t = 0;
#if CONFIG_DEBUG
- assert(tree_len);
+ assert(tree_len);
#endif
- do
- {
- branch_ct[t][0] = branch_ct[t][1] = 0;
- }
- while (++t < tree_len);
+ do {
+ branch_ct[t][0] = branch_ct[t][1] = 0;
+ } while (++t < tree_len);
- t = 0;
+ t = 0;
- do
- {
- int L = tok[t].Len;
- const int enc = tok[t].value;
- const unsigned int ct = num_events[t];
+ do {
+ int L = tok[t].Len;
+ const int enc = tok[t].value;
+ const unsigned int ct = num_events[t];
- vp8_tree_index i = 0;
+ vp8_tree_index i = 0;
- do
- {
- const int b = (enc >> --L) & 1;
- const int j = i >> 1;
+ do {
+ const int b = (enc >> --L) & 1;
+ const int j = i >> 1;
#if CONFIG_DEBUG
- assert(j < tree_len && 0 <= L);
+ assert(j < tree_len && 0 <= L);
#endif
- branch_ct [j] [b] += ct;
- i = tree[ i + b];
- }
- while (i > 0);
+ branch_ct [j] [b] += ct;
+ i = tree[ i + b];
+ } while (i > 0);
#if CONFIG_DEBUG
- assert(!L);
+ assert(!L);
#endif
- }
- while (++t < n);
+ } while (++t < n);
}
void vp8_tree_probs_from_distribution(
- int n, /* n = size of alphabet */
- vp8_token tok [ /* n */ ],
- vp8_tree tree,
- vp8_prob probs [ /* n-1 */ ],
- unsigned int branch_ct [ /* n-1 */ ] [2],
- const unsigned int num_events[ /* n */ ],
- unsigned int Pfac,
- int rd
-)
-{
- const int tree_len = n - 1;
- int t = 0;
-
- branch_counts(n, tok, tree, branch_ct, num_events);
-
- do
- {
- const unsigned int *const c = branch_ct[t];
- const unsigned int tot = c[0] + c[1];
+ int n, /* n = size of alphabet */
+ vp8_token tok [ /* n */ ],
+ vp8_tree tree,
+ vp8_prob probs [ /* n-1 */ ],
+ unsigned int branch_ct [ /* n-1 */ ] [2],
+ const unsigned int num_events[ /* n */ ],
+ unsigned int Pfac,
+ int rd
+) {
+ const int tree_len = n - 1;
+ int t = 0;
+
+ branch_counts(n, tok, tree, branch_ct, num_events);
+
+ do {
+ const unsigned int *const c = branch_ct[t];
+ const unsigned int tot = c[0] + c[1];
#if CONFIG_DEBUG
- assert(tot < (1 << 24)); /* no overflow below */
+ assert(tot < (1 << 24)); /* no overflow below */
#endif
- if (tot)
- {
- const unsigned int p = ((c[0] * Pfac) + (rd ? tot >> 1 : 0)) / tot;
- probs[t] = p < 256 ? (p ? p : 1) : 255; /* agree w/old version for now */
- }
- else
- probs[t] = vp8_prob_half;
- }
- while (++t < tree_len);
+ if (tot) {
+ const unsigned int p = ((c[0] * Pfac) + (rd ? tot >> 1 : 0)) / tot;
+ probs[t] = p < 256 ? (p ? p : 1) : 255; /* agree w/old version for now */
+ } else
+ probs[t] = vp8_prob_half;
+ } while (++t < tree_len);
}
diff --git a/vp8/common/treecoder.h b/vp8/common/treecoder.h
index ebf51c5ed..c4d0aa6ee 100644
--- a/vp8/common/treecoder.h
+++ b/vp8/common/treecoder.h
@@ -45,10 +45,9 @@ typedef const bool_reader c_bool_reader;
typedef const vp8_tree_index vp8_tree[], *vp8_tree_p;
-typedef const struct vp8_token_struct
-{
- int value;
- int Len;
+typedef const struct vp8_token_struct {
+ int value;
+ int Len;
} vp8_token;
/* Construct encoding array from tree. */
@@ -64,26 +63,26 @@ void vp8_tokens_from_tree_offset(struct vp8_token_struct *, vp8_tree,
probability updates. */
void vp8_tree_probs_from_distribution(
- int n, /* n = size of alphabet */
- vp8_token tok [ /* n */ ],
- vp8_tree tree,
- vp8_prob probs [ /* n-1 */ ],
- unsigned int branch_ct [ /* n-1 */ ] [2],
- const unsigned int num_events[ /* n */ ],
- unsigned int Pfactor,
- int Round
+ int n, /* n = size of alphabet */
+ vp8_token tok [ /* n */ ],
+ vp8_tree tree,
+ vp8_prob probs [ /* n-1 */ ],
+ unsigned int branch_ct [ /* n-1 */ ] [2],
+ const unsigned int num_events[ /* n */ ],
+ unsigned int Pfactor,
+ int Round
);
/* Variant of above using coder spec rather than hardwired 8-bit probs. */
void vp8bc_tree_probs_from_distribution(
- int n, /* n = size of alphabet */
- vp8_token tok [ /* n */ ],
- vp8_tree tree,
- vp8_prob probs [ /* n-1 */ ],
- unsigned int branch_ct [ /* n-1 */ ] [2],
- const unsigned int num_events[ /* n */ ],
- c_bool_coder_spec *s
+ int n, /* n = size of alphabet */
+ vp8_token tok [ /* n */ ],
+ vp8_tree tree,
+ vp8_prob probs [ /* n-1 */ ],
+ unsigned int branch_ct [ /* n-1 */ ] [2],
+ const unsigned int num_events[ /* n */ ],
+ c_bool_coder_spec *s
);
diff --git a/vp8/common/x86/loopfilter_x86.c b/vp8/common/x86/loopfilter_x86.c
index 9360ac17c..add888835 100644
--- a/vp8/common/x86/loopfilter_x86.c
+++ b/vp8/common/x86/loopfilter_x86.c
@@ -30,77 +30,71 @@ extern loop_filter_uvfunction vp8_mbloop_filter_vertical_edge_uv_sse2;
#if HAVE_MMX
/* Horizontal MB filtering */
void vp8_loop_filter_mbh_mmx(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_horizontal_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_horizontal_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_horizontal_edge_mmx(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_horizontal_edge_mmx(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_horizontal_edge_mmx(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_horizontal_edge_mmx(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Vertical MB Filtering */
void vp8_loop_filter_mbv_mmx(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_vertical_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_vertical_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_vertical_edge_mmx(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_mbloop_filter_vertical_edge_mmx(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_mbloop_filter_vertical_edge_mmx(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_mbloop_filter_vertical_edge_mmx(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
}
/* Horizontal B Filtering */
void vp8_loop_filter_bh_mmx(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_horizontal_edge_mmx(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_mmx(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_mmx(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_horizontal_edge_mmx(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_mmx(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_mmx(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_horizontal_edge_mmx(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_horizontal_edge_mmx(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_horizontal_edge_mmx(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_horizontal_edge_mmx(v_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
-void vp8_loop_filter_bhs_mmx(unsigned char *y_ptr, int y_stride, const unsigned char *blimit)
-{
- vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 4 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 8 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 12 * y_stride, y_stride, blimit);
+void vp8_loop_filter_bhs_mmx(unsigned char *y_ptr, int y_stride, const unsigned char *blimit) {
+ vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 4 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 8 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_mmx(y_ptr + 12 * y_stride, y_stride, blimit);
}
/* Vertical B Filtering */
void vp8_loop_filter_bv_mmx(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_vertical_edge_mmx(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_mmx(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_mmx(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_vertical_edge_mmx(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_mmx(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_mmx(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_loop_filter_vertical_edge_mmx(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (u_ptr)
+ vp8_loop_filter_vertical_edge_mmx(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
- if (v_ptr)
- vp8_loop_filter_vertical_edge_mmx(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ if (v_ptr)
+ vp8_loop_filter_vertical_edge_mmx(v_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, 1);
}
-void vp8_loop_filter_bvs_mmx(unsigned char *y_ptr, int y_stride, const unsigned char *blimit)
-{
- vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 4, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 8, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 12, y_stride, blimit);
+void vp8_loop_filter_bvs_mmx(unsigned char *y_ptr, int y_stride, const unsigned char *blimit) {
+ vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 4, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 8, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_mmx(y_ptr + 12, y_stride, blimit);
}
#endif
@@ -108,65 +102,59 @@ void vp8_loop_filter_bvs_mmx(unsigned char *y_ptr, int y_stride, const unsigned
/* Horizontal MB filtering */
#if HAVE_SSE2
void vp8_loop_filter_mbh_sse2(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_horizontal_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_horizontal_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_horizontal_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, v_ptr);
+ if (u_ptr)
+ vp8_mbloop_filter_horizontal_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, v_ptr);
}
/* Vertical MB Filtering */
void vp8_loop_filter_mbv_sse2(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_mbloop_filter_vertical_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_mbloop_filter_vertical_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
- vp8_mbloop_filter_vertical_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, v_ptr);
+ if (u_ptr)
+ vp8_mbloop_filter_vertical_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, v_ptr);
}
/* Horizontal B Filtering */
void vp8_loop_filter_bh_sse2(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_horizontal_edge_sse2(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_sse2(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_horizontal_edge_sse2(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
-
- if (u_ptr)
- vp8_loop_filter_horizontal_edge_uv_sse2(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, v_ptr + 4 * uv_stride);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_horizontal_edge_sse2(y_ptr + 4 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_sse2(y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_horizontal_edge_sse2(y_ptr + 12 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+
+ if (u_ptr)
+ vp8_loop_filter_horizontal_edge_uv_sse2(u_ptr + 4 * uv_stride, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, v_ptr + 4 * uv_stride);
}
-void vp8_loop_filter_bhs_sse2(unsigned char *y_ptr, int y_stride, const unsigned char *blimit)
-{
- vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 4 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 8 * y_stride, y_stride, blimit);
- vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 12 * y_stride, y_stride, blimit);
+void vp8_loop_filter_bhs_sse2(unsigned char *y_ptr, int y_stride, const unsigned char *blimit) {
+ vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 4 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 8 * y_stride, y_stride, blimit);
+ vp8_loop_filter_simple_horizontal_edge_sse2(y_ptr + 12 * y_stride, y_stride, blimit);
}
/* Vertical B Filtering */
void vp8_loop_filter_bv_sse2(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
- int y_stride, int uv_stride, loop_filter_info *lfi)
-{
- vp8_loop_filter_vertical_edge_sse2(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_sse2(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
- vp8_loop_filter_vertical_edge_sse2(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
-
- if (u_ptr)
- vp8_loop_filter_vertical_edge_uv_sse2(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, v_ptr + 4);
+ int y_stride, int uv_stride, loop_filter_info *lfi) {
+ vp8_loop_filter_vertical_edge_sse2(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_sse2(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+ vp8_loop_filter_vertical_edge_sse2(y_ptr + 12, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2);
+
+ if (u_ptr)
+ vp8_loop_filter_vertical_edge_uv_sse2(u_ptr + 4, uv_stride, lfi->blim, lfi->lim, lfi->hev_thr, v_ptr + 4);
}
-void vp8_loop_filter_bvs_sse2(unsigned char *y_ptr, int y_stride, const unsigned char *blimit)
-{
- vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 4, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 8, y_stride, blimit);
- vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 12, y_stride, blimit);
+void vp8_loop_filter_bvs_sse2(unsigned char *y_ptr, int y_stride, const unsigned char *blimit) {
+ vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 4, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 8, y_stride, blimit);
+ vp8_loop_filter_simple_vertical_edge_sse2(y_ptr + 12, y_stride, blimit);
}
#endif
diff --git a/vp8/common/x86/recon_wrapper_sse2.c b/vp8/common/x86/recon_wrapper_sse2.c
index cb7b69c08..57ba3fc7e 100644
--- a/vp8/common/x86/recon_wrapper_sse2.c
+++ b/vp8/common/x86/recon_wrapper_sse2.c
@@ -14,8 +14,8 @@
#include "vpx_mem/vpx_mem.h"
#define build_intra_predictors_mbuv_prototype(sym) \
- void sym(unsigned char *dst, int dst_stride, \
- const unsigned char *src, int src_stride)
+ void sym(unsigned char *dst, int dst_stride, \
+ const unsigned char *src, int src_stride)
typedef build_intra_predictors_mbuv_prototype((*build_intra_predictors_mbuv_fn_t));
extern build_intra_predictors_mbuv_prototype(vp8_intra_pred_uv_dc_mmx2);
@@ -33,64 +33,70 @@ static void vp8_build_intra_predictors_mbuv_x86(MACROBLOCKD *x,
unsigned char *dst_v,
int dst_stride,
build_intra_predictors_mbuv_fn_t tm_func,
- build_intra_predictors_mbuv_fn_t ho_func)
-{
- int mode = x->mode_info_context->mbmi.uv_mode;
- build_intra_predictors_mbuv_fn_t fn;
- int src_stride = x->dst.uv_stride;
+ build_intra_predictors_mbuv_fn_t ho_func) {
+ int mode = x->mode_info_context->mbmi.uv_mode;
+ build_intra_predictors_mbuv_fn_t fn;
+ int src_stride = x->dst.uv_stride;
- switch (mode) {
- case V_PRED: fn = vp8_intra_pred_uv_ve_mmx; break;
- case H_PRED: fn = ho_func; break;
- case TM_PRED: fn = tm_func; break;
- case DC_PRED:
- if (x->up_available) {
- if (x->left_available) {
- fn = vp8_intra_pred_uv_dc_mmx2; break;
- } else {
- fn = vp8_intra_pred_uv_dctop_mmx2; break;
- }
- } else if (x->left_available) {
- fn = vp8_intra_pred_uv_dcleft_mmx2; break;
- } else {
- fn = vp8_intra_pred_uv_dc128_mmx; break;
- }
- break;
- default: return;
- }
+ switch (mode) {
+ case V_PRED:
+ fn = vp8_intra_pred_uv_ve_mmx;
+ break;
+ case H_PRED:
+ fn = ho_func;
+ break;
+ case TM_PRED:
+ fn = tm_func;
+ break;
+ case DC_PRED:
+ if (x->up_available) {
+ if (x->left_available) {
+ fn = vp8_intra_pred_uv_dc_mmx2;
+ break;
+ } else {
+ fn = vp8_intra_pred_uv_dctop_mmx2;
+ break;
+ }
+ } else if (x->left_available) {
+ fn = vp8_intra_pred_uv_dcleft_mmx2;
+ break;
+ } else {
+ fn = vp8_intra_pred_uv_dc128_mmx;
+ break;
+ }
+ break;
+ default:
+ return;
+ }
- fn(dst_u, dst_stride, x->dst.u_buffer, src_stride);
- fn(dst_v, dst_stride, x->dst.v_buffer, src_stride);
+ fn(dst_u, dst_stride, x->dst.u_buffer, src_stride);
+ fn(dst_v, dst_stride, x->dst.v_buffer, src_stride);
}
-void vp8_build_intra_predictors_mbuv_sse2(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_x86(x, &x->predictor[256],
- &x->predictor[320], 8,
- vp8_intra_pred_uv_tm_sse2,
- vp8_intra_pred_uv_ho_mmx2);
+void vp8_build_intra_predictors_mbuv_sse2(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_x86(x, &x->predictor[256],
+ &x->predictor[320], 8,
+ vp8_intra_pred_uv_tm_sse2,
+ vp8_intra_pred_uv_ho_mmx2);
}
-void vp8_build_intra_predictors_mbuv_ssse3(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_x86(x, &x->predictor[256],
- &x->predictor[320], 8,
- vp8_intra_pred_uv_tm_ssse3,
- vp8_intra_pred_uv_ho_ssse3);
+void vp8_build_intra_predictors_mbuv_ssse3(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_x86(x, &x->predictor[256],
+ &x->predictor[320], 8,
+ vp8_intra_pred_uv_tm_ssse3,
+ vp8_intra_pred_uv_ho_ssse3);
}
-void vp8_build_intra_predictors_mbuv_s_sse2(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_x86(x, x->dst.u_buffer,
- x->dst.v_buffer, x->dst.uv_stride,
- vp8_intra_pred_uv_tm_sse2,
- vp8_intra_pred_uv_ho_mmx2);
+void vp8_build_intra_predictors_mbuv_s_sse2(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_x86(x, x->dst.u_buffer,
+ x->dst.v_buffer, x->dst.uv_stride,
+ vp8_intra_pred_uv_tm_sse2,
+ vp8_intra_pred_uv_ho_mmx2);
}
-void vp8_build_intra_predictors_mbuv_s_ssse3(MACROBLOCKD *x)
-{
- vp8_build_intra_predictors_mbuv_x86(x, x->dst.u_buffer,
- x->dst.v_buffer, x->dst.uv_stride,
- vp8_intra_pred_uv_tm_ssse3,
- vp8_intra_pred_uv_ho_ssse3);
+void vp8_build_intra_predictors_mbuv_s_ssse3(MACROBLOCKD *x) {
+ vp8_build_intra_predictors_mbuv_x86(x, x->dst.u_buffer,
+ x->dst.v_buffer, x->dst.uv_stride,
+ vp8_intra_pred_uv_tm_ssse3,
+ vp8_intra_pred_uv_ho_ssse3);
}
diff --git a/vp8/common/x86/vp8_asm_stubs.c b/vp8/common/x86/vp8_asm_stubs.c
index 458b3f638..4df4f808d 100644
--- a/vp8/common/x86/vp8_asm_stubs.c
+++ b/vp8/common/x86/vp8_asm_stubs.c
@@ -14,112 +14,112 @@
#include "vp8/common/subpixel.h"
#if CONFIG_SIXTEENTH_SUBPEL_UV
-extern const short vp8_six_tap_mmx[16][6*8];
-extern const short vp8_bilinear_filters_mmx[16][2*8];
+extern const short vp8_six_tap_mmx[16][6 * 8];
+extern const short vp8_bilinear_filters_mmx[16][2 * 8];
#else
-extern const short vp8_six_tap_mmx[8][6*8];
-extern const short vp8_bilinear_filters_mmx[8][2*8];
+extern const short vp8_six_tap_mmx[8][6 * 8];
+extern const short vp8_bilinear_filters_mmx[8][2 * 8];
#endif
-//#define ANNOUNCE_FUNCTION
+// #define ANNOUNCE_FUNCTION
extern void vp8_filter_block1d_h6_mmx
(
- unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_filter_block1dc_v6_mmx
(
- unsigned short *src_ptr,
- unsigned char *output_ptr,
- int output_pitch,
- unsigned int pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned short *src_ptr,
+ unsigned char *output_ptr,
+ int output_pitch,
+ unsigned int pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_filter_block1d8_h6_sse2
(
- unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_filter_block1d16_h6_sse2
(
- unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_filter_block1d8_v6_sse2
(
- unsigned short *src_ptr,
- unsigned char *output_ptr,
- int dst_ptich,
- unsigned int pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned short *src_ptr,
+ unsigned char *output_ptr,
+ int dst_ptich,
+ unsigned int pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_filter_block1d16_v6_sse2
(
- unsigned short *src_ptr,
- unsigned char *output_ptr,
- int dst_ptich,
- unsigned int pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
+ unsigned short *src_ptr,
+ unsigned char *output_ptr,
+ int dst_ptich,
+ unsigned int pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
);
extern void vp8_unpack_block1d16_h6_sse2
(
- unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int output_height,
- unsigned int output_width
+ unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int output_height,
+ unsigned int output_width
);
extern void vp8_filter_block1d8_h6_only_sse2
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- int dst_ptich,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ int dst_ptich,
+ unsigned int output_height,
+ const short *vp8_filter
);
extern void vp8_filter_block1d16_h6_only_sse2
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- int dst_ptich,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ int dst_ptich,
+ unsigned int output_height,
+ const short *vp8_filter
);
extern void vp8_filter_block1d8_v6_only_sse2
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- int dst_ptich,
- unsigned int output_height,
- const short *vp8_filter
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ int dst_ptich,
+ unsigned int output_height,
+ const short *vp8_filter
);
extern prototype_subpixel_predict(vp8_bilinear_predict8x8_mmx);
@@ -127,115 +127,111 @@ extern prototype_subpixel_predict(vp8_bilinear_predict8x8_mmx);
#if HAVE_MMX
void vp8_sixtap_predict4x4_mmx
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict4x4_mmx\n");
+ printf("vp8_sixtap_predict4x4_mmx\n");
#endif
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 16*16); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 8, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1dc_v6_mmx(FData2 + 8, dst_ptr, dst_pitch, 8, 4 , 4, 4, VFilter);
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 16 * 16); /* Temp data bufffer used in filtering */
+ const short *HFilter, *VFilter;
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 8, HFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1dc_v6_mmx(FData2 + 8, dst_ptr, dst_pitch, 8, 4, 4, 4, VFilter);
}
void vp8_sixtap_predict16x16_mmx
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict16x16_mmx\n");
+ printf("vp8_sixtap_predict16x16_mmx\n");
#endif
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 24*24); /* Temp data bufffer used in filtering */
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 24 * 24); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
+ const short *HFilter, *VFilter;
- HFilter = vp8_six_tap_mmx[xoffset];
+ HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 21, 32, HFilter);
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 21, 32, HFilter);
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 8, FData2 + 8, src_pixels_per_line, 1, 21, 32, HFilter);
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 12, FData2 + 12, src_pixels_per_line, 1, 21, 32, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 21, 32, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 21, 32, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 8, FData2 + 8, src_pixels_per_line, 1, 21, 32, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 12, FData2 + 12, src_pixels_per_line, 1, 21, 32, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1dc_v6_mmx(FData2 + 32, dst_ptr, dst_pitch, 32, 16 , 16, 16, VFilter);
- vp8_filter_block1dc_v6_mmx(FData2 + 36, dst_ptr + 4, dst_pitch, 32, 16 , 16, 16, VFilter);
- vp8_filter_block1dc_v6_mmx(FData2 + 40, dst_ptr + 8, dst_pitch, 32, 16 , 16, 16, VFilter);
- vp8_filter_block1dc_v6_mmx(FData2 + 44, dst_ptr + 12, dst_pitch, 32, 16 , 16, 16, VFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1dc_v6_mmx(FData2 + 32, dst_ptr, dst_pitch, 32, 16, 16, 16, VFilter);
+ vp8_filter_block1dc_v6_mmx(FData2 + 36, dst_ptr + 4, dst_pitch, 32, 16, 16, 16, VFilter);
+ vp8_filter_block1dc_v6_mmx(FData2 + 40, dst_ptr + 8, dst_pitch, 32, 16, 16, 16, VFilter);
+ vp8_filter_block1dc_v6_mmx(FData2 + 44, dst_ptr + 12, dst_pitch, 32, 16, 16, 16, VFilter);
}
void vp8_sixtap_predict8x8_mmx
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x8_mmx\n");
+ printf("vp8_sixtap_predict8x8_mmx\n");
#endif
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
+ const short *HFilter, *VFilter;
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 13, 16, HFilter);
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 13, 16, HFilter);
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 13, 16, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 13, 16, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1dc_v6_mmx(FData2 + 16, dst_ptr, dst_pitch, 16, 8 , 8, 8, VFilter);
- vp8_filter_block1dc_v6_mmx(FData2 + 20, dst_ptr + 4, dst_pitch, 16, 8 , 8, 8, VFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1dc_v6_mmx(FData2 + 16, dst_ptr, dst_pitch, 16, 8, 8, 8, VFilter);
+ vp8_filter_block1dc_v6_mmx(FData2 + 20, dst_ptr + 4, dst_pitch, 16, 8, 8, 8, VFilter);
}
void vp8_sixtap_predict8x4_mmx
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x4_mmx\n");
+ printf("vp8_sixtap_predict8x4_mmx\n");
#endif
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
+ const short *HFilter, *VFilter;
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 16, HFilter);
- vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 9, 16, HFilter);
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 16, HFilter);
+ vp8_filter_block1d_h6_mmx(src_ptr - (2 * src_pixels_per_line) + 4, FData2 + 4, src_pixels_per_line, 1, 9, 16, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1dc_v6_mmx(FData2 + 16, dst_ptr, dst_pitch, 16, 8 , 4, 8, VFilter);
- vp8_filter_block1dc_v6_mmx(FData2 + 20, dst_ptr + 4, dst_pitch, 16, 8 , 4, 8, VFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1dc_v6_mmx(FData2 + 16, dst_ptr, dst_pitch, 16, 8, 4, 8, VFilter);
+ vp8_filter_block1dc_v6_mmx(FData2 + 20, dst_ptr + 4, dst_pitch, 16, 8, 4, 8, VFilter);
}
@@ -243,18 +239,17 @@ void vp8_sixtap_predict8x4_mmx
void vp8_bilinear_predict16x16_mmx
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- vp8_bilinear_predict8x8_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pitch);
- vp8_bilinear_predict8x8_mmx(src_ptr + 8, src_pixels_per_line, xoffset, yoffset, dst_ptr + 8, dst_pitch);
- vp8_bilinear_predict8x8_mmx(src_ptr + 8 * src_pixels_per_line, src_pixels_per_line, xoffset, yoffset, dst_ptr + dst_pitch * 8, dst_pitch);
- vp8_bilinear_predict8x8_mmx(src_ptr + 8 * src_pixels_per_line + 8, src_pixels_per_line, xoffset, yoffset, dst_ptr + dst_pitch * 8 + 8, dst_pitch);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ vp8_bilinear_predict8x8_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pitch);
+ vp8_bilinear_predict8x8_mmx(src_ptr + 8, src_pixels_per_line, xoffset, yoffset, dst_ptr + 8, dst_pitch);
+ vp8_bilinear_predict8x8_mmx(src_ptr + 8 * src_pixels_per_line, src_pixels_per_line, xoffset, yoffset, dst_ptr + dst_pitch * 8, dst_pitch);
+ vp8_bilinear_predict8x8_mmx(src_ptr + 8 * src_pixels_per_line + 8, src_pixels_per_line, xoffset, yoffset, dst_ptr + dst_pitch * 8 + 8, dst_pitch);
}
#endif
@@ -262,127 +257,106 @@ void vp8_bilinear_predict16x16_mmx
#if HAVE_SSE2
void vp8_sixtap_predict16x16_sse2
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 24*24); /* Temp data bufffer used in filtering */
-
- const short *HFilter, *VFilter;
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 24 * 24); /* Temp data bufffer used in filtering */
+
+ const short *HFilter, *VFilter;
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict16x16_sse2\n");
+ printf("vp8_sixtap_predict16x16_sse2\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d16_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 21, 32, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1d16_v6_sse2(FData2 + 32, dst_ptr, dst_pitch, 32, 16 , 16, dst_pitch, VFilter);
- }
- else
- {
- /* First-pass only */
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d16_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 16, HFilter);
- }
- }
- else
- {
- /* Second-pass only */
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_unpack_block1d16_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 21, 32);
- vp8_filter_block1d16_v6_sse2(FData2 + 32, dst_ptr, dst_pitch, 32, 16 , 16, dst_pitch, VFilter);
+ if (xoffset) {
+ if (yoffset) {
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d16_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 21, 32, HFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1d16_v6_sse2(FData2 + 32, dst_ptr, dst_pitch, 32, 16, 16, dst_pitch, VFilter);
+ } else {
+ /* First-pass only */
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d16_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 16, HFilter);
}
+ } else {
+ /* Second-pass only */
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_unpack_block1d16_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 21, 32);
+ vp8_filter_block1d16_v6_sse2(FData2 + 32, dst_ptr, dst_pitch, 32, 16, 16, dst_pitch, VFilter);
+ }
}
void vp8_sixtap_predict8x8_sse2
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
+ const short *HFilter, *VFilter;
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x8_sse2\n");
+ printf("vp8_sixtap_predict8x8_sse2\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d8_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 13, 16, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1d8_v6_sse2(FData2 + 16, dst_ptr, dst_pitch, 16, 8 , 8, dst_pitch, VFilter);
- }
- else
- {
- /* First-pass only */
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d8_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 8, HFilter);
- }
- }
- else
- {
- /* Second-pass only */
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1d8_v6_only_sse2(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 8, VFilter);
+ if (xoffset) {
+ if (yoffset) {
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d8_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 13, 16, HFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1d8_v6_sse2(FData2 + 16, dst_ptr, dst_pitch, 16, 8, 8, dst_pitch, VFilter);
+ } else {
+ /* First-pass only */
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d8_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 8, HFilter);
}
+ } else {
+ /* Second-pass only */
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1d8_v6_only_sse2(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 8, VFilter);
+ }
}
void vp8_sixtap_predict8x4_sse2
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
- const short *HFilter, *VFilter;
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, FData2, 256); /* Temp data bufffer used in filtering */
+ const short *HFilter, *VFilter;
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x4_sse2\n");
+ printf("vp8_sixtap_predict8x4_sse2\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d8_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 16, HFilter);
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1d8_v6_sse2(FData2 + 16, dst_ptr, dst_pitch, 16, 8 , 4, dst_pitch, VFilter);
- }
- else
- {
- /* First-pass only */
- HFilter = vp8_six_tap_mmx[xoffset];
- vp8_filter_block1d8_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, HFilter);
- }
- }
- else
- {
- /* Second-pass only */
- VFilter = vp8_six_tap_mmx[yoffset];
- vp8_filter_block1d8_v6_only_sse2(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, VFilter);
+ if (xoffset) {
+ if (yoffset) {
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d8_h6_sse2(src_ptr - (2 * src_pixels_per_line), FData2, src_pixels_per_line, 1, 9, 16, HFilter);
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1d8_v6_sse2(FData2 + 16, dst_ptr, dst_pitch, 16, 8, 4, dst_pitch, VFilter);
+ } else {
+ /* First-pass only */
+ HFilter = vp8_six_tap_mmx[xoffset];
+ vp8_filter_block1d8_h6_only_sse2(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, HFilter);
}
+ } else {
+ /* Second-pass only */
+ VFilter = vp8_six_tap_mmx[yoffset];
+ vp8_filter_block1d8_v6_only_sse2(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, VFilter);
+ }
}
#endif
@@ -391,200 +365,172 @@ void vp8_sixtap_predict8x4_sse2
extern void vp8_filter_block1d8_h6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- unsigned int output_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ unsigned int output_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
extern void vp8_filter_block1d16_h6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- unsigned int output_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ unsigned int output_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
extern void vp8_filter_block1d16_v6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pitch,
- unsigned char *output_ptr,
- unsigned int out_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pitch,
+ unsigned char *output_ptr,
+ unsigned int out_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
extern void vp8_filter_block1d8_v6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pitch,
- unsigned char *output_ptr,
- unsigned int out_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pitch,
+ unsigned char *output_ptr,
+ unsigned int out_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
extern void vp8_filter_block1d4_h6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pixels_per_line,
- unsigned char *output_ptr,
- unsigned int output_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned char *output_ptr,
+ unsigned int output_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
extern void vp8_filter_block1d4_v6_ssse3
(
- unsigned char *src_ptr,
- unsigned int src_pitch,
- unsigned char *output_ptr,
- unsigned int out_pitch,
- unsigned int output_height,
- unsigned int vp8_filter_index
+ unsigned char *src_ptr,
+ unsigned int src_pitch,
+ unsigned char *output_ptr,
+ unsigned int out_pitch,
+ unsigned int output_height,
+ unsigned int vp8_filter_index
);
void vp8_sixtap_predict16x16_ssse3
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 24*24);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 24 * 24);
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict16x16_ssse3\n");
+ printf("vp8_sixtap_predict16x16_ssse3\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- vp8_filter_block1d16_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 16, 21, xoffset);
- vp8_filter_block1d16_v6_ssse3(FData2 , 16, dst_ptr, dst_pitch, 16, yoffset);
- }
- else
- {
- /* First-pass only */
- vp8_filter_block1d16_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 16, xoffset);
- }
- }
- else
- {
- /* Second-pass only */
- vp8_filter_block1d16_v6_ssse3(src_ptr - (2 * src_pixels_per_line) , src_pixels_per_line, dst_ptr, dst_pitch, 16, yoffset);
+ if (xoffset) {
+ if (yoffset) {
+ vp8_filter_block1d16_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 16, 21, xoffset);
+ vp8_filter_block1d16_v6_ssse3(FData2, 16, dst_ptr, dst_pitch, 16, yoffset);
+ } else {
+ /* First-pass only */
+ vp8_filter_block1d16_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 16, xoffset);
}
+ } else {
+ /* Second-pass only */
+ vp8_filter_block1d16_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 16, yoffset);
+ }
}
void vp8_sixtap_predict8x8_ssse3
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 256);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 256);
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x8_ssse3\n");
+ printf("vp8_sixtap_predict8x8_ssse3\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- vp8_filter_block1d8_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 8, 13, xoffset);
- vp8_filter_block1d8_v6_ssse3(FData2, 8, dst_ptr, dst_pitch, 8, yoffset);
- }
- else
- {
- vp8_filter_block1d8_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 8, xoffset);
- }
- }
- else
- {
- /* Second-pass only */
- vp8_filter_block1d8_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 8, yoffset);
+ if (xoffset) {
+ if (yoffset) {
+ vp8_filter_block1d8_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 8, 13, xoffset);
+ vp8_filter_block1d8_v6_ssse3(FData2, 8, dst_ptr, dst_pitch, 8, yoffset);
+ } else {
+ vp8_filter_block1d8_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 8, xoffset);
}
+ } else {
+ /* Second-pass only */
+ vp8_filter_block1d8_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 8, yoffset);
+ }
}
void vp8_sixtap_predict8x4_ssse3
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 256);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 256);
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict8x4_ssse3\n");
+ printf("vp8_sixtap_predict8x4_ssse3\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- vp8_filter_block1d8_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 8, 9, xoffset);
- vp8_filter_block1d8_v6_ssse3(FData2, 8, dst_ptr, dst_pitch, 4, yoffset);
- }
- else
- {
- /* First-pass only */
- vp8_filter_block1d8_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, xoffset);
- }
- }
- else
- {
- /* Second-pass only */
- vp8_filter_block1d8_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, yoffset);
+ if (xoffset) {
+ if (yoffset) {
+ vp8_filter_block1d8_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 8, 9, xoffset);
+ vp8_filter_block1d8_v6_ssse3(FData2, 8, dst_ptr, dst_pitch, 4, yoffset);
+ } else {
+ /* First-pass only */
+ vp8_filter_block1d8_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, xoffset);
}
+ } else {
+ /* Second-pass only */
+ vp8_filter_block1d8_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, yoffset);
+ }
}
void vp8_sixtap_predict4x4_ssse3
(
- unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- unsigned char *dst_ptr,
- int dst_pitch
-)
-{
- DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 4*9);
+ unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ unsigned char *dst_ptr,
+ int dst_pitch
+) {
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, FData2, 4 * 9);
#ifdef ANNOUNCE_FUNCTION
- printf("vp8_sixtap_predict4x4_ssse3\n");
+ printf("vp8_sixtap_predict4x4_ssse3\n");
#endif
- if (xoffset)
- {
- if (yoffset)
- {
- vp8_filter_block1d4_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 4, 9, xoffset);
- vp8_filter_block1d4_v6_ssse3(FData2, 4, dst_ptr, dst_pitch, 4, yoffset);
- }
- else
- {
- vp8_filter_block1d4_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, xoffset);
- }
- }
- else
- {
- vp8_filter_block1d4_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, yoffset);
+ if (xoffset) {
+ if (yoffset) {
+ vp8_filter_block1d4_h6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, FData2, 4, 9, xoffset);
+ vp8_filter_block1d4_v6_ssse3(FData2, 4, dst_ptr, dst_pitch, 4, yoffset);
+ } else {
+ vp8_filter_block1d4_h6_ssse3(src_ptr, src_pixels_per_line, dst_ptr, dst_pitch, 4, xoffset);
+ }
+ } else {
+ vp8_filter_block1d4_v6_ssse3(src_ptr - (2 * src_pixels_per_line), src_pixels_per_line, dst_ptr, dst_pitch, 4, yoffset);
}
}
diff --git a/vp8/common/x86/x86_systemdependent.c b/vp8/common/x86/x86_systemdependent.c
index fae8632a8..7bce3ca34 100644
--- a/vp8/common/x86/x86_systemdependent.c
+++ b/vp8/common/x86/x86_systemdependent.c
@@ -19,127 +19,123 @@
#include "vp8/common/pragmas.h"
#include "vp8/common/onyxc_int.h"
-void vp8_arch_x86_common_init(VP8_COMMON *ctx)
-{
+void vp8_arch_x86_common_init(VP8_COMMON *ctx) {
#if CONFIG_RUNTIME_CPU_DETECT
- VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
- int flags = x86_simd_caps();
+ VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
+ int flags = x86_simd_caps();
- /* Note:
- *
- * This platform can be built without runtime CPU detection as well. If
- * you modify any of the function mappings present in this file, be sure
- * to also update them in static mapings (<arch>/filename_<arch>.h)
- */
+ /* Note:
+ *
+ * This platform can be built without runtime CPU detection as well. If
+ * you modify any of the function mappings present in this file, be sure
+ * to also update them in static mapings (<arch>/filename_<arch>.h)
+ */
- /* Override default functions with fastest ones for this CPU. */
+ /* Override default functions with fastest ones for this CPU. */
#if HAVE_MMX
// The commented functions need to be re-written for vpx.
- if (flags & HAS_MMX)
- {
- rtcd->idct.idct1 = vpx_short_idct4x4llm_1_mmx;
- rtcd->idct.idct16 = vpx_short_idct4x4llm_mmx;
- rtcd->idct.idct1_scalar_add = vpx_dc_only_idct_add_mmx;
- //rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_mmx;
- //rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_mmx;
-
- rtcd->recon.recon = vp8_recon_b_mmx;
- rtcd->recon.copy8x8 = vp8_copy_mem8x8_mmx;
- rtcd->recon.copy8x4 = vp8_copy_mem8x4_mmx;
- rtcd->recon.copy16x16 = vp8_copy_mem16x16_mmx;
+ if (flags & HAS_MMX) {
+ rtcd->idct.idct1 = vpx_short_idct4x4llm_1_mmx;
+ rtcd->idct.idct16 = vpx_short_idct4x4llm_mmx;
+ rtcd->idct.idct1_scalar_add = vpx_dc_only_idct_add_mmx;
+ // rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_mmx;
+ // rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_mmx;
+
+ rtcd->recon.recon = vp8_recon_b_mmx;
+ rtcd->recon.copy8x8 = vp8_copy_mem8x8_mmx;
+ rtcd->recon.copy8x4 = vp8_copy_mem8x4_mmx;
+ rtcd->recon.copy16x16 = vp8_copy_mem16x16_mmx;
#if CONFIG_ENHANCED_INTERP == 0 && CONFIG_HIGH_PRECISION_MV == 0 && CONFIG_SIXTEENTH_SUBPEL_UV == 0
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_mmx;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_mmx;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_mmx;
- rtcd->subpix.sixtap4x4 = vp8_sixtap_predict4x4_mmx;
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_mmx;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_mmx;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_mmx;
+ rtcd->subpix.sixtap4x4 = vp8_sixtap_predict4x4_mmx;
#endif
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_mmx;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_mmx;
- rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_mmx;
- rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_mmx;
-
- rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_mmx;
- rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_mmx;
- rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_mmx;
- rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_mmx;
- rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_mmx;
- rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_mmx;
- rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_mmx;
- rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_mmx;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_mmx;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_mmx;
+ rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_mmx;
+ rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_mmx;
+
+ rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_mmx;
+ rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_mmx;
+ rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_mmx;
+ rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_mmx;
+ rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_mmx;
+ rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_mmx;
+ rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_mmx;
+ rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_mmx;
#if CONFIG_POSTPROC
- rtcd->postproc.down = vp8_mbpost_proc_down_mmx;
- /*rtcd->postproc.across = vp8_mbpost_proc_across_ip_c;*/
- rtcd->postproc.downacross = vp8_post_proc_down_and_across_mmx;
- rtcd->postproc.addnoise = vp8_plane_add_noise_mmx;
+ rtcd->postproc.down = vp8_mbpost_proc_down_mmx;
+ /*rtcd->postproc.across = vp8_mbpost_proc_across_ip_c;*/
+ rtcd->postproc.downacross = vp8_post_proc_down_and_across_mmx;
+ rtcd->postproc.addnoise = vp8_plane_add_noise_mmx;
#endif
- }
+ }
#endif
#if HAVE_SSE2
- if (flags & HAS_SSE2)
- {
- rtcd->recon.recon2 = vp8_recon2b_sse2;
- rtcd->recon.recon4 = vp8_recon4b_sse2;
- rtcd->recon.copy16x16 = vp8_copy_mem16x16_sse2;
+ if (flags & HAS_SSE2) {
+ rtcd->recon.recon2 = vp8_recon2b_sse2;
+ rtcd->recon.recon4 = vp8_recon4b_sse2;
+ rtcd->recon.copy16x16 = vp8_copy_mem16x16_sse2;
#if CONFIG_NEWINTRAMODES == 0
- rtcd->recon.build_intra_predictors_mbuv =
- vp8_build_intra_predictors_mbuv_sse2;
- rtcd->recon.build_intra_predictors_mbuv_s =
- vp8_build_intra_predictors_mbuv_s_sse2;
+ rtcd->recon.build_intra_predictors_mbuv =
+ vp8_build_intra_predictors_mbuv_sse2;
+ rtcd->recon.build_intra_predictors_mbuv_s =
+ vp8_build_intra_predictors_mbuv_s_sse2;
#endif
- //rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_sse2;
+ // rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_sse2;
#if CONFIG_ENHANCED_INTERP == 0 && CONFIG_HIGH_PRECISION_MV == 0 && CONFIG_SIXTEENTH_SUBPEL_UV == 0
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_sse2;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_sse2;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_sse2;
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_sse2;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_sse2;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_sse2;
#endif
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_sse2;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_sse2;
-
- rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_sse2;
- rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_sse2;
- rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_sse2;
- rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_sse2;
- rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_sse2;
- rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_sse2;
- rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_sse2;
- rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_sse2;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_sse2;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_sse2;
+
+ rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_sse2;
+ rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_sse2;
+ rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_sse2;
+ rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_sse2;
+ rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_sse2;
+ rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_sse2;
+ rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_sse2;
+ rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_sse2;
#if CONFIG_POSTPROC
- rtcd->postproc.down = vp8_mbpost_proc_down_xmm;
- rtcd->postproc.across = vp8_mbpost_proc_across_ip_xmm;
- rtcd->postproc.downacross = vp8_post_proc_down_and_across_xmm;
- rtcd->postproc.addnoise = vp8_plane_add_noise_wmt;
+ rtcd->postproc.down = vp8_mbpost_proc_down_xmm;
+ rtcd->postproc.across = vp8_mbpost_proc_across_ip_xmm;
+ rtcd->postproc.downacross = vp8_post_proc_down_and_across_xmm;
+ rtcd->postproc.addnoise = vp8_plane_add_noise_wmt;
#endif
- }
+ }
#endif
#if HAVE_SSSE3
- if (flags & HAS_SSSE3)
- {
+ if (flags & HAS_SSSE3) {
#if CONFIG_ENHANCED_INTERP == 0 && CONFIG_HIGH_PRECISION_MV == 0 && CONFIG_SIXTEENTH_SUBPEL_UV == 0
- rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_ssse3;
- rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_ssse3;
- rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_ssse3;
- rtcd->subpix.sixtap4x4 = vp8_sixtap_predict4x4_ssse3;
- rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_ssse3;
- rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_ssse3;
+ rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_ssse3;
+ rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_ssse3;
+ rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_ssse3;
+ rtcd->subpix.sixtap4x4 = vp8_sixtap_predict4x4_ssse3;
+ rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_ssse3;
+ rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_ssse3;
#endif
#if CONFIG_NEWINTRAMODES == 0
- rtcd->recon.build_intra_predictors_mbuv =
- vp8_build_intra_predictors_mbuv_ssse3;
- rtcd->recon.build_intra_predictors_mbuv_s =
- vp8_build_intra_predictors_mbuv_s_ssse3;
+ rtcd->recon.build_intra_predictors_mbuv =
+ vp8_build_intra_predictors_mbuv_ssse3;
+ rtcd->recon.build_intra_predictors_mbuv_s =
+ vp8_build_intra_predictors_mbuv_s_ssse3;
#endif
- }
+ }
#endif
#endif
diff --git a/vp8/decoder/arm/arm_dsystemdependent.c b/vp8/decoder/arm/arm_dsystemdependent.c
index a6e9d2447..31e8b1ab6 100644
--- a/vp8/decoder/arm/arm_dsystemdependent.c
+++ b/vp8/decoder/arm/arm_dsystemdependent.c
@@ -16,41 +16,37 @@
#include "vp8/decoder/dequantize.h"
#include "vp8/decoder/onyxd_int.h"
-void vp8_arch_arm_decode_init(VP8D_COMP *pbi)
-{
+void vp8_arch_arm_decode_init(VP8D_COMP *pbi) {
#if CONFIG_RUNTIME_CPU_DETECT
- int flags = pbi->common.rtcd.flags;
+ int flags = pbi->common.rtcd.flags;
#if HAVE_ARMV5TE
- if (flags & HAS_EDSP)
- {
- }
+ if (flags & HAS_EDSP) {
+ }
#endif
-//The commented functions need to be re-written for vpx.
+// The commented functions need to be re-written for vpx.
#if HAVE_ARMV6
- if (flags & HAS_MEDIA)
- {
- pbi->dequant.block = vp8_dequantize_b_v6;
- /*pbi->dequant.idct_add = vp8_dequant_idct_add_v6;
- pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_v6;
- pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_v6;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_v6;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_v6;*/
- }
+ if (flags & HAS_MEDIA) {
+ pbi->dequant.block = vp8_dequantize_b_v6;
+ /*pbi->dequant.idct_add = vp8_dequant_idct_add_v6;
+ pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_v6;
+ pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_v6;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_v6;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_v6;*/
+ }
#endif
#if HAVE_ARMV7
- if (flags & HAS_NEON)
- {
- pbi->dequant.block = vp8_dequantize_b_neon;
- //pbi->dequant.idct_add = vp8_dequant_idct_add_neon;
- /*This is not used: NEON always dequants two blocks at once.
- pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_neon;*/
- /*pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_neon;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_neon;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_neon;*/
- }
+ if (flags & HAS_NEON) {
+ pbi->dequant.block = vp8_dequantize_b_neon;
+ // pbi->dequant.idct_add = vp8_dequant_idct_add_neon;
+ /*This is not used: NEON always dequants two blocks at once.
+ pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_neon;*/
+ /*pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_neon;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_neon;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_neon;*/
+ }
#endif
#endif
}
diff --git a/vp8/decoder/arm/armv6/idct_blk_v6.c b/vp8/decoder/arm/armv6/idct_blk_v6.c
index 57c344698..20bb86971 100644
--- a/vp8/decoder/arm/armv6/idct_blk_v6.c
+++ b/vp8/decoder/arm/armv6/idct_blk_v6.c
@@ -13,139 +13,124 @@
#include "vp8/decoder/dequantize.h"
void vp8_dequant_dc_idct_add_y_block_v6
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (eobs[0] > 1)
- vp8_dequant_dc_idct_add_v6 (q, dq, pre, dst, 16, stride, dc[0]);
- else
- vp8_dc_only_idct_add_v6 (dc[0], pre, dst, 16, stride);
-
- if (eobs[1] > 1)
- vp8_dequant_dc_idct_add_v6 (q+16, dq, pre+4, dst+4, 16, stride, dc[1]);
- else
- vp8_dc_only_idct_add_v6 (dc[1], pre+4, dst+4, 16, stride);
-
- if (eobs[2] > 1)
- vp8_dequant_dc_idct_add_v6 (q+32, dq, pre+8, dst+8, 16, stride, dc[2]);
- else
- vp8_dc_only_idct_add_v6 (dc[2], pre+8, dst+8, 16, stride);
-
- if (eobs[3] > 1)
- vp8_dequant_dc_idct_add_v6 (q+48, dq, pre+12, dst+12, 16, stride, dc[3]);
- else
- vp8_dc_only_idct_add_v6 (dc[3], pre+12, dst+12, 16, stride);
-
- q += 64;
- dc += 4;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
- }
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (eobs[0] > 1)
+ vp8_dequant_dc_idct_add_v6(q, dq, pre, dst, 16, stride, dc[0]);
+ else
+ vp8_dc_only_idct_add_v6(dc[0], pre, dst, 16, stride);
+
+ if (eobs[1] > 1)
+ vp8_dequant_dc_idct_add_v6(q + 16, dq, pre + 4, dst + 4, 16, stride, dc[1]);
+ else
+ vp8_dc_only_idct_add_v6(dc[1], pre + 4, dst + 4, 16, stride);
+
+ if (eobs[2] > 1)
+ vp8_dequant_dc_idct_add_v6(q + 32, dq, pre + 8, dst + 8, 16, stride, dc[2]);
+ else
+ vp8_dc_only_idct_add_v6(dc[2], pre + 8, dst + 8, 16, stride);
+
+ if (eobs[3] > 1)
+ vp8_dequant_dc_idct_add_v6(q + 48, dq, pre + 12, dst + 12, 16, stride, dc[3]);
+ else
+ vp8_dc_only_idct_add_v6(dc[3], pre + 12, dst + 12, 16, stride);
+
+ q += 64;
+ dc += 4;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
}
void vp8_dequant_idct_add_y_block_v6
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (eobs[0] > 1)
- vp8_dequant_idct_add_v6 (q, dq, pre, dst, 16, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[0]*dq[0], pre, dst, 16, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vp8_dequant_idct_add_v6 (q+16, dq, pre+4, dst+4, 16, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[16]*dq[0], pre+4, dst+4, 16, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- if (eobs[2] > 1)
- vp8_dequant_idct_add_v6 (q+32, dq, pre+8, dst+8, 16, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[32]*dq[0], pre+8, dst+8, 16, stride);
- ((int *)(q+32))[0] = 0;
- }
-
- if (eobs[3] > 1)
- vp8_dequant_idct_add_v6 (q+48, dq, pre+12, dst+12, 16, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[48]*dq[0], pre+12, dst+12, 16, stride);
- ((int *)(q+48))[0] = 0;
- }
-
- q += 64;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (eobs[0] > 1)
+ vp8_dequant_idct_add_v6(q, dq, pre, dst, 16, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[0]*dq[0], pre, dst, 16, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ if (eobs[1] > 1)
+ vp8_dequant_idct_add_v6(q + 16, dq, pre + 4, dst + 4, 16, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[16]*dq[0], pre + 4, dst + 4, 16, stride);
+ ((int *)(q + 16))[0] = 0;
+ }
+
+ if (eobs[2] > 1)
+ vp8_dequant_idct_add_v6(q + 32, dq, pre + 8, dst + 8, 16, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[32]*dq[0], pre + 8, dst + 8, 16, stride);
+ ((int *)(q + 32))[0] = 0;
+ }
+
+ if (eobs[3] > 1)
+ vp8_dequant_idct_add_v6(q + 48, dq, pre + 12, dst + 12, 16, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[48]*dq[0], pre + 12, dst + 12, 16, stride);
+ ((int *)(q + 48))[0] = 0;
}
+
+ q += 64;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
}
void vp8_dequant_idct_add_uv_block_v6
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 2; i++)
- {
- if (eobs[0] > 1)
- vp8_dequant_idct_add_v6 (q, dq, pre, dstu, 8, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[0]*dq[0], pre, dstu, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vp8_dequant_idct_add_v6 (q+16, dq, pre+4, dstu+4, 8, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[16]*dq[0], pre+4, dstu+4, 8, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- q += 32;
- pre += 32;
- dstu += 4*stride;
- eobs += 2;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ if (eobs[0] > 1)
+ vp8_dequant_idct_add_v6(q, dq, pre, dstu, 8, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[0]*dq[0], pre, dstu, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ if (eobs[1] > 1)
+ vp8_dequant_idct_add_v6(q + 16, dq, pre + 4, dstu + 4, 8, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[16]*dq[0], pre + 4, dstu + 4, 8, stride);
+ ((int *)(q + 16))[0] = 0;
}
- for (i = 0; i < 2; i++)
- {
- if (eobs[0] > 1)
- vp8_dequant_idct_add_v6 (q, dq, pre, dstv, 8, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[0]*dq[0], pre, dstv, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vp8_dequant_idct_add_v6 (q+16, dq, pre+4, dstv+4, 8, stride);
- else
- {
- vp8_dc_only_idct_add_v6 (q[16]*dq[0], pre+4, dstv+4, 8, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- q += 32;
- pre += 32;
- dstv += 4*stride;
- eobs += 2;
+ q += 32;
+ pre += 32;
+ dstu += 4 * stride;
+ eobs += 2;
+ }
+
+ for (i = 0; i < 2; i++) {
+ if (eobs[0] > 1)
+ vp8_dequant_idct_add_v6(q, dq, pre, dstv, 8, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[0]*dq[0], pre, dstv, 8, stride);
+ ((int *)q)[0] = 0;
}
+
+ if (eobs[1] > 1)
+ vp8_dequant_idct_add_v6(q + 16, dq, pre + 4, dstv + 4, 8, stride);
+ else {
+ vp8_dc_only_idct_add_v6(q[16]*dq[0], pre + 4, dstv + 4, 8, stride);
+ ((int *)(q + 16))[0] = 0;
+ }
+
+ q += 32;
+ pre += 32;
+ dstv += 4 * stride;
+ eobs += 2;
+ }
}
diff --git a/vp8/decoder/arm/dequantize_arm.c b/vp8/decoder/arm/dequantize_arm.c
index 98db6eeff..0a0045a7a 100644
--- a/vp8/decoder/arm/dequantize_arm.c
+++ b/vp8/decoder/arm/dequantize_arm.c
@@ -24,23 +24,21 @@ extern void vp8_dequantize_b_loop_v6(short *Q, short *DQC, short *DQ);
#if HAVE_ARMV7
-void vp8_dequantize_b_neon(BLOCKD *d)
-{
- short *DQ = d->dqcoeff;
- short *Q = d->qcoeff;
- short *DQC = d->dequant;
+void vp8_dequantize_b_neon(BLOCKD *d) {
+ short *DQ = d->dqcoeff;
+ short *Q = d->qcoeff;
+ short *DQC = d->dequant;
- vp8_dequantize_b_loop_neon(Q, DQC, DQ);
+ vp8_dequantize_b_loop_neon(Q, DQC, DQ);
}
#endif
#if HAVE_ARMV6
-void vp8_dequantize_b_v6(BLOCKD *d)
-{
- short *DQ = d->dqcoeff;
- short *Q = d->qcoeff;
- short *DQC = d->dequant;
+void vp8_dequantize_b_v6(BLOCKD *d) {
+ short *DQ = d->dqcoeff;
+ short *Q = d->qcoeff;
+ short *DQC = d->dequant;
- vp8_dequantize_b_loop_v6(Q, DQC, DQ);
+ vp8_dequantize_b_loop_v6(Q, DQC, DQ);
}
#endif
diff --git a/vp8/decoder/arm/neon/idct_blk_neon.c b/vp8/decoder/arm/neon/idct_blk_neon.c
index ee3500425..2e494f0b9 100644
--- a/vp8/decoder/arm/neon/idct_blk_neon.c
+++ b/vp8/decoder/arm/neon/idct_blk_neon.c
@@ -16,100 +16,95 @@
* outside of this scope
*/
void idct_dequant_dc_full_2x_neon
- (short *input, short *dq, unsigned char *pre, unsigned char *dst,
- int stride, short *dc);
+(short *input, short *dq, unsigned char *pre, unsigned char *dst,
+ int stride, short *dc);
void idct_dequant_dc_0_2x_neon
- (short *dc, unsigned char *pre, unsigned char *dst, int stride);
+(short *dc, unsigned char *pre, unsigned char *dst, int stride);
void idct_dequant_full_2x_neon
- (short *q, short *dq, unsigned char *pre, unsigned char *dst,
- int pitch, int stride);
+(short *q, short *dq, unsigned char *pre, unsigned char *dst,
+ int pitch, int stride);
void idct_dequant_0_2x_neon
- (short *q, short dq, unsigned char *pre, int pitch,
- unsigned char *dst, int stride);
+(short *q, short dq, unsigned char *pre, int pitch,
+ unsigned char *dst, int stride);
void vp8_dequant_dc_idct_add_y_block_neon
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (((short *)eobs)[0] & 0xfefe)
- idct_dequant_dc_full_2x_neon (q, dq, pre, dst, stride, dc);
- else
- idct_dequant_dc_0_2x_neon(dc, pre, dst, stride);
-
- if (((short *)eobs)[1] & 0xfefe)
- idct_dequant_dc_full_2x_neon (q+32, dq, pre+8, dst+8, stride, dc+2);
- else
- idct_dequant_dc_0_2x_neon(dc+2, pre+8, dst+8, stride);
-
- q += 64;
- dc += 4;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
- }
-}
-
-void vp8_dequant_idct_add_y_block_neon
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (((short *)eobs)[0] & 0xfefe)
- idct_dequant_full_2x_neon (q, dq, pre, dst, 16, stride);
- else
- idct_dequant_0_2x_neon (q, dq[0], pre, 16, dst, stride);
-
- if (((short *)eobs)[1] & 0xfefe)
- idct_dequant_full_2x_neon (q+32, dq, pre+8, dst+8, 16, stride);
- else
- idct_dequant_0_2x_neon (q+32, dq[0], pre+8, 16, dst+8, stride);
-
- q += 64;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
- }
-}
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i;
-void vp8_dequant_idct_add_uv_block_neon
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
+ for (i = 0; i < 4; i++) {
if (((short *)eobs)[0] & 0xfefe)
- idct_dequant_full_2x_neon (q, dq, pre, dstu, 8, stride);
+ idct_dequant_dc_full_2x_neon(q, dq, pre, dst, stride, dc);
else
- idct_dequant_0_2x_neon (q, dq[0], pre, 8, dstu, stride);
-
- q += 32;
- pre += 32;
- dstu += 4*stride;
+ idct_dequant_dc_0_2x_neon(dc, pre, dst, stride);
if (((short *)eobs)[1] & 0xfefe)
- idct_dequant_full_2x_neon (q, dq, pre, dstu, 8, stride);
+ idct_dequant_dc_full_2x_neon(q + 32, dq, pre + 8, dst + 8, stride, dc + 2);
else
- idct_dequant_0_2x_neon (q, dq[0], pre, 8, dstu, stride);
+ idct_dequant_dc_0_2x_neon(dc + 2, pre + 8, dst + 8, stride);
+
+ q += 64;
+ dc += 4;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
+}
- q += 32;
- pre += 32;
+void vp8_dequant_idct_add_y_block_neon
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i;
- if (((short *)eobs)[2] & 0xfefe)
- idct_dequant_full_2x_neon (q, dq, pre, dstv, 8, stride);
+ for (i = 0; i < 4; i++) {
+ if (((short *)eobs)[0] & 0xfefe)
+ idct_dequant_full_2x_neon(q, dq, pre, dst, 16, stride);
else
- idct_dequant_0_2x_neon (q, dq[0], pre, 8, dstv, stride);
-
- q += 32;
- pre += 32;
- dstv += 4*stride;
+ idct_dequant_0_2x_neon(q, dq[0], pre, 16, dst, stride);
- if (((short *)eobs)[3] & 0xfefe)
- idct_dequant_full_2x_neon (q, dq, pre, dstv, 8, stride);
+ if (((short *)eobs)[1] & 0xfefe)
+ idct_dequant_full_2x_neon(q + 32, dq, pre + 8, dst + 8, 16, stride);
else
- idct_dequant_0_2x_neon (q, dq[0], pre, 8, dstv, stride);
+ idct_dequant_0_2x_neon(q + 32, dq[0], pre + 8, 16, dst + 8, stride);
+
+ q += 64;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
+}
+
+void vp8_dequant_idct_add_uv_block_neon
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ if (((short *)eobs)[0] & 0xfefe)
+ idct_dequant_full_2x_neon(q, dq, pre, dstu, 8, stride);
+ else
+ idct_dequant_0_2x_neon(q, dq[0], pre, 8, dstu, stride);
+
+ q += 32;
+ pre += 32;
+ dstu += 4 * stride;
+
+ if (((short *)eobs)[1] & 0xfefe)
+ idct_dequant_full_2x_neon(q, dq, pre, dstu, 8, stride);
+ else
+ idct_dequant_0_2x_neon(q, dq[0], pre, 8, dstu, stride);
+
+ q += 32;
+ pre += 32;
+
+ if (((short *)eobs)[2] & 0xfefe)
+ idct_dequant_full_2x_neon(q, dq, pre, dstv, 8, stride);
+ else
+ idct_dequant_0_2x_neon(q, dq[0], pre, 8, dstv, stride);
+
+ q += 32;
+ pre += 32;
+ dstv += 4 * stride;
+
+ if (((short *)eobs)[3] & 0xfefe)
+ idct_dequant_full_2x_neon(q, dq, pre, dstv, 8, stride);
+ else
+ idct_dequant_0_2x_neon(q, dq[0], pre, 8, dstv, stride);
}
diff --git a/vp8/decoder/dboolhuff.c b/vp8/decoder/dboolhuff.c
index fc57ebceb..fcb76f34b 100644
--- a/vp8/decoder/dboolhuff.c
+++ b/vp8/decoder/dboolhuff.c
@@ -15,102 +15,88 @@
int vp8dx_start_decode(BOOL_DECODER *br,
const unsigned char *source,
- unsigned int source_sz)
-{
- br->user_buffer_end = source+source_sz;
- br->user_buffer = source;
- br->value = 0;
- br->count = -8;
- br->range = 255;
+ unsigned int source_sz) {
+ br->user_buffer_end = source + source_sz;
+ br->user_buffer = source;
+ br->value = 0;
+ br->count = -8;
+ br->range = 255;
- if (source_sz && !source)
- return 1;
+ if (source_sz && !source)
+ return 1;
- /* Populate the buffer */
- vp8dx_bool_decoder_fill(br);
+ /* Populate the buffer */
+ vp8dx_bool_decoder_fill(br);
- return 0;
+ return 0;
}
-void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
-{
- const unsigned char *bufptr;
- const unsigned char *bufend;
- VP8_BD_VALUE value;
- int count;
- bufend = br->user_buffer_end;
- bufptr = br->user_buffer;
- value = br->value;
- count = br->count;
+void vp8dx_bool_decoder_fill(BOOL_DECODER *br) {
+ const unsigned char *bufptr;
+ const unsigned char *bufend;
+ VP8_BD_VALUE value;
+ int count;
+ bufend = br->user_buffer_end;
+ bufptr = br->user_buffer;
+ value = br->value;
+ count = br->count;
- VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend);
+ VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend);
- br->user_buffer = bufptr;
- br->value = value;
- br->count = count;
+ br->user_buffer = bufptr;
+ br->value = value;
+ br->count = count;
}
#if CONFIG_NEWUPDATE
-static int get_unsigned_bits(unsigned num_values)
-{
- int cat=0;
- if ((num_values--)<=1) return 0;
- while (num_values>0)
- {
- cat++;
- num_values>>=1;
- }
- return cat;
+static int get_unsigned_bits(unsigned num_values) {
+ int cat = 0;
+ if ((num_values--) <= 1) return 0;
+ while (num_values > 0) {
+ cat++;
+ num_values >>= 1;
+ }
+ return cat;
}
-int 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);
+int 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);
}
-int vp8_decode_uniform(BOOL_DECODER *br, int n)
-{
- int v;
- int l=get_unsigned_bits(n);
- int m=(1<<l)-n;
- if (!l) return 0;
- v = vp8_decode_value(br, l-1);
- if (v < m)
- return v;
- else
- return (v<<1)-m+vp8_decode_value(br, 1);
+int vp8_decode_uniform(BOOL_DECODER *br, int n) {
+ int v;
+ int l = get_unsigned_bits(n);
+ int m = (1 << l) - n;
+ if (!l) return 0;
+ v = vp8_decode_value(br, l - 1);
+ if (v < m)
+ return v;
+ else
+ return (v << 1) - m + vp8_decode_value(br, 1);
}
-int vp8_decode_term_subexp(BOOL_DECODER *br, int k, int num_syms)
-{
- int i=0, mk=0, word;
- while (1)
- {
- int b = (i?k+i-1:k);
- int a = (1<<b);
- if (num_syms<=mk+3*a)
- {
- word = vp8_decode_uniform(br, num_syms-mk) + mk;
- break;
- }
- else
- {
- if (vp8_decode_value(br, 1))
- {
- i++;
- mk += a;
- }
- else
- {
- word = vp8_decode_value(br, b) + mk;
- break;
- }
- }
+int vp8_decode_term_subexp(BOOL_DECODER *br, int k, int num_syms) {
+ int i = 0, mk = 0, word;
+ while (1) {
+ int b = (i ? k + i - 1 : k);
+ int a = (1 << b);
+ if (num_syms <= mk + 3 * a) {
+ word = vp8_decode_uniform(br, num_syms - mk) + mk;
+ break;
+ } else {
+ if (vp8_decode_value(br, 1)) {
+ i++;
+ mk += a;
+ } else {
+ word = vp8_decode_value(br, b) + mk;
+ break;
+ }
}
- return word;
+ }
+ return word;
}
#endif
diff --git a/vp8/decoder/dboolhuff.h b/vp8/decoder/dboolhuff.h
index 5f0cecd6b..b3ff45d01 100644
--- a/vp8/decoder/dboolhuff.h
+++ b/vp8/decoder/dboolhuff.h
@@ -25,13 +25,12 @@ typedef size_t VP8_BD_VALUE;
Even relatively modest values like 100 would work fine.*/
# define VP8_LOTS_OF_BITS (0x40000000)
-typedef struct
-{
- const unsigned char *user_buffer_end;
- const unsigned char *user_buffer;
- VP8_BD_VALUE value;
- int count;
- unsigned int range;
+typedef struct {
+ const unsigned char *user_buffer_end;
+ const unsigned char *user_buffer;
+ VP8_BD_VALUE value;
+ int count;
+ unsigned int range;
} BOOL_DECODER;
DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
@@ -55,107 +54,102 @@ int inv_recenter_nonneg(int v, int m);
enough to eliminate the stores to those fields and the subsequent reloads
from them when inlining the function.*/
#define VP8DX_BOOL_DECODER_FILL(_count,_value,_bufptr,_bufend) \
- do \
+ do \
+ { \
+ int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \
+ int loop_end, x; \
+ size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \
+ \
+ x = shift + CHAR_BIT - bits_left; \
+ loop_end = 0; \
+ if(x >= 0) \
{ \
- int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \
- int loop_end, x; \
- size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \
- \
- x = shift + CHAR_BIT - bits_left; \
- loop_end = 0; \
- if(x >= 0) \
- { \
- (_count) += VP8_LOTS_OF_BITS; \
- loop_end = x; \
- if(!bits_left) break; \
- } \
- while(shift >= loop_end) \
- { \
- (_count) += CHAR_BIT; \
- (_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \
- shift -= CHAR_BIT; \
- } \
+ (_count) += VP8_LOTS_OF_BITS; \
+ loop_end = x; \
+ if(!bits_left) break; \
} \
- while(0) \
+ while(shift >= loop_end) \
+ { \
+ (_count) += CHAR_BIT; \
+ (_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \
+ shift -= CHAR_BIT; \
+ } \
+ } \
+ while(0) \
static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
- unsigned int bit = 0;
- VP8_BD_VALUE value;
- unsigned int split;
- VP8_BD_VALUE bigsplit;
- int count;
- unsigned int range;
-
- split = 1 + (((br->range - 1) * probability) >> 8);
-
- if(br->count < 0)
- vp8dx_bool_decoder_fill(br);
-
- value = br->value;
- count = br->count;
-
- bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
-
- range = split;
-
- if (value >= bigsplit)
- {
- range = br->range - split;
- value = value - bigsplit;
- bit = 1;
- }
-
- {
- register unsigned int shift = vp8_norm[range];
- range <<= shift;
- value <<= shift;
- count -= shift;
- }
- br->value = value;
- br->count = count;
- br->range = range;
-
- return bit;
+ unsigned int bit = 0;
+ VP8_BD_VALUE value;
+ unsigned int split;
+ VP8_BD_VALUE bigsplit;
+ int count;
+ unsigned int range;
+
+ split = 1 + (((br->range - 1) * probability) >> 8);
+
+ if (br->count < 0)
+ vp8dx_bool_decoder_fill(br);
+
+ value = br->value;
+ count = br->count;
+
+ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
+
+ range = split;
+
+ if (value >= bigsplit) {
+ range = br->range - split;
+ value = value - bigsplit;
+ bit = 1;
+ }
+
+ {
+ register unsigned int shift = vp8_norm[range];
+ range <<= shift;
+ value <<= shift;
+ count -= shift;
+ }
+ br->value = value;
+ br->count = count;
+ br->range = range;
+
+ return bit;
}
-static int vp8_decode_value(BOOL_DECODER *br, int bits)
-{
- int z = 0;
- int bit;
+static int vp8_decode_value(BOOL_DECODER *br, int bits) {
+ int z = 0;
+ int bit;
- for (bit = bits - 1; bit >= 0; bit--)
- {
- z |= (vp8dx_decode_bool(br, 0x80) << bit);
- }
+ for (bit = bits - 1; bit >= 0; bit--) {
+ z |= (vp8dx_decode_bool(br, 0x80) << bit);
+ }
- return z;
+ return z;
}
-static int vp8dx_bool_error(BOOL_DECODER *br)
-{
- /* Check if we have reached the end of the buffer.
- *
- * Variable 'count' stores the number of bits in the 'value' buffer, minus
- * 8. The top byte is part of the algorithm, and the remainder is buffered
- * to be shifted into it. So if count == 8, the top 16 bits of 'value' are
- * occupied, 8 for the algorithm and 8 in the buffer.
- *
- * When reading a byte from the user's buffer, count is filled with 8 and
- * one byte is filled into the value buffer. When we reach the end of the
- * data, count is additionally filled with VP8_LOTS_OF_BITS. So when
- * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted.
+static int vp8dx_bool_error(BOOL_DECODER *br) {
+ /* Check if we have reached the end of the buffer.
+ *
+ * Variable 'count' stores the number of bits in the 'value' buffer, minus
+ * 8. The top byte is part of the algorithm, and the remainder is buffered
+ * to be shifted into it. So if count == 8, the top 16 bits of 'value' are
+ * occupied, 8 for the algorithm and 8 in the buffer.
+ *
+ * When reading a byte from the user's buffer, count is filled with 8 and
+ * one byte is filled into the value buffer. When we reach the end of the
+ * data, count is additionally filled with VP8_LOTS_OF_BITS. So when
+ * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted.
+ */
+ if ((br->count > VP8_BD_VALUE_SIZE) && (br->count < VP8_LOTS_OF_BITS)) {
+ /* We have tried to decode bits after the end of
+ * stream was encountered.
*/
- if ((br->count > VP8_BD_VALUE_SIZE) && (br->count < VP8_LOTS_OF_BITS))
- {
- /* We have tried to decode bits after the end of
- * stream was encountered.
- */
- return 1;
- }
-
- /* No error. */
- return 0;
+ return 1;
+ }
+
+ /* No error. */
+ return 0;
}
#endif
diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c
index 1243b359c..c31ba7379 100644
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -23,1170 +23,1035 @@
#include <assert.h>
#endif
-//#define DEBUG_DEC_MV
+// #define DEBUG_DEC_MV
#ifdef DEBUG_DEC_MV
int dec_mvcount = 0;
#endif
-static int vp8_read_bmode(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_bmode_tree, p);
+static int vp8_read_bmode(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_bmode_tree, p);
- return i;
+ return i;
}
-static int vp8_read_ymode(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_ymode_tree, p);
+static int vp8_read_ymode(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_ymode_tree, p);
- return i;
+ return i;
}
-static int vp8_kfread_ymode(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_kf_ymode_tree, p);
+static int vp8_kfread_ymode(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_kf_ymode_tree, p);
- return i;
+ return i;
}
-static int vp8_read_i8x8_mode(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_i8x8_mode_tree, p);
+static int vp8_read_i8x8_mode(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_i8x8_mode_tree, p);
- return i;
+ return i;
}
-static int vp8_read_uv_mode(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_uv_mode_tree, p);
+static int vp8_read_uv_mode(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_uv_mode_tree, p);
- return i;
+ return i;
}
// This function reads the current macro block's segnent id from the bitstream
// It should only be called if a segment map update is indicated.
-static void vp8_read_mb_segid(vp8_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *x)
-{
- /* Is segmentation enabled */
- if (x->segmentation_enabled && x->update_mb_segmentation_map)
- {
- /* If so then read the segment id. */
- if (vp8_read(r, x->mb_segment_tree_probs[0]))
- mi->segment_id = (unsigned char)(2 + vp8_read(r, x->mb_segment_tree_probs[2]));
- else
- mi->segment_id = (unsigned char)(vp8_read(r, x->mb_segment_tree_probs[1]));
- }
+static void vp8_read_mb_segid(vp8_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *x) {
+ /* Is segmentation enabled */
+ if (x->segmentation_enabled && x->update_mb_segmentation_map) {
+ /* If so then read the segment id. */
+ if (vp8_read(r, x->mb_segment_tree_probs[0]))
+ mi->segment_id = (unsigned char)(2 + vp8_read(r, x->mb_segment_tree_probs[2]));
+ else
+ mi->segment_id = (unsigned char)(vp8_read(r, x->mb_segment_tree_probs[1]));
+ }
}
extern const int vp8_i8x8_block[4];
static void vp8_kfread_modes(VP8D_COMP *pbi,
MODE_INFO *m,
int mb_row,
- int mb_col)
-{
- VP8_COMMON *const cm = & pbi->common;
- vp8_reader *const bc = & pbi->bc;
- const int mis = pbi->common.mode_info_stride;
- int map_index = mb_row * pbi->common.mb_cols + mb_col;
- MB_PREDICTION_MODE y_mode;
-
- // Read the Macroblock segmentation map if it is being updated explicitly
- // this frame (reset to 0 by default).
- m->mbmi.segment_id = 0;
- if (pbi->mb.update_mb_segmentation_map)
- {
- vp8_read_mb_segid(bc, &m->mbmi, &pbi->mb);
- pbi->common.last_frame_seg_map[map_index] = m->mbmi.segment_id;
- }
-
- m->mbmi.mb_skip_coeff = 0;
- if ( pbi->common.mb_no_coeff_skip &&
- ( !segfeature_active( &pbi->mb,
- m->mbmi.segment_id, SEG_LVL_EOB ) ||
- ( get_segdata( &pbi->mb,
- m->mbmi.segment_id, SEG_LVL_EOB ) != 0 ) ) )
- {
+ int mb_col) {
+ VP8_COMMON *const cm = & pbi->common;
+ vp8_reader *const bc = & pbi->bc;
+ const int mis = pbi->common.mode_info_stride;
+ int map_index = mb_row * pbi->common.mb_cols + mb_col;
+ MB_PREDICTION_MODE y_mode;
+
+ // Read the Macroblock segmentation map if it is being updated explicitly
+ // this frame (reset to 0 by default).
+ m->mbmi.segment_id = 0;
+ if (pbi->mb.update_mb_segmentation_map) {
+ vp8_read_mb_segid(bc, &m->mbmi, &pbi->mb);
+ pbi->common.last_frame_seg_map[map_index] = m->mbmi.segment_id;
+ }
+
+ m->mbmi.mb_skip_coeff = 0;
+ if (pbi->common.mb_no_coeff_skip &&
+ (!segfeature_active(&pbi->mb,
+ m->mbmi.segment_id, SEG_LVL_EOB) ||
+ (get_segdata(&pbi->mb,
+ m->mbmi.segment_id, SEG_LVL_EOB) != 0))) {
#if CONFIG_NEWENTROPY
- MACROBLOCKD *const xd = & pbi->mb;
- m->mbmi.mb_skip_coeff = vp8_read(bc, get_pred_prob(cm, xd, PRED_MBSKIP));
+ MACROBLOCKD *const xd = & pbi->mb;
+ m->mbmi.mb_skip_coeff = vp8_read(bc, get_pred_prob(cm, xd, PRED_MBSKIP));
#else
- m->mbmi.mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
+ m->mbmi.mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
#endif
- }
- else
- {
- if ( segfeature_active( &pbi->mb,
- m->mbmi.segment_id, SEG_LVL_EOB ) &&
- ( get_segdata( &pbi->mb,
- m->mbmi.segment_id, SEG_LVL_EOB ) == 0 ) )
- {
- m->mbmi.mb_skip_coeff = 1;
- }
- else
- m->mbmi.mb_skip_coeff = 0;
- }
-
- y_mode = (MB_PREDICTION_MODE) vp8_kfread_ymode(bc,
- pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
+ } else {
+ if (segfeature_active(&pbi->mb,
+ m->mbmi.segment_id, SEG_LVL_EOB) &&
+ (get_segdata(&pbi->mb,
+ m->mbmi.segment_id, SEG_LVL_EOB) == 0)) {
+ m->mbmi.mb_skip_coeff = 1;
+ } else
+ m->mbmi.mb_skip_coeff = 0;
+ }
+
+ y_mode = (MB_PREDICTION_MODE) vp8_kfread_ymode(bc,
+ pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
#if CONFIG_COMP_INTRA_PRED
- m->mbmi.second_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
+ m->mbmi.second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- m->mbmi.ref_frame = INTRA_FRAME;
+ m->mbmi.ref_frame = INTRA_FRAME;
- if ((m->mbmi.mode = y_mode) == B_PRED)
- {
- int i = 0;
+ if ((m->mbmi.mode = y_mode) == B_PRED) {
+ int i = 0;
#if CONFIG_COMP_INTRA_PRED
- int use_comp_pred = vp8_read(bc, 128);
+ int use_comp_pred = vp8_read(bc, 128);
#endif
- do
- {
- const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
- const B_PREDICTION_MODE L = left_block_mode(m, i);
+ do {
+ const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
+ const B_PREDICTION_MODE L = left_block_mode(m, i);
- m->bmi[i].as_mode.first =
- (B_PREDICTION_MODE) vp8_read_bmode(
- bc, pbi->common.kf_bmode_prob [A] [L]);
+ m->bmi[i].as_mode.first =
+ (B_PREDICTION_MODE) vp8_read_bmode(
+ bc, pbi->common.kf_bmode_prob [A] [L]);
#if CONFIG_COMP_INTRA_PRED
- if (use_comp_pred)
- {
- m->bmi[i].as_mode.second =
- (B_PREDICTION_MODE) vp8_read_bmode(
- bc, pbi->common.kf_bmode_prob [A] [L]);
- }
- else
- {
- m->bmi[i].as_mode.second = (B_PREDICTION_MODE) (B_DC_PRED - 1);
- }
+ if (use_comp_pred) {
+ m->bmi[i].as_mode.second =
+ (B_PREDICTION_MODE) vp8_read_bmode(
+ bc, pbi->common.kf_bmode_prob [A] [L]);
+ } else {
+ m->bmi[i].as_mode.second = (B_PREDICTION_MODE)(B_DC_PRED - 1);
+ }
#endif
- }
- while (++i < 16);
- }
- if((m->mbmi.mode = y_mode) == I8X8_PRED)
- {
- int i;
- int mode8x8;
- for(i=0;i<4;i++)
- {
- int ib = vp8_i8x8_block[i];
- mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
- m->bmi[ib+0].as_mode.first= mode8x8;
- m->bmi[ib+1].as_mode.first= mode8x8;
- m->bmi[ib+4].as_mode.first= mode8x8;
- m->bmi[ib+5].as_mode.first= mode8x8;
+ } while (++i < 16);
+ }
+ if ((m->mbmi.mode = y_mode) == I8X8_PRED) {
+ int i;
+ int mode8x8;
+ for (i = 0; i < 4; i++) {
+ int ib = vp8_i8x8_block[i];
+ mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
+ m->bmi[ib + 0].as_mode.first = mode8x8;
+ m->bmi[ib + 1].as_mode.first = mode8x8;
+ m->bmi[ib + 4].as_mode.first = mode8x8;
+ m->bmi[ib + 5].as_mode.first = mode8x8;
#if CONFIG_COMP_INTRA_PRED
- m->bmi[ib+0].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- m->bmi[ib+1].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- m->bmi[ib+4].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- m->bmi[ib+5].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
+ m->bmi[ib + 0].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ m->bmi[ib + 1].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ m->bmi[ib + 4].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ m->bmi[ib + 5].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- }
- }
- else
- m->mbmi.uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc,
- pbi->common.kf_uv_mode_prob[m->mbmi.mode]);
+ }
+ } else
+ m->mbmi.uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc,
+ pbi->common.kf_uv_mode_prob[m->mbmi.mode]);
#if CONFIG_COMP_INTRA_PRED
- m->mbmi.second_uv_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
+ m->mbmi.second_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
}
-static int read_mvcomponent(vp8_reader *r, const MV_CONTEXT *mvc)
-{
- const vp8_prob *const p = (const vp8_prob *) mvc;
- int x = 0;
+static int read_mvcomponent(vp8_reader *r, const MV_CONTEXT *mvc) {
+ const vp8_prob *const p = (const vp8_prob *) mvc;
+ int x = 0;
- if (vp8_read(r, p [mvpis_short])) /* Large */
- {
- int i = 0;
+ if (vp8_read(r, p [mvpis_short])) { /* Large */
+ int i = 0;
- do
- {
- x += vp8_read(r, p [MVPbits + i]) << i;
- }
- while (++i < mvnum_short_bits);
+ do {
+ x += vp8_read(r, p [MVPbits + i]) << i;
+ } while (++i < mvnum_short_bits);
- i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
+ i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
- do
- {
- x += vp8_read(r, p [MVPbits + i]) << i;
- }
- while (--i > mvnum_short_bits);
+ do {
+ x += vp8_read(r, p [MVPbits + i]) << i;
+ } while (--i > mvnum_short_bits);
- if (!(x & ~((2<<mvnum_short_bits)-1)) || vp8_read(r, p [MVPbits + mvnum_short_bits]))
- x += (mvnum_short);
- }
- else /* small */
- x = vp8_treed_read(r, vp8_small_mvtree, p + MVPshort);
+ if (!(x & ~((2 << mvnum_short_bits) - 1)) || vp8_read(r, p [MVPbits + mvnum_short_bits]))
+ x += (mvnum_short);
+ } else /* small */
+ x = vp8_treed_read(r, vp8_small_mvtree, p + MVPshort);
- if (x && vp8_read(r, p [MVPsign]))
- x = -x;
+ if (x && vp8_read(r, p [MVPsign]))
+ x = -x;
- return x;
+ return x;
}
-static void read_mv(vp8_reader *r, MV *mv, const MV_CONTEXT *mvc)
-{
- mv->row = (short)(read_mvcomponent(r, mvc) << 1);
- mv->col = (short)(read_mvcomponent(r, ++mvc) << 1);
+static void read_mv(vp8_reader *r, MV *mv, const MV_CONTEXT *mvc) {
+ mv->row = (short)(read_mvcomponent(r, mvc) << 1);
+ mv->col = (short)(read_mvcomponent(r, ++mvc) << 1);
#ifdef DEBUG_DEC_MV
- int i;
- printf("%d (np): %d %d\n", dec_mvcount++, mv->row, mv->col);
- //for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[-1])->prob[i]); printf("\n");
- //for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[0])->prob[i]); printf("\n");
+ int i;
+ printf("%d (np): %d %d\n", dec_mvcount++, mv->row, mv->col);
+ // for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[-1])->prob[i]); printf("\n");
+ // for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[0])->prob[i]); printf("\n");
#endif
}
-static void read_mvcontexts(vp8_reader *bc, MV_CONTEXT *mvc)
-{
- int i = 0;
+static void read_mvcontexts(vp8_reader *bc, MV_CONTEXT *mvc) {
+ int i = 0;
- do
- {
- const vp8_prob *up = vp8_mv_update_probs[i].prob;
- vp8_prob *p = (vp8_prob *)(mvc + i);
- vp8_prob *const pstop = p + MVPcount;
+ do {
+ const vp8_prob *up = vp8_mv_update_probs[i].prob;
+ vp8_prob *p = (vp8_prob *)(mvc + i);
+ vp8_prob *const pstop = p + MVPcount;
- do
- {
- if (vp8_read(bc, *up++))
- {
- const vp8_prob x = (vp8_prob)vp8_read_literal(bc, 7);
+ do {
+ if (vp8_read(bc, *up++)) {
+ const vp8_prob x = (vp8_prob)vp8_read_literal(bc, 7);
- *p = x ? x << 1 : 1;
- }
- }
- while (++p < pstop);
- }
- while (++i < 2);
+ *p = x ? x << 1 : 1;
+ }
+ } while (++p < pstop);
+ } while (++i < 2);
}
#if CONFIG_HIGH_PRECISION_MV
-static int read_mvcomponent_hp(vp8_reader *r, const MV_CONTEXT_HP *mvc)
-{
- const vp8_prob *const p = (const vp8_prob *) mvc;
- int x = 0;
+static int read_mvcomponent_hp(vp8_reader *r, const MV_CONTEXT_HP *mvc) {
+ const vp8_prob *const p = (const vp8_prob *) mvc;
+ int x = 0;
- if (vp8_read(r, p [mvpis_short_hp])) /* Large */
- {
- int i = 0;
+ if (vp8_read(r, p [mvpis_short_hp])) { /* Large */
+ int i = 0;
- do
- {
- x += vp8_read(r, p [MVPbits_hp + i]) << i;
- }
- while (++i < mvnum_short_bits_hp);
+ do {
+ x += vp8_read(r, p [MVPbits_hp + i]) << i;
+ } while (++i < mvnum_short_bits_hp);
- i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
+ i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
- do
- {
- x += vp8_read(r, p [MVPbits_hp + i]) << i;
- }
- while (--i > mvnum_short_bits_hp);
+ do {
+ x += vp8_read(r, p [MVPbits_hp + i]) << i;
+ } while (--i > mvnum_short_bits_hp);
- if (!(x & ~((2<<mvnum_short_bits_hp)-1)) || vp8_read(r, p [MVPbits_hp + mvnum_short_bits_hp]))
- x += (mvnum_short_hp);
- }
- else /* small */
- x = vp8_treed_read(r, vp8_small_mvtree_hp, p + MVPshort_hp);
+ if (!(x & ~((2 << mvnum_short_bits_hp) - 1)) || vp8_read(r, p [MVPbits_hp + mvnum_short_bits_hp]))
+ x += (mvnum_short_hp);
+ } else /* small */
+ x = vp8_treed_read(r, vp8_small_mvtree_hp, p + MVPshort_hp);
- if (x && vp8_read(r, p [MVPsign_hp]))
- x = -x;
+ if (x && vp8_read(r, p [MVPsign_hp]))
+ x = -x;
- return x;
+ return x;
}
-static void read_mv_hp(vp8_reader *r, MV *mv, const MV_CONTEXT_HP *mvc)
-{
- mv->row = (short)(read_mvcomponent_hp(r, mvc));
- mv->col = (short)(read_mvcomponent_hp(r, ++mvc));
+static void read_mv_hp(vp8_reader *r, MV *mv, const MV_CONTEXT_HP *mvc) {
+ mv->row = (short)(read_mvcomponent_hp(r, mvc));
+ mv->col = (short)(read_mvcomponent_hp(r, ++mvc));
#ifdef DEBUG_DEC_MV
- int i;
- printf("%d (hp): %d %d\n", dec_mvcount++, mv->row, mv->col);
- //for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[-1])->prob[i]); printf("\n");
- //for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[0])->prob[i]); printf("\n");
+ int i;
+ printf("%d (hp): %d %d\n", dec_mvcount++, mv->row, mv->col);
+ // for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[-1])->prob[i]); printf("\n");
+ // for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[0])->prob[i]); printf("\n");
#endif
}
-static void read_mvcontexts_hp(vp8_reader *bc, MV_CONTEXT_HP *mvc)
-{
- int i = 0;
+static void read_mvcontexts_hp(vp8_reader *bc, MV_CONTEXT_HP *mvc) {
+ int i = 0;
- do
- {
- const vp8_prob *up = vp8_mv_update_probs_hp[i].prob;
- vp8_prob *p = (vp8_prob *)(mvc + i);
- vp8_prob *const pstop = p + MVPcount_hp;
+ do {
+ const vp8_prob *up = vp8_mv_update_probs_hp[i].prob;
+ vp8_prob *p = (vp8_prob *)(mvc + i);
+ vp8_prob *const pstop = p + MVPcount_hp;
- do
- {
- if (vp8_read(bc, *up++))
- {
- const vp8_prob x = (vp8_prob)vp8_read_literal(bc, 7);
+ do {
+ if (vp8_read(bc, *up++)) {
+ const vp8_prob x = (vp8_prob)vp8_read_literal(bc, 7);
- *p = x ? x << 1 : 1;
- }
- }
- while (++p < pstop);
- }
- while (++i < 2);
+ *p = x ? x << 1 : 1;
+ }
+ } while (++p < pstop);
+ } while (++i < 2);
}
#endif /* CONFIG_HIGH_PRECISION_MV */
// Read the referncence frame
-static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
- vp8_reader *const bc,
- unsigned char segment_id )
-{
- MV_REFERENCE_FRAME ref_frame;
- int seg_ref_active;
- int seg_ref_count = 0;
-
- VP8_COMMON *const cm = & pbi->common;
- MACROBLOCKD *const xd = &pbi->mb;
-
- seg_ref_active = segfeature_active( xd,
- segment_id,
- SEG_LVL_REF_FRAME );
-
- // If segment coding enabled does the segment allow for more than one
- // possible reference frame
- if ( seg_ref_active )
- {
- seg_ref_count = check_segref( xd, segment_id, INTRA_FRAME ) +
- check_segref( xd, segment_id, LAST_FRAME ) +
- check_segref( xd, segment_id, GOLDEN_FRAME ) +
- check_segref( xd, segment_id, ALTREF_FRAME );
+static MV_REFERENCE_FRAME read_ref_frame(VP8D_COMP *pbi,
+ vp8_reader *const bc,
+ unsigned char segment_id) {
+ MV_REFERENCE_FRAME ref_frame;
+ int seg_ref_active;
+ int seg_ref_count = 0;
+
+ VP8_COMMON *const cm = & pbi->common;
+ MACROBLOCKD *const xd = &pbi->mb;
+
+ seg_ref_active = segfeature_active(xd,
+ segment_id,
+ SEG_LVL_REF_FRAME);
+
+ // If segment coding enabled does the segment allow for more than one
+ // possible reference frame
+ if (seg_ref_active) {
+ seg_ref_count = check_segref(xd, segment_id, INTRA_FRAME) +
+ check_segref(xd, segment_id, LAST_FRAME) +
+ check_segref(xd, segment_id, GOLDEN_FRAME) +
+ check_segref(xd, segment_id, ALTREF_FRAME);
+ }
+
+ // Segment reference frame features not available or allows for
+ // multiple reference frame options
+ if (!seg_ref_active || (seg_ref_count > 1)) {
+ // Values used in prediction model coding
+ unsigned char prediction_flag;
+ vp8_prob pred_prob;
+ MV_REFERENCE_FRAME pred_ref;
+
+ // Get the context probability the prediction flag
+ pred_prob = get_pred_prob(cm, xd, PRED_REF);
+
+ // Read the prediction status flag
+ prediction_flag = (unsigned char)vp8_read(bc, pred_prob);
+
+ // Store the prediction flag.
+ set_pred_flag(xd, PRED_REF, prediction_flag);
+
+ // Get the predicted reference frame.
+ pred_ref = get_pred_ref(cm, xd);
+
+ // If correctly predicted then use the predicted value
+ if (prediction_flag) {
+ ref_frame = pred_ref;
}
-
- // Segment reference frame features not available or allows for
- // multiple reference frame options
- if ( !seg_ref_active || (seg_ref_count > 1) )
- {
- // Values used in prediction model coding
- unsigned char prediction_flag;
- vp8_prob pred_prob;
- MV_REFERENCE_FRAME pred_ref;
-
- // Get the context probability the prediction flag
- pred_prob = get_pred_prob( cm, xd, PRED_REF );
-
- // Read the prediction status flag
- prediction_flag = (unsigned char)vp8_read( bc, pred_prob );
-
- // Store the prediction flag.
- set_pred_flag( xd, PRED_REF, prediction_flag );
-
- // Get the predicted reference frame.
- pred_ref = get_pred_ref( cm, xd );
-
- // If correctly predicted then use the predicted value
- if ( prediction_flag )
- {
- ref_frame = pred_ref;
- }
- // else decode the explicitly coded value
+ // else decode the explicitly coded value
+ else {
+ vp8_prob mod_refprobs[PREDICTION_PROBS];
+ vpx_memcpy(mod_refprobs,
+ cm->mod_refprobs[pred_ref], sizeof(mod_refprobs));
+
+ // If segment coding enabled blank out options that cant occur by
+ // setting the branch probability to 0.
+ if (seg_ref_active) {
+ mod_refprobs[INTRA_FRAME] *=
+ check_segref(xd, segment_id, INTRA_FRAME);
+ mod_refprobs[LAST_FRAME] *=
+ check_segref(xd, segment_id, LAST_FRAME);
+ mod_refprobs[GOLDEN_FRAME] *=
+ (check_segref(xd, segment_id, GOLDEN_FRAME) *
+ check_segref(xd, segment_id, ALTREF_FRAME));
+ }
+
+ // Default to INTRA_FRAME (value 0)
+ ref_frame = INTRA_FRAME;
+
+ // Do we need to decode the Intra/Inter branch
+ if (mod_refprobs[0])
+ ref_frame = (MV_REFERENCE_FRAME) vp8_read(bc, mod_refprobs[0]);
+ else
+ ref_frame++;
+
+ if (ref_frame) {
+ // Do we need to decode the Last/Gf_Arf branch
+ if (mod_refprobs[1])
+ ref_frame += vp8_read(bc, mod_refprobs[1]);
else
- {
- vp8_prob mod_refprobs[PREDICTION_PROBS];
- vpx_memcpy( mod_refprobs,
- cm->mod_refprobs[pred_ref], sizeof(mod_refprobs) );
-
- // If segment coding enabled blank out options that cant occur by
- // setting the branch probability to 0.
- if ( seg_ref_active )
- {
- mod_refprobs[INTRA_FRAME] *=
- check_segref( xd, segment_id, INTRA_FRAME );
- mod_refprobs[LAST_FRAME] *=
- check_segref( xd, segment_id, LAST_FRAME );
- mod_refprobs[GOLDEN_FRAME] *=
- ( check_segref( xd, segment_id, GOLDEN_FRAME ) *
- check_segref( xd, segment_id, ALTREF_FRAME ) );
- }
-
- // Default to INTRA_FRAME (value 0)
- ref_frame = INTRA_FRAME;
-
- // Do we need to decode the Intra/Inter branch
- if ( mod_refprobs[0] )
- ref_frame = (MV_REFERENCE_FRAME) vp8_read(bc, mod_refprobs[0]);
- else
- ref_frame ++;
-
- if (ref_frame)
- {
- // Do we need to decode the Last/Gf_Arf branch
- if ( mod_refprobs[1] )
- ref_frame += vp8_read(bc, mod_refprobs[1]);
- else
- ref_frame++;
-
- if ( ref_frame > 1 )
- {
- // Do we need to decode the GF/Arf branch
- if ( mod_refprobs[2] )
- ref_frame += vp8_read(bc, mod_refprobs[2]);
- else
- {
- if ( seg_ref_active )
- {
- if ( (pred_ref == GOLDEN_FRAME) ||
- !check_segref( xd, segment_id, GOLDEN_FRAME) )
- {
- ref_frame = ALTREF_FRAME;
- }
- else
- ref_frame = GOLDEN_FRAME;
- }
- else
- ref_frame = (pred_ref == GOLDEN_FRAME)
- ? ALTREF_FRAME : GOLDEN_FRAME;
- }
- }
- }
+ ref_frame++;
+
+ if (ref_frame > 1) {
+ // Do we need to decode the GF/Arf branch
+ if (mod_refprobs[2])
+ ref_frame += vp8_read(bc, mod_refprobs[2]);
+ else {
+ if (seg_ref_active) {
+ if ((pred_ref == GOLDEN_FRAME) ||
+ !check_segref(xd, segment_id, GOLDEN_FRAME)) {
+ ref_frame = ALTREF_FRAME;
+ } else
+ ref_frame = GOLDEN_FRAME;
+ } else
+ ref_frame = (pred_ref == GOLDEN_FRAME)
+ ? ALTREF_FRAME : GOLDEN_FRAME;
+ }
}
+ }
}
-
- // Segment reference frame features are enabled
- else
- {
- // The reference frame for the mb is considered as correclty predicted
- // if it is signaled at the segment level for the purposes of the
- // common prediction model
- set_pred_flag( xd, PRED_REF, 1 );
- ref_frame = get_pred_ref( cm, xd );
- }
-
- return (MV_REFERENCE_FRAME)ref_frame;
+ }
+
+ // Segment reference frame features are enabled
+ else {
+ // The reference frame for the mb is considered as correclty predicted
+ // if it is signaled at the segment level for the purposes of the
+ // common prediction model
+ set_pred_flag(xd, PRED_REF, 1);
+ ref_frame = get_pred_ref(cm, xd);
+ }
+
+ return (MV_REFERENCE_FRAME)ref_frame;
}
-static MB_PREDICTION_MODE read_mv_ref(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_mv_ref_tree, p);
+static MB_PREDICTION_MODE read_mv_ref(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_mv_ref_tree, p);
- return (MB_PREDICTION_MODE)i;
+ return (MB_PREDICTION_MODE)i;
}
-static B_PREDICTION_MODE sub_mv_ref(vp8_reader *bc, const vp8_prob *p)
-{
- const int i = vp8_treed_read(bc, vp8_sub_mv_ref_tree, p);
+static B_PREDICTION_MODE sub_mv_ref(vp8_reader *bc, const vp8_prob *p) {
+ const int i = vp8_treed_read(bc, vp8_sub_mv_ref_tree, p);
- return (B_PREDICTION_MODE)i;
+ return (B_PREDICTION_MODE)i;
}
#ifdef VPX_MODE_COUNT
-unsigned int vp8_mv_cont_count[5][4] =
-{
- { 0, 0, 0, 0 },
- { 0, 0, 0, 0 },
- { 0, 0, 0, 0 },
- { 0, 0, 0, 0 },
- { 0, 0, 0, 0 }
+unsigned int vp8_mv_cont_count[5][4] = {
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 }
};
#endif
static const unsigned char mbsplit_fill_count[4] = {8, 8, 4, 1};
static const unsigned char mbsplit_fill_offset[4][16] = {
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
- { 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15},
- { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15},
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
+ { 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15},
+ { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15},
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
};
-static void mb_mode_mv_init(VP8D_COMP *pbi)
-{
- VP8_COMMON *const cm = & pbi->common;
- vp8_reader *const bc = & pbi->bc;
- MV_CONTEXT *const mvc = pbi->common.fc.mvc;
+static void mb_mode_mv_init(VP8D_COMP *pbi) {
+ VP8_COMMON *const cm = & pbi->common;
+ vp8_reader *const bc = & pbi->bc;
+ MV_CONTEXT *const mvc = pbi->common.fc.mvc;
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP *const mvc_hp = pbi->common.fc.mvc_hp;
- MACROBLOCKD *const xd = & pbi->mb;
+ MV_CONTEXT_HP *const mvc_hp = pbi->common.fc.mvc_hp;
+ MACROBLOCKD *const xd = & pbi->mb;
#endif
#if CONFIG_NEWENTROPY
- vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
+ vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
#else
- pbi->prob_skip_false = 0;
+ pbi->prob_skip_false = 0;
#endif
- if (pbi->common.mb_no_coeff_skip)
- {
+ if (pbi->common.mb_no_coeff_skip) {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- cm->mbskip_pred_probs[k] = (vp8_prob)vp8_read_literal(bc, 8);
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ cm->mbskip_pred_probs[k] = (vp8_prob)vp8_read_literal(bc, 8);
#else
- pbi->prob_skip_false = (vp8_prob)vp8_read_literal(bc, 8);
+ pbi->prob_skip_false = (vp8_prob)vp8_read_literal(bc, 8);
#endif
- }
+ }
- if(cm->frame_type != KEY_FRAME)
- {
+ if (cm->frame_type != KEY_FRAME) {
#if CONFIG_PRED_FILTER
- cm->pred_filter_mode = (vp8_prob)vp8_read_literal(bc, 2);
+ cm->pred_filter_mode = (vp8_prob)vp8_read_literal(bc, 2);
- if (cm->pred_filter_mode == 2)
- cm->prob_pred_filter_off = (vp8_prob)vp8_read_literal(bc, 8);
+ if (cm->pred_filter_mode == 2)
+ cm->prob_pred_filter_off = (vp8_prob)vp8_read_literal(bc, 8);
#endif
- // Decode the baseline probabilities for decoding reference frame
- cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
- cm->prob_last_coded = (vp8_prob)vp8_read_literal(bc, 8);
- cm->prob_gf_coded = (vp8_prob)vp8_read_literal(bc, 8);
-
- // Computes a modified set of probabilities for use when reference
- // frame prediction fails.
- compute_mod_refprobs( cm );
-
- pbi->common.comp_pred_mode = vp8_read(bc, 128);
- if (cm->comp_pred_mode)
- cm->comp_pred_mode += vp8_read(bc, 128);
- if (cm->comp_pred_mode == HYBRID_PREDICTION)
- {
- int i;
- for ( i = 0; i < COMP_PRED_CONTEXTS; i++ )
- cm->prob_comppred[i] = (vp8_prob)vp8_read_literal(bc, 8);
- }
+ // Decode the baseline probabilities for decoding reference frame
+ cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
+ cm->prob_last_coded = (vp8_prob)vp8_read_literal(bc, 8);
+ cm->prob_gf_coded = (vp8_prob)vp8_read_literal(bc, 8);
+
+ // Computes a modified set of probabilities for use when reference
+ // frame prediction fails.
+ compute_mod_refprobs(cm);
+
+ pbi->common.comp_pred_mode = vp8_read(bc, 128);
+ if (cm->comp_pred_mode)
+ cm->comp_pred_mode += vp8_read(bc, 128);
+ if (cm->comp_pred_mode == HYBRID_PREDICTION) {
+ int i;
+ for (i = 0; i < COMP_PRED_CONTEXTS; i++)
+ cm->prob_comppred[i] = (vp8_prob)vp8_read_literal(bc, 8);
+ }
- if (vp8_read_bit(bc))
- {
- int i = 0;
+ if (vp8_read_bit(bc)) {
+ int i = 0;
- do
- {
- cm->fc.ymode_prob[i] = (vp8_prob) vp8_read_literal(bc, 8);
- }
- while (++i < VP8_YMODES-1);
- }
+ do {
+ cm->fc.ymode_prob[i] = (vp8_prob) vp8_read_literal(bc, 8);
+ } while (++i < VP8_YMODES - 1);
+ }
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- read_mvcontexts_hp(bc, mvc_hp);
- else
+ if (xd->allow_high_precision_mv)
+ read_mvcontexts_hp(bc, mvc_hp);
+ else
#endif
- read_mvcontexts(bc, mvc);
- }
+ read_mvcontexts(bc, mvc);
+ }
}
// This function either reads the segment id for the current macroblock from
// the bitstream or if the value is temporally predicted asserts the predicted
// value
-static void read_mb_segment_id ( VP8D_COMP *pbi,
- int mb_row, int mb_col )
-{
- vp8_reader *const bc = & pbi->bc;
- VP8_COMMON *const cm = & pbi->common;
- MACROBLOCKD *const xd = & pbi->mb;
- MODE_INFO *mi = xd->mode_info_context;
- MB_MODE_INFO *mbmi = &mi->mbmi;
- int index = mb_row * pbi->common.mb_cols + mb_col;
+static void read_mb_segment_id(VP8D_COMP *pbi,
+ int mb_row, int mb_col) {
+ vp8_reader *const bc = & pbi->bc;
+ VP8_COMMON *const cm = & pbi->common;
+ MACROBLOCKD *const xd = & pbi->mb;
+ MODE_INFO *mi = xd->mode_info_context;
+ MB_MODE_INFO *mbmi = &mi->mbmi;
+ int index = mb_row * pbi->common.mb_cols + mb_col;
+
+ if (xd->segmentation_enabled) {
+ if (xd->update_mb_segmentation_map) {
+ // Is temporal coding of the segment id for this mb enabled.
+ if (cm->temporal_update) {
+ // Get the context based probability for reading the
+ // prediction status flag
+ vp8_prob pred_prob =
+ get_pred_prob(cm, xd, PRED_SEG_ID);
- if (xd->segmentation_enabled)
- {
- if (xd->update_mb_segmentation_map)
- {
- // Is temporal coding of the segment id for this mb enabled.
- if (cm->temporal_update)
- {
- // Get the context based probability for reading the
- // prediction status flag
- vp8_prob pred_prob =
- get_pred_prob( cm, xd, PRED_SEG_ID );
-
- // Read the prediction status flag
- unsigned char seg_pred_flag =
- (unsigned char)vp8_read(bc, pred_prob );
-
- // Store the prediction flag.
- set_pred_flag( xd, PRED_SEG_ID, seg_pred_flag );
-
- // If the value is flagged as correctly predicted
- // then use the predicted value
- if ( seg_pred_flag )
- {
- mbmi->segment_id = get_pred_mb_segid( cm, index );
- }
- // Else .... decode it explicitly
- else
- {
- vp8_read_mb_segid(bc, mbmi, xd );
- cm->last_frame_seg_map[index] = mbmi->segment_id;
- }
+ // Read the prediction status flag
+ unsigned char seg_pred_flag =
+ (unsigned char)vp8_read(bc, pred_prob);
- }
- // Normal unpredicted coding mode
- else
- {
- vp8_read_mb_segid(bc, mbmi, xd);
- cm->last_frame_seg_map[index] = mbmi->segment_id;
- }
+ // Store the prediction flag.
+ set_pred_flag(xd, PRED_SEG_ID, seg_pred_flag);
+
+ // If the value is flagged as correctly predicted
+ // then use the predicted value
+ if (seg_pred_flag) {
+ mbmi->segment_id = get_pred_mb_segid(cm, index);
}
+ // Else .... decode it explicitly
+ else {
+ vp8_read_mb_segid(bc, mbmi, xd);
+ cm->last_frame_seg_map[index] = mbmi->segment_id;
+ }
+
+ }
+ // Normal unpredicted coding mode
+ else {
+ vp8_read_mb_segid(bc, mbmi, xd);
+ cm->last_frame_seg_map[index] = mbmi->segment_id;
+ }
}
- else
- {
- // The encoder explicitly sets the segment_id to 0
- // when segmentation is disabled
- mbmi->segment_id = 0;
- }
+ } else {
+ // The encoder explicitly sets the segment_id to 0
+ // when segmentation is disabled
+ mbmi->segment_id = 0;
+ }
}
static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
MODE_INFO *prev_mi,
- int mb_row, int mb_col)
-{
- VP8_COMMON *const cm = & pbi->common;
- vp8_reader *const bc = & pbi->bc;
- MV_CONTEXT *const mvc = pbi->common.fc.mvc;
+ int mb_row, int mb_col) {
+ VP8_COMMON *const cm = & pbi->common;
+ vp8_reader *const bc = & pbi->bc;
+ MV_CONTEXT *const mvc = pbi->common.fc.mvc;
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP *const mvc_hp = pbi->common.fc.mvc_hp;
+ MV_CONTEXT_HP *const mvc_hp = pbi->common.fc.mvc_hp;
#endif
- const int mis = pbi->common.mode_info_stride;
- MACROBLOCKD *const xd = & pbi->mb;
-
- int_mv *const mv = & mbmi->mv;
- int mb_to_left_edge;
- int mb_to_right_edge;
- int mb_to_top_edge;
- int mb_to_bottom_edge;
-
- mb_to_top_edge = xd->mb_to_top_edge;
- mb_to_bottom_edge = xd->mb_to_bottom_edge;
- mb_to_top_edge -= LEFT_TOP_MARGIN;
- mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
- mbmi->need_to_clamp_mvs = 0;
- mbmi->need_to_clamp_secondmv = 0;
- mbmi->second_ref_frame = 0;
- /* Distance of Mb to the various image edges.
- * These specified to 8th pel as they are always compared to MV values that are in 1/8th pel units
- */
- xd->mb_to_left_edge =
+ const int mis = pbi->common.mode_info_stride;
+ MACROBLOCKD *const xd = & pbi->mb;
+
+ int_mv *const mv = & mbmi->mv;
+ int mb_to_left_edge;
+ int mb_to_right_edge;
+ int mb_to_top_edge;
+ int mb_to_bottom_edge;
+
+ mb_to_top_edge = xd->mb_to_top_edge;
+ mb_to_bottom_edge = xd->mb_to_bottom_edge;
+ mb_to_top_edge -= LEFT_TOP_MARGIN;
+ mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
+ mbmi->need_to_clamp_mvs = 0;
+ mbmi->need_to_clamp_secondmv = 0;
+ mbmi->second_ref_frame = 0;
+ /* Distance of Mb to the various image edges.
+ * These specified to 8th pel as they are always compared to MV values that are in 1/8th pel units
+ */
+ xd->mb_to_left_edge =
mb_to_left_edge = -((mb_col * 16) << 3);
- mb_to_left_edge -= LEFT_TOP_MARGIN;
+ mb_to_left_edge -= LEFT_TOP_MARGIN;
- xd->mb_to_right_edge =
+ xd->mb_to_right_edge =
mb_to_right_edge = ((pbi->common.mb_cols - 1 - mb_col) * 16) << 3;
- mb_to_right_edge += RIGHT_BOTTOM_MARGIN;
-
- // Make sure the MACROBLOCKD mode info pointer is pointed at the
- // correct entry for the current macroblock.
- xd->mode_info_context = mi;
-
- // Read the macroblock segment id.
- read_mb_segment_id ( pbi, mb_row, mb_col );
-
- if ( pbi->common.mb_no_coeff_skip &&
- ( !segfeature_active( xd,
- mbmi->segment_id, SEG_LVL_EOB ) ||
- (get_segdata( xd, mbmi->segment_id, SEG_LVL_EOB ) != 0) ) )
- {
- // Read the macroblock coeff skip flag if this feature is in use,
- // else default to 0
+ mb_to_right_edge += RIGHT_BOTTOM_MARGIN;
+
+ // Make sure the MACROBLOCKD mode info pointer is pointed at the
+ // correct entry for the current macroblock.
+ xd->mode_info_context = mi;
+
+ // Read the macroblock segment id.
+ read_mb_segment_id(pbi, mb_row, mb_col);
+
+ if (pbi->common.mb_no_coeff_skip &&
+ (!segfeature_active(xd,
+ mbmi->segment_id, SEG_LVL_EOB) ||
+ (get_segdata(xd, mbmi->segment_id, SEG_LVL_EOB) != 0))) {
+ // Read the macroblock coeff skip flag if this feature is in use,
+ // else default to 0
#if CONFIG_NEWENTROPY
- mbmi->mb_skip_coeff = vp8_read(bc, get_pred_prob(cm, xd, PRED_MBSKIP));
+ mbmi->mb_skip_coeff = vp8_read(bc, get_pred_prob(cm, xd, PRED_MBSKIP));
#else
- mbmi->mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
+ mbmi->mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
#endif
- }
- else
- {
- if ( segfeature_active( xd,
- mbmi->segment_id, SEG_LVL_EOB ) &&
- (get_segdata( xd, mbmi->segment_id, SEG_LVL_EOB ) == 0) )
- {
- mbmi->mb_skip_coeff = 1;
- }
- else
- mbmi->mb_skip_coeff = 0;
+ } else {
+ if (segfeature_active(xd,
+ mbmi->segment_id, SEG_LVL_EOB) &&
+ (get_segdata(xd, mbmi->segment_id, SEG_LVL_EOB) == 0)) {
+ mbmi->mb_skip_coeff = 1;
+ } else
+ mbmi->mb_skip_coeff = 0;
+ }
+
+ // Read the reference frame
+ mbmi->ref_frame = read_ref_frame(pbi, bc, mbmi->segment_id);
+
+ // If reference frame is an Inter frame
+ if (mbmi->ref_frame) {
+ int rct[4];
+ int_mv nearest, nearby, best_mv;
+ int_mv nearest_second, nearby_second, best_mv_second;
+ vp8_prob mv_ref_p [VP8_MVREFS - 1];
+
+ vp8_find_near_mvs(xd, mi,
+ prev_mi,
+ &nearest, &nearby, &best_mv, rct,
+ mbmi->ref_frame, pbi->common.ref_frame_sign_bias);
+ vp8_mv_ref_probs(&pbi->common, mv_ref_p, rct);
+
+ // Is the segment level mode feature enabled for this segment
+ if (segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) {
+ mbmi->mode =
+ get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE);
+ } else {
+ mbmi->mode = read_mv_ref(bc, mv_ref_p);
+
+ vp8_accum_mv_refs(&pbi->common, mbmi->mode, rct);
}
- // Read the reference frame
- mbmi->ref_frame = read_ref_frame( pbi, bc, mbmi->segment_id );
-
- // If reference frame is an Inter frame
- if (mbmi->ref_frame)
- {
- int rct[4];
- int_mv nearest, nearby, best_mv;
- int_mv nearest_second, nearby_second, best_mv_second;
- vp8_prob mv_ref_p [VP8_MVREFS-1];
-
- vp8_find_near_mvs(xd, mi,
- prev_mi,
- &nearest, &nearby, &best_mv, rct,
- mbmi->ref_frame, pbi->common.ref_frame_sign_bias);
- vp8_mv_ref_probs(&pbi->common, mv_ref_p, rct);
-
- // Is the segment level mode feature enabled for this segment
- if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
- {
- mbmi->mode =
- get_segdata( xd, mbmi->segment_id, SEG_LVL_MODE );
- }
- else
- {
- mbmi->mode = read_mv_ref(bc, mv_ref_p);
-
- vp8_accum_mv_refs(&pbi->common, mbmi->mode, rct);
- }
-
#if CONFIG_PRED_FILTER
- if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV)
- {
- // Is the prediction filter enabled
- if (cm->pred_filter_mode == 2)
- mbmi->pred_filter_enabled =
- vp8_read(bc, cm->prob_pred_filter_off);
- else
- mbmi->pred_filter_enabled = cm->pred_filter_mode;
- }
+ if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV) {
+ // Is the prediction filter enabled
+ if (cm->pred_filter_mode == 2)
+ mbmi->pred_filter_enabled =
+ vp8_read(bc, cm->prob_pred_filter_off);
+ else
+ mbmi->pred_filter_enabled = cm->pred_filter_mode;
+ }
#endif
- if ( cm->comp_pred_mode == COMP_PREDICTION_ONLY ||
- (cm->comp_pred_mode == HYBRID_PREDICTION &&
- vp8_read(bc, get_pred_prob( cm, xd, PRED_COMP ))) )
- {
- /* Since we have 3 reference frames, we can only have 3 unique
- * combinations of combinations of 2 different reference frames
- * (A-G, G-L or A-L). In the bitstream, we use this to simply
- * derive the second reference frame from the first reference
- * frame, by saying it's the next one in the enumerator, and
- * if that's > n_refs, then the second reference frame is the
- * first one in the enumerator. */
- mbmi->second_ref_frame = mbmi->ref_frame + 1;
- if (mbmi->second_ref_frame == 4)
- mbmi->second_ref_frame = 1;
-
- vp8_find_near_mvs(xd, mi,
- prev_mi,
- &nearest_second, &nearby_second, &best_mv_second, rct,
- mbmi->second_ref_frame, pbi->common.ref_frame_sign_bias);
- }
- else
- {
- mbmi->second_ref_frame = 0;
- }
+ if (cm->comp_pred_mode == COMP_PREDICTION_ONLY ||
+ (cm->comp_pred_mode == HYBRID_PREDICTION &&
+ vp8_read(bc, get_pred_prob(cm, xd, PRED_COMP)))) {
+ /* Since we have 3 reference frames, we can only have 3 unique
+ * combinations of combinations of 2 different reference frames
+ * (A-G, G-L or A-L). In the bitstream, we use this to simply
+ * derive the second reference frame from the first reference
+ * frame, by saying it's the next one in the enumerator, and
+ * if that's > n_refs, then the second reference frame is the
+ * first one in the enumerator. */
+ mbmi->second_ref_frame = mbmi->ref_frame + 1;
+ if (mbmi->second_ref_frame == 4)
+ mbmi->second_ref_frame = 1;
+
+ vp8_find_near_mvs(xd, mi,
+ prev_mi,
+ &nearest_second, &nearby_second, &best_mv_second, rct,
+ mbmi->second_ref_frame, pbi->common.ref_frame_sign_bias);
+ } else {
+ mbmi->second_ref_frame = 0;
+ }
- mbmi->uv_mode = DC_PRED;
- switch (mbmi->mode)
- {
- case SPLITMV:
- {
- const int s = mbmi->partitioning =
- vp8_treed_read(bc, vp8_mbsplit_tree, cm->fc.mbsplit_prob);
- const int num_p = vp8_mbsplit_count [s];
- int j = 0;
+ mbmi->uv_mode = DC_PRED;
+ switch (mbmi->mode) {
+ case SPLITMV: {
+ const int s = mbmi->partitioning =
+ vp8_treed_read(bc, vp8_mbsplit_tree, cm->fc.mbsplit_prob);
+ const int num_p = vp8_mbsplit_count [s];
+ int j = 0;
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.mbsplit_counts[s]++;
+ cm->fc.mbsplit_counts[s]++;
#endif
- mbmi->need_to_clamp_mvs = 0;
- do /* for each subset j */
- {
- int_mv leftmv, abovemv, second_leftmv, second_abovemv;
- int_mv blockmv, secondmv;
- int k; /* first block in subset j */
- int mv_contz;
- int blockmode;
-
- k = vp8_mbsplit_offset[s][j];
-
- leftmv.as_int = left_block_mv(mi, k);
- abovemv.as_int = above_block_mv(mi, k, mis);
- if (mbmi->second_ref_frame)
- {
- second_leftmv.as_int = left_block_second_mv(mi, k);
- second_abovemv.as_int = above_block_second_mv(mi, k, mis);
- }
- mv_contz = vp8_mv_cont(&leftmv, &abovemv);
- blockmode = sub_mv_ref(bc, cm->fc.sub_mv_ref_prob [mv_contz]);
+ mbmi->need_to_clamp_mvs = 0;
+ do { /* for each subset j */
+ int_mv leftmv, abovemv, second_leftmv, second_abovemv;
+ int_mv blockmv, secondmv;
+ int k; /* first block in subset j */
+ int mv_contz;
+ int blockmode;
+
+ k = vp8_mbsplit_offset[s][j];
+
+ leftmv.as_int = left_block_mv(mi, k);
+ abovemv.as_int = above_block_mv(mi, k, mis);
+ if (mbmi->second_ref_frame) {
+ second_leftmv.as_int = left_block_second_mv(mi, k);
+ second_abovemv.as_int = above_block_second_mv(mi, k, mis);
+ }
+ mv_contz = vp8_mv_cont(&leftmv, &abovemv);
+ blockmode = sub_mv_ref(bc, cm->fc.sub_mv_ref_prob [mv_contz]);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.sub_mv_ref_counts[mv_contz][blockmode-LEFT4X4]++;
+ cm->fc.sub_mv_ref_counts[mv_contz][blockmode - LEFT4X4]++;
#endif
- switch (blockmode)
- {
- case NEW4X4:
+ switch (blockmode) {
+ case NEW4X4:
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- read_mv_hp(bc, &blockmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
+ if (xd->allow_high_precision_mv) {
+ read_mv_hp(bc, &blockmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount_hp[0][mv_max_hp+(blockmv.as_mv.row)]++;
- cm->fc.MVcount_hp[1][mv_max_hp+(blockmv.as_mv.col)]++;
+ cm->fc.MVcount_hp[0][mv_max_hp + (blockmv.as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp + (blockmv.as_mv.col)]++;
#endif
- }
- else
+ } else
#endif
- {
- read_mv(bc, &blockmv.as_mv, (const MV_CONTEXT *) mvc);
+ {
+ read_mv(bc, &blockmv.as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount[0][mv_max+(blockmv.as_mv.row>>1)]++;
- cm->fc.MVcount[1][mv_max+(blockmv.as_mv.col>>1)]++;
+ cm->fc.MVcount[0][mv_max + (blockmv.as_mv.row >> 1)]++;
+ cm->fc.MVcount[1][mv_max + (blockmv.as_mv.col >> 1)]++;
#endif
- }
- blockmv.as_mv.row += best_mv.as_mv.row;
- blockmv.as_mv.col += best_mv.as_mv.col;
+ }
+ blockmv.as_mv.row += best_mv.as_mv.row;
+ blockmv.as_mv.col += best_mv.as_mv.col;
- if (mbmi->second_ref_frame)
- {
+ if (mbmi->second_ref_frame) {
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- read_mv_hp(bc, &secondmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
+ if (xd->allow_high_precision_mv) {
+ read_mv_hp(bc, &secondmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount_hp[0][mv_max_hp+(secondmv.as_mv.row)]++;
- cm->fc.MVcount_hp[1][mv_max_hp+(secondmv.as_mv.col)]++;
+ cm->fc.MVcount_hp[0][mv_max_hp + (secondmv.as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp + (secondmv.as_mv.col)]++;
#endif
- }
- else
+ } else
#endif
- {
- read_mv(bc, &secondmv.as_mv, (const MV_CONTEXT *) mvc);
+ {
+ read_mv(bc, &secondmv.as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount[0][mv_max+(secondmv.as_mv.row>>1)]++;
- cm->fc.MVcount[1][mv_max+(secondmv.as_mv.col>>1)]++;
+ cm->fc.MVcount[0][mv_max + (secondmv.as_mv.row >> 1)]++;
+ cm->fc.MVcount[1][mv_max + (secondmv.as_mv.col >> 1)]++;
#endif
- }
- secondmv.as_mv.row += best_mv_second.as_mv.row;
- secondmv.as_mv.col += best_mv_second.as_mv.col;
- }
+ }
+ secondmv.as_mv.row += best_mv_second.as_mv.row;
+ secondmv.as_mv.col += best_mv_second.as_mv.col;
+ }
#ifdef VPX_MODE_COUNT
- vp8_mv_cont_count[mv_contz][3]++;
+ vp8_mv_cont_count[mv_contz][3]++;
#endif
- break;
- case LEFT4X4:
- blockmv.as_int = leftmv.as_int;
- if (mbmi->second_ref_frame)
- secondmv.as_int = second_leftmv.as_int;
+ break;
+ case LEFT4X4:
+ blockmv.as_int = leftmv.as_int;
+ if (mbmi->second_ref_frame)
+ secondmv.as_int = second_leftmv.as_int;
#ifdef VPX_MODE_COUNT
- vp8_mv_cont_count[mv_contz][0]++;
+ vp8_mv_cont_count[mv_contz][0]++;
#endif
- break;
- case ABOVE4X4:
- blockmv.as_int = abovemv.as_int;
- if (mbmi->second_ref_frame)
- secondmv.as_int = second_abovemv.as_int;
+ break;
+ case ABOVE4X4:
+ blockmv.as_int = abovemv.as_int;
+ if (mbmi->second_ref_frame)
+ secondmv.as_int = second_abovemv.as_int;
#ifdef VPX_MODE_COUNT
- vp8_mv_cont_count[mv_contz][1]++;
+ vp8_mv_cont_count[mv_contz][1]++;
#endif
- break;
- case ZERO4X4:
- blockmv.as_int = 0;
- if (mbmi->second_ref_frame)
- secondmv.as_int = 0;
+ break;
+ case ZERO4X4:
+ blockmv.as_int = 0;
+ if (mbmi->second_ref_frame)
+ secondmv.as_int = 0;
#ifdef VPX_MODE_COUNT
- vp8_mv_cont_count[mv_contz][2]++;
+ vp8_mv_cont_count[mv_contz][2]++;
#endif
- break;
- default:
- break;
- }
-
- mbmi->need_to_clamp_mvs |= vp8_check_mv_bounds(&blockmv,
- mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
- if (mbmi->second_ref_frame)
- {
- mbmi->need_to_clamp_mvs |= vp8_check_mv_bounds(&secondmv,
- mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
- }
-
- {
- /* Fill (uniform) modes, mvs of jth subset.
- Must do it here because ensuing subsets can
- refer back to us via "left" or "above". */
- const unsigned char *fill_offset;
- unsigned int fill_count = mbsplit_fill_count[s];
-
- fill_offset = &mbsplit_fill_offset[s][(unsigned char)j * mbsplit_fill_count[s]];
-
- do {
- mi->bmi[ *fill_offset].as_mv.first.as_int = blockmv.as_int;
- if (mbmi->second_ref_frame)
- mi->bmi[ *fill_offset].as_mv.second.as_int = secondmv.as_int;
- fill_offset++;
- }while (--fill_count);
- }
-
- }
- while (++j < num_p);
+ break;
+ default:
+ break;
+ }
+
+ mbmi->need_to_clamp_mvs |= vp8_check_mv_bounds(&blockmv,
+ mb_to_left_edge,
+ mb_to_right_edge,
+ mb_to_top_edge,
+ mb_to_bottom_edge);
+ if (mbmi->second_ref_frame) {
+ mbmi->need_to_clamp_mvs |= vp8_check_mv_bounds(&secondmv,
+ mb_to_left_edge,
+ mb_to_right_edge,
+ mb_to_top_edge,
+ mb_to_bottom_edge);
+ }
+
+ {
+ /* Fill (uniform) modes, mvs of jth subset.
+ Must do it here because ensuing subsets can
+ refer back to us via "left" or "above". */
+ const unsigned char *fill_offset;
+ unsigned int fill_count = mbsplit_fill_count[s];
+
+ fill_offset = &mbsplit_fill_offset[s][(unsigned char)j * mbsplit_fill_count[s]];
+
+ do {
+ mi->bmi[ *fill_offset].as_mv.first.as_int = blockmv.as_int;
+ if (mbmi->second_ref_frame)
+ mi->bmi[ *fill_offset].as_mv.second.as_int = secondmv.as_int;
+ fill_offset++;
+ } while (--fill_count);
+ }
+
+ } while (++j < num_p);
+ }
+
+ mv->as_int = mi->bmi[15].as_mv.first.as_int;
+ mbmi->second_mv.as_int = mi->bmi[15].as_mv.second.as_int;
+
+ break; /* done with SPLITMV */
+
+ case NEARMV:
+ mv->as_int = nearby.as_int;
+ /* Clip "next_nearest" so that it does not extend to far out of image */
+ vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
+ mb_to_top_edge, mb_to_bottom_edge);
+ if (mbmi->second_ref_frame) {
+ mbmi->second_mv.as_int = nearby_second.as_int;
+ vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
+ mb_to_top_edge, mb_to_bottom_edge);
}
+ break;
+
+ case NEARESTMV:
+ mv->as_int = nearest.as_int;
+ /* Clip "next_nearest" so that it does not extend to far out of image */
+ vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
+ mb_to_top_edge, mb_to_bottom_edge);
+ if (mbmi->second_ref_frame) {
+ mbmi->second_mv.as_int = nearest_second.as_int;
+ vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
+ mb_to_top_edge, mb_to_bottom_edge);
+ }
+ break;
+
+ case ZEROMV:
+ mv->as_int = 0;
+ if (mbmi->second_ref_frame)
+ mbmi->second_mv.as_int = 0;
+ break;
- mv->as_int = mi->bmi[15].as_mv.first.as_int;
- mbmi->second_mv.as_int = mi->bmi[15].as_mv.second.as_int;
-
- break; /* done with SPLITMV */
-
- case NEARMV:
- mv->as_int = nearby.as_int;
- /* Clip "next_nearest" so that it does not extend to far out of image */
- vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
- mb_to_top_edge, mb_to_bottom_edge);
- if (mbmi->second_ref_frame)
- {
- mbmi->second_mv.as_int = nearby_second.as_int;
- vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
- mb_to_top_edge, mb_to_bottom_edge);
- }
- break;
-
- case NEARESTMV:
- mv->as_int = nearest.as_int;
- /* Clip "next_nearest" so that it does not extend to far out of image */
- vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
- mb_to_top_edge, mb_to_bottom_edge);
- if (mbmi->second_ref_frame)
- {
- mbmi->second_mv.as_int = nearest_second.as_int;
- vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
- mb_to_top_edge, mb_to_bottom_edge);
- }
- break;
-
- case ZEROMV:
- mv->as_int = 0;
- if (mbmi->second_ref_frame)
- mbmi->second_mv.as_int = 0;
- break;
-
- case NEWMV:
+ case NEWMV:
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- read_mv_hp(bc, &mv->as_mv, (const MV_CONTEXT_HP *) mvc_hp);
+ if (xd->allow_high_precision_mv) {
+ read_mv_hp(bc, &mv->as_mv, (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount_hp[0][mv_max_hp+(mv->as_mv.row)]++;
- cm->fc.MVcount_hp[1][mv_max_hp+(mv->as_mv.col)]++;
+ cm->fc.MVcount_hp[0][mv_max_hp + (mv->as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp + (mv->as_mv.col)]++;
#endif
- }
- else
+ } else
#endif
- {
- read_mv(bc, &mv->as_mv, (const MV_CONTEXT *) mvc);
+ {
+ read_mv(bc, &mv->as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount[0][mv_max+(mv->as_mv.row>>1)]++;
- cm->fc.MVcount[1][mv_max+(mv->as_mv.col>>1)]++;
+ cm->fc.MVcount[0][mv_max + (mv->as_mv.row >> 1)]++;
+ cm->fc.MVcount[1][mv_max + (mv->as_mv.col >> 1)]++;
#endif
- }
- mv->as_mv.row += best_mv.as_mv.row;
- mv->as_mv.col += best_mv.as_mv.col;
-
- /* Don't need to check this on NEARMV and NEARESTMV modes
- * since those modes clamp the MV. The NEWMV mode does not,
- * so signal to the prediction stage whether special
- * handling may be required.
- */
- mbmi->need_to_clamp_mvs = vp8_check_mv_bounds(mv,
+ }
+ mv->as_mv.row += best_mv.as_mv.row;
+ mv->as_mv.col += best_mv.as_mv.col;
+
+ /* Don't need to check this on NEARMV and NEARESTMV modes
+ * since those modes clamp the MV. The NEWMV mode does not,
+ * so signal to the prediction stage whether special
+ * handling may be required.
+ */
+ mbmi->need_to_clamp_mvs = vp8_check_mv_bounds(mv,
mb_to_left_edge,
mb_to_right_edge,
mb_to_top_edge,
mb_to_bottom_edge);
- if (mbmi->second_ref_frame)
- {
+ if (mbmi->second_ref_frame) {
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- read_mv_hp(bc, &mbmi->second_mv.as_mv,
- (const MV_CONTEXT_HP *) mvc_hp);
+ if (xd->allow_high_precision_mv) {
+ read_mv_hp(bc, &mbmi->second_mv.as_mv,
+ (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount_hp[0][mv_max_hp+(mbmi->second_mv.as_mv.row)]++;
- cm->fc.MVcount_hp[1][mv_max_hp+(mbmi->second_mv.as_mv.col)]++;
+ cm->fc.MVcount_hp[0][mv_max_hp + (mbmi->second_mv.as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp + (mbmi->second_mv.as_mv.col)]++;
#endif
- }
- else
+ } else
#endif
- {
- read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
+ {
+ read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
- cm->fc.MVcount[0][mv_max+(mbmi->second_mv.as_mv.row>>1)]++;
- cm->fc.MVcount[1][mv_max+(mbmi->second_mv.as_mv.col>>1)]++;
+ cm->fc.MVcount[0][mv_max + (mbmi->second_mv.as_mv.row >> 1)]++;
+ cm->fc.MVcount[1][mv_max + (mbmi->second_mv.as_mv.col >> 1)]++;
#endif
- }
- mbmi->second_mv.as_mv.row += best_mv_second.as_mv.row;
- mbmi->second_mv.as_mv.col += best_mv_second.as_mv.col;
- mbmi->need_to_clamp_secondmv |= vp8_check_mv_bounds(&mbmi->second_mv,
- mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
- }
- break;
- default:;
- #if CONFIG_DEBUG
- assert(0);
- #endif
+ }
+ mbmi->second_mv.as_mv.row += best_mv_second.as_mv.row;
+ mbmi->second_mv.as_mv.col += best_mv_second.as_mv.col;
+ mbmi->need_to_clamp_secondmv |= vp8_check_mv_bounds(&mbmi->second_mv,
+ mb_to_left_edge,
+ mb_to_right_edge,
+ mb_to_top_edge,
+ mb_to_bottom_edge);
}
+ break;
+ default:
+;
+#if CONFIG_DEBUG
+ assert(0);
+#endif
}
- else
- {
- /* required for left and above block mv */
- mbmi->mv.as_int = 0;
-
- if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
- mbmi->mode = (MB_PREDICTION_MODE)
- get_segdata( xd, mbmi->segment_id, SEG_LVL_MODE );
- else
- {
- mbmi->mode = (MB_PREDICTION_MODE)
- vp8_read_ymode(bc, pbi->common.fc.ymode_prob);
+ } else {
+ /* required for left and above block mv */
+ mbmi->mv.as_int = 0;
+
+ if (segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE))
+ mbmi->mode = (MB_PREDICTION_MODE)
+ get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE);
+ else {
+ mbmi->mode = (MB_PREDICTION_MODE)
+ vp8_read_ymode(bc, pbi->common.fc.ymode_prob);
#if CONFIG_ADAPTIVE_ENTROPY
- pbi->common.fc.ymode_counts[mbmi->mode]++;
+ pbi->common.fc.ymode_counts[mbmi->mode]++;
#endif
- }
+ }
#if CONFIG_COMP_INTRA_PRED
- mbmi->second_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
+ mbmi->second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- // If MB mode is BPRED read the block modes
- if (mbmi->mode == B_PRED)
- {
- int j = 0;
+ // If MB mode is BPRED read the block modes
+ if (mbmi->mode == B_PRED) {
+ int j = 0;
#if CONFIG_COMP_INTRA_PRED
- int use_comp_pred = vp8_read(bc, 128);
+ int use_comp_pred = vp8_read(bc, 128);
#endif
- do
- {
- mi->bmi[j].as_mode.first = (B_PREDICTION_MODE)vp8_read_bmode(bc, pbi->common.fc.bmode_prob);
+ do {
+ mi->bmi[j].as_mode.first = (B_PREDICTION_MODE)vp8_read_bmode(bc, pbi->common.fc.bmode_prob);
#if CONFIG_ADAPTIVE_ENTROPY
- pbi->common.fc.bmode_counts[mi->bmi[j].as_mode.first]++;
+ pbi->common.fc.bmode_counts[mi->bmi[j].as_mode.first]++;
#endif
#if CONFIG_COMP_INTRA_PRED
- if (use_comp_pred)
- {
- mi->bmi[j].as_mode.second = (B_PREDICTION_MODE)vp8_read_bmode(bc, pbi->common.fc.bmode_prob);
- }
- else
- {
- mi->bmi[j].as_mode.second = (B_PREDICTION_MODE) (B_DC_PRED - 1);
- }
-#endif
- }
- while (++j < 16);
+ if (use_comp_pred) {
+ mi->bmi[j].as_mode.second = (B_PREDICTION_MODE)vp8_read_bmode(bc, pbi->common.fc.bmode_prob);
+ } else {
+ mi->bmi[j].as_mode.second = (B_PREDICTION_MODE)(B_DC_PRED - 1);
}
+#endif
+ } while (++j < 16);
+ }
- if(mbmi->mode == I8X8_PRED)
- {
- int i;
- int mode8x8;
- for(i=0;i<4;i++)
- {
- int ib = vp8_i8x8_block[i];
- mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
- mi->bmi[ib+0].as_mode.first= mode8x8;
- mi->bmi[ib+1].as_mode.first= mode8x8;
- mi->bmi[ib+4].as_mode.first= mode8x8;
- mi->bmi[ib+5].as_mode.first= mode8x8;
+ if (mbmi->mode == I8X8_PRED) {
+ int i;
+ int mode8x8;
+ for (i = 0; i < 4; i++) {
+ int ib = vp8_i8x8_block[i];
+ mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
+ mi->bmi[ib + 0].as_mode.first = mode8x8;
+ mi->bmi[ib + 1].as_mode.first = mode8x8;
+ mi->bmi[ib + 4].as_mode.first = mode8x8;
+ mi->bmi[ib + 5].as_mode.first = mode8x8;
#if CONFIG_ADAPTIVE_ENTROPY
- pbi->common.fc.i8x8_mode_counts[mode8x8]++;
+ pbi->common.fc.i8x8_mode_counts[mode8x8]++;
#endif
#if CONFIG_COMP_INTRA_PRED
- mi->bmi[ib+0].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- mi->bmi[ib+1].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- mi->bmi[ib+4].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
- mi->bmi[ib+5].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
+ mi->bmi[ib + 0].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ mi->bmi[ib + 1].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ mi->bmi[ib + 4].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ mi->bmi[ib + 5].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- }
- }
- else
- {
- mbmi->uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc,
- pbi->common.fc.uv_mode_prob[mbmi->mode]);
+ }
+ } else {
+ mbmi->uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc,
+ pbi->common.fc.uv_mode_prob[mbmi->mode]);
#if CONFIG_ADAPTIVE_ENTROPY
- pbi->common.fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++;
+ pbi->common.fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++;
#endif
- }
+ }
#if CONFIG_COMP_INTRA_PRED
- mbmi->second_uv_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
+ mbmi->second_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- }
+ }
}
-void vp8_decode_mode_mvs(VP8D_COMP *pbi)
-{
- int i;
- VP8_COMMON *cm = &pbi->common;
- MODE_INFO *mi = cm->mi;
- MACROBLOCKD *const xd = &pbi->mb;
- int sb_row, sb_col;
- int sb_rows = (cm->mb_rows + 1)>>1;
- int sb_cols = (cm->mb_cols + 1)>>1;
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
-
- MODE_INFO *prev_mi = cm->prev_mi;
-
- mb_mode_mv_init(pbi);
-
- if(cm->frame_type==KEY_FRAME && !cm->kf_ymode_probs_update)
- {
- cm->kf_ymode_probs_index = vp8_read_literal(&pbi->bc, 3);
- }
-
- for (sb_row=0; sb_row<sb_rows; sb_row++)
- {
- int mb_col = 0;
- int mb_row = (sb_row <<1);
-
- for (sb_col=0; sb_col<sb_cols; sb_col++)
- {
- for ( i=0; i<4; i++ )
- {
- int mb_to_top_edge;
- int mb_to_bottom_edge;
+void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
+ int i;
+ VP8_COMMON *cm = &pbi->common;
+ MODE_INFO *mi = cm->mi;
+ MACROBLOCKD *const xd = &pbi->mb;
+ int sb_row, sb_col;
+ int sb_rows = (cm->mb_rows + 1) >> 1;
+ int sb_cols = (cm->mb_cols + 1) >> 1;
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
+
+ MODE_INFO *prev_mi = cm->prev_mi;
+
+ mb_mode_mv_init(pbi);
+
+ if (cm->frame_type == KEY_FRAME && !cm->kf_ymode_probs_update) {
+ cm->kf_ymode_probs_index = vp8_read_literal(&pbi->bc, 3);
+ }
+
+ for (sb_row = 0; sb_row < sb_rows; sb_row++) {
+ int mb_col = 0;
+ int mb_row = (sb_row << 1);
+
+ for (sb_col = 0; sb_col < sb_cols; sb_col++) {
+ for (i = 0; i < 4; i++) {
+ int mb_to_top_edge;
+ int mb_to_bottom_edge;
+
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_extended = dy * cm->mode_info_stride + dx;
+
+ if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols)) {
+ /* next macroblock */
+ mb_row += dy;
+ mb_col += dx;
+ mi += offset_extended;
+ prev_mi += offset_extended;
+ continue;
+ }
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * cm->mode_info_stride + dx;
+ // Make sure the MacroBlockD mode info pointer is set correctly
+ xd->mode_info_context = mi;
+ xd->prev_mode_info_context = prev_mi;
- if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols))
- {
- /* next macroblock */
- mb_row += dy;
- mb_col += dx;
- mi += offset_extended;
- prev_mi += offset_extended;
- continue;
- }
+ pbi->mb.mb_to_top_edge = mb_to_top_edge = -((mb_row * 16)) << 3;
+ mb_to_top_edge -= LEFT_TOP_MARGIN;
- // Make sure the MacroBlockD mode info pointer is set correctly
- xd->mode_info_context = mi;
- xd->prev_mode_info_context = prev_mi;
-
- pbi->mb.mb_to_top_edge = mb_to_top_edge = -((mb_row * 16)) << 3;
- mb_to_top_edge -= LEFT_TOP_MARGIN;
-
- pbi->mb.mb_to_bottom_edge =
- mb_to_bottom_edge =
- ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
- mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
-
- if(cm->frame_type == KEY_FRAME)
- vp8_kfread_modes(pbi, mi, mb_row, mb_col);
- else
- read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row,
- mb_col);
-
- /* next macroblock */
- mb_row += dy;
- mb_col += dx;
- mi += offset_extended;
- prev_mi += offset_extended;
- }
- }
+ pbi->mb.mb_to_bottom_edge =
+ mb_to_bottom_edge =
+ ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
+ mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
- mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
- prev_mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
+ if (cm->frame_type == KEY_FRAME)
+ vp8_kfread_modes(pbi, mi, mb_row, mb_col);
+ else
+ read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row,
+ mb_col);
+
+ /* next macroblock */
+ mb_row += dy;
+ mb_col += dx;
+ mi += offset_extended;
+ prev_mi += offset_extended;
+ }
}
+
+ mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
+ prev_mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
+ }
}
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index 50b6cf916..9eb42cc2e 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -48,133 +48,117 @@ int dec_debug = 0;
#if CONFIG_NEWUPDATE
-static int merge_index(int v, int n, int modulus)
-{
- int max1 = (n-1 - modulus/2)/modulus + 1;
- if (v < max1) v = v * modulus + modulus/2;
- else
- {
- int w;
- v -= max1;
- w = v;
- v += (v + modulus-modulus/2)/modulus;
- while (v%modulus == modulus/2 ||
- w != v - (v + modulus-modulus/2)/modulus) v++;
- }
- return v;
+static int merge_index(int v, int n, int modulus) {
+ int max1 = (n - 1 - modulus / 2) / modulus + 1;
+ if (v < max1) v = v * modulus + modulus / 2;
+ else {
+ int w;
+ v -= max1;
+ w = v;
+ v += (v + modulus - modulus / 2) / modulus;
+ while (v % modulus == modulus / 2 ||
+ w != v - (v + modulus - modulus / 2) / modulus) v++;
+ }
+ return v;
}
-static int inv_remap_prob(int v, int m)
-{
- const int n = 256;
- const int modulus = MODULUS_PARAM;
- int i, w;
- v = merge_index(v, n-1, modulus);
- if ((m<<1)<=n) {
- i = inv_recenter_nonneg(v+1, m);
- } else {
- i = n-1-inv_recenter_nonneg(v+1, n-1-m);
- }
- return i;
+static int inv_remap_prob(int v, int m) {
+ const int n = 256;
+ const int modulus = MODULUS_PARAM;
+ int i, w;
+ v = merge_index(v, n - 1, modulus);
+ if ((m << 1) <= n) {
+ i = inv_recenter_nonneg(v + 1, m);
+ } else {
+ i = n - 1 - inv_recenter_nonneg(v + 1, n - 1 - m);
+ }
+ return i;
}
-static vp8_prob read_prob_diff_update(vp8_reader *const bc, int oldp)
-{
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- return (vp8_prob)inv_remap_prob(delp, oldp);
+static vp8_prob read_prob_diff_update(vp8_reader *const bc, int oldp) {
+ int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
+ return (vp8_prob)inv_remap_prob(delp, oldp);
}
#endif
-void vp8cx_init_de_quantizer(VP8D_COMP *pbi)
-{
- int i;
- int Q;
- VP8_COMMON *const pc = & pbi->common;
-
- for (Q = 0; Q < QINDEX_RANGE; Q++)
- {
- pc->Y1dequant[Q][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q);
- pc->Y2dequant[Q][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q);
- pc->UVdequant[Q][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q);
-
- /* all the ac values = ; */
- for (i = 1; i < 16; i++)
- {
- int rc = vp8_default_zig_zag1d[i];
-
- pc->Y1dequant[Q][rc] = (short)vp8_ac_yquant(Q);
- pc->Y2dequant[Q][rc] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q);
- pc->UVdequant[Q][rc] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q);
- }
+void vp8cx_init_de_quantizer(VP8D_COMP *pbi) {
+ int i;
+ int Q;
+ VP8_COMMON *const pc = & pbi->common;
+
+ for (Q = 0; Q < QINDEX_RANGE; Q++) {
+ pc->Y1dequant[Q][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q);
+ pc->Y2dequant[Q][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q);
+ pc->UVdequant[Q][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q);
+
+ /* all the ac values =; */
+ for (i = 1; i < 16; i++) {
+ int rc = vp8_default_zig_zag1d[i];
+
+ pc->Y1dequant[Q][rc] = (short)vp8_ac_yquant(Q);
+ pc->Y2dequant[Q][rc] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q);
+ pc->UVdequant[Q][rc] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q);
}
+ }
}
-void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
-{
- int i;
- int QIndex;
- VP8_COMMON *const pc = & pbi->common;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- // Set the Q baseline allowing for any segment level adjustment
- if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
- {
- /* Abs Value */
- if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
- QIndex = get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
-
- /* Delta Value */
- else
- {
- QIndex = pc->base_qindex +
- get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
- QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */
- }
+void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) {
+ int i;
+ int QIndex;
+ VP8_COMMON *const pc = & pbi->common;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ // Set the Q baseline allowing for any segment level adjustment
+ if (segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
+ /* Abs Value */
+ if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
+ QIndex = get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
+
+ /* Delta Value */
+ else {
+ QIndex = pc->base_qindex +
+ get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
+ QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */
}
- else
- QIndex = pc->base_qindex;
+ } else
+ QIndex = pc->base_qindex;
- /* Set up the block level dequant pointers */
- for (i = 0; i < 16; i++)
- {
- xd->block[i].dequant = pc->Y1dequant[QIndex];
- }
+ /* Set up the block level dequant pointers */
+ for (i = 0; i < 16; i++) {
+ xd->block[i].dequant = pc->Y1dequant[QIndex];
+ }
#if CONFIG_LOSSLESS
- if(!QIndex)
- {
- pbi->common.rtcd.idct.idct1 = vp8_short_inv_walsh4x4_1_x8_c;
- pbi->common.rtcd.idct.idct16 = vp8_short_inv_walsh4x4_x8_c;
- pbi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_inv_walsh_add_c;
- pbi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_lossless_c;
- pbi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_lossless_c;
- pbi->dequant.idct_add = vp8_dequant_idct_add_lossless_c;
- pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_lossless_c;
- pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_lossless_c;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_lossless_c;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_lossless_c;
- }
- else
- {
- pbi->common.rtcd.idct.idct1 = vp8_short_idct4x4llm_1_c;
- pbi->common.rtcd.idct.idct16 = vp8_short_idct4x4llm_c;
- pbi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
- pbi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
- pbi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_c;
- pbi->dequant.idct_add = vp8_dequant_idct_add_c;
- pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_c;
- pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_c;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_c;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_c;
- }
+ if (!QIndex) {
+ pbi->common.rtcd.idct.idct1 = vp8_short_inv_walsh4x4_1_x8_c;
+ pbi->common.rtcd.idct.idct16 = vp8_short_inv_walsh4x4_x8_c;
+ pbi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_inv_walsh_add_c;
+ pbi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_lossless_c;
+ pbi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_lossless_c;
+ pbi->dequant.idct_add = vp8_dequant_idct_add_lossless_c;
+ pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_lossless_c;
+ pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_lossless_c;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_lossless_c;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_lossless_c;
+ } else {
+ pbi->common.rtcd.idct.idct1 = vp8_short_idct4x4llm_1_c;
+ pbi->common.rtcd.idct.idct16 = vp8_short_idct4x4llm_c;
+ pbi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
+ pbi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
+ pbi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_c;
+ pbi->dequant.idct_add = vp8_dequant_idct_add_c;
+ pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_c;
+ pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_c;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_c;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_c;
+ }
#endif
- for (i = 16; i < 24; i++)
- {
- xd->block[i].dequant = pc->UVdequant[QIndex];
- }
+ for (i = 16; i < 24; i++) {
+ xd->block[i].dequant = pc->UVdequant[QIndex];
+ }
- xd->block[24].dequant = pc->Y2dequant[QIndex];
+ xd->block[24].dequant = pc->Y2dequant[QIndex];
}
@@ -187,343 +171,292 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
/* skip_recon_mb() is Modified: Instead of writing the result to predictor buffer and then copying it
* to dst buffer, we can write the result directly to dst buffer. This eliminates unnecessary copy.
*/
-static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *xd)
-{
- if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
- {
- RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv_s)(xd);
- RECON_INVOKE(&pbi->common.rtcd.recon,
- build_intra_predictors_mby_s)(xd);
- }
- else
- {
- vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
- xd->dst.u_buffer, xd->dst.v_buffer,
- xd->dst.y_stride, xd->dst.uv_stride);
-
- if (xd->mode_info_context->mbmi.second_ref_frame)
- {
- vp8_build_2nd_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
- xd->dst.u_buffer, xd->dst.v_buffer,
- xd->dst.y_stride, xd->dst.uv_stride);
- }
+static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *xd) {
+ if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
+ RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv_s)(xd);
+ RECON_INVOKE(&pbi->common.rtcd.recon,
+ build_intra_predictors_mby_s)(xd);
+ } else {
+ vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
+ xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.y_stride, xd->dst.uv_stride);
+
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ vp8_build_2nd_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
+ xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.y_stride, xd->dst.uv_stride);
}
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int i, j;
- printf("Generating predictors\n");
- for (i=0;i<16;i++) {
- for (j=0;j<16;j++) printf("%3d ", xd->dst.y_buffer[i*xd->dst.y_stride+j]);
- printf("\n");
- }
- }
+ if (dec_debug) {
+ int i, j;
+ printf("Generating predictors\n");
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) printf("%3d ", xd->dst.y_buffer[i * xd->dst.y_stride + j]);
+ printf("\n");
+ }
+ }
#endif
}
extern const int vp8_i8x8_block[4];
static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
- unsigned int mb_idx)
-{
- int eobtotal = 0;
- MB_PREDICTION_MODE mode;
- int i;
- int tx_type;
-
- if(pbi->common.frame_type == KEY_FRAME)
- {
- if( pbi->common.txfm_mode==ALLOW_8X8 &&
- xd->mode_info_context->mbmi.mode != I8X8_PRED &&
- xd->mode_info_context->mbmi.mode != B_PRED)
- xd->mode_info_context->mbmi.txfm_size = TX_8X8;
- else
- xd->mode_info_context->mbmi.txfm_size = TX_4X4;
- }
+ unsigned int mb_idx) {
+ int eobtotal = 0;
+ MB_PREDICTION_MODE mode;
+ int i;
+ int tx_type;
+
+ if (pbi->common.frame_type == KEY_FRAME) {
+ if (pbi->common.txfm_mode == ALLOW_8X8 &&
+ xd->mode_info_context->mbmi.mode != I8X8_PRED &&
+ xd->mode_info_context->mbmi.mode != B_PRED)
+ xd->mode_info_context->mbmi.txfm_size = TX_8X8;
else
- {
- if( pbi->common.txfm_mode==ONLY_4X4 )
- {
- xd->mode_info_context->mbmi.txfm_size = TX_4X4;
- }
- else if( pbi->common.txfm_mode == ALLOW_8X8 )
- {
- if( xd->mode_info_context->mbmi.mode ==B_PRED
- ||xd->mode_info_context->mbmi.mode ==I8X8_PRED
- ||xd->mode_info_context->mbmi.mode ==SPLITMV)
- xd->mode_info_context->mbmi.txfm_size = TX_4X4;
- else
- xd->mode_info_context->mbmi.txfm_size = TX_8X8;
- }
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ } else {
+ if (pbi->common.txfm_mode == ONLY_4X4) {
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ } else if (pbi->common.txfm_mode == ALLOW_8X8) {
+ if (xd->mode_info_context->mbmi.mode == B_PRED
+ || xd->mode_info_context->mbmi.mode == I8X8_PRED
+ || xd->mode_info_context->mbmi.mode == SPLITMV)
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ else
+ xd->mode_info_context->mbmi.txfm_size = TX_8X8;
}
- tx_type = xd->mode_info_context->mbmi.txfm_size;
-
- if (xd->mode_info_context->mbmi.mb_skip_coeff)
- {
- vp8_reset_mb_tokens_context(xd);
+ }
+ tx_type = xd->mode_info_context->mbmi.txfm_size;
+
+ if (xd->mode_info_context->mbmi.mb_skip_coeff) {
+ vp8_reset_mb_tokens_context(xd);
+ } else if (!vp8dx_bool_error(xd->current_bc)) {
+ for (i = 0; i < 25; i++) {
+ xd->block[i].eob = 0;
+ xd->eobs[i] = 0;
}
- else if (!vp8dx_bool_error(xd->current_bc))
- {
- for(i = 0; i < 25; i++)
- {
- xd->block[i].eob = 0;
- xd->eobs[i] = 0;
- }
- if ( tx_type == TX_8X8 )
- eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd);
- else
- eobtotal = vp8_decode_mb_tokens(pbi, xd);
+ if (tx_type == TX_8X8)
+ eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd);
+ else
+ eobtotal = vp8_decode_mb_tokens(pbi, xd);
#ifdef DEC_DEBUG
- if (dec_debug) {
- printf("\nTokens (%d)\n", eobtotal);
- for (i =0; i<400; i++) {
- printf("%3d ", xd->qcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("\n");
- }
-#endif
+ if (dec_debug) {
+ printf("\nTokens (%d)\n", eobtotal);
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", xd->qcoeff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("\n");
}
+#endif
+ }
- mode = xd->mode_info_context->mbmi.mode;
+ mode = xd->mode_info_context->mbmi.mode;
- if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
- && mode != I8X8_PRED
- &&!vp8dx_bool_error(xd->current_bc)
- )
- {
- /* Special case: Force the loopfilter to skip when eobtotal and
- * mb_skip_coeff are zero.
- * */
- xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+ if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
+ && mode != I8X8_PRED
+ && !vp8dx_bool_error(xd->current_bc)
+ ) {
+ /* Special case: Force the loopfilter to skip when eobtotal and
+ * mb_skip_coeff are zero.
+ * */
+ xd->mode_info_context->mbmi.mb_skip_coeff = 1;
- skip_recon_mb(pbi, xd);
- return;
- }
+ skip_recon_mb(pbi, xd);
+ return;
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int i, j;
- printf("Generating predictors\n");
- for (i=0;i<16;i++) {
- for (j=0;j<16;j++) printf("%3d ", xd->dst.y_buffer[i*xd->dst.y_stride+j]);
- printf("\n");
- }
- }
+ if (dec_debug) {
+ int i, j;
+ printf("Generating predictors\n");
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) printf("%3d ", xd->dst.y_buffer[i * xd->dst.y_stride + j]);
+ printf("\n");
+ }
+ }
#endif
- if (xd->segmentation_enabled)
- mb_init_dequantizer(pbi, xd);
+ if (xd->segmentation_enabled)
+ mb_init_dequantizer(pbi, xd);
- /* do prediction */
- if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
- {
- if(mode != I8X8_PRED)
- {
- RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv)(xd);
- if (mode != B_PRED)
- {
- RECON_INVOKE(&pbi->common.rtcd.recon,
- build_intra_predictors_mby)(xd);
- }
+ /* do prediction */
+ if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
+ if (mode != I8X8_PRED) {
+ RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv)(xd);
+ if (mode != B_PRED) {
+ RECON_INVOKE(&pbi->common.rtcd.recon,
+ build_intra_predictors_mby)(xd);
+ }
#if 0
- // Intra-modes requiring recon data from top-right
- // MB have been temporarily disabled.
- else
- {
- vp8_intra_prediction_down_copy(xd);
- }
+ // Intra-modes requiring recon data from top-right
+ // MB have been temporarily disabled.
+ else {
+ vp8_intra_prediction_down_copy(xd);
+ }
#endif
- }
}
- else
- {
- vp8_build_inter_predictors_mb(xd);
- }
-
- /* dequantization and idct */
- if (mode == I8X8_PRED)
- {
- for (i = 0; i < 4; i++)
- {
- int ib = vp8_i8x8_block[i];
- const int iblock[4]={0,1,4,5};
- int j;
- int i8x8mode;
- BLOCKD *b;
-
- b = &xd->block[ib];
- i8x8mode= b->bmi.as_mode.first;
- RECON_INVOKE(RTCD_VTABLE(recon), intra8x8_predict)
- (b, i8x8mode, b->predictor);
-
- for(j = 0; j < 4; j++)
- {
- b = &xd->block[ib+iblock[j]];
- if (xd->eobs[ib+iblock[j]] > 1)
- {
- DEQUANT_INVOKE(&pbi->dequant, idct_add)
- (b->qcoeff, b->dequant, b->predictor,
- *(b->base_dst) + b->dst, 16, b->dst_stride);
- }
- else
- {
- IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
- (b->qcoeff[0] * b->dequant[0], b->predictor,
- *(b->base_dst) + b->dst, 16, b->dst_stride);
- ((int *)b->qcoeff)[0] = 0;
- }
- }
-
- b = &xd->block[16+i];
- RECON_INVOKE(RTCD_VTABLE(recon), intra_uv4x4_predict)
- (b, i8x8mode, b->predictor);
- DEQUANT_INVOKE(&pbi->dequant, idct_add)
- (b->qcoeff, b->dequant, b->predictor,
- *(b->base_dst) + b->dst, 8, b->dst_stride);
- b = &xd->block[20+i];
- RECON_INVOKE(RTCD_VTABLE(recon), intra_uv4x4_predict)
- (b, i8x8mode, b->predictor);
- DEQUANT_INVOKE(&pbi->dequant, idct_add)
- (b->qcoeff, b->dequant, b->predictor,
- *(b->base_dst) + b->dst, 8, b->dst_stride);
+ } else {
+ vp8_build_inter_predictors_mb(xd);
+ }
+
+ /* dequantization and idct */
+ if (mode == I8X8_PRED) {
+ for (i = 0; i < 4; i++) {
+ int ib = vp8_i8x8_block[i];
+ const int iblock[4] = {0, 1, 4, 5};
+ int j;
+ int i8x8mode;
+ BLOCKD *b;
+
+ b = &xd->block[ib];
+ i8x8mode = b->bmi.as_mode.first;
+ RECON_INVOKE(RTCD_VTABLE(recon), intra8x8_predict)
+ (b, i8x8mode, b->predictor);
+
+ for (j = 0; j < 4; j++) {
+ b = &xd->block[ib + iblock[j]];
+ if (xd->eobs[ib + iblock[j]] > 1) {
+ DEQUANT_INVOKE(&pbi->dequant, idct_add)
+ (b->qcoeff, b->dequant, b->predictor,
+ *(b->base_dst) + b->dst, 16, b->dst_stride);
+ } else {
+ IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
+ (b->qcoeff[0] * b->dequant[0], b->predictor,
+ *(b->base_dst) + b->dst, 16, b->dst_stride);
+ ((int *)b->qcoeff)[0] = 0;
}
+ }
+
+ b = &xd->block[16 + i];
+ RECON_INVOKE(RTCD_VTABLE(recon), intra_uv4x4_predict)
+ (b, i8x8mode, b->predictor);
+ DEQUANT_INVOKE(&pbi->dequant, idct_add)
+ (b->qcoeff, b->dequant, b->predictor,
+ *(b->base_dst) + b->dst, 8, b->dst_stride);
+ b = &xd->block[20 + i];
+ RECON_INVOKE(RTCD_VTABLE(recon), intra_uv4x4_predict)
+ (b, i8x8mode, b->predictor);
+ DEQUANT_INVOKE(&pbi->dequant, idct_add)
+ (b->qcoeff, b->dequant, b->predictor,
+ *(b->base_dst) + b->dst, 8, b->dst_stride);
}
- else if (mode == B_PRED)
- {
- for (i = 0; i < 16; i++)
- {
- BLOCKD *b = &xd->block[i];
- int b_mode = xd->mode_info_context->bmi[i].as_mode.first;
+ } else if (mode == B_PRED) {
+ for (i = 0; i < 16; i++) {
+ BLOCKD *b = &xd->block[i];
+ int b_mode = xd->mode_info_context->bmi[i].as_mode.first;
#if CONFIG_COMP_INTRA_PRED
- int b_mode2 = xd->mode_info_context->bmi[i].as_mode.second;
+ int b_mode2 = xd->mode_info_context->bmi[i].as_mode.second;
- if (b_mode2 == (B_PREDICTION_MODE) (B_DC_PRED - 1))
- {
+ if (b_mode2 == (B_PREDICTION_MODE)(B_DC_PRED - 1)) {
#endif
- RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict)
- (b, b_mode, b->predictor);
+ RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict)
+ (b, b_mode, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(RTCD_VTABLE(recon), comp_intra4x4_predict)
- (b, b_mode, b_mode2, b->predictor);
- }
+ } else {
+ RECON_INVOKE(RTCD_VTABLE(recon), comp_intra4x4_predict)
+ (b, b_mode, b_mode2, b->predictor);
+ }
#endif
- if (xd->eobs[i] > 1)
- {
- DEQUANT_INVOKE(&pbi->dequant, idct_add)
- (b->qcoeff, b->dequant, b->predictor,
- *(b->base_dst) + b->dst, 16, b->dst_stride);
- }
- else
- {
- IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
- (b->qcoeff[0] * b->dequant[0], b->predictor,
- *(b->base_dst) + b->dst, 16, b->dst_stride);
- ((int *)b->qcoeff)[0] = 0;
- }
- }
- }
- else if (mode == SPLITMV)
- {
- DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block)
- (xd->qcoeff, xd->block[0].dequant,
- xd->predictor, xd->dst.y_buffer,
- xd->dst.y_stride, xd->eobs);
+ if (xd->eobs[i] > 1) {
+ DEQUANT_INVOKE(&pbi->dequant, idct_add)
+ (b->qcoeff, b->dequant, b->predictor,
+ *(b->base_dst) + b->dst, 16, b->dst_stride);
+ } else {
+ IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
+ (b->qcoeff[0] * b->dequant[0], b->predictor,
+ *(b->base_dst) + b->dst, 16, b->dst_stride);
+ ((int *)b->qcoeff)[0] = 0;
+ }
}
- else
- {
- BLOCKD *b = &xd->block[24];
+ } else if (mode == SPLITMV) {
+ DEQUANT_INVOKE(&pbi->dequant, idct_add_y_block)
+ (xd->qcoeff, xd->block[0].dequant,
+ xd->predictor, xd->dst.y_buffer,
+ xd->dst.y_stride, xd->eobs);
+ } else {
+ BLOCKD *b = &xd->block[24];
- if( tx_type == TX_8X8 )
- {
- DEQUANT_INVOKE(&pbi->dequant, block_2x2)(b);
+ if (tx_type == TX_8X8) {
+ DEQUANT_INVOKE(&pbi->dequant, block_2x2)(b);
#ifdef DEC_DEBUG
- if (dec_debug)
- {
- int j;
- printf("DQcoeff Haar\n");
- for (j=0;j<16;j++) {
- printf("%d ", b->dqcoeff[j]);
- }
- printf("\n");
- }
-#endif
- IDCT_INVOKE(RTCD_VTABLE(idct), ihaar2)(&b->dqcoeff[0], b->diff, 8);
- ((int *)b->qcoeff)[0] = 0;//2nd order block are set to 0 after inverse transform
- ((int *)b->qcoeff)[1] = 0;
- ((int *)b->qcoeff)[2] = 0;
- ((int *)b->qcoeff)[3] = 0;
- ((int *)b->qcoeff)[4] = 0;
- ((int *)b->qcoeff)[5] = 0;
- ((int *)b->qcoeff)[6] = 0;
- ((int *)b->qcoeff)[7] = 0;
- DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block_8x8)
- (xd->qcoeff, xd->block[0].dequant,
- xd->predictor, xd->dst.y_buffer,
- xd->dst.y_stride, xd->eobs, xd->block[24].diff, xd);
- }
- else
- {
- DEQUANT_INVOKE(&pbi->dequant, block)(b);
- if (xd->eobs[24] > 1)
- {
- IDCT_INVOKE(RTCD_VTABLE(idct), iwalsh16)(&b->dqcoeff[0], b->diff);
- ((int *)b->qcoeff)[0] = 0;
- ((int *)b->qcoeff)[1] = 0;
- ((int *)b->qcoeff)[2] = 0;
- ((int *)b->qcoeff)[3] = 0;
- ((int *)b->qcoeff)[4] = 0;
- ((int *)b->qcoeff)[5] = 0;
- ((int *)b->qcoeff)[6] = 0;
- ((int *)b->qcoeff)[7] = 0;
- }
- else
- {
- IDCT_INVOKE(RTCD_VTABLE(idct), iwalsh1)(&b->dqcoeff[0], b->diff);
- ((int *)b->qcoeff)[0] = 0;
- }
-
- DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block)
- (xd->qcoeff, xd->block[0].dequant,
- xd->predictor, xd->dst.y_buffer,
- xd->dst.y_stride, xd->eobs, xd->block[24].diff);
+ if (dec_debug) {
+ int j;
+ printf("DQcoeff Haar\n");
+ for (j = 0; j < 16; j++) {
+ printf("%d ", b->dqcoeff[j]);
}
+ printf("\n");
+ }
+#endif
+ IDCT_INVOKE(RTCD_VTABLE(idct), ihaar2)(&b->dqcoeff[0], b->diff, 8);
+ ((int *)b->qcoeff)[0] = 0;// 2nd order block are set to 0 after inverse transform
+ ((int *)b->qcoeff)[1] = 0;
+ ((int *)b->qcoeff)[2] = 0;
+ ((int *)b->qcoeff)[3] = 0;
+ ((int *)b->qcoeff)[4] = 0;
+ ((int *)b->qcoeff)[5] = 0;
+ ((int *)b->qcoeff)[6] = 0;
+ ((int *)b->qcoeff)[7] = 0;
+ DEQUANT_INVOKE(&pbi->dequant, dc_idct_add_y_block_8x8)
+ (xd->qcoeff, xd->block[0].dequant,
+ xd->predictor, xd->dst.y_buffer,
+ xd->dst.y_stride, xd->eobs, xd->block[24].diff, xd);
+ } else {
+ DEQUANT_INVOKE(&pbi->dequant, block)(b);
+ if (xd->eobs[24] > 1) {
+ IDCT_INVOKE(RTCD_VTABLE(idct), iwalsh16)(&b->dqcoeff[0], b->diff);
+ ((int *)b->qcoeff)[0] = 0;
+ ((int *)b->qcoeff)[1] = 0;
+ ((int *)b->qcoeff)[2] = 0;
+ ((int *)b->qcoeff)[3] = 0;
+ ((int *)b->qcoeff)[4] = 0;
+ ((int *)b->qcoeff)[5] = 0;
+ ((int *)b->qcoeff)[6] = 0;
+ ((int *)b->qcoeff)[7] = 0;
+ } else {
+ IDCT_INVOKE(RTCD_VTABLE(idct), iwalsh1)(&b->dqcoeff[0], b->diff);
+ ((int *)b->qcoeff)[0] = 0;
+ }
+
+ DEQUANT_INVOKE(&pbi->dequant, dc_idct_add_y_block)
+ (xd->qcoeff, xd->block[0].dequant,
+ xd->predictor, xd->dst.y_buffer,
+ xd->dst.y_stride, xd->eobs, xd->block[24].diff);
}
-
- if( tx_type == TX_8X8 )
- DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block_8x8)//
- (xd->qcoeff+16*16, xd->block[16].dequant,
- xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer,
- xd->dst.uv_stride, xd->eobs+16, xd);//
- else if(xd->mode_info_context->mbmi.mode!=I8X8_PRED)
- DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block)
- (xd->qcoeff+16*16, xd->block[16].dequant,
- xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer,
- xd->dst.uv_stride, xd->eobs+16);
+ }
+
+ if (tx_type == TX_8X8)
+ DEQUANT_INVOKE(&pbi->dequant, idct_add_uv_block_8x8) //
+ (xd->qcoeff + 16 * 16, xd->block[16].dequant,
+ xd->predictor + 16 * 16, xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.uv_stride, xd->eobs + 16, xd); //
+ else if (xd->mode_info_context->mbmi.mode != I8X8_PRED)
+ DEQUANT_INVOKE(&pbi->dequant, idct_add_uv_block)
+ (xd->qcoeff + 16 * 16, xd->block[16].dequant,
+ xd->predictor + 16 * 16, xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.uv_stride, xd->eobs + 16);
}
-static int get_delta_q(vp8_reader *bc, int prev, int *q_update)
-{
- int ret_val = 0;
+static int get_delta_q(vp8_reader *bc, int prev, int *q_update) {
+ int ret_val = 0;
- if (vp8_read_bit(bc))
- {
- ret_val = vp8_read_literal(bc, 4);
+ if (vp8_read_bit(bc)) {
+ ret_val = vp8_read_literal(bc, 4);
- if (vp8_read_bit(bc))
- ret_val = -ret_val;
- }
+ if (vp8_read_bit(bc))
+ ret_val = -ret_val;
+ }
- /* Trigger a quantizer update if the delta-q value has changed */
- if (ret_val != prev)
- *q_update = 1;
+ /* Trigger a quantizer update if the delta-q value has changed */
+ if (ret_val != prev)
+ *q_update = 1;
- return ret_val;
+ return ret_val;
}
#ifdef PACKET_TESTING
@@ -533,1059 +466,960 @@ FILE *vpxlog = 0;
/* Decode a row of Superblocks (2x2 region of MBs) */
static void
-decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd)
-{
- int i;
- int sb_col;
- int mb_row, mb_col;
- int recon_yoffset, recon_uvoffset;
- int ref_fb_idx = pc->lst_fb_idx;
- int dst_fb_idx = pc->new_fb_idx;
- int recon_y_stride = pc->yv12_fb[ref_fb_idx].y_stride;
- int recon_uv_stride = pc->yv12_fb[ref_fb_idx].uv_stride;
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
- int sb_cols = (pc->mb_cols + 1)>>1;
- ENTROPY_CONTEXT_PLANES left_context[2];
-
- // For a SB there are 2 left contexts, each pertaining to a MB row within
- vpx_memset(left_context, 0, sizeof(left_context));
-
- mb_row = mbrow;
- mb_col = 0;
-
- for (sb_col=0; sb_col<sb_cols; sb_col++)
- {
- // Process the 4 MBs within the SB in the order:
- // top-left, top-right, bottom-left, bottom-right
- for ( i=0; i<4; i++ )
- {
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * xd->mode_info_stride + dx;
-
- if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols))
- {
- // MB lies outside frame, skip on to next
- mb_row += dy;
- mb_col += dx;
- xd->mode_info_context += offset_extended;
- continue;
- }
+decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
+ int i;
+ int sb_col;
+ int mb_row, mb_col;
+ int recon_yoffset, recon_uvoffset;
+ int ref_fb_idx = pc->lst_fb_idx;
+ int dst_fb_idx = pc->new_fb_idx;
+ int recon_y_stride = pc->yv12_fb[ref_fb_idx].y_stride;
+ int recon_uv_stride = pc->yv12_fb[ref_fb_idx].uv_stride;
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
+ int sb_cols = (pc->mb_cols + 1) >> 1;
+ ENTROPY_CONTEXT_PLANES left_context[2];
+
+ // For a SB there are 2 left contexts, each pertaining to a MB row within
+ vpx_memset(left_context, 0, sizeof(left_context));
+
+ mb_row = mbrow;
+ mb_col = 0;
+
+ for (sb_col = 0; sb_col < sb_cols; sb_col++) {
+ // Process the 4 MBs within the SB in the order:
+ // top-left, top-right, bottom-left, bottom-right
+ for (i = 0; i < 4; i++) {
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_extended = dy * xd->mode_info_stride + dx;
+
+ if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols)) {
+ // MB lies outside frame, skip on to next
+ mb_row += dy;
+ mb_col += dx;
+ xd->mode_info_context += offset_extended;
+ continue;
+ }
#ifdef DEC_DEBUG
- dec_debug = (pc->current_video_frame==0 && mb_row==0 && mb_col==0);
+ dec_debug = (pc->current_video_frame == 0 && mb_row == 0 && mb_col == 0);
#endif
- // Copy in the appropriate left context for this MB row
- vpx_memcpy (&pc->left_context,
- &left_context[i>>1],
- sizeof(ENTROPY_CONTEXT_PLANES));
-
- // Set above context pointer
- xd->above_context = pc->above_context + mb_col;
-
- /* Distance of Mb to the various image edges.
- * These are specified to 8th pel as they are always compared to
- * values that are in 1/8th pel units
- */
- xd->mb_to_top_edge = -((mb_row * 16)) << 3;
- xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
-
- xd->mb_to_left_edge = -((mb_col * 16) << 3);
- xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
-
- xd->up_available = (mb_row != 0);
- xd->left_available = (mb_col != 0);
-
- update_blockd_bmi(xd);
-
- recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
-
- xd->dst.y_buffer = pc->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
- xd->dst.u_buffer = pc->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
- xd->dst.v_buffer = pc->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
-
- /* Select the appropriate reference frame for this MB */
- if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
- ref_fb_idx = pc->lst_fb_idx;
- else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
- ref_fb_idx = pc->gld_fb_idx;
- else
- ref_fb_idx = pc->alt_fb_idx;
-
- xd->pre.y_buffer = pc->yv12_fb[ref_fb_idx].y_buffer +recon_yoffset;
- xd->pre.u_buffer = pc->yv12_fb[ref_fb_idx].u_buffer +recon_uvoffset;
- xd->pre.v_buffer = pc->yv12_fb[ref_fb_idx].v_buffer +recon_uvoffset;
-
- if (xd->mode_info_context->mbmi.second_ref_frame)
- {
- int second_ref_fb_idx;
-
- /* Select the appropriate reference frame for this MB */
- if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = pc->lst_fb_idx;
- else if (xd->mode_info_context->mbmi.second_ref_frame ==
- GOLDEN_FRAME)
- second_ref_fb_idx = pc->gld_fb_idx;
- else
- second_ref_fb_idx = pc->alt_fb_idx;
-
- xd->second_pre.y_buffer =
- pc->yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
- xd->second_pre.u_buffer =
- pc->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset;
- xd->second_pre.v_buffer =
- pc->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset;
- }
-
- if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME)
- {
- /* propagate errors from reference frames */
- xd->corrupted |= pc->yv12_fb[ref_fb_idx].corrupted;
- }
-
- decode_macroblock(pbi, xd, mb_row * pc->mb_cols + mb_col);
-
- /* check if the boolean decoder has suffered an error */
- xd->corrupted |= vp8dx_bool_error(xd->current_bc);
-
- // Store the modified left context for the MB row locally
- vpx_memcpy (&left_context[i>>1],
- &pc->left_context,
- sizeof(ENTROPY_CONTEXT_PLANES));
-
- // skip to next MB
- xd->mode_info_context += offset_extended;
- mb_row += dy;
- mb_col += dx;
- }
+ // Copy in the appropriate left context for this MB row
+ vpx_memcpy(&pc->left_context,
+ &left_context[i >> 1],
+ sizeof(ENTROPY_CONTEXT_PLANES));
+
+ // Set above context pointer
+ xd->above_context = pc->above_context + mb_col;
+
+ /* Distance of Mb to the various image edges.
+ * These are specified to 8th pel as they are always compared to
+ * values that are in 1/8th pel units
+ */
+ xd->mb_to_top_edge = -((mb_row * 16)) << 3;
+ xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
+
+ xd->mb_to_left_edge = -((mb_col * 16) << 3);
+ xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
+
+ xd->up_available = (mb_row != 0);
+ xd->left_available = (mb_col != 0);
+
+ update_blockd_bmi(xd);
+
+ recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
+ recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
+
+ xd->dst.y_buffer = pc->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
+ xd->dst.u_buffer = pc->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
+ xd->dst.v_buffer = pc->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
+
+ /* Select the appropriate reference frame for this MB */
+ if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
+ ref_fb_idx = pc->lst_fb_idx;
+ else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
+ ref_fb_idx = pc->gld_fb_idx;
+ else
+ ref_fb_idx = pc->alt_fb_idx;
+
+ xd->pre.y_buffer = pc->yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
+ xd->pre.u_buffer = pc->yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
+ xd->pre.v_buffer = pc->yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset;
+
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ int second_ref_fb_idx;
+
+ /* Select the appropriate reference frame for this MB */
+ if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
+ second_ref_fb_idx = pc->lst_fb_idx;
+ else if (xd->mode_info_context->mbmi.second_ref_frame ==
+ GOLDEN_FRAME)
+ second_ref_fb_idx = pc->gld_fb_idx;
+ else
+ second_ref_fb_idx = pc->alt_fb_idx;
+
+ xd->second_pre.y_buffer =
+ pc->yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
+ xd->second_pre.u_buffer =
+ pc->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset;
+ xd->second_pre.v_buffer =
+ pc->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset;
+ }
+
+ if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME) {
+ /* propagate errors from reference frames */
+ xd->corrupted |= pc->yv12_fb[ref_fb_idx].corrupted;
+ }
+
+ decode_macroblock(pbi, xd, mb_row * pc->mb_cols + mb_col);
+
+ /* check if the boolean decoder has suffered an error */
+ xd->corrupted |= vp8dx_bool_error(xd->current_bc);
+
+ // Store the modified left context for the MB row locally
+ vpx_memcpy(&left_context[i >> 1],
+ &pc->left_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
+
+ // skip to next MB
+ xd->mode_info_context += offset_extended;
+ mb_row += dy;
+ mb_col += dx;
}
+ }
- /* skip prediction column */
- xd->mode_info_context += 1 - (pc->mb_cols & 0x1) + xd->mode_info_stride;
+ /* skip prediction column */
+ xd->mode_info_context += 1 - (pc->mb_cols & 0x1) + xd->mode_info_stride;
}
-static unsigned int read_partition_size(const unsigned char *cx_size)
-{
- const unsigned int size =
- cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16);
- return size;
+static unsigned int read_partition_size(const unsigned char *cx_size) {
+ const unsigned int size =
+ cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16);
+ return size;
}
static int read_is_valid(const unsigned char *start,
size_t len,
- const unsigned char *end)
-{
- return (start + len > start && start + len <= end);
+ const unsigned char *end) {
+ return (start + len > start && start + len <= end);
}
static void setup_token_decoder(VP8D_COMP *pbi,
- const unsigned char *cx_data)
-{
- VP8_COMMON *pc = &pbi->common;
- const unsigned char *user_data_end = pbi->Source + pbi->source_sz;
- vp8_reader *bool_decoder;
- const unsigned char *partition;
-
- ptrdiff_t partition_size;
- ptrdiff_t bytes_left;
-
- // Dummy read for now
- vp8_read_literal(&pbi->bc, 2);
-
- // Set up pointers to token partition
- partition = cx_data;
- bool_decoder = &pbi->bc2;
- bytes_left = user_data_end - partition;
- partition_size = bytes_left;
-
- /* Validate the calculated partition length. If the buffer
- * described by the partition can't be fully read, then restrict
- * it to the portion that can be (for EC mode) or throw an error.
- */
- if (!read_is_valid(partition, partition_size, user_data_end))
- {
- vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
- "Truncated packet or corrupt partition "
- "%d length", 1);
- }
-
- if (vp8dx_start_decode(bool_decoder, partition, partition_size))
- vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate bool decoder %d", 1);
+ const unsigned char *cx_data) {
+ VP8_COMMON *pc = &pbi->common;
+ const unsigned char *user_data_end = pbi->Source + pbi->source_sz;
+ vp8_reader *bool_decoder;
+ const unsigned char *partition;
+
+ ptrdiff_t partition_size;
+ ptrdiff_t bytes_left;
+
+ // Dummy read for now
+ vp8_read_literal(&pbi->bc, 2);
+
+ // Set up pointers to token partition
+ partition = cx_data;
+ bool_decoder = &pbi->bc2;
+ bytes_left = user_data_end - partition;
+ partition_size = bytes_left;
+
+ /* Validate the calculated partition length. If the buffer
+ * described by the partition can't be fully read, then restrict
+ * it to the portion that can be (for EC mode) or throw an error.
+ */
+ if (!read_is_valid(partition, partition_size, user_data_end)) {
+ vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+ "Truncated packet or corrupt partition "
+ "%d length", 1);
+ }
+
+ if (vp8dx_start_decode(bool_decoder, partition, partition_size))
+ vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate bool decoder %d", 1);
}
-static void init_frame(VP8D_COMP *pbi)
-{
- VP8_COMMON *const pc = & pbi->common;
- MACROBLOCKD *const xd = & pbi->mb;
+static void init_frame(VP8D_COMP *pbi) {
+ VP8_COMMON *const pc = & pbi->common;
+ MACROBLOCKD *const xd = & pbi->mb;
- if (pc->frame_type == KEY_FRAME)
- {
- /* Various keyframe initializations */
- vpx_memcpy(pc->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
+ if (pc->frame_type == KEY_FRAME) {
+ /* Various keyframe initializations */
+ vpx_memcpy(pc->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
#if CONFIG_HIGH_PRECISION_MV
- vpx_memcpy(pc->fc.mvc_hp, vp8_default_mv_context_hp,
- sizeof(vp8_default_mv_context_hp));
+ vpx_memcpy(pc->fc.mvc_hp, vp8_default_mv_context_hp,
+ sizeof(vp8_default_mv_context_hp));
#endif
- vp8_init_mbmode_probs(pc);
+ vp8_init_mbmode_probs(pc);
- vp8_default_coef_probs(pc);
- vp8_kf_default_bmode_probs(pc->kf_bmode_prob);
+ vp8_default_coef_probs(pc);
+ vp8_kf_default_bmode_probs(pc->kf_bmode_prob);
- // Reset the segment feature data to the default stats:
- // Features disabled, 0, with delta coding (Default state).
- clearall_segfeatures( xd );
+ // Reset the segment feature data to the default stats:
+ // Features disabled, 0, with delta coding (Default state).
+ clearall_segfeatures(xd);
- xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
+ xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
- /* reset the mode ref deltasa for loop filter */
- vpx_memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
- vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
+ /* reset the mode ref deltasa for loop filter */
+ vpx_memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
+ vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
- /* All buffers are implicitly updated on key frames. */
- pc->refresh_golden_frame = 1;
- pc->refresh_alt_ref_frame = 1;
- pc->copy_buffer_to_gf = 0;
- pc->copy_buffer_to_arf = 0;
+ /* All buffers are implicitly updated on key frames. */
+ pc->refresh_golden_frame = 1;
+ pc->refresh_alt_ref_frame = 1;
+ pc->copy_buffer_to_gf = 0;
+ pc->copy_buffer_to_arf = 0;
- /* Note that Golden and Altref modes cannot be used on a key frame so
- * ref_frame_sign_bias[] is undefined and meaningless
- */
- pc->ref_frame_sign_bias[GOLDEN_FRAME] = 0;
- pc->ref_frame_sign_bias[ALTREF_FRAME] = 0;
+ /* Note that Golden and Altref modes cannot be used on a key frame so
+ * ref_frame_sign_bias[] is undefined and meaningless
+ */
+ pc->ref_frame_sign_bias[GOLDEN_FRAME] = 0;
+ pc->ref_frame_sign_bias[ALTREF_FRAME] = 0;
- vp8_init_mode_contexts(&pbi->common);
- vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
- vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
+ vp8_init_mode_contexts(&pbi->common);
+ vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
+ vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
- vpx_memcpy( pbi->common.fc.vp8_mode_contexts,
- pbi->common.fc.mode_context,
- sizeof(pbi->common.fc.mode_context));
- }
- else
- {
+ vpx_memcpy(pbi->common.fc.vp8_mode_contexts,
+ pbi->common.fc.mode_context,
+ sizeof(pbi->common.fc.mode_context));
+ } else {
- if (!pc->use_bilinear_mc_filter)
+ if (!pc->use_bilinear_mc_filter)
#if CONFIG_ENHANCED_INTERP
- pc->mcomp_filter_type = EIGHTTAP;
+ pc->mcomp_filter_type = EIGHTTAP;
#else
- pc->mcomp_filter_type = SIXTAP;
+ pc->mcomp_filter_type = SIXTAP;
#endif
- else
- pc->mcomp_filter_type = BILINEAR;
-
- /* To enable choice of different interploation filters */
- if (pc->mcomp_filter_type == SIXTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg16x16);
- }
+ else
+ pc->mcomp_filter_type = BILINEAR;
+
+ /* To enable choice of different interploation filters */
+ if (pc->mcomp_filter_type == SIXTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg16x16);
+ }
#if CONFIG_ENHANCED_INTERP
- else if (pc->mcomp_filter_type == EIGHTTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- RTCD_VTABLE(subpix), eighttap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
- RTCD_VTABLE(subpix), eighttap_avg16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4);
- }
- else if (pc->mcomp_filter_type == EIGHTTAP_SHARP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4_sharp);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4_sharp);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8_sharp);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16_sharp);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4_sharp);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- RTCD_VTABLE(subpix), eighttap_avg8x8_sharp);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
- RTCD_VTABLE(subpix), eighttap_avg16x16_sharp);
- }
+ else if (pc->mcomp_filter_type == EIGHTTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ RTCD_VTABLE(subpix), eighttap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ RTCD_VTABLE(subpix), eighttap_avg16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4);
+ } else if (pc->mcomp_filter_type == EIGHTTAP_SHARP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4_sharp);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4_sharp);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8_sharp);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16_sharp);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4_sharp);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ RTCD_VTABLE(subpix), eighttap_avg8x8_sharp);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ RTCD_VTABLE(subpix), eighttap_avg16x16_sharp);
+ }
#endif
- else
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg16x16);
- }
+ else {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg16x16);
}
+ }
- xd->left_context = &pc->left_context;
- xd->mode_info_context = pc->mi;
- xd->frame_type = pc->frame_type;
- xd->mode_info_context->mbmi.mode = DC_PRED;
- xd->mode_info_stride = pc->mode_info_stride;
- xd->corrupted = 0; /* init without corruption */
+ xd->left_context = &pc->left_context;
+ xd->mode_info_context = pc->mi;
+ xd->frame_type = pc->frame_type;
+ xd->mode_info_context->mbmi.mode = DC_PRED;
+ xd->mode_info_stride = pc->mode_info_stride;
+ xd->corrupted = 0; /* init without corruption */
- xd->fullpixel_mask = 0xffffffff;
- if(pc->full_pixel)
- xd->fullpixel_mask = 0xfffffff8;
+ xd->fullpixel_mask = 0xffffffff;
+ if (pc->full_pixel)
+ xd->fullpixel_mask = 0xfffffff8;
}
#if CONFIG_NEWUPDATE
-static void read_coef_probs3(VP8D_COMP *pbi)
-{
- const vp8_prob grpupd = 216;
- int i, j, k, l;
- vp8_reader *const bc = & pbi->bc;
- VP8_COMMON *const pc = & pbi->common;
- for (i = 0; i < BLOCK_TYPES; i++)
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- if(vp8_read(bc, grpupd))
- {
- //printf("Decoding %d\n", l);
- for (j = !i; j < COEF_BANDS; j++)
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+static void read_coef_probs3(VP8D_COMP *pbi) {
+ const vp8_prob grpupd = 216;
+ int i, j, k, l;
+ vp8_reader *const bc = & pbi->bc;
+ VP8_COMMON *const pc = & pbi->common;
+ for (i = 0; i < BLOCK_TYPES; i++)
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ if (vp8_read(bc, grpupd)) {
+ // printf("Decoding %d\n", l);
+ for (j = !i; j < COEF_BANDS; j++)
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- {
- vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
- int u = vp8_read(bc, COEF_UPDATE_PROB);
- if (u) *p = read_prob_diff_update(bc, *p);
- }
- }
+ {
+ vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
+ int u = vp8_read(bc, COEF_UPDATE_PROB);
+ if (u) *p = read_prob_diff_update(bc, *p);
}
- }
+ }
+ }
+ }
- if(pbi->common.txfm_mode == ALLOW_8X8)
- {
- for (i = 0; i < BLOCK_TYPES_8X8; i++)
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- if(vp8_read(bc, grpupd))
- {
- for (j = !i; j < COEF_BANDS; j++)
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+ if (pbi->common.txfm_mode == ALLOW_8X8) {
+ for (i = 0; i < BLOCK_TYPES_8X8; i++)
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ if (vp8_read(bc, grpupd)) {
+ for (j = !i; j < COEF_BANDS; j++)
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- {
- vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
- int u = vp8_read(bc, COEF_UPDATE_PROB_8X8);
- if (u) *p = read_prob_diff_update(bc, *p);
- }
- }
- }
+ {
+ vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
+ int u = vp8_read(bc, COEF_UPDATE_PROB_8X8);
+ if (u) *p = read_prob_diff_update(bc, *p);
+ }
}
- }
+ }
+ }
+ }
}
-static void read_coef_probs2(VP8D_COMP *pbi)
-{
- const vp8_prob grpupd = 192;
- int i, j, k, l;
- vp8_reader *const bc = & pbi->bc;
- VP8_COMMON *const pc = & pbi->common;
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- if(vp8_read(bc, grpupd))
- {
- //printf("Decoding %d\n", l);
- for (i = 0; i < BLOCK_TYPES; i++)
- for (j = !i; j < COEF_BANDS; j++)
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+static void read_coef_probs2(VP8D_COMP *pbi) {
+ const vp8_prob grpupd = 192;
+ int i, j, k, l;
+ vp8_reader *const bc = & pbi->bc;
+ VP8_COMMON *const pc = & pbi->common;
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ if (vp8_read(bc, grpupd)) {
+ // printf("Decoding %d\n", l);
+ for (i = 0; i < BLOCK_TYPES; i++)
+ for (j = !i; j < COEF_BANDS; j++)
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- {
- vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
- int u = vp8_read(bc, COEF_UPDATE_PROB);
- if (u) *p = read_prob_diff_update(bc, *p);
- }
- }
- }
- }
- if(pbi->common.txfm_mode == ALLOW_8X8)
- {
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- if(vp8_read(bc, grpupd))
{
- for (i = 0; i < BLOCK_TYPES_8X8; i++)
- for (j = !i; j < COEF_BANDS; j++)
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+ vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
+ int u = vp8_read(bc, COEF_UPDATE_PROB);
+ if (u) *p = read_prob_diff_update(bc, *p);
+ }
+ }
+ }
+ }
+ if (pbi->common.txfm_mode == ALLOW_8X8) {
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ if (vp8_read(bc, grpupd)) {
+ for (i = 0; i < BLOCK_TYPES_8X8; i++)
+ for (j = !i; j < COEF_BANDS; j++)
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- {
- vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
+ {
+ vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
- int u = vp8_read(bc, COEF_UPDATE_PROB_8X8);
- if (u) *p = read_prob_diff_update(bc, *p);
- }
- }
+ int u = vp8_read(bc, COEF_UPDATE_PROB_8X8);
+ if (u) *p = read_prob_diff_update(bc, *p);
+ }
}
- }
+ }
}
+ }
}
#endif
-static void read_coef_probs(VP8D_COMP *pbi)
-{
- int i, j, k, l;
- vp8_reader *const bc = & pbi->bc;
- VP8_COMMON *const pc = & pbi->common;
-
- {
- if(vp8_read_bit(bc))
- {
- /* read coef probability tree */
- for (i = 0; i < BLOCK_TYPES; i++)
+static void read_coef_probs(VP8D_COMP *pbi) {
+ int i, j, k, l;
+ vp8_reader *const bc = & pbi->bc;
+ VP8_COMMON *const pc = & pbi->common;
+
+ {
+ if (vp8_read_bit(bc)) {
+ /* read coef probability tree */
+ for (i = 0; i < BLOCK_TYPES; i++)
#if CONFIG_NEWUPDATE
- for (j = !i; j < COEF_BANDS; j++)
+ for (j = !i; j < COEF_BANDS; j++)
#else
- for (j = 0; j < COEF_BANDS; j++)
+ for (j = 0; j < COEF_BANDS; j++)
#endif
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
- if (vp8_read(bc, COEF_UPDATE_PROB))
- {
+ if (vp8_read(bc, COEF_UPDATE_PROB)) {
#if CONFIG_NEWUPDATE
- *p = read_prob_diff_update(bc, *p);
+ *p = read_prob_diff_update(bc, *p);
#else
- *p = (vp8_prob)vp8_read_literal(bc, 8);
+ *p = (vp8_prob)vp8_read_literal(bc, 8);
#endif
- }
- }
- }
- }
+ }
+ }
+ }
}
+ }
- if(pbi->common.txfm_mode == ALLOW_8X8 && vp8_read_bit(bc))
- {
- // read coef probability tree
- for (i = 0; i < BLOCK_TYPES_8X8; i++)
+ if (pbi->common.txfm_mode == ALLOW_8X8 && vp8_read_bit(bc)) {
+ // read coef probability tree
+ for (i = 0; i < BLOCK_TYPES_8X8; i++)
#if CONFIG_NEWUPDATE
- for (j = !i; j < COEF_BANDS; j++)
+ for (j = !i; j < COEF_BANDS; j++)
#else
- for (j = 0; j < COEF_BANDS; j++)
+ for (j = 0; j < COEF_BANDS; j++)
#endif
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >= 3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
- for (l = 0; l < ENTROPY_NODES; l++)
- {
+ for (l = 0; l < ENTROPY_NODES; l++) {
- vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
+ vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
- if (vp8_read(bc, COEF_UPDATE_PROB_8X8))
- {
+ if (vp8_read(bc, COEF_UPDATE_PROB_8X8)) {
#if CONFIG_NEWUPDATE
- *p = read_prob_diff_update(bc, *p);
+ *p = read_prob_diff_update(bc, *p);
#else
- *p = (vp8_prob)vp8_read_literal(bc, 8);
+ *p = (vp8_prob)vp8_read_literal(bc, 8);
#endif
- }
- }
- }
- }
+ }
+ }
+ }
+ }
}
-int vp8_decode_frame(VP8D_COMP *pbi)
-{
- vp8_reader *const bc = & pbi->bc;
- VP8_COMMON *const pc = & pbi->common;
- MACROBLOCKD *const xd = & pbi->mb;
- const unsigned char *data = (const unsigned char *)pbi->Source;
- const unsigned char *data_end = data + pbi->source_sz;
- ptrdiff_t first_partition_length_in_bytes = 0;
+int vp8_decode_frame(VP8D_COMP *pbi) {
+ vp8_reader *const bc = & pbi->bc;
+ VP8_COMMON *const pc = & pbi->common;
+ MACROBLOCKD *const xd = & pbi->mb;
+ const unsigned char *data = (const unsigned char *)pbi->Source;
+ const unsigned char *data_end = data + pbi->source_sz;
+ ptrdiff_t first_partition_length_in_bytes = 0;
+
+ int mb_row;
+ int i, j;
+ int corrupt_tokens = 0;
+
+ /* start with no corruption of current frame */
+ xd->corrupted = 0;
+ pc->yv12_fb[pc->new_fb_idx].corrupted = 0;
+
+ if (data_end - data < 3) {
+ vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+ "Truncated packet");
+ } else {
+ pc->last_frame_type = pc->frame_type;
+ pc->frame_type = (FRAME_TYPE)(data[0] & 1);
+ pc->version = (data[0] >> 1) & 7;
+ pc->show_frame = (data[0] >> 4) & 1;
+ first_partition_length_in_bytes =
+ (data[0] | (data[1] << 8) | (data[2] << 16)) >> 5;
+
+ if ((data + first_partition_length_in_bytes > data_end
+ || data + first_partition_length_in_bytes < data))
+ vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+ "Truncated packet or corrupt partition 0 length");
+
+ data += 3;
+
+ vp8_setup_version(pc);
- int mb_row;
- int i, j;
- int corrupt_tokens = 0;
+ if (pc->frame_type == KEY_FRAME) {
+ const int Width = pc->Width;
+ const int Height = pc->Height;
+
+ /* vet via sync code */
+ /* When error concealment is enabled we should only check the sync
+ * code if we have enough bits available
+ */
+ if (data + 3 < data_end) {
+ if (data[0] != 0x9d || data[1] != 0x01 || data[2] != 0x2a)
+ vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM,
+ "Invalid frame sync code");
+ }
+
+ /* If error concealment is enabled we should only parse the new size
+ * if we have enough data. Otherwise we will end up with the wrong
+ * size.
+ */
+ if (data + 6 < data_end) {
+ pc->Width = (data[3] | (data[4] << 8)) & 0x3fff;
+ pc->horiz_scale = data[4] >> 6;
+ pc->Height = (data[5] | (data[6] << 8)) & 0x3fff;
+ pc->vert_scale = data[6] >> 6;
+ }
+ data += 7;
+
+ if (Width != pc->Width || Height != pc->Height) {
+ if (pc->Width <= 0) {
+ pc->Width = Width;
+ vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+ "Invalid frame width");
+ }
- /* start with no corruption of current frame */
- xd->corrupted = 0;
- pc->yv12_fb[pc->new_fb_idx].corrupted = 0;
+ if (pc->Height <= 0) {
+ pc->Height = Height;
+ vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
+ "Invalid frame height");
+ }
- if (data_end - data < 3)
- {
- vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
- "Truncated packet");
+ if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height))
+ vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate frame buffers");
+ }
}
- else
- {
- pc->last_frame_type = pc->frame_type;
- pc->frame_type = (FRAME_TYPE)(data[0] & 1);
- pc->version = (data[0] >> 1) & 7;
- pc->show_frame = (data[0] >> 4) & 1;
- first_partition_length_in_bytes =
- (data[0] | (data[1] << 8) | (data[2] << 16)) >> 5;
-
- if ((data + first_partition_length_in_bytes > data_end
- || data + first_partition_length_in_bytes < data))
- vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
- "Truncated packet or corrupt partition 0 length");
-
- data += 3;
-
- vp8_setup_version(pc);
-
- if (pc->frame_type == KEY_FRAME)
- {
- const int Width = pc->Width;
- const int Height = pc->Height;
-
- /* vet via sync code */
- /* When error concealment is enabled we should only check the sync
- * code if we have enough bits available
- */
- if (data + 3 < data_end)
- {
- if (data[0] != 0x9d || data[1] != 0x01 || data[2] != 0x2a)
- vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM,
- "Invalid frame sync code");
- }
+ }
- /* If error concealment is enabled we should only parse the new size
- * if we have enough data. Otherwise we will end up with the wrong
- * size.
- */
- if (data + 6 < data_end)
- {
- pc->Width = (data[3] | (data[4] << 8)) & 0x3fff;
- pc->horiz_scale = data[4] >> 6;
- pc->Height = (data[5] | (data[6] << 8)) & 0x3fff;
- pc->vert_scale = data[6] >> 6;
- }
- data += 7;
+ if ((!pbi->decoded_key_frame && pc->frame_type != KEY_FRAME) ||
+ pc->Width == 0 || pc->Height == 0) {
+ return -1;
+ }
- if (Width != pc->Width || Height != pc->Height)
- {
- if (pc->Width <= 0)
- {
- pc->Width = Width;
- vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
- "Invalid frame width");
- }
-
- if (pc->Height <= 0)
- {
- pc->Height = Height;
- vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
- "Invalid frame height");
- }
-
- if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height))
- vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate frame buffers");
- }
- }
- }
+ init_frame(pbi);
- if ((!pbi->decoded_key_frame && pc->frame_type != KEY_FRAME) ||
- pc->Width == 0 || pc->Height == 0)
- {
- return -1;
- }
+ if (vp8dx_start_decode(bc, data, data_end - data))
+ vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate bool decoder 0");
+ if (pc->frame_type == KEY_FRAME) {
+ pc->clr_type = (YUV_TYPE)vp8_read_bit(bc);
+ pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc);
+ }
- init_frame(pbi);
+ /* Is segmentation enabled */
+ xd->segmentation_enabled = (unsigned char)vp8_read_bit(bc);
- if (vp8dx_start_decode(bc, data, data_end - data))
- vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate bool decoder 0");
- if (pc->frame_type == KEY_FRAME) {
- pc->clr_type = (YUV_TYPE)vp8_read_bit(bc);
- pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc);
- }
+ if (xd->segmentation_enabled) {
+ // Read whether or not the segmentation map is being explicitly
+ // updated this frame.
+ xd->update_mb_segmentation_map = (unsigned char)vp8_read_bit(bc);
- /* Is segmentation enabled */
- xd->segmentation_enabled = (unsigned char)vp8_read_bit(bc);
+ // If so what method will be used.
+ if (xd->update_mb_segmentation_map)
+ pc->temporal_update = (unsigned char)vp8_read_bit(bc);
- if (xd->segmentation_enabled)
- {
- // Read whether or not the segmentation map is being explicitly
- // updated this frame.
- xd->update_mb_segmentation_map = (unsigned char)vp8_read_bit(bc);
+ // Is the segment data being updated
+ xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
- // If so what method will be used.
- if ( xd->update_mb_segmentation_map )
- pc->temporal_update = (unsigned char)vp8_read_bit(bc);
+ if (xd->update_mb_segmentation_data) {
+ int data;
- // Is the segment data being updated
- xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
+ xd->mb_segment_abs_delta = (unsigned char)vp8_read_bit(bc);
- if (xd->update_mb_segmentation_data)
- {
- int data;
+ clearall_segfeatures(xd);
- xd->mb_segment_abs_delta = (unsigned char)vp8_read_bit(bc);
+ // For each segmentation...
+ for (i = 0; i < MAX_MB_SEGMENTS; i++) {
+ // For each of the segments features...
+ for (j = 0; j < SEG_LVL_MAX; j++) {
- clearall_segfeatures( xd );
+#if CONFIG_FEATUREUPDATES
+ // feature updated?
+ if (vp8_read_bit(bc)) {
+ int active = 1;
- // For each segmentation...
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- {
- // For each of the segments features...
- for (j = 0; j < SEG_LVL_MAX; j++)
- {
+ if (segfeature_active(xd, i, j))
+ active = vp8_read_bit(bc);
-#if CONFIG_FEATUREUPDATES
- // feature updated?
- if (vp8_read_bit(bc))
- {
- int active=1;
-
- if ( segfeature_active( xd, i, j ))
- active=vp8_read_bit(bc);
-
- // Is the feature enabled
- if (active)
- {
- // Update the feature data and mask
- enable_segfeature(xd, i, j);
-
- data = (signed char)vp8_read_literal(
- bc, seg_feature_data_bits(j));
-
- // Is the segment data signed..
- if ( is_segfeature_signed(j) )
- {
- if (vp8_read_bit(bc))
- data = - data;
- }
- }
- else
- data = 0;
-
- set_segdata(xd, i, j, data);
- }
+ // Is the feature enabled
+ if (active) {
+ // Update the feature data and mask
+ enable_segfeature(xd, i, j);
-#else
- // Is the feature enabled
- if (vp8_read_bit(bc))
- {
- // Update the feature data and mask
- enable_segfeature(xd, i, j);
-
- data = (signed char)vp8_read_literal(
- bc, seg_feature_data_bits(j));
-
- // Is the segment data signed..
- if ( is_segfeature_signed(j) )
- {
- if (vp8_read_bit(bc))
- data = - data;
- }
- }
- else
- data = 0;
-
- set_segdata(xd, i, j, data);
-#endif
- }
- }
- }
+ data = (signed char)vp8_read_literal(
+ bc, seg_feature_data_bits(j));
- if (xd->update_mb_segmentation_map)
- {
- // Which macro block level features are enabled
- vpx_memset(xd->mb_segment_tree_probs, 255,
- sizeof(xd->mb_segment_tree_probs));
- vpx_memset(pc->segment_pred_probs, 255,
- sizeof(pc->segment_pred_probs));
-
- // Read the probs used to decode the segment id for each macro
- // block.
- for (i = 0; i < MB_FEATURE_TREE_PROBS; i++)
- {
- // If not explicitly set value is defaulted to 255 by
- //memset above
+ // Is the segment data signed..
+ if (is_segfeature_signed(j)) {
if (vp8_read_bit(bc))
- xd->mb_segment_tree_probs[i] =
- (vp8_prob)vp8_read_literal(bc, 8);
- }
+ data = - data;
+ }
+ } else
+ data = 0;
- // If predictive coding of segment map is enabled read the
- // prediction probabilities.
- if ( pc->temporal_update )
- {
- // Read the prediction probs needed to decode the segment id
- // when predictive coding enabled
- for (i = 0; i < PREDICTION_PROBS; i++)
- {
- // If not explicitly set value is defaulted to 255 by
- // memset above
- if (vp8_read_bit(bc))
- pc->segment_pred_probs[i] =
- (vp8_prob)vp8_read_literal(bc, 8);
- }
+ set_segdata(xd, i, j, data);
+ }
+
+#else
+ // Is the feature enabled
+ if (vp8_read_bit(bc)) {
+ // Update the feature data and mask
+ enable_segfeature(xd, i, j);
+
+ data = (signed char)vp8_read_literal(
+ bc, seg_feature_data_bits(j));
+
+ // Is the segment data signed..
+ if (is_segfeature_signed(j)) {
+ if (vp8_read_bit(bc))
+ data = - data;
}
+ } else
+ data = 0;
+
+ set_segdata(xd, i, j, data);
+#endif
}
+ }
}
- // Read common prediction model status flag probability updates for the
- // reference frame
- if ( pc->frame_type == KEY_FRAME )
- {
- // Set the prediction probabilities to defaults
- pc->ref_pred_probs[0] = 120;
- pc->ref_pred_probs[1] = 80;
- pc->ref_pred_probs[2] = 40;
- }
- else
- {
- for (i = 0; i < PREDICTION_PROBS; i++)
- {
- if ( vp8_read_bit(bc) )
- pc->ref_pred_probs[i] = (vp8_prob)vp8_read_literal(bc, 8);
+ if (xd->update_mb_segmentation_map) {
+ // Which macro block level features are enabled
+ vpx_memset(xd->mb_segment_tree_probs, 255,
+ sizeof(xd->mb_segment_tree_probs));
+ vpx_memset(pc->segment_pred_probs, 255,
+ sizeof(pc->segment_pred_probs));
+
+ // Read the probs used to decode the segment id for each macro
+ // block.
+ for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
+ // If not explicitly set value is defaulted to 255 by
+ // memset above
+ if (vp8_read_bit(bc))
+ xd->mb_segment_tree_probs[i] =
+ (vp8_prob)vp8_read_literal(bc, 8);
+ }
+
+ // If predictive coding of segment map is enabled read the
+ // prediction probabilities.
+ if (pc->temporal_update) {
+ // Read the prediction probs needed to decode the segment id
+ // when predictive coding enabled
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ // If not explicitly set value is defaulted to 255 by
+ // memset above
+ if (vp8_read_bit(bc))
+ pc->segment_pred_probs[i] =
+ (vp8_prob)vp8_read_literal(bc, 8);
}
+ }
}
+ }
+
+ // Read common prediction model status flag probability updates for the
+ // reference frame
+ if (pc->frame_type == KEY_FRAME) {
+ // Set the prediction probabilities to defaults
+ pc->ref_pred_probs[0] = 120;
+ pc->ref_pred_probs[1] = 80;
+ pc->ref_pred_probs[2] = 40;
+ } else {
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ if (vp8_read_bit(bc))
+ pc->ref_pred_probs[i] = (vp8_prob)vp8_read_literal(bc, 8);
+ }
+ }
- /* Read the loop filter level and type */
- pc->txfm_mode = (TXFM_MODE) vp8_read_bit(bc);
+ /* Read the loop filter level and type */
+ pc->txfm_mode = (TXFM_MODE) vp8_read_bit(bc);
- pc->filter_type = (LOOPFILTERTYPE) vp8_read_bit(bc);
- pc->filter_level = vp8_read_literal(bc, 6);
- pc->sharpness_level = vp8_read_literal(bc, 3);
+ pc->filter_type = (LOOPFILTERTYPE) vp8_read_bit(bc);
+ pc->filter_level = vp8_read_literal(bc, 6);
+ pc->sharpness_level = vp8_read_literal(bc, 3);
- /* Read in loop filter deltas applied at the MB level based on mode or ref frame. */
- xd->mode_ref_lf_delta_update = 0;
- xd->mode_ref_lf_delta_enabled = (unsigned char)vp8_read_bit(bc);
+ /* Read in loop filter deltas applied at the MB level based on mode or ref frame. */
+ xd->mode_ref_lf_delta_update = 0;
+ xd->mode_ref_lf_delta_enabled = (unsigned char)vp8_read_bit(bc);
- if (xd->mode_ref_lf_delta_enabled)
- {
- /* Do the deltas need to be updated */
- xd->mode_ref_lf_delta_update = (unsigned char)vp8_read_bit(bc);
+ if (xd->mode_ref_lf_delta_enabled) {
+ /* Do the deltas need to be updated */
+ xd->mode_ref_lf_delta_update = (unsigned char)vp8_read_bit(bc);
- if (xd->mode_ref_lf_delta_update)
- {
- /* Send update */
- for (i = 0; i < MAX_REF_LF_DELTAS; i++)
- {
- if (vp8_read_bit(bc))
- {
- /*sign = vp8_read_bit( bc );*/
- xd->ref_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
+ if (xd->mode_ref_lf_delta_update) {
+ /* Send update */
+ for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
+ if (vp8_read_bit(bc)) {
+ /*sign = vp8_read_bit( bc );*/
+ xd->ref_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
- if (vp8_read_bit(bc)) /* Apply sign */
- xd->ref_lf_deltas[i] = xd->ref_lf_deltas[i] * -1;
- }
- }
+ if (vp8_read_bit(bc)) /* Apply sign */
+ xd->ref_lf_deltas[i] = xd->ref_lf_deltas[i] * -1;
+ }
+ }
- /* Send update */
- for (i = 0; i < MAX_MODE_LF_DELTAS; i++)
- {
- if (vp8_read_bit(bc))
- {
- /*sign = vp8_read_bit( bc );*/
- xd->mode_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
+ /* Send update */
+ for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
+ if (vp8_read_bit(bc)) {
+ /*sign = vp8_read_bit( bc );*/
+ xd->mode_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
- if (vp8_read_bit(bc)) /* Apply sign */
- xd->mode_lf_deltas[i] = xd->mode_lf_deltas[i] * -1;
- }
- }
+ if (vp8_read_bit(bc)) /* Apply sign */
+ xd->mode_lf_deltas[i] = xd->mode_lf_deltas[i] * -1;
}
+ }
}
-
- setup_token_decoder(pbi, data + first_partition_length_in_bytes);
-
- xd->current_bc = &pbi->bc2;
-
- /* Read the default quantizers. */
- {
- int Q, q_update;
-
- Q = vp8_read_literal(bc, QINDEX_BITS); /* AC 1st order Q = default */
- pc->base_qindex = Q;
- q_update = 0;
- pc->y1dc_delta_q = get_delta_q(bc, pc->y1dc_delta_q, &q_update);
- pc->y2dc_delta_q = get_delta_q(bc, pc->y2dc_delta_q, &q_update);
- pc->y2ac_delta_q = get_delta_q(bc, pc->y2ac_delta_q, &q_update);
- pc->uvdc_delta_q = get_delta_q(bc, pc->uvdc_delta_q, &q_update);
- pc->uvac_delta_q = get_delta_q(bc, pc->uvac_delta_q, &q_update);
-
- if (q_update)
- vp8cx_init_de_quantizer(pbi);
-
- /* MB level dequantizer setup */
- mb_init_dequantizer(pbi, &pbi->mb);
+ }
+
+ setup_token_decoder(pbi, data + first_partition_length_in_bytes);
+
+ xd->current_bc = &pbi->bc2;
+
+ /* Read the default quantizers. */
+ {
+ int Q, q_update;
+
+ Q = vp8_read_literal(bc, QINDEX_BITS); /* AC 1st order Q = default */
+ pc->base_qindex = Q;
+ q_update = 0;
+ pc->y1dc_delta_q = get_delta_q(bc, pc->y1dc_delta_q, &q_update);
+ pc->y2dc_delta_q = get_delta_q(bc, pc->y2dc_delta_q, &q_update);
+ pc->y2ac_delta_q = get_delta_q(bc, pc->y2ac_delta_q, &q_update);
+ pc->uvdc_delta_q = get_delta_q(bc, pc->uvdc_delta_q, &q_update);
+ pc->uvac_delta_q = get_delta_q(bc, pc->uvac_delta_q, &q_update);
+
+ if (q_update)
+ vp8cx_init_de_quantizer(pbi);
+
+ /* MB level dequantizer setup */
+ mb_init_dequantizer(pbi, &pbi->mb);
+ }
+
+ /* Determine if the golden frame or ARF buffer should be updated and how.
+ * For all non key frames the GF and ARF refresh flags and sign bias
+ * flags must be set explicitly.
+ */
+ if (pc->frame_type != KEY_FRAME) {
+ /* Should the GF or ARF be updated from the current frame */
+ pc->refresh_golden_frame = vp8_read_bit(bc);
+ pc->refresh_alt_ref_frame = vp8_read_bit(bc);
+
+ if (pc->refresh_alt_ref_frame) {
+ vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
+ vpx_memcpy(pc->fc.vp8_mode_contexts,
+ pc->fc.mode_context_a,
+ sizeof(pc->fc.vp8_mode_contexts));
+ } else {
+ vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
+ vpx_memcpy(pc->fc.vp8_mode_contexts,
+ pc->fc.mode_context,
+ sizeof(pc->fc.vp8_mode_contexts));
}
- /* Determine if the golden frame or ARF buffer should be updated and how.
- * For all non key frames the GF and ARF refresh flags and sign bias
- * flags must be set explicitly.
- */
- if (pc->frame_type != KEY_FRAME)
- {
- /* Should the GF or ARF be updated from the current frame */
- pc->refresh_golden_frame = vp8_read_bit(bc);
- pc->refresh_alt_ref_frame = vp8_read_bit(bc);
-
- if(pc->refresh_alt_ref_frame)
- {
- vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
- vpx_memcpy( pc->fc.vp8_mode_contexts,
- pc->fc.mode_context_a,
- sizeof(pc->fc.vp8_mode_contexts));
- }
- else
- {
- vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
- vpx_memcpy( pc->fc.vp8_mode_contexts,
- pc->fc.mode_context,
- sizeof(pc->fc.vp8_mode_contexts));
- }
-
- /* Buffer to buffer copy flags. */
- pc->copy_buffer_to_gf = 0;
+ /* Buffer to buffer copy flags. */
+ pc->copy_buffer_to_gf = 0;
- if (!pc->refresh_golden_frame)
- pc->copy_buffer_to_gf = vp8_read_literal(bc, 2);
+ if (!pc->refresh_golden_frame)
+ pc->copy_buffer_to_gf = vp8_read_literal(bc, 2);
- pc->copy_buffer_to_arf = 0;
+ pc->copy_buffer_to_arf = 0;
- if (!pc->refresh_alt_ref_frame)
- pc->copy_buffer_to_arf = vp8_read_literal(bc, 2);
+ if (!pc->refresh_alt_ref_frame)
+ pc->copy_buffer_to_arf = vp8_read_literal(bc, 2);
- pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp8_read_bit(bc);
- pc->ref_frame_sign_bias[ALTREF_FRAME] = vp8_read_bit(bc);
+ pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp8_read_bit(bc);
+ pc->ref_frame_sign_bias[ALTREF_FRAME] = vp8_read_bit(bc);
#if CONFIG_HIGH_PRECISION_MV
- /* Is high precision mv allowed */
- xd->allow_high_precision_mv = (unsigned char)vp8_read_bit(bc);
+ /* Is high precision mv allowed */
+ xd->allow_high_precision_mv = (unsigned char)vp8_read_bit(bc);
#endif
#if CONFIG_ENHANCED_INTERP
- // Read the type of subpel filter to use
- pc->mcomp_filter_type = vp8_read_literal(bc, 2);
- /* To enable choice of different interploation filters */
- if (pc->mcomp_filter_type == SIXTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg16x16);
- }
- else if (pc->mcomp_filter_type == EIGHTTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg16x16);
- }
- else if (pc->mcomp_filter_type == EIGHTTAP_SHARP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4_sharp);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4_sharp);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8_sharp);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16_sharp);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4_sharp);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg8x8_sharp);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg16x16_sharp);
- }
- else
- {
- xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg16x16);
- }
-#endif
- }
-
- pc->refresh_entropy_probs = vp8_read_bit(bc);
- if (pc->refresh_entropy_probs == 0)
- {
- vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
- }
-
- pc->refresh_last_frame = pc->frame_type == KEY_FRAME || vp8_read_bit(bc);
-
- if (0)
- {
- FILE *z = fopen("decodestats.stt", "a");
- fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n",
- pc->current_video_frame,
- pc->frame_type,
- pc->refresh_golden_frame,
- pc->refresh_alt_ref_frame,
- pc->refresh_last_frame,
- pc->base_qindex);
- fclose(z);
+ // Read the type of subpel filter to use
+ pc->mcomp_filter_type = vp8_read_literal(bc, 2);
+ /* To enable choice of different interploation filters */
+ if (pc->mcomp_filter_type == SIXTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap_avg16x16);
+ } else if (pc->mcomp_filter_type == EIGHTTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg16x16);
+ } else if (pc->mcomp_filter_type == EIGHTTAP_SHARP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap4x4_sharp);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x4_sharp);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap8x8_sharp);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap16x16_sharp);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg4x4_sharp);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg8x8_sharp);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), eighttap_avg16x16_sharp);
+ } else {
+ xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear_avg16x16);
}
+#endif
+ }
+
+ pc->refresh_entropy_probs = vp8_read_bit(bc);
+ if (pc->refresh_entropy_probs == 0) {
+ vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
+ }
+
+ pc->refresh_last_frame = pc->frame_type == KEY_FRAME || vp8_read_bit(bc);
+
+ if (0) {
+ FILE *z = fopen("decodestats.stt", "a");
+ fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n",
+ pc->current_video_frame,
+ pc->frame_type,
+ pc->refresh_golden_frame,
+ pc->refresh_alt_ref_frame,
+ pc->refresh_last_frame,
+ pc->base_qindex);
+ fclose(z);
+ }
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_copy(pbi->common.fc.pre_coef_probs, pbi->common.fc.coef_probs);
- vp8_copy(pbi->common.fc.pre_coef_probs_8x8, pbi->common.fc.coef_probs_8x8);
- vp8_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
- vp8_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob);
- vp8_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob);
- vp8_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob);
- vp8_copy(pbi->common.fc.pre_sub_mv_ref_prob, pbi->common.fc.sub_mv_ref_prob);
- vp8_copy(pbi->common.fc.pre_mbsplit_prob, pbi->common.fc.mbsplit_prob);
- vp8_copy(pbi->common.fc.pre_mvc, pbi->common.fc.mvc);
+ vp8_copy(pbi->common.fc.pre_coef_probs, pbi->common.fc.coef_probs);
+ vp8_copy(pbi->common.fc.pre_coef_probs_8x8, pbi->common.fc.coef_probs_8x8);
+ vp8_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
+ vp8_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob);
+ vp8_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob);
+ vp8_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob);
+ vp8_copy(pbi->common.fc.pre_sub_mv_ref_prob, pbi->common.fc.sub_mv_ref_prob);
+ vp8_copy(pbi->common.fc.pre_mbsplit_prob, pbi->common.fc.mbsplit_prob);
+ vp8_copy(pbi->common.fc.pre_mvc, pbi->common.fc.mvc);
#if CONFIG_HIGH_PRECISION_MV
- vp8_copy(pbi->common.fc.pre_mvc_hp, pbi->common.fc.mvc_hp);
+ vp8_copy(pbi->common.fc.pre_mvc_hp, pbi->common.fc.mvc_hp);
#endif
- vp8_zero(pbi->common.fc.coef_counts);
- vp8_zero(pbi->common.fc.coef_counts_8x8);
- vp8_zero(pbi->common.fc.ymode_counts);
- vp8_zero(pbi->common.fc.uv_mode_counts);
- vp8_zero(pbi->common.fc.bmode_counts);
- vp8_zero(pbi->common.fc.i8x8_mode_counts);
- vp8_zero(pbi->common.fc.sub_mv_ref_counts);
- vp8_zero(pbi->common.fc.mbsplit_counts);
- vp8_zero(pbi->common.fc.MVcount);
+ vp8_zero(pbi->common.fc.coef_counts);
+ vp8_zero(pbi->common.fc.coef_counts_8x8);
+ vp8_zero(pbi->common.fc.ymode_counts);
+ vp8_zero(pbi->common.fc.uv_mode_counts);
+ vp8_zero(pbi->common.fc.bmode_counts);
+ vp8_zero(pbi->common.fc.i8x8_mode_counts);
+ vp8_zero(pbi->common.fc.sub_mv_ref_counts);
+ vp8_zero(pbi->common.fc.mbsplit_counts);
+ vp8_zero(pbi->common.fc.MVcount);
#if CONFIG_HIGH_PRECISION_MV
- vp8_zero(pbi->common.fc.MVcount_hp);
+ vp8_zero(pbi->common.fc.MVcount_hp);
#endif
- vp8_zero(pbi->common.fc.mv_ref_ct);
- vp8_zero(pbi->common.fc.mv_ref_ct_a);
+ vp8_zero(pbi->common.fc.mv_ref_ct);
+ vp8_zero(pbi->common.fc.mv_ref_ct_a);
#endif /* CONFIG_ADAPTIVE_ENTROPY */
#if CONFIG_NEWUPDATE && COEFUPDATETYPE == 2
- read_coef_probs2(pbi);
+ read_coef_probs2(pbi);
#elif CONFIG_NEWUPDATE && COEFUPDATETYPE == 3
- read_coef_probs3(pbi);
+ read_coef_probs3(pbi);
#else
- read_coef_probs(pbi);
+ read_coef_probs(pbi);
#endif
- vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
- vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
+ vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
+ vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
- // Create the segmentation map structure and set to 0
- if (!pc->last_frame_seg_map)
- CHECK_MEM_ERROR(pc->last_frame_seg_map,
- vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
+ // Create the segmentation map structure and set to 0
+ if (!pc->last_frame_seg_map)
+ CHECK_MEM_ERROR(pc->last_frame_seg_map,
+ vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
- /* set up frame new frame for intra coded blocks */
- vp8_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]);
+ /* set up frame new frame for intra coded blocks */
+ vp8_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]);
- vp8_setup_block_dptrs(xd);
+ vp8_setup_block_dptrs(xd);
- vp8_build_block_doffsets(xd);
+ vp8_build_block_doffsets(xd);
- /* clear out the coeff buffer */
- vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
+ /* clear out the coeff buffer */
+ vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
- /* Read the mb_no_coeff_skip flag */
- pc->mb_no_coeff_skip = (int)vp8_read_bit(bc);
+ /* Read the mb_no_coeff_skip flag */
+ pc->mb_no_coeff_skip = (int)vp8_read_bit(bc);
- vp8_decode_mode_mvs(pbi);
+ vp8_decode_mode_mvs(pbi);
#if CONFIG_ADAPTIVE_ENTROPY == 0
- if (pc->frame_type != KEY_FRAME)
- {
- vp8_update_mode_context(&pbi->common);
- }
+ if (pc->frame_type != KEY_FRAME) {
+ vp8_update_mode_context(&pbi->common);
+ }
#endif
- vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
+ vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
- // Resset the macroblock mode info context to the start of the list
- xd->mode_info_context = pc->mi;
+ // Resset the macroblock mode info context to the start of the list
+ xd->mode_info_context = pc->mi;
- /* Decode a row of superblocks */
- for (mb_row = 0; mb_row < pc->mb_rows; mb_row+=2)
- {
- decode_sb_row(pbi, pc, mb_row, xd);
- }
- corrupt_tokens |= xd->corrupted;
-
- /* Collect information about decoder corruption. */
- /* 1. Check first boolean decoder for errors. */
- pc->yv12_fb[pc->new_fb_idx].corrupted = vp8dx_bool_error(bc);
- /* 2. Check the macroblock information */
- pc->yv12_fb[pc->new_fb_idx].corrupted |= corrupt_tokens;
-
- if (!pbi->decoded_key_frame)
- {
- if (pc->frame_type == KEY_FRAME &&
- !pc->yv12_fb[pc->new_fb_idx].corrupted)
- pbi->decoded_key_frame = 1;
- else
- vpx_internal_error(&pbi->common.error, VPX_CODEC_CORRUPT_FRAME,
- "A stream must start with a complete key frame");
- }
+ /* Decode a row of superblocks */
+ for (mb_row = 0; mb_row < pc->mb_rows; mb_row += 2) {
+ decode_sb_row(pbi, pc, mb_row, xd);
+ }
+ corrupt_tokens |= xd->corrupted;
+
+ /* Collect information about decoder corruption. */
+ /* 1. Check first boolean decoder for errors. */
+ pc->yv12_fb[pc->new_fb_idx].corrupted = vp8dx_bool_error(bc);
+ /* 2. Check the macroblock information */
+ pc->yv12_fb[pc->new_fb_idx].corrupted |= corrupt_tokens;
+
+ if (!pbi->decoded_key_frame) {
+ if (pc->frame_type == KEY_FRAME &&
+ !pc->yv12_fb[pc->new_fb_idx].corrupted)
+ pbi->decoded_key_frame = 1;
+ else
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_CORRUPT_FRAME,
+ "A stream must start with a complete key frame");
+ }
- /* vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes \n",bc->pos+pbi->bc2.pos); */
+ /* vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes \n",bc->pos+pbi->bc2.pos); */
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_adapt_coef_probs(pc);
- if (pc->frame_type != KEY_FRAME)
- {
- vp8_adapt_mode_probs(pc);
- vp8_adapt_mv_probs(pc);
- vp8_update_mode_context(&pbi->common);
- }
+ vp8_adapt_coef_probs(pc);
+ if (pc->frame_type != KEY_FRAME) {
+ vp8_adapt_mode_probs(pc);
+ vp8_adapt_mv_probs(pc);
+ vp8_update_mode_context(&pbi->common);
+ }
#endif
- /* If this was a kf or Gf note the Q used */
- if ((pc->frame_type == KEY_FRAME) ||
- pc->refresh_golden_frame || pc->refresh_alt_ref_frame)
- {
- pc->last_kf_gf_q = pc->base_qindex;
- }
- if(pc->refresh_entropy_probs)
- {
- if(pc->refresh_alt_ref_frame)
- vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
- else
- vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
- }
+ /* If this was a kf or Gf note the Q used */
+ if ((pc->frame_type == KEY_FRAME) ||
+ pc->refresh_golden_frame || pc->refresh_alt_ref_frame) {
+ pc->last_kf_gf_q = pc->base_qindex;
+ }
+ if (pc->refresh_entropy_probs) {
+ if (pc->refresh_alt_ref_frame)
+ vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
+ else
+ vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
+ }
#ifdef PACKET_TESTING
- {
- FILE *f = fopen("decompressor.VP8", "ab");
- unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8;
- fwrite((void *) &size, 4, 1, f);
- fwrite((void *) pbi->Source, size, 1, f);
- fclose(f);
- }
+ {
+ FILE *f = fopen("decompressor.VP8", "ab");
+ unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8;
+ fwrite((void *) &size, 4, 1, f);
+ fwrite((void *) pbi->Source, size, 1, f);
+ fclose(f);
+ }
#endif
- //printf("Frame %d Done\n", frame_count++);
+ // printf("Frame %d Done\n", frame_count++);
- return 0;
+ return 0;
}
diff --git a/vp8/decoder/dequantize.c b/vp8/decoder/dequantize.c
index a6247b2ee..73859b0d7 100644
--- a/vp8/decoder/dequantize.c
+++ b/vp8/decoder/dequantize.c
@@ -15,7 +15,7 @@
#include "vpx_mem/vpx_mem.h"
#include "onyxd_int.h"
-extern void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) ;
+extern void vp8_short_idct4x4llm_c(short *input, short *output, int pitch);
extern void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch);
extern void vp8_short_idct8x8_c(short *input, short *output, int pitch);
extern void vp8_short_idct8x8_1_c(short *input, short *output, int pitch);
@@ -29,386 +29,358 @@ extern void vp8_short_inv_walsh4x4_1_x8_c(short *input, short *output, int pitch
extern int dec_debug;
#endif
-void vp8_dequantize_b_c(BLOCKD *d)
-{
+void vp8_dequantize_b_c(BLOCKD *d) {
- int i;
- short *DQ = d->dqcoeff;
- short *Q = d->qcoeff;
- short *DQC = d->dequant;
+ int i;
+ short *DQ = d->dqcoeff;
+ short *Q = d->qcoeff;
+ short *DQC = d->dequant;
- for (i = 0; i < 16; i++)
- {
- DQ[i] = Q[i] * DQC[i];
- }
+ for (i = 0; i < 16; i++) {
+ DQ[i] = Q[i] * DQC[i];
+ }
}
void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride)
-{
- short output[16];
- short *diff_ptr = output;
- int r, c;
- int i;
-
- for (i = 0; i < 16; i++)
- {
- input[i] = dq[i] * input[i];
- }
+ unsigned char *dest, int pitch, int stride) {
+ short output[16];
+ short *diff_ptr = output;
+ int r, c;
+ int i;
- /* the idct halves ( >> 1) the pitch */
- vp8_short_idct4x4llm_c(input, output, 4 << 1);
+ for (i = 0; i < 16; i++) {
+ input[i] = dq[i] * input[i];
+ }
- vpx_memset(input, 0, 32);
+ /* the idct halves ( >> 1) the pitch */
+ vp8_short_idct4x4llm_c(input, output, 4 << 1);
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ vpx_memset(input, 0, 32);
- if (a < 0)
- a = 0;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- if (a > 255)
- a = 255;
+ if (a < 0)
+ a = 0;
- dest[c] = (unsigned char) a;
- }
+ if (a > 255)
+ a = 255;
- dest += stride;
- diff_ptr += 4;
- pred += pitch;
+ dest[c] = (unsigned char) a;
}
+
+ dest += stride;
+ diff_ptr += 4;
+ pred += pitch;
+ }
}
void vp8_dequant_dc_idct_add_c(short *input, short *dq, unsigned char *pred,
unsigned char *dest, int pitch, int stride,
- int Dc)
-{
- int i;
- short output[16];
- short *diff_ptr = output;
- int r, c;
-
- input[0] = (short)Dc;
-
- for (i = 1; i < 16; i++)
- {
- input[i] = dq[i] * input[i];
- }
+ int Dc) {
+ int i;
+ short output[16];
+ short *diff_ptr = output;
+ int r, c;
- /* the idct halves ( >> 1) the pitch */
- vp8_short_idct4x4llm_c(input, output, 4 << 1);
+ input[0] = (short)Dc;
- vpx_memset(input, 0, 32);
+ for (i = 1; i < 16; i++) {
+ input[i] = dq[i] * input[i];
+ }
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ /* the idct halves ( >> 1) the pitch */
+ vp8_short_idct4x4llm_c(input, output, 4 << 1);
- if (a < 0)
- a = 0;
+ vpx_memset(input, 0, 32);
- if (a > 255)
- a = 255;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- dest[c] = (unsigned char) a;
- }
+ if (a < 0)
+ a = 0;
- dest += stride;
- diff_ptr += 4;
- pred += pitch;
+ if (a > 255)
+ a = 255;
+
+ dest[c] = (unsigned char) a;
}
+
+ dest += stride;
+ diff_ptr += 4;
+ pred += pitch;
+ }
}
#if CONFIG_LOSSLESS
void vp8_dequant_idct_add_lossless_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride)
-{
- short output[16];
- short *diff_ptr = output;
- int r, c;
- int i;
-
- for (i = 0; i < 16; i++)
- {
- input[i] = dq[i] * input[i];
- }
+ unsigned char *dest, int pitch, int stride) {
+ short output[16];
+ short *diff_ptr = output;
+ int r, c;
+ int i;
- vp8_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
+ for (i = 0; i < 16; i++) {
+ input[i] = dq[i] * input[i];
+ }
- vpx_memset(input, 0, 32);
+ vp8_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ vpx_memset(input, 0, 32);
- if (a < 0)
- a = 0;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- if (a > 255)
- a = 255;
+ if (a < 0)
+ a = 0;
- dest[c] = (unsigned char) a;
- }
+ if (a > 255)
+ a = 255;
- dest += stride;
- diff_ptr += 4;
- pred += pitch;
+ dest[c] = (unsigned char) a;
}
+
+ dest += stride;
+ diff_ptr += 4;
+ pred += pitch;
+ }
}
void vp8_dequant_dc_idct_add_lossless_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride,
- int Dc)
-{
- int i;
- short output[16];
- short *diff_ptr = output;
- int r, c;
-
- input[0] = (short)Dc;
-
- for (i = 1; i < 16; i++)
- {
- input[i] = dq[i] * input[i];
- }
+ unsigned char *dest, int pitch, int stride,
+ int Dc) {
+ int i;
+ short output[16];
+ short *diff_ptr = output;
+ int r, c;
- vp8_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
- vpx_memset(input, 0, 32);
+ input[0] = (short)Dc;
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ for (i = 1; i < 16; i++) {
+ input[i] = dq[i] * input[i];
+ }
- if (a < 0)
- a = 0;
+ vp8_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
+ vpx_memset(input, 0, 32);
- if (a > 255)
- a = 255;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- dest[c] = (unsigned char) a;
- }
+ if (a < 0)
+ a = 0;
- dest += stride;
- diff_ptr += 4;
- pred += pitch;
+ if (a > 255)
+ a = 255;
+
+ dest[c] = (unsigned char) a;
}
+
+ dest += stride;
+ diff_ptr += 4;
+ pred += pitch;
+ }
}
#endif
-void vp8_dequantize_b_2x2_c(BLOCKD *d)
-{
- int i;
- short *DQ = d->dqcoeff;
- short *Q = d->qcoeff;
- short *DQC = d->dequant;
+void vp8_dequantize_b_2x2_c(BLOCKD *d) {
+ int i;
+ short *DQ = d->dqcoeff;
+ short *Q = d->qcoeff;
+ short *DQC = d->dequant;
- for (i = 0; i < 16; i++)
- {
- DQ[i] = (short)((Q[i] * DQC[i]));
- }
+ for (i = 0; i < 16; i++) {
+ DQ[i] = (short)((Q[i] * DQC[i]));
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Dequantize 2x2\n");
- for (j=0;j<16;j++) printf("%d ", Q[j]); printf("\n");
- for (j=0;j<16;j++) printf("%d ", DQ[j]); printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Dequantize 2x2\n");
+ for (j = 0; j < 16; j++) printf("%d ", Q[j]);
+ printf("\n");
+ for (j = 0; j < 16; j++) printf("%d ", DQ[j]);
+ printf("\n");
+ }
#endif
}
void vp8_dequant_idct_add_8x8_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride)//, MACROBLOCKD *xd, short blk_idx
-{
- short output[64];
- short *diff_ptr = output;
- int r, c, b;
- int i;
- unsigned char *origdest = dest;
- unsigned char *origpred = pred;
+ unsigned char *dest, int pitch, int stride) { // , MACROBLOCKD *xd, short blk_idx
+ short output[64];
+ short *diff_ptr = output;
+ int r, c, b;
+ int i;
+ unsigned char *origdest = dest;
+ unsigned char *origpred = pred;
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Input 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", input[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Input 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", input[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- input[0]= input[0] * dq[0];
+ input[0] = input[0] * dq[0];
- // recover quantizer for 4 4x4 blocks
- for (i = 1; i < 64; i++)
- {
- input[i]=input[i] * dq[1];
- }
+ // recover quantizer for 4 4x4 blocks
+ for (i = 1; i < 64; i++) {
+ input[i] = input[i] * dq[1];
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Input DQ 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", input[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Input DQ 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", input[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- // the idct halves ( >> 1) the pitch
- vp8_short_idct8x8_c(input, output, 16);
+ // the idct halves ( >> 1) the pitch
+ vp8_short_idct8x8_c(input, output, 16);
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Output 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", output[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Output 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", output[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- vpx_memset(input, 0, 128);// test what should i put here
-
- for (b = 0; b < 4; b++)
- {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ vpx_memset(input, 0, 128);// test what should i put here
- if (a < 0)
- a = 0;
+ for (b = 0; b < 4; b++) {
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- if (a > 255)
- a = 255;
+ if (a < 0)
+ a = 0;
- dest[c] = (unsigned char) a;
- }
+ if (a > 255)
+ a = 255;
- dest += stride;
- diff_ptr += 8;
- pred += pitch;
+ dest[c] = (unsigned char) a;
}
- diff_ptr = output + (b+1) / 2 * 4 * 8 + (b+1) % 2 * 4;
- dest = origdest + (b+1) / 2 * 4 * stride + (b+1) % 2 * 4;
- pred = origpred + (b+1) / 2 * 4 * pitch + (b+1) % 2 * 4;
- }
+
+ dest += stride;
+ diff_ptr += 8;
+ pred += pitch;
+ }
+ diff_ptr = output + (b + 1) / 2 * 4 * 8 + (b + 1) % 2 * 4;
+ dest = origdest + (b + 1) / 2 * 4 * stride + (b + 1) % 2 * 4;
+ pred = origpred + (b + 1) / 2 * 4 * pitch + (b + 1) % 2 * 4;
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int k,j;
- printf("Final 8x8\n");
- for (j=0;j<8;j++) {
- for (k=0;k<8;k++) {
- printf("%d ", origdest[k]);
- }
- printf("\n");
- origdest+=stride;
+ if (dec_debug) {
+ int k, j;
+ printf("Final 8x8\n");
+ for (j = 0; j < 8; j++) {
+ for (k = 0; k < 8; k++) {
+ printf("%d ", origdest[k]);
}
+ printf("\n");
+ origdest += stride;
}
+ }
#endif
}
void vp8_dequant_dc_idct_add_8x8_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride,
- int Dc)// Dc for 1st order T in some rear case
-{
- short output[64];
- short *diff_ptr = output;
- int r, c, b;
- int i;
- unsigned char *origdest = dest;
- unsigned char *origpred = pred;
-
- input[0] = (short)Dc;//Dc is the reconstructed value, do not need dequantization
- //dc value is recovered after dequantization, since dc need not quantization
+ unsigned char *dest, int pitch, int stride,
+ int Dc) { // Dc for 1st order T in some rear case
+ short output[64];
+ short *diff_ptr = output;
+ int r, c, b;
+ int i;
+ unsigned char *origdest = dest;
+ unsigned char *origpred = pred;
+
+ input[0] = (short)Dc;// Dc is the reconstructed value, do not need dequantization
+ // dc value is recovered after dequantization, since dc need not quantization
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Input 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", input[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Input 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", input[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- for (i = 1; i < 64; i++)
- {
- input[i]=input[i] * dq[1];
- }
+ for (i = 1; i < 64; i++) {
+ input[i] = input[i] * dq[1];
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Input DQ 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", input[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Input DQ 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", input[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- // the idct halves ( >> 1) the pitch
- vp8_short_idct8x8_c(input, output,16);
+ // the idct halves ( >> 1) the pitch
+ vp8_short_idct8x8_c(input, output, 16);
#ifdef DEC_DEBUG
- if (dec_debug) {
- int j;
- printf("Output 8x8\n");
- for (j=0;j<64;j++) {
- printf("%d ", output[j]);
- if (j%8 == 7) printf("\n");
- }
+ if (dec_debug) {
+ int j;
+ printf("Output 8x8\n");
+ for (j = 0; j < 64; j++) {
+ printf("%d ", output[j]);
+ if (j % 8 == 7) printf("\n");
}
+ }
#endif
- vpx_memset(input, 0, 128);
+ vpx_memset(input, 0, 128);
- for (b = 0; b < 4; b++)
- {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int a = diff_ptr[c] + pred[c];
+ for (b = 0; b < 4; b++) {
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int a = diff_ptr[c] + pred[c];
- if (a < 0)
- a = 0;
+ if (a < 0)
+ a = 0;
- if (a > 255)
- a = 255;
+ if (a > 255)
+ a = 255;
- dest[c] = (unsigned char) a;
- }
-
- dest += stride;
- diff_ptr += 8;
- pred += pitch;
+ dest[c] = (unsigned char) a;
}
- diff_ptr = output + (b+1) / 2 * 4 * 8 + (b+1) % 2 * 4;
- dest = origdest + (b+1) / 2 * 4 * stride + (b+1) % 2 * 4;
- pred = origpred + (b+1) / 2 * 4 * pitch + (b+1) % 2 * 4;
- }
+
+ dest += stride;
+ diff_ptr += 8;
+ pred += pitch;
+ }
+ diff_ptr = output + (b + 1) / 2 * 4 * 8 + (b + 1) % 2 * 4;
+ dest = origdest + (b + 1) / 2 * 4 * stride + (b + 1) % 2 * 4;
+ pred = origpred + (b + 1) / 2 * 4 * pitch + (b + 1) % 2 * 4;
+ }
#ifdef DEC_DEBUG
- if (dec_debug) {
- int k,j;
- printf("Final 8x8\n");
- for (j=0;j<8;j++) {
- for (k=0;k<8;k++) {
- printf("%d ", origdest[k]);
- }
- printf("\n");
- origdest+=stride;
+ if (dec_debug) {
+ int k, j;
+ printf("Final 8x8\n");
+ for (j = 0; j < 8; j++) {
+ for (k = 0; k < 8; k++) {
+ printf("%d ", origdest[k]);
}
+ printf("\n");
+ origdest += stride;
}
+ }
#endif
}
diff --git a/vp8/decoder/dequantize.h b/vp8/decoder/dequantize.h
index af84603bb..2582d8626 100644
--- a/vp8/decoder/dequantize.h
+++ b/vp8/decoder/dequantize.h
@@ -14,49 +14,49 @@
#include "vp8/common/blockd.h"
#define prototype_dequant_block(sym) \
- void sym(BLOCKD *x)
+ void sym(BLOCKD *x)
#define prototype_dequant_idct_add(sym) \
- void sym(short *input, short *dq, \
- unsigned char *pred, unsigned char *output, \
- int pitch, int stride)
+ void sym(short *input, short *dq, \
+ unsigned char *pred, unsigned char *output, \
+ int pitch, int stride)
#define prototype_dequant_dc_idct_add(sym) \
- void sym(short *input, short *dq, \
- unsigned char *pred, unsigned char *output, \
- int pitch, int stride, \
- int dc)
+ void sym(short *input, short *dq, \
+ unsigned char *pred, unsigned char *output, \
+ int pitch, int stride, \
+ int dc)
#define prototype_dequant_dc_idct_add_y_block(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst, \
- int stride, char *eobs, short *dc)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst, \
+ int stride, char *eobs, short *dc)
#define prototype_dequant_idct_add_y_block(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst, \
- int stride, char *eobs)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst, \
+ int stride, char *eobs)
#define prototype_dequant_idct_add_uv_block(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst_u, \
- unsigned char *dst_v, int stride, char *eobs)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst_u, \
+ unsigned char *dst_v, int stride, char *eobs)
#define prototype_dequant_dc_idct_add_y_block_8x8(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst, \
- int stride, char *eobs, short *dc, MACROBLOCKD *xd)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst, \
+ int stride, char *eobs, short *dc, MACROBLOCKD *xd)
#define prototype_dequant_idct_add_y_block_8x8(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst, \
- int stride, char *eobs, MACROBLOCKD *xd)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst, \
+ int stride, char *eobs, MACROBLOCKD *xd)
#define prototype_dequant_idct_add_uv_block_8x8(sym) \
- void sym(short *q, short *dq, \
- unsigned char *pre, unsigned char *dst_u, \
- unsigned char *dst_v, int stride, char *eobs, \
- MACROBLOCKD *xd)
+ void sym(short *q, short *dq, \
+ unsigned char *pre, unsigned char *dst_u, \
+ unsigned char *dst_v, int stride, char *eobs, \
+ MACROBLOCKD *xd)
#if ARCH_X86 || ARCH_X86_64
#include "x86/dequantize_x86.h"
@@ -154,20 +154,19 @@ typedef prototype_dequant_idct_add_y_block_8x8((*vp8_dequant_idct_add_y_block_fn
typedef prototype_dequant_idct_add_uv_block_8x8((*vp8_dequant_idct_add_uv_block_fn_t_8x8));
-typedef struct
-{
- vp8_dequant_block_fn_t block;
- vp8_dequant_idct_add_fn_t idct_add;
- vp8_dequant_dc_idct_add_fn_t dc_idct_add;
- vp8_dequant_dc_idct_add_y_block_fn_t dc_idct_add_y_block;
- vp8_dequant_idct_add_y_block_fn_t idct_add_y_block;
- vp8_dequant_idct_add_uv_block_fn_t idct_add_uv_block;
- vp8_dequant_block_fn_t block_2x2;
- vp8_dequant_idct_add_fn_t idct_add_8x8;
- vp8_dequant_dc_idct_add_fn_t dc_idct_add_8x8;
- vp8_dequant_dc_idct_add_y_block_fn_t_8x8 dc_idct_add_y_block_8x8;
- vp8_dequant_idct_add_y_block_fn_t_8x8 idct_add_y_block_8x8;
- vp8_dequant_idct_add_uv_block_fn_t_8x8 idct_add_uv_block_8x8;
+typedef struct {
+ vp8_dequant_block_fn_t block;
+ vp8_dequant_idct_add_fn_t idct_add;
+ vp8_dequant_dc_idct_add_fn_t dc_idct_add;
+ vp8_dequant_dc_idct_add_y_block_fn_t dc_idct_add_y_block;
+ vp8_dequant_idct_add_y_block_fn_t idct_add_y_block;
+ vp8_dequant_idct_add_uv_block_fn_t idct_add_uv_block;
+ vp8_dequant_block_fn_t block_2x2;
+ vp8_dequant_idct_add_fn_t idct_add_8x8;
+ vp8_dequant_dc_idct_add_fn_t dc_idct_add_8x8;
+ vp8_dequant_dc_idct_add_y_block_fn_t_8x8 dc_idct_add_y_block_8x8;
+ vp8_dequant_idct_add_y_block_fn_t_8x8 idct_add_y_block_8x8;
+ vp8_dequant_idct_add_uv_block_fn_t_8x8 idct_add_uv_block_8x8;
} vp8_dequant_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/decoder/detokenize.c b/vp8/decoder/detokenize.c
index c7f2248d0..7f3469efb 100644
--- a/vp8/decoder/detokenize.c
+++ b/vp8/decoder/detokenize.c
@@ -22,15 +22,13 @@
#define OCB_X PREV_COEF_CONTEXTS * ENTROPY_NODES
-DECLARE_ALIGNED(16, int, coef_bands_x[16]) =
-{
- 0 * OCB_X, 1 * OCB_X, 2 * OCB_X, 3 * OCB_X,
- 6 * OCB_X, 4 * OCB_X, 5 * OCB_X, 6 * OCB_X,
- 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X,
- 6 * OCB_X, 7 * OCB_X, 7 * OCB_X, 7 * OCB_X
+DECLARE_ALIGNED(16, int, coef_bands_x[16]) = {
+ 0 * OCB_X, 1 * OCB_X, 2 * OCB_X, 3 * OCB_X,
+ 6 * OCB_X, 4 * OCB_X, 5 * OCB_X, 6 * OCB_X,
+ 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X,
+ 6 * OCB_X, 7 * OCB_X, 7 * OCB_X, 7 * OCB_X
};
-DECLARE_ALIGNED(16, int, coef_bands_x_8x8[64]) =
-{
+DECLARE_ALIGNED(16, int, coef_bands_x_8x8[64]) = {
0 * OCB_X, 1 * OCB_X, 2 * OCB_X, 3 * OCB_X, 5 * OCB_X, 4 * OCB_X, 4 * OCB_X, 5 * OCB_X,
5 * OCB_X, 3 * OCB_X, 6 * OCB_X, 3 * OCB_X, 5 * OCB_X, 4 * OCB_X, 6 * OCB_X, 6 * OCB_X,
6 * OCB_X, 5 * OCB_X, 5 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X,
@@ -81,27 +79,23 @@ DECLARE_ALIGNED(16, int, coef_bands_x_8x8[64]) =
static const unsigned char cat6_prob[14] =
{ 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
-void vp8_reset_mb_tokens_context(MACROBLOCKD *x)
-{
- /* Clear entropy contexts for Y2 blocks */
- if (x->mode_info_context->mbmi.mode != B_PRED &&
- x->mode_info_context->mbmi.mode != I8X8_PRED &&
- x->mode_info_context->mbmi.mode != SPLITMV)
- {
- vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
- }
- else
- {
- vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
- vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
- }
+void vp8_reset_mb_tokens_context(MACROBLOCKD *x) {
+ /* Clear entropy contexts for Y2 blocks */
+ if (x->mode_info_context->mbmi.mode != B_PRED &&
+ x->mode_info_context->mbmi.mode != I8X8_PRED &&
+ x->mode_info_context->mbmi.mode != SPLITMV) {
+ vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
+ } else {
+ vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
+ vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
+ }
}
DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
-//#define PREV_CONTEXT_INC(val) (2+((val)>2))
-//#define PREV_CONTEXT_INC(val) (vp8_prev_token_class[(val)])
+// #define PREV_CONTEXT_INC(val) (2+((val)>2))
+// #define PREV_CONTEXT_INC(val) (vp8_prev_token_class[(val)])
#if CONFIG_EXPANDED_COEF_CONTEXT
#define PREV_CONTEXT_INC(val) (vp8_prev_token_class[(val)>10?10:(val)])
#else
@@ -110,313 +104,297 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
#if CONFIG_ADAPTIVE_ENTROPY
-int get_token(int v)
-{
- if (v < 0) v = -v;
- if (v == 0) return ZERO_TOKEN;
- else if (v == 1) return ONE_TOKEN;
- else if (v == 2) return TWO_TOKEN;
- else if (v == 3) return THREE_TOKEN;
- else if (v == 4) return FOUR_TOKEN;
- else if (v <= 6) return DCT_VAL_CATEGORY1;
- else if (v <= 10) return DCT_VAL_CATEGORY2;
- else if (v <= 18) return DCT_VAL_CATEGORY3;
- else if (v <= 34) return DCT_VAL_CATEGORY4;
- else if (v <= 66) return DCT_VAL_CATEGORY5;
- else return DCT_VAL_CATEGORY6;
+int get_token(int v) {
+ if (v < 0) v = -v;
+ if (v == 0) return ZERO_TOKEN;
+ else if (v == 1) return ONE_TOKEN;
+ else if (v == 2) return TWO_TOKEN;
+ else if (v == 3) return THREE_TOKEN;
+ else if (v == 4) return FOUR_TOKEN;
+ else if (v <= 6) return DCT_VAL_CATEGORY1;
+ else if (v <= 10) return DCT_VAL_CATEGORY2;
+ else if (v <= 18) return DCT_VAL_CATEGORY3;
+ else if (v <= 34) return DCT_VAL_CATEGORY4;
+ else if (v <= 66) return DCT_VAL_CATEGORY5;
+ else return DCT_VAL_CATEGORY6;
}
void static count_tokens(INT16 *qcoeff_ptr, int block, int type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
- int eob, int seg_eob, FRAME_CONTEXT* const fc)
-{
- int c, pt, token, band;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- for (c = !type; c < eob; ++c)
- {
- int rc = vp8_default_zig_zag1d[c];
- int v = qcoeff_ptr[rc];
- band = vp8_coef_bands[c];
- token = get_token(v);
- fc->coef_counts[type][band][pt][token]++;
- pt = vp8_prev_token_class[token];
- }
- if (eob < seg_eob)
- {
- band = vp8_coef_bands[c];
- fc->coef_counts[type][band][pt][DCT_EOB_TOKEN]++;
- }
+ int eob, int seg_eob, FRAME_CONTEXT *const fc) {
+ int c, pt, token, band;
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ for (c = !type; c < eob; ++c) {
+ int rc = vp8_default_zig_zag1d[c];
+ int v = qcoeff_ptr[rc];
+ band = vp8_coef_bands[c];
+ token = get_token(v);
+ fc->coef_counts[type][band][pt][token]++;
+ pt = vp8_prev_token_class[token];
+ }
+ if (eob < seg_eob) {
+ band = vp8_coef_bands[c];
+ fc->coef_counts[type][band][pt][DCT_EOB_TOKEN]++;
+ }
}
void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, int type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
- int eob, int seg_eob, FRAME_CONTEXT *fc)
-{
- int c, pt, token, band;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- for (c = !type; c < eob; ++c)
- {
- int rc = (type == 1 ? vp8_default_zig_zag1d[c] : vp8_default_zig_zag1d_8x8[c]);
- int v = qcoeff_ptr[rc];
- band = (type == 1 ? vp8_coef_bands[c] : vp8_coef_bands_8x8[c]);
- token = get_token(v);
- fc->coef_counts_8x8[type][band][pt][token]++;
- pt = vp8_prev_token_class[token];
- }
- if (eob < seg_eob)
- {
- band = (type == 1 ? vp8_coef_bands[c] : vp8_coef_bands_8x8[c]);
- fc->coef_counts_8x8[type][band][pt][DCT_EOB_TOKEN]++;
- }
+ int eob, int seg_eob, FRAME_CONTEXT *fc) {
+ int c, pt, token, band;
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ for (c = !type; c < eob; ++c) {
+ int rc = (type == 1 ? vp8_default_zig_zag1d[c] : vp8_default_zig_zag1d_8x8[c]);
+ int v = qcoeff_ptr[rc];
+ band = (type == 1 ? vp8_coef_bands[c] : vp8_coef_bands_8x8[c]);
+ token = get_token(v);
+ fc->coef_counts_8x8[type][band][pt][token]++;
+ pt = vp8_prev_token_class[token];
+ }
+ if (eob < seg_eob) {
+ band = (type == 1 ? vp8_coef_bands[c] : vp8_coef_bands_8x8[c]);
+ fc->coef_counts_8x8[type][band][pt][DCT_EOB_TOKEN]++;
+ }
}
#endif
-static int vp8_get_signed(BOOL_DECODER *br, int value_to_sign)
-{
- const int split = (br->range + 1) >> 1;
- const VP8_BD_VALUE bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
- int v;
+static int vp8_get_signed(BOOL_DECODER *br, int value_to_sign) {
+ const int split = (br->range + 1) >> 1;
+ const VP8_BD_VALUE bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
+ int v;
- if (br->count < 0)
- vp8dx_bool_decoder_fill(br);
+ if (br->count < 0)
+ vp8dx_bool_decoder_fill(br);
- if (br->value < bigsplit) {
- br->range = split;
- v = value_to_sign;
- }
- else {
- br->range = br->range - split;
- br->value = br->value - bigsplit;
- v = -value_to_sign;
- }
- br->range += br->range;
- br->value += br->value;
- --br->count;
+ if (br->value < bigsplit) {
+ br->range = split;
+ v = value_to_sign;
+ } else {
+ br->range = br->range - split;
+ br->value = br->value - bigsplit;
+ v = -value_to_sign;
+ }
+ br->range += br->range;
+ br->value += br->value;
+ --br->count;
- return v;
+ return v;
}
#define WRITE_COEF_CONTINUE(val) \
- { \
- Prob = coef_probs + (ENTROPY_NODES*PREV_CONTEXT_INC(val));\
- qcoeff_ptr[scan[c]] = (INT16) vp8_get_signed(br, val); \
- c++; \
- continue; \
- }
+ { \
+ Prob = coef_probs + (ENTROPY_NODES*PREV_CONTEXT_INC(val));\
+ qcoeff_ptr[scan[c]] = (INT16) vp8_get_signed(br, val); \
+ c++; \
+ continue; \
+ }
#define ADJUST_COEF(prob, bits_count) \
- do { \
- if (vp8_read(br, prob)) \
- val += (UINT16)(1 << bits_count);\
- } while (0);
+ do { \
+ if (vp8_read(br, prob)) \
+ val += (UINT16)(1 << bits_count);\
+ } while (0);
static int vp8_decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int type,
int seg_eob, INT16 *qcoeff_ptr, int i,
- const int* const scan, int block_type,
- const int* coef_bands)
-{
- FRAME_CONTEXT* const fc = &dx->common.fc;
- BOOL_DECODER *br = xd->current_bc;
- int tmp, c = (type == 0);
- const vp8_prob *Prob;
- const vp8_prob *coef_probs =
- (block_type == TX_4X4) ? fc->coef_probs[type][0][0]
- : fc->coef_probs_8x8[type][0][0];
-
- VP8_COMBINEENTROPYCONTEXTS(tmp, *a, *l);
- Prob = coef_probs + tmp * ENTROPY_NODES;
-
- while (1) {
- int val;
- const uint8_t* cat6 = cat6_prob;
- if (c == seg_eob) break;
- Prob += coef_bands[c];
- if (!vp8_read(br, Prob[EOB_CONTEXT_NODE]))
- break;
-SKIP_START:
- if (c == seg_eob) break;
- if (!vp8_read(br, Prob[ZERO_CONTEXT_NODE])) {
- ++c;
- Prob = coef_probs + coef_bands[c];
- goto SKIP_START;
- }
- // ONE_CONTEXT_NODE_0_
- if (!vp8_read(br, Prob[ONE_CONTEXT_NODE])) {
- Prob = coef_probs + ENTROPY_NODES;
- qcoeff_ptr[scan[c]] = (INT16) vp8_get_signed(br, 1);
- ++c;
- continue;
- }
- // LOW_VAL_CONTEXT_NODE_0_
- if (!vp8_read(br, Prob[LOW_VAL_CONTEXT_NODE])) {
- if (!vp8_read(br, Prob[TWO_CONTEXT_NODE])) {
- WRITE_COEF_CONTINUE(2);
- }
- if (!vp8_read(br, Prob[THREE_CONTEXT_NODE])) {
- WRITE_COEF_CONTINUE(3);
- }
- WRITE_COEF_CONTINUE(4);
- }
- // HIGH_LOW_CONTEXT_NODE_0_
- if (!vp8_read(br, Prob[HIGH_LOW_CONTEXT_NODE])) {
- if (!vp8_read(br, Prob[CAT_ONE_CONTEXT_NODE])) {
- val = CAT1_MIN_VAL;
- ADJUST_COEF(CAT1_PROB0, 0);
- WRITE_COEF_CONTINUE(val);
- }
- val = CAT2_MIN_VAL;
- ADJUST_COEF(CAT2_PROB1, 1);
- ADJUST_COEF(CAT2_PROB0, 0);
- WRITE_COEF_CONTINUE(val);
- }
- // CAT_THREEFOUR_CONTEXT_NODE_0_
- if (!vp8_read(br, Prob[CAT_THREEFOUR_CONTEXT_NODE])) {
- if (!vp8_read(br, Prob[CAT_THREE_CONTEXT_NODE])) {
- val = CAT3_MIN_VAL;
- ADJUST_COEF(CAT3_PROB2, 2);
- ADJUST_COEF(CAT3_PROB1, 1);
- ADJUST_COEF(CAT3_PROB0, 0);
- WRITE_COEF_CONTINUE(val);
- }
- val = CAT4_MIN_VAL;
- ADJUST_COEF(CAT4_PROB3, 3);
- ADJUST_COEF(CAT4_PROB2, 2);
- ADJUST_COEF(CAT4_PROB1, 1);
- ADJUST_COEF(CAT4_PROB0, 0);
- WRITE_COEF_CONTINUE(val);
- }
- // CAT_FIVE_CONTEXT_NODE_0_:
- if (!vp8_read(br, Prob[CAT_FIVE_CONTEXT_NODE])) {
- val = CAT5_MIN_VAL;
- ADJUST_COEF(CAT5_PROB4, 4);
- ADJUST_COEF(CAT5_PROB3, 3);
- ADJUST_COEF(CAT5_PROB2, 2);
- ADJUST_COEF(CAT5_PROB1, 1);
- ADJUST_COEF(CAT5_PROB0, 0);
- WRITE_COEF_CONTINUE(val);
- }
- val = 0;
- while (*cat6) {
- val = (val << 1) | vp8_read(br, *cat6++);
- }
- val += CAT6_MIN_VAL;
+ const int *const scan, int block_type,
+ const int *coef_bands) {
+ FRAME_CONTEXT *const fc = &dx->common.fc;
+ BOOL_DECODER *br = xd->current_bc;
+ int tmp, c = (type == 0);
+ const vp8_prob *Prob;
+ const vp8_prob *coef_probs =
+ (block_type == TX_4X4) ? fc->coef_probs[type][0][0]
+ : fc->coef_probs_8x8[type][0][0];
+
+ VP8_COMBINEENTROPYCONTEXTS(tmp, *a, *l);
+ Prob = coef_probs + tmp * ENTROPY_NODES;
+
+ while (1) {
+ int val;
+ const uint8_t *cat6 = cat6_prob;
+ if (c == seg_eob) break;
+ Prob += coef_bands[c];
+ if (!vp8_read(br, Prob[EOB_CONTEXT_NODE]))
+ break;
+ SKIP_START:
+ if (c == seg_eob) break;
+ if (!vp8_read(br, Prob[ZERO_CONTEXT_NODE])) {
+ ++c;
+ Prob = coef_probs + coef_bands[c];
+ goto SKIP_START;
+ }
+ // ONE_CONTEXT_NODE_0_
+ if (!vp8_read(br, Prob[ONE_CONTEXT_NODE])) {
+ Prob = coef_probs + ENTROPY_NODES;
+ qcoeff_ptr[scan[c]] = (INT16) vp8_get_signed(br, 1);
+ ++c;
+ continue;
+ }
+ // LOW_VAL_CONTEXT_NODE_0_
+ if (!vp8_read(br, Prob[LOW_VAL_CONTEXT_NODE])) {
+ if (!vp8_read(br, Prob[TWO_CONTEXT_NODE])) {
+ WRITE_COEF_CONTINUE(2);
+ }
+ if (!vp8_read(br, Prob[THREE_CONTEXT_NODE])) {
+ WRITE_COEF_CONTINUE(3);
+ }
+ WRITE_COEF_CONTINUE(4);
+ }
+ // HIGH_LOW_CONTEXT_NODE_0_
+ if (!vp8_read(br, Prob[HIGH_LOW_CONTEXT_NODE])) {
+ if (!vp8_read(br, Prob[CAT_ONE_CONTEXT_NODE])) {
+ val = CAT1_MIN_VAL;
+ ADJUST_COEF(CAT1_PROB0, 0);
WRITE_COEF_CONTINUE(val);
+ }
+ val = CAT2_MIN_VAL;
+ ADJUST_COEF(CAT2_PROB1, 1);
+ ADJUST_COEF(CAT2_PROB0, 0);
+ WRITE_COEF_CONTINUE(val);
}
+ // CAT_THREEFOUR_CONTEXT_NODE_0_
+ if (!vp8_read(br, Prob[CAT_THREEFOUR_CONTEXT_NODE])) {
+ if (!vp8_read(br, Prob[CAT_THREE_CONTEXT_NODE])) {
+ val = CAT3_MIN_VAL;
+ ADJUST_COEF(CAT3_PROB2, 2);
+ ADJUST_COEF(CAT3_PROB1, 1);
+ ADJUST_COEF(CAT3_PROB0, 0);
+ WRITE_COEF_CONTINUE(val);
+ }
+ val = CAT4_MIN_VAL;
+ ADJUST_COEF(CAT4_PROB3, 3);
+ ADJUST_COEF(CAT4_PROB2, 2);
+ ADJUST_COEF(CAT4_PROB1, 1);
+ ADJUST_COEF(CAT4_PROB0, 0);
+ WRITE_COEF_CONTINUE(val);
+ }
+ // CAT_FIVE_CONTEXT_NODE_0_:
+ if (!vp8_read(br, Prob[CAT_FIVE_CONTEXT_NODE])) {
+ val = CAT5_MIN_VAL;
+ ADJUST_COEF(CAT5_PROB4, 4);
+ ADJUST_COEF(CAT5_PROB3, 3);
+ ADJUST_COEF(CAT5_PROB2, 2);
+ ADJUST_COEF(CAT5_PROB1, 1);
+ ADJUST_COEF(CAT5_PROB0, 0);
+ WRITE_COEF_CONTINUE(val);
+ }
+ val = 0;
+ while (*cat6) {
+ val = (val << 1) | vp8_read(br, *cat6++);
+ }
+ val += CAT6_MIN_VAL;
+ WRITE_COEF_CONTINUE(val);
+ }
#if CONFIG_ADAPTIVE_ENTROPY
- if (block_type == TX_4X4)
- count_tokens(qcoeff_ptr, i, type, a, l, c, seg_eob, fc);
- else
- count_tokens_8x8(qcoeff_ptr, i, type, a, l, c, seg_eob, fc);
+ if (block_type == TX_4X4)
+ count_tokens(qcoeff_ptr, i, type, a, l, c, seg_eob, fc);
+ else
+ count_tokens_8x8(qcoeff_ptr, i, type, a, l, c, seg_eob, fc);
#endif
- return c;
+ return c;
}
-int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd)
-{
- ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
- ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
-
- char* const eobs = xd->eobs;
- int c, i, type, eobtotal = 0, seg_eob;
- const int segment_id = xd->mode_info_context->mbmi.segment_id;
- const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
- INT16 *qcoeff_ptr = &xd->qcoeff[0];
- if (xd->mode_info_context->mbmi.mode != B_PRED &&
- xd->mode_info_context->mbmi.mode != SPLITMV)
- {
- ENTROPY_CONTEXT* const a = A + vp8_block2above_8x8[24];
- ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[24];
- const int* const scan = vp8_default_zig_zag1d;
- type = PLANE_TYPE_Y2;
-
- if (seg_active)
- seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
- else
- seg_eob = 4;
- c = vp8_decode_coefs(pbi, xd, a, l, type, seg_eob, qcoeff_ptr + 24*16,
- 24, scan, TX_8X8, coef_bands_x);
- a[0] = l[0] = ((eobs[24] = c) != !type);
-
- eobtotal += c - 4;
-
- type = PLANE_TYPE_Y_NO_DC;
- }
- else
- type = PLANE_TYPE_Y_WITH_DC;
+int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
+ ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
+ ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
+
+ char *const eobs = xd->eobs;
+ int c, i, type, eobtotal = 0, seg_eob;
+ const int segment_id = xd->mode_info_context->mbmi.segment_id;
+ const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
+ INT16 *qcoeff_ptr = &xd->qcoeff[0];
+ if (xd->mode_info_context->mbmi.mode != B_PRED &&
+ xd->mode_info_context->mbmi.mode != SPLITMV) {
+ ENTROPY_CONTEXT *const a = A + vp8_block2above_8x8[24];
+ ENTROPY_CONTEXT *const l = L + vp8_block2left_8x8[24];
+ const int *const scan = vp8_default_zig_zag1d;
+ type = PLANE_TYPE_Y2;
if (seg_active)
- seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
else
- seg_eob = 64;
- for (i = 0; i < 24; i += 4)
- {
- ENTROPY_CONTEXT* const a = A + vp8_block2above_8x8[i];
- ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[i];
- const int* const scan = vp8_default_zig_zag1d_8x8;
- if (i == 16)
- type = PLANE_TYPE_UV;
-
- c = vp8_decode_coefs(pbi, xd, a, l, type, seg_eob, qcoeff_ptr,
- i, scan, TX_8X8, coef_bands_x_8x8);
- a[0] = l[0] = ((eobs[i] = c) != !type);
- a[1] = a[0];
- l[1] = l[0];
-
- eobtotal += c;
- qcoeff_ptr += 64;
- }
-
- return eobtotal;
+ seg_eob = 4;
+ c = vp8_decode_coefs(pbi, xd, a, l, type, seg_eob, qcoeff_ptr + 24 * 16,
+ 24, scan, TX_8X8, coef_bands_x);
+ a[0] = l[0] = ((eobs[24] = c) != !type);
+
+ eobtotal += c - 4;
+
+ type = PLANE_TYPE_Y_NO_DC;
+ } else
+ type = PLANE_TYPE_Y_WITH_DC;
+
+ if (seg_active)
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ else
+ seg_eob = 64;
+ for (i = 0; i < 24; i += 4) {
+ ENTROPY_CONTEXT *const a = A + vp8_block2above_8x8[i];
+ ENTROPY_CONTEXT *const l = L + vp8_block2left_8x8[i];
+ const int *const scan = vp8_default_zig_zag1d_8x8;
+ if (i == 16)
+ type = PLANE_TYPE_UV;
+
+ c = vp8_decode_coefs(pbi, xd, a, l, type, seg_eob, qcoeff_ptr,
+ i, scan, TX_8X8, coef_bands_x_8x8);
+ a[0] = l[0] = ((eobs[i] = c) != !type);
+ a[1] = a[0];
+ l[1] = l[0];
+
+ eobtotal += c;
+ qcoeff_ptr += 64;
+ }
+
+ return eobtotal;
}
-int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd)
-{
- ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
- ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
+int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd) {
+ ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
+ ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
- char* const eobs = xd->eobs;
- const int* const scan = vp8_default_zig_zag1d;
- int c, i, type, eobtotal = 0, seg_eob = 16;
- INT16 *qcoeff_ptr = &xd->qcoeff[0];
+ char *const eobs = xd->eobs;
+ const int *const scan = vp8_default_zig_zag1d;
+ int c, i, type, eobtotal = 0, seg_eob = 16;
+ INT16 *qcoeff_ptr = &xd->qcoeff[0];
- int segment_id = xd->mode_info_context->mbmi.segment_id;
- if (segfeature_active(xd, segment_id, SEG_LVL_EOB))
- seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB))
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
- if (xd->mode_info_context->mbmi.mode != B_PRED &&
- xd->mode_info_context->mbmi.mode != I8X8_PRED &&
- xd->mode_info_context->mbmi.mode != SPLITMV) {
- ENTROPY_CONTEXT* const a = A + vp8_block2above[24];
- ENTROPY_CONTEXT* const l = L + vp8_block2left[24];
- type = PLANE_TYPE_Y2;
+ if (xd->mode_info_context->mbmi.mode != B_PRED &&
+ xd->mode_info_context->mbmi.mode != I8X8_PRED &&
+ xd->mode_info_context->mbmi.mode != SPLITMV) {
+ ENTROPY_CONTEXT *const a = A + vp8_block2above[24];
+ ENTROPY_CONTEXT *const l = L + vp8_block2left[24];
+ type = PLANE_TYPE_Y2;
- c = vp8_decode_coefs(dx, xd, a, l, type, seg_eob, qcoeff_ptr + 24*16, 24,
- scan, TX_4X4, coef_bands_x);
- a[0] = l[0] = ((eobs[24] = c) != !type);
+ c = vp8_decode_coefs(dx, xd, a, l, type, seg_eob, qcoeff_ptr + 24 * 16, 24,
+ scan, TX_4X4, coef_bands_x);
+ a[0] = l[0] = ((eobs[24] = c) != !type);
- eobtotal += c - 16;
+ eobtotal += c - 16;
- type = PLANE_TYPE_Y_NO_DC;
- }
- else {
- type = PLANE_TYPE_Y_WITH_DC;
- }
+ type = PLANE_TYPE_Y_NO_DC;
+ } else {
+ type = PLANE_TYPE_Y_WITH_DC;
+ }
- for (i = 0; i < 24; ++i) {
- ENTROPY_CONTEXT* const a = A + vp8_block2above[i];
- ENTROPY_CONTEXT* const l = L + vp8_block2left[i];
- if (i == 16)
- type = PLANE_TYPE_UV;
+ for (i = 0; i < 24; ++i) {
+ ENTROPY_CONTEXT *const a = A + vp8_block2above[i];
+ ENTROPY_CONTEXT *const l = L + vp8_block2left[i];
+ if (i == 16)
+ type = PLANE_TYPE_UV;
- c = vp8_decode_coefs(dx, xd, a, l, type, seg_eob, qcoeff_ptr,
- i, scan, TX_4X4, coef_bands_x);
- a[0] = l[0] = ((eobs[i] = c) != !type);
+ c = vp8_decode_coefs(dx, xd, a, l, type, seg_eob, qcoeff_ptr,
+ i, scan, TX_4X4, coef_bands_x);
+ a[0] = l[0] = ((eobs[i] = c) != !type);
- eobtotal += c;
- qcoeff_ptr += 16;
- }
+ eobtotal += c;
+ qcoeff_ptr += 16;
+ }
- return eobtotal;
+ return eobtotal;
}
diff --git a/vp8/decoder/ec_types.h b/vp8/decoder/ec_types.h
index ccb5ddbb9..983af7055 100644
--- a/vp8/decoder/ec_types.h
+++ b/vp8/decoder/ec_types.h
@@ -18,34 +18,30 @@
/* The area (pixel area in Q6) the block pointed to by bmi overlaps
* another block with.
*/
-typedef struct
-{
- int overlap;
- union b_mode_info *bmi;
+typedef struct {
+ int overlap;
+ union b_mode_info *bmi;
} OVERLAP_NODE;
/* Structure to keep track of overlapping blocks on a block level. */
-typedef struct
-{
- /* TODO(holmer): This array should be exchanged for a linked list */
- OVERLAP_NODE overlaps[MAX_OVERLAPS];
+typedef struct {
+ /* TODO(holmer): This array should be exchanged for a linked list */
+ OVERLAP_NODE overlaps[MAX_OVERLAPS];
} B_OVERLAP;
/* Structure used to hold all the overlaps of a macroblock. The overlaps of a
* macroblock is further divided into block overlaps.
*/
-typedef struct
-{
- B_OVERLAP overlaps[16];
+typedef struct {
+ B_OVERLAP overlaps[16];
} MB_OVERLAP;
/* Structure for keeping track of motion vectors and which reference frame they
* refer to. Used for motion vector interpolation.
*/
-typedef struct
-{
- MV mv;
- MV_REFERENCE_FRAME ref_frame;
+typedef struct {
+ MV mv;
+ MV_REFERENCE_FRAME ref_frame;
} EC_BLOCK;
#endif /* VP8_DEC_EC_TYPES_H */
diff --git a/vp8/decoder/generic/dsystemdependent.c b/vp8/decoder/generic/dsystemdependent.c
index 4b4a2d105..dd7f4e9f6 100644
--- a/vp8/decoder/generic/dsystemdependent.c
+++ b/vp8/decoder/generic/dsystemdependent.c
@@ -16,31 +16,30 @@
extern void vp8_arch_x86_decode_init(VP8D_COMP *pbi);
extern void vp8_arch_arm_decode_init(VP8D_COMP *pbi);
-void vp8_dmachine_specific_config(VP8D_COMP *pbi)
-{
- /* Pure C: */
+void vp8_dmachine_specific_config(VP8D_COMP *pbi) {
+ /* Pure C: */
#if CONFIG_RUNTIME_CPU_DETECT
- pbi->mb.rtcd = &pbi->common.rtcd;
- pbi->dequant.block_2x2 = vp8_dequantize_b_2x2_c;
- pbi->dequant.idct_add_8x8 = vp8_dequant_idct_add_8x8_c;
- pbi->dequant.dc_idct_add_8x8 = vp8_dequant_dc_idct_add_8x8_c;
- pbi->dequant.dc_idct_add_y_block_8x8 = vp8_dequant_dc_idct_add_y_block_8x8_c;
- pbi->dequant.idct_add_y_block_8x8 = vp8_dequant_idct_add_y_block_8x8_c;
- pbi->dequant.idct_add_uv_block_8x8 = vp8_dequant_idct_add_uv_block_8x8_c;
- pbi->dequant.block = vp8_dequantize_b_c;
- pbi->dequant.idct_add = vp8_dequant_idct_add_c;
- pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_c;
- pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_c;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_c;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_c;
+ pbi->mb.rtcd = &pbi->common.rtcd;
+ pbi->dequant.block_2x2 = vp8_dequantize_b_2x2_c;
+ pbi->dequant.idct_add_8x8 = vp8_dequant_idct_add_8x8_c;
+ pbi->dequant.dc_idct_add_8x8 = vp8_dequant_dc_idct_add_8x8_c;
+ pbi->dequant.dc_idct_add_y_block_8x8 = vp8_dequant_dc_idct_add_y_block_8x8_c;
+ pbi->dequant.idct_add_y_block_8x8 = vp8_dequant_idct_add_y_block_8x8_c;
+ pbi->dequant.idct_add_uv_block_8x8 = vp8_dequant_idct_add_uv_block_8x8_c;
+ pbi->dequant.block = vp8_dequantize_b_c;
+ pbi->dequant.idct_add = vp8_dequant_idct_add_c;
+ pbi->dequant.dc_idct_add = vp8_dequant_dc_idct_add_c;
+ pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_c;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_c;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_c;
#endif
#if ARCH_X86 || ARCH_X86_64
- vp8_arch_x86_decode_init(pbi);
+ vp8_arch_x86_decode_init(pbi);
#endif
#if ARCH_ARM
- vp8_arch_arm_decode_init(pbi);
+ vp8_arch_arm_decode_init(pbi);
#endif
}
diff --git a/vp8/decoder/idct_blk.c b/vp8/decoder/idct_blk.c
index ee23130de..36eea5d6f 100644
--- a/vp8/decoder/idct_blk.c
+++ b/vp8/decoder/idct_blk.c
@@ -21,257 +21,226 @@ void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr,
unsigned char *dst_ptr, int pitch, int stride);
#if CONFIG_LOSSLESS
void vp8_dequant_idct_add_lossless_c(short *input, short *dq, unsigned char *pred,
- unsigned char *dest, int pitch, int stride);
+ unsigned char *dest, int pitch, int stride);
void vp8_dc_only_idct_add_lossless_c(short input_dc, unsigned char *pred_ptr,
- unsigned char *dst_ptr, int pitch, int stride);
+ unsigned char *dst_ptr, int pitch, int stride);
#endif
void vp8_dequant_dc_idct_add_y_block_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i, j;
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_dc_idct_add_c (q, dq, pre, dst, 16, stride, dc[0]);
- else
- vp8_dc_only_idct_add_c (dc[0], pre, dst, 16, stride);
-
- q += 16;
- pre += 4;
- dst += 4;
- dc ++;
- }
-
- pre += 64 - 16;
- dst += 4*stride - 16;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i, j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_dc_idct_add_c(q, dq, pre, dst, 16, stride, dc[0]);
+ else
+ vp8_dc_only_idct_add_c(dc[0], pre, dst, 16, stride);
+
+ q += 16;
+ pre += 4;
+ dst += 4;
+ dc++;
}
+
+ pre += 64 - 16;
+ dst += 4 * stride - 16;
+ }
}
void vp8_dequant_idct_add_y_block_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i, j;
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_c (q, dq, pre, dst, 16, stride);
- else
- {
- vp8_dc_only_idct_add_c (q[0]*dq[0], pre, dst, 16, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dst += 4;
- }
-
- pre += 64 - 16;
- dst += 4*stride - 16;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i, j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_c(q, dq, pre, dst, 16, stride);
+ else {
+ vp8_dc_only_idct_add_c(q[0]*dq[0], pre, dst, 16, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dst += 4;
}
+
+ pre += 64 - 16;
+ dst += 4 * stride - 16;
+ }
}
void vp8_dequant_idct_add_uv_block_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
- int i, j;
-
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_c (q, dq, pre, dstu, 8, stride);
- else
- {
- vp8_dc_only_idct_add_c (q[0]*dq[0], pre, dstu, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dstu += 4;
- }
-
- pre += 32 - 8;
- dstu += 4*stride - 8;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ int i, j;
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_c(q, dq, pre, dstu, 8, stride);
+ else {
+ vp8_dc_only_idct_add_c(q[0]*dq[0], pre, dstu, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dstu += 4;
}
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_c (q, dq, pre, dstv, 8, stride);
- else
- {
- vp8_dc_only_idct_add_c (q[0]*dq[0], pre, dstv, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dstv += 4;
- }
-
- pre += 32 - 8;
- dstv += 4*stride - 8;
+ pre += 32 - 8;
+ dstu += 4 * stride - 8;
+ }
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_c(q, dq, pre, dstv, 8, stride);
+ else {
+ vp8_dc_only_idct_add_c(q[0]*dq[0], pre, dstv, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dstv += 4;
}
+
+ pre += 32 - 8;
+ dstv += 4 * stride - 8;
+ }
}
void vp8_dequant_dc_idct_add_y_block_8x8_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc, MACROBLOCKD *xd)
-{
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc, MACROBLOCKD *xd) {
- vp8_dequant_dc_idct_add_8x8_c (q, dq, pre, dst, 16, stride, dc[0]);
- vp8_dequant_dc_idct_add_8x8_c (&q[64], dq, pre+8, dst+8, 16, stride, dc[1]);
- vp8_dequant_dc_idct_add_8x8_c (&q[128], dq, pre+8*16, dst+8*stride, 16, stride, dc[4]);
- vp8_dequant_dc_idct_add_8x8_c (&q[192], dq, pre+8*16+8, dst+8*stride+8, 16, stride, dc[8]);
+ vp8_dequant_dc_idct_add_8x8_c(q, dq, pre, dst, 16, stride, dc[0]);
+ vp8_dequant_dc_idct_add_8x8_c(&q[64], dq, pre + 8, dst + 8, 16, stride, dc[1]);
+ vp8_dequant_dc_idct_add_8x8_c(&q[128], dq, pre + 8 * 16, dst + 8 * stride, 16, stride, dc[4]);
+ vp8_dequant_dc_idct_add_8x8_c(&q[192], dq, pre + 8 * 16 + 8, dst + 8 * stride + 8, 16, stride, dc[8]);
}
void vp8_dequant_idct_add_y_block_8x8_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, MACROBLOCKD *xd)
-{
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, MACROBLOCKD *xd) {
unsigned char *origdest = dst;
unsigned char *origpred = pre;
- vp8_dequant_idct_add_8x8_c (q, dq, pre, dst, 16, stride);
- vp8_dequant_idct_add_8x8_c (&q[64], dq, origpred+8, origdest+8, 16, stride);
- vp8_dequant_idct_add_8x8_c (&q[128], dq, origpred+8*16, origdest+8*stride, 16, stride);
- vp8_dequant_idct_add_8x8_c (&q[192], dq, origpred+8*16+8, origdest+8*stride+8, 16, stride);
+ vp8_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride);
+ vp8_dequant_idct_add_8x8_c(&q[64], dq, origpred + 8, origdest + 8, 16, stride);
+ vp8_dequant_idct_add_8x8_c(&q[128], dq, origpred + 8 * 16, origdest + 8 * stride, 16, stride);
+ vp8_dequant_idct_add_8x8_c(&q[192], dq, origpred + 8 * 16 + 8, origdest + 8 * stride + 8, 16, stride);
}
void vp8_dequant_idct_add_uv_block_8x8_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs, MACROBLOCKD *xd)
-{
- vp8_dequant_idct_add_8x8_c (q, dq, pre, dstu, 8, stride);
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs, MACROBLOCKD *xd) {
+ vp8_dequant_idct_add_8x8_c(q, dq, pre, dstu, 8, stride);
q += 64;
pre += 64;
- vp8_dequant_idct_add_8x8_c (q, dq, pre, dstv, 8, stride);
+ vp8_dequant_idct_add_8x8_c(q, dq, pre, dstv, 8, stride);
}
#if CONFIG_LOSSLESS
void vp8_dequant_dc_idct_add_y_block_lossless_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i, j;
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_dc_idct_add_lossless_c (q, dq, pre, dst, 16, stride, dc[0]);
- else
- vp8_dc_only_inv_walsh_add_c(dc[0], pre, dst, 16, stride);
-
- q += 16;
- pre += 4;
- dst += 4;
- dc ++;
- }
-
- pre += 64 - 16;
- dst += 4*stride - 16;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i, j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_dc_idct_add_lossless_c(q, dq, pre, dst, 16, stride, dc[0]);
+ else
+ vp8_dc_only_inv_walsh_add_c(dc[0], pre, dst, 16, stride);
+
+ q += 16;
+ pre += 4;
+ dst += 4;
+ dc++;
}
+
+ pre += 64 - 16;
+ dst += 4 * stride - 16;
+ }
}
void vp8_dequant_idct_add_y_block_lossless_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i, j;
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_lossless_c (q, dq, pre, dst, 16, stride);
- else
- {
- vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dst += 4;
- }
-
- pre += 64 - 16;
- dst += 4*stride - 16;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i, j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride);
+ else {
+ vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dst += 4;
}
+
+ pre += 64 - 16;
+ dst += 4 * stride - 16;
+ }
}
void vp8_dequant_idct_add_uv_block_lossless_c
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
- int i, j;
-
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_lossless_c (q, dq, pre, dstu, 8, stride);
- else
- {
- vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dstu += 4;
- }
-
- pre += 32 - 8;
- dstu += 4*stride - 8;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ int i, j;
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride);
+ else {
+ vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dstu += 4;
}
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < 2; j++)
- {
- if (*eobs++ > 1)
- vp8_dequant_idct_add_lossless_c (q, dq, pre, dstv, 8, stride);
- else
- {
- vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstv, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- q += 16;
- pre += 4;
- dstv += 4;
- }
-
- pre += 32 - 8;
- dstv += 4*stride - 8;
+ pre += 32 - 8;
+ dstu += 4 * stride - 8;
+ }
+
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ if (*eobs++ > 1)
+ vp8_dequant_idct_add_lossless_c(q, dq, pre, dstv, 8, stride);
+ else {
+ vp8_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstv, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ q += 16;
+ pre += 4;
+ dstv += 4;
}
+
+ pre += 32 - 8;
+ dstv += 4 * stride - 8;
+ }
}
#endif
diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c
index 201585f8b..992b5db08 100644
--- a/vp8/decoder/onyxd_if.c
+++ b/vp8/decoder/onyxd_if.c
@@ -35,223 +35,206 @@
extern void vp8_init_loop_filter(VP8_COMMON *cm);
extern void vp8cx_init_de_quantizer(VP8D_COMP *pbi);
-static int get_free_fb (VP8_COMMON *cm);
-static void ref_cnt_fb (int *buf, int *idx, int new_idx);
+static int get_free_fb(VP8_COMMON *cm);
+static void ref_cnt_fb(int *buf, int *idx, int new_idx);
#if CONFIG_DEBUG
-void vp8_recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s)
-{
- FILE *yuv_file = fopen((char *)name, "ab");
- unsigned char *src = s->y_buffer;
- int h = s->y_height;
+void vp8_recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s) {
+ FILE *yuv_file = fopen((char *)name, "ab");
+ unsigned char *src = s->y_buffer;
+ int h = s->y_height;
- do
- {
- fwrite(src, s->y_width, 1, yuv_file);
- src += s->y_stride;
- }
- while (--h);
+ do {
+ fwrite(src, s->y_width, 1, yuv_file);
+ src += s->y_stride;
+ } while (--h);
- src = s->u_buffer;
- h = s->uv_height;
+ src = s->u_buffer;
+ h = s->uv_height;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_file);
- src += s->uv_stride;
- }
- while (--h);
+ do {
+ fwrite(src, s->uv_width, 1, yuv_file);
+ src += s->uv_stride;
+ } while (--h);
- src = s->v_buffer;
- h = s->uv_height;
+ src = s->v_buffer;
+ h = s->uv_height;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_file);
- src += s->uv_stride;
- }
- while (--h);
+ do {
+ fwrite(src, s->uv_width, 1, yuv_file);
+ src += s->uv_stride;
+ } while (--h);
- fclose(yuv_file);
+ fclose(yuv_file);
}
#endif
-//#define WRITE_RECON_BUFFER 1
+// #define WRITE_RECON_BUFFER 1
#if WRITE_RECON_BUFFER
-void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
-{
+void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) {
- // write the frame
- FILE *yframe;
- int i;
- char filename[255];
+ // write the frame
+ FILE *yframe;
+ int i;
+ char filename[255];
- sprintf(filename, "dx\\y%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ sprintf(filename, "dx\\y%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->y_height; i++)
- fwrite(frame->y_buffer + i * frame->y_stride,
- frame->y_width, 1, yframe);
+ for (i = 0; i < frame->y_height; i++)
+ fwrite(frame->y_buffer + i * frame->y_stride,
+ frame->y_width, 1, yframe);
- fclose(yframe);
- sprintf(filename, "dx\\u%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ fclose(yframe);
+ sprintf(filename, "dx\\u%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->u_buffer + i * frame->uv_stride,
- frame->uv_width, 1, yframe);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->u_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, yframe);
- fclose(yframe);
- sprintf(filename, "dx\\v%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ fclose(yframe);
+ sprintf(filename, "dx\\v%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->v_buffer + i * frame->uv_stride,
- frame->uv_width, 1, yframe);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->v_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, yframe);
- fclose(yframe);
+ fclose(yframe);
}
#endif
-void vp8dx_initialize()
-{
- static int init_done = 0;
+void vp8dx_initialize() {
+ static int init_done = 0;
- if (!init_done)
- {
- vp8_initialize_common();
- vp8_init_quant_tables();
- vp8_scale_machine_specific_config();
- init_done = 1;
- }
+ if (!init_done) {
+ vp8_initialize_common();
+ vp8_init_quant_tables();
+ vp8_scale_machine_specific_config();
+ init_done = 1;
+ }
}
-VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf)
-{
- VP8D_COMP *pbi = vpx_memalign(32, sizeof(VP8D_COMP));
+VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf) {
+ VP8D_COMP *pbi = vpx_memalign(32, sizeof(VP8D_COMP));
- if (!pbi)
- return NULL;
+ if (!pbi)
+ return NULL;
- vpx_memset(pbi, 0, sizeof(VP8D_COMP));
+ vpx_memset(pbi, 0, sizeof(VP8D_COMP));
- if (setjmp(pbi->common.error.jmp))
- {
- pbi->common.error.setjmp = 0;
- vp8dx_remove_decompressor(pbi);
- return 0;
- }
+ if (setjmp(pbi->common.error.jmp)) {
+ pbi->common.error.setjmp = 0;
+ vp8dx_remove_decompressor(pbi);
+ return 0;
+ }
- pbi->common.error.setjmp = 1;
- vp8dx_initialize();
+ pbi->common.error.setjmp = 1;
+ vp8dx_initialize();
- vp8_create_common(&pbi->common);
- vp8_dmachine_specific_config(pbi);
+ vp8_create_common(&pbi->common);
+ vp8_dmachine_specific_config(pbi);
- pbi->common.current_video_frame = 0;
- pbi->ready_for_new_data = 1;
+ pbi->common.current_video_frame = 0;
+ pbi->ready_for_new_data = 1;
- /* vp8cx_init_de_quantizer() is first called here. Add check in frame_init_dequantizer() to avoid
- * unnecessary calling of vp8cx_init_de_quantizer() for every frame.
- */
- vp8cx_init_de_quantizer(pbi);
+ /* vp8cx_init_de_quantizer() is first called here. Add check in frame_init_dequantizer() to avoid
+ * unnecessary calling of vp8cx_init_de_quantizer() for every frame.
+ */
+ vp8cx_init_de_quantizer(pbi);
- vp8_loop_filter_init(&pbi->common);
+ vp8_loop_filter_init(&pbi->common);
- pbi->common.error.setjmp = 0;
+ pbi->common.error.setjmp = 0;
- pbi->decoded_key_frame = 0;
+ pbi->decoded_key_frame = 0;
- return (VP8D_PTR) pbi;
+ return (VP8D_PTR) pbi;
}
-void vp8dx_remove_decompressor(VP8D_PTR ptr)
-{
- VP8D_COMP *pbi = (VP8D_COMP *) ptr;
+void vp8dx_remove_decompressor(VP8D_PTR ptr) {
+ VP8D_COMP *pbi = (VP8D_COMP *) ptr;
- if (!pbi)
- return;
+ if (!pbi)
+ return;
- // Delete sementation map
- if (pbi->common.last_frame_seg_map != 0)
- vpx_free(pbi->common.last_frame_seg_map);
+ // Delete sementation map
+ if (pbi->common.last_frame_seg_map != 0)
+ vpx_free(pbi->common.last_frame_seg_map);
- vp8_remove_common(&pbi->common);
- vpx_free(pbi->mbc);
- vpx_free(pbi);
+ vp8_remove_common(&pbi->common);
+ vpx_free(pbi->mbc);
+ vpx_free(pbi);
}
-vpx_codec_err_t vp8dx_get_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
-{
- VP8D_COMP *pbi = (VP8D_COMP *) ptr;
- VP8_COMMON *cm = &pbi->common;
- int ref_fb_idx;
-
- if (ref_frame_flag == VP8_LAST_FLAG)
- ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
- ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
- ref_fb_idx = cm->alt_fb_idx;
- else{
- vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
- "Invalid reference frame");
- return pbi->common.error.error_code;
- }
+vpx_codec_err_t vp8dx_get_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd) {
+ VP8D_COMP *pbi = (VP8D_COMP *) ptr;
+ VP8_COMMON *cm = &pbi->common;
+ int ref_fb_idx;
+
+ if (ref_frame_flag == VP8_LAST_FLAG)
+ ref_fb_idx = cm->lst_fb_idx;
+ else if (ref_frame_flag == VP8_GOLD_FLAG)
+ ref_fb_idx = cm->gld_fb_idx;
+ else if (ref_frame_flag == VP8_ALT_FLAG)
+ ref_fb_idx = cm->alt_fb_idx;
+ else {
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
+ "Invalid reference frame");
+ return pbi->common.error.error_code;
+ }
- if(cm->yv12_fb[ref_fb_idx].y_height != sd->y_height ||
- cm->yv12_fb[ref_fb_idx].y_width != sd->y_width ||
- cm->yv12_fb[ref_fb_idx].uv_height != sd->uv_height ||
- cm->yv12_fb[ref_fb_idx].uv_width != sd->uv_width){
- vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
- "Incorrect buffer dimensions");
- }
- else
- vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
+ if (cm->yv12_fb[ref_fb_idx].y_height != sd->y_height ||
+ cm->yv12_fb[ref_fb_idx].y_width != sd->y_width ||
+ cm->yv12_fb[ref_fb_idx].uv_height != sd->uv_height ||
+ cm->yv12_fb[ref_fb_idx].uv_width != sd->uv_width) {
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
+ "Incorrect buffer dimensions");
+ } else
+ vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
- return pbi->common.error.error_code;
+ return pbi->common.error.error_code;
}
-vpx_codec_err_t vp8dx_set_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
-{
- VP8D_COMP *pbi = (VP8D_COMP *) ptr;
- VP8_COMMON *cm = &pbi->common;
- int *ref_fb_ptr = NULL;
- int free_fb;
-
- if (ref_frame_flag == VP8_LAST_FLAG)
- ref_fb_ptr = &cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
- ref_fb_ptr = &cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
- ref_fb_ptr = &cm->alt_fb_idx;
- else{
- vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
- "Invalid reference frame");
- return pbi->common.error.error_code;
- }
+vpx_codec_err_t vp8dx_set_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd) {
+ VP8D_COMP *pbi = (VP8D_COMP *) ptr;
+ VP8_COMMON *cm = &pbi->common;
+ int *ref_fb_ptr = NULL;
+ int free_fb;
+
+ if (ref_frame_flag == VP8_LAST_FLAG)
+ ref_fb_ptr = &cm->lst_fb_idx;
+ else if (ref_frame_flag == VP8_GOLD_FLAG)
+ ref_fb_ptr = &cm->gld_fb_idx;
+ else if (ref_frame_flag == VP8_ALT_FLAG)
+ ref_fb_ptr = &cm->alt_fb_idx;
+ else {
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
+ "Invalid reference frame");
+ return pbi->common.error.error_code;
+ }
- if(cm->yv12_fb[*ref_fb_ptr].y_height != sd->y_height ||
- cm->yv12_fb[*ref_fb_ptr].y_width != sd->y_width ||
- cm->yv12_fb[*ref_fb_ptr].uv_height != sd->uv_height ||
- cm->yv12_fb[*ref_fb_ptr].uv_width != sd->uv_width){
- vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
- "Incorrect buffer dimensions");
- }
- else{
- /* Find an empty frame buffer. */
- free_fb = get_free_fb(cm);
- /* Decrease fb_idx_ref_cnt since it will be increased again in
- * ref_cnt_fb() below. */
- cm->fb_idx_ref_cnt[free_fb]--;
-
- /* Manage the reference counters and copy image. */
- ref_cnt_fb (cm->fb_idx_ref_cnt, ref_fb_ptr, free_fb);
- vp8_yv12_copy_frame_ptr(sd, &cm->yv12_fb[*ref_fb_ptr]);
- }
+ if (cm->yv12_fb[*ref_fb_ptr].y_height != sd->y_height ||
+ cm->yv12_fb[*ref_fb_ptr].y_width != sd->y_width ||
+ cm->yv12_fb[*ref_fb_ptr].uv_height != sd->uv_height ||
+ cm->yv12_fb[*ref_fb_ptr].uv_width != sd->uv_width) {
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
+ "Incorrect buffer dimensions");
+ } else {
+ /* Find an empty frame buffer. */
+ free_fb = get_free_fb(cm);
+ /* Decrease fb_idx_ref_cnt since it will be increased again in
+ * ref_cnt_fb() below. */
+ cm->fb_idx_ref_cnt[free_fb]--;
+
+ /* Manage the reference counters and copy image. */
+ ref_cnt_fb(cm->fb_idx_ref_cnt, ref_fb_ptr, free_fb);
+ vp8_yv12_copy_frame_ptr(sd, &cm->yv12_fb[*ref_fb_ptr]);
+ }
- return pbi->common.error.error_code;
+ return pbi->common.error.error_code;
}
/*For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us.*/
@@ -260,84 +243,77 @@ extern void vp8_push_neon(int64_t *store);
extern void vp8_pop_neon(int64_t *store);
#endif
-static int get_free_fb (VP8_COMMON *cm)
-{
- int i;
- for (i = 0; i < NUM_YV12_BUFFERS; i++)
- if (cm->fb_idx_ref_cnt[i] == 0)
- break;
+static int get_free_fb(VP8_COMMON *cm) {
+ int i;
+ for (i = 0; i < NUM_YV12_BUFFERS; i++)
+ if (cm->fb_idx_ref_cnt[i] == 0)
+ break;
- assert(i < NUM_YV12_BUFFERS);
- cm->fb_idx_ref_cnt[i] = 1;
- return i;
+ assert(i < NUM_YV12_BUFFERS);
+ cm->fb_idx_ref_cnt[i] = 1;
+ return i;
}
-static void ref_cnt_fb (int *buf, int *idx, int new_idx)
-{
- if (buf[*idx] > 0)
- buf[*idx]--;
+static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
+ if (buf[*idx] > 0)
+ buf[*idx]--;
- *idx = new_idx;
+ *idx = new_idx;
- buf[new_idx]++;
+ buf[new_idx]++;
}
/* If any buffer copy / swapping is signalled it should be done here. */
-static int swap_frame_buffers (VP8_COMMON *cm)
-{
- int err = 0;
-
- /* The alternate reference frame or golden frame can be updated
- * using the new, last, or golden/alt ref frame. If it
- * is updated using the newly decoded frame it is a refresh.
- * An update using the last or golden/alt ref frame is a copy.
- */
- if (cm->copy_buffer_to_arf)
- {
- int new_fb = 0;
-
- if (cm->copy_buffer_to_arf == 1)
- new_fb = cm->lst_fb_idx;
- else if (cm->copy_buffer_to_arf == 2)
- new_fb = cm->gld_fb_idx;
- else
- err = -1;
+static int swap_frame_buffers(VP8_COMMON *cm) {
+ int err = 0;
+
+ /* The alternate reference frame or golden frame can be updated
+ * using the new, last, or golden/alt ref frame. If it
+ * is updated using the newly decoded frame it is a refresh.
+ * An update using the last or golden/alt ref frame is a copy.
+ */
+ if (cm->copy_buffer_to_arf) {
+ int new_fb = 0;
+
+ if (cm->copy_buffer_to_arf == 1)
+ new_fb = cm->lst_fb_idx;
+ else if (cm->copy_buffer_to_arf == 2)
+ new_fb = cm->gld_fb_idx;
+ else
+ err = -1;
- ref_cnt_fb (cm->fb_idx_ref_cnt, &cm->alt_fb_idx, new_fb);
- }
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, new_fb);
+ }
- if (cm->copy_buffer_to_gf)
- {
- int new_fb = 0;
+ if (cm->copy_buffer_to_gf) {
+ int new_fb = 0;
- if (cm->copy_buffer_to_gf == 1)
- new_fb = cm->lst_fb_idx;
- else if (cm->copy_buffer_to_gf == 2)
- new_fb = cm->alt_fb_idx;
- else
- err = -1;
+ if (cm->copy_buffer_to_gf == 1)
+ new_fb = cm->lst_fb_idx;
+ else if (cm->copy_buffer_to_gf == 2)
+ new_fb = cm->alt_fb_idx;
+ else
+ err = -1;
- ref_cnt_fb (cm->fb_idx_ref_cnt, &cm->gld_fb_idx, new_fb);
- }
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, new_fb);
+ }
- if (cm->refresh_golden_frame)
- ref_cnt_fb (cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
+ if (cm->refresh_golden_frame)
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
- if (cm->refresh_alt_ref_frame)
- ref_cnt_fb (cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
+ if (cm->refresh_alt_ref_frame)
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
- if (cm->refresh_last_frame)
- {
- ref_cnt_fb (cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
+ if (cm->refresh_last_frame) {
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
- cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx];
- }
- else
- cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
+ cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx];
+ } else
+ cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
- cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
- return err;
+ return err;
}
/*
@@ -356,233 +332,217 @@ static void vp8_print_yuv_rec_mb(VP8_COMMON *cm, int mb_row, int mb_col)
}
*/
-int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsigned char *source, int64_t time_stamp)
-{
+int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsigned char *source, int64_t time_stamp) {
#if HAVE_ARMV7
- int64_t dx_store_reg[8];
+ int64_t dx_store_reg[8];
#endif
- VP8D_COMP *pbi = (VP8D_COMP *) ptr;
- VP8_COMMON *cm = &pbi->common;
- int retcode = 0;
+ VP8D_COMP *pbi = (VP8D_COMP *) ptr;
+ VP8_COMMON *cm = &pbi->common;
+ int retcode = 0;
- /*if(pbi->ready_for_new_data == 0)
- return -1;*/
+ /*if(pbi->ready_for_new_data == 0)
+ return -1;*/
- if (ptr == 0)
- {
- return -1;
- }
+ if (ptr == 0) {
+ return -1;
+ }
- pbi->common.error.error_code = VPX_CODEC_OK;
+ pbi->common.error.error_code = VPX_CODEC_OK;
- pbi->Source = source;
- pbi->source_sz = size;
+ pbi->Source = source;
+ pbi->source_sz = size;
- if (pbi->source_sz == 0)
- {
- /* This is used to signal that we are missing frames.
- * We do not know if the missing frame(s) was supposed to update
- * any of the reference buffers, but we act conservative and
- * mark only the last buffer as corrupted.
- */
- cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
- }
+ if (pbi->source_sz == 0) {
+ /* This is used to signal that we are missing frames.
+ * We do not know if the missing frame(s) was supposed to update
+ * any of the reference buffers, but we act conservative and
+ * mark only the last buffer as corrupted.
+ */
+ cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
+ }
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_push_neon(dx_store_reg);
- }
+ {
+ vp8_push_neon(dx_store_reg);
+ }
#endif
- cm->new_fb_idx = get_free_fb (cm);
+ cm->new_fb_idx = get_free_fb(cm);
- if (setjmp(pbi->common.error.jmp))
- {
+ if (setjmp(pbi->common.error.jmp)) {
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_pop_neon(dx_store_reg);
- }
+ {
+ vp8_pop_neon(dx_store_reg);
+ }
#endif
- pbi->common.error.setjmp = 0;
+ pbi->common.error.setjmp = 0;
- /* We do not know if the missing frame(s) was supposed to update
- * any of the reference buffers, but we act conservative and
- * mark only the last buffer as corrupted.
- */
- cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
+ /* We do not know if the missing frame(s) was supposed to update
+ * any of the reference buffers, but we act conservative and
+ * mark only the last buffer as corrupted.
+ */
+ cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
- if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
- cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
- return -1;
- }
+ if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
+ cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ return -1;
+ }
- pbi->common.error.setjmp = 1;
+ pbi->common.error.setjmp = 1;
- retcode = vp8_decode_frame(pbi);
+ retcode = vp8_decode_frame(pbi);
- if (retcode < 0)
- {
+ if (retcode < 0) {
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_pop_neon(dx_store_reg);
- }
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- pbi->common.error.error_code = VPX_CODEC_ERROR;
- pbi->common.error.setjmp = 0;
- if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
- cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
- return retcode;
+ {
+ vp8_pop_neon(dx_store_reg);
}
+#endif
+ pbi->common.error.error_code = VPX_CODEC_ERROR;
+ pbi->common.error.setjmp = 0;
+ if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
+ cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ return retcode;
+ }
- {
- if (swap_frame_buffers (cm))
- {
+ {
+ if (swap_frame_buffers(cm)) {
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_pop_neon(dx_store_reg);
- }
+ {
+ vp8_pop_neon(dx_store_reg);
+ }
#endif
- pbi->common.error.error_code = VPX_CODEC_ERROR;
- pbi->common.error.setjmp = 0;
- return -1;
- }
+ pbi->common.error.error_code = VPX_CODEC_ERROR;
+ pbi->common.error.setjmp = 0;
+ return -1;
+ }
#if WRITE_RECON_BUFFER
- if(cm->show_frame)
- write_dx_frame_to_file(cm->frame_to_show,
- cm->current_video_frame);
- else
- write_dx_frame_to_file(cm->frame_to_show,
- cm->current_video_frame+1000);
+ if (cm->show_frame)
+ write_dx_frame_to_file(cm->frame_to_show,
+ cm->current_video_frame);
+ else
+ write_dx_frame_to_file(cm->frame_to_show,
+ cm->current_video_frame + 1000);
#endif
- if(cm->filter_level)
- {
- /* Apply the loop filter if appropriate. */
- vp8_loop_filter_frame(cm, &pbi->mb);
- }
- vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show);
+ if (cm->filter_level) {
+ /* Apply the loop filter if appropriate. */
+ vp8_loop_filter_frame(cm, &pbi->mb);
}
+ vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show);
+ }
#if CONFIG_DEBUG
- if(cm->show_frame)
- vp8_recon_write_yuv_frame("recon.yuv", cm->frame_to_show);
+ if (cm->show_frame)
+ vp8_recon_write_yuv_frame("recon.yuv", cm->frame_to_show);
#endif
- vp8_clear_system_state();
+ vp8_clear_system_state();
- if(cm->show_frame)
- {
- vpx_memcpy(cm->prev_mip, cm->mip,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
- }
- else
- {
- vpx_memset(cm->prev_mip, 0,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
- }
+ if (cm->show_frame) {
+ vpx_memcpy(cm->prev_mip, cm->mip,
+ (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
+ } else {
+ vpx_memset(cm->prev_mip, 0,
+ (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
+ }
- /*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/
+ /*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/
- if (cm->show_frame)
- cm->current_video_frame++;
+ if (cm->show_frame)
+ cm->current_video_frame++;
- pbi->ready_for_new_data = 0;
- pbi->last_time_stamp = time_stamp;
- pbi->source_sz = 0;
+ pbi->ready_for_new_data = 0;
+ pbi->last_time_stamp = time_stamp;
+ pbi->source_sz = 0;
#if 0
- {
- int i;
- int64_t earliest_time = pbi->dr[0].time_stamp;
- int64_t latest_time = pbi->dr[0].time_stamp;
- int64_t time_diff = 0;
- int bytes = 0;
-
- pbi->dr[pbi->common.current_video_frame&0xf].size = pbi->bc.pos + pbi->bc2.pos + 4;;
- pbi->dr[pbi->common.current_video_frame&0xf].time_stamp = time_stamp;
+ {
+ int i;
+ int64_t earliest_time = pbi->dr[0].time_stamp;
+ int64_t latest_time = pbi->dr[0].time_stamp;
+ int64_t time_diff = 0;
+ int bytes = 0;
- for (i = 0; i < 16; i++)
- {
+ pbi->dr[pbi->common.current_video_frame & 0xf].size = pbi->bc.pos + pbi->bc2.pos + 4;;
+ pbi->dr[pbi->common.current_video_frame & 0xf].time_stamp = time_stamp;
- bytes += pbi->dr[i].size;
+ for (i = 0; i < 16; i++) {
- if (pbi->dr[i].time_stamp < earliest_time)
- earliest_time = pbi->dr[i].time_stamp;
+ bytes += pbi->dr[i].size;
- if (pbi->dr[i].time_stamp > latest_time)
- latest_time = pbi->dr[i].time_stamp;
- }
+ if (pbi->dr[i].time_stamp < earliest_time)
+ earliest_time = pbi->dr[i].time_stamp;
- time_diff = latest_time - earliest_time;
+ if (pbi->dr[i].time_stamp > latest_time)
+ latest_time = pbi->dr[i].time_stamp;
+ }
- if (time_diff > 0)
- {
- pbi->common.bitrate = 80000.00 * bytes / time_diff ;
- pbi->common.framerate = 160000000.00 / time_diff ;
- }
+ time_diff = latest_time - earliest_time;
+ if (time_diff > 0) {
+ pbi->common.bitrate = 80000.00 * bytes / time_diff;
+ pbi->common.framerate = 160000000.00 / time_diff;
}
+
+ }
#endif
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_pop_neon(dx_store_reg);
- }
+ {
+ vp8_pop_neon(dx_store_reg);
+ }
#endif
- pbi->common.error.setjmp = 0;
- return retcode;
+ pbi->common.error.setjmp = 0;
+ return retcode;
}
-int vp8dx_get_raw_frame(VP8D_PTR ptr, YV12_BUFFER_CONFIG *sd, int64_t *time_stamp, int64_t *time_end_stamp, vp8_ppflags_t *flags)
-{
- int ret = -1;
- VP8D_COMP *pbi = (VP8D_COMP *) ptr;
+int vp8dx_get_raw_frame(VP8D_PTR ptr, YV12_BUFFER_CONFIG *sd, int64_t *time_stamp, int64_t *time_end_stamp, vp8_ppflags_t *flags) {
+ int ret = -1;
+ VP8D_COMP *pbi = (VP8D_COMP *) ptr;
- if (pbi->ready_for_new_data == 1)
- return ret;
+ if (pbi->ready_for_new_data == 1)
+ return ret;
- /* ie no raw frame to show!!! */
- if (pbi->common.show_frame == 0)
- return ret;
+ /* ie no raw frame to show!!! */
+ if (pbi->common.show_frame == 0)
+ return ret;
- pbi->ready_for_new_data = 1;
- *time_stamp = pbi->last_time_stamp;
- *time_end_stamp = 0;
+ pbi->ready_for_new_data = 1;
+ *time_stamp = pbi->last_time_stamp;
+ *time_end_stamp = 0;
- sd->clrtype = pbi->common.clr_type;
+ sd->clrtype = pbi->common.clr_type;
#if CONFIG_POSTPROC
- ret = vp8_post_proc_frame(&pbi->common, sd, flags);
+ ret = vp8_post_proc_frame(&pbi->common, sd, flags);
#else
- if (pbi->common.frame_to_show)
- {
- *sd = *pbi->common.frame_to_show;
- sd->y_width = pbi->common.Width;
- sd->y_height = pbi->common.Height;
- sd->uv_height = pbi->common.Height / 2;
- ret = 0;
- }
- else
- {
- ret = -1;
- }
+ if (pbi->common.frame_to_show) {
+ *sd = *pbi->common.frame_to_show;
+ sd->y_width = pbi->common.Width;
+ sd->y_height = pbi->common.Height;
+ sd->uv_height = pbi->common.Height / 2;
+ ret = 0;
+ } else {
+ ret = -1;
+ }
#endif /*!CONFIG_POSTPROC*/
- vp8_clear_system_state();
- return ret;
+ vp8_clear_system_state();
+ return ret;
}
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index c7ee834b4..5ad0ac83f 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -17,81 +17,76 @@
#include "vp8/common/onyxc_int.h"
#include "dequantize.h"
-//#define DEC_DEBUG
+// #define DEC_DEBUG
-typedef struct
-{
- int ithread;
- void *ptr1;
- void *ptr2;
+typedef struct {
+ int ithread;
+ void *ptr1;
+ void *ptr2;
} DECODETHREAD_DATA;
-typedef struct
-{
- MACROBLOCKD mbd;
- int mb_row;
- int current_mb_col;
- short *coef_ptr;
+typedef struct {
+ MACROBLOCKD mbd;
+ int mb_row;
+ int current_mb_col;
+ short *coef_ptr;
} MB_ROW_DEC;
-typedef struct
-{
- int64_t time_stamp;
- int size;
+typedef struct {
+ int64_t time_stamp;
+ int size;
} DATARATE;
-typedef struct
-{
- int const *scan;
- int const *scan_8x8;
- UINT8 const *ptr_block2leftabove;
- vp8_tree_index const *vp8_coef_tree_ptr;
- unsigned char *norm_ptr;
- UINT8 *ptr_coef_bands_x;
- UINT8 *ptr_coef_bands_x_8x8;
+typedef struct {
+ int const *scan;
+ int const *scan_8x8;
+ UINT8 const *ptr_block2leftabove;
+ vp8_tree_index const *vp8_coef_tree_ptr;
+ unsigned char *norm_ptr;
+ UINT8 *ptr_coef_bands_x;
+ UINT8 *ptr_coef_bands_x_8x8;
- ENTROPY_CONTEXT_PLANES *A;
- ENTROPY_CONTEXT_PLANES *L;
+ ENTROPY_CONTEXT_PLANES *A;
+ ENTROPY_CONTEXT_PLANES *L;
- INT16 *qcoeff_start_ptr;
- BOOL_DECODER *current_bc;
+ INT16 *qcoeff_start_ptr;
+ BOOL_DECODER *current_bc;
- vp8_prob const *coef_probs[BLOCK_TYPES];
- vp8_prob const *coef_probs_8x8[BLOCK_TYPES_8X8];
+ vp8_prob const *coef_probs[BLOCK_TYPES];
+ vp8_prob const *coef_probs_8x8[BLOCK_TYPES_8X8];
- UINT8 eob[25];
+ UINT8 eob[25];
} DETOK;
-typedef struct VP8Decompressor
-{
- DECLARE_ALIGNED(16, MACROBLOCKD, mb);
+typedef struct VP8Decompressor {
+ DECLARE_ALIGNED(16, MACROBLOCKD, mb);
- DECLARE_ALIGNED(16, VP8_COMMON, common);
+ DECLARE_ALIGNED(16, VP8_COMMON, common);
- vp8_reader bc, bc2;
+ vp8_reader bc, bc2;
- VP8D_CONFIG oxcf;
+ VP8D_CONFIG oxcf;
- const unsigned char *Source;
- unsigned int source_sz;
+ const unsigned char *Source;
+ unsigned int source_sz;
- vp8_reader *mbc;
- int64_t last_time_stamp;
- int ready_for_new_data;
+ vp8_reader *mbc;
+ int64_t last_time_stamp;
+ int ready_for_new_data;
- DATARATE dr[16];
+ DATARATE dr[16];
- DETOK detoken;
+ DETOK detoken;
#if CONFIG_RUNTIME_CPU_DETECT
- vp8_dequant_rtcd_vtable_t dequant;
+ vp8_dequant_rtcd_vtable_t dequant;
#endif
- vp8_prob prob_skip_false;
+ vp8_prob prob_skip_false;
- int decoded_key_frame;
+ int decoded_key_frame;
} VP8D_COMP;
@@ -101,19 +96,19 @@ void vp8_dmachine_specific_config(VP8D_COMP *pbi);
#if CONFIG_DEBUG
#define CHECK_MEM_ERROR(lval,expr) do {\
- lval = (expr); \
- if(!lval) \
- vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
- "Failed to allocate "#lval" at %s:%d", \
- __FILE__,__LINE__);\
- } while(0)
+ lval = (expr); \
+ if(!lval) \
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
+ "Failed to allocate "#lval" at %s:%d", \
+ __FILE__,__LINE__);\
+ } while(0)
#else
#define CHECK_MEM_ERROR(lval,expr) do {\
- lval = (expr); \
- if(!lval) \
- vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
- "Failed to allocate "#lval);\
- } while(0)
+ lval = (expr); \
+ if(!lval) \
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
+ "Failed to allocate "#lval);\
+ } while(0)
#endif
#endif
diff --git a/vp8/decoder/reconintra_mt.c b/vp8/decoder/reconintra_mt.c
index b9d2b3703..da6816d56 100644
--- a/vp8/decoder/reconintra_mt.c
+++ b/vp8/decoder/reconintra_mt.c
@@ -19,121 +19,102 @@
* vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x).
*/
-void vp8mt_build_intra_predictors_mby(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col)
-{
- unsigned char *yabove_row; /* = x->dst.y_buffer - x->dst.y_stride; */
- unsigned char *yleft_col;
- unsigned char yleft_buf[16];
- unsigned char ytop_left; /* = yabove_row[-1]; */
- unsigned char *ypred_ptr = x->predictor;
- int r, c, i;
-
- if (pbi->common.filter_level)
- {
- yabove_row = pbi->mt_yabove_row[mb_row] + mb_col*16 +32;
- yleft_col = pbi->mt_yleft_col[mb_row];
- } else
- {
- yabove_row = x->dst.y_buffer - x->dst.y_stride;
-
- for (i = 0; i < 16; i++)
- yleft_buf[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
- yleft_col = yleft_buf;
- }
-
- ytop_left = yabove_row[-1];
+void vp8mt_build_intra_predictors_mby(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col) {
+ unsigned char *yabove_row; /* = x->dst.y_buffer - x->dst.y_stride; */
+ unsigned char *yleft_col;
+ unsigned char yleft_buf[16];
+ unsigned char ytop_left; /* = yabove_row[-1]; */
+ unsigned char *ypred_ptr = x->predictor;
+ int r, c, i;
- /* for Y */
- switch (x->mode_info_context->mbmi.mode)
- {
- case DC_PRED:
- {
- int expected_dc;
- int i;
- int shift;
- int average = 0;
+ if (pbi->common.filter_level) {
+ yabove_row = pbi->mt_yabove_row[mb_row] + mb_col * 16 + 32;
+ yleft_col = pbi->mt_yleft_col[mb_row];
+ } else {
+ yabove_row = x->dst.y_buffer - x->dst.y_stride;
+ for (i = 0; i < 16; i++)
+ yleft_buf[i] = x->dst.y_buffer [i * x->dst.y_stride - 1];
+ yleft_col = yleft_buf;
+ }
- if (x->up_available || x->left_available)
- {
- if (x->up_available)
- {
- for (i = 0; i < 16; i++)
- {
- average += yabove_row[i];
- }
- }
+ ytop_left = yabove_row[-1];
- if (x->left_available)
- {
+ /* for Y */
+ switch (x->mode_info_context->mbmi.mode) {
+ case DC_PRED: {
+ int expected_dc;
+ int i;
+ int shift;
+ int average = 0;
- for (i = 0; i < 16; i++)
- {
- average += yleft_col[i];
- }
- }
+ if (x->up_available || x->left_available) {
+ if (x->up_available) {
+ for (i = 0; i < 16; i++) {
+ average += yabove_row[i];
+ }
+ }
+ if (x->left_available) {
+ for (i = 0; i < 16; i++) {
+ average += yleft_col[i];
+ }
- shift = 3 + x->up_available + x->left_available;
- expected_dc = (average + (1 << (shift - 1))) >> shift;
- }
- else
- {
- expected_dc = 128;
}
- vpx_memset(ypred_ptr, expected_dc, 256);
+
+
+ shift = 3 + x->up_available + x->left_available;
+ expected_dc = (average + (1 << (shift - 1))) >> shift;
+ } else {
+ expected_dc = 128;
+ }
+
+ vpx_memset(ypred_ptr, expected_dc, 256);
}
break;
- case V_PRED:
- {
+ case V_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
- ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
- ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
- ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
- ypred_ptr += 16;
- }
+ ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
+ ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
+ ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
+ ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
+ ypred_ptr += 16;
+ }
}
break;
- case H_PRED:
- {
+ case H_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- vpx_memset(ypred_ptr, yleft_col[r], 16);
- ypred_ptr += 16;
- }
+ vpx_memset(ypred_ptr, yleft_col[r], 16);
+ ypred_ptr += 16;
+ }
}
break;
- case TM_PRED:
- {
-
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
+ case TM_PRED: {
- if (pred < 0)
- pred = 0;
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
- if (pred > 255)
- pred = 255;
+ if (pred < 0)
+ pred = 0;
- ypred_ptr[c] = pred;
- }
+ if (pred > 255)
+ pred = 255;
- ypred_ptr += 16;
+ ypred_ptr[c] = pred;
}
+ ypred_ptr += 16;
+ }
+
}
break;
case B_PRED:
@@ -143,133 +124,113 @@ void vp8mt_build_intra_predictors_mby(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
-void vp8mt_build_intra_predictors_mby_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col)
-{
- unsigned char *yabove_row; /* = x->dst.y_buffer - x->dst.y_stride; */
- unsigned char *yleft_col;
- unsigned char yleft_buf[16];
- unsigned char ytop_left; /* = yabove_row[-1]; */
- unsigned char *ypred_ptr = x->predictor;
- int r, c, i;
-
- int y_stride = x->dst.y_stride;
- ypred_ptr = x->dst.y_buffer; /*x->predictor;*/
-
- if (pbi->common.filter_level)
- {
- yabove_row = pbi->mt_yabove_row[mb_row] + mb_col*16 +32;
- yleft_col = pbi->mt_yleft_col[mb_row];
- } else
- {
- yabove_row = x->dst.y_buffer - x->dst.y_stride;
-
- for (i = 0; i < 16; i++)
- yleft_buf[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
- yleft_col = yleft_buf;
- }
+void vp8mt_build_intra_predictors_mby_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col) {
+ unsigned char *yabove_row; /* = x->dst.y_buffer - x->dst.y_stride; */
+ unsigned char *yleft_col;
+ unsigned char yleft_buf[16];
+ unsigned char ytop_left; /* = yabove_row[-1]; */
+ unsigned char *ypred_ptr = x->predictor;
+ int r, c, i;
- ytop_left = yabove_row[-1];
+ int y_stride = x->dst.y_stride;
+ ypred_ptr = x->dst.y_buffer; /*x->predictor;*/
- /* for Y */
- switch (x->mode_info_context->mbmi.mode)
- {
- case DC_PRED:
- {
- int expected_dc;
- int i;
- int shift;
- int average = 0;
+ if (pbi->common.filter_level) {
+ yabove_row = pbi->mt_yabove_row[mb_row] + mb_col * 16 + 32;
+ yleft_col = pbi->mt_yleft_col[mb_row];
+ } else {
+ yabove_row = x->dst.y_buffer - x->dst.y_stride;
+ for (i = 0; i < 16; i++)
+ yleft_buf[i] = x->dst.y_buffer [i * x->dst.y_stride - 1];
+ yleft_col = yleft_buf;
+ }
- if (x->up_available || x->left_available)
- {
- if (x->up_available)
- {
- for (i = 0; i < 16; i++)
- {
- average += yabove_row[i];
- }
- }
+ ytop_left = yabove_row[-1];
- if (x->left_available)
- {
+ /* for Y */
+ switch (x->mode_info_context->mbmi.mode) {
+ case DC_PRED: {
+ int expected_dc;
+ int i;
+ int shift;
+ int average = 0;
- for (i = 0; i < 16; i++)
- {
- average += yleft_col[i];
- }
- }
+ if (x->up_available || x->left_available) {
+ if (x->up_available) {
+ for (i = 0; i < 16; i++) {
+ average += yabove_row[i];
+ }
+ }
+ if (x->left_available) {
+ for (i = 0; i < 16; i++) {
+ average += yleft_col[i];
+ }
- shift = 3 + x->up_available + x->left_available;
- expected_dc = (average + (1 << (shift - 1))) >> shift;
- }
- else
- {
- expected_dc = 128;
}
- /*vpx_memset(ypred_ptr, expected_dc, 256);*/
- for (r = 0; r < 16; r++)
- {
- vpx_memset(ypred_ptr, expected_dc, 16);
- ypred_ptr += y_stride; /*16;*/
- }
+
+
+ shift = 3 + x->up_available + x->left_available;
+ expected_dc = (average + (1 << (shift - 1))) >> shift;
+ } else {
+ expected_dc = 128;
+ }
+
+ /*vpx_memset(ypred_ptr, expected_dc, 256);*/
+ for (r = 0; r < 16; r++) {
+ vpx_memset(ypred_ptr, expected_dc, 16);
+ ypred_ptr += y_stride; /*16;*/
+ }
}
break;
- case V_PRED:
- {
+ case V_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
- ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
- ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
- ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
- ypred_ptr += y_stride; /*16;*/
- }
+ ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
+ ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
+ ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
+ ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
+ ypred_ptr += y_stride; /*16;*/
+ }
}
break;
- case H_PRED:
- {
+ case H_PRED: {
- for (r = 0; r < 16; r++)
- {
+ for (r = 0; r < 16; r++) {
- vpx_memset(ypred_ptr, yleft_col[r], 16);
- ypred_ptr += y_stride; /*16;*/
- }
+ vpx_memset(ypred_ptr, yleft_col[r], 16);
+ ypred_ptr += y_stride; /*16;*/
+ }
}
break;
- case TM_PRED:
- {
-
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
+ case TM_PRED: {
- if (pred < 0)
- pred = 0;
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
- if (pred > 255)
- pred = 255;
+ if (pred < 0)
+ pred = 0;
- ypred_ptr[c] = pred;
- }
+ if (pred > 255)
+ pred = 255;
- ypred_ptr += y_stride; /*16;*/
+ ypred_ptr[c] = pred;
}
+ ypred_ptr += y_stride; /*16;*/
+ }
+
}
break;
case B_PRED:
@@ -279,153 +240,133 @@ void vp8mt_build_intra_predictors_mby_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_r
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
-void vp8mt_build_intra_predictors_mbuv(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col)
-{
- unsigned char *uabove_row; /* = x->dst.u_buffer - x->dst.uv_stride; */
- unsigned char *uleft_col; /*[16];*/
- unsigned char uleft_buf[8];
- unsigned char utop_left; /* = uabove_row[-1]; */
- unsigned char *vabove_row; /* = x->dst.v_buffer - x->dst.uv_stride; */
- unsigned char *vleft_col; /*[20];*/
- unsigned char vleft_buf[8];
- unsigned char vtop_left; /* = vabove_row[-1]; */
- unsigned char *upred_ptr = &x->predictor[256];
- unsigned char *vpred_ptr = &x->predictor[320];
- int i, j;
-
- if (pbi->common.filter_level)
- {
- uabove_row = pbi->mt_uabove_row[mb_row] + mb_col*8 +16;
- vabove_row = pbi->mt_vabove_row[mb_row] + mb_col*8 +16;
- uleft_col = pbi->mt_uleft_col[mb_row];
- vleft_col = pbi->mt_vleft_col[mb_row];
- } else
- {
- uabove_row = x->dst.u_buffer - x->dst.uv_stride;
- vabove_row = x->dst.v_buffer - x->dst.uv_stride;
-
- for (i = 0; i < 8; i++)
- {
- uleft_buf[i] = x->dst.u_buffer [i* x->dst.uv_stride -1];
- vleft_buf[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
- }
- uleft_col = uleft_buf;
- vleft_col = vleft_buf;
- }
- utop_left = uabove_row[-1];
- vtop_left = vabove_row[-1];
-
- switch (x->mode_info_context->mbmi.uv_mode)
- {
- case DC_PRED:
- {
- int expected_udc;
- int expected_vdc;
- int i;
- int shift;
- int Uaverage = 0;
- int Vaverage = 0;
-
- if (x->up_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uabove_row[i];
- Vaverage += vabove_row[i];
- }
- }
-
- if (x->left_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uleft_col[i];
- Vaverage += vleft_col[i];
- }
- }
-
- if (!x->up_available && !x->left_available)
- {
- expected_udc = 128;
- expected_vdc = 128;
- }
- else
- {
- shift = 2 + x->up_available + x->left_available;
- expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
- expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
- }
-
-
- vpx_memset(upred_ptr, expected_udc, 64);
- vpx_memset(vpred_ptr, expected_vdc, 64);
+void vp8mt_build_intra_predictors_mbuv(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col) {
+ unsigned char *uabove_row; /* = x->dst.u_buffer - x->dst.uv_stride; */
+ unsigned char *uleft_col; /*[16];*/
+ unsigned char uleft_buf[8];
+ unsigned char utop_left; /* = uabove_row[-1]; */
+ unsigned char *vabove_row; /* = x->dst.v_buffer - x->dst.uv_stride; */
+ unsigned char *vleft_col; /*[20];*/
+ unsigned char vleft_buf[8];
+ unsigned char vtop_left; /* = vabove_row[-1]; */
+ unsigned char *upred_ptr = &x->predictor[256];
+ unsigned char *vpred_ptr = &x->predictor[320];
+ int i, j;
+
+ if (pbi->common.filter_level) {
+ uabove_row = pbi->mt_uabove_row[mb_row] + mb_col * 8 + 16;
+ vabove_row = pbi->mt_vabove_row[mb_row] + mb_col * 8 + 16;
+ uleft_col = pbi->mt_uleft_col[mb_row];
+ vleft_col = pbi->mt_vleft_col[mb_row];
+ } else {
+ uabove_row = x->dst.u_buffer - x->dst.uv_stride;
+ vabove_row = x->dst.v_buffer - x->dst.uv_stride;
+
+ for (i = 0; i < 8; i++) {
+ uleft_buf[i] = x->dst.u_buffer [i * x->dst.uv_stride - 1];
+ vleft_buf[i] = x->dst.v_buffer [i * x->dst.uv_stride - 1];
+ }
+ uleft_col = uleft_buf;
+ vleft_col = vleft_buf;
+ }
+ utop_left = uabove_row[-1];
+ vtop_left = vabove_row[-1];
+
+ switch (x->mode_info_context->mbmi.uv_mode) {
+ case DC_PRED: {
+ int expected_udc;
+ int expected_vdc;
+ int i;
+ int shift;
+ int Uaverage = 0;
+ int Vaverage = 0;
+
+ if (x->up_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uabove_row[i];
+ Vaverage += vabove_row[i];
+ }
+ }
+
+ if (x->left_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uleft_col[i];
+ Vaverage += vleft_col[i];
+ }
+ }
+
+ if (!x->up_available && !x->left_available) {
+ expected_udc = 128;
+ expected_vdc = 128;
+ } else {
+ shift = 2 + x->up_available + x->left_available;
+ expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
+ expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
+ }
+
+
+ vpx_memset(upred_ptr, expected_udc, 64);
+ vpx_memset(vpred_ptr, expected_vdc, 64);
}
break;
- case V_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- vpx_memcpy(upred_ptr, uabove_row, 8);
- vpx_memcpy(vpred_ptr, vabove_row, 8);
- upred_ptr += 8;
- vpred_ptr += 8;
- }
+ case V_PRED: {
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ vpx_memcpy(upred_ptr, uabove_row, 8);
+ vpx_memcpy(vpred_ptr, vabove_row, 8);
+ upred_ptr += 8;
+ vpred_ptr += 8;
+ }
}
break;
- case H_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- vpx_memset(upred_ptr, uleft_col[i], 8);
- vpx_memset(vpred_ptr, vleft_col[i], 8);
- upred_ptr += 8;
- vpred_ptr += 8;
- }
+ case H_PRED: {
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ vpx_memset(upred_ptr, uleft_col[i], 8);
+ vpx_memset(vpred_ptr, vleft_col[i], 8);
+ upred_ptr += 8;
+ vpred_ptr += 8;
+ }
}
break;
- case TM_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 8; j++)
- {
- int predu = uleft_col[i] + uabove_row[j] - utop_left;
- int predv = vleft_col[i] + vabove_row[j] - vtop_left;
+ case TM_PRED: {
+ int i;
- if (predu < 0)
- predu = 0;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ int predu = uleft_col[i] + uabove_row[j] - utop_left;
+ int predv = vleft_col[i] + vabove_row[j] - vtop_left;
- if (predu > 255)
- predu = 255;
+ if (predu < 0)
+ predu = 0;
- if (predv < 0)
- predv = 0;
+ if (predu > 255)
+ predu = 255;
- if (predv > 255)
- predv = 255;
+ if (predv < 0)
+ predv = 0;
- upred_ptr[j] = predu;
- vpred_ptr[j] = predv;
- }
+ if (predv > 255)
+ predv = 255;
- upred_ptr += 8;
- vpred_ptr += 8;
+ upred_ptr[j] = predu;
+ vpred_ptr[j] = predv;
}
+ upred_ptr += 8;
+ vpred_ptr += 8;
+ }
+
}
break;
case B_PRED:
@@ -435,159 +376,138 @@ void vp8mt_build_intra_predictors_mbuv(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_ro
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
-void vp8mt_build_intra_predictors_mbuv_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col)
-{
- unsigned char *uabove_row; /* = x->dst.u_buffer - x->dst.uv_stride; */
- unsigned char *uleft_col; /*[16];*/
- unsigned char uleft_buf[8];
- unsigned char utop_left; /* = uabove_row[-1]; */
- unsigned char *vabove_row; /* = x->dst.v_buffer - x->dst.uv_stride; */
- unsigned char *vleft_col; /*[20];*/
- unsigned char vleft_buf[8];
- unsigned char vtop_left; /* = vabove_row[-1]; */
- unsigned char *upred_ptr = x->dst.u_buffer; /*&x->predictor[256];*/
- unsigned char *vpred_ptr = x->dst.v_buffer; /*&x->predictor[320];*/
- int uv_stride = x->dst.uv_stride;
- int i, j;
-
- if (pbi->common.filter_level)
- {
- uabove_row = pbi->mt_uabove_row[mb_row] + mb_col*8 +16;
- vabove_row = pbi->mt_vabove_row[mb_row] + mb_col*8 +16;
- uleft_col = pbi->mt_uleft_col[mb_row];
- vleft_col = pbi->mt_vleft_col[mb_row];
- } else
- {
- uabove_row = x->dst.u_buffer - x->dst.uv_stride;
- vabove_row = x->dst.v_buffer - x->dst.uv_stride;
-
- for (i = 0; i < 8; i++)
- {
- uleft_buf[i] = x->dst.u_buffer [i* x->dst.uv_stride -1];
- vleft_buf[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
- }
- uleft_col = uleft_buf;
- vleft_col = vleft_buf;
+void vp8mt_build_intra_predictors_mbuv_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col) {
+ unsigned char *uabove_row; /* = x->dst.u_buffer - x->dst.uv_stride; */
+ unsigned char *uleft_col; /*[16];*/
+ unsigned char uleft_buf[8];
+ unsigned char utop_left; /* = uabove_row[-1]; */
+ unsigned char *vabove_row; /* = x->dst.v_buffer - x->dst.uv_stride; */
+ unsigned char *vleft_col; /*[20];*/
+ unsigned char vleft_buf[8];
+ unsigned char vtop_left; /* = vabove_row[-1]; */
+ unsigned char *upred_ptr = x->dst.u_buffer; /*&x->predictor[256];*/
+ unsigned char *vpred_ptr = x->dst.v_buffer; /*&x->predictor[320];*/
+ int uv_stride = x->dst.uv_stride;
+ int i, j;
+
+ if (pbi->common.filter_level) {
+ uabove_row = pbi->mt_uabove_row[mb_row] + mb_col * 8 + 16;
+ vabove_row = pbi->mt_vabove_row[mb_row] + mb_col * 8 + 16;
+ uleft_col = pbi->mt_uleft_col[mb_row];
+ vleft_col = pbi->mt_vleft_col[mb_row];
+ } else {
+ uabove_row = x->dst.u_buffer - x->dst.uv_stride;
+ vabove_row = x->dst.v_buffer - x->dst.uv_stride;
+
+ for (i = 0; i < 8; i++) {
+ uleft_buf[i] = x->dst.u_buffer [i * x->dst.uv_stride - 1];
+ vleft_buf[i] = x->dst.v_buffer [i * x->dst.uv_stride - 1];
+ }
+ uleft_col = uleft_buf;
+ vleft_col = vleft_buf;
+ }
+ utop_left = uabove_row[-1];
+ vtop_left = vabove_row[-1];
+
+ switch (x->mode_info_context->mbmi.uv_mode) {
+ case DC_PRED: {
+ int expected_udc;
+ int expected_vdc;
+ int i;
+ int shift;
+ int Uaverage = 0;
+ int Vaverage = 0;
+
+ if (x->up_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uabove_row[i];
+ Vaverage += vabove_row[i];
+ }
+ }
+
+ if (x->left_available) {
+ for (i = 0; i < 8; i++) {
+ Uaverage += uleft_col[i];
+ Vaverage += vleft_col[i];
+ }
+ }
+
+ if (!x->up_available && !x->left_available) {
+ expected_udc = 128;
+ expected_vdc = 128;
+ } else {
+ shift = 2 + x->up_available + x->left_available;
+ expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
+ expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
+ }
+
+
+ /*vpx_memset(upred_ptr,expected_udc,64);
+ vpx_memset(vpred_ptr,expected_vdc,64);*/
+ for (i = 0; i < 8; i++) {
+ vpx_memset(upred_ptr, expected_udc, 8);
+ vpx_memset(vpred_ptr, expected_vdc, 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
}
- utop_left = uabove_row[-1];
- vtop_left = vabove_row[-1];
-
- switch (x->mode_info_context->mbmi.uv_mode)
- {
- case DC_PRED:
- {
- int expected_udc;
- int expected_vdc;
- int i;
- int shift;
- int Uaverage = 0;
- int Vaverage = 0;
-
- if (x->up_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uabove_row[i];
- Vaverage += vabove_row[i];
- }
- }
-
- if (x->left_available)
- {
- for (i = 0; i < 8; i++)
- {
- Uaverage += uleft_col[i];
- Vaverage += vleft_col[i];
- }
- }
-
- if (!x->up_available && !x->left_available)
- {
- expected_udc = 128;
- expected_vdc = 128;
- }
- else
- {
- shift = 2 + x->up_available + x->left_available;
- expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
- expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
- }
+ break;
+ case V_PRED: {
+ int i;
+ for (i = 0; i < 8; i++) {
+ vpx_memcpy(upred_ptr, uabove_row, 8);
+ vpx_memcpy(vpred_ptr, vabove_row, 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
- /*vpx_memset(upred_ptr,expected_udc,64);
- vpx_memset(vpred_ptr,expected_vdc,64);*/
- for (i = 0; i < 8; i++)
- {
- vpx_memset(upred_ptr, expected_udc, 8);
- vpx_memset(vpred_ptr, expected_vdc, 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
}
break;
- case V_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- vpx_memcpy(upred_ptr, uabove_row, 8);
- vpx_memcpy(vpred_ptr, vabove_row, 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
+ case H_PRED: {
+ int i;
- }
- break;
- case H_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- vpx_memset(upred_ptr, uleft_col[i], 8);
- vpx_memset(vpred_ptr, vleft_col[i], 8);
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
- }
+ for (i = 0; i < 8; i++) {
+ vpx_memset(upred_ptr, uleft_col[i], 8);
+ vpx_memset(vpred_ptr, vleft_col[i], 8);
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
}
break;
- case TM_PRED:
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 8; j++)
- {
- int predu = uleft_col[i] + uabove_row[j] - utop_left;
- int predv = vleft_col[i] + vabove_row[j] - vtop_left;
+ case TM_PRED: {
+ int i;
- if (predu < 0)
- predu = 0;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ int predu = uleft_col[i] + uabove_row[j] - utop_left;
+ int predv = vleft_col[i] + vabove_row[j] - vtop_left;
- if (predu > 255)
- predu = 255;
+ if (predu < 0)
+ predu = 0;
- if (predv < 0)
- predv = 0;
+ if (predu > 255)
+ predu = 255;
- if (predv > 255)
- predv = 255;
+ if (predv < 0)
+ predv = 0;
- upred_ptr[j] = predu;
- vpred_ptr[j] = predv;
- }
+ if (predv > 255)
+ predv = 255;
- upred_ptr += uv_stride; /*8;*/
- vpred_ptr += uv_stride; /*8;*/
+ upred_ptr[j] = predu;
+ vpred_ptr[j] = predv;
}
+ upred_ptr += uv_stride; /*8;*/
+ vpred_ptr += uv_stride; /*8;*/
+ }
+
}
break;
case B_PRED:
@@ -597,341 +517,317 @@ void vp8mt_build_intra_predictors_mbuv_s(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
- break;
- }
+ break;
+ }
}
void vp8mt_predict_intra4x4(VP8D_COMP *pbi,
- MACROBLOCKD *xd,
- int b_mode,
- unsigned char *predictor,
- int mb_row,
- int mb_col,
- int num)
-{
- int i, r, c;
-
- unsigned char *Above; /* = *(x->base_dst) + x->dst - x->dst_stride; */
- unsigned char Left[4];
- unsigned char top_left; /* = Above[-1]; */
-
- BLOCKD *x = &xd->block[num];
-
- /*Caution: For some b_mode, it needs 8 pixels (4 above + 4 above-right).*/
- if (num < 4 && pbi->common.filter_level)
- Above = pbi->mt_yabove_row[mb_row] + mb_col*16 + num*4 + 32;
- else
- Above = *(x->base_dst) + x->dst - x->dst_stride;
-
- if (num%4==0 && pbi->common.filter_level)
- {
- for (i=0; i<4; i++)
- Left[i] = pbi->mt_yleft_col[mb_row][num + i];
- }else
- {
- Left[0] = (*(x->base_dst))[x->dst - 1];
- Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride];
- Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride];
- Left[3] = (*(x->base_dst))[x->dst - 1 + 3 * x->dst_stride];
- }
-
- if ((num==4 || num==8 || num==12) && pbi->common.filter_level)
- top_left = pbi->mt_yleft_col[mb_row][num-1];
- else
- top_left = Above[-1];
-
- switch (b_mode)
- {
- case B_DC_PRED:
- {
- int expected_dc = 0;
-
- for (i = 0; i < 4; i++)
- {
- expected_dc += Above[i];
- expected_dc += Left[i];
- }
-
- expected_dc = (expected_dc + 4) >> 3;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = expected_dc;
- }
-
- predictor += 16;
- }
+ MACROBLOCKD *xd,
+ int b_mode,
+ unsigned char *predictor,
+ int mb_row,
+ int mb_col,
+ int num) {
+ int i, r, c;
+
+ unsigned char *Above; /* = *(x->base_dst) + x->dst - x->dst_stride; */
+ unsigned char Left[4];
+ unsigned char top_left; /* = Above[-1]; */
+
+ BLOCKD *x = &xd->block[num];
+
+ /*Caution: For some b_mode, it needs 8 pixels (4 above + 4 above-right).*/
+ if (num < 4 && pbi->common.filter_level)
+ Above = pbi->mt_yabove_row[mb_row] + mb_col * 16 + num * 4 + 32;
+ else
+ Above = *(x->base_dst) + x->dst - x->dst_stride;
+
+ if (num % 4 == 0 && pbi->common.filter_level) {
+ for (i = 0; i < 4; i++)
+ Left[i] = pbi->mt_yleft_col[mb_row][num + i];
+ } else {
+ Left[0] = (*(x->base_dst))[x->dst - 1];
+ Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride];
+ Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride];
+ Left[3] = (*(x->base_dst))[x->dst - 1 + 3 * x->dst_stride];
+ }
+
+ if ((num == 4 || num == 8 || num == 12) && pbi->common.filter_level)
+ top_left = pbi->mt_yleft_col[mb_row][num - 1];
+ else
+ top_left = Above[-1];
+
+ switch (b_mode) {
+ case B_DC_PRED: {
+ int expected_dc = 0;
+
+ for (i = 0; i < 4; i++) {
+ expected_dc += Above[i];
+ expected_dc += Left[i];
+ }
+
+ expected_dc = (expected_dc + 4) >> 3;
+
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = expected_dc;
+ }
+
+ predictor += 16;
+ }
}
break;
- case B_TM_PRED:
- {
- /* prediction similar to true_motion prediction */
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- int pred = Above[c] - top_left + Left[r];
+ case B_TM_PRED: {
+ /* prediction similar to true_motion prediction */
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ int pred = Above[c] - top_left + Left[r];
- if (pred < 0)
- pred = 0;
+ if (pred < 0)
+ pred = 0;
- if (pred > 255)
- pred = 255;
+ if (pred > 255)
+ pred = 255;
- predictor[c] = pred;
- }
-
- predictor += 16;
+ predictor[c] = pred;
}
+
+ predictor += 16;
+ }
}
break;
- case B_VE_PRED:
- {
-
- unsigned int ap[4];
- ap[0] = (top_left + 2 * Above[0] + Above[1] + 2) >> 2;
- ap[1] = (Above[0] + 2 * Above[1] + Above[2] + 2) >> 2;
- ap[2] = (Above[1] + 2 * Above[2] + Above[3] + 2) >> 2;
- ap[3] = (Above[2] + 2 * Above[3] + Above[4] + 2) >> 2;
+ case B_VE_PRED: {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
+ unsigned int ap[4];
+ ap[0] = (top_left + 2 * Above[0] + Above[1] + 2) >> 2;
+ ap[1] = (Above[0] + 2 * Above[1] + Above[2] + 2) >> 2;
+ ap[2] = (Above[1] + 2 * Above[2] + Above[3] + 2) >> 2;
+ ap[3] = (Above[2] + 2 * Above[3] + Above[4] + 2) >> 2;
- predictor[c] = ap[c];
- }
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
- predictor += 16;
+ predictor[c] = ap[c];
}
+ predictor += 16;
+ }
+
}
break;
- case B_HE_PRED:
- {
-
- unsigned int lp[4];
- lp[0] = (top_left + 2 * Left[0] + Left[1] + 2) >> 2;
- lp[1] = (Left[0] + 2 * Left[1] + Left[2] + 2) >> 2;
- lp[2] = (Left[1] + 2 * Left[2] + Left[3] + 2) >> 2;
- lp[3] = (Left[2] + 2 * Left[3] + Left[3] + 2) >> 2;
+ case B_HE_PRED: {
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- predictor[c] = lp[r];
- }
+ unsigned int lp[4];
+ lp[0] = (top_left + 2 * Left[0] + Left[1] + 2) >> 2;
+ lp[1] = (Left[0] + 2 * Left[1] + Left[2] + 2) >> 2;
+ lp[2] = (Left[1] + 2 * Left[2] + Left[3] + 2) >> 2;
+ lp[3] = (Left[2] + 2 * Left[3] + Left[3] + 2) >> 2;
- predictor += 16;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ predictor[c] = lp[r];
}
- }
- break;
- case B_LD_PRED:
- {
- unsigned char *ptr = Above;
- predictor[0 * 16 + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2;
- predictor[0 * 16 + 1] =
- predictor[1 * 16 + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2;
- predictor[0 * 16 + 2] =
- predictor[1 * 16 + 1] =
- predictor[2 * 16 + 0] = (ptr[2] + ptr[3] * 2 + ptr[4] + 2) >> 2;
- predictor[0 * 16 + 3] =
- predictor[1 * 16 + 2] =
- predictor[2 * 16 + 1] =
- predictor[3 * 16 + 0] = (ptr[3] + ptr[4] * 2 + ptr[5] + 2) >> 2;
- predictor[1 * 16 + 3] =
- predictor[2 * 16 + 2] =
- predictor[3 * 16 + 1] = (ptr[4] + ptr[5] * 2 + ptr[6] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[3 * 16 + 2] = (ptr[5] + ptr[6] * 2 + ptr[7] + 2) >> 2;
- predictor[3 * 16 + 3] = (ptr[6] + ptr[7] * 2 + ptr[7] + 2) >> 2;
+ predictor += 16;
+ }
}
break;
- case B_RD_PRED:
- {
-
- unsigned char pp[9];
-
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
- predictor[3 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[3 * 16 + 1] =
- predictor[2 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[3 * 16 + 2] =
- predictor[2 * 16 + 1] =
- predictor[1 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[3 * 16 + 3] =
- predictor[2 * 16 + 2] =
- predictor[1 * 16 + 1] =
- predictor[0 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[1 * 16 + 2] =
- predictor[0 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[1 * 16 + 3] =
- predictor[0 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
+ case B_LD_PRED: {
+ unsigned char *ptr = Above;
+ predictor[0 * 16 + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2;
+ predictor[0 * 16 + 1] =
+ predictor[1 * 16 + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2;
+ predictor[0 * 16 + 2] =
+ predictor[1 * 16 + 1] =
+ predictor[2 * 16 + 0] = (ptr[2] + ptr[3] * 2 + ptr[4] + 2) >> 2;
+ predictor[0 * 16 + 3] =
+ predictor[1 * 16 + 2] =
+ predictor[2 * 16 + 1] =
+ predictor[3 * 16 + 0] = (ptr[3] + ptr[4] * 2 + ptr[5] + 2) >> 2;
+ predictor[1 * 16 + 3] =
+ predictor[2 * 16 + 2] =
+ predictor[3 * 16 + 1] = (ptr[4] + ptr[5] * 2 + ptr[6] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[3 * 16 + 2] = (ptr[5] + ptr[6] * 2 + ptr[7] + 2) >> 2;
+ predictor[3 * 16 + 3] = (ptr[6] + ptr[7] * 2 + ptr[7] + 2) >> 2;
}
break;
- case B_VR_PRED:
- {
-
- unsigned char pp[9];
-
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
-
- predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[3 * 16 + 1] =
- predictor[1 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ case B_RD_PRED: {
+
+ unsigned char pp[9];
+
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+ predictor[3 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[3 * 16 + 1] =
+ predictor[2 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[3 * 16 + 2] =
predictor[2 * 16 + 1] =
- predictor[0 * 16 + 0] = (pp[4] + pp[5] + 1) >> 1;
- predictor[3 * 16 + 2] =
- predictor[1 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[1 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[3 * 16 + 3] =
predictor[2 * 16 + 2] =
- predictor[0 * 16 + 1] = (pp[5] + pp[6] + 1) >> 1;
- predictor[3 * 16 + 3] =
- predictor[1 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
- predictor[2 * 16 + 3] =
- predictor[0 * 16 + 2] = (pp[6] + pp[7] + 1) >> 1;
- predictor[1 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[7] + pp[8] + 1) >> 1;
+ predictor[1 * 16 + 1] =
+ predictor[0 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[1 * 16 + 2] =
+ predictor[0 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[1 * 16 + 3] =
+ predictor[0 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
+
+ }
+ break;
+ case B_VR_PRED: {
+
+ unsigned char pp[9];
+
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+
+ predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[3 * 16 + 1] =
+ predictor[1 * 16 + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 1] =
+ predictor[0 * 16 + 0] = (pp[4] + pp[5] + 1) >> 1;
+ predictor[3 * 16 + 2] =
+ predictor[1 * 16 + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[0 * 16 + 1] = (pp[5] + pp[6] + 1) >> 1;
+ predictor[3 * 16 + 3] =
+ predictor[1 * 16 + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ predictor[2 * 16 + 3] =
+ predictor[0 * 16 + 2] = (pp[6] + pp[7] + 1) >> 1;
+ predictor[1 * 16 + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[7] + pp[8] + 1) >> 1;
}
break;
- case B_VL_PRED:
- {
+ case B_VL_PRED: {
- unsigned char *pp = Above;
+ unsigned char *pp = Above;
- predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[1 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[2 * 16 + 0] =
- predictor[0 * 16 + 1] = (pp[1] + pp[2] + 1) >> 1;
- predictor[1 * 16 + 1] =
- predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 1] =
- predictor[0 * 16 + 2] = (pp[2] + pp[3] + 1) >> 1;
- predictor[3 * 16 + 1] =
- predictor[1 * 16 + 2] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[0 * 16 + 3] =
- predictor[2 * 16 + 2] = (pp[3] + pp[4] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[3 * 16 + 2] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[2 * 16 + 3] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[3 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[1 * 16 + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[2 * 16 + 0] =
+ predictor[0 * 16 + 1] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[1 * 16 + 1] =
+ predictor[3 * 16 + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 1] =
+ predictor[0 * 16 + 2] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[3 * 16 + 1] =
+ predictor[1 * 16 + 2] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[0 * 16 + 3] =
+ predictor[2 * 16 + 2] = (pp[3] + pp[4] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[3 * 16 + 2] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[2 * 16 + 3] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[3 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
}
break;
- case B_HD_PRED:
- {
- unsigned char pp[9];
- pp[0] = Left[3];
- pp[1] = Left[2];
- pp[2] = Left[1];
- pp[3] = Left[0];
- pp[4] = top_left;
- pp[5] = Above[0];
- pp[6] = Above[1];
- pp[7] = Above[2];
- pp[8] = Above[3];
-
-
- predictor[3 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[3 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[2 * 16 + 0] =
- predictor[3 * 16 + 2] = (pp[1] + pp[2] + 1) >> 1;
- predictor[2 * 16 + 1] =
- predictor[3 * 16 + 3] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 2] =
- predictor[1 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
- predictor[2 * 16 + 3] =
- predictor[1 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
- predictor[1 * 16 + 2] =
- predictor[0 * 16 + 0] = (pp[3] + pp[4] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[0 * 16 + 1] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
- predictor[0 * 16 + 2] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
- predictor[0 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
+ case B_HD_PRED: {
+ unsigned char pp[9];
+ pp[0] = Left[3];
+ pp[1] = Left[2];
+ pp[2] = Left[1];
+ pp[3] = Left[0];
+ pp[4] = top_left;
+ pp[5] = Above[0];
+ pp[6] = Above[1];
+ pp[7] = Above[2];
+ pp[8] = Above[3];
+
+
+ predictor[3 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[3 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[2 * 16 + 0] =
+ predictor[3 * 16 + 2] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[2 * 16 + 1] =
+ predictor[3 * 16 + 3] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[1 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[2 * 16 + 3] =
+ predictor[1 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
+ predictor[1 * 16 + 2] =
+ predictor[0 * 16 + 0] = (pp[3] + pp[4] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[0 * 16 + 1] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
+ predictor[0 * 16 + 2] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
+ predictor[0 * 16 + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
}
break;
- case B_HU_PRED:
- {
- unsigned char *pp = Left;
- predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
- predictor[0 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
- predictor[0 * 16 + 2] =
- predictor[1 * 16 + 0] = (pp[1] + pp[2] + 1) >> 1;
- predictor[0 * 16 + 3] =
- predictor[1 * 16 + 1] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
- predictor[1 * 16 + 2] =
- predictor[2 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
- predictor[1 * 16 + 3] =
- predictor[2 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[3] + 2) >> 2;
- predictor[2 * 16 + 2] =
- predictor[2 * 16 + 3] =
- predictor[3 * 16 + 0] =
- predictor[3 * 16 + 1] =
- predictor[3 * 16 + 2] =
- predictor[3 * 16 + 3] = pp[3];
+ case B_HU_PRED: {
+ unsigned char *pp = Left;
+ predictor[0 * 16 + 0] = (pp[0] + pp[1] + 1) >> 1;
+ predictor[0 * 16 + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
+ predictor[0 * 16 + 2] =
+ predictor[1 * 16 + 0] = (pp[1] + pp[2] + 1) >> 1;
+ predictor[0 * 16 + 3] =
+ predictor[1 * 16 + 1] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
+ predictor[1 * 16 + 2] =
+ predictor[2 * 16 + 0] = (pp[2] + pp[3] + 1) >> 1;
+ predictor[1 * 16 + 3] =
+ predictor[2 * 16 + 1] = (pp[2] + pp[3] * 2 + pp[3] + 2) >> 2;
+ predictor[2 * 16 + 2] =
+ predictor[2 * 16 + 3] =
+ predictor[3 * 16 + 0] =
+ predictor[3 * 16 + 1] =
+ predictor[3 * 16 + 2] =
+ predictor[3 * 16 + 3] = pp[3];
}
break;
- }
+ }
}
/* copy 4 bytes from the above right down so that the 4x4 prediction modes using pixels above and
* to the right prediction have filled in pixels to use.
*/
-void vp8mt_intra_prediction_down_copy(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col)
-{
- unsigned char *above_right; /* = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16; */
- unsigned int *src_ptr;
- unsigned int *dst_ptr0;
- unsigned int *dst_ptr1;
- unsigned int *dst_ptr2;
-
- if (pbi->common.filter_level)
- above_right = pbi->mt_yabove_row[mb_row] + mb_col*16 + 32 +16;
- else
- above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
-
- src_ptr = (unsigned int *)above_right;
- /*dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
- dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
- dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);*/
- dst_ptr0 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 3 * x->block[0].dst_stride);
- dst_ptr1 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 7 * x->block[0].dst_stride);
- dst_ptr2 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 11 * x->block[0].dst_stride);
- *dst_ptr0 = *src_ptr;
- *dst_ptr1 = *src_ptr;
- *dst_ptr2 = *src_ptr;
+void vp8mt_intra_prediction_down_copy(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row, int mb_col) {
+ unsigned char *above_right; /* = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16; */
+ unsigned int *src_ptr;
+ unsigned int *dst_ptr0;
+ unsigned int *dst_ptr1;
+ unsigned int *dst_ptr2;
+
+ if (pbi->common.filter_level)
+ above_right = pbi->mt_yabove_row[mb_row] + mb_col * 16 + 32 + 16;
+ else
+ above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
+
+ src_ptr = (unsigned int *)above_right;
+ /*dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
+ dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
+ dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);*/
+ dst_ptr0 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 3 * x->block[0].dst_stride);
+ dst_ptr1 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 7 * x->block[0].dst_stride);
+ dst_ptr2 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 11 * x->block[0].dst_stride);
+ *dst_ptr0 = *src_ptr;
+ *dst_ptr1 = *src_ptr;
+ *dst_ptr2 = *src_ptr;
}
diff --git a/vp8/decoder/treereader.h b/vp8/decoder/treereader.h
index 238ff8536..89f529951 100644
--- a/vp8/decoder/treereader.h
+++ b/vp8/decoder/treereader.h
@@ -26,16 +26,15 @@ typedef BOOL_DECODER vp8_reader;
/* Intent of tree data structure is to make decoding trivial. */
static int vp8_treed_read(
- vp8_reader *const r, /* !!! must return a 0 or 1 !!! */
- vp8_tree t,
- const vp8_prob *const p
-)
-{
- register vp8_tree_index i = 0;
+ vp8_reader *const r, /* !!! must return a 0 or 1 !!! */
+ vp8_tree t,
+ const vp8_prob *const p
+) {
+ register vp8_tree_index i = 0;
- while ((i = t[ i + vp8_read(r, p[i>>1])]) > 0) ;
+ while ((i = t[ i + vp8_read(r, p[i >> 1])]) > 0);
- return -i;
+ return -i;
}
#endif /* tree_reader_h */
diff --git a/vp8/decoder/x86/idct_blk_mmx.c b/vp8/decoder/x86/idct_blk_mmx.c
index b9c11bc65..4fac314e5 100644
--- a/vp8/decoder/x86/idct_blk_mmx.c
+++ b/vp8/decoder/x86/idct_blk_mmx.c
@@ -13,139 +13,124 @@
#include "vp8/decoder/dequantize.h"
void vp8_dequant_dc_idct_add_y_block_mmx
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (eobs[0] > 1)
- vpx_dequant_dc_idct_add_mmx (q, dq, pre, dst, 16, stride, dc[0]);
- else
- vpx_dc_only_idct_add_mmx (dc[0], pre, dst, 16, stride);
-
- if (eobs[1] > 1)
- vpx_dequant_dc_idct_add_mmx (q+16, dq, pre+4, dst+4, 16, stride, dc[1]);
- else
- vpx_dc_only_idct_add_mmx (dc[1], pre+4, dst+4, 16, stride);
-
- if (eobs[2] > 1)
- vpx_dequant_dc_idct_add_mmx (q+32, dq, pre+8, dst+8, 16, stride, dc[2]);
- else
- vpx_dc_only_idct_add_mmx (dc[2], pre+8, dst+8, 16, stride);
-
- if (eobs[3] > 1)
- vpx_dequant_dc_idct_add_mmx (q+48, dq, pre+12, dst+12, 16, stride, dc[3]);
- else
- vpx_dc_only_idct_add_mmx (dc[3], pre+12, dst+12, 16, stride);
-
- q += 64;
- dc += 4;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
- }
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (eobs[0] > 1)
+ vpx_dequant_dc_idct_add_mmx(q, dq, pre, dst, 16, stride, dc[0]);
+ else
+ vpx_dc_only_idct_add_mmx(dc[0], pre, dst, 16, stride);
+
+ if (eobs[1] > 1)
+ vpx_dequant_dc_idct_add_mmx(q + 16, dq, pre + 4, dst + 4, 16, stride, dc[1]);
+ else
+ vpx_dc_only_idct_add_mmx(dc[1], pre + 4, dst + 4, 16, stride);
+
+ if (eobs[2] > 1)
+ vpx_dequant_dc_idct_add_mmx(q + 32, dq, pre + 8, dst + 8, 16, stride, dc[2]);
+ else
+ vpx_dc_only_idct_add_mmx(dc[2], pre + 8, dst + 8, 16, stride);
+
+ if (eobs[3] > 1)
+ vpx_dequant_dc_idct_add_mmx(q + 48, dq, pre + 12, dst + 12, 16, stride, dc[3]);
+ else
+ vpx_dc_only_idct_add_mmx(dc[3], pre + 12, dst + 12, 16, stride);
+
+ q += 64;
+ dc += 4;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
}
void vp8_dequant_idct_add_y_block_mmx
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (eobs[0] > 1)
- vpx_dequant_idct_add_mmx (q, dq, pre, dst, 16, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[0]*dq[0], pre, dst, 16, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vpx_dequant_idct_add_mmx (q+16, dq, pre+4, dst+4, 16, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[16]*dq[0], pre+4, dst+4, 16, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- if (eobs[2] > 1)
- vpx_dequant_idct_add_mmx (q+32, dq, pre+8, dst+8, 16, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[32]*dq[0], pre+8, dst+8, 16, stride);
- ((int *)(q+32))[0] = 0;
- }
-
- if (eobs[3] > 1)
- vpx_dequant_idct_add_mmx (q+48, dq, pre+12, dst+12, 16, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[48]*dq[0], pre+12, dst+12, 16, stride);
- ((int *)(q+48))[0] = 0;
- }
-
- q += 64;
- pre += 64;
- dst += 4*stride;
- eobs += 4;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (eobs[0] > 1)
+ vpx_dequant_idct_add_mmx(q, dq, pre, dst, 16, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[0]*dq[0], pre, dst, 16, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ if (eobs[1] > 1)
+ vpx_dequant_idct_add_mmx(q + 16, dq, pre + 4, dst + 4, 16, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[16]*dq[0], pre + 4, dst + 4, 16, stride);
+ ((int *)(q + 16))[0] = 0;
+ }
+
+ if (eobs[2] > 1)
+ vpx_dequant_idct_add_mmx(q + 32, dq, pre + 8, dst + 8, 16, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[32]*dq[0], pre + 8, dst + 8, 16, stride);
+ ((int *)(q + 32))[0] = 0;
+ }
+
+ if (eobs[3] > 1)
+ vpx_dequant_idct_add_mmx(q + 48, dq, pre + 12, dst + 12, 16, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[48]*dq[0], pre + 12, dst + 12, 16, stride);
+ ((int *)(q + 48))[0] = 0;
}
+
+ q += 64;
+ pre += 64;
+ dst += 4 * stride;
+ eobs += 4;
+ }
}
void vp8_dequant_idct_add_uv_block_mmx
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 2; i++)
- {
- if (eobs[0] > 1)
- vpx_dequant_idct_add_mmx (q, dq, pre, dstu, 8, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[0]*dq[0], pre, dstu, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vpx_dequant_idct_add_mmx (q+16, dq, pre+4, dstu+4, 8, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[16]*dq[0], pre+4, dstu+4, 8, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- q += 32;
- pre += 32;
- dstu += 4*stride;
- eobs += 2;
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ if (eobs[0] > 1)
+ vpx_dequant_idct_add_mmx(q, dq, pre, dstu, 8, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[0]*dq[0], pre, dstu, 8, stride);
+ ((int *)q)[0] = 0;
+ }
+
+ if (eobs[1] > 1)
+ vpx_dequant_idct_add_mmx(q + 16, dq, pre + 4, dstu + 4, 8, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[16]*dq[0], pre + 4, dstu + 4, 8, stride);
+ ((int *)(q + 16))[0] = 0;
}
- for (i = 0; i < 2; i++)
- {
- if (eobs[0] > 1)
- vpx_dequant_idct_add_mmx (q, dq, pre, dstv, 8, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[0]*dq[0], pre, dstv, 8, stride);
- ((int *)q)[0] = 0;
- }
-
- if (eobs[1] > 1)
- vpx_dequant_idct_add_mmx (q+16, dq, pre+4, dstv+4, 8, stride);
- else
- {
- vpx_dc_only_idct_add_mmx (q[16]*dq[0], pre+4, dstv+4, 8, stride);
- ((int *)(q+16))[0] = 0;
- }
-
- q += 32;
- pre += 32;
- dstv += 4*stride;
- eobs += 2;
+ q += 32;
+ pre += 32;
+ dstu += 4 * stride;
+ eobs += 2;
+ }
+
+ for (i = 0; i < 2; i++) {
+ if (eobs[0] > 1)
+ vpx_dequant_idct_add_mmx(q, dq, pre, dstv, 8, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[0]*dq[0], pre, dstv, 8, stride);
+ ((int *)q)[0] = 0;
}
+
+ if (eobs[1] > 1)
+ vpx_dequant_idct_add_mmx(q + 16, dq, pre + 4, dstv + 4, 8, stride);
+ else {
+ vpx_dc_only_idct_add_mmx(q[16]*dq[0], pre + 4, dstv + 4, 8, stride);
+ ((int *)(q + 16))[0] = 0;
+ }
+
+ q += 32;
+ pre += 32;
+ dstv += 4 * stride;
+ eobs += 2;
+ }
}
diff --git a/vp8/decoder/x86/idct_blk_sse2.c b/vp8/decoder/x86/idct_blk_sse2.c
index 3a4806862..17ecde12c 100644
--- a/vp8/decoder/x86/idct_blk_sse2.c
+++ b/vp8/decoder/x86/idct_blk_sse2.c
@@ -13,102 +13,97 @@
#include "vp8/decoder/dequantize.h"
void vp8_idct_dequant_dc_0_2x_sse2
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int dst_stride, short *dc);
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int dst_stride, short *dc);
void vp8_idct_dequant_dc_full_2x_sse2
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int dst_stride, short *dc);
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int dst_stride, short *dc);
void vp8_idct_dequant_0_2x_sse2
- (short *q, short *dq ,unsigned char *pre,
- unsigned char *dst, int dst_stride, int blk_stride);
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int dst_stride, int blk_stride);
void vp8_idct_dequant_full_2x_sse2
- (short *q, short *dq ,unsigned char *pre,
- unsigned char *dst, int dst_stride, int blk_stride);
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int dst_stride, int blk_stride);
void vp8_dequant_dc_idct_add_y_block_sse2
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs, short *dc)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (((short *)(eobs))[0] & 0xfefe)
- vp8_idct_dequant_dc_full_2x_sse2 (q, dq, pre, dst, stride, dc);
- else
- vp8_idct_dequant_dc_0_2x_sse2 (q, dq, pre, dst, stride, dc);
-
- if (((short *)(eobs))[1] & 0xfefe)
- vp8_idct_dequant_dc_full_2x_sse2 (q+32, dq, pre+8, dst+8, stride, dc+2);
- else
- vp8_idct_dequant_dc_0_2x_sse2 (q+32, dq, pre+8, dst+8, stride, dc+2);
-
- q += 64;
- dc += 4;
- pre += 64;
- dst += stride*4;
- eobs += 4;
- }
-}
-
-void vp8_dequant_idct_add_y_block_sse2
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dst, int stride, char *eobs)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (((short *)(eobs))[0] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q, dq, pre, dst, stride, 16);
- else
- vp8_idct_dequant_0_2x_sse2 (q, dq, pre, dst, stride, 16);
-
- if (((short *)(eobs))[1] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q+32, dq, pre+8, dst+8, stride, 16);
- else
- vp8_idct_dequant_0_2x_sse2 (q+32, dq, pre+8, dst+8, stride, 16);
-
- q += 64;
- pre += 64;
- dst += stride*4;
- eobs += 4;
- }
-}
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs, short *dc) {
+ int i;
-void vp8_dequant_idct_add_uv_block_sse2
- (short *q, short *dq, unsigned char *pre,
- unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
-{
+ for (i = 0; i < 4; i++) {
if (((short *)(eobs))[0] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q, dq, pre, dstu, stride, 8);
+ vp8_idct_dequant_dc_full_2x_sse2(q, dq, pre, dst, stride, dc);
else
- vp8_idct_dequant_0_2x_sse2 (q, dq, pre, dstu, stride, 8);
-
- q += 32;
- pre += 32;
- dstu += stride*4;
+ vp8_idct_dequant_dc_0_2x_sse2(q, dq, pre, dst, stride, dc);
if (((short *)(eobs))[1] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q, dq, pre, dstu, stride, 8);
+ vp8_idct_dequant_dc_full_2x_sse2(q + 32, dq, pre + 8, dst + 8, stride, dc + 2);
else
- vp8_idct_dequant_0_2x_sse2 (q, dq, pre, dstu, stride, 8);
+ vp8_idct_dequant_dc_0_2x_sse2(q + 32, dq, pre + 8, dst + 8, stride, dc + 2);
+
+ q += 64;
+ dc += 4;
+ pre += 64;
+ dst += stride * 4;
+ eobs += 4;
+ }
+}
- q += 32;
- pre += 32;
+void vp8_dequant_idct_add_y_block_sse2
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dst, int stride, char *eobs) {
+ int i;
- if (((short *)(eobs))[2] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q, dq, pre, dstv, stride, 8);
+ for (i = 0; i < 4; i++) {
+ if (((short *)(eobs))[0] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q, dq, pre, dst, stride, 16);
else
- vp8_idct_dequant_0_2x_sse2 (q, dq, pre, dstv, stride, 8);
-
- q += 32;
- pre += 32;
- dstv += stride*4;
+ vp8_idct_dequant_0_2x_sse2(q, dq, pre, dst, stride, 16);
- if (((short *)(eobs))[3] & 0xfefe)
- vp8_idct_dequant_full_2x_sse2 (q, dq, pre, dstv, stride, 8);
+ if (((short *)(eobs))[1] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q + 32, dq, pre + 8, dst + 8, stride, 16);
else
- vp8_idct_dequant_0_2x_sse2 (q, dq, pre, dstv, stride, 8);
+ vp8_idct_dequant_0_2x_sse2(q + 32, dq, pre + 8, dst + 8, stride, 16);
+
+ q += 64;
+ pre += 64;
+ dst += stride * 4;
+ eobs += 4;
+ }
+}
+
+void vp8_dequant_idct_add_uv_block_sse2
+(short *q, short *dq, unsigned char *pre,
+ unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) {
+ if (((short *)(eobs))[0] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q, dq, pre, dstu, stride, 8);
+ else
+ vp8_idct_dequant_0_2x_sse2(q, dq, pre, dstu, stride, 8);
+
+ q += 32;
+ pre += 32;
+ dstu += stride * 4;
+
+ if (((short *)(eobs))[1] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q, dq, pre, dstu, stride, 8);
+ else
+ vp8_idct_dequant_0_2x_sse2(q, dq, pre, dstu, stride, 8);
+
+ q += 32;
+ pre += 32;
+
+ if (((short *)(eobs))[2] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q, dq, pre, dstv, stride, 8);
+ else
+ vp8_idct_dequant_0_2x_sse2(q, dq, pre, dstv, stride, 8);
+
+ q += 32;
+ pre += 32;
+ dstv += stride * 4;
+
+ if (((short *)(eobs))[3] & 0xfefe)
+ vp8_idct_dequant_full_2x_sse2(q, dq, pre, dstv, stride, 8);
+ else
+ vp8_idct_dequant_0_2x_sse2(q, dq, pre, dstv, stride, 8);
}
diff --git a/vp8/decoder/x86/x86_dsystemdependent.c b/vp8/decoder/x86/x86_dsystemdependent.c
index c46cfaec7..ec7089752 100644
--- a/vp8/decoder/x86/x86_dsystemdependent.c
+++ b/vp8/decoder/x86/x86_dsystemdependent.c
@@ -17,45 +17,41 @@
#if HAVE_MMX
void vpx_dequantize_b_impl_mmx(short *sq, short *dq, short *q);
-void vp8_dequantize_b_mmx(BLOCKD *d)
-{
- short *sq = (short *) d->qcoeff;
- short *dq = (short *) d->dqcoeff;
- short *q = (short *) d->dequant;
- vpx_dequantize_b_impl_mmx(sq, dq, q);
+void vp8_dequantize_b_mmx(BLOCKD *d) {
+ short *sq = (short *) d->qcoeff;
+ short *dq = (short *) d->dqcoeff;
+ short *q = (short *) d->dequant;
+ vpx_dequantize_b_impl_mmx(sq, dq, q);
}
#endif
-void vp8_arch_x86_decode_init(VP8D_COMP *pbi)
-{
+void vp8_arch_x86_decode_init(VP8D_COMP *pbi) {
#if CONFIG_RUNTIME_CPU_DETECT
- int flags = x86_simd_caps();
-
- /* Note:
- *
- * This platform can be built without runtime CPU detection as well. If
- * you modify any of the function mappings present in this file, be sure
- * to also update them in static mapings (<arch>/filename_<arch>.h)
- */
- /* Override default functions with fastest ones for this CPU. */
+ int flags = x86_simd_caps();
+
+ /* Note:
+ *
+ * This platform can be built without runtime CPU detection as well. If
+ * you modify any of the function mappings present in this file, be sure
+ * to also update them in static mapings (<arch>/filename_<arch>.h)
+ */
+ /* Override default functions with fastest ones for this CPU. */
#if HAVE_MMX
- if (flags & HAS_MMX)
- {
- pbi->dequant.block = vp8_dequantize_b_mmx;
- pbi->dequant.idct_add = vpx_dequant_idct_add_mmx;
- pbi->dequant.dc_idct_add = vpx_dequant_dc_idct_add_mmx;
- pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_mmx;
- pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_mmx;
- pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_mmx;
- }
+ if (flags & HAS_MMX) {
+ pbi->dequant.block = vp8_dequantize_b_mmx;
+ pbi->dequant.idct_add = vpx_dequant_idct_add_mmx;
+ pbi->dequant.dc_idct_add = vpx_dequant_dc_idct_add_mmx;
+ pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_mmx;
+ pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_mmx;
+ pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_mmx;
+ }
#endif
#if HAVE_SSE2
- if (flags & HAS_SSE2)
- {
- //pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_sse2;
- //pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_sse2;
- //pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_sse2;
- }
+ if (flags & HAS_SSE2) {
+ // pbi->dequant.dc_idct_add_y_block = vp8_dequant_dc_idct_add_y_block_sse2;
+ // pbi->dequant.idct_add_y_block = vp8_dequant_idct_add_y_block_sse2;
+ // pbi->dequant.idct_add_uv_block = vp8_dequant_idct_add_uv_block_sse2;
+ }
#endif
#endif
diff --git a/vp8/encoder/arm/arm_csystemdependent.c b/vp8/encoder/arm/arm_csystemdependent.c
index e66835ae0..1166efd96 100644
--- a/vp8/encoder/arm/arm_csystemdependent.c
+++ b/vp8/encoder/arm/arm_csystemdependent.c
@@ -18,116 +18,112 @@ extern void (*vp8_yv12_copy_partial_frame_ptr)(YV12_BUFFER_CONFIG *src_ybc, YV12
extern void vp8_yv12_copy_partial_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction);
extern void vpxyv12_copy_partial_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction);
-void vp8_arch_arm_encoder_init(VP8_COMP *cpi)
-{
+void vp8_arch_arm_encoder_init(VP8_COMP *cpi) {
#if CONFIG_RUNTIME_CPU_DETECT
- int flags = cpi->common.rtcd.flags;
+ int flags = cpi->common.rtcd.flags;
#if HAVE_ARMV5TE
- if (flags & HAS_EDSP)
- {
- }
+ if (flags & HAS_EDSP) {
+ }
#endif
#if HAVE_ARMV6
- if (flags & HAS_MEDIA)
- {
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_armv6;
- /*cpi->rtcd.variance.sad16x8 = vp8_sad16x8_c;
- cpi->rtcd.variance.sad8x16 = vp8_sad8x16_c;
- cpi->rtcd.variance.sad8x8 = vp8_sad8x8_c;
- cpi->rtcd.variance.sad4x4 = vp8_sad4x4_c;*/
-
- /*cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;*/
- cpi->rtcd.variance.var8x8 = vp8_variance8x8_armv6;
- /*cpi->rtcd.variance.var8x16 = vp8_variance8x16_c;
- cpi->rtcd.variance.var16x8 = vp8_variance16x8_c;*/
- cpi->rtcd.variance.var16x16 = vp8_variance16x16_armv6;
-
- /*cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;*/
- cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_armv6;
- /*cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;*/
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_armv6;
- cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_armv6;
- cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_armv6;
- cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_armv6;
-
- cpi->rtcd.variance.mse16x16 = vp8_mse16x16_armv6;
- /*cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;*/
-
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_armv6;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_armv6;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_armv6;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_armv6;
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_armv6;
-
- /*cpi->rtcd.encodemb.berr = vp8_block_error_c;
- cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
- cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;*/
- cpi->rtcd.encodemb.subb = vp8_subtract_b_armv6;
- cpi->rtcd.encodemb.submby = vp8_subtract_mby_armv6;
- cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_armv6;
-
- /*cpi->rtcd.quantize.quantb = vp8_regular_quantize_b;*/
- cpi->rtcd.quantize.fastquantb = vp8_fast_quantize_b_armv6;
- }
+ if (flags & HAS_MEDIA) {
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_armv6;
+ /*cpi->rtcd.variance.sad16x8 = vp8_sad16x8_c;
+ cpi->rtcd.variance.sad8x16 = vp8_sad8x16_c;
+ cpi->rtcd.variance.sad8x8 = vp8_sad8x8_c;
+ cpi->rtcd.variance.sad4x4 = vp8_sad4x4_c;*/
+
+ /*cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;*/
+ cpi->rtcd.variance.var8x8 = vp8_variance8x8_armv6;
+ /*cpi->rtcd.variance.var8x16 = vp8_variance8x16_c;
+ cpi->rtcd.variance.var16x8 = vp8_variance16x8_c;*/
+ cpi->rtcd.variance.var16x16 = vp8_variance16x16_armv6;
+
+ /*cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;*/
+ cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_armv6;
+ /*cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;*/
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_armv6;
+ cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_armv6;
+ cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_armv6;
+ cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_armv6;
+
+ cpi->rtcd.variance.mse16x16 = vp8_mse16x16_armv6;
+ /*cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;*/
+
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_armv6;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_armv6;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_armv6;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_armv6;
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_armv6;
+
+ /*cpi->rtcd.encodemb.berr = vp8_block_error_c;
+ cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
+ cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;*/
+ cpi->rtcd.encodemb.subb = vp8_subtract_b_armv6;
+ cpi->rtcd.encodemb.submby = vp8_subtract_mby_armv6;
+ cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_armv6;
+
+ /*cpi->rtcd.quantize.quantb = vp8_regular_quantize_b;*/
+ cpi->rtcd.quantize.fastquantb = vp8_fast_quantize_b_armv6;
+ }
#endif
#if HAVE_ARMV7
- if (flags & HAS_NEON)
- {
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_neon;
- cpi->rtcd.variance.sad16x8 = vp8_sad16x8_neon;
- cpi->rtcd.variance.sad8x16 = vp8_sad8x16_neon;
- cpi->rtcd.variance.sad8x8 = vp8_sad8x8_neon;
- cpi->rtcd.variance.sad4x4 = vp8_sad4x4_neon;
-
- /*cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;*/
- cpi->rtcd.variance.var8x8 = vp8_variance8x8_neon;
- cpi->rtcd.variance.var8x16 = vp8_variance8x16_neon;
- cpi->rtcd.variance.var16x8 = vp8_variance16x8_neon;
- cpi->rtcd.variance.var16x16 = vp8_variance16x16_neon;
-
- /*cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;*/
- cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_neon;
- /*cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;*/
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_neon;
- cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_neon;
- cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_neon;
- cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_neon;
-
- cpi->rtcd.variance.mse16x16 = vp8_mse16x16_neon;
- /*cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;*/
-
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_neon;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_neon;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_neon;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_neon;
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_neon;
-
- /*cpi->rtcd.encodemb.berr = vp8_block_error_c;
- cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
- cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;*/
- cpi->rtcd.encodemb.subb = vp8_subtract_b_neon;
- cpi->rtcd.encodemb.submby = vp8_subtract_mby_neon;
- cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_neon;
-
- /*cpi->rtcd.quantize.quantb = vp8_regular_quantize_b;
- cpi->rtcd.quantize.quantb_pair = vp8_regular_quantize_b_pair;*/
- cpi->rtcd.quantize.fastquantb = vp8_fast_quantize_b_neon;
- cpi->rtcd.quantize.fastquantb_pair = vp8_fast_quantize_b_pair_neon;
- }
+ if (flags & HAS_NEON) {
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_neon;
+ cpi->rtcd.variance.sad16x8 = vp8_sad16x8_neon;
+ cpi->rtcd.variance.sad8x16 = vp8_sad8x16_neon;
+ cpi->rtcd.variance.sad8x8 = vp8_sad8x8_neon;
+ cpi->rtcd.variance.sad4x4 = vp8_sad4x4_neon;
+
+ /*cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;*/
+ cpi->rtcd.variance.var8x8 = vp8_variance8x8_neon;
+ cpi->rtcd.variance.var8x16 = vp8_variance8x16_neon;
+ cpi->rtcd.variance.var16x8 = vp8_variance16x8_neon;
+ cpi->rtcd.variance.var16x16 = vp8_variance16x16_neon;
+
+ /*cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;*/
+ cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_neon;
+ /*cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;*/
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_neon;
+ cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_neon;
+ cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_neon;
+ cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_neon;
+
+ cpi->rtcd.variance.mse16x16 = vp8_mse16x16_neon;
+ /*cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;*/
+
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_neon;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_neon;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_neon;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_neon;
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_neon;
+
+ /*cpi->rtcd.encodemb.berr = vp8_block_error_c;
+ cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
+ cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;*/
+ cpi->rtcd.encodemb.subb = vp8_subtract_b_neon;
+ cpi->rtcd.encodemb.submby = vp8_subtract_mby_neon;
+ cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_neon;
+
+ /*cpi->rtcd.quantize.quantb = vp8_regular_quantize_b;
+ cpi->rtcd.quantize.quantb_pair = vp8_regular_quantize_b_pair;*/
+ cpi->rtcd.quantize.fastquantb = vp8_fast_quantize_b_neon;
+ cpi->rtcd.quantize.fastquantb_pair = vp8_fast_quantize_b_pair_neon;
+ }
#endif
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (flags & HAS_NEON)
+ if (flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_partial_frame_ptr = vpxyv12_copy_partial_frame_neon;
- }
+ {
+ vp8_yv12_copy_partial_frame_ptr = vpxyv12_copy_partial_frame_neon;
+ }
#endif
#endif
}
diff --git a/vp8/encoder/arm/boolhuff_arm.c b/vp8/encoder/arm/boolhuff_arm.c
index 9089663ca..07042071a 100644
--- a/vp8/encoder/arm/boolhuff_arm.c
+++ b/vp8/encoder/arm/boolhuff_arm.c
@@ -12,23 +12,22 @@
#include "vp8/encoder/boolhuff.h"
#include "vp8/common/blockd.h"
-const unsigned int vp8_prob_cost[256] =
-{
- 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, 1129, 1099, 1072, 1046,
- 1023, 1000, 979, 959, 940, 922, 905, 889, 873, 858, 843, 829, 816, 803, 790, 778,
- 767, 755, 744, 733, 723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625,
- 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, 534, 528, 522, 516,
- 511, 505, 499, 494, 488, 483, 477, 472, 467, 462, 457, 452, 447, 442, 437, 433,
- 428, 424, 419, 415, 410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365,
- 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, 317, 314, 311, 307,
- 304, 301, 297, 294, 291, 288, 285, 281, 278, 275, 272, 269, 266, 263, 260, 257,
- 255, 252, 249, 246, 243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214,
- 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, 181, 179, 177, 174,
- 172, 170, 168, 165, 163, 161, 159, 156, 154, 152, 150, 148, 145, 143, 141, 139,
- 137, 135, 133, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107,
- 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, 82, 81, 79, 77,
- 75, 73, 72, 70, 68, 66, 65, 63, 61, 60, 58, 56, 55, 53, 51, 50,
- 48, 46, 45, 43, 41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24,
- 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3, 1, 1
+const unsigned int vp8_prob_cost[256] = {
+ 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, 1129, 1099, 1072, 1046,
+ 1023, 1000, 979, 959, 940, 922, 905, 889, 873, 858, 843, 829, 816, 803, 790, 778,
+ 767, 755, 744, 733, 723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625,
+ 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, 534, 528, 522, 516,
+ 511, 505, 499, 494, 488, 483, 477, 472, 467, 462, 457, 452, 447, 442, 437, 433,
+ 428, 424, 419, 415, 410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365,
+ 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, 317, 314, 311, 307,
+ 304, 301, 297, 294, 291, 288, 285, 281, 278, 275, 272, 269, 266, 263, 260, 257,
+ 255, 252, 249, 246, 243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214,
+ 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, 181, 179, 177, 174,
+ 172, 170, 168, 165, 163, 161, 159, 156, 154, 152, 150, 148, 145, 143, 141, 139,
+ 137, 135, 133, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107,
+ 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, 82, 81, 79, 77,
+ 75, 73, 72, 70, 68, 66, 65, 63, 61, 60, 58, 56, 55, 53, 51, 50,
+ 48, 46, 45, 43, 41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24,
+ 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3, 1, 1
};
diff --git a/vp8/encoder/arm/dct_arm.c b/vp8/encoder/arm/dct_arm.c
index 2692acb49..913d5c0f0 100644
--- a/vp8/encoder/arm/dct_arm.c
+++ b/vp8/encoder/arm/dct_arm.c
@@ -13,10 +13,9 @@
#if HAVE_ARMV6
-void vp8_short_fdct8x4_armv6(short *input, short *output, int pitch)
-{
- vp8_short_fdct4x4_armv6(input, output, pitch);
- vp8_short_fdct4x4_armv6(input + 4, output + 16, pitch);
+void vp8_short_fdct8x4_armv6(short *input, short *output, int pitch) {
+ vp8_short_fdct4x4_armv6(input, output, pitch);
+ vp8_short_fdct4x4_armv6(input + 4, output + 16, pitch);
}
#endif /* HAVE_ARMV6 */
diff --git a/vp8/encoder/arm/encodemb_arm.h b/vp8/encoder/arm/encodemb_arm.h
index bf417fe1d..7bcc747fc 100644
--- a/vp8/encoder/arm/encodemb_arm.h
+++ b/vp8/encoder/arm/encodemb_arm.h
@@ -31,22 +31,22 @@ extern prototype_submbuv(vp8_subtract_mbuv_armv6);
#endif /* HAVE_ARMV6 */
#if HAVE_ARMV7
-//extern prototype_berr(vp8_block_error_c);
-//extern prototype_mberr(vp8_mbblock_error_c);
-//extern prototype_mbuverr(vp8_mbuverror_c);
+// extern prototype_berr(vp8_block_error_c);
+// extern prototype_mberr(vp8_mbblock_error_c);
+// extern prototype_mbuverr(vp8_mbuverror_c);
extern prototype_subb(vp8_subtract_b_neon);
extern prototype_submby(vp8_subtract_mby_neon);
extern prototype_submbuv(vp8_subtract_mbuv_neon);
-//#undef vp8_encodemb_berr
-//#define vp8_encodemb_berr vp8_block_error_c
+// #undef vp8_encodemb_berr
+// #define vp8_encodemb_berr vp8_block_error_c
-//#undef vp8_encodemb_mberr
-//#define vp8_encodemb_mberr vp8_mbblock_error_c
+// #undef vp8_encodemb_mberr
+// #define vp8_encodemb_mberr vp8_mbblock_error_c
-//#undef vp8_encodemb_mbuverr
-//#define vp8_encodemb_mbuverr vp8_mbuverror_c
+// #undef vp8_encodemb_mbuverr
+// #define vp8_encodemb_mbuverr vp8_mbuverror_c
#if !CONFIG_RUNTIME_CPU_DETECT
#undef vp8_encodemb_subb
diff --git a/vp8/encoder/arm/neon/picklpf_arm.c b/vp8/encoder/arm/neon/picklpf_arm.c
index 3fb370c3d..44cb6a674 100644
--- a/vp8/encoder/arm/neon/picklpf_arm.c
+++ b/vp8/encoder/arm/neon/picklpf_arm.c
@@ -21,30 +21,29 @@ extern void vp8_memcpy_neon(unsigned char *dst_ptr, unsigned char *src_ptr, int
void
-vpxyv12_copy_partial_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction)
-{
- unsigned char *src_y, *dst_y;
- int yheight;
- int ystride;
- int border;
- int yoffset;
- int linestocopy;
+vpxyv12_copy_partial_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction) {
+ unsigned char *src_y, *dst_y;
+ int yheight;
+ int ystride;
+ int border;
+ int yoffset;
+ int linestocopy;
- border = src_ybc->border;
- yheight = src_ybc->y_height;
- ystride = src_ybc->y_stride;
+ border = src_ybc->border;
+ yheight = src_ybc->y_height;
+ ystride = src_ybc->y_stride;
- linestocopy = (yheight >> (Fraction + 4));
+ linestocopy = (yheight >> (Fraction + 4));
- if (linestocopy < 1)
- linestocopy = 1;
+ if (linestocopy < 1)
+ linestocopy = 1;
- linestocopy <<= 4;
+ linestocopy <<= 4;
- yoffset = ystride * ((yheight >> 5) * 16 - 8);
- src_y = src_ybc->y_buffer + yoffset;
- dst_y = dst_ybc->y_buffer + yoffset;
+ yoffset = ystride * ((yheight >> 5) * 16 - 8);
+ src_y = src_ybc->y_buffer + yoffset;
+ dst_y = dst_ybc->y_buffer + yoffset;
- //vpx_memcpy (dst_y, src_y, ystride * (linestocopy +16));
- vp8_memcpy_neon((unsigned char *)dst_y, (unsigned char *)src_y, (int)(ystride *(linestocopy + 16)));
+ // vpx_memcpy (dst_y, src_y, ystride * (linestocopy +16));
+ vp8_memcpy_neon((unsigned char *)dst_y, (unsigned char *)src_y, (int)(ystride * (linestocopy + 16)));
}
diff --git a/vp8/encoder/arm/quantize_arm.c b/vp8/encoder/arm/quantize_arm.c
index 52d84013e..b78c2534b 100644
--- a/vp8/encoder/arm/quantize_arm.c
+++ b/vp8/encoder/arm/quantize_arm.c
@@ -21,42 +21,39 @@
/* vp8_quantize_mbX functions here differs from corresponding ones in
* quantize.c only by using quantize_b_pair function pointer instead of
* the regular quantize_b function pointer */
-void vp8_quantize_mby_neon(MACROBLOCK *x)
-{
- int i;
- int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
-
- for (i = 0; i < 16; i+=2)
- x->quantize_b_pair(&x->block[i], &x->block[i+1],
- &x->e_mbd.block[i], &x->e_mbd.block[i+1]);
-
- if(has_2nd_order)
- x->quantize_b(&x->block[24], &x->e_mbd.block[24]);
+void vp8_quantize_mby_neon(MACROBLOCK *x) {
+ int i;
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+
+ for (i = 0; i < 16; i += 2)
+ x->quantize_b_pair(&x->block[i], &x->block[i + 1],
+ &x->e_mbd.block[i], &x->e_mbd.block[i + 1]);
+
+ if (has_2nd_order)
+ x->quantize_b(&x->block[24], &x->e_mbd.block[24]);
}
-void vp8_quantize_mb_neon(MACROBLOCK *x)
-{
- int i;
- int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+void vp8_quantize_mb_neon(MACROBLOCK *x) {
+ int i;
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for (i = 0; i < 24; i+=2)
- x->quantize_b_pair(&x->block[i], &x->block[i+1],
- &x->e_mbd.block[i], &x->e_mbd.block[i+1]);
+ for (i = 0; i < 24; i += 2)
+ x->quantize_b_pair(&x->block[i], &x->block[i + 1],
+ &x->e_mbd.block[i], &x->e_mbd.block[i + 1]);
- if (has_2nd_order)
- x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
+ if (has_2nd_order)
+ x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
}
-void vp8_quantize_mbuv_neon(MACROBLOCK *x)
-{
- int i;
+void vp8_quantize_mbuv_neon(MACROBLOCK *x) {
+ int i;
- for (i = 16; i < 24; i+=2)
- x->quantize_b_pair(&x->block[i], &x->block[i+1],
- &x->e_mbd.block[i], &x->e_mbd.block[i+1]);
+ for (i = 16; i < 24; i += 2)
+ x->quantize_b_pair(&x->block[i], &x->block[i + 1],
+ &x->e_mbd.block[i], &x->e_mbd.block[i + 1]);
}
#endif /* HAVE_ARMV7 */
diff --git a/vp8/encoder/arm/variance_arm.c b/vp8/encoder/arm/variance_arm.c
index 6e83c6e7b..b268f3e19 100644
--- a/vp8/encoder/arm/variance_arm.c
+++ b/vp8/encoder/arm/variance_arm.c
@@ -23,78 +23,69 @@
unsigned int vp8_sub_pixel_variance8x8_armv6
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short first_pass[10*8];
- unsigned char second_pass[8*8];
- const short *HFilter, *VFilter;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short first_pass[10 * 8];
+ unsigned char second_pass[8 * 8];
+ const short *HFilter, *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ vp8_filter_block2d_bil_first_pass_armv6(src_ptr, first_pass,
+ src_pixels_per_line,
+ 9, 8, HFilter);
+ vp8_filter_block2d_bil_second_pass_armv6(first_pass, second_pass,
+ 8, 8, 8, VFilter);
+
+ return vp8_variance8x8_armv6(second_pass, 8, dst_ptr,
+ dst_pixels_per_line, sse);
+}
+unsigned int vp8_sub_pixel_variance16x16_armv6
+(
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short first_pass[36 * 16];
+ unsigned char second_pass[20 * 16];
+ const short *HFilter, *VFilter;
+ unsigned int var;
+
+ if (xoffset == HALFNDX && yoffset == 0) {
+ var = vp8_variance_halfpixvar16x16_h_armv6(src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, sse);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ var = vp8_variance_halfpixvar16x16_v_armv6(src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, sse);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ var = vp8_variance_halfpixvar16x16_hv_armv6(src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, sse);
+ } else {
HFilter = vp8_bilinear_filters[xoffset];
VFilter = vp8_bilinear_filters[yoffset];
vp8_filter_block2d_bil_first_pass_armv6(src_ptr, first_pass,
src_pixels_per_line,
- 9, 8, HFilter);
+ 17, 16, HFilter);
vp8_filter_block2d_bil_second_pass_armv6(first_pass, second_pass,
- 8, 8, 8, VFilter);
+ 16, 16, 16, VFilter);
- return vp8_variance8x8_armv6(second_pass, 8, dst_ptr,
- dst_pixels_per_line, sse);
-}
-
-unsigned int vp8_sub_pixel_variance16x16_armv6
-(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short first_pass[36*16];
- unsigned char second_pass[20*16];
- const short *HFilter, *VFilter;
- unsigned int var;
-
- if (xoffset == HALFNDX && yoffset == 0)
- {
- var = vp8_variance_halfpixvar16x16_h_armv6(src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, sse);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- var = vp8_variance_halfpixvar16x16_v_armv6(src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, sse);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- var = vp8_variance_halfpixvar16x16_hv_armv6(src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, sse);
- }
- else
- {
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- vp8_filter_block2d_bil_first_pass_armv6(src_ptr, first_pass,
- src_pixels_per_line,
- 17, 16, HFilter);
- vp8_filter_block2d_bil_second_pass_armv6(first_pass, second_pass,
- 16, 16, 16, VFilter);
-
- var = vp8_variance16x16_armv6(second_pass, 16, dst_ptr,
- dst_pixels_per_line, sse);
- }
- return var;
+ var = vp8_variance16x16_armv6(second_pass, 16, dst_ptr,
+ dst_pixels_per_line, sse);
+ }
+ return var;
}
#endif /* HAVE_ARMV6 */
@@ -104,15 +95,14 @@ unsigned int vp8_sub_pixel_variance16x16_armv6
unsigned int vp8_sub_pixel_variance16x16_neon
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
if (xoffset == HALFNDX && yoffset == 0)
return vp8_variance_halfpixvar16x16_h_neon(src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
else if (xoffset == 0 && yoffset == HALFNDX)
diff --git a/vp8/encoder/arm/variance_arm.h b/vp8/encoder/arm/variance_arm.h
index fdb7289b1..8deb72d4a 100644
--- a/vp8/encoder/arm/variance_arm.h
+++ b/vp8/encoder/arm/variance_arm.h
@@ -65,23 +65,23 @@ extern prototype_sad(vp8_sad8x16_neon);
extern prototype_sad(vp8_sad16x8_neon);
extern prototype_sad(vp8_sad16x16_neon);
-//extern prototype_variance(vp8_variance4x4_c);
+// extern prototype_variance(vp8_variance4x4_c);
extern prototype_variance(vp8_variance8x8_neon);
extern prototype_variance(vp8_variance8x16_neon);
extern prototype_variance(vp8_variance16x8_neon);
extern prototype_variance(vp8_variance16x16_neon);
-//extern prototype_subpixvariance(vp8_sub_pixel_variance4x4_c);
+// extern prototype_subpixvariance(vp8_sub_pixel_variance4x4_c);
extern prototype_subpixvariance(vp8_sub_pixel_variance8x8_neon);
-//extern prototype_subpixvariance(vp8_sub_pixel_variance8x16_c);
-//extern prototype_subpixvariance(vp8_sub_pixel_variance16x8_c);
+// extern prototype_subpixvariance(vp8_sub_pixel_variance8x16_c);
+// extern prototype_subpixvariance(vp8_sub_pixel_variance16x8_c);
extern prototype_subpixvariance(vp8_sub_pixel_variance16x16_neon);
extern prototype_subpixvariance(vp8_sub_pixel_variance16x16_neon_func);
extern prototype_variance(vp8_variance_halfpixvar16x16_h_neon);
extern prototype_variance(vp8_variance_halfpixvar16x16_v_neon);
extern prototype_variance(vp8_variance_halfpixvar16x16_hv_neon);
-//extern prototype_getmbss(vp8_get_mb_ss_c);
+// extern prototype_getmbss(vp8_get_mb_ss_c);
extern prototype_variance(vp8_mse16x16_neon);
#if !CONFIG_RUNTIME_CPU_DETECT
@@ -100,8 +100,8 @@ extern prototype_variance(vp8_mse16x16_neon);
#undef vp8_variance_sad16x16
#define vp8_variance_sad16x16 vp8_sad16x16_neon
-//#undef vp8_variance_var4x4
-//#define vp8_variance_var4x4 vp8_variance4x4_c
+// #undef vp8_variance_var4x4
+// #define vp8_variance_var4x4 vp8_variance4x4_c
#undef vp8_variance_var8x8
#define vp8_variance_var8x8 vp8_variance8x8_neon
@@ -115,17 +115,17 @@ extern prototype_variance(vp8_mse16x16_neon);
#undef vp8_variance_var16x16
#define vp8_variance_var16x16 vp8_variance16x16_neon
-//#undef vp8_variance_subpixvar4x4
-//#define vp8_variance_subpixvar4x4 vp8_sub_pixel_variance4x4_c
+// #undef vp8_variance_subpixvar4x4
+// #define vp8_variance_subpixvar4x4 vp8_sub_pixel_variance4x4_c
#undef vp8_variance_subpixvar8x8
#define vp8_variance_subpixvar8x8 vp8_sub_pixel_variance8x8_neon
-//#undef vp8_variance_subpixvar8x16
-//#define vp8_variance_subpixvar8x16 vp8_sub_pixel_variance8x16_c
+// #undef vp8_variance_subpixvar8x16
+// #define vp8_variance_subpixvar8x16 vp8_sub_pixel_variance8x16_c
-//#undef vp8_variance_subpixvar16x8
-//#define vp8_variance_subpixvar16x8 vp8_sub_pixel_variance16x8_c
+// #undef vp8_variance_subpixvar16x8
+// #define vp8_variance_subpixvar16x8 vp8_sub_pixel_variance16x8_c
#undef vp8_variance_subpixvar16x16
#define vp8_variance_subpixvar16x16 vp8_sub_pixel_variance16x16_neon
@@ -139,8 +139,8 @@ extern prototype_variance(vp8_mse16x16_neon);
#undef vp8_variance_halfpixvar16x16_hv
#define vp8_variance_halfpixvar16x16_hv vp8_variance_halfpixvar16x16_hv_neon
-//#undef vp8_variance_getmbss
-//#define vp8_variance_getmbss vp8_get_mb_ss_c
+// #undef vp8_variance_getmbss
+// #define vp8_variance_getmbss vp8_get_mb_ss_c
#undef vp8_variance_mse16x16
#define vp8_variance_mse16x16 vp8_mse16x16_neon
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index 99201ba78..3d0119572 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -34,16 +34,16 @@ unsigned __int64 Sectionbits[500];
#ifdef ENTROPY_STATS
int intra_mode_stats[VP8_BINTRAMODES]
- [VP8_BINTRAMODES]
- [VP8_BINTRAMODES];
+[VP8_BINTRAMODES]
+[VP8_BINTRAMODES];
unsigned int tree_update_hist [BLOCK_TYPES]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES][2];
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES][2];
unsigned int tree_update_hist_8x8 [BLOCK_TYPES_8X8]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES] [2];
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES] [2];
extern unsigned int active_section;
#endif
@@ -59,2792 +59,2462 @@ int count_mb_seg[4] = { 0, 0, 0, 0 };
#define SEARCH_NEWP
static int update_bits[255];
-static void compute_update_table()
-{
- int i;
- for (i=0; i<255; i++)
- update_bits[i] = vp8_count_term_subexp(i, SUBEXP_PARAM, 255);
+static void compute_update_table() {
+ int i;
+ for (i = 0; i < 255; i++)
+ update_bits[i] = vp8_count_term_subexp(i, SUBEXP_PARAM, 255);
}
-static int split_index(int i, int n, int modulus)
-{
- int max1 = (n-1 - modulus/2)/modulus + 1;
- if (i%modulus == modulus/2) i = i/modulus;
- else i = max1 + i - (i + modulus-modulus/2)/modulus;
- return i;
+static int split_index(int i, int n, int modulus) {
+ int max1 = (n - 1 - modulus / 2) / modulus + 1;
+ if (i % modulus == modulus / 2) i = i / modulus;
+ else i = max1 + i - (i + modulus - modulus / 2) / modulus;
+ return i;
}
-static int remap_prob(int v, int m)
-{
- const int n = 256;
- const int modulus = MODULUS_PARAM;
- const int max1 = (n-2-modulus/2+modulus-1)/modulus;
- int i;
- if ((m<<1)<=n)
- i = recenter_nonneg(v, m) - 1;
- else
- i = recenter_nonneg(n-1-v, n-1-m) - 1;
-
- i = split_index(i, n-1, modulus);
- return i;
+static int remap_prob(int v, int m) {
+ const int n = 256;
+ const int modulus = MODULUS_PARAM;
+ const int max1 = (n - 2 - modulus / 2 + modulus - 1) / modulus;
+ int i;
+ if ((m << 1) <= n)
+ i = recenter_nonneg(v, m) - 1;
+ else
+ i = recenter_nonneg(n - 1 - v, n - 1 - m) - 1;
+
+ i = split_index(i, n - 1, modulus);
+ return i;
}
static void write_prob_diff_update(vp8_writer *const w,
- vp8_prob newp, vp8_prob oldp)
-{
- int delp = remap_prob(newp, oldp);
- vp8_encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
+ vp8_prob newp, vp8_prob oldp) {
+ int delp = remap_prob(newp, oldp);
+ vp8_encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
}
-static int prob_diff_update_cost(vp8_prob newp, vp8_prob oldp)
-{
- int delp = remap_prob(newp, oldp);
- return update_bits[delp]*256;
+static int prob_diff_update_cost(vp8_prob newp, vp8_prob oldp) {
+ int delp = remap_prob(newp, oldp);
+ return update_bits[delp] * 256;
}
#endif
static void update_mode(
- vp8_writer *const w,
- int n,
- vp8_token tok [/* n */],
- vp8_tree tree,
- vp8_prob Pnew [/* n-1 */],
- vp8_prob Pcur [/* n-1 */],
- unsigned int bct [/* n-1 */] [2],
- const unsigned int num_events[/* n */]
-)
-{
- unsigned int new_b = 0, old_b = 0;
+ vp8_writer *const w,
+ int n,
+ vp8_token tok [/* n */],
+ vp8_tree tree,
+ vp8_prob Pnew [/* n-1 */],
+ vp8_prob Pcur [/* n-1 */],
+ unsigned int bct [/* n-1 */] [2],
+ const unsigned int num_events[/* n */]
+) {
+ unsigned int new_b = 0, old_b = 0;
+ int i = 0;
+
+ vp8_tree_probs_from_distribution(
+ n--, tok, tree,
+ Pnew, bct, num_events,
+ 256, 1
+ );
+
+ do {
+ new_b += vp8_cost_branch(bct[i], Pnew[i]);
+ old_b += vp8_cost_branch(bct[i], Pcur[i]);
+ } while (++i < n);
+
+ if (new_b + (n << 8) < old_b) {
int i = 0;
- vp8_tree_probs_from_distribution(
- n--, tok, tree,
- Pnew, bct, num_events,
- 256, 1
- );
-
- do
- {
- new_b += vp8_cost_branch(bct[i], Pnew[i]);
- old_b += vp8_cost_branch(bct[i], Pcur[i]);
- }
- while (++i < n);
-
- if (new_b + (n << 8) < old_b)
- {
- int i = 0;
-
- vp8_write_bit(w, 1);
+ vp8_write_bit(w, 1);
- do
- {
- const vp8_prob p = Pnew[i];
+ do {
+ const vp8_prob p = Pnew[i];
- vp8_write_literal(w, Pcur[i] = p ? p : 1, 8);
- }
- while (++i < n);
- }
- else
- vp8_write_bit(w, 0);
+ vp8_write_literal(w, Pcur[i] = p ? p : 1, 8);
+ } while (++i < n);
+ } else
+ vp8_write_bit(w, 0);
}
-static void update_mbintra_mode_probs(VP8_COMP *cpi)
-{
- VP8_COMMON *const x = & cpi->common;
+static void update_mbintra_mode_probs(VP8_COMP *cpi) {
+ VP8_COMMON *const x = & cpi->common;
- vp8_writer *const w = & cpi->bc;
+ vp8_writer *const w = & cpi->bc;
- {
- vp8_prob Pnew [VP8_YMODES-1];
- unsigned int bct [VP8_YMODES-1] [2];
+ {
+ vp8_prob Pnew [VP8_YMODES - 1];
+ unsigned int bct [VP8_YMODES - 1] [2];
- update_mode(
- w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
- Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count
- );
- }
+ update_mode(
+ w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
+ Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count
+ );
+ }
}
-void update_skip_probs(VP8_COMP *cpi)
-{
+void update_skip_probs(VP8_COMP *cpi) {
#if CONFIG_NEWENTROPY
- VP8_COMMON *const pc = & cpi->common;
- int prob_skip_false[3] = {0, 0, 0};
- int k;
+ VP8_COMMON *const pc = & cpi->common;
+ int prob_skip_false[3] = {0, 0, 0};
+ int k;
- for (k=0;k<MBSKIP_CONTEXTS;++k)
- {
- if ( (cpi->skip_false_count[k] + cpi->skip_true_count[k]) )
- {
- prob_skip_false[k] =
- cpi->skip_false_count[k] * 256 /
- (cpi->skip_false_count[k] + cpi->skip_true_count[k]);
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k) {
+ if ((cpi->skip_false_count[k] + cpi->skip_true_count[k])) {
+ prob_skip_false[k] =
+ cpi->skip_false_count[k] * 256 /
+ (cpi->skip_false_count[k] + cpi->skip_true_count[k]);
- if (prob_skip_false[k] <= 1)
- prob_skip_false[k] = 1;
+ if (prob_skip_false[k] <= 1)
+ prob_skip_false[k] = 1;
- if (prob_skip_false[k] > 255)
- prob_skip_false[k] = 255;
- }
- else
- prob_skip_false[k] = 128;
+ if (prob_skip_false[k] > 255)
+ prob_skip_false[k] = 255;
+ } else
+ prob_skip_false[k] = 128;
- pc->mbskip_pred_probs[k] = prob_skip_false[k];
- }
+ pc->mbskip_pred_probs[k] = prob_skip_false[k];
+ }
#else
- int prob_skip_false = 0;
+ int prob_skip_false = 0;
- if ( (cpi->skip_false_count + cpi->skip_true_count) )
- {
- prob_skip_false = cpi->skip_false_count * 256 /
- (cpi->skip_false_count + cpi->skip_true_count);
+ if ((cpi->skip_false_count + cpi->skip_true_count)) {
+ prob_skip_false = cpi->skip_false_count * 256 /
+ (cpi->skip_false_count + cpi->skip_true_count);
- if (prob_skip_false <= 1)
- prob_skip_false = 1;
+ if (prob_skip_false <= 1)
+ prob_skip_false = 1;
- if (prob_skip_false > 255)
- prob_skip_false = 255;
- }
- else
- prob_skip_false = 128;
+ if (prob_skip_false > 255)
+ prob_skip_false = 255;
+ } else
+ prob_skip_false = 128;
- cpi->prob_skip_false = prob_skip_false;
+ cpi->prob_skip_false = prob_skip_false;
#endif
}
// This function updates the reference frame prediction stats
-static void update_refpred_stats( VP8_COMP *cpi )
-{
- VP8_COMMON *const cm = & cpi->common;
- int i;
- int tot_count;
- vp8_prob new_pred_probs[PREDICTION_PROBS];
- int old_cost, new_cost;
-
- // Set the prediction probability structures to defaults
- if ( cm->frame_type == KEY_FRAME )
- {
- // Set the prediction probabilities to defaults
- cm->ref_pred_probs[0] = 120;
- cm->ref_pred_probs[1] = 80;
- cm->ref_pred_probs[2] = 40;
-
- vpx_memset(cpi->ref_pred_probs_update, 0,
- sizeof(cpi->ref_pred_probs_update) );
- }
- else
- {
- // From the prediction counts set the probabilities for each context
- for ( i = 0; i < PREDICTION_PROBS; i++ )
- {
- tot_count = cpi->ref_pred_count[i][0] + cpi->ref_pred_count[i][1];
- if ( tot_count )
- {
- new_pred_probs[i] =
- ( cpi->ref_pred_count[i][0] * 255 + (tot_count >> 1)) / tot_count;
-
- // Clamp to minimum allowed value
- new_pred_probs[i] += !new_pred_probs[i];
- }
- else
- new_pred_probs[i] = 128;
-
- // Decide whether or not to update the reference frame probs.
- // Returned costs are in 1/256 bit units.
- old_cost =
- (cpi->ref_pred_count[i][0] * vp8_cost_zero(cm->ref_pred_probs[i])) +
- (cpi->ref_pred_count[i][1] * vp8_cost_one(cm->ref_pred_probs[i]));
-
- new_cost =
- (cpi->ref_pred_count[i][0] * vp8_cost_zero(new_pred_probs[i])) +
- (cpi->ref_pred_count[i][1] * vp8_cost_one(new_pred_probs[i]));
-
- // Cost saving must be >= 8 bits (2048 in these units)
- if ( (old_cost - new_cost) >= 2048 )
- {
- cpi->ref_pred_probs_update[i] = 1;
- cm->ref_pred_probs[i] = new_pred_probs[i];
- }
- else
- cpi->ref_pred_probs_update[i] = 0;
+static void update_refpred_stats(VP8_COMP *cpi) {
+ VP8_COMMON *const cm = & cpi->common;
+ int i;
+ int tot_count;
+ vp8_prob new_pred_probs[PREDICTION_PROBS];
+ int old_cost, new_cost;
+
+ // Set the prediction probability structures to defaults
+ if (cm->frame_type == KEY_FRAME) {
+ // Set the prediction probabilities to defaults
+ cm->ref_pred_probs[0] = 120;
+ cm->ref_pred_probs[1] = 80;
+ cm->ref_pred_probs[2] = 40;
+
+ vpx_memset(cpi->ref_pred_probs_update, 0,
+ sizeof(cpi->ref_pred_probs_update));
+ } else {
+ // From the prediction counts set the probabilities for each context
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ tot_count = cpi->ref_pred_count[i][0] + cpi->ref_pred_count[i][1];
+ if (tot_count) {
+ new_pred_probs[i] =
+ (cpi->ref_pred_count[i][0] * 255 + (tot_count >> 1)) / tot_count;
+
+ // Clamp to minimum allowed value
+ new_pred_probs[i] += !new_pred_probs[i];
+ } else
+ new_pred_probs[i] = 128;
+
+ // Decide whether or not to update the reference frame probs.
+ // Returned costs are in 1/256 bit units.
+ old_cost =
+ (cpi->ref_pred_count[i][0] * vp8_cost_zero(cm->ref_pred_probs[i])) +
+ (cpi->ref_pred_count[i][1] * vp8_cost_one(cm->ref_pred_probs[i]));
+
+ new_cost =
+ (cpi->ref_pred_count[i][0] * vp8_cost_zero(new_pred_probs[i])) +
+ (cpi->ref_pred_count[i][1] * vp8_cost_one(new_pred_probs[i]));
+
+ // Cost saving must be >= 8 bits (2048 in these units)
+ if ((old_cost - new_cost) >= 2048) {
+ cpi->ref_pred_probs_update[i] = 1;
+ cm->ref_pred_probs[i] = new_pred_probs[i];
+ } else
+ cpi->ref_pred_probs_update[i] = 0;
- }
}
+ }
}
-static void write_ymode(vp8_writer *bc, int m, const vp8_prob *p)
-{
- vp8_write_token(bc, vp8_ymode_tree, p, vp8_ymode_encodings + m);
+static void write_ymode(vp8_writer *bc, int m, const vp8_prob *p) {
+ vp8_write_token(bc, vp8_ymode_tree, p, vp8_ymode_encodings + m);
}
-static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p)
-{
- vp8_write_token(bc, vp8_kf_ymode_tree, p, vp8_kf_ymode_encodings + m);
+static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p) {
+ vp8_write_token(bc, vp8_kf_ymode_tree, p, vp8_kf_ymode_encodings + m);
}
-static void write_i8x8_mode(vp8_writer *bc, int m, const vp8_prob *p)
-{
- vp8_write_token(bc,vp8_i8x8_mode_tree, p, vp8_i8x8_mode_encodings + m);
+static void write_i8x8_mode(vp8_writer *bc, int m, const vp8_prob *p) {
+ vp8_write_token(bc, vp8_i8x8_mode_tree, p, vp8_i8x8_mode_encodings + m);
}
-static void write_uv_mode(vp8_writer *bc, int m, const vp8_prob *p)
-{
- vp8_write_token(bc, vp8_uv_mode_tree, p, vp8_uv_mode_encodings + m);
+static void write_uv_mode(vp8_writer *bc, int m, const vp8_prob *p) {
+ vp8_write_token(bc, vp8_uv_mode_tree, p, vp8_uv_mode_encodings + m);
}
-static void write_bmode(vp8_writer *bc, int m, const vp8_prob *p)
-{
- vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m);
+static void write_bmode(vp8_writer *bc, int m, const vp8_prob *p) {
+ vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m);
}
-static void write_split(vp8_writer *bc, int x, const vp8_prob *p)
-{
- vp8_write_token(
- bc, vp8_mbsplit_tree, p, vp8_mbsplit_encodings + x
- );
+static void write_split(vp8_writer *bc, int x, const vp8_prob *p) {
+ vp8_write_token(
+ bc, vp8_mbsplit_tree, p, vp8_mbsplit_encodings + x
+ );
}
static int prob_update_savings(const unsigned int *ct,
const vp8_prob oldp, const vp8_prob newp,
- const vp8_prob upd)
-{
- const int old_b = vp8_cost_branch256(ct, oldp);
- const int new_b = vp8_cost_branch256(ct, newp);
- const int update_b = 2048 + vp8_cost_upd256;
- return (old_b - new_b - update_b);
+ const vp8_prob upd) {
+ const int old_b = vp8_cost_branch256(ct, oldp);
+ const int new_b = vp8_cost_branch256(ct, newp);
+ const int update_b = 2048 + vp8_cost_upd256;
+ return (old_b - new_b - update_b);
}
#if CONFIG_NEWUPDATE
static int prob_diff_update_savings(const unsigned int *ct,
- const vp8_prob oldp, const vp8_prob newp,
- const vp8_prob upd)
-{
- const int old_b = vp8_cost_branch256(ct, oldp);
- const int new_b = vp8_cost_branch256(ct, newp);
- const int update_b = (newp == oldp ? 0 :
- prob_diff_update_cost(newp, oldp) + vp8_cost_upd256);
- return (old_b - new_b - update_b);
+ const vp8_prob oldp, const vp8_prob newp,
+ const vp8_prob upd) {
+ const int old_b = vp8_cost_branch256(ct, oldp);
+ const int new_b = vp8_cost_branch256(ct, newp);
+ const int update_b = (newp == oldp ? 0 :
+ prob_diff_update_cost(newp, oldp) + vp8_cost_upd256);
+ return (old_b - new_b - update_b);
}
static int prob_diff_update_savings_search(const unsigned int *ct,
- const vp8_prob oldp, vp8_prob *bestp,
- const vp8_prob upd)
-{
- const int old_b = vp8_cost_branch256(ct, oldp);
- int new_b, update_b, savings, bestsavings, step;
- vp8_prob newp, bestnewp;
-
- bestsavings = 0;
- bestnewp = oldp;
-
- step = (*bestp > oldp ? -1 : 1);
- for (newp = *bestp; newp != oldp; newp+=step)
- {
- new_b = vp8_cost_branch256(ct, newp);
- update_b = prob_diff_update_cost(newp, oldp) + vp8_cost_upd256;
- savings = old_b - new_b - update_b;
- if (savings > bestsavings)
- {
- bestsavings = savings;
- bestnewp = newp;
- }
+ const vp8_prob oldp, vp8_prob *bestp,
+ const vp8_prob upd) {
+ const int old_b = vp8_cost_branch256(ct, oldp);
+ int new_b, update_b, savings, bestsavings, step;
+ vp8_prob newp, bestnewp;
+
+ bestsavings = 0;
+ bestnewp = oldp;
+
+ step = (*bestp > oldp ? -1 : 1);
+ for (newp = *bestp; newp != oldp; newp += step) {
+ new_b = vp8_cost_branch256(ct, newp);
+ update_b = prob_diff_update_cost(newp, oldp) + vp8_cost_upd256;
+ savings = old_b - new_b - update_b;
+ if (savings > bestsavings) {
+ bestsavings = savings;
+ bestnewp = newp;
}
- *bestp = bestnewp;
- return bestsavings;
+ }
+ *bestp = bestnewp;
+ return bestsavings;
}
#endif
-static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
-{
- const TOKENEXTRA *const stop = p + xcount;
- unsigned int split;
- unsigned int shift;
- int count = w->count;
- unsigned int range = w->range;
- unsigned int lowvalue = w->lowvalue;
+static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount) {
+ const TOKENEXTRA *const stop = p + xcount;
+ unsigned int split;
+ unsigned int shift;
+ int count = w->count;
+ unsigned int range = w->range;
+ unsigned int lowvalue = w->lowvalue;
- while (p < stop)
- {
- const int t = p->Token;
- vp8_token *const a = vp8_coef_encodings + t;
- const vp8_extra_bit_struct *const b = vp8_extra_bits + t;
- int i = 0;
- const unsigned char *pp = p->context_tree;
- int v = a->value;
- int n = a->Len;
-
- /* skip one or two nodes */
- if (p->skip_eob_node)
- {
- n-=p->skip_eob_node;
- i = 2*p->skip_eob_node;
- }
+ while (p < stop) {
+ const int t = p->Token;
+ vp8_token *const a = vp8_coef_encodings + t;
+ const vp8_extra_bit_struct *const b = vp8_extra_bits + t;
+ int i = 0;
+ const unsigned char *pp = p->context_tree;
+ int v = a->value;
+ int n = a->Len;
+
+ /* skip one or two nodes */
+ if (p->skip_eob_node) {
+ n -= p->skip_eob_node;
+ i = 2 * p->skip_eob_node;
+ }
- do
- {
- const int bb = (v >> --n) & 1;
- split = 1 + (((range - 1) * pp[i>>1]) >> 8);
- i = vp8_coef_tree[i+bb];
+ do {
+ const int bb = (v >> --n) & 1;
+ split = 1 + (((range - 1) * pp[i >> 1]) >> 8);
+ i = vp8_coef_tree[i + bb];
- if (bb)
- {
- lowvalue += split;
- range = range - split;
- }
- else
- {
- range = split;
- }
+ if (bb) {
+ lowvalue += split;
+ range = range - split;
+ } else {
+ range = split;
+ }
- shift = vp8_norm[range];
- range <<= shift;
- count += shift;
+ shift = vp8_norm[range];
+ range <<= shift;
+ count += shift;
- if (count >= 0)
- {
- int offset = shift - count;
+ if (count >= 0) {
+ int offset = shift - count;
- if ((lowvalue << (offset - 1)) & 0x80000000)
- {
- int x = w->pos - 1;
+ if ((lowvalue << (offset - 1)) & 0x80000000) {
+ int x = w->pos - 1;
- while (x >= 0 && w->buffer[x] == 0xff)
- {
- w->buffer[x] = (unsigned char)0;
- x--;
- }
+ while (x >= 0 && w->buffer[x] == 0xff) {
+ w->buffer[x] = (unsigned char)0;
+ x--;
+ }
- w->buffer[x] += 1;
- }
+ w->buffer[x] += 1;
+ }
- w->buffer[w->pos++] = (lowvalue >> (24 - offset));
- lowvalue <<= offset;
- shift = count;
- lowvalue &= 0xffffff;
- count -= 8 ;
- }
+ w->buffer[w->pos++] = (lowvalue >> (24 - offset));
+ lowvalue <<= offset;
+ shift = count;
+ lowvalue &= 0xffffff;
+ count -= 8;
+ }
- lowvalue <<= shift;
- }
- while (n);
+ lowvalue <<= shift;
+ } while (n);
- if (b->base_val)
- {
- const int e = p->Extra, L = b->Len;
+ if (b->base_val) {
+ const int e = p->Extra, L = b->Len;
- if (L)
- {
- const unsigned char *pp = b->prob;
- int v = e >> 1;
- int n = L; /* number of bits in v, assumed nonzero */
- int i = 0;
+ if (L) {
+ const unsigned char *pp = b->prob;
+ int v = e >> 1;
+ int n = L; /* number of bits in v, assumed nonzero */
+ int i = 0;
- do
- {
- const int bb = (v >> --n) & 1;
- split = 1 + (((range - 1) * pp[i>>1]) >> 8);
- i = b->tree[i+bb];
+ do {
+ const int bb = (v >> --n) & 1;
+ split = 1 + (((range - 1) * pp[i >> 1]) >> 8);
+ i = b->tree[i + bb];
- if (bb)
- {
- lowvalue += split;
- range = range - split;
- }
- else
- {
- range = split;
- }
+ if (bb) {
+ lowvalue += split;
+ range = range - split;
+ } else {
+ range = split;
+ }
- shift = vp8_norm[range];
- range <<= shift;
- count += shift;
+ shift = vp8_norm[range];
+ range <<= shift;
+ count += shift;
- if (count >= 0)
- {
- int offset = shift - count;
-
- if ((lowvalue << (offset - 1)) & 0x80000000)
- {
- int x = w->pos - 1;
-
- while (x >= 0 && w->buffer[x] == 0xff)
- {
- w->buffer[x] = (unsigned char)0;
- x--;
- }
-
- w->buffer[x] += 1;
- }
-
- w->buffer[w->pos++] = (lowvalue >> (24 - offset));
- lowvalue <<= offset;
- shift = count;
- lowvalue &= 0xffffff;
- count -= 8 ;
- }
+ if (count >= 0) {
+ int offset = shift - count;
- lowvalue <<= shift;
- }
- while (n);
+ if ((lowvalue << (offset - 1)) & 0x80000000) {
+ int x = w->pos - 1;
+
+ while (x >= 0 && w->buffer[x] == 0xff) {
+ w->buffer[x] = (unsigned char)0;
+ x--;
+ }
+
+ w->buffer[x] += 1;
}
+ w->buffer[w->pos++] = (lowvalue >> (24 - offset));
+ lowvalue <<= offset;
+ shift = count;
+ lowvalue &= 0xffffff;
+ count -= 8;
+ }
- {
+ lowvalue <<= shift;
+ } while (n);
+ }
- split = (range + 1) >> 1;
- if (e & 1)
- {
- lowvalue += split;
- range = range - split;
- }
- else
- {
- range = split;
- }
+ {
- range <<= 1;
+ split = (range + 1) >> 1;
- if ((lowvalue & 0x80000000))
- {
- int x = w->pos - 1;
+ if (e & 1) {
+ lowvalue += split;
+ range = range - split;
+ } else {
+ range = split;
+ }
- while (x >= 0 && w->buffer[x] == 0xff)
- {
- w->buffer[x] = (unsigned char)0;
- x--;
- }
+ range <<= 1;
- w->buffer[x] += 1;
+ if ((lowvalue & 0x80000000)) {
+ int x = w->pos - 1;
- }
+ while (x >= 0 && w->buffer[x] == 0xff) {
+ w->buffer[x] = (unsigned char)0;
+ x--;
+ }
- lowvalue <<= 1;
+ w->buffer[x] += 1;
- if (!++count)
- {
- count = -8;
- w->buffer[w->pos++] = (lowvalue >> 24);
- lowvalue &= 0xffffff;
- }
- }
+ }
+ lowvalue <<= 1;
+
+ if (!++count) {
+ count = -8;
+ w->buffer[w->pos++] = (lowvalue >> 24);
+ lowvalue &= 0xffffff;
}
+ }
- ++p;
}
- w->count = count;
- w->lowvalue = lowvalue;
- w->range = range;
+ ++p;
+ }
+
+ w->count = count;
+ w->lowvalue = lowvalue;
+ w->range = range;
}
-static void write_partition_size(unsigned char *cx_data, int size)
-{
- signed char csize;
+static void write_partition_size(unsigned char *cx_data, int size) {
+ signed char csize;
- csize = size & 0xff;
- *cx_data = csize;
- csize = (size >> 8) & 0xff;
- *(cx_data + 1) = csize;
- csize = (size >> 16) & 0xff;
- *(cx_data + 2) = csize;
+ csize = size & 0xff;
+ *cx_data = csize;
+ csize = (size >> 8) & 0xff;
+ *(cx_data + 1) = csize;
+ csize = (size >> 16) & 0xff;
+ *(cx_data + 2) = csize;
}
static void write_mv_ref
(
- vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p
-)
-{
+ vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p
+) {
#if CONFIG_DEBUG
- assert(NEARESTMV <= m && m <= SPLITMV);
+ assert(NEARESTMV <= m && m <= SPLITMV);
#endif
- vp8_write_token(w, vp8_mv_ref_tree, p,
- vp8_mv_ref_encoding_array - NEARESTMV + m);
+ vp8_write_token(w, vp8_mv_ref_tree, p,
+ vp8_mv_ref_encoding_array - NEARESTMV + m);
}
static void write_sub_mv_ref
(
- vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p
-)
-{
+ vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p
+) {
#if CONFIG_DEBUG
- assert(LEFT4X4 <= m && m <= NEW4X4);
+ assert(LEFT4X4 <= m && m <= NEW4X4);
#endif
- vp8_write_token(w, vp8_sub_mv_ref_tree, p,
- vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
+ vp8_write_token(w, vp8_sub_mv_ref_tree, p,
+ vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
}
static void write_mv
(
- vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT *mvc
-)
-{
- MV e;
- e.row = mv->row - ref->as_mv.row;
- e.col = mv->col - ref->as_mv.col;
-
- vp8_encode_motion_vector(w, &e, mvc);
+ vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT *mvc
+) {
+ MV e;
+ e.row = mv->row - ref->as_mv.row;
+ e.col = mv->col - ref->as_mv.col;
+
+ vp8_encode_motion_vector(w, &e, mvc);
}
#if CONFIG_HIGH_PRECISION_MV
static void write_mv_hp
(
- vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT_HP *mvc
-)
-{
- MV e;
- e.row = mv->row - ref->as_mv.row;
- e.col = mv->col - ref->as_mv.col;
-
- vp8_encode_motion_vector_hp(w, &e, mvc);
+ vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT_HP *mvc
+) {
+ MV e;
+ e.row = mv->row - ref->as_mv.row;
+ e.col = mv->col - ref->as_mv.col;
+
+ vp8_encode_motion_vector_hp(w, &e, mvc);
}
#endif
// This function writes the current macro block's segnment id to the bitstream
// It should only be called if a segment map update is indicated.
static void write_mb_segid(vp8_writer *w,
- const MB_MODE_INFO *mi, const MACROBLOCKD *x)
-{
- // Encode the MB segment id.
- if (x->segmentation_enabled && x->update_mb_segmentation_map)
- {
- switch (mi->segment_id)
- {
- case 0:
- vp8_write(w, 0, x->mb_segment_tree_probs[0]);
- vp8_write(w, 0, x->mb_segment_tree_probs[1]);
- break;
- case 1:
- vp8_write(w, 0, x->mb_segment_tree_probs[0]);
- vp8_write(w, 1, x->mb_segment_tree_probs[1]);
- break;
- case 2:
- vp8_write(w, 1, x->mb_segment_tree_probs[0]);
- vp8_write(w, 0, x->mb_segment_tree_probs[2]);
- break;
- case 3:
- vp8_write(w, 1, x->mb_segment_tree_probs[0]);
- vp8_write(w, 1, x->mb_segment_tree_probs[2]);
- break;
-
- // TRAP.. This should not happen
- default:
- vp8_write(w, 0, x->mb_segment_tree_probs[0]);
- vp8_write(w, 0, x->mb_segment_tree_probs[1]);
- break;
- }
+ const MB_MODE_INFO *mi, const MACROBLOCKD *x) {
+ // Encode the MB segment id.
+ if (x->segmentation_enabled && x->update_mb_segmentation_map) {
+ switch (mi->segment_id) {
+ case 0:
+ vp8_write(w, 0, x->mb_segment_tree_probs[0]);
+ vp8_write(w, 0, x->mb_segment_tree_probs[1]);
+ break;
+ case 1:
+ vp8_write(w, 0, x->mb_segment_tree_probs[0]);
+ vp8_write(w, 1, x->mb_segment_tree_probs[1]);
+ break;
+ case 2:
+ vp8_write(w, 1, x->mb_segment_tree_probs[0]);
+ vp8_write(w, 0, x->mb_segment_tree_probs[2]);
+ break;
+ case 3:
+ vp8_write(w, 1, x->mb_segment_tree_probs[0]);
+ vp8_write(w, 1, x->mb_segment_tree_probs[2]);
+ break;
+
+ // TRAP.. This should not happen
+ default:
+ vp8_write(w, 0, x->mb_segment_tree_probs[0]);
+ vp8_write(w, 0, x->mb_segment_tree_probs[1]);
+ break;
}
+ }
}
// This function encodes the reference frame
-static void encode_ref_frame( vp8_writer *const w,
- VP8_COMMON *const cm,
- MACROBLOCKD *xd,
- int segment_id,
- MV_REFERENCE_FRAME rf )
-{
- int seg_ref_active;
- int seg_ref_count = 0;
- seg_ref_active = segfeature_active( xd,
- segment_id,
- SEG_LVL_REF_FRAME );
-
- if ( seg_ref_active )
- {
- seg_ref_count = check_segref( xd, segment_id, INTRA_FRAME ) +
- check_segref( xd, segment_id, LAST_FRAME ) +
- check_segref( xd, segment_id, GOLDEN_FRAME ) +
- check_segref( xd, segment_id, ALTREF_FRAME );
- }
-
- // If segment level coding of this signal is disabled...
- // or the segment allows multiple reference frame options
- if ( !seg_ref_active || (seg_ref_count > 1) )
- {
- // Values used in prediction model coding
- unsigned char prediction_flag;
- vp8_prob pred_prob;
- MV_REFERENCE_FRAME pred_rf;
-
- // Get the context probability the prediction flag
- pred_prob = get_pred_prob( cm, xd, PRED_REF );
-
- // Get the predicted value.
- pred_rf = get_pred_ref( cm, xd );
-
- // Did the chosen reference frame match its predicted value.
- prediction_flag =
- ( xd->mode_info_context->mbmi.ref_frame == pred_rf );
-
- set_pred_flag( xd, PRED_REF, prediction_flag );
- vp8_write( w, prediction_flag, pred_prob );
-
- // If not predicted correctly then code value explicitly
- if ( !prediction_flag )
- {
- vp8_prob mod_refprobs[PREDICTION_PROBS];
-
- vpx_memcpy( mod_refprobs,
- cm->mod_refprobs[pred_rf], sizeof(mod_refprobs) );
-
- // If segment coding enabled blank out options that cant occur by
- // setting the branch probability to 0.
- if ( seg_ref_active )
- {
- mod_refprobs[INTRA_FRAME] *=
- check_segref( xd, segment_id, INTRA_FRAME );
- mod_refprobs[LAST_FRAME] *=
- check_segref( xd, segment_id, LAST_FRAME );
- mod_refprobs[GOLDEN_FRAME] *=
- ( check_segref( xd, segment_id, GOLDEN_FRAME ) *
- check_segref( xd, segment_id, ALTREF_FRAME ) );
- }
-
- if ( mod_refprobs[0] )
- {
- vp8_write(w, (rf != INTRA_FRAME), mod_refprobs[0] );
- }
-
- // Inter coded
- if (rf != INTRA_FRAME)
- {
- if ( mod_refprobs[1] )
- {
- vp8_write(w, (rf != LAST_FRAME), mod_refprobs[1] );
- }
+static void encode_ref_frame(vp8_writer *const w,
+ VP8_COMMON *const cm,
+ MACROBLOCKD *xd,
+ int segment_id,
+ MV_REFERENCE_FRAME rf) {
+ int seg_ref_active;
+ int seg_ref_count = 0;
+ seg_ref_active = segfeature_active(xd,
+ segment_id,
+ SEG_LVL_REF_FRAME);
+
+ if (seg_ref_active) {
+ seg_ref_count = check_segref(xd, segment_id, INTRA_FRAME) +
+ check_segref(xd, segment_id, LAST_FRAME) +
+ check_segref(xd, segment_id, GOLDEN_FRAME) +
+ check_segref(xd, segment_id, ALTREF_FRAME);
+ }
+
+ // If segment level coding of this signal is disabled...
+ // or the segment allows multiple reference frame options
+ if (!seg_ref_active || (seg_ref_count > 1)) {
+ // Values used in prediction model coding
+ unsigned char prediction_flag;
+ vp8_prob pred_prob;
+ MV_REFERENCE_FRAME pred_rf;
+
+ // Get the context probability the prediction flag
+ pred_prob = get_pred_prob(cm, xd, PRED_REF);
+
+ // Get the predicted value.
+ pred_rf = get_pred_ref(cm, xd);
+
+ // Did the chosen reference frame match its predicted value.
+ prediction_flag =
+ (xd->mode_info_context->mbmi.ref_frame == pred_rf);
+
+ set_pred_flag(xd, PRED_REF, prediction_flag);
+ vp8_write(w, prediction_flag, pred_prob);
+
+ // If not predicted correctly then code value explicitly
+ if (!prediction_flag) {
+ vp8_prob mod_refprobs[PREDICTION_PROBS];
+
+ vpx_memcpy(mod_refprobs,
+ cm->mod_refprobs[pred_rf], sizeof(mod_refprobs));
+
+ // If segment coding enabled blank out options that cant occur by
+ // setting the branch probability to 0.
+ if (seg_ref_active) {
+ mod_refprobs[INTRA_FRAME] *=
+ check_segref(xd, segment_id, INTRA_FRAME);
+ mod_refprobs[LAST_FRAME] *=
+ check_segref(xd, segment_id, LAST_FRAME);
+ mod_refprobs[GOLDEN_FRAME] *=
+ (check_segref(xd, segment_id, GOLDEN_FRAME) *
+ check_segref(xd, segment_id, ALTREF_FRAME));
+ }
+
+ if (mod_refprobs[0]) {
+ vp8_write(w, (rf != INTRA_FRAME), mod_refprobs[0]);
+ }
+
+ // Inter coded
+ if (rf != INTRA_FRAME) {
+ if (mod_refprobs[1]) {
+ vp8_write(w, (rf != LAST_FRAME), mod_refprobs[1]);
+ }
- if (rf != LAST_FRAME)
- {
- if ( mod_refprobs[2] )
- {
- vp8_write(w, (rf != GOLDEN_FRAME), mod_refprobs[2] );
- }
- }
- }
+ if (rf != LAST_FRAME) {
+ if (mod_refprobs[2]) {
+ vp8_write(w, (rf != GOLDEN_FRAME), mod_refprobs[2]);
+ }
}
+ }
}
+ }
- // if using the prediction mdoel we have nothing further to do because
- // the reference frame is fully coded by the segment
+ // if using the prediction mdoel we have nothing further to do because
+ // the reference frame is fully coded by the segment
}
// Update the probabilities used to encode reference frame data
-static void update_ref_probs( VP8_COMP *const cpi )
-{
- VP8_COMMON *const cm = & cpi->common;
+static void update_ref_probs(VP8_COMP *const cpi) {
+ VP8_COMMON *const cm = & cpi->common;
- const int *const rfct = cpi->count_mb_ref_frame_usage;
- const int rf_intra = rfct[INTRA_FRAME];
- const int rf_inter = rfct[LAST_FRAME] +
- rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
+ const int *const rfct = cpi->count_mb_ref_frame_usage;
+ const int rf_intra = rfct[INTRA_FRAME];
+ const int rf_inter = rfct[LAST_FRAME] +
+ rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
- cm->prob_intra_coded = (rf_intra + rf_inter)
- ? rf_intra * 255 / (rf_intra + rf_inter) : 1;
+ cm->prob_intra_coded = (rf_intra + rf_inter)
+ ? rf_intra * 255 / (rf_intra + rf_inter) : 1;
- if (!cm->prob_intra_coded)
- cm->prob_intra_coded = 1;
+ if (!cm->prob_intra_coded)
+ cm->prob_intra_coded = 1;
- cm->prob_last_coded = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
+ cm->prob_last_coded = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
- if (!cm->prob_last_coded)
- cm->prob_last_coded = 1;
+ if (!cm->prob_last_coded)
+ cm->prob_last_coded = 1;
- cm->prob_gf_coded = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
- ? (rfct[GOLDEN_FRAME] * 255) /
- (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
+ cm->prob_gf_coded = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
+ ? (rfct[GOLDEN_FRAME] * 255) /
+ (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
- if (!cm->prob_gf_coded)
- cm->prob_gf_coded = 1;
+ if (!cm->prob_gf_coded)
+ cm->prob_gf_coded = 1;
- // Compute a modified set of probabilities to use when prediction of the
- // reference frame fails
- compute_mod_refprobs( cm );
+ // Compute a modified set of probabilities to use when prediction of the
+ // reference frame fails
+ compute_mod_refprobs(cm);
}
-static void pack_inter_mode_mvs(VP8_COMP *const cpi)
-{
- int i;
- VP8_COMMON *const pc = & cpi->common;
- vp8_writer *const w = & cpi->bc;
- const MV_CONTEXT *mvc = pc->fc.mvc;
+static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
+ int i;
+ VP8_COMMON *const pc = & cpi->common;
+ vp8_writer *const w = & cpi->bc;
+ const MV_CONTEXT *mvc = pc->fc.mvc;
#if CONFIG_HIGH_PRECISION_MV
- const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
+ const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
#endif
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- MODE_INFO *m;
- MODE_INFO *prev_m;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ MODE_INFO *m;
+ MODE_INFO *prev_m;
- const int mis = pc->mode_info_stride;
- int mb_row, mb_col;
- int row, col;
+ const int mis = pc->mode_info_stride;
+ int mb_row, mb_col;
+ int row, col;
- // Values used in prediction model coding
- vp8_prob pred_prob;
- unsigned char prediction_flag;
+ // Values used in prediction model coding
+ vp8_prob pred_prob;
+ unsigned char prediction_flag;
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
- cpi->mb.partition_info = cpi->mb.pi;
+ cpi->mb.partition_info = cpi->mb.pi;
- // Update the probabilities used to encode reference frame data
- update_ref_probs( cpi );
+ // Update the probabilities used to encode reference frame data
+ update_ref_probs(cpi);
#ifdef ENTROPY_STATS
- active_section = 1;
+ active_section = 1;
#endif
- if (pc->mb_no_coeff_skip)
- {
+ if (pc->mb_no_coeff_skip) {
#if CONFIG_NEWENTROPY
- int k;
+ int k;
- update_skip_probs( cpi );
- for (k=0;k<MBSKIP_CONTEXTS;++k)
- vp8_write_literal(w, pc->mbskip_pred_probs[k], 8);
+ update_skip_probs(cpi);
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ vp8_write_literal(w, pc->mbskip_pred_probs[k], 8);
#else
- update_skip_probs( cpi );
- vp8_write_literal(w, cpi->prob_skip_false, 8);
+ update_skip_probs(cpi);
+ vp8_write_literal(w, cpi->prob_skip_false, 8);
#endif
- }
+ }
#if CONFIG_PRED_FILTER
- // Write the prediction filter mode used for this frame
- vp8_write_literal(w, pc->pred_filter_mode, 2);
-
- // Write prediction filter on/off probability if signaling at MB level
- if (pc->pred_filter_mode == 2)
- vp8_write_literal(w, pc->prob_pred_filter_off, 8);
-
- //printf("pred_filter_mode:%d prob_pred_filter_off:%d\n",
- // pc->pred_filter_mode, pc->prob_pred_filter_off);
-#endif
-
- vp8_write_literal(w, pc->prob_intra_coded, 8);
- vp8_write_literal(w, pc->prob_last_coded, 8);
- vp8_write_literal(w, pc->prob_gf_coded, 8);
-
- if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
- {
- vp8_write(w, 1, 128);
- vp8_write(w, 1, 128);
- for (i = 0; i < COMP_PRED_CONTEXTS; i++)
- {
- if (cpi->single_pred_count[i] + cpi->comp_pred_count[i])
- {
- pc->prob_comppred[i] = cpi->single_pred_count[i] * 255 /
- (cpi->single_pred_count[i] + cpi->comp_pred_count[i]);
- if (pc->prob_comppred[i] < 1)
- pc->prob_comppred[i] = 1;
- }
- else
- {
- pc->prob_comppred[i] = 128;
- }
- vp8_write_literal(w, pc->prob_comppred[i], 8);
- }
- }
- else if (cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY)
- {
- vp8_write(w, 0, 128);
- }
- else /* compound prediction only */
- {
- vp8_write(w, 1, 128);
- vp8_write(w, 0, 128);
+ // Write the prediction filter mode used for this frame
+ vp8_write_literal(w, pc->pred_filter_mode, 2);
+
+ // Write prediction filter on/off probability if signaling at MB level
+ if (pc->pred_filter_mode == 2)
+ vp8_write_literal(w, pc->prob_pred_filter_off, 8);
+
+ // printf("pred_filter_mode:%d prob_pred_filter_off:%d\n",
+ // pc->pred_filter_mode, pc->prob_pred_filter_off);
+#endif
+
+ vp8_write_literal(w, pc->prob_intra_coded, 8);
+ vp8_write_literal(w, pc->prob_last_coded, 8);
+ vp8_write_literal(w, pc->prob_gf_coded, 8);
+
+ if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
+ vp8_write(w, 1, 128);
+ vp8_write(w, 1, 128);
+ for (i = 0; i < COMP_PRED_CONTEXTS; i++) {
+ if (cpi->single_pred_count[i] + cpi->comp_pred_count[i]) {
+ pc->prob_comppred[i] = cpi->single_pred_count[i] * 255 /
+ (cpi->single_pred_count[i] + cpi->comp_pred_count[i]);
+ if (pc->prob_comppred[i] < 1)
+ pc->prob_comppred[i] = 1;
+ } else {
+ pc->prob_comppred[i] = 128;
+ }
+ vp8_write_literal(w, pc->prob_comppred[i], 8);
}
+ } else if (cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY) {
+ vp8_write(w, 0, 128);
+ } else { /* compound prediction only */
+ vp8_write(w, 1, 128);
+ vp8_write(w, 0, 128);
+ }
- update_mbintra_mode_probs(cpi);
+ update_mbintra_mode_probs(cpi);
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- vp8_write_mvprobs_hp(cpi);
- else
-#endif
- vp8_write_mvprobs(cpi);
-
- mb_row = 0;
- for (row=0; row < pc->mb_rows; row += 2)
- {
- m = pc->mi + row * mis;
- prev_m = pc->prev_mi + row * mis;
-
- mb_col = 0;
- for (col=0; col < pc->mb_cols; col += 2)
- {
- int i;
-
- // Process the 4 MBs in the order:
- // top-left, top-right, bottom-left, bottom-right
- for (i=0; i<4; i++)
- {
- MB_MODE_INFO *mi;
- MV_REFERENCE_FRAME rf;
- MB_PREDICTION_MODE mode;
- int segment_id;
-
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * mis + dx;
-
- if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols))
- {
- // MB lies outside frame, move on
- mb_row += dy;
- mb_col += dx;
- m += offset_extended;
- prev_m += offset_extended;
- cpi->mb.partition_info += offset_extended;
- continue;
- }
+ if (xd->allow_high_precision_mv)
+ vp8_write_mvprobs_hp(cpi);
+ else
+#endif
+ vp8_write_mvprobs(cpi);
+
+ mb_row = 0;
+ for (row = 0; row < pc->mb_rows; row += 2) {
+ m = pc->mi + row * mis;
+ prev_m = pc->prev_mi + row * mis;
+
+ mb_col = 0;
+ for (col = 0; col < pc->mb_cols; col += 2) {
+ int i;
+
+ // Process the 4 MBs in the order:
+ // top-left, top-right, bottom-left, bottom-right
+ for (i = 0; i < 4; i++) {
+ MB_MODE_INFO *mi;
+ MV_REFERENCE_FRAME rf;
+ MB_PREDICTION_MODE mode;
+ int segment_id;
+
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_extended = dy * mis + dx;
+
+ if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols)) {
+ // MB lies outside frame, move on
+ mb_row += dy;
+ mb_col += dx;
+ m += offset_extended;
+ prev_m += offset_extended;
+ cpi->mb.partition_info += offset_extended;
+ continue;
+ }
- mi = & m->mbmi;
- rf = mi->ref_frame;
- mode = mi->mode;
- segment_id = mi->segment_id;
+ mi = & m->mbmi;
+ rf = mi->ref_frame;
+ mode = mi->mode;
+ segment_id = mi->segment_id;
- // Distance of Mb to the various image edges.
- // These specified to 8th pel as they are always compared to MV
- // values that are in 1/8th pel units
- xd->mb_to_left_edge = -((mb_col * 16) << 3);
- xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
- xd->mb_to_top_edge = -((mb_row * 16)) << 3;
- xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
+ // Distance of Mb to the various image edges.
+ // These specified to 8th pel as they are always compared to MV
+ // values that are in 1/8th pel units
+ xd->mb_to_left_edge = -((mb_col * 16) << 3);
+ xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
+ xd->mb_to_top_edge = -((mb_row * 16)) << 3;
+ xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
- // Make sure the MacroBlockD mode info pointer is set correctly
- xd->mode_info_context = m;
- xd->prev_mode_info_context = prev_m;
+ // Make sure the MacroBlockD mode info pointer is set correctly
+ xd->mode_info_context = m;
+ xd->prev_mode_info_context = prev_m;
#ifdef ENTROPY_STATS
- active_section = 9;
+ active_section = 9;
#endif
- if (cpi->mb.e_mbd.update_mb_segmentation_map)
- {
- // Is temporal coding of the segment map enabled
- if (pc->temporal_update)
- {
- prediction_flag = get_pred_flag( xd, PRED_SEG_ID );
- pred_prob = get_pred_prob( pc, xd, PRED_SEG_ID);
+ if (cpi->mb.e_mbd.update_mb_segmentation_map) {
+ // Is temporal coding of the segment map enabled
+ if (pc->temporal_update) {
+ prediction_flag = get_pred_flag(xd, PRED_SEG_ID);
+ pred_prob = get_pred_prob(pc, xd, PRED_SEG_ID);
- // Code the segment id prediction flag for this mb
- vp8_write( w, prediction_flag, pred_prob );
+ // Code the segment id prediction flag for this mb
+ vp8_write(w, prediction_flag, pred_prob);
- // If the mb segment id wasn't predicted code explicitly
- if (!prediction_flag)
- write_mb_segid(w, mi, &cpi->mb.e_mbd);
- }
- else
- {
- // Normal unpredicted coding
- write_mb_segid(w, mi, &cpi->mb.e_mbd);
- }
- }
+ // If the mb segment id wasn't predicted code explicitly
+ if (!prediction_flag)
+ write_mb_segid(w, mi, &cpi->mb.e_mbd);
+ } else {
+ // Normal unpredicted coding
+ write_mb_segid(w, mi, &cpi->mb.e_mbd);
+ }
+ }
- if ( pc->mb_no_coeff_skip &&
- ( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
- ( get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0 ) ) )
- {
+ if (pc->mb_no_coeff_skip &&
+ (!segfeature_active(xd, segment_id, SEG_LVL_EOB) ||
+ (get_segdata(xd, segment_id, SEG_LVL_EOB) != 0))) {
#if CONFIG_NEWENTROPY
- vp8_encode_bool(w, mi->mb_skip_coeff,
- get_pred_prob(pc, xd, PRED_MBSKIP));
+ vp8_encode_bool(w, mi->mb_skip_coeff,
+ get_pred_prob(pc, xd, PRED_MBSKIP));
#else
- vp8_encode_bool(w, mi->mb_skip_coeff, cpi->prob_skip_false);
+ vp8_encode_bool(w, mi->mb_skip_coeff, cpi->prob_skip_false);
#endif
- }
+ }
- // Encode the reference frame.
- encode_ref_frame( w, pc, xd, segment_id, rf );
+ // Encode the reference frame.
+ encode_ref_frame(w, pc, xd, segment_id, rf);
- if (rf == INTRA_FRAME)
- {
+ if (rf == INTRA_FRAME) {
#ifdef ENTROPY_STATS
- active_section = 6;
+ active_section = 6;
#endif
- if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
- {
- write_ymode(w, mode, pc->fc.ymode_prob);
- }
+ if (!segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
+ write_ymode(w, mode, pc->fc.ymode_prob);
+ }
- if (mode == B_PRED)
- {
- int j = 0;
+ if (mode == B_PRED) {
+ int j = 0;
#if CONFIG_COMP_INTRA_PRED
- int uses_second =
- m->bmi[0].as_mode.second !=
- (B_PREDICTION_MODE) (B_DC_PRED - 1);
- vp8_write(w, uses_second, 128);
+ int uses_second =
+ m->bmi[0].as_mode.second !=
+ (B_PREDICTION_MODE)(B_DC_PRED - 1);
+ vp8_write(w, uses_second, 128);
#endif
- do {
+ do {
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE mode2 = m->bmi[j].as_mode.second;
+ B_PREDICTION_MODE mode2 = m->bmi[j].as_mode.second;
#endif
- write_bmode(w, m->bmi[j].as_mode.first,
- pc->fc.bmode_prob);
+ write_bmode(w, m->bmi[j].as_mode.first,
+ pc->fc.bmode_prob);
#if CONFIG_COMP_INTRA_PRED
- if (uses_second)
- {
- write_bmode(w, mode2, pc->fc.bmode_prob);
- }
-#endif
- } while (++j < 16);
- }
- if(mode == I8X8_PRED)
- {
- write_i8x8_mode(w, m->bmi[0].as_mode.first,
- pc->fc.i8x8_mode_prob);
- write_i8x8_mode(w, m->bmi[2].as_mode.first,
- pc->fc.i8x8_mode_prob);
- write_i8x8_mode(w, m->bmi[8].as_mode.first,
- pc->fc.i8x8_mode_prob);
- write_i8x8_mode(w, m->bmi[10].as_mode.first,
- pc->fc.i8x8_mode_prob);
- }
- else
- {
- write_uv_mode(w, mi->uv_mode,
- pc->fc.uv_mode_prob[mode]);
- }
- }
- else
- {
- int_mv best_mv, best_second_mv;
- int ct[4];
-
- vp8_prob mv_ref_p [VP8_MVREFS-1];
-
- {
- int_mv n1, n2;
-
- vp8_find_near_mvs(xd, m, prev_m, &n1, &n2, &best_mv, ct,
- rf, cpi->common.ref_frame_sign_bias);
- vp8_mv_ref_probs(&cpi->common, mv_ref_p, ct);
+ if (uses_second) {
+ write_bmode(w, mode2, pc->fc.bmode_prob);
+ }
+#endif
+ } while (++j < 16);
+ }
+ if (mode == I8X8_PRED) {
+ write_i8x8_mode(w, m->bmi[0].as_mode.first,
+ pc->fc.i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[2].as_mode.first,
+ pc->fc.i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[8].as_mode.first,
+ pc->fc.i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[10].as_mode.first,
+ pc->fc.i8x8_mode_prob);
+ } else {
+ write_uv_mode(w, mi->uv_mode,
+ pc->fc.uv_mode_prob[mode]);
+ }
+ } else {
+ int_mv best_mv, best_second_mv;
+ int ct[4];
+
+ vp8_prob mv_ref_p [VP8_MVREFS - 1];
+
+ {
+ int_mv n1, n2;
+
+ vp8_find_near_mvs(xd, m, prev_m, &n1, &n2, &best_mv, ct,
+ rf, cpi->common.ref_frame_sign_bias);
+ vp8_mv_ref_probs(&cpi->common, mv_ref_p, ct);
#ifdef ENTROPY_STATS
- accum_mv_refs(mode, ct);
+ accum_mv_refs(mode, ct);
#endif
- }
+ }
#ifdef ENTROPY_STATS
- active_section = 3;
+ active_section = 3;
#endif
- // Is the segment coding of mode enabled
- if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
- {
- write_mv_ref(w, mode, mv_ref_p);
- vp8_accum_mv_refs(&cpi->common, mode, ct);
- }
+ // Is the segment coding of mode enabled
+ if (!segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
+ write_mv_ref(w, mode, mv_ref_p);
+ vp8_accum_mv_refs(&cpi->common, mode, ct);
+ }
#if CONFIG_PRED_FILTER
- // Is the prediction filter enabled
- if (mode >= NEARESTMV && mode < SPLITMV)
- {
- if (cpi->common.pred_filter_mode == 2 )
- vp8_write(w, mi->pred_filter_enabled,
- pc->prob_pred_filter_off);
- else
- assert (mi->pred_filter_enabled ==
- cpi->common.pred_filter_mode);
- }
-#endif
- if (mi->second_ref_frame &&
- (mode == NEWMV || mode == SPLITMV))
- {
- int_mv n1, n2;
-
- vp8_find_near_mvs(xd, m,
- prev_m,
- &n1, &n2, &best_second_mv, ct,
- mi->second_ref_frame, cpi->common.ref_frame_sign_bias);
- }
-
- // does the feature use compound prediction or not
- // (if not specified at the frame/segment level)
- if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
- {
- vp8_write(w, mi->second_ref_frame != INTRA_FRAME,
- get_pred_prob( pc, xd, PRED_COMP ) );
- }
-
- {
- switch (mode) /* new, split require MVs */
- {
- case NEWMV:
+ // Is the prediction filter enabled
+ if (mode >= NEARESTMV && mode < SPLITMV) {
+ if (cpi->common.pred_filter_mode == 2)
+ vp8_write(w, mi->pred_filter_enabled,
+ pc->prob_pred_filter_off);
+ else
+ assert(mi->pred_filter_enabled ==
+ cpi->common.pred_filter_mode);
+ }
+#endif
+ if (mi->second_ref_frame &&
+ (mode == NEWMV || mode == SPLITMV)) {
+ int_mv n1, n2;
+
+ vp8_find_near_mvs(xd, m,
+ prev_m,
+ &n1, &n2, &best_second_mv, ct,
+ mi->second_ref_frame, cpi->common.ref_frame_sign_bias);
+ }
+
+ // does the feature use compound prediction or not
+ // (if not specified at the frame/segment level)
+ if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
+ vp8_write(w, mi->second_ref_frame != INTRA_FRAME,
+ get_pred_prob(pc, xd, PRED_COMP));
+ }
+
+ {
+ switch (mode) { /* new, split require MVs */
+ case NEWMV:
#ifdef ENTROPY_STATS
- active_section = 5;
+ active_section = 5;
#endif
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
- }
- else
-#endif
- {
- write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
- }
-
- if (mi->second_ref_frame)
- {
+ if (xd->allow_high_precision_mv) {
+ write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
+ } else
+#endif
+ {
+ write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
+ }
+
+ if (mi->second_ref_frame) {
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- write_mv_hp(w, &mi->second_mv.as_mv,
- &best_second_mv, mvc_hp);
- }
- else
-#endif
- {
- write_mv(w, &mi->second_mv.as_mv,
- &best_second_mv, mvc);
- }
- }
- break;
- case SPLITMV:
- {
- int j = 0;
+ if (xd->allow_high_precision_mv) {
+ write_mv_hp(w, &mi->second_mv.as_mv,
+ &best_second_mv, mvc_hp);
+ } else
+#endif
+ {
+ write_mv(w, &mi->second_mv.as_mv,
+ &best_second_mv, mvc);
+ }
+ }
+ break;
+ case SPLITMV: {
+ int j = 0;
#ifdef MODE_STATS
- ++count_mb_seg [mi->partitioning];
+ ++count_mb_seg [mi->partitioning];
#endif
- write_split(w, mi->partitioning, cpi->common.fc.mbsplit_prob);
+ write_split(w, mi->partitioning, cpi->common.fc.mbsplit_prob);
#if CONFIG_ADAPTIVE_ENTROPY
- cpi->mbsplit_count[mi->partitioning]++;
+ cpi->mbsplit_count[mi->partitioning]++;
#endif
- do
- {
- B_PREDICTION_MODE blockmode;
- int_mv blockmv;
- const int *const L =
- vp8_mbsplits [mi->partitioning];
- int k = -1; /* first block in subset j */
- int mv_contz;
- int_mv leftmv, abovemv;
+ do {
+ B_PREDICTION_MODE blockmode;
+ int_mv blockmv;
+ const int *const L =
+ vp8_mbsplits [mi->partitioning];
+ int k = -1; /* first block in subset j */
+ int mv_contz;
+ int_mv leftmv, abovemv;
- blockmode = cpi->mb.partition_info->bmi[j].mode;
- blockmv = cpi->mb.partition_info->bmi[j].mv;
+ blockmode = cpi->mb.partition_info->bmi[j].mode;
+ blockmv = cpi->mb.partition_info->bmi[j].mv;
#if CONFIG_DEBUG
- while (j != L[++k])
- if (k >= 16)
- assert(0);
+ while (j != L[++k])
+ if (k >= 16)
+ assert(0);
#else
- while (j != L[++k]);
+ while (j != L[++k]);
#endif
- leftmv.as_int = left_block_mv(m, k);
- abovemv.as_int = above_block_mv(m, k, mis);
- mv_contz = vp8_mv_cont(&leftmv, &abovemv);
+ leftmv.as_int = left_block_mv(m, k);
+ abovemv.as_int = above_block_mv(m, k, mis);
+ mv_contz = vp8_mv_cont(&leftmv, &abovemv);
- write_sub_mv_ref(w, blockmode,
- cpi->common.fc.sub_mv_ref_prob [mv_contz]);
+ write_sub_mv_ref(w, blockmode,
+ cpi->common.fc.sub_mv_ref_prob [mv_contz]);
#if CONFIG_ADAPTIVE_ENTROPY
- cpi->sub_mv_ref_count[mv_contz][blockmode-LEFT4X4]++;
+ cpi->sub_mv_ref_count[mv_contz][blockmode - LEFT4X4]++;
#endif
- if (blockmode == NEW4X4)
- {
+ if (blockmode == NEW4X4) {
#ifdef ENTROPY_STATS
- active_section = 11;
+ active_section = 11;
#endif
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- write_mv_hp(w, &blockmv.as_mv, &best_mv,
- (const MV_CONTEXT_HP *) mvc_hp);
- }
- else
-#endif
- {
- write_mv(w, &blockmv.as_mv, &best_mv,
- (const MV_CONTEXT *) mvc);
- }
-
- if (mi->second_ref_frame)
- {
-#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- write_mv_hp(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
- &best_second_mv, (const MV_CONTEXT_HP *) mvc_hp);
- }
- else
-#endif
- {
- write_mv(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
- &best_second_mv, (const MV_CONTEXT *) mvc);
- }
- }
- }
- }
- while (++j < cpi->mb.partition_info->count);
- }
- break;
- default:
- break;
- }
+ if (xd->allow_high_precision_mv) {
+ write_mv_hp(w, &blockmv.as_mv, &best_mv,
+ (const MV_CONTEXT_HP *) mvc_hp);
+ } else
+#endif
+ {
+ write_mv(w, &blockmv.as_mv, &best_mv,
+ (const MV_CONTEXT *) mvc);
}
- }
- // Next MB
- mb_row += dy;
- mb_col += dx;
- m += offset_extended;
- prev_m += offset_extended;
- cpi->mb.partition_info += offset_extended;
-#if CONFIG_DEBUG
- assert((prev_m-cpi->common.prev_mip)==(m-cpi->common.mip));
- assert((prev_m-cpi->common.prev_mi)==(m-cpi->common.mi));
-#endif
+ if (mi->second_ref_frame) {
+#if CONFIG_HIGH_PRECISION_MV
+ if (xd->allow_high_precision_mv) {
+ write_mv_hp(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
+ &best_second_mv, (const MV_CONTEXT_HP *) mvc_hp);
+ } else
+#endif
+ {
+ write_mv(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
+ &best_second_mv, (const MV_CONTEXT *) mvc);
+ }
+ }
+ }
+ } while (++j < cpi->mb.partition_info->count);
+ }
+ break;
+ default:
+ break;
}
+ }
}
- // Next SB
- mb_row += 2;
- m += mis + (1 - (pc->mb_cols & 0x1));
- prev_m += mis + (1 - (pc->mb_cols & 0x1));
- cpi->mb.partition_info += mis + (1 - (pc->mb_cols & 0x1));
+ // Next MB
+ mb_row += dy;
+ mb_col += dx;
+ m += offset_extended;
+ prev_m += offset_extended;
+ cpi->mb.partition_info += offset_extended;
+#if CONFIG_DEBUG
+ assert((prev_m - cpi->common.prev_mip) == (m - cpi->common.mip));
+ assert((prev_m - cpi->common.prev_mi) == (m - cpi->common.mi));
+#endif
+ }
}
+
+ // Next SB
+ mb_row += 2;
+ m += mis + (1 - (pc->mb_cols & 0x1));
+ prev_m += mis + (1 - (pc->mb_cols & 0x1));
+ cpi->mb.partition_info += mis + (1 - (pc->mb_cols & 0x1));
+ }
}
-static void write_kfmodes(VP8_COMP *cpi)
-{
- vp8_writer *const bc = & cpi->bc;
- VP8_COMMON *const c = & cpi->common;
- const int mis = c->mode_info_stride;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- MODE_INFO *m;
- int i;
- int row, col;
- int mb_row, mb_col;
+static void write_kfmodes(VP8_COMP *cpi) {
+ vp8_writer *const bc = & cpi->bc;
+ VP8_COMMON *const c = & cpi->common;
+ const int mis = c->mode_info_stride;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ MODE_INFO *m;
+ int i;
+ int row, col;
+ int mb_row, mb_col;
#if CONFIG_NEWENTROPY
- int prob_skip_false[3] = {0, 0, 0};
+ int prob_skip_false[3] = {0, 0, 0};
#else
- int prob_skip_false = 0;
+ int prob_skip_false = 0;
#endif
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
- //printf("write_kfmodes\n");
- if (c->mb_no_coeff_skip)
- {
- // Divide by 0 check. 0 case possible with segment features
+ // printf("write_kfmodes\n");
+ if (c->mb_no_coeff_skip) {
+ // Divide by 0 check. 0 case possible with segment features
#if CONFIG_NEWENTROPY
- int k;
- for (k=0;k<MBSKIP_CONTEXTS;++k)
- {
- if ( (cpi->skip_false_count[k] + cpi->skip_true_count[k]) )
- {
- prob_skip_false[k] = cpi->skip_false_count[k] * 256 /
- (cpi->skip_false_count[k] + cpi->skip_true_count[k]);
-
- if (prob_skip_false[k] <= 1)
- prob_skip_false[k] = 1;
-
- if (prob_skip_false[k] > 255)
- prob_skip_false[k] = 255;
- }
- else
- prob_skip_false[k] = 255;
-
- c->mbskip_pred_probs[k] = prob_skip_false[k];
- vp8_write_literal(bc, prob_skip_false[k], 8);
- }
-#else
- if ( (cpi->skip_false_count + cpi->skip_true_count) )
- {
- prob_skip_false = cpi->skip_false_count * 256 /
- (cpi->skip_false_count + cpi->skip_true_count);
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k) {
+ if ((cpi->skip_false_count[k] + cpi->skip_true_count[k])) {
+ prob_skip_false[k] = cpi->skip_false_count[k] * 256 /
+ (cpi->skip_false_count[k] + cpi->skip_true_count[k]);
- if (prob_skip_false <= 1)
- prob_skip_false = 1;
+ if (prob_skip_false[k] <= 1)
+ prob_skip_false[k] = 1;
- if (prob_skip_false > 255)
- prob_skip_false = 255;
- }
- else
- prob_skip_false = 255;
+ if (prob_skip_false[k] > 255)
+ prob_skip_false[k] = 255;
+ } else
+ prob_skip_false[k] = 255;
- cpi->prob_skip_false = prob_skip_false;
- vp8_write_literal(bc, prob_skip_false, 8);
-#endif
+ c->mbskip_pred_probs[k] = prob_skip_false[k];
+ vp8_write_literal(bc, prob_skip_false[k], 8);
}
+#else
+ if ((cpi->skip_false_count + cpi->skip_true_count)) {
+ prob_skip_false = cpi->skip_false_count * 256 /
+ (cpi->skip_false_count + cpi->skip_true_count);
- if(!c->kf_ymode_probs_update)
- {
- vp8_write_literal(bc, c->kf_ymode_probs_index, 3);
- }
+ if (prob_skip_false <= 1)
+ prob_skip_false = 1;
- mb_row = 0;
- for (row=0; row < c->mb_rows; row += 2)
- {
- m = c->mi + row * mis;
-
- mb_col = 0;
- for (col=0; col < c->mb_cols; col += 2)
- {
- // Process the 4 MBs in the order:
- // top-left, top-right, bottom-left, bottom-right
- for (i=0; i<4; i++)
- {
- int ym;
- int segment_id;
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * mis + dx;
-
- if ((mb_row >= c->mb_rows) || (mb_col >= c->mb_cols))
- {
- // MB lies outside frame, move on
- mb_row += dy;
- mb_col += dx;
- m += offset_extended;
- continue;
- }
+ if (prob_skip_false > 255)
+ prob_skip_false = 255;
+ } else
+ prob_skip_false = 255;
- // Make sure the MacroBlockD mode info pointer is set correctly
- xd->mode_info_context = m;
+ cpi->prob_skip_false = prob_skip_false;
+ vp8_write_literal(bc, prob_skip_false, 8);
+#endif
+ }
+
+ if (!c->kf_ymode_probs_update) {
+ vp8_write_literal(bc, c->kf_ymode_probs_index, 3);
+ }
+
+ mb_row = 0;
+ for (row = 0; row < c->mb_rows; row += 2) {
+ m = c->mi + row * mis;
+
+ mb_col = 0;
+ for (col = 0; col < c->mb_cols; col += 2) {
+ // Process the 4 MBs in the order:
+ // top-left, top-right, bottom-left, bottom-right
+ for (i = 0; i < 4; i++) {
+ int ym;
+ int segment_id;
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_extended = dy * mis + dx;
+
+ if ((mb_row >= c->mb_rows) || (mb_col >= c->mb_cols)) {
+ // MB lies outside frame, move on
+ mb_row += dy;
+ mb_col += dx;
+ m += offset_extended;
+ continue;
+ }
- ym = m->mbmi.mode;
- segment_id = m->mbmi.segment_id;
+ // Make sure the MacroBlockD mode info pointer is set correctly
+ xd->mode_info_context = m;
- if (cpi->mb.e_mbd.update_mb_segmentation_map)
- {
- write_mb_segid(bc, &m->mbmi, &cpi->mb.e_mbd);
- }
+ ym = m->mbmi.mode;
+ segment_id = m->mbmi.segment_id;
- if ( c->mb_no_coeff_skip &&
- ( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
- (get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0) ) )
- {
+ if (cpi->mb.e_mbd.update_mb_segmentation_map) {
+ write_mb_segid(bc, &m->mbmi, &cpi->mb.e_mbd);
+ }
+
+ if (c->mb_no_coeff_skip &&
+ (!segfeature_active(xd, segment_id, SEG_LVL_EOB) ||
+ (get_segdata(xd, segment_id, SEG_LVL_EOB) != 0))) {
#if CONFIG_NEWENTROPY
- vp8_encode_bool(bc, m->mbmi.mb_skip_coeff,
- get_pred_prob(c, xd, PRED_MBSKIP));
+ vp8_encode_bool(bc, m->mbmi.mb_skip_coeff,
+ get_pred_prob(c, xd, PRED_MBSKIP));
#else
- vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
+ vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
#endif
- }
- kfwrite_ymode(bc, ym,
- c->kf_ymode_prob[c->kf_ymode_probs_index]);
+ }
+ kfwrite_ymode(bc, ym,
+ c->kf_ymode_prob[c->kf_ymode_probs_index]);
- if (ym == B_PRED)
- {
- const int mis = c->mode_info_stride;
- int i = 0;
+ if (ym == B_PRED) {
+ const int mis = c->mode_info_stride;
+ int i = 0;
#if CONFIG_COMP_INTRA_PRED
- int uses_second =
- m->bmi[0].as_mode.second !=
- (B_PREDICTION_MODE) (B_DC_PRED - 1);
- vp8_write(bc, uses_second, 128);
-#endif
- do
- {
- const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
- const B_PREDICTION_MODE L = left_block_mode(m, i);
- const int bm = m->bmi[i].as_mode.first;
+ int uses_second =
+ m->bmi[0].as_mode.second !=
+ (B_PREDICTION_MODE)(B_DC_PRED - 1);
+ vp8_write(bc, uses_second, 128);
+#endif
+ do {
+ const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
+ const B_PREDICTION_MODE L = left_block_mode(m, i);
+ const int bm = m->bmi[i].as_mode.first;
#if CONFIG_COMP_INTRA_PRED
- const int bm2 = m->bmi[i].as_mode.second;
+ const int bm2 = m->bmi[i].as_mode.second;
#endif
#ifdef ENTROPY_STATS
- ++intra_mode_stats [A] [L] [bm];
+ ++intra_mode_stats [A] [L] [bm];
#endif
- write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
- //printf(" mode: %d\n", bm);
+ write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
+ // printf(" mode: %d\n", bm);
#if CONFIG_COMP_INTRA_PRED
- if (uses_second)
- {
- write_bmode(bc, bm2, c->kf_bmode_prob [A] [L]);
- }
-#endif
- }
- while (++i < 16);
- }
- if(ym == I8X8_PRED)
- {
- write_i8x8_mode(bc, m->bmi[0].as_mode.first,
- c->fc.i8x8_mode_prob);
- //printf(" mode: %d\n", m->bmi[0].as_mode.first); fflush(stdout);
- write_i8x8_mode(bc, m->bmi[2].as_mode.first,
- c->fc.i8x8_mode_prob);
- //printf(" mode: %d\n", m->bmi[2].as_mode.first); fflush(stdout);
- write_i8x8_mode(bc, m->bmi[8].as_mode.first,
- c->fc.i8x8_mode_prob);
- //printf(" mode: %d\n", m->bmi[8].as_mode.first); fflush(stdout);
- write_i8x8_mode(bc, m->bmi[10].as_mode.first,
- c->fc.i8x8_mode_prob);
- //printf(" mode: %d\n", m->bmi[10].as_mode.first); fflush(stdout);
- }
- else
- write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
-
- // Next MB
- mb_row += dy;
- mb_col += dx;
- m += offset_extended;
+ if (uses_second) {
+ write_bmode(bc, bm2, c->kf_bmode_prob [A] [L]);
}
+#endif
+ } while (++i < 16);
}
- mb_row += 2;
+ if (ym == I8X8_PRED) {
+ write_i8x8_mode(bc, m->bmi[0].as_mode.first,
+ c->fc.i8x8_mode_prob);
+ // printf(" mode: %d\n", m->bmi[0].as_mode.first); fflush(stdout);
+ write_i8x8_mode(bc, m->bmi[2].as_mode.first,
+ c->fc.i8x8_mode_prob);
+ // printf(" mode: %d\n", m->bmi[2].as_mode.first); fflush(stdout);
+ write_i8x8_mode(bc, m->bmi[8].as_mode.first,
+ c->fc.i8x8_mode_prob);
+ // printf(" mode: %d\n", m->bmi[8].as_mode.first); fflush(stdout);
+ write_i8x8_mode(bc, m->bmi[10].as_mode.first,
+ c->fc.i8x8_mode_prob);
+ // printf(" mode: %d\n", m->bmi[10].as_mode.first); fflush(stdout);
+ } else
+ write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
+
+ // Next MB
+ mb_row += dy;
+ mb_col += dx;
+ m += offset_extended;
+ }
}
+ mb_row += 2;
+ }
}
/* This function is used for debugging probability trees. */
static void print_prob_tree(vp8_prob
- coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES])
-{
- /* print coef probability tree */
- int i,j,k,l;
- FILE* f = fopen("enc_tree_probs.txt", "a");
- fprintf(f, "{\n");
- for (i = 0; i < BLOCK_TYPES; i++)
- {
- fprintf(f, " {\n");
- for (j = 0; j < COEF_BANDS; j++)
- {
- fprintf(f, " {\n");
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
- fprintf(f, " {");
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- fprintf(f, "%3u, ",
- (unsigned int)(coef_probs [i][j][k][l]));
- }
- fprintf(f, " }\n");
- }
- fprintf(f, " }\n");
+ coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
+ /* print coef probability tree */
+ int i, j, k, l;
+ FILE *f = fopen("enc_tree_probs.txt", "a");
+ fprintf(f, "{\n");
+ for (i = 0; i < BLOCK_TYPES; i++) {
+ fprintf(f, " {\n");
+ for (j = 0; j < COEF_BANDS; j++) {
+ fprintf(f, " {\n");
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
+ fprintf(f, " {");
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ fprintf(f, "%3u, ",
+ (unsigned int)(coef_probs [i][j][k][l]));
}
- fprintf(f, " }\n");
+ fprintf(f, " }\n");
+ }
+ fprintf(f, " }\n");
}
- fprintf(f, "}\n");
- fclose(f);
+ fprintf(f, " }\n");
+ }
+ fprintf(f, "}\n");
+ fclose(f);
}
-void build_coeff_contexts(VP8_COMP *cpi)
-{
- int i = 0;
- do
- {
- int j = 0;
- do
- {
- int k = 0;
- do
- {
+void build_coeff_contexts(VP8_COMP *cpi) {
+ int i = 0;
+ do {
+ int j = 0;
+ do {
+ int k = 0;
+ do {
#ifdef ENTROPY_STATS
- int t;
+ int t;
#endif
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
-#endif
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- cpi->frame_coef_probs [i][j][k],
- cpi->frame_branch_ct [i][j][k],
- cpi->coef_counts [i][j][k],
- 256, 1
- );
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
+#endif
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ cpi->frame_coef_probs [i][j][k],
+ cpi->frame_branch_ct [i][j][k],
+ cpi->coef_counts [i][j][k],
+ 256, 1
+ );
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- {
- t = 0;
- do
- {
- context_counters [i][j][k][t] +=
- cpi->coef_counts [i][j][k][t];
- }
- while (++t < MAX_ENTROPY_TOKENS);
- }
-#endif
- }
- while (++k < PREV_COEF_CONTEXTS);
+ if (!cpi->dummy_packing) {
+ t = 0;
+ do {
+ context_counters [i][j][k][t] +=
+ cpi->coef_counts [i][j][k][t];
+ } while (++t < MAX_ENTROPY_TOKENS);
}
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES);
-
-
- i= 0;
- if(cpi->common.txfm_mode == ALLOW_8X8)
- {
- do
- {
- int j = 0; /* token/prob index */
- do
- {
- int k = 0;
- do
- {
- /* at every context */
- /* calc probs and branch cts for this frame only */
- //vp8_prob new_p [ENTROPY_NODES];
- //unsigned int branch_ct [ENTROPY_NODES] [2];
+#endif
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES);
+
+
+ i = 0;
+ if (cpi->common.txfm_mode == ALLOW_8X8) {
+ do {
+ int j = 0; /* token/prob index */
+ do {
+ int k = 0;
+ do {
+ /* at every context */
+ /* calc probs and branch cts for this frame only */
+ // vp8_prob new_p [ENTROPY_NODES];
+ // unsigned int branch_ct [ENTROPY_NODES] [2];
#ifdef ENTROPY_STATS
- int t = 0; /* token/prob index */
+ int t = 0; /* token/prob index */
#endif
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
-#endif
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- cpi->frame_coef_probs_8x8 [i][j][k],
- cpi->frame_branch_ct_8x8 [i][j][k],
- cpi->coef_counts_8x8 [i][j][k],
- 256, 1
- );
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
+#endif
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ cpi->frame_coef_probs_8x8 [i][j][k],
+ cpi->frame_branch_ct_8x8 [i][j][k],
+ cpi->coef_counts_8x8 [i][j][k],
+ 256, 1
+ );
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- {
- t = 0;
- do
- {
- context_counters_8x8 [i][j][k][t] +=
- cpi->coef_counts_8x8 [i][j][k][t];
- }
- while (++t < MAX_ENTROPY_TOKENS);
- }
+ if (!cpi->dummy_packing) {
+ t = 0;
+ do {
+ context_counters_8x8 [i][j][k][t] +=
+ cpi->coef_counts_8x8 [i][j][k][t];
+ } while (++t < MAX_ENTROPY_TOKENS);
+ }
#endif
- }
- while (++k < PREV_COEF_CONTEXTS);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES_8X8);
- }
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES_8X8);
+ }
}
#if CONFIG_NEWUPDATE
-static void update_coef_probs3(VP8_COMP *cpi)
-{
- const vp8_prob grpupd = 216;
- int i, j, k, t;
- vp8_writer *const w = & cpi->bc;
- int update[2];
- int savings;
- int bestupdndx[2*ENTROPY_NODES];
-
- vp8_clear_system_state(); //__asm emms;
- // Build the cofficient contexts based on counts collected in encode loop
- build_coeff_contexts(cpi);
-
- i = 0;
- for (i = 0; i < BLOCK_TYPES; ++i)
- {
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- /* dry run to see if there is any udpate at all needed */
- savings = 0;
- update[0] = update[1] = 0;
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s;
- int u = 0;
+static void update_coef_probs3(VP8_COMP *cpi) {
+ const vp8_prob grpupd = 216;
+ int i, j, k, t;
+ vp8_writer *const w = & cpi->bc;
+ int update[2];
+ int savings;
+ int bestupdndx[2 * ENTROPY_NODES];
+
+ vp8_clear_system_state(); // __asm emms;
+ // Build the cofficient contexts based on counts collected in encode loop
+ build_coeff_contexts(cpi);
+
+ i = 0;
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ /* dry run to see if there is any udpate at all needed */
+ savings = 0;
+ update[0] = update[1] = 0;
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
- if (s > 0 && newp != *Pold) u = 1;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold) u = 1;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
- if (s > 0) u = 1;
- if (u)
- savings += s;
-#endif
- //printf(" %d %d %d: %d\n", i, j, k, u);
- update[u]++;
- }
- }
- if (update[1] == 0 || savings < 0)
- {
- vp8_write(w, 0, grpupd);
- continue;
- }
- vp8_write(w, 1, grpupd);
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s;
- int u = 0;
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
+ if (s > 0) u = 1;
+ if (u)
+ savings += s;
+#endif
+ // printf(" %d %d %d: %d\n", i, j, k, u);
+ update[u]++;
+ }
+ }
+ if (update[1] == 0 || savings < 0) {
+ vp8_write(w, 0, grpupd);
+ continue;
+ }
+ vp8_write(w, 1, grpupd);
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
- if (s > 0 && newp != *Pold) u = 1;
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold) u = 1;
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
- if (s > 0) u = 1;
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
+ if (s > 0) u = 1;
#endif
- //printf(" %d %d %d: %d (%d)\n", i, j, k, u, upd);
- vp8_write(w, u, upd);
+ // printf(" %d %d %d: %d (%d)\n", i, j, k, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- ++ tree_update_hist [i][j][k][t] [u];
+ if (!cpi->dummy_packing)
+ ++ tree_update_hist [i][j][k][t] [u];
#endif
- if (u)
- { /* send/use new probability */
- write_prob_diff_update(w, newp, *Pold);
- *Pold = newp;
- }
+ if (u) {
+ /* send/use new probability */
+ write_prob_diff_update(w, newp, *Pold);
+ *Pold = newp;
+ }
- }
- }
}
+ }
}
-
- if(cpi->common.txfm_mode != ALLOW_8X8) return;
-
- for (i = 0; i < BLOCK_TYPES_8X8; ++i)
- {
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- /* dry run to see if there is any udpate at all needed */
- savings = 0;
- update[0] = update[1] = 0;
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
- int s;
- int u = 0;
+ }
+
+ if (cpi->common.txfm_mode != ALLOW_8X8) return;
+
+ for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ /* dry run to see if there is any udpate at all needed */
+ savings = 0;
+ update[0] = update[1] = 0;
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
- if (u)
- savings += s;
-#endif
- update[u]++;
- }
- }
- if (update[1] == 0 || savings < 0)
- {
- vp8_write(w, 0, grpupd);
- continue;
- }
- vp8_write(w, 1, grpupd);
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
- int s;
- int u = 0;
+ s = prob_update_savings(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
+ if (u)
+ savings += s;
+#endif
+ update[u]++;
+ }
+ }
+ if (update[1] == 0 || savings < 0) {
+ vp8_write(w, 0, grpupd);
+ continue;
+ }
+ vp8_write(w, 1, grpupd);
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
#else
- s = prob_update_savings(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
+ s = prob_update_savings(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
#endif
- vp8_write(w, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- ++ tree_update_hist_8x8 [i][j][k][t] [u];
-#endif
- if (u)
- {
- /* send/use new probability */
- write_prob_diff_update(w, newp, *Pold);
- *Pold = newp;
- }
- }
- }
+ if (!cpi->dummy_packing)
+ ++ tree_update_hist_8x8 [i][j][k][t] [u];
+#endif
+ if (u) {
+ /* send/use new probability */
+ write_prob_diff_update(w, newp, *Pold);
+ *Pold = newp;
+ }
}
+ }
}
+ }
}
-static void update_coef_probs2(VP8_COMP *cpi)
-{
- const vp8_prob grpupd = 192;
- int i, j, k, t;
- vp8_writer *const w = & cpi->bc;
- int update[2];
- int savings;
- int bestupdndx[2*ENTROPY_NODES];
+static void update_coef_probs2(VP8_COMP *cpi) {
+ const vp8_prob grpupd = 192;
+ int i, j, k, t;
+ vp8_writer *const w = & cpi->bc;
+ int update[2];
+ int savings;
+ int bestupdndx[2 * ENTROPY_NODES];
- vp8_clear_system_state(); //__asm emms;
- // Build the cofficient contexts based on counts collected in encode loop
- build_coeff_contexts(cpi);
+ vp8_clear_system_state(); // __asm emms;
+ // Build the cofficient contexts based on counts collected in encode loop
+ build_coeff_contexts(cpi);
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- /* dry run to see if there is any udpate at all needed */
- savings = 0;
- update[0] = update[1] = 0;
- for (i = 0; i < BLOCK_TYPES; ++i)
- {
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s;
- int u = 0;
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ /* dry run to see if there is any udpate at all needed */
+ savings = 0;
+ update[0] = update[1] = 0;
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
- if (s > 0 && newp != *Pold) u = 1;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold) u = 1;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
- if (s > 0) u = 1;
- if (u)
- savings += s;
-#endif
- //printf(" %d %d %d: %d\n", i, j, k, u);
- update[u]++;
- }
- }
- }
- if (update[1] == 0 || savings < 0)
- {
- vp8_write(w, 0, grpupd);
- continue;
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
+ if (s > 0) u = 1;
+ if (u)
+ savings += s;
+#endif
+ // printf(" %d %d %d: %d\n", i, j, k, u);
+ update[u]++;
}
- vp8_write(w, 1, grpupd);
- for (i = 0; i < BLOCK_TYPES; ++i)
- {
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s;
- int u = 0;
+ }
+ }
+ if (update[1] == 0 || savings < 0) {
+ vp8_write(w, 0, grpupd);
+ continue;
+ }
+ vp8_write(w, 1, grpupd);
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
- if (s > 0 && newp != *Pold) u = 1;
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold) u = 1;
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
- if (s > 0) u = 1;
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t], *Pold, newp, upd);
+ if (s > 0) u = 1;
#endif
- //printf(" %d %d %d: %d (%d)\n", i, j, k, u, upd);
- vp8_write(w, u, upd);
+ // printf(" %d %d %d: %d (%d)\n", i, j, k, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- ++ tree_update_hist [i][j][k][t] [u];
+ ++ tree_update_hist [i][j][k][t] [u];
#endif
- if (u)
- { /* send/use new probability */
- write_prob_diff_update(w, newp, *Pold);
- *Pold = newp;
- }
- }
- }
+ if (u) {
+ /* send/use new probability */
+ write_prob_diff_update(w, newp, *Pold);
+ *Pold = newp;
+ }
}
+ }
}
+ }
- if(cpi->common.txfm_mode != ALLOW_8X8) return;
+ if (cpi->common.txfm_mode != ALLOW_8X8) return;
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- /* dry run to see if there is any udpate at all needed */
- savings = 0;
- update[0] = update[1] = 0;
- for (i = 0; i < BLOCK_TYPES_8X8; ++i)
- {
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
- int s;
- int u = 0;
+ for (t = 0; t < ENTROPY_NODES; ++t) {
+ /* dry run to see if there is any udpate at all needed */
+ savings = 0;
+ update[0] = update[1] = 0;
+ for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
- if (u)
- savings += s;
-#endif
- update[u]++;
- }
- }
- }
- if (update[1] == 0 || savings < 0)
- {
- vp8_write(w, 0, grpupd);
- continue;
+ s = prob_update_savings(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
+ if (u)
+ savings += s;
+#endif
+ update[u]++;
}
- vp8_write(w, 1, grpupd);
- for (i = 0; i < BLOCK_TYPES_8X8; ++i)
- {
- for (j = !i; j < COEF_BANDS; ++j)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
- int s;
- int u = 0;
+ }
+ }
+ if (update[1] == 0 || savings < 0) {
+ vp8_write(w, 0, grpupd);
+ continue;
+ }
+ vp8_write(w, 1, grpupd);
+ for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
+ for (j = !i; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int s;
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
#else
- s = prob_update_savings(
- cpi->frame_branch_ct_8x8 [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
+ s = prob_update_savings(
+ cpi->frame_branch_ct_8x8 [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
#endif
- vp8_write(w, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- ++ tree_update_hist_8x8 [i][j][k][t] [u];
-#endif
- if (u)
- {
- /* send/use new probability */
- write_prob_diff_update(w, newp, *Pold);
- *Pold = newp;
- }
- }
- }
+ if (!cpi->dummy_packing)
+ ++ tree_update_hist_8x8 [i][j][k][t] [u];
+#endif
+ if (u) {
+ /* send/use new probability */
+ write_prob_diff_update(w, newp, *Pold);
+ *Pold = newp;
+ }
}
+ }
}
+ }
}
#endif
-static void update_coef_probs(VP8_COMP *cpi)
-{
- int i = 0;
- vp8_writer *const w = & cpi->bc;
- int update[2] = {0, 0};
- int savings;
+static void update_coef_probs(VP8_COMP *cpi) {
+ int i = 0;
+ vp8_writer *const w = & cpi->bc;
+ int update[2] = {0, 0};
+ int savings;
- vp8_clear_system_state(); //__asm emms;
+ vp8_clear_system_state(); // __asm emms;
- // Build the cofficient contexts based on counts collected in encode loop
+ // Build the cofficient contexts based on counts collected in encode loop
- build_coeff_contexts(cpi);
+ build_coeff_contexts(cpi);
- //vp8_prob bestupd = find_coef_update_prob(cpi);
+ // vp8_prob bestupd = find_coef_update_prob(cpi);
- /* dry run to see if there is any udpate at all needed */
- savings = 0;
- do
- {
+ /* dry run to see if there is any udpate at all needed */
+ savings = 0;
+ do {
#if CONFIG_NEWUPDATE
- int j = !i;
+ int j = !i;
#else
- int j = 0; /* token/prob index */
-#endif
- do
- {
- int k = 0;
- int prev_coef_savings[ENTROPY_NODES] = {0};
- do
- {
- int t = 0; /* token/prob index */
- do
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s = prev_coef_savings[t];
- int u = 0;
+ int j = 0; /* token/prob index */
+#endif
+ do {
+ int k = 0;
+ int prev_coef_savings[ENTROPY_NODES] = {0};
+ do {
+ int t = 0; /* token/prob index */
+ do {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s = prev_coef_savings[t];
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
- if (u)
- savings += s;
-#endif
-
- update[u]++;
- }
- while (++t < ENTROPY_NODES);
- }
- while (++k < PREV_COEF_CONTEXTS);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES);
-
- //printf("Update %d %d, savings %d\n", update[0], update[1], savings);
- /* Is coef updated at all */
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
+ if (u)
+ savings += s;
+#endif
+
+ update[u]++;
+ } while (++t < ENTROPY_NODES);
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES);
+
+ // printf("Update %d %d, savings %d\n", update[0], update[1], savings);
+ /* Is coef updated at all */
#if CONFIG_NEWUPDATE
- if(update[1] == 0 || savings < 0)
+ if (update[1] == 0 || savings < 0)
#else
- if(update[1] == 0)
+ if (update[1] == 0)
#endif
- {
- vp8_write_bit(w, 0);
- }
- else
- {
- vp8_write_bit(w, 1);
- i=0;
- do
- {
+ {
+ vp8_write_bit(w, 0);
+ } else {
+ vp8_write_bit(w, 1);
+ i = 0;
+ do {
#if CONFIG_NEWUPDATE
- int j = !i;
+ int j = !i;
#else
- int j = 0; /* token/prob index */
-#endif
- do
- {
- int k = 0;
- int prev_coef_savings[ENTROPY_NODES] = {0};
-
- do
- {
- // calc probs and branch cts for this frame only
- int t = 0; /* token/prob index */
- do
- {
- vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
- const vp8_prob upd = COEF_UPDATE_PROB;
- int s = prev_coef_savings[t];
- int u = 0;
+ int j = 0; /* token/prob index */
+#endif
+ do {
+ int k = 0;
+ int prev_coef_savings[ENTROPY_NODES] = {0};
+
+ do {
+ // calc probs and branch cts for this frame only
+ int t = 0; /* token/prob index */
+ do {
+ vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
+ const vp8_prob upd = COEF_UPDATE_PROB;
+ int s = prev_coef_savings[t];
+ int u = 0;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, &newp, upd);
- if (s > 0 && newp != *Pold)
- u = 1;
+ s = prob_diff_update_savings_search(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, &newp, upd);
+ if (s > 0 && newp != *Pold)
+ u = 1;
#else
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, newp, upd);
- if (s > 0)
- u = 1;
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, newp, upd);
+ if (s > 0)
+ u = 1;
#endif
- vp8_write(w, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- ++ tree_update_hist [i][j][k][t] [u];
+ if (!cpi->dummy_packing)
+ ++ tree_update_hist [i][j][k][t] [u];
#endif
- if (u)
- {
- /* send/use new probability */
+ if (u) {
+ /* send/use new probability */
#if CONFIG_NEWUPDATE
- write_prob_diff_update(w, newp, *Pold);
+ write_prob_diff_update(w, newp, *Pold);
#else
- vp8_write_literal(w, newp, 8);
+ vp8_write_literal(w, newp, 8);
#endif
- *Pold = newp;
- }
- }
- while (++t < ENTROPY_NODES);
-
- }
- while (++k < PREV_COEF_CONTEXTS);
+ *Pold = newp;
}
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES);
- }
+ } while (++t < ENTROPY_NODES);
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES);
+ }
- /* do not do this if not evena allowed */
- if(cpi->common.txfm_mode == ALLOW_8X8)
- {
- /* dry run to see if update is necessary */
- update[0] = update[1] = 0;
- savings = 0;
- i = 0;
- do
- {
+
+ /* do not do this if not evena allowed */
+ if (cpi->common.txfm_mode == ALLOW_8X8) {
+ /* dry run to see if update is necessary */
+ update[0] = update[1] = 0;
+ savings = 0;
+ i = 0;
+ do {
#if CONFIG_NEWUPDATE
- int j = !i;
+ int j = !i;
#else
- int j = 0; /* token/prob index */
-#endif
- do
- {
- int k = 0;
- do
- {
- // calc probs and branch cts for this frame only
- int t = 0; /* token/prob index */
- do
- {
- const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob oldp = *Pold;
- int s,u;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int j = 0; /* token/prob index */
+#endif
+ do {
+ int k = 0;
+ do {
+ // calc probs and branch cts for this frame only
+ int t = 0; /* token/prob index */
+ do {
+ const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob oldp = *Pold;
+ int s, u;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
- u = s > 0 && newp != oldp ? 1 : 0;
- if (u)
- savings += s - (int)(vp8_cost_zero(upd));
- else
- savings -= (int)(vp8_cost_zero(upd));
+ s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
+ u = s > 0 && newp != oldp ? 1 : 0;
+ if (u)
+ savings += s - (int)(vp8_cost_zero(upd));
+ else
+ savings -= (int)(vp8_cost_zero(upd));
#else
- s = prob_update_savings(ct, oldp, newp, upd);
- u = s > 0 ? 1 : 0;
- if (u)
- savings += s;
+ s = prob_update_savings(ct, oldp, newp, upd);
+ u = s > 0 ? 1 : 0;
+ if (u)
+ savings += s;
#endif
- update[u]++;
- }
- while (++t < MAX_ENTROPY_TOKENS - 1);
- }
- while (++k < PREV_COEF_CONTEXTS);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES_8X8);
+ update[u]++;
+ } while (++t < MAX_ENTROPY_TOKENS - 1);
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES_8X8);
#if CONFIG_NEWUPDATE
- if (update[1] == 0 || savings < 0)
+ if (update[1] == 0 || savings < 0)
#else
- if (update[1] == 0)
+ if (update[1] == 0)
#endif
- {
- vp8_write_bit(w, 0);
- }
- else
- {
- vp8_write_bit(w, 1);
- i = 0;
- do
- {
+ {
+ vp8_write_bit(w, 0);
+ } else {
+ vp8_write_bit(w, 1);
+ i = 0;
+ do {
#if CONFIG_NEWUPDATE
- int j = !i;
+ int j = !i;
#else
- int j = 0; /* token/prob index */
+ int j = 0; /* token/prob index */
#endif
- do
- {
- int k = 0;
- do
- {
- int t = 0; /* token/prob index */
- do
- {
- const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
- vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob oldp = *Pold;
- const vp8_prob upd = COEF_UPDATE_PROB_8X8;
- int s, u;
+ do {
+ int k = 0;
+ do {
+ int t = 0; /* token/prob index */
+ do {
+ const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
+ vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob oldp = *Pold;
+ const vp8_prob upd = COEF_UPDATE_PROB_8X8;
+ int s, u;
#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) ||
- (i > 0 && j == 0)))
- continue;
+ if (k >= 3 && ((i == 0 && j == 1) ||
+ (i > 0 && j == 0)))
+ continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
- u = s > 0 && newp != oldp ? 1 : 0;
+ s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
+ u = s > 0 && newp != oldp ? 1 : 0;
#else
- s = prob_update_savings(ct, oldp, newp, upd);
- u = s > 0 ? 1 : 0;
+ s = prob_update_savings(ct, oldp, newp, upd);
+ u = s > 0 ? 1 : 0;
#endif
- vp8_write(w, u, upd);
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- if(!cpi->dummy_packing)
- ++ tree_update_hist_8x8 [i][j][k][t] [u];
+ if (!cpi->dummy_packing)
+ ++ tree_update_hist_8x8 [i][j][k][t] [u];
#endif
- if (u)
- {
- /* send/use new probability */
+ if (u) {
+ /* send/use new probability */
#if CONFIG_NEWUPDATE
- write_prob_diff_update(w, newp, oldp);
+ write_prob_diff_update(w, newp, oldp);
#else
- vp8_write_literal(w, newp, 8);
-#endif
- *Pold = newp;
- }
- }
- while (++t < MAX_ENTROPY_TOKENS - 1);
- }
- while (++k < PREV_COEF_CONTEXTS);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES_8X8);
- }
+ vp8_write_literal(w, newp, 8);
+#endif
+ *Pold = newp;
+ }
+ } while (++t < MAX_ENTROPY_TOKENS - 1);
+ } while (++k < PREV_COEF_CONTEXTS);
+ } while (++j < COEF_BANDS);
+ } while (++i < BLOCK_TYPES_8X8);
}
+ }
}
#ifdef PACKET_TESTING
FILE *vpxlogc = 0;
#endif
-static void put_delta_q(vp8_writer *bc, int delta_q)
-{
- if (delta_q != 0)
- {
- vp8_write_bit(bc, 1);
- vp8_write_literal(bc, abs(delta_q), 4);
+static void put_delta_q(vp8_writer *bc, int delta_q) {
+ if (delta_q != 0) {
+ vp8_write_bit(bc, 1);
+ vp8_write_literal(bc, abs(delta_q), 4);
- if (delta_q < 0)
- vp8_write_bit(bc, 1);
- else
- vp8_write_bit(bc, 0);
- }
+ if (delta_q < 0)
+ vp8_write_bit(bc, 1);
else
- vp8_write_bit(bc, 0);
+ vp8_write_bit(bc, 0);
+ } else
+ vp8_write_bit(bc, 0);
}
extern const unsigned int kf_y_mode_cts[8][VP8_YMODES];
-static void decide_kf_ymode_entropy(VP8_COMP *cpi)
-{
-
- int mode_cost[MB_MODE_COUNT];
- int cost;
- int bestcost = INT_MAX;
- int bestindex = 0;
- int i, j;
-
- for(i=0; i<8; i++)
- {
- vp8_cost_tokens(mode_cost, cpi->common.kf_ymode_prob[i], vp8_kf_ymode_tree);
- cost = 0;
- for(j=0;j<VP8_YMODES;j++)
- {
- cost += mode_cost[j] * cpi->ymode_count[j];
- }
- if(cost < bestcost)
- {
- bestindex = i;
- bestcost = cost;
- }
+static void decide_kf_ymode_entropy(VP8_COMP *cpi) {
+
+ int mode_cost[MB_MODE_COUNT];
+ int cost;
+ int bestcost = INT_MAX;
+ int bestindex = 0;
+ int i, j;
+
+ for (i = 0; i < 8; i++) {
+ vp8_cost_tokens(mode_cost, cpi->common.kf_ymode_prob[i], vp8_kf_ymode_tree);
+ cost = 0;
+ for (j = 0; j < VP8_YMODES; j++) {
+ cost += mode_cost[j] * cpi->ymode_count[j];
}
- cpi->common.kf_ymode_probs_index = bestindex;
+ if (cost < bestcost) {
+ bestindex = i;
+ bestcost = cost;
+ }
+ }
+ cpi->common.kf_ymode_probs_index = bestindex;
}
-static void segment_reference_frames(VP8_COMP *cpi)
-{
- VP8_COMMON *oci = &cpi->common;
- MODE_INFO *mi = oci->mi;
- int ref[MAX_MB_SEGMENTS]={0};
- int i,j;
- int mb_index=0;
- MACROBLOCKD *const xd = & cpi->mb.e_mbd;
-
- for (i = 0; i < oci->mb_rows; i++)
- {
- for (j = 0; j < oci->mb_cols; j++, mb_index++)
- {
- ref[mi[mb_index].mbmi.segment_id]|=(1<<mi[mb_index].mbmi.ref_frame);
- }
- mb_index++;
- }
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- {
- enable_segfeature(xd,i,SEG_LVL_REF_FRAME);
- set_segdata( xd,i, SEG_LVL_REF_FRAME, ref[i]);
+static void segment_reference_frames(VP8_COMP *cpi) {
+ VP8_COMMON *oci = &cpi->common;
+ MODE_INFO *mi = oci->mi;
+ int ref[MAX_MB_SEGMENTS] = {0};
+ int i, j;
+ int mb_index = 0;
+ MACROBLOCKD *const xd = & cpi->mb.e_mbd;
+
+ for (i = 0; i < oci->mb_rows; i++) {
+ for (j = 0; j < oci->mb_cols; j++, mb_index++) {
+ ref[mi[mb_index].mbmi.segment_id] |= (1 << mi[mb_index].mbmi.ref_frame);
}
+ mb_index++;
+ }
+ for (i = 0; i < MAX_MB_SEGMENTS; i++) {
+ enable_segfeature(xd, i, SEG_LVL_REF_FRAME);
+ set_segdata(xd, i, SEG_LVL_REF_FRAME, ref[i]);
+ }
}
-void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
-{
- int i, j;
- VP8_HEADER oh;
- VP8_COMMON *const pc = & cpi->common;
- vp8_writer *const bc = & cpi->bc;
- MACROBLOCKD *const xd = & cpi->mb.e_mbd;
- int extra_bytes_packed = 0;
+void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) {
+ int i, j;
+ VP8_HEADER oh;
+ VP8_COMMON *const pc = & cpi->common;
+ vp8_writer *const bc = & cpi->bc;
+ MACROBLOCKD *const xd = & cpi->mb.e_mbd;
+ int extra_bytes_packed = 0;
- unsigned char *cx_data = dest;
+ unsigned char *cx_data = dest;
- oh.show_frame = (int) pc->show_frame;
- oh.type = (int)pc->frame_type;
- oh.version = pc->version;
- oh.first_partition_length_in_bytes = 0;
+ oh.show_frame = (int) pc->show_frame;
+ oh.type = (int)pc->frame_type;
+ oh.version = pc->version;
+ oh.first_partition_length_in_bytes = 0;
- cx_data += 3;
+ cx_data += 3;
#if defined(SECTIONBITS_OUTPUT)
- Sectionbits[active_section = 1] += sizeof(VP8_HEADER) * 8 * 256;
+ Sectionbits[active_section = 1] += sizeof(VP8_HEADER) * 8 * 256;
#endif
#if CONFIG_NEWUPDATE
- compute_update_table();
+ compute_update_table();
#endif
- //vp8_kf_default_bmode_probs() is called in vp8_setup_key_frame() once for each
- //K frame before encode frame. pc->kf_bmode_prob doesn't get changed anywhere
- //else. No need to call it again here. --yw
- //vp8_kf_default_bmode_probs( pc->kf_bmode_prob);
+ // vp8_kf_default_bmode_probs() is called in vp8_setup_key_frame() once for each
+ // K frame before encode frame. pc->kf_bmode_prob doesn't get changed anywhere
+ // else. No need to call it again here. --yw
+ // vp8_kf_default_bmode_probs( pc->kf_bmode_prob);
- // every keyframe send startcode, width, height, scale factor, clamp and color type
- if (oh.type == KEY_FRAME)
- {
- int v;
+ // every keyframe send startcode, width, height, scale factor, clamp and color type
+ if (oh.type == KEY_FRAME) {
+ int v;
- // Start / synch code
- cx_data[0] = 0x9D;
- cx_data[1] = 0x01;
- cx_data[2] = 0x2a;
+ // Start / synch code
+ cx_data[0] = 0x9D;
+ cx_data[1] = 0x01;
+ cx_data[2] = 0x2a;
- v = (pc->horiz_scale << 14) | pc->Width;
- cx_data[3] = v;
- cx_data[4] = v >> 8;
+ v = (pc->horiz_scale << 14) | pc->Width;
+ cx_data[3] = v;
+ cx_data[4] = v >> 8;
- v = (pc->vert_scale << 14) | pc->Height;
- cx_data[5] = v;
- cx_data[6] = v >> 8;
+ v = (pc->vert_scale << 14) | pc->Height;
+ cx_data[5] = v;
+ cx_data[6] = v >> 8;
- extra_bytes_packed = 7;
- cx_data += extra_bytes_packed ;
+ extra_bytes_packed = 7;
+ cx_data += extra_bytes_packed;
- vp8_start_encode(bc, cx_data);
+ vp8_start_encode(bc, cx_data);
- // signal clr type
- vp8_write_bit(bc, pc->clr_type);
- vp8_write_bit(bc, pc->clamp_type);
+ // signal clr type
+ vp8_write_bit(bc, pc->clr_type);
+ vp8_write_bit(bc, pc->clamp_type);
- }
- else
- vp8_start_encode(bc, cx_data);
+ } else
+ vp8_start_encode(bc, cx_data);
- // Signal whether or not Segmentation is enabled
- vp8_write_bit(bc, (xd->segmentation_enabled) ? 1 : 0);
+ // Signal whether or not Segmentation is enabled
+ vp8_write_bit(bc, (xd->segmentation_enabled) ? 1 : 0);
- // Indicate which features are enabled
- if ( xd->segmentation_enabled )
- {
- // Indicate whether or not the segmentation map is being updated.
- vp8_write_bit(bc, (xd->update_mb_segmentation_map) ? 1 : 0);
-
- // If it is, then indicate the method that will be used.
- if ( xd->update_mb_segmentation_map )
- {
- // Select the coding strategy (temporal or spatial)
- choose_segmap_coding_method( cpi );
-
- // Take a copy of the segment map if it changed for
- // future comparison
- vpx_memcpy( pc->last_frame_seg_map,
- cpi->segmentation_map, pc->MBs );
-
- // Write out the chosen coding method.
- vp8_write_bit(bc, (pc->temporal_update) ? 1:0);
- }
+ // Indicate which features are enabled
+ if (xd->segmentation_enabled) {
+ // Indicate whether or not the segmentation map is being updated.
+ vp8_write_bit(bc, (xd->update_mb_segmentation_map) ? 1 : 0);
- vp8_write_bit(bc, (xd->update_mb_segmentation_data) ? 1 : 0);
+ // If it is, then indicate the method that will be used.
+ if (xd->update_mb_segmentation_map) {
+ // Select the coding strategy (temporal or spatial)
+ choose_segmap_coding_method(cpi);
- //segment_reference_frames(cpi);
+ // Take a copy of the segment map if it changed for
+ // future comparison
+ vpx_memcpy(pc->last_frame_seg_map,
+ cpi->segmentation_map, pc->MBs);
- if (xd->update_mb_segmentation_data)
- {
- signed char Data;
+ // Write out the chosen coding method.
+ vp8_write_bit(bc, (pc->temporal_update) ? 1 : 0);
+ }
- vp8_write_bit(bc, (xd->mb_segment_abs_delta) ? 1 : 0);
+ vp8_write_bit(bc, (xd->update_mb_segmentation_data) ? 1 : 0);
- // For each segments id...
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- {
- // For each segmentation codable feature...
- for (j = 0; j < SEG_LVL_MAX; j++)
- {
- Data = get_segdata( xd, i, j );
+ // segment_reference_frames(cpi);
+ if (xd->update_mb_segmentation_data) {
+ signed char Data;
-#if CONFIG_FEATUREUPDATES
+ vp8_write_bit(bc, (xd->mb_segment_abs_delta) ? 1 : 0);
- // check if there's an update
- if(segfeature_changed( xd,i,j) )
- {
- vp8_write_bit(bc, 1);
-
- if ( segfeature_active( xd, i, j ) )
- {
- // this bit is to say we are still
- // active/ if we were inactive
- // this is unnecessary
- if ( old_segfeature_active( xd, i, j ))
- {
- vp8_write_bit(bc, 1);
- }
- // Is the segment data signed..
- if ( is_segfeature_signed(j) )
- {
- // Encode the relevant feature data
- if (Data < 0)
- {
- Data = - Data;
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- vp8_write_bit(bc, 1);
- }
- else
- {
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- vp8_write_bit(bc, 0);
- }
- }
- // Unsigned data element so no sign bit needed
- else
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- }
- // feature is inactive now
- else if ( old_segfeature_active( xd, i, j ))
- {
- vp8_write_bit(bc, 0);
- }
- }
- else
- {
- vp8_write_bit(bc,0);
- }
-#else
+ // For each segments id...
+ for (i = 0; i < MAX_MB_SEGMENTS; i++) {
+ // For each segmentation codable feature...
+ for (j = 0; j < SEG_LVL_MAX; j++) {
+ Data = get_segdata(xd, i, j);
- // If the feature is enabled...
- if ( segfeature_active( xd, i, j ) )
- {
- vp8_write_bit(bc, 1);
-
- // Is the segment data signed..
- if ( is_segfeature_signed(j) )
- {
- // Encode the relevant feature data
- if (Data < 0)
- {
- Data = - Data;
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- vp8_write_bit(bc, 1);
- }
- else
- {
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- vp8_write_bit(bc, 0);
- }
- }
- // Unsigned data element so no sign bit needed
- else
- vp8_write_literal(bc, Data,
- seg_feature_data_bits(j));
- }
- else
- vp8_write_bit(bc, 0);
-#endif
- }
- }
- }
#if CONFIG_FEATUREUPDATES
- // save the segment info for updates next frame
- save_segment_info ( xd );
-#endif
- if (xd->update_mb_segmentation_map)
- {
- // Send the tree probabilities used to decode unpredicted
- // macro-block segments
- for (i = 0; i < MB_FEATURE_TREE_PROBS; i++)
- {
- int Data = xd->mb_segment_tree_probs[i];
+ // check if there's an update
+ if (segfeature_changed(xd, i, j)) {
+ vp8_write_bit(bc, 1);
- if (Data != 255)
- {
- vp8_write_bit(bc, 1);
- vp8_write_literal(bc, Data, 8);
+ if (segfeature_active(xd, i, j)) {
+ // this bit is to say we are still
+ // active/ if we were inactive
+ // this is unnecessary
+ if (old_segfeature_active(xd, i, j)) {
+ vp8_write_bit(bc, 1);
+ }
+ // Is the segment data signed..
+ if (is_segfeature_signed(j)) {
+ // Encode the relevant feature data
+ if (Data < 0) {
+ Data = - Data;
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
+ vp8_write_bit(bc, 1);
+ } else {
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
+ vp8_write_bit(bc, 0);
}
- else
- vp8_write_bit(bc, 0);
+ }
+ // Unsigned data element so no sign bit needed
+ else
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
}
-
- // If predictive coding of segment map is enabled send the
- // prediction probabilities.
- if ( pc->temporal_update )
- {
- for (i = 0; i < PREDICTION_PROBS; i++)
- {
- int Data = pc->segment_pred_probs[i];
-
- if (Data != 255)
- {
- vp8_write_bit(bc, 1);
- vp8_write_literal(bc, Data, 8);
- }
- else
- vp8_write_bit(bc, 0);
- }
+ // feature is inactive now
+ else if (old_segfeature_active(xd, i, j)) {
+ vp8_write_bit(bc, 0);
}
- }
- }
+ } else {
+ vp8_write_bit(bc, 0);
+ }
+#else
- // Encode the common prediction model status flag probability updates for
- // the reference frame
- update_refpred_stats( cpi );
- if ( pc->frame_type != KEY_FRAME )
- {
- for (i = 0; i < PREDICTION_PROBS; i++)
- {
- if ( cpi->ref_pred_probs_update[i] )
- {
+ // If the feature is enabled...
+ if (segfeature_active(xd, i, j)) {
+ vp8_write_bit(bc, 1);
+
+ // Is the segment data signed..
+ if (is_segfeature_signed(j)) {
+ // Encode the relevant feature data
+ if (Data < 0) {
+ Data = - Data;
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
vp8_write_bit(bc, 1);
- vp8_write_literal(bc, pc->ref_pred_probs[i], 8);
+ } else {
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
+ vp8_write_bit(bc, 0);
+ }
}
+ // Unsigned data element so no sign bit needed
else
- vp8_write_bit(bc, 0);
+ vp8_write_literal(bc, Data,
+ seg_feature_data_bits(j));
+ } else
+ vp8_write_bit(bc, 0);
+#endif
}
+ }
}
- vp8_write_bit(bc, pc->txfm_mode);
-
- // Encode the loop filter level and type
- vp8_write_bit(bc, pc->filter_type);
- vp8_write_literal(bc, pc->filter_level, 6);
- vp8_write_literal(bc, pc->sharpness_level, 3);
-
- // Write out loop filter deltas applied at the MB level based on mode or ref frame (if they are enabled).
- vp8_write_bit(bc, (xd->mode_ref_lf_delta_enabled) ? 1 : 0);
-
- if (xd->mode_ref_lf_delta_enabled)
- {
- // Do the deltas need to be updated
- int send_update = xd->mode_ref_lf_delta_update;
-
- vp8_write_bit(bc, send_update);
- if (send_update)
- {
- int Data;
-
- // Send update
- for (i = 0; i < MAX_REF_LF_DELTAS; i++)
- {
- Data = xd->ref_lf_deltas[i];
-
- // Frame level data
- if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i])
- {
- xd->last_ref_lf_deltas[i] = xd->ref_lf_deltas[i];
- vp8_write_bit(bc, 1);
-
- if (Data > 0)
- {
- vp8_write_literal(bc, (Data & 0x3F), 6);
- vp8_write_bit(bc, 0); // sign
- }
- else
- {
- Data = -Data;
- vp8_write_literal(bc, (Data & 0x3F), 6);
- vp8_write_bit(bc, 1); // sign
- }
- }
- else
- vp8_write_bit(bc, 0);
- }
-
- // Send update
- for (i = 0; i < MAX_MODE_LF_DELTAS; i++)
- {
- Data = xd->mode_lf_deltas[i];
-
- if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i])
- {
- xd->last_mode_lf_deltas[i] = xd->mode_lf_deltas[i];
- vp8_write_bit(bc, 1);
-
- if (Data > 0)
- {
- vp8_write_literal(bc, (Data & 0x3F), 6);
- vp8_write_bit(bc, 0); // sign
- }
- else
- {
- Data = -Data;
- vp8_write_literal(bc, (Data & 0x3F), 6);
- vp8_write_bit(bc, 1); // sign
- }
- }
- else
- vp8_write_bit(bc, 0);
- }
+#if CONFIG_FEATUREUPDATES
+ // save the segment info for updates next frame
+ save_segment_info(xd);
+#endif
+
+ if (xd->update_mb_segmentation_map) {
+ // Send the tree probabilities used to decode unpredicted
+ // macro-block segments
+ for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
+ int Data = xd->mb_segment_tree_probs[i];
+
+ if (Data != 255) {
+ vp8_write_bit(bc, 1);
+ vp8_write_literal(bc, Data, 8);
+ } else
+ vp8_write_bit(bc, 0);
+ }
+
+ // If predictive coding of segment map is enabled send the
+ // prediction probabilities.
+ if (pc->temporal_update) {
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ int Data = pc->segment_pred_probs[i];
+
+ if (Data != 255) {
+ vp8_write_bit(bc, 1);
+ vp8_write_literal(bc, Data, 8);
+ } else
+ vp8_write_bit(bc, 0);
}
+ }
+ }
+ }
+
+ // Encode the common prediction model status flag probability updates for
+ // the reference frame
+ update_refpred_stats(cpi);
+ if (pc->frame_type != KEY_FRAME) {
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ if (cpi->ref_pred_probs_update[i]) {
+ vp8_write_bit(bc, 1);
+ vp8_write_literal(bc, pc->ref_pred_probs[i], 8);
+ } else
+ vp8_write_bit(bc, 0);
}
+ }
+
+ vp8_write_bit(bc, pc->txfm_mode);
+
+ // Encode the loop filter level and type
+ vp8_write_bit(bc, pc->filter_type);
+ vp8_write_literal(bc, pc->filter_level, 6);
+ vp8_write_literal(bc, pc->sharpness_level, 3);
+
+ // Write out loop filter deltas applied at the MB level based on mode or ref frame (if they are enabled).
+ vp8_write_bit(bc, (xd->mode_ref_lf_delta_enabled) ? 1 : 0);
+
+ if (xd->mode_ref_lf_delta_enabled) {
+ // Do the deltas need to be updated
+ int send_update = xd->mode_ref_lf_delta_update;
+
+ vp8_write_bit(bc, send_update);
+ if (send_update) {
+ int Data;
+
+ // Send update
+ for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
+ Data = xd->ref_lf_deltas[i];
+
+ // Frame level data
+ if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i]) {
+ xd->last_ref_lf_deltas[i] = xd->ref_lf_deltas[i];
+ vp8_write_bit(bc, 1);
+
+ if (Data > 0) {
+ vp8_write_literal(bc, (Data & 0x3F), 6);
+ vp8_write_bit(bc, 0); // sign
+ } else {
+ Data = -Data;
+ vp8_write_literal(bc, (Data & 0x3F), 6);
+ vp8_write_bit(bc, 1); // sign
+ }
+ } else
+ vp8_write_bit(bc, 0);
+ }
+
+ // Send update
+ for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
+ Data = xd->mode_lf_deltas[i];
+
+ if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i]) {
+ xd->last_mode_lf_deltas[i] = xd->mode_lf_deltas[i];
+ vp8_write_bit(bc, 1);
+
+ if (Data > 0) {
+ vp8_write_literal(bc, (Data & 0x3F), 6);
+ vp8_write_bit(bc, 0); // sign
+ } else {
+ Data = -Data;
+ vp8_write_literal(bc, (Data & 0x3F), 6);
+ vp8_write_bit(bc, 1); // sign
+ }
+ } else
+ vp8_write_bit(bc, 0);
+ }
+ }
+ }
- //signal here is multi token partition is enabled
- //vp8_write_literal(bc, pc->multi_token_partition, 2);
- vp8_write_literal(bc, 0, 2);
+ // signal here is multi token partition is enabled
+ // vp8_write_literal(bc, pc->multi_token_partition, 2);
+ vp8_write_literal(bc, 0, 2);
- // Frame Q baseline quantizer index
- vp8_write_literal(bc, pc->base_qindex, QINDEX_BITS);
+ // Frame Q baseline quantizer index
+ vp8_write_literal(bc, pc->base_qindex, QINDEX_BITS);
- // Transmit Dc, Second order and Uv quantizer delta information
- put_delta_q(bc, pc->y1dc_delta_q);
- put_delta_q(bc, pc->y2dc_delta_q);
- put_delta_q(bc, pc->y2ac_delta_q);
- put_delta_q(bc, pc->uvdc_delta_q);
- put_delta_q(bc, pc->uvac_delta_q);
+ // Transmit Dc, Second order and Uv quantizer delta information
+ put_delta_q(bc, pc->y1dc_delta_q);
+ put_delta_q(bc, pc->y2dc_delta_q);
+ put_delta_q(bc, pc->y2ac_delta_q);
+ put_delta_q(bc, pc->uvdc_delta_q);
+ put_delta_q(bc, pc->uvac_delta_q);
- // When there is a key frame all reference buffers are updated using the new key frame
- if (pc->frame_type != KEY_FRAME)
- {
- // Should the GF or ARF be updated using the transmitted frame or buffer
- vp8_write_bit(bc, pc->refresh_golden_frame);
- vp8_write_bit(bc, pc->refresh_alt_ref_frame);
+ // When there is a key frame all reference buffers are updated using the new key frame
+ if (pc->frame_type != KEY_FRAME) {
+ // Should the GF or ARF be updated using the transmitted frame or buffer
+ vp8_write_bit(bc, pc->refresh_golden_frame);
+ vp8_write_bit(bc, pc->refresh_alt_ref_frame);
- // For inter frames the current default behavior is that when
- // cm->refresh_golden_frame is set we copy the old GF over to
- // the ARF buffer. This is purely an encoder decision at present.
- if (pc->refresh_golden_frame)
- pc->copy_buffer_to_arf = 2;
+ // For inter frames the current default behavior is that when
+ // cm->refresh_golden_frame is set we copy the old GF over to
+ // the ARF buffer. This is purely an encoder decision at present.
+ if (pc->refresh_golden_frame)
+ pc->copy_buffer_to_arf = 2;
- // If not being updated from current frame should either GF or ARF be updated from another buffer
- if (!pc->refresh_golden_frame)
- vp8_write_literal(bc, pc->copy_buffer_to_gf, 2);
+ // If not being updated from current frame should either GF or ARF be updated from another buffer
+ if (!pc->refresh_golden_frame)
+ vp8_write_literal(bc, pc->copy_buffer_to_gf, 2);
- if (!pc->refresh_alt_ref_frame)
- vp8_write_literal(bc, pc->copy_buffer_to_arf, 2);
+ if (!pc->refresh_alt_ref_frame)
+ vp8_write_literal(bc, pc->copy_buffer_to_arf, 2);
- // Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
- vp8_write_bit(bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
- vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
+ // Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
+ vp8_write_bit(bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
+ vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
#if CONFIG_HIGH_PRECISION_MV
- // Signal whether to allow high MV precision
- vp8_write_bit(bc, (xd->allow_high_precision_mv) ? 1 : 0);
+ // Signal whether to allow high MV precision
+ vp8_write_bit(bc, (xd->allow_high_precision_mv) ? 1 : 0);
#endif
#if CONFIG_ENHANCED_INTERP
- // Signal the type of subpel filter to use
- vp8_write_literal(bc, (pc->mcomp_filter_type), 2);
+ // Signal the type of subpel filter to use
+ vp8_write_literal(bc, (pc->mcomp_filter_type), 2);
#endif
- }
+ }
- vp8_write_bit(bc, pc->refresh_entropy_probs);
+ vp8_write_bit(bc, pc->refresh_entropy_probs);
- if (pc->frame_type != KEY_FRAME)
- vp8_write_bit(bc, pc->refresh_last_frame);
+ if (pc->frame_type != KEY_FRAME)
+ vp8_write_bit(bc, pc->refresh_last_frame);
#ifdef ENTROPY_STATS
- if (pc->frame_type == INTER_FRAME)
- active_section = 0;
- else
- active_section = 7;
+ if (pc->frame_type == INTER_FRAME)
+ active_section = 0;
+ else
+ active_section = 7;
#endif
- vp8_clear_system_state(); //__asm emms;
+ vp8_clear_system_state(); // __asm emms;
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_copy(cpi->common.fc.pre_coef_probs, cpi->common.fc.coef_probs);
- vp8_copy(cpi->common.fc.pre_coef_probs_8x8, cpi->common.fc.coef_probs_8x8);
- vp8_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
- vp8_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
- vp8_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob);
- vp8_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
- vp8_copy(cpi->common.fc.pre_mbsplit_prob, cpi->common.fc.mbsplit_prob);
- vp8_copy(cpi->common.fc.pre_i8x8_mode_prob, cpi->common.fc.i8x8_mode_prob);
- vp8_copy(cpi->common.fc.pre_mvc, cpi->common.fc.mvc);
+ vp8_copy(cpi->common.fc.pre_coef_probs, cpi->common.fc.coef_probs);
+ vp8_copy(cpi->common.fc.pre_coef_probs_8x8, cpi->common.fc.coef_probs_8x8);
+ vp8_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
+ vp8_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
+ vp8_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob);
+ vp8_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
+ vp8_copy(cpi->common.fc.pre_mbsplit_prob, cpi->common.fc.mbsplit_prob);
+ vp8_copy(cpi->common.fc.pre_i8x8_mode_prob, cpi->common.fc.i8x8_mode_prob);
+ vp8_copy(cpi->common.fc.pre_mvc, cpi->common.fc.mvc);
#if CONFIG_HIGH_PRECISION_MV
- vp8_copy(cpi->common.fc.pre_mvc_hp, cpi->common.fc.mvc_hp);
+ vp8_copy(cpi->common.fc.pre_mvc_hp, cpi->common.fc.mvc_hp);
#endif
- vp8_zero(cpi->sub_mv_ref_count);
- vp8_zero(cpi->mbsplit_count);
- vp8_zero(cpi->common.fc.mv_ref_ct)
- vp8_zero(cpi->common.fc.mv_ref_ct_a)
+ vp8_zero(cpi->sub_mv_ref_count);
+ vp8_zero(cpi->mbsplit_count);
+ vp8_zero(cpi->common.fc.mv_ref_ct)
+ vp8_zero(cpi->common.fc.mv_ref_ct_a)
#endif
#if CONFIG_NEWUPDATE && COEFUPDATETYPE == 2
- update_coef_probs2(cpi);
+ update_coef_probs2(cpi);
#elif CONFIG_NEWUPDATE && COEFUPDATETYPE == 3
- update_coef_probs3(cpi);
+ update_coef_probs3(cpi);
#else
- update_coef_probs(cpi);
+ update_coef_probs(cpi);
#endif
#ifdef ENTROPY_STATS
- active_section = 2;
+ active_section = 2;
#endif
- // Write out the mb_no_coeff_skip flag
- vp8_write_bit(bc, pc->mb_no_coeff_skip);
+ // Write out the mb_no_coeff_skip flag
+ vp8_write_bit(bc, pc->mb_no_coeff_skip);
- if (pc->frame_type == KEY_FRAME)
- {
- decide_kf_ymode_entropy(cpi);
- write_kfmodes(cpi);
+ if (pc->frame_type == KEY_FRAME) {
+ decide_kf_ymode_entropy(cpi);
+ write_kfmodes(cpi);
#ifdef ENTROPY_STATS
- active_section = 8;
+ active_section = 8;
#endif
- }
- else
- {
- pack_inter_mode_mvs(cpi);
+ } else {
+ pack_inter_mode_mvs(cpi);
#if CONFIG_ADAPTIVE_ENTROPY == 0
- vp8_update_mode_context(&cpi->common);
+ vp8_update_mode_context(&cpi->common);
#endif
#ifdef ENTROPY_STATS
- active_section = 1;
+ active_section = 1;
#endif
- }
+ }
- vp8_stop_encode(bc);
+ vp8_stop_encode(bc);
- oh.first_partition_length_in_bytes = cpi->bc.pos;
+ oh.first_partition_length_in_bytes = cpi->bc.pos;
- /* update frame tag */
- {
- int v = (oh.first_partition_length_in_bytes << 5) |
- (oh.show_frame << 4) |
- (oh.version << 1) |
- oh.type;
-
- dest[0] = v;
- dest[1] = v >> 8;
- dest[2] = v >> 16;
- }
+ /* update frame tag */
+ {
+ int v = (oh.first_partition_length_in_bytes << 5) |
+ (oh.show_frame << 4) |
+ (oh.version << 1) |
+ oh.type;
+
+ dest[0] = v;
+ dest[1] = v >> 8;
+ dest[2] = v >> 16;
+ }
- *size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos;
+ *size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos;
- vp8_start_encode(&cpi->bc2, cx_data + bc->pos);
+ vp8_start_encode(&cpi->bc2, cx_data + bc->pos);
- pack_tokens(&cpi->bc2, cpi->tok, cpi->tok_count);
+ pack_tokens(&cpi->bc2, cpi->tok, cpi->tok_count);
- vp8_stop_encode(&cpi->bc2);
+ vp8_stop_encode(&cpi->bc2);
- *size += cpi->bc2.pos;
+ *size += cpi->bc2.pos;
}
#ifdef ENTROPY_STATS
-void print_tree_update_probs()
-{
- int i, j, k, l;
- FILE *f = fopen("coefupdprob.h", "w");
- int Sum;
- fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
- fprintf(f, "const vp8_prob\n"
- "vp8_coef_update_probs[BLOCK_TYPES]\n"
- " [COEF_BANDS]\n"
- " [PREV_COEF_CONTEXTS]\n"
- " [ENTROPY_NODES] = {\n");
-
- for (i = 0; i < BLOCK_TYPES; i++)
- {
- fprintf(f, " { \n");
-
- for (j = 0; j < COEF_BANDS; j++)
- {
- fprintf(f, " {\n");
-
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
- fprintf(f, " {");
-
- for (l = 0; l < ENTROPY_NODES; l++)
- {
- Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][j][k][l][1];
-
- if (Sum > 0)
- {
- if (((tree_update_hist[i][j][k][l][0] * 255) / Sum) > 0)
- fprintf(f, "%3ld, ", (tree_update_hist[i][j][k][l][0] * 255) / Sum);
- else
- fprintf(f, "%3ld, ", 1);
- }
- else
- fprintf(f, "%3ld, ", 128);
- }
-
- fprintf(f, "},\n");
- }
-
- fprintf(f, " },\n");
+void print_tree_update_probs() {
+ int i, j, k, l;
+ FILE *f = fopen("coefupdprob.h", "w");
+ int Sum;
+ fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
+ fprintf(f, "const vp8_prob\n"
+ "vp8_coef_update_probs[BLOCK_TYPES]\n"
+ " [COEF_BANDS]\n"
+ " [PREV_COEF_CONTEXTS]\n"
+ " [ENTROPY_NODES] = {\n");
+
+ for (i = 0; i < BLOCK_TYPES; i++) {
+ fprintf(f, " { \n");
+
+ for (j = 0; j < COEF_BANDS; j++) {
+ fprintf(f, " {\n");
+
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
+ fprintf(f, " {");
+
+ for (l = 0; l < ENTROPY_NODES; l++) {
+ Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][j][k][l][1];
+
+ if (Sum > 0) {
+ if (((tree_update_hist[i][j][k][l][0] * 255) / Sum) > 0)
+ fprintf(f, "%3ld, ", (tree_update_hist[i][j][k][l][0] * 255) / Sum);
+ else
+ fprintf(f, "%3ld, ", 1);
+ } else
+ fprintf(f, "%3ld, ", 128);
}
- fprintf(f, " },\n");
+ fprintf(f, "},\n");
+ }
+
+ fprintf(f, " },\n");
}
- fprintf(f, "};\n");
+ fprintf(f, " },\n");
+ }
- fprintf(f, "const vp8_prob\n"
- "vp8_coef_update_probs_8x8[BLOCK_TYPES_8X8]\n"
- " [COEF_BANDS]\n"
- " [PREV_COEF_CONTEXTS]\n"
- " [ENTROPY_NODES] = {\n");
+ fprintf(f, "};\n");
+ fprintf(f, "const vp8_prob\n"
+ "vp8_coef_update_probs_8x8[BLOCK_TYPES_8X8]\n"
+ " [COEF_BANDS]\n"
+ " [PREV_COEF_CONTEXTS]\n"
+ " [ENTROPY_NODES] = {\n");
- for (i = 0; i < BLOCK_TYPES_8X8; i++)
- {
- fprintf(f, " { \n");
- for (j = 0; j < COEF_BANDS; j++)
- {
- fprintf(f, " {\n");
+ for (i = 0; i < BLOCK_TYPES_8X8; i++) {
+ fprintf(f, " { \n");
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
- fprintf(f, " {");
+ for (j = 0; j < COEF_BANDS; j++) {
+ fprintf(f, " {\n");
- for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++)
- {
- Sum = tree_update_hist_8x8[i][j][k][l][0] + tree_update_hist_8x8[i][j][k][l][1];
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
+ fprintf(f, " {");
- if (Sum > 0)
- {
- if (((tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum) > 0)
- fprintf(f, "%3ld, ", (tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum);
- else
- fprintf(f, "%3ld, ", 1);
- }
- else
- fprintf(f, "%3ld, ", 128);
- }
-
- fprintf(f, "},\n");
- }
+ for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) {
+ Sum = tree_update_hist_8x8[i][j][k][l][0] + tree_update_hist_8x8[i][j][k][l][1];
- fprintf(f, " },\n");
+ if (Sum > 0) {
+ if (((tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum) > 0)
+ fprintf(f, "%3ld, ", (tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum);
+ else
+ fprintf(f, "%3ld, ", 1);
+ } else
+ fprintf(f, "%3ld, ", 128);
}
- fprintf(f, " },\n");
+ fprintf(f, "},\n");
+ }
+
+ fprintf(f, " },\n");
}
- fclose(f);
- f = fopen("treeupdate.bin", "wb");
- fwrite(tree_update_hist, sizeof(tree_update_hist), 1, f);
- fwrite(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
- fclose(f);
+
+ fprintf(f, " },\n");
+ }
+ fclose(f);
+ f = fopen("treeupdate.bin", "wb");
+ fwrite(tree_update_hist, sizeof(tree_update_hist), 1, f);
+ fwrite(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
+ fclose(f);
}
#endif
diff --git a/vp8/encoder/bitstream.h b/vp8/encoder/bitstream.h
index 78fb26f66..b1c46dc95 100644
--- a/vp8/encoder/bitstream.h
+++ b/vp8/encoder/bitstream.h
@@ -18,7 +18,7 @@ void vp8cx_pack_tokens_armv5(vp8_writer *w, const TOKENEXTRA *p, int xcount,
vp8_extra_bit_struct *,
const vp8_tree_index *);
# define pack_tokens(a,b,c) \
- vp8cx_pack_tokens_armv5(a,b,c,vp8_coef_encodings,vp8_extra_bits,vp8_coef_tree)
+ vp8cx_pack_tokens_armv5(a,b,c,vp8_coef_encodings,vp8_extra_bits,vp8_coef_tree)
#else
# define pack_tokens(a,b,c) pack_tokens_c(a,b,c)
#endif
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h
index 45f157703..766e80776 100644
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -19,168 +19,162 @@
#include "vpx_ports/mem.h"
// motion search site
-typedef struct
-{
- MV mv;
- int offset;
+typedef struct {
+ MV mv;
+ int offset;
} search_site;
-typedef struct
-{
- // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
- short *src_diff;
- short *coeff;
-
- // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
- short *quant;
- short *quant_fast; // fast quant deprecated for now
- unsigned char *quant_shift;
- short *zbin;
- short *zbin_8x8;
- short *zrun_zbin_boost;
- short *zrun_zbin_boost_8x8;
- short *round;
-
- // Zbin Over Quant value
- short zbin_extra;
-
- unsigned char **base_src;
- unsigned char **base_second_src;
- int src;
- int src_stride;
-
- int eob_max_offset;
- int eob_max_offset_8x8;
+typedef struct {
+ // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
+ short *src_diff;
+ short *coeff;
+
+ // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
+ short *quant;
+ short *quant_fast; // fast quant deprecated for now
+ unsigned char *quant_shift;
+ short *zbin;
+ short *zbin_8x8;
+ short *zrun_zbin_boost;
+ short *zrun_zbin_boost_8x8;
+ short *round;
+
+ // Zbin Over Quant value
+ short zbin_extra;
+
+ unsigned char **base_src;
+ unsigned char **base_second_src;
+ int src;
+ int src_stride;
+
+ int eob_max_offset;
+ int eob_max_offset_8x8;
} BLOCK;
-typedef struct
-{
- int count;
- struct
- {
- B_PREDICTION_MODE mode;
- int_mv mv;
- int_mv second_mv;
- } bmi[16];
+typedef struct {
+ int count;
+ struct {
+ B_PREDICTION_MODE mode;
+ int_mv mv;
+ int_mv second_mv;
+ } bmi[16];
} PARTITION_INFO;
// Structure to hold snapshot of coding context during the mode picking process
// TODO Do we need all of these?
-typedef struct
-{
- MODE_INFO mic;
- PARTITION_INFO partition_info;
- int_mv best_ref_mv;
- int_mv second_best_ref_mv;
- int rate;
- int distortion;
- int intra_error;
- int best_mode_index;
- int rddiv;
- int rdmult;
+typedef struct {
+ MODE_INFO mic;
+ PARTITION_INFO partition_info;
+ int_mv best_ref_mv;
+ int_mv second_best_ref_mv;
+ int rate;
+ int distortion;
+ int intra_error;
+ int best_mode_index;
+ int rddiv;
+ int rdmult;
} PICK_MODE_CONTEXT;
-typedef struct
-{
- DECLARE_ALIGNED(16, short, src_diff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
- DECLARE_ALIGNED(16, short, coeff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
- DECLARE_ALIGNED(16, unsigned char, thismb[256]); // 16x16 Y
-
- unsigned char *thismb_ptr;
- // 16 Y blocks, 4 U blocks, 4 V blocks,
- // 1 DC 2nd order block each with 16 entries
- BLOCK block[25];
-
- YV12_BUFFER_CONFIG src;
-
- MACROBLOCKD e_mbd;
- PARTITION_INFO *partition_info; /* work pointer */
- PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */
- PARTITION_INFO *pip; /* Base of allocated array */
-
- search_site *ss;
- int ss_count;
- int searches_per_step;
-
- int errorperbit;
- int sadperbit16;
- int sadperbit4;
- int rddiv;
- int rdmult;
- unsigned int * mb_activity_ptr;
- int * mb_norm_activity_ptr;
- signed int act_zbin_adj;
-
- int mvcosts[2][MVvals+1];
- int *mvcost[2];
- int mvsadcosts[2][MVfpvals+1];
- int *mvsadcost[2];
+typedef struct {
+ DECLARE_ALIGNED(16, short, src_diff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
+ DECLARE_ALIGNED(16, short, coeff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
+ DECLARE_ALIGNED(16, unsigned char, thismb[256]); // 16x16 Y
+
+ unsigned char *thismb_ptr;
+ // 16 Y blocks, 4 U blocks, 4 V blocks,
+ // 1 DC 2nd order block each with 16 entries
+ BLOCK block[25];
+
+ YV12_BUFFER_CONFIG src;
+
+ MACROBLOCKD e_mbd;
+ PARTITION_INFO *partition_info; /* work pointer */
+ PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */
+ PARTITION_INFO *pip; /* Base of allocated array */
+
+ search_site *ss;
+ int ss_count;
+ int searches_per_step;
+
+ int errorperbit;
+ int sadperbit16;
+ int sadperbit4;
+ int rddiv;
+ int rdmult;
+ unsigned int *mb_activity_ptr;
+ int *mb_norm_activity_ptr;
+ signed int act_zbin_adj;
+
+ int mvcosts[2][MVvals + 1];
+ int *mvcost[2];
+ int mvsadcosts[2][MVfpvals + 1];
+ int *mvsadcost[2];
#if CONFIG_HIGH_PRECISION_MV
- int mvcosts_hp[2][MVvals_hp+1];
- int *mvcost_hp[2];
- int mvsadcosts_hp[2][MVfpvals_hp+1];
- int *mvsadcost_hp[2];
+ int mvcosts_hp[2][MVvals_hp + 1];
+ int *mvcost_hp[2];
+ int mvsadcosts_hp[2][MVfpvals_hp + 1];
+ int *mvsadcost_hp[2];
#endif
- int mbmode_cost[2][MB_MODE_COUNT];
- int intra_uv_mode_cost[2][MB_MODE_COUNT];
- int bmode_costs[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES];
- int i8x8_mode_costs[MB_MODE_COUNT];
- int inter_bmode_costs[B_MODE_COUNT];
-
- // These define limits to motion vector components to prevent them from extending outside the UMV borders
- int mv_col_min;
- int mv_col_max;
- int mv_row_min;
- int mv_row_max;
+ int mbmode_cost[2][MB_MODE_COUNT];
+ int intra_uv_mode_cost[2][MB_MODE_COUNT];
+ int bmode_costs[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES];
+ int i8x8_mode_costs[MB_MODE_COUNT];
+ int inter_bmode_costs[B_MODE_COUNT];
+
+ // These define limits to motion vector components to prevent them from extending outside the UMV borders
+ int mv_col_min;
+ int mv_col_max;
+ int mv_row_min;
+ int mv_row_max;
#if CONFIG_SUPERBLOCKS
- int mv_col_min_sb;
- int mv_col_max_sb;
- int mv_row_min_sb;
- int mv_row_max_sb;
+ int mv_col_min_sb;
+ int mv_col_max_sb;
+ int mv_row_min_sb;
+ int mv_row_max_sb;
#endif
- int skip;
+ int skip;
- int encode_breakout;
+ int encode_breakout;
- //char * gf_active_ptr;
- signed char *gf_active_ptr;
+ // char * gf_active_ptr;
+ signed char *gf_active_ptr;
- unsigned char *active_ptr;
- MV_CONTEXT *mvc;
+ unsigned char *active_ptr;
+ MV_CONTEXT *mvc;
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP *mvc_hp;
+ MV_CONTEXT_HP *mvc_hp;
#endif
- unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS]
- [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
- unsigned int token_costs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]
- [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
+ unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS]
+ [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
+ unsigned int token_costs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]
+ [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
- int optimize;
- int q_index;
+ int optimize;
+ int q_index;
- int encode_as_sb;
+ int encode_as_sb;
- // Structure to hold context for each of the 4 MBs within a SB:
- // when encoded as 4 independent MBs:
- PICK_MODE_CONTEXT mb_context[4];
+ // Structure to hold context for each of the 4 MBs within a SB:
+ // when encoded as 4 independent MBs:
+ PICK_MODE_CONTEXT mb_context[4];
#if CONFIG_SUPERBLOCKS
- // when 4 MBs share coding parameters:
- PICK_MODE_CONTEXT sb_context[4];
+ // when 4 MBs share coding parameters:
+ PICK_MODE_CONTEXT sb_context[4];
#endif
- void (*vp8_short_fdct4x4)(short *input, short *output, int pitch);
- void (*vp8_short_fdct8x4)(short *input, short *output, int pitch);
- void (*short_walsh4x4)(short *input, short *output, int pitch);
- void (*quantize_b)(BLOCK *b, BLOCKD *d);
- void (*quantize_b_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1);
- void (*vp8_short_fdct8x8)(short *input, short *output, int pitch);
- void (*short_fhaar2x2)(short *input, short *output, int pitch);
- void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d);
- void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d);
+ void (*vp8_short_fdct4x4)(short *input, short *output, int pitch);
+ void (*vp8_short_fdct8x4)(short *input, short *output, int pitch);
+ void (*short_walsh4x4)(short *input, short *output, int pitch);
+ void (*quantize_b)(BLOCK *b, BLOCKD *d);
+ void (*quantize_b_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1);
+ void (*vp8_short_fdct8x8)(short *input, short *output, int pitch);
+ void (*short_fhaar2x2)(short *input, short *output, int pitch);
+ void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d);
+ void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d);
} MACROBLOCK;
diff --git a/vp8/encoder/boolhuff.c b/vp8/encoder/boolhuff.c
index d96ca7d40..e23d32e85 100644
--- a/vp8/encoder/boolhuff.c
+++ b/vp8/encoder/boolhuff.c
@@ -20,149 +20,137 @@ unsigned __int64 Sectionbits[500];
unsigned int active_section = 0;
#endif
-const unsigned int vp8_prob_cost[256] =
-{
- 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, 1129, 1099, 1072, 1046,
- 1023, 1000, 979, 959, 940, 922, 905, 889, 873, 858, 843, 829, 816, 803, 790, 778,
- 767, 755, 744, 733, 723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625,
- 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, 534, 528, 522, 516,
- 511, 505, 499, 494, 488, 483, 477, 472, 467, 462, 457, 452, 447, 442, 437, 433,
- 428, 424, 419, 415, 410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365,
- 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, 317, 314, 311, 307,
- 304, 301, 297, 294, 291, 288, 285, 281, 278, 275, 272, 269, 266, 263, 260, 257,
- 255, 252, 249, 246, 243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214,
- 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, 181, 179, 177, 174,
- 172, 170, 168, 165, 163, 161, 159, 156, 154, 152, 150, 148, 145, 143, 141, 139,
- 137, 135, 133, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107,
- 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, 82, 81, 79, 77,
- 75, 73, 72, 70, 68, 66, 65, 63, 61, 60, 58, 56, 55, 53, 51, 50,
- 48, 46, 45, 43, 41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24,
- 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3, 1, 1
+const unsigned int vp8_prob_cost[256] = {
+ 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, 1129, 1099, 1072, 1046,
+ 1023, 1000, 979, 959, 940, 922, 905, 889, 873, 858, 843, 829, 816, 803, 790, 778,
+ 767, 755, 744, 733, 723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625,
+ 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, 534, 528, 522, 516,
+ 511, 505, 499, 494, 488, 483, 477, 472, 467, 462, 457, 452, 447, 442, 437, 433,
+ 428, 424, 419, 415, 410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365,
+ 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, 317, 314, 311, 307,
+ 304, 301, 297, 294, 291, 288, 285, 281, 278, 275, 272, 269, 266, 263, 260, 257,
+ 255, 252, 249, 246, 243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214,
+ 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, 181, 179, 177, 174,
+ 172, 170, 168, 165, 163, 161, 159, 156, 154, 152, 150, 148, 145, 143, 141, 139,
+ 137, 135, 133, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107,
+ 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, 82, 81, 79, 77,
+ 75, 73, 72, 70, 68, 66, 65, 63, 61, 60, 58, 56, 55, 53, 51, 50,
+ 48, 46, 45, 43, 41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24,
+ 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3, 1, 1
};
-void vp8_start_encode(BOOL_CODER *br, unsigned char *source)
-{
+void vp8_start_encode(BOOL_CODER *br, unsigned char *source) {
- br->lowvalue = 0;
- br->range = 255;
- br->value = 0;
- br->count = -24;
- br->buffer = source;
- br->pos = 0;
+ br->lowvalue = 0;
+ br->range = 255;
+ br->value = 0;
+ br->count = -24;
+ br->buffer = source;
+ br->pos = 0;
}
-void vp8_stop_encode(BOOL_CODER *br)
-{
- int i;
+void vp8_stop_encode(BOOL_CODER *br) {
+ int i;
- for (i = 0; i < 32; i++)
- vp8_encode_bool(br, 0, 128);
+ for (i = 0; i < 32; i++)
+ vp8_encode_bool(br, 0, 128);
}
-void vp8_encode_value(BOOL_CODER *br, int data, int bits)
-{
- int bit;
+void vp8_encode_value(BOOL_CODER *br, int data, int bits) {
+ int bit;
- for (bit = bits - 1; bit >= 0; bit--)
- vp8_encode_bool(br, (1 & (data >> bit)), 0x80);
+ for (bit = bits - 1; bit >= 0; bit--)
+ vp8_encode_bool(br, (1 & (data >> bit)), 0x80);
}
#if CONFIG_NEWUPDATE
-int recenter_nonneg(int v, int m)
-{
- if (v > (m<<1)) return v;
- else if (v >= m) return ((v-m)<<1);
- else return ((m-v)<<1)-1;
+int recenter_nonneg(int v, int m) {
+ if (v > (m << 1)) return v;
+ else if (v >= m) return ((v - m) << 1);
+ else return ((m - v) << 1) - 1;
}
-static int get_unsigned_bits(unsigned num_values)
-{
- int cat=0;
- if ((num_values--)<=1) return 0;
- while (num_values>0)
- {
- cat++;
- num_values>>=1;
- }
- return cat;
+static int get_unsigned_bits(unsigned num_values) {
+ int cat = 0;
+ if ((num_values--) <= 1) return 0;
+ while (num_values > 0) {
+ cat++;
+ num_values >>= 1;
+ }
+ return cat;
}
-void vp8_encode_uniform(BOOL_CODER *br, int v, int n)
-{
- int l = get_unsigned_bits(n);
- int m;
- if (l == 0) return;
- m = (1<<l)-n;
- if (v<m)
- vp8_encode_value(br, v, l-1);
- else
- {
- vp8_encode_value(br, m+((v-m)>>1), l-1);
- vp8_encode_value(br, (v-m)&1, 1);
- }
+void vp8_encode_uniform(BOOL_CODER *br, int v, int n) {
+ int l = get_unsigned_bits(n);
+ int m;
+ if (l == 0) return;
+ m = (1 << l) - n;
+ if (v < m)
+ vp8_encode_value(br, v, l - 1);
+ else {
+ vp8_encode_value(br, m + ((v - m) >> 1), l - 1);
+ vp8_encode_value(br, (v - m) & 1, 1);
+ }
}
-int vp8_count_uniform(int v, int n)
-{
- int l = get_unsigned_bits(n);
- int m;
- if (l == 0) return 0;
- m = (1<<l)-n;
- if (v<m)
- return l-1;
- else
- return l;
+int vp8_count_uniform(int v, int n) {
+ int l = get_unsigned_bits(n);
+ int m;
+ if (l == 0) return 0;
+ m = (1 << l) - n;
+ if (v < m)
+ return l - 1;
+ else
+ return l;
}
-void vp8_encode_term_subexp(BOOL_CODER *br, int word, int k, int num_syms)
-{
- int i = 0;
- int mk = 0;
- while (1) {
- int b = (i?k+i-1:k);
- int a = (1<<b);
- if (num_syms<=mk+3*a) {
- vp8_encode_uniform(br, word-mk, num_syms-mk);
- break;
- } else {
- int t = (word>=mk+a);
- vp8_encode_value(br, t, 1);
- if (t) {
- i=i+1;
- mk+=a;
- } else {
- vp8_encode_value(br, word-mk, b);
- break;
- }
- }
+void vp8_encode_term_subexp(BOOL_CODER *br, int word, int k, int num_syms) {
+ int i = 0;
+ int mk = 0;
+ while (1) {
+ int b = (i ? k + i - 1 : k);
+ int a = (1 << b);
+ if (num_syms <= mk + 3 * a) {
+ vp8_encode_uniform(br, word - mk, num_syms - mk);
+ break;
+ } else {
+ int t = (word >= mk + a);
+ vp8_encode_value(br, t, 1);
+ if (t) {
+ i = i + 1;
+ mk += a;
+ } else {
+ vp8_encode_value(br, word - mk, b);
+ break;
+ }
}
+ }
}
-int vp8_count_term_subexp(int word, int k, int num_syms)
-{
- int count = 0;
- int i = 0;
- int mk = 0;
- while (1) {
- int b = (i?k+i-1:k);
- int a = (1<<b);
- if (num_syms<=mk+3*a) {
- count += vp8_count_uniform(word-mk, num_syms-mk);
- break;
- } else {
- int t = (word>=mk+a);
- count++;
- if (t) {
- i=i+1;
- mk+=a;
- } else {
- count += b;
- break;
- }
- }
+int vp8_count_term_subexp(int word, int k, int num_syms) {
+ int count = 0;
+ int i = 0;
+ int mk = 0;
+ while (1) {
+ int b = (i ? k + i - 1 : k);
+ int a = (1 << b);
+ if (num_syms <= mk + 3 * a) {
+ count += vp8_count_uniform(word - mk, num_syms - mk);
+ break;
+ } else {
+ int t = (word >= mk + a);
+ count++;
+ if (t) {
+ i = i + 1;
+ mk += a;
+ } else {
+ count += b;
+ break;
+ }
}
- return count;
+ }
+ return count;
}
#endif
diff --git a/vp8/encoder/boolhuff.h b/vp8/encoder/boolhuff.h
index 1fb3cfadf..5b81b0670 100644
--- a/vp8/encoder/boolhuff.h
+++ b/vp8/encoder/boolhuff.h
@@ -21,18 +21,17 @@
#include "vpx_ports/mem.h"
-typedef struct
-{
- unsigned int lowvalue;
- unsigned int range;
- unsigned int value;
- int count;
- unsigned int pos;
- unsigned char *buffer;
-
- // Variables used to track bit costs without outputing to the bitstream
- unsigned int measure_cost;
- unsigned long bit_counter;
+typedef struct {
+ unsigned int lowvalue;
+ unsigned int range;
+ unsigned int value;
+ int count;
+ unsigned int pos;
+ unsigned char *buffer;
+
+ // Variables used to track bit costs without outputing to the bitstream
+ unsigned int measure_cost;
+ unsigned long bit_counter;
} BOOL_CODER;
extern void vp8_start_encode(BOOL_CODER *bc, unsigned char *buffer);
@@ -52,68 +51,63 @@ extern int recenter_nonneg(int v, int m);
DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
-static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability)
-{
- unsigned int split;
- int count = br->count;
- unsigned int range = br->range;
- unsigned int lowvalue = br->lowvalue;
- register unsigned int shift;
+static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability) {
+ unsigned int split;
+ int count = br->count;
+ unsigned int range = br->range;
+ unsigned int lowvalue = br->lowvalue;
+ register unsigned int shift;
#ifdef ENTROPY_STATS
#if defined(SECTIONBITS_OUTPUT)
- if (bit)
- Sectionbits[active_section] += vp8_prob_cost[255-probability];
- else
- Sectionbits[active_section] += vp8_prob_cost[probability];
+ if (bit)
+ Sectionbits[active_section] += vp8_prob_cost[255 - probability];
+ else
+ Sectionbits[active_section] += vp8_prob_cost[probability];
#endif
#endif
- split = 1 + (((range - 1) * probability) >> 8);
+ split = 1 + (((range - 1) * probability) >> 8);
- range = split;
+ range = split;
- if (bit)
- {
- lowvalue += split;
- range = br->range - split;
- }
-
- shift = vp8_norm[range];
+ if (bit) {
+ lowvalue += split;
+ range = br->range - split;
+ }
- range <<= shift;
- count += shift;
+ shift = vp8_norm[range];
- if (count >= 0)
- {
- int offset = shift - count;
+ range <<= shift;
+ count += shift;
- if ((lowvalue << (offset - 1)) & 0x80000000)
- {
- int x = br->pos - 1;
+ if (count >= 0) {
+ int offset = shift - count;
- while (x >= 0 && br->buffer[x] == 0xff)
- {
- br->buffer[x] = (unsigned char)0;
- x--;
- }
+ if ((lowvalue << (offset - 1)) & 0x80000000) {
+ int x = br->pos - 1;
- br->buffer[x] += 1;
- }
+ while (x >= 0 && br->buffer[x] == 0xff) {
+ br->buffer[x] = (unsigned char)0;
+ x--;
+ }
- br->buffer[br->pos++] = (lowvalue >> (24 - offset));
- lowvalue <<= offset;
- shift = count;
- lowvalue &= 0xffffff;
- count -= 8 ;
+ br->buffer[x] += 1;
}
- lowvalue <<= shift;
- br->count = count;
- br->lowvalue = lowvalue;
- br->range = range;
+ br->buffer[br->pos++] = (lowvalue >> (24 - offset));
+ lowvalue <<= offset;
+ shift = count;
+ lowvalue &= 0xffffff;
+ count -= 8;
+ }
+
+ lowvalue <<= shift;
+ br->count = count;
+ br->lowvalue = lowvalue;
+ br->range = range;
}
#endif
diff --git a/vp8/encoder/dct.c b/vp8/encoder/dct.c
index 568d0e087..b98e3f25d 100644
--- a/vp8/encoder/dct.c
+++ b/vp8/encoder/dct.c
@@ -31,234 +31,230 @@ static const int xC7S1 = 3196;
#define IN_SHIFT (FINAL_SHIFT+1)
-void vp8_short_fdct8x8_c ( short * InputData, short * OutputData, int pitch)
-{
- int loop;
- int short_pitch = pitch>>1;
- int is07, is12, is34, is56;
- int is0734, is1256;
- int id07, id12, id34, id56;
- int irot_input_x, irot_input_y;
- int icommon_product1; // Re-used product (c4s4 * (s12 - s56))
- int icommon_product2; // Re-used product (c4s4 * (d12 + d56))
- int temp1, temp2; // intermediate variable for computation
-
- int InterData[64];
- int *ip = InterData;
- short *op = OutputData;
-
- for (loop = 0; loop < 8; loop++)
- {
- // Pre calculate some common sums and differences.
- is07 = (InputData[0] + InputData[7])<<IN_SHIFT;
- is12 = (InputData[1] + InputData[2])<<IN_SHIFT;
- is34 = (InputData[3] + InputData[4])<<IN_SHIFT;
- is56 = (InputData[5] + InputData[6])<<IN_SHIFT;
- id07 = (InputData[0] - InputData[7])<<IN_SHIFT;
- id12 = (InputData[1] - InputData[2])<<IN_SHIFT;
- id34 = (InputData[3] - InputData[4])<<IN_SHIFT;
- id56 = (InputData[5] - InputData[6])<<IN_SHIFT;
-
- is0734 = is07 + is34;
- is1256 = is12 + is56;
-
- // Pre-Calculate some common product terms.
- icommon_product1 = xC4S4*(is12 - is56);
- DOROUND(icommon_product1)
- icommon_product1>>=SHIFT_BITS;
-
- icommon_product2 = xC4S4*(id12 + id56);
- DOROUND(icommon_product2)
- icommon_product2>>=SHIFT_BITS;
-
-
- ip[0] = (xC4S4*(is0734 + is1256));
- DOROUND(ip[0]);
- ip[0] >>= SHIFT_BITS;
-
- ip[4] = (xC4S4*(is0734 - is1256));
- DOROUND(ip[4]);
- ip[4] >>= SHIFT_BITS;
-
- // Define inputs to rotation for outputs 2 and 6
- irot_input_x = id12 - id56;
- irot_input_y = is07 - is34;
-
- // Apply rotation for outputs 2 and 6.
- temp1=xC6S2*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC2S6*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[2] = temp1 + temp2;
-
- temp1=xC6S2*irot_input_y;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC2S6*irot_input_x ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[6] = temp1 -temp2 ;
-
- // Define inputs to rotation for outputs 1 and 7
- irot_input_x = icommon_product1 + id07;
- irot_input_y = -( id34 + icommon_product2 );
-
- // Apply rotation for outputs 1 and 7.
- temp1=xC1S7*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC7S1*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[1] = temp1 - temp2;
-
- temp1=xC7S1*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC1S7*irot_input_y ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[7] = temp1 + temp2 ;
-
- // Define inputs to rotation for outputs 3 and 5
- irot_input_x = id07 - icommon_product1;
- irot_input_y = id34 - icommon_product2;
-
- // Apply rotation for outputs 3 and 5.
- temp1=xC3S5*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC5S3*irot_input_y ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[3] = temp1 - temp2 ;
-
-
- temp1=xC5S3*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC3S5*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- ip[5] = temp1 + temp2;
-
- // Increment data pointer for next row
- InputData += short_pitch ;
- ip += 8;
- }
+void vp8_short_fdct8x8_c(short *InputData, short *OutputData, int pitch) {
+ int loop;
+ int short_pitch = pitch >> 1;
+ int is07, is12, is34, is56;
+ int is0734, is1256;
+ int id07, id12, id34, id56;
+ int irot_input_x, irot_input_y;
+ int icommon_product1; // Re-used product (c4s4 * (s12 - s56))
+ int icommon_product2; // Re-used product (c4s4 * (d12 + d56))
+ int temp1, temp2; // intermediate variable for computation
+
+ int InterData[64];
+ int *ip = InterData;
+ short *op = OutputData;
+
+ for (loop = 0; loop < 8; loop++) {
+ // Pre calculate some common sums and differences.
+ is07 = (InputData[0] + InputData[7]) << IN_SHIFT;
+ is12 = (InputData[1] + InputData[2]) << IN_SHIFT;
+ is34 = (InputData[3] + InputData[4]) << IN_SHIFT;
+ is56 = (InputData[5] + InputData[6]) << IN_SHIFT;
+ id07 = (InputData[0] - InputData[7]) << IN_SHIFT;
+ id12 = (InputData[1] - InputData[2]) << IN_SHIFT;
+ id34 = (InputData[3] - InputData[4]) << IN_SHIFT;
+ id56 = (InputData[5] - InputData[6]) << IN_SHIFT;
+
+ is0734 = is07 + is34;
+ is1256 = is12 + is56;
+
+ // Pre-Calculate some common product terms.
+ icommon_product1 = xC4S4 * (is12 - is56);
+ DOROUND(icommon_product1)
+ icommon_product1 >>= SHIFT_BITS;
+
+ icommon_product2 = xC4S4 * (id12 + id56);
+ DOROUND(icommon_product2)
+ icommon_product2 >>= SHIFT_BITS;
+
+
+ ip[0] = (xC4S4 * (is0734 + is1256));
+ DOROUND(ip[0]);
+ ip[0] >>= SHIFT_BITS;
+
+ ip[4] = (xC4S4 * (is0734 - is1256));
+ DOROUND(ip[4]);
+ ip[4] >>= SHIFT_BITS;
+
+ // Define inputs to rotation for outputs 2 and 6
+ irot_input_x = id12 - id56;
+ irot_input_y = is07 - is34;
+
+ // Apply rotation for outputs 2 and 6.
+ temp1 = xC6S2 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC2S6 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[2] = temp1 + temp2;
+
+ temp1 = xC6S2 * irot_input_y;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC2S6 * irot_input_x;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[6] = temp1 - temp2;
+
+ // Define inputs to rotation for outputs 1 and 7
+ irot_input_x = icommon_product1 + id07;
+ irot_input_y = -(id34 + icommon_product2);
+
+ // Apply rotation for outputs 1 and 7.
+ temp1 = xC1S7 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC7S1 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[1] = temp1 - temp2;
+
+ temp1 = xC7S1 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC1S7 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[7] = temp1 + temp2;
+
+ // Define inputs to rotation for outputs 3 and 5
+ irot_input_x = id07 - icommon_product1;
+ irot_input_y = id34 - icommon_product2;
+
+ // Apply rotation for outputs 3 and 5.
+ temp1 = xC3S5 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC5S3 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[3] = temp1 - temp2;
+
+
+ temp1 = xC5S3 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC3S5 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ ip[5] = temp1 + temp2;
+
+ // Increment data pointer for next row
+ InputData += short_pitch;
+ ip += 8;
+ }
- // Performed DCT on rows, now transform the columns
- ip = InterData;
- for (loop = 0; loop < 8; loop++)
- {
- // Pre calculate some common sums and differences.
- is07 = ip[0 * 8] + ip[7 * 8];
- is12 = ip[1 * 8] + ip[2 * 8];
- is34 = ip[3 * 8] + ip[4 * 8];
- is56 = ip[5 * 8] + ip[6 * 8];
-
- id07 = ip[0 * 8] - ip[7 * 8];
- id12 = ip[1 * 8] - ip[2 * 8];
- id34 = ip[3 * 8] - ip[4 * 8];
- id56 = ip[5 * 8] - ip[6 * 8];
-
- is0734 = is07 + is34;
- is1256 = is12 + is56;
-
- // Pre-Calculate some common product terms
- icommon_product1 = xC4S4*(is12 - is56) ;
- icommon_product2 = xC4S4*(id12 + id56) ;
- DOROUND(icommon_product1)
- DOROUND(icommon_product2)
- icommon_product1>>=SHIFT_BITS;
- icommon_product2>>=SHIFT_BITS;
-
-
- temp1 = xC4S4*(is0734 + is1256) ;
- temp2 = xC4S4*(is0734 - is1256) ;
- DOROUND(temp1);
- DOROUND(temp2);
- temp1>>=SHIFT_BITS;
-
- temp2>>=SHIFT_BITS;
- op[0*8] = (temp1 + FINAL_ROUNDING)>>FINAL_SHIFT;
- op[4*8] = (temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
-
- // Define inputs to rotation for outputs 2 and 6
- irot_input_x = id12 - id56;
- irot_input_y = is07 - is34;
-
- // Apply rotation for outputs 2 and 6.
- temp1=xC6S2*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC2S6*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[2*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
-
- temp1=xC6S2*irot_input_y;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC2S6*irot_input_x ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[6*8] = (temp1 -temp2 + FINAL_ROUNDING)>>FINAL_SHIFT ;
-
- // Define inputs to rotation for outputs 1 and 7
- irot_input_x = icommon_product1 + id07;
- irot_input_y = -( id34 + icommon_product2 );
-
- // Apply rotation for outputs 1 and 7.
- temp1=xC1S7*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC7S1*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[1*8] = (temp1 - temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
-
- temp1=xC7S1*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC1S7*irot_input_y ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[7*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
-
- // Define inputs to rotation for outputs 3 and 5
- irot_input_x = id07 - icommon_product1;
- irot_input_y = id34 - icommon_product2;
-
- // Apply rotation for outputs 3 and 5.
- temp1=xC3S5*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC5S3*irot_input_y ;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[3*8] = (temp1 - temp2 + FINAL_ROUNDING)>>FINAL_SHIFT ;
-
-
- temp1=xC5S3*irot_input_x;
- DOROUND(temp1);
- temp1>>=SHIFT_BITS;
- temp2=xC3S5*irot_input_y;
- DOROUND(temp2);
- temp2>>=SHIFT_BITS;
- op[5*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
-
- // Increment data pointer for next column.
- ip ++;
- op ++;
- }
+ // Performed DCT on rows, now transform the columns
+ ip = InterData;
+ for (loop = 0; loop < 8; loop++) {
+ // Pre calculate some common sums and differences.
+ is07 = ip[0 * 8] + ip[7 * 8];
+ is12 = ip[1 * 8] + ip[2 * 8];
+ is34 = ip[3 * 8] + ip[4 * 8];
+ is56 = ip[5 * 8] + ip[6 * 8];
+
+ id07 = ip[0 * 8] - ip[7 * 8];
+ id12 = ip[1 * 8] - ip[2 * 8];
+ id34 = ip[3 * 8] - ip[4 * 8];
+ id56 = ip[5 * 8] - ip[6 * 8];
+
+ is0734 = is07 + is34;
+ is1256 = is12 + is56;
+
+ // Pre-Calculate some common product terms
+ icommon_product1 = xC4S4 * (is12 - is56);
+ icommon_product2 = xC4S4 * (id12 + id56);
+ DOROUND(icommon_product1)
+ DOROUND(icommon_product2)
+ icommon_product1 >>= SHIFT_BITS;
+ icommon_product2 >>= SHIFT_BITS;
+
+
+ temp1 = xC4S4 * (is0734 + is1256);
+ temp2 = xC4S4 * (is0734 - is1256);
+ DOROUND(temp1);
+ DOROUND(temp2);
+ temp1 >>= SHIFT_BITS;
+
+ temp2 >>= SHIFT_BITS;
+ op[0 * 8] = (temp1 + FINAL_ROUNDING) >> FINAL_SHIFT;
+ op[4 * 8] = (temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ // Define inputs to rotation for outputs 2 and 6
+ irot_input_x = id12 - id56;
+ irot_input_y = is07 - is34;
+
+ // Apply rotation for outputs 2 and 6.
+ temp1 = xC6S2 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC2S6 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[2 * 8] = (temp1 + temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ temp1 = xC6S2 * irot_input_y;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC2S6 * irot_input_x;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[6 * 8] = (temp1 - temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ // Define inputs to rotation for outputs 1 and 7
+ irot_input_x = icommon_product1 + id07;
+ irot_input_y = -(id34 + icommon_product2);
+
+ // Apply rotation for outputs 1 and 7.
+ temp1 = xC1S7 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC7S1 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[1 * 8] = (temp1 - temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ temp1 = xC7S1 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC1S7 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[7 * 8] = (temp1 + temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ // Define inputs to rotation for outputs 3 and 5
+ irot_input_x = id07 - icommon_product1;
+ irot_input_y = id34 - icommon_product2;
+
+ // Apply rotation for outputs 3 and 5.
+ temp1 = xC3S5 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC5S3 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[3 * 8] = (temp1 - temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+
+ temp1 = xC5S3 * irot_input_x;
+ DOROUND(temp1);
+ temp1 >>= SHIFT_BITS;
+ temp2 = xC3S5 * irot_input_y;
+ DOROUND(temp2);
+ temp2 >>= SHIFT_BITS;
+ op[5 * 8] = (temp1 + temp2 + FINAL_ROUNDING) >> FINAL_SHIFT;
+
+ // Increment data pointer for next column.
+ ip++;
+ op++;
+ }
}
#else
-void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
-{
+void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch) {
int j1, i, j, k;
float b[8];
float b1[8];
@@ -272,15 +268,12 @@ void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
float f6 = (float) .1913417;
float f7 = (float) .0975452;
pitch = pitch / 2;
- for (i = 0, k = 0; i < 8; i++, k += pitch)
- {
- for (j = 0; j < 8; j++)
- {
- b[j] = (float)( block[k + j]<<3);
+ for (i = 0, k = 0; i < 8; i++, k += pitch) {
+ for (j = 0; j < 8; j++) {
+ b[j] = (float)(block[k + j] << 3);
}
/* Horizontal transform */
- for (j = 0; j < 4; j++)
- {
+ for (j = 0; j < 4; j++) {
j1 = 7 - j;
b1[j] = b[j] + b[j1];
b1[j1] = b[j] - b[j1];
@@ -307,10 +300,8 @@ void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
d[i][3] = b1[6] * f3 - b1[5] * f5;
}
/* Vertical transform */
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 4; j++)
- {
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 4; j++) {
j1 = 7 - j;
b1[j] = d[j][i] + d[j1][i];
b1[j1] = d[j][i] - d[j1][i];
@@ -336,11 +327,9 @@ void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
d[7][i] = b1[7] * f7 - b1[4] * f1;
d[3][i] = b1[6] * f3 - b1[5] * f5;
}
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 8; j++)
- {
- *(coefs + j + i * 8) = (short) floor(d[i][j] +0.5);
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ *(coefs + j + i * 8) = (short) floor(d[i][j] + 0.5);
}
}
return;
@@ -348,207 +337,191 @@ void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
#endif
-void vp8_short_fhaar2x2_c(short *input, short *output, int pitch) //pitch = 8
-{
- /* [1 1 ; 1 -1] orthogonal transform */
- /* use position: 0,1, 4, 8 */
- int i;
- short *ip1 = input;
- short *op1 = output;
- for (i = 0; i < 16; i++)
- {
- op1[i] = 0;
- }
-
- op1[0]=(ip1[0] + ip1[1] + ip1[4] + ip1[8] + 1)>>1;
- op1[1]=(ip1[0] - ip1[1] + ip1[4] - ip1[8])>>1;
- op1[4]=(ip1[0] + ip1[1] - ip1[4] - ip1[8])>>1;
- op1[8]=(ip1[0] - ip1[1] - ip1[4] + ip1[8])>>1;
+void vp8_short_fhaar2x2_c(short *input, short *output, int pitch) { // pitch = 8
+ /* [1 1; 1 -1] orthogonal transform */
+ /* use position: 0,1, 4, 8 */
+ int i;
+ short *ip1 = input;
+ short *op1 = output;
+ for (i = 0; i < 16; i++) {
+ op1[i] = 0;
+ }
+
+ op1[0] = (ip1[0] + ip1[1] + ip1[4] + ip1[8] + 1) >> 1;
+ op1[1] = (ip1[0] - ip1[1] + ip1[4] - ip1[8]) >> 1;
+ op1[4] = (ip1[0] + ip1[1] - ip1[4] - ip1[8]) >> 1;
+ op1[8] = (ip1[0] - ip1[1] - ip1[4] + ip1[8]) >> 1;
}
-void vp8_short_fdct4x4_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
+void vp8_short_fdct4x4_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ((ip[0] + ip[3])<<5);
- b1 = ((ip[1] + ip[2])<<5);
- c1 = ((ip[1] - ip[2])<<5);
- d1 = ((ip[0] - ip[3])<<5);
+ for (i = 0; i < 4; i++) {
+ a1 = ((ip[0] + ip[3]) << 5);
+ b1 = ((ip[1] + ip[2]) << 5);
+ c1 = ((ip[1] - ip[2]) << 5);
+ d1 = ((ip[0] - ip[3]) << 5);
- op[0] = a1 + b1;
- op[2] = a1 - b1;
+ op[0] = a1 + b1;
+ op[2] = a1 - b1;
- op[1] = (c1 * 2217 + d1 * 5352 + 14500)>>12;
- op[3] = (d1 * 2217 - c1 * 5352 + 7500)>>12;
+ op[1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12;
+ op[3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12;
- ip += pitch / 2;
- op += 4;
+ ip += pitch / 2;
+ op += 4;
- }
- ip = output;
- op = output;
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[12];
- b1 = ip[4] + ip[8];
- c1 = ip[4] - ip[8];
- d1 = ip[0] - ip[12];
-
- op[0] = ( a1 + b1 + 7)>>4;
- op[8] = ( a1 - b1 + 7)>>4;
-
- op[4] =((c1 * 2217 + d1 * 5352 + 12000)>>16) + (d1!=0);
- op[12] = (d1 * 2217 - c1 * 5352 + 51000)>>16;
-
- ip++;
- op++;
- }
+ }
+ ip = output;
+ op = output;
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[12];
+ b1 = ip[4] + ip[8];
+ c1 = ip[4] - ip[8];
+ d1 = ip[0] - ip[12];
+
+ op[0] = (a1 + b1 + 7) >> 4;
+ op[8] = (a1 - b1 + 7) >> 4;
+
+ op[4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + (d1 != 0);
+ op[12] = (d1 * 2217 - c1 * 5352 + 51000) >> 16;
+
+ ip++;
+ op++;
+ }
}
-void vp8_short_fdct8x4_c(short *input, short *output, int pitch)
-{
- vp8_short_fdct4x4_c(input, output, pitch);
- vp8_short_fdct4x4_c(input + 4, output + 16, pitch);
+void vp8_short_fdct8x4_c(short *input, short *output, int pitch) {
+ vp8_short_fdct4x4_c(input, output, pitch);
+ vp8_short_fdct4x4_c(input + 4, output + 16, pitch);
}
-void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
- int pitch_short = pitch >>1;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
- b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
- c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
- d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
-
- op[0] = (a1 + b1 + 1)>>1;
- op[4] = (c1 + d1)>>1;
- op[8] = (a1 - b1)>>1;
- op[12]= (d1 - c1)>>1;
-
- ip++;
- op++;
- }
- ip = output;
- op = output;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[3];
- b1 = ip[1] + ip[2];
- c1 = ip[1] - ip[2];
- d1 = ip[0] - ip[3];
-
- op[0] = (a1 + b1 + 1)>>1;
- op[1] = (c1 + d1)>>1;
- op[2] = (a1 - b1)>>1;
- op[3] = (d1 - c1)>>1;
-
- ip += 4;
- op += 4;
- }
+void vp8_short_walsh4x4_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+ int pitch_short = pitch >> 1;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
+ b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
+ c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
+ d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[4] = (c1 + d1) >> 1;
+ op[8] = (a1 - b1) >> 1;
+ op[12] = (d1 - c1) >> 1;
+
+ ip++;
+ op++;
+ }
+ ip = output;
+ op = output;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[3];
+ b1 = ip[1] + ip[2];
+ c1 = ip[1] - ip[2];
+ d1 = ip[0] - ip[3];
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[1] = (c1 + d1) >> 1;
+ op[2] = (a1 - b1) >> 1;
+ op[3] = (d1 - c1) >> 1;
+
+ ip += 4;
+ op += 4;
+ }
}
#if CONFIG_LOSSLESS
-void vp8_short_walsh4x4_lossless_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
- int pitch_short = pitch >>1;
-
- for (i = 0; i < 4; i++)
- {
- a1 = (ip[0 * pitch_short] + ip[3 * pitch_short])>>Y2_WHT_UPSCALE_FACTOR;
- b1 = (ip[1 * pitch_short] + ip[2 * pitch_short])>>Y2_WHT_UPSCALE_FACTOR;
- c1 = (ip[1 * pitch_short] - ip[2 * pitch_short])>>Y2_WHT_UPSCALE_FACTOR;
- d1 = (ip[0 * pitch_short] - ip[3 * pitch_short])>>Y2_WHT_UPSCALE_FACTOR;
-
- op[0] = (a1 + b1 + 1)>>1;
- op[4] = (c1 + d1)>>1;
- op[8] = (a1 - b1)>>1;
- op[12]= (d1 - c1)>>1;
-
- ip++;
- op++;
- }
- ip = output;
- op = output;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[3];
- b1 = ip[1] + ip[2];
- c1 = ip[1] - ip[2];
- d1 = ip[0] - ip[3];
-
- op[0] = ((a1 + b1 + 1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[1] = ((c1 + d1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[2] = ((a1 - b1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
- op[3] = ((d1 - c1)>>1)<<Y2_WHT_UPSCALE_FACTOR;
-
- ip += 4;
- op += 4;
- }
+void vp8_short_walsh4x4_lossless_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+ int pitch_short = pitch >> 1;
+
+ for (i = 0; i < 4; i++) {
+ a1 = (ip[0 * pitch_short] + ip[3 * pitch_short]) >> Y2_WHT_UPSCALE_FACTOR;
+ b1 = (ip[1 * pitch_short] + ip[2 * pitch_short]) >> Y2_WHT_UPSCALE_FACTOR;
+ c1 = (ip[1 * pitch_short] - ip[2 * pitch_short]) >> Y2_WHT_UPSCALE_FACTOR;
+ d1 = (ip[0 * pitch_short] - ip[3 * pitch_short]) >> Y2_WHT_UPSCALE_FACTOR;
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[4] = (c1 + d1) >> 1;
+ op[8] = (a1 - b1) >> 1;
+ op[12] = (d1 - c1) >> 1;
+
+ ip++;
+ op++;
+ }
+ ip = output;
+ op = output;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[3];
+ b1 = ip[1] + ip[2];
+ c1 = ip[1] - ip[2];
+ d1 = ip[0] - ip[3];
+
+ op[0] = ((a1 + b1 + 1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[1] = ((c1 + d1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[2] = ((a1 - b1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+ op[3] = ((d1 - c1) >> 1) << Y2_WHT_UPSCALE_FACTOR;
+
+ ip += 4;
+ op += 4;
+ }
}
-void vp8_short_walsh4x4_x8_c(short *input, short *output, int pitch)
-{
- int i;
- int a1, b1, c1, d1;
- short *ip = input;
- short *op = output;
- int pitch_short = pitch >>1;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
- b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
- c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
- d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
-
- op[0] = (a1 + b1 +1)>>1;
- op[4] = (c1 + d1)>>1;
- op[8] = (a1 - b1)>>1;
- op[12]= (d1 - c1)>>1;
-
- ip++;
- op++;
- }
- ip = output;
- op = output;
-
- for (i = 0; i < 4; i++)
- {
- a1 = ip[0] + ip[3];
- b1 = ip[1] + ip[2];
- c1 = ip[1] - ip[2];
- d1 = ip[0] - ip[3];
-
- op[0] = ((a1 + b1 +1)>>1)<<WHT_UPSCALE_FACTOR;
- op[1] = ((c1 + d1)>>1)<<WHT_UPSCALE_FACTOR;
- op[2] = ((a1 - b1)>>1)<<WHT_UPSCALE_FACTOR;
- op[3] = ((d1 - c1)>>1)<<WHT_UPSCALE_FACTOR;
-
- ip += 4;
- op += 4;
- }
+void vp8_short_walsh4x4_x8_c(short *input, short *output, int pitch) {
+ int i;
+ int a1, b1, c1, d1;
+ short *ip = input;
+ short *op = output;
+ int pitch_short = pitch >> 1;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
+ b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
+ c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
+ d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
+
+ op[0] = (a1 + b1 + 1) >> 1;
+ op[4] = (c1 + d1) >> 1;
+ op[8] = (a1 - b1) >> 1;
+ op[12] = (d1 - c1) >> 1;
+
+ ip++;
+ op++;
+ }
+ ip = output;
+ op = output;
+
+ for (i = 0; i < 4; i++) {
+ a1 = ip[0] + ip[3];
+ b1 = ip[1] + ip[2];
+ c1 = ip[1] - ip[2];
+ d1 = ip[0] - ip[3];
+
+ op[0] = ((a1 + b1 + 1) >> 1) << WHT_UPSCALE_FACTOR;
+ op[1] = ((c1 + d1) >> 1) << WHT_UPSCALE_FACTOR;
+ op[2] = ((a1 - b1) >> 1) << WHT_UPSCALE_FACTOR;
+ op[3] = ((d1 - c1) >> 1) << WHT_UPSCALE_FACTOR;
+
+ ip += 4;
+ op += 4;
+ }
}
-void vp8_short_walsh8x4_x8_c(short *input, short *output, int pitch)
-{
+void vp8_short_walsh8x4_x8_c(short *input, short *output, int pitch) {
vp8_short_walsh4x4_x8_c(input, output, pitch);
vp8_short_walsh4x4_x8_c(input + 4, output + 16, pitch);
}
diff --git a/vp8/encoder/dct.h b/vp8/encoder/dct.h
index 2a059a0b1..6d2b736b3 100644
--- a/vp8/encoder/dct.h
+++ b/vp8/encoder/dct.h
@@ -66,15 +66,14 @@ extern prototype_fdct(vp8_short_walsh4x4_lossless_c);
#endif
typedef prototype_fdct(*vp8_fdct_fn_t);
-typedef struct
-{
- vp8_fdct_fn_t short8x8;
- vp8_fdct_fn_t haar_short2x2;
- vp8_fdct_fn_t short4x4;
- vp8_fdct_fn_t short8x4;
- vp8_fdct_fn_t fast4x4;
- vp8_fdct_fn_t fast8x4;
- vp8_fdct_fn_t walsh_short4x4;
+typedef struct {
+ vp8_fdct_fn_t short8x8;
+ vp8_fdct_fn_t haar_short2x2;
+ vp8_fdct_fn_t short4x4;
+ vp8_fdct_fn_t short8x4;
+ vp8_fdct_fn_t fast4x4;
+ vp8_fdct_fn_t fast8x4;
+ vp8_fdct_fn_t walsh_short4x4;
} vp8_fdct_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index be2d1f4e3..ee0ed2921 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -32,7 +32,7 @@
#include "vpx_ports/vpx_timer.h"
#include "vp8/common/pred_common.h"
-//#define DBG_PRNT_SEGMAP 1
+// #define DBG_PRNT_SEGMAP 1
#if CONFIG_RUNTIME_CPU_DETECT
#define RTCD(x) &cpi->common.rtcd.x
@@ -43,11 +43,11 @@
#endif
#ifdef ENC_DEBUG
-int enc_debug=0;
+int enc_debug = 0;
int mb_row_debug, mb_col_debug;
#endif
-extern void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
+extern void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t);
extern void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex);
extern void vp8_auto_select_speed(VP8_COMP *cpi);
@@ -66,7 +66,7 @@ void vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t,
int output_enabled);
void vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x,
TOKENEXTRA **t, int output_enabled);
-static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x );
+static void adjust_act_zbin(VP8_COMP *cpi, MACROBLOCK *x);
@@ -94,128 +94,116 @@ unsigned int b_modes[B_MODE_COUNT];
* Eventually this should be replaced by custom no-reference routines,
* which will be faster.
*/
-static const unsigned char VP8_VAR_OFFS[16]=
-{
- 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128
+static const unsigned char VP8_VAR_OFFS[16] = {
+ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128
};
// Original activity measure from Tim T's code.
-static unsigned int tt_activity_measure( VP8_COMP *cpi, MACROBLOCK *x )
-{
- unsigned int act;
- unsigned int sse;
- /* TODO: This could also be done over smaller areas (8x8), but that would
- * require extensive changes elsewhere, as lambda is assumed to be fixed
- * over an entire MB in most of the code.
- * Another option is to compute four 8x8 variances, and pick a single
- * lambda using a non-linear combination (e.g., the smallest, or second
- * smallest, etc.).
- */
- act = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)(x->src.y_buffer,
- x->src.y_stride, VP8_VAR_OFFS, 0, &sse);
- act = act<<4;
-
- /* If the region is flat, lower the activity some more. */
- if (act < 8<<12)
- act = act < 5<<12 ? act : 5<<12;
-
- return act;
+static unsigned int tt_activity_measure(VP8_COMP *cpi, MACROBLOCK *x) {
+ unsigned int act;
+ unsigned int sse;
+ /* TODO: This could also be done over smaller areas (8x8), but that would
+ * require extensive changes elsewhere, as lambda is assumed to be fixed
+ * over an entire MB in most of the code.
+ * Another option is to compute four 8x8 variances, and pick a single
+ * lambda using a non-linear combination (e.g., the smallest, or second
+ * smallest, etc.).
+ */
+ act = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)(x->src.y_buffer,
+ x->src.y_stride, VP8_VAR_OFFS, 0, &sse);
+ act = act << 4;
+
+ /* If the region is flat, lower the activity some more. */
+ if (act < 8 << 12)
+ act = act < 5 << 12 ? act : 5 << 12;
+
+ return act;
}
// Stub for alternative experimental activity measures.
-static unsigned int alt_activity_measure( VP8_COMP *cpi,
- MACROBLOCK *x, int use_dc_pred )
-{
- return vp8_encode_intra(cpi,x, use_dc_pred);
+static unsigned int alt_activity_measure(VP8_COMP *cpi,
+ MACROBLOCK *x, int use_dc_pred) {
+ return vp8_encode_intra(cpi, x, use_dc_pred);
}
// Measure the activity of the current macroblock
// What we measure here is TBD so abstracted to this function
#define ALT_ACT_MEASURE 1
-static unsigned int mb_activity_measure( VP8_COMP *cpi, MACROBLOCK *x,
- int mb_row, int mb_col)
-{
- unsigned int mb_activity;
+static unsigned int mb_activity_measure(VP8_COMP *cpi, MACROBLOCK *x,
+ int mb_row, int mb_col) {
+ unsigned int mb_activity;
- if ( ALT_ACT_MEASURE )
- {
- int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
+ if (ALT_ACT_MEASURE) {
+ int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
- // Or use and alternative.
- mb_activity = alt_activity_measure( cpi, x, use_dc_pred );
- }
- else
- {
- // Original activity measure from Tim T's code.
- mb_activity = tt_activity_measure( cpi, x );
- }
+ // Or use and alternative.
+ mb_activity = alt_activity_measure(cpi, x, use_dc_pred);
+ } else {
+ // Original activity measure from Tim T's code.
+ mb_activity = tt_activity_measure(cpi, x);
+ }
- if ( mb_activity < VP8_ACTIVITY_AVG_MIN )
- mb_activity = VP8_ACTIVITY_AVG_MIN;
+ if (mb_activity < VP8_ACTIVITY_AVG_MIN)
+ mb_activity = VP8_ACTIVITY_AVG_MIN;
- return mb_activity;
+ return mb_activity;
}
// Calculate an "average" mb activity value for the frame
#define ACT_MEDIAN 0
-static void calc_av_activity( VP8_COMP *cpi, int64_t activity_sum )
-{
+static void calc_av_activity(VP8_COMP *cpi, int64_t activity_sum) {
#if ACT_MEDIAN
- // Find median: Simple n^2 algorithm for experimentation
- {
- unsigned int median;
- unsigned int i,j;
- unsigned int * sortlist;
- unsigned int tmp;
-
- // Create a list to sort to
- CHECK_MEM_ERROR(sortlist,
- vpx_calloc(sizeof(unsigned int),
- cpi->common.MBs));
-
- // Copy map to sort list
- vpx_memcpy( sortlist, cpi->mb_activity_map,
- sizeof(unsigned int) * cpi->common.MBs );
-
-
- // Ripple each value down to its correct position
- for ( i = 1; i < cpi->common.MBs; i ++ )
- {
- for ( j = i; j > 0; j -- )
- {
- if ( sortlist[j] < sortlist[j-1] )
- {
- // Swap values
- tmp = sortlist[j-1];
- sortlist[j-1] = sortlist[j];
- sortlist[j] = tmp;
- }
- else
- break;
- }
- }
+ // Find median: Simple n^2 algorithm for experimentation
+ {
+ unsigned int median;
+ unsigned int i, j;
+ unsigned int *sortlist;
+ unsigned int tmp;
+
+ // Create a list to sort to
+ CHECK_MEM_ERROR(sortlist,
+ vpx_calloc(sizeof(unsigned int),
+ cpi->common.MBs));
+
+ // Copy map to sort list
+ vpx_memcpy(sortlist, cpi->mb_activity_map,
+ sizeof(unsigned int) * cpi->common.MBs);
+
+
+ // Ripple each value down to its correct position
+ for (i = 1; i < cpi->common.MBs; i ++) {
+ for (j = i; j > 0; j --) {
+ if (sortlist[j] < sortlist[j - 1]) {
+ // Swap values
+ tmp = sortlist[j - 1];
+ sortlist[j - 1] = sortlist[j];
+ sortlist[j] = tmp;
+ } else
+ break;
+ }
+ }
- // Even number MBs so estimate median as mean of two either side.
- median = ( 1 + sortlist[cpi->common.MBs >> 1] +
- sortlist[(cpi->common.MBs >> 1) + 1] ) >> 1;
+ // Even number MBs so estimate median as mean of two either side.
+ median = (1 + sortlist[cpi->common.MBs >> 1] +
+ sortlist[(cpi->common.MBs >> 1) + 1]) >> 1;
- cpi->activity_avg = median;
+ cpi->activity_avg = median;
- vpx_free(sortlist);
- }
+ vpx_free(sortlist);
+ }
#else
- // Simple mean for now
- cpi->activity_avg = (unsigned int)(activity_sum/cpi->common.MBs);
+ // Simple mean for now
+ cpi->activity_avg = (unsigned int)(activity_sum / cpi->common.MBs);
#endif
- if (cpi->activity_avg < VP8_ACTIVITY_AVG_MIN)
- cpi->activity_avg = VP8_ACTIVITY_AVG_MIN;
+ if (cpi->activity_avg < VP8_ACTIVITY_AVG_MIN)
+ cpi->activity_avg = VP8_ACTIVITY_AVG_MIN;
- // Experimental code: return fixed value normalized for several clips
- if ( ALT_ACT_MEASURE )
- cpi->activity_avg = 100000;
+ // Experimental code: return fixed value normalized for several clips
+ if (ALT_ACT_MEASURE)
+ cpi->activity_avg = 100000;
}
#define USE_ACT_INDEX 0
@@ -223,56 +211,53 @@ static void calc_av_activity( VP8_COMP *cpi, int64_t activity_sum )
#if USE_ACT_INDEX
// Calculate and activity index for each mb
-static void calc_activity_index( VP8_COMP *cpi, MACROBLOCK *x )
-{
- VP8_COMMON *const cm = & cpi->common;
- int mb_row, mb_col;
+static void calc_activity_index(VP8_COMP *cpi, MACROBLOCK *x) {
+ VP8_COMMON *const cm = & cpi->common;
+ int mb_row, mb_col;
- int64_t act;
- int64_t a;
- int64_t b;
+ int64_t act;
+ int64_t a;
+ int64_t b;
#if OUTPUT_NORM_ACT_STATS
- FILE *f = fopen("norm_act.stt", "a");
- fprintf(f, "\n%12d\n", cpi->activity_avg );
+ FILE *f = fopen("norm_act.stt", "a");
+ fprintf(f, "\n%12d\n", cpi->activity_avg);
#endif
- // Reset pointers to start of activity map
- x->mb_activity_ptr = cpi->mb_activity_map;
+ // Reset pointers to start of activity map
+ x->mb_activity_ptr = cpi->mb_activity_map;
- // Calculate normalized mb activity number.
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- // for each macroblock col in image
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- // Read activity from the map
- act = *(x->mb_activity_ptr);
+ // Calculate normalized mb activity number.
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ // for each macroblock col in image
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ // Read activity from the map
+ act = *(x->mb_activity_ptr);
- // Calculate a normalized activity number
- a = act + 4*cpi->activity_avg;
- b = 4*act + cpi->activity_avg;
+ // Calculate a normalized activity number
+ a = act + 4 * cpi->activity_avg;
+ b = 4 * act + cpi->activity_avg;
- if ( b >= a )
- *(x->activity_ptr) = (int)((b + (a>>1))/a) - 1;
- else
- *(x->activity_ptr) = 1 - (int)((a + (b>>1))/b);
+ if (b >= a)
+ *(x->activity_ptr) = (int)((b + (a >> 1)) / a) - 1;
+ else
+ *(x->activity_ptr) = 1 - (int)((a + (b >> 1)) / b);
#if OUTPUT_NORM_ACT_STATS
- fprintf(f, " %6d", *(x->mb_activity_ptr));
+ fprintf(f, " %6d", *(x->mb_activity_ptr));
#endif
- // Increment activity map pointers
- x->mb_activity_ptr++;
- }
+ // Increment activity map pointers
+ x->mb_activity_ptr++;
+ }
#if OUTPUT_NORM_ACT_STATS
- fprintf(f, "\n");
+ fprintf(f, "\n");
#endif
- }
+ }
#if OUTPUT_NORM_ACT_STATS
- fclose(f);
+ fclose(f);
#endif
}
@@ -280,1384 +265,1285 @@ static void calc_activity_index( VP8_COMP *cpi, MACROBLOCK *x )
// Loop through all MBs. Note activity of each, average activity and
// calculate a normalized activity for each
-static void build_activity_map( VP8_COMP *cpi )
-{
- MACROBLOCK *const x = & cpi->mb;
- MACROBLOCKD *xd = &x->e_mbd;
- VP8_COMMON *const cm = & cpi->common;
+static void build_activity_map(VP8_COMP *cpi) {
+ MACROBLOCK *const x = & cpi->mb;
+ MACROBLOCKD *xd = &x->e_mbd;
+ VP8_COMMON *const cm = & cpi->common;
#if ALT_ACT_MEASURE
- YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
- int recon_yoffset;
- int recon_y_stride = new_yv12->y_stride;
+ YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
+ int recon_yoffset;
+ int recon_y_stride = new_yv12->y_stride;
#endif
- int mb_row, mb_col;
- unsigned int mb_activity;
- int64_t activity_sum = 0;
+ int mb_row, mb_col;
+ unsigned int mb_activity;
+ int64_t activity_sum = 0;
- // for each macroblock row in image
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
+ // for each macroblock row in image
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
#if ALT_ACT_MEASURE
- // reset above block coeffs
- xd->up_available = (mb_row != 0);
- recon_yoffset = (mb_row * recon_y_stride * 16);
+ // reset above block coeffs
+ xd->up_available = (mb_row != 0);
+ recon_yoffset = (mb_row * recon_y_stride * 16);
#endif
- // for each macroblock col in image
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
+ // for each macroblock col in image
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
#if ALT_ACT_MEASURE
- xd->dst.y_buffer = new_yv12->y_buffer + recon_yoffset;
- xd->left_available = (mb_col != 0);
- recon_yoffset += 16;
+ xd->dst.y_buffer = new_yv12->y_buffer + recon_yoffset;
+ xd->left_available = (mb_col != 0);
+ recon_yoffset += 16;
#endif
- //Copy current mb to a buffer
- RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
- x->src.y_stride,
- x->thismb, 16);
+ // Copy current mb to a buffer
+ RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
+ x->src.y_stride,
+ x->thismb, 16);
- // measure activity
- mb_activity = mb_activity_measure( cpi, x, mb_row, mb_col );
+ // measure activity
+ mb_activity = mb_activity_measure(cpi, x, mb_row, mb_col);
- // Keep frame sum
- activity_sum += mb_activity;
+ // Keep frame sum
+ activity_sum += mb_activity;
- // Store MB level activity details.
- *x->mb_activity_ptr = mb_activity;
+ // Store MB level activity details.
+ *x->mb_activity_ptr = mb_activity;
- // Increment activity map pointer
- x->mb_activity_ptr++;
+ // Increment activity map pointer
+ x->mb_activity_ptr++;
- // adjust to the next column of source macroblocks
- x->src.y_buffer += 16;
- }
+ // adjust to the next column of source macroblocks
+ x->src.y_buffer += 16;
+ }
- // adjust to the next row of mbs
- x->src.y_buffer += 16 * x->src.y_stride - 16 * cm->mb_cols;
+ // adjust to the next row of mbs
+ x->src.y_buffer += 16 * x->src.y_stride - 16 * cm->mb_cols;
#if ALT_ACT_MEASURE
- //extend the recon for intra prediction
- vp8_extend_mb_row(new_yv12, xd->dst.y_buffer + 16,
- xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
+ // extend the recon for intra prediction
+ vp8_extend_mb_row(new_yv12, xd->dst.y_buffer + 16,
+ xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
#endif
- }
+ }
- // Calculate an "average" MB activity
- calc_av_activity(cpi, activity_sum);
+ // Calculate an "average" MB activity
+ calc_av_activity(cpi, activity_sum);
#if USE_ACT_INDEX
- // Calculate an activity index number of each mb
- calc_activity_index( cpi, x );
+ // Calculate an activity index number of each mb
+ calc_activity_index(cpi, x);
#endif
}
// Macroblock activity masking
-void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x)
-{
+void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x) {
#if USE_ACT_INDEX
- x->rdmult += *(x->mb_activity_ptr) * (x->rdmult >> 2);
- x->errorperbit = x->rdmult * 100 /(110 * x->rddiv);
- x->errorperbit += (x->errorperbit==0);
+ x->rdmult += *(x->mb_activity_ptr) * (x->rdmult >> 2);
+ x->errorperbit = x->rdmult * 100 / (110 * x->rddiv);
+ x->errorperbit += (x->errorperbit == 0);
#else
- int64_t a;
- int64_t b;
- int64_t act = *(x->mb_activity_ptr);
+ int64_t a;
+ int64_t b;
+ int64_t act = *(x->mb_activity_ptr);
- // Apply the masking to the RD multiplier.
- a = act + (2*cpi->activity_avg);
- b = (2*act) + cpi->activity_avg;
+ // Apply the masking to the RD multiplier.
+ a = act + (2 * cpi->activity_avg);
+ b = (2 * act) + cpi->activity_avg;
- x->rdmult = (unsigned int)(((int64_t)x->rdmult*b + (a>>1))/a);
- x->errorperbit = x->rdmult * 100 /(110 * x->rddiv);
- x->errorperbit += (x->errorperbit==0);
+ x->rdmult = (unsigned int)(((int64_t)x->rdmult * b + (a >> 1)) / a);
+ x->errorperbit = x->rdmult * 100 / (110 * x->rddiv);
+ x->errorperbit += (x->errorperbit == 0);
#endif
- // Activity based Zbin adjustment
- adjust_act_zbin(cpi, x);
+ // Activity based Zbin adjustment
+ adjust_act_zbin(cpi, x);
}
-static void update_state (VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx)
-{
- int i;
- MACROBLOCKD *xd = &x->e_mbd;
- MODE_INFO *mi = &ctx->mic;
- int mb_mode = mi->mbmi.mode;
- int mb_mode_index = ctx->best_mode_index;
+static void update_state(VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) {
+ int i;
+ MACROBLOCKD *xd = &x->e_mbd;
+ MODE_INFO *mi = &ctx->mic;
+ int mb_mode = mi->mbmi.mode;
+ int mb_mode_index = ctx->best_mode_index;
#if CONFIG_DEBUG
- assert (mb_mode < MB_MODE_COUNT);
- assert (mb_mode_index < MAX_MODES);
- assert (mi->mbmi.ref_frame < MAX_REF_FRAMES);
+ assert(mb_mode < MB_MODE_COUNT);
+ assert(mb_mode_index < MAX_MODES);
+ assert(mi->mbmi.ref_frame < MAX_REF_FRAMES);
#endif
- // Restore the coding context of the MB to that that was in place
- // when the mode was picked for it
- vpx_memcpy(xd->mode_info_context, mi, sizeof(MODE_INFO));
+ // Restore the coding context of the MB to that that was in place
+ // when the mode was picked for it
+ vpx_memcpy(xd->mode_info_context, mi, sizeof(MODE_INFO));
- if (mb_mode == B_PRED)
- {
- for (i = 0; i < 16; i++)
- {
- xd->block[i].bmi.as_mode = xd->mode_info_context->bmi[i].as_mode;
- assert (xd->block[i].bmi.as_mode.first < MB_MODE_COUNT);
- }
+ if (mb_mode == B_PRED) {
+ for (i = 0; i < 16; i++) {
+ xd->block[i].bmi.as_mode = xd->mode_info_context->bmi[i].as_mode;
+ assert(xd->block[i].bmi.as_mode.first < MB_MODE_COUNT);
}
- else if (mb_mode == I8X8_PRED)
- {
- for (i = 0; i < 16; i++)
- {
- xd->block[i].bmi = xd->mode_info_context->bmi[i];
- }
- }
- else if (mb_mode == SPLITMV)
- {
- vpx_memcpy(x->partition_info, &ctx->partition_info,
- sizeof(PARTITION_INFO));
-
- xd->mode_info_context->mbmi.mv.as_int =
- x->partition_info->bmi[15].mv.as_int;
- xd->mode_info_context->mbmi.second_mv.as_int =
- x->partition_info->bmi[15].second_mv.as_int;
+ } else if (mb_mode == I8X8_PRED) {
+ for (i = 0; i < 16; i++) {
+ xd->block[i].bmi = xd->mode_info_context->bmi[i];
}
-
- if (cpi->common.frame_type == KEY_FRAME)
- {
- // Restore the coding modes to that held in the coding context
- //if (mb_mode == B_PRED)
- // for (i = 0; i < 16; i++)
- // {
- // xd->block[i].bmi.as_mode =
- // xd->mode_info_context->bmi[i].as_mode;
- // assert(xd->mode_info_context->bmi[i].as_mode < MB_MODE_COUNT);
- // }
+ } else if (mb_mode == SPLITMV) {
+ vpx_memcpy(x->partition_info, &ctx->partition_info,
+ sizeof(PARTITION_INFO));
+
+ xd->mode_info_context->mbmi.mv.as_int =
+ x->partition_info->bmi[15].mv.as_int;
+ xd->mode_info_context->mbmi.second_mv.as_int =
+ x->partition_info->bmi[15].second_mv.as_int;
+ }
+
+ if (cpi->common.frame_type == KEY_FRAME) {
+ // Restore the coding modes to that held in the coding context
+ // if (mb_mode == B_PRED)
+ // for (i = 0; i < 16; i++)
+ // {
+ // xd->block[i].bmi.as_mode =
+ // xd->mode_info_context->bmi[i].as_mode;
+ // assert(xd->mode_info_context->bmi[i].as_mode < MB_MODE_COUNT);
+ // }
#if CONFIG_INTERNAL_STATS
- static const int kf_mode_index[] = {
- THR_DC /*DC_PRED*/,
- THR_V_PRED /*V_PRED*/,
- THR_H_PRED /*H_PRED*/,
+ static const int kf_mode_index[] = {
+ THR_DC /*DC_PRED*/,
+ THR_V_PRED /*V_PRED*/,
+ THR_H_PRED /*H_PRED*/,
#if CONFIG_NEWINTRAMODES
- THR_D45_PRED /*D45_PRED*/,
- THR_D135_PRED /*D135_PRED*/,
- THR_D117_PRED /*D117_PRED*/,
- THR_D153_PRED /*D153_PRED*/,
- THR_D27_PRED /*D27_PRED*/,
- THR_D63_PRED /*D63_PRED*/,
+ THR_D45_PRED /*D45_PRED*/,
+ THR_D135_PRED /*D135_PRED*/,
+ THR_D117_PRED /*D117_PRED*/,
+ THR_D153_PRED /*D153_PRED*/,
+ THR_D27_PRED /*D27_PRED*/,
+ THR_D63_PRED /*D63_PRED*/,
#endif
- THR_TM /*TM_PRED*/,
- THR_I8X8_PRED /*I8X8_PRED*/,
- THR_B_PRED /*B_PRED*/,
- };
- cpi->mode_chosen_counts[kf_mode_index[mb_mode]]++;
+ THR_TM /*TM_PRED*/,
+ THR_I8X8_PRED /*I8X8_PRED*/,
+ THR_B_PRED /*B_PRED*/,
+ };
+ cpi->mode_chosen_counts[kf_mode_index[mb_mode]]++;
#endif
- }
- else
- {
-/*
- // Reduce the activation RD thresholds for the best choice mode
- if ((cpi->rd_baseline_thresh[mb_mode_index] > 0) &&
- (cpi->rd_baseline_thresh[mb_mode_index] < (INT_MAX >> 2)))
- {
- int best_adjustment = (cpi->rd_thresh_mult[mb_mode_index] >> 2);
+ } else {
+ /*
+ // Reduce the activation RD thresholds for the best choice mode
+ if ((cpi->rd_baseline_thresh[mb_mode_index] > 0) &&
+ (cpi->rd_baseline_thresh[mb_mode_index] < (INT_MAX >> 2)))
+ {
+ int best_adjustment = (cpi->rd_thresh_mult[mb_mode_index] >> 2);
- cpi->rd_thresh_mult[mb_mode_index] =
- (cpi->rd_thresh_mult[mb_mode_index]
- >= (MIN_THRESHMULT + best_adjustment)) ?
- cpi->rd_thresh_mult[mb_mode_index] - best_adjustment :
- MIN_THRESHMULT;
- cpi->rd_threshes[mb_mode_index] =
- (cpi->rd_baseline_thresh[mb_mode_index] >> 7)
- * cpi->rd_thresh_mult[mb_mode_index];
+ cpi->rd_thresh_mult[mb_mode_index] =
+ (cpi->rd_thresh_mult[mb_mode_index]
+ >= (MIN_THRESHMULT + best_adjustment)) ?
+ cpi->rd_thresh_mult[mb_mode_index] - best_adjustment :
+ MIN_THRESHMULT;
+ cpi->rd_threshes[mb_mode_index] =
+ (cpi->rd_baseline_thresh[mb_mode_index] >> 7)
+ * cpi->rd_thresh_mult[mb_mode_index];
- }
-*/
- // Note how often each mode chosen as best
- cpi->mode_chosen_counts[mb_mode_index]++;
+ }
+ */
+ // Note how often each mode chosen as best
+ cpi->mode_chosen_counts[mb_mode_index]++;
- rd_update_mvcount(cpi, x, &ctx->best_ref_mv, &ctx->second_best_ref_mv);
+ rd_update_mvcount(cpi, x, &ctx->best_ref_mv, &ctx->second_best_ref_mv);
- cpi->prediction_error += ctx->distortion;
- cpi->intra_error += ctx->intra_error;
- }
+ cpi->prediction_error += ctx->distortion;
+ cpi->intra_error += ctx->intra_error;
+ }
}
-static void pick_mb_modes (VP8_COMP *cpi,
- VP8_COMMON *cm,
- int mb_row,
- int mb_col,
- MACROBLOCK *x,
- MACROBLOCKD *xd,
- TOKENEXTRA **tp,
- int *totalrate)
-{
- int i;
- int map_index;
- int recon_yoffset, recon_uvoffset;
- int ref_fb_idx = cm->lst_fb_idx;
- int dst_fb_idx = cm->new_fb_idx;
- int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
- int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
- ENTROPY_CONTEXT_PLANES left_context[2];
- ENTROPY_CONTEXT_PLANES above_context[2];
- ENTROPY_CONTEXT_PLANES *initial_above_context_ptr = cm->above_context
- + mb_col;
-
- // Offsets to move pointers from MB to MB within a SB in raster order
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
-
- /* Function should not modify L & A contexts; save and restore on exit */
- vpx_memcpy (left_context,
- cpi->left_context,
- sizeof(left_context));
- vpx_memcpy (above_context,
- initial_above_context_ptr,
- sizeof(above_context));
-
- /* Encode MBs in raster order within the SB */
- for ( i=0; i<4; i++ )
- {
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_unextended = dy * cm->mb_cols + dx;
- int offset_extended = dy * xd->mode_info_stride + dx;
-
- // TODO Many of the index items here can be computed more efficiently!
-
- if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols))
- {
- // MB lies outside frame, move on
- mb_row += dy;
- mb_col += dx;
-
- // Update pointers
- x->src.y_buffer += 16 * (dx + dy*x->src.y_stride);
- x->src.u_buffer += 8 * (dx + dy*x->src.uv_stride);
- x->src.v_buffer += 8 * (dx + dy*x->src.uv_stride);
-
- x->gf_active_ptr += offset_unextended;
- x->partition_info += offset_extended;
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
+static void pick_mb_modes(VP8_COMP *cpi,
+ VP8_COMMON *cm,
+ int mb_row,
+ int mb_col,
+ MACROBLOCK *x,
+ MACROBLOCKD *xd,
+ TOKENEXTRA **tp,
+ int *totalrate) {
+ int i;
+ int map_index;
+ int recon_yoffset, recon_uvoffset;
+ int ref_fb_idx = cm->lst_fb_idx;
+ int dst_fb_idx = cm->new_fb_idx;
+ int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
+ int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
+ ENTROPY_CONTEXT_PLANES left_context[2];
+ ENTROPY_CONTEXT_PLANES above_context[2];
+ ENTROPY_CONTEXT_PLANES *initial_above_context_ptr = cm->above_context
+ + mb_col;
+
+ // Offsets to move pointers from MB to MB within a SB in raster order
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
+
+ /* Function should not modify L & A contexts; save and restore on exit */
+ vpx_memcpy(left_context,
+ cpi->left_context,
+ sizeof(left_context));
+ vpx_memcpy(above_context,
+ initial_above_context_ptr,
+ sizeof(above_context));
+
+ /* Encode MBs in raster order within the SB */
+ for (i = 0; i < 4; i++) {
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_unextended = dy * cm->mb_cols + dx;
+ int offset_extended = dy * xd->mode_info_stride + dx;
+
+ // TODO Many of the index items here can be computed more efficiently!
+
+ if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols)) {
+ // MB lies outside frame, move on
+ mb_row += dy;
+ mb_col += dx;
+
+ // Update pointers
+ x->src.y_buffer += 16 * (dx + dy * x->src.y_stride);
+ x->src.u_buffer += 8 * (dx + dy * x->src.uv_stride);
+ x->src.v_buffer += 8 * (dx + dy * x->src.uv_stride);
+
+ x->gf_active_ptr += offset_unextended;
+ x->partition_info += offset_extended;
+ xd->mode_info_context += offset_extended;
+ xd->prev_mode_info_context += offset_extended;
#if CONFIG_DEBUG
- assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
- (xd->mode_info_context - cpi->common.mip));
+ assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
+ (xd->mode_info_context - cpi->common.mip));
#endif
- continue;
- }
-
- // Index of the MB in the SB 0..3
- xd->mb_index = i;
-
- map_index = (mb_row * cpi->common.mb_cols) + mb_col;
- x->mb_activity_ptr = &cpi->mb_activity_map[map_index];
-
- // set above context pointer
- xd->above_context = cm->above_context + mb_col;
-
- // Restore the appropriate left context depending on which
- // row in the SB the MB is situated
- vpx_memcpy (&cm->left_context,
- &cpi->left_context[i>>1],
- sizeof(ENTROPY_CONTEXT_PLANES));
-
- // Set up distance of MB to edge of frame in 1/8th pel units
- xd->mb_to_top_edge = -((mb_row * 16) << 3);
- xd->mb_to_left_edge = -((mb_col * 16) << 3);
- xd->mb_to_bottom_edge = ((cm->mb_rows - 1 - mb_row) * 16) << 3;
- xd->mb_to_right_edge = ((cm->mb_cols - 1 - mb_col) * 16) << 3;
-
- // Set up limit values for MV components to prevent them from
- // extending beyond the UMV borders assuming 16x16 block size
- x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
- (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
- x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
- (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
-
- xd->up_available = (mb_row != 0);
- xd->left_available = (mb_col != 0);
-
- recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
-
- xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
- xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
- xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
-
- // Copy current MB to a work buffer
- RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
- x->src.y_stride,
- x->thismb, 16);
-
- x->rddiv = cpi->RDDIV;
- x->rdmult = cpi->RDMULT;
-
- if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
- vp8_activity_masking(cpi, x);
-
- // Is segmentation enabled
- if (xd->segmentation_enabled)
- {
- // Code to set segment id in xd->mbmi.segment_id
- if (cpi->segmentation_map[map_index] <= 3)
- xd->mode_info_context->mbmi.segment_id =
- cpi->segmentation_map[map_index];
- else
- xd->mode_info_context->mbmi.segment_id = 0;
-
- vp8cx_mb_init_quantizer(cpi, x);
- }
- else
- // Set to Segment 0 by default
- xd->mode_info_context->mbmi.segment_id = 0;
-
- x->active_ptr = cpi->active_map + map_index;
-
- /* force 4x4 transform for mode selection */
- xd->mode_info_context->mbmi.txfm_size = TX_4X4; // TODO IS this right??
-
- cpi->update_context = 0; // TODO Do we need this now??
-
- // Find best coding mode & reconstruct the MB so it is available
- // as a predictor for MBs that follow in the SB
- if (cm->frame_type == KEY_FRAME)
- {
- *totalrate += vp8_rd_pick_intra_mode(cpi, x);
-
- // Save the coding context
- vpx_memcpy (&x->mb_context[i].mic, xd->mode_info_context,
- sizeof(MODE_INFO));
-
- // Dummy encode, do not do the tokenization
- vp8cx_encode_intra_macro_block(cpi, x, tp, 0);
- //Note the encoder may have changed the segment_id
- }
- else
- {
- int seg_id;
-
- if (xd->segmentation_enabled && cpi->seg0_cnt > 0 &&
- !segfeature_active( xd, 0, SEG_LVL_REF_FRAME ) &&
- segfeature_active( xd, 1, SEG_LVL_REF_FRAME ) &&
- check_segref(xd, 1, INTRA_FRAME) +
- check_segref(xd, 1, LAST_FRAME) +
- check_segref(xd, 1, GOLDEN_FRAME) +
- check_segref(xd, 1, ALTREF_FRAME) == 1)
- {
- cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt;
- }
- else
- {
- cpi->seg0_progress = (((mb_col & ~1) * 2 + (mb_row & ~1) * cm->mb_cols + i) << 16) / cm->MBs;
- }
-
- *totalrate += vp8cx_pick_mode_inter_macroblock(cpi, x,
- recon_yoffset,
- recon_uvoffset);
-
- // Dummy encode, do not do the tokenization
- vp8cx_encode_inter_macroblock(cpi, x, tp,
- recon_yoffset, recon_uvoffset, 0);
-
- seg_id = xd->mode_info_context->mbmi.segment_id;
- if (cpi->mb.e_mbd.segmentation_enabled && seg_id == 0)
- {
- cpi->seg0_idx++;
- }
- if (!xd->segmentation_enabled ||
- !segfeature_active( xd, seg_id, SEG_LVL_REF_FRAME ) ||
- check_segref(xd, seg_id, INTRA_FRAME) +
- check_segref(xd, seg_id, LAST_FRAME) +
- check_segref(xd, seg_id, GOLDEN_FRAME) +
- check_segref(xd, seg_id, ALTREF_FRAME) > 1)
- {
- // Get the prediction context and status
- int pred_flag = get_pred_flag( xd, PRED_REF );
- int pred_context = get_pred_context( cm, xd, PRED_REF );
+ continue;
+ }
- // Count prediction success
- cpi->ref_pred_count[pred_context][pred_flag]++;
- }
- }
+ // Index of the MB in the SB 0..3
+ xd->mb_index = i;
+
+ map_index = (mb_row * cpi->common.mb_cols) + mb_col;
+ x->mb_activity_ptr = &cpi->mb_activity_map[map_index];
+
+ // set above context pointer
+ xd->above_context = cm->above_context + mb_col;
+
+ // Restore the appropriate left context depending on which
+ // row in the SB the MB is situated
+ vpx_memcpy(&cm->left_context,
+ &cpi->left_context[i >> 1],
+ sizeof(ENTROPY_CONTEXT_PLANES));
+
+ // Set up distance of MB to edge of frame in 1/8th pel units
+ xd->mb_to_top_edge = -((mb_row * 16) << 3);
+ xd->mb_to_left_edge = -((mb_col * 16) << 3);
+ xd->mb_to_bottom_edge = ((cm->mb_rows - 1 - mb_row) * 16) << 3;
+ xd->mb_to_right_edge = ((cm->mb_cols - 1 - mb_col) * 16) << 3;
+
+ // Set up limit values for MV components to prevent them from
+ // extending beyond the UMV borders assuming 16x16 block size
+ x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
+ (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
+ x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
+ (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
+
+ xd->up_available = (mb_row != 0);
+ xd->left_available = (mb_col != 0);
+
+ recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
+ recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
+
+ xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
+ xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
+ xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
+
+ // Copy current MB to a work buffer
+ RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
+ x->src.y_stride,
+ x->thismb, 16);
+
+ x->rddiv = cpi->RDDIV;
+ x->rdmult = cpi->RDMULT;
+
+ if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
+ vp8_activity_masking(cpi, x);
+
+ // Is segmentation enabled
+ if (xd->segmentation_enabled) {
+ // Code to set segment id in xd->mbmi.segment_id
+ if (cpi->segmentation_map[map_index] <= 3)
+ xd->mode_info_context->mbmi.segment_id =
+ cpi->segmentation_map[map_index];
+ else
+ xd->mode_info_context->mbmi.segment_id = 0;
+
+ vp8cx_mb_init_quantizer(cpi, x);
+ } else
+ // Set to Segment 0 by default
+ xd->mode_info_context->mbmi.segment_id = 0;
+
+ x->active_ptr = cpi->active_map + map_index;
+
+ /* force 4x4 transform for mode selection */
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4; // TODO IS this right??
+
+ cpi->update_context = 0; // TODO Do we need this now??
+
+ // Find best coding mode & reconstruct the MB so it is available
+ // as a predictor for MBs that follow in the SB
+ if (cm->frame_type == KEY_FRAME) {
+ *totalrate += vp8_rd_pick_intra_mode(cpi, x);
+
+ // Save the coding context
+ vpx_memcpy(&x->mb_context[i].mic, xd->mode_info_context,
+ sizeof(MODE_INFO));
+
+ // Dummy encode, do not do the tokenization
+ vp8cx_encode_intra_macro_block(cpi, x, tp, 0);
+ // Note the encoder may have changed the segment_id
+ } else {
+ int seg_id;
+
+ if (xd->segmentation_enabled && cpi->seg0_cnt > 0 &&
+ !segfeature_active(xd, 0, SEG_LVL_REF_FRAME) &&
+ segfeature_active(xd, 1, SEG_LVL_REF_FRAME) &&
+ check_segref(xd, 1, INTRA_FRAME) +
+ check_segref(xd, 1, LAST_FRAME) +
+ check_segref(xd, 1, GOLDEN_FRAME) +
+ check_segref(xd, 1, ALTREF_FRAME) == 1) {
+ cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt;
+ } else {
+ cpi->seg0_progress = (((mb_col & ~1) * 2 + (mb_row & ~1) * cm->mb_cols + i) << 16) / cm->MBs;
+ }
+
+ *totalrate += vp8cx_pick_mode_inter_macroblock(cpi, x,
+ recon_yoffset,
+ recon_uvoffset);
+
+ // Dummy encode, do not do the tokenization
+ vp8cx_encode_inter_macroblock(cpi, x, tp,
+ recon_yoffset, recon_uvoffset, 0);
+
+ seg_id = xd->mode_info_context->mbmi.segment_id;
+ if (cpi->mb.e_mbd.segmentation_enabled && seg_id == 0) {
+ cpi->seg0_idx++;
+ }
+ if (!xd->segmentation_enabled ||
+ !segfeature_active(xd, seg_id, SEG_LVL_REF_FRAME) ||
+ check_segref(xd, seg_id, INTRA_FRAME) +
+ check_segref(xd, seg_id, LAST_FRAME) +
+ check_segref(xd, seg_id, GOLDEN_FRAME) +
+ check_segref(xd, seg_id, ALTREF_FRAME) > 1) {
+ // Get the prediction context and status
+ int pred_flag = get_pred_flag(xd, PRED_REF);
+ int pred_context = get_pred_context(cm, xd, PRED_REF);
+
+ // Count prediction success
+ cpi->ref_pred_count[pred_context][pred_flag]++;
+ }
+ }
- // Keep a copy of the updated left context
- vpx_memcpy (&cpi->left_context[i>>1],
- &cm->left_context,
- sizeof(ENTROPY_CONTEXT_PLANES));
+ // Keep a copy of the updated left context
+ vpx_memcpy(&cpi->left_context[i >> 1],
+ &cm->left_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
- // Next MB
- mb_row += dy;
- mb_col += dx;
+ // Next MB
+ mb_row += dy;
+ mb_col += dx;
- x->src.y_buffer += 16 * (dx + dy*x->src.y_stride);
- x->src.u_buffer += 8 * (dx + dy*x->src.uv_stride);
- x->src.v_buffer += 8 * (dx + dy*x->src.uv_stride);
+ x->src.y_buffer += 16 * (dx + dy * x->src.y_stride);
+ x->src.u_buffer += 8 * (dx + dy * x->src.uv_stride);
+ x->src.v_buffer += 8 * (dx + dy * x->src.uv_stride);
- x->gf_active_ptr += offset_unextended;
- x->partition_info += offset_extended;
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
+ x->gf_active_ptr += offset_unextended;
+ x->partition_info += offset_extended;
+ xd->mode_info_context += offset_extended;
+ xd->prev_mode_info_context += offset_extended;
#if CONFIG_DEBUG
- assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
- (xd->mode_info_context - cpi->common.mip));
+ assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
+ (xd->mode_info_context - cpi->common.mip));
#endif
- }
-
- /* Restore L & A coding context to those in place on entry */
- vpx_memcpy (cpi->left_context,
- left_context,
- sizeof(left_context));
- vpx_memcpy (initial_above_context_ptr,
- above_context,
- sizeof(above_context));
+ }
+
+ /* Restore L & A coding context to those in place on entry */
+ vpx_memcpy(cpi->left_context,
+ left_context,
+ sizeof(left_context));
+ vpx_memcpy(initial_above_context_ptr,
+ above_context,
+ sizeof(above_context));
}
-static void encode_sb ( VP8_COMP *cpi,
- VP8_COMMON *cm,
- int mbrow,
- int mbcol,
- MACROBLOCK *x,
- MACROBLOCKD *xd,
- TOKENEXTRA **tp )
-{
- int i;
- int map_index;
- int mb_row, mb_col;
- int recon_yoffset, recon_uvoffset;
- int ref_fb_idx = cm->lst_fb_idx;
- int dst_fb_idx = cm->new_fb_idx;
- int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
- int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = {+1, -1, +1, +1};
-
- mb_row = mbrow;
- mb_col = mbcol;
-
- /* Encode MBs in raster order within the SB */
- for ( i=0; i<4; i++ )
- {
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * xd->mode_info_stride + dx;
- int offset_unextended = dy * cm->mb_cols + dx;
-
- if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols))
- {
- // MB lies outside frame, move on
- mb_row += dy;
- mb_col += dx;
-
- x->src.y_buffer += 16 * (dx + dy*x->src.y_stride);
- x->src.u_buffer += 8 * (dx + dy*x->src.uv_stride);
- x->src.v_buffer += 8 * (dx + dy*x->src.uv_stride);
-
- x->gf_active_ptr += offset_unextended;
- x->partition_info += offset_extended;
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
+static void encode_sb(VP8_COMP *cpi,
+ VP8_COMMON *cm,
+ int mbrow,
+ int mbcol,
+ MACROBLOCK *x,
+ MACROBLOCKD *xd,
+ TOKENEXTRA **tp) {
+ int i;
+ int map_index;
+ int mb_row, mb_col;
+ int recon_yoffset, recon_uvoffset;
+ int ref_fb_idx = cm->lst_fb_idx;
+ int dst_fb_idx = cm->new_fb_idx;
+ int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
+ int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
+ int row_delta[4] = { 0, +1, 0, -1};
+ int col_delta[4] = { +1, -1, +1, +1};
+
+ mb_row = mbrow;
+ mb_col = mbcol;
+
+ /* Encode MBs in raster order within the SB */
+ for (i = 0; i < 4; i++) {
+ int dy = row_delta[i];
+ int dx = col_delta[i];
+ int offset_extended = dy * xd->mode_info_stride + dx;
+ int offset_unextended = dy * cm->mb_cols + dx;
+
+ if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols)) {
+ // MB lies outside frame, move on
+ mb_row += dy;
+ mb_col += dx;
+
+ x->src.y_buffer += 16 * (dx + dy * x->src.y_stride);
+ x->src.u_buffer += 8 * (dx + dy * x->src.uv_stride);
+ x->src.v_buffer += 8 * (dx + dy * x->src.uv_stride);
+
+ x->gf_active_ptr += offset_unextended;
+ x->partition_info += offset_extended;
+ xd->mode_info_context += offset_extended;
+ xd->prev_mode_info_context += offset_extended;
#if CONFIG_DEBUG
- assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
- (xd->mode_info_context - cpi->common.mip));
+ assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
+ (xd->mode_info_context - cpi->common.mip));
#endif
- continue;
- }
+ continue;
+ }
- xd->mb_index = i;
+ xd->mb_index = i;
#ifdef ENC_DEBUG
- enc_debug = (cpi->common.current_video_frame == 0 &&
- mb_row==0 && mb_col==0);
- mb_col_debug=mb_col;
- mb_row_debug=mb_row;
+ enc_debug = (cpi->common.current_video_frame == 0 &&
+ mb_row == 0 && mb_col == 0);
+ mb_col_debug = mb_col;
+ mb_row_debug = mb_row;
#endif
- // Restore MB state to that when it was picked
+ // Restore MB state to that when it was picked
#if CONFIG_SUPERBLOCKS
- if (x->encode_as_sb)
- update_state (cpi, x, &x->sb_context[i]);
- else
+ if (x->encode_as_sb)
+ update_state(cpi, x, &x->sb_context[i]);
+ else
#endif
- update_state (cpi, x, &x->mb_context[i]);
-
- // Copy in the appropriate left context
- vpx_memcpy (&cm->left_context,
- &cpi->left_context[i>>1],
- sizeof(ENTROPY_CONTEXT_PLANES));
-
- map_index = (mb_row * cpi->common.mb_cols) + mb_col;
- x->mb_activity_ptr = &cpi->mb_activity_map[map_index];
-
- // reset above block coeffs
- xd->above_context = cm->above_context + mb_col;
-
- // Set up distance of MB to edge of the frame in 1/8th pel units
- xd->mb_to_top_edge = -((mb_row * 16) << 3);
- xd->mb_to_left_edge = -((mb_col * 16) << 3);
- xd->mb_to_bottom_edge = ((cm->mb_rows - 1 - mb_row) * 16) << 3;
- xd->mb_to_right_edge = ((cm->mb_cols - 1 - mb_col) * 16) << 3;
-
- // Set up limit values for MV components to prevent them from
- // extending beyond the UMV borders assuming 16x16 block size
- x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
- (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
- x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
- (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
+ update_state(cpi, x, &x->mb_context[i]);
+
+ // Copy in the appropriate left context
+ vpx_memcpy(&cm->left_context,
+ &cpi->left_context[i >> 1],
+ sizeof(ENTROPY_CONTEXT_PLANES));
+
+ map_index = (mb_row * cpi->common.mb_cols) + mb_col;
+ x->mb_activity_ptr = &cpi->mb_activity_map[map_index];
+
+ // reset above block coeffs
+ xd->above_context = cm->above_context + mb_col;
+
+ // Set up distance of MB to edge of the frame in 1/8th pel units
+ xd->mb_to_top_edge = -((mb_row * 16) << 3);
+ xd->mb_to_left_edge = -((mb_col * 16) << 3);
+ xd->mb_to_bottom_edge = ((cm->mb_rows - 1 - mb_row) * 16) << 3;
+ xd->mb_to_right_edge = ((cm->mb_cols - 1 - mb_col) * 16) << 3;
+
+ // Set up limit values for MV components to prevent them from
+ // extending beyond the UMV borders assuming 16x16 block size
+ x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
+ (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
+ x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
+ (VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
#if CONFIG_SUPERBLOCKS
- // Set up limit values for MV components to prevent them from
- // extending beyond the UMV borders assuming 32x32 block size
- x->mv_row_min_sb = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_col_min_sb = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
- x->mv_row_max_sb = ((cm->mb_rows - mb_row) * 16 +
- (VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
- x->mv_col_max_sb = ((cm->mb_cols - mb_col) * 16 +
- (VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
+ // Set up limit values for MV components to prevent them from
+ // extending beyond the UMV borders assuming 32x32 block size
+ x->mv_row_min_sb = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_col_min_sb = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
+ x->mv_row_max_sb = ((cm->mb_rows - mb_row) * 16 +
+ (VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
+ x->mv_col_max_sb = ((cm->mb_cols - mb_col) * 16 +
+ (VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
#endif
- xd->up_available = (mb_row != 0);
- xd->left_available = (mb_col != 0);
+ xd->up_available = (mb_row != 0);
+ xd->left_available = (mb_col != 0);
- recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
+ recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
+ recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
- xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
- xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
- xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
+ xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
+ xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
+ xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
- // Copy current MB to a work buffer
- RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
- x->src.y_stride,
- x->thismb, 16);
+ // Copy current MB to a work buffer
+ RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
+ x->src.y_stride,
+ x->thismb, 16);
- if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
- vp8_activity_masking(cpi, x);
+ if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
+ vp8_activity_masking(cpi, x);
- // Is segmentation enabled
- if (xd->segmentation_enabled)
- {
- // Code to set segment id in xd->mbmi.segment_id
- if (cpi->segmentation_map[map_index] <= 3)
- xd->mode_info_context->mbmi.segment_id =
- cpi->segmentation_map[map_index];
- else
- xd->mode_info_context->mbmi.segment_id = 0;
-
- vp8cx_mb_init_quantizer(cpi, x);
- }
- else
- // Set to Segment 0 by default
- xd->mode_info_context->mbmi.segment_id = 0;
+ // Is segmentation enabled
+ if (xd->segmentation_enabled) {
+ // Code to set segment id in xd->mbmi.segment_id
+ if (cpi->segmentation_map[map_index] <= 3)
+ xd->mode_info_context->mbmi.segment_id =
+ cpi->segmentation_map[map_index];
+ else
+ xd->mode_info_context->mbmi.segment_id = 0;
- x->active_ptr = cpi->active_map + map_index;
+ vp8cx_mb_init_quantizer(cpi, x);
+ } else
+ // Set to Segment 0 by default
+ xd->mode_info_context->mbmi.segment_id = 0;
- cpi->update_context = 0;
+ x->active_ptr = cpi->active_map + map_index;
- if (cm->frame_type == KEY_FRAME)
- {
- vp8cx_encode_intra_macro_block(cpi, x, tp, 1);
- //Note the encoder may have changed the segment_id
+ cpi->update_context = 0;
+
+ if (cm->frame_type == KEY_FRAME) {
+ vp8cx_encode_intra_macro_block(cpi, x, tp, 1);
+ // Note the encoder may have changed the segment_id
#ifdef MODE_STATS
- y_modes[xd->mode_info_context->mbmi.mode] ++;
+ y_modes[xd->mode_info_context->mbmi.mode]++;
#endif
- }
- else
- {
- unsigned char *segment_id;
- int seg_ref_active;
+ } else {
+ unsigned char *segment_id;
+ int seg_ref_active;
- vp8cx_encode_inter_macroblock(cpi, x, tp,
- recon_yoffset, recon_uvoffset, 1);
- //Note the encoder may have changed the segment_id
+ vp8cx_encode_inter_macroblock(cpi, x, tp,
+ recon_yoffset, recon_uvoffset, 1);
+ // Note the encoder may have changed the segment_id
#ifdef MODE_STATS
- inter_y_modes[xd->mode_info_context->mbmi.mode] ++;
+ inter_y_modes[xd->mode_info_context->mbmi.mode]++;
- if (xd->mode_info_context->mbmi.mode == SPLITMV)
- {
- int b;
+ if (xd->mode_info_context->mbmi.mode == SPLITMV) {
+ int b;
- for (b = 0; b < x->partition_info->count; b++)
- {
- inter_b_modes[x->partition_info->bmi[b].mode] ++;
- }
- }
+ for (b = 0; b < x->partition_info->count; b++) {
+ inter_b_modes[x->partition_info->bmi[b].mode]++;
+ }
+ }
#endif
- // If we have just a single reference frame coded for a segment then
- // exclude from the reference frame counts used to work out
- // probabilities. NOTE: At the moment we dont support custom trees
- // for the reference frame coding for each segment but this is a
- // possible future action.
- segment_id = &xd->mode_info_context->mbmi.segment_id;
- seg_ref_active = segfeature_active( xd, *segment_id, SEG_LVL_REF_FRAME );
- if ( !seg_ref_active ||
- ( ( check_segref( xd, *segment_id, INTRA_FRAME ) +
- check_segref( xd, *segment_id, LAST_FRAME ) +
- check_segref( xd, *segment_id, GOLDEN_FRAME ) +
- check_segref( xd, *segment_id, ALTREF_FRAME ) ) > 1 ) )
- {
+ // If we have just a single reference frame coded for a segment then
+ // exclude from the reference frame counts used to work out
+ // probabilities. NOTE: At the moment we dont support custom trees
+ // for the reference frame coding for each segment but this is a
+ // possible future action.
+ segment_id = &xd->mode_info_context->mbmi.segment_id;
+ seg_ref_active = segfeature_active(xd, *segment_id, SEG_LVL_REF_FRAME);
+ if (!seg_ref_active ||
+ ((check_segref(xd, *segment_id, INTRA_FRAME) +
+ check_segref(xd, *segment_id, LAST_FRAME) +
+ check_segref(xd, *segment_id, GOLDEN_FRAME) +
+ check_segref(xd, *segment_id, ALTREF_FRAME)) > 1)) {
// TODO this may not be a good idea as it makes sample size small and means
// the predictor functions cannot use data about most likely value only most
// likely unpredicted value.
-//#if CONFIG_COMPRED
+// #if CONFIG_COMPRED
// // Only update count for incorrectly predicted cases
// if ( !ref_pred_flag )
-//#endif
- {
- cpi->count_mb_ref_frame_usage
- [xd->mode_info_context->mbmi.ref_frame]++;
- }
- }
-
- // Count of last ref frame 0,0 usage
- if ((xd->mode_info_context->mbmi.mode == ZEROMV) &&
- (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME))
- cpi->inter_zz_count ++;
+// #endif
+ {
+ cpi->count_mb_ref_frame_usage
+ [xd->mode_info_context->mbmi.ref_frame]++;
}
+ }
- // TODO Partitioning is broken!
- cpi->tplist[mb_row].stop = *tp;
+ // Count of last ref frame 0,0 usage
+ if ((xd->mode_info_context->mbmi.mode == ZEROMV) &&
+ (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME))
+ cpi->inter_zz_count++;
+ }
- // Copy back updated left context
- vpx_memcpy (&cpi->left_context[i>>1],
- &cm->left_context,
- sizeof(ENTROPY_CONTEXT_PLANES));
+ // TODO Partitioning is broken!
+ cpi->tplist[mb_row].stop = *tp;
- // Next MB
- mb_row += dy;
- mb_col += dx;
+ // Copy back updated left context
+ vpx_memcpy(&cpi->left_context[i >> 1],
+ &cm->left_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
- x->src.y_buffer += 16 * (dx + dy*x->src.y_stride);
- x->src.u_buffer += 8 * (dx + dy*x->src.uv_stride);
- x->src.v_buffer += 8 * (dx + dy*x->src.uv_stride);
+ // Next MB
+ mb_row += dy;
+ mb_col += dx;
- x->gf_active_ptr += offset_unextended;
- x->partition_info += offset_extended;
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
+ x->src.y_buffer += 16 * (dx + dy * x->src.y_stride);
+ x->src.u_buffer += 8 * (dx + dy * x->src.uv_stride);
+ x->src.v_buffer += 8 * (dx + dy * x->src.uv_stride);
+
+ x->gf_active_ptr += offset_unextended;
+ x->partition_info += offset_extended;
+ xd->mode_info_context += offset_extended;
+ xd->prev_mode_info_context += offset_extended;
#if CONFIG_DEBUG
- assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
- (xd->mode_info_context - cpi->common.mip));
+ assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
+ (xd->mode_info_context - cpi->common.mip));
#endif
- }
+ }
- // debug output
+ // debug output
#if DBG_PRNT_SEGMAP
- {
- FILE *statsfile;
- statsfile = fopen("segmap2.stt", "a");
- fprintf(statsfile, "\n" );
- fclose(statsfile);
- }
- #endif
+ {
+ FILE *statsfile;
+ statsfile = fopen("segmap2.stt", "a");
+ fprintf(statsfile, "\n");
+ fclose(statsfile);
+ }
+#endif
}
static
-void encode_sb_row ( VP8_COMP *cpi,
- VP8_COMMON *cm,
- int mb_row,
- MACROBLOCK *x,
- MACROBLOCKD *xd,
- TOKENEXTRA **tp,
- int *totalrate )
-{
- int mb_col;
- int mb_cols = cm->mb_cols;
-
- // Initialize the left context for the new SB row
- vpx_memset (cpi->left_context, 0, sizeof(cpi->left_context));
- vpx_memset (&cm->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
-
- // Code each SB in the row
- for (mb_col=0; mb_col<mb_cols; mb_col+=2)
- {
- int mb_rate = 0;
+void encode_sb_row(VP8_COMP *cpi,
+ VP8_COMMON *cm,
+ int mb_row,
+ MACROBLOCK *x,
+ MACROBLOCKD *xd,
+ TOKENEXTRA **tp,
+ int *totalrate) {
+ int mb_col;
+ int mb_cols = cm->mb_cols;
+
+ // Initialize the left context for the new SB row
+ vpx_memset(cpi->left_context, 0, sizeof(cpi->left_context));
+ vpx_memset(&cm->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ // Code each SB in the row
+ for (mb_col = 0; mb_col < mb_cols; mb_col += 2) {
+ int mb_rate = 0;
#if CONFIG_SUPERBLOCKS
- int sb_rate = INT_MAX;
+ int sb_rate = INT_MAX;
#endif
#if CONFIG_DEBUG
- MODE_INFO *mic = xd->mode_info_context;
- PARTITION_INFO *pi = x->partition_info;
- signed char *gfa = x->gf_active_ptr;
- unsigned char *yb = x->src.y_buffer;
- unsigned char *ub = x->src.u_buffer;
- unsigned char *vb = x->src.v_buffer;
+ MODE_INFO *mic = xd->mode_info_context;
+ PARTITION_INFO *pi = x->partition_info;
+ signed char *gfa = x->gf_active_ptr;
+ unsigned char *yb = x->src.y_buffer;
+ unsigned char *ub = x->src.u_buffer;
+ unsigned char *vb = x->src.v_buffer;
#endif
- // Pick modes assuming the SB is coded as 4 independent MBs
- pick_mb_modes (cpi, cm, mb_row, mb_col, x, xd, tp, &mb_rate);
+ // Pick modes assuming the SB is coded as 4 independent MBs
+ pick_mb_modes(cpi, cm, mb_row, mb_col, x, xd, tp, &mb_rate);
- x->src.y_buffer -= 32;
- x->src.u_buffer -= 16;
- x->src.v_buffer -= 16;
+ x->src.y_buffer -= 32;
+ x->src.u_buffer -= 16;
+ x->src.v_buffer -= 16;
- x->gf_active_ptr -= 2;
- x->partition_info -= 2;
- xd->mode_info_context -= 2;
- xd->prev_mode_info_context -= 2;
+ x->gf_active_ptr -= 2;
+ x->partition_info -= 2;
+ xd->mode_info_context -= 2;
+ xd->prev_mode_info_context -= 2;
#if CONFIG_DEBUG
- assert (x->gf_active_ptr == gfa);
- assert (x->partition_info == pi);
- assert (xd->mode_info_context == mic);
- assert (x->src.y_buffer == yb);
- assert (x->src.u_buffer == ub);
- assert (x->src.v_buffer == vb);
+ assert(x->gf_active_ptr == gfa);
+ assert(x->partition_info == pi);
+ assert(xd->mode_info_context == mic);
+ assert(x->src.y_buffer == yb);
+ assert(x->src.u_buffer == ub);
+ assert(x->src.v_buffer == vb);
#endif
#if CONFIG_SUPERBLOCKS
- // Pick a mode assuming that it applies all 4 of the MBs in the SB
- pick_sb_modes(cpi, cm, mb_row, mb_col, x, xd, &sb_rate);
-
- // Decide whether to encode as a SB or 4xMBs
- if(sb_rate < mb_rate)
- {
- x->encode_as_sb = 1;
- *totalrate += sb_rate;
- }
- else
+ // Pick a mode assuming that it applies all 4 of the MBs in the SB
+ pick_sb_modes(cpi, cm, mb_row, mb_col, x, xd, &sb_rate);
+
+ // Decide whether to encode as a SB or 4xMBs
+ if (sb_rate < mb_rate) {
+ x->encode_as_sb = 1;
+ *totalrate += sb_rate;
+ } else
#endif
- {
- x->encode_as_sb = 0;
- *totalrate += mb_rate;
- }
+ {
+ x->encode_as_sb = 0;
+ *totalrate += mb_rate;
+ }
- // Encode SB using best computed mode(s)
- encode_sb (cpi, cm, mb_row, mb_col, x, xd, tp);
+ // Encode SB using best computed mode(s)
+ encode_sb(cpi, cm, mb_row, mb_col, x, xd, tp);
#if CONFIG_DEBUG
- assert (x->gf_active_ptr == gfa+2);
- assert (x->partition_info == pi+2);
- assert (xd->mode_info_context == mic+2);
- assert (x->src.y_buffer == yb+32);
- assert (x->src.u_buffer == ub+16);
- assert (x->src.v_buffer == vb+16);
+ assert(x->gf_active_ptr == gfa + 2);
+ assert(x->partition_info == pi + 2);
+ assert(xd->mode_info_context == mic + 2);
+ assert(x->src.y_buffer == yb + 32);
+ assert(x->src.u_buffer == ub + 16);
+ assert(x->src.v_buffer == vb + 16);
#endif
- }
+ }
- // this is to account for the border
- x->gf_active_ptr += mb_cols - (mb_cols & 0x1);
- x->partition_info += xd->mode_info_stride + 1 - (mb_cols & 0x1);
- xd->mode_info_context += xd->mode_info_stride + 1 - (mb_cols & 0x1);
- xd->prev_mode_info_context += xd->mode_info_stride + 1 - (mb_cols & 0x1);
+ // this is to account for the border
+ x->gf_active_ptr += mb_cols - (mb_cols & 0x1);
+ x->partition_info += xd->mode_info_stride + 1 - (mb_cols & 0x1);
+ xd->mode_info_context += xd->mode_info_stride + 1 - (mb_cols & 0x1);
+ xd->prev_mode_info_context += xd->mode_info_stride + 1 - (mb_cols & 0x1);
#if CONFIG_DEBUG
- assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
- (xd->mode_info_context - cpi->common.mip));
+ assert((xd->prev_mode_info_context - cpi->common.prev_mip) ==
+ (xd->mode_info_context - cpi->common.mip));
#endif
}
-void init_encode_frame_mb_context(VP8_COMP *cpi)
-{
- MACROBLOCK *const x = & cpi->mb;
- VP8_COMMON *const cm = & cpi->common;
- MACROBLOCKD *const xd = & x->e_mbd;
+void init_encode_frame_mb_context(VP8_COMP *cpi) {
+ MACROBLOCK *const x = & cpi->mb;
+ VP8_COMMON *const cm = & cpi->common;
+ MACROBLOCKD *const xd = & x->e_mbd;
- // GF active flags data structure
- x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
+ // GF active flags data structure
+ x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
- // Activity map pointer
- x->mb_activity_ptr = cpi->mb_activity_map;
+ // Activity map pointer
+ x->mb_activity_ptr = cpi->mb_activity_map;
- x->act_zbin_adj = 0;
- cpi->seg0_idx = 0;
- vpx_memset(cpi->ref_pred_count, 0, sizeof(cpi->ref_pred_count));
+ x->act_zbin_adj = 0;
+ cpi->seg0_idx = 0;
+ vpx_memset(cpi->ref_pred_count, 0, sizeof(cpi->ref_pred_count));
- x->partition_info = x->pi;
+ x->partition_info = x->pi;
- xd->mode_info_context = cm->mi;
- xd->mode_info_stride = cm->mode_info_stride;
- xd->prev_mode_info_context = cm->prev_mi;
+ xd->mode_info_context = cm->mi;
+ xd->mode_info_stride = cm->mode_info_stride;
+ xd->prev_mode_info_context = cm->prev_mi;
- xd->frame_type = cm->frame_type;
+ xd->frame_type = cm->frame_type;
- xd->frames_since_golden = cm->frames_since_golden;
- xd->frames_till_alt_ref_frame = cm->frames_till_alt_ref_frame;
+ xd->frames_since_golden = cm->frames_since_golden;
+ xd->frames_till_alt_ref_frame = cm->frames_till_alt_ref_frame;
- // reset intra mode contexts
- if (cm->frame_type == KEY_FRAME)
- vp8_init_mbmode_probs(cm);
+ // reset intra mode contexts
+ if (cm->frame_type == KEY_FRAME)
+ vp8_init_mbmode_probs(cm);
- // Copy data over into macro block data structures.
- x->src = * cpi->Source;
- xd->pre = cm->yv12_fb[cm->lst_fb_idx];
- xd->dst = cm->yv12_fb[cm->new_fb_idx];
+ // Copy data over into macro block data structures.
+ x->src = * cpi->Source;
+ xd->pre = cm->yv12_fb[cm->lst_fb_idx];
+ xd->dst = cm->yv12_fb[cm->new_fb_idx];
- // set up frame for intra coded blocks
- vp8_setup_intra_recon(&cm->yv12_fb[cm->new_fb_idx]);
+ // set up frame for intra coded blocks
+ vp8_setup_intra_recon(&cm->yv12_fb[cm->new_fb_idx]);
- vp8_build_block_offsets(x);
+ vp8_build_block_offsets(x);
- vp8_setup_block_dptrs(&x->e_mbd);
+ vp8_setup_block_dptrs(&x->e_mbd);
- vp8_setup_block_ptrs(x);
+ vp8_setup_block_ptrs(x);
- xd->mode_info_context->mbmi.mode = DC_PRED;
- xd->mode_info_context->mbmi.uv_mode = DC_PRED;
+ xd->mode_info_context->mbmi.mode = DC_PRED;
+ xd->mode_info_context->mbmi.uv_mode = DC_PRED;
- xd->left_context = &cm->left_context;
+ xd->left_context = &cm->left_context;
- vp8_zero(cpi->count_mb_ref_frame_usage)
- vp8_zero(cpi->bmode_count)
- vp8_zero(cpi->ymode_count)
- vp8_zero(cpi->i8x8_mode_count)
- vp8_zero(cpi->y_uv_mode_count)
- vp8_zero(cpi->sub_mv_ref_count)
- vp8_zero(cpi->mbsplit_count)
+ vp8_zero(cpi->count_mb_ref_frame_usage)
+ vp8_zero(cpi->bmode_count)
+ vp8_zero(cpi->ymode_count)
+ vp8_zero(cpi->i8x8_mode_count)
+ vp8_zero(cpi->y_uv_mode_count)
+ vp8_zero(cpi->sub_mv_ref_count)
+ vp8_zero(cpi->mbsplit_count)
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_zero(cpi->common.fc.mv_ref_ct)
- vp8_zero(cpi->common.fc.mv_ref_ct_a)
+ vp8_zero(cpi->common.fc.mv_ref_ct)
+ vp8_zero(cpi->common.fc.mv_ref_ct_a)
#endif
- //vp8_zero(cpi->uv_mode_count)
+ // vp8_zero(cpi->uv_mode_count)
- x->mvc = cm->fc.mvc;
+ x->mvc = cm->fc.mvc;
#if CONFIG_HIGH_PRECISION_MV
- x->mvc_hp = cm->fc.mvc_hp;
+ x->mvc_hp = cm->fc.mvc_hp;
#endif
- vpx_memset(cm->above_context, 0,
- sizeof(ENTROPY_CONTEXT_PLANES) * cm->mb_cols);
+ vpx_memset(cm->above_context, 0,
+ sizeof(ENTROPY_CONTEXT_PLANES) * cm->mb_cols);
- xd->fullpixel_mask = 0xffffffff;
- if(cm->full_pixel)
- xd->fullpixel_mask = 0xfffffff8;
+ xd->fullpixel_mask = 0xffffffff;
+ if (cm->full_pixel)
+ xd->fullpixel_mask = 0xfffffff8;
}
-static void encode_frame_internal(VP8_COMP *cpi)
-{
- int mb_row;
- MACROBLOCK *const x = & cpi->mb;
- VP8_COMMON *const cm = & cpi->common;
- MACROBLOCKD *const xd = & x->e_mbd;
+static void encode_frame_internal(VP8_COMP *cpi) {
+ int mb_row;
+ MACROBLOCK *const x = & cpi->mb;
+ VP8_COMMON *const cm = & cpi->common;
+ MACROBLOCKD *const xd = & x->e_mbd;
- TOKENEXTRA *tp = cpi->tok;
- int totalrate;
+ TOKENEXTRA *tp = cpi->tok;
+ int totalrate;
- // Compute a modified set of reference frame probabilities to use when
- // prediction fails. These are based on the current general estimates for
- // this frame which may be updated with each iteration of the recode loop.
- compute_mod_refprobs( cm );
+ // Compute a modified set of reference frame probabilities to use when
+ // prediction fails. These are based on the current general estimates for
+ // this frame which may be updated with each iteration of the recode loop.
+ compute_mod_refprobs(cm);
// debug output
#if DBG_PRNT_SEGMAP
- {
- FILE *statsfile;
- statsfile = fopen("segmap2.stt", "a");
- fprintf(statsfile, "\n" );
- fclose(statsfile);
- }
+ {
+ FILE *statsfile;
+ statsfile = fopen("segmap2.stt", "a");
+ fprintf(statsfile, "\n");
+ fclose(statsfile);
+ }
#endif
- totalrate = 0;
-
- // Functions setup for all frame types so we can use MC in AltRef
- if (cm->mcomp_filter_type == SIXTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, sixtap_avg16x16);
- }
+ totalrate = 0;
+
+ // Functions setup for all frame types so we can use MC in AltRef
+ if (cm->mcomp_filter_type == SIXTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, sixtap_avg16x16);
+ }
#if CONFIG_ENHANCED_INTERP
- else if (cm->mcomp_filter_type == EIGHTTAP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg16x16);
- }
- else if (cm->mcomp_filter_type == EIGHTTAP_SHARP)
- {
- xd->subpixel_predict = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap4x4_sharp);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap8x4_sharp);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap8x8_sharp);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap16x16_sharp);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg4x4_sharp);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg8x8_sharp);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, eighttap_avg16x16_sharp);
- }
+ else if (cm->mcomp_filter_type == EIGHTTAP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg16x16);
+ } else if (cm->mcomp_filter_type == EIGHTTAP_SHARP) {
+ xd->subpixel_predict = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap4x4_sharp);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap8x4_sharp);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap8x8_sharp);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap16x16_sharp);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg4x4_sharp);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg8x8_sharp);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, eighttap_avg16x16_sharp);
+ }
#endif
- else
- {
- xd->subpixel_predict = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear4x4);
- xd->subpixel_predict8x4 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear8x4);
- xd->subpixel_predict8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear8x8);
- xd->subpixel_predict16x16 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear16x16);
- xd->subpixel_predict_avg = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear_avg4x4);
- xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
- &cpi->common.rtcd.subpix, bilinear_avg8x8);
- xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
+ else {
+ xd->subpixel_predict = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear4x4);
+ xd->subpixel_predict8x4 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear8x4);
+ xd->subpixel_predict8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear8x8);
+ xd->subpixel_predict16x16 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear16x16);
+ xd->subpixel_predict_avg = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear_avg4x4);
+ xd->subpixel_predict_avg8x8 = SUBPIX_INVOKE(
+ &cpi->common.rtcd.subpix, bilinear_avg8x8);
+ xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
&cpi->common.rtcd.subpix, bilinear_avg16x16);
- }
+ }
- // Reset frame count of inter 0,0 motion vector usage.
- cpi->inter_zz_count = 0;
+ // Reset frame count of inter 0,0 motion vector usage.
+ cpi->inter_zz_count = 0;
- cpi->prediction_error = 0;
- cpi->intra_error = 0;
+ cpi->prediction_error = 0;
+ cpi->intra_error = 0;
#if CONFIG_NEWENTROPY
- cpi->skip_true_count[0] = cpi->skip_true_count[1] = cpi->skip_true_count[2] = 0;
- cpi->skip_false_count[0] = cpi->skip_false_count[1] = cpi->skip_false_count[2] = 0;
+ cpi->skip_true_count[0] = cpi->skip_true_count[1] = cpi->skip_true_count[2] = 0;
+ cpi->skip_false_count[0] = cpi->skip_false_count[1] = cpi->skip_false_count[2] = 0;
#else
- cpi->skip_true_count = 0;
- cpi->skip_false_count = 0;
+ cpi->skip_true_count = 0;
+ cpi->skip_false_count = 0;
#endif
#if CONFIG_PRED_FILTER
- if (cm->current_video_frame == 0)
- {
- // Initially assume that we'll signal the prediction filter
- // state at the frame level and that it is off.
- cpi->common.pred_filter_mode = 0;
- cpi->common.prob_pred_filter_off = 128;
- }
- cpi->pred_filter_on_count = 0;
- cpi->pred_filter_off_count = 0;
+ if (cm->current_video_frame == 0) {
+ // Initially assume that we'll signal the prediction filter
+ // state at the frame level and that it is off.
+ cpi->common.pred_filter_mode = 0;
+ cpi->common.prob_pred_filter_off = 128;
+ }
+ cpi->pred_filter_on_count = 0;
+ cpi->pred_filter_off_count = 0;
#endif
#if 0
- // Experimental code
- cpi->frame_distortion = 0;
- cpi->last_mb_distortion = 0;
+ // Experimental code
+ cpi->frame_distortion = 0;
+ cpi->last_mb_distortion = 0;
#endif
- xd->mode_info_context = cm->mi;
- xd->prev_mode_info_context = cm->prev_mi;
+ xd->mode_info_context = cm->mi;
+ xd->prev_mode_info_context = cm->prev_mi;
- vp8_zero(cpi->MVcount);
+ vp8_zero(cpi->MVcount);
#if CONFIG_HIGH_PRECISION_MV
- vp8_zero(cpi->MVcount_hp);
+ vp8_zero(cpi->MVcount_hp);
#endif
- vp8_zero(cpi->coef_counts);
- vp8_zero(cpi->coef_counts_8x8);
+ vp8_zero(cpi->coef_counts);
+ vp8_zero(cpi->coef_counts_8x8);
- vp8cx_frame_init_quantizer(cpi);
+ vp8cx_frame_init_quantizer(cpi);
- vp8_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
- vp8cx_initialize_me_consts(cpi, cm->base_qindex);
+ vp8_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
+ vp8cx_initialize_me_consts(cpi, cm->base_qindex);
- if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
- {
- // Initialize encode frame context.
- init_encode_frame_mb_context(cpi);
-
- // Build a frame level activity map
- build_activity_map(cpi);
- }
-
- // re-initencode frame context.
+ if (cpi->oxcf.tuning == VP8_TUNE_SSIM) {
+ // Initialize encode frame context.
init_encode_frame_mb_context(cpi);
- cpi->rd_single_diff = cpi->rd_comp_diff = cpi->rd_hybrid_diff = 0;
- vpx_memset(cpi->single_pred_count, 0, sizeof(cpi->single_pred_count));
- vpx_memset(cpi->comp_pred_count, 0, sizeof(cpi->comp_pred_count));
+ // Build a frame level activity map
+ build_activity_map(cpi);
+ }
- {
- struct vpx_usec_timer emr_timer;
- vpx_usec_timer_start(&emr_timer);
+ // re-initencode frame context.
+ init_encode_frame_mb_context(cpi);
- {
- // For each row of SBs in the frame
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row+=2)
- {
- int offset = (cm->mb_cols+1) & ~0x1;
+ cpi->rd_single_diff = cpi->rd_comp_diff = cpi->rd_hybrid_diff = 0;
+ vpx_memset(cpi->single_pred_count, 0, sizeof(cpi->single_pred_count));
+ vpx_memset(cpi->comp_pred_count, 0, sizeof(cpi->comp_pred_count));
- encode_sb_row(cpi, cm, mb_row, x, xd, &tp, &totalrate);
+ {
+ struct vpx_usec_timer emr_timer;
+ vpx_usec_timer_start(&emr_timer);
- // adjust to the next row of SBs
- x->src.y_buffer += 32 * x->src.y_stride - 16 * offset;
- x->src.u_buffer += 16 * x->src.uv_stride - 8 * offset;
- x->src.v_buffer += 16 * x->src.uv_stride - 8 * offset;
- }
+ {
+ // For each row of SBs in the frame
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 2) {
+ int offset = (cm->mb_cols + 1) & ~0x1;
- cpi->tok_count = tp - cpi->tok;
- }
+ encode_sb_row(cpi, cm, mb_row, x, xd, &tp, &totalrate);
- vpx_usec_timer_mark(&emr_timer);
- cpi->time_encode_mb_row += vpx_usec_timer_elapsed(&emr_timer);
+ // adjust to the next row of SBs
+ x->src.y_buffer += 32 * x->src.y_stride - 16 * offset;
+ x->src.u_buffer += 16 * x->src.uv_stride - 8 * offset;
+ x->src.v_buffer += 16 * x->src.uv_stride - 8 * offset;
+ }
+ cpi->tok_count = tp - cpi->tok;
}
- // 256 rate units to the bit,
- // projected_frame_size in units of BYTES
- cpi->projected_frame_size = totalrate >> 8;
+ vpx_usec_timer_mark(&emr_timer);
+ cpi->time_encode_mb_row += vpx_usec_timer_elapsed(&emr_timer);
+
+ }
+
+ // 256 rate units to the bit,
+ // projected_frame_size in units of BYTES
+ cpi->projected_frame_size = totalrate >> 8;
#if 0
- // Keep record of the total distortion this time around for future use
- cpi->last_frame_distortion = cpi->frame_distortion;
+ // Keep record of the total distortion this time around for future use
+ cpi->last_frame_distortion = cpi->frame_distortion;
#endif
}
-static int check_dual_ref_flags(VP8_COMP *cpi)
-{
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- int ref_flags = cpi->ref_frame_flags;
-
- if (segfeature_active(xd, 1, SEG_LVL_REF_FRAME))
- {
- if ((ref_flags & (VP8_LAST_FLAG | VP8_GOLD_FLAG)) == (VP8_LAST_FLAG | VP8_GOLD_FLAG) &&
- check_segref(xd, 1, LAST_FRAME))
- return 1;
- if ((ref_flags & (VP8_GOLD_FLAG | VP8_ALT_FLAG )) == (VP8_GOLD_FLAG | VP8_ALT_FLAG ) &&
- check_segref(xd, 1, GOLDEN_FRAME))
- return 1;
- if ((ref_flags & (VP8_ALT_FLAG | VP8_LAST_FLAG)) == (VP8_ALT_FLAG | VP8_LAST_FLAG) &&
- check_segref(xd, 1, ALTREF_FRAME))
- return 1;
- return 0;
- }
- else
- {
- return (!!(ref_flags & VP8_GOLD_FLAG) +
- !!(ref_flags & VP8_LAST_FLAG) +
- !!(ref_flags & VP8_ALT_FLAG) ) >= 2;
- }
+static int check_dual_ref_flags(VP8_COMP *cpi) {
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ int ref_flags = cpi->ref_frame_flags;
+
+ if (segfeature_active(xd, 1, SEG_LVL_REF_FRAME)) {
+ if ((ref_flags & (VP8_LAST_FLAG | VP8_GOLD_FLAG)) == (VP8_LAST_FLAG | VP8_GOLD_FLAG) &&
+ check_segref(xd, 1, LAST_FRAME))
+ return 1;
+ if ((ref_flags & (VP8_GOLD_FLAG | VP8_ALT_FLAG)) == (VP8_GOLD_FLAG | VP8_ALT_FLAG) &&
+ check_segref(xd, 1, GOLDEN_FRAME))
+ return 1;
+ if ((ref_flags & (VP8_ALT_FLAG | VP8_LAST_FLAG)) == (VP8_ALT_FLAG | VP8_LAST_FLAG) &&
+ check_segref(xd, 1, ALTREF_FRAME))
+ return 1;
+ return 0;
+ } else {
+ return (!!(ref_flags & VP8_GOLD_FLAG) +
+ !!(ref_flags & VP8_LAST_FLAG) +
+ !!(ref_flags & VP8_ALT_FLAG)) >= 2;
+ }
}
-void vp8_encode_frame(VP8_COMP *cpi)
-{
- if (cpi->sf.RD)
- {
- int frame_type, pred_type;
- int single_diff, comp_diff, hybrid_diff;
-
- /*
- * This code does a single RD pass over the whole frame assuming
- * either compound, single or hybrid prediction as per whatever has
- * worked best for that type of frame in the past.
- * It also predicts whether another coding mode would have worked
- * better that this coding mode. If that is the case, it remembers
- * that for subsequent frames. If the difference is above a certain
- * threshold, it will actually re-encode the current frame using
- * that different coding mode.
- */
- if (cpi->common.frame_type == KEY_FRAME)
- frame_type = 0;
- else if (cpi->is_src_frame_alt_ref && cpi->common.refresh_golden_frame)
- frame_type = 3;
- else if (cpi->common.refresh_golden_frame || cpi->common.refresh_alt_ref_frame)
- frame_type = 1;
- else
- frame_type = 2;
-
- if (frame_type == 3)
- pred_type = SINGLE_PREDICTION_ONLY;
- else if (cpi->rd_prediction_type_threshes[frame_type][1] >
- cpi->rd_prediction_type_threshes[frame_type][0] &&
- cpi->rd_prediction_type_threshes[frame_type][1] >
- cpi->rd_prediction_type_threshes[frame_type][2] &&
- check_dual_ref_flags(cpi))
- pred_type = COMP_PREDICTION_ONLY;
- else if (cpi->rd_prediction_type_threshes[frame_type][0] >
- cpi->rd_prediction_type_threshes[frame_type][1] &&
- cpi->rd_prediction_type_threshes[frame_type][0] >
- cpi->rd_prediction_type_threshes[frame_type][2])
- pred_type = SINGLE_PREDICTION_ONLY;
- else
- pred_type = HYBRID_PREDICTION;
-
- cpi->common.comp_pred_mode = pred_type;
- encode_frame_internal(cpi);
-
- single_diff = cpi->rd_single_diff / cpi->common.MBs;
- cpi->rd_prediction_type_threshes[frame_type][0] += single_diff;
- cpi->rd_prediction_type_threshes[frame_type][0] >>= 1;
- comp_diff = cpi->rd_comp_diff / cpi->common.MBs;
- cpi->rd_prediction_type_threshes[frame_type][1] += comp_diff;
- cpi->rd_prediction_type_threshes[frame_type][1] >>= 1;
- hybrid_diff = cpi->rd_hybrid_diff / cpi->common.MBs;
- cpi->rd_prediction_type_threshes[frame_type][2] += hybrid_diff;
- cpi->rd_prediction_type_threshes[frame_type][2] >>= 1;
-
- if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
- {
- int single_count_zero = 0;
- int comp_count_zero = 0;
- int i;
-
- for ( i = 0; i < COMP_PRED_CONTEXTS; i++ )
- {
- single_count_zero += cpi->single_pred_count[i];
- comp_count_zero += cpi->comp_pred_count[i];
- }
-
- if (comp_count_zero == 0)
- {
- cpi->common.comp_pred_mode = SINGLE_PREDICTION_ONLY;
- }
- else if (single_count_zero == 0)
- {
- cpi->common.comp_pred_mode = COMP_PREDICTION_ONLY;
- }
- }
- }
+void vp8_encode_frame(VP8_COMP *cpi) {
+ if (cpi->sf.RD) {
+ int frame_type, pred_type;
+ int single_diff, comp_diff, hybrid_diff;
+
+ /*
+ * This code does a single RD pass over the whole frame assuming
+ * either compound, single or hybrid prediction as per whatever has
+ * worked best for that type of frame in the past.
+ * It also predicts whether another coding mode would have worked
+ * better that this coding mode. If that is the case, it remembers
+ * that for subsequent frames. If the difference is above a certain
+ * threshold, it will actually re-encode the current frame using
+ * that different coding mode.
+ */
+ if (cpi->common.frame_type == KEY_FRAME)
+ frame_type = 0;
+ else if (cpi->is_src_frame_alt_ref && cpi->common.refresh_golden_frame)
+ frame_type = 3;
+ else if (cpi->common.refresh_golden_frame || cpi->common.refresh_alt_ref_frame)
+ frame_type = 1;
else
- {
- encode_frame_internal(cpi);
+ frame_type = 2;
+
+ if (frame_type == 3)
+ pred_type = SINGLE_PREDICTION_ONLY;
+ else if (cpi->rd_prediction_type_threshes[frame_type][1] >
+ cpi->rd_prediction_type_threshes[frame_type][0] &&
+ cpi->rd_prediction_type_threshes[frame_type][1] >
+ cpi->rd_prediction_type_threshes[frame_type][2] &&
+ check_dual_ref_flags(cpi))
+ pred_type = COMP_PREDICTION_ONLY;
+ else if (cpi->rd_prediction_type_threshes[frame_type][0] >
+ cpi->rd_prediction_type_threshes[frame_type][1] &&
+ cpi->rd_prediction_type_threshes[frame_type][0] >
+ cpi->rd_prediction_type_threshes[frame_type][2])
+ pred_type = SINGLE_PREDICTION_ONLY;
+ else
+ pred_type = HYBRID_PREDICTION;
+
+ cpi->common.comp_pred_mode = pred_type;
+ encode_frame_internal(cpi);
+
+ single_diff = cpi->rd_single_diff / cpi->common.MBs;
+ cpi->rd_prediction_type_threshes[frame_type][0] += single_diff;
+ cpi->rd_prediction_type_threshes[frame_type][0] >>= 1;
+ comp_diff = cpi->rd_comp_diff / cpi->common.MBs;
+ cpi->rd_prediction_type_threshes[frame_type][1] += comp_diff;
+ cpi->rd_prediction_type_threshes[frame_type][1] >>= 1;
+ hybrid_diff = cpi->rd_hybrid_diff / cpi->common.MBs;
+ cpi->rd_prediction_type_threshes[frame_type][2] += hybrid_diff;
+ cpi->rd_prediction_type_threshes[frame_type][2] >>= 1;
+
+ if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
+ int single_count_zero = 0;
+ int comp_count_zero = 0;
+ int i;
+
+ for (i = 0; i < COMP_PRED_CONTEXTS; i++) {
+ single_count_zero += cpi->single_pred_count[i];
+ comp_count_zero += cpi->comp_pred_count[i];
+ }
+
+ if (comp_count_zero == 0) {
+ cpi->common.comp_pred_mode = SINGLE_PREDICTION_ONLY;
+ } else if (single_count_zero == 0) {
+ cpi->common.comp_pred_mode = COMP_PREDICTION_ONLY;
+ }
}
+ } else {
+ encode_frame_internal(cpi);
+ }
}
-void vp8_setup_block_ptrs(MACROBLOCK *x)
-{
- int r, c;
- int i;
+void vp8_setup_block_ptrs(MACROBLOCK *x) {
+ int r, c;
+ int i;
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- x->block[r*4+c].src_diff = x->src_diff + r * 4 * 16 + c * 4;
- }
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ x->block[r * 4 + c].src_diff = x->src_diff + r * 4 * 16 + c * 4;
}
+ }
- for (r = 0; r < 2; r++)
- {
- for (c = 0; c < 2; c++)
- {
- x->block[16 + r*2+c].src_diff = x->src_diff + 256 + r * 4 * 8 + c * 4;
- }
+ for (r = 0; r < 2; r++) {
+ for (c = 0; c < 2; c++) {
+ x->block[16 + r * 2 + c].src_diff = x->src_diff + 256 + r * 4 * 8 + c * 4;
}
+ }
- for (r = 0; r < 2; r++)
- {
- for (c = 0; c < 2; c++)
- {
- x->block[20 + r*2+c].src_diff = x->src_diff + 320 + r * 4 * 8 + c * 4;
- }
+ for (r = 0; r < 2; r++) {
+ for (c = 0; c < 2; c++) {
+ x->block[20 + r * 2 + c].src_diff = x->src_diff + 320 + r * 4 * 8 + c * 4;
}
+ }
- x->block[24].src_diff = x->src_diff + 384;
+ x->block[24].src_diff = x->src_diff + 384;
- for (i = 0; i < 25; i++)
- {
- x->block[i].coeff = x->coeff + i * 16;
- }
+ for (i = 0; i < 25; i++) {
+ x->block[i].coeff = x->coeff + i * 16;
+ }
}
-void vp8_build_block_offsets(MACROBLOCK *x)
-{
- int block = 0;
- int br, bc;
-
- vp8_build_block_doffsets(&x->e_mbd);
-
- // y blocks
- x->thismb_ptr = &x->thismb[0];
- for (br = 0; br < 4; br++)
- {
- for (bc = 0; bc < 4; bc++)
- {
- BLOCK *this_block = &x->block[block];
- //this_block->base_src = &x->src.y_buffer;
- //this_block->src_stride = x->src.y_stride;
- //this_block->src = 4 * br * this_block->src_stride + 4 * bc;
- this_block->base_src = &x->thismb_ptr;
- this_block->src_stride = 16;
- this_block->src = 4 * br * 16 + 4 * bc;
- ++block;
- }
+void vp8_build_block_offsets(MACROBLOCK *x) {
+ int block = 0;
+ int br, bc;
+
+ vp8_build_block_doffsets(&x->e_mbd);
+
+ // y blocks
+ x->thismb_ptr = &x->thismb[0];
+ for (br = 0; br < 4; br++) {
+ for (bc = 0; bc < 4; bc++) {
+ BLOCK *this_block = &x->block[block];
+ // this_block->base_src = &x->src.y_buffer;
+ // this_block->src_stride = x->src.y_stride;
+ // this_block->src = 4 * br * this_block->src_stride + 4 * bc;
+ this_block->base_src = &x->thismb_ptr;
+ this_block->src_stride = 16;
+ this_block->src = 4 * br * 16 + 4 * bc;
+ ++block;
}
-
- // u blocks
- for (br = 0; br < 2; br++)
- {
- for (bc = 0; bc < 2; bc++)
- {
- BLOCK *this_block = &x->block[block];
- this_block->base_src = &x->src.u_buffer;
- this_block->src_stride = x->src.uv_stride;
- this_block->src = 4 * br * this_block->src_stride + 4 * bc;
- ++block;
- }
+ }
+
+ // u blocks
+ for (br = 0; br < 2; br++) {
+ for (bc = 0; bc < 2; bc++) {
+ BLOCK *this_block = &x->block[block];
+ this_block->base_src = &x->src.u_buffer;
+ this_block->src_stride = x->src.uv_stride;
+ this_block->src = 4 * br * this_block->src_stride + 4 * bc;
+ ++block;
}
-
- // v blocks
- for (br = 0; br < 2; br++)
- {
- for (bc = 0; bc < 2; bc++)
- {
- BLOCK *this_block = &x->block[block];
- this_block->base_src = &x->src.v_buffer;
- this_block->src_stride = x->src.uv_stride;
- this_block->src = 4 * br * this_block->src_stride + 4 * bc;
- ++block;
- }
+ }
+
+ // v blocks
+ for (br = 0; br < 2; br++) {
+ for (bc = 0; bc < 2; bc++) {
+ BLOCK *this_block = &x->block[block];
+ this_block->base_src = &x->src.v_buffer;
+ this_block->src_stride = x->src.uv_stride;
+ this_block->src = 4 * br * this_block->src_stride + 4 * bc;
+ ++block;
}
+ }
}
-static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x)
-{
- const MACROBLOCKD *xd = & x->e_mbd;
- const MB_PREDICTION_MODE m = xd->mode_info_context->mbmi.mode;
- const MB_PREDICTION_MODE uvm = xd->mode_info_context->mbmi.uv_mode;
+static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x) {
+ const MACROBLOCKD *xd = & x->e_mbd;
+ const MB_PREDICTION_MODE m = xd->mode_info_context->mbmi.mode;
+ const MB_PREDICTION_MODE uvm = xd->mode_info_context->mbmi.uv_mode;
#ifdef MODE_STATS
- const int is_key = cpi->common.frame_type == KEY_FRAME;
+ const int is_key = cpi->common.frame_type == KEY_FRAME;
- ++ (is_key ? uv_modes : inter_uv_modes)[uvm];
- ++ uv_modes_y[m][uvm];
+ ++ (is_key ? uv_modes : inter_uv_modes)[uvm];
+ ++ uv_modes_y[m][uvm];
- if (m == B_PRED)
- {
- unsigned int *const bct = is_key ? b_modes : inter_b_modes;
+ if (m == B_PRED) {
+ unsigned int *const bct = is_key ? b_modes : inter_b_modes;
- int b = 0;
+ int b = 0;
- do
- {
- ++ bct[xd->block[b].bmi.as_mode.first];
- }
- while (++b < 16);
- }
+ do {
+ ++ bct[xd->block[b].bmi.as_mode.first];
+ } while (++b < 16);
+ }
- if(m==I8X8_PRED)
- {
- i8x8_modes[xd->block[0].bmi.as_mode.first]++;
- i8x8_modes[xd->block[2].bmi.as_mode.first]++;
- i8x8_modes[xd->block[8].bmi.as_mode.first]++;
- i8x8_modes[xd->block[10].bmi.as_mode.first]++;
- }
+ if (m == I8X8_PRED) {
+ i8x8_modes[xd->block[0].bmi.as_mode.first]++;
+ i8x8_modes[xd->block[2].bmi.as_mode.first]++;
+ i8x8_modes[xd->block[8].bmi.as_mode.first]++;
+ i8x8_modes[xd->block[10].bmi.as_mode.first]++;
+ }
#endif
- ++cpi->ymode_count[m];
- if (m!=I8X8_PRED)
- ++cpi->y_uv_mode_count[m][uvm];
- else
- {
- cpi->i8x8_mode_count[xd->block[0].bmi.as_mode.first]++;
- cpi->i8x8_mode_count[xd->block[2].bmi.as_mode.first]++;
- cpi->i8x8_mode_count[xd->block[8].bmi.as_mode.first]++;
- cpi->i8x8_mode_count[xd->block[10].bmi.as_mode.first]++;
- }
- if (m == B_PRED)
- {
- int b = 0;
- do
- {
- ++ cpi->bmode_count[xd->block[b].bmi.as_mode.first];
- }
- while (++b < 16);
- }
+ ++cpi->ymode_count[m];
+ if (m != I8X8_PRED)
+ ++cpi->y_uv_mode_count[m][uvm];
+ else {
+ cpi->i8x8_mode_count[xd->block[0].bmi.as_mode.first]++;
+ cpi->i8x8_mode_count[xd->block[2].bmi.as_mode.first]++;
+ cpi->i8x8_mode_count[xd->block[8].bmi.as_mode.first]++;
+ cpi->i8x8_mode_count[xd->block[10].bmi.as_mode.first]++;
+ }
+ if (m == B_PRED) {
+ int b = 0;
+ do {
+ ++ cpi->bmode_count[xd->block[b].bmi.as_mode.first];
+ } while (++b < 16);
+ }
}
// Experimental stub function to create a per MB zbin adjustment based on
// some previously calculated measure of MB activity.
-static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x )
-{
+static void adjust_act_zbin(VP8_COMP *cpi, MACROBLOCK *x) {
#if USE_ACT_INDEX
- x->act_zbin_adj = *(x->mb_activity_ptr);
+ x->act_zbin_adj = *(x->mb_activity_ptr);
#else
- int64_t a;
- int64_t b;
- int64_t act = *(x->mb_activity_ptr);
-
- // Apply the masking to the RD multiplier.
- a = act + 4*cpi->activity_avg;
- b = 4*act + cpi->activity_avg;
-
- if ( act > cpi->activity_avg )
- x->act_zbin_adj = (int)(((int64_t)b + (a>>1))/a) - 1;
- else
- x->act_zbin_adj = 1 - (int)(((int64_t)a + (b>>1))/b);
+ int64_t a;
+ int64_t b;
+ int64_t act = *(x->mb_activity_ptr);
+
+ // Apply the masking to the RD multiplier.
+ a = act + 4 * cpi->activity_avg;
+ b = 4 * act + cpi->activity_avg;
+
+ if (act > cpi->activity_avg)
+ x->act_zbin_adj = (int)(((int64_t)b + (a >> 1)) / a) - 1;
+ else
+ x->act_zbin_adj = 1 - (int)(((int64_t)a + (b >> 1)) / b);
#endif
}
void vp8cx_encode_intra_macro_block(VP8_COMP *cpi,
- MACROBLOCK *x,
- TOKENEXTRA **t,
- int output_enabled)
-{
- if((cpi->oxcf.tuning == VP8_TUNE_SSIM) && output_enabled)
- {
- adjust_act_zbin( cpi, x );
- vp8_update_zbin_extra(cpi, x);
- }
-
- /* test code: set transform size based on mode selection */
- if(cpi->common.txfm_mode == ALLOW_8X8
- && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != B_PRED)
- {
- x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
- cpi->t8x8_count++;
- }
- else
- {
- x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
- cpi->t4x4_count ++;
- }
-
- if(x->e_mbd.mode_info_context->mbmi.mode == I8X8_PRED)
- {
- vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
- vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
- }
- else if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
- vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
- else
- vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
-
- if(x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED)
- vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
-
- if (output_enabled)
- {
- // Tokenize
- sum_intra_stats(cpi, x);
- vp8_tokenize_mb(cpi, &x->e_mbd, t);
- }
+ MACROBLOCK *x,
+ TOKENEXTRA **t,
+ int output_enabled) {
+ if ((cpi->oxcf.tuning == VP8_TUNE_SSIM) && output_enabled) {
+ adjust_act_zbin(cpi, x);
+ vp8_update_zbin_extra(cpi, x);
+ }
+
+ /* test code: set transform size based on mode selection */
+ if (cpi->common.txfm_mode == ALLOW_8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != B_PRED) {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
+ cpi->t8x8_count++;
+ } else {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
+ cpi->t4x4_count++;
+ }
+
+ if (x->e_mbd.mode_info_context->mbmi.mode == I8X8_PRED) {
+ vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
+ vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
+ } else if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
+ vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
+ else
+ vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
+
+ if (x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED)
+ vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
+
+ if (output_enabled) {
+ // Tokenize
+ sum_intra_stats(cpi, x);
+ vp8_tokenize_mb(cpi, &x->e_mbd, t);
+ }
}
#ifdef SPEEDSTATS
extern int cnt_pm;
@@ -1667,201 +1553,174 @@ extern void vp8_fix_contexts(MACROBLOCKD *x);
void vp8cx_encode_inter_macroblock
(
- VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t,
- int recon_yoffset, int recon_uvoffset,
- int output_enabled
-)
-{
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *const xd = &x->e_mbd;
- unsigned char *segment_id = &xd->mode_info_context->mbmi.segment_id;
- int seg_ref_active;
- unsigned char ref_pred_flag;
-
- x->skip = 0;
-
- if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
- {
- // Adjust the zbin based on this MB rate.
- adjust_act_zbin( cpi, x );
+ VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t,
+ int recon_yoffset, int recon_uvoffset,
+ int output_enabled
+) {
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ unsigned char *segment_id = &xd->mode_info_context->mbmi.segment_id;
+ int seg_ref_active;
+ unsigned char ref_pred_flag;
+
+ x->skip = 0;
+
+ if (cpi->oxcf.tuning == VP8_TUNE_SSIM) {
+ // Adjust the zbin based on this MB rate.
+ adjust_act_zbin(cpi, x);
+ }
+
+ {
+ // Experimental code. Special case for gf and arf zeromv modes.
+ // Increase zbin size to suppress noise
+ cpi->zbin_mode_boost = 0;
+ if (cpi->zbin_mode_boost_enabled) {
+ if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME) {
+ if (xd->mode_info_context->mbmi.mode == ZEROMV) {
+ if (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME)
+ cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
+ else
+ cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
+ } else if (xd->mode_info_context->mbmi.mode == SPLITMV)
+ cpi->zbin_mode_boost = 0;
+ else
+ cpi->zbin_mode_boost = MV_ZBIN_BOOST;
+ }
}
- {
- // Experimental code. Special case for gf and arf zeromv modes.
- // Increase zbin size to suppress noise
- cpi->zbin_mode_boost = 0;
- if (cpi->zbin_mode_boost_enabled)
- {
- if ( xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME )
- {
- if (xd->mode_info_context->mbmi.mode == ZEROMV)
- {
- if (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME)
- cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
- else
- cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
- }
- else if (xd->mode_info_context->mbmi.mode == SPLITMV)
- cpi->zbin_mode_boost = 0;
- else
- cpi->zbin_mode_boost = MV_ZBIN_BOOST;
- }
- }
-
- vp8_update_zbin_extra(cpi, x);
+ vp8_update_zbin_extra(cpi, x);
+ }
+
+ seg_ref_active = segfeature_active(xd, *segment_id, SEG_LVL_REF_FRAME);
+
+ // SET VARIOUS PREDICTION FLAGS
+
+ // Did the chosen reference frame match its predicted value.
+ ref_pred_flag = ((xd->mode_info_context->mbmi.ref_frame ==
+ get_pred_ref(cm, xd)));
+ set_pred_flag(xd, PRED_REF, ref_pred_flag);
+
+ /* test code: set transform size based on mode selection */
+ if (cpi->common.txfm_mode == ALLOW_8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV) {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
+ cpi->t8x8_count++;
+ } else {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
+ cpi->t4x4_count++;
+ }
+
+ if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
+ if (xd->mode_info_context->mbmi.mode == B_PRED) {
+ vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
+ vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
+ } else if (xd->mode_info_context->mbmi.mode == I8X8_PRED) {
+ vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
+ vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
+ } else {
+ vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
+ vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
}
- seg_ref_active = segfeature_active( xd, *segment_id, SEG_LVL_REF_FRAME );
-
- // SET VARIOUS PREDICTION FLAGS
-
- // Did the chosen reference frame match its predicted value.
- ref_pred_flag = ( (xd->mode_info_context->mbmi.ref_frame ==
- get_pred_ref( cm, xd )) );
- set_pred_flag( xd, PRED_REF, ref_pred_flag );
-
- /* test code: set transform size based on mode selection */
- if( cpi->common.txfm_mode == ALLOW_8X8
- && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- {
- x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
- cpi->t8x8_count ++;
- }
+ if (output_enabled)
+ sum_intra_stats(cpi, x);
+ } else {
+ int ref_fb_idx;
+
+ if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
+ ref_fb_idx = cpi->common.lst_fb_idx;
+ else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
+ ref_fb_idx = cpi->common.gld_fb_idx;
else
- {
- x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
- cpi->t4x4_count++;
+ ref_fb_idx = cpi->common.alt_fb_idx;
+
+ xd->pre.y_buffer = cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
+ xd->pre.u_buffer = cpi->common.yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
+ xd->pre.v_buffer = cpi->common.yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset;
+
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ int second_ref_fb_idx;
+
+ if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
+ second_ref_fb_idx = cpi->common.lst_fb_idx;
+ else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
+ second_ref_fb_idx = cpi->common.gld_fb_idx;
+ else
+ second_ref_fb_idx = cpi->common.alt_fb_idx;
+
+ xd->second_pre.y_buffer = cpi->common.yv12_fb[second_ref_fb_idx].y_buffer +
+ recon_yoffset;
+ xd->second_pre.u_buffer = cpi->common.yv12_fb[second_ref_fb_idx].u_buffer +
+ recon_uvoffset;
+ xd->second_pre.v_buffer = cpi->common.yv12_fb[second_ref_fb_idx].v_buffer +
+ recon_uvoffset;
}
- if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
- {
- if (xd->mode_info_context->mbmi.mode == B_PRED)
- {
- vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
- vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
- }
- else if(xd->mode_info_context->mbmi.mode == I8X8_PRED)
- {
- vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
- vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
- }
- else
- {
- vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
- vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
- }
+ if (!x->skip) {
+ vp8_encode_inter16x16(IF_RTCD(&cpi->rtcd), x);
- if (output_enabled)
- sum_intra_stats(cpi, x);
- }
- else
- {
- int ref_fb_idx;
-
- if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
- ref_fb_idx = cpi->common.lst_fb_idx;
- else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
- ref_fb_idx = cpi->common.gld_fb_idx;
- else
- ref_fb_idx = cpi->common.alt_fb_idx;
-
- xd->pre.y_buffer = cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
- xd->pre.u_buffer = cpi->common.yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
- xd->pre.v_buffer = cpi->common.yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset;
-
- if (xd->mode_info_context->mbmi.second_ref_frame) {
- int second_ref_fb_idx;
-
- if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = cpi->common.lst_fb_idx;
- else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
- second_ref_fb_idx = cpi->common.gld_fb_idx;
- else
- second_ref_fb_idx = cpi->common.alt_fb_idx;
-
- xd->second_pre.y_buffer = cpi->common.yv12_fb[second_ref_fb_idx].y_buffer +
- recon_yoffset;
- xd->second_pre.u_buffer = cpi->common.yv12_fb[second_ref_fb_idx].u_buffer +
- recon_uvoffset;
- xd->second_pre.v_buffer = cpi->common.yv12_fb[second_ref_fb_idx].v_buffer +
- recon_uvoffset;
- }
+ // Clear mb_skip_coeff if mb_no_coeff_skip is not set
+ if (!cpi->common.mb_no_coeff_skip)
+ xd->mode_info_context->mbmi.mb_skip_coeff = 0;
- if (!x->skip)
- {
- vp8_encode_inter16x16(IF_RTCD(&cpi->rtcd), x);
-
- // Clear mb_skip_coeff if mb_no_coeff_skip is not set
- if (!cpi->common.mb_no_coeff_skip)
- xd->mode_info_context->mbmi.mb_skip_coeff = 0;
-
- }
- else
- {
- vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
- xd->dst.u_buffer, xd->dst.v_buffer,
- xd->dst.y_stride, xd->dst.uv_stride);
- }
+ } else {
+ vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
+ xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.y_stride, xd->dst.uv_stride);
}
+ }
- if (!x->skip)
- {
+ if (!x->skip) {
#ifdef ENC_DEBUG
- if (enc_debug)
- {
- int i;
- printf("Segment=%d [%d, %d]: %d %d:\n", x->e_mbd.mode_info_context->mbmi.segment_id, mb_col_debug, mb_row_debug, xd->mb_to_left_edge, xd->mb_to_top_edge);
- for (i =0; i<400; i++) {
- printf("%3d ", xd->qcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("\n");
- printf("eobs = ");
- for (i=0;i<25;i++)
- printf("%d:%d ", i, xd->block[i].eob);
- printf("\n");
- fflush(stdout);
- }
+ if (enc_debug) {
+ int i;
+ printf("Segment=%d [%d, %d]: %d %d:\n", x->e_mbd.mode_info_context->mbmi.segment_id, mb_col_debug, mb_row_debug, xd->mb_to_left_edge, xd->mb_to_top_edge);
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", xd->qcoeff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("\n");
+ printf("eobs = ");
+ for (i = 0; i < 25; i++)
+ printf("%d:%d ", i, xd->block[i].eob);
+ printf("\n");
+ fflush(stdout);
+ }
#endif
- if (output_enabled)
- vp8_tokenize_mb(cpi, xd, t);
+ if (output_enabled)
+ vp8_tokenize_mb(cpi, xd, t);
#ifdef ENC_DEBUG
- if (enc_debug) {
- printf("Tokenized\n");
- fflush(stdout);
- }
-#endif
+ if (enc_debug) {
+ printf("Tokenized\n");
+ fflush(stdout);
}
- else
- {
+#endif
+ } else {
#if CONFIG_NEWENTROPY
- int mb_skip_context =
- cpi->common.mb_no_coeff_skip ?
- (x->e_mbd.mode_info_context-1)->mbmi.mb_skip_coeff +
- (x->e_mbd.mode_info_context-cpi->common.mode_info_stride)->mbmi.mb_skip_coeff :
- 0;
+ int mb_skip_context =
+ cpi->common.mb_no_coeff_skip ?
+ (x->e_mbd.mode_info_context - 1)->mbmi.mb_skip_coeff +
+ (x->e_mbd.mode_info_context - cpi->common.mode_info_stride)->mbmi.mb_skip_coeff :
+ 0;
#endif
- if (cpi->common.mb_no_coeff_skip)
- {
- xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+ if (cpi->common.mb_no_coeff_skip) {
+ xd->mode_info_context->mbmi.mb_skip_coeff = 1;
#if CONFIG_NEWENTROPY
- cpi->skip_true_count[mb_skip_context] ++;
+ cpi->skip_true_count[mb_skip_context]++;
#else
- cpi->skip_true_count ++;
+ cpi->skip_true_count++;
#endif
- vp8_fix_contexts(xd);
- }
- else
- {
- vp8_stuff_mb(cpi, xd, t);
- xd->mode_info_context->mbmi.mb_skip_coeff = 0;
+ vp8_fix_contexts(xd);
+ } else {
+ vp8_stuff_mb(cpi, xd, t);
+ xd->mode_info_context->mbmi.mb_skip_coeff = 0;
#if CONFIG_NEWENTROPY
- cpi->skip_false_count[mb_skip_context] ++;
+ cpi->skip_false_count[mb_skip_context]++;
#else
- cpi->skip_false_count ++;
+ cpi->skip_false_count++;
#endif
- }
}
+ }
}
diff --git a/vp8/encoder/encodeintra.c b/vp8/encoder/encodeintra.c
index bb7a1aa74..7d1453218 100644
--- a/vp8/encoder/encodeintra.c
+++ b/vp8/encoder/encodeintra.c
@@ -32,338 +32,308 @@ extern int enc_debug;
#define IF_RTCD(x) NULL
#endif
-int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_16x16_pred)
-{
+int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) {
- int i;
- int intra_pred_var = 0;
- (void) cpi;
+ int i;
+ int intra_pred_var = 0;
+ (void) cpi;
- if (use_16x16_pred)
- {
- x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;
+ if (use_16x16_pred) {
+ x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;
#if CONFIG_COMP_INTRA_PRED
- x->e_mbd.mode_info_context->mbmi.second_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
+ x->e_mbd.mode_info_context->mbmi.second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
- x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
- x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-
- vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
- }
- else
- {
- for (i = 0; i < 16; i++)
- {
- x->e_mbd.block[i].bmi.as_mode.first = B_DC_PRED;
- vp8_encode_intra4x4block(IF_RTCD(&cpi->rtcd), x, i);
- }
+ x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
+ x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
+
+ vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
+ } else {
+ for (i = 0; i < 16; i++) {
+ x->e_mbd.block[i].bmi.as_mode.first = B_DC_PRED;
+ vp8_encode_intra4x4block(IF_RTCD(&cpi->rtcd), x, i);
}
+ }
- intra_pred_var = VARIANCE_INVOKE(&cpi->rtcd.variance, getmbss)(x->src_diff);
+ intra_pred_var = VARIANCE_INVOKE(&cpi->rtcd.variance, getmbss)(x->src_diff);
- return intra_pred_var;
+ return intra_pred_var;
}
void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd,
- MACROBLOCK *x, int ib)
-{
- BLOCKD *b = &x->e_mbd.block[ib];
- BLOCK *be = &x->block[ib];
+ MACROBLOCK *x, int ib) {
+ BLOCKD *b = &x->e_mbd.block[ib];
+ BLOCK *be = &x->block[ib];
#if CONFIG_COMP_INTRA_PRED
- if (b->bmi.as_mode.second == (B_PREDICTION_MODE) (B_DC_PRED - 1))
- {
+ if (b->bmi.as_mode.second == (B_PREDICTION_MODE)(B_DC_PRED - 1)) {
#endif
RECON_INVOKE(&rtcd->common->recon, intra4x4_predict)
- (b, b->bmi.as_mode.first, b->predictor);
+ (b, b->bmi.as_mode.first, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(&rtcd->common->recon, comp_intra4x4_predict)
- (b, b->bmi.as_mode.first, b->bmi.as_mode.second, b->predictor);
- }
+ } else {
+ RECON_INVOKE(&rtcd->common->recon, comp_intra4x4_predict)
+ (b, b->bmi.as_mode.first, b->bmi.as_mode.second, b->predictor);
+ }
#endif
- ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
+ ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
- x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
+ x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
- x->quantize_b(be, b);
+ x->quantize_b(be, b);
- vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32);
+ vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32);
- RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
}
-void vp8_encode_intra4x4mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb)
-{
- int i;
+void vp8_encode_intra4x4mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb) {
+ int i;
#if 0
- MACROBLOCKD *x = &mb->e_mbd;
- // Intra modes requiring top-right MB reconstructed data have been disabled
- vp8_intra_prediction_down_copy(x);
+ MACROBLOCKD *x = &mb->e_mbd;
+ // Intra modes requiring top-right MB reconstructed data have been disabled
+ vp8_intra_prediction_down_copy(x);
#endif
- for (i = 0; i < 16; i++)
- vp8_encode_intra4x4block(rtcd, mb, i);
- return;
+ for (i = 0; i < 16; i++)
+ vp8_encode_intra4x4block(rtcd, mb, i);
+ return;
}
-void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- BLOCK *b = &x->block[0];
+void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ BLOCK *b = &x->block[0];
- int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#if CONFIG_COMP_INTRA_PRED
- if (x->e_mbd.mode_info_context->mbmi.second_mode == (MB_PREDICTION_MODE) (DC_PRED - 1))
+ if (x->e_mbd.mode_info_context->mbmi.second_mode == (MB_PREDICTION_MODE)(DC_PRED - 1))
#endif
RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mby)(&x->e_mbd);
#if CONFIG_COMP_INTRA_PRED
- else
- RECON_INVOKE(&rtcd->common->recon, build_comp_intra_predictors_mby)(&x->e_mbd);
+ else
+ RECON_INVOKE(&rtcd->common->recon, build_comp_intra_predictors_mby)(&x->e_mbd);
#endif
- ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
- if( tx_type == TX_8X8 )
- vp8_transform_intra_mby_8x8(x);
- else
- vp8_transform_intra_mby(x);
+ if (tx_type == TX_8X8)
+ vp8_transform_intra_mby_8x8(x);
+ else
+ vp8_transform_intra_mby(x);
- if(tx_type == TX_8X8)
- vp8_quantize_mby_8x8(x);
- else
- vp8_quantize_mby(x);
-
- if (x->optimize)
- {
- if( tx_type == TX_8X8 )
- vp8_optimize_mby_8x8(x, rtcd);
- else
- vp8_optimize_mby(x, rtcd);
- }
+ if (tx_type == TX_8X8)
+ vp8_quantize_mby_8x8(x);
+ else
+ vp8_quantize_mby(x);
- if(tx_type == TX_8X8)
- vp8_inverse_transform_mby_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ if (x->optimize) {
+ if (tx_type == TX_8X8)
+ vp8_optimize_mby_8x8(x, rtcd);
else
- vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ vp8_optimize_mby(x, rtcd);
+ }
+
+ if (tx_type == TX_8X8)
+ vp8_inverse_transform_mby_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ else
+ vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
#ifdef ENC_DEBUG
- if (enc_debug) {
- int i;
- printf("Intra qcoeff:\n");
- printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.qcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("Intra dqcoeff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.dqcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("Intra diff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.diff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("Intra predictor:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.predictor[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("eobs:\n");
- for (i=0;i<25;i++)
- printf("%d ", x->e_mbd.block[i].eob);
- printf("\n");
+ if (enc_debug) {
+ int i;
+ printf("Intra qcoeff:\n");
+ printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.qcoeff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("Intra dqcoeff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.dqcoeff[i]);
+ if (i % 16 == 15) printf("\n");
}
+ printf("Intra diff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.diff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("Intra predictor:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.predictor[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("eobs:\n");
+ for (i = 0; i < 25; i++)
+ printf("%d ", x->e_mbd.block[i].eob);
+ printf("\n");
+ }
#endif
- RECON_INVOKE(&rtcd->common->recon, recon_mby)
- (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
+ RECON_INVOKE(&rtcd->common->recon, recon_mby)
+ (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
}
-void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
+void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#if CONFIG_COMP_INTRA_PRED
- if (x->e_mbd.mode_info_context->mbmi.second_uv_mode == (MB_PREDICTION_MODE) (DC_PRED - 1))
- {
+ if (x->e_mbd.mode_info_context->mbmi.second_uv_mode == (MB_PREDICTION_MODE)(DC_PRED - 1)) {
#endif
RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mbuv)(&x->e_mbd);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(&rtcd->common->recon, build_comp_intra_predictors_mbuv)(&x->e_mbd);
- }
+ } else {
+ RECON_INVOKE(&rtcd->common->recon, build_comp_intra_predictors_mbuv)(&x->e_mbd);
+ }
#endif
- ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
- if(tx_type == TX_8X8)
- vp8_transform_mbuv_8x8(x);
- else
- vp8_transform_mbuv(x);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
+ if (tx_type == TX_8X8)
+ vp8_transform_mbuv_8x8(x);
+ else
+ vp8_transform_mbuv(x);
- if(tx_type == TX_8X8)
- vp8_quantize_mbuv_8x8(x);
- else
- vp8_quantize_mbuv(x);
+ if (tx_type == TX_8X8)
+ vp8_quantize_mbuv_8x8(x);
+ else
+ vp8_quantize_mbuv(x);
#ifdef ENC_DEBUG
- if (enc_debug) {
- int i;
- printf("vp8_encode_intra16x16mbuv\n");
- printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
- printf("qcoeff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.qcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("dqcoeff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.dqcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("diff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.diff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("predictor:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.predictor[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("eobs:\n");
- for (i=0;i<25;i++)
- printf("%d ", x->e_mbd.block[i].eob);
- printf("\n");
+ if (enc_debug) {
+ int i;
+ printf("vp8_encode_intra16x16mbuv\n");
+ printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
+ printf("qcoeff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.qcoeff[i]);
+ if (i % 16 == 15) printf("\n");
}
-#endif
- if (x->optimize)
- {
- if(tx_type == TX_8X8)
- vp8_optimize_mbuv_8x8(x, rtcd);
- else
- vp8_optimize_mbuv(x, rtcd);
+ printf("dqcoeff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.dqcoeff[i]);
+ if (i % 16 == 15) printf("\n");
}
-
- if(tx_type == TX_8X8)
- vp8_inverse_transform_mbuv_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ printf("diff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.diff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("predictor:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.predictor[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("eobs:\n");
+ for (i = 0; i < 25; i++)
+ printf("%d ", x->e_mbd.block[i].eob);
+ printf("\n");
+ }
+#endif
+ if (x->optimize) {
+ if (tx_type == TX_8X8)
+ vp8_optimize_mbuv_8x8(x, rtcd);
else
- vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ vp8_optimize_mbuv(x, rtcd);
+ }
+
+ if (tx_type == TX_8X8)
+ vp8_inverse_transform_mbuv_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ else
+ vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
- vp8_recon_intra_mbuv(IF_RTCD(&rtcd->common->recon), &x->e_mbd);
+ vp8_recon_intra_mbuv(IF_RTCD(&rtcd->common->recon), &x->e_mbd);
}
void vp8_encode_intra8x8(const VP8_ENCODER_RTCD *rtcd,
- MACROBLOCK *x, int ib)
-{
- BLOCKD *b = &x->e_mbd.block[ib];
- BLOCK *be = &x->block[ib];
- const int iblock[4]={0,1,4,5};
- int i;
+ MACROBLOCK *x, int ib) {
+ BLOCKD *b = &x->e_mbd.block[ib];
+ BLOCK *be = &x->block[ib];
+ const int iblock[4] = {0, 1, 4, 5};
+ int i;
#if CONFIG_COMP_INTRA_PRED
- if (b->bmi.as_mode.second == (MB_PREDICTION_MODE) (DC_PRED - 1))
- {
+ if (b->bmi.as_mode.second == (MB_PREDICTION_MODE)(DC_PRED - 1)) {
#endif
RECON_INVOKE(&rtcd->common->recon, intra8x8_predict)
- (b, b->bmi.as_mode.first, b->predictor);
+ (b, b->bmi.as_mode.first, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(&rtcd->common->recon, comp_intra8x8_predict)
- (b, b->bmi.as_mode.first, b->bmi.as_mode.second, b->predictor);
- }
+ } else {
+ RECON_INVOKE(&rtcd->common->recon, comp_intra8x8_predict)
+ (b, b->bmi.as_mode.first, b->bmi.as_mode.second, b->predictor);
+ }
#endif
- for(i=0;i<4;i++)
- {
- b = &x->e_mbd.block[ib + iblock[i]];
- be = &x->block[ib + iblock[i]];
- ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
- x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
- x->quantize_b(be, b);
- vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32);
- RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor,
- b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- }
+ for (i = 0; i < 4; i++) {
+ b = &x->e_mbd.block[ib + iblock[i]];
+ be = &x->block[ib + iblock[i]];
+ ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
+ x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
+ x->quantize_b(be, b);
+ vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32);
+ RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor,
+ b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ }
}
extern const int vp8_i8x8_block[4];
-void vp8_encode_intra8x8mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- int i, ib;
-
- for(i=0;i<4;i++)
- {
- ib = vp8_i8x8_block[i];
- vp8_encode_intra8x8(rtcd, x, ib);
- }
+void vp8_encode_intra8x8mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ int i, ib;
+
+ for (i = 0; i < 4; i++) {
+ ib = vp8_i8x8_block[i];
+ vp8_encode_intra8x8(rtcd, x, ib);
+ }
}
void vp8_encode_intra_uv4x4(const VP8_ENCODER_RTCD *rtcd,
- MACROBLOCK *x, int ib,
- int mode, int second)
-{
- BLOCKD *b = &x->e_mbd.block[ib];
- BLOCK *be = &x->block[ib];
+ MACROBLOCK *x, int ib,
+ int mode, int second) {
+ BLOCKD *b = &x->e_mbd.block[ib];
+ BLOCK *be = &x->block[ib];
#if CONFIG_COMP_INTRA_PRED
- if (second == -1)
- {
+ if (second == -1) {
#endif
RECON_INVOKE(&rtcd->common->recon, intra_uv4x4_predict)
- (b, mode, b->predictor);
+ (b, mode, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(&rtcd->common->recon, comp_intra_uv4x4_predict)
- (b, mode, second, b->predictor);
- }
+ } else {
+ RECON_INVOKE(&rtcd->common->recon, comp_intra_uv4x4_predict)
+ (b, mode, second, b->predictor);
+ }
#endif
- ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 8);
+ ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 8);
- x->vp8_short_fdct4x4(be->src_diff, be->coeff, 16);
+ x->vp8_short_fdct4x4(be->src_diff, be->coeff, 16);
- x->quantize_b(be, b);
+ x->quantize_b(be, b);
- vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 16);
+ vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 16);
- RECON_INVOKE(&rtcd->common->recon, recon_uv)(b->predictor,
- b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ RECON_INVOKE(&rtcd->common->recon, recon_uv)(b->predictor,
+ b->diff, *(b->base_dst) + b->dst, b->dst_stride);
}
-void vp8_encode_intra8x8mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- int i, ib, mode, second;
- BLOCKD *b;
- for(i=0;i<4;i++)
- {
- ib = vp8_i8x8_block[i];
- b = &x->e_mbd.block[ib];
- mode = b->bmi.as_mode.first;
+void vp8_encode_intra8x8mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ int i, ib, mode, second;
+ BLOCKD *b;
+ for (i = 0; i < 4; i++) {
+ ib = vp8_i8x8_block[i];
+ b = &x->e_mbd.block[ib];
+ mode = b->bmi.as_mode.first;
#if CONFIG_COMP_INTRA_PRED
- second = b->bmi.as_mode.second;
+ second = b->bmi.as_mode.second;
#else
- second = -1;
+ second = -1;
#endif
- /*u */
- vp8_encode_intra_uv4x4(rtcd, x, i+16, mode, second);
- /*v */
- vp8_encode_intra_uv4x4(rtcd, x, i+20, mode, second);
- }
+ /*u */
+ vp8_encode_intra_uv4x4(rtcd, x, i + 16, mode, second);
+ /*v */
+ vp8_encode_intra_uv4x4(rtcd, x, i + 20, mode, second);
+ }
}
diff --git a/vp8/encoder/encodeintra.h b/vp8/encoder/encodeintra.h
index ae822d3d9..7d122938f 100644
--- a/vp8/encoder/encodeintra.h
+++ b/vp8/encoder/encodeintra.h
@@ -22,6 +22,6 @@ void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd,
void vp8_encode_intra8x8mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x);
void vp8_encode_intra8x8mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x);
void vp8_encode_intra8x8(const VP8_ENCODER_RTCD *rtcd,
- MACROBLOCK *x, int ib);
+ MACROBLOCK *x, int ib);
#endif
diff --git a/vp8/encoder/encodemb.c b/vp8/encoder/encodemb.c
index dcf479f61..fac2adddf 100644
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -32,309 +32,267 @@
extern int enc_debug;
#endif
-void vp8_subtract_b_c(BLOCK *be, BLOCKD *bd, int pitch)
-{
- unsigned char *src_ptr = (*(be->base_src) + be->src);
- short *diff_ptr = be->src_diff;
- unsigned char *pred_ptr = bd->predictor;
- int src_stride = be->src_stride;
-
- int r, c;
-
- for (r = 0; r < 4; r++)
- {
- for (c = 0; c < 4; c++)
- {
- diff_ptr[c] = src_ptr[c] - pred_ptr[c];
- }
+void vp8_subtract_b_c(BLOCK *be, BLOCKD *bd, int pitch) {
+ unsigned char *src_ptr = (*(be->base_src) + be->src);
+ short *diff_ptr = be->src_diff;
+ unsigned char *pred_ptr = bd->predictor;
+ int src_stride = be->src_stride;
+
+ int r, c;
- diff_ptr += pitch;
- pred_ptr += pitch;
- src_ptr += src_stride;
+ for (r = 0; r < 4; r++) {
+ for (c = 0; c < 4; c++) {
+ diff_ptr[c] = src_ptr[c] - pred_ptr[c];
}
+
+ diff_ptr += pitch;
+ pred_ptr += pitch;
+ src_ptr += src_stride;
+ }
}
-void vp8_subtract_4b_c(BLOCK *be, BLOCKD *bd, int pitch)
-{
- unsigned char *src_ptr = (*(be->base_src) + be->src);
- short *diff_ptr = be->src_diff;
- unsigned char *pred_ptr = bd->predictor;
- int src_stride = be->src_stride;
- int r, c;
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- diff_ptr[c] = src_ptr[c] - pred_ptr[c];
- }
- diff_ptr += pitch;
- pred_ptr += pitch;
- src_ptr += src_stride;
+void vp8_subtract_4b_c(BLOCK *be, BLOCKD *bd, int pitch) {
+ unsigned char *src_ptr = (*(be->base_src) + be->src);
+ short *diff_ptr = be->src_diff;
+ unsigned char *pred_ptr = bd->predictor;
+ int src_stride = be->src_stride;
+ int r, c;
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ diff_ptr[c] = src_ptr[c] - pred_ptr[c];
}
+ diff_ptr += pitch;
+ pred_ptr += pitch;
+ src_ptr += src_stride;
+ }
}
-void vp8_subtract_mbuv_c(short *diff, unsigned char *usrc, unsigned char *vsrc, unsigned char *pred, int stride)
-{
- short *udiff = diff + 256;
- short *vdiff = diff + 320;
- unsigned char *upred = pred + 256;
- unsigned char *vpred = pred + 320;
+void vp8_subtract_mbuv_c(short *diff, unsigned char *usrc, unsigned char *vsrc, unsigned char *pred, int stride) {
+ short *udiff = diff + 256;
+ short *vdiff = diff + 320;
+ unsigned char *upred = pred + 256;
+ unsigned char *vpred = pred + 320;
- int r, c;
+ int r, c;
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- udiff[c] = usrc[c] - upred[c];
- }
-
- udiff += 8;
- upred += 8;
- usrc += stride;
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ udiff[c] = usrc[c] - upred[c];
}
- for (r = 0; r < 8; r++)
- {
- for (c = 0; c < 8; c++)
- {
- vdiff[c] = vsrc[c] - vpred[c];
- }
+ udiff += 8;
+ upred += 8;
+ usrc += stride;
+ }
- vdiff += 8;
- vpred += 8;
- vsrc += stride;
+ for (r = 0; r < 8; r++) {
+ for (c = 0; c < 8; c++) {
+ vdiff[c] = vsrc[c] - vpred[c];
}
-}
-void vp8_subtract_mby_c(short *diff, unsigned char *src, unsigned char *pred, int stride)
-{
- int r, c;
+ vdiff += 8;
+ vpred += 8;
+ vsrc += stride;
+ }
+}
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- diff[c] = src[c] - pred[c];
- }
+void vp8_subtract_mby_c(short *diff, unsigned char *src, unsigned char *pred, int stride) {
+ int r, c;
- diff += 16;
- pred += 16;
- src += stride;
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ diff[c] = src[c] - pred[c];
}
+
+ diff += 16;
+ pred += 16;
+ src += stride;
+ }
}
-static void vp8_subtract_mb(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- BLOCK *b = &x->block[0];
+static void vp8_subtract_mb(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ BLOCK *b = &x->block[0];
- ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
- ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
}
-static void build_dcblock(MACROBLOCK *x)
-{
- short *src_diff_ptr = &x->src_diff[384];
- int i;
+static void build_dcblock(MACROBLOCK *x) {
+ short *src_diff_ptr = &x->src_diff[384];
+ int i;
- for (i = 0; i < 16; i++)
- {
- src_diff_ptr[i] = x->coeff[i * 16];
- }
+ for (i = 0; i < 16; i++) {
+ src_diff_ptr[i] = x->coeff[i * 16];
+ }
}
-void vp8_build_dcblock_8x8(MACROBLOCK *x)
-{
- short *src_diff_ptr = &x->src_diff[384];
- int i;
- for (i = 0; i < 16; i++)
- {
- src_diff_ptr[i] = 0;
- }
- src_diff_ptr[0] = x->coeff[0 * 16];
- src_diff_ptr[1] = x->coeff[4 * 16];
- src_diff_ptr[4] = x->coeff[8 * 16];
- src_diff_ptr[8] = x->coeff[12 * 16];
+void vp8_build_dcblock_8x8(MACROBLOCK *x) {
+ short *src_diff_ptr = &x->src_diff[384];
+ int i;
+ for (i = 0; i < 16; i++) {
+ src_diff_ptr[i] = 0;
+ }
+ src_diff_ptr[0] = x->coeff[0 * 16];
+ src_diff_ptr[1] = x->coeff[4 * 16];
+ src_diff_ptr[4] = x->coeff[8 * 16];
+ src_diff_ptr[8] = x->coeff[12 * 16];
}
-void vp8_transform_mbuv(MACROBLOCK *x)
-{
- int i;
+void vp8_transform_mbuv(MACROBLOCK *x) {
+ int i;
- for (i = 16; i < 24; i += 2)
- {
- x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 16);
- }
+ for (i = 16; i < 24; i += 2) {
+ x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 16);
+ }
}
-void vp8_transform_intra_mby(MACROBLOCK *x)
-{
- int i;
+void vp8_transform_intra_mby(MACROBLOCK *x) {
+ int i;
- for (i = 0; i < 16; i += 2)
- {
- x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
+ for (i = 0; i < 16; i += 2) {
+ x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
- // build dc block from 16 y dc values
- build_dcblock(x);
+ // build dc block from 16 y dc values
+ build_dcblock(x);
- // do 2nd order transform on the dc block
- x->short_walsh4x4(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
+ // do 2nd order transform on the dc block
+ x->short_walsh4x4(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
}
-static void transform_mb(MACROBLOCK *x)
-{
- int i;
+static void transform_mb(MACROBLOCK *x) {
+ int i;
- for (i = 0; i < 16; i += 2)
- {
- x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
+ for (i = 0; i < 16; i += 2) {
+ x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
- // build dc block from 16 y dc values
- if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- build_dcblock(x);
+ // build dc block from 16 y dc values
+ if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ build_dcblock(x);
- for (i = 16; i < 24; i += 2)
- {
- x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 16);
- }
+ for (i = 16; i < 24; i += 2) {
+ x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 16);
+ }
- // do 2nd order transform on the dc block
- if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- x->short_walsh4x4(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
+ // do 2nd order transform on the dc block
+ if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ x->short_walsh4x4(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
}
-static void transform_mby(MACROBLOCK *x)
-{
- int i;
+static void transform_mby(MACROBLOCK *x) {
+ int i;
- for (i = 0; i < 16; i += 2)
- {
- x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
+ for (i = 0; i < 16; i += 2) {
+ x->vp8_short_fdct8x4(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
- // build dc block from 16 y dc values
- if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- {
- build_dcblock(x);
- x->short_walsh4x4(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
- }
+ // build dc block from 16 y dc values
+ if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV) {
+ build_dcblock(x);
+ x->short_walsh4x4(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
+ }
}
-void vp8_transform_mbuv_8x8(MACROBLOCK *x)
-{
- int i;
+void vp8_transform_mbuv_8x8(MACROBLOCK *x) {
+ int i;
#if !CONFIG_INT_8X8FDCT
- vp8_clear_system_state();
+ vp8_clear_system_state();
#endif
- for (i = 16; i < 24; i += 4)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 16);
- }
+ for (i = 16; i < 24; i += 4) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 16);
+ }
}
-void vp8_transform_intra_mby_8x8(MACROBLOCK *x)//changed
-{
- int i;
+void vp8_transform_intra_mby_8x8(MACROBLOCK *x) { // changed
+ int i;
#if !CONFIG_INT_8X8FDCT
- vp8_clear_system_state();
+ vp8_clear_system_state();
#endif
- for (i = 0; i < 9; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
- for (i = 2; i < 11; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i+2].coeff[0], 32);
- }
- // build dc block from 16 y dc values
- vp8_build_dcblock_8x8(x);
- //vp8_build_dcblock(x);
-
- // do 2nd order transform on the dc block
- x->short_fhaar2x2(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
+ for (i = 0; i < 9; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
+ for (i = 2; i < 11; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i + 2].coeff[0], 32);
+ }
+ // build dc block from 16 y dc values
+ vp8_build_dcblock_8x8(x);
+ // vp8_build_dcblock(x);
+
+ // do 2nd order transform on the dc block
+ x->short_fhaar2x2(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
}
-void vp8_transform_mb_8x8(MACROBLOCK *x)
-{
- int i;
+void vp8_transform_mb_8x8(MACROBLOCK *x) {
+ int i;
#if !CONFIG_INT_8X8FDCT
- vp8_clear_system_state();
+ vp8_clear_system_state();
#endif
- for (i = 0; i < 9; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
- for (i = 2; i < 11; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i+2].coeff[0], 32);
- }
- // build dc block from 16 y dc values
- if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED &&x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- vp8_build_dcblock_8x8(x);
- //vp8_build_dcblock(x);
-
- for (i = 16; i < 24; i += 4)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 16);
- }
+ for (i = 0; i < 9; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
+ for (i = 2; i < 11; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i + 2].coeff[0], 32);
+ }
+ // build dc block from 16 y dc values
+ if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ vp8_build_dcblock_8x8(x);
+ // vp8_build_dcblock(x);
+
+ for (i = 16; i < 24; i += 4) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 16);
+ }
- // do 2nd order transform on the dc block
- if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED &&x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- x->short_fhaar2x2(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
+ // do 2nd order transform on the dc block
+ if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ x->short_fhaar2x2(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
}
-void vp8_transform_mby_8x8(MACROBLOCK *x)
-{
- int i;
+void vp8_transform_mby_8x8(MACROBLOCK *x) {
+ int i;
#if !CONFIG_INT_8X8FDCT
- vp8_clear_system_state();
+ vp8_clear_system_state();
#endif
- for (i = 0; i < 9; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i].coeff[0], 32);
- }
- for (i = 2; i < 11; i += 8)
- {
- x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
- &x->block[i+2].coeff[0], 32);
- }
- // build dc block from 16 y dc values
- if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
- {
- //vp8_build_dcblock(x);
- vp8_build_dcblock_8x8(x);
- x->short_fhaar2x2(&x->block[24].src_diff[0],
- &x->block[24].coeff[0], 8);
- }
+ for (i = 0; i < 9; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i].coeff[0], 32);
+ }
+ for (i = 2; i < 11; i += 8) {
+ x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
+ &x->block[i + 2].coeff[0], 32);
+ }
+ // build dc block from 16 y dc values
+ if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV) {
+ // vp8_build_dcblock(x);
+ vp8_build_dcblock_8x8(x);
+ x->short_fhaar2x2(&x->block[24].src_diff[0],
+ &x->block[24].coeff[0], 8);
+ }
}
@@ -342,7 +300,7 @@ void vp8_transform_mby_8x8(MACROBLOCK *x)
#define RDTRUNC_8x8(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF )
typedef struct vp8_token_state vp8_token_state;
-struct vp8_token_state{
+struct vp8_token_state {
int rate;
int error;
signed char next;
@@ -355,895 +313,829 @@ struct vp8_token_state{
#define UV_RD_MULT 2
#define Y2_RD_MULT 4
-static const int plane_rd_mult[4]=
-{
- Y1_RD_MULT,
- Y2_RD_MULT,
- UV_RD_MULT,
- Y1_RD_MULT
+static const int plane_rd_mult[4] = {
+ Y1_RD_MULT,
+ Y2_RD_MULT,
+ UV_RD_MULT,
+ Y1_RD_MULT
};
static void optimize_b(MACROBLOCK *mb, int ib, int type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
- const VP8_ENCODER_RTCD *rtcd)
-{
- BLOCK *b;
- BLOCKD *d;
- vp8_token_state tokens[17][2];
- unsigned best_mask[2];
- const short *dequant_ptr;
- const short *coeff_ptr;
- short *qcoeff_ptr;
- short *dqcoeff_ptr;
- int eob;
- int i0;
- int rc;
- int x;
- int sz = 0;
- int next;
- int rdmult;
- int rddiv;
- int final_eob;
- int rd_cost0;
- int rd_cost1;
- int rate0;
- int rate1;
- int error0;
- int error1;
- int t0;
- int t1;
- int best;
- int band;
- int pt;
- int i;
- int err_mult = plane_rd_mult[type];
-
- b = &mb->block[ib];
- d = &mb->e_mbd.block[ib];
-
- dequant_ptr = d->dequant;
- coeff_ptr = b->coeff;
- qcoeff_ptr = d->qcoeff;
- dqcoeff_ptr = d->dqcoeff;
- i0 = !type;
- eob = d->eob;
-
- /* Now set up a Viterbi trellis to evaluate alternative roundings. */
- rdmult = mb->rdmult * err_mult;
- if(mb->e_mbd.mode_info_context->mbmi.ref_frame==INTRA_FRAME)
- rdmult = (rdmult * 9)>>4;
-
- rddiv = mb->rddiv;
- best_mask[0] = best_mask[1] = 0;
- /* Initialize the sentinel node of the trellis. */
- tokens[eob][0].rate = 0;
- tokens[eob][0].error = 0;
- tokens[eob][0].next = 16;
- tokens[eob][0].token = DCT_EOB_TOKEN;
- tokens[eob][0].qc = 0;
- *(tokens[eob] + 1) = *(tokens[eob] + 0);
- next = eob;
- for (i = eob; i-- > i0;)
- {
- int base_bits;
- int d2;
- int dx;
-
- rc = vp8_default_zig_zag1d[i];
- x = qcoeff_ptr[rc];
- /* Only add a trellis state for non-zero coefficients. */
- if (x)
- {
- int shortcut=0;
- error0 = tokens[next][0].error;
- error1 = tokens[next][1].error;
- /* Evaluate the first possibility for this state. */
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
- t0 = (vp8_dct_value_tokens_ptr + x)->Token;
- /* Consider both possible successor states. */
- if (next < 16)
- {
- band = vp8_coef_bands[i + 1];
- pt = vp8_prev_token_class[t0];
- rate0 +=
- mb->token_costs[type][band][pt][tokens[next][0].token];
- rate1 +=
- mb->token_costs[type][band][pt][tokens[next][1].token];
- }
- rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
- rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);
- }
- /* And pick the best. */
- best = rd_cost1 < rd_cost0;
- base_bits = *(vp8_dct_value_cost_ptr + x);
- dx = dqcoeff_ptr[rc] - coeff_ptr[rc];
- d2 = dx*dx;
- tokens[i][0].rate = base_bits + (best ? rate1 : rate0);
- tokens[i][0].error = d2 + (best ? error1 : error0);
- tokens[i][0].next = next;
- tokens[i][0].token = t0;
- tokens[i][0].qc = x;
- best_mask[0] |= best << i;
- /* Evaluate the second possibility for this state. */
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
-
- if((abs(x)*dequant_ptr[rc]>abs(coeff_ptr[rc])) &&
- (abs(x)*dequant_ptr[rc]<abs(coeff_ptr[rc])+dequant_ptr[rc]))
- shortcut = 1;
- else
- shortcut = 0;
-
- if(shortcut)
- {
- sz = -(x < 0);
- x -= 2*sz + 1;
- }
-
- /* Consider both possible successor states. */
- if (!x)
- {
- /* If we reduced this coefficient to zero, check to see if
- * we need to move the EOB back here.
- */
- t0 = tokens[next][0].token == DCT_EOB_TOKEN ?
- DCT_EOB_TOKEN : ZERO_TOKEN;
- t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
- DCT_EOB_TOKEN : ZERO_TOKEN;
- }
- else
- {
- t0=t1 = (vp8_dct_value_tokens_ptr + x)->Token;
- }
- if (next < 16)
- {
- band = vp8_coef_bands[i + 1];
- if(t0!=DCT_EOB_TOKEN)
- {
- pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs[type][band][pt][
- tokens[next][0].token];
- }
- if(t1!=DCT_EOB_TOKEN)
- {
- pt = vp8_prev_token_class[t1];
- rate1 += mb->token_costs[type][band][pt][
- tokens[next][1].token];
- }
- }
-
- rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
- rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);
- }
- /* And pick the best. */
- best = rd_cost1 < rd_cost0;
- base_bits = *(vp8_dct_value_cost_ptr + x);
-
- if(shortcut)
- {
- dx -= (dequant_ptr[rc] + sz) ^ sz;
- d2 = dx*dx;
- }
- tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
- tokens[i][1].error = d2 + (best ? error1 : error0);
- tokens[i][1].next = next;
- tokens[i][1].token =best?t1:t0;
- tokens[i][1].qc = x;
- best_mask[1] |= best << i;
- /* Finally, make this the new head of the trellis. */
- next = i;
- }
- /* There's no choice to make for a zero coefficient, so we don't
- * add a new trellis node, but we do need to update the costs.
+ const VP8_ENCODER_RTCD *rtcd) {
+ BLOCK *b;
+ BLOCKD *d;
+ vp8_token_state tokens[17][2];
+ unsigned best_mask[2];
+ const short *dequant_ptr;
+ const short *coeff_ptr;
+ short *qcoeff_ptr;
+ short *dqcoeff_ptr;
+ int eob;
+ int i0;
+ int rc;
+ int x;
+ int sz = 0;
+ int next;
+ int rdmult;
+ int rddiv;
+ int final_eob;
+ int rd_cost0;
+ int rd_cost1;
+ int rate0;
+ int rate1;
+ int error0;
+ int error1;
+ int t0;
+ int t1;
+ int best;
+ int band;
+ int pt;
+ int i;
+ int err_mult = plane_rd_mult[type];
+
+ b = &mb->block[ib];
+ d = &mb->e_mbd.block[ib];
+
+ dequant_ptr = d->dequant;
+ coeff_ptr = b->coeff;
+ qcoeff_ptr = d->qcoeff;
+ dqcoeff_ptr = d->dqcoeff;
+ i0 = !type;
+ eob = d->eob;
+
+ /* Now set up a Viterbi trellis to evaluate alternative roundings. */
+ rdmult = mb->rdmult * err_mult;
+ if (mb->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
+ rdmult = (rdmult * 9) >> 4;
+
+ rddiv = mb->rddiv;
+ best_mask[0] = best_mask[1] = 0;
+ /* Initialize the sentinel node of the trellis. */
+ tokens[eob][0].rate = 0;
+ tokens[eob][0].error = 0;
+ tokens[eob][0].next = 16;
+ tokens[eob][0].token = DCT_EOB_TOKEN;
+ tokens[eob][0].qc = 0;
+ *(tokens[eob] + 1) = *(tokens[eob] + 0);
+ next = eob;
+ for (i = eob; i-- > i0;) {
+ int base_bits;
+ int d2;
+ int dx;
+
+ rc = vp8_default_zig_zag1d[i];
+ x = qcoeff_ptr[rc];
+ /* Only add a trellis state for non-zero coefficients. */
+ if (x) {
+ int shortcut = 0;
+ error0 = tokens[next][0].error;
+ error1 = tokens[next][1].error;
+ /* Evaluate the first possibility for this state. */
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+ t0 = (vp8_dct_value_tokens_ptr + x)->Token;
+ /* Consider both possible successor states. */
+ if (next < 16) {
+ band = vp8_coef_bands[i + 1];
+ pt = vp8_prev_token_class[t0];
+ rate0 +=
+ mb->token_costs[type][band][pt][tokens[next][0].token];
+ rate1 +=
+ mb->token_costs[type][band][pt][tokens[next][1].token];
+ }
+ rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
+ rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);
+ }
+ /* And pick the best. */
+ best = rd_cost1 < rd_cost0;
+ base_bits = *(vp8_dct_value_cost_ptr + x);
+ dx = dqcoeff_ptr[rc] - coeff_ptr[rc];
+ d2 = dx * dx;
+ tokens[i][0].rate = base_bits + (best ? rate1 : rate0);
+ tokens[i][0].error = d2 + (best ? error1 : error0);
+ tokens[i][0].next = next;
+ tokens[i][0].token = t0;
+ tokens[i][0].qc = x;
+ best_mask[0] |= best << i;
+ /* Evaluate the second possibility for this state. */
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+
+ if ((abs(x)*dequant_ptr[rc] > abs(coeff_ptr[rc])) &&
+ (abs(x)*dequant_ptr[rc] < abs(coeff_ptr[rc]) + dequant_ptr[rc]))
+ shortcut = 1;
+ else
+ shortcut = 0;
+
+ if (shortcut) {
+ sz = -(x < 0);
+ x -= 2 * sz + 1;
+ }
+
+ /* Consider both possible successor states. */
+ if (!x) {
+ /* If we reduced this coefficient to zero, check to see if
+ * we need to move the EOB back here.
*/
- else
- {
- band = vp8_coef_bands[i + 1];
- t0 = tokens[next][0].token;
- t1 = tokens[next][1].token;
- /* Update the cost of each path if we're past the EOB token. */
- if (t0 != DCT_EOB_TOKEN)
- {
- tokens[next][0].rate += mb->token_costs[type][band][0][t0];
- tokens[next][0].token = ZERO_TOKEN;
- }
- if (t1 != DCT_EOB_TOKEN)
- {
- tokens[next][1].rate += mb->token_costs[type][band][0][t1];
- tokens[next][1].token = ZERO_TOKEN;
- }
- /* Don't update next, because we didn't add a new node. */
+ t0 = tokens[next][0].token == DCT_EOB_TOKEN ?
+ DCT_EOB_TOKEN : ZERO_TOKEN;
+ t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
+ DCT_EOB_TOKEN : ZERO_TOKEN;
+ } else {
+ t0 = t1 = (vp8_dct_value_tokens_ptr + x)->Token;
+ }
+ if (next < 16) {
+ band = vp8_coef_bands[i + 1];
+ if (t0 != DCT_EOB_TOKEN) {
+ pt = vp8_prev_token_class[t0];
+ rate0 += mb->token_costs[type][band][pt][
+ tokens[next][0].token];
}
- }
+ if (t1 != DCT_EOB_TOKEN) {
+ pt = vp8_prev_token_class[t1];
+ rate1 += mb->token_costs[type][band][pt][
+ tokens[next][1].token];
+ }
+ }
- /* Now pick the best path through the whole trellis. */
- band = vp8_coef_bands[i + 1];
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
- error0 = tokens[next][0].error;
- error1 = tokens[next][1].error;
- t0 = tokens[next][0].token;
- t1 = tokens[next][1].token;
- rate0 += mb->token_costs[type][band][pt][t0];
- rate1 += mb->token_costs[type][band][pt][t1];
- rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
+ rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);
rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);
+ }
+ /* And pick the best. */
+ best = rd_cost1 < rd_cost0;
+ base_bits = *(vp8_dct_value_cost_ptr + x);
+
+ if (shortcut) {
+ dx -= (dequant_ptr[rc] + sz) ^ sz;
+ d2 = dx * dx;
+ }
+ tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
+ tokens[i][1].error = d2 + (best ? error1 : error0);
+ tokens[i][1].next = next;
+ tokens[i][1].token = best ? t1 : t0;
+ tokens[i][1].qc = x;
+ best_mask[1] |= best << i;
+ /* Finally, make this the new head of the trellis. */
+ next = i;
}
- best = rd_cost1 < rd_cost0;
- final_eob = i0 - 1;
- for (i = next; i < eob; i = next)
- {
- x = tokens[i][best].qc;
- if (x)
- final_eob = i;
- rc = vp8_default_zig_zag1d[i];
- qcoeff_ptr[rc] = x;
- dqcoeff_ptr[rc] = x * dequant_ptr[rc];
- next = tokens[i][best].next;
- best = (best_mask[best] >> i) & 1;
+ /* There's no choice to make for a zero coefficient, so we don't
+ * add a new trellis node, but we do need to update the costs.
+ */
+ else {
+ band = vp8_coef_bands[i + 1];
+ t0 = tokens[next][0].token;
+ t1 = tokens[next][1].token;
+ /* Update the cost of each path if we're past the EOB token. */
+ if (t0 != DCT_EOB_TOKEN) {
+ tokens[next][0].rate += mb->token_costs[type][band][0][t0];
+ tokens[next][0].token = ZERO_TOKEN;
+ }
+ if (t1 != DCT_EOB_TOKEN) {
+ tokens[next][1].rate += mb->token_costs[type][band][0][t1];
+ tokens[next][1].token = ZERO_TOKEN;
+ }
+ /* Don't update next, because we didn't add a new node. */
}
- final_eob++;
-
- d->eob = final_eob;
- *a = *l = (d->eob != !type);
+ }
+
+ /* Now pick the best path through the whole trellis. */
+ band = vp8_coef_bands[i + 1];
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+ error0 = tokens[next][0].error;
+ error1 = tokens[next][1].error;
+ t0 = tokens[next][0].token;
+ t1 = tokens[next][1].token;
+ rate0 += mb->token_costs[type][band][pt][t0];
+ rate1 += mb->token_costs[type][band][pt][t1];
+ rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
+ rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);
+ }
+ best = rd_cost1 < rd_cost0;
+ final_eob = i0 - 1;
+ for (i = next; i < eob; i = next) {
+ x = tokens[i][best].qc;
+ if (x)
+ final_eob = i;
+ rc = vp8_default_zig_zag1d[i];
+ qcoeff_ptr[rc] = x;
+ dqcoeff_ptr[rc] = x * dequant_ptr[rc];
+ next = tokens[i][best].next;
+ best = (best_mask[best] >> i) & 1;
+ }
+ final_eob++;
+
+ d->eob = final_eob;
+ *a = *l = (d->eob != !type);
}
- /**************************************************************************
- our inverse hadamard transform effectively is weighted sum of all 16 inputs
- with weight either 1 or -1. It has a last stage scaling of (sum+1)>>2. And
- dc only idct is (dc+16)>>5. So if all the sums are between -65 and 63 the
- output after inverse wht and idct will be all zero. A sum of absolute value
- smaller than 65 guarantees all 16 different (+1/-1) weighted sums in wht
- fall between -65 and +65.
- **************************************************************************/
+/**************************************************************************
+our inverse hadamard transform effectively is weighted sum of all 16 inputs
+with weight either 1 or -1. It has a last stage scaling of (sum+1)>>2. And
+dc only idct is (dc+16)>>5. So if all the sums are between -65 and 63 the
+output after inverse wht and idct will be all zero. A sum of absolute value
+smaller than 65 guarantees all 16 different (+1/-1) weighted sums in wht
+fall between -65 and +65.
+**************************************************************************/
#define SUM_2ND_COEFF_THRESH 65
static void check_reset_2nd_coeffs(MACROBLOCKD *x, int type,
- ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
-{
- int sum=0;
- int i;
- BLOCKD *bd = &x->block[24];
- if(bd->dequant[0]>=SUM_2ND_COEFF_THRESH
- && bd->dequant[1]>=SUM_2ND_COEFF_THRESH)
- return;
-
- for(i=0;i<bd->eob;i++)
- {
- int coef = bd->dqcoeff[vp8_default_zig_zag1d[i]];
- sum+= (coef>=0)?coef:-coef;
- if(sum>=SUM_2ND_COEFF_THRESH)
- return;
- }
-
- if(sum < SUM_2ND_COEFF_THRESH)
- {
- for(i=0;i<bd->eob;i++)
- {
- int rc = vp8_default_zig_zag1d[i];
- bd->qcoeff[rc]=0;
- bd->dqcoeff[rc]=0;
- }
- bd->eob = 0;
- *a = *l = (bd->eob != !type);
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
+ int sum = 0;
+ int i;
+ BLOCKD *bd = &x->block[24];
+ if (bd->dequant[0] >= SUM_2ND_COEFF_THRESH
+ && bd->dequant[1] >= SUM_2ND_COEFF_THRESH)
+ return;
+
+ for (i = 0; i < bd->eob; i++) {
+ int coef = bd->dqcoeff[vp8_default_zig_zag1d[i]];
+ sum += (coef >= 0) ? coef : -coef;
+ if (sum >= SUM_2ND_COEFF_THRESH)
+ return;
+ }
+
+ if (sum < SUM_2ND_COEFF_THRESH) {
+ for (i = 0; i < bd->eob; i++) {
+ int rc = vp8_default_zig_zag1d[i];
+ bd->qcoeff[rc] = 0;
+ bd->dqcoeff[rc] = 0;
}
+ bd->eob = 0;
+ *a = *l = (bd->eob != !type);
+ }
}
#define SUM_2ND_COEFF_THRESH_8X8 32
static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *x, int type,
- ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
-{
- int sum=0;
- BLOCKD *bd = &x->block[24];
- int coef;
-
- coef = bd->dqcoeff[0];
- sum+= (coef>=0)?coef:-coef;
- coef = bd->dqcoeff[1];
- sum+= (coef>=0)?coef:-coef;
- coef = bd->dqcoeff[4];
- sum+= (coef>=0)?coef:-coef;
- coef = bd->dqcoeff[8];
- sum+= (coef>=0)?coef:-coef;
-
- if(sum < SUM_2ND_COEFF_THRESH_8X8)
- {
- bd->qcoeff[0] = 0;
- bd->dqcoeff[0] = 0;
- bd->qcoeff[1] = 0;
- bd->dqcoeff[1] = 0;
- bd->qcoeff[4] = 0;
- bd->dqcoeff[4] = 0;
- bd->qcoeff[8] = 0;
- bd->dqcoeff[8] = 0;
- bd->eob = 0;
- *a = *l = (bd->eob != !type);
- }
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
+ int sum = 0;
+ BLOCKD *bd = &x->block[24];
+ int coef;
+
+ coef = bd->dqcoeff[0];
+ sum += (coef >= 0) ? coef : -coef;
+ coef = bd->dqcoeff[1];
+ sum += (coef >= 0) ? coef : -coef;
+ coef = bd->dqcoeff[4];
+ sum += (coef >= 0) ? coef : -coef;
+ coef = bd->dqcoeff[8];
+ sum += (coef >= 0) ? coef : -coef;
+
+ if (sum < SUM_2ND_COEFF_THRESH_8X8) {
+ bd->qcoeff[0] = 0;
+ bd->dqcoeff[0] = 0;
+ bd->qcoeff[1] = 0;
+ bd->dqcoeff[1] = 0;
+ bd->qcoeff[4] = 0;
+ bd->dqcoeff[4] = 0;
+ bd->qcoeff[8] = 0;
+ bd->dqcoeff[8] = 0;
+ bd->eob = 0;
+ *a = *l = (bd->eob != !type);
+ }
}
-static void optimize_mb(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- int type;
- int has_2nd_order;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+static void optimize_mb(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ int type;
+ int has_2nd_order;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- &&x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
+ has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+ type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
- for (b = 0; b < 16; b++)
- {
- optimize_b(x, b, type,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- }
+ for (b = 0; b < 16; b++) {
+ optimize_b(x, b, type,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ }
- for (b = 16; b < 24; b++)
- {
- optimize_b(x, b, PLANE_TYPE_UV,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- }
+ for (b = 16; b < 24; b++) {
+ optimize_b(x, b, PLANE_TYPE_UV,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ }
- if (has_2nd_order)
- {
- b=24;
- optimize_b(x, b, PLANE_TYPE_Y2,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
- ta + vp8_block2above[b], tl + vp8_block2left[b]);
- }
+ if (has_2nd_order) {
+ b = 24;
+ optimize_b(x, b, PLANE_TYPE_Y2,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ }
}
-void vp8_optimize_mby(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- int type;
- int has_2nd_order;
+void vp8_optimize_mby(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ int type;
+ int has_2nd_order;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- if (!x->e_mbd.above_context)
- return;
+ if (!x->e_mbd.above_context)
+ return;
- if (!x->e_mbd.left_context)
- return;
+ if (!x->e_mbd.left_context)
+ return;
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- &&x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
+ has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+ type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
- for (b = 0; b < 16; b++)
- {
- optimize_b(x, b, type,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- }
+ for (b = 0; b < 16; b++) {
+ optimize_b(x, b, type,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ }
- if (has_2nd_order)
- {
- b=24;
- optimize_b(x, b, PLANE_TYPE_Y2,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
- ta + vp8_block2above[b], tl + vp8_block2left[b]);
- }
+ if (has_2nd_order) {
+ b = 24;
+ optimize_b(x, b, PLANE_TYPE_Y2,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ }
}
-void vp8_optimize_mbuv(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+void vp8_optimize_mbuv(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- if (!x->e_mbd.above_context)
- return;
+ if (!x->e_mbd.above_context)
+ return;
- if (!x->e_mbd.left_context)
- return;
+ if (!x->e_mbd.left_context)
+ return;
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 16; b < 24; b++)
- {
- optimize_b(x, b, PLANE_TYPE_UV,
- ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
- }
+ for (b = 16; b < 24; b++) {
+ optimize_b(x, b, PLANE_TYPE_UV,
+ ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd);
+ }
}
void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
- const VP8_ENCODER_RTCD *rtcd)
-{
- BLOCK *b;
- BLOCKD *d;
- vp8_token_state tokens[65][2];
- unsigned best_mask[2];
- const short *dequant_ptr;
- const short *coeff_ptr;
- short *qcoeff_ptr;
- short *dqcoeff_ptr;
- int eob;
- int i0;
- int rc;
- int x;
- int sz = 0;
- int next;
- int rdmult;
- int rddiv;
- int final_eob;
- int rd_cost0;
- int rd_cost1;
- int rate0;
- int rate1;
- int error0;
- int error1;
- int t0;
- int t1;
- int best;
- int band;
- int pt;
- int err_mult = plane_rd_mult[type];
-
- b = &mb->block[i];
- d = &mb->e_mbd.block[i];
-
- dequant_ptr = d->dequant;
- coeff_ptr = b->coeff;
- qcoeff_ptr = d->qcoeff;
- dqcoeff_ptr = d->dqcoeff;
- i0 = !type;
- eob = d->eob;
-
- /* Now set up a Viterbi trellis to evaluate alternative roundings. */
- rdmult = mb->rdmult * err_mult;
- if(mb->e_mbd.mode_info_context->mbmi.ref_frame==INTRA_FRAME)
- rdmult = (rdmult * 9)>>4;
- rddiv = mb->rddiv;
- best_mask[0] = best_mask[1] = 0;
- /* Initialize the sentinel node of the trellis. */
- tokens[eob][0].rate = 0;
- tokens[eob][0].error = 0;
- tokens[eob][0].next = 64;
- tokens[eob][0].token = DCT_EOB_TOKEN;
- tokens[eob][0].qc = 0;
- *(tokens[eob] + 1) = *(tokens[eob] + 0);
- next = eob;
- for (i = eob; i-- > i0;)
- {
- int base_bits;
- int d2;
- int dx;
-
- rc = vp8_default_zig_zag1d_8x8[i];
- x = qcoeff_ptr[rc];
- /* Only add a trellis state for non-zero coefficients. */
- if (x)
- {
- int shortcut=0;
- error0 = tokens[next][0].error;
- error1 = tokens[next][1].error;
- /* Evaluate the first possibility for this state. */
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
- t0 = (vp8_dct_value_tokens_ptr + x)->Token;
- /* Consider both possible successor states. */
- if (next < 64)
- {
- band = vp8_coef_bands_8x8[i + 1];
- pt = vp8_prev_token_class[t0];
- rate0 +=
- mb->token_costs_8x8[type][band][pt][tokens[next][0].token];
- rate1 +=
- mb->token_costs_8x8[type][band][pt][tokens[next][1].token];
- }
- rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
- rd_cost0 = RDTRUNC_8x8(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDTRUNC_8x8(rdmult, rddiv, rate1, error1);
- }
- /* And pick the best. */
- best = rd_cost1 < rd_cost0;
- base_bits = *(vp8_dct_value_cost_ptr + x);
- dx = dqcoeff_ptr[rc] - coeff_ptr[rc];
- d2 = dx*dx;
- tokens[i][0].rate = base_bits + (best ? rate1 : rate0);
- tokens[i][0].error = d2 + (best ? error1 : error0);
- tokens[i][0].next = next;
- tokens[i][0].token = t0;
- tokens[i][0].qc = x;
- best_mask[0] |= best << i;
- /* Evaluate the second possibility for this state. */
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
-
- if((abs(x)*dequant_ptr[rc!=0]>abs(coeff_ptr[rc])) &&
- (abs(x)*dequant_ptr[rc!=0]<abs(coeff_ptr[rc])+dequant_ptr[rc!=0]))
- shortcut = 1;
- else
- shortcut = 0;
-
- if(shortcut)
- {
- sz = -(x < 0);
- x -= 2*sz + 1;
- }
-
- /* Consider both possible successor states. */
- if (!x)
- {
- /* If we reduced this coefficient to zero, check to see if
- * we need to move the EOB back here.
- */
- t0 = tokens[next][0].token == DCT_EOB_TOKEN ?
- DCT_EOB_TOKEN : ZERO_TOKEN;
- t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
- DCT_EOB_TOKEN : ZERO_TOKEN;
- }
- else
- {
- t0=t1 = (vp8_dct_value_tokens_ptr + x)->Token;
- }
- if (next < 64)
- {
- band = vp8_coef_bands_8x8[i + 1];
- if(t0!=DCT_EOB_TOKEN)
- {
- pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs_8x8[type][band][pt][
- tokens[next][0].token];
- }
- if(t1!=DCT_EOB_TOKEN)
- {
- pt = vp8_prev_token_class[t1];
- rate1 += mb->token_costs_8x8[type][band][pt][
- tokens[next][1].token];
- }
- }
-
- rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
- rd_cost0 = RDTRUNC_8x8(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDTRUNC_8x8(rdmult, rddiv, rate1, error1);
- }
- /* And pick the best. */
- best = rd_cost1 < rd_cost0;
- base_bits = *(vp8_dct_value_cost_ptr + x);
-
- if(shortcut)
- {
- dx -= (dequant_ptr[rc!=0] + sz) ^ sz;
- d2 = dx*dx;
- }
- tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
- tokens[i][1].error = d2 + (best ? error1 : error0);
- tokens[i][1].next = next;
- tokens[i][1].token =best?t1:t0;
- tokens[i][1].qc = x;
- best_mask[1] |= best << i;
- /* Finally, make this the new head of the trellis. */
- next = i;
- }
- /* There's no choice to make for a zero coefficient, so we don't
- * add a new trellis node, but we do need to update the costs.
+ const VP8_ENCODER_RTCD *rtcd) {
+ BLOCK *b;
+ BLOCKD *d;
+ vp8_token_state tokens[65][2];
+ unsigned best_mask[2];
+ const short *dequant_ptr;
+ const short *coeff_ptr;
+ short *qcoeff_ptr;
+ short *dqcoeff_ptr;
+ int eob;
+ int i0;
+ int rc;
+ int x;
+ int sz = 0;
+ int next;
+ int rdmult;
+ int rddiv;
+ int final_eob;
+ int rd_cost0;
+ int rd_cost1;
+ int rate0;
+ int rate1;
+ int error0;
+ int error1;
+ int t0;
+ int t1;
+ int best;
+ int band;
+ int pt;
+ int err_mult = plane_rd_mult[type];
+
+ b = &mb->block[i];
+ d = &mb->e_mbd.block[i];
+
+ dequant_ptr = d->dequant;
+ coeff_ptr = b->coeff;
+ qcoeff_ptr = d->qcoeff;
+ dqcoeff_ptr = d->dqcoeff;
+ i0 = !type;
+ eob = d->eob;
+
+ /* Now set up a Viterbi trellis to evaluate alternative roundings. */
+ rdmult = mb->rdmult * err_mult;
+ if (mb->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
+ rdmult = (rdmult * 9) >> 4;
+ rddiv = mb->rddiv;
+ best_mask[0] = best_mask[1] = 0;
+ /* Initialize the sentinel node of the trellis. */
+ tokens[eob][0].rate = 0;
+ tokens[eob][0].error = 0;
+ tokens[eob][0].next = 64;
+ tokens[eob][0].token = DCT_EOB_TOKEN;
+ tokens[eob][0].qc = 0;
+ *(tokens[eob] + 1) = *(tokens[eob] + 0);
+ next = eob;
+ for (i = eob; i-- > i0;) {
+ int base_bits;
+ int d2;
+ int dx;
+
+ rc = vp8_default_zig_zag1d_8x8[i];
+ x = qcoeff_ptr[rc];
+ /* Only add a trellis state for non-zero coefficients. */
+ if (x) {
+ int shortcut = 0;
+ error0 = tokens[next][0].error;
+ error1 = tokens[next][1].error;
+ /* Evaluate the first possibility for this state. */
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+ t0 = (vp8_dct_value_tokens_ptr + x)->Token;
+ /* Consider both possible successor states. */
+ if (next < 64) {
+ band = vp8_coef_bands_8x8[i + 1];
+ pt = vp8_prev_token_class[t0];
+ rate0 +=
+ mb->token_costs_8x8[type][band][pt][tokens[next][0].token];
+ rate1 +=
+ mb->token_costs_8x8[type][band][pt][tokens[next][1].token];
+ }
+ rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
+ rd_cost0 = RDTRUNC_8x8(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDTRUNC_8x8(rdmult, rddiv, rate1, error1);
+ }
+ /* And pick the best. */
+ best = rd_cost1 < rd_cost0;
+ base_bits = *(vp8_dct_value_cost_ptr + x);
+ dx = dqcoeff_ptr[rc] - coeff_ptr[rc];
+ d2 = dx * dx;
+ tokens[i][0].rate = base_bits + (best ? rate1 : rate0);
+ tokens[i][0].error = d2 + (best ? error1 : error0);
+ tokens[i][0].next = next;
+ tokens[i][0].token = t0;
+ tokens[i][0].qc = x;
+ best_mask[0] |= best << i;
+ /* Evaluate the second possibility for this state. */
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+
+ if ((abs(x)*dequant_ptr[rc != 0] > abs(coeff_ptr[rc])) &&
+ (abs(x)*dequant_ptr[rc != 0] < abs(coeff_ptr[rc]) + dequant_ptr[rc != 0]))
+ shortcut = 1;
+ else
+ shortcut = 0;
+
+ if (shortcut) {
+ sz = -(x < 0);
+ x -= 2 * sz + 1;
+ }
+
+ /* Consider both possible successor states. */
+ if (!x) {
+ /* If we reduced this coefficient to zero, check to see if
+ * we need to move the EOB back here.
*/
- else
- {
- band = vp8_coef_bands_8x8[i + 1];
- t0 = tokens[next][0].token;
- t1 = tokens[next][1].token;
- /* Update the cost of each path if we're past the EOB token. */
- if (t0 != DCT_EOB_TOKEN)
- {
- tokens[next][0].rate += mb->token_costs_8x8[type][band][0][t0];
- tokens[next][0].token = ZERO_TOKEN;
- }
- if (t1 != DCT_EOB_TOKEN)
- {
- tokens[next][1].rate += mb->token_costs_8x8[type][band][0][t1];
- tokens[next][1].token = ZERO_TOKEN;
- }
- /* Don't update next, because we didn't add a new node. */
+ t0 = tokens[next][0].token == DCT_EOB_TOKEN ?
+ DCT_EOB_TOKEN : ZERO_TOKEN;
+ t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
+ DCT_EOB_TOKEN : ZERO_TOKEN;
+ } else {
+ t0 = t1 = (vp8_dct_value_tokens_ptr + x)->Token;
+ }
+ if (next < 64) {
+ band = vp8_coef_bands_8x8[i + 1];
+ if (t0 != DCT_EOB_TOKEN) {
+ pt = vp8_prev_token_class[t0];
+ rate0 += mb->token_costs_8x8[type][band][pt][
+ tokens[next][0].token];
}
- }
+ if (t1 != DCT_EOB_TOKEN) {
+ pt = vp8_prev_token_class[t1];
+ rate1 += mb->token_costs_8x8[type][band][pt][
+ tokens[next][1].token];
+ }
+ }
- /* Now pick the best path through the whole trellis. */
- band = vp8_coef_bands_8x8[i + 1];
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- rate0 = tokens[next][0].rate;
- rate1 = tokens[next][1].rate;
- error0 = tokens[next][0].error;
- error1 = tokens[next][1].error;
- t0 = tokens[next][0].token;
- t1 = tokens[next][1].token;
- rate0 += mb->token_costs_8x8[type][band][pt][t0];
- rate1 += mb->token_costs_8x8[type][band][pt][t1];
- rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
- rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
- if (rd_cost0 == rd_cost1)
- {
+ rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
rd_cost0 = RDTRUNC_8x8(rdmult, rddiv, rate0, error0);
rd_cost1 = RDTRUNC_8x8(rdmult, rddiv, rate1, error1);
+ }
+ /* And pick the best. */
+ best = rd_cost1 < rd_cost0;
+ base_bits = *(vp8_dct_value_cost_ptr + x);
+
+ if (shortcut) {
+ dx -= (dequant_ptr[rc != 0] + sz) ^ sz;
+ d2 = dx * dx;
+ }
+ tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
+ tokens[i][1].error = d2 + (best ? error1 : error0);
+ tokens[i][1].next = next;
+ tokens[i][1].token = best ? t1 : t0;
+ tokens[i][1].qc = x;
+ best_mask[1] |= best << i;
+ /* Finally, make this the new head of the trellis. */
+ next = i;
}
- best = rd_cost1 < rd_cost0;
- final_eob = i0 - 1;
- for (i = next; i < eob; i = next)
- {
- x = tokens[i][best].qc;
- if (x)
- final_eob = i;
- rc = vp8_default_zig_zag1d_8x8[i];
- qcoeff_ptr[rc] = x;
- dqcoeff_ptr[rc] = (x * dequant_ptr[rc!=0]);
-
- next = tokens[i][best].next;
- best = (best_mask[best] >> i) & 1;
+ /* There's no choice to make for a zero coefficient, so we don't
+ * add a new trellis node, but we do need to update the costs.
+ */
+ else {
+ band = vp8_coef_bands_8x8[i + 1];
+ t0 = tokens[next][0].token;
+ t1 = tokens[next][1].token;
+ /* Update the cost of each path if we're past the EOB token. */
+ if (t0 != DCT_EOB_TOKEN) {
+ tokens[next][0].rate += mb->token_costs_8x8[type][band][0][t0];
+ tokens[next][0].token = ZERO_TOKEN;
+ }
+ if (t1 != DCT_EOB_TOKEN) {
+ tokens[next][1].rate += mb->token_costs_8x8[type][band][0][t1];
+ tokens[next][1].token = ZERO_TOKEN;
+ }
+ /* Don't update next, because we didn't add a new node. */
}
- final_eob++;
-
- d->eob = final_eob;
- *a = *l = (d->eob != !type);
+ }
+
+ /* Now pick the best path through the whole trellis. */
+ band = vp8_coef_bands_8x8[i + 1];
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ rate0 = tokens[next][0].rate;
+ rate1 = tokens[next][1].rate;
+ error0 = tokens[next][0].error;
+ error1 = tokens[next][1].error;
+ t0 = tokens[next][0].token;
+ t1 = tokens[next][1].token;
+ rate0 += mb->token_costs_8x8[type][band][pt][t0];
+ rate1 += mb->token_costs_8x8[type][band][pt][t1];
+ rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
+ if (rd_cost0 == rd_cost1) {
+ rd_cost0 = RDTRUNC_8x8(rdmult, rddiv, rate0, error0);
+ rd_cost1 = RDTRUNC_8x8(rdmult, rddiv, rate1, error1);
+ }
+ best = rd_cost1 < rd_cost0;
+ final_eob = i0 - 1;
+ for (i = next; i < eob; i = next) {
+ x = tokens[i][best].qc;
+ if (x)
+ final_eob = i;
+ rc = vp8_default_zig_zag1d_8x8[i];
+ qcoeff_ptr[rc] = x;
+ dqcoeff_ptr[rc] = (x * dequant_ptr[rc != 0]);
+
+ next = tokens[i][best].next;
+ best = (best_mask[best] >> i) & 1;
+ }
+ final_eob++;
+
+ d->eob = final_eob;
+ *a = *l = (d->eob != !type);
}
-void optimize_mb_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- int type;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
-
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
-
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
-
- type = 0;
- for (b = 0; b < 16; b+=4)
- {
- optimize_b_8x8(x, b, type,
- ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
- rtcd);
- *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
- *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b] );
- }
-
- for (b = 16; b < 24; b+=4)
- {
- optimize_b_8x8(x, b, PLANE_TYPE_UV,
- ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
- rtcd);
- *(ta + vp8_block2above_8x8[b]+1) = *(ta + vp8_block2above_8x8[b]);
- *(tl + vp8_block2left_8x8[b]+1 ) = *(tl + vp8_block2left_8x8[b]);
- }
-
- //8x8 always have 2nd roder haar block
- check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
- ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
+void optimize_mb_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ int type;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+
+ type = 0;
+ for (b = 0; b < 16; b += 4) {
+ optimize_b_8x8(x, b, type,
+ ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
+ rtcd);
+ *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
+ *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b]);
+ }
+
+ for (b = 16; b < 24; b += 4) {
+ optimize_b_8x8(x, b, PLANE_TYPE_UV,
+ ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
+ rtcd);
+ *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
+ *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b]);
+ }
+
+ // 8x8 always have 2nd roder haar block
+ check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
}
-void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- int type;
+void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ int type;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- if (!x->e_mbd.above_context)
- return;
+ if (!x->e_mbd.above_context)
+ return;
- if (!x->e_mbd.left_context)
- return;
+ if (!x->e_mbd.left_context)
+ return;
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
- type = 0;
- for (b = 0; b < 16; b+=4)
- {
- optimize_b_8x8(x, b, type,
- ta + vp8_block2above[b], tl + vp8_block2left[b],
- rtcd);
- *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
- *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b] );
- }
- //8x8 always have 2nd roder haar block
- check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
- ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+ type = 0;
+ for (b = 0; b < 16; b += 4) {
+ optimize_b_8x8(x, b, type,
+ ta + vp8_block2above[b], tl + vp8_block2left[b],
+ rtcd);
+ *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
+ *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b]);
+ }
+ // 8x8 always have 2nd roder haar block
+ check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
}
-void vp8_optimize_mbuv_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+void vp8_optimize_mbuv_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- if (!x->e_mbd.above_context)
- return;
+ if (!x->e_mbd.above_context)
+ return;
- if (!x->e_mbd.left_context)
- return;
+ if (!x->e_mbd.left_context)
+ return;
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 16; b < 24; b+=4)
- {
- optimize_b_8x8(x, b, PLANE_TYPE_UV,
- ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
- rtcd);
- *(ta + vp8_block2above_8x8[b]+1) = *(ta + vp8_block2above_8x8[b]);
- *(tl + vp8_block2left_8x8[b]+1 ) = *(tl + vp8_block2left_8x8[b]);
- }
+ for (b = 16; b < 24; b += 4) {
+ optimize_b_8x8(x, b, PLANE_TYPE_UV,
+ ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b],
+ rtcd);
+ *(ta + vp8_block2above_8x8[b] + 1) = *(ta + vp8_block2above_8x8[b]);
+ *(tl + vp8_block2left_8x8[b] + 1) = *(tl + vp8_block2left_8x8[b]);
+ }
}
-void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
- vp8_build_inter_predictors_mb(&x->e_mbd);
+void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
+ vp8_build_inter_predictors_mb(&x->e_mbd);
- vp8_subtract_mb(rtcd, x);
+ vp8_subtract_mb(rtcd, x);
- if( tx_type == TX_8X8 )
- vp8_transform_mb_8x8(x);
- else
- transform_mb(x);
+ if (tx_type == TX_8X8)
+ vp8_transform_mb_8x8(x);
+ else
+ transform_mb(x);
- if( tx_type == TX_8X8 )
- vp8_quantize_mb_8x8(x);
- else
- vp8_quantize_mb(x);
-
- if (x->optimize)
- {
- if( tx_type == TX_8X8 )
- optimize_mb_8x8(x, rtcd);
- else
- optimize_mb(x, rtcd);
- }
+ if (tx_type == TX_8X8)
+ vp8_quantize_mb_8x8(x);
+ else
+ vp8_quantize_mb(x);
- if( tx_type == TX_8X8 )
- vp8_inverse_transform_mb_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ if (x->optimize) {
+ if (tx_type == TX_8X8)
+ optimize_mb_8x8(x, rtcd);
else
- vp8_inverse_transform_mb(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ optimize_mb(x, rtcd);
+ }
+
+ if (tx_type == TX_8X8)
+ vp8_inverse_transform_mb_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ else
+ vp8_inverse_transform_mb(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
- if( tx_type == TX_8X8 )
- {
+ if (tx_type == TX_8X8) {
#ifdef ENC_DEBUG
- if (enc_debug)
- {
- int i;
- printf("qcoeff:\n");
- printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.qcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("dqcoeff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.dqcoeff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("diff:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.diff[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("predictor:\n");
- for (i =0; i<400; i++) {
- printf("%3d ", x->e_mbd.predictor[i]);
- if (i%16 == 15) printf("\n");
- }
- printf("\n");
- }
-#endif
+ if (enc_debug) {
+ int i;
+ printf("qcoeff:\n");
+ printf("%d %d:\n", x->e_mbd.mb_to_left_edge, x->e_mbd.mb_to_top_edge);
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.qcoeff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("dqcoeff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.dqcoeff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("diff:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.diff[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("predictor:\n");
+ for (i = 0; i < 400; i++) {
+ printf("%3d ", x->e_mbd.predictor[i]);
+ if (i % 16 == 15) printf("\n");
+ }
+ printf("\n");
}
+#endif
+ }
- RECON_INVOKE(&rtcd->common->recon, recon_mb)
- (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
+ RECON_INVOKE(&rtcd->common->recon, recon_mb)
+ (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
#ifdef ENC_DEBUG
- if (enc_debug) {
- int i, j, k;
- printf("Final Reconstruction\n");
- for (i =0; i<16; i+=4) {
- BLOCKD *b = &x->e_mbd.block[i];
- unsigned char *d = *(b->base_dst) + b->dst;
- for (k=0; k<4; k++) {
- for (j=0; j<16; j++)
- printf("%3d ", d[j]);
- printf("\n");
- d+=b->dst_stride;
- }
+ if (enc_debug) {
+ int i, j, k;
+ printf("Final Reconstruction\n");
+ for (i = 0; i < 16; i += 4) {
+ BLOCKD *b = &x->e_mbd.block[i];
+ unsigned char *d = *(b->base_dst) + b->dst;
+ for (k = 0; k < 4; k++) {
+ for (j = 0; j < 16; j++)
+ printf("%3d ", d[j]);
+ printf("\n");
+ d += b->dst_stride;
}
}
+ }
#endif
}
/* this function is used by first pass only */
-void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
-{
- int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
+void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) {
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
- BLOCK *b = &x->block[0];
+ BLOCK *b = &x->block[0];
#if CONFIG_PRED_FILTER
- // Disable the prediction filter for firstpass
- x->e_mbd.mode_info_context->mbmi.pred_filter_enabled = 0;
+ // Disable the prediction filter for firstpass
+ x->e_mbd.mode_info_context->mbmi.pred_filter_enabled = 0;
#endif
- vp8_build_inter16x16_predictors_mby(&x->e_mbd);
+ vp8_build_inter16x16_predictors_mby(&x->e_mbd);
- ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
- if( tx_type == TX_8X8 )
- vp8_transform_mby_8x8(x);
- else
- transform_mby(x);
+ if (tx_type == TX_8X8)
+ vp8_transform_mby_8x8(x);
+ else
+ transform_mby(x);
- vp8_quantize_mby(x);
+ vp8_quantize_mby(x);
- if( tx_type == TX_8X8 )
- vp8_inverse_transform_mby_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
- else
- vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ if (tx_type == TX_8X8)
+ vp8_inverse_transform_mby_8x8(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
+ else
+ vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
- RECON_INVOKE(&rtcd->common->recon, recon_mby)
- (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
+ RECON_INVOKE(&rtcd->common->recon, recon_mby)
+ (IF_RTCD(&rtcd->common->recon), &x->e_mbd);
}
diff --git a/vp8/encoder/encodemb.h b/vp8/encoder/encodemb.h
index 396a15196..bfcd0f92c 100644
--- a/vp8/encoder/encodemb.h
+++ b/vp8/encoder/encodemb.h
@@ -16,23 +16,23 @@
#include "block.h"
#define prototype_mberr(sym) \
- int (sym)(MACROBLOCK *mb, int dc)
+ int (sym)(MACROBLOCK *mb, int dc)
#define prototype_berr(sym) \
- int (sym)(short *coeff, short *dqcoeff)
+ int (sym)(short *coeff, short *dqcoeff)
#define prototype_mbuverr(sym) \
- int (sym)(MACROBLOCK *mb)
+ int (sym)(MACROBLOCK *mb)
#define prototype_subb(sym) \
- void (sym)(BLOCK *be,BLOCKD *bd, int pitch)
+ void (sym)(BLOCK *be,BLOCKD *bd, int pitch)
#define prototype_submby(sym) \
- void (sym)(short *diff, unsigned char *src, unsigned char *pred, int stride)
+ void (sym)(short *diff, unsigned char *src, unsigned char *pred, int stride)
#define prototype_submbuv(sym) \
- void (sym)(short *diff, unsigned char *usrc, unsigned char *vsrc,\
- unsigned char *pred, int stride)
+ void (sym)(short *diff, unsigned char *usrc, unsigned char *vsrc,\
+ unsigned char *pred, int stride)
#if ARCH_X86 || ARCH_X86_64
#include "x86/encodemb_x86.h"
@@ -73,23 +73,21 @@ extern prototype_submby(vp8_encodemb_submby);
extern prototype_submbuv(vp8_encodemb_submbuv);
-typedef struct
-{
- prototype_berr(*berr);
- prototype_mberr(*mberr);
- prototype_mbuverr(*mbuverr);
- prototype_subb(*subb);
- prototype_submby(*submby);
- prototype_submbuv(*submbuv);
+typedef struct {
+ prototype_berr(*berr);
+ prototype_mberr(*mberr);
+ prototype_mbuverr(*mbuverr);
+ prototype_subb(*subb);
+ prototype_submby(*submby);
+ prototype_submbuv(*submbuv);
} vp8_encodemb_rtcd_vtable_t;
-typedef struct
-{
- MB_PREDICTION_MODE mode;
- MV_REFERENCE_FRAME ref_frame;
- MV_REFERENCE_FRAME second_ref_frame;
+typedef struct {
+ MB_PREDICTION_MODE mode;
+ MV_REFERENCE_FRAME ref_frame;
+ MV_REFERENCE_FRAME second_ref_frame;
#if CONFIG_PRED_FILTER
- int pred_filter_flag;
+ int pred_filter_flag;
#endif
} MODE_DEFINITION;
diff --git a/vp8/encoder/encodemv.c b/vp8/encoder/encodemv.c
index 0ba8848a0..e2643f012 100644
--- a/vp8/encoder/encodemv.c
+++ b/vp8/encoder/encodemv.c
@@ -20,177 +20,159 @@
extern unsigned int active_section;
#endif
-//#define DEBUG_ENC_MV
+// #define DEBUG_ENC_MV
#ifdef DEBUG_ENC_MV
int enc_mvcount = 0;
#endif
static void encode_mvcomponent(
- vp8_writer *const w,
- const int v,
- const struct mv_context *mvc
-)
-{
- const vp8_prob *p = mvc->prob;
- const int x = v < 0 ? -v : v;
-
- if (x < mvnum_short) // Small
- {
- vp8_write(w, 0, p [mvpis_short]);
- vp8_treed_write(w, vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
- if (!x)
- return; // no sign bit
- }
- else // Large
- {
- int i = 0;
+ vp8_writer *const w,
+ const int v,
+ const struct mv_context *mvc
+) {
+ const vp8_prob *p = mvc->prob;
+ const int x = v < 0 ? -v : v;
- vp8_write(w, 1, p [mvpis_short]);
+ if (x < mvnum_short) { // Small
+ vp8_write(w, 0, p [mvpis_short]);
+ vp8_treed_write(w, vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
+ if (!x)
+ return; // no sign bit
+ } else { // Large
+ int i = 0;
- do
- vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
+ vp8_write(w, 1, p [mvpis_short]);
- while (++i < mvnum_short_bits);
+ do
+ vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
- i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
+ while (++i < mvnum_short_bits);
- do
- vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
+ i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
- while (--i > mvnum_short_bits);
+ do
+ vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
- if (x & ~((2<<mvnum_short_bits)-1))
- vp8_write(w, (x >> mvnum_short_bits) & 1, p [MVPbits + mvnum_short_bits]);
- }
+ while (--i > mvnum_short_bits);
+
+ if (x & ~((2 << mvnum_short_bits) - 1))
+ vp8_write(w, (x >> mvnum_short_bits) & 1, p [MVPbits + mvnum_short_bits]);
+ }
- vp8_write(w, v < 0, p [MVPsign]);
+ vp8_write(w, v < 0, p [MVPsign]);
}
#if 0
static int max_mv_r = 0;
static int max_mv_c = 0;
#endif
-void vp8_encode_motion_vector(vp8_writer *w, const MV *mv, const MV_CONTEXT *mvc)
-{
+void vp8_encode_motion_vector(vp8_writer *w, const MV *mv, const MV_CONTEXT *mvc) {
#if 0
- {
- if (abs(mv->row >> 1) > max_mv_r)
- {
- FILE *f = fopen("maxmv.stt", "a");
- max_mv_r = abs(mv->row >> 1);
- fprintf(f, "New Mv Row Max %6d\n", (mv->row >> 1));
-
- if ((abs(mv->row) / 2) != max_mv_r)
- fprintf(f, "MV Row conversion error %6d\n", abs(mv->row) / 2);
-
- fclose(f);
- }
-
- if (abs(mv->col >> 1) > max_mv_c)
- {
- FILE *f = fopen("maxmv.stt", "a");
- fprintf(f, "New Mv Col Max %6d\n", (mv->col >> 1));
- max_mv_c = abs(mv->col >> 1);
- fclose(f);
- }
+ {
+ if (abs(mv->row >> 1) > max_mv_r) {
+ FILE *f = fopen("maxmv.stt", "a");
+ max_mv_r = abs(mv->row >> 1);
+ fprintf(f, "New Mv Row Max %6d\n", (mv->row >> 1));
+
+ if ((abs(mv->row) / 2) != max_mv_r)
+ fprintf(f, "MV Row conversion error %6d\n", abs(mv->row) / 2);
+
+ fclose(f);
+ }
+
+ if (abs(mv->col >> 1) > max_mv_c) {
+ FILE *f = fopen("maxmv.stt", "a");
+ fprintf(f, "New Mv Col Max %6d\n", (mv->col >> 1));
+ max_mv_c = abs(mv->col >> 1);
+ fclose(f);
}
+ }
#endif
- encode_mvcomponent(w, mv->row >> 1, &mvc[0]);
- encode_mvcomponent(w, mv->col >> 1, &mvc[1]);
+ encode_mvcomponent(w, mv->row >> 1, &mvc[0]);
+ encode_mvcomponent(w, mv->col >> 1, &mvc[1]);
#ifdef DEBUG_ENC_MV
- {
+ {
int i;
printf("%d (np): %d %d\n", enc_mvcount++,
- (mv->row >> 1)<<1, (mv->col >> 1)<<1);
- //for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[0])->prob[i]);
- //printf("\n");
- //for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[1])->prob[i]);
- //printf("\n");
+ (mv->row >> 1) << 1, (mv->col >> 1) << 1);
+ // for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[0])->prob[i]);
+ // printf("\n");
+ // for (i=0; i<MVPcount;++i) printf(" %d", (&mvc[1])->prob[i]);
+ // printf("\n");
fflush(stdout);
- }
+ }
#endif
}
-static unsigned int cost_mvcomponent(const int v, const struct mv_context *mvc)
-{
- const vp8_prob *p = mvc->prob;
- const int x = v; //v<0? -v:v;
- unsigned int cost;
+static unsigned int cost_mvcomponent(const int v, const struct mv_context *mvc) {
+ const vp8_prob *p = mvc->prob;
+ const int x = v; // v<0? -v:v;
+ unsigned int cost;
- if (x < mvnum_short)
- {
- cost = vp8_cost_zero(p [mvpis_short])
- + vp8_treed_cost(vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
+ if (x < mvnum_short) {
+ cost = vp8_cost_zero(p [mvpis_short])
+ + vp8_treed_cost(vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
- if (!x)
- return cost;
- }
- else
- {
- int i = 0;
- cost = vp8_cost_one(p [mvpis_short]);
+ if (!x)
+ return cost;
+ } else {
+ int i = 0;
+ cost = vp8_cost_one(p [mvpis_short]);
- do
- cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1);
+ do
+ cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1);
- while (++i < mvnum_short_bits);
+ while (++i < mvnum_short_bits);
- i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
+ i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
- do
- cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1);
+ do
+ cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1);
- while (--i > mvnum_short_bits);
+ while (--i > mvnum_short_bits);
- if (x & ~((2<<mvnum_short_bits)-1))
- cost += vp8_cost_bit(p [MVPbits + mvnum_short_bits], (x >> mvnum_short_bits) & 1);
- }
+ if (x & ~((2 << mvnum_short_bits) - 1))
+ cost += vp8_cost_bit(p [MVPbits + mvnum_short_bits], (x >> mvnum_short_bits) & 1);
+ }
- return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
+ return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
}
-void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2])
-{
- int i = 1; //-mv_max;
- unsigned int cost0 = 0;
- unsigned int cost1 = 0;
+void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2]) {
+ int i = 1; // -mv_max;
+ unsigned int cost0 = 0;
+ unsigned int cost1 = 0;
- vp8_clear_system_state();
+ vp8_clear_system_state();
- i = 1;
+ i = 1;
- if (mvc_flag[0])
- {
- mvcost [0] [0] = cost_mvcomponent(0, &mvc[0]);
+ if (mvc_flag[0]) {
+ mvcost [0] [0] = cost_mvcomponent(0, &mvc[0]);
- do
- {
- //mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]);
- cost0 = cost_mvcomponent(i, &mvc[0]);
-
- mvcost [0] [i] = cost0 + vp8_cost_zero(mvc[0].prob[MVPsign]);
- mvcost [0] [-i] = cost0 + vp8_cost_one(mvc[0].prob[MVPsign]);
- }
- while (++i <= mv_max);
- }
+ do {
+ // mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]);
+ cost0 = cost_mvcomponent(i, &mvc[0]);
- i = 1;
+ mvcost [0] [i] = cost0 + vp8_cost_zero(mvc[0].prob[MVPsign]);
+ mvcost [0] [-i] = cost0 + vp8_cost_one(mvc[0].prob[MVPsign]);
+ } while (++i <= mv_max);
+ }
- if (mvc_flag[1])
- {
- mvcost [1] [0] = cost_mvcomponent(0, &mvc[1]);
+ i = 1;
- do
- {
- //mvcost [1] [i] = cost_mvcomponent( i, mvc[1]);
- cost1 = cost_mvcomponent(i, &mvc[1]);
-
- mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign]);
- mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign]);
- }
- while (++i <= mv_max);
- }
+ if (mvc_flag[1]) {
+ mvcost [1] [0] = cost_mvcomponent(0, &mvc[1]);
+
+ do {
+ // mvcost [1] [i] = cost_mvcomponent( i, mvc[1]);
+ cost1 = cost_mvcomponent(i, &mvc[1]);
+
+ mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign]);
+ mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign]);
+ } while (++i <= mv_max);
+ }
}
@@ -201,574 +183,537 @@ void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int m
#define MV_PROB_UPDATE_CORRECTION -1
-__inline static void calc_prob(vp8_prob *p, const unsigned int ct[2])
-{
- const unsigned int tot = ct[0] + ct[1];
+__inline static void calc_prob(vp8_prob *p, const unsigned int ct[2]) {
+ const unsigned int tot = ct[0] + ct[1];
- if (tot)
- {
- const vp8_prob x = ((ct[0] * 255) / tot) & -2;
- *p = x ? x : 1;
- }
+ if (tot) {
+ const vp8_prob x = ((ct[0] * 255) / tot) & -2;
+ *p = x ? x : 1;
+ }
}
static void update(
- vp8_writer *const w,
- const unsigned int ct[2],
- vp8_prob *const cur_p,
- const vp8_prob new_p,
- const vp8_prob update_p,
- int *updated
-)
-{
- const int cur_b = vp8_cost_branch(ct, *cur_p);
- const int new_b = vp8_cost_branch(ct, new_p);
- const int cost = 7 + MV_PROB_UPDATE_CORRECTION + ((vp8_cost_one(update_p) - vp8_cost_zero(update_p) + 128) >> 8);
-
- if (cur_b - new_b > cost)
- {
- *cur_p = new_p;
- vp8_write(w, 1, update_p);
- vp8_write_literal(w, new_p >> 1, 7);
- *updated = 1;
-
- }
- else
- vp8_write(w, 0, update_p);
+ vp8_writer *const w,
+ const unsigned int ct[2],
+ vp8_prob *const cur_p,
+ const vp8_prob new_p,
+ const vp8_prob update_p,
+ int *updated
+) {
+ const int cur_b = vp8_cost_branch(ct, *cur_p);
+ const int new_b = vp8_cost_branch(ct, new_p);
+ const int cost = 7 + MV_PROB_UPDATE_CORRECTION + ((vp8_cost_one(update_p) - vp8_cost_zero(update_p) + 128) >> 8);
+
+ if (cur_b - new_b > cost) {
+ *cur_p = new_p;
+ vp8_write(w, 1, update_p);
+ vp8_write_literal(w, new_p >> 1, 7);
+ *updated = 1;
+
+ } else
+ vp8_write(w, 0, update_p);
}
static void write_component_probs(
- vp8_writer *const w,
- struct mv_context *cur_mvc,
- const struct mv_context *default_mvc_,
- const struct mv_context *update_mvc,
- const unsigned int events [MVvals],
- unsigned int rc,
- int *updated
-)
-{
- vp8_prob *Pcur = cur_mvc->prob;
- const vp8_prob *default_mvc = default_mvc_->prob;
- const vp8_prob *Pupdate = update_mvc->prob;
- unsigned int is_short_ct[2], sign_ct[2];
-
- unsigned int bit_ct [mvlong_width] [2];
-
- unsigned int short_ct [mvnum_short];
- unsigned int short_bct [mvnum_short-1] [2];
-
- vp8_prob Pnew [MVPcount];
-
- (void) rc;
- vp8_copy_array(Pnew, default_mvc, MVPcount);
-
- vp8_zero(is_short_ct)
- vp8_zero(sign_ct)
- vp8_zero(bit_ct)
- vp8_zero(short_ct)
- vp8_zero(short_bct)
-
-
- //j=0
- {
- const int c = events [mv_max];
-
- is_short_ct [0] += c; // Short vector
- short_ct [0] += c; // Magnitude distribution
- }
-
- //j: 1 ~ mv_max (1023)
- {
- int j = 1;
-
+ vp8_writer *const w,
+ struct mv_context *cur_mvc,
+ const struct mv_context *default_mvc_,
+ const struct mv_context *update_mvc,
+ const unsigned int events [MVvals],
+ unsigned int rc,
+ int *updated
+) {
+ vp8_prob *Pcur = cur_mvc->prob;
+ const vp8_prob *default_mvc = default_mvc_->prob;
+ const vp8_prob *Pupdate = update_mvc->prob;
+ unsigned int is_short_ct[2], sign_ct[2];
+
+ unsigned int bit_ct [mvlong_width] [2];
+
+ unsigned int short_ct [mvnum_short];
+ unsigned int short_bct [mvnum_short - 1] [2];
+
+ vp8_prob Pnew [MVPcount];
+
+ (void) rc;
+ vp8_copy_array(Pnew, default_mvc, MVPcount);
+
+ vp8_zero(is_short_ct)
+ vp8_zero(sign_ct)
+ vp8_zero(bit_ct)
+ vp8_zero(short_ct)
+ vp8_zero(short_bct)
+
+
+ // j=0
+ {
+ const int c = events [mv_max];
+
+ is_short_ct [0] += c; // Short vector
+ short_ct [0] += c; // Magnitude distribution
+ }
+
+ // j: 1 ~ mv_max (1023)
+ {
+ int j = 1;
+
+ do {
+ const int c1 = events [mv_max + j]; // positive
+ const int c2 = events [mv_max - j]; // negative
+ const int c = c1 + c2;
+ int a = j;
+
+ sign_ct [0] += c1;
+ sign_ct [1] += c2;
+
+ if (a < mvnum_short) {
+ is_short_ct [0] += c; // Short vector
+ short_ct [a] += c; // Magnitude distribution
+ } else {
+ int k = mvlong_width - 1;
+ is_short_ct [1] += c; // Long vector
+
+ /* bit 3 not always encoded. */
do
- {
- const int c1 = events [mv_max + j]; //positive
- const int c2 = events [mv_max - j]; //negative
- const int c = c1 + c2;
- int a = j;
-
- sign_ct [0] += c1;
- sign_ct [1] += c2;
-
- if (a < mvnum_short)
- {
- is_short_ct [0] += c; // Short vector
- short_ct [a] += c; // Magnitude distribution
- }
- else
- {
- int k = mvlong_width - 1;
- is_short_ct [1] += c; // Long vector
-
- /* bit 3 not always encoded. */
- do
- bit_ct [k] [(a >> k) & 1] += c;
-
- while (--k >= 0);
- }
- }
- while (++j <= mv_max);
- }
-
- /*
- {
- int j = -mv_max;
- do
- {
-
- const int c = events [mv_max + j];
- int a = j;
-
- if( j < 0)
- {
- sign_ct [1] += c;
- a = -j;
- }
- else if( j)
- sign_ct [0] += c;
-
- if( a < mvnum_short)
- {
- is_short_ct [0] += c; // Short vector
- short_ct [a] += c; // Magnitude distribution
- }
- else
- {
- int k = mvlong_width - 1;
- is_short_ct [1] += c; // Long vector
-
- // bit 3 not always encoded.
-
- do
- bit_ct [k] [(a >> k) & 1] += c;
- while( --k >= 0);
- }
- } while( ++j <= mv_max);
- }
- */
-
- calc_prob(Pnew + mvpis_short, is_short_ct);
-
- calc_prob(Pnew + MVPsign, sign_ct);
-
- {
- vp8_prob p [mvnum_short - 1]; /* actually only need branch ct */
- int j = 0;
+ bit_ct [k] [(a >> k) & 1] += c;
+
+ while (--k >= 0);
+ }
+ } while (++j <= mv_max);
+ }
+
+ /*
+ {
+ int j = -mv_max;
+ do
+ {
+
+ const int c = events [mv_max + j];
+ int a = j;
+
+ if( j < 0)
+ {
+ sign_ct [1] += c;
+ a = -j;
+ }
+ else if( j)
+ sign_ct [0] += c;
+
+ if( a < mvnum_short)
+ {
+ is_short_ct [0] += c; // Short vector
+ short_ct [a] += c; // Magnitude distribution
+ }
+ else
+ {
+ int k = mvlong_width - 1;
+ is_short_ct [1] += c; // Long vector
+
+ // bit 3 not always encoded.
+
+ do
+ bit_ct [k] [(a >> k) & 1] += c;
+ while( --k >= 0);
+ }
+ } while( ++j <= mv_max);
+ }
+ */
+
+ calc_prob(Pnew + mvpis_short, is_short_ct);
+
+ calc_prob(Pnew + MVPsign, sign_ct);
+
+ {
+ vp8_prob p [mvnum_short - 1]; /* actually only need branch ct */
+ int j = 0;
+
+ vp8_tree_probs_from_distribution(
+ mvnum_short, vp8_small_mvencodings, vp8_small_mvtree,
+ p, short_bct, short_ct,
+ 256, 1
+ );
- vp8_tree_probs_from_distribution(
- mvnum_short, vp8_small_mvencodings, vp8_small_mvtree,
- p, short_bct, short_ct,
- 256, 1
- );
+ do
+ calc_prob(Pnew + MVPshort + j, short_bct[j]);
- do
- calc_prob(Pnew + MVPshort + j, short_bct[j]);
-
- while (++j < mvnum_short - 1);
- }
+ while (++j < mvnum_short - 1);
+ }
- {
- int j = 0;
+ {
+ int j = 0;
- do
- calc_prob(Pnew + MVPbits + j, bit_ct[j]);
+ do
+ calc_prob(Pnew + MVPbits + j, bit_ct[j]);
- while (++j < mvlong_width);
- }
+ while (++j < mvlong_width);
+ }
- update(w, is_short_ct, Pcur + mvpis_short, Pnew[mvpis_short], *Pupdate++, updated);
+ update(w, is_short_ct, Pcur + mvpis_short, Pnew[mvpis_short], *Pupdate++, updated);
- update(w, sign_ct, Pcur + MVPsign, Pnew[MVPsign], *Pupdate++, updated);
+ update(w, sign_ct, Pcur + MVPsign, Pnew[MVPsign], *Pupdate++, updated);
- {
- const vp8_prob *const new_p = Pnew + MVPshort;
- vp8_prob *const cur_p = Pcur + MVPshort;
+ {
+ const vp8_prob *const new_p = Pnew + MVPshort;
+ vp8_prob *const cur_p = Pcur + MVPshort;
- int j = 0;
+ int j = 0;
- do
+ do
- update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
+ update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
- while (++j < mvnum_short - 1);
- }
+ while (++j < mvnum_short - 1);
+ }
- {
- const vp8_prob *const new_p = Pnew + MVPbits;
- vp8_prob *const cur_p = Pcur + MVPbits;
+ {
+ const vp8_prob *const new_p = Pnew + MVPbits;
+ vp8_prob *const cur_p = Pcur + MVPbits;
- int j = 0;
+ int j = 0;
- do
+ do
- update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
+ update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
- while (++j < mvlong_width);
- }
+ while (++j < mvlong_width);
+ }
}
-void vp8_write_mvprobs(VP8_COMP *cpi)
-{
- vp8_writer *const w = & cpi->bc;
- MV_CONTEXT *mvc = cpi->common.fc.mvc;
- int flags[2] = {0, 0};
+void vp8_write_mvprobs(VP8_COMP *cpi) {
+ vp8_writer *const w = & cpi->bc;
+ MV_CONTEXT *mvc = cpi->common.fc.mvc;
+ int flags[2] = {0, 0};
#ifdef ENTROPY_STATS
- active_section = 4;
+ active_section = 4;
#endif
- write_component_probs(
- w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MVcount[0], 0, &flags[0]
- );
- write_component_probs(
- w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MVcount[1], 1, &flags[1]
- );
+ write_component_probs(
+ w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MVcount[0], 0, &flags[0]
+ );
+ write_component_probs(
+ w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MVcount[1], 1, &flags[1]
+ );
- if (flags[0] || flags[1])
- vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
+ if (flags[0] || flags[1])
+ vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
#ifdef ENTROPY_STATS
- active_section = 5;
+ active_section = 5;
#endif
}
#if CONFIG_HIGH_PRECISION_MV
static void encode_mvcomponent_hp(
- vp8_writer *const w,
- const int v,
- const struct mv_context_hp *mvc
-)
-{
- const vp8_prob *p = mvc->prob;
- const int x = v < 0 ? -v : v;
-
- if (x < mvnum_short_hp) // Small
- {
- vp8_write(w, 0, p [mvpis_short_hp]);
- vp8_treed_write(w, vp8_small_mvtree_hp, p + MVPshort_hp, x,
- mvnum_short_bits_hp);
- if (!x)
- return; // no sign bit
- }
- else // Large
- {
- int i = 0;
+ vp8_writer *const w,
+ const int v,
+ const struct mv_context_hp *mvc
+) {
+ const vp8_prob *p = mvc->prob;
+ const int x = v < 0 ? -v : v;
- vp8_write(w, 1, p [mvpis_short_hp]);
+ if (x < mvnum_short_hp) { // Small
+ vp8_write(w, 0, p [mvpis_short_hp]);
+ vp8_treed_write(w, vp8_small_mvtree_hp, p + MVPshort_hp, x,
+ mvnum_short_bits_hp);
+ if (!x)
+ return; // no sign bit
+ } else { // Large
+ int i = 0;
- do
- vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
+ vp8_write(w, 1, p [mvpis_short_hp]);
- while (++i < mvnum_short_bits_hp);
+ do
+ vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
- i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
+ while (++i < mvnum_short_bits_hp);
- do
- vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
+ i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
- while (--i > mvnum_short_bits_hp);
+ do
+ vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
- if (x & ~((2<<mvnum_short_bits_hp)-1))
- vp8_write(w, (x >> mvnum_short_bits_hp) & 1,
- p [MVPbits_hp + mvnum_short_bits_hp]);
- }
+ while (--i > mvnum_short_bits_hp);
+
+ if (x & ~((2 << mvnum_short_bits_hp) - 1))
+ vp8_write(w, (x >> mvnum_short_bits_hp) & 1,
+ p [MVPbits_hp + mvnum_short_bits_hp]);
+ }
- vp8_write(w, v < 0, p [MVPsign_hp]);
+ vp8_write(w, v < 0, p [MVPsign_hp]);
}
#if 0
static int max_mv_r = 0;
static int max_mv_c = 0;
#endif
void vp8_encode_motion_vector_hp(vp8_writer *w, const MV *mv,
- const MV_CONTEXT_HP *mvc)
-{
+ const MV_CONTEXT_HP *mvc) {
#if 0
- {
- if (abs(mv->row >> 1) > max_mv_r)
- {
- FILE *f = fopen("maxmv.stt", "a");
- max_mv_r = abs(mv->row >> 1);
- fprintf(f, "New Mv Row Max %6d\n", (mv->row >> 1));
-
- if ((abs(mv->row) / 2) != max_mv_r)
- fprintf(f, "MV Row conversion error %6d\n", abs(mv->row) / 2);
-
- fclose(f);
- }
-
- if (abs(mv->col >> 1) > max_mv_c)
- {
- FILE *f = fopen("maxmv.stt", "a");
- fprintf(f, "New Mv Col Max %6d\n", (mv->col >> 1));
- max_mv_c = abs(mv->col >> 1);
- fclose(f);
- }
+ {
+ if (abs(mv->row >> 1) > max_mv_r) {
+ FILE *f = fopen("maxmv.stt", "a");
+ max_mv_r = abs(mv->row >> 1);
+ fprintf(f, "New Mv Row Max %6d\n", (mv->row >> 1));
+
+ if ((abs(mv->row) / 2) != max_mv_r)
+ fprintf(f, "MV Row conversion error %6d\n", abs(mv->row) / 2);
+
+ fclose(f);
}
+
+ if (abs(mv->col >> 1) > max_mv_c) {
+ FILE *f = fopen("maxmv.stt", "a");
+ fprintf(f, "New Mv Col Max %6d\n", (mv->col >> 1));
+ max_mv_c = abs(mv->col >> 1);
+ fclose(f);
+ }
+ }
#endif
- encode_mvcomponent_hp(w, mv->row, &mvc[0]);
- encode_mvcomponent_hp(w, mv->col, &mvc[1]);
+ encode_mvcomponent_hp(w, mv->row, &mvc[0]);
+ encode_mvcomponent_hp(w, mv->col, &mvc[1]);
#ifdef DEBUG_ENC_MV
- {
+ {
int i;
printf("%d (hp): %d %d\n", enc_mvcount++, mv->row, mv->col);
- //for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[0])->prob[i]);
- //printf("\n");
- //for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[1])->prob[i]);
- //printf("\n");
+ // for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[0])->prob[i]);
+ // printf("\n");
+ // for (i=0; i<MVPcount_hp;++i) printf(" %d", (&mvc[1])->prob[i]);
+ // printf("\n");
fflush(stdout);
- }
+ }
#endif
}
static unsigned int cost_mvcomponent_hp(const int v,
- const struct mv_context_hp *mvc)
-{
- const vp8_prob *p = mvc->prob;
- const int x = v; //v<0? -v:v;
- unsigned int cost;
-
- if (x < mvnum_short_hp)
- {
- cost = vp8_cost_zero(p [mvpis_short_hp])
- + vp8_treed_cost(vp8_small_mvtree_hp, p + MVPshort_hp, x,
- mvnum_short_bits_hp);
-
- if (!x)
- return cost;
- }
- else
- {
- int i = 0;
- cost = vp8_cost_one(p [mvpis_short_hp]);
+ const struct mv_context_hp *mvc) {
+ const vp8_prob *p = mvc->prob;
+ const int x = v; // v<0? -v:v;
+ unsigned int cost;
- do
- cost += vp8_cost_bit(p [MVPbits_hp + i], (x >> i) & 1);
+ if (x < mvnum_short_hp) {
+ cost = vp8_cost_zero(p [mvpis_short_hp])
+ + vp8_treed_cost(vp8_small_mvtree_hp, p + MVPshort_hp, x,
+ mvnum_short_bits_hp);
- while (++i < mvnum_short_bits_hp);
+ if (!x)
+ return cost;
+ } else {
+ int i = 0;
+ cost = vp8_cost_one(p [mvpis_short_hp]);
- i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
+ do
+ cost += vp8_cost_bit(p [MVPbits_hp + i], (x >> i) & 1);
- do
- cost += vp8_cost_bit(p [MVPbits_hp + i], (x >> i) & 1);
+ while (++i < mvnum_short_bits_hp);
- while (--i > mvnum_short_bits_hp);
+ i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
- if (x & ~((2<<mvnum_short_bits_hp)-1))
- cost += vp8_cost_bit(p [MVPbits_hp + mvnum_short_bits_hp],
- (x >> mvnum_short_bits_hp) & 1);
- }
+ do
+ cost += vp8_cost_bit(p [MVPbits_hp + i], (x >> i) & 1);
+
+ while (--i > mvnum_short_bits_hp);
+
+ if (x & ~((2 << mvnum_short_bits_hp) - 1))
+ cost += vp8_cost_bit(p [MVPbits_hp + mvnum_short_bits_hp],
+ (x >> mvnum_short_bits_hp) & 1);
+ }
- return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
+ return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
}
void vp8_build_component_cost_table_hp(int *mvcost[2],
const MV_CONTEXT_HP *mvc,
- int mvc_flag[2])
-{
- int i = 1; //-mv_max;
- unsigned int cost0 = 0;
- unsigned int cost1 = 0;
+ int mvc_flag[2]) {
+ int i = 1; // -mv_max;
+ unsigned int cost0 = 0;
+ unsigned int cost1 = 0;
- vp8_clear_system_state();
+ vp8_clear_system_state();
- i = 1;
+ i = 1;
- if (mvc_flag[0])
- {
- mvcost [0] [0] = cost_mvcomponent_hp(0, &mvc[0]);
+ if (mvc_flag[0]) {
+ mvcost [0] [0] = cost_mvcomponent_hp(0, &mvc[0]);
- do
- {
- //mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]);
- cost0 = cost_mvcomponent_hp(i, &mvc[0]);
-
- mvcost [0] [i] = cost0 + vp8_cost_zero(mvc[0].prob[MVPsign_hp]);
- mvcost [0] [-i] = cost0 + vp8_cost_one(mvc[0].prob[MVPsign_hp]);
- }
- while (++i <= mv_max_hp);
- }
+ do {
+ // mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]);
+ cost0 = cost_mvcomponent_hp(i, &mvc[0]);
- i = 1;
+ mvcost [0] [i] = cost0 + vp8_cost_zero(mvc[0].prob[MVPsign_hp]);
+ mvcost [0] [-i] = cost0 + vp8_cost_one(mvc[0].prob[MVPsign_hp]);
+ } while (++i <= mv_max_hp);
+ }
- if (mvc_flag[1])
- {
- mvcost [1] [0] = cost_mvcomponent_hp(0, &mvc[1]);
+ i = 1;
- do
- {
- //mvcost [1] [i] = cost_mvcomponent( i, mvc[1]);
- cost1 = cost_mvcomponent_hp(i, &mvc[1]);
-
- mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign_hp]);
- mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign_hp]);
- }
- while (++i <= mv_max_hp);
- }
-}
+ if (mvc_flag[1]) {
+ mvcost [1] [0] = cost_mvcomponent_hp(0, &mvc[1]);
+ do {
+ // mvcost [1] [i] = cost_mvcomponent( i, mvc[1]);
+ cost1 = cost_mvcomponent_hp(i, &mvc[1]);
-static void write_component_probs_hp(
- vp8_writer *const w,
- struct mv_context_hp *cur_mvc,
- const struct mv_context_hp *default_mvc_,
- const struct mv_context_hp *update_mvc,
- const unsigned int events [MVvals_hp],
- unsigned int rc,
- int *updated
-)
-{
- vp8_prob *Pcur = cur_mvc->prob;
- const vp8_prob *default_mvc = default_mvc_->prob;
- const vp8_prob *Pupdate = update_mvc->prob;
- unsigned int is_short_ct[2], sign_ct[2];
-
- unsigned int bit_ct [mvlong_width_hp] [2];
-
- unsigned int short_ct [mvnum_short_hp];
- unsigned int short_bct [mvnum_short_hp-1] [2];
-
- vp8_prob Pnew [MVPcount_hp];
-
- (void) rc;
- vp8_copy_array(Pnew, default_mvc, MVPcount_hp);
-
- vp8_zero(is_short_ct)
- vp8_zero(sign_ct)
- vp8_zero(bit_ct)
- vp8_zero(short_ct)
- vp8_zero(short_bct)
-
-
- //j=0
- {
- const int c = events [mv_max_hp];
-
- is_short_ct [0] += c; // Short vector
- short_ct [0] += c; // Magnitude distribution
- }
+ mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign_hp]);
+ mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign_hp]);
+ } while (++i <= mv_max_hp);
+ }
+}
- //j: 1 ~ mv_max (1023)
- {
- int j = 1;
+static void write_component_probs_hp(
+ vp8_writer *const w,
+ struct mv_context_hp *cur_mvc,
+ const struct mv_context_hp *default_mvc_,
+ const struct mv_context_hp *update_mvc,
+ const unsigned int events [MVvals_hp],
+ unsigned int rc,
+ int *updated
+) {
+ vp8_prob *Pcur = cur_mvc->prob;
+ const vp8_prob *default_mvc = default_mvc_->prob;
+ const vp8_prob *Pupdate = update_mvc->prob;
+ unsigned int is_short_ct[2], sign_ct[2];
+
+ unsigned int bit_ct [mvlong_width_hp] [2];
+
+ unsigned int short_ct [mvnum_short_hp];
+ unsigned int short_bct [mvnum_short_hp - 1] [2];
+
+ vp8_prob Pnew [MVPcount_hp];
+
+ (void) rc;
+ vp8_copy_array(Pnew, default_mvc, MVPcount_hp);
+
+ vp8_zero(is_short_ct)
+ vp8_zero(sign_ct)
+ vp8_zero(bit_ct)
+ vp8_zero(short_ct)
+ vp8_zero(short_bct)
+
+
+ // j=0
+ {
+ const int c = events [mv_max_hp];
+
+ is_short_ct [0] += c; // Short vector
+ short_ct [0] += c; // Magnitude distribution
+ }
+
+ // j: 1 ~ mv_max (1023)
+ {
+ int j = 1;
+
+ do {
+ const int c1 = events [mv_max_hp + j]; // positive
+ const int c2 = events [mv_max_hp - j]; // negative
+ const int c = c1 + c2;
+ int a = j;
+
+ sign_ct [0] += c1;
+ sign_ct [1] += c2;
+
+ if (a < mvnum_short_hp) {
+ is_short_ct [0] += c; // Short vector
+ short_ct [a] += c; // Magnitude distribution
+ } else {
+ int k = mvlong_width_hp - 1;
+ is_short_ct [1] += c; // Long vector
+
+ /* bit 3 not always encoded. */
do
- {
- const int c1 = events [mv_max_hp + j]; //positive
- const int c2 = events [mv_max_hp - j]; //negative
- const int c = c1 + c2;
- int a = j;
-
- sign_ct [0] += c1;
- sign_ct [1] += c2;
-
- if (a < mvnum_short_hp)
- {
- is_short_ct [0] += c; // Short vector
- short_ct [a] += c; // Magnitude distribution
- }
- else
- {
- int k = mvlong_width_hp - 1;
- is_short_ct [1] += c; // Long vector
-
- /* bit 3 not always encoded. */
- do
- bit_ct [k] [(a >> k) & 1] += c;
-
- while (--k >= 0);
- }
- }
- while (++j <= mv_max_hp);
- }
+ bit_ct [k] [(a >> k) & 1] += c;
- calc_prob(Pnew + mvpis_short_hp, is_short_ct);
+ while (--k >= 0);
+ }
+ } while (++j <= mv_max_hp);
+ }
- calc_prob(Pnew + MVPsign_hp, sign_ct);
+ calc_prob(Pnew + mvpis_short_hp, is_short_ct);
- {
- vp8_prob p [mvnum_short_hp - 1]; /* actually only need branch ct */
- int j = 0;
+ calc_prob(Pnew + MVPsign_hp, sign_ct);
- vp8_tree_probs_from_distribution(
- mvnum_short_hp, vp8_small_mvencodings_hp, vp8_small_mvtree_hp,
- p, short_bct, short_ct,
- 256, 1
- );
+ {
+ vp8_prob p [mvnum_short_hp - 1]; /* actually only need branch ct */
+ int j = 0;
- do
- calc_prob(Pnew + MVPshort_hp + j, short_bct[j]);
+ vp8_tree_probs_from_distribution(
+ mvnum_short_hp, vp8_small_mvencodings_hp, vp8_small_mvtree_hp,
+ p, short_bct, short_ct,
+ 256, 1
+ );
- while (++j < mvnum_short_hp - 1);
- }
+ do
+ calc_prob(Pnew + MVPshort_hp + j, short_bct[j]);
- {
- int j = 0;
+ while (++j < mvnum_short_hp - 1);
+ }
- do
- calc_prob(Pnew + MVPbits_hp + j, bit_ct[j]);
+ {
+ int j = 0;
- while (++j < mvlong_width_hp);
- }
+ do
+ calc_prob(Pnew + MVPbits_hp + j, bit_ct[j]);
- update(w, is_short_ct, Pcur + mvpis_short_hp, Pnew[mvpis_short_hp],
- *Pupdate++, updated);
+ while (++j < mvlong_width_hp);
+ }
- update(w, sign_ct, Pcur + MVPsign_hp, Pnew[MVPsign_hp], *Pupdate++,
- updated);
+ update(w, is_short_ct, Pcur + mvpis_short_hp, Pnew[mvpis_short_hp],
+ *Pupdate++, updated);
- {
- const vp8_prob *const new_p = Pnew + MVPshort_hp;
- vp8_prob *const cur_p = Pcur + MVPshort_hp;
+ update(w, sign_ct, Pcur + MVPsign_hp, Pnew[MVPsign_hp], *Pupdate++,
+ updated);
- int j = 0;
+ {
+ const vp8_prob *const new_p = Pnew + MVPshort_hp;
+ vp8_prob *const cur_p = Pcur + MVPshort_hp;
- do
+ int j = 0;
- update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
+ do
- while (++j < mvnum_short_hp - 1);
- }
+ update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
- {
- const vp8_prob *const new_p = Pnew + MVPbits_hp;
- vp8_prob *const cur_p = Pcur + MVPbits_hp;
+ while (++j < mvnum_short_hp - 1);
+ }
- int j = 0;
+ {
+ const vp8_prob *const new_p = Pnew + MVPbits_hp;
+ vp8_prob *const cur_p = Pcur + MVPbits_hp;
- do
+ int j = 0;
- update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
+ do
- while (++j < mvlong_width_hp);
- }
+ update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
+
+ while (++j < mvlong_width_hp);
+ }
}
-void vp8_write_mvprobs_hp(VP8_COMP *cpi)
-{
- vp8_writer *const w = & cpi->bc;
- MV_CONTEXT_HP *mvc = cpi->common.fc.mvc_hp;
- int flags[2] = {0, 0};
+void vp8_write_mvprobs_hp(VP8_COMP *cpi) {
+ vp8_writer *const w = & cpi->bc;
+ MV_CONTEXT_HP *mvc = cpi->common.fc.mvc_hp;
+ int flags[2] = {0, 0};
#ifdef ENTROPY_STATS
- active_section = 4;
+ active_section = 4;
#endif
- write_component_probs_hp(
- w, &mvc[0], &vp8_default_mv_context_hp[0], &vp8_mv_update_probs_hp[0],
- cpi->MVcount_hp[0], 0, &flags[0]
- );
- write_component_probs_hp(
- w, &mvc[1], &vp8_default_mv_context_hp[1], &vp8_mv_update_probs_hp[1],
- cpi->MVcount_hp[1], 1, &flags[1]
- );
-
- if (flags[0] || flags[1])
- vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp,
- (const MV_CONTEXT_HP *)
- cpi->common.fc.mvc_hp, flags);
+ write_component_probs_hp(
+ w, &mvc[0], &vp8_default_mv_context_hp[0], &vp8_mv_update_probs_hp[0],
+ cpi->MVcount_hp[0], 0, &flags[0]
+ );
+ write_component_probs_hp(
+ w, &mvc[1], &vp8_default_mv_context_hp[1], &vp8_mv_update_probs_hp[1],
+ cpi->MVcount_hp[1], 1, &flags[1]
+ );
+
+ if (flags[0] || flags[1])
+ vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp,
+ (const MV_CONTEXT_HP *)
+ cpi->common.fc.mvc_hp, flags);
#ifdef ENTROPY_STATS
- active_section = 5;
+ active_section = 5;
#endif
}
#endif /* CONFIG_HIGH_PRECISION_MV */
diff --git a/vp8/encoder/find_rotation.c b/vp8/encoder/find_rotation.c
index 742c0ba81..59a0a722f 100644
--- a/vp8/encoder/find_rotation.c
+++ b/vp8/encoder/find_rotation.c
@@ -16,43 +16,40 @@
int vp8_find_best_rotation(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv,
int_mv *ref_mv, int *bri, int error_per_bit,
const vp8_variance_fn_ptr_t *vfp, int *mvcost[2],
- int *distortion, unsigned int *sse1)
-{
- unsigned char *z = (*(b->base_src) + b->src);
-
- int ri;
-
- int y_stride;
-
- unsigned int besterr;
- int br = bestmv->as_mv.row;
- int bc = bestmv->as_mv.col;
- unsigned char *y = *(d->base_pre) + d->pre + br * d->pre_stride + bc;
- y_stride = d->pre_stride;
-
- // calculate central point error
- besterr = vfp->vf(y, y_stride, z, b->src_stride, sse1);
- *distortion = besterr;
-
- // find the best matching rotation
- *bri = 5;
- for (ri = 0; ri < ROTATIONS; ri++)
- {
- unsigned int this_err;
- unsigned char pb[256];
- predict_rotated_16x16(ri, y, y_stride, pb, 16);
- this_err = vfp->vf(pb, 16, z, b->src_stride, sse1);
-
- if (this_err < besterr)
- {
- *bri = ri;
- besterr = this_err;
- }
+ int *distortion, unsigned int *sse1) {
+ unsigned char *z = (*(b->base_src) + b->src);
+
+ int ri;
+
+ int y_stride;
+
+ unsigned int besterr;
+ int br = bestmv->as_mv.row;
+ int bc = bestmv->as_mv.col;
+ unsigned char *y = *(d->base_pre) + d->pre + br * d->pre_stride + bc;
+ y_stride = d->pre_stride;
+
+ // calculate central point error
+ besterr = vfp->vf(y, y_stride, z, b->src_stride, sse1);
+ *distortion = besterr;
+
+ // find the best matching rotation
+ *bri = 5;
+ for (ri = 0; ri < ROTATIONS; ri++) {
+ unsigned int this_err;
+ unsigned char pb[256];
+ predict_rotated_16x16(ri, y, y_stride, pb, 16);
+ this_err = vfp->vf(pb, 16, z, b->src_stride, sse1);
+
+ if (this_err < besterr) {
+ *bri = ri;
+ besterr = this_err;
}
- *sse1 = besterr;
- *distortion = besterr;
+ }
+ *sse1 = besterr;
+ *distortion = besterr;
- return 0;
+ return 0;
}
#endif
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index 77076ff5f..6715c80f6 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -30,7 +30,7 @@
#include "vp8/common/quant_common.h"
#include "encodemv.h"
-//#define OUTPUT_FPF 1
+// #define OUTPUT_FPF 1
#if CONFIG_RUNTIME_CPU_DETECT
#define IF_RTCD(x) (x)
@@ -67,788 +67,736 @@ extern void vp8_alloc_compressor_data(VP8_COMP *cpi);
static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame);
-static int select_cq_level( int qindex )
-{
- int ret_val = QINDEX_RANGE - 1;
- int i;
+static int select_cq_level(int qindex) {
+ int ret_val = QINDEX_RANGE - 1;
+ int i;
- double target_q = ( vp8_convert_qindex_to_q( qindex ) * 0.5847 ) + 1.0;
+ double target_q = (vp8_convert_qindex_to_q(qindex) * 0.5847) + 1.0;
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- if ( target_q <= vp8_convert_qindex_to_q( i ) )
- {
- ret_val = i;
- break;
- }
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ if (target_q <= vp8_convert_qindex_to_q(i)) {
+ ret_val = i;
+ break;
}
+ }
- return ret_val;
+ return ret_val;
}
// Resets the first pass file to the given position using a relative seek from the current position
-static void reset_fpf_position(VP8_COMP *cpi, FIRSTPASS_STATS *Position)
-{
- cpi->twopass.stats_in = Position;
+static void reset_fpf_position(VP8_COMP *cpi, FIRSTPASS_STATS *Position) {
+ cpi->twopass.stats_in = Position;
}
-static int lookup_next_frame_stats(VP8_COMP *cpi, FIRSTPASS_STATS *next_frame)
-{
- if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
- return EOF;
+static int lookup_next_frame_stats(VP8_COMP *cpi, FIRSTPASS_STATS *next_frame) {
+ if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
+ return EOF;
- *next_frame = *cpi->twopass.stats_in;
- return 1;
+ *next_frame = *cpi->twopass.stats_in;
+ return 1;
}
// Read frame stats at an offset from the current position
-static int read_frame_stats( VP8_COMP *cpi,
- FIRSTPASS_STATS *frame_stats,
- int offset )
-{
- FIRSTPASS_STATS * fps_ptr = cpi->twopass.stats_in;
-
- // Check legality of offset
- if ( offset >= 0 )
- {
- if ( &fps_ptr[offset] >= cpi->twopass.stats_in_end )
- return EOF;
- }
- else if ( offset < 0 )
- {
- if ( &fps_ptr[offset] < cpi->twopass.stats_in_start )
- return EOF;
- }
-
- *frame_stats = fps_ptr[offset];
- return 1;
+static int read_frame_stats(VP8_COMP *cpi,
+ FIRSTPASS_STATS *frame_stats,
+ int offset) {
+ FIRSTPASS_STATS *fps_ptr = cpi->twopass.stats_in;
+
+ // Check legality of offset
+ if (offset >= 0) {
+ if (&fps_ptr[offset] >= cpi->twopass.stats_in_end)
+ return EOF;
+ } else if (offset < 0) {
+ if (&fps_ptr[offset] < cpi->twopass.stats_in_start)
+ return EOF;
+ }
+
+ *frame_stats = fps_ptr[offset];
+ return 1;
}
-static int input_stats(VP8_COMP *cpi, FIRSTPASS_STATS *fps)
-{
- if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
- return EOF;
+static int input_stats(VP8_COMP *cpi, FIRSTPASS_STATS *fps) {
+ if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
+ return EOF;
- *fps = *cpi->twopass.stats_in;
- cpi->twopass.stats_in =
- (void*)((char *)cpi->twopass.stats_in + sizeof(FIRSTPASS_STATS));
- return 1;
+ *fps = *cpi->twopass.stats_in;
+ cpi->twopass.stats_in =
+ (void *)((char *)cpi->twopass.stats_in + sizeof(FIRSTPASS_STATS));
+ return 1;
}
static void output_stats(const VP8_COMP *cpi,
struct vpx_codec_pkt_list *pktlist,
- FIRSTPASS_STATS *stats)
-{
- struct vpx_codec_cx_pkt pkt;
- pkt.kind = VPX_CODEC_STATS_PKT;
- pkt.data.twopass_stats.buf = stats;
- pkt.data.twopass_stats.sz = sizeof(FIRSTPASS_STATS);
- vpx_codec_pkt_list_add(pktlist, &pkt);
+ FIRSTPASS_STATS *stats) {
+ struct vpx_codec_cx_pkt pkt;
+ pkt.kind = VPX_CODEC_STATS_PKT;
+ pkt.data.twopass_stats.buf = stats;
+ pkt.data.twopass_stats.sz = sizeof(FIRSTPASS_STATS);
+ vpx_codec_pkt_list_add(pktlist, &pkt);
// TEMP debug code
#if OUTPUT_FPF
- {
- FILE *fpfile;
- fpfile = fopen("firstpass.stt", "a");
-
- fprintf(fpfile, "%12.0f %12.0f %12.0f %12.0f %12.0f %12.4f %12.4f"
- "%12.4f %12.4f %12.4f %12.4f %12.4f %12.4f %12.4f"
- "%12.0f %12.0f %12.4f %12.0f %12.0f %12.4f\n",
- stats->frame,
- stats->intra_error,
- stats->coded_error,
- stats->sr_coded_error,
- stats->ssim_weighted_pred_err,
- stats->pcnt_inter,
- stats->pcnt_motion,
- stats->pcnt_second_ref,
- stats->pcnt_neutral,
- stats->MVr,
- stats->mvr_abs,
- stats->MVc,
- stats->mvc_abs,
- stats->MVrv,
- stats->MVcv,
- stats->mv_in_out_count,
- stats->new_mv_count,
- stats->count,
- stats->duration);
- fclose(fpfile);
- }
+ {
+ FILE *fpfile;
+ fpfile = fopen("firstpass.stt", "a");
+
+ fprintf(fpfile, "%12.0f %12.0f %12.0f %12.0f %12.0f %12.4f %12.4f"
+ "%12.4f %12.4f %12.4f %12.4f %12.4f %12.4f %12.4f"
+ "%12.0f %12.0f %12.4f %12.0f %12.0f %12.4f\n",
+ stats->frame,
+ stats->intra_error,
+ stats->coded_error,
+ stats->sr_coded_error,
+ stats->ssim_weighted_pred_err,
+ stats->pcnt_inter,
+ stats->pcnt_motion,
+ stats->pcnt_second_ref,
+ stats->pcnt_neutral,
+ stats->MVr,
+ stats->mvr_abs,
+ stats->MVc,
+ stats->mvc_abs,
+ stats->MVrv,
+ stats->MVcv,
+ stats->mv_in_out_count,
+ stats->new_mv_count,
+ stats->count,
+ stats->duration);
+ fclose(fpfile);
+ }
#endif
}
-static void zero_stats(FIRSTPASS_STATS *section)
-{
- section->frame = 0.0;
- section->intra_error = 0.0;
- section->coded_error = 0.0;
- section->sr_coded_error = 0.0;
- section->ssim_weighted_pred_err = 0.0;
- section->pcnt_inter = 0.0;
- section->pcnt_motion = 0.0;
- section->pcnt_second_ref = 0.0;
- section->pcnt_neutral = 0.0;
- section->MVr = 0.0;
- section->mvr_abs = 0.0;
- section->MVc = 0.0;
- section->mvc_abs = 0.0;
- section->MVrv = 0.0;
- section->MVcv = 0.0;
- section->mv_in_out_count = 0.0;
- section->new_mv_count = 0.0;
- section->count = 0.0;
- section->duration = 1.0;
+static void zero_stats(FIRSTPASS_STATS *section) {
+ section->frame = 0.0;
+ section->intra_error = 0.0;
+ section->coded_error = 0.0;
+ section->sr_coded_error = 0.0;
+ section->ssim_weighted_pred_err = 0.0;
+ section->pcnt_inter = 0.0;
+ section->pcnt_motion = 0.0;
+ section->pcnt_second_ref = 0.0;
+ section->pcnt_neutral = 0.0;
+ section->MVr = 0.0;
+ section->mvr_abs = 0.0;
+ section->MVc = 0.0;
+ section->mvc_abs = 0.0;
+ section->MVrv = 0.0;
+ section->MVcv = 0.0;
+ section->mv_in_out_count = 0.0;
+ section->new_mv_count = 0.0;
+ section->count = 0.0;
+ section->duration = 1.0;
}
-static void accumulate_stats(FIRSTPASS_STATS *section, FIRSTPASS_STATS *frame)
-{
- section->frame += frame->frame;
- section->intra_error += frame->intra_error;
- section->coded_error += frame->coded_error;
- section->sr_coded_error += frame->sr_coded_error;
- section->ssim_weighted_pred_err += frame->ssim_weighted_pred_err;
- section->pcnt_inter += frame->pcnt_inter;
- section->pcnt_motion += frame->pcnt_motion;
- section->pcnt_second_ref += frame->pcnt_second_ref;
- section->pcnt_neutral += frame->pcnt_neutral;
- section->MVr += frame->MVr;
- section->mvr_abs += frame->mvr_abs;
- section->MVc += frame->MVc;
- section->mvc_abs += frame->mvc_abs;
- section->MVrv += frame->MVrv;
- section->MVcv += frame->MVcv;
- section->mv_in_out_count += frame->mv_in_out_count;
- section->new_mv_count += frame->new_mv_count;
- section->count += frame->count;
- section->duration += frame->duration;
+static void accumulate_stats(FIRSTPASS_STATS *section, FIRSTPASS_STATS *frame) {
+ section->frame += frame->frame;
+ section->intra_error += frame->intra_error;
+ section->coded_error += frame->coded_error;
+ section->sr_coded_error += frame->sr_coded_error;
+ section->ssim_weighted_pred_err += frame->ssim_weighted_pred_err;
+ section->pcnt_inter += frame->pcnt_inter;
+ section->pcnt_motion += frame->pcnt_motion;
+ section->pcnt_second_ref += frame->pcnt_second_ref;
+ section->pcnt_neutral += frame->pcnt_neutral;
+ section->MVr += frame->MVr;
+ section->mvr_abs += frame->mvr_abs;
+ section->MVc += frame->MVc;
+ section->mvc_abs += frame->mvc_abs;
+ section->MVrv += frame->MVrv;
+ section->MVcv += frame->MVcv;
+ section->mv_in_out_count += frame->mv_in_out_count;
+ section->new_mv_count += frame->new_mv_count;
+ section->count += frame->count;
+ section->duration += frame->duration;
}
-static void subtract_stats(FIRSTPASS_STATS *section, FIRSTPASS_STATS *frame)
-{
- section->frame -= frame->frame;
- section->intra_error -= frame->intra_error;
- section->coded_error -= frame->coded_error;
- section->sr_coded_error -= frame->sr_coded_error;
- section->ssim_weighted_pred_err -= frame->ssim_weighted_pred_err;
- section->pcnt_inter -= frame->pcnt_inter;
- section->pcnt_motion -= frame->pcnt_motion;
- section->pcnt_second_ref -= frame->pcnt_second_ref;
- section->pcnt_neutral -= frame->pcnt_neutral;
- section->MVr -= frame->MVr;
- section->mvr_abs -= frame->mvr_abs;
- section->MVc -= frame->MVc;
- section->mvc_abs -= frame->mvc_abs;
- section->MVrv -= frame->MVrv;
- section->MVcv -= frame->MVcv;
- section->mv_in_out_count -= frame->mv_in_out_count;
- section->new_mv_count -= frame->new_mv_count;
- section->count -= frame->count;
- section->duration -= frame->duration;
+static void subtract_stats(FIRSTPASS_STATS *section, FIRSTPASS_STATS *frame) {
+ section->frame -= frame->frame;
+ section->intra_error -= frame->intra_error;
+ section->coded_error -= frame->coded_error;
+ section->sr_coded_error -= frame->sr_coded_error;
+ section->ssim_weighted_pred_err -= frame->ssim_weighted_pred_err;
+ section->pcnt_inter -= frame->pcnt_inter;
+ section->pcnt_motion -= frame->pcnt_motion;
+ section->pcnt_second_ref -= frame->pcnt_second_ref;
+ section->pcnt_neutral -= frame->pcnt_neutral;
+ section->MVr -= frame->MVr;
+ section->mvr_abs -= frame->mvr_abs;
+ section->MVc -= frame->MVc;
+ section->mvc_abs -= frame->mvc_abs;
+ section->MVrv -= frame->MVrv;
+ section->MVcv -= frame->MVcv;
+ section->mv_in_out_count -= frame->mv_in_out_count;
+ section->new_mv_count -= frame->new_mv_count;
+ section->count -= frame->count;
+ section->duration -= frame->duration;
}
-static void avg_stats(FIRSTPASS_STATS *section)
-{
- if (section->count < 1.0)
- return;
-
- section->intra_error /= section->count;
- section->coded_error /= section->count;
- section->sr_coded_error /= section->count;
- section->ssim_weighted_pred_err /= section->count;
- section->pcnt_inter /= section->count;
- section->pcnt_second_ref /= section->count;
- section->pcnt_neutral /= section->count;
- section->pcnt_motion /= section->count;
- section->MVr /= section->count;
- section->mvr_abs /= section->count;
- section->MVc /= section->count;
- section->mvc_abs /= section->count;
- section->MVrv /= section->count;
- section->MVcv /= section->count;
- section->mv_in_out_count /= section->count;
- section->duration /= section->count;
+static void avg_stats(FIRSTPASS_STATS *section) {
+ if (section->count < 1.0)
+ return;
+
+ section->intra_error /= section->count;
+ section->coded_error /= section->count;
+ section->sr_coded_error /= section->count;
+ section->ssim_weighted_pred_err /= section->count;
+ section->pcnt_inter /= section->count;
+ section->pcnt_second_ref /= section->count;
+ section->pcnt_neutral /= section->count;
+ section->pcnt_motion /= section->count;
+ section->MVr /= section->count;
+ section->mvr_abs /= section->count;
+ section->MVc /= section->count;
+ section->mvc_abs /= section->count;
+ section->MVrv /= section->count;
+ section->MVcv /= section->count;
+ section->mv_in_out_count /= section->count;
+ section->duration /= section->count;
}
// Calculate a modified Error used in distributing bits between easier and harder frames
-static double calculate_modified_err(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
-{
- double av_err = ( cpi->twopass.total_stats->ssim_weighted_pred_err /
- cpi->twopass.total_stats->count );
- double this_err = this_frame->ssim_weighted_pred_err;
- double modified_err;
-
- if (this_err > av_err)
- modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW1);
- else
- modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW2);
-
- return modified_err;
+static double calculate_modified_err(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
+ double av_err = (cpi->twopass.total_stats->ssim_weighted_pred_err /
+ cpi->twopass.total_stats->count);
+ double this_err = this_frame->ssim_weighted_pred_err;
+ double modified_err;
+
+ if (this_err > av_err)
+ modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW1);
+ else
+ modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW2);
+
+ return modified_err;
}
static const double weight_table[256] = {
-0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
-0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
-0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
-0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
-0.020000, 0.031250, 0.062500, 0.093750, 0.125000, 0.156250, 0.187500, 0.218750,
-0.250000, 0.281250, 0.312500, 0.343750, 0.375000, 0.406250, 0.437500, 0.468750,
-0.500000, 0.531250, 0.562500, 0.593750, 0.625000, 0.656250, 0.687500, 0.718750,
-0.750000, 0.781250, 0.812500, 0.843750, 0.875000, 0.906250, 0.937500, 0.968750,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
-1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000
+ 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
+ 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
+ 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
+ 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000, 0.020000,
+ 0.020000, 0.031250, 0.062500, 0.093750, 0.125000, 0.156250, 0.187500, 0.218750,
+ 0.250000, 0.281250, 0.312500, 0.343750, 0.375000, 0.406250, 0.437500, 0.468750,
+ 0.500000, 0.531250, 0.562500, 0.593750, 0.625000, 0.656250, 0.687500, 0.718750,
+ 0.750000, 0.781250, 0.812500, 0.843750, 0.875000, 0.906250, 0.937500, 0.968750,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+ 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000
};
-static double simple_weight(YV12_BUFFER_CONFIG *source)
-{
- int i, j;
-
- unsigned char *src = source->y_buffer;
- double sum_weights = 0.0;
-
- // Loop throught the Y plane raw examining levels and creating a weight for the image
- i = source->y_height;
- do
- {
- j = source->y_width;
- do
- {
- sum_weights += weight_table[ *src];
- src++;
- }while(--j);
- src -= source->y_width;
- src += source->y_stride;
- }while(--i);
-
- sum_weights /= (source->y_height * source->y_width);
-
- return sum_weights;
+static double simple_weight(YV12_BUFFER_CONFIG *source) {
+ int i, j;
+
+ unsigned char *src = source->y_buffer;
+ double sum_weights = 0.0;
+
+ // Loop throught the Y plane raw examining levels and creating a weight for the image
+ i = source->y_height;
+ do {
+ j = source->y_width;
+ do {
+ sum_weights += weight_table[ *src];
+ src++;
+ } while (--j);
+ src -= source->y_width;
+ src += source->y_stride;
+ } while (--i);
+
+ sum_weights /= (source->y_height * source->y_width);
+
+ return sum_weights;
}
// This function returns the current per frame maximum bitrate target
-static int frame_max_bits(VP8_COMP *cpi)
-{
- // Max allocation for a single frame based on the max section guidelines passed in and how many bits are left
- int max_bits;
+static int frame_max_bits(VP8_COMP *cpi) {
+ // Max allocation for a single frame based on the max section guidelines passed in and how many bits are left
+ int max_bits;
- // For VBR base this on the bits and frames left plus the two_pass_vbrmax_section rate passed in by the user
- max_bits = (int)(((double)cpi->twopass.bits_left / (cpi->twopass.total_stats->count - (double)cpi->common.current_video_frame)) * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
+ // For VBR base this on the bits and frames left plus the two_pass_vbrmax_section rate passed in by the user
+ max_bits = (int)(((double)cpi->twopass.bits_left / (cpi->twopass.total_stats->count - (double)cpi->common.current_video_frame)) * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
- // Trap case where we are out of bits
- if (max_bits < 0)
- max_bits = 0;
+ // Trap case where we are out of bits
+ if (max_bits < 0)
+ max_bits = 0;
- return max_bits;
+ return max_bits;
}
-void vp8_init_first_pass(VP8_COMP *cpi)
-{
- zero_stats(cpi->twopass.total_stats);
+void vp8_init_first_pass(VP8_COMP *cpi) {
+ zero_stats(cpi->twopass.total_stats);
}
-void vp8_end_first_pass(VP8_COMP *cpi)
-{
- output_stats(cpi, cpi->output_pkt_list, cpi->twopass.total_stats);
+void vp8_end_first_pass(VP8_COMP *cpi) {
+ output_stats(cpi, cpi->output_pkt_list, cpi->twopass.total_stats);
}
-static void zz_motion_search( VP8_COMP *cpi, MACROBLOCK * x, YV12_BUFFER_CONFIG * recon_buffer, int * best_motion_err, int recon_yoffset )
-{
- MACROBLOCKD * const xd = & x->e_mbd;
- BLOCK *b = &x->block[0];
- BLOCKD *d = &x->e_mbd.block[0];
+static void zz_motion_search(VP8_COMP *cpi, MACROBLOCK *x, YV12_BUFFER_CONFIG *recon_buffer, int *best_motion_err, int recon_yoffset) {
+ MACROBLOCKD *const xd = & x->e_mbd;
+ BLOCK *b = &x->block[0];
+ BLOCKD *d = &x->e_mbd.block[0];
- unsigned char *src_ptr = (*(b->base_src) + b->src);
- int src_stride = b->src_stride;
- unsigned char *ref_ptr;
- int ref_stride=d->pre_stride;
+ unsigned char *src_ptr = (*(b->base_src) + b->src);
+ int src_stride = b->src_stride;
+ unsigned char *ref_ptr;
+ int ref_stride = d->pre_stride;
- // Set up pointers for this macro block recon buffer
- xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
+ // Set up pointers for this macro block recon buffer
+ xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
- ref_ptr = (unsigned char *)(*(d->base_pre) + d->pre );
+ ref_ptr = (unsigned char *)(*(d->base_pre) + d->pre);
- VARIANCE_INVOKE(IF_RTCD(&cpi->rtcd.variance), mse16x16) ( src_ptr, src_stride, ref_ptr, ref_stride, (unsigned int *)(best_motion_err));
+ VARIANCE_INVOKE(IF_RTCD(&cpi->rtcd.variance), mse16x16)(src_ptr, src_stride, ref_ptr, ref_stride, (unsigned int *)(best_motion_err));
}
static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
int_mv *ref_mv, MV *best_mv,
YV12_BUFFER_CONFIG *recon_buffer,
- int *best_motion_err, int recon_yoffset )
-{
- MACROBLOCKD *const xd = & x->e_mbd;
- BLOCK *b = &x->block[0];
- BLOCKD *d = &x->e_mbd.block[0];
- int num00;
-
- int_mv tmp_mv;
- int_mv ref_mv_full;
-
- int tmp_err;
- int step_param = 3;
- int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
- int n;
- vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
- int new_mv_mode_penalty = 256;
-
- // override the default variance function to use MSE
- v_fn_ptr.vf = VARIANCE_INVOKE(IF_RTCD(&cpi->rtcd.variance), mse16x16);
-
- // Set up pointers for this macro block recon buffer
- xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
-
- // Initial step/diamond search centred on best mv
- tmp_mv.as_int = 0;
- ref_mv_full.as_mv.col = ref_mv->as_mv.col>>3;
- ref_mv_full.as_mv.row = ref_mv->as_mv.row>>3;
- tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param,
- x->sadperbit16, &num00, &v_fn_ptr,
- XMVCOST, ref_mv);
- if ( tmp_err < INT_MAX-new_mv_mode_penalty )
+ int *best_motion_err, int recon_yoffset) {
+ MACROBLOCKD *const xd = & x->e_mbd;
+ BLOCK *b = &x->block[0];
+ BLOCKD *d = &x->e_mbd.block[0];
+ int num00;
+
+ int_mv tmp_mv;
+ int_mv ref_mv_full;
+
+ int tmp_err;
+ int step_param = 3;
+ int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
+ int n;
+ vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
+ int new_mv_mode_penalty = 256;
+
+ // override the default variance function to use MSE
+ v_fn_ptr.vf = VARIANCE_INVOKE(IF_RTCD(&cpi->rtcd.variance), mse16x16);
+
+ // Set up pointers for this macro block recon buffer
+ xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
+
+ // Initial step/diamond search centred on best mv
+ tmp_mv.as_int = 0;
+ ref_mv_full.as_mv.col = ref_mv->as_mv.col >> 3;
+ ref_mv_full.as_mv.row = ref_mv->as_mv.row >> 3;
+ tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param,
+ x->sadperbit16, &num00, &v_fn_ptr,
+ XMVCOST, ref_mv);
+ if (tmp_err < INT_MAX - new_mv_mode_penalty)
+ tmp_err += new_mv_mode_penalty;
+
+ if (tmp_err < *best_motion_err) {
+ *best_motion_err = tmp_err;
+ best_mv->row = tmp_mv.as_mv.row;
+ best_mv->col = tmp_mv.as_mv.col;
+ }
+
+ // Further step/diamond searches as necessary
+ n = num00;
+ num00 = 0;
+
+ while (n < further_steps) {
+ n++;
+
+ if (num00)
+ num00--;
+ else {
+ tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv,
+ step_param + n, x->sadperbit16,
+ &num00, &v_fn_ptr,
+ XMVCOST, ref_mv);
+ if (tmp_err < INT_MAX - new_mv_mode_penalty)
tmp_err += new_mv_mode_penalty;
- if (tmp_err < *best_motion_err)
- {
+ if (tmp_err < *best_motion_err) {
*best_motion_err = tmp_err;
best_mv->row = tmp_mv.as_mv.row;
best_mv->col = tmp_mv.as_mv.col;
+ }
}
-
- // Further step/diamond searches as necessary
- n = num00;
- num00 = 0;
-
- while (n < further_steps)
- {
- n++;
-
- if (num00)
- num00--;
- else
- {
- tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv,
- step_param + n, x->sadperbit16,
- &num00, &v_fn_ptr,
- XMVCOST, ref_mv);
- if ( tmp_err < INT_MAX-new_mv_mode_penalty )
- tmp_err += new_mv_mode_penalty;
-
- if (tmp_err < *best_motion_err)
- {
- *best_motion_err = tmp_err;
- best_mv->row = tmp_mv.as_mv.row;
- best_mv->col = tmp_mv.as_mv.col;
- }
- }
- }
+ }
}
-void vp8_first_pass(VP8_COMP *cpi)
-{
- int mb_row, mb_col;
- MACROBLOCK *const x = & cpi->mb;
- VP8_COMMON *const cm = & cpi->common;
- MACROBLOCKD *const xd = & x->e_mbd;
-
- int recon_yoffset, recon_uvoffset;
- YV12_BUFFER_CONFIG *lst_yv12 = &cm->yv12_fb[cm->lst_fb_idx];
- YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
- YV12_BUFFER_CONFIG *gld_yv12 = &cm->yv12_fb[cm->gld_fb_idx];
- int recon_y_stride = lst_yv12->y_stride;
- int recon_uv_stride = lst_yv12->uv_stride;
- int64_t intra_error = 0;
- int64_t coded_error = 0;
- int64_t sr_coded_error = 0;
-
- int sum_mvr = 0, sum_mvc = 0;
- int sum_mvr_abs = 0, sum_mvc_abs = 0;
- int sum_mvrs = 0, sum_mvcs = 0;
- int mvcount = 0;
- int intercount = 0;
- int second_ref_count = 0;
- int intrapenalty = 256;
- int neutral_count = 0;
- int new_mv_count = 0;
- int sum_in_vectors = 0;
- uint32_t lastmv_as_int = 0;
-
- int_mv zero_ref_mv;
-
- zero_ref_mv.as_int = 0;
-
- vp8_clear_system_state(); //__asm emms;
-
- x->src = * cpi->Source;
- xd->pre = *lst_yv12;
- xd->dst = *new_yv12;
-
- x->partition_info = x->pi;
-
- xd->mode_info_context = cm->mi;
-
- vp8_build_block_offsets(x);
-
- vp8_setup_block_dptrs(&x->e_mbd);
-
- vp8_setup_block_ptrs(x);
-
- // set up frame new frame for intra coded blocks
- vp8_setup_intra_recon(new_yv12);
- vp8cx_frame_init_quantizer(cpi);
-
- // Initialise the MV cost table to the defaults
- //if( cm->current_video_frame == 0)
- //if ( 0 )
- {
- int flag[2] = {1, 1};
- vp8_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
- vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
- vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
+void vp8_first_pass(VP8_COMP *cpi) {
+ int mb_row, mb_col;
+ MACROBLOCK *const x = & cpi->mb;
+ VP8_COMMON *const cm = & cpi->common;
+ MACROBLOCKD *const xd = & x->e_mbd;
+
+ int recon_yoffset, recon_uvoffset;
+ YV12_BUFFER_CONFIG *lst_yv12 = &cm->yv12_fb[cm->lst_fb_idx];
+ YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
+ YV12_BUFFER_CONFIG *gld_yv12 = &cm->yv12_fb[cm->gld_fb_idx];
+ int recon_y_stride = lst_yv12->y_stride;
+ int recon_uv_stride = lst_yv12->uv_stride;
+ int64_t intra_error = 0;
+ int64_t coded_error = 0;
+ int64_t sr_coded_error = 0;
+
+ int sum_mvr = 0, sum_mvc = 0;
+ int sum_mvr_abs = 0, sum_mvc_abs = 0;
+ int sum_mvrs = 0, sum_mvcs = 0;
+ int mvcount = 0;
+ int intercount = 0;
+ int second_ref_count = 0;
+ int intrapenalty = 256;
+ int neutral_count = 0;
+ int new_mv_count = 0;
+ int sum_in_vectors = 0;
+ uint32_t lastmv_as_int = 0;
+
+ int_mv zero_ref_mv;
+
+ zero_ref_mv.as_int = 0;
+
+ vp8_clear_system_state(); // __asm emms;
+
+ x->src = * cpi->Source;
+ xd->pre = *lst_yv12;
+ xd->dst = *new_yv12;
+
+ x->partition_info = x->pi;
+
+ xd->mode_info_context = cm->mi;
+
+ vp8_build_block_offsets(x);
+
+ vp8_setup_block_dptrs(&x->e_mbd);
+
+ vp8_setup_block_ptrs(x);
+
+ // set up frame new frame for intra coded blocks
+ vp8_setup_intra_recon(new_yv12);
+ vp8cx_frame_init_quantizer(cpi);
+
+ // Initialise the MV cost table to the defaults
+ // if( cm->current_video_frame == 0)
+ // if ( 0 )
+ {
+ int flag[2] = {1, 1};
+ vp8_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
+ vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
+ vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
#if CONFIG_HIGH_PRECISION_MV
- vpx_memcpy(cm->fc.mvc_hp, vp8_default_mv_context_hp, sizeof(vp8_default_mv_context_hp));
- vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp, (const MV_CONTEXT_HP *) cm->fc.mvc_hp, flag);
+ vpx_memcpy(cm->fc.mvc_hp, vp8_default_mv_context_hp, sizeof(vp8_default_mv_context_hp));
+ vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp, (const MV_CONTEXT_HP *) cm->fc.mvc_hp, flag);
#endif
- }
+ }
+
+ // for each macroblock row in image
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ int_mv best_ref_mv;
+
+ best_ref_mv.as_int = 0;
+
+ // reset above block coeffs
+ xd->up_available = (mb_row != 0);
+ recon_yoffset = (mb_row * recon_y_stride * 16);
+ recon_uvoffset = (mb_row * recon_uv_stride * 8);
+
+ // Set up limit values for motion vectors to prevent them extending outside the UMV borders
+ x->mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
+ x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16) + (VP8BORDERINPIXELS - 16);
+
+
+ // for each macroblock col in image
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ int this_error;
+ int gf_motion_error = INT_MAX;
+ int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
+
+ xd->dst.y_buffer = new_yv12->y_buffer + recon_yoffset;
+ xd->dst.u_buffer = new_yv12->u_buffer + recon_uvoffset;
+ xd->dst.v_buffer = new_yv12->v_buffer + recon_uvoffset;
+ xd->left_available = (mb_col != 0);
+
+ // Copy current mb to a buffer
+ RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer, x->src.y_stride, x->thismb, 16);
+
+ // do intra 16x16 prediction
+ this_error = vp8_encode_intra(cpi, x, use_dc_pred);
+
+ // "intrapenalty" below deals with situations where the intra and inter error scores are very low (eg a plain black frame)
+ // We do not have special cases in first pass for 0,0 and nearest etc so all inter modes carry an overhead cost estimate fot the mv.
+ // When the error score is very low this causes us to pick all or lots of INTRA modes and throw lots of key frames.
+ // This penalty adds a cost matching that of a 0,0 mv to the intra case.
+ this_error += intrapenalty;
+
+ // Cumulative intra error total
+ intra_error += (int64_t)this_error;
+
+ // Set up limit values for motion vectors to prevent them extending outside the UMV borders
+ x->mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
+ x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16) + (VP8BORDERINPIXELS - 16);
+
+ // Other than for the first frame do a motion search
+ if (cm->current_video_frame > 0) {
+ int tmp_err;
+ int motion_error = INT_MAX;
+ int_mv mv, tmp_mv;
+
+ // Simple 0,0 motion with no mv overhead
+ zz_motion_search(cpi, x, lst_yv12, &motion_error, recon_yoffset);
+ mv.as_int = tmp_mv.as_int = 0;
+
+ // Test last reference frame using the previous best mv as the
+ // starting point (best reference) for the search
+ first_pass_motion_search(cpi, x, &best_ref_mv,
+ &mv.as_mv, lst_yv12,
+ &motion_error, recon_yoffset);
+
+ // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
+ if (best_ref_mv.as_int) {
+ tmp_err = INT_MAX;
+ first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv.as_mv,
+ lst_yv12, &tmp_err, recon_yoffset);
+
+ if (tmp_err < motion_error) {
+ motion_error = tmp_err;
+ mv.as_int = tmp_mv.as_int;
+ }
+ }
- // for each macroblock row in image
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- int_mv best_ref_mv;
+ // Experimental search in an older reference frame
+ if (cm->current_video_frame > 1) {
+ // Simple 0,0 motion with no mv overhead
+ zz_motion_search(cpi, x, gld_yv12,
+ &gf_motion_error, recon_yoffset);
+
+ first_pass_motion_search(cpi, x, &zero_ref_mv,
+ &tmp_mv.as_mv, gld_yv12,
+ &gf_motion_error, recon_yoffset);
+
+ if ((gf_motion_error < motion_error) &&
+ (gf_motion_error < this_error)) {
+ second_ref_count++;
+ }
+
+ // Reset to last frame as reference buffer
+ xd->pre.y_buffer = lst_yv12->y_buffer + recon_yoffset;
+ xd->pre.u_buffer = lst_yv12->u_buffer + recon_uvoffset;
+ xd->pre.v_buffer = lst_yv12->v_buffer + recon_uvoffset;
+
+ // In accumulating a score for the older reference frame
+ // take the best of the motion predicted score and
+ // the intra coded error (just as will be done for)
+ // accumulation of "coded_error" for the last frame.
+ if (gf_motion_error < this_error)
+ sr_coded_error += gf_motion_error;
+ else
+ sr_coded_error += this_error;
+ } else
+ sr_coded_error += motion_error;
+ /* Intra assumed best */
best_ref_mv.as_int = 0;
- // reset above block coeffs
- xd->up_available = (mb_row != 0);
- recon_yoffset = (mb_row * recon_y_stride * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8);
-
- // Set up limit values for motion vectors to prevent them extending outside the UMV borders
- x->mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
- x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16) + (VP8BORDERINPIXELS - 16);
-
-
- // for each macroblock col in image
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- int this_error;
- int gf_motion_error = INT_MAX;
- int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
-
- xd->dst.y_buffer = new_yv12->y_buffer + recon_yoffset;
- xd->dst.u_buffer = new_yv12->u_buffer + recon_uvoffset;
- xd->dst.v_buffer = new_yv12->v_buffer + recon_uvoffset;
- xd->left_available = (mb_col != 0);
-
- //Copy current mb to a buffer
- RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer, x->src.y_stride, x->thismb, 16);
-
- // do intra 16x16 prediction
- this_error = vp8_encode_intra(cpi, x, use_dc_pred);
-
- // "intrapenalty" below deals with situations where the intra and inter error scores are very low (eg a plain black frame)
- // We do not have special cases in first pass for 0,0 and nearest etc so all inter modes carry an overhead cost estimate fot the mv.
- // When the error score is very low this causes us to pick all or lots of INTRA modes and throw lots of key frames.
- // This penalty adds a cost matching that of a 0,0 mv to the intra case.
- this_error += intrapenalty;
-
- // Cumulative intra error total
- intra_error += (int64_t)this_error;
-
- // Set up limit values for motion vectors to prevent them extending outside the UMV borders
- x->mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
- x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16) + (VP8BORDERINPIXELS - 16);
-
- // Other than for the first frame do a motion search
- if (cm->current_video_frame > 0)
- {
- int tmp_err;
- int motion_error = INT_MAX;
- int_mv mv, tmp_mv;
-
- // Simple 0,0 motion with no mv overhead
- zz_motion_search( cpi, x, lst_yv12, &motion_error, recon_yoffset );
- mv.as_int = tmp_mv.as_int = 0;
-
- // Test last reference frame using the previous best mv as the
- // starting point (best reference) for the search
- first_pass_motion_search(cpi, x, &best_ref_mv,
- &mv.as_mv, lst_yv12,
- &motion_error, recon_yoffset);
-
- // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
- if (best_ref_mv.as_int)
- {
- tmp_err = INT_MAX;
- first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv.as_mv,
- lst_yv12, &tmp_err, recon_yoffset);
-
- if ( tmp_err < motion_error )
- {
- motion_error = tmp_err;
- mv.as_int = tmp_mv.as_int;
- }
- }
-
- // Experimental search in an older reference frame
- if (cm->current_video_frame > 1)
- {
- // Simple 0,0 motion with no mv overhead
- zz_motion_search( cpi, x, gld_yv12,
- &gf_motion_error, recon_yoffset );
-
- first_pass_motion_search(cpi, x, &zero_ref_mv,
- &tmp_mv.as_mv, gld_yv12,
- &gf_motion_error, recon_yoffset);
-
- if ( (gf_motion_error < motion_error) &&
- (gf_motion_error < this_error))
- {
- second_ref_count++;
- }
-
- // Reset to last frame as reference buffer
- xd->pre.y_buffer = lst_yv12->y_buffer + recon_yoffset;
- xd->pre.u_buffer = lst_yv12->u_buffer + recon_uvoffset;
- xd->pre.v_buffer = lst_yv12->v_buffer + recon_uvoffset;
-
- // In accumulating a score for the older reference frame
- // take the best of the motion predicted score and
- // the intra coded error (just as will be done for)
- // accumulation of "coded_error" for the last frame.
- if ( gf_motion_error < this_error )
- sr_coded_error += gf_motion_error;
- else
- sr_coded_error += this_error;
- }
- else
- sr_coded_error += motion_error;
-
- /* Intra assumed best */
- best_ref_mv.as_int = 0;
-
- if (motion_error <= this_error)
- {
- // Keep a count of cases where the inter and intra were
- // very close and very low. This helps with scene cut
- // detection for example in cropped clips with black bars
- // at the sides or top and bottom.
- if( (((this_error-intrapenalty) * 9) <=
- (motion_error*10)) &&
- (this_error < (2*intrapenalty)) )
- {
- neutral_count++;
- }
-
- mv.as_mv.row <<= 3;
- mv.as_mv.col <<= 3;
- this_error = motion_error;
- vp8_set_mbmode_and_mvs(x, NEWMV, &mv);
- vp8_encode_inter16x16y(IF_RTCD(&cpi->rtcd), x);
- sum_mvr += mv.as_mv.row;
- sum_mvr_abs += abs(mv.as_mv.row);
- sum_mvc += mv.as_mv.col;
- sum_mvc_abs += abs(mv.as_mv.col);
- sum_mvrs += mv.as_mv.row * mv.as_mv.row;
- sum_mvcs += mv.as_mv.col * mv.as_mv.col;
- intercount++;
-
- best_ref_mv.as_int = mv.as_int;
-
- // Was the vector non-zero
- if (mv.as_int)
- {
- mvcount++;
-
- // Was it different from the last non zero vector
- if ( mv.as_int != lastmv_as_int )
- new_mv_count++;
- lastmv_as_int = mv.as_int;
-
- // Does the Row vector point inwards or outwards
- if (mb_row < cm->mb_rows / 2)
- {
- if (mv.as_mv.row > 0)
- sum_in_vectors--;
- else if (mv.as_mv.row < 0)
- sum_in_vectors++;
- }
- else if (mb_row > cm->mb_rows / 2)
- {
- if (mv.as_mv.row > 0)
- sum_in_vectors++;
- else if (mv.as_mv.row < 0)
- sum_in_vectors--;
- }
-
- // Does the Row vector point inwards or outwards
- if (mb_col < cm->mb_cols / 2)
- {
- if (mv.as_mv.col > 0)
- sum_in_vectors--;
- else if (mv.as_mv.col < 0)
- sum_in_vectors++;
- }
- else if (mb_col > cm->mb_cols / 2)
- {
- if (mv.as_mv.col > 0)
- sum_in_vectors++;
- else if (mv.as_mv.col < 0)
- sum_in_vectors--;
- }
- }
- }
+ if (motion_error <= this_error) {
+ // Keep a count of cases where the inter and intra were
+ // very close and very low. This helps with scene cut
+ // detection for example in cropped clips with black bars
+ // at the sides or top and bottom.
+ if ((((this_error - intrapenalty) * 9) <=
+ (motion_error * 10)) &&
+ (this_error < (2 * intrapenalty))) {
+ neutral_count++;
+ }
+
+ mv.as_mv.row <<= 3;
+ mv.as_mv.col <<= 3;
+ this_error = motion_error;
+ vp8_set_mbmode_and_mvs(x, NEWMV, &mv);
+ vp8_encode_inter16x16y(IF_RTCD(&cpi->rtcd), x);
+ sum_mvr += mv.as_mv.row;
+ sum_mvr_abs += abs(mv.as_mv.row);
+ sum_mvc += mv.as_mv.col;
+ sum_mvc_abs += abs(mv.as_mv.col);
+ sum_mvrs += mv.as_mv.row * mv.as_mv.row;
+ sum_mvcs += mv.as_mv.col * mv.as_mv.col;
+ intercount++;
+
+ best_ref_mv.as_int = mv.as_int;
+
+ // Was the vector non-zero
+ if (mv.as_int) {
+ mvcount++;
+
+ // Was it different from the last non zero vector
+ if (mv.as_int != lastmv_as_int)
+ new_mv_count++;
+ lastmv_as_int = mv.as_int;
+
+ // Does the Row vector point inwards or outwards
+ if (mb_row < cm->mb_rows / 2) {
+ if (mv.as_mv.row > 0)
+ sum_in_vectors--;
+ else if (mv.as_mv.row < 0)
+ sum_in_vectors++;
+ } else if (mb_row > cm->mb_rows / 2) {
+ if (mv.as_mv.row > 0)
+ sum_in_vectors++;
+ else if (mv.as_mv.row < 0)
+ sum_in_vectors--;
}
- else
- sr_coded_error += (int64_t)this_error;
-
- coded_error += (int64_t)this_error;
- // adjust to the next column of macroblocks
- x->src.y_buffer += 16;
- x->src.u_buffer += 8;
- x->src.v_buffer += 8;
-
- recon_yoffset += 16;
- recon_uvoffset += 8;
+ // Does the Row vector point inwards or outwards
+ if (mb_col < cm->mb_cols / 2) {
+ if (mv.as_mv.col > 0)
+ sum_in_vectors--;
+ else if (mv.as_mv.col < 0)
+ sum_in_vectors++;
+ } else if (mb_col > cm->mb_cols / 2) {
+ if (mv.as_mv.col > 0)
+ sum_in_vectors++;
+ else if (mv.as_mv.col < 0)
+ sum_in_vectors--;
+ }
+ }
}
+ } else
+ sr_coded_error += (int64_t)this_error;
- // adjust to the next row of mbs
- x->src.y_buffer += 16 * x->src.y_stride - 16 * cm->mb_cols;
- x->src.u_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
- x->src.v_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
+ coded_error += (int64_t)this_error;
- //extend the recon for intra prediction
- vp8_extend_mb_row(new_yv12, xd->dst.y_buffer + 16, xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
- vp8_clear_system_state(); //__asm emms;
- }
+ // adjust to the next column of macroblocks
+ x->src.y_buffer += 16;
+ x->src.u_buffer += 8;
+ x->src.v_buffer += 8;
- vp8_clear_system_state(); //__asm emms;
- {
- double weight = 0.0;
-
- FIRSTPASS_STATS fps;
-
- fps.frame = cm->current_video_frame ;
- fps.intra_error = intra_error >> 8;
- fps.coded_error = coded_error >> 8;
- fps.sr_coded_error = sr_coded_error >> 8;
- weight = simple_weight(cpi->Source);
-
-
- if (weight < 0.1)
- weight = 0.1;
-
- fps.ssim_weighted_pred_err = fps.coded_error * weight;
-
- fps.pcnt_inter = 0.0;
- fps.pcnt_motion = 0.0;
- fps.MVr = 0.0;
- fps.mvr_abs = 0.0;
- fps.MVc = 0.0;
- fps.mvc_abs = 0.0;
- fps.MVrv = 0.0;
- fps.MVcv = 0.0;
- fps.mv_in_out_count = 0.0;
- fps.new_mv_count = 0.0;
- fps.count = 1.0;
-
- fps.pcnt_inter = 1.0 * (double)intercount / cm->MBs;
- fps.pcnt_second_ref = 1.0 * (double)second_ref_count / cm->MBs;
- fps.pcnt_neutral = 1.0 * (double)neutral_count / cm->MBs;
-
- if (mvcount > 0)
- {
- fps.MVr = (double)sum_mvr / (double)mvcount;
- fps.mvr_abs = (double)sum_mvr_abs / (double)mvcount;
- fps.MVc = (double)sum_mvc / (double)mvcount;
- fps.mvc_abs = (double)sum_mvc_abs / (double)mvcount;
- fps.MVrv = ((double)sum_mvrs - (fps.MVr * fps.MVr / (double)mvcount)) / (double)mvcount;
- fps.MVcv = ((double)sum_mvcs - (fps.MVc * fps.MVc / (double)mvcount)) / (double)mvcount;
- fps.mv_in_out_count = (double)sum_in_vectors / (double)(mvcount * 2);
- fps.new_mv_count = new_mv_count;
-
- fps.pcnt_motion = 1.0 * (double)mvcount / cpi->common.MBs;
- }
-
- // TODO: handle the case when duration is set to 0, or something less
- // than the full time between subsequent cpi->source_time_stamp s .
- fps.duration = cpi->source->ts_end
- - cpi->source->ts_start;
-
- // don't want to do output stats with a stack variable!
- memcpy(cpi->twopass.this_frame_stats,
- &fps,
- sizeof(FIRSTPASS_STATS));
- output_stats(cpi, cpi->output_pkt_list, cpi->twopass.this_frame_stats);
- accumulate_stats(cpi->twopass.total_stats, &fps);
+ recon_yoffset += 16;
+ recon_uvoffset += 8;
}
- // Copy the previous Last Frame back into gf and and arf buffers if
- // the prediction is good enough... but also dont allow it to lag too far
- if ((cpi->twopass.sr_update_lag > 3) ||
- ((cm->current_video_frame > 0) &&
- (cpi->twopass.this_frame_stats->pcnt_inter > 0.20) &&
- ((cpi->twopass.this_frame_stats->intra_error /
- cpi->twopass.this_frame_stats->coded_error) > 2.0)))
- {
- vp8_yv12_copy_frame_ptr(lst_yv12, gld_yv12);
- cpi->twopass.sr_update_lag = 1;
+ // adjust to the next row of mbs
+ x->src.y_buffer += 16 * x->src.y_stride - 16 * cm->mb_cols;
+ x->src.u_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
+ x->src.v_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
+
+ // extend the recon for intra prediction
+ vp8_extend_mb_row(new_yv12, xd->dst.y_buffer + 16, xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
+ vp8_clear_system_state(); // __asm emms;
+ }
+
+ vp8_clear_system_state(); // __asm emms;
+ {
+ double weight = 0.0;
+
+ FIRSTPASS_STATS fps;
+
+ fps.frame = cm->current_video_frame;
+ fps.intra_error = intra_error >> 8;
+ fps.coded_error = coded_error >> 8;
+ fps.sr_coded_error = sr_coded_error >> 8;
+ weight = simple_weight(cpi->Source);
+
+
+ if (weight < 0.1)
+ weight = 0.1;
+
+ fps.ssim_weighted_pred_err = fps.coded_error * weight;
+
+ fps.pcnt_inter = 0.0;
+ fps.pcnt_motion = 0.0;
+ fps.MVr = 0.0;
+ fps.mvr_abs = 0.0;
+ fps.MVc = 0.0;
+ fps.mvc_abs = 0.0;
+ fps.MVrv = 0.0;
+ fps.MVcv = 0.0;
+ fps.mv_in_out_count = 0.0;
+ fps.new_mv_count = 0.0;
+ fps.count = 1.0;
+
+ fps.pcnt_inter = 1.0 * (double)intercount / cm->MBs;
+ fps.pcnt_second_ref = 1.0 * (double)second_ref_count / cm->MBs;
+ fps.pcnt_neutral = 1.0 * (double)neutral_count / cm->MBs;
+
+ if (mvcount > 0) {
+ fps.MVr = (double)sum_mvr / (double)mvcount;
+ fps.mvr_abs = (double)sum_mvr_abs / (double)mvcount;
+ fps.MVc = (double)sum_mvc / (double)mvcount;
+ fps.mvc_abs = (double)sum_mvc_abs / (double)mvcount;
+ fps.MVrv = ((double)sum_mvrs - (fps.MVr * fps.MVr / (double)mvcount)) / (double)mvcount;
+ fps.MVcv = ((double)sum_mvcs - (fps.MVc * fps.MVc / (double)mvcount)) / (double)mvcount;
+ fps.mv_in_out_count = (double)sum_in_vectors / (double)(mvcount * 2);
+ fps.new_mv_count = new_mv_count;
+
+ fps.pcnt_motion = 1.0 * (double)mvcount / cpi->common.MBs;
}
- else
- cpi->twopass.sr_update_lag ++;
- // swap frame pointers so last frame refers to the frame we just compressed
- vp8_swap_yv12_buffer(lst_yv12, new_yv12);
- vp8_yv12_extend_frame_borders(lst_yv12);
+ // TODO: handle the case when duration is set to 0, or something less
+ // than the full time between subsequent cpi->source_time_stamp s .
+ fps.duration = cpi->source->ts_end
+ - cpi->source->ts_start;
+
+ // don't want to do output stats with a stack variable!
+ memcpy(cpi->twopass.this_frame_stats,
+ &fps,
+ sizeof(FIRSTPASS_STATS));
+ output_stats(cpi, cpi->output_pkt_list, cpi->twopass.this_frame_stats);
+ accumulate_stats(cpi->twopass.total_stats, &fps);
+ }
+
+ // Copy the previous Last Frame back into gf and and arf buffers if
+ // the prediction is good enough... but also dont allow it to lag too far
+ if ((cpi->twopass.sr_update_lag > 3) ||
+ ((cm->current_video_frame > 0) &&
+ (cpi->twopass.this_frame_stats->pcnt_inter > 0.20) &&
+ ((cpi->twopass.this_frame_stats->intra_error /
+ cpi->twopass.this_frame_stats->coded_error) > 2.0))) {
+ vp8_yv12_copy_frame_ptr(lst_yv12, gld_yv12);
+ cpi->twopass.sr_update_lag = 1;
+ } else
+ cpi->twopass.sr_update_lag++;
- // Special case for the first frame. Copy into the GF buffer as a second reference.
- if (cm->current_video_frame == 0)
- {
- vp8_yv12_copy_frame_ptr(lst_yv12, gld_yv12);
- }
+ // swap frame pointers so last frame refers to the frame we just compressed
+ vp8_swap_yv12_buffer(lst_yv12, new_yv12);
+ vp8_yv12_extend_frame_borders(lst_yv12);
+ // Special case for the first frame. Copy into the GF buffer as a second reference.
+ if (cm->current_video_frame == 0) {
+ vp8_yv12_copy_frame_ptr(lst_yv12, gld_yv12);
+ }
- // use this to see what the first pass reconstruction looks like
- if (0)
- {
- char filename[512];
- FILE *recon_file;
- sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
- if (cm->current_video_frame == 0)
- recon_file = fopen(filename, "wb");
- else
- recon_file = fopen(filename, "ab");
+ // use this to see what the first pass reconstruction looks like
+ if (0) {
+ char filename[512];
+ FILE *recon_file;
+ sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
- if(fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1, recon_file));
- fclose(recon_file);
- }
+ if (cm->current_video_frame == 0)
+ recon_file = fopen(filename, "wb");
+ else
+ recon_file = fopen(filename, "ab");
+
+ if (fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1, recon_file));
+ fclose(recon_file);
+ }
- cm->current_video_frame++;
+ cm->current_video_frame++;
}
@@ -858,1840 +806,1723 @@ void vp8_first_pass(VP8_COMP *cpi)
//
-double bitcost( double prob )
-{
- return -(log( prob ) / log( 2.0 ));
+double bitcost(double prob) {
+ return -(log(prob) / log(2.0));
}
static long long estimate_modemvcost(VP8_COMP *cpi,
- FIRSTPASS_STATS * fpstats)
-{
- int mv_cost;
- int mode_cost;
-
- double av_pct_inter = fpstats->pcnt_inter / fpstats->count;
- double av_pct_motion = fpstats->pcnt_motion / fpstats->count;
- double av_intra = (1.0 - av_pct_inter);
-
- double zz_cost;
- double motion_cost;
- double intra_cost;
-
- zz_cost = bitcost(av_pct_inter - av_pct_motion);
- motion_cost = bitcost(av_pct_motion);
- intra_cost = bitcost(av_intra);
-
- // Estimate of extra bits per mv overhead for mbs
- // << 9 is the normalization to the (bits * 512) used in vp8_bits_per_mb
- mv_cost = ((int)(fpstats->new_mv_count / fpstats->count) * 8) << 9;
-
- // Crude estimate of overhead cost from modes
- // << 9 is the normalization to (bits * 512) used in vp8_bits_per_mb
- mode_cost =
- (int)( ( ((av_pct_inter - av_pct_motion) * zz_cost) +
- (av_pct_motion * motion_cost) +
- (av_intra * intra_cost) ) * cpi->common.MBs ) << 9;
-
- //return mv_cost + mode_cost;
- // TODO PGW Fix overhead costs for extended Q range
- return 0;
+ FIRSTPASS_STATS *fpstats) {
+ int mv_cost;
+ int mode_cost;
+
+ double av_pct_inter = fpstats->pcnt_inter / fpstats->count;
+ double av_pct_motion = fpstats->pcnt_motion / fpstats->count;
+ double av_intra = (1.0 - av_pct_inter);
+
+ double zz_cost;
+ double motion_cost;
+ double intra_cost;
+
+ zz_cost = bitcost(av_pct_inter - av_pct_motion);
+ motion_cost = bitcost(av_pct_motion);
+ intra_cost = bitcost(av_intra);
+
+ // Estimate of extra bits per mv overhead for mbs
+ // << 9 is the normalization to the (bits * 512) used in vp8_bits_per_mb
+ mv_cost = ((int)(fpstats->new_mv_count / fpstats->count) * 8) << 9;
+
+ // Crude estimate of overhead cost from modes
+ // << 9 is the normalization to (bits * 512) used in vp8_bits_per_mb
+ mode_cost =
+ (int)((((av_pct_inter - av_pct_motion) * zz_cost) +
+ (av_pct_motion * motion_cost) +
+ (av_intra * intra_cost)) * cpi->common.MBs) << 9;
+
+ // return mv_cost + mode_cost;
+ // TODO PGW Fix overhead costs for extended Q range
+ return 0;
}
-static double calc_correction_factor( double err_per_mb,
- double err_divisor,
- double pt_low,
- double pt_high,
- int Q )
-{
- double power_term;
- double error_term = err_per_mb / err_divisor;
- double correction_factor;
+static double calc_correction_factor(double err_per_mb,
+ double err_divisor,
+ double pt_low,
+ double pt_high,
+ int Q) {
+ double power_term;
+ double error_term = err_per_mb / err_divisor;
+ double correction_factor;
- // Adjustment based on actual quantizer to power term.
- power_term = (vp8_convert_qindex_to_q(Q) * 0.01) + pt_low;
- power_term = (power_term > pt_high) ? pt_high : power_term;
+ // Adjustment based on actual quantizer to power term.
+ power_term = (vp8_convert_qindex_to_q(Q) * 0.01) + pt_low;
+ power_term = (power_term > pt_high) ? pt_high : power_term;
- // Adjustments to error term
- // TBD
+ // Adjustments to error term
+ // TBD
- // Calculate correction factor
- correction_factor = pow(error_term, power_term);
+ // Calculate correction factor
+ correction_factor = pow(error_term, power_term);
- // Clip range
- correction_factor =
- (correction_factor < 0.05)
- ? 0.05 : (correction_factor > 2.0) ? 2.0 : correction_factor;
+ // Clip range
+ correction_factor =
+ (correction_factor < 0.05)
+ ? 0.05 : (correction_factor > 2.0) ? 2.0 : correction_factor;
- return correction_factor;
+ return correction_factor;
}
// Given a current maxQ value sets a range for future values.
// PGW TODO..
// This code removes direct dependency on QIndex to determin the range
// (now uses the actual quantizer) but has not been tuned.
-static void adjust_maxq_qrange(VP8_COMP *cpi)
-{
- int i;
- double q;
-
- // Set the max corresponding to cpi->avg_q * 2.0
- q = cpi->avg_q * 2.0;
- cpi->twopass.maxq_max_limit = cpi->worst_quality;
- for ( i = cpi->best_quality; i <= cpi->worst_quality; i++ )
- {
- cpi->twopass.maxq_max_limit = i;
- if ( vp8_convert_qindex_to_q(i) >= q )
- break;
- }
-
- // Set the min corresponding to cpi->avg_q * 0.5
- q = cpi->avg_q * 0.5;
- cpi->twopass.maxq_min_limit = cpi->best_quality;
- for ( i = cpi->worst_quality; i >= cpi->best_quality; i-- )
- {
- cpi->twopass.maxq_min_limit = i;
- if ( vp8_convert_qindex_to_q(i) <= q )
- break;
- }
+static void adjust_maxq_qrange(VP8_COMP *cpi) {
+ int i;
+ double q;
+
+ // Set the max corresponding to cpi->avg_q * 2.0
+ q = cpi->avg_q * 2.0;
+ cpi->twopass.maxq_max_limit = cpi->worst_quality;
+ for (i = cpi->best_quality; i <= cpi->worst_quality; i++) {
+ cpi->twopass.maxq_max_limit = i;
+ if (vp8_convert_qindex_to_q(i) >= q)
+ break;
+ }
+
+ // Set the min corresponding to cpi->avg_q * 0.5
+ q = cpi->avg_q * 0.5;
+ cpi->twopass.maxq_min_limit = cpi->best_quality;
+ for (i = cpi->worst_quality; i >= cpi->best_quality; i--) {
+ cpi->twopass.maxq_min_limit = i;
+ if (vp8_convert_qindex_to_q(i) <= q)
+ break;
+ }
}
static int estimate_max_q(VP8_COMP *cpi,
- FIRSTPASS_STATS * fpstats,
+ FIRSTPASS_STATS *fpstats,
int section_target_bandwitdh,
- int overhead_bits )
-{
- int Q;
- int num_mbs = cpi->common.MBs;
- int target_norm_bits_per_mb;
-
- double section_err = (fpstats->coded_error / fpstats->count);
- double sr_err_diff;
- double sr_correction;
- double err_per_mb = section_err / num_mbs;
- double err_correction_factor;
- double speed_correction = 1.0;
- int overhead_bits_per_mb;
-
- if (section_target_bandwitdh <= 0)
- return cpi->twopass.maxq_max_limit; // Highest value allowed
-
- target_norm_bits_per_mb =
- (section_target_bandwitdh < (1 << 20))
- ? (512 * section_target_bandwitdh) / num_mbs
- : 512 * (section_target_bandwitdh / num_mbs);
-
- // Look at the drop in prediction quality between the last frame
- // and the GF buffer (which contained an older frame).
- sr_err_diff =
- (fpstats->sr_coded_error - fpstats->coded_error) /
- (fpstats->count * cpi->common.MBs);
- sr_correction = (sr_err_diff / 32.0);
- sr_correction = pow( sr_correction, 0.25 );
- if ( sr_correction < 0.75 )
- sr_correction = 0.75;
- else if ( sr_correction > 1.25 )
- sr_correction = 1.25;
-
- // Calculate a corrective factor based on a rolling ratio of bits spent
- // vs target bits
- if ((cpi->rolling_target_bits > 0) &&
- (cpi->active_worst_quality < cpi->worst_quality))
- {
- double rolling_ratio;
-
- rolling_ratio = (double)cpi->rolling_actual_bits /
- (double)cpi->rolling_target_bits;
-
- if (rolling_ratio < 0.95)
- cpi->twopass.est_max_qcorrection_factor -= 0.005;
- else if (rolling_ratio > 1.05)
- cpi->twopass.est_max_qcorrection_factor += 0.005;
-
- cpi->twopass.est_max_qcorrection_factor =
- (cpi->twopass.est_max_qcorrection_factor < 0.1)
- ? 0.1
- : (cpi->twopass.est_max_qcorrection_factor > 10.0)
- ? 10.0 : cpi->twopass.est_max_qcorrection_factor;
- }
-
- // Corrections for higher compression speed settings
- // (reduced compression expected)
- if (cpi->compressor_speed == 1)
- {
- if (cpi->oxcf.cpu_used <= 5)
- speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
- speed_correction = 1.25;
- }
-
- // Estimate of overhead bits per mb
- // Correction to overhead bits for min allowed Q.
+ int overhead_bits) {
+ int Q;
+ int num_mbs = cpi->common.MBs;
+ int target_norm_bits_per_mb;
+
+ double section_err = (fpstats->coded_error / fpstats->count);
+ double sr_err_diff;
+ double sr_correction;
+ double err_per_mb = section_err / num_mbs;
+ double err_correction_factor;
+ double speed_correction = 1.0;
+ int overhead_bits_per_mb;
+
+ if (section_target_bandwitdh <= 0)
+ return cpi->twopass.maxq_max_limit; // Highest value allowed
+
+ target_norm_bits_per_mb =
+ (section_target_bandwitdh < (1 << 20))
+ ? (512 * section_target_bandwitdh) / num_mbs
+ : 512 * (section_target_bandwitdh / num_mbs);
+
+ // Look at the drop in prediction quality between the last frame
+ // and the GF buffer (which contained an older frame).
+ sr_err_diff =
+ (fpstats->sr_coded_error - fpstats->coded_error) /
+ (fpstats->count * cpi->common.MBs);
+ sr_correction = (sr_err_diff / 32.0);
+ sr_correction = pow(sr_correction, 0.25);
+ if (sr_correction < 0.75)
+ sr_correction = 0.75;
+ else if (sr_correction > 1.25)
+ sr_correction = 1.25;
+
+ // Calculate a corrective factor based on a rolling ratio of bits spent
+ // vs target bits
+ if ((cpi->rolling_target_bits > 0) &&
+ (cpi->active_worst_quality < cpi->worst_quality)) {
+ double rolling_ratio;
+
+ rolling_ratio = (double)cpi->rolling_actual_bits /
+ (double)cpi->rolling_target_bits;
+
+ if (rolling_ratio < 0.95)
+ cpi->twopass.est_max_qcorrection_factor -= 0.005;
+ else if (rolling_ratio > 1.05)
+ cpi->twopass.est_max_qcorrection_factor += 0.005;
+
+ cpi->twopass.est_max_qcorrection_factor =
+ (cpi->twopass.est_max_qcorrection_factor < 0.1)
+ ? 0.1
+ : (cpi->twopass.est_max_qcorrection_factor > 10.0)
+ ? 10.0 : cpi->twopass.est_max_qcorrection_factor;
+ }
+
+ // Corrections for higher compression speed settings
+ // (reduced compression expected)
+ if (cpi->compressor_speed == 1) {
+ if (cpi->oxcf.cpu_used <= 5)
+ speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
+ else
+ speed_correction = 1.25;
+ }
+
+ // Estimate of overhead bits per mb
+ // Correction to overhead bits for min allowed Q.
+ // PGW TODO.. This code is broken for the extended Q range
+ // for now overhead set to 0.
+ overhead_bits_per_mb = overhead_bits / num_mbs;
+ overhead_bits_per_mb *= pow(0.98, (double)cpi->twopass.maxq_min_limit);
+
+ // Try and pick a max Q that will be high enough to encode the
+ // content at the given rate.
+ for (Q = cpi->twopass.maxq_min_limit; Q < cpi->twopass.maxq_max_limit; Q++) {
+ int bits_per_mb_at_this_q;
+
+ err_correction_factor =
+ calc_correction_factor(err_per_mb, ERR_DIVISOR, 0.4, 0.90, Q) *
+ sr_correction * speed_correction *
+ cpi->twopass.est_max_qcorrection_factor;
+
+ if (err_correction_factor < 0.05)
+ err_correction_factor = 0.05;
+ else if (err_correction_factor > 5.0)
+ err_correction_factor = 5.0;
+
+ bits_per_mb_at_this_q =
+ vp8_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
+
+ bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
+ (double)bits_per_mb_at_this_q);
+
+ // Mode and motion overhead
+ // As Q rises in real encode loop rd code will force overhead down
+ // We make a crude adjustment for this here as *.98 per Q step.
// PGW TODO.. This code is broken for the extended Q range
// for now overhead set to 0.
- overhead_bits_per_mb = overhead_bits / num_mbs;
- overhead_bits_per_mb *= pow( 0.98, (double)cpi->twopass.maxq_min_limit );
-
- // Try and pick a max Q that will be high enough to encode the
- // content at the given rate.
- for (Q = cpi->twopass.maxq_min_limit; Q < cpi->twopass.maxq_max_limit; Q++)
- {
- int bits_per_mb_at_this_q;
-
- err_correction_factor =
- calc_correction_factor(err_per_mb, ERR_DIVISOR, 0.4, 0.90, Q) *
- sr_correction * speed_correction *
- cpi->twopass.est_max_qcorrection_factor;
-
- if ( err_correction_factor < 0.05 )
- err_correction_factor = 0.05;
- else if ( err_correction_factor > 5.0 )
- err_correction_factor = 5.0;
-
- bits_per_mb_at_this_q =
- vp8_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
-
- bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
- (double)bits_per_mb_at_this_q);
-
- // Mode and motion overhead
- // As Q rises in real encode loop rd code will force overhead down
- // We make a crude adjustment for this here as *.98 per Q step.
- // PGW TODO.. This code is broken for the extended Q range
- // for now overhead set to 0.
- //overhead_bits_per_mb = (int)((double)overhead_bits_per_mb * 0.98);
-
- if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
- break;
- }
-
- // Restriction on active max q for constrained quality mode.
- if ( (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (Q < cpi->cq_target_quality) )
- {
- Q = cpi->cq_target_quality;
- }
-
- // Adjust maxq_min_limit and maxq_max_limit limits based on
- // averaga q observed in clip for non kf/gf/arf frames
- // Give average a chance to settle though.
- // PGW TODO.. This code is broken for the extended Q range
- if ( (cpi->ni_frames >
- ((unsigned int)cpi->twopass.total_stats->count >> 8)) &&
- (cpi->ni_frames > 150) )
- {
- adjust_maxq_qrange( cpi );
- }
-
- return Q;
+ // overhead_bits_per_mb = (int)((double)overhead_bits_per_mb * 0.98);
+
+ if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
+ break;
+ }
+
+ // Restriction on active max q for constrained quality mode.
+ if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ (Q < cpi->cq_target_quality)) {
+ Q = cpi->cq_target_quality;
+ }
+
+ // Adjust maxq_min_limit and maxq_max_limit limits based on
+ // averaga q observed in clip for non kf/gf/arf frames
+ // Give average a chance to settle though.
+ // PGW TODO.. This code is broken for the extended Q range
+ if ((cpi->ni_frames >
+ ((unsigned int)cpi->twopass.total_stats->count >> 8)) &&
+ (cpi->ni_frames > 150)) {
+ adjust_maxq_qrange(cpi);
+ }
+
+ return Q;
}
// For cq mode estimate a cq level that matches the observed
// complexity and data rate.
-static int estimate_cq( VP8_COMP *cpi,
- FIRSTPASS_STATS * fpstats,
- int section_target_bandwitdh,
- int overhead_bits )
-{
- int Q;
- int num_mbs = cpi->common.MBs;
- int target_norm_bits_per_mb;
-
- double section_err = (fpstats->coded_error / fpstats->count);
- double err_per_mb = section_err / num_mbs;
- double err_correction_factor;
- double sr_err_diff;
- double sr_correction;
- double speed_correction = 1.0;
- double clip_iiratio;
- double clip_iifactor;
- int overhead_bits_per_mb;
-
-
- target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20))
- ? (512 * section_target_bandwitdh) / num_mbs
- : 512 * (section_target_bandwitdh / num_mbs);
-
- // Estimate of overhead bits per mb
- overhead_bits_per_mb = overhead_bits / num_mbs;
-
- // Corrections for higher compression speed settings
- // (reduced compression expected)
- if (cpi->compressor_speed == 1)
- {
- if (cpi->oxcf.cpu_used <= 5)
- speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
- speed_correction = 1.25;
- }
+static int estimate_cq(VP8_COMP *cpi,
+ FIRSTPASS_STATS *fpstats,
+ int section_target_bandwitdh,
+ int overhead_bits) {
+ int Q;
+ int num_mbs = cpi->common.MBs;
+ int target_norm_bits_per_mb;
+
+ double section_err = (fpstats->coded_error / fpstats->count);
+ double err_per_mb = section_err / num_mbs;
+ double err_correction_factor;
+ double sr_err_diff;
+ double sr_correction;
+ double speed_correction = 1.0;
+ double clip_iiratio;
+ double clip_iifactor;
+ int overhead_bits_per_mb;
+
+
+ target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20))
+ ? (512 * section_target_bandwitdh) / num_mbs
+ : 512 * (section_target_bandwitdh / num_mbs);
+
+ // Estimate of overhead bits per mb
+ overhead_bits_per_mb = overhead_bits / num_mbs;
+
+ // Corrections for higher compression speed settings
+ // (reduced compression expected)
+ if (cpi->compressor_speed == 1) {
+ if (cpi->oxcf.cpu_used <= 5)
+ speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
+ else
+ speed_correction = 1.25;
+ }
+
+ // Look at the drop in prediction quality between the last frame
+ // and the GF buffer (which contained an older frame).
+ sr_err_diff =
+ (fpstats->sr_coded_error - fpstats->coded_error) /
+ (fpstats->count * cpi->common.MBs);
+ sr_correction = (sr_err_diff / 32.0);
+ sr_correction = pow(sr_correction, 0.25);
+ if (sr_correction < 0.75)
+ sr_correction = 0.75;
+ else if (sr_correction > 1.25)
+ sr_correction = 1.25;
+
+ // II ratio correction factor for clip as a whole
+ clip_iiratio = cpi->twopass.total_stats->intra_error /
+ DOUBLE_DIVIDE_CHECK(cpi->twopass.total_stats->coded_error);
+ clip_iifactor = 1.0 - ((clip_iiratio - 10.0) * 0.025);
+ if (clip_iifactor < 0.80)
+ clip_iifactor = 0.80;
+
+ // Try and pick a Q that can encode the content at the given rate.
+ for (Q = 0; Q < MAXQ; Q++) {
+ int bits_per_mb_at_this_q;
+
+ // Error per MB based correction factor
+ err_correction_factor =
+ calc_correction_factor(err_per_mb, 100.0, 0.4, 0.90, Q) *
+ sr_correction * speed_correction * clip_iifactor;
+
+ if (err_correction_factor < 0.05)
+ err_correction_factor = 0.05;
+ else if (err_correction_factor > 5.0)
+ err_correction_factor = 5.0;
+
+ bits_per_mb_at_this_q =
+ vp8_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
+
+ bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
+ (double)bits_per_mb_at_this_q);
+
+ // Mode and motion overhead
+ // As Q rises in real encode loop rd code will force overhead down
+ // We make a crude adjustment for this here as *.98 per Q step.
+ // PGW TODO.. This code is broken for the extended Q range
+ // for now overhead set to 0.
+ overhead_bits_per_mb = (int)((double)overhead_bits_per_mb * 0.98);
- // Look at the drop in prediction quality between the last frame
- // and the GF buffer (which contained an older frame).
- sr_err_diff =
- (fpstats->sr_coded_error - fpstats->coded_error) /
- (fpstats->count * cpi->common.MBs);
- sr_correction = (sr_err_diff / 32.0);
- sr_correction = pow( sr_correction, 0.25 );
- if ( sr_correction < 0.75 )
- sr_correction = 0.75;
- else if ( sr_correction > 1.25 )
- sr_correction = 1.25;
-
- // II ratio correction factor for clip as a whole
- clip_iiratio = cpi->twopass.total_stats->intra_error /
- DOUBLE_DIVIDE_CHECK(cpi->twopass.total_stats->coded_error);
- clip_iifactor = 1.0 - ((clip_iiratio - 10.0) * 0.025);
- if (clip_iifactor < 0.80)
- clip_iifactor = 0.80;
-
- // Try and pick a Q that can encode the content at the given rate.
- for (Q = 0; Q < MAXQ; Q++)
- {
- int bits_per_mb_at_this_q;
-
- // Error per MB based correction factor
- err_correction_factor =
- calc_correction_factor(err_per_mb, 100.0, 0.4, 0.90, Q) *
- sr_correction * speed_correction * clip_iifactor;
-
- if ( err_correction_factor < 0.05 )
- err_correction_factor = 0.05;
- else if ( err_correction_factor > 5.0 )
- err_correction_factor = 5.0;
-
- bits_per_mb_at_this_q =
- vp8_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
-
- bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
- (double)bits_per_mb_at_this_q);
-
- // Mode and motion overhead
- // As Q rises in real encode loop rd code will force overhead down
- // We make a crude adjustment for this here as *.98 per Q step.
- // PGW TODO.. This code is broken for the extended Q range
- // for now overhead set to 0.
- overhead_bits_per_mb = (int)((double)overhead_bits_per_mb * 0.98);
-
- if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
- break;
- }
+ if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
+ break;
+ }
- // Clip value to range "best allowed to (worst allowed - 1)"
- Q = select_cq_level( Q );
- if ( Q >= cpi->worst_quality )
- Q = cpi->worst_quality - 1;
- if ( Q < cpi->best_quality )
- Q = cpi->best_quality;
+ // Clip value to range "best allowed to (worst allowed - 1)"
+ Q = select_cq_level(Q);
+ if (Q >= cpi->worst_quality)
+ Q = cpi->worst_quality - 1;
+ if (Q < cpi->best_quality)
+ Q = cpi->best_quality;
- return Q;
+ return Q;
}
extern void vp8_new_frame_rate(VP8_COMP *cpi, double framerate);
-void vp8_init_second_pass(VP8_COMP *cpi)
-{
- FIRSTPASS_STATS this_frame;
- FIRSTPASS_STATS *start_pos;
+void vp8_init_second_pass(VP8_COMP *cpi) {
+ FIRSTPASS_STATS this_frame;
+ FIRSTPASS_STATS *start_pos;
- double lower_bounds_min_rate = FRAME_OVERHEAD_BITS*cpi->oxcf.frame_rate;
- double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
- * cpi->oxcf.two_pass_vbrmin_section / 100);
+ double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.frame_rate;
+ double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
+ * cpi->oxcf.two_pass_vbrmin_section / 100);
- if (two_pass_min_rate < lower_bounds_min_rate)
- two_pass_min_rate = lower_bounds_min_rate;
+ if (two_pass_min_rate < lower_bounds_min_rate)
+ two_pass_min_rate = lower_bounds_min_rate;
- zero_stats(cpi->twopass.total_stats);
- zero_stats(cpi->twopass.total_left_stats);
+ zero_stats(cpi->twopass.total_stats);
+ zero_stats(cpi->twopass.total_left_stats);
- if (!cpi->twopass.stats_in_end)
- return;
+ if (!cpi->twopass.stats_in_end)
+ return;
- *cpi->twopass.total_stats = *cpi->twopass.stats_in_end;
- *cpi->twopass.total_left_stats = *cpi->twopass.total_stats;
+ *cpi->twopass.total_stats = *cpi->twopass.stats_in_end;
+ *cpi->twopass.total_left_stats = *cpi->twopass.total_stats;
- // each frame can have a different duration, as the frame rate in the source
- // isn't guaranteed to be constant. The frame rate prior to the first frame
- // encoded in the second pass is a guess. However the sum duration is not.
- // Its calculated based on the actual durations of all frames from the first
- // pass.
- vp8_new_frame_rate(cpi, 10000000.0 * cpi->twopass.total_stats->count / cpi->twopass.total_stats->duration);
+ // each frame can have a different duration, as the frame rate in the source
+ // isn't guaranteed to be constant. The frame rate prior to the first frame
+ // encoded in the second pass is a guess. However the sum duration is not.
+ // Its calculated based on the actual durations of all frames from the first
+ // pass.
+ vp8_new_frame_rate(cpi, 10000000.0 * cpi->twopass.total_stats->count / cpi->twopass.total_stats->duration);
- cpi->output_frame_rate = cpi->oxcf.frame_rate;
- cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats->duration * cpi->oxcf.target_bandwidth / 10000000.0) ;
- cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats->duration * two_pass_min_rate / 10000000.0);
-
- // Calculate a minimum intra value to be used in determining the IIratio
- // scores used in the second pass. We have this minimum to make sure
- // that clips that are static but "low complexity" in the intra domain
- // are still boosted appropriately for KF/GF/ARF
- cpi->twopass.kf_intra_err_min = KF_MB_INTRA_MIN * cpi->common.MBs;
- cpi->twopass.gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs;
-
- // This variable monitors how far behind the second ref update is lagging
- cpi->twopass.sr_update_lag = 1;
+ cpi->output_frame_rate = cpi->oxcf.frame_rate;
+ cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats->duration * cpi->oxcf.target_bandwidth / 10000000.0);
+ cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats->duration * two_pass_min_rate / 10000000.0);
- // Scan the first pass file and calculate an average Intra / Inter error score ratio for the sequence
- {
- double sum_iiratio = 0.0;
- double IIRatio;
+ // Calculate a minimum intra value to be used in determining the IIratio
+ // scores used in the second pass. We have this minimum to make sure
+ // that clips that are static but "low complexity" in the intra domain
+ // are still boosted appropriately for KF/GF/ARF
+ cpi->twopass.kf_intra_err_min = KF_MB_INTRA_MIN * cpi->common.MBs;
+ cpi->twopass.gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs;
- start_pos = cpi->twopass.stats_in; // Note starting "file" position
+ // This variable monitors how far behind the second ref update is lagging
+ cpi->twopass.sr_update_lag = 1;
- while (input_stats(cpi, &this_frame) != EOF)
- {
- IIRatio = this_frame.intra_error / DOUBLE_DIVIDE_CHECK(this_frame.coded_error);
- IIRatio = (IIRatio < 1.0) ? 1.0 : (IIRatio > 20.0) ? 20.0 : IIRatio;
- sum_iiratio += IIRatio;
- }
+ // Scan the first pass file and calculate an average Intra / Inter error score ratio for the sequence
+ {
+ double sum_iiratio = 0.0;
+ double IIRatio;
- cpi->twopass.avg_iiratio = sum_iiratio / DOUBLE_DIVIDE_CHECK((double)cpi->twopass.total_stats->count);
+ start_pos = cpi->twopass.stats_in; // Note starting "file" position
- // Reset file position
- reset_fpf_position(cpi, start_pos);
+ while (input_stats(cpi, &this_frame) != EOF) {
+ IIRatio = this_frame.intra_error / DOUBLE_DIVIDE_CHECK(this_frame.coded_error);
+ IIRatio = (IIRatio < 1.0) ? 1.0 : (IIRatio > 20.0) ? 20.0 : IIRatio;
+ sum_iiratio += IIRatio;
}
- // Scan the first pass file and calculate a modified total error based upon the bias/power function
- // used to allocate bits
- {
- start_pos = cpi->twopass.stats_in; // Note starting "file" position
+ cpi->twopass.avg_iiratio = sum_iiratio / DOUBLE_DIVIDE_CHECK((double)cpi->twopass.total_stats->count);
- cpi->twopass.modified_error_total = 0.0;
- cpi->twopass.modified_error_used = 0.0;
+ // Reset file position
+ reset_fpf_position(cpi, start_pos);
+ }
- while (input_stats(cpi, &this_frame) != EOF)
- {
- cpi->twopass.modified_error_total += calculate_modified_err(cpi, &this_frame);
- }
- cpi->twopass.modified_error_left = cpi->twopass.modified_error_total;
+ // Scan the first pass file and calculate a modified total error based upon the bias/power function
+ // used to allocate bits
+ {
+ start_pos = cpi->twopass.stats_in; // Note starting "file" position
- reset_fpf_position(cpi, start_pos); // Reset file position
+ cpi->twopass.modified_error_total = 0.0;
+ cpi->twopass.modified_error_used = 0.0;
+ while (input_stats(cpi, &this_frame) != EOF) {
+ cpi->twopass.modified_error_total += calculate_modified_err(cpi, &this_frame);
}
+ cpi->twopass.modified_error_left = cpi->twopass.modified_error_total;
+
+ reset_fpf_position(cpi, start_pos); // Reset file position
+
+ }
}
-void vp8_end_second_pass(VP8_COMP *cpi)
-{
+void vp8_end_second_pass(VP8_COMP *cpi) {
}
// This function gives and estimate of how badly we believe
// the prediction quality is decaying from frame to frame.
-static double get_prediction_decay_rate( VP8_COMP *cpi,
- FIRSTPASS_STATS *next_frame)
-{
- double prediction_decay_rate;
- double second_ref_decay;
- double mb_sr_err_diff;
-
- // Initial basis is the % mbs inter coded
- prediction_decay_rate = next_frame->pcnt_inter;
-
- // Look at the observed drop in prediction quality between the last frame
- // and the GF buffer (which contains an older frame).
- mb_sr_err_diff =
- (next_frame->sr_coded_error - next_frame->coded_error) /
- (cpi->common.MBs);
- second_ref_decay = 1.0 - (mb_sr_err_diff / 512.0);
- second_ref_decay = pow( second_ref_decay, 0.5 );
- if ( second_ref_decay < 0.85 )
- second_ref_decay = 0.85;
- else if ( second_ref_decay > 1.0 )
- second_ref_decay = 1.0;
-
- if ( second_ref_decay < prediction_decay_rate )
- prediction_decay_rate = second_ref_decay;
-
- return prediction_decay_rate;
+static double get_prediction_decay_rate(VP8_COMP *cpi,
+ FIRSTPASS_STATS *next_frame) {
+ double prediction_decay_rate;
+ double second_ref_decay;
+ double mb_sr_err_diff;
+
+ // Initial basis is the % mbs inter coded
+ prediction_decay_rate = next_frame->pcnt_inter;
+
+ // Look at the observed drop in prediction quality between the last frame
+ // and the GF buffer (which contains an older frame).
+ mb_sr_err_diff =
+ (next_frame->sr_coded_error - next_frame->coded_error) /
+ (cpi->common.MBs);
+ second_ref_decay = 1.0 - (mb_sr_err_diff / 512.0);
+ second_ref_decay = pow(second_ref_decay, 0.5);
+ if (second_ref_decay < 0.85)
+ second_ref_decay = 0.85;
+ else if (second_ref_decay > 1.0)
+ second_ref_decay = 1.0;
+
+ if (second_ref_decay < prediction_decay_rate)
+ prediction_decay_rate = second_ref_decay;
+
+ return prediction_decay_rate;
}
// Function to test for a condition where a complex transition is followed
// by a static section. For example in slide shows where there is a fade
// between slides. This is to help with more optimal kf and gf positioning.
static int detect_transition_to_still(
- VP8_COMP *cpi,
- int frame_interval,
- int still_interval,
- double loop_decay_rate,
- double last_decay_rate )
-{
- BOOL trans_to_still = FALSE;
-
- // Break clause to detect very still sections after motion
- // For example a static image after a fade or other transition
- // instead of a clean scene cut.
- if ( (frame_interval > MIN_GF_INTERVAL) &&
- (loop_decay_rate >= 0.999) &&
- (last_decay_rate < 0.9) )
- {
- int j;
- FIRSTPASS_STATS * position = cpi->twopass.stats_in;
- FIRSTPASS_STATS tmp_next_frame;
- double zz_inter;
-
- // Look ahead a few frames to see if static condition
- // persists...
- for ( j = 0; j < still_interval; j++ )
- {
- if (EOF == input_stats(cpi, &tmp_next_frame))
- break;
-
- zz_inter =
- (tmp_next_frame.pcnt_inter - tmp_next_frame.pcnt_motion);
- if ( zz_inter < 0.999 )
- break;
- }
- // Reset file position
- reset_fpf_position(cpi, position);
+ VP8_COMP *cpi,
+ int frame_interval,
+ int still_interval,
+ double loop_decay_rate,
+ double last_decay_rate) {
+ BOOL trans_to_still = FALSE;
+
+ // Break clause to detect very still sections after motion
+ // For example a static image after a fade or other transition
+ // instead of a clean scene cut.
+ if ((frame_interval > MIN_GF_INTERVAL) &&
+ (loop_decay_rate >= 0.999) &&
+ (last_decay_rate < 0.9)) {
+ int j;
+ FIRSTPASS_STATS *position = cpi->twopass.stats_in;
+ FIRSTPASS_STATS tmp_next_frame;
+ double zz_inter;
+
+ // Look ahead a few frames to see if static condition
+ // persists...
+ for (j = 0; j < still_interval; j++) {
+ if (EOF == input_stats(cpi, &tmp_next_frame))
+ break;
- // Only if it does do we signal a transition to still
- if ( j == still_interval )
- trans_to_still = TRUE;
+ zz_inter =
+ (tmp_next_frame.pcnt_inter - tmp_next_frame.pcnt_motion);
+ if (zz_inter < 0.999)
+ break;
}
+ // Reset file position
+ reset_fpf_position(cpi, position);
- return trans_to_still;
+ // Only if it does do we signal a transition to still
+ if (j == still_interval)
+ trans_to_still = TRUE;
+ }
+
+ return trans_to_still;
}
// This function detects a flash through the high relative pcnt_second_ref
// score in the frame following a flash frame. The offset passed in should
// reflect this
-static BOOL detect_flash( VP8_COMP *cpi, int offset )
-{
- FIRSTPASS_STATS next_frame;
-
- BOOL flash_detected = FALSE;
-
- // Read the frame data.
- // The return is FALSE (no flash detected) if not a valid frame
- if ( read_frame_stats(cpi, &next_frame, offset) != EOF )
- {
- // What we are looking for here is a situation where there is a
- // brief break in prediction (such as a flash) but subsequent frames
- // are reasonably well predicted by an earlier (pre flash) frame.
- // The recovery after a flash is indicated by a high pcnt_second_ref
- // comapred to pcnt_inter.
- if ( (next_frame.pcnt_second_ref > next_frame.pcnt_inter) &&
- (next_frame.pcnt_second_ref >= 0.5 ) )
- {
- flash_detected = TRUE;
- }
+static BOOL detect_flash(VP8_COMP *cpi, int offset) {
+ FIRSTPASS_STATS next_frame;
+
+ BOOL flash_detected = FALSE;
+
+ // Read the frame data.
+ // The return is FALSE (no flash detected) if not a valid frame
+ if (read_frame_stats(cpi, &next_frame, offset) != EOF) {
+ // What we are looking for here is a situation where there is a
+ // brief break in prediction (such as a flash) but subsequent frames
+ // are reasonably well predicted by an earlier (pre flash) frame.
+ // The recovery after a flash is indicated by a high pcnt_second_ref
+ // comapred to pcnt_inter.
+ if ((next_frame.pcnt_second_ref > next_frame.pcnt_inter) &&
+ (next_frame.pcnt_second_ref >= 0.5)) {
+ flash_detected = TRUE;
}
+ }
- return flash_detected;
+ return flash_detected;
}
// Update the motion related elements to the GF arf boost calculation
static void accumulate_frame_motion_stats(
- VP8_COMP *cpi,
- FIRSTPASS_STATS * this_frame,
- double * this_frame_mv_in_out,
- double * mv_in_out_accumulator,
- double * abs_mv_in_out_accumulator,
- double * mv_ratio_accumulator )
-{
- //double this_frame_mv_in_out;
- double this_frame_mvr_ratio;
- double this_frame_mvc_ratio;
- double motion_pct;
-
- // Accumulate motion stats.
- motion_pct = this_frame->pcnt_motion;
-
- // Accumulate Motion In/Out of frame stats
- *this_frame_mv_in_out = this_frame->mv_in_out_count * motion_pct;
- *mv_in_out_accumulator += this_frame->mv_in_out_count * motion_pct;
- *abs_mv_in_out_accumulator +=
- fabs(this_frame->mv_in_out_count * motion_pct);
-
- // Accumulate a measure of how uniform (or conversely how random)
- // the motion field is. (A ratio of absmv / mv)
- if (motion_pct > 0.05)
- {
- this_frame_mvr_ratio = fabs(this_frame->mvr_abs) /
- DOUBLE_DIVIDE_CHECK(fabs(this_frame->MVr));
-
- this_frame_mvc_ratio = fabs(this_frame->mvc_abs) /
- DOUBLE_DIVIDE_CHECK(fabs(this_frame->MVc));
-
- *mv_ratio_accumulator +=
- (this_frame_mvr_ratio < this_frame->mvr_abs)
- ? (this_frame_mvr_ratio * motion_pct)
- : this_frame->mvr_abs * motion_pct;
-
- *mv_ratio_accumulator +=
- (this_frame_mvc_ratio < this_frame->mvc_abs)
- ? (this_frame_mvc_ratio * motion_pct)
- : this_frame->mvc_abs * motion_pct;
-
- }
+ VP8_COMP *cpi,
+ FIRSTPASS_STATS *this_frame,
+ double *this_frame_mv_in_out,
+ double *mv_in_out_accumulator,
+ double *abs_mv_in_out_accumulator,
+ double *mv_ratio_accumulator) {
+ // double this_frame_mv_in_out;
+ double this_frame_mvr_ratio;
+ double this_frame_mvc_ratio;
+ double motion_pct;
+
+ // Accumulate motion stats.
+ motion_pct = this_frame->pcnt_motion;
+
+ // Accumulate Motion In/Out of frame stats
+ *this_frame_mv_in_out = this_frame->mv_in_out_count * motion_pct;
+ *mv_in_out_accumulator += this_frame->mv_in_out_count * motion_pct;
+ *abs_mv_in_out_accumulator +=
+ fabs(this_frame->mv_in_out_count * motion_pct);
+
+ // Accumulate a measure of how uniform (or conversely how random)
+ // the motion field is. (A ratio of absmv / mv)
+ if (motion_pct > 0.05) {
+ this_frame_mvr_ratio = fabs(this_frame->mvr_abs) /
+ DOUBLE_DIVIDE_CHECK(fabs(this_frame->MVr));
+
+ this_frame_mvc_ratio = fabs(this_frame->mvc_abs) /
+ DOUBLE_DIVIDE_CHECK(fabs(this_frame->MVc));
+
+ *mv_ratio_accumulator +=
+ (this_frame_mvr_ratio < this_frame->mvr_abs)
+ ? (this_frame_mvr_ratio * motion_pct)
+ : this_frame->mvr_abs * motion_pct;
+
+ *mv_ratio_accumulator +=
+ (this_frame_mvc_ratio < this_frame->mvc_abs)
+ ? (this_frame_mvc_ratio * motion_pct)
+ : this_frame->mvc_abs * motion_pct;
+
+ }
}
// Calculate a baseline boost number for the current frame.
static double calc_frame_boost(
- VP8_COMP *cpi,
- FIRSTPASS_STATS * this_frame,
- double this_frame_mv_in_out )
-{
- double frame_boost;
-
- // Underlying boost factor is based on inter intra error ratio
- if (this_frame->intra_error > cpi->twopass.gf_intra_err_min)
- frame_boost = (IIFACTOR * this_frame->intra_error /
- DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
- else
- frame_boost = (IIFACTOR * cpi->twopass.gf_intra_err_min /
- DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
-
- // Increase boost for frames where new data coming into frame
- // (eg zoom out). Slightly reduce boost if there is a net balance
- // of motion out of the frame (zoom in).
- // The range for this_frame_mv_in_out is -1.0 to +1.0
- if (this_frame_mv_in_out > 0.0)
- frame_boost += frame_boost * (this_frame_mv_in_out * 2.0);
- // In extreme case boost is halved
- else
- frame_boost += frame_boost * (this_frame_mv_in_out / 2.0);
-
- // Clip to maximum
- if (frame_boost > GF_RMAX)
- frame_boost = GF_RMAX;
-
- return frame_boost;
+ VP8_COMP *cpi,
+ FIRSTPASS_STATS *this_frame,
+ double this_frame_mv_in_out) {
+ double frame_boost;
+
+ // Underlying boost factor is based on inter intra error ratio
+ if (this_frame->intra_error > cpi->twopass.gf_intra_err_min)
+ frame_boost = (IIFACTOR * this_frame->intra_error /
+ DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
+ else
+ frame_boost = (IIFACTOR * cpi->twopass.gf_intra_err_min /
+ DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
+
+ // Increase boost for frames where new data coming into frame
+ // (eg zoom out). Slightly reduce boost if there is a net balance
+ // of motion out of the frame (zoom in).
+ // The range for this_frame_mv_in_out is -1.0 to +1.0
+ if (this_frame_mv_in_out > 0.0)
+ frame_boost += frame_boost * (this_frame_mv_in_out * 2.0);
+ // In extreme case boost is halved
+ else
+ frame_boost += frame_boost * (this_frame_mv_in_out / 2.0);
+
+ // Clip to maximum
+ if (frame_boost > GF_RMAX)
+ frame_boost = GF_RMAX;
+
+ return frame_boost;
}
static int calc_arf_boost(
- VP8_COMP *cpi,
- int offset,
- int f_frames,
- int b_frames,
- int *f_boost,
- int *b_boost )
-{
- FIRSTPASS_STATS this_frame;
-
- int i;
- double boost_score = 0.0;
- double mv_ratio_accumulator = 0.0;
- double decay_accumulator = 1.0;
- double this_frame_mv_in_out = 0.0;
- double mv_in_out_accumulator = 0.0;
- double abs_mv_in_out_accumulator = 0.0;
- int arf_boost;
- BOOL flash_detected = FALSE;
-
- // Search forward from the proposed arf/next gf position
- for ( i = 0; i < f_frames; i++ )
- {
- if ( read_frame_stats(cpi, &this_frame, (i+offset)) == EOF )
- break;
-
- // Update the motion related elements to the boost calculation
- accumulate_frame_motion_stats( cpi, &this_frame,
- &this_frame_mv_in_out, &mv_in_out_accumulator,
- &abs_mv_in_out_accumulator, &mv_ratio_accumulator );
-
- // We want to discount the the flash frame itself and the recovery
- // frame that follows as both will have poor scores.
- flash_detected = detect_flash(cpi, (i+offset)) ||
- detect_flash(cpi, (i+offset+1));
-
- // Cumulative effect of prediction quality decay
- if ( !flash_detected )
- {
- decay_accumulator =
- decay_accumulator *
- get_prediction_decay_rate(cpi, &this_frame);
- decay_accumulator =
- decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
- }
-
- boost_score += (decay_accumulator *
- calc_frame_boost( cpi, &this_frame, this_frame_mv_in_out ));
+ VP8_COMP *cpi,
+ int offset,
+ int f_frames,
+ int b_frames,
+ int *f_boost,
+ int *b_boost) {
+ FIRSTPASS_STATS this_frame;
+
+ int i;
+ double boost_score = 0.0;
+ double mv_ratio_accumulator = 0.0;
+ double decay_accumulator = 1.0;
+ double this_frame_mv_in_out = 0.0;
+ double mv_in_out_accumulator = 0.0;
+ double abs_mv_in_out_accumulator = 0.0;
+ int arf_boost;
+ BOOL flash_detected = FALSE;
+
+ // Search forward from the proposed arf/next gf position
+ for (i = 0; i < f_frames; i++) {
+ if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF)
+ break;
+
+ // Update the motion related elements to the boost calculation
+ accumulate_frame_motion_stats(cpi, &this_frame,
+ &this_frame_mv_in_out, &mv_in_out_accumulator,
+ &abs_mv_in_out_accumulator, &mv_ratio_accumulator);
+
+ // We want to discount the the flash frame itself and the recovery
+ // frame that follows as both will have poor scores.
+ flash_detected = detect_flash(cpi, (i + offset)) ||
+ detect_flash(cpi, (i + offset + 1));
+
+ // Cumulative effect of prediction quality decay
+ if (!flash_detected) {
+ decay_accumulator =
+ decay_accumulator *
+ get_prediction_decay_rate(cpi, &this_frame);
+ decay_accumulator =
+ decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
}
- *f_boost = boost_score;
-
- // Reset for backward looking loop
- boost_score = 0.0;
- mv_ratio_accumulator = 0.0;
- decay_accumulator = 1.0;
- this_frame_mv_in_out = 0.0;
- mv_in_out_accumulator = 0.0;
- abs_mv_in_out_accumulator = 0.0;
-
- // Search backward towards last gf position
- for ( i = -1; i >= -b_frames; i-- )
- {
- if ( read_frame_stats(cpi, &this_frame, (i+offset)) == EOF )
- break;
-
- // Update the motion related elements to the boost calculation
- accumulate_frame_motion_stats( cpi, &this_frame,
- &this_frame_mv_in_out, &mv_in_out_accumulator,
- &abs_mv_in_out_accumulator, &mv_ratio_accumulator );
-
- // We want to discount the the flash frame itself and the recovery
- // frame that follows as both will have poor scores.
- flash_detected = detect_flash(cpi, (i+offset)) ||
- detect_flash(cpi, (i+offset+1));
-
- // Cumulative effect of prediction quality decay
- if ( !flash_detected )
- {
- decay_accumulator =
- decay_accumulator *
- get_prediction_decay_rate(cpi, &this_frame);
- decay_accumulator =
- decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
- }
+ boost_score += (decay_accumulator *
+ calc_frame_boost(cpi, &this_frame, this_frame_mv_in_out));
+ }
+
+ *f_boost = boost_score;
+
+ // Reset for backward looking loop
+ boost_score = 0.0;
+ mv_ratio_accumulator = 0.0;
+ decay_accumulator = 1.0;
+ this_frame_mv_in_out = 0.0;
+ mv_in_out_accumulator = 0.0;
+ abs_mv_in_out_accumulator = 0.0;
+
+ // Search backward towards last gf position
+ for (i = -1; i >= -b_frames; i--) {
+ if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF)
+ break;
+
+ // Update the motion related elements to the boost calculation
+ accumulate_frame_motion_stats(cpi, &this_frame,
+ &this_frame_mv_in_out, &mv_in_out_accumulator,
+ &abs_mv_in_out_accumulator, &mv_ratio_accumulator);
+
+ // We want to discount the the flash frame itself and the recovery
+ // frame that follows as both will have poor scores.
+ flash_detected = detect_flash(cpi, (i + offset)) ||
+ detect_flash(cpi, (i + offset + 1));
+
+ // Cumulative effect of prediction quality decay
+ if (!flash_detected) {
+ decay_accumulator =
+ decay_accumulator *
+ get_prediction_decay_rate(cpi, &this_frame);
+ decay_accumulator =
+ decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
+ }
- boost_score += (decay_accumulator *
- calc_frame_boost( cpi, &this_frame, this_frame_mv_in_out ));
+ boost_score += (decay_accumulator *
+ calc_frame_boost(cpi, &this_frame, this_frame_mv_in_out));
- }
- *b_boost = boost_score;
+ }
+ *b_boost = boost_score;
- arf_boost = (*f_boost + *b_boost);
- if ( arf_boost < ((b_frames + f_frames) * 20) )
- arf_boost = ((b_frames + f_frames) * 20);
+ arf_boost = (*f_boost + *b_boost);
+ if (arf_boost < ((b_frames + f_frames) * 20))
+ arf_boost = ((b_frames + f_frames) * 20);
- return arf_boost;
+ return arf_boost;
}
-static void configure_arnr_filter( VP8_COMP *cpi, FIRSTPASS_STATS *this_frame )
-{
- int half_gf_int;
- int frames_after_arf;
- int frames_bwd = cpi->oxcf.arnr_max_frames - 1;
- int frames_fwd = cpi->oxcf.arnr_max_frames - 1;
-
- // Define the arnr filter width for this group of frames:
- // We only filter frames that lie within a distance of half
- // the GF interval from the ARF frame. We also have to trap
- // cases where the filter extends beyond the end of clip.
- // Note: this_frame->frame has been updated in the loop
- // so it now points at the ARF frame.
- half_gf_int = cpi->baseline_gf_interval >> 1;
- frames_after_arf = cpi->twopass.total_stats->count -
- this_frame->frame - 1;
-
- switch (cpi->oxcf.arnr_type)
- {
+static void configure_arnr_filter(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
+ int half_gf_int;
+ int frames_after_arf;
+ int frames_bwd = cpi->oxcf.arnr_max_frames - 1;
+ int frames_fwd = cpi->oxcf.arnr_max_frames - 1;
+
+ // Define the arnr filter width for this group of frames:
+ // We only filter frames that lie within a distance of half
+ // the GF interval from the ARF frame. We also have to trap
+ // cases where the filter extends beyond the end of clip.
+ // Note: this_frame->frame has been updated in the loop
+ // so it now points at the ARF frame.
+ half_gf_int = cpi->baseline_gf_interval >> 1;
+ frames_after_arf = cpi->twopass.total_stats->count -
+ this_frame->frame - 1;
+
+ switch (cpi->oxcf.arnr_type) {
case 1: // Backward filter
- frames_fwd = 0;
- if (frames_bwd > half_gf_int)
- frames_bwd = half_gf_int;
- break;
+ frames_fwd = 0;
+ if (frames_bwd > half_gf_int)
+ frames_bwd = half_gf_int;
+ break;
case 2: // Forward filter
- if (frames_fwd > half_gf_int)
- frames_fwd = half_gf_int;
- if (frames_fwd > frames_after_arf)
- frames_fwd = frames_after_arf;
- frames_bwd = 0;
- break;
+ if (frames_fwd > half_gf_int)
+ frames_fwd = half_gf_int;
+ if (frames_fwd > frames_after_arf)
+ frames_fwd = frames_after_arf;
+ frames_bwd = 0;
+ break;
case 3: // Centered filter
default:
- frames_fwd >>= 1;
- if (frames_fwd > frames_after_arf)
- frames_fwd = frames_after_arf;
- if (frames_fwd > half_gf_int)
- frames_fwd = half_gf_int;
-
- frames_bwd = frames_fwd;
-
- // For even length filter there is one more frame backward
- // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
- if (frames_bwd < half_gf_int)
- frames_bwd += (cpi->oxcf.arnr_max_frames+1) & 0x1;
- break;
- }
-
- cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
+ frames_fwd >>= 1;
+ if (frames_fwd > frames_after_arf)
+ frames_fwd = frames_after_arf;
+ if (frames_fwd > half_gf_int)
+ frames_fwd = half_gf_int;
+
+ frames_bwd = frames_fwd;
+
+ // For even length filter there is one more frame backward
+ // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
+ if (frames_bwd < half_gf_int)
+ frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1;
+ break;
+ }
+
+ cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
}
// Analyse and define a gf/arf group .
-static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
-{
- FIRSTPASS_STATS next_frame;
- FIRSTPASS_STATS *start_pos;
- int i;
- double boost_score = 0.0;
- double old_boost_score = 0.0;
- double gf_group_err = 0.0;
- double gf_first_frame_err = 0.0;
- double mod_frame_err = 0.0;
+static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
+ FIRSTPASS_STATS next_frame;
+ FIRSTPASS_STATS *start_pos;
+ int i;
+ double boost_score = 0.0;
+ double old_boost_score = 0.0;
+ double gf_group_err = 0.0;
+ double gf_first_frame_err = 0.0;
+ double mod_frame_err = 0.0;
- double mv_ratio_accumulator = 0.0;
- double decay_accumulator = 1.0;
- double zero_motion_accumulator = 1.0;
+ double mv_ratio_accumulator = 0.0;
+ double decay_accumulator = 1.0;
+ double zero_motion_accumulator = 1.0;
- double loop_decay_rate = 1.00; // Starting decay rate
- double last_loop_decay_rate = 1.00;
+ double loop_decay_rate = 1.00; // Starting decay rate
+ double last_loop_decay_rate = 1.00;
- double this_frame_mv_in_out = 0.0;
- double mv_in_out_accumulator = 0.0;
- double abs_mv_in_out_accumulator = 0.0;
+ double this_frame_mv_in_out = 0.0;
+ double mv_in_out_accumulator = 0.0;
+ double abs_mv_in_out_accumulator = 0.0;
- int max_bits = frame_max_bits(cpi); // Max for a single frame
+ int max_bits = frame_max_bits(cpi); // Max for a single frame
- unsigned int allow_alt_ref =
- cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames;
+ unsigned int allow_alt_ref =
+ cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames;
- int f_boost = 0;
- int b_boost = 0;
- BOOL flash_detected;
+ int f_boost = 0;
+ int b_boost = 0;
+ BOOL flash_detected;
- cpi->twopass.gf_group_bits = 0;
+ cpi->twopass.gf_group_bits = 0;
- vp8_clear_system_state(); //__asm emms;
+ vp8_clear_system_state(); // __asm emms;
- start_pos = cpi->twopass.stats_in;
-
- vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
+ start_pos = cpi->twopass.stats_in;
- // Load stats for the current frame.
- mod_frame_err = calculate_modified_err(cpi, this_frame);
+ vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
- // Note the error of the frame at the start of the group (this will be
- // the GF frame error if we code a normal gf
- gf_first_frame_err = mod_frame_err;
+ // Load stats for the current frame.
+ mod_frame_err = calculate_modified_err(cpi, this_frame);
- // Special treatment if the current frame is a key frame (which is also
- // a gf). If it is then its error score (and hence bit allocation) need
- // to be subtracted out from the calculation for the GF group
- if (cpi->common.frame_type == KEY_FRAME)
- gf_group_err -= gf_first_frame_err;
+ // Note the error of the frame at the start of the group (this will be
+ // the GF frame error if we code a normal gf
+ gf_first_frame_err = mod_frame_err;
- // Scan forward to try and work out how many frames the next gf group
- // should contain and what level of boost is appropriate for the GF
- // or ARF that will be coded with the group
- i = 0;
+ // Special treatment if the current frame is a key frame (which is also
+ // a gf). If it is then its error score (and hence bit allocation) need
+ // to be subtracted out from the calculation for the GF group
+ if (cpi->common.frame_type == KEY_FRAME)
+ gf_group_err -= gf_first_frame_err;
- while (((i < cpi->twopass.static_scene_max_gf_interval) ||
- ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)) &&
- (i < cpi->twopass.frames_to_key))
- {
- i++; // Increment the loop counter
+ // Scan forward to try and work out how many frames the next gf group
+ // should contain and what level of boost is appropriate for the GF
+ // or ARF that will be coded with the group
+ i = 0;
- // Accumulate error score of frames in this gf group
- mod_frame_err = calculate_modified_err(cpi, this_frame);
- gf_group_err += mod_frame_err;
-
- if (EOF == input_stats(cpi, &next_frame))
- break;
-
- // Test for the case where there is a brief flash but the prediction
- // quality back to an earlier frame is then restored.
- flash_detected = detect_flash(cpi, 0);
-
- // Update the motion related elements to the boost calculation
- accumulate_frame_motion_stats( cpi, &next_frame,
- &this_frame_mv_in_out, &mv_in_out_accumulator,
- &abs_mv_in_out_accumulator, &mv_ratio_accumulator );
-
- // Cumulative effect of prediction quality decay
- if ( !flash_detected )
- {
- last_loop_decay_rate = loop_decay_rate;
- loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
- decay_accumulator = decay_accumulator * loop_decay_rate;
-
- // Monitor for static sections.
- if ( (next_frame.pcnt_inter - next_frame.pcnt_motion) <
- zero_motion_accumulator )
- {
- zero_motion_accumulator =
- (next_frame.pcnt_inter - next_frame.pcnt_motion);
- }
+ while (((i < cpi->twopass.static_scene_max_gf_interval) ||
+ ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)) &&
+ (i < cpi->twopass.frames_to_key)) {
+ i++; // Increment the loop counter
- // Break clause to detect very still sections after motion
- // (for example a staic image after a fade or other transition).
- if ( detect_transition_to_still( cpi, i, 5, loop_decay_rate,
- last_loop_decay_rate ) )
- {
- allow_alt_ref = FALSE;
- break;
- }
- }
+ // Accumulate error score of frames in this gf group
+ mod_frame_err = calculate_modified_err(cpi, this_frame);
+ gf_group_err += mod_frame_err;
+
+ if (EOF == input_stats(cpi, &next_frame))
+ break;
+
+ // Test for the case where there is a brief flash but the prediction
+ // quality back to an earlier frame is then restored.
+ flash_detected = detect_flash(cpi, 0);
+
+ // Update the motion related elements to the boost calculation
+ accumulate_frame_motion_stats(cpi, &next_frame,
+ &this_frame_mv_in_out, &mv_in_out_accumulator,
+ &abs_mv_in_out_accumulator, &mv_ratio_accumulator);
+
+ // Cumulative effect of prediction quality decay
+ if (!flash_detected) {
+ last_loop_decay_rate = loop_decay_rate;
+ loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
+ decay_accumulator = decay_accumulator * loop_decay_rate;
+
+ // Monitor for static sections.
+ if ((next_frame.pcnt_inter - next_frame.pcnt_motion) <
+ zero_motion_accumulator) {
+ zero_motion_accumulator =
+ (next_frame.pcnt_inter - next_frame.pcnt_motion);
+ }
+
+ // Break clause to detect very still sections after motion
+ // (for example a staic image after a fade or other transition).
+ if (detect_transition_to_still(cpi, i, 5, loop_decay_rate,
+ last_loop_decay_rate)) {
+ allow_alt_ref = FALSE;
+ break;
+ }
+ }
- // Calculate a boost number for this frame
- boost_score +=
- ( decay_accumulator *
- calc_frame_boost( cpi, &next_frame, this_frame_mv_in_out ) );
-
- // Break out conditions.
- if (
- // Break at cpi->max_gf_interval unless almost totally static
- (i >= cpi->max_gf_interval && (zero_motion_accumulator < 0.995)) ||
- (
- // Dont break out with a very short interval
- (i > MIN_GF_INTERVAL) &&
- // Dont break out very close to a key frame
- ((cpi->twopass.frames_to_key - i) >= MIN_GF_INTERVAL) &&
- ((boost_score > 125.0) || (next_frame.pcnt_inter < 0.75)) &&
- (!flash_detected) &&
- ((mv_ratio_accumulator > 100.0) ||
- (abs_mv_in_out_accumulator > 3.0) ||
- (mv_in_out_accumulator < -2.0) ||
- ((boost_score - old_boost_score) < 12.5))
- ) )
- {
- boost_score = old_boost_score;
- break;
- }
+ // Calculate a boost number for this frame
+ boost_score +=
+ (decay_accumulator *
+ calc_frame_boost(cpi, &next_frame, this_frame_mv_in_out));
+
+ // Break out conditions.
+ if (
+ // Break at cpi->max_gf_interval unless almost totally static
+ (i >= cpi->max_gf_interval && (zero_motion_accumulator < 0.995)) ||
+ (
+ // Dont break out with a very short interval
+ (i > MIN_GF_INTERVAL) &&
+ // Dont break out very close to a key frame
+ ((cpi->twopass.frames_to_key - i) >= MIN_GF_INTERVAL) &&
+ ((boost_score > 125.0) || (next_frame.pcnt_inter < 0.75)) &&
+ (!flash_detected) &&
+ ((mv_ratio_accumulator > 100.0) ||
+ (abs_mv_in_out_accumulator > 3.0) ||
+ (mv_in_out_accumulator < -2.0) ||
+ ((boost_score - old_boost_score) < 12.5))
+ )) {
+ boost_score = old_boost_score;
+ break;
+ }
- vpx_memcpy(this_frame, &next_frame, sizeof(*this_frame));
+ vpx_memcpy(this_frame, &next_frame, sizeof(*this_frame));
- old_boost_score = boost_score;
- }
+ old_boost_score = boost_score;
+ }
- // Dont allow a gf too near the next kf
- if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)
- {
- while (i < cpi->twopass.frames_to_key)
- {
- i++;
+ // Dont allow a gf too near the next kf
+ if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL) {
+ while (i < cpi->twopass.frames_to_key) {
+ i++;
- if (EOF == input_stats(cpi, this_frame))
- break;
+ if (EOF == input_stats(cpi, this_frame))
+ break;
- if (i < cpi->twopass.frames_to_key)
- {
- mod_frame_err = calculate_modified_err(cpi, this_frame);
- gf_group_err += mod_frame_err;
- }
- }
+ if (i < cpi->twopass.frames_to_key) {
+ mod_frame_err = calculate_modified_err(cpi, this_frame);
+ gf_group_err += mod_frame_err;
+ }
}
+ }
+
+ // Set the interval till the next gf or arf.
+ cpi->baseline_gf_interval = i;
+
+ // Should we use the alternate refernce frame
+ if (allow_alt_ref &&
+ (i < cpi->oxcf.lag_in_frames) &&
+ (i >= MIN_GF_INTERVAL) &&
+ // dont use ARF very near next kf
+ (i <= (cpi->twopass.frames_to_key - MIN_GF_INTERVAL)) &&
+ ((next_frame.pcnt_inter > 0.75) ||
+ (next_frame.pcnt_second_ref > 0.5)) &&
+ ((mv_in_out_accumulator / (double)i > -0.2) ||
+ (mv_in_out_accumulator > -2.0)) &&
+ (boost_score > 100)) {
+ // Alterrnative boost calculation for alt ref
+ cpi->gfu_boost = calc_arf_boost(cpi, 0, (i - 1), (i - 1), &f_boost, &b_boost);
+ cpi->source_alt_ref_pending = TRUE;
+
+ configure_arnr_filter(cpi, this_frame);
+ } else {
+ cpi->gfu_boost = (int)boost_score;
+ cpi->source_alt_ref_pending = FALSE;
+ }
+
+ // Now decide how many bits should be allocated to the GF group as a
+ // proportion of those remaining in the kf group.
+ // The final key frame group in the clip is treated as a special case
+ // where cpi->twopass.kf_group_bits is tied to cpi->twopass.bits_left.
+ // This is also important for short clips where there may only be one
+ // key frame.
+ if (cpi->twopass.frames_to_key >= (int)(cpi->twopass.total_stats->count -
+ cpi->common.current_video_frame)) {
+ cpi->twopass.kf_group_bits =
+ (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0;
+ }
+
+ // Calculate the bits to be allocated to the group as a whole
+ if ((cpi->twopass.kf_group_bits > 0) &&
+ (cpi->twopass.kf_group_error_left > 0)) {
+ cpi->twopass.gf_group_bits =
+ (int)((double)cpi->twopass.kf_group_bits *
+ (gf_group_err / (double)cpi->twopass.kf_group_error_left));
+ } else
+ cpi->twopass.gf_group_bits = 0;
- // Set the interval till the next gf or arf.
- cpi->baseline_gf_interval = i;
-
- // Should we use the alternate refernce frame
- if (allow_alt_ref &&
- (i < cpi->oxcf.lag_in_frames ) &&
- (i >= MIN_GF_INTERVAL) &&
- // dont use ARF very near next kf
- (i <= (cpi->twopass.frames_to_key - MIN_GF_INTERVAL)) &&
- ((next_frame.pcnt_inter > 0.75) ||
- (next_frame.pcnt_second_ref > 0.5)) &&
- ((mv_in_out_accumulator / (double)i > -0.2) ||
- (mv_in_out_accumulator > -2.0)) &&
- (boost_score > 100))
- {
- // Alterrnative boost calculation for alt ref
- cpi->gfu_boost = calc_arf_boost( cpi, 0, (i-1), (i-1), &f_boost, &b_boost );
- cpi->source_alt_ref_pending = TRUE;
-
- configure_arnr_filter( cpi, this_frame );
- }
+ cpi->twopass.gf_group_bits =
+ (cpi->twopass.gf_group_bits < 0)
+ ? 0
+ : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits)
+ ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits;
+
+ // Clip cpi->twopass.gf_group_bits based on user supplied data rate
+ // variability limit (cpi->oxcf.two_pass_vbrmax_section)
+ if (cpi->twopass.gf_group_bits > max_bits * cpi->baseline_gf_interval)
+ cpi->twopass.gf_group_bits = max_bits * cpi->baseline_gf_interval;
+
+ // Reset the file position
+ reset_fpf_position(cpi, start_pos);
+
+ // Update the record of error used so far (only done once per gf group)
+ cpi->twopass.modified_error_used += gf_group_err;
+
+ // Assign bits to the arf or gf.
+ for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME); i++) {
+ int boost;
+ int allocation_chunks;
+ int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
+ int gf_bits;
+
+ boost = (cpi->gfu_boost * vp8_gfboost_qadjust(Q)) / 100;
+
+ // Set max and minimum boost and hence minimum allocation
+ if (boost > ((cpi->baseline_gf_interval + 1) * 200))
+ boost = ((cpi->baseline_gf_interval + 1) * 200);
+ else if (boost < 125)
+ boost = 125;
+
+ if (cpi->source_alt_ref_pending && i == 0)
+ allocation_chunks =
+ ((cpi->baseline_gf_interval + 1) * 100) + boost;
else
- {
- cpi->gfu_boost = (int)boost_score;
- cpi->source_alt_ref_pending = FALSE;
+ allocation_chunks =
+ (cpi->baseline_gf_interval * 100) + (boost - 100);
+
+ // Prevent overflow
+ if (boost > 1028) {
+ int divisor = boost >> 10;
+ boost /= divisor;
+ allocation_chunks /= divisor;
}
- // Now decide how many bits should be allocated to the GF group as a
- // proportion of those remaining in the kf group.
- // The final key frame group in the clip is treated as a special case
- // where cpi->twopass.kf_group_bits is tied to cpi->twopass.bits_left.
- // This is also important for short clips where there may only be one
- // key frame.
- if (cpi->twopass.frames_to_key >= (int)(cpi->twopass.total_stats->count -
- cpi->common.current_video_frame))
- {
- cpi->twopass.kf_group_bits =
- (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0;
+ // Calculate the number of bits to be spent on the gf or arf based on
+ // the boost number
+ gf_bits = (int)((double)boost *
+ (cpi->twopass.gf_group_bits /
+ (double)allocation_chunks));
+
+ // If the frame that is to be boosted is simpler than the average for
+ // the gf/arf group then use an alternative calculation
+ // based on the error score of the frame itself
+ if (mod_frame_err < gf_group_err / (double)cpi->baseline_gf_interval) {
+ double alt_gf_grp_bits;
+ int alt_gf_bits;
+
+ alt_gf_grp_bits =
+ (double)cpi->twopass.kf_group_bits *
+ (mod_frame_err * (double)cpi->baseline_gf_interval) /
+ DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left);
+
+ alt_gf_bits = (int)((double)boost * (alt_gf_grp_bits /
+ (double)allocation_chunks));
+
+ if (gf_bits > alt_gf_bits) {
+ gf_bits = alt_gf_bits;
+ }
}
-
- // Calculate the bits to be allocated to the group as a whole
- if ((cpi->twopass.kf_group_bits > 0) &&
- (cpi->twopass.kf_group_error_left > 0))
- {
- cpi->twopass.gf_group_bits =
- (int)((double)cpi->twopass.kf_group_bits *
- (gf_group_err / (double)cpi->twopass.kf_group_error_left));
+ // Else if it is harder than other frames in the group make sure it at
+ // least receives an allocation in keeping with its relative error
+ // score, otherwise it may be worse off than an "un-boosted" frame
+ else {
+ int alt_gf_bits =
+ (int)((double)cpi->twopass.kf_group_bits *
+ mod_frame_err /
+ DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left));
+
+ if (alt_gf_bits > gf_bits) {
+ gf_bits = alt_gf_bits;
+ }
}
- else
- cpi->twopass.gf_group_bits = 0;
-
- cpi->twopass.gf_group_bits =
- (cpi->twopass.gf_group_bits < 0)
- ? 0
- : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits)
- ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits;
-
- // Clip cpi->twopass.gf_group_bits based on user supplied data rate
- // variability limit (cpi->oxcf.two_pass_vbrmax_section)
- if (cpi->twopass.gf_group_bits > max_bits * cpi->baseline_gf_interval)
- cpi->twopass.gf_group_bits = max_bits * cpi->baseline_gf_interval;
-
- // Reset the file position
- reset_fpf_position(cpi, start_pos);
-
- // Update the record of error used so far (only done once per gf group)
- cpi->twopass.modified_error_used += gf_group_err;
-
- // Assign bits to the arf or gf.
- for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME); i++)
- {
- int boost;
- int allocation_chunks;
- int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
- int gf_bits;
-
- boost = (cpi->gfu_boost * vp8_gfboost_qadjust(Q)) / 100;
-
- // Set max and minimum boost and hence minimum allocation
- if (boost > ((cpi->baseline_gf_interval + 1) * 200))
- boost = ((cpi->baseline_gf_interval + 1) * 200);
- else if (boost < 125)
- boost = 125;
-
- if ( cpi->source_alt_ref_pending && i == 0 )
- allocation_chunks =
- ((cpi->baseline_gf_interval + 1) * 100) + boost;
- else
- allocation_chunks =
- (cpi->baseline_gf_interval * 100) + (boost - 100);
-
- // Prevent overflow
- if ( boost > 1028 )
- {
- int divisor = boost >> 10;
- boost/= divisor;
- allocation_chunks /= divisor;
- }
-
- // Calculate the number of bits to be spent on the gf or arf based on
- // the boost number
- gf_bits = (int)((double)boost *
- (cpi->twopass.gf_group_bits /
- (double)allocation_chunks));
-
- // If the frame that is to be boosted is simpler than the average for
- // the gf/arf group then use an alternative calculation
- // based on the error score of the frame itself
- if (mod_frame_err < gf_group_err / (double)cpi->baseline_gf_interval)
- {
- double alt_gf_grp_bits;
- int alt_gf_bits;
-
- alt_gf_grp_bits =
- (double)cpi->twopass.kf_group_bits *
- (mod_frame_err * (double)cpi->baseline_gf_interval) /
- DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left);
-
- alt_gf_bits = (int)((double)boost * (alt_gf_grp_bits /
- (double)allocation_chunks));
-
- if (gf_bits > alt_gf_bits)
- {
- gf_bits = alt_gf_bits;
- }
- }
- // Else if it is harder than other frames in the group make sure it at
- // least receives an allocation in keeping with its relative error
- // score, otherwise it may be worse off than an "un-boosted" frame
- else
- {
- int alt_gf_bits =
- (int)((double)cpi->twopass.kf_group_bits *
- mod_frame_err /
- DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left));
-
- if (alt_gf_bits > gf_bits)
- {
- gf_bits = alt_gf_bits;
- }
- }
- // Dont allow a negative value for gf_bits
- if (gf_bits < 0)
- gf_bits = 0;
+ // Dont allow a negative value for gf_bits
+ if (gf_bits < 0)
+ gf_bits = 0;
- gf_bits += cpi->min_frame_bandwidth; // Add in minimum for a frame
+ gf_bits += cpi->min_frame_bandwidth; // Add in minimum for a frame
- if (i == 0)
- {
- cpi->twopass.gf_bits = gf_bits;
- }
- if (i == 1 || (!cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME)))
- {
- cpi->per_frame_bandwidth = gf_bits; // Per frame bit target for this frame
- }
+ if (i == 0) {
+ cpi->twopass.gf_bits = gf_bits;
}
-
- {
- // Adjust KF group bits and error remainin
- cpi->twopass.kf_group_error_left -= gf_group_err;
- cpi->twopass.kf_group_bits -= cpi->twopass.gf_group_bits;
-
- if (cpi->twopass.kf_group_bits < 0)
- cpi->twopass.kf_group_bits = 0;
-
- // Note the error score left in the remaining frames of the group.
- // For normal GFs we want to remove the error score for the first frame
- // of the group (except in Key frame case where this has already
- // happened)
- if (!cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME)
- cpi->twopass.gf_group_error_left = gf_group_err - gf_first_frame_err;
- else
- cpi->twopass.gf_group_error_left = gf_group_err;
-
- cpi->twopass.gf_group_bits -= cpi->twopass.gf_bits - cpi->min_frame_bandwidth;
-
- if (cpi->twopass.gf_group_bits < 0)
- cpi->twopass.gf_group_bits = 0;
-
- // This condition could fail if there are two kfs very close together
- // despite (MIN_GF_INTERVAL) and would cause a devide by 0 in the
- // calculation of cpi->twopass.alt_extra_bits.
- if ( cpi->baseline_gf_interval >= 3 )
- {
- int boost = (cpi->source_alt_ref_pending)
- ? b_boost : cpi->gfu_boost;
-
- if ( boost >= 150 )
- {
- int pct_extra;
-
- pct_extra = (boost - 100) / 50;
- pct_extra = (pct_extra > 20) ? 20 : pct_extra;
-
- cpi->twopass.alt_extra_bits =
- (cpi->twopass.gf_group_bits * pct_extra) / 100;
- cpi->twopass.gf_group_bits -= cpi->twopass.alt_extra_bits;
- cpi->twopass.alt_extra_bits /=
- ((cpi->baseline_gf_interval-1)>>1);
- }
- else
- cpi->twopass.alt_extra_bits = 0;
- }
- else
- cpi->twopass.alt_extra_bits = 0;
+ if (i == 1 || (!cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME))) {
+ cpi->per_frame_bandwidth = gf_bits; // Per frame bit target for this frame
}
+ }
+
+ {
+ // Adjust KF group bits and error remainin
+ cpi->twopass.kf_group_error_left -= gf_group_err;
+ cpi->twopass.kf_group_bits -= cpi->twopass.gf_group_bits;
+
+ if (cpi->twopass.kf_group_bits < 0)
+ cpi->twopass.kf_group_bits = 0;
+
+ // Note the error score left in the remaining frames of the group.
+ // For normal GFs we want to remove the error score for the first frame
+ // of the group (except in Key frame case where this has already
+ // happened)
+ if (!cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME)
+ cpi->twopass.gf_group_error_left = gf_group_err - gf_first_frame_err;
+ else
+ cpi->twopass.gf_group_error_left = gf_group_err;
- if (cpi->common.frame_type != KEY_FRAME)
- {
- FIRSTPASS_STATS sectionstats;
+ cpi->twopass.gf_group_bits -= cpi->twopass.gf_bits - cpi->min_frame_bandwidth;
- zero_stats(&sectionstats);
- reset_fpf_position(cpi, start_pos);
+ if (cpi->twopass.gf_group_bits < 0)
+ cpi->twopass.gf_group_bits = 0;
+
+ // This condition could fail if there are two kfs very close together
+ // despite (MIN_GF_INTERVAL) and would cause a devide by 0 in the
+ // calculation of cpi->twopass.alt_extra_bits.
+ if (cpi->baseline_gf_interval >= 3) {
+ int boost = (cpi->source_alt_ref_pending)
+ ? b_boost : cpi->gfu_boost;
+
+ if (boost >= 150) {
+ int pct_extra;
+
+ pct_extra = (boost - 100) / 50;
+ pct_extra = (pct_extra > 20) ? 20 : pct_extra;
+
+ cpi->twopass.alt_extra_bits =
+ (cpi->twopass.gf_group_bits * pct_extra) / 100;
+ cpi->twopass.gf_group_bits -= cpi->twopass.alt_extra_bits;
+ cpi->twopass.alt_extra_bits /=
+ ((cpi->baseline_gf_interval - 1) >> 1);
+ } else
+ cpi->twopass.alt_extra_bits = 0;
+ } else
+ cpi->twopass.alt_extra_bits = 0;
+ }
+
+ if (cpi->common.frame_type != KEY_FRAME) {
+ FIRSTPASS_STATS sectionstats;
+
+ zero_stats(&sectionstats);
+ reset_fpf_position(cpi, start_pos);
- for (i = 0 ; i < cpi->baseline_gf_interval ; i++)
- {
- input_stats(cpi, &next_frame);
- accumulate_stats(&sectionstats, &next_frame);
- }
+ for (i = 0; i < cpi->baseline_gf_interval; i++) {
+ input_stats(cpi, &next_frame);
+ accumulate_stats(&sectionstats, &next_frame);
+ }
- avg_stats(&sectionstats);
+ avg_stats(&sectionstats);
- cpi->twopass.section_intra_rating =
- sectionstats.intra_error /
- DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
+ cpi->twopass.section_intra_rating =
+ sectionstats.intra_error /
+ DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
- reset_fpf_position(cpi, start_pos);
- }
+ reset_fpf_position(cpi, start_pos);
+ }
}
// Allocate bits to a normal frame that is neither a gf an arf or a key frame.
-static void assign_std_frame_bits(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
-{
- int target_frame_size; // gf_group_error_left
+static void assign_std_frame_bits(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
+ int target_frame_size; // gf_group_error_left
- double modified_err;
- double err_fraction; // What portion of the remaining GF group error is used by this frame
+ double modified_err;
+ double err_fraction; // What portion of the remaining GF group error is used by this frame
- int max_bits = frame_max_bits(cpi); // Max for a single frame
+ int max_bits = frame_max_bits(cpi); // Max for a single frame
- // Calculate modified prediction error used in bit allocation
- modified_err = calculate_modified_err(cpi, this_frame);
+ // Calculate modified prediction error used in bit allocation
+ modified_err = calculate_modified_err(cpi, this_frame);
- if (cpi->twopass.gf_group_error_left > 0)
- err_fraction = modified_err / cpi->twopass.gf_group_error_left; // What portion of the remaining GF group error is used by this frame
- else
- err_fraction = 0.0;
+ if (cpi->twopass.gf_group_error_left > 0)
+ err_fraction = modified_err / cpi->twopass.gf_group_error_left; // What portion of the remaining GF group error is used by this frame
+ else
+ err_fraction = 0.0;
- target_frame_size = (int)((double)cpi->twopass.gf_group_bits * err_fraction); // How many of those bits available for allocation should we give it?
+ target_frame_size = (int)((double)cpi->twopass.gf_group_bits * err_fraction); // How many of those bits available for allocation should we give it?
- // Clip to target size to 0 - max_bits (or cpi->twopass.gf_group_bits) at the top end.
- if (target_frame_size < 0)
- target_frame_size = 0;
- else
- {
- if (target_frame_size > max_bits)
- target_frame_size = max_bits;
+ // Clip to target size to 0 - max_bits (or cpi->twopass.gf_group_bits) at the top end.
+ if (target_frame_size < 0)
+ target_frame_size = 0;
+ else {
+ if (target_frame_size > max_bits)
+ target_frame_size = max_bits;
- if (target_frame_size > cpi->twopass.gf_group_bits)
- target_frame_size = cpi->twopass.gf_group_bits;
- }
+ if (target_frame_size > cpi->twopass.gf_group_bits)
+ target_frame_size = cpi->twopass.gf_group_bits;
+ }
- cpi->twopass.gf_group_error_left -= modified_err; // Adjust error remaining
- cpi->twopass.gf_group_bits -= target_frame_size; // Adjust bits remaining
+ cpi->twopass.gf_group_error_left -= modified_err; // Adjust error remaining
+ cpi->twopass.gf_group_bits -= target_frame_size; // Adjust bits remaining
- if (cpi->twopass.gf_group_bits < 0)
- cpi->twopass.gf_group_bits = 0;
+ if (cpi->twopass.gf_group_bits < 0)
+ cpi->twopass.gf_group_bits = 0;
- target_frame_size += cpi->min_frame_bandwidth; // Add in the minimum number of bits that is set aside for every frame.
+ target_frame_size += cpi->min_frame_bandwidth; // Add in the minimum number of bits that is set aside for every frame.
- cpi->per_frame_bandwidth = target_frame_size; // Per frame bit target for this frame
+ cpi->per_frame_bandwidth = target_frame_size; // Per frame bit target for this frame
}
// Make a damped adjustment to the active max q.
-int adjust_active_maxq( int old_maxqi, int new_maxqi )
-{
- int i;
- int ret_val = new_maxqi;
- double old_q;
- double new_q;
- double target_q;
-
- old_q = vp8_convert_qindex_to_q( old_maxqi );
- new_q = vp8_convert_qindex_to_q( new_maxqi );
-
- target_q = ((old_q * 7.0) + new_q) / 8.0;
-
- if ( target_q > old_q )
- {
- for ( i = old_maxqi; i <= new_maxqi; i++ )
- {
- if ( vp8_convert_qindex_to_q( i ) >= target_q )
- {
- ret_val = i;
- break;
- }
- }
+int adjust_active_maxq(int old_maxqi, int new_maxqi) {
+ int i;
+ int ret_val = new_maxqi;
+ double old_q;
+ double new_q;
+ double target_q;
+
+ old_q = vp8_convert_qindex_to_q(old_maxqi);
+ new_q = vp8_convert_qindex_to_q(new_maxqi);
+
+ target_q = ((old_q * 7.0) + new_q) / 8.0;
+
+ if (target_q > old_q) {
+ for (i = old_maxqi; i <= new_maxqi; i++) {
+ if (vp8_convert_qindex_to_q(i) >= target_q) {
+ ret_val = i;
+ break;
+ }
}
- else
- {
- for ( i = old_maxqi; i >= new_maxqi; i-- )
- {
- if ( vp8_convert_qindex_to_q( i ) <= target_q )
- {
- ret_val = i;
- break;
- }
- }
+ } else {
+ for (i = old_maxqi; i >= new_maxqi; i--) {
+ if (vp8_convert_qindex_to_q(i) <= target_q) {
+ ret_val = i;
+ break;
+ }
}
+ }
- return ret_val;
+ return ret_val;
}
-void vp8_second_pass(VP8_COMP *cpi)
-{
- int tmp_q;
- int frames_left = (int)(cpi->twopass.total_stats->count - cpi->common.current_video_frame);
+void vp8_second_pass(VP8_COMP *cpi) {
+ int tmp_q;
+ int frames_left = (int)(cpi->twopass.total_stats->count - cpi->common.current_video_frame);
- FIRSTPASS_STATS this_frame;
- FIRSTPASS_STATS this_frame_copy;
+ FIRSTPASS_STATS this_frame;
+ FIRSTPASS_STATS this_frame_copy;
- double this_frame_error;
- double this_frame_intra_error;
- double this_frame_coded_error;
+ double this_frame_error;
+ double this_frame_intra_error;
+ double this_frame_coded_error;
- FIRSTPASS_STATS *start_pos;
+ FIRSTPASS_STATS *start_pos;
- int overhead_bits;
+ int overhead_bits;
- if (!cpi->twopass.stats_in)
- {
- return ;
- }
+ if (!cpi->twopass.stats_in) {
+ return;
+ }
- vp8_clear_system_state();
+ vp8_clear_system_state();
- if (EOF == input_stats(cpi, &this_frame))
- return;
+ if (EOF == input_stats(cpi, &this_frame))
+ return;
- this_frame_error = this_frame.ssim_weighted_pred_err;
- this_frame_intra_error = this_frame.intra_error;
- this_frame_coded_error = this_frame.coded_error;
+ this_frame_error = this_frame.ssim_weighted_pred_err;
+ this_frame_intra_error = this_frame.intra_error;
+ this_frame_coded_error = this_frame.coded_error;
- start_pos = cpi->twopass.stats_in;
+ start_pos = cpi->twopass.stats_in;
- // keyframe and section processing !
- if (cpi->twopass.frames_to_key == 0)
- {
- // Define next KF group and assign bits to it
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- find_next_key_frame(cpi, &this_frame_copy);
- }
+ // keyframe and section processing !
+ if (cpi->twopass.frames_to_key == 0) {
+ // Define next KF group and assign bits to it
+ vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
+ find_next_key_frame(cpi, &this_frame_copy);
+ }
- // Is this a GF / ARF (Note that a KF is always also a GF)
- if (cpi->frames_till_gf_update_due == 0)
- {
- // Define next gf group and assign bits to it
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- define_gf_group(cpi, &this_frame_copy);
-
- // If we are going to code an altref frame at the end of the group and the current frame is not a key frame....
- // If the previous group used an arf this frame has already benefited from that arf boost and it should not be given extra bits
- // If the previous group was NOT coded using arf we may want to apply some boost to this GF as well
- if (cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME))
- {
- // Assign a standard frames worth of bits from those allocated to the GF group
- int bak = cpi->per_frame_bandwidth;
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- assign_std_frame_bits(cpi, &this_frame_copy);
- cpi->per_frame_bandwidth = bak;
- }
- }
+ // Is this a GF / ARF (Note that a KF is always also a GF)
+ if (cpi->frames_till_gf_update_due == 0) {
+ // Define next gf group and assign bits to it
+ vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
+ define_gf_group(cpi, &this_frame_copy);
- // Otherwise this is an ordinary frame
- else
- {
- // Assign bits from those allocated to the GF group
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- assign_std_frame_bits(cpi, &this_frame_copy);
+ // If we are going to code an altref frame at the end of the group and the current frame is not a key frame....
+ // If the previous group used an arf this frame has already benefited from that arf boost and it should not be given extra bits
+ // If the previous group was NOT coded using arf we may want to apply some boost to this GF as well
+ if (cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME)) {
+ // Assign a standard frames worth of bits from those allocated to the GF group
+ int bak = cpi->per_frame_bandwidth;
+ vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
+ assign_std_frame_bits(cpi, &this_frame_copy);
+ cpi->per_frame_bandwidth = bak;
}
-
- // Keep a globally available copy of this and the next frame's iiratio.
- cpi->twopass.this_iiratio = this_frame_intra_error /
- DOUBLE_DIVIDE_CHECK(this_frame_coded_error);
- {
- FIRSTPASS_STATS next_frame;
- if ( lookup_next_frame_stats(cpi, &next_frame) != EOF )
- {
- cpi->twopass.next_iiratio = next_frame.intra_error /
- DOUBLE_DIVIDE_CHECK(next_frame.coded_error);
- }
+ }
+
+ // Otherwise this is an ordinary frame
+ else {
+ // Assign bits from those allocated to the GF group
+ vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
+ assign_std_frame_bits(cpi, &this_frame_copy);
+ }
+
+ // Keep a globally available copy of this and the next frame's iiratio.
+ cpi->twopass.this_iiratio = this_frame_intra_error /
+ DOUBLE_DIVIDE_CHECK(this_frame_coded_error);
+ {
+ FIRSTPASS_STATS next_frame;
+ if (lookup_next_frame_stats(cpi, &next_frame) != EOF) {
+ cpi->twopass.next_iiratio = next_frame.intra_error /
+ DOUBLE_DIVIDE_CHECK(next_frame.coded_error);
}
+ }
- // Set nominal per second bandwidth for this frame
- cpi->target_bandwidth = cpi->per_frame_bandwidth * cpi->output_frame_rate;
- if (cpi->target_bandwidth < 0)
- cpi->target_bandwidth = 0;
-
+ // Set nominal per second bandwidth for this frame
+ cpi->target_bandwidth = cpi->per_frame_bandwidth * cpi->output_frame_rate;
+ if (cpi->target_bandwidth < 0)
+ cpi->target_bandwidth = 0;
- // Account for mv, mode and other overheads.
- overhead_bits = estimate_modemvcost(
- cpi, cpi->twopass.total_left_stats );
- // Special case code for first frame.
- if (cpi->common.current_video_frame == 0)
- {
- cpi->twopass.est_max_qcorrection_factor = 1.0;
+ // Account for mv, mode and other overheads.
+ overhead_bits = estimate_modemvcost(
+ cpi, cpi->twopass.total_left_stats);
- // Set a cq_level in constrained quality mode.
- if ( cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY )
- {
- int est_cq;
+ // Special case code for first frame.
+ if (cpi->common.current_video_frame == 0) {
+ cpi->twopass.est_max_qcorrection_factor = 1.0;
- est_cq =
- estimate_cq( cpi,
- cpi->twopass.total_left_stats,
- (int)(cpi->twopass.bits_left / frames_left),
- overhead_bits );
-
- cpi->cq_target_quality = cpi->oxcf.cq_level;
- if ( est_cq > cpi->cq_target_quality )
- cpi->cq_target_quality = est_cq;
- }
+ // Set a cq_level in constrained quality mode.
+ if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
+ int est_cq;
- // guess at maxq needed in 2nd pass
- cpi->twopass.maxq_max_limit = cpi->worst_quality;
- cpi->twopass.maxq_min_limit = cpi->best_quality;
-
- tmp_q = estimate_max_q(
- cpi,
+ est_cq =
+ estimate_cq(cpi,
cpi->twopass.total_left_stats,
(int)(cpi->twopass.bits_left / frames_left),
- overhead_bits );
-
- cpi->active_worst_quality = tmp_q;
- cpi->ni_av_qi = tmp_q;
- cpi->avg_q = vp8_convert_qindex_to_q( tmp_q );
-
- // Limit the maxq value returned subsequently.
- // This increases the risk of overspend or underspend if the initial
- // estimate for the clip is bad, but helps prevent excessive
- // variation in Q, especially near the end of a clip
- // where for example a small overspend may cause Q to crash
- adjust_maxq_qrange(cpi);
- }
+ overhead_bits);
- // The last few frames of a clip almost always have to few or too many
- // bits and for the sake of over exact rate control we dont want to make
- // radical adjustments to the allowed quantizer range just to use up a
- // few surplus bits or get beneath the target rate.
- else if ( (cpi->common.current_video_frame <
- (((unsigned int)cpi->twopass.total_stats->count * 255)>>8)) &&
- ((cpi->common.current_video_frame + cpi->baseline_gf_interval) <
- (unsigned int)cpi->twopass.total_stats->count) )
- {
- if (frames_left < 1)
- frames_left = 1;
-
- tmp_q = estimate_max_q(
- cpi,
- cpi->twopass.total_left_stats,
- (int)(cpi->twopass.bits_left / frames_left),
- overhead_bits );
-
- // Make a damped adjustment to active max Q
- cpi->active_worst_quality =
- adjust_active_maxq( cpi->active_worst_quality, tmp_q );
+ cpi->cq_target_quality = cpi->oxcf.cq_level;
+ if (est_cq > cpi->cq_target_quality)
+ cpi->cq_target_quality = est_cq;
}
- cpi->twopass.frames_to_key --;
+ // guess at maxq needed in 2nd pass
+ cpi->twopass.maxq_max_limit = cpi->worst_quality;
+ cpi->twopass.maxq_min_limit = cpi->best_quality;
- // Update the total stats remaining sturcture
- subtract_stats(cpi->twopass.total_left_stats, &this_frame );
+ tmp_q = estimate_max_q(
+ cpi,
+ cpi->twopass.total_left_stats,
+ (int)(cpi->twopass.bits_left / frames_left),
+ overhead_bits);
+
+ cpi->active_worst_quality = tmp_q;
+ cpi->ni_av_qi = tmp_q;
+ cpi->avg_q = vp8_convert_qindex_to_q(tmp_q);
+
+ // Limit the maxq value returned subsequently.
+ // This increases the risk of overspend or underspend if the initial
+ // estimate for the clip is bad, but helps prevent excessive
+ // variation in Q, especially near the end of a clip
+ // where for example a small overspend may cause Q to crash
+ adjust_maxq_qrange(cpi);
+ }
+
+ // The last few frames of a clip almost always have to few or too many
+ // bits and for the sake of over exact rate control we dont want to make
+ // radical adjustments to the allowed quantizer range just to use up a
+ // few surplus bits or get beneath the target rate.
+ else if ((cpi->common.current_video_frame <
+ (((unsigned int)cpi->twopass.total_stats->count * 255) >> 8)) &&
+ ((cpi->common.current_video_frame + cpi->baseline_gf_interval) <
+ (unsigned int)cpi->twopass.total_stats->count)) {
+ if (frames_left < 1)
+ frames_left = 1;
+
+ tmp_q = estimate_max_q(
+ cpi,
+ cpi->twopass.total_left_stats,
+ (int)(cpi->twopass.bits_left / frames_left),
+ overhead_bits);
+
+ // Make a damped adjustment to active max Q
+ cpi->active_worst_quality =
+ adjust_active_maxq(cpi->active_worst_quality, tmp_q);
+ }
+
+ cpi->twopass.frames_to_key--;
+
+ // Update the total stats remaining sturcture
+ subtract_stats(cpi->twopass.total_left_stats, &this_frame);
}
-static BOOL test_candidate_kf(VP8_COMP *cpi, FIRSTPASS_STATS *last_frame, FIRSTPASS_STATS *this_frame, FIRSTPASS_STATS *next_frame)
-{
- BOOL is_viable_kf = FALSE;
-
- // Does the frame satisfy the primary criteria of a key frame
- // If so, then examine how well it predicts subsequent frames
- if ((this_frame->pcnt_second_ref < 0.10) &&
- (next_frame->pcnt_second_ref < 0.10) &&
- ((this_frame->pcnt_inter < 0.05) ||
- (
- ((this_frame->pcnt_inter - this_frame->pcnt_neutral) < .35) &&
- ((this_frame->intra_error / DOUBLE_DIVIDE_CHECK(this_frame->coded_error)) < 2.5) &&
- ((fabs(last_frame->coded_error - this_frame->coded_error) / DOUBLE_DIVIDE_CHECK(this_frame->coded_error) > .40) ||
- (fabs(last_frame->intra_error - this_frame->intra_error) / DOUBLE_DIVIDE_CHECK(this_frame->intra_error) > .40) ||
- ((next_frame->intra_error / DOUBLE_DIVIDE_CHECK(next_frame->coded_error)) > 3.5)
- )
+static BOOL test_candidate_kf(VP8_COMP *cpi, FIRSTPASS_STATS *last_frame, FIRSTPASS_STATS *this_frame, FIRSTPASS_STATS *next_frame) {
+ BOOL is_viable_kf = FALSE;
+
+ // Does the frame satisfy the primary criteria of a key frame
+ // If so, then examine how well it predicts subsequent frames
+ if ((this_frame->pcnt_second_ref < 0.10) &&
+ (next_frame->pcnt_second_ref < 0.10) &&
+ ((this_frame->pcnt_inter < 0.05) ||
+ (
+ ((this_frame->pcnt_inter - this_frame->pcnt_neutral) < .35) &&
+ ((this_frame->intra_error / DOUBLE_DIVIDE_CHECK(this_frame->coded_error)) < 2.5) &&
+ ((fabs(last_frame->coded_error - this_frame->coded_error) / DOUBLE_DIVIDE_CHECK(this_frame->coded_error) > .40) ||
+ (fabs(last_frame->intra_error - this_frame->intra_error) / DOUBLE_DIVIDE_CHECK(this_frame->intra_error) > .40) ||
+ ((next_frame->intra_error / DOUBLE_DIVIDE_CHECK(next_frame->coded_error)) > 3.5)
)
- )
)
- {
- int i;
- FIRSTPASS_STATS *start_pos;
-
- FIRSTPASS_STATS local_next_frame;
-
- double boost_score = 0.0;
- double old_boost_score = 0.0;
- double decay_accumulator = 1.0;
- double next_iiratio;
-
- vpx_memcpy(&local_next_frame, next_frame, sizeof(*next_frame));
-
- // Note the starting file position so we can reset to it
- start_pos = cpi->twopass.stats_in;
-
- // Examine how well the key frame predicts subsequent frames
- for (i = 0 ; i < 16; i++)
- {
- next_iiratio = (IIKFACTOR1 * local_next_frame.intra_error / DOUBLE_DIVIDE_CHECK(local_next_frame.coded_error)) ;
-
- if (next_iiratio > RMAX)
- next_iiratio = RMAX;
-
- // Cumulative effect of decay in prediction quality
- if (local_next_frame.pcnt_inter > 0.85)
- decay_accumulator = decay_accumulator * local_next_frame.pcnt_inter;
- else
- decay_accumulator = decay_accumulator * ((0.85 + local_next_frame.pcnt_inter) / 2.0);
-
- //decay_accumulator = decay_accumulator * local_next_frame.pcnt_inter;
-
- // Keep a running total
- boost_score += (decay_accumulator * next_iiratio);
-
- // Test various breakout clauses
- if ((local_next_frame.pcnt_inter < 0.05) ||
- (next_iiratio < 1.5) ||
- (((local_next_frame.pcnt_inter -
- local_next_frame.pcnt_neutral) < 0.20) &&
- (next_iiratio < 3.0)) ||
- ((boost_score - old_boost_score) < 3.0) ||
- (local_next_frame.intra_error < 200)
- )
- {
- break;
- }
+ )
+ ) {
+ int i;
+ FIRSTPASS_STATS *start_pos;
- old_boost_score = boost_score;
+ FIRSTPASS_STATS local_next_frame;
- // Get the next frame details
- if (EOF == input_stats(cpi, &local_next_frame))
- break;
- }
+ double boost_score = 0.0;
+ double old_boost_score = 0.0;
+ double decay_accumulator = 1.0;
+ double next_iiratio;
- // If there is tolerable prediction for at least the next 3 frames then break out else discard this pottential key frame and move on
- if (boost_score > 30.0 && (i > 3))
- is_viable_kf = TRUE;
- else
- {
- // Reset the file position
- reset_fpf_position(cpi, start_pos);
+ vpx_memcpy(&local_next_frame, next_frame, sizeof(*next_frame));
- is_viable_kf = FALSE;
- }
- }
+ // Note the starting file position so we can reset to it
+ start_pos = cpi->twopass.stats_in;
- return is_viable_kf;
-}
-static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
-{
- int i,j;
- FIRSTPASS_STATS last_frame;
- FIRSTPASS_STATS first_frame;
- FIRSTPASS_STATS next_frame;
- FIRSTPASS_STATS *start_position;
+ // Examine how well the key frame predicts subsequent frames
+ for (i = 0; i < 16; i++) {
+ next_iiratio = (IIKFACTOR1 * local_next_frame.intra_error / DOUBLE_DIVIDE_CHECK(local_next_frame.coded_error));
+
+ if (next_iiratio > RMAX)
+ next_iiratio = RMAX;
+
+ // Cumulative effect of decay in prediction quality
+ if (local_next_frame.pcnt_inter > 0.85)
+ decay_accumulator = decay_accumulator * local_next_frame.pcnt_inter;
+ else
+ decay_accumulator = decay_accumulator * ((0.85 + local_next_frame.pcnt_inter) / 2.0);
+
+ // decay_accumulator = decay_accumulator * local_next_frame.pcnt_inter;
+
+ // Keep a running total
+ boost_score += (decay_accumulator * next_iiratio);
+
+ // Test various breakout clauses
+ if ((local_next_frame.pcnt_inter < 0.05) ||
+ (next_iiratio < 1.5) ||
+ (((local_next_frame.pcnt_inter -
+ local_next_frame.pcnt_neutral) < 0.20) &&
+ (next_iiratio < 3.0)) ||
+ ((boost_score - old_boost_score) < 3.0) ||
+ (local_next_frame.intra_error < 200)
+ ) {
+ break;
+ }
- double decay_accumulator = 1.0;
- double zero_motion_accumulator = 1.0;
- double boost_score = 0;
- double old_boost_score = 0.0;
- double loop_decay_rate;
+ old_boost_score = boost_score;
- double kf_mod_err = 0.0;
- double kf_group_err = 0.0;
- double kf_group_intra_err = 0.0;
- double kf_group_coded_err = 0.0;
- double recent_loop_decay[8] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
+ // Get the next frame details
+ if (EOF == input_stats(cpi, &local_next_frame))
+ break;
+ }
- vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
+ // If there is tolerable prediction for at least the next 3 frames then break out else discard this pottential key frame and move on
+ if (boost_score > 30.0 && (i > 3))
+ is_viable_kf = TRUE;
+ else {
+ // Reset the file position
+ reset_fpf_position(cpi, start_pos);
- vp8_clear_system_state(); //__asm emms;
- start_position = cpi->twopass.stats_in;
+ is_viable_kf = FALSE;
+ }
+ }
- cpi->common.frame_type = KEY_FRAME;
+ return is_viable_kf;
+}
+static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
+ int i, j;
+ FIRSTPASS_STATS last_frame;
+ FIRSTPASS_STATS first_frame;
+ FIRSTPASS_STATS next_frame;
+ FIRSTPASS_STATS *start_position;
- // is this a forced key frame by interval
- cpi->this_key_frame_forced = cpi->next_key_frame_forced;
+ double decay_accumulator = 1.0;
+ double zero_motion_accumulator = 1.0;
+ double boost_score = 0;
+ double old_boost_score = 0.0;
+ double loop_decay_rate;
- // Clear the alt ref active flag as this can never be active on a key frame
- cpi->source_alt_ref_active = FALSE;
+ double kf_mod_err = 0.0;
+ double kf_group_err = 0.0;
+ double kf_group_intra_err = 0.0;
+ double kf_group_coded_err = 0.0;
+ double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
- // Kf is always a gf so clear frames till next gf counter
- cpi->frames_till_gf_update_due = 0;
+ vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
- cpi->twopass.frames_to_key = 1;
+ vp8_clear_system_state(); // __asm emms;
+ start_position = cpi->twopass.stats_in;
- // Take a copy of the initial frame details
- vpx_memcpy(&first_frame, this_frame, sizeof(*this_frame));
+ cpi->common.frame_type = KEY_FRAME;
- cpi->twopass.kf_group_bits = 0; // Total bits avaialable to kf group
- cpi->twopass.kf_group_error_left = 0; // Group modified error score.
+ // is this a forced key frame by interval
+ cpi->this_key_frame_forced = cpi->next_key_frame_forced;
- kf_mod_err = calculate_modified_err(cpi, this_frame);
+ // Clear the alt ref active flag as this can never be active on a key frame
+ cpi->source_alt_ref_active = FALSE;
- // find the next keyframe
- i = 0;
- while (cpi->twopass.stats_in < cpi->twopass.stats_in_end)
- {
- // Accumulate kf group error
- kf_group_err += calculate_modified_err(cpi, this_frame);
+ // Kf is always a gf so clear frames till next gf counter
+ cpi->frames_till_gf_update_due = 0;
- // These figures keep intra and coded error counts for all frames including key frames in the group.
- // The effect of the key frame itself can be subtracted out using the first_frame data collected above
- kf_group_intra_err += this_frame->intra_error;
- kf_group_coded_err += this_frame->coded_error;
+ cpi->twopass.frames_to_key = 1;
- // load a the next frame's stats
- vpx_memcpy(&last_frame, this_frame, sizeof(*this_frame));
- input_stats(cpi, this_frame);
+ // Take a copy of the initial frame details
+ vpx_memcpy(&first_frame, this_frame, sizeof(*this_frame));
- // Provided that we are not at the end of the file...
- if (cpi->oxcf.auto_key
- && lookup_next_frame_stats(cpi, &next_frame) != EOF)
- {
- // Normal scene cut check
- if ( test_candidate_kf(cpi, &last_frame, this_frame, &next_frame) )
- {
- break;
- }
+ cpi->twopass.kf_group_bits = 0; // Total bits avaialable to kf group
+ cpi->twopass.kf_group_error_left = 0; // Group modified error score.
- // How fast is prediction quality decaying
- loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
-
- // We want to know something about the recent past... rather than
- // as used elsewhere where we are concened with decay in prediction
- // quality since the last GF or KF.
- recent_loop_decay[i%8] = loop_decay_rate;
- decay_accumulator = 1.0;
- for (j = 0; j < 8; j++)
- {
- decay_accumulator = decay_accumulator * recent_loop_decay[j];
- }
+ kf_mod_err = calculate_modified_err(cpi, this_frame);
- // Special check for transition or high motion followed by a
- // to a static scene.
- if ( detect_transition_to_still( cpi, i,
- (cpi->key_frame_frequency-i),
- loop_decay_rate,
- decay_accumulator ) )
- {
- break;
- }
+ // find the next keyframe
+ i = 0;
+ while (cpi->twopass.stats_in < cpi->twopass.stats_in_end) {
+ // Accumulate kf group error
+ kf_group_err += calculate_modified_err(cpi, this_frame);
+ // These figures keep intra and coded error counts for all frames including key frames in the group.
+ // The effect of the key frame itself can be subtracted out using the first_frame data collected above
+ kf_group_intra_err += this_frame->intra_error;
+ kf_group_coded_err += this_frame->coded_error;
- // Step on to the next frame
- cpi->twopass.frames_to_key ++;
+ // load a the next frame's stats
+ vpx_memcpy(&last_frame, this_frame, sizeof(*this_frame));
+ input_stats(cpi, this_frame);
- // If we don't have a real key frame within the next two
- // forcekeyframeevery intervals then break out of the loop.
- if (cpi->twopass.frames_to_key >= 2 *(int)cpi->key_frame_frequency)
- break;
- } else
- cpi->twopass.frames_to_key ++;
+ // Provided that we are not at the end of the file...
+ if (cpi->oxcf.auto_key
+ && lookup_next_frame_stats(cpi, &next_frame) != EOF) {
+ // Normal scene cut check
+ if (test_candidate_kf(cpi, &last_frame, this_frame, &next_frame)) {
+ break;
+ }
+
+ // How fast is prediction quality decaying
+ loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
+
+ // We want to know something about the recent past... rather than
+ // as used elsewhere where we are concened with decay in prediction
+ // quality since the last GF or KF.
+ recent_loop_decay[i % 8] = loop_decay_rate;
+ decay_accumulator = 1.0;
+ for (j = 0; j < 8; j++) {
+ decay_accumulator = decay_accumulator * recent_loop_decay[j];
+ }
+
+ // Special check for transition or high motion followed by a
+ // to a static scene.
+ if (detect_transition_to_still(cpi, i,
+ (cpi->key_frame_frequency - i),
+ loop_decay_rate,
+ decay_accumulator)) {
+ break;
+ }
- i++;
- }
- // If there is a max kf interval set by the user we must obey it.
- // We already breakout of the loop above at 2x max.
- // This code centers the extra kf if the actual natural
- // interval is between 1x and 2x
- if (cpi->oxcf.auto_key
- && cpi->twopass.frames_to_key > (int)cpi->key_frame_frequency )
- {
- FIRSTPASS_STATS *current_pos = cpi->twopass.stats_in;
- FIRSTPASS_STATS tmp_frame;
+ // Step on to the next frame
+ cpi->twopass.frames_to_key++;
- cpi->twopass.frames_to_key /= 2;
+ // If we don't have a real key frame within the next two
+ // forcekeyframeevery intervals then break out of the loop.
+ if (cpi->twopass.frames_to_key >= 2 * (int)cpi->key_frame_frequency)
+ break;
+ } else
+ cpi->twopass.frames_to_key++;
- // Copy first frame details
- vpx_memcpy(&tmp_frame, &first_frame, sizeof(first_frame));
+ i++;
+ }
- // Reset to the start of the group
- reset_fpf_position(cpi, start_position);
+ // If there is a max kf interval set by the user we must obey it.
+ // We already breakout of the loop above at 2x max.
+ // This code centers the extra kf if the actual natural
+ // interval is between 1x and 2x
+ if (cpi->oxcf.auto_key
+ && cpi->twopass.frames_to_key > (int)cpi->key_frame_frequency) {
+ FIRSTPASS_STATS *current_pos = cpi->twopass.stats_in;
+ FIRSTPASS_STATS tmp_frame;
- kf_group_err = 0;
- kf_group_intra_err = 0;
- kf_group_coded_err = 0;
+ cpi->twopass.frames_to_key /= 2;
- // Rescan to get the correct error data for the forced kf group
- for( i = 0; i < cpi->twopass.frames_to_key; i++ )
- {
- // Accumulate kf group errors
- kf_group_err += calculate_modified_err(cpi, &tmp_frame);
- kf_group_intra_err += tmp_frame.intra_error;
- kf_group_coded_err += tmp_frame.coded_error;
+ // Copy first frame details
+ vpx_memcpy(&tmp_frame, &first_frame, sizeof(first_frame));
- // Load a the next frame's stats
- input_stats(cpi, &tmp_frame);
- }
+ // Reset to the start of the group
+ reset_fpf_position(cpi, start_position);
+
+ kf_group_err = 0;
+ kf_group_intra_err = 0;
+ kf_group_coded_err = 0;
- // Reset to the start of the group
- reset_fpf_position(cpi, current_pos);
+ // Rescan to get the correct error data for the forced kf group
+ for (i = 0; i < cpi->twopass.frames_to_key; i++) {
+ // Accumulate kf group errors
+ kf_group_err += calculate_modified_err(cpi, &tmp_frame);
+ kf_group_intra_err += tmp_frame.intra_error;
+ kf_group_coded_err += tmp_frame.coded_error;
- cpi->next_key_frame_forced = TRUE;
+ // Load a the next frame's stats
+ input_stats(cpi, &tmp_frame);
}
+
+ // Reset to the start of the group
+ reset_fpf_position(cpi, current_pos);
+
+ cpi->next_key_frame_forced = TRUE;
+ } else
+ cpi->next_key_frame_forced = FALSE;
+
+ // Special case for the last frame of the file
+ if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end) {
+ // Accumulate kf group error
+ kf_group_err += calculate_modified_err(cpi, this_frame);
+
+ // These figures keep intra and coded error counts for all frames including key frames in the group.
+ // The effect of the key frame itself can be subtracted out using the first_frame data collected above
+ kf_group_intra_err += this_frame->intra_error;
+ kf_group_coded_err += this_frame->coded_error;
+ }
+
+ // Calculate the number of bits that should be assigned to the kf group.
+ if ((cpi->twopass.bits_left > 0) && (cpi->twopass.modified_error_left > 0.0)) {
+ // Max for a single normal frame (not key frame)
+ int max_bits = frame_max_bits(cpi);
+
+ // Maximum bits for the kf group
+ int64_t max_grp_bits;
+
+ // Default allocation based on bits left and relative
+ // complexity of the section
+ cpi->twopass.kf_group_bits = (int64_t)(cpi->twopass.bits_left *
+ (kf_group_err /
+ cpi->twopass.modified_error_left));
+
+ // Clip based on maximum per frame rate defined by the user.
+ max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key;
+ if (cpi->twopass.kf_group_bits > max_grp_bits)
+ cpi->twopass.kf_group_bits = max_grp_bits;
+ } else
+ cpi->twopass.kf_group_bits = 0;
+
+ // Reset the first pass file position
+ reset_fpf_position(cpi, start_position);
+
+ // determine how big to make this keyframe based on how well the subsequent frames use inter blocks
+ decay_accumulator = 1.0;
+ boost_score = 0.0;
+ loop_decay_rate = 1.00; // Starting decay rate
+
+ for (i = 0; i < cpi->twopass.frames_to_key; i++) {
+ double r;
+
+ if (EOF == input_stats(cpi, &next_frame))
+ break;
+
+ if (next_frame.intra_error > cpi->twopass.kf_intra_err_min)
+ r = (IIKFACTOR2 * next_frame.intra_error /
+ DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
else
- cpi->next_key_frame_forced = FALSE;
-
- // Special case for the last frame of the file
- if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
- {
- // Accumulate kf group error
- kf_group_err += calculate_modified_err(cpi, this_frame);
-
- // These figures keep intra and coded error counts for all frames including key frames in the group.
- // The effect of the key frame itself can be subtracted out using the first_frame data collected above
- kf_group_intra_err += this_frame->intra_error;
- kf_group_coded_err += this_frame->coded_error;
+ r = (IIKFACTOR2 * cpi->twopass.kf_intra_err_min /
+ DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
+
+ if (r > RMAX)
+ r = RMAX;
+
+ // Monitor for static sections.
+ if ((next_frame.pcnt_inter - next_frame.pcnt_motion) <
+ zero_motion_accumulator) {
+ zero_motion_accumulator =
+ (next_frame.pcnt_inter - next_frame.pcnt_motion);
}
- // Calculate the number of bits that should be assigned to the kf group.
- if ((cpi->twopass.bits_left > 0) && (cpi->twopass.modified_error_left > 0.0))
- {
- // Max for a single normal frame (not key frame)
- int max_bits = frame_max_bits(cpi);
-
- // Maximum bits for the kf group
- int64_t max_grp_bits;
-
- // Default allocation based on bits left and relative
- // complexity of the section
- cpi->twopass.kf_group_bits = (int64_t)( cpi->twopass.bits_left *
- ( kf_group_err /
- cpi->twopass.modified_error_left ));
-
- // Clip based on maximum per frame rate defined by the user.
- max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key;
- if (cpi->twopass.kf_group_bits > max_grp_bits)
- cpi->twopass.kf_group_bits = max_grp_bits;
+ // How fast is prediction quality decaying
+ if (!detect_flash(cpi, 0)) {
+ loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
+ decay_accumulator = decay_accumulator * loop_decay_rate;
+ decay_accumulator = decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
}
- else
- cpi->twopass.kf_group_bits = 0;
- // Reset the first pass file position
- reset_fpf_position(cpi, start_position);
+ boost_score += (decay_accumulator * r);
- // determine how big to make this keyframe based on how well the subsequent frames use inter blocks
- decay_accumulator = 1.0;
- boost_score = 0.0;
- loop_decay_rate = 1.00; // Starting decay rate
-
- for (i = 0 ; i < cpi->twopass.frames_to_key ; i++)
- {
- double r;
-
- if (EOF == input_stats(cpi, &next_frame))
- break;
-
- if (next_frame.intra_error > cpi->twopass.kf_intra_err_min)
- r = (IIKFACTOR2 * next_frame.intra_error /
- DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
- else
- r = (IIKFACTOR2 * cpi->twopass.kf_intra_err_min /
- DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
-
- if (r > RMAX)
- r = RMAX;
-
- // Monitor for static sections.
- if ( (next_frame.pcnt_inter - next_frame.pcnt_motion) <
- zero_motion_accumulator )
- {
- zero_motion_accumulator =
- (next_frame.pcnt_inter - next_frame.pcnt_motion);
- }
+ if ((i > MIN_GF_INTERVAL) &&
+ ((boost_score - old_boost_score) < 6.25)) {
+ break;
+ }
- // How fast is prediction quality decaying
- if ( !detect_flash(cpi, 0) )
- {
- loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
- decay_accumulator = decay_accumulator * loop_decay_rate;
- decay_accumulator = decay_accumulator < 0.1 ? 0.1 : decay_accumulator;
- }
+ old_boost_score = boost_score;
+ }
- boost_score += (decay_accumulator * r);
+ {
+ FIRSTPASS_STATS sectionstats;
- if ((i > MIN_GF_INTERVAL) &&
- ((boost_score - old_boost_score) < 6.25))
- {
- break;
- }
+ zero_stats(&sectionstats);
+ reset_fpf_position(cpi, start_position);
- old_boost_score = boost_score;
+ for (i = 0; i < cpi->twopass.frames_to_key; i++) {
+ input_stats(cpi, &next_frame);
+ accumulate_stats(&sectionstats, &next_frame);
}
- {
- FIRSTPASS_STATS sectionstats;
+ avg_stats(&sectionstats);
- zero_stats(&sectionstats);
- reset_fpf_position(cpi, start_position);
+ cpi->twopass.section_intra_rating =
+ sectionstats.intra_error
+ / DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
+ }
- for (i = 0 ; i < cpi->twopass.frames_to_key ; i++)
- {
- input_stats(cpi, &next_frame);
- accumulate_stats(&sectionstats, &next_frame);
- }
+ // Reset the first pass file position
+ reset_fpf_position(cpi, start_position);
- avg_stats(&sectionstats);
+ // Work out how many bits to allocate for the key frame itself
+ if (1) {
+ int kf_boost = boost_score;
+ int allocation_chunks;
+ int alt_kf_bits;
- cpi->twopass.section_intra_rating =
- sectionstats.intra_error
- / DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
+ if (kf_boost < 300) {
+ kf_boost += (cpi->twopass.frames_to_key * 3);
+ if (kf_boost > 300)
+ kf_boost = 300;
}
- // Reset the first pass file position
- reset_fpf_position(cpi, start_position);
-
- // Work out how many bits to allocate for the key frame itself
- if (1)
- {
- int kf_boost = boost_score;
- int allocation_chunks;
- int alt_kf_bits;
-
- if ( kf_boost < 300 )
- {
- kf_boost += (cpi->twopass.frames_to_key * 3);
- if ( kf_boost > 300 )
- kf_boost = 300;
- }
-
- if (kf_boost < 250) // Min KF boost
- kf_boost = 250;
-
- // Make a note of baseline boost and the zero motion
- // accumulator value for use elsewhere.
- cpi->kf_boost = kf_boost;
- cpi->kf_zeromotion_pct = (int)(zero_motion_accumulator * 100.0);
-
- // We do three calculations for kf size.
- // The first is based on the error score for the whole kf group.
- // The second (optionaly) on the key frames own error if this is
- // smaller than the average for the group.
- // The final one insures that the frame receives at least the
- // allocation it would have received based on its own error score vs
- // the error score remaining
- // Special case if the sequence appears almost totaly static
- // In this case we want to spend almost all of the bits on the
- // key frame.
- // cpi->twopass.frames_to_key-1 because key frame itself is taken
- // care of by kf_boost.
- if ( zero_motion_accumulator >= 0.99 )
- {
- allocation_chunks =
- ((cpi->twopass.frames_to_key - 1) * 10) + kf_boost;
- }
- else
- {
- allocation_chunks =
- ((cpi->twopass.frames_to_key - 1) * 100) + kf_boost;
- }
+ if (kf_boost < 250) // Min KF boost
+ kf_boost = 250;
+
+ // Make a note of baseline boost and the zero motion
+ // accumulator value for use elsewhere.
+ cpi->kf_boost = kf_boost;
+ cpi->kf_zeromotion_pct = (int)(zero_motion_accumulator * 100.0);
+
+ // We do three calculations for kf size.
+ // The first is based on the error score for the whole kf group.
+ // The second (optionaly) on the key frames own error if this is
+ // smaller than the average for the group.
+ // The final one insures that the frame receives at least the
+ // allocation it would have received based on its own error score vs
+ // the error score remaining
+ // Special case if the sequence appears almost totaly static
+ // In this case we want to spend almost all of the bits on the
+ // key frame.
+ // cpi->twopass.frames_to_key-1 because key frame itself is taken
+ // care of by kf_boost.
+ if (zero_motion_accumulator >= 0.99) {
+ allocation_chunks =
+ ((cpi->twopass.frames_to_key - 1) * 10) + kf_boost;
+ } else {
+ allocation_chunks =
+ ((cpi->twopass.frames_to_key - 1) * 100) + kf_boost;
+ }
- // Prevent overflow
- if ( kf_boost > 1028 )
- {
- int divisor = kf_boost >> 10;
- kf_boost /= divisor;
- allocation_chunks /= divisor;
- }
+ // Prevent overflow
+ if (kf_boost > 1028) {
+ int divisor = kf_boost >> 10;
+ kf_boost /= divisor;
+ allocation_chunks /= divisor;
+ }
- cpi->twopass.kf_group_bits = (cpi->twopass.kf_group_bits < 0) ? 0 : cpi->twopass.kf_group_bits;
+ cpi->twopass.kf_group_bits = (cpi->twopass.kf_group_bits < 0) ? 0 : cpi->twopass.kf_group_bits;
- // Calculate the number of bits to be spent on the key frame
- cpi->twopass.kf_bits = (int)((double)kf_boost * ((double)cpi->twopass.kf_group_bits / (double)allocation_chunks));
+ // Calculate the number of bits to be spent on the key frame
+ cpi->twopass.kf_bits = (int)((double)kf_boost * ((double)cpi->twopass.kf_group_bits / (double)allocation_chunks));
- // If the key frame is actually easier than the average for the
- // kf group (which does sometimes happen... eg a blank intro frame)
- // Then use an alternate calculation based on the kf error score
- // which should give a smaller key frame.
- if (kf_mod_err < kf_group_err / cpi->twopass.frames_to_key)
- {
- double alt_kf_grp_bits =
- ((double)cpi->twopass.bits_left *
- (kf_mod_err * (double)cpi->twopass.frames_to_key) /
- DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left));
+ // If the key frame is actually easier than the average for the
+ // kf group (which does sometimes happen... eg a blank intro frame)
+ // Then use an alternate calculation based on the kf error score
+ // which should give a smaller key frame.
+ if (kf_mod_err < kf_group_err / cpi->twopass.frames_to_key) {
+ double alt_kf_grp_bits =
+ ((double)cpi->twopass.bits_left *
+ (kf_mod_err * (double)cpi->twopass.frames_to_key) /
+ DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left));
- alt_kf_bits = (int)((double)kf_boost *
- (alt_kf_grp_bits / (double)allocation_chunks));
+ alt_kf_bits = (int)((double)kf_boost *
+ (alt_kf_grp_bits / (double)allocation_chunks));
- if (cpi->twopass.kf_bits > alt_kf_bits)
- {
- cpi->twopass.kf_bits = alt_kf_bits;
- }
- }
- // Else if it is much harder than other frames in the group make sure
- // it at least receives an allocation in keeping with its relative
- // error score
- else
- {
- alt_kf_bits =
- (int)((double)cpi->twopass.bits_left *
- (kf_mod_err /
- DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left)));
-
- if (alt_kf_bits > cpi->twopass.kf_bits)
- {
- cpi->twopass.kf_bits = alt_kf_bits;
- }
- }
+ if (cpi->twopass.kf_bits > alt_kf_bits) {
+ cpi->twopass.kf_bits = alt_kf_bits;
+ }
+ }
+ // Else if it is much harder than other frames in the group make sure
+ // it at least receives an allocation in keeping with its relative
+ // error score
+ else {
+ alt_kf_bits =
+ (int)((double)cpi->twopass.bits_left *
+ (kf_mod_err /
+ DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left)));
+
+ if (alt_kf_bits > cpi->twopass.kf_bits) {
+ cpi->twopass.kf_bits = alt_kf_bits;
+ }
+ }
- cpi->twopass.kf_group_bits -= cpi->twopass.kf_bits;
- cpi->twopass.kf_bits += cpi->min_frame_bandwidth; // Add in the minimum frame allowance
+ cpi->twopass.kf_group_bits -= cpi->twopass.kf_bits;
+ cpi->twopass.kf_bits += cpi->min_frame_bandwidth; // Add in the minimum frame allowance
- cpi->per_frame_bandwidth = cpi->twopass.kf_bits; // Peer frame bit target for this frame
- cpi->target_bandwidth = cpi->twopass.kf_bits * cpi->output_frame_rate; // Convert to a per second bitrate
- }
+ cpi->per_frame_bandwidth = cpi->twopass.kf_bits; // Peer frame bit target for this frame
+ cpi->target_bandwidth = cpi->twopass.kf_bits * cpi->output_frame_rate; // Convert to a per second bitrate
+ }
- // Note the total error score of the kf group minus the key frame itself
- cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err);
+ // Note the total error score of the kf group minus the key frame itself
+ cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err);
- // Adjust the count of total modified error left.
- // The count of bits left is adjusted elsewhere based on real coded frame sizes
- cpi->twopass.modified_error_left -= kf_group_err;
+ // Adjust the count of total modified error left.
+ // The count of bits left is adjusted elsewhere based on real coded frame sizes
+ cpi->twopass.modified_error_left -= kf_group_err;
}
diff --git a/vp8/encoder/generic/csystemdependent.c b/vp8/encoder/generic/csystemdependent.c
index 59b30a762..695e9c69b 100644
--- a/vp8/encoder/generic/csystemdependent.c
+++ b/vp8/encoder/generic/csystemdependent.c
@@ -20,95 +20,94 @@ void vp8_arch_arm_encoder_init(VP8_COMP *cpi);
void (*vp8_yv12_copy_partial_frame_ptr)(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction);
extern void vp8_yv12_copy_partial_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction);
-void vp8_cmachine_specific_config(VP8_COMP *cpi)
-{
+void vp8_cmachine_specific_config(VP8_COMP *cpi) {
#if CONFIG_RUNTIME_CPU_DETECT
- cpi->rtcd.common = &cpi->common.rtcd;
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_c;
- cpi->rtcd.variance.sad16x8 = vp8_sad16x8_c;
- cpi->rtcd.variance.sad8x16 = vp8_sad8x16_c;
- cpi->rtcd.variance.sad8x8 = vp8_sad8x8_c;
- cpi->rtcd.variance.sad4x4 = vp8_sad4x4_c;
-
- cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_c;
- cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_c;
- cpi->rtcd.variance.sad8x16x3 = vp8_sad8x16x3_c;
- cpi->rtcd.variance.sad8x8x3 = vp8_sad8x8x3_c;
- cpi->rtcd.variance.sad4x4x3 = vp8_sad4x4x3_c;
-
- cpi->rtcd.variance.sad16x16x8 = vp8_sad16x16x8_c;
- cpi->rtcd.variance.sad16x8x8 = vp8_sad16x8x8_c;
- cpi->rtcd.variance.sad8x16x8 = vp8_sad8x16x8_c;
- cpi->rtcd.variance.sad8x8x8 = vp8_sad8x8x8_c;
- cpi->rtcd.variance.sad4x4x8 = vp8_sad4x4x8_c;
-
- cpi->rtcd.variance.sad16x16x4d = vp8_sad16x16x4d_c;
- cpi->rtcd.variance.sad16x8x4d = vp8_sad16x8x4d_c;
- cpi->rtcd.variance.sad8x16x4d = vp8_sad8x16x4d_c;
- cpi->rtcd.variance.sad8x8x4d = vp8_sad8x8x4d_c;
- cpi->rtcd.variance.sad4x4x4d = vp8_sad4x4x4d_c;
+ cpi->rtcd.common = &cpi->common.rtcd;
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_c;
+ cpi->rtcd.variance.sad16x8 = vp8_sad16x8_c;
+ cpi->rtcd.variance.sad8x16 = vp8_sad8x16_c;
+ cpi->rtcd.variance.sad8x8 = vp8_sad8x8_c;
+ cpi->rtcd.variance.sad4x4 = vp8_sad4x4_c;
+
+ cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_c;
+ cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_c;
+ cpi->rtcd.variance.sad8x16x3 = vp8_sad8x16x3_c;
+ cpi->rtcd.variance.sad8x8x3 = vp8_sad8x8x3_c;
+ cpi->rtcd.variance.sad4x4x3 = vp8_sad4x4x3_c;
+
+ cpi->rtcd.variance.sad16x16x8 = vp8_sad16x16x8_c;
+ cpi->rtcd.variance.sad16x8x8 = vp8_sad16x8x8_c;
+ cpi->rtcd.variance.sad8x16x8 = vp8_sad8x16x8_c;
+ cpi->rtcd.variance.sad8x8x8 = vp8_sad8x8x8_c;
+ cpi->rtcd.variance.sad4x4x8 = vp8_sad4x4x8_c;
+
+ cpi->rtcd.variance.sad16x16x4d = vp8_sad16x16x4d_c;
+ cpi->rtcd.variance.sad16x8x4d = vp8_sad16x8x4d_c;
+ cpi->rtcd.variance.sad8x16x4d = vp8_sad8x16x4d_c;
+ cpi->rtcd.variance.sad8x8x4d = vp8_sad8x8x4d_c;
+ cpi->rtcd.variance.sad4x4x4d = vp8_sad4x4x4d_c;
#if ARCH_X86 || ARCH_X86_64
- cpi->rtcd.variance.copy32xn = vp8_copy32xn_c;
+ cpi->rtcd.variance.copy32xn = vp8_copy32xn_c;
#endif
- cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;
- cpi->rtcd.variance.var8x8 = vp8_variance8x8_c;
- cpi->rtcd.variance.var8x16 = vp8_variance8x16_c;
- cpi->rtcd.variance.var16x8 = vp8_variance16x8_c;
- cpi->rtcd.variance.var16x16 = vp8_variance16x16_c;
-
- cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;
- cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_c;
- cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_c;
- cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_c;
- cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_c;
- cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_c;
- cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_c;
-
- cpi->rtcd.variance.mse16x16 = vp8_mse16x16_c;
- cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;
-
- cpi->rtcd.fdct.short8x8 = vp8_short_fdct8x8_c;
- cpi->rtcd.fdct.haar_short2x2 = vp8_short_fhaar2x2_c;
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_c;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_c;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_c;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_c;
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
-
- cpi->rtcd.encodemb.berr = vp8_block_error_c;
- cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
- cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;
- cpi->rtcd.encodemb.subb = vp8_subtract_b_c;
- cpi->rtcd.encodemb.submby = vp8_subtract_mby_c;
- cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_c;
-
- cpi->rtcd.search.full_search = vp8_full_search_sad;
- cpi->rtcd.search.refining_search = vp8_refining_search_sad;
- cpi->rtcd.search.diamond_search = vp8_diamond_search_sad;
- cpi->rtcd.temporal.apply = vp8_temporal_filter_apply_c;
+ cpi->rtcd.variance.var4x4 = vp8_variance4x4_c;
+ cpi->rtcd.variance.var8x8 = vp8_variance8x8_c;
+ cpi->rtcd.variance.var8x16 = vp8_variance8x16_c;
+ cpi->rtcd.variance.var16x8 = vp8_variance16x8_c;
+ cpi->rtcd.variance.var16x16 = vp8_variance16x16_c;
+
+ cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_c;
+ cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_c;
+ cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_c;
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_c;
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_c;
+ cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_c;
+ cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_c;
+ cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_c;
+ cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_c;
+
+ cpi->rtcd.variance.mse16x16 = vp8_mse16x16_c;
+ cpi->rtcd.variance.getmbss = vp8_get_mb_ss_c;
+
+ cpi->rtcd.fdct.short8x8 = vp8_short_fdct8x8_c;
+ cpi->rtcd.fdct.haar_short2x2 = vp8_short_fhaar2x2_c;
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_c;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_c;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_c;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_c;
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
+
+ cpi->rtcd.encodemb.berr = vp8_block_error_c;
+ cpi->rtcd.encodemb.mberr = vp8_mbblock_error_c;
+ cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_c;
+ cpi->rtcd.encodemb.subb = vp8_subtract_b_c;
+ cpi->rtcd.encodemb.submby = vp8_subtract_mby_c;
+ cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_c;
+
+ cpi->rtcd.search.full_search = vp8_full_search_sad;
+ cpi->rtcd.search.refining_search = vp8_refining_search_sad;
+ cpi->rtcd.search.diamond_search = vp8_diamond_search_sad;
+ cpi->rtcd.temporal.apply = vp8_temporal_filter_apply_c;
#if CONFIG_INTERNAL_STATS
- cpi->rtcd.variance.ssimpf_8x8 = vp8_ssim_parms_8x8_c;
- cpi->rtcd.variance.ssimpf_16x16 = vp8_ssim_parms_16x16_c;
+ cpi->rtcd.variance.ssimpf_8x8 = vp8_ssim_parms_8x8_c;
+ cpi->rtcd.variance.ssimpf_16x16 = vp8_ssim_parms_16x16_c;
#endif
#endif
- cpi->rtcd.variance.satd16x16 = vp8_satd16x16_c;
- vp8_yv12_copy_partial_frame_ptr = vp8_yv12_copy_partial_frame;
+ cpi->rtcd.variance.satd16x16 = vp8_satd16x16_c;
+ vp8_yv12_copy_partial_frame_ptr = vp8_yv12_copy_partial_frame;
#if ARCH_X86 || ARCH_X86_64
- vp8_arch_x86_encoder_init(cpi);
+ vp8_arch_x86_encoder_init(cpi);
#endif
#if ARCH_ARM
- vp8_arch_arm_encoder_init(cpi);
+ vp8_arch_arm_encoder_init(cpi);
#endif
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_c;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_c;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_c;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_c;
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_c;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_c;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_c;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_c;
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
}
diff --git a/vp8/encoder/lookahead.c b/vp8/encoder/lookahead.c
index b800d0136..ae21f9729 100644
--- a/vp8/encoder/lookahead.c
+++ b/vp8/encoder/lookahead.c
@@ -15,85 +15,78 @@
#define MAX_LAG_BUFFERS 25
-struct lookahead_ctx
-{
- unsigned int max_sz; /* Absolute size of the queue */
- unsigned int sz; /* Number of buffers currently in the queue */
- unsigned int read_idx; /* Read index */
- unsigned int write_idx; /* Write index */
- struct lookahead_entry *buf; /* Buffer list */
+struct lookahead_ctx {
+ unsigned int max_sz; /* Absolute size of the queue */
+ unsigned int sz; /* Number of buffers currently in the queue */
+ unsigned int read_idx; /* Read index */
+ unsigned int write_idx; /* Write index */
+ struct lookahead_entry *buf; /* Buffer list */
};
/* Return the buffer at the given absolute index and increment the index */
static struct lookahead_entry *
pop(struct lookahead_ctx *ctx,
- unsigned int *idx)
-{
- unsigned int index = *idx;
- struct lookahead_entry *buf = ctx->buf + index;
-
- assert(index < ctx->max_sz);
- if(++index >= ctx->max_sz)
- index -= ctx->max_sz;
- *idx = index;
- return buf;
+ unsigned int *idx) {
+ unsigned int index = *idx;
+ struct lookahead_entry *buf = ctx->buf + index;
+
+ assert(index < ctx->max_sz);
+ if (++index >= ctx->max_sz)
+ index -= ctx->max_sz;
+ *idx = index;
+ return buf;
}
void
-vp8_lookahead_destroy(struct lookahead_ctx *ctx)
-{
- if(ctx)
- {
- if(ctx->buf)
- {
- int i;
-
- for(i = 0; i < ctx->max_sz; i++)
- vp8_yv12_de_alloc_frame_buffer(&ctx->buf[i].img);
- free(ctx->buf);
- }
- free(ctx);
+vp8_lookahead_destroy(struct lookahead_ctx *ctx) {
+ if (ctx) {
+ if (ctx->buf) {
+ int i;
+
+ for (i = 0; i < ctx->max_sz; i++)
+ vp8_yv12_de_alloc_frame_buffer(&ctx->buf[i].img);
+ free(ctx->buf);
}
+ free(ctx);
+ }
}
-struct lookahead_ctx*
+struct lookahead_ctx *
vp8_lookahead_init(unsigned int width,
unsigned int height,
- unsigned int depth)
-{
- struct lookahead_ctx *ctx = NULL;
- int i;
-
- /* Clamp the lookahead queue depth */
- if(depth < 1)
- depth = 1;
- else if(depth > MAX_LAG_BUFFERS)
- depth = MAX_LAG_BUFFERS;
-
- /* Align the buffer dimensions */
- width = (width + 15) & ~15;
- height = (height + 15) & ~15;
-
- /* Allocate the lookahead structures */
- ctx = calloc(1, sizeof(*ctx));
- if(ctx)
- {
- ctx->max_sz = depth;
- ctx->buf = calloc(depth, sizeof(*ctx->buf));
- if(!ctx->buf)
- goto bail;
- for(i=0; i<depth; i++)
- if (vp8_yv12_alloc_frame_buffer(&ctx->buf[i].img,
- width, height, VP8BORDERINPIXELS))
- goto bail;
- }
- return ctx;
+ unsigned int depth) {
+ struct lookahead_ctx *ctx = NULL;
+ int i;
+
+ /* Clamp the lookahead queue depth */
+ if (depth < 1)
+ depth = 1;
+ else if (depth > MAX_LAG_BUFFERS)
+ depth = MAX_LAG_BUFFERS;
+
+ /* Align the buffer dimensions */
+ width = (width + 15) &~15;
+ height = (height + 15) &~15;
+
+ /* Allocate the lookahead structures */
+ ctx = calloc(1, sizeof(*ctx));
+ if (ctx) {
+ ctx->max_sz = depth;
+ ctx->buf = calloc(depth, sizeof(*ctx->buf));
+ if (!ctx->buf)
+ goto bail;
+ for (i = 0; i < depth; i++)
+ if (vp8_yv12_alloc_frame_buffer(&ctx->buf[i].img,
+ width, height, VP8BORDERINPIXELS))
+ goto bail;
+ }
+ return ctx;
bail:
- vp8_lookahead_destroy(ctx);
- return NULL;
+ vp8_lookahead_destroy(ctx);
+ return NULL;
}
@@ -103,109 +96,96 @@ vp8_lookahead_push(struct lookahead_ctx *ctx,
int64_t ts_start,
int64_t ts_end,
unsigned int flags,
- unsigned char *active_map)
-{
- struct lookahead_entry* buf;
- int row, col, active_end;
- int mb_rows = (src->y_height + 15) >> 4;
- int mb_cols = (src->y_width + 15) >> 4;
-
- if(ctx->sz + 1 > ctx->max_sz)
- return 1;
- ctx->sz++;
- buf = pop(ctx, &ctx->write_idx);
-
- // Only do this partial copy if the following conditions are all met:
- // 1. Lookahead queue has has size of 1.
- // 2. Active map is provided.
- // 3. This is not a key frame, golden nor altref frame.
- if (ctx->max_sz == 1 && active_map && !flags)
- {
- for (row = 0; row < mb_rows; ++row)
- {
- col = 0;
-
- while (1)
- {
- // Find the first active macroblock in this row.
- for (; col < mb_cols; ++col)
- {
- if (active_map[col])
- break;
- }
-
- // No more active macroblock in this row.
- if (col == mb_cols)
- break;
-
- // Find the end of active region in this row.
- active_end = col;
-
- for (; active_end < mb_cols; ++active_end)
- {
- if (!active_map[active_end])
- break;
- }
-
- // Only copy this active region.
- vp8_copy_and_extend_frame_with_rect(src, &buf->img,
- row << 4,
- col << 4, 16,
- (active_end - col) << 4);
-
- // Start again from the end of this active region.
- col = active_end;
- }
-
- active_map += mb_cols;
+ unsigned char *active_map) {
+ struct lookahead_entry *buf;
+ int row, col, active_end;
+ int mb_rows = (src->y_height + 15) >> 4;
+ int mb_cols = (src->y_width + 15) >> 4;
+
+ if (ctx->sz + 1 > ctx->max_sz)
+ return 1;
+ ctx->sz++;
+ buf = pop(ctx, &ctx->write_idx);
+
+ // Only do this partial copy if the following conditions are all met:
+ // 1. Lookahead queue has has size of 1.
+ // 2. Active map is provided.
+ // 3. This is not a key frame, golden nor altref frame.
+ if (ctx->max_sz == 1 && active_map && !flags) {
+ for (row = 0; row < mb_rows; ++row) {
+ col = 0;
+
+ while (1) {
+ // Find the first active macroblock in this row.
+ for (; col < mb_cols; ++col) {
+ if (active_map[col])
+ break;
}
+
+ // No more active macroblock in this row.
+ if (col == mb_cols)
+ break;
+
+ // Find the end of active region in this row.
+ active_end = col;
+
+ for (; active_end < mb_cols; ++active_end) {
+ if (!active_map[active_end])
+ break;
+ }
+
+ // Only copy this active region.
+ vp8_copy_and_extend_frame_with_rect(src, &buf->img,
+ row << 4,
+ col << 4, 16,
+ (active_end - col) << 4);
+
+ // Start again from the end of this active region.
+ col = active_end;
+ }
+
+ active_map += mb_cols;
}
- else
- {
- vp8_copy_and_extend_frame(src, &buf->img);
- }
- buf->ts_start = ts_start;
- buf->ts_end = ts_end;
- buf->flags = flags;
- return 0;
+ } else {
+ vp8_copy_and_extend_frame(src, &buf->img);
+ }
+ buf->ts_start = ts_start;
+ buf->ts_end = ts_end;
+ buf->flags = flags;
+ return 0;
}
-struct lookahead_entry*
+struct lookahead_entry *
vp8_lookahead_pop(struct lookahead_ctx *ctx,
- int drain)
-{
- struct lookahead_entry* buf = NULL;
-
- if(ctx->sz && (drain || ctx->sz == ctx->max_sz))
- {
- buf = pop(ctx, &ctx->read_idx);
- ctx->sz--;
- }
- return buf;
+ int drain) {
+ struct lookahead_entry *buf = NULL;
+
+ if (ctx->sz && (drain || ctx->sz == ctx->max_sz)) {
+ buf = pop(ctx, &ctx->read_idx);
+ ctx->sz--;
+ }
+ return buf;
}
-struct lookahead_entry*
+struct lookahead_entry *
vp8_lookahead_peek(struct lookahead_ctx *ctx,
- int index)
-{
- struct lookahead_entry* buf = NULL;
-
- assert(index < ctx->max_sz);
- if(index < ctx->sz)
- {
- index += ctx->read_idx;
- if(index >= ctx->max_sz)
- index -= ctx->max_sz;
- buf = ctx->buf + index;
- }
- return buf;
+ int index) {
+ struct lookahead_entry *buf = NULL;
+
+ assert(index < ctx->max_sz);
+ if (index < ctx->sz) {
+ index += ctx->read_idx;
+ if (index >= ctx->max_sz)
+ index -= ctx->max_sz;
+ buf = ctx->buf + index;
+ }
+ return buf;
}
unsigned int
-vp8_lookahead_depth(struct lookahead_ctx *ctx)
-{
- return ctx->sz;
+vp8_lookahead_depth(struct lookahead_ctx *ctx) {
+ return ctx->sz;
}
diff --git a/vp8/encoder/lookahead.h b/vp8/encoder/lookahead.h
index afb3fd4a9..3c7abf901 100644
--- a/vp8/encoder/lookahead.h
+++ b/vp8/encoder/lookahead.h
@@ -12,12 +12,11 @@
#include "vpx_scale/yv12config.h"
#include "vpx/vpx_integer.h"
-struct lookahead_entry
-{
- YV12_BUFFER_CONFIG img;
- int64_t ts_start;
- int64_t ts_end;
- unsigned int flags;
+struct lookahead_entry {
+ YV12_BUFFER_CONFIG img;
+ int64_t ts_start;
+ int64_t ts_end;
+ unsigned int flags;
};
@@ -30,10 +29,10 @@ struct lookahead_ctx;
*
*
*/
-struct lookahead_ctx* vp8_lookahead_init(unsigned int width,
+struct lookahead_ctx *vp8_lookahead_init(unsigned int width,
unsigned int height,
unsigned int depth
- );
+ );
/**\brief Destroys the lookahead stage
@@ -77,7 +76,7 @@ vp8_lookahead_push(struct lookahead_ctx *ctx,
* \retval NULL, if drain not set and queue not of the configured depth
*
*/
-struct lookahead_entry*
+struct lookahead_entry *
vp8_lookahead_pop(struct lookahead_ctx *ctx,
int drain);
@@ -90,7 +89,7 @@ vp8_lookahead_pop(struct lookahead_ctx *ctx,
* \retval NULL, if no buffer exists at the specified index
*
*/
-struct lookahead_entry*
+struct lookahead_entry *
vp8_lookahead_peek(struct lookahead_ctx *ctx,
int index);
diff --git a/vp8/encoder/mbgraph.c b/vp8/encoder/mbgraph.c
index cad27500a..4cd3ea233 100644
--- a/vp8/encoder/mbgraph.c
+++ b/vp8/encoder/mbgraph.c
@@ -20,549 +20,509 @@
static unsigned int do_16x16_motion_iteration
(
- VP8_COMP *cpi,
- int_mv *ref_mv,
- int_mv *dst_mv
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
- BLOCK *b = &x->block[0];
- BLOCKD *d = &xd->block[0];
- vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
- unsigned int best_err;
- int step_param, further_steps;
- static int dummy_cost[2*mv_max+1];
- int *mvcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
- int *mvsadcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
+ VP8_COMP *cpi,
+ int_mv *ref_mv,
+ int_mv *dst_mv
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ BLOCK *b = &x->block[0];
+ BLOCKD *d = &xd->block[0];
+ vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
+ unsigned int best_err;
+ int step_param, further_steps;
+ static int dummy_cost[2 * mv_max + 1];
+ int *mvcost[2] = { &dummy_cost[mv_max + 1], &dummy_cost[mv_max + 1] };
+ int *mvsadcost[2] = { &dummy_cost[mv_max + 1], &dummy_cost[mv_max + 1] };
#if CONFIG_HIGH_PRECISION_MV
- static int dummy_cost_hp[2*mv_max_hp+1];
- int *mvcost_hp[2] = { &dummy_cost_hp[mv_max_hp+1], &dummy_cost_hp[mv_max_hp+1] };
- int *mvsadcost_hp[2] = { &dummy_cost_hp[mv_max_hp+1], &dummy_cost_hp[mv_max_hp+1] };
+ static int dummy_cost_hp[2 * mv_max_hp + 1];
+ int *mvcost_hp[2] = { &dummy_cost_hp[mv_max_hp + 1], &dummy_cost_hp[mv_max_hp + 1] };
+ int *mvsadcost_hp[2] = { &dummy_cost_hp[mv_max_hp + 1], &dummy_cost_hp[mv_max_hp + 1] };
#endif
- int col_min = (ref_mv->as_mv.col>>3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.col & 7)?1:0);
- int row_min = (ref_mv->as_mv.row>>3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.row & 7)?1:0);
- int col_max = (ref_mv->as_mv.col>>3) + MAX_FULL_PEL_VAL;
- int row_max = (ref_mv->as_mv.row>>3) + MAX_FULL_PEL_VAL;
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
- int_mv ref_full;
-
- // Further step/diamond searches as necessary
- if (cpi->Speed < 8)
- {
- step_param = cpi->sf.first_step + ((cpi->Speed > 5) ? 1 : 0);
- further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
- }
- else
- {
- step_param = cpi->sf.first_step + 2;
- further_steps = 0;
- }
-
- /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
- if (x->mv_col_min < col_min )
- x->mv_col_min = col_min;
- if (x->mv_col_max > col_max )
- x->mv_col_max = col_max;
- if (x->mv_row_min < row_min )
- x->mv_row_min = row_min;
- if (x->mv_row_max > row_max )
- x->mv_row_max = row_max;
-
- ref_full.as_mv.col = ref_mv->as_mv.col >> 3;
- ref_full.as_mv.row = ref_mv->as_mv.row >> 3;
-
- /*cpi->sf.search_method == HEX*/
- best_err = vp8_hex_search(x, b, d,
- &ref_full, dst_mv,
- step_param,
- x->errorperbit,
- &v_fn_ptr,
+ int col_min = (ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.col & 7) ? 1 : 0);
+ int row_min = (ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.row & 7) ? 1 : 0);
+ int col_max = (ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
+ int row_max = (ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
+ int tmp_col_min = x->mv_col_min;
+ int tmp_col_max = x->mv_col_max;
+ int tmp_row_min = x->mv_row_min;
+ int tmp_row_max = x->mv_row_max;
+ int_mv ref_full;
+
+ // Further step/diamond searches as necessary
+ if (cpi->Speed < 8) {
+ step_param = cpi->sf.first_step + ((cpi->Speed > 5) ? 1 : 0);
+ further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
+ } else {
+ step_param = cpi->sf.first_step + 2;
+ further_steps = 0;
+ }
+
+ /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
+ if (x->mv_col_min < col_min)
+ x->mv_col_min = col_min;
+ if (x->mv_col_max > col_max)
+ x->mv_col_max = col_max;
+ if (x->mv_row_min < row_min)
+ x->mv_row_min = row_min;
+ if (x->mv_row_max > row_max)
+ x->mv_row_max = row_max;
+
+ ref_full.as_mv.col = ref_mv->as_mv.col >> 3;
+ ref_full.as_mv.row = ref_mv->as_mv.row >> 3;
+
+ /*cpi->sf.search_method == HEX*/
+ best_err = vp8_hex_search(x, b, d,
+ &ref_full, dst_mv,
+ step_param,
+ x->errorperbit,
+ &v_fn_ptr,
#if CONFIG_HIGH_PRECISION_MV
- xd->allow_high_precision_mv?mvsadcost_hp:mvsadcost, xd->allow_high_precision_mv?mvcost_hp:mvcost,
+ xd->allow_high_precision_mv ? mvsadcost_hp : mvsadcost, xd->allow_high_precision_mv ? mvcost_hp : mvcost,
#else
- mvsadcost, mvcost,
+ mvsadcost, mvcost,
#endif
- ref_mv);
-
- // Try sub-pixel MC
- //if (bestsme > error_thresh && bestsme < INT_MAX)
- {
- int distortion;
- unsigned int sse;
- best_err = cpi->find_fractional_mv_step(x, b, d,
- dst_mv, ref_mv,
- x->errorperbit, &v_fn_ptr,
+ ref_mv);
+
+ // Try sub-pixel MC
+ // if (bestsme > error_thresh && bestsme < INT_MAX)
+ {
+ int distortion;
+ unsigned int sse;
+ best_err = cpi->find_fractional_mv_step(x, b, d,
+ dst_mv, ref_mv,
+ x->errorperbit, &v_fn_ptr,
#if CONFIG_HIGH_PRECISION_MV
- xd->allow_high_precision_mv?mvcost_hp:mvcost,
+ xd->allow_high_precision_mv ? mvcost_hp : mvcost,
#else
- mvcost,
+ mvcost,
#endif
- &distortion, &sse);
- }
+ & distortion, &sse);
+ }
#if CONFIG_PRED_FILTER
- // Disable the prediction filter
- xd->mode_info_context->mbmi.pred_filter_enabled = 0;
+ // Disable the prediction filter
+ xd->mode_info_context->mbmi.pred_filter_enabled = 0;
#endif
- vp8_set_mbmode_and_mvs(x, NEWMV, dst_mv);
- vp8_build_inter16x16_predictors_mby(xd);
- //VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
- best_err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
- (xd->dst.y_buffer, xd->dst.y_stride,
- xd->predictor, 16, INT_MAX);
+ vp8_set_mbmode_and_mvs(x, NEWMV, dst_mv);
+ vp8_build_inter16x16_predictors_mby(xd);
+ // VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
+ best_err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
+ (xd->dst.y_buffer, xd->dst.y_stride,
+ xd->predictor, 16, INT_MAX);
- /* restore UMV window */
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
+ /* restore UMV window */
+ x->mv_col_min = tmp_col_min;
+ x->mv_col_max = tmp_col_max;
+ x->mv_row_min = tmp_row_min;
+ x->mv_row_max = tmp_row_max;
- return best_err;
+ return best_err;
}
static int do_16x16_motion_search
(
- VP8_COMP *cpi,
- int_mv *ref_mv,
- int_mv *dst_mv,
- YV12_BUFFER_CONFIG *buf,
- int buf_mb_y_offset,
- YV12_BUFFER_CONFIG *ref,
- int mb_y_offset
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
- unsigned int err, tmp_err;
- int_mv tmp_mv;
- int n;
-
- for (n = 0; n < 16; n++) {
- BLOCKD *d = &xd->block[n];
- BLOCK *b = &x->block[n];
-
- b->base_src = &buf->y_buffer;
- b->src_stride = buf->y_stride;
- b->src = buf->y_stride * (n & 12) + (n & 3) * 4 + buf_mb_y_offset;
-
- d->base_pre = &ref->y_buffer;
- d->pre_stride = ref->y_stride;
- d->pre = ref->y_stride * (n & 12) + (n & 3) * 4 + mb_y_offset;
- }
-
- // Try zero MV first
- // FIXME should really use something like near/nearest MV and/or MV prediction
- xd->pre.y_buffer = ref->y_buffer + mb_y_offset;
- xd->pre.y_stride = ref->y_stride;
- //VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
- err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
- (ref->y_buffer + mb_y_offset,
- ref->y_stride, xd->dst.y_buffer,
- xd->dst.y_stride, INT_MAX);
- dst_mv->as_int = 0;
-
- // Test last reference frame using the previous best mv as the
- // starting point (best reference) for the search
- tmp_err = do_16x16_motion_iteration(cpi, ref_mv, &tmp_mv);
- if (tmp_err < err)
- {
- err = tmp_err;
- dst_mv->as_int = tmp_mv.as_int;
- }
-
- // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
- if (ref_mv->as_int)
- {
- int tmp_err;
- int_mv zero_ref_mv, tmp_mv;
-
- zero_ref_mv.as_int = 0;
- tmp_err = do_16x16_motion_iteration(cpi, &zero_ref_mv, &tmp_mv);
- if (tmp_err < err)
- {
- dst_mv->as_int = tmp_mv.as_int;
- err = tmp_err;
- }
+ VP8_COMP *cpi,
+ int_mv *ref_mv,
+ int_mv *dst_mv,
+ YV12_BUFFER_CONFIG *buf,
+ int buf_mb_y_offset,
+ YV12_BUFFER_CONFIG *ref,
+ int mb_y_offset
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ unsigned int err, tmp_err;
+ int_mv tmp_mv;
+ int n;
+
+ for (n = 0; n < 16; n++) {
+ BLOCKD *d = &xd->block[n];
+ BLOCK *b = &x->block[n];
+
+ b->base_src = &buf->y_buffer;
+ b->src_stride = buf->y_stride;
+ b->src = buf->y_stride * (n & 12) + (n & 3) * 4 + buf_mb_y_offset;
+
+ d->base_pre = &ref->y_buffer;
+ d->pre_stride = ref->y_stride;
+ d->pre = ref->y_stride * (n & 12) + (n & 3) * 4 + mb_y_offset;
+ }
+
+ // Try zero MV first
+ // FIXME should really use something like near/nearest MV and/or MV prediction
+ xd->pre.y_buffer = ref->y_buffer + mb_y_offset;
+ xd->pre.y_stride = ref->y_stride;
+ // VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
+ err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
+ (ref->y_buffer + mb_y_offset,
+ ref->y_stride, xd->dst.y_buffer,
+ xd->dst.y_stride, INT_MAX);
+ dst_mv->as_int = 0;
+
+ // Test last reference frame using the previous best mv as the
+ // starting point (best reference) for the search
+ tmp_err = do_16x16_motion_iteration(cpi, ref_mv, &tmp_mv);
+ if (tmp_err < err) {
+ err = tmp_err;
+ dst_mv->as_int = tmp_mv.as_int;
+ }
+
+ // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
+ if (ref_mv->as_int) {
+ int tmp_err;
+ int_mv zero_ref_mv, tmp_mv;
+
+ zero_ref_mv.as_int = 0;
+ tmp_err = do_16x16_motion_iteration(cpi, &zero_ref_mv, &tmp_mv);
+ if (tmp_err < err) {
+ dst_mv->as_int = tmp_mv.as_int;
+ err = tmp_err;
}
+ }
- return err;
+ return err;
}
static int do_16x16_zerozero_search
(
- VP8_COMP *cpi,
- int_mv *dst_mv,
- YV12_BUFFER_CONFIG *buf,
- int buf_mb_y_offset,
- YV12_BUFFER_CONFIG *ref,
- int mb_y_offset
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
- unsigned int err;
- int n;
-
- for (n = 0; n < 16; n++) {
- BLOCKD *d = &xd->block[n];
- BLOCK *b = &x->block[n];
-
- b->base_src = &buf->y_buffer;
- b->src_stride = buf->y_stride;
- b->src = buf->y_stride * (n & 12) + (n & 3) * 4 + buf_mb_y_offset;
-
- d->base_pre = &ref->y_buffer;
- d->pre_stride = ref->y_stride;
- d->pre = ref->y_stride * (n & 12) + (n & 3) * 4 + mb_y_offset;
- }
-
- // Try zero MV first
- // FIXME should really use something like near/nearest MV and/or MV prediction
- xd->pre.y_buffer = ref->y_buffer + mb_y_offset;
- xd->pre.y_stride = ref->y_stride;
- //VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
- err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
- (ref->y_buffer + mb_y_offset,
- ref->y_stride, xd->dst.y_buffer,
- xd->dst.y_stride, INT_MAX);
-
- dst_mv->as_int = 0;
-
- return err;
+ VP8_COMP *cpi,
+ int_mv *dst_mv,
+ YV12_BUFFER_CONFIG *buf,
+ int buf_mb_y_offset,
+ YV12_BUFFER_CONFIG *ref,
+ int mb_y_offset
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ unsigned int err;
+ int n;
+
+ for (n = 0; n < 16; n++) {
+ BLOCKD *d = &xd->block[n];
+ BLOCK *b = &x->block[n];
+
+ b->base_src = &buf->y_buffer;
+ b->src_stride = buf->y_stride;
+ b->src = buf->y_stride * (n & 12) + (n & 3) * 4 + buf_mb_y_offset;
+
+ d->base_pre = &ref->y_buffer;
+ d->pre_stride = ref->y_stride;
+ d->pre = ref->y_stride * (n & 12) + (n & 3) * 4 + mb_y_offset;
+ }
+
+ // Try zero MV first
+ // FIXME should really use something like near/nearest MV and/or MV prediction
+ xd->pre.y_buffer = ref->y_buffer + mb_y_offset;
+ xd->pre.y_stride = ref->y_stride;
+ // VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
+ err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
+ (ref->y_buffer + mb_y_offset,
+ ref->y_stride, xd->dst.y_buffer,
+ xd->dst.y_stride, INT_MAX);
+
+ dst_mv->as_int = 0;
+
+ return err;
}
static int find_best_16x16_intra
(
- VP8_COMP *cpi,
- YV12_BUFFER_CONFIG *buf,
- int mb_y_offset,
- MB_PREDICTION_MODE *pbest_mode
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
- MB_PREDICTION_MODE best_mode = -1, mode;
- int best_err = INT_MAX;
-
- // calculate SATD for each intra prediction mode;
- // we're intentionally not doing 4x4, we just want a rough estimate
- for (mode = DC_PRED; mode <= TM_PRED; mode++)
- {
- unsigned int err;
-
- xd->mode_info_context->mbmi.mode = mode;
- RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mby)(xd);
- //VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
- err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
- (xd->predictor, 16,
- buf->y_buffer + mb_y_offset,
- buf->y_stride, best_err);
- // find best
- if (err < best_err)
- {
- best_err = err;
- best_mode = mode;
- }
+ VP8_COMP *cpi,
+ YV12_BUFFER_CONFIG *buf,
+ int mb_y_offset,
+ MB_PREDICTION_MODE *pbest_mode
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ MB_PREDICTION_MODE best_mode = -1, mode;
+ int best_err = INT_MAX;
+
+ // calculate SATD for each intra prediction mode;
+ // we're intentionally not doing 4x4, we just want a rough estimate
+ for (mode = DC_PRED; mode <= TM_PRED; mode++) {
+ unsigned int err;
+
+ xd->mode_info_context->mbmi.mode = mode;
+ RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mby)(xd);
+ // VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
+ err = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16)
+ (xd->predictor, 16,
+ buf->y_buffer + mb_y_offset,
+ buf->y_stride, best_err);
+ // find best
+ if (err < best_err) {
+ best_err = err;
+ best_mode = mode;
}
+ }
- if (pbest_mode)
- *pbest_mode = best_mode;
+ if (pbest_mode)
+ *pbest_mode = best_mode;
- return best_err;
+ return best_err;
}
static void update_mbgraph_mb_stats
(
- VP8_COMP *cpi,
- MBGRAPH_MB_STATS *stats,
- YV12_BUFFER_CONFIG *buf,
- int mb_y_offset,
- YV12_BUFFER_CONFIG *golden_ref,
- int_mv *prev_golden_ref_mv,
- int gld_y_offset,
- YV12_BUFFER_CONFIG *alt_ref,
- int_mv *prev_alt_ref_mv,
- int arf_y_offset
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
- int intra_error;
-
- // FIXME in practice we're completely ignoring chroma here
- xd->dst.y_buffer = buf->y_buffer + mb_y_offset;
-
- // do intra 16x16 prediction
- intra_error = find_best_16x16_intra(cpi, buf, mb_y_offset, &stats->ref[INTRA_FRAME].m.mode);
- if (intra_error <= 0)
- intra_error = 1;
- stats->ref[INTRA_FRAME].err = intra_error;
-
- // Golden frame MV search, if it exists and is different than last frame
- if (golden_ref)
- {
- int g_motion_error = do_16x16_motion_search(cpi, prev_golden_ref_mv,
- &stats->ref[GOLDEN_FRAME].m.mv,
- buf, mb_y_offset,
- golden_ref, gld_y_offset);
- stats->ref[GOLDEN_FRAME].err = g_motion_error;
- }
- else
- {
- stats->ref[GOLDEN_FRAME].err = INT_MAX;
- stats->ref[GOLDEN_FRAME].m.mv.as_int = 0;
- }
-
- // Alt-ref frame MV search, if it exists and is different than last/golden frame
- if (alt_ref)
- {
- //int a_motion_error = do_16x16_motion_search(cpi, prev_alt_ref_mv,
- // &stats->ref[ALTREF_FRAME].m.mv,
- // buf, mb_y_offset,
- // alt_ref, arf_y_offset);
-
- int a_motion_error =
- do_16x16_zerozero_search( cpi,
- &stats->ref[ALTREF_FRAME].m.mv,
- buf, mb_y_offset,
- alt_ref, arf_y_offset);
-
- stats->ref[ALTREF_FRAME].err = a_motion_error;
- }
- else
- {
- stats->ref[ALTREF_FRAME].err = INT_MAX;
- stats->ref[ALTREF_FRAME].m.mv.as_int = 0;
- }
+ VP8_COMP *cpi,
+ MBGRAPH_MB_STATS *stats,
+ YV12_BUFFER_CONFIG *buf,
+ int mb_y_offset,
+ YV12_BUFFER_CONFIG *golden_ref,
+ int_mv *prev_golden_ref_mv,
+ int gld_y_offset,
+ YV12_BUFFER_CONFIG *alt_ref,
+ int_mv *prev_alt_ref_mv,
+ int arf_y_offset
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ int intra_error;
+
+ // FIXME in practice we're completely ignoring chroma here
+ xd->dst.y_buffer = buf->y_buffer + mb_y_offset;
+
+ // do intra 16x16 prediction
+ intra_error = find_best_16x16_intra(cpi, buf, mb_y_offset, &stats->ref[INTRA_FRAME].m.mode);
+ if (intra_error <= 0)
+ intra_error = 1;
+ stats->ref[INTRA_FRAME].err = intra_error;
+
+ // Golden frame MV search, if it exists and is different than last frame
+ if (golden_ref) {
+ int g_motion_error = do_16x16_motion_search(cpi, prev_golden_ref_mv,
+ &stats->ref[GOLDEN_FRAME].m.mv,
+ buf, mb_y_offset,
+ golden_ref, gld_y_offset);
+ stats->ref[GOLDEN_FRAME].err = g_motion_error;
+ } else {
+ stats->ref[GOLDEN_FRAME].err = INT_MAX;
+ stats->ref[GOLDEN_FRAME].m.mv.as_int = 0;
+ }
+
+ // Alt-ref frame MV search, if it exists and is different than last/golden frame
+ if (alt_ref) {
+ // int a_motion_error = do_16x16_motion_search(cpi, prev_alt_ref_mv,
+ // &stats->ref[ALTREF_FRAME].m.mv,
+ // buf, mb_y_offset,
+ // alt_ref, arf_y_offset);
+
+ int a_motion_error =
+ do_16x16_zerozero_search(cpi,
+ &stats->ref[ALTREF_FRAME].m.mv,
+ buf, mb_y_offset,
+ alt_ref, arf_y_offset);
+
+ stats->ref[ALTREF_FRAME].err = a_motion_error;
+ } else {
+ stats->ref[ALTREF_FRAME].err = INT_MAX;
+ stats->ref[ALTREF_FRAME].m.mv.as_int = 0;
+ }
}
static void update_mbgraph_frame_stats
(
- VP8_COMP *cpi,
- MBGRAPH_FRAME_STATS *stats,
- YV12_BUFFER_CONFIG *buf,
- YV12_BUFFER_CONFIG *golden_ref,
- YV12_BUFFER_CONFIG *alt_ref
-)
-{
- MACROBLOCK * const x = &cpi->mb;
- VP8_COMMON * const cm = &cpi->common;
- MACROBLOCKD * const xd = &x->e_mbd;
- int mb_col, mb_row, offset = 0;
- int mb_y_offset = 0, arf_y_offset = 0, gld_y_offset = 0;
- int_mv arf_top_mv, gld_top_mv;
- MODE_INFO mi_local;
+ VP8_COMP *cpi,
+ MBGRAPH_FRAME_STATS *stats,
+ YV12_BUFFER_CONFIG *buf,
+ YV12_BUFFER_CONFIG *golden_ref,
+ YV12_BUFFER_CONFIG *alt_ref
+) {
+ MACROBLOCK *const x = &cpi->mb;
+ VP8_COMMON *const cm = &cpi->common;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ int mb_col, mb_row, offset = 0;
+ int mb_y_offset = 0, arf_y_offset = 0, gld_y_offset = 0;
+ int_mv arf_top_mv, gld_top_mv;
+ MODE_INFO mi_local;
+
+ // Set up limit values for motion vectors to prevent them extending outside the UMV borders
+ arf_top_mv.as_int = 0;
+ gld_top_mv.as_int = 0;
+ x->mv_row_min = -(VP8BORDERINPIXELS - 16 - INTERP_EXTEND);
+ x->mv_row_max = (cm->mb_rows - 1) * 16 + VP8BORDERINPIXELS - 16 - INTERP_EXTEND;
+ xd->up_available = 0;
+ xd->dst.y_stride = buf->y_stride;
+ xd->pre.y_stride = buf->y_stride;
+ xd->dst.uv_stride = buf->uv_stride;
+ xd->mode_info_context = &mi_local;
+
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ int_mv arf_left_mv, gld_left_mv;
+ int mb_y_in_offset = mb_y_offset;
+ int arf_y_in_offset = arf_y_offset;
+ int gld_y_in_offset = gld_y_offset;
// Set up limit values for motion vectors to prevent them extending outside the UMV borders
- arf_top_mv.as_int = 0;
- gld_top_mv.as_int = 0;
- x->mv_row_min = -(VP8BORDERINPIXELS - 16 - INTERP_EXTEND);
- x->mv_row_max = (cm->mb_rows - 1) * 16 + VP8BORDERINPIXELS - 16 - INTERP_EXTEND;
- xd->up_available = 0;
- xd->dst.y_stride = buf->y_stride;
- xd->pre.y_stride = buf->y_stride;
- xd->dst.uv_stride = buf->uv_stride;
- xd->mode_info_context = &mi_local;
-
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- int_mv arf_left_mv, gld_left_mv;
- int mb_y_in_offset = mb_y_offset;
- int arf_y_in_offset = arf_y_offset;
- int gld_y_in_offset = gld_y_offset;
-
- // Set up limit values for motion vectors to prevent them extending outside the UMV borders
- arf_left_mv.as_int = arf_top_mv.as_int;
- gld_left_mv.as_int = gld_top_mv.as_int;
- x->mv_col_min = -(VP8BORDERINPIXELS - 16 - INTERP_EXTEND);
- x->mv_col_max = (cm->mb_cols - 1) * 16 + VP8BORDERINPIXELS - 16 - INTERP_EXTEND;
- xd->left_available = 0;
-
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- MBGRAPH_MB_STATS *mb_stats = &stats->mb_stats[offset + mb_col];
-
- update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset,
- golden_ref, &gld_left_mv, gld_y_in_offset,
- alt_ref, &arf_left_mv, arf_y_in_offset);
- arf_left_mv.as_int = mb_stats->ref[ALTREF_FRAME].m.mv.as_int;
- gld_left_mv.as_int = mb_stats->ref[GOLDEN_FRAME].m.mv.as_int;
- if (mb_col == 0)
- {
- arf_top_mv.as_int = arf_left_mv.as_int;
- gld_top_mv.as_int = gld_left_mv.as_int;
- }
- xd->left_available = 1;
- mb_y_in_offset += 16;
- gld_y_in_offset += 16;
- arf_y_in_offset += 16;
- x->mv_col_min -= 16;
- x->mv_col_max -= 16;
- }
- xd->up_available = 1;
- mb_y_offset += buf->y_stride * 16;
- gld_y_offset += golden_ref->y_stride * 16;
- if (alt_ref)
- arf_y_offset += alt_ref->y_stride * 16;
- x->mv_row_min -= 16;
- x->mv_row_max -= 16;
- offset += cm->mb_cols;
+ arf_left_mv.as_int = arf_top_mv.as_int;
+ gld_left_mv.as_int = gld_top_mv.as_int;
+ x->mv_col_min = -(VP8BORDERINPIXELS - 16 - INTERP_EXTEND);
+ x->mv_col_max = (cm->mb_cols - 1) * 16 + VP8BORDERINPIXELS - 16 - INTERP_EXTEND;
+ xd->left_available = 0;
+
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ MBGRAPH_MB_STATS *mb_stats = &stats->mb_stats[offset + mb_col];
+
+ update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset,
+ golden_ref, &gld_left_mv, gld_y_in_offset,
+ alt_ref, &arf_left_mv, arf_y_in_offset);
+ arf_left_mv.as_int = mb_stats->ref[ALTREF_FRAME].m.mv.as_int;
+ gld_left_mv.as_int = mb_stats->ref[GOLDEN_FRAME].m.mv.as_int;
+ if (mb_col == 0) {
+ arf_top_mv.as_int = arf_left_mv.as_int;
+ gld_top_mv.as_int = gld_left_mv.as_int;
+ }
+ xd->left_available = 1;
+ mb_y_in_offset += 16;
+ gld_y_in_offset += 16;
+ arf_y_in_offset += 16;
+ x->mv_col_min -= 16;
+ x->mv_col_max -= 16;
}
+ xd->up_available = 1;
+ mb_y_offset += buf->y_stride * 16;
+ gld_y_offset += golden_ref->y_stride * 16;
+ if (alt_ref)
+ arf_y_offset += alt_ref->y_stride * 16;
+ x->mv_row_min -= 16;
+ x->mv_row_max -= 16;
+ offset += cm->mb_cols;
+ }
}
// Test for small magnitude (<= 1 pel mvs)
-int small_mv( MV mv )
-{
- if ( (abs( (int)mv.col ) > 2) || (abs( (int)mv.row ) > 2) )
- return FALSE;
- else
- return TRUE;
+int small_mv(MV mv) {
+ if ((abs((int)mv.col) > 2) || (abs((int)mv.row) > 2))
+ return FALSE;
+ else
+ return TRUE;
}
-//void separate_arf_mbs_byzz
+// void separate_arf_mbs_byzz
void separate_arf_mbs
(
- VP8_COMP *cpi
-)
-{
- VP8_COMMON * const cm = &cpi->common;
- int mb_col, mb_row, offset, i;
- int ncnt[4];
- int n_frames = cpi->mbgraph_n_frames;
-
- int * arf_not_zz;
-
- CHECK_MEM_ERROR(arf_not_zz,
- vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz), 1));
-
- vpx_memset(arf_not_zz, 0, sizeof(arf_not_zz));
-
- // We are not interested in results beyond the alt ref itself.
- if ( n_frames > cpi->frames_till_gf_update_due )
- n_frames = cpi->frames_till_gf_update_due;
-
- // defer cost to reference frames
- for (i = n_frames - 1; i >= 0; i--)
- {
- MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
-
- for (offset = 0, mb_row = 0; mb_row < cm->mb_rows;
- offset += cm->mb_cols, mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- MBGRAPH_MB_STATS *mb_stats =
- &frame_stats->mb_stats[offset + mb_col];
-
- int altref_err = mb_stats->ref[ALTREF_FRAME].err;
- int intra_err = mb_stats->ref[INTRA_FRAME ].err;
- int golden_err = mb_stats->ref[GOLDEN_FRAME].err;
-
- // Test for altref vs intra and gf and that its mv was 0,0.
- if ( (altref_err > 1000) ||
- (altref_err > intra_err) ||
- (altref_err > golden_err) )
- {
- arf_not_zz[offset + mb_col]++;
- }
- }
- }
- }
+ VP8_COMP *cpi
+) {
+ VP8_COMMON *const cm = &cpi->common;
+ int mb_col, mb_row, offset, i;
+ int ncnt[4];
+ int n_frames = cpi->mbgraph_n_frames;
+
+ int *arf_not_zz;
+
+ CHECK_MEM_ERROR(arf_not_zz,
+ vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz), 1));
+
+ vpx_memset(arf_not_zz, 0, sizeof(arf_not_zz));
+
+ // We are not interested in results beyond the alt ref itself.
+ if (n_frames > cpi->frames_till_gf_update_due)
+ n_frames = cpi->frames_till_gf_update_due;
+
+ // defer cost to reference frames
+ for (i = n_frames - 1; i >= 0; i--) {
+ MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
- vpx_memset(ncnt, 0, sizeof(ncnt));
for (offset = 0, mb_row = 0; mb_row < cm->mb_rows;
- offset += cm->mb_cols, mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- // If any of the blocks in the sequence failed then the MB
- // goes in segment 0
- if ( arf_not_zz[offset + mb_col] )
- {
- ncnt[0]++;
- cpi->segmentation_map[offset + mb_col] = 0;
- }
- else
- {
- ncnt[1]++;
- cpi->segmentation_map[offset + mb_col] = 1;
- }
+ offset += cm->mb_cols, mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ MBGRAPH_MB_STATS *mb_stats =
+ &frame_stats->mb_stats[offset + mb_col];
+
+ int altref_err = mb_stats->ref[ALTREF_FRAME].err;
+ int intra_err = mb_stats->ref[INTRA_FRAME ].err;
+ int golden_err = mb_stats->ref[GOLDEN_FRAME].err;
+
+ // Test for altref vs intra and gf and that its mv was 0,0.
+ if ((altref_err > 1000) ||
+ (altref_err > intra_err) ||
+ (altref_err > golden_err)) {
+ arf_not_zz[offset + mb_col]++;
}
+ }
}
-
- // Only bother with segmentation if over 10% of the MBs in static segment
- //if ( ncnt[1] && (ncnt[0] / ncnt[1] < 10) )
- if ( 1 )
- {
- // Note % of blocks that are marked as static
- if ( cm->MBs )
- cpi->static_mb_pct = (ncnt[1] * 100) / cm->MBs;
-
- // This error case should not be reachable as this function should
- // never be called with the common data structure unititialized.
- else
- cpi->static_mb_pct = 0;
-
- cpi->seg0_cnt = ncnt[0];
- vp8_enable_segmentation((VP8_PTR) cpi);
+ }
+
+ vpx_memset(ncnt, 0, sizeof(ncnt));
+ for (offset = 0, mb_row = 0; mb_row < cm->mb_rows;
+ offset += cm->mb_cols, mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ // If any of the blocks in the sequence failed then the MB
+ // goes in segment 0
+ if (arf_not_zz[offset + mb_col]) {
+ ncnt[0]++;
+ cpi->segmentation_map[offset + mb_col] = 0;
+ } else {
+ ncnt[1]++;
+ cpi->segmentation_map[offset + mb_col] = 1;
+ }
}
+ }
+
+ // Only bother with segmentation if over 10% of the MBs in static segment
+ // if ( ncnt[1] && (ncnt[0] / ncnt[1] < 10) )
+ if (1) {
+ // Note % of blocks that are marked as static
+ if (cm->MBs)
+ cpi->static_mb_pct = (ncnt[1] * 100) / cm->MBs;
+
+ // This error case should not be reachable as this function should
+ // never be called with the common data structure unititialized.
else
- {
- cpi->static_mb_pct = 0;
- vp8_disable_segmentation((VP8_PTR) cpi);
- }
+ cpi->static_mb_pct = 0;
+
+ cpi->seg0_cnt = ncnt[0];
+ vp8_enable_segmentation((VP8_PTR) cpi);
+ } else {
+ cpi->static_mb_pct = 0;
+ vp8_disable_segmentation((VP8_PTR) cpi);
+ }
- // Free localy allocated storage
- vpx_free(arf_not_zz);
+ // Free localy allocated storage
+ vpx_free(arf_not_zz);
}
void vp8_update_mbgraph_stats
(
- VP8_COMP *cpi
-)
-{
- VP8_COMMON * const cm = &cpi->common;
- int i, n_frames = vp8_lookahead_depth(cpi->lookahead);
- YV12_BUFFER_CONFIG *golden_ref = &cm->yv12_fb[cm->gld_fb_idx];
-
- // we need to look ahead beyond where the ARF transitions into
- // being a GF - so exit if we don't look ahead beyond that
- if (n_frames <= cpi->frames_till_gf_update_due)
- return;
- if( n_frames > cpi->common.frames_till_alt_ref_frame)
- n_frames = cpi->common.frames_till_alt_ref_frame;
- if (n_frames > MAX_LAG_BUFFERS)
- n_frames = MAX_LAG_BUFFERS;
-
- cpi->mbgraph_n_frames = n_frames;
- for (i = 0; i < n_frames; i++)
- {
- MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
- vpx_memset(frame_stats->mb_stats, 0,
- cm->mb_rows * cm->mb_cols * sizeof(*cpi->mbgraph_stats[i].mb_stats));
- }
-
- // do motion search to find contribution of each reference to data
- // later on in this GF group
- // FIXME really, the GF/last MC search should be done forward, and
- // the ARF MC search backwards, to get optimal results for MV caching
- for (i = 0; i < n_frames; i++)
- {
- MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
- struct lookahead_entry *q_cur =
- vp8_lookahead_peek(cpi->lookahead, i);
-
- assert(q_cur != NULL);
-
- update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img,
- golden_ref, cpi->Source);
- }
-
- vp8_clear_system_state(); //__asm emms;
-
- separate_arf_mbs(cpi);
+ VP8_COMP *cpi
+) {
+ VP8_COMMON *const cm = &cpi->common;
+ int i, n_frames = vp8_lookahead_depth(cpi->lookahead);
+ YV12_BUFFER_CONFIG *golden_ref = &cm->yv12_fb[cm->gld_fb_idx];
+
+ // we need to look ahead beyond where the ARF transitions into
+ // being a GF - so exit if we don't look ahead beyond that
+ if (n_frames <= cpi->frames_till_gf_update_due)
+ return;
+ if (n_frames > cpi->common.frames_till_alt_ref_frame)
+ n_frames = cpi->common.frames_till_alt_ref_frame;
+ if (n_frames > MAX_LAG_BUFFERS)
+ n_frames = MAX_LAG_BUFFERS;
+
+ cpi->mbgraph_n_frames = n_frames;
+ for (i = 0; i < n_frames; i++) {
+ MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
+ vpx_memset(frame_stats->mb_stats, 0,
+ cm->mb_rows * cm->mb_cols * sizeof(*cpi->mbgraph_stats[i].mb_stats));
+ }
+
+ // do motion search to find contribution of each reference to data
+ // later on in this GF group
+ // FIXME really, the GF/last MC search should be done forward, and
+ // the ARF MC search backwards, to get optimal results for MV caching
+ for (i = 0; i < n_frames; i++) {
+ MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
+ struct lookahead_entry *q_cur =
+ vp8_lookahead_peek(cpi->lookahead, i);
+
+ assert(q_cur != NULL);
+
+ update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img,
+ golden_ref, cpi->Source);
+ }
+
+ vp8_clear_system_state(); // __asm emms;
+
+ separate_arf_mbs(cpi);
}
diff --git a/vp8/encoder/mcomp.c b/vp8/encoder/mcomp.c
index 698528d95..0b08ed3a9 100644
--- a/vp8/encoder/mcomp.c
+++ b/vp8/encoder/mcomp.c
@@ -23,178 +23,169 @@ static int mv_mode_cts [4] [2];
#endif
#if CONFIG_HIGH_PRECISION_MV
-int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight, int ishp)
-{
- // MV costing is based on the distribution of vectors in the previous frame and as such will tend to
- // over state the cost of vectors. In addition coding a new vector can have a knock on effect on the
- // cost of subsequent vectors and the quality of prediction from NEAR and NEAREST for subsequent blocks.
- // The "Weight" parameter allows, to a limited extent, for some account to be taken of these factors.
- return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp==0)] + mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp==0)]) * Weight) >> 7;
+int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight, int ishp) {
+ // MV costing is based on the distribution of vectors in the previous frame and as such will tend to
+ // over state the cost of vectors. In addition coding a new vector can have a knock on effect on the
+ // cost of subsequent vectors and the quality of prediction from NEAR and NEAREST for subsequent blocks.
+ // The "Weight" parameter allows, to a limited extent, for some account to be taken of these factors.
+ return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp == 0)] + mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp == 0)]) * Weight) >> 7;
}
#else
-int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight)
-{
- // MV costing is based on the distribution of vectors in the previous frame and as such will tend to
- // over state the cost of vectors. In addition coding a new vector can have a knock on effect on the
- // cost of subsequent vectors and the quality of prediction from NEAR and NEAREST for subsequent blocks.
- // The "Weight" parameter allows, to a limited extent, for some account to be taken of these factors.
- return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] + mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) * Weight) >> 7;
+int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight) {
+ // MV costing is based on the distribution of vectors in the previous frame and as such will tend to
+ // over state the cost of vectors. In addition coding a new vector can have a knock on effect on the
+ // cost of subsequent vectors and the quality of prediction from NEAR and NEAREST for subsequent blocks.
+ // The "Weight" parameter allows, to a limited extent, for some account to be taken of these factors.
+ return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] + mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) * Weight) >> 7;
}
#endif
#if CONFIG_HIGH_PRECISION_MV
-static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit, int ishp)
-{
- // Ignore costing if mvcost is NULL
- if (mvcost)
- return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp==0)] +
- mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp==0)])
- * error_per_bit + 128) >> 8;
- return 0;
+static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit, int ishp) {
+ // Ignore costing if mvcost is NULL
+ if (mvcost)
+ return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp == 0)] +
+ mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp == 0)])
+ * error_per_bit + 128) >> 8;
+ return 0;
}
#else
-static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit)
-{
- // Ignore costing if mvcost is NULL
- if (mvcost)
- return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] +
- mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1])
- * error_per_bit + 128) >> 8;
- return 0;
+static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit) {
+ // Ignore costing if mvcost is NULL
+ if (mvcost)
+ return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] +
+ mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1])
+ * error_per_bit + 128) >> 8;
+ return 0;
}
#endif
-static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvsadcost[2], int error_per_bit)
-{
- // Calculate sad error cost on full pixel basis.
- // Ignore costing if mvcost is NULL
- if (mvsadcost)
- return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] +
- mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)])
- * error_per_bit + 128) >> 8;
- return 0;
+static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvsadcost[2], int error_per_bit) {
+ // Calculate sad error cost on full pixel basis.
+ // Ignore costing if mvcost is NULL
+ if (mvsadcost)
+ return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] +
+ mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)])
+ * error_per_bit + 128) >> 8;
+ return 0;
}
-void vp8_init_dsmotion_compensation(MACROBLOCK *x, int stride)
-{
- int Len;
- int search_site_count = 0;
+void vp8_init_dsmotion_compensation(MACROBLOCK *x, int stride) {
+ int Len;
+ int search_site_count = 0;
- // Generate offsets for 4 search sites per step.
- Len = MAX_FIRST_STEP;
+ // Generate offsets for 4 search sites per step.
+ Len = MAX_FIRST_STEP;
+ x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = 0;
+ x->ss[search_site_count].offset = 0;
+ search_site_count++;
+
+ while (Len > 0) {
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = -Len;
+ x->ss[search_site_count].offset = -Len * stride;
+ search_site_count++;
+
+ // Compute offsets for search sites.
x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = Len;
+ x->ss[search_site_count].offset = Len * stride;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = -Len;
x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = 0;
+ x->ss[search_site_count].offset = -Len;
search_site_count++;
- while (Len > 0)
- {
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = 0;
- x->ss[search_site_count].mv.row = -Len;
- x->ss[search_site_count].offset = -Len * stride;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = 0;
- x->ss[search_site_count].mv.row = Len;
- x->ss[search_site_count].offset = Len * stride;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = -Len;
- x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = -Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = Len;
- x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = Len;
- search_site_count++;
-
- // Contract.
- Len /= 2;
- }
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = Len;
+ x->ss[search_site_count].mv.row = 0;
+ x->ss[search_site_count].offset = Len;
+ search_site_count++;
- x->ss_count = search_site_count;
- x->searches_per_step = 4;
+ // Contract.
+ Len /= 2;
+ }
+
+ x->ss_count = search_site_count;
+ x->searches_per_step = 4;
}
-void vp8_init3smotion_compensation(MACROBLOCK *x, int stride)
-{
- int Len;
- int search_site_count = 0;
+void vp8_init3smotion_compensation(MACROBLOCK *x, int stride) {
+ int Len;
+ int search_site_count = 0;
+
+ // Generate offsets for 8 search sites per step.
+ Len = MAX_FIRST_STEP;
+ x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = 0;
+ x->ss[search_site_count].offset = 0;
+ search_site_count++;
+
+ while (Len > 0) {
- // Generate offsets for 8 search sites per step.
- Len = MAX_FIRST_STEP;
+ // Compute offsets for search sites.
x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = -Len;
+ x->ss[search_site_count].offset = -Len * stride;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = 0;
+ x->ss[search_site_count].mv.row = Len;
+ x->ss[search_site_count].offset = Len * stride;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = -Len;
x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = 0;
+ x->ss[search_site_count].offset = -Len;
search_site_count++;
- while (Len > 0)
- {
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = 0;
- x->ss[search_site_count].mv.row = -Len;
- x->ss[search_site_count].offset = -Len * stride;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = 0;
- x->ss[search_site_count].mv.row = Len;
- x->ss[search_site_count].offset = Len * stride;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = -Len;
- x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = -Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = Len;
- x->ss[search_site_count].mv.row = 0;
- x->ss[search_site_count].offset = Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = -Len;
- x->ss[search_site_count].mv.row = -Len;
- x->ss[search_site_count].offset = -Len * stride - Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = Len;
- x->ss[search_site_count].mv.row = -Len;
- x->ss[search_site_count].offset = -Len * stride + Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = -Len;
- x->ss[search_site_count].mv.row = Len;
- x->ss[search_site_count].offset = Len * stride - Len;
- search_site_count++;
-
- // Compute offsets for search sites.
- x->ss[search_site_count].mv.col = Len;
- x->ss[search_site_count].mv.row = Len;
- x->ss[search_site_count].offset = Len * stride + Len;
- search_site_count++;
-
-
- // Contract.
- Len /= 2;
- }
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = Len;
+ x->ss[search_site_count].mv.row = 0;
+ x->ss[search_site_count].offset = Len;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = -Len;
+ x->ss[search_site_count].mv.row = -Len;
+ x->ss[search_site_count].offset = -Len * stride - Len;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = Len;
+ x->ss[search_site_count].mv.row = -Len;
+ x->ss[search_site_count].offset = -Len * stride + Len;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = -Len;
+ x->ss[search_site_count].mv.row = Len;
+ x->ss[search_site_count].offset = Len * stride - Len;
+ search_site_count++;
+
+ // Compute offsets for search sites.
+ x->ss[search_site_count].mv.col = Len;
+ x->ss[search_site_count].mv.row = Len;
+ x->ss[search_site_count].offset = Len * stride + Len;
+ search_site_count++;
- x->ss_count = search_site_count;
- x->searches_per_step = 8;
+
+ // Contract.
+ Len /= 2;
+ }
+
+ x->ss_count = search_site_count;
+ x->searches_per_step = 8;
}
/*
@@ -240,217 +231,209 @@ int vp8_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int error_per_bit,
const vp8_variance_fn_ptr_t *vfp,
int *mvcost[2], int *distortion,
- unsigned int *sse1)
-{
- unsigned char *z = (*(b->base_src) + b->src);
- MACROBLOCKD *xd = &x->e_mbd;
-
- int rr, rc, br, bc, hstep;
- int tr, tc;
- unsigned int besterr = INT_MAX;
- unsigned int left, right, up, down, diag;
- unsigned int sse;
- unsigned int whichdir;
- unsigned int halfiters = 4;
- unsigned int quarteriters = 4;
+ unsigned int *sse1) {
+ unsigned char *z = (*(b->base_src) + b->src);
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int rr, rc, br, bc, hstep;
+ int tr, tc;
+ unsigned int besterr = INT_MAX;
+ unsigned int left, right, up, down, diag;
+ unsigned int sse;
+ unsigned int whichdir;
+ unsigned int halfiters = 4;
+ unsigned int quarteriters = 4;
#if CONFIG_HIGH_PRECISION_MV
- unsigned int eighthiters = 4;
+ unsigned int eighthiters = 4;
#endif
- int thismse;
- int maxc, minc, maxr, minr;
- int y_stride;
- int offset;
+ int thismse;
+ int maxc, minc, maxr, minr;
+ int y_stride;
+ int offset;
#if ARCH_X86 || ARCH_X86_64
- unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- unsigned char *y;
- int buf_r1, buf_r2, buf_c1, buf_c2;
-
- // Clamping to avoid out-of-range data access
- buf_r1 = ((bestmv->as_mv.row - INTERP_EXTEND) < x->mv_row_min)?(bestmv->as_mv.row - x->mv_row_min):INTERP_EXTEND;
- buf_r2 = ((bestmv->as_mv.row + INTERP_EXTEND) > x->mv_row_max)?(x->mv_row_max - bestmv->as_mv.row):INTERP_EXTEND;
- buf_c1 = ((bestmv->as_mv.col - INTERP_EXTEND) < x->mv_col_min)?(bestmv->as_mv.col - x->mv_col_min):INTERP_EXTEND;
- buf_c2 = ((bestmv->as_mv.col + INTERP_EXTEND) > x->mv_col_max)?(x->mv_col_max - bestmv->as_mv.col):INTERP_EXTEND;
- y_stride = 32;
-
- /* Copy to intermediate buffer before searching. */
- vfp->copymem(y0 - buf_c1 - d->pre_stride*buf_r1, d->pre_stride, xd->y_buf, y_stride, 16+buf_r1+buf_r2);
- y = xd->y_buf + y_stride*buf_r1 +buf_c1;
+ unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ unsigned char *y;
+ int buf_r1, buf_r2, buf_c1, buf_c2;
+
+ // Clamping to avoid out-of-range data access
+ buf_r1 = ((bestmv->as_mv.row - INTERP_EXTEND) < x->mv_row_min) ? (bestmv->as_mv.row - x->mv_row_min) : INTERP_EXTEND;
+ buf_r2 = ((bestmv->as_mv.row + INTERP_EXTEND) > x->mv_row_max) ? (x->mv_row_max - bestmv->as_mv.row) : INTERP_EXTEND;
+ buf_c1 = ((bestmv->as_mv.col - INTERP_EXTEND) < x->mv_col_min) ? (bestmv->as_mv.col - x->mv_col_min) : INTERP_EXTEND;
+ buf_c2 = ((bestmv->as_mv.col + INTERP_EXTEND) > x->mv_col_max) ? (x->mv_col_max - bestmv->as_mv.col) : INTERP_EXTEND;
+ y_stride = 32;
+
+ /* Copy to intermediate buffer before searching. */
+ vfp->copymem(y0 - buf_c1 - d->pre_stride * buf_r1, d->pre_stride, xd->y_buf, y_stride, 16 + buf_r1 + buf_r2);
+ y = xd->y_buf + y_stride * buf_r1 + buf_c1;
#else
- unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- y_stride = d->pre_stride;
+ unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ y_stride = d->pre_stride;
#endif
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- rr = ref_mv->as_mv.row; rc = ref_mv->as_mv.col;
- br = bestmv->as_mv.row << 3; bc = bestmv->as_mv.col << 3;
- hstep = 4;
- minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) - ((1 << mvlong_width_hp) - 1));
- maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) + ((1 << mvlong_width_hp) - 1));
- minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) - ((1 << mvlong_width_hp) - 1));
- maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) + ((1 << mvlong_width_hp) - 1));
- }
- else
+ if (xd->allow_high_precision_mv) {
+ rr = ref_mv->as_mv.row;
+ rc = ref_mv->as_mv.col;
+ br = bestmv->as_mv.row << 3;
+ bc = bestmv->as_mv.col << 3;
+ hstep = 4;
+ minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) - ((1 << mvlong_width_hp) - 1));
+ maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) + ((1 << mvlong_width_hp) - 1));
+ minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) - ((1 << mvlong_width_hp) - 1));
+ maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) + ((1 << mvlong_width_hp) - 1));
+ } else
+#endif
+ {
+ rr = ref_mv->as_mv.row >> 1;
+ rc = ref_mv->as_mv.col >> 1;
+ br = bestmv->as_mv.row << 2;
+ bc = bestmv->as_mv.col << 2;
+ hstep = 2;
+ minc = MAX(x->mv_col_min << 2, (ref_mv->as_mv.col >> 1) - ((1 << mvlong_width) - 1));
+ maxc = MIN(x->mv_col_max << 2, (ref_mv->as_mv.col >> 1) + ((1 << mvlong_width) - 1));
+ minr = MAX(x->mv_row_min << 2, (ref_mv->as_mv.row >> 1) - ((1 << mvlong_width) - 1));
+ maxr = MIN(x->mv_row_max << 2, (ref_mv->as_mv.row >> 1) + ((1 << mvlong_width) - 1));
+ }
+
+ tr = br;
+ tc = bc;
+
+
+ offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
+
+ // central mv
+ bestmv->as_mv.row <<= 3;
+ bestmv->as_mv.col <<= 3;
+
+ // calculate central point error
+ besterr = vfp->vf(y, y_stride, z, b->src_stride, sse1);
+ *distortion = besterr;
+#if CONFIG_HIGH_PRECISION_MV
+ besterr += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+#else
+ besterr += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
#endif
- {
- rr = ref_mv->as_mv.row >> 1; rc = ref_mv->as_mv.col >> 1;
- br = bestmv->as_mv.row << 2; bc = bestmv->as_mv.col << 2;
- hstep = 2;
- minc = MAX(x->mv_col_min << 2, (ref_mv->as_mv.col >> 1) - ((1 << mvlong_width) - 1));
- maxc = MIN(x->mv_col_max << 2, (ref_mv->as_mv.col >> 1) + ((1 << mvlong_width) - 1));
- minr = MAX(x->mv_row_min << 2, (ref_mv->as_mv.row >> 1) - ((1 << mvlong_width) - 1));
- maxr = MIN(x->mv_row_max << 2, (ref_mv->as_mv.row >> 1) + ((1 << mvlong_width) - 1));
- }
- tr = br;
- tc = bc;
+ // TODO: Each subsequent iteration checks at least one point in common with the last iteration could be 2 ( if diag selected)
+ while (--halfiters) {
+ // 1/2 pel
+ CHECK_BETTER(left, tr, tc - hstep);
+ CHECK_BETTER(right, tr, tc + hstep);
+ CHECK_BETTER(up, tr - hstep, tc);
+ CHECK_BETTER(down, tr + hstep, tc);
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
- offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
+ switch (whichdir) {
+ case 0:
+ CHECK_BETTER(diag, tr - hstep, tc - hstep);
+ break;
+ case 1:
+ CHECK_BETTER(diag, tr - hstep, tc + hstep);
+ break;
+ case 2:
+ CHECK_BETTER(diag, tr + hstep, tc - hstep);
+ break;
+ case 3:
+ CHECK_BETTER(diag, tr + hstep, tc + hstep);
+ break;
+ }
- // central mv
- bestmv->as_mv.row <<= 3;
- bestmv->as_mv.col <<= 3;
+ // no reason to check the same one again.
+ if (tr == br && tc == bc)
+ break;
- // calculate central point error
- besterr = vfp->vf(y, y_stride, z, b->src_stride, sse1);
- *distortion = besterr;
-#if CONFIG_HIGH_PRECISION_MV
- besterr += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
-#else
- besterr += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
-#endif
+ tr = br;
+ tc = bc;
+ }
- // TODO: Each subsequent iteration checks at least one point in common with the last iteration could be 2 ( if diag selected)
- while (--halfiters)
- {
- // 1/2 pel
- CHECK_BETTER(left, tr, tc - hstep);
- CHECK_BETTER(right, tr, tc + hstep);
- CHECK_BETTER(up, tr - hstep, tc);
- CHECK_BETTER(down, tr + hstep, tc);
+ // TODO: Each subsequent iteration checks at least one point in common with the last iteration could be 2 ( if diag selected)
+ // 1/4 pel
+ hstep >>= 1;
+ while (--quarteriters) {
+ CHECK_BETTER(left, tr, tc - hstep);
+ CHECK_BETTER(right, tr, tc + hstep);
+ CHECK_BETTER(up, tr - hstep, tc);
+ CHECK_BETTER(down, tr + hstep, tc);
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
- switch (whichdir)
- {
- case 0:
- CHECK_BETTER(diag, tr - hstep, tc - hstep);
- break;
- case 1:
- CHECK_BETTER(diag, tr - hstep, tc + hstep);
- break;
- case 2:
- CHECK_BETTER(diag, tr + hstep, tc - hstep);
- break;
- case 3:
- CHECK_BETTER(diag, tr + hstep, tc + hstep);
- break;
- }
+ switch (whichdir) {
+ case 0:
+ CHECK_BETTER(diag, tr - hstep, tc - hstep);
+ break;
+ case 1:
+ CHECK_BETTER(diag, tr - hstep, tc + hstep);
+ break;
+ case 2:
+ CHECK_BETTER(diag, tr + hstep, tc - hstep);
+ break;
+ case 3:
+ CHECK_BETTER(diag, tr + hstep, tc + hstep);
+ break;
+ }
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
+ // no reason to check the same one again.
+ if (tr == br && tc == bc)
+ break;
- tr = br;
- tc = bc;
- }
+ tr = br;
+ tc = bc;
+ }
- // TODO: Each subsequent iteration checks at least one point in common with the last iteration could be 2 ( if diag selected)
- // 1/4 pel
+#if CONFIG_HIGH_PRECISION_MV
+ if (x->e_mbd.allow_high_precision_mv) {
hstep >>= 1;
- while (--quarteriters)
- {
- CHECK_BETTER(left, tr, tc - hstep);
- CHECK_BETTER(right, tr, tc + hstep);
- CHECK_BETTER(up, tr - hstep, tc);
- CHECK_BETTER(down, tr + hstep, tc);
+ while (--eighthiters) {
+ CHECK_BETTER(left, tr, tc - hstep);
+ CHECK_BETTER(right, tr, tc + hstep);
+ CHECK_BETTER(up, tr - hstep, tc);
+ CHECK_BETTER(down, tr + hstep, tc);
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
- switch (whichdir)
- {
+ switch (whichdir) {
case 0:
- CHECK_BETTER(diag, tr - hstep, tc - hstep);
- break;
+ CHECK_BETTER(diag, tr - hstep, tc - hstep);
+ break;
case 1:
- CHECK_BETTER(diag, tr - hstep, tc + hstep);
- break;
+ CHECK_BETTER(diag, tr - hstep, tc + hstep);
+ break;
case 2:
- CHECK_BETTER(diag, tr + hstep, tc - hstep);
- break;
+ CHECK_BETTER(diag, tr + hstep, tc - hstep);
+ break;
case 3:
- CHECK_BETTER(diag, tr + hstep, tc + hstep);
- break;
- }
+ CHECK_BETTER(diag, tr + hstep, tc + hstep);
+ break;
+ }
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
-
- tr = br;
- tc = bc;
- }
-
-#if CONFIG_HIGH_PRECISION_MV
- if (x->e_mbd.allow_high_precision_mv)
- {
- hstep >>= 1;
- while (--eighthiters)
- {
- CHECK_BETTER(left, tr, tc - hstep);
- CHECK_BETTER(right, tr, tc + hstep);
- CHECK_BETTER(up, tr - hstep, tc);
- CHECK_BETTER(down, tr + hstep, tc);
-
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
-
- switch (whichdir)
- {
- case 0:
- CHECK_BETTER(diag, tr - hstep, tc - hstep);
- break;
- case 1:
- CHECK_BETTER(diag, tr - hstep, tc + hstep);
- break;
- case 2:
- CHECK_BETTER(diag, tr + hstep, tc - hstep);
- break;
- case 3:
- CHECK_BETTER(diag, tr + hstep, tc + hstep);
- break;
- }
-
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
+ // no reason to check the same one again.
+ if (tr == br && tc == bc)
+ break;
- tr = br;
- tc = bc;
- }
+ tr = br;
+ tc = bc;
}
+ }
#endif
#if CONFIG_HIGH_PRECISION_MV
- if (x->e_mbd.allow_high_precision_mv)
- {
- bestmv->as_mv.row = br;
- bestmv->as_mv.col = bc;
- }
- else
+ if (x->e_mbd.allow_high_precision_mv) {
+ bestmv->as_mv.row = br;
+ bestmv->as_mv.col = bc;
+ } else
#endif /* CONFIG_HIGH_PRECISION_MV */
- {
- bestmv->as_mv.row = br << 1;
- bestmv->as_mv.col = bc << 1;
- }
+ {
+ bestmv->as_mv.row = br << 1;
+ bestmv->as_mv.col = bc << 1;
+ }
- if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL<<3)) ||
- (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL<<3)))
- return INT_MAX;
+ if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
+ (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
+ return INT_MAX;
- return besterr;
+ return besterr;
}
#undef MVC
#undef PRE
@@ -479,559 +462,494 @@ int vp8_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int error_per_bit,
const vp8_variance_fn_ptr_t *vfp,
int *mvcost[2], int *distortion,
- unsigned int *sse1)
-{
- int bestmse = INT_MAX;
- int_mv startmv;
- int_mv this_mv;
+ unsigned int *sse1) {
+ int bestmse = INT_MAX;
+ int_mv startmv;
+ int_mv this_mv;
#if CONFIG_HIGH_PRECISION_MV
- int_mv orig_mv;
- int yrow_movedback=0, ycol_movedback=0;
+ int_mv orig_mv;
+ int yrow_movedback = 0, ycol_movedback = 0;
#endif
- unsigned char *z = (*(b->base_src) + b->src);
- int left, right, up, down, diag;
- unsigned int sse;
- int whichdir ;
- int thismse;
- int y_stride;
- MACROBLOCKD *xd = &x->e_mbd;
+ unsigned char *z = (*(b->base_src) + b->src);
+ int left, right, up, down, diag;
+ unsigned int sse;
+ int whichdir;
+ int thismse;
+ int y_stride;
+ MACROBLOCKD *xd = &x->e_mbd;
#if ARCH_X86 || ARCH_X86_64
- unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- unsigned char *y;
+ unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ unsigned char *y;
- y_stride = 32;
- /* Copy 18 rows x 32 cols area to intermediate buffer before searching. */
- vfp->copymem(y0 - 1 - d->pre_stride, d->pre_stride, xd->y_buf, y_stride, 18);
- y = xd->y_buf + y_stride + 1;
+ y_stride = 32;
+ /* Copy 18 rows x 32 cols area to intermediate buffer before searching. */
+ vfp->copymem(y0 - 1 - d->pre_stride, d->pre_stride, xd->y_buf, y_stride, 18);
+ y = xd->y_buf + y_stride + 1;
#else
- unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- y_stride = d->pre_stride;
+ unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ y_stride = d->pre_stride;
#endif
- // central mv
- bestmv->as_mv.row <<= 3;
- bestmv->as_mv.col <<= 3;
- startmv = *bestmv;
+ // central mv
+ bestmv->as_mv.row <<= 3;
+ bestmv->as_mv.col <<= 3;
+ startmv = *bestmv;
#if CONFIG_HIGH_PRECISION_MV
- orig_mv = *bestmv;
+ orig_mv = *bestmv;
#endif
- // calculate central point error
- bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1);
- *distortion = bestmse;
+ // calculate central point error
+ bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1);
+ *distortion = bestmse;
#if CONFIG_HIGH_PRECISION_MV
- bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
+ bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
#endif
- // go left then right and check error
- this_mv.as_mv.row = startmv.as_mv.row;
- this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
- thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse);
+ // go left then right and check error
+ this_mv.as_mv.row = startmv.as_mv.row;
+ this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
+ thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (left < bestmse)
- {
- *bestmv = this_mv;
- bestmse = left;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (left < bestmse) {
+ *bestmv = this_mv;
+ bestmse = left;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.col += 8;
- thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse);
+ this_mv.as_mv.col += 8;
+ thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (right < bestmse)
- {
- *bestmv = this_mv;
- bestmse = right;
- *distortion = thismse;
- *sse1 = sse;
- }
-
- // go up then down and check error
- this_mv.as_mv.col = startmv.as_mv.col;
- this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
- thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse);
+ if (right < bestmse) {
+ *bestmv = this_mv;
+ bestmse = right;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
+
+ // go up then down and check error
+ this_mv.as_mv.col = startmv.as_mv.col;
+ this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
+ thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (up < bestmse)
- {
- *bestmv = this_mv;
- bestmse = up;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (up < bestmse) {
+ *bestmv = this_mv;
+ bestmse = up;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.row += 8;
- thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse);
+ this_mv.as_mv.row += 8;
+ thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (down < bestmse)
- {
- *bestmv = this_mv;
- bestmse = down;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (down < bestmse) {
+ *bestmv = this_mv;
+ bestmse = down;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- // now check 1 more diagonal
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
- //for(whichdir =0;whichdir<4;whichdir++)
- //{
- this_mv = startmv;
+ // now check 1 more diagonal
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ // for(whichdir =0;whichdir<4;whichdir++)
+ // {
+ this_mv = startmv;
- switch (whichdir)
- {
+ switch (whichdir) {
case 0:
- this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
- this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
- thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
+ this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
+ thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride, z, b->src_stride, &sse);
+ break;
case 1:
- this_mv.as_mv.col += 4;
- this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
- thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col += 4;
+ this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
+ thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride, z, b->src_stride, &sse);
+ break;
case 2:
- this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
- this_mv.as_mv.row += 4;
- thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
+ this_mv.as_mv.row += 4;
+ thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, b->src_stride, &sse);
+ break;
case 3:
default:
- this_mv.as_mv.col += 4;
- this_mv.as_mv.row += 4;
- thismse = vfp->svf_halfpix_hv(y, y_stride, z, b->src_stride, &sse);
- break;
- }
+ this_mv.as_mv.col += 4;
+ this_mv.as_mv.row += 4;
+ thismse = vfp->svf_halfpix_hv(y, y_stride, z, b->src_stride, &sse);
+ break;
+ }
#if CONFIG_HIGH_PRECISION_MV
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (diag < bestmse)
- {
- *bestmv = this_mv;
- bestmse = diag;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (diag < bestmse) {
+ *bestmv = this_mv;
+ bestmse = diag;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
// }
- // time to check quarter pels.
- if (bestmv->as_mv.row < startmv.as_mv.row)
- {
- y -= y_stride;
+ // time to check quarter pels.
+ if (bestmv->as_mv.row < startmv.as_mv.row) {
+ y -= y_stride;
#if CONFIG_HIGH_PRECISION_MV
- yrow_movedback = 1;
+ yrow_movedback = 1;
#endif
- }
+ }
- if (bestmv->as_mv.col < startmv.as_mv.col)
- {
- y--;
+ if (bestmv->as_mv.col < startmv.as_mv.col) {
+ y--;
#if CONFIG_HIGH_PRECISION_MV
- ycol_movedback = 1;
+ ycol_movedback = 1;
#endif
- }
+ }
- startmv = *bestmv;
+ startmv = *bestmv;
- // go left then right and check error
- this_mv.as_mv.row = startmv.as_mv.row;
+ // go left then right and check error
+ this_mv.as_mv.row = startmv.as_mv.row;
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col = startmv.as_mv.col - 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
- thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col = startmv.as_mv.col - 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
+ thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ }
#if CONFIG_HIGH_PRECISION_MV
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (left < bestmse)
- {
- *bestmv = this_mv;
- bestmse = left;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (left < bestmse) {
+ *bestmv = this_mv;
+ bestmse = left;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.col += 4;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ this_mv.as_mv.col += 4;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (right < bestmse)
- {
- *bestmv = this_mv;
- bestmse = right;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (right < bestmse) {
+ *bestmv = this_mv;
+ bestmse = right;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- // go up then down and check error
- this_mv.as_mv.col = startmv.as_mv.col;
+ // go up then down and check error
+ this_mv.as_mv.col = startmv.as_mv.col;
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row = startmv.as_mv.row - 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row = startmv.as_mv.row - 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
+ }
#if CONFIG_HIGH_PRECISION_MV
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (up < bestmse)
- {
- *bestmv = this_mv;
- bestmse = up;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (up < bestmse) {
+ *bestmv = this_mv;
+ bestmse = up;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.row += 4;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ this_mv.as_mv.row += 4;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (down < bestmse)
- {
- *bestmv = this_mv;
- bestmse = down;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (down < bestmse) {
+ *bestmv = this_mv;
+ bestmse = down;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- // now check 1 more diagonal
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ // now check 1 more diagonal
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
// for(whichdir=0;whichdir<4;whichdir++)
// {
- this_mv = startmv;
+ this_mv = startmv;
- switch (whichdir)
- {
+ switch (whichdir) {
case 0:
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row -= 2;
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row -= 2;
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
- thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);;
- }
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
+ thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);;
}
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
-
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 2;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
- thismse = vfp->svf(y - y_stride - 1, y_stride, SP(6), SP(6), z, b->src_stride, &sse);
- }
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
+
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 2;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
+ thismse = vfp->svf(y - y_stride - 1, y_stride, SP(6), SP(6), z, b->src_stride, &sse);
}
+ }
- break;
+ break;
case 1:
- this_mv.as_mv.col += 2;
+ this_mv.as_mv.col += 2;
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row -= 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row -= 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6), z, b->src_stride, &sse);
+ }
- break;
+ break;
case 2:
- this_mv.as_mv.row += 2;
+ this_mv.as_mv.row += 2;
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
- thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
+ thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ }
- break;
+ break;
case 3:
- this_mv.as_mv.col += 2;
- this_mv.as_mv.row += 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- break;
- }
+ this_mv.as_mv.col += 2;
+ this_mv.as_mv.row += 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ break;
+ }
#if CONFIG_HIGH_PRECISION_MV
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (diag < bestmse)
- {
- *bestmv = this_mv;
- bestmse = diag;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (diag < bestmse) {
+ *bestmv = this_mv;
+ bestmse = diag;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
#if CONFIG_HIGH_PRECISION_MV
- if (!x->e_mbd.allow_high_precision_mv)
- return bestmse;
-
- /* Now do 1/8th pixel */
- if (bestmv->as_mv.row < orig_mv.as_mv.row && !yrow_movedback)
- {
- y -= y_stride;
- yrow_movedback = 1;
- }
-
- if (bestmv->as_mv.col < orig_mv.as_mv.col && !ycol_movedback)
- {
- y--;
- ycol_movedback = 1;
- }
-
- startmv = *bestmv;
+ if (!x->e_mbd.allow_high_precision_mv)
+ return bestmse;
- // go left then right and check error
- this_mv.as_mv.row = startmv.as_mv.row;
+ /* Now do 1/8th pixel */
+ if (bestmv->as_mv.row < orig_mv.as_mv.row && !yrow_movedback) {
+ y -= y_stride;
+ yrow_movedback = 1;
+ }
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col = startmv.as_mv.col - 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
- thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
+ if (bestmv->as_mv.col < orig_mv.as_mv.col && !ycol_movedback) {
+ y--;
+ ycol_movedback = 1;
+ }
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ startmv = *bestmv;
- if (left < bestmse)
- {
- *bestmv = this_mv;
- bestmse = left;
- *distortion = thismse;
- *sse1 = sse;
- }
+ // go left then right and check error
+ this_mv.as_mv.row = startmv.as_mv.row;
- this_mv.as_mv.col += 2;
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col = startmv.as_mv.col - 1;
thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
-
- if (right < bestmse)
- {
- *bestmv = this_mv;
- bestmse = right;
- *distortion = thismse;
- *sse1 = sse;
- }
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
+ thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ }
+
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+
+ if (left < bestmse) {
+ *bestmv = this_mv;
+ bestmse = left;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
+
+ this_mv.as_mv.col += 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+
+ if (right < bestmse) {
+ *bestmv = this_mv;
+ bestmse = right;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
+
+ // go up then down and check error
+ this_mv.as_mv.col = startmv.as_mv.col;
+
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row = startmv.as_mv.row - 1;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
+ }
- // go up then down and check error
- this_mv.as_mv.col = startmv.as_mv.col;
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row = startmv.as_mv.row - 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
- }
+ if (up < bestmse) {
+ *bestmv = this_mv;
+ bestmse = up;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ this_mv.as_mv.row += 2;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
- if (up < bestmse)
- {
- *bestmv = this_mv;
- bestmse = up;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (down < bestmse) {
+ *bestmv = this_mv;
+ bestmse = down;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.row += 2;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
-
- if (down < bestmse)
- {
- *bestmv = this_mv;
- bestmse = down;
- *distortion = thismse;
- *sse1 = sse;
- }
-
- // now check 1 more diagonal
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ // now check 1 more diagonal
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
// for(whichdir=0;whichdir<4;whichdir++)
// {
- this_mv = startmv;
+ this_mv = startmv;
- switch (whichdir)
- {
+ switch (whichdir) {
case 0:
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row -= 1;
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row -= 1;
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
- thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);;
- }
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 1;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
+ thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);;
}
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
-
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 1;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
- thismse = vfp->svf(y - y_stride - 1, y_stride, SP(7), SP(7), z, b->src_stride, &sse);
- }
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
+
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 1;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
+ thismse = vfp->svf(y - y_stride - 1, y_stride, SP(7), SP(7), z, b->src_stride, &sse);
}
+ }
- break;
+ break;
case 1:
- this_mv.as_mv.col += 1;
+ this_mv.as_mv.col += 1;
- if (startmv.as_mv.row & 7)
- {
- this_mv.as_mv.row -= 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
- thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.row & 7) {
+ this_mv.as_mv.row -= 1;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
+ thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse);
+ }
- break;
+ break;
case 2:
- this_mv.as_mv.row += 1;
+ this_mv.as_mv.row += 1;
- if (startmv.as_mv.col & 7)
- {
- this_mv.as_mv.col -= 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
- else
- {
- this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
- thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- }
+ if (startmv.as_mv.col & 7) {
+ this_mv.as_mv.col -= 1;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ } else {
+ this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
+ thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ }
- break;
+ break;
case 3:
- this_mv.as_mv.col += 1;
- this_mv.as_mv.row += 1;
- thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
- break;
- }
+ this_mv.as_mv.col += 1;
+ this_mv.as_mv.row += 1;
+ thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse);
+ break;
+ }
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
- if (diag < bestmse)
- {
- *bestmv = this_mv;
- bestmse = diag;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (diag < bestmse) {
+ *bestmv = this_mv;
+ bestmse = diag;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
#endif /* CONFIG_HIGH_PRECISION_MV */
- return bestmse;
+ return bestmse;
}
#undef SP
@@ -1041,369 +959,343 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int error_per_bit,
const vp8_variance_fn_ptr_t *vfp,
int *mvcost[2], int *distortion,
- unsigned int *sse1)
-{
- int bestmse = INT_MAX;
- int_mv startmv;
- int_mv this_mv;
- unsigned char *z = (*(b->base_src) + b->src);
- int left, right, up, down, diag;
- unsigned int sse;
- int whichdir ;
- int thismse;
- int y_stride;
- MACROBLOCKD *xd = &x->e_mbd;
+ unsigned int *sse1) {
+ int bestmse = INT_MAX;
+ int_mv startmv;
+ int_mv this_mv;
+ unsigned char *z = (*(b->base_src) + b->src);
+ int left, right, up, down, diag;
+ unsigned int sse;
+ int whichdir;
+ int thismse;
+ int y_stride;
+ MACROBLOCKD *xd = &x->e_mbd;
#if ARCH_X86 || ARCH_X86_64
- unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- unsigned char *y;
+ unsigned char *y0 = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ unsigned char *y;
- y_stride = 32;
- /* Copy 18 rows x 32 cols area to intermediate buffer before searching. */
- vfp->copymem(y0 - 1 - d->pre_stride, d->pre_stride, xd->y_buf, y_stride, 18);
- y = xd->y_buf + y_stride + 1;
+ y_stride = 32;
+ /* Copy 18 rows x 32 cols area to intermediate buffer before searching. */
+ vfp->copymem(y0 - 1 - d->pre_stride, d->pre_stride, xd->y_buf, y_stride, 18);
+ y = xd->y_buf + y_stride + 1;
#else
- unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
- y_stride = d->pre_stride;
+ unsigned char *y = *(d->base_pre) + d->pre + (bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
+ y_stride = d->pre_stride;
#endif
- // central mv
- bestmv->as_mv.row <<= 3;
- bestmv->as_mv.col <<= 3;
- startmv = *bestmv;
+ // central mv
+ bestmv->as_mv.row <<= 3;
+ bestmv->as_mv.col <<= 3;
+ startmv = *bestmv;
- // calculate central point error
- bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1);
- *distortion = bestmse;
+ // calculate central point error
+ bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1);
+ *distortion = bestmse;
#if CONFIG_HIGH_PRECISION_MV
- bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
+ bestmse += mv_err_cost(bestmv, ref_mv, mvcost, error_per_bit);
#endif
- // go left then right and check error
- this_mv.as_mv.row = startmv.as_mv.row;
- this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
- thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse);
+ // go left then right and check error
+ this_mv.as_mv.row = startmv.as_mv.row;
+ this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
+ thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ left = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (left < bestmse)
- {
- *bestmv = this_mv;
- bestmse = left;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (left < bestmse) {
+ *bestmv = this_mv;
+ bestmse = left;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.col += 8;
- thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse);
+ this_mv.as_mv.col += 8;
+ thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ right = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (right < bestmse)
- {
- *bestmv = this_mv;
- bestmse = right;
- *distortion = thismse;
- *sse1 = sse;
- }
-
- // go up then down and check error
- this_mv.as_mv.col = startmv.as_mv.col;
- this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
- thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse);
+ if (right < bestmse) {
+ *bestmv = this_mv;
+ bestmse = right;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
+
+ // go up then down and check error
+ this_mv.as_mv.col = startmv.as_mv.col;
+ this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
+ thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ up = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (up < bestmse)
- {
- *bestmv = this_mv;
- bestmse = up;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (up < bestmse) {
+ *bestmv = this_mv;
+ bestmse = up;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- this_mv.as_mv.row += 8;
- thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse);
+ this_mv.as_mv.row += 8;
+ thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse);
#if CONFIG_HIGH_PRECISION_MV
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ down = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (down < bestmse)
- {
- *bestmv = this_mv;
- bestmse = down;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (down < bestmse) {
+ *bestmv = this_mv;
+ bestmse = down;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- // now check 1 more diagonal -
- whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
- this_mv = startmv;
+ // now check 1 more diagonal -
+ whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
+ this_mv = startmv;
- switch (whichdir)
- {
+ switch (whichdir) {
case 0:
- this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
- this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
- thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
+ this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
+ thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride, z, b->src_stride, &sse);
+ break;
case 1:
- this_mv.as_mv.col += 4;
- this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
- thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col += 4;
+ this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
+ thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride, z, b->src_stride, &sse);
+ break;
case 2:
- this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
- this_mv.as_mv.row += 4;
- thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, b->src_stride, &sse);
- break;
+ this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
+ this_mv.as_mv.row += 4;
+ thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, b->src_stride, &sse);
+ break;
case 3:
default:
- this_mv.as_mv.col += 4;
- this_mv.as_mv.row += 4;
- thismse = vfp->svf_halfpix_hv(y, y_stride, z, b->src_stride, &sse);
- break;
- }
+ this_mv.as_mv.col += 4;
+ this_mv.as_mv.row += 4;
+ thismse = vfp->svf_halfpix_hv(y, y_stride, z, b->src_stride, &sse);
+ break;
+ }
#if CONFIG_HIGH_PRECISION_MV
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit, xd->allow_high_precision_mv);
#else
- diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
+ diag = thismse + mv_err_cost(&this_mv, ref_mv, mvcost, error_per_bit);
#endif
- if (diag < bestmse)
- {
- *bestmv = this_mv;
- bestmse = diag;
- *distortion = thismse;
- *sse1 = sse;
- }
+ if (diag < bestmse) {
+ *bestmv = this_mv;
+ bestmse = diag;
+ *distortion = thismse;
+ *sse1 = sse;
+ }
- return bestmse;
+ return bestmse;
}
#define CHECK_BOUNDS(range) \
-{\
+ {\
all_in = 1;\
all_in &= ((br-range) >= x->mv_row_min);\
all_in &= ((br+range) <= x->mv_row_max);\
all_in &= ((bc-range) >= x->mv_col_min);\
all_in &= ((bc+range) <= x->mv_col_max);\
-}
+ }
#define CHECK_POINT \
-{\
+ {\
if (this_mv.as_mv.col < x->mv_col_min) continue;\
if (this_mv.as_mv.col > x->mv_col_max) continue;\
if (this_mv.as_mv.row < x->mv_row_min) continue;\
if (this_mv.as_mv.row > x->mv_row_max) continue;\
-}
+ }
#define CHECK_BETTER \
-{\
+ {\
if (thissad < bestsad)\
{\
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);\
- if (thissad < bestsad)\
- {\
- bestsad = thissad;\
- best_site = i;\
- }\
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);\
+ if (thissad < bestsad)\
+ {\
+ bestsad = thissad;\
+ best_site = i;\
+ }\
}\
-}
-
-static const MV next_chkpts[6][3] =
-{
- {{ -2, 0}, { -1, -2}, {1, -2}},
- {{ -1, -2}, {1, -2}, {2, 0}},
- {{1, -2}, {2, 0}, {1, 2}},
- {{2, 0}, {1, 2}, { -1, 2}},
- {{1, 2}, { -1, 2}, { -2, 0}},
- {{ -1, 2}, { -2, 0}, { -1, -2}}
+ }
+
+static const MV next_chkpts[6][3] = {
+ {{ -2, 0}, { -1, -2}, {1, -2}},
+ {{ -1, -2}, {1, -2}, {2, 0}},
+ {{1, -2}, {2, 0}, {1, 2}},
+ {{2, 0}, {1, 2}, { -1, 2}},
+ {{1, 2}, { -1, 2}, { -2, 0}},
+ {{ -1, 2}, { -2, 0}, { -1, -2}}
};
int vp8_hex_search
(
- MACROBLOCK *x,
- BLOCK *b,
- BLOCKD *d,
- int_mv *ref_mv,
- int_mv *best_mv,
- int search_param,
- int sad_per_bit,
- const vp8_variance_fn_ptr_t *vfp,
- int *mvsadcost[2],
- int *mvcost[2],
- int_mv *center_mv
-)
-{
- MV hex[6] = { { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0} } ;
- MV neighbors[4] = {{0, -1}, { -1, 0}, {1, 0}, {0, 1}} ;
- int i, j;
-
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- int in_what_stride = d->pre_stride;
- int br, bc;
- int_mv this_mv;
- unsigned int bestsad = 0x7fffffff;
- unsigned int thissad;
- unsigned char *base_offset;
- unsigned char *this_offset;
- int k = -1;
- int all_in;
- int best_site = -1;
-
- int_mv fcenter_mv;
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- // adjust ref_mv to make sure it is within MV range
- vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- br = ref_mv->as_mv.row;
- bc = ref_mv->as_mv.col;
-
- // Work out the start point for the search
- base_offset = (unsigned char *)(*(d->base_pre) + d->pre);
- this_offset = base_offset + (br * (d->pre_stride)) + bc;
- this_mv.as_mv.row = br;
- this_mv.as_mv.col = bc;
- bestsad = vfp->sdf( what, what_stride, this_offset,
- in_what_stride, 0x7fffffff)
+ MACROBLOCK *x,
+ BLOCK *b,
+ BLOCKD *d,
+ int_mv *ref_mv,
+ int_mv *best_mv,
+ int search_param,
+ int sad_per_bit,
+ const vp8_variance_fn_ptr_t *vfp,
+ int *mvsadcost[2],
+ int *mvcost[2],
+ int_mv *center_mv
+) {
+ MV hex[6] = { { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0} };
+ MV neighbors[4] = {{0, -1}, { -1, 0}, {1, 0}, {0, 1}};
+ int i, j;
+
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ int in_what_stride = d->pre_stride;
+ int br, bc;
+ int_mv this_mv;
+ unsigned int bestsad = 0x7fffffff;
+ unsigned int thissad;
+ unsigned char *base_offset;
+ unsigned char *this_offset;
+ int k = -1;
+ int all_in;
+ int best_site = -1;
+
+ int_mv fcenter_mv;
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ // adjust ref_mv to make sure it is within MV range
+ vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ br = ref_mv->as_mv.row;
+ bc = ref_mv->as_mv.col;
+
+ // Work out the start point for the search
+ base_offset = (unsigned char *)(*(d->base_pre) + d->pre);
+ this_offset = base_offset + (br * (d->pre_stride)) + bc;
+ this_mv.as_mv.row = br;
+ this_mv.as_mv.col = bc;
+ bestsad = vfp->sdf(what, what_stride, this_offset,
+ in_what_stride, 0x7fffffff)
+ mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
- // hex search
- //j=0
+ // hex search
+ // j=0
+ CHECK_BOUNDS(2)
+
+ if (all_in) {
+ for (i = 0; i < 6; i++) {
+ this_mv.as_mv.row = br + hex[i].row;
+ this_mv.as_mv.col = bc + hex[i].col;
+ this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
+ } else {
+ for (i = 0; i < 6; i++) {
+ this_mv.as_mv.row = br + hex[i].row;
+ this_mv.as_mv.col = bc + hex[i].col;
+ CHECK_POINT
+ this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
+ }
+
+ if (best_site == -1)
+ goto cal_neighbors;
+ else {
+ br += hex[best_site].row;
+ bc += hex[best_site].col;
+ k = best_site;
+ }
+
+ for (j = 1; j < 127; j++) {
+ best_site = -1;
CHECK_BOUNDS(2)
- if(all_in)
- {
- for (i = 0; i < 6; i++)
- {
- this_mv.as_mv.row = br + hex[i].row;
- this_mv.as_mv.col = bc + hex[i].col;
- this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv.as_mv.col;
- thissad=vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
- }else
- {
- for (i = 0; i < 6; i++)
- {
- this_mv.as_mv.row = br + hex[i].row;
- this_mv.as_mv.col = bc + hex[i].col;
- CHECK_POINT
- this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv.as_mv.col;
- thissad=vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
+ if (all_in) {
+ for (i = 0; i < 3; i++) {
+ this_mv.as_mv.row = br + next_chkpts[k][i].row;
+ this_mv.as_mv.col = bc + next_chkpts[k][i].col;
+ this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
+ } else {
+ for (i = 0; i < 3; i++) {
+ this_mv.as_mv.row = br + next_chkpts[k][i].row;
+ this_mv.as_mv.col = bc + next_chkpts[k][i].col;
+ CHECK_POINT
+ this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
}
if (best_site == -1)
- goto cal_neighbors;
- else
- {
- br += hex[best_site].row;
- bc += hex[best_site].col;
- k = best_site;
+ break;
+ else {
+ br += next_chkpts[k][best_site].row;
+ bc += next_chkpts[k][best_site].col;
+ k += 5 + best_site;
+ if (k >= 12) k -= 12;
+ else if (k >= 6) k -= 6;
}
+ }
- for (j = 1; j < 127; j++)
- {
- best_site = -1;
- CHECK_BOUNDS(2)
-
- if(all_in)
- {
- for (i = 0; i < 3; i++)
- {
- this_mv.as_mv.row = br + next_chkpts[k][i].row;
- this_mv.as_mv.col = bc + next_chkpts[k][i].col;
- this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
- thissad = vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
- }else
- {
- for (i = 0; i < 3; i++)
- {
- this_mv.as_mv.row = br + next_chkpts[k][i].row;
- this_mv.as_mv.col = bc + next_chkpts[k][i].col;
- CHECK_POINT
- this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
- thissad = vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
- }
-
- if (best_site == -1)
- break;
- else
- {
- br += next_chkpts[k][best_site].row;
- bc += next_chkpts[k][best_site].col;
- k += 5 + best_site;
- if (k >= 12) k -= 12;
- else if (k >= 6) k -= 6;
- }
- }
-
- // check 4 1-away neighbors
+ // check 4 1-away neighbors
cal_neighbors:
- for (j = 0; j < 32; j++)
- {
- best_site = -1;
- CHECK_BOUNDS(1)
-
- if(all_in)
- {
- for (i = 0; i < 4; i++)
- {
- this_mv.as_mv.row = br + neighbors[i].row;
- this_mv.as_mv.col = bc + neighbors[i].col;
- this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
- thissad = vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
- }else
- {
- for (i = 0; i < 4; i++)
- {
- this_mv.as_mv.row = br + neighbors[i].row;
- this_mv.as_mv.col = bc + neighbors[i].col;
- CHECK_POINT
- this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
- thissad = vfp->sdf( what, what_stride, this_offset, in_what_stride, bestsad);
- CHECK_BETTER
- }
- }
+ for (j = 0; j < 32; j++) {
+ best_site = -1;
+ CHECK_BOUNDS(1)
+
+ if (all_in) {
+ for (i = 0; i < 4; i++) {
+ this_mv.as_mv.row = br + neighbors[i].row;
+ this_mv.as_mv.col = bc + neighbors[i].col;
+ this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
+ } else {
+ for (i = 0; i < 4; i++) {
+ this_mv.as_mv.row = br + neighbors[i].row;
+ this_mv.as_mv.col = bc + neighbors[i].col;
+ CHECK_POINT
+ this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + this_mv.as_mv.col;
+ thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad);
+ CHECK_BETTER
+ }
+ }
- if (best_site == -1)
- break;
- else
- {
- br += neighbors[best_site].row;
- bc += neighbors[best_site].col;
- }
+ if (best_site == -1)
+ break;
+ else {
+ br += neighbors[best_site].row;
+ bc += neighbors[best_site].col;
}
+ }
- best_mv->as_mv.row = br;
- best_mv->as_mv.col = bc;
+ best_mv->as_mv.row = br;
+ best_mv->as_mv.col = bc;
- return bestsad;
+ return bestsad;
}
#undef CHECK_BOUNDS
#undef CHECK_POINT
@@ -1411,1040 +1303,948 @@ cal_neighbors:
int vp8_diamond_search_sad
(
- MACROBLOCK *x,
- BLOCK *b,
- BLOCKD *d,
- int_mv *ref_mv,
- int_mv *best_mv,
- int search_param,
- int sad_per_bit,
- int *num00,
- vp8_variance_fn_ptr_t *fn_ptr,
- int *mvcost[2],
- int_mv *center_mv
-)
-{
- int i, j, step;
-
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- unsigned char *in_what;
- int in_what_stride = d->pre_stride;
- unsigned char *best_address;
-
- int tot_steps;
- int_mv this_mv;
-
- int bestsad = INT_MAX;
- int best_site = 0;
- int last_site = 0;
-
- int ref_row;
- int ref_col;
- int this_row_offset;
- int this_col_offset;
- search_site *ss;
-
- unsigned char *check_here;
- int thissad;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ MACROBLOCK *x,
+ BLOCK *b,
+ BLOCKD *d,
+ int_mv *ref_mv,
+ int_mv *best_mv,
+ int search_param,
+ int sad_per_bit,
+ int *num00,
+ vp8_variance_fn_ptr_t *fn_ptr,
+ int *mvcost[2],
+ int_mv *center_mv
+) {
+ int i, j, step;
+
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ unsigned char *in_what;
+ int in_what_stride = d->pre_stride;
+ unsigned char *best_address;
+
+ int tot_steps;
+ int_mv this_mv;
+
+ int bestsad = INT_MAX;
+ int best_site = 0;
+ int last_site = 0;
+
+ int ref_row;
+ int ref_col;
+ int this_row_offset;
+ int this_col_offset;
+ search_site *ss;
+
+ unsigned char *check_here;
+ int thissad;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- ref_row = ref_mv->as_mv.row;
- ref_col = ref_mv->as_mv.col;
- *num00 = 0;
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
-
- // Work out the start point for the search
- in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
- best_address = in_what;
-
- // Check the starting position
- bestsad = fn_ptr->sdf(what, what_stride, in_what,
- in_what_stride, 0x7fffffff)
- + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
-
- // search_param determines the length of the initial step and hence the number of iterations
- // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc.
- ss = &x->ss[search_param * x->searches_per_step];
- tot_steps = (x->ss_count / x->searches_per_step) - search_param;
-
- i = 1;
-
- for (step = 0; step < tot_steps ; step++)
- {
- for (j = 0 ; j < x->searches_per_step ; j++)
- {
- // Trap illegal vectors
- this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
-
- if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
- (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max))
-
- {
- check_here = ss[i].offset + best_address;
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_site = i;
- }
- }
- }
-
- i++;
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ ref_row = ref_mv->as_mv.row;
+ ref_col = ref_mv->as_mv.col;
+ *num00 = 0;
+ best_mv->as_mv.row = ref_row;
+ best_mv->as_mv.col = ref_col;
+
+ // Work out the start point for the search
+ in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
+ best_address = in_what;
+
+ // Check the starting position
+ bestsad = fn_ptr->sdf(what, what_stride, in_what,
+ in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+
+ // search_param determines the length of the initial step and hence the number of iterations
+ // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc.
+ ss = &x->ss[search_param * x->searches_per_step];
+ tot_steps = (x->ss_count / x->searches_per_step) - search_param;
+
+ i = 1;
+
+ for (step = 0; step < tot_steps; step++) {
+ for (j = 0; j < x->searches_per_step; j++) {
+ // Trap illegal vectors
+ this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
+ this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
+
+ if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
+ (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max))
+
+ {
+ check_here = ss[i].offset + best_address;
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.row = this_row_offset;
+ this_mv.as_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = i;
+ }
}
+ }
- if (best_site != last_site)
- {
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
- best_address += ss[best_site].offset;
- last_site = best_site;
- }
- else if (best_address == in_what)
- (*num00)++;
+ i++;
}
- this_mv.as_mv.row = best_mv->as_mv.row << 3;
- this_mv.as_mv.col = best_mv->as_mv.col << 3;
+ if (best_site != last_site) {
+ best_mv->as_mv.row += ss[best_site].mv.row;
+ best_mv->as_mv.col += ss[best_site].mv.col;
+ best_address += ss[best_site].offset;
+ last_site = best_site;
+ } else if (best_address == in_what)
+ (*num00)++;
+ }
- if (bestsad == INT_MAX)
- return INT_MAX;
+ this_mv.as_mv.row = best_mv->as_mv.row << 3;
+ this_mv.as_mv.col = best_mv->as_mv.col << 3;
- return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad == INT_MAX)
+ return INT_MAX;
+
+ return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
}
int vp8_diamond_search_sadx4
(
- MACROBLOCK *x,
- BLOCK *b,
- BLOCKD *d,
- int_mv *ref_mv,
- int_mv *best_mv,
- int search_param,
- int sad_per_bit,
- int *num00,
- vp8_variance_fn_ptr_t *fn_ptr,
- int *mvcost[2],
- int_mv *center_mv
-)
-{
- int i, j, step;
-
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- unsigned char *in_what;
- int in_what_stride = d->pre_stride;
- unsigned char *best_address;
-
- int tot_steps;
- int_mv this_mv;
-
- int bestsad = INT_MAX;
- int best_site = 0;
- int last_site = 0;
-
- int ref_row;
- int ref_col;
- int this_row_offset;
- int this_col_offset;
- search_site *ss;
-
- unsigned char *check_here;
- unsigned int thissad;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ MACROBLOCK *x,
+ BLOCK *b,
+ BLOCKD *d,
+ int_mv *ref_mv,
+ int_mv *best_mv,
+ int search_param,
+ int sad_per_bit,
+ int *num00,
+ vp8_variance_fn_ptr_t *fn_ptr,
+ int *mvcost[2],
+ int_mv *center_mv
+) {
+ int i, j, step;
+
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ unsigned char *in_what;
+ int in_what_stride = d->pre_stride;
+ unsigned char *best_address;
+
+ int tot_steps;
+ int_mv this_mv;
+
+ int bestsad = INT_MAX;
+ int best_site = 0;
+ int last_site = 0;
+
+ int ref_row;
+ int ref_col;
+ int this_row_offset;
+ int this_col_offset;
+ search_site *ss;
+
+ unsigned char *check_here;
+ unsigned int thissad;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- ref_row = ref_mv->as_mv.row;
- ref_col = ref_mv->as_mv.col;
- *num00 = 0;
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
-
- // Work out the start point for the search
- in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
- best_address = in_what;
-
- // Check the starting position
- bestsad = fn_ptr->sdf(what, what_stride,
- in_what, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
-
- // search_param determines the length of the initial step and hence the number of iterations
- // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc.
- ss = &x->ss[search_param * x->searches_per_step];
- tot_steps = (x->ss_count / x->searches_per_step) - search_param;
-
- i = 1;
-
- for (step = 0; step < tot_steps ; step++)
- {
- int all_in = 1, t;
-
- // To know if all neighbor points are within the bounds, 4 bounds checking are enough instead of
- // checking 4 bounds for each points.
- all_in &= ((best_mv->as_mv.row + ss[i].mv.row)> x->mv_row_min);
- all_in &= ((best_mv->as_mv.row + ss[i+1].mv.row) < x->mv_row_max);
- all_in &= ((best_mv->as_mv.col + ss[i+2].mv.col) > x->mv_col_min);
- all_in &= ((best_mv->as_mv.col + ss[i+3].mv.col) < x->mv_col_max);
-
- if (all_in)
- {
- unsigned int sad_array[4];
-
- for (j = 0 ; j < x->searches_per_step ; j += 4)
- {
- unsigned char *block_offset[4];
-
- for (t = 0; t < 4; t++)
- block_offset[t] = ss[i+t].offset + best_address;
-
- fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, sad_array);
-
- for (t = 0; t < 4; t++, i++)
- {
- if (sad_array[t] < bestsad)
- {
- this_mv.as_mv.row = best_mv->as_mv.row + ss[i].mv.row;
- this_mv.as_mv.col = best_mv->as_mv.col + ss[i].mv.col;
- sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (sad_array[t] < bestsad)
- {
- bestsad = sad_array[t];
- best_site = i;
- }
- }
- }
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ ref_row = ref_mv->as_mv.row;
+ ref_col = ref_mv->as_mv.col;
+ *num00 = 0;
+ best_mv->as_mv.row = ref_row;
+ best_mv->as_mv.col = ref_col;
+
+ // Work out the start point for the search
+ in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
+ best_address = in_what;
+
+ // Check the starting position
+ bestsad = fn_ptr->sdf(what, what_stride,
+ in_what, in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+
+ // search_param determines the length of the initial step and hence the number of iterations
+ // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc.
+ ss = &x->ss[search_param * x->searches_per_step];
+ tot_steps = (x->ss_count / x->searches_per_step) - search_param;
+
+ i = 1;
+
+ for (step = 0; step < tot_steps; step++) {
+ int all_in = 1, t;
+
+ // To know if all neighbor points are within the bounds, 4 bounds checking are enough instead of
+ // checking 4 bounds for each points.
+ all_in &= ((best_mv->as_mv.row + ss[i].mv.row) > x->mv_row_min);
+ all_in &= ((best_mv->as_mv.row + ss[i + 1].mv.row) < x->mv_row_max);
+ all_in &= ((best_mv->as_mv.col + ss[i + 2].mv.col) > x->mv_col_min);
+ all_in &= ((best_mv->as_mv.col + ss[i + 3].mv.col) < x->mv_col_max);
+
+ if (all_in) {
+ unsigned int sad_array[4];
+
+ for (j = 0; j < x->searches_per_step; j += 4) {
+ unsigned char *block_offset[4];
+
+ for (t = 0; t < 4; t++)
+ block_offset[t] = ss[i + t].offset + best_address;
+
+ fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, sad_array);
+
+ for (t = 0; t < 4; t++, i++) {
+ if (sad_array[t] < bestsad) {
+ this_mv.as_mv.row = best_mv->as_mv.row + ss[i].mv.row;
+ this_mv.as_mv.col = best_mv->as_mv.col + ss[i].mv.col;
+ sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (sad_array[t] < bestsad) {
+ bestsad = sad_array[t];
+ best_site = i;
}
+ }
}
- else
- {
- for (j = 0 ; j < x->searches_per_step ; j++)
- {
- // Trap illegal vectors
- this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
-
- if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
- (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max))
- {
- check_here = ss[i].offset + best_address;
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_site = i;
- }
- }
- }
- i++;
+ }
+ } else {
+ for (j = 0; j < x->searches_per_step; j++) {
+ // Trap illegal vectors
+ this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
+ this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
+
+ if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
+ (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max)) {
+ check_here = ss[i].offset + best_address;
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.row = this_row_offset;
+ this_mv.as_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = i;
}
+ }
}
-
- if (best_site != last_site)
- {
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
- best_address += ss[best_site].offset;
- last_site = best_site;
- }
- else if (best_address == in_what)
- (*num00)++;
+ i++;
+ }
}
- this_mv.as_mv.row = best_mv->as_mv.row << 3;
- this_mv.as_mv.col = best_mv->as_mv.col << 3;
+ if (best_site != last_site) {
+ best_mv->as_mv.row += ss[best_site].mv.row;
+ best_mv->as_mv.col += ss[best_site].mv.col;
+ best_address += ss[best_site].offset;
+ last_site = best_site;
+ } else if (best_address == in_what)
+ (*num00)++;
+ }
- if (bestsad == INT_MAX)
- return INT_MAX;
+ this_mv.as_mv.row = best_mv->as_mv.row << 3;
+ this_mv.as_mv.col = best_mv->as_mv.col << 3;
- return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad == INT_MAX)
+ return INT_MAX;
+
+ return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
}
int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
- int_mv *center_mv)
-{
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- unsigned char *in_what;
- int in_what_stride = d->pre_stride;
- int mv_stride = d->pre_stride;
- unsigned char *bestaddress;
- int_mv *best_mv = &d->bmi.as_mv.first;
- int_mv this_mv;
- int bestsad = INT_MAX;
- int r, c;
-
- unsigned char *check_here;
- int thissad;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
-
- int row_min = ref_row - distance;
- int row_max = ref_row + distance;
- int col_min = ref_col - distance;
- int col_max = ref_col + distance;
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ int_mv *center_mv) {
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ unsigned char *in_what;
+ int in_what_stride = d->pre_stride;
+ int mv_stride = d->pre_stride;
+ unsigned char *bestaddress;
+ int_mv *best_mv = &d->bmi.as_mv.first;
+ int_mv this_mv;
+ int bestsad = INT_MAX;
+ int r, c;
+
+ unsigned char *check_here;
+ int thissad;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int ref_row = ref_mv->as_mv.row;
+ int ref_col = ref_mv->as_mv.col;
+
+ int row_min = ref_row - distance;
+ int row_max = ref_row + distance;
+ int col_min = ref_col - distance;
+ int col_max = ref_col + distance;
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
- // Work out the mid point for the search
- in_what = *(d->base_pre) + d->pre;
- bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
+ // Work out the mid point for the search
+ in_what = *(d->base_pre) + d->pre;
+ bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
+ best_mv->as_mv.row = ref_row;
+ best_mv->as_mv.col = ref_col;
- // Baseline value at the centre
- bestsad = fn_ptr->sdf(what, what_stride, bestaddress,
- in_what_stride, 0x7fffffff)
- + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+ // Baseline value at the centre
+ bestsad = fn_ptr->sdf(what, what_stride, bestaddress,
+ in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
- // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
- if (col_min < x->mv_col_min)
- col_min = x->mv_col_min;
+ // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
+ if (col_min < x->mv_col_min)
+ col_min = x->mv_col_min;
- if (col_max > x->mv_col_max)
- col_max = x->mv_col_max;
+ if (col_max > x->mv_col_max)
+ col_max = x->mv_col_max;
- if (row_min < x->mv_row_min)
- row_min = x->mv_row_min;
+ if (row_min < x->mv_row_min)
+ row_min = x->mv_row_min;
- if (row_max > x->mv_row_max)
- row_max = x->mv_row_max;
+ if (row_max > x->mv_row_max)
+ row_max = x->mv_row_max;
- for (r = row_min; r < row_max ; r++)
- {
- this_mv.as_mv.row = r;
- check_here = r * mv_stride + in_what + col_min;
+ for (r = row_min; r < row_max; r++) {
+ this_mv.as_mv.row = r;
+ check_here = r * mv_stride + in_what + col_min;
- for (c = col_min; c < col_max; c++)
- {
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
+ for (c = col_min; c < col_max; c++) {
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
+ }
- check_here++;
- }
+ check_here++;
}
+ }
- this_mv.as_mv.row = best_mv->as_mv.row << 3;
- this_mv.as_mv.col = best_mv->as_mv.col << 3;
+ this_mv.as_mv.row = best_mv->as_mv.row << 3;
+ this_mv.as_mv.col = best_mv->as_mv.col << 3;
- if (bestsad < INT_MAX)
- return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad < INT_MAX)
+ return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
- else
- return INT_MAX;
+ else
+ return INT_MAX;
}
int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
- int_mv *center_mv)
-{
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- unsigned char *in_what;
- int in_what_stride = d->pre_stride;
- int mv_stride = d->pre_stride;
- unsigned char *bestaddress;
- int_mv *best_mv = &d->bmi.as_mv.first;
- int_mv this_mv;
- int bestsad = INT_MAX;
- int r, c;
-
- unsigned char *check_here;
- unsigned int thissad;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
-
- int row_min = ref_row - distance;
- int row_max = ref_row + distance;
- int col_min = ref_col - distance;
- int col_max = ref_col + distance;
-
- unsigned int sad_array[3];
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ int_mv *center_mv) {
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ unsigned char *in_what;
+ int in_what_stride = d->pre_stride;
+ int mv_stride = d->pre_stride;
+ unsigned char *bestaddress;
+ int_mv *best_mv = &d->bmi.as_mv.first;
+ int_mv this_mv;
+ int bestsad = INT_MAX;
+ int r, c;
+
+ unsigned char *check_here;
+ unsigned int thissad;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int ref_row = ref_mv->as_mv.row;
+ int ref_col = ref_mv->as_mv.col;
+
+ int row_min = ref_row - distance;
+ int row_max = ref_row + distance;
+ int col_min = ref_col - distance;
+ int col_max = ref_col + distance;
+
+ unsigned int sad_array[3];
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- // Work out the mid point for the search
- in_what = *(d->base_pre) + d->pre;
- bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
-
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
-
- // Baseline value at the centre
- bestsad = fn_ptr->sdf(what, what_stride,
- bestaddress, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
-
- // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
- if (col_min < x->mv_col_min)
- col_min = x->mv_col_min;
-
- if (col_max > x->mv_col_max)
- col_max = x->mv_col_max;
-
- if (row_min < x->mv_row_min)
- row_min = x->mv_row_min;
-
- if (row_max > x->mv_row_max)
- row_max = x->mv_row_max;
-
- for (r = row_min; r < row_max ; r++)
- {
- this_mv.as_mv.row = r;
- check_here = r * mv_stride + in_what + col_min;
- c = col_min;
-
- while ((c + 2) < col_max)
- {
- int i;
-
- fn_ptr->sdx3f(what, what_stride, check_here , in_what_stride, sad_array);
-
- for (i = 0; i < 3; i++)
- {
- thissad = sad_array[i];
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
- }
-
- check_here++;
- c++;
- }
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ // Work out the mid point for the search
+ in_what = *(d->base_pre) + d->pre;
+ bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
+
+ best_mv->as_mv.row = ref_row;
+ best_mv->as_mv.col = ref_col;
+
+ // Baseline value at the centre
+ bestsad = fn_ptr->sdf(what, what_stride,
+ bestaddress, in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+
+ // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
+ if (col_min < x->mv_col_min)
+ col_min = x->mv_col_min;
+
+ if (col_max > x->mv_col_max)
+ col_max = x->mv_col_max;
+
+ if (row_min < x->mv_row_min)
+ row_min = x->mv_row_min;
+
+ if (row_max > x->mv_row_max)
+ row_max = x->mv_row_max;
+
+ for (r = row_min; r < row_max; r++) {
+ this_mv.as_mv.row = r;
+ check_here = r * mv_stride + in_what + col_min;
+ c = col_min;
+
+ while ((c + 2) < col_max) {
+ int i;
+
+ fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
+
+ for (i = 0; i < 3; i++) {
+ thissad = sad_array[i];
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
+ }
}
- while (c < col_max)
- {
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
- }
+ check_here++;
+ c++;
+ }
+ }
+
+ while (c < col_max) {
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
- check_here ++;
- c ++;
+ if (thissad < bestsad) {
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
}
+ }
+ check_here++;
+ c++;
}
- this_mv.as_mv.row = best_mv->as_mv.row << 3;
- this_mv.as_mv.col = best_mv->as_mv.col << 3;
+ }
+
+ this_mv.as_mv.row = best_mv->as_mv.row << 3;
+ this_mv.as_mv.col = best_mv->as_mv.col << 3;
- if (bestsad < INT_MAX)
- return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad < INT_MAX)
+ return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
- else
- return INT_MAX;
+ else
+ return INT_MAX;
}
int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
- int_mv *center_mv)
-{
- unsigned char *what = (*(b->base_src) + b->src);
- int what_stride = b->src_stride;
- unsigned char *in_what;
- int in_what_stride = d->pre_stride;
- int mv_stride = d->pre_stride;
- unsigned char *bestaddress;
- int_mv *best_mv = &d->bmi.as_mv.first;
- int_mv this_mv;
- int bestsad = INT_MAX;
- int r, c;
-
- unsigned char *check_here;
- unsigned int thissad;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
-
- int row_min = ref_row - distance;
- int row_max = ref_row + distance;
- int col_min = ref_col - distance;
- int col_max = ref_col + distance;
-
- DECLARE_ALIGNED_ARRAY(16, unsigned short, sad_array8, 8);
- unsigned int sad_array[3];
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ int_mv *center_mv) {
+ unsigned char *what = (*(b->base_src) + b->src);
+ int what_stride = b->src_stride;
+ unsigned char *in_what;
+ int in_what_stride = d->pre_stride;
+ int mv_stride = d->pre_stride;
+ unsigned char *bestaddress;
+ int_mv *best_mv = &d->bmi.as_mv.first;
+ int_mv this_mv;
+ int bestsad = INT_MAX;
+ int r, c;
+
+ unsigned char *check_here;
+ unsigned int thissad;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int ref_row = ref_mv->as_mv.row;
+ int ref_col = ref_mv->as_mv.col;
+
+ int row_min = ref_row - distance;
+ int row_max = ref_row + distance;
+ int col_min = ref_col - distance;
+ int col_max = ref_col + distance;
+
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, sad_array8, 8);
+ unsigned int sad_array[3];
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- // Work out the mid point for the search
- in_what = *(d->base_pre) + d->pre;
- bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
-
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
-
- // Baseline value at the centre
- bestsad = fn_ptr->sdf(what, what_stride,
- bestaddress, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
-
- // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
- if (col_min < x->mv_col_min)
- col_min = x->mv_col_min;
-
- if (col_max > x->mv_col_max)
- col_max = x->mv_col_max;
-
- if (row_min < x->mv_row_min)
- row_min = x->mv_row_min;
-
- if (row_max > x->mv_row_max)
- row_max = x->mv_row_max;
-
- for (r = row_min; r < row_max ; r++)
- {
- this_mv.as_mv.row = r;
- check_here = r * mv_stride + in_what + col_min;
- c = col_min;
-
- while ((c + 7) < col_max)
- {
- int i;
-
- fn_ptr->sdx8f(what, what_stride, check_here , in_what_stride, sad_array8);
-
- for (i = 0; i < 8; i++)
- {
- thissad = (unsigned int)sad_array8[i];
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
- }
-
- check_here++;
- c++;
- }
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ // Work out the mid point for the search
+ in_what = *(d->base_pre) + d->pre;
+ bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
+
+ best_mv->as_mv.row = ref_row;
+ best_mv->as_mv.col = ref_col;
+
+ // Baseline value at the centre
+ bestsad = fn_ptr->sdf(what, what_stride,
+ bestaddress, in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+
+ // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
+ if (col_min < x->mv_col_min)
+ col_min = x->mv_col_min;
+
+ if (col_max > x->mv_col_max)
+ col_max = x->mv_col_max;
+
+ if (row_min < x->mv_row_min)
+ row_min = x->mv_row_min;
+
+ if (row_max > x->mv_row_max)
+ row_max = x->mv_row_max;
+
+ for (r = row_min; r < row_max; r++) {
+ this_mv.as_mv.row = r;
+ check_here = r * mv_stride + in_what + col_min;
+ c = col_min;
+
+ while ((c + 7) < col_max) {
+ int i;
+
+ fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8);
+
+ for (i = 0; i < 8; i++) {
+ thissad = (unsigned int)sad_array8[i];
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
+ }
}
- while ((c + 2) < col_max)
- {
- int i;
-
- fn_ptr->sdx3f(what, what_stride, check_here , in_what_stride, sad_array);
-
- for (i = 0; i < 3; i++)
- {
- thissad = sad_array[i];
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
- }
-
- check_here++;
- c++;
- }
+ check_here++;
+ c++;
+ }
+ }
+
+ while ((c + 2) < col_max) {
+ int i;
+
+ fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
+
+ for (i = 0; i < 3; i++) {
+ thissad = sad_array[i];
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
+ }
}
- while (c < col_max)
- {
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
- mvsadcost, sad_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_mv->as_mv.row = r;
- best_mv->as_mv.col = c;
- bestaddress = check_here;
- }
- }
+ check_here++;
+ c++;
+ }
+ }
- check_here ++;
- c ++;
+ while (c < col_max) {
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_mv->as_mv.row = r;
+ best_mv->as_mv.col = c;
+ bestaddress = check_here;
}
+ }
+
+ check_here++;
+ c++;
}
+ }
- this_mv.as_mv.row = best_mv->as_mv.row << 3;
- this_mv.as_mv.col = best_mv->as_mv.col << 3;
+ this_mv.as_mv.row = best_mv->as_mv.row << 3;
+ this_mv.as_mv.col = best_mv->as_mv.col << 3;
- if (bestsad < INT_MAX)
- return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad < INT_MAX)
+ return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
- else
- return INT_MAX;
+ else
+ return INT_MAX;
}
int vp8_refining_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int error_per_bit, int search_range,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
- int_mv *center_mv)
-{
- MV neighbors[4] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
- int i, j;
- short this_row_offset, this_col_offset;
-
- int what_stride = b->src_stride;
- int in_what_stride = d->pre_stride;
- unsigned char *what = (*(b->base_src) + b->src);
- unsigned char *best_address = (unsigned char *)(*(d->base_pre) + d->pre +
- (ref_mv->as_mv.row * (d->pre_stride)) + ref_mv->as_mv.col);
- unsigned char *check_here;
- unsigned int thissad;
- int_mv this_mv;
- unsigned int bestsad = INT_MAX;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ int_mv *center_mv) {
+ MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
+ int i, j;
+ short this_row_offset, this_col_offset;
+
+ int what_stride = b->src_stride;
+ int in_what_stride = d->pre_stride;
+ unsigned char *what = (*(b->base_src) + b->src);
+ unsigned char *best_address = (unsigned char *)(*(d->base_pre) + d->pre +
+ (ref_mv->as_mv.row * (d->pre_stride)) + ref_mv->as_mv.col);
+ unsigned char *check_here;
+ unsigned int thissad;
+ int_mv this_mv;
+ unsigned int bestsad = INT_MAX;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit);
-
- for (i=0; i<search_range; i++)
- {
- int best_site = -1;
-
- for (j = 0 ; j < 4 ; j++)
- {
- this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
- this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
-
- if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
- (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max))
- {
- check_here = (neighbors[j].row)*in_what_stride + neighbors[j].col + best_address;
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_site = j;
- }
- }
- }
- }
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit);
+
+ for (i = 0; i < search_range; i++) {
+ int best_site = -1;
+
+ for (j = 0; j < 4; j++) {
+ this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
+ this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
- if (best_site == -1)
- break;
- else
- {
- ref_mv->as_mv.row += neighbors[best_site].row;
- ref_mv->as_mv.col += neighbors[best_site].col;
- best_address += (neighbors[best_site].row)*in_what_stride + neighbors[best_site].col;
+ if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
+ (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max)) {
+ check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + best_address;
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.row = this_row_offset;
+ this_mv.as_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = j;
+ }
}
+ }
}
- this_mv.as_mv.row = ref_mv->as_mv.row << 3;
- this_mv.as_mv.col = ref_mv->as_mv.col << 3;
+ if (best_site == -1)
+ break;
+ else {
+ ref_mv->as_mv.row += neighbors[best_site].row;
+ ref_mv->as_mv.col += neighbors[best_site].col;
+ best_address += (neighbors[best_site].row) * in_what_stride + neighbors[best_site].col;
+ }
+ }
- if (bestsad < INT_MAX)
- return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
+ this_mv.as_mv.row = ref_mv->as_mv.row << 3;
+ this_mv.as_mv.col = ref_mv->as_mv.col << 3;
+
+ if (bestsad < INT_MAX)
+ return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
- else
- return INT_MAX;
+ else
+ return INT_MAX;
}
int vp8_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *ref_mv, int error_per_bit,
int search_range, vp8_variance_fn_ptr_t *fn_ptr,
- int *mvcost[2], int_mv *center_mv)
-{
- MV neighbors[4] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
- int i, j;
- short this_row_offset, this_col_offset;
-
- int what_stride = b->src_stride;
- int in_what_stride = d->pre_stride;
- unsigned char *what = (*(b->base_src) + b->src);
- unsigned char *best_address = (unsigned char *)(*(d->base_pre) + d->pre +
- (ref_mv->as_mv.row * (d->pre_stride)) + ref_mv->as_mv.col);
- unsigned char *check_here;
- unsigned int thissad;
- int_mv this_mv;
- unsigned int bestsad = INT_MAX;
- MACROBLOCKD *xd = &x->e_mbd;
-
- int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
- int_mv fcenter_mv;
+ int *mvcost[2], int_mv *center_mv) {
+ MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
+ int i, j;
+ short this_row_offset, this_col_offset;
+
+ int what_stride = b->src_stride;
+ int in_what_stride = d->pre_stride;
+ unsigned char *what = (*(b->base_src) + b->src);
+ unsigned char *best_address = (unsigned char *)(*(d->base_pre) + d->pre +
+ (ref_mv->as_mv.row * (d->pre_stride)) + ref_mv->as_mv.col);
+ unsigned char *check_here;
+ unsigned int thissad;
+ int_mv this_mv;
+ unsigned int bestsad = INT_MAX;
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
+ int_mv fcenter_mv;
#if CONFIG_HIGH_PRECISION_MV
- if (xd->allow_high_precision_mv)
- {
- mvsadcost[0] = x->mvsadcost_hp[0];
- mvsadcost[1] = x->mvsadcost_hp[1];
- }
+ if (xd->allow_high_precision_mv) {
+ mvsadcost[0] = x->mvsadcost_hp[0];
+ mvsadcost[1] = x->mvsadcost_hp[1];
+ }
#endif
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
-
- bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit);
-
- for (i=0; i<search_range; i++)
- {
- int best_site = -1;
- int all_in = 1;
-
- all_in &= ((ref_mv->as_mv.row - 1) > x->mv_row_min);
- all_in &= ((ref_mv->as_mv.row + 1) < x->mv_row_max);
- all_in &= ((ref_mv->as_mv.col - 1) > x->mv_col_min);
- all_in &= ((ref_mv->as_mv.col + 1) < x->mv_col_max);
-
- if(all_in)
- {
- unsigned int sad_array[4];
- unsigned char *block_offset[4];
- block_offset[0] = best_address - in_what_stride;
- block_offset[1] = best_address - 1;
- block_offset[2] = best_address + 1;
- block_offset[3] = best_address + in_what_stride;
-
- fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, sad_array);
-
- for (j = 0; j < 4; j++)
- {
- if (sad_array[j] < bestsad)
- {
- this_mv.as_mv.row = ref_mv->as_mv.row + neighbors[j].row;
- this_mv.as_mv.col = ref_mv->as_mv.col + neighbors[j].col;
- sad_array[j] += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
-
- if (sad_array[j] < bestsad)
- {
- bestsad = sad_array[j];
- best_site = j;
- }
- }
- }
+ fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
+ fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+
+ bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit);
+
+ for (i = 0; i < search_range; i++) {
+ int best_site = -1;
+ int all_in = 1;
+
+ all_in &= ((ref_mv->as_mv.row - 1) > x->mv_row_min);
+ all_in &= ((ref_mv->as_mv.row + 1) < x->mv_row_max);
+ all_in &= ((ref_mv->as_mv.col - 1) > x->mv_col_min);
+ all_in &= ((ref_mv->as_mv.col + 1) < x->mv_col_max);
+
+ if (all_in) {
+ unsigned int sad_array[4];
+ unsigned char *block_offset[4];
+ block_offset[0] = best_address - in_what_stride;
+ block_offset[1] = best_address - 1;
+ block_offset[2] = best_address + 1;
+ block_offset[3] = best_address + in_what_stride;
+
+ fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, sad_array);
+
+ for (j = 0; j < 4; j++) {
+ if (sad_array[j] < bestsad) {
+ this_mv.as_mv.row = ref_mv->as_mv.row + neighbors[j].row;
+ this_mv.as_mv.col = ref_mv->as_mv.col + neighbors[j].col;
+ sad_array[j] += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
+
+ if (sad_array[j] < bestsad) {
+ bestsad = sad_array[j];
+ best_site = j;
+ }
}
- else
- {
- for (j = 0 ; j < 4 ; j++)
- {
- this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
- this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
-
- if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
- (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max))
- {
- check_here = (neighbors[j].row)*in_what_stride + neighbors[j].col + best_address;
- thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
-
- if (thissad < bestsad)
- {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
-
- if (thissad < bestsad)
- {
- bestsad = thissad;
- best_site = j;
- }
- }
- }
+ }
+ } else {
+ for (j = 0; j < 4; j++) {
+ this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
+ this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
+
+ if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_col_max) &&
+ (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_max)) {
+ check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + best_address;
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.as_mv.row = this_row_offset;
+ this_mv.as_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_site = j;
}
+ }
}
+ }
+ }
- if (best_site == -1)
- break;
- else
- {
- ref_mv->as_mv.row += neighbors[best_site].row;
- ref_mv->as_mv.col += neighbors[best_site].col;
- best_address += (neighbors[best_site].row)*in_what_stride + neighbors[best_site].col;
- }
+ if (best_site == -1)
+ break;
+ else {
+ ref_mv->as_mv.row += neighbors[best_site].row;
+ ref_mv->as_mv.col += neighbors[best_site].col;
+ best_address += (neighbors[best_site].row) * in_what_stride + neighbors[best_site].col;
}
+ }
- this_mv.as_mv.row = ref_mv->as_mv.row << 3;
- this_mv.as_mv.col = ref_mv->as_mv.col << 3;
+ this_mv.as_mv.row = ref_mv->as_mv.row << 3;
+ this_mv.as_mv.col = ref_mv->as_mv.col << 3;
- if (bestsad < INT_MAX)
- return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
+ if (bestsad < INT_MAX)
+ return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad))
#if CONFIG_HIGH_PRECISION_MV
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit, xd->allow_high_precision_mv);
#else
- + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
+ + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
#endif
- else
- return INT_MAX;
+ else
+ return INT_MAX;
}
#ifdef ENTROPY_STATS
-void print_mode_context(void)
-{
- FILE *f = fopen("modecont.c", "a");
- int i, j;
-
- fprintf(f, "#include \"entropy.h\"\n");
- fprintf(f, "const int vp8_mode_contexts[6][4] =");
- fprintf(f, "{\n");
- for (j = 0; j < 6; j++)
- {
- fprintf(f, " {/* %d */ ", j);
- fprintf(f, " ");
- for (i = 0; i < 4; i++)
- {
- int this_prob;
- int count;
-
- // context probs
- count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
- if (count)
- this_prob = 256 * mv_ref_ct[j][i][0] / count;
- else
- this_prob = 128;
-
- if (this_prob == 0)
- this_prob = 1;
- fprintf(f, "%5d, ", this_prob);
- }
- fprintf(f, " },\n");
- }
-
- fprintf(f, "};\n");
- fclose(f);
+void print_mode_context(void) {
+ FILE *f = fopen("modecont.c", "a");
+ int i, j;
+
+ fprintf(f, "#include \"entropy.h\"\n");
+ fprintf(f, "const int vp8_mode_contexts[6][4] =");
+ fprintf(f, "{\n");
+ for (j = 0; j < 6; j++) {
+ fprintf(f, " {/* %d */ ", j);
+ fprintf(f, " ");
+ for (i = 0; i < 4; i++) {
+ int this_prob;
+ int count;
+
+ // context probs
+ count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
+ if (count)
+ this_prob = 256 * mv_ref_ct[j][i][0] / count;
+ else
+ this_prob = 128;
+
+ if (this_prob == 0)
+ this_prob = 1;
+ fprintf(f, "%5d, ", this_prob);
+ }
+ fprintf(f, " },\n");
+ }
+
+ fprintf(f, "};\n");
+ fclose(f);
}
/* MV ref count ENTROPY_STATS stats code */
-void init_mv_ref_counts()
-{
- vpx_memset(mv_ref_ct, 0, sizeof(mv_ref_ct));
- vpx_memset(mv_mode_cts, 0, sizeof(mv_mode_cts));
+void init_mv_ref_counts() {
+ vpx_memset(mv_ref_ct, 0, sizeof(mv_ref_ct));
+ vpx_memset(mv_mode_cts, 0, sizeof(mv_mode_cts));
}
-void accum_mv_refs(MB_PREDICTION_MODE m, const int ct[4])
-{
- if (m == ZEROMV)
- {
- ++mv_ref_ct [ct[0]] [0] [0];
- ++mv_mode_cts[0][0];
- }
- else
- {
- ++mv_ref_ct [ct[0]] [0] [1];
- ++mv_mode_cts[0][1];
-
- if (m == NEARESTMV)
- {
- ++mv_ref_ct [ct[1]] [1] [0];
- ++mv_mode_cts[1][0];
- }
- else
- {
- ++mv_ref_ct [ct[1]] [1] [1];
- ++mv_mode_cts[1][1];
-
- if (m == NEARMV)
- {
- ++mv_ref_ct [ct[2]] [2] [0];
- ++mv_mode_cts[2][0];
- }
- else
- {
- ++mv_ref_ct [ct[2]] [2] [1];
- ++mv_mode_cts[2][1];
-
- if (m == NEWMV)
- {
- ++mv_ref_ct [ct[3]] [3] [0];
- ++mv_mode_cts[3][0];
- }
- else
- {
- ++mv_ref_ct [ct[3]] [3] [1];
- ++mv_mode_cts[3][1];
- }
- }
+void accum_mv_refs(MB_PREDICTION_MODE m, const int ct[4]) {
+ if (m == ZEROMV) {
+ ++mv_ref_ct [ct[0]] [0] [0];
+ ++mv_mode_cts[0][0];
+ } else {
+ ++mv_ref_ct [ct[0]] [0] [1];
+ ++mv_mode_cts[0][1];
+
+ if (m == NEARESTMV) {
+ ++mv_ref_ct [ct[1]] [1] [0];
+ ++mv_mode_cts[1][0];
+ } else {
+ ++mv_ref_ct [ct[1]] [1] [1];
+ ++mv_mode_cts[1][1];
+
+ if (m == NEARMV) {
+ ++mv_ref_ct [ct[2]] [2] [0];
+ ++mv_mode_cts[2][0];
+ } else {
+ ++mv_ref_ct [ct[2]] [2] [1];
+ ++mv_mode_cts[2][1];
+
+ if (m == NEWMV) {
+ ++mv_ref_ct [ct[3]] [3] [0];
+ ++mv_mode_cts[3][0];
+ } else {
+ ++mv_ref_ct [ct[3]] [3] [1];
+ ++mv_mode_cts[3][1];
}
+ }
}
+ }
}
#endif/* END MV ref count ENTROPY_STATS stats code */
diff --git a/vp8/encoder/mcomp.h b/vp8/encoder/mcomp.h
index f1314533f..d7fd137ca 100644
--- a/vp8/encoder/mcomp.h
+++ b/vp8/encoder/mcomp.h
@@ -36,71 +36,71 @@ extern void vp8_init3smotion_compensation(MACROBLOCK *x, int stride);
extern int vp8_hex_search
(
- MACROBLOCK *x,
- BLOCK *b,
- BLOCKD *d,
- int_mv *ref_mv,
- int_mv *best_mv,
- int search_param,
- int error_per_bit,
- const vp8_variance_fn_ptr_t *vf,
- int *mvsadcost[2],
- int *mvcost[2],
- int_mv *center_mv
+ MACROBLOCK *x,
+ BLOCK *b,
+ BLOCKD *d,
+ int_mv *ref_mv,
+ int_mv *best_mv,
+ int search_param,
+ int error_per_bit,
+ const vp8_variance_fn_ptr_t *vf,
+ int *mvsadcost[2],
+ int *mvcost[2],
+ int_mv *center_mv
);
typedef int (fractional_mv_step_fp)
- (MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv,
- int error_per_bit, const vp8_variance_fn_ptr_t *vfp, int *mvcost[2],
- int *distortion, unsigned int *sse);
+(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv,
+ int error_per_bit, const vp8_variance_fn_ptr_t *vfp, int *mvcost[2],
+ int *distortion, unsigned int *sse);
extern fractional_mv_step_fp vp8_find_best_sub_pixel_step_iteratively;
extern fractional_mv_step_fp vp8_find_best_sub_pixel_step;
extern fractional_mv_step_fp vp8_find_best_half_pixel_step;
extern fractional_mv_step_fp vp8_skip_fractional_mv_step;
#define prototype_full_search_sad(sym)\
- int (sym)\
- (\
- MACROBLOCK *x, \
- BLOCK *b, \
- BLOCKD *d, \
- int_mv *ref_mv, \
- int sad_per_bit, \
- int distance, \
- vp8_variance_fn_ptr_t *fn_ptr, \
- int *mvcost[2], \
- int_mv *center_mv \
- )
+ int (sym)\
+ (\
+ MACROBLOCK *x, \
+ BLOCK *b, \
+ BLOCKD *d, \
+ int_mv *ref_mv, \
+ int sad_per_bit, \
+ int distance, \
+ vp8_variance_fn_ptr_t *fn_ptr, \
+ int *mvcost[2], \
+ int_mv *center_mv \
+ )
#define prototype_refining_search_sad(sym)\
- int (sym)\
- (\
- MACROBLOCK *x, \
- BLOCK *b, \
- BLOCKD *d, \
- int_mv *ref_mv, \
- int sad_per_bit, \
- int distance, \
- vp8_variance_fn_ptr_t *fn_ptr, \
- int *mvcost[2], \
- int_mv *center_mv \
- )
+ int (sym)\
+ (\
+ MACROBLOCK *x, \
+ BLOCK *b, \
+ BLOCKD *d, \
+ int_mv *ref_mv, \
+ int sad_per_bit, \
+ int distance, \
+ vp8_variance_fn_ptr_t *fn_ptr, \
+ int *mvcost[2], \
+ int_mv *center_mv \
+ )
#define prototype_diamond_search_sad(sym)\
- int (sym)\
- (\
- MACROBLOCK *x, \
- BLOCK *b, \
- BLOCKD *d, \
- int_mv *ref_mv, \
- int_mv *best_mv, \
- int search_param, \
- int sad_per_bit, \
- int *num00, \
- vp8_variance_fn_ptr_t *fn_ptr, \
- int *mvcost[2], \
- int_mv *center_mv \
- )
+ int (sym)\
+ (\
+ MACROBLOCK *x, \
+ BLOCK *b, \
+ BLOCKD *d, \
+ int_mv *ref_mv, \
+ int_mv *best_mv, \
+ int search_param, \
+ int sad_per_bit, \
+ int *num00, \
+ vp8_variance_fn_ptr_t *fn_ptr, \
+ int *mvcost[2], \
+ int_mv *center_mv \
+ )
#if ARCH_X86 || ARCH_X86_64
#include "x86/mcomp_x86.h"
@@ -134,11 +134,10 @@ extern prototype_refining_search_sad(vp8_search_refining_search);
#endif
extern prototype_diamond_search_sad(vp8_search_diamond_search);
-typedef struct
-{
- prototype_full_search_sad(*full_search);
- prototype_refining_search_sad(*refining_search);
- prototype_diamond_search_sad(*diamond_search);
+typedef struct {
+ prototype_full_search_sad(*full_search);
+ prototype_refining_search_sad(*refining_search);
+ prototype_diamond_search_sad(*diamond_search);
} vp8_search_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/encoder/modecosts.c b/vp8/encoder/modecosts.c
index a156d6205..7a9c19a82 100644
--- a/vp8/encoder/modecosts.c
+++ b/vp8/encoder/modecosts.c
@@ -15,45 +15,40 @@
#include "vp8/common/entropymode.h"
-void vp8_init_mode_costs(VP8_COMP *c)
-{
- VP8_COMMON *x = &c->common;
- {
- const vp8_tree_p T = vp8_bmode_tree;
-
- int i = 0;
-
- do
- {
- int j = 0;
-
- do
- {
- vp8_cost_tokens((int *)c->mb.bmode_costs[i][j], x->kf_bmode_prob[i][j], T);
- }
- while (++j < VP8_BINTRAMODES);
- }
- while (++i < VP8_BINTRAMODES);
-
- vp8_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.bmode_prob, T);
- }
+void vp8_init_mode_costs(VP8_COMP *c) {
+ VP8_COMMON *x = &c->common;
+ {
+ const vp8_tree_p T = vp8_bmode_tree;
+
+ int i = 0;
+
+ do {
+ int j = 0;
+
+ do {
+ vp8_cost_tokens((int *)c->mb.bmode_costs[i][j], x->kf_bmode_prob[i][j], T);
+ } while (++j < VP8_BINTRAMODES);
+ } while (++i < VP8_BINTRAMODES);
+
+ vp8_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.bmode_prob, T);
+ }
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_cost_tokens((int *)c->mb.inter_bmode_costs,
- vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
+ vp8_cost_tokens((int *)c->mb.inter_bmode_costs,
+ vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
#else
- vp8_cost_tokens(c->mb.inter_bmode_costs,
- vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
+ vp8_cost_tokens(c->mb.inter_bmode_costs,
+ vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
#endif
- vp8_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp8_ymode_tree);
- vp8_cost_tokens(c->mb.mbmode_cost[0],
- x->kf_ymode_prob[c->common.kf_ymode_probs_index],
- vp8_kf_ymode_tree);
- vp8_cost_tokens(c->mb.intra_uv_mode_cost[1],
- x->fc.uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree);
- vp8_cost_tokens(c->mb.intra_uv_mode_cost[0],
- x->kf_uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree);
- vp8_cost_tokens(c->mb.i8x8_mode_costs,
- x->fc.i8x8_mode_prob,vp8_i8x8_mode_tree);
+ vp8_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp8_ymode_tree);
+ vp8_cost_tokens(c->mb.mbmode_cost[0],
+ x->kf_ymode_prob[c->common.kf_ymode_probs_index],
+ vp8_kf_ymode_tree);
+ vp8_cost_tokens(c->mb.intra_uv_mode_cost[1],
+ x->fc.uv_mode_prob[VP8_YMODES - 1], vp8_uv_mode_tree);
+ vp8_cost_tokens(c->mb.intra_uv_mode_cost[0],
+ x->kf_uv_mode_prob[VP8_YMODES - 1], vp8_uv_mode_tree);
+ vp8_cost_tokens(c->mb.i8x8_mode_costs,
+ x->fc.i8x8_mode_prob, vp8_i8x8_mode_tree);
}
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index bfcaf746d..3eb25d255 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -84,14 +84,14 @@ extern const int vp8_gf_interval_table[101];
#if CONFIG_ENHANCED_INTERP
#define SEARCH_BEST_FILTER 0 /* to search exhaustively for best filter */
#define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state
- before trying each new filter */
+before trying each new filter */
#endif
#if CONFIG_HIGH_PRECISION_MV
#define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv for altref computation */
#define HIGH_PRECISION_MV_QTHRESH 200 /* Q threshold for use of high precision mv */
- /* Choose a very high value for now so
- * that HIGH_PRECISION is always chosen
- */
+/* Choose a very high value for now so
+ * that HIGH_PRECISION is always chosen
+ */
#endif
#if CONFIG_INTERNAL_STATS
@@ -99,28 +99,28 @@ extern const int vp8_gf_interval_table[101];
extern double vp8_calc_ssim
(
- YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest,
- int lumamask,
- double *weight,
- const vp8_variance_rtcd_vtable_t *rtcd
+ YV12_BUFFER_CONFIG *source,
+ YV12_BUFFER_CONFIG *dest,
+ int lumamask,
+ double *weight,
+ const vp8_variance_rtcd_vtable_t *rtcd
);
extern double vp8_calc_ssimg
(
- YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest,
- double *ssim_y,
- double *ssim_u,
- double *ssim_v,
- const vp8_variance_rtcd_vtable_t *rtcd
+ YV12_BUFFER_CONFIG *source,
+ YV12_BUFFER_CONFIG *dest,
+ double *ssim_y,
+ double *ssim_u,
+ double *ssim_v,
+ const vp8_variance_rtcd_vtable_t *rtcd
);
#endif
-//#define OUTPUT_YUV_REC
+// #define OUTPUT_YUV_REC
#ifdef OUTPUT_YUV_SRC
FILE *yuv_file;
@@ -158,13 +158,13 @@ extern unsigned __int64 Sectionbits[500];
#endif
#ifdef MODE_STATS
extern INT64 Sectionbits[500];
-extern unsigned int y_modes[VP8_YMODES] ;
+extern unsigned int y_modes[VP8_YMODES];
extern unsigned int i8x8_modes[VP8_I8X8_MODES];
-extern unsigned int uv_modes[VP8_UV_MODES] ;
+extern unsigned int uv_modes[VP8_UV_MODES];
extern unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES];
extern unsigned int b_modes[B_MODE_COUNT];
-extern unsigned int inter_y_modes[MB_MODE_COUNT] ;
-extern unsigned int inter_uv_modes[VP8_UV_MODES] ;
+extern unsigned int inter_y_modes[MB_MODE_COUNT];
+extern unsigned int inter_uv_modes[VP8_UV_MODES];
extern unsigned int inter_b_modes[B_MODE_COUNT];
#endif
@@ -190,1229 +190,1160 @@ static int inter_minq[QINDEX_RANGE];
// formulaic approach to facilitate easier adjustment of the Q tables.
// The formulae were derived from computing a 3rd order polynomial best
// fit to the original data (after plotting real maxq vs minq (not q index))
-int calculate_minq_index( double maxq,
- double x3, double x2, double x, double c )
-{
- int i;
- double minqtarget;
- double thisq;
-
- minqtarget = ( (x3 * maxq * maxq * maxq) +
- (x2 * maxq * maxq) +
- (x * maxq) +
- c );
-
- if ( minqtarget > maxq )
- minqtarget = maxq;
-
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- thisq = vp8_convert_qindex_to_q(i);
- if ( minqtarget <= vp8_convert_qindex_to_q(i) )
- return i;
- }
- return QINDEX_RANGE-1;
+int calculate_minq_index(double maxq,
+ double x3, double x2, double x, double c) {
+ int i;
+ double minqtarget;
+ double thisq;
+
+ minqtarget = ((x3 * maxq * maxq * maxq) +
+ (x2 * maxq * maxq) +
+ (x * maxq) +
+ c);
+
+ if (minqtarget > maxq)
+ minqtarget = maxq;
+
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ thisq = vp8_convert_qindex_to_q(i);
+ if (minqtarget <= vp8_convert_qindex_to_q(i))
+ return i;
+ }
+ return QINDEX_RANGE - 1;
}
-void init_minq_luts()
-{
- int i;
- double maxq;
-
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- maxq = vp8_convert_qindex_to_q(i);
-
-
- kf_low_motion_minq[i] = calculate_minq_index( maxq,
- 0.0000003,
- -0.000015,
- 0.074,
- 0.0 );
- kf_high_motion_minq[i] = calculate_minq_index( maxq,
- 0.0000004,
- -0.000125,
- 0.14,
- 0.0 );
- gf_low_motion_minq[i] = calculate_minq_index( maxq,
- 0.0000015,
- -0.0009,
- 0.33,
- 0.0 );
- gf_high_motion_minq[i] = calculate_minq_index( maxq,
- 0.0000021,
- -0.00125,
- 0.45,
- 0.0 );
- inter_minq[i] = calculate_minq_index( maxq,
- 0.00000271,
- -0.00113,
- 0.697,
- 0.0 );
-
- }
+void init_minq_luts() {
+ int i;
+ double maxq;
+
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ maxq = vp8_convert_qindex_to_q(i);
+
+
+ kf_low_motion_minq[i] = calculate_minq_index(maxq,
+ 0.0000003,
+ -0.000015,
+ 0.074,
+ 0.0);
+ kf_high_motion_minq[i] = calculate_minq_index(maxq,
+ 0.0000004,
+ -0.000125,
+ 0.14,
+ 0.0);
+ gf_low_motion_minq[i] = calculate_minq_index(maxq,
+ 0.0000015,
+ -0.0009,
+ 0.33,
+ 0.0);
+ gf_high_motion_minq[i] = calculate_minq_index(maxq,
+ 0.0000021,
+ -0.00125,
+ 0.45,
+ 0.0);
+ inter_minq[i] = calculate_minq_index(maxq,
+ 0.00000271,
+ -0.00113,
+ 0.697,
+ 0.0);
+
+ }
}
-void init_base_skip_probs()
-{
- int i;
- double q;
- int skip_prob, t;
+void init_base_skip_probs() {
+ int i;
+ double q;
+ int skip_prob, t;
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- q = vp8_convert_qindex_to_q(i);
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ q = vp8_convert_qindex_to_q(i);
- // Exponential decay caluclation of baseline skip prob with clamping
- // Based on crude best fit of old table.
- t = (int)( 564.25 * pow( 2.71828, (-0.012*q) ) );
+ // Exponential decay caluclation of baseline skip prob with clamping
+ // Based on crude best fit of old table.
+ t = (int)(564.25 * pow(2.71828, (-0.012 * q)));
- skip_prob = t;
- if ( skip_prob < 1 )
- skip_prob = 1;
- else if ( skip_prob > 255 )
- skip_prob = 255;
+ skip_prob = t;
+ if (skip_prob < 1)
+ skip_prob = 1;
+ else if (skip_prob > 255)
+ skip_prob = 255;
#if CONFIG_NEWENTROPY
- vp8cx_base_skip_false_prob[i][1] = skip_prob;
-
- skip_prob = t * 0.75;
- if ( skip_prob < 1 )
- skip_prob = 1;
- else if ( skip_prob > 255 )
- skip_prob = 255;
- vp8cx_base_skip_false_prob[i][2] = skip_prob;
-
- skip_prob = t * 1.25;
- if ( skip_prob < 1 )
- skip_prob = 1;
- else if ( skip_prob > 255 )
- skip_prob = 255;
- vp8cx_base_skip_false_prob[i][0] = skip_prob;
+ vp8cx_base_skip_false_prob[i][1] = skip_prob;
+
+ skip_prob = t * 0.75;
+ if (skip_prob < 1)
+ skip_prob = 1;
+ else if (skip_prob > 255)
+ skip_prob = 255;
+ vp8cx_base_skip_false_prob[i][2] = skip_prob;
+
+ skip_prob = t * 1.25;
+ if (skip_prob < 1)
+ skip_prob = 1;
+ else if (skip_prob > 255)
+ skip_prob = 255;
+ vp8cx_base_skip_false_prob[i][0] = skip_prob;
#else
- vp8cx_base_skip_false_prob[i] = skip_prob;
+ vp8cx_base_skip_false_prob[i] = skip_prob;
#endif
- }
+ }
}
-void update_base_skip_probs(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
+void update_base_skip_probs(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
- if (cm->frame_type != KEY_FRAME)
- {
- update_skip_probs(cpi);
+ if (cm->frame_type != KEY_FRAME) {
+ update_skip_probs(cpi);
- if (cm->refresh_alt_ref_frame)
- {
+ if (cm->refresh_alt_ref_frame) {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- cpi->last_skip_false_probs[2][k] = cm->mbskip_pred_probs[k];
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ cpi->last_skip_false_probs[2][k] = cm->mbskip_pred_probs[k];
#else
- cpi->last_skip_false_probs[2] = cpi->prob_skip_false;
+ cpi->last_skip_false_probs[2] = cpi->prob_skip_false;
#endif
- cpi->last_skip_probs_q[2] = cm->base_qindex;
- }
- else if (cpi->common.refresh_golden_frame)
- {
+ cpi->last_skip_probs_q[2] = cm->base_qindex;
+ } else if (cpi->common.refresh_golden_frame) {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- cpi->last_skip_false_probs[1][k] = cm->mbskip_pred_probs[k];
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ cpi->last_skip_false_probs[1][k] = cm->mbskip_pred_probs[k];
#else
- cpi->last_skip_false_probs[1] = cpi->prob_skip_false;
+ cpi->last_skip_false_probs[1] = cpi->prob_skip_false;
#endif
- cpi->last_skip_probs_q[1] = cm->base_qindex;
- }
- else
- {
+ cpi->last_skip_probs_q[1] = cm->base_qindex;
+ } else {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- cpi->last_skip_false_probs[0][k] = cm->mbskip_pred_probs[k];
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ cpi->last_skip_false_probs[0][k] = cm->mbskip_pred_probs[k];
#else
- cpi->last_skip_false_probs[0] = cpi->prob_skip_false;
+ cpi->last_skip_false_probs[0] = cpi->prob_skip_false;
#endif
- cpi->last_skip_probs_q[0] = cm->base_qindex;
+ cpi->last_skip_probs_q[0] = cm->base_qindex;
- // update the baseline table for the current q
+ // update the baseline table for the current q
#if CONFIG_NEWENTROPY
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- cpi->base_skip_false_prob[cm->base_qindex][k] =
- cm->mbskip_pred_probs[k];
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k)
+ cpi->base_skip_false_prob[cm->base_qindex][k] =
+ cm->mbskip_pred_probs[k];
#else
- cpi->base_skip_false_prob[cm->base_qindex] = cpi->prob_skip_false;
+ cpi->base_skip_false_prob[cm->base_qindex] = cpi->prob_skip_false;
#endif
- }
}
+ }
}
-void vp8_initialize()
-{
- static int init_done = 0;
-
- if (!init_done)
- {
- vp8_scale_machine_specific_config();
- vp8_initialize_common();
- //vp8_dmachine_specific_config();
- vp8_tokenize_initialize();
- vp8_init_quant_tables();
- vp8_init_me_luts();
- init_minq_luts();
- init_base_skip_probs();
- init_done = 1;
- }
+void vp8_initialize() {
+ static int init_done = 0;
+
+ if (!init_done) {
+ vp8_scale_machine_specific_config();
+ vp8_initialize_common();
+ // vp8_dmachine_specific_config();
+ vp8_tokenize_initialize();
+ vp8_init_quant_tables();
+ vp8_init_me_luts();
+ init_minq_luts();
+ init_base_skip_probs();
+ init_done = 1;
+ }
}
#ifdef PACKET_TESTING
extern FILE *vpxlogc;
#endif
-static void setup_features(VP8_COMP *cpi)
-{
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
+static void setup_features(VP8_COMP *cpi) {
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
- // Set up default state for MB feature flags
+ // Set up default state for MB feature flags
- xd->segmentation_enabled = 0; // Default segmentation disabled
+ xd->segmentation_enabled = 0; // Default segmentation disabled
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
- vpx_memset(xd->mb_segment_tree_probs, 255, sizeof(xd->mb_segment_tree_probs));
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
+ vpx_memset(xd->mb_segment_tree_probs, 255, sizeof(xd->mb_segment_tree_probs));
- clearall_segfeatures( xd );
+ clearall_segfeatures(xd);
- xd->mode_ref_lf_delta_enabled = 0;
- xd->mode_ref_lf_delta_update = 0;
- vpx_memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
- vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
- vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
- vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
+ xd->mode_ref_lf_delta_enabled = 0;
+ xd->mode_ref_lf_delta_update = 0;
+ vpx_memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
+ vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
+ vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
+ vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
- set_default_lf_deltas(cpi);
+ set_default_lf_deltas(cpi);
}
-static void dealloc_compressor_data(VP8_COMP *cpi)
-{
- vpx_free(cpi->tplist);
- cpi->tplist = NULL;
+static void dealloc_compressor_data(VP8_COMP *cpi) {
+ vpx_free(cpi->tplist);
+ cpi->tplist = NULL;
- // Delete last frame MV storage buffers
- vpx_free(cpi->lfmv);
- cpi->lfmv = 0;
+ // Delete last frame MV storage buffers
+ vpx_free(cpi->lfmv);
+ cpi->lfmv = 0;
- vpx_free(cpi->lf_ref_frame_sign_bias);
- cpi->lf_ref_frame_sign_bias = 0;
+ vpx_free(cpi->lf_ref_frame_sign_bias);
+ cpi->lf_ref_frame_sign_bias = 0;
- vpx_free(cpi->lf_ref_frame);
- cpi->lf_ref_frame = 0;
+ vpx_free(cpi->lf_ref_frame);
+ cpi->lf_ref_frame = 0;
- // Delete sementation map
- vpx_free(cpi->segmentation_map);
- cpi->segmentation_map = 0;
- vpx_free(cpi->common.last_frame_seg_map);
- cpi->common.last_frame_seg_map = 0;
- vpx_free(cpi->coding_context.last_frame_seg_map_copy);
- cpi->coding_context.last_frame_seg_map_copy = 0;
+ // Delete sementation map
+ vpx_free(cpi->segmentation_map);
+ cpi->segmentation_map = 0;
+ vpx_free(cpi->common.last_frame_seg_map);
+ cpi->common.last_frame_seg_map = 0;
+ vpx_free(cpi->coding_context.last_frame_seg_map_copy);
+ cpi->coding_context.last_frame_seg_map_copy = 0;
- vpx_free(cpi->active_map);
- cpi->active_map = 0;
+ vpx_free(cpi->active_map);
+ cpi->active_map = 0;
- vp8_de_alloc_frame_buffers(&cpi->common);
+ vp8_de_alloc_frame_buffers(&cpi->common);
- vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf);
- vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source);
+ vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf);
+ vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source);
#if VP8_TEMPORAL_ALT_REF
- vp8_yv12_de_alloc_frame_buffer(&cpi->alt_ref_buffer);
+ vp8_yv12_de_alloc_frame_buffer(&cpi->alt_ref_buffer);
#endif
- vp8_lookahead_destroy(cpi->lookahead);
+ vp8_lookahead_destroy(cpi->lookahead);
- vpx_free(cpi->tok);
- cpi->tok = 0;
+ vpx_free(cpi->tok);
+ cpi->tok = 0;
- // Structure used to monitor GF usage
- vpx_free(cpi->gf_active_flags);
- cpi->gf_active_flags = 0;
+ // Structure used to monitor GF usage
+ vpx_free(cpi->gf_active_flags);
+ cpi->gf_active_flags = 0;
- // Activity mask based per mb zbin adjustments
- vpx_free(cpi->mb_activity_map);
- cpi->mb_activity_map = 0;
- vpx_free(cpi->mb_norm_activity_map);
- cpi->mb_norm_activity_map = 0;
+ // Activity mask based per mb zbin adjustments
+ vpx_free(cpi->mb_activity_map);
+ cpi->mb_activity_map = 0;
+ vpx_free(cpi->mb_norm_activity_map);
+ cpi->mb_norm_activity_map = 0;
- vpx_free(cpi->mb.pip);
- cpi->mb.pip = 0;
+ vpx_free(cpi->mb.pip);
+ cpi->mb.pip = 0;
- vpx_free(cpi->twopass.total_stats);
- cpi->twopass.total_stats = 0;
+ vpx_free(cpi->twopass.total_stats);
+ cpi->twopass.total_stats = 0;
- vpx_free(cpi->twopass.total_left_stats);
- cpi->twopass.total_left_stats = 0;
+ vpx_free(cpi->twopass.total_left_stats);
+ cpi->twopass.total_left_stats = 0;
- vpx_free(cpi->twopass.this_frame_stats);
- cpi->twopass.this_frame_stats = 0;
+ vpx_free(cpi->twopass.this_frame_stats);
+ cpi->twopass.this_frame_stats = 0;
}
// Computes a q delta (in "q index" terms) to get from a starting q value
// to a target value
// target q value
-static int compute_qdelta( VP8_COMP *cpi, double qstart, double qtarget )
-{
- int i;
- int start_index = cpi->worst_quality;
- int target_index = cpi->worst_quality;
-
- // Convert the average q value to an index.
- for ( i = cpi->best_quality; i < cpi->worst_quality; i++ )
- {
- start_index = i;
- if ( vp8_convert_qindex_to_q(i) >= qstart )
- break;
- }
-
- // Convert the q target to an index
- for ( i = cpi->best_quality; i < cpi->worst_quality; i++ )
- {
- target_index = i;
- if ( vp8_convert_qindex_to_q(i) >= qtarget )
- break;
- }
-
- return target_index - start_index;
+static int compute_qdelta(VP8_COMP *cpi, double qstart, double qtarget) {
+ int i;
+ int start_index = cpi->worst_quality;
+ int target_index = cpi->worst_quality;
+
+ // Convert the average q value to an index.
+ for (i = cpi->best_quality; i < cpi->worst_quality; i++) {
+ start_index = i;
+ if (vp8_convert_qindex_to_q(i) >= qstart)
+ break;
+ }
+
+ // Convert the q target to an index
+ for (i = cpi->best_quality; i < cpi->worst_quality; i++) {
+ target_index = i;
+ if (vp8_convert_qindex_to_q(i) >= qtarget)
+ break;
+ }
+
+ return target_index - start_index;
}
-static void init_seg_features(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
+static void init_seg_features(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
- int high_q = (int)(cpi->avg_q > 48.0);
- int qi_delta;
+ int high_q = (int)(cpi->avg_q > 48.0);
+ int qi_delta;
- // Disable and clear down for KF
- if ( cm->frame_type == KEY_FRAME )
- {
- // Clear down the global segmentation map
- vpx_memset( cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
- cpi->static_mb_pct = 0;
+ // Disable and clear down for KF
+ if (cm->frame_type == KEY_FRAME) {
+ // Clear down the global segmentation map
+ vpx_memset(cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
+ cpi->static_mb_pct = 0;
- // Disable segmentation
- vp8_disable_segmentation((VP8_PTR)cpi);
+ // Disable segmentation
+ vp8_disable_segmentation((VP8_PTR)cpi);
- // Clear down the segment features.
- clearall_segfeatures(xd);
- }
+ // Clear down the segment features.
+ clearall_segfeatures(xd);
+ }
- // If this is an alt ref frame
- else if ( cm->refresh_alt_ref_frame )
- {
- // Clear down the global segmentation map
- vpx_memset( cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
- cpi->static_mb_pct = 0;
+ // If this is an alt ref frame
+ else if (cm->refresh_alt_ref_frame) {
+ // Clear down the global segmentation map
+ vpx_memset(cpi->segmentation_map, 0, (cm->mb_rows * cm->mb_cols));
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
+ cpi->static_mb_pct = 0;
- // Disable segmentation and individual segment features by default
- vp8_disable_segmentation((VP8_PTR)cpi);
- clearall_segfeatures(xd);
+ // Disable segmentation and individual segment features by default
+ vp8_disable_segmentation((VP8_PTR)cpi);
+ clearall_segfeatures(xd);
- // Scan frames from current to arf frame.
- // This function re-enables segmentation if appropriate.
- vp8_update_mbgraph_stats(cpi);
+ // Scan frames from current to arf frame.
+ // This function re-enables segmentation if appropriate.
+ vp8_update_mbgraph_stats(cpi);
- // If segmentation was enabled set those features needed for the
- // arf itself.
- if ( xd->segmentation_enabled )
- {
- xd->update_mb_segmentation_map = 1;
- xd->update_mb_segmentation_data = 1;
+ // If segmentation was enabled set those features needed for the
+ // arf itself.
+ if (xd->segmentation_enabled) {
+ xd->update_mb_segmentation_map = 1;
+ xd->update_mb_segmentation_data = 1;
- qi_delta = compute_qdelta( cpi, cpi->avg_q, (cpi->avg_q * 0.875) );
- set_segdata( xd, 1, SEG_LVL_ALT_Q, (qi_delta - 2) );
- set_segdata( xd, 1, SEG_LVL_ALT_LF, -2 );
+ qi_delta = compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875));
+ set_segdata(xd, 1, SEG_LVL_ALT_Q, (qi_delta - 2));
+ set_segdata(xd, 1, SEG_LVL_ALT_LF, -2);
- enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
- enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
+ enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
+ enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
- // Where relevant assume segment data is delta data
- xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
+ // Where relevant assume segment data is delta data
+ xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
- }
}
- // All other frames if segmentation has been enabled
- else if ( xd->segmentation_enabled )
- {
-/*
- int i;
+ }
+ // All other frames if segmentation has been enabled
+ else if (xd->segmentation_enabled) {
+ /*
+ int i;
- // clears prior frame seg lev refs
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- {
- // only do it if the force drop the background stuff is off
- if(!segfeature_active(xd, i, SEG_LVL_MODE))
+ // clears prior frame seg lev refs
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
{
- disable_segfeature(xd,i,SEG_LVL_REF_FRAME);
- set_segdata( xd,i, SEG_LVL_REF_FRAME, 0xffffff);
+ // only do it if the force drop the background stuff is off
+ if(!segfeature_active(xd, i, SEG_LVL_MODE))
+ {
+ disable_segfeature(xd,i,SEG_LVL_REF_FRAME);
+ set_segdata( xd,i, SEG_LVL_REF_FRAME, 0xffffff);
+ }
}
- }
-*/
+ */
- // First normal frame in a valid gf or alt ref group
- if ( cpi->common.frames_since_golden == 0 )
- {
- // Set up segment features for normal frames in an af group
- if ( cpi->source_alt_ref_active )
- {
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 1;
- xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
+ // First normal frame in a valid gf or alt ref group
+ if (cpi->common.frames_since_golden == 0) {
+ // Set up segment features for normal frames in an af group
+ if (cpi->source_alt_ref_active) {
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 1;
+ xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
- qi_delta = compute_qdelta( cpi, cpi->avg_q,
- (cpi->avg_q * 1.125) );
- set_segdata( xd, 1, SEG_LVL_ALT_Q, (qi_delta + 2) );
- set_segdata( xd, 1, SEG_LVL_ALT_Q, 0 );
- enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
+ qi_delta = compute_qdelta(cpi, cpi->avg_q,
+ (cpi->avg_q * 1.125));
+ set_segdata(xd, 1, SEG_LVL_ALT_Q, (qi_delta + 2));
+ set_segdata(xd, 1, SEG_LVL_ALT_Q, 0);
+ enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
- set_segdata( xd, 1, SEG_LVL_ALT_LF, -2 );
- enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
+ set_segdata(xd, 1, SEG_LVL_ALT_LF, -2);
+ enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
- // Segment coding disabled for compred testing
- if ( high_q || (cpi->static_mb_pct == 100) )
- {
- //set_segref(xd, 1, LAST_FRAME);
- set_segref(xd, 1, ALTREF_FRAME);
- enable_segfeature(xd, 1, SEG_LVL_REF_FRAME);
+ // Segment coding disabled for compred testing
+ if (high_q || (cpi->static_mb_pct == 100)) {
+ // set_segref(xd, 1, LAST_FRAME);
+ set_segref(xd, 1, ALTREF_FRAME);
+ enable_segfeature(xd, 1, SEG_LVL_REF_FRAME);
- set_segdata( xd, 1, SEG_LVL_MODE, ZEROMV );
- enable_segfeature(xd, 1, SEG_LVL_MODE);
+ set_segdata(xd, 1, SEG_LVL_MODE, ZEROMV);
+ enable_segfeature(xd, 1, SEG_LVL_MODE);
- // EOB segment coding not fixed for 8x8 yet
- set_segdata( xd, 1, SEG_LVL_EOB, 0 );
- enable_segfeature(xd, 1, SEG_LVL_EOB);
- }
- }
- // Disable segmentation and clear down features if alt ref
- // is not active for this group
- else
- {
- vp8_disable_segmentation((VP8_PTR)cpi);
-
- vpx_memset( cpi->segmentation_map, 0,
- (cm->mb_rows * cm->mb_cols));
+ // EOB segment coding not fixed for 8x8 yet
+ set_segdata(xd, 1, SEG_LVL_EOB, 0);
+ enable_segfeature(xd, 1, SEG_LVL_EOB);
+ }
+ }
+ // Disable segmentation and clear down features if alt ref
+ // is not active for this group
+ else {
+ vp8_disable_segmentation((VP8_PTR)cpi);
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
+ vpx_memset(cpi->segmentation_map, 0,
+ (cm->mb_rows * cm->mb_cols));
- clearall_segfeatures(xd);
- }
- }
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
- // Special case where we are coding over the top of a previous
- // alt ref frame
- // Segment coding disabled for compred testing
- else if ( cpi->is_src_frame_alt_ref )
- {
- // Enable mode and ref frame features for segment 0 as well
- enable_segfeature(xd, 0, SEG_LVL_REF_FRAME);
- enable_segfeature(xd, 0, SEG_LVL_MODE);
- enable_segfeature(xd, 1, SEG_LVL_REF_FRAME);
- enable_segfeature(xd, 1, SEG_LVL_MODE);
-
- // All mbs should use ALTREF_FRAME, ZEROMV exclusively
- clear_segref(xd, 0);
- set_segref(xd, 0, ALTREF_FRAME);
- clear_segref(xd, 1);
- set_segref(xd, 1, ALTREF_FRAME);
- set_segdata( xd, 0, SEG_LVL_MODE, ZEROMV );
- set_segdata( xd, 1, SEG_LVL_MODE, ZEROMV );
-
- // Skip all MBs if high Q
- if ( high_q )
- {
- enable_segfeature(xd, 0, SEG_LVL_EOB);
- set_segdata( xd, 0, SEG_LVL_EOB, 0 );
- enable_segfeature(xd, 1, SEG_LVL_EOB);
- set_segdata( xd, 1, SEG_LVL_EOB, 0 );
- }
- // Enable data udpate
- xd->update_mb_segmentation_data = 1;
- }
- // All other frames.
- else
- {
- // No updates.. leave things as they are.
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
- }
- }
+ clearall_segfeatures(xd);
+ }
+ }
+
+ // Special case where we are coding over the top of a previous
+ // alt ref frame
+ // Segment coding disabled for compred testing
+ else if (cpi->is_src_frame_alt_ref) {
+ // Enable mode and ref frame features for segment 0 as well
+ enable_segfeature(xd, 0, SEG_LVL_REF_FRAME);
+ enable_segfeature(xd, 0, SEG_LVL_MODE);
+ enable_segfeature(xd, 1, SEG_LVL_REF_FRAME);
+ enable_segfeature(xd, 1, SEG_LVL_MODE);
+
+ // All mbs should use ALTREF_FRAME, ZEROMV exclusively
+ clear_segref(xd, 0);
+ set_segref(xd, 0, ALTREF_FRAME);
+ clear_segref(xd, 1);
+ set_segref(xd, 1, ALTREF_FRAME);
+ set_segdata(xd, 0, SEG_LVL_MODE, ZEROMV);
+ set_segdata(xd, 1, SEG_LVL_MODE, ZEROMV);
+
+ // Skip all MBs if high Q
+ if (high_q) {
+ enable_segfeature(xd, 0, SEG_LVL_EOB);
+ set_segdata(xd, 0, SEG_LVL_EOB, 0);
+ enable_segfeature(xd, 1, SEG_LVL_EOB);
+ set_segdata(xd, 1, SEG_LVL_EOB, 0);
+ }
+ // Enable data udpate
+ xd->update_mb_segmentation_data = 1;
+ }
+ // All other frames.
+ else {
+ // No updates.. leave things as they are.
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
+ }
+ }
}
// DEBUG: Print out the segment id of each MB in the current frame.
-static void print_seg_map(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = & cpi->common;
- int row,col;
- int map_index = 0;
- FILE *statsfile;
+static void print_seg_map(VP8_COMP *cpi) {
+ VP8_COMMON *cm = & cpi->common;
+ int row, col;
+ int map_index = 0;
+ FILE *statsfile;
- statsfile = fopen("segmap.stt", "a");
+ statsfile = fopen("segmap.stt", "a");
- fprintf(statsfile, "%10d\n",
- cm->current_video_frame );
+ fprintf(statsfile, "%10d\n",
+ cm->current_video_frame);
- for ( row = 0; row < cpi->common.mb_rows; row++ )
- {
- for ( col = 0; col < cpi->common.mb_cols; col++ )
- {
- fprintf(statsfile, "%10d",
- cpi->segmentation_map[map_index]);
- map_index++;
- }
- fprintf(statsfile, "\n");
+ for (row = 0; row < cpi->common.mb_rows; row++) {
+ for (col = 0; col < cpi->common.mb_cols; col++) {
+ fprintf(statsfile, "%10d",
+ cpi->segmentation_map[map_index]);
+ map_index++;
}
fprintf(statsfile, "\n");
+ }
+ fprintf(statsfile, "\n");
- fclose(statsfile);
+ fclose(statsfile);
}
-static void set_default_lf_deltas(VP8_COMP *cpi)
-{
- cpi->mb.e_mbd.mode_ref_lf_delta_enabled = 1;
- cpi->mb.e_mbd.mode_ref_lf_delta_update = 1;
+static void set_default_lf_deltas(VP8_COMP *cpi) {
+ cpi->mb.e_mbd.mode_ref_lf_delta_enabled = 1;
+ cpi->mb.e_mbd.mode_ref_lf_delta_update = 1;
- vpx_memset(cpi->mb.e_mbd.ref_lf_deltas, 0, sizeof(cpi->mb.e_mbd.ref_lf_deltas));
- vpx_memset(cpi->mb.e_mbd.mode_lf_deltas, 0, sizeof(cpi->mb.e_mbd.mode_lf_deltas));
+ vpx_memset(cpi->mb.e_mbd.ref_lf_deltas, 0, sizeof(cpi->mb.e_mbd.ref_lf_deltas));
+ vpx_memset(cpi->mb.e_mbd.mode_lf_deltas, 0, sizeof(cpi->mb.e_mbd.mode_lf_deltas));
- // Test of ref frame deltas
- cpi->mb.e_mbd.ref_lf_deltas[INTRA_FRAME] = 2;
- cpi->mb.e_mbd.ref_lf_deltas[LAST_FRAME] = 0;
- cpi->mb.e_mbd.ref_lf_deltas[GOLDEN_FRAME] = -2;
- cpi->mb.e_mbd.ref_lf_deltas[ALTREF_FRAME] = -2;
+ // Test of ref frame deltas
+ cpi->mb.e_mbd.ref_lf_deltas[INTRA_FRAME] = 2;
+ cpi->mb.e_mbd.ref_lf_deltas[LAST_FRAME] = 0;
+ cpi->mb.e_mbd.ref_lf_deltas[GOLDEN_FRAME] = -2;
+ cpi->mb.e_mbd.ref_lf_deltas[ALTREF_FRAME] = -2;
- cpi->mb.e_mbd.mode_lf_deltas[0] = 4; // BPRED
- cpi->mb.e_mbd.mode_lf_deltas[1] = -2; // Zero
- cpi->mb.e_mbd.mode_lf_deltas[2] = 2; // New mv
- cpi->mb.e_mbd.mode_lf_deltas[3] = 4; // Split mv
+ cpi->mb.e_mbd.mode_lf_deltas[0] = 4; // BPRED
+ cpi->mb.e_mbd.mode_lf_deltas[1] = -2; // Zero
+ cpi->mb.e_mbd.mode_lf_deltas[2] = 2; // New mv
+ cpi->mb.e_mbd.mode_lf_deltas[3] = 4; // Split mv
}
-void vp8_set_speed_features(VP8_COMP *cpi)
-{
- SPEED_FEATURES *sf = &cpi->sf;
- int Mode = cpi->compressor_speed;
- int Speed = cpi->Speed;
- int i;
- VP8_COMMON *cm = &cpi->common;
-
- // Only modes 0 and 1 supported for now in experimental code basae
- if ( Mode > 1 )
- Mode = 1;
-
- // Initialise default mode frequency sampling variables
- for (i = 0; i < MAX_MODES; i ++)
- {
- cpi->mode_check_freq[i] = 0;
- cpi->mode_test_hit_counts[i] = 0;
- cpi->mode_chosen_counts[i] = 0;
- }
-
- // best quality defaults
- sf->RD = 1;
- sf->search_method = NSTEP;
- sf->improved_dct = 1;
- sf->auto_filter = 1;
- sf->recode_loop = 1;
- sf->quarter_pixel_search = 1;
- sf->half_pixel_search = 1;
- sf->iterative_sub_pixel = 1;
+void vp8_set_speed_features(VP8_COMP *cpi) {
+ SPEED_FEATURES *sf = &cpi->sf;
+ int Mode = cpi->compressor_speed;
+ int Speed = cpi->Speed;
+ int i;
+ VP8_COMMON *cm = &cpi->common;
+
+ // Only modes 0 and 1 supported for now in experimental code basae
+ if (Mode > 1)
+ Mode = 1;
+
+ // Initialise default mode frequency sampling variables
+ for (i = 0; i < MAX_MODES; i ++) {
+ cpi->mode_check_freq[i] = 0;
+ cpi->mode_test_hit_counts[i] = 0;
+ cpi->mode_chosen_counts[i] = 0;
+ }
+
+ // best quality defaults
+ sf->RD = 1;
+ sf->search_method = NSTEP;
+ sf->improved_dct = 1;
+ sf->auto_filter = 1;
+ sf->recode_loop = 1;
+ sf->quarter_pixel_search = 1;
+ sf->half_pixel_search = 1;
+ sf->iterative_sub_pixel = 1;
#if CONFIG_LOSSLESS
- sf->optimize_coefficients = 0;
+ sf->optimize_coefficients = 0;
#else
- sf->optimize_coefficients = 1;
+ sf->optimize_coefficients = 1;
#endif
- sf->no_skip_block4x4_search = 1;
+ sf->no_skip_block4x4_search = 1;
- sf->first_step = 0;
- sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
- sf->improved_mv_pred = 1;
+ sf->first_step = 0;
+ sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
+ sf->improved_mv_pred = 1;
- // default thresholds to 0
- for (i = 0; i < MAX_MODES; i++)
- sf->thresh_mult[i] = 0;
+ // default thresholds to 0
+ for (i = 0; i < MAX_MODES; i++)
+ sf->thresh_mult[i] = 0;
- switch (Mode)
- {
+ switch (Mode) {
case 0: // best quality mode
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
- sf->thresh_mult[THR_ZEROG ] = 0;
- sf->thresh_mult[THR_ZEROG_FILT ] = 0;
- sf->thresh_mult[THR_ZEROA ] = 0;
- sf->thresh_mult[THR_ZEROA_FILT ] = 0;
- sf->thresh_mult[THR_NEARESTMV ] = 0;
- sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
- sf->thresh_mult[THR_NEARESTG ] = 0;
- sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
- sf->thresh_mult[THR_NEARESTA ] = 0;
- sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_NEARMV_FILT ] = 0;
- sf->thresh_mult[THR_NEARG ] = 0;
- sf->thresh_mult[THR_NEARG_FILT ] = 0;
- sf->thresh_mult[THR_NEARA ] = 0;
- sf->thresh_mult[THR_NEARA_FILT ] = 0;
-
- sf->thresh_mult[THR_DC ] = 0;
-
- sf->thresh_mult[THR_V_PRED ] = 1000;
- sf->thresh_mult[THR_H_PRED ] = 1000;
- sf->thresh_mult[THR_B_PRED ] = 2000;
- sf->thresh_mult[THR_I8X8_PRED] = 2000;
- sf->thresh_mult[THR_TM ] = 1000;
-
- sf->thresh_mult[THR_NEWMV ] = 1000;
- sf->thresh_mult[THR_NEWG ] = 1000;
- sf->thresh_mult[THR_NEWA ] = 1000;
- sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
- sf->thresh_mult[THR_NEWG_FILT ] = 1000;
- sf->thresh_mult[THR_NEWA_FILT ] = 1000;
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
+ sf->thresh_mult[THR_ZEROG ] = 0;
+ sf->thresh_mult[THR_ZEROG_FILT ] = 0;
+ sf->thresh_mult[THR_ZEROA ] = 0;
+ sf->thresh_mult[THR_ZEROA_FILT ] = 0;
+ sf->thresh_mult[THR_NEARESTMV ] = 0;
+ sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
+ sf->thresh_mult[THR_NEARESTG ] = 0;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
+ sf->thresh_mult[THR_NEARESTA ] = 0;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_NEARMV_FILT ] = 0;
+ sf->thresh_mult[THR_NEARG ] = 0;
+ sf->thresh_mult[THR_NEARG_FILT ] = 0;
+ sf->thresh_mult[THR_NEARA ] = 0;
+ sf->thresh_mult[THR_NEARA_FILT ] = 0;
+
+ sf->thresh_mult[THR_DC ] = 0;
+
+ sf->thresh_mult[THR_V_PRED ] = 1000;
+ sf->thresh_mult[THR_H_PRED ] = 1000;
+ sf->thresh_mult[THR_B_PRED ] = 2000;
+ sf->thresh_mult[THR_I8X8_PRED] = 2000;
+ sf->thresh_mult[THR_TM ] = 1000;
+
+ sf->thresh_mult[THR_NEWMV ] = 1000;
+ sf->thresh_mult[THR_NEWG ] = 1000;
+ sf->thresh_mult[THR_NEWA ] = 1000;
+ sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
+ sf->thresh_mult[THR_NEWG_FILT ] = 1000;
+ sf->thresh_mult[THR_NEWA_FILT ] = 1000;
#else
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_ZEROG ] = 0;
- sf->thresh_mult[THR_ZEROA ] = 0;
- sf->thresh_mult[THR_NEARESTMV] = 0;
- sf->thresh_mult[THR_NEARESTG ] = 0;
- sf->thresh_mult[THR_NEARESTA ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_NEARG ] = 0;
- sf->thresh_mult[THR_NEARA ] = 0;
-
- sf->thresh_mult[THR_DC ] = 0;
-
- sf->thresh_mult[THR_V_PRED ] = 1000;
- sf->thresh_mult[THR_H_PRED ] = 1000;
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_ZEROG ] = 0;
+ sf->thresh_mult[THR_ZEROA ] = 0;
+ sf->thresh_mult[THR_NEARESTMV] = 0;
+ sf->thresh_mult[THR_NEARESTG ] = 0;
+ sf->thresh_mult[THR_NEARESTA ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_NEARG ] = 0;
+ sf->thresh_mult[THR_NEARA ] = 0;
+
+ sf->thresh_mult[THR_DC ] = 0;
+
+ sf->thresh_mult[THR_V_PRED ] = 1000;
+ sf->thresh_mult[THR_H_PRED ] = 1000;
#if CONFIG_NEWINTRAMODES
- sf->thresh_mult[THR_D45_PRED ] = 1000;
- sf->thresh_mult[THR_D135_PRED] = 1000;
- sf->thresh_mult[THR_D117_PRED] = 1000;
- sf->thresh_mult[THR_D153_PRED] = 1000;
- sf->thresh_mult[THR_D27_PRED ] = 1000;
- sf->thresh_mult[THR_D63_PRED ] = 1000;
+ sf->thresh_mult[THR_D45_PRED ] = 1000;
+ sf->thresh_mult[THR_D135_PRED] = 1000;
+ sf->thresh_mult[THR_D117_PRED] = 1000;
+ sf->thresh_mult[THR_D153_PRED] = 1000;
+ sf->thresh_mult[THR_D27_PRED ] = 1000;
+ sf->thresh_mult[THR_D63_PRED ] = 1000;
#endif
- sf->thresh_mult[THR_B_PRED ] = 2000;
- sf->thresh_mult[THR_I8X8_PRED] = 2000;
- sf->thresh_mult[THR_TM ] = 1000;
+ sf->thresh_mult[THR_B_PRED ] = 2000;
+ sf->thresh_mult[THR_I8X8_PRED] = 2000;
+ sf->thresh_mult[THR_TM ] = 1000;
- sf->thresh_mult[THR_NEWMV ] = 1000;
- sf->thresh_mult[THR_NEWG ] = 1000;
- sf->thresh_mult[THR_NEWA ] = 1000;
+ sf->thresh_mult[THR_NEWMV ] = 1000;
+ sf->thresh_mult[THR_NEWG ] = 1000;
+ sf->thresh_mult[THR_NEWA ] = 1000;
#endif
- sf->thresh_mult[THR_SPLITMV ] = 2500;
- sf->thresh_mult[THR_SPLITG ] = 5000;
- sf->thresh_mult[THR_SPLITA ] = 5000;
-
- sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
- sf->thresh_mult[THR_COMP_NEARLG ] = 0;
- sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
- sf->thresh_mult[THR_COMP_NEARLA ] = 0;
- sf->thresh_mult[THR_COMP_ZEROGA ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTGA] = 0;
- sf->thresh_mult[THR_COMP_NEARGA ] = 0;
-
- sf->thresh_mult[THR_COMP_NEWLG ] = 1000;
- sf->thresh_mult[THR_COMP_NEWLA ] = 1000;
- sf->thresh_mult[THR_COMP_NEWGA ] = 1000;
-
- sf->thresh_mult[THR_COMP_SPLITLA ] = 2500;
- sf->thresh_mult[THR_COMP_SPLITGA ] = 5000;
- sf->thresh_mult[THR_COMP_SPLITLG ] = 5000;
-
- sf->first_step = 0;
- sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
+ sf->thresh_mult[THR_SPLITMV ] = 2500;
+ sf->thresh_mult[THR_SPLITG ] = 5000;
+ sf->thresh_mult[THR_SPLITA ] = 5000;
+
+ sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
+ sf->thresh_mult[THR_COMP_NEARLG ] = 0;
+ sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
+ sf->thresh_mult[THR_COMP_NEARLA ] = 0;
+ sf->thresh_mult[THR_COMP_ZEROGA ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTGA] = 0;
+ sf->thresh_mult[THR_COMP_NEARGA ] = 0;
+
+ sf->thresh_mult[THR_COMP_NEWLG ] = 1000;
+ sf->thresh_mult[THR_COMP_NEWLA ] = 1000;
+ sf->thresh_mult[THR_COMP_NEWGA ] = 1000;
+
+ sf->thresh_mult[THR_COMP_SPLITLA ] = 2500;
+ sf->thresh_mult[THR_COMP_SPLITGA ] = 5000;
+ sf->thresh_mult[THR_COMP_SPLITLG ] = 5000;
+
+ sf->first_step = 0;
+ sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
#if CONFIG_ENHANCED_INTERP
- sf->search_best_filter = SEARCH_BEST_FILTER;
+ sf->search_best_filter = SEARCH_BEST_FILTER;
#endif
- break;
+ break;
case 1:
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTMV] = 0;
- sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
- sf->thresh_mult[THR_DC ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_NEARMV_FILT ] = 0;
- sf->thresh_mult[THR_V_PRED ] = 1000;
- sf->thresh_mult[THR_H_PRED ] = 1000;
+ sf->thresh_mult[THR_NEARESTMV] = 0;
+ sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
+ sf->thresh_mult[THR_DC ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_NEARMV_FILT ] = 0;
+ sf->thresh_mult[THR_V_PRED ] = 1000;
+ sf->thresh_mult[THR_H_PRED ] = 1000;
#if CONFIG_NEWINTRAMODES
- sf->thresh_mult[THR_D45_PRED ] = 1000;
- sf->thresh_mult[THR_D135_PRED] = 1000;
- sf->thresh_mult[THR_D117_PRED] = 1000;
- sf->thresh_mult[THR_D153_PRED] = 1000;
- sf->thresh_mult[THR_D27_PRED ] = 1000;
- sf->thresh_mult[THR_D63_PRED ] = 1000;
+ sf->thresh_mult[THR_D45_PRED ] = 1000;
+ sf->thresh_mult[THR_D135_PRED] = 1000;
+ sf->thresh_mult[THR_D117_PRED] = 1000;
+ sf->thresh_mult[THR_D153_PRED] = 1000;
+ sf->thresh_mult[THR_D27_PRED ] = 1000;
+ sf->thresh_mult[THR_D63_PRED ] = 1000;
#endif
- sf->thresh_mult[THR_B_PRED ] = 2500;
- sf->thresh_mult[THR_I8X8_PRED] = 2500;
- sf->thresh_mult[THR_TM ] = 1000;
-
- sf->thresh_mult[THR_NEARESTG ] = 1000;
- sf->thresh_mult[THR_NEARESTG_FILT ] = 1000;
- sf->thresh_mult[THR_NEARESTA ] = 1000;
- sf->thresh_mult[THR_NEARESTA_FILT ] = 1000;
-
- sf->thresh_mult[THR_ZEROG ] = 1000;
- sf->thresh_mult[THR_ZEROA ] = 1000;
- sf->thresh_mult[THR_NEARG ] = 1000;
- sf->thresh_mult[THR_NEARA ] = 1000;
- sf->thresh_mult[THR_ZEROG_FILT ] = 1000;
- sf->thresh_mult[THR_ZEROA_FILT ] = 1000;
- sf->thresh_mult[THR_NEARG_FILT ] = 1000;
- sf->thresh_mult[THR_NEARA_FILT ] = 1000;
-
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_ZEROG ] = 0;
- sf->thresh_mult[THR_ZEROA ] = 0;
- sf->thresh_mult[THR_NEARESTMV] = 0;
- sf->thresh_mult[THR_NEARESTG ] = 0;
- sf->thresh_mult[THR_NEARESTA ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_NEARG ] = 0;
- sf->thresh_mult[THR_NEARA ] = 0;
- sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
- sf->thresh_mult[THR_ZEROG_FILT ] = 0;
- sf->thresh_mult[THR_ZEROA_FILT ] = 0;
- sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
- sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
- sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
- sf->thresh_mult[THR_NEARMV_FILT ] = 0;
- sf->thresh_mult[THR_NEARG_FILT ] = 0;
- sf->thresh_mult[THR_NEARA_FILT ] = 0;
-
- sf->thresh_mult[THR_NEWMV ] = 1000;
- sf->thresh_mult[THR_NEWG ] = 1000;
- sf->thresh_mult[THR_NEWA ] = 1000;
- sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
- sf->thresh_mult[THR_NEWG_FILT ] = 1000;
- sf->thresh_mult[THR_NEWA_FILT ] = 1000;
+ sf->thresh_mult[THR_B_PRED ] = 2500;
+ sf->thresh_mult[THR_I8X8_PRED] = 2500;
+ sf->thresh_mult[THR_TM ] = 1000;
+
+ sf->thresh_mult[THR_NEARESTG ] = 1000;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = 1000;
+ sf->thresh_mult[THR_NEARESTA ] = 1000;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = 1000;
+
+ sf->thresh_mult[THR_ZEROG ] = 1000;
+ sf->thresh_mult[THR_ZEROA ] = 1000;
+ sf->thresh_mult[THR_NEARG ] = 1000;
+ sf->thresh_mult[THR_NEARA ] = 1000;
+ sf->thresh_mult[THR_ZEROG_FILT ] = 1000;
+ sf->thresh_mult[THR_ZEROA_FILT ] = 1000;
+ sf->thresh_mult[THR_NEARG_FILT ] = 1000;
+ sf->thresh_mult[THR_NEARA_FILT ] = 1000;
+
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_ZEROG ] = 0;
+ sf->thresh_mult[THR_ZEROA ] = 0;
+ sf->thresh_mult[THR_NEARESTMV] = 0;
+ sf->thresh_mult[THR_NEARESTG ] = 0;
+ sf->thresh_mult[THR_NEARESTA ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_NEARG ] = 0;
+ sf->thresh_mult[THR_NEARA ] = 0;
+ sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
+ sf->thresh_mult[THR_ZEROG_FILT ] = 0;
+ sf->thresh_mult[THR_ZEROA_FILT ] = 0;
+ sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
+ sf->thresh_mult[THR_NEARMV_FILT ] = 0;
+ sf->thresh_mult[THR_NEARG_FILT ] = 0;
+ sf->thresh_mult[THR_NEARA_FILT ] = 0;
+
+ sf->thresh_mult[THR_NEWMV ] = 1000;
+ sf->thresh_mult[THR_NEWG ] = 1000;
+ sf->thresh_mult[THR_NEWA ] = 1000;
+ sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
+ sf->thresh_mult[THR_NEWG_FILT ] = 1000;
+ sf->thresh_mult[THR_NEWA_FILT ] = 1000;
#else
- sf->thresh_mult[THR_NEARESTMV] = 0;
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_DC ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_V_PRED ] = 1000;
- sf->thresh_mult[THR_H_PRED ] = 1000;
+ sf->thresh_mult[THR_NEARESTMV] = 0;
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_DC ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_V_PRED ] = 1000;
+ sf->thresh_mult[THR_H_PRED ] = 1000;
#if CONFIG_NEWINTRAMODES
- sf->thresh_mult[THR_D45_PRED ] = 1000;
- sf->thresh_mult[THR_D135_PRED] = 1000;
- sf->thresh_mult[THR_D117_PRED] = 1000;
- sf->thresh_mult[THR_D153_PRED] = 1000;
- sf->thresh_mult[THR_D27_PRED ] = 1000;
- sf->thresh_mult[THR_D63_PRED ] = 1000;
+ sf->thresh_mult[THR_D45_PRED ] = 1000;
+ sf->thresh_mult[THR_D135_PRED] = 1000;
+ sf->thresh_mult[THR_D117_PRED] = 1000;
+ sf->thresh_mult[THR_D153_PRED] = 1000;
+ sf->thresh_mult[THR_D27_PRED ] = 1000;
+ sf->thresh_mult[THR_D63_PRED ] = 1000;
#endif
- sf->thresh_mult[THR_B_PRED ] = 2500;
- sf->thresh_mult[THR_I8X8_PRED] = 2500;
- sf->thresh_mult[THR_TM ] = 1000;
-
- sf->thresh_mult[THR_NEARESTG ] = 1000;
- sf->thresh_mult[THR_NEARESTA ] = 1000;
-
- sf->thresh_mult[THR_ZEROG ] = 1000;
- sf->thresh_mult[THR_ZEROA ] = 1000;
- sf->thresh_mult[THR_NEARG ] = 1000;
- sf->thresh_mult[THR_NEARA ] = 1000;
-
- sf->thresh_mult[THR_ZEROMV ] = 0;
- sf->thresh_mult[THR_ZEROG ] = 0;
- sf->thresh_mult[THR_ZEROA ] = 0;
- sf->thresh_mult[THR_NEARESTMV] = 0;
- sf->thresh_mult[THR_NEARESTG ] = 0;
- sf->thresh_mult[THR_NEARESTA ] = 0;
- sf->thresh_mult[THR_NEARMV ] = 0;
- sf->thresh_mult[THR_NEARG ] = 0;
- sf->thresh_mult[THR_NEARA ] = 0;
-
- sf->thresh_mult[THR_NEWMV ] = 1000;
- sf->thresh_mult[THR_NEWG ] = 1000;
- sf->thresh_mult[THR_NEWA ] = 1000;
+ sf->thresh_mult[THR_B_PRED ] = 2500;
+ sf->thresh_mult[THR_I8X8_PRED] = 2500;
+ sf->thresh_mult[THR_TM ] = 1000;
+
+ sf->thresh_mult[THR_NEARESTG ] = 1000;
+ sf->thresh_mult[THR_NEARESTA ] = 1000;
+
+ sf->thresh_mult[THR_ZEROG ] = 1000;
+ sf->thresh_mult[THR_ZEROA ] = 1000;
+ sf->thresh_mult[THR_NEARG ] = 1000;
+ sf->thresh_mult[THR_NEARA ] = 1000;
+
+ sf->thresh_mult[THR_ZEROMV ] = 0;
+ sf->thresh_mult[THR_ZEROG ] = 0;
+ sf->thresh_mult[THR_ZEROA ] = 0;
+ sf->thresh_mult[THR_NEARESTMV] = 0;
+ sf->thresh_mult[THR_NEARESTG ] = 0;
+ sf->thresh_mult[THR_NEARESTA ] = 0;
+ sf->thresh_mult[THR_NEARMV ] = 0;
+ sf->thresh_mult[THR_NEARG ] = 0;
+ sf->thresh_mult[THR_NEARA ] = 0;
+
+ sf->thresh_mult[THR_NEWMV ] = 1000;
+ sf->thresh_mult[THR_NEWG ] = 1000;
+ sf->thresh_mult[THR_NEWA ] = 1000;
#endif
- sf->thresh_mult[THR_SPLITMV ] = 1700;
- sf->thresh_mult[THR_SPLITG ] = 4500;
- sf->thresh_mult[THR_SPLITA ] = 4500;
-
- sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
- sf->thresh_mult[THR_COMP_NEARLG ] = 0;
- sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
- sf->thresh_mult[THR_COMP_NEARLA ] = 0;
- sf->thresh_mult[THR_COMP_ZEROGA ] = 0;
- sf->thresh_mult[THR_COMP_NEARESTGA] = 0;
- sf->thresh_mult[THR_COMP_NEARGA ] = 0;
-
- sf->thresh_mult[THR_COMP_NEWLG ] = 1000;
- sf->thresh_mult[THR_COMP_NEWLA ] = 1000;
- sf->thresh_mult[THR_COMP_NEWGA ] = 1000;
-
- sf->thresh_mult[THR_COMP_SPLITLA ] = 1700;
- sf->thresh_mult[THR_COMP_SPLITGA ] = 4500;
- sf->thresh_mult[THR_COMP_SPLITLG ] = 4500;
-
- if (Speed > 0)
- {
- /* Disable coefficient optimization above speed 0 */
- sf->optimize_coefficients = 0;
- sf->no_skip_block4x4_search = 0;
+ sf->thresh_mult[THR_SPLITMV ] = 1700;
+ sf->thresh_mult[THR_SPLITG ] = 4500;
+ sf->thresh_mult[THR_SPLITA ] = 4500;
+
+ sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
+ sf->thresh_mult[THR_COMP_NEARLG ] = 0;
+ sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
+ sf->thresh_mult[THR_COMP_NEARLA ] = 0;
+ sf->thresh_mult[THR_COMP_ZEROGA ] = 0;
+ sf->thresh_mult[THR_COMP_NEARESTGA] = 0;
+ sf->thresh_mult[THR_COMP_NEARGA ] = 0;
+
+ sf->thresh_mult[THR_COMP_NEWLG ] = 1000;
+ sf->thresh_mult[THR_COMP_NEWLA ] = 1000;
+ sf->thresh_mult[THR_COMP_NEWGA ] = 1000;
+
+ sf->thresh_mult[THR_COMP_SPLITLA ] = 1700;
+ sf->thresh_mult[THR_COMP_SPLITGA ] = 4500;
+ sf->thresh_mult[THR_COMP_SPLITLG ] = 4500;
+
+ if (Speed > 0) {
+ /* Disable coefficient optimization above speed 0 */
+ sf->optimize_coefficients = 0;
+ sf->no_skip_block4x4_search = 0;
- sf->first_step = 1;
+ sf->first_step = 1;
- cpi->mode_check_freq[THR_SPLITG] = 2;
- cpi->mode_check_freq[THR_SPLITA] = 2;
- cpi->mode_check_freq[THR_SPLITMV] = 0;
+ cpi->mode_check_freq[THR_SPLITG] = 2;
+ cpi->mode_check_freq[THR_SPLITA] = 2;
+ cpi->mode_check_freq[THR_SPLITMV] = 0;
- cpi->mode_check_freq[THR_COMP_SPLITGA] = 2;
- cpi->mode_check_freq[THR_COMP_SPLITLG] = 2;
- cpi->mode_check_freq[THR_COMP_SPLITLA] = 0;
- }
+ cpi->mode_check_freq[THR_COMP_SPLITGA] = 2;
+ cpi->mode_check_freq[THR_COMP_SPLITLG] = 2;
+ cpi->mode_check_freq[THR_COMP_SPLITLA] = 0;
+ }
- if (Speed > 1)
- {
- cpi->mode_check_freq[THR_SPLITG] = 4;
- cpi->mode_check_freq[THR_SPLITA] = 4;
- cpi->mode_check_freq[THR_SPLITMV] = 2;
+ if (Speed > 1) {
+ cpi->mode_check_freq[THR_SPLITG] = 4;
+ cpi->mode_check_freq[THR_SPLITA] = 4;
+ cpi->mode_check_freq[THR_SPLITMV] = 2;
- cpi->mode_check_freq[THR_COMP_SPLITGA] = 4;
- cpi->mode_check_freq[THR_COMP_SPLITLG] = 4;
- cpi->mode_check_freq[THR_COMP_SPLITLA] = 2;
+ cpi->mode_check_freq[THR_COMP_SPLITGA] = 4;
+ cpi->mode_check_freq[THR_COMP_SPLITLG] = 4;
+ cpi->mode_check_freq[THR_COMP_SPLITLA] = 2;
- sf->thresh_mult[THR_TM ] = 1500;
- sf->thresh_mult[THR_V_PRED ] = 1500;
- sf->thresh_mult[THR_H_PRED ] = 1500;
+ sf->thresh_mult[THR_TM ] = 1500;
+ sf->thresh_mult[THR_V_PRED ] = 1500;
+ sf->thresh_mult[THR_H_PRED ] = 1500;
#if CONFIG_NEWINTRAMODES
- sf->thresh_mult[THR_D45_PRED ] = 1500;
- sf->thresh_mult[THR_D135_PRED] = 1500;
- sf->thresh_mult[THR_D117_PRED] = 1500;
- sf->thresh_mult[THR_D153_PRED] = 1500;
- sf->thresh_mult[THR_D27_PRED ] = 1500;
- sf->thresh_mult[THR_D63_PRED ] = 1500;
+ sf->thresh_mult[THR_D45_PRED ] = 1500;
+ sf->thresh_mult[THR_D135_PRED] = 1500;
+ sf->thresh_mult[THR_D117_PRED] = 1500;
+ sf->thresh_mult[THR_D153_PRED] = 1500;
+ sf->thresh_mult[THR_D27_PRED ] = 1500;
+ sf->thresh_mult[THR_D63_PRED ] = 1500;
#endif
- sf->thresh_mult[THR_B_PRED ] = 5000;
- sf->thresh_mult[THR_I8X8_PRED] = 5000;
+ sf->thresh_mult[THR_B_PRED ] = 5000;
+ sf->thresh_mult[THR_I8X8_PRED] = 5000;
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
- {
- sf->thresh_mult[THR_NEWMV ] = 2000;
+ if (cpi->ref_frame_flags & VP8_LAST_FLAG) {
+ sf->thresh_mult[THR_NEWMV ] = 2000;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
+ sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
#endif
- sf->thresh_mult[THR_SPLITMV ] = 10000;
- sf->thresh_mult[THR_COMP_SPLITLG ] = 20000;
- }
+ sf->thresh_mult[THR_SPLITMV ] = 10000;
+ sf->thresh_mult[THR_COMP_SPLITLG ] = 20000;
+ }
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
- {
- sf->thresh_mult[THR_NEARESTG ] = 1500;
- sf->thresh_mult[THR_ZEROG ] = 1500;
- sf->thresh_mult[THR_NEARG ] = 1500;
- sf->thresh_mult[THR_NEWG ] = 2000;
+ if (cpi->ref_frame_flags & VP8_GOLD_FLAG) {
+ sf->thresh_mult[THR_NEARESTG ] = 1500;
+ sf->thresh_mult[THR_ZEROG ] = 1500;
+ sf->thresh_mult[THR_NEARG ] = 1500;
+ sf->thresh_mult[THR_NEWG ] = 2000;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTG_FILT ] = 1500;
- sf->thresh_mult[THR_ZEROG_FILT ] = 1500;
- sf->thresh_mult[THR_NEARG_FILT ] = 1500;
- sf->thresh_mult[THR_NEWG_FILT ] = 2000;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = 1500;
+ sf->thresh_mult[THR_ZEROG_FILT ] = 1500;
+ sf->thresh_mult[THR_NEARG_FILT ] = 1500;
+ sf->thresh_mult[THR_NEWG_FILT ] = 2000;
#endif
- sf->thresh_mult[THR_SPLITG ] = 20000;
- sf->thresh_mult[THR_COMP_SPLITGA ] = 20000;
- }
+ sf->thresh_mult[THR_SPLITG ] = 20000;
+ sf->thresh_mult[THR_COMP_SPLITGA ] = 20000;
+ }
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
- {
- sf->thresh_mult[THR_NEARESTA ] = 1500;
- sf->thresh_mult[THR_ZEROA ] = 1500;
- sf->thresh_mult[THR_NEARA ] = 1500;
- sf->thresh_mult[THR_NEWA ] = 2000;
+ if (cpi->ref_frame_flags & VP8_ALT_FLAG) {
+ sf->thresh_mult[THR_NEARESTA ] = 1500;
+ sf->thresh_mult[THR_ZEROA ] = 1500;
+ sf->thresh_mult[THR_NEARA ] = 1500;
+ sf->thresh_mult[THR_NEWA ] = 2000;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTA_FILT ] = 1500;
- sf->thresh_mult[THR_ZEROA_FILT ] = 1500;
- sf->thresh_mult[THR_NEARA_FILT ] = 1500;
- sf->thresh_mult[THR_NEWA_FILT ] = 2000;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = 1500;
+ sf->thresh_mult[THR_ZEROA_FILT ] = 1500;
+ sf->thresh_mult[THR_NEARA_FILT ] = 1500;
+ sf->thresh_mult[THR_NEWA_FILT ] = 2000;
#endif
- sf->thresh_mult[THR_SPLITA ] = 20000;
- sf->thresh_mult[THR_COMP_SPLITLA ] = 10000;
- }
-
- sf->thresh_mult[THR_COMP_ZEROLG ] = 1500;
- sf->thresh_mult[THR_COMP_NEARESTLG] = 1500;
- sf->thresh_mult[THR_COMP_NEARLG ] = 1500;
- sf->thresh_mult[THR_COMP_ZEROLA ] = 1500;
- sf->thresh_mult[THR_COMP_NEARESTLA] = 1500;
- sf->thresh_mult[THR_COMP_NEARLA ] = 1500;
- sf->thresh_mult[THR_COMP_ZEROGA ] = 1500;
- sf->thresh_mult[THR_COMP_NEARESTGA] = 1500;
- sf->thresh_mult[THR_COMP_NEARGA ] = 1500;
-
- sf->thresh_mult[THR_COMP_NEWLG ] = 2000;
- sf->thresh_mult[THR_COMP_NEWLA ] = 2000;
- sf->thresh_mult[THR_COMP_NEWGA ] = 2000;
+ sf->thresh_mult[THR_SPLITA ] = 20000;
+ sf->thresh_mult[THR_COMP_SPLITLA ] = 10000;
}
- if (Speed > 2)
- {
- cpi->mode_check_freq[THR_SPLITG] = 15;
- cpi->mode_check_freq[THR_SPLITA] = 15;
- cpi->mode_check_freq[THR_SPLITMV] = 7;
-
- cpi->mode_check_freq[THR_COMP_SPLITGA] = 15;
- cpi->mode_check_freq[THR_COMP_SPLITLG] = 15;
- cpi->mode_check_freq[THR_COMP_SPLITLA] = 7;
-
- sf->thresh_mult[THR_TM ] = 2000;
- sf->thresh_mult[THR_V_PRED ] = 2000;
- sf->thresh_mult[THR_H_PRED ] = 2000;
+ sf->thresh_mult[THR_COMP_ZEROLG ] = 1500;
+ sf->thresh_mult[THR_COMP_NEARESTLG] = 1500;
+ sf->thresh_mult[THR_COMP_NEARLG ] = 1500;
+ sf->thresh_mult[THR_COMP_ZEROLA ] = 1500;
+ sf->thresh_mult[THR_COMP_NEARESTLA] = 1500;
+ sf->thresh_mult[THR_COMP_NEARLA ] = 1500;
+ sf->thresh_mult[THR_COMP_ZEROGA ] = 1500;
+ sf->thresh_mult[THR_COMP_NEARESTGA] = 1500;
+ sf->thresh_mult[THR_COMP_NEARGA ] = 1500;
+
+ sf->thresh_mult[THR_COMP_NEWLG ] = 2000;
+ sf->thresh_mult[THR_COMP_NEWLA ] = 2000;
+ sf->thresh_mult[THR_COMP_NEWGA ] = 2000;
+ }
+
+ if (Speed > 2) {
+ cpi->mode_check_freq[THR_SPLITG] = 15;
+ cpi->mode_check_freq[THR_SPLITA] = 15;
+ cpi->mode_check_freq[THR_SPLITMV] = 7;
+
+ cpi->mode_check_freq[THR_COMP_SPLITGA] = 15;
+ cpi->mode_check_freq[THR_COMP_SPLITLG] = 15;
+ cpi->mode_check_freq[THR_COMP_SPLITLA] = 7;
+
+ sf->thresh_mult[THR_TM ] = 2000;
+ sf->thresh_mult[THR_V_PRED ] = 2000;
+ sf->thresh_mult[THR_H_PRED ] = 2000;
#if CONFIG_NEWINTRAMODES
- sf->thresh_mult[THR_D45_PRED ] = 2000;
- sf->thresh_mult[THR_D135_PRED] = 2000;
- sf->thresh_mult[THR_D117_PRED] = 2000;
- sf->thresh_mult[THR_D153_PRED] = 2000;
- sf->thresh_mult[THR_D27_PRED ] = 2000;
- sf->thresh_mult[THR_D63_PRED ] = 2000;
+ sf->thresh_mult[THR_D45_PRED ] = 2000;
+ sf->thresh_mult[THR_D135_PRED] = 2000;
+ sf->thresh_mult[THR_D117_PRED] = 2000;
+ sf->thresh_mult[THR_D153_PRED] = 2000;
+ sf->thresh_mult[THR_D27_PRED ] = 2000;
+ sf->thresh_mult[THR_D63_PRED ] = 2000;
#endif
- sf->thresh_mult[THR_B_PRED ] = 7500;
- sf->thresh_mult[THR_I8X8_PRED] = 7500;
+ sf->thresh_mult[THR_B_PRED ] = 7500;
+ sf->thresh_mult[THR_I8X8_PRED] = 7500;
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
- {
- sf->thresh_mult[THR_NEWMV ] = 2000;
+ if (cpi->ref_frame_flags & VP8_LAST_FLAG) {
+ sf->thresh_mult[THR_NEWMV ] = 2000;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
+ sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
#endif
- sf->thresh_mult[THR_SPLITMV ] = 25000;
- sf->thresh_mult[THR_COMP_SPLITLG ] = 50000;
- }
+ sf->thresh_mult[THR_SPLITMV ] = 25000;
+ sf->thresh_mult[THR_COMP_SPLITLG ] = 50000;
+ }
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
- {
- sf->thresh_mult[THR_NEARESTG ] = 2000;
- sf->thresh_mult[THR_ZEROG ] = 2000;
- sf->thresh_mult[THR_NEARG ] = 2000;
- sf->thresh_mult[THR_NEWG ] = 2500;
+ if (cpi->ref_frame_flags & VP8_GOLD_FLAG) {
+ sf->thresh_mult[THR_NEARESTG ] = 2000;
+ sf->thresh_mult[THR_ZEROG ] = 2000;
+ sf->thresh_mult[THR_NEARG ] = 2000;
+ sf->thresh_mult[THR_NEWG ] = 2500;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTG_FILT ] = 2000;
- sf->thresh_mult[THR_ZEROG_FILT ] = 2000;
- sf->thresh_mult[THR_NEARG_FILT ] = 2000;
- sf->thresh_mult[THR_NEWG_FILT ] = 2500;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = 2000;
+ sf->thresh_mult[THR_ZEROG_FILT ] = 2000;
+ sf->thresh_mult[THR_NEARG_FILT ] = 2000;
+ sf->thresh_mult[THR_NEWG_FILT ] = 2500;
#endif
- sf->thresh_mult[THR_SPLITG ] = 50000;
- sf->thresh_mult[THR_COMP_SPLITGA ] = 50000;
- }
+ sf->thresh_mult[THR_SPLITG ] = 50000;
+ sf->thresh_mult[THR_COMP_SPLITGA ] = 50000;
+ }
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
- {
- sf->thresh_mult[THR_NEARESTA ] = 2000;
- sf->thresh_mult[THR_ZEROA ] = 2000;
- sf->thresh_mult[THR_NEARA ] = 2000;
- sf->thresh_mult[THR_NEWA ] = 2500;
+ if (cpi->ref_frame_flags & VP8_ALT_FLAG) {
+ sf->thresh_mult[THR_NEARESTA ] = 2000;
+ sf->thresh_mult[THR_ZEROA ] = 2000;
+ sf->thresh_mult[THR_NEARA ] = 2000;
+ sf->thresh_mult[THR_NEWA ] = 2500;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTA_FILT ] = 2000;
- sf->thresh_mult[THR_ZEROA_FILT ] = 2000;
- sf->thresh_mult[THR_NEARA_FILT ] = 2000;
- sf->thresh_mult[THR_NEWA_FILT ] = 2500;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = 2000;
+ sf->thresh_mult[THR_ZEROA_FILT ] = 2000;
+ sf->thresh_mult[THR_NEARA_FILT ] = 2000;
+ sf->thresh_mult[THR_NEWA_FILT ] = 2500;
#endif
- sf->thresh_mult[THR_SPLITA ] = 50000;
- sf->thresh_mult[THR_COMP_SPLITLA ] = 25000;
- }
+ sf->thresh_mult[THR_SPLITA ] = 50000;
+ sf->thresh_mult[THR_COMP_SPLITLA ] = 25000;
+ }
- sf->thresh_mult[THR_COMP_ZEROLG ] = 2000;
- sf->thresh_mult[THR_COMP_NEARESTLG] = 2000;
- sf->thresh_mult[THR_COMP_NEARLG ] = 2000;
- sf->thresh_mult[THR_COMP_ZEROLA ] = 2000;
- sf->thresh_mult[THR_COMP_NEARESTLA] = 2000;
- sf->thresh_mult[THR_COMP_NEARLA ] = 2000;
- sf->thresh_mult[THR_COMP_ZEROGA ] = 2000;
- sf->thresh_mult[THR_COMP_NEARESTGA] = 2000;
- sf->thresh_mult[THR_COMP_NEARGA ] = 2000;
+ sf->thresh_mult[THR_COMP_ZEROLG ] = 2000;
+ sf->thresh_mult[THR_COMP_NEARESTLG] = 2000;
+ sf->thresh_mult[THR_COMP_NEARLG ] = 2000;
+ sf->thresh_mult[THR_COMP_ZEROLA ] = 2000;
+ sf->thresh_mult[THR_COMP_NEARESTLA] = 2000;
+ sf->thresh_mult[THR_COMP_NEARLA ] = 2000;
+ sf->thresh_mult[THR_COMP_ZEROGA ] = 2000;
+ sf->thresh_mult[THR_COMP_NEARESTGA] = 2000;
+ sf->thresh_mult[THR_COMP_NEARGA ] = 2000;
- sf->thresh_mult[THR_COMP_NEWLG ] = 2500;
- sf->thresh_mult[THR_COMP_NEWLA ] = 2500;
- sf->thresh_mult[THR_COMP_NEWGA ] = 2500;
+ sf->thresh_mult[THR_COMP_NEWLG ] = 2500;
+ sf->thresh_mult[THR_COMP_NEWLA ] = 2500;
+ sf->thresh_mult[THR_COMP_NEWGA ] = 2500;
- sf->improved_dct = 0;
+ sf->improved_dct = 0;
- // Only do recode loop on key frames, golden frames and
- // alt ref frames
- sf->recode_loop = 2;
+ // Only do recode loop on key frames, golden frames and
+ // alt ref frames
+ sf->recode_loop = 2;
- }
+ }
- break;
+ break;
- }; /* switch */
+ }; /* switch */
- /* disable frame modes if flags not set */
- if (!(cpi->ref_frame_flags & VP8_LAST_FLAG))
- {
- sf->thresh_mult[THR_NEWMV ] = INT_MAX;
- sf->thresh_mult[THR_NEARESTMV] = INT_MAX;
- sf->thresh_mult[THR_ZEROMV ] = INT_MAX;
- sf->thresh_mult[THR_NEARMV ] = INT_MAX;
+ /* disable frame modes if flags not set */
+ if (!(cpi->ref_frame_flags & VP8_LAST_FLAG)) {
+ sf->thresh_mult[THR_NEWMV ] = INT_MAX;
+ sf->thresh_mult[THR_NEARESTMV] = INT_MAX;
+ sf->thresh_mult[THR_ZEROMV ] = INT_MAX;
+ sf->thresh_mult[THR_NEARMV ] = INT_MAX;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEWMV_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEARESTMV_FILT] = INT_MAX;
- sf->thresh_mult[THR_ZEROMV_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEARMV_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEWMV_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARESTMV_FILT] = INT_MAX;
+ sf->thresh_mult[THR_ZEROMV_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARMV_FILT ] = INT_MAX;
#endif
- sf->thresh_mult[THR_SPLITMV ] = INT_MAX;
- }
-
- if (!(cpi->ref_frame_flags & VP8_GOLD_FLAG))
- {
- sf->thresh_mult[THR_NEARESTG ] = INT_MAX;
- sf->thresh_mult[THR_ZEROG ] = INT_MAX;
- sf->thresh_mult[THR_NEARG ] = INT_MAX;
- sf->thresh_mult[THR_NEWG ] = INT_MAX;
+ sf->thresh_mult[THR_SPLITMV ] = INT_MAX;
+ }
+
+ if (!(cpi->ref_frame_flags & VP8_GOLD_FLAG)) {
+ sf->thresh_mult[THR_NEARESTG ] = INT_MAX;
+ sf->thresh_mult[THR_ZEROG ] = INT_MAX;
+ sf->thresh_mult[THR_NEARG ] = INT_MAX;
+ sf->thresh_mult[THR_NEWG ] = INT_MAX;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTG_FILT ] = INT_MAX;
- sf->thresh_mult[THR_ZEROG_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEARG_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEWG_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARESTG_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_ZEROG_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARG_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEWG_FILT ] = INT_MAX;
#endif
- sf->thresh_mult[THR_SPLITG ] = INT_MAX;
- }
-
- if (!(cpi->ref_frame_flags & VP8_ALT_FLAG))
- {
- sf->thresh_mult[THR_NEARESTA ] = INT_MAX;
- sf->thresh_mult[THR_ZEROA ] = INT_MAX;
- sf->thresh_mult[THR_NEARA ] = INT_MAX;
- sf->thresh_mult[THR_NEWA ] = INT_MAX;
+ sf->thresh_mult[THR_SPLITG ] = INT_MAX;
+ }
+
+ if (!(cpi->ref_frame_flags & VP8_ALT_FLAG)) {
+ sf->thresh_mult[THR_NEARESTA ] = INT_MAX;
+ sf->thresh_mult[THR_ZEROA ] = INT_MAX;
+ sf->thresh_mult[THR_NEARA ] = INT_MAX;
+ sf->thresh_mult[THR_NEWA ] = INT_MAX;
#if CONFIG_PRED_FILTER
- sf->thresh_mult[THR_NEARESTA_FILT ] = INT_MAX;
- sf->thresh_mult[THR_ZEROA_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEARA_FILT ] = INT_MAX;
- sf->thresh_mult[THR_NEWA_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARESTA_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_ZEROA_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEARA_FILT ] = INT_MAX;
+ sf->thresh_mult[THR_NEWA_FILT ] = INT_MAX;
#endif
- sf->thresh_mult[THR_SPLITA ] = INT_MAX;
- }
-
- if ((cpi->ref_frame_flags & (VP8_LAST_FLAG | VP8_GOLD_FLAG)) != (VP8_LAST_FLAG | VP8_GOLD_FLAG))
- {
- sf->thresh_mult[THR_COMP_ZEROLG ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARESTLG] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARLG ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEWLG ] = INT_MAX;
- sf->thresh_mult[THR_COMP_SPLITLG ] = INT_MAX;
- }
-
- if ((cpi->ref_frame_flags & (VP8_LAST_FLAG | VP8_ALT_FLAG)) != (VP8_LAST_FLAG | VP8_ALT_FLAG))
- {
- sf->thresh_mult[THR_COMP_ZEROLA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARESTLA] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARLA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEWLA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_SPLITLA ] = INT_MAX;
- }
-
- if ((cpi->ref_frame_flags & (VP8_GOLD_FLAG | VP8_ALT_FLAG)) != (VP8_GOLD_FLAG | VP8_ALT_FLAG))
- {
- sf->thresh_mult[THR_COMP_ZEROGA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARESTGA] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEARGA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_NEWGA ] = INT_MAX;
- sf->thresh_mult[THR_COMP_SPLITGA ] = INT_MAX;
- }
-
- // Slow quant, dct and trellis not worthwhile for first pass
- // so make sure they are always turned off.
- if ( cpi->pass == 1 )
- {
- sf->optimize_coefficients = 0;
- sf->improved_dct = 0;
- }
+ sf->thresh_mult[THR_SPLITA ] = INT_MAX;
+ }
+
+ if ((cpi->ref_frame_flags & (VP8_LAST_FLAG | VP8_GOLD_FLAG)) != (VP8_LAST_FLAG | VP8_GOLD_FLAG)) {
+ sf->thresh_mult[THR_COMP_ZEROLG ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARESTLG] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARLG ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEWLG ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_SPLITLG ] = INT_MAX;
+ }
+
+ if ((cpi->ref_frame_flags & (VP8_LAST_FLAG | VP8_ALT_FLAG)) != (VP8_LAST_FLAG | VP8_ALT_FLAG)) {
+ sf->thresh_mult[THR_COMP_ZEROLA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARESTLA] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARLA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEWLA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_SPLITLA ] = INT_MAX;
+ }
+
+ if ((cpi->ref_frame_flags & (VP8_GOLD_FLAG | VP8_ALT_FLAG)) != (VP8_GOLD_FLAG | VP8_ALT_FLAG)) {
+ sf->thresh_mult[THR_COMP_ZEROGA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARESTGA] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEARGA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_NEWGA ] = INT_MAX;
+ sf->thresh_mult[THR_COMP_SPLITGA ] = INT_MAX;
+ }
+
+ // Slow quant, dct and trellis not worthwhile for first pass
+ // so make sure they are always turned off.
+ if (cpi->pass == 1) {
+ sf->optimize_coefficients = 0;
+ sf->improved_dct = 0;
+ }
- if (cpi->sf.search_method == NSTEP)
- {
- vp8_init3smotion_compensation(&cpi->mb, cm->yv12_fb[cm->lst_fb_idx].y_stride);
- }
- else if (cpi->sf.search_method == DIAMOND)
- {
- vp8_init_dsmotion_compensation(&cpi->mb, cm->yv12_fb[cm->lst_fb_idx].y_stride);
- }
+ if (cpi->sf.search_method == NSTEP) {
+ vp8_init3smotion_compensation(&cpi->mb, cm->yv12_fb[cm->lst_fb_idx].y_stride);
+ } else if (cpi->sf.search_method == DIAMOND) {
+ vp8_init_dsmotion_compensation(&cpi->mb, cm->yv12_fb[cm->lst_fb_idx].y_stride);
+ }
- if (cpi->sf.improved_dct)
- {
- cpi->mb.vp8_short_fdct8x8 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x8);
- cpi->mb.vp8_short_fdct8x4 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x4);
- cpi->mb.vp8_short_fdct4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, short4x4);
- }
- else
- {
- cpi->mb.vp8_short_fdct8x8 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x8);
- cpi->mb.vp8_short_fdct8x4 = FDCT_INVOKE(&cpi->rtcd.fdct, fast8x4);
- cpi->mb.vp8_short_fdct4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, fast4x4);
- }
+ if (cpi->sf.improved_dct) {
+ cpi->mb.vp8_short_fdct8x8 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x8);
+ cpi->mb.vp8_short_fdct8x4 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x4);
+ cpi->mb.vp8_short_fdct4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, short4x4);
+ } else {
+ cpi->mb.vp8_short_fdct8x8 = FDCT_INVOKE(&cpi->rtcd.fdct, short8x8);
+ cpi->mb.vp8_short_fdct8x4 = FDCT_INVOKE(&cpi->rtcd.fdct, fast8x4);
+ cpi->mb.vp8_short_fdct4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, fast4x4);
+ }
- cpi->mb.short_walsh4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, walsh_short4x4);
- cpi->mb.short_fhaar2x2 = FDCT_INVOKE(&cpi->rtcd.fdct, haar_short2x2);
+ cpi->mb.short_walsh4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, walsh_short4x4);
+ cpi->mb.short_fhaar2x2 = FDCT_INVOKE(&cpi->rtcd.fdct, haar_short2x2);
- cpi->mb.quantize_b = vp8_regular_quantize_b;
- cpi->mb.quantize_b_pair = vp8_regular_quantize_b_pair;
- cpi->mb.quantize_b_8x8 = vp8_regular_quantize_b_8x8;
- cpi->mb.quantize_b_2x2 = vp8_regular_quantize_b_2x2;
+ cpi->mb.quantize_b = vp8_regular_quantize_b;
+ cpi->mb.quantize_b_pair = vp8_regular_quantize_b_pair;
+ cpi->mb.quantize_b_8x8 = vp8_regular_quantize_b_8x8;
+ cpi->mb.quantize_b_2x2 = vp8_regular_quantize_b_2x2;
- vp8cx_init_quantizer(cpi);
+ vp8cx_init_quantizer(cpi);
#if CONFIG_RUNTIME_CPU_DETECT
- cpi->mb.e_mbd.rtcd = &cpi->common.rtcd;
+ cpi->mb.e_mbd.rtcd = &cpi->common.rtcd;
#endif
- if (cpi->sf.iterative_sub_pixel == 1)
- {
- cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step_iteratively;
- }
- else if (cpi->sf.quarter_pixel_search)
- {
- cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step;
- }
- else if (cpi->sf.half_pixel_search)
- {
- cpi->find_fractional_mv_step = vp8_find_best_half_pixel_step;
- }
+ if (cpi->sf.iterative_sub_pixel == 1) {
+ cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step_iteratively;
+ } else if (cpi->sf.quarter_pixel_search) {
+ cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step;
+ } else if (cpi->sf.half_pixel_search) {
+ cpi->find_fractional_mv_step = vp8_find_best_half_pixel_step;
+ }
- if (cpi->sf.optimize_coefficients == 1 && cpi->pass!=1)
- cpi->mb.optimize = 1;
- else
- cpi->mb.optimize = 0;
+ if (cpi->sf.optimize_coefficients == 1 && cpi->pass != 1)
+ cpi->mb.optimize = 1;
+ else
+ cpi->mb.optimize = 0;
#ifdef SPEEDSTATS
- frames_at_speed[cpi->Speed]++;
+ frames_at_speed[cpi->Speed]++;
#endif
}
-static void alloc_raw_frame_buffers(VP8_COMP *cpi)
-{
- int width = (cpi->oxcf.Width + 15) & ~15;
- int height = (cpi->oxcf.Height + 15) & ~15;
+static void alloc_raw_frame_buffers(VP8_COMP *cpi) {
+ int width = (cpi->oxcf.Width + 15) & ~15;
+ int height = (cpi->oxcf.Height + 15) & ~15;
- cpi->lookahead = vp8_lookahead_init(cpi->oxcf.Width, cpi->oxcf.Height,
- cpi->oxcf.lag_in_frames);
- if(!cpi->lookahead)
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate lag buffers");
+ cpi->lookahead = vp8_lookahead_init(cpi->oxcf.Width, cpi->oxcf.Height,
+ cpi->oxcf.lag_in_frames);
+ if (!cpi->lookahead)
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate lag buffers");
#if VP8_TEMPORAL_ALT_REF
- if (vp8_yv12_alloc_frame_buffer(&cpi->alt_ref_buffer,
- width, height, VP8BORDERINPIXELS))
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate altref buffer");
+ if (vp8_yv12_alloc_frame_buffer(&cpi->alt_ref_buffer,
+ width, height, VP8BORDERINPIXELS))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate altref buffer");
#endif
}
-static int vp8_alloc_partition_data(VP8_COMP *cpi)
-{
- vpx_free(cpi->mb.pip);
+static int vp8_alloc_partition_data(VP8_COMP *cpi) {
+ vpx_free(cpi->mb.pip);
- cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) *
- (cpi->common.mb_rows + 1),
- sizeof(PARTITION_INFO));
- if(!cpi->mb.pip)
- return 1;
+ cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) *
+ (cpi->common.mb_rows + 1),
+ sizeof(PARTITION_INFO));
+ if (!cpi->mb.pip)
+ return 1;
- cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
+ cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
- return 0;
+ return 0;
}
-void vp8_alloc_compressor_data(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = & cpi->common;
+void vp8_alloc_compressor_data(VP8_COMP *cpi) {
+ VP8_COMMON *cm = & cpi->common;
- int width = cm->Width;
- int height = cm->Height;
+ int width = cm->Width;
+ int height = cm->Height;
- if (vp8_alloc_frame_buffers(cm, width, height))
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate frame buffers");
+ if (vp8_alloc_frame_buffers(cm, width, height))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate frame buffers");
- if (vp8_alloc_partition_data(cpi))
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate partition data");
+ if (vp8_alloc_partition_data(cpi))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate partition data");
- if ((width & 0xf) != 0)
- width += 16 - (width & 0xf);
+ if ((width & 0xf) != 0)
+ width += 16 - (width & 0xf);
- if ((height & 0xf) != 0)
- height += 16 - (height & 0xf);
+ if ((height & 0xf) != 0)
+ height += 16 - (height & 0xf);
- if (vp8_yv12_alloc_frame_buffer(&cpi->last_frame_uf,
- width, height, VP8BORDERINPIXELS))
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate last frame buffer");
+ if (vp8_yv12_alloc_frame_buffer(&cpi->last_frame_uf,
+ width, height, VP8BORDERINPIXELS))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate last frame buffer");
- if (vp8_yv12_alloc_frame_buffer(&cpi->scaled_source,
- width, height, VP8BORDERINPIXELS))
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate scaled source buffer");
+ if (vp8_yv12_alloc_frame_buffer(&cpi->scaled_source,
+ width, height, VP8BORDERINPIXELS))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate scaled source buffer");
- vpx_free(cpi->tok);
+ vpx_free(cpi->tok);
- {
- unsigned int tokens = cm->mb_rows * cm->mb_cols * 24 * 16;
+ {
+ unsigned int tokens = cm->mb_rows * cm->mb_cols * 24 * 16;
- CHECK_MEM_ERROR(cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
- }
+ CHECK_MEM_ERROR(cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
+ }
- // Data used for real time vc mode to see if gf needs refreshing
- cpi->inter_zz_count = 0;
- cpi->gf_bad_count = 0;
- cpi->gf_update_recommended = 0;
+ // Data used for real time vc mode to see if gf needs refreshing
+ cpi->inter_zz_count = 0;
+ cpi->gf_bad_count = 0;
+ cpi->gf_update_recommended = 0;
- // Structures used to minitor GF usage
- vpx_free(cpi->gf_active_flags);
- CHECK_MEM_ERROR(cpi->gf_active_flags,
- vpx_calloc(1, cm->mb_rows * cm->mb_cols));
- cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
+ // Structures used to minitor GF usage
+ vpx_free(cpi->gf_active_flags);
+ CHECK_MEM_ERROR(cpi->gf_active_flags,
+ vpx_calloc(1, cm->mb_rows * cm->mb_cols));
+ cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
- vpx_free(cpi->mb_activity_map);
- CHECK_MEM_ERROR(cpi->mb_activity_map,
- vpx_calloc(sizeof(unsigned int),
- cm->mb_rows * cm->mb_cols));
+ vpx_free(cpi->mb_activity_map);
+ CHECK_MEM_ERROR(cpi->mb_activity_map,
+ vpx_calloc(sizeof(unsigned int),
+ cm->mb_rows * cm->mb_cols));
- vpx_free(cpi->mb_norm_activity_map);
- CHECK_MEM_ERROR(cpi->mb_norm_activity_map,
- vpx_calloc(sizeof(unsigned int),
- cm->mb_rows * cm->mb_cols));
+ vpx_free(cpi->mb_norm_activity_map);
+ CHECK_MEM_ERROR(cpi->mb_norm_activity_map,
+ vpx_calloc(sizeof(unsigned int),
+ cm->mb_rows * cm->mb_cols));
- vpx_free(cpi->twopass.total_stats);
+ vpx_free(cpi->twopass.total_stats);
- cpi->twopass.total_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
+ cpi->twopass.total_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
- vpx_free(cpi->twopass.total_left_stats);
- cpi->twopass.total_left_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
+ vpx_free(cpi->twopass.total_left_stats);
+ cpi->twopass.total_left_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
- vpx_free(cpi->twopass.this_frame_stats);
+ vpx_free(cpi->twopass.this_frame_stats);
- cpi->twopass.this_frame_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
+ cpi->twopass.this_frame_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS));
- if( !cpi->twopass.total_stats ||
- !cpi->twopass.total_left_stats ||
- !cpi->twopass.this_frame_stats)
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate firstpass stats");
+ if (!cpi->twopass.total_stats ||
+ !cpi->twopass.total_left_stats ||
+ !cpi->twopass.this_frame_stats)
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate firstpass stats");
- vpx_free(cpi->tplist);
+ vpx_free(cpi->tplist);
- CHECK_MEM_ERROR(cpi->tplist, vpx_malloc(sizeof(TOKENLIST) * cpi->common.mb_rows));
+ CHECK_MEM_ERROR(cpi->tplist, vpx_malloc(sizeof(TOKENLIST) * cpi->common.mb_rows));
}
@@ -1422,968 +1353,917 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
//
// Table that converts 0-63 Q range values passed in outside to the Qindex
// range used internally.
-static const int q_trans[] =
-{
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 60,
- 64, 68, 72, 76, 80, 84, 88, 92,
- 96, 100, 104, 108, 112, 116, 120, 124,
- 128, 132, 136, 140, 144, 148, 152, 156,
- 160, 164, 168, 172, 176, 180, 184, 188,
- 192, 196, 200, 204, 208, 212, 216, 220,
- 224, 228, 232, 236, 240, 244, 249, 255,
+static const int q_trans[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 44, 48, 52, 56, 60,
+ 64, 68, 72, 76, 80, 84, 88, 92,
+ 96, 100, 104, 108, 112, 116, 120, 124,
+ 128, 132, 136, 140, 144, 148, 152, 156,
+ 160, 164, 168, 172, 176, 180, 184, 188,
+ 192, 196, 200, 204, 208, 212, 216, 220,
+ 224, 228, 232, 236, 240, 244, 249, 255,
};
-int vp8_reverse_trans(int x)
-{
- int i;
+int vp8_reverse_trans(int x) {
+ int i;
- for (i = 0; i < 64; i++)
- if (q_trans[i] >= x)
- return i;
+ for (i = 0; i < 64; i++)
+ if (q_trans[i] >= x)
+ return i;
- return 63;
+ return 63;
};
-void vp8_new_frame_rate(VP8_COMP *cpi, double framerate)
-{
- if(framerate < .1)
- framerate = 30;
+void vp8_new_frame_rate(VP8_COMP *cpi, double framerate) {
+ if (framerate < .1)
+ framerate = 30;
- cpi->oxcf.frame_rate = framerate;
- cpi->output_frame_rate = cpi->oxcf.frame_rate;
- cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
- cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
- cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100);
+ cpi->oxcf.frame_rate = framerate;
+ cpi->output_frame_rate = cpi->oxcf.frame_rate;
+ cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
+ cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
+ cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100);
- if (cpi->min_frame_bandwidth < FRAME_OVERHEAD_BITS )
- cpi->min_frame_bandwidth = FRAME_OVERHEAD_BITS;
+ if (cpi->min_frame_bandwidth < FRAME_OVERHEAD_BITS)
+ cpi->min_frame_bandwidth = FRAME_OVERHEAD_BITS;
- // Set Maximum gf/arf interval
- cpi->max_gf_interval = ((int)(cpi->output_frame_rate / 2.0) + 2);
+ // Set Maximum gf/arf interval
+ cpi->max_gf_interval = ((int)(cpi->output_frame_rate / 2.0) + 2);
- if(cpi->max_gf_interval < 12)
- cpi->max_gf_interval = 12;
+ if (cpi->max_gf_interval < 12)
+ cpi->max_gf_interval = 12;
- // Extended interval for genuinely static scenes
- cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1;
+ // Extended interval for genuinely static scenes
+ cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1;
- // Special conditions when altr ref frame enabled in lagged compress mode
- if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames)
- {
- if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1)
- cpi->max_gf_interval = cpi->oxcf.lag_in_frames - 1;
+ // Special conditions when altr ref frame enabled in lagged compress mode
+ if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) {
+ if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1)
+ cpi->max_gf_interval = cpi->oxcf.lag_in_frames - 1;
- if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1)
- cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1;
- }
+ if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1)
+ cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1;
+ }
- if ( cpi->max_gf_interval > cpi->twopass.static_scene_max_gf_interval )
- cpi->max_gf_interval = cpi->twopass.static_scene_max_gf_interval;
+ if (cpi->max_gf_interval > cpi->twopass.static_scene_max_gf_interval)
+ cpi->max_gf_interval = cpi->twopass.static_scene_max_gf_interval;
}
static int
-rescale(int val, int num, int denom)
-{
- int64_t llnum = num;
- int64_t llden = denom;
- int64_t llval = val;
+rescale(int val, int num, int denom) {
+ int64_t llnum = num;
+ int64_t llden = denom;
+ int64_t llval = val;
- return llval * llnum / llden;
+ return llval * llnum / llden;
}
-static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
- VP8_COMMON *cm = &cpi->common;
+static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ VP8_COMMON *cm = &cpi->common;
- cpi->oxcf = *oxcf;
+ cpi->oxcf = *oxcf;
- cpi->goldfreq = 7;
+ cpi->goldfreq = 7;
- cm->version = oxcf->Version;
- vp8_setup_version(cm);
+ cm->version = oxcf->Version;
+ vp8_setup_version(cm);
- // change includes all joint functionality
- vp8_change_config(ptr, oxcf);
+ // change includes all joint functionality
+ vp8_change_config(ptr, oxcf);
- // Initialize active best and worst q and average q values.
- cpi->active_worst_quality = cpi->oxcf.worst_allowed_q;
- cpi->active_best_quality = cpi->oxcf.best_allowed_q;
- cpi->avg_frame_qindex = cpi->oxcf.worst_allowed_q;
+ // Initialize active best and worst q and average q values.
+ cpi->active_worst_quality = cpi->oxcf.worst_allowed_q;
+ cpi->active_best_quality = cpi->oxcf.best_allowed_q;
+ cpi->avg_frame_qindex = cpi->oxcf.worst_allowed_q;
- // Initialise the starting buffer levels
- cpi->buffer_level = cpi->oxcf.starting_buffer_level;
- cpi->bits_off_target = cpi->oxcf.starting_buffer_level;
+ // Initialise the starting buffer levels
+ cpi->buffer_level = cpi->oxcf.starting_buffer_level;
+ cpi->bits_off_target = cpi->oxcf.starting_buffer_level;
- cpi->rolling_target_bits = cpi->av_per_frame_bandwidth;
- cpi->rolling_actual_bits = cpi->av_per_frame_bandwidth;
- cpi->long_rolling_target_bits = cpi->av_per_frame_bandwidth;
- cpi->long_rolling_actual_bits = cpi->av_per_frame_bandwidth;
+ cpi->rolling_target_bits = cpi->av_per_frame_bandwidth;
+ cpi->rolling_actual_bits = cpi->av_per_frame_bandwidth;
+ cpi->long_rolling_target_bits = cpi->av_per_frame_bandwidth;
+ cpi->long_rolling_actual_bits = cpi->av_per_frame_bandwidth;
- cpi->total_actual_bits = 0;
- cpi->total_target_vs_actual = 0;
+ cpi->total_actual_bits = 0;
+ cpi->total_target_vs_actual = 0;
- cpi->static_mb_pct = 0;
+ cpi->static_mb_pct = 0;
#if VP8_TEMPORAL_ALT_REF
- {
- int i;
+ {
+ int i;
- cpi->fixed_divide[0] = 0;
+ cpi->fixed_divide[0] = 0;
- for (i = 1; i < 512; i++)
- cpi->fixed_divide[i] = 0x80000 / i;
- }
+ for (i = 1; i < 512; i++)
+ cpi->fixed_divide[i] = 0x80000 / i;
+ }
#endif
}
-void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
- VP8_COMMON *cm = &cpi->common;
+void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ VP8_COMMON *cm = &cpi->common;
- if (!cpi)
- return;
+ if (!cpi)
+ return;
- if (!oxcf)
- return;
+ if (!oxcf)
+ return;
- if (cm->version != oxcf->Version)
- {
- cm->version = oxcf->Version;
- vp8_setup_version(cm);
- }
+ if (cm->version != oxcf->Version) {
+ cm->version = oxcf->Version;
+ vp8_setup_version(cm);
+ }
- cpi->oxcf = *oxcf;
+ cpi->oxcf = *oxcf;
- switch (cpi->oxcf.Mode)
- {
- // Real time and one pass deprecated in test code base
+ switch (cpi->oxcf.Mode) {
+ // Real time and one pass deprecated in test code base
case MODE_FIRSTPASS:
- cpi->pass = 1;
- cpi->compressor_speed = 1;
- break;
+ cpi->pass = 1;
+ cpi->compressor_speed = 1;
+ break;
case MODE_SECONDPASS:
- cpi->pass = 2;
- cpi->compressor_speed = 1;
+ cpi->pass = 2;
+ cpi->compressor_speed = 1;
- if (cpi->oxcf.cpu_used < -5)
- {
- cpi->oxcf.cpu_used = -5;
- }
+ if (cpi->oxcf.cpu_used < -5) {
+ cpi->oxcf.cpu_used = -5;
+ }
- if (cpi->oxcf.cpu_used > 5)
- cpi->oxcf.cpu_used = 5;
+ if (cpi->oxcf.cpu_used > 5)
+ cpi->oxcf.cpu_used = 5;
- break;
+ break;
case MODE_SECONDPASS_BEST:
- cpi->pass = 2;
- cpi->compressor_speed = 0;
- break;
- }
+ cpi->pass = 2;
+ cpi->compressor_speed = 0;
+ break;
+ }
- cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q];
- cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q];
- cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
+ cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q];
+ cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q];
+ cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
#if CONFIG_LOSSLESS
- cpi->oxcf.lossless = oxcf->lossless;
- if(cpi->oxcf.lossless)
- {
- cpi->rtcd.fdct.short4x4 = vp8_short_walsh4x4_x8_c;
- cpi->rtcd.fdct.fast4x4 = vp8_short_walsh4x4_x8_c;
- cpi->rtcd.fdct.short8x4 = vp8_short_walsh8x4_x8_c;
- cpi->rtcd.fdct.fast8x4 = vp8_short_walsh8x4_x8_c;
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_lossless_c;
- cpi->common.rtcd.idct.idct1 = vp8_short_inv_walsh4x4_1_x8_c;
- cpi->common.rtcd.idct.idct16 = vp8_short_inv_walsh4x4_x8_c;
- cpi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_inv_walsh_add_c;
- cpi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
- cpi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_lossless_c;
- }
+ cpi->oxcf.lossless = oxcf->lossless;
+ if (cpi->oxcf.lossless) {
+ cpi->rtcd.fdct.short4x4 = vp8_short_walsh4x4_x8_c;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_walsh4x4_x8_c;
+ cpi->rtcd.fdct.short8x4 = vp8_short_walsh8x4_x8_c;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_walsh8x4_x8_c;
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_lossless_c;
+ cpi->common.rtcd.idct.idct1 = vp8_short_inv_walsh4x4_1_x8_c;
+ cpi->common.rtcd.idct.idct16 = vp8_short_inv_walsh4x4_x8_c;
+ cpi->common.rtcd.idct.idct1_scalar_add = vp8_dc_only_inv_walsh_add_c;
+ cpi->common.rtcd.idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c;
+ cpi->common.rtcd.idct.iwalsh16 = vp8_short_inv_walsh4x4_lossless_c;
+ }
#endif
- cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
+ cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
- cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
+ cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
- //cpi->use_golden_frame_only = 0;
- //cpi->use_last_frame_only = 0;
- cm->refresh_golden_frame = 0;
- cm->refresh_last_frame = 1;
- cm->refresh_entropy_probs = 1;
+ // cpi->use_golden_frame_only = 0;
+ // cpi->use_last_frame_only = 0;
+ cm->refresh_golden_frame = 0;
+ cm->refresh_last_frame = 1;
+ cm->refresh_entropy_probs = 1;
- setup_features(cpi);
+ setup_features(cpi);
#if CONFIG_HIGH_PRECISION_MV
- cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation
+ cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation
#endif
- {
- int i;
-
- for (i = 0; i < MAX_MB_SEGMENTS; i++)
- cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout;
- }
-
- // At the moment the first order values may not be > MAXQ
- if (cpi->oxcf.fixed_q > MAXQ)
- cpi->oxcf.fixed_q = MAXQ;
-
- // local file playback mode == really big buffer
- if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK)
- {
- cpi->oxcf.starting_buffer_level = 60000;
- cpi->oxcf.optimal_buffer_level = 60000;
- cpi->oxcf.maximum_buffer_size = 240000;
- }
-
- // Convert target bandwidth from Kbit/s to Bit/s
- cpi->oxcf.target_bandwidth *= 1000;
-
- cpi->oxcf.starting_buffer_level =
- rescale(cpi->oxcf.starting_buffer_level,
- cpi->oxcf.target_bandwidth, 1000);
-
- // Set or reset optimal and maximum buffer levels.
- if (cpi->oxcf.optimal_buffer_level == 0)
- cpi->oxcf.optimal_buffer_level = cpi->oxcf.target_bandwidth / 8;
- else
- cpi->oxcf.optimal_buffer_level =
- rescale(cpi->oxcf.optimal_buffer_level,
- cpi->oxcf.target_bandwidth, 1000);
-
- if (cpi->oxcf.maximum_buffer_size == 0)
- cpi->oxcf.maximum_buffer_size = cpi->oxcf.target_bandwidth / 8;
- else
- cpi->oxcf.maximum_buffer_size =
- rescale(cpi->oxcf.maximum_buffer_size,
- cpi->oxcf.target_bandwidth, 1000);
-
- // Set up frame rate and related parameters rate control values.
- vp8_new_frame_rate(cpi, cpi->oxcf.frame_rate);
-
- // Set absolute upper and lower quality limits
- cpi->worst_quality = cpi->oxcf.worst_allowed_q;
- cpi->best_quality = cpi->oxcf.best_allowed_q;
-
- // active values should only be modified if out of new range
- if (cpi->active_worst_quality > cpi->oxcf.worst_allowed_q)
- {
- cpi->active_worst_quality = cpi->oxcf.worst_allowed_q;
- }
- // less likely
- else if (cpi->active_worst_quality < cpi->oxcf.best_allowed_q)
- {
- cpi->active_worst_quality = cpi->oxcf.best_allowed_q;
- }
- if (cpi->active_best_quality < cpi->oxcf.best_allowed_q)
- {
- cpi->active_best_quality = cpi->oxcf.best_allowed_q;
- }
- // less likely
- else if (cpi->active_best_quality > cpi->oxcf.worst_allowed_q)
- {
- cpi->active_best_quality = cpi->oxcf.worst_allowed_q;
- }
-
- cpi->buffered_mode = (cpi->oxcf.optimal_buffer_level > 0) ? TRUE : FALSE;
-
- cpi->cq_target_quality = cpi->oxcf.cq_level;
+ {
+ int i;
- if (!cm->use_bilinear_mc_filter)
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout;
+ }
+
+ // At the moment the first order values may not be > MAXQ
+ if (cpi->oxcf.fixed_q > MAXQ)
+ cpi->oxcf.fixed_q = MAXQ;
+
+ // local file playback mode == really big buffer
+ if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) {
+ cpi->oxcf.starting_buffer_level = 60000;
+ cpi->oxcf.optimal_buffer_level = 60000;
+ cpi->oxcf.maximum_buffer_size = 240000;
+ }
+
+ // Convert target bandwidth from Kbit/s to Bit/s
+ cpi->oxcf.target_bandwidth *= 1000;
+
+ cpi->oxcf.starting_buffer_level =
+ rescale(cpi->oxcf.starting_buffer_level,
+ cpi->oxcf.target_bandwidth, 1000);
+
+ // Set or reset optimal and maximum buffer levels.
+ if (cpi->oxcf.optimal_buffer_level == 0)
+ cpi->oxcf.optimal_buffer_level = cpi->oxcf.target_bandwidth / 8;
+ else
+ cpi->oxcf.optimal_buffer_level =
+ rescale(cpi->oxcf.optimal_buffer_level,
+ cpi->oxcf.target_bandwidth, 1000);
+
+ if (cpi->oxcf.maximum_buffer_size == 0)
+ cpi->oxcf.maximum_buffer_size = cpi->oxcf.target_bandwidth / 8;
+ else
+ cpi->oxcf.maximum_buffer_size =
+ rescale(cpi->oxcf.maximum_buffer_size,
+ cpi->oxcf.target_bandwidth, 1000);
+
+ // Set up frame rate and related parameters rate control values.
+ vp8_new_frame_rate(cpi, cpi->oxcf.frame_rate);
+
+ // Set absolute upper and lower quality limits
+ cpi->worst_quality = cpi->oxcf.worst_allowed_q;
+ cpi->best_quality = cpi->oxcf.best_allowed_q;
+
+ // active values should only be modified if out of new range
+ if (cpi->active_worst_quality > cpi->oxcf.worst_allowed_q) {
+ cpi->active_worst_quality = cpi->oxcf.worst_allowed_q;
+ }
+ // less likely
+ else if (cpi->active_worst_quality < cpi->oxcf.best_allowed_q) {
+ cpi->active_worst_quality = cpi->oxcf.best_allowed_q;
+ }
+ if (cpi->active_best_quality < cpi->oxcf.best_allowed_q) {
+ cpi->active_best_quality = cpi->oxcf.best_allowed_q;
+ }
+ // less likely
+ else if (cpi->active_best_quality > cpi->oxcf.worst_allowed_q) {
+ cpi->active_best_quality = cpi->oxcf.worst_allowed_q;
+ }
+
+ cpi->buffered_mode = (cpi->oxcf.optimal_buffer_level > 0) ? TRUE : FALSE;
+
+ cpi->cq_target_quality = cpi->oxcf.cq_level;
+
+ if (!cm->use_bilinear_mc_filter)
#if CONFIG_ENHANCED_INTERP
- cm->mcomp_filter_type = EIGHTTAP;
+ cm->mcomp_filter_type = EIGHTTAP;
#else
- cm->mcomp_filter_type = SIXTAP;
+ cm->mcomp_filter_type = SIXTAP;
#endif
- else
- cm->mcomp_filter_type = BILINEAR;
+ else
+ cm->mcomp_filter_type = BILINEAR;
- cpi->target_bandwidth = cpi->oxcf.target_bandwidth;
+ cpi->target_bandwidth = cpi->oxcf.target_bandwidth;
- cm->Width = cpi->oxcf.Width ;
- cm->Height = cpi->oxcf.Height ;
+ cm->Width = cpi->oxcf.Width;
+ cm->Height = cpi->oxcf.Height;
- cm->horiz_scale = cpi->horiz_scale;
- cm->vert_scale = cpi->vert_scale ;
+ cm->horiz_scale = cpi->horiz_scale;
+ cm->vert_scale = cpi->vert_scale;
- // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
- if (cpi->oxcf.Sharpness > 7)
- cpi->oxcf.Sharpness = 7;
+ // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
+ if (cpi->oxcf.Sharpness > 7)
+ cpi->oxcf.Sharpness = 7;
- cm->sharpness_level = cpi->oxcf.Sharpness;
+ cm->sharpness_level = cpi->oxcf.Sharpness;
- if (cm->horiz_scale != NORMAL || cm->vert_scale != NORMAL)
- {
- int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs);
- int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs);
+ if (cm->horiz_scale != NORMAL || cm->vert_scale != NORMAL) {
+ int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs);
+ int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs);
- Scale2Ratio(cm->horiz_scale, &hr, &hs);
- Scale2Ratio(cm->vert_scale, &vr, &vs);
+ Scale2Ratio(cm->horiz_scale, &hr, &hs);
+ Scale2Ratio(cm->vert_scale, &vr, &vs);
- // always go to the next whole number
- cm->Width = (hs - 1 + cpi->oxcf.Width * hr) / hs;
- cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs;
- }
+ // always go to the next whole number
+ cm->Width = (hs - 1 + cpi->oxcf.Width * hr) / hs;
+ cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs;
+ }
- if (((cm->Width + 15) & 0xfffffff0) !=
- cm->yv12_fb[cm->lst_fb_idx].y_width ||
- ((cm->Height + 15) & 0xfffffff0) !=
- cm->yv12_fb[cm->lst_fb_idx].y_height ||
- cm->yv12_fb[cm->lst_fb_idx].y_width == 0)
- {
- alloc_raw_frame_buffers(cpi);
- vp8_alloc_compressor_data(cpi);
- }
+ if (((cm->Width + 15) & 0xfffffff0) !=
+ cm->yv12_fb[cm->lst_fb_idx].y_width ||
+ ((cm->Height + 15) & 0xfffffff0) !=
+ cm->yv12_fb[cm->lst_fb_idx].y_height ||
+ cm->yv12_fb[cm->lst_fb_idx].y_width == 0) {
+ alloc_raw_frame_buffers(cpi);
+ vp8_alloc_compressor_data(cpi);
+ }
- if (cpi->oxcf.fixed_q >= 0)
- {
- cpi->last_q[0] = cpi->oxcf.fixed_q;
- cpi->last_q[1] = cpi->oxcf.fixed_q;
- cpi->last_boosted_qindex = cpi->oxcf.fixed_q;
- }
+ if (cpi->oxcf.fixed_q >= 0) {
+ cpi->last_q[0] = cpi->oxcf.fixed_q;
+ cpi->last_q[1] = cpi->oxcf.fixed_q;
+ cpi->last_boosted_qindex = cpi->oxcf.fixed_q;
+ }
- cpi->Speed = cpi->oxcf.cpu_used;
+ cpi->Speed = cpi->oxcf.cpu_used;
- // force to allowlag to 0 if lag_in_frames is 0;
- if (cpi->oxcf.lag_in_frames == 0)
- {
- cpi->oxcf.allow_lag = 0;
- }
- // Limit on lag buffers as these are not currently dynamically allocated
- else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS)
- cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS;
+ // force to allowlag to 0 if lag_in_frames is 0;
+ if (cpi->oxcf.lag_in_frames == 0) {
+ cpi->oxcf.allow_lag = 0;
+ }
+ // Limit on lag buffers as these are not currently dynamically allocated
+ else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS)
+ cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS;
- // YX Temp
- cpi->alt_ref_source = NULL;
- cpi->is_src_frame_alt_ref = 0;
+ // YX Temp
+ cpi->alt_ref_source = NULL;
+ cpi->is_src_frame_alt_ref = 0;
#if 0
- // Experimental RD Code
- cpi->frame_distortion = 0;
- cpi->last_frame_distortion = 0;
+ // Experimental RD Code
+ cpi->frame_distortion = 0;
+ cpi->last_frame_distortion = 0;
#endif
}
#define M_LOG2_E 0.693147180559945309417
#define log2f(x) (log (x) / (float) M_LOG2_E)
-static void cal_mvsadcosts(int *mvsadcost[2])
-{
- int i = 1;
-
- mvsadcost [0] [0] = 300;
- mvsadcost [1] [0] = 300;
-
- do
- {
- double z = 256 * (2 * (log2f(8 * i) + .6));
- mvsadcost [0][i] = (int) z;
- mvsadcost [1][i] = (int) z;
- mvsadcost [0][-i] = (int) z;
- mvsadcost [1][-i] = (int) z;
- }
- while (++i <= mvfp_max);
+static void cal_mvsadcosts(int *mvsadcost[2]) {
+ int i = 1;
+
+ mvsadcost [0] [0] = 300;
+ mvsadcost [1] [0] = 300;
+
+ do {
+ double z = 256 * (2 * (log2f(8 * i) + .6));
+ mvsadcost [0][i] = (int) z;
+ mvsadcost [1][i] = (int) z;
+ mvsadcost [0][-i] = (int) z;
+ mvsadcost [1][-i] = (int) z;
+ } while (++i <= mvfp_max);
}
#if CONFIG_HIGH_PRECISION_MV
-static void cal_mvsadcosts_hp(int *mvsadcost[2])
-{
- int i = 1;
-
- mvsadcost [0] [0] = 300;
- mvsadcost [1] [0] = 300;
-
- do
- {
- double z = 256 * (2 * (log2f(8 * i) + .6));
- mvsadcost [0][i] = (int) z;
- mvsadcost [1][i] = (int) z;
- mvsadcost [0][-i] = (int) z;
- mvsadcost [1][-i] = (int) z;
- }
- while (++i <= mvfp_max_hp);
+static void cal_mvsadcosts_hp(int *mvsadcost[2]) {
+ int i = 1;
+
+ mvsadcost [0] [0] = 300;
+ mvsadcost [1] [0] = 300;
+
+ do {
+ double z = 256 * (2 * (log2f(8 * i) + .6));
+ mvsadcost [0][i] = (int) z;
+ mvsadcost [1][i] = (int) z;
+ mvsadcost [0][-i] = (int) z;
+ mvsadcost [1][-i] = (int) z;
+ } while (++i <= mvfp_max_hp);
}
#endif
-VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
-{
- int i;
- volatile union
- {
- VP8_COMP *cpi;
- VP8_PTR ptr;
- } ctx;
-
+VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf) {
+ int i;
+ volatile union {
VP8_COMP *cpi;
- VP8_COMMON *cm;
-
- cpi = ctx.cpi = vpx_memalign(32, sizeof(VP8_COMP));
- // Check that the CPI instance is valid
- if (!cpi)
- return 0;
-
- cm = &cpi->common;
-
- vpx_memset(cpi, 0, sizeof(VP8_COMP));
-
- if (setjmp(cm->error.jmp))
- {
- VP8_PTR ptr = ctx.ptr;
-
- ctx.cpi->common.error.setjmp = 0;
- vp8_remove_compressor(&ptr);
- return 0;
- }
-
- cpi->common.error.setjmp = 1;
+ VP8_PTR ptr;
+ } ctx;
- CHECK_MEM_ERROR(cpi->mb.ss, vpx_calloc(sizeof(search_site), (MAX_MVSEARCH_STEPS * 8) + 1));
+ VP8_COMP *cpi;
+ VP8_COMMON *cm;
- vp8_create_common(&cpi->common);
- vp8_cmachine_specific_config(cpi);
-
- init_config((VP8_PTR)cpi, oxcf);
-
- memcpy(cpi->base_skip_false_prob, vp8cx_base_skip_false_prob, sizeof(vp8cx_base_skip_false_prob));
- cpi->common.current_video_frame = 0;
- cpi->kf_overspend_bits = 0;
- cpi->kf_bitrate_adjustment = 0;
- cpi->frames_till_gf_update_due = 0;
- cpi->gf_overspend_bits = 0;
- cpi->non_gf_bitrate_adjustment = 0;
- cm->prob_last_coded = 128;
- cm->prob_gf_coded = 128;
- cm->prob_intra_coded = 63;
- for ( i = 0; i < COMP_PRED_CONTEXTS; i++ )
- cm->prob_comppred[i] = 128;
-
- // Prime the recent reference frame useage counters.
- // Hereafter they will be maintained as a sort of moving average
- cpi->recent_ref_frame_usage[INTRA_FRAME] = 1;
- cpi->recent_ref_frame_usage[LAST_FRAME] = 1;
- cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1;
- cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1;
-
- // Set reference frame sign bias for ALTREF frame to 1 (for now)
- cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
-
- cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
-
- cpi->gold_is_last = 0 ;
- cpi->alt_is_last = 0 ;
- cpi->gold_is_alt = 0 ;
-
- // allocate memory for storing last frame's MVs for MV prediction.
- CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cpi->common.mb_rows+2) * (cpi->common.mb_cols+2), sizeof(int_mv)));
- CHECK_MEM_ERROR(cpi->lf_ref_frame_sign_bias, vpx_calloc((cpi->common.mb_rows+2) * (cpi->common.mb_cols+2), sizeof(int)));
- CHECK_MEM_ERROR(cpi->lf_ref_frame, vpx_calloc((cpi->common.mb_rows+2) * (cpi->common.mb_cols+2), sizeof(int)));
-
- // Create the encoder segmentation map and set all entries to 0
- CHECK_MEM_ERROR(cpi->segmentation_map, vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ cpi = ctx.cpi = vpx_memalign(32, sizeof(VP8_COMP));
+ // Check that the CPI instance is valid
+ if (!cpi)
+ return 0;
- // And a copy in common for temporal coding
- CHECK_MEM_ERROR(cm->last_frame_seg_map,
- vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ cm = &cpi->common;
- // And a place holder structure is the coding context
- // for use if we want to save and restore it
- CHECK_MEM_ERROR(cpi->coding_context.last_frame_seg_map_copy,
- vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+ vpx_memset(cpi, 0, sizeof(VP8_COMP));
- CHECK_MEM_ERROR(cpi->active_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
- vpx_memset(cpi->active_map , 1, (cpi->common.mb_rows * cpi->common.mb_cols));
- cpi->active_map_enabled = 0;
+ if (setjmp(cm->error.jmp)) {
+ VP8_PTR ptr = ctx.ptr;
- for (i = 0; i < ( sizeof(cpi->mbgraph_stats) /
- sizeof(cpi->mbgraph_stats[0]) ); i++)
- {
- CHECK_MEM_ERROR(cpi->mbgraph_stats[i].mb_stats,
- vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols *
- sizeof(*cpi->mbgraph_stats[i].mb_stats),
- 1));
- }
+ ctx.cpi->common.error.setjmp = 0;
+ vp8_remove_compressor(&ptr);
+ return 0;
+ }
+
+ cpi->common.error.setjmp = 1;
+
+ CHECK_MEM_ERROR(cpi->mb.ss, vpx_calloc(sizeof(search_site), (MAX_MVSEARCH_STEPS * 8) + 1));
+
+ vp8_create_common(&cpi->common);
+ vp8_cmachine_specific_config(cpi);
+
+ init_config((VP8_PTR)cpi, oxcf);
+
+ memcpy(cpi->base_skip_false_prob, vp8cx_base_skip_false_prob, sizeof(vp8cx_base_skip_false_prob));
+ cpi->common.current_video_frame = 0;
+ cpi->kf_overspend_bits = 0;
+ cpi->kf_bitrate_adjustment = 0;
+ cpi->frames_till_gf_update_due = 0;
+ cpi->gf_overspend_bits = 0;
+ cpi->non_gf_bitrate_adjustment = 0;
+ cm->prob_last_coded = 128;
+ cm->prob_gf_coded = 128;
+ cm->prob_intra_coded = 63;
+ for (i = 0; i < COMP_PRED_CONTEXTS; i++)
+ cm->prob_comppred[i] = 128;
+
+ // Prime the recent reference frame useage counters.
+ // Hereafter they will be maintained as a sort of moving average
+ cpi->recent_ref_frame_usage[INTRA_FRAME] = 1;
+ cpi->recent_ref_frame_usage[LAST_FRAME] = 1;
+ cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1;
+ cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1;
+
+ // Set reference frame sign bias for ALTREF frame to 1 (for now)
+ cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
+
+ cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
+
+ cpi->gold_is_last = 0;
+ cpi->alt_is_last = 0;
+ cpi->gold_is_alt = 0;
+
+ // allocate memory for storing last frame's MVs for MV prediction.
+ CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cpi->common.mb_rows + 2) * (cpi->common.mb_cols + 2), sizeof(int_mv)));
+ CHECK_MEM_ERROR(cpi->lf_ref_frame_sign_bias, vpx_calloc((cpi->common.mb_rows + 2) * (cpi->common.mb_cols + 2), sizeof(int)));
+ CHECK_MEM_ERROR(cpi->lf_ref_frame, vpx_calloc((cpi->common.mb_rows + 2) * (cpi->common.mb_cols + 2), sizeof(int)));
+
+ // Create the encoder segmentation map and set all entries to 0
+ CHECK_MEM_ERROR(cpi->segmentation_map, vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+
+ // And a copy in common for temporal coding
+ CHECK_MEM_ERROR(cm->last_frame_seg_map,
+ vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+
+ // And a place holder structure is the coding context
+ // for use if we want to save and restore it
+ CHECK_MEM_ERROR(cpi->coding_context.last_frame_seg_map_copy,
+ vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
+
+ CHECK_MEM_ERROR(cpi->active_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
+ vpx_memset(cpi->active_map, 1, (cpi->common.mb_rows * cpi->common.mb_cols));
+ cpi->active_map_enabled = 0;
+
+ for (i = 0; i < (sizeof(cpi->mbgraph_stats) /
+ sizeof(cpi->mbgraph_stats[0])); i++) {
+ CHECK_MEM_ERROR(cpi->mbgraph_stats[i].mb_stats,
+ vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols *
+ sizeof(*cpi->mbgraph_stats[i].mb_stats),
+ 1));
+ }
#ifdef ENTROPY_STATS
- if(cpi->pass != 1)
- init_context_counters();
+ if (cpi->pass != 1)
+ init_context_counters();
#endif
#ifdef MODE_STATS
- vp8_zero(y_modes);
- vp8_zero(i8x8_modes);
- vp8_zero(uv_modes);
- vp8_zero(uv_modes_y);
- vp8_zero(b_modes);
- vp8_zero(inter_y_modes);
- vp8_zero(inter_uv_modes);
- vp8_zero(inter_b_modes);
+ vp8_zero(y_modes);
+ vp8_zero(i8x8_modes);
+ vp8_zero(uv_modes);
+ vp8_zero(uv_modes_y);
+ vp8_zero(b_modes);
+ vp8_zero(inter_y_modes);
+ vp8_zero(inter_uv_modes);
+ vp8_zero(inter_b_modes);
#endif
- /*Initialize the feed-forward activity masking.*/
- cpi->activity_avg = 90<<12;
+ /*Initialize the feed-forward activity masking.*/
+ cpi->activity_avg = 90 << 12;
- cpi->frames_since_key = 8; // Give a sensible default for the first frame.
- cpi->key_frame_frequency = cpi->oxcf.key_freq;
- cpi->this_key_frame_forced = FALSE;
- cpi->next_key_frame_forced = FALSE;
+ cpi->frames_since_key = 8; // Give a sensible default for the first frame.
+ cpi->key_frame_frequency = cpi->oxcf.key_freq;
+ cpi->this_key_frame_forced = FALSE;
+ cpi->next_key_frame_forced = FALSE;
- cpi->source_alt_ref_pending = FALSE;
- cpi->source_alt_ref_active = FALSE;
- cpi->common.refresh_alt_ref_frame = 0;
+ cpi->source_alt_ref_pending = FALSE;
+ cpi->source_alt_ref_active = FALSE;
+ cpi->common.refresh_alt_ref_frame = 0;
- cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS;
+ cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS;
#if CONFIG_INTERNAL_STATS
- cpi->b_calculate_ssimg = 0;
-
- cpi->count = 0;
- cpi->bytes = 0;
-
- if (cpi->b_calculate_psnr)
- {
- cpi->total_sq_error = 0.0;
- cpi->total_sq_error2 = 0.0;
- cpi->total_y = 0.0;
- cpi->total_u = 0.0;
- cpi->total_v = 0.0;
- cpi->total = 0.0;
- cpi->totalp_y = 0.0;
- cpi->totalp_u = 0.0;
- cpi->totalp_v = 0.0;
- cpi->totalp = 0.0;
- cpi->tot_recode_hits = 0;
- cpi->summed_quality = 0;
- cpi->summed_weights = 0;
- }
-
- if (cpi->b_calculate_ssimg)
- {
- cpi->total_ssimg_y = 0;
- cpi->total_ssimg_u = 0;
- cpi->total_ssimg_v = 0;
- cpi->total_ssimg_all = 0;
- }
+ cpi->b_calculate_ssimg = 0;
+
+ cpi->count = 0;
+ cpi->bytes = 0;
+
+ if (cpi->b_calculate_psnr) {
+ cpi->total_sq_error = 0.0;
+ cpi->total_sq_error2 = 0.0;
+ cpi->total_y = 0.0;
+ cpi->total_u = 0.0;
+ cpi->total_v = 0.0;
+ cpi->total = 0.0;
+ cpi->totalp_y = 0.0;
+ cpi->totalp_u = 0.0;
+ cpi->totalp_v = 0.0;
+ cpi->totalp = 0.0;
+ cpi->tot_recode_hits = 0;
+ cpi->summed_quality = 0;
+ cpi->summed_weights = 0;
+ }
+
+ if (cpi->b_calculate_ssimg) {
+ cpi->total_ssimg_y = 0;
+ cpi->total_ssimg_u = 0;
+ cpi->total_ssimg_v = 0;
+ cpi->total_ssimg_all = 0;
+ }
#endif
#ifndef LLONG_MAX
#define LLONG_MAX 9223372036854775807LL
#endif
- cpi->first_time_stamp_ever = LLONG_MAX;
+ cpi->first_time_stamp_ever = LLONG_MAX;
- cpi->frames_till_gf_update_due = 0;
- cpi->key_frame_count = 1;
+ cpi->frames_till_gf_update_due = 0;
+ cpi->key_frame_count = 1;
- cpi->ni_av_qi = cpi->oxcf.worst_allowed_q;
- cpi->ni_tot_qi = 0;
- cpi->ni_frames = 0;
- cpi->tot_q = 0.0;
- cpi->avg_q = vp8_convert_qindex_to_q( cpi->oxcf.worst_allowed_q );
- cpi->total_byte_count = 0;
+ cpi->ni_av_qi = cpi->oxcf.worst_allowed_q;
+ cpi->ni_tot_qi = 0;
+ cpi->ni_frames = 0;
+ cpi->tot_q = 0.0;
+ cpi->avg_q = vp8_convert_qindex_to_q(cpi->oxcf.worst_allowed_q);
+ cpi->total_byte_count = 0;
- cpi->rate_correction_factor = 1.0;
- cpi->key_frame_rate_correction_factor = 1.0;
- cpi->gf_rate_correction_factor = 1.0;
- cpi->twopass.est_max_qcorrection_factor = 1.0;
+ cpi->rate_correction_factor = 1.0;
+ cpi->key_frame_rate_correction_factor = 1.0;
+ cpi->gf_rate_correction_factor = 1.0;
+ cpi->twopass.est_max_qcorrection_factor = 1.0;
- cpi->mb.mvcost[0] = &cpi->mb.mvcosts[0][mv_max+1];
- cpi->mb.mvcost[1] = &cpi->mb.mvcosts[1][mv_max+1];
- cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mvfp_max+1];
- cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mvfp_max+1];
+ cpi->mb.mvcost[0] = &cpi->mb.mvcosts[0][mv_max + 1];
+ cpi->mb.mvcost[1] = &cpi->mb.mvcosts[1][mv_max + 1];
+ cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mvfp_max + 1];
+ cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mvfp_max + 1];
- cal_mvsadcosts(cpi->mb.mvsadcost);
+ cal_mvsadcosts(cpi->mb.mvsadcost);
#if CONFIG_HIGH_PRECISION_MV
- cpi->mb.mvcost_hp[0] = &cpi->mb.mvcosts_hp[0][mv_max_hp+1];
- cpi->mb.mvcost_hp[1] = &cpi->mb.mvcosts_hp[1][mv_max_hp+1];
- cpi->mb.mvsadcost_hp[0] = &cpi->mb.mvsadcosts_hp[0][mvfp_max_hp+1];
- cpi->mb.mvsadcost_hp[1] = &cpi->mb.mvsadcosts_hp[1][mvfp_max_hp+1];
+ cpi->mb.mvcost_hp[0] = &cpi->mb.mvcosts_hp[0][mv_max_hp + 1];
+ cpi->mb.mvcost_hp[1] = &cpi->mb.mvcosts_hp[1][mv_max_hp + 1];
+ cpi->mb.mvsadcost_hp[0] = &cpi->mb.mvsadcosts_hp[0][mvfp_max_hp + 1];
+ cpi->mb.mvsadcost_hp[1] = &cpi->mb.mvsadcosts_hp[1][mvfp_max_hp + 1];
- cal_mvsadcosts_hp(cpi->mb.mvsadcost_hp);
+ cal_mvsadcosts_hp(cpi->mb.mvsadcost_hp);
#endif
- for (i = 0; i < KEY_FRAME_CONTEXT; i++)
- {
- cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
- }
+ for (i = 0; i < KEY_FRAME_CONTEXT; i++) {
+ cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
+ }
#ifdef OUTPUT_YUV_SRC
- yuv_file = fopen("bd.yuv", "ab");
+ yuv_file = fopen("bd.yuv", "ab");
#endif
#ifdef OUTPUT_YUV_REC
- yuv_rec_file = fopen("rec.yuv", "wb");
+ yuv_rec_file = fopen("rec.yuv", "wb");
#endif
#if 0
- framepsnr = fopen("framepsnr.stt", "a");
- kf_list = fopen("kf_list.stt", "w");
+ framepsnr = fopen("framepsnr.stt", "a");
+ kf_list = fopen("kf_list.stt", "w");
#endif
- cpi->output_pkt_list = oxcf->output_pkt_list;
+ cpi->output_pkt_list = oxcf->output_pkt_list;
- if (cpi->pass == 1)
- {
- vp8_init_first_pass(cpi);
- }
- else if (cpi->pass == 2)
- {
- size_t packet_sz = sizeof(FIRSTPASS_STATS);
- int packets = oxcf->two_pass_stats_in.sz / packet_sz;
-
- cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
- cpi->twopass.stats_in = cpi->twopass.stats_in_start;
- cpi->twopass.stats_in_end = (void*)((char *)cpi->twopass.stats_in
- + (packets - 1) * packet_sz);
- vp8_init_second_pass(cpi);
- }
+ if (cpi->pass == 1) {
+ vp8_init_first_pass(cpi);
+ } else if (cpi->pass == 2) {
+ size_t packet_sz = sizeof(FIRSTPASS_STATS);
+ int packets = oxcf->two_pass_stats_in.sz / packet_sz;
- vp8_set_speed_features(cpi);
+ cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
+ cpi->twopass.stats_in = cpi->twopass.stats_in_start;
+ cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in
+ + (packets - 1) * packet_sz);
+ vp8_init_second_pass(cpi);
+ }
- // Set starting values of RD threshold multipliers (128 = *1)
- for (i = 0; i < MAX_MODES; i++)
- {
- cpi->rd_thresh_mult[i] = 128;
- }
+ vp8_set_speed_features(cpi);
+
+ // Set starting values of RD threshold multipliers (128 = *1)
+ for (i = 0; i < MAX_MODES; i++) {
+ cpi->rd_thresh_mult[i] = 128;
+ }
#ifdef ENTROPY_STATS
- init_mv_ref_counts();
+ init_mv_ref_counts();
#endif
- cpi->fn_ptr[BLOCK_16X16].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16);
- cpi->fn_ptr[BLOCK_16X16].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16);
- cpi->fn_ptr[BLOCK_16X16].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar16x16);
- cpi->fn_ptr[BLOCK_16X16].svf_halfpix_h = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_h);
- cpi->fn_ptr[BLOCK_16X16].svf_halfpix_v = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_v);
- cpi->fn_ptr[BLOCK_16X16].svf_halfpix_hv = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_hv);
- cpi->fn_ptr[BLOCK_16X16].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x3);
- cpi->fn_ptr[BLOCK_16X16].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x8);
- cpi->fn_ptr[BLOCK_16X16].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x4d);
-
- cpi->fn_ptr[BLOCK_16X8].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8);
- cpi->fn_ptr[BLOCK_16X8].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x8);
- cpi->fn_ptr[BLOCK_16X8].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar16x8);
- cpi->fn_ptr[BLOCK_16X8].svf_halfpix_h = NULL;
- cpi->fn_ptr[BLOCK_16X8].svf_halfpix_v = NULL;
- cpi->fn_ptr[BLOCK_16X8].svf_halfpix_hv = NULL;
- cpi->fn_ptr[BLOCK_16X8].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x3);
- cpi->fn_ptr[BLOCK_16X8].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x8);
- cpi->fn_ptr[BLOCK_16X8].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x4d);
-
- cpi->fn_ptr[BLOCK_8X16].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16);
- cpi->fn_ptr[BLOCK_8X16].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var8x16);
- cpi->fn_ptr[BLOCK_8X16].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar8x16);
- cpi->fn_ptr[BLOCK_8X16].svf_halfpix_h = NULL;
- cpi->fn_ptr[BLOCK_8X16].svf_halfpix_v = NULL;
- cpi->fn_ptr[BLOCK_8X16].svf_halfpix_hv = NULL;
- cpi->fn_ptr[BLOCK_8X16].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x3);
- cpi->fn_ptr[BLOCK_8X16].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x8);
- cpi->fn_ptr[BLOCK_8X16].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x4d);
-
- cpi->fn_ptr[BLOCK_8X8].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8);
- cpi->fn_ptr[BLOCK_8X8].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var8x8);
- cpi->fn_ptr[BLOCK_8X8].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar8x8);
- cpi->fn_ptr[BLOCK_8X8].svf_halfpix_h = NULL;
- cpi->fn_ptr[BLOCK_8X8].svf_halfpix_v = NULL;
- cpi->fn_ptr[BLOCK_8X8].svf_halfpix_hv = NULL;
- cpi->fn_ptr[BLOCK_8X8].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x3);
- cpi->fn_ptr[BLOCK_8X8].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x8);
- cpi->fn_ptr[BLOCK_8X8].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x4d);
-
- cpi->fn_ptr[BLOCK_4X4].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4);
- cpi->fn_ptr[BLOCK_4X4].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var4x4);
- cpi->fn_ptr[BLOCK_4X4].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar4x4);
- cpi->fn_ptr[BLOCK_4X4].svf_halfpix_h = NULL;
- cpi->fn_ptr[BLOCK_4X4].svf_halfpix_v = NULL;
- cpi->fn_ptr[BLOCK_4X4].svf_halfpix_hv = NULL;
- cpi->fn_ptr[BLOCK_4X4].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x3);
- cpi->fn_ptr[BLOCK_4X4].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x8);
- cpi->fn_ptr[BLOCK_4X4].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x4d);
+ cpi->fn_ptr[BLOCK_16X16].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16);
+ cpi->fn_ptr[BLOCK_16X16].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16);
+ cpi->fn_ptr[BLOCK_16X16].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar16x16);
+ cpi->fn_ptr[BLOCK_16X16].svf_halfpix_h = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_h);
+ cpi->fn_ptr[BLOCK_16X16].svf_halfpix_v = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_v);
+ cpi->fn_ptr[BLOCK_16X16].svf_halfpix_hv = VARIANCE_INVOKE(&cpi->rtcd.variance, halfpixvar16x16_hv);
+ cpi->fn_ptr[BLOCK_16X16].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x3);
+ cpi->fn_ptr[BLOCK_16X16].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x8);
+ cpi->fn_ptr[BLOCK_16X16].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x16x4d);
+
+ cpi->fn_ptr[BLOCK_16X8].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8);
+ cpi->fn_ptr[BLOCK_16X8].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x8);
+ cpi->fn_ptr[BLOCK_16X8].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar16x8);
+ cpi->fn_ptr[BLOCK_16X8].svf_halfpix_h = NULL;
+ cpi->fn_ptr[BLOCK_16X8].svf_halfpix_v = NULL;
+ cpi->fn_ptr[BLOCK_16X8].svf_halfpix_hv = NULL;
+ cpi->fn_ptr[BLOCK_16X8].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x3);
+ cpi->fn_ptr[BLOCK_16X8].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x8);
+ cpi->fn_ptr[BLOCK_16X8].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad16x8x4d);
+
+ cpi->fn_ptr[BLOCK_8X16].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16);
+ cpi->fn_ptr[BLOCK_8X16].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var8x16);
+ cpi->fn_ptr[BLOCK_8X16].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar8x16);
+ cpi->fn_ptr[BLOCK_8X16].svf_halfpix_h = NULL;
+ cpi->fn_ptr[BLOCK_8X16].svf_halfpix_v = NULL;
+ cpi->fn_ptr[BLOCK_8X16].svf_halfpix_hv = NULL;
+ cpi->fn_ptr[BLOCK_8X16].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x3);
+ cpi->fn_ptr[BLOCK_8X16].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x8);
+ cpi->fn_ptr[BLOCK_8X16].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x16x4d);
+
+ cpi->fn_ptr[BLOCK_8X8].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8);
+ cpi->fn_ptr[BLOCK_8X8].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var8x8);
+ cpi->fn_ptr[BLOCK_8X8].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar8x8);
+ cpi->fn_ptr[BLOCK_8X8].svf_halfpix_h = NULL;
+ cpi->fn_ptr[BLOCK_8X8].svf_halfpix_v = NULL;
+ cpi->fn_ptr[BLOCK_8X8].svf_halfpix_hv = NULL;
+ cpi->fn_ptr[BLOCK_8X8].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x3);
+ cpi->fn_ptr[BLOCK_8X8].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x8);
+ cpi->fn_ptr[BLOCK_8X8].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad8x8x4d);
+
+ cpi->fn_ptr[BLOCK_4X4].sdf = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4);
+ cpi->fn_ptr[BLOCK_4X4].vf = VARIANCE_INVOKE(&cpi->rtcd.variance, var4x4);
+ cpi->fn_ptr[BLOCK_4X4].svf = VARIANCE_INVOKE(&cpi->rtcd.variance, subpixvar4x4);
+ cpi->fn_ptr[BLOCK_4X4].svf_halfpix_h = NULL;
+ cpi->fn_ptr[BLOCK_4X4].svf_halfpix_v = NULL;
+ cpi->fn_ptr[BLOCK_4X4].svf_halfpix_hv = NULL;
+ cpi->fn_ptr[BLOCK_4X4].sdx3f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x3);
+ cpi->fn_ptr[BLOCK_4X4].sdx8f = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x8);
+ cpi->fn_ptr[BLOCK_4X4].sdx4df = VARIANCE_INVOKE(&cpi->rtcd.variance, sad4x4x4d);
#if ARCH_X86 || ARCH_X86_64
- cpi->fn_ptr[BLOCK_16X16].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
- cpi->fn_ptr[BLOCK_16X8].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
- cpi->fn_ptr[BLOCK_8X16].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
- cpi->fn_ptr[BLOCK_8X8].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
- cpi->fn_ptr[BLOCK_4X4].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
+ cpi->fn_ptr[BLOCK_16X16].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
+ cpi->fn_ptr[BLOCK_16X8].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
+ cpi->fn_ptr[BLOCK_8X16].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
+ cpi->fn_ptr[BLOCK_8X8].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
+ cpi->fn_ptr[BLOCK_4X4].copymem = VARIANCE_INVOKE(&cpi->rtcd.variance, copy32xn);
#endif
- cpi->full_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, full_search);
- cpi->diamond_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, diamond_search);
- cpi->refining_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, refining_search);
+ cpi->full_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, full_search);
+ cpi->diamond_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, diamond_search);
+ cpi->refining_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, refining_search);
- // make sure frame 1 is okay
- cpi->error_bins[0] = cpi->common.MBs;
+ // make sure frame 1 is okay
+ cpi->error_bins[0] = cpi->common.MBs;
- //vp8cx_init_quantizer() is first called here. Add check in vp8cx_frame_init_quantizer() so that vp8cx_init_quantizer is only called later
- //when needed. This will avoid unnecessary calls of vp8cx_init_quantizer() for every frame.
- vp8cx_init_quantizer(cpi);
+ // vp8cx_init_quantizer() is first called here. Add check in vp8cx_frame_init_quantizer() so that vp8cx_init_quantizer is only called later
+ // when needed. This will avoid unnecessary calls of vp8cx_init_quantizer() for every frame.
+ vp8cx_init_quantizer(cpi);
- vp8_loop_filter_init(cm);
+ vp8_loop_filter_init(cm);
- cpi->common.error.setjmp = 0;
+ cpi->common.error.setjmp = 0;
- vp8_zero(cpi->y_uv_mode_count)
+ vp8_zero(cpi->y_uv_mode_count)
- return (VP8_PTR) cpi;
+ return (VP8_PTR) cpi;
}
-void vp8_remove_compressor(VP8_PTR *ptr)
-{
- VP8_COMP *cpi = (VP8_COMP *)(*ptr);
- int i;
+void vp8_remove_compressor(VP8_PTR *ptr) {
+ VP8_COMP *cpi = (VP8_COMP *)(*ptr);
+ int i;
- if (!cpi)
- return;
+ if (!cpi)
+ return;
- if (cpi && (cpi->common.current_video_frame > 0))
- {
- if (cpi->pass == 2)
- {
- vp8_end_second_pass(cpi);
- }
+ if (cpi && (cpi->common.current_video_frame > 0)) {
+ if (cpi->pass == 2) {
+ vp8_end_second_pass(cpi);
+ }
#ifdef ENTROPY_STATS
- if(cpi->pass != 1)
- {
- print_context_counters();
- print_tree_update_probs();
- print_mode_context();
+ if (cpi->pass != 1) {
+ print_context_counters();
+ print_tree_update_probs();
+ print_mode_context();
}
#endif
#if CONFIG_INTERNAL_STATS
- vp8_clear_system_state();
+ vp8_clear_system_state();
- //printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count);
- if (cpi->pass != 1)
- {
- FILE *f = fopen("opsnr.stt", "a");
- double time_encoded = (cpi->last_end_time_stamp_seen
- - cpi->first_time_stamp_ever) / 10000000.000;
- double total_encode_time = (cpi->time_receive_data + cpi->time_compress_data) / 1000.000;
- double dr = (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded;
+ // printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count);
+ if (cpi->pass != 1) {
+ FILE *f = fopen("opsnr.stt", "a");
+ double time_encoded = (cpi->last_end_time_stamp_seen
+ - cpi->first_time_stamp_ever) / 10000000.000;
+ double total_encode_time = (cpi->time_receive_data + cpi->time_compress_data) / 1000.000;
+ double dr = (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded;
#if defined(MODE_STATS)
- print_mode_contexts(&cpi->common);
+ print_mode_contexts(&cpi->common);
#endif
- if (cpi->b_calculate_psnr)
- {
- YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
- double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_yv12->y_height;
- double total_psnr = vp8_mse2psnr(samples, 255.0, cpi->total_sq_error);
- double total_psnr2 = vp8_mse2psnr(samples, 255.0, cpi->total_sq_error2);
- double total_ssim = 100 * pow(cpi->summed_quality / cpi->summed_weights, 8.0);
-
- fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\tVPXSSIM\t Time(us)\n");
- fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n",
- dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, total_ssim,
- total_encode_time);
+ if (cpi->b_calculate_psnr) {
+ YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
+ double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_yv12->y_height;
+ double total_psnr = vp8_mse2psnr(samples, 255.0, cpi->total_sq_error);
+ double total_psnr2 = vp8_mse2psnr(samples, 255.0, cpi->total_sq_error2);
+ double total_ssim = 100 * pow(cpi->summed_quality / cpi->summed_weights, 8.0);
+
+ fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\tVPXSSIM\t Time(us)\n");
+ fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n",
+ dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, total_ssim,
+ total_encode_time);
// fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f %10ld\n",
// dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, total_ssim,
// total_encode_time, cpi->tot_recode_hits);
- }
+ }
- if (cpi->b_calculate_ssimg)
- {
- fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t Time(us)\n");
- fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr,
- cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cpi->count,
- cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / cpi->count, total_encode_time);
+ if (cpi->b_calculate_ssimg) {
+ fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t Time(us)\n");
+ fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr,
+ cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cpi->count,
+ cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / cpi->count, total_encode_time);
// fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f %10ld\n", dr,
// cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cpi->count,
// cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / cpi->count, total_encode_time, cpi->tot_recode_hits);
- }
+ }
- fclose(f);
- }
+ fclose(f);
+ }
#endif
#ifdef MODE_STATS
- {
- extern int count_mb_seg[4];
- char modes_stats_file[250];
- FILE *f;
- double dr = (double)cpi->oxcf.frame_rate * (double)cpi->bytes * (double)8 / (double)cpi->count / (double)1000 ;
- sprintf(modes_stats_file, "modes_q%03d.stt",cpi->common.base_qindex);
- f = fopen(modes_stats_file, "w");
- fprintf(f, "intra_mode in Intra Frames:\n");
- {
- int i;
- fprintf(f, "Y: ");
- for (i=0;i<VP8_YMODES;i++) fprintf(f, " %8d,", y_modes[i]);
- fprintf(f, "\n");
- }
- {
- int i;
- fprintf(f, "I8: ");
- for (i=0;i<VP8_I8X8_MODES;i++) fprintf(f, " %8d,", i8x8_modes[i]);
- fprintf(f, "\n");
- }
- {
- int i;
- fprintf(f, "UV: ");
- for (i=0;i<VP8_UV_MODES;i++) fprintf(f, " %8d,", uv_modes[i]);
- fprintf(f, "\n");
- }
- {
- int i, j;
- fprintf(f, "KeyFrame Y-UV:\n");
- for(i=0;i<VP8_YMODES;i++)
- {
- fprintf(f, "%2d:", i);
- for (j=0; j<VP8_UV_MODES;j++) fprintf(f, "%8d, ",uv_modes_y[i][j]);
- fprintf(f, "\n");
- }
- }
- {
- int i, j;
- fprintf(f, "Inter Y-UV:\n");
- for(i=0;i<VP8_YMODES;i++)
- {
- fprintf(f, "%2d:", i);
- for (j=0; j<VP8_UV_MODES;j++) fprintf(f, "%8d, ",cpi->y_uv_mode_count[i][j]);
- fprintf(f, "\n");
- }
- }
- {
- int i;
+ {
+ extern int count_mb_seg[4];
+ char modes_stats_file[250];
+ FILE *f;
+ double dr = (double)cpi->oxcf.frame_rate * (double)cpi->bytes * (double)8 / (double)cpi->count / (double)1000;
+ sprintf(modes_stats_file, "modes_q%03d.stt", cpi->common.base_qindex);
+ f = fopen(modes_stats_file, "w");
+ fprintf(f, "intra_mode in Intra Frames:\n");
+ {
+ int i;
+ fprintf(f, "Y: ");
+ for (i = 0; i < VP8_YMODES; i++) fprintf(f, " %8d,", y_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "I8: ");
+ for (i = 0; i < VP8_I8X8_MODES; i++) fprintf(f, " %8d,", i8x8_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "UV: ");
+ for (i = 0; i < VP8_UV_MODES; i++) fprintf(f, " %8d,", uv_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i, j;
+ fprintf(f, "KeyFrame Y-UV:\n");
+ for (i = 0; i < VP8_YMODES; i++) {
+ fprintf(f, "%2d:", i);
+ for (j = 0; j < VP8_UV_MODES; j++) fprintf(f, "%8d, ", uv_modes_y[i][j]);
+ fprintf(f, "\n");
+ }
+ }
+ {
+ int i, j;
+ fprintf(f, "Inter Y-UV:\n");
+ for (i = 0; i < VP8_YMODES; i++) {
+ fprintf(f, "%2d:", i);
+ for (j = 0; j < VP8_UV_MODES; j++) fprintf(f, "%8d, ", cpi->y_uv_mode_count[i][j]);
+ fprintf(f, "\n");
+ }
+ }
+ {
+ int i;
- fprintf(f, "B: ");
- for (i = 0; i < VP8_BINTRAMODES; i++)
- fprintf(f, "%8d, ", b_modes[i]);
+ fprintf(f, "B: ");
+ for (i = 0; i < VP8_BINTRAMODES; i++)
+ fprintf(f, "%8d, ", b_modes[i]);
- fprintf(f, "\n");
+ fprintf(f, "\n");
- }
+ }
- fprintf(f, "Modes in Inter Frames:\n");
- {
- int i;
- fprintf(f, "Y: ");
- for (i=0;i<MB_MODE_COUNT;i++) fprintf(f, " %8d,", inter_y_modes[i]);
- fprintf(f, "\n");
- }
- {
- int i;
- fprintf(f, "UV: ");
- for (i=0;i<VP8_UV_MODES;i++) fprintf(f, " %8d,", inter_uv_modes[i]);
- fprintf(f, "\n");
- }
- {
- int i;
- fprintf(f, "B: ");
- for (i = 0; i < B_MODE_COUNT; i++) fprintf(f, "%8d, ", inter_b_modes[i]);
- fprintf(f, "\n");
- }
- fprintf(f, "P:%8d, %8d, %8d, %8d\n", count_mb_seg[0], count_mb_seg[1], count_mb_seg[2], count_mb_seg[3]);
- fprintf(f, "PB:%8d, %8d, %8d, %8d\n", inter_b_modes[LEFT4X4], inter_b_modes[ABOVE4X4], inter_b_modes[ZERO4X4], inter_b_modes[NEW4X4]);
- fclose(f);
- }
+ fprintf(f, "Modes in Inter Frames:\n");
+ {
+ int i;
+ fprintf(f, "Y: ");
+ for (i = 0; i < MB_MODE_COUNT; i++) fprintf(f, " %8d,", inter_y_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "UV: ");
+ for (i = 0; i < VP8_UV_MODES; i++) fprintf(f, " %8d,", inter_uv_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "B: ");
+ for (i = 0; i < B_MODE_COUNT; i++) fprintf(f, "%8d, ", inter_b_modes[i]);
+ fprintf(f, "\n");
+ }
+ fprintf(f, "P:%8d, %8d, %8d, %8d\n", count_mb_seg[0], count_mb_seg[1], count_mb_seg[2], count_mb_seg[3]);
+ fprintf(f, "PB:%8d, %8d, %8d, %8d\n", inter_b_modes[LEFT4X4], inter_b_modes[ABOVE4X4], inter_b_modes[ZERO4X4], inter_b_modes[NEW4X4]);
+ fclose(f);
+ }
#endif
#ifdef ENTROPY_STATS
- {
- int i, j, k;
- FILE *fmode = fopen("modecontext.c", "w");
+ {
+ int i, j, k;
+ FILE *fmode = fopen("modecontext.c", "w");
- fprintf(fmode, "\n#include \"entropymode.h\"\n\n");
- fprintf(fmode, "const unsigned int vp8_kf_default_bmode_counts ");
- fprintf(fmode, "[VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES] =\n{\n");
+ fprintf(fmode, "\n#include \"entropymode.h\"\n\n");
+ fprintf(fmode, "const unsigned int vp8_kf_default_bmode_counts ");
+ fprintf(fmode, "[VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES] =\n{\n");
- for (i = 0; i < 10; i++)
- {
+ for (i = 0; i < 10; i++) {
- fprintf(fmode, " { //Above Mode : %d\n", i);
+ fprintf(fmode, " { // Above Mode : %d\n", i);
- for (j = 0; j < 10; j++)
- {
+ for (j = 0; j < 10; j++) {
- fprintf(fmode, " {");
+ fprintf(fmode, " {");
- for (k = 0; k < VP8_BINTRAMODES; k++)
- {
- if (!intra_mode_stats[i][j][k])
- fprintf(fmode, " %5d, ", 1);
- else
- fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]);
- }
+ for (k = 0; k < VP8_BINTRAMODES; k++) {
+ if (!intra_mode_stats[i][j][k])
+ fprintf(fmode, " %5d, ", 1);
+ else
+ fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]);
+ }
- fprintf(fmode, "}, // left_mode %d\n", j);
+ fprintf(fmode, "}, // left_mode %d\n", j);
- }
+ }
- fprintf(fmode, " },\n");
+ fprintf(fmode, " },\n");
- }
+ }
- fprintf(fmode, "};\n");
- fclose(fmode);
- }
+ fprintf(fmode, "};\n");
+ fclose(fmode);
+ }
#endif
#if defined(SECTIONBITS_OUTPUT)
- if (0)
- {
- int i;
- FILE *f = fopen("tokenbits.stt", "a");
+ if (0) {
+ int i;
+ FILE *f = fopen("tokenbits.stt", "a");
- for (i = 0; i < 28; i++)
- fprintf(f, "%8d", (int)(Sectionbits[i] / 256));
+ for (i = 0; i < 28; i++)
+ fprintf(f, "%8d", (int)(Sectionbits[i] / 256));
- fprintf(f, "\n");
- fclose(f);
- }
+ fprintf(f, "\n");
+ fclose(f);
+ }
#endif
#if 0
- {
- printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000);
- printf("\n_frames recive_data encod_mb_row compress_frame Total\n");
- printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame, cpi->time_receive_data / 1000, cpi->time_encode_mb_row / 1000, cpi->time_compress_data / 1000, (cpi->time_receive_data + cpi->time_compress_data) / 1000);
- }
+ {
+ printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000);
+ printf("\n_frames recive_data encod_mb_row compress_frame Total\n");
+ printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame, cpi->time_receive_data / 1000, cpi->time_encode_mb_row / 1000, cpi->time_compress_data / 1000, (cpi->time_receive_data + cpi->time_compress_data) / 1000);
+ }
#endif
- }
+ }
- dealloc_compressor_data(cpi);
- vpx_free(cpi->mb.ss);
- vpx_free(cpi->tok);
+ dealloc_compressor_data(cpi);
+ vpx_free(cpi->mb.ss);
+ vpx_free(cpi->tok);
- for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); i++)
- {
- vpx_free(cpi->mbgraph_stats[i].mb_stats);
- }
+ for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); i++) {
+ vpx_free(cpi->mbgraph_stats[i].mb_stats);
+ }
- vp8_remove_common(&cpi->common);
- vpx_free(cpi);
- *ptr = 0;
+ vp8_remove_common(&cpi->common);
+ vpx_free(cpi);
+ *ptr = 0;
#ifdef OUTPUT_YUV_SRC
- fclose(yuv_file);
+ fclose(yuv_file);
#endif
#ifdef OUTPUT_YUV_REC
- fclose(yuv_rec_file);
+ fclose(yuv_rec_file);
#endif
#if 0
- if (keyfile)
- fclose(keyfile);
+ if (keyfile)
+ fclose(keyfile);
- if (framepsnr)
- fclose(framepsnr);
+ if (framepsnr)
+ fclose(framepsnr);
- if (kf_list)
- fclose(kf_list);
+ if (kf_list)
+ fclose(kf_list);
#endif
@@ -2393,2461 +2273,2233 @@ void vp8_remove_compressor(VP8_PTR *ptr)
static uint64_t calc_plane_error(unsigned char *orig, int orig_stride,
unsigned char *recon, int recon_stride,
unsigned int cols, unsigned int rows,
- vp8_variance_rtcd_vtable_t *rtcd)
-{
- unsigned int row, col;
- uint64_t total_sse = 0;
- int diff;
-
- for (row = 0; row + 16 <= rows; row += 16)
- {
- for (col = 0; col + 16 <= cols; col += 16)
- {
- unsigned int sse;
-
- VARIANCE_INVOKE(rtcd, mse16x16)(orig + col, orig_stride,
- recon + col, recon_stride,
- &sse);
- total_sse += sse;
+ vp8_variance_rtcd_vtable_t *rtcd) {
+ unsigned int row, col;
+ uint64_t total_sse = 0;
+ int diff;
+
+ for (row = 0; row + 16 <= rows; row += 16) {
+ for (col = 0; col + 16 <= cols; col += 16) {
+ unsigned int sse;
+
+ VARIANCE_INVOKE(rtcd, mse16x16)(orig + col, orig_stride,
+ recon + col, recon_stride,
+ &sse);
+ total_sse += sse;
+ }
+
+ /* Handle odd-sized width */
+ if (col < cols) {
+ unsigned int border_row, border_col;
+ unsigned char *border_orig = orig;
+ unsigned char *border_recon = recon;
+
+ for (border_row = 0; border_row < 16; border_row++) {
+ for (border_col = col; border_col < cols; border_col++) {
+ diff = border_orig[border_col] - border_recon[border_col];
+ total_sse += diff * diff;
}
- /* Handle odd-sized width */
- if (col < cols)
- {
- unsigned int border_row, border_col;
- unsigned char *border_orig = orig;
- unsigned char *border_recon = recon;
-
- for (border_row = 0; border_row < 16; border_row++)
- {
- for (border_col = col; border_col < cols; border_col++)
- {
- diff = border_orig[border_col] - border_recon[border_col];
- total_sse += diff * diff;
- }
-
- border_orig += orig_stride;
- border_recon += recon_stride;
- }
- }
-
- orig += orig_stride * 16;
- recon += recon_stride * 16;
+ border_orig += orig_stride;
+ border_recon += recon_stride;
+ }
}
- /* Handle odd-sized height */
- for (; row < rows; row++)
- {
- for (col = 0; col < cols; col++)
- {
- diff = orig[col] - recon[col];
- total_sse += diff * diff;
- }
+ orig += orig_stride * 16;
+ recon += recon_stride * 16;
+ }
- orig += orig_stride;
- recon += recon_stride;
+ /* Handle odd-sized height */
+ for (; row < rows; row++) {
+ for (col = 0; col < cols; col++) {
+ diff = orig[col] - recon[col];
+ total_sse += diff * diff;
}
- return total_sse;
+ orig += orig_stride;
+ recon += recon_stride;
+ }
+
+ return total_sse;
}
-static void generate_psnr_packet(VP8_COMP *cpi)
-{
- YV12_BUFFER_CONFIG *orig = cpi->Source;
- YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show;
- struct vpx_codec_cx_pkt pkt;
- uint64_t sse;
- int i;
- unsigned int width = cpi->common.Width;
- unsigned int height = cpi->common.Height;
-
- pkt.kind = VPX_CODEC_PSNR_PKT;
- sse = calc_plane_error(orig->y_buffer, orig->y_stride,
- recon->y_buffer, recon->y_stride,
- width, height,
- IF_RTCD(&cpi->rtcd.variance));
- pkt.data.psnr.sse[0] = sse;
- pkt.data.psnr.sse[1] = sse;
- pkt.data.psnr.samples[0] = width * height;
- pkt.data.psnr.samples[1] = width * height;
-
- width = (width + 1) / 2;
- height = (height + 1) / 2;
-
- sse = calc_plane_error(orig->u_buffer, orig->uv_stride,
- recon->u_buffer, recon->uv_stride,
- width, height,
- IF_RTCD(&cpi->rtcd.variance));
- pkt.data.psnr.sse[0] += sse;
- pkt.data.psnr.sse[2] = sse;
- pkt.data.psnr.samples[0] += width * height;
- pkt.data.psnr.samples[2] = width * height;
-
- sse = calc_plane_error(orig->v_buffer, orig->uv_stride,
- recon->v_buffer, recon->uv_stride,
- width, height,
- IF_RTCD(&cpi->rtcd.variance));
- pkt.data.psnr.sse[0] += sse;
- pkt.data.psnr.sse[3] = sse;
- pkt.data.psnr.samples[0] += width * height;
- pkt.data.psnr.samples[3] = width * height;
-
- for (i = 0; i < 4; i++)
- pkt.data.psnr.psnr[i] = vp8_mse2psnr(pkt.data.psnr.samples[i], 255.0,
- pkt.data.psnr.sse[i]);
-
- vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
+static void generate_psnr_packet(VP8_COMP *cpi) {
+ YV12_BUFFER_CONFIG *orig = cpi->Source;
+ YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show;
+ struct vpx_codec_cx_pkt pkt;
+ uint64_t sse;
+ int i;
+ unsigned int width = cpi->common.Width;
+ unsigned int height = cpi->common.Height;
+
+ pkt.kind = VPX_CODEC_PSNR_PKT;
+ sse = calc_plane_error(orig->y_buffer, orig->y_stride,
+ recon->y_buffer, recon->y_stride,
+ width, height,
+ IF_RTCD(&cpi->rtcd.variance));
+ pkt.data.psnr.sse[0] = sse;
+ pkt.data.psnr.sse[1] = sse;
+ pkt.data.psnr.samples[0] = width * height;
+ pkt.data.psnr.samples[1] = width * height;
+
+ width = (width + 1) / 2;
+ height = (height + 1) / 2;
+
+ sse = calc_plane_error(orig->u_buffer, orig->uv_stride,
+ recon->u_buffer, recon->uv_stride,
+ width, height,
+ IF_RTCD(&cpi->rtcd.variance));
+ pkt.data.psnr.sse[0] += sse;
+ pkt.data.psnr.sse[2] = sse;
+ pkt.data.psnr.samples[0] += width * height;
+ pkt.data.psnr.samples[2] = width * height;
+
+ sse = calc_plane_error(orig->v_buffer, orig->uv_stride,
+ recon->v_buffer, recon->uv_stride,
+ width, height,
+ IF_RTCD(&cpi->rtcd.variance));
+ pkt.data.psnr.sse[0] += sse;
+ pkt.data.psnr.sse[3] = sse;
+ pkt.data.psnr.samples[0] += width * height;
+ pkt.data.psnr.samples[3] = width * height;
+
+ for (i = 0; i < 4; i++)
+ pkt.data.psnr.psnr[i] = vp8_mse2psnr(pkt.data.psnr.samples[i], 255.0,
+ pkt.data.psnr.sse[i]);
+
+ vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
}
-int vp8_use_as_reference(VP8_PTR ptr, int ref_frame_flags)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+int vp8_use_as_reference(VP8_PTR ptr, int ref_frame_flags) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- if (ref_frame_flags > 7)
- return -1 ;
+ if (ref_frame_flags > 7)
+ return -1;
- cpi->ref_frame_flags = ref_frame_flags;
- return 0;
+ cpi->ref_frame_flags = ref_frame_flags;
+ return 0;
}
-int vp8_update_reference(VP8_PTR ptr, int ref_frame_flags)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+int vp8_update_reference(VP8_PTR ptr, int ref_frame_flags) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- if (ref_frame_flags > 7)
- return -1 ;
+ if (ref_frame_flags > 7)
+ return -1;
- cpi->common.refresh_golden_frame = 0;
- cpi->common.refresh_alt_ref_frame = 0;
- cpi->common.refresh_last_frame = 0;
+ cpi->common.refresh_golden_frame = 0;
+ cpi->common.refresh_alt_ref_frame = 0;
+ cpi->common.refresh_last_frame = 0;
- if (ref_frame_flags & VP8_LAST_FLAG)
- cpi->common.refresh_last_frame = 1;
+ if (ref_frame_flags & VP8_LAST_FLAG)
+ cpi->common.refresh_last_frame = 1;
- if (ref_frame_flags & VP8_GOLD_FLAG)
- cpi->common.refresh_golden_frame = 1;
+ if (ref_frame_flags & VP8_GOLD_FLAG)
+ cpi->common.refresh_golden_frame = 1;
- if (ref_frame_flags & VP8_ALT_FLAG)
- cpi->common.refresh_alt_ref_frame = 1;
+ if (ref_frame_flags & VP8_ALT_FLAG)
+ cpi->common.refresh_alt_ref_frame = 1;
- return 0;
+ return 0;
}
-int vp8_get_reference(VP8_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
- VP8_COMMON *cm = &cpi->common;
- int ref_fb_idx;
-
- if (ref_frame_flag == VP8_LAST_FLAG)
- ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
- ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
- ref_fb_idx = cm->alt_fb_idx;
- else
- return -1;
-
- vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
-
- return 0;
-}
-int vp8_set_reference(VP8_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
- VP8_COMMON *cm = &cpi->common;
-
- int ref_fb_idx;
-
- if (ref_frame_flag == VP8_LAST_FLAG)
- ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
- ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
- ref_fb_idx = cm->alt_fb_idx;
- else
- return -1;
+int vp8_get_reference(VP8_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ VP8_COMMON *cm = &cpi->common;
+ int ref_fb_idx;
- vp8_yv12_copy_frame_ptr(sd, &cm->yv12_fb[ref_fb_idx]);
+ if (ref_frame_flag == VP8_LAST_FLAG)
+ ref_fb_idx = cm->lst_fb_idx;
+ else if (ref_frame_flag == VP8_GOLD_FLAG)
+ ref_fb_idx = cm->gld_fb_idx;
+ else if (ref_frame_flag == VP8_ALT_FLAG)
+ ref_fb_idx = cm->alt_fb_idx;
+ else
+ return -1;
- return 0;
-}
-int vp8_update_entropy(VP8_PTR comp, int update)
-{
- VP8_COMP *cpi = (VP8_COMP *) comp;
- VP8_COMMON *cm = &cpi->common;
- cm->refresh_entropy_probs = update;
+ vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
- return 0;
+ return 0;
}
+int vp8_set_reference(VP8_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ VP8_COMMON *cm = &cpi->common;
+ int ref_fb_idx;
-#ifdef OUTPUT_YUV_SRC
-void vp8_write_yuv_frame(YV12_BUFFER_CONFIG *s)
-{
- unsigned char *src = s->y_buffer;
- int h = s->y_height;
+ if (ref_frame_flag == VP8_LAST_FLAG)
+ ref_fb_idx = cm->lst_fb_idx;
+ else if (ref_frame_flag == VP8_GOLD_FLAG)
+ ref_fb_idx = cm->gld_fb_idx;
+ else if (ref_frame_flag == VP8_ALT_FLAG)
+ ref_fb_idx = cm->alt_fb_idx;
+ else
+ return -1;
- do
- {
- fwrite(src, s->y_width, 1, yuv_file);
- src += s->y_stride;
- }
- while (--h);
+ vp8_yv12_copy_frame_ptr(sd, &cm->yv12_fb[ref_fb_idx]);
- src = s->u_buffer;
- h = s->uv_height;
+ return 0;
+}
+int vp8_update_entropy(VP8_PTR comp, int update) {
+ VP8_COMP *cpi = (VP8_COMP *) comp;
+ VP8_COMMON *cm = &cpi->common;
+ cm->refresh_entropy_probs = update;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_file);
- src += s->uv_stride;
- }
- while (--h);
+ return 0;
+}
- src = s->v_buffer;
- h = s->uv_height;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_file);
- src += s->uv_stride;
- }
- while (--h);
+#ifdef OUTPUT_YUV_SRC
+void vp8_write_yuv_frame(YV12_BUFFER_CONFIG *s) {
+ unsigned char *src = s->y_buffer;
+ int h = s->y_height;
+
+ do {
+ fwrite(src, s->y_width, 1, yuv_file);
+ src += s->y_stride;
+ } while (--h);
+
+ src = s->u_buffer;
+ h = s->uv_height;
+
+ do {
+ fwrite(src, s->uv_width, 1, yuv_file);
+ src += s->uv_stride;
+ } while (--h);
+
+ src = s->v_buffer;
+ h = s->uv_height;
+
+ do {
+ fwrite(src, s->uv_width, 1, yuv_file);
+ src += s->uv_stride;
+ } while (--h);
}
#endif
#ifdef OUTPUT_YUV_REC
-void vp8_write_yuv_rec_frame(VP8_COMMON *cm)
-{
- YV12_BUFFER_CONFIG *s = cm->frame_to_show;
- unsigned char *src = s->y_buffer;
- int h = cm->Height;
+void vp8_write_yuv_rec_frame(VP8_COMMON *cm) {
+ YV12_BUFFER_CONFIG *s = cm->frame_to_show;
+ unsigned char *src = s->y_buffer;
+ int h = cm->Height;
+
+ do {
+ fwrite(src, s->y_width, 1, yuv_rec_file);
+ src += s->y_stride;
+ } while (--h);
+
+ src = s->u_buffer;
+ h = (cm->Height + 1) / 2;
+
+ do {
+ fwrite(src, s->uv_width, 1, yuv_rec_file);
+ src += s->uv_stride;
+ } while (--h);
+
+ src = s->v_buffer;
+ h = (cm->Height + 1) / 2;
+
+ do {
+ fwrite(src, s->uv_width, 1, yuv_rec_file);
+ src += s->uv_stride;
+ } while (--h);
+}
+#endif
- do
- {
- fwrite(src, s->y_width, 1, yuv_rec_file);
- src += s->y_stride;
- }
- while (--h);
+static void update_alt_ref_frame_stats(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
- src = s->u_buffer;
- h = (cm->Height+1)/2;
+ // Update data structure that monitors level of reference to last GF
+ vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
+ cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_rec_file);
- src += s->uv_stride;
- }
- while (--h);
+ // this frame refreshes means next frames don't unless specified by user
+ cpi->common.frames_since_golden = 0;
- src = s->v_buffer;
- h = (cm->Height+1)/2;
+ // Clear the alternate reference update pending flag.
+ cpi->source_alt_ref_pending = FALSE;
- do
- {
- fwrite(src, s->uv_width, 1, yuv_rec_file);
- src += s->uv_stride;
- }
- while (--h);
-}
-#endif
+ // Set the alternate refernce frame active flag
+ cpi->source_alt_ref_active = TRUE;
-static void update_alt_ref_frame_stats(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
+}
+static void update_golden_frame_stats(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
+
+ // Update the Golden frame usage counts.
+ if (cm->refresh_golden_frame) {
// Update data structure that monitors level of reference to last GF
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
// this frame refreshes means next frames don't unless specified by user
+ cm->refresh_golden_frame = 0;
cpi->common.frames_since_golden = 0;
- // Clear the alternate reference update pending flag.
- cpi->source_alt_ref_pending = FALSE;
-
- // Set the alternate refernce frame active flag
- cpi->source_alt_ref_active = TRUE;
-
-
-}
-static void update_golden_frame_stats(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
-
- // Update the Golden frame usage counts.
- if (cm->refresh_golden_frame)
- {
- // Update data structure that monitors level of reference to last GF
- vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
- cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
-
- // this frame refreshes means next frames don't unless specified by user
- cm->refresh_golden_frame = 0;
- cpi->common.frames_since_golden = 0;
-
- //if ( cm->frame_type == KEY_FRAME )
- //{
- cpi->recent_ref_frame_usage[INTRA_FRAME] = 1;
- cpi->recent_ref_frame_usage[LAST_FRAME] = 1;
- cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1;
- cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1;
- //}
- //else
- //{
- // // Carry a potrtion of count over to begining of next gf sequence
- // cpi->recent_ref_frame_usage[INTRA_FRAME] >>= 5;
- // cpi->recent_ref_frame_usage[LAST_FRAME] >>= 5;
- // cpi->recent_ref_frame_usage[GOLDEN_FRAME] >>= 5;
- // cpi->recent_ref_frame_usage[ALTREF_FRAME] >>= 5;
- //}
-
- // ******** Fixed Q test code only ************
- // If we are going to use the ALT reference for the next group of frames set a flag to say so.
- if (cpi->oxcf.fixed_q >= 0 &&
- cpi->oxcf.play_alternate && !cpi->common.refresh_alt_ref_frame)
- {
- cpi->source_alt_ref_pending = TRUE;
- cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
- }
-
- if (!cpi->source_alt_ref_pending)
- cpi->source_alt_ref_active = FALSE;
-
- // Decrement count down till next gf
- if (cpi->frames_till_gf_update_due > 0)
- cpi->frames_till_gf_update_due--;
-
- }
- else if (!cpi->common.refresh_alt_ref_frame)
- {
- // Decrement count down till next gf
- if (cpi->frames_till_gf_update_due > 0)
- cpi->frames_till_gf_update_due--;
-
- if (cpi->common.frames_till_alt_ref_frame)
- cpi->common.frames_till_alt_ref_frame --;
-
- cpi->common.frames_since_golden ++;
-
- if (cpi->common.frames_since_golden > 1)
- {
- cpi->recent_ref_frame_usage[INTRA_FRAME] += cpi->count_mb_ref_frame_usage[INTRA_FRAME];
- cpi->recent_ref_frame_usage[LAST_FRAME] += cpi->count_mb_ref_frame_usage[LAST_FRAME];
- cpi->recent_ref_frame_usage[GOLDEN_FRAME] += cpi->count_mb_ref_frame_usage[GOLDEN_FRAME];
- cpi->recent_ref_frame_usage[ALTREF_FRAME] += cpi->count_mb_ref_frame_usage[ALTREF_FRAME];
- }
- }
+ // if ( cm->frame_type == KEY_FRAME )
+ // {
+ cpi->recent_ref_frame_usage[INTRA_FRAME] = 1;
+ cpi->recent_ref_frame_usage[LAST_FRAME] = 1;
+ cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1;
+ cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1;
+ // }
+ // else
+ // {
+ // // Carry a potrtion of count over to begining of next gf sequence
+ // cpi->recent_ref_frame_usage[INTRA_FRAME] >>= 5;
+ // cpi->recent_ref_frame_usage[LAST_FRAME] >>= 5;
+ // cpi->recent_ref_frame_usage[GOLDEN_FRAME] >>= 5;
+ // cpi->recent_ref_frame_usage[ALTREF_FRAME] >>= 5;
+ // }
+
+ // ******** Fixed Q test code only ************
+ // If we are going to use the ALT reference for the next group of frames set a flag to say so.
+ if (cpi->oxcf.fixed_q >= 0 &&
+ cpi->oxcf.play_alternate && !cpi->common.refresh_alt_ref_frame) {
+ cpi->source_alt_ref_pending = TRUE;
+ cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
+ }
+
+ if (!cpi->source_alt_ref_pending)
+ cpi->source_alt_ref_active = FALSE;
+
+ // Decrement count down till next gf
+ if (cpi->frames_till_gf_update_due > 0)
+ cpi->frames_till_gf_update_due--;
+
+ } else if (!cpi->common.refresh_alt_ref_frame) {
+ // Decrement count down till next gf
+ if (cpi->frames_till_gf_update_due > 0)
+ cpi->frames_till_gf_update_due--;
+
+ if (cpi->common.frames_till_alt_ref_frame)
+ cpi->common.frames_till_alt_ref_frame--;
+
+ cpi->common.frames_since_golden++;
+
+ if (cpi->common.frames_since_golden > 1) {
+ cpi->recent_ref_frame_usage[INTRA_FRAME] += cpi->count_mb_ref_frame_usage[INTRA_FRAME];
+ cpi->recent_ref_frame_usage[LAST_FRAME] += cpi->count_mb_ref_frame_usage[LAST_FRAME];
+ cpi->recent_ref_frame_usage[GOLDEN_FRAME] += cpi->count_mb_ref_frame_usage[GOLDEN_FRAME];
+ cpi->recent_ref_frame_usage[ALTREF_FRAME] += cpi->count_mb_ref_frame_usage[ALTREF_FRAME];
+ }
+ }
}
-int find_fp_qindex()
-{
- int i;
+int find_fp_qindex() {
+ int i;
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- if ( vp8_convert_qindex_to_q(i) >= 30.0 )
- {
- break;
- }
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ if (vp8_convert_qindex_to_q(i) >= 30.0) {
+ break;
}
+ }
- if ( i == QINDEX_RANGE )
- i--;
+ if (i == QINDEX_RANGE)
+ i--;
- return i;
+ return i;
}
-static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned int *frame_flags)
-{
- (void) size;
- (void) dest;
- (void) frame_flags;
+static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned int *frame_flags) {
+ (void) size;
+ (void) dest;
+ (void) frame_flags;
- vp8_set_quantizer(cpi, find_fp_qindex());
- vp8_first_pass(cpi);
+ vp8_set_quantizer(cpi, find_fp_qindex());
+ vp8_first_pass(cpi);
}
#if 1
-void write_yuv_frame_to_file(YV12_BUFFER_CONFIG *frame)
-{
-
- // write the frame
- int i;
- FILE *fp = fopen("encode_recon.yuv", "a");
-
- for (i = 0; i < frame->y_height; i++)
- fwrite(frame->y_buffer + i * frame->y_stride,
- frame->y_width, 1, fp);
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->u_buffer + i * frame->uv_stride,
- frame->uv_width, 1, fp);
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->v_buffer + i * frame->uv_stride,
- frame->uv_width, 1, fp);
-
- fclose(fp);
+void write_yuv_frame_to_file(YV12_BUFFER_CONFIG *frame) {
+
+ // write the frame
+ int i;
+ FILE *fp = fopen("encode_recon.yuv", "a");
+
+ for (i = 0; i < frame->y_height; i++)
+ fwrite(frame->y_buffer + i * frame->y_stride,
+ frame->y_width, 1, fp);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->u_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, fp);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->v_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, fp);
+
+ fclose(fp);
}
#endif
-//#define WRITE_RECON_BUFFER 1
+// #define WRITE_RECON_BUFFER 1
#if WRITE_RECON_BUFFER
-void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
-{
+void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) {
- // write the frame
- FILE *yframe;
- int i;
- char filename[255];
+ // write the frame
+ FILE *yframe;
+ int i;
+ char filename[255];
- sprintf(filename, "cx\\y%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ sprintf(filename, "cx\\y%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->y_height; i++)
- fwrite(frame->y_buffer + i * frame->y_stride,
- frame->y_width, 1, yframe);
+ for (i = 0; i < frame->y_height; i++)
+ fwrite(frame->y_buffer + i * frame->y_stride,
+ frame->y_width, 1, yframe);
- fclose(yframe);
- sprintf(filename, "cx\\u%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ fclose(yframe);
+ sprintf(filename, "cx\\u%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->u_buffer + i * frame->uv_stride,
- frame->uv_width, 1, yframe);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->u_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, yframe);
- fclose(yframe);
- sprintf(filename, "cx\\v%04d.raw", this_frame);
- yframe = fopen(filename, "wb");
+ fclose(yframe);
+ sprintf(filename, "cx\\v%04d.raw", this_frame);
+ yframe = fopen(filename, "wb");
- for (i = 0; i < frame->uv_height; i++)
- fwrite(frame->v_buffer + i * frame->uv_stride,
- frame->uv_width, 1, yframe);
+ for (i = 0; i < frame->uv_height; i++)
+ fwrite(frame->v_buffer + i * frame->uv_stride,
+ frame->uv_width, 1, yframe);
- fclose(yframe);
+ fclose(yframe);
}
#endif
-static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame)
-{
+static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame) {
#define EDGE_THRESH 128
- int i, j;
- int num_edge_pels = 0;
- int num_pels = (frame->y_height - 2) * (frame->y_width - 2);
- unsigned char *prev = frame->y_buffer + 1;
- unsigned char *curr = frame->y_buffer + 1 + frame->y_stride;
- unsigned char *next = frame->y_buffer + 1 + 2*frame->y_stride;
- for (i = 1; i < frame->y_height - 1; i++)
- {
- for (j = 1; j < frame->y_width - 1; j++)
- {
- /* Sobel hor and ver gradients */
- int v = 2*(curr[1] - curr[-1]) + (prev[1] - prev[-1]) + (next[1] - next[-1]);
- int h = 2*(prev[0] - next[0]) + (prev[1] - next[1]) + (prev[-1] - next[-1]);
- h = (h < 0 ? -h : h);
- v = (v < 0 ? -v : v);
- if (h > EDGE_THRESH || v > EDGE_THRESH) num_edge_pels++;
- curr++;
- prev++;
- next++;
- }
- curr += frame->y_stride - frame->y_width + 2;
- prev += frame->y_stride - frame->y_width + 2;
- next += frame->y_stride - frame->y_width + 2;
- }
- return (double)num_edge_pels/(double)num_pels;
+ int i, j;
+ int num_edge_pels = 0;
+ int num_pels = (frame->y_height - 2) * (frame->y_width - 2);
+ unsigned char *prev = frame->y_buffer + 1;
+ unsigned char *curr = frame->y_buffer + 1 + frame->y_stride;
+ unsigned char *next = frame->y_buffer + 1 + 2 * frame->y_stride;
+ for (i = 1; i < frame->y_height - 1; i++) {
+ for (j = 1; j < frame->y_width - 1; j++) {
+ /* Sobel hor and ver gradients */
+ int v = 2 * (curr[1] - curr[-1]) + (prev[1] - prev[-1]) + (next[1] - next[-1]);
+ int h = 2 * (prev[0] - next[0]) + (prev[1] - next[1]) + (prev[-1] - next[-1]);
+ h = (h < 0 ? -h : h);
+ v = (v < 0 ? -v : v);
+ if (h > EDGE_THRESH || v > EDGE_THRESH) num_edge_pels++;
+ curr++;
+ prev++;
+ next++;
+ }
+ curr += frame->y_stride - frame->y_width + 2;
+ prev += frame->y_stride - frame->y_width + 2;
+ next += frame->y_stride - frame->y_width + 2;
+ }
+ return (double)num_edge_pels / (double)num_pels;
}
// Function to test for conditions that indicate we should loop
// back and recode a frame.
-static BOOL recode_loop_test( VP8_COMP *cpi,
- int high_limit, int low_limit,
- int q, int maxq, int minq )
-{
- BOOL force_recode = FALSE;
- VP8_COMMON *cm = &cpi->common;
-
- // Is frame recode allowed at all
- // Yes if either recode mode 1 is selected or mode two is selcted
- // and the frame is a key frame. golden frame or alt_ref_frame
- if ( (cpi->sf.recode_loop == 1) ||
- ( (cpi->sf.recode_loop == 2) &&
- ( (cm->frame_type == KEY_FRAME) ||
- cm->refresh_golden_frame ||
- cm->refresh_alt_ref_frame ) ) )
- {
- // General over and under shoot tests
- if ( ((cpi->projected_frame_size > high_limit) && (q < maxq)) ||
- ((cpi->projected_frame_size < low_limit) && (q > minq)) )
- {
- force_recode = TRUE;
- }
- // Special Constrained quality tests
- else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY)
- {
- // Undershoot and below auto cq level
- if ( (q > cpi->cq_target_quality) &&
- (cpi->projected_frame_size <
- ((cpi->this_frame_target * 7) >> 3)))
- {
- force_recode = TRUE;
- }
- // Severe undershoot and between auto and user cq level
- else if ( (q > cpi->oxcf.cq_level) &&
- (cpi->projected_frame_size < cpi->min_frame_bandwidth) &&
- (cpi->active_best_quality > cpi->oxcf.cq_level))
- {
- force_recode = TRUE;
- cpi->active_best_quality = cpi->oxcf.cq_level;
- }
- }
- }
-
- return force_recode;
+static BOOL recode_loop_test(VP8_COMP *cpi,
+ int high_limit, int low_limit,
+ int q, int maxq, int minq) {
+ BOOL force_recode = FALSE;
+ VP8_COMMON *cm = &cpi->common;
+
+ // Is frame recode allowed at all
+ // Yes if either recode mode 1 is selected or mode two is selcted
+ // and the frame is a key frame. golden frame or alt_ref_frame
+ if ((cpi->sf.recode_loop == 1) ||
+ ((cpi->sf.recode_loop == 2) &&
+ ((cm->frame_type == KEY_FRAME) ||
+ cm->refresh_golden_frame ||
+ cm->refresh_alt_ref_frame))) {
+ // General over and under shoot tests
+ if (((cpi->projected_frame_size > high_limit) && (q < maxq)) ||
+ ((cpi->projected_frame_size < low_limit) && (q > minq))) {
+ force_recode = TRUE;
+ }
+ // Special Constrained quality tests
+ else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
+ // Undershoot and below auto cq level
+ if ((q > cpi->cq_target_quality) &&
+ (cpi->projected_frame_size <
+ ((cpi->this_frame_target * 7) >> 3))) {
+ force_recode = TRUE;
+ }
+ // Severe undershoot and between auto and user cq level
+ else if ((q > cpi->oxcf.cq_level) &&
+ (cpi->projected_frame_size < cpi->min_frame_bandwidth) &&
+ (cpi->active_best_quality > cpi->oxcf.cq_level)) {
+ force_recode = TRUE;
+ cpi->active_best_quality = cpi->oxcf.cq_level;
+ }
+ }
+ }
+
+ return force_recode;
}
-void update_reference_frames(VP8_COMMON *cm)
-{
- YV12_BUFFER_CONFIG *yv12_fb = cm->yv12_fb;
+void update_reference_frames(VP8_COMMON *cm) {
+ YV12_BUFFER_CONFIG *yv12_fb = cm->yv12_fb;
- // At this point the new frame has been encoded.
- // If any buffer copy / swapping is signaled it should be done here.
+ // At this point the new frame has been encoded.
+ // If any buffer copy / swapping is signaled it should be done here.
- if (cm->frame_type == KEY_FRAME)
- {
- yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG | VP8_ALT_FLAG ;
+ if (cm->frame_type == KEY_FRAME) {
+ yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG | VP8_ALT_FLAG;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
- cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
- }
- else /* For non key frames */
- {
- if (cm->refresh_alt_ref_frame)
- {
- assert(!cm->copy_buffer_to_arf);
+ cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
+ } else { /* For non key frames */
+ if (cm->refresh_alt_ref_frame) {
+ assert(!cm->copy_buffer_to_arf);
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_ALT_FLAG;
- cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
- cm->alt_fb_idx = cm->new_fb_idx;
- }
- else if (cm->copy_buffer_to_arf)
- {
- assert(!(cm->copy_buffer_to_arf & ~0x3));
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_ALT_FLAG;
+ cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ cm->alt_fb_idx = cm->new_fb_idx;
+ } else if (cm->copy_buffer_to_arf) {
+ assert(!(cm->copy_buffer_to_arf & ~0x3));
- if (cm->copy_buffer_to_arf == 1)
- {
- if(cm->alt_fb_idx != cm->lst_fb_idx)
- {
- yv12_fb[cm->lst_fb_idx].flags |= VP8_ALT_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
- cm->alt_fb_idx = cm->lst_fb_idx;
- }
- }
- else /* if (cm->copy_buffer_to_arf == 2) */
- {
- if(cm->alt_fb_idx != cm->gld_fb_idx)
- {
- yv12_fb[cm->gld_fb_idx].flags |= VP8_ALT_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
- cm->alt_fb_idx = cm->gld_fb_idx;
- }
- }
+ if (cm->copy_buffer_to_arf == 1) {
+ if (cm->alt_fb_idx != cm->lst_fb_idx) {
+ yv12_fb[cm->lst_fb_idx].flags |= VP8_ALT_FLAG;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ cm->alt_fb_idx = cm->lst_fb_idx;
}
+ } else { /* if (cm->copy_buffer_to_arf == 2) */
+ if (cm->alt_fb_idx != cm->gld_fb_idx) {
+ yv12_fb[cm->gld_fb_idx].flags |= VP8_ALT_FLAG;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ cm->alt_fb_idx = cm->gld_fb_idx;
+ }
+ }
+ }
- if (cm->refresh_golden_frame)
- {
- assert(!cm->copy_buffer_to_gf);
+ if (cm->refresh_golden_frame) {
+ assert(!cm->copy_buffer_to_gf);
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG;
- cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
- cm->gld_fb_idx = cm->new_fb_idx;
- }
- else if (cm->copy_buffer_to_gf)
- {
- assert(!(cm->copy_buffer_to_arf & ~0x3));
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG;
+ cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ cm->gld_fb_idx = cm->new_fb_idx;
+ } else if (cm->copy_buffer_to_gf) {
+ assert(!(cm->copy_buffer_to_arf & ~0x3));
- if (cm->copy_buffer_to_gf == 1)
- {
- if(cm->gld_fb_idx != cm->lst_fb_idx)
- {
- yv12_fb[cm->lst_fb_idx].flags |= VP8_GOLD_FLAG;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
- cm->gld_fb_idx = cm->lst_fb_idx;
- }
- }
- else /* if (cm->copy_buffer_to_gf == 2) */
- {
- if(cm->alt_fb_idx != cm->gld_fb_idx)
- {
- yv12_fb[cm->alt_fb_idx].flags |= VP8_GOLD_FLAG;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
- cm->gld_fb_idx = cm->alt_fb_idx;
- }
- }
+ if (cm->copy_buffer_to_gf == 1) {
+ if (cm->gld_fb_idx != cm->lst_fb_idx) {
+ yv12_fb[cm->lst_fb_idx].flags |= VP8_GOLD_FLAG;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ cm->gld_fb_idx = cm->lst_fb_idx;
+ }
+ } else { /* if (cm->copy_buffer_to_gf == 2) */
+ if (cm->alt_fb_idx != cm->gld_fb_idx) {
+ yv12_fb[cm->alt_fb_idx].flags |= VP8_GOLD_FLAG;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ cm->gld_fb_idx = cm->alt_fb_idx;
}
+ }
}
+ }
- if (cm->refresh_last_frame)
- {
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_LAST_FLAG;
- cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FLAG;
- cm->lst_fb_idx = cm->new_fb_idx;
- }
+ if (cm->refresh_last_frame) {
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_LAST_FLAG;
+ cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FLAG;
+ cm->lst_fb_idx = cm->new_fb_idx;
+ }
}
-void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm)
-{
- if (cm->no_lpf)
- {
- cm->filter_level = 0;
- }
+void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm) {
+ if (cm->no_lpf) {
+ cm->filter_level = 0;
+ }
#if CONFIG_LOSSLESS
- else if(cpi->oxcf.lossless)
- {
- cm->filter_level = 0;
- }
+ else if (cpi->oxcf.lossless) {
+ cm->filter_level = 0;
+ }
#endif
- else
- {
- struct vpx_usec_timer timer;
+ else {
+ struct vpx_usec_timer timer;
- vp8_clear_system_state();
+ vp8_clear_system_state();
- vpx_usec_timer_start(&timer);
- if (cpi->sf.auto_filter == 0)
- vp8cx_pick_filter_level_fast(cpi->Source, cpi);
+ vpx_usec_timer_start(&timer);
+ if (cpi->sf.auto_filter == 0)
+ vp8cx_pick_filter_level_fast(cpi->Source, cpi);
- else
- vp8cx_pick_filter_level(cpi->Source, cpi);
+ else
+ vp8cx_pick_filter_level(cpi->Source, cpi);
- vpx_usec_timer_mark(&timer);
- cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
- }
+ vpx_usec_timer_mark(&timer);
+ cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
+ }
- if (cm->filter_level > 0)
- {
- vp8cx_set_alt_lf_level(cpi, cm->filter_level);
- vp8_loop_filter_frame(cm, &cpi->mb.e_mbd);
- }
+ if (cm->filter_level > 0) {
+ vp8cx_set_alt_lf_level(cpi, cm->filter_level);
+ vp8_loop_filter_frame(cm, &cpi->mb.e_mbd);
+ }
- vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show);
+ vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show);
}
#if CONFIG_PRED_FILTER
-void select_pred_filter_mode(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
-
- int prob_pred_filter_off = cm->prob_pred_filter_off;
+void select_pred_filter_mode(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
+
+ int prob_pred_filter_off = cm->prob_pred_filter_off;
+
+ // Force filter on/off if probability is extreme
+ if (prob_pred_filter_off >= 255 * 0.95)
+ cm->pred_filter_mode = 0; // Off at the frame level
+ else if (prob_pred_filter_off <= 255 * 0.05)
+ cm->pred_filter_mode = 1; // On at the frame level
+ else
+ cm->pred_filter_mode = 2; // Selectable at the MB level
+}
- // Force filter on/off if probability is extreme
- if (prob_pred_filter_off >= 255 * 0.95)
- cm->pred_filter_mode = 0; // Off at the frame level
- else if (prob_pred_filter_off <= 255 * 0.05)
- cm->pred_filter_mode = 1; // On at the frame level
- else
- cm->pred_filter_mode = 2; // Selectable at the MB level
+void update_pred_filt_prob(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
+ int prob_pred_filter_off;
+
+ // Based on the selection in the previous frame determine what mode
+ // to use for the current frame and work out the signaling probability
+ if (cpi->pred_filter_on_count + cpi->pred_filter_off_count) {
+ prob_pred_filter_off = cpi->pred_filter_off_count * 256 /
+ (cpi->pred_filter_on_count + cpi->pred_filter_off_count);
+
+ if (prob_pred_filter_off < 1)
+ prob_pred_filter_off = 1;
+
+ if (prob_pred_filter_off > 255)
+ prob_pred_filter_off = 255;
+
+ cm->prob_pred_filter_off = prob_pred_filter_off;
+ } else
+ cm->prob_pred_filter_off = 128;
+ /*
+ {
+ FILE *fp = fopen("filt_use.txt", "a");
+ fprintf (fp, "%d %d prob=%d\n", cpi->pred_filter_off_count,
+ cpi->pred_filter_on_count, cm->prob_pred_filter_off);
+ fclose(fp);
+ }
+ */
}
+#endif
-void update_pred_filt_prob(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
- int prob_pred_filter_off;
+static void encode_frame_to_data_rate
+(
+ VP8_COMP *cpi,
+ unsigned long *size,
+ unsigned char *dest,
+ unsigned int *frame_flags
+) {
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
- // Based on the selection in the previous frame determine what mode
- // to use for the current frame and work out the signaling probability
- if ( cpi->pred_filter_on_count + cpi->pred_filter_off_count )
- {
- prob_pred_filter_off = cpi->pred_filter_off_count * 256 /
- ( cpi->pred_filter_on_count + cpi->pred_filter_off_count);
+ int Q;
+ int frame_over_shoot_limit;
+ int frame_under_shoot_limit;
- if (prob_pred_filter_off < 1)
- prob_pred_filter_off = 1;
+ int Loop = FALSE;
+ int loop_count;
+ int this_q;
+ int last_zbin_oq;
- if (prob_pred_filter_off > 255)
- prob_pred_filter_off = 255;
+ int q_low;
+ int q_high;
+ int zbin_oq_high;
+ int zbin_oq_low = 0;
- cm->prob_pred_filter_off = prob_pred_filter_off;
- }
- else
- cm->prob_pred_filter_off = 128;
-/*
- {
- FILE *fp = fopen("filt_use.txt", "a");
- fprintf (fp, "%d %d prob=%d\n", cpi->pred_filter_off_count,
- cpi->pred_filter_on_count, cm->prob_pred_filter_off);
- fclose(fp);
- }
-*/
-}
-#endif
+ int top_index;
+ int bottom_index;
+ int active_worst_qchanged = FALSE;
-static void encode_frame_to_data_rate
-(
- VP8_COMP *cpi,
- unsigned long *size,
- unsigned char *dest,
- unsigned int *frame_flags
-)
-{
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
-
- int Q;
- int frame_over_shoot_limit;
- int frame_under_shoot_limit;
-
- int Loop = FALSE;
- int loop_count;
- int this_q;
- int last_zbin_oq;
-
- int q_low;
- int q_high;
- int zbin_oq_high;
- int zbin_oq_low = 0;
-
- int top_index;
- int bottom_index;
- int active_worst_qchanged = FALSE;
-
- int overshoot_seen = FALSE;
- int undershoot_seen = FALSE;
-
- int loop_size_estimate = 0;
+ int overshoot_seen = FALSE;
+ int undershoot_seen = FALSE;
+
+ int loop_size_estimate = 0;
#if CONFIG_ENHANCED_INTERP
- SPEED_FEATURES *sf = &cpi->sf;
+ SPEED_FEATURES *sf = &cpi->sf;
#if RESET_FOREACH_FILTER
- int q_low0;
- int q_high0;
- int zbin_oq_high0;
- int zbin_oq_low0 = 0;
- int Q0;
- int last_zbin_oq0;
- int active_best_quality0;
- int active_worst_quality0;
- double rate_correction_factor0;
- double gf_rate_correction_factor0;
+ int q_low0;
+ int q_high0;
+ int zbin_oq_high0;
+ int zbin_oq_low0 = 0;
+ int Q0;
+ int last_zbin_oq0;
+ int active_best_quality0;
+ int active_worst_quality0;
+ double rate_correction_factor0;
+ double gf_rate_correction_factor0;
#endif
- /* list of filters to search over */
- int mcomp_filters_to_search[] = {EIGHTTAP, EIGHTTAP_SHARP, SIXTAP};
- int mcomp_filters = sizeof(mcomp_filters_to_search)/sizeof(*mcomp_filters_to_search);
- int mcomp_filter_index = 0;
- INT64 mcomp_filter_cost[4];
+ /* list of filters to search over */
+ int mcomp_filters_to_search[] = {EIGHTTAP, EIGHTTAP_SHARP, SIXTAP};
+ int mcomp_filters = sizeof(mcomp_filters_to_search) / sizeof(*mcomp_filters_to_search);
+ int mcomp_filter_index = 0;
+ INT64 mcomp_filter_cost[4];
#endif
- // Clear down mmx registers to allow floating point in what follows
- vp8_clear_system_state();
+ // Clear down mmx registers to allow floating point in what follows
+ vp8_clear_system_state();
- // For an alt ref frame in 2 pass we skip the call to the second
- // pass function that sets the target bandwidth so must set it here
- if (cpi->common.refresh_alt_ref_frame)
- {
- cpi->per_frame_bandwidth = cpi->twopass.gf_bits; // Per frame bit target for the alt ref frame
- cpi->target_bandwidth = cpi->twopass.gf_bits * cpi->output_frame_rate; // per second target bitrate
- }
+ // For an alt ref frame in 2 pass we skip the call to the second
+ // pass function that sets the target bandwidth so must set it here
+ if (cpi->common.refresh_alt_ref_frame) {
+ cpi->per_frame_bandwidth = cpi->twopass.gf_bits; // Per frame bit target for the alt ref frame
+ cpi->target_bandwidth = cpi->twopass.gf_bits * cpi->output_frame_rate; // per second target bitrate
+ }
- // Default turn off buffer to buffer copying
- cm->copy_buffer_to_gf = 0;
- cm->copy_buffer_to_arf = 0;
+ // Default turn off buffer to buffer copying
+ cm->copy_buffer_to_gf = 0;
+ cm->copy_buffer_to_arf = 0;
- // Clear zbin over-quant value and mode boost values.
- cpi->zbin_over_quant = 0;
- cpi->zbin_mode_boost = 0;
+ // Clear zbin over-quant value and mode boost values.
+ cpi->zbin_over_quant = 0;
+ cpi->zbin_mode_boost = 0;
- // Enable or disable mode based tweaking of the zbin
- // For 2 Pass Only used where GF/ARF prediction quality
- // is above a threshold
- cpi->zbin_mode_boost = 0;
+ // Enable or disable mode based tweaking of the zbin
+ // For 2 Pass Only used where GF/ARF prediction quality
+ // is above a threshold
+ cpi->zbin_mode_boost = 0;
#if CONFIG_LOSSLESS
- cpi->zbin_mode_boost_enabled = FALSE;
+ cpi->zbin_mode_boost_enabled = FALSE;
#else
- cpi->zbin_mode_boost_enabled = TRUE;
+ cpi->zbin_mode_boost_enabled = TRUE;
#endif
- if ( cpi->gfu_boost <= 400 )
- {
- cpi->zbin_mode_boost_enabled = FALSE;
- }
-
- // Current default encoder behaviour for the altref sign bias
- if (cpi->source_alt_ref_active)
- cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
- else
- cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 0;
-
- // Check to see if a key frame is signalled
- // For two pass with auto key frame enabled cm->frame_type may already be set, but not for one pass.
- if ((cm->current_video_frame == 0) ||
- (cm->frame_flags & FRAMEFLAGS_KEY) ||
- (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency == 0)))
- {
- // Key frame from VFW/auto-keyframe/first frame
- cm->frame_type = KEY_FRAME;
- }
-
- // Set default state for segment based loop filter update flags
- xd->mode_ref_lf_delta_update = 0;
-
- // Set various flags etc to special state if it is a key frame
- if (cm->frame_type == KEY_FRAME)
- {
- int i;
-
- // Reset the loop filter deltas and segmentation map
- setup_features(cpi);
+ if (cpi->gfu_boost <= 400) {
+ cpi->zbin_mode_boost_enabled = FALSE;
+ }
- // If segmentation is enabled force a map update for key frames
- if (xd->segmentation_enabled)
- {
- xd->update_mb_segmentation_map = 1;
- xd->update_mb_segmentation_data = 1;
- }
+ // Current default encoder behaviour for the altref sign bias
+ if (cpi->source_alt_ref_active)
+ cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
+ else
+ cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 0;
+
+ // Check to see if a key frame is signalled
+ // For two pass with auto key frame enabled cm->frame_type may already be set, but not for one pass.
+ if ((cm->current_video_frame == 0) ||
+ (cm->frame_flags & FRAMEFLAGS_KEY) ||
+ (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency == 0))) {
+ // Key frame from VFW/auto-keyframe/first frame
+ cm->frame_type = KEY_FRAME;
+ }
+
+ // Set default state for segment based loop filter update flags
+ xd->mode_ref_lf_delta_update = 0;
+
+ // Set various flags etc to special state if it is a key frame
+ if (cm->frame_type == KEY_FRAME) {
+ int i;
- // The alternate reference frame cannot be active for a key frame
- cpi->source_alt_ref_active = FALSE;
+ // Reset the loop filter deltas and segmentation map
+ setup_features(cpi);
- // Reset the RD threshold multipliers to default of * 1 (128)
- for (i = 0; i < MAX_MODES; i++)
- {
- cpi->rd_thresh_mult[i] = 128;
- }
+ // If segmentation is enabled force a map update for key frames
+ if (xd->segmentation_enabled) {
+ xd->update_mb_segmentation_map = 1;
+ xd->update_mb_segmentation_data = 1;
}
-//#if !CONFIG_COMPRED
- // This function has been deprecated for now but we may want to do
- // something here at a late date
- //update_rd_ref_frame_probs(cpi);
-//#endif
-
- // Test code for new segment features
- init_seg_features( cpi );
+ // The alternate reference frame cannot be active for a key frame
+ cpi->source_alt_ref_active = FALSE;
- // Decide how big to make the frame
- vp8_pick_frame_size(cpi);
+ // Reset the RD threshold multipliers to default of * 1 (128)
+ for (i = 0; i < MAX_MODES; i++) {
+ cpi->rd_thresh_mult[i] = 128;
+ }
+ }
- vp8_clear_system_state();
+// #if !CONFIG_COMPRED
+ // This function has been deprecated for now but we may want to do
+ // something here at a late date
+ // update_rd_ref_frame_probs(cpi);
+// #endif
- // Set an active best quality and if necessary active worst quality
- Q = cpi->active_worst_quality;
+ // Test code for new segment features
+ init_seg_features(cpi);
- if ( cm->frame_type == KEY_FRAME )
- {
- int high = 2000;
- int low = 400;
-
- if ( cpi->kf_boost > high )
- cpi->active_best_quality = kf_low_motion_minq[Q];
- else if ( cpi->kf_boost < low )
- cpi->active_best_quality = kf_high_motion_minq[Q];
- else
- {
- int gap = high - low;
- int offset = high - cpi->kf_boost;
- int qdiff = kf_high_motion_minq[Q] - kf_low_motion_minq[Q];
- int adjustment = ((offset * qdiff) + (gap>>1)) / gap;
+ // Decide how big to make the frame
+ vp8_pick_frame_size(cpi);
- cpi->active_best_quality = kf_low_motion_minq[Q] + adjustment;
- }
+ vp8_clear_system_state();
- // Make an adjustment based on the %s static
- // The main impact of this is at lower Q to prevent overly large key
- // frames unless a lot of the image is static.
- if (cpi->kf_zeromotion_pct < 64 )
- cpi->active_best_quality += 4 - (cpi->kf_zeromotion_pct >> 4);
+ // Set an active best quality and if necessary active worst quality
+ Q = cpi->active_worst_quality;
- // Special case for key frames forced because we have reached
- // the maximum key frame interval. Here force the Q to a range
- // based on the ambient Q to reduce the risk of popping
- if ( cpi->this_key_frame_forced )
- {
- int delta_qindex;
- int qindex = cpi->last_boosted_qindex;
+ if (cm->frame_type == KEY_FRAME) {
+ int high = 2000;
+ int low = 400;
- delta_qindex = compute_qdelta( cpi, qindex,
- (qindex * 0.75) );
+ if (cpi->kf_boost > high)
+ cpi->active_best_quality = kf_low_motion_minq[Q];
+ else if (cpi->kf_boost < low)
+ cpi->active_best_quality = kf_high_motion_minq[Q];
+ else {
+ int gap = high - low;
+ int offset = high - cpi->kf_boost;
+ int qdiff = kf_high_motion_minq[Q] - kf_low_motion_minq[Q];
+ int adjustment = ((offset * qdiff) + (gap >> 1)) / gap;
- cpi->active_best_quality = qindex + delta_qindex;
- if (cpi->active_best_quality < cpi->best_quality)
- cpi->active_best_quality = cpi->best_quality;
- }
+ cpi->active_best_quality = kf_low_motion_minq[Q] + adjustment;
}
- else if (cm->refresh_golden_frame || cpi->common.refresh_alt_ref_frame)
- {
- int high = 2000;
- int low = 400;
-
- // Use the lower of cpi->active_worst_quality and recent
- // average Q as basis for GF/ARF Q limit unless last frame was
- // a key frame.
- if ( (cpi->frames_since_key > 1) &&
- (cpi->avg_frame_qindex < cpi->active_worst_quality) )
- {
- Q = cpi->avg_frame_qindex;
- }
-
- // For constrained quality dont allow Q less than the cq level
- if ( (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (Q < cpi->cq_target_quality) )
- {
- Q = cpi->cq_target_quality;
- }
-
- if ( cpi->gfu_boost > high )
- cpi->active_best_quality = gf_low_motion_minq[Q];
- else if ( cpi->gfu_boost < low )
- cpi->active_best_quality = gf_high_motion_minq[Q];
- else
- {
- int gap = high - low;
- int offset = high - cpi->gfu_boost;
- int qdiff = gf_high_motion_minq[Q] - gf_low_motion_minq[Q];
- int adjustment = ((offset * qdiff) + (gap>>1)) / gap;
-
- cpi->active_best_quality = gf_low_motion_minq[Q] + adjustment;
- }
-
- // Constrained quality use slightly lower active best.
- if ( cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY )
- {
- cpi->active_best_quality =
- cpi->active_best_quality * 15/16;
- }
- }
- else
- {
- cpi->active_best_quality = inter_minq[Q];
+ // Make an adjustment based on the %s static
+ // The main impact of this is at lower Q to prevent overly large key
+ // frames unless a lot of the image is static.
+ if (cpi->kf_zeromotion_pct < 64)
+ cpi->active_best_quality += 4 - (cpi->kf_zeromotion_pct >> 4);
- // For the constant/constrained quality mode we dont want
- // q to fall below the cq level.
- if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (cpi->active_best_quality < cpi->cq_target_quality) )
- {
- // If we are strongly undershooting the target rate in the last
- // frames then use the user passed in cq value not the auto
- // cq value.
- if ( cpi->rolling_actual_bits < cpi->min_frame_bandwidth )
- cpi->active_best_quality = cpi->oxcf.cq_level;
- else
- cpi->active_best_quality = cpi->cq_target_quality;
- }
- }
+ // Special case for key frames forced because we have reached
+ // the maximum key frame interval. Here force the Q to a range
+ // based on the ambient Q to reduce the risk of popping
+ if (cpi->this_key_frame_forced) {
+ int delta_qindex;
+ int qindex = cpi->last_boosted_qindex;
- // Clip the active best and worst quality values to limits
- if (cpi->active_worst_quality > cpi->worst_quality)
- cpi->active_worst_quality = cpi->worst_quality;
+ delta_qindex = compute_qdelta(cpi, qindex,
+ (qindex * 0.75));
- if (cpi->active_best_quality < cpi->best_quality)
+ cpi->active_best_quality = qindex + delta_qindex;
+ if (cpi->active_best_quality < cpi->best_quality)
cpi->active_best_quality = cpi->best_quality;
-
- if (cpi->active_best_quality > cpi->worst_quality)
- cpi->active_best_quality = cpi->worst_quality;
-
- if ( cpi->active_worst_quality < cpi->active_best_quality )
- cpi->active_worst_quality = cpi->active_best_quality;
-
- // Specuial case code to try and match quality with forced key frames
- if ( (cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced )
- {
- Q = cpi->last_boosted_qindex;
}
- else
- {
- // Determine initial Q to try
- Q = vp8_regulate_q(cpi, cpi->this_frame_target);
- }
- last_zbin_oq = cpi->zbin_over_quant;
-
- // Set highest allowed value for Zbin over quant
- if (cm->frame_type == KEY_FRAME)
- zbin_oq_high = 0; //ZBIN_OQ_MAX/16
- else if (cm->refresh_alt_ref_frame || (cm->refresh_golden_frame && !cpi->source_alt_ref_active))
- zbin_oq_high = 16;
- else
- zbin_oq_high = ZBIN_OQ_MAX;
-
- vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &frame_over_shoot_limit);
-
- // Limit Q range for the adaptive loop.
- bottom_index = cpi->active_best_quality;
- top_index = cpi->active_worst_quality;
- q_low = cpi->active_best_quality;
- q_high = cpi->active_worst_quality;
-
- loop_count = 0;
+ }
+
+ else if (cm->refresh_golden_frame || cpi->common.refresh_alt_ref_frame) {
+ int high = 2000;
+ int low = 400;
+
+ // Use the lower of cpi->active_worst_quality and recent
+ // average Q as basis for GF/ARF Q limit unless last frame was
+ // a key frame.
+ if ((cpi->frames_since_key > 1) &&
+ (cpi->avg_frame_qindex < cpi->active_worst_quality)) {
+ Q = cpi->avg_frame_qindex;
+ }
+
+ // For constrained quality dont allow Q less than the cq level
+ if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ (Q < cpi->cq_target_quality)) {
+ Q = cpi->cq_target_quality;
+ }
+
+ if (cpi->gfu_boost > high)
+ cpi->active_best_quality = gf_low_motion_minq[Q];
+ else if (cpi->gfu_boost < low)
+ cpi->active_best_quality = gf_high_motion_minq[Q];
+ else {
+ int gap = high - low;
+ int offset = high - cpi->gfu_boost;
+ int qdiff = gf_high_motion_minq[Q] - gf_low_motion_minq[Q];
+ int adjustment = ((offset * qdiff) + (gap >> 1)) / gap;
+
+ cpi->active_best_quality = gf_low_motion_minq[Q] + adjustment;
+ }
+
+ // Constrained quality use slightly lower active best.
+ if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
+ cpi->active_best_quality =
+ cpi->active_best_quality * 15 / 16;
+ }
+ } else {
+ cpi->active_best_quality = inter_minq[Q];
+
+ // For the constant/constrained quality mode we dont want
+ // q to fall below the cq level.
+ if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ (cpi->active_best_quality < cpi->cq_target_quality)) {
+ // If we are strongly undershooting the target rate in the last
+ // frames then use the user passed in cq value not the auto
+ // cq value.
+ if (cpi->rolling_actual_bits < cpi->min_frame_bandwidth)
+ cpi->active_best_quality = cpi->oxcf.cq_level;
+ else
+ cpi->active_best_quality = cpi->cq_target_quality;
+ }
+ }
+
+ // Clip the active best and worst quality values to limits
+ if (cpi->active_worst_quality > cpi->worst_quality)
+ cpi->active_worst_quality = cpi->worst_quality;
+
+ if (cpi->active_best_quality < cpi->best_quality)
+ cpi->active_best_quality = cpi->best_quality;
+
+ if (cpi->active_best_quality > cpi->worst_quality)
+ cpi->active_best_quality = cpi->worst_quality;
+
+ if (cpi->active_worst_quality < cpi->active_best_quality)
+ cpi->active_worst_quality = cpi->active_best_quality;
+
+ // Specuial case code to try and match quality with forced key frames
+ if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
+ Q = cpi->last_boosted_qindex;
+ } else {
+ // Determine initial Q to try
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+ }
+ last_zbin_oq = cpi->zbin_over_quant;
+
+ // Set highest allowed value for Zbin over quant
+ if (cm->frame_type == KEY_FRAME)
+ zbin_oq_high = 0; // ZBIN_OQ_MAX/16
+ else if (cm->refresh_alt_ref_frame || (cm->refresh_golden_frame && !cpi->source_alt_ref_active))
+ zbin_oq_high = 16;
+ else
+ zbin_oq_high = ZBIN_OQ_MAX;
+
+ vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &frame_over_shoot_limit);
+
+ // Limit Q range for the adaptive loop.
+ bottom_index = cpi->active_best_quality;
+ top_index = cpi->active_worst_quality;
+ q_low = cpi->active_best_quality;
+ q_high = cpi->active_worst_quality;
+
+ loop_count = 0;
#if CONFIG_HIGH_PRECISION_MV || CONFIG_ENHANCED_INTERP
- if (cm->frame_type != KEY_FRAME)
- {
+ if (cm->frame_type != KEY_FRAME) {
#if CONFIG_ENHANCED_INTERP
- /* TODO: Decide this more intelligently */
- if (sf->search_best_filter)
- {
- cm->mcomp_filter_type = mcomp_filters_to_search[0];
- mcomp_filter_index = 0;
- }
- else
- cm->mcomp_filter_type = EIGHTTAP;
+ /* TODO: Decide this more intelligently */
+ if (sf->search_best_filter) {
+ cm->mcomp_filter_type = mcomp_filters_to_search[0];
+ mcomp_filter_index = 0;
+ } else
+ cm->mcomp_filter_type = EIGHTTAP;
#endif
#if CONFIG_HIGH_PRECISION_MV
- /* TODO: Decide this more intelligently */
- xd->allow_high_precision_mv = (Q < HIGH_PRECISION_MV_QTHRESH);
+ /* TODO: Decide this more intelligently */
+ xd->allow_high_precision_mv = (Q < HIGH_PRECISION_MV_QTHRESH);
#endif
- }
+ }
#endif
#if CONFIG_POSTPROC
- if (cpi->oxcf.noise_sensitivity > 0)
- {
- unsigned char *src;
- int l = 0;
+ if (cpi->oxcf.noise_sensitivity > 0) {
+ unsigned char *src;
+ int l = 0;
- switch (cpi->oxcf.noise_sensitivity)
- {
- case 1:
- l = 20;
- break;
- case 2:
- l = 40;
- break;
- case 3:
- l = 60;
- break;
- case 4:
-
- case 5:
- l = 100;
- break;
- case 6:
- l = 150;
- break;
- }
+ switch (cpi->oxcf.noise_sensitivity) {
+ case 1:
+ l = 20;
+ break;
+ case 2:
+ l = 40;
+ break;
+ case 3:
+ l = 60;
+ break;
+ case 4:
+ case 5:
+ l = 100;
+ break;
+ case 6:
+ l = 150;
+ break;
+ }
- if (cm->frame_type == KEY_FRAME)
- {
- vp8_de_noise(cpi->Source, cpi->Source, l , 1, 0, RTCD(postproc));
- }
- else
- {
- vp8_de_noise(cpi->Source, cpi->Source, l , 1, 0, RTCD(postproc));
- src = cpi->Source->y_buffer;
+ if (cm->frame_type == KEY_FRAME) {
+ vp8_de_noise(cpi->Source, cpi->Source, l, 1, 0, RTCD(postproc));
+ } else {
+ vp8_de_noise(cpi->Source, cpi->Source, l, 1, 0, RTCD(postproc));
- if (cpi->Source->y_stride < 0)
- {
- src += cpi->Source->y_stride * (cpi->Source->y_height - 1);
- }
- }
+ src = cpi->Source->y_buffer;
+
+ if (cpi->Source->y_stride < 0) {
+ src += cpi->Source->y_stride * (cpi->Source->y_height - 1);
+ }
}
+ }
#endif
#ifdef OUTPUT_YUV_SRC
- vp8_write_yuv_frame(cpi->Source);
+ vp8_write_yuv_frame(cpi->Source);
#endif
#if CONFIG_ENHANCED_INTERP && RESET_FOREACH_FILTER
- if (sf->search_best_filter)
- {
- q_low0 = q_low;
- q_high0 = q_high;
- Q0 = Q;
- zbin_oq_low0 = zbin_oq_low;
- zbin_oq_high0 = zbin_oq_high;
- last_zbin_oq0 = last_zbin_oq;
- rate_correction_factor0 = cpi->rate_correction_factor;
- gf_rate_correction_factor0 = cpi->gf_rate_correction_factor;
- active_best_quality0 = cpi->active_best_quality;
- active_worst_quality0 = cpi->active_worst_quality;
- }
+ if (sf->search_best_filter) {
+ q_low0 = q_low;
+ q_high0 = q_high;
+ Q0 = Q;
+ zbin_oq_low0 = zbin_oq_low;
+ zbin_oq_high0 = zbin_oq_high;
+ last_zbin_oq0 = last_zbin_oq;
+ rate_correction_factor0 = cpi->rate_correction_factor;
+ gf_rate_correction_factor0 = cpi->gf_rate_correction_factor;
+ active_best_quality0 = cpi->active_best_quality;
+ active_worst_quality0 = cpi->active_worst_quality;
+ }
#endif
- do
- {
- vp8_clear_system_state(); //__asm emms;
+ do {
+ vp8_clear_system_state(); // __asm emms;
- vp8_set_quantizer(cpi, Q);
- this_q = Q;
+ vp8_set_quantizer(cpi, Q);
+ this_q = Q;
- if ( loop_count == 0 )
- {
+ if (loop_count == 0) {
- // setup skip prob for costing in mode/mv decision
- if (cpi->common.mb_no_coeff_skip)
- {
+ // setup skip prob for costing in mode/mv decision
+ if (cpi->common.mb_no_coeff_skip) {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; k++)
- cm->mbskip_pred_probs[k] = cpi->base_skip_false_prob[Q][k];
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; k++)
+ cm->mbskip_pred_probs[k] = cpi->base_skip_false_prob[Q][k];
#else
- cpi->prob_skip_false = cpi->base_skip_false_prob[Q];
+ cpi->prob_skip_false = cpi->base_skip_false_prob[Q];
#endif
- if (cm->frame_type != KEY_FRAME)
- {
- if (cpi->common.refresh_alt_ref_frame)
- {
+ if (cm->frame_type != KEY_FRAME) {
+ if (cpi->common.refresh_alt_ref_frame) {
#if CONFIG_NEWENTROPY
- for (k=0; k<MBSKIP_CONTEXTS; k++)
- {
- if (cpi->last_skip_false_probs[2][k] != 0)
- cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[2][k];
- }
+ for (k = 0; k < MBSKIP_CONTEXTS; k++) {
+ if (cpi->last_skip_false_probs[2][k] != 0)
+ cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[2][k];
+ }
#else
- if (cpi->last_skip_false_probs[2] != 0)
- cpi->prob_skip_false = cpi->last_skip_false_probs[2];
+ if (cpi->last_skip_false_probs[2] != 0)
+ cpi->prob_skip_false = cpi->last_skip_false_probs[2];
#endif
- }
- else if (cpi->common.refresh_golden_frame)
- {
+ } else if (cpi->common.refresh_golden_frame) {
#if CONFIG_NEWENTROPY
- for (k=0; k<MBSKIP_CONTEXTS; k++)
- {
- if (cpi->last_skip_false_probs[1][k] != 0)
- cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[1][k];
- }
+ for (k = 0; k < MBSKIP_CONTEXTS; k++) {
+ if (cpi->last_skip_false_probs[1][k] != 0)
+ cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[1][k];
+ }
#else
- if (cpi->last_skip_false_probs[1] != 0)
- cpi->prob_skip_false = cpi->last_skip_false_probs[1];
+ if (cpi->last_skip_false_probs[1] != 0)
+ cpi->prob_skip_false = cpi->last_skip_false_probs[1];
#endif
- }
- else
- {
+ } else {
#if CONFIG_NEWENTROPY
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; k++)
- {
- if (cpi->last_skip_false_probs[0][k] != 0)
- cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[0][k];
- }
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; k++) {
+ if (cpi->last_skip_false_probs[0][k] != 0)
+ cm->mbskip_pred_probs[k] = cpi->last_skip_false_probs[0][k];
+ }
#else
- if (cpi->last_skip_false_probs[0] != 0)
- cpi->prob_skip_false = cpi->last_skip_false_probs[0];
+ if (cpi->last_skip_false_probs[0] != 0)
+ cpi->prob_skip_false = cpi->last_skip_false_probs[0];
#endif
- }
+ }
- // as this is for cost estimate, let's make sure it does not
- // get extreme either way
+ // as this is for cost estimate, let's make sure it does not
+ // get extreme either way
#if CONFIG_NEWENTROPY
- {
- int k;
- for (k=0; k<MBSKIP_CONTEXTS; ++k)
- {
- if (cm->mbskip_pred_probs[k] < 5)
- cm->mbskip_pred_probs[k] = 5;
-
- if (cm->mbskip_pred_probs[k] > 250)
- cm->mbskip_pred_probs[k] = 250;
-
- if (cpi->is_src_frame_alt_ref)
- cm->mbskip_pred_probs[k] = 1;
- }
- }
+ {
+ int k;
+ for (k = 0; k < MBSKIP_CONTEXTS; ++k) {
+ if (cm->mbskip_pred_probs[k] < 5)
+ cm->mbskip_pred_probs[k] = 5;
+
+ if (cm->mbskip_pred_probs[k] > 250)
+ cm->mbskip_pred_probs[k] = 250;
+
+ if (cpi->is_src_frame_alt_ref)
+ cm->mbskip_pred_probs[k] = 1;
+ }
+ }
#else
- if (cpi->prob_skip_false < 5)
- cpi->prob_skip_false = 5;
+ if (cpi->prob_skip_false < 5)
+ cpi->prob_skip_false = 5;
- if (cpi->prob_skip_false > 250)
- cpi->prob_skip_false = 250;
+ if (cpi->prob_skip_false > 250)
+ cpi->prob_skip_false = 250;
- if (cpi->is_src_frame_alt_ref)
- cpi->prob_skip_false = 1;
+ if (cpi->is_src_frame_alt_ref)
+ cpi->prob_skip_false = 1;
#endif
- }
- }
-
- // Set up entropy depending on frame type.
- if (cm->frame_type == KEY_FRAME)
- vp8_setup_key_frame(cpi);
- else
- vp8_setup_inter_frame(cpi);
}
+ }
+
+ // Set up entropy depending on frame type.
+ if (cm->frame_type == KEY_FRAME)
+ vp8_setup_key_frame(cpi);
+ else
+ vp8_setup_inter_frame(cpi);
+ }
- // transform / motion compensation build reconstruction frame
+ // transform / motion compensation build reconstruction frame
- vp8_encode_frame(cpi);
+ vp8_encode_frame(cpi);
- // Update the skip mb flag probabilities based on the distribution
- // seen in the last encoder iteration.
- update_base_skip_probs( cpi );
+ // Update the skip mb flag probabilities based on the distribution
+ // seen in the last encoder iteration.
+ update_base_skip_probs(cpi);
- vp8_clear_system_state(); //__asm emms;
+ vp8_clear_system_state(); // __asm emms;
#if CONFIG_PRED_FILTER
- // Update prediction filter on/off probability based on
- // selection made for the current frame
- if (cm->frame_type != KEY_FRAME)
- update_pred_filt_prob( cpi );
+ // Update prediction filter on/off probability based on
+ // selection made for the current frame
+ if (cm->frame_type != KEY_FRAME)
+ update_pred_filt_prob(cpi);
#endif
- // Dummy pack of the bitstream using up to date stats to get an
- // accurate estimate of output frame size to determine if we need
- // to recode.
- vp8_save_coding_context(cpi);
- cpi->dummy_packing = 1;
- vp8_pack_bitstream(cpi, dest, size);
- cpi->projected_frame_size = (*size) << 3;
- vp8_restore_coding_context(cpi);
-
- if (frame_over_shoot_limit == 0)
- frame_over_shoot_limit = 1;
- active_worst_qchanged = FALSE;
-
- // Special case handling for forced key frames
- if ( (cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced )
- {
- int last_q = Q;
- int kf_err = vp8_calc_ss_err(cpi->Source,
- &cm->yv12_fb[cm->new_fb_idx],
- IF_RTCD(&cpi->rtcd.variance));
-
- int high_err_target = cpi->ambient_err;
- int low_err_target = (cpi->ambient_err >> 1);
-
- // Prevent possible divide by zero error below for perfect KF
- kf_err += (!kf_err);
-
- // The key frame is not good enough or we can afford
- // to make it better without undue risk of popping.
- if ( ( (kf_err > high_err_target) &&
- (cpi->projected_frame_size <= frame_over_shoot_limit) ) ||
- ( (kf_err > low_err_target) &&
- (cpi->projected_frame_size <= frame_under_shoot_limit) ) )
- {
- // Lower q_high
- q_high = (Q > q_low) ? (Q - 1) : q_low;
-
- // Adjust Q
- Q = (Q * high_err_target) / kf_err;
- if ( Q < ((q_high + q_low) >> 1))
- Q = (q_high + q_low) >> 1;
- }
- // The key frame is much better than the previous frame
- else if ( (kf_err < low_err_target) &&
- (cpi->projected_frame_size >= frame_under_shoot_limit) )
- {
- // Raise q_low
- q_low = (Q < q_high) ? (Q + 1) : q_high;
-
- // Adjust Q
- Q = (Q * low_err_target) / kf_err;
- if ( Q > ((q_high + q_low + 1) >> 1))
- Q = (q_high + q_low + 1) >> 1;
- }
-
- // Clamp Q to upper and lower limits:
- if (Q > q_high)
- Q = q_high;
- else if (Q < q_low)
- Q = q_low;
-
- Loop = ((Q != last_q)) ? TRUE : FALSE;
+ // Dummy pack of the bitstream using up to date stats to get an
+ // accurate estimate of output frame size to determine if we need
+ // to recode.
+ vp8_save_coding_context(cpi);
+ cpi->dummy_packing = 1;
+ vp8_pack_bitstream(cpi, dest, size);
+ cpi->projected_frame_size = (*size) << 3;
+ vp8_restore_coding_context(cpi);
+
+ if (frame_over_shoot_limit == 0)
+ frame_over_shoot_limit = 1;
+ active_worst_qchanged = FALSE;
+
+ // Special case handling for forced key frames
+ if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
+ int last_q = Q;
+ int kf_err = vp8_calc_ss_err(cpi->Source,
+ &cm->yv12_fb[cm->new_fb_idx],
+ IF_RTCD(&cpi->rtcd.variance));
+
+ int high_err_target = cpi->ambient_err;
+ int low_err_target = (cpi->ambient_err >> 1);
+
+ // Prevent possible divide by zero error below for perfect KF
+ kf_err += (!kf_err);
+
+ // The key frame is not good enough or we can afford
+ // to make it better without undue risk of popping.
+ if (((kf_err > high_err_target) &&
+ (cpi->projected_frame_size <= frame_over_shoot_limit)) ||
+ ((kf_err > low_err_target) &&
+ (cpi->projected_frame_size <= frame_under_shoot_limit))) {
+ // Lower q_high
+ q_high = (Q > q_low) ? (Q - 1) : q_low;
+
+ // Adjust Q
+ Q = (Q * high_err_target) / kf_err;
+ if (Q < ((q_high + q_low) >> 1))
+ Q = (q_high + q_low) >> 1;
+ }
+ // The key frame is much better than the previous frame
+ else if ((kf_err < low_err_target) &&
+ (cpi->projected_frame_size >= frame_under_shoot_limit)) {
+ // Raise q_low
+ q_low = (Q < q_high) ? (Q + 1) : q_high;
+
+ // Adjust Q
+ Q = (Q * low_err_target) / kf_err;
+ if (Q > ((q_high + q_low + 1) >> 1))
+ Q = (q_high + q_low + 1) >> 1;
+ }
+
+ // Clamp Q to upper and lower limits:
+ if (Q > q_high)
+ Q = q_high;
+ else if (Q < q_low)
+ Q = q_low;
+
+ Loop = ((Q != last_q)) ? TRUE : FALSE;
+ }
+
+ // Is the projected frame size out of range and are we allowed to attempt to recode.
+ else if (recode_loop_test(cpi,
+ frame_over_shoot_limit, frame_under_shoot_limit,
+ Q, top_index, bottom_index)) {
+ int last_q = Q;
+ int Retries = 0;
+
+ // Frame size out of permitted range:
+ // Update correction factor & compute new Q to try...
+
+ // Frame is too large
+ if (cpi->projected_frame_size > cpi->this_frame_target) {
+ q_low = (Q < q_high) ? (Q + 1) : q_high; // Raise Qlow as to at least the current value
+
+ if (cpi->zbin_over_quant > 0) // If we are using over quant do the same for zbin_oq_low
+ zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
+
+ if (undershoot_seen || (loop_count > 1)) {
+ // Update rate_correction_factor unless cpi->active_worst_quality has changed.
+ if (!active_worst_qchanged)
+ vp8_update_rate_correction_factors(cpi, 1);
+
+ Q = (q_high + q_low + 1) / 2;
+
+ // Adjust cpi->zbin_over_quant (only allowed when Q is max)
+ if (Q < MAXQ)
+ cpi->zbin_over_quant = 0;
+ else {
+ zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
+ cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
+ }
+ } else {
+ // Update rate_correction_factor unless cpi->active_worst_quality has changed.
+ if (!active_worst_qchanged)
+ vp8_update_rate_correction_factors(cpi, 0);
+
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+
+ while (((Q < q_low) || (cpi->zbin_over_quant < zbin_oq_low)) && (Retries < 10)) {
+ vp8_update_rate_correction_factors(cpi, 0);
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+ Retries++;
+ }
}
- // Is the projected frame size out of range and are we allowed to attempt to recode.
- else if ( recode_loop_test( cpi,
- frame_over_shoot_limit, frame_under_shoot_limit,
- Q, top_index, bottom_index ) )
- {
- int last_q = Q;
- int Retries = 0;
-
- // Frame size out of permitted range:
- // Update correction factor & compute new Q to try...
-
- // Frame is too large
- if (cpi->projected_frame_size > cpi->this_frame_target)
- {
- q_low = (Q < q_high) ? (Q + 1) : q_high; // Raise Qlow as to at least the current value
-
- if (cpi->zbin_over_quant > 0) // If we are using over quant do the same for zbin_oq_low
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
+ overshoot_seen = TRUE;
+ }
+ // Frame is too small
+ else {
+ if (cpi->zbin_over_quant == 0)
+ q_high = (Q > q_low) ? (Q - 1) : q_low; // Lower q_high if not using over quant
+ else // else lower zbin_oq_high
+ zbin_oq_high = (cpi->zbin_over_quant > zbin_oq_low) ? (cpi->zbin_over_quant - 1) : zbin_oq_low;
+
+ if (overshoot_seen || (loop_count > 1)) {
+ // Update rate_correction_factor unless cpi->active_worst_quality has changed.
+ if (!active_worst_qchanged)
+ vp8_update_rate_correction_factors(cpi, 1);
+
+ Q = (q_high + q_low) / 2;
+
+ // Adjust cpi->zbin_over_quant (only allowed when Q is max)
+ if (Q < MAXQ)
+ cpi->zbin_over_quant = 0;
+ else
+ cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
+ } else {
+ // Update rate_correction_factor unless cpi->active_worst_quality has changed.
+ if (!active_worst_qchanged)
+ vp8_update_rate_correction_factors(cpi, 0);
+
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+
+ // Special case reset for qlow for constrained quality.
+ // This should only trigger where there is very substantial
+ // undershoot on a frame and the auto cq level is above
+ // the user passsed in value.
+ if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ (Q < q_low)) {
+ q_low = Q;
+ }
+
+ while (((Q > q_high) || (cpi->zbin_over_quant > zbin_oq_high)) && (Retries < 10)) {
+ vp8_update_rate_correction_factors(cpi, 0);
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+ Retries++;
+ }
+ }
- if ( undershoot_seen || (loop_count > 1) )
- {
- // Update rate_correction_factor unless cpi->active_worst_quality has changed.
- if (!active_worst_qchanged)
- vp8_update_rate_correction_factors(cpi, 1);
-
- Q = (q_high + q_low + 1) / 2;
-
- // Adjust cpi->zbin_over_quant (only allowed when Q is max)
- if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
- else
- {
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
- }
- }
- else
- {
- // Update rate_correction_factor unless cpi->active_worst_quality has changed.
- if (!active_worst_qchanged)
- vp8_update_rate_correction_factors(cpi, 0);
-
- Q = vp8_regulate_q(cpi, cpi->this_frame_target);
-
- while (((Q < q_low) || (cpi->zbin_over_quant < zbin_oq_low)) && (Retries < 10))
- {
- vp8_update_rate_correction_factors(cpi, 0);
- Q = vp8_regulate_q(cpi, cpi->this_frame_target);
- Retries ++;
- }
- }
+ undershoot_seen = TRUE;
+ }
- overshoot_seen = TRUE;
- }
- // Frame is too small
- else
- {
- if (cpi->zbin_over_quant == 0)
- q_high = (Q > q_low) ? (Q - 1) : q_low; // Lower q_high if not using over quant
- else // else lower zbin_oq_high
- zbin_oq_high = (cpi->zbin_over_quant > zbin_oq_low) ? (cpi->zbin_over_quant - 1) : zbin_oq_low;
+ // Clamp Q to upper and lower limits:
+ if (Q > q_high)
+ Q = q_high;
+ else if (Q < q_low)
+ Q = q_low;
- if ( overshoot_seen || (loop_count > 1) )
- {
- // Update rate_correction_factor unless cpi->active_worst_quality has changed.
- if (!active_worst_qchanged)
- vp8_update_rate_correction_factors(cpi, 1);
+ // Clamp cpi->zbin_over_quant
+ cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ? zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ? zbin_oq_high : cpi->zbin_over_quant;
- Q = (q_high + q_low) / 2;
+ // Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE;
+ Loop = ((Q != last_q)) ? TRUE : FALSE;
+ last_zbin_oq = cpi->zbin_over_quant;
+ } else
+ Loop = FALSE;
- // Adjust cpi->zbin_over_quant (only allowed when Q is max)
- if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
- else
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
- }
- else
- {
- // Update rate_correction_factor unless cpi->active_worst_quality has changed.
- if (!active_worst_qchanged)
- vp8_update_rate_correction_factors(cpi, 0);
-
- Q = vp8_regulate_q(cpi, cpi->this_frame_target);
-
- // Special case reset for qlow for constrained quality.
- // This should only trigger where there is very substantial
- // undershoot on a frame and the auto cq level is above
- // the user passsed in value.
- if ( (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (Q < q_low) )
- {
- q_low = Q;
- }
-
- while (((Q > q_high) || (cpi->zbin_over_quant > zbin_oq_high)) && (Retries < 10))
- {
- vp8_update_rate_correction_factors(cpi, 0);
- Q = vp8_regulate_q(cpi, cpi->this_frame_target);
- Retries ++;
- }
- }
+ if (cpi->is_src_frame_alt_ref)
+ Loop = FALSE;
- undershoot_seen = TRUE;
+#if CONFIG_ENHANCED_INTERP
+ if (Loop == FALSE && cm->frame_type != KEY_FRAME && sf->search_best_filter) {
+ if (mcomp_filter_index < mcomp_filters) {
+ INT64 err = vp8_calc_ss_err(cpi->Source,
+ &cm->yv12_fb[cm->new_fb_idx],
+ IF_RTCD(&cpi->rtcd.variance));
+ INT64 rate = cpi->projected_frame_size << 8;
+ mcomp_filter_cost[mcomp_filter_index] =
+ (RDCOST(cpi->RDMULT, cpi->RDDIV, rate, err));
+ mcomp_filter_index++;
+ if (mcomp_filter_index < mcomp_filters) {
+ cm->mcomp_filter_type = mcomp_filters_to_search[mcomp_filter_index];
+ loop_count = -1;
+ Loop = TRUE;
+ } else {
+ int f;
+ INT64 best_cost = mcomp_filter_cost[0];
+ int mcomp_best_filter = mcomp_filters_to_search[0];
+ for (f = 1; f < mcomp_filters; f++) {
+ if (mcomp_filter_cost[f] < best_cost) {
+ mcomp_best_filter = mcomp_filters_to_search[f];
+ best_cost = mcomp_filter_cost[f];
}
-
- // Clamp Q to upper and lower limits:
- if (Q > q_high)
- Q = q_high;
- else if (Q < q_low)
- Q = q_low;
-
- // Clamp cpi->zbin_over_quant
- cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ? zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ? zbin_oq_high : cpi->zbin_over_quant;
-
- //Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE;
- Loop = ((Q != last_q)) ? TRUE : FALSE;
- last_zbin_oq = cpi->zbin_over_quant;
+ }
+ if (mcomp_best_filter != mcomp_filters_to_search[mcomp_filters - 1]) {
+ loop_count = -1;
+ Loop = TRUE;
+ cm->mcomp_filter_type = mcomp_best_filter;
+ }
+ /*
+ printf(" best filter = %d, ( ", mcomp_best_filter);
+ for (f=0;f<mcomp_filters; f++) printf("%d ", mcomp_filter_cost[f]);
+ printf(")\n");
+ */
}
- else
- Loop = FALSE;
-
- if (cpi->is_src_frame_alt_ref)
- Loop = FALSE;
-
-#if CONFIG_ENHANCED_INTERP
- if (Loop == FALSE && cm->frame_type != KEY_FRAME && sf->search_best_filter)
- {
- if (mcomp_filter_index < mcomp_filters)
- {
- INT64 err = vp8_calc_ss_err(cpi->Source,
- &cm->yv12_fb[cm->new_fb_idx],
- IF_RTCD(&cpi->rtcd.variance));
- INT64 rate = cpi->projected_frame_size << 8;
- mcomp_filter_cost[mcomp_filter_index] =
- (RDCOST(cpi->RDMULT, cpi->RDDIV, rate, err));
- mcomp_filter_index++;
- if (mcomp_filter_index < mcomp_filters)
- {
- cm->mcomp_filter_type = mcomp_filters_to_search[mcomp_filter_index];
- loop_count = -1;
- Loop = TRUE;
- }
- else
- {
- int f;
- INT64 best_cost = mcomp_filter_cost[0];
- int mcomp_best_filter = mcomp_filters_to_search[0];
- for (f = 1; f < mcomp_filters; f++)
- {
- if (mcomp_filter_cost[f] < best_cost)
- {
- mcomp_best_filter = mcomp_filters_to_search[f];
- best_cost = mcomp_filter_cost[f];
- }
- }
- if (mcomp_best_filter != mcomp_filters_to_search[mcomp_filters-1])
- {
- loop_count = -1;
- Loop = TRUE;
- cm->mcomp_filter_type = mcomp_best_filter;
- }
- /*
- printf(" best filter = %d, ( ", mcomp_best_filter);
- for (f=0;f<mcomp_filters; f++) printf("%d ", mcomp_filter_cost[f]);
- printf(")\n");
- */
- }
#if RESET_FOREACH_FILTER
- if (Loop == TRUE)
- {
- overshoot_seen = FALSE;
- undershoot_seen = FALSE;
- zbin_oq_low = zbin_oq_low0;
- zbin_oq_high = zbin_oq_high0;
- q_low = q_low0;
- q_high = q_high0;
- Q = Q0;
- cpi->zbin_over_quant = last_zbin_oq = last_zbin_oq0;
- cpi->rate_correction_factor = rate_correction_factor0;
- cpi->gf_rate_correction_factor = gf_rate_correction_factor0;
- cpi->active_best_quality = active_best_quality0;
- cpi->active_worst_quality = active_worst_quality0;
- }
-#endif
- }
+ if (Loop == TRUE) {
+ overshoot_seen = FALSE;
+ undershoot_seen = FALSE;
+ zbin_oq_low = zbin_oq_low0;
+ zbin_oq_high = zbin_oq_high0;
+ q_low = q_low0;
+ q_high = q_high0;
+ Q = Q0;
+ cpi->zbin_over_quant = last_zbin_oq = last_zbin_oq0;
+ cpi->rate_correction_factor = rate_correction_factor0;
+ cpi->gf_rate_correction_factor = gf_rate_correction_factor0;
+ cpi->active_best_quality = active_best_quality0;
+ cpi->active_worst_quality = active_worst_quality0;
}
#endif
+ }
+ }
+#endif
- if (Loop == TRUE)
- {
- loop_count++;
+ if (Loop == TRUE) {
+ loop_count++;
#if CONFIG_INTERNAL_STATS
- cpi->tot_recode_hits++;
+ cpi->tot_recode_hits++;
#endif
- }
- }
- while (Loop == TRUE);
-
- // Special case code to reduce pulsing when key frames are forced at a
- // fixed interval. Note the reconstruction error if it is the frame before
- // the force key frame
- if ( cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0) )
- {
- cpi->ambient_err = vp8_calc_ss_err(cpi->Source,
- &cm->yv12_fb[cm->new_fb_idx],
- IF_RTCD(&cpi->rtcd.variance));
}
-
- // This frame's MVs are saved and will be used in next frame's MV
- // prediction. Last frame has one more line(add to bottom) and one
- // more column(add to right) than cm->mip. The edge elements are
- // initialized to 0.
- if(cm->show_frame) //do not save for altref frame
- {
- int mb_row;
- int mb_col;
- MODE_INFO *tmp = cm->mip;
-
- if(cm->frame_type != KEY_FRAME)
- {
- for (mb_row = 0; mb_row < cm->mb_rows+1; mb_row ++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols+1; mb_col ++)
- {
- if(tmp->mbmi.ref_frame != INTRA_FRAME)
- cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride+1)].as_int = tmp->mbmi.mv.as_int;
-
- cpi->lf_ref_frame_sign_bias[mb_col + mb_row*(cm->mode_info_stride+1)] = cm->ref_frame_sign_bias[tmp->mbmi.ref_frame];
- cpi->lf_ref_frame[mb_col + mb_row*(cm->mode_info_stride+1)] = tmp->mbmi.ref_frame;
- tmp++;
- }
- }
+ } while (Loop == TRUE);
+
+ // Special case code to reduce pulsing when key frames are forced at a
+ // fixed interval. Note the reconstruction error if it is the frame before
+ // the force key frame
+ if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) {
+ cpi->ambient_err = vp8_calc_ss_err(cpi->Source,
+ &cm->yv12_fb[cm->new_fb_idx],
+ IF_RTCD(&cpi->rtcd.variance));
+ }
+
+ // This frame's MVs are saved and will be used in next frame's MV
+ // prediction. Last frame has one more line(add to bottom) and one
+ // more column(add to right) than cm->mip. The edge elements are
+ // initialized to 0.
+ if (cm->show_frame) { // do not save for altref frame
+ int mb_row;
+ int mb_col;
+ MODE_INFO *tmp = cm->mip;
+
+ if (cm->frame_type != KEY_FRAME) {
+ for (mb_row = 0; mb_row < cm->mb_rows + 1; mb_row ++) {
+ for (mb_col = 0; mb_col < cm->mb_cols + 1; mb_col ++) {
+ if (tmp->mbmi.ref_frame != INTRA_FRAME)
+ cpi->lfmv[mb_col + mb_row * (cm->mode_info_stride + 1)].as_int = tmp->mbmi.mv.as_int;
+
+ cpi->lf_ref_frame_sign_bias[mb_col + mb_row * (cm->mode_info_stride + 1)] = cm->ref_frame_sign_bias[tmp->mbmi.ref_frame];
+ cpi->lf_ref_frame[mb_col + mb_row * (cm->mode_info_stride + 1)] = tmp->mbmi.ref_frame;
+ tmp++;
}
+ }
}
+ }
- // Update the GF useage maps.
- // This is done after completing the compression of a frame when all modes
- // etc. are finalized but before loop filter
- vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);
+ // Update the GF useage maps.
+ // This is done after completing the compression of a frame when all modes
+ // etc. are finalized but before loop filter
+ vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);
- if (cm->frame_type == KEY_FRAME)
- cm->refresh_last_frame = 1;
+ if (cm->frame_type == KEY_FRAME)
+ cm->refresh_last_frame = 1;
#if 0
- {
- FILE *f = fopen("gfactive.stt", "a");
- fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iiratio, cpi->next_iiratio, cm->refresh_golden_frame);
- fclose(f);
- }
+ {
+ FILE *f = fopen("gfactive.stt", "a");
+ fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iiratio, cpi->next_iiratio, cm->refresh_golden_frame);
+ fclose(f);
+ }
#endif
- cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
+ cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
#if WRITE_RECON_BUFFER
- if(cm->show_frame)
- write_cx_frame_to_file(cm->frame_to_show,
- cm->current_video_frame);
- else
- write_cx_frame_to_file(cm->frame_to_show,
- cm->current_video_frame+1000);
+ if (cm->show_frame)
+ write_cx_frame_to_file(cm->frame_to_show,
+ cm->current_video_frame);
+ else
+ write_cx_frame_to_file(cm->frame_to_show,
+ cm->current_video_frame + 1000);
#endif
- // Pick the loop filter level for the frame.
- loopfilter_frame(cpi, cm);
+ // Pick the loop filter level for the frame.
+ loopfilter_frame(cpi, cm);
- // build the bitstream
- cpi->dummy_packing = 0;
- vp8_pack_bitstream(cpi, dest, size);
+ // build the bitstream
+ cpi->dummy_packing = 0;
+ vp8_pack_bitstream(cpi, dest, size);
#if CONFIG_PRED_FILTER
- // Select the prediction filtering mode to use for the
- // next frame based on the current frame selections
- if(cm->frame_type != KEY_FRAME)
- select_pred_filter_mode (cpi);
+ // Select the prediction filtering mode to use for the
+ // next frame based on the current frame selections
+ if (cm->frame_type != KEY_FRAME)
+ select_pred_filter_mode(cpi);
#endif
- update_reference_frames(cm);
+ update_reference_frames(cm);
#if CONFIG_ADAPTIVE_ENTROPY
- vp8_copy(cpi->common.fc.coef_counts, cpi->coef_counts);
- vp8_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8);
- vp8_adapt_coef_probs(&cpi->common);
- if (cpi->common.frame_type != KEY_FRAME)
- {
- vp8_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
- vp8_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
- vp8_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
- vp8_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count);
- vp8_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
- vp8_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count);
- vp8_adapt_mode_probs(&cpi->common);
-
- vp8_copy(cpi->common.fc.MVcount, cpi->MVcount);
+ vp8_copy(cpi->common.fc.coef_counts, cpi->coef_counts);
+ vp8_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8);
+ vp8_adapt_coef_probs(&cpi->common);
+ if (cpi->common.frame_type != KEY_FRAME) {
+ vp8_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
+ vp8_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
+ vp8_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
+ vp8_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count);
+ vp8_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
+ vp8_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count);
+ vp8_adapt_mode_probs(&cpi->common);
+
+ vp8_copy(cpi->common.fc.MVcount, cpi->MVcount);
#if CONFIG_HIGH_PRECISION_MV
- vp8_copy(cpi->common.fc.MVcount_hp, cpi->MVcount_hp);
+ vp8_copy(cpi->common.fc.MVcount_hp, cpi->MVcount_hp);
#endif
- vp8_adapt_mv_probs(&cpi->common);
- vp8_update_mode_context(&cpi->common);
- }
+ vp8_adapt_mv_probs(&cpi->common);
+ vp8_update_mode_context(&cpi->common);
+ }
#endif /* CONFIG_ADAPTIVE_ENTROPY */
- /* Move storing frame_type out of the above loop since it is also
- * needed in motion search besides loopfilter */
- cm->last_frame_type = cm->frame_type;
-
- // Keep a copy of the size estimate used in the loop
- loop_size_estimate = cpi->projected_frame_size;
-
- // Update rate control heuristics
- cpi->total_byte_count += (*size);
- cpi->projected_frame_size = (*size) << 3;
-
- if (!active_worst_qchanged)
- vp8_update_rate_correction_factors(cpi, 2);
-
- cpi->last_q[cm->frame_type] = cm->base_qindex;
-
- // Keep record of last boosted (KF/KF/ARF) Q value.
- // If the current frame is coded at a lower Q then we also update it.
- // If all mbs in this group are skipped only update if the Q value is
- // better than that already stored.
- // This is used to help set quality in forced key frames to reduce popping
- if ( (cm->base_qindex < cpi->last_boosted_qindex) ||
- ( (cpi->static_mb_pct < 100) &&
- ( (cm->frame_type == KEY_FRAME) ||
- cm->refresh_alt_ref_frame ||
- (cm->refresh_golden_frame && !cpi->is_src_frame_alt_ref) ) ) )
- {
- cpi->last_boosted_qindex = cm->base_qindex;
- }
-
- if (cm->frame_type == KEY_FRAME)
- {
- vp8_adjust_key_frame_context(cpi);
- }
-
- // Keep a record of ambient average Q.
- if (cm->frame_type != KEY_FRAME)
- cpi->avg_frame_qindex = (2 + 3 * cpi->avg_frame_qindex + cm->base_qindex) >> 2;
-
- // Keep a record from which we can calculate the average Q excluding GF updates and key frames
- if ((cm->frame_type != KEY_FRAME) && !cm->refresh_golden_frame && !cm->refresh_alt_ref_frame)
- {
- cpi->ni_frames++;
- cpi->tot_q += vp8_convert_qindex_to_q(Q);
- cpi->avg_q = cpi->tot_q / (double)cpi->ni_frames;
-
- // Calculate the average Q for normal inter frames (not key or GFU
- // frames).
- cpi->ni_tot_qi += Q;
- cpi->ni_av_qi = (cpi->ni_tot_qi / cpi->ni_frames);
- }
-
- // Update the buffer level variable.
- // Non-viewable frames are a special case and are treated as pure overhead.
- if ( !cm->show_frame )
- cpi->bits_off_target -= cpi->projected_frame_size;
+ /* Move storing frame_type out of the above loop since it is also
+ * needed in motion search besides loopfilter */
+ cm->last_frame_type = cm->frame_type;
+
+ // Keep a copy of the size estimate used in the loop
+ loop_size_estimate = cpi->projected_frame_size;
+
+ // Update rate control heuristics
+ cpi->total_byte_count += (*size);
+ cpi->projected_frame_size = (*size) << 3;
+
+ if (!active_worst_qchanged)
+ vp8_update_rate_correction_factors(cpi, 2);
+
+ cpi->last_q[cm->frame_type] = cm->base_qindex;
+
+ // Keep record of last boosted (KF/KF/ARF) Q value.
+ // If the current frame is coded at a lower Q then we also update it.
+ // If all mbs in this group are skipped only update if the Q value is
+ // better than that already stored.
+ // This is used to help set quality in forced key frames to reduce popping
+ if ((cm->base_qindex < cpi->last_boosted_qindex) ||
+ ((cpi->static_mb_pct < 100) &&
+ ((cm->frame_type == KEY_FRAME) ||
+ cm->refresh_alt_ref_frame ||
+ (cm->refresh_golden_frame && !cpi->is_src_frame_alt_ref)))) {
+ cpi->last_boosted_qindex = cm->base_qindex;
+ }
+
+ if (cm->frame_type == KEY_FRAME) {
+ vp8_adjust_key_frame_context(cpi);
+ }
+
+ // Keep a record of ambient average Q.
+ if (cm->frame_type != KEY_FRAME)
+ cpi->avg_frame_qindex = (2 + 3 * cpi->avg_frame_qindex + cm->base_qindex) >> 2;
+
+ // Keep a record from which we can calculate the average Q excluding GF updates and key frames
+ if ((cm->frame_type != KEY_FRAME) && !cm->refresh_golden_frame && !cm->refresh_alt_ref_frame) {
+ cpi->ni_frames++;
+ cpi->tot_q += vp8_convert_qindex_to_q(Q);
+ cpi->avg_q = cpi->tot_q / (double)cpi->ni_frames;
+
+ // Calculate the average Q for normal inter frames (not key or GFU
+ // frames).
+ cpi->ni_tot_qi += Q;
+ cpi->ni_av_qi = (cpi->ni_tot_qi / cpi->ni_frames);
+ }
+
+ // Update the buffer level variable.
+ // Non-viewable frames are a special case and are treated as pure overhead.
+ if (!cm->show_frame)
+ cpi->bits_off_target -= cpi->projected_frame_size;
+ else
+ cpi->bits_off_target += cpi->av_per_frame_bandwidth - cpi->projected_frame_size;
+
+ // Clip the buffer level at the maximum buffer size
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
+
+ // Rolling monitors of whether we are over or underspending used to help regulate min and Max Q in two pass.
+ cpi->rolling_target_bits = ((cpi->rolling_target_bits * 3) + cpi->this_frame_target + 2) / 4;
+ cpi->rolling_actual_bits = ((cpi->rolling_actual_bits * 3) + cpi->projected_frame_size + 2) / 4;
+ cpi->long_rolling_target_bits = ((cpi->long_rolling_target_bits * 31) + cpi->this_frame_target + 16) / 32;
+ cpi->long_rolling_actual_bits = ((cpi->long_rolling_actual_bits * 31) + cpi->projected_frame_size + 16) / 32;
+
+ // Actual bits spent
+ cpi->total_actual_bits += cpi->projected_frame_size;
+
+ // Debug stats
+ cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_frame_size);
+
+ cpi->buffer_level = cpi->bits_off_target;
+
+ // Update bits left to the kf and gf groups to account for overshoot or undershoot on these frames
+ if (cm->frame_type == KEY_FRAME) {
+ cpi->twopass.kf_group_bits += cpi->this_frame_target - cpi->projected_frame_size;
+
+ if (cpi->twopass.kf_group_bits < 0)
+ cpi->twopass.kf_group_bits = 0;
+ } else if (cm->refresh_golden_frame || cm->refresh_alt_ref_frame) {
+ cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_frame_size;
+
+ if (cpi->twopass.gf_group_bits < 0)
+ cpi->twopass.gf_group_bits = 0;
+ }
+
+ // Update the skip mb flag probabilities based on the distribution seen
+ // in this frame.
+ update_base_skip_probs(cpi);
+
+#if 0// 1 && CONFIG_INTERNAL_STATS
+ {
+ FILE *f = fopen("tmp.stt", "a");
+ int recon_err;
+
+ vp8_clear_system_state(); // __asm emms;
+
+ recon_err = vp8_calc_ss_err(cpi->Source,
+ &cm->yv12_fb[cm->new_fb_idx],
+ IF_RTCD(&cpi->rtcd.variance));
+
+ if (cpi->twopass.total_left_stats->coded_error != 0.0)
+ fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
+ "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
+ "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+ "%10.3f %8d %10d %10d %10d\n",
+ cpi->common.current_video_frame, cpi->this_frame_target,
+ cpi->projected_frame_size, loop_size_estimate,
+ (cpi->projected_frame_size - cpi->this_frame_target),
+ (int)cpi->total_target_vs_actual,
+ (cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
+ (int)cpi->total_actual_bits,
+ vp8_convert_qindex_to_q(cm->base_qindex),
+ (double)vp8_dc_quant(cm->base_qindex, 0) / 4.0,
+ vp8_convert_qindex_to_q(cpi->active_best_quality),
+ vp8_convert_qindex_to_q(cpi->active_worst_quality),
+ cpi->avg_q,
+ vp8_convert_qindex_to_q(cpi->ni_av_qi),
+ vp8_convert_qindex_to_q(cpi->cq_target_quality),
+ cpi->zbin_over_quant,
+ // cpi->avg_frame_qindex, cpi->zbin_over_quant,
+ cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
+ cm->frame_type, cpi->gfu_boost,
+ cpi->twopass.est_max_qcorrection_factor,
+ (int)cpi->twopass.bits_left,
+ cpi->twopass.total_left_stats->coded_error,
+ (double)cpi->twopass.bits_left /
+ cpi->twopass.total_left_stats->coded_error,
+ cpi->tot_recode_hits, recon_err, cpi->kf_boost,
+ cpi->kf_zeromotion_pct);
else
- cpi->bits_off_target += cpi->av_per_frame_bandwidth - cpi->projected_frame_size;
-
- // Clip the buffer level at the maximum buffer size
- if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
- cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
-
- // Rolling monitors of whether we are over or underspending used to help regulate min and Max Q in two pass.
- cpi->rolling_target_bits = ((cpi->rolling_target_bits * 3) + cpi->this_frame_target + 2) / 4;
- cpi->rolling_actual_bits = ((cpi->rolling_actual_bits * 3) + cpi->projected_frame_size + 2) / 4;
- cpi->long_rolling_target_bits = ((cpi->long_rolling_target_bits * 31) + cpi->this_frame_target + 16) / 32;
- cpi->long_rolling_actual_bits = ((cpi->long_rolling_actual_bits * 31) + cpi->projected_frame_size + 16) / 32;
-
- // Actual bits spent
- cpi->total_actual_bits += cpi->projected_frame_size;
-
- // Debug stats
- cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_frame_size);
-
- cpi->buffer_level = cpi->bits_off_target;
-
- // Update bits left to the kf and gf groups to account for overshoot or undershoot on these frames
- if (cm->frame_type == KEY_FRAME)
- {
- cpi->twopass.kf_group_bits += cpi->this_frame_target - cpi->projected_frame_size;
-
- if (cpi->twopass.kf_group_bits < 0)
- cpi->twopass.kf_group_bits = 0 ;
- }
- else if (cm->refresh_golden_frame || cm->refresh_alt_ref_frame)
- {
- cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_frame_size;
-
- if (cpi->twopass.gf_group_bits < 0)
- cpi->twopass.gf_group_bits = 0 ;
- }
-
- // Update the skip mb flag probabilities based on the distribution seen
- // in this frame.
- update_base_skip_probs( cpi );
-
-#if 0//1 && CONFIG_INTERNAL_STATS
- {
- FILE *f = fopen("tmp.stt", "a");
- int recon_err;
-
- vp8_clear_system_state(); //__asm emms;
-
- recon_err = vp8_calc_ss_err(cpi->Source,
- &cm->yv12_fb[cm->new_fb_idx],
- IF_RTCD(&cpi->rtcd.variance));
-
- if (cpi->twopass.total_left_stats->coded_error != 0.0)
- fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
- "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
- "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
- "%10.3f %8d %10d %10d %10d\n",
- cpi->common.current_video_frame, cpi->this_frame_target,
- cpi->projected_frame_size, loop_size_estimate,
- (cpi->projected_frame_size - cpi->this_frame_target),
- (int)cpi->total_target_vs_actual,
- (cpi->oxcf.starting_buffer_level-cpi->bits_off_target),
- (int)cpi->total_actual_bits,
- vp8_convert_qindex_to_q(cm->base_qindex),
- (double)vp8_dc_quant(cm->base_qindex,0)/4.0,
- vp8_convert_qindex_to_q(cpi->active_best_quality),
- vp8_convert_qindex_to_q(cpi->active_worst_quality),
- cpi->avg_q,
- vp8_convert_qindex_to_q(cpi->ni_av_qi),
- vp8_convert_qindex_to_q(cpi->cq_target_quality),
- cpi->zbin_over_quant,
- //cpi->avg_frame_qindex, cpi->zbin_over_quant,
- cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
- cm->frame_type, cpi->gfu_boost,
- cpi->twopass.est_max_qcorrection_factor,
- (int)cpi->twopass.bits_left,
- cpi->twopass.total_left_stats->coded_error,
- (double)cpi->twopass.bits_left /
- cpi->twopass.total_left_stats->coded_error,
- cpi->tot_recode_hits, recon_err, cpi->kf_boost,
- cpi->kf_zeromotion_pct);
- else
- fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
- "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
- "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
- "%8d %10d %10d %10d\n",
- cpi->common.current_video_frame,
- cpi->this_frame_target, cpi->projected_frame_size,
- loop_size_estimate,
- (cpi->projected_frame_size - cpi->this_frame_target),
- (int)cpi->total_target_vs_actual,
- (cpi->oxcf.starting_buffer_level-cpi->bits_off_target),
- (int)cpi->total_actual_bits,
- vp8_convert_qindex_to_q(cm->base_qindex),
- (double)vp8_dc_quant(cm->base_qindex,0)/4.0,
- vp8_convert_qindex_to_q(cpi->active_best_quality),
- vp8_convert_qindex_to_q(cpi->active_worst_quality),
- cpi->avg_q,
- vp8_convert_qindex_to_q(cpi->ni_av_qi),
- vp8_convert_qindex_to_q(cpi->cq_target_quality),
- cpi->zbin_over_quant,
- //cpi->avg_frame_qindex, cpi->zbin_over_quant,
- cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
- cm->frame_type, cpi->gfu_boost,
- cpi->twopass.est_max_qcorrection_factor,
- (int)cpi->twopass.bits_left,
- cpi->twopass.total_left_stats->coded_error,
- cpi->tot_recode_hits, recon_err, cpi->kf_boost,
- cpi->kf_zeromotion_pct);
-
- fclose(f);
-
- if ( 0 )
- {
- FILE *fmodes = fopen("Modes.stt", "a");
- int i;
-
- fprintf(fmodes, "%6d:%1d:%1d:%1d ",
- cpi->common.current_video_frame,
- cm->frame_type, cm->refresh_golden_frame,
- cm->refresh_alt_ref_frame);
-
- for (i = 0; i < MAX_MODES; i++)
- fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]);
-
- fprintf(fmodes, "\n");
-
- fclose(fmodes);
- }
- }
+ fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
+ "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
+ "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+ "%8d %10d %10d %10d\n",
+ cpi->common.current_video_frame,
+ cpi->this_frame_target, cpi->projected_frame_size,
+ loop_size_estimate,
+ (cpi->projected_frame_size - cpi->this_frame_target),
+ (int)cpi->total_target_vs_actual,
+ (cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
+ (int)cpi->total_actual_bits,
+ vp8_convert_qindex_to_q(cm->base_qindex),
+ (double)vp8_dc_quant(cm->base_qindex, 0) / 4.0,
+ vp8_convert_qindex_to_q(cpi->active_best_quality),
+ vp8_convert_qindex_to_q(cpi->active_worst_quality),
+ cpi->avg_q,
+ vp8_convert_qindex_to_q(cpi->ni_av_qi),
+ vp8_convert_qindex_to_q(cpi->cq_target_quality),
+ cpi->zbin_over_quant,
+ // cpi->avg_frame_qindex, cpi->zbin_over_quant,
+ cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
+ cm->frame_type, cpi->gfu_boost,
+ cpi->twopass.est_max_qcorrection_factor,
+ (int)cpi->twopass.bits_left,
+ cpi->twopass.total_left_stats->coded_error,
+ cpi->tot_recode_hits, recon_err, cpi->kf_boost,
+ cpi->kf_zeromotion_pct);
+
+ fclose(f);
+
+ if (0) {
+ FILE *fmodes = fopen("Modes.stt", "a");
+ int i;
+
+ fprintf(fmodes, "%6d:%1d:%1d:%1d ",
+ cpi->common.current_video_frame,
+ cm->frame_type, cm->refresh_golden_frame,
+ cm->refresh_alt_ref_frame);
+
+ for (i = 0; i < MAX_MODES; i++)
+ fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]);
+
+ fprintf(fmodes, "\n");
+
+ fclose(fmodes);
+ }
+ }
#endif
#if 0
- // Debug stats for segment feature experiments.
- print_seg_map(cpi);
+ // Debug stats for segment feature experiments.
+ print_seg_map(cpi);
#endif
- // If this was a kf or Gf note the Q
- if ((cm->frame_type == KEY_FRAME) || cm->refresh_golden_frame || cm->refresh_alt_ref_frame)
- cm->last_kf_gf_q = cm->base_qindex;
+ // If this was a kf or Gf note the Q
+ if ((cm->frame_type == KEY_FRAME) || cm->refresh_golden_frame || cm->refresh_alt_ref_frame)
+ cm->last_kf_gf_q = cm->base_qindex;
- if (cm->refresh_golden_frame == 1)
- cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN;
- else
- cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_GOLDEN;
+ if (cm->refresh_golden_frame == 1)
+ cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN;
+ else
+ cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_GOLDEN;
- if (cm->refresh_alt_ref_frame == 1)
- cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF;
- else
- cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_ALTREF;
+ if (cm->refresh_alt_ref_frame == 1)
+ cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF;
+ else
+ cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_ALTREF;
- if (cm->refresh_last_frame & cm->refresh_golden_frame) // both refreshed
- cpi->gold_is_last = 1;
- else if (cm->refresh_last_frame ^ cm->refresh_golden_frame) // 1 refreshed but not the other
- cpi->gold_is_last = 0;
+ if (cm->refresh_last_frame & cm->refresh_golden_frame) // both refreshed
+ cpi->gold_is_last = 1;
+ else if (cm->refresh_last_frame ^ cm->refresh_golden_frame) // 1 refreshed but not the other
+ cpi->gold_is_last = 0;
- if (cm->refresh_last_frame & cm->refresh_alt_ref_frame) // both refreshed
- cpi->alt_is_last = 1;
- else if (cm->refresh_last_frame ^ cm->refresh_alt_ref_frame) // 1 refreshed but not the other
- cpi->alt_is_last = 0;
+ if (cm->refresh_last_frame & cm->refresh_alt_ref_frame) // both refreshed
+ cpi->alt_is_last = 1;
+ else if (cm->refresh_last_frame ^ cm->refresh_alt_ref_frame) // 1 refreshed but not the other
+ cpi->alt_is_last = 0;
- if (cm->refresh_alt_ref_frame & cm->refresh_golden_frame) // both refreshed
- cpi->gold_is_alt = 1;
- else if (cm->refresh_alt_ref_frame ^ cm->refresh_golden_frame) // 1 refreshed but not the other
- cpi->gold_is_alt = 0;
+ if (cm->refresh_alt_ref_frame & cm->refresh_golden_frame) // both refreshed
+ cpi->gold_is_alt = 1;
+ else if (cm->refresh_alt_ref_frame ^ cm->refresh_golden_frame) // 1 refreshed but not the other
+ cpi->gold_is_alt = 0;
- cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
+ cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
- if (cpi->gold_is_last)
- cpi->ref_frame_flags &= ~VP8_GOLD_FLAG;
+ if (cpi->gold_is_last)
+ cpi->ref_frame_flags &= ~VP8_GOLD_FLAG;
- if (cpi->alt_is_last)
- cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
+ if (cpi->alt_is_last)
+ cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
- if (cpi->gold_is_alt)
- cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
+ if (cpi->gold_is_alt)
+ cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
- if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME))
- // Update the alternate reference frame stats as appropriate.
- update_alt_ref_frame_stats(cpi);
- else
- // Update the Golden frame stats as appropriate.
- update_golden_frame_stats(cpi);
+ if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME))
+ // Update the alternate reference frame stats as appropriate.
+ update_alt_ref_frame_stats(cpi);
+ else
+ // Update the Golden frame stats as appropriate.
+ update_golden_frame_stats(cpi);
- if (cm->frame_type == KEY_FRAME)
- {
- // Tell the caller that the frame was coded as a key frame
- *frame_flags = cm->frame_flags | FRAMEFLAGS_KEY;
+ if (cm->frame_type == KEY_FRAME) {
+ // Tell the caller that the frame was coded as a key frame
+ *frame_flags = cm->frame_flags | FRAMEFLAGS_KEY;
- // As this frame is a key frame the next defaults to an inter frame.
- cm->frame_type = INTER_FRAME;
- }
- else
- {
- *frame_flags = cm->frame_flags&~FRAMEFLAGS_KEY;
- }
+ // As this frame is a key frame the next defaults to an inter frame.
+ cm->frame_type = INTER_FRAME;
+ } else {
+ *frame_flags = cm->frame_flags&~FRAMEFLAGS_KEY;
+ }
- // Clear the one shot update flags for segmentation map and mode/ref loop filter deltas.
- xd->update_mb_segmentation_map = 0;
- xd->update_mb_segmentation_data = 0;
- xd->mode_ref_lf_delta_update = 0;
+ // Clear the one shot update flags for segmentation map and mode/ref loop filter deltas.
+ xd->update_mb_segmentation_map = 0;
+ xd->update_mb_segmentation_data = 0;
+ xd->mode_ref_lf_delta_update = 0;
- // Dont increment frame counters if this was an altref buffer update not a real frame
- if (cm->show_frame)
- {
- cm->current_video_frame++;
- cpi->frames_since_key++;
- }
+ // Dont increment frame counters if this was an altref buffer update not a real frame
+ if (cm->show_frame) {
+ cm->current_video_frame++;
+ cpi->frames_since_key++;
+ }
- // reset to normal state now that we are done.
+ // reset to normal state now that we are done.
#if 0
- {
- char filename[512];
- FILE *recon_file;
- sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
- recon_file = fopen(filename, "wb");
- fwrite(cm->yv12_fb[cm->lst_fb_idx].buffer_alloc,
- cm->yv12_fb[cm->lst_fb_idx].frame_size, 1, recon_file);
- fclose(recon_file);
- }
+ {
+ char filename[512];
+ FILE *recon_file;
+ sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
+ recon_file = fopen(filename, "wb");
+ fwrite(cm->yv12_fb[cm->lst_fb_idx].buffer_alloc,
+ cm->yv12_fb[cm->lst_fb_idx].frame_size, 1, recon_file);
+ fclose(recon_file);
+ }
#endif
#ifdef OUTPUT_YUV_REC
- vp8_write_yuv_rec_frame(cm);
+ vp8_write_yuv_rec_frame(cm);
#endif
- if(cm->show_frame)
- {
- vpx_memcpy(cm->prev_mip, cm->mip,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
- }
- else
- {
- vpx_memset(cm->prev_mip, 0,
- (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
- }
+ if (cm->show_frame) {
+ vpx_memcpy(cm->prev_mip, cm->mip,
+ (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
+ } else {
+ vpx_memset(cm->prev_mip, 0,
+ (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
+ }
}
-static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned int *frame_flags)
-{
+static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned int *frame_flags) {
- if (!cpi->common.refresh_alt_ref_frame)
- vp8_second_pass(cpi);
+ if (!cpi->common.refresh_alt_ref_frame)
+ vp8_second_pass(cpi);
- encode_frame_to_data_rate(cpi, size, dest, frame_flags);
- cpi->twopass.bits_left -= 8 * *size;
+ encode_frame_to_data_rate(cpi, size, dest, frame_flags);
+ cpi->twopass.bits_left -= 8 * *size;
- if (!cpi->common.refresh_alt_ref_frame)
- {
- double lower_bounds_min_rate = FRAME_OVERHEAD_BITS*cpi->oxcf.frame_rate;
- double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
- *cpi->oxcf.two_pass_vbrmin_section / 100);
+ if (!cpi->common.refresh_alt_ref_frame) {
+ double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.frame_rate;
+ double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
+ * cpi->oxcf.two_pass_vbrmin_section / 100);
- if (two_pass_min_rate < lower_bounds_min_rate)
- two_pass_min_rate = lower_bounds_min_rate;
+ if (two_pass_min_rate < lower_bounds_min_rate)
+ two_pass_min_rate = lower_bounds_min_rate;
- cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.frame_rate);
- }
+ cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.frame_rate);
+ }
}
-//For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us.
+// For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us.
#if HAVE_ARMV7
extern void vp8_push_neon(int64_t *store);
extern void vp8_pop_neon(int64_t *store);
#endif
-int vp8_receive_raw_frame(VP8_PTR ptr, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time)
-{
+int vp8_receive_raw_frame(VP8_PTR ptr, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time) {
#if HAVE_ARMV7
- int64_t store_reg[8];
+ int64_t store_reg[8];
#endif
- VP8_COMP *cpi = (VP8_COMP *) ptr;
- VP8_COMMON *cm = &cpi->common;
- struct vpx_usec_timer timer;
- int res = 0;
+ VP8_COMP *cpi = (VP8_COMP *) ptr;
+ VP8_COMMON *cm = &cpi->common;
+ struct vpx_usec_timer timer;
+ int res = 0;
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_push_neon(store_reg);
- }
+ {
+ vp8_push_neon(store_reg);
+ }
#endif
- vpx_usec_timer_start(&timer);
- if(vp8_lookahead_push(cpi->lookahead, sd, time_stamp, end_time,
- frame_flags, cpi->active_map_enabled ? cpi->active_map : NULL))
- res = -1;
- cm->clr_type = sd->clrtype;
- vpx_usec_timer_mark(&timer);
- cpi->time_receive_data += vpx_usec_timer_elapsed(&timer);
+ vpx_usec_timer_start(&timer);
+ if (vp8_lookahead_push(cpi->lookahead, sd, time_stamp, end_time,
+ frame_flags, cpi->active_map_enabled ? cpi->active_map : NULL))
+ res = -1;
+ cm->clr_type = sd->clrtype;
+ vpx_usec_timer_mark(&timer);
+ cpi->time_receive_data += vpx_usec_timer_elapsed(&timer);
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_pop_neon(store_reg);
- }
+ {
+ vp8_pop_neon(store_reg);
+ }
#endif
- return res;
+ return res;
}
-static int frame_is_reference(const VP8_COMP *cpi)
-{
- const VP8_COMMON *cm = &cpi->common;
- const MACROBLOCKD *xd = &cpi->mb.e_mbd;
+static int frame_is_reference(const VP8_COMP *cpi) {
+ const VP8_COMMON *cm = &cpi->common;
+ const MACROBLOCKD *xd = &cpi->mb.e_mbd;
- return cm->frame_type == KEY_FRAME || cm->refresh_last_frame
- || cm->refresh_golden_frame || cm->refresh_alt_ref_frame
- || cm->copy_buffer_to_gf || cm->copy_buffer_to_arf
- || cm->refresh_entropy_probs
- || xd->mode_ref_lf_delta_update
- || xd->update_mb_segmentation_map || xd->update_mb_segmentation_data;
+ return cm->frame_type == KEY_FRAME || cm->refresh_last_frame
+ || cm->refresh_golden_frame || cm->refresh_alt_ref_frame
+ || cm->copy_buffer_to_gf || cm->copy_buffer_to_arf
+ || cm->refresh_entropy_probs
+ || xd->mode_ref_lf_delta_update
+ || xd->update_mb_segmentation_map || xd->update_mb_segmentation_data;
}
-int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush)
-{
+int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush) {
#if HAVE_ARMV7
- int64_t store_reg[8];
+ int64_t store_reg[8];
#endif
- VP8_COMP *cpi = (VP8_COMP *) ptr;
- VP8_COMMON *cm = &cpi->common;
- struct vpx_usec_timer cmptimer;
- YV12_BUFFER_CONFIG *force_src_buffer = NULL;
+ VP8_COMP *cpi = (VP8_COMP *) ptr;
+ VP8_COMMON *cm = &cpi->common;
+ struct vpx_usec_timer cmptimer;
+ YV12_BUFFER_CONFIG *force_src_buffer = NULL;
- if (!cpi)
- return -1;
+ if (!cpi)
+ return -1;
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_push_neon(store_reg);
- }
+ {
+ vp8_push_neon(store_reg);
+ }
#endif
- vpx_usec_timer_start(&cmptimer);
+ vpx_usec_timer_start(&cmptimer);
- cpi->source = NULL;
+ cpi->source = NULL;
#if CONFIG_HIGH_PRECISION_MV
- cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
+ cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
#endif
- // Should we code an alternate reference frame
- if (cpi->oxcf.play_alternate &&
- cpi->source_alt_ref_pending)
- {
- if ((cpi->source = vp8_lookahead_peek(cpi->lookahead,
- cpi->frames_till_gf_update_due)))
- {
- cpi->alt_ref_source = cpi->source;
- if (cpi->oxcf.arnr_max_frames > 0)
- {
- vp8_temporal_filter_prepare_c(cpi,
- cpi->frames_till_gf_update_due);
- force_src_buffer = &cpi->alt_ref_buffer;
- }
- cm->frames_till_alt_ref_frame = cpi->frames_till_gf_update_due;
- cm->refresh_alt_ref_frame = 1;
- cm->refresh_golden_frame = 0;
- cm->refresh_last_frame = 0;
- cm->show_frame = 0;
- cpi->source_alt_ref_pending = FALSE; // Clear Pending altf Ref flag.
- cpi->is_src_frame_alt_ref = 0;
- }
- }
-
- if (!cpi->source)
- {
- if ((cpi->source = vp8_lookahead_pop(cpi->lookahead, flush)))
- {
- cm->show_frame = 1;
-
- cpi->is_src_frame_alt_ref = cpi->alt_ref_source
- && (cpi->source == cpi->alt_ref_source);
-
- if(cpi->is_src_frame_alt_ref)
- cpi->alt_ref_source = NULL;
- }
- }
-
- if (cpi->source)
- {
- cpi->un_scaled_source =
- cpi->Source = force_src_buffer ? force_src_buffer : &cpi->source->img;
- *time_stamp = cpi->source->ts_start;
- *time_end = cpi->source->ts_end;
- *frame_flags = cpi->source->flags;
+ // Should we code an alternate reference frame
+ if (cpi->oxcf.play_alternate &&
+ cpi->source_alt_ref_pending) {
+ if ((cpi->source = vp8_lookahead_peek(cpi->lookahead,
+ cpi->frames_till_gf_update_due))) {
+ cpi->alt_ref_source = cpi->source;
+ if (cpi->oxcf.arnr_max_frames > 0) {
+ vp8_temporal_filter_prepare_c(cpi,
+ cpi->frames_till_gf_update_due);
+ force_src_buffer = &cpi->alt_ref_buffer;
+ }
+ cm->frames_till_alt_ref_frame = cpi->frames_till_gf_update_due;
+ cm->refresh_alt_ref_frame = 1;
+ cm->refresh_golden_frame = 0;
+ cm->refresh_last_frame = 0;
+ cm->show_frame = 0;
+ cpi->source_alt_ref_pending = FALSE; // Clear Pending altf Ref flag.
+ cpi->is_src_frame_alt_ref = 0;
+ }
+ }
+
+ if (!cpi->source) {
+ if ((cpi->source = vp8_lookahead_pop(cpi->lookahead, flush))) {
+ cm->show_frame = 1;
+
+ cpi->is_src_frame_alt_ref = cpi->alt_ref_source
+ && (cpi->source == cpi->alt_ref_source);
+
+ if (cpi->is_src_frame_alt_ref)
+ cpi->alt_ref_source = NULL;
+ }
+ }
+
+ if (cpi->source) {
+ cpi->un_scaled_source =
+ cpi->Source = force_src_buffer ? force_src_buffer : &cpi->source->img;
+ *time_stamp = cpi->source->ts_start;
+ *time_end = cpi->source->ts_end;
+ *frame_flags = cpi->source->flags;
+ } else {
+ *size = 0;
+ if (flush && cpi->pass == 1 && !cpi->twopass.first_pass_done) {
+ vp8_end_first_pass(cpi); /* get last stats packet */
+ cpi->twopass.first_pass_done = 1;
}
- else
- {
- *size = 0;
- if (flush && cpi->pass == 1 && !cpi->twopass.first_pass_done)
- {
- vp8_end_first_pass(cpi); /* get last stats packet */
- cpi->twopass.first_pass_done = 1;
- }
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_pop_neon(store_reg);
- }
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- return -1;
- }
-
- if (cpi->source->ts_start < cpi->first_time_stamp_ever)
{
- cpi->first_time_stamp_ever = cpi->source->ts_start;
- cpi->last_end_time_stamp_seen = cpi->source->ts_start;
+ vp8_pop_neon(store_reg);
}
+#endif
+ return -1;
+ }
- // adjust frame rates based on timestamps given
- if (!cm->refresh_alt_ref_frame)
- {
- int64_t this_duration;
- int step = 0;
+ if (cpi->source->ts_start < cpi->first_time_stamp_ever) {
+ cpi->first_time_stamp_ever = cpi->source->ts_start;
+ cpi->last_end_time_stamp_seen = cpi->source->ts_start;
+ }
- if (cpi->source->ts_start == cpi->first_time_stamp_ever)
- {
- this_duration = cpi->source->ts_end - cpi->source->ts_start;
- step = 1;
- }
- else
- {
- int64_t last_duration;
-
- this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen;
- last_duration = cpi->last_end_time_stamp_seen
- - cpi->last_time_stamp_seen;
- // do a step update if the duration changes by 10%
- if (last_duration)
- step = ((this_duration - last_duration) * 10 / last_duration);
- }
+ // adjust frame rates based on timestamps given
+ if (!cm->refresh_alt_ref_frame) {
+ int64_t this_duration;
+ int step = 0;
- if (this_duration)
- {
- if (step)
- vp8_new_frame_rate(cpi, 10000000.0 / this_duration);
- else
- {
- double avg_duration, interval;
+ if (cpi->source->ts_start == cpi->first_time_stamp_ever) {
+ this_duration = cpi->source->ts_end - cpi->source->ts_start;
+ step = 1;
+ } else {
+ int64_t last_duration;
- /* Average this frame's rate into the last second's average
- * frame rate. If we haven't seen 1 second yet, then average
- * over the whole interval seen.
- */
- interval = cpi->source->ts_end - cpi->first_time_stamp_ever;
- if(interval > 10000000.0)
- interval = 10000000;
+ this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen;
+ last_duration = cpi->last_end_time_stamp_seen
+ - cpi->last_time_stamp_seen;
+ // do a step update if the duration changes by 10%
+ if (last_duration)
+ step = ((this_duration - last_duration) * 10 / last_duration);
+ }
- avg_duration = 10000000.0 / cpi->oxcf.frame_rate;
- avg_duration *= (interval - avg_duration + this_duration);
- avg_duration /= interval;
+ if (this_duration) {
+ if (step)
+ vp8_new_frame_rate(cpi, 10000000.0 / this_duration);
+ else {
+ double avg_duration, interval;
- vp8_new_frame_rate(cpi, 10000000.0 / avg_duration);
- }
- }
+ /* Average this frame's rate into the last second's average
+ * frame rate. If we haven't seen 1 second yet, then average
+ * over the whole interval seen.
+ */
+ interval = cpi->source->ts_end - cpi->first_time_stamp_ever;
+ if (interval > 10000000.0)
+ interval = 10000000;
- cpi->last_time_stamp_seen = cpi->source->ts_start;
- cpi->last_end_time_stamp_seen = cpi->source->ts_end;
+ avg_duration = 10000000.0 / cpi->oxcf.frame_rate;
+ avg_duration *= (interval - avg_duration + this_duration);
+ avg_duration /= interval;
+
+ vp8_new_frame_rate(cpi, 10000000.0 / avg_duration);
+ }
}
- // start with a 0 size frame
- *size = 0;
+ cpi->last_time_stamp_seen = cpi->source->ts_start;
+ cpi->last_end_time_stamp_seen = cpi->source->ts_end;
+ }
- // Clear down mmx registers
- vp8_clear_system_state(); //__asm emms;
+ // start with a 0 size frame
+ *size = 0;
- cm->frame_type = INTER_FRAME;
- cm->frame_flags = *frame_flags;
+ // Clear down mmx registers
+ vp8_clear_system_state(); // __asm emms;
+
+ cm->frame_type = INTER_FRAME;
+ cm->frame_flags = *frame_flags;
#if 0
- if (cm->refresh_alt_ref_frame)
- {
- //cm->refresh_golden_frame = 1;
- cm->refresh_golden_frame = 0;
- cm->refresh_last_frame = 0;
- }
- else
- {
- cm->refresh_golden_frame = 0;
- cm->refresh_last_frame = 1;
- }
+ if (cm->refresh_alt_ref_frame) {
+ // cm->refresh_golden_frame = 1;
+ cm->refresh_golden_frame = 0;
+ cm->refresh_last_frame = 0;
+ } else {
+ cm->refresh_golden_frame = 0;
+ cm->refresh_last_frame = 1;
+ }
#endif
- /* find a free buffer for the new frame */
- {
- int i = 0;
- for(; i < NUM_YV12_BUFFERS; i++)
- {
- if(!cm->yv12_fb[i].flags)
- {
- cm->new_fb_idx = i;
- break;
- }
- }
-
- assert(i < NUM_YV12_BUFFERS );
- }
- if (cpi->pass == 1)
- {
- Pass1Encode(cpi, size, dest, frame_flags);
- }
- else if (cpi->pass == 2)
- {
- Pass2Encode(cpi, size, dest, frame_flags);
+ /* find a free buffer for the new frame */
+ {
+ int i = 0;
+ for (; i < NUM_YV12_BUFFERS; i++) {
+ if (!cm->yv12_fb[i].flags) {
+ cm->new_fb_idx = i;
+ break;
+ }
}
- else
- encode_frame_to_data_rate(cpi, size, dest, frame_flags);
- if(cm->refresh_entropy_probs)
- {
- if(cm->refresh_alt_ref_frame)
- vpx_memcpy(&cm->lfc_a, &cm->fc, sizeof(cm->fc));
- else
- vpx_memcpy(&cm->lfc, &cm->fc, sizeof(cm->fc));
- }
+ assert(i < NUM_YV12_BUFFERS);
+ }
+ if (cpi->pass == 1) {
+ Pass1Encode(cpi, size, dest, frame_flags);
+ } else if (cpi->pass == 2) {
+ Pass2Encode(cpi, size, dest, frame_flags);
+ } else
+ encode_frame_to_data_rate(cpi, size, dest, frame_flags);
- // if its a dropped frame honor the requests on subsequent frames
- if (*size > 0)
- {
- cpi->droppable = !frame_is_reference(cpi);
+ if (cm->refresh_entropy_probs) {
+ if (cm->refresh_alt_ref_frame)
+ vpx_memcpy(&cm->lfc_a, &cm->fc, sizeof(cm->fc));
+ else
+ vpx_memcpy(&cm->lfc, &cm->fc, sizeof(cm->fc));
+ }
- // return to normal state
- cm->refresh_entropy_probs = 1;
- cm->refresh_alt_ref_frame = 0;
- cm->refresh_golden_frame = 0;
- cm->refresh_last_frame = 1;
- cm->frame_type = INTER_FRAME;
+ // if its a dropped frame honor the requests on subsequent frames
+ if (*size > 0) {
+ cpi->droppable = !frame_is_reference(cpi);
- }
+ // return to normal state
+ cm->refresh_entropy_probs = 1;
+ cm->refresh_alt_ref_frame = 0;
+ cm->refresh_golden_frame = 0;
+ cm->refresh_last_frame = 1;
+ cm->frame_type = INTER_FRAME;
- vpx_usec_timer_mark(&cmptimer);
- cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);
+ }
- if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame)
- {
- generate_psnr_packet(cpi);
- }
+ vpx_usec_timer_mark(&cmptimer);
+ cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);
+
+ if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) {
+ generate_psnr_packet(cpi);
+ }
#if CONFIG_INTERNAL_STATS
- if (cpi->pass != 1)
- {
- cpi->bytes += *size;
+ if (cpi->pass != 1) {
+ cpi->bytes += *size;
- if (cm->show_frame)
- {
+ if (cm->show_frame) {
- cpi->count ++;
+ cpi->count++;
- if (cpi->b_calculate_psnr)
- {
- double ye,ue,ve;
- double frame_psnr;
- YV12_BUFFER_CONFIG *orig = cpi->Source;
- YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show;
- YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer;
- int y_samples = orig->y_height * orig->y_width ;
- int uv_samples = orig->uv_height * orig->uv_width ;
- int t_samples = y_samples + 2 * uv_samples;
- int64_t sq_error;
-
- ye = calc_plane_error(orig->y_buffer, orig->y_stride,
- recon->y_buffer, recon->y_stride, orig->y_width, orig->y_height,
- IF_RTCD(&cpi->rtcd.variance));
-
- ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
- recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_height,
- IF_RTCD(&cpi->rtcd.variance));
-
- ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
- recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_height,
- IF_RTCD(&cpi->rtcd.variance));
-
- sq_error = ye + ue + ve;
-
- frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error);
-
- cpi->total_y += vp8_mse2psnr(y_samples, 255.0, ye);
- cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, ue);
- cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, ve);
- cpi->total_sq_error += sq_error;
- cpi->total += frame_psnr;
- {
- double frame_psnr2, frame_ssim2 = 0;
- double weight = 0;
+ if (cpi->b_calculate_psnr) {
+ double ye, ue, ve;
+ double frame_psnr;
+ YV12_BUFFER_CONFIG *orig = cpi->Source;
+ YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show;
+ YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer;
+ int y_samples = orig->y_height * orig->y_width;
+ int uv_samples = orig->uv_height * orig->uv_width;
+ int t_samples = y_samples + 2 * uv_samples;
+ int64_t sq_error;
+
+ ye = calc_plane_error(orig->y_buffer, orig->y_stride,
+ recon->y_buffer, recon->y_stride, orig->y_width, orig->y_height,
+ IF_RTCD(&cpi->rtcd.variance));
- vp8_deblock(cm->frame_to_show, &cm->post_proc_buffer, cm->filter_level * 10 / 6, 1, 0, IF_RTCD(&cm->rtcd.postproc));
- vp8_clear_system_state();
+ ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
+ recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_height,
+ IF_RTCD(&cpi->rtcd.variance));
- ye = calc_plane_error(orig->y_buffer, orig->y_stride,
- pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height,
- IF_RTCD(&cpi->rtcd.variance));
+ ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
+ recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_height,
+ IF_RTCD(&cpi->rtcd.variance));
- ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
- pp->u_buffer, pp->uv_stride, orig->uv_width, orig->uv_height,
- IF_RTCD(&cpi->rtcd.variance));
+ sq_error = ye + ue + ve;
- ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
- pp->v_buffer, pp->uv_stride, orig->uv_width, orig->uv_height,
- IF_RTCD(&cpi->rtcd.variance));
+ frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error);
- sq_error = ye + ue + ve;
+ cpi->total_y += vp8_mse2psnr(y_samples, 255.0, ye);
+ cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, ue);
+ cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, ve);
+ cpi->total_sq_error += sq_error;
+ cpi->total += frame_psnr;
+ {
+ double frame_psnr2, frame_ssim2 = 0;
+ double weight = 0;
- frame_psnr2 = vp8_mse2psnr(t_samples, 255.0, sq_error);
+ vp8_deblock(cm->frame_to_show, &cm->post_proc_buffer, cm->filter_level * 10 / 6, 1, 0, IF_RTCD(&cm->rtcd.postproc));
+ vp8_clear_system_state();
- cpi->totalp_y += vp8_mse2psnr(y_samples, 255.0, ye);
- cpi->totalp_u += vp8_mse2psnr(uv_samples, 255.0, ue);
- cpi->totalp_v += vp8_mse2psnr(uv_samples, 255.0, ve);
- cpi->total_sq_error2 += sq_error;
- cpi->totalp += frame_psnr2;
+ ye = calc_plane_error(orig->y_buffer, orig->y_stride,
+ pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height,
+ IF_RTCD(&cpi->rtcd.variance));
- frame_ssim2 = vp8_calc_ssim(cpi->Source,
- &cm->post_proc_buffer, 1, &weight,
- IF_RTCD(&cpi->rtcd.variance));
+ ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
+ pp->u_buffer, pp->uv_stride, orig->uv_width, orig->uv_height,
+ IF_RTCD(&cpi->rtcd.variance));
- cpi->summed_quality += frame_ssim2 * weight;
- cpi->summed_weights += weight;
+ ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
+ pp->v_buffer, pp->uv_stride, orig->uv_width, orig->uv_height,
+ IF_RTCD(&cpi->rtcd.variance));
+
+ sq_error = ye + ue + ve;
+
+ frame_psnr2 = vp8_mse2psnr(t_samples, 255.0, sq_error);
+
+ cpi->totalp_y += vp8_mse2psnr(y_samples, 255.0, ye);
+ cpi->totalp_u += vp8_mse2psnr(uv_samples, 255.0, ue);
+ cpi->totalp_v += vp8_mse2psnr(uv_samples, 255.0, ve);
+ cpi->total_sq_error2 += sq_error;
+ cpi->totalp += frame_psnr2;
+
+ frame_ssim2 = vp8_calc_ssim(cpi->Source,
+ &cm->post_proc_buffer, 1, &weight,
+ IF_RTCD(&cpi->rtcd.variance));
+
+ cpi->summed_quality += frame_ssim2 * weight;
+ cpi->summed_weights += weight;
#if 0
- {
- FILE *f = fopen("q_used.stt", "a");
- fprintf(f, "%5d : Y%f7.3:U%f7.3:V%f7.3:F%f7.3:S%7.3f\n",
- cpi->common.current_video_frame,y2, u2, v2,
- frame_psnr2, frame_ssim2);
- fclose(f);
- }
+ {
+ FILE *f = fopen("q_used.stt", "a");
+ fprintf(f, "%5d : Y%f7.3:U%f7.3:V%f7.3:F%f7.3:S%7.3f\n",
+ cpi->common.current_video_frame, y2, u2, v2,
+ frame_psnr2, frame_ssim2);
+ fclose(f);
+ }
#endif
- }
- }
+ }
+ }
- if (cpi->b_calculate_ssimg)
- {
- double y, u, v, frame_all;
- frame_all = vp8_calc_ssimg(cpi->Source, cm->frame_to_show,
- &y, &u, &v, IF_RTCD(&cpi->rtcd.variance));
- cpi->total_ssimg_y += y;
- cpi->total_ssimg_u += u;
- cpi->total_ssimg_v += v;
- cpi->total_ssimg_all += frame_all;
- }
+ if (cpi->b_calculate_ssimg) {
+ double y, u, v, frame_all;
+ frame_all = vp8_calc_ssimg(cpi->Source, cm->frame_to_show,
+ &y, &u, &v, IF_RTCD(&cpi->rtcd.variance));
+ cpi->total_ssimg_y += y;
+ cpi->total_ssimg_u += u;
+ cpi->total_ssimg_v += v;
+ cpi->total_ssimg_all += frame_all;
+ }
- }
}
+ }
#endif
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_pop_neon(store_reg);
- }
+ {
+ vp8_pop_neon(store_reg);
+ }
#endif
- return 0;
+ return 0;
}
-int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags)
-{
- VP8_COMP *cpi = (VP8_COMP *) comp;
+int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags) {
+ VP8_COMP *cpi = (VP8_COMP *) comp;
- if (cpi->common.refresh_alt_ref_frame)
- return -1;
- else
- {
- int ret;
+ if (cpi->common.refresh_alt_ref_frame)
+ return -1;
+ else {
+ int ret;
#if CONFIG_POSTPROC
- ret = vp8_post_proc_frame(&cpi->common, dest, flags);
+ ret = vp8_post_proc_frame(&cpi->common, dest, flags);
#else
- if (cpi->common.frame_to_show)
- {
- *dest = *cpi->common.frame_to_show;
- dest->y_width = cpi->common.Width;
- dest->y_height = cpi->common.Height;
- dest->uv_height = cpi->common.Height / 2;
- ret = 0;
- }
- else
- {
- ret = -1;
- }
-
-#endif //!CONFIG_POSTPROC
- vp8_clear_system_state();
- return ret;
- }
-}
-
-int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4])
-{
- VP8_COMP *cpi = (VP8_COMP *) comp;
- signed char feature_data[SEG_LVL_MAX][MAX_MB_SEGMENTS];
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- int i;
-
- if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols)
- return -1;
-
- if (!map)
- {
- vp8_disable_segmentation((VP8_PTR)cpi);
- return 0;
+ if (cpi->common.frame_to_show) {
+ *dest = *cpi->common.frame_to_show;
+ dest->y_width = cpi->common.Width;
+ dest->y_height = cpi->common.Height;
+ dest->uv_height = cpi->common.Height / 2;
+ ret = 0;
+ } else {
+ ret = -1;
}
- // Set the segmentation Map
- vp8_set_segmentation_map((VP8_PTR)cpi, map);
-
- // Activate segmentation.
- vp8_enable_segmentation((VP8_PTR)cpi);
+#endif // !CONFIG_POSTPROC
+ vp8_clear_system_state();
+ return ret;
+ }
+}
- // Set up the quant segment data
- feature_data[SEG_LVL_ALT_Q][0] = delta_q[0];
- feature_data[SEG_LVL_ALT_Q][1] = delta_q[1];
- feature_data[SEG_LVL_ALT_Q][2] = delta_q[2];
- feature_data[SEG_LVL_ALT_Q][3] = delta_q[3];
+int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]) {
+ VP8_COMP *cpi = (VP8_COMP *) comp;
+ signed char feature_data[SEG_LVL_MAX][MAX_MB_SEGMENTS];
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ int i;
- // Set up the loop segment data s
- feature_data[SEG_LVL_ALT_LF][0] = delta_lf[0];
- feature_data[SEG_LVL_ALT_LF][1] = delta_lf[1];
- feature_data[SEG_LVL_ALT_LF][2] = delta_lf[2];
- feature_data[SEG_LVL_ALT_LF][3] = delta_lf[3];
+ if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols)
+ return -1;
- cpi->segment_encode_breakout[0] = threshold[0];
- cpi->segment_encode_breakout[1] = threshold[1];
- cpi->segment_encode_breakout[2] = threshold[2];
- cpi->segment_encode_breakout[3] = threshold[3];
+ if (!map) {
+ vp8_disable_segmentation((VP8_PTR)cpi);
+ return 0;
+ }
+
+ // Set the segmentation Map
+ vp8_set_segmentation_map((VP8_PTR)cpi, map);
+
+ // Activate segmentation.
+ vp8_enable_segmentation((VP8_PTR)cpi);
+
+ // Set up the quant segment data
+ feature_data[SEG_LVL_ALT_Q][0] = delta_q[0];
+ feature_data[SEG_LVL_ALT_Q][1] = delta_q[1];
+ feature_data[SEG_LVL_ALT_Q][2] = delta_q[2];
+ feature_data[SEG_LVL_ALT_Q][3] = delta_q[3];
+
+ // Set up the loop segment data s
+ feature_data[SEG_LVL_ALT_LF][0] = delta_lf[0];
+ feature_data[SEG_LVL_ALT_LF][1] = delta_lf[1];
+ feature_data[SEG_LVL_ALT_LF][2] = delta_lf[2];
+ feature_data[SEG_LVL_ALT_LF][3] = delta_lf[3];
+
+ cpi->segment_encode_breakout[0] = threshold[0];
+ cpi->segment_encode_breakout[1] = threshold[1];
+ cpi->segment_encode_breakout[2] = threshold[2];
+ cpi->segment_encode_breakout[3] = threshold[3];
+
+ // Enable the loop and quant changes in the feature mask
+ for (i = 0; i < 4; i++) {
+ if (delta_q[i])
+ enable_segfeature(xd, i, SEG_LVL_ALT_Q);
+ else
+ disable_segfeature(xd, i, SEG_LVL_ALT_Q);
- // Enable the loop and quant changes in the feature mask
- for ( i = 0; i < 4; i++ )
- {
- if (delta_q[i])
- enable_segfeature(xd, i, SEG_LVL_ALT_Q);
- else
- disable_segfeature(xd, i, SEG_LVL_ALT_Q);
-
- if (delta_lf[i])
- enable_segfeature(xd, i, SEG_LVL_ALT_LF);
- else
- disable_segfeature(xd, i, SEG_LVL_ALT_LF);
- }
+ if (delta_lf[i])
+ enable_segfeature(xd, i, SEG_LVL_ALT_LF);
+ else
+ disable_segfeature(xd, i, SEG_LVL_ALT_LF);
+ }
- // Initialise the feature data structure
- // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1
- vp8_set_segment_data((VP8_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA);
+ // Initialise the feature data structure
+ // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1
+ vp8_set_segment_data((VP8_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA);
- return 0;
+ return 0;
}
-int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols)
-{
- VP8_COMP *cpi = (VP8_COMP *) comp;
+int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols) {
+ VP8_COMP *cpi = (VP8_COMP *) comp;
- if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols)
- {
- if (map)
- {
- vpx_memcpy(cpi->active_map, map, rows * cols);
- cpi->active_map_enabled = 1;
- }
- else
- cpi->active_map_enabled = 0;
+ if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols) {
+ if (map) {
+ vpx_memcpy(cpi->active_map, map, rows * cols);
+ cpi->active_map_enabled = 1;
+ } else
+ cpi->active_map_enabled = 0;
- return 0;
- }
- else
- {
- //cpi->active_map_enabled = 0;
- return -1 ;
- }
+ return 0;
+ } else {
+ // cpi->active_map_enabled = 0;
+ return -1;
+ }
}
-int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode)
-{
- VP8_COMP *cpi = (VP8_COMP *) comp;
+int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode) {
+ VP8_COMP *cpi = (VP8_COMP *) comp;
- if (horiz_mode <= ONETWO)
- cpi->common.horiz_scale = horiz_mode;
- else
- return -1;
+ if (horiz_mode <= ONETWO)
+ cpi->common.horiz_scale = horiz_mode;
+ else
+ return -1;
- if (vert_mode <= ONETWO)
- cpi->common.vert_scale = vert_mode;
- else
- return -1;
+ if (vert_mode <= ONETWO)
+ cpi->common.vert_scale = vert_mode;
+ else
+ return -1;
- return 0;
+ return 0;
}
-int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const vp8_variance_rtcd_vtable_t *rtcd)
-{
- int i, j;
- int Total = 0;
+int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const vp8_variance_rtcd_vtable_t *rtcd) {
+ int i, j;
+ int Total = 0;
- unsigned char *src = source->y_buffer;
- unsigned char *dst = dest->y_buffer;
- (void)rtcd;
+ unsigned char *src = source->y_buffer;
+ unsigned char *dst = dest->y_buffer;
+ (void)rtcd;
- // Loop through the Y plane raw and reconstruction data summing (square differences)
- for (i = 0; i < source->y_height; i += 16)
- {
- for (j = 0; j < source->y_width; j += 16)
- {
- unsigned int sse;
- Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, dst + j, dest->y_stride, &sse);
- }
-
- src += 16 * source->y_stride;
- dst += 16 * dest->y_stride;
+ // Loop through the Y plane raw and reconstruction data summing (square differences)
+ for (i = 0; i < source->y_height; i += 16) {
+ for (j = 0; j < source->y_width; j += 16) {
+ unsigned int sse;
+ Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, dst + j, dest->y_stride, &sse);
}
- return Total;
+ src += 16 * source->y_stride;
+ dst += 16 * dest->y_stride;
+ }
+
+ return Total;
}
-int vp8_get_quantizer(VP8_PTR c)
-{
- VP8_COMP *cpi = (VP8_COMP *) c;
- return cpi->common.base_qindex;
+int vp8_get_quantizer(VP8_PTR c) {
+ VP8_COMP *cpi = (VP8_COMP *) c;
+ return cpi->common.base_qindex;
}
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index c838eccad..1fa8b0588 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -31,7 +31,7 @@
#include "vp8/common/findnearmv.h"
#include "lookahead.h"
-//#define SPEEDSTATS 1
+// #define SPEEDSTATS 1
#define MIN_GF_INTERVAL 4
#define DEFAULT_GF_INTERVAL 7
@@ -67,705 +67,688 @@
#define VP8_TEMPORAL_ALT_REF 1
-typedef struct
-{
- MV_CONTEXT mvc[2];
- int mvcosts[2][MVvals+1];
+typedef struct {
+ MV_CONTEXT mvc[2];
+ int mvcosts[2][MVvals + 1];
#if CONFIG_HIGH_PRECISION_MV
- MV_CONTEXT_HP mvc_hp[2];
- int mvcosts_hp[2][MVvals_hp+1];
+ MV_CONTEXT_HP mvc_hp[2];
+ int mvcosts_hp[2][MVvals_hp + 1];
#endif
#ifdef MODE_STATS
- // Stats
- int y_modes[VP8_YMODES];
- int uv_modes[VP8_UV_MODES];
- int i8x8_modes[VP8_I8X8_MODES];
- int b_modes[B_MODE_COUNT];
- int inter_y_modes[MB_MODE_COUNT];
- int inter_uv_modes[VP8_UV_MODES];
- int inter_b_modes[B_MODE_COUNT];
+ // Stats
+ int y_modes[VP8_YMODES];
+ int uv_modes[VP8_UV_MODES];
+ int i8x8_modes[VP8_I8X8_MODES];
+ int b_modes[B_MODE_COUNT];
+ int inter_y_modes[MB_MODE_COUNT];
+ int inter_uv_modes[VP8_UV_MODES];
+ int inter_b_modes[B_MODE_COUNT];
#endif
- vp8_prob segment_pred_probs[PREDICTION_PROBS];
- unsigned char ref_pred_probs_update[PREDICTION_PROBS];
- vp8_prob ref_pred_probs[PREDICTION_PROBS];
- vp8_prob prob_comppred[COMP_PRED_CONTEXTS];
+ vp8_prob segment_pred_probs[PREDICTION_PROBS];
+ unsigned char ref_pred_probs_update[PREDICTION_PROBS];
+ vp8_prob ref_pred_probs[PREDICTION_PROBS];
+ vp8_prob prob_comppred[COMP_PRED_CONTEXTS];
- unsigned char * last_frame_seg_map_copy;
+ unsigned char *last_frame_seg_map_copy;
- // 0 = Intra, Last, GF, ARF
- signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
- // 0 = BPRED, ZERO_MV, MV, SPLIT
- signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
+ // 0 = Intra, Last, GF, ARF
+ signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
+ // 0 = BPRED, ZERO_MV, MV, SPLIT
+ signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
- vp8_prob coef_probs[BLOCK_TYPES]
- [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
- vp8_prob coef_probs_8x8[BLOCK_TYPES_8X8]
- [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
+ vp8_prob coef_probs[BLOCK_TYPES]
+ [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
+ vp8_prob coef_probs_8x8[BLOCK_TYPES_8X8]
+ [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
- vp8_prob ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */
- vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
- vp8_prob bmode_prob [VP8_BINTRAMODES-1];
- vp8_prob i8x8_mode_prob [VP8_I8X8_MODES-1];
- vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
- vp8_prob mbsplit_prob [VP8_NUMMBSPLITS-1];
+ vp8_prob ymode_prob [VP8_YMODES - 1]; /* interframe intra mode probs */
+ vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES - 1];
+ vp8_prob bmode_prob [VP8_BINTRAMODES - 1];
+ vp8_prob i8x8_mode_prob [VP8_I8X8_MODES - 1];
+ vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS - 1];
+ vp8_prob mbsplit_prob [VP8_NUMMBSPLITS - 1];
- int mv_ref_ct[6][4][2];
- int mode_context[6][4];
- int mv_ref_ct_a[6][4][2];
- int mode_context_a[6][4];
+ int mv_ref_ct[6][4][2];
+ int mode_context[6][4];
+ int mv_ref_ct_a[6][4][2];
+ int mode_context_a[6][4];
} CODING_CONTEXT;
-typedef struct
-{
- double frame;
- double intra_error;
- double coded_error;
- double sr_coded_error;
- double ssim_weighted_pred_err;
- double pcnt_inter;
- double pcnt_motion;
- double pcnt_second_ref;
- double pcnt_neutral;
- double MVr;
- double mvr_abs;
- double MVc;
- double mvc_abs;
- double MVrv;
- double MVcv;
- double mv_in_out_count;
- double new_mv_count;
- double duration;
- double count;
+typedef struct {
+ double frame;
+ double intra_error;
+ double coded_error;
+ double sr_coded_error;
+ double ssim_weighted_pred_err;
+ double pcnt_inter;
+ double pcnt_motion;
+ double pcnt_second_ref;
+ double pcnt_neutral;
+ double MVr;
+ double mvr_abs;
+ double MVc;
+ double mvc_abs;
+ double MVrv;
+ double MVcv;
+ double mv_in_out_count;
+ double new_mv_count;
+ double duration;
+ double count;
}
FIRSTPASS_STATS;
-typedef struct
-{
- int frames_so_far;
- double frame_intra_error;
- double frame_coded_error;
- double frame_pcnt_inter;
- double frame_pcnt_motion;
- double frame_mvr;
- double frame_mvr_abs;
- double frame_mvc;
- double frame_mvc_abs;
+typedef struct {
+ int frames_so_far;
+ double frame_intra_error;
+ double frame_coded_error;
+ double frame_pcnt_inter;
+ double frame_pcnt_motion;
+ double frame_mvr;
+ double frame_mvr_abs;
+ double frame_mvc;
+ double frame_mvc_abs;
} ONEPASS_FRAMESTATS;
-typedef struct
-{
- struct {
- int err;
- union {
- int_mv mv;
- MB_PREDICTION_MODE mode;
- } m;
- } ref[MAX_REF_FRAMES];
+typedef struct {
+ struct {
+ int err;
+ union {
+ int_mv mv;
+ MB_PREDICTION_MODE mode;
+ } m;
+ } ref[MAX_REF_FRAMES];
} MBGRAPH_MB_STATS;
-typedef struct
-{
- MBGRAPH_MB_STATS *mb_stats;
+typedef struct {
+ MBGRAPH_MB_STATS *mb_stats;
} MBGRAPH_FRAME_STATS;
#if CONFIG_PRED_FILTER
-typedef enum
-{
- THR_ZEROMV,
- THR_ZEROMV_FILT,
- THR_DC,
-
- THR_NEARESTMV,
- THR_NEARESTMV_FILT,
- THR_NEARMV,
- THR_NEARMV_FILT,
-
- THR_ZEROG,
- THR_ZEROG_FILT,
- THR_NEARESTG,
- THR_NEARESTG_FILT,
-
- THR_ZEROA,
- THR_ZEROA_FILT,
- THR_NEARESTA,
- THR_NEARESTA_FILT,
-
- THR_NEARG,
- THR_NEARG_FILT,
- THR_NEARA,
- THR_NEARA_FILT,
-
- THR_V_PRED,
- THR_H_PRED,
+typedef enum {
+ THR_ZEROMV,
+ THR_ZEROMV_FILT,
+ THR_DC,
+
+ THR_NEARESTMV,
+ THR_NEARESTMV_FILT,
+ THR_NEARMV,
+ THR_NEARMV_FILT,
+
+ THR_ZEROG,
+ THR_ZEROG_FILT,
+ THR_NEARESTG,
+ THR_NEARESTG_FILT,
+
+ THR_ZEROA,
+ THR_ZEROA_FILT,
+ THR_NEARESTA,
+ THR_NEARESTA_FILT,
+
+ THR_NEARG,
+ THR_NEARG_FILT,
+ THR_NEARA,
+ THR_NEARA_FILT,
+
+ THR_V_PRED,
+ THR_H_PRED,
#if CONFIG_NEWINTRAMODES
- THR_D45_PRED,
- THR_D135_PRED,
- THR_D117_PRED,
- THR_D153_PRED,
- THR_D27_PRED,
- THR_D63_PRED,
+ THR_D45_PRED,
+ THR_D135_PRED,
+ THR_D117_PRED,
+ THR_D153_PRED,
+ THR_D27_PRED,
+ THR_D63_PRED,
#endif
- THR_TM,
+ THR_TM,
- THR_NEWMV,
- THR_NEWMV_FILT,
- THR_NEWG,
- THR_NEWG_FILT,
- THR_NEWA,
- THR_NEWA_FILT,
+ THR_NEWMV,
+ THR_NEWMV_FILT,
+ THR_NEWG,
+ THR_NEWG_FILT,
+ THR_NEWA,
+ THR_NEWA_FILT,
- THR_SPLITMV,
- THR_SPLITG,
- THR_SPLITA,
+ THR_SPLITMV,
+ THR_SPLITG,
+ THR_SPLITA,
- THR_B_PRED,
- THR_I8X8_PRED,
+ THR_B_PRED,
+ THR_I8X8_PRED,
- THR_COMP_ZEROLG,
- THR_COMP_NEARESTLG,
- THR_COMP_NEARLG,
+ THR_COMP_ZEROLG,
+ THR_COMP_NEARESTLG,
+ THR_COMP_NEARLG,
- THR_COMP_ZEROLA,
- THR_COMP_NEARESTLA,
- THR_COMP_NEARLA,
+ THR_COMP_ZEROLA,
+ THR_COMP_NEARESTLA,
+ THR_COMP_NEARLA,
- THR_COMP_ZEROGA,
- THR_COMP_NEARESTGA,
- THR_COMP_NEARGA,
+ THR_COMP_ZEROGA,
+ THR_COMP_NEARESTGA,
+ THR_COMP_NEARGA,
- THR_COMP_NEWLG,
- THR_COMP_NEWLA,
- THR_COMP_NEWGA,
+ THR_COMP_NEWLG,
+ THR_COMP_NEWLA,
+ THR_COMP_NEWGA,
- THR_COMP_SPLITLG,
- THR_COMP_SPLITLA,
- THR_COMP_SPLITGA,
+ THR_COMP_SPLITLG,
+ THR_COMP_SPLITLA,
+ THR_COMP_SPLITGA,
}
THR_MODES;
#else
-typedef enum
-{
- THR_ZEROMV,
- THR_DC,
+typedef enum {
+ THR_ZEROMV,
+ THR_DC,
- THR_NEARESTMV,
- THR_NEARMV,
+ THR_NEARESTMV,
+ THR_NEARMV,
- THR_ZEROG,
- THR_NEARESTG,
+ THR_ZEROG,
+ THR_NEARESTG,
- THR_ZEROA,
- THR_NEARESTA,
+ THR_ZEROA,
+ THR_NEARESTA,
- THR_NEARG,
- THR_NEARA,
+ THR_NEARG,
+ THR_NEARA,
- THR_V_PRED,
- THR_H_PRED,
+ THR_V_PRED,
+ THR_H_PRED,
#if CONFIG_NEWINTRAMODES
- THR_D45_PRED,
- THR_D135_PRED,
- THR_D117_PRED,
- THR_D153_PRED,
- THR_D27_PRED,
- THR_D63_PRED,
+ THR_D45_PRED,
+ THR_D135_PRED,
+ THR_D117_PRED,
+ THR_D153_PRED,
+ THR_D27_PRED,
+ THR_D63_PRED,
#endif
- THR_TM,
+ THR_TM,
- THR_NEWMV,
- THR_NEWG,
- THR_NEWA,
+ THR_NEWMV,
+ THR_NEWG,
+ THR_NEWA,
- THR_SPLITMV,
- THR_SPLITG,
- THR_SPLITA,
+ THR_SPLITMV,
+ THR_SPLITG,
+ THR_SPLITA,
- THR_B_PRED,
- THR_I8X8_PRED,
+ THR_B_PRED,
+ THR_I8X8_PRED,
- THR_COMP_ZEROLG,
- THR_COMP_NEARESTLG,
- THR_COMP_NEARLG,
+ THR_COMP_ZEROLG,
+ THR_COMP_NEARESTLG,
+ THR_COMP_NEARLG,
- THR_COMP_ZEROLA,
- THR_COMP_NEARESTLA,
- THR_COMP_NEARLA,
+ THR_COMP_ZEROLA,
+ THR_COMP_NEARESTLA,
+ THR_COMP_NEARLA,
- THR_COMP_ZEROGA,
- THR_COMP_NEARESTGA,
- THR_COMP_NEARGA,
+ THR_COMP_ZEROGA,
+ THR_COMP_NEARESTGA,
+ THR_COMP_NEARGA,
- THR_COMP_NEWLG,
- THR_COMP_NEWLA,
- THR_COMP_NEWGA,
+ THR_COMP_NEWLG,
+ THR_COMP_NEWLA,
+ THR_COMP_NEWGA,
- THR_COMP_SPLITLG,
- THR_COMP_SPLITLA,
- THR_COMP_SPLITGA
+ THR_COMP_SPLITLG,
+ THR_COMP_SPLITLA,
+ THR_COMP_SPLITGA
}
THR_MODES;
#endif
-typedef enum
-{
- DIAMOND = 0,
- NSTEP = 1,
- HEX = 2
+typedef enum {
+ DIAMOND = 0,
+ NSTEP = 1,
+ HEX = 2
} SEARCH_METHODS;
-typedef struct
-{
- int RD;
- SEARCH_METHODS search_method;
- int improved_dct;
- int auto_filter;
- int recode_loop;
- int iterative_sub_pixel;
- int half_pixel_search;
- int quarter_pixel_search;
- int thresh_mult[MAX_MODES];
- int max_step_search_steps;
- int first_step;
- int optimize_coefficients;
- int no_skip_block4x4_search;
- int improved_mv_pred;
+typedef struct {
+ int RD;
+ SEARCH_METHODS search_method;
+ int improved_dct;
+ int auto_filter;
+ int recode_loop;
+ int iterative_sub_pixel;
+ int half_pixel_search;
+ int quarter_pixel_search;
+ int thresh_mult[MAX_MODES];
+ int max_step_search_steps;
+ int first_step;
+ int optimize_coefficients;
+ int no_skip_block4x4_search;
+ int improved_mv_pred;
#if CONFIG_ENHANCED_INTERP
- int search_best_filter;
+ int search_best_filter;
#endif
} SPEED_FEATURES;
-typedef struct
-{
- MACROBLOCK mb;
- int totalrate;
+typedef struct {
+ MACROBLOCK mb;
+ int totalrate;
} MB_ROW_COMP;
-typedef struct
-{
- TOKENEXTRA *start;
- TOKENEXTRA *stop;
+typedef struct {
+ TOKENEXTRA *start;
+ TOKENEXTRA *stop;
} TOKENLIST;
-typedef struct
-{
- int ithread;
- void *ptr1;
- void *ptr2;
+typedef struct {
+ int ithread;
+ void *ptr1;
+ void *ptr2;
} ENCODETHREAD_DATA;
-typedef struct
-{
- int ithread;
- void *ptr1;
+typedef struct {
+ int ithread;
+ void *ptr1;
} LPFTHREAD_DATA;
-typedef struct VP8_ENCODER_RTCD
-{
- VP8_COMMON_RTCD *common;
- vp8_variance_rtcd_vtable_t variance;
- vp8_fdct_rtcd_vtable_t fdct;
- vp8_encodemb_rtcd_vtable_t encodemb;
- vp8_search_rtcd_vtable_t search;
- vp8_temporal_rtcd_vtable_t temporal;
+typedef struct VP8_ENCODER_RTCD {
+ VP8_COMMON_RTCD *common;
+ vp8_variance_rtcd_vtable_t variance;
+ vp8_fdct_rtcd_vtable_t fdct;
+ vp8_encodemb_rtcd_vtable_t encodemb;
+ vp8_search_rtcd_vtable_t search;
+ vp8_temporal_rtcd_vtable_t temporal;
} VP8_ENCODER_RTCD;
-enum
-{
- BLOCK_16X8,
- BLOCK_8X16,
- BLOCK_8X8,
- BLOCK_4X4,
- BLOCK_16X16,
- BLOCK_MAX_SEGMENTS
+enum {
+ BLOCK_16X8,
+ BLOCK_8X16,
+ BLOCK_8X8,
+ BLOCK_4X4,
+ BLOCK_16X16,
+ BLOCK_MAX_SEGMENTS
};
-typedef struct VP8_COMP
-{
+typedef struct VP8_COMP {
- DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, unsigned char, Y1quant_shift[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, unsigned char, Y1quant_shift[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, unsigned char, Y2quant_shift[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, unsigned char, Y2quant_shift[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, unsigned char, UVquant_shift[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, unsigned char, UVquant_shift[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]);
+ DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]);
- DECLARE_ALIGNED(64, short, Y1zbin_8x8[QINDEX_RANGE][64]);
- DECLARE_ALIGNED(64, short, Y2zbin_8x8[QINDEX_RANGE][64]);
- DECLARE_ALIGNED(64, short, UVzbin_8x8[QINDEX_RANGE][64]);
- DECLARE_ALIGNED(64, short, zrun_zbin_boost_y1_8x8[QINDEX_RANGE][64]);
- DECLARE_ALIGNED(64, short, zrun_zbin_boost_y2_8x8[QINDEX_RANGE][64]);
- DECLARE_ALIGNED(64, short, zrun_zbin_boost_uv_8x8[QINDEX_RANGE][64]);
-
- MACROBLOCK mb;
- VP8_COMMON common;
- vp8_writer bc, bc2;
- // bool_writer *bc2;
-
- VP8_CONFIG oxcf;
-
- struct lookahead_ctx *lookahead;
- struct lookahead_entry *source;
- struct lookahead_entry *alt_ref_source;
+ DECLARE_ALIGNED(64, short, Y1zbin_8x8[QINDEX_RANGE][64]);
+ DECLARE_ALIGNED(64, short, Y2zbin_8x8[QINDEX_RANGE][64]);
+ DECLARE_ALIGNED(64, short, UVzbin_8x8[QINDEX_RANGE][64]);
+ DECLARE_ALIGNED(64, short, zrun_zbin_boost_y1_8x8[QINDEX_RANGE][64]);
+ DECLARE_ALIGNED(64, short, zrun_zbin_boost_y2_8x8[QINDEX_RANGE][64]);
+ DECLARE_ALIGNED(64, short, zrun_zbin_boost_uv_8x8[QINDEX_RANGE][64]);
+
+ MACROBLOCK mb;
+ VP8_COMMON common;
+ vp8_writer bc, bc2;
+ // bool_writer *bc2;
+
+ VP8_CONFIG oxcf;
+
+ struct lookahead_ctx *lookahead;
+ struct lookahead_entry *source;
+ struct lookahead_entry *alt_ref_source;
- YV12_BUFFER_CONFIG *Source;
- YV12_BUFFER_CONFIG *un_scaled_source;
- YV12_BUFFER_CONFIG scaled_source;
+ YV12_BUFFER_CONFIG *Source;
+ YV12_BUFFER_CONFIG *un_scaled_source;
+ YV12_BUFFER_CONFIG scaled_source;
- int source_alt_ref_pending; // frame in src_buffers has been identified to be encoded as an alt ref
- int source_alt_ref_active; // an alt ref frame has been encoded and is usable
+ int source_alt_ref_pending; // frame in src_buffers has been identified to be encoded as an alt ref
+ int source_alt_ref_active; // an alt ref frame has been encoded and is usable
- int is_src_frame_alt_ref; // source of frame to encode is an exact copy of an alt ref frame
+ int is_src_frame_alt_ref; // source of frame to encode is an exact copy of an alt ref frame
- int gold_is_last; // golden frame same as last frame ( short circuit gold searches)
- int alt_is_last; // Alt reference frame same as last ( short circuit altref search)
- int gold_is_alt; // don't do both alt and gold search ( just do gold).
+ int gold_is_last; // golden frame same as last frame ( short circuit gold searches)
+ int alt_is_last; // Alt reference frame same as last ( short circuit altref search)
+ int gold_is_alt; // don't do both alt and gold search ( just do gold).
- //int refresh_alt_ref_frame;
- YV12_BUFFER_CONFIG last_frame_uf;
+ // int refresh_alt_ref_frame;
+ YV12_BUFFER_CONFIG last_frame_uf;
- TOKENEXTRA *tok;
- unsigned int tok_count;
+ TOKENEXTRA *tok;
+ unsigned int tok_count;
- unsigned int frames_since_key;
- unsigned int key_frame_frequency;
- unsigned int this_key_frame_forced;
- unsigned int next_key_frame_forced;
+ unsigned int frames_since_key;
+ unsigned int key_frame_frequency;
+ unsigned int this_key_frame_forced;
+ unsigned int next_key_frame_forced;
- // Ambient reconstruction err target for force key frames
- int ambient_err;
+ // Ambient reconstruction err target for force key frames
+ int ambient_err;
- unsigned int mode_check_freq[MAX_MODES];
- unsigned int mode_test_hit_counts[MAX_MODES];
- unsigned int mode_chosen_counts[MAX_MODES];
+ unsigned int mode_check_freq[MAX_MODES];
+ unsigned int mode_test_hit_counts[MAX_MODES];
+ unsigned int mode_chosen_counts[MAX_MODES];
- int rd_thresh_mult[MAX_MODES];
- int rd_baseline_thresh[MAX_MODES];
- int rd_threshes[MAX_MODES];
- int64_t rd_single_diff, rd_comp_diff, rd_hybrid_diff;
- int rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
- int comp_pred_count[COMP_PRED_CONTEXTS];
- int single_pred_count[COMP_PRED_CONTEXTS];
+ int rd_thresh_mult[MAX_MODES];
+ int rd_baseline_thresh[MAX_MODES];
+ int rd_threshes[MAX_MODES];
+ int64_t rd_single_diff, rd_comp_diff, rd_hybrid_diff;
+ int rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
+ int comp_pred_count[COMP_PRED_CONTEXTS];
+ int single_pred_count[COMP_PRED_CONTEXTS];
- int RDMULT;
- int RDDIV ;
+ int RDMULT;
+ int RDDIV;
- CODING_CONTEXT coding_context;
+ CODING_CONTEXT coding_context;
- // Rate targetting variables
- int64_t prediction_error;
- int64_t last_prediction_error;
- int64_t intra_error;
- int64_t last_intra_error;
+ // Rate targetting variables
+ int64_t prediction_error;
+ int64_t last_prediction_error;
+ int64_t intra_error;
+ int64_t last_intra_error;
- int this_frame_target;
- int projected_frame_size;
- int last_q[2]; // Separate values for Intra/Inter
- int last_boosted_qindex; // Last boosted GF/KF/ARF q
+ int this_frame_target;
+ int projected_frame_size;
+ int last_q[2]; // Separate values for Intra/Inter
+ int last_boosted_qindex; // Last boosted GF/KF/ARF q
- double rate_correction_factor;
- double key_frame_rate_correction_factor;
- double gf_rate_correction_factor;
+ double rate_correction_factor;
+ double key_frame_rate_correction_factor;
+ double gf_rate_correction_factor;
- int frames_till_gf_update_due; // Count down till next GF
- int current_gf_interval; // GF interval chosen when we coded the last GF
+ int frames_till_gf_update_due; // Count down till next GF
+ int current_gf_interval; // GF interval chosen when we coded the last GF
- int gf_overspend_bits; // Total bits overspent becasue of GF boost (cumulative)
+ int gf_overspend_bits; // Total bits overspent becasue of GF boost (cumulative)
- int non_gf_bitrate_adjustment; // Used in the few frames following a GF to recover the extra bits spent in that GF
+ int non_gf_bitrate_adjustment; // Used in the few frames following a GF to recover the extra bits spent in that GF
- int kf_overspend_bits; // Extra bits spent on key frames that need to be recovered on inter frames
- int kf_bitrate_adjustment; // Current number of bit s to try and recover on each inter frame.
- int max_gf_interval;
- int baseline_gf_interval;
- int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
+ int kf_overspend_bits; // Extra bits spent on key frames that need to be recovered on inter frames
+ int kf_bitrate_adjustment; // Current number of bit s to try and recover on each inter frame.
+ int max_gf_interval;
+ int baseline_gf_interval;
+ int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
- int64_t key_frame_count;
- int prior_key_frame_distance[KEY_FRAME_CONTEXT];
- int per_frame_bandwidth; // Current section per frame bandwidth target
- int av_per_frame_bandwidth; // Average frame size target for clip
- int min_frame_bandwidth; // Minimum allocation that should be used for any frame
- int inter_frame_target;
- double output_frame_rate;
- int64_t last_time_stamp_seen;
- int64_t last_end_time_stamp_seen;
- int64_t first_time_stamp_ever;
+ int64_t key_frame_count;
+ int prior_key_frame_distance[KEY_FRAME_CONTEXT];
+ int per_frame_bandwidth; // Current section per frame bandwidth target
+ int av_per_frame_bandwidth; // Average frame size target for clip
+ int min_frame_bandwidth; // Minimum allocation that should be used for any frame
+ int inter_frame_target;
+ double output_frame_rate;
+ int64_t last_time_stamp_seen;
+ int64_t last_end_time_stamp_seen;
+ int64_t first_time_stamp_ever;
- int ni_av_qi;
- int ni_tot_qi;
- int ni_frames;
- int avg_frame_qindex;
- double tot_q;
- double avg_q;
+ int ni_av_qi;
+ int ni_tot_qi;
+ int ni_frames;
+ int avg_frame_qindex;
+ double tot_q;
+ double avg_q;
- int zbin_over_quant;
- int zbin_mode_boost;
- int zbin_mode_boost_enabled;
+ int zbin_over_quant;
+ int zbin_mode_boost;
+ int zbin_mode_boost_enabled;
- int64_t total_byte_count;
+ int64_t total_byte_count;
- int buffered_mode;
+ int buffered_mode;
- int buffer_level;
- int bits_off_target;
+ int buffer_level;
+ int bits_off_target;
- int rolling_target_bits;
- int rolling_actual_bits;
+ int rolling_target_bits;
+ int rolling_actual_bits;
- int long_rolling_target_bits;
- int long_rolling_actual_bits;
+ int long_rolling_target_bits;
+ int long_rolling_actual_bits;
- int64_t total_actual_bits;
- int total_target_vs_actual; // debug stats
+ int64_t total_actual_bits;
+ int total_target_vs_actual; // debug stats
- int worst_quality;
- int active_worst_quality;
- int best_quality;
- int active_best_quality;
+ int worst_quality;
+ int active_worst_quality;
+ int best_quality;
+ int active_best_quality;
- int cq_target_quality;
+ int cq_target_quality;
- int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
- int bmode_count [VP8_BINTRAMODES];
- int i8x8_mode_count [VP8_I8X8_MODES];
- int sub_mv_ref_count [SUBMVREF_COUNT][VP8_SUBMVREFS];
- int mbsplit_count [VP8_NUMMBSPLITS];
- //int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
- int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES];
-
- unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */
+ int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
+ int bmode_count [VP8_BINTRAMODES];
+ int i8x8_mode_count [VP8_I8X8_MODES];
+ int sub_mv_ref_count [SUBMVREF_COUNT][VP8_SUBMVREFS];
+ int mbsplit_count [VP8_NUMMBSPLITS];
+ // int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
+ int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES];
+
+ unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */
#if CONFIG_HIGH_PRECISION_MV
- unsigned int MVcount_hp [2] [MVvals_hp]; /* (row,col) MV cts this frame */
+ unsigned int MVcount_hp [2] [MVvals_hp]; /* (row,col) MV cts this frame */
#endif
- unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
- //DECLARE_ALIGNED(16, int, coef_counts_backup [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]); //not used any more
- //save vp8_tree_probs_from_distribution result for each frame to avoid repeat calculation
- vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
- unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
- vp8_prob frame_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
- unsigned int frame_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
+ unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
+ // DECLARE_ALIGNED(16, int, coef_counts_backup [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]); //not used any more
+ // save vp8_tree_probs_from_distribution result for each frame to avoid repeat calculation
+ vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
+ unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
+ vp8_prob frame_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
+ unsigned int frame_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
- int gfu_boost;
- int last_boost;
- int kf_boost;
- int kf_zeromotion_pct;
+ int gfu_boost;
+ int last_boost;
+ int kf_boost;
+ int kf_zeromotion_pct;
- int target_bandwidth;
- struct vpx_codec_pkt_list *output_pkt_list;
+ int target_bandwidth;
+ struct vpx_codec_pkt_list *output_pkt_list;
#if 0
- // Experimental code for lagged and one pass
- ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
- int one_pass_frame_index;
+ // Experimental code for lagged and one pass
+ ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
+ int one_pass_frame_index;
#endif
- MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
- int mbgraph_n_frames; // number of frames filled in the above
- int static_mb_pct; // % forced skip mbs by segmentation
- int seg0_progress, seg0_idx, seg0_cnt;
- int ref_pred_count[3][2];
-
- int decimation_factor;
- int decimation_count;
-
- // for real time encoding
- int avg_encode_time; //microsecond
- int avg_pick_mode_time; //microsecond
- int Speed;
- unsigned int cpu_freq; //Mhz
- int compressor_speed;
-
- int interquantizer;
- int goldfreq;
- int auto_worst_q;
- int cpu_used;
- int horiz_scale;
- int vert_scale;
- int pass;
+ MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
+ int mbgraph_n_frames; // number of frames filled in the above
+ int static_mb_pct; // % forced skip mbs by segmentation
+ int seg0_progress, seg0_idx, seg0_cnt;
+ int ref_pred_count[3][2];
+
+ int decimation_factor;
+ int decimation_count;
+
+ // for real time encoding
+ int avg_encode_time; // microsecond
+ int avg_pick_mode_time; // microsecond
+ int Speed;
+ unsigned int cpu_freq; // Mhz
+ int compressor_speed;
+
+ int interquantizer;
+ int goldfreq;
+ int auto_worst_q;
+ int cpu_used;
+ int horiz_scale;
+ int vert_scale;
+ int pass;
#if CONFIG_NEWENTROPY
- vp8_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
+ vp8_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
#else
- vp8_prob prob_skip_false;
- vp8_prob last_skip_false_probs[3];
+ vp8_prob prob_skip_false;
+ vp8_prob last_skip_false_probs[3];
#endif
- int last_skip_probs_q[3];
+ int last_skip_probs_q[3];
- int recent_ref_frame_usage[MAX_REF_FRAMES];
- int count_mb_ref_frame_usage[MAX_REF_FRAMES];
- int ref_frame_flags;
+ int recent_ref_frame_usage[MAX_REF_FRAMES];
+ int count_mb_ref_frame_usage[MAX_REF_FRAMES];
+ int ref_frame_flags;
- unsigned char ref_pred_probs_update[PREDICTION_PROBS];
+ unsigned char ref_pred_probs_update[PREDICTION_PROBS];
- SPEED_FEATURES sf;
- int error_bins[1024];
+ SPEED_FEATURES sf;
+ int error_bins[1024];
- // Data used for real time conferencing mode to help determine if it would be good to update the gf
- int inter_zz_count;
- int gf_bad_count;
- int gf_update_recommended;
+ // Data used for real time conferencing mode to help determine if it would be good to update the gf
+ int inter_zz_count;
+ int gf_bad_count;
+ int gf_update_recommended;
#if CONFIG_NEWENTROPY
- int skip_true_count[3];
- int skip_false_count[3];
+ int skip_true_count[3];
+ int skip_false_count[3];
#else
- int skip_true_count;
- int skip_false_count;
+ int skip_true_count;
+ int skip_false_count;
#endif
- int t4x4_count;
- int t8x8_count;
+ int t4x4_count;
+ int t8x8_count;
- unsigned char *segmentation_map;
+ unsigned char *segmentation_map;
- // segment threashold for encode breakout
- int segment_encode_breakout[MAX_MB_SEGMENTS];
+ // segment threashold for encode breakout
+ int segment_encode_breakout[MAX_MB_SEGMENTS];
- unsigned char *active_map;
- unsigned int active_map_enabled;
+ unsigned char *active_map;
+ unsigned int active_map_enabled;
- TOKENLIST *tplist;
+ TOKENLIST *tplist;
- fractional_mv_step_fp *find_fractional_mv_step;
- vp8_full_search_fn_t full_search_sad;
- vp8_refining_search_fn_t refining_search_sad;
- vp8_diamond_search_fn_t diamond_search_sad;
- vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS];
- unsigned int time_receive_data;
- unsigned int time_compress_data;
- unsigned int time_pick_lpf;
- unsigned int time_encode_mb_row;
+ fractional_mv_step_fp *find_fractional_mv_step;
+ vp8_full_search_fn_t full_search_sad;
+ vp8_refining_search_fn_t refining_search_sad;
+ vp8_diamond_search_fn_t diamond_search_sad;
+ vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS];
+ unsigned int time_receive_data;
+ unsigned int time_compress_data;
+ unsigned int time_pick_lpf;
+ unsigned int time_encode_mb_row;
#if CONFIG_NEWENTROPY
- int base_skip_false_prob[QINDEX_RANGE][3];
+ int base_skip_false_prob[QINDEX_RANGE][3];
#else
- int base_skip_false_prob[QINDEX_RANGE];
+ int base_skip_false_prob[QINDEX_RANGE];
#endif
- struct twopass_rc
- {
- unsigned int section_intra_rating;
- unsigned int next_iiratio;
- unsigned int this_iiratio;
- FIRSTPASS_STATS *total_stats;
- FIRSTPASS_STATS *this_frame_stats;
- FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
- FIRSTPASS_STATS *total_left_stats;
- int first_pass_done;
- int64_t bits_left;
- int64_t clip_bits_total;
- double avg_iiratio;
- double modified_error_total;
- double modified_error_used;
- double modified_error_left;
- double kf_intra_err_min;
- double gf_intra_err_min;
- int frames_to_key;
- int maxq_max_limit;
- int maxq_min_limit;
- int static_scene_max_gf_interval;
- int kf_bits;
- int gf_group_error_left; // Remaining error from uncoded frames in a gf group. Two pass use only
-
- // Projected total bits available for a key frame group of frames
- int64_t kf_group_bits;
-
- // Error score of frames still to be coded in kf group
- int64_t kf_group_error_left;
-
- int gf_group_bits; // Projected Bits available for a group of frames including 1 GF or ARF
- int gf_bits; // Bits for the golden frame or ARF - 2 pass only
- int alt_extra_bits;
-
- int sr_update_lag;
- double est_max_qcorrection_factor;
- } twopass;
+ struct twopass_rc {
+ unsigned int section_intra_rating;
+ unsigned int next_iiratio;
+ unsigned int this_iiratio;
+ FIRSTPASS_STATS *total_stats;
+ FIRSTPASS_STATS *this_frame_stats;
+ FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
+ FIRSTPASS_STATS *total_left_stats;
+ int first_pass_done;
+ int64_t bits_left;
+ int64_t clip_bits_total;
+ double avg_iiratio;
+ double modified_error_total;
+ double modified_error_used;
+ double modified_error_left;
+ double kf_intra_err_min;
+ double gf_intra_err_min;
+ int frames_to_key;
+ int maxq_max_limit;
+ int maxq_min_limit;
+ int static_scene_max_gf_interval;
+ int kf_bits;
+ int gf_group_error_left; // Remaining error from uncoded frames in a gf group. Two pass use only
+
+ // Projected total bits available for a key frame group of frames
+ int64_t kf_group_bits;
+
+ // Error score of frames still to be coded in kf group
+ int64_t kf_group_error_left;
+
+ int gf_group_bits; // Projected Bits available for a group of frames including 1 GF or ARF
+ int gf_bits; // Bits for the golden frame or ARF - 2 pass only
+ int alt_extra_bits;
+
+ int sr_update_lag;
+ double est_max_qcorrection_factor;
+ } twopass;
#if CONFIG_RUNTIME_CPU_DETECT
- VP8_ENCODER_RTCD rtcd;
+ VP8_ENCODER_RTCD rtcd;
#endif
#if VP8_TEMPORAL_ALT_REF
- YV12_BUFFER_CONFIG alt_ref_buffer;
- YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
- int fixed_divide[512];
+ YV12_BUFFER_CONFIG alt_ref_buffer;
+ YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
+ int fixed_divide[512];
#endif
#if CONFIG_INTERNAL_STATS
- int count;
- double total_y;
- double total_u;
- double total_v;
- double total ;
- double total_sq_error;
- double totalp_y;
- double totalp_u;
- double totalp_v;
- double totalp;
- double total_sq_error2;
- int bytes;
- double summed_quality;
- double summed_weights;
- unsigned int tot_recode_hits;
-
-
- double total_ssimg_y;
- double total_ssimg_u;
- double total_ssimg_v;
- double total_ssimg_all;
-
- int b_calculate_ssimg;
+ int count;
+ double total_y;
+ double total_u;
+ double total_v;
+ double total;
+ double total_sq_error;
+ double totalp_y;
+ double totalp_u;
+ double totalp_v;
+ double totalp;
+ double total_sq_error2;
+ int bytes;
+ double summed_quality;
+ double summed_weights;
+ unsigned int tot_recode_hits;
+
+
+ double total_ssimg_y;
+ double total_ssimg_u;
+ double total_ssimg_v;
+ double total_ssimg_all;
+
+ int b_calculate_ssimg;
#endif
- int b_calculate_psnr;
+ int b_calculate_psnr;
- // Per MB activity measurement
- unsigned int activity_avg;
- unsigned int * mb_activity_map;
- int * mb_norm_activity_map;
+ // Per MB activity measurement
+ unsigned int activity_avg;
+ unsigned int *mb_activity_map;
+ int *mb_norm_activity_map;
- // Record of which MBs still refer to last golden frame either
- // directly or through 0,0
- unsigned char *gf_active_flags;
- int gf_active_count;
+ // Record of which MBs still refer to last golden frame either
+ // directly or through 0,0
+ unsigned char *gf_active_flags;
+ int gf_active_count;
- int output_partition;
+ int output_partition;
- //Store last frame's MV info for next frame MV prediction
- int_mv *lfmv;
- int *lf_ref_frame_sign_bias;
- int *lf_ref_frame;
+ // Store last frame's MV info for next frame MV prediction
+ int_mv *lfmv;
+ int *lf_ref_frame_sign_bias;
+ int *lf_ref_frame;
- /* force next frame to intra when kf_auto says so */
- int force_next_frame_intra;
+ /* force next frame to intra when kf_auto says so */
+ int force_next_frame_intra;
- int droppable;
+ int droppable;
- // Global store for SB left contexts, one for each MB row in the SB
- ENTROPY_CONTEXT_PLANES left_context[2];
+ // Global store for SB left contexts, one for each MB row in the SB
+ ENTROPY_CONTEXT_PLANES left_context[2];
- // TODO Do we still need this??
- int update_context;
+ // TODO Do we still need this??
+ int update_context;
- int dummy_packing; /* flag to indicate if packing is dummy */
+ int dummy_packing; /* flag to indicate if packing is dummy */
#if CONFIG_PRED_FILTER
- int pred_filter_on_count;
- int pred_filter_off_count;
+ int pred_filter_on_count;
+ int pred_filter_off_count;
#endif
} VP8_COMP;
@@ -786,18 +769,18 @@ void vp8_set_speed_features(VP8_COMP *cpi);
#if CONFIG_DEBUG
#define CHECK_MEM_ERROR(lval,expr) do {\
- lval = (expr); \
- if(!lval) \
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
- "Failed to allocate "#lval" at %s:%d", \
- __FILE__,__LINE__);\
- } while(0)
+ lval = (expr); \
+ if(!lval) \
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
+ "Failed to allocate "#lval" at %s:%d", \
+ __FILE__,__LINE__);\
+ } while(0)
#else
#define CHECK_MEM_ERROR(lval,expr) do {\
- lval = (expr); \
- if(!lval) \
- vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
- "Failed to allocate "#lval);\
- } while(0)
+ lval = (expr); \
+ if(!lval) \
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
+ "Failed to allocate "#lval);\
+ } while(0)
#endif
#endif
diff --git a/vp8/encoder/picklpf.c b/vp8/encoder/picklpf.c
index 171ec3a4d..d17dd9219 100644
--- a/vp8/encoder/picklpf.c
+++ b/vp8/encoder/picklpf.c
@@ -39,635 +39,597 @@ extern void
extern void vp8_loop_filter_frame_segment
(
- VP8_COMMON *cm,
- MACROBLOCKD *xd,
- int default_filt_lvl,
- int segment
+ VP8_COMMON *cm,
+ MACROBLOCKD *xd,
+ int default_filt_lvl,
+ int segment
);
void
-vp8_yv12_copy_partial_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction)
-{
- unsigned char *src_y, *dst_y;
- int yheight;
- int ystride;
- int border;
- int yoffset;
- int linestocopy;
+vp8_yv12_copy_partial_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc, int Fraction) {
+ unsigned char *src_y, *dst_y;
+ int yheight;
+ int ystride;
+ int border;
+ int yoffset;
+ int linestocopy;
- border = src_ybc->border;
- yheight = src_ybc->y_height;
- ystride = src_ybc->y_stride;
+ border = src_ybc->border;
+ yheight = src_ybc->y_height;
+ ystride = src_ybc->y_stride;
- linestocopy = (yheight >> (Fraction + 4));
+ linestocopy = (yheight >> (Fraction + 4));
- if (linestocopy < 1)
- linestocopy = 1;
+ if (linestocopy < 1)
+ linestocopy = 1;
- linestocopy <<= 4;
+ linestocopy <<= 4;
- yoffset = ystride * ((yheight >> 5) * 16 - 8);
- src_y = src_ybc->y_buffer + yoffset;
- dst_y = dst_ybc->y_buffer + yoffset;
+ yoffset = ystride * ((yheight >> 5) * 16 - 8);
+ src_y = src_ybc->y_buffer + yoffset;
+ dst_y = dst_ybc->y_buffer + yoffset;
- vpx_memcpy(dst_y, src_y, ystride *(linestocopy + 16));
+ vpx_memcpy(dst_y, src_y, ystride * (linestocopy + 16));
}
-static int vp8_calc_partial_ssl_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, int Fraction, const vp8_variance_rtcd_vtable_t *rtcd)
-{
- int i, j;
- int Total = 0;
- int srcoffset, dstoffset;
- unsigned char *src = source->y_buffer;
- unsigned char *dst = dest->y_buffer;
+static int vp8_calc_partial_ssl_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, int Fraction, const vp8_variance_rtcd_vtable_t *rtcd) {
+ int i, j;
+ int Total = 0;
+ int srcoffset, dstoffset;
+ unsigned char *src = source->y_buffer;
+ unsigned char *dst = dest->y_buffer;
- int linestocopy = (source->y_height >> (Fraction + 4));
- (void)rtcd;
+ int linestocopy = (source->y_height >> (Fraction + 4));
+ (void)rtcd;
- if (linestocopy < 1)
- linestocopy = 1;
+ if (linestocopy < 1)
+ linestocopy = 1;
- linestocopy <<= 4;
+ linestocopy <<= 4;
- srcoffset = source->y_stride * (dest->y_height >> 5) * 16;
- dstoffset = dest->y_stride * (dest->y_height >> 5) * 16;
+ srcoffset = source->y_stride * (dest->y_height >> 5) * 16;
+ dstoffset = dest->y_stride * (dest->y_height >> 5) * 16;
- src += srcoffset;
- dst += dstoffset;
+ src += srcoffset;
+ dst += dstoffset;
- // Loop through the Y plane raw and reconstruction data summing (square differences)
- for (i = 0; i < linestocopy; i += 16)
- {
- for (j = 0; j < source->y_width; j += 16)
- {
- unsigned int sse;
- Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, dst + j, dest->y_stride, &sse);
- }
-
- src += 16 * source->y_stride;
- dst += 16 * dest->y_stride;
+ // Loop through the Y plane raw and reconstruction data summing (square differences)
+ for (i = 0; i < linestocopy; i += 16) {
+ for (j = 0; j < source->y_width; j += 16) {
+ unsigned int sse;
+ Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, dst + j, dest->y_stride, &sse);
}
- return Total;
+ src += 16 * source->y_stride;
+ dst += 16 * dest->y_stride;
+ }
+
+ return Total;
}
// Enforce a minimum filter level based upon baseline Q
-static int get_min_filter_level(VP8_COMP *cpi, int base_qindex)
-{
- int min_filter_level;
- /*int q = (int) vp8_convert_qindex_to_q(base_qindex);
-
- if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->common.refresh_alt_ref_frame)
- min_filter_level = 0;
- else
- {
- if (q <= 10)
- min_filter_level = 0;
- else if (q <= 64)
- min_filter_level = 1;
- else
- min_filter_level = (q >> 6);
- }
- */
- min_filter_level = 0;
-
- return min_filter_level;
+static int get_min_filter_level(VP8_COMP *cpi, int base_qindex) {
+ int min_filter_level;
+ /*int q = (int) vp8_convert_qindex_to_q(base_qindex);
+
+ if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->common.refresh_alt_ref_frame)
+ min_filter_level = 0;
+ else
+ {
+ if (q <= 10)
+ min_filter_level = 0;
+ else if (q <= 64)
+ min_filter_level = 1;
+ else
+ min_filter_level = (q >> 6);
+ }
+ */
+ min_filter_level = 0;
+
+ return min_filter_level;
}
// Enforce a maximum filter level based upon baseline Q
-static int get_max_filter_level(VP8_COMP *cpi, int base_qindex)
-{
- // PGW August 2006: Highest filter values almost always a bad idea
+static int get_max_filter_level(VP8_COMP *cpi, int base_qindex) {
+ // PGW August 2006: Highest filter values almost always a bad idea
- // jbb chg: 20100118 - not so any more with this overquant stuff allow high values
- // with lots of intra coming in.
- int max_filter_level = MAX_LOOP_FILTER ;//* 3 / 4;
- (void)base_qindex;
+ // jbb chg: 20100118 - not so any more with this overquant stuff allow high values
+ // with lots of intra coming in.
+ int max_filter_level = MAX_LOOP_FILTER;// * 3 / 4;
+ (void)base_qindex;
- if (cpi->twopass.section_intra_rating > 8)
- max_filter_level = MAX_LOOP_FILTER * 3 / 4;
+ if (cpi->twopass.section_intra_rating > 8)
+ max_filter_level = MAX_LOOP_FILTER * 3 / 4;
- return max_filter_level;
+ return max_filter_level;
}
-void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
-
- int best_err = 0;
- int filt_err = 0;
- int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
- int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
- int filt_val;
- int best_filt_val = cm->filter_level;
-
- // Make a copy of the unfiltered / processed recon buffer
- vp8_yv12_copy_partial_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf, 3);
-
- if (cm->frame_type == KEY_FRAME)
- cm->sharpness_level = 0;
- else
- cm->sharpness_level = cpi->oxcf.Sharpness;
-
- if (cm->sharpness_level != cm->last_sharpness_level)
- {
- vp8_loop_filter_update_sharpness(&cm->lf_info, cm->sharpness_level);
- cm->last_sharpness_level = cm->sharpness_level;
- }
+void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
- // Start the search at the previous frame filter level unless it is now out of range.
- if (cm->filter_level < min_filter_level)
- cm->filter_level = min_filter_level;
- else if (cm->filter_level > max_filter_level)
- cm->filter_level = max_filter_level;
+ int best_err = 0;
+ int filt_err = 0;
+ int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
+ int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
+ int filt_val;
+ int best_filt_val = cm->filter_level;
- filt_val = cm->filter_level;
- best_filt_val = filt_val;
+ // Make a copy of the unfiltered / processed recon buffer
+ vp8_yv12_copy_partial_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf, 3);
- // Get the err using the previous frame's filter value.
- vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
+ if (cm->frame_type == KEY_FRAME)
+ cm->sharpness_level = 0;
+ else
+ cm->sharpness_level = cpi->oxcf.Sharpness;
- best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
+ if (cm->sharpness_level != cm->last_sharpness_level) {
+ vp8_loop_filter_update_sharpness(&cm->lf_info, cm->sharpness_level);
+ cm->last_sharpness_level = cm->sharpness_level;
+ }
- // Re-instate the unfiltered frame
- vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
+ // Start the search at the previous frame filter level unless it is now out of range.
+ if (cm->filter_level < min_filter_level)
+ cm->filter_level = min_filter_level;
+ else if (cm->filter_level > max_filter_level)
+ cm->filter_level = max_filter_level;
- filt_val -= (1 + ((filt_val > 10) ? 1 : 0));
+ filt_val = cm->filter_level;
+ best_filt_val = filt_val;
- // Search lower filter levels
- while (filt_val >= min_filter_level)
- {
- // Apply the loop filter
- vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
+ // Get the err using the previous frame's filter value.
+ vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
- // Get the err for filtered frame
- filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
+ best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
- // Re-instate the unfiltered frame
- vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
+ // Re-instate the unfiltered frame
+ vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
+ filt_val -= (1 + ((filt_val > 10) ? 1 : 0));
- // Update the best case record or exit loop.
- if (filt_err < best_err)
- {
- best_err = filt_err;
- best_filt_val = filt_val;
- }
- else
- break;
-
- // Adjust filter level
- filt_val -= (1 + ((filt_val > 10) ? 1 : 0));
- }
+ // Search lower filter levels
+ while (filt_val >= min_filter_level) {
+ // Apply the loop filter
+ vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
+
+ // Get the err for filtered frame
+ filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
+
+ // Re-instate the unfiltered frame
+ vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
- // Search up (note that we have already done filt_val = cm->filter_level)
- filt_val = cm->filter_level + (1 + ((filt_val > 10) ? 1 : 0));
- if (best_filt_val == cm->filter_level)
- {
- // Resist raising filter level for very small gains
- best_err -= (best_err >> 10);
+ // Update the best case record or exit loop.
+ if (filt_err < best_err) {
+ best_err = filt_err;
+ best_filt_val = filt_val;
+ } else
+ break;
+
+ // Adjust filter level
+ filt_val -= (1 + ((filt_val > 10) ? 1 : 0));
+ }
- while (filt_val < max_filter_level)
- {
- // Apply the loop filter
- vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
+ // Search up (note that we have already done filt_val = cm->filter_level)
+ filt_val = cm->filter_level + (1 + ((filt_val > 10) ? 1 : 0));
- // Get the err for filtered frame
- filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
+ if (best_filt_val == cm->filter_level) {
+ // Resist raising filter level for very small gains
+ best_err -= (best_err >> 10);
- // Re-instate the unfiltered frame
- vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
+ while (filt_val < max_filter_level) {
+ // Apply the loop filter
+ vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
- // Update the best case record or exit loop.
- if (filt_err < best_err)
- {
- // Do not raise filter level if improvement is < 1 part in 4096
- best_err = filt_err - (filt_err >> 10);
+ // Get the err for filtered frame
+ filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
- best_filt_val = filt_val;
- }
- else
- break;
+ // Re-instate the unfiltered frame
+ vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
- // Adjust filter level
- filt_val += (1 + ((filt_val > 10) ? 1 : 0));
- }
+ // Update the best case record or exit loop.
+ if (filt_err < best_err) {
+ // Do not raise filter level if improvement is < 1 part in 4096
+ best_err = filt_err - (filt_err >> 10);
+
+ best_filt_val = filt_val;
+ } else
+ break;
+
+ // Adjust filter level
+ filt_val += (1 + ((filt_val > 10) ? 1 : 0));
}
+ }
- cm->filter_level = best_filt_val;
+ cm->filter_level = best_filt_val;
- if (cm->filter_level < min_filter_level)
- cm->filter_level = min_filter_level;
+ if (cm->filter_level < min_filter_level)
+ cm->filter_level = min_filter_level;
- if (cm->filter_level > max_filter_level)
- cm->filter_level = max_filter_level;
+ if (cm->filter_level > max_filter_level)
+ cm->filter_level = max_filter_level;
}
// Stub function for now Alt LF not used
-void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val)
-{
+void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val) {
}
#if CONFIG_FEATUREUPDATES
-void vp8cx_pick_filter_level_sg(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi, int segment)
-{
- VP8_COMMON *cm = &cpi->common;
+void vp8cx_pick_filter_level_sg(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi, int segment) {
+ VP8_COMMON *cm = &cpi->common;
- int best_err = 0;
- int filt_err = 0;
- int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
- int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
+ int best_err = 0;
+ int filt_err = 0;
+ int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
+ int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
- int filter_step;
- int filt_high = 0;
- int filt_mid = cm->filter_level; // Start search at previous frame filter level
- int filt_low = 0;
- int filt_best;
- int filt_direction = 0;
+ int filter_step;
+ int filt_high = 0;
+ int filt_mid = cm->filter_level; // Start search at previous frame filter level
+ int filt_low = 0;
+ int filt_best;
+ int filt_direction = 0;
- int Bias = 0; // Bias against raising loop filter and in favour of lowering it
+ int Bias = 0; // Bias against raising loop filter and in favour of lowering it
- // Make a copy of the unfiltered / processed recon buffer
+ // Make a copy of the unfiltered / processed recon buffer
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(cm->frame_to_show, &cpi->last_frame_uf);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(cm->frame_to_show, &cpi->last_frame_uf);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf);
- }
+ {
+ vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf);
+ }
#endif
- if (cm->frame_type == KEY_FRAME)
- cm->sharpness_level = 0;
- else
- cm->sharpness_level = cpi->oxcf.Sharpness;
+ if (cm->frame_type == KEY_FRAME)
+ cm->sharpness_level = 0;
+ else
+ cm->sharpness_level = cpi->oxcf.Sharpness;
- // Start the search at the previous frame filter level unless it is now out of range.
- filt_mid = cm->filter_level;
+ // Start the search at the previous frame filter level unless it is now out of range.
+ filt_mid = cm->filter_level;
- if (filt_mid < min_filter_level)
- filt_mid = min_filter_level;
- else if (filt_mid > max_filter_level)
- filt_mid = max_filter_level;
+ if (filt_mid < min_filter_level)
+ filt_mid = min_filter_level;
+ else if (filt_mid > max_filter_level)
+ filt_mid = max_filter_level;
- // Define the initial step size
- filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
+ // Define the initial step size
+ filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
- // Get baseline error score
- vp8cx_set_alt_lf_level(cpi, filt_mid);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_mid,segment);
+ // Get baseline error score
+ vp8cx_set_alt_lf_level(cpi, filt_mid);
+ vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_mid, segment);
- best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- filt_best = filt_mid;
+ best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_best = filt_mid;
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#endif
- while (filter_step > 0)
- {
- Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; //PGW change 12/12/06 for small images
+ while (filter_step > 0) {
+ Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; // PGW change 12/12/06 for small images
- // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
- if (cpi->twopass.section_intra_rating < 20)
- Bias = Bias * cpi->twopass.section_intra_rating / 20;
+ // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
+ if (cpi->twopass.section_intra_rating < 20)
+ Bias = Bias * cpi->twopass.section_intra_rating / 20;
- // yx, bias less for large block size
- if(cpi->common.txfm_mode == ALLOW_8X8)
- Bias >>= 1;
+ // yx, bias less for large block size
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ Bias >>= 1;
- filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
- filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
+ filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
+ filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
- if ((filt_direction <= 0) && (filt_low != filt_mid))
- {
- // Get Low filter error score
- vp8cx_set_alt_lf_level(cpi, filt_low);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_low, segment);
+ if ((filt_direction <= 0) && (filt_low != filt_mid)) {
+ // Get Low filter error score
+ vp8cx_set_alt_lf_level(cpi, filt_low);
+ vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_low, segment);
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#endif
- // If value is close to the best so far then bias towards a lower loop filter value.
- if ((filt_err - Bias) < best_err)
- {
- // Was it actually better than the previous best?
- if (filt_err < best_err)
- best_err = filt_err;
+ // If value is close to the best so far then bias towards a lower loop filter value.
+ if ((filt_err - Bias) < best_err) {
+ // Was it actually better than the previous best?
+ if (filt_err < best_err)
+ best_err = filt_err;
- filt_best = filt_low;
- }
- }
+ filt_best = filt_low;
+ }
+ }
- // Now look at filt_high
- if ((filt_direction >= 0) && (filt_high != filt_mid))
- {
- vp8cx_set_alt_lf_level(cpi, filt_high);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_high, segment);
+ // Now look at filt_high
+ if ((filt_direction >= 0) && (filt_high != filt_mid)) {
+ vp8cx_set_alt_lf_level(cpi, filt_high);
+ vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_high, segment);
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#endif
-
- // Was it better than the previous best?
- if (filt_err < (best_err - Bias))
- {
- best_err = filt_err;
- filt_best = filt_high;
- }
- }
-
- // Half the step distance if the best filter value was the same as last time
- if (filt_best == filt_mid)
- {
- filter_step = filter_step / 2;
- filt_direction = 0;
- }
- else
- {
- filt_direction = (filt_best < filt_mid) ? -1 : 1;
- filt_mid = filt_best;
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
+#endif
+
+ // Was it better than the previous best?
+ if (filt_err < (best_err - Bias)) {
+ best_err = filt_err;
+ filt_best = filt_high;
+ }
}
- cm->filter_level = filt_best;
+ // Half the step distance if the best filter value was the same as last time
+ if (filt_best == filt_mid) {
+ filter_step = filter_step / 2;
+ filt_direction = 0;
+ } else {
+ filt_direction = (filt_best < filt_mid) ? -1 : 1;
+ filt_mid = filt_best;
+ }
+ }
+
+ cm->filter_level = filt_best;
}
-void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
-{
- VP8_COMMON *oci = &cpi->common;
- MODE_INFO *mi = oci->mi;
- int filt_lev[2];
- int i, j;
- MACROBLOCKD * const xd = &cpi->mb.e_mbd;
- int max_seg;
- int mb_index = 0;
-
- // pick the loop filter for each segment after segment 0
- for (i = 1; i < MAX_MB_SEGMENTS; i++)
- {
- // if the segment loop filter is active
- if (segfeature_active(xd, i, SEG_LVL_ALT_LF))
- {
- set_segdata(xd, i, SEG_LVL_ALT_LF, 0);
- vp8cx_pick_filter_level_sg(sd, cpi, i);
- filt_lev[i] = oci->filter_level;
- }
+void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
+ VP8_COMMON *oci = &cpi->common;
+ MODE_INFO *mi = oci->mi;
+ int filt_lev[2];
+ int i, j;
+ MACROBLOCKD *const xd = &cpi->mb.e_mbd;
+ int max_seg;
+ int mb_index = 0;
+
+ // pick the loop filter for each segment after segment 0
+ for (i = 1; i < MAX_MB_SEGMENTS; i++) {
+ // if the segment loop filter is active
+ if (segfeature_active(xd, i, SEG_LVL_ALT_LF)) {
+ set_segdata(xd, i, SEG_LVL_ALT_LF, 0);
+ vp8cx_pick_filter_level_sg(sd, cpi, i);
+ filt_lev[i] = oci->filter_level;
+ }
+ }
+
+ // do the 0 segment ( this filter also picks the filter value for all
+ // the not enabled features )
+
+ // TODO : Fix the code if segment 0 is the one with seg_lvl_alt_lf on
+ // right now assumes segment 0 gets base loop filter and the rest are
+ // deltas off of segment 0.
+ set_segdata(xd, 0, SEG_LVL_ALT_LF, 0);
+ vp8cx_pick_filter_level_sg(sd, cpi, 0);
+ filt_lev[0] = oci->filter_level;
+
+ // convert the best filter level for the mbs of the segment to
+ // a delta from 0
+ for (i = 1; i < MAX_MB_SEGMENTS; i++)
+ if (segfeature_active(xd, i, SEG_LVL_ALT_LF)) {
+ set_segdata(xd, i, SEG_LVL_ALT_LF, filt_lev[i] - filt_lev[0]);
+ xd->update_mb_segmentation_data !=
+ segfeature_changed(xd, i, SEG_LVL_ALT_LF);
}
-
- // do the 0 segment ( this filter also picks the filter value for all
- // the not enabled features )
-
- // TODO : Fix the code if segment 0 is the one with seg_lvl_alt_lf on
- // right now assumes segment 0 gets base loop filter and the rest are
- // deltas off of segment 0.
- set_segdata(xd, 0, SEG_LVL_ALT_LF, 0);
- vp8cx_pick_filter_level_sg(sd, cpi, 0);
- filt_lev[0] = oci->filter_level;
-
- // convert the best filter level for the mbs of the segment to
- // a delta from 0
- for (i = 1; i < MAX_MB_SEGMENTS; i++)
- if (segfeature_active(xd, i, SEG_LVL_ALT_LF))
- {
- set_segdata(xd, i, SEG_LVL_ALT_LF, filt_lev[i] - filt_lev[0]);
- xd->update_mb_segmentation_data !=
- segfeature_changed( xd,i,SEG_LVL_ALT_LF);
- }
}
#else
-void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
+void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
- int best_err = 0;
- int filt_err = 0;
- int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
- int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
+ int best_err = 0;
+ int filt_err = 0;
+ int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
+ int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
- int filter_step;
- int filt_high = 0;
- int filt_mid = cm->filter_level; // Start search at previous frame filter level
- int filt_low = 0;
- int filt_best;
- int filt_direction = 0;
+ int filter_step;
+ int filt_high = 0;
+ int filt_mid = cm->filter_level; // Start search at previous frame filter level
+ int filt_low = 0;
+ int filt_best;
+ int filt_direction = 0;
- int Bias = 0; // Bias against raising loop filter and in favour of lowering it
+ int Bias = 0; // Bias against raising loop filter and in favour of lowering it
- // Make a copy of the unfiltered / processed recon buffer
+ // Make a copy of the unfiltered / processed recon buffer
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(cm->frame_to_show, &cpi->last_frame_uf);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(cm->frame_to_show, &cpi->last_frame_uf);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf);
- }
+ {
+ vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf);
+ }
#endif
- if (cm->frame_type == KEY_FRAME)
- cm->sharpness_level = 0;
- else
- cm->sharpness_level = cpi->oxcf.Sharpness;
+ if (cm->frame_type == KEY_FRAME)
+ cm->sharpness_level = 0;
+ else
+ cm->sharpness_level = cpi->oxcf.Sharpness;
- // Start the search at the previous frame filter level unless it is now out of range.
- filt_mid = cm->filter_level;
+ // Start the search at the previous frame filter level unless it is now out of range.
+ filt_mid = cm->filter_level;
- if (filt_mid < min_filter_level)
- filt_mid = min_filter_level;
- else if (filt_mid > max_filter_level)
- filt_mid = max_filter_level;
+ if (filt_mid < min_filter_level)
+ filt_mid = min_filter_level;
+ else if (filt_mid > max_filter_level)
+ filt_mid = max_filter_level;
- // Define the initial step size
- filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
+ // Define the initial step size
+ filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
- // Get baseline error score
- vp8cx_set_alt_lf_level(cpi, filt_mid);
- vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid);
+ // Get baseline error score
+ vp8cx_set_alt_lf_level(cpi, filt_mid);
+ vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid);
- best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- filt_best = filt_mid;
+ best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_best = filt_mid;
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#endif
- while (filter_step > 0)
- {
- Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; //PGW change 12/12/06 for small images
+ while (filter_step > 0) {
+ Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; // PGW change 12/12/06 for small images
- // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
- if (cpi->twopass.section_intra_rating < 20)
- Bias = Bias * cpi->twopass.section_intra_rating / 20;
+ // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
+ if (cpi->twopass.section_intra_rating < 20)
+ Bias = Bias * cpi->twopass.section_intra_rating / 20;
- // yx, bias less for large block size
- if(cpi->common.txfm_mode == ALLOW_8X8)
- Bias >>= 1;
+ // yx, bias less for large block size
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ Bias >>= 1;
- filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
- filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
+ filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
+ filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
- if ((filt_direction <= 0) && (filt_low != filt_mid))
- {
- // Get Low filter error score
- vp8cx_set_alt_lf_level(cpi, filt_low);
- vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low);
+ if ((filt_direction <= 0) && (filt_low != filt_mid)) {
+ // Get Low filter error score
+ vp8cx_set_alt_lf_level(cpi, filt_low);
+ vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low);
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#endif
- // If value is close to the best so far then bias towards a lower loop filter value.
- if ((filt_err - Bias) < best_err)
- {
- // Was it actually better than the previous best?
- if (filt_err < best_err)
- best_err = filt_err;
+ // If value is close to the best so far then bias towards a lower loop filter value.
+ if ((filt_err - Bias) < best_err) {
+ // Was it actually better than the previous best?
+ if (filt_err < best_err)
+ best_err = filt_err;
- filt_best = filt_low;
- }
- }
+ filt_best = filt_low;
+ }
+ }
- // Now look at filt_high
- if ((filt_direction >= 0) && (filt_high != filt_mid))
- {
- vp8cx_set_alt_lf_level(cpi, filt_high);
- vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high);
+ // Now look at filt_high
+ if ((filt_direction >= 0) && (filt_high != filt_mid)) {
+ vp8cx_set_alt_lf_level(cpi, filt_high);
+ vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high);
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
+ filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
- // Re-instate the unfiltered frame
+ // Re-instate the unfiltered frame
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
+ if (cm->rtcd.flags & HAS_NEON)
#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
+ {
+ vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
+ }
#if CONFIG_RUNTIME_CPU_DETECT
- else
+ else
#endif
#endif
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#endif
-
- // Was it better than the previous best?
- if (filt_err < (best_err - Bias))
- {
- best_err = filt_err;
- filt_best = filt_high;
- }
- }
-
- // Half the step distance if the best filter value was the same as last time
- if (filt_best == filt_mid)
- {
- filter_step = filter_step / 2;
- filt_direction = 0;
- }
- else
- {
- filt_direction = (filt_best < filt_mid) ? -1 : 1;
- filt_mid = filt_best;
- }
+ {
+ vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
+ }
+#endif
+
+ // Was it better than the previous best?
+ if (filt_err < (best_err - Bias)) {
+ best_err = filt_err;
+ filt_best = filt_high;
+ }
+ }
+
+ // Half the step distance if the best filter value was the same as last time
+ if (filt_best == filt_mid) {
+ filter_step = filter_step / 2;
+ filt_direction = 0;
+ } else {
+ filt_direction = (filt_best < filt_mid) ? -1 : 1;
+ filt_mid = filt_best;
}
+ }
- cm->filter_level = filt_best;
+ cm->filter_level = filt_best;
}
#endif
diff --git a/vp8/encoder/ppc/csystemdependent.c b/vp8/encoder/ppc/csystemdependent.c
index 49b1dd6a9..96c9a0384 100644
--- a/vp8/encoder/ppc/csystemdependent.c
+++ b/vp8/encoder/ppc/csystemdependent.c
@@ -115,42 +115,41 @@ extern sub_pixel_variance_function vp8_sub_pixel_variance16x16_ppc;
extern unsigned int vp8_get8x8var_ppc(unsigned char *src_ptr, int source_stride, unsigned char *ref_ptr, int recon_stride, unsigned int *SSE, int *Sum);
extern unsigned int vp8_get16x16var_ppc(unsigned char *src_ptr, int source_stride, unsigned char *ref_ptr, int recon_stride, unsigned int *SSE, int *Sum);
-void vp8_cmachine_specific_config(void)
-{
- // Pure C:
- vp8_mbuverror = vp8_mbuverror_c;
- vp8_fast_quantize_b = vp8_fast_quantize_b_c;
- vp8_short_fdct4x4 = vp8_short_fdct4x4_ppc;
- vp8_short_fdct8x4 = vp8_short_fdct8x4_ppc;
- vp8_fast_fdct4x4 = vp8_short_fdct4x4_ppc;
- vp8_fast_fdct8x4 = vp8_short_fdct8x4_ppc;
- short_walsh4x4 = vp8_short_walsh4x4_c;
-
- vp8_variance4x4 = vp8_variance4x4_ppc;
- vp8_variance8x8 = vp8_variance8x8_ppc;
- vp8_variance8x16 = vp8_variance8x16_ppc;
- vp8_variance16x8 = vp8_variance16x8_ppc;
- vp8_variance16x16 = vp8_variance16x16_ppc;
- vp8_mse16x16 = vp8_mse16x16_ppc;
-
- vp8_sub_pixel_variance4x4 = vp8_sub_pixel_variance4x4_ppc;
- vp8_sub_pixel_variance8x8 = vp8_sub_pixel_variance8x8_ppc;
- vp8_sub_pixel_variance8x16 = vp8_sub_pixel_variance8x16_ppc;
- vp8_sub_pixel_variance16x8 = vp8_sub_pixel_variance16x8_ppc;
- vp8_sub_pixel_variance16x16 = vp8_sub_pixel_variance16x16_ppc;
-
- vp8_get_mb_ss = vp8_get_mb_ss_c;
-
- vp8_sad16x16 = vp8_sad16x16_ppc;
- vp8_sad16x8 = vp8_sad16x8_ppc;
- vp8_sad8x16 = vp8_sad8x16_ppc;
- vp8_sad8x8 = vp8_sad8x8_ppc;
- vp8_sad4x4 = vp8_sad4x4_ppc;
-
- vp8_block_error = vp8_block_error_ppc;
- vp8_mbblock_error = vp8_mbblock_error_c;
-
- vp8_subtract_b = vp8_subtract_b_c;
- vp8_subtract_mby = vp8_subtract_mby_ppc;
- vp8_subtract_mbuv = vp8_subtract_mbuv_ppc;
+void vp8_cmachine_specific_config(void) {
+ // Pure C:
+ vp8_mbuverror = vp8_mbuverror_c;
+ vp8_fast_quantize_b = vp8_fast_quantize_b_c;
+ vp8_short_fdct4x4 = vp8_short_fdct4x4_ppc;
+ vp8_short_fdct8x4 = vp8_short_fdct8x4_ppc;
+ vp8_fast_fdct4x4 = vp8_short_fdct4x4_ppc;
+ vp8_fast_fdct8x4 = vp8_short_fdct8x4_ppc;
+ short_walsh4x4 = vp8_short_walsh4x4_c;
+
+ vp8_variance4x4 = vp8_variance4x4_ppc;
+ vp8_variance8x8 = vp8_variance8x8_ppc;
+ vp8_variance8x16 = vp8_variance8x16_ppc;
+ vp8_variance16x8 = vp8_variance16x8_ppc;
+ vp8_variance16x16 = vp8_variance16x16_ppc;
+ vp8_mse16x16 = vp8_mse16x16_ppc;
+
+ vp8_sub_pixel_variance4x4 = vp8_sub_pixel_variance4x4_ppc;
+ vp8_sub_pixel_variance8x8 = vp8_sub_pixel_variance8x8_ppc;
+ vp8_sub_pixel_variance8x16 = vp8_sub_pixel_variance8x16_ppc;
+ vp8_sub_pixel_variance16x8 = vp8_sub_pixel_variance16x8_ppc;
+ vp8_sub_pixel_variance16x16 = vp8_sub_pixel_variance16x16_ppc;
+
+ vp8_get_mb_ss = vp8_get_mb_ss_c;
+
+ vp8_sad16x16 = vp8_sad16x16_ppc;
+ vp8_sad16x8 = vp8_sad16x8_ppc;
+ vp8_sad8x16 = vp8_sad8x16_ppc;
+ vp8_sad8x8 = vp8_sad8x8_ppc;
+ vp8_sad4x4 = vp8_sad4x4_ppc;
+
+ vp8_block_error = vp8_block_error_ppc;
+ vp8_mbblock_error = vp8_mbblock_error_c;
+
+ vp8_subtract_b = vp8_subtract_b_c;
+ vp8_subtract_mby = vp8_subtract_mby_ppc;
+ vp8_subtract_mbuv = vp8_subtract_mbuv_ppc;
}
diff --git a/vp8/encoder/psnr.c b/vp8/encoder/psnr.c
index 7ecf6d7cd..5aa5587ee 100644
--- a/vp8/encoder/psnr.c
+++ b/vp8/encoder/psnr.c
@@ -15,17 +15,16 @@
#define MAX_PSNR 100
-double vp8_mse2psnr(double Samples, double Peak, double Mse)
-{
- double psnr;
+double vp8_mse2psnr(double Samples, double Peak, double Mse) {
+ double psnr;
- if ((double)Mse > 0.0)
- psnr = 10.0 * log10(Peak * Peak * Samples / Mse);
- else
- psnr = MAX_PSNR; // Limit to prevent / 0
+ if ((double)Mse > 0.0)
+ psnr = 10.0 * log10(Peak * Peak * Samples / Mse);
+ else
+ psnr = MAX_PSNR; // Limit to prevent / 0
- if (psnr > MAX_PSNR)
- psnr = MAX_PSNR;
+ if (psnr > MAX_PSNR)
+ psnr = MAX_PSNR;
- return psnr;
+ return psnr;
}
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c
index dace31cba..821507c62 100644
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -22,97 +22,89 @@
extern int enc_debug;
#endif
-void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
-{
- int i, rc, eob;
- int zbin;
- int x, y, z, sz;
- short *zbin_boost_ptr = b->zrun_zbin_boost;
- short *coeff_ptr = b->coeff;
- short *zbin_ptr = b->zbin;
- short *round_ptr = b->round;
- short *quant_ptr = b->quant;
- unsigned char *quant_shift_ptr = b->quant_shift;
- short *qcoeff_ptr = d->qcoeff;
- short *dqcoeff_ptr = d->dqcoeff;
- short *dequant_ptr = d->dequant;
- short zbin_oq_value = b->zbin_extra;
-
- vpx_memset(qcoeff_ptr, 0, 32);
- vpx_memset(dqcoeff_ptr, 0, 32);
-
- eob = -1;
-
- for (i = 0; i < b->eob_max_offset; i++)
- {
- rc = vp8_default_zig_zag1d[i];
- z = coeff_ptr[rc];
-
- zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value;
- zbin_boost_ptr ++;
-
- sz = (z >> 31); // sign of z
- x = (z ^ sz) - sz; // x = abs(z)
-
- if (x >= zbin)
- {
- x += round_ptr[rc];
- y = (((x * quant_ptr[rc]) >> 16) + x)
- >> quant_shift_ptr[rc]; // quantize (x)
- x = (y ^ sz) - sz; // get the sign back
- qcoeff_ptr[rc] = x; // write to destination
- dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
-
- if (y)
- {
- eob = i; // last nonzero coeffs
- zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
- }
- }
+void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d) {
+ int i, rc, eob;
+ int zbin;
+ int x, y, z, sz;
+ short *zbin_boost_ptr = b->zrun_zbin_boost;
+ short *coeff_ptr = b->coeff;
+ short *zbin_ptr = b->zbin;
+ short *round_ptr = b->round;
+ short *quant_ptr = b->quant;
+ unsigned char *quant_shift_ptr = b->quant_shift;
+ short *qcoeff_ptr = d->qcoeff;
+ short *dqcoeff_ptr = d->dqcoeff;
+ short *dequant_ptr = d->dequant;
+ short zbin_oq_value = b->zbin_extra;
+
+ vpx_memset(qcoeff_ptr, 0, 32);
+ vpx_memset(dqcoeff_ptr, 0, 32);
+
+ eob = -1;
+
+ for (i = 0; i < b->eob_max_offset; i++) {
+ rc = vp8_default_zig_zag1d[i];
+ z = coeff_ptr[rc];
+
+ zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value;
+ zbin_boost_ptr++;
+
+ sz = (z >> 31); // sign of z
+ x = (z ^ sz) - sz; // x = abs(z)
+
+ if (x >= zbin) {
+ x += round_ptr[rc];
+ y = (((x * quant_ptr[rc]) >> 16) + x)
+ >> quant_shift_ptr[rc]; // quantize (x)
+ x = (y ^ sz) - sz; // get the sign back
+ qcoeff_ptr[rc] = x; // write to destination
+ dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
+
+ if (y) {
+ eob = i; // last nonzero coeffs
+ zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
+ }
}
+ }
- d->eob = eob + 1;
+ d->eob = eob + 1;
}
-void vp8_quantize_mby_c(MACROBLOCK *x)
-{
- int i;
- int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+void vp8_quantize_mby_c(MACROBLOCK *x) {
+ int i;
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for (i = 0; i < 16; i++)
- x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
+ for (i = 0; i < 16; i++)
+ x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
- if(has_2nd_order)
- x->quantize_b(&x->block[24], &x->e_mbd.block[24]);
+ if (has_2nd_order)
+ x->quantize_b(&x->block[24], &x->e_mbd.block[24]);
}
-void vp8_quantize_mb_c(MACROBLOCK *x)
-{
- int i;
- int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+void vp8_quantize_mb_c(MACROBLOCK *x) {
+ int i;
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for (i = 0; i < 24+has_2nd_order; i++)
- x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
+ for (i = 0; i < 24 + has_2nd_order; i++)
+ x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
}
-void vp8_quantize_mbuv_c(MACROBLOCK *x)
-{
- int i;
+void vp8_quantize_mbuv_c(MACROBLOCK *x) {
+ int i;
- for (i = 16; i < 24; i++)
- x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
+ for (i = 16; i < 24; i++)
+ x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
}
-void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
-{
+void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d) {
int i, rc, eob;
int zbin;
int x, y, z, sz;
@@ -127,14 +119,13 @@ void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
short *dqcoeff_ptr = d->dqcoeff;
short *dequant_ptr = d->dequant;
short zbin_oq_value = b->zbin_extra;
- //double q2nd = 4;
+ // double q2nd = 4;
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
eob = -1;
- for (i = 0; i < b->eob_max_offset_8x8; i++)
- {
+ for (i = 0; i < b->eob_max_offset_8x8; i++) {
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
@@ -145,8 +136,7 @@ void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
- if (x >= zbin)
- {
+ if (x >= zbin) {
x += (round_ptr[rc]);
y = ((int)((int)(x * quant_ptr[rc]) >> 16) + x)
>> quant_shift_ptr[rc]; // quantize (x)
@@ -154,8 +144,7 @@ void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
qcoeff_ptr[rc] = x; // write to destination
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
- if (y)
- {
+ if (y) {
eob = i; // last nonzero coeffs
zbin_zrun_index = 0;
}
@@ -165,8 +154,7 @@ void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
d->eob = eob + 1;
}
-void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
-{
+void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d) {
int i, rc, eob;
int zbin;
int x, y, z, sz;
@@ -181,33 +169,30 @@ void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
short *dequant_ptr = d->dequant;
short zbin_oq_value = b->zbin_extra;
- vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
- vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
+ vpx_memset(qcoeff_ptr, 0, 64 * sizeof(short));
+ vpx_memset(dqcoeff_ptr, 0, 64 * sizeof(short));
eob = -1;
- for (i = 0; i < b->eob_max_offset_8x8; i++)
- {
+ for (i = 0; i < b->eob_max_offset_8x8; i++) {
rc = vp8_default_zig_zag1d_8x8[i];
z = coeff_ptr[rc];
- zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value);
- zbin_boost_ptr ++;
+ zbin = (zbin_ptr[rc != 0] + *zbin_boost_ptr + zbin_oq_value);
+ zbin_boost_ptr++;
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
- if (x >= zbin)
- {
- x += (round_ptr[rc!=0]);
- y = ((int)(((int)(x * quant_ptr[rc!=0]) >> 16) + x))
- >> quant_shift_ptr[rc!=0]; // quantize (x)
+ if (x >= zbin) {
+ x += (round_ptr[rc != 0]);
+ y = ((int)(((int)(x * quant_ptr[rc != 0]) >> 16) + x))
+ >> quant_shift_ptr[rc != 0]; // quantize (x)
x = (y ^ sz) - sz; // get the sign back
qcoeff_ptr[rc] = x; // write to destination
- dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
+ dqcoeff_ptr[rc] = x * dequant_ptr[rc != 0]; // dequantized value
- if (y)
- {
+ if (y) {
eob = i; // last nonzero coeffs
zbin_boost_ptr = b->zrun_zbin_boost_8x8;
}
@@ -217,17 +202,15 @@ void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
d->eob = eob + 1;
}
-void vp8_quantize_mby_8x8(MACROBLOCK *x)
-{
+void vp8_quantize_mby_8x8(MACROBLOCK *x) {
int i;
- int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for(i = 0; i < 16; i ++)
- {
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+ for (i = 0; i < 16; i ++) {
x->e_mbd.block[i].eob = 0;
}
x->e_mbd.block[24].eob = 0;
- for (i = 0; i < 16; i+=4)
+ for (i = 0; i < 16; i += 4)
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
if (has_2nd_order)
@@ -235,31 +218,27 @@ void vp8_quantize_mby_8x8(MACROBLOCK *x)
}
-void vp8_quantize_mb_8x8(MACROBLOCK *x)
-{
+void vp8_quantize_mb_8x8(MACROBLOCK *x) {
int i;
- int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
- && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for(i = 0; i < 25; i ++)
- {
+ int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
+ for (i = 0; i < 25; i ++) {
x->e_mbd.block[i].eob = 0;
}
- for (i = 0; i < 24; i+=4)
+ for (i = 0; i < 24; i += 4)
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
if (has_2nd_order)
x->quantize_b_2x2(&x->block[24], &x->e_mbd.block[24]);
}
-void vp8_quantize_mbuv_8x8(MACROBLOCK *x)
-{
+void vp8_quantize_mbuv_8x8(MACROBLOCK *x) {
int i;
- for(i = 16; i < 24; i ++)
- {
+ for (i = 16; i < 24; i ++) {
x->e_mbd.block[i].eob = 0;
}
- for (i = 16; i < 24; i+=4)
+ for (i = 16; i < 24; i += 4)
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
}
@@ -269,347 +248,321 @@ void vp8_quantize_mbuv_8x8(MACROBLOCK *x)
* these two C functions if corresponding optimized routine is not available.
* NEON optimized version implements currently the fast quantization for pair
* of blocks. */
-void vp8_regular_quantize_b_pair(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
-{
- vp8_regular_quantize_b(b1, d1);
- vp8_regular_quantize_b(b2, d2);
+void vp8_regular_quantize_b_pair(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2) {
+ vp8_regular_quantize_b(b1, d1);
+ vp8_regular_quantize_b(b2, d2);
}
static void invert_quant(short *quant,
- unsigned char *shift, short d)
-{
- unsigned t;
- int l;
- t = d;
- for(l = 0; t > 1; l++)
- t>>=1;
- t = 1 + (1<<(16+l))/d;
- *quant = (short)(t - (1<<16));
- *shift = l;
+ unsigned char *shift, short d) {
+ unsigned t;
+ int l;
+ t = d;
+ for (l = 0; t > 1; l++)
+ t >>= 1;
+ t = 1 + (1 << (16 + l)) / d;
+ *quant = (short)(t - (1 << 16));
+ *shift = l;
}
-void vp8cx_init_quantizer(VP8_COMP *cpi)
-{
- int i;
- int quant_val;
- int Q;
- int zbin_boost[16] = { 0, 0, 8, 10, 12, 14, 16, 20,
- 24, 28, 32, 36, 40, 44, 44, 44};
+void vp8cx_init_quantizer(VP8_COMP *cpi) {
+ int i;
+ int quant_val;
+ int Q;
+ int zbin_boost[16] = { 0, 0, 8, 10, 12, 14, 16, 20,
+ 24, 28, 32, 36, 40, 44, 44, 44
+ };
- int zbin_boost_8x8[64] = { 0, 0, 0, 8, 8, 8, 10, 12,
- 14, 16, 18, 20, 22, 24, 26, 28,
- 30, 32, 34, 36, 38, 40, 42, 44,
- 46, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48 };
+ int zbin_boost_8x8[64] = { 0, 0, 0, 8, 8, 8, 10, 12,
+ 14, 16, 18, 20, 22, 24, 26, 28,
+ 30, 32, 34, 36, 38, 40, 42, 44,
+ 46, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48
+ };
- int qrounding_factor = 48;
+ int qrounding_factor = 48;
- for (Q = 0; Q < QINDEX_RANGE; Q++)
- {
- int qzbin_factor = (vp8_dc_quant(Q,0) < 148) ? 84 : 80;
+ for (Q = 0; Q < QINDEX_RANGE; Q++) {
+ int qzbin_factor = (vp8_dc_quant(Q, 0) < 148) ? 84 : 80;
#if CONFIG_LOSSLESS
- if(cpi->oxcf.lossless)
- {
- if (Q==0)
- {
- qzbin_factor = 64;
- qrounding_factor = 64;
- }
- }
+ if (cpi->oxcf.lossless) {
+ if (Q == 0) {
+ qzbin_factor = 64;
+ qrounding_factor = 64;
+ }
+ }
#endif
- // dc values
- quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
- invert_quant(cpi->Y1quant[Q] + 0,
- cpi->Y1quant_shift[Q] + 0, quant_val);
- cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y1zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.Y1dequant[Q][0] = quant_val;
- cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
- cpi->zrun_zbin_boost_y1_8x8[Q][0] =
- ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
-
- quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
- invert_quant(cpi->Y2quant[Q] + 0,
- cpi->Y2quant_shift[Q] + 0, quant_val);
- cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y2zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.Y2dequant[Q][0] = quant_val;
- cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
- cpi->zrun_zbin_boost_y2_8x8[Q][0] =
- ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
-
- quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
- invert_quant(cpi->UVquant[Q] + 0,
- cpi->UVquant_shift[Q] + 0, quant_val);
- cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
- cpi->UVzbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
- cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.UVdequant[Q][0] = quant_val;
- cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
- cpi->zrun_zbin_boost_uv_8x8[Q][0] =
- ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
-
- // all the 4x4 ac values = ;
- for (i = 1; i < 16; i++)
- {
- int rc = vp8_default_zig_zag1d[i];
-
- quant_val = vp8_ac_yquant(Q);
- invert_quant(cpi->Y1quant[Q] + rc,
- cpi->Y1quant_shift[Q] + rc, quant_val);
- cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
- cpi->common.Y1dequant[Q][rc] = quant_val;
- cpi->zrun_zbin_boost_y1[Q][i] =
- ((quant_val * zbin_boost[i]) + 64) >> 7;
-
- quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
- invert_quant(cpi->Y2quant[Q] + rc,
- cpi->Y2quant_shift[Q] + rc, quant_val);
- cpi->Y2zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->Y2round[Q][rc] = (qrounding_factor * quant_val) >> 7;
- cpi->common.Y2dequant[Q][rc] = quant_val;
- cpi->zrun_zbin_boost_y2[Q][i] =
- ((quant_val * zbin_boost[i]) + 64) >> 7;
-
- quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
- invert_quant(cpi->UVquant[Q] + rc,
- cpi->UVquant_shift[Q] + rc, quant_val);
- cpi->UVzbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->UVround[Q][rc] = (qrounding_factor * quant_val) >> 7;
- cpi->common.UVdequant[Q][rc] = quant_val;
- cpi->zrun_zbin_boost_uv[Q][i] =
- ((quant_val * zbin_boost[i]) + 64) >> 7;
- }
-
- // 8x8 structures... only zbin seperated out for now
- // This needs cleaning up for 8x8 especially if we are to add
- // support for non flat Q matices
- for (i = 1; i < 64; i++)
- {
- int rc = vp8_default_zig_zag1d_8x8[i];
-
- quant_val = vp8_ac_yquant(Q);
- cpi->Y1zbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->zrun_zbin_boost_y1_8x8[Q][i] =
- ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
-
- quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
- cpi->Y2zbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->zrun_zbin_boost_y2_8x8[Q][i] =
- ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
-
- quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
- cpi->UVzbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
- cpi->zrun_zbin_boost_uv_8x8[Q][i] =
- ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
- }
+ // dc values
+ quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
+ invert_quant(cpi->Y1quant[Q] + 0,
+ cpi->Y1quant_shift[Q] + 0, quant_val);
+ cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y1zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.Y1dequant[Q][0] = quant_val;
+ cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
+ cpi->zrun_zbin_boost_y1_8x8[Q][0] =
+ ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
+
+ quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
+ invert_quant(cpi->Y2quant[Q] + 0,
+ cpi->Y2quant_shift[Q] + 0, quant_val);
+ cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y2zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.Y2dequant[Q][0] = quant_val;
+ cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
+ cpi->zrun_zbin_boost_y2_8x8[Q][0] =
+ ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
+
+ quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
+ invert_quant(cpi->UVquant[Q] + 0,
+ cpi->UVquant_shift[Q] + 0, quant_val);
+ cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
+ cpi->UVzbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
+ cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.UVdequant[Q][0] = quant_val;
+ cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
+ cpi->zrun_zbin_boost_uv_8x8[Q][0] =
+ ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
+
+ // all the 4x4 ac values =;
+ for (i = 1; i < 16; i++) {
+ int rc = vp8_default_zig_zag1d[i];
+
+ quant_val = vp8_ac_yquant(Q);
+ invert_quant(cpi->Y1quant[Q] + rc,
+ cpi->Y1quant_shift[Q] + rc, quant_val);
+ cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.Y1dequant[Q][rc] = quant_val;
+ cpi->zrun_zbin_boost_y1[Q][i] =
+ ((quant_val * zbin_boost[i]) + 64) >> 7;
+
+ quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
+ invert_quant(cpi->Y2quant[Q] + rc,
+ cpi->Y2quant_shift[Q] + rc, quant_val);
+ cpi->Y2zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->Y2round[Q][rc] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.Y2dequant[Q][rc] = quant_val;
+ cpi->zrun_zbin_boost_y2[Q][i] =
+ ((quant_val * zbin_boost[i]) + 64) >> 7;
+
+ quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
+ invert_quant(cpi->UVquant[Q] + rc,
+ cpi->UVquant_shift[Q] + rc, quant_val);
+ cpi->UVzbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->UVround[Q][rc] = (qrounding_factor * quant_val) >> 7;
+ cpi->common.UVdequant[Q][rc] = quant_val;
+ cpi->zrun_zbin_boost_uv[Q][i] =
+ ((quant_val * zbin_boost[i]) + 64) >> 7;
}
-}
-void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
-{
- int i;
- int QIndex;
- MACROBLOCKD *xd = &x->e_mbd;
- int zbin_extra;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- // Select the baseline MB Q index allowing for any segment level change.
- if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
- {
- // Abs Value
- if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
- QIndex = get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
-
- // Delta Value
- else
- {
- QIndex = cpi->common.base_qindex +
- get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
-
- // Clamp to valid range
- QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;
- }
- }
- else
- QIndex = cpi->common.base_qindex;
-
- // Y
- zbin_extra = ( cpi->common.Y1dequant[QIndex][1] *
- ( cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
-
- for (i = 0; i < 16; i++)
- {
- x->block[i].quant = cpi->Y1quant[QIndex];
- x->block[i].quant_shift = cpi->Y1quant_shift[QIndex];
- x->block[i].zbin = cpi->Y1zbin[QIndex];
- x->block[i].zbin_8x8 = cpi->Y1zbin_8x8[QIndex];
- x->block[i].round = cpi->Y1round[QIndex];
- x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex];
- x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex];
- x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y1_8x8[QIndex];
- x->block[i].zbin_extra = (short)zbin_extra;
-
- // Segment max eob offset feature.
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- x->block[i].eob_max_offset =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
- x->block[i].eob_max_offset_8x8 =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
- }
- else
- {
- x->block[i].eob_max_offset = 16;
- x->block[i].eob_max_offset_8x8 = 64;
- }
+ // 8x8 structures... only zbin seperated out for now
+ // This needs cleaning up for 8x8 especially if we are to add
+ // support for non flat Q matices
+ for (i = 1; i < 64; i++) {
+ int rc = vp8_default_zig_zag1d_8x8[i];
+
+ quant_val = vp8_ac_yquant(Q);
+ cpi->Y1zbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->zrun_zbin_boost_y1_8x8[Q][i] =
+ ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
+
+ quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
+ cpi->Y2zbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->zrun_zbin_boost_y2_8x8[Q][i] =
+ ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
+
+ quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
+ cpi->UVzbin_8x8[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
+ cpi->zrun_zbin_boost_uv_8x8[Q][i] =
+ ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
}
+ }
+}
- // UV
- zbin_extra = ( cpi->common.UVdequant[QIndex][1] *
- ( cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
-
- for (i = 16; i < 24; i++)
- {
- x->block[i].quant = cpi->UVquant[QIndex];
- x->block[i].quant_shift = cpi->UVquant_shift[QIndex];
- x->block[i].zbin = cpi->UVzbin[QIndex];
- x->block[i].zbin_8x8 = cpi->UVzbin_8x8[QIndex];
- x->block[i].round = cpi->UVround[QIndex];
- x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex];
- x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex];
- x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_uv_8x8[QIndex];
-
- x->block[i].zbin_extra = (short)zbin_extra;
-
- // Segment max eob offset feature.
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- x->block[i].eob_max_offset =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
- x->block[i].eob_max_offset_8x8 =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
- }
- else
- {
- x->block[i].eob_max_offset = 16;
- x->block[i].eob_max_offset_8x8 = 64;
- }
+void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) {
+ int i;
+ int QIndex;
+ MACROBLOCKD *xd = &x->e_mbd;
+ int zbin_extra;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ // Select the baseline MB Q index allowing for any segment level change.
+ if (segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
+ // Abs Value
+ if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
+ QIndex = get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
+
+ // Delta Value
+ else {
+ QIndex = cpi->common.base_qindex +
+ get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
+
+ // Clamp to valid range
+ QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;
}
+ } else
+ QIndex = cpi->common.base_qindex;
+
+ // Y
+ zbin_extra = (cpi->common.Y1dequant[QIndex][1] *
+ (cpi->zbin_over_quant +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
+
+ for (i = 0; i < 16; i++) {
+ x->block[i].quant = cpi->Y1quant[QIndex];
+ x->block[i].quant_shift = cpi->Y1quant_shift[QIndex];
+ x->block[i].zbin = cpi->Y1zbin[QIndex];
+ x->block[i].zbin_8x8 = cpi->Y1zbin_8x8[QIndex];
+ x->block[i].round = cpi->Y1round[QIndex];
+ x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex];
+ x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex];
+ x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y1_8x8[QIndex];
+ x->block[i].zbin_extra = (short)zbin_extra;
- // Y2
- zbin_extra = ( cpi->common.Y2dequant[QIndex][1] *
- ( (cpi->zbin_over_quant / 2) +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
-
- x->block[24].quant = cpi->Y2quant[QIndex];
- x->block[24].quant_shift = cpi->Y2quant_shift[QIndex];
- x->block[24].zbin = cpi->Y2zbin[QIndex];
- x->block[24].zbin_8x8 = cpi->Y2zbin_8x8[QIndex];
- x->block[24].round = cpi->Y2round[QIndex];
- x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex];
- x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
- x->block[24].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y2_8x8[QIndex];
- x->block[24].zbin_extra = (short)zbin_extra;
-
- // TBD perhaps not use for Y2
// Segment max eob offset feature.
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- x->block[24].eob_max_offset =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
- x->block[24].eob_max_offset_8x8 =
- get_segdata( xd, segment_id, SEG_LVL_EOB );
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ x->block[i].eob_max_offset =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ x->block[i].eob_max_offset_8x8 =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ } else {
+ x->block[i].eob_max_offset = 16;
+ x->block[i].eob_max_offset_8x8 = 64;
}
- else
- {
- x->block[24].eob_max_offset = 16;
- x->block[24].eob_max_offset_8x8 = 4;
+ }
+
+ // UV
+ zbin_extra = (cpi->common.UVdequant[QIndex][1] *
+ (cpi->zbin_over_quant +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
+
+ for (i = 16; i < 24; i++) {
+ x->block[i].quant = cpi->UVquant[QIndex];
+ x->block[i].quant_shift = cpi->UVquant_shift[QIndex];
+ x->block[i].zbin = cpi->UVzbin[QIndex];
+ x->block[i].zbin_8x8 = cpi->UVzbin_8x8[QIndex];
+ x->block[i].round = cpi->UVround[QIndex];
+ x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex];
+ x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex];
+ x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_uv_8x8[QIndex];
+
+ x->block[i].zbin_extra = (short)zbin_extra;
+
+ // Segment max eob offset feature.
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ x->block[i].eob_max_offset =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ x->block[i].eob_max_offset_8x8 =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ } else {
+ x->block[i].eob_max_offset = 16;
+ x->block[i].eob_max_offset_8x8 = 64;
}
+ }
+
+ // Y2
+ zbin_extra = (cpi->common.Y2dequant[QIndex][1] *
+ ((cpi->zbin_over_quant / 2) +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
+
+ x->block[24].quant = cpi->Y2quant[QIndex];
+ x->block[24].quant_shift = cpi->Y2quant_shift[QIndex];
+ x->block[24].zbin = cpi->Y2zbin[QIndex];
+ x->block[24].zbin_8x8 = cpi->Y2zbin_8x8[QIndex];
+ x->block[24].round = cpi->Y2round[QIndex];
+ x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex];
+ x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
+ x->block[24].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y2_8x8[QIndex];
+ x->block[24].zbin_extra = (short)zbin_extra;
+
+ // TBD perhaps not use for Y2
+ // Segment max eob offset feature.
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ x->block[24].eob_max_offset =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ x->block[24].eob_max_offset_8x8 =
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+ } else {
+ x->block[24].eob_max_offset = 16;
+ x->block[24].eob_max_offset_8x8 = 4;
+ }
- /* save this macroblock QIndex for vp8_update_zbin_extra() */
- x->q_index = QIndex;
+ /* save this macroblock QIndex for vp8_update_zbin_extra() */
+ x->q_index = QIndex;
}
-void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x)
-{
- int i;
- int QIndex = x->q_index;
- int zbin_extra;
-
- // Y
- zbin_extra = ( cpi->common.Y1dequant[QIndex][1] *
- ( cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
- for (i = 0; i < 16; i++)
- {
- x->block[i].zbin_extra = (short)zbin_extra;
- }
+void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x) {
+ int i;
+ int QIndex = x->q_index;
+ int zbin_extra;
+
+ // Y
+ zbin_extra = (cpi->common.Y1dequant[QIndex][1] *
+ (cpi->zbin_over_quant +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
+ for (i = 0; i < 16; i++) {
+ x->block[i].zbin_extra = (short)zbin_extra;
+ }
- // UV
- zbin_extra = ( cpi->common.UVdequant[QIndex][1] *
- ( cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
+ // UV
+ zbin_extra = (cpi->common.UVdequant[QIndex][1] *
+ (cpi->zbin_over_quant +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
- for (i = 16; i < 24; i++)
- {
- x->block[i].zbin_extra = (short)zbin_extra;
- }
+ for (i = 16; i < 24; i++) {
+ x->block[i].zbin_extra = (short)zbin_extra;
+ }
- // Y2
- zbin_extra = ( cpi->common.Y2dequant[QIndex][1] *
- ( (cpi->zbin_over_quant / 2) +
- cpi->zbin_mode_boost +
- x->act_zbin_adj ) ) >> 7;
+ // Y2
+ zbin_extra = (cpi->common.Y2dequant[QIndex][1] *
+ ((cpi->zbin_over_quant / 2) +
+ cpi->zbin_mode_boost +
+ x->act_zbin_adj)) >> 7;
- x->block[24].zbin_extra = (short)zbin_extra;
+ x->block[24].zbin_extra = (short)zbin_extra;
}
-void vp8cx_frame_init_quantizer(VP8_COMP *cpi)
-{
- // Clear Zbin mode boost for default case
- cpi->zbin_mode_boost = 0;
+void vp8cx_frame_init_quantizer(VP8_COMP *cpi) {
+ // Clear Zbin mode boost for default case
+ cpi->zbin_mode_boost = 0;
- // MB level quantizer setup
- vp8cx_mb_init_quantizer(cpi, &cpi->mb);
+ // MB level quantizer setup
+ vp8cx_mb_init_quantizer(cpi, &cpi->mb);
}
-void vp8_set_quantizer(struct VP8_COMP *cpi, int Q)
-{
- VP8_COMMON *cm = &cpi->common;
+void vp8_set_quantizer(struct VP8_COMP *cpi, int Q) {
+ VP8_COMMON *cm = &cpi->common;
- cm->base_qindex = Q;
+ cm->base_qindex = Q;
- // if any of the delta_q values are changing update flag will
- // have to be set.
- cm->y1dc_delta_q = 0;
- cm->y2ac_delta_q = 0;
- cm->uvdc_delta_q = 0;
- cm->uvac_delta_q = 0;
- cm->y2dc_delta_q = 0;
+ // if any of the delta_q values are changing update flag will
+ // have to be set.
+ cm->y1dc_delta_q = 0;
+ cm->y2ac_delta_q = 0;
+ cm->uvdc_delta_q = 0;
+ cm->uvac_delta_q = 0;
+ cm->y2dc_delta_q = 0;
- // quantizer has to be reinitialized if any delta_q changes.
- // As there are not any here for now this is inactive code.
- //if(update)
- // vp8cx_init_quantizer(cpi);
+ // quantizer has to be reinitialized if any delta_q changes.
+ // As there are not any here for now this is inactive code.
+ // if(update)
+ // vp8cx_init_quantizer(cpi);
}
diff --git a/vp8/encoder/quantize.h b/vp8/encoder/quantize.h
index 5cde006bc..4106064f5 100644
--- a/vp8/encoder/quantize.h
+++ b/vp8/encoder/quantize.h
@@ -15,13 +15,13 @@
#include "block.h"
#define prototype_quantize_block(sym) \
- void (sym)(BLOCK *b,BLOCKD *d)
+ void (sym)(BLOCK *b,BLOCKD *d)
#define prototype_quantize_block_pair(sym) \
- void (sym)(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
+ void (sym)(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
#define prototype_quantize_mb(sym) \
- void (sym)(MACROBLOCK *x)
+ void (sym)(MACROBLOCK *x)
#if ARCH_X86 || ARCH_X86_64
#include "x86/quantize_x86.h"
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index 52424aa7a..9885f8742 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -44,46 +44,42 @@ extern unsigned int inter_b_modes[B_MODE_COUNT];
#define BPER_MB_NORMBITS 9
// % adjustment to target kf size based on seperation from previous frame
-static const int kf_boost_seperation_adjustment[16] =
-{
- 30, 40, 50, 55, 60, 65, 70, 75,
- 80, 85, 90, 95, 100, 100, 100, 100,
+static const int kf_boost_seperation_adjustment[16] = {
+ 30, 40, 50, 55, 60, 65, 70, 75,
+ 80, 85, 90, 95, 100, 100, 100, 100,
};
-static const int gf_adjust_table[101] =
-{
- 100,
- 115, 130, 145, 160, 175, 190, 200, 210, 220, 230,
- 240, 260, 270, 280, 290, 300, 310, 320, 330, 340,
- 350, 360, 370, 380, 390, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
- 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+static const int gf_adjust_table[101] = {
+ 100,
+ 115, 130, 145, 160, 175, 190, 200, 210, 220, 230,
+ 240, 260, 270, 280, 290, 300, 310, 320, 330, 340,
+ 350, 360, 370, 380, 390, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
};
-static const int gf_intra_usage_adjustment[20] =
-{
- 125, 120, 115, 110, 105, 100, 95, 85, 80, 75,
- 70, 65, 60, 55, 50, 50, 50, 50, 50, 50,
+static const int gf_intra_usage_adjustment[20] = {
+ 125, 120, 115, 110, 105, 100, 95, 85, 80, 75,
+ 70, 65, 60, 55, 50, 50, 50, 50, 50, 50,
};
-static const int gf_interval_table[101] =
-{
- 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+static const int gf_interval_table[101] = {
+ 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
};
static const unsigned int prior_key_frame_weight[KEY_FRAME_CONTEXT] = { 1, 2, 3, 4, 5 };
@@ -91,274 +87,260 @@ static const unsigned int prior_key_frame_weight[KEY_FRAME_CONTEXT] = { 1, 2, 3,
// These functions use formulaic calculations to make playing with the
// quantizer tables easier. If necessary they can be replaced by lookup
// tables if and when things settle down in the experimental bitstream
-double vp8_convert_qindex_to_q( int qindex )
-{
- // Convert the index to a real Q value (scaled down to match old Q values)
- return (double)vp8_ac_yquant( qindex ) / 4.0;
+double vp8_convert_qindex_to_q(int qindex) {
+ // Convert the index to a real Q value (scaled down to match old Q values)
+ return (double)vp8_ac_yquant(qindex) / 4.0;
}
-int vp8_gfboost_qadjust( int qindex )
-{
- int retval;
- double q;
+int vp8_gfboost_qadjust(int qindex) {
+ int retval;
+ double q;
- q = vp8_convert_qindex_to_q(qindex);
- retval = (int)( ( 0.00000828 * q * q * q ) +
- ( -0.0055 * q * q ) +
- ( 1.32 * q ) + 79.3 );
- return retval;
+ q = vp8_convert_qindex_to_q(qindex);
+ retval = (int)((0.00000828 * q * q * q) +
+ (-0.0055 * q * q) +
+ (1.32 * q) + 79.3);
+ return retval;
}
-int kfboost_qadjust( int qindex )
-{
- int retval;
- double q;
+int kfboost_qadjust(int qindex) {
+ int retval;
+ double q;
- q = vp8_convert_qindex_to_q(qindex);
- retval = (int)( ( 0.00000973 * q * q * q ) +
- ( -0.00613 * q * q ) +
- ( 1.316 * q ) + 121.2 );
- return retval;
+ q = vp8_convert_qindex_to_q(qindex);
+ retval = (int)((0.00000973 * q * q * q) +
+ (-0.00613 * q * q) +
+ (1.316 * q) + 121.2);
+ return retval;
}
-int vp8_bits_per_mb( FRAME_TYPE frame_type, int qindex )
-{
- if ( frame_type == KEY_FRAME )
- return (int)(4500000 / vp8_convert_qindex_to_q(qindex));
- else
- return (int)(2850000 / vp8_convert_qindex_to_q(qindex));
+int vp8_bits_per_mb(FRAME_TYPE frame_type, int qindex) {
+ if (frame_type == KEY_FRAME)
+ return (int)(4500000 / vp8_convert_qindex_to_q(qindex));
+ else
+ return (int)(2850000 / vp8_convert_qindex_to_q(qindex));
}
-void vp8_save_coding_context(VP8_COMP *cpi)
-{
- CODING_CONTEXT *const cc = & cpi->coding_context;
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
+void vp8_save_coding_context(VP8_COMP *cpi) {
+ CODING_CONTEXT *const cc = & cpi->coding_context;
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
- // Stores a snapshot of key state variables which can subsequently be
- // restored with a call to vp8_restore_coding_context. These functions are
- // intended for use in a re-code loop in vp8_compress_frame where the
- // quantizer value is adjusted between loop iterations.
+ // Stores a snapshot of key state variables which can subsequently be
+ // restored with a call to vp8_restore_coding_context. These functions are
+ // intended for use in a re-code loop in vp8_compress_frame where the
+ // quantizer value is adjusted between loop iterations.
- vp8_copy(cc->mvc, cm->fc.mvc);
- vp8_copy(cc->mvcosts, cpi->mb.mvcosts);
+ vp8_copy(cc->mvc, cm->fc.mvc);
+ vp8_copy(cc->mvcosts, cpi->mb.mvcosts);
#if CONFIG_HIGH_PRECISION_MV
- vp8_copy(cc->mvc_hp, cm->fc.mvc_hp);
- vp8_copy(cc->mvcosts_hp, cpi->mb.mvcosts_hp);
+ vp8_copy(cc->mvc_hp, cm->fc.mvc_hp);
+ vp8_copy(cc->mvcosts_hp, cpi->mb.mvcosts_hp);
#endif
- vp8_copy( cc->mv_ref_ct, cm->fc.mv_ref_ct );
- vp8_copy( cc->mode_context, cm->fc.mode_context );
- vp8_copy( cc->mv_ref_ct_a, cm->fc.mv_ref_ct_a );
- vp8_copy( cc->mode_context_a, cm->fc.mode_context_a );
+ vp8_copy(cc->mv_ref_ct, cm->fc.mv_ref_ct);
+ vp8_copy(cc->mode_context, cm->fc.mode_context);
+ vp8_copy(cc->mv_ref_ct_a, cm->fc.mv_ref_ct_a);
+ vp8_copy(cc->mode_context_a, cm->fc.mode_context_a);
- vp8_copy( cc->ymode_prob, cm->fc.ymode_prob );
- vp8_copy( cc->bmode_prob, cm->fc.bmode_prob );
- vp8_copy( cc->uv_mode_prob, cm->fc.uv_mode_prob );
- vp8_copy( cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob );
- vp8_copy( cc->sub_mv_ref_prob, cm->fc.sub_mv_ref_prob );
- vp8_copy( cc->mbsplit_prob, cm->fc.mbsplit_prob );
+ vp8_copy(cc->ymode_prob, cm->fc.ymode_prob);
+ vp8_copy(cc->bmode_prob, cm->fc.bmode_prob);
+ vp8_copy(cc->uv_mode_prob, cm->fc.uv_mode_prob);
+ vp8_copy(cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob);
+ vp8_copy(cc->sub_mv_ref_prob, cm->fc.sub_mv_ref_prob);
+ vp8_copy(cc->mbsplit_prob, cm->fc.mbsplit_prob);
- // Stats
+ // Stats
#ifdef MODE_STATS
- vp8_copy(cc->y_modes, y_modes);
- vp8_copy(cc->uv_modes, uv_modes);
- vp8_copy(cc->b_modes, b_modes);
- vp8_copy(cc->inter_y_modes, inter_y_modes);
- vp8_copy(cc->inter_uv_modes, inter_uv_modes);
- vp8_copy(cc->inter_b_modes, inter_b_modes);
+ vp8_copy(cc->y_modes, y_modes);
+ vp8_copy(cc->uv_modes, uv_modes);
+ vp8_copy(cc->b_modes, b_modes);
+ vp8_copy(cc->inter_y_modes, inter_y_modes);
+ vp8_copy(cc->inter_uv_modes, inter_uv_modes);
+ vp8_copy(cc->inter_b_modes, inter_b_modes);
#endif
- vp8_copy( cc->segment_pred_probs, cm->segment_pred_probs );
- vp8_copy( cc->ref_pred_probs_update, cpi->ref_pred_probs_update );
- vp8_copy( cc->ref_pred_probs, cm->ref_pred_probs );
- vp8_copy( cc->prob_comppred, cm->prob_comppred );
+ vp8_copy(cc->segment_pred_probs, cm->segment_pred_probs);
+ vp8_copy(cc->ref_pred_probs_update, cpi->ref_pred_probs_update);
+ vp8_copy(cc->ref_pred_probs, cm->ref_pred_probs);
+ vp8_copy(cc->prob_comppred, cm->prob_comppred);
- vpx_memcpy( cpi->coding_context.last_frame_seg_map_copy,
- cm->last_frame_seg_map, (cm->mb_rows * cm->mb_cols) );
+ vpx_memcpy(cpi->coding_context.last_frame_seg_map_copy,
+ cm->last_frame_seg_map, (cm->mb_rows * cm->mb_cols));
- vp8_copy( cc->last_ref_lf_deltas, xd->last_ref_lf_deltas );
- vp8_copy( cc->last_mode_lf_deltas, xd->last_mode_lf_deltas );
+ vp8_copy(cc->last_ref_lf_deltas, xd->last_ref_lf_deltas);
+ vp8_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas);
- vp8_copy( cc->coef_probs, cm->fc.coef_probs );
- vp8_copy( cc->coef_probs_8x8, cm->fc.coef_probs_8x8 );
+ vp8_copy(cc->coef_probs, cm->fc.coef_probs);
+ vp8_copy(cc->coef_probs_8x8, cm->fc.coef_probs_8x8);
}
-void vp8_restore_coding_context(VP8_COMP *cpi)
-{
- CODING_CONTEXT *const cc = & cpi->coding_context;
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
+void vp8_restore_coding_context(VP8_COMP *cpi) {
+ CODING_CONTEXT *const cc = & cpi->coding_context;
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
- // Restore key state variables to the snapshot state stored in the
- // previous call to vp8_save_coding_context.
+ // Restore key state variables to the snapshot state stored in the
+ // previous call to vp8_save_coding_context.
- vp8_copy(cm->fc.mvc, cc->mvc);
- vp8_copy(cpi->mb.mvcosts, cc->mvcosts);
+ vp8_copy(cm->fc.mvc, cc->mvc);
+ vp8_copy(cpi->mb.mvcosts, cc->mvcosts);
#if CONFIG_HIGH_PRECISION_MV
- vp8_copy(cm->fc.mvc_hp, cc->mvc_hp);
- vp8_copy(cpi->mb.mvcosts_hp, cc->mvcosts_hp);
+ vp8_copy(cm->fc.mvc_hp, cc->mvc_hp);
+ vp8_copy(cpi->mb.mvcosts_hp, cc->mvcosts_hp);
#endif
- vp8_copy( cm->fc.mv_ref_ct, cc->mv_ref_ct );
- vp8_copy( cm->fc.mode_context, cc->mode_context );
- vp8_copy( cm->fc.mv_ref_ct_a, cc->mv_ref_ct_a );
- vp8_copy( cm->fc.mode_context_a, cc->mode_context_a );
+ vp8_copy(cm->fc.mv_ref_ct, cc->mv_ref_ct);
+ vp8_copy(cm->fc.mode_context, cc->mode_context);
+ vp8_copy(cm->fc.mv_ref_ct_a, cc->mv_ref_ct_a);
+ vp8_copy(cm->fc.mode_context_a, cc->mode_context_a);
- vp8_copy( cm->fc.ymode_prob, cc->ymode_prob);
- vp8_copy( cm->fc.bmode_prob, cc->bmode_prob);
- vp8_copy( cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob);
- vp8_copy( cm->fc.uv_mode_prob, cc->uv_mode_prob);
- vp8_copy( cm->fc.sub_mv_ref_prob, cc->sub_mv_ref_prob);
- vp8_copy( cm->fc.mbsplit_prob, cc->mbsplit_prob );
+ vp8_copy(cm->fc.ymode_prob, cc->ymode_prob);
+ vp8_copy(cm->fc.bmode_prob, cc->bmode_prob);
+ vp8_copy(cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob);
+ vp8_copy(cm->fc.uv_mode_prob, cc->uv_mode_prob);
+ vp8_copy(cm->fc.sub_mv_ref_prob, cc->sub_mv_ref_prob);
+ vp8_copy(cm->fc.mbsplit_prob, cc->mbsplit_prob);
- // Stats
+ // Stats
#ifdef MODE_STATS
- vp8_copy(y_modes, cc->y_modes);
- vp8_copy(uv_modes, cc->uv_modes);
- vp8_copy(b_modes, cc->b_modes);
- vp8_copy(inter_y_modes, cc->inter_y_modes);
- vp8_copy(inter_uv_modes, cc->inter_uv_modes);
- vp8_copy(inter_b_modes, cc->inter_b_modes);
+ vp8_copy(y_modes, cc->y_modes);
+ vp8_copy(uv_modes, cc->uv_modes);
+ vp8_copy(b_modes, cc->b_modes);
+ vp8_copy(inter_y_modes, cc->inter_y_modes);
+ vp8_copy(inter_uv_modes, cc->inter_uv_modes);
+ vp8_copy(inter_b_modes, cc->inter_b_modes);
#endif
- vp8_copy( cm->segment_pred_probs, cc->segment_pred_probs );
- vp8_copy( cpi->ref_pred_probs_update, cc->ref_pred_probs_update );
- vp8_copy( cm->ref_pred_probs, cc->ref_pred_probs );
- vp8_copy( cm->prob_comppred, cc->prob_comppred );
+ vp8_copy(cm->segment_pred_probs, cc->segment_pred_probs);
+ vp8_copy(cpi->ref_pred_probs_update, cc->ref_pred_probs_update);
+ vp8_copy(cm->ref_pred_probs, cc->ref_pred_probs);
+ vp8_copy(cm->prob_comppred, cc->prob_comppred);
- vpx_memcpy( cm->last_frame_seg_map,
- cpi->coding_context.last_frame_seg_map_copy,
- (cm->mb_rows * cm->mb_cols) );
+ vpx_memcpy(cm->last_frame_seg_map,
+ cpi->coding_context.last_frame_seg_map_copy,
+ (cm->mb_rows * cm->mb_cols));
- vp8_copy( xd->last_ref_lf_deltas, cc->last_ref_lf_deltas );
- vp8_copy( xd->last_mode_lf_deltas, cc->last_mode_lf_deltas );
+ vp8_copy(xd->last_ref_lf_deltas, cc->last_ref_lf_deltas);
+ vp8_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas);
- vp8_copy( cm->fc.coef_probs, cc->coef_probs );
- vp8_copy( cm->fc.coef_probs_8x8, cc->coef_probs_8x8 );
+ vp8_copy(cm->fc.coef_probs, cc->coef_probs);
+ vp8_copy(cm->fc.coef_probs_8x8, cc->coef_probs_8x8);
}
-void vp8_setup_key_frame(VP8_COMP *cpi)
-{
- // Setup for Key frame:
- vp8_default_coef_probs(& cpi->common);
- vp8_kf_default_bmode_probs(cpi->common.kf_bmode_prob);
- vp8_init_mbmode_probs(& cpi->common);
+void vp8_setup_key_frame(VP8_COMP *cpi) {
+ // Setup for Key frame:
+ vp8_default_coef_probs(& cpi->common);
+ vp8_kf_default_bmode_probs(cpi->common.kf_bmode_prob);
+ vp8_init_mbmode_probs(& cpi->common);
- vpx_memcpy(cpi->common.fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
- {
- int flag[2] = {1, 1};
- vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flag);
- }
+ vpx_memcpy(cpi->common.fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
+ {
+ int flag[2] = {1, 1};
+ vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flag);
+ }
#if CONFIG_HIGH_PRECISION_MV
- vpx_memcpy(cpi->common.fc.mvc_hp, vp8_default_mv_context_hp, sizeof(vp8_default_mv_context_hp));
- {
- int flag[2] = {1, 1};
- vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp, (const MV_CONTEXT_HP *) cpi->common.fc.mvc_hp, flag);
- }
+ vpx_memcpy(cpi->common.fc.mvc_hp, vp8_default_mv_context_hp, sizeof(vp8_default_mv_context_hp));
+ {
+ int flag[2] = {1, 1};
+ vp8_build_component_cost_table_hp(cpi->mb.mvcost_hp, (const MV_CONTEXT_HP *) cpi->common.fc.mvc_hp, flag);
+ }
#endif
- cpi->common.txfm_mode = ALLOW_8X8;
+ cpi->common.txfm_mode = ALLOW_8X8;
#if CONFIG_LOSSLESS
- if(cpi->oxcf.lossless)
- cpi->common.txfm_mode = ONLY_4X4;
+ if (cpi->oxcf.lossless)
+ cpi->common.txfm_mode = ONLY_4X4;
#endif
- //cpi->common.filter_level = 0; // Reset every key frame.
- cpi->common.filter_level = cpi->common.base_qindex * 3 / 8 ;
+ // cpi->common.filter_level = 0; // Reset every key frame.
+ cpi->common.filter_level = cpi->common.base_qindex * 3 / 8;
- // interval before next GF
- cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
+ // interval before next GF
+ cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
- cpi->common.refresh_golden_frame = TRUE;
- cpi->common.refresh_alt_ref_frame = TRUE;
+ cpi->common.refresh_golden_frame = TRUE;
+ cpi->common.refresh_alt_ref_frame = TRUE;
- vp8_init_mode_contexts(&cpi->common);
- vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc));
- vpx_memcpy(&cpi->common.lfc_a, &cpi->common.fc, sizeof(cpi->common.fc));
+ vp8_init_mode_contexts(&cpi->common);
+ vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc));
+ vpx_memcpy(&cpi->common.lfc_a, &cpi->common.fc, sizeof(cpi->common.fc));
- /*
- vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
- cpi->common.fc.mode_context,
- sizeof(cpi->common.fc.mode_context));
- */
- vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
- default_vp8_mode_contexts,
- sizeof(default_vp8_mode_contexts));
+ /*
+ vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context,
+ sizeof(cpi->common.fc.mode_context));
+ */
+ vpx_memcpy(cpi->common.fc.vp8_mode_contexts,
+ default_vp8_mode_contexts,
+ sizeof(default_vp8_mode_contexts));
}
-void vp8_setup_inter_frame(VP8_COMP *cpi)
-{
+void vp8_setup_inter_frame(VP8_COMP *cpi) {
- cpi->common.txfm_mode = ALLOW_8X8;
+ cpi->common.txfm_mode = ALLOW_8X8;
#if CONFIG_LOSSLESS
- if(cpi->oxcf.lossless)
- cpi->common.txfm_mode = ONLY_4X4;
+ if (cpi->oxcf.lossless)
+ cpi->common.txfm_mode = ONLY_4X4;
#endif
- if(cpi->common.refresh_alt_ref_frame)
- {
- vpx_memcpy( &cpi->common.fc,
- &cpi->common.lfc_a,
- sizeof(cpi->common.fc));
- vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
- cpi->common.fc.mode_context_a,
- sizeof(cpi->common.fc.vp8_mode_contexts));
- }
- else
- {
- vpx_memcpy( &cpi->common.fc,
- &cpi->common.lfc,
- sizeof(cpi->common.fc));
- vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
- cpi->common.fc.mode_context,
- sizeof(cpi->common.fc.vp8_mode_contexts));
- }
+ if (cpi->common.refresh_alt_ref_frame) {
+ vpx_memcpy(&cpi->common.fc,
+ &cpi->common.lfc_a,
+ sizeof(cpi->common.fc));
+ vpx_memcpy(cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context_a,
+ sizeof(cpi->common.fc.vp8_mode_contexts));
+ } else {
+ vpx_memcpy(&cpi->common.fc,
+ &cpi->common.lfc,
+ sizeof(cpi->common.fc));
+ vpx_memcpy(cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context,
+ sizeof(cpi->common.fc.vp8_mode_contexts));
+ }
}
static int estimate_bits_at_q(int frame_kind, int Q, int MBs,
- double correction_factor)
-{
- int Bpm = (int)(.5 + correction_factor * vp8_bits_per_mb(frame_kind, Q));
-
- /* Attempt to retain reasonable accuracy without overflow. The cutoff is
- * chosen such that the maximum product of Bpm and MBs fits 31 bits. The
- * largest Bpm takes 20 bits.
- */
- if (MBs > (1 << 11))
- return (Bpm >> BPER_MB_NORMBITS) * MBs;
- else
- return (Bpm * MBs) >> BPER_MB_NORMBITS;
+ double correction_factor) {
+ int Bpm = (int)(.5 + correction_factor * vp8_bits_per_mb(frame_kind, Q));
+
+ /* Attempt to retain reasonable accuracy without overflow. The cutoff is
+ * chosen such that the maximum product of Bpm and MBs fits 31 bits. The
+ * largest Bpm takes 20 bits.
+ */
+ if (MBs > (1 << 11))
+ return (Bpm >> BPER_MB_NORMBITS) * MBs;
+ else
+ return (Bpm * MBs) >> BPER_MB_NORMBITS;
}
-static void calc_iframe_target_size(VP8_COMP *cpi)
-{
- // boost defaults to half second
- int target;
+static void calc_iframe_target_size(VP8_COMP *cpi) {
+ // boost defaults to half second
+ int target;
- // Clear down mmx registers to allow floating point in what follows
- vp8_clear_system_state(); //__asm emms;
+ // Clear down mmx registers to allow floating point in what follows
+ vp8_clear_system_state(); // __asm emms;
- // New Two pass RC
- target = cpi->per_frame_bandwidth;
+ // New Two pass RC
+ target = cpi->per_frame_bandwidth;
- if (cpi->oxcf.rc_max_intra_bitrate_pct)
- {
- unsigned int max_rate = cpi->per_frame_bandwidth
- * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
+ if (cpi->oxcf.rc_max_intra_bitrate_pct) {
+ unsigned int max_rate = cpi->per_frame_bandwidth
+ * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
- if (target > max_rate)
- target = max_rate;
- }
+ if (target > max_rate)
+ target = max_rate;
+ }
- cpi->this_frame_target = target;
+ cpi->this_frame_target = target;
}
@@ -368,417 +350,370 @@ static void calc_iframe_target_size(VP8_COMP *cpi)
//
// In this experimental code only two pass is supported
// so we just use the interval determined in the two pass code.
-static void calc_gf_params(VP8_COMP *cpi)
-{
- // Set the gf interval
- cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
+static void calc_gf_params(VP8_COMP *cpi) {
+ // Set the gf interval
+ cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
}
-static void calc_pframe_target_size(VP8_COMP *cpi)
-{
- int min_frame_target;
+static void calc_pframe_target_size(VP8_COMP *cpi) {
+ int min_frame_target;
- min_frame_target = 0;
+ min_frame_target = 0;
- min_frame_target = cpi->min_frame_bandwidth;
+ min_frame_target = cpi->min_frame_bandwidth;
- if (min_frame_target < (cpi->av_per_frame_bandwidth >> 5))
- min_frame_target = cpi->av_per_frame_bandwidth >> 5;
+ if (min_frame_target < (cpi->av_per_frame_bandwidth >> 5))
+ min_frame_target = cpi->av_per_frame_bandwidth >> 5;
- // Special alt reference frame case
- if (cpi->common.refresh_alt_ref_frame)
- {
- // Per frame bit target for the alt ref frame
- cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
- cpi->this_frame_target = cpi->per_frame_bandwidth;
- }
+ // Special alt reference frame case
+ if (cpi->common.refresh_alt_ref_frame) {
+ // Per frame bit target for the alt ref frame
+ cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
+ cpi->this_frame_target = cpi->per_frame_bandwidth;
+ }
- // Normal frames (gf,and inter)
- else
- {
- cpi->this_frame_target = cpi->per_frame_bandwidth;
- }
+ // Normal frames (gf,and inter)
+ else {
+ cpi->this_frame_target = cpi->per_frame_bandwidth;
+ }
- // Sanity check that the total sum of adjustments is not above the maximum allowed
- // That is that having allowed for KF and GF penalties we have not pushed the
- // current interframe target to low. If the adjustment we apply here is not capable of recovering
- // all the extra bits we have spent in the KF or GF then the remainder will have to be recovered over
- // a longer time span via other buffer / rate control mechanisms.
- if (cpi->this_frame_target < min_frame_target)
- cpi->this_frame_target = min_frame_target;
-
- if (!cpi->common.refresh_alt_ref_frame)
- // Note the baseline target data rate for this inter frame.
- cpi->inter_frame_target = cpi->this_frame_target;
-
- // Adjust target frame size for Golden Frames:
- if ( cpi->frames_till_gf_update_due == 0 )
- {
- //int Boost = 0;
- int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
-
- cpi->common.refresh_golden_frame = TRUE;
-
- calc_gf_params(cpi);
-
- // If we are using alternate ref instead of gf then do not apply the boost
- // It will instead be applied to the altref update
- // Jims modified boost
- if (!cpi->source_alt_ref_active)
- {
- if (cpi->oxcf.fixed_q < 0)
- {
- // The spend on the GF is defined in the two pass code
- // for two pass encodes
- cpi->this_frame_target = cpi->per_frame_bandwidth;
- }
- else
- cpi->this_frame_target =
- (estimate_bits_at_q(1, Q, cpi->common.MBs, 1.0)
- * cpi->last_boost) / 100;
+ // Sanity check that the total sum of adjustments is not above the maximum allowed
+ // That is that having allowed for KF and GF penalties we have not pushed the
+ // current interframe target to low. If the adjustment we apply here is not capable of recovering
+ // all the extra bits we have spent in the KF or GF then the remainder will have to be recovered over
+ // a longer time span via other buffer / rate control mechanisms.
+ if (cpi->this_frame_target < min_frame_target)
+ cpi->this_frame_target = min_frame_target;
- }
- // If there is an active ARF at this location use the minimum
- // bits on this frame even if it is a contructed arf.
- // The active maximum quantizer insures that an appropriate
- // number of bits will be spent if needed for contstructed ARFs.
- else
- {
- cpi->this_frame_target = 0;
- }
+ if (!cpi->common.refresh_alt_ref_frame)
+ // Note the baseline target data rate for this inter frame.
+ cpi->inter_frame_target = cpi->this_frame_target;
+
+ // Adjust target frame size for Golden Frames:
+ if (cpi->frames_till_gf_update_due == 0) {
+ // int Boost = 0;
+ int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
+
+ cpi->common.refresh_golden_frame = TRUE;
- cpi->current_gf_interval = cpi->frames_till_gf_update_due;
+ calc_gf_params(cpi);
+
+ // If we are using alternate ref instead of gf then do not apply the boost
+ // It will instead be applied to the altref update
+ // Jims modified boost
+ if (!cpi->source_alt_ref_active) {
+ if (cpi->oxcf.fixed_q < 0) {
+ // The spend on the GF is defined in the two pass code
+ // for two pass encodes
+ cpi->this_frame_target = cpi->per_frame_bandwidth;
+ } else
+ cpi->this_frame_target =
+ (estimate_bits_at_q(1, Q, cpi->common.MBs, 1.0)
+ * cpi->last_boost) / 100;
+
+ }
+ // If there is an active ARF at this location use the minimum
+ // bits on this frame even if it is a contructed arf.
+ // The active maximum quantizer insures that an appropriate
+ // number of bits will be spent if needed for contstructed ARFs.
+ else {
+ cpi->this_frame_target = 0;
}
+
+ cpi->current_gf_interval = cpi->frames_till_gf_update_due;
+ }
}
-void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var)
-{
- int Q = cpi->common.base_qindex;
- int correction_factor = 100;
- double rate_correction_factor;
- double adjustment_limit;
+void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var) {
+ int Q = cpi->common.base_qindex;
+ int correction_factor = 100;
+ double rate_correction_factor;
+ double adjustment_limit;
- int projected_size_based_on_q = 0;
+ int projected_size_based_on_q = 0;
- // Clear down mmx registers to allow floating point in what follows
- vp8_clear_system_state(); //__asm emms;
+ // Clear down mmx registers to allow floating point in what follows
+ vp8_clear_system_state(); // __asm emms;
- if (cpi->common.frame_type == KEY_FRAME)
- {
- rate_correction_factor = cpi->key_frame_rate_correction_factor;
- }
+ if (cpi->common.frame_type == KEY_FRAME) {
+ rate_correction_factor = cpi->key_frame_rate_correction_factor;
+ } else {
+ if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ rate_correction_factor = cpi->gf_rate_correction_factor;
else
- {
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
- rate_correction_factor = cpi->gf_rate_correction_factor;
- else
- rate_correction_factor = cpi->rate_correction_factor;
- }
-
- // Work out how big we would have expected the frame to be at this Q given the current correction factor.
- // Stay in double to avoid int overflow when values are large
- projected_size_based_on_q =
- (int)(((.5 + rate_correction_factor *
- vp8_bits_per_mb(cpi->common.frame_type, Q)) *
- cpi->common.MBs) / (1 << BPER_MB_NORMBITS));
-
- // Make some allowance for cpi->zbin_over_quant
- if (cpi->zbin_over_quant > 0)
- {
- int Z = cpi->zbin_over_quant;
- double Factor = 0.99;
- double factor_adjustment = 0.01 / 256.0; //(double)ZBIN_OQ_MAX;
-
- while (Z > 0)
- {
- Z --;
- projected_size_based_on_q =
- (int)(Factor * projected_size_based_on_q);
- Factor += factor_adjustment;
-
- if (Factor >= 0.999)
- Factor = 0.999;
- }
+ rate_correction_factor = cpi->rate_correction_factor;
+ }
+
+ // Work out how big we would have expected the frame to be at this Q given the current correction factor.
+ // Stay in double to avoid int overflow when values are large
+ projected_size_based_on_q =
+ (int)(((.5 + rate_correction_factor *
+ vp8_bits_per_mb(cpi->common.frame_type, Q)) *
+ cpi->common.MBs) / (1 << BPER_MB_NORMBITS));
+
+ // Make some allowance for cpi->zbin_over_quant
+ if (cpi->zbin_over_quant > 0) {
+ int Z = cpi->zbin_over_quant;
+ double Factor = 0.99;
+ double factor_adjustment = 0.01 / 256.0; // (double)ZBIN_OQ_MAX;
+
+ while (Z > 0) {
+ Z--;
+ projected_size_based_on_q =
+ (int)(Factor * projected_size_based_on_q);
+ Factor += factor_adjustment;
+
+ if (Factor >= 0.999)
+ Factor = 0.999;
}
+ }
- // Work out a size correction factor.
- //if ( cpi->this_frame_target > 0 )
- // correction_factor = (100 * cpi->projected_frame_size) / cpi->this_frame_target;
- if (projected_size_based_on_q > 0)
- correction_factor = (100 * cpi->projected_frame_size) / projected_size_based_on_q;
+ // Work out a size correction factor.
+ // if ( cpi->this_frame_target > 0 )
+ // correction_factor = (100 * cpi->projected_frame_size) / cpi->this_frame_target;
+ if (projected_size_based_on_q > 0)
+ correction_factor = (100 * cpi->projected_frame_size) / projected_size_based_on_q;
- // More heavily damped adjustment used if we have been oscillating either side of target
- switch (damp_var)
- {
+ // More heavily damped adjustment used if we have been oscillating either side of target
+ switch (damp_var) {
case 0:
- adjustment_limit = 0.75;
- break;
+ adjustment_limit = 0.75;
+ break;
case 1:
- adjustment_limit = 0.375;
- break;
+ adjustment_limit = 0.375;
+ break;
case 2:
default:
- adjustment_limit = 0.25;
- break;
- }
-
- //if ( (correction_factor > 102) && (Q < cpi->active_worst_quality) )
- if (correction_factor > 102)
- {
- // We are not already at the worst allowable quality
- correction_factor = (int)(100.5 + ((correction_factor - 100) * adjustment_limit));
- rate_correction_factor = ((rate_correction_factor * correction_factor) / 100);
-
- // Keep rate_correction_factor within limits
- if (rate_correction_factor > MAX_BPB_FACTOR)
- rate_correction_factor = MAX_BPB_FACTOR;
- }
- //else if ( (correction_factor < 99) && (Q > cpi->active_best_quality) )
- else if (correction_factor < 99)
- {
- // We are not already at the best allowable quality
- correction_factor = (int)(100.5 - ((100 - correction_factor) * adjustment_limit));
- rate_correction_factor = ((rate_correction_factor * correction_factor) / 100);
-
- // Keep rate_correction_factor within limits
- if (rate_correction_factor < MIN_BPB_FACTOR)
- rate_correction_factor = MIN_BPB_FACTOR;
- }
-
- if (cpi->common.frame_type == KEY_FRAME)
- cpi->key_frame_rate_correction_factor = rate_correction_factor;
+ adjustment_limit = 0.25;
+ break;
+ }
+
+ // if ( (correction_factor > 102) && (Q < cpi->active_worst_quality) )
+ if (correction_factor > 102) {
+ // We are not already at the worst allowable quality
+ correction_factor = (int)(100.5 + ((correction_factor - 100) * adjustment_limit));
+ rate_correction_factor = ((rate_correction_factor * correction_factor) / 100);
+
+ // Keep rate_correction_factor within limits
+ if (rate_correction_factor > MAX_BPB_FACTOR)
+ rate_correction_factor = MAX_BPB_FACTOR;
+ }
+ // else if ( (correction_factor < 99) && (Q > cpi->active_best_quality) )
+ else if (correction_factor < 99) {
+ // We are not already at the best allowable quality
+ correction_factor = (int)(100.5 - ((100 - correction_factor) * adjustment_limit));
+ rate_correction_factor = ((rate_correction_factor * correction_factor) / 100);
+
+ // Keep rate_correction_factor within limits
+ if (rate_correction_factor < MIN_BPB_FACTOR)
+ rate_correction_factor = MIN_BPB_FACTOR;
+ }
+
+ if (cpi->common.frame_type == KEY_FRAME)
+ cpi->key_frame_rate_correction_factor = rate_correction_factor;
+ else {
+ if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ cpi->gf_rate_correction_factor = rate_correction_factor;
else
- {
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
- cpi->gf_rate_correction_factor = rate_correction_factor;
- else
- cpi->rate_correction_factor = rate_correction_factor;
- }
+ cpi->rate_correction_factor = rate_correction_factor;
+ }
}
-int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
-{
- int Q = cpi->active_worst_quality;
+int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame) {
+ int Q = cpi->active_worst_quality;
- int i;
- int last_error = INT_MAX;
- int target_bits_per_mb;
- int bits_per_mb_at_this_q;
- double correction_factor;
+ int i;
+ int last_error = INT_MAX;
+ int target_bits_per_mb;
+ int bits_per_mb_at_this_q;
+ double correction_factor;
- // Reset Zbin OQ value
- cpi->zbin_over_quant = 0;
+ // Reset Zbin OQ value
+ cpi->zbin_over_quant = 0;
- // Select the appropriate correction factor based upon type of frame.
- if (cpi->common.frame_type == KEY_FRAME)
- correction_factor = cpi->key_frame_rate_correction_factor;
+ // Select the appropriate correction factor based upon type of frame.
+ if (cpi->common.frame_type == KEY_FRAME)
+ correction_factor = cpi->key_frame_rate_correction_factor;
+ else {
+ if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ correction_factor = cpi->gf_rate_correction_factor;
else
- {
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
- correction_factor = cpi->gf_rate_correction_factor;
- else
- correction_factor = cpi->rate_correction_factor;
- }
+ correction_factor = cpi->rate_correction_factor;
+ }
- // Calculate required scaling factor based on target frame size and size of frame produced using previous Q
- if (target_bits_per_frame >= (INT_MAX >> BPER_MB_NORMBITS))
- target_bits_per_mb = (target_bits_per_frame / cpi->common.MBs) << BPER_MB_NORMBITS; // Case where we would overflow int
- else
- target_bits_per_mb = (target_bits_per_frame << BPER_MB_NORMBITS) / cpi->common.MBs;
+ // Calculate required scaling factor based on target frame size and size of frame produced using previous Q
+ if (target_bits_per_frame >= (INT_MAX >> BPER_MB_NORMBITS))
+ target_bits_per_mb = (target_bits_per_frame / cpi->common.MBs) << BPER_MB_NORMBITS; // Case where we would overflow int
+ else
+ target_bits_per_mb = (target_bits_per_frame << BPER_MB_NORMBITS) / cpi->common.MBs;
- i = cpi->active_best_quality;
+ i = cpi->active_best_quality;
- do
- {
- bits_per_mb_at_this_q =
- (int)(.5 + correction_factor *
- vp8_bits_per_mb(cpi->common.frame_type, i ));
+ do {
+ bits_per_mb_at_this_q =
+ (int)(.5 + correction_factor *
+ vp8_bits_per_mb(cpi->common.frame_type, i));
- if (bits_per_mb_at_this_q <= target_bits_per_mb)
- {
- if ((target_bits_per_mb - bits_per_mb_at_this_q) <= last_error)
- Q = i;
- else
- Q = i - 1;
+ if (bits_per_mb_at_this_q <= target_bits_per_mb) {
+ if ((target_bits_per_mb - bits_per_mb_at_this_q) <= last_error)
+ Q = i;
+ else
+ Q = i - 1;
- break;
- }
- else
- last_error = bits_per_mb_at_this_q - target_bits_per_mb;
- }
- while (++i <= cpi->active_worst_quality);
+ break;
+ } else
+ last_error = bits_per_mb_at_this_q - target_bits_per_mb;
+ } while (++i <= cpi->active_worst_quality);
- // If we are at MAXQ then enable Q over-run which seeks to claw back additional bits through things like
- // the RD multiplier and zero bin size.
- if (Q >= MAXQ)
- {
- int zbin_oqmax;
+ // If we are at MAXQ then enable Q over-run which seeks to claw back additional bits through things like
+ // the RD multiplier and zero bin size.
+ if (Q >= MAXQ) {
+ int zbin_oqmax;
- double Factor = 0.99;
- double factor_adjustment = 0.01 / 256.0; //(double)ZBIN_OQ_MAX;
+ double Factor = 0.99;
+ double factor_adjustment = 0.01 / 256.0; // (double)ZBIN_OQ_MAX;
- if (cpi->common.frame_type == KEY_FRAME)
- zbin_oqmax = 0; //ZBIN_OQ_MAX/16
- else if (cpi->common.refresh_alt_ref_frame || (cpi->common.refresh_golden_frame && !cpi->source_alt_ref_active))
- zbin_oqmax = 16;
- else
- zbin_oqmax = ZBIN_OQ_MAX;
+ if (cpi->common.frame_type == KEY_FRAME)
+ zbin_oqmax = 0; // ZBIN_OQ_MAX/16
+ else if (cpi->common.refresh_alt_ref_frame || (cpi->common.refresh_golden_frame && !cpi->source_alt_ref_active))
+ zbin_oqmax = 16;
+ else
+ zbin_oqmax = ZBIN_OQ_MAX;
- // Each incrment in the zbin is assumed to have a fixed effect on bitrate. This is not of course true.
- // The effect will be highly clip dependent and may well have sudden steps.
- // The idea here is to acheive higher effective quantizers than the normal maximum by expanding the zero
- // bin and hence decreasing the number of low magnitude non zero coefficients.
- while (cpi->zbin_over_quant < zbin_oqmax)
- {
- cpi->zbin_over_quant ++;
+ // Each incrment in the zbin is assumed to have a fixed effect on bitrate. This is not of course true.
+ // The effect will be highly clip dependent and may well have sudden steps.
+ // The idea here is to acheive higher effective quantizers than the normal maximum by expanding the zero
+ // bin and hence decreasing the number of low magnitude non zero coefficients.
+ while (cpi->zbin_over_quant < zbin_oqmax) {
+ cpi->zbin_over_quant++;
- if (cpi->zbin_over_quant > zbin_oqmax)
- cpi->zbin_over_quant = zbin_oqmax;
+ if (cpi->zbin_over_quant > zbin_oqmax)
+ cpi->zbin_over_quant = zbin_oqmax;
- // Adjust bits_per_mb_at_this_q estimate
- bits_per_mb_at_this_q = (int)(Factor * bits_per_mb_at_this_q);
- Factor += factor_adjustment;
+ // Adjust bits_per_mb_at_this_q estimate
+ bits_per_mb_at_this_q = (int)(Factor * bits_per_mb_at_this_q);
+ Factor += factor_adjustment;
- if (Factor >= 0.999)
- Factor = 0.999;
-
- if (bits_per_mb_at_this_q <= target_bits_per_mb) // Break out if we get down to the target rate
- break;
- }
+ if (Factor >= 0.999)
+ Factor = 0.999;
+ if (bits_per_mb_at_this_q <= target_bits_per_mb) // Break out if we get down to the target rate
+ break;
}
- return Q;
+ }
+
+ return Q;
}
-static int estimate_keyframe_frequency(VP8_COMP *cpi)
-{
- int i;
+static int estimate_keyframe_frequency(VP8_COMP *cpi) {
+ int i;
- // Average key frame frequency
- int av_key_frame_frequency = 0;
+ // Average key frame frequency
+ int av_key_frame_frequency = 0;
- /* First key frame at start of sequence is a special case. We have no
- * frequency data.
+ /* First key frame at start of sequence is a special case. We have no
+ * frequency data.
+ */
+ if (cpi->key_frame_count == 1) {
+ /* Assume a default of 1 kf every 2 seconds, or the max kf interval,
+ * whichever is smaller.
*/
- if (cpi->key_frame_count == 1)
- {
- /* Assume a default of 1 kf every 2 seconds, or the max kf interval,
- * whichever is smaller.
- */
- int key_freq = cpi->oxcf.key_freq>0 ? cpi->oxcf.key_freq : 1;
- av_key_frame_frequency = (int)cpi->output_frame_rate * 2;
-
- if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
- av_key_frame_frequency = cpi->oxcf.key_freq;
-
- cpi->prior_key_frame_distance[KEY_FRAME_CONTEXT - 1]
- = av_key_frame_frequency;
- }
- else
- {
- unsigned int total_weight = 0;
- int last_kf_interval =
- (cpi->frames_since_key > 0) ? cpi->frames_since_key : 1;
-
- /* reset keyframe context and calculate weighted average of last
- * KEY_FRAME_CONTEXT keyframes
- */
- for (i = 0; i < KEY_FRAME_CONTEXT; i++)
- {
- if (i < KEY_FRAME_CONTEXT - 1)
- cpi->prior_key_frame_distance[i]
- = cpi->prior_key_frame_distance[i+1];
- else
- cpi->prior_key_frame_distance[i] = last_kf_interval;
-
- av_key_frame_frequency += prior_key_frame_weight[i]
- * cpi->prior_key_frame_distance[i];
- total_weight += prior_key_frame_weight[i];
- }
+ int key_freq = cpi->oxcf.key_freq > 0 ? cpi->oxcf.key_freq : 1;
+ av_key_frame_frequency = (int)cpi->output_frame_rate * 2;
- av_key_frame_frequency /= total_weight;
+ if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
+ av_key_frame_frequency = cpi->oxcf.key_freq;
+ cpi->prior_key_frame_distance[KEY_FRAME_CONTEXT - 1]
+ = av_key_frame_frequency;
+ } else {
+ unsigned int total_weight = 0;
+ int last_kf_interval =
+ (cpi->frames_since_key > 0) ? cpi->frames_since_key : 1;
+
+ /* reset keyframe context and calculate weighted average of last
+ * KEY_FRAME_CONTEXT keyframes
+ */
+ for (i = 0; i < KEY_FRAME_CONTEXT; i++) {
+ if (i < KEY_FRAME_CONTEXT - 1)
+ cpi->prior_key_frame_distance[i]
+ = cpi->prior_key_frame_distance[i + 1];
+ else
+ cpi->prior_key_frame_distance[i] = last_kf_interval;
+
+ av_key_frame_frequency += prior_key_frame_weight[i]
+ * cpi->prior_key_frame_distance[i];
+ total_weight += prior_key_frame_weight[i];
}
- return av_key_frame_frequency;
+
+ av_key_frame_frequency /= total_weight;
+
+ }
+ return av_key_frame_frequency;
}
-void vp8_adjust_key_frame_context(VP8_COMP *cpi)
-{
- // Clear down mmx registers to allow floating point in what follows
- vp8_clear_system_state();
+void vp8_adjust_key_frame_context(VP8_COMP *cpi) {
+ // Clear down mmx registers to allow floating point in what follows
+ vp8_clear_system_state();
- cpi->frames_since_key = 0;
- cpi->key_frame_count++;
+ cpi->frames_since_key = 0;
+ cpi->key_frame_count++;
}
-void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit, int *frame_over_shoot_limit)
-{
- // Set-up bounds on acceptable frame size:
- if (cpi->oxcf.fixed_q >= 0)
- {
- // Fixed Q scenario: frame size never outranges target (there is no target!)
- *frame_under_shoot_limit = 0;
- *frame_over_shoot_limit = INT_MAX;
- }
- else
- {
- if (cpi->common.frame_type == KEY_FRAME)
- {
- *frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
- *frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
+void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit, int *frame_over_shoot_limit) {
+ // Set-up bounds on acceptable frame size:
+ if (cpi->oxcf.fixed_q >= 0) {
+ // Fixed Q scenario: frame size never outranges target (there is no target!)
+ *frame_under_shoot_limit = 0;
+ *frame_over_shoot_limit = INT_MAX;
+ } else {
+ if (cpi->common.frame_type == KEY_FRAME) {
+ *frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
+ *frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
+ } else {
+ if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame) {
+ *frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
+ *frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
+ } else {
+ // Stron overshoot limit for constrained quality
+ if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
+ *frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
+ *frame_under_shoot_limit = cpi->this_frame_target * 2 / 8;
+ } else {
+ *frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
+ *frame_under_shoot_limit = cpi->this_frame_target * 5 / 8;
}
- else
- {
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
- {
- *frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
- *frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
- }
- else
- {
- // Stron overshoot limit for constrained quality
- if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY)
- {
- *frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
- *frame_under_shoot_limit = cpi->this_frame_target * 2 / 8;
- }
- else
- {
- *frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
- *frame_under_shoot_limit = cpi->this_frame_target * 5 / 8;
- }
- }
- }
-
- // For very small rate targets where the fractional adjustment
- // (eg * 7/8) may be tiny make sure there is at least a minimum
- // range.
- *frame_over_shoot_limit += 200;
- *frame_under_shoot_limit -= 200;
- if ( *frame_under_shoot_limit < 0 )
- *frame_under_shoot_limit = 0;
+ }
}
+
+ // For very small rate targets where the fractional adjustment
+ // (eg * 7/8) may be tiny make sure there is at least a minimum
+ // range.
+ *frame_over_shoot_limit += 200;
+ *frame_under_shoot_limit -= 200;
+ if (*frame_under_shoot_limit < 0)
+ *frame_under_shoot_limit = 0;
+ }
}
// return of 0 means drop frame
-int vp8_pick_frame_size(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
+int vp8_pick_frame_size(VP8_COMP *cpi) {
+ VP8_COMMON *cm = &cpi->common;
- if (cm->frame_type == KEY_FRAME)
- calc_iframe_target_size(cpi);
- else
- calc_pframe_target_size(cpi);
+ if (cm->frame_type == KEY_FRAME)
+ calc_iframe_target_size(cpi);
+ else
+ calc_pframe_target_size(cpi);
- return 1;
+ return 1;
}
diff --git a/vp8/encoder/ratectrl.h b/vp8/encoder/ratectrl.h
index 76eff47a0..ac1a76f4c 100644
--- a/vp8/encoder/ratectrl.h
+++ b/vp8/encoder/ratectrl.h
@@ -27,9 +27,9 @@ extern void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_
// return of 0 means drop frame
extern int vp8_pick_frame_size(VP8_COMP *cpi);
-extern double vp8_convert_qindex_to_q( int qindex );
-extern int vp8_gfboost_qadjust( int qindex );
-extern int vp8_bits_per_mb( FRAME_TYPE frame_type, int qindex );
+extern double vp8_convert_qindex_to_q(int qindex);
+extern int vp8_gfboost_qadjust(int qindex);
+extern int vp8_bits_per_mb(FRAME_TYPE frame_type, int qindex);
void vp8_setup_inter_frame(VP8_COMP *cpi);
#endif
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index 47f13cee7..00732fdc7 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -60,187 +60,182 @@ extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x);
#define INVALID_MV 0x80008000
-static const int auto_speed_thresh[17] =
-{
- 1000,
- 200,
- 150,
- 130,
- 150,
- 125,
- 120,
- 115,
- 115,
- 115,
- 115,
- 115,
- 115,
- 115,
- 115,
- 115,
- 105
+static const int auto_speed_thresh[17] = {
+ 1000,
+ 200,
+ 150,
+ 130,
+ 150,
+ 125,
+ 120,
+ 115,
+ 115,
+ 115,
+ 115,
+ 115,
+ 115,
+ 115,
+ 115,
+ 115,
+ 105
};
#if CONFIG_PRED_FILTER
-const MODE_DEFINITION vp8_mode_order[MAX_MODES] =
-{
- {ZEROMV, LAST_FRAME, 0, 0},
- {ZEROMV, LAST_FRAME, 0, 1},
- {DC_PRED, INTRA_FRAME, 0, 0},
-
- {NEARESTMV, LAST_FRAME, 0, 0},
- {NEARESTMV, LAST_FRAME, 0, 1},
- {NEARMV, LAST_FRAME, 0, 0},
- {NEARMV, LAST_FRAME, 0, 1},
-
- {ZEROMV, GOLDEN_FRAME, 0, 0},
- {ZEROMV, GOLDEN_FRAME, 0, 1},
- {NEARESTMV, GOLDEN_FRAME, 0, 0},
- {NEARESTMV, GOLDEN_FRAME, 0, 1},
-
- {ZEROMV, ALTREF_FRAME, 0, 0},
- {ZEROMV, ALTREF_FRAME, 0, 1},
- {NEARESTMV, ALTREF_FRAME, 0, 0},
- {NEARESTMV, ALTREF_FRAME, 0, 1},
-
- {NEARMV, GOLDEN_FRAME, 0, 0},
- {NEARMV, GOLDEN_FRAME, 0, 1},
- {NEARMV, ALTREF_FRAME, 0, 0},
- {NEARMV, ALTREF_FRAME, 0, 1},
-
- {V_PRED, INTRA_FRAME, 0, 0},
- {H_PRED, INTRA_FRAME, 0, 0},
+const MODE_DEFINITION vp8_mode_order[MAX_MODES] = {
+ {ZEROMV, LAST_FRAME, 0, 0},
+ {ZEROMV, LAST_FRAME, 0, 1},
+ {DC_PRED, INTRA_FRAME, 0, 0},
+
+ {NEARESTMV, LAST_FRAME, 0, 0},
+ {NEARESTMV, LAST_FRAME, 0, 1},
+ {NEARMV, LAST_FRAME, 0, 0},
+ {NEARMV, LAST_FRAME, 0, 1},
+
+ {ZEROMV, GOLDEN_FRAME, 0, 0},
+ {ZEROMV, GOLDEN_FRAME, 0, 1},
+ {NEARESTMV, GOLDEN_FRAME, 0, 0},
+ {NEARESTMV, GOLDEN_FRAME, 0, 1},
+
+ {ZEROMV, ALTREF_FRAME, 0, 0},
+ {ZEROMV, ALTREF_FRAME, 0, 1},
+ {NEARESTMV, ALTREF_FRAME, 0, 0},
+ {NEARESTMV, ALTREF_FRAME, 0, 1},
+
+ {NEARMV, GOLDEN_FRAME, 0, 0},
+ {NEARMV, GOLDEN_FRAME, 0, 1},
+ {NEARMV, ALTREF_FRAME, 0, 0},
+ {NEARMV, ALTREF_FRAME, 0, 1},
+
+ {V_PRED, INTRA_FRAME, 0, 0},
+ {H_PRED, INTRA_FRAME, 0, 0},
#if CONFIG_NEWINTRAMODES
- {D45_PRED, INTRA_FRAME, 0, 0},
- {D135_PRED, INTRA_FRAME, 0, 0},
- {D117_PRED, INTRA_FRAME, 0, 0},
- {D153_PRED, INTRA_FRAME, 0, 0},
- {D27_PRED, INTRA_FRAME, 0, 0},
- {D63_PRED, INTRA_FRAME, 0, 0},
-#endif
-
- {TM_PRED, INTRA_FRAME, 0, 0},
-
- {NEWMV, LAST_FRAME, 0, 0},
- {NEWMV, LAST_FRAME, 0, 1},
- {NEWMV, GOLDEN_FRAME, 0, 0},
- {NEWMV, GOLDEN_FRAME, 0, 1},
- {NEWMV, ALTREF_FRAME, 0, 0},
- {NEWMV, ALTREF_FRAME, 0, 1},
-
- {SPLITMV, LAST_FRAME, 0, 0},
- {SPLITMV, GOLDEN_FRAME, 0, 0},
- {SPLITMV, ALTREF_FRAME, 0, 0},
-
- {B_PRED, INTRA_FRAME, 0, 0},
- {I8X8_PRED, INTRA_FRAME, 0, 0},
-
- /* compound prediction modes */
- {ZEROMV, LAST_FRAME, GOLDEN_FRAME, 0},
- {NEARESTMV, LAST_FRAME, GOLDEN_FRAME, 0},
- {NEARMV, LAST_FRAME, GOLDEN_FRAME, 0},
-
- {ZEROMV, ALTREF_FRAME, LAST_FRAME, 0},
- {NEARESTMV, ALTREF_FRAME, LAST_FRAME, 0},
- {NEARMV, ALTREF_FRAME, LAST_FRAME, 0},
-
- {ZEROMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
- {NEARESTMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
- {NEARMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
-
- {NEWMV, LAST_FRAME, GOLDEN_FRAME, 0},
- {NEWMV, ALTREF_FRAME, LAST_FRAME, 0},
- {NEWMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
-
- {SPLITMV, LAST_FRAME, GOLDEN_FRAME, 0},
- {SPLITMV, ALTREF_FRAME, LAST_FRAME, 0},
- {SPLITMV, GOLDEN_FRAME, ALTREF_FRAME, 0}
+ {D45_PRED, INTRA_FRAME, 0, 0},
+ {D135_PRED, INTRA_FRAME, 0, 0},
+ {D117_PRED, INTRA_FRAME, 0, 0},
+ {D153_PRED, INTRA_FRAME, 0, 0},
+ {D27_PRED, INTRA_FRAME, 0, 0},
+ {D63_PRED, INTRA_FRAME, 0, 0},
+#endif
+
+ {TM_PRED, INTRA_FRAME, 0, 0},
+
+ {NEWMV, LAST_FRAME, 0, 0},
+ {NEWMV, LAST_FRAME, 0, 1},
+ {NEWMV, GOLDEN_FRAME, 0, 0},
+ {NEWMV, GOLDEN_FRAME, 0, 1},
+ {NEWMV, ALTREF_FRAME, 0, 0},
+ {NEWMV, ALTREF_FRAME, 0, 1},
+
+ {SPLITMV, LAST_FRAME, 0, 0},
+ {SPLITMV, GOLDEN_FRAME, 0, 0},
+ {SPLITMV, ALTREF_FRAME, 0, 0},
+
+ {B_PRED, INTRA_FRAME, 0, 0},
+ {I8X8_PRED, INTRA_FRAME, 0, 0},
+
+ /* compound prediction modes */
+ {ZEROMV, LAST_FRAME, GOLDEN_FRAME, 0},
+ {NEARESTMV, LAST_FRAME, GOLDEN_FRAME, 0},
+ {NEARMV, LAST_FRAME, GOLDEN_FRAME, 0},
+
+ {ZEROMV, ALTREF_FRAME, LAST_FRAME, 0},
+ {NEARESTMV, ALTREF_FRAME, LAST_FRAME, 0},
+ {NEARMV, ALTREF_FRAME, LAST_FRAME, 0},
+
+ {ZEROMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
+ {NEARESTMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
+ {NEARMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
+
+ {NEWMV, LAST_FRAME, GOLDEN_FRAME, 0},
+ {NEWMV, ALTREF_FRAME, LAST_FRAME, 0},
+ {NEWMV, GOLDEN_FRAME, ALTREF_FRAME, 0},
+
+ {SPLITMV, LAST_FRAME, GOLDEN_FRAME, 0},
+ {SPLITMV, ALTREF_FRAME, LAST_FRAME, 0},
+ {SPLITMV, GOLDEN_FRAME, ALTREF_FRAME, 0}
};
#else
-const MODE_DEFINITION vp8_mode_order[MAX_MODES] =
-{
- {ZEROMV, LAST_FRAME, 0},
- {DC_PRED, INTRA_FRAME, 0},
+const MODE_DEFINITION vp8_mode_order[MAX_MODES] = {
+ {ZEROMV, LAST_FRAME, 0},
+ {DC_PRED, INTRA_FRAME, 0},
- {NEARESTMV, LAST_FRAME, 0},
- {NEARMV, LAST_FRAME, 0},
+ {NEARESTMV, LAST_FRAME, 0},
+ {NEARMV, LAST_FRAME, 0},
- {ZEROMV, GOLDEN_FRAME, 0},
- {NEARESTMV, GOLDEN_FRAME, 0},
+ {ZEROMV, GOLDEN_FRAME, 0},
+ {NEARESTMV, GOLDEN_FRAME, 0},
- {ZEROMV, ALTREF_FRAME, 0},
- {NEARESTMV, ALTREF_FRAME, 0},
+ {ZEROMV, ALTREF_FRAME, 0},
+ {NEARESTMV, ALTREF_FRAME, 0},
- {NEARMV, GOLDEN_FRAME, 0},
- {NEARMV, ALTREF_FRAME, 0},
+ {NEARMV, GOLDEN_FRAME, 0},
+ {NEARMV, ALTREF_FRAME, 0},
- {V_PRED, INTRA_FRAME, 0},
- {H_PRED, INTRA_FRAME, 0},
+ {V_PRED, INTRA_FRAME, 0},
+ {H_PRED, INTRA_FRAME, 0},
#if CONFIG_NEWINTRAMODES
- {D45_PRED, INTRA_FRAME, 0},
- {D135_PRED, INTRA_FRAME, 0},
- {D117_PRED, INTRA_FRAME, 0},
- {D153_PRED, INTRA_FRAME, 0},
- {D27_PRED, INTRA_FRAME, 0},
- {D63_PRED, INTRA_FRAME, 0},
+ {D45_PRED, INTRA_FRAME, 0},
+ {D135_PRED, INTRA_FRAME, 0},
+ {D117_PRED, INTRA_FRAME, 0},
+ {D153_PRED, INTRA_FRAME, 0},
+ {D27_PRED, INTRA_FRAME, 0},
+ {D63_PRED, INTRA_FRAME, 0},
#endif
- {TM_PRED, INTRA_FRAME, 0},
+ {TM_PRED, INTRA_FRAME, 0},
- {NEWMV, LAST_FRAME, 0},
- {NEWMV, GOLDEN_FRAME, 0},
- {NEWMV, ALTREF_FRAME, 0},
+ {NEWMV, LAST_FRAME, 0},
+ {NEWMV, GOLDEN_FRAME, 0},
+ {NEWMV, ALTREF_FRAME, 0},
- {SPLITMV, LAST_FRAME, 0},
- {SPLITMV, GOLDEN_FRAME, 0},
- {SPLITMV, ALTREF_FRAME, 0},
+ {SPLITMV, LAST_FRAME, 0},
+ {SPLITMV, GOLDEN_FRAME, 0},
+ {SPLITMV, ALTREF_FRAME, 0},
- {B_PRED, INTRA_FRAME, 0},
- {I8X8_PRED, INTRA_FRAME, 0},
+ {B_PRED, INTRA_FRAME, 0},
+ {I8X8_PRED, INTRA_FRAME, 0},
- /* compound prediction modes */
- {ZEROMV, LAST_FRAME, GOLDEN_FRAME},
- {NEARESTMV, LAST_FRAME, GOLDEN_FRAME},
- {NEARMV, LAST_FRAME, GOLDEN_FRAME},
+ /* compound prediction modes */
+ {ZEROMV, LAST_FRAME, GOLDEN_FRAME},
+ {NEARESTMV, LAST_FRAME, GOLDEN_FRAME},
+ {NEARMV, LAST_FRAME, GOLDEN_FRAME},
- {ZEROMV, ALTREF_FRAME, LAST_FRAME},
- {NEARESTMV, ALTREF_FRAME, LAST_FRAME},
- {NEARMV, ALTREF_FRAME, LAST_FRAME},
+ {ZEROMV, ALTREF_FRAME, LAST_FRAME},
+ {NEARESTMV, ALTREF_FRAME, LAST_FRAME},
+ {NEARMV, ALTREF_FRAME, LAST_FRAME},
- {ZEROMV, GOLDEN_FRAME, ALTREF_FRAME},
- {NEARESTMV, GOLDEN_FRAME, ALTREF_FRAME},
- {NEARMV, GOLDEN_FRAME, ALTREF_FRAME},
+ {ZEROMV, GOLDEN_FRAME, ALTREF_FRAME},
+ {NEARESTMV, GOLDEN_FRAME, ALTREF_FRAME},
+ {NEARMV, GOLDEN_FRAME, ALTREF_FRAME},
- {NEWMV, LAST_FRAME, GOLDEN_FRAME},
- {NEWMV, ALTREF_FRAME, LAST_FRAME },
- {NEWMV, GOLDEN_FRAME, ALTREF_FRAME},
+ {NEWMV, LAST_FRAME, GOLDEN_FRAME},
+ {NEWMV, ALTREF_FRAME, LAST_FRAME },
+ {NEWMV, GOLDEN_FRAME, ALTREF_FRAME},
- {SPLITMV, LAST_FRAME, GOLDEN_FRAME},
- {SPLITMV, ALTREF_FRAME, LAST_FRAME },
- {SPLITMV, GOLDEN_FRAME, ALTREF_FRAME}
+ {SPLITMV, LAST_FRAME, GOLDEN_FRAME},
+ {SPLITMV, ALTREF_FRAME, LAST_FRAME },
+ {SPLITMV, GOLDEN_FRAME, ALTREF_FRAME}
};
#endif
static void fill_token_costs(
- unsigned int (*c)[COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS],
- const vp8_prob (*p)[COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES],
- int block_type_counts)
-{
- int i, j, k;
-
- for (i = 0; i < block_type_counts; i++)
- for (j = 0; j < COEF_BANDS; j++)
- for (k = 0; k < PREV_COEF_CONTEXTS; k++)
- {
- if(k == 0 && ((j > 0 && i > 0) || (j > 1 && i == 0)))
- vp8_cost_tokens_skip((int *)( c [i][j][k]),
- p [i][j][k],
- vp8_coef_tree);
- else
- vp8_cost_tokens((int *)(c [i][j][k]),
- p [i][j][k],
- vp8_coef_tree);
- }
+ unsigned int (*c)[COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS],
+ const vp8_prob(*p)[COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES],
+ int block_type_counts) {
+ int i, j, k;
+
+ for (i = 0; i < block_type_counts; i++)
+ for (j = 0; j < COEF_BANDS; j++)
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
+ if (k == 0 && ((j > 0 && i > 0) || (j > 1 && i == 0)))
+ vp8_cost_tokens_skip((int *)(c [i][j][k]),
+ p [i][j][k],
+ vp8_coef_tree);
+ else
+ vp8_cost_tokens((int *)(c [i][j][k]),
+ p [i][j][k],
+ vp8_coef_tree);
+ }
}
@@ -256,710 +251,648 @@ static int rd_iifactor [ 32 ] = { 4, 4, 3, 2, 1, 0, 0, 0,
static int sad_per_bit16lut[QINDEX_RANGE];
static int sad_per_bit4lut[QINDEX_RANGE];
-void vp8_init_me_luts()
-{
- int i;
-
- // Initialize the sad lut tables using a formulaic calculation for now
- // This is to make it easier to resolve the impact of experimental changes
- // to the quantizer tables.
- for ( i = 0; i < QINDEX_RANGE; i++ )
- {
- sad_per_bit16lut[i] =
- (int)((0.0418*vp8_convert_qindex_to_q(i)) + 2.4107);
- sad_per_bit4lut[i] = (int)((0.063*vp8_convert_qindex_to_q(i)) + 2.742);
- }
+void vp8_init_me_luts() {
+ int i;
+
+ // Initialize the sad lut tables using a formulaic calculation for now
+ // This is to make it easier to resolve the impact of experimental changes
+ // to the quantizer tables.
+ for (i = 0; i < QINDEX_RANGE; i++) {
+ sad_per_bit16lut[i] =
+ (int)((0.0418 * vp8_convert_qindex_to_q(i)) + 2.4107);
+ sad_per_bit4lut[i] = (int)((0.063 * vp8_convert_qindex_to_q(i)) + 2.742);
+ }
}
-int compute_rd_mult( int qindex )
-{
- int q;
+int compute_rd_mult(int qindex) {
+ int q;
- q = vp8_dc_quant(qindex,0);
- return (11 * q * q) >> 6;
+ q = vp8_dc_quant(qindex, 0);
+ return (11 * q * q) >> 6;
}
-void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
-{
- cpi->mb.sadperbit16 = sad_per_bit16lut[QIndex];
- cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex];
+void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex) {
+ cpi->mb.sadperbit16 = sad_per_bit16lut[QIndex];
+ cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex];
}
-void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex)
-{
- int q;
- int i;
+void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex) {
+ int q;
+ int i;
- vp8_clear_system_state(); //__asm emms;
+ vp8_clear_system_state(); // __asm emms;
- // Further tests required to see if optimum is different
- // for key frames, golden frames and arf frames.
- // if (cpi->common.refresh_golden_frame ||
- // cpi->common.refresh_alt_ref_frame)
- QIndex=(QIndex<0)? 0 : ((QIndex>MAXQ)?MAXQ : QIndex);
+ // Further tests required to see if optimum is different
+ // for key frames, golden frames and arf frames.
+ // if (cpi->common.refresh_golden_frame ||
+ // cpi->common.refresh_alt_ref_frame)
+ QIndex = (QIndex < 0) ? 0 : ((QIndex > MAXQ) ? MAXQ : QIndex);
- cpi->RDMULT = compute_rd_mult(QIndex);
+ cpi->RDMULT = compute_rd_mult(QIndex);
- // Extend rate multiplier along side quantizer zbin increases
- if (cpi->zbin_over_quant > 0)
- {
- double oq_factor;
+ // Extend rate multiplier along side quantizer zbin increases
+ if (cpi->zbin_over_quant > 0) {
+ double oq_factor;
- // Experimental code using the same basic equation as used for Q above
- // The units of cpi->zbin_over_quant are 1/128 of Q bin size
- oq_factor = 1.0 + ((double)0.0015625 * cpi->zbin_over_quant);
- cpi->RDMULT = (int)((double)cpi->RDMULT * oq_factor * oq_factor);
- }
+ // Experimental code using the same basic equation as used for Q above
+ // The units of cpi->zbin_over_quant are 1/128 of Q bin size
+ oq_factor = 1.0 + ((double)0.0015625 * cpi->zbin_over_quant);
+ cpi->RDMULT = (int)((double)cpi->RDMULT * oq_factor * oq_factor);
+ }
- if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME))
- {
- if (cpi->twopass.next_iiratio > 31)
- cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;
- else
- cpi->RDMULT +=
- (cpi->RDMULT * rd_iifactor[cpi->twopass.next_iiratio]) >> 4;
- }
+ if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
+ if (cpi->twopass.next_iiratio > 31)
+ cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;
+ else
+ cpi->RDMULT +=
+ (cpi->RDMULT * rd_iifactor[cpi->twopass.next_iiratio]) >> 4;
+ }
- if (cpi->RDMULT < 7)
- cpi->RDMULT = 7;
+ if (cpi->RDMULT < 7)
+ cpi->RDMULT = 7;
- cpi->mb.errorperbit = (cpi->RDMULT / 110);
- cpi->mb.errorperbit += (cpi->mb.errorperbit==0);
+ cpi->mb.errorperbit = (cpi->RDMULT / 110);
+ cpi->mb.errorperbit += (cpi->mb.errorperbit == 0);
- vp8_set_speed_features(cpi);
+ vp8_set_speed_features(cpi);
- q = (int)pow(vp8_dc_quant(QIndex,0)>>2, 1.25);
- q = q << 2;
- cpi->RDMULT = cpi->RDMULT << 4;
+ q = (int)pow(vp8_dc_quant(QIndex, 0) >> 2, 1.25);
+ q = q << 2;
+ cpi->RDMULT = cpi->RDMULT << 4;
- if (q < 8)
- q = 8;
+ if (q < 8)
+ q = 8;
- if (cpi->RDMULT > 1000)
- {
- cpi->RDDIV = 1;
- cpi->RDMULT /= 100;
+ if (cpi->RDMULT > 1000) {
+ cpi->RDDIV = 1;
+ cpi->RDMULT /= 100;
- for (i = 0; i < MAX_MODES; i++)
- {
- if (cpi->sf.thresh_mult[i] < INT_MAX)
- {
- cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
- }
- else
- {
- cpi->rd_threshes[i] = INT_MAX;
- }
+ for (i = 0; i < MAX_MODES; i++) {
+ if (cpi->sf.thresh_mult[i] < INT_MAX) {
+ cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
+ } else {
+ cpi->rd_threshes[i] = INT_MAX;
+ }
- cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
- }
+ cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
}
- else
- {
- cpi->RDDIV = 100;
+ } else {
+ cpi->RDDIV = 100;
- for (i = 0; i < MAX_MODES; i++)
- {
- if (cpi->sf.thresh_mult[i] < (INT_MAX / q))
- {
- cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
- }
- else
- {
- cpi->rd_threshes[i] = INT_MAX;
- }
+ for (i = 0; i < MAX_MODES; i++) {
+ if (cpi->sf.thresh_mult[i] < (INT_MAX / q)) {
+ cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
+ } else {
+ cpi->rd_threshes[i] = INT_MAX;
+ }
- cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
- }
+ cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
}
+ }
- fill_token_costs(
- cpi->mb.token_costs,
- (const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs,
- BLOCK_TYPES);
+ fill_token_costs(
+ cpi->mb.token_costs,
+ (const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs,
+ BLOCK_TYPES);
- fill_token_costs(
- cpi->mb.token_costs_8x8,
- (const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_8x8,
- BLOCK_TYPES_8X8);
+ fill_token_costs(
+ cpi->mb.token_costs_8x8,
+ (const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_8x8,
+ BLOCK_TYPES_8X8);
- /*rough estimate for costing*/
- cpi->common.kf_ymode_probs_index = cpi->common.base_qindex>>4;
- vp8_init_mode_costs(cpi);
+ /*rough estimate for costing*/
+ cpi->common.kf_ymode_probs_index = cpi->common.base_qindex >> 4;
+ vp8_init_mode_costs(cpi);
}
-void vp8_auto_select_speed(VP8_COMP *cpi)
-{
- int milliseconds_for_compress = (int)(1000000 / cpi->oxcf.frame_rate);
+void vp8_auto_select_speed(VP8_COMP *cpi) {
+ int milliseconds_for_compress = (int)(1000000 / cpi->oxcf.frame_rate);
- milliseconds_for_compress = milliseconds_for_compress * (16 - cpi->oxcf.cpu_used) / 16;
+ milliseconds_for_compress = milliseconds_for_compress * (16 - cpi->oxcf.cpu_used) / 16;
#if 0
- if (0)
- {
- FILE *f;
+ if (0) {
+ FILE *f;
- f = fopen("speed.stt", "a");
- fprintf(f, " %8ld %10ld %10ld %10ld\n",
- cpi->common.current_video_frame, cpi->Speed, milliseconds_for_compress, cpi->avg_pick_mode_time);
- fclose(f);
- }
+ f = fopen("speed.stt", "a");
+ fprintf(f, " %8ld %10ld %10ld %10ld\n",
+ cpi->common.current_video_frame, cpi->Speed, milliseconds_for_compress, cpi->avg_pick_mode_time);
+ fclose(f);
+ }
#endif
- /*
- // this is done during parameter valid check
- if( cpi->oxcf.cpu_used > 16)
- cpi->oxcf.cpu_used = 16;
- if( cpi->oxcf.cpu_used < -16)
- cpi->oxcf.cpu_used = -16;
- */
+ /*
+ // this is done during parameter valid check
+ if( cpi->oxcf.cpu_used > 16)
+ cpi->oxcf.cpu_used = 16;
+ if( cpi->oxcf.cpu_used < -16)
+ cpi->oxcf.cpu_used = -16;
+ */
- if (cpi->avg_pick_mode_time < milliseconds_for_compress && (cpi->avg_encode_time - cpi->avg_pick_mode_time) < milliseconds_for_compress)
- {
- if (cpi->avg_pick_mode_time == 0)
- {
- cpi->Speed = 4;
+ if (cpi->avg_pick_mode_time < milliseconds_for_compress && (cpi->avg_encode_time - cpi->avg_pick_mode_time) < milliseconds_for_compress) {
+ if (cpi->avg_pick_mode_time == 0) {
+ cpi->Speed = 4;
+ } else {
+ if (milliseconds_for_compress * 100 < cpi->avg_encode_time * 95) {
+ cpi->Speed += 2;
+ cpi->avg_pick_mode_time = 0;
+ cpi->avg_encode_time = 0;
+
+ if (cpi->Speed > 16) {
+ cpi->Speed = 16;
}
- else
- {
- if (milliseconds_for_compress * 100 < cpi->avg_encode_time * 95)
- {
- cpi->Speed += 2;
- cpi->avg_pick_mode_time = 0;
- cpi->avg_encode_time = 0;
-
- if (cpi->Speed > 16)
- {
- cpi->Speed = 16;
- }
- }
+ }
- if (milliseconds_for_compress * 100 > cpi->avg_encode_time * auto_speed_thresh[cpi->Speed])
- {
- cpi->Speed -= 1;
- cpi->avg_pick_mode_time = 0;
- cpi->avg_encode_time = 0;
+ if (milliseconds_for_compress * 100 > cpi->avg_encode_time * auto_speed_thresh[cpi->Speed]) {
+ cpi->Speed -= 1;
+ cpi->avg_pick_mode_time = 0;
+ cpi->avg_encode_time = 0;
- // In real-time mode, cpi->speed is in [4, 16].
- if (cpi->Speed < 4) //if ( cpi->Speed < 0 )
- {
- cpi->Speed = 4; //cpi->Speed = 0;
- }
- }
+ // In real-time mode, cpi->speed is in [4, 16].
+ if (cpi->Speed < 4) { // if ( cpi->Speed < 0 )
+ cpi->Speed = 4; // cpi->Speed = 0;
}
+ }
}
- else
- {
- cpi->Speed += 4;
+ } else {
+ cpi->Speed += 4;
- if (cpi->Speed > 16)
- cpi->Speed = 16;
+ if (cpi->Speed > 16)
+ cpi->Speed = 16;
- cpi->avg_pick_mode_time = 0;
- cpi->avg_encode_time = 0;
- }
+ cpi->avg_pick_mode_time = 0;
+ cpi->avg_encode_time = 0;
+ }
}
-int vp8_block_error_c(short *coeff, short *dqcoeff)
-{
- int i;
- int error = 0;
+int vp8_block_error_c(short *coeff, short *dqcoeff) {
+ int i;
+ int error = 0;
- for (i = 0; i < 16; i++)
- {
- int this_diff = coeff[i] - dqcoeff[i];
- error += this_diff * this_diff;
- }
+ for (i = 0; i < 16; i++) {
+ int this_diff = coeff[i] - dqcoeff[i];
+ error += this_diff * this_diff;
+ }
- return error;
+ return error;
}
-int vp8_mbblock_error_c(MACROBLOCK *mb, int dc)
-{
- BLOCK *be;
- BLOCKD *bd;
- int i, j;
- int berror, error = 0;
+int vp8_mbblock_error_c(MACROBLOCK *mb, int dc) {
+ BLOCK *be;
+ BLOCKD *bd;
+ int i, j;
+ int berror, error = 0;
- for (i = 0; i < 16; i++)
- {
- be = &mb->block[i];
- bd = &mb->e_mbd.block[i];
-
- berror = 0;
+ for (i = 0; i < 16; i++) {
+ be = &mb->block[i];
+ bd = &mb->e_mbd.block[i];
- for (j = dc; j < 16; j++)
- {
- int this_diff = be->coeff[j] - bd->dqcoeff[j];
- berror += this_diff * this_diff;
- }
+ berror = 0;
- error += berror;
+ for (j = dc; j < 16; j++) {
+ int this_diff = be->coeff[j] - bd->dqcoeff[j];
+ berror += this_diff * this_diff;
}
- return error;
+ error += berror;
+ }
+
+ return error;
}
-int vp8_mbuverror_c(MACROBLOCK *mb)
-{
+int vp8_mbuverror_c(MACROBLOCK *mb) {
- BLOCK *be;
- BLOCKD *bd;
+ BLOCK *be;
+ BLOCKD *bd;
- int i;
- int error = 0;
+ int i;
+ int error = 0;
- for (i = 16; i < 24; i++)
- {
- be = &mb->block[i];
- bd = &mb->e_mbd.block[i];
+ for (i = 16; i < 24; i++) {
+ be = &mb->block[i];
+ bd = &mb->e_mbd.block[i];
- error += vp8_block_error_c(be->coeff, bd->dqcoeff);
- }
+ error += vp8_block_error_c(be->coeff, bd->dqcoeff);
+ }
- return error;
+ return error;
}
-int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd)
-{
- unsigned char *uptr, *vptr;
- unsigned char *upred_ptr = (*(x->block[16].base_src) + x->block[16].src);
- unsigned char *vpred_ptr = (*(x->block[20].base_src) + x->block[20].src);
- int uv_stride = x->block[16].src_stride;
-
- unsigned int sse1 = 0;
- unsigned int sse2 = 0;
- int mv_row = x->e_mbd.mode_info_context->mbmi.mv.as_mv.row;
- int mv_col = x->e_mbd.mode_info_context->mbmi.mv.as_mv.col;
- int offset;
- int pre_stride = x->e_mbd.block[16].pre_stride;
-
- if (mv_row < 0)
- mv_row -= 1;
- else
- mv_row += 1;
-
- if (mv_col < 0)
- mv_col -= 1;
- else
- mv_col += 1;
-
- mv_row /= 2;
- mv_col /= 2;
-
- offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
- uptr = x->e_mbd.pre.u_buffer + offset;
- vptr = x->e_mbd.pre.v_buffer + offset;
-
- if ((mv_row | mv_col) & 7)
- {
+int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd) {
+ unsigned char *uptr, *vptr;
+ unsigned char *upred_ptr = (*(x->block[16].base_src) + x->block[16].src);
+ unsigned char *vpred_ptr = (*(x->block[20].base_src) + x->block[20].src);
+ int uv_stride = x->block[16].src_stride;
+
+ unsigned int sse1 = 0;
+ unsigned int sse2 = 0;
+ int mv_row = x->e_mbd.mode_info_context->mbmi.mv.as_mv.row;
+ int mv_col = x->e_mbd.mode_info_context->mbmi.mv.as_mv.col;
+ int offset;
+ int pre_stride = x->e_mbd.block[16].pre_stride;
+
+ if (mv_row < 0)
+ mv_row -= 1;
+ else
+ mv_row += 1;
+
+ if (mv_col < 0)
+ mv_col -= 1;
+ else
+ mv_col += 1;
+
+ mv_row /= 2;
+ mv_col /= 2;
+
+ offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+ uptr = x->e_mbd.pre.u_buffer + offset;
+ vptr = x->e_mbd.pre.v_buffer + offset;
+
+ if ((mv_row | mv_col) & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- VARIANCE_INVOKE(rtcd, subpixvar8x8)(uptr, pre_stride,
- (mv_col & 7)<<1, (mv_row & 7)<<1, upred_ptr, uv_stride, &sse2);
- VARIANCE_INVOKE(rtcd, subpixvar8x8)(vptr, pre_stride,
- (mv_col & 7)<<1, (mv_row & 7)<<1, vpred_ptr, uv_stride, &sse1);
+ VARIANCE_INVOKE(rtcd, subpixvar8x8)(uptr, pre_stride,
+ (mv_col & 7) << 1, (mv_row & 7) << 1, upred_ptr, uv_stride, &sse2);
+ VARIANCE_INVOKE(rtcd, subpixvar8x8)(vptr, pre_stride,
+ (mv_col & 7) << 1, (mv_row & 7) << 1, vpred_ptr, uv_stride, &sse1);
#else
- VARIANCE_INVOKE(rtcd, subpixvar8x8)(uptr, pre_stride,
- mv_col & 7, mv_row & 7, upred_ptr, uv_stride, &sse2);
- VARIANCE_INVOKE(rtcd, subpixvar8x8)(vptr, pre_stride,
- mv_col & 7, mv_row & 7, vpred_ptr, uv_stride, &sse1);
-#endif
- sse2 += sse1;
- }
- else
- {
- VARIANCE_INVOKE(rtcd, var8x8)(uptr, pre_stride,
- upred_ptr, uv_stride, &sse2);
- VARIANCE_INVOKE(rtcd, var8x8)(vptr, pre_stride,
- vpred_ptr, uv_stride, &sse1);
- sse2 += sse1;
- }
- return sse2;
+ VARIANCE_INVOKE(rtcd, subpixvar8x8)(uptr, pre_stride,
+ mv_col & 7, mv_row & 7, upred_ptr, uv_stride, &sse2);
+ VARIANCE_INVOKE(rtcd, subpixvar8x8)(vptr, pre_stride,
+ mv_col & 7, mv_row & 7, vpred_ptr, uv_stride, &sse1);
+#endif
+ sse2 += sse1;
+ } else {
+ VARIANCE_INVOKE(rtcd, var8x8)(uptr, pre_stride,
+ upred_ptr, uv_stride, &sse2);
+ VARIANCE_INVOKE(rtcd, var8x8)(vptr, pre_stride,
+ vpred_ptr, uv_stride, &sse1);
+ sse2 += sse1;
+ }
+ return sse2;
}
-static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, int type, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
-{
- int c = !type; /* start at coef 0, unless Y with Y2 */
- int eob = b->eob;
- int pt ; /* surrounding block/prev coef predictor */
- int cost = 0;
- short *qcoeff_ptr = b->qcoeff;
+static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, int type, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
+ int c = !type; /* start at coef 0, unless Y with Y2 */
+ int eob = b->eob;
+ int pt; /* surrounding block/prev coef predictor */
+ int cost = 0;
+ short *qcoeff_ptr = b->qcoeff;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
# define QC( I) ( qcoeff_ptr [vp8_default_zig_zag1d[I]] )
- for (; c < eob; c++)
- {
- int v = QC(c);
- int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [t];
- cost += vp8_dct_value_cost_ptr[v];
- pt = vp8_prev_token_class[t];
- }
+ for (; c < eob; c++) {
+ int v = QC(c);
+ int t = vp8_dct_value_tokens_ptr[v].Token;
+ cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [t];
+ cost += vp8_dct_value_cost_ptr[v];
+ pt = vp8_prev_token_class[t];
+ }
# undef QC
- if (c < 16)
- cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [DCT_EOB_TOKEN];
+ if (c < 16)
+ cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [DCT_EOB_TOKEN];
- pt = (c != !type); // is eob first coefficient;
- *a = *l = pt;
+ pt = (c != !type); // is eob first coefficient;
+ *a = *l = pt;
- return cost;
+ return cost;
}
-static int vp8_rdcost_mby(MACROBLOCK *mb)
-{
- int cost = 0;
- int b;
- MACROBLOCKD *x = &mb->e_mbd;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+static int vp8_rdcost_mby(MACROBLOCK *mb) {
+ int cost = 0;
+ int b;
+ MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 0; b < 16; b++)
- cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
- ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ for (b = 0; b < 16; b++)
+ cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
+ ta + vp8_block2above[b], tl + vp8_block2left[b]);
- cost += cost_coeffs(mb, x->block + 24, PLANE_TYPE_Y2,
- ta + vp8_block2above[24], tl + vp8_block2left[24]);
+ cost += cost_coeffs(mb, x->block + 24, PLANE_TYPE_Y2,
+ ta + vp8_block2above[24], tl + vp8_block2left[24]);
- return cost;
+ return cost;
}
-static void macro_block_yrd( MACROBLOCK *mb,
- int *Rate,
- int *Distortion,
- const VP8_ENCODER_RTCD *rtcd)
-{
- int b;
- MACROBLOCKD *const x = &mb->e_mbd;
- BLOCK *const mb_y2 = mb->block + 24;
- BLOCKD *const x_y2 = x->block + 24;
- short *Y2DCPtr = mb_y2->src_diff;
- BLOCK *beptr;
- int d;
-
- ENCODEMB_INVOKE(&rtcd->encodemb, submby)(
- mb->src_diff,
- *(mb->block[0].base_src),
- mb->e_mbd.predictor,
- mb->block[0].src_stride );
-
- // Fdct and building the 2nd order block
- for (beptr = mb->block; beptr < mb->block + 16; beptr += 2)
- {
- mb->vp8_short_fdct8x4(beptr->src_diff, beptr->coeff, 32);
- *Y2DCPtr++ = beptr->coeff[0];
- *Y2DCPtr++ = beptr->coeff[16];
- }
+static void macro_block_yrd(MACROBLOCK *mb,
+ int *Rate,
+ int *Distortion,
+ const VP8_ENCODER_RTCD *rtcd) {
+ int b;
+ MACROBLOCKD *const x = &mb->e_mbd;
+ BLOCK *const mb_y2 = mb->block + 24;
+ BLOCKD *const x_y2 = x->block + 24;
+ short *Y2DCPtr = mb_y2->src_diff;
+ BLOCK *beptr;
+ int d;
- // 2nd order fdct
- mb->short_walsh4x4(mb_y2->src_diff, mb_y2->coeff, 8);
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)(
+ mb->src_diff,
+ *(mb->block[0].base_src),
+ mb->e_mbd.predictor,
+ mb->block[0].src_stride);
- // Quantization
- for (b = 0; b < 16; b++)
- {
- mb->quantize_b(&mb->block[b], &mb->e_mbd.block[b]);
- }
+ // Fdct and building the 2nd order block
+ for (beptr = mb->block; beptr < mb->block + 16; beptr += 2) {
+ mb->vp8_short_fdct8x4(beptr->src_diff, beptr->coeff, 32);
+ *Y2DCPtr++ = beptr->coeff[0];
+ *Y2DCPtr++ = beptr->coeff[16];
+ }
+
+ // 2nd order fdct
+ mb->short_walsh4x4(mb_y2->src_diff, mb_y2->coeff, 8);
+
+ // Quantization
+ for (b = 0; b < 16; b++) {
+ mb->quantize_b(&mb->block[b], &mb->e_mbd.block[b]);
+ }
- // DC predication and Quantization of 2nd Order block
- mb->quantize_b(mb_y2, x_y2);
+ // DC predication and Quantization of 2nd Order block
+ mb->quantize_b(mb_y2, x_y2);
- // Distortion
- d = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(mb, 1);
+ // Distortion
+ d = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(mb, 1);
- d += ENCODEMB_INVOKE(&rtcd->encodemb, berr)(mb_y2->coeff, x_y2->dqcoeff);
+ d += ENCODEMB_INVOKE(&rtcd->encodemb, berr)(mb_y2->coeff, x_y2->dqcoeff);
- *Distortion = (d >> 2);
- // rate
- *Rate = vp8_rdcost_mby(mb);
+ *Distortion = (d >> 2);
+ // rate
+ *Rate = vp8_rdcost_mby(mb);
}
static int cost_coeffs_2x2(MACROBLOCK *mb,
BLOCKD *b, int type,
- ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
-{
- int c = !type; /* start at coef 0, unless Y with Y2 */
- int eob = b->eob;
- int pt ; /* surrounding block/prev coef predictor */
- int cost = 0;
- short *qcoeff_ptr = b->qcoeff;
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
+ int c = !type; /* start at coef 0, unless Y with Y2 */
+ int eob = b->eob;
+ int pt; /* surrounding block/prev coef predictor */
+ int cost = 0;
+ short *qcoeff_ptr = b->qcoeff;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- assert(eob<=4);
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ assert(eob <= 4);
# define QC2X2( I) ( qcoeff_ptr [vp8_default_zig_zag1d[I]] )
- for (; c < eob; c++)
- {
- int v = QC2X2(c);
- int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs_8x8[type] [vp8_coef_bands[c]] [pt] [t];
- cost += vp8_dct_value_cost_ptr[v];
- pt = vp8_prev_token_class[t];
- }
+ for (; c < eob; c++) {
+ int v = QC2X2(c);
+ int t = vp8_dct_value_tokens_ptr[v].Token;
+ cost += mb->token_costs_8x8[type] [vp8_coef_bands[c]] [pt] [t];
+ cost += vp8_dct_value_cost_ptr[v];
+ pt = vp8_prev_token_class[t];
+ }
# undef QC2X2
- if (c < 4)
- cost += mb->token_costs_8x8 [type][vp8_coef_bands[c]]
- [pt] [DCT_EOB_TOKEN];
+ if (c < 4)
+ cost += mb->token_costs_8x8 [type][vp8_coef_bands[c]]
+ [pt] [DCT_EOB_TOKEN];
- pt = (c != !type); // is eob first coefficient;
- *a = *l = pt;
- return cost;
+ pt = (c != !type); // is eob first coefficient;
+ *a = *l = pt;
+ return cost;
}
static int cost_coeffs_8x8(MACROBLOCK *mb,
BLOCKD *b, int type,
- ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
-{
- int c = !type; /* start at coef 0, unless Y with Y2 */
- int eob = b->eob;
- int pt ; /* surrounding block/prev coef predictor */
- int cost = 0;
- short *qcoeff_ptr = b->qcoeff;
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
+ int c = !type; /* start at coef 0, unless Y with Y2 */
+ int eob = b->eob;
+ int pt; /* surrounding block/prev coef predictor */
+ int cost = 0;
+ short *qcoeff_ptr = b->qcoeff;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
# define QC8X8( I) ( qcoeff_ptr [vp8_default_zig_zag1d_8x8[I]] )
- for (; c < eob; c++)
- {
- int v = QC8X8(c);
- int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs_8x8[type] [vp8_coef_bands_8x8[c]] [pt] [t];
- cost += vp8_dct_value_cost_ptr[v];
- pt = vp8_prev_token_class[t];
- }
+ for (; c < eob; c++) {
+ int v = QC8X8(c);
+ int t = vp8_dct_value_tokens_ptr[v].Token;
+ cost += mb->token_costs_8x8[type] [vp8_coef_bands_8x8[c]] [pt] [t];
+ cost += vp8_dct_value_cost_ptr[v];
+ pt = vp8_prev_token_class[t];
+ }
# undef QC8X8
- if (c < 64)
- cost += mb->token_costs_8x8 [type][vp8_coef_bands_8x8[c]]
- [pt] [DCT_EOB_TOKEN];
+ if (c < 64)
+ cost += mb->token_costs_8x8 [type][vp8_coef_bands_8x8[c]]
+ [pt] [DCT_EOB_TOKEN];
- pt = (c != !type); // is eob first coefficient;
- *a = *l = pt;
- return cost;
+ pt = (c != !type); // is eob first coefficient;
+ *a = *l = pt;
+ return cost;
}
-static int vp8_rdcost_mby_8x8(MACROBLOCK *mb)
-{
- int cost = 0;
- int b;
- MACROBLOCKD *x = &mb->e_mbd;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
-
- vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
-
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
-
- for (b = 0; b < 16; b+=4)
- cost += cost_coeffs_8x8(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
- ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b]);
-
- cost += cost_coeffs_2x2(mb, x->block + 24, PLANE_TYPE_Y2,
- ta + vp8_block2above[24], tl + vp8_block2left[24]);
- return cost;
+static int vp8_rdcost_mby_8x8(MACROBLOCK *mb) {
+ int cost = 0;
+ int b;
+ MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+
+ for (b = 0; b < 16; b += 4)
+ cost += cost_coeffs_8x8(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
+ ta + vp8_block2above_8x8[b], tl + vp8_block2left_8x8[b]);
+
+ cost += cost_coeffs_2x2(mb, x->block + 24, PLANE_TYPE_Y2,
+ ta + vp8_block2above[24], tl + vp8_block2left[24]);
+ return cost;
}
-static void macro_block_yrd_8x8( MACROBLOCK *mb,
- int *Rate,
- int *Distortion,
- const VP8_ENCODER_RTCD *rtcd)
-{
- MACROBLOCKD *const x = &mb->e_mbd;
- BLOCK *const mb_y2 = mb->block + 24;
- BLOCKD *const x_y2 = x->block + 24;
- int d;
-
- ENCODEMB_INVOKE(&rtcd->encodemb, submby)(
- mb->src_diff,
- *(mb->block[0].base_src),
- mb->e_mbd.predictor,
- mb->block[0].src_stride );
-
- vp8_transform_mby_8x8(mb);
- vp8_quantize_mby_8x8(mb);
-
- /* remove 1st order dc to properly combine 1st/2nd order distortion */
- mb->coeff[0] = 0;
- mb->coeff[64] = 0;
- mb->coeff[128] = 0;
- mb->coeff[192] = 0;
- mb->e_mbd.dqcoeff[0] = 0;
- mb->e_mbd.dqcoeff[64] = 0;
- mb->e_mbd.dqcoeff[128] = 0;
- mb->e_mbd.dqcoeff[192] = 0;
-
- d = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(mb, 0);
- d += ENCODEMB_INVOKE(&rtcd->encodemb, berr)(mb_y2->coeff, x_y2->dqcoeff);
-
- *Distortion = (d >> 2);
- // rate
- *Rate = vp8_rdcost_mby_8x8(mb);
+static void macro_block_yrd_8x8(MACROBLOCK *mb,
+ int *Rate,
+ int *Distortion,
+ const VP8_ENCODER_RTCD *rtcd) {
+ MACROBLOCKD *const x = &mb->e_mbd;
+ BLOCK *const mb_y2 = mb->block + 24;
+ BLOCKD *const x_y2 = x->block + 24;
+ int d;
+
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)(
+ mb->src_diff,
+ *(mb->block[0].base_src),
+ mb->e_mbd.predictor,
+ mb->block[0].src_stride);
+
+ vp8_transform_mby_8x8(mb);
+ vp8_quantize_mby_8x8(mb);
+
+ /* remove 1st order dc to properly combine 1st/2nd order distortion */
+ mb->coeff[0] = 0;
+ mb->coeff[64] = 0;
+ mb->coeff[128] = 0;
+ mb->coeff[192] = 0;
+ mb->e_mbd.dqcoeff[0] = 0;
+ mb->e_mbd.dqcoeff[64] = 0;
+ mb->e_mbd.dqcoeff[128] = 0;
+ mb->e_mbd.dqcoeff[192] = 0;
+
+ d = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(mb, 0);
+ d += ENCODEMB_INVOKE(&rtcd->encodemb, berr)(mb_y2->coeff, x_y2->dqcoeff);
+
+ *Distortion = (d >> 2);
+ // rate
+ *Rate = vp8_rdcost_mby_8x8(mb);
}
-static void copy_predictor(unsigned char *dst, const unsigned char *predictor)
-{
- const unsigned int *p = (const unsigned int *)predictor;
- unsigned int *d = (unsigned int *)dst;
- d[0] = p[0];
- d[4] = p[4];
- d[8] = p[8];
- d[12] = p[12];
+static void copy_predictor(unsigned char *dst, const unsigned char *predictor) {
+ const unsigned int *p = (const unsigned int *)predictor;
+ unsigned int *d = (unsigned int *)dst;
+ d[0] = p[0];
+ d[4] = p[4];
+ d[8] = p[8];
+ d[12] = p[12];
}
-static void copy_predictor_8x8(unsigned char *dst, const unsigned char *predictor)
-{
- const unsigned int *p = (const unsigned int *)predictor;
- unsigned int *d = (unsigned int *)dst;
- d[0] = p[0];
- d[1] = p[1];
- d[4] = p[4];
- d[5] = p[5];
- d[8] = p[8];
- d[9] = p[9];
- d[12] = p[12];
- d[13] = p[13];
- d[16] = p[16];
- d[17] = p[17];
- d[20] = p[20];
- d[21] = p[21];
- d[24] = p[24];
- d[25] = p[25];
- d[28] = p[28];
- d[29] = p[29];
+static void copy_predictor_8x8(unsigned char *dst, const unsigned char *predictor) {
+ const unsigned int *p = (const unsigned int *)predictor;
+ unsigned int *d = (unsigned int *)dst;
+ d[0] = p[0];
+ d[1] = p[1];
+ d[4] = p[4];
+ d[5] = p[5];
+ d[8] = p[8];
+ d[9] = p[9];
+ d[12] = p[12];
+ d[13] = p[13];
+ d[16] = p[16];
+ d[17] = p[17];
+ d[20] = p[20];
+ d[21] = p[21];
+ d[24] = p[24];
+ d[25] = p[25];
+ d[28] = p[28];
+ d[29] = p[29];
}
static int rd_pick_intra4x4block(
- VP8_COMP *cpi,
- MACROBLOCK *x,
- BLOCK *be,
- BLOCKD *b,
- B_PREDICTION_MODE *best_mode,
+ VP8_COMP *cpi,
+ MACROBLOCK *x,
+ BLOCK *be,
+ BLOCKD *b,
+ B_PREDICTION_MODE *best_mode,
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE *best_second_mode,
- int allow_comp,
+ B_PREDICTION_MODE *best_second_mode,
+ int allow_comp,
#endif
- int *bmode_costs,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
-
- int *bestrate,
- int *bestratey,
- int *bestdistortion)
-{
- B_PREDICTION_MODE mode;
-#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE mode2;
-#endif
- int best_rd = INT_MAX;
- int rate = 0;
- int distortion;
+ int *bmode_costs,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
- ENTROPY_CONTEXT ta = *a, tempa = *a;
- ENTROPY_CONTEXT tl = *l, templ = *l;
- /*
- * The predictor buffer is a 2d buffer with a stride of 16. Create
- * a temp buffer that meets the stride requirements, but we are only
- * interested in the left 4x4 block
- * */
- DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16*4);
- DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16);
-
- for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++)
- {
+ int *bestrate,
+ int *bestratey,
+ int *bestdistortion) {
+ B_PREDICTION_MODE mode;
#if CONFIG_COMP_INTRA_PRED
- for (mode2 = (allow_comp ? 0 : (B_DC_PRED - 1)); mode2 != (allow_comp ? (mode + 1) : 0); mode2++)
- {
+ B_PREDICTION_MODE mode2;
+#endif
+ int best_rd = INT_MAX;
+ int rate = 0;
+ int distortion;
+
+ ENTROPY_CONTEXT ta = *a, tempa = *a;
+ ENTROPY_CONTEXT tl = *l, templ = *l;
+ /*
+ * The predictor buffer is a 2d buffer with a stride of 16. Create
+ * a temp buffer that meets the stride requirements, but we are only
+ * interested in the left 4x4 block
+ * */
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16 * 4);
+ DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16);
+
+ for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++) {
+#if CONFIG_COMP_INTRA_PRED
+ for (mode2 = (allow_comp ? 0 : (B_DC_PRED - 1)); mode2 != (allow_comp ? (mode + 1) : 0); mode2++) {
#endif
- int this_rd;
- int ratey;
+ int this_rd;
+ int ratey;
- // TODO Temporarily ignore modes that need the above-right data. SB
- // encoding means this data is not available for the bottom right MB
- // Do we need to do this for mode2 also?
- if (mode==B_LD_PRED || mode==B_VL_PRED)
- continue;
- rate = bmode_costs[mode];
+ // TODO Temporarily ignore modes that need the above-right data. SB
+ // encoding means this data is not available for the bottom right MB
+ // Do we need to do this for mode2 also?
+ if (mode == B_LD_PRED || mode == B_VL_PRED)
+ continue;
+ rate = bmode_costs[mode];
#if CONFIG_COMP_INTRA_PRED
- if (mode2 == (B_PREDICTION_MODE) (B_DC_PRED - 1))
- {
+ if (mode2 == (B_PREDICTION_MODE)(B_DC_PRED - 1)) {
#endif
RECON_INVOKE(&cpi->rtcd.common->recon, intra4x4_predict)
- (b, mode, b->predictor);
+ (b, mode, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- RECON_INVOKE(&cpi->rtcd.common->recon, comp_intra4x4_predict)
- (b, mode, mode2, b->predictor);
- rate += bmode_costs[mode2];
- }
-#endif
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), subb)(be, b, 16);
- x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
- x->quantize_b(be, b);
-
- tempa = ta;
- templ = tl;
-
- ratey = cost_coeffs(x, b, PLANE_TYPE_Y_WITH_DC, &tempa, &templ);
- rate += ratey;
- distortion = ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)(
- be->coeff, b->dqcoeff) >> 2;
-
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
-
- if (this_rd < best_rd)
- {
- *bestrate = rate;
- *bestratey = ratey;
- *bestdistortion = distortion;
- best_rd = this_rd;
- *best_mode = mode;
+ } else {
+ RECON_INVOKE(&cpi->rtcd.common->recon, comp_intra4x4_predict)
+ (b, mode, mode2, b->predictor);
+ rate += bmode_costs[mode2];
+ }
+#endif
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), subb)(be, b, 16);
+ x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
+ x->quantize_b(be, b);
+
+ tempa = ta;
+ templ = tl;
+
+ ratey = cost_coeffs(x, b, PLANE_TYPE_Y_WITH_DC, &tempa, &templ);
+ rate += ratey;
+ distortion = ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)(
+ be->coeff, b->dqcoeff) >> 2;
+
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+
+ if (this_rd < best_rd) {
+ *bestrate = rate;
+ *bestratey = ratey;
+ *bestdistortion = distortion;
+ best_rd = this_rd;
+ *best_mode = mode;
#if CONFIG_COMP_INTRA_PRED
- *best_second_mode = mode2;
+ *best_second_mode = mode2;
#endif
- *a = tempa;
- *l = templ;
- copy_predictor(best_predictor, b->predictor);
- vpx_memcpy(best_dqcoeff, b->dqcoeff, 32);
+ *a = tempa;
+ *l = templ;
+ copy_predictor(best_predictor, b->predictor);
+ vpx_memcpy(best_dqcoeff, b->dqcoeff, 32);
#if CONFIG_COMP_INTRA_PRED
- }
+ }
#endif
- }
}
- b->bmi.as_mode.first = (B_PREDICTION_MODE)(*best_mode);
+ }
+ b->bmi.as_mode.first = (B_PREDICTION_MODE)(*best_mode);
#if CONFIG_COMP_INTRA_PRED
- b->bmi.as_mode.second = (B_PREDICTION_MODE)(*best_second_mode);
+ b->bmi.as_mode.second = (B_PREDICTION_MODE)(*best_second_mode);
#endif
- IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(best_dqcoeff, b->diff, 32);
- RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(best_predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+ IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(best_dqcoeff, b->diff, 32);
+ RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(best_predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
- return best_rd;
+ return best_rd;
}
static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
@@ -967,90 +900,84 @@ static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
#if CONFIG_COMP_INTRA_PRED
int allow_comp,
#endif
- int update_contexts)
-{
- int i;
- MACROBLOCKD *const xd = &mb->e_mbd;
- int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];
- int distortion = 0;
- int tot_rate_y = 0;
- int64_t total_rd = 0;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
- int *bmode_costs;
-
- if (update_contexts)
- {
- ta = (ENTROPY_CONTEXT *)mb->e_mbd.above_context;
- tl = (ENTROPY_CONTEXT *)mb->e_mbd.left_context;
- }
- else
- {
- vpx_memcpy(&t_above, mb->e_mbd.above_context,
- sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context,
- sizeof(ENTROPY_CONTEXT_PLANES));
+ int update_contexts) {
+ int i;
+ MACROBLOCKD *const xd = &mb->e_mbd;
+ int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];
+ int distortion = 0;
+ int tot_rate_y = 0;
+ int64_t total_rd = 0;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+ int *bmode_costs;
+
+ if (update_contexts) {
+ ta = (ENTROPY_CONTEXT *)mb->e_mbd.above_context;
+ tl = (ENTROPY_CONTEXT *)mb->e_mbd.left_context;
+ } else {
+ vpx_memcpy(&t_above, mb->e_mbd.above_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
- }
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+ }
- // TODO(agrange)
- //vp8_intra_prediction_down_copy(xd);
+ // TODO(agrange)
+ // vp8_intra_prediction_down_copy(xd);
- bmode_costs = mb->inter_bmode_costs;
+ bmode_costs = mb->inter_bmode_costs;
- for (i = 0; i < 16; i++)
- {
- MODE_INFO *const mic = xd->mode_info_context;
- const int mis = xd->mode_info_stride;
- B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
+ for (i = 0; i < 16; i++) {
+ MODE_INFO *const mic = xd->mode_info_context;
+ const int mis = xd->mode_info_stride;
+ B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_second_mode);
+ B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_second_mode);
#endif
- int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry), UNINITIALIZED_IS_SAFE(d);
+ int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry), UNINITIALIZED_IS_SAFE(d);
- if (mb->e_mbd.frame_type == KEY_FRAME)
- {
- const B_PREDICTION_MODE A = above_block_mode(mic, i, mis);
- const B_PREDICTION_MODE L = left_block_mode(mic, i);
+ if (mb->e_mbd.frame_type == KEY_FRAME) {
+ const B_PREDICTION_MODE A = above_block_mode(mic, i, mis);
+ const B_PREDICTION_MODE L = left_block_mode(mic, i);
- bmode_costs = mb->bmode_costs[A][L];
- }
+ bmode_costs = mb->bmode_costs[A][L];
+ }
- total_rd += rd_pick_intra4x4block(
- cpi, mb, mb->block + i, xd->block + i, &best_mode,
+ total_rd += rd_pick_intra4x4block(
+ cpi, mb, mb->block + i, xd->block + i, &best_mode,
#if CONFIG_COMP_INTRA_PRED
- &best_second_mode, allow_comp,
+ & best_second_mode, allow_comp,
#endif
- bmode_costs, ta + vp8_block2above[i],
- tl + vp8_block2left[i], &r, &ry, &d);
+ bmode_costs, ta + vp8_block2above[i],
+ tl + vp8_block2left[i], &r, &ry, &d);
- cost += r;
- distortion += d;
- tot_rate_y += ry;
+ cost += r;
+ distortion += d;
+ tot_rate_y += ry;
- mic->bmi[i].as_mode.first = best_mode;
+ mic->bmi[i].as_mode.first = best_mode;
#if CONFIG_COMP_INTRA_PRED
- mic->bmi[i].as_mode.second = best_second_mode;
+ mic->bmi[i].as_mode.second = best_second_mode;
#endif
- if(total_rd >= (int64_t)best_rd)
- break;
- }
+ if (total_rd >= (int64_t)best_rd)
+ break;
+ }
- if(total_rd >= (int64_t)best_rd)
- return INT_MAX;
+ if (total_rd >= (int64_t)best_rd)
+ return INT_MAX;
#if CONFIG_COMP_INTRA_PRED
- cost += vp8_cost_bit(128, allow_comp);
+ cost += vp8_cost_bit(128, allow_comp);
#endif
- *Rate = cost;
- *rate_y += tot_rate_y;
- *Distortion = distortion;
+ *Rate = cost;
+ *rate_y += tot_rate_y;
+ *Distortion = distortion;
- return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
+ return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
}
@@ -1058,435 +985,407 @@ static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi,
MACROBLOCK *x,
int *Rate,
int *rate_y,
- int *Distortion)
-{
- MB_PREDICTION_MODE mode;
- MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
+ int *Distortion) {
+ MB_PREDICTION_MODE mode;
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
#if CONFIG_COMP_INTRA_PRED
- MB_PREDICTION_MODE mode2;
- MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode2_selected);
+ MB_PREDICTION_MODE mode2;
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode2_selected);
#endif
- int rate, ratey;
- int distortion;
- int best_rd = INT_MAX;
- int this_rd;
+ int rate, ratey;
+ int distortion;
+ int best_rd = INT_MAX;
+ int this_rd;
- //Y Search for 16x16 intra prediction mode
- for (mode = DC_PRED; mode <= TM_PRED; mode++)
- {
- x->e_mbd.mode_info_context->mbmi.mode = mode;
+ // Y Search for 16x16 intra prediction mode
+ for (mode = DC_PRED; mode <= TM_PRED; mode++) {
+ x->e_mbd.mode_info_context->mbmi.mode = mode;
#if CONFIG_COMP_INTRA_PRED
- for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++)
- {
- x->e_mbd.mode_info_context->mbmi.second_mode = mode2;
- if (mode2 == (MB_PREDICTION_MODE) (DC_PRED - 1))
- {
+ for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++) {
+ x->e_mbd.mode_info_context->mbmi.second_mode = mode2;
+ if (mode2 == (MB_PREDICTION_MODE)(DC_PRED - 1)) {
#endif
RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
- (&x->e_mbd);
+ (&x->e_mbd);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- continue; // i.e. disable for now
- RECON_INVOKE(&cpi->common.rtcd.recon, build_comp_intra_predictors_mby)(&x->e_mbd);
- }
+ } else {
+ continue; // i.e. disable for now
+ RECON_INVOKE(&cpi->common.rtcd.recon, build_comp_intra_predictors_mby)(&x->e_mbd);
+ }
#endif
- macro_block_yrd_8x8(x, &ratey, &distortion, IF_RTCD(&cpi->rtcd));
- // FIXME add compoundmode cost
- // FIXME add rate for mode2
- rate = ratey + x->mbmode_cost[x->e_mbd.frame_type]
- [x->e_mbd.mode_info_context->mbmi.mode];
+ macro_block_yrd_8x8(x, &ratey, &distortion, IF_RTCD(&cpi->rtcd));
+ // FIXME add compoundmode cost
+ // FIXME add rate for mode2
+ rate = ratey + x->mbmode_cost[x->e_mbd.frame_type]
+ [x->e_mbd.mode_info_context->mbmi.mode];
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
- if (this_rd < best_rd)
- {
- mode_selected = mode;
+ if (this_rd < best_rd) {
+ mode_selected = mode;
#if CONFIG_COMP_INTRA_PRED
- mode2_selected = mode2;
+ mode2_selected = mode2;
#endif
- best_rd = this_rd;
- *Rate = rate;
- *rate_y = ratey;
- *Distortion = distortion;
- }
+ best_rd = this_rd;
+ *Rate = rate;
+ *rate_y = ratey;
+ *Distortion = distortion;
+ }
#if CONFIG_COMP_INTRA_PRED
- }
-#endif
}
+#endif
+ }
- x->e_mbd.mode_info_context->mbmi.mode = mode_selected;
+ x->e_mbd.mode_info_context->mbmi.mode = mode_selected;
#if CONFIG_COMP_INTRA_PRED
- x->e_mbd.mode_info_context->mbmi.second_mode = mode2_selected;
+ x->e_mbd.mode_info_context->mbmi.second_mode = mode2_selected;
#endif
- return best_rd;
+ return best_rd;
}
static int rd_pick_intra8x8block(
- VP8_COMP *cpi,
- MACROBLOCK *x,
- int ib,
- B_PREDICTION_MODE *best_mode,
+ VP8_COMP *cpi,
+ MACROBLOCK *x,
+ int ib,
+ B_PREDICTION_MODE *best_mode,
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE *best_second_mode,
-#endif
- int *mode_costs,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- int *bestrate,
- int *bestratey,
- int *bestdistortion)
-{
- MB_PREDICTION_MODE mode;
+ B_PREDICTION_MODE *best_second_mode,
+#endif
+ int *mode_costs,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ int *bestrate,
+ int *bestratey,
+ int *bestdistortion) {
+ MB_PREDICTION_MODE mode;
#if CONFIG_COMP_INTRA_PRED
- MB_PREDICTION_MODE mode2;
+ MB_PREDICTION_MODE mode2;
#endif
- MACROBLOCKD *xd = &x->e_mbd;
- int best_rd = INT_MAX;
- int rate = 0;
- int distortion;
- BLOCK *be=x->block + ib;
- BLOCKD *b=x->e_mbd.block + ib;
- ENTROPY_CONTEXT ta0, ta1, besta0 = 0, besta1 = 0;
- ENTROPY_CONTEXT tl0, tl1, bestl0 = 0, bestl1 = 0;
+ MACROBLOCKD *xd = &x->e_mbd;
+ int best_rd = INT_MAX;
+ int rate = 0;
+ int distortion;
+ BLOCK *be = x->block + ib;
+ BLOCKD *b = x->e_mbd.block + ib;
+ ENTROPY_CONTEXT ta0, ta1, besta0 = 0, besta1 = 0;
+ ENTROPY_CONTEXT tl0, tl1, bestl0 = 0, bestl1 = 0;
- /*
- * The predictor buffer is a 2d buffer with a stride of 16. Create
- * a temp buffer that meets the stride requirements, but we are only
- * interested in the left 8x8 block
- * */
+ /*
+ * The predictor buffer is a 2d buffer with a stride of 16. Create
+ * a temp buffer that meets the stride requirements, but we are only
+ * interested in the left 8x8 block
+ * */
- DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16*8);
- DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16*4);
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16 * 8);
+ DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16 * 4);
- for (mode = DC_PRED; mode <= TM_PRED; mode++)
- {
+ for (mode = DC_PRED; mode <= TM_PRED; mode++) {
#if CONFIG_COMP_INTRA_PRED
- for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++)
- {
+ for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++) {
#endif
- int this_rd;
- int rate_t;
+ int this_rd;
+ int rate_t;
- // FIXME rate for compound mode and second intrapred mode
- rate = mode_costs[mode];
+ // FIXME rate for compound mode and second intrapred mode
+ rate = mode_costs[mode];
#if CONFIG_COMP_INTRA_PRED
- if (mode2 == (MB_PREDICTION_MODE) (DC_PRED - 1))
- {
+ if (mode2 == (MB_PREDICTION_MODE)(DC_PRED - 1)) {
#endif
RECON_INVOKE(&cpi->rtcd.common->recon, intra8x8_predict)
- (b, mode, b->predictor);
+ (b, mode, b->predictor);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- continue; // i.e. disable for now
- RECON_INVOKE(&cpi->rtcd.common->recon, comp_intra8x8_predict)
- (b, mode, mode2, b->predictor);
- }
-#endif
-
- vp8_subtract_4b_c(be, b, 16);
-
- x->vp8_short_fdct8x4(be->src_diff, be->coeff, 32);
- x->vp8_short_fdct8x4(be->src_diff + 64, be->coeff + 64, 32);
-
- x->quantize_b_pair(x->block+ib, x->block+ib+1,
- xd->block+ib, xd->block+ib+1);
- x->quantize_b_pair(x->block+ib+4, x->block+ib+5,
- xd->block+ib+4, xd->block+ib+5);
-
- distortion = ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
- ((x->block+ib)->coeff,(xd->block+ib)->dqcoeff)>>2;
- distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
- ((x->block+ib+1)->coeff,(xd->block+ib+1)->dqcoeff)>>2;
- distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
- ((x->block+ib+4)->coeff,(xd->block+ib+4)->dqcoeff)>>2;
- distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
- ((x->block+ib+5)->coeff,(xd->block+ib+5)->dqcoeff)>>2;
-
- ta0 = *(a + vp8_block2above[ib]);
- ta1 = *(a + vp8_block2above[ib+1]);
- tl0 = *(l + vp8_block2above[ib]);
- tl1 = *(l + vp8_block2above[ib+4]);
- rate_t = cost_coeffs(x, xd->block+ib, PLANE_TYPE_Y_WITH_DC,
- &ta0, &tl0);
- rate_t += cost_coeffs(x, xd->block+ib+1, PLANE_TYPE_Y_WITH_DC,
- &ta1, &tl0);
- rate_t += cost_coeffs(x, xd->block+ib+4, PLANE_TYPE_Y_WITH_DC,
- &ta0, &tl1);
- rate_t += cost_coeffs(x, xd->block+ib+5, PLANE_TYPE_Y_WITH_DC,
- &ta1, &tl1);
- rate += rate_t;
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
- if (this_rd < best_rd)
- {
- *bestrate = rate;
- *bestratey = rate_t;
- *bestdistortion = distortion;
- besta0 = ta0;
- besta1 = ta1;
- bestl0 = tl0;
- bestl1 = tl1;
- best_rd = this_rd;
- *best_mode = mode;
+ } else {
+ continue; // i.e. disable for now
+ RECON_INVOKE(&cpi->rtcd.common->recon, comp_intra8x8_predict)
+ (b, mode, mode2, b->predictor);
+ }
+#endif
+
+ vp8_subtract_4b_c(be, b, 16);
+
+ x->vp8_short_fdct8x4(be->src_diff, be->coeff, 32);
+ x->vp8_short_fdct8x4(be->src_diff + 64, be->coeff + 64, 32);
+
+ x->quantize_b_pair(x->block + ib, x->block + ib + 1,
+ xd->block + ib, xd->block + ib + 1);
+ x->quantize_b_pair(x->block + ib + 4, x->block + ib + 5,
+ xd->block + ib + 4, xd->block + ib + 5);
+
+ distortion = ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
+ ((x->block + ib)->coeff, (xd->block + ib)->dqcoeff) >> 2;
+ distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
+ ((x->block + ib + 1)->coeff, (xd->block + ib + 1)->dqcoeff) >> 2;
+ distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
+ ((x->block + ib + 4)->coeff, (xd->block + ib + 4)->dqcoeff) >> 2;
+ distortion += ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), berr)
+ ((x->block + ib + 5)->coeff, (xd->block + ib + 5)->dqcoeff) >> 2;
+
+ ta0 = *(a + vp8_block2above[ib]);
+ ta1 = *(a + vp8_block2above[ib + 1]);
+ tl0 = *(l + vp8_block2above[ib]);
+ tl1 = *(l + vp8_block2above[ib + 4]);
+ rate_t = cost_coeffs(x, xd->block + ib, PLANE_TYPE_Y_WITH_DC,
+ &ta0, &tl0);
+ rate_t += cost_coeffs(x, xd->block + ib + 1, PLANE_TYPE_Y_WITH_DC,
+ &ta1, &tl0);
+ rate_t += cost_coeffs(x, xd->block + ib + 4, PLANE_TYPE_Y_WITH_DC,
+ &ta0, &tl1);
+ rate_t += cost_coeffs(x, xd->block + ib + 5, PLANE_TYPE_Y_WITH_DC,
+ &ta1, &tl1);
+ rate += rate_t;
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+ if (this_rd < best_rd) {
+ *bestrate = rate;
+ *bestratey = rate_t;
+ *bestdistortion = distortion;
+ besta0 = ta0;
+ besta1 = ta1;
+ bestl0 = tl0;
+ bestl1 = tl1;
+ best_rd = this_rd;
+ *best_mode = mode;
#if CONFIG_COMP_INTRA_PRED
- *best_second_mode = mode2;
+ *best_second_mode = mode2;
#endif
- copy_predictor_8x8(best_predictor, b->predictor);
- vpx_memcpy(best_dqcoeff, b->dqcoeff, 64);
- vpx_memcpy(best_dqcoeff+32, b->dqcoeff+64, 64);
+ copy_predictor_8x8(best_predictor, b->predictor);
+ vpx_memcpy(best_dqcoeff, b->dqcoeff, 64);
+ vpx_memcpy(best_dqcoeff + 32, b->dqcoeff + 64, 64);
#if CONFIG_COMP_INTRA_PRED
- }
+ }
#endif
- }
}
- b->bmi.as_mode.first = (*best_mode);
+ }
+ b->bmi.as_mode.first = (*best_mode);
#if CONFIG_COMP_INTRA_PRED
- b->bmi.as_mode.second = (*best_second_mode);
-#endif
- vp8_encode_intra8x8 (IF_RTCD(&cpi->rtcd), x, ib);
- *(a + vp8_block2above[ib]) = besta0;
- *(a + vp8_block2above[ib+1]) = besta1;
- *(l + vp8_block2above[ib]) = bestl0;
- *(l + vp8_block2above[ib+4]) = bestl1;
- return best_rd;
+ b->bmi.as_mode.second = (*best_second_mode);
+#endif
+ vp8_encode_intra8x8(IF_RTCD(&cpi->rtcd), x, ib);
+ *(a + vp8_block2above[ib]) = besta0;
+ *(a + vp8_block2above[ib + 1]) = besta1;
+ *(l + vp8_block2above[ib]) = bestl0;
+ *(l + vp8_block2above[ib + 4]) = bestl1;
+ return best_rd;
}
-const int vp8_i8x8_block[4]={0, 2, 8, 10};
+const int vp8_i8x8_block[4] = {0, 2, 8, 10};
int rd_pick_intra8x8mby_modes(VP8_COMP *cpi,
- MACROBLOCK *mb,
- int *Rate,
- int *rate_y,
- int *Distortion,
- int best_rd)
-{
- MACROBLOCKD *const xd = &mb->e_mbd;
- int i,ib;
- int cost = mb->mbmode_cost [xd->frame_type] [I8X8_PRED];
- int distortion = 0;
- int tot_rate_y = 0;
- long long total_rd = 0;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
- int *i8x8mode_costs;
-
- vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
-
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
-
- i8x8mode_costs = mb->i8x8_mode_costs;
-
- for (i = 0; i < 4; i++)
- {
- MODE_INFO *const mic = xd->mode_info_context;
- B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
+ MACROBLOCK *mb,
+ int *Rate,
+ int *rate_y,
+ int *Distortion,
+ int best_rd) {
+ MACROBLOCKD *const xd = &mb->e_mbd;
+ int i, ib;
+ int cost = mb->mbmode_cost [xd->frame_type] [I8X8_PRED];
+ int distortion = 0;
+ int tot_rate_y = 0;
+ long long total_rd = 0;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+ int *i8x8mode_costs;
+
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+
+ i8x8mode_costs = mb->i8x8_mode_costs;
+
+ for (i = 0; i < 4; i++) {
+ MODE_INFO *const mic = xd->mode_info_context;
+ B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
#if CONFIG_COMP_INTRA_PRED
- B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_second_mode);
+ B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_second_mode);
#endif
- int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry), UNINITIALIZED_IS_SAFE(d);
+ int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry), UNINITIALIZED_IS_SAFE(d);
- ib = vp8_i8x8_block[i];
- total_rd += rd_pick_intra8x8block(
- cpi, mb, ib, &best_mode,
+ ib = vp8_i8x8_block[i];
+ total_rd += rd_pick_intra8x8block(
+ cpi, mb, ib, &best_mode,
#if CONFIG_COMP_INTRA_PRED
- &best_second_mode,
+ & best_second_mode,
#endif
- i8x8mode_costs, ta, tl, &r, &ry, &d);
- cost += r;
- distortion += d;
- tot_rate_y += ry;
- mic->bmi[ib].as_mode.first = best_mode;
+ i8x8mode_costs, ta, tl, &r, &ry, &d);
+ cost += r;
+ distortion += d;
+ tot_rate_y += ry;
+ mic->bmi[ib].as_mode.first = best_mode;
#if CONFIG_COMP_INTRA_PRED
- mic->bmi[ib].as_mode.second = best_second_mode;
+ mic->bmi[ib].as_mode.second = best_second_mode;
#endif
- }
- *Rate = cost;
- *rate_y += tot_rate_y;
- *Distortion = distortion;
- return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
+ }
+ *Rate = cost;
+ *rate_y += tot_rate_y;
+ *Distortion = distortion;
+ return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
}
-static int rd_cost_mbuv(MACROBLOCK *mb)
-{
- int b;
- int cost = 0;
- MACROBLOCKD *x = &mb->e_mbd;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+static int rd_cost_mbuv(MACROBLOCK *mb) {
+ int b;
+ int cost = 0;
+ MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 16; b < 24; b++)
- cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_UV,
- ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ for (b = 16; b < 24; b++)
+ cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_UV,
+ ta + vp8_block2above[b], tl + vp8_block2left[b]);
- return cost;
+ return cost;
}
static int rd_inter16x16_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate,
- int *distortion, int fullpixel)
-{
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
- x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
+ int *distortion, int fullpixel) {
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
+ x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
- vp8_transform_mbuv(x);
- vp8_quantize_mbuv(x);
+ vp8_transform_mbuv(x);
+ vp8_quantize_mbuv(x);
- *rate = rd_cost_mbuv(x);
- *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
+ *rate = rd_cost_mbuv(x);
+ *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
- return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
+ return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
}
-static int rd_cost_mbuv_8x8(MACROBLOCK *mb)
-{
- int b;
- int cost = 0;
- MACROBLOCKD *x = &mb->e_mbd;
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
+static int rd_cost_mbuv_8x8(MACROBLOCK *mb) {
+ int b;
+ int cost = 0;
+ MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
- vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 16; b < 24; b+=4)
- cost += cost_coeffs_8x8(mb, x->block + b, PLANE_TYPE_UV,
- ta + vp8_block2above_8x8[b],
- tl + vp8_block2left_8x8[b]);
+ for (b = 16; b < 24; b += 4)
+ cost += cost_coeffs_8x8(mb, x->block + b, PLANE_TYPE_UV,
+ ta + vp8_block2above_8x8[b],
+ tl + vp8_block2left_8x8[b]);
- return cost;
+ return cost;
}
static int rd_inter16x16_uv_8x8(VP8_COMP *cpi, MACROBLOCK *x, int *rate,
- int *distortion, int fullpixel)
-{
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
- x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
+ int *distortion, int fullpixel) {
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
+ x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
- vp8_transform_mbuv_8x8(x);
+ vp8_transform_mbuv_8x8(x);
- vp8_quantize_mbuv_8x8(x);
+ vp8_quantize_mbuv_8x8(x);
- *rate = rd_cost_mbuv_8x8(x);
- *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
+ *rate = rd_cost_mbuv_8x8(x);
+ *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
- return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
+ return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
}
static int rd_inter4x4_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate,
- int *distortion, int fullpixel)
-{
- vp8_build_inter4x4_predictors_mbuv(&x->e_mbd);
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
- x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
+ int *distortion, int fullpixel) {
+ vp8_build_inter4x4_predictors_mbuv(&x->e_mbd);
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
+ x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
- vp8_transform_mbuv(x);
- vp8_quantize_mbuv(x);
+ vp8_transform_mbuv(x);
+ vp8_quantize_mbuv(x);
- *rate = rd_cost_mbuv(x);
- *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
+ *rate = rd_cost_mbuv(x);
+ *distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
- return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
+ return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
}
static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi,
MACROBLOCK *x,
int *rate,
int *rate_tokenonly,
- int *distortion)
-{
- MB_PREDICTION_MODE mode;
- MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
+ int *distortion) {
+ MB_PREDICTION_MODE mode;
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
#if CONFIG_COMP_INTRA_PRED
- MB_PREDICTION_MODE mode2;
- MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode2_selected);
+ MB_PREDICTION_MODE mode2;
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode2_selected);
#endif
- int best_rd = INT_MAX;
- int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
- int rate_to;
+ int best_rd = INT_MAX;
+ int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
+ int rate_to;
- for (mode = DC_PRED; mode <= TM_PRED; mode++)
- {
+ for (mode = DC_PRED; mode <= TM_PRED; mode++) {
#if CONFIG_COMP_INTRA_PRED
- for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++)
- {
+ for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++) {
#endif
- int rate;
- int distortion;
- int this_rd;
+ int rate;
+ int distortion;
+ int this_rd;
- x->e_mbd.mode_info_context->mbmi.uv_mode = mode;
+ x->e_mbd.mode_info_context->mbmi.uv_mode = mode;
#if CONFIG_COMP_INTRA_PRED
- x->e_mbd.mode_info_context->mbmi.second_uv_mode = mode2;
- if (mode2 == (MB_PREDICTION_MODE) (DC_PRED - 1))
- {
+ x->e_mbd.mode_info_context->mbmi.second_uv_mode = mode2;
+ if (mode2 == (MB_PREDICTION_MODE)(DC_PRED - 1)) {
#endif
RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mbuv)
- (&x->e_mbd);
+ (&x->e_mbd);
#if CONFIG_COMP_INTRA_PRED
- }
- else
- {
- continue;
- RECON_INVOKE(&cpi->rtcd.common->recon, build_comp_intra_predictors_mbuv)
- (&x->e_mbd);
- }
+ } else {
+ continue;
+ RECON_INVOKE(&cpi->rtcd.common->recon, build_comp_intra_predictors_mbuv)
+ (&x->e_mbd);
+ }
#endif
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
- x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor,
- x->src.uv_stride);
- vp8_transform_mbuv(x);
- vp8_quantize_mbuv(x);
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
+ x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor,
+ x->src.uv_stride);
+ vp8_transform_mbuv(x);
+ vp8_quantize_mbuv(x);
- rate_to = rd_cost_mbuv(x);
- rate = rate_to
+ rate_to = rd_cost_mbuv(x);
+ rate = rate_to
+ x->intra_uv_mode_cost[x->e_mbd.frame_type]
- [x->e_mbd.mode_info_context->mbmi.uv_mode];
+ [x->e_mbd.mode_info_context->mbmi.uv_mode];
- distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
+ distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
- if (this_rd < best_rd)
- {
- best_rd = this_rd;
- d = distortion;
- r = rate;
- *rate_tokenonly = rate_to;
- mode_selected = mode;
+ if (this_rd < best_rd) {
+ best_rd = this_rd;
+ d = distortion;
+ r = rate;
+ *rate_tokenonly = rate_to;
+ mode_selected = mode;
#if CONFIG_COMP_INTRA_PRED
- mode2_selected = mode2;
- }
+ mode2_selected = mode2;
+ }
#endif
- }
}
+ }
- *rate = r;
- *distortion = d;
+ *rate = r;
+ *distortion = d;
- x->e_mbd.mode_info_context->mbmi.uv_mode = mode_selected;
+ x->e_mbd.mode_info_context->mbmi.uv_mode = mode_selected;
#if CONFIG_COMP_INTRA_PRED
- x->e_mbd.mode_info_context->mbmi.second_uv_mode = mode2_selected;
+ x->e_mbd.mode_info_context->mbmi.second_uv_mode = mode2_selected;
#endif
}
@@ -1494,261 +1393,240 @@ static void rd_pick_intra_mbuv_mode_8x8(VP8_COMP *cpi,
MACROBLOCK *x,
int *rate,
int *rate_tokenonly,
- int *distortion)
-{
- MB_PREDICTION_MODE mode;
- MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
- int best_rd = INT_MAX;
- int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
- int rate_to;
-
- for (mode = DC_PRED; mode <= TM_PRED; mode++)
- {
- int rate;
- int distortion;
- int this_rd;
+ int *distortion) {
+ MB_PREDICTION_MODE mode;
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
+ int best_rd = INT_MAX;
+ int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
+ int rate_to;
+
+ for (mode = DC_PRED; mode <= TM_PRED; mode++) {
+ int rate;
+ int distortion;
+ int this_rd;
- x->e_mbd.mode_info_context->mbmi.uv_mode = mode;
- RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mbuv)
- (&x->e_mbd);
- ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
- x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor,
- x->src.uv_stride);
- vp8_transform_mbuv_8x8(x);
+ x->e_mbd.mode_info_context->mbmi.uv_mode = mode;
+ RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mbuv)
+ (&x->e_mbd);
+ ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
+ x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor,
+ x->src.uv_stride);
+ vp8_transform_mbuv_8x8(x);
- vp8_quantize_mbuv_8x8(x);
+ vp8_quantize_mbuv_8x8(x);
- rate_to = rd_cost_mbuv_8x8(x);
- rate = rate_to + x->intra_uv_mode_cost[x->e_mbd.frame_type]
- [x->e_mbd.mode_info_context->mbmi.uv_mode];
+ rate_to = rd_cost_mbuv_8x8(x);
+ rate = rate_to + x->intra_uv_mode_cost[x->e_mbd.frame_type]
+ [x->e_mbd.mode_info_context->mbmi.uv_mode];
- distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+ distortion = ENCODEMB_INVOKE(&cpi->rtcd.encodemb, mbuverr)(x) / 4;
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
- if (this_rd < best_rd)
- {
- best_rd = this_rd;
- d = distortion;
- r = rate;
- *rate_tokenonly = rate_to;
- mode_selected = mode;
- }
+ if (this_rd < best_rd) {
+ best_rd = this_rd;
+ d = distortion;
+ r = rate;
+ *rate_tokenonly = rate_to;
+ mode_selected = mode;
}
- *rate = r;
- *distortion = d;
- x->e_mbd.mode_info_context->mbmi.uv_mode = mode_selected;
+ }
+ *rate = r;
+ *distortion = d;
+ x->e_mbd.mode_info_context->mbmi.uv_mode = mode_selected;
}
int vp8_cost_mv_ref(VP8_COMP *cpi,
MB_PREDICTION_MODE m,
- const int near_mv_ref_ct[4])
-{
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- // If the mode coding is done entirely at the segment level
- // we should not account for it at the per mb level in rd code.
- // Note that if the segment level coding is expanded from single mode
- // to multiple mode masks as per reference frame coding we will need
- // to do something different here.
- if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE) )
- {
- VP8_COMMON *pc = &cpi->common;
-
- vp8_prob p [VP8_MVREFS-1];
- assert(NEARESTMV <= m && m <= SPLITMV);
- vp8_mv_ref_probs(pc, p, near_mv_ref_ct);
- return vp8_cost_token(vp8_mv_ref_tree, p,
- vp8_mv_ref_encoding_array - NEARESTMV + m);
- }
- else
- return 0;
+ const int near_mv_ref_ct[4]) {
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ // If the mode coding is done entirely at the segment level
+ // we should not account for it at the per mb level in rd code.
+ // Note that if the segment level coding is expanded from single mode
+ // to multiple mode masks as per reference frame coding we will need
+ // to do something different here.
+ if (!segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
+ VP8_COMMON *pc = &cpi->common;
+
+ vp8_prob p [VP8_MVREFS - 1];
+ assert(NEARESTMV <= m && m <= SPLITMV);
+ vp8_mv_ref_probs(pc, p, near_mv_ref_ct);
+ return vp8_cost_token(vp8_mv_ref_tree, p,
+ vp8_mv_ref_encoding_array - NEARESTMV + m);
+ } else
+ return 0;
}
-void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv)
-{
- x->e_mbd.mode_info_context->mbmi.mode = mb;
- x->e_mbd.mode_info_context->mbmi.mv.as_int = mv->as_int;
+void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) {
+ x->e_mbd.mode_info_context->mbmi.mode = mb;
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = mv->as_int;
}
static int labels2mode(
- MACROBLOCK *x,
- int const *labelings, int which_label,
- B_PREDICTION_MODE this_mode,
- int_mv *this_mv, int_mv *this_second_mv,
- int_mv seg_mvs[MAX_REF_FRAMES - 1],
- int_mv *best_ref_mv,
- int_mv *second_best_ref_mv,
- int *mvcost[2]
-)
-{
- MACROBLOCKD *const xd = & x->e_mbd;
- MODE_INFO *const mic = xd->mode_info_context;
- const int mis = xd->mode_info_stride;
-
- int cost = 0;
- int thismvcost = 0;
-
- /* We have to be careful retrieving previously-encoded motion vectors.
- Ones from this macroblock have to be pulled from the BLOCKD array
- as they have not yet made it to the bmi array in our MB_MODE_INFO. */
-
- int i = 0;
-
- do
- {
- BLOCKD *const d = xd->block + i;
- const int row = i >> 2, col = i & 3;
-
- B_PREDICTION_MODE m;
-
- if (labelings[i] != which_label)
- continue;
-
- if (col && labelings[i] == labelings[i-1])
- m = LEFT4X4;
- else if (row && labelings[i] == labelings[i-4])
- m = ABOVE4X4;
- else
- {
- // the only time we should do costing for new motion vector or mode
- // is when we are on a new label (jbb May 08, 2007)
- switch (m = this_mode)
- {
- case NEW4X4 :
- if (xd->mode_info_context->mbmi.second_ref_frame)
- {
- this_mv->as_int = seg_mvs[xd->mode_info_context->mbmi.ref_frame - 1].as_int;
- this_second_mv->as_int = seg_mvs[xd->mode_info_context->mbmi.second_ref_frame - 1].as_int;
- }
+ MACROBLOCK *x,
+ int const *labelings, int which_label,
+ B_PREDICTION_MODE this_mode,
+ int_mv *this_mv, int_mv *this_second_mv,
+ int_mv seg_mvs[MAX_REF_FRAMES - 1],
+ int_mv *best_ref_mv,
+ int_mv *second_best_ref_mv,
+ int *mvcost[2]
+) {
+ MACROBLOCKD *const xd = & x->e_mbd;
+ MODE_INFO *const mic = xd->mode_info_context;
+ const int mis = xd->mode_info_stride;
+
+ int cost = 0;
+ int thismvcost = 0;
+
+ /* We have to be careful retrieving previously-encoded motion vectors.
+ Ones from this macroblock have to be pulled from the BLOCKD array
+ as they have not yet made it to the bmi array in our MB_MODE_INFO. */
+
+ int i = 0;
+
+ do {
+ BLOCKD *const d = xd->block + i;
+ const int row = i >> 2, col = i & 3;
+
+ B_PREDICTION_MODE m;
+
+ if (labelings[i] != which_label)
+ continue;
+
+ if (col && labelings[i] == labelings[i - 1])
+ m = LEFT4X4;
+ else if (row && labelings[i] == labelings[i - 4])
+ m = ABOVE4X4;
+ else {
+ // the only time we should do costing for new motion vector or mode
+ // is when we are on a new label (jbb May 08, 2007)
+ switch (m = this_mode) {
+ case NEW4X4 :
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ this_mv->as_int = seg_mvs[xd->mode_info_context->mbmi.ref_frame - 1].as_int;
+ this_second_mv->as_int = seg_mvs[xd->mode_info_context->mbmi.second_ref_frame - 1].as_int;
+ }
#if CONFIG_HIGH_PRECISION_MV
- thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, mvcost,
- 102, xd->allow_high_precision_mv);
- if (xd->mode_info_context->mbmi.second_ref_frame)
- {
- thismvcost += vp8_mv_bit_cost(this_second_mv, second_best_ref_mv, mvcost,
- 102, xd->allow_high_precision_mv);
- }
+ thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, mvcost,
+ 102, xd->allow_high_precision_mv);
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ thismvcost += vp8_mv_bit_cost(this_second_mv, second_best_ref_mv, mvcost,
+ 102, xd->allow_high_precision_mv);
+ }
#else
- thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, mvcost, 102);
- if (xd->mode_info_context->mbmi.second_ref_frame)
- {
- thismvcost += vp8_mv_bit_cost(this_second_mv, second_best_ref_mv, mvcost, 102);
- }
-#endif
- break;
- case LEFT4X4:
- this_mv->as_int = col ? d[-1].bmi.as_mv.first.as_int : left_block_mv(mic, i);
- if (xd->mode_info_context->mbmi.second_ref_frame)
- this_second_mv->as_int = col ? d[-1].bmi.as_mv.second.as_int : left_block_second_mv(mic, i);
- break;
- case ABOVE4X4:
- this_mv->as_int = row ? d[-4].bmi.as_mv.first.as_int : above_block_mv(mic, i, mis);
- if (xd->mode_info_context->mbmi.second_ref_frame)
- this_second_mv->as_int = row ? d[-4].bmi.as_mv.second.as_int : above_block_second_mv(mic, i, mis);
- break;
- case ZERO4X4:
- this_mv->as_int = 0;
- if (xd->mode_info_context->mbmi.second_ref_frame)
- this_second_mv->as_int = 0;
- break;
- default:
- break;
- }
+ thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, mvcost, 102);
+ if (xd->mode_info_context->mbmi.second_ref_frame) {
+ thismvcost += vp8_mv_bit_cost(this_second_mv, second_best_ref_mv, mvcost, 102);
+ }
+#endif
+ break;
+ case LEFT4X4:
+ this_mv->as_int = col ? d[-1].bmi.as_mv.first.as_int : left_block_mv(mic, i);
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ this_second_mv->as_int = col ? d[-1].bmi.as_mv.second.as_int : left_block_second_mv(mic, i);
+ break;
+ case ABOVE4X4:
+ this_mv->as_int = row ? d[-4].bmi.as_mv.first.as_int : above_block_mv(mic, i, mis);
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ this_second_mv->as_int = row ? d[-4].bmi.as_mv.second.as_int : above_block_second_mv(mic, i, mis);
+ break;
+ case ZERO4X4:
+ this_mv->as_int = 0;
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ this_second_mv->as_int = 0;
+ break;
+ default:
+ break;
+ }
- if (m == ABOVE4X4) // replace above with left if same
- {
- int_mv left_mv, left_second_mv;
+ if (m == ABOVE4X4) { // replace above with left if same
+ int_mv left_mv, left_second_mv;
- left_mv.as_int = col ? d[-1].bmi.as_mv.first.as_int :
- left_block_mv(mic, i);
- if (xd->mode_info_context->mbmi.second_ref_frame)
- left_second_mv.as_int = col ? d[-1].bmi.as_mv.second.as_int :
- left_block_second_mv(mic, i);
+ left_mv.as_int = col ? d[-1].bmi.as_mv.first.as_int :
+ left_block_mv(mic, i);
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ left_second_mv.as_int = col ? d[-1].bmi.as_mv.second.as_int :
+ left_block_second_mv(mic, i);
- if (left_mv.as_int == this_mv->as_int &&
- (!xd->mode_info_context->mbmi.second_ref_frame ||
- left_second_mv.as_int == this_second_mv->as_int))
- m = LEFT4X4;
- }
+ if (left_mv.as_int == this_mv->as_int &&
+ (!xd->mode_info_context->mbmi.second_ref_frame ||
+ left_second_mv.as_int == this_second_mv->as_int))
+ m = LEFT4X4;
+ }
- cost = x->inter_bmode_costs[ m];
- }
+ cost = x->inter_bmode_costs[ m];
+ }
- d->bmi.as_mv.first.as_int = this_mv->as_int;
- if (xd->mode_info_context->mbmi.second_ref_frame)
- d->bmi.as_mv.second.as_int = this_second_mv->as_int;
+ d->bmi.as_mv.first.as_int = this_mv->as_int;
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ d->bmi.as_mv.second.as_int = this_second_mv->as_int;
- x->partition_info->bmi[i].mode = m;
- x->partition_info->bmi[i].mv.as_int = this_mv->as_int;
- if (xd->mode_info_context->mbmi.second_ref_frame)
- x->partition_info->bmi[i].second_mv.as_int = this_second_mv->as_int;
- }
- while (++i < 16);
+ x->partition_info->bmi[i].mode = m;
+ x->partition_info->bmi[i].mv.as_int = this_mv->as_int;
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ x->partition_info->bmi[i].second_mv.as_int = this_second_mv->as_int;
+ } while (++i < 16);
- cost += thismvcost ;
- return cost;
+ cost += thismvcost;
+ return cost;
}
static int rdcost_mbsegment_y(MACROBLOCK *mb, const int *labels,
int which_label, ENTROPY_CONTEXT *ta,
- ENTROPY_CONTEXT *tl)
-{
- int cost = 0;
- int b;
- MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT *tl) {
+ int cost = 0;
+ int b;
+ MACROBLOCKD *x = &mb->e_mbd;
- for (b = 0; b < 16; b++)
- if (labels[ b] == which_label)
- cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_WITH_DC,
- ta + vp8_block2above[b],
- tl + vp8_block2left[b]);
+ for (b = 0; b < 16; b++)
+ if (labels[ b] == which_label)
+ cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_WITH_DC,
+ ta + vp8_block2above[b],
+ tl + vp8_block2left[b]);
- return cost;
+ return cost;
}
static unsigned int vp8_encode_inter_mb_segment(
- MACROBLOCK *x,
- int const *labels,
- int which_label,
- const VP8_ENCODER_RTCD *rtcd)
-{
- int i;
- unsigned int distortion = 0;
-
- for (i = 0; i < 16; i++)
- {
- if (labels[i] == which_label)
- {
- BLOCKD *bd = &x->e_mbd.block[i];
- BLOCK *be = &x->block[i];
- int thisdistortion;
-
- vp8_build_inter_predictors_b(bd, 16, x->e_mbd.subpixel_predict);
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- vp8_build_2nd_inter_predictors_b(bd, 16, x->e_mbd.subpixel_predict_avg);
- ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, bd, 16);
- x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
-
- // set to 0 no way to account for 2nd order DC so discount
- //be->coeff[0] = 0;
- x->quantize_b(be, bd);
- thisdistortion = ENCODEMB_INVOKE(&rtcd->encodemb,berr)(
- be->coeff,
- bd->dqcoeff)/4;
- distortion += thisdistortion;
- }
- }
- return distortion;
+ MACROBLOCK *x,
+ int const *labels,
+ int which_label,
+ const VP8_ENCODER_RTCD *rtcd) {
+ int i;
+ unsigned int distortion = 0;
+
+ for (i = 0; i < 16; i++) {
+ if (labels[i] == which_label) {
+ BLOCKD *bd = &x->e_mbd.block[i];
+ BLOCK *be = &x->block[i];
+ int thisdistortion;
+
+ vp8_build_inter_predictors_b(bd, 16, x->e_mbd.subpixel_predict);
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ vp8_build_2nd_inter_predictors_b(bd, 16, x->e_mbd.subpixel_predict_avg);
+ ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, bd, 16);
+ x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
+
+ // set to 0 no way to account for 2nd order DC so discount
+ // be->coeff[0] = 0;
+ x->quantize_b(be, bd);
+ thisdistortion = ENCODEMB_INVOKE(&rtcd->encodemb, berr)(
+ be->coeff,
+ bd->dqcoeff) / 4;
+ distortion += thisdistortion;
+ }
+ }
+ return distortion;
}
static const unsigned int segmentation_to_sseshift[4] = {3, 3, 2, 0};
-typedef struct
-{
+typedef struct {
int_mv *ref_mv, *second_ref_mv;
int_mv mvp;
@@ -1772,312 +1650,288 @@ typedef struct
static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
BEST_SEG_INFO *bsi, unsigned int segmentation,
- int_mv seg_mvs[16 /* n_blocks */][MAX_REF_FRAMES - 1])
-{
- int i;
- int const *labels;
- int br = 0;
- int bd = 0;
- B_PREDICTION_MODE this_mode;
-
-
- int label_count;
- int this_segment_rd = 0;
- int label_mv_thresh;
- int rate = 0;
- int sbr = 0;
- int sbd = 0;
- int segmentyrate = 0;
-
- vp8_variance_fn_ptr_t *v_fn_ptr;
-
- ENTROPY_CONTEXT_PLANES t_above, t_left;
- ENTROPY_CONTEXT *ta;
- ENTROPY_CONTEXT *tl;
- ENTROPY_CONTEXT_PLANES t_above_b, t_left_b;
- ENTROPY_CONTEXT *ta_b;
- ENTROPY_CONTEXT *tl_b;
-
- vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
-
- ta = (ENTROPY_CONTEXT *)&t_above;
- tl = (ENTROPY_CONTEXT *)&t_left;
- ta_b = (ENTROPY_CONTEXT *)&t_above_b;
- tl_b = (ENTROPY_CONTEXT *)&t_left_b;
-
- br = 0;
- bd = 0;
+ int_mv seg_mvs[16 /* n_blocks */][MAX_REF_FRAMES - 1]) {
+ int i;
+ int const *labels;
+ int br = 0;
+ int bd = 0;
+ B_PREDICTION_MODE this_mode;
+
+
+ int label_count;
+ int this_segment_rd = 0;
+ int label_mv_thresh;
+ int rate = 0;
+ int sbr = 0;
+ int sbd = 0;
+ int segmentyrate = 0;
+
+ vp8_variance_fn_ptr_t *v_fn_ptr;
+
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+ ENTROPY_CONTEXT_PLANES t_above_b, t_left_b;
+ ENTROPY_CONTEXT *ta_b;
+ ENTROPY_CONTEXT *tl_b;
+
+ vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+ ta_b = (ENTROPY_CONTEXT *)&t_above_b;
+ tl_b = (ENTROPY_CONTEXT *)&t_left_b;
+
+ br = 0;
+ bd = 0;
+
+ v_fn_ptr = &cpi->fn_ptr[segmentation];
+ labels = vp8_mbsplits[segmentation];
+ label_count = vp8_mbsplit_count[segmentation];
+
+ // 64 makes this threshold really big effectively
+ // making it so that we very rarely check mvs on
+ // segments. setting this to 1 would make mv thresh
+ // roughly equal to what it is for macroblocks
+ label_mv_thresh = 1 * bsi->mvthresh / label_count;
+
+ // Segmentation method overheads
+ rate = vp8_cost_token(vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + segmentation);
+ rate += vp8_cost_mv_ref(cpi, SPLITMV, bsi->mdcounts);
+ this_segment_rd += RDCOST(x->rdmult, x->rddiv, rate, 0);
+ br += rate;
+
+ for (i = 0; i < label_count; i++) {
+ int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT];
+ int best_label_rd = INT_MAX;
+ B_PREDICTION_MODE mode_selected = ZERO4X4;
+ int bestlabelyrate = 0;
+
+ // search for the best motion vector on this segment
+ for (this_mode = LEFT4X4; this_mode <= NEW4X4; this_mode ++) {
+ int this_rd;
+ int distortion;
+ int labelyrate;
+ ENTROPY_CONTEXT_PLANES t_above_s, t_left_s;
+ ENTROPY_CONTEXT *ta_s;
+ ENTROPY_CONTEXT *tl_s;
+
+ vpx_memcpy(&t_above_s, &t_above, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left_s, &t_left, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta_s = (ENTROPY_CONTEXT *)&t_above_s;
+ tl_s = (ENTROPY_CONTEXT *)&t_left_s;
+
+ // motion search for newmv (single predictor case only)
+ if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame && this_mode == NEW4X4) {
+ int sseshift;
+ int num00;
+ int step_param = 0;
+ int further_steps;
+ int n;
+ int thissme;
+ int bestsme = INT_MAX;
+ int_mv temp_mv;
+ BLOCK *c;
+ BLOCKD *e;
+
+ // Is the best so far sufficiently good that we cant justify doing and new motion search.
+ if (best_label_rd < label_mv_thresh)
+ break;
+
+ if (cpi->compressor_speed) {
+ if (segmentation == BLOCK_8X16 || segmentation == BLOCK_16X8) {
+ bsi->mvp.as_int = bsi->sv_mvp[i].as_int;
+ if (i == 1 && segmentation == BLOCK_16X8)
+ bsi->mvp.as_int = bsi->sv_mvp[2].as_int;
+
+ step_param = bsi->sv_istep[i];
+ }
+
+ // use previous block's result as next block's MV predictor.
+ if (segmentation == BLOCK_4X4 && i > 0) {
+ bsi->mvp.as_int = x->e_mbd.block[i - 1].bmi.as_mv.first.as_int;
+ if (i == 4 || i == 8 || i == 12)
+ bsi->mvp.as_int = x->e_mbd.block[i - 4].bmi.as_mv.first.as_int;
+ step_param = 2;
+ }
+ }
+
+ further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
+
+ {
+ int sadpb = x->sadperbit4;
+ int_mv mvp_full;
+
+ mvp_full.as_mv.row = bsi->mvp.as_mv.row >> 3;
+ mvp_full.as_mv.col = bsi->mvp.as_mv.col >> 3;
+
+ // find first label
+ n = vp8_mbsplit_offset[segmentation][i];
+
+ c = &x->block[n];
+ e = &x->e_mbd.block[n];
+
+ {
+ bestsme = cpi->diamond_search_sad(x, c, e, &mvp_full,
+ &mode_mv[NEW4X4], step_param,
+ sadpb, &num00, v_fn_ptr,
+ XMVCOST,
+ bsi->ref_mv);
+
+ n = num00;
+ num00 = 0;
+
+ while (n < further_steps) {
+ n++;
+
+ if (num00)
+ num00--;
+ else {
+ thissme = cpi->diamond_search_sad(x, c, e,
+ &mvp_full, &temp_mv,
+ step_param + n, sadpb,
+ &num00, v_fn_ptr,
+ XMVCOST,
+ bsi->ref_mv);
+
+ if (thissme < bestsme) {
+ bestsme = thissme;
+ mode_mv[NEW4X4].as_int = temp_mv.as_int;
+ }
+ }
+ }
+ }
- v_fn_ptr = &cpi->fn_ptr[segmentation];
- labels = vp8_mbsplits[segmentation];
- label_count = vp8_mbsplit_count[segmentation];
+ sseshift = segmentation_to_sseshift[segmentation];
- // 64 makes this threshold really big effectively
- // making it so that we very rarely check mvs on
- // segments. setting this to 1 would make mv thresh
- // roughly equal to what it is for macroblocks
- label_mv_thresh = 1 * bsi->mvthresh / label_count ;
+ // Should we do a full search (best quality only)
+ if ((cpi->compressor_speed == 0) && (bestsme >> sseshift) > 4000) {
+ /* Check if mvp_full is within the range. */
+ vp8_clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- // Segmentation method overheads
- rate = vp8_cost_token(vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + segmentation);
- rate += vp8_cost_mv_ref(cpi, SPLITMV, bsi->mdcounts);
- this_segment_rd += RDCOST(x->rdmult, x->rddiv, rate, 0);
- br += rate;
+ thissme = cpi->full_search_sad(x, c, e, &mvp_full,
+ sadpb, 16, v_fn_ptr,
+ XMVCOST, bsi->ref_mv);
- for (i = 0; i < label_count; i++)
- {
- int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT];
- int best_label_rd = INT_MAX;
- B_PREDICTION_MODE mode_selected = ZERO4X4;
- int bestlabelyrate = 0;
+ if (thissme < bestsme) {
+ bestsme = thissme;
+ mode_mv[NEW4X4].as_int = e->bmi.as_mv.first.as_int;
+ } else {
+ // The full search result is actually worse so re-instate the previous best vector
+ e->bmi.as_mv.first.as_int = mode_mv[NEW4X4].as_int;
+ }
+ }
+ }
- // search for the best motion vector on this segment
- for (this_mode = LEFT4X4; this_mode <= NEW4X4 ; this_mode ++)
- {
- int this_rd;
- int distortion;
- int labelyrate;
- ENTROPY_CONTEXT_PLANES t_above_s, t_left_s;
- ENTROPY_CONTEXT *ta_s;
- ENTROPY_CONTEXT *tl_s;
-
- vpx_memcpy(&t_above_s, &t_above, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(&t_left_s, &t_left, sizeof(ENTROPY_CONTEXT_PLANES));
-
- ta_s = (ENTROPY_CONTEXT *)&t_above_s;
- tl_s = (ENTROPY_CONTEXT *)&t_left_s;
-
- // motion search for newmv (single predictor case only)
- if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame && this_mode == NEW4X4)
- {
- int sseshift;
- int num00;
- int step_param = 0;
- int further_steps;
- int n;
- int thissme;
- int bestsme = INT_MAX;
- int_mv temp_mv;
- BLOCK *c;
- BLOCKD *e;
-
- // Is the best so far sufficiently good that we cant justify doing and new motion search.
- if (best_label_rd < label_mv_thresh)
- break;
-
- if(cpi->compressor_speed)
- {
- if (segmentation == BLOCK_8X16 || segmentation == BLOCK_16X8)
- {
- bsi->mvp.as_int = bsi->sv_mvp[i].as_int;
- if (i==1 && segmentation == BLOCK_16X8)
- bsi->mvp.as_int = bsi->sv_mvp[2].as_int;
-
- step_param = bsi->sv_istep[i];
- }
-
- // use previous block's result as next block's MV predictor.
- if (segmentation == BLOCK_4X4 && i>0)
- {
- bsi->mvp.as_int = x->e_mbd.block[i-1].bmi.as_mv.first.as_int;
- if (i==4 || i==8 || i==12)
- bsi->mvp.as_int = x->e_mbd.block[i-4].bmi.as_mv.first.as_int;
- step_param = 2;
- }
- }
+ if (bestsme < INT_MAX) {
+ int distortion;
+ unsigned int sse;
+ cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
+ bsi->ref_mv, x->errorperbit, v_fn_ptr, XMVCOST,
+ &distortion, &sse);
- further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
-
- {
- int sadpb = x->sadperbit4;
- int_mv mvp_full;
-
- mvp_full.as_mv.row = bsi->mvp.as_mv.row >>3;
- mvp_full.as_mv.col = bsi->mvp.as_mv.col >>3;
-
- // find first label
- n = vp8_mbsplit_offset[segmentation][i];
-
- c = &x->block[n];
- e = &x->e_mbd.block[n];
-
- {
- bestsme = cpi->diamond_search_sad(x, c, e, &mvp_full,
- &mode_mv[NEW4X4], step_param,
- sadpb, &num00, v_fn_ptr,
- XMVCOST,
- bsi->ref_mv);
-
- n = num00;
- num00 = 0;
-
- while (n < further_steps)
- {
- n++;
-
- if (num00)
- num00--;
- else
- {
- thissme = cpi->diamond_search_sad(x, c, e,
- &mvp_full, &temp_mv,
- step_param + n, sadpb,
- &num00, v_fn_ptr,
- XMVCOST,
- bsi->ref_mv);
-
- if (thissme < bestsme)
- {
- bestsme = thissme;
- mode_mv[NEW4X4].as_int = temp_mv.as_int;
- }
- }
- }
- }
-
- sseshift = segmentation_to_sseshift[segmentation];
-
- // Should we do a full search (best quality only)
- if ((cpi->compressor_speed == 0) && (bestsme >> sseshift) > 4000)
- {
- /* Check if mvp_full is within the range. */
- vp8_clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
-
- thissme = cpi->full_search_sad(x, c, e, &mvp_full,
- sadpb, 16, v_fn_ptr,
- XMVCOST, bsi->ref_mv);
-
- if (thissme < bestsme)
- {
- bestsme = thissme;
- mode_mv[NEW4X4].as_int = e->bmi.as_mv.first.as_int;
- }
- else
- {
- // The full search result is actually worse so re-instate the previous best vector
- e->bmi.as_mv.first.as_int = mode_mv[NEW4X4].as_int;
- }
- }
- }
+ // safe motion search result for use in compound prediction
+ seg_mvs[i][x->e_mbd.mode_info_context->mbmi.ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
+ }
+ } /* NEW4X4 */
+ else if (x->e_mbd.mode_info_context->mbmi.second_ref_frame && this_mode == NEW4X4) {
+ // motion search not completed? Then skip newmv for this block with comppred
+ if (seg_mvs[i][x->e_mbd.mode_info_context->mbmi.second_ref_frame - 1].as_int == INVALID_MV ||
+ seg_mvs[i][x->e_mbd.mode_info_context->mbmi.ref_frame - 1].as_int == INVALID_MV) {
+ continue;
+ }
+ }
- if (bestsme < INT_MAX)
- {
- int distortion;
- unsigned int sse;
- cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
- bsi->ref_mv, x->errorperbit, v_fn_ptr, XMVCOST,
- &distortion, &sse);
+ rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
+ &second_mode_mv[this_mode], seg_mvs[i], bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
- // safe motion search result for use in compound prediction
- seg_mvs[i][x->e_mbd.mode_info_context->mbmi.ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
- }
- } /* NEW4X4 */
- else if (x->e_mbd.mode_info_context->mbmi.second_ref_frame && this_mode == NEW4X4)
- {
- // motion search not completed? Then skip newmv for this block with comppred
- if (seg_mvs[i][x->e_mbd.mode_info_context->mbmi.second_ref_frame - 1].as_int == INVALID_MV ||
- seg_mvs[i][x->e_mbd.mode_info_context->mbmi.ref_frame - 1].as_int == INVALID_MV)
- {
- continue;
- }
- }
+ // Trap vectors that reach beyond the UMV borders
+ if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
+ ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) || ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
+ continue;
+ }
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ if (((second_mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
+ ((second_mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
+ ((second_mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) ||
+ ((second_mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
+ continue;
+ }
+ }
- rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
- &second_mode_mv[this_mode], seg_mvs[i], bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
+ distortion = vp8_encode_inter_mb_segment(
+ x, labels, i,
+ IF_RTCD(&cpi->rtcd));
- // Trap vectors that reach beyond the UMV borders
- if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
- ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) || ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
- {
- continue;
- }
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- if (((second_mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
- ((second_mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
- ((second_mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) ||
- ((second_mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
- {
- continue;
- }
- }
+ labelyrate = rdcost_mbsegment_y(x, labels, i, ta_s, tl_s);
+ rate += labelyrate;
- distortion = vp8_encode_inter_mb_segment(
- x, labels, i,
- IF_RTCD(&cpi->rtcd));
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
- labelyrate = rdcost_mbsegment_y(x, labels, i, ta_s, tl_s);
- rate += labelyrate;
+ if (this_rd < best_label_rd) {
+ sbr = rate;
+ sbd = distortion;
+ bestlabelyrate = labelyrate;
+ mode_selected = this_mode;
+ best_label_rd = this_rd;
- this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+ vpx_memcpy(ta_b, ta_s, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(tl_b, tl_s, sizeof(ENTROPY_CONTEXT_PLANES));
- if (this_rd < best_label_rd)
- {
- sbr = rate;
- sbd = distortion;
- bestlabelyrate = labelyrate;
- mode_selected = this_mode;
- best_label_rd = this_rd;
+ }
+ } /*for each 4x4 mode*/
- vpx_memcpy(ta_b, ta_s, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(tl_b, tl_s, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(ta, ta_b, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(tl, tl_b, sizeof(ENTROPY_CONTEXT_PLANES));
- }
- } /*for each 4x4 mode*/
+ labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
+ &second_mode_mv[mode_selected], seg_mvs[i], bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
- vpx_memcpy(ta, ta_b, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memcpy(tl, tl_b, sizeof(ENTROPY_CONTEXT_PLANES));
+ br += sbr;
+ bd += sbd;
+ segmentyrate += bestlabelyrate;
+ this_segment_rd += best_label_rd;
- labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
- &second_mode_mv[mode_selected], seg_mvs[i], bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
-
- br += sbr;
- bd += sbd;
- segmentyrate += bestlabelyrate;
- this_segment_rd += best_label_rd;
+ if (this_segment_rd >= bsi->segment_rd) {
+ break;
+ }
- if (this_segment_rd >= bsi->segment_rd) {
- break;
- }
+ } /* for each label */
- } /* for each label */
+ if (this_segment_rd < bsi->segment_rd) {
+ bsi->r = br;
+ bsi->d = bd;
+ bsi->segment_yrate = segmentyrate;
+ bsi->segment_rd = this_segment_rd;
+ bsi->segment_num = segmentation;
- if (this_segment_rd < bsi->segment_rd)
- {
- bsi->r = br;
- bsi->d = bd;
- bsi->segment_yrate = segmentyrate;
- bsi->segment_rd = this_segment_rd;
- bsi->segment_num = segmentation;
-
- // store everything needed to come back to this!!
- for (i = 0; i < 16; i++)
- {
- BLOCKD *bd = &x->e_mbd.block[i];
+ // store everything needed to come back to this!!
+ for (i = 0; i < 16; i++) {
+ BLOCKD *bd = &x->e_mbd.block[i];
- bsi->mvs[i].as_mv = x->partition_info->bmi[i].mv.as_mv;
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- bsi->second_mvs[i].as_mv = x->partition_info->bmi[i].second_mv.as_mv;
- bsi->modes[i] = x->partition_info->bmi[i].mode;
- bsi->eobs[i] = bd->eob;
- }
+ bsi->mvs[i].as_mv = x->partition_info->bmi[i].mv.as_mv;
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ bsi->second_mvs[i].as_mv = x->partition_info->bmi[i].second_mv.as_mv;
+ bsi->modes[i] = x->partition_info->bmi[i].mode;
+ bsi->eobs[i] = bd->eob;
}
+ }
}
static __inline
-void vp8_cal_step_param(int sr, int *sp)
-{
- int step = 0;
+void vp8_cal_step_param(int sr, int *sp) {
+ int step = 0;
- if (sr > MAX_FIRST_STEP) sr = MAX_FIRST_STEP;
- else if (sr < 1) sr = 1;
+ if (sr > MAX_FIRST_STEP) sr = MAX_FIRST_STEP;
+ else if (sr < 1) sr = 1;
- while (sr>>=1)
- step++;
+ while (sr >>= 1)
+ step++;
- *sp = MAX_MVSEARCH_STEPS - 1 - step;
+ *sp = MAX_MVSEARCH_STEPS - 1 - step;
}
static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x,
@@ -2085,1085 +1939,969 @@ static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x,
int *mdcounts, int *returntotrate,
int *returnyrate, int *returndistortion,
int mvthresh,
- int_mv seg_mvs[BLOCK_MAX_SEGMENTS - 1][16 /* n_blocks */][MAX_REF_FRAMES - 1])
-{
- int i;
- BEST_SEG_INFO bsi;
-
- vpx_memset(&bsi, 0, sizeof(bsi));
+ int_mv seg_mvs[BLOCK_MAX_SEGMENTS - 1][16 /* n_blocks */][MAX_REF_FRAMES - 1]) {
+ int i;
+ BEST_SEG_INFO bsi;
+
+ vpx_memset(&bsi, 0, sizeof(bsi));
+
+ bsi.segment_rd = best_rd;
+ bsi.ref_mv = best_ref_mv;
+ bsi.second_ref_mv = second_best_ref_mv;
+ bsi.mvp.as_int = best_ref_mv->as_int;
+ bsi.mvthresh = mvthresh;
+ bsi.mdcounts = mdcounts;
+
+ for (i = 0; i < 16; i++) {
+ bsi.modes[i] = ZERO4X4;
+ }
+
+ if (cpi->compressor_speed == 0) {
+ /* for now, we will keep the original segmentation order
+ when in best quality mode */
+ rd_check_segment(cpi, x, &bsi, BLOCK_16X8, seg_mvs[BLOCK_16X8]);
+ rd_check_segment(cpi, x, &bsi, BLOCK_8X16, seg_mvs[BLOCK_8X16]);
+ rd_check_segment(cpi, x, &bsi, BLOCK_8X8, seg_mvs[BLOCK_8X8]);
+ rd_check_segment(cpi, x, &bsi, BLOCK_4X4, seg_mvs[BLOCK_4X4]);
+ } else {
+ int sr;
+
+ rd_check_segment(cpi, x, &bsi, BLOCK_8X8, seg_mvs[BLOCK_8X8]);
+
+
+ if (bsi.segment_rd < best_rd) {
+ int col_min = (best_ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.col & 7) ? 1 : 0);
+ int row_min = (best_ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.row & 7) ? 1 : 0);
+ int col_max = (best_ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
+ int row_max = (best_ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
+
+ int tmp_col_min = x->mv_col_min;
+ int tmp_col_max = x->mv_col_max;
+ int tmp_row_min = x->mv_row_min;
+ int tmp_row_max = x->mv_row_max;
+
+ /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
+ if (x->mv_col_min < col_min)
+ x->mv_col_min = col_min;
+ if (x->mv_col_max > col_max)
+ x->mv_col_max = col_max;
+ if (x->mv_row_min < row_min)
+ x->mv_row_min = row_min;
+ if (x->mv_row_max > row_max)
+ x->mv_row_max = row_max;
+
+ /* Get 8x8 result */
+ bsi.sv_mvp[0].as_int = bsi.mvs[0].as_int;
+ bsi.sv_mvp[1].as_int = bsi.mvs[2].as_int;
+ bsi.sv_mvp[2].as_int = bsi.mvs[8].as_int;
+ bsi.sv_mvp[3].as_int = bsi.mvs[10].as_int;
+
+ /* Use 8x8 result as 16x8/8x16's predictor MV. Adjust search range according to the closeness of 2 MV. */
+ /* block 8X16 */
+ {
+ sr = MAXF((abs(bsi.sv_mvp[0].as_mv.row - bsi.sv_mvp[2].as_mv.row)) >> 3, (abs(bsi.sv_mvp[0].as_mv.col - bsi.sv_mvp[2].as_mv.col)) >> 3);
+ vp8_cal_step_param(sr, &bsi.sv_istep[0]);
+
+ sr = MAXF((abs(bsi.sv_mvp[1].as_mv.row - bsi.sv_mvp[3].as_mv.row)) >> 3, (abs(bsi.sv_mvp[1].as_mv.col - bsi.sv_mvp[3].as_mv.col)) >> 3);
+ vp8_cal_step_param(sr, &bsi.sv_istep[1]);
- bsi.segment_rd = best_rd;
- bsi.ref_mv = best_ref_mv;
- bsi.second_ref_mv = second_best_ref_mv;
- bsi.mvp.as_int = best_ref_mv->as_int;
- bsi.mvthresh = mvthresh;
- bsi.mdcounts = mdcounts;
-
- for(i = 0; i < 16; i++)
- {
- bsi.modes[i] = ZERO4X4;
- }
-
- if(cpi->compressor_speed == 0)
- {
- /* for now, we will keep the original segmentation order
- when in best quality mode */
- rd_check_segment(cpi, x, &bsi, BLOCK_16X8, seg_mvs[BLOCK_16X8]);
rd_check_segment(cpi, x, &bsi, BLOCK_8X16, seg_mvs[BLOCK_8X16]);
- rd_check_segment(cpi, x, &bsi, BLOCK_8X8, seg_mvs[BLOCK_8X8]);
- rd_check_segment(cpi, x, &bsi, BLOCK_4X4, seg_mvs[BLOCK_4X4]);
- }
- else
- {
- int sr;
-
- rd_check_segment(cpi, x, &bsi, BLOCK_8X8, seg_mvs[BLOCK_8X8]);
-
-
- if (bsi.segment_rd < best_rd)
- {
- int col_min = (best_ref_mv->as_mv.col>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.col & 7)?1:0);
- int row_min = (best_ref_mv->as_mv.row>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.row & 7)?1:0);
- int col_max = (best_ref_mv->as_mv.col>>3) + MAX_FULL_PEL_VAL;
- int row_max = (best_ref_mv->as_mv.row>>3) + MAX_FULL_PEL_VAL;
-
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
-
- /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
- if (x->mv_col_min < col_min )
- x->mv_col_min = col_min;
- if (x->mv_col_max > col_max )
- x->mv_col_max = col_max;
- if (x->mv_row_min < row_min )
- x->mv_row_min = row_min;
- if (x->mv_row_max > row_max )
- x->mv_row_max = row_max;
-
- /* Get 8x8 result */
- bsi.sv_mvp[0].as_int = bsi.mvs[0].as_int;
- bsi.sv_mvp[1].as_int = bsi.mvs[2].as_int;
- bsi.sv_mvp[2].as_int = bsi.mvs[8].as_int;
- bsi.sv_mvp[3].as_int = bsi.mvs[10].as_int;
-
- /* Use 8x8 result as 16x8/8x16's predictor MV. Adjust search range according to the closeness of 2 MV. */
- /* block 8X16 */
- {
- sr = MAXF((abs(bsi.sv_mvp[0].as_mv.row - bsi.sv_mvp[2].as_mv.row))>>3, (abs(bsi.sv_mvp[0].as_mv.col - bsi.sv_mvp[2].as_mv.col))>>3);
- vp8_cal_step_param(sr, &bsi.sv_istep[0]);
-
- sr = MAXF((abs(bsi.sv_mvp[1].as_mv.row - bsi.sv_mvp[3].as_mv.row))>>3, (abs(bsi.sv_mvp[1].as_mv.col - bsi.sv_mvp[3].as_mv.col))>>3);
- vp8_cal_step_param(sr, &bsi.sv_istep[1]);
-
- rd_check_segment(cpi, x, &bsi, BLOCK_8X16, seg_mvs[BLOCK_8X16]);
- }
+ }
- /* block 16X8 */
- {
- sr = MAXF((abs(bsi.sv_mvp[0].as_mv.row - bsi.sv_mvp[1].as_mv.row))>>3, (abs(bsi.sv_mvp[0].as_mv.col - bsi.sv_mvp[1].as_mv.col))>>3);
- vp8_cal_step_param(sr, &bsi.sv_istep[0]);
+ /* block 16X8 */
+ {
+ sr = MAXF((abs(bsi.sv_mvp[0].as_mv.row - bsi.sv_mvp[1].as_mv.row)) >> 3, (abs(bsi.sv_mvp[0].as_mv.col - bsi.sv_mvp[1].as_mv.col)) >> 3);
+ vp8_cal_step_param(sr, &bsi.sv_istep[0]);
- sr = MAXF((abs(bsi.sv_mvp[2].as_mv.row - bsi.sv_mvp[3].as_mv.row))>>3, (abs(bsi.sv_mvp[2].as_mv.col - bsi.sv_mvp[3].as_mv.col))>>3);
- vp8_cal_step_param(sr, &bsi.sv_istep[1]);
+ sr = MAXF((abs(bsi.sv_mvp[2].as_mv.row - bsi.sv_mvp[3].as_mv.row)) >> 3, (abs(bsi.sv_mvp[2].as_mv.col - bsi.sv_mvp[3].as_mv.col)) >> 3);
+ vp8_cal_step_param(sr, &bsi.sv_istep[1]);
- rd_check_segment(cpi, x, &bsi, BLOCK_16X8, seg_mvs[BLOCK_16X8]);
- }
+ rd_check_segment(cpi, x, &bsi, BLOCK_16X8, seg_mvs[BLOCK_16X8]);
+ }
- /* If 8x8 is better than 16x8/8x16, then do 4x4 search */
- /* Not skip 4x4 if speed=0 (good quality) */
- if (cpi->sf.no_skip_block4x4_search || bsi.segment_num == BLOCK_8X8) /* || (sv_segment_rd8x8-bsi.segment_rd) < sv_segment_rd8x8>>5) */
- {
- bsi.mvp.as_int = bsi.sv_mvp[0].as_int;
- rd_check_segment(cpi, x, &bsi, BLOCK_4X4, seg_mvs[BLOCK_4X4]);
- }
+ /* If 8x8 is better than 16x8/8x16, then do 4x4 search */
+ /* Not skip 4x4 if speed=0 (good quality) */
+ if (cpi->sf.no_skip_block4x4_search || bsi.segment_num == BLOCK_8X8) { /* || (sv_segment_rd8x8-bsi.segment_rd) < sv_segment_rd8x8>>5) */
+ bsi.mvp.as_int = bsi.sv_mvp[0].as_int;
+ rd_check_segment(cpi, x, &bsi, BLOCK_4X4, seg_mvs[BLOCK_4X4]);
+ }
- /* restore UMV window */
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
- }
+ /* restore UMV window */
+ x->mv_col_min = tmp_col_min;
+ x->mv_col_max = tmp_col_max;
+ x->mv_row_min = tmp_row_min;
+ x->mv_row_max = tmp_row_max;
}
+ }
- /* set it to the best */
- for (i = 0; i < 16; i++)
- {
- BLOCKD *bd = &x->e_mbd.block[i];
+ /* set it to the best */
+ for (i = 0; i < 16; i++) {
+ BLOCKD *bd = &x->e_mbd.block[i];
- bd->bmi.as_mv.first.as_int = bsi.mvs[i].as_int;
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- bd->bmi.as_mv.second.as_int = bsi.second_mvs[i].as_int;
- bd->eob = bsi.eobs[i];
- }
+ bd->bmi.as_mv.first.as_int = bsi.mvs[i].as_int;
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ bd->bmi.as_mv.second.as_int = bsi.second_mvs[i].as_int;
+ bd->eob = bsi.eobs[i];
+ }
- *returntotrate = bsi.r;
- *returndistortion = bsi.d;
- *returnyrate = bsi.segment_yrate;
+ *returntotrate = bsi.r;
+ *returndistortion = bsi.d;
+ *returnyrate = bsi.segment_yrate;
- /* save partitions */
- x->e_mbd.mode_info_context->mbmi.partitioning = bsi.segment_num;
- x->partition_info->count = vp8_mbsplit_count[bsi.segment_num];
+ /* save partitions */
+ x->e_mbd.mode_info_context->mbmi.partitioning = bsi.segment_num;
+ x->partition_info->count = vp8_mbsplit_count[bsi.segment_num];
- for (i = 0; i < x->partition_info->count; i++)
- {
- int j;
+ for (i = 0; i < x->partition_info->count; i++) {
+ int j;
- j = vp8_mbsplit_offset[bsi.segment_num][i];
+ j = vp8_mbsplit_offset[bsi.segment_num][i];
- x->partition_info->bmi[i].mode = bsi.modes[j];
- x->partition_info->bmi[i].mv.as_mv = bsi.mvs[j].as_mv;
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- x->partition_info->bmi[i].second_mv.as_mv = bsi.second_mvs[j].as_mv;
- }
- /*
- * used to set x->e_mbd.mode_info_context->mbmi.mv.as_int
- */
- x->partition_info->bmi[15].mv.as_int = bsi.mvs[15].as_int;
+ x->partition_info->bmi[i].mode = bsi.modes[j];
+ x->partition_info->bmi[i].mv.as_mv = bsi.mvs[j].as_mv;
if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- x->partition_info->bmi[15].second_mv.as_int = bsi.second_mvs[15].as_int;
-
- return bsi.segment_rd;
+ x->partition_info->bmi[i].second_mv.as_mv = bsi.second_mvs[j].as_mv;
+ }
+ /*
+ * used to set x->e_mbd.mode_info_context->mbmi.mv.as_int
+ */
+ x->partition_info->bmi[15].mv.as_int = bsi.mvs[15].as_int;
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ x->partition_info->bmi[15].second_mv.as_int = bsi.second_mvs[15].as_int;
+
+ return bsi.segment_rd;
}
/* Order arr in increasing order, original position stored in idx */
-static void insertsortmv(int arr[], int len)
-{
- int i, j, k;
+static void insertsortmv(int arr[], int len) {
+ int i, j, k;
- for ( i = 1 ; i <= len-1 ; i++ )
- {
- for ( j = 0 ; j < i ; j++ )
- {
- if ( arr[j] > arr[i] )
- {
- int temp;
+ for (i = 1; i <= len - 1; i++) {
+ for (j = 0; j < i; j++) {
+ if (arr[j] > arr[i]) {
+ int temp;
- temp = arr[i];
+ temp = arr[i];
- for ( k = i; k >j; k--)
- arr[k] = arr[k - 1] ;
+ for (k = i; k > j; k--)
+ arr[k] = arr[k - 1];
- arr[j] = temp ;
- }
- }
+ arr[j] = temp;
+ }
}
+ }
}
-static void insertsortsad(int arr[],int idx[], int len)
-{
- int i, j, k;
+static void insertsortsad(int arr[], int idx[], int len) {
+ int i, j, k;
- for ( i = 1 ; i <= len-1 ; i++ )
- {
- for ( j = 0 ; j < i ; j++ )
- {
- if ( arr[j] > arr[i] )
- {
- int temp, tempi;
-
- temp = arr[i];
- tempi = idx[i];
+ for (i = 1; i <= len - 1; i++) {
+ for (j = 0; j < i; j++) {
+ if (arr[j] > arr[i]) {
+ int temp, tempi;
- for ( k = i; k >j; k--)
- {
- arr[k] = arr[k - 1] ;
- idx[k] = idx[k - 1];
- }
+ temp = arr[i];
+ tempi = idx[i];
- arr[j] = temp ;
- idx[j] = tempi;
- }
+ for (k = i; k > j; k--) {
+ arr[k] = arr[k - 1];
+ idx[k] = idx[k - 1];
}
+
+ arr[j] = temp;
+ idx[j] = tempi;
+ }
}
+ }
}
-//The improved MV prediction
+// The improved MV prediction
void vp8_mv_pred
(
- VP8_COMP *cpi,
- MACROBLOCKD *xd,
- const MODE_INFO *here,
- int_mv *mvp,
- int refframe,
- int *ref_frame_sign_bias,
- int *sr,
- int near_sadidx[]
-)
-{
- const MODE_INFO *above = here - xd->mode_info_stride;
- const MODE_INFO *left = here - 1;
- const MODE_INFO *aboveleft = above - 1;
- int_mv near_mvs[8];
- int near_ref[8];
- int_mv mv;
- int vcnt=0;
- int find=0;
- int mb_offset;
-
- int mvx[8];
- int mvy[8];
- int i;
-
- mv.as_int = 0;
-
- if(here->mbmi.ref_frame != INTRA_FRAME)
- {
- near_mvs[0].as_int = near_mvs[1].as_int = near_mvs[2].as_int = near_mvs[3].as_int = near_mvs[4].as_int = near_mvs[5].as_int = near_mvs[6].as_int = near_mvs[7].as_int = 0;
- near_ref[0] = near_ref[1] = near_ref[2] = near_ref[3] = near_ref[4] = near_ref[5] = near_ref[6] = near_ref[7] = 0;
-
- // read in 3 nearby block's MVs from current frame as prediction candidates.
- if (above->mbmi.ref_frame != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = above->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = above->mbmi.ref_frame;
- }
- vcnt++;
- if (left->mbmi.ref_frame != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = left->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = left->mbmi.ref_frame;
- }
- vcnt++;
- if (aboveleft->mbmi.ref_frame != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = aboveleft->mbmi.mv.as_int;
- mv_bias(ref_frame_sign_bias[aboveleft->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = aboveleft->mbmi.ref_frame;
- }
- vcnt++;
-
- // read in 5 nearby block's MVs from last frame.
- if(cpi->common.last_frame_type != KEY_FRAME)
- {
- mb_offset = (-xd->mb_to_top_edge/128 + 1) * (xd->mode_info_stride +1) + (-xd->mb_to_left_edge/128 +1) ;
-
- // current in last frame
- if (cpi->lf_ref_frame[mb_offset] != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = cpi->lfmv[mb_offset].as_int;
- mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = cpi->lf_ref_frame[mb_offset];
- }
- vcnt++;
-
- // above in last frame
- if (cpi->lf_ref_frame[mb_offset - xd->mode_info_stride-1] != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = cpi->lfmv[mb_offset - xd->mode_info_stride-1].as_int;
- mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset - xd->mode_info_stride-1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = cpi->lf_ref_frame[mb_offset - xd->mode_info_stride-1];
- }
- vcnt++;
-
- // left in last frame
- if (cpi->lf_ref_frame[mb_offset-1] != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = cpi->lfmv[mb_offset -1].as_int;
- mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset -1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = cpi->lf_ref_frame[mb_offset - 1];
- }
- vcnt++;
-
- // right in last frame
- if (cpi->lf_ref_frame[mb_offset +1] != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = cpi->lfmv[mb_offset +1].as_int;
- mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset +1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = cpi->lf_ref_frame[mb_offset +1];
- }
- vcnt++;
-
- // below in last frame
- if (cpi->lf_ref_frame[mb_offset + xd->mode_info_stride +1] != INTRA_FRAME)
- {
- near_mvs[vcnt].as_int = cpi->lfmv[mb_offset + xd->mode_info_stride +1].as_int;
- mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset + xd->mode_info_stride +1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
- near_ref[vcnt] = cpi->lf_ref_frame[mb_offset + xd->mode_info_stride +1];
- }
- vcnt++;
- }
-
- for(i=0; i< vcnt; i++)
- {
- if(near_ref[near_sadidx[i]] != INTRA_FRAME)
- {
- if(here->mbmi.ref_frame == near_ref[near_sadidx[i]])
- {
- mv.as_int = near_mvs[near_sadidx[i]].as_int;
- find = 1;
- if (i < 3)
- *sr = 3;
- else
- *sr = 2;
- break;
- }
- }
- }
-
- if(!find)
- {
- for(i=0; i<vcnt; i++)
- {
- mvx[i] = near_mvs[i].as_mv.row;
- mvy[i] = near_mvs[i].as_mv.col;
- }
-
- insertsortmv(mvx, vcnt);
- insertsortmv(mvy, vcnt);
- mv.as_mv.row = mvx[vcnt/2];
- mv.as_mv.col = mvy[vcnt/2];
-
- find = 1;
- //sr is set to 0 to allow calling function to decide the search range.
- *sr = 0;
- }
- }
-
- /* Set up return values */
- mvp->as_int = mv.as_int;
- vp8_clamp_mv2(mvp, xd);
+ VP8_COMP *cpi,
+ MACROBLOCKD *xd,
+ const MODE_INFO *here,
+ int_mv *mvp,
+ int refframe,
+ int *ref_frame_sign_bias,
+ int *sr,
+ int near_sadidx[]
+) {
+ const MODE_INFO *above = here - xd->mode_info_stride;
+ const MODE_INFO *left = here - 1;
+ const MODE_INFO *aboveleft = above - 1;
+ int_mv near_mvs[8];
+ int near_ref[8];
+ int_mv mv;
+ int vcnt = 0;
+ int find = 0;
+ int mb_offset;
+
+ int mvx[8];
+ int mvy[8];
+ int i;
+
+ mv.as_int = 0;
+
+ if (here->mbmi.ref_frame != INTRA_FRAME) {
+ near_mvs[0].as_int = near_mvs[1].as_int = near_mvs[2].as_int = near_mvs[3].as_int = near_mvs[4].as_int = near_mvs[5].as_int = near_mvs[6].as_int = near_mvs[7].as_int = 0;
+ near_ref[0] = near_ref[1] = near_ref[2] = near_ref[3] = near_ref[4] = near_ref[5] = near_ref[6] = near_ref[7] = 0;
+
+ // read in 3 nearby block's MVs from current frame as prediction candidates.
+ if (above->mbmi.ref_frame != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = above->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = above->mbmi.ref_frame;
+ }
+ vcnt++;
+ if (left->mbmi.ref_frame != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = left->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = left->mbmi.ref_frame;
+ }
+ vcnt++;
+ if (aboveleft->mbmi.ref_frame != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = aboveleft->mbmi.mv.as_int;
+ mv_bias(ref_frame_sign_bias[aboveleft->mbmi.ref_frame], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = aboveleft->mbmi.ref_frame;
+ }
+ vcnt++;
+
+ // read in 5 nearby block's MVs from last frame.
+ if (cpi->common.last_frame_type != KEY_FRAME) {
+ mb_offset = (-xd->mb_to_top_edge / 128 + 1) * (xd->mode_info_stride + 1) + (-xd->mb_to_left_edge / 128 + 1);
+
+ // current in last frame
+ if (cpi->lf_ref_frame[mb_offset] != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = cpi->lfmv[mb_offset].as_int;
+ mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = cpi->lf_ref_frame[mb_offset];
+ }
+ vcnt++;
+
+ // above in last frame
+ if (cpi->lf_ref_frame[mb_offset - xd->mode_info_stride - 1] != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = cpi->lfmv[mb_offset - xd->mode_info_stride - 1].as_int;
+ mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset - xd->mode_info_stride - 1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = cpi->lf_ref_frame[mb_offset - xd->mode_info_stride - 1];
+ }
+ vcnt++;
+
+ // left in last frame
+ if (cpi->lf_ref_frame[mb_offset - 1] != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = cpi->lfmv[mb_offset - 1].as_int;
+ mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset - 1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = cpi->lf_ref_frame[mb_offset - 1];
+ }
+ vcnt++;
+
+ // right in last frame
+ if (cpi->lf_ref_frame[mb_offset + 1] != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = cpi->lfmv[mb_offset + 1].as_int;
+ mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset + 1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = cpi->lf_ref_frame[mb_offset + 1];
+ }
+ vcnt++;
+
+ // below in last frame
+ if (cpi->lf_ref_frame[mb_offset + xd->mode_info_stride + 1] != INTRA_FRAME) {
+ near_mvs[vcnt].as_int = cpi->lfmv[mb_offset + xd->mode_info_stride + 1].as_int;
+ mv_bias(cpi->lf_ref_frame_sign_bias[mb_offset + xd->mode_info_stride + 1], refframe, &near_mvs[vcnt], ref_frame_sign_bias);
+ near_ref[vcnt] = cpi->lf_ref_frame[mb_offset + xd->mode_info_stride + 1];
+ }
+ vcnt++;
+ }
+
+ for (i = 0; i < vcnt; i++) {
+ if (near_ref[near_sadidx[i]] != INTRA_FRAME) {
+ if (here->mbmi.ref_frame == near_ref[near_sadidx[i]]) {
+ mv.as_int = near_mvs[near_sadidx[i]].as_int;
+ find = 1;
+ if (i < 3)
+ *sr = 3;
+ else
+ *sr = 2;
+ break;
+ }
+ }
+ }
+
+ if (!find) {
+ for (i = 0; i < vcnt; i++) {
+ mvx[i] = near_mvs[i].as_mv.row;
+ mvy[i] = near_mvs[i].as_mv.col;
+ }
+
+ insertsortmv(mvx, vcnt);
+ insertsortmv(mvy, vcnt);
+ mv.as_mv.row = mvx[vcnt / 2];
+ mv.as_mv.col = mvy[vcnt / 2];
+
+ find = 1;
+ // sr is set to 0 to allow calling function to decide the search range.
+ *sr = 0;
+ }
+ }
+
+ /* Set up return values */
+ mvp->as_int = mv.as_int;
+ vp8_clamp_mv2(mvp, xd);
}
-void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[])
-{
-
- int near_sad[8] = {0}; // 0-cf above, 1-cf left, 2-cf aboveleft, 3-lf current, 4-lf above, 5-lf left, 6-lf right, 7-lf below
- BLOCK *b = &x->block[0];
- unsigned char *src_y_ptr = *(b->base_src);
-
- //calculate sad for current frame 3 nearby MBs.
- if( xd->mb_to_top_edge==0 && xd->mb_to_left_edge ==0)
- {
- near_sad[0] = near_sad[1] = near_sad[2] = INT_MAX;
- }else if(xd->mb_to_top_edge==0)
- { //only has left MB for sad calculation.
- near_sad[0] = near_sad[2] = INT_MAX;
- near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - 16,xd->dst.y_stride, 0x7fffffff);
- }else if(xd->mb_to_left_edge ==0)
- { //only has left MB for sad calculation.
- near_sad[1] = near_sad[2] = INT_MAX;
- near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride, 0x7fffffff);
- }else
- {
- near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride, 0x7fffffff);
- near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - 16,xd->dst.y_stride, 0x7fffffff);
- near_sad[2] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride *16 -16,xd->dst.y_stride, 0x7fffffff);
- }
-
- if(cpi->common.last_frame_type != KEY_FRAME)
- {
- //calculate sad for last frame 5 nearby MBs.
- unsigned char *pre_y_buffer = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_buffer + recon_yoffset;
- int pre_y_stride = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_stride;
-
- if(xd->mb_to_top_edge==0) near_sad[4] = INT_MAX;
- if(xd->mb_to_left_edge ==0) near_sad[5] = INT_MAX;
- if(xd->mb_to_right_edge ==0) near_sad[6] = INT_MAX;
- if(xd->mb_to_bottom_edge==0) near_sad[7] = INT_MAX;
-
- if(near_sad[4] != INT_MAX)
- near_sad[4] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer - pre_y_stride *16, pre_y_stride, 0x7fffffff);
- if(near_sad[5] != INT_MAX)
- near_sad[5] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer - 16, pre_y_stride, 0x7fffffff);
- near_sad[3] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer, pre_y_stride, 0x7fffffff);
- if(near_sad[6] != INT_MAX)
- near_sad[6] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer + 16, pre_y_stride, 0x7fffffff);
- if(near_sad[7] != INT_MAX)
- near_sad[7] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer + pre_y_stride *16, pre_y_stride, 0x7fffffff);
- }
-
- if(cpi->common.last_frame_type != KEY_FRAME)
- {
- insertsortsad(near_sad, near_sadidx, 8);
- }else
- {
- insertsortsad(near_sad, near_sadidx, 3);
- }
+void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]) {
+
+ int near_sad[8] = {0}; // 0-cf above, 1-cf left, 2-cf aboveleft, 3-lf current, 4-lf above, 5-lf left, 6-lf right, 7-lf below
+ BLOCK *b = &x->block[0];
+ unsigned char *src_y_ptr = *(b->base_src);
+
+ // calculate sad for current frame 3 nearby MBs.
+ if (xd->mb_to_top_edge == 0 && xd->mb_to_left_edge == 0) {
+ near_sad[0] = near_sad[1] = near_sad[2] = INT_MAX;
+ } else if (xd->mb_to_top_edge == 0) {
+ // only has left MB for sad calculation.
+ near_sad[0] = near_sad[2] = INT_MAX;
+ near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - 16, xd->dst.y_stride, 0x7fffffff);
+ } else if (xd->mb_to_left_edge == 0) {
+ // only has left MB for sad calculation.
+ near_sad[1] = near_sad[2] = INT_MAX;
+ near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride * 16, xd->dst.y_stride, 0x7fffffff);
+ } else {
+ near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride * 16, xd->dst.y_stride, 0x7fffffff);
+ near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - 16, xd->dst.y_stride, 0x7fffffff);
+ near_sad[2] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd->dst.y_buffer - xd->dst.y_stride * 16 - 16, xd->dst.y_stride, 0x7fffffff);
+ }
+
+ if (cpi->common.last_frame_type != KEY_FRAME) {
+ // calculate sad for last frame 5 nearby MBs.
+ unsigned char *pre_y_buffer = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_buffer + recon_yoffset;
+ int pre_y_stride = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_stride;
+
+ if (xd->mb_to_top_edge == 0) near_sad[4] = INT_MAX;
+ if (xd->mb_to_left_edge == 0) near_sad[5] = INT_MAX;
+ if (xd->mb_to_right_edge == 0) near_sad[6] = INT_MAX;
+ if (xd->mb_to_bottom_edge == 0) near_sad[7] = INT_MAX;
+
+ if (near_sad[4] != INT_MAX)
+ near_sad[4] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer - pre_y_stride * 16, pre_y_stride, 0x7fffffff);
+ if (near_sad[5] != INT_MAX)
+ near_sad[5] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer - 16, pre_y_stride, 0x7fffffff);
+ near_sad[3] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer, pre_y_stride, 0x7fffffff);
+ if (near_sad[6] != INT_MAX)
+ near_sad[6] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer + 16, pre_y_stride, 0x7fffffff);
+ if (near_sad[7] != INT_MAX)
+ near_sad[7] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre_y_buffer + pre_y_stride * 16, pre_y_stride, 0x7fffffff);
+ }
+
+ if (cpi->common.last_frame_type != KEY_FRAME) {
+ insertsortsad(near_sad, near_sadidx, 8);
+ } else {
+ insertsortsad(near_sad, near_sadidx, 3);
+ }
}
void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x,
- int_mv *best_ref_mv, int_mv *second_best_ref_mv)
-{
- if (x->e_mbd.mode_info_context->mbmi.mode == SPLITMV)
- {
- int i;
+ int_mv *best_ref_mv, int_mv *second_best_ref_mv) {
+ if (x->e_mbd.mode_info_context->mbmi.mode == SPLITMV) {
+ int i;
- for (i = 0; i < x->partition_info->count; i++)
- {
- if (x->partition_info->bmi[i].mode == NEW4X4)
- {
+ for (i = 0; i < x->partition_info->count; i++) {
+ if (x->partition_info->bmi[i].mode == NEW4X4) {
#if CONFIG_HIGH_PRECISION_MV
- if (x->e_mbd.allow_high_precision_mv)
- {
- cpi->MVcount_hp[0][mv_max_hp+(x->partition_info->bmi[i].mv.as_mv.row
- - best_ref_mv->as_mv.row)]++;
- cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].mv.as_mv.col
- - best_ref_mv->as_mv.col)]++;
+ if (x->e_mbd.allow_high_precision_mv) {
+ cpi->MVcount_hp[0][mv_max_hp + (x->partition_info->bmi[i].mv.as_mv.row
+ - best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp + (x->partition_info->bmi[i].mv.as_mv.col
+ - best_ref_mv->as_mv.col)]++;
#if CONFIG_ADAPTIVE_ENTROPY
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- cpi->MVcount_hp[0][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row)]++;
- cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col)]++;
- }
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ cpi->MVcount_hp[0][mv_max_hp + (x->partition_info->bmi[i].second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp + (x->partition_info->bmi[i].second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col)]++;
+ }
#endif
- }
- else
+ } else
#endif
- {
- cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].mv.as_mv.row
- - best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col
- - best_ref_mv->as_mv.col) >> 1)]++;
+ {
+ cpi->MVcount[0][mv_max + ((x->partition_info->bmi[i].mv.as_mv.row
+ - best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max + ((x->partition_info->bmi[i].mv.as_mv.col
+ - best_ref_mv->as_mv.col) >> 1)]++;
#if CONFIG_ADAPTIVE_ENTROPY
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col) >> 1)]++;
- }
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ cpi->MVcount[0][mv_max + ((x->partition_info->bmi[i].second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max + ((x->partition_info->bmi[i].second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col) >> 1)]++;
+ }
#endif
- }
- }
}
+ }
}
- else if (x->e_mbd.mode_info_context->mbmi.mode == NEWMV)
- {
+ } else if (x->e_mbd.mode_info_context->mbmi.mode == NEWMV) {
#if CONFIG_HIGH_PRECISION_MV
- if (x->e_mbd.allow_high_precision_mv)
- {
- cpi->MVcount_hp[0][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
- - best_ref_mv->as_mv.row)]++;
- cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
- - best_ref_mv->as_mv.col)]++;
+ if (x->e_mbd.allow_high_precision_mv) {
+ cpi->MVcount_hp[0][mv_max_hp + (x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
+ - best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp + (x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
+ - best_ref_mv->as_mv.col)]++;
#if CONFIG_ADAPTIVE_ENTROPY
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- cpi->MVcount_hp[0][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row)]++;
- cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col)]++;
- }
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ cpi->MVcount_hp[0][mv_max_hp + (x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp + (x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col)]++;
+ }
#endif
- }
- else
+ } else
#endif
- {
- cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
- - best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
- - best_ref_mv->as_mv.col) >> 1)]++;
+ {
+ cpi->MVcount[0][mv_max + ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
+ - best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max + ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
+ - best_ref_mv->as_mv.col) >> 1)]++;
#if CONFIG_ADAPTIVE_ENTROPY
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
- - second_best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
- - second_best_ref_mv->as_mv.col) >> 1)]++;
- }
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ cpi->MVcount[0][mv_max + ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max + ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col) >> 1)]++;
+ }
#endif
- }
}
+ }
}
-static void set_i8x8_block_modes(MACROBLOCK *x, int modes[2][4])
-{
- int i;
- MACROBLOCKD *xd = &x->e_mbd;
- for(i=0;i<4;i++)
- {
- int ib = vp8_i8x8_block[i];
- x->e_mbd.mode_info_context->bmi[ib+0].as_mode.first= modes[0][i];
- x->e_mbd.mode_info_context->bmi[ib+1].as_mode.first= modes[0][i];
- x->e_mbd.mode_info_context->bmi[ib+4].as_mode.first= modes[0][i];
- x->e_mbd.mode_info_context->bmi[ib+5].as_mode.first= modes[0][i];
+static void set_i8x8_block_modes(MACROBLOCK *x, int modes[2][4]) {
+ int i;
+ MACROBLOCKD *xd = &x->e_mbd;
+ for (i = 0; i < 4; i++) {
+ int ib = vp8_i8x8_block[i];
+ x->e_mbd.mode_info_context->bmi[ib + 0].as_mode.first = modes[0][i];
+ x->e_mbd.mode_info_context->bmi[ib + 1].as_mode.first = modes[0][i];
+ x->e_mbd.mode_info_context->bmi[ib + 4].as_mode.first = modes[0][i];
+ x->e_mbd.mode_info_context->bmi[ib + 5].as_mode.first = modes[0][i];
#if CONFIG_COMP_INTRA_PRED
- x->e_mbd.mode_info_context->bmi[ib+0].as_mode.second= modes[1][i];
- x->e_mbd.mode_info_context->bmi[ib+1].as_mode.second= modes[1][i];
- x->e_mbd.mode_info_context->bmi[ib+4].as_mode.second= modes[1][i];
- x->e_mbd.mode_info_context->bmi[ib+5].as_mode.second= modes[1][i];
-#endif
- //printf("%d,%d,%d,%d %d,%d,%d,%d\n",
- // modes[0][0], modes[0][1], modes[0][2], modes[0][3],
- // modes[1][0], modes[1][1], modes[1][2], modes[1][3]);
- }
-
- for (i = 0; i < 16; i++)
- {
- xd->block[i].bmi = xd->mode_info_context->bmi[i];
- }
+ x->e_mbd.mode_info_context->bmi[ib + 0].as_mode.second = modes[1][i];
+ x->e_mbd.mode_info_context->bmi[ib + 1].as_mode.second = modes[1][i];
+ x->e_mbd.mode_info_context->bmi[ib + 4].as_mode.second = modes[1][i];
+ x->e_mbd.mode_info_context->bmi[ib + 5].as_mode.second = modes[1][i];
+#endif
+ // printf("%d,%d,%d,%d %d,%d,%d,%d\n",
+ // modes[0][0], modes[0][1], modes[0][2], modes[0][3],
+ // modes[1][0], modes[1][1], modes[1][2], modes[1][3]);
+ }
+
+ for (i = 0; i < 16; i++) {
+ xd->block[i].bmi = xd->mode_info_context->bmi[i];
+ }
}
-extern void calc_ref_probs( int * count, vp8_prob * probs );
-static void estimate_curframe_refprobs(VP8_COMP *cpi, vp8_prob mod_refprobs[3], int pred_ref)
-{
- int norm_cnt[MAX_REF_FRAMES];
- const int *const rfct = cpi->count_mb_ref_frame_usage;
- int intra_count = rfct[INTRA_FRAME];
- int last_count = rfct[LAST_FRAME];
- int gf_count = rfct[GOLDEN_FRAME];
- int arf_count = rfct[ALTREF_FRAME];
-
- // Work out modified reference frame probabilities to use where prediction
- // of the reference frame fails
- if (pred_ref == INTRA_FRAME)
- {
- norm_cnt[0] = 0;
- norm_cnt[1] = last_count;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, mod_refprobs );
- mod_refprobs[0] = 0; // This branch implicit
- }
- else if (pred_ref == LAST_FRAME)
- {
- norm_cnt[0] = intra_count;
- norm_cnt[1] = 0;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, mod_refprobs);
- mod_refprobs[1] = 0; // This branch implicit
- }
- else if (pred_ref == GOLDEN_FRAME)
- {
- norm_cnt[0] = intra_count;
- norm_cnt[1] = last_count;
- norm_cnt[2] = 0;
- norm_cnt[3] = arf_count;
- calc_ref_probs( norm_cnt, mod_refprobs );
- mod_refprobs[2] = 0; // This branch implicit
- }
- else
- {
- norm_cnt[0] = intra_count;
- norm_cnt[1] = last_count;
- norm_cnt[2] = gf_count;
- norm_cnt[3] = 0;
- calc_ref_probs( norm_cnt, mod_refprobs );
- mod_refprobs[2] = 0; // This branch implicit
- }
+extern void calc_ref_probs(int *count, vp8_prob *probs);
+static void estimate_curframe_refprobs(VP8_COMP *cpi, vp8_prob mod_refprobs[3], int pred_ref) {
+ int norm_cnt[MAX_REF_FRAMES];
+ const int *const rfct = cpi->count_mb_ref_frame_usage;
+ int intra_count = rfct[INTRA_FRAME];
+ int last_count = rfct[LAST_FRAME];
+ int gf_count = rfct[GOLDEN_FRAME];
+ int arf_count = rfct[ALTREF_FRAME];
+
+ // Work out modified reference frame probabilities to use where prediction
+ // of the reference frame fails
+ if (pred_ref == INTRA_FRAME) {
+ norm_cnt[0] = 0;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, mod_refprobs);
+ mod_refprobs[0] = 0; // This branch implicit
+ } else if (pred_ref == LAST_FRAME) {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = 0;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, mod_refprobs);
+ mod_refprobs[1] = 0; // This branch implicit
+ } else if (pred_ref == GOLDEN_FRAME) {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = 0;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs(norm_cnt, mod_refprobs);
+ mod_refprobs[2] = 0; // This branch implicit
+ } else {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = 0;
+ calc_ref_probs(norm_cnt, mod_refprobs);
+ mod_refprobs[2] = 0; // This branch implicit
+ }
}
-static __inline unsigned weighted_cost(vp8_prob *tab0, vp8_prob *tab1, int idx, int val, int weight)
-{
- unsigned cost0 = tab0[idx] ? vp8_cost_bit(tab0[idx], val) : 0;
- unsigned cost1 = tab1[idx] ? vp8_cost_bit(tab1[idx], val) : 0;
- // weight is 16-bit fixed point, so this basically calculates:
- // 0.5 + weight * cost1 + (1.0 - weight) * cost0
- return (0x8000 + weight * cost1 + (0x10000 - weight) * cost0) >> 16;
+static __inline unsigned weighted_cost(vp8_prob *tab0, vp8_prob *tab1, int idx, int val, int weight) {
+ unsigned cost0 = tab0[idx] ? vp8_cost_bit(tab0[idx], val) : 0;
+ unsigned cost1 = tab1[idx] ? vp8_cost_bit(tab1[idx], val) : 0;
+ // weight is 16-bit fixed point, so this basically calculates:
+ // 0.5 + weight * cost1 + (1.0 - weight) * cost0
+ return (0x8000 + weight * cost1 + (0x10000 - weight) * cost0) >> 16;
}
-static void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, int segment_id, unsigned int * ref_costs )
-{
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- vp8_prob * mod_refprobs;
-
- unsigned int cost;
- int pred_ref ;
- int pred_flag;
- int pred_ctx ;
- int i;
- int tot_count;
-
- vp8_prob pred_prob, new_pred_prob;
- int seg_ref_active;
- int seg_ref_count = 0;
- seg_ref_active = segfeature_active( xd,
- segment_id,
- SEG_LVL_REF_FRAME );
-
- if ( seg_ref_active )
- {
- seg_ref_count = check_segref( xd, segment_id, INTRA_FRAME ) +
- check_segref( xd, segment_id, LAST_FRAME ) +
- check_segref( xd, segment_id, GOLDEN_FRAME ) +
- check_segref( xd, segment_id, ALTREF_FRAME );
- }
-
- // Get the predicted reference for this mb
- pred_ref = get_pred_ref( cm, xd );
-
- // Get the context probability for the prediction flag (based on last frame)
- pred_prob = get_pred_prob( cm, xd, PRED_REF );
-
- // Predict probability for current frame based on stats so far
- pred_ctx = get_pred_context(cm, xd, PRED_REF);
- tot_count = cpi->ref_pred_count[pred_ctx][0] + cpi->ref_pred_count[pred_ctx][1];
- if ( tot_count )
- {
- new_pred_prob =
- ( cpi->ref_pred_count[pred_ctx][0] * 255 + (tot_count >> 1)) / tot_count;
- new_pred_prob += !new_pred_prob;
- }
- else
- new_pred_prob = 128;
-
- // Get the set of probabilities to use if prediction fails
- mod_refprobs = cm->mod_refprobs[pred_ref];
-
- // For each possible selected reference frame work out a cost.
- for ( i = 0; i < MAX_REF_FRAMES; i++ )
- {
- if (seg_ref_active && seg_ref_count == 1)
- {
- cost = 0;
- }
- else
- {
- pred_flag = (i == pred_ref);
-
- // Get the prediction for the current mb
- cost = weighted_cost(&pred_prob, &new_pred_prob, 0,
- pred_flag, cpi->seg0_progress);
- if (cost > 1024) cost = 768; // i.e. account for 4 bits max.
-
- // for incorrectly predicted cases
- if ( ! pred_flag )
- {
- vp8_prob curframe_mod_refprobs[3];
-
- if (cpi->seg0_progress)
- {
- estimate_curframe_refprobs(cpi, curframe_mod_refprobs, pred_ref);
- }
- else
- {
- vpx_memset(curframe_mod_refprobs, 0, sizeof(curframe_mod_refprobs));
- }
-
- cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 0,
- (i != INTRA_FRAME), cpi->seg0_progress);
- if (i != INTRA_FRAME)
- {
- cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 1,
- (i != LAST_FRAME), cpi->seg0_progress);
- if (i != LAST_FRAME)
- {
- cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 2,
- (i != GOLDEN_FRAME), cpi->seg0_progress);
- }
- }
- }
- }
-
- ref_costs[i] = cost;
- }
+static void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, int segment_id, unsigned int *ref_costs) {
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ vp8_prob *mod_refprobs;
+
+ unsigned int cost;
+ int pred_ref;
+ int pred_flag;
+ int pred_ctx;
+ int i;
+ int tot_count;
+
+ vp8_prob pred_prob, new_pred_prob;
+ int seg_ref_active;
+ int seg_ref_count = 0;
+ seg_ref_active = segfeature_active(xd,
+ segment_id,
+ SEG_LVL_REF_FRAME);
+
+ if (seg_ref_active) {
+ seg_ref_count = check_segref(xd, segment_id, INTRA_FRAME) +
+ check_segref(xd, segment_id, LAST_FRAME) +
+ check_segref(xd, segment_id, GOLDEN_FRAME) +
+ check_segref(xd, segment_id, ALTREF_FRAME);
+ }
+
+ // Get the predicted reference for this mb
+ pred_ref = get_pred_ref(cm, xd);
+
+ // Get the context probability for the prediction flag (based on last frame)
+ pred_prob = get_pred_prob(cm, xd, PRED_REF);
+
+ // Predict probability for current frame based on stats so far
+ pred_ctx = get_pred_context(cm, xd, PRED_REF);
+ tot_count = cpi->ref_pred_count[pred_ctx][0] + cpi->ref_pred_count[pred_ctx][1];
+ if (tot_count) {
+ new_pred_prob =
+ (cpi->ref_pred_count[pred_ctx][0] * 255 + (tot_count >> 1)) / tot_count;
+ new_pred_prob += !new_pred_prob;
+ } else
+ new_pred_prob = 128;
+
+ // Get the set of probabilities to use if prediction fails
+ mod_refprobs = cm->mod_refprobs[pred_ref];
+
+ // For each possible selected reference frame work out a cost.
+ for (i = 0; i < MAX_REF_FRAMES; i++) {
+ if (seg_ref_active && seg_ref_count == 1) {
+ cost = 0;
+ } else {
+ pred_flag = (i == pred_ref);
+
+ // Get the prediction for the current mb
+ cost = weighted_cost(&pred_prob, &new_pred_prob, 0,
+ pred_flag, cpi->seg0_progress);
+ if (cost > 1024) cost = 768; // i.e. account for 4 bits max.
+
+ // for incorrectly predicted cases
+ if (! pred_flag) {
+ vp8_prob curframe_mod_refprobs[3];
+
+ if (cpi->seg0_progress) {
+ estimate_curframe_refprobs(cpi, curframe_mod_refprobs, pred_ref);
+ } else {
+ vpx_memset(curframe_mod_refprobs, 0, sizeof(curframe_mod_refprobs));
+ }
+
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 0,
+ (i != INTRA_FRAME), cpi->seg0_progress);
+ if (i != INTRA_FRAME) {
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 1,
+ (i != LAST_FRAME), cpi->seg0_progress);
+ if (i != LAST_FRAME) {
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 2,
+ (i != GOLDEN_FRAME), cpi->seg0_progress);
+ }
+ }
+ }
+ }
+
+ ref_costs[i] = cost;
+ }
}
-static void store_coding_context (MACROBLOCK *x, int mb_index,
- int mode_index,
- PARTITION_INFO *partition,
- int_mv *ref_mv,
- int_mv *second_ref_mv)
-{
- MACROBLOCKD *xd = &x->e_mbd;
-
- // Take a snapshot of the coding context so it can be
- // restored if we decide to encode this way
- x->mb_context[mb_index].best_mode_index = mode_index;
- vpx_memcpy(&x->mb_context[mb_index].mic, xd->mode_info_context,
- sizeof(MODE_INFO));
- vpx_memcpy(&x->mb_context[mb_index].partition_info, partition,
- sizeof(PARTITION_INFO));
- x->mb_context[mb_index].best_ref_mv.as_int = ref_mv->as_int;
- x->mb_context[mb_index].second_best_ref_mv.as_int = second_ref_mv->as_int;
-
- //x->mb_context[mb_index].rddiv = x->rddiv;
- //x->mb_context[mb_index].rdmult = x->rdmult;
+static void store_coding_context(MACROBLOCK *x, int mb_index,
+ int mode_index,
+ PARTITION_INFO *partition,
+ int_mv *ref_mv,
+ int_mv *second_ref_mv) {
+ MACROBLOCKD *xd = &x->e_mbd;
+
+ // Take a snapshot of the coding context so it can be
+ // restored if we decide to encode this way
+ x->mb_context[mb_index].best_mode_index = mode_index;
+ vpx_memcpy(&x->mb_context[mb_index].mic, xd->mode_info_context,
+ sizeof(MODE_INFO));
+ vpx_memcpy(&x->mb_context[mb_index].partition_info, partition,
+ sizeof(PARTITION_INFO));
+ x->mb_context[mb_index].best_ref_mv.as_int = ref_mv->as_int;
+ x->mb_context[mb_index].second_best_ref_mv.as_int = second_ref_mv->as_int;
+
+ // x->mb_context[mb_index].rddiv = x->rddiv;
+ // x->mb_context[mb_index].rdmult = x->rdmult;
}
void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset,
int *returnrate, int *returndistortion, int *returnintra,
int *best_single_rd_diff, int *best_comp_rd_diff,
- int *best_hybrid_rd_diff)
-{
- VP8_COMMON *cm = &cpi->common;
- BLOCK *b = &x->block[0];
- BLOCKD *d = &x->e_mbd.block[0];
- MACROBLOCKD *xd = &x->e_mbd;
- union b_mode_info best_bmodes[16];
- MB_MODE_INFO best_mbmode;
- PARTITION_INFO best_partition;
- int_mv best_ref_mv, second_best_ref_mv;
- int_mv mode_mv[MB_MODE_COUNT];
- MB_PREDICTION_MODE this_mode;
- int num00;
- int best_mode_index = 0;
- int mode8x8[2][4];
- unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
- int mb_index = xd->mb_index;
-
- int i;
- int mode_index;
- int mdcounts[4];
- int rate;
- int distortion;
- int best_rd = INT_MAX;
- int best_intra_rd = INT_MAX;
- int best_comp_rd = INT_MAX;
- int best_single_rd = INT_MAX;
- int best_hybrid_rd = INT_MAX;
+ int *best_hybrid_rd_diff) {
+ VP8_COMMON *cm = &cpi->common;
+ BLOCK *b = &x->block[0];
+ BLOCKD *d = &x->e_mbd.block[0];
+ MACROBLOCKD *xd = &x->e_mbd;
+ union b_mode_info best_bmodes[16];
+ MB_MODE_INFO best_mbmode;
+ PARTITION_INFO best_partition;
+ int_mv best_ref_mv, second_best_ref_mv;
+ int_mv mode_mv[MB_MODE_COUNT];
+ MB_PREDICTION_MODE this_mode;
+ int num00;
+ int best_mode_index = 0;
+ int mode8x8[2][4];
+ unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
+ int mb_index = xd->mb_index;
+
+ int i;
+ int mode_index;
+ int mdcounts[4];
+ int rate;
+ int distortion;
+ int best_rd = INT_MAX;
+ int best_intra_rd = INT_MAX;
+ int best_comp_rd = INT_MAX;
+ int best_single_rd = INT_MAX;
+ int best_hybrid_rd = INT_MAX;
#if CONFIG_PRED_FILTER
- int best_overall_rd = INT_MAX;
-#endif
- int rate2, distortion2;
- int uv_intra_rate, uv_intra_distortion, uv_intra_rate_tokenonly;
- int uv_intra_skippable = 0;
- int uv_intra_rate_8x8 = 0, uv_intra_distortion_8x8 = 0, uv_intra_rate_tokenonly_8x8 = 0;
- int uv_intra_skippable_8x8=0;
- int rate_y, UNINITIALIZED_IS_SAFE(rate_uv);
- int distortion_uv;
- int best_yrd = INT_MAX;
+ int best_overall_rd = INT_MAX;
+#endif
+ int rate2, distortion2;
+ int uv_intra_rate, uv_intra_distortion, uv_intra_rate_tokenonly;
+ int uv_intra_skippable = 0;
+ int uv_intra_rate_8x8 = 0, uv_intra_distortion_8x8 = 0, uv_intra_rate_tokenonly_8x8 = 0;
+ int uv_intra_skippable_8x8 = 0;
+ int rate_y, UNINITIALIZED_IS_SAFE(rate_uv);
+ int distortion_uv;
+ int best_yrd = INT_MAX;
#if CONFIG_PRED_FILTER
- int best_filter_state;
+ int best_filter_state;
#endif
- //int all_rds[MAX_MODES]; // Experimental debug code.
- //int all_rates[MAX_MODES];
- //int all_dist[MAX_MODES];
- //int intermodecost[MAX_MODES];
-
- MB_PREDICTION_MODE uv_intra_mode;
- MB_PREDICTION_MODE uv_intra_mode_8x8 = 0;
-
- int_mv mvp;
- int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7};
- int saddone=0;
- int sr=0; //search range got from mv_pred(). It uses step_param levels. (0-7)
-
- int_mv frame_nearest_mv[4];
- int_mv frame_near_mv[4];
- int_mv frame_best_ref_mv[4];
- int_mv mc_search_result[4];
- int frame_mdcounts[4][4];
- unsigned char *y_buffer[4];
- unsigned char *u_buffer[4];
- unsigned char *v_buffer[4];
-
- unsigned int ref_costs[MAX_REF_FRAMES];
- int_mv seg_mvs[BLOCK_MAX_SEGMENTS - 1][16 /* n_blocks */][MAX_REF_FRAMES - 1];
-
- vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
- vpx_memset(&best_bmodes, 0, sizeof(best_bmodes));
- vpx_memset(&x->mb_context[mb_index], 0, sizeof(PICK_MODE_CONTEXT));
-
- for (i = 0; i < 4; i++)
- {
- mc_search_result[i].as_int = INVALID_MV;
- }
-
- for (i = 0; i < BLOCK_MAX_SEGMENTS - 1; i++)
- {
- int j;
-
- for (j = 0; j < 16; j++)
- {
- int k;
-
- for (k = 0; k < MAX_REF_FRAMES - 1; k++)
- {
- seg_mvs[i][j][k].as_int = INVALID_MV;
- }
- }
- }
-
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
- {
- YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
-
- vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
- x->e_mbd.prev_mode_info_context,
- &frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME],
- &frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
+ // int all_rds[MAX_MODES]; // Experimental debug code.
+ // int all_rates[MAX_MODES];
+ // int all_dist[MAX_MODES];
+ // int intermodecost[MAX_MODES];
- y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
- u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset;
- v_buffer[LAST_FRAME] = lst_yv12->v_buffer + recon_uvoffset;
- }
-
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
- {
- YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
-
- vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
- x->e_mbd.prev_mode_info_context,
- &frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME],
- &frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
-
- y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
- u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset;
- v_buffer[GOLDEN_FRAME] = gld_yv12->v_buffer + recon_uvoffset;
- }
-
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
- {
- YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
-
- vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
- x->e_mbd.prev_mode_info_context,
- &frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME],
- &frame_best_ref_mv[ALTREF_FRAME], frame_mdcounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
-
- y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
- u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset;
- v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset;
- }
+ MB_PREDICTION_MODE uv_intra_mode;
+ MB_PREDICTION_MODE uv_intra_mode_8x8 = 0;
- *returnintra = INT_MAX;
-
- x->skip = 0;
-
- vpx_memset(mode_mv, 0, sizeof(mode_mv));
-
- x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-
- /* Initialize zbin mode boost for uv costing */
- cpi->zbin_mode_boost = 0;
- vp8_update_zbin_extra(cpi, x);
-
- rd_pick_intra_mbuv_mode(cpi, x, &uv_intra_rate,
- &uv_intra_rate_tokenonly, &uv_intra_distortion);
- uv_intra_mode = x->e_mbd.mode_info_context->mbmi.uv_mode;
- uv_intra_skippable = mbuv_is_skippable(&x->e_mbd);
+ int_mv mvp;
+ int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+ int saddone = 0;
+ int sr = 0; // search range got from mv_pred(). It uses step_param levels. (0-7)
+
+ int_mv frame_nearest_mv[4];
+ int_mv frame_near_mv[4];
+ int_mv frame_best_ref_mv[4];
+ int_mv mc_search_result[4];
+ int frame_mdcounts[4][4];
+ unsigned char *y_buffer[4];
+ unsigned char *u_buffer[4];
+ unsigned char *v_buffer[4];
+
+ unsigned int ref_costs[MAX_REF_FRAMES];
+ int_mv seg_mvs[BLOCK_MAX_SEGMENTS - 1][16 /* n_blocks */][MAX_REF_FRAMES - 1];
+
+ vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
+ vpx_memset(&best_bmodes, 0, sizeof(best_bmodes));
+ vpx_memset(&x->mb_context[mb_index], 0, sizeof(PICK_MODE_CONTEXT));
+
+ for (i = 0; i < 4; i++) {
+ mc_search_result[i].as_int = INVALID_MV;
+ }
+
+ for (i = 0; i < BLOCK_MAX_SEGMENTS - 1; i++) {
+ int j;
+
+ for (j = 0; j < 16; j++) {
+ int k;
+
+ for (k = 0; k < MAX_REF_FRAMES - 1; k++) {
+ seg_mvs[i][j][k].as_int = INVALID_MV;
+ }
+ }
+ }
+
+ if (cpi->ref_frame_flags & VP8_LAST_FLAG) {
+ YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
+
+ vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
+ x->e_mbd.prev_mode_info_context,
+ &frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME],
+ &frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
+
+ y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
+ u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset;
+ v_buffer[LAST_FRAME] = lst_yv12->v_buffer + recon_uvoffset;
+ }
+
+ if (cpi->ref_frame_flags & VP8_GOLD_FLAG) {
+ YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
+
+ vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
+ x->e_mbd.prev_mode_info_context,
+ &frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME],
+ &frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
+
+ y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
+ u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset;
+ v_buffer[GOLDEN_FRAME] = gld_yv12->v_buffer + recon_uvoffset;
+ }
+
+ if (cpi->ref_frame_flags & VP8_ALT_FLAG) {
+ YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
+
+ vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
+ x->e_mbd.prev_mode_info_context,
+ &frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME],
+ &frame_best_ref_mv[ALTREF_FRAME], frame_mdcounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
+
+ y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
+ u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset;
+ v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset;
+ }
+
+ *returnintra = INT_MAX;
+
+ x->skip = 0;
+
+ vpx_memset(mode_mv, 0, sizeof(mode_mv));
+
+ x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
+
+ /* Initialize zbin mode boost for uv costing */
+ cpi->zbin_mode_boost = 0;
+ vp8_update_zbin_extra(cpi, x);
+
+ rd_pick_intra_mbuv_mode(cpi, x, &uv_intra_rate,
+ &uv_intra_rate_tokenonly, &uv_intra_distortion);
+ uv_intra_mode = x->e_mbd.mode_info_context->mbmi.uv_mode;
+ uv_intra_skippable = mbuv_is_skippable(&x->e_mbd);
+
+ /* rough estimate for now */
+ if (cpi->common.txfm_mode == ALLOW_8X8) {
+ rd_pick_intra_mbuv_mode_8x8(cpi, x, &uv_intra_rate_8x8,
+ &uv_intra_rate_tokenonly_8x8,
+ &uv_intra_distortion_8x8);
+ uv_intra_mode_8x8 = x->e_mbd.mode_info_context->mbmi.uv_mode;
+ uv_intra_skippable_8x8 = mbuv_is_skippable_8x8(&x->e_mbd);
+ }
+
+ // Get estimates of reference frame costs for each reference frame
+ // that depend on the current prediction etc.
+ vp8_estimate_ref_frame_costs(cpi, segment_id, ref_costs);
+
+ for (mode_index = 0; mode_index < MAX_MODES; mode_index++) {
+ int this_rd = INT_MAX;
+ int disable_skip = 0;
+ int other_cost = 0;
+ int compmode_cost = 0;
+ int mode_excluded = 0;
- /* rough estimate for now */
- if(cpi->common.txfm_mode==ALLOW_8X8)
- {
- rd_pick_intra_mbuv_mode_8x8(cpi, x, &uv_intra_rate_8x8,
- &uv_intra_rate_tokenonly_8x8,
- &uv_intra_distortion_8x8);
- uv_intra_mode_8x8 = x->e_mbd.mode_info_context->mbmi.uv_mode;
- uv_intra_skippable_8x8 = mbuv_is_skippable_8x8(&x->e_mbd);
+ // Test best rd so far against threshold for trying this mode.
+ if (best_rd <= cpi->rd_threshes[mode_index]) {
+ continue;
}
-
- // Get estimates of reference frame costs for each reference frame
- // that depend on the current prediction etc.
- vp8_estimate_ref_frame_costs( cpi, segment_id, ref_costs );
-
- for (mode_index = 0; mode_index < MAX_MODES; mode_index++)
- {
- int this_rd = INT_MAX;
- int disable_skip = 0;
- int other_cost = 0;
- int compmode_cost = 0;
- int mode_excluded = 0;
-
- // Test best rd so far against threshold for trying this mode.
- if (best_rd <= cpi->rd_threshes[mode_index])
- {
- continue;
- }
-
- // These variables hold are rolling total cost and distortion for this mode
- rate2 = 0;
- distortion2 = 0;
- rate_y = 0;
- rate_uv =0;
-
- this_mode = vp8_mode_order[mode_index].mode;
- xd->mode_info_context->mbmi.mode = this_mode;
- xd->mode_info_context->mbmi.uv_mode = DC_PRED;
- xd->mode_info_context->mbmi.ref_frame =
- vp8_mode_order[mode_index].ref_frame;
- xd->mode_info_context->mbmi.second_ref_frame =
- vp8_mode_order[mode_index].second_ref_frame;
+
+ // These variables hold are rolling total cost and distortion for this mode
+ rate2 = 0;
+ distortion2 = 0;
+ rate_y = 0;
+ rate_uv = 0;
+
+ this_mode = vp8_mode_order[mode_index].mode;
+ xd->mode_info_context->mbmi.mode = this_mode;
+ xd->mode_info_context->mbmi.uv_mode = DC_PRED;
+ xd->mode_info_context->mbmi.ref_frame =
+ vp8_mode_order[mode_index].ref_frame;
+ xd->mode_info_context->mbmi.second_ref_frame =
+ vp8_mode_order[mode_index].second_ref_frame;
#if CONFIG_PRED_FILTER
- xd->mode_info_context->mbmi.pred_filter_enabled = 0;
+ xd->mode_info_context->mbmi.pred_filter_enabled = 0;
#endif
#if CONFIG_COMP_INTRA_PRED
- xd->mode_info_context->mbmi.second_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
- xd->mode_info_context->mbmi.second_uv_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
-#endif
-
- // If the segment reference frame feature is enabled....
- // then do nothing if the current ref frame is not allowed..
- if ( segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
- !check_segref( xd, segment_id,
- xd->mode_info_context->mbmi.ref_frame ) )
- {
- continue;
- }
- // If the segment mode feature is enabled....
- // then do nothing if the current mode is not allowed..
- else if ( segfeature_active( xd, segment_id, SEG_LVL_MODE ) &&
- ( this_mode !=
- get_segdata( xd, segment_id, SEG_LVL_MODE ) ) )
- {
- continue;
- }
-
- // Disable this drop out case if either the mode or ref frame
- // segment level feature is enabled for this segment. This is to
- // prevent the possibility that the we end up unable to pick any mode.
- else if ( !segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
- !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
- {
- // Only consider ZEROMV/ALTREF_FRAME for alt ref frame,
- // unless ARNR filtering is enabled in which case we want
- // an unfiltered alternative
- if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0))
- {
- if (this_mode != ZEROMV ||
- x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME)
- {
- continue;
- }
- }
- }
-
- /* everything but intra */
- if (x->e_mbd.mode_info_context->mbmi.ref_frame)
- {
- int ref = x->e_mbd.mode_info_context->mbmi.ref_frame;
-
- x->e_mbd.pre.y_buffer = y_buffer[ref];
- x->e_mbd.pre.u_buffer = u_buffer[ref];
- x->e_mbd.pre.v_buffer = v_buffer[ref];
- mode_mv[NEARESTMV] = frame_nearest_mv[ref];
- mode_mv[NEARMV] = frame_near_mv[ref];
- best_ref_mv = frame_best_ref_mv[ref];
- vpx_memcpy(mdcounts, frame_mdcounts[ref], sizeof(mdcounts));
- }
-
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- {
- int ref = x->e_mbd.mode_info_context->mbmi.second_ref_frame;
-
- x->e_mbd.second_pre.y_buffer = y_buffer[ref];
- x->e_mbd.second_pre.u_buffer = u_buffer[ref];
- x->e_mbd.second_pre.v_buffer = v_buffer[ref];
- second_best_ref_mv = frame_best_ref_mv[ref];
- }
-
- // Experimental code. Special case for gf and arf zeromv modes.
- // Increase zbin size to suppress noise
- if (cpi->zbin_mode_boost_enabled)
- {
- if ( vp8_mode_order[mode_index].ref_frame == INTRA_FRAME )
- cpi->zbin_mode_boost = 0;
- else
- {
- if (vp8_mode_order[mode_index].mode == ZEROMV)
- {
- if (vp8_mode_order[mode_index].ref_frame != LAST_FRAME)
- cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
- else
- cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
- }
- else if (vp8_mode_order[mode_index].mode == SPLITMV)
- cpi->zbin_mode_boost = 0;
- else
- cpi->zbin_mode_boost = MV_ZBIN_BOOST;
- }
+ xd->mode_info_context->mbmi.second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
+ xd->mode_info_context->mbmi.second_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
+#endif
+
+ // If the segment reference frame feature is enabled....
+ // then do nothing if the current ref frame is not allowed..
+ if (segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME) &&
+ !check_segref(xd, segment_id,
+ xd->mode_info_context->mbmi.ref_frame)) {
+ continue;
+ }
+ // If the segment mode feature is enabled....
+ // then do nothing if the current mode is not allowed..
+ else if (segfeature_active(xd, segment_id, SEG_LVL_MODE) &&
+ (this_mode !=
+ get_segdata(xd, segment_id, SEG_LVL_MODE))) {
+ continue;
+ }
+
+ // Disable this drop out case if either the mode or ref frame
+ // segment level feature is enabled for this segment. This is to
+ // prevent the possibility that the we end up unable to pick any mode.
+ else if (!segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME) &&
+ !segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
+ // Only consider ZEROMV/ALTREF_FRAME for alt ref frame,
+ // unless ARNR filtering is enabled in which case we want
+ // an unfiltered alternative
+ if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) {
+ if (this_mode != ZEROMV ||
+ x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME) {
+ continue;
+ }
+ }
+ }
+
+ /* everything but intra */
+ if (x->e_mbd.mode_info_context->mbmi.ref_frame) {
+ int ref = x->e_mbd.mode_info_context->mbmi.ref_frame;
+
+ x->e_mbd.pre.y_buffer = y_buffer[ref];
+ x->e_mbd.pre.u_buffer = u_buffer[ref];
+ x->e_mbd.pre.v_buffer = v_buffer[ref];
+ mode_mv[NEARESTMV] = frame_nearest_mv[ref];
+ mode_mv[NEARMV] = frame_near_mv[ref];
+ best_ref_mv = frame_best_ref_mv[ref];
+ vpx_memcpy(mdcounts, frame_mdcounts[ref], sizeof(mdcounts));
+ }
+
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
+ int ref = x->e_mbd.mode_info_context->mbmi.second_ref_frame;
+
+ x->e_mbd.second_pre.y_buffer = y_buffer[ref];
+ x->e_mbd.second_pre.u_buffer = u_buffer[ref];
+ x->e_mbd.second_pre.v_buffer = v_buffer[ref];
+ second_best_ref_mv = frame_best_ref_mv[ref];
+ }
+
+ // Experimental code. Special case for gf and arf zeromv modes.
+ // Increase zbin size to suppress noise
+ if (cpi->zbin_mode_boost_enabled) {
+ if (vp8_mode_order[mode_index].ref_frame == INTRA_FRAME)
+ cpi->zbin_mode_boost = 0;
+ else {
+ if (vp8_mode_order[mode_index].mode == ZEROMV) {
+ if (vp8_mode_order[mode_index].ref_frame != LAST_FRAME)
+ cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
+ else
+ cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
+ } else if (vp8_mode_order[mode_index].mode == SPLITMV)
+ cpi->zbin_mode_boost = 0;
+ else
+ cpi->zbin_mode_boost = MV_ZBIN_BOOST;
+ }
- vp8_update_zbin_extra(cpi, x);
- }
+ vp8_update_zbin_extra(cpi, x);
+ }
- if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame)
- switch (this_mode)
- {
- case B_PRED:
- {
- int tmp_rd;
+ if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ switch (this_mode) {
+ case B_PRED: {
+ int tmp_rd;
- // Note the rate value returned here includes the cost of coding the BPRED mode : x->mbmode_cost[x->e_mbd.frame_type][BPRED];
- tmp_rd = rd_pick_intra4x4mby_modes(cpi, x, &rate, &rate_y, &distortion, best_yrd,
+ // Note the rate value returned here includes the cost of coding the BPRED mode : x->mbmode_cost[x->e_mbd.frame_type][BPRED];
+ tmp_rd = rd_pick_intra4x4mby_modes(cpi, x, &rate, &rate_y, &distortion, best_yrd,
#if CONFIG_COMP_INTRA_PRED
- 0,
-#endif
- 0);
- rate2 += rate;
- distortion2 += distortion;
-
- if(tmp_rd < best_yrd)
- {
- rate2 += uv_intra_rate;
- rate_uv = uv_intra_rate_tokenonly;
- distortion2 += uv_intra_distortion;
- distortion_uv = uv_intra_distortion;
- }
- else
- {
- this_rd = INT_MAX;
- disable_skip = 1;
- }
+ 0,
+#endif
+ 0);
+ rate2 += rate;
+ distortion2 += distortion;
+
+ if (tmp_rd < best_yrd) {
+ rate2 += uv_intra_rate;
+ rate_uv = uv_intra_rate_tokenonly;
+ distortion2 += uv_intra_distortion;
+ distortion_uv = uv_intra_distortion;
+ } else {
+ this_rd = INT_MAX;
+ disable_skip = 1;
+ }
}
break;
- case I8X8_PRED:
- {
- int tmp_rd;
- tmp_rd = rd_pick_intra8x8mby_modes(cpi,
- x, &rate, &rate_y, &distortion, best_yrd);
- rate2 += rate;
- distortion2 += distortion;
-
- mode8x8[0][0]= x->e_mbd.mode_info_context->bmi[0].as_mode.first;
- mode8x8[0][1]= x->e_mbd.mode_info_context->bmi[2].as_mode.first;
- mode8x8[0][2]= x->e_mbd.mode_info_context->bmi[8].as_mode.first;
- mode8x8[0][3]= x->e_mbd.mode_info_context->bmi[10].as_mode.first;
+ case I8X8_PRED: {
+ int tmp_rd;
+ tmp_rd = rd_pick_intra8x8mby_modes(cpi,
+ x, &rate, &rate_y, &distortion, best_yrd);
+ rate2 += rate;
+ distortion2 += distortion;
+
+ mode8x8[0][0] = x->e_mbd.mode_info_context->bmi[0].as_mode.first;
+ mode8x8[0][1] = x->e_mbd.mode_info_context->bmi[2].as_mode.first;
+ mode8x8[0][2] = x->e_mbd.mode_info_context->bmi[8].as_mode.first;
+ mode8x8[0][3] = x->e_mbd.mode_info_context->bmi[10].as_mode.first;
#if CONFIG_COMP_INTRA_PRED
- mode8x8[1][0]= x->e_mbd.mode_info_context->bmi[0].as_mode.second;
- mode8x8[1][1]= x->e_mbd.mode_info_context->bmi[2].as_mode.second;
- mode8x8[1][2]= x->e_mbd.mode_info_context->bmi[8].as_mode.second;
- mode8x8[1][3]= x->e_mbd.mode_info_context->bmi[10].as_mode.second;
-#endif
-
- /* TODO: uv rate maybe over-estimated here since there is UV intra
- mode coded in I8X8_PRED prediction */
- if(tmp_rd < best_yrd)
- {
- rate2 += uv_intra_rate;
- rate_uv = uv_intra_rate_tokenonly;
- distortion2 += uv_intra_distortion;
- distortion_uv = uv_intra_distortion;
- }
- else
- {
- this_rd = INT_MAX;
- disable_skip = 1;
- }
+ mode8x8[1][0] = x->e_mbd.mode_info_context->bmi[0].as_mode.second;
+ mode8x8[1][1] = x->e_mbd.mode_info_context->bmi[2].as_mode.second;
+ mode8x8[1][2] = x->e_mbd.mode_info_context->bmi[8].as_mode.second;
+ mode8x8[1][3] = x->e_mbd.mode_info_context->bmi[10].as_mode.second;
+#endif
+
+ /* TODO: uv rate maybe over-estimated here since there is UV intra
+ mode coded in I8X8_PRED prediction */
+ if (tmp_rd < best_yrd) {
+ rate2 += uv_intra_rate;
+ rate_uv = uv_intra_rate_tokenonly;
+ distortion2 += uv_intra_distortion;
+ distortion_uv = uv_intra_distortion;
+ } else {
+ this_rd = INT_MAX;
+ disable_skip = 1;
+ }
}
break;
- case SPLITMV:
- {
- int tmp_rd;
- int this_rd_thresh;
-
- this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? cpi->rd_threshes[THR_NEWMV] : cpi->rd_threshes[THR_NEWA];
- this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ? cpi->rd_threshes[THR_NEWG]: this_rd_thresh;
-
- tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv, NULL,
- best_yrd, mdcounts,
- &rate, &rate_y, &distortion, this_rd_thresh, seg_mvs) ;
-
- rate2 += rate;
- distortion2 += distortion;
-
- // If even the 'Y' rd value of split is higher than best so far then dont bother looking at UV
- if (tmp_rd < best_yrd)
- {
- // Now work out UV cost and add it in
- rd_inter4x4_uv(cpi, x, &rate_uv, &distortion_uv, cpi->common.full_pixel);
- rate2 += rate_uv;
- distortion2 += distortion_uv;
- }
- else
- {
- this_rd = INT_MAX;
- disable_skip = 1;
- }
- mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY;
- compmode_cost =
- vp8_cost_bit( get_pred_prob( cm, xd, PRED_COMP ), 0 );
+ case SPLITMV: {
+ int tmp_rd;
+ int this_rd_thresh;
+
+ this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? cpi->rd_threshes[THR_NEWMV] : cpi->rd_threshes[THR_NEWA];
+ this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ? cpi->rd_threshes[THR_NEWG] : this_rd_thresh;
+
+ tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv, NULL,
+ best_yrd, mdcounts,
+ &rate, &rate_y, &distortion, this_rd_thresh, seg_mvs);
+
+ rate2 += rate;
+ distortion2 += distortion;
+
+ // If even the 'Y' rd value of split is higher than best so far then dont bother looking at UV
+ if (tmp_rd < best_yrd) {
+ // Now work out UV cost and add it in
+ rd_inter4x4_uv(cpi, x, &rate_uv, &distortion_uv, cpi->common.full_pixel);
+ rate2 += rate_uv;
+ distortion2 += distortion_uv;
+ } else {
+ this_rd = INT_MAX;
+ disable_skip = 1;
+ }
+ mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY;
+ compmode_cost =
+ vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 0);
}
break;
#if CONFIG_NEWINTRAMODES
@@ -3178,976 +2916,895 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
case V_PRED:
case H_PRED:
case TM_PRED:
- x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
- // FIXME compound intra prediction
- RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
- (&x->e_mbd);
- if(cpi->common.txfm_mode == ALLOW_8X8)
- macro_block_yrd_8x8(x, &rate_y, &distortion,
- IF_RTCD(&cpi->rtcd)) ;
- else
- macro_block_yrd(x, &rate_y, &distortion,
- IF_RTCD(&cpi->rtcd)) ;
- rate2 += rate_y;
- distortion2 += distortion;
- rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode];
- if(cpi->common.txfm_mode == ALLOW_8X8)
- {
- rate2 += uv_intra_rate_8x8;
- rate_uv = uv_intra_rate_tokenonly_8x8;
- distortion2 += uv_intra_distortion_8x8;
- distortion_uv = uv_intra_distortion_8x8;
- }
- else
- {
- rate2 += uv_intra_rate;
- rate_uv = uv_intra_rate_tokenonly;
- distortion2 += uv_intra_distortion;
- distortion_uv = uv_intra_distortion;
- }
- break;
-
- case NEWMV:
- {
- int thissme;
- int bestsme = INT_MAX;
- int step_param = cpi->sf.first_step;
- int further_steps;
- int n;
- int do_refine=1; /* If last step (1-away) of n-step search doesn't pick the center point as the best match,
- we will do a final 1-away diamond refining search */
-
- int sadpb = x->sadperbit16;
- int_mv mvp_full;
-
- int col_min = (best_ref_mv.as_mv.col>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.col & 7)?1:0);
- int row_min = (best_ref_mv.as_mv.row>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.row & 7)?1:0);
- int col_max = (best_ref_mv.as_mv.col>>3) + MAX_FULL_PEL_VAL;
- int row_max = (best_ref_mv.as_mv.row>>3) + MAX_FULL_PEL_VAL;
-
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
-
- if(!saddone)
- {
- vp8_cal_sad(cpi,xd,x, recon_yoffset ,&near_sadidx[0] );
- saddone = 1;
- }
+ x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
+ // FIXME compound intra prediction
+ RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
+ (&x->e_mbd);
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ macro_block_yrd_8x8(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+ else
+ macro_block_yrd(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+ rate2 += rate_y;
+ distortion2 += distortion;
+ rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode];
+ if (cpi->common.txfm_mode == ALLOW_8X8) {
+ rate2 += uv_intra_rate_8x8;
+ rate_uv = uv_intra_rate_tokenonly_8x8;
+ distortion2 += uv_intra_distortion_8x8;
+ distortion_uv = uv_intra_distortion_8x8;
+ } else {
+ rate2 += uv_intra_rate;
+ rate_uv = uv_intra_rate_tokenonly;
+ distortion2 += uv_intra_distortion;
+ distortion_uv = uv_intra_distortion;
+ }
+ break;
+
+ case NEWMV: {
+ int thissme;
+ int bestsme = INT_MAX;
+ int step_param = cpi->sf.first_step;
+ int further_steps;
+ int n;
+ int do_refine = 1; /* If last step (1-away) of n-step search doesn't pick the center point as the best match,
+ we will do a final 1-away diamond refining search */
+
+ int sadpb = x->sadperbit16;
+ int_mv mvp_full;
+
+ int col_min = (best_ref_mv.as_mv.col >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.col & 7) ? 1 : 0);
+ int row_min = (best_ref_mv.as_mv.row >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.row & 7) ? 1 : 0);
+ int col_max = (best_ref_mv.as_mv.col >> 3) + MAX_FULL_PEL_VAL;
+ int row_max = (best_ref_mv.as_mv.row >> 3) + MAX_FULL_PEL_VAL;
+
+ int tmp_col_min = x->mv_col_min;
+ int tmp_col_max = x->mv_col_max;
+ int tmp_row_min = x->mv_row_min;
+ int tmp_row_max = x->mv_row_max;
+
+ if (!saddone) {
+ vp8_cal_sad(cpi, xd, x, recon_yoffset, &near_sadidx[0]);
+ saddone = 1;
+ }
+
+ vp8_mv_pred(cpi, &x->e_mbd, x->e_mbd.mode_info_context, &mvp,
+ x->e_mbd.mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias, &sr, &near_sadidx[0]);
+
+ mvp_full.as_mv.col = mvp.as_mv.col >> 3;
+ mvp_full.as_mv.row = mvp.as_mv.row >> 3;
+
+ // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
+ if (x->mv_col_min < col_min)
+ x->mv_col_min = col_min;
+ if (x->mv_col_max > col_max)
+ x->mv_col_max = col_max;
+ if (x->mv_row_min < row_min)
+ x->mv_row_min = row_min;
+ if (x->mv_row_max > row_max)
+ x->mv_row_max = row_max;
+
+ // adjust search range according to sr from mv prediction
+ if (sr > step_param)
+ step_param = sr;
+
+ // Initial step/diamond search
+ {
+ bestsme = cpi->diamond_search_sad(x, b, d, &mvp_full, &d->bmi.as_mv.first,
+ step_param, sadpb, &num00,
+ &cpi->fn_ptr[BLOCK_16X16],
+ XMVCOST, &best_ref_mv);
+ mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
- vp8_mv_pred(cpi, &x->e_mbd, x->e_mbd.mode_info_context, &mvp,
- x->e_mbd.mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias, &sr, &near_sadidx[0]);
-
- mvp_full.as_mv.col = mvp.as_mv.col>>3;
- mvp_full.as_mv.row = mvp.as_mv.row>>3;
-
- // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
- if (x->mv_col_min < col_min )
- x->mv_col_min = col_min;
- if (x->mv_col_max > col_max )
- x->mv_col_max = col_max;
- if (x->mv_row_min < row_min )
- x->mv_row_min = row_min;
- if (x->mv_row_max > row_max )
- x->mv_row_max = row_max;
-
- //adjust search range according to sr from mv prediction
- if(sr > step_param)
- step_param = sr;
-
- // Initial step/diamond search
- {
- bestsme = cpi->diamond_search_sad(x, b, d, &mvp_full, &d->bmi.as_mv.first,
- step_param, sadpb, &num00,
- &cpi->fn_ptr[BLOCK_16X16],
- XMVCOST, &best_ref_mv);
- mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
-
- // Further step/diamond searches as necessary
- n = 0;
- further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
-
- n = num00;
- num00 = 0;
-
- /* If there won't be more n-step search, check to see if refining search is needed. */
- if (n > further_steps)
- do_refine = 0;
-
- while (n < further_steps)
- {
- n++;
-
- if (num00)
- num00--;
- else
- {
- thissme = cpi->diamond_search_sad(x, b, d, &mvp_full,
- &d->bmi.as_mv.first, step_param + n, sadpb, &num00,
- &cpi->fn_ptr[BLOCK_16X16],
- XMVCOST, &best_ref_mv);
-
- /* check to see if refining search is needed. */
- if (num00 > (further_steps-n))
- do_refine = 0;
-
- if (thissme < bestsme)
- {
- bestsme = thissme;
- mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
- }
- else
- {
- d->bmi.as_mv.first.as_int = mode_mv[NEWMV].as_int;
- }
- }
+ // Further step/diamond searches as necessary
+ n = 0;
+ further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
+
+ n = num00;
+ num00 = 0;
+
+ /* If there won't be more n-step search, check to see if refining search is needed. */
+ if (n > further_steps)
+ do_refine = 0;
+
+ while (n < further_steps) {
+ n++;
+
+ if (num00)
+ num00--;
+ else {
+ thissme = cpi->diamond_search_sad(x, b, d, &mvp_full,
+ &d->bmi.as_mv.first, step_param + n, sadpb, &num00,
+ &cpi->fn_ptr[BLOCK_16X16],
+ XMVCOST, &best_ref_mv);
+
+ /* check to see if refining search is needed. */
+ if (num00 > (further_steps - n))
+ do_refine = 0;
+
+ if (thissme < bestsme) {
+ bestsme = thissme;
+ mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
+ } else {
+ d->bmi.as_mv.first.as_int = mode_mv[NEWMV].as_int;
}
+ }
}
+ }
- /* final 1-away diamond refining search */
- if (do_refine == 1)
- {
- int search_range;
+ /* final 1-away diamond refining search */
+ if (do_refine == 1) {
+ int search_range;
- //It seems not a good way to set search_range. Need further investigation.
- //search_range = MAXF(abs((mvp.row>>3) - d->bmi.mv.as_mv.row), abs((mvp.col>>3) - d->bmi.mv.as_mv.col));
- search_range = 8;
+ // It seems not a good way to set search_range. Need further investigation.
+ // search_range = MAXF(abs((mvp.row>>3) - d->bmi.mv.as_mv.row), abs((mvp.col>>3) - d->bmi.mv.as_mv.col));
+ search_range = 8;
- //thissme = cpi->full_search_sad(x, b, d, &d->bmi.mv.as_mv, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
- thissme = cpi->refining_search_sad(x, b, d, &d->bmi.as_mv.first, sadpb,
- search_range, &cpi->fn_ptr[BLOCK_16X16],
- XMVCOST, &best_ref_mv);
+ // thissme = cpi->full_search_sad(x, b, d, &d->bmi.mv.as_mv, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
+ thissme = cpi->refining_search_sad(x, b, d, &d->bmi.as_mv.first, sadpb,
+ search_range, &cpi->fn_ptr[BLOCK_16X16],
+ XMVCOST, &best_ref_mv);
- if (thissme < bestsme)
- {
- bestsme = thissme;
- mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
- }
- else
- {
- d->bmi.as_mv.first.as_int = mode_mv[NEWMV].as_int;
- }
+ if (thissme < bestsme) {
+ bestsme = thissme;
+ mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
+ } else {
+ d->bmi.as_mv.first.as_int = mode_mv[NEWMV].as_int;
}
+ }
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
-
- if (bestsme < INT_MAX)
- {
- int dis; /* TODO: use dis in distortion calculation later. */
- unsigned int sse;
- cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first, &best_ref_mv,
- x->errorperbit,
- &cpi->fn_ptr[BLOCK_16X16],
- XMVCOST, &dis, &sse);
- }
- mc_search_result[x->e_mbd.mode_info_context->mbmi.ref_frame].as_int = d->bmi.as_mv.first.as_int;
+ x->mv_col_min = tmp_col_min;
+ x->mv_col_max = tmp_col_max;
+ x->mv_row_min = tmp_row_min;
+ x->mv_row_max = tmp_row_max;
- mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
+ if (bestsme < INT_MAX) {
+ int dis; /* TODO: use dis in distortion calculation later. */
+ unsigned int sse;
+ cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first, &best_ref_mv,
+ x->errorperbit,
+ &cpi->fn_ptr[BLOCK_16X16],
+ XMVCOST, &dis, &sse);
+ }
+ mc_search_result[x->e_mbd.mode_info_context->mbmi.ref_frame].as_int = d->bmi.as_mv.first.as_int;
- // Add the new motion vector cost to our rolling cost variable
+ mode_mv[NEWMV].as_int = d->bmi.as_mv.first.as_int;
+
+ // Add the new motion vector cost to our rolling cost variable
#if CONFIG_HIGH_PRECISION_MV
- rate2 += vp8_mv_bit_cost(&mode_mv[NEWMV], &best_ref_mv,
- XMVCOST, 96,
- x->e_mbd.allow_high_precision_mv);
+ rate2 += vp8_mv_bit_cost(&mode_mv[NEWMV], &best_ref_mv,
+ XMVCOST, 96,
+ x->e_mbd.allow_high_precision_mv);
#else
- rate2 += vp8_mv_bit_cost(&mode_mv[NEWMV], &best_ref_mv,
- XMVCOST, 96);
+ rate2 += vp8_mv_bit_cost(&mode_mv[NEWMV], &best_ref_mv,
+ XMVCOST, 96);
#endif
}
case NEARESTMV:
case NEARMV:
- // Clip "next_nearest" so that it does not extend to far out of image
- vp8_clamp_mv2(&mode_mv[this_mode], xd);
+ // Clip "next_nearest" so that it does not extend to far out of image
+ vp8_clamp_mv2(&mode_mv[this_mode], xd);
- // Do not bother proceeding if the vector (from newmv,nearest or near) is 0,0 as this should then be coded using the zeromv mode.
- if (((this_mode == NEARMV) || (this_mode == NEARESTMV)) && (mode_mv[this_mode].as_int == 0))
- {
- continue;
- }
+ // Do not bother proceeding if the vector (from newmv,nearest or near) is 0,0 as this should then be coded using the zeromv mode.
+ if (((this_mode == NEARMV) || (this_mode == NEARESTMV)) && (mode_mv[this_mode].as_int == 0)) {
+ continue;
+ }
case ZEROMV:
- // Trap vectors that reach beyond the UMV borders
- // Note that ALL New MV, Nearest MV Near MV and Zero MV code drops through to this point
- // because of the lack of break statements in the previous two cases.
- if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
- ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) || ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
- {
- continue;
- }
+ // Trap vectors that reach beyond the UMV borders
+ // Note that ALL New MV, Nearest MV Near MV and Zero MV code drops through to this point
+ // because of the lack of break statements in the previous two cases.
+ if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
+ ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) || ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
+ continue;
+ }
- vp8_set_mbmode_and_mvs(x, this_mode, &mode_mv[this_mode]);
+ vp8_set_mbmode_and_mvs(x, this_mode, &mode_mv[this_mode]);
#if CONFIG_PRED_FILTER
- // Filtered prediction:
- xd->mode_info_context->mbmi.pred_filter_enabled =
- vp8_mode_order[mode_index].pred_filter_flag;
- rate2 += vp8_cost_bit( cpi->common.prob_pred_filter_off,
- xd->mode_info_context->mbmi.pred_filter_enabled);
-#endif
-
- vp8_build_inter16x16_predictors_mby(&x->e_mbd);
-
- compmode_cost =
- vp8_cost_bit( get_pred_prob( cm, xd, PRED_COMP ), 0 );
-
- if (cpi->active_map_enabled && x->active_ptr[0] == 0) {
- x->skip = 1;
- }
- else if (x->encode_breakout)
- {
- unsigned int sse;
- unsigned int var;
- int threshold = (xd->block[0].dequant[1]
- * xd->block[0].dequant[1] >>4);
-
- if(threshold < x->encode_breakout)
- threshold = x->encode_breakout;
-
- var = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
- (*(b->base_src), b->src_stride,
- x->e_mbd.predictor, 16, &sse);
-
- if (sse < threshold)
- {
- unsigned int q2dc = xd->block[24].dequant[0];
- /* If there is no codeable 2nd order dc
- or a very small uniform pixel change change */
- if ((sse - var < q2dc * q2dc >>4) ||
- (sse /2 > var && sse-var < 64))
- {
- // Check u and v to make sure skip is ok
- int sse2= VP8_UVSSE(x, IF_RTCD(&cpi->rtcd.variance));
- if (sse2 * 2 < threshold)
- {
- x->skip = 1;
- distortion2 = sse + sse2;
- rate2 = 500;
-
- /* for best_yrd calculation */
- rate_uv = 0;
- distortion_uv = sse2;
-
- disable_skip = 1;
- this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
-
- break;
- }
- }
+ // Filtered prediction:
+ xd->mode_info_context->mbmi.pred_filter_enabled =
+ vp8_mode_order[mode_index].pred_filter_flag;
+ rate2 += vp8_cost_bit(cpi->common.prob_pred_filter_off,
+ xd->mode_info_context->mbmi.pred_filter_enabled);
+#endif
+
+ vp8_build_inter16x16_predictors_mby(&x->e_mbd);
+
+ compmode_cost =
+ vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 0);
+
+ if (cpi->active_map_enabled && x->active_ptr[0] == 0) {
+ x->skip = 1;
+ } else if (x->encode_breakout) {
+ unsigned int sse;
+ unsigned int var;
+ int threshold = (xd->block[0].dequant[1]
+ * xd->block[0].dequant[1] >> 4);
+
+ if (threshold < x->encode_breakout)
+ threshold = x->encode_breakout;
+
+ var = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
+ (*(b->base_src), b->src_stride,
+ x->e_mbd.predictor, 16, &sse);
+
+ if (sse < threshold) {
+ unsigned int q2dc = xd->block[24].dequant[0];
+ /* If there is no codeable 2nd order dc
+ or a very small uniform pixel change change */
+ if ((sse - var < q2dc *q2dc >> 4) ||
+ (sse / 2 > var && sse - var < 64)) {
+ // Check u and v to make sure skip is ok
+ int sse2 = VP8_UVSSE(x, IF_RTCD(&cpi->rtcd.variance));
+ if (sse2 * 2 < threshold) {
+ x->skip = 1;
+ distortion2 = sse + sse2;
+ rate2 = 500;
+
+ /* for best_yrd calculation */
+ rate_uv = 0;
+ distortion_uv = sse2;
+
+ disable_skip = 1;
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+
+ break;
}
+ }
}
- //intermodecost[mode_index] = vp8_cost_mv_ref(cpi, this_mode, mdcounts); // Experimental debug code
+ }
+ // intermodecost[mode_index] = vp8_cost_mv_ref(cpi, this_mode, mdcounts); // Experimental debug code
- // Add in the Mv/mode cost
- rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts);
+ // Add in the Mv/mode cost
+ rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts);
- // Y cost and distortion
- if(cpi->common.txfm_mode == ALLOW_8X8)
- macro_block_yrd_8x8(x, &rate_y, &distortion,
- IF_RTCD(&cpi->rtcd));
- else
- macro_block_yrd(x, &rate_y, &distortion,
+ // Y cost and distortion
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ macro_block_yrd_8x8(x, &rate_y, &distortion,
IF_RTCD(&cpi->rtcd));
-
- rate2 += rate_y;
- distortion2 += distortion;
-
- // UV cost and distortion
- vp8_build_inter16x16_predictors_mbuv(&x->e_mbd);
-
- if(cpi->common.txfm_mode == ALLOW_8X8)
- rd_inter16x16_uv_8x8(cpi, x, &rate_uv,
- &distortion_uv,
- cpi->common.full_pixel);
- else
- rd_inter16x16_uv(cpi, x, &rate_uv,
- &distortion_uv,
- cpi->common.full_pixel);
- rate2 += rate_uv;
- distortion2 += distortion_uv;
- mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY;
- break;
+ else
+ macro_block_yrd(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+
+ rate2 += rate_y;
+ distortion2 += distortion;
+
+ // UV cost and distortion
+ vp8_build_inter16x16_predictors_mbuv(&x->e_mbd);
+
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ rd_inter16x16_uv_8x8(cpi, x, &rate_uv,
+ &distortion_uv,
+ cpi->common.full_pixel);
+ else
+ rd_inter16x16_uv(cpi, x, &rate_uv,
+ &distortion_uv,
+ cpi->common.full_pixel);
+ rate2 += rate_uv;
+ distortion2 += distortion_uv;
+ mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY;
+ break;
default:
- break;
- }
- else /* x->e_mbd.mode_info_context->mbmi.second_ref_frame != 0 */
- {
- int ref1 = x->e_mbd.mode_info_context->mbmi.ref_frame;
- int ref2 = x->e_mbd.mode_info_context->mbmi.second_ref_frame;
-
- mode_excluded = cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY;
- switch (this_mode)
- {
- case NEWMV:
- if (mc_search_result[ref1].as_int == INVALID_MV ||
- mc_search_result[ref2].as_int == INVALID_MV)
- continue;
- x->e_mbd.mode_info_context->mbmi.mv.as_int = mc_search_result[ref1].as_int;
- x->e_mbd.mode_info_context->mbmi.second_mv.as_int = mc_search_result[ref2].as_int;
+ break;
+ }
+ else { /* x->e_mbd.mode_info_context->mbmi.second_ref_frame != 0 */
+ int ref1 = x->e_mbd.mode_info_context->mbmi.ref_frame;
+ int ref2 = x->e_mbd.mode_info_context->mbmi.second_ref_frame;
+
+ mode_excluded = cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY;
+ switch (this_mode) {
+ case NEWMV:
+ if (mc_search_result[ref1].as_int == INVALID_MV ||
+ mc_search_result[ref2].as_int == INVALID_MV)
+ continue;
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = mc_search_result[ref1].as_int;
+ x->e_mbd.mode_info_context->mbmi.second_mv.as_int = mc_search_result[ref2].as_int;
#if CONFIG_HIGH_PRECISION_MV
- rate2 += vp8_mv_bit_cost(&mc_search_result[ref1],
- &frame_best_ref_mv[ref1],
- XMVCOST, 96,
- x->e_mbd.allow_high_precision_mv);
- rate2 += vp8_mv_bit_cost(&mc_search_result[ref2],
- &frame_best_ref_mv[ref2],
- XMVCOST, 96,
- x->e_mbd.allow_high_precision_mv);
+ rate2 += vp8_mv_bit_cost(&mc_search_result[ref1],
+ &frame_best_ref_mv[ref1],
+ XMVCOST, 96,
+ x->e_mbd.allow_high_precision_mv);
+ rate2 += vp8_mv_bit_cost(&mc_search_result[ref2],
+ &frame_best_ref_mv[ref2],
+ XMVCOST, 96,
+ x->e_mbd.allow_high_precision_mv);
#else
- rate2 += vp8_mv_bit_cost(&mc_search_result[ref1],
- &frame_best_ref_mv[ref1],
- XMVCOST, 96);
- rate2 += vp8_mv_bit_cost(&mc_search_result[ref2],
- &frame_best_ref_mv[ref2],
- XMVCOST, 96);
-#endif
- break;
- case ZEROMV:
- x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
- x->e_mbd.mode_info_context->mbmi.second_mv.as_int = 0;
- break;
- case NEARMV:
- if (frame_near_mv[ref1].as_int == 0 || frame_near_mv[ref2].as_int == 0)
- {
- continue;
- }
- x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_near_mv[ref1].as_int;
- x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_near_mv[ref2].as_int;
- break;
- case NEARESTMV:
- if (frame_nearest_mv[ref1].as_int == 0 || frame_nearest_mv[ref2].as_int == 0)
- {
- continue;
- }
- x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_nearest_mv[ref1].as_int;
- x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_nearest_mv[ref2].as_int;
- break;
- case SPLITMV:
- {
- int tmp_rd;
- int this_rd_thresh;
-
- this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? cpi->rd_threshes[THR_NEWMV] : cpi->rd_threshes[THR_NEWA];
- this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ? cpi->rd_threshes[THR_NEWG]: this_rd_thresh;
-
- tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv, &second_best_ref_mv,
- best_yrd, mdcounts,
- &rate, &rate_y, &distortion, this_rd_thresh, seg_mvs) ;
-
- rate2 += rate;
- distortion2 += distortion;
-
- // If even the 'Y' rd value of split is higher than best so far then dont bother looking at UV
- if (tmp_rd < best_yrd)
- {
- // Now work out UV cost and add it in
- rd_inter4x4_uv(cpi, x, &rate_uv, &distortion_uv, cpi->common.full_pixel);
- rate2 += rate_uv;
- distortion2 += distortion_uv;
- }
- else
- {
- this_rd = INT_MAX;
- disable_skip = 1;
- }
- }
- break;
- default:
- break;
- }
-
- if (this_mode != SPLITMV)
- {
- /* Add in the Mv/mode cost */
- rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts);
-
- vp8_clamp_mv2(&x->e_mbd.mode_info_context->mbmi.mv, xd);
- vp8_clamp_mv2(&x->e_mbd.mode_info_context->mbmi.second_mv, xd);
- if (((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row >> 3) < x->mv_row_min) ||
- ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row >> 3) > x->mv_row_max) ||
- ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col >> 3) < x->mv_col_min) ||
- ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col >> 3) > x->mv_col_max) ||
- ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row >> 3) < x->mv_row_min) ||
- ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row >> 3) > x->mv_row_max) ||
- ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col >> 3) < x->mv_col_min) ||
- ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col >> 3) > x->mv_col_max))
- {
- continue;
- }
-
- /* build first and second prediction */
- vp8_build_inter16x16_predictors_mby(&x->e_mbd);
- vp8_build_inter16x16_predictors_mbuv(&x->e_mbd);
- /* do second round and average the results */
- vp8_build_2nd_inter16x16_predictors_mb(&x->e_mbd, x->e_mbd.predictor,
- &x->e_mbd.predictor[256],
- &x->e_mbd.predictor[320], 16, 8);
-
- /* Y cost and distortion */
- if (cpi->common.txfm_mode == ALLOW_8X8)
- macro_block_yrd_8x8(x, &rate_y, &distortion,
- IF_RTCD(&cpi->rtcd));
- else
- macro_block_yrd(x, &rate_y, &distortion,
- IF_RTCD(&cpi->rtcd));
-
- rate2 += rate_y;
- distortion2 += distortion;
-
- /* UV cost and distortion */
- if(cpi->common.txfm_mode == ALLOW_8X8)
- rd_inter16x16_uv_8x8(cpi, x, &rate_uv,
- &distortion_uv,
- cpi->common.full_pixel);
- else
- rd_inter16x16_uv(cpi, x, &rate_uv,
- &distortion_uv,
- cpi->common.full_pixel);
- rate2 += rate_uv;
- distortion2 += distortion_uv;
- }
-
- /* don't bother w/ skip, we would never have come here if skip were enabled */
- x->e_mbd.mode_info_context->mbmi.mode = this_mode;
-
- /* We don't include the cost of the second reference here, because there are only
- * three options: Last/Golden, ARF/Last or Golden/ARF, or in other words if you
- * present them in that order, the second one is always known if the first is known */
- compmode_cost =
- vp8_cost_bit( get_pred_prob( cm, xd, PRED_COMP ), 1 );
- }
-
- if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
- {
- rate2 += compmode_cost;
+ rate2 += vp8_mv_bit_cost(&mc_search_result[ref1],
+ &frame_best_ref_mv[ref1],
+ XMVCOST, 96);
+ rate2 += vp8_mv_bit_cost(&mc_search_result[ref2],
+ &frame_best_ref_mv[ref2],
+ XMVCOST, 96);
+#endif
+ break;
+ case ZEROMV:
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
+ x->e_mbd.mode_info_context->mbmi.second_mv.as_int = 0;
+ break;
+ case NEARMV:
+ if (frame_near_mv[ref1].as_int == 0 || frame_near_mv[ref2].as_int == 0) {
+ continue;
+ }
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_near_mv[ref1].as_int;
+ x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_near_mv[ref2].as_int;
+ break;
+ case NEARESTMV:
+ if (frame_nearest_mv[ref1].as_int == 0 || frame_nearest_mv[ref2].as_int == 0) {
+ continue;
+ }
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_nearest_mv[ref1].as_int;
+ x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_nearest_mv[ref2].as_int;
+ break;
+ case SPLITMV: {
+ int tmp_rd;
+ int this_rd_thresh;
+
+ this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? cpi->rd_threshes[THR_NEWMV] : cpi->rd_threshes[THR_NEWA];
+ this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ? cpi->rd_threshes[THR_NEWG] : this_rd_thresh;
+
+ tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv, &second_best_ref_mv,
+ best_yrd, mdcounts,
+ &rate, &rate_y, &distortion, this_rd_thresh, seg_mvs);
+
+ rate2 += rate;
+ distortion2 += distortion;
+
+ // If even the 'Y' rd value of split is higher than best so far then dont bother looking at UV
+ if (tmp_rd < best_yrd) {
+ // Now work out UV cost and add it in
+ rd_inter4x4_uv(cpi, x, &rate_uv, &distortion_uv, cpi->common.full_pixel);
+ rate2 += rate_uv;
+ distortion2 += distortion_uv;
+ } else {
+ this_rd = INT_MAX;
+ disable_skip = 1;
+ }
}
+ break;
+ default:
+ break;
+ }
+
+ if (this_mode != SPLITMV) {
+ /* Add in the Mv/mode cost */
+ rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts);
+
+ vp8_clamp_mv2(&x->e_mbd.mode_info_context->mbmi.mv, xd);
+ vp8_clamp_mv2(&x->e_mbd.mode_info_context->mbmi.second_mv, xd);
+ if (((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row >> 3) < x->mv_row_min) ||
+ ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row >> 3) > x->mv_row_max) ||
+ ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col >> 3) < x->mv_col_min) ||
+ ((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col >> 3) > x->mv_col_max) ||
+ ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row >> 3) < x->mv_row_min) ||
+ ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row >> 3) > x->mv_row_max) ||
+ ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col >> 3) < x->mv_col_min) ||
+ ((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col >> 3) > x->mv_col_max)) {
+ continue;
+ }
+
+ /* build first and second prediction */
+ vp8_build_inter16x16_predictors_mby(&x->e_mbd);
+ vp8_build_inter16x16_predictors_mbuv(&x->e_mbd);
+ /* do second round and average the results */
+ vp8_build_2nd_inter16x16_predictors_mb(&x->e_mbd, x->e_mbd.predictor,
+ &x->e_mbd.predictor[256],
+ &x->e_mbd.predictor[320], 16, 8);
+
+ /* Y cost and distortion */
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ macro_block_yrd_8x8(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+ else
+ macro_block_yrd(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+ rate2 += rate_y;
+ distortion2 += distortion;
- // Estimate the reference frame signaling cost and add it
- // to the rolling cost variable.
- rate2 += ref_costs[x->e_mbd.mode_info_context->mbmi.ref_frame];
-
- if (!disable_skip)
- {
- // Test for the condition where skip block will be activated
- // because there are no non zero coefficients and make any
- // necessary adjustment for rate. Ignore if skip is coded at
- // segment level as the cost wont have been added in.
- if ( cpi->common.mb_no_coeff_skip )
- {
- int mb_skippable;
- int mb_skip_allowed;
- int has_y2 = ( this_mode!=SPLITMV
- &&this_mode!=B_PRED
- &&this_mode!=I8X8_PRED);
-
- if((cpi->common.txfm_mode == ALLOW_8X8) && has_y2)
- {
- if(x->e_mbd.mode_info_context->mbmi.ref_frame!=INTRA_FRAME)
- mb_skippable = mb_is_skippable_8x8(&x->e_mbd);
- else
- mb_skippable = uv_intra_skippable_8x8
- & mby_is_skippable_8x8(&x->e_mbd);
- }
- else
- {
- if(x->e_mbd.mode_info_context->mbmi.ref_frame!=INTRA_FRAME)
- mb_skippable = mb_is_skippable(&x->e_mbd, has_y2);
- else
- mb_skippable = uv_intra_skippable
- & mby_is_skippable(&x->e_mbd, has_y2);
- }
-
- // Is Mb level skip allowed for this mb.
- mb_skip_allowed =
- !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
- get_segdata( xd, segment_id, SEG_LVL_EOB );
-
- if (mb_skippable)
- {
- // Back out the coefficient coding costs
- rate2 -= (rate_y + rate_uv);
- //for best_yrd calculation
- rate_uv = 0;
-
- if ( mb_skip_allowed )
- {
- int prob_skip_cost;
-
- // Cost the skip mb case
+ /* UV cost and distortion */
+ if (cpi->common.txfm_mode == ALLOW_8X8)
+ rd_inter16x16_uv_8x8(cpi, x, &rate_uv,
+ &distortion_uv,
+ cpi->common.full_pixel);
+ else
+ rd_inter16x16_uv(cpi, x, &rate_uv,
+ &distortion_uv,
+ cpi->common.full_pixel);
+ rate2 += rate_uv;
+ distortion2 += distortion_uv;
+ }
+
+ /* don't bother w/ skip, we would never have come here if skip were enabled */
+ x->e_mbd.mode_info_context->mbmi.mode = this_mode;
+
+ /* We don't include the cost of the second reference here, because there are only
+ * three options: Last/Golden, ARF/Last or Golden/ARF, or in other words if you
+ * present them in that order, the second one is always known if the first is known */
+ compmode_cost =
+ vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 1);
+ }
+
+ if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
+ rate2 += compmode_cost;
+ }
+
+
+ // Estimate the reference frame signaling cost and add it
+ // to the rolling cost variable.
+ rate2 += ref_costs[x->e_mbd.mode_info_context->mbmi.ref_frame];
+
+ if (!disable_skip) {
+ // Test for the condition where skip block will be activated
+ // because there are no non zero coefficients and make any
+ // necessary adjustment for rate. Ignore if skip is coded at
+ // segment level as the cost wont have been added in.
+ if (cpi->common.mb_no_coeff_skip) {
+ int mb_skippable;
+ int mb_skip_allowed;
+ int has_y2 = (this_mode != SPLITMV
+ && this_mode != B_PRED
+ && this_mode != I8X8_PRED);
+
+ if ((cpi->common.txfm_mode == ALLOW_8X8) && has_y2) {
+ if (x->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME)
+ mb_skippable = mb_is_skippable_8x8(&x->e_mbd);
+ else
+ mb_skippable = uv_intra_skippable_8x8
+ & mby_is_skippable_8x8(&x->e_mbd);
+ } else {
+ if (x->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME)
+ mb_skippable = mb_is_skippable(&x->e_mbd, has_y2);
+ else
+ mb_skippable = uv_intra_skippable
+ & mby_is_skippable(&x->e_mbd, has_y2);
+ }
+
+ // Is Mb level skip allowed for this mb.
+ mb_skip_allowed =
+ !segfeature_active(xd, segment_id, SEG_LVL_EOB) ||
+ get_segdata(xd, segment_id, SEG_LVL_EOB);
+
+ if (mb_skippable) {
+ // Back out the coefficient coding costs
+ rate2 -= (rate_y + rate_uv);
+ // for best_yrd calculation
+ rate_uv = 0;
+
+ if (mb_skip_allowed) {
+ int prob_skip_cost;
+
+ // Cost the skip mb case
#if CONFIG_NEWENTROPY
- vp8_prob skip_prob =
- get_pred_prob(cm, &x->e_mbd, PRED_MBSKIP);
-
- if (skip_prob)
- {
- prob_skip_cost = vp8_cost_bit(skip_prob, 1);
- rate2 += prob_skip_cost;
- other_cost += prob_skip_cost;
- }
+ vp8_prob skip_prob =
+ get_pred_prob(cm, &x->e_mbd, PRED_MBSKIP);
+
+ if (skip_prob) {
+ prob_skip_cost = vp8_cost_bit(skip_prob, 1);
+ rate2 += prob_skip_cost;
+ other_cost += prob_skip_cost;
+ }
#else
- if (cpi->prob_skip_false)
- {
- prob_skip_cost =
- vp8_cost_bit(cpi->prob_skip_false, 1);
- rate2 += prob_skip_cost;
- other_cost += prob_skip_cost;
- }
-#endif
- }
- }
- // Add in the cost of the no skip flag.
- else if ( mb_skip_allowed )
- {
- #if CONFIG_NEWENTROPY
- int prob_skip_cost = vp8_cost_bit(
- get_pred_prob(cm, &x->e_mbd, PRED_MBSKIP), 0);
- #else
- int prob_skip_cost = vp8_cost_bit(cpi->prob_skip_false, 0);
- #endif
- rate2 += prob_skip_cost;
- other_cost += prob_skip_cost;
- }
+ if (cpi->prob_skip_false) {
+ prob_skip_cost =
+ vp8_cost_bit(cpi->prob_skip_false, 1);
+ rate2 += prob_skip_cost;
+ other_cost += prob_skip_cost;
}
-
- // Calculate the final RD estimate for this mode.
- this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
- }
-
- // Experimental debug code.
- //all_rds[mode_index] = this_rd;
- //all_rates[mode_index] = rate2;
- //all_dist[mode_index] = distortion2;
-
- // Keep record of best intra distortion
- if ((x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME) &&
- (this_rd < best_intra_rd) )
- {
- best_intra_rd = this_rd;
- *returnintra = distortion2 ;
- }
-
- if (!disable_skip && x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
- {
- if (this_rd < best_comp_rd)
- best_comp_rd = this_rd;
- if (this_rd < best_single_rd)
- best_single_rd = this_rd;
- if (this_rd < best_hybrid_rd)
- best_hybrid_rd = this_rd;
- }
-
-#if CONFIG_PRED_FILTER
- // Keep track of the best mode irrespective of prediction filter state
- if (this_rd < best_overall_rd)
- {
- best_overall_rd = this_rd;
- best_filter_state = xd->mode_info_context->mbmi.pred_filter_enabled;
- }
-
- // Ignore modes where the prediction filter state doesn't
- // match the state signaled at the frame level
- if ((cm->pred_filter_mode == 2) ||
- (cm->pred_filter_mode ==
- xd->mode_info_context->mbmi.pred_filter_enabled))
- {
#endif
- // Did this mode help.. i.e. is it the new best mode
- if (this_rd < best_rd || x->skip)
- {
- if (!mode_excluded)
- {
- // Note index of best mode so far
- best_mode_index = mode_index;
-
- if (this_mode <= B_PRED)
- {
- if( cpi->common.txfm_mode == ALLOW_8X8
- && this_mode != B_PRED
- && this_mode != I8X8_PRED)
- x->e_mbd.mode_info_context->mbmi.uv_mode = uv_intra_mode_8x8;
- else
- x->e_mbd.mode_info_context->mbmi.uv_mode = uv_intra_mode;
- /* required for left and above block mv */
- x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
- }
-
- other_cost +=
- ref_costs[x->e_mbd.mode_info_context->mbmi.ref_frame];
-
- /* Calculate the final y RD estimate for this mode */
- best_yrd = RDCOST(x->rdmult, x->rddiv, (rate2-rate_uv-other_cost),
- (distortion2-distortion_uv));
-
- *returnrate = rate2;
- *returndistortion = distortion2;
- best_rd = this_rd;
- vpx_memcpy(&best_mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE_INFO));
- vpx_memcpy(&best_partition, x->partition_info, sizeof(PARTITION_INFO));
-
- if ((this_mode == B_PRED)
- ||(this_mode == I8X8_PRED)
- || (this_mode == SPLITMV))
- for (i = 0; i < 16; i++)
- {
- best_bmodes[i] = x->e_mbd.block[i].bmi;
- }
- }
-
- // Testing this mode gave rise to an improvement in best error score. Lower threshold a bit for next time
- cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
- cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ }
}
- // If the mode did not help improve the best error case then raise the threshold for testing that mode next time around.
- else
- {
- cpi->rd_thresh_mult[mode_index] += 4;
-
- if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
- cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
-
- cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ // Add in the cost of the no skip flag.
+ else if (mb_skip_allowed) {
+#if CONFIG_NEWENTROPY
+ int prob_skip_cost = vp8_cost_bit(
+ get_pred_prob(cm, &x->e_mbd, PRED_MBSKIP), 0);
+#else
+ int prob_skip_cost = vp8_cost_bit(cpi->prob_skip_false, 0);
+#endif
+ rate2 += prob_skip_cost;
+ other_cost += prob_skip_cost;
}
+ }
- /* keep record of best compound/single-only prediction */
- if (!disable_skip &&
- x->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME)
- {
- int single_rd, hybrid_rd, single_rate, hybrid_rate;
-
- if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
- {
- single_rate = rate2 - compmode_cost;
- hybrid_rate = rate2;
- }
- else
- {
- single_rate = rate2;
- hybrid_rate = rate2 + compmode_cost;
- }
-
- single_rd = RDCOST(x->rdmult, x->rddiv, single_rate, distortion2);
- hybrid_rd = RDCOST(x->rdmult, x->rddiv, hybrid_rate, distortion2);
+ // Calculate the final RD estimate for this mode.
+ this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+ }
- if (x->e_mbd.mode_info_context->mbmi.second_ref_frame == INTRA_FRAME &&
- single_rd < best_single_rd)
- {
- best_single_rd = single_rd;
- }
- else if (x->e_mbd.mode_info_context->mbmi.second_ref_frame != INTRA_FRAME &&
- single_rd < best_comp_rd)
- {
- best_comp_rd = single_rd;
- }
- if (hybrid_rd < best_hybrid_rd)
- {
- best_hybrid_rd = hybrid_rd;
- }
- }
-#if CONFIG_PRED_FILTER
- }
-#endif
+ // Experimental debug code.
+ // all_rds[mode_index] = this_rd;
+ // all_rates[mode_index] = rate2;
+ // all_dist[mode_index] = distortion2;
- if (x->skip)
- break;
+ // Keep record of best intra distortion
+ if ((x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME) &&
+ (this_rd < best_intra_rd)) {
+ best_intra_rd = this_rd;
+ *returnintra = distortion2;
+ }
+ if (!disable_skip && x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
+ if (this_rd < best_comp_rd)
+ best_comp_rd = this_rd;
+ if (this_rd < best_single_rd)
+ best_single_rd = this_rd;
+ if (this_rd < best_hybrid_rd)
+ best_hybrid_rd = this_rd;
}
#if CONFIG_PRED_FILTER
- // Update counts for prediction filter usage
- if (best_filter_state != 0)
- ++cpi->pred_filter_on_count;
- else
- ++cpi->pred_filter_off_count;
-#endif
+ // Keep track of the best mode irrespective of prediction filter state
+ if (this_rd < best_overall_rd) {
+ best_overall_rd = this_rd;
+ best_filter_state = xd->mode_info_context->mbmi.pred_filter_enabled;
+ }
+
+ // Ignore modes where the prediction filter state doesn't
+ // match the state signaled at the frame level
+ if ((cm->pred_filter_mode == 2) ||
+ (cm->pred_filter_mode ==
+ xd->mode_info_context->mbmi.pred_filter_enabled)) {
+#endif
+ // Did this mode help.. i.e. is it the new best mode
+ if (this_rd < best_rd || x->skip) {
+ if (!mode_excluded) {
+ // Note index of best mode so far
+ best_mode_index = mode_index;
+
+ if (this_mode <= B_PRED) {
+ if (cpi->common.txfm_mode == ALLOW_8X8
+ && this_mode != B_PRED
+ && this_mode != I8X8_PRED)
+ x->e_mbd.mode_info_context->mbmi.uv_mode = uv_intra_mode_8x8;
+ else
+ x->e_mbd.mode_info_context->mbmi.uv_mode = uv_intra_mode;
+ /* required for left and above block mv */
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
+ }
- // Reduce the activation RD thresholds for the best choice mode
- if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
- {
- int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 2);
+ other_cost +=
+ ref_costs[x->e_mbd.mode_info_context->mbmi.ref_frame];
- cpi->rd_thresh_mult[best_mode_index] = (cpi->rd_thresh_mult[best_mode_index] >= (MIN_THRESHMULT + best_adjustment)) ? cpi->rd_thresh_mult[best_mode_index] - best_adjustment : MIN_THRESHMULT;
- cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
+ /* Calculate the final y RD estimate for this mode */
+ best_yrd = RDCOST(x->rdmult, x->rddiv, (rate2 - rate_uv - other_cost),
+ (distortion2 - distortion_uv));
- // If we chose a split mode then reset the new MV thresholds as well
- /*if ( vp8_mode_order[best_mode_index].mode == SPLITMV )
- {
- best_adjustment = 4; //(cpi->rd_thresh_mult[THR_NEWMV] >> 4);
- cpi->rd_thresh_mult[THR_NEWMV] = (cpi->rd_thresh_mult[THR_NEWMV] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWMV]-best_adjustment: MIN_THRESHMULT;
- cpi->rd_threshes[THR_NEWMV] = (cpi->rd_baseline_thresh[THR_NEWMV] >> 7) * cpi->rd_thresh_mult[THR_NEWMV];
+ *returnrate = rate2;
+ *returndistortion = distortion2;
+ best_rd = this_rd;
+ vpx_memcpy(&best_mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE_INFO));
+ vpx_memcpy(&best_partition, x->partition_info, sizeof(PARTITION_INFO));
- best_adjustment = 4; //(cpi->rd_thresh_mult[THR_NEWG] >> 4);
- cpi->rd_thresh_mult[THR_NEWG] = (cpi->rd_thresh_mult[THR_NEWG] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWG]-best_adjustment: MIN_THRESHMULT;
- cpi->rd_threshes[THR_NEWG] = (cpi->rd_baseline_thresh[THR_NEWG] >> 7) * cpi->rd_thresh_mult[THR_NEWG];
+ if ((this_mode == B_PRED)
+ || (this_mode == I8X8_PRED)
+ || (this_mode == SPLITMV))
+ for (i = 0; i < 16; i++) {
+ best_bmodes[i] = x->e_mbd.block[i].bmi;
+ }
+ }
- best_adjustment = 4; //(cpi->rd_thresh_mult[THR_NEWA] >> 4);
- cpi->rd_thresh_mult[THR_NEWA] = (cpi->rd_thresh_mult[THR_NEWA] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWA]-best_adjustment: MIN_THRESHMULT;
- cpi->rd_threshes[THR_NEWA] = (cpi->rd_baseline_thresh[THR_NEWA] >> 7) * cpi->rd_thresh_mult[THR_NEWA];
- }*/
+ // Testing this mode gave rise to an improvement in best error score. Lower threshold a bit for next time
+ cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
+ cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ }
+ // If the mode did not help improve the best error case then raise the threshold for testing that mode next time around.
+ else {
+ cpi->rd_thresh_mult[mode_index] += 4;
- }
+ if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
- // This code force Altref,0,0 and skip for the frame that overlays a
- // an alrtef unless Altref is filtered. However, this is unsafe if
- // segment level coding of ref frame or mode is enabled for this
- // segment.
- if (!segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
- !segfeature_active( xd, segment_id, SEG_LVL_MODE ) &&
- cpi->is_src_frame_alt_ref &&
- (cpi->oxcf.arnr_max_frames == 0) &&
- (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
- {
- x->e_mbd.mode_info_context->mbmi.mode = ZEROMV;
- x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME;
- x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
- x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
- x->e_mbd.mode_info_context->mbmi.mb_skip_coeff =
- (cpi->common.mb_no_coeff_skip) ? 1 : 0;
- x->e_mbd.mode_info_context->mbmi.partitioning = 0;
-
- *best_single_rd_diff = *best_comp_rd_diff = *best_hybrid_rd_diff = 0;
-
- store_coding_context (x, mb_index, best_mode_index, &best_partition,
- &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
- &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
- return;
- }
+ cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ }
- // macroblock modes
- vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+ /* keep record of best compound/single-only prediction */
+ if (!disable_skip &&
+ x->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME) {
+ int single_rd, hybrid_rd, single_rate, hybrid_rate;
- if (best_mbmode.mode == B_PRED)
- {
- for (i = 0; i < 16; i++)
- {
- xd->mode_info_context->bmi[i].as_mode = best_bmodes[i].as_mode;
- xd->block[i].bmi.as_mode = xd->mode_info_context->bmi[i].as_mode;
+ if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
+ single_rate = rate2 - compmode_cost;
+ hybrid_rate = rate2;
+ } else {
+ single_rate = rate2;
+ hybrid_rate = rate2 + compmode_cost;
}
- }
- if (best_mbmode.mode == I8X8_PRED)
- {
- set_i8x8_block_modes(x, mode8x8);
- }
-
- if (best_mbmode.mode == SPLITMV)
- {
- for (i = 0; i < 16; i++)
- xd->mode_info_context->bmi[i].as_mv.first.as_int = best_bmodes[i].as_mv.first.as_int;
- if (xd->mode_info_context->mbmi.second_ref_frame)
- for (i = 0; i < 16; i++)
- xd->mode_info_context->bmi[i].as_mv.second.as_int = best_bmodes[i].as_mv.second.as_int;
-
- vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
+ single_rd = RDCOST(x->rdmult, x->rddiv, single_rate, distortion2);
+ hybrid_rd = RDCOST(x->rdmult, x->rddiv, hybrid_rate, distortion2);
- x->e_mbd.mode_info_context->mbmi.mv.as_int =
- x->partition_info->bmi[15].mv.as_int;
- x->e_mbd.mode_info_context->mbmi.second_mv.as_int =
- x->partition_info->bmi[15].second_mv.as_int;
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame == INTRA_FRAME &&
+ single_rd < best_single_rd) {
+ best_single_rd = single_rd;
+ } else if (x->e_mbd.mode_info_context->mbmi.second_ref_frame != INTRA_FRAME &&
+ single_rd < best_comp_rd) {
+ best_comp_rd = single_rd;
+ }
+ if (hybrid_rd < best_hybrid_rd) {
+ best_hybrid_rd = hybrid_rd;
+ }
+ }
+#if CONFIG_PRED_FILTER
}
+#endif
- if (best_single_rd == INT_MAX)
- *best_single_rd_diff = INT_MIN;
- else
- *best_single_rd_diff = best_rd - best_single_rd;
- if (best_comp_rd == INT_MAX)
- *best_comp_rd_diff = INT_MIN;
- else
- *best_comp_rd_diff = best_rd - best_comp_rd;
- if (best_hybrid_rd == INT_MAX)
- *best_hybrid_rd_diff = INT_MIN;
- else
- *best_hybrid_rd_diff = best_rd - best_hybrid_rd;
+ if (x->skip)
+ break;
+
+ }
- store_coding_context (x, mb_index, best_mode_index, &best_partition,
- &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
- &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
+#if CONFIG_PRED_FILTER
+ // Update counts for prediction filter usage
+ if (best_filter_state != 0)
+ ++cpi->pred_filter_on_count;
+ else
+ ++cpi->pred_filter_off_count;
+#endif
+
+ // Reduce the activation RD thresholds for the best choice mode
+ if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2))) {
+ int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 2);
+
+ cpi->rd_thresh_mult[best_mode_index] = (cpi->rd_thresh_mult[best_mode_index] >= (MIN_THRESHMULT + best_adjustment)) ? cpi->rd_thresh_mult[best_mode_index] - best_adjustment : MIN_THRESHMULT;
+ cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
+
+ // If we chose a split mode then reset the new MV thresholds as well
+ /*if ( vp8_mode_order[best_mode_index].mode == SPLITMV )
+ {
+ best_adjustment = 4; // (cpi->rd_thresh_mult[THR_NEWMV] >> 4);
+ cpi->rd_thresh_mult[THR_NEWMV] = (cpi->rd_thresh_mult[THR_NEWMV] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWMV]-best_adjustment: MIN_THRESHMULT;
+ cpi->rd_threshes[THR_NEWMV] = (cpi->rd_baseline_thresh[THR_NEWMV] >> 7) * cpi->rd_thresh_mult[THR_NEWMV];
+
+ best_adjustment = 4; // (cpi->rd_thresh_mult[THR_NEWG] >> 4);
+ cpi->rd_thresh_mult[THR_NEWG] = (cpi->rd_thresh_mult[THR_NEWG] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWG]-best_adjustment: MIN_THRESHMULT;
+ cpi->rd_threshes[THR_NEWG] = (cpi->rd_baseline_thresh[THR_NEWG] >> 7) * cpi->rd_thresh_mult[THR_NEWG];
+
+ best_adjustment = 4; // (cpi->rd_thresh_mult[THR_NEWA] >> 4);
+ cpi->rd_thresh_mult[THR_NEWA] = (cpi->rd_thresh_mult[THR_NEWA] >= (MIN_THRESHMULT+best_adjustment)) ? cpi->rd_thresh_mult[THR_NEWA]-best_adjustment: MIN_THRESHMULT;
+ cpi->rd_threshes[THR_NEWA] = (cpi->rd_baseline_thresh[THR_NEWA] >> 7) * cpi->rd_thresh_mult[THR_NEWA];
+ }*/
+
+ }
+
+ // This code force Altref,0,0 and skip for the frame that overlays a
+ // an alrtef unless Altref is filtered. However, this is unsafe if
+ // segment level coding of ref frame or mode is enabled for this
+ // segment.
+ if (!segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME) &&
+ !segfeature_active(xd, segment_id, SEG_LVL_MODE) &&
+ cpi->is_src_frame_alt_ref &&
+ (cpi->oxcf.arnr_max_frames == 0) &&
+ (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME)) {
+ x->e_mbd.mode_info_context->mbmi.mode = ZEROMV;
+ x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME;
+ x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
+ x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
+ x->e_mbd.mode_info_context->mbmi.mb_skip_coeff =
+ (cpi->common.mb_no_coeff_skip) ? 1 : 0;
+ x->e_mbd.mode_info_context->mbmi.partitioning = 0;
+
+ *best_single_rd_diff = *best_comp_rd_diff = *best_hybrid_rd_diff = 0;
+
+ store_coding_context(x, mb_index, best_mode_index, &best_partition,
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
+ return;
+ }
+
+ // macroblock modes
+ vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+
+ if (best_mbmode.mode == B_PRED) {
+ for (i = 0; i < 16; i++) {
+ xd->mode_info_context->bmi[i].as_mode = best_bmodes[i].as_mode;
+ xd->block[i].bmi.as_mode = xd->mode_info_context->bmi[i].as_mode;
+ }
+ }
+
+ if (best_mbmode.mode == I8X8_PRED) {
+ set_i8x8_block_modes(x, mode8x8);
+ }
+
+ if (best_mbmode.mode == SPLITMV) {
+ for (i = 0; i < 16; i++)
+ xd->mode_info_context->bmi[i].as_mv.first.as_int = best_bmodes[i].as_mv.first.as_int;
+ if (xd->mode_info_context->mbmi.second_ref_frame)
+ for (i = 0; i < 16; i++)
+ xd->mode_info_context->bmi[i].as_mv.second.as_int = best_bmodes[i].as_mv.second.as_int;
+
+ vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
+
+ x->e_mbd.mode_info_context->mbmi.mv.as_int =
+ x->partition_info->bmi[15].mv.as_int;
+ x->e_mbd.mode_info_context->mbmi.second_mv.as_int =
+ x->partition_info->bmi[15].second_mv.as_int;
+ }
+
+ if (best_single_rd == INT_MAX)
+ *best_single_rd_diff = INT_MIN;
+ else
+ *best_single_rd_diff = best_rd - best_single_rd;
+ if (best_comp_rd == INT_MAX)
+ *best_comp_rd_diff = INT_MIN;
+ else
+ *best_comp_rd_diff = best_rd - best_comp_rd;
+ if (best_hybrid_rd == INT_MAX)
+ *best_hybrid_rd_diff = INT_MIN;
+ else
+ *best_hybrid_rd_diff = best_rd - best_hybrid_rd;
+
+ store_coding_context(x, mb_index, best_mode_index, &best_partition,
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
}
-int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x)
-{
- MACROBLOCKD *xd = &x->e_mbd;
- int error4x4, error16x16;
+int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x) {
+ MACROBLOCKD *xd = &x->e_mbd;
+ int error4x4, error16x16;
#if CONFIG_COMP_INTRA_PRED
- int error4x4d, rate4x4d, dist4x4d;
-#endif
- int rate4x4, rate16x16 = 0, rateuv;
- int dist4x4, dist16x16, distuv;
- int rate;
- int rate4x4_tokenonly = 0;
- int rate16x16_tokenonly = 0;
- int rateuv_tokenonly = 0;
- int error8x8, rate8x8_tokenonly=0;
- int rate8x8, dist8x8;
- int mode16x16;
- int mode8x8[2][4];
-
- xd->mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-
- rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
- rate = rateuv;
-
- error16x16 = rd_pick_intra16x16mby_mode(cpi, x,
- &rate16x16, &rate16x16_tokenonly,
- &dist16x16);
- mode16x16 = xd->mode_info_context->mbmi.mode;
-
- error8x8 = rd_pick_intra8x8mby_modes(cpi, x,
- &rate8x8, &rate8x8_tokenonly,
- &dist8x8, error16x16);
- mode8x8[0][0]= xd->mode_info_context->bmi[0].as_mode.first;
- mode8x8[0][1]= xd->mode_info_context->bmi[2].as_mode.first;
- mode8x8[0][2]= xd->mode_info_context->bmi[8].as_mode.first;
- mode8x8[0][3]= xd->mode_info_context->bmi[10].as_mode.first;
+ int error4x4d, rate4x4d, dist4x4d;
+#endif
+ int rate4x4, rate16x16 = 0, rateuv;
+ int dist4x4, dist16x16, distuv;
+ int rate;
+ int rate4x4_tokenonly = 0;
+ int rate16x16_tokenonly = 0;
+ int rateuv_tokenonly = 0;
+ int error8x8, rate8x8_tokenonly = 0;
+ int rate8x8, dist8x8;
+ int mode16x16;
+ int mode8x8[2][4];
+
+ xd->mode_info_context->mbmi.ref_frame = INTRA_FRAME;
+
+ rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
+ rate = rateuv;
+
+ error16x16 = rd_pick_intra16x16mby_mode(cpi, x,
+ &rate16x16, &rate16x16_tokenonly,
+ &dist16x16);
+ mode16x16 = xd->mode_info_context->mbmi.mode;
+
+ error8x8 = rd_pick_intra8x8mby_modes(cpi, x,
+ &rate8x8, &rate8x8_tokenonly,
+ &dist8x8, error16x16);
+ mode8x8[0][0] = xd->mode_info_context->bmi[0].as_mode.first;
+ mode8x8[0][1] = xd->mode_info_context->bmi[2].as_mode.first;
+ mode8x8[0][2] = xd->mode_info_context->bmi[8].as_mode.first;
+ mode8x8[0][3] = xd->mode_info_context->bmi[10].as_mode.first;
#if CONFIG_COMP_INTRA_PRED
- mode8x8[1][0]= xd->mode_info_context->bmi[0].as_mode.second;
- mode8x8[1][1]= xd->mode_info_context->bmi[2].as_mode.second;
- mode8x8[1][2]= xd->mode_info_context->bmi[8].as_mode.second;
- mode8x8[1][3]= xd->mode_info_context->bmi[10].as_mode.second;
+ mode8x8[1][0] = xd->mode_info_context->bmi[0].as_mode.second;
+ mode8x8[1][1] = xd->mode_info_context->bmi[2].as_mode.second;
+ mode8x8[1][2] = xd->mode_info_context->bmi[8].as_mode.second;
+ mode8x8[1][3] = xd->mode_info_context->bmi[10].as_mode.second;
#endif
- error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
- &rate4x4, &rate4x4_tokenonly,
- &dist4x4, error16x16,
+ error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
+ &rate4x4, &rate4x4_tokenonly,
+ &dist4x4, error16x16,
#if CONFIG_COMP_INTRA_PRED
- 0,
+ 0,
#endif
- 0);
+ 0);
#if CONFIG_COMP_INTRA_PRED
- error4x4d = rd_pick_intra4x4mby_modes(cpi, x,
- &rate4x4d, &rate4x4_tokenonly,
- &dist4x4d, error16x16, 1, 0);
+ error4x4d = rd_pick_intra4x4mby_modes(cpi, x,
+ &rate4x4d, &rate4x4_tokenonly,
+ &dist4x4d, error16x16, 1, 0);
#endif
- if(error8x8> error16x16)
- {
- if (error4x4 < error16x16)
- {
+ if (error8x8 > error16x16) {
+ if (error4x4 < error16x16) {
#if CONFIG_COMP_INTRA_PRED
- rate += (error4x4d < error4x4) ? rate4x4d : rate4x4;
- if (error4x4d >= error4x4) // FIXME save original modes etc.
- error4x4 = rd_pick_intra4x4mby_modes(cpi, x, &rate4x4,
- &rate4x4_tokenonly,
- &dist4x4, error16x16, 0,
- cpi->update_context);
+ rate += (error4x4d < error4x4) ? rate4x4d : rate4x4;
+ if (error4x4d >= error4x4) // FIXME save original modes etc.
+ error4x4 = rd_pick_intra4x4mby_modes(cpi, x, &rate4x4,
+ &rate4x4_tokenonly,
+ &dist4x4, error16x16, 0,
+ cpi->update_context);
#else
- rate += rate4x4;
+ rate += rate4x4;
#endif
- xd->mode_info_context->mbmi.mode = B_PRED;
- }
- else
- {
- xd->mode_info_context->mbmi.mode = mode16x16;
- rate += rate16x16;
+ xd->mode_info_context->mbmi.mode = B_PRED;
+ } else {
+ xd->mode_info_context->mbmi.mode = mode16x16;
+ rate += rate16x16;
- }
}
- else
- {
- if (error4x4 < error8x8)
- {
+ } else {
+ if (error4x4 < error8x8) {
#if CONFIG_COMP_INTRA_PRED
- rate += (error4x4d < error4x4) ? rate4x4d : rate4x4;
- if (error4x4d >= error4x4) // FIXME save original modes etc.
- error4x4 = rd_pick_intra4x4mby_modes(cpi, x, &rate4x4,
- &rate4x4_tokenonly,
- &dist4x4, error16x16, 0,
- cpi->update_context);
+ rate += (error4x4d < error4x4) ? rate4x4d : rate4x4;
+ if (error4x4d >= error4x4) // FIXME save original modes etc.
+ error4x4 = rd_pick_intra4x4mby_modes(cpi, x, &rate4x4,
+ &rate4x4_tokenonly,
+ &dist4x4, error16x16, 0,
+ cpi->update_context);
#else
- rate += rate4x4;
+ rate += rate4x4;
#endif
- xd->mode_info_context->mbmi.mode = B_PRED;
- }
- else
- {
+ xd->mode_info_context->mbmi.mode = B_PRED;
+ } else {
- xd->mode_info_context->mbmi.mode = I8X8_PRED;
- set_i8x8_block_modes(x, mode8x8);
- rate += rate8x8;
- }
+ xd->mode_info_context->mbmi.mode = I8X8_PRED;
+ set_i8x8_block_modes(x, mode8x8);
+ rate += rate8x8;
}
- return rate;
+ }
+ return rate;
}
int vp8cx_pick_mode_inter_macroblock
(
- VP8_COMP *cpi, MACROBLOCK *x,
- int recon_yoffset, int recon_uvoffset
-)
-{
- VP8_COMMON *cm = &cpi->common;
- MACROBLOCKD *const xd = &x->e_mbd;
- int rate;
- int distortion;
- int intra_error = 0;
- unsigned char *segment_id = &xd->mode_info_context->mbmi.segment_id;
+ VP8_COMP *cpi, MACROBLOCK *x,
+ int recon_yoffset, int recon_uvoffset
+) {
+ VP8_COMMON *cm = &cpi->common;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ int rate;
+ int distortion;
+ int intra_error = 0;
+ unsigned char *segment_id = &xd->mode_info_context->mbmi.segment_id;
#if CONFIG_COMPRED
- unsigned char ref_pred_flag;
-#endif
-
- if (xd->segmentation_enabled)
- x->encode_breakout = cpi->segment_encode_breakout[*segment_id];
- else
- x->encode_breakout = cpi->oxcf.encode_breakout;
-
- //if (cpi->sf.RD)
- // For now this codebase is limited to a single rd encode path
- {
- int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
- int single, compound, hybrid;
-
- vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate,
- &distortion, &intra_error, &single, &compound,
- &hybrid);
-
- // TODO Save these to add in only if MB coding mode is selected?
- cpi->rd_single_diff += single;
- cpi->rd_comp_diff += compound;
- cpi->rd_hybrid_diff += hybrid;
- if (xd->mode_info_context->mbmi.ref_frame)
- {
- unsigned char pred_context;
-
- pred_context = get_pred_context( cm, xd, PRED_COMP );
-
- if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)
- cpi->single_pred_count[pred_context]++;
- else
- cpi->comp_pred_count[pred_context]++;
- }
-
- /* test code: set transform size based on mode selection */
- if( cpi->common.txfm_mode == ALLOW_8X8
- && xd->mode_info_context->mbmi.mode != I8X8_PRED
- && xd->mode_info_context->mbmi.mode != B_PRED
- && xd->mode_info_context->mbmi.mode != SPLITMV)
- {
- xd->mode_info_context->mbmi.txfm_size = TX_8X8;
- cpi->t8x8_count ++;
- }
- else
- {
- xd->mode_info_context->mbmi.txfm_size = TX_4X4;
- cpi->t4x4_count++;
- }
-
- /* restore cpi->zbin_mode_boost_enabled */
- cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
- }
- //else
- // The non rd encode path has been deleted from this code base
- // to simplify development
- // vp8_pick_inter_mode
-
- // Store metrics so they can be added in to totals if this mode is picked
- x->mb_context[xd->mb_index].distortion = distortion;
- x->mb_context[xd->mb_index].intra_error = intra_error;
-
- return rate;
+ unsigned char ref_pred_flag;
+#endif
+
+ if (xd->segmentation_enabled)
+ x->encode_breakout = cpi->segment_encode_breakout[*segment_id];
+ else
+ x->encode_breakout = cpi->oxcf.encode_breakout;
+
+ // if (cpi->sf.RD)
+ // For now this codebase is limited to a single rd encode path
+ {
+ int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
+ int single, compound, hybrid;
+
+ vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate,
+ &distortion, &intra_error, &single, &compound,
+ &hybrid);
+
+ // TODO Save these to add in only if MB coding mode is selected?
+ cpi->rd_single_diff += single;
+ cpi->rd_comp_diff += compound;
+ cpi->rd_hybrid_diff += hybrid;
+ if (xd->mode_info_context->mbmi.ref_frame) {
+ unsigned char pred_context;
+
+ pred_context = get_pred_context(cm, xd, PRED_COMP);
+
+ if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)
+ cpi->single_pred_count[pred_context]++;
+ else
+ cpi->comp_pred_count[pred_context]++;
+ }
+
+ /* test code: set transform size based on mode selection */
+ if (cpi->common.txfm_mode == ALLOW_8X8
+ && xd->mode_info_context->mbmi.mode != I8X8_PRED
+ && xd->mode_info_context->mbmi.mode != B_PRED
+ && xd->mode_info_context->mbmi.mode != SPLITMV) {
+ xd->mode_info_context->mbmi.txfm_size = TX_8X8;
+ cpi->t8x8_count++;
+ } else {
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ cpi->t4x4_count++;
+ }
+
+ /* restore cpi->zbin_mode_boost_enabled */
+ cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
+ }
+ // else
+ // The non rd encode path has been deleted from this code base
+ // to simplify development
+ // vp8_pick_inter_mode
+
+ // Store metrics so they can be added in to totals if this mode is picked
+ x->mb_context[xd->mb_index].distortion = distortion;
+ x->mb_context[xd->mb_index].intra_error = intra_error;
+
+ return rate;
}
diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h
index 5e11c8d49..0077411d0 100644
--- a/vp8/encoder/rdopt.h
+++ b/vp8/encoder/rdopt.h
@@ -23,14 +23,14 @@ extern int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x);
extern void vp8_mv_pred
(
- VP8_COMP *cpi,
- MACROBLOCKD *xd,
- const MODE_INFO *here,
- int_mv *mvp,
- int refframe,
- int *ref_frame_sign_bias,
- int *sr,
- int near_sadidx[]
+ VP8_COMP *cpi,
+ MACROBLOCKD *xd,
+ const MODE_INFO *here,
+ int_mv *mvp,
+ int refframe,
+ int *ref_frame_sign_bias,
+ int *sr,
+ int near_sadidx[]
);
extern void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]);
extern void vp8_init_me_luts();
diff --git a/vp8/encoder/sad_c.c b/vp8/encoder/sad_c.c
index c734458a9..5ce13ec12 100644
--- a/vp8/encoder/sad_c.c
+++ b/vp8/encoder/sad_c.c
@@ -14,389 +14,362 @@
#include "vpx/vpx_integer.h"
unsigned int vp8_sad16x16_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int max_sad)
-{
-
- int r, c;
- unsigned int sad = 0;
-
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- sad += abs(src_ptr[c] - ref_ptr[c]);
- }
-
- src_ptr += src_stride;
- ref_ptr += ref_stride;
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int max_sad) {
+
+ int r, c;
+ unsigned int sad = 0;
+
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ sad += abs(src_ptr[c] - ref_ptr[c]);
}
- return sad;
+ src_ptr += src_stride;
+ ref_ptr += ref_stride;
+ }
+
+ return sad;
}
static __inline
unsigned int sad_mx_n_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int m,
- int n)
-{
-
- int r, c;
- unsigned int sad = 0;
-
- for (r = 0; r < n; r++)
- {
- for (c = 0; c < m; c++)
- {
- sad += abs(src_ptr[c] - ref_ptr[c]);
- }
-
- src_ptr += src_stride;
- ref_ptr += ref_stride;
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int m,
+ int n) {
+
+ int r, c;
+ unsigned int sad = 0;
+
+ for (r = 0; r < n; r++) {
+ for (c = 0; c < m; c++) {
+ sad += abs(src_ptr[c] - ref_ptr[c]);
}
- return sad;
+ src_ptr += src_stride;
+ ref_ptr += ref_stride;
+ }
+
+ return sad;
}
unsigned int vp8_sad8x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int max_sad)
-{
-
- return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 8);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int max_sad) {
+
+ return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 8);
}
unsigned int vp8_sad16x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int max_sad)
-{
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int max_sad) {
- return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 16, 8);
+ return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 16, 8);
}
unsigned int vp8_sad8x16_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int max_sad)
-{
-
- return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 16);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int max_sad) {
+
+ return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 16);
}
unsigned int vp8_sad4x4_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- int max_sad)
-{
-
- return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 4, 4);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ int max_sad) {
+
+ return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 4, 4);
}
void vp8_sad16x16x3_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
}
void vp8_sad16x16x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned short *sad_array
-)
-{
- sad_array[0] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
- sad_array[3] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 3 , ref_stride, 0x7fffffff);
- sad_array[4] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
- sad_array[5] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
- sad_array[6] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 6 , ref_stride, 0x7fffffff);
- sad_array[7] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned short *sad_array
+) {
+ sad_array[0] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ sad_array[3] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 3, ref_stride, 0x7fffffff);
+ sad_array[4] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
+ sad_array[5] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
+ sad_array[6] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 6, ref_stride, 0x7fffffff);
+ sad_array[7] = (unsigned short)vp8_sad16x16_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
}
void vp8_sad16x8x3_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
}
void vp8_sad16x8x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned short *sad_array
-)
-{
- sad_array[0] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
- sad_array[3] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 3 , ref_stride, 0x7fffffff);
- sad_array[4] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
- sad_array[5] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
- sad_array[6] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 6 , ref_stride, 0x7fffffff);
- sad_array[7] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned short *sad_array
+) {
+ sad_array[0] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ sad_array[3] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 3, ref_stride, 0x7fffffff);
+ sad_array[4] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
+ sad_array[5] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
+ sad_array[6] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 6, ref_stride, 0x7fffffff);
+ sad_array[7] = (unsigned short)vp8_sad16x8_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
}
void vp8_sad8x8x3_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
}
void vp8_sad8x8x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned short *sad_array
-)
-{
- sad_array[0] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
- sad_array[3] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 3 , ref_stride, 0x7fffffff);
- sad_array[4] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
- sad_array[5] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
- sad_array[6] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 6 , ref_stride, 0x7fffffff);
- sad_array[7] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned short *sad_array
+) {
+ sad_array[0] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ sad_array[3] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 3, ref_stride, 0x7fffffff);
+ sad_array[4] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
+ sad_array[5] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
+ sad_array[6] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 6, ref_stride, 0x7fffffff);
+ sad_array[7] = (unsigned short)vp8_sad8x8_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
}
void vp8_sad8x16x3_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
}
void vp8_sad8x16x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned short *sad_array
-)
-{
- sad_array[0] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
- sad_array[3] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 3 , ref_stride, 0x7fffffff);
- sad_array[4] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
- sad_array[5] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
- sad_array[6] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 6 , ref_stride, 0x7fffffff);
- sad_array[7] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned short *sad_array
+) {
+ sad_array[0] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ sad_array[3] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 3, ref_stride, 0x7fffffff);
+ sad_array[4] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
+ sad_array[5] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
+ sad_array[6] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 6, ref_stride, 0x7fffffff);
+ sad_array[7] = (unsigned short)vp8_sad8x16_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
}
void vp8_sad4x4x3_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
}
void vp8_sad4x4x8_c(
- const unsigned char *src_ptr,
- int src_stride,
- const unsigned char *ref_ptr,
- int ref_stride,
- unsigned short *sad_array
-)
-{
- sad_array[0] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr , ref_stride, 0x7fffffff);
- sad_array[1] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
- sad_array[2] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
- sad_array[3] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 3 , ref_stride, 0x7fffffff);
- sad_array[4] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
- sad_array[5] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
- sad_array[6] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 6 , ref_stride, 0x7fffffff);
- sad_array[7] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ const unsigned char *ref_ptr,
+ int ref_stride,
+ unsigned short *sad_array
+) {
+ sad_array[0] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr, ref_stride, 0x7fffffff);
+ sad_array[1] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 1, ref_stride, 0x7fffffff);
+ sad_array[2] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 2, ref_stride, 0x7fffffff);
+ sad_array[3] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 3, ref_stride, 0x7fffffff);
+ sad_array[4] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 4, ref_stride, 0x7fffffff);
+ sad_array[5] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 5, ref_stride, 0x7fffffff);
+ sad_array[6] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 6, ref_stride, 0x7fffffff);
+ sad_array[7] = (unsigned short)vp8_sad4x4_c(src_ptr, src_stride, ref_ptr + 7, ref_stride, 0x7fffffff);
}
void vp8_sad16x16x4d_c(
- const unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr[],
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
- sad_array[3] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr[],
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
+ sad_array[3] = vp8_sad16x16_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
}
void vp8_sad16x8x4d_c(
- const unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr[],
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
- sad_array[3] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr[],
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
+ sad_array[3] = vp8_sad16x8_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
}
void vp8_sad8x8x4d_c(
- const unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr[],
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
- sad_array[3] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr[],
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
+ sad_array[3] = vp8_sad8x8_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
}
void vp8_sad8x16x4d_c(
- const unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr[],
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
- sad_array[3] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr[],
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
+ sad_array[3] = vp8_sad8x16_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
}
void vp8_sad4x4x4d_c(
- const unsigned char *src_ptr,
- int src_stride,
- unsigned char *ref_ptr[],
- int ref_stride,
- unsigned int *sad_array
-)
-{
- sad_array[0] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
- sad_array[1] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
- sad_array[2] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
- sad_array[3] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
+ const unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *ref_ptr[],
+ int ref_stride,
+ unsigned int *sad_array
+) {
+ sad_array[0] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[0], ref_stride, 0x7fffffff);
+ sad_array[1] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[1], ref_stride, 0x7fffffff);
+ sad_array[2] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[2], ref_stride, 0x7fffffff);
+ sad_array[3] = vp8_sad4x4_c(src_ptr, src_stride, ref_ptr[3], ref_stride, 0x7fffffff);
}
/* Copy 2 macroblocks to a buffer */
void vp8_copy32xn_c(
- unsigned char *src_ptr,
- int src_stride,
- unsigned char *dst_ptr,
- int dst_stride,
- int height)
-{
- int r;
-
- for (r = 0; r < height; r++)
- {
+ unsigned char *src_ptr,
+ int src_stride,
+ unsigned char *dst_ptr,
+ int dst_stride,
+ int height) {
+ int r;
+
+ for (r = 0; r < height; r++) {
#if !(CONFIG_FAST_UNALIGNED)
- dst_ptr[0] = src_ptr[0];
- dst_ptr[1] = src_ptr[1];
- dst_ptr[2] = src_ptr[2];
- dst_ptr[3] = src_ptr[3];
- dst_ptr[4] = src_ptr[4];
- dst_ptr[5] = src_ptr[5];
- dst_ptr[6] = src_ptr[6];
- dst_ptr[7] = src_ptr[7];
- dst_ptr[8] = src_ptr[8];
- dst_ptr[9] = src_ptr[9];
- dst_ptr[10] = src_ptr[10];
- dst_ptr[11] = src_ptr[11];
- dst_ptr[12] = src_ptr[12];
- dst_ptr[13] = src_ptr[13];
- dst_ptr[14] = src_ptr[14];
- dst_ptr[15] = src_ptr[15];
- dst_ptr[16] = src_ptr[16];
- dst_ptr[17] = src_ptr[17];
- dst_ptr[18] = src_ptr[18];
- dst_ptr[19] = src_ptr[19];
- dst_ptr[20] = src_ptr[20];
- dst_ptr[21] = src_ptr[21];
- dst_ptr[22] = src_ptr[22];
- dst_ptr[23] = src_ptr[23];
- dst_ptr[24] = src_ptr[24];
- dst_ptr[25] = src_ptr[25];
- dst_ptr[26] = src_ptr[26];
- dst_ptr[27] = src_ptr[27];
- dst_ptr[28] = src_ptr[28];
- dst_ptr[29] = src_ptr[29];
- dst_ptr[30] = src_ptr[30];
- dst_ptr[31] = src_ptr[31];
+ dst_ptr[0] = src_ptr[0];
+ dst_ptr[1] = src_ptr[1];
+ dst_ptr[2] = src_ptr[2];
+ dst_ptr[3] = src_ptr[3];
+ dst_ptr[4] = src_ptr[4];
+ dst_ptr[5] = src_ptr[5];
+ dst_ptr[6] = src_ptr[6];
+ dst_ptr[7] = src_ptr[7];
+ dst_ptr[8] = src_ptr[8];
+ dst_ptr[9] = src_ptr[9];
+ dst_ptr[10] = src_ptr[10];
+ dst_ptr[11] = src_ptr[11];
+ dst_ptr[12] = src_ptr[12];
+ dst_ptr[13] = src_ptr[13];
+ dst_ptr[14] = src_ptr[14];
+ dst_ptr[15] = src_ptr[15];
+ dst_ptr[16] = src_ptr[16];
+ dst_ptr[17] = src_ptr[17];
+ dst_ptr[18] = src_ptr[18];
+ dst_ptr[19] = src_ptr[19];
+ dst_ptr[20] = src_ptr[20];
+ dst_ptr[21] = src_ptr[21];
+ dst_ptr[22] = src_ptr[22];
+ dst_ptr[23] = src_ptr[23];
+ dst_ptr[24] = src_ptr[24];
+ dst_ptr[25] = src_ptr[25];
+ dst_ptr[26] = src_ptr[26];
+ dst_ptr[27] = src_ptr[27];
+ dst_ptr[28] = src_ptr[28];
+ dst_ptr[29] = src_ptr[29];
+ dst_ptr[30] = src_ptr[30];
+ dst_ptr[31] = src_ptr[31];
#else
- ((uint32_t *)dst_ptr)[0] = ((uint32_t *)src_ptr)[0] ;
- ((uint32_t *)dst_ptr)[1] = ((uint32_t *)src_ptr)[1] ;
- ((uint32_t *)dst_ptr)[2] = ((uint32_t *)src_ptr)[2] ;
- ((uint32_t *)dst_ptr)[3] = ((uint32_t *)src_ptr)[3] ;
- ((uint32_t *)dst_ptr)[4] = ((uint32_t *)src_ptr)[4] ;
- ((uint32_t *)dst_ptr)[5] = ((uint32_t *)src_ptr)[5] ;
- ((uint32_t *)dst_ptr)[6] = ((uint32_t *)src_ptr)[6] ;
- ((uint32_t *)dst_ptr)[7] = ((uint32_t *)src_ptr)[7] ;
+ ((uint32_t *)dst_ptr)[0] = ((uint32_t *)src_ptr)[0];
+ ((uint32_t *)dst_ptr)[1] = ((uint32_t *)src_ptr)[1];
+ ((uint32_t *)dst_ptr)[2] = ((uint32_t *)src_ptr)[2];
+ ((uint32_t *)dst_ptr)[3] = ((uint32_t *)src_ptr)[3];
+ ((uint32_t *)dst_ptr)[4] = ((uint32_t *)src_ptr)[4];
+ ((uint32_t *)dst_ptr)[5] = ((uint32_t *)src_ptr)[5];
+ ((uint32_t *)dst_ptr)[6] = ((uint32_t *)src_ptr)[6];
+ ((uint32_t *)dst_ptr)[7] = ((uint32_t *)src_ptr)[7];
#endif
- src_ptr += src_stride;
- dst_ptr += dst_stride;
+ src_ptr += src_stride;
+ dst_ptr += dst_stride;
- }
+ }
}
diff --git a/vp8/encoder/satd_c.c b/vp8/encoder/satd_c.c
index 88c304b1f..2ce1b9937 100644
--- a/vp8/encoder/satd_c.c
+++ b/vp8/encoder/satd_c.c
@@ -16,38 +16,33 @@ unsigned int vp8_satd16x16_c(const unsigned char *src_ptr,
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
- unsigned int *psatd)
-{
- int r, c, i;
- unsigned int satd = 0;
- DECLARE_ALIGNED(16, short, diff_in[256]);
- DECLARE_ALIGNED(16, short, diff_out[16]);
- short *in;
+ unsigned int *psatd) {
+ int r, c, i;
+ unsigned int satd = 0;
+ DECLARE_ALIGNED(16, short, diff_in[256]);
+ DECLARE_ALIGNED(16, short, diff_out[16]);
+ short *in;
- for (r = 0; r < 16; r++)
- {
- for (c = 0; c < 16; c++)
- {
- diff_in[r * 16 + c] = src_ptr[c] - ref_ptr[c];
- }
- src_ptr += src_stride;
- ref_ptr += ref_stride;
+ for (r = 0; r < 16; r++) {
+ for (c = 0; c < 16; c++) {
+ diff_in[r * 16 + c] = src_ptr[c] - ref_ptr[c];
}
+ src_ptr += src_stride;
+ ref_ptr += ref_stride;
+ }
- in = diff_in;
- for (r = 0; r < 16; r += 4)
- {
- for (c = 0; c < 16; c+=4)
- {
- vp8_short_walsh4x4_c(in + c, diff_out, 32);
- for(i = 0; i < 16; i++)
- satd += abs(diff_out[i]);
- }
- in += 64;
+ in = diff_in;
+ for (r = 0; r < 16; r += 4) {
+ for (c = 0; c < 16; c += 4) {
+ vp8_short_walsh4x4_c(in + c, diff_out, 32);
+ for (i = 0; i < 16; i++)
+ satd += abs(diff_out[i]);
}
+ in += 64;
+ }
- if (psatd)
- *psatd = satd;
+ if (psatd)
+ *psatd = satd;
- return satd;
+ return satd;
}
diff --git a/vp8/encoder/segmentation.c b/vp8/encoder/segmentation.c
index c36246a02..83b27a6e9 100644
--- a/vp8/encoder/segmentation.c
+++ b/vp8/encoder/segmentation.c
@@ -14,304 +14,276 @@
#include "segmentation.h"
#include "vp8/common/pred_common.h"
-void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x)
-{
- int mb_row, mb_col;
+void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x) {
+ int mb_row, mb_col;
+
+ MODE_INFO *this_mb_mode_info = cm->mi;
+
+ x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
+
+ if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) {
+ // Reset Gf useage monitors
+ vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
+ cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
+ } else {
+ // for each macroblock row in image
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ // for each macroblock col in image
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+
+ // If using golden then set GF active flag if not already set.
+ // If using last frame 0,0 mode then leave flag as it is
+ // else if using non 0,0 motion or intra modes then clear
+ // flag if it is currently set
+ if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) ||
+ (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME)) {
+ if (*(x->gf_active_ptr) == 0) {
+ *(x->gf_active_ptr) = 1;
+ cpi->gf_active_count++;
+ }
+ } else if ((this_mb_mode_info->mbmi.mode != ZEROMV) &&
+ *(x->gf_active_ptr)) {
+ *(x->gf_active_ptr) = 0;
+ cpi->gf_active_count--;
+ }
- MODE_INFO *this_mb_mode_info = cm->mi;
+ x->gf_active_ptr++; // Step onto next entry
+ this_mb_mode_info++; // skip to next mb
- x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
+ }
- if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame))
- {
- // Reset Gf useage monitors
- vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
- cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
- }
- else
- {
- // for each macroblock row in image
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- // for each macroblock col in image
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
-
- // If using golden then set GF active flag if not already set.
- // If using last frame 0,0 mode then leave flag as it is
- // else if using non 0,0 motion or intra modes then clear
- // flag if it is currently set
- if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) ||
- (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME))
- {
- if (*(x->gf_active_ptr) == 0)
- {
- *(x->gf_active_ptr) = 1;
- cpi->gf_active_count ++;
- }
- }
- else if ((this_mb_mode_info->mbmi.mode != ZEROMV) &&
- *(x->gf_active_ptr))
- {
- *(x->gf_active_ptr) = 0;
- cpi->gf_active_count--;
- }
-
- x->gf_active_ptr++; // Step onto next entry
- this_mb_mode_info++; // skip to next mb
-
- }
-
- // this is to account for the border
- this_mb_mode_info++;
- }
+ // this is to account for the border
+ this_mb_mode_info++;
}
+ }
}
-void vp8_enable_segmentation(VP8_PTR ptr)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+void vp8_enable_segmentation(VP8_PTR ptr) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- // Set the appropriate feature bit
- cpi->mb.e_mbd.segmentation_enabled = 1;
- cpi->mb.e_mbd.update_mb_segmentation_map = 1;
- cpi->mb.e_mbd.update_mb_segmentation_data = 1;
+ // Set the appropriate feature bit
+ cpi->mb.e_mbd.segmentation_enabled = 1;
+ cpi->mb.e_mbd.update_mb_segmentation_map = 1;
+ cpi->mb.e_mbd.update_mb_segmentation_data = 1;
}
-void vp8_disable_segmentation(VP8_PTR ptr)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+void vp8_disable_segmentation(VP8_PTR ptr) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- // Clear the appropriate feature bit
- cpi->mb.e_mbd.segmentation_enabled = 0;
+ // Clear the appropriate feature bit
+ cpi->mb.e_mbd.segmentation_enabled = 0;
}
void vp8_set_segmentation_map(VP8_PTR ptr,
- unsigned char *segmentation_map)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ unsigned char *segmentation_map) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- // Copy in the new segmentation map
- vpx_memcpy( cpi->segmentation_map, segmentation_map,
- (cpi->common.mb_rows * cpi->common.mb_cols) );
+ // Copy in the new segmentation map
+ vpx_memcpy(cpi->segmentation_map, segmentation_map,
+ (cpi->common.mb_rows * cpi->common.mb_cols));
- // Signal that the map should be updated.
- cpi->mb.e_mbd.update_mb_segmentation_map = 1;
- cpi->mb.e_mbd.update_mb_segmentation_data = 1;
+ // Signal that the map should be updated.
+ cpi->mb.e_mbd.update_mb_segmentation_map = 1;
+ cpi->mb.e_mbd.update_mb_segmentation_data = 1;
}
void vp8_set_segment_data(VP8_PTR ptr,
signed char *feature_data,
- unsigned char abs_delta)
-{
- VP8_COMP *cpi = (VP8_COMP *)(ptr);
+ unsigned char abs_delta) {
+ VP8_COMP *cpi = (VP8_COMP *)(ptr);
- cpi->mb.e_mbd.mb_segment_abs_delta = abs_delta;
+ cpi->mb.e_mbd.mb_segment_abs_delta = abs_delta;
- vpx_memcpy(cpi->mb.e_mbd.segment_feature_data, feature_data,
- sizeof(cpi->mb.e_mbd.segment_feature_data));
+ vpx_memcpy(cpi->mb.e_mbd.segment_feature_data, feature_data,
+ sizeof(cpi->mb.e_mbd.segment_feature_data));
- // TBD ?? Set the feature mask
- // vpx_memcpy(cpi->mb.e_mbd.segment_feature_mask, 0,
- // sizeof(cpi->mb.e_mbd.segment_feature_mask));
+ // TBD ?? Set the feature mask
+ // vpx_memcpy(cpi->mb.e_mbd.segment_feature_mask, 0,
+ // sizeof(cpi->mb.e_mbd.segment_feature_mask));
}
// Based on set of segment counts calculate a probability tree
-static void calc_segtree_probs( MACROBLOCKD * xd,
- int * segcounts,
- vp8_prob * segment_tree_probs )
-{
- int count1,count2;
- int tot_count;
- int i;
-
- // Blank the strtucture to start with
- vpx_memset(segment_tree_probs, 0, sizeof(segment_tree_probs));
-
- // Total count for all segments
- count1 = segcounts[0] + segcounts[1];
- count2 = segcounts[2] + segcounts[3];
- tot_count = count1 + count2;
-
- // Work out probabilities of each segment
- if (tot_count)
- segment_tree_probs[0] = (count1 * 255) / tot_count;
- if (count1 > 0)
- segment_tree_probs[1] = (segcounts[0] * 255) / count1;
- if (count2 > 0)
- segment_tree_probs[2] = (segcounts[2] * 255) / count2;
-
- // Clamp probabilities to minimum allowed value
- for (i = 0; i < MB_FEATURE_TREE_PROBS; i++)
- {
- if (segment_tree_probs[i] == 0)
- segment_tree_probs[i] = 1;
- }
+static void calc_segtree_probs(MACROBLOCKD *xd,
+ int *segcounts,
+ vp8_prob *segment_tree_probs) {
+ int count1, count2;
+ int tot_count;
+ int i;
+
+ // Blank the strtucture to start with
+ vpx_memset(segment_tree_probs, 0, sizeof(segment_tree_probs));
+
+ // Total count for all segments
+ count1 = segcounts[0] + segcounts[1];
+ count2 = segcounts[2] + segcounts[3];
+ tot_count = count1 + count2;
+
+ // Work out probabilities of each segment
+ if (tot_count)
+ segment_tree_probs[0] = (count1 * 255) / tot_count;
+ if (count1 > 0)
+ segment_tree_probs[1] = (segcounts[0] * 255) / count1;
+ if (count2 > 0)
+ segment_tree_probs[2] = (segcounts[2] * 255) / count2;
+
+ // Clamp probabilities to minimum allowed value
+ for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
+ if (segment_tree_probs[i] == 0)
+ segment_tree_probs[i] = 1;
+ }
}
// Based on set of segment counts and probabilities calculate a cost estimate
-static int cost_segmap( MACROBLOCKD * xd,
- int * segcounts,
- vp8_prob * probs )
-{
- int cost;
- int count1,count2;
-
- // Cost the top node of the tree
- count1 = segcounts[0] + segcounts[1];
- count2 = segcounts[2] + segcounts[3];
- cost = count1 * vp8_cost_zero(probs[0]) +
- count2 * vp8_cost_one(probs[0]);
-
- // Now add the cost of each individual segment branch
- if (count1 > 0)
- cost += segcounts[0] * vp8_cost_zero(probs[1]) +
- segcounts[1] * vp8_cost_one(probs[1]);
-
- if (count2 > 0)
- cost += segcounts[2] * vp8_cost_zero(probs[2]) +
- segcounts[3] * vp8_cost_one(probs[2]) ;
-
- return cost;
+static int cost_segmap(MACROBLOCKD *xd,
+ int *segcounts,
+ vp8_prob *probs) {
+ int cost;
+ int count1, count2;
-}
+ // Cost the top node of the tree
+ count1 = segcounts[0] + segcounts[1];
+ count2 = segcounts[2] + segcounts[3];
+ cost = count1 * vp8_cost_zero(probs[0]) +
+ count2 * vp8_cost_one(probs[0]);
-void choose_segmap_coding_method( VP8_COMP *cpi )
-{
- VP8_COMMON *const cm = & cpi->common;
- MACROBLOCKD *const xd = & cpi->mb.e_mbd;
-
- int i;
- int tot_count;
- int no_pred_cost;
- int t_pred_cost = INT_MAX;
- int pred_context;
-
- int mb_row, mb_col;
- int segmap_index = 0;
- unsigned char segment_id;
-
- int temporal_predictor_count[PREDICTION_PROBS][2];
- int no_pred_segcounts[MAX_MB_SEGMENTS];
- int t_unpred_seg_counts[MAX_MB_SEGMENTS];
-
- vp8_prob no_pred_tree[MB_FEATURE_TREE_PROBS];
- vp8_prob t_pred_tree[MB_FEATURE_TREE_PROBS];
- vp8_prob t_nopred_prob[PREDICTION_PROBS];
-
- // Set default state for the segment tree probabilities and the
- // temporal coding probabilities
- vpx_memset(xd->mb_segment_tree_probs, 255,
- sizeof(xd->mb_segment_tree_probs));
- vpx_memset(cm->segment_pred_probs, 255,
- sizeof(cm->segment_pred_probs));
-
- vpx_memset(no_pred_segcounts, 0, sizeof(no_pred_segcounts));
- vpx_memset(t_unpred_seg_counts, 0, sizeof(t_unpred_seg_counts));
- vpx_memset(temporal_predictor_count, 0, sizeof(temporal_predictor_count));
-
- // First of all generate stats regarding how well the last segment map
- // predicts this one
-
- // Initialize macroblock decoder mode info context for the first mb
- // in the frame
- xd->mode_info_context = cm->mi;
-
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- segment_id = xd->mode_info_context->mbmi.segment_id;
-
- // Count the number of hits on each segment with no prediction
- no_pred_segcounts[segment_id]++;
-
- // Temporal prediction not allowed on key frames
- if (cm->frame_type != KEY_FRAME)
- {
- // Test to see if the segment id matches the predicted value.
- int seg_predicted =
- (segment_id == get_pred_mb_segid( cm, segmap_index ));
-
- // Get the segment id prediction context
- pred_context =
- get_pred_context( cm, xd, PRED_SEG_ID );
-
- // Store the prediction status for this mb and update counts
- // as appropriate
- set_pred_flag( xd, PRED_SEG_ID, seg_predicted );
- temporal_predictor_count[pred_context][seg_predicted]++;
-
- if ( !seg_predicted )
- // Update the "unpredicted" segment count
- t_unpred_seg_counts[segment_id]++;
- }
-
- // Step on to the next mb
- xd->mode_info_context++;
-
- // Step on to the next entry in the segment maps
- segmap_index++;
- }
+ // Now add the cost of each individual segment branch
+ if (count1 > 0)
+ cost += segcounts[0] * vp8_cost_zero(probs[1]) +
+ segcounts[1] * vp8_cost_one(probs[1]);
- // this is to account for the border in mode_info_context
- xd->mode_info_context++;
- }
+ if (count2 > 0)
+ cost += segcounts[2] * vp8_cost_zero(probs[2]) +
+ segcounts[3] * vp8_cost_one(probs[2]);
- // Work out probability tree for coding segments without prediction
- // and the cost.
- calc_segtree_probs( xd, no_pred_segcounts, no_pred_tree );
- no_pred_cost = cost_segmap( xd, no_pred_segcounts, no_pred_tree );
-
- // Key frames cannot use temporal prediction
- if (cm->frame_type != KEY_FRAME)
- {
- // Work out probability tree for coding those segments not
- // predicted using the temporal method and the cost.
- calc_segtree_probs( xd, t_unpred_seg_counts, t_pred_tree );
- t_pred_cost = cost_segmap( xd, t_unpred_seg_counts, t_pred_tree );
-
- // Add in the cost of the signalling for each prediction context
- for ( i = 0; i < PREDICTION_PROBS; i++ )
- {
- tot_count = temporal_predictor_count[i][0] +
- temporal_predictor_count[i][1];
-
- // Work out the context probabilities for the segment
- // prediction flag
- if ( tot_count )
- {
- t_nopred_prob[i] = ( temporal_predictor_count[i][0] * 255 ) /
- tot_count;
-
- // Clamp to minimum allowed value
- if ( t_nopred_prob[i] < 1 )
- t_nopred_prob[i] = 1;
- }
- else
- t_nopred_prob[i] = 1;
-
- // Add in the predictor signaling cost
- t_pred_cost += ( temporal_predictor_count[i][0] *
- vp8_cost_zero(t_nopred_prob[i]) ) +
- ( temporal_predictor_count[i][1] *
- vp8_cost_one(t_nopred_prob[i]) );
- }
- }
+ return cost;
- // Now choose which coding method to use.
- if ( t_pred_cost < no_pred_cost )
- {
- cm->temporal_update = 1;
- vpx_memcpy( xd->mb_segment_tree_probs,
- t_pred_tree, sizeof(t_pred_tree) );
- vpx_memcpy( &cm->segment_pred_probs,
- t_nopred_prob, sizeof(t_nopred_prob) );
+}
+
+void choose_segmap_coding_method(VP8_COMP *cpi) {
+ VP8_COMMON *const cm = & cpi->common;
+ MACROBLOCKD *const xd = & cpi->mb.e_mbd;
+
+ int i;
+ int tot_count;
+ int no_pred_cost;
+ int t_pred_cost = INT_MAX;
+ int pred_context;
+
+ int mb_row, mb_col;
+ int segmap_index = 0;
+ unsigned char segment_id;
+
+ int temporal_predictor_count[PREDICTION_PROBS][2];
+ int no_pred_segcounts[MAX_MB_SEGMENTS];
+ int t_unpred_seg_counts[MAX_MB_SEGMENTS];
+
+ vp8_prob no_pred_tree[MB_FEATURE_TREE_PROBS];
+ vp8_prob t_pred_tree[MB_FEATURE_TREE_PROBS];
+ vp8_prob t_nopred_prob[PREDICTION_PROBS];
+
+ // Set default state for the segment tree probabilities and the
+ // temporal coding probabilities
+ vpx_memset(xd->mb_segment_tree_probs, 255,
+ sizeof(xd->mb_segment_tree_probs));
+ vpx_memset(cm->segment_pred_probs, 255,
+ sizeof(cm->segment_pred_probs));
+
+ vpx_memset(no_pred_segcounts, 0, sizeof(no_pred_segcounts));
+ vpx_memset(t_unpred_seg_counts, 0, sizeof(t_unpred_seg_counts));
+ vpx_memset(temporal_predictor_count, 0, sizeof(temporal_predictor_count));
+
+ // First of all generate stats regarding how well the last segment map
+ // predicts this one
+
+ // Initialize macroblock decoder mode info context for the first mb
+ // in the frame
+ xd->mode_info_context = cm->mi;
+
+ for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
+ segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ // Count the number of hits on each segment with no prediction
+ no_pred_segcounts[segment_id]++;
+
+ // Temporal prediction not allowed on key frames
+ if (cm->frame_type != KEY_FRAME) {
+ // Test to see if the segment id matches the predicted value.
+ int seg_predicted =
+ (segment_id == get_pred_mb_segid(cm, segmap_index));
+
+ // Get the segment id prediction context
+ pred_context =
+ get_pred_context(cm, xd, PRED_SEG_ID);
+
+ // Store the prediction status for this mb and update counts
+ // as appropriate
+ set_pred_flag(xd, PRED_SEG_ID, seg_predicted);
+ temporal_predictor_count[pred_context][seg_predicted]++;
+
+ if (!seg_predicted)
+ // Update the "unpredicted" segment count
+ t_unpred_seg_counts[segment_id]++;
+ }
+
+ // Step on to the next mb
+ xd->mode_info_context++;
+
+ // Step on to the next entry in the segment maps
+ segmap_index++;
}
- else
- {
- cm->temporal_update = 0;
- vpx_memcpy( xd->mb_segment_tree_probs,
- no_pred_tree, sizeof(no_pred_tree) );
+
+ // this is to account for the border in mode_info_context
+ xd->mode_info_context++;
+ }
+
+ // Work out probability tree for coding segments without prediction
+ // and the cost.
+ calc_segtree_probs(xd, no_pred_segcounts, no_pred_tree);
+ no_pred_cost = cost_segmap(xd, no_pred_segcounts, no_pred_tree);
+
+ // Key frames cannot use temporal prediction
+ if (cm->frame_type != KEY_FRAME) {
+ // Work out probability tree for coding those segments not
+ // predicted using the temporal method and the cost.
+ calc_segtree_probs(xd, t_unpred_seg_counts, t_pred_tree);
+ t_pred_cost = cost_segmap(xd, t_unpred_seg_counts, t_pred_tree);
+
+ // Add in the cost of the signalling for each prediction context
+ for (i = 0; i < PREDICTION_PROBS; i++) {
+ tot_count = temporal_predictor_count[i][0] +
+ temporal_predictor_count[i][1];
+
+ // Work out the context probabilities for the segment
+ // prediction flag
+ if (tot_count) {
+ t_nopred_prob[i] = (temporal_predictor_count[i][0] * 255) /
+ tot_count;
+
+ // Clamp to minimum allowed value
+ if (t_nopred_prob[i] < 1)
+ t_nopred_prob[i] = 1;
+ } else
+ t_nopred_prob[i] = 1;
+
+ // Add in the predictor signaling cost
+ t_pred_cost += (temporal_predictor_count[i][0] *
+ vp8_cost_zero(t_nopred_prob[i])) +
+ (temporal_predictor_count[i][1] *
+ vp8_cost_one(t_nopred_prob[i]));
}
+ }
+
+ // Now choose which coding method to use.
+ if (t_pred_cost < no_pred_cost) {
+ cm->temporal_update = 1;
+ vpx_memcpy(xd->mb_segment_tree_probs,
+ t_pred_tree, sizeof(t_pred_tree));
+ vpx_memcpy(&cm->segment_pred_probs,
+ t_nopred_prob, sizeof(t_nopred_prob));
+ } else {
+ cm->temporal_update = 0;
+ vpx_memcpy(xd->mb_segment_tree_probs,
+ no_pred_tree, sizeof(no_pred_tree));
+ }
}
diff --git a/vp8/encoder/segmentation.h b/vp8/encoder/segmentation.h
index a7e1f7cfe..80e09fabb 100644
--- a/vp8/encoder/segmentation.h
+++ b/vp8/encoder/segmentation.h
@@ -28,9 +28,9 @@ extern void vp8_set_segmentation_map(VP8_PTR ptr, unsigned char *segmentation_ma
// The values given for each segment can be either deltas (from the default
// value chosen for the frame) or absolute values.
//
-// Valid range for abs values is (0-127 for MB_LVL_ALT_Q) , (0-63 for
+// Valid range for abs values is (0-127 for MB_LVL_ALT_Q), (0-63 for
// SEGMENT_ALT_LF)
-// Valid range for delta values are (+/-127 for MB_LVL_ALT_Q) , (+/-63 for
+// Valid range for delta values are (+/-127 for MB_LVL_ALT_Q), (+/-63 for
// SEGMENT_ALT_LF)
//
// abs_delta = SEGMENT_DELTADATA (deltas) abs_delta = SEGMENT_ABSDATA (use
@@ -38,6 +38,6 @@ extern void vp8_set_segmentation_map(VP8_PTR ptr, unsigned char *segmentation_ma
//
extern void vp8_set_segment_data(VP8_PTR ptr, signed char *feature_data, unsigned char abs_delta);
-extern void choose_segmap_coding_method( VP8_COMP *cpi );
+extern void choose_segmap_coding_method(VP8_COMP *cpi);
#endif /* __INC_SEGMENTATION_H__ */
diff --git a/vp8/encoder/ssim.c b/vp8/encoder/ssim.c
index d0f8e490a..d3d9711dc 100644
--- a/vp8/encoder/ssim.c
+++ b/vp8/encoder/ssim.c
@@ -13,55 +13,49 @@
void vp8_ssim_parms_16x16_c
(
- unsigned char *s,
- int sp,
- unsigned char *r,
- int rp,
- unsigned long *sum_s,
- unsigned long *sum_r,
- unsigned long *sum_sq_s,
- unsigned long *sum_sq_r,
- unsigned long *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];
- }
- }
+ unsigned char *s,
+ int sp,
+ unsigned char *r,
+ int rp,
+ unsigned long *sum_s,
+ unsigned long *sum_r,
+ unsigned long *sum_sq_s,
+ unsigned long *sum_sq_r,
+ unsigned long *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];
+ }
+ }
}
void vp8_ssim_parms_8x8_c
(
- unsigned char *s,
- int sp,
- unsigned char *r,
- int rp,
- unsigned long *sum_s,
- unsigned long *sum_r,
- unsigned long *sum_sq_s,
- unsigned long *sum_sq_r,
- unsigned long *sum_sxr
-)
-{
- int i,j;
- for(i=0;i<8;i++,s+=sp,r+=rp)
- {
- for(j=0;j<8;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];
- }
- }
+ unsigned char *s,
+ int sp,
+ unsigned char *r,
+ int rp,
+ unsigned long *sum_s,
+ unsigned long *sum_r,
+ unsigned long *sum_sq_s,
+ unsigned long *sum_sq_r,
+ unsigned long *sum_sxr
+) {
+ int i, j;
+ for (i = 0; i < 8; i++, s += sp, r += rp) {
+ for (j = 0; j < 8; 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];
+ }
+ }
}
const static int64_t cc1 = 26634; // (64^2*(.01*255)^2
@@ -69,79 +63,75 @@ const static int64_t cc2 = 239708; // (64^2*(.03*255)^2
static double similarity
(
- unsigned long sum_s,
- unsigned long sum_r,
- unsigned long sum_sq_s,
- unsigned long sum_sq_r,
- unsigned long sum_sxr,
- int count
-)
-{
- int64_t ssim_n, ssim_d;
- int64_t c1, c2;
-
- //scale the constants by number of pixels
- c1 = (cc1*count*count)>>12;
- c2 = (cc2*count*count)>>12;
-
- ssim_n = (2*sum_s*sum_r+ c1)*((int64_t) 2*count*sum_sxr-
- (int64_t) 2*sum_s*sum_r+c2);
-
- ssim_d = (sum_s*sum_s +sum_r*sum_r+c1)*
- ((int64_t)count*sum_sq_s-(int64_t)sum_s*sum_s +
- (int64_t)count*sum_sq_r-(int64_t) sum_r*sum_r +c2) ;
-
- return ssim_n * 1.0 / ssim_d;
+ unsigned long sum_s,
+ unsigned long sum_r,
+ unsigned long sum_sq_s,
+ unsigned long sum_sq_r,
+ unsigned long sum_sxr,
+ int count
+) {
+ int64_t ssim_n, ssim_d;
+ int64_t c1, c2;
+
+ // scale the constants by number of pixels
+ c1 = (cc1 * count * count) >> 12;
+ c2 = (cc2 * count * count) >> 12;
+
+ ssim_n = (2 * sum_s * sum_r + c1) * ((int64_t) 2 * count * sum_sxr -
+ (int64_t) 2 * sum_s * sum_r + c2);
+
+ ssim_d = (sum_s * sum_s + sum_r * sum_r + c1) *
+ ((int64_t)count * sum_sq_s - (int64_t)sum_s * sum_s +
+ (int64_t)count * sum_sq_r - (int64_t) sum_r * sum_r + c2);
+
+ return ssim_n * 1.0 / ssim_d;
}
-static double ssim_16x16(unsigned char *s,int sp, unsigned char *r,int rp,
- const vp8_variance_rtcd_vtable_t *rtcd)
-{
- unsigned long sum_s=0,sum_r=0,sum_sq_s=0,sum_sq_r=0,sum_sxr=0;
- SSIMPF_INVOKE(rtcd,16x16)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
- return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 256);
+static double ssim_16x16(unsigned char *s, int sp, unsigned char *r, int rp,
+ const vp8_variance_rtcd_vtable_t *rtcd) {
+ unsigned long sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
+ SSIMPF_INVOKE(rtcd, 16x16)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
+ return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 256);
}
-static double ssim_8x8(unsigned char *s,int sp, unsigned char *r,int rp,
- const vp8_variance_rtcd_vtable_t *rtcd)
-{
- unsigned long sum_s=0,sum_r=0,sum_sq_s=0,sum_sq_r=0,sum_sxr=0;
- SSIMPF_INVOKE(rtcd,8x8)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
- return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 64);
+static double ssim_8x8(unsigned char *s, int sp, unsigned char *r, int rp,
+ const vp8_variance_rtcd_vtable_t *rtcd) {
+ unsigned long sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
+ SSIMPF_INVOKE(rtcd, 8x8)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
+ return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 64);
}
// TODO: (jbb) tried to scale this function such that we may be able to use it
// for distortion metric in mode selection code ( provided we do a reconstruction)
-long dssim(unsigned char *s,int sp, unsigned char *r,int rp,
- const vp8_variance_rtcd_vtable_t *rtcd)
-{
- unsigned long sum_s=0,sum_r=0,sum_sq_s=0,sum_sq_r=0,sum_sxr=0;
- int64_t ssim3;
- int64_t ssim_n1,ssim_n2;
- int64_t ssim_d1,ssim_d2;
- int64_t ssim_t1,ssim_t2;
- int64_t c1, c2;
+long dssim(unsigned char *s, int sp, unsigned char *r, int rp,
+ const vp8_variance_rtcd_vtable_t *rtcd) {
+ unsigned long sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
+ int64_t ssim3;
+ int64_t ssim_n1, ssim_n2;
+ int64_t ssim_d1, ssim_d2;
+ int64_t ssim_t1, ssim_t2;
+ int64_t c1, c2;
- // normalize by 256/64
- c1 = cc1*16;
- c2 = cc2*16;
+ // normalize by 256/64
+ c1 = cc1 * 16;
+ c2 = cc2 * 16;
- SSIMPF_INVOKE(rtcd,16x16)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
- ssim_n1 = (2*sum_s*sum_r+ c1);
+ SSIMPF_INVOKE(rtcd, 16x16)(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr);
+ ssim_n1 = (2 * sum_s * sum_r + c1);
- ssim_n2 =((int64_t) 2*256*sum_sxr-(int64_t) 2*sum_s*sum_r+c2);
+ ssim_n2 = ((int64_t) 2 * 256 * sum_sxr - (int64_t) 2 * sum_s * sum_r + c2);
- ssim_d1 =((int64_t)sum_s*sum_s +(int64_t)sum_r*sum_r+c1);
+ ssim_d1 = ((int64_t)sum_s * sum_s + (int64_t)sum_r * sum_r + c1);
- ssim_d2 = (256 * (int64_t) sum_sq_s-(int64_t) sum_s*sum_s +
- (int64_t) 256*sum_sq_r-(int64_t) sum_r*sum_r +c2) ;
+ ssim_d2 = (256 * (int64_t) sum_sq_s - (int64_t) sum_s * sum_s +
+ (int64_t) 256 * sum_sq_r - (int64_t) sum_r * sum_r + c2);
- ssim_t1 = 256 - 256 * ssim_n1 / ssim_d1;
- ssim_t2 = 256 - 256 * ssim_n2 / ssim_d2;
+ ssim_t1 = 256 - 256 * ssim_n1 / ssim_d1;
+ ssim_t2 = 256 - 256 * ssim_n2 / ssim_d2;
- ssim3 = 256 *ssim_t1 * ssim_t2;
- if(ssim3 <0 )
- ssim3=0;
- return (long)( ssim3 );
+ ssim3 = 256 * ssim_t1 * ssim_t2;
+ if (ssim3 < 0)
+ ssim3 = 0;
+ return (long)(ssim3);
}
// We are using a 8x8 moving window with starting location of each 8x8 window
@@ -149,91 +139,86 @@ long dssim(unsigned char *s,int sp, unsigned char *r,int rp,
// block boundaries to penalize blocking artifacts.
double vp8_ssim2
(
- unsigned char *img1,
- unsigned char *img2,
- int stride_img1,
- int stride_img2,
- int width,
- int height,
- const vp8_variance_rtcd_vtable_t *rtcd
-)
-{
- int i,j;
- int samples =0;
- double ssim_total=0;
-
- // sample point start with each 4x4 location
- for(i=0; i < height-8; i+=4, img1 += stride_img1*4, img2 += stride_img2*4)
- {
- for(j=0; j < width-8; j+=4 )
- {
- double v = ssim_8x8(img1+j, stride_img1, img2+j, stride_img2, rtcd);
- ssim_total += v;
- samples++;
- }
+ unsigned char *img1,
+ unsigned char *img2,
+ int stride_img1,
+ int stride_img2,
+ int width,
+ int height,
+ const vp8_variance_rtcd_vtable_t *rtcd
+) {
+ int i, j;
+ int samples = 0;
+ double ssim_total = 0;
+
+ // sample point start with each 4x4 location
+ for (i = 0; i < height - 8; i += 4, img1 += stride_img1 * 4, img2 += stride_img2 * 4) {
+ for (j = 0; j < width - 8; j += 4) {
+ double v = ssim_8x8(img1 + j, stride_img1, img2 + j, stride_img2, rtcd);
+ ssim_total += v;
+ samples++;
}
- ssim_total /= samples;
- return ssim_total;
+ }
+ ssim_total /= samples;
+ return ssim_total;
}
double vp8_calc_ssim
(
- YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest,
- int lumamask,
- double *weight,
- const vp8_variance_rtcd_vtable_t *rtcd
-)
-{
- double a, b, c;
- double ssimv;
+ YV12_BUFFER_CONFIG *source,
+ YV12_BUFFER_CONFIG *dest,
+ int lumamask,
+ double *weight,
+ const vp8_variance_rtcd_vtable_t *rtcd
+) {
+ double a, b, c;
+ double ssimv;
- a = vp8_ssim2(source->y_buffer, dest->y_buffer,
- source->y_stride, dest->y_stride, source->y_width,
- source->y_height, rtcd);
+ a = vp8_ssim2(source->y_buffer, dest->y_buffer,
+ source->y_stride, dest->y_stride, source->y_width,
+ source->y_height, rtcd);
- b = vp8_ssim2(source->u_buffer, dest->u_buffer,
- source->uv_stride, dest->uv_stride, source->uv_width,
- source->uv_height, rtcd);
+ b = vp8_ssim2(source->u_buffer, dest->u_buffer,
+ source->uv_stride, dest->uv_stride, source->uv_width,
+ source->uv_height, rtcd);
- c = vp8_ssim2(source->v_buffer, dest->v_buffer,
- source->uv_stride, dest->uv_stride, source->uv_width,
- source->uv_height, rtcd);
+ c = vp8_ssim2(source->v_buffer, dest->v_buffer,
+ source->uv_stride, dest->uv_stride, source->uv_width,
+ source->uv_height, rtcd);
- ssimv = a * .8 + .1 * (b + c);
+ ssimv = a * .8 + .1 * (b + c);
- *weight = 1;
+ *weight = 1;
- return ssimv;
+ return ssimv;
}
double vp8_calc_ssimg
(
- YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest,
- double *ssim_y,
- double *ssim_u,
- double *ssim_v,
- const vp8_variance_rtcd_vtable_t *rtcd
-)
-{
- double ssim_all = 0;
- double a, b, c;
-
- a = vp8_ssim2(source->y_buffer, dest->y_buffer,
- source->y_stride, dest->y_stride, source->y_width,
- source->y_height, rtcd);
-
- b = vp8_ssim2(source->u_buffer, dest->u_buffer,
- source->uv_stride, dest->uv_stride, source->uv_width,
- source->uv_height, rtcd);
-
- c = vp8_ssim2(source->v_buffer, dest->v_buffer,
- source->uv_stride, dest->uv_stride, source->uv_width,
- source->uv_height, rtcd);
- *ssim_y = a;
- *ssim_u = b;
- *ssim_v = c;
- ssim_all = (a * 4 + b + c) /6;
-
- return ssim_all;
+ YV12_BUFFER_CONFIG *source,
+ YV12_BUFFER_CONFIG *dest,
+ double *ssim_y,
+ double *ssim_u,
+ double *ssim_v,
+ const vp8_variance_rtcd_vtable_t *rtcd
+) {
+ double ssim_all = 0;
+ double a, b, c;
+
+ a = vp8_ssim2(source->y_buffer, dest->y_buffer,
+ source->y_stride, dest->y_stride, source->y_width,
+ source->y_height, rtcd);
+
+ b = vp8_ssim2(source->u_buffer, dest->u_buffer,
+ source->uv_stride, dest->uv_stride, source->uv_width,
+ source->uv_height, rtcd);
+
+ c = vp8_ssim2(source->v_buffer, dest->v_buffer,
+ source->uv_stride, dest->uv_stride, source->uv_width,
+ source->uv_height, rtcd);
+ *ssim_y = a;
+ *ssim_u = b;
+ *ssim_v = c;
+ ssim_all = (a * 4 + b + c) / 6;
+
+ return ssim_all;
}
diff --git a/vp8/encoder/temporal_filter.c b/vp8/encoder/temporal_filter.c
index 564be41f1..964f4c856 100644
--- a/vp8/encoder/temporal_filter.c
+++ b/vp8/encoder/temporal_filter.c
@@ -39,520 +39,491 @@
static void vp8_temporal_filter_predictors_mb_c
(
- MACROBLOCKD *x,
- unsigned char *y_mb_ptr,
- unsigned char *u_mb_ptr,
- unsigned char *v_mb_ptr,
- int stride,
- int mv_row,
- int mv_col,
- unsigned char *pred
-)
-{
- int offset;
- unsigned char *yptr, *uptr, *vptr;
- int omv_row, omv_col;
-
- // Y
- yptr = y_mb_ptr + (mv_row >> 3) * stride + (mv_col >> 3);
-
- if ((mv_row | mv_col) & 7)
- {
+ MACROBLOCKD *x,
+ unsigned char *y_mb_ptr,
+ unsigned char *u_mb_ptr,
+ unsigned char *v_mb_ptr,
+ int stride,
+ int mv_row,
+ int mv_col,
+ unsigned char *pred
+) {
+ int offset;
+ unsigned char *yptr, *uptr, *vptr;
+ int omv_row, omv_col;
+
+ // Y
+ yptr = y_mb_ptr + (mv_row >> 3) * stride + (mv_col >> 3);
+
+ if ((mv_row | mv_col) & 7) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- x->subpixel_predict16x16(yptr, stride,
- (mv_col & 7)<<1, (mv_row & 7)<<1, &pred[0], 16);
+ x->subpixel_predict16x16(yptr, stride,
+ (mv_col & 7) << 1, (mv_row & 7) << 1, &pred[0], 16);
#else
- x->subpixel_predict16x16(yptr, stride,
- mv_col & 7, mv_row & 7, &pred[0], 16);
+ x->subpixel_predict16x16(yptr, stride,
+ mv_col & 7, mv_row & 7, &pred[0], 16);
#endif
- }
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy16x16)(yptr, stride, &pred[0], 16);
- }
-
- // U & V
- omv_row = mv_row;
- omv_col = mv_col;
- mv_row >>= 1;
- mv_col >>= 1;
- stride = (stride + 1) >> 1;
- offset = (mv_row >> 3) * stride + (mv_col >> 3);
- uptr = u_mb_ptr + offset;
- vptr = v_mb_ptr + offset;
+ } else {
+ RECON_INVOKE(&x->rtcd->recon, copy16x16)(yptr, stride, &pred[0], 16);
+ }
+
+ // U & V
+ omv_row = mv_row;
+ omv_col = mv_col;
+ mv_row >>= 1;
+ mv_col >>= 1;
+ stride = (stride + 1) >> 1;
+ offset = (mv_row >> 3) * stride + (mv_col >> 3);
+ uptr = u_mb_ptr + offset;
+ vptr = v_mb_ptr + offset;
#if CONFIG_SIXTEENTH_SUBPEL_UV
- if ((omv_row | omv_col) & 15)
- {
- x->subpixel_predict8x8(uptr, stride,
- (omv_col & 15), (omv_row & 15), &pred[256], 8);
- x->subpixel_predict8x8(vptr, stride,
- (omv_col & 15), (omv_row & 15), &pred[320], 8);
- }
+ if ((omv_row | omv_col) & 15) {
+ x->subpixel_predict8x8(uptr, stride,
+ (omv_col & 15), (omv_row & 15), &pred[256], 8);
+ x->subpixel_predict8x8(vptr, stride,
+ (omv_col & 15), (omv_row & 15), &pred[320], 8);
+ }
#else
- if ((mv_row | mv_col) & 7)
- {
- x->subpixel_predict8x8(uptr, stride,
- mv_col & 7, mv_row & 7, &pred[256], 8);
- x->subpixel_predict8x8(vptr, stride,
- mv_col & 7, mv_row & 7, &pred[320], 8);
- }
+ if ((mv_row | mv_col) & 7) {
+ x->subpixel_predict8x8(uptr, stride,
+ mv_col & 7, mv_row & 7, &pred[256], 8);
+ x->subpixel_predict8x8(vptr, stride,
+ mv_col & 7, mv_row & 7, &pred[320], 8);
+ }
#endif
- else
- {
- RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, stride, &pred[256], 8);
- RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, stride, &pred[320], 8);
- }
+ else {
+ RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, stride, &pred[256], 8);
+ RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, stride, &pred[320], 8);
+ }
}
void vp8_temporal_filter_apply_c
(
- unsigned char *frame1,
- unsigned int stride,
- unsigned char *frame2,
- unsigned int block_size,
- int strength,
- int filter_weight,
- unsigned int *accumulator,
- unsigned short *count
-)
-{
- unsigned int i, j, k;
- int modifier;
- int byte = 0;
-
- for (i = 0,k = 0; i < block_size; i++)
- {
- for (j = 0; j < block_size; j++, k++)
- {
-
- int src_byte = frame1[byte];
- int pixel_value = *frame2++;
-
- modifier = src_byte - pixel_value;
- // This is an integer approximation of:
- // float coeff = (3.0 * modifer * modifier) / pow(2, strength);
- // modifier = (int)roundf(coeff > 16 ? 0 : 16-coeff);
- modifier *= modifier;
- modifier *= 3;
- modifier += 1 << (strength - 1);
- modifier >>= strength;
-
- if (modifier > 16)
- modifier = 16;
-
- modifier = 16 - modifier;
- modifier *= filter_weight;
-
- count[k] += modifier;
- accumulator[k] += modifier * pixel_value;
-
- byte++;
- }
-
- byte += stride - block_size;
+ unsigned char *frame1,
+ unsigned int stride,
+ unsigned char *frame2,
+ unsigned int block_size,
+ int strength,
+ int filter_weight,
+ unsigned int *accumulator,
+ unsigned short *count
+) {
+ unsigned int i, j, k;
+ int modifier;
+ int byte = 0;
+
+ for (i = 0, k = 0; i < block_size; i++) {
+ for (j = 0; j < block_size; j++, k++) {
+
+ int src_byte = frame1[byte];
+ int pixel_value = *frame2++;
+
+ modifier = src_byte - pixel_value;
+ // This is an integer approximation of:
+ // float coeff = (3.0 * modifer * modifier) / pow(2, strength);
+ // modifier = (int)roundf(coeff > 16 ? 0 : 16-coeff);
+ modifier *= modifier;
+ modifier *= 3;
+ modifier += 1 << (strength - 1);
+ modifier >>= strength;
+
+ if (modifier > 16)
+ modifier = 16;
+
+ modifier = 16 - modifier;
+ modifier *= filter_weight;
+
+ count[k] += modifier;
+ accumulator[k] += modifier * pixel_value;
+
+ byte++;
}
+
+ byte += stride - block_size;
+ }
}
#if ALT_REF_MC_ENABLED
static int vp8_temporal_filter_find_matching_mb_c
(
- VP8_COMP *cpi,
- YV12_BUFFER_CONFIG *arf_frame,
- YV12_BUFFER_CONFIG *frame_ptr,
- int mb_offset,
- int error_thresh
-)
-{
- MACROBLOCK *x = &cpi->mb;
- int step_param;
- int further_steps;
- int sadpb = x->sadperbit16;
- int bestsme = INT_MAX;
-
- BLOCK *b = &x->block[0];
- BLOCKD *d = &x->e_mbd.block[0];
- int_mv best_ref_mv1;
- int_mv best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
-
- // Save input state
- unsigned char **base_src = b->base_src;
- int src = b->src;
- int src_stride = b->src_stride;
- unsigned char **base_pre = d->base_pre;
- int pre = d->pre;
- int pre_stride = d->pre_stride;
-
- best_ref_mv1.as_int = 0;
- best_ref_mv1_full.as_mv.col = best_ref_mv1.as_mv.col >>3;
- best_ref_mv1_full.as_mv.row = best_ref_mv1.as_mv.row >>3;
-
- // Setup frame pointers
- b->base_src = &arf_frame->y_buffer;
- b->src_stride = arf_frame->y_stride;
- b->src = mb_offset;
-
- d->base_pre = &frame_ptr->y_buffer;
- d->pre_stride = frame_ptr->y_stride;
- d->pre = mb_offset;
-
- // Further step/diamond searches as necessary
- if (cpi->Speed < 8)
- {
- step_param = cpi->sf.first_step +
- ((cpi->Speed > 5) ? 1 : 0);
- further_steps =
- (cpi->sf.max_step_search_steps - 1)-step_param;
- }
- else
- {
- step_param = cpi->sf.first_step + 2;
- further_steps = 0;
- }
-
- /*cpi->sf.search_method == HEX*/
- // TODO Check that the 16x16 vf & sdf are selected here
- // Ignore mv costing by sending NULL pointer instead of cost arrays
- bestsme = vp8_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first,
- step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16],
- NULL, NULL, &best_ref_mv1);
+ VP8_COMP *cpi,
+ YV12_BUFFER_CONFIG *arf_frame,
+ YV12_BUFFER_CONFIG *frame_ptr,
+ int mb_offset,
+ int error_thresh
+) {
+ MACROBLOCK *x = &cpi->mb;
+ int step_param;
+ int further_steps;
+ int sadpb = x->sadperbit16;
+ int bestsme = INT_MAX;
+
+ BLOCK *b = &x->block[0];
+ BLOCKD *d = &x->e_mbd.block[0];
+ int_mv best_ref_mv1;
+ int_mv best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
+
+ // Save input state
+ unsigned char **base_src = b->base_src;
+ int src = b->src;
+ int src_stride = b->src_stride;
+ unsigned char **base_pre = d->base_pre;
+ int pre = d->pre;
+ int pre_stride = d->pre_stride;
+
+ best_ref_mv1.as_int = 0;
+ best_ref_mv1_full.as_mv.col = best_ref_mv1.as_mv.col >> 3;
+ best_ref_mv1_full.as_mv.row = best_ref_mv1.as_mv.row >> 3;
+
+ // Setup frame pointers
+ b->base_src = &arf_frame->y_buffer;
+ b->src_stride = arf_frame->y_stride;
+ b->src = mb_offset;
+
+ d->base_pre = &frame_ptr->y_buffer;
+ d->pre_stride = frame_ptr->y_stride;
+ d->pre = mb_offset;
+
+ // Further step/diamond searches as necessary
+ if (cpi->Speed < 8) {
+ step_param = cpi->sf.first_step +
+ ((cpi->Speed > 5) ? 1 : 0);
+ further_steps =
+ (cpi->sf.max_step_search_steps - 1) - step_param;
+ } else {
+ step_param = cpi->sf.first_step + 2;
+ further_steps = 0;
+ }
+
+ /*cpi->sf.search_method == HEX*/
+ // TODO Check that the 16x16 vf & sdf are selected here
+ // Ignore mv costing by sending NULL pointer instead of cost arrays
+ bestsme = vp8_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first,
+ step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16],
+ NULL, NULL, &best_ref_mv1);
#if ALT_REF_SUBPEL_ENABLED
- // Try sub-pixel MC?
- //if (bestsme > error_thresh && bestsme < INT_MAX)
- {
- int distortion;
- unsigned int sse;
- // Ignore mv costing by sending NULL pointer instead of cost array
- bestsme = cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first,
- &best_ref_mv1,
- x->errorperbit,
- &cpi->fn_ptr[BLOCK_16X16],
- NULL, &distortion, &sse);
- }
+ // Try sub-pixel MC?
+ // if (bestsme > error_thresh && bestsme < INT_MAX)
+ {
+ int distortion;
+ unsigned int sse;
+ // Ignore mv costing by sending NULL pointer instead of cost array
+ bestsme = cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first,
+ &best_ref_mv1,
+ x->errorperbit,
+ &cpi->fn_ptr[BLOCK_16X16],
+ NULL, &distortion, &sse);
+ }
#endif
- // Save input state
- b->base_src = base_src;
- b->src = src;
- b->src_stride = src_stride;
- d->base_pre = base_pre;
- d->pre = pre;
- d->pre_stride = pre_stride;
+ // Save input state
+ b->base_src = base_src;
+ b->src = src;
+ b->src_stride = src_stride;
+ d->base_pre = base_pre;
+ d->pre = pre;
+ d->pre_stride = pre_stride;
- return bestsme;
+ return bestsme;
}
#endif
static void vp8_temporal_filter_iterate_c
(
- VP8_COMP *cpi,
- int frame_count,
- int alt_ref_index,
- int strength
-)
-{
- int byte;
- int frame;
- int mb_col, mb_row;
- unsigned int filter_weight;
- int mb_cols = cpi->common.mb_cols;
- int mb_rows = cpi->common.mb_rows;
- int mb_y_offset = 0;
- int mb_uv_offset = 0;
- DECLARE_ALIGNED_ARRAY(16, unsigned int, accumulator, 16*16 + 8*8 + 8*8);
- DECLARE_ALIGNED_ARRAY(16, unsigned short, count, 16*16 + 8*8 + 8*8);
- MACROBLOCKD *mbd = &cpi->mb.e_mbd;
- YV12_BUFFER_CONFIG *f = cpi->frames[alt_ref_index];
- unsigned char *dst1, *dst2;
- DECLARE_ALIGNED_ARRAY(16, unsigned char, predictor, 16*16 + 8*8 + 8*8);
-
- // Save input state
- unsigned char *y_buffer = mbd->pre.y_buffer;
- unsigned char *u_buffer = mbd->pre.u_buffer;
- unsigned char *v_buffer = mbd->pre.v_buffer;
-
- for (mb_row = 0; mb_row < mb_rows; mb_row++)
- {
+ VP8_COMP *cpi,
+ int frame_count,
+ int alt_ref_index,
+ int strength
+) {
+ int byte;
+ int frame;
+ int mb_col, mb_row;
+ unsigned int filter_weight;
+ int mb_cols = cpi->common.mb_cols;
+ int mb_rows = cpi->common.mb_rows;
+ int mb_y_offset = 0;
+ int mb_uv_offset = 0;
+ DECLARE_ALIGNED_ARRAY(16, unsigned int, accumulator, 16 * 16 + 8 * 8 + 8 * 8);
+ DECLARE_ALIGNED_ARRAY(16, unsigned short, count, 16 * 16 + 8 * 8 + 8 * 8);
+ MACROBLOCKD *mbd = &cpi->mb.e_mbd;
+ YV12_BUFFER_CONFIG *f = cpi->frames[alt_ref_index];
+ unsigned char *dst1, *dst2;
+ DECLARE_ALIGNED_ARRAY(16, unsigned char, predictor, 16 * 16 + 8 * 8 + 8 * 8);
+
+ // Save input state
+ unsigned char *y_buffer = mbd->pre.y_buffer;
+ unsigned char *u_buffer = mbd->pre.u_buffer;
+ unsigned char *v_buffer = mbd->pre.v_buffer;
+
+ for (mb_row = 0; mb_row < mb_rows; mb_row++) {
#if ALT_REF_MC_ENABLED
- // Source frames are extended to 16 pixels. This is different than
- // L/A/G reference frames that have a border of 32 (VP8BORDERINPIXELS)
- // A 6/8 tap filter is used for motion search. This requires 2 pixels
- // before and 3 pixels after. So the largest Y mv on a border would
- // then be 16 - INTERP_EXTEND. The UV blocks are half the size of the Y and
- // therefore only extended by 8. The largest mv that a UV block
- // can support is 8 - INTERP_EXTEND. A UV mv is half of a Y mv.
- // (16 - INTERP_EXTEND) >> 1 which is greater than 8 - INTERP_EXTEND.
- // To keep the mv in play for both Y and UV planes the max that it
- // can be on a border is therefore 16 - (2*INTERP_EXTEND+1).
- cpi->mb.mv_row_min = -((mb_row * 16) + (17 - 2*INTERP_EXTEND));
- cpi->mb.mv_row_max = ((cpi->common.mb_rows - 1 - mb_row) * 16)
- + (17 - 2*INTERP_EXTEND);
+ // Source frames are extended to 16 pixels. This is different than
+ // L/A/G reference frames that have a border of 32 (VP8BORDERINPIXELS)
+ // A 6/8 tap filter is used for motion search. This requires 2 pixels
+ // before and 3 pixels after. So the largest Y mv on a border would
+ // then be 16 - INTERP_EXTEND. The UV blocks are half the size of the Y and
+ // therefore only extended by 8. The largest mv that a UV block
+ // can support is 8 - INTERP_EXTEND. A UV mv is half of a Y mv.
+ // (16 - INTERP_EXTEND) >> 1 which is greater than 8 - INTERP_EXTEND.
+ // To keep the mv in play for both Y and UV planes the max that it
+ // can be on a border is therefore 16 - (2*INTERP_EXTEND+1).
+ cpi->mb.mv_row_min = -((mb_row * 16) + (17 - 2 * INTERP_EXTEND));
+ cpi->mb.mv_row_max = ((cpi->common.mb_rows - 1 - mb_row) * 16)
+ + (17 - 2 * INTERP_EXTEND);
#endif
- for (mb_col = 0; mb_col < mb_cols; mb_col++)
- {
- int i, j, k;
- int stride;
+ for (mb_col = 0; mb_col < mb_cols; mb_col++) {
+ int i, j, k;
+ int stride;
- vpx_memset(accumulator, 0, 384*sizeof(unsigned int));
- vpx_memset(count, 0, 384*sizeof(unsigned short));
+ vpx_memset(accumulator, 0, 384 * sizeof(unsigned int));
+ vpx_memset(count, 0, 384 * sizeof(unsigned short));
#if ALT_REF_MC_ENABLED
- cpi->mb.mv_col_min = -((mb_col * 16) + (17 - 2*INTERP_EXTEND));
- cpi->mb.mv_col_max = ((cpi->common.mb_cols - 1 - mb_col) * 16)
- + (17 - 2*INTERP_EXTEND);
+ cpi->mb.mv_col_min = -((mb_col * 16) + (17 - 2 * INTERP_EXTEND));
+ cpi->mb.mv_col_max = ((cpi->common.mb_cols - 1 - mb_col) * 16)
+ + (17 - 2 * INTERP_EXTEND);
#endif
- for (frame = 0; frame < frame_count; frame++)
- {
- if (cpi->frames[frame] == NULL)
- continue;
-
- mbd->block[0].bmi.as_mv.first.as_mv.row = 0;
- mbd->block[0].bmi.as_mv.first.as_mv.col = 0;
-
- if (frame == alt_ref_index)
- {
- filter_weight = 2;
- }
- else
- {
- int err = 0;
+ for (frame = 0; frame < frame_count; frame++) {
+ if (cpi->frames[frame] == NULL)
+ continue;
+
+ mbd->block[0].bmi.as_mv.first.as_mv.row = 0;
+ mbd->block[0].bmi.as_mv.first.as_mv.col = 0;
+
+ if (frame == alt_ref_index) {
+ filter_weight = 2;
+ } else {
+ int err = 0;
#if ALT_REF_MC_ENABLED
#define THRESH_LOW 10000
#define THRESH_HIGH 20000
- // Find best match in this frame by MC
- err = vp8_temporal_filter_find_matching_mb_c
- (cpi,
- cpi->frames[alt_ref_index],
- cpi->frames[frame],
- mb_y_offset,
- THRESH_LOW);
+ // Find best match in this frame by MC
+ err = vp8_temporal_filter_find_matching_mb_c
+ (cpi,
+ cpi->frames[alt_ref_index],
+ cpi->frames[frame],
+ mb_y_offset,
+ THRESH_LOW);
#endif
- // Assign higher weight to matching MB if it's error
- // score is lower. If not applying MC default behavior
- // is to weight all MBs equal.
- filter_weight = err<THRESH_LOW
- ? 2 : err<THRESH_HIGH ? 1 : 0;
- }
-
- if (filter_weight != 0)
- {
- // Construct the predictors
- vp8_temporal_filter_predictors_mb_c
- (mbd,
- cpi->frames[frame]->y_buffer + mb_y_offset,
- cpi->frames[frame]->u_buffer + mb_uv_offset,
- cpi->frames[frame]->v_buffer + mb_uv_offset,
- cpi->frames[frame]->y_stride,
- mbd->block[0].bmi.as_mv.first.as_mv.row,
- mbd->block[0].bmi.as_mv.first.as_mv.col,
- predictor);
-
- // Apply the filter (YUV)
- TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
- (f->y_buffer + mb_y_offset,
- f->y_stride,
- predictor,
- 16,
- strength,
- filter_weight,
- accumulator,
- count);
-
- TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
- (f->u_buffer + mb_uv_offset,
- f->uv_stride,
- predictor + 256,
- 8,
- strength,
- filter_weight,
- accumulator + 256,
- count + 256);
-
- TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
- (f->v_buffer + mb_uv_offset,
- f->uv_stride,
- predictor + 320,
- 8,
- strength,
- filter_weight,
- accumulator + 320,
- count + 320);
- }
- }
-
- // Normalize filter output to produce AltRef frame
- dst1 = cpi->alt_ref_buffer.y_buffer;
- stride = cpi->alt_ref_buffer.y_stride;
- byte = mb_y_offset;
- for (i = 0,k = 0; i < 16; i++)
- {
- for (j = 0; j < 16; j++, k++)
- {
- unsigned int pval = accumulator[k] + (count[k] >> 1);
- pval *= cpi->fixed_divide[count[k]];
- pval >>= 19;
-
- dst1[byte] = (unsigned char)pval;
-
- // move to next pixel
- byte++;
- }
-
- byte += stride - 16;
- }
-
- dst1 = cpi->alt_ref_buffer.u_buffer;
- dst2 = cpi->alt_ref_buffer.v_buffer;
- stride = cpi->alt_ref_buffer.uv_stride;
- byte = mb_uv_offset;
- for (i = 0,k = 256; i < 8; i++)
- {
- for (j = 0; j < 8; j++, k++)
- {
- int m=k+64;
-
- // U
- unsigned int pval = accumulator[k] + (count[k] >> 1);
- pval *= cpi->fixed_divide[count[k]];
- pval >>= 19;
- dst1[byte] = (unsigned char)pval;
-
- // V
- pval = accumulator[m] + (count[m] >> 1);
- pval *= cpi->fixed_divide[count[m]];
- pval >>= 19;
- dst2[byte] = (unsigned char)pval;
-
- // move to next pixel
- byte++;
- }
-
- byte += stride - 8;
- }
-
- mb_y_offset += 16;
- mb_uv_offset += 8;
+ // Assign higher weight to matching MB if it's error
+ // score is lower. If not applying MC default behavior
+ // is to weight all MBs equal.
+ filter_weight = err < THRESH_LOW
+ ? 2 : err < THRESH_HIGH ? 1 : 0;
+ }
+
+ if (filter_weight != 0) {
+ // Construct the predictors
+ vp8_temporal_filter_predictors_mb_c
+ (mbd,
+ cpi->frames[frame]->y_buffer + mb_y_offset,
+ cpi->frames[frame]->u_buffer + mb_uv_offset,
+ cpi->frames[frame]->v_buffer + mb_uv_offset,
+ cpi->frames[frame]->y_stride,
+ mbd->block[0].bmi.as_mv.first.as_mv.row,
+ mbd->block[0].bmi.as_mv.first.as_mv.col,
+ predictor);
+
+ // Apply the filter (YUV)
+ TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
+ (f->y_buffer + mb_y_offset,
+ f->y_stride,
+ predictor,
+ 16,
+ strength,
+ filter_weight,
+ accumulator,
+ count);
+
+ TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
+ (f->u_buffer + mb_uv_offset,
+ f->uv_stride,
+ predictor + 256,
+ 8,
+ strength,
+ filter_weight,
+ accumulator + 256,
+ count + 256);
+
+ TEMPORAL_INVOKE(&cpi->rtcd.temporal, apply)
+ (f->v_buffer + mb_uv_offset,
+ f->uv_stride,
+ predictor + 320,
+ 8,
+ strength,
+ filter_weight,
+ accumulator + 320,
+ count + 320);
+ }
+ }
+
+ // Normalize filter output to produce AltRef frame
+ dst1 = cpi->alt_ref_buffer.y_buffer;
+ stride = cpi->alt_ref_buffer.y_stride;
+ byte = mb_y_offset;
+ for (i = 0, k = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++, k++) {
+ unsigned int pval = accumulator[k] + (count[k] >> 1);
+ pval *= cpi->fixed_divide[count[k]];
+ pval >>= 19;
+
+ dst1[byte] = (unsigned char)pval;
+
+ // move to next pixel
+ byte++;
+ }
+
+ byte += stride - 16;
+ }
+
+ dst1 = cpi->alt_ref_buffer.u_buffer;
+ dst2 = cpi->alt_ref_buffer.v_buffer;
+ stride = cpi->alt_ref_buffer.uv_stride;
+ byte = mb_uv_offset;
+ for (i = 0, k = 256; i < 8; i++) {
+ for (j = 0; j < 8; j++, k++) {
+ int m = k + 64;
+
+ // U
+ unsigned int pval = accumulator[k] + (count[k] >> 1);
+ pval *= cpi->fixed_divide[count[k]];
+ pval >>= 19;
+ dst1[byte] = (unsigned char)pval;
+
+ // V
+ pval = accumulator[m] + (count[m] >> 1);
+ pval *= cpi->fixed_divide[count[m]];
+ pval >>= 19;
+ dst2[byte] = (unsigned char)pval;
+
+ // move to next pixel
+ byte++;
}
- mb_y_offset += 16*(f->y_stride-mb_cols);
- mb_uv_offset += 8*(f->uv_stride-mb_cols);
+ byte += stride - 8;
+ }
+
+ mb_y_offset += 16;
+ mb_uv_offset += 8;
}
- // Restore input state
- mbd->pre.y_buffer = y_buffer;
- mbd->pre.u_buffer = u_buffer;
- mbd->pre.v_buffer = v_buffer;
+ mb_y_offset += 16 * (f->y_stride - mb_cols);
+ mb_uv_offset += 8 * (f->uv_stride - mb_cols);
+ }
+
+ // Restore input state
+ mbd->pre.y_buffer = y_buffer;
+ mbd->pre.u_buffer = u_buffer;
+ mbd->pre.v_buffer = v_buffer;
}
void vp8_temporal_filter_prepare_c
(
- VP8_COMP *cpi,
- int distance
-)
-{
- int frame = 0;
+ VP8_COMP *cpi,
+ int distance
+) {
+ int frame = 0;
- int num_frames_backward = 0;
- int num_frames_forward = 0;
- int frames_to_blur_backward = 0;
- int frames_to_blur_forward = 0;
- int frames_to_blur = 0;
- int start_frame = 0;
+ int num_frames_backward = 0;
+ int num_frames_forward = 0;
+ int frames_to_blur_backward = 0;
+ int frames_to_blur_forward = 0;
+ int frames_to_blur = 0;
+ int start_frame = 0;
- int strength = cpi->oxcf.arnr_strength;
+ int strength = cpi->oxcf.arnr_strength;
- int blur_type = cpi->oxcf.arnr_type;
+ int blur_type = cpi->oxcf.arnr_type;
- int max_frames = cpi->active_arnr_frames;
+ int max_frames = cpi->active_arnr_frames;
- num_frames_backward = distance;
- num_frames_forward = vp8_lookahead_depth(cpi->lookahead)
- - (num_frames_backward + 1);
+ num_frames_backward = distance;
+ num_frames_forward = vp8_lookahead_depth(cpi->lookahead)
+ - (num_frames_backward + 1);
- switch (blur_type)
- {
+ switch (blur_type) {
case 1:
- /////////////////////////////////////////
- // Backward Blur
+ /////////////////////////////////////////
+ // Backward Blur
- frames_to_blur_backward = num_frames_backward;
+ frames_to_blur_backward = num_frames_backward;
- if (frames_to_blur_backward >= max_frames)
- frames_to_blur_backward = max_frames - 1;
+ if (frames_to_blur_backward >= max_frames)
+ frames_to_blur_backward = max_frames - 1;
- frames_to_blur = frames_to_blur_backward + 1;
- break;
+ frames_to_blur = frames_to_blur_backward + 1;
+ break;
case 2:
- /////////////////////////////////////////
- // Forward Blur
+ /////////////////////////////////////////
+ // Forward Blur
- frames_to_blur_forward = num_frames_forward;
+ frames_to_blur_forward = num_frames_forward;
- if (frames_to_blur_forward >= max_frames)
- frames_to_blur_forward = max_frames - 1;
+ if (frames_to_blur_forward >= max_frames)
+ frames_to_blur_forward = max_frames - 1;
- frames_to_blur = frames_to_blur_forward + 1;
- break;
+ frames_to_blur = frames_to_blur_forward + 1;
+ break;
case 3:
default:
- /////////////////////////////////////////
- // Center Blur
- frames_to_blur_forward = num_frames_forward;
- frames_to_blur_backward = num_frames_backward;
+ /////////////////////////////////////////
+ // Center Blur
+ frames_to_blur_forward = num_frames_forward;
+ frames_to_blur_backward = num_frames_backward;
- if (frames_to_blur_forward > frames_to_blur_backward)
- frames_to_blur_forward = frames_to_blur_backward;
+ if (frames_to_blur_forward > frames_to_blur_backward)
+ frames_to_blur_forward = frames_to_blur_backward;
- if (frames_to_blur_backward > frames_to_blur_forward)
- frames_to_blur_backward = frames_to_blur_forward;
+ if (frames_to_blur_backward > frames_to_blur_forward)
+ frames_to_blur_backward = frames_to_blur_forward;
- // When max_frames is even we have 1 more frame backward than forward
- if (frames_to_blur_forward > (max_frames - 1) / 2)
- frames_to_blur_forward = ((max_frames - 1) / 2);
+ // When max_frames is even we have 1 more frame backward than forward
+ if (frames_to_blur_forward > (max_frames - 1) / 2)
+ frames_to_blur_forward = ((max_frames - 1) / 2);
- if (frames_to_blur_backward > (max_frames / 2))
- frames_to_blur_backward = (max_frames / 2);
+ if (frames_to_blur_backward > (max_frames / 2))
+ frames_to_blur_backward = (max_frames / 2);
- frames_to_blur = frames_to_blur_backward + frames_to_blur_forward + 1;
- break;
- }
+ frames_to_blur = frames_to_blur_backward + frames_to_blur_forward + 1;
+ break;
+ }
- start_frame = distance + frames_to_blur_forward;
+ start_frame = distance + frames_to_blur_forward;
#ifdef DEBUGFWG
- // DEBUG FWG
- printf("max:%d FBCK:%d FFWD:%d ftb:%d ftbbck:%d ftbfwd:%d sei:%d lasei:%d start:%d"
- , max_frames
- , num_frames_backward
- , num_frames_forward
- , frames_to_blur
- , frames_to_blur_backward
- , frames_to_blur_forward
- , cpi->source_encode_index
- , cpi->last_alt_ref_sei
- , start_frame);
+ // DEBUG FWG
+ printf("max:%d FBCK:%d FFWD:%d ftb:%d ftbbck:%d ftbfwd:%d sei:%d lasei:%d start:%d"
+, max_frames
+, num_frames_backward
+, num_frames_forward
+, frames_to_blur
+, frames_to_blur_backward
+, frames_to_blur_forward
+, cpi->source_encode_index
+, cpi->last_alt_ref_sei
+, start_frame);
#endif
- // Setup frame pointers, NULL indicates frame not included in filter
- vpx_memset(cpi->frames, 0, max_frames*sizeof(YV12_BUFFER_CONFIG *));
- for (frame = 0; frame < frames_to_blur; frame++)
- {
- int which_buffer = start_frame - frame;
- struct lookahead_entry* buf = vp8_lookahead_peek(cpi->lookahead,
- which_buffer);
- cpi->frames[frames_to_blur-1-frame] = &buf->img;
- }
-
- vp8_temporal_filter_iterate_c (
- cpi,
- frames_to_blur,
- frames_to_blur_backward,
- strength );
+ // Setup frame pointers, NULL indicates frame not included in filter
+ vpx_memset(cpi->frames, 0, max_frames * sizeof(YV12_BUFFER_CONFIG *));
+ for (frame = 0; frame < frames_to_blur; frame++) {
+ int which_buffer = start_frame - frame;
+ struct lookahead_entry *buf = vp8_lookahead_peek(cpi->lookahead,
+ which_buffer);
+ cpi->frames[frames_to_blur - 1 - frame] = &buf->img;
+ }
+
+ vp8_temporal_filter_iterate_c(
+ cpi,
+ frames_to_blur,
+ frames_to_blur_backward,
+ strength);
}
#endif
diff --git a/vp8/encoder/temporal_filter.h b/vp8/encoder/temporal_filter.h
index 740037a85..e051c5c76 100644
--- a/vp8/encoder/temporal_filter.h
+++ b/vp8/encoder/temporal_filter.h
@@ -13,17 +13,17 @@
#define __INC_VP8_TEMPORAL_FILTER_H
#define prototype_apply(sym)\
- void (sym) \
- ( \
- unsigned char *frame1, \
- unsigned int stride, \
- unsigned char *frame2, \
- unsigned int block_size, \
- int strength, \
- int filter_weight, \
- unsigned int *accumulator, \
- unsigned short *count \
- )
+ void (sym) \
+ ( \
+ unsigned char *frame1, \
+ unsigned int stride, \
+ unsigned char *frame2, \
+ unsigned int block_size, \
+ int strength, \
+ int filter_weight, \
+ unsigned int *accumulator, \
+ unsigned short *count \
+ )
#if ARCH_X86 || ARCH_X86_64
#include "x86/temporal_filter_x86.h"
@@ -34,9 +34,8 @@
#endif
extern prototype_apply(vp8_temporal_filter_apply);
-typedef struct
-{
- prototype_apply(*apply);
+typedef struct {
+ prototype_apply(*apply);
} vp8_temporal_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c
index 4bbe99fd0..2d58669e0 100644
--- a/vp8/encoder/tokenize.c
+++ b/vp8/encoder/tokenize.c
@@ -27,21 +27,21 @@
INT64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
INT64 context_counters_8x8[BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
extern unsigned int tree_update_hist [BLOCK_TYPES]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES][2];
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES][2];
extern unsigned int tree_update_hist_8x8 [BLOCK_TYPES_8X8]
- [COEF_BANDS]
- [PREV_COEF_CONTEXTS]
- [ENTROPY_NODES] [2];
+[COEF_BANDS]
+[PREV_COEF_CONTEXTS]
+[ENTROPY_NODES] [2];
#endif
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
-void vp8_stuff_mb_8x8(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t);
+void vp8_stuff_mb_8x8(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t);
void vp8_fix_contexts(MACROBLOCKD *x);
-static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE*2];
+static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2];
const TOKENVALUE *vp8_dct_value_tokens_ptr;
-static int dct_value_cost[DCT_MAX_VALUE*2];
+static int dct_value_cost[DCT_MAX_VALUE * 2];
const int *vp8_dct_value_cost_ptr;
#ifdef ENC_DEBUG
@@ -50,877 +50,782 @@ extern int mb_col_debug;
extern int enc_debug;
#endif
-static void fill_value_tokens()
-{
+static void fill_value_tokens() {
- TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE;
- vp8_extra_bit_struct *const e = vp8_extra_bits;
+ TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE;
+ vp8_extra_bit_struct *const e = vp8_extra_bits;
- int i = -DCT_MAX_VALUE;
- int sign = 1;
+ int i = -DCT_MAX_VALUE;
+ int sign = 1;
- do
- {
- if (!i)
- sign = 0;
-
- {
- const int a = sign ? -i : i;
- int eb = sign;
+ do {
+ if (!i)
+ sign = 0;
- if (a > 4)
- {
- int j = 4;
+ {
+ const int a = sign ? -i : i;
+ int eb = sign;
- while (++j < 11 && e[j].base_val <= a) {}
+ if (a > 4) {
+ int j = 4;
- t[i].Token = --j;
- eb |= (a - e[j].base_val) << 1;
- }
- else
- t[i].Token = a;
+ while (++j < 11 && e[j].base_val <= a) {}
- t[i].Extra = eb;
- }
+ t[i].Token = --j;
+ eb |= (a - e[j].base_val) << 1;
+ } else
+ t[i].Token = a;
- // initialize the cost for extra bits for all possible coefficient value.
- {
- int cost = 0;
- vp8_extra_bit_struct *p = vp8_extra_bits + t[i].Token;
+ t[i].Extra = eb;
+ }
- if (p->base_val)
- {
- const int extra = t[i].Extra;
- const int Length = p->Len;
+ // initialize the cost for extra bits for all possible coefficient value.
+ {
+ int cost = 0;
+ vp8_extra_bit_struct *p = vp8_extra_bits + t[i].Token;
- if (Length)
- cost += vp8_treed_cost(p->tree, p->prob, extra >> 1, Length);
+ if (p->base_val) {
+ const int extra = t[i].Extra;
+ const int Length = p->Len;
- cost += vp8_cost_bit(vp8_prob_half, extra & 1); /* sign */
- dct_value_cost[i + DCT_MAX_VALUE] = cost;
- }
+ if (Length)
+ cost += vp8_treed_cost(p->tree, p->prob, extra >> 1, Length);
- }
+ cost += vp8_cost_bit(vp8_prob_half, extra & 1); /* sign */
+ dct_value_cost[i + DCT_MAX_VALUE] = cost;
+ }
}
- while (++i < DCT_MAX_VALUE);
- vp8_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE;
- vp8_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE;
+ } while (++i < DCT_MAX_VALUE);
+
+ vp8_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE;
+ vp8_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE;
}
static void tokenize2nd_order_b_8x8
(
- MACROBLOCKD *xd,
- const BLOCKD *const b,
- TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- int c = 0; /* start at DC */
- const int eob = b->eob; /* one beyond last nonzero coeff */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- int x;
- const short *qcoeff_ptr = b->qcoeff;
-
- int seg_eob = 4;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
- }
-
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- assert(eob<=4);
-
- do
- {
- const int band = vp8_coef_bands[c];
- int v = 0;
-
- if (c < eob)
- {
- int rc = vp8_default_zig_zag1d[c];
- v = qcoeff_ptr[rc];
-
- assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
-
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- x = vp8_dct_value_tokens_ptr[v].Token;
- }
- else
- x = DCT_EOB_TOKEN;
-
- t->Token = x;
- //printf("Token : %d\n", x);
- t->context_tree = cpi->common.fc.coef_probs_8x8 [type] [band] [pt];
-
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ MACROBLOCKD *xd,
+ const BLOCKD *const b,
+ TOKENEXTRA **tp,
+ const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ const FRAME_TYPE frametype,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ int c = 0; /* start at DC */
+ const int eob = b->eob; /* one beyond last nonzero coeff */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ int x;
+ const short *qcoeff_ptr = b->qcoeff;
+
+ int seg_eob = 4;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ }
+
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ assert(eob <= 4);
+
+ do {
+ const int band = vp8_coef_bands[c];
+ int v = 0;
+
+ if (c < eob) {
+ int rc = vp8_default_zig_zag1d[c];
+ v = qcoeff_ptr[rc];
+
+ assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
+
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ x = vp8_dct_value_tokens_ptr[v].Token;
+ } else
+ x = DCT_EOB_TOKEN;
+
+ t->Token = x;
+ // printf("Token : %d\n", x);
+ t->context_tree = cpi->common.fc.coef_probs_8x8 [type] [band] [pt];
+
+ t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
#ifdef ENC_DEBUG
- if (t->skip_eob_node && vp8_coef_encodings[x].Len==1)
- printf("Trouble 2 x=%d Len=%d skip=%d eob=%d c=%d band=%d type=%d: [%d %d %d]\n",
- x, vp8_coef_encodings[x].Len, t->skip_eob_node, eob, c, band, type,
- cpi->count, mb_row_debug, mb_col_debug);
+ if (t->skip_eob_node && vp8_coef_encodings[x].Len == 1)
+ printf("Trouble 2 x=%d Len=%d skip=%d eob=%d c=%d band=%d type=%d: [%d %d %d]\n",
+ x, vp8_coef_encodings[x].Len, t->skip_eob_node, eob, c, band, type,
+ cpi->count, mb_row_debug, mb_col_debug);
#endif
- ++cpi->coef_counts_8x8 [type] [band] [pt] [x];
- }
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c <seg_eob);
+ ++cpi->coef_counts_8x8 [type] [band] [pt] [x];
+ } while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < seg_eob);
- *tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ *tp = t;
+ pt = (c != !type); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
static void tokenize2nd_order_b
(
- MACROBLOCKD *xd,
- TOKENEXTRA **tp,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- int c; /* start at DC */
- TOKENEXTRA *t = *tp;/* store tokens starting here */
- const BLOCKD *b;
- const short *qcoeff_ptr;
- ENTROPY_CONTEXT * a;
- ENTROPY_CONTEXT * l;
- int band, rc, v, token;
-
- int seg_eob = 16;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
- }
-
- b = xd->block + 24;
- qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)xd->above_context + 8;
- l = (ENTROPY_CONTEXT *)xd->left_context + 8;
-
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- for (c = 0; c < b->eob; c++)
- {
- rc = vp8_default_zig_zag1d[c];
- band = vp8_coef_bands[c];
- v = qcoeff_ptr[rc];
-
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- token = vp8_dct_value_tokens_ptr[v].Token;
-
- t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
-
- t->skip_eob_node = ((pt == 0) && (band > 0));
-
- ++cpi->coef_counts [1] [band] [pt] [token];
-
- pt = vp8_prev_token_class[token];
- t++;
- }
+ MACROBLOCKD *xd,
+ TOKENEXTRA **tp,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ int c; /* start at DC */
+ TOKENEXTRA *t = *tp;/* store tokens starting here */
+ const BLOCKD *b;
+ const short *qcoeff_ptr;
+ ENTROPY_CONTEXT *a;
+ ENTROPY_CONTEXT *l;
+ int band, rc, v, token;
+
+ int seg_eob = 16;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ }
+
+ b = xd->block + 24;
+ qcoeff_ptr = b->qcoeff;
+ a = (ENTROPY_CONTEXT *)xd->above_context + 8;
+ l = (ENTROPY_CONTEXT *)xd->left_context + 8;
+
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ for (c = 0; c < b->eob; c++) {
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
+
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ token = vp8_dct_value_tokens_ptr[v].Token;
+
+ t->Token = token;
+ t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
+
+ t->skip_eob_node = ((pt == 0) && (band > 0));
+
+ ++cpi->coef_counts [1] [band] [pt] [token];
+
+ pt = vp8_prev_token_class[token];
+ t++;
+ }
+
+ if (c < seg_eob) {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
- if (c < seg_eob)
- {
- band = vp8_coef_bands[c];
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
+ t->skip_eob_node = ((pt == 0) && (band > 0));
- t->skip_eob_node = ((pt == 0) && (band > 0));
+ ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
- ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
+ t++;
+ }
- t++;
- }
-
- *tp = t;
- pt = (c != 0); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ *tp = t;
+ pt = (c != 0); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
static void tokenize1st_order_b_8x8
(
- MACROBLOCKD *xd,
- const BLOCKD *const b,
- TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- int c = type ? 0 : 1; /* start at DC unless type 0 */
- const int eob = b->eob; /* one beyond last nonzero coeff */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- int x;
- const short *qcoeff_ptr = b->qcoeff;
-
- int seg_eob = 64;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
+ MACROBLOCKD *xd,
+ const BLOCKD *const b,
+ TOKENEXTRA **tp,
+ const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ const FRAME_TYPE frametype,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ int c = type ? 0 : 1; /* start at DC unless type 0 */
+ const int eob = b->eob; /* one beyond last nonzero coeff */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ int x;
+ const short *qcoeff_ptr = b->qcoeff;
+
+ int seg_eob = 64;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ }
+
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ do {
+ const int band = vp8_coef_bands_8x8[c];
+ int v;
+
+ x = DCT_EOB_TOKEN;
+
+ if (c < eob) {
+ int rc = vp8_default_zig_zag1d_8x8[c];
+ v = qcoeff_ptr[rc];
+
+ assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
+
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ x = vp8_dct_value_tokens_ptr[v].Token;
}
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- do
- {
- const int band = vp8_coef_bands_8x8[c];
- int v;
-
- x = DCT_EOB_TOKEN;
-
- if (c < eob)
- {
- int rc = vp8_default_zig_zag1d_8x8[c];
- v = qcoeff_ptr[rc];
-
- assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
-
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- x = vp8_dct_value_tokens_ptr[v].Token;
- }
-
- t->Token = x;
- t->context_tree = cpi->common.fc.coef_probs_8x8 [type] [band] [pt];
+ t->Token = x;
+ t->context_tree = cpi->common.fc.coef_probs_8x8 [type] [band] [pt];
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
#ifdef ENC_DEBUG
- if (t->skip_eob_node && vp8_coef_encodings[x].Len==1)
- printf("Trouble 1 x=%d Len=%d skip=%d eob=%d c=%d band=%d type=%d: [%d %d %d]\n", x, vp8_coef_encodings[x].Len, t->skip_eob_node, eob, c, band, type, cpi->count, mb_row_debug, mb_col_debug);
+ if (t->skip_eob_node && vp8_coef_encodings[x].Len == 1)
+ printf("Trouble 1 x=%d Len=%d skip=%d eob=%d c=%d band=%d type=%d: [%d %d %d]\n", x, vp8_coef_encodings[x].Len, t->skip_eob_node, eob, c, band, type, cpi->count, mb_row_debug, mb_col_debug);
#endif
- ++cpi->coef_counts_8x8 [type] [band] [pt] [x];
- }
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < seg_eob);
+ ++cpi->coef_counts_8x8 [type] [band] [pt] [x];
+ } while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < seg_eob);
- *tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ *tp = t;
+ pt = (c != !type); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
static void tokenize1st_order_b
(
- MACROBLOCKD *xd,
- TOKENEXTRA **tp,
- int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- VP8_COMP *cpi
-)
-{
- unsigned int block;
- const BLOCKD *b;
- int pt; /* near block/prev token context index */
- int c;
- int token;
- TOKENEXTRA *t = *tp;/* store tokens starting here */
- const short *qcoeff_ptr;
- ENTROPY_CONTEXT * a;
- ENTROPY_CONTEXT * l;
- int band, rc, v;
- int tmp1, tmp2;
-
- int seg_eob = 16;
- int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
- {
- seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
- }
-
- b = xd->block;
- /* Luma */
- for (block = 0; block < 16; block++, b++)
- {
- tmp1 = vp8_block2above[block];
- tmp2 = vp8_block2left[block];
- qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- c = type ? 0 : 1;
+ MACROBLOCKD *xd,
+ TOKENEXTRA **tp,
+ int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ VP8_COMP *cpi
+) {
+ unsigned int block;
+ const BLOCKD *b;
+ int pt; /* near block/prev token context index */
+ int c;
+ int token;
+ TOKENEXTRA *t = *tp;/* store tokens starting here */
+ const short *qcoeff_ptr;
+ ENTROPY_CONTEXT *a;
+ ENTROPY_CONTEXT *l;
+ int band, rc, v;
+ int tmp1, tmp2;
+
+ int seg_eob = 16;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if (segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
+ seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
+ }
+
+ b = xd->block;
+ /* Luma */
+ for (block = 0; block < 16; block++, b++) {
+ tmp1 = vp8_block2above[block];
+ tmp2 = vp8_block2left[block];
+ qcoeff_ptr = b->qcoeff;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- for (; c < b->eob; c++)
- {
- rc = vp8_default_zig_zag1d[c];
- band = vp8_coef_bands[c];
- v = qcoeff_ptr[rc];
+ c = type ? 0 : 1;
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- token = vp8_dct_value_tokens_ptr[v].Token;
+ for (; c < b->eob; c++) {
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
- t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ token = vp8_dct_value_tokens_ptr[v].Token;
- t->skip_eob_node = pt == 0 &&
- ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->Token = token;
+ t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
- ++cpi->coef_counts [type] [band] [pt] [token];
+ t->skip_eob_node = pt == 0 &&
+ ((band > 0 && type > 0) || (band > 1 && type == 0));
- pt = vp8_prev_token_class[token];
- t++;
- }
+ ++cpi->coef_counts [type] [band] [pt] [token];
- if (c < seg_eob)
- {
- band = vp8_coef_bands[c];
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
+ pt = vp8_prev_token_class[token];
+ t++;
+ }
- t->skip_eob_node = pt == 0 &&
- ((band > 0 && type > 0) || (band > 1 && type == 0));
+ if (c < seg_eob) {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
- ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ t->skip_eob_node = pt == 0 &&
+ ((band > 0 && type > 0) || (band > 1 && type == 0));
- t++;
- }
- *tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ t++;
}
- /* Chroma */
- for (block = 16; block < 24; block++, b++)
- {
- tmp1 = vp8_block2above[block];
- tmp2 = vp8_block2left[block];
- qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
+ *tp = t;
+ pt = (c != !type); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ }
+ /* Chroma */
+ for (block = 16; block < 24; block++, b++) {
+ tmp1 = vp8_block2above[block];
+ tmp2 = vp8_block2left[block];
+ qcoeff_ptr = b->qcoeff;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
- for (c = 0; c < b->eob; c++)
- {
- rc = vp8_default_zig_zag1d[c];
- band = vp8_coef_bands[c];
- v = qcoeff_ptr[rc];
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- token = vp8_dct_value_tokens_ptr[v].Token;
+ for (c = 0; c < b->eob; c++) {
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
- t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ token = vp8_dct_value_tokens_ptr[v].Token;
- t->skip_eob_node = ((pt == 0) && (band > 0));
+ t->Token = token;
+ t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
- ++cpi->coef_counts [2] [band] [pt] [token];
+ t->skip_eob_node = ((pt == 0) && (band > 0));
- pt = vp8_prev_token_class[token];
- t++;
- }
+ ++cpi->coef_counts [2] [band] [pt] [token];
+
+ pt = vp8_prev_token_class[token];
+ t++;
+ }
- if (c < seg_eob)
- {
- band = vp8_coef_bands[c];
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
+ if (c < seg_eob) {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
- t->skip_eob_node = ((pt == 0) && (band > 0));
+ t->skip_eob_node = ((pt == 0) && (band > 0));
- ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
+ ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
- t++;
- }
- *tp = t;
- pt = (c != 0); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ t++;
}
+ *tp = t;
+ pt = (c != 0); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
+ }
}
-int mby_is_skippable(MACROBLOCKD *x, int has_y2_block)
-{
- int skip = 1;
- int i = 0;
+int mby_is_skippable(MACROBLOCKD *x, int has_y2_block) {
+ int skip = 1;
+ int i = 0;
- if (has_y2_block)
- {
- for (i = 0; i < 16; i++)
- skip &= (x->block[i].eob < 2);
- skip &= (!x->block[24].eob);
- }
- else
- {
- for (i = 0; i < 16; i++)
- skip &= (!x->block[i].eob);
- }
- return skip;
+ if (has_y2_block) {
+ for (i = 0; i < 16; i++)
+ skip &= (x->block[i].eob < 2);
+ skip &= (!x->block[24].eob);
+ } else {
+ for (i = 0; i < 16; i++)
+ skip &= (!x->block[i].eob);
+ }
+ return skip;
}
-int mbuv_is_skippable(MACROBLOCKD *x)
-{
- int skip = 1;
- int i;
+int mbuv_is_skippable(MACROBLOCKD *x) {
+ int skip = 1;
+ int i;
- for (i = 16; i < 24; i++)
- skip &= (!x->block[i].eob);
- return skip;
+ for (i = 16; i < 24; i++)
+ skip &= (!x->block[i].eob);
+ return skip;
}
-int mb_is_skippable(MACROBLOCKD *x, int has_y2_block)
-{
- return (mby_is_skippable(x, has_y2_block) &
- mbuv_is_skippable(x));
+int mb_is_skippable(MACROBLOCKD *x, int has_y2_block) {
+ return (mby_is_skippable(x, has_y2_block) &
+ mbuv_is_skippable(x));
}
-int mby_is_skippable_8x8(MACROBLOCKD *x)
-{
- int skip = 1;
- int i = 0;
+int mby_is_skippable_8x8(MACROBLOCKD *x) {
+ int skip = 1;
+ int i = 0;
- for (i = 0; i < 16; i+=4)
- skip &= (x->block[i].eob < 2);
- skip &= (!x->block[24].eob);
- return skip;
+ for (i = 0; i < 16; i += 4)
+ skip &= (x->block[i].eob < 2);
+ skip &= (!x->block[24].eob);
+ return skip;
}
-int mbuv_is_skippable_8x8(MACROBLOCKD *x)
-{
- return (!x->block[16].eob) & (!x->block[20].eob);
+int mbuv_is_skippable_8x8(MACROBLOCKD *x) {
+ return (!x->block[16].eob) & (!x->block[20].eob);
}
-int mb_is_skippable_8x8(MACROBLOCKD *x)
-{
- return (mby_is_skippable_8x8(x) & mbuv_is_skippable_8x8(x));
+int mb_is_skippable_8x8(MACROBLOCKD *x) {
+ return (mby_is_skippable_8x8(x) & mbuv_is_skippable_8x8(x));
}
-void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
-{
- int plane_type;
- int has_y2_block;
- int b;
- int tx_type = x->mode_info_context->mbmi.txfm_size;
+void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) {
+ int plane_type;
+ int has_y2_block;
+ int b;
+ int tx_type = x->mode_info_context->mbmi.txfm_size;
#if CONFIG_NEWENTROPY
- int mb_skip_context = get_pred_context(&cpi->common, x, PRED_MBSKIP);
+ int mb_skip_context = get_pred_context(&cpi->common, x, PRED_MBSKIP);
#endif
- // If the MB is going to be skipped because of a segment level flag
- // exclude this from the skip count stats used to calculate the
- // transmitted skip probability;
- int skip_inc;
- int segment_id = x->mode_info_context->mbmi.segment_id;
+ // If the MB is going to be skipped because of a segment level flag
+ // exclude this from the skip count stats used to calculate the
+ // transmitted skip probability;
+ int skip_inc;
+ int segment_id = x->mode_info_context->mbmi.segment_id;
- if ( !segfeature_active( x, segment_id, SEG_LVL_EOB ) ||
- ( get_segdata( x, segment_id, SEG_LVL_EOB ) != 0) )
- {
- skip_inc = 1;
- }
- else
- skip_inc = 0;
+ if (!segfeature_active(x, segment_id, SEG_LVL_EOB) ||
+ (get_segdata(x, segment_id, SEG_LVL_EOB) != 0)) {
+ skip_inc = 1;
+ } else
+ skip_inc = 0;
- has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != I8X8_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV);
+ has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
+ && x->mode_info_context->mbmi.mode != I8X8_PRED
+ && x->mode_info_context->mbmi.mode != SPLITMV);
- x->mode_info_context->mbmi.mb_skip_coeff =
- (( tx_type == TX_8X8 ) ?
- mb_is_skippable_8x8(x) :
- mb_is_skippable(x, has_y2_block));
+ x->mode_info_context->mbmi.mb_skip_coeff =
+ ((tx_type == TX_8X8) ?
+ mb_is_skippable_8x8(x) :
+ mb_is_skippable(x, has_y2_block));
- if (x->mode_info_context->mbmi.mb_skip_coeff)
- {
+ if (x->mode_info_context->mbmi.mb_skip_coeff) {
#if CONFIG_NEWENTROPY
- cpi->skip_true_count[mb_skip_context] += skip_inc;
+ cpi->skip_true_count[mb_skip_context] += skip_inc;
#else
- cpi->skip_true_count += skip_inc;
+ cpi->skip_true_count += skip_inc;
#endif
- if (!cpi->common.mb_no_coeff_skip)
- {
- if ( tx_type == TX_8X8 )
- vp8_stuff_mb_8x8(cpi, x, t) ;
- else
- vp8_stuff_mb(cpi, x, t) ;
- }
- else
- {
- vp8_fix_contexts(x);
- }
-
- return;
+ if (!cpi->common.mb_no_coeff_skip) {
+ if (tx_type == TX_8X8)
+ vp8_stuff_mb_8x8(cpi, x, t);
+ else
+ vp8_stuff_mb(cpi, x, t);
+ } else {
+ vp8_fix_contexts(x);
}
+ return;
+ }
+
#if CONFIG_NEWENTROPY
- cpi->skip_false_count[mb_skip_context] += skip_inc;
+ cpi->skip_false_count[mb_skip_context] += skip_inc;
#else
- cpi->skip_false_count += skip_inc;
+ cpi->skip_false_count += skip_inc;
#endif
- plane_type = 3;
- if(has_y2_block)
- {
- if ( tx_type == TX_8X8 )
- {
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
- tokenize2nd_order_b_8x8(x,
- x->block + 24, t, 1, x->frame_type,
- A + vp8_block2above_8x8[24],
- L + vp8_block2left_8x8[24], cpi);
- }
- else
- tokenize2nd_order_b(x, t, cpi);
-
- plane_type = 0;
+ plane_type = 3;
+ if (has_y2_block) {
+ if (tx_type == TX_8X8) {
+ ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
+ ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
+ tokenize2nd_order_b_8x8(x,
+ x->block + 24, t, 1, x->frame_type,
+ A + vp8_block2above_8x8[24],
+ L + vp8_block2left_8x8[24], cpi);
+ } else
+ tokenize2nd_order_b(x, t, cpi);
- }
+ plane_type = 0;
- if ( tx_type == TX_8X8 )
- {
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
- for (b = 0; b < 16; b+=4)
- {
- tokenize1st_order_b_8x8(x,
- x->block + b, t, plane_type, x->frame_type,
- A + vp8_block2above_8x8[b],
- L + vp8_block2left_8x8[b],
- cpi);
- *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
- *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b] );
- }
- for (b = 16; b < 24; b+=4)
- {
- tokenize1st_order_b_8x8(x,
- x->block + b, t, 2, x->frame_type,
- A + vp8_block2above_8x8[b],
- L + vp8_block2left_8x8[b],
- cpi);
- *(A + vp8_block2above_8x8[b]+1) = *(A + vp8_block2above_8x8[b]);
- *(L + vp8_block2left_8x8[b]+1 ) = *(L + vp8_block2left_8x8[b]);
- }
+ }
+
+ if (tx_type == TX_8X8) {
+ ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
+ ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
+ for (b = 0; b < 16; b += 4) {
+ tokenize1st_order_b_8x8(x,
+ x->block + b, t, plane_type, x->frame_type,
+ A + vp8_block2above_8x8[b],
+ L + vp8_block2left_8x8[b],
+ cpi);
+ *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
+ *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
+ }
+ for (b = 16; b < 24; b += 4) {
+ tokenize1st_order_b_8x8(x,
+ x->block + b, t, 2, x->frame_type,
+ A + vp8_block2above_8x8[b],
+ L + vp8_block2left_8x8[b],
+ cpi);
+ *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
+ *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
}
- else
+ } else
- tokenize1st_order_b(x, t, plane_type, cpi);
+ tokenize1st_order_b(x, t, plane_type, cpi);
}
#ifdef ENTROPY_STATS
-void init_context_counters(void)
-{
- FILE *f = fopen("context.bin", "rb");
- if(!f)
- {
- vpx_memset(context_counters, 0, sizeof(context_counters));
- vpx_memset(context_counters_8x8, 0, sizeof(context_counters_8x8));
- }
- else
- {
- fread(context_counters, sizeof(context_counters), 1, f);
- fread(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
- fclose(f);
- }
-
- f = fopen("treeupdate.bin", "rb");
- if(!f)
- {
- vpx_memset(tree_update_hist, 0, sizeof(tree_update_hist));
- vpx_memset(tree_update_hist_8x8, 0, sizeof(tree_update_hist_8x8));
- }
- else
- {
- fread(tree_update_hist, sizeof(tree_update_hist), 1, f);
- fread(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
- fclose(f);
- }
+void init_context_counters(void) {
+ FILE *f = fopen("context.bin", "rb");
+ if (!f) {
+ vpx_memset(context_counters, 0, sizeof(context_counters));
+ vpx_memset(context_counters_8x8, 0, sizeof(context_counters_8x8));
+ } else {
+ fread(context_counters, sizeof(context_counters), 1, f);
+ fread(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
+ fclose(f);
+ }
+
+ f = fopen("treeupdate.bin", "rb");
+ if (!f) {
+ vpx_memset(tree_update_hist, 0, sizeof(tree_update_hist));
+ vpx_memset(tree_update_hist_8x8, 0, sizeof(tree_update_hist_8x8));
+ } else {
+ fread(tree_update_hist, sizeof(tree_update_hist), 1, f);
+ fread(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
+ fclose(f);
+ }
}
-void print_context_counters()
-{
+void print_context_counters() {
- int type, band, pt, t;
- FILE *f = fopen("context.c", "w");
+ int type, band, pt, t;
+ FILE *f = fopen("context.c", "w");
- fprintf(f, "#include \"entropy.h\"\n");
- fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
- fprintf(f, "static const unsigned int\n"
- "vp8_default_coef_counts[BLOCK_TYPES]\n"
- " [COEF_BANDS]\n"
- " [PREV_COEF_CONTEXTS]\n"
- " [MAX_ENTROPY_TOKENS]={\n");
+ fprintf(f, "#include \"entropy.h\"\n");
+ fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
+ fprintf(f, "static const unsigned int\n"
+ "vp8_default_coef_counts[BLOCK_TYPES]\n"
+ " [COEF_BANDS]\n"
+ " [PREV_COEF_CONTEXTS]\n"
+ " [MAX_ENTROPY_TOKENS]={\n");
# define Comma( X) (X? ",":"")
- type = 0;
- do
- {
- fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
- band = 0;
- do
- {
- fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
- pt = 0;
- do
- {
- fprintf(f, "%s\n {", Comma(pt));
-
- t = 0;
- do
- {
- const INT64 x = context_counters [type] [band] [pt] [t];
- const int y = (int) x;
- assert(x == (INT64) y); /* no overflow handling yet */
- fprintf(f, "%s %d", Comma(t), y);
- }
- while (++t < MAX_ENTROPY_TOKENS);
- fprintf(f, "}");
- }
- while (++pt < PREV_COEF_CONTEXTS);
- fprintf(f, "\n }");
- }
- while (++band < COEF_BANDS);
- fprintf(f, "\n }");
- }
- while (++type < BLOCK_TYPES);
- fprintf(f, "\n};\n");
+ type = 0;
+ do {
+ fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
+ band = 0;
+ do {
+ fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
+ pt = 0;
+ do {
+ fprintf(f, "%s\n {", Comma(pt));
+
+ t = 0;
+ do {
+ const INT64 x = context_counters [type] [band] [pt] [t];
+ const int y = (int) x;
+ assert(x == (INT64) y); /* no overflow handling yet */
+ fprintf(f, "%s %d", Comma(t), y);
+ } while (++t < MAX_ENTROPY_TOKENS);
+ fprintf(f, "}");
+ } while (++pt < PREV_COEF_CONTEXTS);
+ fprintf(f, "\n }");
+ } while (++band < COEF_BANDS);
+ fprintf(f, "\n }");
+ } while (++type < BLOCK_TYPES);
+ fprintf(f, "\n};\n");
- fprintf(f, "static const unsigned int\nvp8_default_coef_counts_8x8"
- "[BLOCK_TYPES_8X8] [COEF_BANDS]"
- "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {");
+ fprintf(f, "static const unsigned int\nvp8_default_coef_counts_8x8"
+ "[BLOCK_TYPES_8X8] [COEF_BANDS]"
+ "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {");
+
+ type = 0;
+ do {
+ fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
+ band = 0;
+ do {
+ fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
+ pt = 0;
+ do {
+ fprintf(f, "%s\n {", Comma(pt));
+ t = 0;
+ do {
+ const INT64 x = context_counters_8x8 [type] [band] [pt] [t];
+ const int y = (int) x;
- type = 0;
- do
- {
- fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
- band = 0;
- do
- {
- fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
- pt = 0;
- do
- {
- fprintf(f, "%s\n {", Comma(pt));
- t = 0;
- do
- {
- const INT64 x = context_counters_8x8 [type] [band] [pt] [t];
- const int y = (int) x;
-
- assert(x == (INT64) y); /* no overflow handling yet */
- fprintf(f, "%s %d", Comma(t), y);
-
- }
- while (++t < MAX_ENTROPY_TOKENS);
-
- fprintf(f, "}");
- }
- while (++pt < PREV_COEF_CONTEXTS);
-
- fprintf(f, "\n }");
-
- }
- while (++band < COEF_BANDS);
-
- fprintf(f, "\n }");
- }
- while (++type < BLOCK_TYPES_8X8);
+ assert(x == (INT64) y); /* no overflow handling yet */
+ fprintf(f, "%s %d", Comma(t), y);
- fprintf(f, "\n};\n");
+ } while (++t < MAX_ENTROPY_TOKENS);
- fprintf(f, "static const vp8_prob\n"
- "vp8_default_coef_probs[BLOCK_TYPES] [COEF_BANDS] \n"
- "[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
- type = 0;
+ fprintf(f, "}");
+ } while (++pt < PREV_COEF_CONTEXTS);
- do
- {
- fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
+ fprintf(f, "\n }");
- band = 0;
+ } while (++band < COEF_BANDS);
- do
- {
- fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
+ fprintf(f, "\n }");
+ } while (++type < BLOCK_TYPES_8X8);
- pt = 0;
+ fprintf(f, "\n};\n");
- do
- {
+ fprintf(f, "static const vp8_prob\n"
+ "vp8_default_coef_probs[BLOCK_TYPES] [COEF_BANDS] \n"
+ "[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
+ type = 0;
- unsigned int branch_ct [ENTROPY_NODES] [2];
- unsigned int coef_counts[MAX_ENTROPY_TOKENS];
- vp8_prob coef_probs[ENTROPY_NODES];
- for (t=0; t<MAX_ENTROPY_TOKENS; ++t)
- coef_counts[t]=context_counters [type] [band] [pt] [t];
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- coef_probs, branch_ct, coef_counts, 256, 1);
- fprintf(f, "%s\n {", Comma(pt));
+ do {
+ fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
- t = 0;
+ band = 0;
- do
- {
- fprintf(f, "%s %d", Comma(t), coef_probs[t]);
+ do {
+ fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
- }
- while (++t < ENTROPY_NODES);
+ pt = 0;
- fprintf(f, "}");
- }
- while (++pt < PREV_COEF_CONTEXTS);
+ do {
- fprintf(f, "\n }");
+ unsigned int branch_ct [ENTROPY_NODES] [2];
+ unsigned int coef_counts[MAX_ENTROPY_TOKENS];
+ vp8_prob coef_probs[ENTROPY_NODES];
+ for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
+ coef_counts[t] = context_counters [type] [band] [pt] [t];
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ coef_probs, branch_ct, coef_counts, 256, 1);
+ fprintf(f, "%s\n {", Comma(pt));
- }
- while (++band < COEF_BANDS);
+ t = 0;
- fprintf(f, "\n }");
- }
- while (++type < BLOCK_TYPES);
- fprintf(f, "\n};\n");
+ do {
+ fprintf(f, "%s %d", Comma(t), coef_probs[t]);
- fprintf(f, "static const vp8_prob\n"
- "vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]\n"
- "[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
- type = 0;
+ } while (++t < ENTROPY_NODES);
- do
- {
- fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
+ fprintf(f, "}");
+ } while (++pt < PREV_COEF_CONTEXTS);
- band = 0;
+ fprintf(f, "\n }");
- do
- {
- fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
+ } while (++band < COEF_BANDS);
- pt = 0;
+ fprintf(f, "\n }");
+ } while (++type < BLOCK_TYPES);
+ fprintf(f, "\n};\n");
- do
- {
+ fprintf(f, "static const vp8_prob\n"
+ "vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]\n"
+ "[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
+ type = 0;
- unsigned int branch_ct [ENTROPY_NODES] [2];
- unsigned int coef_counts[MAX_ENTROPY_TOKENS];
- vp8_prob coef_probs[ENTROPY_NODES];
- for (t=0; t<MAX_ENTROPY_TOKENS; ++t)
- coef_counts[t]=context_counters_8x8[type] [band] [pt] [t];
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- coef_probs, branch_ct, coef_counts, 256, 1);
+ do {
+ fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
- fprintf(f, "%s\n {", Comma(pt));
- t = 0;
+ band = 0;
- do
- {
- fprintf(f, "%s %d", Comma(t), coef_probs[t]);
+ do {
+ fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
- }
- while (++t < ENTROPY_NODES);
+ pt = 0;
- fprintf(f, "}");
- }
- while (++pt < PREV_COEF_CONTEXTS);
+ do {
- fprintf(f, "\n }");
+ unsigned int branch_ct [ENTROPY_NODES] [2];
+ unsigned int coef_counts[MAX_ENTROPY_TOKENS];
+ vp8_prob coef_probs[ENTROPY_NODES];
+ for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
+ coef_counts[t] = context_counters_8x8[type] [band] [pt] [t];
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ coef_probs, branch_ct, coef_counts, 256, 1);
- }
- while (++band < COEF_BANDS);
+ fprintf(f, "%s\n {", Comma(pt));
+ t = 0;
- fprintf(f, "\n }");
- }
- while (++type < BLOCK_TYPES_8X8);
- fprintf(f, "\n};\n");
+ do {
+ fprintf(f, "%s %d", Comma(t), coef_probs[t]);
- fclose(f);
+ } while (++t < ENTROPY_NODES);
- f = fopen("context.bin", "wb");
- fwrite(context_counters, sizeof(context_counters), 1, f);
- fwrite(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
- fclose(f);
+ fprintf(f, "}");
+ } while (++pt < PREV_COEF_CONTEXTS);
+
+ fprintf(f, "\n }");
+
+ } while (++band < COEF_BANDS);
+
+ fprintf(f, "\n }");
+ } while (++type < BLOCK_TYPES_8X8);
+ fprintf(f, "\n};\n");
+
+ fclose(f);
+
+ f = fopen("context.bin", "wb");
+ fwrite(context_counters, sizeof(context_counters), 1, f);
+ fwrite(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
+ fclose(f);
}
#endif
-void vp8_tokenize_initialize()
-{
- fill_value_tokens();
+void vp8_tokenize_initialize() {
+ fill_value_tokens();
}
static __inline void stuff2nd_order_b_8x8
(
- const BLOCKD *const b,
- TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs_8x8 [1] [0] [pt];
- //t->section = 11;
- t->skip_eob_node = 0;
- ++t;
-
- *tp = t;
- ++cpi->coef_counts_8x8 [1] [0] [pt] [DCT_EOB_TOKEN];
- pt = 0;
- *a = *l = pt;
+ const BLOCKD *const b,
+ TOKENEXTRA **tp,
+ const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ const FRAME_TYPE frametype,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ (void) frametype;
+ (void) type;
+ (void) b;
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs_8x8 [1] [0] [pt];
+ // t->section = 11;
+ t->skip_eob_node = 0;
+ ++t;
+
+ *tp = t;
+ ++cpi->coef_counts_8x8 [1] [0] [pt] [DCT_EOB_TOKEN];
+ pt = 0;
+ *a = *l = pt;
}
static __inline void stuff1st_order_b_8x8
(
- const BLOCKD *const b,
- TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs_8x8 [0] [1] [pt];
- //t->section = 8;
- t->skip_eob_node = 0;
- ++t;
- *tp = t;
- ++cpi->coef_counts_8x8 [0] [1] [pt] [DCT_EOB_TOKEN];
- pt = 0; /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ const BLOCKD *const b,
+ TOKENEXTRA **tp,
+ const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ const FRAME_TYPE frametype,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ (void) frametype;
+ (void) type;
+ (void) b;
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs_8x8 [0] [1] [pt];
+ // t->section = 8;
+ t->skip_eob_node = 0;
+ ++t;
+ *tp = t;
+ ++cpi->coef_counts_8x8 [0] [1] [pt] [DCT_EOB_TOKEN];
+ pt = 0; /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
@@ -928,173 +833,161 @@ static __inline void stuff1st_order_b_8x8
static __inline
void stuff1st_order_buv_8x8
(
- const BLOCKD *const b,
- TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs_8x8 [2] [0] [pt];
- //t->section = 13;
- t->skip_eob_node = 0;
- ++t;
- *tp = t;
- ++cpi->coef_counts_8x8[2] [0] [pt] [DCT_EOB_TOKEN];
- pt = 0; /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ const BLOCKD *const b,
+ TOKENEXTRA **tp,
+ const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ const FRAME_TYPE frametype,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ (void) frametype;
+ (void) type;
+ (void) b;
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs_8x8 [2] [0] [pt];
+ // t->section = 13;
+ t->skip_eob_node = 0;
+ ++t;
+ *tp = t;
+ ++cpi->coef_counts_8x8[2] [0] [pt] [DCT_EOB_TOKEN];
+ pt = 0; /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
-void vp8_stuff_mb_8x8(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
-{
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
- int plane_type;
- int b;
-
- stuff2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type,
- A + vp8_block2above_8x8[24],
- L + vp8_block2left_8x8[24], cpi);
- plane_type = 0;
-
- for (b = 0; b < 16; b+=4)
- {
- stuff1st_order_b_8x8(x->block + b, t, plane_type, x->frame_type,
- A + vp8_block2above_8x8[b],
- L + vp8_block2left_8x8[b],
- cpi);
- *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
- *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b] );
- }
-
- for (b = 16; b < 24; b+=4)
- {
- stuff1st_order_buv_8x8(x->block + b, t, 2, x->frame_type,
- A + vp8_block2above[b],
- L + vp8_block2left[b],
- cpi);
- *(A + vp8_block2above_8x8[b]+1) = *(A + vp8_block2above_8x8[b]);
- *(L + vp8_block2left_8x8[b]+1 ) = *(L + vp8_block2left_8x8[b]);
- }
+void vp8_stuff_mb_8x8(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) {
+ ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
+ ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
+ int plane_type;
+ int b;
+
+ stuff2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type,
+ A + vp8_block2above_8x8[24],
+ L + vp8_block2left_8x8[24], cpi);
+ plane_type = 0;
+
+ for (b = 0; b < 16; b += 4) {
+ stuff1st_order_b_8x8(x->block + b, t, plane_type, x->frame_type,
+ A + vp8_block2above_8x8[b],
+ L + vp8_block2left_8x8[b],
+ cpi);
+ *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
+ *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
+ }
+
+ for (b = 16; b < 24; b += 4) {
+ stuff1st_order_buv_8x8(x->block + b, t, 2, x->frame_type,
+ A + vp8_block2above[b],
+ L + vp8_block2left[b],
+ cpi);
+ *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
+ *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
+ }
}
static __inline void stuff2nd_order_b
(
- TOKENEXTRA **tp,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
- t->skip_eob_node = 0;
- ++t;
- *tp = t;
- ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
-
- pt = 0;
- *a = *l = pt;
+ TOKENEXTRA **tp,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
+ t->skip_eob_node = 0;
+ ++t;
+ *tp = t;
+ ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
+
+ pt = 0;
+ *a = *l = pt;
}
static __inline void stuff1st_order_b
(
- TOKENEXTRA **tp,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [0] [1] [pt];
- t->skip_eob_node = 0;
- ++t;
- *tp = t;
- ++cpi->coef_counts [0] [1] [pt] [DCT_EOB_TOKEN];
- pt = 0; /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ TOKENEXTRA **tp,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [0] [1] [pt];
+ t->skip_eob_node = 0;
+ ++t;
+ *tp = t;
+ ++cpi->coef_counts [0] [1] [pt] [DCT_EOB_TOKEN];
+ pt = 0; /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
static __inline
void stuff1st_order_buv
(
- TOKENEXTRA **tp,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
-)
-{
- int pt; /* near block/prev token context index */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
-
- t->Token = DCT_EOB_TOKEN;
- t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
- t->skip_eob_node = 0;
- ++t;
- *tp = t;
- ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
- pt = 0; /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ TOKENEXTRA **tp,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ VP8_COMP *cpi
+) {
+ int pt; /* near block/prev token context index */
+ TOKENEXTRA *t = *tp; /* store tokens starting here */
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
+ t->skip_eob_node = 0;
+ ++t;
+ *tp = t;
+ ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
+ pt = 0; /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
}
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
-{
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
- int plane_type;
- int b;
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) {
+ ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
+ ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
+ int plane_type;
+ int b;
- stuff2nd_order_b(t,
- A + vp8_block2above[24], L + vp8_block2left[24], cpi);
- plane_type = 0;
+ stuff2nd_order_b(t,
+ A + vp8_block2above[24], L + vp8_block2left[24], cpi);
+ plane_type = 0;
- for (b = 0; b < 16; b++)
- stuff1st_order_b(t,
- A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
+ for (b = 0; b < 16; b++)
+ stuff1st_order_b(t,
+ A + vp8_block2above[b],
+ L + vp8_block2left[b], cpi);
- for (b = 16; b < 24; b++)
- stuff1st_order_buv(t,
- A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
+ for (b = 16; b < 24; b++)
+ stuff1st_order_buv(t,
+ A + vp8_block2above[b],
+ L + vp8_block2left[b], cpi);
}
-void vp8_fix_contexts(MACROBLOCKD *x)
-{
- /* Clear entropy contexts for Y2 blocks */
- if (x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != I8X8_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV)
- {
- vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
- vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
- }
- else
- {
- vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
- vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
- }
+void vp8_fix_contexts(MACROBLOCKD *x) {
+ /* Clear entropy contexts for Y2 blocks */
+ if (x->mode_info_context->mbmi.mode != B_PRED
+ && x->mode_info_context->mbmi.mode != I8X8_PRED
+ && x->mode_info_context->mbmi.mode != SPLITMV) {
+ vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
+ } else {
+ vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
+ vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
+ }
}
diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h
index bc3a05bd5..4ee676e7f 100644
--- a/vp8/encoder/tokenize.h
+++ b/vp8/encoder/tokenize.h
@@ -17,25 +17,23 @@
void vp8_tokenize_initialize();
-typedef struct
-{
- short Token;
- short Extra;
+typedef struct {
+ short Token;
+ short Extra;
} TOKENVALUE;
-typedef struct
-{
- const vp8_prob *context_tree;
- short Extra;
- unsigned char Token;
- unsigned char skip_eob_node;
+typedef struct {
+ const vp8_prob *context_tree;
+ short Extra;
+ unsigned char Token;
+ unsigned char skip_eob_node;
} TOKENEXTRA;
int rd_cost_mby(MACROBLOCKD *);
-extern int mby_is_skippable(MACROBLOCKD *x,int has_y2_block);
+extern int mby_is_skippable(MACROBLOCKD *x, int has_y2_block);
extern int mbuv_is_skippable(MACROBLOCKD *x);
-extern int mb_is_skippable(MACROBLOCKD *x,int has_y2_block);
+extern int mb_is_skippable(MACROBLOCKD *x, int has_y2_block);
extern int mby_is_skippable_8x8(MACROBLOCKD *x);
extern int mbuv_is_skippable_8x8(MACROBLOCKD *x);
extern int mb_is_skippable_8x8(MACROBLOCKD *x);
diff --git a/vp8/encoder/treewriter.c b/vp8/encoder/treewriter.c
index 6d46d369f..2dc7d8e62 100644
--- a/vp8/encoder/treewriter.c
+++ b/vp8/encoder/treewriter.c
@@ -12,33 +12,28 @@
#include "treewriter.h"
static void cost(
- int *const C,
- vp8_tree T,
- const vp8_prob *const P,
- int i,
- int c
-)
-{
- const vp8_prob p = P [i>>1];
+ int *const C,
+ vp8_tree T,
+ const vp8_prob *const P,
+ int i,
+ int c
+) {
+ const vp8_prob p = P [i >> 1];
- do
- {
- const vp8_tree_index j = T[i];
- const int d = c + vp8_cost_bit(p, i & 1);
+ do {
+ const vp8_tree_index j = T[i];
+ const int d = c + vp8_cost_bit(p, i & 1);
- if (j <= 0)
- C[-j] = d;
- else
- cost(C, T, P, j, d);
- }
- while (++i & 1);
+ if (j <= 0)
+ C[-j] = d;
+ else
+ cost(C, T, P, j, d);
+ } while (++i & 1);
}
-void vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t)
-{
- cost(c, t, p, 0, 0);
+void vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t) {
+ cost(c, t, p, 0, 0);
}
-void vp8_cost_tokens_skip(int *c, const vp8_prob *p, vp8_tree t)
-{
- cost(c, t, p, 2, 0);
+void vp8_cost_tokens_skip(int *c, const vp8_prob *p, vp8_tree t) {
+ cost(c, t, p, 2, 0);
}
diff --git a/vp8/encoder/treewriter.h b/vp8/encoder/treewriter.h
index 5fd6138d3..7292072fe 100644
--- a/vp8/encoder/treewriter.h
+++ b/vp8/encoder/treewriter.h
@@ -42,20 +42,18 @@ typedef BOOL_CODER vp8_writer;
/* Both of these return bits, not scaled bits. */
-static __inline unsigned int vp8_cost_branch(const unsigned int ct[2], vp8_prob p)
-{
- /* Imitate existing calculation */
+static __inline unsigned int vp8_cost_branch(const unsigned int ct[2], vp8_prob p) {
+ /* Imitate existing calculation */
- return ((ct[0] * vp8_cost_zero(p))
- + (ct[1] * vp8_cost_one(p))) >> 8;
+ return ((ct[0] * vp8_cost_zero(p))
+ + (ct[1] * vp8_cost_one(p))) >> 8;
}
-static __inline unsigned int vp8_cost_branch256(const unsigned int ct[2], vp8_prob p)
-{
- /* Imitate existing calculation */
+static __inline unsigned int vp8_cost_branch256(const unsigned int ct[2], vp8_prob p) {
+ /* Imitate existing calculation */
- return ((ct[0] * vp8_cost_zero(p))
- + (ct[1] * vp8_cost_one(p)));
+ return ((ct[0] * vp8_cost_zero(p))
+ + (ct[1] * vp8_cost_one(p)));
}
/* Small functions to write explicit values and tokens, as well as
@@ -63,68 +61,60 @@ static __inline unsigned int vp8_cost_branch256(const unsigned int ct[2], vp8_pr
static __inline void vp8_treed_write
(
- vp8_writer *const w,
- vp8_tree t,
- const vp8_prob *const p,
- int v,
- int n /* number of bits in v, assumed nonzero */
-)
-{
- vp8_tree_index i = 0;
-
- do
- {
- const int b = (v >> --n) & 1;
- vp8_write(w, b, p[i>>1]);
- i = t[i+b];
- }
- while (n);
+ vp8_writer *const w,
+ vp8_tree t,
+ const vp8_prob *const p,
+ int v,
+ int n /* number of bits in v, assumed nonzero */
+) {
+ vp8_tree_index i = 0;
+
+ do {
+ const int b = (v >> --n) & 1;
+ vp8_write(w, b, p[i >> 1]);
+ i = t[i + b];
+ } while (n);
}
static __inline void vp8_write_token
(
- vp8_writer *const w,
- vp8_tree t,
- const vp8_prob *const p,
- vp8_token *const x
-)
-{
- vp8_treed_write(w, t, p, x->value, x->Len);
+ vp8_writer *const w,
+ vp8_tree t,
+ const vp8_prob *const p,
+ vp8_token *const x
+) {
+ vp8_treed_write(w, t, p, x->value, x->Len);
}
static __inline int vp8_treed_cost(
- vp8_tree t,
- const vp8_prob *const p,
- int v,
- int n /* number of bits in v, assumed nonzero */
-)
-{
- int c = 0;
- vp8_tree_index i = 0;
-
- do
- {
- const int b = (v >> --n) & 1;
- c += vp8_cost_bit(p[i>>1], b);
- i = t[i+b];
- }
- while (n);
-
- return c;
+ vp8_tree t,
+ const vp8_prob *const p,
+ int v,
+ int n /* number of bits in v, assumed nonzero */
+) {
+ int c = 0;
+ vp8_tree_index i = 0;
+
+ do {
+ const int b = (v >> --n) & 1;
+ c += vp8_cost_bit(p[i >> 1], b);
+ i = t[i + b];
+ } while (n);
+
+ return c;
}
static __inline int vp8_cost_token
(
- vp8_tree t,
- const vp8_prob *const p,
- vp8_token *const x
-)
-{
- return vp8_treed_cost(t, p, x->value, x->Len);
+ vp8_tree t,
+ const vp8_prob *const p,
+ vp8_token *const x
+) {
+ return vp8_treed_cost(t, p, x->value, x->Len);
}
/* Fill array of costs for all possible token values. */
void vp8_cost_tokens(
- int *Costs, const vp8_prob *, vp8_tree
+ int *Costs, const vp8_prob *, vp8_tree
);
void vp8_cost_tokens_skip(int *c, const vp8_prob *p, vp8_tree t);
diff --git a/vp8/encoder/variance.h b/vp8/encoder/variance.h
index fde8ade09..0bfd93c2c 100644
--- a/vp8/encoder/variance.h
+++ b/vp8/encoder/variance.h
@@ -13,102 +13,102 @@
#define VARIANCE_H
#define prototype_sad(sym)\
- unsigned int (sym)\
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride, \
- int max_sad\
- )
+ unsigned int (sym)\
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride, \
+ int max_sad\
+ )
#define prototype_sad_multi_same_address(sym)\
- void (sym)\
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride, \
- unsigned int *sad_array\
- )
+ void (sym)\
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride, \
+ unsigned int *sad_array\
+ )
#define prototype_sad_multi_same_address_1(sym)\
- void (sym)\
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride, \
- unsigned short *sad_array\
- )
+ void (sym)\
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride, \
+ unsigned short *sad_array\
+ )
#define prototype_sad_multi_dif_address(sym)\
- void (sym)\
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- unsigned char *ref_ptr[4], \
- int ref_stride, \
- unsigned int *sad_array\
- )
+ void (sym)\
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ unsigned char *ref_ptr[4], \
+ int ref_stride, \
+ unsigned int *sad_array\
+ )
#define prototype_variance(sym) \
- unsigned int (sym) \
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride, \
- unsigned int *sse\
- )
+ unsigned int (sym) \
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride, \
+ unsigned int *sse\
+ )
#define prototype_variance2(sym) \
- unsigned int (sym) \
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride, \
- unsigned int *sse,\
- int *sum\
- )
+ unsigned int (sym) \
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride, \
+ unsigned int *sse,\
+ int *sum\
+ )
#define prototype_subpixvariance(sym) \
- unsigned int (sym) \
- ( \
- const unsigned char *src_ptr, \
- int source_stride, \
- int xoffset, \
- int yoffset, \
- const unsigned char *ref_ptr, \
- int Refstride, \
- unsigned int *sse \
- );
+ unsigned int (sym) \
+ ( \
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ int xoffset, \
+ int yoffset, \
+ const unsigned char *ref_ptr, \
+ int Refstride, \
+ unsigned int *sse \
+ );
#define prototype_ssimpf(sym) \
- void (sym) \
- ( \
- unsigned char *s, \
- int sp, \
- unsigned char *r, \
- int rp, \
- unsigned long *sum_s, \
- unsigned long *sum_r, \
- unsigned long *sum_sq_s, \
- unsigned long *sum_sq_r, \
- unsigned long *sum_sxr \
- );
+ void (sym) \
+ ( \
+ unsigned char *s, \
+ int sp, \
+ unsigned char *r, \
+ int rp, \
+ unsigned long *sum_s, \
+ unsigned long *sum_r, \
+ unsigned long *sum_sq_s, \
+ unsigned long *sum_sq_r, \
+ unsigned long *sum_sxr \
+ );
#define prototype_getmbss(sym) unsigned int (sym)(const short *)
#define prototype_get16x16prederror(sym)\
- unsigned int (sym)\
- (\
- const unsigned char *src_ptr, \
- int source_stride, \
- const unsigned char *ref_ptr, \
- int ref_stride \
- )
+ unsigned int (sym)\
+ (\
+ const unsigned char *src_ptr, \
+ int source_stride, \
+ const unsigned char *ref_ptr, \
+ int ref_stride \
+ )
#if ARCH_X86 || ARCH_X86_64
#include "x86/variance_x86.h"
@@ -143,7 +143,7 @@ extern prototype_sad(vp8_variance_sad16x8);
#endif
extern prototype_sad(vp8_variance_sad16x16);
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef vp8_variance_sad16x16x3
#define vp8_variance_sad16x16x3 vp8_sad16x16x3_c
@@ -195,7 +195,7 @@ extern prototype_sad_multi_same_address_1(vp8_variance_sad8x16x8);
#endif
extern prototype_sad_multi_same_address_1(vp8_variance_sad4x4x8);
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef vp8_variance_sad16x16x4d
#define vp8_variance_sad16x16x4d vp8_sad16x16x4d_c
@@ -229,7 +229,7 @@ extern prototype_sad_multi_dif_address(vp8_variance_sad4x4x4d);
extern prototype_sad(vp8_variance_copy32xn);
#endif
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef vp8_variance_var4x4
#define vp8_variance_var4x4 vp8_variance4x4_c
@@ -256,7 +256,7 @@ extern prototype_variance(vp8_variance_var16x8);
#endif
extern prototype_variance(vp8_variance_var16x16);
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef vp8_variance_subpixvar4x4
#define vp8_variance_subpixvar4x4 vp8_sub_pixel_variance4x4_c
@@ -303,7 +303,7 @@ extern prototype_variance(vp8_variance_halfpixvar16x16_hv);
#endif
extern prototype_subpixvariance(vp8_variance_subpixmse16x16);
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef vp8_variance_getmbss
#define vp8_variance_getmbss vp8_get_mb_ss_c
@@ -341,76 +341,74 @@ typedef prototype_getmbss(*vp8_getmbss_fn_t);
typedef prototype_ssimpf(*vp8_ssimpf_fn_t);
typedef prototype_get16x16prederror(*vp8_get16x16prederror_fn_t);
-typedef struct
-{
- vp8_sad_fn_t sad4x4;
- vp8_sad_fn_t sad8x8;
- vp8_sad_fn_t sad8x16;
- vp8_sad_fn_t sad16x8;
- vp8_sad_fn_t sad16x16;
-
- vp8_variance_fn_t var4x4;
- vp8_variance_fn_t var8x8;
- vp8_variance_fn_t var8x16;
- vp8_variance_fn_t var16x8;
- vp8_variance_fn_t var16x16;
-
- vp8_subpixvariance_fn_t subpixvar4x4;
- vp8_subpixvariance_fn_t subpixvar8x8;
- vp8_subpixvariance_fn_t subpixvar8x16;
- vp8_subpixvariance_fn_t subpixvar16x8;
- vp8_subpixvariance_fn_t subpixvar16x16;
- vp8_variance_fn_t halfpixvar16x16_h;
- vp8_variance_fn_t halfpixvar16x16_v;
- vp8_variance_fn_t halfpixvar16x16_hv;
- vp8_subpixvariance_fn_t subpixmse16x16;
-
- vp8_getmbss_fn_t getmbss;
- vp8_variance_fn_t mse16x16;
-
- vp8_sad_multi_fn_t sad16x16x3;
- vp8_sad_multi_fn_t sad16x8x3;
- vp8_sad_multi_fn_t sad8x16x3;
- vp8_sad_multi_fn_t sad8x8x3;
- vp8_sad_multi_fn_t sad4x4x3;
-
- vp8_sad_multi1_fn_t sad16x16x8;
- vp8_sad_multi1_fn_t sad16x8x8;
- vp8_sad_multi1_fn_t sad8x16x8;
- vp8_sad_multi1_fn_t sad8x8x8;
- vp8_sad_multi1_fn_t sad4x4x8;
-
- vp8_sad_multi_d_fn_t sad16x16x4d;
- vp8_sad_multi_d_fn_t sad16x8x4d;
- vp8_sad_multi_d_fn_t sad8x16x4d;
- vp8_sad_multi_d_fn_t sad8x8x4d;
- vp8_sad_multi_d_fn_t sad4x4x4d;
+typedef struct {
+ vp8_sad_fn_t sad4x4;
+ vp8_sad_fn_t sad8x8;
+ vp8_sad_fn_t sad8x16;
+ vp8_sad_fn_t sad16x8;
+ vp8_sad_fn_t sad16x16;
+
+ vp8_variance_fn_t var4x4;
+ vp8_variance_fn_t var8x8;
+ vp8_variance_fn_t var8x16;
+ vp8_variance_fn_t var16x8;
+ vp8_variance_fn_t var16x16;
+
+ vp8_subpixvariance_fn_t subpixvar4x4;
+ vp8_subpixvariance_fn_t subpixvar8x8;
+ vp8_subpixvariance_fn_t subpixvar8x16;
+ vp8_subpixvariance_fn_t subpixvar16x8;
+ vp8_subpixvariance_fn_t subpixvar16x16;
+ vp8_variance_fn_t halfpixvar16x16_h;
+ vp8_variance_fn_t halfpixvar16x16_v;
+ vp8_variance_fn_t halfpixvar16x16_hv;
+ vp8_subpixvariance_fn_t subpixmse16x16;
+
+ vp8_getmbss_fn_t getmbss;
+ vp8_variance_fn_t mse16x16;
+
+ vp8_sad_multi_fn_t sad16x16x3;
+ vp8_sad_multi_fn_t sad16x8x3;
+ vp8_sad_multi_fn_t sad8x16x3;
+ vp8_sad_multi_fn_t sad8x8x3;
+ vp8_sad_multi_fn_t sad4x4x3;
+
+ vp8_sad_multi1_fn_t sad16x16x8;
+ vp8_sad_multi1_fn_t sad16x8x8;
+ vp8_sad_multi1_fn_t sad8x16x8;
+ vp8_sad_multi1_fn_t sad8x8x8;
+ vp8_sad_multi1_fn_t sad4x4x8;
+
+ vp8_sad_multi_d_fn_t sad16x16x4d;
+ vp8_sad_multi_d_fn_t sad16x8x4d;
+ vp8_sad_multi_d_fn_t sad8x16x4d;
+ vp8_sad_multi_d_fn_t sad8x8x4d;
+ vp8_sad_multi_d_fn_t sad4x4x4d;
#if ARCH_X86 || ARCH_X86_64
- vp8_sad_fn_t copy32xn;
+ vp8_sad_fn_t copy32xn;
#endif
#if CONFIG_INTERNAL_STATS
- vp8_ssimpf_fn_t ssimpf_8x8;
- vp8_ssimpf_fn_t ssimpf_16x16;
+ vp8_ssimpf_fn_t ssimpf_8x8;
+ vp8_ssimpf_fn_t ssimpf_16x16;
#endif
- vp8_variance_fn_t satd16x16;
+ vp8_variance_fn_t satd16x16;
} vp8_variance_rtcd_vtable_t;
-typedef struct
-{
- vp8_sad_fn_t sdf;
- vp8_variance_fn_t vf;
- vp8_subpixvariance_fn_t svf;
- vp8_variance_fn_t svf_halfpix_h;
- vp8_variance_fn_t svf_halfpix_v;
- vp8_variance_fn_t svf_halfpix_hv;
- vp8_sad_multi_fn_t sdx3f;
- vp8_sad_multi1_fn_t sdx8f;
- vp8_sad_multi_d_fn_t sdx4df;
+typedef struct {
+ vp8_sad_fn_t sdf;
+ vp8_variance_fn_t vf;
+ vp8_subpixvariance_fn_t svf;
+ vp8_variance_fn_t svf_halfpix_h;
+ vp8_variance_fn_t svf_halfpix_v;
+ vp8_variance_fn_t svf_halfpix_hv;
+ vp8_sad_multi_fn_t sdx3f;
+ vp8_sad_multi1_fn_t sdx8f;
+ vp8_sad_multi_d_fn_t sdx4df;
#if ARCH_X86 || ARCH_X86_64
- vp8_sad_fn_t copymem;
+ vp8_sad_fn_t copymem;
#endif
} vp8_variance_fn_ptr_t;
diff --git a/vp8/encoder/variance_c.c b/vp8/encoder/variance_c.c
index 402ff0450..9444ed87d 100644
--- a/vp8/encoder/variance_c.c
+++ b/vp8/encoder/variance_c.c
@@ -15,148 +15,136 @@
unsigned int vp8_get_mb_ss_c
(
- const short *src_ptr
-)
-{
- unsigned int i = 0, sum = 0;
-
- do
- {
- sum += (src_ptr[i] * src_ptr[i]);
- i++;
- }
- while (i < 256);
+ const short *src_ptr
+) {
+ unsigned int i = 0, sum = 0;
+
+ do {
+ sum += (src_ptr[i] * src_ptr[i]);
+ i++;
+ } while (i < 256);
- return sum;
+ return sum;
}
static void variance(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- int w,
- int h,
- unsigned int *sse,
- int *sum)
-{
- int i, j;
- int diff;
-
- *sum = 0;
- *sse = 0;
-
- for (i = 0; i < h; i++)
- {
- for (j = 0; j < w; j++)
- {
- diff = src_ptr[j] - ref_ptr[j];
- *sum += diff;
- *sse += diff * diff;
- }
-
- src_ptr += source_stride;
- ref_ptr += recon_stride;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ int w,
+ int h,
+ unsigned int *sse,
+ int *sum) {
+ int i, j;
+ int diff;
+
+ *sum = 0;
+ *sse = 0;
+
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ diff = src_ptr[j] - ref_ptr[j];
+ *sum += diff;
+ *sse += diff * diff;
}
+
+ src_ptr += source_stride;
+ ref_ptr += recon_stride;
+ }
}
unsigned int vp8_variance16x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
- *sse = var;
- return (var - ((avg * avg) >> 8));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 8));
}
unsigned int vp8_variance8x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
- *sse = var;
- return (var - ((avg * avg) >> 7));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 7));
}
unsigned int vp8_variance16x8_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
- *sse = var;
- return (var - ((avg * avg) >> 7));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 7));
}
unsigned int vp8_variance8x8_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
- *sse = var;
- return (var - ((avg * avg) >> 6));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 6));
}
unsigned int vp8_variance4x4_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4, &var, &avg);
- *sse = var;
- return (var - ((avg * avg) >> 4));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 4));
}
unsigned int vp8_mse16x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
- *sse = var;
- return var;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
+ *sse = var;
+ return var;
}
@@ -190,32 +178,29 @@ unsigned int vp8_mse16x16_c(
****************************************************************************/
static void var_filter_block2d_bil_first_pass
(
- const unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- // Apply bilinear filter
- output_ptr[j] = (((int)src_ptr[0] * vp8_filter[0]) +
- ((int)src_ptr[pixel_step] * vp8_filter[1]) +
- (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
- src_ptr++;
- }
-
- // Next row...
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_width;
+ const unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ // Apply bilinear filter
+ output_ptr[j] = (((int)src_ptr[0] * vp8_filter[0]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[1]) +
+ (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
+ src_ptr++;
}
+
+ // Next row...
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_width;
+ }
}
/****************************************************************************
@@ -248,226 +233,214 @@ static void var_filter_block2d_bil_first_pass
****************************************************************************/
static void var_filter_block2d_bil_second_pass
(
- const unsigned short *src_ptr,
- unsigned char *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- const short *vp8_filter
-)
-{
- unsigned int i, j;
- int Temp;
-
- for (i = 0; i < output_height; i++)
- {
- for (j = 0; j < output_width; j++)
- {
- // Apply filter
- Temp = ((int)src_ptr[0] * vp8_filter[0]) +
- ((int)src_ptr[pixel_step] * vp8_filter[1]) +
- (VP8_FILTER_WEIGHT / 2);
- output_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
- src_ptr++;
- }
-
- // Next row...
- src_ptr += src_pixels_per_line - output_width;
- output_ptr += output_width;
+ const unsigned short *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ const short *vp8_filter
+) {
+ unsigned int i, j;
+ int Temp;
+
+ for (i = 0; i < output_height; i++) {
+ for (j = 0; j < output_width; j++) {
+ // Apply filter
+ Temp = ((int)src_ptr[0] * vp8_filter[0]) +
+ ((int)src_ptr[pixel_step] * vp8_filter[1]) +
+ (VP8_FILTER_WEIGHT / 2);
+ output_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
+ src_ptr++;
}
+
+ // Next row...
+ src_ptr += src_pixels_per_line - output_width;
+ output_ptr += output_width;
+ }
}
unsigned int vp8_sub_pixel_variance4x4_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned char temp2[20*16];
- const short *HFilter, *VFilter;
- unsigned short FData3[5*4]; // Temp data bufffer used in filtering
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- // First filter 1d Horizontal
- var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 5, 4, HFilter);
-
- // Now filter Verticaly
- var_filter_block2d_bil_second_pass(FData3, temp2, 4, 4, 4, 4, VFilter);
-
- return vp8_variance4x4_c(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned char temp2[20 * 16];
+ const short *HFilter, *VFilter;
+ unsigned short FData3[5 * 4]; // Temp data bufffer used in filtering
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ // First filter 1d Horizontal
+ var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 5, 4, HFilter);
+
+ // Now filter Verticaly
+ var_filter_block2d_bil_second_pass(FData3, temp2, 4, 4, 4, 4, VFilter);
+
+ return vp8_variance4x4_c(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
}
unsigned int vp8_sub_pixel_variance8x8_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short FData3[9*8]; // Temp data bufffer used in filtering
- unsigned char temp2[20*16];
- const short *HFilter, *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 8, HFilter);
- var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 8, 8, VFilter);
-
- return vp8_variance8x8_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short FData3[9 * 8]; // Temp data bufffer used in filtering
+ unsigned char temp2[20 * 16];
+ const short *HFilter, *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 8, HFilter);
+ var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 8, 8, VFilter);
+
+ return vp8_variance8x8_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
}
unsigned int vp8_sub_pixel_variance16x16_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short FData3[17*16]; // Temp data bufffer used in filtering
- unsigned char temp2[20*16];
- const short *HFilter, *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 16, HFilter);
- var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 16, 16, VFilter);
-
- return vp8_variance16x16_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short FData3[17 * 16]; // Temp data bufffer used in filtering
+ unsigned char temp2[20 * 16];
+ const short *HFilter, *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 16, HFilter);
+ var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 16, 16, VFilter);
+
+ return vp8_variance16x16_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
}
unsigned int vp8_variance_halfpixvar16x16_h_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 0,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 0,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 4, 0,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 4, 0,
+ ref_ptr, recon_stride, sse);
#endif
}
unsigned int vp8_variance_halfpixvar16x16_v_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 0, 8,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 0, 8,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 0, 4,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 0, 4,
+ ref_ptr, recon_stride, sse);
#endif
}
unsigned int vp8_variance_halfpixvar16x16_hv_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 8,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 8,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 4, 4,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_c(src_ptr, source_stride, 4, 4,
+ ref_ptr, recon_stride, sse);
#endif
}
unsigned int vp8_sub_pixel_mse16x16_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- vp8_sub_pixel_variance16x16_c(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
- return *sse;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ vp8_sub_pixel_variance16x16_c(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
+ return *sse;
}
unsigned int vp8_sub_pixel_variance16x8_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short FData3[16*9]; // Temp data bufffer used in filtering
- unsigned char temp2[20*16];
- const short *HFilter, *VFilter;
-
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
-
- var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 16, HFilter);
- var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 8, 16, VFilter);
-
- return vp8_variance16x8_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short FData3[16 * 9]; // Temp data bufffer used in filtering
+ unsigned char temp2[20 * 16];
+ const short *HFilter, *VFilter;
+
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
+
+ var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 16, HFilter);
+ var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 8, 16, VFilter);
+
+ return vp8_variance16x8_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
}
unsigned int vp8_sub_pixel_variance8x16_c
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- unsigned short FData3[9*16]; // Temp data bufffer used in filtering
- unsigned char temp2[20*16];
- const short *HFilter, *VFilter;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ unsigned short FData3[9 * 16]; // Temp data bufffer used in filtering
+ unsigned char temp2[20 * 16];
+ const short *HFilter, *VFilter;
- HFilter = vp8_bilinear_filters[xoffset];
- VFilter = vp8_bilinear_filters[yoffset];
+ HFilter = vp8_bilinear_filters[xoffset];
+ VFilter = vp8_bilinear_filters[yoffset];
- var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 8, HFilter);
- var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 16, 8, VFilter);
+ var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 8, HFilter);
+ var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 16, 8, VFilter);
- return vp8_variance8x16_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
+ return vp8_variance8x16_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
}
diff --git a/vp8/encoder/x86/variance_mmx.c b/vp8/encoder/x86/variance_mmx.c
index b84d00034..19264489d 100644
--- a/vp8/encoder/x86/variance_mmx.c
+++ b/vp8/encoder/x86/variance_mmx.c
@@ -15,185 +15,179 @@
extern void filter_block1d_h6_mmx
(
- const unsigned char *src_ptr,
- unsigned short *output_ptr,
- unsigned int src_pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- short *vp7_filter
+ const unsigned char *src_ptr,
+ unsigned short *output_ptr,
+ unsigned int src_pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ short *vp7_filter
);
extern void filter_block1d_v6_mmx
(
- const short *src_ptr,
- unsigned char *output_ptr,
- unsigned int pixels_per_line,
- unsigned int pixel_step,
- unsigned int output_height,
- unsigned int output_width,
- short *vp7_filter
+ const short *src_ptr,
+ unsigned char *output_ptr,
+ unsigned int pixels_per_line,
+ unsigned int pixel_step,
+ unsigned int output_height,
+ unsigned int output_width,
+ short *vp7_filter
);
extern unsigned int vp8_get_mb_ss_mmx(const short *src_ptr);
extern unsigned int vp8_get8x8var_mmx
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
extern unsigned int vp8_get4x4var_mmx
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
extern void vp8_filter_block2d_bil4x4_var_mmx
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- const short *HFilter,
- const short *VFilter,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ const short *HFilter,
+ const short *VFilter,
+ int *sum,
+ unsigned int *sumsquared
);
extern void vp8_filter_block2d_bil_var_mmx
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- const short *HFilter,
- const short *VFilter,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ const short *HFilter,
+ const short *VFilter,
+ int *sum,
+ unsigned int *sumsquared
);
unsigned int vp8_variance4x4_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
- *sse = var;
- return (var - ((avg * avg) >> 4));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 4));
}
unsigned int vp8_variance8x8_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
- vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
- *sse = var;
+ vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
+ *sse = var;
- return (var - ((avg * avg) >> 6));
+ return (var - ((avg * avg) >> 6));
}
unsigned int vp8_mse16x16_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, sse2, sse3, var;
- int sum0, sum1, sum2, sum3;
-
-
- vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
- vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ;
- vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
-
- var = sse0 + sse1 + sse2 + sse3;
- *sse = var;
- return var;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, sse2, sse3, var;
+ int sum0, sum1, sum2, sum3;
+
+
+ vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
+ vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
+ vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
+
+ var = sse0 + sse1 + sse2 + sse3;
+ *sse = var;
+ return var;
}
unsigned int vp8_variance16x16_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, sse2, sse3, var;
- int sum0, sum1, sum2, sum3, avg;
-
-
- vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
- vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ;
- vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
-
- var = sse0 + sse1 + sse2 + sse3;
- avg = sum0 + sum1 + sum2 + sum3;
- *sse = var;
- return (var - ((avg * avg) >> 8));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, sse2, sse3, var;
+ int sum0, sum1, sum2, sum3, avg;
+
+
+ vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
+ vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
+ vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
+
+ var = sse0 + sse1 + sse2 + sse3;
+ avg = sum0 + sum1 + sum2 + sum3;
+ *sse = var;
+ return (var - ((avg * avg) >> 8));
}
unsigned int vp8_variance16x8_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, var;
- int sum0, sum1, avg;
-
- vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
-
- var = sse0 + sse1;
- avg = sum0 + sum1;
- *sse = var;
- return (var - ((avg * avg) >> 7));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, var;
+ int sum0, sum1, avg;
+
+ vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
+
+ var = sse0 + sse1;
+ avg = sum0 + sum1;
+ *sse = var;
+ return (var - ((avg * avg) >> 7));
}
unsigned int vp8_variance8x16_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, var;
- int sum0, sum1, avg;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, var;
+ int sum0, sum1, avg;
- vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1) ;
+ vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1);
- var = sse0 + sse1;
- avg = sum0 + sum1;
- *sse = var;
+ var = sse0 + sse1;
+ avg = sum0 + sum1;
+ *sse = var;
- return (var - ((avg * avg) >> 7));
+ return (var - ((avg * avg) >> 7));
}
@@ -205,246 +199,236 @@ unsigned int vp8_variance8x16_mmx(
// int one pass //
///////////////////////////////////////////////////////////////////////////
#if CONFIG_SIXTEENTH_SUBPEL_UV
-DECLARE_ALIGNED(16, const short, vp8_vp7_bilinear_filters_mmx[16][8]) =
-{
- { 128, 128, 128, 128, 0, 0, 0, 0 },
- { 120, 120, 120, 120, 8, 8, 8, 8 },
- { 112, 112, 112, 112, 16, 16, 16, 16 },
- { 104, 104, 104, 104, 24, 24, 24, 24 },
- { 96, 96, 96, 96, 32, 32, 32, 32 },
- { 88, 88, 88, 88, 40, 40, 40, 40 },
- { 80, 80, 80, 80, 48, 48, 48, 48 },
- { 72, 72, 72, 72, 56, 56, 56, 56 },
- { 64, 64, 64, 64, 64, 64, 64, 64 },
- { 56, 56, 56, 56, 72, 72, 72, 72 },
- { 48, 48, 48, 48, 80, 80, 80, 80 },
- { 40, 40, 40, 40, 88, 88, 88, 88 },
- { 32, 32, 32, 32, 96, 96, 96, 96 },
- { 24, 24, 24, 24, 104, 104, 104, 104 },
- { 16, 16, 16, 16, 112, 112, 112, 112 },
- { 8, 8, 8, 8, 120, 120, 120, 120 }
+DECLARE_ALIGNED(16, const short, vp8_vp7_bilinear_filters_mmx[16][8]) = {
+ { 128, 128, 128, 128, 0, 0, 0, 0 },
+ { 120, 120, 120, 120, 8, 8, 8, 8 },
+ { 112, 112, 112, 112, 16, 16, 16, 16 },
+ { 104, 104, 104, 104, 24, 24, 24, 24 },
+ { 96, 96, 96, 96, 32, 32, 32, 32 },
+ { 88, 88, 88, 88, 40, 40, 40, 40 },
+ { 80, 80, 80, 80, 48, 48, 48, 48 },
+ { 72, 72, 72, 72, 56, 56, 56, 56 },
+ { 64, 64, 64, 64, 64, 64, 64, 64 },
+ { 56, 56, 56, 56, 72, 72, 72, 72 },
+ { 48, 48, 48, 48, 80, 80, 80, 80 },
+ { 40, 40, 40, 40, 88, 88, 88, 88 },
+ { 32, 32, 32, 32, 96, 96, 96, 96 },
+ { 24, 24, 24, 24, 104, 104, 104, 104 },
+ { 16, 16, 16, 16, 112, 112, 112, 112 },
+ { 8, 8, 8, 8, 120, 120, 120, 120 }
};
#else
-DECLARE_ALIGNED(16, const short, vp8_vp7_bilinear_filters_mmx[8][8]) =
-{
- { 128, 128, 128, 128, 0, 0, 0, 0 },
- { 112, 112, 112, 112, 16, 16, 16, 16 },
- { 96, 96, 96, 96, 32, 32, 32, 32 },
- { 80, 80, 80, 80, 48, 48, 48, 48 },
- { 64, 64, 64, 64, 64, 64, 64, 64 },
- { 48, 48, 48, 48, 80, 80, 80, 80 },
- { 32, 32, 32, 32, 96, 96, 96, 96 },
- { 16, 16, 16, 16, 112, 112, 112, 112 }
+DECLARE_ALIGNED(16, const short, vp8_vp7_bilinear_filters_mmx[8][8]) = {
+ { 128, 128, 128, 128, 0, 0, 0, 0 },
+ { 112, 112, 112, 112, 16, 16, 16, 16 },
+ { 96, 96, 96, 96, 32, 32, 32, 32 },
+ { 80, 80, 80, 80, 48, 48, 48, 48 },
+ { 64, 64, 64, 64, 64, 64, 64, 64 },
+ { 48, 48, 48, 48, 80, 80, 80, 80 },
+ { 32, 32, 32, 32, 96, 96, 96, 96 },
+ { 16, 16, 16, 16, 112, 112, 112, 112 }
};
#endif
unsigned int vp8_sub_pixel_variance4x4_mmx
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse)
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse)
{
- int xsum;
- unsigned int xxsum;
- vp8_filter_block2d_bil4x4_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum, &xxsum
- );
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 4));
+ int xsum;
+ unsigned int xxsum;
+ vp8_filter_block2d_bil4x4_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum, &xxsum
+ );
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 4));
}
unsigned int vp8_sub_pixel_variance8x8_mmx
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
-
- int xsum;
- unsigned int xxsum;
- vp8_filter_block2d_bil_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum, &xxsum
- );
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 6));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+
+ int xsum;
+ unsigned int xxsum;
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum, &xxsum
+ );
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 6));
}
unsigned int vp8_sub_pixel_variance16x16_mmx
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
-
- int xsum0, xsum1;
- unsigned int xxsum0, xxsum1;
-
- vp8_filter_block2d_bil_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum0, &xxsum0
- );
-
- vp8_filter_block2d_bil_var_mmx(
- src_ptr + 8, src_pixels_per_line,
- dst_ptr + 8, dst_pixels_per_line, 16,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum1, &xxsum1
- );
-
- xsum0 += xsum1;
- xxsum0 += xxsum1;
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+
+ int xsum0, xsum1;
+ unsigned int xxsum0, xxsum1;
+
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum0, &xxsum0
+ );
+
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr + 8, src_pixels_per_line,
+ dst_ptr + 8, dst_pixels_per_line, 16,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum1, &xxsum1
+ );
+
+ xsum0 += xsum1;
+ xxsum0 += xxsum1;
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
unsigned int vp8_sub_pixel_mse16x16_mmx(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- vp8_sub_pixel_variance16x16_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
- return *sse;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ vp8_sub_pixel_variance16x16_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
+ return *sse;
}
unsigned int vp8_sub_pixel_variance16x8_mmx
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum0, xsum1;
- unsigned int xxsum0, xxsum1;
-
-
- vp8_filter_block2d_bil_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum0, &xxsum0
- );
-
-
- vp8_filter_block2d_bil_var_mmx(
- src_ptr + 8, src_pixels_per_line,
- dst_ptr + 8, dst_pixels_per_line, 8,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum1, &xxsum1
- );
-
- xsum0 += xsum1;
- xxsum0 += xxsum1;
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 7));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum0, xsum1;
+ unsigned int xxsum0, xxsum1;
+
+
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum0, &xxsum0
+ );
+
+
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr + 8, src_pixels_per_line,
+ dst_ptr + 8, dst_pixels_per_line, 8,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum1, &xxsum1
+ );
+
+ xsum0 += xsum1;
+ xxsum0 += xxsum1;
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 7));
}
unsigned int vp8_sub_pixel_variance8x16_mmx
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum;
- unsigned int xxsum;
- vp8_filter_block2d_bil_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum, &xxsum
- );
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 7));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum;
+ unsigned int xxsum;
+ vp8_filter_block2d_bil_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum, &xxsum
+ );
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 7));
}
unsigned int vp8_variance_halfpixvar16x16_h_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 8, 0,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 8, 0,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 0,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 0,
+ ref_ptr, recon_stride, sse);
#endif
}
unsigned int vp8_variance_halfpixvar16x16_v_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 8,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 8,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 4,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 4,
+ ref_ptr, recon_stride, sse);
#endif
}
unsigned int vp8_variance_halfpixvar16x16_hv_mmx(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
#if CONFIG_SIXTEENTH_SUBPEL_UV
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 8, 8,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 8, 8,
+ ref_ptr, recon_stride, sse);
#else
- return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 4,
- ref_ptr, recon_stride, sse);
+ return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 4,
+ ref_ptr, recon_stride, sse);
#endif
}
diff --git a/vp8/encoder/x86/variance_sse2.c b/vp8/encoder/x86/variance_sse2.c
index e3c6268ea..0d6b2372e 100644
--- a/vp8/encoder/x86/variance_sse2.c
+++ b/vp8/encoder/x86/variance_sse2.c
@@ -26,119 +26,119 @@ extern void filter_block1d8_v6_sse2(const short *src_ptr, unsigned char *output_
extern void vp8_filter_block2d_bil4x4_var_mmx
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- const short *HFilter,
- const short *VFilter,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ const short *HFilter,
+ const short *VFilter,
+ int *sum,
+ unsigned int *sumsquared
);
extern unsigned int vp8_get4x4var_mmx
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
unsigned int vp8_get_mb_ss_sse2
(
- const short *src_ptr
+ const short *src_ptr
);
unsigned int vp8_get16x16var_sse2
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
unsigned int vp8_get8x8var_sse2
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
void vp8_filter_block2d_bil_var_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int xoffset,
- int yoffset,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int xoffset,
+ int yoffset,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_horiz_vert_variance8x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_horiz_vert_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_horiz_variance8x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_horiz_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_vert_variance8x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
void vp8_half_vert_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
#if CONFIG_SIXTEENTH_SUBPEL_UV
@@ -148,421 +148,378 @@ DECLARE_ALIGNED(16, extern short, vp8_vp7_bilinear_filters_mmx[8][8]);
#endif
unsigned int vp8_variance4x4_wmt(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
- *sse = var;
- return (var - ((avg * avg) >> 4));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 4));
}
unsigned int vp8_variance8x8_wmt
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
- *sse = var;
- return (var - ((avg * avg) >> 6));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
+ *sse = var;
+ return (var - ((avg * avg) >> 6));
}
unsigned int vp8_variance16x16_wmt
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0;
- int sum0;
-
-
- vp8_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- *sse = sse0;
- return (sse0 - ((sum0 * sum0) >> 8));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0;
+ int sum0;
+
+
+ vp8_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ *sse = sse0;
+ return (sse0 - ((sum0 * sum0) >> 8));
}
unsigned int vp8_mse16x16_wmt(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
-
- unsigned int sse0;
- int sum0;
- vp8_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- *sse = sse0;
- return sse0;
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+
+ unsigned int sse0;
+ int sum0;
+ vp8_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ *sse = sse0;
+ return sse0;
}
unsigned int vp8_variance16x8_wmt
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, var;
- int sum0, sum1, avg;
-
- vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_sse2(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
-
- var = sse0 + sse1;
- avg = sum0 + sum1;
- *sse = var;
- return (var - ((avg * avg) >> 7));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, var;
+ int sum0, sum1, avg;
+
+ vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_sse2(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
+
+ var = sse0 + sse1;
+ avg = sum0 + sum1;
+ *sse = var;
+ return (var - ((avg * avg) >> 7));
}
unsigned int vp8_variance8x16_wmt
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int sse0, sse1, var;
- int sum0, sum1, avg;
-
- vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
- vp8_get8x8var_sse2(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1) ;
-
- var = sse0 + sse1;
- avg = sum0 + sum1;
- *sse = var;
- return (var - ((avg * avg) >> 7));
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int sse0, sse1, var;
+ int sum0, sum1, avg;
+
+ vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
+ vp8_get8x8var_sse2(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1);
+
+ var = sse0 + sse1;
+ avg = sum0 + sum1;
+ *sse = var;
+ return (var - ((avg * avg) >> 7));
}
unsigned int vp8_sub_pixel_variance4x4_wmt
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum;
- unsigned int xxsum;
- vp8_filter_block2d_bil4x4_var_mmx(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line,
- vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
- &xsum, &xxsum
- );
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 4));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum;
+ unsigned int xxsum;
+ vp8_filter_block2d_bil4x4_var_mmx(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line,
+ vp8_vp7_bilinear_filters_mmx[xoffset], vp8_vp7_bilinear_filters_mmx[yoffset],
+ &xsum, &xxsum
+ );
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 4));
}
unsigned int vp8_sub_pixel_variance8x8_wmt
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum;
- unsigned int xxsum;
-
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum, &xxsum);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum, &xxsum);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum, &xxsum);
- }
- else
- {
- vp8_filter_block2d_bil_var_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- xoffset, yoffset,
- &xsum, &xxsum);
- }
-
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 6));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum;
+ unsigned int xxsum;
+
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum, &xxsum);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum, &xxsum);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum, &xxsum);
+ } else {
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ xoffset, yoffset,
+ &xsum, &xxsum);
+ }
+
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 6));
}
unsigned int vp8_sub_pixel_variance16x16_wmt
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum0, xsum1;
- unsigned int xxsum0, xxsum1;
-
-
- // note we could avoid these if statements if the calling function
- // just called the appropriate functions inside.
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else
- {
- vp8_filter_block2d_bil_var_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- xoffset, yoffset,
- &xsum0, &xxsum0
- );
-
- vp8_filter_block2d_bil_var_sse2(
- src_ptr + 8, src_pixels_per_line,
- dst_ptr + 8, dst_pixels_per_line, 16,
- xoffset, yoffset,
- &xsum1, &xxsum1
- );
- xsum0 += xsum1;
- xxsum0 += xxsum1;
- }
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum0, xsum1;
+ unsigned int xxsum0, xxsum1;
+
+
+ // note we could avoid these if statements if the calling function
+ // just called the appropriate functions inside.
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else {
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ xoffset, yoffset,
+ &xsum0, &xxsum0
+ );
+
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr + 8, src_pixels_per_line,
+ dst_ptr + 8, dst_pixels_per_line, 16,
+ xoffset, yoffset,
+ &xsum1, &xxsum1
+ );
+ xsum0 += xsum1;
+ xxsum0 += xxsum1;
+ }
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
unsigned int vp8_sub_pixel_mse16x16_wmt(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- vp8_sub_pixel_variance16x16_wmt(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
- return *sse;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ vp8_sub_pixel_variance16x16_wmt(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
+ return *sse;
}
unsigned int vp8_sub_pixel_variance16x8_wmt
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-
-)
-{
- int xsum0, xsum1;
- unsigned int xxsum0, xxsum1;
-
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else
- {
- vp8_filter_block2d_bil_var_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- xoffset, yoffset,
- &xsum0, &xxsum0);
-
- vp8_filter_block2d_bil_var_sse2(
- src_ptr + 8, src_pixels_per_line,
- dst_ptr + 8, dst_pixels_per_line, 8,
- xoffset, yoffset,
- &xsum1, &xxsum1);
- xsum0 += xsum1;
- xxsum0 += xxsum1;
- }
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 7));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+
+) {
+ int xsum0, xsum1;
+ unsigned int xxsum0, xxsum1;
+
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else {
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ xoffset, yoffset,
+ &xsum0, &xxsum0);
+
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr + 8, src_pixels_per_line,
+ dst_ptr + 8, dst_pixels_per_line, 8,
+ xoffset, yoffset,
+ &xsum1, &xxsum1);
+ xsum0 += xsum1;
+ xxsum0 += xxsum1;
+ }
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 7));
}
unsigned int vp8_sub_pixel_variance8x16_wmt
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum;
- unsigned int xxsum;
-
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum, &xxsum);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum, &xxsum);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance8x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum, &xxsum);
- }
- else
- {
- vp8_filter_block2d_bil_var_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- xoffset, yoffset,
- &xsum, &xxsum);
- }
-
- *sse = xxsum;
- return (xxsum - ((xsum * xsum) >> 7));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum;
+ unsigned int xxsum;
+
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum, &xxsum);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum, &xxsum);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance8x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum, &xxsum);
+ } else {
+ vp8_filter_block2d_bil_var_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ xoffset, yoffset,
+ &xsum, &xxsum);
+ }
+
+ *sse = xxsum;
+ return (xxsum - ((xsum * xsum) >> 7));
}
unsigned int vp8_variance_halfpixvar16x16_h_wmt(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse)
-{
- int xsum0;
- unsigned int xxsum0;
-
- vp8_half_horiz_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse) {
+ int xsum0;
+ unsigned int xxsum0;
+
+ vp8_half_horiz_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
unsigned int vp8_variance_halfpixvar16x16_v_wmt(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse)
-{
- int xsum0;
- unsigned int xxsum0;
- vp8_half_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse) {
+ int xsum0;
+ unsigned int xxsum0;
+ vp8_half_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
unsigned int vp8_variance_halfpixvar16x16_hv_wmt(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse)
-{
- int xsum0;
- unsigned int xxsum0;
-
- vp8_half_horiz_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
-
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse) {
+ int xsum0;
+ unsigned int xxsum0;
+
+ vp8_half_horiz_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
diff --git a/vp8/encoder/x86/variance_ssse3.c b/vp8/encoder/x86/variance_ssse3.c
index fc2a3c3f2..fc3b313f6 100644
--- a/vp8/encoder/x86/variance_ssse3.c
+++ b/vp8/encoder/x86/variance_ssse3.c
@@ -21,151 +21,135 @@
extern unsigned int vp8_get16x16var_sse2
(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *SSE,
- int *Sum
+ const unsigned char *src_ptr,
+ int source_stride,
+ const unsigned char *ref_ptr,
+ int recon_stride,
+ unsigned int *SSE,
+ int *Sum
);
extern void vp8_half_horiz_vert_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
extern void vp8_half_horiz_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
extern void vp8_half_vert_variance16x_h_sse2
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int *sum,
+ unsigned int *sumsquared
);
extern void vp8_filter_block2d_bil_var_ssse3
(
- const unsigned char *ref_ptr,
- int ref_pixels_per_line,
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- unsigned int Height,
- int xoffset,
- int yoffset,
- int *sum,
- unsigned int *sumsquared
+ const unsigned char *ref_ptr,
+ int ref_pixels_per_line,
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ unsigned int Height,
+ int xoffset,
+ int yoffset,
+ int *sum,
+ unsigned int *sumsquared
);
unsigned int vp8_sub_pixel_variance16x16_ssse3
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
-)
-{
- int xsum0;
- unsigned int xxsum0;
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
+) {
+ int xsum0;
+ unsigned int xxsum0;
- // note we could avoid these if statements if the calling function
- // just called the appropriate functions inside.
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- &xsum0, &xxsum0);
- }
- else
- {
- vp8_filter_block2d_bil_var_ssse3(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 16,
- xoffset, yoffset,
- &xsum0, &xxsum0);
- }
+ // note we could avoid these if statements if the calling function
+ // just called the appropriate functions inside.
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ &xsum0, &xxsum0);
+ } else {
+ vp8_filter_block2d_bil_var_ssse3(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 16,
+ xoffset, yoffset,
+ &xsum0, &xxsum0);
+ }
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 8));
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 8));
}
unsigned int vp8_sub_pixel_variance16x8_ssse3
(
- const unsigned char *src_ptr,
- int src_pixels_per_line,
- int xoffset,
- int yoffset,
- const unsigned char *dst_ptr,
- int dst_pixels_per_line,
- unsigned int *sse
+ const unsigned char *src_ptr,
+ int src_pixels_per_line,
+ int xoffset,
+ int yoffset,
+ const unsigned char *dst_ptr,
+ int dst_pixels_per_line,
+ unsigned int *sse
-)
-{
- int xsum0;
- unsigned int xxsum0;
+) {
+ int xsum0;
+ unsigned int xxsum0;
- if (xoffset == HALFNDX && yoffset == 0)
- {
- vp8_half_horiz_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else if (xoffset == 0 && yoffset == HALFNDX)
- {
- vp8_half_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else if (xoffset == HALFNDX && yoffset == HALFNDX)
- {
- vp8_half_horiz_vert_variance16x_h_sse2(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- &xsum0, &xxsum0);
- }
- else
- {
- vp8_filter_block2d_bil_var_ssse3(
- src_ptr, src_pixels_per_line,
- dst_ptr, dst_pixels_per_line, 8,
- xoffset, yoffset,
- &xsum0, &xxsum0);
- }
+ if (xoffset == HALFNDX && yoffset == 0) {
+ vp8_half_horiz_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else if (xoffset == 0 && yoffset == HALFNDX) {
+ vp8_half_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else if (xoffset == HALFNDX && yoffset == HALFNDX) {
+ vp8_half_horiz_vert_variance16x_h_sse2(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ &xsum0, &xxsum0);
+ } else {
+ vp8_filter_block2d_bil_var_ssse3(
+ src_ptr, src_pixels_per_line,
+ dst_ptr, dst_pixels_per_line, 8,
+ xoffset, yoffset,
+ &xsum0, &xxsum0);
+ }
- *sse = xxsum0;
- return (xxsum0 - ((xsum0 * xsum0) >> 7));
+ *sse = xxsum0;
+ return (xxsum0 - ((xsum0 * xsum0) >> 7));
}
diff --git a/vp8/encoder/x86/x86_csystemdependent.c b/vp8/encoder/x86/x86_csystemdependent.c
index ae803f860..146888a1f 100644
--- a/vp8/encoder/x86/x86_csystemdependent.c
+++ b/vp8/encoder/x86/x86_csystemdependent.c
@@ -16,227 +16,214 @@
#if HAVE_MMX
-void vp8_short_fdct8x4_mmx(short *input, short *output, int pitch)
-{
- vp8_short_fdct4x4_mmx(input, output, pitch);
- vp8_short_fdct4x4_mmx(input + 4, output + 16, pitch);
+void vp8_short_fdct8x4_mmx(short *input, short *output, int pitch) {
+ vp8_short_fdct4x4_mmx(input, output, pitch);
+ vp8_short_fdct4x4_mmx(input + 4, output + 16, pitch);
}
int vp8_mbblock_error_mmx_impl(short *coeff_ptr, short *dcoef_ptr, int dc);
-int vp8_mbblock_error_mmx(MACROBLOCK *mb, int dc)
-{
- short *coeff_ptr = mb->block[0].coeff;
- short *dcoef_ptr = mb->e_mbd.block[0].dqcoeff;
- return vp8_mbblock_error_mmx_impl(coeff_ptr, dcoef_ptr, dc);
+int vp8_mbblock_error_mmx(MACROBLOCK *mb, int dc) {
+ short *coeff_ptr = mb->block[0].coeff;
+ short *dcoef_ptr = mb->e_mbd.block[0].dqcoeff;
+ return vp8_mbblock_error_mmx_impl(coeff_ptr, dcoef_ptr, dc);
}
int vp8_mbuverror_mmx_impl(short *s_ptr, short *d_ptr);
-int vp8_mbuverror_mmx(MACROBLOCK *mb)
-{
- short *s_ptr = &mb->coeff[256];
- short *d_ptr = &mb->e_mbd.dqcoeff[256];
- return vp8_mbuverror_mmx_impl(s_ptr, d_ptr);
+int vp8_mbuverror_mmx(MACROBLOCK *mb) {
+ short *s_ptr = &mb->coeff[256];
+ short *d_ptr = &mb->e_mbd.dqcoeff[256];
+ return vp8_mbuverror_mmx_impl(s_ptr, d_ptr);
}
void vp8_subtract_b_mmx_impl(unsigned char *z, int src_stride,
short *diff, unsigned char *predictor,
int pitch);
-void vp8_subtract_b_mmx(BLOCK *be, BLOCKD *bd, int pitch)
-{
- unsigned char *z = *(be->base_src) + be->src;
- unsigned int src_stride = be->src_stride;
- short *diff = &be->src_diff[0];
- unsigned char *predictor = &bd->predictor[0];
- vp8_subtract_b_mmx_impl(z, src_stride, diff, predictor, pitch);
+void vp8_subtract_b_mmx(BLOCK *be, BLOCKD *bd, int pitch) {
+ unsigned char *z = *(be->base_src) + be->src;
+ unsigned int src_stride = be->src_stride;
+ short *diff = &be->src_diff[0];
+ unsigned char *predictor = &bd->predictor[0];
+ vp8_subtract_b_mmx_impl(z, src_stride, diff, predictor, pitch);
}
#endif
#if HAVE_SSE2
int vp8_mbblock_error_xmm_impl(short *coeff_ptr, short *dcoef_ptr, int dc);
-int vp8_mbblock_error_xmm(MACROBLOCK *mb, int dc)
-{
- short *coeff_ptr = mb->block[0].coeff;
- short *dcoef_ptr = mb->e_mbd.block[0].dqcoeff;
- return vp8_mbblock_error_xmm_impl(coeff_ptr, dcoef_ptr, dc);
+int vp8_mbblock_error_xmm(MACROBLOCK *mb, int dc) {
+ short *coeff_ptr = mb->block[0].coeff;
+ short *dcoef_ptr = mb->e_mbd.block[0].dqcoeff;
+ return vp8_mbblock_error_xmm_impl(coeff_ptr, dcoef_ptr, dc);
}
int vp8_mbuverror_xmm_impl(short *s_ptr, short *d_ptr);
-int vp8_mbuverror_xmm(MACROBLOCK *mb)
-{
- short *s_ptr = &mb->coeff[256];
- short *d_ptr = &mb->e_mbd.dqcoeff[256];
- return vp8_mbuverror_xmm_impl(s_ptr, d_ptr);
+int vp8_mbuverror_xmm(MACROBLOCK *mb) {
+ short *s_ptr = &mb->coeff[256];
+ short *d_ptr = &mb->e_mbd.dqcoeff[256];
+ return vp8_mbuverror_xmm_impl(s_ptr, d_ptr);
}
void vp8_subtract_b_sse2_impl(unsigned char *z, int src_stride,
- short *diff, unsigned char *predictor,
- int pitch);
-void vp8_subtract_b_sse2(BLOCK *be, BLOCKD *bd, int pitch)
-{
- unsigned char *z = *(be->base_src) + be->src;
- unsigned int src_stride = be->src_stride;
- short *diff = &be->src_diff[0];
- unsigned char *predictor = &bd->predictor[0];
- vp8_subtract_b_sse2_impl(z, src_stride, diff, predictor, pitch);
+ short *diff, unsigned char *predictor,
+ int pitch);
+void vp8_subtract_b_sse2(BLOCK *be, BLOCKD *bd, int pitch) {
+ unsigned char *z = *(be->base_src) + be->src;
+ unsigned int src_stride = be->src_stride;
+ short *diff = &be->src_diff[0];
+ unsigned char *predictor = &bd->predictor[0];
+ vp8_subtract_b_sse2_impl(z, src_stride, diff, predictor, pitch);
}
#endif
-void vp8_arch_x86_encoder_init(VP8_COMP *cpi)
-{
+void vp8_arch_x86_encoder_init(VP8_COMP *cpi) {
#if CONFIG_RUNTIME_CPU_DETECT
- int flags = x86_simd_caps();
+ int flags = x86_simd_caps();
- /* Note:
- *
- * This platform can be built without runtime CPU detection as well. If
- * you modify any of the function mappings present in this file, be sure
- * to also update them in static mapings (<arch>/filename_<arch>.h)
- */
+ /* Note:
+ *
+ * This platform can be built without runtime CPU detection as well. If
+ * you modify any of the function mappings present in this file, be sure
+ * to also update them in static mapings (<arch>/filename_<arch>.h)
+ */
- /* Override default functions with fastest ones for this CPU. */
+ /* Override default functions with fastest ones for this CPU. */
#if HAVE_MMX
- if (flags & HAS_MMX)
- {
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_mmx;
- cpi->rtcd.variance.sad16x8 = vp8_sad16x8_mmx;
- cpi->rtcd.variance.sad8x16 = vp8_sad8x16_mmx;
- cpi->rtcd.variance.sad8x8 = vp8_sad8x8_mmx;
- cpi->rtcd.variance.sad4x4 = vp8_sad4x4_mmx;
-
- cpi->rtcd.variance.var4x4 = vp8_variance4x4_mmx;
- cpi->rtcd.variance.var8x8 = vp8_variance8x8_mmx;
- cpi->rtcd.variance.var8x16 = vp8_variance8x16_mmx;
- cpi->rtcd.variance.var16x8 = vp8_variance16x8_mmx;
- cpi->rtcd.variance.var16x16 = vp8_variance16x16_mmx;
-
- cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_mmx;
- cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_mmx;
- cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_mmx;
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_mmx;
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_mmx;
- cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_mmx;
- cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_mmx;
- cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_mmx;
- cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_mmx;
-
- cpi->rtcd.variance.mse16x16 = vp8_mse16x16_mmx;
- cpi->rtcd.variance.getmbss = vp8_get_mb_ss_mmx;
-
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_mmx;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_mmx;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_mmx;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_mmx;
-
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
-
- cpi->rtcd.encodemb.berr = vp8_block_error_mmx;
- cpi->rtcd.encodemb.mberr = vp8_mbblock_error_mmx;
- cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_mmx;
- cpi->rtcd.encodemb.subb = vp8_subtract_b_mmx;
- cpi->rtcd.encodemb.submby = vp8_subtract_mby_mmx;
- cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_mmx;
- }
+ if (flags & HAS_MMX) {
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_mmx;
+ cpi->rtcd.variance.sad16x8 = vp8_sad16x8_mmx;
+ cpi->rtcd.variance.sad8x16 = vp8_sad8x16_mmx;
+ cpi->rtcd.variance.sad8x8 = vp8_sad8x8_mmx;
+ cpi->rtcd.variance.sad4x4 = vp8_sad4x4_mmx;
+
+ cpi->rtcd.variance.var4x4 = vp8_variance4x4_mmx;
+ cpi->rtcd.variance.var8x8 = vp8_variance8x8_mmx;
+ cpi->rtcd.variance.var8x16 = vp8_variance8x16_mmx;
+ cpi->rtcd.variance.var16x8 = vp8_variance16x8_mmx;
+ cpi->rtcd.variance.var16x16 = vp8_variance16x16_mmx;
+
+ cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_mmx;
+ cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_mmx;
+ cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_mmx;
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_mmx;
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_mmx;
+ cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_mmx;
+ cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_mmx;
+ cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_mmx;
+ cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_mmx;
+
+ cpi->rtcd.variance.mse16x16 = vp8_mse16x16_mmx;
+ cpi->rtcd.variance.getmbss = vp8_get_mb_ss_mmx;
+
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_mmx;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_mmx;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_mmx;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_mmx;
+
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_c;
+
+ cpi->rtcd.encodemb.berr = vp8_block_error_mmx;
+ cpi->rtcd.encodemb.mberr = vp8_mbblock_error_mmx;
+ cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_mmx;
+ cpi->rtcd.encodemb.subb = vp8_subtract_b_mmx;
+ cpi->rtcd.encodemb.submby = vp8_subtract_mby_mmx;
+ cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_mmx;
+ }
#endif
#if HAVE_SSE2
- if (flags & HAS_SSE2)
- {
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_wmt;
- cpi->rtcd.variance.sad16x8 = vp8_sad16x8_wmt;
- cpi->rtcd.variance.sad8x16 = vp8_sad8x16_wmt;
- cpi->rtcd.variance.sad8x8 = vp8_sad8x8_wmt;
- cpi->rtcd.variance.sad4x4 = vp8_sad4x4_wmt;
- cpi->rtcd.variance.copy32xn = vp8_copy32xn_sse2;
-
- cpi->rtcd.variance.var4x4 = vp8_variance4x4_wmt;
- cpi->rtcd.variance.var8x8 = vp8_variance8x8_wmt;
- cpi->rtcd.variance.var8x16 = vp8_variance8x16_wmt;
- cpi->rtcd.variance.var16x8 = vp8_variance16x8_wmt;
- cpi->rtcd.variance.var16x16 = vp8_variance16x16_wmt;
-
- cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_wmt;
- cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_wmt;
- cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_wmt;
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_wmt;
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_wmt;
- cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_wmt;
- cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_wmt;
- cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_wmt;
- cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_wmt;
-
- cpi->rtcd.variance.mse16x16 = vp8_mse16x16_wmt;
- cpi->rtcd.variance.getmbss = vp8_get_mb_ss_sse2;
-
- cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_sse2;
- cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_sse2;
- cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_sse2;
- cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_sse2;
-
- cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_sse2 ;
-
- cpi->rtcd.encodemb.berr = vp8_block_error_xmm;
- cpi->rtcd.encodemb.mberr = vp8_mbblock_error_xmm;
- cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_xmm;
- cpi->rtcd.encodemb.subb = vp8_subtract_b_sse2;
- cpi->rtcd.encodemb.submby = vp8_subtract_mby_sse2;
- cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_sse2;
- cpi->rtcd.temporal.apply = vp8_temporal_filter_apply_sse2;
+ if (flags & HAS_SSE2) {
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_wmt;
+ cpi->rtcd.variance.sad16x8 = vp8_sad16x8_wmt;
+ cpi->rtcd.variance.sad8x16 = vp8_sad8x16_wmt;
+ cpi->rtcd.variance.sad8x8 = vp8_sad8x8_wmt;
+ cpi->rtcd.variance.sad4x4 = vp8_sad4x4_wmt;
+ cpi->rtcd.variance.copy32xn = vp8_copy32xn_sse2;
+
+ cpi->rtcd.variance.var4x4 = vp8_variance4x4_wmt;
+ cpi->rtcd.variance.var8x8 = vp8_variance8x8_wmt;
+ cpi->rtcd.variance.var8x16 = vp8_variance8x16_wmt;
+ cpi->rtcd.variance.var16x8 = vp8_variance16x8_wmt;
+ cpi->rtcd.variance.var16x16 = vp8_variance16x16_wmt;
+
+ cpi->rtcd.variance.subpixvar4x4 = vp8_sub_pixel_variance4x4_wmt;
+ cpi->rtcd.variance.subpixvar8x8 = vp8_sub_pixel_variance8x8_wmt;
+ cpi->rtcd.variance.subpixvar8x16 = vp8_sub_pixel_variance8x16_wmt;
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_wmt;
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_wmt;
+ cpi->rtcd.variance.halfpixvar16x16_h = vp8_variance_halfpixvar16x16_h_wmt;
+ cpi->rtcd.variance.halfpixvar16x16_v = vp8_variance_halfpixvar16x16_v_wmt;
+ cpi->rtcd.variance.halfpixvar16x16_hv = vp8_variance_halfpixvar16x16_hv_wmt;
+ cpi->rtcd.variance.subpixmse16x16 = vp8_sub_pixel_mse16x16_wmt;
+
+ cpi->rtcd.variance.mse16x16 = vp8_mse16x16_wmt;
+ cpi->rtcd.variance.getmbss = vp8_get_mb_ss_sse2;
+
+ cpi->rtcd.fdct.short4x4 = vp8_short_fdct4x4_sse2;
+ cpi->rtcd.fdct.short8x4 = vp8_short_fdct8x4_sse2;
+ cpi->rtcd.fdct.fast4x4 = vp8_short_fdct4x4_sse2;
+ cpi->rtcd.fdct.fast8x4 = vp8_short_fdct8x4_sse2;
+
+ cpi->rtcd.fdct.walsh_short4x4 = vp8_short_walsh4x4_sse2;
+
+ cpi->rtcd.encodemb.berr = vp8_block_error_xmm;
+ cpi->rtcd.encodemb.mberr = vp8_mbblock_error_xmm;
+ cpi->rtcd.encodemb.mbuverr = vp8_mbuverror_xmm;
+ cpi->rtcd.encodemb.subb = vp8_subtract_b_sse2;
+ cpi->rtcd.encodemb.submby = vp8_subtract_mby_sse2;
+ cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_sse2;
+ cpi->rtcd.temporal.apply = vp8_temporal_filter_apply_sse2;
#if CONFIG_INTERNAL_STATS
#if ARCH_X86_64
- cpi->rtcd.variance.ssimpf_8x8 = vp8_ssim_parms_8x8_sse2;
- cpi->rtcd.variance.ssimpf_16x16 = vp8_ssim_parms_16x16_sse2;
+ cpi->rtcd.variance.ssimpf_8x8 = vp8_ssim_parms_8x8_sse2;
+ cpi->rtcd.variance.ssimpf_16x16 = vp8_ssim_parms_16x16_sse2;
#endif
#endif
- }
+ }
#endif
#if HAVE_SSE3
- if (flags & HAS_SSE3)
- {
- cpi->rtcd.variance.sad16x16 = vp8_sad16x16_sse3;
- cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_sse3;
- cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_sse3;
- cpi->rtcd.variance.sad8x16x3 = vp8_sad8x16x3_sse3;
- cpi->rtcd.variance.sad8x8x3 = vp8_sad8x8x3_sse3;
- cpi->rtcd.variance.sad4x4x3 = vp8_sad4x4x3_sse3;
- cpi->rtcd.search.full_search = vp8_full_search_sadx3;
- cpi->rtcd.variance.sad16x16x4d = vp8_sad16x16x4d_sse3;
- cpi->rtcd.variance.sad16x8x4d = vp8_sad16x8x4d_sse3;
- cpi->rtcd.variance.sad8x16x4d = vp8_sad8x16x4d_sse3;
- cpi->rtcd.variance.sad8x8x4d = vp8_sad8x8x4d_sse3;
- cpi->rtcd.variance.sad4x4x4d = vp8_sad4x4x4d_sse3;
- cpi->rtcd.variance.copy32xn = vp8_copy32xn_sse3;
- cpi->rtcd.search.diamond_search = vp8_diamond_search_sadx4;
- cpi->rtcd.search.refining_search = vp8_refining_search_sadx4;
- }
+ if (flags & HAS_SSE3) {
+ cpi->rtcd.variance.sad16x16 = vp8_sad16x16_sse3;
+ cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_sse3;
+ cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_sse3;
+ cpi->rtcd.variance.sad8x16x3 = vp8_sad8x16x3_sse3;
+ cpi->rtcd.variance.sad8x8x3 = vp8_sad8x8x3_sse3;
+ cpi->rtcd.variance.sad4x4x3 = vp8_sad4x4x3_sse3;
+ cpi->rtcd.search.full_search = vp8_full_search_sadx3;
+ cpi->rtcd.variance.sad16x16x4d = vp8_sad16x16x4d_sse3;
+ cpi->rtcd.variance.sad16x8x4d = vp8_sad16x8x4d_sse3;
+ cpi->rtcd.variance.sad8x16x4d = vp8_sad8x16x4d_sse3;
+ cpi->rtcd.variance.sad8x8x4d = vp8_sad8x8x4d_sse3;
+ cpi->rtcd.variance.sad4x4x4d = vp8_sad4x4x4d_sse3;
+ cpi->rtcd.variance.copy32xn = vp8_copy32xn_sse3;
+ cpi->rtcd.search.diamond_search = vp8_diamond_search_sadx4;
+ cpi->rtcd.search.refining_search = vp8_refining_search_sadx4;
+ }
#endif
#if HAVE_SSSE3
- if (flags & HAS_SSSE3)
- {
- cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_ssse3;
- cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_ssse3;
-
- cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_ssse3;
- cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_ssse3;
- }
+ if (flags & HAS_SSSE3) {
+ cpi->rtcd.variance.sad16x16x3 = vp8_sad16x16x3_ssse3;
+ cpi->rtcd.variance.sad16x8x3 = vp8_sad16x8x3_ssse3;
+
+ cpi->rtcd.variance.subpixvar16x8 = vp8_sub_pixel_variance16x8_ssse3;
+ cpi->rtcd.variance.subpixvar16x16 = vp8_sub_pixel_variance16x16_ssse3;
+ }
#endif
#if HAVE_SSE4_1
- if (flags & HAS_SSE4_1)
- {
- cpi->rtcd.variance.sad16x16x8 = vp8_sad16x16x8_sse4;
- cpi->rtcd.variance.sad16x8x8 = vp8_sad16x8x8_sse4;
- cpi->rtcd.variance.sad8x16x8 = vp8_sad8x16x8_sse4;
- cpi->rtcd.variance.sad8x8x8 = vp8_sad8x8x8_sse4;
- cpi->rtcd.variance.sad4x4x8 = vp8_sad4x4x8_sse4;
- cpi->rtcd.search.full_search = vp8_full_search_sadx8;
- }
+ if (flags & HAS_SSE4_1) {
+ cpi->rtcd.variance.sad16x16x8 = vp8_sad16x16x8_sse4;
+ cpi->rtcd.variance.sad16x8x8 = vp8_sad16x8x8_sse4;
+ cpi->rtcd.variance.sad8x16x8 = vp8_sad8x16x8_sse4;
+ cpi->rtcd.variance.sad8x8x8 = vp8_sad8x8x8_sse4;
+ cpi->rtcd.variance.sad4x4x8 = vp8_sad4x4x8_sse4;
+ cpi->rtcd.search.full_search = vp8_full_search_sadx8;
+ }
#endif
#endif
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c
index be32c3719..b12aac80b 100644
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -24,360 +24,343 @@
*/
#define NO_MODE_SET 255
-struct vp8_extracfg
-{
- struct vpx_codec_pkt_list *pkt_list;
- vp8e_encoding_mode encoding_mode; /** best, good, realtime */
- int cpu_used; /** available cpu percentage in 1/16*/
- unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */
- unsigned int noise_sensitivity;
- unsigned int Sharpness;
- unsigned int static_thresh;
- unsigned int token_partitions;
- unsigned int arnr_max_frames; /* alt_ref Noise Reduction Max Frame Count */
- unsigned int arnr_strength; /* alt_ref Noise Reduction Strength */
- unsigned int arnr_type; /* alt_ref filter type */
- unsigned int experimental;
- vp8e_tuning tuning;
- unsigned int cq_level; /* constrained quality level */
- unsigned int rc_max_intra_bitrate_pct;
+struct vp8_extracfg {
+ struct vpx_codec_pkt_list *pkt_list;
+ vp8e_encoding_mode encoding_mode; /** best, good, realtime */
+ int cpu_used; /** available cpu percentage in 1/16*/
+ unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */
+ unsigned int noise_sensitivity;
+ unsigned int Sharpness;
+ unsigned int static_thresh;
+ unsigned int token_partitions;
+ unsigned int arnr_max_frames; /* alt_ref Noise Reduction Max Frame Count */
+ unsigned int arnr_strength; /* alt_ref Noise Reduction Strength */
+ unsigned int arnr_type; /* alt_ref filter type */
+ unsigned int experimental;
+ vp8e_tuning tuning;
+ unsigned int cq_level; /* constrained quality level */
+ unsigned int rc_max_intra_bitrate_pct;
};
-struct extraconfig_map
-{
- int usage;
- struct vp8_extracfg cfg;
+struct extraconfig_map {
+ int usage;
+ struct vp8_extracfg cfg;
};
-static const struct extraconfig_map extracfg_map[] =
-{
+static const struct extraconfig_map extracfg_map[] = {
+ {
+ 0,
{
- 0,
- {
- NULL,
- VP8_BEST_QUALITY_ENCODING, /* Encoding Mode */
- 0, /* cpu_used */
- 0, /* enable_auto_alt_ref */
- 0, /* noise_sensitivity */
- 0, /* Sharpness */
- 0, /* static_thresh */
- VP8_ONE_TOKENPARTITION, /* token_partitions */
- 0, /* arnr_max_frames */
- 3, /* arnr_strength */
- 3, /* arnr_type*/
- 0, /* experimental mode */
- 0, /* tuning*/
- 10, /* cq_level */
- 0, /* rc_max_intra_bitrate_pct */
- }
+ NULL,
+ VP8_BEST_QUALITY_ENCODING, /* Encoding Mode */
+ 0, /* cpu_used */
+ 0, /* enable_auto_alt_ref */
+ 0, /* noise_sensitivity */
+ 0, /* Sharpness */
+ 0, /* static_thresh */
+ VP8_ONE_TOKENPARTITION, /* token_partitions */
+ 0, /* arnr_max_frames */
+ 3, /* arnr_strength */
+ 3, /* arnr_type*/
+ 0, /* experimental mode */
+ 0, /* tuning*/
+ 10, /* cq_level */
+ 0, /* rc_max_intra_bitrate_pct */
}
+ }
};
-struct vpx_codec_alg_priv
-{
- vpx_codec_priv_t base;
- vpx_codec_enc_cfg_t cfg;
- struct vp8_extracfg vp8_cfg;
- VP8_CONFIG oxcf;
- VP8_PTR cpi;
- unsigned char *cx_data;
- unsigned int cx_data_sz;
- vpx_image_t preview_img;
- unsigned int next_frame_flag;
- vp8_postproc_cfg_t preview_ppcfg;
- vpx_codec_pkt_list_decl(64) pkt_list; // changed to accomendate the maximum number of lagged frames allowed
- int deprecated_mode;
- unsigned int fixed_kf_cntr;
+struct vpx_codec_alg_priv {
+ vpx_codec_priv_t base;
+ vpx_codec_enc_cfg_t cfg;
+ struct vp8_extracfg vp8_cfg;
+ VP8_CONFIG oxcf;
+ VP8_PTR cpi;
+ unsigned char *cx_data;
+ unsigned int cx_data_sz;
+ vpx_image_t preview_img;
+ unsigned int next_frame_flag;
+ vp8_postproc_cfg_t preview_ppcfg;
+ vpx_codec_pkt_list_decl(64) pkt_list; // changed to accomendate the maximum number of lagged frames allowed
+ int deprecated_mode;
+ unsigned int fixed_kf_cntr;
};
static vpx_codec_err_t
update_error_state(vpx_codec_alg_priv_t *ctx,
- const struct vpx_internal_error_info *error)
-{
- vpx_codec_err_t res;
+ const struct vpx_internal_error_info *error) {
+ vpx_codec_err_t res;
- if ((res = error->error_code))
- ctx->base.err_detail = error->has_detail
- ? error->detail
- : NULL;
+ if ((res = error->error_code))
+ ctx->base.err_detail = error->has_detail
+ ? error->detail
+ : NULL;
- return res;
+ return res;
}
#undef ERROR
#define ERROR(str) do {\
- ctx->base.err_detail = str;\
- return VPX_CODEC_INVALID_PARAM;\
- } while(0)
+ ctx->base.err_detail = str;\
+ return VPX_CODEC_INVALID_PARAM;\
+ } while(0)
#define RANGE_CHECK(p,memb,lo,hi) do {\
- if(!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \
- ERROR(#memb " out of range ["#lo".."#hi"]");\
- } while(0)
+ if(!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \
+ ERROR(#memb " out of range ["#lo".."#hi"]");\
+ } while(0)
#define RANGE_CHECK_HI(p,memb,hi) do {\
- if(!((p)->memb <= (hi))) \
- ERROR(#memb " out of range [.."#hi"]");\
- } while(0)
+ if(!((p)->memb <= (hi))) \
+ ERROR(#memb " out of range [.."#hi"]");\
+ } while(0)
#define RANGE_CHECK_LO(p,memb,lo) do {\
- if(!((p)->memb >= (lo))) \
- ERROR(#memb " out of range ["#lo"..]");\
- } while(0)
+ if(!((p)->memb >= (lo))) \
+ ERROR(#memb " out of range ["#lo"..]");\
+ } while(0)
#define RANGE_CHECK_BOOL(p,memb) do {\
- if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\
- } while(0)
+ if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\
+ } while(0)
static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
const vpx_codec_enc_cfg_t *cfg,
- const struct vp8_extracfg *vp8_cfg)
-{
- RANGE_CHECK(cfg, g_w, 1, 16383); /* 14 bits available */
- RANGE_CHECK(cfg, g_h, 1, 16383); /* 14 bits available */
- RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
- RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
- RANGE_CHECK_HI(cfg, g_profile, 3);
- RANGE_CHECK_HI(cfg, rc_max_quantizer, 63);
- RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer);
- RANGE_CHECK_HI(cfg, g_threads, 64);
- RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
- RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ);
- RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000);
- RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000);
- RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
- RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO);
- //RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile);
- RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
- RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
- RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
- RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
- RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
-
- /* VP8 does not support a lower bound on the keyframe interval in
- * automatic keyframe placement mode.
- */
- if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist
- && cfg->kf_min_dist > 0)
- ERROR("kf_min_dist not supported in auto mode, use 0 "
- "or kf_max_dist instead.");
-
- RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref);
- RANGE_CHECK(vp8_cfg, cpu_used, -16, 16);
-
- RANGE_CHECK(vp8_cfg, encoding_mode, VP8_BEST_QUALITY_ENCODING, VP8_REAL_TIME_ENCODING);
- RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6);
-
- RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOKENPARTITION);
- RANGE_CHECK_HI(vp8_cfg, Sharpness, 7);
- RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15);
- RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6);
- RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
- RANGE_CHECK(vp8_cfg, cq_level, 0, 63);
-
- if (cfg->g_pass == VPX_RC_LAST_PASS)
- {
- size_t packet_sz = sizeof(FIRSTPASS_STATS);
- int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz;
- FIRSTPASS_STATS *stats;
-
- if (!cfg->rc_twopass_stats_in.buf)
- ERROR("rc_twopass_stats_in.buf not set.");
-
- if (cfg->rc_twopass_stats_in.sz % packet_sz)
- ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
-
- if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz)
- ERROR("rc_twopass_stats_in requires at least two packets.");
-
- stats = (void*)((char *)cfg->rc_twopass_stats_in.buf
- + (n_packets - 1) * packet_sz);
-
- if ((int)(stats->count + 0.5) != n_packets - 1)
- ERROR("rc_twopass_stats_in missing EOS stats packet");
- }
-
- return VPX_CODEC_OK;
+ const struct vp8_extracfg *vp8_cfg) {
+ RANGE_CHECK(cfg, g_w, 1, 16383); /* 14 bits available */
+ RANGE_CHECK(cfg, g_h, 1, 16383); /* 14 bits available */
+ RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
+ RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
+ RANGE_CHECK_HI(cfg, g_profile, 3);
+ RANGE_CHECK_HI(cfg, rc_max_quantizer, 63);
+ RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer);
+ RANGE_CHECK_HI(cfg, g_threads, 64);
+ RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
+ RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ);
+ RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000);
+ RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000);
+ RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
+ RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO);
+ // RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile);
+ RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
+ RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
+ RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
+ RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
+ RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
+
+ /* VP8 does not support a lower bound on the keyframe interval in
+ * automatic keyframe placement mode.
+ */
+ if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist
+ && cfg->kf_min_dist > 0)
+ ERROR("kf_min_dist not supported in auto mode, use 0 "
+ "or kf_max_dist instead.");
+
+ RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref);
+ RANGE_CHECK(vp8_cfg, cpu_used, -16, 16);
+
+ RANGE_CHECK(vp8_cfg, encoding_mode, VP8_BEST_QUALITY_ENCODING, VP8_REAL_TIME_ENCODING);
+ RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6);
+
+ RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOKENPARTITION);
+ RANGE_CHECK_HI(vp8_cfg, Sharpness, 7);
+ RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15);
+ RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6);
+ RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
+ RANGE_CHECK(vp8_cfg, cq_level, 0, 63);
+
+ if (cfg->g_pass == VPX_RC_LAST_PASS) {
+ size_t packet_sz = sizeof(FIRSTPASS_STATS);
+ int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz;
+ FIRSTPASS_STATS *stats;
+
+ if (!cfg->rc_twopass_stats_in.buf)
+ ERROR("rc_twopass_stats_in.buf not set.");
+
+ if (cfg->rc_twopass_stats_in.sz % packet_sz)
+ ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
+
+ if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz)
+ ERROR("rc_twopass_stats_in requires at least two packets.");
+
+ stats = (void *)((char *)cfg->rc_twopass_stats_in.buf
+ + (n_packets - 1) * packet_sz);
+
+ if ((int)(stats->count + 0.5) != n_packets - 1)
+ ERROR("rc_twopass_stats_in missing EOS stats packet");
+ }
+
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx,
- const vpx_image_t *img)
-{
- switch (img->fmt)
- {
+ const vpx_image_t *img) {
+ switch (img->fmt) {
case VPX_IMG_FMT_YV12:
case VPX_IMG_FMT_I420:
case VPX_IMG_FMT_VPXI420:
case VPX_IMG_FMT_VPXYV12:
- break;
+ break;
default:
- ERROR("Invalid image format. Only YV12 and I420 images are supported");
- }
+ ERROR("Invalid image format. Only YV12 and I420 images are supported");
+ }
- if ((img->d_w != ctx->cfg.g_w) || (img->d_h != ctx->cfg.g_h))
- ERROR("Image size must match encoder init configuration size");
+ if ((img->d_w != ctx->cfg.g_w) || (img->d_h != ctx->cfg.g_h))
+ ERROR("Image size must match encoder init configuration size");
- return VPX_CODEC_OK;
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t set_vp8e_config(VP8_CONFIG *oxcf,
vpx_codec_enc_cfg_t cfg,
- struct vp8_extracfg vp8_cfg)
-{
- oxcf->Version = cfg.g_profile;
- oxcf->Version |= vp8_cfg.experimental? 0x4 : 0;
+ struct vp8_extracfg vp8_cfg) {
+ oxcf->Version = cfg.g_profile;
+ oxcf->Version |= vp8_cfg.experimental ? 0x4 : 0;
- oxcf->Width = cfg.g_w;
- oxcf->Height = cfg.g_h;
- /* guess a frame rate if out of whack, use 30 */
- oxcf->frame_rate = (double)(cfg.g_timebase.den) / (double)(cfg.g_timebase.num);
+ oxcf->Width = cfg.g_w;
+ oxcf->Height = cfg.g_h;
+ /* guess a frame rate if out of whack, use 30 */
+ oxcf->frame_rate = (double)(cfg.g_timebase.den) / (double)(cfg.g_timebase.num);
- if (oxcf->frame_rate > 180)
- {
- oxcf->frame_rate = 30;
- }
+ if (oxcf->frame_rate > 180) {
+ oxcf->frame_rate = 30;
+ }
- switch (cfg.g_pass)
- {
+ switch (cfg.g_pass) {
case VPX_RC_ONE_PASS:
- oxcf->Mode = MODE_BESTQUALITY;
- break;
+ oxcf->Mode = MODE_BESTQUALITY;
+ break;
case VPX_RC_FIRST_PASS:
- oxcf->Mode = MODE_FIRSTPASS;
- break;
+ oxcf->Mode = MODE_FIRSTPASS;
+ break;
case VPX_RC_LAST_PASS:
- oxcf->Mode = MODE_SECONDPASS_BEST;
- break;
- }
-
- if (cfg.g_pass == VPX_RC_FIRST_PASS)
- {
- oxcf->allow_lag = 0;
- oxcf->lag_in_frames = 0;
- }
- else
- {
- oxcf->allow_lag = (cfg.g_lag_in_frames) > 0;
- oxcf->lag_in_frames = cfg.g_lag_in_frames;
- }
-
- // VBR only supported for now.
- // CBR code has been deprectated for experimental phase.
- // CQ mode not yet tested
- oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;
- /*if (cfg.rc_end_usage == VPX_CQ)
- oxcf->end_usage = USAGE_CONSTRAINED_QUALITY;
- else
- oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;*/
-
- oxcf->target_bandwidth = cfg.rc_target_bitrate;
- oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct;
-
- oxcf->best_allowed_q = cfg.rc_min_quantizer;
- oxcf->worst_allowed_q = cfg.rc_max_quantizer;
- oxcf->cq_level = vp8_cfg.cq_level;
- oxcf->fixed_q = -1;
-
- oxcf->under_shoot_pct = cfg.rc_undershoot_pct;
- oxcf->over_shoot_pct = cfg.rc_overshoot_pct;
-
- oxcf->maximum_buffer_size = cfg.rc_buf_sz;
- oxcf->starting_buffer_level = cfg.rc_buf_initial_sz;
- oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz;
-
- oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct;
- oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct;
- oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct;
-
- oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO
- && cfg.kf_min_dist != cfg.kf_max_dist;
- //oxcf->kf_min_dist = cfg.kf_min_dis;
- oxcf->key_freq = cfg.kf_max_dist;
-
- //oxcf->delete_first_pass_file = cfg.g_delete_firstpassfile;
- //strcpy(oxcf->first_pass_file, cfg.g_firstpass_file);
-
- oxcf->cpu_used = vp8_cfg.cpu_used;
- oxcf->encode_breakout = vp8_cfg.static_thresh;
- oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref;
- oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity;
- oxcf->Sharpness = vp8_cfg.Sharpness;
-
- oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in;
- oxcf->output_pkt_list = vp8_cfg.pkt_list;
-
- oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames;
- oxcf->arnr_strength = vp8_cfg.arnr_strength;
- oxcf->arnr_type = vp8_cfg.arnr_type;
-
- oxcf->tuning = vp8_cfg.tuning;
+ oxcf->Mode = MODE_SECONDPASS_BEST;
+ break;
+ }
+
+ if (cfg.g_pass == VPX_RC_FIRST_PASS) {
+ oxcf->allow_lag = 0;
+ oxcf->lag_in_frames = 0;
+ } else {
+ oxcf->allow_lag = (cfg.g_lag_in_frames) > 0;
+ oxcf->lag_in_frames = cfg.g_lag_in_frames;
+ }
+
+ // VBR only supported for now.
+ // CBR code has been deprectated for experimental phase.
+ // CQ mode not yet tested
+ oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;
+ /*if (cfg.rc_end_usage == VPX_CQ)
+ oxcf->end_usage = USAGE_CONSTRAINED_QUALITY;
+ else
+ oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;*/
+
+ oxcf->target_bandwidth = cfg.rc_target_bitrate;
+ oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct;
+
+ oxcf->best_allowed_q = cfg.rc_min_quantizer;
+ oxcf->worst_allowed_q = cfg.rc_max_quantizer;
+ oxcf->cq_level = vp8_cfg.cq_level;
+ oxcf->fixed_q = -1;
+
+ oxcf->under_shoot_pct = cfg.rc_undershoot_pct;
+ oxcf->over_shoot_pct = cfg.rc_overshoot_pct;
+
+ oxcf->maximum_buffer_size = cfg.rc_buf_sz;
+ oxcf->starting_buffer_level = cfg.rc_buf_initial_sz;
+ oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz;
+
+ oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct;
+ oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct;
+ oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct;
+
+ oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO
+ && cfg.kf_min_dist != cfg.kf_max_dist;
+ // oxcf->kf_min_dist = cfg.kf_min_dis;
+ oxcf->key_freq = cfg.kf_max_dist;
+
+ // oxcf->delete_first_pass_file = cfg.g_delete_firstpassfile;
+ // strcpy(oxcf->first_pass_file, cfg.g_firstpass_file);
+
+ oxcf->cpu_used = vp8_cfg.cpu_used;
+ oxcf->encode_breakout = vp8_cfg.static_thresh;
+ oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref;
+ oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity;
+ oxcf->Sharpness = vp8_cfg.Sharpness;
+
+ oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in;
+ oxcf->output_pkt_list = vp8_cfg.pkt_list;
+
+ oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames;
+ oxcf->arnr_strength = vp8_cfg.arnr_strength;
+ oxcf->arnr_type = vp8_cfg.arnr_type;
+
+ oxcf->tuning = vp8_cfg.tuning;
#if CONFIG_LOSSLESS
- oxcf->lossless = cfg.lossless;
+ oxcf->lossless = cfg.lossless;
#endif
- /*
- printf("Current VP8 Settings: \n");
- printf("target_bandwidth: %d\n", oxcf->target_bandwidth);
- printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity);
- printf("Sharpness: %d\n", oxcf->Sharpness);
- printf("cpu_used: %d\n", oxcf->cpu_used);
- printf("Mode: %d\n", oxcf->Mode);
- printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file);
- printf("auto_key: %d\n", oxcf->auto_key);
- printf("key_freq: %d\n", oxcf->key_freq);
- printf("end_usage: %d\n", oxcf->end_usage);
- printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct);
- printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct);
- printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level);
- printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level);
- printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size);
- printf("fixed_q: %d\n", oxcf->fixed_q);
- printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
- printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
- printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias);
- printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
- printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);
- printf("allow_lag: %d\n", oxcf->allow_lag);
- printf("lag_in_frames: %d\n", oxcf->lag_in_frames);
- printf("play_alternate: %d\n", oxcf->play_alternate);
- printf("Version: %d\n", oxcf->Version);
- printf("encode_breakout: %d\n", oxcf->encode_breakout);
- */
- return VPX_CODEC_OK;
+ /*
+ printf("Current VP8 Settings: \n");
+ printf("target_bandwidth: %d\n", oxcf->target_bandwidth);
+ printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity);
+ printf("Sharpness: %d\n", oxcf->Sharpness);
+ printf("cpu_used: %d\n", oxcf->cpu_used);
+ printf("Mode: %d\n", oxcf->Mode);
+ printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file);
+ printf("auto_key: %d\n", oxcf->auto_key);
+ printf("key_freq: %d\n", oxcf->key_freq);
+ printf("end_usage: %d\n", oxcf->end_usage);
+ printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct);
+ printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct);
+ printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level);
+ printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level);
+ printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size);
+ printf("fixed_q: %d\n", oxcf->fixed_q);
+ printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
+ printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
+ printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias);
+ printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
+ printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);
+ printf("allow_lag: %d\n", oxcf->allow_lag);
+ printf("lag_in_frames: %d\n", oxcf->lag_in_frames);
+ printf("play_alternate: %d\n", oxcf->play_alternate);
+ printf("Version: %d\n", oxcf->Version);
+ printf("encode_breakout: %d\n", oxcf->encode_breakout);
+ */
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t vp8e_set_config(vpx_codec_alg_priv_t *ctx,
- const vpx_codec_enc_cfg_t *cfg)
-{
- vpx_codec_err_t res;
+ const vpx_codec_enc_cfg_t *cfg) {
+ vpx_codec_err_t res;
- if ((cfg->g_w != ctx->cfg.g_w) || (cfg->g_h != ctx->cfg.g_h))
- ERROR("Cannot change width or height after initialization");
+ if ((cfg->g_w != ctx->cfg.g_w) || (cfg->g_h != ctx->cfg.g_h))
+ ERROR("Cannot change width or height after initialization");
- /* Prevent increasing lag_in_frames. This check is stricter than it needs
- * to be -- the limit is not increasing past the first lag_in_frames
- * value, but we don't track the initial config, only the last successful
- * config.
- */
- if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames))
- ERROR("Cannot increase lag_in_frames");
+ /* Prevent increasing lag_in_frames. This check is stricter than it needs
+ * to be -- the limit is not increasing past the first lag_in_frames
+ * value, but we don't track the initial config, only the last successful
+ * config.
+ */
+ if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames))
+ ERROR("Cannot increase lag_in_frames");
- res = validate_config(ctx, cfg, &ctx->vp8_cfg);
+ res = validate_config(ctx, cfg, &ctx->vp8_cfg);
- if (!res)
- {
- ctx->cfg = *cfg;
- set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
- vp8_change_config(ctx->cpi, &ctx->oxcf);
- }
+ if (!res) {
+ ctx->cfg = *cfg;
+ set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
+ vp8_change_config(ctx->cpi, &ctx->oxcf);
+ }
- return res;
+ return res;
}
@@ -386,219 +369,202 @@ int vp8_reverse_trans(int);
static vpx_codec_err_t get_param(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
- va_list args)
-{
- void *arg = va_arg(args, void *);
+ va_list args) {
+ void *arg = va_arg(args, void *);
#define MAP(id, var) case id: *(RECAST(id, arg)) = var; break
- if (!arg)
- return VPX_CODEC_INVALID_PARAM;
+ if (!arg)
+ return VPX_CODEC_INVALID_PARAM;
- switch (ctrl_id)
- {
- MAP(VP8E_GET_LAST_QUANTIZER, vp8_get_quantizer(ctx->cpi));
- MAP(VP8E_GET_LAST_QUANTIZER_64, vp8_reverse_trans(vp8_get_quantizer(ctx->cpi)));
- }
+ switch (ctrl_id) {
+ MAP(VP8E_GET_LAST_QUANTIZER, vp8_get_quantizer(ctx->cpi));
+ MAP(VP8E_GET_LAST_QUANTIZER_64, vp8_reverse_trans(vp8_get_quantizer(ctx->cpi)));
+ }
- return VPX_CODEC_OK;
+ return VPX_CODEC_OK;
#undef MAP
}
static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
- va_list args)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
- struct vp8_extracfg xcfg = ctx->vp8_cfg;
+ va_list args) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+ struct vp8_extracfg xcfg = ctx->vp8_cfg;
#define MAP(id, var) case id: var = CAST(id, args); break;
- switch (ctrl_id)
- {
- MAP(VP8E_SET_ENCODING_MODE, ctx->deprecated_mode);
- MAP(VP8E_SET_CPUUSED, xcfg.cpu_used);
- MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref);
- MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity);
- MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness);
- MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh);
- MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions);
-
- MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames);
- MAP(VP8E_SET_ARNR_STRENGTH , xcfg.arnr_strength);
- MAP(VP8E_SET_ARNR_TYPE , xcfg.arnr_type);
- MAP(VP8E_SET_TUNING, xcfg.tuning);
- MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
- MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
-
- }
-
- res = validate_config(ctx, &ctx->cfg, &xcfg);
-
- if (!res)
- {
- ctx->vp8_cfg = xcfg;
- set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
- vp8_change_config(ctx->cpi, &ctx->oxcf);
- }
-
- return res;
+ switch (ctrl_id) {
+ MAP(VP8E_SET_ENCODING_MODE, ctx->deprecated_mode);
+ MAP(VP8E_SET_CPUUSED, xcfg.cpu_used);
+ MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref);
+ MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity);
+ MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness);
+ MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh);
+ MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions);
+
+ MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames);
+ MAP(VP8E_SET_ARNR_STRENGTH, xcfg.arnr_strength);
+ MAP(VP8E_SET_ARNR_TYPE, xcfg.arnr_type);
+ MAP(VP8E_SET_TUNING, xcfg.tuning);
+ MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
+ MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
+
+ }
+
+ res = validate_config(ctx, &ctx->cfg, &xcfg);
+
+ if (!res) {
+ ctx->vp8_cfg = xcfg;
+ set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
+ vp8_change_config(ctx->cpi, &ctx->oxcf);
+ }
+
+ return res;
#undef MAP
}
static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx,
- int experimental)
-{
- vpx_codec_err_t res = VPX_DEC_OK;
- struct vpx_codec_alg_priv *priv;
- vpx_codec_enc_cfg_t *cfg;
- unsigned int i;
+ int experimental) {
+ vpx_codec_err_t res = VPX_DEC_OK;
+ struct vpx_codec_alg_priv *priv;
+ vpx_codec_enc_cfg_t *cfg;
+ unsigned int i;
- VP8_PTR optr;
+ VP8_PTR optr;
- if (!ctx->priv)
- {
- priv = calloc(1, sizeof(struct vpx_codec_alg_priv));
+ if (!ctx->priv) {
+ priv = calloc(1, sizeof(struct vpx_codec_alg_priv));
- if (!priv)
- {
- return VPX_CODEC_MEM_ERROR;
- }
+ if (!priv) {
+ return VPX_CODEC_MEM_ERROR;
+ }
- ctx->priv = &priv->base;
- ctx->priv->sz = sizeof(*ctx->priv);
- ctx->priv->iface = ctx->iface;
- ctx->priv->alg_priv = priv;
- ctx->priv->init_flags = ctx->init_flags;
+ ctx->priv = &priv->base;
+ ctx->priv->sz = sizeof(*ctx->priv);
+ ctx->priv->iface = ctx->iface;
+ ctx->priv->alg_priv = priv;
+ ctx->priv->init_flags = ctx->init_flags;
+
+ if (ctx->config.enc) {
+ /* Update the reference to the config structure to an
+ * internal copy.
+ */
+ ctx->priv->alg_priv->cfg = *ctx->config.enc;
+ ctx->config.enc = &ctx->priv->alg_priv->cfg;
+ }
- if (ctx->config.enc)
- {
- /* Update the reference to the config structure to an
- * internal copy.
- */
- ctx->priv->alg_priv->cfg = *ctx->config.enc;
- ctx->config.enc = &ctx->priv->alg_priv->cfg;
- }
+ cfg = &ctx->priv->alg_priv->cfg;
- cfg = &ctx->priv->alg_priv->cfg;
+ /* Select the extra vp6 configuration table based on the current
+ * usage value. If the current usage value isn't found, use the
+ * values for usage case 0.
+ */
+ for (i = 0;
+ extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage;
+ i++);
- /* Select the extra vp6 configuration table based on the current
- * usage value. If the current usage value isn't found, use the
- * values for usage case 0.
- */
- for (i = 0;
- extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage;
- i++);
+ priv->vp8_cfg = extracfg_map[i].cfg;
+ priv->vp8_cfg.pkt_list = &priv->pkt_list.head;
+ priv->vp8_cfg.experimental = experimental;
- priv->vp8_cfg = extracfg_map[i].cfg;
- priv->vp8_cfg.pkt_list = &priv->pkt_list.head;
- priv->vp8_cfg.experimental = experimental;
+ priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2;
- priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2;
+ if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096;
- if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096;
+ priv->cx_data = malloc(priv->cx_data_sz);
- priv->cx_data = malloc(priv->cx_data_sz);
+ if (!priv->cx_data) {
+ return VPX_CODEC_MEM_ERROR;
+ }
- if (!priv->cx_data)
- {
- return VPX_CODEC_MEM_ERROR;
- }
+ priv->deprecated_mode = NO_MODE_SET;
- priv->deprecated_mode = NO_MODE_SET;
+ vp8_initialize();
- vp8_initialize();
+ res = validate_config(priv, &priv->cfg, &priv->vp8_cfg);
- res = validate_config(priv, &priv->cfg, &priv->vp8_cfg);
+ if (!res) {
+ set_vp8e_config(&ctx->priv->alg_priv->oxcf,
+ ctx->priv->alg_priv->cfg,
+ ctx->priv->alg_priv->vp8_cfg);
+ optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf);
- if (!res)
- {
- set_vp8e_config(&ctx->priv->alg_priv->oxcf,
- ctx->priv->alg_priv->cfg,
- ctx->priv->alg_priv->vp8_cfg);
- optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf);
-
- if (!optr)
- res = VPX_CODEC_MEM_ERROR;
- else
- ctx->priv->alg_priv->cpi = optr;
- }
+ if (!optr)
+ res = VPX_CODEC_MEM_ERROR;
+ else
+ ctx->priv->alg_priv->cpi = optr;
}
+ }
- return res;
+ return res;
}
-static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx)
-{
- return vp8e_common_init(ctx, 0);
+static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx) {
+ return vp8e_common_init(ctx, 0);
}
#if CONFIG_EXPERIMENTAL
-static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx)
-{
- return vp8e_common_init(ctx, 1);
+static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx) {
+ return vp8e_common_init(ctx, 1);
}
#endif
-static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx)
-{
+static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) {
- free(ctx->cx_data);
- vp8_remove_compressor(&ctx->cpi);
- free(ctx);
- return VPX_CODEC_OK;
+ free(ctx->cx_data);
+ vp8_remove_compressor(&ctx->cpi);
+ free(ctx);
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
- YV12_BUFFER_CONFIG *yv12)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
- yv12->y_buffer = img->planes[VPX_PLANE_Y];
- yv12->u_buffer = img->planes[VPX_PLANE_U];
- yv12->v_buffer = img->planes[VPX_PLANE_V];
-
- yv12->y_width = img->d_w;
- yv12->y_height = img->d_h;
- yv12->uv_width = (1 + yv12->y_width) / 2;
- yv12->uv_height = (1 + yv12->y_height) / 2;
-
- yv12->y_stride = img->stride[VPX_PLANE_Y];
- yv12->uv_stride = img->stride[VPX_PLANE_U];
-
- yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
- yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12); //REG_YUV = 0
- return res;
+ YV12_BUFFER_CONFIG *yv12) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+ yv12->y_buffer = img->planes[VPX_PLANE_Y];
+ yv12->u_buffer = img->planes[VPX_PLANE_U];
+ yv12->v_buffer = img->planes[VPX_PLANE_V];
+
+ yv12->y_width = img->d_w;
+ yv12->y_height = img->d_h;
+ yv12->uv_width = (1 + yv12->y_width) / 2;
+ yv12->uv_height = (1 + yv12->y_height) / 2;
+
+ yv12->y_stride = img->stride[VPX_PLANE_Y];
+ yv12->uv_stride = img->stride[VPX_PLANE_U];
+
+ yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
+ yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12); // REG_YUV = 0
+ return res;
}
static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
unsigned long duration,
- unsigned long deadline)
-{
- unsigned int new_qc;
-
- /* Use best quality mode if no deadline is given. */
- if (deadline)
- new_qc = MODE_GOODQUALITY;
- else
- new_qc = MODE_BESTQUALITY;
-
- if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS)
- new_qc = MODE_FIRSTPASS;
- else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS)
- new_qc = (new_qc == MODE_BESTQUALITY)
- ? MODE_SECONDPASS_BEST
- : MODE_SECONDPASS;
-
- if (ctx->oxcf.Mode != new_qc)
- {
- ctx->oxcf.Mode = new_qc;
- vp8_change_config(ctx->cpi, &ctx->oxcf);
- }
+ unsigned long deadline) {
+ unsigned int new_qc;
+
+ /* Use best quality mode if no deadline is given. */
+ if (deadline)
+ new_qc = MODE_GOODQUALITY;
+ else
+ new_qc = MODE_BESTQUALITY;
+
+ if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS)
+ new_qc = MODE_FIRSTPASS;
+ else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS)
+ new_qc = (new_qc == MODE_BESTQUALITY)
+ ? MODE_SECONDPASS_BEST
+ : MODE_SECONDPASS;
+
+ if (ctx->oxcf.Mode != new_qc) {
+ ctx->oxcf.Mode = new_qc;
+ vp8_change_config(ctx->cpi, &ctx->oxcf);
+ }
}
@@ -607,559 +573,515 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
vpx_codec_pts_t pts,
unsigned long duration,
vpx_enc_frame_flags_t flags,
- unsigned long deadline)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
+ unsigned long deadline) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
- if (img)
- res = validate_img(ctx, img);
+ if (img)
+ res = validate_img(ctx, img);
- pick_quickcompress_mode(ctx, duration, deadline);
- vpx_codec_pkt_list_init(&ctx->pkt_list);
+ pick_quickcompress_mode(ctx, duration, deadline);
+ vpx_codec_pkt_list_init(&ctx->pkt_list);
- /* Handle Flags */
- if (((flags & VP8_EFLAG_NO_UPD_GF) && (flags & VP8_EFLAG_FORCE_GF))
- || ((flags & VP8_EFLAG_NO_UPD_ARF) && (flags & VP8_EFLAG_FORCE_ARF)))
- {
- ctx->base.err_detail = "Conflicting flags.";
- return VPX_CODEC_INVALID_PARAM;
- }
+ /* Handle Flags */
+ if (((flags & VP8_EFLAG_NO_UPD_GF) && (flags & VP8_EFLAG_FORCE_GF))
+ || ((flags & VP8_EFLAG_NO_UPD_ARF) && (flags & VP8_EFLAG_FORCE_ARF))) {
+ ctx->base.err_detail = "Conflicting flags.";
+ return VPX_CODEC_INVALID_PARAM;
+ }
- if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF
- | VP8_EFLAG_NO_REF_ARF))
- {
- int ref = 7;
+ if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF
+ | VP8_EFLAG_NO_REF_ARF)) {
+ int ref = 7;
- if (flags & VP8_EFLAG_NO_REF_LAST)
- ref ^= VP8_LAST_FLAG;
+ if (flags & VP8_EFLAG_NO_REF_LAST)
+ ref ^= VP8_LAST_FLAG;
- if (flags & VP8_EFLAG_NO_REF_GF)
- ref ^= VP8_GOLD_FLAG;
+ if (flags & VP8_EFLAG_NO_REF_GF)
+ ref ^= VP8_GOLD_FLAG;
- if (flags & VP8_EFLAG_NO_REF_ARF)
- ref ^= VP8_ALT_FLAG;
+ if (flags & VP8_EFLAG_NO_REF_ARF)
+ ref ^= VP8_ALT_FLAG;
- vp8_use_as_reference(ctx->cpi, ref);
- }
+ vp8_use_as_reference(ctx->cpi, ref);
+ }
- if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF
- | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF
- | VP8_EFLAG_FORCE_ARF))
- {
- int upd = 7;
+ if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF
+ | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF
+ | VP8_EFLAG_FORCE_ARF)) {
+ int upd = 7;
- if (flags & VP8_EFLAG_NO_UPD_LAST)
- upd ^= VP8_LAST_FLAG;
+ if (flags & VP8_EFLAG_NO_UPD_LAST)
+ upd ^= VP8_LAST_FLAG;
- if (flags & VP8_EFLAG_NO_UPD_GF)
- upd ^= VP8_GOLD_FLAG;
+ if (flags & VP8_EFLAG_NO_UPD_GF)
+ upd ^= VP8_GOLD_FLAG;
- if (flags & VP8_EFLAG_NO_UPD_ARF)
- upd ^= VP8_ALT_FLAG;
+ if (flags & VP8_EFLAG_NO_UPD_ARF)
+ upd ^= VP8_ALT_FLAG;
- vp8_update_reference(ctx->cpi, upd);
- }
+ vp8_update_reference(ctx->cpi, upd);
+ }
- if (flags & VP8_EFLAG_NO_UPD_ENTROPY)
- {
- vp8_update_entropy(ctx->cpi, 0);
- }
+ if (flags & VP8_EFLAG_NO_UPD_ENTROPY) {
+ vp8_update_entropy(ctx->cpi, 0);
+ }
- /* Handle fixed keyframe intervals */
- if (ctx->cfg.kf_mode == VPX_KF_AUTO
- && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist)
- {
- if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist)
- {
- flags |= VPX_EFLAG_FORCE_KF;
- ctx->fixed_kf_cntr = 1;
- }
+ /* Handle fixed keyframe intervals */
+ if (ctx->cfg.kf_mode == VPX_KF_AUTO
+ && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) {
+ if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) {
+ flags |= VPX_EFLAG_FORCE_KF;
+ ctx->fixed_kf_cntr = 1;
}
+ }
- /* Initialize the encoder instance on the first frame*/
- if (!res && ctx->cpi)
- {
- unsigned int lib_flags;
- YV12_BUFFER_CONFIG sd;
- int64_t dst_time_stamp, dst_end_time_stamp;
- unsigned long size, cx_data_sz;
- unsigned char *cx_data;
+ /* Initialize the encoder instance on the first frame*/
+ if (!res && ctx->cpi) {
+ unsigned int lib_flags;
+ YV12_BUFFER_CONFIG sd;
+ int64_t dst_time_stamp, dst_end_time_stamp;
+ unsigned long size, cx_data_sz;
+ unsigned char *cx_data;
- /* Set up internal flags */
- if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
- ((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1;
+ /* Set up internal flags */
+ if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
+ ((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1;
- //if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION)
- // ((VP8_COMP *)ctx->cpi)->output_partition = 1;
+ // if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION)
+ // ((VP8_COMP *)ctx->cpi)->output_partition = 1;
- /* Convert API flags to internal codec lib flags */
- lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
+ /* Convert API flags to internal codec lib flags */
+ lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
- /* vp8 use 10,000,000 ticks/second as time stamp */
- dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
- dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
+ /* vp8 use 10,000,000 ticks/second as time stamp */
+ dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
+ dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
- if (img != NULL)
- {
- res = image2yuvconfig(img, &sd);
+ if (img != NULL) {
+ res = image2yuvconfig(img, &sd);
- if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
- &sd, dst_time_stamp, dst_end_time_stamp))
- {
- VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
- res = update_error_state(ctx, &cpi->common.error);
- }
+ if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
+ &sd, dst_time_stamp, dst_end_time_stamp)) {
+ VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
+ res = update_error_state(ctx, &cpi->common.error);
+ }
+
+ /* reset for next frame */
+ ctx->next_frame_flag = 0;
+ }
- /* reset for next frame */
- ctx->next_frame_flag = 0;
+ cx_data = ctx->cx_data;
+ cx_data_sz = ctx->cx_data_sz;
+ lib_flags = 0;
+
+ while (cx_data_sz >= ctx->cx_data_sz / 2
+ && -1 != vp8_get_compressed_data(ctx->cpi, &lib_flags, &size, cx_data, &dst_time_stamp, &dst_end_time_stamp, !img)) {
+ if (size) {
+ vpx_codec_pts_t round, delta;
+ vpx_codec_cx_pkt_t pkt;
+ VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
+
+ /* Add the frame packet to the list of returned packets. */
+ round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1;
+ delta = (dst_end_time_stamp - dst_time_stamp);
+ pkt.kind = VPX_CODEC_CX_FRAME_PKT;
+ pkt.data.frame.pts =
+ (dst_time_stamp * ctx->cfg.g_timebase.den + round)
+ / ctx->cfg.g_timebase.num / 10000000;
+ pkt.data.frame.duration =
+ (delta * ctx->cfg.g_timebase.den + round)
+ / ctx->cfg.g_timebase.num / 10000000;
+ pkt.data.frame.flags = lib_flags << 16;
+
+ if (lib_flags & FRAMEFLAGS_KEY)
+ pkt.data.frame.flags |= VPX_FRAME_IS_KEY;
+
+ if (!cpi->common.show_frame) {
+ pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
+
+ // This timestamp should be as close as possible to the
+ // prior PTS so that if a decoder uses pts to schedule when
+ // to do this, we start right after last frame was decoded.
+ // Invisible frames have no duration.
+ pkt.data.frame.pts = ((cpi->last_time_stamp_seen
+ * ctx->cfg.g_timebase.den + round)
+ / ctx->cfg.g_timebase.num / 10000000) + 1;
+ pkt.data.frame.duration = 0;
}
- cx_data = ctx->cx_data;
- cx_data_sz = ctx->cx_data_sz;
- lib_flags = 0;
+ if (cpi->droppable)
+ pkt.data.frame.flags |= VPX_FRAME_IS_DROPPABLE;
- while (cx_data_sz >= ctx->cx_data_sz / 2
- && -1 != vp8_get_compressed_data(ctx->cpi, &lib_flags, &size, cx_data, &dst_time_stamp, &dst_end_time_stamp, !img))
+ /*if (cpi->output_partition)
{
- if (size)
+ int i;
+ const int num_partitions = 1;
+
+ pkt.data.frame.flags |= VPX_FRAME_IS_FRAGMENT;
+
+ for (i = 0; i < num_partitions; ++i)
{
- vpx_codec_pts_t round, delta;
- vpx_codec_cx_pkt_t pkt;
- VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
-
- /* Add the frame packet to the list of returned packets. */
- round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1;
- delta = (dst_end_time_stamp - dst_time_stamp);
- pkt.kind = VPX_CODEC_CX_FRAME_PKT;
- pkt.data.frame.pts =
- (dst_time_stamp * ctx->cfg.g_timebase.den + round)
- / ctx->cfg.g_timebase.num / 10000000;
- pkt.data.frame.duration =
- (delta * ctx->cfg.g_timebase.den + round)
- / ctx->cfg.g_timebase.num / 10000000;
- pkt.data.frame.flags = lib_flags << 16;
-
- if (lib_flags & FRAMEFLAGS_KEY)
- pkt.data.frame.flags |= VPX_FRAME_IS_KEY;
-
- if (!cpi->common.show_frame)
- {
- pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
-
- // This timestamp should be as close as possible to the
- // prior PTS so that if a decoder uses pts to schedule when
- // to do this, we start right after last frame was decoded.
- // Invisible frames have no duration.
- pkt.data.frame.pts = ((cpi->last_time_stamp_seen
- * ctx->cfg.g_timebase.den + round)
- / ctx->cfg.g_timebase.num / 10000000) + 1;
- pkt.data.frame.duration = 0;
- }
-
- if (cpi->droppable)
- pkt.data.frame.flags |= VPX_FRAME_IS_DROPPABLE;
-
- /*if (cpi->output_partition)
- {
- int i;
- const int num_partitions = 1;
-
- pkt.data.frame.flags |= VPX_FRAME_IS_FRAGMENT;
-
- for (i = 0; i < num_partitions; ++i)
- {
- pkt.data.frame.buf = cx_data;
- pkt.data.frame.sz = cpi->partition_sz[i];
- pkt.data.frame.partition_id = i;
- // don't set the fragment bit for the last partition
- if (i == (num_partitions - 1))
- pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT;
- vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
- cx_data += cpi->partition_sz[i];
- cx_data_sz -= cpi->partition_sz[i];
- }
- }
- else*/
- {
- pkt.data.frame.buf = cx_data;
- pkt.data.frame.sz = size;
- pkt.data.frame.partition_id = -1;
- vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
- cx_data += size;
- cx_data_sz -= size;
- }
-
- //printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->data.frame.duration);
+ pkt.data.frame.buf = cx_data;
+ pkt.data.frame.sz = cpi->partition_sz[i];
+ pkt.data.frame.partition_id = i;
+ // don't set the fragment bit for the last partition
+ if (i == (num_partitions - 1))
+ pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT;
+ vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
+ cx_data += cpi->partition_sz[i];
+ cx_data_sz -= cpi->partition_sz[i];
}
}
+ else*/
+ {
+ pkt.data.frame.buf = cx_data;
+ pkt.data.frame.sz = size;
+ pkt.data.frame.partition_id = -1;
+ vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
+ cx_data += size;
+ cx_data_sz -= size;
+ }
+
+ // printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->data.frame.duration);
+ }
}
+ }
- return res;
+ return res;
}
static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx,
- vpx_codec_iter_t *iter)
-{
- return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter);
+ vpx_codec_iter_t *iter) {
+ return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter);
}
static vpx_codec_err_t vp8e_set_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
- vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
+ int ctr_id,
+ va_list args) {
+ vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
- if (data)
- {
- vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
- YV12_BUFFER_CONFIG sd;
+ if (data) {
+ vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
+ YV12_BUFFER_CONFIG sd;
- image2yuvconfig(&frame->img, &sd);
- vp8_set_reference(ctx->cpi, frame->frame_type, &sd);
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ image2yuvconfig(&frame->img, &sd);
+ vp8_set_reference(ctx->cpi, frame->frame_type, &sd);
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8e_get_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
+ int ctr_id,
+ va_list args) {
- vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
+ vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
- if (data)
- {
- vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
- YV12_BUFFER_CONFIG sd;
+ if (data) {
+ vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
+ YV12_BUFFER_CONFIG sd;
- image2yuvconfig(&frame->img, &sd);
- vp8_get_reference(ctx->cpi, frame->frame_type, &sd);
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ image2yuvconfig(&frame->img, &sd);
+ vp8_get_reference(ctx->cpi, frame->frame_type, &sd);
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
+ int ctr_id,
+ va_list args) {
#if CONFIG_POSTPROC
- vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
- (void)ctr_id;
+ vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
+ (void)ctr_id;
- if (data)
- {
- ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data);
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ if (data) {
+ ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data);
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
#else
- (void)ctx;
- (void)ctr_id;
- (void)args;
- return VPX_CODEC_INCAPABLE;
+ (void)ctx;
+ (void)ctr_id;
+ (void)args;
+ return VPX_CODEC_INCAPABLE;
#endif
}
-static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
-{
+static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) {
- YV12_BUFFER_CONFIG sd;
- vp8_ppflags_t flags = {0};
+ YV12_BUFFER_CONFIG sd;
+ vp8_ppflags_t flags = {0};
- if (ctx->preview_ppcfg.post_proc_flag)
- {
- flags.post_proc_flag = ctx->preview_ppcfg.post_proc_flag;
- flags.deblocking_level = ctx->preview_ppcfg.deblocking_level;
- flags.noise_level = ctx->preview_ppcfg.noise_level;
- }
+ if (ctx->preview_ppcfg.post_proc_flag) {
+ flags.post_proc_flag = ctx->preview_ppcfg.post_proc_flag;
+ flags.deblocking_level = ctx->preview_ppcfg.deblocking_level;
+ flags.noise_level = ctx->preview_ppcfg.noise_level;
+ }
- if (0 == vp8_get_preview_raw_frame(ctx->cpi, &sd, &flags))
- {
+ if (0 == vp8_get_preview_raw_frame(ctx->cpi, &sd, &flags)) {
- /*
- vpx_img_wrap(&ctx->preview_img, VPX_IMG_FMT_YV12,
- sd.y_width + 2*VP8BORDERINPIXELS,
- sd.y_height + 2*VP8BORDERINPIXELS,
- 1,
- sd.buffer_alloc);
- vpx_img_set_rect(&ctx->preview_img,
- VP8BORDERINPIXELS, VP8BORDERINPIXELS,
- sd.y_width, sd.y_height);
- */
-
- ctx->preview_img.bps = 12;
- ctx->preview_img.planes[VPX_PLANE_Y] = sd.y_buffer;
- ctx->preview_img.planes[VPX_PLANE_U] = sd.u_buffer;
- ctx->preview_img.planes[VPX_PLANE_V] = sd.v_buffer;
-
- if (sd.clrtype == REG_YUV)
- ctx->preview_img.fmt = VPX_IMG_FMT_I420;
- else
- ctx->preview_img.fmt = VPX_IMG_FMT_VPXI420;
-
- ctx->preview_img.x_chroma_shift = 1;
- ctx->preview_img.y_chroma_shift = 1;
-
- ctx->preview_img.d_w = sd.y_width;
- ctx->preview_img.d_h = sd.y_height;
- ctx->preview_img.stride[VPX_PLANE_Y] = sd.y_stride;
- ctx->preview_img.stride[VPX_PLANE_U] = sd.uv_stride;
- ctx->preview_img.stride[VPX_PLANE_V] = sd.uv_stride;
- ctx->preview_img.w = sd.y_width;
- ctx->preview_img.h = sd.y_height;
-
- return &ctx->preview_img;
- }
+ /*
+ vpx_img_wrap(&ctx->preview_img, VPX_IMG_FMT_YV12,
+ sd.y_width + 2*VP8BORDERINPIXELS,
+ sd.y_height + 2*VP8BORDERINPIXELS,
+ 1,
+ sd.buffer_alloc);
+ vpx_img_set_rect(&ctx->preview_img,
+ VP8BORDERINPIXELS, VP8BORDERINPIXELS,
+ sd.y_width, sd.y_height);
+ */
+
+ ctx->preview_img.bps = 12;
+ ctx->preview_img.planes[VPX_PLANE_Y] = sd.y_buffer;
+ ctx->preview_img.planes[VPX_PLANE_U] = sd.u_buffer;
+ ctx->preview_img.planes[VPX_PLANE_V] = sd.v_buffer;
+
+ if (sd.clrtype == REG_YUV)
+ ctx->preview_img.fmt = VPX_IMG_FMT_I420;
else
- return NULL;
+ ctx->preview_img.fmt = VPX_IMG_FMT_VPXI420;
+
+ ctx->preview_img.x_chroma_shift = 1;
+ ctx->preview_img.y_chroma_shift = 1;
+
+ ctx->preview_img.d_w = sd.y_width;
+ ctx->preview_img.d_h = sd.y_height;
+ ctx->preview_img.stride[VPX_PLANE_Y] = sd.y_stride;
+ ctx->preview_img.stride[VPX_PLANE_U] = sd.uv_stride;
+ ctx->preview_img.stride[VPX_PLANE_V] = sd.uv_stride;
+ ctx->preview_img.w = sd.y_width;
+ ctx->preview_img.h = sd.y_height;
+
+ return &ctx->preview_img;
+ } else
+ return NULL;
}
static vpx_codec_err_t vp8e_update_entropy(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
- int update = va_arg(args, int);
- vp8_update_entropy(ctx->cpi, update);
- return VPX_CODEC_OK;
+ int ctr_id,
+ va_list args) {
+ int update = va_arg(args, int);
+ vp8_update_entropy(ctx->cpi, update);
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t vp8e_update_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
- int update = va_arg(args, int);
- vp8_update_reference(ctx->cpi, update);
- return VPX_CODEC_OK;
+ int ctr_id,
+ va_list args) {
+ int update = va_arg(args, int);
+ vp8_update_reference(ctx->cpi, update);
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t vp8e_use_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
- int reference_flag = va_arg(args, int);
- vp8_use_as_reference(ctx->cpi, reference_flag);
- return VPX_CODEC_OK;
+ int ctr_id,
+ va_list args) {
+ int reference_flag = va_arg(args, int);
+ vp8_use_as_reference(ctx->cpi, reference_flag);
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t vp8e_set_roi_map(vpx_codec_alg_priv_t *ctx,
int ctr_id,
- va_list args)
-{
- vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *);
+ va_list args) {
+ vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *);
- if (data)
- {
- vpx_roi_map_t *roi = (vpx_roi_map_t *)data;
+ if (data) {
+ vpx_roi_map_t *roi = (vpx_roi_map_t *)data;
- if (!vp8_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols, roi->delta_q, roi->delta_lf, roi->static_threshold))
- return VPX_CODEC_OK;
- else
- return VPX_CODEC_INVALID_PARAM;
- }
+ if (!vp8_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols, roi->delta_q, roi->delta_lf, roi->static_threshold))
+ return VPX_CODEC_OK;
else
- return VPX_CODEC_INVALID_PARAM;
+ return VPX_CODEC_INVALID_PARAM;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
- vpx_active_map_t *data = va_arg(args, vpx_active_map_t *);
+ int ctr_id,
+ va_list args) {
+ vpx_active_map_t *data = va_arg(args, vpx_active_map_t *);
- if (data)
- {
+ if (data) {
- vpx_active_map_t *map = (vpx_active_map_t *)data;
+ vpx_active_map_t *map = (vpx_active_map_t *)data;
- if (!vp8_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols))
- return VPX_CODEC_OK;
- else
- return VPX_CODEC_INVALID_PARAM;
- }
+ if (!vp8_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols))
+ return VPX_CODEC_OK;
else
- return VPX_CODEC_INVALID_PARAM;
+ return VPX_CODEC_INVALID_PARAM;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
-
- vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *);
-
- if (data)
- {
- int res;
- vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data ;
- res = vp8_set_internal_size(ctx->cpi, scalemode.h_scaling_mode, scalemode.v_scaling_mode);
-
- if (!res)
- {
- /*force next frame a key frame to effect scaling mode */
- ctx->next_frame_flag |= FRAMEFLAGS_KEY;
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ int ctr_id,
+ va_list args) {
+
+ vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *);
+
+ if (data) {
+ int res;
+ vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data;
+ res = vp8_set_internal_size(ctx->cpi, scalemode.h_scaling_mode, scalemode.v_scaling_mode);
+
+ if (!res) {
+ /*force next frame a key frame to effect scaling mode */
+ ctx->next_frame_flag |= FRAMEFLAGS_KEY;
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
-static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] =
-{
- {VP8_SET_REFERENCE, vp8e_set_reference},
- {VP8_COPY_REFERENCE, vp8e_get_reference},
- {VP8_SET_POSTPROC, vp8e_set_previewpp},
- {VP8E_UPD_ENTROPY, vp8e_update_entropy},
- {VP8E_UPD_REFERENCE, vp8e_update_reference},
- {VP8E_USE_REFERENCE, vp8e_use_reference},
- {VP8E_SET_ROI_MAP, vp8e_set_roi_map},
- {VP8E_SET_ACTIVEMAP, vp8e_set_activemap},
- {VP8E_SET_SCALEMODE, vp8e_set_scalemode},
- {VP8E_SET_ENCODING_MODE, set_param},
- {VP8E_SET_CPUUSED, set_param},
- {VP8E_SET_NOISE_SENSITIVITY, set_param},
- {VP8E_SET_ENABLEAUTOALTREF, set_param},
- {VP8E_SET_SHARPNESS, set_param},
- {VP8E_SET_STATIC_THRESHOLD, set_param},
- {VP8E_SET_TOKEN_PARTITIONS, set_param},
- {VP8E_GET_LAST_QUANTIZER, get_param},
- {VP8E_GET_LAST_QUANTIZER_64, get_param},
- {VP8E_SET_ARNR_MAXFRAMES, set_param},
- {VP8E_SET_ARNR_STRENGTH , set_param},
- {VP8E_SET_ARNR_TYPE , set_param},
- {VP8E_SET_TUNING, set_param},
- {VP8E_SET_CQ_LEVEL, set_param},
- {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
- { -1, NULL},
+static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = {
+ {VP8_SET_REFERENCE, vp8e_set_reference},
+ {VP8_COPY_REFERENCE, vp8e_get_reference},
+ {VP8_SET_POSTPROC, vp8e_set_previewpp},
+ {VP8E_UPD_ENTROPY, vp8e_update_entropy},
+ {VP8E_UPD_REFERENCE, vp8e_update_reference},
+ {VP8E_USE_REFERENCE, vp8e_use_reference},
+ {VP8E_SET_ROI_MAP, vp8e_set_roi_map},
+ {VP8E_SET_ACTIVEMAP, vp8e_set_activemap},
+ {VP8E_SET_SCALEMODE, vp8e_set_scalemode},
+ {VP8E_SET_ENCODING_MODE, set_param},
+ {VP8E_SET_CPUUSED, set_param},
+ {VP8E_SET_NOISE_SENSITIVITY, set_param},
+ {VP8E_SET_ENABLEAUTOALTREF, set_param},
+ {VP8E_SET_SHARPNESS, set_param},
+ {VP8E_SET_STATIC_THRESHOLD, set_param},
+ {VP8E_SET_TOKEN_PARTITIONS, set_param},
+ {VP8E_GET_LAST_QUANTIZER, get_param},
+ {VP8E_GET_LAST_QUANTIZER_64, get_param},
+ {VP8E_SET_ARNR_MAXFRAMES, set_param},
+ {VP8E_SET_ARNR_STRENGTH, set_param},
+ {VP8E_SET_ARNR_TYPE, set_param},
+ {VP8E_SET_TUNING, set_param},
+ {VP8E_SET_CQ_LEVEL, set_param},
+ {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
+ { -1, NULL},
};
-static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] =
-{
- {
+static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = {
+ {
0,
{
- 0, /* g_usage */
- 0, /* g_threads */
- 0, /* g_profile */
+ 0, /* g_usage */
+ 0, /* g_threads */
+ 0, /* g_profile */
- 320, /* g_width */
- 240, /* g_height */
- {1, 30}, /* g_timebase */
+ 320, /* g_width */
+ 240, /* g_height */
+ {1, 30}, /* g_timebase */
- 0, /* g_error_resilient */
+ 0, /* g_error_resilient */
- VPX_RC_ONE_PASS, /* g_pass */
+ VPX_RC_ONE_PASS, /* g_pass */
- 0, /* g_lag_in_frames */
+ 0, /* g_lag_in_frames */
- 0, /* rc_dropframe_thresh */
- 0, /* rc_resize_allowed */
- 60, /* rc_resize_down_thresold */
- 30, /* rc_resize_up_thresold */
+ 0, /* rc_dropframe_thresh */
+ 0, /* rc_resize_allowed */
+ 60, /* rc_resize_down_thresold */
+ 30, /* rc_resize_up_thresold */
- VPX_VBR, /* rc_end_usage */
+ VPX_VBR, /* rc_end_usage */
#if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION)
- {0}, /* rc_twopass_stats_in */
+ {0}, /* rc_twopass_stats_in */
#endif
- 256, /* rc_target_bandwidth */
- 4, /* rc_min_quantizer */
- 63, /* rc_max_quantizer */
- 100, /* rc_undershoot_pct */
- 100, /* rc_overshoot_pct */
+ 256, /* rc_target_bandwidth */
+ 4, /* rc_min_quantizer */
+ 63, /* rc_max_quantizer */
+ 100, /* rc_undershoot_pct */
+ 100, /* rc_overshoot_pct */
- 6000, /* rc_max_buffer_size */
- 4000, /* rc_buffer_initial_size; */
- 5000, /* rc_buffer_optimal_size; */
+ 6000, /* rc_max_buffer_size */
+ 4000, /* rc_buffer_initial_size; */
+ 5000, /* rc_buffer_optimal_size; */
- 50, /* rc_two_pass_vbrbias */
- 0, /* rc_two_pass_vbrmin_section */
- 400, /* rc_two_pass_vbrmax_section */
+ 50, /* rc_two_pass_vbrbias */
+ 0, /* rc_two_pass_vbrmin_section */
+ 400, /* rc_two_pass_vbrmax_section */
- /* keyframing settings (kf) */
- VPX_KF_AUTO, /* g_kfmode*/
- 0, /* kf_min_dist */
- 9999, /* kf_max_dist */
+ /* keyframing settings (kf) */
+ VPX_KF_AUTO, /* g_kfmode*/
+ 0, /* kf_min_dist */
+ 9999, /* kf_max_dist */
#if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION)
- 1, /* g_delete_first_pass_file */
- "vp8.fpf" /* first pass filename */
+ 1, /* g_delete_first_pass_file */
+ "vp8.fpf" /* first pass filename */
#endif
- }},
- { -1, {NOT_IMPLEMENTED}}
+ }
+ },
+ { -1, {NOT_IMPLEMENTED}}
};
#ifndef VERSION_STRING
#define VERSION_STRING
#endif
-CODEC_INTERFACE(vpx_codec_vp8_cx) =
-{
- "WebM Project VP8 Encoder" VERSION_STRING,
- VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR |
- VPX_CODEC_CAP_OUTPUT_PARTITION,
- /* vpx_codec_caps_t caps; */
- vp8e_init, /* vpx_codec_init_fn_t init; */
- vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
- vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
- NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
- NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
- {
- NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
- NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
- NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
- NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
- },
- {
- vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
- vp8e_encode, /* vpx_codec_encode_fn_t encode; */
- vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
- vp8e_set_config,
- NOT_IMPLEMENTED,
- vp8e_get_preview,
- } /* encoder functions */
+CODEC_INTERFACE(vpx_codec_vp8_cx) = {
+ "WebM Project VP8 Encoder" VERSION_STRING,
+ VPX_CODEC_INTERNAL_ABI_VERSION,
+ VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR |
+ VPX_CODEC_CAP_OUTPUT_PARTITION,
+ /* vpx_codec_caps_t caps; */
+ vp8e_init, /* vpx_codec_init_fn_t init; */
+ vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
+ vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
+ NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
+ NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
+ {
+ NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
+ NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
+ NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
+ NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
+ },
+ {
+ vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
+ vp8e_encode, /* vpx_codec_encode_fn_t encode; */
+ vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
+ vp8e_set_config,
+ NOT_IMPLEMENTED,
+ vp8e_get_preview,
+ } /* encoder functions */
};
#if CONFIG_EXPERIMENTAL
-vpx_codec_iface_t vpx_codec_vp8x_cx_algo =
-{
- "VP8 Experimental Encoder" VERSION_STRING,
- VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR,
- /* vpx_codec_caps_t caps; */
- vp8e_exp_init, /* vpx_codec_init_fn_t init; */
- vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
- vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
- NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
- NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
- {
- NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
- NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
- NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
- NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
- },
- {
- vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
- vp8e_encode, /* vpx_codec_encode_fn_t encode; */
- vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
- vp8e_set_config,
- NOT_IMPLEMENTED,
- vp8e_get_preview,
- } /* encoder functions */
+vpx_codec_iface_t vpx_codec_vp8x_cx_algo = {
+ "VP8 Experimental Encoder" VERSION_STRING,
+ VPX_CODEC_INTERNAL_ABI_VERSION,
+ VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR,
+ /* vpx_codec_caps_t caps; */
+ vp8e_exp_init, /* vpx_codec_init_fn_t init; */
+ vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
+ vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
+ NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
+ NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
+ {
+ NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
+ NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
+ NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
+ NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
+ },
+ {
+ vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
+ vp8e_encode, /* vpx_codec_encode_fn_t encode; */
+ vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
+ vp8e_set_config,
+ NOT_IMPLEMENTED,
+ vp8e_get_preview,
+ } /* encoder functions */
};
#endif
@@ -1170,38 +1092,33 @@ vpx_codec_iface_t vpx_codec_vp8x_cx_algo =
#define FORCE_KEY 2
static vpx_codec_err_t api1_control(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
- va_list args)
-{
- vpx_codec_ctrl_fn_map_t *entry;
+ va_list args) {
+ vpx_codec_ctrl_fn_map_t *entry;
- switch (ctrl_id)
- {
+ switch (ctrl_id) {
case VP8E_SET_FLUSHFLAG:
- /* VP8 sample code did VP8E_SET_FLUSHFLAG followed by
- * vpx_codec_get_cx_data() rather than vpx_codec_encode().
- */
- return vp8e_encode(ctx, NULL, 0, 0, 0, 0);
+ /* VP8 sample code did VP8E_SET_FLUSHFLAG followed by
+ * vpx_codec_get_cx_data() rather than vpx_codec_encode().
+ */
+ return vp8e_encode(ctx, NULL, 0, 0, 0, 0);
case VP8E_SET_FRAMETYPE:
- ctx->base.enc.tbd |= FORCE_KEY;
- return VPX_CODEC_OK;
- }
+ ctx->base.enc.tbd |= FORCE_KEY;
+ return VPX_CODEC_OK;
+ }
- for (entry = vp8e_ctf_maps; entry && entry->fn; entry++)
- {
- if (!entry->ctrl_id || entry->ctrl_id == ctrl_id)
- {
- return entry->fn(ctx, ctrl_id, args);
- }
+ for (entry = vp8e_ctf_maps; entry && entry->fn; entry++) {
+ if (!entry->ctrl_id || entry->ctrl_id == ctrl_id) {
+ return entry->fn(ctx, ctrl_id, args);
}
+ }
- return VPX_CODEC_ERROR;
+ return VPX_CODEC_ERROR;
}
-static vpx_codec_ctrl_fn_map_t api1_ctrl_maps[] =
-{
- {0, api1_control},
- { -1, NULL}
+static vpx_codec_ctrl_fn_map_t api1_ctrl_maps[] = {
+ {0, api1_control},
+ { -1, NULL}
};
@@ -1210,39 +1127,37 @@ static vpx_codec_err_t api1_encode(vpx_codec_alg_priv_t *ctx,
vpx_codec_pts_t pts,
unsigned long duration,
vpx_enc_frame_flags_t flags,
- unsigned long deadline)
-{
- int force = ctx->base.enc.tbd;
-
- ctx->base.enc.tbd = 0;
- return vp8e_encode
- (ctx,
- img,
- pts,
- duration,
- flags | ((force & FORCE_KEY) ? VPX_EFLAG_FORCE_KF : 0),
- deadline);
+ unsigned long deadline) {
+ int force = ctx->base.enc.tbd;
+
+ ctx->base.enc.tbd = 0;
+ return vp8e_encode
+ (ctx,
+ img,
+ pts,
+ duration,
+ flags | ((force & FORCE_KEY) ? VPX_EFLAG_FORCE_KF : 0),
+ deadline);
}
-vpx_codec_iface_t vpx_enc_vp8_algo =
-{
- "WebM Project VP8 Encoder (Deprecated API)" VERSION_STRING,
- VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_ENCODER,
- /* vpx_codec_caps_t caps; */
- vp8e_init, /* vpx_codec_init_fn_t init; */
- vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
- api1_ctrl_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
- NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
- NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
- {NOT_IMPLEMENTED}, /* decoder functions */
- {
- vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
- api1_encode, /* vpx_codec_encode_fn_t encode; */
- vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
- vp8e_set_config,
- NOT_IMPLEMENTED,
- vp8e_get_preview,
- } /* encoder functions */
+vpx_codec_iface_t vpx_enc_vp8_algo = {
+ "WebM Project VP8 Encoder (Deprecated API)" VERSION_STRING,
+ VPX_CODEC_INTERNAL_ABI_VERSION,
+ VPX_CODEC_CAP_ENCODER,
+ /* vpx_codec_caps_t caps; */
+ vp8e_init, /* vpx_codec_init_fn_t init; */
+ vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
+ api1_ctrl_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
+ NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
+ NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
+ {NOT_IMPLEMENTED}, /* decoder functions */
+ {
+ vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
+ api1_encode, /* vpx_codec_encode_fn_t encode; */
+ vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
+ vp8e_set_config,
+ NOT_IMPLEMENTED,
+ vp8e_get_preview,
+ } /* encoder functions */
};
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c
index e59c877a1..112c1c5d4 100644
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -22,766 +22,693 @@
typedef vpx_codec_stream_info_t vp8_stream_info_t;
/* Structures for handling memory allocations */
-typedef enum
-{
- VP8_SEG_ALG_PRIV = 256,
- VP8_SEG_MAX
+typedef enum {
+ VP8_SEG_ALG_PRIV = 256,
+ VP8_SEG_MAX
} mem_seg_id_t;
#define NELEMENTS(x) ((int)(sizeof(x)/sizeof(x[0])))
static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t);
-typedef struct
-{
- unsigned int id;
- unsigned long sz;
- unsigned int align;
- unsigned int flags;
- unsigned long(*calc_sz)(const vpx_codec_dec_cfg_t *, vpx_codec_flags_t);
+typedef struct {
+ unsigned int id;
+ unsigned long sz;
+ unsigned int align;
+ unsigned int flags;
+ unsigned long(*calc_sz)(const vpx_codec_dec_cfg_t *, vpx_codec_flags_t);
} mem_req_t;
-static const mem_req_t vp8_mem_req_segs[] =
-{
- {VP8_SEG_ALG_PRIV, 0, 8, VPX_CODEC_MEM_ZERO, vp8_priv_sz},
- {VP8_SEG_MAX, 0, 0, 0, NULL}
+static const mem_req_t vp8_mem_req_segs[] = {
+ {VP8_SEG_ALG_PRIV, 0, 8, VPX_CODEC_MEM_ZERO, vp8_priv_sz},
+ {VP8_SEG_MAX, 0, 0, 0, NULL}
};
-struct vpx_codec_alg_priv
-{
- vpx_codec_priv_t base;
- vpx_codec_mmap_t mmaps[NELEMENTS(vp8_mem_req_segs)-1];
- vpx_codec_dec_cfg_t cfg;
- vp8_stream_info_t si;
- int defer_alloc;
- int decoder_init;
- VP8D_PTR pbi;
- int postproc_cfg_set;
- vp8_postproc_cfg_t postproc_cfg;
+struct vpx_codec_alg_priv {
+ vpx_codec_priv_t base;
+ vpx_codec_mmap_t mmaps[NELEMENTS(vp8_mem_req_segs) - 1];
+ vpx_codec_dec_cfg_t cfg;
+ vp8_stream_info_t si;
+ int defer_alloc;
+ int decoder_init;
+ VP8D_PTR pbi;
+ int postproc_cfg_set;
+ vp8_postproc_cfg_t postproc_cfg;
#if CONFIG_POSTPROC_VISUALIZER
- unsigned int dbg_postproc_flag;
- int dbg_color_ref_frame_flag;
- int dbg_color_mb_modes_flag;
- int dbg_color_b_modes_flag;
- int dbg_display_mv_flag;
+ unsigned int dbg_postproc_flag;
+ int dbg_color_ref_frame_flag;
+ int dbg_color_mb_modes_flag;
+ int dbg_color_b_modes_flag;
+ int dbg_display_mv_flag;
#endif
- vpx_image_t img;
- int img_setup;
- int img_avail;
+ vpx_image_t img;
+ int img_setup;
+ int img_avail;
};
-static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t flags)
-{
- /* Although this declaration is constant, we can't use it in the requested
- * segments list because we want to define the requested segments list
- * before defining the private type (so that the number of memory maps is
- * known)
- */
- (void)si;
- return sizeof(vpx_codec_alg_priv_t);
+static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t flags) {
+ /* Although this declaration is constant, we can't use it in the requested
+ * segments list because we want to define the requested segments list
+ * before defining the private type (so that the number of memory maps is
+ * known)
+ */
+ (void)si;
+ return sizeof(vpx_codec_alg_priv_t);
}
-static void vp8_mmap_dtor(vpx_codec_mmap_t *mmap)
-{
- free(mmap->priv);
+static void vp8_mmap_dtor(vpx_codec_mmap_t *mmap) {
+ free(mmap->priv);
}
-static vpx_codec_err_t vp8_mmap_alloc(vpx_codec_mmap_t *mmap)
-{
- vpx_codec_err_t res;
- unsigned int align;
+static vpx_codec_err_t vp8_mmap_alloc(vpx_codec_mmap_t *mmap) {
+ vpx_codec_err_t res;
+ unsigned int align;
- align = mmap->align ? mmap->align - 1 : 0;
+ align = mmap->align ? mmap->align - 1 : 0;
- if (mmap->flags & VPX_CODEC_MEM_ZERO)
- mmap->priv = calloc(1, mmap->sz + align);
- else
- mmap->priv = malloc(mmap->sz + align);
+ if (mmap->flags & VPX_CODEC_MEM_ZERO)
+ mmap->priv = calloc(1, mmap->sz + align);
+ else
+ mmap->priv = malloc(mmap->sz + align);
- res = (mmap->priv) ? VPX_CODEC_OK : VPX_CODEC_MEM_ERROR;
- mmap->base = (void *)((((uintptr_t)mmap->priv) + align) & ~(uintptr_t)align);
- mmap->dtor = vp8_mmap_dtor;
- return res;
+ res = (mmap->priv) ? VPX_CODEC_OK : VPX_CODEC_MEM_ERROR;
+ mmap->base = (void *)((((uintptr_t)mmap->priv) + align) & ~(uintptr_t)align);
+ mmap->dtor = vp8_mmap_dtor;
+ return res;
}
static vpx_codec_err_t vp8_validate_mmaps(const vp8_stream_info_t *si,
- const vpx_codec_mmap_t *mmaps,
- vpx_codec_flags_t init_flags)
-{
- int i;
- vpx_codec_err_t res = VPX_CODEC_OK;
-
- for (i = 0; i < NELEMENTS(vp8_mem_req_segs) - 1; i++)
- {
- /* Ensure the segment has been allocated */
- if (!mmaps[i].base)
- {
- res = VPX_CODEC_MEM_ERROR;
- break;
- }
+ const vpx_codec_mmap_t *mmaps,
+ vpx_codec_flags_t init_flags) {
+ int i;
+ vpx_codec_err_t res = VPX_CODEC_OK;
+
+ for (i = 0; i < NELEMENTS(vp8_mem_req_segs) - 1; i++) {
+ /* Ensure the segment has been allocated */
+ if (!mmaps[i].base) {
+ res = VPX_CODEC_MEM_ERROR;
+ break;
+ }
- /* Verify variable size segment is big enough for the current si. */
- if (vp8_mem_req_segs[i].calc_sz)
- {
- vpx_codec_dec_cfg_t cfg;
+ /* Verify variable size segment is big enough for the current si. */
+ if (vp8_mem_req_segs[i].calc_sz) {
+ vpx_codec_dec_cfg_t cfg;
- cfg.w = si->w;
- cfg.h = si->h;
+ cfg.w = si->w;
+ cfg.h = si->h;
- if (mmaps[i].sz < vp8_mem_req_segs[i].calc_sz(&cfg, init_flags))
- {
- res = VPX_CODEC_MEM_ERROR;
- break;
- }
- }
+ if (mmaps[i].sz < vp8_mem_req_segs[i].calc_sz(&cfg, init_flags)) {
+ res = VPX_CODEC_MEM_ERROR;
+ break;
+ }
}
+ }
- return res;
+ return res;
}
-static void vp8_init_ctx(vpx_codec_ctx_t *ctx, const vpx_codec_mmap_t *mmap)
-{
- int i;
+static void vp8_init_ctx(vpx_codec_ctx_t *ctx, const vpx_codec_mmap_t *mmap) {
+ int i;
- ctx->priv = mmap->base;
- ctx->priv->sz = sizeof(*ctx->priv);
- ctx->priv->iface = ctx->iface;
- ctx->priv->alg_priv = mmap->base;
+ ctx->priv = mmap->base;
+ ctx->priv->sz = sizeof(*ctx->priv);
+ ctx->priv->iface = ctx->iface;
+ ctx->priv->alg_priv = mmap->base;
- for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++)
- ctx->priv->alg_priv->mmaps[i].id = vp8_mem_req_segs[i].id;
+ for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++)
+ ctx->priv->alg_priv->mmaps[i].id = vp8_mem_req_segs[i].id;
- ctx->priv->alg_priv->mmaps[0] = *mmap;
- ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si);
- ctx->priv->init_flags = ctx->init_flags;
+ ctx->priv->alg_priv->mmaps[0] = *mmap;
+ ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si);
+ ctx->priv->init_flags = ctx->init_flags;
- if (ctx->config.dec)
- {
- /* Update the reference to the config structure to an internal copy. */
- ctx->priv->alg_priv->cfg = *ctx->config.dec;
- ctx->config.dec = &ctx->priv->alg_priv->cfg;
- }
+ if (ctx->config.dec) {
+ /* Update the reference to the config structure to an internal copy. */
+ ctx->priv->alg_priv->cfg = *ctx->config.dec;
+ ctx->config.dec = &ctx->priv->alg_priv->cfg;
+ }
}
-static void *mmap_lkup(vpx_codec_alg_priv_t *ctx, unsigned int id)
-{
- int i;
+static void *mmap_lkup(vpx_codec_alg_priv_t *ctx, unsigned int id) {
+ int i;
- for (i = 0; i < NELEMENTS(ctx->mmaps); i++)
- if (ctx->mmaps[i].id == id)
- return ctx->mmaps[i].base;
+ for (i = 0; i < NELEMENTS(ctx->mmaps); i++)
+ if (ctx->mmaps[i].id == id)
+ return ctx->mmaps[i].base;
- return NULL;
+ return NULL;
}
-static void vp8_finalize_mmaps(vpx_codec_alg_priv_t *ctx)
-{
- /* nothing to clean up */
+static void vp8_finalize_mmaps(vpx_codec_alg_priv_t *ctx) {
+ /* nothing to clean up */
}
-static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
+static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
- /* This function only allocates space for the vpx_codec_alg_priv_t
- * structure. More memory may be required at the time the stream
- * information becomes known.
- */
- if (!ctx->priv)
- {
- vpx_codec_mmap_t mmap;
+ /* This function only allocates space for the vpx_codec_alg_priv_t
+ * structure. More memory may be required at the time the stream
+ * information becomes known.
+ */
+ if (!ctx->priv) {
+ vpx_codec_mmap_t mmap;
- mmap.id = vp8_mem_req_segs[0].id;
- mmap.sz = sizeof(vpx_codec_alg_priv_t);
- mmap.align = vp8_mem_req_segs[0].align;
- mmap.flags = vp8_mem_req_segs[0].flags;
+ mmap.id = vp8_mem_req_segs[0].id;
+ mmap.sz = sizeof(vpx_codec_alg_priv_t);
+ mmap.align = vp8_mem_req_segs[0].align;
+ mmap.flags = vp8_mem_req_segs[0].flags;
- res = vp8_mmap_alloc(&mmap);
+ res = vp8_mmap_alloc(&mmap);
- if (!res)
- {
- vp8_init_ctx(ctx, &mmap);
+ if (!res) {
+ vp8_init_ctx(ctx, &mmap);
- ctx->priv->alg_priv->defer_alloc = 1;
- /*post processing level initialized to do nothing */
- }
+ ctx->priv->alg_priv->defer_alloc = 1;
+ /*post processing level initialized to do nothing */
}
+ }
- return res;
+ return res;
}
-static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx)
-{
- int i;
+static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx) {
+ int i;
- vp8dx_remove_decompressor(ctx->pbi);
+ vp8dx_remove_decompressor(ctx->pbi);
- for (i = NELEMENTS(ctx->mmaps) - 1; i >= 0; i--)
- {
- if (ctx->mmaps[i].dtor)
- ctx->mmaps[i].dtor(&ctx->mmaps[i]);
- }
+ for (i = NELEMENTS(ctx->mmaps) - 1; i >= 0; i--) {
+ if (ctx->mmaps[i].dtor)
+ ctx->mmaps[i].dtor(&ctx->mmaps[i]);
+ }
- return VPX_CODEC_OK;
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t vp8_peek_si(const uint8_t *data,
unsigned int data_sz,
- vpx_codec_stream_info_t *si)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
-
- if(data + data_sz <= data)
- res = VPX_CODEC_INVALID_PARAM;
- else
- {
- /* Parse uncompresssed part of key frame header.
- * 3 bytes:- including version, frame type and an offset
- * 3 bytes:- sync code (0x9d, 0x01, 0x2a)
- * 4 bytes:- including image width and height in the lowest 14 bits
- * of each 2-byte value.
- */
- si->is_kf = 0;
-
- if (data_sz >= 10 && !(data[0] & 0x01)) /* I-Frame */
- {
- const uint8_t *c = data + 3;
- si->is_kf = 1;
-
- /* vet via sync code */
- if (c[0] != 0x9d || c[1] != 0x01 || c[2] != 0x2a)
- res = VPX_CODEC_UNSUP_BITSTREAM;
-
- si->w = (c[3] | (c[4] << 8)) & 0x3fff;
- si->h = (c[5] | (c[6] << 8)) & 0x3fff;
-
- /*printf("w=%d, h=%d\n", si->w, si->h);*/
- if (!(si->h | si->w))
- res = VPX_CODEC_UNSUP_BITSTREAM;
- }
- else
- res = VPX_CODEC_UNSUP_BITSTREAM;
- }
+ vpx_codec_stream_info_t *si) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+
+ if (data + data_sz <= data)
+ res = VPX_CODEC_INVALID_PARAM;
+ else {
+ /* Parse uncompresssed part of key frame header.
+ * 3 bytes:- including version, frame type and an offset
+ * 3 bytes:- sync code (0x9d, 0x01, 0x2a)
+ * 4 bytes:- including image width and height in the lowest 14 bits
+ * of each 2-byte value.
+ */
+ si->is_kf = 0;
+
+ if (data_sz >= 10 && !(data[0] & 0x01)) { /* I-Frame */
+ const uint8_t *c = data + 3;
+ si->is_kf = 1;
+
+ /* vet via sync code */
+ if (c[0] != 0x9d || c[1] != 0x01 || c[2] != 0x2a)
+ res = VPX_CODEC_UNSUP_BITSTREAM;
+
+ si->w = (c[3] | (c[4] << 8)) & 0x3fff;
+ si->h = (c[5] | (c[6] << 8)) & 0x3fff;
- return res;
+ /*printf("w=%d, h=%d\n", si->w, si->h);*/
+ if (!(si->h | si->w))
+ res = VPX_CODEC_UNSUP_BITSTREAM;
+ } else
+ res = VPX_CODEC_UNSUP_BITSTREAM;
+ }
+
+ return res;
}
static vpx_codec_err_t vp8_get_si(vpx_codec_alg_priv_t *ctx,
- vpx_codec_stream_info_t *si)
-{
+ vpx_codec_stream_info_t *si) {
- unsigned int sz;
+ unsigned int sz;
- if (si->sz >= sizeof(vp8_stream_info_t))
- sz = sizeof(vp8_stream_info_t);
- else
- sz = sizeof(vpx_codec_stream_info_t);
+ if (si->sz >= sizeof(vp8_stream_info_t))
+ sz = sizeof(vp8_stream_info_t);
+ else
+ sz = sizeof(vpx_codec_stream_info_t);
- memcpy(si, &ctx->si, sz);
- si->sz = sz;
+ memcpy(si, &ctx->si, sz);
+ si->sz = sz;
- return VPX_CODEC_OK;
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t
update_error_state(vpx_codec_alg_priv_t *ctx,
- const struct vpx_internal_error_info *error)
-{
- vpx_codec_err_t res;
+ const struct vpx_internal_error_info *error) {
+ vpx_codec_err_t res;
- if ((res = error->error_code))
- ctx->base.err_detail = error->has_detail
- ? error->detail
- : NULL;
+ if ((res = error->error_code))
+ ctx->base.err_detail = error->has_detail
+ ? error->detail
+ : NULL;
- return res;
+ return res;
}
static void yuvconfig2image(vpx_image_t *img,
const YV12_BUFFER_CONFIG *yv12,
- void *user_priv)
-{
- /** vpx_img_wrap() doesn't allow specifying independent strides for
- * the Y, U, and V planes, nor other alignment adjustments that
- * might be representable by a YV12_BUFFER_CONFIG, so we just
- * initialize all the fields.*/
- img->fmt = yv12->clrtype == REG_YUV ?
- VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
- img->w = yv12->y_stride;
- img->h = (yv12->y_height + 2 * VP8BORDERINPIXELS + 15) & ~15;
- img->d_w = yv12->y_width;
- img->d_h = yv12->y_height;
- img->x_chroma_shift = 1;
- img->y_chroma_shift = 1;
- img->planes[VPX_PLANE_Y] = yv12->y_buffer;
- img->planes[VPX_PLANE_U] = yv12->u_buffer;
- img->planes[VPX_PLANE_V] = yv12->v_buffer;
- img->planes[VPX_PLANE_ALPHA] = NULL;
- img->stride[VPX_PLANE_Y] = yv12->y_stride;
- img->stride[VPX_PLANE_U] = yv12->uv_stride;
- img->stride[VPX_PLANE_V] = yv12->uv_stride;
- img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
- img->bps = 12;
- img->user_priv = user_priv;
- img->img_data = yv12->buffer_alloc;
- img->img_data_owner = 0;
- img->self_allocd = 0;
+ void *user_priv) {
+ /** vpx_img_wrap() doesn't allow specifying independent strides for
+ * the Y, U, and V planes, nor other alignment adjustments that
+ * might be representable by a YV12_BUFFER_CONFIG, so we just
+ * initialize all the fields.*/
+ img->fmt = yv12->clrtype == REG_YUV ?
+ VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
+ img->w = yv12->y_stride;
+ img->h = (yv12->y_height + 2 * VP8BORDERINPIXELS + 15) & ~15;
+ img->d_w = yv12->y_width;
+ img->d_h = yv12->y_height;
+ img->x_chroma_shift = 1;
+ img->y_chroma_shift = 1;
+ img->planes[VPX_PLANE_Y] = yv12->y_buffer;
+ img->planes[VPX_PLANE_U] = yv12->u_buffer;
+ img->planes[VPX_PLANE_V] = yv12->v_buffer;
+ img->planes[VPX_PLANE_ALPHA] = NULL;
+ img->stride[VPX_PLANE_Y] = yv12->y_stride;
+ img->stride[VPX_PLANE_U] = yv12->uv_stride;
+ img->stride[VPX_PLANE_V] = yv12->uv_stride;
+ img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
+ img->bps = 12;
+ img->user_priv = user_priv;
+ img->img_data = yv12->buffer_alloc;
+ img->img_data_owner = 0;
+ img->self_allocd = 0;
}
static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
const uint8_t *data,
unsigned int data_sz,
void *user_priv,
- long deadline)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
-
- ctx->img_avail = 0;
-
- /* Determine the stream parameters. Note that we rely on peek_si to
- * validate that we have a buffer that does not wrap around the top
- * of the heap.
- */
- if (!ctx->si.h)
- res = ctx->base.iface->dec.peek_si(data, data_sz, &ctx->si);
+ long deadline) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+ ctx->img_avail = 0;
- /* Perform deferred allocations, if required */
- if (!res && ctx->defer_alloc)
- {
- int i;
+ /* Determine the stream parameters. Note that we rely on peek_si to
+ * validate that we have a buffer that does not wrap around the top
+ * of the heap.
+ */
+ if (!ctx->si.h)
+ res = ctx->base.iface->dec.peek_si(data, data_sz, &ctx->si);
- for (i = 1; !res && i < NELEMENTS(ctx->mmaps); i++)
- {
- vpx_codec_dec_cfg_t cfg;
- cfg.w = ctx->si.w;
- cfg.h = ctx->si.h;
- ctx->mmaps[i].id = vp8_mem_req_segs[i].id;
- ctx->mmaps[i].sz = vp8_mem_req_segs[i].sz;
- ctx->mmaps[i].align = vp8_mem_req_segs[i].align;
- ctx->mmaps[i].flags = vp8_mem_req_segs[i].flags;
+ /* Perform deferred allocations, if required */
+ if (!res && ctx->defer_alloc) {
+ int i;
- if (!ctx->mmaps[i].sz)
- ctx->mmaps[i].sz = vp8_mem_req_segs[i].calc_sz(&cfg,
- ctx->base.init_flags);
+ for (i = 1; !res && i < NELEMENTS(ctx->mmaps); i++) {
+ vpx_codec_dec_cfg_t cfg;
- res = vp8_mmap_alloc(&ctx->mmaps[i]);
- }
+ cfg.w = ctx->si.w;
+ cfg.h = ctx->si.h;
+ ctx->mmaps[i].id = vp8_mem_req_segs[i].id;
+ ctx->mmaps[i].sz = vp8_mem_req_segs[i].sz;
+ ctx->mmaps[i].align = vp8_mem_req_segs[i].align;
+ ctx->mmaps[i].flags = vp8_mem_req_segs[i].flags;
- if (!res)
- vp8_finalize_mmaps(ctx);
+ if (!ctx->mmaps[i].sz)
+ ctx->mmaps[i].sz = vp8_mem_req_segs[i].calc_sz(&cfg,
+ ctx->base.init_flags);
- ctx->defer_alloc = 0;
+ res = vp8_mmap_alloc(&ctx->mmaps[i]);
}
- /* Initialize the decoder instance on the first frame*/
- if (!res && !ctx->decoder_init)
- {
- res = vp8_validate_mmaps(&ctx->si, ctx->mmaps, ctx->base.init_flags);
-
- if (!res)
- {
- VP8D_CONFIG oxcf;
- VP8D_PTR optr;
-
- vp8dx_initialize();
-
- oxcf.Width = ctx->si.w;
- oxcf.Height = ctx->si.h;
- oxcf.Version = 9;
- oxcf.postprocess = 0;
- oxcf.max_threads = ctx->cfg.threads;
- optr = vp8dx_create_decompressor(&oxcf);
-
- /* If postprocessing was enabled by the application and a
- * configuration has not been provided, default it.
- */
- if (!ctx->postproc_cfg_set
- && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
- {
- ctx->postproc_cfg.post_proc_flag =
- VP8_DEBLOCK | VP8_DEMACROBLOCK;
- ctx->postproc_cfg.deblocking_level = 4;
- ctx->postproc_cfg.noise_level = 0;
- }
-
- if (!optr)
- res = VPX_CODEC_ERROR;
- else
- ctx->pbi = optr;
- }
-
- ctx->decoder_init = 1;
+ if (!res)
+ vp8_finalize_mmaps(ctx);
+
+ ctx->defer_alloc = 0;
+ }
+
+ /* Initialize the decoder instance on the first frame*/
+ if (!res && !ctx->decoder_init) {
+ res = vp8_validate_mmaps(&ctx->si, ctx->mmaps, ctx->base.init_flags);
+
+ if (!res) {
+ VP8D_CONFIG oxcf;
+ VP8D_PTR optr;
+
+ vp8dx_initialize();
+
+ oxcf.Width = ctx->si.w;
+ oxcf.Height = ctx->si.h;
+ oxcf.Version = 9;
+ oxcf.postprocess = 0;
+ oxcf.max_threads = ctx->cfg.threads;
+ optr = vp8dx_create_decompressor(&oxcf);
+
+ /* If postprocessing was enabled by the application and a
+ * configuration has not been provided, default it.
+ */
+ if (!ctx->postproc_cfg_set
+ && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) {
+ ctx->postproc_cfg.post_proc_flag =
+ VP8_DEBLOCK | VP8_DEMACROBLOCK;
+ ctx->postproc_cfg.deblocking_level = 4;
+ ctx->postproc_cfg.noise_level = 0;
+ }
+
+ if (!optr)
+ res = VPX_CODEC_ERROR;
+ else
+ ctx->pbi = optr;
}
- if (!res && ctx->pbi)
- {
- YV12_BUFFER_CONFIG sd;
- int64_t time_stamp = 0, time_end_stamp = 0;
- vp8_ppflags_t flags = {0};
+ ctx->decoder_init = 1;
+ }
+
+ if (!res && ctx->pbi) {
+ YV12_BUFFER_CONFIG sd;
+ int64_t time_stamp = 0, time_end_stamp = 0;
+ vp8_ppflags_t flags = {0};
- if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)
- {
- flags.post_proc_flag= ctx->postproc_cfg.post_proc_flag
+ if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC) {
+ flags.post_proc_flag = ctx->postproc_cfg.post_proc_flag
#if CONFIG_POSTPROC_VISUALIZER
- | ((ctx->dbg_color_ref_frame_flag != 0) ? VP8D_DEBUG_CLR_FRM_REF_BLKS : 0)
- | ((ctx->dbg_color_mb_modes_flag != 0) ? VP8D_DEBUG_CLR_BLK_MODES : 0)
- | ((ctx->dbg_color_b_modes_flag != 0) ? VP8D_DEBUG_CLR_BLK_MODES : 0)
- | ((ctx->dbg_display_mv_flag != 0) ? VP8D_DEBUG_DRAW_MV : 0)
+ | ((ctx->dbg_color_ref_frame_flag != 0) ? VP8D_DEBUG_CLR_FRM_REF_BLKS : 0)
+ | ((ctx->dbg_color_mb_modes_flag != 0) ? VP8D_DEBUG_CLR_BLK_MODES : 0)
+ | ((ctx->dbg_color_b_modes_flag != 0) ? VP8D_DEBUG_CLR_BLK_MODES : 0)
+ | ((ctx->dbg_display_mv_flag != 0) ? VP8D_DEBUG_DRAW_MV : 0)
#endif
- ;
- flags.deblocking_level = ctx->postproc_cfg.deblocking_level;
- flags.noise_level = ctx->postproc_cfg.noise_level;
+;
+ flags.deblocking_level = ctx->postproc_cfg.deblocking_level;
+ flags.noise_level = ctx->postproc_cfg.noise_level;
#if CONFIG_POSTPROC_VISUALIZER
- flags.display_ref_frame_flag= ctx->dbg_color_ref_frame_flag;
- flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag;
- flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag;
- flags.display_mv_flag = ctx->dbg_display_mv_flag;
+ flags.display_ref_frame_flag = ctx->dbg_color_ref_frame_flag;
+ flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag;
+ flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag;
+ flags.display_mv_flag = ctx->dbg_display_mv_flag;
#endif
- }
+ }
- if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
- {
- VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
- res = update_error_state(ctx, &pbi->common.error);
- }
+ if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline)) {
+ VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
+ res = update_error_state(ctx, &pbi->common.error);
+ }
- if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, &flags))
- {
- yuvconfig2image(&ctx->img, &sd, user_priv);
- ctx->img_avail = 1;
- }
+ if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, &flags)) {
+ yuvconfig2image(&ctx->img, &sd, user_priv);
+ ctx->img_avail = 1;
}
+ }
- return res;
+ return res;
}
static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t *ctx,
- vpx_codec_iter_t *iter)
-{
- vpx_image_t *img = NULL;
-
- if (ctx->img_avail)
- {
- /* iter acts as a flip flop, so an image is only returned on the first
- * call to get_frame.
- */
- if (!(*iter))
- {
- img = &ctx->img;
- *iter = img;
- }
+ vpx_codec_iter_t *iter) {
+ vpx_image_t *img = NULL;
+
+ if (ctx->img_avail) {
+ /* iter acts as a flip flop, so an image is only returned on the first
+ * call to get_frame.
+ */
+ if (!(*iter)) {
+ img = &ctx->img;
+ *iter = img;
}
+ }
- return img;
+ return img;
}
static
vpx_codec_err_t vp8_xma_get_mmap(const vpx_codec_ctx_t *ctx,
vpx_codec_mmap_t *mmap,
- vpx_codec_iter_t *iter)
-{
- vpx_codec_err_t res;
- const mem_req_t *seg_iter = *iter;
-
- /* Get address of next segment request */
- do
- {
- if (!seg_iter)
- seg_iter = vp8_mem_req_segs;
- else if (seg_iter->id != VP8_SEG_MAX)
- seg_iter++;
-
- *iter = (vpx_codec_iter_t)seg_iter;
-
- if (seg_iter->id != VP8_SEG_MAX)
- {
- mmap->id = seg_iter->id;
- mmap->sz = seg_iter->sz;
- mmap->align = seg_iter->align;
- mmap->flags = seg_iter->flags;
-
- if (!seg_iter->sz)
- mmap->sz = seg_iter->calc_sz(ctx->config.dec, ctx->init_flags);
-
- res = VPX_CODEC_OK;
- }
- else
- res = VPX_CODEC_LIST_END;
- }
- while (!mmap->sz && res != VPX_CODEC_LIST_END);
-
- return res;
+ vpx_codec_iter_t *iter) {
+ vpx_codec_err_t res;
+ const mem_req_t *seg_iter = *iter;
+
+ /* Get address of next segment request */
+ do {
+ if (!seg_iter)
+ seg_iter = vp8_mem_req_segs;
+ else if (seg_iter->id != VP8_SEG_MAX)
+ seg_iter++;
+
+ *iter = (vpx_codec_iter_t)seg_iter;
+
+ if (seg_iter->id != VP8_SEG_MAX) {
+ mmap->id = seg_iter->id;
+ mmap->sz = seg_iter->sz;
+ mmap->align = seg_iter->align;
+ mmap->flags = seg_iter->flags;
+
+ if (!seg_iter->sz)
+ mmap->sz = seg_iter->calc_sz(ctx->config.dec, ctx->init_flags);
+
+ res = VPX_CODEC_OK;
+ } else
+ res = VPX_CODEC_LIST_END;
+ } while (!mmap->sz && res != VPX_CODEC_LIST_END);
+
+ return res;
}
static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx,
- const vpx_codec_mmap_t *mmap)
-{
- vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
- int i, done;
-
- if (!ctx->priv)
- {
- if (mmap->id == VP8_SEG_ALG_PRIV)
- {
- if (!ctx->priv)
- {
- vp8_init_ctx(ctx, mmap);
- res = VPX_CODEC_OK;
- }
- }
+ const vpx_codec_mmap_t *mmap) {
+ vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
+ int i, done;
+
+ if (!ctx->priv) {
+ if (mmap->id == VP8_SEG_ALG_PRIV) {
+ if (!ctx->priv) {
+ vp8_init_ctx(ctx, mmap);
+ res = VPX_CODEC_OK;
+ }
}
+ }
- done = 1;
+ done = 1;
- if (!res && ctx->priv->alg_priv)
- {
- for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++)
- {
- if (ctx->priv->alg_priv->mmaps[i].id == mmap->id)
- if (!ctx->priv->alg_priv->mmaps[i].base)
- {
- ctx->priv->alg_priv->mmaps[i] = *mmap;
- res = VPX_CODEC_OK;
- }
-
- done &= (ctx->priv->alg_priv->mmaps[i].base != NULL);
+ if (!res && ctx->priv->alg_priv) {
+ for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++) {
+ if (ctx->priv->alg_priv->mmaps[i].id == mmap->id)
+ if (!ctx->priv->alg_priv->mmaps[i].base) {
+ ctx->priv->alg_priv->mmaps[i] = *mmap;
+ res = VPX_CODEC_OK;
}
- }
- if (done && !res)
- {
- vp8_finalize_mmaps(ctx->priv->alg_priv);
- res = ctx->iface->init(ctx);
+ done &= (ctx->priv->alg_priv->mmaps[i].base != NULL);
}
+ }
+
+ if (done && !res) {
+ vp8_finalize_mmaps(ctx->priv->alg_priv);
+ res = ctx->iface->init(ctx);
+ }
- return res;
+ return res;
}
static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
- YV12_BUFFER_CONFIG *yv12)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
- yv12->y_buffer = img->planes[VPX_PLANE_Y];
- yv12->u_buffer = img->planes[VPX_PLANE_U];
- yv12->v_buffer = img->planes[VPX_PLANE_V];
+ YV12_BUFFER_CONFIG *yv12) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+ yv12->y_buffer = img->planes[VPX_PLANE_Y];
+ yv12->u_buffer = img->planes[VPX_PLANE_U];
+ yv12->v_buffer = img->planes[VPX_PLANE_V];
- yv12->y_width = img->d_w;
- yv12->y_height = img->d_h;
- yv12->uv_width = yv12->y_width / 2;
- yv12->uv_height = yv12->y_height / 2;
+ yv12->y_width = img->d_w;
+ yv12->y_height = img->d_h;
+ yv12->uv_width = yv12->y_width / 2;
+ yv12->uv_height = yv12->y_height / 2;
- yv12->y_stride = img->stride[VPX_PLANE_Y];
- yv12->uv_stride = img->stride[VPX_PLANE_U];
+ yv12->y_stride = img->stride[VPX_PLANE_Y];
+ yv12->uv_stride = img->stride[VPX_PLANE_U];
- yv12->border = (img->stride[VPX_PLANE_Y] - img->d_w) / 2;
- yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12);
+ yv12->border = (img->stride[VPX_PLANE_Y] - img->d_w) / 2;
+ yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12);
- return res;
+ return res;
}
static vpx_codec_err_t vp8_set_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
+ int ctr_id,
+ va_list args) {
- vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
+ vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
- if (data)
- {
- vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
- YV12_BUFFER_CONFIG sd;
+ if (data) {
+ vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
+ YV12_BUFFER_CONFIG sd;
- image2yuvconfig(&frame->img, &sd);
+ image2yuvconfig(&frame->img, &sd);
- return vp8dx_set_reference(ctx->pbi, frame->frame_type, &sd);
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ return vp8dx_set_reference(ctx->pbi, frame->frame_type, &sd);
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8_get_reference(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args)
-{
+ int ctr_id,
+ va_list args) {
- vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
+ vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
- if (data)
- {
- vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
- YV12_BUFFER_CONFIG sd;
+ if (data) {
+ vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
+ YV12_BUFFER_CONFIG sd;
- image2yuvconfig(&frame->img, &sd);
+ image2yuvconfig(&frame->img, &sd);
- return vp8dx_get_reference(ctx->pbi, frame->frame_type, &sd);
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ return vp8dx_get_reference(ctx->pbi, frame->frame_type, &sd);
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8_set_postproc(vpx_codec_alg_priv_t *ctx,
int ctr_id,
- va_list args)
-{
+ va_list args) {
#if CONFIG_POSTPROC
- vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
+ vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
- if (data)
- {
- ctx->postproc_cfg_set = 1;
- ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data);
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ if (data) {
+ ctx->postproc_cfg_set = 1;
+ ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data);
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
#else
- return VPX_CODEC_INCAPABLE;
+ return VPX_CODEC_INCAPABLE;
#endif
}
static vpx_codec_err_t vp8_set_dbg_options(vpx_codec_alg_priv_t *ctx,
- int ctrl_id,
- va_list args)
-{
+ int ctrl_id,
+ va_list args) {
#if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC
- int data = va_arg(args, int);
+ int data = va_arg(args, int);
#define MAP(id, var) case id: var = data; break;
- switch (ctrl_id)
- {
- MAP (VP8_SET_DBG_COLOR_REF_FRAME, ctx->dbg_color_ref_frame_flag);
- MAP (VP8_SET_DBG_COLOR_MB_MODES, ctx->dbg_color_mb_modes_flag);
- MAP (VP8_SET_DBG_COLOR_B_MODES, ctx->dbg_color_b_modes_flag);
- MAP (VP8_SET_DBG_DISPLAY_MV, ctx->dbg_display_mv_flag);
- }
+ switch (ctrl_id) {
+ MAP(VP8_SET_DBG_COLOR_REF_FRAME, ctx->dbg_color_ref_frame_flag);
+ MAP(VP8_SET_DBG_COLOR_MB_MODES, ctx->dbg_color_mb_modes_flag);
+ MAP(VP8_SET_DBG_COLOR_B_MODES, ctx->dbg_color_b_modes_flag);
+ MAP(VP8_SET_DBG_DISPLAY_MV, ctx->dbg_display_mv_flag);
+ }
- return VPX_CODEC_OK;
+ return VPX_CODEC_OK;
#else
- return VPX_CODEC_INCAPABLE;
+ return VPX_CODEC_INCAPABLE;
#endif
}
static vpx_codec_err_t vp8_get_last_ref_updates(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
- va_list args)
-{
- int *update_info = va_arg(args, int *);
- VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
+ va_list args) {
+ int *update_info = va_arg(args, int *);
+ VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
- if (update_info)
- {
- *update_info = pbi->common.refresh_alt_ref_frame * (int) VP8_ALTR_FRAME
- + pbi->common.refresh_golden_frame * (int) VP8_GOLD_FRAME
- + pbi->common.refresh_last_frame * (int) VP8_LAST_FRAME;
+ if (update_info) {
+ *update_info = pbi->common.refresh_alt_ref_frame * (int) VP8_ALTR_FRAME
+ + pbi->common.refresh_golden_frame * (int) VP8_GOLD_FRAME
+ + pbi->common.refresh_last_frame * (int) VP8_LAST_FRAME;
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
- va_list args)
-{
+ va_list args) {
- int *corrupted = va_arg(args, int *);
+ int *corrupted = va_arg(args, int *);
- if (corrupted)
- {
- VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
- *corrupted = pbi->common.frame_to_show->corrupted;
+ if (corrupted) {
+ VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
+ *corrupted = pbi->common.frame_to_show->corrupted;
- return VPX_CODEC_OK;
- }
- else
- return VPX_CODEC_INVALID_PARAM;
+ return VPX_CODEC_OK;
+ } else
+ return VPX_CODEC_INVALID_PARAM;
}
-vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] =
-{
- {VP8_SET_REFERENCE, vp8_set_reference},
- {VP8_COPY_REFERENCE, vp8_get_reference},
- {VP8_SET_POSTPROC, vp8_set_postproc},
- {VP8_SET_DBG_COLOR_REF_FRAME, vp8_set_dbg_options},
- {VP8_SET_DBG_COLOR_MB_MODES, vp8_set_dbg_options},
- {VP8_SET_DBG_COLOR_B_MODES, vp8_set_dbg_options},
- {VP8_SET_DBG_DISPLAY_MV, vp8_set_dbg_options},
- {VP8D_GET_LAST_REF_UPDATES, vp8_get_last_ref_updates},
- {VP8D_GET_FRAME_CORRUPTED, vp8_get_frame_corrupted},
- { -1, NULL},
+vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] = {
+ {VP8_SET_REFERENCE, vp8_set_reference},
+ {VP8_COPY_REFERENCE, vp8_get_reference},
+ {VP8_SET_POSTPROC, vp8_set_postproc},
+ {VP8_SET_DBG_COLOR_REF_FRAME, vp8_set_dbg_options},
+ {VP8_SET_DBG_COLOR_MB_MODES, vp8_set_dbg_options},
+ {VP8_SET_DBG_COLOR_B_MODES, vp8_set_dbg_options},
+ {VP8_SET_DBG_DISPLAY_MV, vp8_set_dbg_options},
+ {VP8D_GET_LAST_REF_UPDATES, vp8_get_last_ref_updates},
+ {VP8D_GET_FRAME_CORRUPTED, vp8_get_frame_corrupted},
+ { -1, NULL},
};
#ifndef VERSION_STRING
#define VERSION_STRING
#endif
-CODEC_INTERFACE(vpx_codec_vp8_dx) =
-{
- "WebM Project VP8 Decoder" VERSION_STRING,
- VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC |
- VPX_CODEC_CAP_INPUT_PARTITION,
- /* vpx_codec_caps_t caps; */
- vp8_init, /* vpx_codec_init_fn_t init; */
- vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */
- vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
- vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */
- vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */
- {
- vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */
- vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */
- vp8_decode, /* vpx_codec_decode_fn_t decode; */
- vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
- },
- { /* encoder functions */
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED
- }
+CODEC_INTERFACE(vpx_codec_vp8_dx) = {
+ "WebM Project VP8 Decoder" VERSION_STRING,
+ VPX_CODEC_INTERNAL_ABI_VERSION,
+ VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC |
+ VPX_CODEC_CAP_INPUT_PARTITION,
+ /* vpx_codec_caps_t caps; */
+ vp8_init, /* vpx_codec_init_fn_t init; */
+ vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */
+ vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
+ vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */
+ vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */
+ {
+ vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */
+ vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */
+ vp8_decode, /* vpx_codec_decode_fn_t decode; */
+ vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
+ },
+ {
+ /* encoder functions */
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED
+ }
};
/*
* BEGIN BACKWARDS COMPATIBILITY SHIM.
*/
-vpx_codec_iface_t vpx_codec_vp8_algo =
-{
- "WebM Project VP8 Decoder (Deprecated API)" VERSION_STRING,
- VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC,
- /* vpx_codec_caps_t caps; */
- vp8_init, /* vpx_codec_init_fn_t init; */
- vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */
- vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
- vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */
- vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */
- {
- vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */
- vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */
- vp8_decode, /* vpx_codec_decode_fn_t decode; */
- vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
- },
- { /* encoder functions */
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED,
- NOT_IMPLEMENTED
- }
+vpx_codec_iface_t vpx_codec_vp8_algo = {
+ "WebM Project VP8 Decoder (Deprecated API)" VERSION_STRING,
+ VPX_CODEC_INTERNAL_ABI_VERSION,
+ VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC,
+ /* vpx_codec_caps_t caps; */
+ vp8_init, /* vpx_codec_init_fn_t init; */
+ vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */
+ vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
+ vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */
+ vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */
+ {
+ vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */
+ vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */
+ vp8_decode, /* vpx_codec_decode_fn_t decode; */
+ vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
+ },
+ {
+ /* encoder functions */
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED,
+ NOT_IMPLEMENTED
+ }
};
diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h
index a1ff1921e..811fe3462 100644
--- a/vpx/internal/vpx_codec_internal.h
+++ b/vpx/internal/vpx_codec_internal.h
@@ -107,8 +107,8 @@ typedef vpx_codec_err_t (*vpx_codec_destroy_fn_t)(vpx_codec_alg_priv_t *ctx);
* Bitstream is parsable and stream information updated
*/
typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(const uint8_t *data,
- unsigned int data_sz,
- vpx_codec_stream_info_t *si);
+ unsigned int data_sz,
+ vpx_codec_stream_info_t *si);
/*!\brief Return information about the current stream.
*
@@ -124,7 +124,7 @@ typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(const uint8_t *data,
* Bitstream is parsable and stream information updated
*/
typedef vpx_codec_err_t (*vpx_codec_get_si_fn_t)(vpx_codec_alg_priv_t *ctx,
- vpx_codec_stream_info_t *si);
+ vpx_codec_stream_info_t *si);
/*!\brief control function pointer prototype
*
@@ -149,8 +149,8 @@ typedef vpx_codec_err_t (*vpx_codec_get_si_fn_t)(vpx_codec_alg_priv_t *ctx,
* The internal state data was deserialized.
*/
typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(vpx_codec_alg_priv_t *ctx,
- int ctrl_id,
- va_list ap);
+ int ctrl_id,
+ va_list ap);
/*!\brief control function pointer mapping
*
@@ -163,10 +163,9 @@ typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(vpx_codec_alg_priv_t *ctx,
* mapping. This implies that ctrl_id values chosen by the algorithm
* \ref MUST be non-zero.
*/
-typedef const struct
-{
- int ctrl_id;
- vpx_codec_control_fn_t fn;
+typedef const struct {
+ int ctrl_id;
+ vpx_codec_control_fn_t fn;
} vpx_codec_ctrl_fn_map_t;
/*!\brief decode data function pointer prototype
@@ -190,10 +189,10 @@ typedef const struct
* for recoverability capabilities.
*/
typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx,
- const uint8_t *data,
- unsigned int data_sz,
- void *user_priv,
- long deadline);
+ const uint8_t *data,
+ unsigned int data_sz,
+ void *user_priv,
+ long deadline);
/*!\brief Decoded frames iterator
*
@@ -210,8 +209,8 @@ typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx,
* \return Returns a pointer to an image, if one is ready for display. Frames
* produced will always be in PTS (presentation time stamp) order.
*/
-typedef vpx_image_t*(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
- vpx_codec_iter_t *iter);
+typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
+ vpx_codec_iter_t *iter);
/*\brief eXternal Memory Allocation memory map get iterator
@@ -226,8 +225,8 @@ typedef vpx_image_t*(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
* indicate end-of-list.
*/
typedef vpx_codec_err_t (*vpx_codec_get_mmap_fn_t)(const vpx_codec_ctx_t *ctx,
- vpx_codec_mmap_t *mmap,
- vpx_codec_iter_t *iter);
+ vpx_codec_mmap_t *mmap,
+ vpx_codec_iter_t *iter);
/*\brief eXternal Memory Allocation memory map set iterator
@@ -243,17 +242,17 @@ typedef vpx_codec_err_t (*vpx_codec_get_mmap_fn_t)(const vpx_codec_ctx_t *c
* The memory map was rejected.
*/
typedef vpx_codec_err_t (*vpx_codec_set_mmap_fn_t)(vpx_codec_ctx_t *ctx,
- const vpx_codec_mmap_t *mmap);
+ const vpx_codec_mmap_t *mmap);
typedef vpx_codec_err_t (*vpx_codec_encode_fn_t)(vpx_codec_alg_priv_t *ctx,
- const vpx_image_t *img,
- vpx_codec_pts_t pts,
- unsigned long duration,
- vpx_enc_frame_flags_t flags,
- unsigned long deadline);
-typedef const vpx_codec_cx_pkt_t*(*vpx_codec_get_cx_data_fn_t)(vpx_codec_alg_priv_t *ctx,
- vpx_codec_iter_t *iter);
+ const vpx_image_t *img,
+ vpx_codec_pts_t pts,
+ unsigned long duration,
+ vpx_enc_frame_flags_t flags,
+ unsigned long deadline);
+typedef const vpx_codec_cx_pkt_t *(*vpx_codec_get_cx_data_fn_t)(vpx_codec_alg_priv_t *ctx,
+ vpx_codec_iter_t *iter);
typedef vpx_codec_err_t
(*vpx_codec_enc_config_set_fn_t)(vpx_codec_alg_priv_t *ctx,
@@ -274,10 +273,9 @@ typedef vpx_image_t *
* one mapping must be present, in addition to the end-of-list.
*
*/
-typedef const struct
-{
- int usage;
- vpx_codec_enc_cfg_t cfg;
+typedef const struct {
+ int usage;
+ vpx_codec_enc_cfg_t cfg;
} vpx_codec_enc_cfg_map_t;
#define NOT_IMPLEMENTED 0
@@ -286,43 +284,38 @@ typedef const struct
*
* All decoders \ref MUST expose a variable of this type.
*/
-struct vpx_codec_iface
-{
- const char *name; /**< Identification String */
- int abi_version; /**< Implemented ABI version */
- vpx_codec_caps_t caps; /**< Decoder capabilities */
- vpx_codec_init_fn_t init; /**< \copydoc ::vpx_codec_init_fn_t */
- vpx_codec_destroy_fn_t destroy; /**< \copydoc ::vpx_codec_destroy_fn_t */
- vpx_codec_ctrl_fn_map_t *ctrl_maps; /**< \copydoc ::vpx_codec_ctrl_fn_map_t */
- vpx_codec_get_mmap_fn_t get_mmap; /**< \copydoc ::vpx_codec_get_mmap_fn_t */
- vpx_codec_set_mmap_fn_t set_mmap; /**< \copydoc ::vpx_codec_set_mmap_fn_t */
- struct
- {
- vpx_codec_peek_si_fn_t peek_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */
- vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */
- vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_fn_t */
- vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_frame_fn_t */
- } dec;
- struct
- {
- vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_codec_enc_cfg_map_t */
- vpx_codec_encode_fn_t encode; /**< \copydoc ::vpx_codec_encode_fn_t */
- vpx_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::vpx_codec_get_cx_data_fn_t */
- vpx_codec_enc_config_set_fn_t cfg_set; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */
- vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */
- vpx_codec_get_preview_frame_fn_t get_preview; /**< \copydoc ::vpx_codec_get_preview_frame_fn_t */
- } enc;
+struct vpx_codec_iface {
+ const char *name; /**< Identification String */
+ int abi_version; /**< Implemented ABI version */
+ vpx_codec_caps_t caps; /**< Decoder capabilities */
+ vpx_codec_init_fn_t init; /**< \copydoc ::vpx_codec_init_fn_t */
+ vpx_codec_destroy_fn_t destroy; /**< \copydoc ::vpx_codec_destroy_fn_t */
+ vpx_codec_ctrl_fn_map_t *ctrl_maps; /**< \copydoc ::vpx_codec_ctrl_fn_map_t */
+ vpx_codec_get_mmap_fn_t get_mmap; /**< \copydoc ::vpx_codec_get_mmap_fn_t */
+ vpx_codec_set_mmap_fn_t set_mmap; /**< \copydoc ::vpx_codec_set_mmap_fn_t */
+ struct {
+ vpx_codec_peek_si_fn_t peek_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */
+ vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */
+ vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_fn_t */
+ vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_frame_fn_t */
+ } dec;
+ struct {
+ vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_codec_enc_cfg_map_t */
+ vpx_codec_encode_fn_t encode; /**< \copydoc ::vpx_codec_encode_fn_t */
+ vpx_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::vpx_codec_get_cx_data_fn_t */
+ vpx_codec_enc_config_set_fn_t cfg_set; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */
+ vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */
+ vpx_codec_get_preview_frame_fn_t get_preview; /**< \copydoc ::vpx_codec_get_preview_frame_fn_t */
+ } enc;
};
/*!\brief Callback function pointer / user data pair storage */
-typedef struct vpx_codec_priv_cb_pair
-{
- union
- {
- vpx_codec_put_frame_cb_fn_t put_frame;
- vpx_codec_put_slice_cb_fn_t put_slice;
- } u;
- void *user_priv;
+typedef struct vpx_codec_priv_cb_pair {
+ union {
+ vpx_codec_put_frame_cb_fn_t put_frame;
+ vpx_codec_put_slice_cb_fn_t put_slice;
+ } u;
+ void *user_priv;
} vpx_codec_priv_cb_pair_t;
@@ -334,56 +327,53 @@ typedef struct vpx_codec_priv_cb_pair
* structure can be made the first member of the algorithm specific structure,
* and the pointer cast to the proper type.
*/
-struct vpx_codec_priv
-{
- unsigned int sz;
- vpx_codec_iface_t *iface;
- struct vpx_codec_alg_priv *alg_priv;
- const char *err_detail;
- vpx_codec_flags_t init_flags;
- struct
- {
- vpx_codec_priv_cb_pair_t put_frame_cb;
- vpx_codec_priv_cb_pair_t put_slice_cb;
- } dec;
- struct
- {
- int tbd;
- struct vpx_fixed_buf cx_data_dst_buf;
- unsigned int cx_data_pad_before;
- unsigned int cx_data_pad_after;
- vpx_codec_cx_pkt_t cx_data_pkt;
- } enc;
+struct vpx_codec_priv {
+ unsigned int sz;
+ vpx_codec_iface_t *iface;
+ struct vpx_codec_alg_priv *alg_priv;
+ const char *err_detail;
+ vpx_codec_flags_t init_flags;
+ struct {
+ vpx_codec_priv_cb_pair_t put_frame_cb;
+ vpx_codec_priv_cb_pair_t put_slice_cb;
+ } dec;
+ struct {
+ int tbd;
+ struct vpx_fixed_buf cx_data_dst_buf;
+ unsigned int cx_data_pad_before;
+ unsigned int cx_data_pad_after;
+ vpx_codec_cx_pkt_t cx_data_pkt;
+ } enc;
};
#undef VPX_CTRL_USE_TYPE
#define VPX_CTRL_USE_TYPE(id, typ) \
- static typ id##__value(va_list args) {return va_arg(args, typ);} \
- static typ id##__convert(void *x)\
+ static typ id##__value(va_list args) {return va_arg(args, typ);} \
+ static typ id##__convert(void *x)\
+ {\
+ union\
{\
- union\
- {\
- void *x;\
- typ d;\
- } u;\
- u.x = x;\
- return u.d;\
- }
+ void *x;\
+ typ d;\
+ } u;\
+ u.x = x;\
+ return u.d;\
+ }
#undef VPX_CTRL_USE_TYPE_DEPRECATED
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
- static typ id##__value(va_list args) {return va_arg(args, typ);} \
- static typ id##__convert(void *x)\
+ static typ id##__value(va_list args) {return va_arg(args, typ);} \
+ static typ id##__convert(void *x)\
+ {\
+ union\
{\
- union\
- {\
- void *x;\
- typ d;\
- } u;\
- u.x = x;\
- return u.d;\
- }
+ void *x;\
+ typ d;\
+ } u;\
+ u.x = x;\
+ return u.d;\
+ }
#define CAST(id, arg) id##__value(arg)
#define RECAST(id, x) id##__convert(x)
@@ -399,8 +389,8 @@ struct vpx_codec_priv
* macro is provided to define this getter function automatically.
*/
#define CODEC_INTERFACE(id)\
-vpx_codec_iface_t* id(void) { return &id##_algo; }\
-vpx_codec_iface_t id##_algo
+ vpx_codec_iface_t* id(void) { return &id##_algo; }\
+ vpx_codec_iface_t id##_algo
/* Internal Utility Functions
@@ -408,64 +398,60 @@ vpx_codec_iface_t id##_algo
* The following functions are intended to be used inside algorithms as
* utilities for manipulating vpx_codec_* data structures.
*/
-struct vpx_codec_pkt_list
-{
- unsigned int cnt;
- unsigned int max;
- struct vpx_codec_cx_pkt pkts[1];
+struct vpx_codec_pkt_list {
+ unsigned int cnt;
+ unsigned int max;
+ struct vpx_codec_cx_pkt pkts[1];
};
#define vpx_codec_pkt_list_decl(n)\
- union {struct vpx_codec_pkt_list head;\
- struct {struct vpx_codec_pkt_list head;\
- struct vpx_codec_cx_pkt pkts[n];} alloc;}
+ union {struct vpx_codec_pkt_list head;\
+ struct {struct vpx_codec_pkt_list head;\
+ struct vpx_codec_cx_pkt pkts[n];} alloc;}
#define vpx_codec_pkt_list_init(m)\
- (m)->alloc.head.cnt = 0,\
- (m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof((m)->alloc.pkts[0])
+ (m)->alloc.head.cnt = 0,\
+ (m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof((m)->alloc.pkts[0])
int
vpx_codec_pkt_list_add(struct vpx_codec_pkt_list *,
const struct vpx_codec_cx_pkt *);
-const vpx_codec_cx_pkt_t*
+const vpx_codec_cx_pkt_t *
vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list,
vpx_codec_iter_t *iter);
#include <stdio.h>
#include <setjmp.h>
-struct vpx_internal_error_info
-{
- vpx_codec_err_t error_code;
- int has_detail;
- char detail[80];
- int setjmp;
- jmp_buf jmp;
+struct vpx_internal_error_info {
+ vpx_codec_err_t error_code;
+ int has_detail;
+ char detail[80];
+ int setjmp;
+ jmp_buf jmp;
};
static void vpx_internal_error(struct vpx_internal_error_info *info,
vpx_codec_err_t error,
const char *fmt,
- ...)
-{
- va_list ap;
-
- info->error_code = error;
- info->has_detail = 0;
-
- if (fmt)
- {
- size_t sz = sizeof(info->detail);
-
- info->has_detail = 1;
- va_start(ap, fmt);
- vsnprintf(info->detail, sz - 1, fmt, ap);
- va_end(ap);
- info->detail[sz-1] = '\0';
- }
-
- if (info->setjmp)
- longjmp(info->jmp, info->error_code);
+ ...) {
+ va_list ap;
+
+ info->error_code = error;
+ info->has_detail = 0;
+
+ if (fmt) {
+ size_t sz = sizeof(info->detail);
+
+ info->has_detail = 1;
+ va_start(ap, fmt);
+ vsnprintf(info->detail, sz - 1, fmt, ap);
+ va_end(ap);
+ info->detail[sz - 1] = '\0';
+ }
+
+ if (info->setjmp)
+ longjmp(info->jmp, info->error_code);
}
#endif
diff --git a/vpx/src/vpx_codec.c b/vpx/src/vpx_codec.c
index f1a8b67b5..61d7f4c18 100644
--- a/vpx/src/vpx_codec.c
+++ b/vpx/src/vpx_codec.c
@@ -20,131 +20,116 @@
#define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var)
-int vpx_codec_version(void)
-{
- return VERSION_PACKED;
+int vpx_codec_version(void) {
+ return VERSION_PACKED;
}
-const char *vpx_codec_version_str(void)
-{
- return VERSION_STRING_NOSP;
+const char *vpx_codec_version_str(void) {
+ return VERSION_STRING_NOSP;
}
-const char *vpx_codec_version_extra_str(void)
-{
- return VERSION_EXTRA;
+const char *vpx_codec_version_extra_str(void) {
+ return VERSION_EXTRA;
}
-const char *vpx_codec_iface_name(vpx_codec_iface_t *iface)
-{
- return iface ? iface->name : "<invalid interface>";
+const char *vpx_codec_iface_name(vpx_codec_iface_t *iface) {
+ return iface ? iface->name : "<invalid interface>";
}
-const char *vpx_codec_err_to_string(vpx_codec_err_t err)
-{
- switch (err)
- {
+const char *vpx_codec_err_to_string(vpx_codec_err_t err) {
+ switch (err) {
case VPX_CODEC_OK:
- return "Success";
+ return "Success";
case VPX_CODEC_ERROR:
- return "Unspecified internal error";
+ return "Unspecified internal error";
case VPX_CODEC_MEM_ERROR:
- return "Memory allocation error";
+ return "Memory allocation error";
case VPX_CODEC_ABI_MISMATCH:
- return "ABI version mismatch";
+ return "ABI version mismatch";
case VPX_CODEC_INCAPABLE:
- return "Codec does not implement requested capability";
+ return "Codec does not implement requested capability";
case VPX_CODEC_UNSUP_BITSTREAM:
- return "Bitstream not supported by this decoder";
+ return "Bitstream not supported by this decoder";
case VPX_CODEC_UNSUP_FEATURE:
- return "Bitstream required feature not supported by this decoder";
+ return "Bitstream required feature not supported by this decoder";
case VPX_CODEC_CORRUPT_FRAME:
- return "Corrupt frame detected";
+ return "Corrupt frame detected";
case VPX_CODEC_INVALID_PARAM:
- return "Invalid parameter";
+ return "Invalid parameter";
case VPX_CODEC_LIST_END:
- return "End of iterated list";
- }
+ return "End of iterated list";
+ }
- return "Unrecognized error code";
+ return "Unrecognized error code";
}
-const char *vpx_codec_error(vpx_codec_ctx_t *ctx)
-{
- return (ctx) ? vpx_codec_err_to_string(ctx->err)
- : vpx_codec_err_to_string(VPX_CODEC_INVALID_PARAM);
+const char *vpx_codec_error(vpx_codec_ctx_t *ctx) {
+ return (ctx) ? vpx_codec_err_to_string(ctx->err)
+ : vpx_codec_err_to_string(VPX_CODEC_INVALID_PARAM);
}
-const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx)
-{
- if (ctx && ctx->err)
- return ctx->priv ? ctx->priv->err_detail : ctx->err_detail;
+const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx) {
+ if (ctx && ctx->err)
+ return ctx->priv ? ctx->priv->err_detail : ctx->err_detail;
- return NULL;
+ return NULL;
}
-vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
-{
- vpx_codec_err_t res;
+vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx) {
+ vpx_codec_err_t res;
- if (!ctx)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv)
- res = VPX_CODEC_ERROR;
- else
- {
- if (ctx->priv->alg_priv)
- ctx->iface->destroy(ctx->priv->alg_priv);
+ if (!ctx)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv)
+ res = VPX_CODEC_ERROR;
+ else {
+ if (ctx->priv->alg_priv)
+ ctx->iface->destroy(ctx->priv->alg_priv);
- ctx->iface = NULL;
- ctx->name = NULL;
- ctx->priv = NULL;
- res = VPX_CODEC_OK;
- }
+ ctx->iface = NULL;
+ ctx->name = NULL;
+ ctx->priv = NULL;
+ res = VPX_CODEC_OK;
+ }
- return SAVE_STATUS(ctx, res);
+ return SAVE_STATUS(ctx, res);
}
-vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface)
-{
- return (iface) ? iface->caps : 0;
+vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface) {
+ return (iface) ? iface->caps : 0;
}
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx,
int ctrl_id,
- ...)
-{
- vpx_codec_err_t res;
-
- if (!ctx || !ctrl_id)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv || !ctx->iface->ctrl_maps)
- res = VPX_CODEC_ERROR;
- else
- {
- vpx_codec_ctrl_fn_map_t *entry;
-
- res = VPX_CODEC_ERROR;
-
- for (entry = ctx->iface->ctrl_maps; entry && entry->fn; entry++)
- {
- if (!entry->ctrl_id || entry->ctrl_id == ctrl_id)
- {
- va_list ap;
-
- va_start(ap, ctrl_id);
- res = entry->fn(ctx->priv->alg_priv, ctrl_id, ap);
- va_end(ap);
- break;
- }
- }
+ ...) {
+ vpx_codec_err_t res;
+
+ if (!ctx || !ctrl_id)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv || !ctx->iface->ctrl_maps)
+ res = VPX_CODEC_ERROR;
+ else {
+ vpx_codec_ctrl_fn_map_t *entry;
+
+ res = VPX_CODEC_ERROR;
+
+ for (entry = ctx->iface->ctrl_maps; entry && entry->fn; entry++) {
+ if (!entry->ctrl_id || entry->ctrl_id == ctrl_id) {
+ va_list ap;
+
+ va_start(ap, ctrl_id);
+ res = entry->fn(ctx->priv->alg_priv, ctrl_id, ap);
+ va_end(ap);
+ break;
+ }
}
+ }
- return SAVE_STATUS(ctx, res);
+ return SAVE_STATUS(ctx, res);
}
diff --git a/vpx/src/vpx_decoder.c b/vpx/src/vpx_decoder.c
index 64c7ea5a4..9fa1bf6c2 100644
--- a/vpx/src/vpx_decoder.c
+++ b/vpx/src/vpx_decoder.c
@@ -22,96 +22,88 @@ vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
vpx_codec_iface_t *iface,
vpx_codec_dec_cfg_t *cfg,
vpx_codec_flags_t flags,
- int ver)
-{
- vpx_codec_err_t res;
-
- if (ver != VPX_DECODER_ABI_VERSION)
- res = VPX_CODEC_ABI_MISMATCH;
- else if (!ctx || !iface)
- res = VPX_CODEC_INVALID_PARAM;
- else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
- res = VPX_CODEC_ABI_MISMATCH;
- else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA))
- res = VPX_CODEC_INCAPABLE;
- else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POSTPROC))
- res = VPX_CODEC_INCAPABLE;
- else if ((flags & VPX_CODEC_USE_INPUT_PARTITION) &&
- !(iface->caps & VPX_CODEC_CAP_INPUT_PARTITION))
- res = VPX_CODEC_INCAPABLE;
- else if (!(iface->caps & VPX_CODEC_CAP_DECODER))
- res = VPX_CODEC_INCAPABLE;
- else
- {
- memset(ctx, 0, sizeof(*ctx));
- ctx->iface = iface;
- ctx->name = iface->name;
- ctx->priv = NULL;
- ctx->init_flags = flags;
- ctx->config.dec = cfg;
- res = VPX_CODEC_OK;
-
- if (!(flags & VPX_CODEC_USE_XMA))
- {
- res = ctx->iface->init(ctx);
-
- if (res)
- {
- ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
- vpx_codec_destroy(ctx);
- }
-
- if (ctx->priv)
- ctx->priv->iface = ctx->iface;
- }
+ int ver) {
+ vpx_codec_err_t res;
+
+ if (ver != VPX_DECODER_ABI_VERSION)
+ res = VPX_CODEC_ABI_MISMATCH;
+ else if (!ctx || !iface)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
+ res = VPX_CODEC_ABI_MISMATCH;
+ else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA))
+ res = VPX_CODEC_INCAPABLE;
+ else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POSTPROC))
+ res = VPX_CODEC_INCAPABLE;
+ else if ((flags & VPX_CODEC_USE_INPUT_PARTITION) &&
+ !(iface->caps & VPX_CODEC_CAP_INPUT_PARTITION))
+ res = VPX_CODEC_INCAPABLE;
+ else if (!(iface->caps & VPX_CODEC_CAP_DECODER))
+ res = VPX_CODEC_INCAPABLE;
+ else {
+ memset(ctx, 0, sizeof(*ctx));
+ ctx->iface = iface;
+ ctx->name = iface->name;
+ ctx->priv = NULL;
+ ctx->init_flags = flags;
+ ctx->config.dec = cfg;
+ res = VPX_CODEC_OK;
+
+ if (!(flags & VPX_CODEC_USE_XMA)) {
+ res = ctx->iface->init(ctx);
+
+ if (res) {
+ ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
+ vpx_codec_destroy(ctx);
+ }
+
+ if (ctx->priv)
+ ctx->priv->iface = ctx->iface;
}
+ }
- return SAVE_STATUS(ctx, res);
+ return SAVE_STATUS(ctx, res);
}
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
- const uint8_t *data,
- unsigned int data_sz,
- vpx_codec_stream_info_t *si)
-{
- vpx_codec_err_t res;
-
- if (!iface || !data || !data_sz || !si
- || si->sz < sizeof(vpx_codec_stream_info_t))
- res = VPX_CODEC_INVALID_PARAM;
- else
- {
- /* Set default/unknown values */
- si->w = 0;
- si->h = 0;
-
- res = iface->dec.peek_si(data, data_sz, si);
- }
-
- return res;
+ const uint8_t *data,
+ unsigned int data_sz,
+ vpx_codec_stream_info_t *si) {
+ vpx_codec_err_t res;
+
+ if (!iface || !data || !data_sz || !si
+ || si->sz < sizeof(vpx_codec_stream_info_t))
+ res = VPX_CODEC_INVALID_PARAM;
+ else {
+ /* Set default/unknown values */
+ si->w = 0;
+ si->h = 0;
+
+ res = iface->dec.peek_si(data, data_sz, si);
+ }
+
+ return res;
}
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
- vpx_codec_stream_info_t *si)
-{
- vpx_codec_err_t res;
-
- if (!ctx || !si || si->sz < sizeof(vpx_codec_stream_info_t))
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv)
- res = VPX_CODEC_ERROR;
- else
- {
- /* Set default/unknown values */
- si->w = 0;
- si->h = 0;
-
- res = ctx->iface->dec.get_si(ctx->priv->alg_priv, si);
- }
-
- return SAVE_STATUS(ctx, res);
+ vpx_codec_stream_info_t *si) {
+ vpx_codec_err_t res;
+
+ if (!ctx || !si || si->sz < sizeof(vpx_codec_stream_info_t))
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv)
+ res = VPX_CODEC_ERROR;
+ else {
+ /* Set default/unknown values */
+ si->w = 0;
+ si->h = 0;
+
+ res = ctx->iface->dec.get_si(ctx->priv->alg_priv, si);
+ }
+
+ return SAVE_STATUS(ctx, res);
}
@@ -119,126 +111,115 @@ vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx,
const uint8_t *data,
unsigned int data_sz,
void *user_priv,
- long deadline)
-{
- vpx_codec_err_t res;
-
- /* Sanity checks */
- /* NULL data ptr allowed if data_sz is 0 too */
- if (!ctx || (!data && data_sz))
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv)
- res = VPX_CODEC_ERROR;
- else
- {
- res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz,
- user_priv, deadline);
- }
-
- return SAVE_STATUS(ctx, res);
+ long deadline) {
+ vpx_codec_err_t res;
+
+ /* Sanity checks */
+ /* NULL data ptr allowed if data_sz is 0 too */
+ if (!ctx || (!data && data_sz))
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv)
+ res = VPX_CODEC_ERROR;
+ else {
+ res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz,
+ user_priv, deadline);
+ }
+
+ return SAVE_STATUS(ctx, res);
}
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx,
- vpx_codec_iter_t *iter)
-{
- vpx_image_t *img;
+ vpx_codec_iter_t *iter) {
+ vpx_image_t *img;
- if (!ctx || !iter || !ctx->iface || !ctx->priv)
- img = NULL;
- else
- img = ctx->iface->dec.get_frame(ctx->priv->alg_priv, iter);
+ if (!ctx || !iter || !ctx->iface || !ctx->priv)
+ img = NULL;
+ else
+ img = ctx->iface->dec.get_frame(ctx->priv->alg_priv, iter);
- return img;
+ return img;
}
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
- vpx_codec_put_frame_cb_fn_t cb,
- void *user_priv)
-{
- vpx_codec_err_t res;
-
- if (!ctx || !cb)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv
- || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_FRAME))
- res = VPX_CODEC_ERROR;
- else
- {
- ctx->priv->dec.put_frame_cb.u.put_frame = cb;
- ctx->priv->dec.put_frame_cb.user_priv = user_priv;
- res = VPX_CODEC_OK;
- }
-
- return SAVE_STATUS(ctx, res);
+ vpx_codec_put_frame_cb_fn_t cb,
+ void *user_priv) {
+ vpx_codec_err_t res;
+
+ if (!ctx || !cb)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv
+ || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_FRAME))
+ res = VPX_CODEC_ERROR;
+ else {
+ ctx->priv->dec.put_frame_cb.u.put_frame = cb;
+ ctx->priv->dec.put_frame_cb.user_priv = user_priv;
+ res = VPX_CODEC_OK;
+ }
+
+ return SAVE_STATUS(ctx, res);
}
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
- vpx_codec_put_slice_cb_fn_t cb,
- void *user_priv)
-{
- vpx_codec_err_t res;
-
- if (!ctx || !cb)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv
- || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_FRAME))
- res = VPX_CODEC_ERROR;
- else
- {
- ctx->priv->dec.put_slice_cb.u.put_slice = cb;
- ctx->priv->dec.put_slice_cb.user_priv = user_priv;
- res = VPX_CODEC_OK;
- }
-
- return SAVE_STATUS(ctx, res);
+ vpx_codec_put_slice_cb_fn_t cb,
+ void *user_priv) {
+ vpx_codec_err_t res;
+
+ if (!ctx || !cb)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv
+ || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_FRAME))
+ res = VPX_CODEC_ERROR;
+ else {
+ ctx->priv->dec.put_slice_cb.u.put_slice = cb;
+ ctx->priv->dec.put_slice_cb.user_priv = user_priv;
+ res = VPX_CODEC_OK;
+ }
+
+ return SAVE_STATUS(ctx, res);
}
vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx,
vpx_codec_mmap_t *mmap,
- vpx_codec_iter_t *iter)
-{
- vpx_codec_err_t res = VPX_CODEC_OK;
-
- if (!ctx || !mmap || !iter || !ctx->iface)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA))
- res = VPX_CODEC_ERROR;
- else
- res = ctx->iface->get_mmap(ctx, mmap, iter);
-
- return SAVE_STATUS(ctx, res);
+ vpx_codec_iter_t *iter) {
+ vpx_codec_err_t res = VPX_CODEC_OK;
+
+ if (!ctx || !mmap || !iter || !ctx->iface)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA))
+ res = VPX_CODEC_ERROR;
+ else
+ res = ctx->iface->get_mmap(ctx, mmap, iter);
+
+ return SAVE_STATUS(ctx, res);
}
vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx,
vpx_codec_mmap_t *mmap,
- unsigned int num_maps)
-{
- vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
-
- if (!ctx || !mmap || !ctx->iface)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA))
- res = VPX_CODEC_ERROR;
- else
- {
- unsigned int i;
-
- for (i = 0; i < num_maps; i++, mmap++)
- {
- if (!mmap->base)
- break;
-
- /* Everything look ok, set the mmap in the decoder */
- res = ctx->iface->set_mmap(ctx, mmap);
-
- if (res)
- break;
- }
+ unsigned int num_maps) {
+ vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
+
+ if (!ctx || !mmap || !ctx->iface)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA))
+ res = VPX_CODEC_ERROR;
+ else {
+ unsigned int i;
+
+ for (i = 0; i < num_maps; i++, mmap++) {
+ if (!mmap->base)
+ break;
+
+ /* Everything look ok, set the mmap in the decoder */
+ res = ctx->iface->set_mmap(ctx, mmap);
+
+ if (res)
+ break;
}
+ }
- return SAVE_STATUS(ctx, res);
+ return SAVE_STATUS(ctx, res);
}
diff --git a/vpx/src/vpx_decoder_compat.c b/vpx/src/vpx_decoder_compat.c
index 4fe00ce4f..59bd261a6 100644
--- a/vpx/src/vpx_decoder_compat.c
+++ b/vpx/src/vpx_decoder_compat.c
@@ -20,74 +20,64 @@
#define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var)
-const char *vpx_dec_iface_name(vpx_dec_iface_t *iface)
-{
- return vpx_codec_iface_name((vpx_codec_iface_t *)iface);
+const char *vpx_dec_iface_name(vpx_dec_iface_t *iface) {
+ return vpx_codec_iface_name((vpx_codec_iface_t *)iface);
}
-const char *vpx_dec_err_to_string(vpx_dec_err_t err)
-{
- return vpx_codec_err_to_string(err);
+const char *vpx_dec_err_to_string(vpx_dec_err_t err) {
+ return vpx_codec_err_to_string(err);
}
-const char *vpx_dec_error(vpx_dec_ctx_t *ctx)
-{
- return vpx_codec_error((vpx_codec_ctx_t *)ctx);
+const char *vpx_dec_error(vpx_dec_ctx_t *ctx) {
+ return vpx_codec_error((vpx_codec_ctx_t *)ctx);
}
-const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx)
-{
- return vpx_codec_error_detail((vpx_codec_ctx_t *)ctx);
+const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx) {
+ return vpx_codec_error_detail((vpx_codec_ctx_t *)ctx);
}
vpx_dec_err_t vpx_dec_init_ver(vpx_dec_ctx_t *ctx,
vpx_dec_iface_t *iface,
- int ver)
-{
- return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx,
- (vpx_codec_iface_t *)iface,
- NULL,
- 0,
- ver);
+ int ver) {
+ return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx,
+ (vpx_codec_iface_t *)iface,
+ NULL,
+ 0,
+ ver);
}
-vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx)
-{
- return vpx_codec_destroy((vpx_codec_ctx_t *)ctx);
+vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx) {
+ return vpx_codec_destroy((vpx_codec_ctx_t *)ctx);
}
-vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface)
-{
- return vpx_codec_get_caps((vpx_codec_iface_t *)iface);
+vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface) {
+ return vpx_codec_get_caps((vpx_codec_iface_t *)iface);
}
vpx_dec_err_t vpx_dec_peek_stream_info(vpx_dec_iface_t *iface,
const uint8_t *data,
unsigned int data_sz,
- vpx_dec_stream_info_t *si)
-{
- return vpx_codec_peek_stream_info((vpx_codec_iface_t *)iface, data, data_sz,
- (vpx_codec_stream_info_t *)si);
+ vpx_dec_stream_info_t *si) {
+ return vpx_codec_peek_stream_info((vpx_codec_iface_t *)iface, data, data_sz,
+ (vpx_codec_stream_info_t *)si);
}
vpx_dec_err_t vpx_dec_get_stream_info(vpx_dec_ctx_t *ctx,
- vpx_dec_stream_info_t *si)
-{
- return vpx_codec_get_stream_info((vpx_codec_ctx_t *)ctx,
- (vpx_codec_stream_info_t *)si);
+ vpx_dec_stream_info_t *si) {
+ return vpx_codec_get_stream_info((vpx_codec_ctx_t *)ctx,
+ (vpx_codec_stream_info_t *)si);
}
vpx_dec_err_t vpx_dec_control(vpx_dec_ctx_t *ctx,
int ctrl_id,
- void *data)
-{
- return vpx_codec_control_((vpx_codec_ctx_t *)ctx, ctrl_id, data);
+ void *data) {
+ return vpx_codec_control_((vpx_codec_ctx_t *)ctx, ctrl_id, data);
}
@@ -95,107 +85,96 @@ vpx_dec_err_t vpx_dec_decode(vpx_dec_ctx_t *ctx,
uint8_t *data,
unsigned int data_sz,
void *user_priv,
- int rel_pts)
-{
- (void)rel_pts;
- return vpx_codec_decode((vpx_codec_ctx_t *)ctx, data, data_sz, user_priv,
- 0);
+ int rel_pts) {
+ (void)rel_pts;
+ return vpx_codec_decode((vpx_codec_ctx_t *)ctx, data, data_sz, user_priv,
+ 0);
}
vpx_image_t *vpx_dec_get_frame(vpx_dec_ctx_t *ctx,
- vpx_dec_iter_t *iter)
-{
- return vpx_codec_get_frame((vpx_codec_ctx_t *)ctx, iter);
+ vpx_dec_iter_t *iter) {
+ return vpx_codec_get_frame((vpx_codec_ctx_t *)ctx, iter);
}
vpx_dec_err_t vpx_dec_register_put_frame_cb(vpx_dec_ctx_t *ctx,
- vpx_dec_put_frame_cb_fn_t cb,
- void *user_priv)
-{
- return vpx_codec_register_put_frame_cb((vpx_codec_ctx_t *)ctx, cb,
- user_priv);
+ vpx_dec_put_frame_cb_fn_t cb,
+ void *user_priv) {
+ return vpx_codec_register_put_frame_cb((vpx_codec_ctx_t *)ctx, cb,
+ user_priv);
}
vpx_dec_err_t vpx_dec_register_put_slice_cb(vpx_dec_ctx_t *ctx,
- vpx_dec_put_slice_cb_fn_t cb,
- void *user_priv)
-{
- return vpx_codec_register_put_slice_cb((vpx_codec_ctx_t *)ctx, cb,
- user_priv);
+ vpx_dec_put_slice_cb_fn_t cb,
+ void *user_priv) {
+ return vpx_codec_register_put_slice_cb((vpx_codec_ctx_t *)ctx, cb,
+ user_priv);
}
vpx_dec_err_t vpx_dec_xma_init_ver(vpx_dec_ctx_t *ctx,
vpx_dec_iface_t *iface,
- int ver)
-{
- return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx,
- (vpx_codec_iface_t *)iface,
- NULL,
- VPX_CODEC_USE_XMA,
- ver);
+ int ver) {
+ return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx,
+ (vpx_codec_iface_t *)iface,
+ NULL,
+ VPX_CODEC_USE_XMA,
+ ver);
}
vpx_dec_err_t vpx_dec_get_mem_map(vpx_dec_ctx_t *ctx_,
vpx_dec_mmap_t *mmap,
const vpx_dec_stream_info_t *si,
- vpx_dec_iter_t *iter)
-{
- vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_;
- vpx_dec_err_t res = VPX_DEC_OK;
-
- if (!ctx || !mmap || !si || !iter || !ctx->iface)
- res = VPX_DEC_INVALID_PARAM;
- else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA))
- res = VPX_DEC_ERROR;
- else
- {
- if (!ctx->config.dec)
- {
- ctx->config.dec = malloc(sizeof(vpx_codec_dec_cfg_t));
- ctx->config.dec->w = si->w;
- ctx->config.dec->h = si->h;
- }
-
- res = ctx->iface->get_mmap(ctx, mmap, iter);
+ vpx_dec_iter_t *iter) {
+ vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_;
+ vpx_dec_err_t res = VPX_DEC_OK;
+
+ if (!ctx || !mmap || !si || !iter || !ctx->iface)
+ res = VPX_DEC_INVALID_PARAM;
+ else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA))
+ res = VPX_DEC_ERROR;
+ else {
+ if (!ctx->config.dec) {
+ ctx->config.dec = malloc(sizeof(vpx_codec_dec_cfg_t));
+ ctx->config.dec->w = si->w;
+ ctx->config.dec->h = si->h;
}
- return SAVE_STATUS(ctx, res);
+ res = ctx->iface->get_mmap(ctx, mmap, iter);
+ }
+
+ return SAVE_STATUS(ctx, res);
}
vpx_dec_err_t vpx_dec_set_mem_map(vpx_dec_ctx_t *ctx_,
vpx_dec_mmap_t *mmap,
- unsigned int num_maps)
-{
- vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_;
- vpx_dec_err_t res = VPX_DEC_MEM_ERROR;
-
- if (!ctx || !mmap || !ctx->iface)
- res = VPX_DEC_INVALID_PARAM;
- else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA))
- res = VPX_DEC_ERROR;
- else
- {
- void *save = (ctx->priv) ? NULL : ctx->config.dec;
- unsigned int i;
-
- for (i = 0; i < num_maps; i++, mmap++)
- {
- if (!mmap->base)
- break;
-
- /* Everything look ok, set the mmap in the decoder */
- res = ctx->iface->set_mmap(ctx, mmap);
-
- if (res)
- break;
- }
-
- if (save) free(save);
+ unsigned int num_maps) {
+ vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_;
+ vpx_dec_err_t res = VPX_DEC_MEM_ERROR;
+
+ if (!ctx || !mmap || !ctx->iface)
+ res = VPX_DEC_INVALID_PARAM;
+ else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA))
+ res = VPX_DEC_ERROR;
+ else {
+ void *save = (ctx->priv) ? NULL : ctx->config.dec;
+ unsigned int i;
+
+ for (i = 0; i < num_maps; i++, mmap++) {
+ if (!mmap->base)
+ break;
+
+ /* Everything look ok, set the mmap in the decoder */
+ res = ctx->iface->set_mmap(ctx, mmap);
+
+ if (res)
+ break;
}
- return SAVE_STATUS(ctx, res);
+ if (save) free(save);
+ }
+
+ return SAVE_STATUS(ctx, res);
}
diff --git a/vpx/src/vpx_encoder.c b/vpx/src/vpx_encoder.c
index 5e86835ea..1d3b646d3 100644
--- a/vpx/src/vpx_encoder.c
+++ b/vpx/src/vpx_encoder.c
@@ -24,78 +24,71 @@ vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
vpx_codec_iface_t *iface,
vpx_codec_enc_cfg_t *cfg,
vpx_codec_flags_t flags,
- int ver)
-{
- vpx_codec_err_t res;
-
- if (ver != VPX_ENCODER_ABI_VERSION)
- res = VPX_CODEC_ABI_MISMATCH;
- else if (!ctx || !iface || !cfg)
- res = VPX_CODEC_INVALID_PARAM;
- else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
- res = VPX_CODEC_ABI_MISMATCH;
- else if (!(iface->caps & VPX_CODEC_CAP_ENCODER))
- res = VPX_CODEC_INCAPABLE;
- else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA))
- res = VPX_CODEC_INCAPABLE;
- else if ((flags & VPX_CODEC_USE_PSNR)
- && !(iface->caps & VPX_CODEC_CAP_PSNR))
- res = VPX_CODEC_INCAPABLE;
- else if ((flags & VPX_CODEC_USE_OUTPUT_PARTITION)
- && !(iface->caps & VPX_CODEC_CAP_OUTPUT_PARTITION))
- res = VPX_CODEC_INCAPABLE;
- else
- {
- ctx->iface = iface;
- ctx->name = iface->name;
- ctx->priv = NULL;
- ctx->init_flags = flags;
- ctx->config.enc = cfg;
- res = ctx->iface->init(ctx);
-
- if (res)
- {
- ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
- vpx_codec_destroy(ctx);
- }
-
- if (ctx->priv)
- ctx->priv->iface = ctx->iface;
+ int ver) {
+ vpx_codec_err_t res;
+
+ if (ver != VPX_ENCODER_ABI_VERSION)
+ res = VPX_CODEC_ABI_MISMATCH;
+ else if (!ctx || !iface || !cfg)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
+ res = VPX_CODEC_ABI_MISMATCH;
+ else if (!(iface->caps & VPX_CODEC_CAP_ENCODER))
+ res = VPX_CODEC_INCAPABLE;
+ else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA))
+ res = VPX_CODEC_INCAPABLE;
+ else if ((flags & VPX_CODEC_USE_PSNR)
+ && !(iface->caps & VPX_CODEC_CAP_PSNR))
+ res = VPX_CODEC_INCAPABLE;
+ else if ((flags & VPX_CODEC_USE_OUTPUT_PARTITION)
+ && !(iface->caps & VPX_CODEC_CAP_OUTPUT_PARTITION))
+ res = VPX_CODEC_INCAPABLE;
+ else {
+ ctx->iface = iface;
+ ctx->name = iface->name;
+ ctx->priv = NULL;
+ ctx->init_flags = flags;
+ ctx->config.enc = cfg;
+ res = ctx->iface->init(ctx);
+
+ if (res) {
+ ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
+ vpx_codec_destroy(ctx);
}
- return SAVE_STATUS(ctx, res);
+ if (ctx->priv)
+ ctx->priv->iface = ctx->iface;
+ }
+
+ return SAVE_STATUS(ctx, res);
}
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
- vpx_codec_enc_cfg_t *cfg,
- unsigned int usage)
-{
- vpx_codec_err_t res;
- vpx_codec_enc_cfg_map_t *map;
-
- if (!iface || !cfg || usage > INT_MAX)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!(iface->caps & VPX_CODEC_CAP_ENCODER))
- res = VPX_CODEC_INCAPABLE;
- else
- {
- res = VPX_CODEC_INVALID_PARAM;
-
- for (map = iface->enc.cfg_maps; map->usage >= 0; map++)
- {
- if (map->usage == (int)usage)
- {
- *cfg = map->cfg;
- cfg->g_usage = usage;
- res = VPX_CODEC_OK;
- break;
- }
- }
+ vpx_codec_enc_cfg_t *cfg,
+ unsigned int usage) {
+ vpx_codec_err_t res;
+ vpx_codec_enc_cfg_map_t *map;
+
+ if (!iface || !cfg || usage > INT_MAX)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!(iface->caps & VPX_CODEC_CAP_ENCODER))
+ res = VPX_CODEC_INCAPABLE;
+ else {
+ res = VPX_CODEC_INVALID_PARAM;
+
+ for (map = iface->enc.cfg_maps; map->usage >= 0; map++) {
+ if (map->usage == (int)usage) {
+ *cfg = map->cfg;
+ cfg->g_usage = usage;
+ res = VPX_CODEC_OK;
+ break;
+ }
}
+ }
- return res;
+ return res;
}
@@ -105,9 +98,9 @@ vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
*/
#include "vpx_ports/x86.h"
#define FLOATING_POINT_INIT() do {\
- unsigned short x87_orig_mode = x87_set_double_precision();
+ unsigned short x87_orig_mode = x87_set_double_precision();
#define FLOATING_POINT_RESTORE() \
- x87_set_control_word(x87_orig_mode); }while(0)
+ x87_set_control_word(x87_orig_mode); }while(0)
#else
@@ -121,196 +114,176 @@ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
vpx_codec_pts_t pts,
unsigned long duration,
vpx_enc_frame_flags_t flags,
- unsigned long deadline)
-{
- vpx_codec_err_t res;
-
- if (!ctx || (img && !duration))
- res = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv)
- res = VPX_CODEC_ERROR;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
- res = VPX_CODEC_INCAPABLE;
- else
- {
- /* Execute in a normalized floating point environment, if the platform
- * requires it.
- */
- FLOATING_POINT_INIT();
- res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts,
- duration, flags, deadline);
- FLOATING_POINT_RESTORE();
- }
-
- return SAVE_STATUS(ctx, res);
+ unsigned long deadline) {
+ vpx_codec_err_t res;
+
+ if (!ctx || (img && !duration))
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv)
+ res = VPX_CODEC_ERROR;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
+ res = VPX_CODEC_INCAPABLE;
+ else {
+ /* Execute in a normalized floating point environment, if the platform
+ * requires it.
+ */
+ FLOATING_POINT_INIT();
+ res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts,
+ duration, flags, deadline);
+ FLOATING_POINT_RESTORE();
+ }
+
+ return SAVE_STATUS(ctx, res);
}
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
- vpx_codec_iter_t *iter)
-{
- const vpx_codec_cx_pkt_t *pkt = NULL;
-
- if (ctx)
- {
- if (!iter)
- ctx->err = VPX_CODEC_INVALID_PARAM;
- else if (!ctx->iface || !ctx->priv)
- ctx->err = VPX_CODEC_ERROR;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
- ctx->err = VPX_CODEC_INCAPABLE;
- else
- pkt = ctx->iface->enc.get_cx_data(ctx->priv->alg_priv, iter);
+ vpx_codec_iter_t *iter) {
+ const vpx_codec_cx_pkt_t *pkt = NULL;
+
+ if (ctx) {
+ if (!iter)
+ ctx->err = VPX_CODEC_INVALID_PARAM;
+ else if (!ctx->iface || !ctx->priv)
+ ctx->err = VPX_CODEC_ERROR;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
+ ctx->err = VPX_CODEC_INCAPABLE;
+ else
+ pkt = ctx->iface->enc.get_cx_data(ctx->priv->alg_priv, iter);
+ }
+
+ if (pkt && pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
+ /* If the application has specified a destination area for the
+ * compressed data, and the codec has not placed the data there,
+ * and it fits, copy it.
+ */
+ char *dst_buf = ctx->priv->enc.cx_data_dst_buf.buf;
+
+ if (dst_buf
+ && pkt->data.raw.buf != dst_buf
+ && pkt->data.raw.sz
+ + ctx->priv->enc.cx_data_pad_before
+ + ctx->priv->enc.cx_data_pad_after
+ <= ctx->priv->enc.cx_data_dst_buf.sz) {
+ vpx_codec_cx_pkt_t *modified_pkt = &ctx->priv->enc.cx_data_pkt;
+
+ memcpy(dst_buf + ctx->priv->enc.cx_data_pad_before,
+ pkt->data.raw.buf, pkt->data.raw.sz);
+ *modified_pkt = *pkt;
+ modified_pkt->data.raw.buf = dst_buf;
+ modified_pkt->data.raw.sz += ctx->priv->enc.cx_data_pad_before
+ + ctx->priv->enc.cx_data_pad_after;
+ pkt = modified_pkt;
}
- if (pkt && pkt->kind == VPX_CODEC_CX_FRAME_PKT)
- {
- /* If the application has specified a destination area for the
- * compressed data, and the codec has not placed the data there,
- * and it fits, copy it.
- */
- char *dst_buf = ctx->priv->enc.cx_data_dst_buf.buf;
-
- if (dst_buf
- && pkt->data.raw.buf != dst_buf
- && pkt->data.raw.sz
- + ctx->priv->enc.cx_data_pad_before
- + ctx->priv->enc.cx_data_pad_after
- <= ctx->priv->enc.cx_data_dst_buf.sz)
- {
- vpx_codec_cx_pkt_t *modified_pkt = &ctx->priv->enc.cx_data_pkt;
-
- memcpy(dst_buf + ctx->priv->enc.cx_data_pad_before,
- pkt->data.raw.buf, pkt->data.raw.sz);
- *modified_pkt = *pkt;
- modified_pkt->data.raw.buf = dst_buf;
- modified_pkt->data.raw.sz += ctx->priv->enc.cx_data_pad_before
- + ctx->priv->enc.cx_data_pad_after;
- pkt = modified_pkt;
- }
-
- if (dst_buf == pkt->data.raw.buf)
- {
- ctx->priv->enc.cx_data_dst_buf.buf = dst_buf + pkt->data.raw.sz;
- ctx->priv->enc.cx_data_dst_buf.sz -= pkt->data.raw.sz;
- }
+ if (dst_buf == pkt->data.raw.buf) {
+ ctx->priv->enc.cx_data_dst_buf.buf = dst_buf + pkt->data.raw.sz;
+ ctx->priv->enc.cx_data_dst_buf.sz -= pkt->data.raw.sz;
}
+ }
- return pkt;
+ return pkt;
}
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
- const vpx_fixed_buf_t *buf,
- unsigned int pad_before,
- unsigned int pad_after)
-{
- if (!ctx || !ctx->priv)
- return VPX_CODEC_INVALID_PARAM;
-
- if (buf)
- {
- ctx->priv->enc.cx_data_dst_buf = *buf;
- ctx->priv->enc.cx_data_pad_before = pad_before;
- ctx->priv->enc.cx_data_pad_after = pad_after;
- }
- else
- {
- ctx->priv->enc.cx_data_dst_buf.buf = NULL;
- ctx->priv->enc.cx_data_dst_buf.sz = 0;
- ctx->priv->enc.cx_data_pad_before = 0;
- ctx->priv->enc.cx_data_pad_after = 0;
- }
-
- return VPX_CODEC_OK;
+ const vpx_fixed_buf_t *buf,
+ unsigned int pad_before,
+ unsigned int pad_after) {
+ if (!ctx || !ctx->priv)
+ return VPX_CODEC_INVALID_PARAM;
+
+ if (buf) {
+ ctx->priv->enc.cx_data_dst_buf = *buf;
+ ctx->priv->enc.cx_data_pad_before = pad_before;
+ ctx->priv->enc.cx_data_pad_after = pad_after;
+ } else {
+ ctx->priv->enc.cx_data_dst_buf.buf = NULL;
+ ctx->priv->enc.cx_data_dst_buf.sz = 0;
+ ctx->priv->enc.cx_data_pad_before = 0;
+ ctx->priv->enc.cx_data_pad_after = 0;
+ }
+
+ return VPX_CODEC_OK;
}
-const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx)
-{
- vpx_image_t *img = NULL;
-
- if (ctx)
- {
- if (!ctx->iface || !ctx->priv)
- ctx->err = VPX_CODEC_ERROR;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
- ctx->err = VPX_CODEC_INCAPABLE;
- else if (!ctx->iface->enc.get_preview)
- ctx->err = VPX_CODEC_INCAPABLE;
- else
- img = ctx->iface->enc.get_preview(ctx->priv->alg_priv);
- }
+const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx) {
+ vpx_image_t *img = NULL;
+
+ if (ctx) {
+ if (!ctx->iface || !ctx->priv)
+ ctx->err = VPX_CODEC_ERROR;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
+ ctx->err = VPX_CODEC_INCAPABLE;
+ else if (!ctx->iface->enc.get_preview)
+ ctx->err = VPX_CODEC_INCAPABLE;
+ else
+ img = ctx->iface->enc.get_preview(ctx->priv->alg_priv);
+ }
- return img;
+ return img;
}
-vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx)
-{
- vpx_fixed_buf_t *buf = NULL;
-
- if (ctx)
- {
- if (!ctx->iface || !ctx->priv)
- ctx->err = VPX_CODEC_ERROR;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
- ctx->err = VPX_CODEC_INCAPABLE;
- else if (!ctx->iface->enc.get_glob_hdrs)
- ctx->err = VPX_CODEC_INCAPABLE;
- else
- buf = ctx->iface->enc.get_glob_hdrs(ctx->priv->alg_priv);
- }
+vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx) {
+ vpx_fixed_buf_t *buf = NULL;
- return buf;
+ if (ctx) {
+ if (!ctx->iface || !ctx->priv)
+ ctx->err = VPX_CODEC_ERROR;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
+ ctx->err = VPX_CODEC_INCAPABLE;
+ else if (!ctx->iface->enc.get_glob_hdrs)
+ ctx->err = VPX_CODEC_INCAPABLE;
+ else
+ buf = ctx->iface->enc.get_glob_hdrs(ctx->priv->alg_priv);
+ }
+
+ return buf;
}
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
- const vpx_codec_enc_cfg_t *cfg)
-{
- vpx_codec_err_t res;
+ const vpx_codec_enc_cfg_t *cfg) {
+ vpx_codec_err_t res;
- if (!ctx || !ctx->iface || !ctx->priv || !cfg)
- res = VPX_CODEC_INVALID_PARAM;
- else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
- res = VPX_CODEC_INCAPABLE;
- else
- res = ctx->iface->enc.cfg_set(ctx->priv->alg_priv, cfg);
+ if (!ctx || !ctx->iface || !ctx->priv || !cfg)
+ res = VPX_CODEC_INVALID_PARAM;
+ else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
+ res = VPX_CODEC_INCAPABLE;
+ else
+ res = ctx->iface->enc.cfg_set(ctx->priv->alg_priv, cfg);
- return SAVE_STATUS(ctx, res);
+ return SAVE_STATUS(ctx, res);
}
int vpx_codec_pkt_list_add(struct vpx_codec_pkt_list *list,
- const struct vpx_codec_cx_pkt *pkt)
-{
- if (list->cnt < list->max)
- {
- list->pkts[list->cnt++] = *pkt;
- return 0;
- }
+ const struct vpx_codec_cx_pkt *pkt) {
+ if (list->cnt < list->max) {
+ list->pkts[list->cnt++] = *pkt;
+ return 0;
+ }
- return 1;
+ return 1;
}
const vpx_codec_cx_pkt_t *vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list,
- vpx_codec_iter_t *iter)
-{
- const vpx_codec_cx_pkt_t *pkt;
+ vpx_codec_iter_t *iter) {
+ const vpx_codec_cx_pkt_t *pkt;
- if (!(*iter))
- {
- *iter = list->pkts;
- }
+ if (!(*iter)) {
+ *iter = list->pkts;
+ }
- pkt = (const void *) * iter;
+ pkt = (const void *) * iter;
- if ((size_t)(pkt - list->pkts) < list->cnt)
- *iter = pkt + 1;
- else
- pkt = NULL;
+ if ((size_t)(pkt - list->pkts) < list->cnt)
+ *iter = pkt + 1;
+ else
+ pkt = NULL;
- return pkt;
+ return pkt;
}
diff --git a/vpx/src/vpx_image.c b/vpx/src/vpx_image.c
index 7a4e27062..4903789f2 100644
--- a/vpx/src/vpx_image.c
+++ b/vpx/src/vpx_image.c
@@ -18,33 +18,31 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
unsigned int d_w,
unsigned int d_h,
unsigned int stride_align,
- unsigned char *img_data)
-{
+ unsigned char *img_data) {
- unsigned int h, w, s, xcs, ycs, bps;
- int align;
+ unsigned int h, w, s, xcs, ycs, bps;
+ int align;
- /* Treat align==0 like align==1 */
- if (!stride_align)
- stride_align = 1;
+ /* Treat align==0 like align==1 */
+ if (!stride_align)
+ stride_align = 1;
- /* Validate alignment (must be power of 2) */
- if (stride_align & (stride_align - 1))
- goto fail;
+ /* Validate alignment (must be power of 2) */
+ if (stride_align & (stride_align - 1))
+ goto fail;
- /* Get sample size for this format */
- switch (fmt)
- {
+ /* Get sample size for this format */
+ switch (fmt) {
case VPX_IMG_FMT_RGB32:
case VPX_IMG_FMT_RGB32_LE:
case VPX_IMG_FMT_ARGB:
case VPX_IMG_FMT_ARGB_LE:
- bps = 32;
- break;
+ bps = 32;
+ break;
case VPX_IMG_FMT_RGB24:
case VPX_IMG_FMT_BGR24:
- bps = 24;
- break;
+ bps = 24;
+ break;
case VPX_IMG_FMT_RGB565:
case VPX_IMG_FMT_RGB565_LE:
case VPX_IMG_FMT_RGB555:
@@ -52,107 +50,100 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
case VPX_IMG_FMT_UYVY:
case VPX_IMG_FMT_YUY2:
case VPX_IMG_FMT_YVYU:
- bps = 16;
- break;
+ bps = 16;
+ break;
case VPX_IMG_FMT_I420:
case VPX_IMG_FMT_YV12:
case VPX_IMG_FMT_VPXI420:
case VPX_IMG_FMT_VPXYV12:
- bps = 12;
- break;
+ bps = 12;
+ break;
default:
- bps = 16;
- break;
- }
+ bps = 16;
+ break;
+ }
- /* Get chroma shift values for this format */
- switch (fmt)
- {
+ /* Get chroma shift values for this format */
+ switch (fmt) {
case VPX_IMG_FMT_I420:
case VPX_IMG_FMT_YV12:
case VPX_IMG_FMT_VPXI420:
case VPX_IMG_FMT_VPXYV12:
- xcs = 1;
- break;
+ xcs = 1;
+ break;
default:
- xcs = 0;
- break;
- }
+ xcs = 0;
+ break;
+ }
- switch (fmt)
- {
+ switch (fmt) {
case VPX_IMG_FMT_I420:
case VPX_IMG_FMT_YV12:
case VPX_IMG_FMT_VPXI420:
case VPX_IMG_FMT_VPXYV12:
- ycs = 1;
- break;
+ ycs = 1;
+ break;
default:
- ycs = 0;
- break;
- }
+ ycs = 0;
+ break;
+ }
+
+ /* Calculate storage sizes given the chroma subsampling */
+ align = (1 << xcs) - 1;
+ w = (d_w + align) & ~align;
+ align = (1 << ycs) - 1;
+ h = (d_h + align) & ~align;
+ s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8;
+ s = (s + stride_align - 1) & ~(stride_align - 1);
+
+ /* Allocate the new image */
+ if (!img) {
+ img = (vpx_image_t *)calloc(1, sizeof(vpx_image_t));
- /* Calculate storage sizes given the chroma subsampling */
- align = (1 << xcs) - 1;
- w = (d_w + align) & ~align;
- align = (1 << ycs) - 1;
- h = (d_h + align) & ~align;
- s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8;
- s = (s + stride_align - 1) & ~(stride_align - 1);
-
- /* Allocate the new image */
if (!img)
- {
- img = (vpx_image_t *)calloc(1, sizeof(vpx_image_t));
-
- if (!img)
- goto fail;
+ goto fail;
- img->self_allocd = 1;
- }
- else
- {
- memset(img, 0, sizeof(vpx_image_t));
- }
+ img->self_allocd = 1;
+ } else {
+ memset(img, 0, sizeof(vpx_image_t));
+ }
- img->img_data = img_data;
+ img->img_data = img_data;
- if (!img_data)
- {
- img->img_data = malloc((fmt & VPX_IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s);
- img->img_data_owner = 1;
- }
+ if (!img_data) {
+ img->img_data = malloc((fmt & VPX_IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s);
+ img->img_data_owner = 1;
+ }
- if (!img->img_data)
- goto fail;
+ if (!img->img_data)
+ goto fail;
- img->fmt = fmt;
- img->w = w;
- img->h = h;
- img->x_chroma_shift = xcs;
- img->y_chroma_shift = ycs;
- img->bps = bps;
+ img->fmt = fmt;
+ img->w = w;
+ img->h = h;
+ img->x_chroma_shift = xcs;
+ img->y_chroma_shift = ycs;
+ img->bps = bps;
- /* Calculate strides */
- img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = s;
- img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = s >> xcs;
+ /* Calculate strides */
+ img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = s;
+ img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = s >> xcs;
- /* Default viewport to entire image */
- if (!vpx_img_set_rect(img, 0, 0, d_w, d_h))
- return img;
+ /* Default viewport to entire image */
+ if (!vpx_img_set_rect(img, 0, 0, d_w, d_h))
+ return img;
fail:
- vpx_img_free(img);
- return NULL;
+ vpx_img_free(img);
+ return NULL;
}
vpx_image_t *vpx_img_alloc(vpx_image_t *img,
vpx_img_fmt_t fmt,
unsigned int d_w,
unsigned int d_h,
- unsigned int stride_align)
-{
- return img_alloc_helper(img, fmt, d_w, d_h, stride_align, NULL);
+ unsigned int stride_align) {
+ return img_alloc_helper(img, fmt, d_w, d_h, stride_align, NULL);
}
vpx_image_t *vpx_img_wrap(vpx_image_t *img,
@@ -160,103 +151,90 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img,
unsigned int d_w,
unsigned int d_h,
unsigned int stride_align,
- unsigned char *img_data)
-{
- return img_alloc_helper(img, fmt, d_w, d_h, stride_align, img_data);
+ unsigned char *img_data) {
+ return img_alloc_helper(img, fmt, d_w, d_h, stride_align, img_data);
}
int vpx_img_set_rect(vpx_image_t *img,
unsigned int x,
unsigned int y,
unsigned int w,
- unsigned int h)
-{
- unsigned char *data;
-
- if (x + w <= img->w && y + h <= img->h)
- {
- img->d_w = w;
- img->d_h = h;
-
- /* Calculate plane pointers */
- if (!(img->fmt & VPX_IMG_FMT_PLANAR))
- {
- img->planes[VPX_PLANE_PACKED] =
- img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED];
- }
- else
- {
- data = img->img_data;
-
- if (img->fmt & VPX_IMG_FMT_HAS_ALPHA)
- {
- img->planes[VPX_PLANE_ALPHA] =
- data + x + y * img->stride[VPX_PLANE_ALPHA];
- data += img->h * img->stride[VPX_PLANE_ALPHA];
- }
-
- img->planes[VPX_PLANE_Y] = data + x + y * img->stride[VPX_PLANE_Y];
- data += img->h * img->stride[VPX_PLANE_Y];
-
- if (!(img->fmt & VPX_IMG_FMT_UV_FLIP))
- {
- img->planes[VPX_PLANE_U] = data
- + (x >> img->x_chroma_shift)
- + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
- data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
- img->planes[VPX_PLANE_V] = data
- + (x >> img->x_chroma_shift)
- + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
- }
- else
- {
- img->planes[VPX_PLANE_V] = data
- + (x >> img->x_chroma_shift)
- + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
- data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
- img->planes[VPX_PLANE_U] = data
- + (x >> img->x_chroma_shift)
- + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
- }
- }
-
- return 0;
+ unsigned int h) {
+ unsigned char *data;
+
+ if (x + w <= img->w && y + h <= img->h) {
+ img->d_w = w;
+ img->d_h = h;
+
+ /* Calculate plane pointers */
+ if (!(img->fmt & VPX_IMG_FMT_PLANAR)) {
+ img->planes[VPX_PLANE_PACKED] =
+ img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED];
+ } else {
+ data = img->img_data;
+
+ if (img->fmt & VPX_IMG_FMT_HAS_ALPHA) {
+ img->planes[VPX_PLANE_ALPHA] =
+ data + x + y * img->stride[VPX_PLANE_ALPHA];
+ data += img->h * img->stride[VPX_PLANE_ALPHA];
+ }
+
+ img->planes[VPX_PLANE_Y] = data + x + y * img->stride[VPX_PLANE_Y];
+ data += img->h * img->stride[VPX_PLANE_Y];
+
+ if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) {
+ img->planes[VPX_PLANE_U] = data
+ + (x >> img->x_chroma_shift)
+ + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
+ data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
+ img->planes[VPX_PLANE_V] = data
+ + (x >> img->x_chroma_shift)
+ + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
+ } else {
+ img->planes[VPX_PLANE_V] = data
+ + (x >> img->x_chroma_shift)
+ + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
+ data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
+ img->planes[VPX_PLANE_U] = data
+ + (x >> img->x_chroma_shift)
+ + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
+ }
}
- return -1;
+ return 0;
+ }
+
+ return -1;
}
-void vpx_img_flip(vpx_image_t *img)
-{
- /* Note: In the calculation pointer adjustment calculation, we want the
- * rhs to be promoted to a signed type. Section 6.3.1.8 of the ISO C99
- * standard indicates that if the adjustment parameter is unsigned, the
- * stride parameter will be promoted to unsigned, causing errors when
- * the lhs is a larger type than the rhs.
- */
- img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y];
- img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y];
-
- img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
- * img->stride[VPX_PLANE_U];
- img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U];
-
- img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
- * img->stride[VPX_PLANE_V];
- img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V];
-
- img->planes[VPX_PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA];
- img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA];
+void vpx_img_flip(vpx_image_t *img) {
+ /* Note: In the calculation pointer adjustment calculation, we want the
+ * rhs to be promoted to a signed type. Section 6.3.1.8 of the ISO C99
+ * standard indicates that if the adjustment parameter is unsigned, the
+ * stride parameter will be promoted to unsigned, causing errors when
+ * the lhs is a larger type than the rhs.
+ */
+ img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y];
+ img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y];
+
+ img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
+ * img->stride[VPX_PLANE_U];
+ img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U];
+
+ img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
+ * img->stride[VPX_PLANE_V];
+ img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V];
+
+ img->planes[VPX_PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA];
+ img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA];
}
-void vpx_img_free(vpx_image_t *img)
-{
- if (img)
- {
- if (img->img_data && img->img_data_owner)
- free(img->img_data);
+void vpx_img_free(vpx_image_t *img) {
+ if (img) {
+ if (img->img_data && img->img_data_owner)
+ free(img->img_data);
- if (img->self_allocd)
- free(img);
- }
+ if (img->self_allocd)
+ free(img);
+ }
}
diff --git a/vpx/vp8.h b/vpx/vp8.h
index 983cc4ad4..0082ed8fc 100644
--- a/vpx/vp8.h
+++ b/vpx/vp8.h
@@ -36,33 +36,31 @@
*
* The set of macros define the control functions of VP8 interface
*/
-enum vp8_com_control_id
-{
- VP8_SET_REFERENCE = 1, /**< pass in an external frame into decoder to be used as reference frame */
- VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
- VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
- VP8_SET_DBG_COLOR_REF_FRAME = 4, /**< set the reference frames to color for each macroblock */
- VP8_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
- VP8_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */
- VP8_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */
- VP8_COMMON_CTRL_ID_MAX,
- VP8_DECODER_CTRL_ID_START = 256,
+enum vp8_com_control_id {
+ VP8_SET_REFERENCE = 1, /**< pass in an external frame into decoder to be used as reference frame */
+ VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
+ VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
+ VP8_SET_DBG_COLOR_REF_FRAME = 4, /**< set the reference frames to color for each macroblock */
+ VP8_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
+ VP8_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */
+ VP8_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */
+ VP8_COMMON_CTRL_ID_MAX,
+ VP8_DECODER_CTRL_ID_START = 256,
};
/*!\brief post process flags
*
* The set of macros define VP8 decoder post processing flags
*/
-enum vp8_postproc_level
-{
- VP8_NOFILTERING = 0,
- VP8_DEBLOCK = 1<<0,
- VP8_DEMACROBLOCK = 1<<1,
- VP8_ADDNOISE = 1<<2,
- VP8_DEBUG_TXT_FRAME_INFO = 1<<3, /**< print frame information */
- VP8_DEBUG_TXT_MBLK_MODES = 1<<4, /**< print macro block modes over each macro block */
- VP8_DEBUG_TXT_DC_DIFF = 1<<5, /**< print dc diff for each macro block */
- VP8_DEBUG_TXT_RATE_INFO = 1<<6, /**< print video rate info (encoder only) */
+enum vp8_postproc_level {
+ VP8_NOFILTERING = 0,
+ VP8_DEBLOCK = 1 << 0,
+ VP8_DEMACROBLOCK = 1 << 1,
+ VP8_ADDNOISE = 1 << 2,
+ VP8_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */
+ VP8_DEBUG_TXT_MBLK_MODES = 1 << 4, /**< print macro block modes over each macro block */
+ VP8_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */
+ VP8_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */
};
/*!\brief post process flags
@@ -72,22 +70,20 @@ enum vp8_postproc_level
* to VP8_DEBLOCK and deblocking_level to 1.
*/
-typedef struct vp8_postproc_cfg
-{
- int post_proc_flag; /**< the types of post processing to be done, should be combination of "vp8_postproc_level" */
- int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
- int noise_level; /**< the strength of additive noise, valid range [0, 16] */
+typedef struct vp8_postproc_cfg {
+ int post_proc_flag; /**< the types of post processing to be done, should be combination of "vp8_postproc_level" */
+ int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
+ int noise_level; /**< the strength of additive noise, valid range [0, 16] */
} vp8_postproc_cfg_t;
/*!\brief reference frame type
*
* The set of macros define the type of VP8 reference frames
*/
-typedef enum vpx_ref_frame_type
-{
- VP8_LAST_FRAME = 1,
- VP8_GOLD_FRAME = 2,
- VP8_ALTR_FRAME = 4
+typedef enum vpx_ref_frame_type {
+ VP8_LAST_FRAME = 1,
+ VP8_GOLD_FRAME = 2,
+ VP8_ALTR_FRAME = 4
} vpx_ref_frame_type_t;
/*!\brief reference frame data struct
@@ -95,10 +91,9 @@ typedef enum vpx_ref_frame_type
* define the data struct to access vp8 reference frames
*/
-typedef struct vpx_ref_frame
-{
- vpx_ref_frame_type_t frame_type; /**< which reference frame */
- vpx_image_t img; /**< reference frame data in image format */
+typedef struct vpx_ref_frame {
+ vpx_ref_frame_type_t frame_type; /**< which reference frame */
+ vpx_image_t img; /**< reference frame data in image format */
} vpx_ref_frame_t;
diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h
index d7b87da87..f691c6535 100644
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -31,7 +31,7 @@
* @{
*/
extern vpx_codec_iface_t vpx_codec_vp8_cx_algo;
-extern vpx_codec_iface_t* vpx_codec_vp8_cx(void);
+extern vpx_codec_iface_t *vpx_codec_vp8_cx(void);
/*!@} - end algorithm interface member group*/
@@ -131,75 +131,73 @@ extern vpx_codec_iface_t vpx_codec_vp8x_cx_algo;
*
* \sa #vpx_codec_control
*/
-enum vp8e_enc_control_id
-{
- VP8E_UPD_ENTROPY = 5, /**< control function to set mode of entropy update in encoder */
- VP8E_UPD_REFERENCE, /**< control function to set reference update mode in encoder */
- VP8E_USE_REFERENCE, /**< control function to set which reference frame encoder can use */
- VP8E_SET_ROI_MAP, /**< control function to pass an ROI map to encoder */
- VP8E_SET_ACTIVEMAP, /**< control function to pass an Active map to encoder */
- VP8E_SET_SCALEMODE = 11, /**< control function to set encoder scaling mode */
- /*!\brief control function to set vp8 encoder cpuused
- *
- * Changes in this value influences, among others, the encoder's selection
- * of motion estimation methods. Values greater than 0 will increase encoder
- * speed at the expense of quality.
- * The full set of adjustments can be found in
- * onyx_if.c:vp8_set_speed_features().
- * \todo List highlights of the changes at various levels.
- *
- * \note Valid range: -16..16
- */
- VP8E_SET_CPUUSED = 13,
- VP8E_SET_ENABLEAUTOALTREF, /**< control function to enable vp8 to automatic set and use altref frame */
- VP8E_SET_NOISE_SENSITIVITY, /**< control function to set noise sensitivity */
- VP8E_SET_SHARPNESS, /**< control function to set sharpness */
- VP8E_SET_STATIC_THRESHOLD, /**< control function to set the threshold for macroblocks treated static */
- VP8E_SET_TOKEN_PARTITIONS, /**< control function to set the number of token partitions */
- VP8E_GET_LAST_QUANTIZER, /**< return the quantizer chosen by the
+enum vp8e_enc_control_id {
+ VP8E_UPD_ENTROPY = 5, /**< control function to set mode of entropy update in encoder */
+ VP8E_UPD_REFERENCE, /**< control function to set reference update mode in encoder */
+ VP8E_USE_REFERENCE, /**< control function to set which reference frame encoder can use */
+ VP8E_SET_ROI_MAP, /**< control function to pass an ROI map to encoder */
+ VP8E_SET_ACTIVEMAP, /**< control function to pass an Active map to encoder */
+ VP8E_SET_SCALEMODE = 11, /**< control function to set encoder scaling mode */
+ /*!\brief control function to set vp8 encoder cpuused
+ *
+ * Changes in this value influences, among others, the encoder's selection
+ * of motion estimation methods. Values greater than 0 will increase encoder
+ * speed at the expense of quality.
+ * The full set of adjustments can be found in
+ * onyx_if.c:vp8_set_speed_features().
+ * \todo List highlights of the changes at various levels.
+ *
+ * \note Valid range: -16..16
+ */
+ VP8E_SET_CPUUSED = 13,
+ VP8E_SET_ENABLEAUTOALTREF, /**< control function to enable vp8 to automatic set and use altref frame */
+ VP8E_SET_NOISE_SENSITIVITY, /**< control function to set noise sensitivity */
+ VP8E_SET_SHARPNESS, /**< control function to set sharpness */
+ VP8E_SET_STATIC_THRESHOLD, /**< control function to set the threshold for macroblocks treated static */
+ VP8E_SET_TOKEN_PARTITIONS, /**< control function to set the number of token partitions */
+ VP8E_GET_LAST_QUANTIZER, /**< return the quantizer chosen by the
encoder for the last frame using the internal
scale */
- VP8E_GET_LAST_QUANTIZER_64, /**< return the quantizer chosen by the
+ VP8E_GET_LAST_QUANTIZER_64, /**< return the quantizer chosen by the
encoder for the last frame, using the 0..63
scale as used by the rc_*_quantizer config
parameters */
- VP8E_SET_ARNR_MAXFRAMES, /**< control function to set the max number of frames blurred creating arf*/
- VP8E_SET_ARNR_STRENGTH , /**< control function to set the filter strength for the arf */
- VP8E_SET_ARNR_TYPE , /**< control function to set the type of filter to use for the arf*/
- VP8E_SET_TUNING, /**< control function to set visual tuning */
- /*!\brief control function to set constrained quality level
- *
- * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be
- * set to #VPX_CQ.
- * \note Valid range: 0..63
- */
- VP8E_SET_CQ_LEVEL,
-
- /*!\brief Max data rate for Intra frames
- *
- * This value controls additional clamping on the maximum size of a
- * keyframe. It is expressed as a percentage of the average
- * per-frame bitrate, with the special (and default) value 0 meaning
- * unlimited, or no additional clamping beyond the codec's built-in
- * algorithm.
- *
- * For example, to allocate no more than 4.5 frames worth of bitrate
- * to a keyframe, set this to 450.
- *
- */
- VP8E_SET_MAX_INTRA_BITRATE_PCT,
+ VP8E_SET_ARNR_MAXFRAMES, /**< control function to set the max number of frames blurred creating arf*/
+ VP8E_SET_ARNR_STRENGTH, /**< control function to set the filter strength for the arf */
+ VP8E_SET_ARNR_TYPE, /**< control function to set the type of filter to use for the arf*/
+ VP8E_SET_TUNING, /**< control function to set visual tuning */
+ /*!\brief control function to set constrained quality level
+ *
+ * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be
+ * set to #VPX_CQ.
+ * \note Valid range: 0..63
+ */
+ VP8E_SET_CQ_LEVEL,
+
+ /*!\brief Max data rate for Intra frames
+ *
+ * This value controls additional clamping on the maximum size of a
+ * keyframe. It is expressed as a percentage of the average
+ * per-frame bitrate, with the special (and default) value 0 meaning
+ * unlimited, or no additional clamping beyond the codec's built-in
+ * algorithm.
+ *
+ * For example, to allocate no more than 4.5 frames worth of bitrate
+ * to a keyframe, set this to 450.
+ *
+ */
+ VP8E_SET_MAX_INTRA_BITRATE_PCT,
};
/*!\brief vpx 1-D scaling mode
*
* This set of constants define 1-D vpx scaling modes
*/
-typedef enum vpx_scaling_mode_1d
-{
- VP8E_NORMAL = 0,
- VP8E_FOURFIVE = 1,
- VP8E_THREEFIVE = 2,
- VP8E_ONETWO = 3
+typedef enum vpx_scaling_mode_1d {
+ VP8E_NORMAL = 0,
+ VP8E_FOURFIVE = 1,
+ VP8E_THREEFIVE = 2,
+ VP8E_ONETWO = 3
} VPX_SCALING_MODE;
@@ -209,14 +207,13 @@ typedef enum vpx_scaling_mode_1d
*
*/
-typedef struct vpx_roi_map
-{
- unsigned char *roi_map; /**< specify an id between 0 and 3 for each 16x16 region within a frame */
- unsigned int rows; /**< number of rows */
- unsigned int cols; /**< number of cols */
- int delta_q[4]; /**< quantizer delta [-64, 64] off baseline for regions with id between 0 and 3*/
- int delta_lf[4]; /**< loop filter strength delta [-32, 32] for regions with id between 0 and 3 */
- unsigned int static_threshold[4];/**< threshold for region to be treated as static */
+typedef struct vpx_roi_map {
+ unsigned char *roi_map; /**< specify an id between 0 and 3 for each 16x16 region within a frame */
+ unsigned int rows; /**< number of rows */
+ unsigned int cols; /**< number of cols */
+ int delta_q[4]; /**< quantizer delta [-64, 64] off baseline for regions with id between 0 and 3*/
+ int delta_lf[4]; /**< loop filter strength delta [-32, 32] for regions with id between 0 and 3 */
+ unsigned int static_threshold[4];/**< threshold for region to be treated as static */
} vpx_roi_map_t;
/*!\brief vpx active region map
@@ -226,11 +223,10 @@ typedef struct vpx_roi_map
*/
-typedef struct vpx_active_map
-{
- unsigned char *active_map; /**< specify an on (1) or off (0) each 16x16 region within a frame */
- unsigned int rows; /**< number of rows */
- unsigned int cols; /**< number of cols */
+typedef struct vpx_active_map {
+ unsigned char *active_map; /**< specify an on (1) or off (0) each 16x16 region within a frame */
+ unsigned int rows; /**< number of rows */
+ unsigned int cols; /**< number of cols */
} vpx_active_map_t;
/*!\brief vpx image scaling mode
@@ -238,10 +234,9 @@ typedef struct vpx_active_map
* This defines the data structure for image scaling mode
*
*/
-typedef struct vpx_scaling_mode
-{
- VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */
- VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */
+typedef struct vpx_scaling_mode {
+ VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */
+ VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */
} vpx_scaling_mode_t;
/*!\brief VP8 encoding mode
@@ -249,11 +244,10 @@ typedef struct vpx_scaling_mode
* This defines VP8 encoding mode
*
*/
-typedef enum
-{
- VP8_BEST_QUALITY_ENCODING,
- VP8_GOOD_QUALITY_ENCODING,
- VP8_REAL_TIME_ENCODING
+typedef enum {
+ VP8_BEST_QUALITY_ENCODING,
+ VP8_GOOD_QUALITY_ENCODING,
+ VP8_REAL_TIME_ENCODING
} vp8e_encoding_mode;
/*!\brief VP8 token partition mode
@@ -263,12 +257,11 @@ typedef enum
*
*/
-typedef enum
-{
- VP8_ONE_TOKENPARTITION = 0,
- VP8_TWO_TOKENPARTITION = 1,
- VP8_FOUR_TOKENPARTITION = 2,
- VP8_EIGHT_TOKENPARTITION = 3,
+typedef enum {
+ VP8_ONE_TOKENPARTITION = 0,
+ VP8_TWO_TOKENPARTITION = 1,
+ VP8_FOUR_TOKENPARTITION = 2,
+ VP8_EIGHT_TOKENPARTITION = 3,
} vp8e_token_partitions;
@@ -277,10 +270,9 @@ typedef enum
* Changes the encoder to tune for certain types of input material.
*
*/
-typedef enum
-{
- VP8_TUNE_PSNR,
- VP8_TUNE_SSIM
+typedef enum {
+ VP8_TUNE_PSNR,
+ VP8_TUNE_SSIM
} vp8e_tuning;
@@ -311,10 +303,10 @@ VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int)
VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, vp8e_token_partitions)
VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int)
-VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH , unsigned int)
-VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_TYPE , unsigned int)
+VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int)
+VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_TYPE, unsigned int)
VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, vp8e_tuning)
-VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL , unsigned int)
+VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int)
VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *)
VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h
index 1d9d53165..8ac0d9da9 100644
--- a/vpx/vp8dx.h
+++ b/vpx/vp8dx.h
@@ -31,7 +31,7 @@
* @{
*/
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
-extern vpx_codec_iface_t* vpx_codec_vp8_dx(void);
+extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
/*!@} - end algorithm interface member group*/
/* Include controls common to both the encoder and decoder */
@@ -45,18 +45,17 @@ extern vpx_codec_iface_t* vpx_codec_vp8_dx(void);
*
* \sa #vpx_codec_control
*/
-enum vp8_dec_control_id
-{
- /** control function to get info on which reference frames were updated
- * by the last decode
- */
- VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
-
- /** check if the indicated frame is corrupted */
- VP8D_GET_FRAME_CORRUPTED,
-
- VP8_DECODER_CTRL_ID_MAX
-} ;
+enum vp8_dec_control_id {
+ /** control function to get info on which reference frames were updated
+ * by the last decode
+ */
+ VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
+
+ /** check if the indicated frame is corrupted */
+ VP8D_GET_FRAME_CORRUPTED,
+
+ VP8_DECODER_CTRL_ID_MAX
+};
/*!\brief VP8 decoder control function parameter type
diff --git a/vpx/vp8e.h b/vpx/vp8e.h
index ca907c96f..4dacb3cd7 100644
--- a/vpx/vp8e.h
+++ b/vpx/vp8e.h
@@ -24,14 +24,13 @@
DECLSPEC_DEPRECATED extern vpx_codec_iface_t vpx_enc_vp8_algo DEPRECATED;
-enum
-{
- VP8E_SET_REFERENCE = VP8_SET_REFERENCE,
- VP8E_COPY_REFERENCE = VP8_COPY_REFERENCE,
- VP8E_SET_PREVIEWPP = VP8_SET_POSTPROC,
- VP8E_SET_FLUSHFLAG = 4,
- VP8E_SET_FRAMETYPE = 10,
- VP8E_SET_ENCODING_MODE = 12
+enum {
+ VP8E_SET_REFERENCE = VP8_SET_REFERENCE,
+ VP8E_COPY_REFERENCE = VP8_COPY_REFERENCE,
+ VP8E_SET_PREVIEWPP = VP8_SET_POSTPROC,
+ VP8E_SET_FLUSHFLAG = 4,
+ VP8E_SET_FRAMETYPE = 10,
+ VP8E_SET_ENCODING_MODE = 12
};
#define NORMAL_FRAME (0)
diff --git a/vpx/vpx_codec.h b/vpx/vpx_codec.h
index d92e165ff..368a92262 100644
--- a/vpx/vpx_codec.h
+++ b/vpx/vpx_codec.h
@@ -45,7 +45,7 @@ extern "C" {
#include "vpx_integer.h"
#include "vpx_image.h"
- /*!\brief Decorator indicating a function is deprecated */
+ /*!\brief Decorator indicating a function is deprecated */
#ifndef DEPRECATED
#if defined(__GNUC__) && __GNUC__
#define DEPRECATED __attribute__ ((deprecated))
@@ -59,7 +59,7 @@ extern "C" {
#endif
#endif
- /*!\brief Decorator indicating a function is potentially unused */
+ /*!\brief Decorator indicating a function is potentially unused */
#ifdef UNUSED
#elif __GNUC__
#define UNUSED __attribute__ ((unused))
@@ -67,312 +67,310 @@ extern "C" {
#define UNUSED
#endif
- /*!\brief Current ABI version number
- *
- * \internal
- * If this file is altered in any way that changes the ABI, this value
- * must be bumped. Examples include, but are not limited to, changing
- * types, removing or reassigning enums, adding/removing/rearranging
- * fields to structures
- */
+ /*!\brief Current ABI version number
+ *
+ * \internal
+ * If this file is altered in any way that changes the ABI, this value
+ * must be bumped. Examples include, but are not limited to, changing
+ * types, removing or reassigning enums, adding/removing/rearranging
+ * fields to structures
+ */
#define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
- /*!\brief Algorithm return codes */
- typedef enum {
- /*!\brief Operation completed without error */
- VPX_CODEC_OK,
-
- /*!\brief Unspecified error */
- VPX_CODEC_ERROR,
-
- /*!\brief Memory operation failed */
- VPX_CODEC_MEM_ERROR,
-
- /*!\brief ABI version mismatch */
- VPX_CODEC_ABI_MISMATCH,
-
- /*!\brief Algorithm does not have required capability */
- VPX_CODEC_INCAPABLE,
-
- /*!\brief The given bitstream is not supported.
- *
- * The bitstream was unable to be parsed at the highest level. The decoder
- * is unable to proceed. This error \ref SHOULD be treated as fatal to the
- * stream. */
- VPX_CODEC_UNSUP_BITSTREAM,
-
- /*!\brief Encoded bitstream uses an unsupported feature
- *
- * The decoder does not implement a feature required by the encoder. This
- * return code should only be used for features that prevent future
- * pictures from being properly decoded. This error \ref MAY be treated as
- * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
- */
- VPX_CODEC_UNSUP_FEATURE,
-
- /*!\brief The coded data for this stream is corrupt or incomplete
- *
- * There was a problem decoding the current frame. This return code
- * should only be used for failures that prevent future pictures from
- * being properly decoded. This error \ref MAY be treated as fatal to the
- * stream or \ref MAY be treated as fatal to the current GOP. If decoding
- * is continued for the current GOP, artifacts may be present.
- */
- VPX_CODEC_CORRUPT_FRAME,
-
- /*!\brief An application-supplied parameter is not valid.
- *
- */
- VPX_CODEC_INVALID_PARAM,
-
- /*!\brief An iterator reached the end of list.
- *
- */
- VPX_CODEC_LIST_END
-
- }
- vpx_codec_err_t;
-
-
- /*! \brief Codec capabilities bitfield
- *
- * Each codec advertises the capabilities it supports as part of its
- * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
- * or functionality, and are not required to be supported.
- *
- * The available flags are specified by VPX_CODEC_CAP_* defines.
- */
- typedef long vpx_codec_caps_t;
-#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
-#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
-#define VPX_CODEC_CAP_XMA 0x4 /**< Supports eXternal Memory Allocation */
-
-
- /*! \brief Initialization-time Feature Enabling
- *
- * Certain codec features must be known at initialization time, to allow for
- * proper memory allocation.
- *
- * The available flags are specified by VPX_CODEC_USE_* defines.
- */
- typedef long vpx_codec_flags_t;
-#define VPX_CODEC_USE_XMA 0x00000001 /**< Use eXternal Memory Allocation mode */
-
-
- /*!\brief Codec interface structure.
- *
- * Contains function pointers and other data private to the codec
- * implementation. This structure is opaque to the application.
- */
- typedef const struct vpx_codec_iface vpx_codec_iface_t;
-
-
- /*!\brief Codec private data structure.
- *
- * Contains data private to the codec implementation. This structure is opaque
- * to the application.
- */
- typedef struct vpx_codec_priv vpx_codec_priv_t;
-
-
- /*!\brief Iterator
- *
- * Opaque storage used for iterating over lists.
- */
- typedef const void *vpx_codec_iter_t;
+ /*!\brief Algorithm return codes */
+ typedef enum {
+ /*!\brief Operation completed without error */
+ VPX_CODEC_OK,
+ /*!\brief Unspecified error */
+ VPX_CODEC_ERROR,
- /*!\brief Codec context structure
- *
- * All codecs \ref MUST support this context structure fully. In general,
- * this data should be considered private to the codec algorithm, and
- * not be manipulated or examined by the calling application. Applications
- * may reference the 'name' member to get a printable description of the
- * algorithm.
- */
- typedef struct vpx_codec_ctx
- {
- const char *name; /**< Printable interface name */
- vpx_codec_iface_t *iface; /**< Interface pointers */
- vpx_codec_err_t err; /**< Last returned error */
- const char *err_detail; /**< Detailed info, if available */
- vpx_codec_flags_t init_flags; /**< Flags passed at init time */
- union
- {
- struct vpx_codec_dec_cfg *dec; /**< Decoder Configuration Pointer */
- struct vpx_codec_enc_cfg *enc; /**< Encoder Configuration Pointer */
- void *raw;
- } config; /**< Configuration pointer aliasing union */
- vpx_codec_priv_t *priv; /**< Algorithm private storage */
- } vpx_codec_ctx_t;
+ /*!\brief Memory operation failed */
+ VPX_CODEC_MEM_ERROR,
+ /*!\brief ABI version mismatch */
+ VPX_CODEC_ABI_MISMATCH,
- /*
- * Library Version Number Interface
- *
- * For example, see the following sample return values:
- * vpx_codec_version() (1<<16 | 2<<8 | 3)
- * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
- * vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
- */
+ /*!\brief Algorithm does not have required capability */
+ VPX_CODEC_INCAPABLE,
- /*!\brief Return the version information (as an integer)
- *
- * Returns a packed encoding of the library version number. This will only include
- * the major.minor.patch component of the version number. Note that this encoded
- * value should be accessed through the macros provided, as the encoding may change
- * in the future.
+ /*!\brief The given bitstream is not supported.
*
- */
- int vpx_codec_version(void);
-#define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) /**< extract major from packed version */
-#define VPX_VERSION_MINOR(v) ((v>>8)&0xff) /**< extract minor from packed version */
-#define VPX_VERSION_PATCH(v) ((v>>0)&0xff) /**< extract patch from packed version */
-
- /*!\brief Return the version major number */
-#define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff)
-
- /*!\brief Return the version minor number */
-#define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff)
+ * The bitstream was unable to be parsed at the highest level. The decoder
+ * is unable to proceed. This error \ref SHOULD be treated as fatal to the
+ * stream. */
+ VPX_CODEC_UNSUP_BITSTREAM,
- /*!\brief Return the version patch number */
-#define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff)
-
-
- /*!\brief Return the version information (as a string)
- *
- * Returns a printable string containing the full library version number. This may
- * contain additional text following the three digit version number, as to indicate
- * release candidates, prerelease versions, etc.
+ /*!\brief Encoded bitstream uses an unsupported feature
*
+ * The decoder does not implement a feature required by the encoder. This
+ * return code should only be used for features that prevent future
+ * pictures from being properly decoded. This error \ref MAY be treated as
+ * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
*/
- const char *vpx_codec_version_str(void);
+ VPX_CODEC_UNSUP_FEATURE,
-
- /*!\brief Return the version information (as a string)
- *
- * Returns a printable "extra string". This is the component of the string returned
- * by vpx_codec_version_str() following the three digit version number.
+ /*!\brief The coded data for this stream is corrupt or incomplete
*
+ * There was a problem decoding the current frame. This return code
+ * should only be used for failures that prevent future pictures from
+ * being properly decoded. This error \ref MAY be treated as fatal to the
+ * stream or \ref MAY be treated as fatal to the current GOP. If decoding
+ * is continued for the current GOP, artifacts may be present.
*/
- const char *vpx_codec_version_extra_str(void);
+ VPX_CODEC_CORRUPT_FRAME,
-
- /*!\brief Return the build configuration
- *
- * Returns a printable string containing an encoded version of the build
- * configuration. This may be useful to vpx support.
+ /*!\brief An application-supplied parameter is not valid.
*
*/
- const char *vpx_codec_build_config(void);
+ VPX_CODEC_INVALID_PARAM,
-
- /*!\brief Return the name for a given interface
- *
- * Returns a human readable string for name of the given codec interface.
- *
- * \param[in] iface Interface pointer
+ /*!\brief An iterator reached the end of list.
*
*/
- const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
-
+ VPX_CODEC_LIST_END
- /*!\brief Convert error number to printable string
- *
- * Returns a human readable string for the last error returned by the
- * algorithm. The returned error will be one line and will not contain
- * any newline characters.
- *
- *
- * \param[in] err Error number.
- *
- */
- const char *vpx_codec_err_to_string(vpx_codec_err_t err);
+ }
+ vpx_codec_err_t;
- /*!\brief Retrieve error synopsis for codec context
- *
- * Returns a human readable string for the last error returned by the
- * algorithm. The returned error will be one line and will not contain
- * any newline characters.
- *
- *
- * \param[in] ctx Pointer to this instance's context.
- *
- */
- const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
+ /*! \brief Codec capabilities bitfield
+ *
+ * Each codec advertises the capabilities it supports as part of its
+ * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
+ * or functionality, and are not required to be supported.
+ *
+ * The available flags are specified by VPX_CODEC_CAP_* defines.
+ */
+ typedef long vpx_codec_caps_t;
+#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
+#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
+#define VPX_CODEC_CAP_XMA 0x4 /**< Supports eXternal Memory Allocation */
- /*!\brief Retrieve detailed error information for codec context
- *
- * Returns a human readable string providing detailed information about
- * the last error.
- *
- * \param[in] ctx Pointer to this instance's context.
- *
- * \retval NULL
- * No detailed information is available.
- */
- const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
+ /*! \brief Initialization-time Feature Enabling
+ *
+ * Certain codec features must be known at initialization time, to allow for
+ * proper memory allocation.
+ *
+ * The available flags are specified by VPX_CODEC_USE_* defines.
+ */
+ typedef long vpx_codec_flags_t;
+#define VPX_CODEC_USE_XMA 0x00000001 /**< Use eXternal Memory Allocation mode */
- /* REQUIRED FUNCTIONS
- *
- * The following functions are required to be implemented for all codecs.
- * They represent the base case functionality expected of all codecs.
- */
+ /*!\brief Codec interface structure.
+ *
+ * Contains function pointers and other data private to the codec
+ * implementation. This structure is opaque to the application.
+ */
+ typedef const struct vpx_codec_iface vpx_codec_iface_t;
+
+
+ /*!\brief Codec private data structure.
+ *
+ * Contains data private to the codec implementation. This structure is opaque
+ * to the application.
+ */
+ typedef struct vpx_codec_priv vpx_codec_priv_t;
+
+
+ /*!\brief Iterator
+ *
+ * Opaque storage used for iterating over lists.
+ */
+ typedef const void *vpx_codec_iter_t;
+
+
+ /*!\brief Codec context structure
+ *
+ * All codecs \ref MUST support this context structure fully. In general,
+ * this data should be considered private to the codec algorithm, and
+ * not be manipulated or examined by the calling application. Applications
+ * may reference the 'name' member to get a printable description of the
+ * algorithm.
+ */
+ typedef struct vpx_codec_ctx {
+ const char *name; /**< Printable interface name */
+ vpx_codec_iface_t *iface; /**< Interface pointers */
+ vpx_codec_err_t err; /**< Last returned error */
+ const char *err_detail; /**< Detailed info, if available */
+ vpx_codec_flags_t init_flags; /**< Flags passed at init time */
+ union {
+ struct vpx_codec_dec_cfg *dec; /**< Decoder Configuration Pointer */
+ struct vpx_codec_enc_cfg *enc; /**< Encoder Configuration Pointer */
+ void *raw;
+ } config; /**< Configuration pointer aliasing union */
+ vpx_codec_priv_t *priv; /**< Algorithm private storage */
+ } vpx_codec_ctx_t;
+
+
+ /*
+ * Library Version Number Interface
+ *
+ * For example, see the following sample return values:
+ * vpx_codec_version() (1<<16 | 2<<8 | 3)
+ * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
+ * vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
+ */
+
+ /*!\brief Return the version information (as an integer)
+ *
+ * Returns a packed encoding of the library version number. This will only include
+ * the major.minor.patch component of the version number. Note that this encoded
+ * value should be accessed through the macros provided, as the encoding may change
+ * in the future.
+ *
+ */
+ int vpx_codec_version(void);
+#define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) /**< extract major from packed version */
+#define VPX_VERSION_MINOR(v) ((v>>8)&0xff) /**< extract minor from packed version */
+#define VPX_VERSION_PATCH(v) ((v>>0)&0xff) /**< extract patch from packed version */
- /*!\brief Destroy a codec instance
- *
- * Destroys a codec context, freeing any associated memory buffers.
- *
- * \param[in] ctx Pointer to this instance's context
- *
- * \retval #VPX_CODEC_OK
- * The codec algorithm initialized.
- * \retval #VPX_CODEC_MEM_ERROR
- * Memory allocation failed.
- */
- vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
+ /*!\brief Return the version major number */
+#define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff)
+ /*!\brief Return the version minor number */
+#define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff)
- /*!\brief Get the capabilities of an algorithm.
- *
- * Retrieves the capabilities bitfield from the algorithm's interface.
- *
- * \param[in] iface Pointer to the algorithm interface
- *
- */
- vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
+ /*!\brief Return the version patch number */
+#define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff)
- /*!\brief Control algorithm
- *
- * This function is used to exchange algorithm specific data with the codec
- * instance. This can be used to implement features specific to a particular
- * algorithm.
- *
- * This wrapper function dispatches the request to the helper function
- * associated with the given ctrl_id. It tries to call this function
- * transparently, but will return #VPX_CODEC_ERROR if the request could not
- * be dispatched.
- *
- * Note that this function should not be used directly. Call the
- * #vpx_codec_control wrapper macro instead.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] ctrl_id Algorithm specific control identifier
- *
- * \retval #VPX_CODEC_OK
- * The control request was processed.
- * \retval #VPX_CODEC_ERROR
- * The control request was not processed.
- * \retval #VPX_CODEC_INVALID_PARAM
- * The data was not valid.
- */
- vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx,
- int ctrl_id,
- ...);
+ /*!\brief Return the version information (as a string)
+ *
+ * Returns a printable string containing the full library version number. This may
+ * contain additional text following the three digit version number, as to indicate
+ * release candidates, prerelease versions, etc.
+ *
+ */
+ const char *vpx_codec_version_str(void);
+
+
+ /*!\brief Return the version information (as a string)
+ *
+ * Returns a printable "extra string". This is the component of the string returned
+ * by vpx_codec_version_str() following the three digit version number.
+ *
+ */
+ const char *vpx_codec_version_extra_str(void);
+
+
+ /*!\brief Return the build configuration
+ *
+ * Returns a printable string containing an encoded version of the build
+ * configuration. This may be useful to vpx support.
+ *
+ */
+ const char *vpx_codec_build_config(void);
+
+
+ /*!\brief Return the name for a given interface
+ *
+ * Returns a human readable string for name of the given codec interface.
+ *
+ * \param[in] iface Interface pointer
+ *
+ */
+ const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
+
+
+ /*!\brief Convert error number to printable string
+ *
+ * Returns a human readable string for the last error returned by the
+ * algorithm. The returned error will be one line and will not contain
+ * any newline characters.
+ *
+ *
+ * \param[in] err Error number.
+ *
+ */
+ const char *vpx_codec_err_to_string(vpx_codec_err_t err);
+
+
+ /*!\brief Retrieve error synopsis for codec context
+ *
+ * Returns a human readable string for the last error returned by the
+ * algorithm. The returned error will be one line and will not contain
+ * any newline characters.
+ *
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ *
+ */
+ const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
+
+
+ /*!\brief Retrieve detailed error information for codec context
+ *
+ * Returns a human readable string providing detailed information about
+ * the last error.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ *
+ * \retval NULL
+ * No detailed information is available.
+ */
+ const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
+
+
+ /* REQUIRED FUNCTIONS
+ *
+ * The following functions are required to be implemented for all codecs.
+ * They represent the base case functionality expected of all codecs.
+ */
+
+ /*!\brief Destroy a codec instance
+ *
+ * Destroys a codec context, freeing any associated memory buffers.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ *
+ * \retval #VPX_CODEC_OK
+ * The codec algorithm initialized.
+ * \retval #VPX_CODEC_MEM_ERROR
+ * Memory allocation failed.
+ */
+ vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
+
+
+ /*!\brief Get the capabilities of an algorithm.
+ *
+ * Retrieves the capabilities bitfield from the algorithm's interface.
+ *
+ * \param[in] iface Pointer to the algorithm interface
+ *
+ */
+ vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
+
+
+ /*!\brief Control algorithm
+ *
+ * This function is used to exchange algorithm specific data with the codec
+ * instance. This can be used to implement features specific to a particular
+ * algorithm.
+ *
+ * This wrapper function dispatches the request to the helper function
+ * associated with the given ctrl_id. It tries to call this function
+ * transparently, but will return #VPX_CODEC_ERROR if the request could not
+ * be dispatched.
+ *
+ * Note that this function should not be used directly. Call the
+ * #vpx_codec_control wrapper macro instead.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] ctrl_id Algorithm specific control identifier
+ *
+ * \retval #VPX_CODEC_OK
+ * The control request was processed.
+ * \retval #VPX_CODEC_ERROR
+ * The control request was not processed.
+ * \retval #VPX_CODEC_INVALID_PARAM
+ * The data was not valid.
+ */
+ vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx,
+ int ctrl_id,
+ ...);
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
# define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data)
# define VPX_CTRL_USE_TYPE(id, typ)
@@ -380,172 +378,171 @@ extern "C" {
# define VPX_CTRL_VOID(id, typ)
#else
- /*!\brief vpx_codec_control wrapper macro
- *
- * This macro allows for type safe conversions across the variadic parameter
- * to vpx_codec_control_().
- *
- * \internal
- * It works by dispatching the call to the control function through a wrapper
- * function named with the id parameter.
- */
+ /*!\brief vpx_codec_control wrapper macro
+ *
+ * This macro allows for type safe conversions across the variadic parameter
+ * to vpx_codec_control_().
+ *
+ * \internal
+ * It works by dispatching the call to the control function through a wrapper
+ * function named with the id parameter.
+ */
# define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\
- /**<\hideinitializer*/
-
-
- /*!\brief vpx_codec_control type definition macro
- *
- * This macro allows for type safe conversions across the variadic parameter
- * to vpx_codec_control_(). It defines the type of the argument for a given
- * control identifier.
- *
- * \internal
- * It defines a static function with
- * the correctly typed arguments as a wrapper to the type-unsafe internal
- * function.
- */
+ /**<\hideinitializer*/
+
+
+ /*!\brief vpx_codec_control type definition macro
+ *
+ * This macro allows for type safe conversions across the variadic parameter
+ * to vpx_codec_control_(). It defines the type of the argument for a given
+ * control identifier.
+ *
+ * \internal
+ * It defines a static function with
+ * the correctly typed arguments as a wrapper to the type-unsafe internal
+ * function.
+ */
# define VPX_CTRL_USE_TYPE(id, typ) \
- static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\
- \
- static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
- return vpx_codec_control_(ctx, ctrl_id, data);\
- } /**<\hideinitializer*/
-
-
- /*!\brief vpx_codec_control deprecated type definition macro
- *
- * Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
- * deprecated and should not be used. Consult the documentation for your
- * codec for more information.
- *
- * \internal
- * It defines a static function with the correctly typed arguments as a
- * wrapper to the type-unsafe internal function.
- */
+ static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\
+ \
+ static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
+ return vpx_codec_control_(ctx, ctrl_id, data);\
+ } /**<\hideinitializer*/
+
+
+ /*!\brief vpx_codec_control deprecated type definition macro
+ *
+ * Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
+ * deprecated and should not be used. Consult the documentation for your
+ * codec for more information.
+ *
+ * \internal
+ * It defines a static function with the correctly typed arguments as a
+ * wrapper to the type-unsafe internal function.
+ */
# define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
- DECLSPEC_DEPRECATED static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\
- \
- DECLSPEC_DEPRECATED static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
- return vpx_codec_control_(ctx, ctrl_id, data);\
- } /**<\hideinitializer*/
-
-
- /*!\brief vpx_codec_control void type definition macro
- *
- * This macro allows for type safe conversions across the variadic parameter
- * to vpx_codec_control_(). It indicates that a given control identifier takes
- * no argument.
- *
- * \internal
- * It defines a static function without a data argument as a wrapper to the
- * type-unsafe internal function.
- */
+ DECLSPEC_DEPRECATED static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\
+ \
+ DECLSPEC_DEPRECATED static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
+ return vpx_codec_control_(ctx, ctrl_id, data);\
+ } /**<\hideinitializer*/
+
+
+ /*!\brief vpx_codec_control void type definition macro
+ *
+ * This macro allows for type safe conversions across the variadic parameter
+ * to vpx_codec_control_(). It indicates that a given control identifier takes
+ * no argument.
+ *
+ * \internal
+ * It defines a static function without a data argument as a wrapper to the
+ * type-unsafe internal function.
+ */
# define VPX_CTRL_VOID(id) \
- static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\
- \
- static vpx_codec_err_t \
- vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\
- return vpx_codec_control_(ctx, ctrl_id);\
- } /**<\hideinitializer*/
+ static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\
+ \
+ static vpx_codec_err_t \
+ vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\
+ return vpx_codec_control_(ctx, ctrl_id);\
+ } /**<\hideinitializer*/
#endif
- /*!\defgroup cap_xma External Memory Allocation Functions
- *
- * The following functions are required to be implemented for all codecs
- * that advertise the VPX_CODEC_CAP_XMA capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_CODEC_INCAPABLE
- * @{
- */
+ /*!\defgroup cap_xma External Memory Allocation Functions
+ *
+ * The following functions are required to be implemented for all codecs
+ * that advertise the VPX_CODEC_CAP_XMA capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_CODEC_INCAPABLE
+ * @{
+ */
- /*!\brief Memory Map Entry
- *
- * This structure is used to contain the properties of a memory segment. It
- * is populated by the codec in the request phase, and by the calling
- * application once the requested allocation has been performed.
+ /*!\brief Memory Map Entry
+ *
+ * This structure is used to contain the properties of a memory segment. It
+ * is populated by the codec in the request phase, and by the calling
+ * application once the requested allocation has been performed.
+ */
+ typedef struct vpx_codec_mmap {
+ /*
+ * The following members are set by the codec when requesting a segment
*/
- typedef struct vpx_codec_mmap
- {
- /*
- * The following members are set by the codec when requesting a segment
- */
- unsigned int id; /**< identifier for the segment's contents */
- unsigned long sz; /**< size of the segment, in bytes */
- unsigned int align; /**< required alignment of the segment, in bytes */
- unsigned int flags; /**< bitfield containing segment properties */
+ unsigned int id; /**< identifier for the segment's contents */
+ unsigned long sz; /**< size of the segment, in bytes */
+ unsigned int align; /**< required alignment of the segment, in bytes */
+ unsigned int flags; /**< bitfield containing segment properties */
#define VPX_CODEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */
#define VPX_CODEC_MEM_WRONLY 0x2 /**< Segment need not be readable */
#define VPX_CODEC_MEM_FAST 0x4 /**< Place in fast memory, if available */
- /* The following members are to be filled in by the allocation function */
- void *base; /**< pointer to the allocated segment */
- void (*dtor)(struct vpx_codec_mmap *map); /**< destructor to call */
- void *priv; /**< allocator private storage */
- } vpx_codec_mmap_t; /**< alias for struct vpx_codec_mmap */
-
-
- /*!\brief Iterate over the list of segments to allocate.
- *
- * Iterates over a list of the segments to allocate. The iterator storage
- * should be initialized to NULL to start the iteration. Iteration is complete
- * when this function returns VPX_CODEC_LIST_END. The amount of memory needed to
- * allocate is dependent upon the size of the encoded stream. In cases where the
- * stream is not available at allocation time, a fixed size must be requested.
- * The codec will not be able to operate on streams larger than the size used at
- * allocation time.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[out] mmap Pointer to the memory map entry to populate.
- * \param[in,out] iter Iterator storage, initialized to NULL
- *
- * \retval #VPX_CODEC_OK
- * The memory map entry was populated.
- * \retval #VPX_CODEC_ERROR
- * Codec does not support XMA mode.
- * \retval #VPX_CODEC_MEM_ERROR
- * Unable to determine segment size from stream info.
- */
- vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx,
- vpx_codec_mmap_t *mmap,
- vpx_codec_iter_t *iter);
-
-
- /*!\brief Identify allocated segments to codec instance
- *
- * Stores a list of allocated segments in the codec. Segments \ref MUST be
- * passed in the order they are read from vpx_codec_get_mem_map(), but may be
- * passed in groups of any size. Segments \ref MUST be set only once. The
- * allocation function \ref MUST ensure that the vpx_codec_mmap_t::base member
- * is non-NULL. If the segment requires cleanup handling (e.g., calling free()
- * or close()) then the vpx_codec_mmap_t::dtor member \ref MUST be populated.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] mmaps Pointer to the first memory map entry in the list.
- * \param[in] num_maps Number of entries being set at this time
- *
- * \retval #VPX_CODEC_OK
- * The segment was stored in the codec context.
- * \retval #VPX_CODEC_INCAPABLE
- * Codec does not support XMA mode.
- * \retval #VPX_CODEC_MEM_ERROR
- * Segment base address was not set, or segment was already stored.
-
- */
- vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx,
- vpx_codec_mmap_t *mmaps,
- unsigned int num_maps);
-
- /*!@} - end defgroup cap_xma*/
- /*!@} - end defgroup codec*/
+ /* The following members are to be filled in by the allocation function */
+ void *base; /**< pointer to the allocated segment */
+ void (*dtor)(struct vpx_codec_mmap *map); /**< destructor to call */
+ void *priv; /**< allocator private storage */
+ } vpx_codec_mmap_t; /**< alias for struct vpx_codec_mmap */
+
+
+ /*!\brief Iterate over the list of segments to allocate.
+ *
+ * Iterates over a list of the segments to allocate. The iterator storage
+ * should be initialized to NULL to start the iteration. Iteration is complete
+ * when this function returns VPX_CODEC_LIST_END. The amount of memory needed to
+ * allocate is dependent upon the size of the encoded stream. In cases where the
+ * stream is not available at allocation time, a fixed size must be requested.
+ * The codec will not be able to operate on streams larger than the size used at
+ * allocation time.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[out] mmap Pointer to the memory map entry to populate.
+ * \param[in,out] iter Iterator storage, initialized to NULL
+ *
+ * \retval #VPX_CODEC_OK
+ * The memory map entry was populated.
+ * \retval #VPX_CODEC_ERROR
+ * Codec does not support XMA mode.
+ * \retval #VPX_CODEC_MEM_ERROR
+ * Unable to determine segment size from stream info.
+ */
+ vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx,
+ vpx_codec_mmap_t *mmap,
+ vpx_codec_iter_t *iter);
+
+
+ /*!\brief Identify allocated segments to codec instance
+ *
+ * Stores a list of allocated segments in the codec. Segments \ref MUST be
+ * passed in the order they are read from vpx_codec_get_mem_map(), but may be
+ * passed in groups of any size. Segments \ref MUST be set only once. The
+ * allocation function \ref MUST ensure that the vpx_codec_mmap_t::base member
+ * is non-NULL. If the segment requires cleanup handling (e.g., calling free()
+ * or close()) then the vpx_codec_mmap_t::dtor member \ref MUST be populated.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] mmaps Pointer to the first memory map entry in the list.
+ * \param[in] num_maps Number of entries being set at this time
+ *
+ * \retval #VPX_CODEC_OK
+ * The segment was stored in the codec context.
+ * \retval #VPX_CODEC_INCAPABLE
+ * Codec does not support XMA mode.
+ * \retval #VPX_CODEC_MEM_ERROR
+ * Segment base address was not set, or segment was already stored.
+
+ */
+ vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx,
+ vpx_codec_mmap_t *mmaps,
+ unsigned int num_maps);
+
+ /*!@} - end defgroup cap_xma*/
+ /*!@} - end defgroup codec*/
#endif
diff --git a/vpx/vpx_decoder.h b/vpx/vpx_decoder.h
index ea2569daf..3b919e508 100644
--- a/vpx/vpx_decoder.h
+++ b/vpx/vpx_decoder.h
@@ -32,289 +32,287 @@ extern "C" {
#define VPX_DECODER_H
#include "vpx_codec.h"
- /*!\brief Current ABI version number
- *
- * \internal
- * If this file is altered in any way that changes the ABI, this value
- * must be bumped. Examples include, but are not limited to, changing
- * types, removing or reassigning enums, adding/removing/rearranging
- * fields to structures
- */
+ /*!\brief Current ABI version number
+ *
+ * \internal
+ * If this file is altered in any way that changes the ABI, this value
+ * must be bumped. Examples include, but are not limited to, changing
+ * types, removing or reassigning enums, adding/removing/rearranging
+ * fields to structures
+ */
#define VPX_DECODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
- /*! \brief Decoder capabilities bitfield
- *
- * Each decoder advertises the capabilities it supports as part of its
- * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
- * or functionality, and are not required to be supported by a decoder.
- *
- * The available flags are specified by VPX_CODEC_CAP_* defines.
- */
+ /*! \brief Decoder capabilities bitfield
+ *
+ * Each decoder advertises the capabilities it supports as part of its
+ * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
+ * or functionality, and are not required to be supported by a decoder.
+ *
+ * The available flags are specified by VPX_CODEC_CAP_* defines.
+ */
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
#define VPX_CODEC_CAP_INPUT_PARTITION 0x100000 /**< Can receive encoded frames
- one partition at a time */
-
- /*! \brief Initialization-time Feature Enabling
- *
- * Certain codec features must be known at initialization time, to allow for
- * proper memory allocation.
- *
- * The available flags are specified by VPX_CODEC_USE_* defines.
- */
+ one partition at a time */
+
+ /*! \brief Initialization-time Feature Enabling
+ *
+ * Certain codec features must be known at initialization time, to allow for
+ * proper memory allocation.
+ *
+ * The available flags are specified by VPX_CODEC_USE_* defines.
+ */
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
#define VPX_CODEC_USE_INPUT_PARTITION 0x40000 /**< The input frame should be
- passed to the decoder one
- partition at a time */
-
- /*!\brief Stream properties
- *
- * This structure is used to query or set properties of the decoded
- * stream. Algorithms may extend this structure with data specific
- * to their bitstream by setting the sz member appropriately.
- */
- typedef struct vpx_codec_stream_info
- {
- unsigned int sz; /**< Size of this structure */
- unsigned int w; /**< Width (or 0 for unknown/default) */
- unsigned int h; /**< Height (or 0 for unknown/default) */
- unsigned int is_kf; /**< Current frame is a keyframe */
- } vpx_codec_stream_info_t;
-
- /* REQUIRED FUNCTIONS
- *
- * The following functions are required to be implemented for all decoders.
- * They represent the base case functionality expected of all decoders.
- */
-
-
- /*!\brief Initialization Configurations
- *
- * This structure is used to pass init time configuration options to the
- * decoder.
- */
- typedef struct vpx_codec_dec_cfg
- {
- unsigned int threads; /**< Maximum number of threads to use, default 1 */
- unsigned int w; /**< Width */
- unsigned int h; /**< Height */
- } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
-
-
- /*!\brief Initialize a decoder instance
- *
- * Initializes a decoder context using the given interface. Applications
- * should call the vpx_codec_dec_init convenience macro instead of this
- * function directly, to ensure that the ABI version number parameter
- * is properly initialized.
- *
- * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
- * parameter), the storage pointed to by the cfg parameter must be
- * kept readable and stable until all memory maps have been set.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] iface Pointer to the algorithm interface to use.
- * \param[in] cfg Configuration to use, if known. May be NULL.
- * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
- * \param[in] ver ABI version number. Must be set to
- * VPX_DECODER_ABI_VERSION
- * \retval #VPX_CODEC_OK
- * The decoder algorithm initialized.
- * \retval #VPX_CODEC_MEM_ERROR
- * Memory allocation failed.
- */
- vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
- vpx_codec_iface_t *iface,
- vpx_codec_dec_cfg_t *cfg,
- vpx_codec_flags_t flags,
- int ver);
-
- /*!\brief Convenience macro for vpx_codec_dec_init_ver()
- *
- * Ensures the ABI version parameter is properly set.
- */
+ passed to the decoder one
+ partition at a time */
+
+ /*!\brief Stream properties
+ *
+ * This structure is used to query or set properties of the decoded
+ * stream. Algorithms may extend this structure with data specific
+ * to their bitstream by setting the sz member appropriately.
+ */
+ typedef struct vpx_codec_stream_info {
+ unsigned int sz; /**< Size of this structure */
+ unsigned int w; /**< Width (or 0 for unknown/default) */
+ unsigned int h; /**< Height (or 0 for unknown/default) */
+ unsigned int is_kf; /**< Current frame is a keyframe */
+ } vpx_codec_stream_info_t;
+
+ /* REQUIRED FUNCTIONS
+ *
+ * The following functions are required to be implemented for all decoders.
+ * They represent the base case functionality expected of all decoders.
+ */
+
+
+ /*!\brief Initialization Configurations
+ *
+ * This structure is used to pass init time configuration options to the
+ * decoder.
+ */
+ typedef struct vpx_codec_dec_cfg {
+ unsigned int threads; /**< Maximum number of threads to use, default 1 */
+ unsigned int w; /**< Width */
+ unsigned int h; /**< Height */
+ } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
+
+
+ /*!\brief Initialize a decoder instance
+ *
+ * Initializes a decoder context using the given interface. Applications
+ * should call the vpx_codec_dec_init convenience macro instead of this
+ * function directly, to ensure that the ABI version number parameter
+ * is properly initialized.
+ *
+ * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
+ * parameter), the storage pointed to by the cfg parameter must be
+ * kept readable and stable until all memory maps have been set.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] iface Pointer to the algorithm interface to use.
+ * \param[in] cfg Configuration to use, if known. May be NULL.
+ * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
+ * \param[in] ver ABI version number. Must be set to
+ * VPX_DECODER_ABI_VERSION
+ * \retval #VPX_CODEC_OK
+ * The decoder algorithm initialized.
+ * \retval #VPX_CODEC_MEM_ERROR
+ * Memory allocation failed.
+ */
+ vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
+ vpx_codec_iface_t *iface,
+ vpx_codec_dec_cfg_t *cfg,
+ vpx_codec_flags_t flags,
+ int ver);
+
+ /*!\brief Convenience macro for vpx_codec_dec_init_ver()
+ *
+ * Ensures the ABI version parameter is properly set.
+ */
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
- vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
-
-
- /*!\brief Parse stream info from a buffer
- *
- * Performs high level parsing of the bitstream. Construction of a decoder
- * context is not necessary. Can be used to determine if the bitstream is
- * of the proper format, and to extract information from the stream.
- *
- * \param[in] iface Pointer to the algorithm interface
- * \param[in] data Pointer to a block of data to parse
- * \param[in] data_sz Size of the data buffer
- * \param[in,out] si Pointer to stream info to update. The size member
- * \ref MUST be properly initialized, but \ref MAY be
- * clobbered by the algorithm. This parameter \ref MAY
- * be NULL.
- *
- * \retval #VPX_CODEC_OK
- * Bitstream is parsable and stream information updated
- */
- vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
- const uint8_t *data,
- unsigned int data_sz,
- vpx_codec_stream_info_t *si);
-
-
- /*!\brief Return information about the current stream.
- *
- * Returns information about the stream that has been parsed during decoding.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in,out] si Pointer to stream info to update. The size member
- * \ref MUST be properly initialized, but \ref MAY be
- * clobbered by the algorithm. This parameter \ref MAY
- * be NULL.
- *
- * \retval #VPX_CODEC_OK
- * Bitstream is parsable and stream information updated
- */
- vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
- vpx_codec_stream_info_t *si);
-
-
- /*!\brief Decode data
- *
- * Processes a buffer of coded data. If the processing results in a new
- * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
- * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
- * time stamp) order. Frames produced will always be in PTS (presentation
- * time stamp) order.
- * If the decoder is configured with VPX_CODEC_USE_INPUT_PARTITION enabled,
- * data and data_sz must contain at most one encoded partition. When no more
- * data is available, this function should be called with NULL as data and 0
- * as data_sz. The memory passed to this function must be available until
- * the frame has been decoded.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] data Pointer to this block of new coded data. If
- * NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
- * for the previously decoded frame.
- * \param[in] data_sz Size of the coded data, in bytes.
- * \param[in] user_priv Application specific data to associate with
- * this frame.
- * \param[in] deadline Soft deadline the decoder should attempt to meet,
- * in us. Set to zero for unlimited.
- *
- * \return Returns #VPX_CODEC_OK if the coded data was processed completely
- * and future pictures can be decoded without error. Otherwise,
- * see the descriptions of the other error codes in ::vpx_codec_err_t
- * for recoverability capabilities.
- */
- vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx,
- const uint8_t *data,
- unsigned int data_sz,
- void *user_priv,
- long deadline);
-
-
- /*!\brief Decoded frames iterator
- *
- * Iterates over a list of the frames available for display. The iterator
- * storage should be initialized to NULL to start the iteration. Iteration is
- * complete when this function returns NULL.
- *
- * The list of available frames becomes valid upon completion of the
- * vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in,out] iter Iterator storage, initialized to NULL
- *
- * \return Returns a pointer to an image, if one is ready for display. Frames
- * produced will always be in PTS (presentation time stamp) order.
- */
- vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx,
- vpx_codec_iter_t *iter);
-
-
- /*!\defgroup cap_put_frame Frame-Based Decoding Functions
- *
- * The following functions are required to be implemented for all decoders
- * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_CODEC_ERROR
- * @{
- */
-
- /*!\brief put frame callback prototype
- *
- * This callback is invoked by the decoder to notify the application of
- * the availability of decoded image data.
- */
- typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
- const vpx_image_t *img);
-
-
- /*!\brief Register for notification of frame completion.
- *
- * Registers a given function to be called when a decoded frame is
- * available.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] cb Pointer to the callback function
- * \param[in] user_priv User's private data
- *
- * \retval #VPX_CODEC_OK
- * Callback successfully registered.
- * \retval #VPX_CODEC_ERROR
- * Decoder context not initialized, or algorithm not capable of
- * posting slice completion.
- */
- vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
- vpx_codec_put_frame_cb_fn_t cb,
- void *user_priv);
-
-
- /*!@} - end defgroup cap_put_frame */
-
- /*!\defgroup cap_put_slice Slice-Based Decoding Functions
- *
- * The following functions are required to be implemented for all decoders
- * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_CODEC_ERROR
- * @{
- */
-
- /*!\brief put slice callback prototype
- *
- * This callback is invoked by the decoder to notify the application of
- * the availability of partially decoded image data. The
- */
- typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
- const vpx_image_t *img,
- const vpx_image_rect_t *valid,
- const vpx_image_rect_t *update);
-
-
- /*!\brief Register for notification of slice completion.
- *
- * Registers a given function to be called when a decoded slice is
- * available.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] cb Pointer to the callback function
- * \param[in] user_priv User's private data
- *
- * \retval #VPX_CODEC_OK
- * Callback successfully registered.
- * \retval #VPX_CODEC_ERROR
- * Decoder context not initialized, or algorithm not capable of
- * posting slice completion.
- */
- vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
- vpx_codec_put_slice_cb_fn_t cb,
- void *user_priv);
-
-
- /*!@} - end defgroup cap_put_slice*/
-
- /*!@} - end defgroup decoder*/
+ vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
+
+
+ /*!\brief Parse stream info from a buffer
+ *
+ * Performs high level parsing of the bitstream. Construction of a decoder
+ * context is not necessary. Can be used to determine if the bitstream is
+ * of the proper format, and to extract information from the stream.
+ *
+ * \param[in] iface Pointer to the algorithm interface
+ * \param[in] data Pointer to a block of data to parse
+ * \param[in] data_sz Size of the data buffer
+ * \param[in,out] si Pointer to stream info to update. The size member
+ * \ref MUST be properly initialized, but \ref MAY be
+ * clobbered by the algorithm. This parameter \ref MAY
+ * be NULL.
+ *
+ * \retval #VPX_CODEC_OK
+ * Bitstream is parsable and stream information updated
+ */
+ vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
+ const uint8_t *data,
+ unsigned int data_sz,
+ vpx_codec_stream_info_t *si);
+
+
+ /*!\brief Return information about the current stream.
+ *
+ * Returns information about the stream that has been parsed during decoding.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in,out] si Pointer to stream info to update. The size member
+ * \ref MUST be properly initialized, but \ref MAY be
+ * clobbered by the algorithm. This parameter \ref MAY
+ * be NULL.
+ *
+ * \retval #VPX_CODEC_OK
+ * Bitstream is parsable and stream information updated
+ */
+ vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
+ vpx_codec_stream_info_t *si);
+
+
+ /*!\brief Decode data
+ *
+ * Processes a buffer of coded data. If the processing results in a new
+ * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
+ * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
+ * time stamp) order. Frames produced will always be in PTS (presentation
+ * time stamp) order.
+ * If the decoder is configured with VPX_CODEC_USE_INPUT_PARTITION enabled,
+ * data and data_sz must contain at most one encoded partition. When no more
+ * data is available, this function should be called with NULL as data and 0
+ * as data_sz. The memory passed to this function must be available until
+ * the frame has been decoded.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] data Pointer to this block of new coded data. If
+ * NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
+ * for the previously decoded frame.
+ * \param[in] data_sz Size of the coded data, in bytes.
+ * \param[in] user_priv Application specific data to associate with
+ * this frame.
+ * \param[in] deadline Soft deadline the decoder should attempt to meet,
+ * in us. Set to zero for unlimited.
+ *
+ * \return Returns #VPX_CODEC_OK if the coded data was processed completely
+ * and future pictures can be decoded without error. Otherwise,
+ * see the descriptions of the other error codes in ::vpx_codec_err_t
+ * for recoverability capabilities.
+ */
+ vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx,
+ const uint8_t *data,
+ unsigned int data_sz,
+ void *user_priv,
+ long deadline);
+
+
+ /*!\brief Decoded frames iterator
+ *
+ * Iterates over a list of the frames available for display. The iterator
+ * storage should be initialized to NULL to start the iteration. Iteration is
+ * complete when this function returns NULL.
+ *
+ * The list of available frames becomes valid upon completion of the
+ * vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in,out] iter Iterator storage, initialized to NULL
+ *
+ * \return Returns a pointer to an image, if one is ready for display. Frames
+ * produced will always be in PTS (presentation time stamp) order.
+ */
+ vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx,
+ vpx_codec_iter_t *iter);
+
+
+ /*!\defgroup cap_put_frame Frame-Based Decoding Functions
+ *
+ * The following functions are required to be implemented for all decoders
+ * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_CODEC_ERROR
+ * @{
+ */
+
+ /*!\brief put frame callback prototype
+ *
+ * This callback is invoked by the decoder to notify the application of
+ * the availability of decoded image data.
+ */
+ typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
+ const vpx_image_t *img);
+
+
+ /*!\brief Register for notification of frame completion.
+ *
+ * Registers a given function to be called when a decoded frame is
+ * available.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] cb Pointer to the callback function
+ * \param[in] user_priv User's private data
+ *
+ * \retval #VPX_CODEC_OK
+ * Callback successfully registered.
+ * \retval #VPX_CODEC_ERROR
+ * Decoder context not initialized, or algorithm not capable of
+ * posting slice completion.
+ */
+ vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
+ vpx_codec_put_frame_cb_fn_t cb,
+ void *user_priv);
+
+
+ /*!@} - end defgroup cap_put_frame */
+
+ /*!\defgroup cap_put_slice Slice-Based Decoding Functions
+ *
+ * The following functions are required to be implemented for all decoders
+ * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_CODEC_ERROR
+ * @{
+ */
+
+ /*!\brief put slice callback prototype
+ *
+ * This callback is invoked by the decoder to notify the application of
+ * the availability of partially decoded image data. The
+ */
+ typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
+ const vpx_image_t *img,
+ const vpx_image_rect_t *valid,
+ const vpx_image_rect_t *update);
+
+
+ /*!\brief Register for notification of slice completion.
+ *
+ * Registers a given function to be called when a decoded slice is
+ * available.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] cb Pointer to the callback function
+ * \param[in] user_priv User's private data
+ *
+ * \retval #VPX_CODEC_OK
+ * Callback successfully registered.
+ * \retval #VPX_CODEC_ERROR
+ * Decoder context not initialized, or algorithm not capable of
+ * posting slice completion.
+ */
+ vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
+ vpx_codec_put_slice_cb_fn_t cb,
+ void *user_priv);
+
+
+ /*!@} - end defgroup cap_put_slice*/
+
+ /*!@} - end defgroup decoder*/
#endif
diff --git a/vpx/vpx_decoder_compat.h b/vpx/vpx_decoder_compat.h
index 8adc1b998..c657ef9d9 100644
--- a/vpx/vpx_decoder_compat.h
+++ b/vpx/vpx_decoder_compat.h
@@ -30,555 +30,552 @@ extern "C" {
#ifndef VPX_DECODER_COMPAT_H
#define VPX_DECODER_COMPAT_H
- /*!\brief Decoder algorithm return codes */
- typedef enum {
- /*!\brief Operation completed without error */
- VPX_DEC_OK = VPX_CODEC_OK,
-
- /*!\brief Unspecified error */
- VPX_DEC_ERROR = VPX_CODEC_ERROR,
-
- /*!\brief Memory operation failed */
- VPX_DEC_MEM_ERROR = VPX_CODEC_MEM_ERROR,
-
- /*!\brief ABI version mismatch */
- VPX_DEC_ABI_MISMATCH = VPX_CODEC_ABI_MISMATCH,
-
- /*!\brief The given bitstream is not supported.
- *
- * The bitstream was unable to be parsed at the highest level. The decoder
- * is unable to proceed. This error \ref SHOULD be treated as fatal to the
- * stream. */
- VPX_DEC_UNSUP_BITSTREAM = VPX_CODEC_UNSUP_BITSTREAM,
-
- /*!\brief Encoded bitstream uses an unsupported feature
- *
- * The decoder does not implement a feature required by the encoder. This
- * return code should only be used for features that prevent future
- * pictures from being properly decoded. This error \ref MAY be treated as
- * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
- */
- VPX_DEC_UNSUP_FEATURE = VPX_CODEC_UNSUP_FEATURE,
-
- /*!\brief The coded data for this stream is corrupt or incomplete
- *
- * There was a problem decoding the current frame. This return code
- * should only be used for failures that prevent future pictures from
- * being properly decoded. This error \ref MAY be treated as fatal to the
- * stream or \ref MAY be treated as fatal to the current GOP. If decoding
- * is continued for the current GOP, artifacts may be present.
- */
- VPX_DEC_CORRUPT_FRAME = VPX_CODEC_CORRUPT_FRAME,
-
- /*!\brief An application-supplied parameter is not valid.
- *
- */
- VPX_DEC_INVALID_PARAM = VPX_CODEC_INVALID_PARAM,
-
- /*!\brief An iterator reached the end of list.
- *
- */
- VPX_DEC_LIST_END = VPX_CODEC_LIST_END
-
- }
- vpx_dec_err_t;
-
- /*! \brief Decoder capabilities bitfield
- *
- * Each decoder advertises the capabilities it supports as part of its
- * ::vpx_dec_iface_t interface structure. Capabilities are extra interfaces
- * or functionality, and are not required to be supported by a decoder.
- *
- * The available flags are specified by VPX_DEC_CAP_* defines.
- */
- typedef int vpx_dec_caps_t;
-#define VPX_DEC_CAP_PUT_SLICE 0x0001 /**< Will issue put_slice callbacks */
-#define VPX_DEC_CAP_PUT_FRAME 0x0002 /**< Will issue put_frame callbacks */
-#define VPX_DEC_CAP_XMA 0x0004 /**< Supports eXternal Memory Allocation */
+ /*!\brief Decoder algorithm return codes */
+ typedef enum {
+ /*!\brief Operation completed without error */
+ VPX_DEC_OK = VPX_CODEC_OK,
- /*!\brief Stream properties
- *
- * This structure is used to query or set properties of the decoded
- * stream. Algorithms may extend this structure with data specific
- * to their bitstream by setting the sz member appropriately.
- */
-#if 1
- typedef vpx_codec_stream_info_t vpx_dec_stream_info_t;
-#else
- typedef struct
- {
- unsigned int sz; /**< Size of this structure */
- unsigned int w; /**< Width (or 0 for unknown/default) */
- unsigned int h; /**< Height (or 0 for unknown/default) */
- unsigned int is_kf; /**< Current frame is a keyframe */
- } vpx_dec_stream_info_t;
-#endif
+ /*!\brief Unspecified error */
+ VPX_DEC_ERROR = VPX_CODEC_ERROR,
+ /*!\brief Memory operation failed */
+ VPX_DEC_MEM_ERROR = VPX_CODEC_MEM_ERROR,
- /*!\brief Decoder interface structure.
- *
- * Contains function pointers and other data private to the decoder
- * implementation. This structure is opaque to the application.
- */
- typedef const struct vpx_codec_iface vpx_dec_iface_t;
- typedef struct vpx_codec_priv vpx_dec_priv_t;
+ /*!\brief ABI version mismatch */
+ VPX_DEC_ABI_MISMATCH = VPX_CODEC_ABI_MISMATCH,
- /*!\brief Iterator
+ /*!\brief The given bitstream is not supported.
*
- * Opaque storage used for iterating over lists.
- */
- typedef vpx_codec_iter_t vpx_dec_iter_t;
+ * The bitstream was unable to be parsed at the highest level. The decoder
+ * is unable to proceed. This error \ref SHOULD be treated as fatal to the
+ * stream. */
+ VPX_DEC_UNSUP_BITSTREAM = VPX_CODEC_UNSUP_BITSTREAM,
- /*!\brief Decoder context structure
+ /*!\brief Encoded bitstream uses an unsupported feature
*
- * All decoders \ref MUST support this context structure fully. In general,
- * this data should be considered private to the decoder algorithm, and
- * not be manipulated or examined by the calling application. Applications
- * may reference the 'name' member to get a printable description of the
- * algorithm.
+ * The decoder does not implement a feature required by the encoder. This
+ * return code should only be used for features that prevent future
+ * pictures from being properly decoded. This error \ref MAY be treated as
+ * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
*/
-#if 1
- typedef vpx_codec_ctx_t vpx_dec_ctx_t;
-#else
- typedef struct
- {
- const char *name; /**< Printable interface name */
- vpx_dec_iface_t *iface; /**< Interface pointers */
- vpx_dec_err_t err; /**< Last returned error */
- vpx_dec_priv_t *priv; /**< Algorithm private storage */
- } vpx_dec_ctx_t;
-#endif
+ VPX_DEC_UNSUP_FEATURE = VPX_CODEC_UNSUP_FEATURE,
-
- /*!\brief Return the build configuration
- *
- * Returns a printable string containing an encoded version of the build
- * configuration. This may be useful to vpx support.
+ /*!\brief The coded data for this stream is corrupt or incomplete
*
+ * There was a problem decoding the current frame. This return code
+ * should only be used for failures that prevent future pictures from
+ * being properly decoded. This error \ref MAY be treated as fatal to the
+ * stream or \ref MAY be treated as fatal to the current GOP. If decoding
+ * is continued for the current GOP, artifacts may be present.
*/
- const char *vpx_dec_build_config(void) DEPRECATED;
+ VPX_DEC_CORRUPT_FRAME = VPX_CODEC_CORRUPT_FRAME,
- /*!\brief Return the name for a given interface
- *
- * Returns a human readable string for name of the given decoder interface.
- *
- * \param[in] iface Interface pointer
- *
- */
- const char *vpx_dec_iface_name(vpx_dec_iface_t *iface) DEPRECATED;
-
-
- /*!\brief Convert error number to printable string
- *
- * Returns a human readable string for the last error returned by the
- * algorithm. The returned error will be one line and will not contain
- * any newline characters.
- *
- *
- * \param[in] err Error number.
+ /*!\brief An application-supplied parameter is not valid.
*
*/
- const char *vpx_dec_err_to_string(vpx_dec_err_t err) DEPRECATED;
+ VPX_DEC_INVALID_PARAM = VPX_CODEC_INVALID_PARAM,
-
- /*!\brief Retrieve error synopsis for decoder context
- *
- * Returns a human readable string for the last error returned by the
- * algorithm. The returned error will be one line and will not contain
- * any newline characters.
- *
- *
- * \param[in] ctx Pointer to this instance's context.
+ /*!\brief An iterator reached the end of list.
*
*/
- const char *vpx_dec_error(vpx_dec_ctx_t *ctx) DEPRECATED;
-
+ VPX_DEC_LIST_END = VPX_CODEC_LIST_END
+
+ }
+ vpx_dec_err_t;
+
+ /*! \brief Decoder capabilities bitfield
+ *
+ * Each decoder advertises the capabilities it supports as part of its
+ * ::vpx_dec_iface_t interface structure. Capabilities are extra interfaces
+ * or functionality, and are not required to be supported by a decoder.
+ *
+ * The available flags are specified by VPX_DEC_CAP_* defines.
+ */
+ typedef int vpx_dec_caps_t;
+#define VPX_DEC_CAP_PUT_SLICE 0x0001 /**< Will issue put_slice callbacks */
+#define VPX_DEC_CAP_PUT_FRAME 0x0002 /**< Will issue put_frame callbacks */
+#define VPX_DEC_CAP_XMA 0x0004 /**< Supports eXternal Memory Allocation */
- /*!\brief Retrieve detailed error information for decoder context
- *
- * Returns a human readable string providing detailed information about
- * the last error.
- *
- * \param[in] ctx Pointer to this instance's context.
- *
- * \retval NULL
- * No detailed information is available.
- */
- const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx) DEPRECATED;
+ /*!\brief Stream properties
+ *
+ * This structure is used to query or set properties of the decoded
+ * stream. Algorithms may extend this structure with data specific
+ * to their bitstream by setting the sz member appropriately.
+ */
+#if 1
+ typedef vpx_codec_stream_info_t vpx_dec_stream_info_t;
+#else
+ typedef struct {
+ unsigned int sz; /**< Size of this structure */
+ unsigned int w; /**< Width (or 0 for unknown/default) */
+ unsigned int h; /**< Height (or 0 for unknown/default) */
+ unsigned int is_kf; /**< Current frame is a keyframe */
+ } vpx_dec_stream_info_t;
+#endif
- /* REQUIRED FUNCTIONS
- *
- * The following functions are required to be implemented for all decoders.
- * They represent the base case functionality expected of all decoders.
- */
+ /*!\brief Decoder interface structure.
+ *
+ * Contains function pointers and other data private to the decoder
+ * implementation. This structure is opaque to the application.
+ */
+ typedef const struct vpx_codec_iface vpx_dec_iface_t;
+ typedef struct vpx_codec_priv vpx_dec_priv_t;
+
+ /*!\brief Iterator
+ *
+ * Opaque storage used for iterating over lists.
+ */
+ typedef vpx_codec_iter_t vpx_dec_iter_t;
+
+ /*!\brief Decoder context structure
+ *
+ * All decoders \ref MUST support this context structure fully. In general,
+ * this data should be considered private to the decoder algorithm, and
+ * not be manipulated or examined by the calling application. Applications
+ * may reference the 'name' member to get a printable description of the
+ * algorithm.
+ */
+#if 1
+ typedef vpx_codec_ctx_t vpx_dec_ctx_t;
+#else
+ typedef struct {
+ const char *name; /**< Printable interface name */
+ vpx_dec_iface_t *iface; /**< Interface pointers */
+ vpx_dec_err_t err; /**< Last returned error */
+ vpx_dec_priv_t *priv; /**< Algorithm private storage */
+ } vpx_dec_ctx_t;
+#endif
- /*!\brief Initialize a decoder instance
- *
- * Initializes a decoder context using the given interface. Applications
- * should call the vpx_dec_init convenience macro instead of this
- * function directly, to ensure that the ABI version number parameter
- * is properly initialized.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] iface Pointer to the algorithm interface to use.
- * \param[in] ver ABI version number. Must be set to
- * VPX_DECODER_ABI_VERSION
- * \retval #VPX_DEC_OK
- * The decoder algorithm initialized.
- * \retval #VPX_DEC_MEM_ERROR
- * Memory allocation failed.
- */
- vpx_dec_err_t vpx_dec_init_ver(vpx_dec_ctx_t *ctx,
- vpx_dec_iface_t *iface,
- int ver) DEPRECATED;
+ /*!\brief Return the build configuration
+ *
+ * Returns a printable string containing an encoded version of the build
+ * configuration. This may be useful to vpx support.
+ *
+ */
+ const char *vpx_dec_build_config(void) DEPRECATED;
+
+ /*!\brief Return the name for a given interface
+ *
+ * Returns a human readable string for name of the given decoder interface.
+ *
+ * \param[in] iface Interface pointer
+ *
+ */
+ const char *vpx_dec_iface_name(vpx_dec_iface_t *iface) DEPRECATED;
+
+
+ /*!\brief Convert error number to printable string
+ *
+ * Returns a human readable string for the last error returned by the
+ * algorithm. The returned error will be one line and will not contain
+ * any newline characters.
+ *
+ *
+ * \param[in] err Error number.
+ *
+ */
+ const char *vpx_dec_err_to_string(vpx_dec_err_t err) DEPRECATED;
+
+
+ /*!\brief Retrieve error synopsis for decoder context
+ *
+ * Returns a human readable string for the last error returned by the
+ * algorithm. The returned error will be one line and will not contain
+ * any newline characters.
+ *
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ *
+ */
+ const char *vpx_dec_error(vpx_dec_ctx_t *ctx) DEPRECATED;
+
+
+ /*!\brief Retrieve detailed error information for decoder context
+ *
+ * Returns a human readable string providing detailed information about
+ * the last error.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ *
+ * \retval NULL
+ * No detailed information is available.
+ */
+ const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx) DEPRECATED;
+
+
+ /* REQUIRED FUNCTIONS
+ *
+ * The following functions are required to be implemented for all decoders.
+ * They represent the base case functionality expected of all decoders.
+ */
+
+
+ /*!\brief Initialize a decoder instance
+ *
+ * Initializes a decoder context using the given interface. Applications
+ * should call the vpx_dec_init convenience macro instead of this
+ * function directly, to ensure that the ABI version number parameter
+ * is properly initialized.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] iface Pointer to the algorithm interface to use.
+ * \param[in] ver ABI version number. Must be set to
+ * VPX_DECODER_ABI_VERSION
+ * \retval #VPX_DEC_OK
+ * The decoder algorithm initialized.
+ * \retval #VPX_DEC_MEM_ERROR
+ * Memory allocation failed.
+ */
+ vpx_dec_err_t vpx_dec_init_ver(vpx_dec_ctx_t *ctx,
+ vpx_dec_iface_t *iface,
+ int ver) DEPRECATED;
#define vpx_dec_init(ctx, iface) \
- vpx_dec_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION)
-
-
- /*!\brief Destroy a decoder instance
- *
- * Destroys a decoder context, freeing any associated memory buffers.
- *
- * \param[in] ctx Pointer to this instance's context
- *
- * \retval #VPX_DEC_OK
- * The decoder algorithm initialized.
- * \retval #VPX_DEC_MEM_ERROR
- * Memory allocation failed.
- */
- vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx) DEPRECATED;
-
-
- /*!\brief Get the capabilities of an algorithm.
- *
- * Retrieves the capabilities bitfield from the algorithm's interface.
- *
- * \param[in] iface Pointer to the algorithm interface
- *
- */
- vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface) DEPRECATED;
-
-
- /*!\brief Parse stream info from a buffer
- *
- * Performs high level parsing of the bitstream. Construction of a decoder
- * context is not necessary. Can be used to determine if the bitstream is
- * of the proper format, and to extract information from the stream.
- *
- * \param[in] iface Pointer to the algorithm interface
- * \param[in] data Pointer to a block of data to parse
- * \param[in] data_sz Size of the data buffer
- * \param[in,out] si Pointer to stream info to update. The size member
- * \ref MUST be properly initialized, but \ref MAY be
- * clobbered by the algorithm. This parameter \ref MAY
- * be NULL.
- *
- * \retval #VPX_DEC_OK
- * Bitstream is parsable and stream information updated
- */
- vpx_dec_err_t vpx_dec_peek_stream_info(vpx_dec_iface_t *iface,
- const uint8_t *data,
- unsigned int data_sz,
- vpx_dec_stream_info_t *si) DEPRECATED;
-
-
- /*!\brief Return information about the current stream.
- *
- * Returns information about the stream that has been parsed during decoding.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in,out] si Pointer to stream info to update. The size member
- * \ref MUST be properly initialized, but \ref MAY be
- * clobbered by the algorithm. This parameter \ref MAY
- * be NULL.
- *
- * \retval #VPX_DEC_OK
- * Bitstream is parsable and stream information updated
- */
- vpx_dec_err_t vpx_dec_get_stream_info(vpx_dec_ctx_t *ctx,
- vpx_dec_stream_info_t *si) DEPRECATED;
-
-
- /*!\brief Control algorithm
- *
- * This function is used to exchange algorithm specific data with the decoder
- * instance. This can be used to implement features specific to a particular
- * algorithm.
- *
- * This wrapper function dispatches the request to the helper function
- * associated with the given ctrl_id. It tries to call this function
- * transparently, but will return #VPX_DEC_ERROR if the request could not
- * be dispatched.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] ctrl_id Algorithm specific control identifier
- * \param[in,out] data Data to exchange with algorithm instance.
- *
- * \retval #VPX_DEC_OK
- * The control request was processed.
- * \retval #VPX_DEC_ERROR
- * The control request was not processed.
- * \retval #VPX_DEC_INVALID_PARAM
- * The data was not valid.
- */
- vpx_dec_err_t vpx_dec_control(vpx_dec_ctx_t *ctx,
- int ctrl_id,
- void *data) DEPRECATED;
-
- /*!\brief Decode data
- *
- * Processes a buffer of coded data. If the processing results in a new
- * decoded frame becoming available, #VPX_DEC_CB_PUT_SLICE and
- * #VPX_DEC_CB_PUT_FRAME events may be generated, as appropriate. Encoded data
- * \ref MUST be passed in DTS (decode time stamp) order. Frames produced will
- * always be in PTS (presentation time stamp) order.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] data Pointer to this block of new coded data. If
- * NULL, a VPX_DEC_CB_PUT_FRAME event is posted
- * for the previously decoded frame.
- * \param[in] data_sz Size of the coded data, in bytes.
- * \param[in] user_priv Application specific data to associate with
- * this frame.
- * \param[in] rel_pts PTS relative to the previous frame, in us. If
- * unknown or unavailable, set to zero.
- *
- * \return Returns #VPX_DEC_OK if the coded data was processed completely
- * and future pictures can be decoded without error. Otherwise,
- * see the descriptions of the other error codes in ::vpx_dec_err_t
- * for recoverability capabilities.
- */
- vpx_dec_err_t vpx_dec_decode(vpx_dec_ctx_t *ctx,
- uint8_t *data,
- unsigned int data_sz,
- void *user_priv,
- int rel_pts) DEPRECATED;
-
-
- /*!\brief Decoded frames iterator
- *
- * Iterates over a list of the frames available for display. The iterator
- * storage should be initialized to NULL to start the iteration. Iteration is
- * complete when this function returns NULL.
- *
- * The list of available frames becomes valid upon completion of the
- * vpx_dec_decode call, and remains valid until the next call to vpx_dec_decode.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in out] iter Iterator storage, initialized to NULL
- *
- * \return Returns a pointer to an image, if one is ready for display. Frames
- * produced will always be in PTS (presentation time stamp) order.
- */
- vpx_image_t *vpx_dec_get_frame(vpx_dec_ctx_t *ctx,
- vpx_dec_iter_t *iter) DEPRECATED;
-
-
- /*!\defgroup cap_put_frame Frame-Based Decoding Functions
- *
- * The following functions are required to be implemented for all decoders
- * that advertise the VPX_DEC_CAP_PUT_FRAME capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_DEC_ERROR
- * @{
- */
-
- /*!\brief put frame callback prototype
- *
- * This callback is invoked by the decoder to notify the application of
- * the availability of decoded image data.
- */
- typedef void (*vpx_dec_put_frame_cb_fn_t)(void *user_priv,
- const vpx_image_t *img);
-
-
- /*!\brief Register for notification of frame completion.
- *
- * Registers a given function to be called when a decoded frame is
- * available.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] cb Pointer to the callback function
- * \param[in] user_priv User's private data
- *
- * \retval #VPX_DEC_OK
- * Callback successfully registered.
- * \retval #VPX_DEC_ERROR
- * Decoder context not initialized, or algorithm not capable of
- * posting slice completion.
- */
- vpx_dec_err_t vpx_dec_register_put_frame_cb(vpx_dec_ctx_t *ctx,
- vpx_dec_put_frame_cb_fn_t cb,
- void *user_priv) DEPRECATED;
-
-
- /*!@} - end defgroup cap_put_frame */
-
- /*!\defgroup cap_put_slice Slice-Based Decoding Functions
- *
- * The following functions are required to be implemented for all decoders
- * that advertise the VPX_DEC_CAP_PUT_SLICE capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_DEC_ERROR
- * @{
- */
-
- /*!\brief put slice callback prototype
- *
- * This callback is invoked by the decoder to notify the application of
- * the availability of partially decoded image data. The
- */
- typedef void (*vpx_dec_put_slice_cb_fn_t)(void *user_priv,
- const vpx_image_t *img,
- const vpx_image_rect_t *valid,
- const vpx_image_rect_t *update);
-
-
- /*!\brief Register for notification of slice completion.
- *
- * Registers a given function to be called when a decoded slice is
- * available.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] cb Pointer to the callback function
- * \param[in] user_priv User's private data
- *
- * \retval #VPX_DEC_OK
- * Callback successfully registered.
- * \retval #VPX_DEC_ERROR
- * Decoder context not initialized, or algorithm not capable of
- * posting slice completion.
- */
- vpx_dec_err_t vpx_dec_register_put_slice_cb(vpx_dec_ctx_t *ctx,
- vpx_dec_put_slice_cb_fn_t cb,
- void *user_priv) DEPRECATED;
-
-
- /*!@} - end defgroup cap_put_slice*/
-
- /*!\defgroup cap_xma External Memory Allocation Functions
- *
- * The following functions are required to be implemented for all decoders
- * that advertise the VPX_DEC_CAP_XMA capability. Calling these functions
- * for codecs that don't advertise this capability will result in an error
- * code being returned, usually VPX_DEC_ERROR
- * @{
- */
-
- /*!\brief Memory Map Entry
- *
- * This structure is used to contain the properties of a memory segment. It
- * is populated by the decoder in the request phase, and by the calling
- * application once the requested allocation has been performed.
- */
+ vpx_dec_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION)
+
+
+ /*!\brief Destroy a decoder instance
+ *
+ * Destroys a decoder context, freeing any associated memory buffers.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ *
+ * \retval #VPX_DEC_OK
+ * The decoder algorithm initialized.
+ * \retval #VPX_DEC_MEM_ERROR
+ * Memory allocation failed.
+ */
+ vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx) DEPRECATED;
+
+
+ /*!\brief Get the capabilities of an algorithm.
+ *
+ * Retrieves the capabilities bitfield from the algorithm's interface.
+ *
+ * \param[in] iface Pointer to the algorithm interface
+ *
+ */
+ vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface) DEPRECATED;
+
+
+ /*!\brief Parse stream info from a buffer
+ *
+ * Performs high level parsing of the bitstream. Construction of a decoder
+ * context is not necessary. Can be used to determine if the bitstream is
+ * of the proper format, and to extract information from the stream.
+ *
+ * \param[in] iface Pointer to the algorithm interface
+ * \param[in] data Pointer to a block of data to parse
+ * \param[in] data_sz Size of the data buffer
+ * \param[in,out] si Pointer to stream info to update. The size member
+ * \ref MUST be properly initialized, but \ref MAY be
+ * clobbered by the algorithm. This parameter \ref MAY
+ * be NULL.
+ *
+ * \retval #VPX_DEC_OK
+ * Bitstream is parsable and stream information updated
+ */
+ vpx_dec_err_t vpx_dec_peek_stream_info(vpx_dec_iface_t *iface,
+ const uint8_t *data,
+ unsigned int data_sz,
+ vpx_dec_stream_info_t *si) DEPRECATED;
+
+
+ /*!\brief Return information about the current stream.
+ *
+ * Returns information about the stream that has been parsed during decoding.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in,out] si Pointer to stream info to update. The size member
+ * \ref MUST be properly initialized, but \ref MAY be
+ * clobbered by the algorithm. This parameter \ref MAY
+ * be NULL.
+ *
+ * \retval #VPX_DEC_OK
+ * Bitstream is parsable and stream information updated
+ */
+ vpx_dec_err_t vpx_dec_get_stream_info(vpx_dec_ctx_t *ctx,
+ vpx_dec_stream_info_t *si) DEPRECATED;
+
+
+ /*!\brief Control algorithm
+ *
+ * This function is used to exchange algorithm specific data with the decoder
+ * instance. This can be used to implement features specific to a particular
+ * algorithm.
+ *
+ * This wrapper function dispatches the request to the helper function
+ * associated with the given ctrl_id. It tries to call this function
+ * transparently, but will return #VPX_DEC_ERROR if the request could not
+ * be dispatched.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] ctrl_id Algorithm specific control identifier
+ * \param[in,out] data Data to exchange with algorithm instance.
+ *
+ * \retval #VPX_DEC_OK
+ * The control request was processed.
+ * \retval #VPX_DEC_ERROR
+ * The control request was not processed.
+ * \retval #VPX_DEC_INVALID_PARAM
+ * The data was not valid.
+ */
+ vpx_dec_err_t vpx_dec_control(vpx_dec_ctx_t *ctx,
+ int ctrl_id,
+ void *data) DEPRECATED;
+
+ /*!\brief Decode data
+ *
+ * Processes a buffer of coded data. If the processing results in a new
+ * decoded frame becoming available, #VPX_DEC_CB_PUT_SLICE and
+ * #VPX_DEC_CB_PUT_FRAME events may be generated, as appropriate. Encoded data
+ * \ref MUST be passed in DTS (decode time stamp) order. Frames produced will
+ * always be in PTS (presentation time stamp) order.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] data Pointer to this block of new coded data. If
+ * NULL, a VPX_DEC_CB_PUT_FRAME event is posted
+ * for the previously decoded frame.
+ * \param[in] data_sz Size of the coded data, in bytes.
+ * \param[in] user_priv Application specific data to associate with
+ * this frame.
+ * \param[in] rel_pts PTS relative to the previous frame, in us. If
+ * unknown or unavailable, set to zero.
+ *
+ * \return Returns #VPX_DEC_OK if the coded data was processed completely
+ * and future pictures can be decoded without error. Otherwise,
+ * see the descriptions of the other error codes in ::vpx_dec_err_t
+ * for recoverability capabilities.
+ */
+ vpx_dec_err_t vpx_dec_decode(vpx_dec_ctx_t *ctx,
+ uint8_t *data,
+ unsigned int data_sz,
+ void *user_priv,
+ int rel_pts) DEPRECATED;
+
+
+ /*!\brief Decoded frames iterator
+ *
+ * Iterates over a list of the frames available for display. The iterator
+ * storage should be initialized to NULL to start the iteration. Iteration is
+ * complete when this function returns NULL.
+ *
+ * The list of available frames becomes valid upon completion of the
+ * vpx_dec_decode call, and remains valid until the next call to vpx_dec_decode.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in out] iter Iterator storage, initialized to NULL
+ *
+ * \return Returns a pointer to an image, if one is ready for display. Frames
+ * produced will always be in PTS (presentation time stamp) order.
+ */
+ vpx_image_t *vpx_dec_get_frame(vpx_dec_ctx_t *ctx,
+ vpx_dec_iter_t *iter) DEPRECATED;
+
+
+ /*!\defgroup cap_put_frame Frame-Based Decoding Functions
+ *
+ * The following functions are required to be implemented for all decoders
+ * that advertise the VPX_DEC_CAP_PUT_FRAME capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_DEC_ERROR
+ * @{
+ */
+
+ /*!\brief put frame callback prototype
+ *
+ * This callback is invoked by the decoder to notify the application of
+ * the availability of decoded image data.
+ */
+ typedef void (*vpx_dec_put_frame_cb_fn_t)(void *user_priv,
+ const vpx_image_t *img);
+
+
+ /*!\brief Register for notification of frame completion.
+ *
+ * Registers a given function to be called when a decoded frame is
+ * available.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] cb Pointer to the callback function
+ * \param[in] user_priv User's private data
+ *
+ * \retval #VPX_DEC_OK
+ * Callback successfully registered.
+ * \retval #VPX_DEC_ERROR
+ * Decoder context not initialized, or algorithm not capable of
+ * posting slice completion.
+ */
+ vpx_dec_err_t vpx_dec_register_put_frame_cb(vpx_dec_ctx_t *ctx,
+ vpx_dec_put_frame_cb_fn_t cb,
+ void *user_priv) DEPRECATED;
+
+
+ /*!@} - end defgroup cap_put_frame */
+
+ /*!\defgroup cap_put_slice Slice-Based Decoding Functions
+ *
+ * The following functions are required to be implemented for all decoders
+ * that advertise the VPX_DEC_CAP_PUT_SLICE capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_DEC_ERROR
+ * @{
+ */
+
+ /*!\brief put slice callback prototype
+ *
+ * This callback is invoked by the decoder to notify the application of
+ * the availability of partially decoded image data. The
+ */
+ typedef void (*vpx_dec_put_slice_cb_fn_t)(void *user_priv,
+ const vpx_image_t *img,
+ const vpx_image_rect_t *valid,
+ const vpx_image_rect_t *update);
+
+
+ /*!\brief Register for notification of slice completion.
+ *
+ * Registers a given function to be called when a decoded slice is
+ * available.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] cb Pointer to the callback function
+ * \param[in] user_priv User's private data
+ *
+ * \retval #VPX_DEC_OK
+ * Callback successfully registered.
+ * \retval #VPX_DEC_ERROR
+ * Decoder context not initialized, or algorithm not capable of
+ * posting slice completion.
+ */
+ vpx_dec_err_t vpx_dec_register_put_slice_cb(vpx_dec_ctx_t *ctx,
+ vpx_dec_put_slice_cb_fn_t cb,
+ void *user_priv) DEPRECATED;
+
+
+ /*!@} - end defgroup cap_put_slice*/
+
+ /*!\defgroup cap_xma External Memory Allocation Functions
+ *
+ * The following functions are required to be implemented for all decoders
+ * that advertise the VPX_DEC_CAP_XMA capability. Calling these functions
+ * for codecs that don't advertise this capability will result in an error
+ * code being returned, usually VPX_DEC_ERROR
+ * @{
+ */
+
+ /*!\brief Memory Map Entry
+ *
+ * This structure is used to contain the properties of a memory segment. It
+ * is populated by the decoder in the request phase, and by the calling
+ * application once the requested allocation has been performed.
+ */
#if 1
#define VPX_DEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */
#define VPX_DEC_MEM_WRONLY 0x2 /**< Segment need not be readable */
#define VPX_DEC_MEM_FAST 0x4 /**< Place in fast memory, if available */
- typedef struct vpx_codec_mmap vpx_dec_mmap_t;
+ typedef struct vpx_codec_mmap vpx_dec_mmap_t;
#else
- typedef struct vpx_dec_mmap
- {
- /*
- * The following members are set by the codec when requesting a segment
- */
- unsigned int id; /**< identifier for the segment's contents */
- unsigned long sz; /**< size of the segment, in bytes */
- unsigned int align; /**< required alignment of the segment, in bytes */
- unsigned int flags; /**< bitfield containing segment properties */
+ typedef struct vpx_dec_mmap {
+ /*
+ * The following members are set by the codec when requesting a segment
+ */
+ unsigned int id; /**< identifier for the segment's contents */
+ unsigned long sz; /**< size of the segment, in bytes */
+ unsigned int align; /**< required alignment of the segment, in bytes */
+ unsigned int flags; /**< bitfield containing segment properties */
#define VPX_DEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */
#define VPX_DEC_MEM_WRONLY 0x2 /**< Segment need not be readable */
#define VPX_DEC_MEM_FAST 0x4 /**< Place in fast memory, if available */
- /* The following members are to be filled in by the allocation function */
- void *base; /**< pointer to the allocated segment */
- void (*dtor)(struct vpx_dec_mmap *map); /**< destructor to call */
- void *priv; /**< allocator private storage */
- } vpx_dec_mmap_t;
+ /* The following members are to be filled in by the allocation function */
+ void *base; /**< pointer to the allocated segment */
+ void (*dtor)(struct vpx_dec_mmap *map); /**< destructor to call */
+ void *priv; /**< allocator private storage */
+ } vpx_dec_mmap_t;
#endif
- /*!\brief Initialize a decoder instance in external allocation mode
- *
- * Initializes a decoder context using the given interface. Applications
- * should call the vpx_dec_xma_init convenience macro instead of this
- * function directly, to ensure that the ABI version number parameter
- * is properly initialized.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] iface Pointer to the algorithm interface to use.
- * \param[in] ver ABI version number. Must be set to
- * VPX_DECODER_ABI_VERSION
- * \retval #VPX_DEC_OK
- * The decoder algorithm initialized.
- * \retval #VPX_DEC_ERROR
- * Decoder does not support XMA mode.
- */
- vpx_dec_err_t vpx_dec_xma_init_ver(vpx_dec_ctx_t *ctx,
- vpx_dec_iface_t *iface,
- int ver) DEPRECATED;
+ /*!\brief Initialize a decoder instance in external allocation mode
+ *
+ * Initializes a decoder context using the given interface. Applications
+ * should call the vpx_dec_xma_init convenience macro instead of this
+ * function directly, to ensure that the ABI version number parameter
+ * is properly initialized.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] iface Pointer to the algorithm interface to use.
+ * \param[in] ver ABI version number. Must be set to
+ * VPX_DECODER_ABI_VERSION
+ * \retval #VPX_DEC_OK
+ * The decoder algorithm initialized.
+ * \retval #VPX_DEC_ERROR
+ * Decoder does not support XMA mode.
+ */
+ vpx_dec_err_t vpx_dec_xma_init_ver(vpx_dec_ctx_t *ctx,
+ vpx_dec_iface_t *iface,
+ int ver) DEPRECATED;
#define vpx_dec_xma_init(ctx, iface) \
- vpx_dec_xma_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION)
-
-
- /*!\brief Iterate over the list of segments to allocate.
- *
- * Iterates over a list of the segments to allocate. The iterator storage
- * should be initialized to NULL to start the iteration. Iteration is complete
- * when this function returns VPX_DEC_LIST_END. The amount of memory needed to
- * allocate is dependent upon the size of the encoded stream. This means that
- * the stream info structure must be known at allocation time. It can be
- * populated with the vpx_dec_peek_stream_info() function. In cases where the
- * stream to be decoded is not available at allocation time, a fixed size must
- * be requested. The decoder will not be able to decode streams larger than
- * the size used at allocation time.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[out] mmap Pointer to the memory map entry to populate.
- * \param[in] si Pointer to the stream info.
- * \param[in out] iter Iterator storage, initialized to NULL
- *
- * \retval #VPX_DEC_OK
- * The memory map entry was populated.
- * \retval #VPX_DEC_ERROR
- * Decoder does not support XMA mode.
- * \retval #VPX_DEC_MEM_ERROR
- * Unable to determine segment size from stream info.
- */
- vpx_dec_err_t vpx_dec_get_mem_map(vpx_dec_ctx_t *ctx,
- vpx_dec_mmap_t *mmap,
- const vpx_dec_stream_info_t *si,
- vpx_dec_iter_t *iter) DEPRECATED;
-
-
- /*!\brief Identify allocated segments to decoder instance
- *
- * Stores a list of allocated segments in the decoder. Segments \ref MUST be
- * passed in the order they are read from vpx_dec_get_mem_map(), but may be
- * passed in groups of any size. Segments \ref MUST be set only once. The
- * allocation function \ref MUST ensure that the vpx_dec_mmap_t::base member
- * is non-NULL. If the segment requires cleanup handling (e.g., calling free()
- * or close()) then the vpx_dec_mmap_t::dtor member \ref MUST be populated.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] mmaps Pointer to the first memory map entry in the list.
- * \param[in] num_maps Number of entries being set at this time
- *
- * \retval #VPX_DEC_OK
- * The segment was stored in the decoder context.
- * \retval #VPX_DEC_ERROR
- * Decoder does not support XMA mode.
- * \retval #VPX_DEC_MEM_ERROR
- * Segment base address was not set, or segment was already stored.
-
- */
- vpx_dec_err_t vpx_dec_set_mem_map(vpx_dec_ctx_t *ctx,
- vpx_dec_mmap_t *mmaps,
- unsigned int num_maps) DEPRECATED;
-
- /*!@} - end defgroup cap_xma*/
- /*!@} - end defgroup decoder*/
+ vpx_dec_xma_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION)
+
+
+ /*!\brief Iterate over the list of segments to allocate.
+ *
+ * Iterates over a list of the segments to allocate. The iterator storage
+ * should be initialized to NULL to start the iteration. Iteration is complete
+ * when this function returns VPX_DEC_LIST_END. The amount of memory needed to
+ * allocate is dependent upon the size of the encoded stream. This means that
+ * the stream info structure must be known at allocation time. It can be
+ * populated with the vpx_dec_peek_stream_info() function. In cases where the
+ * stream to be decoded is not available at allocation time, a fixed size must
+ * be requested. The decoder will not be able to decode streams larger than
+ * the size used at allocation time.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[out] mmap Pointer to the memory map entry to populate.
+ * \param[in] si Pointer to the stream info.
+ * \param[in out] iter Iterator storage, initialized to NULL
+ *
+ * \retval #VPX_DEC_OK
+ * The memory map entry was populated.
+ * \retval #VPX_DEC_ERROR
+ * Decoder does not support XMA mode.
+ * \retval #VPX_DEC_MEM_ERROR
+ * Unable to determine segment size from stream info.
+ */
+ vpx_dec_err_t vpx_dec_get_mem_map(vpx_dec_ctx_t *ctx,
+ vpx_dec_mmap_t *mmap,
+ const vpx_dec_stream_info_t *si,
+ vpx_dec_iter_t *iter) DEPRECATED;
+
+
+ /*!\brief Identify allocated segments to decoder instance
+ *
+ * Stores a list of allocated segments in the decoder. Segments \ref MUST be
+ * passed in the order they are read from vpx_dec_get_mem_map(), but may be
+ * passed in groups of any size. Segments \ref MUST be set only once. The
+ * allocation function \ref MUST ensure that the vpx_dec_mmap_t::base member
+ * is non-NULL. If the segment requires cleanup handling (e.g., calling free()
+ * or close()) then the vpx_dec_mmap_t::dtor member \ref MUST be populated.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] mmaps Pointer to the first memory map entry in the list.
+ * \param[in] num_maps Number of entries being set at this time
+ *
+ * \retval #VPX_DEC_OK
+ * The segment was stored in the decoder context.
+ * \retval #VPX_DEC_ERROR
+ * Decoder does not support XMA mode.
+ * \retval #VPX_DEC_MEM_ERROR
+ * Segment base address was not set, or segment was already stored.
+
+ */
+ vpx_dec_err_t vpx_dec_set_mem_map(vpx_dec_ctx_t *ctx,
+ vpx_dec_mmap_t *mmaps,
+ unsigned int num_maps) DEPRECATED;
+
+ /*!@} - end defgroup cap_xma*/
+ /*!@} - end defgroup decoder*/
#endif
diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h
index 971a4368d..ec7ce4898 100644
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -33,809 +33,798 @@ extern "C" {
#include "vpx_codec.h"
- /*!\brief Current ABI version number
- *
- * \internal
- * If this file is altered in any way that changes the ABI, this value
- * must be bumped. Examples include, but are not limited to, changing
- * types, removing or reassigning enums, adding/removing/rearranging
- * fields to structures
- */
+ /*!\brief Current ABI version number
+ *
+ * \internal
+ * If this file is altered in any way that changes the ABI, this value
+ * must be bumped. Examples include, but are not limited to, changing
+ * types, removing or reassigning enums, adding/removing/rearranging
+ * fields to structures
+ */
#define VPX_ENCODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
- /*! \brief Encoder capabilities bitfield
- *
- * Each encoder advertises the capabilities it supports as part of its
- * ::vpx_codec_iface_t interface structure. Capabilities are extra
- * interfaces or functionality, and are not required to be supported
- * by an encoder.
- *
- * The available flags are specified by VPX_CODEC_CAP_* defines.
- */
+ /*! \brief Encoder capabilities bitfield
+ *
+ * Each encoder advertises the capabilities it supports as part of its
+ * ::vpx_codec_iface_t interface structure. Capabilities are extra
+ * interfaces or functionality, and are not required to be supported
+ * by an encoder.
+ *
+ * The available flags are specified by VPX_CODEC_CAP_* defines.
+ */
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
- /*! Can output one partition at a time. Each partition is returned in its
- * own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
- * every partition but the last. In this mode all frames are always
- * returned partition by partition.
- */
+ /*! Can output one partition at a time. Each partition is returned in its
+ * own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
+ * every partition but the last. In this mode all frames are always
+ * returned partition by partition.
+ */
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
- /*! \brief Initialization-time Feature Enabling
- *
- * Certain codec features must be known at initialization time, to allow
- * for proper memory allocation.
- *
- * The available flags are specified by VPX_CODEC_USE_* defines.
- */
+ /*! \brief Initialization-time Feature Enabling
+ *
+ * Certain codec features must be known at initialization time, to allow
+ * for proper memory allocation.
+ *
+ * The available flags are specified by VPX_CODEC_USE_* defines.
+ */
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000 /**< Make the encoder output one
- partition at a time. */
-
-
- /*!\brief Generic fixed size buffer structure
- *
- * This structure is able to hold a reference to any fixed size buffer.
- */
- typedef struct vpx_fixed_buf
- {
- void *buf; /**< Pointer to the data */
- size_t sz; /**< Length of the buffer, in chars */
- } vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
-
-
- /*!\brief Time Stamp Type
- *
- * An integer, which when multiplied by the stream's time base, provides
- * the absolute time of a sample.
- */
- typedef int64_t vpx_codec_pts_t;
-
-
- /*!\brief Compressed Frame Flags
- *
- * This type represents a bitfield containing information about a compressed
- * frame that may be useful to an application. The most significant 16 bits
- * can be used by an algorithm to provide additional detail, for example to
- * support frame types that are codec specific (MPEG-1 D-frames for example)
- */
- typedef uint32_t vpx_codec_frame_flags_t;
+ partition at a time. */
+
+
+ /*!\brief Generic fixed size buffer structure
+ *
+ * This structure is able to hold a reference to any fixed size buffer.
+ */
+ typedef struct vpx_fixed_buf {
+ void *buf; /**< Pointer to the data */
+ size_t sz; /**< Length of the buffer, in chars */
+ } vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
+
+
+ /*!\brief Time Stamp Type
+ *
+ * An integer, which when multiplied by the stream's time base, provides
+ * the absolute time of a sample.
+ */
+ typedef int64_t vpx_codec_pts_t;
+
+
+ /*!\brief Compressed Frame Flags
+ *
+ * This type represents a bitfield containing information about a compressed
+ * frame that may be useful to an application. The most significant 16 bits
+ * can be used by an algorithm to provide additional detail, for example to
+ * support frame types that are codec specific (MPEG-1 D-frames for example)
+ */
+ typedef uint32_t vpx_codec_frame_flags_t;
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
#define VPX_FRAME_IS_DROPPABLE 0x2 /**< frame can be dropped without affecting
- the stream (no future frame depends on
- this one) */
+ the stream (no future frame depends on
+ this one) */
#define VPX_FRAME_IS_INVISIBLE 0x4 /**< frame should be decoded but will not
- be shown */
+ be shown */
#define VPX_FRAME_IS_FRAGMENT 0x8 /**< this is a fragment of the encoded
- frame */
-
- /*!\brief Error Resilient flags
- *
- * These flags define which error resilient features to enable in the
- * encoder. The flags are specified through the
- * vpx_codec_enc_cfg::g_error_resilient variable.
- */
- typedef uint32_t vpx_codec_er_flags_t;
+ frame */
+
+ /*!\brief Error Resilient flags
+ *
+ * These flags define which error resilient features to enable in the
+ * encoder. The flags are specified through the
+ * vpx_codec_enc_cfg::g_error_resilient variable.
+ */
+ typedef uint32_t vpx_codec_er_flags_t;
#define VPX_ERROR_RESILIENT_DEFAULT 0x1 /**< Improve resiliency against
- losses of whole frames */
+ losses of whole frames */
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2 /**< The frame partitions are
- independently decodable by the
- bool decoder, meaning that
- partitions can be decoded even
- though earlier partitions have
- been lost. Note that intra
- predicition is still done over
- the partition boundary. */
-
- /*!\brief Encoder output packet variants
- *
- * This enumeration lists the different kinds of data packets that can be
- * returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
- * extend this list to provide additional functionality.
- */
- enum vpx_codec_cx_pkt_kind
- {
- VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
- VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
- VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
- VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
- };
-
-
- /*!\brief Encoder output packet
- *
- * This structure contains the different kinds of output data the encoder
- * may produce while compressing a frame.
- */
- typedef struct vpx_codec_cx_pkt
- {
- enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
- union
- {
- struct
- {
- void *buf; /**< compressed data buffer */
- size_t sz; /**< length of compressed data */
- vpx_codec_pts_t pts; /**< time stamp to show frame
+ independently decodable by the
+ bool decoder, meaning that
+ partitions can be decoded even
+ though earlier partitions have
+ been lost. Note that intra
+ predicition is still done over
+ the partition boundary. */
+
+ /*!\brief Encoder output packet variants
+ *
+ * This enumeration lists the different kinds of data packets that can be
+ * returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
+ * extend this list to provide additional functionality.
+ */
+ enum vpx_codec_cx_pkt_kind {
+ VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
+ VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
+ VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
+ VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
+ };
+
+
+ /*!\brief Encoder output packet
+ *
+ * This structure contains the different kinds of output data the encoder
+ * may produce while compressing a frame.
+ */
+ typedef struct vpx_codec_cx_pkt {
+ enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
+ union {
+ struct {
+ void *buf; /**< compressed data buffer */
+ size_t sz; /**< length of compressed data */
+ vpx_codec_pts_t pts; /**< time stamp to show frame
(in timebase units) */
- unsigned long duration; /**< duration to show frame
+ unsigned long duration; /**< duration to show frame
(in timebase units) */
- vpx_codec_frame_flags_t flags; /**< flags for this frame */
- int partition_id; /**< the partition id
+ vpx_codec_frame_flags_t flags; /**< flags for this frame */
+ int partition_id; /**< the partition id
defines the decoding order
of the partitions. Only
applicable when "output partition"
mode is enabled. First partition
has id 0.*/
- } frame; /**< data for compressed frame packet */
- struct vpx_fixed_buf twopass_stats; /**< data for two-pass packet */
- struct vpx_psnr_pkt
- {
- unsigned int samples[4]; /**< Number of samples, total/y/u/v */
- uint64_t sse[4]; /**< sum squared error, total/y/u/v */
- double psnr[4]; /**< PSNR, total/y/u/v */
- } psnr; /**< data for PSNR packet */
- struct vpx_fixed_buf raw; /**< data for arbitrary packets */
+ } frame; /**< data for compressed frame packet */
+ struct vpx_fixed_buf twopass_stats; /**< data for two-pass packet */
+ struct vpx_psnr_pkt {
+ unsigned int samples[4]; /**< Number of samples, total/y/u/v */
+ uint64_t sse[4]; /**< sum squared error, total/y/u/v */
+ double psnr[4]; /**< PSNR, total/y/u/v */
+ } psnr; /**< data for PSNR packet */
+ struct vpx_fixed_buf raw; /**< data for arbitrary packets */
+
+ /* This packet size is fixed to allow codecs to extend this
+ * interface without having to manage storage for raw packets,
+ * i.e., if it's smaller than 128 bytes, you can store in the
+ * packet list directly.
+ */
+ char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
+ } data; /**< packet data */
+ } vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
+
+
+ /*!\brief Rational Number
+ *
+ * This structure holds a fractional value.
+ */
+ typedef struct vpx_rational {
+ int num; /**< fraction numerator */
+ int den; /**< fraction denominator */
+ } vpx_rational_t; /**< alias for struct vpx_rational */
+
+
+ /*!\brief Multi-pass Encoding Pass */
+ enum vpx_enc_pass {
+ VPX_RC_ONE_PASS, /**< Single pass mode */
+ VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
+ VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
+ };
+
+
+ /*!\brief Rate control mode */
+ enum vpx_rc_mode {
+ VPX_VBR, /**< Variable Bit Rate (VBR) mode */
+ VPX_CBR, /**< Constant Bit Rate (CBR) mode */
+ VPX_CQ /**< Constant Quality (CQ) mode */
+ };
+
+
+ /*!\brief Keyframe placement mode.
+ *
+ * This enumeration determines whether keyframes are placed automatically by
+ * the encoder or whether this behavior is disabled. Older releases of this
+ * SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
+ * This name is confusing for this behavior, so the new symbols to be used
+ * are VPX_KF_AUTO and VPX_KF_DISABLED.
+ */
+ enum vpx_kf_mode {
+ VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
+ VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
+ VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
+ };
+
+
+ /*!\brief Encoded Frame Flags
+ *
+ * This type indicates a bitfield to be passed to vpx_codec_encode(), defining
+ * per-frame boolean values. By convention, bits common to all codecs will be
+ * named VPX_EFLAG_*, and bits specific to an algorithm will be named
+ * /algo/_eflag_*. The lower order 16 bits are reserved for common use.
+ */
+ typedef long vpx_enc_frame_flags_t;
+#define VPX_EFLAG_FORCE_KF (1<<0) /**< Force this frame to be a keyframe */
+
+
+ /*!\brief Encoder configuration structure
+ *
+ * This structure contains the encoder settings that have common representations
+ * across all codecs. This doesn't imply that all codecs support all features,
+ * however.
+ */
+ typedef struct vpx_codec_enc_cfg {
+ /*
+ * generic settings (g)
+ */
- /* This packet size is fixed to allow codecs to extend this
- * interface without having to manage storage for raw packets,
- * i.e., if it's smaller than 128 bytes, you can store in the
- * packet list directly.
- */
- char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
- } data; /**< packet data */
- } vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
+ /*!\brief Algorithm specific "usage" value
+ *
+ * Algorithms may define multiple values for usage, which may convey the
+ * intent of how the application intends to use the stream. If this value
+ * is non-zero, consult the documentation for the codec to determine its
+ * meaning.
+ */
+ unsigned int g_usage;
- /*!\brief Rational Number
+ /*!\brief Maximum number of threads to use
*
- * This structure holds a fractional value.
+ * For multi-threaded implementations, use no more than this number of
+ * threads. The codec may use fewer threads than allowed. The value
+ * 0 is equivalent to the value 1.
*/
- typedef struct vpx_rational
- {
- int num; /**< fraction numerator */
- int den; /**< fraction denominator */
- } vpx_rational_t; /**< alias for struct vpx_rational */
+ unsigned int g_threads;
- /*!\brief Multi-pass Encoding Pass */
- enum vpx_enc_pass
- {
- VPX_RC_ONE_PASS, /**< Single pass mode */
- VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
- VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
- };
+ /*!\brief Bitstream profile to use
+ *
+ * Some codecs support a notion of multiple bitstream profiles. Typically
+ * this maps to a set of features that are turned on or off. Often the
+ * profile to use is determined by the features of the intended decoder.
+ * Consult the documentation for the codec to determine the valid values
+ * for this parameter, or set to zero for a sane default.
+ */
+ unsigned int g_profile; /**< profile of bitstream to use */
- /*!\brief Rate control mode */
- enum vpx_rc_mode
- {
- VPX_VBR, /**< Variable Bit Rate (VBR) mode */
- VPX_CBR, /**< Constant Bit Rate (CBR) mode */
- VPX_CQ /**< Constant Quality (CQ) mode */
- };
+
+ /*!\brief Width of the frame
+ *
+ * This value identifies the presentation resolution of the frame,
+ * in pixels. Note that the frames passed as input to the encoder must
+ * have this resolution. Frames will be presented by the decoder in this
+ * resolution, independent of any spatial resampling the encoder may do.
+ */
+ unsigned int g_w;
- /*!\brief Keyframe placement mode.
+ /*!\brief Height of the frame
*
- * This enumeration determines whether keyframes are placed automatically by
- * the encoder or whether this behavior is disabled. Older releases of this
- * SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
- * This name is confusing for this behavior, so the new symbols to be used
- * are VPX_KF_AUTO and VPX_KF_DISABLED.
+ * This value identifies the presentation resolution of the frame,
+ * in pixels. Note that the frames passed as input to the encoder must
+ * have this resolution. Frames will be presented by the decoder in this
+ * resolution, independent of any spatial resampling the encoder may do.
*/
- enum vpx_kf_mode
- {
- VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
- VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
- VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
- };
+ unsigned int g_h;
- /*!\brief Encoded Frame Flags
+ /*!\brief Stream timebase units
*
- * This type indicates a bitfield to be passed to vpx_codec_encode(), defining
- * per-frame boolean values. By convention, bits common to all codecs will be
- * named VPX_EFLAG_*, and bits specific to an algorithm will be named
- * /algo/_eflag_*. The lower order 16 bits are reserved for common use.
+ * Indicates the smallest interval of time, in seconds, used by the stream.
+ * For fixed frame rate material, or variable frame rate material where
+ * frames are timed at a multiple of a given clock (ex: video capture),
+ * the \ref RECOMMENDED method is to set the timebase to the reciprocal
+ * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
+ * pts to correspond to the frame number, which can be handy. For
+ * re-encoding video from containers with absolute time timestamps, the
+ * \ref RECOMMENDED method is to set the timebase to that of the parent
+ * container or multimedia framework (ex: 1/1000 for ms, as in FLV).
*/
- typedef long vpx_enc_frame_flags_t;
-#define VPX_EFLAG_FORCE_KF (1<<0) /**< Force this frame to be a keyframe */
+ struct vpx_rational g_timebase;
- /*!\brief Encoder configuration structure
- *
- * This structure contains the encoder settings that have common representations
- * across all codecs. This doesn't imply that all codecs support all features,
- * however.
- */
- typedef struct vpx_codec_enc_cfg
- {
- /*
- * generic settings (g)
- */
-
- /*!\brief Algorithm specific "usage" value
- *
- * Algorithms may define multiple values for usage, which may convey the
- * intent of how the application intends to use the stream. If this value
- * is non-zero, consult the documentation for the codec to determine its
- * meaning.
- */
- unsigned int g_usage;
-
-
- /*!\brief Maximum number of threads to use
- *
- * For multi-threaded implementations, use no more than this number of
- * threads. The codec may use fewer threads than allowed. The value
- * 0 is equivalent to the value 1.
- */
- unsigned int g_threads;
-
-
- /*!\brief Bitstream profile to use
- *
- * Some codecs support a notion of multiple bitstream profiles. Typically
- * this maps to a set of features that are turned on or off. Often the
- * profile to use is determined by the features of the intended decoder.
- * Consult the documentation for the codec to determine the valid values
- * for this parameter, or set to zero for a sane default.
- */
- unsigned int g_profile; /**< profile of bitstream to use */
-
-
-
- /*!\brief Width of the frame
- *
- * This value identifies the presentation resolution of the frame,
- * in pixels. Note that the frames passed as input to the encoder must
- * have this resolution. Frames will be presented by the decoder in this
- * resolution, independent of any spatial resampling the encoder may do.
- */
- unsigned int g_w;
-
-
- /*!\brief Height of the frame
- *
- * This value identifies the presentation resolution of the frame,
- * in pixels. Note that the frames passed as input to the encoder must
- * have this resolution. Frames will be presented by the decoder in this
- * resolution, independent of any spatial resampling the encoder may do.
- */
- unsigned int g_h;
-
-
- /*!\brief Stream timebase units
- *
- * Indicates the smallest interval of time, in seconds, used by the stream.
- * For fixed frame rate material, or variable frame rate material where
- * frames are timed at a multiple of a given clock (ex: video capture),
- * the \ref RECOMMENDED method is to set the timebase to the reciprocal
- * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
- * pts to correspond to the frame number, which can be handy. For
- * re-encoding video from containers with absolute time timestamps, the
- * \ref RECOMMENDED method is to set the timebase to that of the parent
- * container or multimedia framework (ex: 1/1000 for ms, as in FLV).
- */
- struct vpx_rational g_timebase;
-
-
- /*!\brief Enable error resilient modes.
- *
- * The error resilient bitfield indicates to the encoder which features
- * it should enable to take measures for streaming over lossy or noisy
- * links.
- */
- vpx_codec_er_flags_t g_error_resilient;
-
-
- /*!\brief Multi-pass Encoding Mode
- *
- * This value should be set to the current phase for multi-pass encoding.
- * For single pass, set to #VPX_RC_ONE_PASS.
- */
- enum vpx_enc_pass g_pass;
-
-
- /*!\brief Allow lagged encoding
- *
- * If set, this value allows the encoder to consume a number of input
- * frames before producing output frames. This allows the encoder to
- * base decisions for the current frame on future frames. This does
- * increase the latency of the encoding pipeline, so it is not appropriate
- * in all situations (ex: realtime encoding).
- *
- * Note that this is a maximum value -- the encoder may produce frames
- * sooner than the given limit. Set this value to 0 to disable this
- * feature.
- */
- unsigned int g_lag_in_frames;
-
-
- /*
- * rate control settings (rc)
- */
-
- /*!\brief Temporal resampling configuration, if supported by the codec.
- *
- * Temporal resampling allows the codec to "drop" frames as a strategy to
- * meet its target data rate. This can cause temporal discontinuities in
- * the encoded video, which may appear as stuttering during playback. This
- * trade-off is often acceptable, but for many applications is not. It can
- * be disabled in these cases.
- *
- * Note that not all codecs support this feature. All vpx VPx codecs do.
- * For other codecs, consult the documentation for that algorithm.
- *
- * This threshold is described as a percentage of the target data buffer.
- * When the data buffer falls below this percentage of fullness, a
- * dropped frame is indicated. Set the threshold to zero (0) to disable
- * this feature.
- */
- unsigned int rc_dropframe_thresh;
-
-
- /*!\brief Enable/disable spatial resampling, if supported by the codec.
- *
- * Spatial resampling allows the codec to compress a lower resolution
- * version of the frame, which is then upscaled by the encoder to the
- * correct presentation resolution. This increases visual quality at
- * low data rates, at the expense of CPU time on the encoder/decoder.
- */
- unsigned int rc_resize_allowed;
-
-
- /*!\brief Spatial resampling up watermark.
- *
- * This threshold is described as a percentage of the target data buffer.
- * When the data buffer rises above this percentage of fullness, the
- * encoder will step up to a higher resolution version of the frame.
- */
- unsigned int rc_resize_up_thresh;
-
-
- /*!\brief Spatial resampling down watermark.
- *
- * This threshold is described as a percentage of the target data buffer.
- * When the data buffer falls below this percentage of fullness, the
- * encoder will step down to a lower resolution version of the frame.
- */
- unsigned int rc_resize_down_thresh;
-
-
- /*!\brief Rate control algorithm to use.
- *
- * Indicates whether the end usage of this stream is to be streamed over
- * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
- * mode should be used, or whether it will be played back on a high
- * bandwidth link, as from a local disk, where higher variations in
- * bitrate are acceptable.
- */
- enum vpx_rc_mode rc_end_usage;
-
-
- /*!\brief Two-pass stats buffer.
- *
- * A buffer containing all of the stats packets produced in the first
- * pass, concatenated.
- */
- struct vpx_fixed_buf rc_twopass_stats_in;
-
-
- /*!\brief Target data rate
- *
- * Target bandwidth to use for this stream, in kilobits per second.
- */
- unsigned int rc_target_bitrate;
-
-
- /*
- * quantizer settings
- */
-
-
- /*!\brief Minimum (Best Quality) Quantizer
- *
- * The quantizer is the most direct control over the quality of the
- * encoded image. The range of valid values for the quantizer is codec
- * specific. Consult the documentation for the codec to determine the
- * values to use. To determine the range programmatically, call
- * vpx_codec_enc_config_default() with a usage value of 0.
- */
- unsigned int rc_min_quantizer;
-
-
- /*!\brief Maximum (Worst Quality) Quantizer
- *
- * The quantizer is the most direct control over the quality of the
- * encoded image. The range of valid values for the quantizer is codec
- * specific. Consult the documentation for the codec to determine the
- * values to use. To determine the range programmatically, call
- * vpx_codec_enc_config_default() with a usage value of 0.
- */
- unsigned int rc_max_quantizer;
-
-
- /*
- * bitrate tolerance
- */
-
-
- /*!\brief Rate control adaptation undershoot control
- *
- * This value, expressed as a percentage of the target bitrate,
- * controls the maximum allowed adaptation speed of the codec.
- * This factor controls the maximum amount of bits that can
- * be subtracted from the target bitrate in order to compensate
- * for prior overshoot.
- *
- * Valid values in the range 0-1000.
- */
- unsigned int rc_undershoot_pct;
-
-
- /*!\brief Rate control adaptation overshoot control
- *
- * This value, expressed as a percentage of the target bitrate,
- * controls the maximum allowed adaptation speed of the codec.
- * This factor controls the maximum amount of bits that can
- * be added to the target bitrate in order to compensate for
- * prior undershoot.
- *
- * Valid values in the range 0-1000.
- */
- unsigned int rc_overshoot_pct;
-
-
- /*
- * decoder buffer model parameters
- */
-
-
- /*!\brief Decoder Buffer Size
- *
- * This value indicates the amount of data that may be buffered by the
- * decoding application. Note that this value is expressed in units of
- * time (milliseconds). For example, a value of 5000 indicates that the
- * client will buffer (at least) 5000ms worth of encoded data. Use the
- * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
- * necessary.
- */
- unsigned int rc_buf_sz;
-
-
- /*!\brief Decoder Buffer Initial Size
- *
- * This value indicates the amount of data that will be buffered by the
- * decoding application prior to beginning playback. This value is
- * expressed in units of time (milliseconds). Use the target bitrate
- * (#rc_target_bitrate) to convert to bits/bytes, if necessary.
- */
- unsigned int rc_buf_initial_sz;
-
-
- /*!\brief Decoder Buffer Optimal Size
- *
- * This value indicates the amount of data that the encoder should try
- * to maintain in the decoder's buffer. This value is expressed in units
- * of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
- * to convert to bits/bytes, if necessary.
- */
- unsigned int rc_buf_optimal_sz;
-
-
- /*
- * 2 pass rate control parameters
- */
-
-
- /*!\brief Two-pass mode CBR/VBR bias
- *
- * Bias, expressed on a scale of 0 to 100, for determining target size
- * for the current frame. The value 0 indicates the optimal CBR mode
- * value should be used. The value 100 indicates the optimal VBR mode
- * value should be used. Values in between indicate which way the
- * encoder should "lean."
- */
- unsigned int rc_2pass_vbr_bias_pct; /**< RC mode bias between CBR and VBR(0-100: 0->CBR, 100->VBR) */
-
-
- /*!\brief Two-pass mode per-GOP minimum bitrate
- *
- * This value, expressed as a percentage of the target bitrate, indicates
- * the minimum bitrate to be used for a single GOP (aka "section")
- */
- unsigned int rc_2pass_vbr_minsection_pct;
-
-
- /*!\brief Two-pass mode per-GOP maximum bitrate
- *
- * This value, expressed as a percentage of the target bitrate, indicates
- * the maximum bitrate to be used for a single GOP (aka "section")
- */
- unsigned int rc_2pass_vbr_maxsection_pct;
-
-
- /*
- * keyframing settings (kf)
- */
-
- /*!\brief Keyframe placement mode
- *
- * This value indicates whether the encoder should place keyframes at a
- * fixed interval, or determine the optimal placement automatically
- * (as governed by the #kf_min_dist and #kf_max_dist parameters)
- */
- enum vpx_kf_mode kf_mode;
-
-
- /*!\brief Keyframe minimum interval
- *
- * This value, expressed as a number of frames, prevents the encoder from
- * placing a keyframe nearer than kf_min_dist to the previous keyframe. At
- * least kf_min_dist frames non-keyframes will be coded before the next
- * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
- */
- unsigned int kf_min_dist;
-
-
- /*!\brief Keyframe maximum interval
- *
- * This value, expressed as a number of frames, forces the encoder to code
- * a keyframe if one has not been coded in the last kf_max_dist frames.
- * A value of 0 implies all frames will be keyframes. Set kf_min_dist
- * equal to kf_max_dist for a fixed interval.
- */
- unsigned int kf_max_dist;
-
-
- /*!\brief Enable lossless compression mode
- *
- * If this flag is set, the decoder will be in lossless compression mode.
- */
- unsigned int lossless;
- } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
-
-
- /*!\brief Initialize an encoder instance
- *
- * Initializes a encoder context using the given interface. Applications
- * should call the vpx_codec_enc_init convenience macro instead of this
- * function directly, to ensure that the ABI version number parameter
- * is properly initialized.
- *
- * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
- * parameter), the storage pointed to by the cfg parameter must be
- * kept readable and stable until all memory maps have been set.
- *
- * \param[in] ctx Pointer to this instance's context.
- * \param[in] iface Pointer to the algorithm interface to use.
- * \param[in] cfg Configuration to use, if known. May be NULL.
- * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
- * \param[in] ver ABI version number. Must be set to
- * VPX_ENCODER_ABI_VERSION
- * \retval #VPX_CODEC_OK
- * The decoder algorithm initialized.
- * \retval #VPX_CODEC_MEM_ERROR
- * Memory allocation failed.
- */
- vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
- vpx_codec_iface_t *iface,
- vpx_codec_enc_cfg_t *cfg,
- vpx_codec_flags_t flags,
- int ver);
-
-
- /*!\brief Convenience macro for vpx_codec_enc_init_ver()
+ /*!\brief Enable error resilient modes.
*
- * Ensures the ABI version parameter is properly set.
+ * The error resilient bitfield indicates to the encoder which features
+ * it should enable to take measures for streaming over lossy or noisy
+ * links.
*/
-#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
- vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
+ vpx_codec_er_flags_t g_error_resilient;
- /*!\brief Get a default configuration
+ /*!\brief Multi-pass Encoding Mode
*
- * Initializes a encoder configuration structure with default values. Supports
- * the notion of "usages" so that an algorithm may offer different default
- * settings depending on the user's intended goal. This function \ref SHOULD
- * be called by all applications to initialize the configuration structure
- * before specializing the configuration with application specific values.
+ * This value should be set to the current phase for multi-pass encoding.
+ * For single pass, set to #VPX_RC_ONE_PASS.
+ */
+ enum vpx_enc_pass g_pass;
+
+
+ /*!\brief Allow lagged encoding
*
- * \param[in] iface Pointer to the algorithm interface to use.
- * \param[out] cfg Configuration buffer to populate
- * \param[in] usage End usage. Set to 0 or use codec specific values.
+ * If set, this value allows the encoder to consume a number of input
+ * frames before producing output frames. This allows the encoder to
+ * base decisions for the current frame on future frames. This does
+ * increase the latency of the encoding pipeline, so it is not appropriate
+ * in all situations (ex: realtime encoding).
*
- * \retval #VPX_CODEC_OK
- * The configuration was populated.
- * \retval #VPX_CODEC_INCAPABLE
- * Interface is not an encoder interface.
- * \retval #VPX_CODEC_INVALID_PARAM
- * A parameter was NULL, or the usage value was not recognized.
+ * Note that this is a maximum value -- the encoder may produce frames
+ * sooner than the given limit. Set this value to 0 to disable this
+ * feature.
*/
- vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
- vpx_codec_enc_cfg_t *cfg,
- unsigned int usage);
+ unsigned int g_lag_in_frames;
+
+ /*
+ * rate control settings (rc)
+ */
- /*!\brief Set or change configuration
+ /*!\brief Temporal resampling configuration, if supported by the codec.
*
- * Reconfigures an encoder instance according to the given configuration.
+ * Temporal resampling allows the codec to "drop" frames as a strategy to
+ * meet its target data rate. This can cause temporal discontinuities in
+ * the encoded video, which may appear as stuttering during playback. This
+ * trade-off is often acceptable, but for many applications is not. It can
+ * be disabled in these cases.
*
- * \param[in] ctx Pointer to this instance's context
- * \param[in] cfg Configuration buffer to use
+ * Note that not all codecs support this feature. All vpx VPx codecs do.
+ * For other codecs, consult the documentation for that algorithm.
*
- * \retval #VPX_CODEC_OK
- * The configuration was populated.
- * \retval #VPX_CODEC_INCAPABLE
- * Interface is not an encoder interface.
- * \retval #VPX_CODEC_INVALID_PARAM
- * A parameter was NULL, or the usage value was not recognized.
+ * This threshold is described as a percentage of the target data buffer.
+ * When the data buffer falls below this percentage of fullness, a
+ * dropped frame is indicated. Set the threshold to zero (0) to disable
+ * this feature.
*/
- vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
- const vpx_codec_enc_cfg_t *cfg);
+ unsigned int rc_dropframe_thresh;
- /*!\brief Get global stream headers
+ /*!\brief Enable/disable spatial resampling, if supported by the codec.
*
- * Retrieves a stream level global header packet, if supported by the codec.
- *
- * \param[in] ctx Pointer to this instance's context
+ * Spatial resampling allows the codec to compress a lower resolution
+ * version of the frame, which is then upscaled by the encoder to the
+ * correct presentation resolution. This increases visual quality at
+ * low data rates, at the expense of CPU time on the encoder/decoder.
+ */
+ unsigned int rc_resize_allowed;
+
+
+ /*!\brief Spatial resampling up watermark.
*
- * \retval NULL
- * Encoder does not support global header
- * \retval Non-NULL
- * Pointer to buffer containing global header packet
+ * This threshold is described as a percentage of the target data buffer.
+ * When the data buffer rises above this percentage of fullness, the
+ * encoder will step up to a higher resolution version of the frame.
*/
- vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
+ unsigned int rc_resize_up_thresh;
-#define VPX_DL_REALTIME (1) /**< deadline parameter analogous to
- * VPx REALTIME mode. */
-#define VPX_DL_GOOD_QUALITY (1000000) /**< deadline parameter analogous to
- * VPx GOOD QUALITY mode. */
-#define VPX_DL_BEST_QUALITY (0) /**< deadline parameter analogous to
- * VPx BEST QUALITY mode. */
- /*!\brief Encode a frame
- *
- * Encodes a video frame at the given "presentation time." The presentation
- * time stamp (PTS) \ref MUST be strictly increasing.
- *
- * The encoder supports the notion of a soft real-time deadline. Given a
- * non-zero value to the deadline parameter, the encoder will make a "best
- * effort" guarantee to return before the given time slice expires. It is
- * implicit that limiting the available time to encode will degrade the
- * output quality. The encoder can be given an unlimited time to produce the
- * best possible frame by specifying a deadline of '0'. This deadline
- * supercedes the VPx notion of "best quality, good quality, realtime".
- * Applications that wish to map these former settings to the new deadline
- * based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
- * and #VPX_DL_BEST_QUALITY.
- *
- * When the last frame has been passed to the encoder, this function should
- * continue to be called, with the img parameter set to NULL. This will
- * signal the end-of-stream condition to the encoder and allow it to encode
- * any held buffers. Encoding is complete when vpx_codec_encode() is called
- * and vpx_codec_get_cx_data() returns no data.
- *
- * \param[in] ctx Pointer to this instance's context
- * \param[in] img Image data to encode, NULL to flush.
- * \param[in] pts Presentation time stamp, in timebase units.
- * \param[in] duration Duration to show frame, in timebase units.
- * \param[in] flags Flags to use for encoding this frame.
- * \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
- *
- * \retval #VPX_CODEC_OK
- * The configuration was populated.
- * \retval #VPX_CODEC_INCAPABLE
- * Interface is not an encoder interface.
- * \retval #VPX_CODEC_INVALID_PARAM
- * A parameter was NULL, the image format is unsupported, etc.
+ /*!\brief Spatial resampling down watermark.
+ *
+ * This threshold is described as a percentage of the target data buffer.
+ * When the data buffer falls below this percentage of fullness, the
+ * encoder will step down to a lower resolution version of the frame.
*/
- vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
- const vpx_image_t *img,
- vpx_codec_pts_t pts,
- unsigned long duration,
- vpx_enc_frame_flags_t flags,
- unsigned long deadline);
+ unsigned int rc_resize_down_thresh;
- /*!\brief Set compressed data output buffer
+ /*!\brief Rate control algorithm to use.
*
- * Sets the buffer that the codec should output the compressed data
- * into. This call effectively sets the buffer pointer returned in the
- * next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
- * appended into this buffer. The buffer is preserved across frames,
- * so applications must periodically call this function after flushing
- * the accumulated compressed data to disk or to the network to reset
- * the pointer to the buffer's head.
+ * Indicates whether the end usage of this stream is to be streamed over
+ * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
+ * mode should be used, or whether it will be played back on a high
+ * bandwidth link, as from a local disk, where higher variations in
+ * bitrate are acceptable.
+ */
+ enum vpx_rc_mode rc_end_usage;
+
+
+ /*!\brief Two-pass stats buffer.
*
- * `pad_before` bytes will be skipped before writing the compressed
- * data, and `pad_after` bytes will be appended to the packet. The size
- * of the packet will be the sum of the size of the actual compressed
- * data, pad_before, and pad_after. The padding bytes will be preserved
- * (not overwritten).
+ * A buffer containing all of the stats packets produced in the first
+ * pass, concatenated.
+ */
+ struct vpx_fixed_buf rc_twopass_stats_in;
+
+
+ /*!\brief Target data rate
*
- * Note that calling this function does not guarantee that the returned
- * compressed data will be placed into the specified buffer. In the
- * event that the encoded data will not fit into the buffer provided,
- * the returned packet \ref MAY point to an internal buffer, as it would
- * if this call were never used. In this event, the output packet will
- * NOT have any padding, and the application must free space and copy it
- * to the proper place. This is of particular note in configurations
- * that may output multiple packets for a single encoded frame (e.g., lagged
- * encoding) or if the application does not reset the buffer periodically.
+ * Target bandwidth to use for this stream, in kilobits per second.
+ */
+ unsigned int rc_target_bitrate;
+
+
+ /*
+ * quantizer settings
+ */
+
+
+ /*!\brief Minimum (Best Quality) Quantizer
*
- * Applications may restore the default behavior of the codec providing
- * the compressed data buffer by calling this function with a NULL
- * buffer.
+ * The quantizer is the most direct control over the quality of the
+ * encoded image. The range of valid values for the quantizer is codec
+ * specific. Consult the documentation for the codec to determine the
+ * values to use. To determine the range programmatically, call
+ * vpx_codec_enc_config_default() with a usage value of 0.
+ */
+ unsigned int rc_min_quantizer;
+
+
+ /*!\brief Maximum (Worst Quality) Quantizer
*
- * Applications \ref MUSTNOT call this function during iteration of
- * vpx_codec_get_cx_data().
+ * The quantizer is the most direct control over the quality of the
+ * encoded image. The range of valid values for the quantizer is codec
+ * specific. Consult the documentation for the codec to determine the
+ * values to use. To determine the range programmatically, call
+ * vpx_codec_enc_config_default() with a usage value of 0.
+ */
+ unsigned int rc_max_quantizer;
+
+
+ /*
+ * bitrate tolerance
+ */
+
+
+ /*!\brief Rate control adaptation undershoot control
*
- * \param[in] ctx Pointer to this instance's context
- * \param[in] buf Buffer to store compressed data into
- * \param[in] pad_before Bytes to skip before writing compressed data
- * \param[in] pad_after Bytes to skip after writing compressed data
+ * This value, expressed as a percentage of the target bitrate,
+ * controls the maximum allowed adaptation speed of the codec.
+ * This factor controls the maximum amount of bits that can
+ * be subtracted from the target bitrate in order to compensate
+ * for prior overshoot.
*
- * \retval #VPX_CODEC_OK
- * The buffer was set successfully.
- * \retval #VPX_CODEC_INVALID_PARAM
- * A parameter was NULL, the image format is unsupported, etc.
+ * Valid values in the range 0-1000.
*/
- vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
- const vpx_fixed_buf_t *buf,
- unsigned int pad_before,
- unsigned int pad_after);
+ unsigned int rc_undershoot_pct;
- /*!\brief Encoded data iterator
+ /*!\brief Rate control adaptation overshoot control
*
- * Iterates over a list of data packets to be passed from the encoder to the
- * application. The different kinds of packets available are enumerated in
- * #vpx_codec_cx_pkt_kind.
+ * This value, expressed as a percentage of the target bitrate,
+ * controls the maximum allowed adaptation speed of the codec.
+ * This factor controls the maximum amount of bits that can
+ * be added to the target bitrate in order to compensate for
+ * prior undershoot.
*
- * #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
- * muxer. Multiple compressed frames may be in the list.
- * #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
+ * Valid values in the range 0-1000.
+ */
+ unsigned int rc_overshoot_pct;
+
+
+ /*
+ * decoder buffer model parameters
+ */
+
+
+ /*!\brief Decoder Buffer Size
*
- * The application \ref MUST silently ignore any packet kinds that it does
- * not recognize or support.
+ * This value indicates the amount of data that may be buffered by the
+ * decoding application. Note that this value is expressed in units of
+ * time (milliseconds). For example, a value of 5000 indicates that the
+ * client will buffer (at least) 5000ms worth of encoded data. Use the
+ * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
+ * necessary.
+ */
+ unsigned int rc_buf_sz;
+
+
+ /*!\brief Decoder Buffer Initial Size
*
- * The data buffers returned from this function are only guaranteed to be
- * valid until the application makes another call to any vpx_codec_* function.
+ * This value indicates the amount of data that will be buffered by the
+ * decoding application prior to beginning playback. This value is
+ * expressed in units of time (milliseconds). Use the target bitrate
+ * (#rc_target_bitrate) to convert to bits/bytes, if necessary.
+ */
+ unsigned int rc_buf_initial_sz;
+
+
+ /*!\brief Decoder Buffer Optimal Size
*
- * \param[in] ctx Pointer to this instance's context
- * \param[in,out] iter Iterator storage, initialized to NULL
+ * This value indicates the amount of data that the encoder should try
+ * to maintain in the decoder's buffer. This value is expressed in units
+ * of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
+ * to convert to bits/bytes, if necessary.
+ */
+ unsigned int rc_buf_optimal_sz;
+
+
+ /*
+ * 2 pass rate control parameters
+ */
+
+
+ /*!\brief Two-pass mode CBR/VBR bias
*
- * \return Returns a pointer to an output data packet (compressed frame data,
- * two-pass statistics, etc.) or NULL to signal end-of-list.
+ * Bias, expressed on a scale of 0 to 100, for determining target size
+ * for the current frame. The value 0 indicates the optimal CBR mode
+ * value should be used. The value 100 indicates the optimal VBR mode
+ * value should be used. Values in between indicate which way the
+ * encoder should "lean."
+ */
+ unsigned int rc_2pass_vbr_bias_pct; /**< RC mode bias between CBR and VBR(0-100: 0->CBR, 100->VBR) */
+
+
+ /*!\brief Two-pass mode per-GOP minimum bitrate
*
+ * This value, expressed as a percentage of the target bitrate, indicates
+ * the minimum bitrate to be used for a single GOP (aka "section")
*/
- const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
- vpx_codec_iter_t *iter);
+ unsigned int rc_2pass_vbr_minsection_pct;
- /*!\brief Get Preview Frame
+ /*!\brief Two-pass mode per-GOP maximum bitrate
*
- * Returns an image that can be used as a preview. Shows the image as it would
- * exist at the decompressor. The application \ref MUST NOT write into this
- * image buffer.
+ * This value, expressed as a percentage of the target bitrate, indicates
+ * the maximum bitrate to be used for a single GOP (aka "section")
+ */
+ unsigned int rc_2pass_vbr_maxsection_pct;
+
+
+ /*
+ * keyframing settings (kf)
+ */
+
+ /*!\brief Keyframe placement mode
*
- * \param[in] ctx Pointer to this instance's context
+ * This value indicates whether the encoder should place keyframes at a
+ * fixed interval, or determine the optimal placement automatically
+ * (as governed by the #kf_min_dist and #kf_max_dist parameters)
+ */
+ enum vpx_kf_mode kf_mode;
+
+
+ /*!\brief Keyframe minimum interval
*
- * \return Returns a pointer to a preview image, or NULL if no image is
- * available.
+ * This value, expressed as a number of frames, prevents the encoder from
+ * placing a keyframe nearer than kf_min_dist to the previous keyframe. At
+ * least kf_min_dist frames non-keyframes will be coded before the next
+ * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
+ */
+ unsigned int kf_min_dist;
+
+
+ /*!\brief Keyframe maximum interval
*
+ * This value, expressed as a number of frames, forces the encoder to code
+ * a keyframe if one has not been coded in the last kf_max_dist frames.
+ * A value of 0 implies all frames will be keyframes. Set kf_min_dist
+ * equal to kf_max_dist for a fixed interval.
*/
- const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
+ unsigned int kf_max_dist;
- /*!@} - end defgroup encoder*/
+ /*!\brief Enable lossless compression mode
+ *
+ * If this flag is set, the decoder will be in lossless compression mode.
+ */
+ unsigned int lossless;
+ } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
+
+
+ /*!\brief Initialize an encoder instance
+ *
+ * Initializes a encoder context using the given interface. Applications
+ * should call the vpx_codec_enc_init convenience macro instead of this
+ * function directly, to ensure that the ABI version number parameter
+ * is properly initialized.
+ *
+ * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
+ * parameter), the storage pointed to by the cfg parameter must be
+ * kept readable and stable until all memory maps have been set.
+ *
+ * \param[in] ctx Pointer to this instance's context.
+ * \param[in] iface Pointer to the algorithm interface to use.
+ * \param[in] cfg Configuration to use, if known. May be NULL.
+ * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
+ * \param[in] ver ABI version number. Must be set to
+ * VPX_ENCODER_ABI_VERSION
+ * \retval #VPX_CODEC_OK
+ * The decoder algorithm initialized.
+ * \retval #VPX_CODEC_MEM_ERROR
+ * Memory allocation failed.
+ */
+ vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
+ vpx_codec_iface_t *iface,
+ vpx_codec_enc_cfg_t *cfg,
+ vpx_codec_flags_t flags,
+ int ver);
+
+
+ /*!\brief Convenience macro for vpx_codec_enc_init_ver()
+ *
+ * Ensures the ABI version parameter is properly set.
+ */
+#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
+ vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
+
+
+ /*!\brief Get a default configuration
+ *
+ * Initializes a encoder configuration structure with default values. Supports
+ * the notion of "usages" so that an algorithm may offer different default
+ * settings depending on the user's intended goal. This function \ref SHOULD
+ * be called by all applications to initialize the configuration structure
+ * before specializing the configuration with application specific values.
+ *
+ * \param[in] iface Pointer to the algorithm interface to use.
+ * \param[out] cfg Configuration buffer to populate
+ * \param[in] usage End usage. Set to 0 or use codec specific values.
+ *
+ * \retval #VPX_CODEC_OK
+ * The configuration was populated.
+ * \retval #VPX_CODEC_INCAPABLE
+ * Interface is not an encoder interface.
+ * \retval #VPX_CODEC_INVALID_PARAM
+ * A parameter was NULL, or the usage value was not recognized.
+ */
+ vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
+ vpx_codec_enc_cfg_t *cfg,
+ unsigned int usage);
+
+
+ /*!\brief Set or change configuration
+ *
+ * Reconfigures an encoder instance according to the given configuration.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] cfg Configuration buffer to use
+ *
+ * \retval #VPX_CODEC_OK
+ * The configuration was populated.
+ * \retval #VPX_CODEC_INCAPABLE
+ * Interface is not an encoder interface.
+ * \retval #VPX_CODEC_INVALID_PARAM
+ * A parameter was NULL, or the usage value was not recognized.
+ */
+ vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
+ const vpx_codec_enc_cfg_t *cfg);
+
+
+ /*!\brief Get global stream headers
+ *
+ * Retrieves a stream level global header packet, if supported by the codec.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ *
+ * \retval NULL
+ * Encoder does not support global header
+ * \retval Non-NULL
+ * Pointer to buffer containing global header packet
+ */
+ vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
+
+
+#define VPX_DL_REALTIME (1) /**< deadline parameter analogous to
+ * VPx REALTIME mode. */
+#define VPX_DL_GOOD_QUALITY (1000000) /**< deadline parameter analogous to
+ * VPx GOOD QUALITY mode. */
+#define VPX_DL_BEST_QUALITY (0) /**< deadline parameter analogous to
+ * VPx BEST QUALITY mode. */
+ /*!\brief Encode a frame
+ *
+ * Encodes a video frame at the given "presentation time." The presentation
+ * time stamp (PTS) \ref MUST be strictly increasing.
+ *
+ * The encoder supports the notion of a soft real-time deadline. Given a
+ * non-zero value to the deadline parameter, the encoder will make a "best
+ * effort" guarantee to return before the given time slice expires. It is
+ * implicit that limiting the available time to encode will degrade the
+ * output quality. The encoder can be given an unlimited time to produce the
+ * best possible frame by specifying a deadline of '0'. This deadline
+ * supercedes the VPx notion of "best quality, good quality, realtime".
+ * Applications that wish to map these former settings to the new deadline
+ * based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
+ * and #VPX_DL_BEST_QUALITY.
+ *
+ * When the last frame has been passed to the encoder, this function should
+ * continue to be called, with the img parameter set to NULL. This will
+ * signal the end-of-stream condition to the encoder and allow it to encode
+ * any held buffers. Encoding is complete when vpx_codec_encode() is called
+ * and vpx_codec_get_cx_data() returns no data.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] img Image data to encode, NULL to flush.
+ * \param[in] pts Presentation time stamp, in timebase units.
+ * \param[in] duration Duration to show frame, in timebase units.
+ * \param[in] flags Flags to use for encoding this frame.
+ * \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
+ *
+ * \retval #VPX_CODEC_OK
+ * The configuration was populated.
+ * \retval #VPX_CODEC_INCAPABLE
+ * Interface is not an encoder interface.
+ * \retval #VPX_CODEC_INVALID_PARAM
+ * A parameter was NULL, the image format is unsupported, etc.
+ */
+ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx,
+ const vpx_image_t *img,
+ vpx_codec_pts_t pts,
+ unsigned long duration,
+ vpx_enc_frame_flags_t flags,
+ unsigned long deadline);
+
+
+ /*!\brief Set compressed data output buffer
+ *
+ * Sets the buffer that the codec should output the compressed data
+ * into. This call effectively sets the buffer pointer returned in the
+ * next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
+ * appended into this buffer. The buffer is preserved across frames,
+ * so applications must periodically call this function after flushing
+ * the accumulated compressed data to disk or to the network to reset
+ * the pointer to the buffer's head.
+ *
+ * `pad_before` bytes will be skipped before writing the compressed
+ * data, and `pad_after` bytes will be appended to the packet. The size
+ * of the packet will be the sum of the size of the actual compressed
+ * data, pad_before, and pad_after. The padding bytes will be preserved
+ * (not overwritten).
+ *
+ * Note that calling this function does not guarantee that the returned
+ * compressed data will be placed into the specified buffer. In the
+ * event that the encoded data will not fit into the buffer provided,
+ * the returned packet \ref MAY point to an internal buffer, as it would
+ * if this call were never used. In this event, the output packet will
+ * NOT have any padding, and the application must free space and copy it
+ * to the proper place. This is of particular note in configurations
+ * that may output multiple packets for a single encoded frame (e.g., lagged
+ * encoding) or if the application does not reset the buffer periodically.
+ *
+ * Applications may restore the default behavior of the codec providing
+ * the compressed data buffer by calling this function with a NULL
+ * buffer.
+ *
+ * Applications \ref MUSTNOT call this function during iteration of
+ * vpx_codec_get_cx_data().
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in] buf Buffer to store compressed data into
+ * \param[in] pad_before Bytes to skip before writing compressed data
+ * \param[in] pad_after Bytes to skip after writing compressed data
+ *
+ * \retval #VPX_CODEC_OK
+ * The buffer was set successfully.
+ * \retval #VPX_CODEC_INVALID_PARAM
+ * A parameter was NULL, the image format is unsupported, etc.
+ */
+ vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
+ const vpx_fixed_buf_t *buf,
+ unsigned int pad_before,
+ unsigned int pad_after);
+
+
+ /*!\brief Encoded data iterator
+ *
+ * Iterates over a list of data packets to be passed from the encoder to the
+ * application. The different kinds of packets available are enumerated in
+ * #vpx_codec_cx_pkt_kind.
+ *
+ * #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
+ * muxer. Multiple compressed frames may be in the list.
+ * #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
+ *
+ * The application \ref MUST silently ignore any packet kinds that it does
+ * not recognize or support.
+ *
+ * The data buffers returned from this function are only guaranteed to be
+ * valid until the application makes another call to any vpx_codec_* function.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ * \param[in,out] iter Iterator storage, initialized to NULL
+ *
+ * \return Returns a pointer to an output data packet (compressed frame data,
+ * two-pass statistics, etc.) or NULL to signal end-of-list.
+ *
+ */
+ const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
+ vpx_codec_iter_t *iter);
+
+
+ /*!\brief Get Preview Frame
+ *
+ * Returns an image that can be used as a preview. Shows the image as it would
+ * exist at the decompressor. The application \ref MUST NOT write into this
+ * image buffer.
+ *
+ * \param[in] ctx Pointer to this instance's context
+ *
+ * \return Returns a pointer to a preview image, or NULL if no image is
+ * available.
+ *
+ */
+ const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
+
+
+ /*!@} - end defgroup encoder*/
#endif
#ifdef __cplusplus
diff --git a/vpx/vpx_image.h b/vpx/vpx_image.h
index 8e08b3642..c94028bb4 100644
--- a/vpx/vpx_image.h
+++ b/vpx/vpx_image.h
@@ -20,14 +20,14 @@ extern "C" {
#ifndef VPX_IMAGE_H
#define VPX_IMAGE_H
- /*!\brief Current ABI version number
- *
- * \internal
- * If this file is altered in any way that changes the ABI, this value
- * must be bumped. Examples include, but are not limited to, changing
- * types, removing or reassigning enums, adding/removing/rearranging
- * fields to structures
- */
+ /*!\brief Current ABI version number
+ *
+ * \internal
+ * If this file is altered in any way that changes the ABI, this value
+ * must be bumped. Examples include, but are not limited to, changing
+ * types, removing or reassigning enums, adding/removing/rearranging
+ * fields to structures
+ */
#define VPX_IMAGE_ABI_VERSION (1) /**<\hideinitializer*/
@@ -36,41 +36,41 @@ extern "C" {
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel component */
- /*!\brief List of supported image formats */
- typedef enum vpx_img_fmt {
- VPX_IMG_FMT_NONE,
- VPX_IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */
- VPX_IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */
- VPX_IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */
- VPX_IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */
- VPX_IMG_FMT_UYVY, /**< UYVY packed YUV */
- VPX_IMG_FMT_YUY2, /**< YUYV packed YUV */
- VPX_IMG_FMT_YVYU, /**< YVYU packed YUV */
- VPX_IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */
- VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
- VPX_IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */
- VPX_IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */
- VPX_IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */
- VPX_IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
- VPX_IMG_FMT_YV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
- VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
- VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
- VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4 /** < planar 4:2:0 format with vpx color space */
- }
- vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
+ /*!\brief List of supported image formats */
+ typedef enum vpx_img_fmt {
+ VPX_IMG_FMT_NONE,
+ VPX_IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */
+ VPX_IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */
+ VPX_IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */
+ VPX_IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */
+ VPX_IMG_FMT_UYVY, /**< UYVY packed YUV */
+ VPX_IMG_FMT_YUY2, /**< YUYV packed YUV */
+ VPX_IMG_FMT_YVYU, /**< YVYU packed YUV */
+ VPX_IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */
+ VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
+ VPX_IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */
+ VPX_IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */
+ VPX_IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */
+ VPX_IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
+ VPX_IMG_FMT_YV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
+ VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
+ VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
+ VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4 /** < planar 4:2:0 format with vpx color space */
+ }
+ vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
#define IMG_FMT_PLANAR VPX_IMG_FMT_PLANAR /**< \deprecated Use #VPX_IMG_FMT_PLANAR */
#define IMG_FMT_UV_FLIP VPX_IMG_FMT_UV_FLIP /**< \deprecated Use #VPX_IMG_FMT_UV_FLIP */
#define IMG_FMT_HAS_ALPHA VPX_IMG_FMT_HAS_ALPHA /**< \deprecated Use #VPX_IMG_FMT_HAS_ALPHA */
- /*!\brief Deprecated list of supported image formats
- * \deprecated New code should use #vpx_img_fmt
- */
+ /*!\brief Deprecated list of supported image formats
+ * \deprecated New code should use #vpx_img_fmt
+ */
#define img_fmt vpx_img_fmt
- /*!\brief alias for enum img_fmt.
- * \deprecated New code should use #vpx_img_fmt_t
- */
+ /*!\brief alias for enum img_fmt.
+ * \deprecated New code should use #vpx_img_fmt_t
+ */
#define img_fmt_t vpx_img_fmt_t
#define IMG_FMT_NONE VPX_IMG_FMT_NONE /**< \deprecated Use #VPX_IMG_FMT_NONE */
@@ -93,24 +93,23 @@ extern "C" {
#define IMG_FMT_VPXI420 VPX_IMG_FMT_VPXI420 /**< \deprecated Use #VPX_IMG_FMT_VPXI420 */
#endif /* VPX_CODEC_DISABLE_COMPAT */
- /**\brief Image Descriptor */
- typedef struct vpx_image
- {
- vpx_img_fmt_t fmt; /**< Image Format */
+ /**\brief Image Descriptor */
+ typedef struct vpx_image {
+ vpx_img_fmt_t fmt; /**< Image Format */
- /* Image storage dimensions */
- unsigned int w; /**< Stored image width */
- unsigned int h; /**< Stored image height */
+ /* Image storage dimensions */
+ unsigned int w; /**< Stored image width */
+ unsigned int h; /**< Stored image height */
- /* Image display dimensions */
- unsigned int d_w; /**< Displayed image width */
- unsigned int d_h; /**< Displayed image height */
+ /* Image display dimensions */
+ unsigned int d_w; /**< Displayed image width */
+ unsigned int d_h; /**< Displayed image height */
- /* Chroma subsampling info */
- unsigned int x_chroma_shift; /**< subsampling order, X */
- unsigned int y_chroma_shift; /**< subsampling order, Y */
+ /* Chroma subsampling info */
+ unsigned int x_chroma_shift; /**< subsampling order, X */
+ unsigned int y_chroma_shift; /**< subsampling order, Y */
- /* Image data pointers. */
+ /* Image data pointers. */
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
@@ -123,118 +122,117 @@ extern "C" {
#define PLANE_V VPX_PLANE_V
#define PLANE_ALPHA VPX_PLANE_ALPHA
#endif
- unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
- int stride[4]; /**< stride between rows for each plane */
+ unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
+ int stride[4]; /**< stride between rows for each plane */
- int bps; /**< bits per sample (for packed formats) */
-
- /* The following member may be set by the application to associate data
- * with this image.
- */
- void *user_priv; /**< may be set by the application to associate data
- * with this image. */
+ int bps; /**< bits per sample (for packed formats) */
- /* The following members should be treated as private. */
- unsigned char *img_data; /**< private */
- int img_data_owner; /**< private */
- int self_allocd; /**< private */
- } vpx_image_t; /**< alias for struct vpx_image */
-
- /**\brief Representation of a rectangle on a surface */
- typedef struct vpx_image_rect
- {
- unsigned int x; /**< leftmost column */
- unsigned int y; /**< topmost row */
- unsigned int w; /**< width */
- unsigned int h; /**< height */
- } vpx_image_rect_t; /**< alias for struct vpx_image_rect */
-
- /*!\brief Open a descriptor, allocating storage for the underlying image
- *
- * Returns a descriptor for storing an image of the given format. The
- * storage for the descriptor is allocated on the heap.
- *
- * \param[in] img Pointer to storage for descriptor. If this parameter
- * is NULL, the storage for the descriptor will be
- * allocated on the heap.
- * \param[in] fmt Format for the image
- * \param[in] d_w Width of the image
- * \param[in] d_h Height of the image
- * \param[in] align Alignment, in bytes, of each row in the image.
- *
- * \return Returns a pointer to the initialized image descriptor. If the img
- * parameter is non-null, the value of the img parameter will be
- * returned.
+ /* The following member may be set by the application to associate data
+ * with this image.
*/
- vpx_image_t *vpx_img_alloc(vpx_image_t *img,
- vpx_img_fmt_t fmt,
- unsigned int d_w,
- unsigned int d_h,
- unsigned int align);
-
- /*!\brief Open a descriptor, using existing storage for the underlying image
- *
- * Returns a descriptor for storing an image of the given format. The
- * storage for descriptor has been allocated elsewhere, and a descriptor is
- * desired to "wrap" that storage.
- *
- * \param[in] img Pointer to storage for descriptor. If this parameter
- * is NULL, the storage for the descriptor will be
- * allocated on the heap.
- * \param[in] fmt Format for the image
- * \param[in] d_w Width of the image
- * \param[in] d_h Height of the image
- * \param[in] align Alignment, in bytes, of each row in the image.
- * \param[in] img_data Storage to use for the image
- *
- * \return Returns a pointer to the initialized image descriptor. If the img
- * parameter is non-null, the value of the img parameter will be
- * returned.
- */
- vpx_image_t *vpx_img_wrap(vpx_image_t *img,
- vpx_img_fmt_t fmt,
- unsigned int d_w,
- unsigned int d_h,
- unsigned int align,
- unsigned char *img_data);
-
-
- /*!\brief Set the rectangle identifying the displayed portion of the image
- *
- * Updates the displayed rectangle (aka viewport) on the image surface to
- * match the specified coordinates and size.
- *
- * \param[in] img Image descriptor
- * \param[in] x leftmost column
- * \param[in] y topmost row
- * \param[in] w width
- * \param[in] h height
- *
- * \return 0 if the requested rectangle is valid, nonzero otherwise.
- */
- int vpx_img_set_rect(vpx_image_t *img,
- unsigned int x,
- unsigned int y,
- unsigned int w,
- unsigned int h);
-
-
- /*!\brief Flip the image vertically (top for bottom)
- *
- * Adjusts the image descriptor's pointers and strides to make the image
- * be referenced upside-down.
- *
- * \param[in] img Image descriptor
- */
- void vpx_img_flip(vpx_image_t *img);
+ void *user_priv; /**< may be set by the application to associate data
+ * with this image. */
- /*!\brief Close an image descriptor
- *
- * Frees all allocated storage associated with an image descriptor.
- *
- * \param[in] img Image descriptor
- */
- void vpx_img_free(vpx_image_t *img);
+ /* The following members should be treated as private. */
+ unsigned char *img_data; /**< private */
+ int img_data_owner; /**< private */
+ int self_allocd; /**< private */
+ } vpx_image_t; /**< alias for struct vpx_image */
+
+ /**\brief Representation of a rectangle on a surface */
+ typedef struct vpx_image_rect {
+ unsigned int x; /**< leftmost column */
+ unsigned int y; /**< topmost row */
+ unsigned int w; /**< width */
+ unsigned int h; /**< height */
+ } vpx_image_rect_t; /**< alias for struct vpx_image_rect */
+
+ /*!\brief Open a descriptor, allocating storage for the underlying image
+ *
+ * Returns a descriptor for storing an image of the given format. The
+ * storage for the descriptor is allocated on the heap.
+ *
+ * \param[in] img Pointer to storage for descriptor. If this parameter
+ * is NULL, the storage for the descriptor will be
+ * allocated on the heap.
+ * \param[in] fmt Format for the image
+ * \param[in] d_w Width of the image
+ * \param[in] d_h Height of the image
+ * \param[in] align Alignment, in bytes, of each row in the image.
+ *
+ * \return Returns a pointer to the initialized image descriptor. If the img
+ * parameter is non-null, the value of the img parameter will be
+ * returned.
+ */
+ vpx_image_t *vpx_img_alloc(vpx_image_t *img,
+ vpx_img_fmt_t fmt,
+ unsigned int d_w,
+ unsigned int d_h,
+ unsigned int align);
+
+ /*!\brief Open a descriptor, using existing storage for the underlying image
+ *
+ * Returns a descriptor for storing an image of the given format. The
+ * storage for descriptor has been allocated elsewhere, and a descriptor is
+ * desired to "wrap" that storage.
+ *
+ * \param[in] img Pointer to storage for descriptor. If this parameter
+ * is NULL, the storage for the descriptor will be
+ * allocated on the heap.
+ * \param[in] fmt Format for the image
+ * \param[in] d_w Width of the image
+ * \param[in] d_h Height of the image
+ * \param[in] align Alignment, in bytes, of each row in the image.
+ * \param[in] img_data Storage to use for the image
+ *
+ * \return Returns a pointer to the initialized image descriptor. If the img
+ * parameter is non-null, the value of the img parameter will be
+ * returned.
+ */
+ vpx_image_t *vpx_img_wrap(vpx_image_t *img,
+ vpx_img_fmt_t fmt,
+ unsigned int d_w,
+ unsigned int d_h,
+ unsigned int align,
+ unsigned char *img_data);
+
+
+ /*!\brief Set the rectangle identifying the displayed portion of the image
+ *
+ * Updates the displayed rectangle (aka viewport) on the image surface to
+ * match the specified coordinates and size.
+ *
+ * \param[in] img Image descriptor
+ * \param[in] x leftmost column
+ * \param[in] y topmost row
+ * \param[in] w width
+ * \param[in] h height
+ *
+ * \return 0 if the requested rectangle is valid, nonzero otherwise.
+ */
+ int vpx_img_set_rect(vpx_image_t *img,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h);
+
+
+ /*!\brief Flip the image vertically (top for bottom)
+ *
+ * Adjusts the image descriptor's pointers and strides to make the image
+ * be referenced upside-down.
+ *
+ * \param[in] img Image descriptor
+ */
+ void vpx_img_flip(vpx_image_t *img);
+
+ /*!\brief Close an image descriptor
+ *
+ * Frees all allocated storage associated with an image descriptor.
+ *
+ * \param[in] img Image descriptor
+ */
+ void vpx_img_free(vpx_image_t *img);
#endif
#ifdef __cplusplus
diff --git a/vpx_mem/include/vpx_mem_intrnl.h b/vpx_mem/include/vpx_mem_intrnl.h
index 6e261ba7f..0f58cfc8f 100644
--- a/vpx_mem/include/vpx_mem_intrnl.h
+++ b/vpx_mem/include/vpx_mem_intrnl.h
@@ -47,8 +47,8 @@ vpx_memcpy, _memset, and _memmove*/
#ifndef DEFAULT_ALIGNMENT
# if defined(VXWORKS)
# define DEFAULT_ALIGNMENT 32 /*default addr alignment to use in
- calls to vpx_* functions other
- than vpx_memalign*/
+calls to vpx_* functions other
+than vpx_memalign*/
# else
# define DEFAULT_ALIGNMENT 1
# endif
@@ -60,9 +60,9 @@ vpx_memcpy, _memset, and _memmove*/
#if CONFIG_MEM_TRACKER
# define TRY_BOUNDS_CHECK 1 /*when set to 1 pads each allocation,
- integrity can be checked using
- vpx_memory_tracker_check_integrity
- or on free by defining*/
+integrity can be checked using
+vpx_memory_tracker_check_integrity
+or on free by defining*/
/*TRY_BOUNDS_CHECK_ON_FREE*/
#else
# define TRY_BOUNDS_CHECK 0
@@ -70,13 +70,13 @@ vpx_memcpy, _memset, and _memmove*/
#if TRY_BOUNDS_CHECK
# define TRY_BOUNDS_CHECK_ON_FREE 0 /*checks mem integrity on every
- free, very expensive*/
+free, very expensive*/
# define BOUNDS_CHECK_VALUE 0xdeadbeef /*value stored before/after ea.
- mem addr for bounds checking*/
+mem addr for bounds checking*/
# define BOUNDS_CHECK_PAD_SIZE 32 /*size of the padding before and
- after ea allocation to be filled
- with BOUNDS_CHECK_VALUE.
- this should be a multiple of 4*/
+after ea allocation to be filled
+with BOUNDS_CHECK_VALUE.
+this should be a multiple of 4*/
#else
# define BOUNDS_CHECK_VALUE 0
# define BOUNDS_CHECK_PAD_SIZE 0
diff --git a/vpx_mem/include/vpx_mem_tracker.h b/vpx_mem/include/vpx_mem_tracker.h
index ef2b29b07..3be0d2ddb 100644
--- a/vpx_mem/include/vpx_mem_tracker.h
+++ b/vpx_mem/include/vpx_mem_tracker.h
@@ -23,158 +23,157 @@
#include <stdarg.h>
-struct mem_block
-{
- size_t addr;
- unsigned int size,
- line;
- char *file;
- struct mem_block *prev,
- * next;
-
- int padded; // This mem_block has padding for integrity checks.
- // As of right now, this should only be 0 if
- // using vpx_mem_alloc to allocate cache memory.
- // 2005-01-11 tjf
+struct mem_block {
+ size_t addr;
+ unsigned int size,
+ line;
+ char *file;
+ struct mem_block *prev,
+ * next;
+
+ int padded; // This mem_block has padding for integrity checks.
+ // As of right now, this should only be 0 if
+ // using vpx_mem_alloc to allocate cache memory.
+ // 2005-01-11 tjf
};
#if defined(__cplusplus)
extern "C" {
#endif
- /*
- vpx_memory_tracker_init(int padding_size, int pad_value)
- padding_size - the size of the padding before and after each mem addr.
- Values > 0 indicate that integrity checks can be performed
- by inspecting these areas.
- pad_value - the initial value within the padding area before and after
- each mem addr.
-
- Initializes the memory tracker interface. Should be called before any
- other calls to the memory tracker.
- */
- int vpx_memory_tracker_init(int padding_size, int pad_value);
-
- /*
- vpx_memory_tracker_destroy()
- Deinitializes the memory tracker interface
- */
- void vpx_memory_tracker_destroy();
-
- /*
- vpx_memory_tracker_add(size_t addr, unsigned int size,
- char * file, unsigned int line)
- addr - memory address to be added to list
- size - size of addr
- file - the file addr was referenced from
- line - the line in file addr was referenced from
- Adds memory address addr, it's size, file and line it came from
- to the memory tracker allocation table
- */
- void vpx_memory_tracker_add(size_t addr, unsigned int size,
- char *file, unsigned int line,
- int padded);
-
- /*
- vpx_memory_tracker_add(size_t addr, unsigned int size, char * file, unsigned int line)
- addr - memory address to be added to be removed
- padded - if 0, disables bounds checking on this memory block even if bounds
- checking is enabled. (for example, when allocating cache memory, we still want
- to check for memory leaks, but we do not waste cache space for bounds check padding)
- Removes the specified address from the memory tracker's allocation
- table
- Return:
- 0: on success
- -1: if memory allocation table's mutex could not be locked
- -2: if the addr was not found in the list
- */
- int vpx_memory_tracker_remove(size_t addr);
-
- /*
- vpx_memory_tracker_find(unsigned int addr)
- addr - address to be found in the memory tracker's
- allocation table
- Return:
- If found, pointer to the memory block that matches addr
- NULL otherwise
- */
- struct mem_block *vpx_memory_tracker_find(size_t addr);
-
- /*
- vpx_memory_tracker_dump()
- Dumps the current contents of the memory
- tracker allocation table
- */
- void vpx_memory_tracker_dump();
-
- /*
- vpx_memory_tracker_check_integrity()
- If a padding_size was provided to vpx_memory_tracker_init()
- This function will verify that the region before and after each
- memory address contains the specified pad_value. Should the check
- fail, the filename and line of the check will be printed out.
- */
- void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
-
- /*
- vpx_memory_tracker_set_log_type
- type - value representing the logging type to use
- option - type specific option. This will be interpreted differently
- based on the type.
- Sets the logging type for the memory tracker.
- Values currently supported:
- 0: if option is NULL, log to stderr, otherwise interpret option as a
- filename and attempt to open it.
- 1: Use output_debug_string (WIN32 only), option ignored
- Return:
- 0: on success
- -1: if the logging type could not be set, because the value was invalid
- or because a file could not be opened
- */
- int vpx_memory_tracker_set_log_type(int type, char *option);
-
- /*
- vpx_memory_tracker_set_log_func
- userdata - ptr to be passed to the supplied logfunc, can be NULL
- logfunc - the logging function to be used to output data from
- vpx_memory_track_dump/check_integrity
- Sets a logging function to be used by the memory tracker.
- Return:
- 0: on success
- -1: if the logging type could not be set because logfunc was NULL
- */
- int vpx_memory_tracker_set_log_func(void *userdata,
- void(*logfunc)(void *userdata,
- const char *fmt, va_list args));
-
- /* Wrappers to standard library functions. */
- typedef void*(* mem_track_malloc_func)(size_t);
- typedef void*(* mem_track_calloc_func)(size_t, size_t);
- typedef void*(* mem_track_realloc_func)(void *, size_t);
- typedef void (* mem_track_free_func)(void *);
- typedef void*(* mem_track_memcpy_func)(void *, const void *, size_t);
- typedef void*(* mem_track_memset_func)(void *, int, size_t);
- typedef void*(* mem_track_memmove_func)(void *, const void *, size_t);
-
- /*
- vpx_memory_tracker_set_functions
-
- Sets the function pointers for the standard library functions.
-
- Return:
- 0: on success
- -1: if the use global function pointers is not set.
- */
- int vpx_memory_tracker_set_functions(mem_track_malloc_func g_malloc_l
- , mem_track_calloc_func g_calloc_l
- , mem_track_realloc_func g_realloc_l
- , mem_track_free_func g_free_l
- , mem_track_memcpy_func g_memcpy_l
- , mem_track_memset_func g_memset_l
- , mem_track_memmove_func g_memmove_l);
+ /*
+ vpx_memory_tracker_init(int padding_size, int pad_value)
+ padding_size - the size of the padding before and after each mem addr.
+ Values > 0 indicate that integrity checks can be performed
+ by inspecting these areas.
+ pad_value - the initial value within the padding area before and after
+ each mem addr.
+
+ Initializes the memory tracker interface. Should be called before any
+ other calls to the memory tracker.
+ */
+ int vpx_memory_tracker_init(int padding_size, int pad_value);
+
+ /*
+ vpx_memory_tracker_destroy()
+ Deinitializes the memory tracker interface
+ */
+ void vpx_memory_tracker_destroy();
+
+ /*
+ vpx_memory_tracker_add(size_t addr, unsigned int size,
+ char * file, unsigned int line)
+ addr - memory address to be added to list
+ size - size of addr
+ file - the file addr was referenced from
+ line - the line in file addr was referenced from
+ Adds memory address addr, it's size, file and line it came from
+ to the memory tracker allocation table
+ */
+ void vpx_memory_tracker_add(size_t addr, unsigned int size,
+ char *file, unsigned int line,
+ int padded);
+
+ /*
+ vpx_memory_tracker_add(size_t addr, unsigned int size, char * file, unsigned int line)
+ addr - memory address to be added to be removed
+ padded - if 0, disables bounds checking on this memory block even if bounds
+ checking is enabled. (for example, when allocating cache memory, we still want
+ to check for memory leaks, but we do not waste cache space for bounds check padding)
+ Removes the specified address from the memory tracker's allocation
+ table
+ Return:
+ 0: on success
+ -1: if memory allocation table's mutex could not be locked
+ -2: if the addr was not found in the list
+ */
+ int vpx_memory_tracker_remove(size_t addr);
+
+ /*
+ vpx_memory_tracker_find(unsigned int addr)
+ addr - address to be found in the memory tracker's
+ allocation table
+ Return:
+ If found, pointer to the memory block that matches addr
+ NULL otherwise
+ */
+ struct mem_block *vpx_memory_tracker_find(size_t addr);
+
+ /*
+ vpx_memory_tracker_dump()
+ Dumps the current contents of the memory
+ tracker allocation table
+ */
+ void vpx_memory_tracker_dump();
+
+ /*
+ vpx_memory_tracker_check_integrity()
+ If a padding_size was provided to vpx_memory_tracker_init()
+ This function will verify that the region before and after each
+ memory address contains the specified pad_value. Should the check
+ fail, the filename and line of the check will be printed out.
+ */
+ void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
+
+ /*
+ vpx_memory_tracker_set_log_type
+ type - value representing the logging type to use
+ option - type specific option. This will be interpreted differently
+ based on the type.
+ Sets the logging type for the memory tracker.
+ Values currently supported:
+ 0: if option is NULL, log to stderr, otherwise interpret option as a
+ filename and attempt to open it.
+ 1: Use output_debug_string (WIN32 only), option ignored
+ Return:
+ 0: on success
+ -1: if the logging type could not be set, because the value was invalid
+ or because a file could not be opened
+ */
+ int vpx_memory_tracker_set_log_type(int type, char *option);
+
+ /*
+ vpx_memory_tracker_set_log_func
+ userdata - ptr to be passed to the supplied logfunc, can be NULL
+ logfunc - the logging function to be used to output data from
+ vpx_memory_track_dump/check_integrity
+ Sets a logging function to be used by the memory tracker.
+ Return:
+ 0: on success
+ -1: if the logging type could not be set because logfunc was NULL
+ */
+ int vpx_memory_tracker_set_log_func(void *userdata,
+ void(*logfunc)(void *userdata,
+ const char *fmt, va_list args));
+
+ /* Wrappers to standard library functions. */
+ typedef void *(* mem_track_malloc_func)(size_t);
+ typedef void *(* mem_track_calloc_func)(size_t, size_t);
+ typedef void *(* mem_track_realloc_func)(void *, size_t);
+ typedef void (* mem_track_free_func)(void *);
+ typedef void *(* mem_track_memcpy_func)(void *, const void *, size_t);
+ typedef void *(* mem_track_memset_func)(void *, int, size_t);
+ typedef void *(* mem_track_memmove_func)(void *, const void *, size_t);
+
+ /*
+ vpx_memory_tracker_set_functions
+
+ Sets the function pointers for the standard library functions.
+
+ Return:
+ 0: on success
+ -1: if the use global function pointers is not set.
+ */
+ int vpx_memory_tracker_set_functions(mem_track_malloc_func g_malloc_l
+, mem_track_calloc_func g_calloc_l
+, mem_track_realloc_func g_realloc_l
+, mem_track_free_func g_free_l
+, mem_track_memcpy_func g_memcpy_l
+, mem_track_memset_func g_memset_l
+, mem_track_memmove_func g_memmove_l);
#if defined(__cplusplus)
}
#endif
-#endif //__VPX_MEM_TRACKER_H__
+#endif // __VPX_MEM_TRACKER_H__
diff --git a/vpx_mem/memory_manager/hmm_alloc.c b/vpx_mem/memory_manager/hmm_alloc.c
index 22c4a54ee..ab3562dfb 100644
--- a/vpx_mem/memory_manager/hmm_alloc.c
+++ b/vpx_mem/memory_manager/hmm_alloc.c
@@ -15,46 +15,44 @@
#include "hmm_intrnl.h"
-void *U(alloc)(U(descriptor) *desc, U(size_aau) n)
-{
+void *U(alloc)(U(descriptor) *desc, U(size_aau) n) {
#ifdef HMM_AUDIT_FAIL
- if (desc->avl_tree_root)
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ if (desc->avl_tree_root)
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
- if (desc->last_freed)
- {
+ if (desc->last_freed) {
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(desc->last_freed)
+ AUDIT_BLOCK(desc->last_freed)
#endif
- U(into_free_collection)(desc, (head_record *)(desc->last_freed));
+ U(into_free_collection)(desc, (head_record *)(desc->last_freed));
- desc->last_freed = 0;
- }
-
- /* Add space for block header. */
- n += HEAD_AAUS;
-
- /* Convert n from number of address alignment units to block alignment
- ** units. */
- n = DIV_ROUND_UP(n, HMM_BLOCK_ALIGN_UNIT);
-
- if (n < MIN_BLOCK_BAUS)
- n = MIN_BLOCK_BAUS;
-
- {
- /* Search for the first node of the bin containing the smallest
- ** block big enough to satisfy request. */
- ptr_record *ptr_rec_ptr =
- U(avl_search)(
- (U(avl_avl) *) & (desc->avl_tree_root), (U(size_bau)) n,
- AVL_GREATER_EQUAL);
-
- /* If an approprate bin is found, satisfy the allocation request,
- ** otherwise return null pointer. */
- return(ptr_rec_ptr ?
- U(alloc_from_bin)(desc, ptr_rec_ptr, (U(size_bau)) n) : 0);
+ desc->last_freed = 0;
}
+
+ /* Add space for block header. */
+ n += HEAD_AAUS;
+
+ /* Convert n from number of address alignment units to block alignment
+ ** units. */
+ n = DIV_ROUND_UP(n, HMM_BLOCK_ALIGN_UNIT);
+
+ if (n < MIN_BLOCK_BAUS)
+ n = MIN_BLOCK_BAUS;
+
+ {
+ /* Search for the first node of the bin containing the smallest
+ ** block big enough to satisfy request. */
+ ptr_record *ptr_rec_ptr =
+ U(avl_search)(
+ (U(avl_avl) *) & (desc->avl_tree_root), (U(size_bau)) n,
+ AVL_GREATER_EQUAL);
+
+ /* If an approprate bin is found, satisfy the allocation request,
+ ** otherwise return null pointer. */
+ return(ptr_rec_ptr ?
+ U(alloc_from_bin)(desc, ptr_rec_ptr, (U(size_bau)) n) : 0);
+ }
}
diff --git a/vpx_mem/memory_manager/hmm_base.c b/vpx_mem/memory_manager/hmm_base.c
index ad1da032e..0eff59d20 100644
--- a/vpx_mem/memory_manager/hmm_base.c
+++ b/vpx_mem/memory_manager/hmm_base.c
@@ -15,58 +15,53 @@
#include "hmm_intrnl.h"
-void U(init)(U(descriptor) *desc)
-{
- desc->avl_tree_root = 0;
- desc->last_freed = 0;
+void U(init)(U(descriptor) *desc) {
+ desc->avl_tree_root = 0;
+ desc->last_freed = 0;
}
/* Remove a free block from a bin's doubly-linked list when it is not,
** the first block in the bin.
*/
void U(dll_remove)(
- /* Pointer to pointer record in the block to be removed. */
- ptr_record *to_remove)
-{
- to_remove->prev->next = to_remove->next;
+ /* Pointer to pointer record in the block to be removed. */
+ ptr_record *to_remove) {
+ to_remove->prev->next = to_remove->next;
- if (to_remove->next)
- to_remove->next->prev = to_remove->prev;
+ if (to_remove->next)
+ to_remove->next->prev = to_remove->prev;
}
/* Put a block into the free collection of a heap.
*/
void U(into_free_collection)(
- /* Pointer to heap descriptor. */
- U(descriptor) *desc,
- /* Pointer to head record of block. */
- head_record *head_ptr)
-{
- ptr_record *ptr_rec_ptr = HEAD_TO_PTR_REC(head_ptr);
-
- ptr_record *bin_front_ptr =
- U(avl_insert)((U(avl_avl) *) & (desc->avl_tree_root), ptr_rec_ptr);
-
- if (bin_front_ptr != ptr_rec_ptr)
- {
- /* The block was not inserted into the AVL tree because there is
- ** already a bin for the size of the block. */
-
- MARK_SUCCESSIVE_BLOCK_IN_FREE_BIN(head_ptr)
- ptr_rec_ptr->self = ptr_rec_ptr;
-
- /* Make the block the new second block in the bin's doubly-linked
- ** list. */
- ptr_rec_ptr->prev = bin_front_ptr;
- ptr_rec_ptr->next = bin_front_ptr->next;
- bin_front_ptr->next = ptr_rec_ptr;
-
- if (ptr_rec_ptr->next)
- ptr_rec_ptr->next->prev = ptr_rec_ptr;
- }
- else
- /* Block is first block in new bin. */
- ptr_rec_ptr->next = 0;
+ /* Pointer to heap descriptor. */
+ U(descriptor) *desc,
+ /* Pointer to head record of block. */
+ head_record *head_ptr) {
+ ptr_record *ptr_rec_ptr = HEAD_TO_PTR_REC(head_ptr);
+
+ ptr_record *bin_front_ptr =
+ U(avl_insert)((U(avl_avl) *) & (desc->avl_tree_root), ptr_rec_ptr);
+
+ if (bin_front_ptr != ptr_rec_ptr) {
+ /* The block was not inserted into the AVL tree because there is
+ ** already a bin for the size of the block. */
+
+ MARK_SUCCESSIVE_BLOCK_IN_FREE_BIN(head_ptr)
+ ptr_rec_ptr->self = ptr_rec_ptr;
+
+ /* Make the block the new second block in the bin's doubly-linked
+ ** list. */
+ ptr_rec_ptr->prev = bin_front_ptr;
+ ptr_rec_ptr->next = bin_front_ptr->next;
+ bin_front_ptr->next = ptr_rec_ptr;
+
+ if (ptr_rec_ptr->next)
+ ptr_rec_ptr->next->prev = ptr_rec_ptr;
+ } else
+ /* Block is first block in new bin. */
+ ptr_rec_ptr->next = 0;
}
/* Allocate a block from a given bin. Returns a pointer to the payload
@@ -74,268 +69,245 @@ void U(into_free_collection)(
** to calling this function.
*/
void *U(alloc_from_bin)(
- /* Pointer to heap descriptor. */
- U(descriptor) *desc,
- /* Pointer to pointer record of first block in bin. */
- ptr_record *bin_front_ptr,
- /* Number of BAUs needed in the allocated block. If the block taken
- ** from the bin is significantly larger than the number of BAUs needed,
- ** the "extra" BAUs are split off to form a new free block. */
- U(size_bau) n_baus)
-{
- head_record *head_ptr;
- U(size_bau) rem_baus;
-
- if (bin_front_ptr->next)
- {
- /* There are multiple blocks in this bin. Use the 2nd block in
- ** the bin to avoid needless change to the AVL tree.
- */
-
- ptr_record *ptr_rec_ptr = bin_front_ptr->next;
- head_ptr = PTR_REC_TO_HEAD(ptr_rec_ptr);
+ /* Pointer to heap descriptor. */
+ U(descriptor) *desc,
+ /* Pointer to pointer record of first block in bin. */
+ ptr_record *bin_front_ptr,
+ /* Number of BAUs needed in the allocated block. If the block taken
+ ** from the bin is significantly larger than the number of BAUs needed,
+ ** the "extra" BAUs are split off to form a new free block. */
+ U(size_bau) n_baus) {
+ head_record *head_ptr;
+ U(size_bau) rem_baus;
+
+ if (bin_front_ptr->next) {
+ /* There are multiple blocks in this bin. Use the 2nd block in
+ ** the bin to avoid needless change to the AVL tree.
+ */
+
+ ptr_record *ptr_rec_ptr = bin_front_ptr->next;
+ head_ptr = PTR_REC_TO_HEAD(ptr_rec_ptr);
#ifdef AUDIT_FAIL
- AUDIT_BLOCK(head_ptr)
+ AUDIT_BLOCK(head_ptr)
#endif
- U(dll_remove)(ptr_rec_ptr);
- }
- else
- {
- /* There is only one block in the bin, so it has to be removed
- ** from the AVL tree.
- */
+ U(dll_remove)(ptr_rec_ptr);
+ } else {
+ /* There is only one block in the bin, so it has to be removed
+ ** from the AVL tree.
+ */
- head_ptr = PTR_REC_TO_HEAD(bin_front_ptr);
+ head_ptr = PTR_REC_TO_HEAD(bin_front_ptr);
- U(avl_remove)(
- (U(avl_avl) *) &(desc->avl_tree_root), BLOCK_BAUS(head_ptr));
- }
+ U(avl_remove)(
+ (U(avl_avl) *) & (desc->avl_tree_root), BLOCK_BAUS(head_ptr));
+ }
- MARK_BLOCK_ALLOCATED(head_ptr)
+ MARK_BLOCK_ALLOCATED(head_ptr)
- rem_baus = BLOCK_BAUS(head_ptr) - n_baus;
+ rem_baus = BLOCK_BAUS(head_ptr) - n_baus;
- if (rem_baus >= MIN_BLOCK_BAUS)
- {
- /* Since there are enough "extra" BAUs, split them off to form
- ** a new free block.
- */
+ if (rem_baus >= MIN_BLOCK_BAUS) {
+ /* Since there are enough "extra" BAUs, split them off to form
+ ** a new free block.
+ */
- head_record *rem_head_ptr =
- (head_record *) BAUS_FORWARD(head_ptr, n_baus);
+ head_record *rem_head_ptr =
+ (head_record *) BAUS_FORWARD(head_ptr, n_baus);
- /* Change the next block's header to reflect the fact that the
- ** block preceeding it is now smaller.
- */
- SET_PREV_BLOCK_BAUS(
- BAUS_FORWARD(head_ptr, head_ptr->block_size), rem_baus)
+ /* Change the next block's header to reflect the fact that the
+ ** block preceeding it is now smaller.
+ */
+ SET_PREV_BLOCK_BAUS(
+ BAUS_FORWARD(head_ptr, head_ptr->block_size), rem_baus)
- head_ptr->block_size = n_baus;
+ head_ptr->block_size = n_baus;
- rem_head_ptr->previous_block_size = n_baus;
- rem_head_ptr->block_size = rem_baus;
+ rem_head_ptr->previous_block_size = n_baus;
+ rem_head_ptr->block_size = rem_baus;
- desc->last_freed = rem_head_ptr;
- }
+ desc->last_freed = rem_head_ptr;
+ }
- return(HEAD_TO_PTR_REC(head_ptr));
+ return(HEAD_TO_PTR_REC(head_ptr));
}
/* Take a block out of the free collection.
*/
void U(out_of_free_collection)(
- /* Descriptor of heap that block is in. */
- U(descriptor) *desc,
- /* Pointer to head of block to take out of free collection. */
- head_record *head_ptr)
-{
- ptr_record *ptr_rec_ptr = HEAD_TO_PTR_REC(head_ptr);
-
- if (ptr_rec_ptr->self == ptr_rec_ptr)
- /* Block is not the front block in its bin, so all we have to
- ** do is take it out of the bin's doubly-linked list. */
- U(dll_remove)(ptr_rec_ptr);
+ /* Descriptor of heap that block is in. */
+ U(descriptor) *desc,
+ /* Pointer to head of block to take out of free collection. */
+ head_record *head_ptr) {
+ ptr_record *ptr_rec_ptr = HEAD_TO_PTR_REC(head_ptr);
+
+ if (ptr_rec_ptr->self == ptr_rec_ptr)
+ /* Block is not the front block in its bin, so all we have to
+ ** do is take it out of the bin's doubly-linked list. */
+ U(dll_remove)(ptr_rec_ptr);
+ else {
+ ptr_record *next = ptr_rec_ptr->next;
+
+ if (next)
+ /* Block is the front block in its bin, and there is at least
+ ** one other block in the bin. Substitute the next block for
+ ** the front block. */
+ U(avl_subst)((U(avl_avl) *) & (desc->avl_tree_root), next);
else
- {
- ptr_record *next = ptr_rec_ptr->next;
-
- if (next)
- /* Block is the front block in its bin, and there is at least
- ** one other block in the bin. Substitute the next block for
- ** the front block. */
- U(avl_subst)((U(avl_avl) *) &(desc->avl_tree_root), next);
- else
- /* Block is the front block in its bin, but there is no other
- ** block in the bin. Eliminate the bin. */
- U(avl_remove)(
- (U(avl_avl) *) &(desc->avl_tree_root), BLOCK_BAUS(head_ptr));
- }
+ /* Block is the front block in its bin, but there is no other
+ ** block in the bin. Eliminate the bin. */
+ U(avl_remove)(
+ (U(avl_avl) *) & (desc->avl_tree_root), BLOCK_BAUS(head_ptr));
+ }
}
-void U(free)(U(descriptor) *desc, void *payload_ptr)
-{
- /* Flags if coalesce with adjacent block. */
- int coalesce;
+void U(free)(U(descriptor) *desc, void *payload_ptr) {
+ /* Flags if coalesce with adjacent block. */
+ int coalesce;
- head_record *fwd_head_ptr;
- head_record *free_head_ptr = PTR_REC_TO_HEAD(payload_ptr);
+ head_record *fwd_head_ptr;
+ head_record *free_head_ptr = PTR_REC_TO_HEAD(payload_ptr);
- desc->num_baus_can_shrink = 0;
+ desc->num_baus_can_shrink = 0;
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(free_head_ptr)
+ AUDIT_BLOCK(free_head_ptr)
- /* Make sure not freeing an already free block. */
- if (!IS_BLOCK_ALLOCATED(free_head_ptr))
- HMM_AUDIT_FAIL
+ /* Make sure not freeing an already free block. */
+ if (!IS_BLOCK_ALLOCATED(free_head_ptr))
+ HMM_AUDIT_FAIL
- if (desc->avl_tree_root)
- /* Audit root block in AVL tree. */
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ if (desc->avl_tree_root)
+ /* Audit root block in AVL tree. */
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
- fwd_head_ptr =
- (head_record *) BAUS_FORWARD(free_head_ptr, free_head_ptr->block_size);
+ fwd_head_ptr =
+ (head_record *) BAUS_FORWARD(free_head_ptr, free_head_ptr->block_size);
- if (free_head_ptr->previous_block_size)
- {
- /* Coalesce with backward block if possible. */
+ if (free_head_ptr->previous_block_size) {
+ /* Coalesce with backward block if possible. */
- head_record *bkwd_head_ptr =
- (head_record *) BAUS_BACKWARD(
- free_head_ptr, free_head_ptr->previous_block_size);
+ head_record *bkwd_head_ptr =
+ (head_record *) BAUS_BACKWARD(
+ free_head_ptr, free_head_ptr->previous_block_size);
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(bkwd_head_ptr)
+ AUDIT_BLOCK(bkwd_head_ptr)
#endif
- if (bkwd_head_ptr == (head_record *)(desc->last_freed))
- {
- desc->last_freed = 0;
- coalesce = 1;
- }
- else if (IS_BLOCK_ALLOCATED(bkwd_head_ptr))
- coalesce = 0;
- else
- {
- U(out_of_free_collection)(desc, bkwd_head_ptr);
- coalesce = 1;
- }
-
- if (coalesce)
- {
- bkwd_head_ptr->block_size += free_head_ptr->block_size;
- SET_PREV_BLOCK_BAUS(fwd_head_ptr, BLOCK_BAUS(bkwd_head_ptr))
- free_head_ptr = bkwd_head_ptr;
- }
+ if (bkwd_head_ptr == (head_record *)(desc->last_freed)) {
+ desc->last_freed = 0;
+ coalesce = 1;
+ } else if (IS_BLOCK_ALLOCATED(bkwd_head_ptr))
+ coalesce = 0;
+ else {
+ U(out_of_free_collection)(desc, bkwd_head_ptr);
+ coalesce = 1;
}
- if (fwd_head_ptr->block_size == 0)
- {
- /* Block to be freed is last block before dummy end-of-chunk block. */
- desc->end_of_shrinkable_chunk =
- BAUS_FORWARD(fwd_head_ptr, DUMMY_END_BLOCK_BAUS);
- desc->num_baus_can_shrink = BLOCK_BAUS(free_head_ptr);
-
- if (PREV_BLOCK_BAUS(free_head_ptr) == 0)
- /* Free block is the entire chunk, so shrinking can eliminate
- ** entire chunk including dummy end block. */
- desc->num_baus_can_shrink += DUMMY_END_BLOCK_BAUS;
+ if (coalesce) {
+ bkwd_head_ptr->block_size += free_head_ptr->block_size;
+ SET_PREV_BLOCK_BAUS(fwd_head_ptr, BLOCK_BAUS(bkwd_head_ptr))
+ free_head_ptr = bkwd_head_ptr;
}
- else
- {
- /* Coalesce with forward block if possible. */
+ }
+
+ if (fwd_head_ptr->block_size == 0) {
+ /* Block to be freed is last block before dummy end-of-chunk block. */
+ desc->end_of_shrinkable_chunk =
+ BAUS_FORWARD(fwd_head_ptr, DUMMY_END_BLOCK_BAUS);
+ desc->num_baus_can_shrink = BLOCK_BAUS(free_head_ptr);
+
+ if (PREV_BLOCK_BAUS(free_head_ptr) == 0)
+ /* Free block is the entire chunk, so shrinking can eliminate
+ ** entire chunk including dummy end block. */
+ desc->num_baus_can_shrink += DUMMY_END_BLOCK_BAUS;
+ } else {
+ /* Coalesce with forward block if possible. */
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(fwd_head_ptr)
+ AUDIT_BLOCK(fwd_head_ptr)
#endif
- if (fwd_head_ptr == (head_record *)(desc->last_freed))
- {
- desc->last_freed = 0;
- coalesce = 1;
- }
- else if (IS_BLOCK_ALLOCATED(fwd_head_ptr))
- coalesce = 0;
- else
- {
- U(out_of_free_collection)(desc, fwd_head_ptr);
- coalesce = 1;
- }
-
- if (coalesce)
- {
- free_head_ptr->block_size += fwd_head_ptr->block_size;
-
- fwd_head_ptr =
- (head_record *) BAUS_FORWARD(
- fwd_head_ptr, BLOCK_BAUS(fwd_head_ptr));
-
- SET_PREV_BLOCK_BAUS(fwd_head_ptr, BLOCK_BAUS(free_head_ptr))
-
- if (fwd_head_ptr->block_size == 0)
- {
- /* Coalesced block to be freed is last block before dummy
- ** end-of-chunk block. */
- desc->end_of_shrinkable_chunk =
- BAUS_FORWARD(fwd_head_ptr, DUMMY_END_BLOCK_BAUS);
- desc->num_baus_can_shrink = BLOCK_BAUS(free_head_ptr);
-
- if (PREV_BLOCK_BAUS(free_head_ptr) == 0)
- /* Free block is the entire chunk, so shrinking can
- ** eliminate entire chunk including dummy end block. */
- desc->num_baus_can_shrink += DUMMY_END_BLOCK_BAUS;
- }
- }
+ if (fwd_head_ptr == (head_record *)(desc->last_freed)) {
+ desc->last_freed = 0;
+ coalesce = 1;
+ } else if (IS_BLOCK_ALLOCATED(fwd_head_ptr))
+ coalesce = 0;
+ else {
+ U(out_of_free_collection)(desc, fwd_head_ptr);
+ coalesce = 1;
+ }
+
+ if (coalesce) {
+ free_head_ptr->block_size += fwd_head_ptr->block_size;
+
+ fwd_head_ptr =
+ (head_record *) BAUS_FORWARD(
+ fwd_head_ptr, BLOCK_BAUS(fwd_head_ptr));
+
+ SET_PREV_BLOCK_BAUS(fwd_head_ptr, BLOCK_BAUS(free_head_ptr))
+
+ if (fwd_head_ptr->block_size == 0) {
+ /* Coalesced block to be freed is last block before dummy
+ ** end-of-chunk block. */
+ desc->end_of_shrinkable_chunk =
+ BAUS_FORWARD(fwd_head_ptr, DUMMY_END_BLOCK_BAUS);
+ desc->num_baus_can_shrink = BLOCK_BAUS(free_head_ptr);
+
+ if (PREV_BLOCK_BAUS(free_head_ptr) == 0)
+ /* Free block is the entire chunk, so shrinking can
+ ** eliminate entire chunk including dummy end block. */
+ desc->num_baus_can_shrink += DUMMY_END_BLOCK_BAUS;
+ }
}
+ }
- if (desc->last_freed)
- {
- /* There is a last freed block, but it is not adjacent to the
- ** block being freed by this call to free, so put the last
- ** freed block into the free collection.
- */
+ if (desc->last_freed) {
+ /* There is a last freed block, but it is not adjacent to the
+ ** block being freed by this call to free, so put the last
+ ** freed block into the free collection.
+ */
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(desc->last_freed)
+ AUDIT_BLOCK(desc->last_freed)
#endif
- U(into_free_collection)(desc, (head_record *)(desc->last_freed));
- }
+ U(into_free_collection)(desc, (head_record *)(desc->last_freed));
+ }
- desc->last_freed = free_head_ptr;
+ desc->last_freed = free_head_ptr;
}
-void U(new_chunk)(U(descriptor) *desc, void *start, U(size_bau) n_baus)
-{
+void U(new_chunk)(U(descriptor) *desc, void *start, U(size_bau) n_baus) {
#ifdef HMM_AUDIT_FAIL
- if (desc->avl_tree_root)
- /* Audit root block in AVL tree. */
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ if (desc->avl_tree_root)
+ /* Audit root block in AVL tree. */
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
#undef HEAD_PTR
#define HEAD_PTR ((head_record *) start)
- /* Make the chunk one big free block followed by a dummy end block.
- */
+ /* Make the chunk one big free block followed by a dummy end block.
+ */
- n_baus -= DUMMY_END_BLOCK_BAUS;
+ n_baus -= DUMMY_END_BLOCK_BAUS;
- HEAD_PTR->previous_block_size = 0;
- HEAD_PTR->block_size = n_baus;
+ HEAD_PTR->previous_block_size = 0;
+ HEAD_PTR->block_size = n_baus;
- U(into_free_collection)(desc, HEAD_PTR);
+ U(into_free_collection)(desc, HEAD_PTR);
- /* Set up the dummy end block. */
- start = BAUS_FORWARD(start, n_baus);
- HEAD_PTR->previous_block_size = n_baus;
- HEAD_PTR->block_size = 0;
+ /* Set up the dummy end block. */
+ start = BAUS_FORWARD(start, n_baus);
+ HEAD_PTR->previous_block_size = n_baus;
+ HEAD_PTR->block_size = 0;
#undef HEAD_PTR
}
@@ -345,12 +317,11 @@ void U(new_chunk)(U(descriptor) *desc, void *start, U(size_bau) n_baus)
/* Function that does audit fail actions defined my preprocessor symbol,
** and returns a dummy integer value.
*/
-int U(audit_block_fail_dummy_return)(void)
-{
- HMM_AUDIT_FAIL
+int U(audit_block_fail_dummy_return)(void) {
+ HMM_AUDIT_FAIL
- /* Dummy return. */
- return(0);
+ /* Dummy return. */
+ return(0);
}
#endif
@@ -372,9 +343,9 @@ int U(audit_block_fail_dummy_return)(void)
*/
#define AVL_GET_LESS(H, ACCESS) \
- (((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->self)
+ (((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->self)
#define AVL_GET_GREATER(H, ACCESS) \
- (((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->prev)
+ (((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->prev)
#else
@@ -396,39 +367,39 @@ int U(audit_block_fail_dummy_return)(void)
*/
#define AVL_GET_BALANCE_FACTOR(H) \
- ((((head_record *) (PTR_REC_TO_HEAD(H)))->block_size & \
- HIGH_BIT_BAU_SIZE) ? \
- (((head_record *) (PTR_REC_TO_HEAD(H)))->previous_block_size & \
- HIGH_BIT_BAU_SIZE ? 0 : -1) : 1)
+ ((((head_record *) (PTR_REC_TO_HEAD(H)))->block_size & \
+ HIGH_BIT_BAU_SIZE) ? \
+ (((head_record *) (PTR_REC_TO_HEAD(H)))->previous_block_size & \
+ HIGH_BIT_BAU_SIZE ? 0 : -1) : 1)
#define AVL_SET_BALANCE_FACTOR(H, BF) \
- { \
- register head_record *p = \
- (head_record *) PTR_REC_TO_HEAD(H); \
- register int bal_f = (BF); \
- \
- if (bal_f <= 0) \
- p->block_size |= HIGH_BIT_BAU_SIZE; \
- else \
- p->block_size &= ~HIGH_BIT_BAU_SIZE; \
- if (bal_f >= 0) \
- p->previous_block_size |= HIGH_BIT_BAU_SIZE; \
- else \
- p->previous_block_size &= ~HIGH_BIT_BAU_SIZE; \
- }
+ { \
+ register head_record *p = \
+ (head_record *) PTR_REC_TO_HEAD(H); \
+ register int bal_f = (BF); \
+ \
+ if (bal_f <= 0) \
+ p->block_size |= HIGH_BIT_BAU_SIZE; \
+ else \
+ p->block_size &= ~HIGH_BIT_BAU_SIZE; \
+ if (bal_f >= 0) \
+ p->previous_block_size |= HIGH_BIT_BAU_SIZE; \
+ else \
+ p->previous_block_size &= ~HIGH_BIT_BAU_SIZE; \
+ }
#define COMPARE_KEY_KEY(K1, K2) ((K1) == (K2) ? 0 : ((K1) > (K2) ? 1 : -1))
#define AVL_COMPARE_KEY_NODE(K, H) \
- COMPARE_KEY_KEY(K, BLOCK_BAUS(PTR_REC_TO_HEAD(H)))
+ COMPARE_KEY_KEY(K, BLOCK_BAUS(PTR_REC_TO_HEAD(H)))
#define AVL_COMPARE_NODE_NODE(H1, H2) \
- COMPARE_KEY_KEY(BLOCK_BAUS(PTR_REC_TO_HEAD(H1)), \
- BLOCK_BAUS(PTR_REC_TO_HEAD(H2)))
+ COMPARE_KEY_KEY(BLOCK_BAUS(PTR_REC_TO_HEAD(H1)), \
+ BLOCK_BAUS(PTR_REC_TO_HEAD(H2)))
#define AVL_NULL ((ptr_record *) 0)
#define AVL_IMPL_MASK \
- ( AVL_IMPL_INSERT | AVL_IMPL_SEARCH | AVL_IMPL_REMOVE | AVL_IMPL_SUBST )
+ ( AVL_IMPL_INSERT | AVL_IMPL_SEARCH | AVL_IMPL_REMOVE | AVL_IMPL_SUBST )
#include "cavl_impl.h"
diff --git a/vpx_mem/memory_manager/hmm_dflt_abort.c b/vpx_mem/memory_manager/hmm_dflt_abort.c
index d92435cfa..51c3cc27a 100644
--- a/vpx_mem/memory_manager/hmm_dflt_abort.c
+++ b/vpx_mem/memory_manager/hmm_dflt_abort.c
@@ -29,26 +29,25 @@ static int entered = 0;
/* Print abort message, file and line. Terminate execution.
*/
-void hmm_dflt_abort(const char *file, const char *line)
-{
- /* Avoid use of printf(), which is more likely to use heap. */
+void hmm_dflt_abort(const char *file, const char *line) {
+ /* Avoid use of printf(), which is more likely to use heap. */
- if (entered)
+ if (entered)
- /* The standard I/O functions called a heap function and caused
- ** an indirect recursive call to this function. So we'll have
- ** to just exit without printing a message. */
- while (1);
+ /* The standard I/O functions called a heap function and caused
+ ** an indirect recursive call to this function. So we'll have
+ ** to just exit without printing a message. */
+ while (1);
- entered = 1;
+ entered = 1;
- fputs("\n_abort - Heap corruption\n" "File: ", stderr);
- fputs(file, stderr);
- fputs(" Line: ", stderr);
- fputs(line, stderr);
- fputs("\n\n", stderr);
- fputs("hmm_dflt_abort: while(1)!!!\n", stderr);
- fflush(stderr);
+ fputs("\n_abort - Heap corruption\n" "File: ", stderr);
+ fputs(file, stderr);
+ fputs(" Line: ", stderr);
+ fputs(line, stderr);
+ fputs("\n\n", stderr);
+ fputs("hmm_dflt_abort: while(1)!!!\n", stderr);
+ fflush(stderr);
- while (1);
+ while (1);
}
diff --git a/vpx_mem/memory_manager/hmm_grow.c b/vpx_mem/memory_manager/hmm_grow.c
index 9a4b6e416..0e8637374 100644
--- a/vpx_mem/memory_manager/hmm_grow.c
+++ b/vpx_mem/memory_manager/hmm_grow.c
@@ -15,36 +15,35 @@
#include "hmm_intrnl.h"
-void U(grow_chunk)(U(descriptor) *desc, void *end, U(size_bau) n_baus)
-{
+void U(grow_chunk)(U(descriptor) *desc, void *end, U(size_bau) n_baus) {
#undef HEAD_PTR
#define HEAD_PTR ((head_record *) end)
- end = BAUS_BACKWARD(end, DUMMY_END_BLOCK_BAUS);
+ end = BAUS_BACKWARD(end, DUMMY_END_BLOCK_BAUS);
#ifdef HMM_AUDIT_FAIL
- if (HEAD_PTR->block_size != 0)
- /* Chunk does not have valid dummy end block. */
- HMM_AUDIT_FAIL
+ if (HEAD_PTR->block_size != 0)
+ /* Chunk does not have valid dummy end block. */
+ HMM_AUDIT_FAIL
#endif
- /* Create a new block that absorbs the old dummy end block. */
- HEAD_PTR->block_size = n_baus;
-
- /* Set up the new dummy end block. */
- {
- head_record *dummy = (head_record *) BAUS_FORWARD(end, n_baus);
- dummy->previous_block_size = n_baus;
- dummy->block_size = 0;
- }
-
- /* Simply free the new block, allowing it to coalesce with any
- ** free block at that was the last block in the chunk prior to
- ** growth.
- */
- U(free)(desc, HEAD_TO_PTR_REC(end));
+ /* Create a new block that absorbs the old dummy end block. */
+ HEAD_PTR->block_size = n_baus;
+
+ /* Set up the new dummy end block. */
+ {
+ head_record *dummy = (head_record *) BAUS_FORWARD(end, n_baus);
+ dummy->previous_block_size = n_baus;
+ dummy->block_size = 0;
+ }
+
+ /* Simply free the new block, allowing it to coalesce with any
+ ** free block at that was the last block in the chunk prior to
+ ** growth.
+ */
+ U(free)(desc, HEAD_TO_PTR_REC(end));
#undef HEAD_PTR
}
diff --git a/vpx_mem/memory_manager/hmm_largest.c b/vpx_mem/memory_manager/hmm_largest.c
index c3c6f2c42..192758df9 100644
--- a/vpx_mem/memory_manager/hmm_largest.c
+++ b/vpx_mem/memory_manager/hmm_largest.c
@@ -15,46 +15,43 @@
#include "hmm_intrnl.h"
-U(size_aau) U(largest_available)(U(descriptor) *desc)
-{
- U(size_bau) largest;
-
- if (!(desc->avl_tree_root))
- largest = 0;
- else
- {
+U(size_aau) U(largest_available)(U(descriptor) *desc) {
+ U(size_bau) largest;
+
+ if (!(desc->avl_tree_root))
+ largest = 0;
+ else {
#ifdef HMM_AUDIT_FAIL
- /* Audit root block in AVL tree. */
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ /* Audit root block in AVL tree. */
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
- largest =
- BLOCK_BAUS(
- PTR_REC_TO_HEAD(
- U(avl_search)(
- (U(avl_avl) *) & (desc->avl_tree_root),
- (U(size_bau)) ~(U(size_bau)) 0, AVL_LESS)));
- }
+ largest =
+ BLOCK_BAUS(
+ PTR_REC_TO_HEAD(
+ U(avl_search)(
+ (U(avl_avl) *) & (desc->avl_tree_root),
+ (U(size_bau)) ~(U(size_bau)) 0, AVL_LESS)));
+ }
- if (desc->last_freed)
- {
- /* Size of last freed block. */
- register U(size_bau) lf_size;
+ if (desc->last_freed) {
+ /* Size of last freed block. */
+ register U(size_bau) lf_size;
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(desc->last_freed)
+ AUDIT_BLOCK(desc->last_freed)
#endif
- lf_size = BLOCK_BAUS(desc->last_freed);
+ lf_size = BLOCK_BAUS(desc->last_freed);
- if (lf_size > largest)
- largest = lf_size;
- }
+ if (lf_size > largest)
+ largest = lf_size;
+ }
- /* Convert largest size to AAUs and subract head size leaving payload
- ** size.
- */
- return(largest ?
- ((largest * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT)) - HEAD_AAUS) :
- 0);
+ /* Convert largest size to AAUs and subract head size leaving payload
+ ** size.
+ */
+ return(largest ?
+ ((largest * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT)) - HEAD_AAUS) :
+ 0);
}
diff --git a/vpx_mem/memory_manager/hmm_resize.c b/vpx_mem/memory_manager/hmm_resize.c
index f90da9692..baa5a8f9e 100644
--- a/vpx_mem/memory_manager/hmm_resize.c
+++ b/vpx_mem/memory_manager/hmm_resize.c
@@ -15,105 +15,100 @@
#include "hmm_intrnl.h"
-int U(resize)(U(descriptor) *desc, void *mem, U(size_aau) n)
-{
- U(size_aau) i;
- head_record *next_head_ptr;
- head_record *head_ptr = PTR_REC_TO_HEAD(mem);
+int U(resize)(U(descriptor) *desc, void *mem, U(size_aau) n) {
+ U(size_aau) i;
+ head_record *next_head_ptr;
+ head_record *head_ptr = PTR_REC_TO_HEAD(mem);
- /* Flag. */
- int next_block_free;
+ /* Flag. */
+ int next_block_free;
- /* Convert n from desired block size in AAUs to BAUs. */
- n += HEAD_AAUS;
- n = DIV_ROUND_UP(n, HMM_BLOCK_ALIGN_UNIT);
+ /* Convert n from desired block size in AAUs to BAUs. */
+ n += HEAD_AAUS;
+ n = DIV_ROUND_UP(n, HMM_BLOCK_ALIGN_UNIT);
- if (n < MIN_BLOCK_BAUS)
- n = MIN_BLOCK_BAUS;
+ if (n < MIN_BLOCK_BAUS)
+ n = MIN_BLOCK_BAUS;
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(head_ptr)
+ AUDIT_BLOCK(head_ptr)
- if (!IS_BLOCK_ALLOCATED(head_ptr))
- HMM_AUDIT_FAIL
+ if (!IS_BLOCK_ALLOCATED(head_ptr))
+ HMM_AUDIT_FAIL
- if (desc->avl_tree_root)
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ if (desc->avl_tree_root)
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
- i = head_ptr->block_size;
+ i = head_ptr->block_size;
- next_head_ptr =
- (head_record *) BAUS_FORWARD(head_ptr, head_ptr->block_size);
+ next_head_ptr =
+ (head_record *) BAUS_FORWARD(head_ptr, head_ptr->block_size);
- next_block_free =
- (next_head_ptr == desc->last_freed) ||
- !IS_BLOCK_ALLOCATED(next_head_ptr);
+ next_block_free =
+ (next_head_ptr == desc->last_freed) ||
+ !IS_BLOCK_ALLOCATED(next_head_ptr);
- if (next_block_free)
- /* Block can expand into next free block. */
- i += BLOCK_BAUS(next_head_ptr);
+ if (next_block_free)
+ /* Block can expand into next free block. */
+ i += BLOCK_BAUS(next_head_ptr);
- if (n > i)
- /* Not enough room for block to expand. */
- return(-1);
+ if (n > i)
+ /* Not enough room for block to expand. */
+ return(-1);
- if (next_block_free)
- {
+ if (next_block_free) {
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(next_head_ptr)
+ AUDIT_BLOCK(next_head_ptr)
#endif
- if (next_head_ptr == desc->last_freed)
- desc->last_freed = 0;
- else
- U(out_of_free_collection)(desc, next_head_ptr);
+ if (next_head_ptr == desc->last_freed)
+ desc->last_freed = 0;
+ else
+ U(out_of_free_collection)(desc, next_head_ptr);
- next_head_ptr =
- (head_record *) BAUS_FORWARD(head_ptr, (U(size_bau)) i);
- }
+ next_head_ptr =
+ (head_record *) BAUS_FORWARD(head_ptr, (U(size_bau)) i);
+ }
- /* Set i to number of "extra" BAUs. */
- i -= n;
+ /* Set i to number of "extra" BAUs. */
+ i -= n;
- if (i < MIN_BLOCK_BAUS)
- /* Not enough extra BAUs to be a block on their own, so just keep them
- ** in the block being resized.
- */
- {
- n += i;
- i = n;
- }
- else
- {
- /* There are enough "leftover" BAUs in the next block to
- ** form a remainder block. */
+ if (i < MIN_BLOCK_BAUS)
+ /* Not enough extra BAUs to be a block on their own, so just keep them
+ ** in the block being resized.
+ */
+ {
+ n += i;
+ i = n;
+ } else {
+ /* There are enough "leftover" BAUs in the next block to
+ ** form a remainder block. */
- head_record *rem_head_ptr;
+ head_record *rem_head_ptr;
- rem_head_ptr = (head_record *) BAUS_FORWARD(head_ptr, n);
+ rem_head_ptr = (head_record *) BAUS_FORWARD(head_ptr, n);
- rem_head_ptr->previous_block_size = (U(size_bau)) n;
- rem_head_ptr->block_size = (U(size_bau)) i;
+ rem_head_ptr->previous_block_size = (U(size_bau)) n;
+ rem_head_ptr->block_size = (U(size_bau)) i;
- if (desc->last_freed)
- {
+ if (desc->last_freed) {
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(desc->last_freed)
+ AUDIT_BLOCK(desc->last_freed)
#endif
- U(into_free_collection)(desc, (head_record *)(desc->last_freed));
+ U(into_free_collection)(desc, (head_record *)(desc->last_freed));
- desc->last_freed = 0;
- }
-
- desc->last_freed = rem_head_ptr;
+ desc->last_freed = 0;
}
- head_ptr->block_size = (U(size_bau)) n;
- next_head_ptr->previous_block_size = (U(size_bau)) i;
+ desc->last_freed = rem_head_ptr;
+ }
+
+ head_ptr->block_size = (U(size_bau)) n;
+ next_head_ptr->previous_block_size = (U(size_bau)) i;
- return(0);
+ return(0);
}
diff --git a/vpx_mem/memory_manager/hmm_shrink.c b/vpx_mem/memory_manager/hmm_shrink.c
index 78fe268ba..f80aeead7 100644
--- a/vpx_mem/memory_manager/hmm_shrink.c
+++ b/vpx_mem/memory_manager/hmm_shrink.c
@@ -15,97 +15,89 @@
#include "hmm_intrnl.h"
-void U(shrink_chunk)(U(descriptor) *desc, U(size_bau) n_baus_to_shrink)
-{
- head_record *dummy_end_block = (head_record *)
- BAUS_BACKWARD(desc->end_of_shrinkable_chunk, DUMMY_END_BLOCK_BAUS);
+void U(shrink_chunk)(U(descriptor) *desc, U(size_bau) n_baus_to_shrink) {
+ head_record *dummy_end_block = (head_record *)
+ BAUS_BACKWARD(desc->end_of_shrinkable_chunk, DUMMY_END_BLOCK_BAUS);
#ifdef HMM_AUDIT_FAIL
- if (dummy_end_block->block_size != 0)
- /* Chunk does not have valid dummy end block. */
- HMM_AUDIT_FAIL
+ if (dummy_end_block->block_size != 0)
+ /* Chunk does not have valid dummy end block. */
+ HMM_AUDIT_FAIL
#endif
- if (n_baus_to_shrink)
- {
- head_record *last_block = (head_record *)
- BAUS_BACKWARD(
- dummy_end_block, dummy_end_block->previous_block_size);
+ if (n_baus_to_shrink) {
+ head_record *last_block = (head_record *)
+ BAUS_BACKWARD(
+ dummy_end_block, dummy_end_block->previous_block_size);
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(last_block)
+ AUDIT_BLOCK(last_block)
#endif
- if (last_block == desc->last_freed)
- {
- U(size_bau) bs = BLOCK_BAUS(last_block);
-
- /* Chunk will not be shrunk out of existence if
- ** 1. There is at least one allocated block in the chunk
- ** and the amount to shrink is exactly the size of the
- ** last block, OR
- ** 2. After the last block is shrunk, there will be enough
- ** BAUs left in it to form a minimal size block. */
- int chunk_will_survive =
- (PREV_BLOCK_BAUS(last_block) && (n_baus_to_shrink == bs)) ||
- (n_baus_to_shrink <= (U(size_bau))(bs - MIN_BLOCK_BAUS));
-
- if (chunk_will_survive ||
- (!PREV_BLOCK_BAUS(last_block) &&
- (n_baus_to_shrink ==
- (U(size_bau))(bs + DUMMY_END_BLOCK_BAUS))))
- {
- desc->last_freed = 0;
-
- if (chunk_will_survive)
- {
- bs -= n_baus_to_shrink;
-
- if (bs)
- {
- /* The last (non-dummy) block was not completely
- ** eliminated by the shrink. */
-
- last_block->block_size = bs;
-
- /* Create new dummy end record.
- */
- dummy_end_block =
- (head_record *) BAUS_FORWARD(last_block, bs);
- dummy_end_block->previous_block_size = bs;
- dummy_end_block->block_size = 0;
+ if (last_block == desc->last_freed) {
+ U(size_bau) bs = BLOCK_BAUS(last_block);
+
+ /* Chunk will not be shrunk out of existence if
+ ** 1. There is at least one allocated block in the chunk
+ ** and the amount to shrink is exactly the size of the
+ ** last block, OR
+ ** 2. After the last block is shrunk, there will be enough
+ ** BAUs left in it to form a minimal size block. */
+ int chunk_will_survive =
+ (PREV_BLOCK_BAUS(last_block) && (n_baus_to_shrink == bs)) ||
+ (n_baus_to_shrink <= (U(size_bau))(bs - MIN_BLOCK_BAUS));
+
+ if (chunk_will_survive ||
+ (!PREV_BLOCK_BAUS(last_block) &&
+ (n_baus_to_shrink ==
+ (U(size_bau))(bs + DUMMY_END_BLOCK_BAUS)))) {
+ desc->last_freed = 0;
+
+ if (chunk_will_survive) {
+ bs -= n_baus_to_shrink;
+
+ if (bs) {
+ /* The last (non-dummy) block was not completely
+ ** eliminated by the shrink. */
+
+ last_block->block_size = bs;
+
+ /* Create new dummy end record.
+ */
+ dummy_end_block =
+ (head_record *) BAUS_FORWARD(last_block, bs);
+ dummy_end_block->previous_block_size = bs;
+ dummy_end_block->block_size = 0;
#ifdef HMM_AUDIT_FAIL
- if (desc->avl_tree_root)
- AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
+ if (desc->avl_tree_root)
+ AUDIT_BLOCK(PTR_REC_TO_HEAD(desc->avl_tree_root))
#endif
- U(into_free_collection)(desc, last_block);
- }
- else
- {
- /* The last (non-dummy) block was completely
- ** eliminated by the shrink. Make its head
- ** the new dummy end block.
- */
- last_block->block_size = 0;
- last_block->previous_block_size &= ~HIGH_BIT_BAU_SIZE;
- }
- }
- }
+ U(into_free_collection)(desc, last_block);
+ } else {
+ /* The last (non-dummy) block was completely
+ ** eliminated by the shrink. Make its head
+ ** the new dummy end block.
+ */
+ last_block->block_size = 0;
+ last_block->previous_block_size &= ~HIGH_BIT_BAU_SIZE;
+ }
+ }
+ }
#ifdef HMM_AUDIT_FAIL
- else
- HMM_AUDIT_FAIL
+ else
+ HMM_AUDIT_FAIL
#endif
- }
+ }
#ifdef HMM_AUDIT_FAIL
- else
- HMM_AUDIT_FAIL
+ else
+ HMM_AUDIT_FAIL
#endif
- }
+ }
}
diff --git a/vpx_mem/memory_manager/hmm_true.c b/vpx_mem/memory_manager/hmm_true.c
index 3f7be8f70..4428c3e34 100644
--- a/vpx_mem/memory_manager/hmm_true.c
+++ b/vpx_mem/memory_manager/hmm_true.c
@@ -15,18 +15,17 @@
#include "hmm_intrnl.h"
-U(size_aau) U(true_size)(void *payload_ptr)
-{
- register head_record *head_ptr = PTR_REC_TO_HEAD(payload_ptr);
+U(size_aau) U(true_size)(void *payload_ptr) {
+ register head_record *head_ptr = PTR_REC_TO_HEAD(payload_ptr);
#ifdef HMM_AUDIT_FAIL
- AUDIT_BLOCK(head_ptr)
+ AUDIT_BLOCK(head_ptr)
#endif
- /* Convert block size from BAUs to AAUs. Subtract head size, leaving
- ** payload size.
- */
- return(
- (BLOCK_BAUS(head_ptr) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT)) -
- HEAD_AAUS);
+ /* Convert block size from BAUs to AAUs. Subtract head size, leaving
+ ** payload size.
+ */
+ return(
+ (BLOCK_BAUS(head_ptr) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT)) -
+ HEAD_AAUS);
}
diff --git a/vpx_mem/memory_manager/include/cavl_if.h b/vpx_mem/memory_manager/include/cavl_if.h
index 1b2c9b738..ec6e525b7 100644
--- a/vpx_mem/memory_manager/include/cavl_if.h
+++ b/vpx_mem/memory_manager/include/cavl_if.h
@@ -32,13 +32,12 @@
#ifndef AVL_SEARCH_TYPE_DEFINED_
#define AVL_SEARCH_TYPE_DEFINED_
-typedef enum
-{
- AVL_EQUAL = 1,
- AVL_LESS = 2,
- AVL_GREATER = 4,
- AVL_LESS_EQUAL = AVL_EQUAL | AVL_LESS,
- AVL_GREATER_EQUAL = AVL_EQUAL | AVL_GREATER
+typedef enum {
+ AVL_EQUAL = 1,
+ AVL_LESS = 2,
+ AVL_GREATER = 4,
+ AVL_LESS_EQUAL = AVL_EQUAL | AVL_LESS,
+ AVL_GREATER_EQUAL = AVL_EQUAL | AVL_GREATER
}
avl_search_type;
@@ -75,15 +74,14 @@ avl_search_type;
#endif
-typedef struct
-{
+typedef struct {
#ifdef AVL_INSIDE_STRUCT
- AVL_INSIDE_STRUCT
+ AVL_INSIDE_STRUCT
#endif
- AVL_HANDLE root;
+ AVL_HANDLE root;
}
L_(avl);
@@ -108,7 +106,7 @@ L_SC AVL_HANDLE L_(subst)(L_(avl) *tree, AVL_HANDLE new_node);
#ifdef AVL_BUILD_ITER_TYPE
L_SC int L_(build)(
- L_(avl) *tree, AVL_BUILD_ITER_TYPE p, L_SIZE num_nodes);
+ L_(avl) *tree, AVL_BUILD_ITER_TYPE p, L_SIZE num_nodes);
#endif
@@ -153,7 +151,7 @@ L_SC int L_(build)(
/* Maximum depth may be more than number of bits in a long. */
#define L_BIT_ARR_DEFN(NAME) \
- unsigned long NAME[((AVL_MAX_DEPTH) + L_LONG_BIT - 1) / L_LONG_BIT];
+ unsigned long NAME[((AVL_MAX_DEPTH) + L_LONG_BIT - 1) / L_LONG_BIT];
#else
@@ -164,29 +162,28 @@ L_SC int L_(build)(
#endif
/* Iterator structure. */
-typedef struct
-{
- /* Tree being iterated over. */
- L_(avl) *tree_;
-
- /* Records a path into the tree. If bit n is true, indicates
- ** take greater branch from the nth node in the path, otherwise
- ** take the less branch. bit 0 gives branch from root, and
- ** so on. */
- L_BIT_ARR_DEFN(branch)
-
- /* Zero-based depth of path into tree. */
- unsigned depth;
-
- /* Handles of nodes in path from root to current node (returned by *). */
- AVL_HANDLE path_h[(AVL_MAX_DEPTH) - 1];
+typedef struct {
+ /* Tree being iterated over. */
+ L_(avl) *tree_;
+
+ /* Records a path into the tree. If bit n is true, indicates
+ ** take greater branch from the nth node in the path, otherwise
+ ** take the less branch. bit 0 gives branch from root, and
+ ** so on. */
+ L_BIT_ARR_DEFN(branch)
+
+ /* Zero-based depth of path into tree. */
+ unsigned depth;
+
+ /* Handles of nodes in path from root to current node (returned by *). */
+ AVL_HANDLE path_h[(AVL_MAX_DEPTH) - 1];
}
L_(iter);
/* Iterator function prototypes. */
L_SC void L_(start_iter)(
- L_(avl) *tree, L_(iter) *iter, AVL_KEY k, avl_search_type st);
+ L_(avl) *tree, L_(iter) *iter, AVL_KEY k, avl_search_type st);
L_SC void L_(start_iter_least)(L_(avl) *tree, L_(iter) *iter);
diff --git a/vpx_mem/memory_manager/include/cavl_impl.h b/vpx_mem/memory_manager/include/cavl_impl.h
index 5e165dd4d..cf7deb7fb 100644
--- a/vpx_mem/memory_manager/include/cavl_impl.h
+++ b/vpx_mem/memory_manager/include/cavl_impl.h
@@ -110,16 +110,16 @@
#define L_BIT_ARR_DEFN(NAME) unsigned long NAME[L_BIT_ARR_LONGS];
#define L_BIT_ARR_VAL(BIT_ARR, BIT_NUM) \
- ((BIT_ARR)[(BIT_NUM) / L_LONG_BIT] & (1L << ((BIT_NUM) % L_LONG_BIT)))
+ ((BIT_ARR)[(BIT_NUM) / L_LONG_BIT] & (1L << ((BIT_NUM) % L_LONG_BIT)))
#define L_BIT_ARR_0(BIT_ARR, BIT_NUM) \
- (BIT_ARR)[(BIT_NUM) / L_LONG_BIT] &= ~(1L << ((BIT_NUM) % L_LONG_BIT));
+ (BIT_ARR)[(BIT_NUM) / L_LONG_BIT] &= ~(1L << ((BIT_NUM) % L_LONG_BIT));
#define L_BIT_ARR_1(BIT_ARR, BIT_NUM) \
- (BIT_ARR)[(BIT_NUM) / L_LONG_BIT] |= 1L << ((BIT_NUM) % L_LONG_BIT);
+ (BIT_ARR)[(BIT_NUM) / L_LONG_BIT] |= 1L << ((BIT_NUM) % L_LONG_BIT);
#define L_BIT_ARR_ALL(BIT_ARR, BIT_VAL) \
- { int i = L_BIT_ARR_LONGS; do (BIT_ARR)[--i] = 0L - (BIT_VAL); while(i); }
+ { int i = L_BIT_ARR_LONGS; do (BIT_ARR)[--i] = 0L - (BIT_VAL); while(i); }
#else /* The bit array can definitely fit in one long */
@@ -138,7 +138,7 @@
#ifdef AVL_READ_ERRORS_HAPPEN
#define L_CHECK_READ_ERROR(ERROR_RETURN) \
- { if (AVL_READ_ERROR) return(ERROR_RETURN); }
+ { if (AVL_READ_ERROR) return(ERROR_RETURN); }
#else
@@ -179,18 +179,16 @@
#if (L_IMPL_MASK & AVL_IMPL_INIT)
-L_SC void L_(init)(L_(avl) *l_tree)
-{
- l_tree->root = AVL_NULL;
+L_SC void L_(init)(L_(avl) *l_tree) {
+ l_tree->root = AVL_NULL;
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_IS_EMPTY)
-L_SC int L_(is_empty)(L_(avl) *l_tree)
-{
- return(l_tree->root == AVL_NULL);
+L_SC int L_(is_empty)(L_(avl) *l_tree) {
+ return(l_tree->root == AVL_NULL);
}
#endif
@@ -201,358 +199,305 @@ L_SC int L_(is_empty)(L_(avl) *l_tree)
/* Balances subtree, returns handle of root node of subtree after balancing.
*/
-L_SC AVL_HANDLE L_(balance)(L_BALANCE_PARAM_DECL_PREFIX AVL_HANDLE bal_h)
-{
- AVL_HANDLE deep_h;
+L_SC AVL_HANDLE L_(balance)(L_BALANCE_PARAM_DECL_PREFIX AVL_HANDLE bal_h) {
+ AVL_HANDLE deep_h;
- /* Either the "greater than" or the "less than" subtree of
- ** this node has to be 2 levels deeper (or else it wouldn't
- ** need balancing).
- */
- if (AVL_GET_BALANCE_FACTOR(bal_h) > 0)
- {
- /* "Greater than" subtree is deeper. */
+ /* Either the "greater than" or the "less than" subtree of
+ ** this node has to be 2 levels deeper (or else it wouldn't
+ ** need balancing).
+ */
+ if (AVL_GET_BALANCE_FACTOR(bal_h) > 0) {
+ /* "Greater than" subtree is deeper. */
- deep_h = AVL_GET_GREATER(bal_h, 1);
+ deep_h = AVL_GET_GREATER(bal_h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
+ L_CHECK_READ_ERROR(AVL_NULL)
- if (AVL_GET_BALANCE_FACTOR(deep_h) < 0)
- {
- int bf;
-
- AVL_HANDLE old_h = bal_h;
- bal_h = AVL_GET_LESS(deep_h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
- AVL_SET_GREATER(old_h, AVL_GET_LESS(bal_h, 1))
- AVL_SET_LESS(deep_h, AVL_GET_GREATER(bal_h, 1))
- AVL_SET_LESS(bal_h, old_h)
- AVL_SET_GREATER(bal_h, deep_h)
-
- bf = AVL_GET_BALANCE_FACTOR(bal_h);
-
- if (bf != 0)
- {
- if (bf > 0)
- {
- AVL_SET_BALANCE_FACTOR(old_h, -1)
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(deep_h, 1)
- AVL_SET_BALANCE_FACTOR(old_h, 0)
- }
-
- AVL_SET_BALANCE_FACTOR(bal_h, 0)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(old_h, 0)
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- }
- }
- else
- {
- AVL_SET_GREATER(bal_h, AVL_GET_LESS(deep_h, 0))
- AVL_SET_LESS(deep_h, bal_h)
-
- if (AVL_GET_BALANCE_FACTOR(deep_h) == 0)
- {
- AVL_SET_BALANCE_FACTOR(deep_h, -1)
- AVL_SET_BALANCE_FACTOR(bal_h, 1)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- AVL_SET_BALANCE_FACTOR(bal_h, 0)
- }
-
- bal_h = deep_h;
+ if (AVL_GET_BALANCE_FACTOR(deep_h) < 0) {
+ int bf;
+
+ AVL_HANDLE old_h = bal_h;
+ bal_h = AVL_GET_LESS(deep_h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ AVL_SET_GREATER(old_h, AVL_GET_LESS(bal_h, 1))
+ AVL_SET_LESS(deep_h, AVL_GET_GREATER(bal_h, 1))
+ AVL_SET_LESS(bal_h, old_h)
+ AVL_SET_GREATER(bal_h, deep_h)
+
+ bf = AVL_GET_BALANCE_FACTOR(bal_h);
+
+ if (bf != 0) {
+ if (bf > 0) {
+ AVL_SET_BALANCE_FACTOR(old_h, -1)
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ } else {
+ AVL_SET_BALANCE_FACTOR(deep_h, 1)
+ AVL_SET_BALANCE_FACTOR(old_h, 0)
}
+
+ AVL_SET_BALANCE_FACTOR(bal_h, 0)
+ } else {
+ AVL_SET_BALANCE_FACTOR(old_h, 0)
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ }
+ } else {
+ AVL_SET_GREATER(bal_h, AVL_GET_LESS(deep_h, 0))
+ AVL_SET_LESS(deep_h, bal_h)
+
+ if (AVL_GET_BALANCE_FACTOR(deep_h) == 0) {
+ AVL_SET_BALANCE_FACTOR(deep_h, -1)
+ AVL_SET_BALANCE_FACTOR(bal_h, 1)
+ } else {
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ AVL_SET_BALANCE_FACTOR(bal_h, 0)
+ }
+
+ bal_h = deep_h;
}
- else
- {
- /* "Less than" subtree is deeper. */
+ } else {
+ /* "Less than" subtree is deeper. */
- deep_h = AVL_GET_LESS(bal_h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
+ deep_h = AVL_GET_LESS(bal_h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
- if (AVL_GET_BALANCE_FACTOR(deep_h) > 0)
- {
- int bf;
- AVL_HANDLE old_h = bal_h;
- bal_h = AVL_GET_GREATER(deep_h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
- AVL_SET_LESS(old_h, AVL_GET_GREATER(bal_h, 0))
- AVL_SET_GREATER(deep_h, AVL_GET_LESS(bal_h, 0))
- AVL_SET_GREATER(bal_h, old_h)
- AVL_SET_LESS(bal_h, deep_h)
-
- bf = AVL_GET_BALANCE_FACTOR(bal_h);
-
- if (bf != 0)
- {
- if (bf < 0)
- {
- AVL_SET_BALANCE_FACTOR(old_h, 1)
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(deep_h, -1)
- AVL_SET_BALANCE_FACTOR(old_h, 0)
- }
-
- AVL_SET_BALANCE_FACTOR(bal_h, 0)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(old_h, 0)
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- }
- }
- else
- {
- AVL_SET_LESS(bal_h, AVL_GET_GREATER(deep_h, 0))
- AVL_SET_GREATER(deep_h, bal_h)
-
- if (AVL_GET_BALANCE_FACTOR(deep_h) == 0)
- {
- AVL_SET_BALANCE_FACTOR(deep_h, 1)
- AVL_SET_BALANCE_FACTOR(bal_h, -1)
- }
- else
- {
- AVL_SET_BALANCE_FACTOR(deep_h, 0)
- AVL_SET_BALANCE_FACTOR(bal_h, 0)
- }
-
- bal_h = deep_h;
+ if (AVL_GET_BALANCE_FACTOR(deep_h) > 0) {
+ int bf;
+ AVL_HANDLE old_h = bal_h;
+ bal_h = AVL_GET_GREATER(deep_h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ AVL_SET_LESS(old_h, AVL_GET_GREATER(bal_h, 0))
+ AVL_SET_GREATER(deep_h, AVL_GET_LESS(bal_h, 0))
+ AVL_SET_GREATER(bal_h, old_h)
+ AVL_SET_LESS(bal_h, deep_h)
+
+ bf = AVL_GET_BALANCE_FACTOR(bal_h);
+
+ if (bf != 0) {
+ if (bf < 0) {
+ AVL_SET_BALANCE_FACTOR(old_h, 1)
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ } else {
+ AVL_SET_BALANCE_FACTOR(deep_h, -1)
+ AVL_SET_BALANCE_FACTOR(old_h, 0)
}
+
+ AVL_SET_BALANCE_FACTOR(bal_h, 0)
+ } else {
+ AVL_SET_BALANCE_FACTOR(old_h, 0)
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ }
+ } else {
+ AVL_SET_LESS(bal_h, AVL_GET_GREATER(deep_h, 0))
+ AVL_SET_GREATER(deep_h, bal_h)
+
+ if (AVL_GET_BALANCE_FACTOR(deep_h) == 0) {
+ AVL_SET_BALANCE_FACTOR(deep_h, 1)
+ AVL_SET_BALANCE_FACTOR(bal_h, -1)
+ } else {
+ AVL_SET_BALANCE_FACTOR(deep_h, 0)
+ AVL_SET_BALANCE_FACTOR(bal_h, 0)
+ }
+
+ bal_h = deep_h;
}
+ }
- return(bal_h);
+ return(bal_h);
}
-L_SC AVL_HANDLE L_(insert)(L_(avl) *l_tree, AVL_HANDLE h)
-{
- AVL_SET_LESS(h, AVL_NULL)
- AVL_SET_GREATER(h, AVL_NULL)
- AVL_SET_BALANCE_FACTOR(h, 0)
+L_SC AVL_HANDLE L_(insert)(L_(avl) *l_tree, AVL_HANDLE h) {
+ AVL_SET_LESS(h, AVL_NULL)
+ AVL_SET_GREATER(h, AVL_NULL)
+ AVL_SET_BALANCE_FACTOR(h, 0)
- if (l_tree->root == AVL_NULL)
- l_tree->root = h;
- else
- {
- /* Last unbalanced node encountered in search for insertion point. */
- AVL_HANDLE unbal = AVL_NULL;
- /* Parent of last unbalanced node. */
- AVL_HANDLE parent_unbal = AVL_NULL;
- /* Balance factor of last unbalanced node. */
- int unbal_bf;
-
- /* Zero-based depth in tree. */
- unsigned depth = 0, unbal_depth = 0;
-
- /* Records a path into the tree. If bit n is true, indicates
- ** take greater branch from the nth node in the path, otherwise
- ** take the less branch. bit 0 gives branch from root, and
- ** so on. */
- L_BIT_ARR_DEFN(branch)
-
- AVL_HANDLE hh = l_tree->root;
- AVL_HANDLE parent = AVL_NULL;
- int cmp;
-
- do
- {
- if (AVL_GET_BALANCE_FACTOR(hh) != 0)
- {
- unbal = hh;
- parent_unbal = parent;
- unbal_depth = depth;
- }
-
- cmp = AVL_COMPARE_NODE_NODE(h, hh);
-
- if (cmp == 0)
- /* Duplicate key. */
- return(hh);
-
- parent = hh;
-
- if (cmp > 0)
- {
- hh = AVL_GET_GREATER(hh, 1);
- L_BIT_ARR_1(branch, depth)
- }
- else
- {
- hh = AVL_GET_LESS(hh, 1);
- L_BIT_ARR_0(branch, depth)
- }
-
- L_CHECK_READ_ERROR(AVL_NULL)
- depth++;
- }
- while (hh != AVL_NULL);
+ if (l_tree->root == AVL_NULL)
+ l_tree->root = h;
+ else {
+ /* Last unbalanced node encountered in search for insertion point. */
+ AVL_HANDLE unbal = AVL_NULL;
+ /* Parent of last unbalanced node. */
+ AVL_HANDLE parent_unbal = AVL_NULL;
+ /* Balance factor of last unbalanced node. */
+ int unbal_bf;
- /* Add node to insert as leaf of tree. */
- if (cmp < 0)
- AVL_SET_LESS(parent, h)
- else
- AVL_SET_GREATER(parent, h)
+ /* Zero-based depth in tree. */
+ unsigned depth = 0, unbal_depth = 0;
- depth = unbal_depth;
+ /* Records a path into the tree. If bit n is true, indicates
+ ** take greater branch from the nth node in the path, otherwise
+ ** take the less branch. bit 0 gives branch from root, and
+ ** so on. */
+ L_BIT_ARR_DEFN(branch)
- if (unbal == AVL_NULL)
- hh = l_tree->root;
- else
- {
- cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
- depth++;
- unbal_bf = AVL_GET_BALANCE_FACTOR(unbal);
-
- if (cmp < 0)
- unbal_bf--;
- else /* cmp > 0 */
- unbal_bf++;
-
- hh = cmp < 0 ? AVL_GET_LESS(unbal, 1) : AVL_GET_GREATER(unbal, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
-
- if ((unbal_bf != -2) && (unbal_bf != 2))
- {
- /* No rebalancing of tree is necessary. */
- AVL_SET_BALANCE_FACTOR(unbal, unbal_bf)
- unbal = AVL_NULL;
- }
- }
+ AVL_HANDLE hh = l_tree->root;
+ AVL_HANDLE parent = AVL_NULL;
+ int cmp;
- if (hh != AVL_NULL)
- while (h != hh)
- {
- cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
- depth++;
-
- if (cmp < 0)
- {
- AVL_SET_BALANCE_FACTOR(hh, -1)
- hh = AVL_GET_LESS(hh, 1);
- }
- else /* cmp > 0 */
- {
- AVL_SET_BALANCE_FACTOR(hh, 1)
- hh = AVL_GET_GREATER(hh, 1);
- }
-
- L_CHECK_READ_ERROR(AVL_NULL)
- }
-
- if (unbal != AVL_NULL)
- {
- unbal = L_(balance)(L_BALANCE_PARAM_CALL_PREFIX unbal);
- L_CHECK_READ_ERROR(AVL_NULL)
-
- if (parent_unbal == AVL_NULL)
- l_tree->root = unbal;
- else
- {
- depth = unbal_depth - 1;
- cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
-
- if (cmp < 0)
- AVL_SET_LESS(parent_unbal, unbal)
- else /* cmp > 0 */
- AVL_SET_GREATER(parent_unbal, unbal)
- }
- }
+ do {
+ if (AVL_GET_BALANCE_FACTOR(hh) != 0) {
+ unbal = hh;
+ parent_unbal = parent;
+ unbal_depth = depth;
+ }
- }
+ cmp = AVL_COMPARE_NODE_NODE(h, hh);
- return(h);
-}
+ if (cmp == 0)
+ /* Duplicate key. */
+ return(hh);
-#endif
+ parent = hh;
-#if (L_IMPL_MASK & AVL_IMPL_SEARCH)
+ if (cmp > 0) {
+ hh = AVL_GET_GREATER(hh, 1);
+ L_BIT_ARR_1(branch, depth)
+ } else {
+ hh = AVL_GET_LESS(hh, 1);
+ L_BIT_ARR_0(branch, depth)
+ }
+
+ L_CHECK_READ_ERROR(AVL_NULL)
+ depth++;
+ } while (hh != AVL_NULL);
+
+ /* Add node to insert as leaf of tree. */
+ if (cmp < 0)
+ AVL_SET_LESS(parent, h)
+ else
+ AVL_SET_GREATER(parent, h)
+
+ depth = unbal_depth;
+
+ if (unbal == AVL_NULL)
+ hh = l_tree->root;
+ else {
+ cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
+ depth++;
+ unbal_bf = AVL_GET_BALANCE_FACTOR(unbal);
+
+ if (cmp < 0)
+ unbal_bf--;
+ else /* cmp > 0 */
+ unbal_bf++;
+
+ hh = cmp < 0 ? AVL_GET_LESS(unbal, 1) : AVL_GET_GREATER(unbal, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+
+ if ((unbal_bf != -2) && (unbal_bf != 2)) {
+ /* No rebalancing of tree is necessary. */
+ AVL_SET_BALANCE_FACTOR(unbal, unbal_bf)
+ unbal = AVL_NULL;
+ }
+ }
-L_SC AVL_HANDLE L_(search)(L_(avl) *l_tree, AVL_KEY k, avl_search_type st)
-{
- int cmp, target_cmp;
- AVL_HANDLE match_h = AVL_NULL;
- AVL_HANDLE h = l_tree->root;
+ if (hh != AVL_NULL)
+ while (h != hh) {
+ cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
+ depth++;
- if (st & AVL_LESS)
- target_cmp = 1;
- else if (st & AVL_GREATER)
- target_cmp = -1;
- else
- target_cmp = 0;
+ if (cmp < 0) {
+ AVL_SET_BALANCE_FACTOR(hh, -1)
+ hh = AVL_GET_LESS(hh, 1);
+ } else { /* cmp > 0 */
+ AVL_SET_BALANCE_FACTOR(hh, 1)
+ hh = AVL_GET_GREATER(hh, 1);
+ }
- while (h != AVL_NULL)
- {
- cmp = AVL_COMPARE_KEY_NODE(k, h);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ }
- if (cmp == 0)
- {
- if (st & AVL_EQUAL)
- {
- match_h = h;
- break;
- }
+ if (unbal != AVL_NULL) {
+ unbal = L_(balance)(L_BALANCE_PARAM_CALL_PREFIX unbal);
+ L_CHECK_READ_ERROR(AVL_NULL)
- cmp = -target_cmp;
- }
- else if (target_cmp != 0)
- if (!((cmp ^ target_cmp) & L_MASK_HIGH_BIT))
- /* cmp and target_cmp are both positive or both negative. */
- match_h = h;
+ if (parent_unbal == AVL_NULL)
+ l_tree->root = unbal;
+ else {
+ depth = unbal_depth - 1;
+ cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
- h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
+ if (cmp < 0)
+ AVL_SET_LESS(parent_unbal, unbal)
+ else /* cmp > 0 */
+ AVL_SET_GREATER(parent_unbal, unbal)
+ }
}
- return(match_h);
+ }
+
+ return(h);
+}
+
+#endif
+
+#if (L_IMPL_MASK & AVL_IMPL_SEARCH)
+
+L_SC AVL_HANDLE L_(search)(L_(avl) *l_tree, AVL_KEY k, avl_search_type st) {
+ int cmp, target_cmp;
+ AVL_HANDLE match_h = AVL_NULL;
+ AVL_HANDLE h = l_tree->root;
+
+ if (st & AVL_LESS)
+ target_cmp = 1;
+ else if (st & AVL_GREATER)
+ target_cmp = -1;
+ else
+ target_cmp = 0;
+
+ while (h != AVL_NULL) {
+ cmp = AVL_COMPARE_KEY_NODE(k, h);
+
+ if (cmp == 0) {
+ if (st & AVL_EQUAL) {
+ match_h = h;
+ break;
+ }
+
+ cmp = -target_cmp;
+ } else if (target_cmp != 0)
+ if (!((cmp ^ target_cmp) & L_MASK_HIGH_BIT))
+ /* cmp and target_cmp are both positive or both negative. */
+ match_h = h;
+
+ h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ }
+
+ return(match_h);
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_SEARCH_LEAST)
-L_SC AVL_HANDLE L_(search_least)(L_(avl) *l_tree)
-{
- AVL_HANDLE h = l_tree->root;
- AVL_HANDLE parent = AVL_NULL;
+L_SC AVL_HANDLE L_(search_least)(L_(avl) *l_tree) {
+ AVL_HANDLE h = l_tree->root;
+ AVL_HANDLE parent = AVL_NULL;
- while (h != AVL_NULL)
- {
- parent = h;
- h = AVL_GET_LESS(h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
- }
+ while (h != AVL_NULL) {
+ parent = h;
+ h = AVL_GET_LESS(h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ }
- return(parent);
+ return(parent);
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_SEARCH_GREATEST)
-L_SC AVL_HANDLE L_(search_greatest)(L_(avl) *l_tree)
-{
- AVL_HANDLE h = l_tree->root;
- AVL_HANDLE parent = AVL_NULL;
+L_SC AVL_HANDLE L_(search_greatest)(L_(avl) *l_tree) {
+ AVL_HANDLE h = l_tree->root;
+ AVL_HANDLE parent = AVL_NULL;
- while (h != AVL_NULL)
- {
- parent = h;
- h = AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
- }
+ while (h != AVL_NULL) {
+ parent = h;
+ h = AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ }
- return(parent);
+ return(parent);
}
#endif
@@ -564,284 +509,253 @@ L_SC AVL_HANDLE L_(search_greatest)(L_(avl) *l_tree)
*/
L_SC AVL_HANDLE L_(balance)(L_BALANCE_PARAM_DECL_PREFIX AVL_HANDLE bal_h);
-L_SC AVL_HANDLE L_(remove)(L_(avl) *l_tree, AVL_KEY k)
-{
- /* Zero-based depth in tree. */
- unsigned depth = 0, rm_depth;
-
- /* Records a path into the tree. If bit n is true, indicates
- ** take greater branch from the nth node in the path, otherwise
- ** take the less branch. bit 0 gives branch from root, and
- ** so on. */
- L_BIT_ARR_DEFN(branch)
-
- AVL_HANDLE h = l_tree->root;
- AVL_HANDLE parent = AVL_NULL;
- AVL_HANDLE child;
- AVL_HANDLE path;
- int cmp, cmp_shortened_sub_with_path;
- int reduced_depth;
- int bf;
- AVL_HANDLE rm;
- AVL_HANDLE parent_rm;
-
- for (; ;)
- {
- if (h == AVL_NULL)
- /* No node in tree with given key. */
- return(AVL_NULL);
-
- cmp = AVL_COMPARE_KEY_NODE(k, h);
+L_SC AVL_HANDLE L_(remove)(L_(avl) *l_tree, AVL_KEY k) {
+ /* Zero-based depth in tree. */
+ unsigned depth = 0, rm_depth;
+
+ /* Records a path into the tree. If bit n is true, indicates
+ ** take greater branch from the nth node in the path, otherwise
+ ** take the less branch. bit 0 gives branch from root, and
+ ** so on. */
+ L_BIT_ARR_DEFN(branch)
+
+ AVL_HANDLE h = l_tree->root;
+ AVL_HANDLE parent = AVL_NULL;
+ AVL_HANDLE child;
+ AVL_HANDLE path;
+ int cmp, cmp_shortened_sub_with_path;
+ int reduced_depth;
+ int bf;
+ AVL_HANDLE rm;
+ AVL_HANDLE parent_rm;
+
+ for (;;) {
+ if (h == AVL_NULL)
+ /* No node in tree with given key. */
+ return(AVL_NULL);
- if (cmp == 0)
- /* Found node to remove. */
- break;
+ cmp = AVL_COMPARE_KEY_NODE(k, h);
- parent = h;
+ if (cmp == 0)
+ /* Found node to remove. */
+ break;
- if (cmp > 0)
- {
- h = AVL_GET_GREATER(h, 1);
- L_BIT_ARR_1(branch, depth)
- }
- else
- {
- h = AVL_GET_LESS(h, 1);
- L_BIT_ARR_0(branch, depth)
- }
+ parent = h;
- L_CHECK_READ_ERROR(AVL_NULL)
- depth++;
- cmp_shortened_sub_with_path = cmp;
+ if (cmp > 0) {
+ h = AVL_GET_GREATER(h, 1);
+ L_BIT_ARR_1(branch, depth)
+ } else {
+ h = AVL_GET_LESS(h, 1);
+ L_BIT_ARR_0(branch, depth)
}
- rm = h;
- parent_rm = parent;
- rm_depth = depth;
-
- /* If the node to remove is not a leaf node, we need to get a
- ** leaf node, or a node with a single leaf as its child, to put
- ** in the place of the node to remove. We will get the greatest
- ** node in the less subtree (of the node to remove), or the least
- ** node in the greater subtree. We take the leaf node from the
- ** deeper subtree, if there is one. */
-
- if (AVL_GET_BALANCE_FACTOR(h) < 0)
- {
+ L_CHECK_READ_ERROR(AVL_NULL)
+ depth++;
+ cmp_shortened_sub_with_path = cmp;
+ }
+
+ rm = h;
+ parent_rm = parent;
+ rm_depth = depth;
+
+ /* If the node to remove is not a leaf node, we need to get a
+ ** leaf node, or a node with a single leaf as its child, to put
+ ** in the place of the node to remove. We will get the greatest
+ ** node in the less subtree (of the node to remove), or the least
+ ** node in the greater subtree. We take the leaf node from the
+ ** deeper subtree, if there is one. */
+
+ if (AVL_GET_BALANCE_FACTOR(h) < 0) {
+ child = AVL_GET_LESS(h, 1);
+ L_BIT_ARR_0(branch, depth)
+ cmp = -1;
+ } else {
+ child = AVL_GET_GREATER(h, 1);
+ L_BIT_ARR_1(branch, depth)
+ cmp = 1;
+ }
+
+ L_CHECK_READ_ERROR(AVL_NULL)
+ depth++;
+
+ if (child != AVL_NULL) {
+ cmp = -cmp;
+
+ do {
+ parent = h;
+ h = child;
+
+ if (cmp < 0) {
child = AVL_GET_LESS(h, 1);
L_BIT_ARR_0(branch, depth)
- cmp = -1;
- }
- else
- {
+ } else {
child = AVL_GET_GREATER(h, 1);
L_BIT_ARR_1(branch, depth)
- cmp = 1;
- }
+ }
- L_CHECK_READ_ERROR(AVL_NULL)
- depth++;
+ L_CHECK_READ_ERROR(AVL_NULL)
+ depth++;
+ } while (child != AVL_NULL);
- if (child != AVL_NULL)
- {
- cmp = -cmp;
-
- do
- {
- parent = h;
- h = child;
-
- if (cmp < 0)
- {
- child = AVL_GET_LESS(h, 1);
- L_BIT_ARR_0(branch, depth)
- }
- else
- {
- child = AVL_GET_GREATER(h, 1);
- L_BIT_ARR_1(branch, depth)
- }
-
- L_CHECK_READ_ERROR(AVL_NULL)
- depth++;
- }
- while (child != AVL_NULL);
+ if (parent == rm)
+ /* Only went through do loop once. Deleted node will be replaced
+ ** in the tree structure by one of its immediate children. */
+ cmp_shortened_sub_with_path = -cmp;
+ else
+ cmp_shortened_sub_with_path = cmp;
+
+ /* Get the handle of the opposite child, which may not be null. */
+ child = cmp > 0 ? AVL_GET_LESS(h, 0) : AVL_GET_GREATER(h, 0);
+ }
- if (parent == rm)
- /* Only went through do loop once. Deleted node will be replaced
- ** in the tree structure by one of its immediate children. */
- cmp_shortened_sub_with_path = -cmp;
+ if (parent == AVL_NULL)
+ /* There were only 1 or 2 nodes in this tree. */
+ l_tree->root = child;
+ else if (cmp_shortened_sub_with_path < 0)
+ AVL_SET_LESS(parent, child)
+ else
+ AVL_SET_GREATER(parent, child)
+
+ /* "path" is the parent of the subtree being eliminated or reduced
+ ** from a depth of 2 to 1. If "path" is the node to be removed, we
+ ** set path to the node we're about to poke into the position of the
+ ** node to be removed. */
+ path = parent == rm ? h : parent;
+
+ if (h != rm) {
+ /* Poke in the replacement for the node to be removed. */
+ AVL_SET_LESS(h, AVL_GET_LESS(rm, 0))
+ AVL_SET_GREATER(h, AVL_GET_GREATER(rm, 0))
+ AVL_SET_BALANCE_FACTOR(h, AVL_GET_BALANCE_FACTOR(rm))
+
+ if (parent_rm == AVL_NULL)
+ l_tree->root = h;
+ else {
+ depth = rm_depth - 1;
+
+ if (L_BIT_ARR_VAL(branch, depth))
+ AVL_SET_GREATER(parent_rm, h)
else
- cmp_shortened_sub_with_path = cmp;
+ AVL_SET_LESS(parent_rm, h)
+ }
+ }
- /* Get the handle of the opposite child, which may not be null. */
- child = cmp > 0 ? AVL_GET_LESS(h, 0) : AVL_GET_GREATER(h, 0);
- }
+ if (path != AVL_NULL) {
+ /* Create a temporary linked list from the parent of the path node
+ ** to the root node. */
+ h = l_tree->root;
+ parent = AVL_NULL;
+ depth = 0;
- if (parent == AVL_NULL)
- /* There were only 1 or 2 nodes in this tree. */
- l_tree->root = child;
- else if (cmp_shortened_sub_with_path < 0)
- AVL_SET_LESS(parent, child)
- else
- AVL_SET_GREATER(parent, child)
-
- /* "path" is the parent of the subtree being eliminated or reduced
- ** from a depth of 2 to 1. If "path" is the node to be removed, we
- ** set path to the node we're about to poke into the position of the
- ** node to be removed. */
- path = parent == rm ? h : parent;
-
- if (h != rm)
- {
- /* Poke in the replacement for the node to be removed. */
- AVL_SET_LESS(h, AVL_GET_LESS(rm, 0))
- AVL_SET_GREATER(h, AVL_GET_GREATER(rm, 0))
- AVL_SET_BALANCE_FACTOR(h, AVL_GET_BALANCE_FACTOR(rm))
-
- if (parent_rm == AVL_NULL)
- l_tree->root = h;
- else
- {
- depth = rm_depth - 1;
-
- if (L_BIT_ARR_VAL(branch, depth))
- AVL_SET_GREATER(parent_rm, h)
- else
- AVL_SET_LESS(parent_rm, h)
- }
+ while (h != path) {
+ if (L_BIT_ARR_VAL(branch, depth)) {
+ child = AVL_GET_GREATER(h, 1);
+ AVL_SET_GREATER(h, parent)
+ } else {
+ child = AVL_GET_LESS(h, 1);
+ AVL_SET_LESS(h, parent)
+ }
+
+ L_CHECK_READ_ERROR(AVL_NULL)
+ depth++;
+ parent = h;
+ h = child;
}
- if (path != AVL_NULL)
- {
- /* Create a temporary linked list from the parent of the path node
- ** to the root node. */
- h = l_tree->root;
- parent = AVL_NULL;
- depth = 0;
-
- while (h != path)
- {
- if (L_BIT_ARR_VAL(branch, depth))
- {
- child = AVL_GET_GREATER(h, 1);
- AVL_SET_GREATER(h, parent)
- }
- else
- {
- child = AVL_GET_LESS(h, 1);
- AVL_SET_LESS(h, parent)
- }
-
- L_CHECK_READ_ERROR(AVL_NULL)
- depth++;
- parent = h;
- h = child;
- }
+ /* Climb from the path node to the root node using the linked
+ ** list, restoring the tree structure and rebalancing as necessary.
+ */
+ reduced_depth = 1;
+ cmp = cmp_shortened_sub_with_path;
- /* Climb from the path node to the root node using the linked
- ** list, restoring the tree structure and rebalancing as necessary.
- */
- reduced_depth = 1;
- cmp = cmp_shortened_sub_with_path;
-
- for (; ;)
- {
- if (reduced_depth)
- {
- bf = AVL_GET_BALANCE_FACTOR(h);
-
- if (cmp < 0)
- bf++;
- else /* cmp > 0 */
- bf--;
-
- if ((bf == -2) || (bf == 2))
- {
- h = L_(balance)(L_BALANCE_PARAM_CALL_PREFIX h);
- L_CHECK_READ_ERROR(AVL_NULL)
- bf = AVL_GET_BALANCE_FACTOR(h);
- }
- else
- AVL_SET_BALANCE_FACTOR(h, bf)
- reduced_depth = (bf == 0);
- }
-
- if (parent == AVL_NULL)
- break;
-
- child = h;
- h = parent;
- depth--;
- cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
-
- if (cmp < 0)
- {
- parent = AVL_GET_LESS(h, 1);
- AVL_SET_LESS(h, child)
- }
- else
- {
- parent = AVL_GET_GREATER(h, 1);
- AVL_SET_GREATER(h, child)
- }
-
- L_CHECK_READ_ERROR(AVL_NULL)
- }
+ for (;;) {
+ if (reduced_depth) {
+ bf = AVL_GET_BALANCE_FACTOR(h);
+
+ if (cmp < 0)
+ bf++;
+ else /* cmp > 0 */
+ bf--;
+
+ if ((bf == -2) || (bf == 2)) {
+ h = L_(balance)(L_BALANCE_PARAM_CALL_PREFIX h);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ bf = AVL_GET_BALANCE_FACTOR(h);
+ } else
+ AVL_SET_BALANCE_FACTOR(h, bf)
+ reduced_depth = (bf == 0);
+ }
+
+ if (parent == AVL_NULL)
+ break;
+
+ child = h;
+ h = parent;
+ depth--;
+ cmp = L_BIT_ARR_VAL(branch, depth) ? 1 : -1;
+
+ if (cmp < 0) {
+ parent = AVL_GET_LESS(h, 1);
+ AVL_SET_LESS(h, child)
+ } else {
+ parent = AVL_GET_GREATER(h, 1);
+ AVL_SET_GREATER(h, child)
+ }
- l_tree->root = h;
+ L_CHECK_READ_ERROR(AVL_NULL)
}
- return(rm);
+ l_tree->root = h;
+ }
+
+ return(rm);
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_SUBST)
-L_SC AVL_HANDLE L_(subst)(L_(avl) *l_tree, AVL_HANDLE new_node)
-{
- AVL_HANDLE h = l_tree->root;
- AVL_HANDLE parent = AVL_NULL;
- int cmp, last_cmp;
-
- /* Search for node already in tree with same key. */
- for (; ;)
- {
- if (h == AVL_NULL)
- /* No node in tree with same key as new node. */
- return(AVL_NULL);
+L_SC AVL_HANDLE L_(subst)(L_(avl) *l_tree, AVL_HANDLE new_node) {
+ AVL_HANDLE h = l_tree->root;
+ AVL_HANDLE parent = AVL_NULL;
+ int cmp, last_cmp;
- cmp = AVL_COMPARE_NODE_NODE(new_node, h);
-
- if (cmp == 0)
- /* Found the node to substitute new one for. */
- break;
+ /* Search for node already in tree with same key. */
+ for (;;) {
+ if (h == AVL_NULL)
+ /* No node in tree with same key as new node. */
+ return(AVL_NULL);
- last_cmp = cmp;
- parent = h;
- h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR(AVL_NULL)
- }
+ cmp = AVL_COMPARE_NODE_NODE(new_node, h);
- /* Copy tree housekeeping fields from node in tree to new node. */
- AVL_SET_LESS(new_node, AVL_GET_LESS(h, 0))
- AVL_SET_GREATER(new_node, AVL_GET_GREATER(h, 0))
- AVL_SET_BALANCE_FACTOR(new_node, AVL_GET_BALANCE_FACTOR(h))
+ if (cmp == 0)
+ /* Found the node to substitute new one for. */
+ break;
- if (parent == AVL_NULL)
- /* New node is also new root. */
- l_tree->root = new_node;
- else
- {
- /* Make parent point to new node. */
- if (last_cmp < 0)
- AVL_SET_LESS(parent, new_node)
- else
- AVL_SET_GREATER(parent, new_node)
- }
-
- return(h);
+ last_cmp = cmp;
+ parent = h;
+ h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR(AVL_NULL)
+ }
+
+ /* Copy tree housekeeping fields from node in tree to new node. */
+ AVL_SET_LESS(new_node, AVL_GET_LESS(h, 0))
+ AVL_SET_GREATER(new_node, AVL_GET_GREATER(h, 0))
+ AVL_SET_BALANCE_FACTOR(new_node, AVL_GET_BALANCE_FACTOR(h))
+
+ if (parent == AVL_NULL)
+ /* New node is also new root. */
+ l_tree->root = new_node;
+ else {
+ /* Make parent point to new node. */
+ if (last_cmp < 0)
+ AVL_SET_LESS(parent, new_node)
+ else
+ AVL_SET_GREATER(parent, new_node)
+ }
+
+ return(h);
}
#endif
@@ -851,144 +765,136 @@ L_SC AVL_HANDLE L_(subst)(L_(avl) *l_tree, AVL_HANDLE new_node)
#if (L_IMPL_MASK & AVL_IMPL_BUILD)
L_SC int L_(build)(
- L_(avl) *l_tree, AVL_BUILD_ITER_TYPE p, L_SIZE num_nodes)
-{
- /* Gives path to subtree being built. If bit n is false, branch
- ** less from the node at depth n, if true branch greater. */
- L_BIT_ARR_DEFN(branch)
-
- /* If bit n is true, then for the current subtree at depth n, its
- ** greater subtree has one more node than its less subtree. */
- L_BIT_ARR_DEFN(rem)
-
- /* Depth of root node of current subtree. */
- unsigned depth = 0;
+ L_(avl) *l_tree, AVL_BUILD_ITER_TYPE p, L_SIZE num_nodes) {
+ /* Gives path to subtree being built. If bit n is false, branch
+ ** less from the node at depth n, if true branch greater. */
+ L_BIT_ARR_DEFN(branch)
+
+ /* If bit n is true, then for the current subtree at depth n, its
+ ** greater subtree has one more node than its less subtree. */
+ L_BIT_ARR_DEFN(rem)
+
+ /* Depth of root node of current subtree. */
+ unsigned depth = 0;
+
+ /* Number of nodes in current subtree. */
+ L_SIZE num_sub = num_nodes;
+
+ /* The algorithm relies on a stack of nodes whose less subtree has
+ ** been built, but whose greater subtree has not yet been built.
+ ** The stack is implemented as linked list. The nodes are linked
+ ** together by having the "greater" handle of a node set to the
+ ** next node in the list. "less_parent" is the handle of the first
+ ** node in the list. */
+ AVL_HANDLE less_parent = AVL_NULL;
+
+ /* h is root of current subtree, child is one of its children. */
+ AVL_HANDLE h;
+ AVL_HANDLE child;
+
+ if (num_nodes == 0) {
+ l_tree->root = AVL_NULL;
+ return(1);
+ }
- /* Number of nodes in current subtree. */
- L_SIZE num_sub = num_nodes;
+ for (;;) {
+ while (num_sub > 2) {
+ /* Subtract one for root of subtree. */
+ num_sub--;
- /* The algorithm relies on a stack of nodes whose less subtree has
- ** been built, but whose greater subtree has not yet been built.
- ** The stack is implemented as linked list. The nodes are linked
- ** together by having the "greater" handle of a node set to the
- ** next node in the list. "less_parent" is the handle of the first
- ** node in the list. */
- AVL_HANDLE less_parent = AVL_NULL;
+ if (num_sub & 1)
+ L_BIT_ARR_1(rem, depth)
+ else
+ L_BIT_ARR_0(rem, depth)
+ L_BIT_ARR_0(branch, depth)
+ depth++;
- /* h is root of current subtree, child is one of its children. */
- AVL_HANDLE h;
- AVL_HANDLE child;
+ num_sub >>= 1;
+ }
- if (num_nodes == 0)
- {
- l_tree->root = AVL_NULL;
- return(1);
+ if (num_sub == 2) {
+ /* Build a subtree with two nodes, slanting to greater.
+ ** I arbitrarily chose to always have the extra node in the
+ ** greater subtree when there is an odd number of nodes to
+ ** split between the two subtrees. */
+
+ h = AVL_BUILD_ITER_VAL(p);
+ L_CHECK_READ_ERROR(0)
+ AVL_BUILD_ITER_INCR(p)
+ child = AVL_BUILD_ITER_VAL(p);
+ L_CHECK_READ_ERROR(0)
+ AVL_BUILD_ITER_INCR(p)
+ AVL_SET_LESS(child, AVL_NULL)
+ AVL_SET_GREATER(child, AVL_NULL)
+ AVL_SET_BALANCE_FACTOR(child, 0)
+ AVL_SET_GREATER(h, child)
+ AVL_SET_LESS(h, AVL_NULL)
+ AVL_SET_BALANCE_FACTOR(h, 1)
+ } else { /* num_sub == 1 */
+ /* Build a subtree with one node. */
+
+ h = AVL_BUILD_ITER_VAL(p);
+ L_CHECK_READ_ERROR(0)
+ AVL_BUILD_ITER_INCR(p)
+ AVL_SET_LESS(h, AVL_NULL)
+ AVL_SET_GREATER(h, AVL_NULL)
+ AVL_SET_BALANCE_FACTOR(h, 0)
}
- for (; ;)
- {
- while (num_sub > 2)
- {
- /* Subtract one for root of subtree. */
- num_sub--;
-
- if (num_sub & 1)
- L_BIT_ARR_1(rem, depth)
- else
- L_BIT_ARR_0(rem, depth)
- L_BIT_ARR_0(branch, depth)
- depth++;
-
- num_sub >>= 1;
+ while (depth) {
+ depth--;
+
+ if (!L_BIT_ARR_VAL(branch, depth))
+ /* We've completed a less subtree. */
+ break;
+
+ /* We've completed a greater subtree, so attach it to
+ ** its parent (that is less than it). We pop the parent
+ ** off the stack of less parents. */
+ child = h;
+ h = less_parent;
+ less_parent = AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR(0)
+ AVL_SET_GREATER(h, child)
+ /* num_sub = 2 * (num_sub - rem[depth]) + rem[depth] + 1 */
+ num_sub <<= 1;
+ num_sub += L_BIT_ARR_VAL(rem, depth) ? 0 : 1;
+
+ if (num_sub & (num_sub - 1))
+ /* num_sub is not a power of 2. */
+ AVL_SET_BALANCE_FACTOR(h, 0)
+ else
+ /* num_sub is a power of 2. */
+ AVL_SET_BALANCE_FACTOR(h, 1)
}
- if (num_sub == 2)
- {
- /* Build a subtree with two nodes, slanting to greater.
- ** I arbitrarily chose to always have the extra node in the
- ** greater subtree when there is an odd number of nodes to
- ** split between the two subtrees. */
-
- h = AVL_BUILD_ITER_VAL(p);
- L_CHECK_READ_ERROR(0)
- AVL_BUILD_ITER_INCR(p)
- child = AVL_BUILD_ITER_VAL(p);
- L_CHECK_READ_ERROR(0)
- AVL_BUILD_ITER_INCR(p)
- AVL_SET_LESS(child, AVL_NULL)
- AVL_SET_GREATER(child, AVL_NULL)
- AVL_SET_BALANCE_FACTOR(child, 0)
- AVL_SET_GREATER(h, child)
- AVL_SET_LESS(h, AVL_NULL)
- AVL_SET_BALANCE_FACTOR(h, 1)
- }
- else /* num_sub == 1 */
- {
- /* Build a subtree with one node. */
-
- h = AVL_BUILD_ITER_VAL(p);
- L_CHECK_READ_ERROR(0)
- AVL_BUILD_ITER_INCR(p)
- AVL_SET_LESS(h, AVL_NULL)
- AVL_SET_GREATER(h, AVL_NULL)
- AVL_SET_BALANCE_FACTOR(h, 0)
- }
+ if (num_sub == num_nodes)
+ /* We've completed the full tree. */
+ break;
- while (depth)
- {
- depth--;
-
- if (!L_BIT_ARR_VAL(branch, depth))
- /* We've completed a less subtree. */
- break;
-
- /* We've completed a greater subtree, so attach it to
- ** its parent (that is less than it). We pop the parent
- ** off the stack of less parents. */
- child = h;
- h = less_parent;
- less_parent = AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR(0)
- AVL_SET_GREATER(h, child)
- /* num_sub = 2 * (num_sub - rem[depth]) + rem[depth] + 1 */
- num_sub <<= 1;
- num_sub += L_BIT_ARR_VAL(rem, depth) ? 0 : 1;
-
- if (num_sub & (num_sub - 1))
- /* num_sub is not a power of 2. */
- AVL_SET_BALANCE_FACTOR(h, 0)
- else
- /* num_sub is a power of 2. */
- AVL_SET_BALANCE_FACTOR(h, 1)
- }
-
- if (num_sub == num_nodes)
- /* We've completed the full tree. */
- break;
-
- /* The subtree we've completed is the less subtree of the
- ** next node in the sequence. */
-
- child = h;
- h = AVL_BUILD_ITER_VAL(p);
- L_CHECK_READ_ERROR(0)
- AVL_BUILD_ITER_INCR(p)
- AVL_SET_LESS(h, child)
+ /* The subtree we've completed is the less subtree of the
+ ** next node in the sequence. */
- /* Put h into stack of less parents. */
- AVL_SET_GREATER(h, less_parent)
- less_parent = h;
+ child = h;
+ h = AVL_BUILD_ITER_VAL(p);
+ L_CHECK_READ_ERROR(0)
+ AVL_BUILD_ITER_INCR(p)
+ AVL_SET_LESS(h, child)
- /* Proceed to creating greater than subtree of h. */
- L_BIT_ARR_1(branch, depth)
- num_sub += L_BIT_ARR_VAL(rem, depth) ? 1 : 0;
- depth++;
+ /* Put h into stack of less parents. */
+ AVL_SET_GREATER(h, less_parent)
+ less_parent = h;
- } /* end for ( ; ; ) */
+ /* Proceed to creating greater than subtree of h. */
+ L_BIT_ARR_1(branch, depth)
+ num_sub += L_BIT_ARR_VAL(rem, depth) ? 1 : 0;
+ depth++;
- l_tree->root = h;
+ } /* end for (;; ) */
- return(1);
+ l_tree->root = h;
+
+ return(1);
}
#endif
@@ -1001,9 +907,8 @@ L_SC int L_(build)(
** invalid. (Depth is zero-base.) It's not necessary to initialize
** iterators prior to passing them to the "start" function.
*/
-L_SC void L_(init_iter)(L_(iter) *iter)
-{
- iter->depth = ~0;
+L_SC void L_(init_iter)(L_(iter) *iter) {
+ iter->depth = ~0;
}
#endif
@@ -1011,7 +916,7 @@ L_SC void L_(init_iter)(L_(iter) *iter)
#ifdef AVL_READ_ERRORS_HAPPEN
#define L_CHECK_READ_ERROR_INV_DEPTH \
- { if (AVL_READ_ERROR) { iter->depth = ~0; return; } }
+ { if (AVL_READ_ERROR) { iter->depth = ~0; return; } }
#else
@@ -1022,174 +927,157 @@ L_SC void L_(init_iter)(L_(iter) *iter)
#if (L_IMPL_MASK & AVL_IMPL_START_ITER)
L_SC void L_(start_iter)(
- L_(avl) *l_tree, L_(iter) *iter, AVL_KEY k, avl_search_type st)
-{
- AVL_HANDLE h = l_tree->root;
- unsigned d = 0;
- int cmp, target_cmp;
-
- /* Save the tree that we're going to iterate through in a
- ** member variable. */
- iter->tree_ = l_tree;
-
- iter->depth = ~0;
+ L_(avl) *l_tree, L_(iter) *iter, AVL_KEY k, avl_search_type st) {
+ AVL_HANDLE h = l_tree->root;
+ unsigned d = 0;
+ int cmp, target_cmp;
+
+ /* Save the tree that we're going to iterate through in a
+ ** member variable. */
+ iter->tree_ = l_tree;
+
+ iter->depth = ~0;
+
+ if (h == AVL_NULL)
+ /* Tree is empty. */
+ return;
+
+ if (st & AVL_LESS)
+ /* Key can be greater than key of starting node. */
+ target_cmp = 1;
+ else if (st & AVL_GREATER)
+ /* Key can be less than key of starting node. */
+ target_cmp = -1;
+ else
+ /* Key must be same as key of starting node. */
+ target_cmp = 0;
+
+ for (;;) {
+ cmp = AVL_COMPARE_KEY_NODE(k, h);
+
+ if (cmp == 0) {
+ if (st & AVL_EQUAL) {
+ /* Equal node was sought and found as starting node. */
+ iter->depth = d;
+ break;
+ }
+
+ cmp = -target_cmp;
+ } else if (target_cmp != 0)
+ if (!((cmp ^ target_cmp) & L_MASK_HIGH_BIT))
+ /* cmp and target_cmp are both negative or both positive. */
+ iter->depth = d;
+
+ h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
if (h == AVL_NULL)
- /* Tree is empty. */
- return;
-
- if (st & AVL_LESS)
- /* Key can be greater than key of starting node. */
- target_cmp = 1;
- else if (st & AVL_GREATER)
- /* Key can be less than key of starting node. */
- target_cmp = -1;
- else
- /* Key must be same as key of starting node. */
- target_cmp = 0;
-
- for (; ;)
- {
- cmp = AVL_COMPARE_KEY_NODE(k, h);
-
- if (cmp == 0)
- {
- if (st & AVL_EQUAL)
- {
- /* Equal node was sought and found as starting node. */
- iter->depth = d;
- break;
- }
-
- cmp = -target_cmp;
- }
- else if (target_cmp != 0)
- if (!((cmp ^ target_cmp) & L_MASK_HIGH_BIT))
- /* cmp and target_cmp are both negative or both positive. */
- iter->depth = d;
-
- h = cmp < 0 ? AVL_GET_LESS(h, 1) : AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR_INV_DEPTH
-
- if (h == AVL_NULL)
- break;
-
- if (cmp > 0)
- L_BIT_ARR_1(iter->branch, d)
- else
- L_BIT_ARR_0(iter->branch, d)
- iter->path_h[d++] = h;
- }
+ break;
+
+ if (cmp > 0)
+ L_BIT_ARR_1(iter->branch, d)
+ else
+ L_BIT_ARR_0(iter->branch, d)
+ iter->path_h[d++] = h;
+ }
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_START_ITER_LEAST)
-L_SC void L_(start_iter_least)(L_(avl) *l_tree, L_(iter) *iter)
-{
- AVL_HANDLE h = l_tree->root;
+L_SC void L_(start_iter_least)(L_(avl) *l_tree, L_(iter) *iter) {
+ AVL_HANDLE h = l_tree->root;
- iter->tree_ = l_tree;
+ iter->tree_ = l_tree;
- iter->depth = ~0;
+ iter->depth = ~0;
- L_BIT_ARR_ALL(iter->branch, 0)
+ L_BIT_ARR_ALL(iter->branch, 0)
- while (h != AVL_NULL)
- {
- if (iter->depth != ~0)
- iter->path_h[iter->depth] = h;
+ while (h != AVL_NULL) {
+ if (iter->depth != ~0)
+ iter->path_h[iter->depth] = h;
- iter->depth++;
- h = AVL_GET_LESS(h, 1);
- L_CHECK_READ_ERROR_INV_DEPTH
- }
+ iter->depth++;
+ h = AVL_GET_LESS(h, 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
+ }
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_START_ITER_GREATEST)
-L_SC void L_(start_iter_greatest)(L_(avl) *l_tree, L_(iter) *iter)
-{
- AVL_HANDLE h = l_tree->root;
+L_SC void L_(start_iter_greatest)(L_(avl) *l_tree, L_(iter) *iter) {
+ AVL_HANDLE h = l_tree->root;
- iter->tree_ = l_tree;
+ iter->tree_ = l_tree;
- iter->depth = ~0;
+ iter->depth = ~0;
- L_BIT_ARR_ALL(iter->branch, 1)
+ L_BIT_ARR_ALL(iter->branch, 1)
- while (h != AVL_NULL)
- {
- if (iter->depth != ~0)
- iter->path_h[iter->depth] = h;
+ while (h != AVL_NULL) {
+ if (iter->depth != ~0)
+ iter->path_h[iter->depth] = h;
- iter->depth++;
- h = AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR_INV_DEPTH
- }
+ iter->depth++;
+ h = AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
+ }
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_GET_ITER)
-L_SC AVL_HANDLE L_(get_iter)(L_(iter) *iter)
-{
- if (iter->depth == ~0)
- return(AVL_NULL);
+L_SC AVL_HANDLE L_(get_iter)(L_(iter) *iter) {
+ if (iter->depth == ~0)
+ return(AVL_NULL);
- return(iter->depth == 0 ?
- iter->tree_->root : iter->path_h[iter->depth - 1]);
+ return(iter->depth == 0 ?
+ iter->tree_->root : iter->path_h[iter->depth - 1]);
}
#endif
#if (L_IMPL_MASK & AVL_IMPL_INCR_ITER)
-L_SC void L_(incr_iter)(L_(iter) *iter)
-{
+L_SC void L_(incr_iter)(L_(iter) *iter) {
#define l_tree (iter->tree_)
- if (iter->depth != ~0)
- {
- AVL_HANDLE h =
- AVL_GET_GREATER((iter->depth == 0 ?
- iter->tree_->root : iter->path_h[iter->depth - 1]), 1);
- L_CHECK_READ_ERROR_INV_DEPTH
+ if (iter->depth != ~0) {
+ AVL_HANDLE h =
+ AVL_GET_GREATER((iter->depth == 0 ?
+ iter->tree_->root : iter->path_h[iter->depth - 1]), 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
- if (h == AVL_NULL)
- do
- {
- if (iter->depth == 0)
- {
- iter->depth = ~0;
- break;
- }
-
- iter->depth--;
- }
- while (L_BIT_ARR_VAL(iter->branch, iter->depth));
- else
- {
- L_BIT_ARR_1(iter->branch, iter->depth)
- iter->path_h[iter->depth++] = h;
+ if (h == AVL_NULL)
+ do {
+ if (iter->depth == 0) {
+ iter->depth = ~0;
+ break;
+ }
- for (; ;)
- {
- h = AVL_GET_LESS(h, 1);
- L_CHECK_READ_ERROR_INV_DEPTH
+ iter->depth--;
+ } while (L_BIT_ARR_VAL(iter->branch, iter->depth));
+ else {
+ L_BIT_ARR_1(iter->branch, iter->depth)
+ iter->path_h[iter->depth++] = h;
- if (h == AVL_NULL)
- break;
+ for (;;) {
+ h = AVL_GET_LESS(h, 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
- L_BIT_ARR_0(iter->branch, iter->depth)
- iter->path_h[iter->depth++] = h;
- }
- }
+ if (h == AVL_NULL)
+ break;
+
+ L_BIT_ARR_0(iter->branch, iter->depth)
+ iter->path_h[iter->depth++] = h;
+ }
}
+ }
#undef l_tree
}
@@ -1198,47 +1086,40 @@ L_SC void L_(incr_iter)(L_(iter) *iter)
#if (L_IMPL_MASK & AVL_IMPL_DECR_ITER)
-L_SC void L_(decr_iter)(L_(iter) *iter)
-{
+L_SC void L_(decr_iter)(L_(iter) *iter) {
#define l_tree (iter->tree_)
- if (iter->depth != ~0)
- {
- AVL_HANDLE h =
- AVL_GET_LESS((iter->depth == 0 ?
- iter->tree_->root : iter->path_h[iter->depth - 1]), 1);
- L_CHECK_READ_ERROR_INV_DEPTH
+ if (iter->depth != ~0) {
+ AVL_HANDLE h =
+ AVL_GET_LESS((iter->depth == 0 ?
+ iter->tree_->root : iter->path_h[iter->depth - 1]), 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
- if (h == AVL_NULL)
- do
- {
- if (iter->depth == 0)
- {
- iter->depth = ~0;
- break;
- }
-
- iter->depth--;
- }
- while (!L_BIT_ARR_VAL(iter->branch, iter->depth));
- else
- {
- L_BIT_ARR_0(iter->branch, iter->depth)
- iter->path_h[iter->depth++] = h;
+ if (h == AVL_NULL)
+ do {
+ if (iter->depth == 0) {
+ iter->depth = ~0;
+ break;
+ }
- for (; ;)
- {
- h = AVL_GET_GREATER(h, 1);
- L_CHECK_READ_ERROR_INV_DEPTH
+ iter->depth--;
+ } while (!L_BIT_ARR_VAL(iter->branch, iter->depth));
+ else {
+ L_BIT_ARR_0(iter->branch, iter->depth)
+ iter->path_h[iter->depth++] = h;
- if (h == AVL_NULL)
- break;
+ for (;;) {
+ h = AVL_GET_GREATER(h, 1);
+ L_CHECK_READ_ERROR_INV_DEPTH
- L_BIT_ARR_1(iter->branch, iter->depth)
- iter->path_h[iter->depth++] = h;
- }
- }
+ if (h == AVL_NULL)
+ break;
+
+ L_BIT_ARR_1(iter->branch, iter->depth)
+ iter->path_h[iter->depth++] = h;
+ }
}
+ }
#undef l_tree
}
diff --git a/vpx_mem/memory_manager/include/heapmm.h b/vpx_mem/memory_manager/include/heapmm.h
index 33004cadc..4934c2d8a 100644
--- a/vpx_mem/memory_manager/include/heapmm.h
+++ b/vpx_mem/memory_manager/include/heapmm.h
@@ -81,30 +81,29 @@
#include "hmm_cnfg.h"
/* Heap descriptor. */
-typedef struct HMM_UNIQUE(structure)
-{
- /* private: */
-
- /* Pointer to (payload of) root node in AVL tree. This field should
- ** really be the AVL tree descriptor (type avl_avl). But (in the
- ** instantiation of the AVL tree generic package used in package) the
- ** AVL tree descriptor simply contains a pointer to the root. So,
- ** whenever a pointer to the AVL tree descriptor is needed, I use the
- ** cast:
- **
- ** (avl_avl *) &(heap_desc->avl_tree_root)
- **
- ** (where heap_desc is a pointer to a heap descriptor). This trick
- ** allows me to avoid including cavl_if.h in this external header. */
- void *avl_tree_root;
-
- /* Pointer to first byte of last block freed, after any coalescing. */
- void *last_freed;
-
- /* public: */
-
- HMM_UNIQUE(size_bau) num_baus_can_shrink;
- void *end_of_shrinkable_chunk;
+typedef struct HMM_UNIQUE(structure) {
+ /* private: */
+
+ /* Pointer to (payload of) root node in AVL tree. This field should
+ ** really be the AVL tree descriptor (type avl_avl). But (in the
+ ** instantiation of the AVL tree generic package used in package) the
+ ** AVL tree descriptor simply contains a pointer to the root. So,
+ ** whenever a pointer to the AVL tree descriptor is needed, I use the
+ ** cast:
+ **
+ ** (avl_avl *) &(heap_desc->avl_tree_root)
+ **
+ ** (where heap_desc is a pointer to a heap descriptor). This trick
+ ** allows me to avoid including cavl_if.h in this external header. */
+ void *avl_tree_root;
+
+ /* Pointer to first byte of last block freed, after any coalescing. */
+ void *last_freed;
+
+ /* public: */
+
+ HMM_UNIQUE(size_bau) num_baus_can_shrink;
+ void *end_of_shrinkable_chunk;
}
HMM_UNIQUE(descriptor);
@@ -113,41 +112,41 @@ HMM_UNIQUE(descriptor);
void HMM_UNIQUE(init)(HMM_UNIQUE(descriptor) *desc);
void *HMM_UNIQUE(alloc)(
- HMM_UNIQUE(descriptor) *desc, HMM_UNIQUE(size_aau) num_addr_align_units);
+ HMM_UNIQUE(descriptor) *desc, HMM_UNIQUE(size_aau) num_addr_align_units);
/* NOT YET IMPLEMENTED */
void *HMM_UNIQUE(greedy_alloc)(
- HMM_UNIQUE(descriptor) *desc, HMM_UNIQUE(size_aau) needed_addr_align_units,
- HMM_UNIQUE(size_aau) coveted_addr_align_units);
+ HMM_UNIQUE(descriptor) *desc, HMM_UNIQUE(size_aau) needed_addr_align_units,
+ HMM_UNIQUE(size_aau) coveted_addr_align_units);
int HMM_UNIQUE(resize)(
- HMM_UNIQUE(descriptor) *desc, void *mem,
- HMM_UNIQUE(size_aau) num_addr_align_units);
+ HMM_UNIQUE(descriptor) *desc, void *mem,
+ HMM_UNIQUE(size_aau) num_addr_align_units);
/* NOT YET IMPLEMENTED */
int HMM_UNIQUE(greedy_resize)(
- HMM_UNIQUE(descriptor) *desc, void *mem,
- HMM_UNIQUE(size_aau) needed_addr_align_units,
- HMM_UNIQUE(size_aau) coveted_addr_align_units);
+ HMM_UNIQUE(descriptor) *desc, void *mem,
+ HMM_UNIQUE(size_aau) needed_addr_align_units,
+ HMM_UNIQUE(size_aau) coveted_addr_align_units);
void HMM_UNIQUE(free)(HMM_UNIQUE(descriptor) *desc, void *mem);
HMM_UNIQUE(size_aau) HMM_UNIQUE(true_size)(void *mem);
HMM_UNIQUE(size_aau) HMM_UNIQUE(largest_available)(
- HMM_UNIQUE(descriptor) *desc);
+ HMM_UNIQUE(descriptor) *desc);
void HMM_UNIQUE(new_chunk)(
- HMM_UNIQUE(descriptor) *desc, void *start_of_chunk,
- HMM_UNIQUE(size_bau) num_block_align_units);
+ HMM_UNIQUE(descriptor) *desc, void *start_of_chunk,
+ HMM_UNIQUE(size_bau) num_block_align_units);
void HMM_UNIQUE(grow_chunk)(
- HMM_UNIQUE(descriptor) *desc, void *end_of_chunk,
- HMM_UNIQUE(size_bau) num_block_align_units);
+ HMM_UNIQUE(descriptor) *desc, void *end_of_chunk,
+ HMM_UNIQUE(size_bau) num_block_align_units);
/* NOT YET IMPLEMENTED */
void HMM_UNIQUE(shrink_chunk)(
- HMM_UNIQUE(descriptor) *desc,
- HMM_UNIQUE(size_bau) num_block_align_units);
+ HMM_UNIQUE(descriptor) *desc,
+ HMM_UNIQUE(size_bau) num_block_align_units);
#endif /* defined HMM_PROCESS */
diff --git a/vpx_mem/memory_manager/include/hmm_cnfg.h b/vpx_mem/memory_manager/include/hmm_cnfg.h
index 30b9f5045..2c3391d7b 100644
--- a/vpx_mem/memory_manager/include/hmm_cnfg.h
+++ b/vpx_mem/memory_manager/include/hmm_cnfg.h
@@ -45,8 +45,8 @@
#define HMM_UNIQUE(BASE) hmm_ ## BASE
/* Number of bytes in an Address Alignment Unit (AAU). */
-//fwg
-//#define HMM_ADDR_ALIGN_UNIT sizeof(int)
+// fwg
+// #define HMM_ADDR_ALIGN_UNIT sizeof(int)
#define HMM_ADDR_ALIGN_UNIT 32
/* Number of AAUs in a Block Alignment Unit (BAU). */
@@ -65,7 +65,7 @@ void hmm_dflt_abort(const char *, const char *);
** statement. If you remove the definition of this macro, no self-auditing
** will be performed. */
#define HMM_AUDIT_FAIL \
- hmm_dflt_abort(__FILE__, HMM_SYM_TO_STRING(__LINE__));
+ hmm_dflt_abort(__FILE__, HMM_SYM_TO_STRING(__LINE__));
#elif HMM_CNFG_NUM == 0
@@ -90,8 +90,8 @@ extern const char *HMM_UNIQUE(fail_file);
extern unsigned HMM_UNIQUE(fail_line);
#define HMM_AUDIT_FAIL \
- { HMM_UNIQUE(fail_file) = __FILE__; HMM_UNIQUE(fail_line) = __LINE__; \
- longjmp(HMM_UNIQUE(jmp_buf), 1); }
+ { HMM_UNIQUE(fail_file) = __FILE__; HMM_UNIQUE(fail_line) = __LINE__; \
+ longjmp(HMM_UNIQUE(jmp_buf), 1); }
#elif HMM_CNFG_NUM == 1
diff --git a/vpx_mem/memory_manager/include/hmm_intrnl.h b/vpx_mem/memory_manager/include/hmm_intrnl.h
index 5d62abc59..27cefe449 100644
--- a/vpx_mem/memory_manager/include/hmm_intrnl.h
+++ b/vpx_mem/memory_manager/include/hmm_intrnl.h
@@ -26,34 +26,32 @@
/* Mask of high bit of variable of size_bau type. */
#define HIGH_BIT_BAU_SIZE \
- ((U(size_bau)) ~ (((U(size_bau)) ~ (U(size_bau)) 0) >> 1))
+ ((U(size_bau)) ~ (((U(size_bau)) ~ (U(size_bau)) 0) >> 1))
/* Add a given number of AAUs to pointer. */
#define AAUS_FORWARD(PTR, AAU_OFFSET) \
- (((char *) (PTR)) + ((AAU_OFFSET) * ((U(size_aau)) HMM_ADDR_ALIGN_UNIT)))
+ (((char *) (PTR)) + ((AAU_OFFSET) * ((U(size_aau)) HMM_ADDR_ALIGN_UNIT)))
/* Subtract a given number of AAUs from pointer. */
#define AAUS_BACKWARD(PTR, AAU_OFFSET) \
- (((char *) (PTR)) - ((AAU_OFFSET) * ((U(size_aau)) HMM_ADDR_ALIGN_UNIT)))
+ (((char *) (PTR)) - ((AAU_OFFSET) * ((U(size_aau)) HMM_ADDR_ALIGN_UNIT)))
/* Add a given number of BAUs to a pointer. */
#define BAUS_FORWARD(PTR, BAU_OFFSET) \
- AAUS_FORWARD((PTR), (BAU_OFFSET) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT))
+ AAUS_FORWARD((PTR), (BAU_OFFSET) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT))
/* Subtract a given number of BAUs to a pointer. */
#define BAUS_BACKWARD(PTR, BAU_OFFSET) \
- AAUS_BACKWARD((PTR), (BAU_OFFSET) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT))
+ AAUS_BACKWARD((PTR), (BAU_OFFSET) * ((U(size_aau)) HMM_BLOCK_ALIGN_UNIT))
-typedef struct head_struct
-{
- /* Sizes in Block Alignment Units. */
- HMM_UNIQUE(size_bau) previous_block_size, block_size;
+typedef struct head_struct {
+ /* Sizes in Block Alignment Units. */
+ HMM_UNIQUE(size_bau) previous_block_size, block_size;
}
head_record;
-typedef struct ptr_struct
-{
- struct ptr_struct *self, *prev, *next;
+typedef struct ptr_struct {
+ struct ptr_struct *self, *prev, *next;
}
ptr_record;
@@ -71,50 +69,50 @@ ptr_record;
/* Minimum number of BAUs in a block (allowing room for the pointer record. */
#define MIN_BLOCK_BAUS \
- DIV_ROUND_UP(HEAD_AAUS + PTR_RECORD_AAUS, HMM_BLOCK_ALIGN_UNIT)
+ DIV_ROUND_UP(HEAD_AAUS + PTR_RECORD_AAUS, HMM_BLOCK_ALIGN_UNIT)
/* Return number of BAUs in block (masking off high bit containing block
** status). */
#define BLOCK_BAUS(HEAD_PTR) \
- (((head_record *) (HEAD_PTR))->block_size & ~HIGH_BIT_BAU_SIZE)
+ (((head_record *) (HEAD_PTR))->block_size & ~HIGH_BIT_BAU_SIZE)
/* Return number of BAUs in previous block (masking off high bit containing
** block status). */
#define PREV_BLOCK_BAUS(HEAD_PTR) \
- (((head_record *) (HEAD_PTR))->previous_block_size & ~HIGH_BIT_BAU_SIZE)
+ (((head_record *) (HEAD_PTR))->previous_block_size & ~HIGH_BIT_BAU_SIZE)
/* Set number of BAUs in previous block, preserving high bit containing
** block status. */
#define SET_PREV_BLOCK_BAUS(HEAD_PTR, N_BAUS) \
- { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
- h_ptr->previous_block_size &= HIGH_BIT_BAU_SIZE; \
- h_ptr->previous_block_size |= (N_BAUS); }
+ { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
+ h_ptr->previous_block_size &= HIGH_BIT_BAU_SIZE; \
+ h_ptr->previous_block_size |= (N_BAUS); }
/* Convert pointer to pointer record of block to pointer to block's head
** record. */
#define PTR_REC_TO_HEAD(PTR_REC_PTR) \
- ((head_record *) AAUS_BACKWARD(PTR_REC_PTR, HEAD_AAUS))
+ ((head_record *) AAUS_BACKWARD(PTR_REC_PTR, HEAD_AAUS))
/* Convert pointer to block head to pointer to block's pointer record. */
#define HEAD_TO_PTR_REC(HEAD_PTR) \
- ((ptr_record *) AAUS_FORWARD(HEAD_PTR, HEAD_AAUS))
+ ((ptr_record *) AAUS_FORWARD(HEAD_PTR, HEAD_AAUS))
/* Returns non-zero if block is allocated. */
#define IS_BLOCK_ALLOCATED(HEAD_PTR) \
- (((((head_record *) (HEAD_PTR))->block_size | \
- ((head_record *) (HEAD_PTR))->previous_block_size) & \
- HIGH_BIT_BAU_SIZE) == 0)
+ (((((head_record *) (HEAD_PTR))->block_size | \
+ ((head_record *) (HEAD_PTR))->previous_block_size) & \
+ HIGH_BIT_BAU_SIZE) == 0)
#define MARK_BLOCK_ALLOCATED(HEAD_PTR) \
- { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
- h_ptr->block_size &= ~HIGH_BIT_BAU_SIZE; \
- h_ptr->previous_block_size &= ~HIGH_BIT_BAU_SIZE; }
+ { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
+ h_ptr->block_size &= ~HIGH_BIT_BAU_SIZE; \
+ h_ptr->previous_block_size &= ~HIGH_BIT_BAU_SIZE; }
/* Mark a block as free when it is not the first block in a bin (and
** therefore not a node in the AVL tree). */
#define MARK_SUCCESSIVE_BLOCK_IN_FREE_BIN(HEAD_PTR) \
- { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
- h_ptr->block_size |= HIGH_BIT_BAU_SIZE; }
+ { register head_record *h_ptr = (head_record *) (HEAD_PTR); \
+ h_ptr->block_size |= HIGH_BIT_BAU_SIZE; }
/* Prototypes for internal functions implemented in one file and called in
** another.
@@ -125,7 +123,7 @@ void U(into_free_collection)(U(descriptor) *desc, head_record *head_ptr);
void U(out_of_free_collection)(U(descriptor) *desc, head_record *head_ptr);
void *U(alloc_from_bin)(
- U(descriptor) *desc, ptr_record *bin_front_ptr, U(size_bau) n_baus);
+ U(descriptor) *desc, ptr_record *bin_front_ptr, U(size_bau) n_baus);
#ifdef HMM_AUDIT_FAIL
@@ -137,12 +135,12 @@ int U(audit_block_fail_dummy_return)(void);
/* Auditing a block consists of checking that the size in its head
** matches the previous block size in the head of the next block. */
#define AUDIT_BLOCK_AS_EXPR(HEAD_PTR) \
- ((BLOCK_BAUS(HEAD_PTR) == \
- PREV_BLOCK_BAUS(BAUS_FORWARD(HEAD_PTR, BLOCK_BAUS(HEAD_PTR)))) ? \
- 0 : U(audit_block_fail_dummy_return)())
+ ((BLOCK_BAUS(HEAD_PTR) == \
+ PREV_BLOCK_BAUS(BAUS_FORWARD(HEAD_PTR, BLOCK_BAUS(HEAD_PTR)))) ? \
+ 0 : U(audit_block_fail_dummy_return)())
#define AUDIT_BLOCK(HEAD_PTR) \
- { void *h_ptr = (HEAD_PTR); AUDIT_BLOCK_AS_EXPR(h_ptr); }
+ { void *h_ptr = (HEAD_PTR); AUDIT_BLOCK_AS_EXPR(h_ptr); }
#endif
diff --git a/vpx_mem/vpx_mem.c b/vpx_mem/vpx_mem.c
index eade43222..059248bab 100644
--- a/vpx_mem/vpx_mem.c
+++ b/vpx_mem/vpx_mem.c
@@ -51,15 +51,14 @@ static void *vpx_mm_realloc(void *memblk, size_t size);
#endif /*CONFIG_MEM_MANAGER*/
#if USE_GLOBAL_FUNCTION_POINTERS
-struct GLOBAL_FUNC_POINTERS
-{
- g_malloc_func g_malloc;
- g_calloc_func g_calloc;
- g_realloc_func g_realloc;
- g_free_func g_free;
- g_memcpy_func g_memcpy;
- g_memset_func g_memset;
- g_memmove_func g_memmove;
+struct GLOBAL_FUNC_POINTERS {
+ g_malloc_func g_malloc;
+ g_calloc_func g_calloc;
+ g_realloc_func g_realloc;
+ g_free_func g_free;
+ g_memcpy_func g_memcpy;
+ g_memset_func g_memset;
+ g_memmove_func g_memmove;
} *g_func = NULL;
# define VPX_MALLOC_L g_func->g_malloc
@@ -77,346 +76,314 @@ struct GLOBAL_FUNC_POINTERS
# define VPX_MEMMOVE_L memmove
#endif /* USE_GLOBAL_FUNCTION_POINTERS */
-unsigned int vpx_mem_get_version()
-{
- unsigned int ver = ((unsigned int)(unsigned char)VPX_MEM_VERSION_CHIEF << 24 |
- (unsigned int)(unsigned char)VPX_MEM_VERSION_MAJOR << 16 |
- (unsigned int)(unsigned char)VPX_MEM_VERSION_MINOR << 8 |
- (unsigned int)(unsigned char)VPX_MEM_VERSION_PATCH);
- return ver;
+unsigned int vpx_mem_get_version() {
+ unsigned int ver = ((unsigned int)(unsigned char)VPX_MEM_VERSION_CHIEF << 24 |
+ (unsigned int)(unsigned char)VPX_MEM_VERSION_MAJOR << 16 |
+ (unsigned int)(unsigned char)VPX_MEM_VERSION_MINOR << 8 |
+ (unsigned int)(unsigned char)VPX_MEM_VERSION_PATCH);
+ return ver;
}
-int vpx_mem_set_heap_size(size_t size)
-{
- int ret = -1;
+int vpx_mem_set_heap_size(size_t size) {
+ int ret = -1;
#if CONFIG_MEM_MANAGER
#if MM_DYNAMIC_MEMORY
- if (!g_mng_memory_allocated && size)
- {
- g_mm_memory_size = size;
- ret = 0;
- }
- else
- ret = -3;
+ if (!g_mng_memory_allocated && size) {
+ g_mm_memory_size = size;
+ ret = 0;
+ } else
+ ret = -3;
#else
- ret = -2;
+ ret = -2;
#endif
#else
- (void)size;
+ (void)size;
#endif
- return ret;
+ return ret;
}
-void *vpx_memalign(size_t align, size_t size)
-{
- void *addr,
- * x = NULL;
+void *vpx_memalign(size_t align, size_t size) {
+ void *addr,
+ * x = NULL;
#if CONFIG_MEM_MANAGER
- int number_aau;
+ int number_aau;
- if (vpx_mm_create_heap_memory() < 0)
- {
- _P(printf("[vpx][mm] ERROR vpx_memalign() Couldn't create memory for Heap.\n");)
- }
+ if (vpx_mm_create_heap_memory() < 0) {
+ _P(printf("[vpx][mm] ERROR vpx_memalign() Couldn't create memory for Heap.\n");)
+ }
- number_aau = ((size + align - 1 + ADDRESS_STORAGE_SIZE) >>
- SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
+ number_aau = ((size + align - 1 + ADDRESS_STORAGE_SIZE) >>
+ SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
- addr = hmm_alloc(&hmm_d, number_aau);
+ addr = hmm_alloc(&hmm_d, number_aau);
#else
- addr = VPX_MALLOC_L(size + align - 1 + ADDRESS_STORAGE_SIZE);
+ addr = VPX_MALLOC_L(size + align - 1 + ADDRESS_STORAGE_SIZE);
#endif /*CONFIG_MEM_MANAGER*/
- if (addr)
- {
- x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
- /* save the actual malloc address */
- ((size_t *)x)[-1] = (size_t)addr;
- }
+ if (addr) {
+ x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
+ /* save the actual malloc address */
+ ((size_t *)x)[-1] = (size_t)addr;
+ }
- return x;
+ return x;
}
-void *vpx_malloc(size_t size)
-{
- return vpx_memalign(DEFAULT_ALIGNMENT, size);
+void *vpx_malloc(size_t size) {
+ return vpx_memalign(DEFAULT_ALIGNMENT, size);
}
-void *vpx_calloc(size_t num, size_t size)
-{
- void *x;
+void *vpx_calloc(size_t num, size_t size) {
+ void *x;
- x = vpx_memalign(DEFAULT_ALIGNMENT, num * size);
+ x = vpx_memalign(DEFAULT_ALIGNMENT, num * size);
- if (x)
- VPX_MEMSET_L(x, 0, num * size);
+ if (x)
+ VPX_MEMSET_L(x, 0, num * size);
- return x;
+ return x;
}
-void *vpx_realloc(void *memblk, size_t size)
-{
- void *addr,
- * new_addr = NULL;
- int align = DEFAULT_ALIGNMENT;
-
- /*
- The realloc() function changes the size of the object pointed to by
- ptr to the size specified by size, and returns a pointer to the
- possibly moved block. The contents are unchanged up to the lesser
- of the new and old sizes. If ptr is null, realloc() behaves like
- malloc() for the specified size. If size is zero (0) and ptr is
- not a null pointer, the object pointed to is freed.
- */
- if (!memblk)
- new_addr = vpx_malloc(size);
- else if (!size)
- vpx_free(memblk);
- else
- {
- addr = (void *)(((size_t *)memblk)[-1]);
- memblk = NULL;
+void *vpx_realloc(void *memblk, size_t size) {
+ void *addr,
+ * new_addr = NULL;
+ int align = DEFAULT_ALIGNMENT;
+
+ /*
+ The realloc() function changes the size of the object pointed to by
+ ptr to the size specified by size, and returns a pointer to the
+ possibly moved block. The contents are unchanged up to the lesser
+ of the new and old sizes. If ptr is null, realloc() behaves like
+ malloc() for the specified size. If size is zero (0) and ptr is
+ not a null pointer, the object pointed to is freed.
+ */
+ if (!memblk)
+ new_addr = vpx_malloc(size);
+ else if (!size)
+ vpx_free(memblk);
+ else {
+ addr = (void *)(((size_t *)memblk)[-1]);
+ memblk = NULL;
#if CONFIG_MEM_MANAGER
- new_addr = vpx_mm_realloc(addr, size + align + ADDRESS_STORAGE_SIZE);
+ new_addr = vpx_mm_realloc(addr, size + align + ADDRESS_STORAGE_SIZE);
#else
- new_addr = VPX_REALLOC_L(addr, size + align + ADDRESS_STORAGE_SIZE);
+ new_addr = VPX_REALLOC_L(addr, size + align + ADDRESS_STORAGE_SIZE);
#endif
- if (new_addr)
- {
- addr = new_addr;
- new_addr = (void *)(((size_t)
- ((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) &
- (size_t) - align);
- /* save the actual malloc address */
- ((size_t *)new_addr)[-1] = (size_t)addr;
- }
+ if (new_addr) {
+ addr = new_addr;
+ new_addr = (void *)(((size_t)
+ ((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) &
+ (size_t) - align);
+ /* save the actual malloc address */
+ ((size_t *)new_addr)[-1] = (size_t)addr;
}
+ }
- return new_addr;
+ return new_addr;
}
-void vpx_free(void *memblk)
-{
- if (memblk)
- {
- void *addr = (void *)(((size_t *)memblk)[-1]);
+void vpx_free(void *memblk) {
+ if (memblk) {
+ void *addr = (void *)(((size_t *)memblk)[-1]);
#if CONFIG_MEM_MANAGER
- hmm_free(&hmm_d, addr);
+ hmm_free(&hmm_d, addr);
#else
- VPX_FREE_L(addr);
+ VPX_FREE_L(addr);
#endif
- }
+ }
}
#if CONFIG_MEM_TRACKER
-void *xvpx_memalign(size_t align, size_t size, char *file, int line)
-{
+void *xvpx_memalign(size_t align, size_t size, char *file, int line) {
#if TRY_BOUNDS_CHECK
- unsigned char *x_bounds;
+ unsigned char *x_bounds;
#endif
- void *x;
+ void *x;
- if (g_alloc_count == 0)
- {
+ if (g_alloc_count == 0) {
#if TRY_BOUNDS_CHECK
- int i_rv = vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE);
+ int i_rv = vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE);
#else
- int i_rv = vpx_memory_tracker_init(0, 0);
+ int i_rv = vpx_memory_tracker_init(0, 0);
#endif
- if (i_rv < 0)
- {
- _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
- }
+ if (i_rv < 0) {
+ _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
}
+ }
#if TRY_BOUNDS_CHECK
- {
- int i;
- unsigned int tempme = BOUNDS_CHECK_VALUE;
-
- x_bounds = vpx_memalign(align, size + (BOUNDS_CHECK_PAD_SIZE * 2));
-
- if (x_bounds)
- {
- /*we're aligning the address twice here but to keep things
- consistent we want to have the padding come before the stored
- address so no matter what free function gets called we will
- attempt to free the correct address*/
- x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
- x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
- (int)align);
- /* save the actual malloc address */
- ((size_t *)x)[-1] = (size_t)x_bounds;
-
- for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int))
- {
- VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
- VPX_MEMCPY_L((unsigned char *)x + size + i,
- &tempme, sizeof(unsigned int));
- }
- }
- else
- x = NULL;
- }
+ {
+ int i;
+ unsigned int tempme = BOUNDS_CHECK_VALUE;
+
+ x_bounds = vpx_memalign(align, size + (BOUNDS_CHECK_PAD_SIZE * 2));
+
+ if (x_bounds) {
+ /*we're aligning the address twice here but to keep things
+ consistent we want to have the padding come before the stored
+ address so no matter what free function gets called we will
+ attempt to free the correct address*/
+ x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
+ x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
+ (int)align);
+ /* save the actual malloc address */
+ ((size_t *)x)[-1] = (size_t)x_bounds;
+
+ for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int)) {
+ VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
+ VPX_MEMCPY_L((unsigned char *)x + size + i,
+ &tempme, sizeof(unsigned int));
+ }
+ } else
+ x = NULL;
+ }
#else
- x = vpx_memalign(align, size);
+ x = vpx_memalign(align, size);
#endif /*TRY_BOUNDS_CHECK*/
- g_alloc_count++;
+ g_alloc_count++;
- vpx_memory_tracker_add((size_t)x, (unsigned int)size, file, line, 1);
+ vpx_memory_tracker_add((size_t)x, (unsigned int)size, file, line, 1);
- return x;
+ return x;
}
-void *xvpx_malloc(size_t size, char *file, int line)
-{
- return xvpx_memalign(DEFAULT_ALIGNMENT, size, file, line);
+void *xvpx_malloc(size_t size, char *file, int line) {
+ return xvpx_memalign(DEFAULT_ALIGNMENT, size, file, line);
}
-void *xvpx_calloc(size_t num, size_t size, char *file, int line)
-{
- void *x = xvpx_memalign(DEFAULT_ALIGNMENT, num * size, file, line);
+void *xvpx_calloc(size_t num, size_t size, char *file, int line) {
+ void *x = xvpx_memalign(DEFAULT_ALIGNMENT, num * size, file, line);
- if (x)
- VPX_MEMSET_L(x, 0, num * size);
+ if (x)
+ VPX_MEMSET_L(x, 0, num * size);
- return x;
+ return x;
}
-void *xvpx_realloc(void *memblk, size_t size, char *file, int line)
-{
- struct mem_block *p = NULL;
- int orig_size = 0,
- orig_line = 0;
- char *orig_file = NULL;
+void *xvpx_realloc(void *memblk, size_t size, char *file, int line) {
+ struct mem_block *p = NULL;
+ int orig_size = 0,
+ orig_line = 0;
+ char *orig_file = NULL;
#if TRY_BOUNDS_CHECK
- unsigned char *x_bounds = memblk ?
- (unsigned char *)(((size_t *)memblk)[-1]) :
- NULL;
+ unsigned char *x_bounds = memblk ?
+ (unsigned char *)(((size_t *)memblk)[-1]) :
+ NULL;
#endif
- void *x;
+ void *x;
- if (g_alloc_count == 0)
- {
+ if (g_alloc_count == 0) {
#if TRY_BOUNDS_CHECK
- if (!vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE))
+ if (!vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE))
#else
- if (!vpx_memory_tracker_init(0, 0))
+ if (!vpx_memory_tracker_init(0, 0))
#endif
- {
- _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
- }
- }
-
- if ((p = vpx_memory_tracker_find((size_t)memblk)))
{
- orig_size = p->size;
- orig_file = p->file;
- orig_line = p->line;
+ _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
}
+ }
+
+ if ((p = vpx_memory_tracker_find((size_t)memblk))) {
+ orig_size = p->size;
+ orig_file = p->file;
+ orig_line = p->line;
+ }
#if TRY_BOUNDS_CHECK_ON_FREE
- vpx_memory_tracker_check_integrity(file, line);
+ vpx_memory_tracker_check_integrity(file, line);
#endif
- /* have to do this regardless of success, because
- * the memory that does get realloc'd may change
- * the bounds values of this block
- */
- vpx_memory_tracker_remove((size_t)memblk);
+ /* have to do this regardless of success, because
+ * the memory that does get realloc'd may change
+ * the bounds values of this block
+ */
+ vpx_memory_tracker_remove((size_t)memblk);
#if TRY_BOUNDS_CHECK
- {
- int i;
- unsigned int tempme = BOUNDS_CHECK_VALUE;
-
- x_bounds = vpx_realloc(memblk, size + (BOUNDS_CHECK_PAD_SIZE * 2));
-
- if (x_bounds)
- {
- x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
- x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
- (int)DEFAULT_ALIGNMENT);
- /* save the actual malloc address */
- ((size_t *)x)[-1] = (size_t)x_bounds;
-
- for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int))
- {
- VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
- VPX_MEMCPY_L((unsigned char *)x + size + i,
- &tempme, sizeof(unsigned int));
- }
- }
- else
- x = NULL;
- }
+ {
+ int i;
+ unsigned int tempme = BOUNDS_CHECK_VALUE;
+
+ x_bounds = vpx_realloc(memblk, size + (BOUNDS_CHECK_PAD_SIZE * 2));
+
+ if (x_bounds) {
+ x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
+ x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
+ (int)DEFAULT_ALIGNMENT);
+ /* save the actual malloc address */
+ ((size_t *)x)[-1] = (size_t)x_bounds;
+
+ for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int)) {
+ VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
+ VPX_MEMCPY_L((unsigned char *)x + size + i,
+ &tempme, sizeof(unsigned int));
+ }
+ } else
+ x = NULL;
+ }
#else
- x = vpx_realloc(memblk, size);
+ x = vpx_realloc(memblk, size);
#endif /*TRY_BOUNDS_CHECK*/
- if (!memblk) ++g_alloc_count;
+ if (!memblk) ++g_alloc_count;
- if (x)
- vpx_memory_tracker_add((size_t)x, (unsigned int)size, file, line, 1);
- else
- vpx_memory_tracker_add((size_t)memblk, orig_size, orig_file, orig_line, 1);
+ if (x)
+ vpx_memory_tracker_add((size_t)x, (unsigned int)size, file, line, 1);
+ else
+ vpx_memory_tracker_add((size_t)memblk, orig_size, orig_file, orig_line, 1);
- return x;
+ return x;
}
-void xvpx_free(void *p_address, char *file, int line)
-{
+void xvpx_free(void *p_address, char *file, int line) {
#if TRY_BOUNDS_CHECK
- unsigned char *p_bounds_address = (unsigned char *)p_address;
- /*p_bounds_address -= BOUNDS_CHECK_PAD_SIZE;*/
+ unsigned char *p_bounds_address = (unsigned char *)p_address;
+ /*p_bounds_address -= BOUNDS_CHECK_PAD_SIZE;*/
#endif
#if !TRY_BOUNDS_CHECK_ON_FREE
- (void)file;
- (void)line;
+ (void)file;
+ (void)line;
#endif
- if (p_address)
- {
+ if (p_address) {
#if TRY_BOUNDS_CHECK_ON_FREE
- vpx_memory_tracker_check_integrity(file, line);
+ vpx_memory_tracker_check_integrity(file, line);
#endif
- /* if the addr isn't found in the list, assume it was allocated via
- * vpx_ calls not xvpx_, therefore it does not contain any padding
- */
- if (vpx_memory_tracker_remove((size_t)p_address) == -2)
- {
- p_bounds_address = p_address;
- _P(fprintf(stderr, "[vpx_mem][xvpx_free] addr: %p not found in"
- " list; freed from file:%s"
- " line:%d\n", p_address, file, line));
- }
- else
- --g_alloc_count;
+ /* if the addr isn't found in the list, assume it was allocated via
+ * vpx_ calls not xvpx_, therefore it does not contain any padding
+ */
+ if (vpx_memory_tracker_remove((size_t)p_address) == -2) {
+ p_bounds_address = p_address;
+ _P(fprintf(stderr, "[vpx_mem][xvpx_free] addr: %p not found in"
+ " list; freed from file:%s"
+ " line:%d\n", p_address, file, line));
+ } else
+ --g_alloc_count;
#if TRY_BOUNDS_CHECK
- vpx_free(p_bounds_address);
+ vpx_free(p_bounds_address);
#else
- vpx_free(p_address);
+ vpx_free(p_address);
#endif
- if (!g_alloc_count)
- vpx_memory_tracker_destroy();
- }
+ if (!g_alloc_count)
+ vpx_memory_tracker_destroy();
+ }
}
#endif /*CONFIG_MEM_TRACKER*/
@@ -426,297 +393,265 @@ void xvpx_free(void *p_address, char *file, int line)
#include <task_lib.h> /*for task_delay()*/
/* This function is only used to get a stack trace of the player
object so we can se where we are having a problem. */
-static int get_my_tt(int task)
-{
- tt(task);
+static int get_my_tt(int task) {
+ tt(task);
- return 0;
+ return 0;
}
-static void vx_sleep(int msec)
-{
- int ticks_to_sleep = 0;
+static void vx_sleep(int msec) {
+ int ticks_to_sleep = 0;
- if (msec)
- {
- int msec_per_tick = 1000 / sys_clk_rate_get();
+ if (msec) {
+ int msec_per_tick = 1000 / sys_clk_rate_get();
- if (msec < msec_per_tick)
- ticks_to_sleep++;
- else
- ticks_to_sleep = msec / msec_per_tick;
- }
+ if (msec < msec_per_tick)
+ ticks_to_sleep++;
+ else
+ ticks_to_sleep = msec / msec_per_tick;
+ }
- task_delay(ticks_to_sleep);
+ task_delay(ticks_to_sleep);
}
#endif
#endif
-void *vpx_memcpy(void *dest, const void *source, size_t length)
-{
+void *vpx_memcpy(void *dest, const void *source, size_t length) {
#if CONFIG_MEM_CHECKS
- if (((int)dest < 0x4000) || ((int)source < 0x4000))
- {
- _P(printf("WARNING: vpx_memcpy dest:0x%x source:0x%x len:%d\n", (int)dest, (int)source, length);)
+ if (((int)dest < 0x4000) || ((int)source < 0x4000)) {
+ _P(printf("WARNING: vpx_memcpy dest:0x%x source:0x%x len:%d\n", (int)dest, (int)source, length);)
#if defined(VXWORKS)
- sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
+ sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
- vx_sleep(10000);
+ vx_sleep(10000);
#endif
- }
+ }
#endif
- return VPX_MEMCPY_L(dest, source, length);
+ return VPX_MEMCPY_L(dest, source, length);
}
-void *vpx_memset(void *dest, int val, size_t length)
-{
+void *vpx_memset(void *dest, int val, size_t length) {
#if CONFIG_MEM_CHECKS
- if ((int)dest < 0x4000)
- {
- _P(printf("WARNING: vpx_memset dest:0x%x val:%d len:%d\n", (int)dest, val, length);)
+ if ((int)dest < 0x4000) {
+ _P(printf("WARNING: vpx_memset dest:0x%x val:%d len:%d\n", (int)dest, val, length);)
#if defined(VXWORKS)
- sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
+ sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
- vx_sleep(10000);
+ vx_sleep(10000);
#endif
- }
+ }
#endif
- return VPX_MEMSET_L(dest, val, length);
+ return VPX_MEMSET_L(dest, val, length);
}
-void *vpx_memmove(void *dest, const void *src, size_t count)
-{
+void *vpx_memmove(void *dest, const void *src, size_t count) {
#if CONFIG_MEM_CHECKS
- if (((int)dest < 0x4000) || ((int)src < 0x4000))
- {
- _P(printf("WARNING: vpx_memmove dest:0x%x src:0x%x count:%d\n", (int)dest, (int)src, count);)
+ if (((int)dest < 0x4000) || ((int)src < 0x4000)) {
+ _P(printf("WARNING: vpx_memmove dest:0x%x src:0x%x count:%d\n", (int)dest, (int)src, count);)
#if defined(VXWORKS)
- sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
+ sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
- vx_sleep(10000);
+ vx_sleep(10000);
#endif
- }
+ }
#endif
- return VPX_MEMMOVE_L(dest, src, count);
+ return VPX_MEMMOVE_L(dest, src, count);
}
#if CONFIG_MEM_MANAGER
-static int vpx_mm_create_heap_memory()
-{
- int i_rv = 0;
+static int vpx_mm_create_heap_memory() {
+ int i_rv = 0;
- if (!g_mng_memory_allocated)
- {
+ if (!g_mng_memory_allocated) {
#if MM_DYNAMIC_MEMORY
- g_p_mng_memory_raw =
- (unsigned char *)malloc(g_mm_memory_size + HMM_ADDR_ALIGN_UNIT);
-
- if (g_p_mng_memory_raw)
- {
- g_p_mng_memory = (unsigned char *)((((unsigned int)g_p_mng_memory_raw) +
- HMM_ADDR_ALIGN_UNIT - 1) &
- -(int)HMM_ADDR_ALIGN_UNIT);
-
- _P(printf("[vpx][mm] total memory size:%d g_p_mng_memory_raw:0x%x g_p_mng_memory:0x%x\n"
- , g_mm_memory_size + HMM_ADDR_ALIGN_UNIT
- , (unsigned int)g_p_mng_memory_raw
- , (unsigned int)g_p_mng_memory);)
- }
- else
- {
- _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
- , g_mm_memory_size);)
-
- i_rv = -1;
- }
+ g_p_mng_memory_raw =
+ (unsigned char *)malloc(g_mm_memory_size + HMM_ADDR_ALIGN_UNIT);
+
+ if (g_p_mng_memory_raw) {
+ g_p_mng_memory = (unsigned char *)((((unsigned int)g_p_mng_memory_raw) +
+ HMM_ADDR_ALIGN_UNIT - 1) &
+ -(int)HMM_ADDR_ALIGN_UNIT);
+
+ _P(printf("[vpx][mm] total memory size:%d g_p_mng_memory_raw:0x%x g_p_mng_memory:0x%x\n"
+, g_mm_memory_size + HMM_ADDR_ALIGN_UNIT
+, (unsigned int)g_p_mng_memory_raw
+, (unsigned int)g_p_mng_memory);)
+ } else {
+ _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
+, g_mm_memory_size);)
+
+ i_rv = -1;
+ }
- if (g_p_mng_memory)
+ if (g_p_mng_memory)
#endif
- {
- int chunk_size = 0;
+ {
+ int chunk_size = 0;
- g_mng_memory_allocated = 1;
+ g_mng_memory_allocated = 1;
- hmm_init(&hmm_d);
+ hmm_init(&hmm_d);
- chunk_size = g_mm_memory_size >> SHIFT_HMM_ADDR_ALIGN_UNIT;
+ chunk_size = g_mm_memory_size >> SHIFT_HMM_ADDR_ALIGN_UNIT;
- chunk_size -= DUMMY_END_BLOCK_BAUS;
+ chunk_size -= DUMMY_END_BLOCK_BAUS;
- _P(printf("[vpx][mm] memory size:%d for vpx memory manager. g_p_mng_memory:0x%x chunk_size:%d\n"
- , g_mm_memory_size
- , (unsigned int)g_p_mng_memory
- , chunk_size);)
+ _P(printf("[vpx][mm] memory size:%d for vpx memory manager. g_p_mng_memory:0x%x chunk_size:%d\n"
+, g_mm_memory_size
+, (unsigned int)g_p_mng_memory
+, chunk_size);)
- hmm_new_chunk(&hmm_d, (void *)g_p_mng_memory, chunk_size);
- }
+ hmm_new_chunk(&hmm_d, (void *)g_p_mng_memory, chunk_size);
+ }
#if MM_DYNAMIC_MEMORY
- else
- {
- _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
- , g_mm_memory_size);)
+ else {
+ _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
+, g_mm_memory_size);)
- i_rv = -1;
- }
+ i_rv = -1;
+ }
#endif
- }
+ }
- return i_rv;
+ return i_rv;
}
-static void *vpx_mm_realloc(void *memblk, size_t size)
-{
- void *p_ret = NULL;
+static void *vpx_mm_realloc(void *memblk, size_t size) {
+ void *p_ret = NULL;
- if (vpx_mm_create_heap_memory() < 0)
- {
- _P(printf("[vpx][mm] ERROR vpx_mm_realloc() Couldn't create memory for Heap.\n");)
- }
- else
- {
- int i_rv = 0;
- int old_num_aaus;
- int new_num_aaus;
+ if (vpx_mm_create_heap_memory() < 0) {
+ _P(printf("[vpx][mm] ERROR vpx_mm_realloc() Couldn't create memory for Heap.\n");)
+ } else {
+ int i_rv = 0;
+ int old_num_aaus;
+ int new_num_aaus;
+
+ old_num_aaus = hmm_true_size(memblk);
+ new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
+
+ if (old_num_aaus == new_num_aaus) {
+ p_ret = memblk;
+ } else {
+ i_rv = hmm_resize(&hmm_d, memblk, new_num_aaus);
+
+ if (i_rv == 0) {
+ p_ret = memblk;
+ } else {
+ /* Error. Try to malloc and then copy data. */
+ void *p_from_malloc;
- old_num_aaus = hmm_true_size(memblk);
new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
+ p_from_malloc = hmm_alloc(&hmm_d, new_num_aaus);
- if (old_num_aaus == new_num_aaus)
- {
- p_ret = memblk;
- }
- else
- {
- i_rv = hmm_resize(&hmm_d, memblk, new_num_aaus);
-
- if (i_rv == 0)
- {
- p_ret = memblk;
- }
- else
- {
- /* Error. Try to malloc and then copy data. */
- void *p_from_malloc;
-
- new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
- p_from_malloc = hmm_alloc(&hmm_d, new_num_aaus);
-
- if (p_from_malloc)
- {
- vpx_memcpy(p_from_malloc, memblk, size);
- hmm_free(&hmm_d, memblk);
-
- p_ret = p_from_malloc;
- }
- }
+ if (p_from_malloc) {
+ vpx_memcpy(p_from_malloc, memblk, size);
+ hmm_free(&hmm_d, memblk);
+
+ p_ret = p_from_malloc;
}
+ }
}
+ }
- return p_ret;
+ return p_ret;
}
#endif /*CONFIG_MEM_MANAGER*/
#if USE_GLOBAL_FUNCTION_POINTERS
# if CONFIG_MEM_TRACKER
extern int vpx_memory_tracker_set_functions(g_malloc_func g_malloc_l
- , g_calloc_func g_calloc_l
- , g_realloc_func g_realloc_l
- , g_free_func g_free_l
- , g_memcpy_func g_memcpy_l
- , g_memset_func g_memset_l
- , g_memmove_func g_memmove_l);
+, g_calloc_func g_calloc_l
+, g_realloc_func g_realloc_l
+, g_free_func g_free_l
+, g_memcpy_func g_memcpy_l
+, g_memset_func g_memset_l
+, g_memmove_func g_memmove_l);
# endif
#endif /*USE_GLOBAL_FUNCTION_POINTERS*/
int vpx_mem_set_functions(g_malloc_func g_malloc_l
- , g_calloc_func g_calloc_l
- , g_realloc_func g_realloc_l
- , g_free_func g_free_l
- , g_memcpy_func g_memcpy_l
- , g_memset_func g_memset_l
- , g_memmove_func g_memmove_l)
-{
+, g_calloc_func g_calloc_l
+, g_realloc_func g_realloc_l
+, g_free_func g_free_l
+, g_memcpy_func g_memcpy_l
+, g_memset_func g_memset_l
+, g_memmove_func g_memmove_l) {
#if USE_GLOBAL_FUNCTION_POINTERS
- /* If use global functions is turned on then the
- application must set the global functions before
- it does anything else or vpx_mem will have
- unpredictable results. */
- if (!g_func)
- {
- g_func = (struct GLOBAL_FUNC_POINTERS *)
- g_malloc_l(sizeof(struct GLOBAL_FUNC_POINTERS));
+ /* If use global functions is turned on then the
+ application must set the global functions before
+ it does anything else or vpx_mem will have
+ unpredictable results. */
+ if (!g_func) {
+ g_func = (struct GLOBAL_FUNC_POINTERS *)
+ g_malloc_l(sizeof(struct GLOBAL_FUNC_POINTERS));
- if (!g_func)
- {
- return -1;
- }
+ if (!g_func) {
+ return -1;
}
+ }
#if CONFIG_MEM_TRACKER
- {
- int rv = 0;
- rv = vpx_memory_tracker_set_functions(g_malloc_l
- , g_calloc_l
- , g_realloc_l
- , g_free_l
- , g_memcpy_l
- , g_memset_l
- , g_memmove_l);
-
- if (rv < 0)
- {
- return rv;
- }
+ {
+ int rv = 0;
+ rv = vpx_memory_tracker_set_functions(g_malloc_l
+, g_calloc_l
+, g_realloc_l
+, g_free_l
+, g_memcpy_l
+, g_memset_l
+, g_memmove_l);
+
+ if (rv < 0) {
+ return rv;
}
+ }
#endif
- g_func->g_malloc = g_malloc_l;
- g_func->g_calloc = g_calloc_l;
- g_func->g_realloc = g_realloc_l;
- g_func->g_free = g_free_l;
- g_func->g_memcpy = g_memcpy_l;
- g_func->g_memset = g_memset_l;
- g_func->g_memmove = g_memmove_l;
+ g_func->g_malloc = g_malloc_l;
+ g_func->g_calloc = g_calloc_l;
+ g_func->g_realloc = g_realloc_l;
+ g_func->g_free = g_free_l;
+ g_func->g_memcpy = g_memcpy_l;
+ g_func->g_memset = g_memset_l;
+ g_func->g_memmove = g_memmove_l;
- return 0;
+ return 0;
#else
- (void)g_malloc_l;
- (void)g_calloc_l;
- (void)g_realloc_l;
- (void)g_free_l;
- (void)g_memcpy_l;
- (void)g_memset_l;
- (void)g_memmove_l;
- return -1;
+ (void)g_malloc_l;
+ (void)g_calloc_l;
+ (void)g_realloc_l;
+ (void)g_free_l;
+ (void)g_memcpy_l;
+ (void)g_memset_l;
+ (void)g_memmove_l;
+ return -1;
#endif
}
-int vpx_mem_unset_functions()
-{
+int vpx_mem_unset_functions() {
#if USE_GLOBAL_FUNCTION_POINTERS
- if (g_func)
- {
- g_free_func temp_free = g_func->g_free;
- temp_free(g_func);
- g_func = NULL;
- }
+ if (g_func) {
+ g_free_func temp_free = g_func->g_free;
+ temp_free(g_func);
+ g_func = NULL;
+ }
#endif
- return 0;
+ return 0;
}
diff --git a/vpx_mem/vpx_mem.h b/vpx_mem/vpx_mem.h
index 749eaa42e..6ee5f5d7e 100644
--- a/vpx_mem/vpx_mem.h
+++ b/vpx_mem/vpx_mem.h
@@ -30,11 +30,11 @@
#endif
#ifndef VPX_CHECK_MEM_FUNCTIONS
# define VPX_CHECK_MEM_FUNCTIONS 0 /* enable basic safety checks in _memcpy,
- _memset, and _memmove */
+_memset, and _memmove */
#endif
#ifndef REPLACE_BUILTIN_FUNCTIONS
# define REPLACE_BUILTIN_FUNCTIONS 0 /* replace builtin functions with their
- vpx_ equivalents */
+vpx_ equivalents */
#endif
#include <stdlib.h>
@@ -44,60 +44,60 @@
extern "C" {
#endif
- /*
- vpx_mem_get_version()
- provided for runtime version checking. Returns an unsigned int of the form
- CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high
- order byte.
- */
- unsigned int vpx_mem_get_version(void);
-
- /*
- vpx_mem_set_heap_size(size_t size)
- size - size in bytes for the memory manager to allocate for its heap
- Sets the memory manager's initial heap size
- Return:
- 0: on success
- -1: if memory manager calls have not been included in the vpx_mem lib
- -2: if the memory manager has been compiled to use static memory
- -3: if the memory manager has already allocated its heap
- */
- int vpx_mem_set_heap_size(size_t size);
-
- void *vpx_memalign(size_t align, size_t size);
- void *vpx_malloc(size_t size);
- void *vpx_calloc(size_t num, size_t size);
- void *vpx_realloc(void *memblk, size_t size);
- void vpx_free(void *memblk);
-
- void *vpx_memcpy(void *dest, const void *src, size_t length);
- void *vpx_memset(void *dest, int val, size_t length);
- void *vpx_memmove(void *dest, const void *src, size_t count);
-
- /* special memory functions */
- void *vpx_mem_alloc(int id, size_t size, size_t align);
- void vpx_mem_free(int id, void *mem, size_t size);
-
- /* Wrappers to standard library functions. */
- typedef void*(* g_malloc_func)(size_t);
- typedef void*(* g_calloc_func)(size_t, size_t);
- typedef void*(* g_realloc_func)(void *, size_t);
- typedef void (* g_free_func)(void *);
- typedef void*(* g_memcpy_func)(void *, const void *, size_t);
- typedef void*(* g_memset_func)(void *, int, size_t);
- typedef void*(* g_memmove_func)(void *, const void *, size_t);
-
- int vpx_mem_set_functions(g_malloc_func g_malloc_l
- , g_calloc_func g_calloc_l
- , g_realloc_func g_realloc_l
- , g_free_func g_free_l
- , g_memcpy_func g_memcpy_l
- , g_memset_func g_memset_l
- , g_memmove_func g_memmove_l);
- int vpx_mem_unset_functions(void);
-
-
- /* some defines for backward compatibility */
+ /*
+ vpx_mem_get_version()
+ provided for runtime version checking. Returns an unsigned int of the form
+ CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high
+ order byte.
+ */
+ unsigned int vpx_mem_get_version(void);
+
+ /*
+ vpx_mem_set_heap_size(size_t size)
+ size - size in bytes for the memory manager to allocate for its heap
+ Sets the memory manager's initial heap size
+ Return:
+ 0: on success
+ -1: if memory manager calls have not been included in the vpx_mem lib
+ -2: if the memory manager has been compiled to use static memory
+ -3: if the memory manager has already allocated its heap
+ */
+ int vpx_mem_set_heap_size(size_t size);
+
+ void *vpx_memalign(size_t align, size_t size);
+ void *vpx_malloc(size_t size);
+ void *vpx_calloc(size_t num, size_t size);
+ void *vpx_realloc(void *memblk, size_t size);
+ void vpx_free(void *memblk);
+
+ void *vpx_memcpy(void *dest, const void *src, size_t length);
+ void *vpx_memset(void *dest, int val, size_t length);
+ void *vpx_memmove(void *dest, const void *src, size_t count);
+
+ /* special memory functions */
+ void *vpx_mem_alloc(int id, size_t size, size_t align);
+ void vpx_mem_free(int id, void *mem, size_t size);
+
+ /* Wrappers to standard library functions. */
+ typedef void *(* g_malloc_func)(size_t);
+ typedef void *(* g_calloc_func)(size_t, size_t);
+ typedef void *(* g_realloc_func)(void *, size_t);
+ typedef void (* g_free_func)(void *);
+ typedef void *(* g_memcpy_func)(void *, const void *, size_t);
+ typedef void *(* g_memset_func)(void *, int, size_t);
+ typedef void *(* g_memmove_func)(void *, const void *, size_t);
+
+ int vpx_mem_set_functions(g_malloc_func g_malloc_l
+, g_calloc_func g_calloc_l
+, g_realloc_func g_realloc_l
+, g_free_func g_free_l
+, g_memcpy_func g_memcpy_l
+, g_memset_func g_memset_l
+, g_memmove_func g_memmove_l);
+ int vpx_mem_unset_functions(void);
+
+
+ /* some defines for backward compatibility */
#define DMEM_GENERAL 0
#define duck_memalign(X,Y,Z) vpx_memalign(X,Y)
@@ -124,13 +124,13 @@ extern "C" {
#if CONFIG_MEM_TRACKER
#include <stdarg.h>
- /*from vpx_mem/vpx_mem_tracker.c*/
- extern void vpx_memory_tracker_dump();
- extern void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
- extern int vpx_memory_tracker_set_log_type(int type, char *option);
- extern int vpx_memory_tracker_set_log_func(void *userdata,
- void(*logfunc)(void *userdata,
- const char *fmt, va_list args));
+ /*from vpx_mem/vpx_mem_tracker.c*/
+ extern void vpx_memory_tracker_dump();
+ extern void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
+ extern int vpx_memory_tracker_set_log_type(int type, char *option);
+ extern int vpx_memory_tracker_set_log_func(void *userdata,
+ void(*logfunc)(void *userdata,
+ const char *fmt, va_list args));
# ifndef __VPX_MEM_C__
# define vpx_memalign(align, size) xvpx_memalign((align), (size), __FILE__, __LINE__)
# define vpx_malloc(size) xvpx_malloc((size), __FILE__, __LINE__)
@@ -142,13 +142,13 @@ extern "C" {
# define vpx_mem_free(id,mem,size) xvpx_mem_free(id, mem, size, __FILE__, __LINE__)
# endif
- void *xvpx_memalign(size_t align, size_t size, char *file, int line);
- void *xvpx_malloc(size_t size, char *file, int line);
- void *xvpx_calloc(size_t num, size_t size, char *file, int line);
- void *xvpx_realloc(void *memblk, size_t size, char *file, int line);
- void xvpx_free(void *memblk, char *file, int line);
- void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line);
- void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line);
+ void *xvpx_memalign(size_t align, size_t size, char *file, int line);
+ void *xvpx_malloc(size_t size, char *file, int line);
+ void *xvpx_calloc(size_t num, size_t size, char *file, int line);
+ void *xvpx_realloc(void *memblk, size_t size, char *file, int line);
+ void xvpx_free(void *memblk, char *file, int line);
+ void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line);
+ void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line);
#else
# ifndef __VPX_MEM_C__
diff --git a/vpx_mem/vpx_mem_tracker.c b/vpx_mem/vpx_mem_tracker.c
index 9e8623a9a..5b2103b55 100644
--- a/vpx_mem/vpx_mem_tracker.c
+++ b/vpx_mem/vpx_mem_tracker.c
@@ -40,20 +40,20 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> //VXWORKS doesn't have a malloc/memory.h file,
-//this should pull in malloc,free,etc.
+#include <string.h> // VXWORKS doesn't have a malloc/memory.h file,
+// this should pull in malloc,free,etc.
#include <stdarg.h>
#include "include/vpx_mem_tracker.h"
-#undef vpx_malloc //undefine any vpx_mem macros that may affect calls to
-#undef vpx_free //memory functions in this file
+#undef vpx_malloc // undefine any vpx_mem macros that may affect calls to
+#undef vpx_free // memory functions in this file
#undef vpx_memcpy
#undef vpx_memset
#ifndef USE_GLOBAL_FUNCTION_POINTERS
-# define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions.
+# define USE_GLOBAL_FUNCTION_POINTERS 0 // use function pointers instead of compiled functions.
#endif
#if USE_GLOBAL_FUNCTION_POINTERS
@@ -94,39 +94,37 @@ static int memory_tracker_unlock_mutex();
#endif
#ifndef VPX_NO_GLOBALS
-struct memory_tracker
-{
- struct mem_block *head,
- * tail;
- int len,
- totalsize;
- unsigned int current_allocated,
- max_allocated;
+struct memory_tracker {
+ struct mem_block *head,
+ * tail;
+ int len,
+ totalsize;
+ unsigned int current_allocated,
+ max_allocated;
#if HAVE_PTHREAD_H
- pthread_mutex_t mutex;
+ pthread_mutex_t mutex;
#elif defined(WIN32) || defined(_WIN32_WCE)
- HANDLE mutex;
+ HANDLE mutex;
#elif defined(VXWORKS)
- SEM_ID mutex;
+ SEM_ID mutex;
#elif defined(NO_MUTEX)
#else
#error "No mutex type defined for this platform!"
#endif
- int padding_size,
- pad_value;
+ int padding_size,
+ pad_value;
};
-static struct memory_tracker memtrack; //our global memory allocation list
-static int g_b_mem_tracker_inited = 0; //indicates whether the global list has
-//been initialized (1:yes/0:no)
-static struct
-{
- FILE *file;
- int type;
- void (*func)(void *userdata, const char *fmt, va_list args);
- void *userdata;
+static struct memory_tracker memtrack; // our global memory allocation list
+static int g_b_mem_tracker_inited = 0; // indicates whether the global list has
+// been initialized (1:yes/0:no)
+static struct {
+ FILE *file;
+ int type;
+ void (*func)(void *userdata, const char *fmt, va_list args);
+ void *userdata;
} g_logging = {NULL, 0, NULL, NULL};
#else
# include "vpx_global_handling.h"
@@ -157,60 +155,54 @@ extern void *vpx_memset(void *dest, int val, size_t length);
Initializes global memory tracker structure
Allocates the head of the list
*/
-int vpx_memory_tracker_init(int padding_size, int pad_value)
-{
- if (!g_b_mem_tracker_inited)
- {
- if ((memtrack.head = (struct mem_block *)
- MEM_TRACK_MALLOC(sizeof(struct mem_block))))
- {
- int ret;
+int vpx_memory_tracker_init(int padding_size, int pad_value) {
+ if (!g_b_mem_tracker_inited) {
+ if ((memtrack.head = (struct mem_block *)
+ MEM_TRACK_MALLOC(sizeof(struct mem_block)))) {
+ int ret;
- MEM_TRACK_MEMSET(memtrack.head, 0, sizeof(struct mem_block));
+ MEM_TRACK_MEMSET(memtrack.head, 0, sizeof(struct mem_block));
- memtrack.tail = memtrack.head;
+ memtrack.tail = memtrack.head;
- memtrack.current_allocated = 0;
- memtrack.max_allocated = 0;
+ memtrack.current_allocated = 0;
+ memtrack.max_allocated = 0;
- memtrack.padding_size = padding_size;
- memtrack.pad_value = pad_value;
+ memtrack.padding_size = padding_size;
+ memtrack.pad_value = pad_value;
#if HAVE_PTHREAD_H
- ret = pthread_mutex_init(&memtrack.mutex,
- NULL); /*mutex attributes (NULL=default)*/
+ ret = pthread_mutex_init(&memtrack.mutex,
+ NULL); /*mutex attributes (NULL=default)*/
#elif defined(WIN32) || defined(_WIN32_WCE)
- memtrack.mutex = CreateMutex(NULL, /*security attributes*/
- FALSE, /*we don't want initial ownership*/
- NULL); /*mutex name*/
- ret = !memtrack.mutex;
+ memtrack.mutex = CreateMutex(NULL, /*security attributes*/
+ FALSE, /*we don't want initial ownership*/
+ NULL); /*mutex name*/
+ ret = !memtrack.mutex;
#elif defined(VXWORKS)
- memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority based mutex*/
- SEM_FULL); /*SEM_FULL initial state is unlocked*/
- ret = !memtrack.mutex;
+ memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority based mutex*/
+ SEM_FULL); /*SEM_FULL initial state is unlocked*/
+ ret = !memtrack.mutex;
#elif defined(NO_MUTEX)
- ret = 0;
+ ret = 0;
#endif
- if (ret)
- {
- memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n");
-
- MEM_TRACK_FREE(memtrack.head);
- memtrack.head = NULL;
- }
- else
- {
- memtrack_log("Memory Tracker init'd, v."vpx_mem_tracker_version" pad_size:%d pad_val:0x%x %d\n"
- , padding_size
- , pad_value
- , pad_value);
- g_b_mem_tracker_inited = 1;
- }
- }
+ if (ret) {
+ memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n");
+
+ MEM_TRACK_FREE(memtrack.head);
+ memtrack.head = NULL;
+ } else {
+ memtrack_log("Memory Tracker init'd, v."vpx_mem_tracker_version" pad_size:%d pad_val:0x%x %d\n"
+, padding_size
+, pad_value
+, pad_value);
+ g_b_mem_tracker_inited = 1;
+ }
}
+ }
- return g_b_mem_tracker_inited;
+ return g_b_mem_tracker_inited;
}
/*
@@ -218,39 +210,35 @@ int vpx_memory_tracker_init(int padding_size, int pad_value)
If our global struct was initialized zeros out all its members,
frees memory and destroys it's mutex
*/
-void vpx_memory_tracker_destroy()
-{
- if (!memory_tracker_lock_mutex())
- {
- struct mem_block *p = memtrack.head,
- * p2 = memtrack.head;
+void vpx_memory_tracker_destroy() {
+ if (!memory_tracker_lock_mutex()) {
+ struct mem_block *p = memtrack.head,
+ * p2 = memtrack.head;
- memory_tracker_dump();
+ memory_tracker_dump();
- while (p)
- {
- p2 = p;
- p = p->next;
+ while (p) {
+ p2 = p;
+ p = p->next;
- MEM_TRACK_FREE(p2);
- }
+ MEM_TRACK_FREE(p2);
+ }
- memtrack.head = NULL;
- memtrack.tail = NULL;
- memtrack.len = 0;
- memtrack.current_allocated = 0;
- memtrack.max_allocated = 0;
+ memtrack.head = NULL;
+ memtrack.tail = NULL;
+ memtrack.len = 0;
+ memtrack.current_allocated = 0;
+ memtrack.max_allocated = 0;
- if (!g_logging.type && g_logging.file && g_logging.file != stderr)
- {
- fclose(g_logging.file);
- g_logging.file = NULL;
- }
+ if (!g_logging.type && g_logging.file && g_logging.file != stderr) {
+ fclose(g_logging.file);
+ g_logging.file = NULL;
+ }
- memory_tracker_unlock_mutex();
+ memory_tracker_unlock_mutex();
- g_b_mem_tracker_inited = 0;
- }
+ g_b_mem_tracker_inited = 0;
+ }
}
/*
@@ -265,9 +253,8 @@ void vpx_memory_tracker_destroy()
*/
void vpx_memory_tracker_add(size_t addr, unsigned int size,
char *file, unsigned int line,
- int padded)
-{
- memory_tracker_add(addr, size, file, line, padded);
+ int padded) {
+ memory_tracker_add(addr, size, file, line, padded);
}
/*
@@ -278,9 +265,8 @@ void vpx_memory_tracker_add(size_t addr, unsigned int size,
Return:
Same as described for memory_tracker_remove
*/
-int vpx_memory_tracker_remove(size_t addr)
-{
- return memory_tracker_remove(addr);
+int vpx_memory_tracker_remove(size_t addr) {
+ return memory_tracker_remove(addr);
}
/*
@@ -290,17 +276,15 @@ int vpx_memory_tracker_remove(size_t addr)
If found, pointer to the memory block that matches addr
NULL otherwise
*/
-struct mem_block *vpx_memory_tracker_find(size_t addr)
-{
- struct mem_block *p = NULL;
-
- if (!memory_tracker_lock_mutex())
- {
- p = memory_tracker_find(addr);
- memory_tracker_unlock_mutex();
- }
+struct mem_block *vpx_memory_tracker_find(size_t addr) {
+ struct mem_block *p = NULL;
- return p;
+ if (!memory_tracker_lock_mutex()) {
+ p = memory_tracker_find(addr);
+ memory_tracker_unlock_mutex();
+ }
+
+ return p;
}
/*
@@ -309,13 +293,11 @@ struct mem_block *vpx_memory_tracker_find(size_t addr)
library function to dump the current contents of the
global memory allocation list
*/
-void vpx_memory_tracker_dump()
-{
- if (!memory_tracker_lock_mutex())
- {
- memory_tracker_dump();
- memory_tracker_unlock_mutex();
- }
+void vpx_memory_tracker_dump() {
+ if (!memory_tracker_lock_mutex()) {
+ memory_tracker_dump();
+ memory_tracker_unlock_mutex();
+ }
}
/*
@@ -326,13 +308,11 @@ void vpx_memory_tracker_dump()
integrity check function to inspect every address in the global
memory allocation list
*/
-void vpx_memory_tracker_check_integrity(char *file, unsigned int line)
-{
- if (!memory_tracker_lock_mutex())
- {
- memory_tracker_check_integrity(file, line);
- memory_tracker_unlock_mutex();
- }
+void vpx_memory_tracker_check_integrity(char *file, unsigned int line) {
+ if (!memory_tracker_lock_mutex()) {
+ memory_tracker_check_integrity(file, line);
+ memory_tracker_unlock_mutex();
+ }
}
/*
@@ -344,43 +324,38 @@ void vpx_memory_tracker_check_integrity(char *file, unsigned int line)
-1: if the logging type could not be set, because the value was invalid
or because a file could not be opened
*/
-int vpx_memory_tracker_set_log_type(int type, char *option)
-{
- int ret = -1;
+int vpx_memory_tracker_set_log_type(int type, char *option) {
+ int ret = -1;
- switch (type)
- {
+ switch (type) {
case 0:
- g_logging.type = 0;
+ g_logging.type = 0;
- if (!option)
- {
- g_logging.file = stderr;
- ret = 0;
- }
- else
- {
- if ((g_logging.file = fopen((char *)option, "w")))
- ret = 0;
- }
+ if (!option) {
+ g_logging.file = stderr;
+ ret = 0;
+ } else {
+ if ((g_logging.file = fopen((char *)option, "w")))
+ ret = 0;
+ }
- break;
+ break;
#if defined(WIN32) && !defined(_WIN32_WCE)
case 1:
- g_logging.type = type;
- ret = 0;
- break;
+ g_logging.type = type;
+ ret = 0;
+ break;
#endif
default:
- break;
- }
+ break;
+ }
- //output the version to the new logging destination
- if (!ret)
- memtrack_log("Memory Tracker logging initialized, "
- "Memory Tracker v."vpx_mem_tracker_version"\n");
+ // output the version to the new logging destination
+ if (!ret)
+ memtrack_log("Memory Tracker logging initialized, "
+ "Memory Tracker v."vpx_mem_tracker_version"\n");
- return ret;
+ return ret;
}
/*
@@ -392,24 +367,22 @@ int vpx_memory_tracker_set_log_type(int type, char *option)
*/
int vpx_memory_tracker_set_log_func(void *userdata,
void(*logfunc)(void *userdata,
- const char *fmt, va_list args))
-{
- int ret = -1;
-
- if (logfunc)
- {
- g_logging.type = -1;
- g_logging.userdata = userdata;
- g_logging.func = logfunc;
- ret = 0;
- }
-
- //output the version to the new logging destination
- if (!ret)
- memtrack_log("Memory Tracker logging initialized, "
- "Memory Tracker v."vpx_mem_tracker_version"\n");
-
- return ret;
+ const char *fmt, va_list args)) {
+ int ret = -1;
+
+ if (logfunc) {
+ g_logging.type = -1;
+ g_logging.userdata = userdata;
+ g_logging.func = logfunc;
+ ret = 0;
+ }
+
+ // output the version to the new logging destination
+ if (!ret)
+ memtrack_log("Memory Tracker logging initialized, "
+ "Memory Tracker v."vpx_mem_tracker_version"\n");
+
+ return ret;
}
/*
@@ -425,79 +398,73 @@ int vpx_memory_tracker_set_log_func(void *userdata,
*
*/
-static void memtrack_log(const char *fmt, ...)
-{
- va_list list;
+static void memtrack_log(const char *fmt, ...) {
+ va_list list;
- va_start(list, fmt);
+ va_start(list, fmt);
- switch (g_logging.type)
- {
+ switch (g_logging.type) {
case -1:
- if (g_logging.func)
- g_logging.func(g_logging.userdata, fmt, list);
+ if (g_logging.func)
+ g_logging.func(g_logging.userdata, fmt, list);
- break;
+ break;
case 0:
- if (g_logging.file)
- {
- vfprintf(g_logging.file, fmt, list);
- fflush(g_logging.file);
- }
+ if (g_logging.file) {
+ vfprintf(g_logging.file, fmt, list);
+ fflush(g_logging.file);
+ }
- break;
+ break;
#if defined(WIN32) && !defined(_WIN32_WCE)
- case 1:
- {
- char temp[1024];
- _vsnprintf(temp, sizeof(temp) / sizeof(char) - 1, fmt, list);
- OutputDebugString(temp);
+ case 1: {
+ char temp[1024];
+ _vsnprintf(temp, sizeof(temp) / sizeof(char) - 1, fmt, list);
+ OutputDebugString(temp);
}
break;
#endif
default:
- break;
- }
+ break;
+ }
- va_end(list);
+ va_end(list);
}
/*
memory_tracker_dump()
Dumps the current contents of the global memory allocation list
*/
-static void memory_tracker_dump()
-{
- int i = 0;
- struct mem_block *p = (memtrack.head ? memtrack.head->next : NULL);
+static void memory_tracker_dump() {
+ int i = 0;
+ struct mem_block *p = (memtrack.head ? memtrack.head->next : NULL);
- memtrack_log("\n_currently Allocated= %d; Max allocated= %d\n",
- memtrack.current_allocated, memtrack.max_allocated);
+ memtrack_log("\n_currently Allocated= %d; Max allocated= %d\n",
+ memtrack.current_allocated, memtrack.max_allocated);
- while (p)
- {
+ while (p) {
#if defined(WIN32) && !defined(_WIN32_WCE)
- /*when using outputdebugstring, output filenames so they
- can be clicked to be opened in visual studio*/
- if (g_logging.type == 1)
- memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file:\n"
- " %s(%d):\n", i,
- p->addr, i, p->size,
- p->file, p->line);
- else
+ /*when using outputdebugstring, output filenames so they
+ can be clicked to be opened in visual studio*/
+ if (g_logging.type == 1)
+ memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file:\n"
+ " %s(%d):\n", i,
+ p->addr, i, p->size,
+ p->file, p->line);
+ else
#endif
- memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file: %s, line: %d\n", i,
- p->addr, i, p->size,
- p->file, p->line);
+ memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file: %s, line: %d\n", i,
+ p->addr, i, p->size,
+ p->file, p->line);
- p = p->next;
- ++i;
- }
+ p = p->next;
+ ++i;
+ }
- memtrack_log("\n");
+ memtrack_log("\n");
}
/*
@@ -508,55 +475,49 @@ static void memory_tracker_dump()
this function will check ea. addr in the list verifying that
addr-padding_size and addr+padding_size is filled with pad_value
*/
-static void memory_tracker_check_integrity(char *file, unsigned int line)
-{
- if (memtrack.padding_size)
- {
- int i,
- index = 0;
- unsigned char *p_show_me,
- * p_show_me2;
- unsigned int tempme = memtrack.pad_value,
- dead1,
- dead2;
- unsigned char *x_bounds;
- struct mem_block *p = memtrack.head->next;
-
- while (p)
- {
- //x_bounds = (unsigned char*)p->addr;
- //back up VPX_BYTE_ALIGNMENT
- //x_bounds -= memtrack.padding_size;
-
- if (p->padded) // can the bounds be checked?
- {
- /*yes, move to the address that was actually allocated
- by the vpx_* calls*/
- x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]);
-
- for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int))
- {
- p_show_me = (x_bounds + i);
- p_show_me2 = (unsigned char *)(p->addr + p->size + i);
-
- MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int));
- MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int));
-
- if ((dead1 != tempme) || (dead2 != tempme))
- {
- memtrack_log("\n[vpx_mem integrity check failed]:\n"
- " index[%d,%d] {%s:%d} addr=0x%x, size=%d,"
- " file: %s, line: %d c0:0x%x c1:0x%x\n",
- index, i, file, line, p->addr, p->size, p->file,
- p->line, dead1, dead2);
- }
- }
- }
-
- ++index;
- p = p->next;
+static void memory_tracker_check_integrity(char *file, unsigned int line) {
+ if (memtrack.padding_size) {
+ int i,
+ index = 0;
+ unsigned char *p_show_me,
+ * p_show_me2;
+ unsigned int tempme = memtrack.pad_value,
+ dead1,
+ dead2;
+ unsigned char *x_bounds;
+ struct mem_block *p = memtrack.head->next;
+
+ while (p) {
+ // x_bounds = (unsigned char*)p->addr;
+ // back up VPX_BYTE_ALIGNMENT
+ // x_bounds -= memtrack.padding_size;
+
+ if (p->padded) { // can the bounds be checked?
+ /*yes, move to the address that was actually allocated
+ by the vpx_* calls*/
+ x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]);
+
+ for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int)) {
+ p_show_me = (x_bounds + i);
+ p_show_me2 = (unsigned char *)(p->addr + p->size + i);
+
+ MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int));
+ MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int));
+
+ if ((dead1 != tempme) || (dead2 != tempme)) {
+ memtrack_log("\n[vpx_mem integrity check failed]:\n"
+ " index[%d,%d] {%s:%d} addr=0x%x, size=%d,"
+ " file: %s, line: %d c0:0x%x c1:0x%x\n",
+ index, i, file, line, p->addr, p->size, p->file,
+ p->line, dead1, dead2);
+ }
}
+ }
+
+ ++index;
+ p = p->next;
}
+ }
}
/*
@@ -568,43 +529,38 @@ static void memory_tracker_check_integrity(char *file, unsigned int line)
*/
void memory_tracker_add(size_t addr, unsigned int size,
char *file, unsigned int line,
- int padded)
-{
- if (!memory_tracker_lock_mutex())
- {
- struct mem_block *p;
+ int padded) {
+ if (!memory_tracker_lock_mutex()) {
+ struct mem_block *p;
- p = MEM_TRACK_MALLOC(sizeof(struct mem_block));
+ p = MEM_TRACK_MALLOC(sizeof(struct mem_block));
- if (p)
- {
- p->prev = memtrack.tail;
- p->prev->next = p;
- p->addr = addr;
- p->size = size;
- p->line = line;
- p->file = file;
- p->padded = padded;
- p->next = NULL;
+ if (p) {
+ p->prev = memtrack.tail;
+ p->prev->next = p;
+ p->addr = addr;
+ p->size = size;
+ p->line = line;
+ p->file = file;
+ p->padded = padded;
+ p->next = NULL;
- memtrack.tail = p;
+ memtrack.tail = p;
- memtrack.current_allocated += size;
+ memtrack.current_allocated += size;
- if (memtrack.current_allocated > memtrack.max_allocated)
- memtrack.max_allocated = memtrack.current_allocated;
+ if (memtrack.current_allocated > memtrack.max_allocated)
+ memtrack.max_allocated = memtrack.current_allocated;
- //memtrack_log("memory_tracker_add: added addr=0x%.8x\n", addr);
+ // memtrack_log("memory_tracker_add: added addr=0x%.8x\n", addr);
- memory_tracker_unlock_mutex();
- }
- else
- {
- memtrack_log("memory_tracker_add: error allocating memory!\n");
- memory_tracker_unlock_mutex();
- vpx_memory_tracker_destroy();
- }
+ memory_tracker_unlock_mutex();
+ } else {
+ memtrack_log("memory_tracker_add: error allocating memory!\n");
+ memory_tracker_unlock_mutex();
+ vpx_memory_tracker_destroy();
}
+ }
}
/*
@@ -617,41 +573,36 @@ void memory_tracker_add(size_t addr, unsigned int size,
-1: if the mutex could not be locked
-2: if the addr was not found in the list
*/
-int memory_tracker_remove(size_t addr)
-{
- int ret = -1;
-
- if (!memory_tracker_lock_mutex())
- {
- struct mem_block *p;
+int memory_tracker_remove(size_t addr) {
+ int ret = -1;
- if ((p = memory_tracker_find(addr)))
- {
- memtrack.current_allocated -= p->size;
+ if (!memory_tracker_lock_mutex()) {
+ struct mem_block *p;
- p->prev->next = p->next;
+ if ((p = memory_tracker_find(addr))) {
+ memtrack.current_allocated -= p->size;
- if (p->next)
- p->next->prev = p->prev;
- else
- memtrack.tail = p->prev;
+ p->prev->next = p->next;
- ret = 0;
- MEM_TRACK_FREE(p);
- }
- else
- {
- if (addr)
- memtrack_log("memory_tracker_remove(): addr not found in list,"
- " 0x%.8x\n", addr);
+ if (p->next)
+ p->next->prev = p->prev;
+ else
+ memtrack.tail = p->prev;
- ret = -2;
- }
+ ret = 0;
+ MEM_TRACK_FREE(p);
+ } else {
+ if (addr)
+ memtrack_log("memory_tracker_remove(): addr not found in list,"
+ " 0x%.8x\n", addr);
- memory_tracker_unlock_mutex();
+ ret = -2;
}
- return ret;
+ memory_tracker_unlock_mutex();
+ }
+
+ return ret;
}
/*
@@ -662,19 +613,17 @@ int memory_tracker_remove(size_t addr)
the need for repeated locking and unlocking as in Remove
Returns: pointer to the mem block if found, NULL otherwise
*/
-static struct mem_block *memory_tracker_find(size_t addr)
-{
- struct mem_block *p = NULL;
+static struct mem_block *memory_tracker_find(size_t addr) {
+ struct mem_block *p = NULL;
- if (memtrack.head)
- {
- p = memtrack.head->next;
+ if (memtrack.head) {
+ p = memtrack.head->next;
- while (p && (p->addr != addr))
- p = p->next;
- }
+ while (p && (p->addr != addr))
+ p = p->next;
+ }
- return p;
+ return p;
}
@@ -687,28 +636,25 @@ static struct mem_block *memory_tracker_find(size_t addr)
<0: Failure, either the mutex was not initialized
or the call to lock the mutex failed
*/
-static int memory_tracker_lock_mutex()
-{
- int ret = -1;
+static int memory_tracker_lock_mutex() {
+ int ret = -1;
- if (g_b_mem_tracker_inited)
- {
+ if (g_b_mem_tracker_inited) {
#if HAVE_PTHREAD_H
- ret = pthread_mutex_lock(&memtrack.mutex);
+ ret = pthread_mutex_lock(&memtrack.mutex);
#elif defined(WIN32) || defined(_WIN32_WCE)
- ret = WaitForSingleObject(memtrack.mutex, INFINITE);
+ ret = WaitForSingleObject(memtrack.mutex, INFINITE);
#elif defined(VXWORKS)
- ret = sem_take(memtrack.mutex, WAIT_FOREVER);
+ ret = sem_take(memtrack.mutex, WAIT_FOREVER);
#endif
- if (ret)
- {
- memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n");
- }
+ if (ret) {
+ memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n");
}
+ }
- return ret;
+ return ret;
}
/*
@@ -719,28 +665,25 @@ static int memory_tracker_lock_mutex()
<0: Failure, either the mutex was not initialized
or the call to unlock the mutex failed
*/
-static int memory_tracker_unlock_mutex()
-{
- int ret = -1;
+static int memory_tracker_unlock_mutex() {
+ int ret = -1;
- if (g_b_mem_tracker_inited)
- {
+ if (g_b_mem_tracker_inited) {
#if HAVE_PTHREAD_H
- ret = pthread_mutex_unlock(&memtrack.mutex);
+ ret = pthread_mutex_unlock(&memtrack.mutex);
#elif defined(WIN32) || defined(_WIN32_WCE)
- ret = !ReleaseMutex(memtrack.mutex);
+ ret = !ReleaseMutex(memtrack.mutex);
#elif defined(VXWORKS)
- ret = sem_give(memtrack.mutex);
+ ret = sem_give(memtrack.mutex);
#endif
- if (ret)
- {
- memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n");
- }
+ if (ret) {
+ memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n");
}
+ }
- return ret;
+ return ret;
}
#endif
@@ -754,45 +697,44 @@ static int memory_tracker_unlock_mutex()
-1: if the use global function pointers is not set.
*/
int vpx_memory_tracker_set_functions(mem_track_malloc_func g_malloc_l
- , mem_track_calloc_func g_calloc_l
- , mem_track_realloc_func g_realloc_l
- , mem_track_free_func g_free_l
- , mem_track_memcpy_func g_memcpy_l
- , mem_track_memset_func g_memset_l
- , mem_track_memmove_func g_memmove_l)
-{
+, mem_track_calloc_func g_calloc_l
+, mem_track_realloc_func g_realloc_l
+, mem_track_free_func g_free_l
+, mem_track_memcpy_func g_memcpy_l
+, mem_track_memset_func g_memset_l
+, mem_track_memmove_func g_memmove_l) {
#if USE_GLOBAL_FUNCTION_POINTERS
- if (g_malloc_l)
- g_malloc = g_malloc_l;
+ if (g_malloc_l)
+ g_malloc = g_malloc_l;
- if (g_calloc_l)
- g_calloc = g_calloc_l;
+ if (g_calloc_l)
+ g_calloc = g_calloc_l;
- if (g_realloc_l)
- g_realloc = g_realloc_l;
+ if (g_realloc_l)
+ g_realloc = g_realloc_l;
- if (g_free_l)
- g_free = g_free_l;
+ if (g_free_l)
+ g_free = g_free_l;
- if (g_memcpy_l)
- g_memcpy = g_memcpy_l;
+ if (g_memcpy_l)
+ g_memcpy = g_memcpy_l;
- if (g_memset_l)
- g_memset = g_memset_l;
+ if (g_memset_l)
+ g_memset = g_memset_l;
- if (g_memmove_l)
- g_memmove = g_memmove_l;
+ if (g_memmove_l)
+ g_memmove = g_memmove_l;
- return 0;
+ return 0;
#else
- (void)g_malloc_l;
- (void)g_calloc_l;
- (void)g_realloc_l;
- (void)g_free_l;
- (void)g_memcpy_l;
- (void)g_memset_l;
- (void)g_memmove_l;
- return -1;
+ (void)g_malloc_l;
+ (void)g_calloc_l;
+ (void)g_realloc_l;
+ (void)g_free_l;
+ (void)g_memcpy_l;
+ (void)g_memset_l;
+ (void)g_memmove_l;
+ return -1;
#endif
}
diff --git a/vpx_ports/arm_cpudetect.c b/vpx_ports/arm_cpudetect.c
index 4109924cf..758115967 100644
--- a/vpx_ports/arm_cpudetect.c
+++ b/vpx_ports/arm_cpudetect.c
@@ -12,24 +12,21 @@
#include <string.h>
#include "arm.h"
-static int arm_cpu_env_flags(int *flags)
-{
- char *env;
- env = getenv("VPX_SIMD_CAPS");
- if (env && *env)
- {
- *flags = (int)strtol(env, NULL, 0);
- return 0;
- }
- *flags = 0;
- return -1;
+static int arm_cpu_env_flags(int *flags) {
+ char *env;
+ env = getenv("VPX_SIMD_CAPS");
+ if (env && *env) {
+ *flags = (int)strtol(env, NULL, 0);
+ return 0;
+ }
+ *flags = 0;
+ return -1;
}
-static int arm_cpu_env_mask(void)
-{
- char *env;
- env = getenv("VPX_SIMD_CAPS_MASK");
- return env && *env ? (int)strtol(env, NULL, 0) : ~0;
+static int arm_cpu_env_mask(void) {
+ char *env;
+ env = getenv("VPX_SIMD_CAPS_MASK");
+ return env && *env ? (int)strtol(env, NULL, 0) : ~0;
}
@@ -39,152 +36,129 @@ static int arm_cpu_env_mask(void)
#define WIN32_EXTRA_LEAN
#include <windows.h>
-int arm_cpu_caps(void)
-{
- int flags;
- int mask;
- if (!arm_cpu_env_flags(&flags))
- {
- return flags;
- }
- mask = arm_cpu_env_mask();
- /* MSVC has no inline __asm support for ARM, but it does let you __emit
- * instructions via their assembled hex code.
- * All of these instructions should be essentially nops.
- */
+int arm_cpu_caps(void) {
+ int flags;
+ int mask;
+ if (!arm_cpu_env_flags(&flags)) {
+ return flags;
+ }
+ mask = arm_cpu_env_mask();
+ /* MSVC has no inline __asm support for ARM, but it does let you __emit
+ * instructions via their assembled hex code.
+ * All of these instructions should be essentially nops.
+ */
#if defined(HAVE_ARMV5TE)
- if (mask & HAS_EDSP)
- {
- __try
- {
- /*PLD [r13]*/
- __emit(0xF5DDF000);
- flags |= HAS_EDSP;
- }
- __except(GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION)
- {
- /*Ignore exception.*/
- }
+ if (mask & HAS_EDSP) {
+ __try {
+ /*PLD [r13]*/
+ __emit(0xF5DDF000);
+ flags |= HAS_EDSP;
+ } __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) {
+ /*Ignore exception.*/
}
+ }
#if defined(HAVE_ARMV6)
- if (mask & HAS_MEDIA)
- __try
- {
- /*SHADD8 r3,r3,r3*/
- __emit(0xE6333F93);
- flags |= HAS_MEDIA;
- }
- __except(GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION)
- {
- /*Ignore exception.*/
- }
- }
+ if (mask & HAS_MEDIA)
+ __try {
+ /*SHADD8 r3,r3,r3*/
+ __emit(0xE6333F93);
+ flags |= HAS_MEDIA;
+ } __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) {
+ /*Ignore exception.*/
+ }
+}
#if defined(HAVE_ARMV7)
- if (mask & HAS_NEON)
- {
- __try
- {
- /*VORR q0,q0,q0*/
- __emit(0xF2200150);
- flags |= HAS_NEON;
- }
- __except(GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION)
- {
- /*Ignore exception.*/
- }
- }
+if (mask &HAS_NEON) {
+ __try {
+ /*VORR q0,q0,q0*/
+ __emit(0xF2200150);
+ flags |= HAS_NEON;
+ } __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) {
+ /*Ignore exception.*/
+ }
+}
#endif
#endif
#endif
- return flags & mask;
+return flags & mask;
}
#elif defined(__linux__)
#include <stdio.h>
-int arm_cpu_caps(void)
-{
- FILE *fin;
- int flags;
- int mask;
- if (!arm_cpu_env_flags(&flags))
- {
- return flags;
- }
- mask = arm_cpu_env_mask();
- /* Reading /proc/self/auxv would be easier, but that doesn't work reliably
- * on Android.
- * This also means that detection will fail in Scratchbox.
+int arm_cpu_caps(void) {
+ FILE *fin;
+ int flags;
+ int mask;
+ if (!arm_cpu_env_flags(&flags)) {
+ return flags;
+ }
+ mask = arm_cpu_env_mask();
+ /* Reading /proc/self/auxv would be easier, but that doesn't work reliably
+ * on Android.
+ * This also means that detection will fail in Scratchbox.
+ */
+ fin = fopen("/proc/cpuinfo", "r");
+ if (fin != NULL) {
+ /* 512 should be enough for anybody (it's even enough for all the flags
+ * that x86 has accumulated... so far).
*/
- fin = fopen("/proc/cpuinfo","r");
- if(fin != NULL)
- {
- /* 512 should be enough for anybody (it's even enough for all the flags
- * that x86 has accumulated... so far).
- */
- char buf[512];
- while (fgets(buf, 511, fin) != NULL)
- {
+ char buf[512];
+ while (fgets(buf, 511, fin) != NULL) {
#if defined(HAVE_ARMV5TE) || defined(HAVE_ARMV7)
- if (memcmp(buf, "Features", 8) == 0)
- {
- char *p;
+ if (memcmp(buf, "Features", 8) == 0) {
+ char *p;
#if defined(HAVE_ARMV5TE)
- p=strstr(buf, " edsp");
- if (p != NULL && (p[5] == ' ' || p[5] == '\n'))
- {
- flags |= HAS_EDSP;
- }
+ p = strstr(buf, " edsp");
+ if (p != NULL && (p[5] == ' ' || p[5] == '\n')) {
+ flags |= HAS_EDSP;
+ }
#if defined(HAVE_ARMV7)
- p = strstr(buf, " neon");
- if (p != NULL && (p[5] == ' ' || p[5] == '\n'))
- {
- flags |= HAS_NEON;
- }
+ p = strstr(buf, " neon");
+ if (p != NULL && (p[5] == ' ' || p[5] == '\n')) {
+ flags |= HAS_NEON;
+ }
#endif
#endif
- }
+ }
#endif
#if defined(HAVE_ARMV6)
- if (memcmp(buf, "CPU architecture:",17) == 0){
- int version;
- version = atoi(buf+17);
- if (version >= 6)
- {
- flags |= HAS_MEDIA;
- }
- }
-#endif
+ if (memcmp(buf, "CPU architecture:", 17) == 0) {
+ int version;
+ version = atoi(buf + 17);
+ if (version >= 6) {
+ flags |= HAS_MEDIA;
}
- fclose(fin);
+ }
+#endif
}
- return flags & mask;
+ fclose(fin);
+ }
+ return flags & mask;
}
#elif !CONFIG_RUNTIME_CPU_DETECT
-int arm_cpu_caps(void)
-{
- int flags;
- int mask;
- if (!arm_cpu_env_flags(&flags))
- {
- return flags;
- }
- mask = arm_cpu_env_mask();
+int arm_cpu_caps(void) {
+ int flags;
+ int mask;
+ if (!arm_cpu_env_flags(&flags)) {
+ return flags;
+ }
+ mask = arm_cpu_env_mask();
#if defined(HAVE_ARMV5TE)
- flags |= HAS_EDSP;
+ flags |= HAS_EDSP;
#endif
#if defined(HAVE_ARMV6)
- flags |= HAS_MEDIA;
+ flags |= HAS_MEDIA;
#endif
#if defined(HAVE_ARMV7)
- flags |= HAS_NEON;
+ flags |= HAS_NEON;
#endif
- return flags & mask;
+ return flags & mask;
}
#else
#error "--enable-runtime-cpu-detect selected, but no CPU detection method " \
- "available for your platform. Reconfigure without --enable-runtime-cpu-detect."
+"available for your platform. Reconfigure without --enable-runtime-cpu-detect."
#endif
diff --git a/vpx_ports/asm_offsets.h b/vpx_ports/asm_offsets.h
index d3b4fc706..05da24f2b 100644
--- a/vpx_ports/asm_offsets.h
+++ b/vpx_ports/asm_offsets.h
@@ -15,8 +15,8 @@
#include <stddef.h>
#define ct_assert(name,cond) \
- static void assert_##name(void) UNUSED;\
- static void assert_##name(void) {switch(0){case 0:case !!(cond):;}}
+ static void assert_##name(void) UNUSED;\
+ static void assert_##name(void) {switch(0){case 0:case !!(cond):;}}
#if INLINE_ASM
#define DEFINE(sym, val) asm("\n" #sym " EQU %0" : : "i" (val));
diff --git a/vpx_ports/mem.h b/vpx_ports/mem.h
index 9ec34fec6..c68b90862 100644
--- a/vpx_ports/mem.h
+++ b/vpx_ports/mem.h
@@ -31,8 +31,8 @@
* within the array.
*/
#define DECLARE_ALIGNED_ARRAY(a,typ,val,n)\
-typ val##_[(n)+(a)/sizeof(typ)+1];\
-typ *val = (typ*)((((intptr_t)val##_)+(a)-1)&((intptr_t)-(a)))
+ typ val##_[(n)+(a)/sizeof(typ)+1];\
+ typ *val = (typ*)((((intptr_t)val##_)+(a)-1)&((intptr_t)-(a)))
/* Indicates that the usage of the specified variable has been audited to assure
diff --git a/vpx_ports/mem_ops.h b/vpx_ports/mem_ops.h
index 0e523681d..038f293bc 100644
--- a/vpx_ports/mem_ops.h
+++ b/vpx_ports/mem_ops.h
@@ -60,88 +60,82 @@
#undef mem_get_be16
#define mem_get_be16 mem_ops_wrap_symbol(mem_get_be16)
-static unsigned MEM_VALUE_T mem_get_be16(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[0] << 8;
- val |= mem[1];
- return val;
+static unsigned MEM_VALUE_T mem_get_be16(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[0] << 8;
+ val |= mem[1];
+ return val;
}
#undef mem_get_be24
#define mem_get_be24 mem_ops_wrap_symbol(mem_get_be24)
-static unsigned MEM_VALUE_T mem_get_be24(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[0] << 16;
- val |= mem[1] << 8;
- val |= mem[2];
- return val;
+static unsigned MEM_VALUE_T mem_get_be24(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[0] << 16;
+ val |= mem[1] << 8;
+ val |= mem[2];
+ return val;
}
#undef mem_get_be32
#define mem_get_be32 mem_ops_wrap_symbol(mem_get_be32)
-static unsigned MEM_VALUE_T mem_get_be32(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[0] << 24;
- val |= mem[1] << 16;
- val |= mem[2] << 8;
- val |= mem[3];
- return val;
+static unsigned MEM_VALUE_T mem_get_be32(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[0] << 24;
+ val |= mem[1] << 16;
+ val |= mem[2] << 8;
+ val |= mem[3];
+ return val;
}
#undef mem_get_le16
#define mem_get_le16 mem_ops_wrap_symbol(mem_get_le16)
-static unsigned MEM_VALUE_T mem_get_le16(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[1] << 8;
- val |= mem[0];
- return val;
+static unsigned MEM_VALUE_T mem_get_le16(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[1] << 8;
+ val |= mem[0];
+ return val;
}
#undef mem_get_le24
#define mem_get_le24 mem_ops_wrap_symbol(mem_get_le24)
-static unsigned MEM_VALUE_T mem_get_le24(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[2] << 16;
- val |= mem[1] << 8;
- val |= mem[0];
- return val;
+static unsigned MEM_VALUE_T mem_get_le24(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[2] << 16;
+ val |= mem[1] << 8;
+ val |= mem[0];
+ return val;
}
#undef mem_get_le32
#define mem_get_le32 mem_ops_wrap_symbol(mem_get_le32)
-static unsigned MEM_VALUE_T mem_get_le32(const void *vmem)
-{
- unsigned MEM_VALUE_T val;
- const MAU_T *mem = (const MAU_T *)vmem;
-
- val = mem[3] << 24;
- val |= mem[2] << 16;
- val |= mem[1] << 8;
- val |= mem[0];
- return val;
+static unsigned MEM_VALUE_T mem_get_le32(const void *vmem) {
+ unsigned MEM_VALUE_T val;
+ const MAU_T *mem = (const MAU_T *)vmem;
+
+ val = mem[3] << 24;
+ val |= mem[2] << 16;
+ val |= mem[1] << 8;
+ val |= mem[0];
+ return val;
}
#define mem_get_s_generic(end,sz) \
- static signed MEM_VALUE_T mem_get_s##end##sz(const void *vmem) {\
- const MAU_T *mem = (const MAU_T*)vmem;\
- signed MEM_VALUE_T val = mem_get_##end##sz(mem);\
- return (val << (MEM_VALUE_T_SZ_BITS - sz)) >> (MEM_VALUE_T_SZ_BITS - sz);\
- }
+ static signed MEM_VALUE_T mem_get_s##end##sz(const void *vmem) {\
+ const MAU_T *mem = (const MAU_T*)vmem;\
+ signed MEM_VALUE_T val = mem_get_##end##sz(mem);\
+ return (val << (MEM_VALUE_T_SZ_BITS - sz)) >> (MEM_VALUE_T_SZ_BITS - sz);\
+ }
#undef mem_get_sbe16
#define mem_get_sbe16 mem_ops_wrap_symbol(mem_get_sbe16)
@@ -169,66 +163,60 @@ mem_get_s_generic(le, 32);
#undef mem_put_be16
#define mem_put_be16 mem_ops_wrap_symbol(mem_put_be16)
-static void mem_put_be16(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
+static void mem_put_be16(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
- mem[0] = (val >> 8) & 0xff;
- mem[1] = (val >> 0) & 0xff;
+ mem[0] = (val >> 8) & 0xff;
+ mem[1] = (val >> 0) & 0xff;
}
#undef mem_put_be24
#define mem_put_be24 mem_ops_wrap_symbol(mem_put_be24)
-static void mem_put_be24(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
+static void mem_put_be24(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
- mem[0] = (val >> 16) & 0xff;
- mem[1] = (val >> 8) & 0xff;
- mem[2] = (val >> 0) & 0xff;
+ mem[0] = (val >> 16) & 0xff;
+ mem[1] = (val >> 8) & 0xff;
+ mem[2] = (val >> 0) & 0xff;
}
#undef mem_put_be32
#define mem_put_be32 mem_ops_wrap_symbol(mem_put_be32)
-static void mem_put_be32(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
-
- mem[0] = (val >> 24) & 0xff;
- mem[1] = (val >> 16) & 0xff;
- mem[2] = (val >> 8) & 0xff;
- mem[3] = (val >> 0) & 0xff;
+static void mem_put_be32(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
+
+ mem[0] = (val >> 24) & 0xff;
+ mem[1] = (val >> 16) & 0xff;
+ mem[2] = (val >> 8) & 0xff;
+ mem[3] = (val >> 0) & 0xff;
}
#undef mem_put_le16
#define mem_put_le16 mem_ops_wrap_symbol(mem_put_le16)
-static void mem_put_le16(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
+static void mem_put_le16(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
- mem[0] = (val >> 0) & 0xff;
- mem[1] = (val >> 8) & 0xff;
+ mem[0] = (val >> 0) & 0xff;
+ mem[1] = (val >> 8) & 0xff;
}
#undef mem_put_le24
#define mem_put_le24 mem_ops_wrap_symbol(mem_put_le24)
-static void mem_put_le24(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
+static void mem_put_le24(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
- mem[0] = (val >> 0) & 0xff;
- mem[1] = (val >> 8) & 0xff;
- mem[2] = (val >> 16) & 0xff;
+ mem[0] = (val >> 0) & 0xff;
+ mem[1] = (val >> 8) & 0xff;
+ mem[2] = (val >> 16) & 0xff;
}
#undef mem_put_le32
#define mem_put_le32 mem_ops_wrap_symbol(mem_put_le32)
-static void mem_put_le32(void *vmem, MEM_VALUE_T val)
-{
- MAU_T *mem = (MAU_T *)vmem;
-
- mem[0] = (val >> 0) & 0xff;
- mem[1] = (val >> 8) & 0xff;
- mem[2] = (val >> 16) & 0xff;
- mem[3] = (val >> 24) & 0xff;
+static void mem_put_le32(void *vmem, MEM_VALUE_T val) {
+ MAU_T *mem = (MAU_T *)vmem;
+
+ mem[0] = (val >> 0) & 0xff;
+ mem[1] = (val >> 8) & 0xff;
+ mem[2] = (val >> 16) & 0xff;
+ mem[3] = (val >> 24) & 0xff;
}
diff --git a/vpx_ports/mem_ops_aligned.h b/vpx_ports/mem_ops_aligned.h
index 82a18b2e0..de1b6d408 100644
--- a/vpx_ports/mem_ops_aligned.h
+++ b/vpx_ports/mem_ops_aligned.h
@@ -24,61 +24,61 @@
* could redefine these macros.
*/
#define swap_endian_16(val,raw) do {\
- val = ((raw>>8) & 0x00ff) \
- | ((raw<<8) & 0xff00);\
- } while(0)
+ val = ((raw>>8) & 0x00ff) \
+ | ((raw<<8) & 0xff00);\
+ } while(0)
#define swap_endian_32(val,raw) do {\
- val = ((raw>>24) & 0x000000ff) \
- | ((raw>>8) & 0x0000ff00) \
- | ((raw<<8) & 0x00ff0000) \
- | ((raw<<24) & 0xff000000); \
- } while(0)
+ val = ((raw>>24) & 0x000000ff) \
+ | ((raw>>8) & 0x0000ff00) \
+ | ((raw<<8) & 0x00ff0000) \
+ | ((raw<<24) & 0xff000000); \
+ } while(0)
#define swap_endian_16_se(val,raw) do {\
- swap_endian_16(val,raw);\
- val = ((val << 16) >> 16);\
- } while(0)
+ swap_endian_16(val,raw);\
+ val = ((val << 16) >> 16);\
+ } while(0)
#define swap_endian_32_se(val,raw) swap_endian_32(val,raw)
#define mem_get_ne_aligned_generic(end,sz) \
- static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
- const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
- return *mem;\
- }
+ static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
+ const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
+ return *mem;\
+ }
#define mem_get_sne_aligned_generic(end,sz) \
- static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
- const int##sz##_t *mem = (const int##sz##_t *)vmem;\
- return *mem;\
- }
+ static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
+ const int##sz##_t *mem = (const int##sz##_t *)vmem;\
+ return *mem;\
+ }
#define mem_get_se_aligned_generic(end,sz) \
- static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
- const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
- unsigned MEM_VALUE_T val, raw = *mem;\
- swap_endian_##sz(val,raw);\
- return val;\
- }
+ static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
+ const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
+ unsigned MEM_VALUE_T val, raw = *mem;\
+ swap_endian_##sz(val,raw);\
+ return val;\
+ }
#define mem_get_sse_aligned_generic(end,sz) \
- static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
- const int##sz##_t *mem = (const int##sz##_t *)vmem;\
- unsigned MEM_VALUE_T val, raw = *mem;\
- swap_endian_##sz##_se(val,raw);\
- return val;\
- }
+ static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
+ const int##sz##_t *mem = (const int##sz##_t *)vmem;\
+ unsigned MEM_VALUE_T val, raw = *mem;\
+ swap_endian_##sz##_se(val,raw);\
+ return val;\
+ }
#define mem_put_ne_aligned_generic(end,sz) \
- static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
- uint##sz##_t *mem = (uint##sz##_t *)vmem;\
- *mem = (uint##sz##_t)val;\
- }
+ static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
+ uint##sz##_t *mem = (uint##sz##_t *)vmem;\
+ *mem = (uint##sz##_t)val;\
+ }
#define mem_put_se_aligned_generic(end,sz) \
- static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
- uint##sz##_t *mem = (uint##sz##_t *)vmem, raw;\
- swap_endian_##sz(raw,val);\
- *mem = (uint##sz##_t)raw;\
- }
+ static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
+ uint##sz##_t *mem = (uint##sz##_t *)vmem, raw;\
+ swap_endian_##sz(raw,val);\
+ *mem = (uint##sz##_t)raw;\
+ }
#include "config.h"
#if CONFIG_BIG_ENDIAN
diff --git a/vpx_ports/vpx_timer.h b/vpx_ports/vpx_timer.h
index c8335a0a8..ae7a9967f 100644
--- a/vpx_ports/vpx_timer.h
+++ b/vpx_ports/vpx_timer.h
@@ -31,67 +31,63 @@
/* timersub is not provided by msys at this time. */
#ifndef timersub
#define timersub(a, b, result) \
- do { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
- if ((result)->tv_usec < 0) { \
- --(result)->tv_sec; \
- (result)->tv_usec += 1000000; \
- } \
- } while (0)
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
#endif
#endif
-struct vpx_usec_timer
-{
+struct vpx_usec_timer {
#if defined(_WIN32)
- LARGE_INTEGER begin, end;
+ LARGE_INTEGER begin, end;
#else
- struct timeval begin, end;
+ struct timeval begin, end;
#endif
};
static void
-vpx_usec_timer_start(struct vpx_usec_timer *t)
-{
+vpx_usec_timer_start(struct vpx_usec_timer *t) {
#if defined(_WIN32)
- QueryPerformanceCounter(&t->begin);
+ QueryPerformanceCounter(&t->begin);
#else
- gettimeofday(&t->begin, NULL);
+ gettimeofday(&t->begin, NULL);
#endif
}
static void
-vpx_usec_timer_mark(struct vpx_usec_timer *t)
-{
+vpx_usec_timer_mark(struct vpx_usec_timer *t) {
#if defined(_WIN32)
- QueryPerformanceCounter(&t->end);
+ QueryPerformanceCounter(&t->end);
#else
- gettimeofday(&t->end, NULL);
+ gettimeofday(&t->end, NULL);
#endif
}
static long
-vpx_usec_timer_elapsed(struct vpx_usec_timer *t)
-{
+vpx_usec_timer_elapsed(struct vpx_usec_timer *t) {
#if defined(_WIN32)
- LARGE_INTEGER freq, diff;
+ LARGE_INTEGER freq, diff;
- diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
+ diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
- if (QueryPerformanceFrequency(&freq) && diff.QuadPart < freq.QuadPart)
- return (long)(diff.QuadPart * 1000000 / freq.QuadPart);
+ if (QueryPerformanceFrequency(&freq) && diff.QuadPart < freq.QuadPart)
+ return (long)(diff.QuadPart * 1000000 / freq.QuadPart);
- return 1000000;
+ return 1000000;
#else
- struct timeval diff;
+ struct timeval diff;
- timersub(&t->end, &t->begin, &diff);
- return diff.tv_sec ? 1000000 : diff.tv_usec;
+ timersub(&t->end, &t->begin, &diff);
+ return diff.tv_sec ? 1000000 : diff.tv_usec;
#endif
}
@@ -102,9 +98,8 @@ vpx_usec_timer_elapsed(struct vpx_usec_timer *t)
#define timersub(a, b, result)
#endif
-struct vpx_usec_timer
-{
- void *dummy;
+struct vpx_usec_timer {
+ void *dummy;
};
static void
@@ -114,7 +109,9 @@ static void
vpx_usec_timer_mark(struct vpx_usec_timer *t) { }
static long
-vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { return 0; }
+vpx_usec_timer_elapsed(struct vpx_usec_timer *t) {
+ return 0;
+}
#endif /* CONFIG_OS_SUPPORT */
diff --git a/vpx_ports/vpxtypes.h b/vpx_ports/vpxtypes.h
index 2ab66b14b..9dce15e33 100644
--- a/vpx_ports/vpxtypes.h
+++ b/vpx_ports/vpxtypes.h
@@ -14,7 +14,7 @@
#include "vpx_ports/config.h"
-//#include <sys/types.h>
+// #include <sys/types.h>
#ifdef _MSC_VER
# include <basetsd.h>
typedef SSIZE_T ssize_t;
@@ -112,25 +112,24 @@ typedef vpxu64 uint64_t;
/*!\ingroup basetypes
\brief Common return type*/
-typedef enum
-{
- VPX_NOT_FOUND = -404,
- VPX_BUFFER_EMPTY = -202,
- VPX_BUFFER_FULL = -201,
-
- VPX_CONNREFUSED = -102,
- VPX_TIMEDOUT = -101,
- VPX_WOULDBLOCK = -100,
-
- VPX_NET_ERROR = -9,
- VPX_INVALID_VERSION = -8,
- VPX_INPROGRESS = -7,
- VPX_NOT_SUPP = -6,
- VPX_NO_MEM = -3,
- VPX_INVALID_PARAMS = -2,
- VPX_ERROR = -1,
- VPX_OK = 0,
- VPX_DONE = 1
+typedef enum {
+ VPX_NOT_FOUND = -404,
+ VPX_BUFFER_EMPTY = -202,
+ VPX_BUFFER_FULL = -201,
+
+ VPX_CONNREFUSED = -102,
+ VPX_TIMEDOUT = -101,
+ VPX_WOULDBLOCK = -100,
+
+ VPX_NET_ERROR = -9,
+ VPX_INVALID_VERSION = -8,
+ VPX_INPROGRESS = -7,
+ VPX_NOT_SUPP = -6,
+ VPX_NO_MEM = -3,
+ VPX_INVALID_PARAMS = -2,
+ VPX_ERROR = -1,
+ VPX_OK = 0,
+ VPX_DONE = 1
} vpxsc;
#if defined(WIN32) || defined(_WIN32_WCE)
@@ -140,7 +139,7 @@ typedef enum
#elif defined(LINUX)
# define DLLIMPORT
/*visibility attribute support is available in 3.4 and later.
- see: http://gcc.gnu.org/wiki/Visibility for more info*/
+ see: http:// gcc.gnu.org/wiki/Visibility for more info*/
# if defined(__GNUC__) && ((__GNUC__<<16|(__GNUC_MINOR__&0xff)) >= (3<<16|4))
# define GCC_HASCLASSVISIBILITY
# endif /*defined(__GNUC__) && __GNUC_PREREQ(3,4)*/
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index b0130fbfe..5aeaf9d19 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -14,58 +14,57 @@
#include <stdlib.h>
#include "config.h"
-typedef enum
-{
- VPX_CPU_UNKNOWN = -1,
- VPX_CPU_AMD,
- VPX_CPU_AMD_OLD,
- VPX_CPU_CENTAUR,
- VPX_CPU_CYRIX,
- VPX_CPU_INTEL,
- VPX_CPU_NEXGEN,
- VPX_CPU_NSC,
- VPX_CPU_RISE,
- VPX_CPU_SIS,
- VPX_CPU_TRANSMETA,
- VPX_CPU_TRANSMETA_OLD,
- VPX_CPU_UMC,
- VPX_CPU_VIA,
-
- VPX_CPU_LAST
+typedef enum {
+ VPX_CPU_UNKNOWN = -1,
+ VPX_CPU_AMD,
+ VPX_CPU_AMD_OLD,
+ VPX_CPU_CENTAUR,
+ VPX_CPU_CYRIX,
+ VPX_CPU_INTEL,
+ VPX_CPU_NEXGEN,
+ VPX_CPU_NSC,
+ VPX_CPU_RISE,
+ VPX_CPU_SIS,
+ VPX_CPU_TRANSMETA,
+ VPX_CPU_TRANSMETA_OLD,
+ VPX_CPU_UMC,
+ VPX_CPU_VIA,
+
+ VPX_CPU_LAST
} vpx_cpu_t;
#if defined(__GNUC__) && __GNUC__
#if ARCH_X86_64
#define cpuid(func,ax,bx,cx,dx)\
- __asm__ __volatile__ (\
- "cpuid \n\t" \
- : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) \
- : "a" (func));
+ __asm__ __volatile__ (\
+ "cpuid \n\t" \
+ : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) \
+ : "a" (func));
#else
#define cpuid(func,ax,bx,cx,dx)\
- __asm__ __volatile__ (\
- "mov %%ebx, %%edi \n\t" \
- "cpuid \n\t" \
- "xchg %%edi, %%ebx \n\t" \
- : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \
- : "a" (func));
+ __asm__ __volatile__ (\
+ "mov %%ebx, %%edi \n\t" \
+ "cpuid \n\t" \
+ "xchg %%edi, %%ebx \n\t" \
+ : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \
+ : "a" (func));
#endif
#else
#if ARCH_X86_64
void __cpuid(int CPUInfo[4], int info_type);
#pragma intrinsic(__cpuid)
#define cpuid(func,a,b,c,d) do{\
- int regs[4];\
- __cpuid(regs,func); a=regs[0]; b=regs[1]; c=regs[2]; d=regs[3];\
- } while(0)
+ int regs[4];\
+ __cpuid(regs,func); a=regs[0]; b=regs[1]; c=regs[2]; d=regs[3];\
+ } while(0)
#else
#define cpuid(func,a,b,c,d)\
- __asm mov eax, func\
- __asm cpuid\
- __asm mov a, eax\
- __asm mov b, ebx\
- __asm mov c, ecx\
- __asm mov d, edx
+ __asm mov eax, func\
+ __asm cpuid\
+ __asm mov a, eax\
+ __asm mov b, ebx\
+ __asm mov c, ecx\
+ __asm mov d, edx
#endif
#endif
@@ -80,47 +79,46 @@ void __cpuid(int CPUInfo[4], int info_type);
#endif
static int
-x86_simd_caps(void)
-{
- unsigned int flags = 0;
- unsigned int mask = ~0;
- unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx;
- char *env;
- (void)reg_ebx;
+x86_simd_caps(void) {
+ unsigned int flags = 0;
+ unsigned int mask = ~0;
+ unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx;
+ char *env;
+ (void)reg_ebx;
- /* See if the CPU capabilities are being overridden by the environment */
- env = getenv("VPX_SIMD_CAPS");
+ /* See if the CPU capabilities are being overridden by the environment */
+ env = getenv("VPX_SIMD_CAPS");
- if (env && *env)
- return (int)strtol(env, NULL, 0);
+ if (env && *env)
+ return (int)strtol(env, NULL, 0);
- env = getenv("VPX_SIMD_CAPS_MASK");
+ env = getenv("VPX_SIMD_CAPS_MASK");
- if (env && *env)
- mask = strtol(env, NULL, 0);
+ if (env && *env)
+ mask = strtol(env, NULL, 0);
- /* Ensure that the CPUID instruction supports extended features */
- cpuid(0, reg_eax, reg_ebx, reg_ecx, reg_edx);
+ /* Ensure that the CPUID instruction supports extended features */
+ cpuid(0, reg_eax, reg_ebx, reg_ecx, reg_edx);
- if (reg_eax < 1)
- return 0;
+ if (reg_eax < 1)
+ return 0;
- /* Get the standard feature flags */
- cpuid(1, reg_eax, reg_ebx, reg_ecx, reg_edx);
+ /* Get the standard feature flags */
+ cpuid(1, reg_eax, reg_ebx, reg_ecx, reg_edx);
- if (reg_edx & BIT(23)) flags |= HAS_MMX;
+ if (reg_edx & BIT(23)) flags |= HAS_MMX;
- if (reg_edx & BIT(25)) flags |= HAS_SSE; /* aka xmm */
+ if (reg_edx & BIT(25)) flags |= HAS_SSE; /* aka xmm */
- if (reg_edx & BIT(26)) flags |= HAS_SSE2; /* aka wmt */
+ if (reg_edx & BIT(26)) flags |= HAS_SSE2; /* aka wmt */
- if (reg_ecx & BIT(0)) flags |= HAS_SSE3;
+ if (reg_ecx & BIT(0)) flags |= HAS_SSE3;
- if (reg_ecx & BIT(9)) flags |= HAS_SSSE3;
+ if (reg_ecx & BIT(9)) flags |= HAS_SSSE3;
- if (reg_ecx & BIT(19)) flags |= HAS_SSE4_1;
+ if (reg_ecx & BIT(19)) flags |= HAS_SSE4_1;
- return flags & mask;
+ return flags & mask;
}
vpx_cpu_t vpx_x86_vendor(void);
@@ -130,17 +128,16 @@ unsigned __int64 __rdtsc(void);
#pragma intrinsic(__rdtsc)
#endif
static unsigned int
-x86_readtsc(void)
-{
+x86_readtsc(void) {
#if defined(__GNUC__) && __GNUC__
- unsigned int tsc;
- __asm__ __volatile__("rdtsc\n\t":"=a"(tsc):);
- return tsc;
+ unsigned int tsc;
+ __asm__ __volatile__("rdtsc\n\t":"=a"(tsc):);
+ return tsc;
#else
#if ARCH_X86_64
- return __rdtsc();
+ return __rdtsc();
#else
- __asm rdtsc;
+ __asm rdtsc;
#endif
#endif
}
@@ -148,29 +145,27 @@ x86_readtsc(void)
#if defined(__GNUC__) && __GNUC__
#define x86_pause_hint()\
- __asm__ __volatile__ ("pause \n\t")
+ __asm__ __volatile__ ("pause \n\t")
#else
#if ARCH_X86_64
#define x86_pause_hint()\
- _mm_pause();
+ _mm_pause();
#else
#define x86_pause_hint()\
- __asm pause
+ __asm pause
#endif
#endif
#if defined(__GNUC__) && __GNUC__
static void
-x87_set_control_word(unsigned short mode)
-{
- __asm__ __volatile__("fldcw %0" : : "m"(*&mode));
+x87_set_control_word(unsigned short mode) {
+ __asm__ __volatile__("fldcw %0" : : "m"( *&mode));
}
static unsigned short
-x87_get_control_word(void)
-{
- unsigned short mode;
- __asm__ __volatile__("fstcw %0\n\t":"=m"(*&mode):);
- return mode;
+x87_get_control_word(void) {
+ unsigned short mode;
+ __asm__ __volatile__("fstcw %0\n\t":"=m"( *&mode):);
+ return mode;
}
#elif ARCH_X86_64
/* No fldcw intrinsics on Windows x64, punt to external asm */
@@ -180,25 +175,22 @@ extern unsigned short vpx_winx64_fstcw(void);
#define x87_get_control_word vpx_winx64_fstcw
#else
static void
-x87_set_control_word(unsigned short mode)
-{
- __asm { fldcw mode }
+x87_set_control_word(unsigned short mode) {
+ __asm { fldcw mode }
}
static unsigned short
-x87_get_control_word(void)
-{
- unsigned short mode;
- __asm { fstcw mode }
- return mode;
+x87_get_control_word(void) {
+ unsigned short mode;
+ __asm { fstcw mode }
+ return mode;
}
#endif
static unsigned short
-x87_set_double_precision(void)
-{
- unsigned short mode = x87_get_control_word();
- x87_set_control_word((mode&~0x300) | 0x200);
- return mode;
+x87_set_double_precision(void) {
+ unsigned short mode = x87_get_control_word();
+ x87_set_control_word((mode&~0x300) | 0x200);
+ return mode;
}
diff --git a/vpx_ports/x86_cpuid.c b/vpx_ports/x86_cpuid.c
index ce6403374..fe86cfc7b 100644
--- a/vpx_ports/x86_cpuid.c
+++ b/vpx_ports/x86_cpuid.c
@@ -11,43 +11,39 @@
#include <string.h>
#include "x86.h"
-struct cpuid_vendors
-{
- char vendor_string[12];
- vpx_cpu_t vendor_id;
+struct cpuid_vendors {
+ char vendor_string[12];
+ vpx_cpu_t vendor_id;
};
-static struct cpuid_vendors cpuid_vendor_list[VPX_CPU_LAST] =
-{
- { "AuthenticAMD", VPX_CPU_AMD },
- { "AMDisbetter!", VPX_CPU_AMD_OLD },
- { "CentaurHauls", VPX_CPU_CENTAUR },
- { "CyrixInstead", VPX_CPU_CYRIX },
- { "GenuineIntel", VPX_CPU_INTEL },
- { "NexGenDriven", VPX_CPU_NEXGEN },
- { "Geode by NSC", VPX_CPU_NSC },
- { "RiseRiseRise", VPX_CPU_RISE },
- { "SiS SiS SiS ", VPX_CPU_SIS },
- { "GenuineTMx86", VPX_CPU_TRANSMETA },
- { "TransmetaCPU", VPX_CPU_TRANSMETA_OLD },
- { "UMC UMC UMC ", VPX_CPU_UMC },
- { "VIA VIA VIA ", VPX_CPU_VIA },
+static struct cpuid_vendors cpuid_vendor_list[VPX_CPU_LAST] = {
+ { "AuthenticAMD", VPX_CPU_AMD },
+ { "AMDisbetter!", VPX_CPU_AMD_OLD },
+ { "CentaurHauls", VPX_CPU_CENTAUR },
+ { "CyrixInstead", VPX_CPU_CYRIX },
+ { "GenuineIntel", VPX_CPU_INTEL },
+ { "NexGenDriven", VPX_CPU_NEXGEN },
+ { "Geode by NSC", VPX_CPU_NSC },
+ { "RiseRiseRise", VPX_CPU_RISE },
+ { "SiS SiS SiS ", VPX_CPU_SIS },
+ { "GenuineTMx86", VPX_CPU_TRANSMETA },
+ { "TransmetaCPU", VPX_CPU_TRANSMETA_OLD },
+ { "UMC UMC UMC ", VPX_CPU_UMC },
+ { "VIA VIA VIA ", VPX_CPU_VIA },
};
-vpx_cpu_t vpx_x86_vendor(void)
-{
- unsigned int reg_eax;
- unsigned int vs[3];
- int i;
+vpx_cpu_t vpx_x86_vendor(void) {
+ unsigned int reg_eax;
+ unsigned int vs[3];
+ int i;
- /* Get the Vendor String from the CPU */
- cpuid(0, reg_eax, vs[0], vs[2], vs[1]);
+ /* Get the Vendor String from the CPU */
+ cpuid(0, reg_eax, vs[0], vs[2], vs[1]);
- for (i = 0; i < VPX_CPU_LAST; i++)
- {
- if (strncmp ((const char *)vs, cpuid_vendor_list[i].vendor_string, 12) == 0)
- return (cpuid_vendor_list[i].vendor_id);
- }
+ for (i = 0; i < VPX_CPU_LAST; i++) {
+ if (strncmp((const char *)vs, cpuid_vendor_list[i].vendor_string, 12) == 0)
+ return (cpuid_vendor_list[i].vendor_id);
+ }
- return VPX_CPU_UNKNOWN;
+ return VPX_CPU_UNKNOWN;
}
diff --git a/vpx_scale/arm/neon/yv12extend_arm.c b/vpx_scale/arm/neon/yv12extend_arm.c
index d7a8289a9..94f499cf7 100644
--- a/vpx_scale/arm/neon/yv12extend_arm.c
+++ b/vpx_scale/arm/neon/yv12extend_arm.c
@@ -16,10 +16,9 @@
void vp8_yv12_copy_frame_func_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
void
-vp8_yv12_copy_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
-{
- vp8_yv12_copy_frame_func_neon(src_ybc, dst_ybc);
- //printf("Border:%d; plane_stride:%d; plane_height:%d; plane_width:%d\n",dst_ybc->border,dst_ybc->y_stride,dst_ybc->y_height,dst_ybc->y_width);
+vp8_yv12_copy_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc) {
+ vp8_yv12_copy_frame_func_neon(src_ybc, dst_ybc);
+ // printf("Border:%d; plane_stride:%d; plane_height:%d; plane_width:%d\n",dst_ybc->border,dst_ybc->y_stride,dst_ybc->y_height,dst_ybc->y_width);
- vp8_yv12_extend_frame_borders_ptr(dst_ybc);
+ vp8_yv12_extend_frame_borders_ptr(dst_ybc);
}
diff --git a/vpx_scale/arm/scalesystemdependent.c b/vpx_scale/arm/scalesystemdependent.c
index fee76fff7..5c19d61d9 100644
--- a/vpx_scale/arm/scalesystemdependent.c
+++ b/vpx_scale/arm/scalesystemdependent.c
@@ -46,51 +46,50 @@ extern void vp8_yv12_copy_frame_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CO
* SPECIAL NOTES : None.
*
****************************************************************************/
-void vp8_scale_machine_specific_config()
-{
+void vp8_scale_machine_specific_config() {
#if HAVE_ARMV7 && CONFIG_RUNTIME_CPU_DETECT
- int flags;
+ int flags;
#endif
- /*
- vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_armv4;
- vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_armv4;
- vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
- vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_armv4;
- vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_armv4;
- vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
- vp8_horizontal_line_3_4_scale = horizontal_line_3_4_scale_armv4;
- vp8_vertical_band_3_4_scale = vertical_band_3_4_scale_armv4;
- vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
- vp8_horizontal_line_2_3_scale = horizontal_line_2_3_scale_armv4;
- vp8_vertical_band_2_3_scale = vertical_band_2_3_scale_armv4;
- vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
- vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_armv4;
- vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_armv4;
- vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
+ /*
+ vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_armv4;
+ vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_armv4;
+ vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
+ vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_armv4;
+ vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_armv4;
+ vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
+ vp8_horizontal_line_3_4_scale = horizontal_line_3_4_scale_armv4;
+ vp8_vertical_band_3_4_scale = vertical_band_3_4_scale_armv4;
+ vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
+ vp8_horizontal_line_2_3_scale = horizontal_line_2_3_scale_armv4;
+ vp8_vertical_band_2_3_scale = vertical_band_2_3_scale_armv4;
+ vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
+ vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_armv4;
+ vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_armv4;
+ vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
- vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
- vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
- vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
- vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
- vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
- vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
- vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
- */
+ vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
+ vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
+ vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
+ vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
+ vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
+ vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
+ vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
+ */
#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders;
- vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly;
- vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame;
+ vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders;
+ vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly;
+ vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame;
#endif
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
- flags = arm_cpu_caps();
- if (flags & HAS_NEON)
+ flags = arm_cpu_caps();
+ if (flags & HAS_NEON)
#endif
- {
- vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders_neon;
- vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly_neon;
- vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame_neon;
- }
+ {
+ vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders_neon;
+ vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly_neon;
+ vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame_neon;
+ }
#endif
}
diff --git a/vpx_scale/generic/bicubic_scaler.c b/vpx_scale/generic/bicubic_scaler.c
index 4468e9d0a..c116740da 100644
--- a/vpx_scale/generic/bicubic_scaler.c
+++ b/vpx_scale/generic/bicubic_scaler.c
@@ -46,245 +46,229 @@ static float a = -0.6;
// 3 2
// C0 = a*t - a*t
//
-static short c0_fixed(unsigned int t)
-{
- // put t in Q16 notation
- unsigned short v1, v2;
-
- // Q16
- v1 = (a_i * t) >> 16;
- v1 = (v1 * t) >> 16;
-
- // Q16
- v2 = (a_i * t) >> 16;
- v2 = (v2 * t) >> 16;
- v2 = (v2 * t) >> 16;
-
- // Q12
- return -((v1 - v2) >> 4);
+static short c0_fixed(unsigned int t) {
+ // put t in Q16 notation
+ unsigned short v1, v2;
+
+ // Q16
+ v1 = (a_i * t) >> 16;
+ v1 = (v1 * t) >> 16;
+
+ // Q16
+ v2 = (a_i * t) >> 16;
+ v2 = (v2 * t) >> 16;
+ v2 = (v2 * t) >> 16;
+
+ // Q12
+ return -((v1 - v2) >> 4);
}
// 2 3
// C1 = a*t + (3-2*a)*t - (2-a)*t
//
-static short c1_fixed(unsigned int t)
-{
- unsigned short v1, v2, v3;
- unsigned short two, three;
-
- // Q16
- v1 = (a_i * t) >> 16;
-
- // Q13
- two = 2 << 13;
- v2 = two - (a_i >> 3);
- v2 = (v2 * t) >> 16;
- v2 = (v2 * t) >> 16;
- v2 = (v2 * t) >> 16;
-
- // Q13
- three = 3 << 13;
- v3 = three - (2 * (a_i >> 3));
- v3 = (v3 * t) >> 16;
- v3 = (v3 * t) >> 16;
-
- // Q12
- return (((v1 >> 3) - v2 + v3) >> 1);
+static short c1_fixed(unsigned int t) {
+ unsigned short v1, v2, v3;
+ unsigned short two, three;
+
+ // Q16
+ v1 = (a_i * t) >> 16;
+
+ // Q13
+ two = 2 << 13;
+ v2 = two - (a_i >> 3);
+ v2 = (v2 * t) >> 16;
+ v2 = (v2 * t) >> 16;
+ v2 = (v2 * t) >> 16;
+
+ // Q13
+ three = 3 << 13;
+ v3 = three - (2 * (a_i >> 3));
+ v3 = (v3 * t) >> 16;
+ v3 = (v3 * t) >> 16;
+
+ // Q12
+ return (((v1 >> 3) - v2 + v3) >> 1);
}
// 2 3
// C2 = 1 - (3-a)*t + (2-a)*t
//
-static short c2_fixed(unsigned int t)
-{
- unsigned short v1, v2, v3;
- unsigned short two, three;
-
- // Q13
- v1 = 1 << 13;
-
- // Q13
- three = 3 << 13;
- v2 = three - (a_i >> 3);
- v2 = (v2 * t) >> 16;
- v2 = (v2 * t) >> 16;
-
- // Q13
- two = 2 << 13;
- v3 = two - (a_i >> 3);
- v3 = (v3 * t) >> 16;
- v3 = (v3 * t) >> 16;
- v3 = (v3 * t) >> 16;
-
- // Q12
- return (v1 - v2 + v3) >> 1;
+static short c2_fixed(unsigned int t) {
+ unsigned short v1, v2, v3;
+ unsigned short two, three;
+
+ // Q13
+ v1 = 1 << 13;
+
+ // Q13
+ three = 3 << 13;
+ v2 = three - (a_i >> 3);
+ v2 = (v2 * t) >> 16;
+ v2 = (v2 * t) >> 16;
+
+ // Q13
+ two = 2 << 13;
+ v3 = two - (a_i >> 3);
+ v3 = (v3 * t) >> 16;
+ v3 = (v3 * t) >> 16;
+ v3 = (v3 * t) >> 16;
+
+ // Q12
+ return (v1 - v2 + v3) >> 1;
}
// 2 3
// C3 = a*t - 2*a*t + a*t
//
-static short c3_fixed(unsigned int t)
-{
- int v1, v2, v3;
+static short c3_fixed(unsigned int t) {
+ int v1, v2, v3;
- // Q16
- v1 = (a_i * t) >> 16;
+ // Q16
+ v1 = (a_i * t) >> 16;
- // Q15
- v2 = 2 * (a_i >> 1);
- v2 = (v2 * t) >> 16;
- v2 = (v2 * t) >> 16;
+ // Q15
+ v2 = 2 * (a_i >> 1);
+ v2 = (v2 * t) >> 16;
+ v2 = (v2 * t) >> 16;
- // Q16
- v3 = (a_i * t) >> 16;
- v3 = (v3 * t) >> 16;
- v3 = (v3 * t) >> 16;
+ // Q16
+ v3 = (a_i * t) >> 16;
+ v3 = (v3 * t) >> 16;
+ v3 = (v3 * t) >> 16;
- // Q12
- return ((v2 - (v1 >> 1) - (v3 >> 1)) >> 3);
+ // Q12
+ return ((v2 - (v1 >> 1) - (v3 >> 1)) >> 3);
}
#else
// 3 2
// C0 = -a*t + a*t
//
-float C0(float t)
-{
- return -a * t * t * t + a * t * t;
+float C0(float t) {
+ return -a * t * t * t + a * t * t;
}
// 2 3
// C1 = -a*t + (2*a+3)*t - (a+2)*t
//
-float C1(float t)
-{
- return -(a + 2.0f) * t * t * t + (2.0f * a + 3.0f) * t * t - a * t;
+float C1(float t) {
+ return -(a + 2.0f) * t * t * t + (2.0f * a + 3.0f) * t * t - a * t;
}
// 2 3
// C2 = 1 - (a+3)*t + (a+2)*t
//
-float C2(float t)
-{
- return (a + 2.0f) * t * t * t - (a + 3.0f) * t * t + 1.0f;
+float C2(float t) {
+ return (a + 2.0f) * t * t * t - (a + 3.0f) * t * t + 1.0f;
}
// 2 3
// C3 = a*t - 2*a*t + a*t
//
-float C3(float t)
-{
- return a * t * t * t - 2.0f * a * t * t + a * t;
+float C3(float t) {
+ return a * t * t * t - 2.0f * a * t * t + a * t;
}
#endif
#if 0
-int compare_real_fixed()
-{
- int i, errors = 0;
- float mult = 1.0 / 10000.0;
- unsigned int fixed_mult = mult * 4294967296;//65536;
- unsigned int phase_offset_int;
- float phase_offset_real;
-
- for (i = 0; i < 10000; i++)
- {
- int fixed0, fixed1, fixed2, fixed3, fixed_total;
- int real0, real1, real2, real3, real_total;
-
- phase_offset_real = (float)i * mult;
- phase_offset_int = (fixed_mult * i) >> 16;
+int compare_real_fixed() {
+ int i, errors = 0;
+ float mult = 1.0 / 10000.0;
+ unsigned int fixed_mult = mult * 4294967296;// 65536;
+ unsigned int phase_offset_int;
+ float phase_offset_real;
+
+ for (i = 0; i < 10000; i++) {
+ int fixed0, fixed1, fixed2, fixed3, fixed_total;
+ int real0, real1, real2, real3, real_total;
+
+ phase_offset_real = (float)i * mult;
+ phase_offset_int = (fixed_mult * i) >> 16;
// phase_offset_int = phase_offset_real * 65536;
- fixed0 = c0_fixed(phase_offset_int);
- real0 = C0(phase_offset_real) * 4096.0;
+ fixed0 = c0_fixed(phase_offset_int);
+ real0 = C0(phase_offset_real) * 4096.0;
- if ((abs(fixed0) > (abs(real0) + 1)) || (abs(fixed0) < (abs(real0) - 1)))
- errors++;
+ if ((abs(fixed0) > (abs(real0) + 1)) || (abs(fixed0) < (abs(real0) - 1)))
+ errors++;
- fixed1 = c1_fixed(phase_offset_int);
- real1 = C1(phase_offset_real) * 4096.0;
+ fixed1 = c1_fixed(phase_offset_int);
+ real1 = C1(phase_offset_real) * 4096.0;
- if ((abs(fixed1) > (abs(real1) + 1)) || (abs(fixed1) < (abs(real1) - 1)))
- errors++;
+ if ((abs(fixed1) > (abs(real1) + 1)) || (abs(fixed1) < (abs(real1) - 1)))
+ errors++;
- fixed2 = c2_fixed(phase_offset_int);
- real2 = C2(phase_offset_real) * 4096.0;
+ fixed2 = c2_fixed(phase_offset_int);
+ real2 = C2(phase_offset_real) * 4096.0;
- if ((abs(fixed2) > (abs(real2) + 1)) || (abs(fixed2) < (abs(real2) - 1)))
- errors++;
+ if ((abs(fixed2) > (abs(real2) + 1)) || (abs(fixed2) < (abs(real2) - 1)))
+ errors++;
- fixed3 = c3_fixed(phase_offset_int);
- real3 = C3(phase_offset_real) * 4096.0;
+ fixed3 = c3_fixed(phase_offset_int);
+ real3 = C3(phase_offset_real) * 4096.0;
- if ((abs(fixed3) > (abs(real3) + 1)) || (abs(fixed3) < (abs(real3) - 1)))
- errors++;
+ if ((abs(fixed3) > (abs(real3) + 1)) || (abs(fixed3) < (abs(real3) - 1)))
+ errors++;
- fixed_total = fixed0 + fixed1 + fixed2 + fixed3;
- real_total = real0 + real1 + real2 + real3;
+ fixed_total = fixed0 + fixed1 + fixed2 + fixed3;
+ real_total = real0 + real1 + real2 + real3;
- if ((fixed_total > 4097) || (fixed_total < 4094))
- errors ++;
+ if ((fixed_total > 4097) || (fixed_total < 4094))
+ errors++;
- if ((real_total > 4097) || (real_total < 4095))
- errors ++;
- }
+ if ((real_total > 4097) || (real_total < 4095))
+ errors++;
+ }
- return errors;
+ return errors;
}
#endif
// Find greatest common denominator between two integers. Method used here is
// slow compared to Euclid's algorithm, but does not require any division.
-int gcd(int a, int b)
-{
- // Problem with this algorithm is that if a or b = 0 this function
- // will never exit. Don't want to return 0 because any computation
- // that was based on a common denoninator and tried to reduce by
- // dividing by 0 would fail. Best solution that could be thought of
- // would to be fail by returing a 1;
- if (a <= 0 || b <= 0)
- return 1;
-
- while (a != b)
- {
- if (b > a)
- b = b - a;
- else
- {
- int tmp = a;//swap large and
- a = b; //small
- b = tmp;
- }
+int gcd(int a, int b) {
+ // Problem with this algorithm is that if a or b = 0 this function
+ // will never exit. Don't want to return 0 because any computation
+ // that was based on a common denoninator and tried to reduce by
+ // dividing by 0 would fail. Best solution that could be thought of
+ // would to be fail by returing a 1;
+ if (a <= 0 || b <= 0)
+ return 1;
+
+ while (a != b) {
+ if (b > a)
+ b = b - a;
+ else {
+ int tmp = a;// swap large and
+ a = b; // small
+ b = tmp;
}
+ }
- return b;
+ return b;
}
-void bicubic_coefficient_init()
-{
- vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
- g_first_time = 0;
+void bicubic_coefficient_init() {
+ vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
+ g_first_time = 0;
}
-void bicubic_coefficient_destroy()
-{
- if (!g_first_time)
- {
- vpx_free(g_b_scaler.l_w);
+void bicubic_coefficient_destroy() {
+ if (!g_first_time) {
+ vpx_free(g_b_scaler.l_w);
- vpx_free(g_b_scaler.l_h);
+ vpx_free(g_b_scaler.l_h);
- vpx_free(g_b_scaler.l_h_uv);
+ vpx_free(g_b_scaler.l_h_uv);
- vpx_free(g_b_scaler.c_w);
+ vpx_free(g_b_scaler.c_w);
- vpx_free(g_b_scaler.c_h);
+ vpx_free(g_b_scaler.c_h);
- vpx_free(g_b_scaler.c_h_uv);
+ vpx_free(g_b_scaler.c_h_uv);
- vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
- }
+ vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
+ }
}
// Create the coeffients that will be used for the cubic interpolation.
@@ -292,311 +276,294 @@ void bicubic_coefficient_destroy()
// regimes the phase offsets will be different. There are 4 coefficents
// for each point, two on each side. The layout is that there are the
// 4 coefficents for each phase in the array and then the next phase.
-int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int out_height)
-{
- int i;
+int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int out_height) {
+ int i;
#ifdef FIXED_POINT
- int phase_offset_int;
- unsigned int fixed_mult;
- int product_val = 0;
+ int phase_offset_int;
+ unsigned int fixed_mult;
+ int product_val = 0;
#else
- float phase_offset;
+ float phase_offset;
#endif
- int gcd_w, gcd_h, gcd_h_uv, d_w, d_h, d_h_uv;
+ int gcd_w, gcd_h, gcd_h_uv, d_w, d_h, d_h_uv;
- if (g_first_time)
- bicubic_coefficient_init();
+ if (g_first_time)
+ bicubic_coefficient_init();
- // check to see if the coefficents have already been set up correctly
- if ((in_width == g_b_scaler.in_width) && (in_height == g_b_scaler.in_height)
- && (out_width == g_b_scaler.out_width) && (out_height == g_b_scaler.out_height))
- return 0;
+ // check to see if the coefficents have already been set up correctly
+ if ((in_width == g_b_scaler.in_width) && (in_height == g_b_scaler.in_height)
+ && (out_width == g_b_scaler.out_width) && (out_height == g_b_scaler.out_height))
+ return 0;
- g_b_scaler.in_width = in_width;
- g_b_scaler.in_height = in_height;
- g_b_scaler.out_width = out_width;
- g_b_scaler.out_height = out_height;
+ g_b_scaler.in_width = in_width;
+ g_b_scaler.in_height = in_height;
+ g_b_scaler.out_width = out_width;
+ g_b_scaler.out_height = out_height;
- // Don't want to allow crazy scaling, just try and prevent a catastrophic
- // failure here. Want to fail after setting the member functions so if
- // if the scaler is called the member functions will not scale.
- if (out_width <= 0 || out_height <= 0)
- return -1;
+ // Don't want to allow crazy scaling, just try and prevent a catastrophic
+ // failure here. Want to fail after setting the member functions so if
+ // if the scaler is called the member functions will not scale.
+ if (out_width <= 0 || out_height <= 0)
+ return -1;
- // reduce in/out width and height ratios using the gcd
- gcd_w = gcd(out_width, in_width);
- gcd_h = gcd(out_height, in_height);
- gcd_h_uv = gcd(out_height, in_height / 2);
+ // reduce in/out width and height ratios using the gcd
+ gcd_w = gcd(out_width, in_width);
+ gcd_h = gcd(out_height, in_height);
+ gcd_h_uv = gcd(out_height, in_height / 2);
- // the numerator width and height are to be saved in
- // globals so they can be used during the scaling process
- // without having to be recalculated.
- g_b_scaler.nw = out_width / gcd_w;
- d_w = in_width / gcd_w;
+ // the numerator width and height are to be saved in
+ // globals so they can be used during the scaling process
+ // without having to be recalculated.
+ g_b_scaler.nw = out_width / gcd_w;
+ d_w = in_width / gcd_w;
- g_b_scaler.nh = out_height / gcd_h;
- d_h = in_height / gcd_h;
+ g_b_scaler.nh = out_height / gcd_h;
+ d_h = in_height / gcd_h;
- g_b_scaler.nh_uv = out_height / gcd_h_uv;
- d_h_uv = (in_height / 2) / gcd_h_uv;
+ g_b_scaler.nh_uv = out_height / gcd_h_uv;
+ d_h_uv = (in_height / 2) / gcd_h_uv;
- // allocate memory for the coefficents
- vpx_free(g_b_scaler.l_w);
+ // allocate memory for the coefficents
+ vpx_free(g_b_scaler.l_w);
- vpx_free(g_b_scaler.l_h);
+ vpx_free(g_b_scaler.l_h);
- vpx_free(g_b_scaler.l_h_uv);
+ vpx_free(g_b_scaler.l_h_uv);
- g_b_scaler.l_w = (short *)vpx_memalign(32, out_width * 2);
- g_b_scaler.l_h = (short *)vpx_memalign(32, out_height * 2);
- g_b_scaler.l_h_uv = (short *)vpx_memalign(32, out_height * 2);
+ g_b_scaler.l_w = (short *)vpx_memalign(32, out_width * 2);
+ g_b_scaler.l_h = (short *)vpx_memalign(32, out_height * 2);
+ g_b_scaler.l_h_uv = (short *)vpx_memalign(32, out_height * 2);
- vpx_free(g_b_scaler.c_w);
+ vpx_free(g_b_scaler.c_w);
- vpx_free(g_b_scaler.c_h);
+ vpx_free(g_b_scaler.c_h);
- vpx_free(g_b_scaler.c_h_uv);
+ vpx_free(g_b_scaler.c_h_uv);
- g_b_scaler.c_w = (short *)vpx_memalign(32, g_b_scaler.nw * 4 * 2);
- g_b_scaler.c_h = (short *)vpx_memalign(32, g_b_scaler.nh * 4 * 2);
- g_b_scaler.c_h_uv = (short *)vpx_memalign(32, g_b_scaler.nh_uv * 4 * 2);
+ g_b_scaler.c_w = (short *)vpx_memalign(32, g_b_scaler.nw * 4 * 2);
+ g_b_scaler.c_h = (short *)vpx_memalign(32, g_b_scaler.nh * 4 * 2);
+ g_b_scaler.c_h_uv = (short *)vpx_memalign(32, g_b_scaler.nh_uv * 4 * 2);
- g_b_scaler.hbuf = g_hbuf;
- g_b_scaler.hbuf_uv = g_hbuf_uv;
+ g_b_scaler.hbuf = g_hbuf;
+ g_b_scaler.hbuf_uv = g_hbuf_uv;
- // Set up polyphase filter taps. This needs to be done before
- // the scaling because of the floating point math required. The
- // coefficients are multiplied by 2^12 so that fixed point math
- // can be used in the main scaling loop.
+ // Set up polyphase filter taps. This needs to be done before
+ // the scaling because of the floating point math required. The
+ // coefficients are multiplied by 2^12 so that fixed point math
+ // can be used in the main scaling loop.
#ifdef FIXED_POINT
- fixed_mult = (1.0 / (float)g_b_scaler.nw) * 4294967296;
+ fixed_mult = (1.0 / (float)g_b_scaler.nw) * 4294967296;
- product_val = 0;
+ product_val = 0;
- for (i = 0; i < g_b_scaler.nw; i++)
- {
- if (product_val > g_b_scaler.nw)
- product_val -= g_b_scaler.nw;
+ for (i = 0; i < g_b_scaler.nw; i++) {
+ if (product_val > g_b_scaler.nw)
+ product_val -= g_b_scaler.nw;
- phase_offset_int = (fixed_mult * product_val) >> 16;
+ phase_offset_int = (fixed_mult * product_val) >> 16;
- g_b_scaler.c_w[i*4] = c3_fixed(phase_offset_int);
- g_b_scaler.c_w[i*4+1] = c2_fixed(phase_offset_int);
- g_b_scaler.c_w[i*4+2] = c1_fixed(phase_offset_int);
- g_b_scaler.c_w[i*4+3] = c0_fixed(phase_offset_int);
+ g_b_scaler.c_w[i * 4] = c3_fixed(phase_offset_int);
+ g_b_scaler.c_w[i * 4 + 1] = c2_fixed(phase_offset_int);
+ g_b_scaler.c_w[i * 4 + 2] = c1_fixed(phase_offset_int);
+ g_b_scaler.c_w[i * 4 + 3] = c0_fixed(phase_offset_int);
- product_val += d_w;
- }
+ product_val += d_w;
+ }
- fixed_mult = (1.0 / (float)g_b_scaler.nh) * 4294967296;
+ fixed_mult = (1.0 / (float)g_b_scaler.nh) * 4294967296;
- product_val = 0;
+ product_val = 0;
- for (i = 0; i < g_b_scaler.nh; i++)
- {
- if (product_val > g_b_scaler.nh)
- product_val -= g_b_scaler.nh;
+ for (i = 0; i < g_b_scaler.nh; i++) {
+ if (product_val > g_b_scaler.nh)
+ product_val -= g_b_scaler.nh;
- phase_offset_int = (fixed_mult * product_val) >> 16;
+ phase_offset_int = (fixed_mult * product_val) >> 16;
- g_b_scaler.c_h[i*4] = c0_fixed(phase_offset_int);
- g_b_scaler.c_h[i*4+1] = c1_fixed(phase_offset_int);
- g_b_scaler.c_h[i*4+2] = c2_fixed(phase_offset_int);
- g_b_scaler.c_h[i*4+3] = c3_fixed(phase_offset_int);
+ g_b_scaler.c_h[i * 4] = c0_fixed(phase_offset_int);
+ g_b_scaler.c_h[i * 4 + 1] = c1_fixed(phase_offset_int);
+ g_b_scaler.c_h[i * 4 + 2] = c2_fixed(phase_offset_int);
+ g_b_scaler.c_h[i * 4 + 3] = c3_fixed(phase_offset_int);
- product_val += d_h;
- }
+ product_val += d_h;
+ }
- fixed_mult = (1.0 / (float)g_b_scaler.nh_uv) * 4294967296;
+ fixed_mult = (1.0 / (float)g_b_scaler.nh_uv) * 4294967296;
- product_val = 0;
+ product_val = 0;
- for (i = 0; i < g_b_scaler.nh_uv; i++)
- {
- if (product_val > g_b_scaler.nh_uv)
- product_val -= g_b_scaler.nh_uv;
+ for (i = 0; i < g_b_scaler.nh_uv; i++) {
+ if (product_val > g_b_scaler.nh_uv)
+ product_val -= g_b_scaler.nh_uv;
- phase_offset_int = (fixed_mult * product_val) >> 16;
+ phase_offset_int = (fixed_mult * product_val) >> 16;
- g_b_scaler.c_h_uv[i*4] = c0_fixed(phase_offset_int);
- g_b_scaler.c_h_uv[i*4+1] = c1_fixed(phase_offset_int);
- g_b_scaler.c_h_uv[i*4+2] = c2_fixed(phase_offset_int);
- g_b_scaler.c_h_uv[i*4+3] = c3_fixed(phase_offset_int);
+ g_b_scaler.c_h_uv[i * 4] = c0_fixed(phase_offset_int);
+ g_b_scaler.c_h_uv[i * 4 + 1] = c1_fixed(phase_offset_int);
+ g_b_scaler.c_h_uv[i * 4 + 2] = c2_fixed(phase_offset_int);
+ g_b_scaler.c_h_uv[i * 4 + 3] = c3_fixed(phase_offset_int);
- product_val += d_h_uv;
- }
+ product_val += d_h_uv;
+ }
#else
- for (i = 0; i < g_nw; i++)
- {
- phase_offset = (float)((i * d_w) % g_nw) / (float)g_nw;
- g_c_w[i*4] = (C3(phase_offset) * 4096.0);
- g_c_w[i*4+1] = (C2(phase_offset) * 4096.0);
- g_c_w[i*4+2] = (C1(phase_offset) * 4096.0);
- g_c_w[i*4+3] = (C0(phase_offset) * 4096.0);
- }
-
- for (i = 0; i < g_nh; i++)
- {
- phase_offset = (float)((i * d_h) % g_nh) / (float)g_nh;
- g_c_h[i*4] = (C0(phase_offset) * 4096.0);
- g_c_h[i*4+1] = (C1(phase_offset) * 4096.0);
- g_c_h[i*4+2] = (C2(phase_offset) * 4096.0);
- g_c_h[i*4+3] = (C3(phase_offset) * 4096.0);
- }
-
- for (i = 0; i < g_nh_uv; i++)
- {
- phase_offset = (float)((i * d_h_uv) % g_nh_uv) / (float)g_nh_uv;
- g_c_h_uv[i*4] = (C0(phase_offset) * 4096.0);
- g_c_h_uv[i*4+1] = (C1(phase_offset) * 4096.0);
- g_c_h_uv[i*4+2] = (C2(phase_offset) * 4096.0);
- g_c_h_uv[i*4+3] = (C3(phase_offset) * 4096.0);
- }
+ for (i = 0; i < g_nw; i++) {
+ phase_offset = (float)((i * d_w) % g_nw) / (float)g_nw;
+ g_c_w[i * 4] = (C3(phase_offset) * 4096.0);
+ g_c_w[i * 4 + 1] = (C2(phase_offset) * 4096.0);
+ g_c_w[i * 4 + 2] = (C1(phase_offset) * 4096.0);
+ g_c_w[i * 4 + 3] = (C0(phase_offset) * 4096.0);
+ }
+
+ for (i = 0; i < g_nh; i++) {
+ phase_offset = (float)((i * d_h) % g_nh) / (float)g_nh;
+ g_c_h[i * 4] = (C0(phase_offset) * 4096.0);
+ g_c_h[i * 4 + 1] = (C1(phase_offset) * 4096.0);
+ g_c_h[i * 4 + 2] = (C2(phase_offset) * 4096.0);
+ g_c_h[i * 4 + 3] = (C3(phase_offset) * 4096.0);
+ }
+
+ for (i = 0; i < g_nh_uv; i++) {
+ phase_offset = (float)((i * d_h_uv) % g_nh_uv) / (float)g_nh_uv;
+ g_c_h_uv[i * 4] = (C0(phase_offset) * 4096.0);
+ g_c_h_uv[i * 4 + 1] = (C1(phase_offset) * 4096.0);
+ g_c_h_uv[i * 4 + 2] = (C2(phase_offset) * 4096.0);
+ g_c_h_uv[i * 4 + 3] = (C3(phase_offset) * 4096.0);
+ }
#endif
- // Create an array that corresponds input lines to output lines.
- // This doesn't require floating point math, but it does require
- // a division and because hardware division is not present that
- // is a call.
- for (i = 0; i < out_width; i++)
- {
- g_b_scaler.l_w[i] = (i * d_w) / g_b_scaler.nw;
+ // Create an array that corresponds input lines to output lines.
+ // This doesn't require floating point math, but it does require
+ // a division and because hardware division is not present that
+ // is a call.
+ for (i = 0; i < out_width; i++) {
+ g_b_scaler.l_w[i] = (i * d_w) / g_b_scaler.nw;
- if ((g_b_scaler.l_w[i] + 2) <= in_width)
- g_b_scaler.max_usable_out_width = i;
+ if ((g_b_scaler.l_w[i] + 2) <= in_width)
+ g_b_scaler.max_usable_out_width = i;
- }
+ }
- for (i = 0; i < out_height + 1; i++)
- {
- g_b_scaler.l_h[i] = (i * d_h) / g_b_scaler.nh;
- g_b_scaler.l_h_uv[i] = (i * d_h_uv) / g_b_scaler.nh_uv;
- }
+ for (i = 0; i < out_height + 1; i++) {
+ g_b_scaler.l_h[i] = (i * d_h) / g_b_scaler.nh;
+ g_b_scaler.l_h_uv[i] = (i * d_h_uv) / g_b_scaler.nh_uv;
+ }
- return 0;
+ return 0;
}
int bicubic_scale(int in_width, int in_height, int in_stride,
int out_width, int out_height, int out_stride,
- unsigned char *input_image, unsigned char *output_image)
-{
- short *RESTRICT l_w, * RESTRICT l_h;
- short *RESTRICT c_w, * RESTRICT c_h;
- unsigned char *RESTRICT ip, * RESTRICT op;
- unsigned char *RESTRICT hbuf;
- int h, w, lw, lh;
- int temp_sum;
- int phase_offset_w, phase_offset_h;
-
- c_w = g_b_scaler.c_w;
- c_h = g_b_scaler.c_h;
-
- op = output_image;
-
- l_w = g_b_scaler.l_w;
- l_h = g_b_scaler.l_h;
-
- phase_offset_h = 0;
-
- for (h = 0; h < out_height; h++)
- {
- // select the row to work on
- lh = l_h[h];
- ip = input_image + (in_stride * lh);
-
- // vp8_filter the row vertically into an temporary buffer.
- // If the phase offset == 0 then all the multiplication
- // is going to result in the output equalling the input.
- // So instead point the temporary buffer to the input.
- // Also handle the boundry condition of not being able to
- // filter that last lines.
- if (phase_offset_h && (lh < in_height - 2))
- {
- hbuf = g_b_scaler.hbuf;
-
- for (w = 0; w < in_width; w++)
- {
- temp_sum = c_h[phase_offset_h*4+3] * ip[w - in_stride];
- temp_sum += c_h[phase_offset_h*4+2] * ip[w];
- temp_sum += c_h[phase_offset_h*4+1] * ip[w + in_stride];
- temp_sum += c_h[phase_offset_h*4] * ip[w + 2*in_stride];
-
- hbuf[w] = temp_sum >> 12;
- }
- }
- else
- hbuf = ip;
-
- // increase the phase offset for the next time around.
- if (++phase_offset_h >= g_b_scaler.nh)
- phase_offset_h = 0;
-
- // now filter and expand it horizontally into the final
- // output buffer
+ unsigned char *input_image, unsigned char *output_image) {
+ short *RESTRICT l_w, * RESTRICT l_h;
+ short *RESTRICT c_w, * RESTRICT c_h;
+ unsigned char *RESTRICT ip, * RESTRICT op;
+ unsigned char *RESTRICT hbuf;
+ int h, w, lw, lh;
+ int temp_sum;
+ int phase_offset_w, phase_offset_h;
+
+ c_w = g_b_scaler.c_w;
+ c_h = g_b_scaler.c_h;
+
+ op = output_image;
+
+ l_w = g_b_scaler.l_w;
+ l_h = g_b_scaler.l_h;
+
+ phase_offset_h = 0;
+
+ for (h = 0; h < out_height; h++) {
+ // select the row to work on
+ lh = l_h[h];
+ ip = input_image + (in_stride * lh);
+
+ // vp8_filter the row vertically into an temporary buffer.
+ // If the phase offset == 0 then all the multiplication
+ // is going to result in the output equalling the input.
+ // So instead point the temporary buffer to the input.
+ // Also handle the boundry condition of not being able to
+ // filter that last lines.
+ if (phase_offset_h && (lh < in_height - 2)) {
+ hbuf = g_b_scaler.hbuf;
+
+ for (w = 0; w < in_width; w++) {
+ temp_sum = c_h[phase_offset_h * 4 + 3] * ip[w - in_stride];
+ temp_sum += c_h[phase_offset_h * 4 + 2] * ip[w];
+ temp_sum += c_h[phase_offset_h * 4 + 1] * ip[w + in_stride];
+ temp_sum += c_h[phase_offset_h * 4] * ip[w + 2 * in_stride];
+
+ hbuf[w] = temp_sum >> 12;
+ }
+ } else
+ hbuf = ip;
+
+ // increase the phase offset for the next time around.
+ if (++phase_offset_h >= g_b_scaler.nh)
+ phase_offset_h = 0;
+
+ // now filter and expand it horizontally into the final
+ // output buffer
+ phase_offset_w = 0;
+
+ for (w = 0; w < out_width; w++) {
+ // get the index to use to expand the image
+ lw = l_w[w];
+
+ temp_sum = c_w[phase_offset_w * 4] * hbuf[lw - 1];
+ temp_sum += c_w[phase_offset_w * 4 + 1] * hbuf[lw];
+ temp_sum += c_w[phase_offset_w * 4 + 2] * hbuf[lw + 1];
+ temp_sum += c_w[phase_offset_w * 4 + 3] * hbuf[lw + 2];
+ temp_sum = temp_sum >> 12;
+
+ if (++phase_offset_w >= g_b_scaler.nw)
phase_offset_w = 0;
- for (w = 0; w < out_width; w++)
- {
- // get the index to use to expand the image
- lw = l_w[w];
-
- temp_sum = c_w[phase_offset_w*4] * hbuf[lw - 1];
- temp_sum += c_w[phase_offset_w*4+1] * hbuf[lw];
- temp_sum += c_w[phase_offset_w*4+2] * hbuf[lw + 1];
- temp_sum += c_w[phase_offset_w*4+3] * hbuf[lw + 2];
- temp_sum = temp_sum >> 12;
+ // boundry conditions
+ if ((lw + 2) >= in_width)
+ temp_sum = hbuf[lw];
- if (++phase_offset_w >= g_b_scaler.nw)
- phase_offset_w = 0;
+ if (lw == 0)
+ temp_sum = hbuf[0];
- // boundry conditions
- if ((lw + 2) >= in_width)
- temp_sum = hbuf[lw];
-
- if (lw == 0)
- temp_sum = hbuf[0];
-
- op[w] = temp_sum;
- }
-
- op += out_stride;
+ op[w] = temp_sum;
}
- return 0;
+ op += out_stride;
+ }
+
+ return 0;
}
-void bicubic_scale_frame_reset()
-{
- g_b_scaler.out_width = 0;
- g_b_scaler.out_height = 0;
+void bicubic_scale_frame_reset() {
+ g_b_scaler.out_width = 0;
+ g_b_scaler.out_height = 0;
}
void bicubic_scale_frame(YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
- int new_width, int new_height)
-{
+ int new_width, int new_height) {
- dst->y_width = new_width;
- dst->y_height = new_height;
- dst->uv_width = new_width / 2;
- dst->uv_height = new_height / 2;
+ dst->y_width = new_width;
+ dst->y_height = new_height;
+ dst->uv_width = new_width / 2;
+ dst->uv_height = new_height / 2;
- dst->y_stride = dst->y_width;
- dst->uv_stride = dst->uv_width;
+ dst->y_stride = dst->y_width;
+ dst->uv_stride = dst->uv_width;
- bicubic_scale(src->y_width, src->y_height, src->y_stride,
- new_width, new_height, dst->y_stride,
- src->y_buffer, dst->y_buffer);
+ bicubic_scale(src->y_width, src->y_height, src->y_stride,
+ new_width, new_height, dst->y_stride,
+ src->y_buffer, dst->y_buffer);
- bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
- new_width / 2, new_height / 2, dst->uv_stride,
- src->u_buffer, dst->u_buffer);
+ bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
+ new_width / 2, new_height / 2, dst->uv_stride,
+ src->u_buffer, dst->u_buffer);
- bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
- new_width / 2, new_height / 2, dst->uv_stride,
- src->v_buffer, dst->v_buffer);
+ bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
+ new_width / 2, new_height / 2, dst->uv_stride,
+ src->v_buffer, dst->v_buffer);
}
diff --git a/vpx_scale/generic/gen_scalers.c b/vpx_scale/generic/gen_scalers.c
index b54e334cb..bb1178669 100644
--- a/vpx_scale/generic/gen_scalers.c
+++ b/vpx_scale/generic/gen_scalers.c
@@ -36,45 +36,43 @@
****************************************************************************/
void vp8cx_horizontal_line_4_5_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned i;
- unsigned int a, b, c;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width - 4; i += 4)
- {
- a = src[0];
- b = src[1];
- des [0] = (unsigned char) a;
- des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
- c = src[2] * 154;
- a = src[3];
- des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
- des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
- b = src[4];
- des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8);
-
- src += 4;
- des += 5;
- }
-
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width - 4; i += 4) {
a = src[0];
b = src[1];
- des [0] = (unsigned char)(a);
+ des [0] = (unsigned char) a;
des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
c = src[2] * 154;
a = src[3];
des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
- des [4] = (unsigned char)(a);
+ b = src[4];
+ des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8);
+
+ src += 4;
+ des += 5;
+ }
+
+ a = src[0];
+ b = src[1];
+ des [0] = (unsigned char)(a);
+ des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
+ c = src[2] * 154;
+ a = src[3];
+ des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
+ des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
+ des [4] = (unsigned char)(a);
}
@@ -97,31 +95,29 @@ void vp8cx_horizontal_line_4_5_scale_c
* the current band.
*
****************************************************************************/
-void vp8cx_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c, d;
- unsigned char *des = dest;
+void vp8cx_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c, d;
+ unsigned char *des = dest;
- for (i = 0; i < dest_width; i++)
- {
- a = des [0];
- b = des [dest_pitch];
+ for (i = 0; i < dest_width; i++) {
+ a = des [0];
+ b = des [dest_pitch];
- des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
+ des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
- c = des[dest_pitch*2] * 154;
- d = des[dest_pitch*3];
+ c = des[dest_pitch * 2] * 154;
+ d = des[dest_pitch * 3];
- des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
- des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
+ des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8);
+ des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8);
- /* First line in next band */
- a = des [dest_pitch * 5];
- des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8);
+ /* First line in next band */
+ a = des [dest_pitch * 5];
+ des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8);
- des ++;
- }
+ des++;
+ }
}
/****************************************************************************
@@ -144,30 +140,28 @@ void vp8cx_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitc
* last band.
*
****************************************************************************/
-void vp8cx_last_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c, d;
- unsigned char *des = dest;
+void vp8cx_last_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c, d;
+ unsigned char *des = dest;
- for (i = 0; i < dest_width; ++i)
- {
- a = des[0];
- b = des[dest_pitch];
+ for (i = 0; i < dest_width; ++i) {
+ a = des[0];
+ b = des[dest_pitch];
- des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
+ des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
- c = des[dest_pitch*2] * 154;
- d = des[dest_pitch*3];
+ c = des[dest_pitch * 2] * 154;
+ d = des[dest_pitch * 3];
- des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
- des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
+ des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8);
+ des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8);
- /* No other line for interplation of this line, so .. */
- des[dest_pitch*4] = (unsigned char) d;
+ /* No other line for interplation of this line, so .. */
+ des[dest_pitch * 4] = (unsigned char) d;
- des++;
- }
+ des++;
+ }
}
/****************************************************************************
@@ -192,38 +186,36 @@ void vp8cx_last_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest
****************************************************************************/
void vp8cx_horizontal_line_2_3_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width - 2; i += 2)
- {
- a = src[0];
- b = src[1];
- c = src[2];
-
- des [0] = (unsigned char)(a);
- des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
- des [2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
-
- src += 2;
- des += 3;
- }
-
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width - 2; i += 2) {
a = src[0];
b = src[1];
+ c = src[2];
+
des [0] = (unsigned char)(a);
des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
- des [2] = (unsigned char)(b);
+ des [2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
+
+ src += 2;
+ des += 3;
+ }
+
+ a = src[0];
+ b = src[1];
+ des [0] = (unsigned char)(a);
+ des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
+ des [2] = (unsigned char)(b);
}
@@ -246,22 +238,20 @@ void vp8cx_horizontal_line_2_3_scale_c
* the current band.
*
****************************************************************************/
-void vp8cx_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
-
- for (i = 0; i < dest_width; i++)
- {
- a = des [0];
- b = des [dest_pitch];
- c = des[dest_pitch*3];
- des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
- des [dest_pitch*2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
-
- des++;
- }
+void vp8cx_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+
+ for (i = 0; i < dest_width; i++) {
+ a = des [0];
+ b = des [dest_pitch];
+ c = des[dest_pitch * 3];
+ des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
+ des [dest_pitch * 2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
+
+ des++;
+ }
}
/****************************************************************************
@@ -284,21 +274,19 @@ void vp8cx_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitc
* last band.
*
****************************************************************************/
-void vp8cx_last_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b;
- unsigned char *des = dest;
-
- for (i = 0; i < dest_width; ++i)
- {
- a = des [0];
- b = des [dest_pitch];
-
- des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
- des [dest_pitch*2] = (unsigned char)(b);
- des++;
- }
+void vp8cx_last_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b;
+ unsigned char *des = dest;
+
+ for (i = 0; i < dest_width; ++i) {
+ a = des [0];
+ b = des [dest_pitch];
+
+ des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
+ des [dest_pitch * 2] = (unsigned char)(b);
+ des++;
+ }
}
/****************************************************************************
@@ -323,47 +311,45 @@ void vp8cx_last_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest
****************************************************************************/
void vp8cx_horizontal_line_3_5_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width - 3; i += 3)
- {
- a = src[0];
- b = src[1];
- des [0] = (unsigned char)(a);
- des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
-
- c = src[2] ;
- des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
- des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
-
- a = src[3];
- des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
-
- src += 3;
- des += 5;
- }
-
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width - 3; i += 3) {
a = src[0];
b = src[1];
des [0] = (unsigned char)(a);
-
des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
- c = src[2] ;
+
+ c = src[2];
des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
- des [4] = (unsigned char)(c);
+ a = src[3];
+ des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
+
+ src += 3;
+ des += 5;
+ }
+
+ a = src[0];
+ b = src[1];
+ des [0] = (unsigned char)(a);
+
+ des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
+ c = src[2];
+ des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
+ des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
+
+ des [4] = (unsigned char)(c);
}
/****************************************************************************
@@ -385,28 +371,26 @@ void vp8cx_horizontal_line_3_5_scale_c
* the current band.
*
****************************************************************************/
-void vp8cx_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
-
- for (i = 0; i < dest_width; i++)
- {
- a = des [0];
- b = des [dest_pitch];
- des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
-
- c = des[dest_pitch*2];
- des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
- des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
-
- /* First line in next band... */
- a = des [dest_pitch * 5];
- des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
-
- des++;
- }
+void vp8cx_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+
+ for (i = 0; i < dest_width; i++) {
+ a = des [0];
+ b = des [dest_pitch];
+ des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
+
+ c = des[dest_pitch * 2];
+ des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
+ des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
+
+ /* First line in next band... */
+ a = des [dest_pitch * 5];
+ des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
+
+ des++;
+ }
}
/****************************************************************************
@@ -429,28 +413,26 @@ void vp8cx_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitc
* last band.
*
****************************************************************************/
-void vp8cx_last_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
+void vp8cx_last_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
- for (i = 0; i < dest_width; ++i)
- {
- a = des [0];
- b = des [dest_pitch];
+ for (i = 0; i < dest_width; ++i) {
+ a = des [0];
+ b = des [dest_pitch];
- des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
+ des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
- c = des[dest_pitch*2];
- des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
- des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
+ c = des[dest_pitch * 2];
+ des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
+ des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
- /* No other line for interplation of this line, so .. */
- des [ dest_pitch * 4 ] = (unsigned char)(c) ;
+ /* No other line for interplation of this line, so .. */
+ des [ dest_pitch * 4 ] = (unsigned char)(c);
- des++;
- }
+ des++;
+ }
}
/****************************************************************************
@@ -475,44 +457,42 @@ void vp8cx_last_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest
****************************************************************************/
void vp8cx_horizontal_line_3_4_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width - 3; i += 3)
- {
- a = src[0];
- b = src[1];
- des [0] = (unsigned char)(a);
- des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
-
- c = src[2];
- des [2] = (unsigned char)((b + c + 1) >> 1);
-
- a = src[3];
- des [3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
-
- src += 3;
- des += 4;
- }
-
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width - 3; i += 3) {
a = src[0];
b = src[1];
des [0] = (unsigned char)(a);
des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
- c = src[2] ;
+ c = src[2];
des [2] = (unsigned char)((b + c + 1) >> 1);
- des [3] = (unsigned char)(c);
+
+ a = src[3];
+ des [3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
+
+ src += 3;
+ des += 4;
+ }
+
+ a = src[0];
+ b = src[1];
+ des [0] = (unsigned char)(a);
+ des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
+
+ c = src[2];
+ des [2] = (unsigned char)((b + c + 1) >> 1);
+ des [3] = (unsigned char)(c);
}
/****************************************************************************
@@ -534,27 +514,25 @@ void vp8cx_horizontal_line_3_4_scale_c
* the current band.
*
****************************************************************************/
-void vp8cx_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
-
- for (i = 0; i < dest_width; i++)
- {
- a = des [0];
- b = des [dest_pitch];
- des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
-
- c = des[dest_pitch*2];
- des [dest_pitch*2] = (unsigned char)((b + c + 1) >> 1);
-
- /* First line in next band... */
- a = des [dest_pitch*4];
- des [dest_pitch*3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
-
- des++;
- }
+void vp8cx_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
+
+ for (i = 0; i < dest_width; i++) {
+ a = des [0];
+ b = des [dest_pitch];
+ des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
+
+ c = des[dest_pitch * 2];
+ des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1);
+
+ /* First line in next band... */
+ a = des [dest_pitch * 4];
+ des [dest_pitch * 3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
+
+ des++;
+ }
}
/****************************************************************************
@@ -577,27 +555,25 @@ void vp8cx_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitc
* last band.
*
****************************************************************************/
-void vp8cx_last_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c;
- unsigned char *des = dest;
+void vp8cx_last_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c;
+ unsigned char *des = dest;
- for (i = 0; i < dest_width; ++i)
- {
- a = des [0];
- b = des [dest_pitch];
+ for (i = 0; i < dest_width; ++i) {
+ a = des [0];
+ b = des [dest_pitch];
- des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
+ des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
- c = des[dest_pitch*2];
- des [dest_pitch*2] = (unsigned char)((b + c + 1) >> 1);
+ c = des[dest_pitch * 2];
+ des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1);
- /* No other line for interplation of this line, so .. */
- des [dest_pitch*3] = (unsigned char)(c);
+ /* No other line for interplation of this line, so .. */
+ des [dest_pitch * 3] = (unsigned char)(c);
- des++;
- }
+ des++;
+ }
}
/****************************************************************************
@@ -621,32 +597,30 @@ void vp8cx_last_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest
****************************************************************************/
void vp8cx_horizontal_line_1_2_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a, b;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width - 1; i += 1)
- {
- a = src[0];
- b = src[1];
- des [0] = (unsigned char)(a);
- des [1] = (unsigned char)((a + b + 1) >> 1);
- src += 1;
- des += 2;
- }
-
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a, b;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width - 1; i += 1) {
a = src[0];
+ b = src[1];
des [0] = (unsigned char)(a);
- des [1] = (unsigned char)(a);
+ des [1] = (unsigned char)((a + b + 1) >> 1);
+ src += 1;
+ des += 2;
+ }
+
+ a = src[0];
+ des [0] = (unsigned char)(a);
+ des [1] = (unsigned char)(a);
}
/****************************************************************************
@@ -668,21 +642,19 @@ void vp8cx_horizontal_line_1_2_scale_c
* the current band.
*
****************************************************************************/
-void vp8cx_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b;
- unsigned char *des = dest;
+void vp8cx_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b;
+ unsigned char *des = dest;
- for (i = 0; i < dest_width; i++)
- {
- a = des [0];
- b = des [dest_pitch * 2];
+ for (i = 0; i < dest_width; i++) {
+ a = des [0];
+ b = des [dest_pitch * 2];
- des[dest_pitch] = (unsigned char)((a + b + 1) >> 1);
+ des[dest_pitch] = (unsigned char)((a + b + 1) >> 1);
- des++;
- }
+ des++;
+ }
}
/****************************************************************************
@@ -705,16 +677,14 @@ void vp8cx_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitc
* last band.
*
****************************************************************************/
-void vp8cx_last_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned char *des = dest;
-
- for (i = 0; i < dest_width; ++i)
- {
- des[dest_pitch] = des[0];
- des++;
- }
+void vp8cx_last_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned char *des = dest;
+
+ for (i = 0; i < dest_width; ++i) {
+ des[dest_pitch] = des[0];
+ des++;
+ }
}
@@ -742,65 +712,61 @@ void vp8cx_last_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest
****************************************************************************/
void vp8cx_horizontal_line_5_4_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned i;
- unsigned int a, b, c, d, e;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width; i += 5)
- {
- a = src[0];
- b = src[1];
- c = src[2];
- d = src[3];
- e = src[4];
-
- des[0] = (unsigned char) a;
- des[1] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
- des[2] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
- des[3] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
-
- src += 5;
- des += 4;
- }
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned i;
+ unsigned int a, b, c, d, e;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width; i += 5) {
+ a = src[0];
+ b = src[1];
+ c = src[2];
+ d = src[3];
+ e = src[4];
+
+ des[0] = (unsigned char) a;
+ des[1] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
+ des[2] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
+ des[3] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
+
+ src += 5;
+ des += 4;
+ }
}
-void vp8cx_vertical_band_5_4_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c, d, e;
- unsigned char *des = dest;
- unsigned char *src = source;
+void vp8cx_vertical_band_5_4_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c, d, e;
+ unsigned char *des = dest;
+ unsigned char *src = source;
- for (i = 0; i < dest_width; i++)
- {
+ for (i = 0; i < dest_width; i++) {
- a = src[0 * src_pitch];
- b = src[1 * src_pitch];
- c = src[2 * src_pitch];
- d = src[3 * src_pitch];
- e = src[4 * src_pitch];
+ a = src[0 * src_pitch];
+ b = src[1 * src_pitch];
+ c = src[2 * src_pitch];
+ d = src[3 * src_pitch];
+ e = src[4 * src_pitch];
- des[0 * dest_pitch] = (unsigned char) a;
- des[1 * dest_pitch] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
- des[2 * dest_pitch] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
- des[3 * dest_pitch] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
+ des[0 * dest_pitch] = (unsigned char) a;
+ des[1 * dest_pitch] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
+ des[2 * dest_pitch] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
+ des[3 * dest_pitch] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
- src ++;
- des ++;
+ src++;
+ des++;
- }
+ }
}
@@ -826,61 +792,57 @@ void vp8cx_vertical_band_5_4_scale_c(unsigned char *source, unsigned int src_pit
****************************************************************************/
void vp8cx_horizontal_line_5_3_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a, b, c, d , e;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width; i += 5)
- {
- a = src[0];
- b = src[1];
- c = src[2];
- d = src[3];
- e = src[4];
-
- des[0] = (unsigned char) a;
- des[1] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
- des[2] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
-
- src += 5;
- des += 3;
- }
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a, b, c, d, e;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width; i += 5) {
+ a = src[0];
+ b = src[1];
+ c = src[2];
+ d = src[3];
+ e = src[4];
+
+ des[0] = (unsigned char) a;
+ des[1] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
+ des[2] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
+
+ src += 5;
+ des += 3;
+ }
}
-void vp8cx_vertical_band_5_3_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- unsigned int i;
- unsigned int a, b, c, d, e;
- unsigned char *des = dest;
- unsigned char *src = source;
+void vp8cx_vertical_band_5_3_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ unsigned int i;
+ unsigned int a, b, c, d, e;
+ unsigned char *des = dest;
+ unsigned char *src = source;
- for (i = 0; i < dest_width; i++)
- {
+ for (i = 0; i < dest_width; i++) {
- a = src[0 * src_pitch];
- b = src[1 * src_pitch];
- c = src[2 * src_pitch];
- d = src[3 * src_pitch];
- e = src[4 * src_pitch];
+ a = src[0 * src_pitch];
+ b = src[1 * src_pitch];
+ c = src[2 * src_pitch];
+ d = src[3 * src_pitch];
+ e = src[4 * src_pitch];
- des[0 * dest_pitch] = (unsigned char) a;
- des[1 * dest_pitch] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
- des[2 * dest_pitch] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
+ des[0 * dest_pitch] = (unsigned char) a;
+ des[1 * dest_pitch] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
+ des[2 * dest_pitch] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
- src ++;
- des ++;
+ src++;
+ des++;
- }
+ }
}
/****************************************************************************
@@ -904,53 +866,48 @@ void vp8cx_vertical_band_5_3_scale_c(unsigned char *source, unsigned int src_pit
****************************************************************************/
void vp8cx_horizontal_line_2_1_scale_c
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- unsigned int i;
- unsigned int a;
- unsigned char *des = dest;
- const unsigned char *src = source;
-
- (void) dest_width;
-
- for (i = 0; i < source_width; i += 2)
- {
- a = src[0];
- des [0] = (unsigned char)(a);
- src += 2;
- des += 1;
- }
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ unsigned int i;
+ unsigned int a;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
+
+ (void) dest_width;
+
+ for (i = 0; i < source_width; i += 2) {
+ a = src[0];
+ des [0] = (unsigned char)(a);
+ src += 2;
+ des += 1;
+ }
}
-void vp8cx_vertical_band_2_1_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- (void) dest_pitch;
- (void) src_pitch;
- vpx_memcpy(dest, source, dest_width);
+void vp8cx_vertical_band_2_1_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ (void) dest_pitch;
+ (void) src_pitch;
+ vpx_memcpy(dest, source, dest_width);
}
-void vp8cx_vertical_band_2_1_scale_i_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- int i;
- int temp;
- int width = dest_width;
-
- (void) dest_pitch;
-
- for (i = 0; i < width; i++)
- {
- temp = 8;
- temp += source[i-(int)src_pitch] * 3;
- temp += source[i] * 10;
- temp += source[i+src_pitch] * 3;
- temp >>= 4 ;
- dest[i] = (unsigned char)(temp);
- }
+void vp8cx_vertical_band_2_1_scale_i_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ int i;
+ int temp;
+ int width = dest_width;
+
+ (void) dest_pitch;
+
+ for (i = 0; i < width; i++) {
+ temp = 8;
+ temp += source[i - (int)src_pitch] * 3;
+ temp += source[i] * 10;
+ temp += source[i + src_pitch] * 3;
+ temp >>= 4;
+ dest[i] = (unsigned char)(temp);
+ }
}
diff --git a/vpx_scale/generic/scalesystemdependent.c b/vpx_scale/generic/scalesystemdependent.c
index 92cebc4f4..b9d6de4b1 100644
--- a/vpx_scale/generic/scalesystemdependent.c
+++ b/vpx_scale/generic/scalesystemdependent.c
@@ -42,10 +42,9 @@ extern void vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG
* SPECIAL NOTES : None.
*
****************************************************************************/
-void vp8_scale_machine_specific_config()
-{
- vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders;
- vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly;
- vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame;
+void vp8_scale_machine_specific_config() {
+ vp8_yv12_extend_frame_borders_ptr = vp8_yv12_extend_frame_borders;
+ vp8_yv12_copy_frame_yonly_ptr = vp8_yv12_copy_frame_yonly;
+ vp8_yv12_copy_frame_ptr = vp8_yv12_copy_frame;
}
diff --git a/vpx_scale/generic/vpxscale.c b/vpx_scale/generic/vpxscale.c
index 13c9122f0..82485c73b 100644
--- a/vpx_scale/generic/vpxscale.c
+++ b/vpx_scale/generic/vpxscale.c
@@ -55,18 +55,17 @@ void (*vp8_horizontal_line_5_4_scale)(const unsigned char *source, unsigned int
# include "vpxscale_nofp.h"
#endif
-typedef struct
-{
- int expanded_frame_width;
- int expanded_frame_height;
+typedef struct {
+ int expanded_frame_width;
+ int expanded_frame_height;
- int HScale;
- int HRatio;
- int VScale;
- int VRatio;
+ int HScale;
+ int HRatio;
+ int VScale;
+ int VRatio;
- YV12_BUFFER_CONFIG *src_yuv_config;
- YV12_BUFFER_CONFIG *dst_yuv_config;
+ YV12_BUFFER_CONFIG *src_yuv_config;
+ YV12_BUFFER_CONFIG *dst_yuv_config;
} SCALE_VARS;
@@ -90,15 +89,14 @@ typedef struct
****************************************************************************/
static
void horizontal_line_copy(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- (void) dest_width;
-
- duck_memcpy(dest, source, source_width);
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ (void) dest_width;
+
+ duck_memcpy(dest, source, source_width);
}
/****************************************************************************
*
@@ -120,16 +118,15 @@ void horizontal_line_copy(
****************************************************************************/
static
void null_scale(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- (void) dest;
- (void) dest_pitch;
- (void) dest_width;
-
- return;
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ (void) dest;
+ (void) dest_pitch;
+ (void) dest_width;
+
+ return;
}
/****************************************************************************
@@ -157,35 +154,33 @@ void null_scale(
static
void scale1d_2t1_i
(
- const unsigned char *source,
- int source_step,
- unsigned int source_scale,
- unsigned int source_length,
- unsigned char *dest,
- int dest_step,
- unsigned int dest_scale,
- unsigned int dest_length
-)
-{
- unsigned int i, j;
- unsigned int temp;
- int source_pitch = source_step;
- (void) source_length;
- (void) source_scale;
- (void) dest_scale;
-
- source_step *= 2;
- dest[0] = source[0];
-
- for (i = dest_step, j = source_step; i < dest_length * dest_step; i += dest_step, j += source_step)
- {
- temp = 8;
- temp += 3 * source[j-source_pitch];
- temp += 10 * source[j];
- temp += 3 * source[j+source_pitch];
- temp >>= 4;
- dest[i] = (char)(temp);
- }
+ const unsigned char *source,
+ int source_step,
+ unsigned int source_scale,
+ unsigned int source_length,
+ unsigned char *dest,
+ int dest_step,
+ unsigned int dest_scale,
+ unsigned int dest_length
+) {
+ unsigned int i, j;
+ unsigned int temp;
+ int source_pitch = source_step;
+ (void) source_length;
+ (void) source_scale;
+ (void) dest_scale;
+
+ source_step *= 2;
+ dest[0] = source[0];
+
+ for (i = dest_step, j = source_step; i < dest_length * dest_step; i += dest_step, j += source_step) {
+ temp = 8;
+ temp += 3 * source[j - source_pitch];
+ temp += 10 * source[j];
+ temp += 3 * source[j + source_pitch];
+ temp >>= 4;
+ dest[i] = (char)(temp);
+ }
}
/****************************************************************************
@@ -213,27 +208,26 @@ void scale1d_2t1_i
static
void scale1d_2t1_ps
(
- const unsigned char *source,
- int source_step,
- unsigned int source_scale,
- unsigned int source_length,
- unsigned char *dest,
- int dest_step,
- unsigned int dest_scale,
- unsigned int dest_length
-)
-{
- unsigned int i, j;
-
- (void) source_length;
- (void) source_scale;
- (void) dest_scale;
-
- source_step *= 2;
- j = 0;
-
- for (i = 0; i < dest_length * dest_step; i += dest_step, j += source_step)
- dest[i] = source[j];
+ const unsigned char *source,
+ int source_step,
+ unsigned int source_scale,
+ unsigned int source_length,
+ unsigned char *dest,
+ int dest_step,
+ unsigned int dest_scale,
+ unsigned int dest_length
+) {
+ unsigned int i, j;
+
+ (void) source_length;
+ (void) source_scale;
+ (void) dest_scale;
+
+ source_step *= 2;
+ j = 0;
+
+ for (i = 0; i < dest_length * dest_step; i += dest_step, j += source_step)
+ dest[i] = source[j];
}
/****************************************************************************
*
@@ -260,45 +254,42 @@ void scale1d_2t1_ps
static
void scale1d_c
(
- const unsigned char *source,
- int source_step,
- unsigned int source_scale,
- unsigned int source_length,
- unsigned char *dest,
- int dest_step,
- unsigned int dest_scale,
- unsigned int dest_length
-)
-{
- unsigned int i;
- unsigned int round_value = dest_scale / 2;
- unsigned int left_modifier = dest_scale;
- unsigned int right_modifier = 0;
- unsigned char left_pixel = *source;
- unsigned char right_pixel = *(source + source_step);
-
- (void) source_length;
-
- /* These asserts are needed if there are boundary issues... */
- /*assert ( dest_scale > source_scale );*/
- /*assert ( (source_length-1) * dest_scale >= (dest_length-1) * source_scale );*/
-
- for (i = 0; i < dest_length * dest_step; i += dest_step)
- {
- dest[i] = (char)((left_modifier * left_pixel + right_modifier * right_pixel + round_value) / dest_scale);
-
- right_modifier += source_scale;
-
- while (right_modifier > dest_scale)
- {
- right_modifier -= dest_scale;
- source += source_step;
- left_pixel = *source;
- right_pixel = *(source + source_step);
- }
-
- left_modifier = dest_scale - right_modifier;
+ const unsigned char *source,
+ int source_step,
+ unsigned int source_scale,
+ unsigned int source_length,
+ unsigned char *dest,
+ int dest_step,
+ unsigned int dest_scale,
+ unsigned int dest_length
+) {
+ unsigned int i;
+ unsigned int round_value = dest_scale / 2;
+ unsigned int left_modifier = dest_scale;
+ unsigned int right_modifier = 0;
+ unsigned char left_pixel = *source;
+ unsigned char right_pixel = *(source + source_step);
+
+ (void) source_length;
+
+ /* These asserts are needed if there are boundary issues... */
+ /*assert ( dest_scale > source_scale );*/
+ /*assert ( (source_length-1) * dest_scale >= (dest_length-1) * source_scale );*/
+
+ for (i = 0; i < dest_length * dest_step; i += dest_step) {
+ dest[i] = (char)((left_modifier * left_pixel + right_modifier * right_pixel + round_value) / dest_scale);
+
+ right_modifier += source_scale;
+
+ while (right_modifier > dest_scale) {
+ right_modifier -= dest_scale;
+ source += source_step;
+ left_pixel = *source;
+ right_pixel = *(source + source_step);
}
+
+ left_modifier = dest_scale - right_modifier;
+ }
}
/****************************************************************************
@@ -334,246 +325,221 @@ void scale1d_c
static
void Scale2D
(
- /*const*/
- unsigned char *source,
- int source_pitch,
- unsigned int source_width,
- unsigned int source_height,
- unsigned char *dest,
- int dest_pitch,
- unsigned int dest_width,
- unsigned int dest_height,
- unsigned char *temp_area,
- unsigned char temp_area_height,
- unsigned int hscale,
- unsigned int hratio,
- unsigned int vscale,
- unsigned int vratio,
- unsigned int interlaced
-)
-{
- /*unsigned*/
- int i, j, k;
- int bands;
- int dest_band_height;
- int source_band_height;
-
- typedef void (*Scale1D)(const unsigned char * source, int source_step, unsigned int source_scale, unsigned int source_length,
- unsigned char * dest, int dest_step, unsigned int dest_scale, unsigned int dest_length);
-
- Scale1D Scale1Dv = scale1d_c;
- Scale1D Scale1Dh = scale1d_c;
-
- void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
- void (*vert_band_scale)(unsigned char *, unsigned int, unsigned char *, unsigned int, unsigned int) = NULL;
-
- int ratio_scalable = 1;
- int interpolation = 0;
-
- unsigned char *source_base; /* = (unsigned char *) ((source_pitch >= 0) ? source : (source + ((source_height-1) * source_pitch))); */
- unsigned char *line_src;
-
-
- source_base = (unsigned char *)source;
-
- if (source_pitch < 0)
- {
- int offset;
-
- offset = (source_height - 1);
- offset *= source_pitch;
-
- source_base += offset;
- }
-
- /* find out the ratio for each direction */
- switch (hratio * 10 / hscale)
- {
+ /*const*/
+ unsigned char *source,
+ int source_pitch,
+ unsigned int source_width,
+ unsigned int source_height,
+ unsigned char *dest,
+ int dest_pitch,
+ unsigned int dest_width,
+ unsigned int dest_height,
+ unsigned char *temp_area,
+ unsigned char temp_area_height,
+ unsigned int hscale,
+ unsigned int hratio,
+ unsigned int vscale,
+ unsigned int vratio,
+ unsigned int interlaced
+) {
+ /*unsigned*/
+ int i, j, k;
+ int bands;
+ int dest_band_height;
+ int source_band_height;
+
+ typedef void (*Scale1D)(const unsigned char * source, int source_step, unsigned int source_scale, unsigned int source_length,
+ unsigned char * dest, int dest_step, unsigned int dest_scale, unsigned int dest_length);
+
+ Scale1D Scale1Dv = scale1d_c;
+ Scale1D Scale1Dh = scale1d_c;
+
+ void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
+ void (*vert_band_scale)(unsigned char *, unsigned int, unsigned char *, unsigned int, unsigned int) = NULL;
+
+ int ratio_scalable = 1;
+ int interpolation = 0;
+
+ unsigned char *source_base; /* = (unsigned char *) ((source_pitch >= 0) ? source : (source + ((source_height-1) * source_pitch))); */
+ unsigned char *line_src;
+
+
+ source_base = (unsigned char *)source;
+
+ if (source_pitch < 0) {
+ int offset;
+
+ offset = (source_height - 1);
+ offset *= source_pitch;
+
+ source_base += offset;
+ }
+
+ /* find out the ratio for each direction */
+ switch (hratio * 10 / hscale) {
case 8:
- /* 4-5 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_5_4_scale;
- break;
+ /* 4-5 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_5_4_scale;
+ break;
case 6:
- /* 3-5 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_5_3_scale;
- break;
+ /* 3-5 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_5_3_scale;
+ break;
case 5:
- /* 1-2 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_2_1_scale;
- break;
+ /* 1-2 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_2_1_scale;
+ break;
default:
- /* The ratio is not acceptable now */
- /* throw("The ratio is not acceptable for now!"); */
- ratio_scalable = 0;
- break;
- }
+ /* The ratio is not acceptable now */
+ /* throw("The ratio is not acceptable for now!"); */
+ ratio_scalable = 0;
+ break;
+ }
- switch (vratio * 10 / vscale)
- {
+ switch (vratio * 10 / vscale) {
case 8:
- /* 4-5 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_5_4_scale;
- source_band_height = 5;
- dest_band_height = 4;
- break;
+ /* 4-5 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_5_4_scale;
+ source_band_height = 5;
+ dest_band_height = 4;
+ break;
case 6:
- /* 3-5 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_5_3_scale;
- source_band_height = 5;
- dest_band_height = 3;
- break;
+ /* 3-5 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_5_3_scale;
+ source_band_height = 5;
+ dest_band_height = 3;
+ break;
case 5:
- /* 1-2 Scale in vertical direction */
+ /* 1-2 Scale in vertical direction */
- if (interlaced)
- {
- /* if the content is interlaced, point sampling is used */
- vert_band_scale = vp8_vertical_band_2_1_scale;
- }
- else
- {
+ if (interlaced) {
+ /* if the content is interlaced, point sampling is used */
+ vert_band_scale = vp8_vertical_band_2_1_scale;
+ } else {
- interpolation = 1;
- /* if the content is progressive, interplo */
- vert_band_scale = vp8_vertical_band_2_1_scale_i;
+ interpolation = 1;
+ /* if the content is progressive, interplo */
+ vert_band_scale = vp8_vertical_band_2_1_scale_i;
- }
+ }
- source_band_height = 2;
- dest_band_height = 1;
- break;
+ source_band_height = 2;
+ dest_band_height = 1;
+ break;
default:
- /* The ratio is not acceptable now */
- /* throw("The ratio is not acceptable for now!"); */
- ratio_scalable = 0;
- break;
+ /* The ratio is not acceptable now */
+ /* throw("The ratio is not acceptable for now!"); */
+ ratio_scalable = 0;
+ break;
+ }
+
+ if (ratio_scalable) {
+ if (source_height == dest_height) {
+ /* for each band of the image */
+ for (k = 0; k < (int)dest_height; k++) {
+ horiz_line_scale(source, source_width, dest, dest_width);
+ source += source_pitch;
+ dest += dest_pitch;
+ }
+
+ return;
}
- if (ratio_scalable)
- {
- if (source_height == dest_height)
- {
- /* for each band of the image */
- for (k = 0; k < (int)dest_height; k++)
- {
- horiz_line_scale(source, source_width, dest, dest_width);
- source += source_pitch;
- dest += dest_pitch;
- }
-
- return;
- }
-
- if (interpolation)
- {
- if (source < source_base)
- source = source_base;
-
- horiz_line_scale(source, source_width, temp_area, dest_width);
- }
-
- for (k = 0; k < (int)(dest_height + dest_band_height - 1) / dest_band_height; k++)
- {
- /* scale one band horizontally */
- for (i = 0; i < source_band_height; i++)
- {
- /* Trap case where we could read off the base of the source buffer */
-
- line_src = (unsigned char *)source + i * source_pitch;
-
- if (line_src < source_base)
- line_src = source_base;
-
- horiz_line_scale(line_src, source_width,
- temp_area + (i + 1)*dest_pitch, dest_width);
- }
-
- /* Vertical scaling is in place */
- vert_band_scale(temp_area + dest_pitch, dest_pitch, dest, dest_pitch, dest_width);
-
- if (interpolation)
- vpx_memcpy(temp_area, temp_area + source_band_height * dest_pitch, dest_width);
-
- /* Next band... */
- source += (unsigned long) source_band_height * source_pitch;
- dest += (unsigned long) dest_band_height * dest_pitch;
- }
-
- return;
+ if (interpolation) {
+ if (source < source_base)
+ source = source_base;
+
+ horiz_line_scale(source, source_width, temp_area, dest_width);
}
- if (hscale == 2 && hratio == 1)
- Scale1Dh = scale1d_2t1_ps;
+ for (k = 0; k < (int)(dest_height + dest_band_height - 1) / dest_band_height; k++) {
+ /* scale one band horizontally */
+ for (i = 0; i < source_band_height; i++) {
+ /* Trap case where we could read off the base of the source buffer */
- if (vscale == 2 && vratio == 1)
- {
- if (interlaced)
- Scale1Dv = scale1d_2t1_ps;
- else
- Scale1Dv = scale1d_2t1_i;
- }
+ line_src = (unsigned char *)source + i * source_pitch;
- if (source_height == dest_height)
- {
- /* for each band of the image */
- for (k = 0; k < (int)dest_height; k++)
- {
- Scale1Dh(source, 1, hscale, source_width + 1, dest, 1, hratio, dest_width);
- source += source_pitch;
- dest += dest_pitch;
- }
-
- return;
- }
+ if (line_src < source_base)
+ line_src = source_base;
+
+ horiz_line_scale(line_src, source_width,
+ temp_area + (i + 1)*dest_pitch, dest_width);
+ }
+
+ /* Vertical scaling is in place */
+ vert_band_scale(temp_area + dest_pitch, dest_pitch, dest, dest_pitch, dest_width);
- if (dest_height > source_height)
- {
- dest_band_height = temp_area_height - 1;
- source_band_height = dest_band_height * source_height / dest_height;
+ if (interpolation)
+ vpx_memcpy(temp_area, temp_area + source_band_height * dest_pitch, dest_width);
+
+ /* Next band... */
+ source += (unsigned long) source_band_height * source_pitch;
+ dest += (unsigned long) dest_band_height * dest_pitch;
}
+
+ return;
+ }
+
+ if (hscale == 2 && hratio == 1)
+ Scale1Dh = scale1d_2t1_ps;
+
+ if (vscale == 2 && vratio == 1) {
+ if (interlaced)
+ Scale1Dv = scale1d_2t1_ps;
else
- {
- source_band_height = temp_area_height - 1;
- dest_band_height = source_band_height * vratio / vscale;
+ Scale1Dv = scale1d_2t1_i;
+ }
+
+ if (source_height == dest_height) {
+ /* for each band of the image */
+ for (k = 0; k < (int)dest_height; k++) {
+ Scale1Dh(source, 1, hscale, source_width + 1, dest, 1, hratio, dest_width);
+ source += source_pitch;
+ dest += dest_pitch;
}
- /* first row needs to be done so that we can stay one row ahead for vertical zoom */
- Scale1Dh(source, 1, hscale, source_width + 1, temp_area, 1, hratio, dest_width);
+ return;
+ }
+
+ if (dest_height > source_height) {
+ dest_band_height = temp_area_height - 1;
+ source_band_height = dest_band_height * source_height / dest_height;
+ } else {
+ source_band_height = temp_area_height - 1;
+ dest_band_height = source_band_height * vratio / vscale;
+ }
- /* for each band of the image */
- bands = (dest_height + dest_band_height - 1) / dest_band_height;
-
- for (k = 0; k < bands; k++)
- {
- /* scale one band horizontally */
- for (i = 1; i < source_band_height + 1; i++)
- {
- if (k * source_band_height + i < (int) source_height)
- {
- Scale1Dh(source + i * source_pitch, 1, hscale, source_width + 1,
- temp_area + i * dest_pitch, 1, hratio, dest_width);
- }
- else /* Duplicate the last row */
- {
- /* copy temp_area row 0 over from last row in the past */
- duck_memcpy(temp_area + i * dest_pitch, temp_area + (i - 1)*dest_pitch, dest_pitch);
- }
- }
-
- /* scale one band vertically */
- for (j = 0; j < (int)dest_width; j++)
- {
- Scale1Dv(&temp_area[j], dest_pitch, vscale, source_band_height + 1,
- &dest[j], dest_pitch, vratio, dest_band_height);
- }
+ /* first row needs to be done so that we can stay one row ahead for vertical zoom */
+ Scale1Dh(source, 1, hscale, source_width + 1, temp_area, 1, hratio, dest_width);
+ /* for each band of the image */
+ bands = (dest_height + dest_band_height - 1) / dest_band_height;
+
+ for (k = 0; k < bands; k++) {
+ /* scale one band horizontally */
+ for (i = 1; i < source_band_height + 1; i++) {
+ if (k * source_band_height + i < (int) source_height) {
+ Scale1Dh(source + i * source_pitch, 1, hscale, source_width + 1,
+ temp_area + i * dest_pitch, 1, hratio, dest_width);
+ } else { /* Duplicate the last row */
/* copy temp_area row 0 over from last row in the past */
- duck_memcpy(temp_area, temp_area + source_band_height * dest_pitch, dest_pitch);
+ duck_memcpy(temp_area + i * dest_pitch, temp_area + (i - 1)*dest_pitch, dest_pitch);
+ }
+ }
- /* move to the next band */
- source += source_band_height * source_pitch;
- dest += dest_band_height * dest_pitch;
+ /* scale one band vertically */
+ for (j = 0; j < (int)dest_width; j++) {
+ Scale1Dv(&temp_area[j], dest_pitch, vscale, source_band_height + 1,
+ &dest[j], dest_pitch, vratio, dest_band_height);
}
+
+ /* copy temp_area row 0 over from last row in the past */
+ duck_memcpy(temp_area, temp_area + source_band_height * dest_pitch, dest_pitch);
+
+ /* move to the next band */
+ source += source_band_height * source_pitch;
+ dest += dest_band_height * dest_pitch;
+ }
}
/****************************************************************************
@@ -602,57 +568,56 @@ void Scale2D
****************************************************************************/
void vp8_scale_frame
(
- YV12_BUFFER_CONFIG *src,
- YV12_BUFFER_CONFIG *dst,
- unsigned char *temp_area,
- unsigned char temp_height,
- unsigned int hscale,
- unsigned int hratio,
- unsigned int vscale,
- unsigned int vratio,
- unsigned int interlaced
-)
-{
- int i;
- int dw = (hscale - 1 + src->y_width * hratio) / hscale;
- int dh = (vscale - 1 + src->y_height * vratio) / vscale;
-
- /* call our internal scaling routines!! */
- Scale2D((unsigned char *) src->y_buffer, src->y_stride, src->y_width, src->y_height,
- (unsigned char *) dst->y_buffer, dst->y_stride, dw, dh,
- temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
-
- if (dw < (int)dst->y_width)
- for (i = 0; i < dh; i++)
- duck_memset(dst->y_buffer + i * dst->y_stride + dw - 1, dst->y_buffer[i*dst->y_stride+dw-2], dst->y_width - dw + 1);
-
- if (dh < (int)dst->y_height)
- for (i = dh - 1; i < (int)dst->y_height; i++)
- duck_memcpy(dst->y_buffer + i * dst->y_stride, dst->y_buffer + (dh - 2) * dst->y_stride, dst->y_width + 1);
-
- Scale2D((unsigned char *) src->u_buffer, src->uv_stride, src->uv_width, src->uv_height,
- (unsigned char *) dst->u_buffer, dst->uv_stride, dw / 2, dh / 2,
- temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
-
- if (dw / 2 < (int)dst->uv_width)
- for (i = 0; i < dst->uv_height; i++)
- duck_memset(dst->u_buffer + i * dst->uv_stride + dw / 2 - 1, dst->u_buffer[i*dst->uv_stride+dw/2-2], dst->uv_width - dw / 2 + 1);
-
- if (dh / 2 < (int)dst->uv_height)
- for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
- duck_memcpy(dst->u_buffer + i * dst->uv_stride, dst->u_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
-
- Scale2D((unsigned char *) src->v_buffer, src->uv_stride, src->uv_width, src->uv_height,
- (unsigned char *) dst->v_buffer, dst->uv_stride, dw / 2, dh / 2,
- temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
-
- if (dw / 2 < (int)dst->uv_width)
- for (i = 0; i < dst->uv_height; i++)
- duck_memset(dst->v_buffer + i * dst->uv_stride + dw / 2 - 1, dst->v_buffer[i*dst->uv_stride+dw/2-2], dst->uv_width - dw / 2 + 1);
-
- if (dh / 2 < (int) dst->uv_height)
- for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
- duck_memcpy(dst->v_buffer + i * dst->uv_stride, dst->v_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
+ YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst,
+ unsigned char *temp_area,
+ unsigned char temp_height,
+ unsigned int hscale,
+ unsigned int hratio,
+ unsigned int vscale,
+ unsigned int vratio,
+ unsigned int interlaced
+) {
+ int i;
+ int dw = (hscale - 1 + src->y_width * hratio) / hscale;
+ int dh = (vscale - 1 + src->y_height * vratio) / vscale;
+
+ /* call our internal scaling routines!! */
+ Scale2D((unsigned char *) src->y_buffer, src->y_stride, src->y_width, src->y_height,
+ (unsigned char *) dst->y_buffer, dst->y_stride, dw, dh,
+ temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
+
+ if (dw < (int)dst->y_width)
+ for (i = 0; i < dh; i++)
+ duck_memset(dst->y_buffer + i * dst->y_stride + dw - 1, dst->y_buffer[i * dst->y_stride + dw - 2], dst->y_width - dw + 1);
+
+ if (dh < (int)dst->y_height)
+ for (i = dh - 1; i < (int)dst->y_height; i++)
+ duck_memcpy(dst->y_buffer + i * dst->y_stride, dst->y_buffer + (dh - 2) * dst->y_stride, dst->y_width + 1);
+
+ Scale2D((unsigned char *) src->u_buffer, src->uv_stride, src->uv_width, src->uv_height,
+ (unsigned char *) dst->u_buffer, dst->uv_stride, dw / 2, dh / 2,
+ temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
+
+ if (dw / 2 < (int)dst->uv_width)
+ for (i = 0; i < dst->uv_height; i++)
+ duck_memset(dst->u_buffer + i * dst->uv_stride + dw / 2 - 1, dst->u_buffer[i * dst->uv_stride + dw / 2 - 2], dst->uv_width - dw / 2 + 1);
+
+ if (dh / 2 < (int)dst->uv_height)
+ for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
+ duck_memcpy(dst->u_buffer + i * dst->uv_stride, dst->u_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
+
+ Scale2D((unsigned char *) src->v_buffer, src->uv_stride, src->uv_width, src->uv_height,
+ (unsigned char *) dst->v_buffer, dst->uv_stride, dw / 2, dh / 2,
+ temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
+
+ if (dw / 2 < (int)dst->uv_width)
+ for (i = 0; i < dst->uv_height; i++)
+ duck_memset(dst->v_buffer + i * dst->uv_stride + dw / 2 - 1, dst->v_buffer[i * dst->uv_stride + dw / 2 - 2], dst->uv_width - dw / 2 + 1);
+
+ if (dh / 2 < (int) dst->uv_height)
+ for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
+ duck_memcpy(dst->v_buffer + i * dst->uv_stride, dst->v_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
}
/****************************************************************************
*
@@ -681,183 +646,177 @@ void vp8_scale_frame
static
int any_ratio_2d_scale
(
- SCALE_VARS *si,
- const unsigned char *source,
- int source_pitch,
- unsigned int source_width,
- unsigned int source_height,
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width,
- unsigned int dest_height
-)
-{
- unsigned int i, k;
- unsigned int src_band_height = 0;
- unsigned int dest_band_height = 0;
-
- /* suggested scale factors */
- int hs = si->HScale;
- int hr = si->HRatio;
- int vs = si->VScale;
- int vr = si->VRatio;
-
- /* assume the ratios are scalable instead of should be centered */
- int ratio_scalable = 1;
-
- const unsigned char *source_base = ((source_pitch >= 0) ? source : (source + ((source_height - 1) * source_pitch)));
- const unsigned char *line_src;
-
- void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
- void (*vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
- void (*last_vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
-
- (void) si;
-
- /* find out the ratio for each direction */
- switch (hr * 30 / hs)
- {
+ SCALE_VARS *si,
+ const unsigned char *source,
+ int source_pitch,
+ unsigned int source_width,
+ unsigned int source_height,
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width,
+ unsigned int dest_height
+) {
+ unsigned int i, k;
+ unsigned int src_band_height = 0;
+ unsigned int dest_band_height = 0;
+
+ /* suggested scale factors */
+ int hs = si->HScale;
+ int hr = si->HRatio;
+ int vs = si->VScale;
+ int vr = si->VRatio;
+
+ /* assume the ratios are scalable instead of should be centered */
+ int ratio_scalable = 1;
+
+ const unsigned char *source_base = ((source_pitch >= 0) ? source : (source + ((source_height - 1) * source_pitch)));
+ const unsigned char *line_src;
+
+ void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
+ void (*vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
+ void (*last_vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
+
+ (void) si;
+
+ /* find out the ratio for each direction */
+ switch (hr * 30 / hs) {
case 24:
- /* 4-5 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_4_5_scale;
- break;
+ /* 4-5 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_4_5_scale;
+ break;
case 22:
- /* 3-4 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_3_4_scale;
- break;
+ /* 3-4 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_3_4_scale;
+ break;
case 20:
- /* 4-5 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_2_3_scale;
- break;
+ /* 4-5 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_2_3_scale;
+ break;
case 18:
- /* 3-5 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_3_5_scale;
- break;
+ /* 3-5 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_3_5_scale;
+ break;
case 15:
- /* 1-2 Scale in Width direction */
- horiz_line_scale = vp8_horizontal_line_1_2_scale;
- break;
+ /* 1-2 Scale in Width direction */
+ horiz_line_scale = vp8_horizontal_line_1_2_scale;
+ break;
case 30:
- /* no scale in Width direction */
- horiz_line_scale = horizontal_line_copy;
- break;
+ /* no scale in Width direction */
+ horiz_line_scale = horizontal_line_copy;
+ break;
default:
- /* The ratio is not acceptable now */
- /* throw("The ratio is not acceptable for now!"); */
- ratio_scalable = 0;
- break;
- }
+ /* The ratio is not acceptable now */
+ /* throw("The ratio is not acceptable for now!"); */
+ ratio_scalable = 0;
+ break;
+ }
- switch (vr * 30 / vs)
- {
+ switch (vr * 30 / vs) {
case 24:
- /* 4-5 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_4_5_scale;
- last_vert_band_scale = vp8_last_vertical_band_4_5_scale;
- src_band_height = 4;
- dest_band_height = 5;
- break;
+ /* 4-5 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_4_5_scale;
+ last_vert_band_scale = vp8_last_vertical_band_4_5_scale;
+ src_band_height = 4;
+ dest_band_height = 5;
+ break;
case 22:
- /* 3-4 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_3_4_scale;
- last_vert_band_scale = vp8_last_vertical_band_3_4_scale;
- src_band_height = 3;
- dest_band_height = 4;
- break;
+ /* 3-4 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_3_4_scale;
+ last_vert_band_scale = vp8_last_vertical_band_3_4_scale;
+ src_band_height = 3;
+ dest_band_height = 4;
+ break;
case 20:
- /* 2-3 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_2_3_scale;
- last_vert_band_scale = vp8_last_vertical_band_2_3_scale;
- src_band_height = 2;
- dest_band_height = 3;
- break;
+ /* 2-3 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_2_3_scale;
+ last_vert_band_scale = vp8_last_vertical_band_2_3_scale;
+ src_band_height = 2;
+ dest_band_height = 3;
+ break;
case 18:
- /* 3-5 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_3_5_scale;
- last_vert_band_scale = vp8_last_vertical_band_3_5_scale;
- src_band_height = 3;
- dest_band_height = 5;
- break;
+ /* 3-5 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_3_5_scale;
+ last_vert_band_scale = vp8_last_vertical_band_3_5_scale;
+ src_band_height = 3;
+ dest_band_height = 5;
+ break;
case 15:
- /* 1-2 Scale in vertical direction */
- vert_band_scale = vp8_vertical_band_1_2_scale;
- last_vert_band_scale = vp8_last_vertical_band_1_2_scale;
- src_band_height = 1;
- dest_band_height = 2;
- break;
+ /* 1-2 Scale in vertical direction */
+ vert_band_scale = vp8_vertical_band_1_2_scale;
+ last_vert_band_scale = vp8_last_vertical_band_1_2_scale;
+ src_band_height = 1;
+ dest_band_height = 2;
+ break;
case 30:
- /* no scale in Width direction */
- vert_band_scale = null_scale;
- last_vert_band_scale = null_scale;
- src_band_height = 4;
- dest_band_height = 4;
- break;
+ /* no scale in Width direction */
+ vert_band_scale = null_scale;
+ last_vert_band_scale = null_scale;
+ src_band_height = 4;
+ dest_band_height = 4;
+ break;
default:
- /* The ratio is not acceptable now */
- /* throw("The ratio is not acceptable for now!"); */
- ratio_scalable = 0;
- break;
- }
+ /* The ratio is not acceptable now */
+ /* throw("The ratio is not acceptable for now!"); */
+ ratio_scalable = 0;
+ break;
+ }
- if (ratio_scalable == 0)
- return ratio_scalable;
+ if (ratio_scalable == 0)
+ return ratio_scalable;
- horiz_line_scale(source, source_width, dest, dest_width);
+ horiz_line_scale(source, source_width, dest, dest_width);
- /* except last band */
- for (k = 0; k < (dest_height + dest_band_height - 1) / dest_band_height - 1; k++)
- {
- /* scale one band horizontally */
- for (i = 1; i < src_band_height; i++)
- {
- /* Trap case where we could read off the base of the source buffer */
- line_src = source + i * source_pitch;
+ /* except last band */
+ for (k = 0; k < (dest_height + dest_band_height - 1) / dest_band_height - 1; k++) {
+ /* scale one band horizontally */
+ for (i = 1; i < src_band_height; i++) {
+ /* Trap case where we could read off the base of the source buffer */
+ line_src = source + i * source_pitch;
- if (line_src < source_base)
- line_src = source_base;
+ if (line_src < source_base)
+ line_src = source_base;
- horiz_line_scale(line_src, source_width,
- dest + i * dest_pitch, dest_width);
- }
+ horiz_line_scale(line_src, source_width,
+ dest + i * dest_pitch, dest_width);
+ }
- /* first line of next band */
- /* Trap case where we could read off the base of the source buffer */
- line_src = source + src_band_height * source_pitch;
+ /* first line of next band */
+ /* Trap case where we could read off the base of the source buffer */
+ line_src = source + src_band_height * source_pitch;
- if (line_src < source_base)
- line_src = source_base;
+ if (line_src < source_base)
+ line_src = source_base;
- horiz_line_scale(line_src, source_width,
- dest + dest_band_height * dest_pitch,
- dest_width);
+ horiz_line_scale(line_src, source_width,
+ dest + dest_band_height * dest_pitch,
+ dest_width);
- /* Vertical scaling is in place */
- vert_band_scale(dest, dest_pitch, dest_width);
+ /* Vertical scaling is in place */
+ vert_band_scale(dest, dest_pitch, dest_width);
- /* Next band... */
- source += src_band_height * source_pitch;
- dest += dest_band_height * dest_pitch;
- }
+ /* Next band... */
+ source += src_band_height * source_pitch;
+ dest += dest_band_height * dest_pitch;
+ }
- /* scale one band horizontally */
- for (i = 1; i < src_band_height; i++)
- {
- /* Trap case where we could read off the base of the source buffer */
- line_src = source + i * source_pitch;
+ /* scale one band horizontally */
+ for (i = 1; i < src_band_height; i++) {
+ /* Trap case where we could read off the base of the source buffer */
+ line_src = source + i * source_pitch;
- if (line_src < source_base)
- line_src = source_base;
+ if (line_src < source_base)
+ line_src = source_base;
- horiz_line_scale(line_src, source_width,
- dest + i * dest_pitch,
- dest_width);
- }
+ horiz_line_scale(line_src, source_width,
+ dest + i * dest_pitch,
+ dest_width);
+ }
- /* Vertical scaling is in place */
- last_vert_band_scale(dest, dest_pitch, dest_width);
+ /* Vertical scaling is in place */
+ last_vert_band_scale(dest, dest_pitch, dest_width);
- return ratio_scalable;
+ return ratio_scalable;
}
/****************************************************************************
@@ -879,70 +838,69 @@ int any_ratio_2d_scale
*
****************************************************************************/
static
-int any_ratio_frame_scale(SCALE_VARS *scale_vars, int YOffset, int UVOffset)
-{
- int i;
- int ew;
- int eh;
-
- /* suggested scale factors */
- int hs = scale_vars->HScale;
- int hr = scale_vars->HRatio;
- int vs = scale_vars->VScale;
- int vr = scale_vars->VRatio;
-
- int ratio_scalable = 1;
-
- int sw = (scale_vars->expanded_frame_width * hr + hs - 1) / hs;
- int sh = (scale_vars->expanded_frame_height * vr + vs - 1) / vs;
- int dw = scale_vars->expanded_frame_width;
- int dh = scale_vars->expanded_frame_height;
- YV12_BUFFER_CONFIG *src_yuv_config = scale_vars->src_yuv_config;
- YV12_BUFFER_CONFIG *dst_yuv_config = scale_vars->dst_yuv_config;
-
- if (hr == 3)
- ew = (sw + 2) / 3 * 3 * hs / hr;
- else
- ew = (sw + 7) / 8 * 8 * hs / hr;
-
- if (vr == 3)
- eh = (sh + 2) / 3 * 3 * vs / vr;
- else
- eh = (sh + 7) / 8 * 8 * vs / vr;
-
- ratio_scalable = any_ratio_2d_scale(scale_vars,
- (const unsigned char *)src_yuv_config->y_buffer,
- src_yuv_config->y_stride, sw, sh,
- (unsigned char *) dst_yuv_config->y_buffer + YOffset,
- dst_yuv_config->y_stride, dw, dh);
-
- for (i = 0; i < eh; i++)
- duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride + dw, 0, ew - dw);
-
- for (i = dh; i < eh; i++)
- duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride, 0, ew);
-
- if (ratio_scalable == 0)
- return ratio_scalable;
+int any_ratio_frame_scale(SCALE_VARS *scale_vars, int YOffset, int UVOffset) {
+ int i;
+ int ew;
+ int eh;
+
+ /* suggested scale factors */
+ int hs = scale_vars->HScale;
+ int hr = scale_vars->HRatio;
+ int vs = scale_vars->VScale;
+ int vr = scale_vars->VRatio;
+
+ int ratio_scalable = 1;
+
+ int sw = (scale_vars->expanded_frame_width * hr + hs - 1) / hs;
+ int sh = (scale_vars->expanded_frame_height * vr + vs - 1) / vs;
+ int dw = scale_vars->expanded_frame_width;
+ int dh = scale_vars->expanded_frame_height;
+ YV12_BUFFER_CONFIG *src_yuv_config = scale_vars->src_yuv_config;
+ YV12_BUFFER_CONFIG *dst_yuv_config = scale_vars->dst_yuv_config;
+
+ if (hr == 3)
+ ew = (sw + 2) / 3 * 3 * hs / hr;
+ else
+ ew = (sw + 7) / 8 * 8 * hs / hr;
+
+ if (vr == 3)
+ eh = (sh + 2) / 3 * 3 * vs / vr;
+ else
+ eh = (sh + 7) / 8 * 8 * vs / vr;
+
+ ratio_scalable = any_ratio_2d_scale(scale_vars,
+ (const unsigned char *)src_yuv_config->y_buffer,
+ src_yuv_config->y_stride, sw, sh,
+ (unsigned char *) dst_yuv_config->y_buffer + YOffset,
+ dst_yuv_config->y_stride, dw, dh);
+
+ for (i = 0; i < eh; i++)
+ duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride + dw, 0, ew - dw);
+
+ for (i = dh; i < eh; i++)
+ duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride, 0, ew);
+
+ if (ratio_scalable == 0)
+ return ratio_scalable;
- sw = (sw + 1) >> 1;
- sh = (sh + 1) >> 1;
- dw = (dw + 1) >> 1;
- dh = (dh + 1) >> 1;
+ sw = (sw + 1) >> 1;
+ sh = (sh + 1) >> 1;
+ dw = (dw + 1) >> 1;
+ dh = (dh + 1) >> 1;
- any_ratio_2d_scale(scale_vars,
- (const unsigned char *)src_yuv_config->u_buffer,
- src_yuv_config->y_stride / 2, sw, sh,
- (unsigned char *)dst_yuv_config->u_buffer + UVOffset,
- dst_yuv_config->uv_stride, dw, dh);
+ any_ratio_2d_scale(scale_vars,
+ (const unsigned char *)src_yuv_config->u_buffer,
+ src_yuv_config->y_stride / 2, sw, sh,
+ (unsigned char *)dst_yuv_config->u_buffer + UVOffset,
+ dst_yuv_config->uv_stride, dw, dh);
- any_ratio_2d_scale(scale_vars,
- (const unsigned char *)src_yuv_config->v_buffer,
- src_yuv_config->y_stride / 2, sw, sh,
- (unsigned char *)dst_yuv_config->v_buffer + UVOffset,
- dst_yuv_config->uv_stride, dw, dh);
+ any_ratio_2d_scale(scale_vars,
+ (const unsigned char *)src_yuv_config->v_buffer,
+ src_yuv_config->y_stride / 2, sw, sh,
+ (unsigned char *)dst_yuv_config->v_buffer + UVOffset,
+ dst_yuv_config->uv_stride, dw, dh);
- return ratio_scalable;
+ return ratio_scalable;
}
/****************************************************************************
@@ -961,52 +919,48 @@ int any_ratio_frame_scale(SCALE_VARS *scale_vars, int YOffset, int UVOffset)
*
****************************************************************************/
static void
-center_image(YV12_BUFFER_CONFIG *src_yuv_config, YV12_BUFFER_CONFIG *dst_yuv_config)
-{
- int i;
- int row_offset, col_offset;
- unsigned char *src_data_pointer;
- unsigned char *dst_data_pointer;
-
- /* center values */
- row_offset = (dst_yuv_config->y_height - src_yuv_config->y_height) / 2;
- col_offset = (dst_yuv_config->y_width - src_yuv_config->y_width) / 2;
-
- /* Y's */
- src_data_pointer = src_yuv_config->y_buffer;
- dst_data_pointer = (unsigned char *)dst_yuv_config->y_buffer + (row_offset * dst_yuv_config->y_stride) + col_offset;
-
- for (i = 0; i < src_yuv_config->y_height; i++)
- {
- duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->y_width);
- dst_data_pointer += dst_yuv_config->y_stride;
- src_data_pointer += src_yuv_config->y_stride;
- }
-
- row_offset /= 2;
- col_offset /= 2;
-
- /* U's */
- src_data_pointer = src_yuv_config->u_buffer;
- dst_data_pointer = (unsigned char *)dst_yuv_config->u_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
-
- for (i = 0; i < src_yuv_config->uv_height; i++)
- {
- duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
- dst_data_pointer += dst_yuv_config->uv_stride;
- src_data_pointer += src_yuv_config->uv_stride;
- }
-
- /* V's */
- src_data_pointer = src_yuv_config->v_buffer;
- dst_data_pointer = (unsigned char *)dst_yuv_config->v_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
-
- for (i = 0; i < src_yuv_config->uv_height; i++)
- {
- duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
- dst_data_pointer += dst_yuv_config->uv_stride;
- src_data_pointer += src_yuv_config->uv_stride;
- }
+center_image(YV12_BUFFER_CONFIG *src_yuv_config, YV12_BUFFER_CONFIG *dst_yuv_config) {
+ int i;
+ int row_offset, col_offset;
+ unsigned char *src_data_pointer;
+ unsigned char *dst_data_pointer;
+
+ /* center values */
+ row_offset = (dst_yuv_config->y_height - src_yuv_config->y_height) / 2;
+ col_offset = (dst_yuv_config->y_width - src_yuv_config->y_width) / 2;
+
+ /* Y's */
+ src_data_pointer = src_yuv_config->y_buffer;
+ dst_data_pointer = (unsigned char *)dst_yuv_config->y_buffer + (row_offset * dst_yuv_config->y_stride) + col_offset;
+
+ for (i = 0; i < src_yuv_config->y_height; i++) {
+ duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->y_width);
+ dst_data_pointer += dst_yuv_config->y_stride;
+ src_data_pointer += src_yuv_config->y_stride;
+ }
+
+ row_offset /= 2;
+ col_offset /= 2;
+
+ /* U's */
+ src_data_pointer = src_yuv_config->u_buffer;
+ dst_data_pointer = (unsigned char *)dst_yuv_config->u_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
+
+ for (i = 0; i < src_yuv_config->uv_height; i++) {
+ duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
+ dst_data_pointer += dst_yuv_config->uv_stride;
+ src_data_pointer += src_yuv_config->uv_stride;
+ }
+
+ /* V's */
+ src_data_pointer = src_yuv_config->v_buffer;
+ dst_data_pointer = (unsigned char *)dst_yuv_config->v_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
+
+ for (i = 0; i < src_yuv_config->uv_height; i++) {
+ duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
+ dst_data_pointer += dst_yuv_config->uv_stride;
+ src_data_pointer += src_yuv_config->uv_stride;
+ }
}
/****************************************************************************
@@ -1029,61 +983,58 @@ center_image(YV12_BUFFER_CONFIG *src_yuv_config, YV12_BUFFER_CONFIG *dst_yuv_con
void
vp8_yv12_scale_or_center
(
- YV12_BUFFER_CONFIG *src_yuv_config,
- YV12_BUFFER_CONFIG *dst_yuv_config,
- int expanded_frame_width,
- int expanded_frame_height,
- int scaling_mode,
- int HScale,
- int HRatio,
- int VScale,
- int VRatio
-)
-{
- /*if ( ppi->post_processing_level )
- update_umvborder ( ppi, frame_buffer );*/
-
-
- switch (scaling_mode)
- {
+ YV12_BUFFER_CONFIG *src_yuv_config,
+ YV12_BUFFER_CONFIG *dst_yuv_config,
+ int expanded_frame_width,
+ int expanded_frame_height,
+ int scaling_mode,
+ int HScale,
+ int HRatio,
+ int VScale,
+ int VRatio
+) {
+ /*if ( ppi->post_processing_level )
+ update_umvborder ( ppi, frame_buffer );*/
+
+
+ switch (scaling_mode) {
case SCALE_TO_FIT:
- case MAINTAIN_ASPECT_RATIO:
- {
- SCALE_VARS scale_vars;
- /* center values */
+ case MAINTAIN_ASPECT_RATIO: {
+ SCALE_VARS scale_vars;
+ /* center values */
#if 1
- int row = (dst_yuv_config->y_height - expanded_frame_height) / 2;
- int col = (dst_yuv_config->y_width - expanded_frame_width) / 2;
- /*int YOffset = row * dst_yuv_config->y_width + col;
- int UVOffset = (row>>1) * dst_yuv_config->uv_width + (col>>1);*/
- int YOffset = row * dst_yuv_config->y_stride + col;
- int UVOffset = (row >> 1) * dst_yuv_config->uv_stride + (col >> 1);
+ int row = (dst_yuv_config->y_height - expanded_frame_height) / 2;
+ int col = (dst_yuv_config->y_width - expanded_frame_width) / 2;
+ /*int YOffset = row * dst_yuv_config->y_width + col;
+ int UVOffset = (row>>1) * dst_yuv_config->uv_width + (col>>1);*/
+ int YOffset = row * dst_yuv_config->y_stride + col;
+ int UVOffset = (row >> 1) * dst_yuv_config->uv_stride + (col >> 1);
#else
- int row = (src_yuv_config->y_height - expanded_frame_height) / 2;
- int col = (src_yuv_config->y_width - expanded_frame_width) / 2;
- int YOffset = row * src_yuv_config->y_width + col;
- int UVOffset = (row >> 1) * src_yuv_config->uv_width + (col >> 1);
+ int row = (src_yuv_config->y_height - expanded_frame_height) / 2;
+ int col = (src_yuv_config->y_width - expanded_frame_width) / 2;
+ int YOffset = row * src_yuv_config->y_width + col;
+ int UVOffset = (row >> 1) * src_yuv_config->uv_width + (col >> 1);
#endif
- scale_vars.dst_yuv_config = dst_yuv_config;
- scale_vars.src_yuv_config = src_yuv_config;
- scale_vars.HScale = HScale;
- scale_vars.HRatio = HRatio;
- scale_vars.VScale = VScale;
- scale_vars.VRatio = VRatio;
- scale_vars.expanded_frame_width = expanded_frame_width;
- scale_vars.expanded_frame_height = expanded_frame_height;
+ scale_vars.dst_yuv_config = dst_yuv_config;
+ scale_vars.src_yuv_config = src_yuv_config;
+ scale_vars.HScale = HScale;
+ scale_vars.HRatio = HRatio;
+ scale_vars.VScale = VScale;
+ scale_vars.VRatio = VRatio;
+ scale_vars.expanded_frame_width = expanded_frame_width;
+ scale_vars.expanded_frame_height = expanded_frame_height;
- /* perform center and scale */
- any_ratio_frame_scale(&scale_vars, YOffset, UVOffset);
+ /* perform center and scale */
+ any_ratio_frame_scale(&scale_vars, YOffset, UVOffset);
- break;
+ break;
}
case CENTER:
- center_image(src_yuv_config, dst_yuv_config);
- break;
+ center_image(src_yuv_config, dst_yuv_config);
+ break;
default:
- break;
- }
+ break;
+ }
}
diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c
index eff594e2d..4cb2a4190 100644
--- a/vpx_scale/generic/yv12config.c
+++ b/vpx_scale/generic/yv12config.c
@@ -20,81 +20,73 @@
*
****************************************************************************/
int
-vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
-{
- if (ybf)
- {
- vpx_free(ybf->buffer_alloc);
-
- /* buffer_alloc isn't accessed by most functions. Rather y_buffer,
- u_buffer and v_buffer point to buffer_alloc and are used. Clear out
- all of this so that a freed pointer isn't inadvertently used */
- vpx_memset (ybf, 0, sizeof (YV12_BUFFER_CONFIG));
- }
- else
- {
- return -1;
- }
-
- return 0;
+vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
+ if (ybf) {
+ vpx_free(ybf->buffer_alloc);
+
+ /* buffer_alloc isn't accessed by most functions. Rather y_buffer,
+ u_buffer and v_buffer point to buffer_alloc and are used. Clear out
+ all of this so that a freed pointer isn't inadvertently used */
+ vpx_memset(ybf, 0, sizeof(YV12_BUFFER_CONFIG));
+ } else {
+ return -1;
+ }
+
+ return 0;
}
/****************************************************************************
*
****************************************************************************/
int
-vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border)
-{
-/*NOTE:*/
-
- if (ybf)
- {
- int y_stride = ((width + 2 * border) + 31) & ~31;
- int yplane_size = (height + 2 * border) * y_stride;
- int uv_width = width >> 1;
- int uv_height = height >> 1;
- /** There is currently a bunch of code which assumes
- * uv_stride == y_stride/2, so enforce this here. */
- int uv_stride = y_stride >> 1;
- int uvplane_size = (uv_height + border) * uv_stride;
-
- vp8_yv12_de_alloc_frame_buffer(ybf);
-
- /** Only support allocating buffers that have a height and width that
- * are multiples of 16, and a border that's a multiple of 32.
- * The border restriction is required to get 16-byte alignment of the
- * start of the chroma rows without intoducing an arbitrary gap
- * between planes, which would break the semantics of things like
- * vpx_img_set_rect(). */
- if ((width & 0xf) | (height & 0xf) | (border & 0x1f))
- return -3;
-
- ybf->y_width = width;
- ybf->y_height = height;
- ybf->y_stride = y_stride;
-
- ybf->uv_width = uv_width;
- ybf->uv_height = uv_height;
- ybf->uv_stride = uv_stride;
-
- ybf->border = border;
- ybf->frame_size = yplane_size + 2 * uvplane_size;
-
- ybf->buffer_alloc = (unsigned char *) vpx_memalign(32, ybf->frame_size);
-
- if (ybf->buffer_alloc == NULL)
- return -1;
-
- ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
- ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2 * uv_stride) + border / 2;
- ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2 * uv_stride) + border / 2;
-
- ybf->corrupted = 0; /* assume not currupted by errors */
- }
- else
- {
- return -2;
- }
-
- return 0;
+vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border) {
+ /*NOTE:*/
+
+ if (ybf) {
+ int y_stride = ((width + 2 * border) + 31) & ~31;
+ int yplane_size = (height + 2 * border) * y_stride;
+ int uv_width = width >> 1;
+ int uv_height = height >> 1;
+ /** There is currently a bunch of code which assumes
+ * uv_stride == y_stride/2, so enforce this here. */
+ int uv_stride = y_stride >> 1;
+ int uvplane_size = (uv_height + border) * uv_stride;
+
+ vp8_yv12_de_alloc_frame_buffer(ybf);
+
+ /** Only support allocating buffers that have a height and width that
+ * are multiples of 16, and a border that's a multiple of 32.
+ * The border restriction is required to get 16-byte alignment of the
+ * start of the chroma rows without intoducing an arbitrary gap
+ * between planes, which would break the semantics of things like
+ * vpx_img_set_rect(). */
+ if ((width & 0xf) | (height & 0xf) | (border & 0x1f))
+ return -3;
+
+ ybf->y_width = width;
+ ybf->y_height = height;
+ ybf->y_stride = y_stride;
+
+ ybf->uv_width = uv_width;
+ ybf->uv_height = uv_height;
+ ybf->uv_stride = uv_stride;
+
+ ybf->border = border;
+ ybf->frame_size = yplane_size + 2 * uvplane_size;
+
+ ybf->buffer_alloc = (unsigned char *) vpx_memalign(32, ybf->frame_size);
+
+ if (ybf->buffer_alloc == NULL)
+ return -1;
+
+ ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
+ ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2 * uv_stride) + border / 2;
+ ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2 * uv_stride) + border / 2;
+
+ ybf->corrupted = 0; /* assume not currupted by errors */
+ } else {
+ return -2;
+ }
+
+ return 0;
}
diff --git a/vpx_scale/generic/yv12extend.c b/vpx_scale/generic/yv12extend.c
index c087bdd78..cac8ae9b4 100644
--- a/vpx_scale/generic/yv12extend.c
+++ b/vpx_scale/generic/yv12extend.c
@@ -21,184 +21,174 @@
*
****************************************************************************/
void
-vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf)
-{
- int i;
- unsigned char *src_ptr1, *src_ptr2;
- unsigned char *dest_ptr1, *dest_ptr2;
-
- unsigned int Border;
- int plane_stride;
- int plane_height;
- int plane_width;
-
- /***********/
- /* Y Plane */
- /***********/
- Border = ybf->border;
- plane_stride = ybf->y_stride;
- plane_height = ybf->y_height;
- plane_width = ybf->y_width;
-
- /* copy the left and right most columns out */
- src_ptr1 = ybf->y_buffer;
- src_ptr2 = src_ptr1 + plane_width - 1;
- dest_ptr1 = src_ptr1 - Border;
- dest_ptr2 = src_ptr2 + 1;
-
- for (i = 0; i < plane_height; i++)
- {
- vpx_memset(dest_ptr1, src_ptr1[0], Border);
- vpx_memset(dest_ptr2, src_ptr2[0], Border);
- src_ptr1 += plane_stride;
- src_ptr2 += plane_stride;
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- /* Now copy the top and bottom source lines into each line of the respective borders */
- src_ptr1 = ybf->y_buffer - Border;
- src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
- dest_ptr1 = src_ptr1 - (Border * plane_stride);
- dest_ptr2 = src_ptr2 + plane_stride;
-
- for (i = 0; i < (int)Border; i++)
- {
- vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
- vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
-
- /***********/
- /* U Plane */
- /***********/
- plane_stride = ybf->uv_stride;
- plane_height = ybf->uv_height;
- plane_width = ybf->uv_width;
- Border /= 2;
-
- /* copy the left and right most columns out */
- src_ptr1 = ybf->u_buffer;
- src_ptr2 = src_ptr1 + plane_width - 1;
- dest_ptr1 = src_ptr1 - Border;
- dest_ptr2 = src_ptr2 + 1;
-
- for (i = 0; i < plane_height; i++)
- {
- vpx_memset(dest_ptr1, src_ptr1[0], Border);
- vpx_memset(dest_ptr2, src_ptr2[0], Border);
- src_ptr1 += plane_stride;
- src_ptr2 += plane_stride;
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- /* Now copy the top and bottom source lines into each line of the respective borders */
- src_ptr1 = ybf->u_buffer - Border;
- src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
- dest_ptr1 = src_ptr1 - (Border * plane_stride);
- dest_ptr2 = src_ptr2 + plane_stride;
-
- for (i = 0; i < (int)(Border); i++)
- {
- vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
- vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- /***********/
- /* V Plane */
- /***********/
-
- /* copy the left and right most columns out */
- src_ptr1 = ybf->v_buffer;
- src_ptr2 = src_ptr1 + plane_width - 1;
- dest_ptr1 = src_ptr1 - Border;
- dest_ptr2 = src_ptr2 + 1;
-
- for (i = 0; i < plane_height; i++)
- {
- vpx_memset(dest_ptr1, src_ptr1[0], Border);
- vpx_memset(dest_ptr2, src_ptr2[0], Border);
- src_ptr1 += plane_stride;
- src_ptr2 += plane_stride;
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- /* Now copy the top and bottom source lines into each line of the respective borders */
- src_ptr1 = ybf->v_buffer - Border;
- src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
- dest_ptr1 = src_ptr1 - (Border * plane_stride);
- dest_ptr2 = src_ptr2 + plane_stride;
-
- for (i = 0; i < (int)(Border); i++)
- {
- vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
- vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
+vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf) {
+ int i;
+ unsigned char *src_ptr1, *src_ptr2;
+ unsigned char *dest_ptr1, *dest_ptr2;
+
+ unsigned int Border;
+ int plane_stride;
+ int plane_height;
+ int plane_width;
+
+ /***********/
+ /* Y Plane */
+ /***********/
+ Border = ybf->border;
+ plane_stride = ybf->y_stride;
+ plane_height = ybf->y_height;
+ plane_width = ybf->y_width;
+
+ /* copy the left and right most columns out */
+ src_ptr1 = ybf->y_buffer;
+ src_ptr2 = src_ptr1 + plane_width - 1;
+ dest_ptr1 = src_ptr1 - Border;
+ dest_ptr2 = src_ptr2 + 1;
+
+ for (i = 0; i < plane_height; i++) {
+ vpx_memset(dest_ptr1, src_ptr1[0], Border);
+ vpx_memset(dest_ptr2, src_ptr2[0], Border);
+ src_ptr1 += plane_stride;
+ src_ptr2 += plane_stride;
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ /* Now copy the top and bottom source lines into each line of the respective borders */
+ src_ptr1 = ybf->y_buffer - Border;
+ src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
+ dest_ptr1 = src_ptr1 - (Border * plane_stride);
+ dest_ptr2 = src_ptr2 + plane_stride;
+
+ for (i = 0; i < (int)Border; i++) {
+ vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
+ vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+
+ /***********/
+ /* U Plane */
+ /***********/
+ plane_stride = ybf->uv_stride;
+ plane_height = ybf->uv_height;
+ plane_width = ybf->uv_width;
+ Border /= 2;
+
+ /* copy the left and right most columns out */
+ src_ptr1 = ybf->u_buffer;
+ src_ptr2 = src_ptr1 + plane_width - 1;
+ dest_ptr1 = src_ptr1 - Border;
+ dest_ptr2 = src_ptr2 + 1;
+
+ for (i = 0; i < plane_height; i++) {
+ vpx_memset(dest_ptr1, src_ptr1[0], Border);
+ vpx_memset(dest_ptr2, src_ptr2[0], Border);
+ src_ptr1 += plane_stride;
+ src_ptr2 += plane_stride;
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ /* Now copy the top and bottom source lines into each line of the respective borders */
+ src_ptr1 = ybf->u_buffer - Border;
+ src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
+ dest_ptr1 = src_ptr1 - (Border * plane_stride);
+ dest_ptr2 = src_ptr2 + plane_stride;
+
+ for (i = 0; i < (int)(Border); i++) {
+ vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
+ vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ /***********/
+ /* V Plane */
+ /***********/
+
+ /* copy the left and right most columns out */
+ src_ptr1 = ybf->v_buffer;
+ src_ptr2 = src_ptr1 + plane_width - 1;
+ dest_ptr1 = src_ptr1 - Border;
+ dest_ptr2 = src_ptr2 + 1;
+
+ for (i = 0; i < plane_height; i++) {
+ vpx_memset(dest_ptr1, src_ptr1[0], Border);
+ vpx_memset(dest_ptr2, src_ptr2[0], Border);
+ src_ptr1 += plane_stride;
+ src_ptr2 += plane_stride;
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ /* Now copy the top and bottom source lines into each line of the respective borders */
+ src_ptr1 = ybf->v_buffer - Border;
+ src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
+ dest_ptr1 = src_ptr1 - (Border * plane_stride);
+ dest_ptr2 = src_ptr2 + plane_stride;
+
+ for (i = 0; i < (int)(Border); i++) {
+ vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
+ vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
}
static void
-extend_frame_borders_yonly(YV12_BUFFER_CONFIG *ybf)
-{
- int i;
- unsigned char *src_ptr1, *src_ptr2;
- unsigned char *dest_ptr1, *dest_ptr2;
-
- unsigned int Border;
- int plane_stride;
- int plane_height;
- int plane_width;
-
- /***********/
- /* Y Plane */
- /***********/
- Border = ybf->border;
- plane_stride = ybf->y_stride;
- plane_height = ybf->y_height;
- plane_width = ybf->y_width;
-
- /* copy the left and right most columns out */
- src_ptr1 = ybf->y_buffer;
- src_ptr2 = src_ptr1 + plane_width - 1;
- dest_ptr1 = src_ptr1 - Border;
- dest_ptr2 = src_ptr2 + 1;
-
- for (i = 0; i < plane_height; i++)
- {
- vpx_memset(dest_ptr1, src_ptr1[0], Border);
- vpx_memset(dest_ptr2, src_ptr2[0], Border);
- src_ptr1 += plane_stride;
- src_ptr2 += plane_stride;
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- /* Now copy the top and bottom source lines into each line of the respective borders */
- src_ptr1 = ybf->y_buffer - Border;
- src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
- dest_ptr1 = src_ptr1 - (Border * plane_stride);
- dest_ptr2 = src_ptr2 + plane_stride;
-
- for (i = 0; i < (int)Border; i++)
- {
- vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
- vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
- dest_ptr1 += plane_stride;
- dest_ptr2 += plane_stride;
- }
-
- plane_stride /= 2;
- plane_height /= 2;
- plane_width /= 2;
- Border /= 2;
+extend_frame_borders_yonly(YV12_BUFFER_CONFIG *ybf) {
+ int i;
+ unsigned char *src_ptr1, *src_ptr2;
+ unsigned char *dest_ptr1, *dest_ptr2;
+
+ unsigned int Border;
+ int plane_stride;
+ int plane_height;
+ int plane_width;
+
+ /***********/
+ /* Y Plane */
+ /***********/
+ Border = ybf->border;
+ plane_stride = ybf->y_stride;
+ plane_height = ybf->y_height;
+ plane_width = ybf->y_width;
+
+ /* copy the left and right most columns out */
+ src_ptr1 = ybf->y_buffer;
+ src_ptr2 = src_ptr1 + plane_width - 1;
+ dest_ptr1 = src_ptr1 - Border;
+ dest_ptr2 = src_ptr2 + 1;
+
+ for (i = 0; i < plane_height; i++) {
+ vpx_memset(dest_ptr1, src_ptr1[0], Border);
+ vpx_memset(dest_ptr2, src_ptr2[0], Border);
+ src_ptr1 += plane_stride;
+ src_ptr2 += plane_stride;
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ /* Now copy the top and bottom source lines into each line of the respective borders */
+ src_ptr1 = ybf->y_buffer - Border;
+ src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
+ dest_ptr1 = src_ptr1 - (Border * plane_stride);
+ dest_ptr2 = src_ptr2 + plane_stride;
+
+ for (i = 0; i < (int)Border; i++) {
+ vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
+ vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
+ dest_ptr1 += plane_stride;
+ dest_ptr2 += plane_stride;
+ }
+
+ plane_stride /= 2;
+ plane_height /= 2;
+ plane_width /= 2;
+ Border /= 2;
}
@@ -221,60 +211,54 @@ extend_frame_borders_yonly(YV12_BUFFER_CONFIG *ybf)
*
****************************************************************************/
void
-vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
-{
- int row;
- unsigned char *source, *dest;
-
- source = src_ybc->y_buffer;
- dest = dst_ybc->y_buffer;
-
- for (row = 0; row < src_ybc->y_height; row++)
- {
- vpx_memcpy(dest, source, src_ybc->y_width);
- source += src_ybc->y_stride;
- dest += dst_ybc->y_stride;
- }
-
- source = src_ybc->u_buffer;
- dest = dst_ybc->u_buffer;
-
- for (row = 0; row < src_ybc->uv_height; row++)
- {
- vpx_memcpy(dest, source, src_ybc->uv_width);
- source += src_ybc->uv_stride;
- dest += dst_ybc->uv_stride;
- }
-
- source = src_ybc->v_buffer;
- dest = dst_ybc->v_buffer;
-
- for (row = 0; row < src_ybc->uv_height; row++)
- {
- vpx_memcpy(dest, source, src_ybc->uv_width);
- source += src_ybc->uv_stride;
- dest += dst_ybc->uv_stride;
- }
-
- vp8_yv12_extend_frame_borders_ptr(dst_ybc);
+vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc) {
+ int row;
+ unsigned char *source, *dest;
+
+ source = src_ybc->y_buffer;
+ dest = dst_ybc->y_buffer;
+
+ for (row = 0; row < src_ybc->y_height; row++) {
+ vpx_memcpy(dest, source, src_ybc->y_width);
+ source += src_ybc->y_stride;
+ dest += dst_ybc->y_stride;
+ }
+
+ source = src_ybc->u_buffer;
+ dest = dst_ybc->u_buffer;
+
+ for (row = 0; row < src_ybc->uv_height; row++) {
+ vpx_memcpy(dest, source, src_ybc->uv_width);
+ source += src_ybc->uv_stride;
+ dest += dst_ybc->uv_stride;
+ }
+
+ source = src_ybc->v_buffer;
+ dest = dst_ybc->v_buffer;
+
+ for (row = 0; row < src_ybc->uv_height; row++) {
+ vpx_memcpy(dest, source, src_ybc->uv_width);
+ source += src_ybc->uv_stride;
+ dest += dst_ybc->uv_stride;
+ }
+
+ vp8_yv12_extend_frame_borders_ptr(dst_ybc);
}
void
-vp8_yv12_copy_frame_yonly(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
-{
- int row;
- unsigned char *source, *dest;
+vp8_yv12_copy_frame_yonly(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc) {
+ int row;
+ unsigned char *source, *dest;
- source = src_ybc->y_buffer;
- dest = dst_ybc->y_buffer;
+ source = src_ybc->y_buffer;
+ dest = dst_ybc->y_buffer;
- for (row = 0; row < src_ybc->y_height; row++)
- {
- vpx_memcpy(dest, source, src_ybc->y_width);
- source += src_ybc->y_stride;
- dest += dst_ybc->y_stride;
- }
+ for (row = 0; row < src_ybc->y_height; row++) {
+ vpx_memcpy(dest, source, src_ybc->y_width);
+ source += src_ybc->y_stride;
+ dest += dst_ybc->y_stride;
+ }
- extend_frame_borders_yonly(dst_ybc);
+ extend_frame_borders_yonly(dst_ybc);
}
diff --git a/vpx_scale/include/generic/vpxscale_arbitrary.h b/vpx_scale/include/generic/vpxscale_arbitrary.h
index 39de1816b..c53525271 100644
--- a/vpx_scale/include/generic/vpxscale_arbitrary.h
+++ b/vpx_scale/include/generic/vpxscale_arbitrary.h
@@ -14,33 +14,32 @@
#include "vpx_scale/yv12config.h"
-typedef struct
-{
- int in_width;
- int in_height;
-
- int out_width;
- int out_height;
- int max_usable_out_width;
-
- // numerator for the width and height
- int nw;
- int nh;
- int nh_uv;
-
- // output to input correspondance array
- short *l_w;
- short *l_h;
- short *l_h_uv;
-
- // polyphase coefficients
- short *c_w;
- short *c_h;
- short *c_h_uv;
-
- // buffer for horizontal filtering.
- unsigned char *hbuf;
- unsigned char *hbuf_uv;
+typedef struct {
+ int in_width;
+ int in_height;
+
+ int out_width;
+ int out_height;
+ int max_usable_out_width;
+
+ // numerator for the width and height
+ int nw;
+ int nh;
+ int nh_uv;
+
+ // output to input correspondance array
+ short *l_w;
+ short *l_h;
+ short *l_h_uv;
+
+ // polyphase coefficients
+ short *c_w;
+ short *c_h;
+ short *c_h_uv;
+
+ // buffer for horizontal filtering.
+ unsigned char *hbuf;
+ unsigned char *hbuf_uv;
} BICUBIC_SCALER_STRUCT;
int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int out_height);
diff --git a/vpx_scale/scale_mode.h b/vpx_scale/scale_mode.h
index 1476e641b..5581385b6 100644
--- a/vpx_scale/scale_mode.h
+++ b/vpx_scale/scale_mode.h
@@ -17,12 +17,11 @@
#ifndef SCALE_MODE_H
#define SCALE_MODE_H
-typedef enum
-{
- MAINTAIN_ASPECT_RATIO = 0x0,
- SCALE_TO_FIT = 0x1,
- CENTER = 0x2,
- OTHER = 0x3
+typedef enum {
+ MAINTAIN_ASPECT_RATIO = 0x0,
+ SCALE_TO_FIT = 0x1,
+ CENTER = 0x2,
+ OTHER = 0x3
} SCALE_MODE;
diff --git a/vpx_scale/vpxscale.h b/vpx_scale/vpxscale.h
index 86fc128da..899a50a89 100644
--- a/vpx_scale/vpxscale.h
+++ b/vpx_scale/vpxscale.h
@@ -75,27 +75,27 @@ void vertical_band_1_2_scale_armv4(unsigned char *dest, unsigned int dest_pitch,
extern void dmachine_specific_config(int mmx_enabled, int xmm_enabled, int wmt_enabled);
extern void vp8_yv12_scale_or_center
(
- YV12_BUFFER_CONFIG *src_yuv_config,
- YV12_BUFFER_CONFIG *dst_yuv_config,
- int expanded_frame_width,
- int expanded_frame_height,
- int scaling_mode,
- int HScale,
- int HRatio,
- int VScale,
- int VRatio
+ YV12_BUFFER_CONFIG *src_yuv_config,
+ YV12_BUFFER_CONFIG *dst_yuv_config,
+ int expanded_frame_width,
+ int expanded_frame_height,
+ int scaling_mode,
+ int HScale,
+ int HRatio,
+ int VScale,
+ int VRatio
);
extern void vp8_scale_frame
(
- YV12_BUFFER_CONFIG *src,
- YV12_BUFFER_CONFIG *dst,
- unsigned char *temp_area,
- unsigned char temp_height,
- unsigned int hscale,
- unsigned int hratio,
- unsigned int vscale,
- unsigned int vratio,
- unsigned int interlaced
+ YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst,
+ unsigned char *temp_area,
+ unsigned char temp_height,
+ unsigned int hscale,
+ unsigned int hratio,
+ unsigned int vscale,
+ unsigned int vratio,
+ unsigned int interlaced
);
extern void vp8_scale_machine_specific_config(void);
diff --git a/vpx_scale/win32/scaleopt.c b/vpx_scale/win32/scaleopt.c
index 3711fe5eb..2d96cc7c1 100644
--- a/vpx_scale/win32/scaleopt.c
+++ b/vpx_scale/win32/scaleopt.c
@@ -61,114 +61,112 @@ __declspec(align(16)) const static unsigned short const35_1[] = { 102, 205, 51,
static
void horizontal_line_3_5_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- (void) dest_width;
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ (void) dest_width;
- __asm
- {
+ __asm {
- push ebx
+ push ebx
- mov esi, source
- mov edi, dest
+ mov esi, source
+ mov edi, dest
- mov ecx, source_width
- lea edx, [esi+ecx-3];
+ mov ecx, source_width
+ lea edx, [esi+ecx-3];
- movq mm5, const35_1 // mm5 = 66 xx cd xx 33 xx 9a xx
- movq mm6, const35_2 // mm6 = 9a xx 33 xx cd xx 66 xx
+ movq mm5, const35_1 // mm5 = 66 xx cd xx 33 xx 9a xx
+ movq mm6, const35_2 // mm6 = 9a xx 33 xx cd xx 66 xx
- movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
- pxor mm7, mm7 // clear mm7
+ movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
+ pxor mm7, mm7 // clear mm7
- horiz_line_3_5_loop:
+ horiz_line_3_5_loop:
- mov eax, DWORD PTR [esi] // eax = 00 01 02 03
- mov ebx, eax
+ mov eax, DWORD PTR [esi] // eax = 00 01 02 03
+ mov ebx, eax
- and ebx, 0xffff00 // ebx = xx 01 02 xx
- mov ecx, eax // ecx = 00 01 02 03
+ and ebx, 0xffff00 // ebx = xx 01 02 xx
+ mov ecx, eax // ecx = 00 01 02 03
- and eax, 0xffff0000 // eax = xx xx 02 03
- xor ecx, eax // ecx = 00 01 xx xx
+ and eax, 0xffff0000 // eax = xx xx 02 03
+ xor ecx, eax // ecx = 00 01 xx xx
- shr ebx, 8 // ebx = 01 02 xx xx
- or eax, ebx // eax = 01 02 02 03
+ shr ebx, 8 // ebx = 01 02 xx xx
+ or eax, ebx // eax = 01 02 02 03
- shl ebx, 16 // ebx = xx xx 01 02
- movd mm1, eax // mm1 = 01 02 02 03 xx xx xx xx
+ shl ebx, 16 // ebx = xx xx 01 02
+ movd mm1, eax // mm1 = 01 02 02 03 xx xx xx xx
- or ebx, ecx // ebx = 00 01 01 02
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 03 xx
+ or ebx, ecx // ebx = 00 01 01 02
+ punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 03 xx
- movd mm0, ebx // mm0 = 00 01 01 02
- pmullw mm1, mm6 //
+ movd mm0, ebx // mm0 = 00 01 01 02
+ pmullw mm1, mm6 //
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
- pmullw mm0, mm5 //
+ punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
+ pmullw mm0, mm5 //
- mov [edi], ebx // writeoutput 00 xx xx xx
- add esi, 3
+ mov [edi], ebx // writeoutput 00 xx xx xx
+ add esi, 3
- add edi, 5
- paddw mm0, mm1
+ add edi, 5
+ paddw mm0, mm1
- paddw mm0, mm4
- psrlw mm0, 8
+ paddw mm0, mm4
+ psrlw mm0, 8
- cmp esi, edx
- packuswb mm0, mm7
+ cmp esi, edx
+ packuswb mm0, mm7
- movd DWORD Ptr [edi-4], mm0
- jl horiz_line_3_5_loop
+ movd DWORD Ptr [edi-4], mm0
+ jl horiz_line_3_5_loop
-//Exit:
- mov eax, DWORD PTR [esi] // eax = 00 01 02 03
- mov ebx, eax
+// Exit:
+ mov eax, DWORD PTR [esi] // eax = 00 01 02 03
+ mov ebx, eax
- and ebx, 0xffff00 // ebx = xx 01 02 xx
- mov ecx, eax // ecx = 00 01 02 03
+ and ebx, 0xffff00 // ebx = xx 01 02 xx
+ mov ecx, eax // ecx = 00 01 02 03
- and eax, 0xffff0000 // eax = xx xx 02 03
- xor ecx, eax // ecx = 00 01 xx xx
+ and eax, 0xffff0000 // eax = xx xx 02 03
+ xor ecx, eax // ecx = 00 01 xx xx
- shr ebx, 8 // ebx = 01 02 xx xx
- or eax, ebx // eax = 01 02 02 03
+ shr ebx, 8 // ebx = 01 02 xx xx
+ or eax, ebx // eax = 01 02 02 03
- shl eax, 8 // eax = xx 01 02 02
- and eax, 0xffff0000 // eax = xx xx 02 02
+ shl eax, 8 // eax = xx 01 02 02
+ and eax, 0xffff0000 // eax = xx xx 02 02
- or eax, ebx // eax = 01 02 02 02
+ or eax, ebx // eax = 01 02 02 02
- shl ebx, 16 // ebx = xx xx 01 02
- movd mm1, eax // mm1 = 01 02 02 02 xx xx xx xx
+ shl ebx, 16 // ebx = xx xx 01 02
+ movd mm1, eax // mm1 = 01 02 02 02 xx xx xx xx
- or ebx, ecx // ebx = 00 01 01 02
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 02 xx
+ or ebx, ecx // ebx = 00 01 01 02
+ punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 02 xx
- movd mm0, ebx // mm0 = 00 01 01 02
- pmullw mm1, mm6 //
+ movd mm0, ebx // mm0 = 00 01 01 02
+ pmullw mm1, mm6 //
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
- pmullw mm0, mm5 //
+ punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
+ pmullw mm0, mm5 //
- mov [edi], ebx // writeoutput 00 xx xx xx
- paddw mm0, mm1
+ mov [edi], ebx // writeoutput 00 xx xx xx
+ paddw mm0, mm1
- paddw mm0, mm4
- psrlw mm0, 8
+ paddw mm0, mm4
+ psrlw mm0, 8
- packuswb mm0, mm7
- movd DWORD Ptr [edi+1], mm0
+ packuswb mm0, mm7
+ movd DWORD Ptr [edi+1], mm0
- pop ebx
+ pop ebx
- }
+ }
}
@@ -194,120 +192,118 @@ void horizontal_line_3_5_scale_mmx
static
void horizontal_line_4_5_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- (void)dest_width;
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ (void)dest_width;
- __asm
- {
+ __asm {
- mov esi, source
- mov edi, dest
+ mov esi, source
+ mov edi, dest
- mov ecx, source_width
- lea edx, [esi+ecx-8];
+ mov ecx, source_width
+ lea edx, [esi+ecx-8];
- movq mm5, const45_1 // mm5 = 33 xx 66 xx 9a xx cd xx
- movq mm6, const45_2 // mm6 = cd xx 9a xx 66 xx 33 xx
+ movq mm5, const45_1 // mm5 = 33 xx 66 xx 9a xx cd xx
+ movq mm6, const45_2 // mm6 = cd xx 9a xx 66 xx 33 xx
- movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
- pxor mm7, mm7 // clear mm7
+ movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
+ pxor mm7, mm7 // clear mm7
- horiz_line_4_5_loop:
+ horiz_line_4_5_loop:
- movq mm0, QWORD PTR [esi] // mm0 = 00 01 02 03 04 05 06 07
- movq mm1, QWORD PTR [esi+1]; // mm1 = 01 02 03 04 05 06 07 08
+ movq mm0, QWORD PTR [esi] // mm0 = 00 01 02 03 04 05 06 07
+ movq mm1, QWORD PTR [esi+1]; // mm1 = 01 02 03 04 05 06 07 08
- movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
- movq mm3, mm1 // mm3 = 01 02 03 04 05 06 07 08
+ movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
+ movq mm3, mm1 // mm3 = 01 02 03 04 05 06 07 08
- movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
+ movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
+ punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
- pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
+ punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
+ pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
- pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
- punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
+ pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
+ punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
- movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
- pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
+ movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
+ pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
- punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
- pmullw mm3, mm6 // 05*205 06*154 07*102 08* 51
+ punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
+ pmullw mm3, mm6 // 05*205 06*154 07*102 08* 51
- paddw mm0, mm1 // added round values
- paddw mm0, mm4
+ paddw mm0, mm1 // added round values
+ paddw mm0, mm4
- psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
- packuswb mm0, mm7
+ psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
+ packuswb mm0, mm7
- movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
- add edi, 10
+ movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
+ add edi, 10
- add esi, 8
- paddw mm2, mm3 //
+ add esi, 8
+ paddw mm2, mm3 //
- paddw mm2, mm4 // added round values
- cmp esi, edx
+ paddw mm2, mm4 // added round values
+ cmp esi, edx
- psrlw mm2, 8
- packuswb mm2, mm7
+ psrlw mm2, 8
+ packuswb mm2, mm7
- movd DWORD PTR [edi-4], mm2 // writeoutput 06 07 08 09
- jl horiz_line_4_5_loop
+ movd DWORD PTR [edi-4], mm2 // writeoutput 06 07 08 09
+ jl horiz_line_4_5_loop
-//Exit:
- movq mm0, [esi] // mm0 = 00 01 02 03 04 05 06 07
- movq mm1, mm0 // mm1 = 00 01 02 03 04 05 06 07
+// Exit:
+ movq mm0, [esi] // mm0 = 00 01 02 03 04 05 06 07
+ movq mm1, mm0 // mm1 = 00 01 02 03 04 05 06 07
- movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
- psrlq mm1, 8 // mm1 = 01 02 03 04 05 06 07 00
+ movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
+ psrlq mm1, 8 // mm1 = 01 02 03 04 05 06 07 00
- movq mm3, mask45 // mm3 = 00 00 00 00 00 00 ff 00
- pand mm3, mm1 // mm3 = 00 00 00 00 00 00 07 00
+ movq mm3, mask45 // mm3 = 00 00 00 00 00 00 ff 00
+ pand mm3, mm1 // mm3 = 00 00 00 00 00 00 07 00
- psllq mm3, 8 // mm3 = 00 00 00 00 00 00 00 07
- por mm1, mm3 // mm1 = 01 02 03 04 05 06 07 07
+ psllq mm3, 8 // mm3 = 00 00 00 00 00 00 00 07
+ por mm1, mm3 // mm1 = 01 02 03 04 05 06 07 07
- movq mm3, mm1
+ movq mm3, mm1
- movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
+ movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
+ punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
- pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
+ punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
+ pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
- pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
- punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
+ pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
+ punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
- movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
- pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
+ movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
+ pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
- punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
- pmullw mm3, mm6 // 05*205 06*154 07*102 07* 51
+ punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
+ pmullw mm3, mm6 // 05*205 06*154 07*102 07* 51
- paddw mm0, mm1 // added round values
- paddw mm0, mm4
+ paddw mm0, mm1 // added round values
+ paddw mm0, mm4
- psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
- packuswb mm0, mm7 // 01 02 03 04 xx xx xx xx
+ psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
+ packuswb mm0, mm7 // 01 02 03 04 xx xx xx xx
- movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
- paddw mm2, mm3 //
+ movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
+ paddw mm2, mm3 //
- paddw mm2, mm4 // added round values
- psrlw mm2, 8
+ paddw mm2, mm4 // added round values
+ psrlw mm2, 8
- packuswb mm2, mm7
- movd DWORD PTR [edi+6], mm2 // writeoutput 06 07 08 09
+ packuswb mm2, mm7
+ movd DWORD PTR [edi+6], mm2 // writeoutput 06 07 08 09
- }
+ }
}
/****************************************************************************
@@ -332,167 +328,165 @@ void horizontal_line_4_5_scale_mmx
static
void vertical_band_4_5_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
+ lea edi, [esi+ecx*2] // tow lines below
+ add edi, ecx // three lines below
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
+ pxor mm7, mm7 // clear out mm7
+ mov edx, dest_width // Loop counter
- vs_4_5_loop:
+ vs_4_5_loop:
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
+ movq mm0, QWORD ptr [esi] // src[0];
+ movq mm1, QWORD ptr [esi+ecx] // src[1];
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
+ movq mm2, mm0 // Make a copy
+ punpcklbw mm0, mm7 // unpack low to word
- movq mm5, one_fifth
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm5, one_fifth
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm0, mm5 // a * 1/5
+ pmullw mm0, mm5 // a * 1/5
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
+ movq mm3, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low to word
- pmullw mm2, mm5 // a * 1/5
- movq mm6, four_fifths // constan
+ pmullw mm2, mm5 // a * 1/5
+ movq mm6, four_fifths // constan
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 4/5
+ movq mm4, mm1 // copy of low b
+ pmullw mm4, mm6 // b * 4/5
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
+ punpckhbw mm3, mm7 // unpack high to word
+ movq mm5, mm3 // copy of high b
- pmullw mm5, mm6 // b * 4/5
- paddw mm0, mm4 // a * 1/5 + b * 4/5
+ pmullw mm5, mm6 // b * 4/5
+ paddw mm0, mm4 // a * 1/5 + b * 4/5
- paddw mm2, mm5 // a * 1/5 + b * 4/5
- paddw mm0, round_values // + 128
+ paddw mm2, mm5 // a * 1/5 + b * 4/5
+ paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
- psrlw mm0, 8
+ paddw mm2, round_values // + 128
+ psrlw mm0, 8
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
+ psrlw mm2, 8
+ packuswb mm0, mm2 // des [1]
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
+ movq QWORD ptr [esi+ecx], mm0 // write des[1]
+ movq mm0, [esi+ecx*2] // mm0 = src[2]
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
+ // mm1, mm3 --- Src[1]
+ // mm0 --- Src[2]
+ // mm7 for unpacking
- movq mm5, two_fifths
- movq mm2, mm0 // make a copy
+ movq mm5, two_fifths
+ movq mm2, mm0 // make a copy
- pmullw mm1, mm5 // b * 2/5
- movq mm6, three_fifths
+ pmullw mm1, mm5 // b * 2/5
+ movq mm6, three_fifths
- punpcklbw mm0, mm7 // unpack low to word
- pmullw mm3, mm5 // b * 2/5
+ punpcklbw mm0, mm7 // unpack low to word
+ pmullw mm3, mm5 // b * 2/5
- movq mm4, mm0 // make copy of c
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm4, mm0 // make copy of c
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm4, mm6 // c * 3/5
- movq mm5, mm2
+ pmullw mm4, mm6 // c * 3/5
+ movq mm5, mm2
- pmullw mm5, mm6 // c * 3/5
- paddw mm1, mm4 // b * 2/5 + c * 3/5
+ pmullw mm5, mm6 // c * 3/5
+ paddw mm1, mm4 // b * 2/5 + c * 3/5
- paddw mm3, mm5 // b * 2/5 + c * 3/5
- paddw mm1, round_values // + 128
+ paddw mm3, mm5 // b * 2/5 + c * 3/5
+ paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
- psrlw mm1, 8
+ paddw mm3, round_values // + 128
+ psrlw mm1, 8
- psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
+ psrlw mm3, 8
+ packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- movq mm1, [edi] // mm1=Src[3];
+ movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
+ movq mm1, [edi] // mm1=Src[3];
- // mm0, mm2 --- Src[2]
- // mm1 --- Src[3]
- // mm6 --- 3/5
- // mm7 for unpacking
+ // mm0, mm2 --- Src[2]
+ // mm1 --- Src[3]
+ // mm6 --- 3/5
+ // mm7 for unpacking
- pmullw mm0, mm6 // c * 3/5
- movq mm5, two_fifths // mm5 = 2/5
+ pmullw mm0, mm6 // c * 3/5
+ movq mm5, two_fifths // mm5 = 2/5
- movq mm3, mm1 // make a copy
- pmullw mm2, mm6 // c * 3/5
+ movq mm3, mm1 // make a copy
+ pmullw mm2, mm6 // c * 3/5
- punpcklbw mm1, mm7 // unpack low
- movq mm4, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low
+ movq mm4, mm1 // make a copy
- punpckhbw mm3, mm7 // unpack high
- pmullw mm4, mm5 // d * 2/5
+ punpckhbw mm3, mm7 // unpack high
+ pmullw mm4, mm5 // d * 2/5
- movq mm6, mm3 // make a copy
- pmullw mm6, mm5 // d * 2/5
+ movq mm6, mm3 // make a copy
+ pmullw mm6, mm5 // d * 2/5
- paddw mm0, mm4 // c * 3/5 + d * 2/5
- paddw mm2, mm6 // c * 3/5 + d * 2/5
+ paddw mm0, mm4 // c * 3/5 + d * 2/5
+ paddw mm2, mm6 // c * 3/5 + d * 2/5
- paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
+ paddw mm0, round_values // + 128
+ paddw mm2, round_values // + 128
- psrlw mm0, 8
- psrlw mm2, 8
+ psrlw mm0, 8
+ psrlw mm2, 8
- packuswb mm0, mm2 // des[3]
- movq QWORD ptr [edi], mm0 // write des[3]
+ packuswb mm0, mm2 // des[3]
+ movq QWORD ptr [edi], mm0 // write des[3]
- // mm1, mm3 --- Src[3]
- // mm7 -- cleared for unpacking
+ // mm1, mm3 --- Src[3]
+ // mm7 -- cleared for unpacking
- movq mm0, [edi+ecx*2] // mm0, Src[0] of the next group
+ movq mm0, [edi+ecx*2] // mm0, Src[0] of the next group
- movq mm5, four_fifths // mm5 = 4/5
- pmullw mm1, mm5 // d * 4/5
+ movq mm5, four_fifths // mm5 = 4/5
+ pmullw mm1, mm5 // d * 4/5
- movq mm6, one_fifth // mm6 = 1/5
- movq mm2, mm0 // make a copy
+ movq mm6, one_fifth // mm6 = 1/5
+ movq mm2, mm0 // make a copy
- pmullw mm3, mm5 // d * 4/5
- punpcklbw mm0, mm7 // unpack low
+ pmullw mm3, mm5 // d * 4/5
+ punpcklbw mm0, mm7 // unpack low
- pmullw mm0, mm6 // an * 1/5
- punpckhbw mm2, mm7 // unpack high
+ pmullw mm0, mm6 // an * 1/5
+ punpckhbw mm2, mm7 // unpack high
- paddw mm1, mm0 // d * 4/5 + an * 1/5
- pmullw mm2, mm6 // an * 1/5
+ paddw mm1, mm0 // d * 4/5 + an * 1/5
+ pmullw mm2, mm6 // an * 1/5
- paddw mm3, mm2 // d * 4/5 + an * 1/5
- paddw mm1, round_values // + 128
+ paddw mm3, mm2 // d * 4/5 + an * 1/5
+ paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
- psrlw mm1, 8
+ paddw mm3, round_values // + 128
+ psrlw mm1, 8
- psrlw mm3, 8
- packuswb mm1, mm3 // des[4]
+ psrlw mm3, 8
+ packuswb mm1, mm3 // des[4]
- movq QWORD ptr [edi+ecx], mm1 // write des[4]
+ movq QWORD ptr [edi+ecx], mm1 // write des[4]
- add edi, 8
- add esi, 8
+ add edi, 8
+ add esi, 8
- sub edx, 8
- jg vs_4_5_loop
- }
+ sub edx, 8
+ jg vs_4_5_loop
+ }
}
/****************************************************************************
@@ -517,139 +511,137 @@ void vertical_band_4_5_scale_mmx
static
void last_vertical_band_4_5_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
+ lea edi, [esi+ecx*2] // tow lines below
+ add edi, ecx // three lines below
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
+ pxor mm7, mm7 // clear out mm7
+ mov edx, dest_width // Loop counter
- last_vs_4_5_loop:
+ last_vs_4_5_loop:
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
+ movq mm0, QWORD ptr [esi] // src[0];
+ movq mm1, QWORD ptr [esi+ecx] // src[1];
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
+ movq mm2, mm0 // Make a copy
+ punpcklbw mm0, mm7 // unpack low to word
- movq mm5, one_fifth
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm5, one_fifth
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm0, mm5 // a * 1/5
+ pmullw mm0, mm5 // a * 1/5
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
+ movq mm3, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low to word
- pmullw mm2, mm5 // a * 1/5
- movq mm6, four_fifths // constan
+ pmullw mm2, mm5 // a * 1/5
+ movq mm6, four_fifths // constan
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 4/5
+ movq mm4, mm1 // copy of low b
+ pmullw mm4, mm6 // b * 4/5
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
+ punpckhbw mm3, mm7 // unpack high to word
+ movq mm5, mm3 // copy of high b
- pmullw mm5, mm6 // b * 4/5
- paddw mm0, mm4 // a * 1/5 + b * 4/5
+ pmullw mm5, mm6 // b * 4/5
+ paddw mm0, mm4 // a * 1/5 + b * 4/5
- paddw mm2, mm5 // a * 1/5 + b * 4/5
- paddw mm0, round_values // + 128
+ paddw mm2, mm5 // a * 1/5 + b * 4/5
+ paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
- psrlw mm0, 8
+ paddw mm2, round_values // + 128
+ psrlw mm0, 8
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
+ psrlw mm2, 8
+ packuswb mm0, mm2 // des [1]
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
+ movq QWORD ptr [esi+ecx], mm0 // write des[1]
+ movq mm0, [esi+ecx*2] // mm0 = src[2]
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
+ // mm1, mm3 --- Src[1]
+ // mm0 --- Src[2]
+ // mm7 for unpacking
- movq mm5, two_fifths
- movq mm2, mm0 // make a copy
+ movq mm5, two_fifths
+ movq mm2, mm0 // make a copy
- pmullw mm1, mm5 // b * 2/5
- movq mm6, three_fifths
+ pmullw mm1, mm5 // b * 2/5
+ movq mm6, three_fifths
- punpcklbw mm0, mm7 // unpack low to word
- pmullw mm3, mm5 // b * 2/5
+ punpcklbw mm0, mm7 // unpack low to word
+ pmullw mm3, mm5 // b * 2/5
- movq mm4, mm0 // make copy of c
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm4, mm0 // make copy of c
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm4, mm6 // c * 3/5
- movq mm5, mm2
+ pmullw mm4, mm6 // c * 3/5
+ movq mm5, mm2
- pmullw mm5, mm6 // c * 3/5
- paddw mm1, mm4 // b * 2/5 + c * 3/5
+ pmullw mm5, mm6 // c * 3/5
+ paddw mm1, mm4 // b * 2/5 + c * 3/5
- paddw mm3, mm5 // b * 2/5 + c * 3/5
- paddw mm1, round_values // + 128
+ paddw mm3, mm5 // b * 2/5 + c * 3/5
+ paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
- psrlw mm1, 8
+ paddw mm3, round_values // + 128
+ psrlw mm1, 8
- psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
+ psrlw mm3, 8
+ packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- movq mm1, [edi] // mm1=Src[3];
+ movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
+ movq mm1, [edi] // mm1=Src[3];
- movq QWORD ptr [edi+ecx], mm1 // write des[4];
+ movq QWORD ptr [edi+ecx], mm1 // write des[4];
- // mm0, mm2 --- Src[2]
- // mm1 --- Src[3]
- // mm6 --- 3/5
- // mm7 for unpacking
+ // mm0, mm2 --- Src[2]
+ // mm1 --- Src[3]
+ // mm6 --- 3/5
+ // mm7 for unpacking
- pmullw mm0, mm6 // c * 3/5
- movq mm5, two_fifths // mm5 = 2/5
+ pmullw mm0, mm6 // c * 3/5
+ movq mm5, two_fifths // mm5 = 2/5
- movq mm3, mm1 // make a copy
- pmullw mm2, mm6 // c * 3/5
+ movq mm3, mm1 // make a copy
+ pmullw mm2, mm6 // c * 3/5
- punpcklbw mm1, mm7 // unpack low
- movq mm4, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low
+ movq mm4, mm1 // make a copy
- punpckhbw mm3, mm7 // unpack high
- pmullw mm4, mm5 // d * 2/5
+ punpckhbw mm3, mm7 // unpack high
+ pmullw mm4, mm5 // d * 2/5
- movq mm6, mm3 // make a copy
- pmullw mm6, mm5 // d * 2/5
+ movq mm6, mm3 // make a copy
+ pmullw mm6, mm5 // d * 2/5
- paddw mm0, mm4 // c * 3/5 + d * 2/5
- paddw mm2, mm6 // c * 3/5 + d * 2/5
+ paddw mm0, mm4 // c * 3/5 + d * 2/5
+ paddw mm2, mm6 // c * 3/5 + d * 2/5
- paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
+ paddw mm0, round_values // + 128
+ paddw mm2, round_values // + 128
- psrlw mm0, 8
- psrlw mm2, 8
+ psrlw mm0, 8
+ psrlw mm2, 8
- packuswb mm0, mm2 // des[3]
- movq QWORD ptr [edi], mm0 // write des[3]
+ packuswb mm0, mm2 // des[3]
+ movq QWORD ptr [edi], mm0 // write des[3]
- // mm1, mm3 --- Src[3]
- // mm7 -- cleared for unpacking
- add edi, 8
- add esi, 8
+ // mm1, mm3 --- Src[3]
+ // mm7 -- cleared for unpacking
+ add edi, 8
+ add esi, 8
- sub edx, 8
- jg last_vs_4_5_loop
- }
+ sub edx, 8
+ jg last_vs_4_5_loop
+ }
}
/****************************************************************************
@@ -674,153 +666,151 @@ void last_vertical_band_4_5_scale_mmx
static
void vertical_band_3_5_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
+ lea edi, [esi+ecx*2] // tow lines below
+ add edi, ecx // three lines below
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
+ pxor mm7, mm7 // clear out mm7
+ mov edx, dest_width // Loop counter
- vs_3_5_loop:
+ vs_3_5_loop:
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
+ movq mm0, QWORD ptr [esi] // src[0];
+ movq mm1, QWORD ptr [esi+ecx] // src[1];
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
+ movq mm2, mm0 // Make a copy
+ punpcklbw mm0, mm7 // unpack low to word
- movq mm5, two_fifths // mm5 = 2/5
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm5, two_fifths // mm5 = 2/5
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm0, mm5 // a * 2/5
+ pmullw mm0, mm5 // a * 2/5
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
+ movq mm3, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low to word
- pmullw mm2, mm5 // a * 2/5
- movq mm6, three_fifths // mm6 = 3/5
+ pmullw mm2, mm5 // a * 2/5
+ movq mm6, three_fifths // mm6 = 3/5
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 3/5
+ movq mm4, mm1 // copy of low b
+ pmullw mm4, mm6 // b * 3/5
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
+ punpckhbw mm3, mm7 // unpack high to word
+ movq mm5, mm3 // copy of high b
- pmullw mm5, mm6 // b * 3/5
- paddw mm0, mm4 // a * 2/5 + b * 3/5
+ pmullw mm5, mm6 // b * 3/5
+ paddw mm0, mm4 // a * 2/5 + b * 3/5
- paddw mm2, mm5 // a * 2/5 + b * 3/5
- paddw mm0, round_values // + 128
+ paddw mm2, mm5 // a * 2/5 + b * 3/5
+ paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
- psrlw mm0, 8
+ paddw mm2, round_values // + 128
+ psrlw mm0, 8
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
+ psrlw mm2, 8
+ packuswb mm0, mm2 // des [1]
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
+ movq QWORD ptr [esi+ecx], mm0 // write des[1]
+ movq mm0, [esi+ecx*2] // mm0 = src[2]
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
+ // mm1, mm3 --- Src[1]
+ // mm0 --- Src[2]
+ // mm7 for unpacking
- movq mm4, mm1 // b low
- pmullw mm1, four_fifths // b * 4/5 low
+ movq mm4, mm1 // b low
+ pmullw mm1, four_fifths // b * 4/5 low
- movq mm5, mm3 // b high
- pmullw mm3, four_fifths // b * 4/5 high
+ movq mm5, mm3 // b high
+ pmullw mm3, four_fifths // b * 4/5 high
- movq mm2, mm0 // c
- pmullw mm4, one_fifth // b * 1/5
+ movq mm2, mm0 // c
+ pmullw mm4, one_fifth // b * 1/5
- punpcklbw mm0, mm7 // c low
- pmullw mm5, one_fifth // b * 1/5
+ punpcklbw mm0, mm7 // c low
+ pmullw mm5, one_fifth // b * 1/5
- movq mm6, mm0 // make copy of c low
- punpckhbw mm2, mm7 // c high
+ movq mm6, mm0 // make copy of c low
+ punpckhbw mm2, mm7 // c high
- pmullw mm6, one_fifth // c * 1/5 low
- movq mm7, mm2 // make copy of c high
+ pmullw mm6, one_fifth // c * 1/5 low
+ movq mm7, mm2 // make copy of c high
- pmullw mm7, one_fifth // c * 1/5 high
- paddw mm1, mm6 // b * 4/5 + c * 1/5 low
+ pmullw mm7, one_fifth // c * 1/5 high
+ paddw mm1, mm6 // b * 4/5 + c * 1/5 low
- paddw mm3, mm7 // b * 4/5 + c * 1/5 high
- movq mm6, mm0 // make copy of c low
+ paddw mm3, mm7 // b * 4/5 + c * 1/5 high
+ movq mm6, mm0 // make copy of c low
- pmullw mm6, four_fifths // c * 4/5 low
- movq mm7, mm2 // make copy of c high
+ pmullw mm6, four_fifths // c * 4/5 low
+ movq mm7, mm2 // make copy of c high
- pmullw mm7, four_fifths // c * 4/5 high
+ pmullw mm7, four_fifths // c * 4/5 high
- paddw mm4, mm6 // b * 1/5 + c * 4/5 low
- paddw mm5, mm7 // b * 1/5 + c * 4/5 high
+ paddw mm4, mm6 // b * 1/5 + c * 4/5 low
+ paddw mm5, mm7 // b * 1/5 + c * 4/5 high
- paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
+ paddw mm1, round_values // + 128
+ paddw mm3, round_values // + 128
- psrlw mm1, 8
- psrlw mm3, 8
+ psrlw mm1, 8
+ psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
+ packuswb mm1, mm3 // des[2]
+ movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- paddw mm4, round_values // + 128
- paddw mm5, round_values // + 128
+ paddw mm4, round_values // + 128
+ paddw mm5, round_values // + 128
- psrlw mm4, 8
- psrlw mm5, 8
+ psrlw mm4, 8
+ psrlw mm5, 8
- packuswb mm4, mm5 // des[3]
- movq QWORD ptr [edi], mm4 // write des[3]
+ packuswb mm4, mm5 // des[3]
+ movq QWORD ptr [edi], mm4 // write des[3]
- // mm0, mm2 --- Src[3]
+ // mm0, mm2 --- Src[3]
- pxor mm7, mm7 // clear mm7 for unpacking
- movq mm1, [edi+ecx*2] // mm1 = Src[0] of the next group
+ pxor mm7, mm7 // clear mm7 for unpacking
+ movq mm1, [edi+ecx*2] // mm1 = Src[0] of the next group
- movq mm5, three_fifths // mm5 = 3/5
- pmullw mm0, mm5 // d * 3/5
+ movq mm5, three_fifths // mm5 = 3/5
+ pmullw mm0, mm5 // d * 3/5
- movq mm6, two_fifths // mm6 = 2/5
- movq mm3, mm1 // make a copy
+ movq mm6, two_fifths // mm6 = 2/5
+ movq mm3, mm1 // make a copy
- pmullw mm2, mm5 // d * 3/5
- punpcklbw mm1, mm7 // unpack low
+ pmullw mm2, mm5 // d * 3/5
+ punpcklbw mm1, mm7 // unpack low
- pmullw mm1, mm6 // an * 2/5
- punpckhbw mm3, mm7 // unpack high
+ pmullw mm1, mm6 // an * 2/5
+ punpckhbw mm3, mm7 // unpack high
- paddw mm0, mm1 // d * 3/5 + an * 2/5
- pmullw mm3, mm6 // an * 2/5
+ paddw mm0, mm1 // d * 3/5 + an * 2/5
+ pmullw mm3, mm6 // an * 2/5
- paddw mm2, mm3 // d * 3/5 + an * 2/5
- paddw mm0, round_values // + 128
+ paddw mm2, mm3 // d * 3/5 + an * 2/5
+ paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
- psrlw mm0, 8
+ paddw mm2, round_values // + 128
+ psrlw mm0, 8
- psrlw mm2, 8
- packuswb mm0, mm2 // des[4]
+ psrlw mm2, 8
+ packuswb mm0, mm2 // des[4]
- movq QWORD ptr [edi+ecx], mm0 // write des[4]
+ movq QWORD ptr [edi+ecx], mm0 // write des[4]
- add edi, 8
- add esi, 8
+ add edi, 8
+ add esi, 8
- sub edx, 8
- jg vs_3_5_loop
- }
+ sub edx, 8
+ jg vs_3_5_loop
+ }
}
/****************************************************************************
@@ -845,129 +835,127 @@ void vertical_band_3_5_scale_mmx
static
void last_vertical_band_3_5_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
+ lea edi, [esi+ecx*2] // tow lines below
+ add edi, ecx // three lines below
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
+ pxor mm7, mm7 // clear out mm7
+ mov edx, dest_width // Loop counter
- last_vs_3_5_loop:
+ last_vs_3_5_loop:
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
+ movq mm0, QWORD ptr [esi] // src[0];
+ movq mm1, QWORD ptr [esi+ecx] // src[1];
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
+ movq mm2, mm0 // Make a copy
+ punpcklbw mm0, mm7 // unpack low to word
- movq mm5, two_fifths // mm5 = 2/5
- punpckhbw mm2, mm7 // unpack high to word
+ movq mm5, two_fifths // mm5 = 2/5
+ punpckhbw mm2, mm7 // unpack high to word
- pmullw mm0, mm5 // a * 2/5
+ pmullw mm0, mm5 // a * 2/5
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
+ movq mm3, mm1 // make a copy
+ punpcklbw mm1, mm7 // unpack low to word
- pmullw mm2, mm5 // a * 2/5
- movq mm6, three_fifths // mm6 = 3/5
+ pmullw mm2, mm5 // a * 2/5
+ movq mm6, three_fifths // mm6 = 3/5
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 3/5
+ movq mm4, mm1 // copy of low b
+ pmullw mm4, mm6 // b * 3/5
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
+ punpckhbw mm3, mm7 // unpack high to word
+ movq mm5, mm3 // copy of high b
- pmullw mm5, mm6 // b * 3/5
- paddw mm0, mm4 // a * 2/5 + b * 3/5
+ pmullw mm5, mm6 // b * 3/5
+ paddw mm0, mm4 // a * 2/5 + b * 3/5
- paddw mm2, mm5 // a * 2/5 + b * 3/5
- paddw mm0, round_values // + 128
+ paddw mm2, mm5 // a * 2/5 + b * 3/5
+ paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
- psrlw mm0, 8
+ paddw mm2, round_values // + 128
+ psrlw mm0, 8
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
+ psrlw mm2, 8
+ packuswb mm0, mm2 // des [1]
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
+ movq QWORD ptr [esi+ecx], mm0 // write des[1]
+ movq mm0, [esi+ecx*2] // mm0 = src[2]
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
+ // mm1, mm3 --- Src[1]
+ // mm0 --- Src[2]
+ // mm7 for unpacking
- movq mm4, mm1 // b low
- pmullw mm1, four_fifths // b * 4/5 low
+ movq mm4, mm1 // b low
+ pmullw mm1, four_fifths // b * 4/5 low
- movq QWORD ptr [edi+ecx], mm0 // write des[4]
+ movq QWORD ptr [edi+ecx], mm0 // write des[4]
- movq mm5, mm3 // b high
- pmullw mm3, four_fifths // b * 4/5 high
+ movq mm5, mm3 // b high
+ pmullw mm3, four_fifths // b * 4/5 high
- movq mm2, mm0 // c
- pmullw mm4, one_fifth // b * 1/5
+ movq mm2, mm0 // c
+ pmullw mm4, one_fifth // b * 1/5
- punpcklbw mm0, mm7 // c low
- pmullw mm5, one_fifth // b * 1/5
+ punpcklbw mm0, mm7 // c low
+ pmullw mm5, one_fifth // b * 1/5
- movq mm6, mm0 // make copy of c low
- punpckhbw mm2, mm7 // c high
+ movq mm6, mm0 // make copy of c low
+ punpckhbw mm2, mm7 // c high
- pmullw mm6, one_fifth // c * 1/5 low
- movq mm7, mm2 // make copy of c high
+ pmullw mm6, one_fifth // c * 1/5 low
+ movq mm7, mm2 // make copy of c high
- pmullw mm7, one_fifth // c * 1/5 high
- paddw mm1, mm6 // b * 4/5 + c * 1/5 low
+ pmullw mm7, one_fifth // c * 1/5 high
+ paddw mm1, mm6 // b * 4/5 + c * 1/5 low
- paddw mm3, mm7 // b * 4/5 + c * 1/5 high
- movq mm6, mm0 // make copy of c low
+ paddw mm3, mm7 // b * 4/5 + c * 1/5 high
+ movq mm6, mm0 // make copy of c low
- pmullw mm6, four_fifths // c * 4/5 low
- movq mm7, mm2 // make copy of c high
+ pmullw mm6, four_fifths // c * 4/5 low
+ movq mm7, mm2 // make copy of c high
- pmullw mm7, four_fifths // c * 4/5 high
+ pmullw mm7, four_fifths // c * 4/5 high
- paddw mm4, mm6 // b * 1/5 + c * 4/5 low
- paddw mm5, mm7 // b * 1/5 + c * 4/5 high
+ paddw mm4, mm6 // b * 1/5 + c * 4/5 low
+ paddw mm5, mm7 // b * 1/5 + c * 4/5 high
- paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
+ paddw mm1, round_values // + 128
+ paddw mm3, round_values // + 128
- psrlw mm1, 8
- psrlw mm3, 8
+ psrlw mm1, 8
+ psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
+ packuswb mm1, mm3 // des[2]
+ movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- paddw mm4, round_values // + 128
- paddw mm5, round_values // + 128
+ paddw mm4, round_values // + 128
+ paddw mm5, round_values // + 128
- psrlw mm4, 8
- psrlw mm5, 8
+ psrlw mm4, 8
+ psrlw mm5, 8
- packuswb mm4, mm5 // des[3]
- movq QWORD ptr [edi], mm4 // write des[3]
+ packuswb mm4, mm5 // des[3]
+ movq QWORD ptr [edi], mm4 // write des[3]
- // mm0, mm2 --- Src[3]
+ // mm0, mm2 --- Src[3]
- add edi, 8
- add esi, 8
+ add edi, 8
+ add esi, 8
- sub edx, 8
- jg last_vs_3_5_loop
- }
+ sub edx, 8
+ jg last_vs_3_5_loop
+ }
}
/****************************************************************************
@@ -992,52 +980,50 @@ void last_vertical_band_3_5_scale_mmx
static
void vertical_band_1_2_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
+ pxor mm7, mm7 // clear out mm7
+ mov edx, dest_width // Loop counter
- vs_1_2_loop:
+ vs_1_2_loop:
- movq mm0, [esi] // get Src[0]
- movq mm1, [esi + ecx * 2] // get Src[1]
+ movq mm0, [esi] // get Src[0]
+ movq mm1, [esi + ecx * 2] // get Src[1]
- movq mm2, mm0 // make copy before unpack
- movq mm3, mm1 // make copy before unpack
+ movq mm2, mm0 // make copy before unpack
+ movq mm3, mm1 // make copy before unpack
- punpcklbw mm0, mm7 // low Src[0]
- movq mm6, four_ones // mm6= 1, 1, 1, 1
+ punpcklbw mm0, mm7 // low Src[0]
+ movq mm6, four_ones // mm6= 1, 1, 1, 1
- punpcklbw mm1, mm7 // low Src[1]
- paddw mm0, mm1 // low (a + b)
+ punpcklbw mm1, mm7 // low Src[1]
+ paddw mm0, mm1 // low (a + b)
- punpckhbw mm2, mm7 // high Src[0]
- paddw mm0, mm6 // low (a + b + 1)
+ punpckhbw mm2, mm7 // high Src[0]
+ paddw mm0, mm6 // low (a + b + 1)
- punpckhbw mm3, mm7
- paddw mm2, mm3 // high (a + b )
+ punpckhbw mm3, mm7
+ paddw mm2, mm3 // high (a + b )
- psraw mm0, 1 // low (a + b +1 )/2
- paddw mm2, mm6 // high (a + b + 1)
+ psraw mm0, 1 // low (a + b +1 )/2
+ paddw mm2, mm6 // high (a + b + 1)
- psraw mm2, 1 // high (a + b + 1)/2
- packuswb mm0, mm2 // pack results
+ psraw mm2, 1 // high (a + b + 1)/2
+ packuswb mm0, mm2 // pack results
- movq [esi+ecx], mm0 // write out eight bytes
- add esi, 8
+ movq [esi+ecx], mm0 // write out eight bytes
+ add esi, 8
- sub edx, 8
- jg vs_1_2_loop
- }
+ sub edx, 8
+ jg vs_1_2_loop
+ }
}
@@ -1063,28 +1049,26 @@ void vertical_band_1_2_scale_mmx
static
void last_vertical_band_1_2_scale_mmx
(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-)
-{
- __asm
- {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
+ unsigned char *dest,
+ unsigned int dest_pitch,
+ unsigned int dest_width
+) {
+ __asm {
+ mov esi, dest // Get the source and destination pointer
+ mov ecx, dest_pitch // Get the pitch size
- mov edx, dest_width // Loop counter
+ mov edx, dest_width // Loop counter
- last_vs_1_2_loop:
+ last_vs_1_2_loop:
- movq mm0, [esi] // get Src[0]
- movq [esi+ecx], mm0 // write out eight bytes
+ movq mm0, [esi] // get Src[0]
+ movq [esi+ecx], mm0 // write out eight bytes
- add esi, 8
- sub edx, 8
+ add esi, 8
+ sub edx, 8
- jg last_vs_1_2_loop
- }
+ jg last_vs_1_2_loop
+ }
}
/****************************************************************************
@@ -1108,106 +1092,104 @@ void last_vertical_band_1_2_scale_mmx
static
void horizontal_line_1_2_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- (void) dest_width;
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ (void) dest_width;
- __asm
- {
- mov esi, source
- mov edi, dest
+ __asm {
+ mov esi, source
+ mov edi, dest
- pxor mm7, mm7
- movq mm6, four_ones
+ pxor mm7, mm7
+ movq mm6, four_ones
- mov ecx, source_width
+ mov ecx, source_width
- hs_1_2_loop:
+ hs_1_2_loop:
- movq mm0, [esi]
- movq mm1, [esi+1]
+ movq mm0, [esi]
+ movq mm1, [esi+1]
- movq mm2, mm0
- movq mm3, mm1
+ movq mm2, mm0
+ movq mm3, mm1
- movq mm4, mm0
- punpcklbw mm0, mm7
+ movq mm4, mm0
+ punpcklbw mm0, mm7
- punpcklbw mm1, mm7
- paddw mm0, mm1
+ punpcklbw mm1, mm7
+ paddw mm0, mm1
- paddw mm0, mm6
- punpckhbw mm2, mm7
+ paddw mm0, mm6
+ punpckhbw mm2, mm7
- punpckhbw mm3, mm7
- paddw mm2, mm3
+ punpckhbw mm3, mm7
+ paddw mm2, mm3
- paddw mm2, mm6
- psraw mm0, 1
+ paddw mm2, mm6
+ psraw mm0, 1
- psraw mm2, 1
- packuswb mm0, mm2
+ psraw mm2, 1
+ packuswb mm0, mm2
- movq mm2, mm4
- punpcklbw mm2, mm0
+ movq mm2, mm4
+ punpcklbw mm2, mm0
- movq [edi], mm2
- punpckhbw mm4, mm0
+ movq [edi], mm2
+ punpckhbw mm4, mm0
- movq [edi+8], mm4
- add esi, 8
+ movq [edi+8], mm4
+ add esi, 8
- add edi, 16
- sub ecx, 8
+ add edi, 16
+ sub ecx, 8
- cmp ecx, 8
- jg hs_1_2_loop
+ cmp ecx, 8
+ jg hs_1_2_loop
// last eight pixel
- movq mm0, [esi]
- movq mm1, mm0
+ movq mm0, [esi]
+ movq mm1, mm0
- movq mm2, mm0
- movq mm3, mm1
+ movq mm2, mm0
+ movq mm3, mm1
- psrlq mm1, 8
- psrlq mm3, 56
+ psrlq mm1, 8
+ psrlq mm3, 56
- psllq mm3, 56
- por mm1, mm3
+ psllq mm3, 56
+ por mm1, mm3
- movq mm3, mm1
- movq mm4, mm0
+ movq mm3, mm1
+ movq mm4, mm0
- punpcklbw mm0, mm7
- punpcklbw mm1, mm7
+ punpcklbw mm0, mm7
+ punpcklbw mm1, mm7
- paddw mm0, mm1
- paddw mm0, mm6
+ paddw mm0, mm1
+ paddw mm0, mm6
- punpckhbw mm2, mm7
- punpckhbw mm3, mm7
+ punpckhbw mm2, mm7
+ punpckhbw mm3, mm7
- paddw mm2, mm3
- paddw mm2, mm6
+ paddw mm2, mm3
+ paddw mm2, mm6
- psraw mm0, 1
- psraw mm2, 1
+ psraw mm0, 1
+ psraw mm2, 1
- packuswb mm0, mm2
- movq mm2, mm4
+ packuswb mm0, mm2
+ movq mm2, mm4
- punpcklbw mm2, mm0
- movq [edi], mm2
+ punpcklbw mm2, mm0
+ movq [edi], mm2
- punpckhbw mm4, mm0
- movq [edi+8], mm4
- }
+ punpckhbw mm4, mm0
+ movq [edi+8], mm4
+ }
}
@@ -1240,86 +1222,84 @@ __declspec(align(16)) const static unsigned short const54_1[] = {256, 192, 128,
static
void horizontal_line_5_4_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- /*
- unsigned i;
- unsigned int a, b, c, d, e;
- unsigned char *des = dest;
- const unsigned char *src = source;
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ /*
+ unsigned i;
+ unsigned int a, b, c, d, e;
+ unsigned char *des = dest;
+ const unsigned char *src = source;
- (void) dest_width;
+ (void) dest_width;
- for ( i=0; i<source_width; i+=5 )
- {
- a = src[0];
- b = src[1];
- c = src[2];
- d = src[3];
- e = src[4];
+ for ( i=0; i<source_width; i+=5 )
+ {
+ a = src[0];
+ b = src[1];
+ c = src[2];
+ d = src[3];
+ e = src[4];
- des[0] = a;
- des[1] = ((b*192 + c* 64 + 128)>>8);
- des[2] = ((c*128 + d*128 + 128)>>8);
- des[3] = ((d* 64 + e*192 + 128)>>8);
+ des[0] = a;
+ des[1] = ((b*192 + c* 64 + 128)>>8);
+ des[2] = ((c*128 + d*128 + 128)>>8);
+ des[3] = ((d* 64 + e*192 + 128)>>8);
- src += 5;
- des += 4;
- }
- */
- (void) dest_width;
+ src += 5;
+ des += 4;
+ }
+ */
+ (void) dest_width;
- __asm
- {
+ __asm {
- mov esi, source ;
- mov edi, dest ;
+ mov esi, source;
+ mov edi, dest;
- mov ecx, source_width ;
- movq mm5, const54_1 ;
+ mov ecx, source_width;
+ movq mm5, const54_1;
- pxor mm7, mm7 ;
- movq mm6, const54_2 ;
+ pxor mm7, mm7;
+ movq mm6, const54_2;
- movq mm4, round_values ;
- lea edx, [esi+ecx] ;
- horizontal_line_5_4_loop:
+ movq mm4, round_values;
+ lea edx, [esi+ecx];
+ horizontal_line_5_4_loop:
- movq mm0, QWORD PTR [esi] ;
- 00 01 02 03 04 05 06 07
- movq mm1, mm0 ;
- 00 01 02 03 04 05 06 07
+ movq mm0, QWORD PTR [esi];
+ 00 01 02 03 04 05 06 07
+ movq mm1, mm0;
+ 00 01 02 03 04 05 06 07
- psrlq mm0, 8 ;
- 01 02 03 04 05 06 07 xx
- punpcklbw mm1, mm7 ;
- xx 00 xx 01 xx 02 xx 03
+ psrlq mm0, 8;
+ 01 02 03 04 05 06 07 xx
+ punpcklbw mm1, mm7;
+ xx 00 xx 01 xx 02 xx 03
- punpcklbw mm0, mm7 ;
- xx 01 xx 02 xx 03 xx 04
- pmullw mm1, mm5
+ punpcklbw mm0, mm7;
+ xx 01 xx 02 xx 03 xx 04
+ pmullw mm1, mm5
- pmullw mm0, mm6
- add esi, 5
+ pmullw mm0, mm6
+ add esi, 5
- add edi, 4
- paddw mm1, mm0
+ add edi, 4
+ paddw mm1, mm0
- paddw mm1, mm4
- psrlw mm1, 8
+ paddw mm1, mm4
+ psrlw mm1, 8
- cmp esi, edx
- packuswb mm1, mm7
+ cmp esi, edx
+ packuswb mm1, mm7
- movd DWORD PTR [edi-4], mm1
+ movd DWORD PTR [edi-4], mm1
- jl horizontal_line_5_4_loop
+ jl horizontal_line_5_4_loop
- }
+ }
}
__declspec(align(16)) const static unsigned short one_fourths[] = { 64, 64, 64, 64 };
@@ -1327,86 +1307,84 @@ __declspec(align(16)) const static unsigned short two_fourths[] = { 128, 128,
__declspec(align(16)) const static unsigned short three_fourths[] = { 192, 192, 192, 192 };
static
-void vertical_band_5_4_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
+void vertical_band_5_4_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
- __asm
- {
- push ebx
+ __asm {
+ push ebx
- mov esi, source // Get the source and destination pointer
- mov ecx, src_pitch // Get the pitch size
+ mov esi, source // Get the source and destination pointer
+ mov ecx, src_pitch // Get the pitch size
- mov edi, dest // tow lines below
- pxor mm7, mm7 // clear out mm7
+ mov edi, dest // tow lines below
+ pxor mm7, mm7 // clear out mm7
- mov edx, dest_pitch // Loop counter
- mov ebx, dest_width
+ mov edx, dest_pitch // Loop counter
+ mov ebx, dest_width
- vs_5_4_loop:
+ vs_5_4_loop:
- movd mm0, DWORD ptr [esi] // src[0];
- movd mm1, DWORD ptr [esi+ecx] // src[1];
+ movd mm0, DWORD ptr [esi] // src[0];
+ movd mm1, DWORD ptr [esi+ecx] // src[1];
- movd mm2, DWORD ptr [esi+ecx*2]
- lea eax, [esi+ecx*2] //
+ movd mm2, DWORD ptr [esi+ecx*2]
+ lea eax, [esi+ecx*2] //
- punpcklbw mm1, mm7
- punpcklbw mm2, mm7
+ punpcklbw mm1, mm7
+ punpcklbw mm2, mm7
- movq mm3, mm2
- pmullw mm1, three_fourths
+ movq mm3, mm2
+ pmullw mm1, three_fourths
- pmullw mm2, one_fourths
- movd mm4, [eax+ecx]
+ pmullw mm2, one_fourths
+ movd mm4, [eax+ecx]
- pmullw mm3, two_fourths
- punpcklbw mm4, mm7
+ pmullw mm3, two_fourths
+ punpcklbw mm4, mm7
- movq mm5, mm4
- pmullw mm4, two_fourths
+ movq mm5, mm4
+ pmullw mm4, two_fourths
- paddw mm1, mm2
- movd mm6, [eax+ecx*2]
+ paddw mm1, mm2
+ movd mm6, [eax+ecx*2]
- pmullw mm5, one_fourths
- paddw mm1, round_values;
+ pmullw mm5, one_fourths
+ paddw mm1, round_values;
- paddw mm3, mm4
- psrlw mm1, 8
+ paddw mm3, mm4
+ psrlw mm1, 8
- punpcklbw mm6, mm7
- paddw mm3, round_values
+ punpcklbw mm6, mm7
+ paddw mm3, round_values
- pmullw mm6, three_fourths
- psrlw mm3, 8
+ pmullw mm6, three_fourths
+ psrlw mm3, 8
- packuswb mm1, mm7
- packuswb mm3, mm7
+ packuswb mm1, mm7
+ packuswb mm3, mm7
- movd DWORD PTR [edi], mm0
- movd DWORD PTR [edi+edx], mm1
+ movd DWORD PTR [edi], mm0
+ movd DWORD PTR [edi+edx], mm1
- paddw mm5, mm6
- movd DWORD PTR [edi+edx*2], mm3
+ paddw mm5, mm6
+ movd DWORD PTR [edi+edx*2], mm3
- lea eax, [edi+edx*2]
- paddw mm5, round_values
+ lea eax, [edi+edx*2]
+ paddw mm5, round_values
- psrlw mm5, 8
- add edi, 4
+ psrlw mm5, 8
+ add edi, 4
- packuswb mm5, mm7
- movd DWORD PTR [eax+edx], mm5
+ packuswb mm5, mm7
+ movd DWORD PTR [eax+edx], mm5
- add esi, 4
- sub ebx, 4
+ add esi, 4
+ sub ebx, 4
- jg vs_5_4_loop
+ jg vs_5_4_loop
- pop ebx
- }
+ pop ebx
+ }
}
@@ -1417,96 +1395,94 @@ __declspec(align(16)) const static unsigned short const53_2[] = {256, 171, 85,
static
void horizontal_line_5_3_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
- (void) dest_width;
- __asm
- {
+ (void) dest_width;
+ __asm {
- mov esi, source ;
- mov edi, dest ;
+ mov esi, source;
+ mov edi, dest;
- mov ecx, source_width ;
- movq mm5, const53_1 ;
+ mov ecx, source_width;
+ movq mm5, const53_1;
- pxor mm7, mm7 ;
- movq mm6, const53_2 ;
+ pxor mm7, mm7;
+ movq mm6, const53_2;
- movq mm4, round_values ;
- lea edx, [esi+ecx-5] ;
- horizontal_line_5_3_loop:
+ movq mm4, round_values;
+ lea edx, [esi+ecx-5];
+ horizontal_line_5_3_loop:
- movq mm0, QWORD PTR [esi] ;
- 00 01 02 03 04 05 06 07
- movq mm1, mm0 ;
- 00 01 02 03 04 05 06 07
+ movq mm0, QWORD PTR [esi];
+ 00 01 02 03 04 05 06 07
+ movq mm1, mm0;
+ 00 01 02 03 04 05 06 07
- psllw mm0, 8 ;
- xx 00 xx 02 xx 04 xx 06
- psrlw mm1, 8 ;
- 01 xx 03 xx 05 xx 07 xx
+ psllw mm0, 8;
+ xx 00 xx 02 xx 04 xx 06
+ psrlw mm1, 8;
+ 01 xx 03 xx 05 xx 07 xx
- psrlw mm0, 8 ;
- 00 xx 02 xx 04 xx 06 xx
- psllq mm1, 16 ;
- xx xx 01 xx 03 xx 05 xx
+ psrlw mm0, 8;
+ 00 xx 02 xx 04 xx 06 xx
+ psllq mm1, 16;
+ xx xx 01 xx 03 xx 05 xx
- pmullw mm0, mm6
+ pmullw mm0, mm6
- pmullw mm1, mm5
- add esi, 5
+ pmullw mm1, mm5
+ add esi, 5
- add edi, 3
- paddw mm1, mm0
+ add edi, 3
+ paddw mm1, mm0
- paddw mm1, mm4
- psrlw mm1, 8
+ paddw mm1, mm4
+ psrlw mm1, 8
- cmp esi, edx
- packuswb mm1, mm7
+ cmp esi, edx
+ packuswb mm1, mm7
- movd DWORD PTR [edi-3], mm1
- jl horizontal_line_5_3_loop
+ movd DWORD PTR [edi-3], mm1
+ jl horizontal_line_5_3_loop
-//exit condition
- movq mm0, QWORD PTR [esi] ;
- 00 01 02 03 04 05 06 07
- movq mm1, mm0 ;
- 00 01 02 03 04 05 06 07
+// exit condition
+ movq mm0, QWORD PTR [esi];
+ 00 01 02 03 04 05 06 07
+ movq mm1, mm0;
+ 00 01 02 03 04 05 06 07
- psllw mm0, 8 ;
- xx 00 xx 02 xx 04 xx 06
- psrlw mm1, 8 ;
- 01 xx 03 xx 05 xx 07 xx
+ psllw mm0, 8;
+ xx 00 xx 02 xx 04 xx 06
+ psrlw mm1, 8;
+ 01 xx 03 xx 05 xx 07 xx
- psrlw mm0, 8 ;
- 00 xx 02 xx 04 xx 06 xx
- psllq mm1, 16 ;
- xx xx 01 xx 03 xx 05 xx
+ psrlw mm0, 8;
+ 00 xx 02 xx 04 xx 06 xx
+ psllq mm1, 16;
+ xx xx 01 xx 03 xx 05 xx
- pmullw mm0, mm6
+ pmullw mm0, mm6
- pmullw mm1, mm5
- paddw mm1, mm0
+ pmullw mm1, mm5
+ paddw mm1, mm0
- paddw mm1, mm4
- psrlw mm1, 8
+ paddw mm1, mm4
+ psrlw mm1, 8
- packuswb mm1, mm7
- movd eax, mm1
+ packuswb mm1, mm7
+ movd eax, mm1
- mov edx, eax
- shr edx, 16
+ mov edx, eax
+ shr edx, 16
- mov WORD PTR[edi], ax
- mov BYTE PTR[edi+2], dl
+ mov WORD PTR[edi], ax
+ mov BYTE PTR[edi+2], dl
- }
+ }
}
@@ -1514,75 +1490,73 @@ __declspec(align(16)) const static unsigned short one_thirds[] = { 85, 85, 85
__declspec(align(16)) const static unsigned short two_thirds[] = { 171, 171, 171, 171 };
static
-void vertical_band_5_3_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
+void vertical_band_5_3_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
- __asm
- {
- push ebx
+ __asm {
+ push ebx
- mov esi, source // Get the source and destination pointer
- mov ecx, src_pitch // Get the pitch size
+ mov esi, source // Get the source and destination pointer
+ mov ecx, src_pitch // Get the pitch size
- mov edi, dest // tow lines below
- pxor mm7, mm7 // clear out mm7
+ mov edi, dest // tow lines below
+ pxor mm7, mm7 // clear out mm7
- mov edx, dest_pitch // Loop counter
- movq mm5, one_thirds
+ mov edx, dest_pitch // Loop counter
+ movq mm5, one_thirds
- movq mm6, two_thirds
- mov ebx, dest_width;
+ movq mm6, two_thirds
+ mov ebx, dest_width;
- vs_5_3_loop:
+ vs_5_3_loop:
- movd mm0, DWORD ptr [esi] // src[0];
- movd mm1, DWORD ptr [esi+ecx] // src[1];
+ movd mm0, DWORD ptr [esi] // src[0];
+ movd mm1, DWORD ptr [esi+ecx] // src[1];
- movd mm2, DWORD ptr [esi+ecx*2]
- lea eax, [esi+ecx*2] //
+ movd mm2, DWORD ptr [esi+ecx*2]
+ lea eax, [esi+ecx*2] //
- punpcklbw mm1, mm7
- punpcklbw mm2, mm7
+ punpcklbw mm1, mm7
+ punpcklbw mm2, mm7
- pmullw mm1, mm5
- pmullw mm2, mm6
+ pmullw mm1, mm5
+ pmullw mm2, mm6
- movd mm3, DWORD ptr [eax+ecx]
- movd mm4, DWORD ptr [eax+ecx*2]
+ movd mm3, DWORD ptr [eax+ecx]
+ movd mm4, DWORD ptr [eax+ecx*2]
- punpcklbw mm3, mm7
- punpcklbw mm4, mm7
+ punpcklbw mm3, mm7
+ punpcklbw mm4, mm7
- pmullw mm3, mm6
- pmullw mm4, mm5
+ pmullw mm3, mm6
+ pmullw mm4, mm5
- movd DWORD PTR [edi], mm0
- paddw mm1, mm2
+ movd DWORD PTR [edi], mm0
+ paddw mm1, mm2
- paddw mm1, round_values
- psrlw mm1, 8
+ paddw mm1, round_values
+ psrlw mm1, 8
- packuswb mm1, mm7
- paddw mm3, mm4
+ packuswb mm1, mm7
+ paddw mm3, mm4
- paddw mm3, round_values
- movd DWORD PTR [edi+edx], mm1
+ paddw mm3, round_values
+ movd DWORD PTR [edi+edx], mm1
- psrlw mm3, 8
- packuswb mm3, mm7
+ psrlw mm3, 8
+ packuswb mm3, mm7
- movd DWORD PTR [edi+edx*2], mm3
+ movd DWORD PTR [edi+edx*2], mm3
- add edi, 4
- add esi, 4
+ add edi, 4
+ add esi, 4
- sub ebx, 4
- jg vs_5_3_loop
+ sub ebx, 4
+ jg vs_5_3_loop
- pop ebx
- }
+ pop ebx
+ }
}
@@ -1609,48 +1583,45 @@ void vertical_band_5_3_scale_mmx(unsigned char *source, unsigned int src_pitch,
static
void horizontal_line_2_1_scale_mmx
(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-)
-{
- (void) dest_width;
- (void) source_width;
- __asm
- {
- mov esi, source
- mov edi, dest
-
- pxor mm7, mm7
- mov ecx, dest_width
-
- xor edx, edx
- hs_2_1_loop:
-
- movq mm0, [esi+edx*2]
- psllw mm0, 8
-
- psrlw mm0, 8
- packuswb mm0, mm7
-
- movd DWORD Ptr [edi+edx], mm0;
- add edx, 4
-
- cmp edx, ecx
- jl hs_2_1_loop
-
- }
+ const unsigned char *source,
+ unsigned int source_width,
+ unsigned char *dest,
+ unsigned int dest_width
+) {
+ (void) dest_width;
+ (void) source_width;
+ __asm {
+ mov esi, source
+ mov edi, dest
+
+ pxor mm7, mm7
+ mov ecx, dest_width
+
+ xor edx, edx
+ hs_2_1_loop:
+
+ movq mm0, [esi+edx*2]
+ psllw mm0, 8
+
+ psrlw mm0, 8
+ packuswb mm0, mm7
+
+ movd DWORD Ptr [edi+edx], mm0;
+ add edx, 4
+
+ cmp edx, ecx
+ jl hs_2_1_loop
+
+ }
}
static
-void vertical_band_2_1_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
- (void) dest_pitch;
- (void) src_pitch;
- vpx_memcpy(dest, source, dest_width);
+void vertical_band_2_1_scale_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
+ (void) dest_pitch;
+ (void) src_pitch;
+ vpx_memcpy(dest, source, dest_width);
}
@@ -1658,91 +1629,88 @@ __declspec(align(16)) const static unsigned short three_sixteenths[] = { 48, 4
__declspec(align(16)) const static unsigned short ten_sixteenths[] = { 160, 160, 160, 160 };
static
-void vertical_band_2_1_scale_i_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
-{
+void vertical_band_2_1_scale_i_mmx(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width) {
- (void) dest_pitch;
- __asm
- {
- mov esi, source
- mov edi, dest
+ (void) dest_pitch;
+ __asm {
+ mov esi, source
+ mov edi, dest
- mov eax, src_pitch
- mov edx, dest_width
+ mov eax, src_pitch
+ mov edx, dest_width
- pxor mm7, mm7
- sub esi, eax //back one line
+ pxor mm7, mm7
+ sub esi, eax // back one line
- lea ecx, [esi+edx];
- movq mm6, round_values;
+ lea ecx, [esi+edx];
+ movq mm6, round_values;
- movq mm5, three_sixteenths;
- movq mm4, ten_sixteenths;
+ movq mm5, three_sixteenths;
+ movq mm4, ten_sixteenths;
- vs_2_1_i_loop:
- movd mm0, [esi] //
- movd mm1, [esi+eax] //
+ vs_2_1_i_loop:
+ movd mm0, [esi] //
+ movd mm1, [esi+eax] //
- movd mm2, [esi+eax*2] //
- punpcklbw mm0, mm7
+ movd mm2, [esi+eax*2] //
+ punpcklbw mm0, mm7
- pmullw mm0, mm5
- punpcklbw mm1, mm7
+ pmullw mm0, mm5
+ punpcklbw mm1, mm7
- pmullw mm1, mm4
- punpcklbw mm2, mm7
+ pmullw mm1, mm4
+ punpcklbw mm2, mm7
- pmullw mm2, mm5
- paddw mm0, round_values
+ pmullw mm2, mm5
+ paddw mm0, round_values
- paddw mm1, mm2
- paddw mm0, mm1
+ paddw mm1, mm2
+ paddw mm0, mm1
- psrlw mm0, 8
- packuswb mm0, mm7
+ psrlw mm0, 8
+ packuswb mm0, mm7
- movd DWORD PTR [edi], mm0
- add esi, 4
+ movd DWORD PTR [edi], mm0
+ add esi, 4
- add edi, 4;
- cmp esi, ecx
- jl vs_2_1_i_loop
+ add edi, 4;
+ cmp esi, ecx
+ jl vs_2_1_i_loop
- }
+ }
}
void
-register_mmxscalers(void)
-{
- vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_mmx;
- vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_mmx;
- vp8_last_vertical_band_1_2_scale = last_vertical_band_1_2_scale_mmx;
- vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_mmx;
- vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_mmx;
- vp8_last_vertical_band_3_5_scale = last_vertical_band_3_5_scale_mmx;
- vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_mmx;
- vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_mmx;
- vp8_last_vertical_band_4_5_scale = last_vertical_band_4_5_scale_mmx;
-
- vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
- vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
- vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
- vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
- vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
- vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
-
-
-
- vp8_vertical_band_5_4_scale = vertical_band_5_4_scale_mmx;
- vp8_vertical_band_5_3_scale = vertical_band_5_3_scale_mmx;
- vp8_vertical_band_2_1_scale = vertical_band_2_1_scale_mmx;
- vp8_vertical_band_2_1_scale_i = vertical_band_2_1_scale_i_mmx;
- vp8_horizontal_line_2_1_scale = horizontal_line_2_1_scale_mmx;
- vp8_horizontal_line_5_3_scale = horizontal_line_5_3_scale_mmx;
- vp8_horizontal_line_5_4_scale = horizontal_line_5_4_scale_mmx;
+register_mmxscalers(void) {
+ vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_mmx;
+ vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_mmx;
+ vp8_last_vertical_band_1_2_scale = last_vertical_band_1_2_scale_mmx;
+ vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_mmx;
+ vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_mmx;
+ vp8_last_vertical_band_3_5_scale = last_vertical_band_3_5_scale_mmx;
+ vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_mmx;
+ vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_mmx;
+ vp8_last_vertical_band_4_5_scale = last_vertical_band_4_5_scale_mmx;
+
+ vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
+ vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
+ vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
+ vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
+ vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
+ vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
+
+
+
+ vp8_vertical_band_5_4_scale = vertical_band_5_4_scale_mmx;
+ vp8_vertical_band_5_3_scale = vertical_band_5_3_scale_mmx;
+ vp8_vertical_band_2_1_scale = vertical_band_2_1_scale_mmx;
+ vp8_vertical_band_2_1_scale_i = vertical_band_2_1_scale_i_mmx;
+ vp8_horizontal_line_2_1_scale = horizontal_line_2_1_scale_mmx;
+ vp8_horizontal_line_5_3_scale = horizontal_line_5_3_scale_mmx;
+ vp8_horizontal_line_5_4_scale = horizontal_line_5_4_scale_mmx;
diff --git a/vpx_scale/win32/scalesystemdependent.c b/vpx_scale/win32/scalesystemdependent.c
index 19e61c3a5..98913d19a 100644
--- a/vpx_scale/win32/scalesystemdependent.c
+++ b/vpx_scale/win32/scalesystemdependent.c
@@ -46,46 +46,42 @@ extern void register_mmxscalers(void);
*
****************************************************************************/
void
-vp8_scale_machine_specific_config(void)
-{
- // If MMX supported then set to use MMX versions of functions else
- // use original 'C' versions.
- int mmx_enabled;
- int xmm_enabled;
- int wmt_enabled;
+vp8_scale_machine_specific_config(void) {
+ // If MMX supported then set to use MMX versions of functions else
+ // use original 'C' versions.
+ int mmx_enabled;
+ int xmm_enabled;
+ int wmt_enabled;
- vpx_get_processor_flags(&mmx_enabled, &xmm_enabled, &wmt_enabled);
+ vpx_get_processor_flags(&mmx_enabled, &xmm_enabled, &wmt_enabled);
- if (mmx_enabled || xmm_enabled || wmt_enabled)
- {
- register_mmxscalers();
- }
- else
- {
- vp8_horizontal_line_1_2_scale = vp8cx_horizontal_line_1_2_scale_c;
- vp8_vertical_band_1_2_scale = vp8cx_vertical_band_1_2_scale_c;
- vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
- vp8_horizontal_line_3_5_scale = vp8cx_horizontal_line_3_5_scale_c;
- vp8_vertical_band_3_5_scale = vp8cx_vertical_band_3_5_scale_c;
- vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
- vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
- vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
- vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
- vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
- vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
- vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
- vp8_horizontal_line_4_5_scale = vp8cx_horizontal_line_4_5_scale_c;
- vp8_vertical_band_4_5_scale = vp8cx_vertical_band_4_5_scale_c;
- vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
+ if (mmx_enabled || xmm_enabled || wmt_enabled) {
+ register_mmxscalers();
+ } else {
+ vp8_horizontal_line_1_2_scale = vp8cx_horizontal_line_1_2_scale_c;
+ vp8_vertical_band_1_2_scale = vp8cx_vertical_band_1_2_scale_c;
+ vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
+ vp8_horizontal_line_3_5_scale = vp8cx_horizontal_line_3_5_scale_c;
+ vp8_vertical_band_3_5_scale = vp8cx_vertical_band_3_5_scale_c;
+ vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
+ vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
+ vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
+ vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
+ vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
+ vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
+ vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
+ vp8_horizontal_line_4_5_scale = vp8cx_horizontal_line_4_5_scale_c;
+ vp8_vertical_band_4_5_scale = vp8cx_vertical_band_4_5_scale_c;
+ vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
- vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
- vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
- vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
- vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
- vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
- vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
- vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
+ vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
+ vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
+ vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
+ vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
+ vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
+ vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
+ vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
- }
+ }
}
diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h
index e78046720..1c18b098a 100644
--- a/vpx_scale/yv12config.h
+++ b/vpx_scale/yv12config.h
@@ -26,51 +26,50 @@ extern "C"
#define INTERP_EXTEND 3
#endif
- /*************************************
- For INT_YUV:
+ /*************************************
+ For INT_YUV:
- Y = (R+G*2+B)/4;
- U = (R-B)/2;
- V = (G*2 - R - B)/4;
- And
- R = Y+U-V;
- G = Y+V;
- B = Y-U-V;
- ************************************/
- typedef enum
- {
- REG_YUV = 0, /* Regular yuv */
- INT_YUV = 1 /* The type of yuv that can be tranfer to and from RGB through integer transform */
- }
- YUV_TYPE;
+ Y = (R+G*2+B)/4;
+ U = (R-B)/2;
+ V = (G*2 - R - B)/4;
+ And
+ R = Y+U-V;
+ G = Y+V;
+ B = Y-U-V;
+ ************************************/
+ typedef enum
+ {
+ REG_YUV = 0, /* Regular yuv */
+ INT_YUV = 1 /* The type of yuv that can be tranfer to and from RGB through integer transform */
+ }
+ YUV_TYPE;
- typedef struct
- {
- int y_width;
- int y_height;
- int y_stride;
-/* int yinternal_width; */
+ typedef struct {
+ int y_width;
+ int y_height;
+ int y_stride;
+ /* int yinternal_width; */
- int uv_width;
- int uv_height;
- int uv_stride;
-/* int uvinternal_width; */
+ int uv_width;
+ int uv_height;
+ int uv_stride;
+ /* int uvinternal_width; */
- unsigned char *y_buffer;
- unsigned char *u_buffer;
- unsigned char *v_buffer;
+ unsigned char *y_buffer;
+ unsigned char *u_buffer;
+ unsigned char *v_buffer;
- unsigned char *buffer_alloc;
- int border;
- int frame_size;
- YUV_TYPE clrtype;
+ unsigned char *buffer_alloc;
+ int border;
+ int frame_size;
+ YUV_TYPE clrtype;
- int corrupted;
- int flags;
- } YV12_BUFFER_CONFIG;
+ int corrupted;
+ int flags;
+ } YV12_BUFFER_CONFIG;
- int vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border);
- int vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf);
+ int vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border);
+ int vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf);
#ifdef __cplusplus
}
diff --git a/vpx_scale/yv12extend.h b/vpx_scale/yv12extend.h
index 0c239b9d1..c7fcedf21 100644
--- a/vpx_scale/yv12extend.h
+++ b/vpx_scale/yv12extend.h
@@ -19,12 +19,12 @@ extern "C"
{
#endif
- void vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf);
+ void vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf);
- /* Copy Y,U,V buffer data from src to dst, filling border of dst as well. */
+ /* Copy Y,U,V buffer data from src to dst, filling border of dst as well. */
- void vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
- void vp8_yv12_copy_frame_yonly(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
+ void vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
+ void vp8_yv12_copy_frame_yonly(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
#ifdef __cplusplus
}
diff --git a/vpxdec.c b/vpxdec.c
index 359cd2431..1bcc8e5b3 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -49,168 +49,158 @@
static const char *exec_name;
#define VP8_FOURCC (0x00385056)
-static const struct
-{
- char const *name;
- const vpx_codec_iface_t *iface;
- unsigned int fourcc;
- unsigned int fourcc_mask;
-} ifaces[] =
-{
+static const struct {
+ char const *name;
+ const vpx_codec_iface_t *iface;
+ unsigned int fourcc;
+ unsigned int fourcc_mask;
+} ifaces[] = {
#if CONFIG_VP8_DECODER
- {"vp8", &vpx_codec_vp8_dx_algo, VP8_FOURCC, 0x00FFFFFF},
+ {"vp8", &vpx_codec_vp8_dx_algo, VP8_FOURCC, 0x00FFFFFF},
#endif
};
#include "args.h"
static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1,
- "Codec to use");
+ "Codec to use");
static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0,
- "Output raw YV12 frames");
+ "Output raw YV12 frames");
static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0,
- "Output raw I420 frames");
+ "Output raw I420 frames");
static const arg_def_t flipuvarg = ARG_DEF(NULL, "flipuv", 0,
- "Flip the chroma planes in the output");
+ "Flip the chroma planes in the output");
static const arg_def_t noblitarg = ARG_DEF(NULL, "noblit", 0,
- "Don't process the decoded frames");
+ "Don't process the decoded frames");
static const arg_def_t progressarg = ARG_DEF(NULL, "progress", 0,
- "Show progress after each frame decodes");
+ "Show progress after each frame decodes");
static const arg_def_t limitarg = ARG_DEF(NULL, "limit", 1,
- "Stop decoding after n frames");
+ "Stop decoding after n frames");
static const arg_def_t postprocarg = ARG_DEF(NULL, "postproc", 0,
- "Postprocess decoded frames");
+ "Postprocess decoded frames");
static const arg_def_t summaryarg = ARG_DEF(NULL, "summary", 0,
- "Show timing summary");
+ "Show timing summary");
static const arg_def_t outputfile = ARG_DEF("o", "output", 1,
- "Output file name pattern (see below)");
+ "Output file name pattern (see below)");
static const arg_def_t threadsarg = ARG_DEF("t", "threads", 1,
- "Max threads to use");
+ "Max threads to use");
static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0,
- "Show version string");
+ "Show version string");
#if CONFIG_MD5
static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0,
"Compute the MD5 sum of the decoded frame");
#endif
-static const arg_def_t *all_args[] =
-{
- &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg,
- &progressarg, &limitarg, &postprocarg, &summaryarg, &outputfile,
- &threadsarg, &verbosearg,
+static const arg_def_t *all_args[] = {
+ &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg,
+ &progressarg, &limitarg, &postprocarg, &summaryarg, &outputfile,
+ &threadsarg, &verbosearg,
#if CONFIG_MD5
- &md5arg,
+ &md5arg,
#endif
- NULL
+ NULL
};
#if CONFIG_VP8_DECODER
static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1,
- "Enable VP8 postproc add noise");
+ "Enable VP8 postproc add noise");
static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0,
- "Enable VP8 deblocking");
+ "Enable VP8 deblocking");
static const arg_def_t demacroblock_level = ARG_DEF(NULL, "demacroblock-level", 1,
- "Enable VP8 demacroblocking, w/ level");
+ "Enable VP8 demacroblocking, w/ level");
static const arg_def_t pp_debug_info = ARG_DEF(NULL, "pp-debug-info", 1,
- "Enable VP8 visible debug info");
+ "Enable VP8 visible debug info");
static const arg_def_t pp_disp_ref_frame = ARG_DEF(NULL, "pp-dbg-ref-frame", 1,
- "Display only selected reference frame per macro block");
+ "Display only selected reference frame per macro block");
static const arg_def_t pp_disp_mb_modes = ARG_DEF(NULL, "pp-dbg-mb-modes", 1,
- "Display only selected macro block modes");
+ "Display only selected macro block modes");
static const arg_def_t pp_disp_b_modes = ARG_DEF(NULL, "pp-dbg-b-modes", 1,
- "Display only selected block modes");
+ "Display only selected block modes");
static const arg_def_t pp_disp_mvs = ARG_DEF(NULL, "pp-dbg-mvs", 1,
- "Draw only selected motion vectors");
+ "Draw only selected motion vectors");
-static const arg_def_t *vp8_pp_args[] =
-{
- &addnoise_level, &deblock, &demacroblock_level, &pp_debug_info,
- &pp_disp_ref_frame, &pp_disp_mb_modes, &pp_disp_b_modes, &pp_disp_mvs,
- NULL
+static const arg_def_t *vp8_pp_args[] = {
+ &addnoise_level, &deblock, &demacroblock_level, &pp_debug_info,
+ &pp_disp_ref_frame, &pp_disp_mb_modes, &pp_disp_b_modes, &pp_disp_mvs,
+ NULL
};
#endif
-static void usage_exit()
-{
- int i;
+static void usage_exit() {
+ int i;
- fprintf(stderr, "Usage: %s <options> filename\n\n"
- "Options:\n", exec_name);
- arg_show_usage(stderr, all_args);
+ fprintf(stderr, "Usage: %s <options> filename\n\n"
+ "Options:\n", exec_name);
+ arg_show_usage(stderr, all_args);
#if CONFIG_VP8_DECODER
- fprintf(stderr, "\nVP8 Postprocessing Options:\n");
- arg_show_usage(stderr, vp8_pp_args);
+ fprintf(stderr, "\nVP8 Postprocessing Options:\n");
+ arg_show_usage(stderr, vp8_pp_args);
#endif
- fprintf(stderr,
- "\nOutput File Patterns:\n\n"
- " The -o argument specifies the name of the file(s) to "
- "write to. If the\n argument does not include any escape "
- "characters, the output will be\n written to a single file. "
- "Otherwise, the filename will be calculated by\n expanding "
- "the following escape characters:\n"
- "\n\t%%w - Frame width"
- "\n\t%%h - Frame height"
- "\n\t%%<n> - Frame number, zero padded to <n> places (1..9)"
- "\n\n Pattern arguments are only supported in conjunction "
- "with the --yv12 and\n --i420 options. If the -o option is "
- "not specified, the output will be\n directed to stdout.\n"
- );
- fprintf(stderr, "\nIncluded decoders:\n\n");
-
- for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
- fprintf(stderr, " %-6s - %s\n",
- ifaces[i].name,
- vpx_codec_iface_name(ifaces[i].iface));
-
- exit(EXIT_FAILURE);
+ fprintf(stderr,
+ "\nOutput File Patterns:\n\n"
+ " The -o argument specifies the name of the file(s) to "
+ "write to. If the\n argument does not include any escape "
+ "characters, the output will be\n written to a single file. "
+ "Otherwise, the filename will be calculated by\n expanding "
+ "the following escape characters:\n"
+ "\n\t%%w - Frame width"
+ "\n\t%%h - Frame height"
+ "\n\t%%<n> - Frame number, zero padded to <n> places (1..9)"
+ "\n\n Pattern arguments are only supported in conjunction "
+ "with the --yv12 and\n --i420 options. If the -o option is "
+ "not specified, the output will be\n directed to stdout.\n"
+ );
+ fprintf(stderr, "\nIncluded decoders:\n\n");
+
+ for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
+ fprintf(stderr, " %-6s - %s\n",
+ ifaces[i].name,
+ vpx_codec_iface_name(ifaces[i].iface));
+
+ exit(EXIT_FAILURE);
}
-void die(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- usage_exit();
+void die(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ usage_exit();
}
-static unsigned int mem_get_le16(const void *vmem)
-{
- unsigned int val;
- const unsigned char *mem = (const unsigned char *)vmem;
+static unsigned int mem_get_le16(const void *vmem) {
+ unsigned int val;
+ const unsigned char *mem = (const unsigned char *)vmem;
- val = mem[1] << 8;
- val |= mem[0];
- return val;
+ val = mem[1] << 8;
+ val |= mem[0];
+ return val;
}
-static unsigned int mem_get_le32(const void *vmem)
-{
- unsigned int val;
- const unsigned char *mem = (const unsigned char *)vmem;
+static unsigned int mem_get_le32(const void *vmem) {
+ unsigned int val;
+ const unsigned char *mem = (const unsigned char *)vmem;
- val = mem[3] << 24;
- val |= mem[2] << 16;
- val |= mem[1] << 8;
- val |= mem[0];
- return val;
+ val = mem[3] << 24;
+ val |= mem[2] << 16;
+ val |= mem[1] << 8;
+ val |= mem[0];
+ return val;
}
-enum file_kind
-{
- RAW_FILE,
- IVF_FILE,
- WEBM_FILE
+enum file_kind {
+ RAW_FILE,
+ IVF_FILE,
+ WEBM_FILE
};
-struct input_ctx
-{
- enum file_kind kind;
- FILE *infile;
- nestegg *nestegg_ctx;
- nestegg_packet *pkt;
- unsigned int chunk;
- unsigned int chunks;
- unsigned int video_track;
+struct input_ctx {
+ enum file_kind kind;
+ FILE *infile;
+ nestegg *nestegg_ctx;
+ nestegg_packet *pkt;
+ unsigned int chunk;
+ unsigned int chunks;
+ unsigned int video_track;
};
#define IVF_FRAME_HDR_SZ (sizeof(uint32_t) + sizeof(uint64_t))
@@ -218,163 +208,136 @@ struct input_ctx
static int read_frame(struct input_ctx *input,
uint8_t **buf,
size_t *buf_sz,
- size_t *buf_alloc_sz)
-{
- char raw_hdr[IVF_FRAME_HDR_SZ];
- size_t new_buf_sz;
- FILE *infile = input->infile;
- enum file_kind kind = input->kind;
- if(kind == WEBM_FILE)
- {
- if(input->chunk >= input->chunks)
- {
- unsigned int track;
-
- do
- {
- /* End of this packet, get another. */
- if(input->pkt)
- nestegg_free_packet(input->pkt);
-
- if(nestegg_read_packet(input->nestegg_ctx, &input->pkt) <= 0
- || nestegg_packet_track(input->pkt, &track))
- return 1;
-
- } while(track != input->video_track);
-
- if(nestegg_packet_count(input->pkt, &input->chunks))
- return 1;
- input->chunk = 0;
- }
+ size_t *buf_alloc_sz) {
+ char raw_hdr[IVF_FRAME_HDR_SZ];
+ size_t new_buf_sz;
+ FILE *infile = input->infile;
+ enum file_kind kind = input->kind;
+ if (kind == WEBM_FILE) {
+ if (input->chunk >= input->chunks) {
+ unsigned int track;
+
+ do {
+ /* End of this packet, get another. */
+ if (input->pkt)
+ nestegg_free_packet(input->pkt);
+
+ if (nestegg_read_packet(input->nestegg_ctx, &input->pkt) <= 0
+ || nestegg_packet_track(input->pkt, &track))
+ return 1;
+
+ } while (track != input->video_track);
+
+ if (nestegg_packet_count(input->pkt, &input->chunks))
+ return 1;
+ input->chunk = 0;
+ }
- if(nestegg_packet_data(input->pkt, input->chunk, buf, buf_sz))
- return 1;
- input->chunk++;
+ if (nestegg_packet_data(input->pkt, input->chunk, buf, buf_sz))
+ return 1;
+ input->chunk++;
- return 0;
+ return 0;
+ }
+ /* For both the raw and ivf formats, the frame size is the first 4 bytes
+ * of the frame header. We just need to special case on the header
+ * size.
+ */
+ else if (fread(raw_hdr, kind == IVF_FILE
+ ? IVF_FRAME_HDR_SZ : RAW_FRAME_HDR_SZ, 1, infile) != 1) {
+ if (!feof(infile))
+ fprintf(stderr, "Failed to read frame size\n");
+
+ new_buf_sz = 0;
+ } else {
+ new_buf_sz = mem_get_le32(raw_hdr);
+
+ if (new_buf_sz > 256 * 1024 * 1024) {
+ fprintf(stderr, "Error: Read invalid frame size (%u)\n",
+ (unsigned int)new_buf_sz);
+ new_buf_sz = 0;
}
- /* For both the raw and ivf formats, the frame size is the first 4 bytes
- * of the frame header. We just need to special case on the header
- * size.
- */
- else if (fread(raw_hdr, kind==IVF_FILE
- ? IVF_FRAME_HDR_SZ : RAW_FRAME_HDR_SZ, 1, infile) != 1)
- {
- if (!feof(infile))
- fprintf(stderr, "Failed to read frame size\n");
- new_buf_sz = 0;
- }
- else
- {
- new_buf_sz = mem_get_le32(raw_hdr);
-
- if (new_buf_sz > 256 * 1024 * 1024)
- {
- fprintf(stderr, "Error: Read invalid frame size (%u)\n",
- (unsigned int)new_buf_sz);
- new_buf_sz = 0;
- }
+ if (kind == RAW_FILE && new_buf_sz > 256 * 1024)
+ fprintf(stderr, "Warning: Read invalid frame size (%u)"
+ " - not a raw file?\n", (unsigned int)new_buf_sz);
- if (kind == RAW_FILE && new_buf_sz > 256 * 1024)
- fprintf(stderr, "Warning: Read invalid frame size (%u)"
- " - not a raw file?\n", (unsigned int)new_buf_sz);
-
- if (new_buf_sz > *buf_alloc_sz)
- {
- uint8_t *new_buf = realloc(*buf, 2 * new_buf_sz);
-
- if (new_buf)
- {
- *buf = new_buf;
- *buf_alloc_sz = 2 * new_buf_sz;
- }
- else
- {
- fprintf(stderr, "Failed to allocate compressed data buffer\n");
- new_buf_sz = 0;
- }
- }
- }
+ if (new_buf_sz > *buf_alloc_sz) {
+ uint8_t *new_buf = realloc(*buf, 2 * new_buf_sz);
- *buf_sz = new_buf_sz;
+ if (new_buf) {
+ *buf = new_buf;
+ *buf_alloc_sz = 2 * new_buf_sz;
+ } else {
+ fprintf(stderr, "Failed to allocate compressed data buffer\n");
+ new_buf_sz = 0;
+ }
+ }
+ }
- if (*buf_sz)
- {
- if (fread(*buf, 1, *buf_sz, infile) != *buf_sz)
- {
- fprintf(stderr, "Failed to read full frame\n");
- return 1;
- }
+ *buf_sz = new_buf_sz;
- return 0;
+ if (*buf_sz) {
+ if (fread(*buf, 1, *buf_sz, infile) != *buf_sz) {
+ fprintf(stderr, "Failed to read full frame\n");
+ return 1;
}
- return 1;
+ return 0;
+ }
+
+ return 1;
}
-void *out_open(const char *out_fn, int do_md5)
-{
- void *out = NULL;
+void *out_open(const char *out_fn, int do_md5) {
+ void *out = NULL;
- if (do_md5)
- {
+ if (do_md5) {
#if CONFIG_MD5
- MD5Context *md5_ctx = out = malloc(sizeof(MD5Context));
- (void)out_fn;
- MD5Init(md5_ctx);
+ MD5Context *md5_ctx = out = malloc(sizeof(MD5Context));
+ (void)out_fn;
+ MD5Init(md5_ctx);
#endif
+ } else {
+ FILE *outfile = out = strcmp("-", out_fn) ? fopen(out_fn, "wb")
+ : set_binary_mode(stdout);
+
+ if (!outfile) {
+ fprintf(stderr, "Failed to output file");
+ exit(EXIT_FAILURE);
}
- else
- {
- FILE *outfile = out = strcmp("-", out_fn) ? fopen(out_fn, "wb")
- : set_binary_mode(stdout);
-
- if (!outfile)
- {
- fprintf(stderr, "Failed to output file");
- exit(EXIT_FAILURE);
- }
- }
+ }
- return out;
+ return out;
}
-void out_put(void *out, const uint8_t *buf, unsigned int len, int do_md5)
-{
- if (do_md5)
- {
+void out_put(void *out, const uint8_t *buf, unsigned int len, int do_md5) {
+ if (do_md5) {
#if CONFIG_MD5
- MD5Update(out, buf, len);
+ MD5Update(out, buf, len);
#endif
- }
- else
- {
- if(fwrite(buf, 1, len, out));
- }
+ } else {
+ if (fwrite(buf, 1, len, out));
+ }
}
-void out_close(void *out, const char *out_fn, int do_md5)
-{
- if (do_md5)
- {
+void out_close(void *out, const char *out_fn, int do_md5) {
+ if (do_md5) {
#if CONFIG_MD5
- uint8_t md5[16];
- int i;
+ uint8_t md5[16];
+ int i;
- MD5Final(md5, out);
- free(out);
+ MD5Final(md5, out);
+ free(out);
- for (i = 0; i < 16; i++)
- printf("%02x", md5[i]);
+ for (i = 0; i < 16; i++)
+ printf("%02x", md5[i]);
- printf(" %s\n", out_fn);
+ printf(" %s\n", out_fn);
#endif
- }
- else
- {
- fclose(out);
- }
+ } else {
+ fclose(out);
+ }
}
unsigned int file_is_ivf(FILE *infile,
@@ -382,56 +345,50 @@ unsigned int file_is_ivf(FILE *infile,
unsigned int *width,
unsigned int *height,
unsigned int *fps_den,
- unsigned int *fps_num)
-{
- char raw_hdr[32];
- int is_ivf = 0;
-
- if (fread(raw_hdr, 1, 32, infile) == 32)
- {
- if (raw_hdr[0] == 'D' && raw_hdr[1] == 'K'
- && raw_hdr[2] == 'I' && raw_hdr[3] == 'F')
- {
- is_ivf = 1;
-
- if (mem_get_le16(raw_hdr + 4) != 0)
- fprintf(stderr, "Error: Unrecognized IVF version! This file may not"
- " decode properly.");
-
- *fourcc = mem_get_le32(raw_hdr + 8);
- *width = mem_get_le16(raw_hdr + 12);
- *height = mem_get_le16(raw_hdr + 14);
- *fps_num = mem_get_le32(raw_hdr + 16);
- *fps_den = mem_get_le32(raw_hdr + 20);
-
- /* Some versions of vpxenc used 1/(2*fps) for the timebase, so
- * we can guess the framerate using only the timebase in this
- * case. Other files would require reading ahead to guess the
- * timebase, like we do for webm.
- */
- if(*fps_num < 1000)
- {
- /* Correct for the factor of 2 applied to the timebase in the
- * encoder.
- */
- if(*fps_num&1)*fps_den<<=1;
- else *fps_num>>=1;
- }
- else
- {
- /* Don't know FPS for sure, and don't have readahead code
- * (yet?), so just default to 30fps.
- */
- *fps_num = 30;
- *fps_den = 1;
- }
- }
+ unsigned int *fps_num) {
+ char raw_hdr[32];
+ int is_ivf = 0;
+
+ if (fread(raw_hdr, 1, 32, infile) == 32) {
+ if (raw_hdr[0] == 'D' && raw_hdr[1] == 'K'
+ && raw_hdr[2] == 'I' && raw_hdr[3] == 'F') {
+ is_ivf = 1;
+
+ if (mem_get_le16(raw_hdr + 4) != 0)
+ fprintf(stderr, "Error: Unrecognized IVF version! This file may not"
+ " decode properly.");
+
+ *fourcc = mem_get_le32(raw_hdr + 8);
+ *width = mem_get_le16(raw_hdr + 12);
+ *height = mem_get_le16(raw_hdr + 14);
+ *fps_num = mem_get_le32(raw_hdr + 16);
+ *fps_den = mem_get_le32(raw_hdr + 20);
+
+ /* Some versions of vpxenc used 1/(2*fps) for the timebase, so
+ * we can guess the framerate using only the timebase in this
+ * case. Other files would require reading ahead to guess the
+ * timebase, like we do for webm.
+ */
+ if (*fps_num < 1000) {
+ /* Correct for the factor of 2 applied to the timebase in the
+ * encoder.
+ */
+ if (*fps_num & 1)*fps_den <<= 1;
+ else *fps_num >>= 1;
+ } else {
+ /* Don't know FPS for sure, and don't have readahead code
+ * (yet?), so just default to 30fps.
+ */
+ *fps_num = 30;
+ *fps_den = 1;
+ }
}
+ }
- if (!is_ivf)
- rewind(infile);
+ if (!is_ivf)
+ rewind(infile);
- return is_ivf;
+ return is_ivf;
}
@@ -440,126 +397,121 @@ unsigned int file_is_raw(FILE *infile,
unsigned int *width,
unsigned int *height,
unsigned int *fps_den,
- unsigned int *fps_num)
-{
- unsigned char buf[32];
- int is_raw = 0;
- vpx_codec_stream_info_t si;
-
- si.sz = sizeof(si);
-
- if (fread(buf, 1, 32, infile) == 32)
- {
- int i;
-
- if(mem_get_le32(buf) < 256 * 1024 * 1024)
- for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
- if(!vpx_codec_peek_stream_info(ifaces[i].iface,
- buf + 4, 32 - 4, &si))
- {
- is_raw = 1;
- *fourcc = ifaces[i].fourcc;
- *width = si.w;
- *height = si.h;
- *fps_num = 30;
- *fps_den = 1;
- break;
- }
- }
+ unsigned int *fps_num) {
+ unsigned char buf[32];
+ int is_raw = 0;
+ vpx_codec_stream_info_t si;
- rewind(infile);
- return is_raw;
+ si.sz = sizeof(si);
+
+ if (fread(buf, 1, 32, infile) == 32) {
+ int i;
+
+ if (mem_get_le32(buf) < 256 * 1024 * 1024)
+ for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
+ if (!vpx_codec_peek_stream_info(ifaces[i].iface,
+ buf + 4, 32 - 4, &si)) {
+ is_raw = 1;
+ *fourcc = ifaces[i].fourcc;
+ *width = si.w;
+ *height = si.h;
+ *fps_num = 30;
+ *fps_den = 1;
+ break;
+ }
+ }
+
+ rewind(infile);
+ return is_raw;
}
static int
-nestegg_read_cb(void *buffer, size_t length, void *userdata)
-{
- FILE *f = userdata;
-
- if(fread(buffer, 1, length, f) < length)
- {
- if (ferror(f))
- return -1;
- if (feof(f))
- return 0;
- }
- return 1;
+nestegg_read_cb(void *buffer, size_t length, void *userdata) {
+ FILE *f = userdata;
+
+ if (fread(buffer, 1, length, f) < length) {
+ if (ferror(f))
+ return -1;
+ if (feof(f))
+ return 0;
+ }
+ return 1;
}
static int
-nestegg_seek_cb(int64_t offset, int whence, void * userdata)
-{
- switch(whence) {
- case NESTEGG_SEEK_SET: whence = SEEK_SET; break;
- case NESTEGG_SEEK_CUR: whence = SEEK_CUR; break;
- case NESTEGG_SEEK_END: whence = SEEK_END; break;
- };
- return fseek(userdata, offset, whence)? -1 : 0;
+nestegg_seek_cb(int64_t offset, int whence, void *userdata) {
+ switch (whence) {
+ case NESTEGG_SEEK_SET:
+ whence = SEEK_SET;
+ break;
+ case NESTEGG_SEEK_CUR:
+ whence = SEEK_CUR;
+ break;
+ case NESTEGG_SEEK_END:
+ whence = SEEK_END;
+ break;
+ };
+ return fseek(userdata, offset, whence) ? -1 : 0;
}
static int64_t
-nestegg_tell_cb(void * userdata)
-{
- return ftell(userdata);
+nestegg_tell_cb(void *userdata) {
+ return ftell(userdata);
}
static void
-nestegg_log_cb(nestegg * context, unsigned int severity, char const * format,
- ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- fprintf(stderr, "\n");
- va_end(ap);
+nestegg_log_cb(nestegg *context, unsigned int severity, char const *format,
+ ...) {
+ va_list ap;
+
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
}
static int
webm_guess_framerate(struct input_ctx *input,
unsigned int *fps_den,
- unsigned int *fps_num)
-{
- unsigned int i;
- uint64_t tstamp=0;
-
- /* Guess the framerate. Read up to 1 second, or 50 video packets,
- * whichever comes first.
- */
- for(i=0; tstamp < 1000000000 && i < 50;)
- {
- nestegg_packet * pkt;
- unsigned int track;
-
- if(nestegg_read_packet(input->nestegg_ctx, &pkt) <= 0)
- break;
-
- nestegg_packet_track(pkt, &track);
- if(track == input->video_track)
- {
- nestegg_packet_tstamp(pkt, &tstamp);
- i++;
- }
+ unsigned int *fps_num) {
+ unsigned int i;
+ uint64_t tstamp = 0;
+
+ /* Guess the framerate. Read up to 1 second, or 50 video packets,
+ * whichever comes first.
+ */
+ for (i = 0; tstamp < 1000000000 && i < 50;) {
+ nestegg_packet *pkt;
+ unsigned int track;
+
+ if (nestegg_read_packet(input->nestegg_ctx, &pkt) <= 0)
+ break;
- nestegg_free_packet(pkt);
+ nestegg_packet_track(pkt, &track);
+ if (track == input->video_track) {
+ nestegg_packet_tstamp(pkt, &tstamp);
+ i++;
}
- if(nestegg_track_seek(input->nestegg_ctx, input->video_track, 0))
- goto fail;
+ nestegg_free_packet(pkt);
+ }
- *fps_num = (i - 1) * 1000000;
- *fps_den = tstamp / 1000;
- return 0;
+ if (nestegg_track_seek(input->nestegg_ctx, input->video_track, 0))
+ goto fail;
+
+ *fps_num = (i - 1) * 1000000;
+ *fps_den = tstamp / 1000;
+ return 0;
fail:
- nestegg_destroy(input->nestegg_ctx);
- input->nestegg_ctx = NULL;
- rewind(input->infile);
- return 1;
+ nestegg_destroy(input->nestegg_ctx);
+ input->nestegg_ctx = NULL;
+ rewind(input->infile);
+ return 1;
}
@@ -569,569 +521,527 @@ file_is_webm(struct input_ctx *input,
unsigned int *width,
unsigned int *height,
unsigned int *fps_den,
- unsigned int *fps_num)
-{
- unsigned int i, n;
- int track_type = -1;
-
- nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb,
- input->infile};
- nestegg_video_params params;
-
- if(nestegg_init(&input->nestegg_ctx, io, NULL))
- goto fail;
-
- if(nestegg_track_count(input->nestegg_ctx, &n))
- goto fail;
-
- for(i=0; i<n; i++)
- {
- track_type = nestegg_track_type(input->nestegg_ctx, i);
-
- if(track_type == NESTEGG_TRACK_VIDEO)
- break;
- else if(track_type < 0)
- goto fail;
- }
-
- if(nestegg_track_codec_id(input->nestegg_ctx, i) != NESTEGG_CODEC_VP8)
- {
- fprintf(stderr, "Not VP8 video, quitting.\n");
- exit(1);
- }
-
- input->video_track = i;
-
- if(nestegg_track_video_params(input->nestegg_ctx, i, &params))
- goto fail;
-
- *fps_den = 0;
- *fps_num = 0;
- *fourcc = VP8_FOURCC;
- *width = params.width;
- *height = params.height;
- return 1;
+ unsigned int *fps_num) {
+ unsigned int i, n;
+ int track_type = -1;
+
+ nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb,
+ input->infile
+ };
+ nestegg_video_params params;
+
+ if (nestegg_init(&input->nestegg_ctx, io, NULL))
+ goto fail;
+
+ if (nestegg_track_count(input->nestegg_ctx, &n))
+ goto fail;
+
+ for (i = 0; i < n; i++) {
+ track_type = nestegg_track_type(input->nestegg_ctx, i);
+
+ if (track_type == NESTEGG_TRACK_VIDEO)
+ break;
+ else if (track_type < 0)
+ goto fail;
+ }
+
+ if (nestegg_track_codec_id(input->nestegg_ctx, i) != NESTEGG_CODEC_VP8) {
+ fprintf(stderr, "Not VP8 video, quitting.\n");
+ exit(1);
+ }
+
+ input->video_track = i;
+
+ if (nestegg_track_video_params(input->nestegg_ctx, i, &params))
+ goto fail;
+
+ *fps_den = 0;
+ *fps_num = 0;
+ *fourcc = VP8_FOURCC;
+ *width = params.width;
+ *height = params.height;
+ return 1;
fail:
- input->nestegg_ctx = NULL;
- rewind(input->infile);
- return 0;
+ input->nestegg_ctx = NULL;
+ rewind(input->infile);
+ return 0;
}
-void show_progress(int frame_in, int frame_out, unsigned long dx_time)
-{
- fprintf(stderr, "%d decoded frames/%d showed frames in %lu us (%.2f fps)\r",
- frame_in, frame_out, dx_time,
- (float)frame_out * 1000000.0 / (float)dx_time);
+void show_progress(int frame_in, int frame_out, unsigned long dx_time) {
+ fprintf(stderr, "%d decoded frames/%d showed frames in %lu us (%.2f fps)\r",
+ frame_in, frame_out, dx_time,
+ (float)frame_out * 1000000.0 / (float)dx_time);
}
void generate_filename(const char *pattern, char *out, size_t q_len,
unsigned int d_w, unsigned int d_h,
- unsigned int frame_in)
-{
- const char *p = pattern;
- char *q = out;
-
- do
- {
- char *next_pat = strchr(p, '%');
-
- if(p == next_pat)
- {
- size_t pat_len;
-
- // parse the pattern
- q[q_len - 1] = '\0';
- switch(p[1])
- {
- case 'w': snprintf(q, q_len - 1, "%d", d_w); break;
- case 'h': snprintf(q, q_len - 1, "%d", d_h); break;
- case '1': snprintf(q, q_len - 1, "%d", frame_in); break;
- case '2': snprintf(q, q_len - 1, "%02d", frame_in); break;
- case '3': snprintf(q, q_len - 1, "%03d", frame_in); break;
- case '4': snprintf(q, q_len - 1, "%04d", frame_in); break;
- case '5': snprintf(q, q_len - 1, "%05d", frame_in); break;
- case '6': snprintf(q, q_len - 1, "%06d", frame_in); break;
- case '7': snprintf(q, q_len - 1, "%07d", frame_in); break;
- case '8': snprintf(q, q_len - 1, "%08d", frame_in); break;
- case '9': snprintf(q, q_len - 1, "%09d", frame_in); break;
- default:
- die("Unrecognized pattern %%%c\n", p[1]);
- }
-
- pat_len = strlen(q);
- if(pat_len >= q_len - 1)
- die("Output filename too long.\n");
- q += pat_len;
- p += 2;
- q_len -= pat_len;
- }
- else
- {
- size_t copy_len;
-
- // copy the next segment
- if(!next_pat)
- copy_len = strlen(p);
- else
- copy_len = next_pat - p;
-
- if(copy_len >= q_len - 1)
- die("Output filename too long.\n");
-
- memcpy(q, p, copy_len);
- q[copy_len] = '\0';
- q += copy_len;
- p += copy_len;
- q_len -= copy_len;
- }
- } while(*p);
+ unsigned int frame_in) {
+ const char *p = pattern;
+ char *q = out;
+
+ do {
+ char *next_pat = strchr(p, '%');
+
+ if (p == next_pat) {
+ size_t pat_len;
+
+ // parse the pattern
+ q[q_len - 1] = '\0';
+ switch (p[1]) {
+ case 'w':
+ snprintf(q, q_len - 1, "%d", d_w);
+ break;
+ case 'h':
+ snprintf(q, q_len - 1, "%d", d_h);
+ break;
+ case '1':
+ snprintf(q, q_len - 1, "%d", frame_in);
+ break;
+ case '2':
+ snprintf(q, q_len - 1, "%02d", frame_in);
+ break;
+ case '3':
+ snprintf(q, q_len - 1, "%03d", frame_in);
+ break;
+ case '4':
+ snprintf(q, q_len - 1, "%04d", frame_in);
+ break;
+ case '5':
+ snprintf(q, q_len - 1, "%05d", frame_in);
+ break;
+ case '6':
+ snprintf(q, q_len - 1, "%06d", frame_in);
+ break;
+ case '7':
+ snprintf(q, q_len - 1, "%07d", frame_in);
+ break;
+ case '8':
+ snprintf(q, q_len - 1, "%08d", frame_in);
+ break;
+ case '9':
+ snprintf(q, q_len - 1, "%09d", frame_in);
+ break;
+ default:
+ die("Unrecognized pattern %%%c\n", p[1]);
+ }
+
+ pat_len = strlen(q);
+ if (pat_len >= q_len - 1)
+ die("Output filename too long.\n");
+ q += pat_len;
+ p += 2;
+ q_len -= pat_len;
+ } else {
+ size_t copy_len;
+
+ // copy the next segment
+ if (!next_pat)
+ copy_len = strlen(p);
+ else
+ copy_len = next_pat - p;
+
+ if (copy_len >= q_len - 1)
+ die("Output filename too long.\n");
+
+ memcpy(q, p, copy_len);
+ q[copy_len] = '\0';
+ q += copy_len;
+ p += copy_len;
+ q_len -= copy_len;
+ }
+ } while (*p);
}
-int main(int argc, const char **argv_)
-{
- vpx_codec_ctx_t decoder;
- char *fn = NULL;
- int i;
- uint8_t *buf = NULL;
- size_t buf_sz = 0, buf_alloc_sz = 0;
- FILE *infile;
- int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0, do_md5 = 0, progress = 0;
- int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
- vpx_codec_iface_t *iface = NULL;
- unsigned int fourcc;
- unsigned long dx_time = 0;
- struct arg arg;
- char **argv, **argi, **argj;
- const char *outfile_pattern = 0;
- char outfile[PATH_MAX];
- int single_file;
- int use_y4m = 1;
- unsigned int width;
- unsigned int height;
- unsigned int fps_den;
- unsigned int fps_num;
- void *out = NULL;
- vpx_codec_dec_cfg_t cfg = {0};
+int main(int argc, const char **argv_) {
+ vpx_codec_ctx_t decoder;
+ char *fn = NULL;
+ int i;
+ uint8_t *buf = NULL;
+ size_t buf_sz = 0, buf_alloc_sz = 0;
+ FILE *infile;
+ int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0, do_md5 = 0, progress = 0;
+ int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
+ vpx_codec_iface_t *iface = NULL;
+ unsigned int fourcc;
+ unsigned long dx_time = 0;
+ struct arg arg;
+ char **argv, **argi, **argj;
+ const char *outfile_pattern = 0;
+ char outfile[PATH_MAX];
+ int single_file;
+ int use_y4m = 1;
+ unsigned int width;
+ unsigned int height;
+ unsigned int fps_den;
+ unsigned int fps_num;
+ void *out = NULL;
+ vpx_codec_dec_cfg_t cfg = {0};
#if CONFIG_VP8_DECODER
- vp8_postproc_cfg_t vp8_pp_cfg = {0};
- int vp8_dbg_color_ref_frame = 0;
- int vp8_dbg_color_mb_modes = 0;
- int vp8_dbg_color_b_modes = 0;
- int vp8_dbg_display_mv = 0;
+ vp8_postproc_cfg_t vp8_pp_cfg = {0};
+ int vp8_dbg_color_ref_frame = 0;
+ int vp8_dbg_color_mb_modes = 0;
+ int vp8_dbg_color_b_modes = 0;
+ int vp8_dbg_display_mv = 0;
#endif
- struct input_ctx input = {0};
- int frames_corrupted = 0;
- int dec_flags = 0;
-
- /* Parse command line */
- exec_name = argv_[0];
- argv = argv_dup(argc - 1, argv_ + 1);
-
- for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step)
- {
- memset(&arg, 0, sizeof(arg));
- arg.argv_step = 1;
-
- if (arg_match(&arg, &codecarg, argi))
- {
- int j, k = -1;
-
- for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
- if (!strcmp(ifaces[j].name, arg.val))
- k = j;
-
- if (k >= 0)
- iface = ifaces[k].iface;
- else
- die("Error: Unrecognized argument (%s) to --codec\n",
- arg.val);
- }
- else if (arg_match(&arg, &outputfile, argi))
- outfile_pattern = arg.val;
- else if (arg_match(&arg, &use_yv12, argi))
- {
- use_y4m = 0;
- flipuv = 1;
- }
- else if (arg_match(&arg, &use_i420, argi))
- {
- use_y4m = 0;
- flipuv = 0;
- }
- else if (arg_match(&arg, &flipuvarg, argi))
- flipuv = 1;
- else if (arg_match(&arg, &noblitarg, argi))
- noblit = 1;
- else if (arg_match(&arg, &progressarg, argi))
- progress = 1;
- else if (arg_match(&arg, &limitarg, argi))
- stop_after = arg_parse_uint(&arg);
- else if (arg_match(&arg, &postprocarg, argi))
- postproc = 1;
- else if (arg_match(&arg, &md5arg, argi))
- do_md5 = 1;
- else if (arg_match(&arg, &summaryarg, argi))
- summary = 1;
- else if (arg_match(&arg, &threadsarg, argi))
- cfg.threads = arg_parse_uint(&arg);
- else if (arg_match(&arg, &verbosearg, argi))
- quiet = 0;
+ struct input_ctx input = {0};
+ int frames_corrupted = 0;
+ int dec_flags = 0;
+
+ /* Parse command line */
+ exec_name = argv_[0];
+ argv = argv_dup(argc - 1, argv_ + 1);
+
+ for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
+ memset(&arg, 0, sizeof(arg));
+ arg.argv_step = 1;
+
+ if (arg_match(&arg, &codecarg, argi)) {
+ int j, k = -1;
+
+ for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
+ if (!strcmp(ifaces[j].name, arg.val))
+ k = j;
+
+ if (k >= 0)
+ iface = ifaces[k].iface;
+ else
+ die("Error: Unrecognized argument (%s) to --codec\n",
+ arg.val);
+ } else if (arg_match(&arg, &outputfile, argi))
+ outfile_pattern = arg.val;
+ else if (arg_match(&arg, &use_yv12, argi)) {
+ use_y4m = 0;
+ flipuv = 1;
+ } else if (arg_match(&arg, &use_i420, argi)) {
+ use_y4m = 0;
+ flipuv = 0;
+ } else if (arg_match(&arg, &flipuvarg, argi))
+ flipuv = 1;
+ else if (arg_match(&arg, &noblitarg, argi))
+ noblit = 1;
+ else if (arg_match(&arg, &progressarg, argi))
+ progress = 1;
+ else if (arg_match(&arg, &limitarg, argi))
+ stop_after = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &postprocarg, argi))
+ postproc = 1;
+ else if (arg_match(&arg, &md5arg, argi))
+ do_md5 = 1;
+ else if (arg_match(&arg, &summaryarg, argi))
+ summary = 1;
+ else if (arg_match(&arg, &threadsarg, argi))
+ cfg.threads = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &verbosearg, argi))
+ quiet = 0;
#if CONFIG_VP8_DECODER
- else if (arg_match(&arg, &addnoise_level, argi))
- {
- postproc = 1;
- vp8_pp_cfg.post_proc_flag |= VP8_ADDNOISE;
- vp8_pp_cfg.noise_level = arg_parse_uint(&arg);
- }
- else if (arg_match(&arg, &demacroblock_level, argi))
- {
- postproc = 1;
- vp8_pp_cfg.post_proc_flag |= VP8_DEMACROBLOCK;
- vp8_pp_cfg.deblocking_level = arg_parse_uint(&arg);
- }
- else if (arg_match(&arg, &deblock, argi))
- {
- postproc = 1;
- vp8_pp_cfg.post_proc_flag |= VP8_DEBLOCK;
- }
- else if (arg_match(&arg, &pp_debug_info, argi))
- {
- unsigned int level = arg_parse_uint(&arg);
-
- postproc = 1;
- vp8_pp_cfg.post_proc_flag &= ~0x7;
-
- if (level)
- vp8_pp_cfg.post_proc_flag |= level;
- }
- else if (arg_match(&arg, &pp_disp_ref_frame, argi))
- {
- unsigned int flags = arg_parse_int(&arg);
- if (flags)
- {
- postproc = 1;
- vp8_dbg_color_ref_frame = flags;
- }
- }
- else if (arg_match(&arg, &pp_disp_mb_modes, argi))
- {
- unsigned int flags = arg_parse_int(&arg);
- if (flags)
- {
- postproc = 1;
- vp8_dbg_color_mb_modes = flags;
- }
- }
- else if (arg_match(&arg, &pp_disp_b_modes, argi))
- {
- unsigned int flags = arg_parse_int(&arg);
- if (flags)
- {
- postproc = 1;
- vp8_dbg_color_b_modes = flags;
- }
- }
- else if (arg_match(&arg, &pp_disp_mvs, argi))
- {
- unsigned int flags = arg_parse_int(&arg);
- if (flags)
- {
- postproc = 1;
- vp8_dbg_display_mv = flags;
- }
- }
+ else if (arg_match(&arg, &addnoise_level, argi)) {
+ postproc = 1;
+ vp8_pp_cfg.post_proc_flag |= VP8_ADDNOISE;
+ vp8_pp_cfg.noise_level = arg_parse_uint(&arg);
+ } else if (arg_match(&arg, &demacroblock_level, argi)) {
+ postproc = 1;
+ vp8_pp_cfg.post_proc_flag |= VP8_DEMACROBLOCK;
+ vp8_pp_cfg.deblocking_level = arg_parse_uint(&arg);
+ } else if (arg_match(&arg, &deblock, argi)) {
+ postproc = 1;
+ vp8_pp_cfg.post_proc_flag |= VP8_DEBLOCK;
+ } else if (arg_match(&arg, &pp_debug_info, argi)) {
+ unsigned int level = arg_parse_uint(&arg);
+
+ postproc = 1;
+ vp8_pp_cfg.post_proc_flag &= ~0x7;
+
+ if (level)
+ vp8_pp_cfg.post_proc_flag |= level;
+ } else if (arg_match(&arg, &pp_disp_ref_frame, argi)) {
+ unsigned int flags = arg_parse_int(&arg);
+ if (flags) {
+ postproc = 1;
+ vp8_dbg_color_ref_frame = flags;
+ }
+ } else if (arg_match(&arg, &pp_disp_mb_modes, argi)) {
+ unsigned int flags = arg_parse_int(&arg);
+ if (flags) {
+ postproc = 1;
+ vp8_dbg_color_mb_modes = flags;
+ }
+ } else if (arg_match(&arg, &pp_disp_b_modes, argi)) {
+ unsigned int flags = arg_parse_int(&arg);
+ if (flags) {
+ postproc = 1;
+ vp8_dbg_color_b_modes = flags;
+ }
+ } else if (arg_match(&arg, &pp_disp_mvs, argi)) {
+ unsigned int flags = arg_parse_int(&arg);
+ if (flags) {
+ postproc = 1;
+ vp8_dbg_display_mv = flags;
+ }
+ }
#endif
- else
- argj++;
- }
+ else
+ argj++;
+ }
- /* Check for unrecognized options */
- for (argi = argv; *argi; argi++)
- if (argi[0][0] == '-' && strlen(argi[0]) > 1)
- die("Error: Unrecognized option %s\n", *argi);
+ /* Check for unrecognized options */
+ for (argi = argv; *argi; argi++)
+ if (argi[0][0] == '-' && strlen(argi[0]) > 1)
+ die("Error: Unrecognized option %s\n", *argi);
- /* Handle non-option arguments */
- fn = argv[0];
+ /* Handle non-option arguments */
+ fn = argv[0];
- if (!fn)
- usage_exit();
+ if (!fn)
+ usage_exit();
- /* Open file */
- infile = strcmp(fn, "-") ? fopen(fn, "rb") : set_binary_mode(stdin);
+ /* Open file */
+ infile = strcmp(fn, "-") ? fopen(fn, "rb") : set_binary_mode(stdin);
- if (!infile)
- {
- fprintf(stderr, "Failed to open file '%s'",
- strcmp(fn, "-") ? fn : "stdin");
- return EXIT_FAILURE;
- }
+ if (!infile) {
+ fprintf(stderr, "Failed to open file '%s'",
+ strcmp(fn, "-") ? fn : "stdin");
+ return EXIT_FAILURE;
+ }
#if CONFIG_OS_SUPPORT
- /* Make sure we don't dump to the terminal, unless forced to with -o - */
- if(!outfile_pattern && isatty(fileno(stdout)) && !do_md5 && !noblit)
- {
- fprintf(stderr,
- "Not dumping raw video to your terminal. Use '-o -' to "
- "override.\n");
- return EXIT_FAILURE;
- }
+ /* Make sure we don't dump to the terminal, unless forced to with -o - */
+ if (!outfile_pattern && isatty(fileno(stdout)) && !do_md5 && !noblit) {
+ fprintf(stderr,
+ "Not dumping raw video to your terminal. Use '-o -' to "
+ "override.\n");
+ return EXIT_FAILURE;
+ }
#endif
- input.infile = infile;
- if(file_is_ivf(infile, &fourcc, &width, &height, &fps_den,
- &fps_num))
- input.kind = IVF_FILE;
- else if(file_is_webm(&input, &fourcc, &width, &height, &fps_den, &fps_num))
- input.kind = WEBM_FILE;
- else if(file_is_raw(infile, &fourcc, &width, &height, &fps_den, &fps_num))
- input.kind = RAW_FILE;
- else
- {
- fprintf(stderr, "Unrecognized input file type.\n");
- return EXIT_FAILURE;
+ input.infile = infile;
+ if (file_is_ivf(infile, &fourcc, &width, &height, &fps_den,
+ &fps_num))
+ input.kind = IVF_FILE;
+ else if (file_is_webm(&input, &fourcc, &width, &height, &fps_den, &fps_num))
+ input.kind = WEBM_FILE;
+ else if (file_is_raw(infile, &fourcc, &width, &height, &fps_den, &fps_num))
+ input.kind = RAW_FILE;
+ else {
+ fprintf(stderr, "Unrecognized input file type.\n");
+ return EXIT_FAILURE;
+ }
+
+ /* If the output file is not set or doesn't have a sequence number in
+ * it, then we only open it once.
+ */
+ outfile_pattern = outfile_pattern ? outfile_pattern : "-";
+ single_file = 1;
+ {
+ const char *p = outfile_pattern;
+ do {
+ p = strchr(p, '%');
+ if (p && p[1] >= '1' && p[1] <= '9') {
+ // pattern contains sequence number, so it's not unique.
+ single_file = 0;
+ break;
+ }
+ if (p)
+ p++;
+ } while (p);
+ }
+
+ if (single_file && !noblit) {
+ generate_filename(outfile_pattern, outfile, sizeof(outfile) - 1,
+ width, height, 0);
+ out = out_open(outfile, do_md5);
+ }
+
+ if (use_y4m && !noblit) {
+ char buffer[128];
+ if (!single_file) {
+ fprintf(stderr, "YUV4MPEG2 not supported with output patterns,"
+ " try --i420 or --yv12.\n");
+ return EXIT_FAILURE;
}
- /* If the output file is not set or doesn't have a sequence number in
- * it, then we only open it once.
- */
- outfile_pattern = outfile_pattern ? outfile_pattern : "-";
- single_file = 1;
- {
- const char *p = outfile_pattern;
- do
- {
- p = strchr(p, '%');
- if(p && p[1] >= '1' && p[1] <= '9')
- {
- // pattern contains sequence number, so it's not unique.
- single_file = 0;
- break;
- }
- if(p)
- p++;
- } while(p);
- }
+ if (input.kind == WEBM_FILE)
+ if (webm_guess_framerate(&input, &fps_den, &fps_num)) {
+ fprintf(stderr, "Failed to guess framerate -- error parsing "
+ "webm file?\n");
+ return EXIT_FAILURE;
+ }
- if(single_file && !noblit)
- {
- generate_filename(outfile_pattern, outfile, sizeof(outfile)-1,
- width, height, 0);
- out = out_open(outfile, do_md5);
- }
- if (use_y4m && !noblit)
- {
- char buffer[128];
- if (!single_file)
- {
- fprintf(stderr, "YUV4MPEG2 not supported with output patterns,"
- " try --i420 or --yv12.\n");
- return EXIT_FAILURE;
- }
+ /*Note: We can't output an aspect ratio here because IVF doesn't
+ store one, and neither does VP8.
+ That will have to wait until these tools support WebM natively.*/
+ sprintf(buffer, "YUV4MPEG2 C%s W%u H%u F%u:%u I%c\n",
+ "420jpeg", width, height, fps_num, fps_den, 'p');
+ out_put(out, (unsigned char *)buffer, strlen(buffer), do_md5);
+ }
+
+ /* Try to determine the codec from the fourcc. */
+ for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
+ if ((fourcc & ifaces[i].fourcc_mask) == ifaces[i].fourcc) {
+ vpx_codec_iface_t *ivf_iface = ifaces[i].iface;
- if(input.kind == WEBM_FILE)
- if(webm_guess_framerate(&input, &fps_den, &fps_num))
- {
- fprintf(stderr, "Failed to guess framerate -- error parsing "
- "webm file?\n");
- return EXIT_FAILURE;
- }
-
-
- /*Note: We can't output an aspect ratio here because IVF doesn't
- store one, and neither does VP8.
- That will have to wait until these tools support WebM natively.*/
- sprintf(buffer, "YUV4MPEG2 C%s W%u H%u F%u:%u I%c\n",
- "420jpeg", width, height, fps_num, fps_den, 'p');
- out_put(out, (unsigned char *)buffer, strlen(buffer), do_md5);
+ if (iface && iface != ivf_iface)
+ fprintf(stderr, "Notice -- IVF header indicates codec: %s\n",
+ ifaces[i].name);
+ else
+ iface = ivf_iface;
+
+ break;
}
- /* Try to determine the codec from the fourcc. */
- for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
- if ((fourcc & ifaces[i].fourcc_mask) == ifaces[i].fourcc)
- {
- vpx_codec_iface_t *ivf_iface = ifaces[i].iface;
+ dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0);
+ if (vpx_codec_dec_init(&decoder, iface ? iface : ifaces[0].iface, &cfg,
+ dec_flags)) {
+ fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
- if (iface && iface != ivf_iface)
- fprintf(stderr, "Notice -- IVF header indicates codec: %s\n",
- ifaces[i].name);
- else
- iface = ivf_iface;
+ if (!quiet)
+ fprintf(stderr, "%s\n", decoder.name);
- break;
- }
+#if CONFIG_VP8_DECODER
- dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0);
- if (vpx_codec_dec_init(&decoder, iface ? iface : ifaces[0].iface, &cfg,
- dec_flags))
- {
- fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ if (vp8_pp_cfg.post_proc_flag
+ && vpx_codec_control(&decoder, VP8_SET_POSTPROC, &vp8_pp_cfg)) {
+ fprintf(stderr, "Failed to configure postproc: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+
+ if (vp8_dbg_color_ref_frame
+ && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_REF_FRAME, vp8_dbg_color_ref_frame)) {
+ fprintf(stderr, "Failed to configure reference block visualizer: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+
+ if (vp8_dbg_color_mb_modes
+ && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_MB_MODES, vp8_dbg_color_mb_modes)) {
+ fprintf(stderr, "Failed to configure macro block visualizer: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+
+ if (vp8_dbg_color_b_modes
+ && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_B_MODES, vp8_dbg_color_b_modes)) {
+ fprintf(stderr, "Failed to configure block visualizer: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+
+ if (vp8_dbg_display_mv
+ && vpx_codec_control(&decoder, VP8_SET_DBG_DISPLAY_MV, vp8_dbg_display_mv)) {
+ fprintf(stderr, "Failed to configure motion vector visualizer: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+#endif
- if (!quiet)
- fprintf(stderr, "%s\n", decoder.name);
+ /* Decode file */
+ while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) {
+ vpx_codec_iter_t iter = NULL;
+ vpx_image_t *img;
+ struct vpx_usec_timer timer;
+ int corrupted;
-#if CONFIG_VP8_DECODER
+ vpx_usec_timer_start(&timer);
- if (vp8_pp_cfg.post_proc_flag
- && vpx_codec_control(&decoder, VP8_SET_POSTPROC, &vp8_pp_cfg))
- {
- fprintf(stderr, "Failed to configure postproc: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ if (vpx_codec_decode(&decoder, buf, buf_sz, NULL, 0)) {
+ const char *detail = vpx_codec_error_detail(&decoder);
+ fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&decoder));
- if (vp8_dbg_color_ref_frame
- && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_REF_FRAME, vp8_dbg_color_ref_frame))
- {
- fprintf(stderr, "Failed to configure reference block visualizer: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ if (detail)
+ fprintf(stderr, " Additional information: %s\n", detail);
- if (vp8_dbg_color_mb_modes
- && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_MB_MODES, vp8_dbg_color_mb_modes))
- {
- fprintf(stderr, "Failed to configure macro block visualizer: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
+ goto fail;
}
- if (vp8_dbg_color_b_modes
- && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_B_MODES, vp8_dbg_color_b_modes))
- {
- fprintf(stderr, "Failed to configure block visualizer: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ vpx_usec_timer_mark(&timer);
+ dx_time += vpx_usec_timer_elapsed(&timer);
- if (vp8_dbg_display_mv
- && vpx_codec_control(&decoder, VP8_SET_DBG_DISPLAY_MV, vp8_dbg_display_mv))
- {
- fprintf(stderr, "Failed to configure motion vector visualizer: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
+ ++frame_in;
+
+ if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) {
+ fprintf(stderr, "Failed VP8_GET_FRAME_CORRUPTED: %s\n",
+ vpx_codec_error(&decoder));
+ goto fail;
}
-#endif
+ frames_corrupted += corrupted;
- /* Decode file */
- while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz))
- {
- vpx_codec_iter_t iter = NULL;
- vpx_image_t *img;
- struct vpx_usec_timer timer;
- int corrupted;
+ if ((img = vpx_codec_get_frame(&decoder, &iter)))
+ ++frame_out;
- vpx_usec_timer_start(&timer);
+ if (progress)
+ show_progress(frame_in, frame_out, dx_time);
- if (vpx_codec_decode(&decoder, buf, buf_sz, NULL, 0))
- {
- const char *detail = vpx_codec_error_detail(&decoder);
- fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&decoder));
+ if (!noblit) {
+ if (img) {
+ unsigned int y;
+ char out_fn[PATH_MAX];
+ uint8_t *buf;
- if (detail)
- fprintf(stderr, " Additional information: %s\n", detail);
+ if (!single_file) {
+ size_t len = sizeof(out_fn) - 1;
- goto fail;
- }
+ out_fn[len] = '\0';
+ generate_filename(outfile_pattern, out_fn, len - 1,
+ img->d_w, img->d_h, frame_in);
+ out = out_open(out_fn, do_md5);
+ } else if (use_y4m)
+ out_put(out, (unsigned char *)"FRAME\n", 6, do_md5);
+
+ buf = img->planes[VPX_PLANE_Y];
- vpx_usec_timer_mark(&timer);
- dx_time += vpx_usec_timer_elapsed(&timer);
+ for (y = 0; y < img->d_h; y++) {
+ out_put(out, buf, img->d_w, do_md5);
+ buf += img->stride[VPX_PLANE_Y];
+ }
- ++frame_in;
+ buf = img->planes[flipuv ? VPX_PLANE_V : VPX_PLANE_U];
- if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted))
- {
- fprintf(stderr, "Failed VP8_GET_FRAME_CORRUPTED: %s\n",
- vpx_codec_error(&decoder));
- goto fail;
+ for (y = 0; y < (1 + img->d_h) / 2; y++) {
+ out_put(out, buf, (1 + img->d_w) / 2, do_md5);
+ buf += img->stride[VPX_PLANE_U];
}
- frames_corrupted += corrupted;
-
- if ((img = vpx_codec_get_frame(&decoder, &iter)))
- ++frame_out;
-
- if (progress)
- show_progress(frame_in, frame_out, dx_time);
-
- if (!noblit)
- {
- if (img)
- {
- unsigned int y;
- char out_fn[PATH_MAX];
- uint8_t *buf;
-
- if (!single_file)
- {
- size_t len = sizeof(out_fn)-1;
-
- out_fn[len] = '\0';
- generate_filename(outfile_pattern, out_fn, len-1,
- img->d_w, img->d_h, frame_in);
- out = out_open(out_fn, do_md5);
- }
- else if(use_y4m)
- out_put(out, (unsigned char *)"FRAME\n", 6, do_md5);
-
- buf = img->planes[VPX_PLANE_Y];
-
- for (y = 0; y < img->d_h; y++)
- {
- out_put(out, buf, img->d_w, do_md5);
- buf += img->stride[VPX_PLANE_Y];
- }
-
- buf = img->planes[flipuv?VPX_PLANE_V:VPX_PLANE_U];
-
- for (y = 0; y < (1 + img->d_h) / 2; y++)
- {
- out_put(out, buf, (1 + img->d_w) / 2, do_md5);
- buf += img->stride[VPX_PLANE_U];
- }
-
- buf = img->planes[flipuv?VPX_PLANE_U:VPX_PLANE_V];
-
- for (y = 0; y < (1 + img->d_h) / 2; y++)
- {
- out_put(out, buf, (1 + img->d_w) / 2, do_md5);
- buf += img->stride[VPX_PLANE_V];
- }
-
- if (!single_file)
- out_close(out, out_fn, do_md5);
- }
+
+ buf = img->planes[flipuv ? VPX_PLANE_U : VPX_PLANE_V];
+
+ for (y = 0; y < (1 + img->d_h) / 2; y++) {
+ out_put(out, buf, (1 + img->d_w) / 2, do_md5);
+ buf += img->stride[VPX_PLANE_V];
}
- if (stop_after && frame_in >= stop_after)
- break;
+ if (!single_file)
+ out_close(out, out_fn, do_md5);
+ }
}
- if (summary || progress)
- {
- show_progress(frame_in, frame_out, dx_time);
- fprintf(stderr, "\n");
- }
+ if (stop_after && frame_in >= stop_after)
+ break;
+ }
- if (frames_corrupted)
- fprintf(stderr, "WARNING: %d frames corrupted.\n",frames_corrupted);
+ if (summary || progress) {
+ show_progress(frame_in, frame_out, dx_time);
+ fprintf(stderr, "\n");
+ }
+
+ if (frames_corrupted)
+ fprintf(stderr, "WARNING: %d frames corrupted.\n", frames_corrupted);
fail:
- if (vpx_codec_destroy(&decoder))
- {
- fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
+ if (vpx_codec_destroy(&decoder)) {
+ fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
- if (single_file && !noblit)
- out_close(out, outfile, do_md5);
+ if (single_file && !noblit)
+ out_close(out, outfile, do_md5);
- if(input.nestegg_ctx)
- nestegg_destroy(input.nestegg_ctx);
- if(input.kind != WEBM_FILE)
- free(buf);
- fclose(infile);
- free(argv);
+ if (input.nestegg_ctx)
+ nestegg_destroy(input.nestegg_ctx);
+ if (input.kind != WEBM_FILE)
+ free(buf);
+ fclose(infile);
+ free(argv);
- return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS;
+ return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/vpxenc.c b/vpxenc.c
index e4b4422d6..df38ceb6d 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -72,320 +72,276 @@ typedef long off_t;
static const char *exec_name;
-static const struct codec_item
-{
- char const *name;
- const vpx_codec_iface_t *iface;
- unsigned int fourcc;
-} codecs[] =
-{
+static const struct codec_item {
+ char const *name;
+ const vpx_codec_iface_t *iface;
+ unsigned int fourcc;
+} codecs[] = {
#if CONFIG_EXPERIMENTAL && CONFIG_VP8_ENCODER
- {"vp8x", &vpx_codec_vp8x_cx_algo, 0x78385056},
+ {"vp8x", &vpx_codec_vp8x_cx_algo, 0x78385056},
#endif
#if CONFIG_VP8_ENCODER
- {"vp8", &vpx_codec_vp8_cx_algo, 0x30385056},
+ {"vp8", &vpx_codec_vp8_cx_algo, 0x30385056},
#endif
};
#define VP8_FOURCC (0x00385056)
-static const struct
-{
- char const *name;
- const vpx_codec_iface_t *iface;
- unsigned int fourcc;
- unsigned int fourcc_mask;
-} ifaces[] =
-{
+static const struct {
+ char const *name;
+ const vpx_codec_iface_t *iface;
+ unsigned int fourcc;
+ unsigned int fourcc_mask;
+} ifaces[] = {
#if CONFIG_VP8_DECODER
- {"vp8", &vpx_codec_vp8_dx_algo, VP8_FOURCC, 0x00FFFFFF},
+ {"vp8", &vpx_codec_vp8_dx_algo, VP8_FOURCC, 0x00FFFFFF},
#endif
};
static void usage_exit();
-void die(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- usage_exit();
+void die(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ usage_exit();
}
-static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s)
-{
- if (ctx->err)
- {
- const char *detail = vpx_codec_error_detail(ctx);
+static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s) {
+ if (ctx->err) {
+ const char *detail = vpx_codec_error_detail(ctx);
- fprintf(stderr, "%s: %s\n", s, vpx_codec_error(ctx));
+ fprintf(stderr, "%s: %s\n", s, vpx_codec_error(ctx));
- if (detail)
- fprintf(stderr, " %s\n", detail);
+ if (detail)
+ fprintf(stderr, " %s\n", detail);
- exit(EXIT_FAILURE);
- }
+ exit(EXIT_FAILURE);
+ }
}
/* This structure is used to abstract the different ways of handling
* first pass statistics.
*/
-typedef struct
-{
- vpx_fixed_buf_t buf;
- int pass;
- FILE *file;
- char *buf_ptr;
- size_t buf_alloc_sz;
+typedef struct {
+ vpx_fixed_buf_t buf;
+ int pass;
+ FILE *file;
+ char *buf_ptr;
+ size_t buf_alloc_sz;
} stats_io_t;
-int stats_open_file(stats_io_t *stats, const char *fpf, int pass)
-{
- int res;
+int stats_open_file(stats_io_t *stats, const char *fpf, int pass) {
+ int res;
- stats->pass = pass;
+ stats->pass = pass;
- if (pass == 0)
- {
- stats->file = fopen(fpf, "wb");
- stats->buf.sz = 0;
- stats->buf.buf = NULL,
- res = (stats->file != NULL);
- }
- else
- {
+ if (pass == 0) {
+ stats->file = fopen(fpf, "wb");
+ stats->buf.sz = 0;
+ stats->buf.buf = NULL,
+ res = (stats->file != NULL);
+ } else {
#if 0
#elif USE_POSIX_MMAP
- struct stat stat_buf;
- int fd;
-
- fd = open(fpf, O_RDONLY);
- stats->file = fdopen(fd, "rb");
- fstat(fd, &stat_buf);
- stats->buf.sz = stat_buf.st_size;
- stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE,
- fd, 0);
- res = (stats->buf.buf != NULL);
+ struct stat stat_buf;
+ int fd;
+
+ fd = open(fpf, O_RDONLY);
+ stats->file = fdopen(fd, "rb");
+ fstat(fd, &stat_buf);
+ stats->buf.sz = stat_buf.st_size;
+ stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE,
+ fd, 0);
+ res = (stats->buf.buf != NULL);
#else
- size_t nbytes;
+ size_t nbytes;
- stats->file = fopen(fpf, "rb");
+ stats->file = fopen(fpf, "rb");
- if (fseek(stats->file, 0, SEEK_END))
- {
- fprintf(stderr, "First-pass stats file must be seekable!\n");
- exit(EXIT_FAILURE);
- }
+ if (fseek(stats->file, 0, SEEK_END)) {
+ fprintf(stderr, "First-pass stats file must be seekable!\n");
+ exit(EXIT_FAILURE);
+ }
- stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file);
- rewind(stats->file);
+ stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file);
+ rewind(stats->file);
- stats->buf.buf = malloc(stats->buf_alloc_sz);
+ stats->buf.buf = malloc(stats->buf_alloc_sz);
- if (!stats->buf.buf)
- {
- fprintf(stderr, "Failed to allocate first-pass stats buffer (%lu bytes)\n",
- (unsigned long)stats->buf_alloc_sz);
- exit(EXIT_FAILURE);
- }
+ if (!stats->buf.buf) {
+ fprintf(stderr, "Failed to allocate first-pass stats buffer (%lu bytes)\n",
+ (unsigned long)stats->buf_alloc_sz);
+ exit(EXIT_FAILURE);
+ }
- nbytes = fread(stats->buf.buf, 1, stats->buf.sz, stats->file);
- res = (nbytes == stats->buf.sz);
+ nbytes = fread(stats->buf.buf, 1, stats->buf.sz, stats->file);
+ res = (nbytes == stats->buf.sz);
#endif
- }
+ }
- return res;
+ return res;
}
-int stats_open_mem(stats_io_t *stats, int pass)
-{
- int res;
- stats->pass = pass;
+int stats_open_mem(stats_io_t *stats, int pass) {
+ int res;
+ stats->pass = pass;
- if (!pass)
- {
- stats->buf.sz = 0;
- stats->buf_alloc_sz = 64 * 1024;
- stats->buf.buf = malloc(stats->buf_alloc_sz);
- }
+ if (!pass) {
+ stats->buf.sz = 0;
+ stats->buf_alloc_sz = 64 * 1024;
+ stats->buf.buf = malloc(stats->buf_alloc_sz);
+ }
- stats->buf_ptr = stats->buf.buf;
- res = (stats->buf.buf != NULL);
- return res;
+ stats->buf_ptr = stats->buf.buf;
+ res = (stats->buf.buf != NULL);
+ return res;
}
-void stats_close(stats_io_t *stats, int last_pass)
-{
- if (stats->file)
- {
- if (stats->pass == last_pass)
- {
+void stats_close(stats_io_t *stats, int last_pass) {
+ if (stats->file) {
+ if (stats->pass == last_pass) {
#if 0
#elif USE_POSIX_MMAP
- munmap(stats->buf.buf, stats->buf.sz);
+ munmap(stats->buf.buf, stats->buf.sz);
#else
- free(stats->buf.buf);
+ free(stats->buf.buf);
#endif
- }
-
- fclose(stats->file);
- stats->file = NULL;
- }
- else
- {
- if (stats->pass == last_pass)
- free(stats->buf.buf);
}
+
+ fclose(stats->file);
+ stats->file = NULL;
+ } else {
+ if (stats->pass == last_pass)
+ free(stats->buf.buf);
+ }
}
-void stats_write(stats_io_t *stats, const void *pkt, size_t len)
-{
- if (stats->file)
- {
- if(fwrite(pkt, 1, len, stats->file));
+void stats_write(stats_io_t *stats, const void *pkt, size_t len) {
+ if (stats->file) {
+ if (fwrite(pkt, 1, len, stats->file));
+ } else {
+ if (stats->buf.sz + len > stats->buf_alloc_sz) {
+ size_t new_sz = stats->buf_alloc_sz + 64 * 1024;
+ char *new_ptr = realloc(stats->buf.buf, new_sz);
+
+ if (new_ptr) {
+ stats->buf_ptr = new_ptr + (stats->buf_ptr - (char *)stats->buf.buf);
+ stats->buf.buf = new_ptr;
+ stats->buf_alloc_sz = new_sz;
+ } else {
+ fprintf(stderr,
+ "\nFailed to realloc firstpass stats buffer.\n");
+ exit(EXIT_FAILURE);
+ }
}
- else
- {
- if (stats->buf.sz + len > stats->buf_alloc_sz)
- {
- size_t new_sz = stats->buf_alloc_sz + 64 * 1024;
- char *new_ptr = realloc(stats->buf.buf, new_sz);
-
- if (new_ptr)
- {
- stats->buf_ptr = new_ptr + (stats->buf_ptr - (char *)stats->buf.buf);
- stats->buf.buf = new_ptr;
- stats->buf_alloc_sz = new_sz;
- }
- else
- {
- fprintf(stderr,
- "\nFailed to realloc firstpass stats buffer.\n");
- exit(EXIT_FAILURE);
- }
- }
- memcpy(stats->buf_ptr, pkt, len);
- stats->buf.sz += len;
- stats->buf_ptr += len;
- }
+ memcpy(stats->buf_ptr, pkt, len);
+ stats->buf.sz += len;
+ stats->buf_ptr += len;
+ }
}
-vpx_fixed_buf_t stats_get(stats_io_t *stats)
-{
- return stats->buf;
+vpx_fixed_buf_t stats_get(stats_io_t *stats) {
+ return stats->buf;
}
/* Stereo 3D packed frame format */
-typedef enum stereo_format
-{
- STEREO_FORMAT_MONO = 0,
- STEREO_FORMAT_LEFT_RIGHT = 1,
- STEREO_FORMAT_BOTTOM_TOP = 2,
- STEREO_FORMAT_TOP_BOTTOM = 3,
- STEREO_FORMAT_RIGHT_LEFT = 11
+typedef enum stereo_format {
+ STEREO_FORMAT_MONO = 0,
+ STEREO_FORMAT_LEFT_RIGHT = 1,
+ STEREO_FORMAT_BOTTOM_TOP = 2,
+ STEREO_FORMAT_TOP_BOTTOM = 3,
+ STEREO_FORMAT_RIGHT_LEFT = 11
} stereo_format_t;
-enum video_file_type
-{
- FILE_TYPE_RAW,
- FILE_TYPE_IVF,
- FILE_TYPE_Y4M
+enum video_file_type {
+ FILE_TYPE_RAW,
+ FILE_TYPE_IVF,
+ FILE_TYPE_Y4M
};
struct detect_buffer {
- char buf[4];
- size_t buf_read;
- size_t position;
+ char buf[4];
+ size_t buf_read;
+ size_t position;
};
#define IVF_FRAME_HDR_SZ (4+8) /* 4 byte size + 8 byte timestamp */
static int read_frame(FILE *f, vpx_image_t *img, unsigned int file_type,
- y4m_input *y4m, struct detect_buffer *detect)
-{
- int plane = 0;
- int shortread = 0;
-
- if (file_type == FILE_TYPE_Y4M)
- {
- if (y4m_input_fetch_frame(y4m, f, img) < 1)
- return 0;
+ y4m_input *y4m, struct detect_buffer *detect) {
+ int plane = 0;
+ int shortread = 0;
+
+ if (file_type == FILE_TYPE_Y4M) {
+ if (y4m_input_fetch_frame(y4m, f, img) < 1)
+ return 0;
+ } else {
+ if (file_type == FILE_TYPE_IVF) {
+ char junk[IVF_FRAME_HDR_SZ];
+
+ /* Skip the frame header. We know how big the frame should be. See
+ * write_ivf_frame_header() for documentation on the frame header
+ * layout.
+ */
+ if (fread(junk, 1, IVF_FRAME_HDR_SZ, f));
}
- else
- {
- if (file_type == FILE_TYPE_IVF)
- {
- char junk[IVF_FRAME_HDR_SZ];
- /* Skip the frame header. We know how big the frame should be. See
- * write_ivf_frame_header() for documentation on the frame header
- * layout.
- */
- if(fread(junk, 1, IVF_FRAME_HDR_SZ, f));
+ for (plane = 0; plane < 3; plane++) {
+ unsigned char *ptr;
+ int w = (plane ? (1 + img->d_w) / 2 : img->d_w);
+ int h = (plane ? (1 + img->d_h) / 2 : img->d_h);
+ int r;
+
+ /* Determine the correct plane based on the image format. The for-loop
+ * always counts in Y,U,V order, but this may not match the order of
+ * the data on disk.
+ */
+ switch (plane) {
+ case 1:
+ ptr = img->planes[img->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_V : VPX_PLANE_U];
+ break;
+ case 2:
+ ptr = img->planes[img->fmt == VPX_IMG_FMT_YV12 ? VPX_PLANE_U : VPX_PLANE_V];
+ break;
+ default:
+ ptr = img->planes[plane];
+ }
+
+ for (r = 0; r < h; r++) {
+ size_t needed = w;
+ size_t buf_position = 0;
+ const size_t left = detect->buf_read - detect->position;
+ if (left > 0) {
+ const size_t more = (left < needed) ? left : needed;
+ memcpy(ptr, detect->buf + detect->position, more);
+ buf_position = more;
+ needed -= more;
+ detect->position += more;
}
-
- for (plane = 0; plane < 3; plane++)
- {
- unsigned char *ptr;
- int w = (plane ? (1 + img->d_w) / 2 : img->d_w);
- int h = (plane ? (1 + img->d_h) / 2 : img->d_h);
- int r;
-
- /* Determine the correct plane based on the image format. The for-loop
- * always counts in Y,U,V order, but this may not match the order of
- * the data on disk.
- */
- switch (plane)
- {
- case 1:
- ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12? VPX_PLANE_V : VPX_PLANE_U];
- break;
- case 2:
- ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12?VPX_PLANE_U : VPX_PLANE_V];
- break;
- default:
- ptr = img->planes[plane];
- }
-
- for (r = 0; r < h; r++)
- {
- size_t needed = w;
- size_t buf_position = 0;
- const size_t left = detect->buf_read - detect->position;
- if (left > 0)
- {
- const size_t more = (left < needed) ? left : needed;
- memcpy(ptr, detect->buf + detect->position, more);
- buf_position = more;
- needed -= more;
- detect->position += more;
- }
- if (needed > 0)
- {
- shortread |= (fread(ptr + buf_position, 1, needed, f) < needed);
- }
-
- ptr += img->stride[plane];
- }
+ if (needed > 0) {
+ shortread |= (fread(ptr + buf_position, 1, needed, f) < needed);
}
+
+ ptr += img->stride[plane];
+ }
}
+ }
- return !shortread;
+ return !shortread;
}
unsigned int file_is_y4m(FILE *infile,
y4m_input *y4m,
- char detect[4])
-{
- if(memcmp(detect, "YUV4", 4) == 0)
- {
- return 1;
- }
- return 0;
+ char detect[4]) {
+ if (memcmp(detect, "YUV4", 4) == 0) {
+ return 1;
+ }
+ return 0;
}
#define IVF_FILE_HDR_SZ (32)
@@ -393,272 +349,257 @@ unsigned int file_is_ivf(FILE *infile,
unsigned int *fourcc,
unsigned int *width,
unsigned int *height,
- struct detect_buffer *detect)
-{
- char raw_hdr[IVF_FILE_HDR_SZ];
- int is_ivf = 0;
+ struct detect_buffer *detect) {
+ char raw_hdr[IVF_FILE_HDR_SZ];
+ int is_ivf = 0;
- if(memcmp(detect->buf, "DKIF", 4) != 0)
- return 0;
+ if (memcmp(detect->buf, "DKIF", 4) != 0)
+ return 0;
- /* See write_ivf_file_header() for more documentation on the file header
- * layout.
- */
- if (fread(raw_hdr + 4, 1, IVF_FILE_HDR_SZ - 4, infile)
- == IVF_FILE_HDR_SZ - 4)
+ /* See write_ivf_file_header() for more documentation on the file header
+ * layout.
+ */
+ if (fread(raw_hdr + 4, 1, IVF_FILE_HDR_SZ - 4, infile)
+ == IVF_FILE_HDR_SZ - 4) {
{
- {
- is_ivf = 1;
+ is_ivf = 1;
- if (mem_get_le16(raw_hdr + 4) != 0)
- fprintf(stderr, "Error: Unrecognized IVF version! This file may not"
- " decode properly.");
+ if (mem_get_le16(raw_hdr + 4) != 0)
+ fprintf(stderr, "Error: Unrecognized IVF version! This file may not"
+ " decode properly.");
- *fourcc = mem_get_le32(raw_hdr + 8);
- }
+ *fourcc = mem_get_le32(raw_hdr + 8);
}
+ }
- if (is_ivf)
- {
- *width = mem_get_le16(raw_hdr + 12);
- *height = mem_get_le16(raw_hdr + 14);
- detect->position = 4;
- }
+ if (is_ivf) {
+ *width = mem_get_le16(raw_hdr + 12);
+ *height = mem_get_le16(raw_hdr + 14);
+ detect->position = 4;
+ }
- return is_ivf;
+ return is_ivf;
}
static void write_ivf_file_header(FILE *outfile,
const vpx_codec_enc_cfg_t *cfg,
unsigned int fourcc,
- int frame_cnt)
-{
- char header[32];
-
- if (cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
- return;
-
- header[0] = 'D';
- header[1] = 'K';
- header[2] = 'I';
- header[3] = 'F';
- mem_put_le16(header + 4, 0); /* version */
- mem_put_le16(header + 6, 32); /* headersize */
- mem_put_le32(header + 8, fourcc); /* headersize */
- mem_put_le16(header + 12, cfg->g_w); /* width */
- mem_put_le16(header + 14, cfg->g_h); /* height */
- mem_put_le32(header + 16, cfg->g_timebase.den); /* rate */
- mem_put_le32(header + 20, cfg->g_timebase.num); /* scale */
- mem_put_le32(header + 24, frame_cnt); /* length */
- mem_put_le32(header + 28, 0); /* unused */
-
- if(fwrite(header, 1, 32, outfile));
+ int frame_cnt) {
+ char header[32];
+
+ if (cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
+ return;
+
+ header[0] = 'D';
+ header[1] = 'K';
+ header[2] = 'I';
+ header[3] = 'F';
+ mem_put_le16(header + 4, 0); /* version */
+ mem_put_le16(header + 6, 32); /* headersize */
+ mem_put_le32(header + 8, fourcc); /* headersize */
+ mem_put_le16(header + 12, cfg->g_w); /* width */
+ mem_put_le16(header + 14, cfg->g_h); /* height */
+ mem_put_le32(header + 16, cfg->g_timebase.den); /* rate */
+ mem_put_le32(header + 20, cfg->g_timebase.num); /* scale */
+ mem_put_le32(header + 24, frame_cnt); /* length */
+ mem_put_le32(header + 28, 0); /* unused */
+
+ if (fwrite(header, 1, 32, outfile));
}
static void write_ivf_frame_header(FILE *outfile,
- const vpx_codec_cx_pkt_t *pkt)
-{
- char header[12];
- vpx_codec_pts_t pts;
+ const vpx_codec_cx_pkt_t *pkt) {
+ char header[12];
+ vpx_codec_pts_t pts;
- if (pkt->kind != VPX_CODEC_CX_FRAME_PKT)
- return;
+ if (pkt->kind != VPX_CODEC_CX_FRAME_PKT)
+ return;
- pts = pkt->data.frame.pts;
- mem_put_le32(header, pkt->data.frame.sz);
- mem_put_le32(header + 4, pts & 0xFFFFFFFF);
- mem_put_le32(header + 8, pts >> 32);
+ pts = pkt->data.frame.pts;
+ mem_put_le32(header, pkt->data.frame.sz);
+ mem_put_le32(header + 4, pts & 0xFFFFFFFF);
+ mem_put_le32(header + 8, pts >> 32);
- if(fwrite(header, 1, 12, outfile));
+ if (fwrite(header, 1, 12, outfile));
}
typedef off_t EbmlLoc;
-struct cue_entry
-{
- unsigned int time;
- uint64_t loc;
+struct cue_entry {
+ unsigned int time;
+ uint64_t loc;
};
-struct EbmlGlobal
-{
- int debug;
+struct EbmlGlobal {
+ int debug;
- FILE *stream;
- int64_t last_pts_ms;
- vpx_rational_t framerate;
+ FILE *stream;
+ int64_t last_pts_ms;
+ vpx_rational_t framerate;
- /* These pointers are to the start of an element */
- off_t position_reference;
- off_t seek_info_pos;
- off_t segment_info_pos;
- off_t track_pos;
- off_t cue_pos;
- off_t cluster_pos;
+ /* These pointers are to the start of an element */
+ off_t position_reference;
+ off_t seek_info_pos;
+ off_t segment_info_pos;
+ off_t track_pos;
+ off_t cue_pos;
+ off_t cluster_pos;
- /* This pointer is to a specific element to be serialized */
- off_t track_id_pos;
+ /* This pointer is to a specific element to be serialized */
+ off_t track_id_pos;
- /* These pointers are to the size field of the element */
- EbmlLoc startSegment;
- EbmlLoc startCluster;
+ /* These pointers are to the size field of the element */
+ EbmlLoc startSegment;
+ EbmlLoc startCluster;
- uint32_t cluster_timecode;
- int cluster_open;
+ uint32_t cluster_timecode;
+ int cluster_open;
- struct cue_entry *cue_list;
- unsigned int cues;
+ struct cue_entry *cue_list;
+ unsigned int cues;
};
-void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
-{
- if(fwrite(buffer_in, 1, len, glob->stream));
+void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
+ if (fwrite(buffer_in, 1, len, glob->stream));
}
#define WRITE_BUFFER(s) \
-for(i = len-1; i>=0; i--)\
-{ \
+ for(i = len-1; i>=0; i--)\
+ { \
x = *(const s *)buffer_in >> (i * CHAR_BIT); \
Ebml_Write(glob, &x, 1); \
-}
-void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, int buffer_size, unsigned long len)
-{
- char x;
- int i;
-
- /* buffer_size:
- * 1 - int8_t;
- * 2 - int16_t;
- * 3 - int32_t;
- * 4 - int64_t;
- */
- switch (buffer_size)
- {
- case 1:
- WRITE_BUFFER(int8_t)
- break;
- case 2:
- WRITE_BUFFER(int16_t)
- break;
- case 4:
- WRITE_BUFFER(int32_t)
- break;
- case 8:
- WRITE_BUFFER(int64_t)
- break;
- default:
- break;
- }
+ }
+void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, int buffer_size, unsigned long len) {
+ char x;
+ int i;
+
+ /* buffer_size:
+ * 1 - int8_t;
+ * 2 - int16_t;
+ * 3 - int32_t;
+ * 4 - int64_t;
+ */
+ switch (buffer_size) {
+ case 1:
+ WRITE_BUFFER(int8_t)
+ break;
+ case 2:
+ WRITE_BUFFER(int16_t)
+ break;
+ case 4:
+ WRITE_BUFFER(int32_t)
+ break;
+ case 8:
+ WRITE_BUFFER(int64_t)
+ break;
+ default:
+ break;
+ }
}
#undef WRITE_BUFFER
/* Need a fixed size serializer for the track ID. libmkv provides a 64 bit
* one, but not a 32 bit one.
*/
-static void Ebml_SerializeUnsigned32(EbmlGlobal *glob, unsigned long class_id, uint64_t ui)
-{
- unsigned char sizeSerialized = 4 | 0x80;
- Ebml_WriteID(glob, class_id);
- Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
- Ebml_Serialize(glob, &ui, sizeof(ui), 4);
+static void Ebml_SerializeUnsigned32(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) {
+ unsigned char sizeSerialized = 4 | 0x80;
+ Ebml_WriteID(glob, class_id);
+ Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
+ Ebml_Serialize(glob, &ui, sizeof(ui), 4);
}
static void
Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc,
- unsigned long class_id)
-{
- //todo this is always taking 8 bytes, this may need later optimization
- //this is a key that says length unknown
- uint64_t unknownLen = LITERALU64(0x01FFFFFFFFFFFFFF);
-
- Ebml_WriteID(glob, class_id);
- *ebmlLoc = ftello(glob->stream);
- Ebml_Serialize(glob, &unknownLen, sizeof(unknownLen), 8);
+ unsigned long class_id) {
+ // todo this is always taking 8 bytes, this may need later optimization
+ // this is a key that says length unknown
+ uint64_t unknownLen = LITERALU64(0x01FFFFFFFFFFFFFF);
+
+ Ebml_WriteID(glob, class_id);
+ *ebmlLoc = ftello(glob->stream);
+ Ebml_Serialize(glob, &unknownLen, sizeof(unknownLen), 8);
}
static void
-Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc)
-{
- off_t pos;
- uint64_t size;
+Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
+ off_t pos;
+ uint64_t size;
- /* Save the current stream pointer */
- pos = ftello(glob->stream);
+ /* Save the current stream pointer */
+ pos = ftello(glob->stream);
- /* Calculate the size of this element */
- size = pos - *ebmlLoc - 8;
- size |= LITERALU64(0x0100000000000000);
+ /* Calculate the size of this element */
+ size = pos - *ebmlLoc - 8;
+ size |= LITERALU64(0x0100000000000000);
- /* Seek back to the beginning of the element and write the new size */
- fseeko(glob->stream, *ebmlLoc, SEEK_SET);
- Ebml_Serialize(glob, &size, sizeof(size), 8);
+ /* Seek back to the beginning of the element and write the new size */
+ fseeko(glob->stream, *ebmlLoc, SEEK_SET);
+ Ebml_Serialize(glob, &size, sizeof(size), 8);
- /* Reset the stream pointer */
- fseeko(glob->stream, pos, SEEK_SET);
+ /* Reset the stream pointer */
+ fseeko(glob->stream, pos, SEEK_SET);
}
static void
-write_webm_seek_element(EbmlGlobal *ebml, unsigned long id, off_t pos)
-{
- uint64_t offset = pos - ebml->position_reference;
- EbmlLoc start;
- Ebml_StartSubElement(ebml, &start, Seek);
- Ebml_SerializeBinary(ebml, SeekID, id);
- Ebml_SerializeUnsigned64(ebml, SeekPosition, offset);
- Ebml_EndSubElement(ebml, &start);
+write_webm_seek_element(EbmlGlobal *ebml, unsigned long id, off_t pos) {
+ uint64_t offset = pos - ebml->position_reference;
+ EbmlLoc start;
+ Ebml_StartSubElement(ebml, &start, Seek);
+ Ebml_SerializeBinary(ebml, SeekID, id);
+ Ebml_SerializeUnsigned64(ebml, SeekPosition, offset);
+ Ebml_EndSubElement(ebml, &start);
}
static void
-write_webm_seek_info(EbmlGlobal *ebml)
-{
+write_webm_seek_info(EbmlGlobal *ebml) {
- off_t pos;
+ off_t pos;
- /* Save the current stream pointer */
- pos = ftello(ebml->stream);
+ /* Save the current stream pointer */
+ pos = ftello(ebml->stream);
- if(ebml->seek_info_pos)
- fseeko(ebml->stream, ebml->seek_info_pos, SEEK_SET);
- else
- ebml->seek_info_pos = pos;
+ if (ebml->seek_info_pos)
+ fseeko(ebml->stream, ebml->seek_info_pos, SEEK_SET);
+ else
+ ebml->seek_info_pos = pos;
- {
- EbmlLoc start;
+ {
+ EbmlLoc start;
- Ebml_StartSubElement(ebml, &start, SeekHead);
- write_webm_seek_element(ebml, Tracks, ebml->track_pos);
- write_webm_seek_element(ebml, Cues, ebml->cue_pos);
- write_webm_seek_element(ebml, Info, ebml->segment_info_pos);
- Ebml_EndSubElement(ebml, &start);
- }
- {
- //segment info
- EbmlLoc startInfo;
- uint64_t frame_time;
-
- frame_time = (uint64_t)1000 * ebml->framerate.den
- / ebml->framerate.num;
- ebml->segment_info_pos = ftello(ebml->stream);
- Ebml_StartSubElement(ebml, &startInfo, Info);
- Ebml_SerializeUnsigned(ebml, TimecodeScale, 1000000);
- Ebml_SerializeFloat(ebml, Segment_Duration,
- ebml->last_pts_ms + frame_time);
- Ebml_SerializeString(ebml, 0x4D80,
- ebml->debug ? "vpxenc" : "vpxenc" VERSION_STRING);
- Ebml_SerializeString(ebml, 0x5741,
- ebml->debug ? "vpxenc" : "vpxenc" VERSION_STRING);
- Ebml_EndSubElement(ebml, &startInfo);
- }
+ Ebml_StartSubElement(ebml, &start, SeekHead);
+ write_webm_seek_element(ebml, Tracks, ebml->track_pos);
+ write_webm_seek_element(ebml, Cues, ebml->cue_pos);
+ write_webm_seek_element(ebml, Info, ebml->segment_info_pos);
+ Ebml_EndSubElement(ebml, &start);
+ }
+ {
+ // segment info
+ EbmlLoc startInfo;
+ uint64_t frame_time;
+
+ frame_time = (uint64_t)1000 * ebml->framerate.den
+ / ebml->framerate.num;
+ ebml->segment_info_pos = ftello(ebml->stream);
+ Ebml_StartSubElement(ebml, &startInfo, Info);
+ Ebml_SerializeUnsigned(ebml, TimecodeScale, 1000000);
+ Ebml_SerializeFloat(ebml, Segment_Duration,
+ ebml->last_pts_ms + frame_time);
+ Ebml_SerializeString(ebml, 0x4D80,
+ ebml->debug ? "vpxenc" : "vpxenc" VERSION_STRING);
+ Ebml_SerializeString(ebml, 0x5741,
+ ebml->debug ? "vpxenc" : "vpxenc" VERSION_STRING);
+ Ebml_EndSubElement(ebml, &startInfo);
+ }
}
@@ -666,1646 +607,1525 @@ static void
write_webm_file_header(EbmlGlobal *glob,
const vpx_codec_enc_cfg_t *cfg,
const struct vpx_rational *fps,
- stereo_format_t stereo_fmt)
-{
- {
- EbmlLoc start;
- Ebml_StartSubElement(glob, &start, EBML);
- Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
- Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); //EBML Read Version
- Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); //EBML Max ID Length
- Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); //EBML Max Size Length
- Ebml_SerializeString(glob, DocType, "webm"); //Doc Type
- Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); //Doc Type Version
- Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); //Doc Type Read Version
- Ebml_EndSubElement(glob, &start);
- }
+ stereo_format_t stereo_fmt) {
+ {
+ EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, EBML);
+ Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
+ Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); // EBML Read Version
+ Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); // EBML Max ID Length
+ Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); // EBML Max Size Length
+ Ebml_SerializeString(glob, DocType, "webm"); // Doc Type
+ Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); // Doc Type Version
+ Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); // Doc Type Read Version
+ Ebml_EndSubElement(glob, &start);
+ }
+ {
+ Ebml_StartSubElement(glob, &glob->startSegment, Segment); // segment
+ glob->position_reference = ftello(glob->stream);
+ glob->framerate = *fps;
+ write_webm_seek_info(glob);
+
{
- Ebml_StartSubElement(glob, &glob->startSegment, Segment); //segment
- glob->position_reference = ftello(glob->stream);
- glob->framerate = *fps;
- write_webm_seek_info(glob);
+ EbmlLoc trackStart;
+ glob->track_pos = ftello(glob->stream);
+ Ebml_StartSubElement(glob, &trackStart, Tracks);
+ {
+ unsigned int trackNumber = 1;
+ uint64_t trackID = 0;
+ EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, TrackEntry);
+ Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
+ glob->track_id_pos = ftello(glob->stream);
+ Ebml_SerializeUnsigned32(glob, TrackUID, trackID);
+ Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1
+ Ebml_SerializeString(glob, CodecID, "V_VP8");
{
- EbmlLoc trackStart;
- glob->track_pos = ftello(glob->stream);
- Ebml_StartSubElement(glob, &trackStart, Tracks);
- {
- unsigned int trackNumber = 1;
- uint64_t trackID = 0;
-
- EbmlLoc start;
- Ebml_StartSubElement(glob, &start, TrackEntry);
- Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
- glob->track_id_pos = ftello(glob->stream);
- Ebml_SerializeUnsigned32(glob, TrackUID, trackID);
- Ebml_SerializeUnsigned(glob, TrackType, 1); //video is always 1
- Ebml_SerializeString(glob, CodecID, "V_VP8");
- {
- unsigned int pixelWidth = cfg->g_w;
- unsigned int pixelHeight = cfg->g_h;
- float frameRate = (float)fps->num/(float)fps->den;
-
- EbmlLoc videoStart;
- Ebml_StartSubElement(glob, &videoStart, Video);
- Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
- Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
- Ebml_SerializeUnsigned(glob, StereoMode, stereo_fmt);
- Ebml_SerializeFloat(glob, FrameRate, frameRate);
- Ebml_EndSubElement(glob, &videoStart); //Video
- }
- Ebml_EndSubElement(glob, &start); //Track Entry
- }
- Ebml_EndSubElement(glob, &trackStart);
+ unsigned int pixelWidth = cfg->g_w;
+ unsigned int pixelHeight = cfg->g_h;
+ float frameRate = (float)fps->num / (float)fps->den;
+
+ EbmlLoc videoStart;
+ Ebml_StartSubElement(glob, &videoStart, Video);
+ Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
+ Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
+ Ebml_SerializeUnsigned(glob, StereoMode, stereo_fmt);
+ Ebml_SerializeFloat(glob, FrameRate, frameRate);
+ Ebml_EndSubElement(glob, &videoStart); // Video
}
- // segment element is open
+ Ebml_EndSubElement(glob, &start); // Track Entry
+ }
+ Ebml_EndSubElement(glob, &trackStart);
}
+ // segment element is open
+ }
}
static void
write_webm_block(EbmlGlobal *glob,
const vpx_codec_enc_cfg_t *cfg,
- const vpx_codec_cx_pkt_t *pkt)
-{
- unsigned long block_length;
- unsigned char track_number;
- unsigned short block_timecode = 0;
- unsigned char flags;
- int64_t pts_ms;
- int start_cluster = 0, is_keyframe;
-
- /* Calculate the PTS of this frame in milliseconds */
- pts_ms = pkt->data.frame.pts * 1000
- * (uint64_t)cfg->g_timebase.num / (uint64_t)cfg->g_timebase.den;
- if(pts_ms <= glob->last_pts_ms)
- pts_ms = glob->last_pts_ms + 1;
- glob->last_pts_ms = pts_ms;
-
- /* Calculate the relative time of this block */
- if(pts_ms - glob->cluster_timecode > SHRT_MAX)
- start_cluster = 1;
- else
- block_timecode = pts_ms - glob->cluster_timecode;
-
- is_keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY);
- if(start_cluster || is_keyframe)
- {
- if(glob->cluster_open)
- Ebml_EndSubElement(glob, &glob->startCluster);
-
- /* Open the new cluster */
- block_timecode = 0;
- glob->cluster_open = 1;
- glob->cluster_timecode = pts_ms;
- glob->cluster_pos = ftello(glob->stream);
- Ebml_StartSubElement(glob, &glob->startCluster, Cluster); //cluster
- Ebml_SerializeUnsigned(glob, Timecode, glob->cluster_timecode);
-
- /* Save a cue point if this is a keyframe. */
- if(is_keyframe)
- {
- struct cue_entry *cue, *new_cue_list;
-
- new_cue_list = realloc(glob->cue_list,
- (glob->cues+1) * sizeof(struct cue_entry));
- if(new_cue_list)
- glob->cue_list = new_cue_list;
- else
- {
- fprintf(stderr, "\nFailed to realloc cue list.\n");
- exit(EXIT_FAILURE);
- }
+ const vpx_codec_cx_pkt_t *pkt) {
+ unsigned long block_length;
+ unsigned char track_number;
+ unsigned short block_timecode = 0;
+ unsigned char flags;
+ int64_t pts_ms;
+ int start_cluster = 0, is_keyframe;
+
+ /* Calculate the PTS of this frame in milliseconds */
+ pts_ms = pkt->data.frame.pts * 1000
+ * (uint64_t)cfg->g_timebase.num / (uint64_t)cfg->g_timebase.den;
+ if (pts_ms <= glob->last_pts_ms)
+ pts_ms = glob->last_pts_ms + 1;
+ glob->last_pts_ms = pts_ms;
+
+ /* Calculate the relative time of this block */
+ if (pts_ms - glob->cluster_timecode > SHRT_MAX)
+ start_cluster = 1;
+ else
+ block_timecode = pts_ms - glob->cluster_timecode;
+
+ is_keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY);
+ if (start_cluster || is_keyframe) {
+ if (glob->cluster_open)
+ Ebml_EndSubElement(glob, &glob->startCluster);
+
+ /* Open the new cluster */
+ block_timecode = 0;
+ glob->cluster_open = 1;
+ glob->cluster_timecode = pts_ms;
+ glob->cluster_pos = ftello(glob->stream);
+ Ebml_StartSubElement(glob, &glob->startCluster, Cluster); // cluster
+ Ebml_SerializeUnsigned(glob, Timecode, glob->cluster_timecode);
+
+ /* Save a cue point if this is a keyframe. */
+ if (is_keyframe) {
+ struct cue_entry *cue, *new_cue_list;
+
+ new_cue_list = realloc(glob->cue_list,
+ (glob->cues + 1) * sizeof(struct cue_entry));
+ if (new_cue_list)
+ glob->cue_list = new_cue_list;
+ else {
+ fprintf(stderr, "\nFailed to realloc cue list.\n");
+ exit(EXIT_FAILURE);
+ }
- cue = &glob->cue_list[glob->cues];
- cue->time = glob->cluster_timecode;
- cue->loc = glob->cluster_pos;
- glob->cues++;
- }
+ cue = &glob->cue_list[glob->cues];
+ cue->time = glob->cluster_timecode;
+ cue->loc = glob->cluster_pos;
+ glob->cues++;
}
+ }
- /* Write the Simple Block */
- Ebml_WriteID(glob, SimpleBlock);
+ /* Write the Simple Block */
+ Ebml_WriteID(glob, SimpleBlock);
- block_length = pkt->data.frame.sz + 4;
- block_length |= 0x10000000;
- Ebml_Serialize(glob, &block_length, sizeof(block_length), 4);
+ block_length = pkt->data.frame.sz + 4;
+ block_length |= 0x10000000;
+ Ebml_Serialize(glob, &block_length, sizeof(block_length), 4);
- track_number = 1;
- track_number |= 0x80;
- Ebml_Write(glob, &track_number, 1);
+ track_number = 1;
+ track_number |= 0x80;
+ Ebml_Write(glob, &track_number, 1);
- Ebml_Serialize(glob, &block_timecode, sizeof(block_timecode), 2);
+ Ebml_Serialize(glob, &block_timecode, sizeof(block_timecode), 2);
- flags = 0;
- if(is_keyframe)
- flags |= 0x80;
- if(pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE)
- flags |= 0x08;
- Ebml_Write(glob, &flags, 1);
+ flags = 0;
+ if (is_keyframe)
+ flags |= 0x80;
+ if (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE)
+ flags |= 0x08;
+ Ebml_Write(glob, &flags, 1);
- Ebml_Write(glob, pkt->data.frame.buf, pkt->data.frame.sz);
+ Ebml_Write(glob, pkt->data.frame.buf, pkt->data.frame.sz);
}
static void
-write_webm_file_footer(EbmlGlobal *glob, long hash)
-{
+write_webm_file_footer(EbmlGlobal *glob, long hash) {
- if(glob->cluster_open)
- Ebml_EndSubElement(glob, &glob->startCluster);
+ if (glob->cluster_open)
+ Ebml_EndSubElement(glob, &glob->startCluster);
- {
- EbmlLoc start;
- int i;
+ {
+ EbmlLoc start;
+ int i;
- glob->cue_pos = ftello(glob->stream);
- Ebml_StartSubElement(glob, &start, Cues);
- for(i=0; i<glob->cues; i++)
- {
- struct cue_entry *cue = &glob->cue_list[i];
- EbmlLoc start;
+ glob->cue_pos = ftello(glob->stream);
+ Ebml_StartSubElement(glob, &start, Cues);
+ for (i = 0; i < glob->cues; i++) {
+ struct cue_entry *cue = &glob->cue_list[i];
+ EbmlLoc start;
- Ebml_StartSubElement(glob, &start, CuePoint);
- {
- EbmlLoc start;
+ Ebml_StartSubElement(glob, &start, CuePoint);
+ {
+ EbmlLoc start;
- Ebml_SerializeUnsigned(glob, CueTime, cue->time);
+ Ebml_SerializeUnsigned(glob, CueTime, cue->time);
- Ebml_StartSubElement(glob, &start, CueTrackPositions);
- Ebml_SerializeUnsigned(glob, CueTrack, 1);
- Ebml_SerializeUnsigned64(glob, CueClusterPosition,
- cue->loc - glob->position_reference);
- //Ebml_SerializeUnsigned(glob, CueBlockNumber, cue->blockNumber);
- Ebml_EndSubElement(glob, &start);
- }
- Ebml_EndSubElement(glob, &start);
- }
+ Ebml_StartSubElement(glob, &start, CueTrackPositions);
+ Ebml_SerializeUnsigned(glob, CueTrack, 1);
+ Ebml_SerializeUnsigned64(glob, CueClusterPosition,
+ cue->loc - glob->position_reference);
+ // Ebml_SerializeUnsigned(glob, CueBlockNumber, cue->blockNumber);
Ebml_EndSubElement(glob, &start);
+ }
+ Ebml_EndSubElement(glob, &start);
}
+ Ebml_EndSubElement(glob, &start);
+ }
- Ebml_EndSubElement(glob, &glob->startSegment);
+ Ebml_EndSubElement(glob, &glob->startSegment);
- /* Patch up the seek info block */
- write_webm_seek_info(glob);
+ /* Patch up the seek info block */
+ write_webm_seek_info(glob);
- /* Patch up the track id */
- fseeko(glob->stream, glob->track_id_pos, SEEK_SET);
- Ebml_SerializeUnsigned32(glob, TrackUID, glob->debug ? 0xDEADBEEF : hash);
+ /* Patch up the track id */
+ fseeko(glob->stream, glob->track_id_pos, SEEK_SET);
+ Ebml_SerializeUnsigned32(glob, TrackUID, glob->debug ? 0xDEADBEEF : hash);
- fseeko(glob->stream, 0, SEEK_END);
+ fseeko(glob->stream, 0, SEEK_END);
}
/* Murmur hash derived from public domain reference implementation at
- * http://sites.google.com/site/murmurhash/
+ * http:// sites.google.com/site/murmurhash/
*/
-static unsigned int murmur ( const void * key, int len, unsigned int seed )
-{
- const unsigned int m = 0x5bd1e995;
- const int r = 24;
+static unsigned int murmur(const void *key, int len, unsigned int seed) {
+ const unsigned int m = 0x5bd1e995;
+ const int r = 24;
- unsigned int h = seed ^ len;
+ unsigned int h = seed ^ len;
- const unsigned char * data = (const unsigned char *)key;
+ const unsigned char *data = (const unsigned char *)key;
- while(len >= 4)
- {
- unsigned int k;
+ while (len >= 4) {
+ unsigned int k;
- k = data[0];
- k |= data[1] << 8;
- k |= data[2] << 16;
- k |= data[3] << 24;
+ k = data[0];
+ k |= data[1] << 8;
+ k |= data[2] << 16;
+ k |= data[3] << 24;
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
+ k *= m;
+ k ^= k >> r;
+ k *= m;
- h ^= h >> 13;
h *= m;
- h ^= h >> 15;
-
- return h;
+ h ^= k;
+
+ data += 4;
+ len -= 4;
+ }
+
+ switch (len) {
+ case 3:
+ h ^= data[2] << 16;
+ case 2:
+ h ^= data[1] << 8;
+ case 1:
+ h ^= data[0];
+ h *= m;
+ };
+
+ h ^= h >> 13;
+ h *= m;
+ h ^= h >> 15;
+
+ return h;
}
#include "math.h"
#define MAX_PSNR 100
-static double vp8_mse2psnr(double Samples, double Peak, double Mse)
-{
- double psnr;
+static double vp8_mse2psnr(double Samples, double Peak, double Mse) {
+ double psnr;
- if ((double)Mse > 0.0)
- psnr = 10.0 * log10(Peak * Peak * Samples / Mse);
- else
- psnr = MAX_PSNR; // Limit to prevent / 0
+ if ((double)Mse > 0.0)
+ psnr = 10.0 * log10(Peak * Peak * Samples / Mse);
+ else
+ psnr = MAX_PSNR; // Limit to prevent / 0
- if (psnr > MAX_PSNR)
- psnr = MAX_PSNR;
+ if (psnr > MAX_PSNR)
+ psnr = MAX_PSNR;
- return psnr;
+ return psnr;
}
#include "args.h"
static const arg_def_t debugmode = ARG_DEF("D", "debug", 0,
- "Debug mode (makes output deterministic)");
+ "Debug mode (makes output deterministic)");
static const arg_def_t outputfile = ARG_DEF("o", "output", 1,
- "Output filename");
+ "Output filename");
static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0,
- "Input file is YV12 ");
+ "Input file is YV12 ");
static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0,
- "Input file is I420 (default)");
+ "Input file is I420 (default)");
static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1,
- "Codec to use");
+ "Codec to use");
static const arg_def_t passes = ARG_DEF("p", "passes", 1,
- "Number of passes (1/2)");
+ "Number of passes (1/2)");
static const arg_def_t pass_arg = ARG_DEF(NULL, "pass", 1,
- "Pass to execute (1/2)");
+ "Pass to execute (1/2)");
static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1,
- "First pass statistics file name");
+ "First pass statistics file name");
static const arg_def_t limit = ARG_DEF(NULL, "limit", 1,
"Stop encoding after n input frames");
static const arg_def_t skip = ARG_DEF(NULL, "skip", 1,
- "Skip the first n input frames");
+ "Skip the first n input frames");
static const arg_def_t deadline = ARG_DEF("d", "deadline", 1,
- "Deadline per frame (usec)");
+ "Deadline per frame (usec)");
static const arg_def_t best_dl = ARG_DEF(NULL, "best", 0,
- "Use Best Quality Deadline");
+ "Use Best Quality Deadline");
static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0,
- "Use Good Quality Deadline");
+ "Use Good Quality Deadline");
static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0,
- "Use Realtime Quality Deadline");
+ "Use Realtime Quality Deadline");
static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0,
- "Show encoder parameters");
+ "Show encoder parameters");
static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0,
- "Show PSNR in status line");
+ "Show PSNR in status line");
static const arg_def_t recontest = ARG_DEF(NULL, "test-decode", 0,
- "Test enocde/decode have machted recon buffer");
+ "Test enocde/decode have machted recon buffer");
static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1,
- "Stream frame rate (rate/scale)");
+ "Stream frame rate (rate/scale)");
static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0,
- "Output IVF (default is WebM)");
+ "Output IVF (default is WebM)");
static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1,
- "Show quantizer histogram (n-buckets)");
+ "Show quantizer histogram (n-buckets)");
static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1,
- "Show rate histogram (n-buckets)");
+ "Show rate histogram (n-buckets)");
#if CONFIG_LOSSLESS
static const arg_def_t lossless_enabled = ARG_DEF(NULL, "lossless", 0,
- "Enable lossless compression");
+ "Enable lossless compression");
#endif
-static const arg_def_t *main_args[] =
-{
- &debugmode,
- &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip,
- &deadline,
- &best_dl, &good_dl, &rt_dl,
- &verbosearg, &psnrarg, &recontest, &use_ivf, &q_hist_n, &rate_hist_n,
+static const arg_def_t *main_args[] = {
+ &debugmode,
+ &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip,
+ &deadline,
+ &best_dl, &good_dl, &rt_dl,
+ &verbosearg, &psnrarg, &recontest, &use_ivf, &q_hist_n, &rate_hist_n,
#if CONFIG_LOSSLESS
- &lossless_enabled,
+ &lossless_enabled,
#endif
- NULL
+ NULL
};
static const arg_def_t usage = ARG_DEF("u", "usage", 1,
- "Usage profile number to use");
+ "Usage profile number to use");
static const arg_def_t threads = ARG_DEF("t", "threads", 1,
- "Max number of threads to use");
+ "Max number of threads to use");
static const arg_def_t profile = ARG_DEF(NULL, "profile", 1,
- "Bitstream profile number to use");
+ "Bitstream profile number to use");
static const arg_def_t width = ARG_DEF("w", "width", 1,
- "Frame width");
+ "Frame width");
static const arg_def_t height = ARG_DEF("h", "height", 1,
- "Frame height");
+ "Frame height");
static const struct arg_enum_list stereo_mode_enum[] = {
- {"mono" , STEREO_FORMAT_MONO},
- {"left-right", STEREO_FORMAT_LEFT_RIGHT},
- {"bottom-top", STEREO_FORMAT_BOTTOM_TOP},
- {"top-bottom", STEREO_FORMAT_TOP_BOTTOM},
- {"right-left", STEREO_FORMAT_RIGHT_LEFT},
- {NULL, 0}
+ {"mono", STEREO_FORMAT_MONO},
+ {"left-right", STEREO_FORMAT_LEFT_RIGHT},
+ {"bottom-top", STEREO_FORMAT_BOTTOM_TOP},
+ {"top-bottom", STEREO_FORMAT_TOP_BOTTOM},
+ {"right-left", STEREO_FORMAT_RIGHT_LEFT},
+ {NULL, 0}
};
static const arg_def_t stereo_mode = ARG_DEF_ENUM(NULL, "stereo-mode", 1,
- "Stereo 3D video format", stereo_mode_enum);
+ "Stereo 3D video format", stereo_mode_enum);
static const arg_def_t timebase = ARG_DEF(NULL, "timebase", 1,
- "Output timestamp precision (fractional seconds)");
+ "Output timestamp precision (fractional seconds)");
static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1,
- "Enable error resiliency features");
+ "Enable error resiliency features");
static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1,
- "Max number of frames to lag");
+ "Max number of frames to lag");
-static const arg_def_t *global_args[] =
-{
- &use_yv12, &use_i420, &usage, &threads, &profile,
- &width, &height, &stereo_mode, &timebase, &framerate, &error_resilient,
- &lag_in_frames, NULL
+static const arg_def_t *global_args[] = {
+ &use_yv12, &use_i420, &usage, &threads, &profile,
+ &width, &height, &stereo_mode, &timebase, &framerate, &error_resilient,
+ &lag_in_frames, NULL
};
static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1,
- "Temporal resampling threshold (buf %)");
+ "Temporal resampling threshold (buf %)");
static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1,
- "Spatial resampling enabled (bool)");
+ "Spatial resampling enabled (bool)");
static const arg_def_t resize_up_thresh = ARG_DEF(NULL, "resize-up", 1,
- "Upscale threshold (buf %)");
+ "Upscale threshold (buf %)");
static const arg_def_t resize_down_thresh = ARG_DEF(NULL, "resize-down", 1,
- "Downscale threshold (buf %)");
+ "Downscale threshold (buf %)");
static const struct arg_enum_list end_usage_enum[] = {
- {"vbr", VPX_VBR},
- {"cbr", VPX_CBR},
- {"cq", VPX_CQ},
- {NULL, 0}
+ {"vbr", VPX_VBR},
+ {"cbr", VPX_CBR},
+ {"cq", VPX_CQ},
+ {NULL, 0}
};
static const arg_def_t end_usage = ARG_DEF_ENUM(NULL, "end-usage", 1,
- "Rate control mode", end_usage_enum);
+ "Rate control mode", end_usage_enum);
static const arg_def_t target_bitrate = ARG_DEF(NULL, "target-bitrate", 1,
- "Bitrate (kbps)");
+ "Bitrate (kbps)");
static const arg_def_t min_quantizer = ARG_DEF(NULL, "min-q", 1,
- "Minimum (best) quantizer");
+ "Minimum (best) quantizer");
static const arg_def_t max_quantizer = ARG_DEF(NULL, "max-q", 1,
- "Maximum (worst) quantizer");
+ "Maximum (worst) quantizer");
static const arg_def_t undershoot_pct = ARG_DEF(NULL, "undershoot-pct", 1,
- "Datarate undershoot (min) target (%)");
+ "Datarate undershoot (min) target (%)");
static const arg_def_t overshoot_pct = ARG_DEF(NULL, "overshoot-pct", 1,
- "Datarate overshoot (max) target (%)");
+ "Datarate overshoot (max) target (%)");
static const arg_def_t buf_sz = ARG_DEF(NULL, "buf-sz", 1,
- "Client buffer size (ms)");
+ "Client buffer size (ms)");
static const arg_def_t buf_initial_sz = ARG_DEF(NULL, "buf-initial-sz", 1,
- "Client initial buffer size (ms)");
+ "Client initial buffer size (ms)");
static const arg_def_t buf_optimal_sz = ARG_DEF(NULL, "buf-optimal-sz", 1,
- "Client optimal buffer size (ms)");
-static const arg_def_t *rc_args[] =
-{
- &dropframe_thresh, &resize_allowed, &resize_up_thresh, &resize_down_thresh,
- &end_usage, &target_bitrate, &min_quantizer, &max_quantizer,
- &undershoot_pct, &overshoot_pct, &buf_sz, &buf_initial_sz, &buf_optimal_sz,
- NULL
+ "Client optimal buffer size (ms)");
+static const arg_def_t *rc_args[] = {
+ &dropframe_thresh, &resize_allowed, &resize_up_thresh, &resize_down_thresh,
+ &end_usage, &target_bitrate, &min_quantizer, &max_quantizer,
+ &undershoot_pct, &overshoot_pct, &buf_sz, &buf_initial_sz, &buf_optimal_sz,
+ NULL
};
static const arg_def_t bias_pct = ARG_DEF(NULL, "bias-pct", 1,
- "CBR/VBR bias (0=CBR, 100=VBR)");
+ "CBR/VBR bias (0=CBR, 100=VBR)");
static const arg_def_t minsection_pct = ARG_DEF(NULL, "minsection-pct", 1,
- "GOP min bitrate (% of target)");
+ "GOP min bitrate (% of target)");
static const arg_def_t maxsection_pct = ARG_DEF(NULL, "maxsection-pct", 1,
- "GOP max bitrate (% of target)");
-static const arg_def_t *rc_twopass_args[] =
-{
- &bias_pct, &minsection_pct, &maxsection_pct, NULL
+ "GOP max bitrate (% of target)");
+static const arg_def_t *rc_twopass_args[] = {
+ &bias_pct, &minsection_pct, &maxsection_pct, NULL
};
static const arg_def_t kf_min_dist = ARG_DEF(NULL, "kf-min-dist", 1,
- "Minimum keyframe interval (frames)");
+ "Minimum keyframe interval (frames)");
static const arg_def_t kf_max_dist = ARG_DEF(NULL, "kf-max-dist", 1,
- "Maximum keyframe interval (frames)");
+ "Maximum keyframe interval (frames)");
static const arg_def_t kf_disabled = ARG_DEF(NULL, "disable-kf", 0,
- "Disable keyframe placement");
-static const arg_def_t *kf_args[] =
-{
- &kf_min_dist, &kf_max_dist, &kf_disabled, NULL
+ "Disable keyframe placement");
+static const arg_def_t *kf_args[] = {
+ &kf_min_dist, &kf_max_dist, &kf_disabled, NULL
};
#if CONFIG_VP8_ENCODER
static const arg_def_t noise_sens = ARG_DEF(NULL, "noise-sensitivity", 1,
- "Noise sensitivity (frames to blur)");
+ "Noise sensitivity (frames to blur)");
static const arg_def_t sharpness = ARG_DEF(NULL, "sharpness", 1,
- "Filter sharpness (0-7)");
+ "Filter sharpness (0-7)");
static const arg_def_t static_thresh = ARG_DEF(NULL, "static-thresh", 1,
- "Motion detection threshold");
+ "Motion detection threshold");
#endif
#if CONFIG_VP8_ENCODER
static const arg_def_t cpu_used = ARG_DEF(NULL, "cpu-used", 1,
- "CPU Used (-16..16)");
+ "CPU Used (-16..16)");
#endif
#if CONFIG_VP8_ENCODER
static const arg_def_t token_parts = ARG_DEF(NULL, "token-parts", 1,
- "Number of token partitions to use, log2");
+ "Number of token partitions to use, log2");
static const arg_def_t auto_altref = ARG_DEF(NULL, "auto-alt-ref", 1,
- "Enable automatic alt reference frames");
+ "Enable automatic alt reference frames");
static const arg_def_t arnr_maxframes = ARG_DEF(NULL, "arnr-maxframes", 1,
- "AltRef Max Frames");
+ "AltRef Max Frames");
static const arg_def_t arnr_strength = ARG_DEF(NULL, "arnr-strength", 1,
- "AltRef Strength");
+ "AltRef Strength");
static const arg_def_t arnr_type = ARG_DEF(NULL, "arnr-type", 1,
- "AltRef Type");
+ "AltRef Type");
static const struct arg_enum_list tuning_enum[] = {
- {"psnr", VP8_TUNE_PSNR},
- {"ssim", VP8_TUNE_SSIM},
- {NULL, 0}
+ {"psnr", VP8_TUNE_PSNR},
+ {"ssim", VP8_TUNE_SSIM},
+ {NULL, 0}
};
static const arg_def_t tune_ssim = ARG_DEF_ENUM(NULL, "tune", 1,
- "Material to favor", tuning_enum);
+ "Material to favor", tuning_enum);
static const arg_def_t cq_level = ARG_DEF(NULL, "cq-level", 1,
- "Constrained Quality Level");
+ "Constrained Quality Level");
static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1,
- "Max I-frame bitrate (pct)");
+ "Max I-frame bitrate (pct)");
-static const arg_def_t *vp8_args[] =
-{
- &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh,
- &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type,
- &tune_ssim, &cq_level, &max_intra_rate_pct, NULL
+static const arg_def_t *vp8_args[] = {
+ &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh,
+ &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type,
+ &tune_ssim, &cq_level, &max_intra_rate_pct, NULL
};
-static const int vp8_arg_ctrl_map[] =
-{
- VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF,
- VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD,
- VP8E_SET_TOKEN_PARTITIONS,
- VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH , VP8E_SET_ARNR_TYPE,
- VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, 0
+static const int vp8_arg_ctrl_map[] = {
+ VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF,
+ VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD,
+ VP8E_SET_TOKEN_PARTITIONS,
+ VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE,
+ VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, 0
};
#endif
static const arg_def_t *no_args[] = { NULL };
-static void usage_exit()
-{
- int i;
-
- fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n",
- exec_name);
-
- fprintf(stderr, "\nOptions:\n");
- arg_show_usage(stdout, main_args);
- fprintf(stderr, "\nEncoder Global Options:\n");
- arg_show_usage(stdout, global_args);
- fprintf(stderr, "\nRate Control Options:\n");
- arg_show_usage(stdout, rc_args);
- fprintf(stderr, "\nTwopass Rate Control Options:\n");
- arg_show_usage(stdout, rc_twopass_args);
- fprintf(stderr, "\nKeyframe Placement Options:\n");
- arg_show_usage(stdout, kf_args);
+static void usage_exit() {
+ int i;
+
+ fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n",
+ exec_name);
+
+ fprintf(stderr, "\nOptions:\n");
+ arg_show_usage(stdout, main_args);
+ fprintf(stderr, "\nEncoder Global Options:\n");
+ arg_show_usage(stdout, global_args);
+ fprintf(stderr, "\nRate Control Options:\n");
+ arg_show_usage(stdout, rc_args);
+ fprintf(stderr, "\nTwopass Rate Control Options:\n");
+ arg_show_usage(stdout, rc_twopass_args);
+ fprintf(stderr, "\nKeyframe Placement Options:\n");
+ arg_show_usage(stdout, kf_args);
#if CONFIG_VP8_ENCODER
- fprintf(stderr, "\nVP8 Specific Options:\n");
- arg_show_usage(stdout, vp8_args);
+ fprintf(stderr, "\nVP8 Specific Options:\n");
+ arg_show_usage(stdout, vp8_args);
#endif
- fprintf(stderr, "\nStream timebase (--timebase):\n"
- " The desired precision of timestamps in the output, expressed\n"
- " in fractional seconds. Default is 1/1000.\n");
- fprintf(stderr, "\n"
- "Included encoders:\n"
- "\n");
-
- for (i = 0; i < sizeof(codecs) / sizeof(codecs[0]); i++)
- fprintf(stderr, " %-6s - %s\n",
- codecs[i].name,
- vpx_codec_iface_name(codecs[i].iface));
-
- exit(EXIT_FAILURE);
+ fprintf(stderr, "\nStream timebase (--timebase):\n"
+ " The desired precision of timestamps in the output, expressed\n"
+ " in fractional seconds. Default is 1/1000.\n");
+ fprintf(stderr, "\n"
+ "Included encoders:\n"
+ "\n");
+
+ for (i = 0; i < sizeof(codecs) / sizeof(codecs[0]); i++)
+ fprintf(stderr, " %-6s - %s\n",
+ codecs[i].name,
+ vpx_codec_iface_name(codecs[i].iface));
+
+ exit(EXIT_FAILURE);
}
#define HIST_BAR_MAX 40
-struct hist_bucket
-{
- int low, high, count;
+struct hist_bucket {
+ int low, high, count;
};
static int merge_hist_buckets(struct hist_bucket *bucket,
int *buckets_,
- int max_buckets)
-{
- int small_bucket = 0, merge_bucket = INT_MAX, big_bucket=0;
- int buckets = *buckets_;
- int i;
-
- /* Find the extrema for this list of buckets */
- big_bucket = small_bucket = 0;
- for(i=0; i < buckets; i++)
- {
- if(bucket[i].count < bucket[small_bucket].count)
- small_bucket = i;
- if(bucket[i].count > bucket[big_bucket].count)
- big_bucket = i;
+ int max_buckets) {
+ int small_bucket = 0, merge_bucket = INT_MAX, big_bucket = 0;
+ int buckets = *buckets_;
+ int i;
+
+ /* Find the extrema for this list of buckets */
+ big_bucket = small_bucket = 0;
+ for (i = 0; i < buckets; i++) {
+ if (bucket[i].count < bucket[small_bucket].count)
+ small_bucket = i;
+ if (bucket[i].count > bucket[big_bucket].count)
+ big_bucket = i;
+ }
+
+ /* If we have too many buckets, merge the smallest with an adjacent
+ * bucket.
+ */
+ while (buckets > max_buckets) {
+ int last_bucket = buckets - 1;
+
+ // merge the small bucket with an adjacent one.
+ if (small_bucket == 0)
+ merge_bucket = 1;
+ else if (small_bucket == last_bucket)
+ merge_bucket = last_bucket - 1;
+ else if (bucket[small_bucket - 1].count < bucket[small_bucket + 1].count)
+ merge_bucket = small_bucket - 1;
+ else
+ merge_bucket = small_bucket + 1;
+
+ assert(abs(merge_bucket - small_bucket) <= 1);
+ assert(small_bucket < buckets);
+ assert(big_bucket < buckets);
+ assert(merge_bucket < buckets);
+
+ if (merge_bucket < small_bucket) {
+ bucket[merge_bucket].high = bucket[small_bucket].high;
+ bucket[merge_bucket].count += bucket[small_bucket].count;
+ } else {
+ bucket[small_bucket].high = bucket[merge_bucket].high;
+ bucket[small_bucket].count += bucket[merge_bucket].count;
+ merge_bucket = small_bucket;
}
- /* If we have too many buckets, merge the smallest with an adjacent
- * bucket.
- */
- while(buckets > max_buckets)
- {
- int last_bucket = buckets - 1;
-
- // merge the small bucket with an adjacent one.
- if(small_bucket == 0)
- merge_bucket = 1;
- else if(small_bucket == last_bucket)
- merge_bucket = last_bucket - 1;
- else if(bucket[small_bucket - 1].count < bucket[small_bucket + 1].count)
- merge_bucket = small_bucket - 1;
- else
- merge_bucket = small_bucket + 1;
-
- assert(abs(merge_bucket - small_bucket) <= 1);
- assert(small_bucket < buckets);
- assert(big_bucket < buckets);
- assert(merge_bucket < buckets);
-
- if(merge_bucket < small_bucket)
- {
- bucket[merge_bucket].high = bucket[small_bucket].high;
- bucket[merge_bucket].count += bucket[small_bucket].count;
- }
- else
- {
- bucket[small_bucket].high = bucket[merge_bucket].high;
- bucket[small_bucket].count += bucket[merge_bucket].count;
- merge_bucket = small_bucket;
- }
-
- assert(bucket[merge_bucket].low != bucket[merge_bucket].high);
-
- buckets--;
+ assert(bucket[merge_bucket].low != bucket[merge_bucket].high);
- /* Remove the merge_bucket from the list, and find the new small
- * and big buckets while we're at it
- */
- big_bucket = small_bucket = 0;
- for(i=0; i < buckets; i++)
- {
- if(i > merge_bucket)
- bucket[i] = bucket[i+1];
-
- if(bucket[i].count < bucket[small_bucket].count)
- small_bucket = i;
- if(bucket[i].count > bucket[big_bucket].count)
- big_bucket = i;
- }
+ buckets--;
+ /* Remove the merge_bucket from the list, and find the new small
+ * and big buckets while we're at it
+ */
+ big_bucket = small_bucket = 0;
+ for (i = 0; i < buckets; i++) {
+ if (i > merge_bucket)
+ bucket[i] = bucket[i + 1];
+
+ if (bucket[i].count < bucket[small_bucket].count)
+ small_bucket = i;
+ if (bucket[i].count > bucket[big_bucket].count)
+ big_bucket = i;
}
- *buckets_ = buckets;
- return bucket[big_bucket].count;
+ }
+
+ *buckets_ = buckets;
+ return bucket[big_bucket].count;
}
static void show_histogram(const struct hist_bucket *bucket,
int buckets,
int total,
- int scale)
-{
- const char *pat1, *pat2;
- int i;
-
- switch((int)(log(bucket[buckets-1].high)/log(10))+1)
- {
- case 1:
- case 2:
- pat1 = "%4d %2s: ";
- pat2 = "%4d-%2d: ";
- break;
- case 3:
- pat1 = "%5d %3s: ";
- pat2 = "%5d-%3d: ";
- break;
- case 4:
- pat1 = "%6d %4s: ";
- pat2 = "%6d-%4d: ";
- break;
- case 5:
- pat1 = "%7d %5s: ";
- pat2 = "%7d-%5d: ";
- break;
- case 6:
- pat1 = "%8d %6s: ";
- pat2 = "%8d-%6d: ";
- break;
- case 7:
- pat1 = "%9d %7s: ";
- pat2 = "%9d-%7d: ";
- break;
- default:
- pat1 = "%12d %10s: ";
- pat2 = "%12d-%10d: ";
- break;
- }
+ int scale) {
+ const char *pat1, *pat2;
+ int i;
+
+ switch ((int)(log(bucket[buckets - 1].high) / log(10)) + 1) {
+ case 1:
+ case 2:
+ pat1 = "%4d %2s: ";
+ pat2 = "%4d-%2d: ";
+ break;
+ case 3:
+ pat1 = "%5d %3s: ";
+ pat2 = "%5d-%3d: ";
+ break;
+ case 4:
+ pat1 = "%6d %4s: ";
+ pat2 = "%6d-%4d: ";
+ break;
+ case 5:
+ pat1 = "%7d %5s: ";
+ pat2 = "%7d-%5d: ";
+ break;
+ case 6:
+ pat1 = "%8d %6s: ";
+ pat2 = "%8d-%6d: ";
+ break;
+ case 7:
+ pat1 = "%9d %7s: ";
+ pat2 = "%9d-%7d: ";
+ break;
+ default:
+ pat1 = "%12d %10s: ";
+ pat2 = "%12d-%10d: ";
+ break;
+ }
+
+ for (i = 0; i < buckets; i++) {
+ int len;
+ int j;
+ float pct;
+
+ pct = 100.0 * (float)bucket[i].count / (float)total;
+ len = HIST_BAR_MAX * bucket[i].count / scale;
+ if (len < 1)
+ len = 1;
+ assert(len <= HIST_BAR_MAX);
+
+ if (bucket[i].low == bucket[i].high)
+ fprintf(stderr, pat1, bucket[i].low, "");
+ else
+ fprintf(stderr, pat2, bucket[i].low, bucket[i].high);
- for(i=0; i<buckets; i++)
- {
- int len;
- int j;
- float pct;
-
- pct = 100.0 * (float)bucket[i].count / (float)total;
- len = HIST_BAR_MAX * bucket[i].count / scale;
- if(len < 1)
- len = 1;
- assert(len <= HIST_BAR_MAX);
-
- if(bucket[i].low == bucket[i].high)
- fprintf(stderr, pat1, bucket[i].low, "");
- else
- fprintf(stderr, pat2, bucket[i].low, bucket[i].high);
-
- for(j=0; j<HIST_BAR_MAX; j++)
- fprintf(stderr, j<len?"=":" ");
- fprintf(stderr, "\t%5d (%6.2f%%)\n",bucket[i].count,pct);
- }
+ for (j = 0; j < HIST_BAR_MAX; j++)
+ fprintf(stderr, j < len ? "=" : " ");
+ fprintf(stderr, "\t%5d (%6.2f%%)\n", bucket[i].count, pct);
+ }
}
-static void show_q_histogram(const int counts[64], int max_buckets)
-{
- struct hist_bucket bucket[64];
- int buckets = 0;
- int total = 0;
- int scale;
- int i;
+static void show_q_histogram(const int counts[64], int max_buckets) {
+ struct hist_bucket bucket[64];
+ int buckets = 0;
+ int total = 0;
+ int scale;
+ int i;
- for(i=0; i<64; i++)
- {
- if(counts[i])
- {
- bucket[buckets].low = bucket[buckets].high = i;
- bucket[buckets].count = counts[i];
- buckets++;
- total += counts[i];
- }
+ for (i = 0; i < 64; i++) {
+ if (counts[i]) {
+ bucket[buckets].low = bucket[buckets].high = i;
+ bucket[buckets].count = counts[i];
+ buckets++;
+ total += counts[i];
}
+ }
- fprintf(stderr, "\nQuantizer Selection:\n");
- scale = merge_hist_buckets(bucket, &buckets, max_buckets);
- show_histogram(bucket, buckets, total, scale);
+ fprintf(stderr, "\nQuantizer Selection:\n");
+ scale = merge_hist_buckets(bucket, &buckets, max_buckets);
+ show_histogram(bucket, buckets, total, scale);
}
#define RATE_BINS (100)
-struct rate_hist
-{
- int64_t *pts;
- int *sz;
- int samples;
- int frames;
- struct hist_bucket bucket[RATE_BINS];
- int total;
+struct rate_hist {
+ int64_t *pts;
+ int *sz;
+ int samples;
+ int frames;
+ struct hist_bucket bucket[RATE_BINS];
+ int total;
};
static void init_rate_histogram(struct rate_hist *hist,
const vpx_codec_enc_cfg_t *cfg,
- const vpx_rational_t *fps)
-{
- int i;
-
- /* Determine the number of samples in the buffer. Use the file's framerate
- * to determine the number of frames in rc_buf_sz milliseconds, with an
- * adjustment (5/4) to account for alt-refs
- */
- hist->samples = cfg->rc_buf_sz * 5 / 4 * fps->num / fps->den / 1000;
-
- // prevent division by zero
- if (hist->samples == 0)
- hist->samples=1;
-
- hist->pts = calloc(hist->samples, sizeof(*hist->pts));
- hist->sz = calloc(hist->samples, sizeof(*hist->sz));
- for(i=0; i<RATE_BINS; i++)
- {
- hist->bucket[i].low = INT_MAX;
- hist->bucket[i].high = 0;
- hist->bucket[i].count = 0;
- }
+ const vpx_rational_t *fps) {
+ int i;
+
+ /* Determine the number of samples in the buffer. Use the file's framerate
+ * to determine the number of frames in rc_buf_sz milliseconds, with an
+ * adjustment (5/4) to account for alt-refs
+ */
+ hist->samples = cfg->rc_buf_sz * 5 / 4 * fps->num / fps->den / 1000;
+
+ // prevent division by zero
+ if (hist->samples == 0)
+ hist->samples = 1;
+
+ hist->pts = calloc(hist->samples, sizeof(*hist->pts));
+ hist->sz = calloc(hist->samples, sizeof(*hist->sz));
+ for (i = 0; i < RATE_BINS; i++) {
+ hist->bucket[i].low = INT_MAX;
+ hist->bucket[i].high = 0;
+ hist->bucket[i].count = 0;
+ }
}
-static void destroy_rate_histogram(struct rate_hist *hist)
-{
- free(hist->pts);
- free(hist->sz);
+static void destroy_rate_histogram(struct rate_hist *hist) {
+ free(hist->pts);
+ free(hist->sz);
}
static void update_rate_histogram(struct rate_hist *hist,
const vpx_codec_enc_cfg_t *cfg,
- const vpx_codec_cx_pkt_t *pkt)
-{
- int i, idx;
- int64_t now, then, sum_sz = 0, avg_bitrate;
-
- now = pkt->data.frame.pts * 1000
- * (uint64_t)cfg->g_timebase.num / (uint64_t)cfg->g_timebase.den;
-
- idx = hist->frames++ % hist->samples;
- hist->pts[idx] = now;
- hist->sz[idx] = pkt->data.frame.sz;
-
- if(now < cfg->rc_buf_initial_sz)
- return;
-
- then = now;
-
- /* Sum the size over the past rc_buf_sz ms */
- for(i = hist->frames; i > 0 && hist->frames - i < hist->samples; i--)
- {
- int i_idx = (i-1) % hist->samples;
-
- then = hist->pts[i_idx];
- if(now - then > cfg->rc_buf_sz)
- break;
- sum_sz += hist->sz[i_idx];
- }
-
- if (now == then)
- return;
-
- avg_bitrate = sum_sz * 8 * 1000 / (now - then);
- idx = avg_bitrate * (RATE_BINS/2) / (cfg->rc_target_bitrate * 1000);
- if(idx < 0)
- idx = 0;
- if(idx > RATE_BINS-1)
- idx = RATE_BINS-1;
- if(hist->bucket[idx].low > avg_bitrate)
- hist->bucket[idx].low = avg_bitrate;
- if(hist->bucket[idx].high < avg_bitrate)
- hist->bucket[idx].high = avg_bitrate;
- hist->bucket[idx].count++;
- hist->total++;
+ const vpx_codec_cx_pkt_t *pkt) {
+ int i, idx;
+ int64_t now, then, sum_sz = 0, avg_bitrate;
+
+ now = pkt->data.frame.pts * 1000
+ * (uint64_t)cfg->g_timebase.num / (uint64_t)cfg->g_timebase.den;
+
+ idx = hist->frames++ % hist->samples;
+ hist->pts[idx] = now;
+ hist->sz[idx] = pkt->data.frame.sz;
+
+ if (now < cfg->rc_buf_initial_sz)
+ return;
+
+ then = now;
+
+ /* Sum the size over the past rc_buf_sz ms */
+ for (i = hist->frames; i > 0 && hist->frames - i < hist->samples; i--) {
+ int i_idx = (i - 1) % hist->samples;
+
+ then = hist->pts[i_idx];
+ if (now - then > cfg->rc_buf_sz)
+ break;
+ sum_sz += hist->sz[i_idx];
+ }
+
+ if (now == then)
+ return;
+
+ avg_bitrate = sum_sz * 8 * 1000 / (now - then);
+ idx = avg_bitrate * (RATE_BINS / 2) / (cfg->rc_target_bitrate * 1000);
+ if (idx < 0)
+ idx = 0;
+ if (idx > RATE_BINS - 1)
+ idx = RATE_BINS - 1;
+ if (hist->bucket[idx].low > avg_bitrate)
+ hist->bucket[idx].low = avg_bitrate;
+ if (hist->bucket[idx].high < avg_bitrate)
+ hist->bucket[idx].high = avg_bitrate;
+ hist->bucket[idx].count++;
+ hist->total++;
}
static void show_rate_histogram(struct rate_hist *hist,
const vpx_codec_enc_cfg_t *cfg,
- int max_buckets)
-{
- int i, scale;
- int buckets = 0;
-
- for(i = 0; i < RATE_BINS; i++)
- {
- if(hist->bucket[i].low == INT_MAX)
- continue;
- hist->bucket[buckets++] = hist->bucket[i];
- }
-
- fprintf(stderr, "\nRate (over %dms window):\n", cfg->rc_buf_sz);
- scale = merge_hist_buckets(hist->bucket, &buckets, max_buckets);
- show_histogram(hist->bucket, buckets, hist->total, scale);
+ int max_buckets) {
+ int i, scale;
+ int buckets = 0;
+
+ for (i = 0; i < RATE_BINS; i++) {
+ if (hist->bucket[i].low == INT_MAX)
+ continue;
+ hist->bucket[buckets++] = hist->bucket[i];
+ }
+
+ fprintf(stderr, "\nRate (over %dms window):\n", cfg->rc_buf_sz);
+ scale = merge_hist_buckets(hist->bucket, &buckets, max_buckets);
+ show_histogram(hist->bucket, buckets, hist->total, scale);
}
-static int compare_img(vpx_image_t *img1, vpx_image_t *img2)
-{
- int match = 1;
- int i;
+static int compare_img(vpx_image_t *img1, vpx_image_t *img2) {
+ int match = 1;
+ int i;
- match &= (img1->fmt == img2->fmt);
- match &= (img1->w == img2->w);
- match &= (img1->h == img2->h);
+ match &= (img1->fmt == img2->fmt);
+ match &= (img1->w == img2->w);
+ match &= (img1->h == img2->h);
- for (i = 0; i < img1->d_h; i++)
- match &= ( memcmp(img1->planes[VPX_PLANE_Y]+i*img1->stride[VPX_PLANE_Y],
- img2->planes[VPX_PLANE_Y]+i*img2->stride[VPX_PLANE_Y],
- img1->d_w)==0);
+ for (i = 0; i < img1->d_h; i++)
+ match &= (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y],
+ img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y],
+ img1->d_w) == 0);
- for (i = 0; i < img1->d_h/2; i++)
- match &= ( memcmp(img1->planes[VPX_PLANE_U]+i*img1->stride[VPX_PLANE_U],
- img2->planes[VPX_PLANE_U]+i*img2->stride[VPX_PLANE_U],
- img1->d_w/2)==0);
+ for (i = 0; i < img1->d_h / 2; i++)
+ match &= (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U],
+ img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U],
+ img1->d_w / 2) == 0);
- for (i = 0; i < img1->d_h/2; i++)
- match &= ( memcmp(img1->planes[VPX_PLANE_V]+i*img1->stride[VPX_PLANE_U],
- img2->planes[VPX_PLANE_V]+i*img2->stride[VPX_PLANE_U],
- img1->d_w/2)==0);
+ for (i = 0; i < img1->d_h / 2; i++)
+ match &= (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_U],
+ img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_U],
+ img1->d_w / 2) == 0);
- return match;
+ return match;
}
#define ARG_CTRL_CNT_MAX 10
-int main(int argc, const char **argv_)
-{
- vpx_codec_ctx_t encoder;
- const char *in_fn = NULL, *out_fn = NULL, *stats_fn = NULL;
- int i;
- FILE *infile, *outfile;
- vpx_codec_enc_cfg_t cfg;
- vpx_codec_err_t res;
- int pass, one_pass_only = 0;
- stats_io_t stats;
- vpx_image_t raw;
- const struct codec_item *codec = codecs;
- int frame_avail, got_data;
-
- struct arg arg;
- char **argv, **argi, **argj;
- int arg_usage = 0, arg_passes = 1, arg_deadline = 0;
- int arg_ctrls[ARG_CTRL_CNT_MAX][2], arg_ctrl_cnt = 0;
- int arg_limit = 0;
- int arg_skip = 0;
- static const arg_def_t **ctrl_args = no_args;
- static const int *ctrl_args_map = NULL;
- int verbose = 0, show_psnr = 0, test_decode = 0;
- int arg_use_i420 = 1;
- unsigned long cx_time = 0;
- unsigned int file_type, fourcc;
- y4m_input y4m;
- struct vpx_rational arg_framerate = {30, 1};
- int arg_have_framerate = 0;
- int write_webm = 1;
- EbmlGlobal ebml = {0};
- uint32_t hash = 0;
- uint64_t psnr_sse_total = 0;
- uint64_t psnr_samples_total = 0;
- double psnr_totals[4] = {0, 0, 0, 0};
- int psnr_count = 0;
- stereo_format_t stereo_fmt = STEREO_FORMAT_MONO;
- int counts[64]={0};
- int show_q_hist_buckets=0;
- int show_rate_hist_buckets=0;
- struct rate_hist rate_hist={0};
-
- vpx_codec_ctx_t decoder;
- vpx_ref_frame_t ref_enc;
- vpx_ref_frame_t ref_dec;
- vpx_codec_dec_cfg_t dec_cfg = {0};
- int enc_dec_match = 1;
- int first_bad_frame = -1;
- int test_decode_frame = 0;
-
- exec_name = argv_[0];
- ebml.last_pts_ms = -1;
-
- if (argc < 3)
- usage_exit();
-
-
- /* First parse the codec and usage values, because we want to apply other
- * parameters on top of the default configuration provided by the codec.
- */
- argv = argv_dup(argc - 1, argv_ + 1);
-
- for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step)
- {
- arg.argv_step = 1;
-
- if (arg_match(&arg, &codecarg, argi))
- {
- int j, k = -1;
-
- for (j = 0; j < sizeof(codecs) / sizeof(codecs[0]); j++)
- if (!strcmp(codecs[j].name, arg.val))
- k = j;
-
- if (k >= 0)
- codec = codecs + k;
- else
- die("Error: Unrecognized argument (%s) to --codec\n",
- arg.val);
+int main(int argc, const char **argv_) {
+ vpx_codec_ctx_t encoder;
+ const char *in_fn = NULL, *out_fn = NULL, *stats_fn = NULL;
+ int i;
+ FILE *infile, *outfile;
+ vpx_codec_enc_cfg_t cfg;
+ vpx_codec_err_t res;
+ int pass, one_pass_only = 0;
+ stats_io_t stats;
+ vpx_image_t raw;
+ const struct codec_item *codec = codecs;
+ int frame_avail, got_data;
+
+ struct arg arg;
+ char **argv, **argi, **argj;
+ int arg_usage = 0, arg_passes = 1, arg_deadline = 0;
+ int arg_ctrls[ARG_CTRL_CNT_MAX][2], arg_ctrl_cnt = 0;
+ int arg_limit = 0;
+ int arg_skip = 0;
+ static const arg_def_t **ctrl_args = no_args;
+ static const int *ctrl_args_map = NULL;
+ int verbose = 0, show_psnr = 0, test_decode = 0;
+ int arg_use_i420 = 1;
+ unsigned long cx_time = 0;
+ unsigned int file_type, fourcc;
+ y4m_input y4m;
+ struct vpx_rational arg_framerate = {30, 1};
+ int arg_have_framerate = 0;
+ int write_webm = 1;
+ EbmlGlobal ebml = {0};
+ uint32_t hash = 0;
+ uint64_t psnr_sse_total = 0;
+ uint64_t psnr_samples_total = 0;
+ double psnr_totals[4] = {0, 0, 0, 0};
+ int psnr_count = 0;
+ stereo_format_t stereo_fmt = STEREO_FORMAT_MONO;
+ int counts[64] = {0};
+ int show_q_hist_buckets = 0;
+ int show_rate_hist_buckets = 0;
+ struct rate_hist rate_hist = {0};
+
+ vpx_codec_ctx_t decoder;
+ vpx_ref_frame_t ref_enc;
+ vpx_ref_frame_t ref_dec;
+ vpx_codec_dec_cfg_t dec_cfg = {0};
+ int enc_dec_match = 1;
+ int first_bad_frame = -1;
+ int test_decode_frame = 0;
+
+ exec_name = argv_[0];
+ ebml.last_pts_ms = -1;
+
+ if (argc < 3)
+ usage_exit();
- }
- else if (arg_match(&arg, &passes, argi))
- {
- arg_passes = arg_parse_uint(&arg);
- if (arg_passes < 1 || arg_passes > 2)
- die("Error: Invalid number of passes (%d)\n", arg_passes);
- }
- else if (arg_match(&arg, &pass_arg, argi))
- {
- one_pass_only = arg_parse_uint(&arg);
-
- if (one_pass_only < 1 || one_pass_only > 2)
- die("Error: Invalid pass selected (%d)\n", one_pass_only);
- }
- else if (arg_match(&arg, &fpf_name, argi))
- stats_fn = arg.val;
- else if (arg_match(&arg, &usage, argi))
- arg_usage = arg_parse_uint(&arg);
- else if (arg_match(&arg, &deadline, argi))
- arg_deadline = arg_parse_uint(&arg);
- else if (arg_match(&arg, &best_dl, argi))
- arg_deadline = VPX_DL_BEST_QUALITY;
- else if (arg_match(&arg, &good_dl, argi))
- arg_deadline = VPX_DL_GOOD_QUALITY;
- else if (arg_match(&arg, &rt_dl, argi))
- arg_deadline = VPX_DL_REALTIME;
- else if (arg_match(&arg, &use_yv12, argi))
- {
- arg_use_i420 = 0;
- }
- else if (arg_match(&arg, &use_i420, argi))
- {
- arg_use_i420 = 1;
- }
- else if (arg_match(&arg, &verbosearg, argi))
- verbose = 1;
- else if (arg_match(&arg, &limit, argi))
- arg_limit = arg_parse_uint(&arg);
- else if (arg_match(&arg, &skip, argi))
- arg_skip = arg_parse_uint(&arg);
- else if (arg_match(&arg, &psnrarg, argi))
- show_psnr = 1;
- else if (arg_match(&arg, &recontest, argi))
- test_decode = 1;
- else if (arg_match(&arg, &framerate, argi))
- {
- arg_framerate = arg_parse_rational(&arg);
- arg_have_framerate = 1;
- }
- else if (arg_match(&arg, &use_ivf, argi))
- write_webm = 0;
- else if (arg_match(&arg, &outputfile, argi))
- out_fn = arg.val;
- else if (arg_match(&arg, &debugmode, argi))
- ebml.debug = 1;
- else if (arg_match(&arg, &q_hist_n, argi))
- show_q_hist_buckets = arg_parse_uint(&arg);
- else if (arg_match(&arg, &rate_hist_n, argi))
- show_rate_hist_buckets = arg_parse_uint(&arg);
- else
- argj++;
+ /* First parse the codec and usage values, because we want to apply other
+ * parameters on top of the default configuration provided by the codec.
+ */
+ argv = argv_dup(argc - 1, argv_ + 1);
+
+ for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
+ arg.argv_step = 1;
+
+ if (arg_match(&arg, &codecarg, argi)) {
+ int j, k = -1;
+
+ for (j = 0; j < sizeof(codecs) / sizeof(codecs[0]); j++)
+ if (!strcmp(codecs[j].name, arg.val))
+ k = j;
+
+ if (k >= 0)
+ codec = codecs + k;
+ else
+ die("Error: Unrecognized argument (%s) to --codec\n",
+ arg.val);
+
+ } else if (arg_match(&arg, &passes, argi)) {
+ arg_passes = arg_parse_uint(&arg);
+
+ if (arg_passes < 1 || arg_passes > 2)
+ die("Error: Invalid number of passes (%d)\n", arg_passes);
+ } else if (arg_match(&arg, &pass_arg, argi)) {
+ one_pass_only = arg_parse_uint(&arg);
+
+ if (one_pass_only < 1 || one_pass_only > 2)
+ die("Error: Invalid pass selected (%d)\n", one_pass_only);
+ } else if (arg_match(&arg, &fpf_name, argi))
+ stats_fn = arg.val;
+ else if (arg_match(&arg, &usage, argi))
+ arg_usage = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &deadline, argi))
+ arg_deadline = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &best_dl, argi))
+ arg_deadline = VPX_DL_BEST_QUALITY;
+ else if (arg_match(&arg, &good_dl, argi))
+ arg_deadline = VPX_DL_GOOD_QUALITY;
+ else if (arg_match(&arg, &rt_dl, argi))
+ arg_deadline = VPX_DL_REALTIME;
+ else if (arg_match(&arg, &use_yv12, argi)) {
+ arg_use_i420 = 0;
+ } else if (arg_match(&arg, &use_i420, argi)) {
+ arg_use_i420 = 1;
+ } else if (arg_match(&arg, &verbosearg, argi))
+ verbose = 1;
+ else if (arg_match(&arg, &limit, argi))
+ arg_limit = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &skip, argi))
+ arg_skip = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &psnrarg, argi))
+ show_psnr = 1;
+ else if (arg_match(&arg, &recontest, argi))
+ test_decode = 1;
+ else if (arg_match(&arg, &framerate, argi)) {
+ arg_framerate = arg_parse_rational(&arg);
+ arg_have_framerate = 1;
+ } else if (arg_match(&arg, &use_ivf, argi))
+ write_webm = 0;
+ else if (arg_match(&arg, &outputfile, argi))
+ out_fn = arg.val;
+ else if (arg_match(&arg, &debugmode, argi))
+ ebml.debug = 1;
+ else if (arg_match(&arg, &q_hist_n, argi))
+ show_q_hist_buckets = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &rate_hist_n, argi))
+ show_rate_hist_buckets = arg_parse_uint(&arg);
+ else
+ argj++;
+ }
+
+ /* Ensure that --passes and --pass are consistent. If --pass is set and --passes=2,
+ * ensure --fpf was set.
+ */
+ if (one_pass_only) {
+ /* DWIM: Assume the user meant passes=2 if pass=2 is specified */
+ if (one_pass_only > arg_passes) {
+ fprintf(stderr, "Warning: Assuming --pass=%d implies --passes=%d\n",
+ one_pass_only, one_pass_only);
+ arg_passes = one_pass_only;
}
- /* Ensure that --passes and --pass are consistent. If --pass is set and --passes=2,
- * ensure --fpf was set.
- */
- if (one_pass_only)
- {
- /* DWIM: Assume the user meant passes=2 if pass=2 is specified */
- if (one_pass_only > arg_passes)
- {
- fprintf(stderr, "Warning: Assuming --pass=%d implies --passes=%d\n",
- one_pass_only, one_pass_only);
- arg_passes = one_pass_only;
- }
+ if (arg_passes == 2 && !stats_fn)
+ die("Must specify --fpf when --pass=%d and --passes=2\n", one_pass_only);
+ }
- if (arg_passes == 2 && !stats_fn)
- die("Must specify --fpf when --pass=%d and --passes=2\n", one_pass_only);
- }
+ /* Populate encoder configuration */
+ res = vpx_codec_enc_config_default(codec->iface, &cfg, arg_usage);
- /* Populate encoder configuration */
- res = vpx_codec_enc_config_default(codec->iface, &cfg, arg_usage);
+ if (res) {
+ fprintf(stderr, "Failed to get config: %s\n",
+ vpx_codec_err_to_string(res));
+ return EXIT_FAILURE;
+ }
- if (res)
- {
- fprintf(stderr, "Failed to get config: %s\n",
- vpx_codec_err_to_string(res));
- return EXIT_FAILURE;
- }
+ /* Change the default timebase to a high enough value so that the encoder
+ * will always create strictly increasing timestamps.
+ */
+ cfg.g_timebase.den = 1000;
- /* Change the default timebase to a high enough value so that the encoder
- * will always create strictly increasing timestamps.
- */
- cfg.g_timebase.den = 1000;
-
- /* Never use the library's default resolution, require it be parsed
- * from the file or set on the command line.
- */
- cfg.g_w = 0;
- cfg.g_h = 0;
+ /* Never use the library's default resolution, require it be parsed
+ * from the file or set on the command line.
+ */
+ cfg.g_w = 0;
+ cfg.g_h = 0;
#if CONFIG_LOSSLESS
- cfg.lossless = 0;
+ cfg.lossless = 0;
#endif
- /* Now parse the remainder of the parameters. */
- for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step)
- {
- arg.argv_step = 1;
-
- if (0);
- else if (arg_match(&arg, &threads, argi))
- cfg.g_threads = arg_parse_uint(&arg);
- else if (arg_match(&arg, &profile, argi))
- cfg.g_profile = arg_parse_uint(&arg);
- else if (arg_match(&arg, &width, argi))
- cfg.g_w = arg_parse_uint(&arg);
- else if (arg_match(&arg, &height, argi))
- cfg.g_h = arg_parse_uint(&arg);
- else if (arg_match(&arg, &stereo_mode, argi))
- stereo_fmt = arg_parse_enum_or_int(&arg);
- else if (arg_match(&arg, &timebase, argi))
- cfg.g_timebase = arg_parse_rational(&arg);
- else if (arg_match(&arg, &error_resilient, argi))
- cfg.g_error_resilient = arg_parse_uint(&arg);
- else if (arg_match(&arg, &lag_in_frames, argi))
- cfg.g_lag_in_frames = arg_parse_uint(&arg);
- else if (arg_match(&arg, &dropframe_thresh, argi))
- cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
- else if (arg_match(&arg, &resize_allowed, argi))
- cfg.rc_resize_allowed = arg_parse_uint(&arg);
- else if (arg_match(&arg, &resize_up_thresh, argi))
- cfg.rc_resize_up_thresh = arg_parse_uint(&arg);
- else if (arg_match(&arg, &resize_down_thresh, argi))
- cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
- else if (arg_match(&arg, &resize_down_thresh, argi))
- cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
- else if (arg_match(&arg, &end_usage, argi))
- cfg.rc_end_usage = arg_parse_enum_or_int(&arg);
- else if (arg_match(&arg, &target_bitrate, argi))
- cfg.rc_target_bitrate = arg_parse_uint(&arg);
- else if (arg_match(&arg, &min_quantizer, argi))
- cfg.rc_min_quantizer = arg_parse_uint(&arg);
- else if (arg_match(&arg, &max_quantizer, argi))
- cfg.rc_max_quantizer = arg_parse_uint(&arg);
- else if (arg_match(&arg, &undershoot_pct, argi))
- cfg.rc_undershoot_pct = arg_parse_uint(&arg);
- else if (arg_match(&arg, &overshoot_pct, argi))
- cfg.rc_overshoot_pct = arg_parse_uint(&arg);
- else if (arg_match(&arg, &buf_sz, argi))
- cfg.rc_buf_sz = arg_parse_uint(&arg);
- else if (arg_match(&arg, &buf_initial_sz, argi))
- cfg.rc_buf_initial_sz = arg_parse_uint(&arg);
- else if (arg_match(&arg, &buf_optimal_sz, argi))
- cfg.rc_buf_optimal_sz = arg_parse_uint(&arg);
- else if (arg_match(&arg, &bias_pct, argi))
- {
- cfg.rc_2pass_vbr_bias_pct = arg_parse_uint(&arg);
-
- if (arg_passes < 2)
- fprintf(stderr,
- "Warning: option %s ignored in one-pass mode.\n",
- arg.name);
- }
- else if (arg_match(&arg, &minsection_pct, argi))
- {
- cfg.rc_2pass_vbr_minsection_pct = arg_parse_uint(&arg);
+ /* Now parse the remainder of the parameters. */
+ for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
+ arg.argv_step = 1;
+
+ if (0);
+ else if (arg_match(&arg, &threads, argi))
+ cfg.g_threads = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &profile, argi))
+ cfg.g_profile = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &width, argi))
+ cfg.g_w = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &height, argi))
+ cfg.g_h = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &stereo_mode, argi))
+ stereo_fmt = arg_parse_enum_or_int(&arg);
+ else if (arg_match(&arg, &timebase, argi))
+ cfg.g_timebase = arg_parse_rational(&arg);
+ else if (arg_match(&arg, &error_resilient, argi))
+ cfg.g_error_resilient = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &lag_in_frames, argi))
+ cfg.g_lag_in_frames = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &dropframe_thresh, argi))
+ cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &resize_allowed, argi))
+ cfg.rc_resize_allowed = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &resize_up_thresh, argi))
+ cfg.rc_resize_up_thresh = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &resize_down_thresh, argi))
+ cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &resize_down_thresh, argi))
+ cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &end_usage, argi))
+ cfg.rc_end_usage = arg_parse_enum_or_int(&arg);
+ else if (arg_match(&arg, &target_bitrate, argi))
+ cfg.rc_target_bitrate = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &min_quantizer, argi))
+ cfg.rc_min_quantizer = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &max_quantizer, argi))
+ cfg.rc_max_quantizer = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &undershoot_pct, argi))
+ cfg.rc_undershoot_pct = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &overshoot_pct, argi))
+ cfg.rc_overshoot_pct = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &buf_sz, argi))
+ cfg.rc_buf_sz = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &buf_initial_sz, argi))
+ cfg.rc_buf_initial_sz = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &buf_optimal_sz, argi))
+ cfg.rc_buf_optimal_sz = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &bias_pct, argi)) {
+ cfg.rc_2pass_vbr_bias_pct = arg_parse_uint(&arg);
+
+ if (arg_passes < 2)
+ fprintf(stderr,
+ "Warning: option %s ignored in one-pass mode.\n",
+ arg.name);
+ } else if (arg_match(&arg, &minsection_pct, argi)) {
+ cfg.rc_2pass_vbr_minsection_pct = arg_parse_uint(&arg);
- if (arg_passes < 2)
- fprintf(stderr,
- "Warning: option %s ignored in one-pass mode.\n",
- arg.name);
- }
- else if (arg_match(&arg, &maxsection_pct, argi))
- {
- cfg.rc_2pass_vbr_maxsection_pct = arg_parse_uint(&arg);
+ if (arg_passes < 2)
+ fprintf(stderr,
+ "Warning: option %s ignored in one-pass mode.\n",
+ arg.name);
+ } else if (arg_match(&arg, &maxsection_pct, argi)) {
+ cfg.rc_2pass_vbr_maxsection_pct = arg_parse_uint(&arg);
- if (arg_passes < 2)
- fprintf(stderr,
- "Warning: option %s ignored in one-pass mode.\n",
- arg.name);
- }
- else if (arg_match(&arg, &kf_min_dist, argi))
- cfg.kf_min_dist = arg_parse_uint(&arg);
- else if (arg_match(&arg, &kf_max_dist, argi))
- cfg.kf_max_dist = arg_parse_uint(&arg);
- else if (arg_match(&arg, &kf_disabled, argi))
- cfg.kf_mode = VPX_KF_DISABLED;
+ if (arg_passes < 2)
+ fprintf(stderr,
+ "Warning: option %s ignored in one-pass mode.\n",
+ arg.name);
+ } else if (arg_match(&arg, &kf_min_dist, argi))
+ cfg.kf_min_dist = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &kf_max_dist, argi))
+ cfg.kf_max_dist = arg_parse_uint(&arg);
+ else if (arg_match(&arg, &kf_disabled, argi))
+ cfg.kf_mode = VPX_KF_DISABLED;
#if CONFIG_LOSSLESS
- else if (arg_match(&arg, &lossless_enabled, argi))
- cfg.lossless = 1;
+ else if (arg_match(&arg, &lossless_enabled, argi))
+ cfg.lossless = 1;
#endif
- else
- argj++;
- }
+ else
+ argj++;
+ }
#if CONFIG_LOSSLESS
- if (cfg.lossless)
- {
- cfg.rc_min_quantizer = 0;
- cfg.rc_max_quantizer = 0;
- }
+ if (cfg.lossless) {
+ cfg.rc_min_quantizer = 0;
+ cfg.rc_max_quantizer = 0;
+ }
#endif
- /* Handle codec specific options */
+ /* Handle codec specific options */
#if CONFIG_VP8_ENCODER
- if (codec->iface == &vpx_codec_vp8_cx_algo
+ if (codec->iface == &vpx_codec_vp8_cx_algo
#if CONFIG_EXPERIMENTAL
- || codec->iface == &vpx_codec_vp8x_cx_algo
+ || codec->iface == &vpx_codec_vp8x_cx_algo
#endif
- )
- {
- ctrl_args = vp8_args;
- ctrl_args_map = vp8_arg_ctrl_map;
- }
+ ) {
+ ctrl_args = vp8_args;
+ ctrl_args_map = vp8_arg_ctrl_map;
+ }
#endif
- for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step)
- {
- int match = 0;
+ for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
+ int match = 0;
- arg.argv_step = 1;
+ arg.argv_step = 1;
- for (i = 0; ctrl_args[i]; i++)
- {
- if (arg_match(&arg, ctrl_args[i], argi))
- {
- match = 1;
-
- if (arg_ctrl_cnt < ARG_CTRL_CNT_MAX)
- {
- arg_ctrls[arg_ctrl_cnt][0] = ctrl_args_map[i];
- arg_ctrls[arg_ctrl_cnt][1] = arg_parse_enum_or_int(&arg);
- arg_ctrl_cnt++;
- }
- }
- }
+ for (i = 0; ctrl_args[i]; i++) {
+ if (arg_match(&arg, ctrl_args[i], argi)) {
+ match = 1;
- if (!match)
- argj++;
+ if (arg_ctrl_cnt < ARG_CTRL_CNT_MAX) {
+ arg_ctrls[arg_ctrl_cnt][0] = ctrl_args_map[i];
+ arg_ctrls[arg_ctrl_cnt][1] = arg_parse_enum_or_int(&arg);
+ arg_ctrl_cnt++;
+ }
+ }
}
- /* Check for unrecognized options */
- for (argi = argv; *argi; argi++)
- if (argi[0][0] == '-' && argi[0][1])
- die("Error: Unrecognized option %s\n", *argi);
+ if (!match)
+ argj++;
+ }
- /* Handle non-option arguments */
- in_fn = argv[0];
+ /* Check for unrecognized options */
+ for (argi = argv; *argi; argi++)
+ if (argi[0][0] == '-' && argi[0][1])
+ die("Error: Unrecognized option %s\n", *argi);
- if (!in_fn)
- usage_exit();
+ /* Handle non-option arguments */
+ in_fn = argv[0];
- if(!out_fn)
- die("Error: Output file is required (specify with -o)\n");
+ if (!in_fn)
+ usage_exit();
- memset(&stats, 0, sizeof(stats));
+ if (!out_fn)
+ die("Error: Output file is required (specify with -o)\n");
- for (pass = one_pass_only ? one_pass_only - 1 : 0; pass < arg_passes; pass++)
- {
- int frames_in = 0, frames_out = 0;
- unsigned long nbytes = 0;
- int skip_frames = 0;
- struct detect_buffer detect;
+ memset(&stats, 0, sizeof(stats));
- /* Parse certain options from the input file, if possible */
- infile = strcmp(in_fn, "-") ? fopen(in_fn, "rb")
- : set_binary_mode(stdin);
+ for (pass = one_pass_only ? one_pass_only - 1 : 0; pass < arg_passes; pass++) {
+ int frames_in = 0, frames_out = 0;
+ unsigned long nbytes = 0;
+ int skip_frames = 0;
+ struct detect_buffer detect;
- if (!infile)
- {
- fprintf(stderr, "Failed to open input file\n");
- return EXIT_FAILURE;
- }
+ /* Parse certain options from the input file, if possible */
+ infile = strcmp(in_fn, "-") ? fopen(in_fn, "rb")
+ : set_binary_mode(stdin);
- /* For RAW input sources, these bytes will applied on the first frame
- * in read_frame().
- */
- detect.buf_read = fread(detect.buf, 1, 4, infile);
- detect.position = 0;
+ if (!infile) {
+ fprintf(stderr, "Failed to open input file\n");
+ return EXIT_FAILURE;
+ }
- if (detect.buf_read == 4 && file_is_y4m(infile, &y4m, detect.buf))
- {
- if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0)
- {
- file_type = FILE_TYPE_Y4M;
- cfg.g_w = y4m.pic_w;
- cfg.g_h = y4m.pic_h;
-
- /* Use the frame rate from the file only if none was specified
- * on the command-line.
- */
- if (!arg_have_framerate)
- {
- arg_framerate.num = y4m.fps_n;
- arg_framerate.den = y4m.fps_d;
- }
-
- arg_use_i420 = 0;
- }
- else
- {
- fprintf(stderr, "Unsupported Y4M stream.\n");
- return EXIT_FAILURE;
- }
- }
- else if (detect.buf_read == 4 &&
- file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, &detect))
- {
- file_type = FILE_TYPE_IVF;
- switch (fourcc)
- {
- case 0x32315659:
- arg_use_i420 = 0;
- break;
- case 0x30323449:
- arg_use_i420 = 1;
- break;
- default:
- fprintf(stderr, "Unsupported fourcc (%08x) in IVF\n", fourcc);
- return EXIT_FAILURE;
- }
- }
- else
- {
- file_type = FILE_TYPE_RAW;
- }
+ /* For RAW input sources, these bytes will applied on the first frame
+ * in read_frame().
+ */
+ detect.buf_read = fread(detect.buf, 1, 4, infile);
+ detect.position = 0;
- if(!cfg.g_w || !cfg.g_h)
- {
- fprintf(stderr, "Specify stream dimensions with --width (-w) "
- " and --height (-h).\n");
- return EXIT_FAILURE;
+ if (detect.buf_read == 4 && file_is_y4m(infile, &y4m, detect.buf)) {
+ if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0) {
+ file_type = FILE_TYPE_Y4M;
+ cfg.g_w = y4m.pic_w;
+ cfg.g_h = y4m.pic_h;
+
+ /* Use the frame rate from the file only if none was specified
+ * on the command-line.
+ */
+ if (!arg_have_framerate) {
+ arg_framerate.num = y4m.fps_n;
+ arg_framerate.den = y4m.fps_d;
}
+ arg_use_i420 = 0;
+ } else {
+ fprintf(stderr, "Unsupported Y4M stream.\n");
+ return EXIT_FAILURE;
+ }
+ } else if (detect.buf_read == 4 &&
+ file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, &detect)) {
+ file_type = FILE_TYPE_IVF;
+ switch (fourcc) {
+ case 0x32315659:
+ arg_use_i420 = 0;
+ break;
+ case 0x30323449:
+ arg_use_i420 = 1;
+ break;
+ default:
+ fprintf(stderr, "Unsupported fourcc (%08x) in IVF\n", fourcc);
+ return EXIT_FAILURE;
+ }
+ } else {
+ file_type = FILE_TYPE_RAW;
+ }
+
+ if (!cfg.g_w || !cfg.g_h) {
+ fprintf(stderr, "Specify stream dimensions with --width (-w) "
+ " and --height (-h).\n");
+ return EXIT_FAILURE;
+ }
+
#define SHOW(field) fprintf(stderr, " %-28s = %d\n", #field, cfg.field)
- if (verbose && pass == 0)
- {
- fprintf(stderr, "Codec: %s\n", vpx_codec_iface_name(codec->iface));
- fprintf(stderr, "Source file: %s Format: %s\n", in_fn,
- arg_use_i420 ? "I420" : "YV12");
- fprintf(stderr, "Destination file: %s\n", out_fn);
- fprintf(stderr, "Encoder parameters:\n");
-
- SHOW(g_usage);
- SHOW(g_threads);
- SHOW(g_profile);
- SHOW(g_w);
- SHOW(g_h);
- SHOW(g_timebase.num);
- SHOW(g_timebase.den);
- SHOW(g_error_resilient);
- SHOW(g_pass);
- SHOW(g_lag_in_frames);
- SHOW(rc_dropframe_thresh);
- SHOW(rc_resize_allowed);
- SHOW(rc_resize_up_thresh);
- SHOW(rc_resize_down_thresh);
- SHOW(rc_end_usage);
- SHOW(rc_target_bitrate);
- SHOW(rc_min_quantizer);
- SHOW(rc_max_quantizer);
- SHOW(rc_undershoot_pct);
- SHOW(rc_overshoot_pct);
- SHOW(rc_buf_sz);
- SHOW(rc_buf_initial_sz);
- SHOW(rc_buf_optimal_sz);
- SHOW(rc_2pass_vbr_bias_pct);
- SHOW(rc_2pass_vbr_minsection_pct);
- SHOW(rc_2pass_vbr_maxsection_pct);
- SHOW(kf_mode);
- SHOW(kf_min_dist);
- SHOW(kf_max_dist);
+ if (verbose && pass == 0) {
+ fprintf(stderr, "Codec: %s\n", vpx_codec_iface_name(codec->iface));
+ fprintf(stderr, "Source file: %s Format: %s\n", in_fn,
+ arg_use_i420 ? "I420" : "YV12");
+ fprintf(stderr, "Destination file: %s\n", out_fn);
+ fprintf(stderr, "Encoder parameters:\n");
+
+ SHOW(g_usage);
+ SHOW(g_threads);
+ SHOW(g_profile);
+ SHOW(g_w);
+ SHOW(g_h);
+ SHOW(g_timebase.num);
+ SHOW(g_timebase.den);
+ SHOW(g_error_resilient);
+ SHOW(g_pass);
+ SHOW(g_lag_in_frames);
+ SHOW(rc_dropframe_thresh);
+ SHOW(rc_resize_allowed);
+ SHOW(rc_resize_up_thresh);
+ SHOW(rc_resize_down_thresh);
+ SHOW(rc_end_usage);
+ SHOW(rc_target_bitrate);
+ SHOW(rc_min_quantizer);
+ SHOW(rc_max_quantizer);
+ SHOW(rc_undershoot_pct);
+ SHOW(rc_overshoot_pct);
+ SHOW(rc_buf_sz);
+ SHOW(rc_buf_initial_sz);
+ SHOW(rc_buf_optimal_sz);
+ SHOW(rc_2pass_vbr_bias_pct);
+ SHOW(rc_2pass_vbr_minsection_pct);
+ SHOW(rc_2pass_vbr_maxsection_pct);
+ SHOW(kf_mode);
+ SHOW(kf_min_dist);
+ SHOW(kf_max_dist);
#if CONFIG_LOSSLESS
- SHOW(lossless);
+ SHOW(lossless);
#endif
- }
+ }
- if(pass == (one_pass_only ? one_pass_only - 1 : 0)) {
- if (file_type == FILE_TYPE_Y4M)
- /*The Y4M reader does its own allocation.
- Just initialize this here to avoid problems if we never read any
- frames.*/
- memset(&raw, 0, sizeof(raw));
- else
- vpx_img_alloc(&raw, arg_use_i420 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_YV12,
- cfg.g_w, cfg.g_h, 1);
+ if (pass == (one_pass_only ? one_pass_only - 1 : 0)) {
+ if (file_type == FILE_TYPE_Y4M)
+ /*The Y4M reader does its own allocation.
+ Just initialize this here to avoid problems if we never read any
+ frames.*/
+ memset(&raw, 0, sizeof(raw));
+ else
+ vpx_img_alloc(&raw, arg_use_i420 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_YV12,
+ cfg.g_w, cfg.g_h, 1);
- init_rate_histogram(&rate_hist, &cfg, &arg_framerate);
- }
+ init_rate_histogram(&rate_hist, &cfg, &arg_framerate);
+ }
- if(test_decode)
- {
- int width = cfg.g_w;
- int height = cfg.g_h;
- width = (width + 15)& ~15;
- height = (height + 15) & ~15;
-
- vpx_img_alloc(&ref_enc.img, VPX_IMG_FMT_I420,
- width, height, 1);
- vpx_img_alloc(&ref_dec.img, VPX_IMG_FMT_I420,
- width, height, 1);
- }
+ if (test_decode) {
+ int width = cfg.g_w;
+ int height = cfg.g_h;
+ width = (width + 15)& ~15;
+ height = (height + 15) & ~15;
- outfile = strcmp(out_fn, "-") ? fopen(out_fn, "wb")
- : set_binary_mode(stdout);
+ vpx_img_alloc(&ref_enc.img, VPX_IMG_FMT_I420,
+ width, height, 1);
+ vpx_img_alloc(&ref_dec.img, VPX_IMG_FMT_I420,
+ width, height, 1);
+ }
- if (!outfile)
- {
- fprintf(stderr, "Failed to open output file\n");
- return EXIT_FAILURE;
- }
+ outfile = strcmp(out_fn, "-") ? fopen(out_fn, "wb")
+ : set_binary_mode(stdout);
- if(write_webm && fseek(outfile, 0, SEEK_CUR))
- {
- fprintf(stderr, "WebM output to pipes not supported.\n");
- return EXIT_FAILURE;
- }
+ if (!outfile) {
+ fprintf(stderr, "Failed to open output file\n");
+ return EXIT_FAILURE;
+ }
- if (stats_fn)
- {
- if (!stats_open_file(&stats, stats_fn, pass))
- {
- fprintf(stderr, "Failed to open statistics store\n");
- return EXIT_FAILURE;
- }
- }
- else
- {
- if (!stats_open_mem(&stats, pass))
- {
- fprintf(stderr, "Failed to open statistics store\n");
- return EXIT_FAILURE;
- }
- }
+ if (write_webm && fseek(outfile, 0, SEEK_CUR)) {
+ fprintf(stderr, "WebM output to pipes not supported.\n");
+ return EXIT_FAILURE;
+ }
- cfg.g_pass = arg_passes == 2
- ? pass ? VPX_RC_LAST_PASS : VPX_RC_FIRST_PASS
- : VPX_RC_ONE_PASS;
+ if (stats_fn) {
+ if (!stats_open_file(&stats, stats_fn, pass)) {
+ fprintf(stderr, "Failed to open statistics store\n");
+ return EXIT_FAILURE;
+ }
+ } else {
+ if (!stats_open_mem(&stats, pass)) {
+ fprintf(stderr, "Failed to open statistics store\n");
+ return EXIT_FAILURE;
+ }
+ }
+
+ cfg.g_pass = arg_passes == 2
+ ? pass ? VPX_RC_LAST_PASS : VPX_RC_FIRST_PASS
+ : VPX_RC_ONE_PASS;
#if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION)
- if (pass)
- {
- cfg.rc_twopass_stats_in = stats_get(&stats);
- }
+ if (pass) {
+ cfg.rc_twopass_stats_in = stats_get(&stats);
+ }
#endif
- if(write_webm)
- {
- ebml.stream = outfile;
- write_webm_file_header(&ebml, &cfg, &arg_framerate, stereo_fmt);
- }
- else
- write_ivf_file_header(outfile, &cfg, codec->fourcc, 0);
+ if (write_webm) {
+ ebml.stream = outfile;
+ write_webm_file_header(&ebml, &cfg, &arg_framerate, stereo_fmt);
+ } else
+ write_ivf_file_header(outfile, &cfg, codec->fourcc, 0);
- /* Construct Encoder Context */
- vpx_codec_enc_init(&encoder, codec->iface, &cfg,
- show_psnr ? VPX_CODEC_USE_PSNR : 0);
- ctx_exit_on_error(&encoder, "Failed to initialize encoder");
+ /* Construct Encoder Context */
+ vpx_codec_enc_init(&encoder, codec->iface, &cfg,
+ show_psnr ? VPX_CODEC_USE_PSNR : 0);
+ ctx_exit_on_error(&encoder, "Failed to initialize encoder");
- if( test_decode &&
- vpx_codec_dec_init(&decoder, ifaces[0].iface, &dec_cfg,0))
- {
- fprintf(stderr,
- "Failed to initialize decoder: %s\n",
- vpx_codec_error(&decoder));
- return EXIT_FAILURE;
- }
- /* Note that we bypass the vpx_codec_control wrapper macro because
- * we're being clever to store the control IDs in an array. Real
- * applications will want to make use of the enumerations directly
- */
- for (i = 0; i < arg_ctrl_cnt; i++)
- {
- if (vpx_codec_control_(&encoder, arg_ctrls[i][0], arg_ctrls[i][1]))
- fprintf(stderr, "Error: Tried to set control %d = %d\n",
- arg_ctrls[i][0], arg_ctrls[i][1]);
- ctx_exit_on_error(&encoder, "Failed to control codec");
- }
+ if (test_decode &&
+ vpx_codec_dec_init(&decoder, ifaces[0].iface, &dec_cfg, 0)) {
+ fprintf(stderr,
+ "Failed to initialize decoder: %s\n",
+ vpx_codec_error(&decoder));
+ return EXIT_FAILURE;
+ }
+ /* Note that we bypass the vpx_codec_control wrapper macro because
+ * we're being clever to store the control IDs in an array. Real
+ * applications will want to make use of the enumerations directly
+ */
+ for (i = 0; i < arg_ctrl_cnt; i++) {
+ if (vpx_codec_control_(&encoder, arg_ctrls[i][0], arg_ctrls[i][1]))
+ fprintf(stderr, "Error: Tried to set control %d = %d\n",
+ arg_ctrls[i][0], arg_ctrls[i][1]);
+ ctx_exit_on_error(&encoder, "Failed to control codec");
+ }
- frame_avail = 1;
- got_data = 0;
+ frame_avail = 1;
+ got_data = 0;
+
+ skip_frames = arg_skip;
+ while (skip_frames) {
+ frame_avail = read_frame(infile, &raw, file_type, &y4m, &detect);
+ if (!frame_avail)
+ break;
+ skip_frames--;
+ fprintf(stderr,
+ "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
+ arg_passes, skip_frames, frames_out, nbytes);
+ }
- skip_frames = arg_skip;
- while(skip_frames)
- {
- frame_avail = read_frame(infile, &raw, file_type, &y4m, &detect);
- if (!frame_avail)
- break;
- skip_frames--;
+ while (frame_avail || got_data) {
+ vpx_codec_iter_t iter = NULL;
+ vpx_codec_iter_t dec_iter = NULL;
+ const vpx_codec_cx_pkt_t *pkt;
+ struct vpx_usec_timer timer;
+ int64_t frame_start, next_frame_start;
+
+ if (!arg_limit || frames_in < arg_limit) {
+ frame_avail = read_frame(infile, &raw, file_type, &y4m,
+ &detect);
+ if (frame_avail)
+ frames_in++;
+ } else
+ frame_avail = 0;
+
+ vpx_usec_timer_start(&timer);
+
+ frame_start = (cfg.g_timebase.den * (int64_t)(frames_in - 1)
+ * arg_framerate.den) / cfg.g_timebase.num / arg_framerate.num;
+ next_frame_start = (cfg.g_timebase.den * (int64_t)(frames_in)
+ * arg_framerate.den)
+ / cfg.g_timebase.num / arg_framerate.num;
+ vpx_codec_encode(&encoder, frame_avail ? &raw : NULL, frame_start,
+ next_frame_start - frame_start,
+ 0, arg_deadline);
+ vpx_usec_timer_mark(&timer);
+ cx_time += vpx_usec_timer_elapsed(&timer);
+ ctx_exit_on_error(&encoder, "Failed to encode frame");
+
+ if (cfg.g_pass != VPX_RC_FIRST_PASS) {
+ int q;
+
+ vpx_codec_control(&encoder, VP8E_GET_LAST_QUANTIZER_64, &q);
+ ctx_exit_on_error(&encoder, "Failed to read quantizer");
+ counts[q]++;
+ }
+
+ got_data = 0;
+ test_decode_frame = 0;
+ while ((pkt = vpx_codec_get_cx_data(&encoder, &iter))) {
+ got_data = 1;
+
+ switch (pkt->kind) {
+ case VPX_CODEC_CX_FRAME_PKT:
fprintf(stderr,
- "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
- arg_passes, skip_frames, frames_out, nbytes);
- }
-
- while (frame_avail || got_data)
- {
- vpx_codec_iter_t iter = NULL;
- vpx_codec_iter_t dec_iter = NULL;
- const vpx_codec_cx_pkt_t *pkt;
- struct vpx_usec_timer timer;
- int64_t frame_start, next_frame_start;
-
- if (!arg_limit || frames_in < arg_limit)
- {
- frame_avail = read_frame(infile, &raw, file_type, &y4m,
- &detect);
- if (frame_avail)
- frames_in++;
- }
- else
- frame_avail = 0;
-
- vpx_usec_timer_start(&timer);
-
- frame_start = (cfg.g_timebase.den * (int64_t)(frames_in - 1)
- * arg_framerate.den) / cfg.g_timebase.num / arg_framerate.num;
- next_frame_start = (cfg.g_timebase.den * (int64_t)(frames_in)
- * arg_framerate.den)
- / cfg.g_timebase.num / arg_framerate.num;
- vpx_codec_encode(&encoder, frame_avail ? &raw : NULL, frame_start,
- next_frame_start - frame_start,
- 0, arg_deadline);
- vpx_usec_timer_mark(&timer);
- cx_time += vpx_usec_timer_elapsed(&timer);
- ctx_exit_on_error(&encoder, "Failed to encode frame");
-
- if(cfg.g_pass != VPX_RC_FIRST_PASS)
- {
- int q;
-
- vpx_codec_control(&encoder, VP8E_GET_LAST_QUANTIZER_64, &q);
- ctx_exit_on_error(&encoder, "Failed to read quantizer");
- counts[q]++;
+ "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
+ arg_passes, frames_in, frames_out, nbytes);
+ frames_out++;
+ fprintf(stderr, " %6luF",
+ (unsigned long)pkt->data.frame.sz);
+
+ if (test_decode) {
+ if (!vpx_codec_decode(&decoder,
+ pkt->data.frame.buf,
+ pkt->data.frame.sz,
+ NULL, 0)) {
+ vpx_codec_get_frame(&decoder, &dec_iter);
+ test_decode_frame = 1;
+ } else {
+ const char *detail = vpx_codec_error_detail(&decoder);
+ fprintf(stderr, "Failed to decode frame: %s\n",
+ vpx_codec_error(&decoder));
+ if (detail)
+ fprintf(stderr,
+ " Additional information: %s\n",
+ detail);
+ }
}
- got_data = 0;
- test_decode_frame = 0;
- while ((pkt = vpx_codec_get_cx_data(&encoder, &iter)))
- {
- got_data = 1;
-
- switch (pkt->kind)
- {
- case VPX_CODEC_CX_FRAME_PKT:
- fprintf(stderr,
- "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
- arg_passes, frames_in, frames_out, nbytes);
- frames_out++;
- fprintf(stderr, " %6luF",
- (unsigned long)pkt->data.frame.sz);
-
- if(test_decode)
- {
- if(!vpx_codec_decode(&decoder,
- pkt->data.frame.buf,
- pkt->data.frame.sz,
- NULL, 0))
- {
- vpx_codec_get_frame(&decoder, &dec_iter);
- test_decode_frame = 1;
- }
- else
- {
- const char *detail = vpx_codec_error_detail(&decoder);
- fprintf(stderr, "Failed to decode frame: %s\n",
- vpx_codec_error(&decoder));
- if (detail)
- fprintf(stderr,
- " Additional information: %s\n",
- detail);
- }
- }
-
- update_rate_histogram(&rate_hist, &cfg, pkt);
- if(write_webm)
- {
- /* Update the hash */
- if(!ebml.debug)
- hash = murmur(pkt->data.frame.buf,
- pkt->data.frame.sz, hash);
-
- write_webm_block(&ebml, &cfg, pkt);
- }
- else
- {
- write_ivf_frame_header(outfile, pkt);
- if(fwrite(pkt->data.frame.buf, 1,
- pkt->data.frame.sz, outfile));
- }
- nbytes += pkt->data.raw.sz;
- break;
- case VPX_CODEC_STATS_PKT:
- fprintf(stderr,
- "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
- arg_passes, frames_in, frames_out, nbytes);
- frames_out++;
- fprintf(stderr, " %6luS",
- (unsigned long)pkt->data.twopass_stats.sz);
- stats_write(&stats,
- pkt->data.twopass_stats.buf,
- pkt->data.twopass_stats.sz);
- nbytes += pkt->data.raw.sz;
- break;
- case VPX_CODEC_PSNR_PKT:
-
- if (show_psnr)
- {
- int i;
-
- psnr_sse_total += pkt->data.psnr.sse[0];
- psnr_samples_total += pkt->data.psnr.samples[0];
- for (i = 0; i < 4; i++)
- {
- fprintf(stderr, "%.3lf ", pkt->data.psnr.psnr[i]);
- psnr_totals[i] += pkt->data.psnr.psnr[i];
- }
- psnr_count++;
- }
-
- break;
- default:
- break;
- }
+ update_rate_histogram(&rate_hist, &cfg, pkt);
+ if (write_webm) {
+ /* Update the hash */
+ if (!ebml.debug)
+ hash = murmur(pkt->data.frame.buf,
+ pkt->data.frame.sz, hash);
+
+ write_webm_block(&ebml, &cfg, pkt);
+ } else {
+ write_ivf_frame_header(outfile, pkt);
+ if (fwrite(pkt->data.frame.buf, 1,
+ pkt->data.frame.sz, outfile));
}
- if(test_decode && test_decode_frame)
- {
- ref_enc.frame_type = VP8_LAST_FRAME;
- ref_dec.frame_type = VP8_LAST_FRAME;
-
- vpx_codec_control( &encoder,
- VP8_COPY_REFERENCE,
- &ref_enc);
- vpx_codec_control( &decoder,
- VP8_COPY_REFERENCE,
- &ref_dec);
-
- enc_dec_match &= compare_img( &ref_enc.img,
- &ref_dec.img);
- if(!enc_dec_match && first_bad_frame < 0)
- {
- first_bad_frame = frames_out - 1;
- }
+ nbytes += pkt->data.raw.sz;
+ break;
+ case VPX_CODEC_STATS_PKT:
+ fprintf(stderr,
+ "\rPass %d/%d frame %4d/%-4d %7ldB \033[K", pass + 1,
+ arg_passes, frames_in, frames_out, nbytes);
+ frames_out++;
+ fprintf(stderr, " %6luS",
+ (unsigned long)pkt->data.twopass_stats.sz);
+ stats_write(&stats,
+ pkt->data.twopass_stats.buf,
+ pkt->data.twopass_stats.sz);
+ nbytes += pkt->data.raw.sz;
+ break;
+ case VPX_CODEC_PSNR_PKT:
+
+ if (show_psnr) {
+ int i;
+
+ psnr_sse_total += pkt->data.psnr.sse[0];
+ psnr_samples_total += pkt->data.psnr.samples[0];
+ for (i = 0; i < 4; i++) {
+ fprintf(stderr, "%.3lf ", pkt->data.psnr.psnr[i]);
+ psnr_totals[i] += pkt->data.psnr.psnr[i];
+ }
+ psnr_count++;
}
- fflush(stdout);
+ break;
+ default:
+ break;
}
-
- fprintf(stderr,
- "\rPass %d/%d frame %4d/%-4d %7ldB %7ldb/f %7"PRId64"b/s"
- " %7lu %s (%.2f fps)\033[K", pass + 1,
- arg_passes, frames_in, frames_out, nbytes, nbytes * 8 / frames_in,
- nbytes * 8 *(int64_t)arg_framerate.num / arg_framerate.den / frames_in,
- cx_time > 9999999 ? cx_time / 1000 : cx_time,
- cx_time > 9999999 ? "ms" : "us",
- (float)frames_in * 1000000.0 / (float)cx_time);
-
- if ( (show_psnr) && (psnr_count>0) )
- {
- int i;
- double ovpsnr = vp8_mse2psnr(psnr_samples_total, 255.0,
- psnr_sse_total);
-
- fprintf(stderr, "\nPSNR (Overall/Avg/Y/U/V)");
-
- fprintf(stderr, " %.3lf", ovpsnr);
- for (i = 0; i < 4; i++)
- {
- fprintf(stderr, " %.3lf", psnr_totals[i]/psnr_count);
- }
+ }
+ if (test_decode && test_decode_frame) {
+ ref_enc.frame_type = VP8_LAST_FRAME;
+ ref_dec.frame_type = VP8_LAST_FRAME;
+
+ vpx_codec_control(&encoder,
+ VP8_COPY_REFERENCE,
+ &ref_enc);
+ vpx_codec_control(&decoder,
+ VP8_COPY_REFERENCE,
+ &ref_dec);
+
+ enc_dec_match &= compare_img(&ref_enc.img,
+ &ref_dec.img);
+ if (!enc_dec_match && first_bad_frame < 0) {
+ first_bad_frame = frames_out - 1;
}
+ }
- vpx_codec_destroy(&encoder);
+ fflush(stdout);
+ }
- if(test_decode)
- vpx_codec_destroy(&decoder);
+ fprintf(stderr,
+ "\rPass %d/%d frame %4d/%-4d %7ldB %7ldb/f %7"PRId64"b/s"
+ " %7lu %s (%.2f fps)\033[K", pass + 1,
+ arg_passes, frames_in, frames_out, nbytes, nbytes * 8 / frames_in,
+ nbytes * 8 * (int64_t)arg_framerate.num / arg_framerate.den / frames_in,
+ cx_time > 9999999 ? cx_time / 1000 : cx_time,
+ cx_time > 9999999 ? "ms" : "us",
+ (float)frames_in * 1000000.0 / (float)cx_time);
+
+ if ((show_psnr) && (psnr_count > 0)) {
+ int i;
+ double ovpsnr = vp8_mse2psnr(psnr_samples_total, 255.0,
+ psnr_sse_total);
+
+ fprintf(stderr, "\nPSNR (Overall/Avg/Y/U/V)");
+
+ fprintf(stderr, " %.3lf", ovpsnr);
+ for (i = 0; i < 4; i++) {
+ fprintf(stderr, " %.3lf", psnr_totals[i] / psnr_count);
+ }
+ }
- fclose(infile);
- if (file_type == FILE_TYPE_Y4M)
- y4m_input_close(&y4m);
+ vpx_codec_destroy(&encoder);
- if(write_webm)
- {
- write_webm_file_footer(&ebml, hash);
- free(ebml.cue_list);
- ebml.cue_list = NULL;
- }
- else
- {
- if (!fseek(outfile, 0, SEEK_SET))
- write_ivf_file_header(outfile, &cfg, codec->fourcc, frames_out);
- }
+ if (test_decode)
+ vpx_codec_destroy(&decoder);
- fclose(outfile);
- stats_close(&stats, arg_passes-1);
- fprintf(stderr, "\n");
-
- if (one_pass_only)
- break;
- }
-
- if( test_decode)
- {
- fprintf(stderr, "\n");
- if(enc_dec_match)
- fprintf(stderr, "No mismatch detected in recon buffers\n");
- else
- fprintf(stderr, "First mismatch occurred in frame %d\n",
- first_bad_frame);
+ fclose(infile);
+ if (file_type == FILE_TYPE_Y4M)
+ y4m_input_close(&y4m);
+
+ if (write_webm) {
+ write_webm_file_footer(&ebml, hash);
+ free(ebml.cue_list);
+ ebml.cue_list = NULL;
+ } else {
+ if (!fseek(outfile, 0, SEEK_SET))
+ write_ivf_file_header(outfile, &cfg, codec->fourcc, frames_out);
}
- if (show_q_hist_buckets)
- show_q_histogram(counts, show_q_hist_buckets);
+ fclose(outfile);
+ stats_close(&stats, arg_passes - 1);
+ fprintf(stderr, "\n");
- if (show_rate_hist_buckets)
- show_rate_histogram(&rate_hist, &cfg, show_rate_hist_buckets);
- destroy_rate_histogram(&rate_hist);
+ if (one_pass_only)
+ break;
+ }
- vpx_img_free(&raw);
- if(test_decode)
- {
- vpx_img_free(&ref_enc.img);
- vpx_img_free(&ref_dec.img);
- }
- free(argv);
- return EXIT_SUCCESS;
+ if (test_decode) {
+ fprintf(stderr, "\n");
+ if (enc_dec_match)
+ fprintf(stderr, "No mismatch detected in recon buffers\n");
+ else
+ fprintf(stderr, "First mismatch occurred in frame %d\n",
+ first_bad_frame);
+ }
+
+ if (show_q_hist_buckets)
+ show_q_histogram(counts, show_q_hist_buckets);
+
+ if (show_rate_hist_buckets)
+ show_rate_histogram(&rate_hist, &cfg, show_rate_hist_buckets);
+ destroy_rate_histogram(&rate_hist);
+
+ vpx_img_free(&raw);
+ if (test_decode) {
+ vpx_img_free(&ref_enc.img);
+ vpx_img_free(&ref_dec.img);
+ }
+ free(argv);
+ return EXIT_SUCCESS;
}
diff --git a/y4minput.c b/y4minput.c
index dd51421d7..6be5b2bad 100644
--- a/y4minput.c
+++ b/y4minput.c
@@ -14,7 +14,7 @@
#include <string.h>
#include "y4minput.h"
-static int y4m_parse_tags(y4m_input *_y4m,char *_tags){
+static int y4m_parse_tags(y4m_input *_y4m, char *_tags) {
int got_w;
int got_h;
int got_fps;
@@ -23,55 +23,61 @@ static int y4m_parse_tags(y4m_input *_y4m,char *_tags){
int got_chroma;
char *p;
char *q;
- got_w=got_h=got_fps=got_interlace=got_par=got_chroma=0;
- for(p=_tags;;p=q){
+ got_w = got_h = got_fps = got_interlace = got_par = got_chroma = 0;
+ for (p = _tags;; p = q) {
/*Skip any leading spaces.*/
- while(*p==' ')p++;
+ while (*p == ' ')p++;
/*If that's all we have, stop.*/
- if(p[0]=='\0')break;
+ if (p[0] == '\0')break;
/*Find the end of this tag.*/
- for(q=p+1;*q!='\0'&&*q!=' ';q++);
+ for (q = p + 1; *q != '\0' && *q != ' '; q++);
/*Process the tag.*/
- switch(p[0]){
- case 'W':{
- if(sscanf(p+1,"%d",&_y4m->pic_w)!=1)return -1;
- got_w=1;
- }break;
- case 'H':{
- if(sscanf(p+1,"%d",&_y4m->pic_h)!=1)return -1;
- got_h=1;
- }break;
- case 'F':{
- if(sscanf(p+1,"%d:%d",&_y4m->fps_n,&_y4m->fps_d)!=2){
+ switch (p[0]) {
+ case 'W': {
+ if (sscanf(p + 1, "%d", &_y4m->pic_w) != 1)return -1;
+ got_w = 1;
+ }
+ break;
+ case 'H': {
+ if (sscanf(p + 1, "%d", &_y4m->pic_h) != 1)return -1;
+ got_h = 1;
+ }
+ break;
+ case 'F': {
+ if (sscanf(p + 1, "%d:%d", &_y4m->fps_n, &_y4m->fps_d) != 2) {
return -1;
}
- got_fps=1;
- }break;
- case 'I':{
- _y4m->interlace=p[1];
- got_interlace=1;
- }break;
- case 'A':{
- if(sscanf(p+1,"%d:%d",&_y4m->par_n,&_y4m->par_d)!=2){
+ got_fps = 1;
+ }
+ break;
+ case 'I': {
+ _y4m->interlace = p[1];
+ got_interlace = 1;
+ }
+ break;
+ case 'A': {
+ if (sscanf(p + 1, "%d:%d", &_y4m->par_n, &_y4m->par_d) != 2) {
return -1;
}
- got_par=1;
- }break;
- case 'C':{
- if(q-p>16)return -1;
- memcpy(_y4m->chroma_type,p+1,q-p-1);
- _y4m->chroma_type[q-p-1]='\0';
- got_chroma=1;
- }break;
+ got_par = 1;
+ }
+ break;
+ case 'C': {
+ if (q - p > 16)return -1;
+ memcpy(_y4m->chroma_type, p + 1, q - p - 1);
+ _y4m->chroma_type[q - p - 1] = '\0';
+ got_chroma = 1;
+ }
+ break;
/*Ignore unknown tags.*/
}
}
- if(!got_w||!got_h||!got_fps)return -1;
- if(!got_interlace)_y4m->interlace='?';
- if(!got_par)_y4m->par_n=_y4m->par_d=0;
+ if (!got_w || !got_h || !got_fps)return -1;
+ if (!got_interlace)_y4m->interlace = '?';
+ if (!got_par)_y4m->par_n = _y4m->par_d = 0;
/*Chroma-type is not specified in older files, e.g., those generated by
mplayer.*/
- if(!got_chroma)strcpy(_y4m->chroma_type,"420");
+ if (!got_chroma)strcpy(_y4m->chroma_type, "420");
return 0;
}
@@ -145,48 +151,48 @@ static int y4m_parse_tags(y4m_input *_y4m,char *_tags){
lines, and they are vertically co-sited with the luma samples in both the
mpeg2 and jpeg cases (thus requiring no vertical resampling).*/
static void y4m_42xmpeg2_42xjpeg_helper(unsigned char *_dst,
- const unsigned char *_src,int _c_w,int _c_h){
+ const unsigned char *_src, int _c_w, int _c_h) {
int y;
int x;
- for(y=0;y<_c_h;y++){
+ for (y = 0; y < _c_h; y++) {
/*Filter: [4 -17 114 35 -9 1]/128, derived from a 6-tap Lanczos
window.*/
- for(x=0;x<OC_MINI(_c_w,2);x++){
- _dst[x]=(unsigned char)OC_CLAMPI(0,(4*_src[0]-17*_src[OC_MAXI(x-1,0)]+
- 114*_src[x]+35*_src[OC_MINI(x+1,_c_w-1)]-9*_src[OC_MINI(x+2,_c_w-1)]+
- _src[OC_MINI(x+3,_c_w-1)]+64)>>7,255);
+ for (x = 0; x < OC_MINI(_c_w, 2); x++) {
+ _dst[x] = (unsigned char)OC_CLAMPI(0, (4 * _src[0] - 17 * _src[OC_MAXI(x - 1, 0)] +
+ 114 * _src[x] + 35 * _src[OC_MINI(x + 1, _c_w - 1)] - 9 * _src[OC_MINI(x + 2, _c_w - 1)] +
+ _src[OC_MINI(x + 3, _c_w - 1)] + 64) >> 7, 255);
}
- for(;x<_c_w-3;x++){
- _dst[x]=(unsigned char)OC_CLAMPI(0,(4*_src[x-2]-17*_src[x-1]+
- 114*_src[x]+35*_src[x+1]-9*_src[x+2]+_src[x+3]+64)>>7,255);
+ for (; x < _c_w - 3; x++) {
+ _dst[x] = (unsigned char)OC_CLAMPI(0, (4 * _src[x - 2] - 17 * _src[x - 1] +
+ 114 * _src[x] + 35 * _src[x + 1] - 9 * _src[x + 2] + _src[x + 3] + 64) >> 7, 255);
}
- for(;x<_c_w;x++){
- _dst[x]=(unsigned char)OC_CLAMPI(0,(4*_src[x-2]-17*_src[x-1]+
- 114*_src[x]+35*_src[OC_MINI(x+1,_c_w-1)]-9*_src[OC_MINI(x+2,_c_w-1)]+
- _src[_c_w-1]+64)>>7,255);
+ for (; x < _c_w; x++) {
+ _dst[x] = (unsigned char)OC_CLAMPI(0, (4 * _src[x - 2] - 17 * _src[x - 1] +
+ 114 * _src[x] + 35 * _src[OC_MINI(x + 1, _c_w - 1)] - 9 * _src[OC_MINI(x + 2, _c_w - 1)] +
+ _src[_c_w - 1] + 64) >> 7, 255);
}
- _dst+=_c_w;
- _src+=_c_w;
+ _dst += _c_w;
+ _src += _c_w;
}
}
/*Handles both 422 and 420mpeg2 to 422jpeg and 420jpeg, respectively.*/
-static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
int c_w;
int c_h;
int c_sz;
int pli;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- for(pli=1;pli<3;pli++){
- y4m_42xmpeg2_42xjpeg_helper(_dst,_aux,c_w,c_h);
- _dst+=c_sz;
- _aux+=c_sz;
+ c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ for (pli = 1; pli < 3; pli++) {
+ y4m_42xmpeg2_42xjpeg_helper(_dst, _aux, c_w, c_h);
+ _dst += c_sz;
+ _aux += c_sz;
}
}
@@ -233,8 +239,8 @@ static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m,unsigned char *_dst,
the chroma plane's resolution) to the right.
Then we use another filter to move the C_r location down one quarter pixel,
and the C_b location up one quarter pixel.*/
-static void y4m_convert_42xpaldv_42xjpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_42xpaldv_42xjpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
unsigned char *tmp;
int c_w;
int c_h;
@@ -243,69 +249,71 @@ static void y4m_convert_42xpaldv_42xjpeg(y4m_input *_y4m,unsigned char *_dst,
int y;
int x;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+1)/2;
- c_h=(_y4m->pic_h+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- c_sz=c_w*c_h;
- tmp=_aux+2*c_sz;
- for(pli=1;pli<3;pli++){
+ c_w = (_y4m->pic_w + 1) / 2;
+ c_h = (_y4m->pic_h + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ c_sz = c_w * c_h;
+ tmp = _aux + 2 * c_sz;
+ for (pli = 1; pli < 3; pli++) {
/*First do the horizontal re-sampling.
This is the same as the mpeg2 case, except that after the horizontal
case, we need to apply a second vertical filter.*/
- y4m_42xmpeg2_42xjpeg_helper(tmp,_aux,c_w,c_h);
- _aux+=c_sz;
- switch(pli){
- case 1:{
+ y4m_42xmpeg2_42xjpeg_helper(tmp, _aux, c_w, c_h);
+ _aux += c_sz;
+ switch (pli) {
+ case 1: {
/*Slide C_b up a quarter-pel.
This is the same filter used above, but in the other order.*/
- for(x=0;x<c_w;x++){
- for(y=0;y<OC_MINI(c_h,3);y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(tmp[0]
- -9*tmp[OC_MAXI(y-2,0)*c_w]+35*tmp[OC_MAXI(y-1,0)*c_w]
- +114*tmp[y*c_w]-17*tmp[OC_MINI(y+1,c_h-1)*c_w]
- +4*tmp[OC_MINI(y+2,c_h-1)*c_w]+64)>>7,255);
+ for (x = 0; x < c_w; x++) {
+ for (y = 0; y < OC_MINI(c_h, 3); y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (tmp[0]
+ - 9 * tmp[OC_MAXI(y - 2, 0) * c_w] + 35 * tmp[OC_MAXI(y - 1, 0) * c_w]
+ + 114 * tmp[y * c_w] - 17 * tmp[OC_MINI(y + 1, c_h - 1) * c_w]
+ + 4 * tmp[OC_MINI(y + 2, c_h - 1) * c_w] + 64) >> 7, 255);
}
- for(;y<c_h-2;y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(tmp[(y-3)*c_w]
- -9*tmp[(y-2)*c_w]+35*tmp[(y-1)*c_w]+114*tmp[y*c_w]
- -17*tmp[(y+1)*c_w]+4*tmp[(y+2)*c_w]+64)>>7,255);
+ for (; y < c_h - 2; y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (tmp[(y - 3) * c_w]
+ - 9 * tmp[(y - 2) * c_w] + 35 * tmp[(y - 1) * c_w] + 114 * tmp[y * c_w]
+ - 17 * tmp[(y + 1) * c_w] + 4 * tmp[(y + 2) * c_w] + 64) >> 7, 255);
}
- for(;y<c_h;y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(tmp[(y-3)*c_w]
- -9*tmp[(y-2)*c_w]+35*tmp[(y-1)*c_w]+114*tmp[y*c_w]
- -17*tmp[OC_MINI(y+1,c_h-1)*c_w]+4*tmp[(c_h-1)*c_w]+64)>>7,255);
+ for (; y < c_h; y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (tmp[(y - 3) * c_w]
+ - 9 * tmp[(y - 2) * c_w] + 35 * tmp[(y - 1) * c_w] + 114 * tmp[y * c_w]
+ - 17 * tmp[OC_MINI(y + 1, c_h - 1) * c_w] + 4 * tmp[(c_h - 1) * c_w] + 64) >> 7, 255);
}
_dst++;
tmp++;
}
- _dst+=c_sz-c_w;
- tmp-=c_w;
- }break;
- case 2:{
+ _dst += c_sz - c_w;
+ tmp -= c_w;
+ }
+ break;
+ case 2: {
/*Slide C_r down a quarter-pel.
This is the same as the horizontal filter.*/
- for(x=0;x<c_w;x++){
- for(y=0;y<OC_MINI(c_h,2);y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(4*tmp[0]
- -17*tmp[OC_MAXI(y-1,0)*c_w]+114*tmp[y*c_w]
- +35*tmp[OC_MINI(y+1,c_h-1)*c_w]-9*tmp[OC_MINI(y+2,c_h-1)*c_w]
- +tmp[OC_MINI(y+3,c_h-1)*c_w]+64)>>7,255);
+ for (x = 0; x < c_w; x++) {
+ for (y = 0; y < OC_MINI(c_h, 2); y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (4 * tmp[0]
+ - 17 * tmp[OC_MAXI(y - 1, 0) * c_w] + 114 * tmp[y * c_w]
+ + 35 * tmp[OC_MINI(y + 1, c_h - 1) * c_w] - 9 * tmp[OC_MINI(y + 2, c_h - 1) * c_w]
+ + tmp[OC_MINI(y + 3, c_h - 1) * c_w] + 64) >> 7, 255);
}
- for(;y<c_h-3;y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(4*tmp[(y-2)*c_w]
- -17*tmp[(y-1)*c_w]+114*tmp[y*c_w]+35*tmp[(y+1)*c_w]
- -9*tmp[(y+2)*c_w]+tmp[(y+3)*c_w]+64)>>7,255);
+ for (; y < c_h - 3; y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (4 * tmp[(y - 2) * c_w]
+ - 17 * tmp[(y - 1) * c_w] + 114 * tmp[y * c_w] + 35 * tmp[(y + 1) * c_w]
+ - 9 * tmp[(y + 2) * c_w] + tmp[(y + 3) * c_w] + 64) >> 7, 255);
}
- for(;y<c_h;y++){
- _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,(4*tmp[(y-2)*c_w]
- -17*tmp[(y-1)*c_w]+114*tmp[y*c_w]+35*tmp[OC_MINI(y+1,c_h-1)*c_w]
- -9*tmp[OC_MINI(y+2,c_h-1)*c_w]+tmp[(c_h-1)*c_w]+64)>>7,255);
+ for (; y < c_h; y++) {
+ _dst[y * c_w] = (unsigned char)OC_CLAMPI(0, (4 * tmp[(y - 2) * c_w]
+ - 17 * tmp[(y - 1) * c_w] + 114 * tmp[y * c_w] + 35 * tmp[OC_MINI(y + 1, c_h - 1) * c_w]
+ - 9 * tmp[OC_MINI(y + 2, c_h - 1) * c_w] + tmp[(c_h - 1) * c_w] + 64) >> 7, 255);
}
_dst++;
tmp++;
}
- }break;
+ }
+ break;
}
/*For actual interlaced material, this would have to be done separately on
each field, and the shift amounts would be different.
@@ -320,27 +328,27 @@ static void y4m_convert_42xpaldv_42xjpeg(y4m_input *_y4m,unsigned char *_dst,
/*Perform vertical filtering to reduce a single plane from 4:2:2 to 4:2:0.
This is used as a helper by several converation routines.*/
static void y4m_422jpeg_420jpeg_helper(unsigned char *_dst,
- const unsigned char *_src,int _c_w,int _c_h){
+ const unsigned char *_src, int _c_w, int _c_h) {
int y;
int x;
/*Filter: [3 -17 78 78 -17 3]/128, derived from a 6-tap Lanczos window.*/
- for(x=0;x<_c_w;x++){
- for(y=0;y<OC_MINI(_c_h,2);y+=2){
- _dst[(y>>1)*_c_w]=OC_CLAMPI(0,(64*_src[0]
- +78*_src[OC_MINI(1,_c_h-1)*_c_w]
- -17*_src[OC_MINI(2,_c_h-1)*_c_w]
- +3*_src[OC_MINI(3,_c_h-1)*_c_w]+64)>>7,255);
+ for (x = 0; x < _c_w; x++) {
+ for (y = 0; y < OC_MINI(_c_h, 2); y += 2) {
+ _dst[(y >> 1)*_c_w] = OC_CLAMPI(0, (64 * _src[0]
+ + 78 * _src[OC_MINI(1, _c_h - 1) * _c_w]
+ - 17 * _src[OC_MINI(2, _c_h - 1) * _c_w]
+ + 3 * _src[OC_MINI(3, _c_h - 1) * _c_w] + 64) >> 7, 255);
}
- for(;y<_c_h-3;y+=2){
- _dst[(y>>1)*_c_w]=OC_CLAMPI(0,(3*(_src[(y-2)*_c_w]+_src[(y+3)*_c_w])
- -17*(_src[(y-1)*_c_w]+_src[(y+2)*_c_w])
- +78*(_src[y*_c_w]+_src[(y+1)*_c_w])+64)>>7,255);
+ for (; y < _c_h - 3; y += 2) {
+ _dst[(y >> 1)*_c_w] = OC_CLAMPI(0, (3 * (_src[(y - 2) * _c_w] + _src[(y + 3) * _c_w])
+ - 17 * (_src[(y - 1) * _c_w] + _src[(y + 2) * _c_w])
+ + 78 * (_src[y * _c_w] + _src[(y + 1) * _c_w]) + 64) >> 7, 255);
}
- for(;y<_c_h;y+=2){
- _dst[(y>>1)*_c_w]=OC_CLAMPI(0,(3*(_src[(y-2)*_c_w]
- +_src[(_c_h-1)*_c_w])-17*(_src[(y-1)*_c_w]
- +_src[OC_MINI(y+2,_c_h-1)*_c_w])
- +78*(_src[y*_c_w]+_src[OC_MINI(y+1,_c_h-1)*_c_w])+64)>>7,255);
+ for (; y < _c_h; y += 2) {
+ _dst[(y >> 1)*_c_w] = OC_CLAMPI(0, (3 * (_src[(y - 2) * _c_w]
+ + _src[(_c_h - 1) * _c_w]) - 17 * (_src[(y - 1) * _c_w]
+ + _src[OC_MINI(y + 2, _c_h - 1) * _c_w])
+ + 78 * (_src[y * _c_w] + _src[OC_MINI(y + 1, _c_h - 1) * _c_w]) + 64) >> 7, 255);
}
_src++;
_dst++;
@@ -385,8 +393,8 @@ static void y4m_422jpeg_420jpeg_helper(unsigned char *_dst,
We use a resampling filter to decimate the chroma planes by two in the
vertical direction.*/
-static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
int c_w;
int c_h;
int c_sz;
@@ -395,18 +403,18 @@ static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m,unsigned char *_dst,
int dst_c_sz;
int pli;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h;
- c_h=_y4m->pic_h;
- dst_c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- dst_c_sz=dst_c_w*dst_c_h;
- for(pli=1;pli<3;pli++){
- y4m_422jpeg_420jpeg_helper(_dst,_aux,c_w,c_h);
- _aux+=c_sz;
- _dst+=dst_c_sz;
+ c_w = (_y4m->pic_w + _y4m->src_c_dec_h - 1) / _y4m->src_c_dec_h;
+ c_h = _y4m->pic_h;
+ dst_c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ dst_c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ dst_c_sz = dst_c_w * dst_c_h;
+ for (pli = 1; pli < 3; pli++) {
+ y4m_422jpeg_420jpeg_helper(_dst, _aux, c_w, c_h);
+ _aux += c_sz;
+ _dst += dst_c_sz;
}
}
@@ -450,8 +458,8 @@ static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m,unsigned char *_dst,
pixel (at the original chroma resolution) to the right.
Then we use a second resampling filter to decimate the chroma planes by two
in the vertical direction.*/
-static void y4m_convert_422_420jpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_422_420jpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
unsigned char *tmp;
int c_w;
int c_h;
@@ -460,24 +468,24 @@ static void y4m_convert_422_420jpeg(y4m_input *_y4m,unsigned char *_dst,
int dst_c_sz;
int pli;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h;
- c_h=_y4m->pic_h;
- dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- dst_c_sz=c_w*dst_c_h;
- tmp=_aux+2*c_sz;
- for(pli=1;pli<3;pli++){
+ c_w = (_y4m->pic_w + _y4m->src_c_dec_h - 1) / _y4m->src_c_dec_h;
+ c_h = _y4m->pic_h;
+ dst_c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ dst_c_sz = c_w * dst_c_h;
+ tmp = _aux + 2 * c_sz;
+ for (pli = 1; pli < 3; pli++) {
/*In reality, the horizontal and vertical steps could be pipelined, for
less memory consumption and better cache performance, but we do them
separately for simplicity.*/
/*First do horizontal filtering (convert to 422jpeg)*/
- y4m_42xmpeg2_42xjpeg_helper(tmp,_aux,c_w,c_h);
+ y4m_42xmpeg2_42xjpeg_helper(tmp, _aux, c_w, c_h);
/*Now do the vertical filtering.*/
- y4m_422jpeg_420jpeg_helper(_dst,tmp,c_w,c_h);
- _aux+=c_sz;
- _dst+=dst_c_sz;
+ y4m_422jpeg_420jpeg_helper(_dst, tmp, c_w, c_h);
+ _aux += c_sz;
+ _dst += dst_c_sz;
}
}
@@ -522,8 +530,8 @@ static void y4m_convert_422_420jpeg(y4m_input *_y4m,unsigned char *_dst,
right.
Then we use another filter to decimate the planes by 2 in the vertical
direction.*/
-static void y4m_convert_411_420jpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_411_420jpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
unsigned char *tmp;
int c_w;
int c_h;
@@ -536,57 +544,57 @@ static void y4m_convert_411_420jpeg(y4m_input *_y4m,unsigned char *_dst,
int y;
int x;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h;
- c_h=_y4m->pic_h;
- dst_c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- dst_c_sz=dst_c_w*dst_c_h;
- tmp_sz=dst_c_w*c_h;
- tmp=_aux+2*c_sz;
- for(pli=1;pli<3;pli++){
+ c_w = (_y4m->pic_w + _y4m->src_c_dec_h - 1) / _y4m->src_c_dec_h;
+ c_h = _y4m->pic_h;
+ dst_c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ dst_c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ dst_c_sz = dst_c_w * dst_c_h;
+ tmp_sz = dst_c_w * c_h;
+ tmp = _aux + 2 * c_sz;
+ for (pli = 1; pli < 3; pli++) {
/*In reality, the horizontal and vertical steps could be pipelined, for
less memory consumption and better cache performance, but we do them
separately for simplicity.*/
/*First do horizontal filtering (convert to 422jpeg)*/
- for(y=0;y<c_h;y++){
+ for (y = 0; y < c_h; y++) {
/*Filters: [1 110 18 -1]/128 and [-3 50 86 -5]/128, both derived from a
4-tap Mitchell window.*/
- for(x=0;x<OC_MINI(c_w,1);x++){
- tmp[x<<1]=(unsigned char)OC_CLAMPI(0,(111*_aux[0]
- +18*_aux[OC_MINI(1,c_w-1)]-_aux[OC_MINI(2,c_w-1)]+64)>>7,255);
- tmp[x<<1|1]=(unsigned char)OC_CLAMPI(0,(47*_aux[0]
- +86*_aux[OC_MINI(1,c_w-1)]-5*_aux[OC_MINI(2,c_w-1)]+64)>>7,255);
+ for (x = 0; x < OC_MINI(c_w, 1); x++) {
+ tmp[x << 1] = (unsigned char)OC_CLAMPI(0, (111 * _aux[0]
+ + 18 * _aux[OC_MINI(1, c_w - 1)] - _aux[OC_MINI(2, c_w - 1)] + 64) >> 7, 255);
+ tmp[x << 1 | 1] = (unsigned char)OC_CLAMPI(0, (47 * _aux[0]
+ + 86 * _aux[OC_MINI(1, c_w - 1)] - 5 * _aux[OC_MINI(2, c_w - 1)] + 64) >> 7, 255);
}
- for(;x<c_w-2;x++){
- tmp[x<<1]=(unsigned char)OC_CLAMPI(0,(_aux[x-1]+110*_aux[x]
- +18*_aux[x+1]-_aux[x+2]+64)>>7,255);
- tmp[x<<1|1]=(unsigned char)OC_CLAMPI(0,(-3*_aux[x-1]+50*_aux[x]
- +86*_aux[x+1]-5*_aux[x+2]+64)>>7,255);
+ for (; x < c_w - 2; x++) {
+ tmp[x << 1] = (unsigned char)OC_CLAMPI(0, (_aux[x - 1] + 110 * _aux[x]
+ + 18 * _aux[x + 1] - _aux[x + 2] + 64) >> 7, 255);
+ tmp[x << 1 | 1] = (unsigned char)OC_CLAMPI(0, (-3 * _aux[x - 1] + 50 * _aux[x]
+ + 86 * _aux[x + 1] - 5 * _aux[x + 2] + 64) >> 7, 255);
}
- for(;x<c_w;x++){
- tmp[x<<1]=(unsigned char)OC_CLAMPI(0,(_aux[x-1]+110*_aux[x]
- +18*_aux[OC_MINI(x+1,c_w-1)]-_aux[c_w-1]+64)>>7,255);
- if((x<<1|1)<dst_c_w){
- tmp[x<<1|1]=(unsigned char)OC_CLAMPI(0,(-3*_aux[x-1]+50*_aux[x]
- +86*_aux[OC_MINI(x+1,c_w-1)]-5*_aux[c_w-1]+64)>>7,255);
+ for (; x < c_w; x++) {
+ tmp[x << 1] = (unsigned char)OC_CLAMPI(0, (_aux[x - 1] + 110 * _aux[x]
+ + 18 * _aux[OC_MINI(x + 1, c_w - 1)] - _aux[c_w - 1] + 64) >> 7, 255);
+ if ((x << 1 | 1) < dst_c_w) {
+ tmp[x << 1 | 1] = (unsigned char)OC_CLAMPI(0, (-3 * _aux[x - 1] + 50 * _aux[x]
+ + 86 * _aux[OC_MINI(x + 1, c_w - 1)] - 5 * _aux[c_w - 1] + 64) >> 7, 255);
}
}
- tmp+=dst_c_w;
- _aux+=c_w;
+ tmp += dst_c_w;
+ _aux += c_w;
}
- tmp-=tmp_sz;
+ tmp -= tmp_sz;
/*Now do the vertical filtering.*/
- y4m_422jpeg_420jpeg_helper(_dst,tmp,dst_c_w,c_h);
- _dst+=dst_c_sz;
+ y4m_422jpeg_420jpeg_helper(_dst, tmp, dst_c_w, c_h);
+ _dst += dst_c_sz;
}
}
/*Convert 444 to 420jpeg.*/
-static void y4m_convert_444_420jpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_444_420jpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
unsigned char *tmp;
int c_w;
int c_h;
@@ -599,218 +607,207 @@ static void y4m_convert_444_420jpeg(y4m_input *_y4m,unsigned char *_dst,
int y;
int x;
/*Skip past the luma data.*/
- _dst+=_y4m->pic_w*_y4m->pic_h;
+ _dst += _y4m->pic_w * _y4m->pic_h;
/*Compute the size of each chroma plane.*/
- c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h;
- c_h=_y4m->pic_h;
- dst_c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- dst_c_sz=dst_c_w*dst_c_h;
- tmp_sz=dst_c_w*c_h;
- tmp=_aux+2*c_sz;
- for(pli=1;pli<3;pli++){
+ c_w = (_y4m->pic_w + _y4m->src_c_dec_h - 1) / _y4m->src_c_dec_h;
+ c_h = _y4m->pic_h;
+ dst_c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ dst_c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ dst_c_sz = dst_c_w * dst_c_h;
+ tmp_sz = dst_c_w * c_h;
+ tmp = _aux + 2 * c_sz;
+ for (pli = 1; pli < 3; pli++) {
/*Filter: [3 -17 78 78 -17 3]/128, derived from a 6-tap Lanczos window.*/
- for(y=0;y<c_h;y++){
- for(x=0;x<OC_MINI(c_w,2);x+=2){
- tmp[x>>1]=OC_CLAMPI(0,(64*_aux[0]+78*_aux[OC_MINI(1,c_w-1)]
- -17*_aux[OC_MINI(2,c_w-1)]
- +3*_aux[OC_MINI(3,c_w-1)]+64)>>7,255);
+ for (y = 0; y < c_h; y++) {
+ for (x = 0; x < OC_MINI(c_w, 2); x += 2) {
+ tmp[x >> 1] = OC_CLAMPI(0, (64 * _aux[0] + 78 * _aux[OC_MINI(1, c_w - 1)]
+ - 17 * _aux[OC_MINI(2, c_w - 1)]
+ + 3 * _aux[OC_MINI(3, c_w - 1)] + 64) >> 7, 255);
}
- for(;x<c_w-3;x+=2){
- tmp[x>>1]=OC_CLAMPI(0,(3*(_aux[x-2]+_aux[x+3])
- -17*(_aux[x-1]+_aux[x+2])+78*(_aux[x]+_aux[x+1])+64)>>7,255);
+ for (; x < c_w - 3; x += 2) {
+ tmp[x >> 1] = OC_CLAMPI(0, (3 * (_aux[x - 2] + _aux[x + 3])
+ - 17 * (_aux[x - 1] + _aux[x + 2]) + 78 * (_aux[x] + _aux[x + 1]) + 64) >> 7, 255);
}
- for(;x<c_w;x+=2){
- tmp[x>>1]=OC_CLAMPI(0,(3*(_aux[x-2]+_aux[c_w-1])-
- 17*(_aux[x-1]+_aux[OC_MINI(x+2,c_w-1)])+
- 78*(_aux[x]+_aux[OC_MINI(x+1,c_w-1)])+64)>>7,255);
+ for (; x < c_w; x += 2) {
+ tmp[x >> 1] = OC_CLAMPI(0, (3 * (_aux[x - 2] + _aux[c_w - 1]) -
+ 17 * (_aux[x - 1] + _aux[OC_MINI(x + 2, c_w - 1)]) +
+ 78 * (_aux[x] + _aux[OC_MINI(x + 1, c_w - 1)]) + 64) >> 7, 255);
}
- tmp+=dst_c_w;
- _aux+=c_w;
+ tmp += dst_c_w;
+ _aux += c_w;
}
- tmp-=tmp_sz;
+ tmp -= tmp_sz;
/*Now do the vertical filtering.*/
- y4m_422jpeg_420jpeg_helper(_dst,tmp,dst_c_w,c_h);
- _dst+=dst_c_sz;
+ y4m_422jpeg_420jpeg_helper(_dst, tmp, dst_c_w, c_h);
+ _dst += dst_c_sz;
}
}
/*The image is padded with empty chroma components at 4:2:0.*/
-static void y4m_convert_mono_420jpeg(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_mono_420jpeg(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
int c_sz;
- _dst+=_y4m->pic_w*_y4m->pic_h;
- c_sz=((_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h)*
- ((_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v);
- memset(_dst,128,c_sz*2);
+ _dst += _y4m->pic_w * _y4m->pic_h;
+ c_sz = ((_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h) *
+ ((_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v);
+ memset(_dst, 128, c_sz * 2);
}
/*No conversion function needed.*/
-static void y4m_convert_null(y4m_input *_y4m,unsigned char *_dst,
- unsigned char *_aux){
+static void y4m_convert_null(y4m_input *_y4m, unsigned char *_dst,
+ unsigned char *_aux) {
}
-int y4m_input_open(y4m_input *_y4m,FILE *_fin,char *_skip,int _nskip){
+int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip) {
char buffer[80];
int ret;
int i;
/*Read until newline, or 80 cols, whichever happens first.*/
- for(i=0;i<79;i++){
- if(_nskip>0){
- buffer[i]=*_skip++;
+ for (i = 0; i < 79; i++) {
+ if (_nskip > 0) {
+ buffer[i] = *_skip++;
_nskip--;
+ } else {
+ ret = fread(buffer + i, 1, 1, _fin);
+ if (ret < 1)return -1;
}
- else{
- ret=fread(buffer+i,1,1,_fin);
- if(ret<1)return -1;
- }
- if(buffer[i]=='\n')break;
+ if (buffer[i] == '\n')break;
}
/*We skipped too much header data.*/
- if(_nskip>0)return -1;
- if(i==79){
- fprintf(stderr,"Error parsing header; not a YUV2MPEG2 file?\n");
+ if (_nskip > 0)return -1;
+ if (i == 79) {
+ fprintf(stderr, "Error parsing header; not a YUV2MPEG2 file?\n");
return -1;
}
- buffer[i]='\0';
- if(memcmp(buffer,"YUV4MPEG",8)){
- fprintf(stderr,"Incomplete magic for YUV4MPEG file.\n");
+ buffer[i] = '\0';
+ if (memcmp(buffer, "YUV4MPEG", 8)) {
+ fprintf(stderr, "Incomplete magic for YUV4MPEG file.\n");
return -1;
}
- if(buffer[8]!='2'){
- fprintf(stderr,"Incorrect YUV input file version; YUV4MPEG2 required.\n");
+ if (buffer[8] != '2') {
+ fprintf(stderr, "Incorrect YUV input file version; YUV4MPEG2 required.\n");
}
- ret=y4m_parse_tags(_y4m,buffer+5);
- if(ret<0){
- fprintf(stderr,"Error parsing YUV4MPEG2 header.\n");
+ ret = y4m_parse_tags(_y4m, buffer + 5);
+ if (ret < 0) {
+ fprintf(stderr, "Error parsing YUV4MPEG2 header.\n");
return ret;
}
- if(_y4m->interlace=='?'){
- fprintf(stderr,"Warning: Input video interlacing format unknown; "
- "assuming progressive scan.\n");
- }
- else if(_y4m->interlace!='p'){
- fprintf(stderr,"Input video is interlaced; "
- "Only progressive scan handled.\n");
+ if (_y4m->interlace == '?') {
+ fprintf(stderr, "Warning: Input video interlacing format unknown; "
+ "assuming progressive scan.\n");
+ } else if (_y4m->interlace != 'p') {
+ fprintf(stderr, "Input video is interlaced; "
+ "Only progressive scan handled.\n");
return -1;
}
- if(strcmp(_y4m->chroma_type,"420")==0||
- strcmp(_y4m->chroma_type,"420jpeg")==0){
- _y4m->src_c_dec_h=_y4m->dst_c_dec_h=_y4m->src_c_dec_v=_y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h
- +2*((_y4m->pic_w+1)/2)*((_y4m->pic_h+1)/2);
+ if (strcmp(_y4m->chroma_type, "420") == 0 ||
+ strcmp(_y4m->chroma_type, "420jpeg") == 0) {
+ _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h
+ + 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2);
/*Natively supported: no conversion required.*/
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz=0;
- _y4m->convert=y4m_convert_null;
- }
- else if(strcmp(_y4m->chroma_type,"420mpeg2")==0){
- _y4m->src_c_dec_h=_y4m->dst_c_dec_h=_y4m->src_c_dec_v=_y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0;
+ _y4m->convert = y4m_convert_null;
+ } else if (strcmp(_y4m->chroma_type, "420mpeg2") == 0) {
+ _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.*/
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz=
- 2*((_y4m->pic_w+1)/2)*((_y4m->pic_h+1)/2);
- _y4m->convert=y4m_convert_42xmpeg2_42xjpeg;
- }
- else if(strcmp(_y4m->chroma_type,"420paldv")==0){
- _y4m->src_c_dec_h=_y4m->dst_c_dec_h=_y4m->src_c_dec_v=_y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz =
+ 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2);
+ _y4m->convert = y4m_convert_42xmpeg2_42xjpeg;
+ } else if (strcmp(_y4m->chroma_type, "420paldv") == 0) {
+ _y4m->src_c_dec_h = _y4m->dst_c_dec_h = _y4m->src_c_dec_v = _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.
We need to make two filter passes, so we need some extra space in the
aux buffer.*/
- _y4m->aux_buf_sz=3*((_y4m->pic_w+1)/2)*((_y4m->pic_h+1)/2);
- _y4m->aux_buf_read_sz=2*((_y4m->pic_w+1)/2)*((_y4m->pic_h+1)/2);
- _y4m->convert=y4m_convert_42xpaldv_42xjpeg;
- }
- else if(strcmp(_y4m->chroma_type,"422jpeg")==0){
- _y4m->src_c_dec_h=_y4m->dst_c_dec_h=2;
- _y4m->src_c_dec_v=1;
- _y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_sz = 3 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2);
+ _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 1) / 2) * ((_y4m->pic_h + 1) / 2);
+ _y4m->convert = y4m_convert_42xpaldv_42xjpeg;
+ } else if (strcmp(_y4m->chroma_type, "422jpeg") == 0) {
+ _y4m->src_c_dec_h = _y4m->dst_c_dec_h = 2;
+ _y4m->src_c_dec_v = 1;
+ _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.*/
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz=2*((_y4m->pic_w+1)/2)*_y4m->pic_h;
- _y4m->convert=y4m_convert_422jpeg_420jpeg;
- }
- else if(strcmp(_y4m->chroma_type,"422")==0){
- _y4m->src_c_dec_h=_y4m->dst_c_dec_h=2;
- _y4m->src_c_dec_v=1;
- _y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h;
+ _y4m->convert = y4m_convert_422jpeg_420jpeg;
+ } else if (strcmp(_y4m->chroma_type, "422") == 0) {
+ _y4m->src_c_dec_h = _y4m->dst_c_dec_h = 2;
+ _y4m->src_c_dec_v = 1;
+ _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.
We need to make two filter passes, so we need some extra space in the
aux buffer.*/
- _y4m->aux_buf_read_sz=2*((_y4m->pic_w+1)/2)*_y4m->pic_h;
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz+((_y4m->pic_w+1)/2)*_y4m->pic_h;
- _y4m->convert=y4m_convert_422_420jpeg;
- }
- else if(strcmp(_y4m->chroma_type,"411")==0){
- _y4m->src_c_dec_h=4;
- _y4m->dst_c_dec_h=2;
- _y4m->src_c_dec_v=1;
- _y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 1) / 2) * _y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h;
+ _y4m->convert = y4m_convert_422_420jpeg;
+ } else if (strcmp(_y4m->chroma_type, "411") == 0) {
+ _y4m->src_c_dec_h = 4;
+ _y4m->dst_c_dec_h = 2;
+ _y4m->src_c_dec_v = 1;
+ _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.
We need to make two filter passes, so we need some extra space in the
aux buffer.*/
- _y4m->aux_buf_read_sz=2*((_y4m->pic_w+3)/4)*_y4m->pic_h;
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz+((_y4m->pic_w+1)/2)*_y4m->pic_h;
- _y4m->convert=y4m_convert_411_420jpeg;
- }
- else if(strcmp(_y4m->chroma_type,"444")==0){
- _y4m->src_c_dec_h=1;
- _y4m->dst_c_dec_h=2;
- _y4m->src_c_dec_v=1;
- _y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_read_sz = 2 * ((_y4m->pic_w + 3) / 4) * _y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h;
+ _y4m->convert = y4m_convert_411_420jpeg;
+ } else if (strcmp(_y4m->chroma_type, "444") == 0) {
+ _y4m->src_c_dec_h = 1;
+ _y4m->dst_c_dec_h = 2;
+ _y4m->src_c_dec_v = 1;
+ _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.
We need to make two filter passes, so we need some extra space in the
aux buffer.*/
- _y4m->aux_buf_read_sz=2*_y4m->pic_w*_y4m->pic_h;
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz+((_y4m->pic_w+1)/2)*_y4m->pic_h;
- _y4m->convert=y4m_convert_444_420jpeg;
- }
- else if(strcmp(_y4m->chroma_type,"444alpha")==0){
- _y4m->src_c_dec_h=1;
- _y4m->dst_c_dec_h=2;
- _y4m->src_c_dec_v=1;
- _y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_read_sz = 2 * _y4m->pic_w * _y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz + ((_y4m->pic_w + 1) / 2) * _y4m->pic_h;
+ _y4m->convert = y4m_convert_444_420jpeg;
+ } else if (strcmp(_y4m->chroma_type, "444alpha") == 0) {
+ _y4m->src_c_dec_h = 1;
+ _y4m->dst_c_dec_h = 2;
+ _y4m->src_c_dec_v = 1;
+ _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*Chroma filter required: read into the aux buf first.
We need to make two filter passes, so we need some extra space in the
aux buffer.
The extra plane also gets read into the aux buf.
It will be discarded.*/
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz=3*_y4m->pic_w*_y4m->pic_h;
- _y4m->convert=y4m_convert_444_420jpeg;
- }
- else if(strcmp(_y4m->chroma_type,"mono")==0){
- _y4m->src_c_dec_h=_y4m->src_c_dec_v=0;
- _y4m->dst_c_dec_h=_y4m->dst_c_dec_v=2;
- _y4m->dst_buf_read_sz=_y4m->pic_w*_y4m->pic_h;
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 3 * _y4m->pic_w * _y4m->pic_h;
+ _y4m->convert = y4m_convert_444_420jpeg;
+ } else if (strcmp(_y4m->chroma_type, "mono") == 0) {
+ _y4m->src_c_dec_h = _y4m->src_c_dec_v = 0;
+ _y4m->dst_c_dec_h = _y4m->dst_c_dec_v = 2;
+ _y4m->dst_buf_read_sz = _y4m->pic_w * _y4m->pic_h;
/*No extra space required, but we need to clear the chroma planes.*/
- _y4m->aux_buf_sz=_y4m->aux_buf_read_sz=0;
- _y4m->convert=y4m_convert_mono_420jpeg;
- }
- else{
- fprintf(stderr,"Unknown chroma sampling type: %s\n",_y4m->chroma_type);
+ _y4m->aux_buf_sz = _y4m->aux_buf_read_sz = 0;
+ _y4m->convert = y4m_convert_mono_420jpeg;
+ } else {
+ fprintf(stderr, "Unknown chroma sampling type: %s\n", _y4m->chroma_type);
return -1;
}
/*The size of the final frame buffers is always computed from the
destination chroma decimation type.*/
- _y4m->dst_buf_sz=_y4m->pic_w*_y4m->pic_h
- +2*((_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h)*
- ((_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v);
- _y4m->dst_buf=(unsigned char *)malloc(_y4m->dst_buf_sz);
- _y4m->aux_buf=(unsigned char *)malloc(_y4m->aux_buf_sz);
+ _y4m->dst_buf_sz = _y4m->pic_w * _y4m->pic_h
+ + 2 * ((_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h) *
+ ((_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v);
+ _y4m->dst_buf = (unsigned char *)malloc(_y4m->dst_buf_sz);
+ _y4m->aux_buf = (unsigned char *)malloc(_y4m->aux_buf_sz);
return 0;
}
-void y4m_input_close(y4m_input *_y4m){
+void y4m_input_close(y4m_input *_y4m) {
free(_y4m->dst_buf);
free(_y4m->aux_buf);
}
-int y4m_input_fetch_frame(y4m_input *_y4m,FILE *_fin,vpx_image_t *_img){
+int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *_img) {
char frame[6];
int pic_sz;
int c_w;
@@ -818,54 +815,54 @@ int y4m_input_fetch_frame(y4m_input *_y4m,FILE *_fin,vpx_image_t *_img){
int c_sz;
int ret;
/*Read and skip the frame header.*/
- ret=fread(frame,1,6,_fin);
- if(ret<6)return 0;
- if(memcmp(frame,"FRAME",5)){
- fprintf(stderr,"Loss of framing in Y4M input data\n");
+ ret = fread(frame, 1, 6, _fin);
+ if (ret < 6)return 0;
+ if (memcmp(frame, "FRAME", 5)) {
+ fprintf(stderr, "Loss of framing in Y4M input data\n");
return -1;
}
- if(frame[5]!='\n'){
+ if (frame[5] != '\n') {
char c;
int j;
- for(j=0;j<79&&fread(&c,1,1,_fin)&&c!='\n';j++);
- if(j==79){
- fprintf(stderr,"Error parsing Y4M frame header\n");
+ for (j = 0; j < 79 && fread(&c, 1, 1, _fin) && c != '\n'; j++);
+ if (j == 79) {
+ fprintf(stderr, "Error parsing Y4M frame header\n");
return -1;
}
}
/*Read the frame data that needs no conversion.*/
- if(fread(_y4m->dst_buf,1,_y4m->dst_buf_read_sz,_fin)!=_y4m->dst_buf_read_sz){
- fprintf(stderr,"Error reading Y4M frame data.\n");
+ if (fread(_y4m->dst_buf, 1, _y4m->dst_buf_read_sz, _fin) != _y4m->dst_buf_read_sz) {
+ fprintf(stderr, "Error reading Y4M frame data.\n");
return -1;
}
/*Read the frame data that does need conversion.*/
- if(fread(_y4m->aux_buf,1,_y4m->aux_buf_read_sz,_fin)!=_y4m->aux_buf_read_sz){
- fprintf(stderr,"Error reading Y4M frame data.\n");
+ if (fread(_y4m->aux_buf, 1, _y4m->aux_buf_read_sz, _fin) != _y4m->aux_buf_read_sz) {
+ fprintf(stderr, "Error reading Y4M frame data.\n");
return -1;
}
/*Now convert the just read frame.*/
- (*_y4m->convert)(_y4m,_y4m->dst_buf,_y4m->aux_buf);
+ (*_y4m->convert)(_y4m, _y4m->dst_buf, _y4m->aux_buf);
/*Fill in the frame buffer pointers.
We don't use vpx_img_wrap() because it forces padding for odd picture
sizes, which would require a separate fread call for every row.*/
- memset(_img,0,sizeof(*_img));
+ memset(_img, 0, sizeof(*_img));
/*Y4M has the planes in Y'CbCr order, which libvpx calls Y, U, and V.*/
- _img->fmt=IMG_FMT_I420;
- _img->w=_img->d_w=_y4m->pic_w;
- _img->h=_img->d_h=_y4m->pic_h;
+ _img->fmt = IMG_FMT_I420;
+ _img->w = _img->d_w = _y4m->pic_w;
+ _img->h = _img->d_h = _y4m->pic_h;
/*This is hard-coded to 4:2:0 for now, as that's all VP8 supports.*/
- _img->x_chroma_shift=1;
- _img->y_chroma_shift=1;
- _img->bps=12;
+ _img->x_chroma_shift = 1;
+ _img->y_chroma_shift = 1;
+ _img->bps = 12;
/*Set up the buffer pointers.*/
- pic_sz=_y4m->pic_w*_y4m->pic_h;
- c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h;
- c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v;
- c_sz=c_w*c_h;
- _img->stride[PLANE_Y]=_y4m->pic_w;
- _img->stride[PLANE_U]=_img->stride[PLANE_V]=c_w;
- _img->planes[PLANE_Y]=_y4m->dst_buf;
- _img->planes[PLANE_U]=_y4m->dst_buf+pic_sz;
- _img->planes[PLANE_V]=_y4m->dst_buf+pic_sz+c_sz;
+ pic_sz = _y4m->pic_w * _y4m->pic_h;
+ c_w = (_y4m->pic_w + _y4m->dst_c_dec_h - 1) / _y4m->dst_c_dec_h;
+ c_h = (_y4m->pic_h + _y4m->dst_c_dec_v - 1) / _y4m->dst_c_dec_v;
+ c_sz = c_w * c_h;
+ _img->stride[PLANE_Y] = _y4m->pic_w;
+ _img->stride[PLANE_U] = _img->stride[PLANE_V] = c_w;
+ _img->planes[PLANE_Y] = _y4m->dst_buf;
+ _img->planes[PLANE_U] = _y4m->dst_buf + pic_sz;
+ _img->planes[PLANE_V] = _y4m->dst_buf + pic_sz + c_sz;
return 1;
}
diff --git a/y4minput.h b/y4minput.h
index 1a01bcda7..2fa3767c9 100644
--- a/y4minput.h
+++ b/y4minput.h
@@ -23,11 +23,11 @@ typedef struct y4m_input y4m_input;
/*The function used to perform chroma conversion.*/
typedef void (*y4m_convert_func)(y4m_input *_y4m,
- unsigned char *_dst,unsigned char *_src);
+ unsigned char *_dst, unsigned char *_src);
-struct y4m_input{
+struct y4m_input {
int pic_w;
int pic_h;
int fps_n;
@@ -53,8 +53,8 @@ struct y4m_input{
unsigned char *aux_buf;
};
-int y4m_input_open(y4m_input *_y4m,FILE *_fin,char *_skip,int _nskip);
+int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip);
void y4m_input_close(y4m_input *_y4m);
-int y4m_input_fetch_frame(y4m_input *_y4m,FILE *_fin,vpx_image_t *img);
+int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *img);
#endif