2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
Convert subpixel filters to use convolve framework
Update the code to call the new convolution functions to do subpixel
prediction rather than the existing functions. Remove the old C and
assembly code, since it is unused. This causes a 50% performance
reduction on the decoder, but that will be resolved when the asm for
the new functions is available.
There is no consensus for whether 6-tap or 2-tap predictors will be
supported in the final codec, so these filters are implemented in
terms of the 8-tap code, so that quality testing of these modes
can continue. Implementing the lower complexity algorithms is a
simple exercise, should it be necessary.
This code produces slightly better results in the EIGHTTAP_SMOOTH
case, since the filter is now applied in only one direction when
the subpel motion is only in one direction. Like the previous code,
the filtering is skipped entirely on full-pel MVs. This combination
seems to give the best quality gains, but this may be indicative of a
bug in the encoder's filter selection, since the encoder could
achieve the result of skipping the filtering on full-pel by selecting
one of the other filters. This should be revisited.
Quality gains on derf positive on almost all clips. The only clip
that seemed to be hurt at all datarates was football
(-0.115% PSNR average, -0.587% min). Overall averages 0.375% PSNR,
0.347% SSIM.
Change-Id: I7d469716091b1d89b4b08adde5863999319d69ff
2013-01-29 01:59:03 +01:00
|
|
|
#include <assert.h>
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-08-09 23:07:09 +02:00
|
|
|
#include "./vpx_scale_rtcd.h"
|
2012-12-23 16:20:10 +01:00
|
|
|
#include "./vpx_config.h"
|
2013-08-09 23:07:09 +02:00
|
|
|
|
2011-07-25 16:11:24 +02:00
|
|
|
#include "vpx/vpx_integer.h"
|
2013-08-09 23:07:09 +02:00
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_blockd.h"
|
Convert subpixel filters to use convolve framework
Update the code to call the new convolution functions to do subpixel
prediction rather than the existing functions. Remove the old C and
assembly code, since it is unused. This causes a 50% performance
reduction on the decoder, but that will be resolved when the asm for
the new functions is available.
There is no consensus for whether 6-tap or 2-tap predictors will be
supported in the final codec, so these filters are implemented in
terms of the 8-tap code, so that quality testing of these modes
can continue. Implementing the lower complexity algorithms is a
simple exercise, should it be necessary.
This code produces slightly better results in the EIGHTTAP_SMOOTH
case, since the filter is now applied in only one direction when
the subpel motion is only in one direction. Like the previous code,
the filtering is skipped entirely on full-pel MVs. This combination
seems to give the best quality gains, but this may be indicative of a
bug in the encoder's filter selection, since the encoder could
achieve the result of skipping the filtering on full-pel by selecting
one of the other filters. This should be revisited.
Quality gains on derf positive on almost all clips. The only clip
that seemed to be hurt at all datarates was football
(-0.115% PSNR average, -0.587% min). Overall averages 0.375% PSNR,
0.347% SSIM.
Change-Id: I7d469716091b1d89b4b08adde5863999319d69ff
2013-01-29 01:59:03 +01:00
|
|
|
#include "vp9/common/vp9_filter.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_reconinter.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_reconintra.h"
|
2013-05-15 02:49:41 +02:00
|
|
|
|
Spatial resamping of ZEROMV predictors
This patch allows coding frames using references of different
resolution, in ZEROMV mode. For compound prediction, either
reference may be scaled.
To test, I use the resize_test and enable WRITE_RECON_BUFFER
in vp9_onyxd_if.c. It's also useful to apply this patch to
test/i420_video_source.h:
--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -93,6 +93,7 @@ class I420VideoSource : public VideoSource {
virtual void FillFrame() {
// Read a frame from input_file.
+ if (frame_ != 3)
if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
limit_ = frame_;
}
This forces the frame that the resolution changes on to be coded
with no motion, only scaling, and improves the quality of the
result.
Change-Id: I1ee75d19a437ff801192f767fd02a36bcbd1d496
2013-02-25 05:55:14 +01:00
|
|
|
|
|
|
|
void vp9_setup_interp_filters(MACROBLOCKD *xd,
|
|
|
|
INTERPOLATIONFILTERTYPE mcomp_filter_type,
|
|
|
|
VP9_COMMON *cm) {
|
2013-09-11 19:45:44 +02:00
|
|
|
if (xd->mi_8x8 && xd->this_mi) {
|
|
|
|
MB_MODE_INFO * mbmi = &xd->this_mi->mbmi;
|
Spatial resamping of ZEROMV predictors
This patch allows coding frames using references of different
resolution, in ZEROMV mode. For compound prediction, either
reference may be scaled.
To test, I use the resize_test and enable WRITE_RECON_BUFFER
in vp9_onyxd_if.c. It's also useful to apply this patch to
test/i420_video_source.h:
--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -93,6 +93,7 @@ class I420VideoSource : public VideoSource {
virtual void FillFrame() {
// Read a frame from input_file.
+ if (frame_ != 3)
if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
limit_ = frame_;
}
This forces the frame that the resolution changes on to be coded
with no motion, only scaling, and improves the quality of the
result.
Change-Id: I1ee75d19a437ff801192f767fd02a36bcbd1d496
2013-02-25 05:55:14 +01:00
|
|
|
|
2013-06-28 01:15:43 +02:00
|
|
|
set_scale_factors(xd, mbmi->ref_frame[0] - 1, mbmi->ref_frame[1] - 1,
|
Spatial resamping of ZEROMV predictors
This patch allows coding frames using references of different
resolution, in ZEROMV mode. For compound prediction, either
reference may be scaled.
To test, I use the resize_test and enable WRITE_RECON_BUFFER
in vp9_onyxd_if.c. It's also useful to apply this patch to
test/i420_video_source.h:
--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -93,6 +93,7 @@ class I420VideoSource : public VideoSource {
virtual void FillFrame() {
// Read a frame from input_file.
+ if (frame_ != 3)
if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
limit_ = frame_;
}
This forces the frame that the resolution changes on to be coded
with no motion, only scaling, and improves the quality of the
result.
Change-Id: I1ee75d19a437ff801192f767fd02a36bcbd1d496
2013-02-25 05:55:14 +01:00
|
|
|
cm->active_ref_scale);
|
2013-09-11 19:45:44 +02:00
|
|
|
} else {
|
|
|
|
set_scale_factors(xd, -1, -1, cm->active_ref_scale);
|
Spatial resamping of ZEROMV predictors
This patch allows coding frames using references of different
resolution, in ZEROMV mode. For compound prediction, either
reference may be scaled.
To test, I use the resize_test and enable WRITE_RECON_BUFFER
in vp9_onyxd_if.c. It's also useful to apply this patch to
test/i420_video_source.h:
--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -93,6 +93,7 @@ class I420VideoSource : public VideoSource {
virtual void FillFrame() {
// Read a frame from input_file.
+ if (frame_ != 3)
if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
limit_ = frame_;
}
This forces the frame that the resolution changes on to be coded
with no motion, only scaling, and improves the quality of the
result.
Change-Id: I1ee75d19a437ff801192f767fd02a36bcbd1d496
2013-02-25 05:55:14 +01:00
|
|
|
}
|
|
|
|
|
Convert subpixel filters to use convolve framework
Update the code to call the new convolution functions to do subpixel
prediction rather than the existing functions. Remove the old C and
assembly code, since it is unused. This causes a 50% performance
reduction on the decoder, but that will be resolved when the asm for
the new functions is available.
There is no consensus for whether 6-tap or 2-tap predictors will be
supported in the final codec, so these filters are implemented in
terms of the 8-tap code, so that quality testing of these modes
can continue. Implementing the lower complexity algorithms is a
simple exercise, should it be necessary.
This code produces slightly better results in the EIGHTTAP_SMOOTH
case, since the filter is now applied in only one direction when
the subpel motion is only in one direction. Like the previous code,
the filtering is skipped entirely on full-pel MVs. This combination
seems to give the best quality gains, but this may be indicative of a
bug in the encoder's filter selection, since the encoder could
achieve the result of skipping the filtering on full-pel by selecting
one of the other filters. This should be revisited.
Quality gains on derf positive on almost all clips. The only clip
that seemed to be hurt at all datarates was football
(-0.115% PSNR average, -0.587% min). Overall averages 0.375% PSNR,
0.347% SSIM.
Change-Id: I7d469716091b1d89b4b08adde5863999319d69ff
2013-01-29 01:59:03 +01:00
|
|
|
switch (mcomp_filter_type) {
|
|
|
|
case EIGHTTAP:
|
|
|
|
case SWITCHABLE:
|
|
|
|
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8;
|
|
|
|
break;
|
|
|
|
case EIGHTTAP_SMOOTH:
|
|
|
|
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8lp;
|
|
|
|
break;
|
|
|
|
case EIGHTTAP_SHARP:
|
|
|
|
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8s;
|
|
|
|
break;
|
|
|
|
case BILINEAR:
|
|
|
|
xd->subpix.filter_x = xd->subpix.filter_y = vp9_bilinear_filters;
|
|
|
|
break;
|
2013-01-08 23:14:01 +01:00
|
|
|
}
|
2013-02-21 00:59:20 +01:00
|
|
|
assert(((intptr_t)xd->subpix.filter_x & 0xff) == 0);
|
2012-07-18 22:43:01 +02:00
|
|
|
}
|
|
|
|
|
2013-02-09 02:49:44 +01:00
|
|
|
void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
|
|
|
|
uint8_t *dst, int dst_stride,
|
2013-08-03 00:26:32 +02:00
|
|
|
const MV *src_mv,
|
2013-02-09 02:49:44 +01:00
|
|
|
const struct scale_factors *scale,
|
2013-08-12 22:54:13 +02:00
|
|
|
int w, int h, int ref,
|
2013-06-22 00:34:29 +02:00
|
|
|
const struct subpix_fn_table *subpix,
|
|
|
|
enum mv_precision precision) {
|
2013-08-07 00:43:56 +02:00
|
|
|
const int is_q4 = precision == MV_PRECISION_Q4;
|
2013-09-18 01:31:46 +02:00
|
|
|
const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
|
|
|
|
is_q4 ? src_mv->col : src_mv->col * 2 };
|
2013-08-07 00:43:56 +02:00
|
|
|
const MV32 mv = scale->scale_mv(&mv_q4, scale);
|
|
|
|
const int subpel_x = mv.col & SUBPEL_MASK;
|
|
|
|
const int subpel_y = mv.row & SUBPEL_MASK;
|
|
|
|
|
|
|
|
src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
|
2013-08-12 22:54:13 +02:00
|
|
|
scale->predict[subpel_x != 0][subpel_y != 0][ref](
|
2013-02-09 02:49:44 +01:00
|
|
|
src, src_stride, dst, dst_stride,
|
Spatial resamping of ZEROMV predictors
This patch allows coding frames using references of different
resolution, in ZEROMV mode. For compound prediction, either
reference may be scaled.
To test, I use the resize_test and enable WRITE_RECON_BUFFER
in vp9_onyxd_if.c. It's also useful to apply this patch to
test/i420_video_source.h:
--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -93,6 +93,7 @@ class I420VideoSource : public VideoSource {
virtual void FillFrame() {
// Read a frame from input_file.
+ if (frame_ != 3)
if (fread(img_->img_data, raw_sz_, 1, input_file_) == 0) {
limit_ = frame_;
}
This forces the frame that the resolution changes on to be coded
with no motion, only scaling, and improves the quality of the
result.
Change-Id: I1ee75d19a437ff801192f767fd02a36bcbd1d496
2013-02-25 05:55:14 +01:00
|
|
|
subpix->filter_x[subpel_x], scale->x_step_q4,
|
|
|
|
subpix->filter_y[subpel_y], scale->y_step_q4,
|
2013-02-09 02:49:44 +01:00
|
|
|
w, h);
|
2012-04-18 22:51:58 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:41:18 +02:00
|
|
|
static INLINE int round_mv_comp_q4(int value) {
|
|
|
|
return (value < 0 ? value - 2 : value + 2) / 4;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-03 01:53:18 +02:00
|
|
|
static MV mi_mv_pred_q4(const MODE_INFO *mi, int idx) {
|
|
|
|
MV res = { round_mv_comp_q4(mi->bmi[0].as_mv[idx].as_mv.row +
|
|
|
|
mi->bmi[1].as_mv[idx].as_mv.row +
|
|
|
|
mi->bmi[2].as_mv[idx].as_mv.row +
|
|
|
|
mi->bmi[3].as_mv[idx].as_mv.row),
|
|
|
|
round_mv_comp_q4(mi->bmi[0].as_mv[idx].as_mv.col +
|
|
|
|
mi->bmi[1].as_mv[idx].as_mv.col +
|
|
|
|
mi->bmi[2].as_mv[idx].as_mv.col +
|
|
|
|
mi->bmi[3].as_mv[idx].as_mv.col) };
|
|
|
|
return res;
|
2013-04-17 21:24:51 +02:00
|
|
|
}
|
|
|
|
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
// TODO(jkoleszar): yet another mv clamping function :-(
|
2013-08-08 02:02:28 +02:00
|
|
|
MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, const MV *src_mv,
|
|
|
|
int bw, int bh, int ss_x, int ss_y) {
|
2013-08-02 00:06:34 +02:00
|
|
|
// 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.
|
2013-08-08 02:02:28 +02:00
|
|
|
const int spel_left = (VP9_INTERP_EXTEND + bw) << SUBPEL_BITS;
|
|
|
|
const int spel_right = spel_left - SUBPEL_SHIFTS;
|
|
|
|
const int spel_top = (VP9_INTERP_EXTEND + bh) << SUBPEL_BITS;
|
|
|
|
const int spel_bottom = spel_top - SUBPEL_SHIFTS;
|
2013-08-02 00:06:34 +02:00
|
|
|
MV clamped_mv = {
|
2013-09-18 01:31:46 +02:00
|
|
|
src_mv->row * (1 << (1 - ss_y)),
|
|
|
|
src_mv->col * (1 << (1 - ss_x))
|
2013-08-02 00:06:34 +02:00
|
|
|
};
|
2013-04-17 01:26:26 +02:00
|
|
|
assert(ss_x <= 1);
|
|
|
|
assert(ss_y <= 1);
|
2013-08-02 00:06:34 +02:00
|
|
|
|
2013-09-18 01:31:46 +02:00
|
|
|
clamp_mv(&clamped_mv,
|
|
|
|
xd->mb_to_left_edge * (1 << (1 - ss_x)) - spel_left,
|
|
|
|
xd->mb_to_right_edge * (1 << (1 - ss_x)) + spel_right,
|
|
|
|
xd->mb_to_top_edge * (1 << (1 - ss_y)) - spel_top,
|
|
|
|
xd->mb_to_bottom_edge * (1 << (1 - ss_y)) + spel_bottom);
|
2013-08-02 00:06:34 +02:00
|
|
|
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
return clamped_mv;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct build_inter_predictors_args {
|
|
|
|
MACROBLOCKD *xd;
|
2013-08-12 22:54:13 +02:00
|
|
|
int x, y;
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
};
|
2013-08-16 21:51:20 +02:00
|
|
|
|
2013-08-26 20:33:16 +02:00
|
|
|
static void build_inter_predictors(int plane, int block, BLOCK_SIZE bsize,
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
int pred_w, int pred_h,
|
|
|
|
void *argv) {
|
|
|
|
const struct build_inter_predictors_args* const arg = argv;
|
2013-08-08 02:02:28 +02:00
|
|
|
MACROBLOCKD *const xd = arg->xd;
|
|
|
|
struct macroblockd_plane *const pd = &xd->plane[plane];
|
|
|
|
const int bwl = b_width_log2(bsize) - pd->subsampling_x;
|
|
|
|
const int bw = 4 << bwl;
|
|
|
|
const int bh = plane_block_height(bsize, pd);
|
|
|
|
const int x = 4 * (block & ((1 << bwl) - 1));
|
|
|
|
const int y = 4 * (block >> bwl);
|
2013-09-11 19:45:44 +02:00
|
|
|
const MODE_INFO *mi = xd->this_mi;
|
2013-07-27 04:05:37 +02:00
|
|
|
const int use_second_ref = mi->mbmi.ref_frame[1] > 0;
|
2013-08-12 22:54:13 +02:00
|
|
|
int ref;
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
|
2013-08-08 02:02:28 +02:00
|
|
|
assert(x < bw);
|
|
|
|
assert(y < bh);
|
|
|
|
assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_w == bw);
|
|
|
|
assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_h == bh);
|
2013-04-17 22:41:18 +02:00
|
|
|
|
2013-08-12 22:54:13 +02:00
|
|
|
for (ref = 0; ref < 1 + use_second_ref; ++ref) {
|
|
|
|
struct scale_factors *const scale = &xd->scale_factor[ref];
|
2013-08-16 21:51:20 +02:00
|
|
|
struct buf_2d *const pre_buf = &pd->pre[ref];
|
|
|
|
struct buf_2d *const dst_buf = &pd->dst;
|
2013-08-08 02:02:28 +02:00
|
|
|
|
2013-08-09 06:25:48 +02:00
|
|
|
const uint8_t *const pre = pre_buf->buf + scaled_buffer_offset(x, y,
|
|
|
|
pre_buf->stride, scale);
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
|
2013-08-09 06:25:48 +02:00
|
|
|
uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
|
2013-04-17 22:41:18 +02:00
|
|
|
|
2013-08-03 01:53:18 +02:00
|
|
|
// TODO(jkoleszar): All chroma MVs in SPLITMV mode are taken as the
|
|
|
|
// same MV (the average of the 4 luma MVs) but we could do something
|
|
|
|
// smarter for non-4:2:0. Just punt for now, pending the changes to get
|
|
|
|
// rid of SPLITMV mode entirely.
|
2013-08-06 00:23:49 +02:00
|
|
|
const MV mv = mi->mbmi.sb_type < BLOCK_8X8
|
2013-08-12 22:54:13 +02:00
|
|
|
? (plane == 0 ? mi->bmi[block].as_mv[ref].as_mv
|
|
|
|
: mi_mv_pred_q4(mi, ref))
|
|
|
|
: mi->mbmi.mv[ref].as_mv;
|
2013-08-03 01:53:18 +02:00
|
|
|
|
|
|
|
// TODO(jkoleszar): This clamping is done in the incorrect place for the
|
|
|
|
// scaling case. It needs to be done on the scaled MV, not the pre-scaling
|
|
|
|
// MV. Note however that it performs the subsampling aware scaling so
|
|
|
|
// that the result is always q4.
|
2013-08-08 02:02:28 +02:00
|
|
|
const MV res_mv = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh,
|
|
|
|
pd->subsampling_x,
|
|
|
|
pd->subsampling_y);
|
|
|
|
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
scale->set_scaled_offsets(scale, arg->y + y, arg->x + x);
|
2013-08-09 06:25:48 +02:00
|
|
|
vp9_build_inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride,
|
|
|
|
&res_mv, scale,
|
2013-08-12 22:54:13 +02:00
|
|
|
4 << pred_w, 4 << pred_h, ref,
|
2013-06-22 00:34:29 +02:00
|
|
|
&xd->subpix, MV_PRECISION_Q4);
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
}
|
|
|
|
}
|
2013-08-12 22:54:13 +02:00
|
|
|
|
2013-08-21 02:20:47 +02:00
|
|
|
// TODO(jkoleszar): In principle, pred_w, pred_h are unnecessary, as we could
|
2013-08-26 20:33:16 +02:00
|
|
|
// calculate the subsampled BLOCK_SIZE, but that type isn't defined for
|
2013-08-21 02:20:47 +02:00
|
|
|
// sizes smaller than 16x16 yet.
|
|
|
|
typedef void (*foreach_predicted_block_visitor)(int plane, int block,
|
2013-08-26 20:33:16 +02:00
|
|
|
BLOCK_SIZE bsize,
|
2013-08-21 02:20:47 +02:00
|
|
|
int pred_w, int pred_h,
|
|
|
|
void *arg);
|
|
|
|
static INLINE void foreach_predicted_block_in_plane(
|
2013-08-26 20:33:16 +02:00
|
|
|
const MACROBLOCKD* const xd, BLOCK_SIZE bsize, int plane,
|
2013-08-21 02:20:47 +02:00
|
|
|
foreach_predicted_block_visitor visit, void *arg) {
|
|
|
|
int i, x, y;
|
|
|
|
|
|
|
|
// block sizes in number of 4x4 blocks log 2 ("*_b")
|
|
|
|
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
|
|
|
|
// subsampled size of the block
|
|
|
|
const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
|
|
|
|
const int bhl = b_height_log2(bsize) - xd->plane[plane].subsampling_y;
|
|
|
|
|
|
|
|
// size of the predictor to use.
|
|
|
|
int pred_w, pred_h;
|
|
|
|
|
2013-09-11 19:45:44 +02:00
|
|
|
if (xd->this_mi->mbmi.sb_type < BLOCK_8X8) {
|
2013-08-21 02:20:47 +02:00
|
|
|
assert(bsize == BLOCK_8X8);
|
|
|
|
pred_w = 0;
|
|
|
|
pred_h = 0;
|
|
|
|
} else {
|
|
|
|
pred_w = bwl;
|
|
|
|
pred_h = bhl;
|
|
|
|
}
|
|
|
|
assert(pred_w <= bwl);
|
|
|
|
assert(pred_h <= bhl);
|
|
|
|
|
|
|
|
// visit each subblock in raster order
|
|
|
|
i = 0;
|
|
|
|
for (y = 0; y < 1 << bhl; y += 1 << pred_h) {
|
|
|
|
for (x = 0; x < 1 << bwl; x += 1 << pred_w) {
|
|
|
|
visit(plane, i, bsize, pred_w, pred_h, arg);
|
|
|
|
i += 1 << pred_w;
|
|
|
|
}
|
|
|
|
i += (1 << (bwl + pred_h)) - (1 << bwl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-26 20:33:16 +02:00
|
|
|
static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize,
|
2013-08-12 22:54:13 +02:00
|
|
|
int mi_row, int mi_col,
|
|
|
|
int plane_from, int plane_to) {
|
|
|
|
int plane;
|
|
|
|
for (plane = plane_from; plane <= plane_to; ++plane) {
|
|
|
|
struct build_inter_predictors_args args = {
|
|
|
|
xd, mi_col * MI_SIZE, mi_row * MI_SIZE,
|
|
|
|
};
|
|
|
|
foreach_predicted_block_in_plane(xd, bsize, plane, build_inter_predictors,
|
|
|
|
&args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 06:25:48 +02:00
|
|
|
void vp9_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col,
|
2013-08-26 20:33:16 +02:00
|
|
|
BLOCK_SIZE bsize) {
|
2013-08-12 22:54:13 +02:00
|
|
|
build_inter_predictors_for_planes(xd, bsize, mi_row, mi_col, 0, 0);
|
make buid_inter_predictors block size agnostic (luma)
This commit converts the luma versions of vp9_build_inter_predictors_sb
to use a common function. Update the convolution functions to support
block sizes larger than 16x16, and add a foreach_predicted_block walker.
Next step will be to calculate the UV motion vector and implement SBUV,
then fold in vp9_build_inter16x16_predictors_mb and SPLITMV.
At the 16x16, 32x32, and 64x64 levels implemented in this commit, each
plane is predicted with only a single call to vp9_build_inter_predictor.
This is not yet called for SPLITMV. If the notion of SPLITMV/I8X8/I4X4
goes away, then the prediction block walker can go away, since we'll
always predict the whole bsize in a single step. Implemented using a
block walker at this stage for SPLITMV, as a 4x4 "prediction block size"
within the BLOCK_SIZE_MB16X16 macroblock. It would also support other
rectangular sizes too, if the blocks smaller than 16x16 remain
implemented as a SPLITMV-like thing. Just using 4x4 for now.
There's also a potential to combine with the foreach_transformed_block
walker if the logic for calculating the size of the subsampled
transform is made more straightforward, perhaps as a consequence of
supporing smaller macroblocks than 16x16. Will watch what happens there.
Change-Id: Iddd9973398542216601b630c628b9b7fdee33fe2
2013-04-13 02:19:57 +02:00
|
|
|
}
|
2013-08-09 06:25:48 +02:00
|
|
|
void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd, int mi_row, int mi_col,
|
2013-08-26 20:33:16 +02:00
|
|
|
BLOCK_SIZE bsize) {
|
2013-08-12 22:54:13 +02:00
|
|
|
build_inter_predictors_for_planes(xd, bsize, mi_row, mi_col, 1,
|
|
|
|
MAX_MB_PLANE - 1);
|
2013-04-17 01:26:26 +02:00
|
|
|
}
|
2013-08-12 22:54:13 +02:00
|
|
|
void vp9_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
|
2013-08-26 20:33:16 +02:00
|
|
|
BLOCK_SIZE bsize) {
|
2013-08-12 22:54:13 +02:00
|
|
|
build_inter_predictors_for_planes(xd, bsize, mi_row, mi_col, 0,
|
|
|
|
MAX_MB_PLANE - 1);
|
2013-04-17 22:41:18 +02:00
|
|
|
}
|
2011-04-28 16:53:59 +02:00
|
|
|
|
2013-05-15 02:10:17 +02:00
|
|
|
// TODO(dkovalev: find better place for this function)
|
|
|
|
void vp9_setup_scale_factors(VP9_COMMON *cm, int i) {
|
|
|
|
const int ref = cm->active_ref_idx[i];
|
|
|
|
struct scale_factors *const sf = &cm->active_ref_scale[i];
|
|
|
|
if (ref >= NUM_YV12_BUFFERS) {
|
2013-07-25 23:13:44 +02:00
|
|
|
vp9_zero(*sf);
|
2013-05-15 02:10:17 +02:00
|
|
|
} else {
|
|
|
|
YV12_BUFFER_CONFIG *const fb = &cm->yv12_fb[ref];
|
2013-08-23 00:19:05 +02:00
|
|
|
vp9_setup_scale_factors_for_frame(sf,
|
2013-05-15 02:10:17 +02:00
|
|
|
fb->y_crop_width, fb->y_crop_height,
|
|
|
|
cm->width, cm->height);
|
2013-07-15 23:59:59 +02:00
|
|
|
|
2013-08-22 23:04:59 +02:00
|
|
|
if (vp9_is_scaled(sf))
|
2013-07-15 23:59:59 +02:00
|
|
|
vp9_extend_frame_borders(fb, cm->subsampling_x, cm->subsampling_y);
|
2013-05-15 02:10:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|