|
1 /* |
|
2 * Copyright (c) 2013 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 /** |
|
12 * SvcContext - input parameters and state to encode a multi-layered |
|
13 * spatial SVC frame |
|
14 */ |
|
15 |
|
16 #ifndef VPX_SVC_CONTEXT_H_ |
|
17 #define VPX_SVC_CONTEXT_H_ |
|
18 |
|
19 #include "vpx/vp8cx.h" |
|
20 #include "vpx/vpx_encoder.h" |
|
21 |
|
22 #ifdef __cplusplus |
|
23 extern "C" { |
|
24 #endif |
|
25 |
|
26 typedef enum SVC_ENCODING_MODE { |
|
27 INTER_LAYER_PREDICTION_I, |
|
28 ALT_INTER_LAYER_PREDICTION_IP, |
|
29 INTER_LAYER_PREDICTION_IP, |
|
30 USE_GOLDEN_FRAME |
|
31 } SVC_ENCODING_MODE; |
|
32 |
|
33 typedef enum SVC_LOG_LEVEL { |
|
34 SVC_LOG_ERROR, |
|
35 SVC_LOG_INFO, |
|
36 SVC_LOG_DEBUG |
|
37 } SVC_LOG_LEVEL; |
|
38 |
|
39 typedef struct { |
|
40 // public interface to svc_command options |
|
41 int spatial_layers; // number of layers |
|
42 int first_frame_full_size; // set to one to force first frame full size |
|
43 SVC_ENCODING_MODE encoding_mode; // svc encoding strategy |
|
44 SVC_LOG_LEVEL log_level; // amount of information to display |
|
45 int log_print; // when set, printf log messages instead of returning the |
|
46 // message with svc_get_message |
|
47 |
|
48 // private storage for vpx_svc_encode |
|
49 void *internal; |
|
50 } SvcContext; |
|
51 |
|
52 /** |
|
53 * Set SVC options |
|
54 * options are supplied as a single string separated by spaces |
|
55 * Format: encoding-mode=<i|ip|alt-ip|gf> |
|
56 * layers=<layer_count> |
|
57 * scaling-factors=<n1>/<d1>,<n2>/<d2>,... |
|
58 * quantizers=<q1>,<q2>,... |
|
59 */ |
|
60 vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options); |
|
61 |
|
62 /** |
|
63 * Set SVC quantizer values |
|
64 * values comma separated, ordered from lowest resolution to highest |
|
65 * e.g., "60,53,39,33,27" |
|
66 */ |
|
67 vpx_codec_err_t vpx_svc_set_quantizers(SvcContext *svc_ctx, |
|
68 const char *quantizer_values); |
|
69 |
|
70 /** |
|
71 * Set SVC scale factors |
|
72 * values comma separated, ordered from lowest resolution to highest |
|
73 * e.g., "4/16,5/16,7/16,11/16,16/16" |
|
74 */ |
|
75 vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx, |
|
76 const char *scale_factors); |
|
77 |
|
78 /** |
|
79 * initialize SVC encoding |
|
80 */ |
|
81 vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, |
|
82 vpx_codec_iface_t *iface, |
|
83 vpx_codec_enc_cfg_t *cfg); |
|
84 /** |
|
85 * encode a frame of video with multiple layers |
|
86 */ |
|
87 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, |
|
88 struct vpx_image *rawimg, vpx_codec_pts_t pts, |
|
89 int64_t duration, int deadline); |
|
90 |
|
91 /** |
|
92 * finished with svc encoding, release allocated resources |
|
93 */ |
|
94 void vpx_svc_release(SvcContext *svc_ctx); |
|
95 |
|
96 /** |
|
97 * dump accumulated statistics and reset accumulated values |
|
98 */ |
|
99 const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); |
|
100 |
|
101 /** |
|
102 * get status message from previous encode |
|
103 */ |
|
104 const char *vpx_svc_get_message(const SvcContext *svc_ctx); |
|
105 |
|
106 /** |
|
107 * return size of encoded data to be returned by vpx_svc_get_buffer |
|
108 */ |
|
109 size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx); |
|
110 |
|
111 /** |
|
112 * return buffer with encoded data |
|
113 */ |
|
114 void *vpx_svc_get_buffer(const SvcContext *svc_ctx); |
|
115 |
|
116 /** |
|
117 * return spatial resolution of the specified layer |
|
118 */ |
|
119 vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx, |
|
120 int layer, |
|
121 unsigned int *width, |
|
122 unsigned int *height); |
|
123 /** |
|
124 * return number of frames that have been encoded |
|
125 */ |
|
126 int vpx_svc_get_encode_frame_count(const SvcContext *svc_ctx); |
|
127 |
|
128 /** |
|
129 * return 1 if last encoded frame was a keyframe |
|
130 */ |
|
131 int vpx_svc_is_keyframe(const SvcContext *svc_ctx); |
|
132 |
|
133 /** |
|
134 * force the next frame to be a keyframe |
|
135 */ |
|
136 void vpx_svc_set_keyframe(SvcContext *svc_ctx); |
|
137 |
|
138 #ifdef __cplusplus |
|
139 } // extern "C" |
|
140 #endif |
|
141 |
|
142 #endif /* VPX_SVC_CONTEXT_H_ */ |