1167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org/*
2167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *
4167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  Use of this source code is governed by a BSD-style license
5167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  that can be found in the LICENSE file in the root of the source
6167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  tree. An additional intellectual property rights grant can be found
7167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  in the file PATENTS.  All contributing project authors may
8167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org *  be found in the AUTHORS file in the root of the source tree.
9167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org */
10167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
11167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
12167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include <limits.h>
13167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include "vpx_config.h"
14167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include "onyx_int.h"
15167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include "mr_dissim.h"
16167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include "vpx_mem/vpx_mem.h"
17167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#include "rdopt.h"
18693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com#include "vp8/common/common.h"
19167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
20167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.orgvoid vp8_cal_low_res_mb_cols(VP8_COMP *cpi)
21167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org{
22167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    int low_res_w;
23167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
24167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    /* Support arbitrary down-sampling factor */
25167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    unsigned int iw = cpi->oxcf.Width*cpi->oxcf.mr_down_sampling_factor.den
26167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                      + cpi->oxcf.mr_down_sampling_factor.num - 1;
27167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
28167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    low_res_w = iw/cpi->oxcf.mr_down_sampling_factor.num;
29167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    cpi->mr_low_res_mb_cols = ((low_res_w + 15) >> 4);
30167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org}
31167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
32167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#define GET_MV(x)    \
33167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.orgif(x->mbmi.ref_frame !=INTRA_FRAME)   \
34167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org{   \
35167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    mvx[cnt] = x->mbmi.mv.as_mv.row;  \
36167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    mvy[cnt] = x->mbmi.mv.as_mv.col;  \
37167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    cnt++;    \
38167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org}
39167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
40167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org#define GET_MV_SIGN(x)    \
41167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.orgif(x->mbmi.ref_frame !=INTRA_FRAME)   \
42167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org{   \
43167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    mvx[cnt] = x->mbmi.mv.as_mv.row;  \
44167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    mvy[cnt] = x->mbmi.mv.as_mv.col;  \
45167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    if (cm->ref_frame_sign_bias[x->mbmi.ref_frame]  \
46167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        != cm->ref_frame_sign_bias[tmp->mbmi.ref_frame])  \
47167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    {  \
48167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        mvx[cnt] *= -1;   \
49167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        mvy[cnt] *= -1;   \
50167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    }  \
51167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    cnt++;  \
52167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org}
53167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
54167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.orgvoid vp8_cal_dissimilarity(VP8_COMP *cpi)
55167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org{
56167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    VP8_COMMON *cm = &cpi->common;
57ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org    int i;
58167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
59167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    /* Note: The first row & first column in mip are outside the frame, which
60167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org     * were initialized to all 0.(ref_frame, mode, mv...)
61167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org     * Their ref_frame = 0 means they won't be counted in the following
62167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org     * calculation.
63167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org     */
64167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    if (cpi->oxcf.mr_total_resolutions >1
65167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        && cpi->oxcf.mr_encoder_id < (cpi->oxcf.mr_total_resolutions - 1))
66167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    {
67167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        /* Store info for show/no-show frames for supporting alt_ref.
68167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org         * If parent frame is alt_ref, child has one too.
69167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org         */
70ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        LOWER_RES_FRAME_INFO* store_info
71ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org                      = (LOWER_RES_FRAME_INFO*)cpi->oxcf.mr_low_res_mode_info;
72ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org
73ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        store_info->frame_type = cm->frame_type;
74ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org
75ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        if(cm->frame_type != KEY_FRAME)
76ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        {
77ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org            store_info->is_frame_dropped = 0;
78ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org            for (i = 1; i < MAX_REF_FRAMES; i++)
79ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org                store_info->low_res_ref_frames[i] = cpi->current_ref_frames[i];
80ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        }
81ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org
82167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        if(cm->frame_type != KEY_FRAME)
83167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        {
84167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            int mb_row;
85167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            int mb_col;
86167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            /* Point to beginning of allocated MODE_INFO arrays. */
87167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            MODE_INFO *tmp = cm->mip + cm->mode_info_stride;
88ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org            LOWER_RES_MB_INFO* store_mode_info = store_info->mb_info;
89167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
90167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            for (mb_row = 0; mb_row < cm->mb_rows; mb_row ++)
91167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            {
92167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                tmp++;
93167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                for (mb_col = 0; mb_col < cm->mb_cols; mb_col ++)
94167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                {
95167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    int dissim = INT_MAX;
96167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
97167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    if(tmp->mbmi.ref_frame !=INTRA_FRAME)
98167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    {
99167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        int              mvx[8];
100167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        int              mvy[8];
101167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        int              mmvx;
102167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        int              mmvy;
103167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        int              cnt=0;
104167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *here = tmp;
105167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *above = here - cm->mode_info_stride;
106167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *left = here - 1;
107167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *aboveleft = above - 1;
108167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *aboveright = NULL;
109167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *right = NULL;
110167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *belowleft = NULL;
111167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *below = NULL;
112167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        const MODE_INFO *belowright = NULL;
113167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
114167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        /* If alternate reference frame is used, we have to
115167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                         * check sign of MV. */
116167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        if(cpi->oxcf.play_alternate)
117167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        {
118167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            /* Gather mv of neighboring MBs */
119167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV_SIGN(above)
120167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV_SIGN(left)
121167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV_SIGN(aboveleft)
122167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
123167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_col < (cm->mb_cols-1))
124167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
125167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                right = here + 1;
126167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                aboveright = above + 1;
127167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV_SIGN(right)
128167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV_SIGN(aboveright)
129167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
130167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
131167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_row < (cm->mb_rows-1))
132167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
133167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                below = here + cm->mode_info_stride;
134167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                belowleft = below - 1;
135167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV_SIGN(below)
136167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV_SIGN(belowleft)
137167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
138167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
139167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_col < (cm->mb_cols-1)
140167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                && mb_row < (cm->mb_rows-1))
141167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
142167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                belowright = below + 1;
143167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV_SIGN(belowright)
144167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
145167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        }else
146167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        {
147167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            /* No alt_ref and gather mv of neighboring MBs */
148167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV(above)
149167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV(left)
150167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            GET_MV(aboveleft)
151167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
152167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_col < (cm->mb_cols-1))
153167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
154167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                right = here + 1;
155167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                aboveright = above + 1;
156167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV(right)
157167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV(aboveright)
158167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
159167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
160167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_row < (cm->mb_rows-1))
161167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
162167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                below = here + cm->mode_info_stride;
163167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                belowleft = below - 1;
164167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV(below)
165167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV(belowleft)
166167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
167167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
168167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if(mb_col < (cm->mb_cols-1)
169167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                && mb_row < (cm->mb_rows-1))
170167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
171167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                belowright = below + 1;
172167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                GET_MV(belowright)
173167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
174167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        }
175167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
176167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        if (cnt > 0)
177167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        {
178167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            int max_mvx = mvx[0];
179167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            int min_mvx = mvx[0];
180167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            int max_mvy = mvy[0];
181167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            int min_mvy = mvy[0];
182167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            int i;
183167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
184167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            if (cnt > 1)
185167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            {
186167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                for (i=1; i< cnt; i++)
187167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                {
188167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                    if (mvx[i] > max_mvx) max_mvx = mvx[i];
189167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                    else if (mvx[i] < min_mvx) min_mvx = mvx[i];
190167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                    if (mvy[i] > max_mvy) max_mvy = mvy[i];
191167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                    else if (mvy[i] < min_mvy) min_mvy = mvy[i];
192167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                }
193167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            }
194167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
195167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            mmvx = MAX(abs(min_mvx - here->mbmi.mv.as_mv.row),
196167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                       abs(max_mvx - here->mbmi.mv.as_mv.row));
197167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            mmvy = MAX(abs(min_mvy - here->mbmi.mv.as_mv.col),
198167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                                       abs(max_mvy - here->mbmi.mv.as_mv.col));
199167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                            dissim = MAX(mmvx, mmvy);
200167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                        }
201167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    }
202167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org
203167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    /* Store mode info for next resolution encoding */
204167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    store_mode_info->mode = tmp->mbmi.mode;
205167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    store_mode_info->ref_frame = tmp->mbmi.ref_frame;
206167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    store_mode_info->mv.as_int = tmp->mbmi.mv.as_int;
207167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    store_mode_info->dissim = dissim;
208167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    tmp++;
209167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                    store_mode_info++;
210167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org                }
211167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org            }
212167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org        }
213167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org    }
214167514562bbce1eb0566271d6cb41d90d2b5ffa0hclam@chromium.org}
215ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org
216ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org/* This function is called only when this frame is dropped at current
217ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org   resolution level. */
218ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.orgvoid vp8_store_drop_frame_info(VP8_COMP *cpi)
219ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org{
220ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org    /* If the frame is dropped in lower-resolution encoding, this information
221ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org       is passed to higher resolution level so that the encoder knows there
222ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org       is no mode & motion info available.
223ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org     */
224ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org    if (cpi->oxcf.mr_total_resolutions >1
225ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        && cpi->oxcf.mr_encoder_id < (cpi->oxcf.mr_total_resolutions - 1))
226ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org    {
227ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        /* Store info for show/no-show frames for supporting alt_ref.
228ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org         * If parent frame is alt_ref, child has one too.
229ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org         */
230ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        LOWER_RES_FRAME_INFO* store_info
231ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org                      = (LOWER_RES_FRAME_INFO*)cpi->oxcf.mr_low_res_mode_info;
232ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org
233ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        /* Set frame_type to be INTER_FRAME since we won't drop key frame. */
234ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        store_info->frame_type = INTER_FRAME;
235ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org        store_info->is_frame_dropped = 1;
236ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org    }
237ed759d81a39febed3a8a395386639d54307504aagrunell@chromium.org}
238