• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_
12 #define VP9_ENCODER_VP9_SVC_LAYERCONTEXT_H_
13 
14 #include "vpx/vpx_encoder.h"
15 
16 #include "vp9/encoder/vp9_ratectrl.h"
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct {
23   RATE_CONTROL rc;
24   int target_bandwidth;
25   int64_t starting_buffer_level;
26   int64_t optimal_buffer_level;
27   int64_t maximum_buffer_size;
28   double framerate;
29   int avg_frame_size;
30   struct twopass_rc twopass;
31   struct vpx_fixed_buf rc_twopass_stats_in;
32   unsigned int current_video_frame_in_layer;
33 } LAYER_CONTEXT;
34 
35 typedef struct {
36   int spatial_layer_id;
37   int temporal_layer_id;
38   int number_spatial_layers;
39   int number_temporal_layers;
40   // Layer context used for rate control in one pass temporal CBR mode or
41   // two pass spatial mode. Defined for temporal or spatial layers for now.
42   // Does not support temporal combined with spatial RC.
43   LAYER_CONTEXT layer_context[MAX(VPX_TS_MAX_LAYERS, VPX_SS_MAX_LAYERS)];
44 } SVC;
45 
46 struct VP9_COMP;
47 
48 // Initialize layer context data from init_config().
49 void vp9_init_layer_context(struct VP9_COMP *const cpi);
50 
51 // Update the layer context from a change_config() call.
52 void vp9_update_layer_context_change_config(struct VP9_COMP *const cpi,
53                                             const int target_bandwidth);
54 
55 // Prior to encoding the frame, update framerate-related quantities
56 // for the current temporal layer.
57 void vp9_update_temporal_layer_framerate(struct VP9_COMP *const cpi);
58 
59 // Update framerate-related quantities for the current spatial layer.
60 void vp9_update_spatial_layer_framerate(struct VP9_COMP *const cpi,
61                                         double framerate);
62 
63 // Prior to encoding the frame, set the layer context, for the current layer
64 // to be encoded, to the cpi struct.
65 void vp9_restore_layer_context(struct VP9_COMP *const cpi);
66 
67 // Save the layer context after encoding the frame.
68 void vp9_save_layer_context(struct VP9_COMP *const cpi);
69 
70 // Initialize second pass rc for spatial svc.
71 void vp9_init_second_pass_spatial_svc(struct VP9_COMP *cpi);
72 
73 #ifdef __cplusplus
74 }  // extern "C"
75 #endif
76 
77 #endif  // VP9_ENCODER_VP9_SVC_LAYERCONTEXT_
78