]> granicus.if.org Git - libvpx/blob - vp10/encoder/svc_layercontext.h
Merge "VPX: removed step checks from neon convolve code"
[libvpx] / vp10 / encoder / svc_layercontext.h
1 /*
2  *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #ifndef VP10_ENCODER_SVC_LAYERCONTEXT_H_
12 #define VP10_ENCODER_SVC_LAYERCONTEXT_H_
13
14 #include "vpx/vpx_encoder.h"
15
16 #include "vp10/encoder/ratectrl.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 typedef struct {
23   RATE_CONTROL rc;
24   int target_bandwidth;
25   int spatial_layer_target_bandwidth;  // Target for the spatial layer.
26   double framerate;
27   int avg_frame_size;
28   int max_q;
29   int min_q;
30   int scaling_factor_num;
31   int scaling_factor_den;
32   TWO_PASS twopass;
33   vpx_fixed_buf_t rc_twopass_stats_in;
34   unsigned int current_video_frame_in_layer;
35   int is_key_frame;
36   int frames_from_key_frame;
37   FRAME_TYPE last_frame_type;
38   struct lookahead_entry  *alt_ref_source;
39   int alt_ref_idx;
40   int gold_ref_idx;
41   int has_alt_frame;
42   size_t layer_size;
43   struct vpx_psnr_pkt psnr_pkt;
44 } LAYER_CONTEXT;
45
46 typedef struct {
47   int spatial_layer_id;
48   int temporal_layer_id;
49   int number_spatial_layers;
50   int number_temporal_layers;
51
52   int spatial_layer_to_encode;
53
54   // Workaround for multiple frame contexts
55   enum {
56     ENCODED = 0,
57     ENCODING,
58     NEED_TO_ENCODE
59   }encode_empty_frame_state;
60   struct lookahead_entry empty_frame;
61   int encode_intra_empty_frame;
62
63   // Store scaled source frames to be used for temporal filter to generate
64   // a alt ref frame.
65   YV12_BUFFER_CONFIG scaled_frames[MAX_LAG_BUFFERS];
66
67   // Layer context used for rate control in one pass temporal CBR mode or
68   // two pass spatial mode.
69   LAYER_CONTEXT layer_context[VPX_MAX_LAYERS];
70   // Indicates what sort of temporal layering is used.
71   // Currently, this only works for CBR mode.
72   VP9E_TEMPORAL_LAYERING_MODE temporal_layering_mode;
73 } SVC;
74
75 struct VP10_COMP;
76
77 // Initialize layer context data from init_config().
78 void vp10_init_layer_context(struct VP10_COMP *const cpi);
79
80 // Update the layer context from a change_config() call.
81 void vp10_update_layer_context_change_config(struct VP10_COMP *const cpi,
82                                             const int target_bandwidth);
83
84 // Prior to encoding the frame, update framerate-related quantities
85 // for the current temporal layer.
86 void vp10_update_temporal_layer_framerate(struct VP10_COMP *const cpi);
87
88 // Update framerate-related quantities for the current spatial layer.
89 void vp10_update_spatial_layer_framerate(struct VP10_COMP *const cpi,
90                                         double framerate);
91
92 // Prior to encoding the frame, set the layer context, for the current layer
93 // to be encoded, to the cpi struct.
94 void vp10_restore_layer_context(struct VP10_COMP *const cpi);
95
96 // Save the layer context after encoding the frame.
97 void vp10_save_layer_context(struct VP10_COMP *const cpi);
98
99 // Initialize second pass rc for spatial svc.
100 void vp10_init_second_pass_spatial_svc(struct VP10_COMP *cpi);
101
102 // Increment number of video frames in layer
103 void vp10_inc_frame_in_layer(struct VP10_COMP *const cpi);
104
105 // Check if current layer is key frame in spatial upper layer
106 int vp10_is_upper_layer_key_frame(const struct VP10_COMP *const cpi);
107
108 // Get the next source buffer to encode
109 struct lookahead_entry *vp10_svc_lookahead_pop(struct VP10_COMP *const cpi,
110                                               struct lookahead_ctx *ctx,
111                                               int drain);
112
113 // Start a frame and initialize svc parameters
114 int vp10_svc_start_frame(struct VP10_COMP *const cpi);
115
116 int vp10_one_pass_cbr_svc_start_layer(struct VP10_COMP *const cpi);
117
118 #ifdef __cplusplus
119 }  // extern "C"
120 #endif
121
122 #endif  // VP10_ENCODER_SVC_LAYERCONTEXT_