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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_lookahead.c

Issue 898943004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_lookahead.h ('k') | source/libvpx/vp9/encoder/vp9_mcomp.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) 2011 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 #include <assert.h> 10 #include <assert.h>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 return ctx; 84 return ctx;
85 bail: 85 bail:
86 vp9_lookahead_destroy(ctx); 86 vp9_lookahead_destroy(ctx);
87 return NULL; 87 return NULL;
88 } 88 }
89 89
90 #define USE_PARTIAL_COPY 0 90 #define USE_PARTIAL_COPY 0
91 91
92 int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, 92 int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
93 int64_t ts_start, int64_t ts_end, unsigned int flags) { 93 int64_t ts_start, int64_t ts_end,
94 #if CONFIG_VP9_HIGHBITDEPTH
95 int use_highbitdepth,
96 #endif
97 unsigned int flags) {
94 struct lookahead_entry *buf; 98 struct lookahead_entry *buf;
95 #if USE_PARTIAL_COPY 99 #if USE_PARTIAL_COPY
96 int row, col, active_end; 100 int row, col, active_end;
97 int mb_rows = (src->y_height + 15) >> 4; 101 int mb_rows = (src->y_height + 15) >> 4;
98 int mb_cols = (src->y_width + 15) >> 4; 102 int mb_cols = (src->y_width + 15) >> 4;
99 #endif 103 #endif
104 int width = src->y_crop_width;
105 int height = src->y_crop_height;
106 int uv_width = src->uv_crop_width;
107 int uv_height = src->uv_crop_height;
108 int subsampling_x = src->subsampling_x;
109 int subsampling_y = src->subsampling_y;
110 int larger_dimensions, new_dimensions;
100 111
101 if (ctx->sz + 1 + MAX_PRE_FRAMES > ctx->max_sz) 112 if (ctx->sz + 1 + MAX_PRE_FRAMES > ctx->max_sz)
102 return 1; 113 return 1;
103 ctx->sz++; 114 ctx->sz++;
104 buf = pop(ctx, &ctx->write_idx); 115 buf = pop(ctx, &ctx->write_idx);
105 116
117 new_dimensions = width != buf->img.y_crop_width ||
118 height != buf->img.y_crop_height ||
119 uv_width != buf->img.uv_crop_width ||
120 uv_height != buf->img.uv_crop_height;
121 larger_dimensions = width > buf->img.y_width ||
122 height > buf->img.y_height ||
123 uv_width > buf->img.uv_width ||
124 uv_height > buf->img.uv_height;
125 assert(!larger_dimensions || new_dimensions);
126
106 #if USE_PARTIAL_COPY 127 #if USE_PARTIAL_COPY
107 // TODO(jkoleszar): This is disabled for now, as 128 // TODO(jkoleszar): This is disabled for now, as
108 // vp9_copy_and_extend_frame_with_rect is not subsampling/alpha aware. 129 // vp9_copy_and_extend_frame_with_rect is not subsampling/alpha aware.
109 130
110 // Only do this partial copy if the following conditions are all met: 131 // Only do this partial copy if the following conditions are all met:
111 // 1. Lookahead queue has has size of 1. 132 // 1. Lookahead queue has has size of 1.
112 // 2. Active map is provided. 133 // 2. Active map is provided.
113 // 3. This is not a key frame, golden nor altref frame. 134 // 3. This is not a key frame, golden nor altref frame.
114 if (ctx->max_sz == 1 && active_map && !flags) { 135 if (!new_dimensions && ctx->max_sz == 1 && active_map && !flags) {
115 for (row = 0; row < mb_rows; ++row) { 136 for (row = 0; row < mb_rows; ++row) {
116 col = 0; 137 col = 0;
117 138
118 while (1) { 139 while (1) {
119 // Find the first active macroblock in this row. 140 // Find the first active macroblock in this row.
120 for (; col < mb_cols; ++col) { 141 for (; col < mb_cols; ++col) {
121 if (active_map[col]) 142 if (active_map[col])
122 break; 143 break;
123 } 144 }
124 145
(...skipping 15 matching lines...) Expand all
140 col << 4, 16, 161 col << 4, 16,
141 (active_end - col) << 4); 162 (active_end - col) << 4);
142 163
143 // Start again from the end of this active region. 164 // Start again from the end of this active region.
144 col = active_end; 165 col = active_end;
145 } 166 }
146 167
147 active_map += mb_cols; 168 active_map += mb_cols;
148 } 169 }
149 } else { 170 } else {
171 #endif
172 if (larger_dimensions) {
173 YV12_BUFFER_CONFIG new_img;
174 memset(&new_img, 0, sizeof(new_img));
175 if (vp9_alloc_frame_buffer(&new_img,
176 width, height, subsampling_x, subsampling_y,
177 #if CONFIG_VP9_HIGHBITDEPTH
178 use_highbitdepth,
179 #endif
180 VP9_ENC_BORDER_IN_PIXELS,
181 0))
182 return 1;
183 vp9_free_frame_buffer(&buf->img);
184 buf->img = new_img;
185 } else if (new_dimensions) {
186 buf->img.y_crop_width = src->y_crop_width;
187 buf->img.y_crop_height = src->y_crop_height;
188 buf->img.uv_crop_width = src->uv_crop_width;
189 buf->img.uv_crop_height = src->uv_crop_height;
190 buf->img.subsampling_x = src->subsampling_x;
191 buf->img.subsampling_y = src->subsampling_y;
192 }
193 // Partial copy not implemented yet
150 vp9_copy_and_extend_frame(src, &buf->img); 194 vp9_copy_and_extend_frame(src, &buf->img);
195 #if USE_PARTIAL_COPY
151 } 196 }
152 #else
153 // Partial copy not implemented yet
154 vp9_copy_and_extend_frame(src, &buf->img);
155 #endif 197 #endif
156 198
157 buf->ts_start = ts_start; 199 buf->ts_start = ts_start;
158 buf->ts_end = ts_end; 200 buf->ts_end = ts_end;
159 buf->flags = flags; 201 buf->flags = flags;
160 return 0; 202 return 0;
161 } 203 }
162 204
163 205
164 struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx, 206 struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
(...skipping 29 matching lines...) Expand all
194 buf = ctx->buf + index; 236 buf = ctx->buf + index;
195 } 237 }
196 } 238 }
197 239
198 return buf; 240 return buf;
199 } 241 }
200 242
201 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) { 243 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) {
202 return ctx->sz; 244 return ctx->sz;
203 } 245 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_lookahead.h ('k') | source/libvpx/vp9/encoder/vp9_mcomp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698