OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 23 matching lines...) Expand all Loading... |
34 int spatial_layers; // number of spatial layers | 34 int spatial_layers; // number of spatial layers |
35 int temporal_layers; // number of temporal layers | 35 int temporal_layers; // number of temporal layers |
36 SVC_LOG_LEVEL log_level; // amount of information to display | 36 SVC_LOG_LEVEL log_level; // amount of information to display |
37 int log_print; // when set, printf log messages instead of returning the | 37 int log_print; // when set, printf log messages instead of returning the |
38 // message with svc_get_message | 38 // message with svc_get_message |
39 | 39 |
40 // private storage for vpx_svc_encode | 40 // private storage for vpx_svc_encode |
41 void *internal; | 41 void *internal; |
42 } SvcContext; | 42 } SvcContext; |
43 | 43 |
| 44 #define OPTION_BUFFER_SIZE 1024 |
| 45 #define COMPONENTS 4 // psnr & sse statistics maintained for total, y, u, v |
| 46 |
| 47 typedef struct SvcInternal { |
| 48 char options[OPTION_BUFFER_SIZE]; // set by vpx_svc_set_options |
| 49 |
| 50 // values extracted from option, quantizers |
| 51 vpx_svc_extra_cfg_t svc_params; |
| 52 int enable_auto_alt_ref[VPX_SS_MAX_LAYERS]; |
| 53 int bitrates[VPX_SS_MAX_LAYERS]; |
| 54 |
| 55 // accumulated statistics |
| 56 double psnr_sum[VPX_SS_MAX_LAYERS][COMPONENTS]; // total/Y/U/V |
| 57 uint64_t sse_sum[VPX_SS_MAX_LAYERS][COMPONENTS]; |
| 58 uint32_t bytes_sum[VPX_SS_MAX_LAYERS]; |
| 59 |
| 60 // codec encoding values |
| 61 int width; // width of highest layer |
| 62 int height; // height of highest layer |
| 63 int kf_dist; // distance between keyframes |
| 64 |
| 65 // state variables |
| 66 int psnr_pkt_received; |
| 67 int layer; |
| 68 int use_multiple_frame_contexts; |
| 69 |
| 70 char message_buffer[2048]; |
| 71 vpx_codec_ctx_t *codec_ctx; |
| 72 } SvcInternal_t; |
| 73 |
44 /** | 74 /** |
45 * Set SVC options | 75 * Set SVC options |
46 * options are supplied as a single string separated by spaces | 76 * options are supplied as a single string separated by spaces |
47 * Format: encoding-mode=<i|ip|alt-ip|gf> | 77 * Format: encoding-mode=<i|ip|alt-ip|gf> |
48 * layers=<layer_count> | 78 * layers=<layer_count> |
49 * scaling-factors=<n1>/<d1>,<n2>/<d2>,... | 79 * scaling-factors=<n1>/<d1>,<n2>/<d2>,... |
50 * quantizers=<q1>,<q2>,... | 80 * quantizers=<q1>,<q2>,... |
51 */ | 81 */ |
52 vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options); | 82 vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options); |
53 | 83 |
54 /** | 84 /** |
55 * initialize SVC encoding | 85 * initialize SVC encoding |
56 */ | 86 */ |
57 vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, | 87 vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, |
| 88 vpx_codec_ctx_t *codec_ctx, |
58 vpx_codec_iface_t *iface, | 89 vpx_codec_iface_t *iface, |
59 vpx_codec_enc_cfg_t *cfg); | 90 vpx_codec_enc_cfg_t *cfg); |
60 /** | 91 /** |
61 * encode a frame of video with multiple layers | 92 * encode a frame of video with multiple layers |
62 */ | 93 */ |
63 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, | 94 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, |
64 struct vpx_image *rawimg, vpx_codec_pts_t pts, | 95 vpx_codec_ctx_t *codec_ctx, |
| 96 struct vpx_image *rawimg, |
| 97 vpx_codec_pts_t pts, |
65 int64_t duration, int deadline); | 98 int64_t duration, int deadline); |
66 | 99 |
67 /** | 100 /** |
68 * finished with svc encoding, release allocated resources | 101 * finished with svc encoding, release allocated resources |
69 */ | 102 */ |
70 void vpx_svc_release(SvcContext *svc_ctx); | 103 void vpx_svc_release(SvcContext *svc_ctx); |
71 | 104 |
72 /** | 105 /** |
73 * dump accumulated statistics and reset accumulated values | 106 * dump accumulated statistics and reset accumulated values |
74 */ | 107 */ |
75 const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); | 108 const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); |
76 | 109 |
77 /** | 110 /** |
78 * get status message from previous encode | 111 * get status message from previous encode |
79 */ | 112 */ |
80 const char *vpx_svc_get_message(const SvcContext *svc_ctx); | 113 const char *vpx_svc_get_message(const SvcContext *svc_ctx); |
81 | 114 |
82 #ifdef __cplusplus | 115 #ifdef __cplusplus |
83 } // extern "C" | 116 } // extern "C" |
84 #endif | 117 #endif |
85 | 118 |
86 #endif // VPX_SVC_CONTEXT_H_ | 119 #endif // VPX_SVC_CONTEXT_H_ |
OLD | NEW |