WebM Codec SDK
vpx_temporal_svc_encoder
1 /*
2  * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3  *
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
6  * tree. An additional intellectual property rights grant can be found
7  * in the file PATENTS. All contributing project authors may
8  * be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 // This is an example demonstrating how to implement a multi-layer VPx
12 // encoding scheme based on temporal scalability for video applications
13 // that benefit from a scalable bitstream.
14 
15 #include <assert.h>
16 #include <math.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 
21 #include "./vpx_config.h"
22 #include "../vpx_ports/vpx_timer.h"
23 #include "vpx/vp8cx.h"
24 #include "vpx/vpx_encoder.h"
25 
26 #include "../tools_common.h"
27 #include "../video_writer.h"
28 
29 #define VP8_ROI_MAP 0
30 
31 static const char *exec_name;
32 
33 void usage_exit(void) { exit(EXIT_FAILURE); }
34 
35 // Denoiser states for vp8, for temporal denoising.
36 enum denoiserStateVp8 {
37  kVp8DenoiserOff,
38  kVp8DenoiserOnYOnly,
39  kVp8DenoiserOnYUV,
40  kVp8DenoiserOnYUVAggressive,
41  kVp8DenoiserOnAdaptive
42 };
43 
44 // Denoiser states for vp9, for temporal denoising.
45 enum denoiserStateVp9 {
46  kVp9DenoiserOff,
47  kVp9DenoiserOnYOnly,
48  // For SVC: denoise the top two spatial layers.
49  kVp9DenoiserOnYTwoSpatialLayers
50 };
51 
52 static int mode_to_num_layers[13] = { 1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3, 3 };
53 
54 // For rate control encoding stats.
55 struct RateControlMetrics {
56  // Number of input frames per layer.
57  int layer_input_frames[VPX_TS_MAX_LAYERS];
58  // Total (cumulative) number of encoded frames per layer.
59  int layer_tot_enc_frames[VPX_TS_MAX_LAYERS];
60  // Number of encoded non-key frames per layer.
61  int layer_enc_frames[VPX_TS_MAX_LAYERS];
62  // Framerate per layer layer (cumulative).
63  double layer_framerate[VPX_TS_MAX_LAYERS];
64  // Target average frame size per layer (per-frame-bandwidth per layer).
65  double layer_pfb[VPX_TS_MAX_LAYERS];
66  // Actual average frame size per layer.
67  double layer_avg_frame_size[VPX_TS_MAX_LAYERS];
68  // Average rate mismatch per layer (|target - actual| / target).
69  double layer_avg_rate_mismatch[VPX_TS_MAX_LAYERS];
70  // Actual encoding bitrate per layer (cumulative).
71  double layer_encoding_bitrate[VPX_TS_MAX_LAYERS];
72  // Average of the short-time encoder actual bitrate.
73  // TODO(marpan): Should we add these short-time stats for each layer?
74  double avg_st_encoding_bitrate;
75  // Variance of the short-time encoder actual bitrate.
76  double variance_st_encoding_bitrate;
77  // Window (number of frames) for computing short-timee encoding bitrate.
78  int window_size;
79  // Number of window measurements.
80  int window_count;
81  int layer_target_bitrate[VPX_MAX_LAYERS];
82 };
83 
84 // Note: these rate control metrics assume only 1 key frame in the
85 // sequence (i.e., first frame only). So for temporal pattern# 7
86 // (which has key frame for every frame on base layer), the metrics
87 // computation will be off/wrong.
88 // TODO(marpan): Update these metrics to account for multiple key frames
89 // in the stream.
90 static void set_rate_control_metrics(struct RateControlMetrics *rc,
91  vpx_codec_enc_cfg_t *cfg) {
92  unsigned int i = 0;
93  // Set the layer (cumulative) framerate and the target layer (non-cumulative)
94  // per-frame-bandwidth, for the rate control encoding stats below.
95  const double framerate = cfg->g_timebase.den / cfg->g_timebase.num;
96  rc->layer_framerate[0] = framerate / cfg->ts_rate_decimator[0];
97  rc->layer_pfb[0] =
98  1000.0 * rc->layer_target_bitrate[0] / rc->layer_framerate[0];
99  for (i = 0; i < cfg->ts_number_layers; ++i) {
100  if (i > 0) {
101  rc->layer_framerate[i] = framerate / cfg->ts_rate_decimator[i];
102  rc->layer_pfb[i] = 1000.0 * (rc->layer_target_bitrate[i] -
103  rc->layer_target_bitrate[i - 1]) /
104  (rc->layer_framerate[i] - rc->layer_framerate[i - 1]);
105  }
106  rc->layer_input_frames[i] = 0;
107  rc->layer_enc_frames[i] = 0;
108  rc->layer_tot_enc_frames[i] = 0;
109  rc->layer_encoding_bitrate[i] = 0.0;
110  rc->layer_avg_frame_size[i] = 0.0;
111  rc->layer_avg_rate_mismatch[i] = 0.0;
112  }
113  rc->window_count = 0;
114  rc->window_size = 15;
115  rc->avg_st_encoding_bitrate = 0.0;
116  rc->variance_st_encoding_bitrate = 0.0;
117 }
118 
119 static void printout_rate_control_summary(struct RateControlMetrics *rc,
120  vpx_codec_enc_cfg_t *cfg,
121  int frame_cnt) {
122  unsigned int i = 0;
123  int tot_num_frames = 0;
124  double perc_fluctuation = 0.0;
125  printf("Total number of processed frames: %d\n\n", frame_cnt - 1);
126  printf("Rate control layer stats for %d layer(s):\n\n",
127  cfg->ts_number_layers);
128  for (i = 0; i < cfg->ts_number_layers; ++i) {
129  const int num_dropped =
130  (i > 0) ? (rc->layer_input_frames[i] - rc->layer_enc_frames[i])
131  : (rc->layer_input_frames[i] - rc->layer_enc_frames[i] - 1);
132  tot_num_frames += rc->layer_input_frames[i];
133  rc->layer_encoding_bitrate[i] = 0.001 * rc->layer_framerate[i] *
134  rc->layer_encoding_bitrate[i] /
135  tot_num_frames;
136  rc->layer_avg_frame_size[i] =
137  rc->layer_avg_frame_size[i] / rc->layer_enc_frames[i];
138  rc->layer_avg_rate_mismatch[i] =
139  100.0 * rc->layer_avg_rate_mismatch[i] / rc->layer_enc_frames[i];
140  printf("For layer#: %d \n", i);
141  printf("Bitrate (target vs actual): %d %f \n", rc->layer_target_bitrate[i],
142  rc->layer_encoding_bitrate[i]);
143  printf("Average frame size (target vs actual): %f %f \n", rc->layer_pfb[i],
144  rc->layer_avg_frame_size[i]);
145  printf("Average rate_mismatch: %f \n", rc->layer_avg_rate_mismatch[i]);
146  printf(
147  "Number of input frames, encoded (non-key) frames, "
148  "and perc dropped frames: %d %d %f \n",
149  rc->layer_input_frames[i], rc->layer_enc_frames[i],
150  100.0 * num_dropped / rc->layer_input_frames[i]);
151  printf("\n");
152  }
153  rc->avg_st_encoding_bitrate = rc->avg_st_encoding_bitrate / rc->window_count;
154  rc->variance_st_encoding_bitrate =
155  rc->variance_st_encoding_bitrate / rc->window_count -
156  (rc->avg_st_encoding_bitrate * rc->avg_st_encoding_bitrate);
157  perc_fluctuation = 100.0 * sqrt(rc->variance_st_encoding_bitrate) /
158  rc->avg_st_encoding_bitrate;
159  printf("Short-time stats, for window of %d frames: \n", rc->window_size);
160  printf("Average, rms-variance, and percent-fluct: %f %f %f \n",
161  rc->avg_st_encoding_bitrate, sqrt(rc->variance_st_encoding_bitrate),
162  perc_fluctuation);
163  if ((frame_cnt - 1) != tot_num_frames)
164  die("Error: Number of input frames not equal to output! \n");
165 }
166 
167 #if VP8_ROI_MAP
168 static void vp8_set_roi_map(vpx_codec_enc_cfg_t *cfg, vpx_roi_map_t *roi) {
169  unsigned int i, j;
170  memset(roi, 0, sizeof(*roi));
171 
172  // ROI is based on the segments (4 for vp8, 8 for vp9), smallest unit for
173  // segment is 16x16 for vp8, 8x8 for vp9.
174  roi->rows = (cfg->g_h + 15) / 16;
175  roi->cols = (cfg->g_w + 15) / 16;
176 
177  // Applies delta QP on the segment blocks, varies from -63 to 63.
178  // Setting to negative means lower QP (better quality).
179  // Below we set delta_q to the extreme (-63) to show strong effect.
180  roi->delta_q[0] = 0;
181  roi->delta_q[1] = -63;
182  roi->delta_q[2] = 0;
183  roi->delta_q[3] = 0;
184 
185  // Applies delta loopfilter strength on the segment blocks, varies from -63 to
186  // 63. Setting to positive means stronger loopfilter.
187  roi->delta_lf[0] = 0;
188  roi->delta_lf[1] = 0;
189  roi->delta_lf[2] = 0;
190  roi->delta_lf[3] = 0;
191 
192  // Applies skip encoding threshold on the segment blocks, varies from 0 to
193  // UINT_MAX. Larger value means more skipping of encoding is possible.
194  // This skip threshold only applies on delta frames.
195  roi->static_threshold[0] = 0;
196  roi->static_threshold[1] = 0;
197  roi->static_threshold[2] = 0;
198  roi->static_threshold[3] = 0;
199 
200  // Use 2 states: 1 is center square, 0 is the rest.
201  roi->roi_map =
202  (uint8_t *)calloc(roi->rows * roi->cols, sizeof(*roi->roi_map));
203  for (i = 0; i < roi->rows; ++i) {
204  for (j = 0; j < roi->cols; ++j) {
205  if (i > (roi->rows >> 2) && i < ((roi->rows * 3) >> 2) &&
206  j > (roi->cols >> 2) && j < ((roi->cols * 3) >> 2)) {
207  roi->roi_map[i * roi->cols + j] = 1;
208  }
209  }
210  }
211 }
212 #endif
213 
214 // Temporal scaling parameters:
215 // NOTE: The 3 prediction frames cannot be used interchangeably due to
216 // differences in the way they are handled throughout the code. The
217 // frames should be allocated to layers in the order LAST, GF, ARF.
218 // Other combinations work, but may produce slightly inferior results.
219 static void set_temporal_layer_pattern(int layering_mode,
220  vpx_codec_enc_cfg_t *cfg,
221  int *layer_flags,
222  int *flag_periodicity) {
223  switch (layering_mode) {
224  case 0: {
225  // 1-layer.
226  int ids[1] = { 0 };
227  cfg->ts_periodicity = 1;
228  *flag_periodicity = 1;
229  cfg->ts_number_layers = 1;
230  cfg->ts_rate_decimator[0] = 1;
231  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
232  // Update L only.
233  layer_flags[0] =
235  break;
236  }
237  case 1: {
238  // 2-layers, 2-frame period.
239  int ids[2] = { 0, 1 };
240  cfg->ts_periodicity = 2;
241  *flag_periodicity = 2;
242  cfg->ts_number_layers = 2;
243  cfg->ts_rate_decimator[0] = 2;
244  cfg->ts_rate_decimator[1] = 1;
245  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
246 #if 1
247  // 0=L, 1=GF, Intra-layer prediction enabled.
248  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
251  layer_flags[1] =
253 #else
254  // 0=L, 1=GF, Intra-layer prediction disabled.
255  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
258  layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
260 #endif
261  break;
262  }
263  case 2: {
264  // 2-layers, 3-frame period.
265  int ids[3] = { 0, 1, 1 };
266  cfg->ts_periodicity = 3;
267  *flag_periodicity = 3;
268  cfg->ts_number_layers = 2;
269  cfg->ts_rate_decimator[0] = 3;
270  cfg->ts_rate_decimator[1] = 1;
271  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
272  // 0=L, 1=GF, Intra-layer prediction enabled.
273  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
276  layer_flags[1] = layer_flags[2] =
279  break;
280  }
281  case 3: {
282  // 3-layers, 6-frame period.
283  int ids[6] = { 0, 2, 2, 1, 2, 2 };
284  cfg->ts_periodicity = 6;
285  *flag_periodicity = 6;
286  cfg->ts_number_layers = 3;
287  cfg->ts_rate_decimator[0] = 6;
288  cfg->ts_rate_decimator[1] = 3;
289  cfg->ts_rate_decimator[2] = 1;
290  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
291  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
292  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
295  layer_flags[3] =
297  layer_flags[1] = layer_flags[2] = layer_flags[4] = layer_flags[5] =
299  break;
300  }
301  case 4: {
302  // 3-layers, 4-frame period.
303  int ids[4] = { 0, 2, 1, 2 };
304  cfg->ts_periodicity = 4;
305  *flag_periodicity = 4;
306  cfg->ts_number_layers = 3;
307  cfg->ts_rate_decimator[0] = 4;
308  cfg->ts_rate_decimator[1] = 2;
309  cfg->ts_rate_decimator[2] = 1;
310  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
311  // 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled.
312  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
315  layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
317  layer_flags[1] = layer_flags[3] =
320  break;
321  }
322  case 5: {
323  // 3-layers, 4-frame period.
324  int ids[4] = { 0, 2, 1, 2 };
325  cfg->ts_periodicity = 4;
326  *flag_periodicity = 4;
327  cfg->ts_number_layers = 3;
328  cfg->ts_rate_decimator[0] = 4;
329  cfg->ts_rate_decimator[1] = 2;
330  cfg->ts_rate_decimator[2] = 1;
331  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
332  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled in layer 1, disabled
333  // in layer 2.
334  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
337  layer_flags[2] =
339  layer_flags[1] = layer_flags[3] =
342  break;
343  }
344  case 6: {
345  // 3-layers, 4-frame period.
346  int ids[4] = { 0, 2, 1, 2 };
347  cfg->ts_periodicity = 4;
348  *flag_periodicity = 4;
349  cfg->ts_number_layers = 3;
350  cfg->ts_rate_decimator[0] = 4;
351  cfg->ts_rate_decimator[1] = 2;
352  cfg->ts_rate_decimator[2] = 1;
353  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
354  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
355  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
358  layer_flags[2] =
360  layer_flags[1] = layer_flags[3] =
362  break;
363  }
364  case 7: {
365  // NOTE: Probably of academic interest only.
366  // 5-layers, 16-frame period.
367  int ids[16] = { 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4 };
368  cfg->ts_periodicity = 16;
369  *flag_periodicity = 16;
370  cfg->ts_number_layers = 5;
371  cfg->ts_rate_decimator[0] = 16;
372  cfg->ts_rate_decimator[1] = 8;
373  cfg->ts_rate_decimator[2] = 4;
374  cfg->ts_rate_decimator[3] = 2;
375  cfg->ts_rate_decimator[4] = 1;
376  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
377  layer_flags[0] = VPX_EFLAG_FORCE_KF;
378  layer_flags[1] = layer_flags[3] = layer_flags[5] = layer_flags[7] =
379  layer_flags[9] = layer_flags[11] = layer_flags[13] = layer_flags[15] =
382  layer_flags[2] = layer_flags[6] = layer_flags[10] = layer_flags[14] =
384  layer_flags[4] = layer_flags[12] =
386  layer_flags[8] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
387  break;
388  }
389  case 8: {
390  // 2-layers, with sync point at first frame of layer 1.
391  int ids[2] = { 0, 1 };
392  cfg->ts_periodicity = 2;
393  *flag_periodicity = 8;
394  cfg->ts_number_layers = 2;
395  cfg->ts_rate_decimator[0] = 2;
396  cfg->ts_rate_decimator[1] = 1;
397  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
398  // 0=L, 1=GF.
399  // ARF is used as predictor for all frames, and is only updated on
400  // key frame. Sync point every 8 frames.
401 
402  // Layer 0: predict from L and ARF, update L and G.
403  layer_flags[0] =
405  // Layer 1: sync point: predict from L and ARF, and update G.
406  layer_flags[1] =
408  // Layer 0, predict from L and ARF, update L.
409  layer_flags[2] =
411  // Layer 1: predict from L, G and ARF, and update G.
412  layer_flags[3] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
414  // Layer 0.
415  layer_flags[4] = layer_flags[2];
416  // Layer 1.
417  layer_flags[5] = layer_flags[3];
418  // Layer 0.
419  layer_flags[6] = layer_flags[4];
420  // Layer 1.
421  layer_flags[7] = layer_flags[5];
422  break;
423  }
424  case 9: {
425  // 3-layers: Sync points for layer 1 and 2 every 8 frames.
426  int ids[4] = { 0, 2, 1, 2 };
427  cfg->ts_periodicity = 4;
428  *flag_periodicity = 8;
429  cfg->ts_number_layers = 3;
430  cfg->ts_rate_decimator[0] = 4;
431  cfg->ts_rate_decimator[1] = 2;
432  cfg->ts_rate_decimator[2] = 1;
433  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
434  // 0=L, 1=GF, 2=ARF.
435  layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
438  layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
440  layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
442  layer_flags[3] = layer_flags[5] =
444  layer_flags[4] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
446  layer_flags[6] =
448  layer_flags[7] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
450  break;
451  }
452  case 10: {
453  // 3-layers structure where ARF is used as predictor for all frames,
454  // and is only updated on key frame.
455  // Sync points for layer 1 and 2 every 8 frames.
456 
457  int ids[4] = { 0, 2, 1, 2 };
458  cfg->ts_periodicity = 4;
459  *flag_periodicity = 8;
460  cfg->ts_number_layers = 3;
461  cfg->ts_rate_decimator[0] = 4;
462  cfg->ts_rate_decimator[1] = 2;
463  cfg->ts_rate_decimator[2] = 1;
464  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
465  // 0=L, 1=GF, 2=ARF.
466  // Layer 0: predict from L and ARF; update L and G.
467  layer_flags[0] =
469  // Layer 2: sync point: predict from L and ARF; update none.
470  layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
473  // Layer 1: sync point: predict from L and ARF; update G.
474  layer_flags[2] =
476  // Layer 2: predict from L, G, ARF; update none.
477  layer_flags[3] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
479  // Layer 0: predict from L and ARF; update L.
480  layer_flags[4] =
482  // Layer 2: predict from L, G, ARF; update none.
483  layer_flags[5] = layer_flags[3];
484  // Layer 1: predict from L, G, ARF; update G.
485  layer_flags[6] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
486  // Layer 2: predict from L, G, ARF; update none.
487  layer_flags[7] = layer_flags[3];
488  break;
489  }
490  case 11: {
491  // 3-layers structure with one reference frame.
492  // This works same as temporal_layering_mode 3.
493  // This was added to compare with vp9_spatial_svc_encoder.
494 
495  // 3-layers, 4-frame period.
496  int ids[4] = { 0, 2, 1, 2 };
497  cfg->ts_periodicity = 4;
498  *flag_periodicity = 4;
499  cfg->ts_number_layers = 3;
500  cfg->ts_rate_decimator[0] = 4;
501  cfg->ts_rate_decimator[1] = 2;
502  cfg->ts_rate_decimator[2] = 1;
503  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
504  // 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled.
505  layer_flags[0] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
507  layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
509  layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
511  layer_flags[3] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF |
513  break;
514  }
515  case 12:
516  default: {
517  // 3-layers structure as in case 10, but no sync/refresh points for
518  // layer 1 and 2.
519  int ids[4] = { 0, 2, 1, 2 };
520  cfg->ts_periodicity = 4;
521  *flag_periodicity = 8;
522  cfg->ts_number_layers = 3;
523  cfg->ts_rate_decimator[0] = 4;
524  cfg->ts_rate_decimator[1] = 2;
525  cfg->ts_rate_decimator[2] = 1;
526  memcpy(cfg->ts_layer_id, ids, sizeof(ids));
527  // 0=L, 1=GF, 2=ARF.
528  // Layer 0: predict from L and ARF; update L.
529  layer_flags[0] =
531  layer_flags[4] = layer_flags[0];
532  // Layer 1: predict from L, G, ARF; update G.
533  layer_flags[2] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
534  layer_flags[6] = layer_flags[2];
535  // Layer 2: predict from L, G, ARF; update none.
536  layer_flags[1] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
538  layer_flags[3] = layer_flags[1];
539  layer_flags[5] = layer_flags[1];
540  layer_flags[7] = layer_flags[1];
541  break;
542  }
543  }
544 }
545 
546 int main(int argc, char **argv) {
547  VpxVideoWriter *outfile[VPX_TS_MAX_LAYERS] = { NULL };
548  vpx_codec_ctx_t codec;
550  int frame_cnt = 0;
551  vpx_image_t raw;
552  vpx_codec_err_t res;
553  unsigned int width;
554  unsigned int height;
555  uint32_t error_resilient = 0;
556  int speed;
557  int frame_avail;
558  int got_data;
559  int flags = 0;
560  unsigned int i;
561  int pts = 0; // PTS starts at 0.
562  int frame_duration = 1; // 1 timebase tick per frame.
563  int layering_mode = 0;
564  int layer_flags[VPX_TS_MAX_PERIODICITY] = { 0 };
565  int flag_periodicity = 1;
566 #if VP8_ROI_MAP
567  vpx_roi_map_t roi;
568 #endif
569  vpx_svc_layer_id_t layer_id = { 0, 0 };
570  const VpxInterface *encoder = NULL;
571  FILE *infile = NULL;
572  struct RateControlMetrics rc;
573  int64_t cx_time = 0;
574  const int min_args_base = 13;
575 #if CONFIG_VP9_HIGHBITDEPTH
576  vpx_bit_depth_t bit_depth = VPX_BITS_8;
577  int input_bit_depth = 8;
578  const int min_args = min_args_base + 1;
579 #else
580  const int min_args = min_args_base;
581 #endif // CONFIG_VP9_HIGHBITDEPTH
582  double sum_bitrate = 0.0;
583  double sum_bitrate2 = 0.0;
584  double framerate = 30.0;
585 
586  exec_name = argv[0];
587  // Check usage and arguments.
588  if (argc < min_args) {
589 #if CONFIG_VP9_HIGHBITDEPTH
590  die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
591  "<rate_num> <rate_den> <speed> <frame_drop_threshold> "
592  "<error_resilient> <threads> <mode> "
593  "<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n",
594  argv[0]);
595 #else
596  die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
597  "<rate_num> <rate_den> <speed> <frame_drop_threshold> "
598  "<error_resilient> <threads> <mode> "
599  "<Rate_0> ... <Rate_nlayers-1> \n",
600  argv[0]);
601 #endif // CONFIG_VP9_HIGHBITDEPTH
602  }
603 
604  encoder = get_vpx_encoder_by_name(argv[3]);
605  if (!encoder) die("Unsupported codec.");
606 
607  printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
608 
609  width = (unsigned int)strtoul(argv[4], NULL, 0);
610  height = (unsigned int)strtoul(argv[5], NULL, 0);
611  if (width < 16 || width % 2 || height < 16 || height % 2) {
612  die("Invalid resolution: %d x %d", width, height);
613  }
614 
615  layering_mode = (int)strtol(argv[12], NULL, 0);
616  if (layering_mode < 0 || layering_mode > 13) {
617  die("Invalid layering mode (0..12) %s", argv[12]);
618  }
619 
620  if (argc != min_args + mode_to_num_layers[layering_mode]) {
621  die("Invalid number of arguments");
622  }
623 
624 #if CONFIG_VP9_HIGHBITDEPTH
625  switch (strtol(argv[argc - 1], NULL, 0)) {
626  case 8:
627  bit_depth = VPX_BITS_8;
628  input_bit_depth = 8;
629  break;
630  case 10:
631  bit_depth = VPX_BITS_10;
632  input_bit_depth = 10;
633  break;
634  case 12:
635  bit_depth = VPX_BITS_12;
636  input_bit_depth = 12;
637  break;
638  default: die("Invalid bit depth (8, 10, 12) %s", argv[argc - 1]);
639  }
640  if (!vpx_img_alloc(
641  &raw, bit_depth == VPX_BITS_8 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_I42016,
642  width, height, 32)) {
643  die("Failed to allocate image", width, height);
644  }
645 #else
646  if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 32)) {
647  die("Failed to allocate image", width, height);
648  }
649 #endif // CONFIG_VP9_HIGHBITDEPTH
650 
651  // Populate encoder configuration.
652  res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
653  if (res) {
654  printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
655  return EXIT_FAILURE;
656  }
657 
658  // Update the default configuration with our settings.
659  cfg.g_w = width;
660  cfg.g_h = height;
661 
662 #if CONFIG_VP9_HIGHBITDEPTH
663  if (bit_depth != VPX_BITS_8) {
664  cfg.g_bit_depth = bit_depth;
665  cfg.g_input_bit_depth = input_bit_depth;
666  cfg.g_profile = 2;
667  }
668 #endif // CONFIG_VP9_HIGHBITDEPTH
669 
670  // Timebase format e.g. 30fps: numerator=1, demoninator = 30.
671  cfg.g_timebase.num = (int)strtol(argv[6], NULL, 0);
672  cfg.g_timebase.den = (int)strtol(argv[7], NULL, 0);
673 
674  speed = (int)strtol(argv[8], NULL, 0);
675  if (speed < 0) {
676  die("Invalid speed setting: must be positive");
677  }
678 
679  for (i = min_args_base;
680  (int)i < min_args_base + mode_to_num_layers[layering_mode]; ++i) {
681  rc.layer_target_bitrate[i - 13] = (int)strtol(argv[i], NULL, 0);
682  if (strncmp(encoder->name, "vp8", 3) == 0)
683  cfg.ts_target_bitrate[i - 13] = rc.layer_target_bitrate[i - 13];
684  else if (strncmp(encoder->name, "vp9", 3) == 0)
685  cfg.layer_target_bitrate[i - 13] = rc.layer_target_bitrate[i - 13];
686  }
687 
688  // Real time parameters.
689  cfg.rc_dropframe_thresh = (unsigned int)strtoul(argv[9], NULL, 0);
690  cfg.rc_end_usage = VPX_CBR;
691  cfg.rc_min_quantizer = 2;
692  cfg.rc_max_quantizer = 56;
693  if (strncmp(encoder->name, "vp9", 3) == 0) cfg.rc_max_quantizer = 52;
694  cfg.rc_undershoot_pct = 50;
695  cfg.rc_overshoot_pct = 50;
696  cfg.rc_buf_initial_sz = 600;
697  cfg.rc_buf_optimal_sz = 600;
698  cfg.rc_buf_sz = 1000;
699 
700  // Disable dynamic resizing by default.
701  cfg.rc_resize_allowed = 0;
702 
703  // Use 1 thread as default.
704  cfg.g_threads = (unsigned int)strtoul(argv[11], NULL, 0);
705 
706  error_resilient = (uint32_t)strtoul(argv[10], NULL, 0);
707  if (error_resilient != 0 && error_resilient != 1) {
708  die("Invalid value for error resilient (0, 1): %d.", error_resilient);
709  }
710  // Enable error resilient mode.
711  cfg.g_error_resilient = error_resilient;
712  cfg.g_lag_in_frames = 0;
713  cfg.kf_mode = VPX_KF_AUTO;
714 
715  // Disable automatic keyframe placement.
716  cfg.kf_min_dist = cfg.kf_max_dist = 3000;
717 
719 
720  set_temporal_layer_pattern(layering_mode, &cfg, layer_flags,
721  &flag_periodicity);
722 
723  set_rate_control_metrics(&rc, &cfg);
724 
725  // Target bandwidth for the whole stream.
726  // Set to layer_target_bitrate for highest layer (total bitrate).
727  cfg.rc_target_bitrate = rc.layer_target_bitrate[cfg.ts_number_layers - 1];
728 
729  // Open input file.
730  if (!(infile = fopen(argv[1], "rb"))) {
731  die("Failed to open %s for reading", argv[1]);
732  }
733 
734  framerate = cfg.g_timebase.den / cfg.g_timebase.num;
735  // Open an output file for each stream.
736  for (i = 0; i < cfg.ts_number_layers; ++i) {
737  char file_name[PATH_MAX];
738  VpxVideoInfo info;
739  info.codec_fourcc = encoder->fourcc;
740  info.frame_width = cfg.g_w;
741  info.frame_height = cfg.g_h;
742  info.time_base.numerator = cfg.g_timebase.num;
743  info.time_base.denominator = cfg.g_timebase.den;
744 
745  snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);
746  outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);
747  if (!outfile[i]) die("Failed to open %s for writing", file_name);
748 
749  assert(outfile[i] != NULL);
750  }
751  // No spatial layers in this encoder.
752  cfg.ss_number_layers = 1;
753 
754 // Initialize codec.
755 #if CONFIG_VP9_HIGHBITDEPTH
756  if (vpx_codec_enc_init(
757  &codec, encoder->codec_interface(), &cfg,
758  bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH))
759 #else
760  if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
761 #endif // CONFIG_VP9_HIGHBITDEPTH
762  die_codec(&codec, "Failed to initialize encoder");
763 
764  if (strncmp(encoder->name, "vp8", 3) == 0) {
765  vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);
766  vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kVp8DenoiserOff);
769 #if VP8_ROI_MAP
770  vp8_set_roi_map(&cfg, &roi);
771  if (vpx_codec_control(&codec, VP8E_SET_ROI_MAP, &roi))
772  die_codec(&codec, "Failed to set ROI map");
773 #endif
774 
775  } else if (strncmp(encoder->name, "vp9", 3) == 0) {
776  vpx_svc_extra_cfg_t svc_params;
777  memset(&svc_params, 0, sizeof(svc_params));
778  vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
783  vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, kVp9DenoiserOff);
787  // TODO(marpan/jianj): There is an issue with row-mt for low resolutons at
788  // high speed settings, disable its use for those cases for now.
789  if (cfg.g_threads > 1 && ((cfg.g_w > 320 && cfg.g_h > 240) || speed < 7))
791  else
793  if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1 : 0))
794  die_codec(&codec, "Failed to set SVC");
795  for (i = 0; i < cfg.ts_number_layers; ++i) {
796  svc_params.max_quantizers[i] = cfg.rc_max_quantizer;
797  svc_params.min_quantizers[i] = cfg.rc_min_quantizer;
798  }
799  svc_params.scaling_factor_num[0] = cfg.g_h;
800  svc_params.scaling_factor_den[0] = cfg.g_h;
801  vpx_codec_control(&codec, VP9E_SET_SVC_PARAMETERS, &svc_params);
802  }
803  if (strncmp(encoder->name, "vp8", 3) == 0) {
805  }
807  // This controls the maximum target size of the key frame.
808  // For generating smaller key frames, use a smaller max_intra_size_pct
809  // value, like 100 or 200.
810  {
811  const int max_intra_size_pct = 1000;
813  max_intra_size_pct);
814  }
815 
816  frame_avail = 1;
817  while (frame_avail || got_data) {
818  struct vpx_usec_timer timer;
819  vpx_codec_iter_t iter = NULL;
820  const vpx_codec_cx_pkt_t *pkt;
821  // Update the temporal layer_id. No spatial layers in this test.
822  layer_id.spatial_layer_id = 0;
823  layer_id.temporal_layer_id =
824  cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
825  if (strncmp(encoder->name, "vp9", 3) == 0) {
826  vpx_codec_control(&codec, VP9E_SET_SVC_LAYER_ID, &layer_id);
827  } else if (strncmp(encoder->name, "vp8", 3) == 0) {
829  layer_id.temporal_layer_id);
830  }
831  flags = layer_flags[frame_cnt % flag_periodicity];
832  if (layering_mode == 0) flags = 0;
833  frame_avail = vpx_img_read(&raw, infile);
834  if (frame_avail) ++rc.layer_input_frames[layer_id.temporal_layer_id];
835  vpx_usec_timer_start(&timer);
836  if (vpx_codec_encode(&codec, frame_avail ? &raw : NULL, pts, 1, flags,
837  VPX_DL_REALTIME)) {
838  die_codec(&codec, "Failed to encode frame");
839  }
840  vpx_usec_timer_mark(&timer);
841  cx_time += vpx_usec_timer_elapsed(&timer);
842  // Reset KF flag.
843  if (layering_mode != 7) {
844  layer_flags[0] &= ~VPX_EFLAG_FORCE_KF;
845  }
846  got_data = 0;
847  while ((pkt = vpx_codec_get_cx_data(&codec, &iter))) {
848  got_data = 1;
849  switch (pkt->kind) {
851  for (i = cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
852  i < cfg.ts_number_layers; ++i) {
853  vpx_video_writer_write_frame(outfile[i], pkt->data.frame.buf,
854  pkt->data.frame.sz, pts);
855  ++rc.layer_tot_enc_frames[i];
856  rc.layer_encoding_bitrate[i] += 8.0 * pkt->data.frame.sz;
857  // Keep count of rate control stats per layer (for non-key frames).
858  if (i == cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity] &&
859  !(pkt->data.frame.flags & VPX_FRAME_IS_KEY)) {
860  rc.layer_avg_frame_size[i] += 8.0 * pkt->data.frame.sz;
861  rc.layer_avg_rate_mismatch[i] +=
862  fabs(8.0 * pkt->data.frame.sz - rc.layer_pfb[i]) /
863  rc.layer_pfb[i];
864  ++rc.layer_enc_frames[i];
865  }
866  }
867  // Update for short-time encoding bitrate states, for moving window
868  // of size rc->window, shifted by rc->window / 2.
869  // Ignore first window segment, due to key frame.
870  if (frame_cnt > rc.window_size) {
871  sum_bitrate += 0.001 * 8.0 * pkt->data.frame.sz * framerate;
872  if (frame_cnt % rc.window_size == 0) {
873  rc.window_count += 1;
874  rc.avg_st_encoding_bitrate += sum_bitrate / rc.window_size;
875  rc.variance_st_encoding_bitrate +=
876  (sum_bitrate / rc.window_size) *
877  (sum_bitrate / rc.window_size);
878  sum_bitrate = 0.0;
879  }
880  }
881  // Second shifted window.
882  if (frame_cnt > rc.window_size + rc.window_size / 2) {
883  sum_bitrate2 += 0.001 * 8.0 * pkt->data.frame.sz * framerate;
884  if (frame_cnt > 2 * rc.window_size &&
885  frame_cnt % rc.window_size == 0) {
886  rc.window_count += 1;
887  rc.avg_st_encoding_bitrate += sum_bitrate2 / rc.window_size;
888  rc.variance_st_encoding_bitrate +=
889  (sum_bitrate2 / rc.window_size) *
890  (sum_bitrate2 / rc.window_size);
891  sum_bitrate2 = 0.0;
892  }
893  }
894  break;
895  default: break;
896  }
897  }
898  ++frame_cnt;
899  pts += frame_duration;
900  }
901  fclose(infile);
902  printout_rate_control_summary(&rc, &cfg, frame_cnt);
903  printf("\n");
904  printf("Frame cnt and encoding time/FPS stats for encoding: %d %f %f \n",
905  frame_cnt, 1000 * (float)cx_time / (double)(frame_cnt * 1000000),
906  1000000 * (double)frame_cnt / (double)cx_time);
907 
908  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
909 
910  // Try to rewrite the output file headers with the actual frame count.
911  for (i = 0; i < cfg.ts_number_layers; ++i) vpx_video_writer_close(outfile[i]);
912 
913  vpx_img_free(&raw);
914  return EXIT_SUCCESS;
915 }
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: vpx_encoder.h:559
int min_quantizers[12]
Definition: vpx_encoder.h:722
unsigned char * roi_map
Definition: vp8cx.h:647
unsigned int ts_number_layers
Number of temporal coding layers.
Definition: vpx_encoder.h:663
Codec control function to set encoder internal speed settings.
Definition: vp8cx.h:155
#define VPX_MAX_LAYERS
Definition: vpx_encoder.h:46
#define VP8_EFLAG_NO_REF_LAST
Don&#39;t reference the last frame.
Definition: vp8cx.h:58
#define VP8_EFLAG_NO_UPD_GF
Don&#39;t update the golden frame.
Definition: vp8cx.h:88
Image Descriptor.
Definition: vpx_image.h:88
Describes the encoder algorithm interface to applications.
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
const char * vpx_codec_err_to_string(vpx_codec_err_t err)
Convert error number to printable string.
#define VPX_TS_MAX_LAYERS
Definition: vpx_encoder.h:40
Codec control function to set content type.
Definition: vp8cx.h:451
struct vpx_rational g_timebase
Stream timebase units.
Definition: vpx_encoder.h:357
Definition: vpx_encoder.h:244
Codec control function to set noise sensitivity.
Definition: vp8cx.h:415
unsigned int layer_target_bitrate[12]
Target bitrate for each spatial/temporal layer.
Definition: vpx_encoder.h:703
unsigned int cols
Definition: vp8cx.h:649
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: vpx_encoder.h:550
#define VP8_EFLAG_NO_REF_GF
Don&#39;t reference the golden frame.
Definition: vp8cx.h:66
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition: vpx_encoder.h:343
enum vpx_kf_mode kf_mode
Keyframe placement mode.
Definition: vpx_encoder.h:615
int den
Definition: vpx_encoder.h:231
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img, vpx_codec_pts_t pts, unsigned long duration, vpx_enc_frame_flags_t flags, unsigned long deadline)
Encode a frame.
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition: vpx_encoder.h:501
Codec control function to pass an ROI map to encoder.
Definition: vp8cx.h:130
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: vpx_encoder.h:491
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: vpx_encoder.h:633
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: vpx_encoder.h:386
Encoder configuration structure.
Definition: vpx_encoder.h:279
Definition: vpx_encoder.h:259
Codec control function to set row level multi-threading.
Definition: vp8cx.h:558
int spatial_layer_id
Definition: vp8cx.h:719
Codec control function to set Max data rate for Intra frames.
Definition: vp8cx.h:251
#define VPX_CODEC_USE_HIGHBITDEPTH
Definition: vpx_encoder.h:96
Encoder output packet.
Definition: vpx_encoder.h:170
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: vpx_encoder.h:535
Codec control function to set parameters for SVC.
Definition: vp8cx.h:432
unsigned int ts_rate_decimator[5]
Frame rate decimation factor for each temporal layer.
Definition: vpx_encoder.h:677
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: vpx_encoder.h:568
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: vpx_encoder.h:624
unsigned int g_profile
Bitstream profile to use.
Definition: vpx_encoder.h:309
Codec control function to set number of tile columns.
Definition: vp8cx.h:345
unsigned int ts_layer_id[16]
Template defining the membership of frames to temporal layers.
Definition: vpx_encoder.h:695
struct vpx_codec_cx_pkt::@1::@2 frame
vpx_image_t * vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
Definition: vpx_image.h:55
int scaling_factor_num[12]
Definition: vpx_encoder.h:723
unsigned int g_w
Width of the frame.
Definition: vpx_encoder.h:318
unsigned int static_threshold[4]
Definition: vp8cx.h:656
unsigned int ts_target_bitrate[5]
Target bitrate for each temporal layer.
Definition: vpx_encoder.h:670
enum vpx_bit_depth vpx_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: vpx_encoder.h:520
Codec control function to set adaptive quantization mode.
Definition: vp8cx.h:392
unsigned int g_h
Height of the frame.
Definition: vpx_encoder.h:327
enum vpx_codec_cx_pkt_kind kind
Definition: vpx_encoder.h:171
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: vpx_encoder.h:408
Boost percentage for Golden Frame in CBR mode.
Definition: vp8cx.h:589
vp9 svc layer parameters
Definition: vp8cx.h:718
Codec control function to set the temporal layer id.
Definition: vp8cx.h:298
#define VP8_EFLAG_NO_UPD_LAST
Don&#39;t update the last frame.
Definition: vp8cx.h:81
void vpx_img_free(vpx_image_t *img)
Close an image descriptor.
Codec control function to set the number of token partitions.
Definition: vp8cx.h:188
unsigned int rc_target_bitrate
Target data rate.
Definition: vpx_encoder.h:477
#define VPX_DL_REALTIME
deadline parameter analogous to VPx REALTIME mode.
Definition: vpx_encoder.h:849
int num
Definition: vpx_encoder.h:230
control function to set noise sensitivity
Definition: vp8cx.h:170
Definition: vpx_codec.h:220
Boost percentage for Golden Frame in CBR mode.
Definition: vp8cx.h:287
int delta_lf[4]
Definition: vp8cx.h:654
unsigned int g_threads
Maximum number of threads to use.
Definition: vpx_encoder.h:299
unsigned int ss_number_layers
Number of spatial coding layers.
Definition: vpx_encoder.h:643
vpx_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition: vpx_encoder.h:335
Provides definitions for using VP8 or VP9 encoder algorithm within the vpx Codec Interface.
#define vpx_codec_enc_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_enc_init_ver()
Definition: vpx_encoder.h:760
Codec control function to set encoder screen content mode.
Definition: vp8cx.h:306
unsigned int rc_resize_allowed
Enable/disable spatial resampling, if supported by the codec.
Definition: vpx_encoder.h:417
Bypass mode. Used when application needs to control temporal layering. This will only work when the n...
Definition: vp8cx.h:628
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:90
const vpx_codec_cx_pkt_t * vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Encoded data iterator.
union vpx_codec_cx_pkt::@1 data
int temporal_layering_mode
Temporal layering mode indicating which temporal layering scheme to use.
Definition: vpx_encoder.h:712
int temporal_layer_id
Definition: vp8cx.h:720
Definition: vpx_image.h:63
Codec control function to enable/disable periodic Q boost.
Definition: vp8cx.h:407
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, unsigned int reserved)
Get a default configuration.
#define VPX_TS_MAX_PERIODICITY
Definition: vpx_encoder.h:37
Codec control function to turn on/off SVC in encoder.
Definition: vp8cx.h:424
#define vpx_codec_control(ctx, id, data)
vpx_codec_control wrapper macro
Definition: vpx_codec.h:404
unsigned int ts_periodicity
Length of the sequence defining frame temporal layer membership.
Definition: vpx_encoder.h:686
#define VP8_EFLAG_NO_REF_ARF
Don&#39;t reference the alternate reference frame.
Definition: vp8cx.h:74
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
unsigned int rows
Definition: vp8cx.h:648
Codec control function to enable frame parallel decoding feature.
Definition: vp8cx.h:379
Definition: vpx_codec.h:218
int scaling_factor_den[12]
Definition: vpx_encoder.h:724
Codec control function to set the threshold for MBs treated static.
Definition: vp8cx.h:182
#define VPX_FRAME_IS_KEY
Definition: vpx_encoder.h:122
Definition: vpx_codec.h:219
#define VPX_EFLAG_FORCE_KF
Definition: vpx_encoder.h:271
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:187
vpx region of interest map
Definition: vp8cx.h:645
Definition: vpx_encoder.h:153
int max_quantizers[12]
Definition: vpx_encoder.h:721
int delta_q[4]
Definition: vp8cx.h:653
vp9 svc extra configure parameters
Definition: vpx_encoder.h:720
vpx_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: vpx_encoder.h:365
#define VP8_EFLAG_NO_UPD_ARF
Don&#39;t update the alternate reference frame.
Definition: vp8cx.h:95
#define VP8_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition: vp8cx.h:116
Codec control function to set svc layer for spatial and temporal.
Definition: vp8cx.h:441
enum vpx_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: vpx_encoder.h:457
Codec context structure.
Definition: vpx_codec.h:197