michael@0: /* michael@0: * Copyright (c) 2013 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: /** michael@0: * SvcContext - input parameters and state to encode a multi-layered michael@0: * spatial SVC frame michael@0: */ michael@0: michael@0: #ifndef VPX_SVC_CONTEXT_H_ michael@0: #define VPX_SVC_CONTEXT_H_ michael@0: michael@0: #include "vpx/vp8cx.h" michael@0: #include "vpx/vpx_encoder.h" michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: typedef enum SVC_ENCODING_MODE { michael@0: INTER_LAYER_PREDICTION_I, michael@0: ALT_INTER_LAYER_PREDICTION_IP, michael@0: INTER_LAYER_PREDICTION_IP, michael@0: USE_GOLDEN_FRAME michael@0: } SVC_ENCODING_MODE; michael@0: michael@0: typedef enum SVC_LOG_LEVEL { michael@0: SVC_LOG_ERROR, michael@0: SVC_LOG_INFO, michael@0: SVC_LOG_DEBUG michael@0: } SVC_LOG_LEVEL; michael@0: michael@0: typedef struct { michael@0: // public interface to svc_command options michael@0: int spatial_layers; // number of layers michael@0: int first_frame_full_size; // set to one to force first frame full size michael@0: SVC_ENCODING_MODE encoding_mode; // svc encoding strategy michael@0: SVC_LOG_LEVEL log_level; // amount of information to display michael@0: int log_print; // when set, printf log messages instead of returning the michael@0: // message with svc_get_message michael@0: michael@0: // private storage for vpx_svc_encode michael@0: void *internal; michael@0: } SvcContext; michael@0: michael@0: /** michael@0: * Set SVC options michael@0: * options are supplied as a single string separated by spaces michael@0: * Format: encoding-mode= michael@0: * layers= michael@0: * scaling-factors=/,/,... michael@0: * quantizers=,,... michael@0: */ michael@0: vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options); michael@0: michael@0: /** michael@0: * Set SVC quantizer values michael@0: * values comma separated, ordered from lowest resolution to highest michael@0: * e.g., "60,53,39,33,27" michael@0: */ michael@0: vpx_codec_err_t vpx_svc_set_quantizers(SvcContext *svc_ctx, michael@0: const char *quantizer_values); michael@0: michael@0: /** michael@0: * Set SVC scale factors michael@0: * values comma separated, ordered from lowest resolution to highest michael@0: * e.g., "4/16,5/16,7/16,11/16,16/16" michael@0: */ michael@0: vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx, michael@0: const char *scale_factors); michael@0: michael@0: /** michael@0: * initialize SVC encoding michael@0: */ michael@0: vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, michael@0: vpx_codec_iface_t *iface, michael@0: vpx_codec_enc_cfg_t *cfg); michael@0: /** michael@0: * encode a frame of video with multiple layers michael@0: */ michael@0: vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, michael@0: struct vpx_image *rawimg, vpx_codec_pts_t pts, michael@0: int64_t duration, int deadline); michael@0: michael@0: /** michael@0: * finished with svc encoding, release allocated resources michael@0: */ michael@0: void vpx_svc_release(SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * dump accumulated statistics and reset accumulated values michael@0: */ michael@0: const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * get status message from previous encode michael@0: */ michael@0: const char *vpx_svc_get_message(const SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * return size of encoded data to be returned by vpx_svc_get_buffer michael@0: */ michael@0: size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * return buffer with encoded data michael@0: */ michael@0: void *vpx_svc_get_buffer(const SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * return spatial resolution of the specified layer michael@0: */ michael@0: vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx, michael@0: int layer, michael@0: unsigned int *width, michael@0: unsigned int *height); michael@0: /** michael@0: * return number of frames that have been encoded michael@0: */ michael@0: int vpx_svc_get_encode_frame_count(const SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * return 1 if last encoded frame was a keyframe michael@0: */ michael@0: int vpx_svc_is_keyframe(const SvcContext *svc_ctx); michael@0: michael@0: /** michael@0: * force the next frame to be a keyframe michael@0: */ michael@0: void vpx_svc_set_keyframe(SvcContext *svc_ctx); michael@0: michael@0: #ifdef __cplusplus michael@0: } // extern "C" michael@0: #endif michael@0: michael@0: #endif /* VPX_SVC_CONTEXT_H_ */