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 |
11 #ifndef VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_ | 11 #ifndef VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_ |
12 #define VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_ | 12 #define VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_ |
13 | 13 |
14 #include "vpx/vpx_encoder.h" | 14 #include "vpx/vpx_encoder.h" |
15 | 15 |
16 #include "vp9/encoder/vp9_ratectrl.h" | 16 #include "vp9/encoder/vp9_ratectrl.h" |
17 | 17 |
18 #ifdef __cplusplus | 18 #ifdef __cplusplus |
19 extern "C" { | 19 extern "C" { |
20 #endif | 20 #endif |
21 | 21 |
22 typedef struct { | 22 typedef struct { |
23 RATE_CONTROL rc; | 23 RATE_CONTROL rc; |
24 int target_bandwidth; | 24 int target_bandwidth; |
25 double framerate; | 25 double framerate; |
26 int avg_frame_size; | 26 int avg_frame_size; |
| 27 int max_q; |
| 28 int min_q; |
| 29 int scaling_factor_num; |
| 30 int scaling_factor_den; |
27 TWO_PASS twopass; | 31 TWO_PASS twopass; |
28 vpx_fixed_buf_t rc_twopass_stats_in; | 32 vpx_fixed_buf_t rc_twopass_stats_in; |
29 unsigned int current_video_frame_in_layer; | 33 unsigned int current_video_frame_in_layer; |
30 int is_key_frame; | 34 int is_key_frame; |
31 int frames_from_key_frame; | 35 int frames_from_key_frame; |
32 FRAME_TYPE last_frame_type; | 36 FRAME_TYPE last_frame_type; |
33 vpx_svc_parameters_t svc_params_received; | |
34 struct lookahead_entry *alt_ref_source; | 37 struct lookahead_entry *alt_ref_source; |
35 int alt_ref_idx; | 38 int alt_ref_idx; |
36 int gold_ref_idx; | 39 int gold_ref_idx; |
37 int has_alt_frame; | 40 int has_alt_frame; |
38 size_t layer_size; | 41 size_t layer_size; |
| 42 struct vpx_psnr_pkt psnr_pkt; |
39 } LAYER_CONTEXT; | 43 } LAYER_CONTEXT; |
40 | 44 |
41 typedef struct { | 45 typedef struct { |
42 int spatial_layer_id; | 46 int spatial_layer_id; |
43 int temporal_layer_id; | 47 int temporal_layer_id; |
44 int number_spatial_layers; | 48 int number_spatial_layers; |
45 int number_temporal_layers; | 49 int number_temporal_layers; |
46 | 50 |
| 51 int spatial_layer_to_encode; |
| 52 |
47 // Store scaled source frames to be used for temporal filter to generate | 53 // Store scaled source frames to be used for temporal filter to generate |
48 // a alt ref frame. | 54 // a alt ref frame. |
49 YV12_BUFFER_CONFIG scaled_frames[MAX_LAG_BUFFERS]; | 55 YV12_BUFFER_CONFIG scaled_frames[MAX_LAG_BUFFERS]; |
50 | 56 |
51 // Layer context used for rate control in one pass temporal CBR mode or | 57 // Layer context used for rate control in one pass temporal CBR mode or |
52 // two pass spatial mode. Defined for temporal or spatial layers for now. | 58 // two pass spatial mode. Defined for temporal or spatial layers for now. |
53 // Does not support temporal combined with spatial RC. | 59 // Does not support temporal combined with spatial RC. |
54 LAYER_CONTEXT layer_context[MAX(VPX_TS_MAX_LAYERS, VPX_SS_MAX_LAYERS)]; | 60 LAYER_CONTEXT layer_context[MAX(VPX_TS_MAX_LAYERS, VPX_SS_MAX_LAYERS)]; |
55 } SVC; | 61 } SVC; |
56 | 62 |
(...skipping 23 matching lines...) Expand all Loading... |
80 | 86 |
81 // Initialize second pass rc for spatial svc. | 87 // Initialize second pass rc for spatial svc. |
82 void vp9_init_second_pass_spatial_svc(struct VP9_COMP *cpi); | 88 void vp9_init_second_pass_spatial_svc(struct VP9_COMP *cpi); |
83 | 89 |
84 // Increment number of video frames in layer | 90 // Increment number of video frames in layer |
85 void vp9_inc_frame_in_layer(struct VP9_COMP *const cpi); | 91 void vp9_inc_frame_in_layer(struct VP9_COMP *const cpi); |
86 | 92 |
87 // Check if current layer is key frame in spatial upper layer | 93 // Check if current layer is key frame in spatial upper layer |
88 int vp9_is_upper_layer_key_frame(const struct VP9_COMP *const cpi); | 94 int vp9_is_upper_layer_key_frame(const struct VP9_COMP *const cpi); |
89 | 95 |
90 // Copy the source image, flags and svc parameters into a new framebuffer | |
91 // with the expected stride/border | |
92 int vp9_svc_lookahead_push(const struct VP9_COMP *const cpi, | |
93 struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, | |
94 int64_t ts_start, int64_t ts_end, | |
95 unsigned int flags); | |
96 | |
97 // Get the next source buffer to encode | 96 // Get the next source buffer to encode |
98 struct lookahead_entry *vp9_svc_lookahead_pop(struct VP9_COMP *const cpi, | 97 struct lookahead_entry *vp9_svc_lookahead_pop(struct VP9_COMP *const cpi, |
99 struct lookahead_ctx *ctx, | 98 struct lookahead_ctx *ctx, |
100 int drain); | 99 int drain); |
101 | 100 |
102 // Get a future source buffer to encode | 101 // Start a frame and initialize svc parameters |
103 struct lookahead_entry *vp9_svc_lookahead_peek(struct VP9_COMP *const cpi, | 102 int vp9_svc_start_frame(struct VP9_COMP *const cpi); |
104 struct lookahead_ctx *ctx, | |
105 int index, int copy_params); | |
106 | 103 |
107 #ifdef __cplusplus | 104 #ifdef __cplusplus |
108 } // extern "C" | 105 } // extern "C" |
109 #endif | 106 #endif |
110 | 107 |
111 #endif // VP9_ENCODER_VP9_SVC_LAYERCONTEXT_ | 108 #endif // VP9_ENCODER_VP9_SVC_LAYERCONTEXT_ |
OLD | NEW |