OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 w += w % 2; | 272 w += w % 2; |
273 h += h % 2; | 273 h += h % 2; |
274 | 274 |
275 *width_out = w; | 275 *width_out = w; |
276 *height_out = h; | 276 *height_out = h; |
277 } | 277 } |
278 | 278 |
279 int vp9_svc_start_frame(VP9_COMP *const cpi) { | 279 int vp9_svc_start_frame(VP9_COMP *const cpi) { |
280 int width = 0, height = 0; | 280 int width = 0, height = 0; |
281 LAYER_CONTEXT *lc; | 281 LAYER_CONTEXT *lc; |
| 282 struct lookahead_entry *buf; |
282 int count = 1 << (cpi->svc.number_temporal_layers - 1); | 283 int count = 1 << (cpi->svc.number_temporal_layers - 1); |
283 | 284 |
284 cpi->svc.spatial_layer_id = cpi->svc.spatial_layer_to_encode; | 285 cpi->svc.spatial_layer_id = cpi->svc.spatial_layer_to_encode; |
285 lc = &cpi->svc.layer_context[cpi->svc.spatial_layer_id]; | 286 lc = &cpi->svc.layer_context[cpi->svc.spatial_layer_id]; |
286 | 287 |
287 cpi->svc.temporal_layer_id = 0; | 288 cpi->svc.temporal_layer_id = 0; |
288 while ((lc->current_video_frame_in_layer % count) != 0) { | 289 while ((lc->current_video_frame_in_layer % count) != 0) { |
289 ++cpi->svc.temporal_layer_id; | 290 ++cpi->svc.temporal_layer_id; |
290 count >>= 1; | 291 count >>= 1; |
291 } | 292 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 333 } |
333 | 334 |
334 get_layer_resolution(cpi->oxcf.width, cpi->oxcf.height, | 335 get_layer_resolution(cpi->oxcf.width, cpi->oxcf.height, |
335 lc->scaling_factor_num, lc->scaling_factor_den, | 336 lc->scaling_factor_num, lc->scaling_factor_den, |
336 &width, &height); | 337 &width, &height); |
337 | 338 |
338 // Workaround for multiple frame contexts. In some frames we can't use prev_mi | 339 // Workaround for multiple frame contexts. In some frames we can't use prev_mi |
339 // since its previous frame could be changed during decoding time. The idea is | 340 // since its previous frame could be changed during decoding time. The idea is |
340 // we put a empty invisible frame in front of them, then we will not use | 341 // we put a empty invisible frame in front of them, then we will not use |
341 // prev_mi when encoding these frames. | 342 // prev_mi when encoding these frames. |
| 343 |
| 344 buf = vp9_lookahead_peek(cpi->lookahead, 0); |
342 if (cpi->oxcf.error_resilient_mode == 0 && cpi->oxcf.pass == 2 && | 345 if (cpi->oxcf.error_resilient_mode == 0 && cpi->oxcf.pass == 2 && |
343 cpi->svc.encode_empty_frame_state == NEED_TO_ENCODE) { | 346 cpi->svc.encode_empty_frame_state == NEED_TO_ENCODE && |
| 347 lc->rc.frames_to_key != 0 && |
| 348 !(buf != NULL && (buf->flags & VPX_EFLAG_FORCE_KF))) { |
344 if ((cpi->svc.number_temporal_layers > 1 && | 349 if ((cpi->svc.number_temporal_layers > 1 && |
345 cpi->svc.temporal_layer_id < cpi->svc.number_temporal_layers - 1) || | 350 cpi->svc.temporal_layer_id < cpi->svc.number_temporal_layers - 1) || |
346 (cpi->svc.number_spatial_layers > 1 && | 351 (cpi->svc.number_spatial_layers > 1 && |
347 cpi->svc.spatial_layer_id == 0)) { | 352 cpi->svc.spatial_layer_id == 0)) { |
348 struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead, 0); | 353 struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead, 0); |
349 | 354 |
350 if (buf != NULL) { | 355 if (buf != NULL) { |
351 cpi->svc.empty_frame.ts_start = buf->ts_start; | 356 cpi->svc.empty_frame.ts_start = buf->ts_start; |
352 cpi->svc.empty_frame.ts_end = buf->ts_end; | 357 cpi->svc.empty_frame.ts_end = buf->ts_end; |
353 cpi->svc.encode_empty_frame_state = ENCODING; | 358 cpi->svc.encode_empty_frame_state = ENCODING; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // Only remove the buffer when pop the highest layer. | 405 // Only remove the buffer when pop the highest layer. |
401 if (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1) { | 406 if (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1) { |
402 vp9_lookahead_pop(ctx, drain); | 407 vp9_lookahead_pop(ctx, drain); |
403 } | 408 } |
404 } | 409 } |
405 } | 410 } |
406 | 411 |
407 return buf; | 412 return buf; |
408 } | 413 } |
409 #endif | 414 #endif |
OLD | NEW |