summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/test_libvpx.cc20
-rw-r--r--vp9/encoder/vp9_firstpass.c3
-rw-r--r--vp9/encoder/vp9_rdopt.c23
-rw-r--r--vpxdec.c98
4 files changed, 75 insertions, 69 deletions
diff --git a/test/test_libvpx.cc b/test/test_libvpx.cc
index 80aca98b3..bbcbcf9bc 100644
--- a/test/test_libvpx.cc
+++ b/test/test_libvpx.cc
@@ -22,8 +22,10 @@ extern void vp9_rtcd();
}
#include "third_party/googletest/src/include/gtest/gtest.h"
-static void append_gtest_filter(const char *str) {
+static void append_negative_gtest_filter(const char *str) {
std::string filter = ::testing::FLAGS_gtest_filter;
+ // Negative patterns begin with one '-' followed by a ':' separated list.
+ if (filter.find('-') == std::string::npos) filter += '-';
filter += str;
::testing::FLAGS_gtest_filter = filter;
}
@@ -34,21 +36,21 @@ int main(int argc, char **argv) {
#if ARCH_X86 || ARCH_X86_64
const int simd_caps = x86_simd_caps();
if (!(simd_caps & HAS_MMX))
- append_gtest_filter(":-MMX/*");
+ append_negative_gtest_filter(":MMX/*");
if (!(simd_caps & HAS_SSE))
- append_gtest_filter(":-SSE/*");
+ append_negative_gtest_filter(":SSE/*");
if (!(simd_caps & HAS_SSE2))
- append_gtest_filter(":-SSE2/*");
+ append_negative_gtest_filter(":SSE2/*");
if (!(simd_caps & HAS_SSE3))
- append_gtest_filter(":-SSE3/*");
+ append_negative_gtest_filter(":SSE3/*");
if (!(simd_caps & HAS_SSSE3))
- append_gtest_filter(":-SSSE3/*");
+ append_negative_gtest_filter(":SSSE3/*");
if (!(simd_caps & HAS_SSE4_1))
- append_gtest_filter(":-SSE4_1/*");
+ append_negative_gtest_filter(":SSE4_1/*");
if (!(simd_caps & HAS_AVX))
- append_gtest_filter(":-AVX/*");
+ append_negative_gtest_filter(":AVX/*");
if (!(simd_caps & HAS_AVX2))
- append_gtest_filter(":-AVX2/*");
+ append_negative_gtest_filter(":AVX2/*");
#endif
#if !CONFIG_SHARED
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 812ffa96d..7c4ca6378 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1825,7 +1825,8 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// 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->rc.baseline_gf_interval) {
+ if (cpi->rc.baseline_gf_interval < 1 ||
+ mod_frame_err < gf_group_err / (double)cpi->rc.baseline_gf_interval) {
double alt_gf_grp_bits =
(double)cpi->twopass.kf_group_bits *
(mod_frame_err * (double)cpi->rc.baseline_gf_interval) /
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 81d47de92..64d8cf86d 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1638,6 +1638,10 @@ static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src,
x->e_mbd.plane[0].pre[1] = orig_pre[1];
}
+static INLINE int mv_has_subpel(const MV *mv) {
+ return (mv->row & 0x0F) || (mv->col & 0x0F);
+}
+
static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
const TileInfo *const tile,
BEST_SEG_INFO *bsi_buf, int filter_idx,
@@ -1931,15 +1935,13 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
if (filter_idx > 0) {
BEST_SEG_INFO *ref_bsi = bsi_buf;
- subpelmv = (mode_mv[this_mode].as_mv.row & 0x0f) ||
- (mode_mv[this_mode].as_mv.col & 0x0f);
+ subpelmv = mv_has_subpel(&mode_mv[this_mode].as_mv);
have_ref = mode_mv[this_mode].as_int ==
- ref_bsi->rdstat[i][mode_idx].mvs[0].as_int;
+ ref_bsi->rdstat[i][mode_idx].mvs[0].as_int;
if (has_second_rf) {
- subpelmv |= (second_mode_mv[this_mode].as_mv.row & 0x0f) ||
- (second_mode_mv[this_mode].as_mv.col & 0x0f);
- have_ref &= second_mode_mv[this_mode].as_int ==
- ref_bsi->rdstat[i][mode_idx].mvs[1].as_int;
+ subpelmv |= mv_has_subpel(&second_mode_mv[this_mode].as_mv);
+ have_ref &= second_mode_mv[this_mode].as_int ==
+ ref_bsi->rdstat[i][mode_idx].mvs[1].as_int;
}
if (filter_idx > 1 && !subpelmv && !have_ref) {
@@ -2770,12 +2772,9 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
pred_exists = 0;
// Are all MVs integer pel for Y and UV
- intpel_mv = (mbmi->mv[0].as_mv.row & 15) == 0 &&
- (mbmi->mv[0].as_mv.col & 15) == 0;
+ intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv);
if (is_comp_pred)
- intpel_mv &= (mbmi->mv[1].as_mv.row & 15) == 0 &&
- (mbmi->mv[1].as_mv.col & 15) == 0;
-
+ intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv);
// Search for best switchable filter by checking the variance of
// pred error irrespective of whether the filter will be used
diff --git a/vpxdec.c b/vpxdec.c
index 69b450498..97ac4bb47 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -167,64 +167,68 @@ void usage_exit() {
exit(EXIT_FAILURE);
}
-static int read_frame(struct VpxDecInputContext *input,
- uint8_t **buf,
- size_t *bytes_in_buffer,
- size_t *buffer_size) {
+static int raw_read_frame(struct VpxInputContext *input_ctx, uint8_t **buffer,
+ size_t *bytes_read, size_t *buffer_size) {
char raw_hdr[RAW_FRAME_HDR_SZ];
- size_t bytes_to_read = 0;
- FILE *infile = input->vpx_input_ctx->file;
- enum VideoFileType kind = input->vpx_input_ctx->file_type;
- if (kind == FILE_TYPE_WEBM) {
- return webm_read_frame(input->webm_ctx,
- buf, bytes_in_buffer, buffer_size);
- } else if (kind == FILE_TYPE_RAW) {
- if (fread(raw_hdr, RAW_FRAME_HDR_SZ, 1, infile) != 1) {
- if (!feof(infile))
- warn("Failed to read RAW frame size\n");
- } else {
- const int kCorruptFrameThreshold = 256 * 1024 * 1024;
- const int kFrameTooSmallThreshold = 256 * 1024;
- bytes_to_read = mem_get_le32(raw_hdr);
-
- if (bytes_to_read > kCorruptFrameThreshold) {
- warn("Read invalid frame size (%u)\n", (unsigned int)bytes_to_read);
- bytes_to_read = 0;
- }
+ size_t frame_size = 0;
+ FILE *infile = input_ctx->file;
- if (kind == FILE_TYPE_RAW && bytes_to_read < kFrameTooSmallThreshold) {
- warn("Warning: Read invalid frame size (%u) - not a raw file?\n",
- (unsigned int)bytes_to_read);
- }
+ if (fread(raw_hdr, RAW_FRAME_HDR_SZ, 1, infile) != 1) {
+ if (!feof(infile))
+ warn("Failed to read RAW frame size\n");
+ } else {
+ const int kCorruptFrameThreshold = 256 * 1024 * 1024;
+ const int kFrameTooSmallThreshold = 256 * 1024;
+ frame_size = mem_get_le32(raw_hdr);
- if (bytes_to_read > *buffer_size) {
- uint8_t *new_buf = realloc(*buf, 2 * bytes_to_read);
+ if (frame_size > kCorruptFrameThreshold) {
+ warn("Read invalid frame size (%u)\n", (unsigned int)frame_size);
+ frame_size = 0;
+ }
- if (new_buf) {
- *buf = new_buf;
- *buffer_size = 2 * bytes_to_read;
- } else {
- warn("Failed to allocate compressed data buffer\n");
- bytes_to_read = 0;
- }
- }
+ if (frame_size < kFrameTooSmallThreshold) {
+ warn("Warning: Read invalid frame size (%u) - not a raw file?\n",
+ (unsigned int)frame_size);
}
- if (!feof(infile)) {
- if (fread(*buf, 1, bytes_to_read, infile) != bytes_to_read) {
- warn("Failed to read full frame\n");
- return 1;
+ if (frame_size > *buffer_size) {
+ uint8_t *new_buf = realloc(*buffer, 2 * frame_size);
+ if (new_buf) {
+ *buffer = new_buf;
+ *buffer_size = 2 * frame_size;
+ } else {
+ warn("Failed to allocate compressed data buffer\n");
+ frame_size = 0;
}
- *bytes_in_buffer = bytes_to_read;
}
+ }
- return 0;
- } else if (kind == FILE_TYPE_IVF) {
- return ivf_read_frame(input->vpx_input_ctx,
- buf, bytes_in_buffer, buffer_size);
+ if (!feof(infile)) {
+ if (fread(*buffer, 1, frame_size, infile) != frame_size) {
+ warn("Failed to read full frame\n");
+ return 1;
+ }
+ *bytes_read = frame_size;
}
- return 1;
+ return 0;
+}
+
+static int read_frame(struct VpxDecInputContext *input, uint8_t **buf,
+ size_t *bytes_in_buffer, size_t *buffer_size) {
+ switch (input->vpx_input_ctx->file_type) {
+ case FILE_TYPE_WEBM:
+ return webm_read_frame(input->webm_ctx,
+ buf, bytes_in_buffer, buffer_size);
+ case FILE_TYPE_RAW:
+ return raw_read_frame(input->vpx_input_ctx,
+ buf, bytes_in_buffer, buffer_size);
+ case FILE_TYPE_IVF:
+ return ivf_read_frame(input->vpx_input_ctx,
+ buf, bytes_in_buffer, buffer_size);
+ default:
+ return 1;
+ }
}
void *out_open(const char *out_fn, int do_md5) {