Merge "respect alignment in arm asm files"
diff --git a/build/make/configure.sh b/build/make/configure.sh
index 66e0dbf..23cf443 100755
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -642,8 +642,8 @@
# on arm, isa versions are supersets
enabled armv7a && soft_enable armv7 ### DEBUG
enabled armv7 && soft_enable armv6
- enabled armv6 && soft_enable armv5te
- enabled armv6 && soft_enable fast_unaligned
+ enabled armv7 || enabled armv6 && soft_enable armv5te
+ enabled armv7 || enabled armv6 && soft_enable fast_unaligned
enabled iwmmxt2 && soft_enable iwmmxt
enabled iwmmxt && soft_enable armv5te
diff --git a/examples/decode_with_partial_drops.txt b/examples/decode_with_partial_drops.txt
index 30854d6..7b0d3d2 100644
--- a/examples/decode_with_partial_drops.txt
+++ b/examples/decode_with_partial_drops.txt
@@ -110,7 +110,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INIT
/* Initialize codec */
flags = VPX_CODEC_USE_ERROR_CONCEALMENT;
-res = vpx_codec_dec_init(&codec, interface, NULL, flags);
+res = vpx_codec_dec_init(&codec, interface, &dec_cfg, flags);
if(res)
die_codec(&codec, "Failed to initialize decoder");
@@ -123,11 +123,15 @@
parsed as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
-if(argc!=4 && argc != 5)
- die("Usage: %s <infile> <outfile> <N-M|N/M|L,S>\n", argv[0]);
+if(argc < 4 || argc > 6)
+ die("Usage: %s <infile> <outfile> [-t <num threads>] <N-M|N/M|L,S>\n",
+ argv[0]);
{
char *nptr;
- n = strtol(argv[3], &nptr, 0);
+ int arg_num = 3;
+ if (argc == 6 && strncmp(argv[arg_num++], "-t", 2) == 0)
+ dec_cfg.threads = strtol(argv[arg_num++], NULL, 0);
+ n = strtol(argv[arg_num], &nptr, 0);
mode = (*nptr == '\0' || *nptr == ',') ? 2 : (*nptr == '-') ? 1 : 0;
m = strtol(nptr+1, NULL, 0);
@@ -138,6 +142,7 @@
seed = (m > 0) ? m : (unsigned int)time(NULL);
srand(seed);thrown_frame = 0;
printf("Seed: %u\n", seed);
+printf("Threads: %d\n", dec_cfg.threads);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
@@ -181,6 +186,7 @@
unsigned int seed;
int thrown=0, kept=0;
int thrown_frame=0, kept_frame=0;
+vpx_codec_dec_cfg_t dec_cfg = {0};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS
diff --git a/libs.mk b/libs.mk
index c09581c..ae86fbd 100644
--- a/libs.mk
+++ b/libs.mk
@@ -198,7 +198,7 @@
$(qexec)echo "local: *; };" >> $@
CLEAN-OBJS += libvpx.ver
-$(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)):
+$(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)): $(DIST_DIR)/$(LIBSUBDIR)/$(LIBVPX_SO)
@echo " [LN] $@"
$(qexec)ln -sf $(LIBVPX_SO) $@
diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c
index 216590c..376707e 100644
--- a/vp8/common/alloccommon.c
+++ b/vp8/common/alloccommon.c
@@ -70,7 +70,7 @@
for (i = 0; i < NUM_YV12_BUFFERS; i++)
{
- oci->fb_idx_ref_cnt[0] = 0;
+ 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)
{
diff --git a/vp8/common/defaultcoefcounts.c b/vp8/common/defaultcoefcounts.c
new file mode 100644
index 0000000..ebb7816
--- /dev/null
+++ b/vp8/common/defaultcoefcounts.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "defaultcoefcounts.h"
+
+/* Generated file, included by entropy.c */
+
+const unsigned int vp8_default_coef_counts[BLOCK_TYPES]
+ [COEF_BANDS]
+ [PREV_COEF_CONTEXTS]
+ [vp8_coef_tokens] =
+{
+
+ {
+ /* 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,},
+ },
+ },
+};
diff --git a/vp8/common/defaultcoefcounts.h b/vp8/common/defaultcoefcounts.h
index ca58d56..ebe8d7a 100644
--- a/vp8/common/defaultcoefcounts.h
+++ b/vp8/common/defaultcoefcounts.h
@@ -8,214 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#ifndef __DEFAULTCOEFCOUNTS_H
+#define __DEFAULTCOEFCOUNTS_H
-/* Generated file, included by entropy.c */
+#include "entropy.h"
-static const unsigned int default_coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens] =
-{
+extern const unsigned int vp8_default_coef_counts[BLOCK_TYPES]
+ [COEF_BANDS]
+ [PREV_COEF_CONTEXTS]
+ [vp8_coef_tokens];
- {
- /* 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,},
- },
- },
-};
+#endif //__DEFAULTCOEFCOUNTS_H
diff --git a/vp8/common/entropy.c b/vp8/common/entropy.c
index a1fe4f4..b89ca92 100644
--- a/vp8/common/entropy.c
+++ b/vp8/common/entropy.c
@@ -148,7 +148,9 @@
unsigned int branch_ct [vp8_coef_tokens-1] [2];
vp8_tree_probs_from_distribution(
vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree,
- pc->fc.coef_probs [h][i][k], branch_ct, default_coef_counts [h][i][k],
+ pc->fc.coef_probs[h][i][k],
+ branch_ct,
+ vp8_default_coef_counts[h][i][k],
256, 1);
}
diff --git a/vp8/common/onyx.h b/vp8/common/onyx.h
index a059519..545798a 100644
--- a/vp8/common/onyx.h
+++ b/vp8/common/onyx.h
@@ -184,8 +184,11 @@
int token_partitions; // how many token partitions to create for multi core decoding
int encode_breakout; // early breakout encode threshold : for video conf recommend 800
- int error_resilient_mode; // if running over udp networks provides decodable frames after a
- // dropped packet
+ unsigned int error_resilient_mode; // Bitfield defining the error
+ // resiliency features to enable. Can provide
+ // decodable frames after losses in previous
+ // frames and decodable partitions after
+ // losses in the same frame.
int arnr_max_frames;
int arnr_strength ;
diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h
index 862307e..d366b9b 100644
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -35,6 +35,8 @@
#define NUM_YV12_BUFFERS 4
+#define MAX_PARTITIONS 9
+
typedef struct frame_contexts
{
vp8_prob bmode_prob [VP8_BINTRAMODES-1];
diff --git a/vp8/common/onyxd.h b/vp8/common/onyxd.h
index 140dc57..8a4703a 100644
--- a/vp8/common/onyxd.h
+++ b/vp8/common/onyxd.h
@@ -22,6 +22,7 @@
#include "vpx_scale/yv12config.h"
#include "ppflags.h"
#include "vpx_ports/mem.h"
+#include "vpx/vpx_codec.h"
typedef void *VP8D_PTR;
typedef struct
@@ -32,6 +33,7 @@
int postprocess;
int max_threads;
int error_concealment;
+ int input_partition;
} VP8D_CONFIG;
typedef enum
{
@@ -54,8 +56,8 @@
int vp8dx_receive_compressed_data(VP8D_PTR comp, unsigned long size, const unsigned char *dest, INT64 time_stamp);
int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, INT64 *time_stamp, INT64 *time_end_stamp, vp8_ppflags_t *flags);
- int vp8dx_get_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
- int vp8dx_set_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+ 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);
diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c
index 7dbe966..14c3b7b 100644
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -837,7 +837,6 @@
YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
int width = post->y_width;
int height = post->y_height;
- int mb_cols = width >> 4;
unsigned char *y_buffer = oci->post_proc_buffer.y_buffer;
int y_stride = oci->post_proc_buffer.y_stride;
MODE_INFO *mi = oci->mi;
@@ -861,7 +860,7 @@
{
case 0 : /* mv_top_bottom */
{
- B_MODE_INFO *bmi = &mi->bmi[0];
+ union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 8 + (mv->col >> 3);
@@ -882,7 +881,7 @@
}
case 1 : /* mv_left_right */
{
- B_MODE_INFO *bmi = &mi->bmi[0];
+ union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 4 + (mv->col >> 3);
@@ -903,7 +902,7 @@
}
case 2 : /* mv_quarters */
{
- B_MODE_INFO *bmi = &mi->bmi[0];
+ union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 4 + (mv->col >> 3);
@@ -939,7 +938,7 @@
}
default :
{
- B_MODE_INFO *bmi = mi->bmi;
+ union b_mode_info *bmi = mi->bmi;
int bx0, by0;
for (by0 = y0; by0 < (y0+16); by0 += 4)
@@ -1012,7 +1011,7 @@
{
int by, bx;
unsigned char *yl, *ul, *vl;
- B_MODE_INFO *bmi = mi->bmi;
+ union b_mode_info *bmi = mi->bmi;
yl = y_ptr + x;
ul = u_ptr + (x>>1);
@@ -1025,9 +1024,9 @@
if ((ppflags->display_b_modes_flag & (1<<mi->mbmi.mode))
|| (ppflags->display_mb_modes_flag & B_PRED))
{
- Y = B_PREDICTION_MODE_colors[bmi->mode][0];
- U = B_PREDICTION_MODE_colors[bmi->mode][1];
- V = B_PREDICTION_MODE_colors[bmi->mode][2];
+ Y = B_PREDICTION_MODE_colors[bmi->as_mode][0];
+ U = B_PREDICTION_MODE_colors[bmi->as_mode][1];
+ V = B_PREDICTION_MODE_colors[bmi->as_mode][2];
POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_b)
(yl+bx, ul+(bx>>1), vl+(bx>>1), Y, U, V, 0xc000, y_stride);
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index 734ab36..648fdb2 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -183,7 +183,8 @@
unsigned int mb_idx)
{
int eobtotal = 0;
- int i, do_clamp = xd->mode_info_context->mbmi.need_to_clamp_mvs;
+ MB_PREDICTION_MODE mode;
+ int i;
if (xd->mode_info_context->mbmi.mb_skip_coeff)
{
@@ -195,14 +196,14 @@
}
/* Perform temporary clamping of the MV to be used for prediction */
- if (do_clamp)
+ if (xd->mode_info_context->mbmi.need_to_clamp_mvs)
{
clamp_mvs(xd);
}
- eobtotal |= (xd->mode_info_context->mbmi.mode == B_PRED ||
- xd->mode_info_context->mbmi.mode == SPLITMV);
- if (!eobtotal)
+ mode = xd->mode_info_context->mbmi.mode;
+
+ if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV)
{
/* Special case: Force the loopfilter to skip when eobtotal and
* mb_skip_coeff are zero.
@@ -221,15 +222,12 @@
{
RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv)(xd);
- if (xd->mode_info_context->mbmi.mode != B_PRED)
+ if (mode != B_PRED)
{
RECON_INVOKE(&pbi->common.rtcd.recon,
build_intra_predictors_mby)(xd);
} else {
vp8_intra_prediction_down_copy(xd);
-
-
-
}
}
else
@@ -239,19 +237,51 @@
#if CONFIG_ERROR_CONCEALMENT
if (pbi->ec_enabled &&
- (mb_idx > pbi->mvs_corrupt_from_mb ||
+ (mb_idx >= pbi->mvs_corrupt_from_mb ||
vp8dx_bool_error(xd->current_bc)))
{
/* MB with corrupt residuals or corrupt mode/motion vectors.
* Better to use the predictor as reconstruction.
*/
+ vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
vp8_conceal_corrupt_mb(xd);
return;
}
#endif
/* dequantization and idct */
- if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV)
+ if (mode == B_PRED)
+ {
+ for (i = 0; i < 16; i++)
+ {
+ BLOCKD *b = &xd->block[i];
+ RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict)
+ (b, b->bmi.as_mode, b->predictor);
+
+ 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);
+ }
+ else
{
BLOCKD *b = &xd->block[24];
@@ -281,38 +311,6 @@
xd->predictor, xd->dst.y_buffer,
xd->dst.y_stride, xd->eobs, xd->block[24].diff);
}
- else if (xd->mode_info_context->mbmi.mode == B_PRED)
- {
- for (i = 0; i < 16; i++)
- {
-
- BLOCKD *b = &xd->block[i];
- RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict)
- (b, b->bmi.as_mode, b->predictor);
-
- 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
- {
- 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);
- }
DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block)
(xd->qcoeff+16*16, xd->block[16].dequant,
@@ -462,6 +460,40 @@
return size;
}
+static void setup_token_decoder_partition_input(VP8D_COMP *pbi)
+{
+ vp8_reader *bool_decoder = &pbi->bc2;
+ int part_idx = 1;
+
+ TOKEN_PARTITION multi_token_partition =
+ (TOKEN_PARTITION)vp8_read_literal(&pbi->bc, 2);
+ assert(vp8dx_bool_error(&pbi->bc) ||
+ multi_token_partition == pbi->common.multi_token_partition);
+ if (pbi->num_partitions > 2)
+ {
+ CHECK_MEM_ERROR(pbi->mbc, vpx_malloc((pbi->num_partitions - 1) *
+ sizeof(vp8_reader)));
+ bool_decoder = pbi->mbc;
+ }
+
+ for (; part_idx < pbi->num_partitions; ++part_idx)
+ {
+ if (vp8dx_start_decode(bool_decoder,
+ pbi->partitions[part_idx],
+ pbi->partition_sizes[part_idx]))
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate bool decoder %d",
+ part_idx);
+
+ bool_decoder++;
+ }
+
+#if CONFIG_MULTITHREAD
+ /* Clamp number of decoder threads */
+ if (pbi->decoding_thread_count > pbi->num_partitions - 1)
+ pbi->decoding_thread_count = pbi->num_partitions - 1;
+#endif
+}
static void setup_token_decoder(VP8D_COMP *pbi,
const unsigned char *cx_data)
@@ -474,7 +506,13 @@
const unsigned char *partition;
/* Parse number of token partitions to use */
- pc->multi_token_partition = (TOKEN_PARTITION)vp8_read_literal(&pbi->bc, 2);
+ const TOKEN_PARTITION multi_token_partition =
+ (TOKEN_PARTITION)vp8_read_literal(&pbi->bc, 2);
+ /* Only update the multi_token_partition field if we are sure the value
+ * is correct. */
+ if (!pbi->ec_enabled || !vp8dx_bool_error(&pbi->bc))
+ pc->multi_token_partition = multi_token_partition;
+
num_part = 1 << pc->multi_token_partition;
/* Set up pointers to the first partition */
@@ -612,13 +650,19 @@
VP8_COMMON *const pc = & pbi->common;
MACROBLOCKD *const xd = & pbi->mb;
const unsigned char *data = (const unsigned char *)pbi->Source;
- const unsigned char *const data_end = data + pbi->source_sz;
+ const unsigned char *data_end = data + pbi->source_sz;
ptrdiff_t first_partition_length_in_bytes;
int mb_row;
int i, j, k, l;
const int *const mb_feature_data_bits = vp8_mb_feature_data_bits;
+ if (pbi->input_partition)
+ {
+ data = pbi->partitions[0];
+ data_end = data + pbi->partition_sizes[0];
+ }
+
/* start with no corruption of current frame */
xd->corrupted = 0;
pc->yv12_fb[pc->new_fb_idx].corrupted = 0;
@@ -834,7 +878,14 @@
}
}
- setup_token_decoder(pbi, data + first_partition_length_in_bytes);
+ if (pbi->input_partition)
+ {
+ setup_token_decoder_partition_input(pbi);
+ }
+ else
+ {
+ setup_token_decoder(pbi, data + first_partition_length_in_bytes);
+ }
xd->current_bc = &pbi->bc2;
/* Read the default quantizers. */
@@ -923,10 +974,8 @@
fclose(z);
}
-
{
/* read coef probability tree */
-
for (i = 0; i < BLOCK_TYPES; i++)
for (j = 0; j < COEF_BANDS; j++)
for (k = 0; k < PREV_COEF_CONTEXTS; k++)
@@ -1014,7 +1063,6 @@
}
}
-
stop_token_decoder(pbi);
/* Collect information about decoder corruption. */
diff --git a/vp8/decoder/error_concealment.c b/vp8/decoder/error_concealment.c
index c06bdcf..4f8f1a6 100644
--- a/vp8/decoder/error_concealment.c
+++ b/vp8/decoder/error_concealment.c
@@ -382,6 +382,7 @@
mi->mbmi.mode = SPLITMV;
mi->mbmi.uv_mode = DC_PRED;
mi->mbmi.partitioning = 3;
+ mi->mbmi.segment_id = 0;
estimate_mb_mvs(block_overlaps,
mi,
mb_to_left_edge,
@@ -563,6 +564,12 @@
mb->mb_to_top_edge,
mb->mb_to_bottom_edge);
}
+ else
+ {
+ mv->as_int = 0;
+ mi->bmi[row*4 + col].as_mode = NEW4X4;
+ mi->mbmi.need_to_clamp_mvs = 0;
+ }
}
}
}
@@ -597,6 +604,7 @@
mb->mode_info_context->mbmi.mode = SPLITMV;
mb->mode_info_context->mbmi.uv_mode = DC_PRED;
mb->mode_info_context->mbmi.partitioning = 3;
+ mb->mode_info_context->mbmi.segment_id = 0;
}
void vp8_conceal_corrupt_mb(MACROBLOCKD *xd)
diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c
index 4845cd0..5f81ee6 100644
--- a/vp8/decoder/onyxd_if.c
+++ b/vp8/decoder/onyxd_if.c
@@ -109,6 +109,8 @@
pbi->ec_enabled = 0;
#endif
+ pbi->input_partition = oxcf->input_partition;
+
return (VP8D_PTR) pbi;
}
@@ -134,7 +136,7 @@
}
-int vp8dx_get_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
+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;
@@ -146,16 +148,27 @@
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
- return -1;
+ vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
- vp8_yv12_copy_frame_ptr(&cm->yv12_fb[ref_fb_idx], sd);
-
- return 0;
+ return pbi->common.error.error_code;
}
-int vp8dx_set_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
+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;
@@ -168,20 +181,32 @@
ref_fb_ptr = &cm->gld_fb_idx;
else if (ref_frame_flag == VP8_ALT_FLAG)
ref_fb_ptr = &cm->alt_fb_idx;
- else
- return -1;
+ else{
+ vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
+ "Invalid reference frame");
+ return pbi->common.error.error_code;
+ }
- /* 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]--;
+ 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]);
+ /* 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 0;
+ return pbi->common.error.error_code;
}
/*For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us.*/
@@ -289,69 +314,92 @@
pbi->common.error.error_code = VPX_CODEC_OK;
- if (size == 0)
+ if (pbi->input_partition && !(source == NULL && size == 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 error concealment is disabled we won't signal missing frames to
- * the decoder.
+ /* Store a pointer to this partition and return. We haven't
+ * received the complete frame yet, so we will wait with decoding.
*/
- if (!pbi->ec_enabled)
+ pbi->partitions[pbi->num_partitions] = source;
+ pbi->partition_sizes[pbi->num_partitions] = size;
+ pbi->source_sz += size;
+ pbi->num_partitions++;
+ if (pbi->num_partitions > (1<<pbi->common.multi_token_partition) + 1)
+ pbi->common.multi_token_partition++;
+ if (pbi->common.multi_token_partition > EIGHT_PARTITION)
{
- /* Signal that we have no frame to show. */
- cm->show_frame = 0;
-
- /* Nothing more to do. */
- return 0;
+ pbi->common.error.error_code = VPX_CODEC_UNSUP_BITSTREAM;
+ pbi->common.error.setjmp = 0;
+ return -1;
}
+ return 0;
}
-
-
-#if HAVE_ARMV7
-#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
+ else
{
- vp8_push_neon(dx_store_reg);
- }
-#endif
+ if (!pbi->input_partition)
+ {
+ pbi->Source = source;
+ pbi->source_sz = size;
+ }
- cm->new_fb_idx = get_free_fb (cm);
+ 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 (setjmp(pbi->common.error.jmp))
- {
+ /* If error concealment is disabled we won't signal missing frames to
+ * the decoder.
+ */
+ if (!pbi->ec_enabled)
+ {
+ /* Signal that we have no frame to show. */
+ cm->show_frame = 0;
+
+ /* Nothing more to do. */
+ return 0;
+ }
+ }
+
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
if (cm->rtcd.flags & HAS_NEON)
#endif
{
- vp8_pop_neon(dx_store_reg);
+ vp8_push_neon(dx_store_reg);
}
#endif
- 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;
+ cm->new_fb_idx = get_free_fb (cm);
- if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
- cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
- return -1;
+ if (setjmp(pbi->common.error.jmp))
+ {
+#if HAVE_ARMV7
+#if CONFIG_RUNTIME_CPU_DETECT
+ if (cm->rtcd.flags & HAS_NEON)
+#endif
+ {
+ vp8_pop_neon(dx_store_reg);
+ }
+#endif
+ 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;
+
+ 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;
-
- /*cm->current_video_frame++;*/
- pbi->Source = source;
- pbi->source_sz = size;
-
retcode = vp8_decode_frame(pbi);
if (retcode < 0)
@@ -450,6 +498,10 @@
pbi->ready_for_new_data = 0;
pbi->last_time_stamp = time_stamp;
+ pbi->num_partitions = 0;
+ if (pbi->input_partition)
+ pbi->common.multi_token_partition = 0;
+ pbi->source_sz = 0;
#if 0
{
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index ea6de3d..be6ffe6 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -83,6 +83,9 @@
const unsigned char *Source;
unsigned int source_sz;
+ const unsigned char *partitions[MAX_PARTITIONS];
+ unsigned int partition_sizes[MAX_PARTITIONS];
+ unsigned int num_partitions;
#if CONFIG_MULTITHREAD
/* variable for threading */
@@ -137,6 +140,7 @@
unsigned int mvs_corrupt_from_mb;
#endif
int ec_enabled;
+ int input_partition;
} VP8D_COMP;
diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c
index c1df823..a7af9ac 100644
--- a/vp8/decoder/threading.c
+++ b/vp8/decoder/threading.c
@@ -22,6 +22,9 @@
#include "detokenize.h"
#include "vp8/common/reconinter.h"
#include "reconintra_mt.h"
+#if CONFIG_ERROR_CONCEALMENT
+#include "error_concealment.h"
+#endif
extern void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd);
extern void clamp_mvs(MACROBLOCKD *xd);
@@ -151,6 +154,20 @@
vp8_build_inter_predictors_mb(xd);
}
+#if CONFIG_ERROR_CONCEALMENT
+ if (pbi->ec_enabled &&
+ (mb_row * pbi->common.mb_cols + mb_col >= pbi->mvs_corrupt_from_mb ||
+ vp8dx_bool_error(xd->current_bc)))
+ {
+ /* MB with corrupt residuals or corrupt mode/motion vectors.
+ * Better to use the predictor as reconstruction.
+ */
+ vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
+ vp8_conceal_corrupt_mb(xd);
+ return;
+ }
+#endif
+
/* dequantization and idct */
if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV)
{
@@ -291,12 +308,37 @@
update_blockd_bmi(xd);
- /* 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
+ /* 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_left_edge = -((mb_col * 16) << 3);
xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
+#if CONFIG_ERROR_CONCEALMENT
+ if (pbi->ec_enabled &&
+ (xd->mode_info_context->mbmi.ref_frame ==
+ INTRA_FRAME) &&
+ vp8dx_bool_error(xd->current_bc))
+ {
+ /* We have an intra block with corrupt coefficients,
+ * better to conceal with an inter block.
+ * Interpolate MVs from neighboring MBs
+ *
+ * Note that for the first mb with corrupt residual
+ * in a frame, we might not discover that before
+ * decoding the residual. That happens after this
+ * check, and therefore no inter concealment will be
+ * done.
+ */
+ vp8_interpolate_motion(xd,
+ mb_row, mb_col,
+ pc->mb_rows, pc->mb_cols,
+ pc->mode_info_stride);
+ }
+#endif
+
+
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;
@@ -772,12 +814,35 @@
update_blockd_bmi(xd);
- /* 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
+ /* 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_left_edge = -((mb_col * 16) << 3);
xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
+#if CONFIG_ERROR_CONCEALMENT
+ if (pbi->ec_enabled &&
+ (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) &&
+ vp8dx_bool_error(xd->current_bc))
+ {
+ /* We have an intra block with corrupt coefficients, better
+ * to conceal with an inter block. Interpolate MVs from
+ * neighboring MBs
+ *
+ * Note that for the first mb with corrupt residual in a
+ * frame, we might not discover that before decoding the
+ * residual. That happens after this check, and therefore no
+ * inter concealment will be done.
+ */
+ vp8_interpolate_motion(xd,
+ mb_row, mb_col,
+ pc->mb_rows, pc->mb_cols,
+ pc->mode_info_stride);
+ }
+#endif
+
+
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;
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index e93d30d..ac29812 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -17,9 +17,12 @@
#include "vp8/common/systemdependent.h"
#include <assert.h>
#include <stdio.h>
+#include <limits.h>
#include "vp8/common/pragmas.h"
+#include "vpx/vpx_encoder.h"
#include "vpx_mem/vpx_mem.h"
#include "bitstream.h"
+#include "vp8/common/defaultcoefcounts.h"
const int vp8cx_base_skip_false_prob[128] =
{
@@ -374,6 +377,7 @@
unsigned int shift;
vp8_writer *w = &cpi->bc2;
*size = 3 * (num_part - 1);
+ cpi->partition_sz[0] += *size;
ptr = cx_data + (*size);
for (i = 0; i < num_part; i++)
@@ -570,6 +574,9 @@
vp8_stop_encode(w);
*size += w->pos;
+ /* The first partition size is set earlier */
+ cpi->partition_sz[i + 1] = w->pos;
+
if (i < (num_part - 1))
{
write_partition_size(cx_data, w->pos);
@@ -1123,9 +1130,201 @@
m++; // skip L prediction border
}
}
+
+/* This function is used for debugging probability trees. */
+static void print_prob_tree(vp8_prob
+ coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][vp8_coef_tokens-1])
+{
+ /* 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 < MAX_ENTROPY_TOKENS - 1; 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);
+}
+
+static void sum_probs_over_prev_coef_context(
+ const unsigned int probs[PREV_COEF_CONTEXTS][vp8_coef_tokens],
+ unsigned int* out)
+{
+ int i, j;
+ for (i=0; i < vp8_coef_tokens; ++i)
+ {
+ for (j=0; j < PREV_COEF_CONTEXTS; ++j)
+ {
+ const int tmp = out[i];
+ out[i] += probs[j][i];
+ /* check for wrap */
+ if (out[i] < tmp)
+ out[i] = UINT_MAX;
+ }
+ }
+}
+
+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_branch(ct, oldp);
+ const int new_b = vp8_cost_branch(ct, newp);
+ const int update_b = 8 +
+ ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
+
+ return old_b - new_b - update_b;
+}
+
+static int independent_coef_context_savings(VP8_COMP *cpi)
+{
+ int savings = 0;
+ int i = 0;
+ do
+ {
+ int j = 0;
+ do
+ {
+ int k = 0;
+ unsigned int prev_coef_count_sum[vp8_coef_tokens] = {0};
+ int prev_coef_savings[vp8_coef_tokens] = {0};
+ /* Calculate new probabilities given the constraint that
+ * they must be equal over the prev coef contexts
+ */
+ if (cpi->common.frame_type == KEY_FRAME)
+ {
+ /* Reset to default probabilities at key frames */
+ sum_probs_over_prev_coef_context(vp8_default_coef_counts[i][j],
+ prev_coef_count_sum);
+ }
+ else
+ {
+ sum_probs_over_prev_coef_context(cpi->coef_counts[i][j],
+ prev_coef_count_sum);
+ }
+ do
+ {
+ /* at every context */
+
+ /* calc probs and branch cts for this frame only */
+ //vp8_prob new_p [vp8_coef_tokens-1];
+ //unsigned int branch_ct [vp8_coef_tokens-1] [2];
+
+ int t = 0; /* token/prob index */
+
+ vp8_tree_probs_from_distribution(
+ vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree,
+ cpi->frame_coef_probs[i][j][k],
+ cpi->frame_branch_ct [i][j][k],
+ prev_coef_count_sum,
+ 256, 1);
+
+ do
+ {
+ const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
+ const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t];
+ const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
+ const int s = prob_update_savings(ct, oldp, newp, upd);
+
+ if (cpi->common.frame_type != KEY_FRAME ||
+ (cpi->common.frame_type == KEY_FRAME && newp != oldp))
+ prev_coef_savings[t] += s;
+ }
+ while (++t < vp8_coef_tokens - 1);
+ }
+ while (++k < PREV_COEF_CONTEXTS);
+ k = 0;
+ do
+ {
+ /* We only update probabilities if we can save bits, except
+ * for key frames where we have to update all probabilities
+ * to get the equal probabilities across the prev coef
+ * contexts.
+ */
+ if (prev_coef_savings[k] > 0 ||
+ cpi->common.frame_type == KEY_FRAME)
+ savings += prev_coef_savings[k];
+ }
+ while (++k < vp8_coef_tokens - 1);
+ }
+ while (++j < COEF_BANDS);
+ }
+ while (++i < BLOCK_TYPES);
+ return savings;
+}
+
+static int default_coef_context_savings(VP8_COMP *cpi)
+{
+ int savings = 0;
+ int i = 0;
+ do
+ {
+ int j = 0;
+ do
+ {
+ int k = 0;
+ do
+ {
+ /* at every context */
+
+ /* calc probs and branch cts for this frame only */
+ //vp8_prob new_p [vp8_coef_tokens-1];
+ //unsigned int branch_ct [vp8_coef_tokens-1] [2];
+
+ int t = 0; /* token/prob index */
+
+
+ vp8_tree_probs_from_distribution(
+ vp8_coef_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
+ );
+
+ do
+ {
+ const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
+ const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
+ const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t];
+ const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
+ const int s = prob_update_savings(ct, oldp, newp, upd);
+
+ if (s > 0)
+ {
+ savings += s;
+ }
+ }
+ while (++t < vp8_coef_tokens - 1);
+ }
+ while (++k < PREV_COEF_CONTEXTS);
+ }
+ while (++j < COEF_BANDS);
+ }
+ while (++i < BLOCK_TYPES);
+ return savings;
+}
+
int vp8_estimate_entropy_savings(VP8_COMP *cpi)
{
- int i = 0;
int savings = 0;
const int *const rfct = cpi->count_mb_ref_frame_usage;
@@ -1185,60 +1384,11 @@
}
- do
- {
- int j = 0;
+ if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
+ savings += independent_coef_context_savings(cpi);
+ else
+ savings += default_coef_context_savings(cpi);
- do
- {
- int k = 0;
-
- do
- {
- /* at every context */
-
- /* calc probs and branch cts for this frame only */
- //vp8_prob new_p [vp8_coef_tokens-1];
- //unsigned int branch_ct [vp8_coef_tokens-1] [2];
-
- int t = 0; /* token/prob index */
-
- vp8_tree_probs_from_distribution(
- vp8_coef_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
- );
-
- do
- {
- const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
- const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
-
- const vp8_prob old = cpi->common.fc.coef_probs [i][j][k][t];
- const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
-
- const int old_b = vp8_cost_branch(ct, old);
- const int new_b = vp8_cost_branch(ct, newp);
-
- const int update_b = 8 +
- ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
-
- const int s = old_b - new_b - update_b;
-
- if (s > 0)
- savings += s;
-
-
- }
- while (++t < vp8_coef_tokens - 1);
-
-
- }
- while (++k < PREV_COEF_CONTEXTS);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES);
return savings;
}
@@ -1251,7 +1401,6 @@
vp8_clear_system_state(); //__asm emms;
-
do
{
int j = 0;
@@ -1259,7 +1408,27 @@
do
{
int k = 0;
+ int prev_coef_savings[vp8_coef_tokens - 1] = {0};
+ if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
+ {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
+ {
+ int t; /* token/prob index */
+ for (t = 0; t < vp8_coef_tokens - 1; ++t)
+ {
+ const unsigned int *ct = cpi->frame_branch_ct [i][j]
+ [k][t];
+ const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t];
+ const vp8_prob oldp = cpi->common.fc.coef_probs[i][j]
+ [k][t];
+ const vp8_prob upd = vp8_coef_update_probs[i][j][k][t];
+ prev_coef_savings[t] +=
+ prob_update_savings(ct, oldp, newp, upd);
+ }
+ }
+ k = 0;
+ }
do
{
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
@@ -1279,21 +1448,33 @@
do
{
- const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
const 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 old = *Pold;
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
- const int old_b = vp8_cost_branch(ct, old);
- const int new_b = vp8_cost_branch(ct, newp);
+ int s = prev_coef_savings[t];
+ int u = 0;
- const int update_b = 8 +
- ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
+ if (!(cpi->oxcf.error_resilient_mode &
+ VPX_ERROR_RESILIENT_PARTITIONS))
+ {
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, newp, upd);
+ }
- const int s = old_b - new_b - update_b;
- const int u = s > 0 ? 1 : 0;
+ if (s > 0)
+ u = 1;
+
+ /* Force updates on key frames if the new is different,
+ * so that we can be sure we end up with equal probabilities
+ * over the prev coef contexts.
+ */
+ if ((cpi->oxcf.error_resilient_mode &
+ VPX_ERROR_RESILIENT_PARTITIONS) &&
+ cpi->common.frame_type == KEY_FRAME && newp != *Pold)
+ u = 1;
vp8_write(w, u, upd);
@@ -1590,6 +1771,14 @@
vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
}
+ if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
+ {
+ if (pc->frame_type == KEY_FRAME)
+ pc->refresh_entropy_probs = 1;
+ else
+ pc->refresh_entropy_probs = 0;
+ }
+
vp8_write_bit(bc, pc->refresh_entropy_probs);
if (pc->frame_type != KEY_FRAME)
@@ -1655,6 +1844,7 @@
}
*size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos;
+ cpi->partition_sz[0] = *size;
if (pc->multi_token_partition != ONE_PARTITION)
{
@@ -1680,6 +1870,7 @@
vp8_stop_encode(&cpi->bc2);
*size += cpi->bc2.pos;
+ cpi->partition_sz[1] = cpi->bc2.pos;
}
}
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index a045760..71e285f 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -214,11 +214,25 @@
int max_bits;
// For CBR we need to also consider buffer fullness.
+ // If we are running below the optimal level then we need to gradually tighten up on max_bits.
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
- max_bits = 2 * cpi->av_per_frame_bandwidth;
- max_bits -= cpi->buffered_av_per_frame_bandwidth;
- max_bits *= ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0);
+ double buffer_fullness_ratio = (double)cpi->buffer_level / DOUBLE_DIVIDE_CHECK((double)cpi->oxcf.optimal_buffer_level);
+
+ // For CBR base this on the target average bits per frame plus the maximum sedction rate passed in by the user
+ max_bits = (int)(cpi->av_per_frame_bandwidth * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
+
+ // If our buffer is below the optimum level
+ if (buffer_fullness_ratio < 1.0)
+ {
+ // The lower of max_bits / 4 or cpi->av_per_frame_bandwidth / 4.
+ int min_max_bits = ((cpi->av_per_frame_bandwidth >> 2) < (max_bits >> 2)) ? cpi->av_per_frame_bandwidth >> 2 : max_bits >> 2;
+
+ max_bits = (int)(max_bits * buffer_fullness_ratio);
+
+ if (max_bits < min_max_bits)
+ max_bits = min_max_bits; // Lowest value we will set ... which should allow the buffer to refil.
+ }
}
// VBR
else
@@ -235,45 +249,6 @@
}
-static int gf_group_max_bits(VP8_COMP *cpi)
-{
- // Max allocation for a golden frame group
- int max_bits;
-
- // For CBR we need to also consider buffer fullness.
- if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
- {
- max_bits = cpi->av_per_frame_bandwidth * cpi->baseline_gf_interval;
- if (max_bits > cpi->oxcf.optimal_buffer_level)
- {
- max_bits -= cpi->oxcf.optimal_buffer_level;
- max_bits += cpi->buffer_level;
- }
- else
- {
- max_bits -= (cpi->buffered_av_per_frame_bandwidth
- - cpi->av_per_frame_bandwidth)
- * cpi->baseline_gf_interval;
- }
-
- max_bits *= ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0);
- }
- else
- {
- // 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));
- max_bits *= cpi->baseline_gf_interval;
- }
-
-
- // Trap case where we are out of bits
- if (max_bits < 0)
- max_bits = 0;
-
- return max_bits;
-}
-
-
static void output_stats(const VP8_COMP *cpi,
struct vpx_codec_pkt_list *pktlist,
FIRSTPASS_STATS *stats)
@@ -1358,7 +1333,7 @@
double abs_mv_in_out_accumulator = 0.0;
double mod_err_per_mb_accumulator = 0.0;
- int max_group_bits;
+ 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;
@@ -1711,9 +1686,8 @@
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)
- max_group_bits = gf_group_max_bits(cpi);
- if (cpi->twopass.gf_group_bits > max_group_bits)
- cpi->twopass.gf_group_bits = max_group_bits;
+ 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);
@@ -1808,6 +1782,13 @@
}
}
+ // Apply an additional limit for CBR
+ if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
+ {
+ if (cpi->twopass.gf_bits > (cpi->buffer_level >> 1))
+ cpi->twopass.gf_bits = cpi->buffer_level >> 1;
+ }
+
// Dont allow a negative value for gf_bits
if (gf_bits < 0)
gf_bits = 0;
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index bebc941..a6d7a43 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -1477,7 +1477,6 @@
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->buffered_av_per_frame_bandwidth = cpi->av_per_frame_bandwidth;
cpi->total_actual_bits = 0;
cpi->total_target_vs_actual = 0;
@@ -1573,7 +1572,7 @@
break;
}
- if (cpi->pass == 0 && cpi->oxcf.end_usage != USAGE_STREAM_FROM_SERVER)
+ if (cpi->pass == 0)
cpi->auto_worst_q = 1;
cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q];
@@ -3454,8 +3453,7 @@
// For CBR if the buffer reaches its maximum level then we can no longer
// save up bits for later frames so we might as well use them up
// on the current frame.
- if (cpi->pass == 2
- && (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
+ if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
(cpi->buffer_level >= cpi->oxcf.optimal_buffer_level) && cpi->buffered_mode)
{
int Adjustment = cpi->active_worst_quality / 4; // Max adjustment is 1/4
@@ -3546,9 +3544,6 @@
}
else
{
- if(cpi->pass != 2)
- Q = cpi->avg_frame_qindex;
-
cpi->active_best_quality = inter_minq[Q];
// For the constant/constrained quality mode we dont want
@@ -3850,16 +3845,15 @@
(cpi->active_worst_quality < cpi->worst_quality) &&
(cpi->projected_frame_size > frame_over_shoot_limit))
{
- /* step down active_worst_quality such that the corresponding
- * active_best_quality will be equal to the current
- * active_worst_quality + 1
- */
- int i;
+ int over_size_percent = ((cpi->projected_frame_size - frame_over_shoot_limit) * 100) / frame_over_shoot_limit;
- for(i=cpi->active_worst_quality; i<cpi->worst_quality; i++)
- if(inter_minq[i] >= cpi->active_worst_quality + 1)
- break;
- cpi->active_worst_quality = i;
+ // If so is there any scope for relaxing it
+ while ((cpi->active_worst_quality < cpi->worst_quality) && (over_size_percent > 0))
+ {
+ cpi->active_worst_quality++;
+ top_index = cpi->active_worst_quality;
+ over_size_percent = (int)(over_size_percent * 0.96); // Assume 1 qstep = about 4% on frame size.
+ }
// If we have updated the active max Q do not call vp8_update_rate_correction_factors() this loop.
active_worst_qchanged = TRUE;
@@ -4138,7 +4132,7 @@
update_reference_frames(cm);
- if (cpi->oxcf.error_resilient_mode == 1)
+ if (cpi->oxcf.error_resilient_mode)
{
cm->refresh_entropy_probs = 0;
}
@@ -4247,9 +4241,10 @@
// 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->av_per_frame_bandwidth;
- cpi->bits_off_target -= cpi->projected_frame_size;
+ 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;
// 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;
@@ -4263,33 +4258,7 @@
// Debug stats
cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_frame_size);
- // Update the buffered average bitrate
- {
- long long numerator;
-
- numerator = cpi->oxcf.maximum_buffer_size
- - cpi->buffered_av_per_frame_bandwidth
- + cpi->projected_frame_size;
- numerator *= cpi->buffered_av_per_frame_bandwidth;
- cpi->buffered_av_per_frame_bandwidth = numerator
- / cpi->oxcf.maximum_buffer_size;
- }
-
- {
- long long tmp = (long long)cpi->buffered_av_per_frame_bandwidth
- * cpi->oxcf.maximum_buffer_size
- / cpi->av_per_frame_bandwidth;
- cpi->buffer_level = cpi->oxcf.maximum_buffer_size
- - tmp
- + cpi->oxcf.optimal_buffer_level;
- }
-
- // Accumulate overshoot error.
- cpi->accumulated_overshoot +=
- (cpi->projected_frame_size > cpi->av_per_frame_bandwidth)
- ? cpi->projected_frame_size - cpi->av_per_frame_bandwidth
- : 0;
-
+ 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)
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index c460b9d..d94436b 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -351,10 +351,6 @@
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 buffered_av_per_frame_bandwidth; // Average bitrate over the last buffer
- int buffered_av_per_frame_bandwidth_rem; // Average bitrate remainder
- int accumulated_overshoot; // Accumulated # of bits spent > target
-
int inter_frame_target;
double output_frame_rate;
long long last_time_stamp_seen;
@@ -505,6 +501,7 @@
#endif
TOKENLIST *tplist;
+ unsigned int partition_sz[MAX_PARTITIONS];
// end of multithread data
@@ -608,6 +605,8 @@
unsigned char *gf_active_flags;
int gf_active_count;
+ int output_partition;
+
//Store last frame's MV info for next frame MV prediction
int_mv *lfmv;
int *lf_ref_frame_sign_bias;
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index 73e1437..54c394d 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -605,10 +605,10 @@
static void calc_pframe_target_size(VP8_COMP *cpi)
{
- int min_frame_target, max_frame_target;
+ int min_frame_target;
int Adjustment;
- min_frame_target = 1;
+ min_frame_target = 0;
if (cpi->pass == 2)
{
@@ -616,19 +616,10 @@
if (min_frame_target < (cpi->av_per_frame_bandwidth >> 5))
min_frame_target = cpi->av_per_frame_bandwidth >> 5;
-
- max_frame_target = INT_MAX;
}
- else
- {
- if (min_frame_target < cpi->per_frame_bandwidth / 4)
- min_frame_target = cpi->per_frame_bandwidth / 4;
+ else if (min_frame_target < cpi->per_frame_bandwidth / 4)
+ min_frame_target = cpi->per_frame_bandwidth / 4;
- /* Don't allow the target to completely deplete the buffer. */
- max_frame_target = cpi->buffer_level + cpi->av_per_frame_bandwidth;
- if(max_frame_target < min_frame_target)
- max_frame_target = min_frame_target;
- }
// Special alt reference frame case
if (cpi->common.refresh_alt_ref_frame)
@@ -1121,32 +1112,6 @@
}
}
-
- if (cpi->pass==0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER){
- /* determine the accumulated error to apply to this frame. Apply
- * more of the error when we've been undershooting, less when
- * we've been overshooting
- */
- long long adjust;
- int bitrate_error;
-
- bitrate_error = cpi->av_per_frame_bandwidth
- - cpi->buffered_av_per_frame_bandwidth;
-
- adjust = cpi->accumulated_overshoot;
- adjust *= cpi->av_per_frame_bandwidth + bitrate_error;
- adjust /= cpi->oxcf.maximum_buffer_size;
- if (adjust > (cpi->this_frame_target - min_frame_target))
- adjust = (cpi->this_frame_target - min_frame_target);
- else if (adjust < 0)
- adjust = 0;
-
- cpi->this_frame_target -= adjust;
- cpi->accumulated_overshoot -= adjust;
- }
-
- if(cpi->this_frame_target > max_frame_target)
- cpi->this_frame_target = max_frame_target;
}
diff --git a/vp8/vp8_common.mk b/vp8/vp8_common.mk
index 5f5ba3a..f55c899 100644
--- a/vp8/vp8_common.mk
+++ b/vp8/vp8_common.mk
@@ -19,6 +19,7 @@
VP8_COMMON_SRCS-yes += common/coefupdateprobs.h
VP8_COMMON_SRCS-yes += common/debugmodes.c
VP8_COMMON_SRCS-yes += common/defaultcoefcounts.h
+VP8_COMMON_SRCS-yes += common/defaultcoefcounts.c
VP8_COMMON_SRCS-yes += common/entropy.c
VP8_COMMON_SRCS-yes += common/entropymode.c
VP8_COMMON_SRCS-yes += common/entropymv.c
@@ -99,15 +100,15 @@
VP8_COMMON_SRCS-$(HAVE_SSE2) += common/x86/postproc_sse2.asm
endif
+# common (c)
VP8_COMMON_SRCS-$(ARCH_ARM) += common/asm_com_offsets.c
VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/arm_systemdependent.c
-# common (c)
-VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/bilinearfilter_arm.c
-VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/bilinearfilter_arm.h
-VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/filter_arm.c
-VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/loopfilter_arm.c
-VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/reconintra_arm.c
+VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/bilinearfilter_arm.c
+VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/bilinearfilter_arm.h
+VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/filter_arm.c
+VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/loopfilter_arm.c
+VP8_COMMON_SRCS-$(ARCH_ARM) += common/arm/reconintra_arm.c
# common (armv6)
VP8_COMMON_SRCS-$(HAVE_ARMV6) += common/arm/armv6/bilinearfilter_v6$(ASM)
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c
index db60bfe..5e1278a 100644
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -731,6 +731,9 @@
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;
+
/* Convert API flags to internal codec lib flags */
lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
@@ -770,8 +773,6 @@
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.buf = cx_data;
- pkt.data.frame.sz = size;
pkt.data.frame.pts =
(dst_time_stamp * ctx->cfg.g_timebase.den + round)
/ ctx->cfg.g_timebase.num / 10000000;
@@ -797,11 +798,35 @@
pkt.data.frame.duration = 0;
}
- vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
+ if (cpi->output_partition)
+ {
+ int i;
+ const int num_partitions =
+ (1 << cpi->common.multi_token_partition) + 1;
+ 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);
- cx_data += size;
- cx_data_sz -= size;
}
}
}
@@ -1121,7 +1146,8 @@
{
"WebM Project VP8 Encoder" VERSION_STRING,
VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR,
+ 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; */
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c
index e0f4c0a..58dc486 100644
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -368,6 +368,8 @@
oxcf.max_threads = ctx->cfg.threads;
oxcf.error_concealment =
(ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT);
+ oxcf.input_partition =
+ (ctx->base.init_flags & VPX_CODEC_USE_INPUT_PARTITION);
optr = vp8dx_create_decompressor(&oxcf);
@@ -588,8 +590,7 @@
image2yuvconfig(&frame->img, &sd);
- vp8dx_set_reference(ctx->pbi, frame->frame_type, &sd);
- return VPX_CODEC_OK;
+ return vp8dx_set_reference(ctx->pbi, frame->frame_type, &sd);
}
else
return VPX_CODEC_INVALID_PARAM;
@@ -610,8 +611,7 @@
image2yuvconfig(&frame->img, &sd);
- vp8dx_get_reference(ctx->pbi, frame->frame_type, &sd);
- return VPX_CODEC_OK;
+ return vp8dx_get_reference(ctx->pbi, frame->frame_type, &sd);
}
else
return VPX_CODEC_INVALID_PARAM;
@@ -723,7 +723,8 @@
{
"WebM Project VP8 Decoder" VERSION_STRING,
VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC | VP8_CAP_ERROR_CONCEALMENT,
+ VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC | VP8_CAP_ERROR_CONCEALMENT |
+ 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; */
diff --git a/vp8/vp8cx_arm.mk b/vp8/vp8cx_arm.mk
index 165dada..599bf47 100644
--- a/vp8/vp8cx_arm.mk
+++ b/vp8/vp8cx_arm.mk
@@ -15,17 +15,16 @@
# encoder
VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/arm_csystemdependent.c
-VP8_CX_SRCS-$(HAVE_ARMV7) += encoder/arm/quantize_arm.c
-VP8_CX_SRCS-$(HAVE_ARMV7) += encoder/arm/picklpf_arm.c
-VP8_CX_SRCS-$(HAVE_ARMV6) += encoder/arm/dct_arm.c
-VP8_CX_SRCS-$(HAVE_ARMV6) += encoder/arm/variance_arm.c
-VP8_CX_SRCS-$(HAVE_ARMV6) += encoder/arm/variance_arm.h
-VP8_CX_SRCS-$(HAVE_ARMV5TE) += encoder/arm/boolhuff_arm.c
-
-VP8_CX_SRCS_REMOVE-$(HAVE_ARMV5TE) += encoder/boolhuff.c
+VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/quantize_arm.c
+VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/picklpf_arm.c
+VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/dct_arm.c
+VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/variance_arm.c
+VP8_CX_SRCS-$(ARCH_ARM) += encoder/arm/variance_arm.h
#File list for armv5te
# encoder
+VP8_CX_SRCS-$(HAVE_ARMV5TE) += encoder/arm/boolhuff_arm.c
+VP8_CX_SRCS_REMOVE-$(HAVE_ARMV5TE) += encoder/boolhuff.c
VP8_CX_SRCS-$(HAVE_ARMV5TE) += encoder/arm/armv5te/boolhuff_armv5te$(ASM)
VP8_CX_SRCS-$(HAVE_ARMV5TE) += encoder/arm/armv5te/vp8_packtokens_armv5$(ASM)
VP8_CX_SRCS-$(HAVE_ARMV5TE) += encoder/arm/armv5te/vp8_packtokens_mbrow_armv5$(ASM)
diff --git a/vp8/vp8dx_arm.mk b/vp8/vp8dx_arm.mk
index 03084c5..583562b 100644
--- a/vp8/vp8dx_arm.mk
+++ b/vp8/vp8dx_arm.mk
@@ -14,7 +14,7 @@
VP8_DX_SRCS-$(ARCH_ARM) += decoder/arm/arm_dsystemdependent.c
VP8_CX_SRCS-$(ARCH_ARM) += decoder/asm_dec_offsets.c
-VP8_DX_SRCS-$(HAVE_ARMV6) += decoder/arm/dequantize_arm.c
+VP8_DX_SRCS-$(ARCH_ARM) += decoder/arm/dequantize_arm.c
#File list for armv6
VP8_DX_SRCS-$(HAVE_ARMV6) += decoder/arm/armv6/dequant_dc_idct_v6$(ASM)
diff --git a/vpx/src/vpx_decoder.c b/vpx/src/vpx_decoder.c
index 42aedee..6e877b0 100644
--- a/vpx/src/vpx_decoder.c
+++ b/vpx/src/vpx_decoder.c
@@ -39,6 +39,9 @@
else if ((flags & VPX_CODEC_USE_ERROR_CONCEALMENT) &&
!(iface->caps & VPX_CODEC_CAP_ERROR_CONCEALMENT))
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
diff --git a/vpx/src/vpx_encoder.c b/vpx/src/vpx_encoder.c
index dab7554..5e86835 100644
--- a/vpx/src/vpx_encoder.c
+++ b/vpx/src/vpx_encoder.c
@@ -41,6 +41,9 @@
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;
diff --git a/vpx/vp8.h b/vpx/vp8.h
index 7ca5c6e..983cc4a 100644
--- a/vpx/vp8.h
+++ b/vpx/vp8.h
@@ -30,7 +30,7 @@
*/
#ifndef VP8_H
#define VP8_H
-#include "vpx/vpx_codec_impl_top.h"
+#include "vpx_codec_impl_top.h"
/*!\brief Control functions
*
@@ -126,5 +126,5 @@
DECLSPEC_DEPRECATED extern vpx_codec_iface_t vpx_codec_vp8_algo DEPRECATED;
#endif
-#include "vpx/vpx_codec_impl_bottom.h"
+#include "vpx_codec_impl_bottom.h"
#endif
diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h
index 6fd161b..b6bd7fc 100644
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -22,7 +22,7 @@
*/
#ifndef VP8CX_H
#define VP8CX_H
-#include "vpx/vpx_codec_impl_top.h"
+#include "vpx_codec_impl_top.h"
/*!\name Algorithm interface for VP8
*
@@ -296,5 +296,5 @@
VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
/*! @} - end defgroup vp8_encoder */
-#include "vpx/vpx_codec_impl_bottom.h"
+#include "vpx_codec_impl_bottom.h"
#endif
diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h
index 4a3aef7..1d9d531 100644
--- a/vpx/vp8dx.h
+++ b/vpx/vp8dx.h
@@ -22,7 +22,7 @@
*/
#ifndef VP8DX_H
#define VP8DX_H
-#include "vpx/vpx_codec_impl_top.h"
+#include "vpx_codec_impl_top.h"
/*!\name Algorithm interface for VP8
*
@@ -74,5 +74,5 @@
/*! @} - end defgroup vp8_decoder */
-#include "vpx/vpx_codec_impl_bottom.h"
+#include "vpx_codec_impl_bottom.h"
#endif
diff --git a/vpx/vp8e.h b/vpx/vp8e.h
index abfce33..ca907c9 100644
--- a/vpx/vp8e.h
+++ b/vpx/vp8e.h
@@ -14,7 +14,7 @@
*/
#ifndef VP8E_H
#define VP8E_H
-#include "vpx/vpx_codec_impl_top.h"
+#include "vpx_codec_impl_top.h"
#if defined(VPX_CODEC_DISABLE_COMPAT) && VPX_CODEC_DISABLE_COMPAT
#error "Backwards compatibility disabled: don't include vp8e.h"
@@ -59,5 +59,5 @@
* #VPX_DL_BEST_QUALITY constants to that parameter instead.
*/
VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_ENCODING_MODE, vp8e_encoding_mode)
-#include "vpx/vpx_codec_impl_bottom.h"
+#include "vpx_codec_impl_bottom.h"
#endif
diff --git a/vpx/vpx_decoder.h b/vpx/vpx_decoder.h
index e50fd76..0fc38c6 100644
--- a/vpx/vpx_decoder.h
+++ b/vpx/vpx_decoder.h
@@ -55,6 +55,8 @@
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000 /**< Can conceal errors due to
packet loss */
+#define VPX_CODEC_CAP_INPUT_PARTITION 0x100000 /**< Can receive encoded frames
+ one partition at a time */
/*! \brief Initialization-time Feature Enabling
*
@@ -66,6 +68,9 @@
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded
frames */
+#define VPX_CODEC_USE_INPUT_PARTITION 0x40000 /**< The input frame should be
+ passed to the decoder one
+ partition at a time */
/*!\brief Stream properties
*
@@ -184,6 +189,11 @@
* 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
diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h
index 6dbce0d..71153d5 100644
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -55,6 +55,13 @@
*/
#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.
+ */
+#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
+
/*! \brief Initialization-time Feature Enabling
*
@@ -64,6 +71,8 @@
* 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
@@ -99,7 +108,26 @@
this one) */
#define VPX_FRAME_IS_INVISIBLE 0x4 /**< frame should be decoded but will not
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;
+#define VPX_ERROR_RESILIENT_DEFAULT 0x1 /**< Improve resiliency against
+ 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
*
@@ -135,6 +163,13 @@
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
+ 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
@@ -289,13 +324,13 @@
struct vpx_rational g_timebase;
- /*!\brief Enable error resilient mode.
+ /*!\brief Enable error resilient modes.
*
- * Error resilient mode indicates to the encoder that it should take
- * measures appropriate for streaming over lossy or noisy links, if
- * possible. Set to 1 to enable this feature, 0 to disable it.
+ * The error resilient bitfield indicates to the encoder which features
+ * it should enable to take measures for streaming over lossy or noisy
+ * links.
*/
- unsigned int g_error_resilient;
+ vpx_codec_er_flags_t g_error_resilient;
/*!\brief Multi-pass Encoding Mode
diff --git a/vpxenc.c b/vpxenc.c
index 89cdef0..26afcd6 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -23,6 +23,7 @@
#include <stdarg.h>
#include <string.h>
#include <limits.h>
+#include <assert.h>
#include "vpx/vpx_encoder.h"
#if USE_POSIX_MMAP
#include <sys/types.h>
@@ -909,12 +910,16 @@
"Stream frame rate (rate/scale)");
static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0,
"Output IVF (default is WebM)");
+static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1,
+ "Show quantizer histogram (n-buckets)");
+static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1,
+ "Show rate histogram (n-buckets)");
static const arg_def_t *main_args[] =
{
&debugmode,
&outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &deadline,
&best_dl, &good_dl, &rt_dl,
- &verbosearg, &psnrarg, &use_ivf,
+ &verbosearg, &psnrarg, &use_ivf, &q_hist_n, &rate_hist_n,
NULL
};
@@ -1107,6 +1112,281 @@
exit(EXIT_FAILURE);
}
+
+#define HIST_BAR_MAX 40
+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;
+ }
+
+ /* If we have too many buckets, merge the smallest with an ajacent
+ * 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--;
+
+ /* 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;
+}
+
+
+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;
+ }
+
+ 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);
+ }
+}
+
+
+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];
+ }
+ }
+
+ 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;
+};
+
+
+static void init_rate_histogram(struct rate_hist *hist,
+ const vpx_codec_enc_cfg_t *cfg)
+{
+ int i;
+
+ hist->samples = cfg->rc_buf_sz * 60 / 1000; // max 60 fps
+ 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 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;
+
+ /* Sum the size over the past rc_buf_sz ms */
+ for(i = hist->frames; i > 0; 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];
+ }
+
+ 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);
+}
+
#define ARG_CTRL_CNT_MAX 10
int main(int argc, const char **argv_)
@@ -1145,6 +1425,10 @@
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};
exec_name = argv_[0];
ebml.last_pts_ms = -1;
@@ -1228,6 +1512,10 @@
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++;
}
@@ -1411,6 +1699,8 @@
memset(&stats, 0, sizeof(stats));
+ init_rate_histogram(&rate_hist, &cfg);
+
for (pass = one_pass_only ? one_pass_only - 1 : 0; pass < arg_passes; pass++)
{
int frames_in = 0, frames_out = 0;
@@ -1648,6 +1938,16 @@
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;
while ((pkt = vpx_codec_get_cx_data(&encoder, &iter)))
@@ -1661,6 +1961,7 @@
fprintf(stderr, " %6luF",
(unsigned long)pkt->data.frame.sz);
+ update_rate_histogram(&rate_hist, &cfg, pkt);
if(write_webm)
{
/* Update the hash */
@@ -1739,10 +2040,14 @@
vpx_codec_destroy(&encoder);
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
{
@@ -1758,6 +2063,13 @@
break;
}
+ 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);
free(argv);
return EXIT_SUCCESS;