Merge "Add interface to compute gm parameters in encodeframe" into nextgenv2
This commit is contained in:
@@ -39,6 +39,9 @@
|
|||||||
#if CONFIG_SUPERTX
|
#if CONFIG_SUPERTX
|
||||||
#include "vp10/encoder/cost.h"
|
#include "vp10/encoder/cost.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_GLOBAL_MOTION
|
||||||
|
#include "vp10/encoder/global_motion.h"
|
||||||
|
#endif
|
||||||
#include "vp10/encoder/encodeframe.h"
|
#include "vp10/encoder/encodeframe.h"
|
||||||
#include "vp10/encoder/encodemb.h"
|
#include "vp10/encoder/encodemb.h"
|
||||||
#include "vp10/encoder/encodemv.h"
|
#include "vp10/encoder/encodemv.h"
|
||||||
@@ -1084,6 +1087,17 @@ static void update_filter_type_count(FRAME_COUNTS *counts,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_GLOBAL_MOTION
|
||||||
|
static void update_global_motion_used(PREDICTION_MODE mode,
|
||||||
|
const MB_MODE_INFO *mbmi,
|
||||||
|
VP10_COMP *cpi) {
|
||||||
|
if (mode == ZEROMV) {
|
||||||
|
++cpi->global_motion_used[mbmi->ref_frame[0]];
|
||||||
|
if (has_second_ref(mbmi))
|
||||||
|
++cpi->global_motion_used[mbmi->ref_frame[1]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // CONFIG_GLOBAL_MOTION
|
||||||
|
|
||||||
static void update_state(VP10_COMP *cpi, ThreadData *td,
|
static void update_state(VP10_COMP *cpi, ThreadData *td,
|
||||||
PICK_MODE_CONTEXT *ctx,
|
PICK_MODE_CONTEXT *ctx,
|
||||||
@@ -1231,6 +1245,21 @@ static void update_state(VP10_COMP *cpi, ThreadData *td,
|
|||||||
if (!frame_is_intra_only(cm)) {
|
if (!frame_is_intra_only(cm)) {
|
||||||
if (is_inter_block(mbmi)) {
|
if (is_inter_block(mbmi)) {
|
||||||
vp10_update_mv_count(td);
|
vp10_update_mv_count(td);
|
||||||
|
#if CONFIG_GLOBAL_MOTION
|
||||||
|
if (bsize >= BLOCK_8X8) {
|
||||||
|
update_global_motion_used(mbmi->mode, mbmi, cpi);
|
||||||
|
} else {
|
||||||
|
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
|
||||||
|
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
|
||||||
|
int idx, idy;
|
||||||
|
for (idy = 0; idy < 2; idy += num_4x4_h) {
|
||||||
|
for (idx = 0; idx < 2; idx += num_4x4_w) {
|
||||||
|
const int j = idy * 2 + idx;
|
||||||
|
update_global_motion_used(mi->bmi[j].as_mode, mbmi, cpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // CONFIG_GLOBAL_MOTION
|
||||||
if (cm->interp_filter == SWITCHABLE
|
if (cm->interp_filter == SWITCHABLE
|
||||||
#if CONFIG_EXT_INTERP
|
#if CONFIG_EXT_INTERP
|
||||||
&& vp10_is_interp_needed(xd)
|
&& vp10_is_interp_needed(xd)
|
||||||
@@ -4538,6 +4567,7 @@ static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
|
|||||||
|
|
||||||
#if CONFIG_GLOBAL_MOTION
|
#if CONFIG_GLOBAL_MOTION
|
||||||
#define MIN_TRANS_THRESH 8
|
#define MIN_TRANS_THRESH 8
|
||||||
|
#define GLOBAL_MOTION_MODEL ROTZOOM
|
||||||
static void convert_to_params(double *H, TransformationType type,
|
static void convert_to_params(double *H, TransformationType type,
|
||||||
Global_Motion_Params *model) {
|
Global_Motion_Params *model) {
|
||||||
int i;
|
int i;
|
||||||
@@ -4610,10 +4640,19 @@ static void encode_frame_internal(VP10_COMP *cpi) {
|
|||||||
vpx_clear_system_state();
|
vpx_clear_system_state();
|
||||||
vp10_zero(cpi->global_motion_used);
|
vp10_zero(cpi->global_motion_used);
|
||||||
if (cpi->common.frame_type == INTER_FRAME && cpi->Source) {
|
if (cpi->common.frame_type == INTER_FRAME && cpi->Source) {
|
||||||
|
YV12_BUFFER_CONFIG *ref_buf;
|
||||||
int frame;
|
int frame;
|
||||||
double H[9] = {0, 0, 0, 0, 0, 0, 0, 0, 1};
|
double H[9] = {0, 0, 0, 0, 0, 0, 0, 0, 1};
|
||||||
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame)
|
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
|
||||||
convert_model_to_params(H, AFFINE, &cm->global_motion[frame]);
|
ref_buf = get_ref_frame_buffer(cpi, frame);
|
||||||
|
if (ref_buf) {
|
||||||
|
if (compute_global_motion_feature_based(
|
||||||
|
cpi, GLOBAL_MOTION_MODEL, cpi->Source, ref_buf,
|
||||||
|
0.5, H))
|
||||||
|
convert_model_to_params(H, GLOBAL_MOTION_MODEL,
|
||||||
|
&cm->global_motion[frame]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // CONFIG_GLOBAL_MOTION
|
#endif // CONFIG_GLOBAL_MOTION
|
||||||
|
|
||||||
|
34
vp10/encoder/global_motion.c
Normal file
34
vp10/encoder/global_motion.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "vp10/common/warped_motion.h"
|
||||||
|
|
||||||
|
#include "vp10/encoder/segmentation.h"
|
||||||
|
#include "vp10/encoder/global_motion.h"
|
||||||
|
|
||||||
|
int compute_global_motion_feature_based(struct VP10_COMP *cpi,
|
||||||
|
TransformationType type,
|
||||||
|
YV12_BUFFER_CONFIG *frm,
|
||||||
|
YV12_BUFFER_CONFIG *ref,
|
||||||
|
double inlier_prob, double *H) {
|
||||||
|
(void) cpi;
|
||||||
|
(void) type;
|
||||||
|
(void) frm;
|
||||||
|
(void) ref;
|
||||||
|
(void) inlier_prob;
|
||||||
|
(void) H;
|
||||||
|
return 0;
|
||||||
|
}
|
30
vp10/encoder/global_motion.h
Normal file
30
vp10/encoder/global_motion.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef VP10_ENCODER_GLOBAL_MOTION_H_
|
||||||
|
#define VP10_ENCODER_GLOBAL_MOTION_H_
|
||||||
|
|
||||||
|
#include "vpx/vpx_integer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int compute_global_motion_feature_based(struct VP10_COMP *cpi,
|
||||||
|
TransformationType type,
|
||||||
|
YV12_BUFFER_CONFIG *frm,
|
||||||
|
YV12_BUFFER_CONFIG *ref,
|
||||||
|
double inlier_prob, double *H);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
#endif // VP10_ENCODER_GLOBAL_MOTION_H_
|
||||||
|
|
@@ -36,6 +36,8 @@ VP10_CX_SRCS-yes += encoder/ethread.h
|
|||||||
VP10_CX_SRCS-yes += encoder/ethread.c
|
VP10_CX_SRCS-yes += encoder/ethread.c
|
||||||
VP10_CX_SRCS-yes += encoder/extend.c
|
VP10_CX_SRCS-yes += encoder/extend.c
|
||||||
VP10_CX_SRCS-yes += encoder/firstpass.c
|
VP10_CX_SRCS-yes += encoder/firstpass.c
|
||||||
|
VP10_CX_SRCS-$(CONFIG_GLOBAL_MOTION) += encoder/global_motion.c
|
||||||
|
VP10_CX_SRCS-$(CONFIG_GLOBAL_MOTION) += encoder/global_motion.h
|
||||||
VP10_CX_SRCS-yes += encoder/block.h
|
VP10_CX_SRCS-yes += encoder/block.h
|
||||||
VP10_CX_SRCS-yes += encoder/bitstream.h
|
VP10_CX_SRCS-yes += encoder/bitstream.h
|
||||||
VP10_CX_SRCS-yes += encoder/encodemb.h
|
VP10_CX_SRCS-yes += encoder/encodemb.h
|
||||||
|
Reference in New Issue
Block a user