Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: source/libvpx/vp9/common/vp9_scale.c

Issue 375983002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/common/vp9_scale.h ('k') | source/libvpx/vp9/decoder/vp9_decodeframe.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 static int get_fixed_point_scale_factor(int other_size, int this_size) { 28 static int get_fixed_point_scale_factor(int other_size, int this_size) {
29 // Calculate scaling factor once for each reference frame 29 // Calculate scaling factor once for each reference frame
30 // and use fixed point scaling factors in decoding and encoding routines. 30 // and use fixed point scaling factors in decoding and encoding routines.
31 // Hardware implementations can calculate scale factor in device driver 31 // Hardware implementations can calculate scale factor in device driver
32 // and use multiplication and shifting on hardware instead of division. 32 // and use multiplication and shifting on hardware instead of division.
33 return (other_size << REF_SCALE_SHIFT) / this_size; 33 return (other_size << REF_SCALE_SHIFT) / this_size;
34 } 34 }
35 35
36 static int check_scale_factors(int other_w, int other_h,
37 int this_w, int this_h) {
38 return 2 * this_w >= other_w &&
39 2 * this_h >= other_h &&
40 this_w <= 16 * other_w &&
41 this_h <= 16 * other_h;
42 }
43
44 MV32 vp9_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf) { 36 MV32 vp9_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf) {
45 const int x_off_q4 = scaled_x(x << SUBPEL_BITS, sf) & SUBPEL_MASK; 37 const int x_off_q4 = scaled_x(x << SUBPEL_BITS, sf) & SUBPEL_MASK;
46 const int y_off_q4 = scaled_y(y << SUBPEL_BITS, sf) & SUBPEL_MASK; 38 const int y_off_q4 = scaled_y(y << SUBPEL_BITS, sf) & SUBPEL_MASK;
47 const MV32 res = { 39 const MV32 res = {
48 scaled_y(mv->row, sf) + y_off_q4, 40 scaled_y(mv->row, sf) + y_off_q4,
49 scaled_x(mv->col, sf) + x_off_q4 41 scaled_x(mv->col, sf) + x_off_q4
50 }; 42 };
51 return res; 43 return res;
52 } 44 }
53 45
54 void vp9_setup_scale_factors_for_frame(struct scale_factors *sf, 46 void vp9_setup_scale_factors_for_frame(struct scale_factors *sf,
55 int other_w, int other_h, 47 int other_w, int other_h,
56 int this_w, int this_h) { 48 int this_w, int this_h) {
57 if (!check_scale_factors(other_w, other_h, this_w, this_h)) { 49 if (!valid_ref_frame_size(other_w, other_h, this_w, this_h)) {
58 sf->x_scale_fp = REF_INVALID_SCALE; 50 sf->x_scale_fp = REF_INVALID_SCALE;
59 sf->y_scale_fp = REF_INVALID_SCALE; 51 sf->y_scale_fp = REF_INVALID_SCALE;
60 return; 52 return;
61 } 53 }
62 54
63 sf->x_scale_fp = get_fixed_point_scale_factor(other_w, this_w); 55 sf->x_scale_fp = get_fixed_point_scale_factor(other_w, this_w);
64 sf->y_scale_fp = get_fixed_point_scale_factor(other_h, this_h); 56 sf->y_scale_fp = get_fixed_point_scale_factor(other_h, this_h);
65 sf->x_step_q4 = scaled_x(16, sf); 57 sf->x_step_q4 = scaled_x(16, sf);
66 sf->y_step_q4 = scaled_y(16, sf); 58 sf->y_step_q4 = scaled_y(16, sf);
67 59
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 sf->predict[0][1][0] = vp9_convolve8; 105 sf->predict[0][1][0] = vp9_convolve8;
114 sf->predict[0][1][1] = vp9_convolve8_avg; 106 sf->predict[0][1][1] = vp9_convolve8_avg;
115 sf->predict[1][0][0] = vp9_convolve8; 107 sf->predict[1][0][0] = vp9_convolve8;
116 sf->predict[1][0][1] = vp9_convolve8_avg; 108 sf->predict[1][0][1] = vp9_convolve8_avg;
117 } 109 }
118 } 110 }
119 // 2D subpel motion always gets filtered in both directions 111 // 2D subpel motion always gets filtered in both directions
120 sf->predict[1][1][0] = vp9_convolve8; 112 sf->predict[1][1][0] = vp9_convolve8;
121 sf->predict[1][1][1] = vp9_convolve8_avg; 113 sf->predict[1][1][1] = vp9_convolve8_avg;
122 } 114 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_scale.h ('k') | source/libvpx/vp9/decoder/vp9_decodeframe.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698