2013-10-23 22:53:37 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SvcContext - input parameters and state to encode a multi-layered
|
|
|
|
* spatial SVC frame
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VPX_SVC_CONTEXT_H_
|
|
|
|
#define VPX_SVC_CONTEXT_H_
|
|
|
|
|
2013-12-17 01:15:26 +04:00
|
|
|
#include "./vp8cx.h"
|
|
|
|
#include "./vpx_encoder.h"
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum SVC_LOG_LEVEL {
|
|
|
|
SVC_LOG_ERROR,
|
|
|
|
SVC_LOG_INFO,
|
|
|
|
SVC_LOG_DEBUG
|
|
|
|
} SVC_LOG_LEVEL;
|
|
|
|
|
2014-11-18 23:25:31 +03:00
|
|
|
typedef struct {
|
2013-10-23 22:53:37 +04:00
|
|
|
// public interface to svc_command options
|
2014-09-02 23:05:14 +04:00
|
|
|
int spatial_layers; // number of spatial layers
|
|
|
|
int temporal_layers; // number of temporal layers
|
2015-05-22 02:15:37 +03:00
|
|
|
int temporal_layering_mode;
|
2013-10-23 22:53:37 +04:00
|
|
|
SVC_LOG_LEVEL log_level; // amount of information to display
|
|
|
|
int log_print; // when set, printf log messages instead of returning the
|
|
|
|
// message with svc_get_message
|
2015-05-22 02:15:37 +03:00
|
|
|
int output_rc_stat; // for outputting rc stats
|
|
|
|
int speed; // speed setting for codec
|
|
|
|
int threads;
|
2015-09-08 18:47:42 +03:00
|
|
|
int aqmode; // turns on aq-mdoe=3 (cyclic_refresh): 0=off, 1=on.
|
2013-10-23 22:53:37 +04:00
|
|
|
// private storage for vpx_svc_encode
|
|
|
|
void *internal;
|
2014-11-18 23:25:31 +03:00
|
|
|
} SvcContext;
|
2014-11-07 22:01:53 +03:00
|
|
|
|
|
|
|
#define OPTION_BUFFER_SIZE 1024
|
|
|
|
#define COMPONENTS 4 // psnr & sse statistics maintained for total, y, u, v
|
|
|
|
|
|
|
|
typedef struct SvcInternal {
|
|
|
|
char options[OPTION_BUFFER_SIZE]; // set by vpx_svc_set_options
|
|
|
|
|
|
|
|
// values extracted from option, quantizers
|
|
|
|
vpx_svc_extra_cfg_t svc_params;
|
|
|
|
int enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
|
|
|
|
int bitrates[VPX_SS_MAX_LAYERS];
|
|
|
|
|
|
|
|
// accumulated statistics
|
|
|
|
double psnr_sum[VPX_SS_MAX_LAYERS][COMPONENTS]; // total/Y/U/V
|
|
|
|
uint64_t sse_sum[VPX_SS_MAX_LAYERS][COMPONENTS];
|
|
|
|
uint32_t bytes_sum[VPX_SS_MAX_LAYERS];
|
|
|
|
|
|
|
|
// codec encoding values
|
|
|
|
int width; // width of highest layer
|
|
|
|
int height; // height of highest layer
|
|
|
|
int kf_dist; // distance between keyframes
|
|
|
|
|
|
|
|
// state variables
|
|
|
|
int psnr_pkt_received;
|
|
|
|
int layer;
|
|
|
|
int use_multiple_frame_contexts;
|
|
|
|
|
|
|
|
char message_buffer[2048];
|
|
|
|
vpx_codec_ctx_t *codec_ctx;
|
|
|
|
} SvcInternal_t;
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set SVC options
|
|
|
|
* options are supplied as a single string separated by spaces
|
|
|
|
* Format: encoding-mode=<i|ip|alt-ip|gf>
|
|
|
|
* layers=<layer_count>
|
|
|
|
* scaling-factors=<n1>/<d1>,<n2>/<d2>,...
|
|
|
|
* quantizers=<q1>,<q2>,...
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options);
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize SVC encoding
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx,
|
2014-11-07 22:01:53 +03:00
|
|
|
vpx_codec_ctx_t *codec_ctx,
|
2013-10-23 22:53:37 +04:00
|
|
|
vpx_codec_iface_t *iface,
|
|
|
|
vpx_codec_enc_cfg_t *cfg);
|
|
|
|
/**
|
|
|
|
* encode a frame of video with multiple layers
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx,
|
2014-11-07 22:01:53 +03:00
|
|
|
vpx_codec_ctx_t *codec_ctx,
|
|
|
|
struct vpx_image *rawimg,
|
|
|
|
vpx_codec_pts_t pts,
|
2013-10-23 22:53:37 +04:00
|
|
|
int64_t duration, int deadline);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* finished with svc encoding, release allocated resources
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
void vpx_svc_release(SvcContext *svc_ctx);
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* dump accumulated statistics and reset accumulated values
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
const char *vpx_svc_dump_statistics(SvcContext *svc_ctx);
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get status message from previous encode
|
|
|
|
*/
|
2014-11-18 23:25:31 +03:00
|
|
|
const char *vpx_svc_get_message(const SvcContext *svc_ctx);
|
2013-10-23 22:53:37 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2013-12-16 06:26:15 +04:00
|
|
|
#endif // VPX_SVC_CONTEXT_H_
|