1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vpx/svc_context.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,142 @@ 1.4 +/* 1.5 + * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +/** 1.15 + * SvcContext - input parameters and state to encode a multi-layered 1.16 + * spatial SVC frame 1.17 + */ 1.18 + 1.19 +#ifndef VPX_SVC_CONTEXT_H_ 1.20 +#define VPX_SVC_CONTEXT_H_ 1.21 + 1.22 +#include "vpx/vp8cx.h" 1.23 +#include "vpx/vpx_encoder.h" 1.24 + 1.25 +#ifdef __cplusplus 1.26 +extern "C" { 1.27 +#endif 1.28 + 1.29 +typedef enum SVC_ENCODING_MODE { 1.30 + INTER_LAYER_PREDICTION_I, 1.31 + ALT_INTER_LAYER_PREDICTION_IP, 1.32 + INTER_LAYER_PREDICTION_IP, 1.33 + USE_GOLDEN_FRAME 1.34 +} SVC_ENCODING_MODE; 1.35 + 1.36 +typedef enum SVC_LOG_LEVEL { 1.37 + SVC_LOG_ERROR, 1.38 + SVC_LOG_INFO, 1.39 + SVC_LOG_DEBUG 1.40 +} SVC_LOG_LEVEL; 1.41 + 1.42 +typedef struct { 1.43 + // public interface to svc_command options 1.44 + int spatial_layers; // number of layers 1.45 + int first_frame_full_size; // set to one to force first frame full size 1.46 + SVC_ENCODING_MODE encoding_mode; // svc encoding strategy 1.47 + SVC_LOG_LEVEL log_level; // amount of information to display 1.48 + int log_print; // when set, printf log messages instead of returning the 1.49 + // message with svc_get_message 1.50 + 1.51 + // private storage for vpx_svc_encode 1.52 + void *internal; 1.53 +} SvcContext; 1.54 + 1.55 +/** 1.56 + * Set SVC options 1.57 + * options are supplied as a single string separated by spaces 1.58 + * Format: encoding-mode=<i|ip|alt-ip|gf> 1.59 + * layers=<layer_count> 1.60 + * scaling-factors=<n1>/<d1>,<n2>/<d2>,... 1.61 + * quantizers=<q1>,<q2>,... 1.62 + */ 1.63 +vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options); 1.64 + 1.65 +/** 1.66 + * Set SVC quantizer values 1.67 + * values comma separated, ordered from lowest resolution to highest 1.68 + * e.g., "60,53,39,33,27" 1.69 + */ 1.70 +vpx_codec_err_t vpx_svc_set_quantizers(SvcContext *svc_ctx, 1.71 + const char *quantizer_values); 1.72 + 1.73 +/** 1.74 + * Set SVC scale factors 1.75 + * values comma separated, ordered from lowest resolution to highest 1.76 + * e.g., "4/16,5/16,7/16,11/16,16/16" 1.77 + */ 1.78 +vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx, 1.79 + const char *scale_factors); 1.80 + 1.81 +/** 1.82 + * initialize SVC encoding 1.83 + */ 1.84 +vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, 1.85 + vpx_codec_iface_t *iface, 1.86 + vpx_codec_enc_cfg_t *cfg); 1.87 +/** 1.88 + * encode a frame of video with multiple layers 1.89 + */ 1.90 +vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, 1.91 + struct vpx_image *rawimg, vpx_codec_pts_t pts, 1.92 + int64_t duration, int deadline); 1.93 + 1.94 +/** 1.95 + * finished with svc encoding, release allocated resources 1.96 + */ 1.97 +void vpx_svc_release(SvcContext *svc_ctx); 1.98 + 1.99 +/** 1.100 + * dump accumulated statistics and reset accumulated values 1.101 + */ 1.102 +const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); 1.103 + 1.104 +/** 1.105 + * get status message from previous encode 1.106 + */ 1.107 +const char *vpx_svc_get_message(const SvcContext *svc_ctx); 1.108 + 1.109 +/** 1.110 + * return size of encoded data to be returned by vpx_svc_get_buffer 1.111 + */ 1.112 +size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx); 1.113 + 1.114 +/** 1.115 + * return buffer with encoded data 1.116 + */ 1.117 +void *vpx_svc_get_buffer(const SvcContext *svc_ctx); 1.118 + 1.119 +/** 1.120 + * return spatial resolution of the specified layer 1.121 + */ 1.122 +vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx, 1.123 + int layer, 1.124 + unsigned int *width, 1.125 + unsigned int *height); 1.126 +/** 1.127 + * return number of frames that have been encoded 1.128 + */ 1.129 +int vpx_svc_get_encode_frame_count(const SvcContext *svc_ctx); 1.130 + 1.131 +/** 1.132 + * return 1 if last encoded frame was a keyframe 1.133 + */ 1.134 +int vpx_svc_is_keyframe(const SvcContext *svc_ctx); 1.135 + 1.136 +/** 1.137 + * force the next frame to be a keyframe 1.138 + */ 1.139 +void vpx_svc_set_keyframe(SvcContext *svc_ctx); 1.140 + 1.141 +#ifdef __cplusplus 1.142 +} // extern "C" 1.143 +#endif 1.144 + 1.145 +#endif /* VPX_SVC_CONTEXT_H_ */