svc_context.h 3.58 KB
Newer Older
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3
 *
4
5
6
7
8
9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
11
12
13
14
15
16
 */

/**
 * SvcContext - input parameters and state to encode a multi-layered
 * spatial SVC frame
 */

Adrian Grange's avatar
Adrian Grange committed
17
18
#ifndef AOM_SVC_CONTEXT_H_
#define AOM_SVC_CONTEXT_H_
19

Adrian Grange's avatar
Adrian Grange committed
20
#include "./aomcx.h"
Adrian Grange's avatar
Adrian Grange committed
21
#include "./aom_encoder.h"
22
23
24
25
26
27
28
29
30
31
32

#ifdef __cplusplus
extern "C" {
#endif

typedef enum SVC_LOG_LEVEL {
  SVC_LOG_ERROR,
  SVC_LOG_INFO,
  SVC_LOG_DEBUG
} SVC_LOG_LEVEL;

33
typedef struct {
34
  // public interface to svc_command options
clang-format's avatar
clang-format committed
35
36
  int spatial_layers;   // number of spatial layers
  int temporal_layers;  // number of temporal layers
37
  int temporal_layering_mode;
38
  SVC_LOG_LEVEL log_level;  // amount of information to display
clang-format's avatar
clang-format committed
39
40
  int log_print;       // when set, printf log messages instead of returning the
                       // message with svc_get_message
41
  int output_rc_stat;  // for outputting rc stats
clang-format's avatar
clang-format committed
42
  int speed;           // speed setting for codec
43
  int threads;
44
  int aqmode;  // turns on aq-mode=3 (cyclic_refresh): 0=off, 1=on.
Adrian Grange's avatar
Adrian Grange committed
45
  // private storage for aom_svc_encode
46
  void *internal;
47
} SvcContext;
48
49
50
51
52

#define OPTION_BUFFER_SIZE 1024
#define COMPONENTS 4  // psnr & sse statistics maintained for total, y, u, v

typedef struct SvcInternal {
Adrian Grange's avatar
Adrian Grange committed
53
  char options[OPTION_BUFFER_SIZE];  // set by aom_svc_set_options
54
55

  // values extracted from option, quantizers
Adrian Grange's avatar
Adrian Grange committed
56
  aom_svc_extra_cfg_t svc_params;
Adrian Grange's avatar
Adrian Grange committed
57
58
  int enable_auto_alt_ref[AOM_SS_MAX_LAYERS];
  int bitrates[AOM_SS_MAX_LAYERS];
59
60

  // accumulated statistics
Adrian Grange's avatar
Adrian Grange committed
61
62
63
  double psnr_sum[AOM_SS_MAX_LAYERS][COMPONENTS];  // total/Y/U/V
  uint64_t sse_sum[AOM_SS_MAX_LAYERS][COMPONENTS];
  uint32_t bytes_sum[AOM_SS_MAX_LAYERS];
64
65
66
67
68
69
70
71
72
73
74
75

  // 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];
Adrian Grange's avatar
Adrian Grange committed
76
  aom_codec_ctx_t *codec_ctx;
77
} SvcInternal_t;
78
79
80
81
82
83
84
85
86

/**
 * 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>,...
 */
Adrian Grange's avatar
Adrian Grange committed
87
aom_codec_err_t aom_svc_set_options(SvcContext *svc_ctx, const char *options);
88
89
90
91

/**
 * initialize SVC encoding
 */
Adrian Grange's avatar
Adrian Grange committed
92
93
94
aom_codec_err_t aom_svc_init(SvcContext *svc_ctx, aom_codec_ctx_t *codec_ctx,
                             aom_codec_iface_t *iface,
                             aom_codec_enc_cfg_t *cfg);
95
96
97
/**
 * encode a frame of video with multiple layers
 */
Adrian Grange's avatar
Adrian Grange committed
98
99
aom_codec_err_t aom_svc_encode(SvcContext *svc_ctx, aom_codec_ctx_t *codec_ctx,
                               struct aom_image *rawimg, aom_codec_pts_t pts,
100
101
102
103
104
                               int64_t duration, int deadline);

/**
 * finished with svc encoding, release allocated resources
 */
Adrian Grange's avatar
Adrian Grange committed
105
void aom_svc_release(SvcContext *svc_ctx);
106
107
108
109

/**
 * dump accumulated statistics and reset accumulated values
 */
Adrian Grange's avatar
Adrian Grange committed
110
const char *aom_svc_dump_statistics(SvcContext *svc_ctx);
111
112
113
114

/**
 *  get status message from previous encode
 */
Adrian Grange's avatar
Adrian Grange committed
115
const char *aom_svc_get_message(const SvcContext *svc_ctx);
116
117
118
119
120

#ifdef __cplusplus
}  // extern "C"
#endif

Adrian Grange's avatar
Adrian Grange committed
121
#endif  // AOM_SVC_CONTEXT_H_