WebM VP8 Codec SDK
vp8_scalable_patterns
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 
12 /*
13  * This is an example demonstrating how to implement a multi-layer VP8
14  * encoding scheme based on temporal scalability for video applications
15  * that benefit from a scalable bitstream.
16  */
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <stdarg.h>
20 #include <string.h>
21 #define VPX_CODEC_DISABLE_COMPAT 1
22 #include "vpx/vpx_encoder.h"
23 #include "vpx/vp8cx.h"
24 #define interface (vpx_codec_vp8_cx())
25 #define fourcc 0x30385056
26 
27 #define IVF_FILE_HDR_SZ (32)
28 #define IVF_FRAME_HDR_SZ (12)
29 
30 static void mem_put_le16(char *mem, unsigned int val) {
31  mem[0] = val;
32  mem[1] = val>>8;
33 }
34 
35 static void mem_put_le32(char *mem, unsigned int val) {
36  mem[0] = val;
37  mem[1] = val>>8;
38  mem[2] = val>>16;
39  mem[3] = val>>24;
40 }
41 
42 static void die(const char *fmt, ...) {
43  va_list ap;
44 
45  va_start(ap, fmt);
46  vprintf(fmt, ap);
47  if(fmt[strlen(fmt)-1] != '\n')
48  printf("\n");
49  exit(EXIT_FAILURE);
50 }
51 
52 static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
53  const char *detail = vpx_codec_error_detail(ctx);
54 
55  printf("%s: %s\n", s, vpx_codec_error(ctx));
56  if(detail)
57  printf(" %s\n",detail);
58  exit(EXIT_FAILURE);
59 }
60 
61 static int read_frame(FILE *f, vpx_image_t *img) {
62  size_t nbytes, to_read;
63  int res = 1;
64 
65  to_read = img->w*img->h*3/2;
66  nbytes = fread(img->planes[0], 1, to_read, f);
67  if(nbytes != to_read) {
68  res = 0;
69  if(nbytes > 0)
70  printf("Warning: Read partial frame. Check your width & height!\n");
71  }
72  return res;
73 }
74 
75 static void write_ivf_file_header(FILE *outfile,
76  const vpx_codec_enc_cfg_t *cfg,
77  int frame_cnt) {
78  char header[32];
79 
80  if(cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
81  return;
82  header[0] = 'D';
83  header[1] = 'K';
84  header[2] = 'I';
85  header[3] = 'F';
86  mem_put_le16(header+4, 0); /* version */
87  mem_put_le16(header+6, 32); /* headersize */
88  mem_put_le32(header+8, fourcc); /* headersize */
89  mem_put_le16(header+12, cfg->g_w); /* width */
90  mem_put_le16(header+14, cfg->g_h); /* height */
91  mem_put_le32(header+16, cfg->g_timebase.den); /* rate */
92  mem_put_le32(header+20, cfg->g_timebase.num); /* scale */
93  mem_put_le32(header+24, frame_cnt); /* length */
94  mem_put_le32(header+28, 0); /* unused */
95 
96  if(fwrite(header, 1, 32, outfile));
97 }
98 
99 
100 static void write_ivf_frame_header(FILE *outfile,
101  const vpx_codec_cx_pkt_t *pkt)
102 {
103  char header[12];
104  vpx_codec_pts_t pts;
105 
106  if(pkt->kind != VPX_CODEC_CX_FRAME_PKT)
107  return;
108 
109  pts = pkt->data.frame.pts;
110  mem_put_le32(header, pkt->data.frame.sz);
111  mem_put_le32(header+4, pts&0xFFFFFFFF);
112  mem_put_le32(header+8, pts >> 32);
113 
114  if(fwrite(header, 1, 12, outfile));
115 }
116 
117 static int mode_to_num_layers[9] = {2, 2, 3, 3, 3, 3, 5, 2, 3};
118 
119 int main(int argc, char **argv) {
120  FILE *infile, *outfile[VPX_TS_MAX_LAYERS];
121  vpx_codec_ctx_t codec;
123  int frame_cnt = 0;
124  vpx_image_t raw;
125  vpx_codec_err_t res;
126  unsigned int width;
127  unsigned int height;
128  int frame_avail;
129  int got_data;
130  int flags = 0;
131  int i;
132  int pts = 0; // PTS starts at 0
133  int frame_duration = 1; // 1 timebase tick per frame
134 
135  int layering_mode = 0;
136  int frames_in_layer[VPX_TS_MAX_LAYERS] = {0};
137  int layer_flags[VPX_TS_MAX_PERIODICITY] = {0};
138  int flag_periodicity;
139  int max_intra_size_pct;
140 
141  // Check usage and arguments
142  if (argc < 9)
143  die("Usage: %s <infile> <outfile> <width> <height> <rate_num> "
144  " <rate_den> <mode> <Rate_0> ... <Rate_nlayers-1>\n", argv[0]);
145 
146  width = strtol (argv[3], NULL, 0);
147  height = strtol (argv[4], NULL, 0);
148  if (width < 16 || width%2 || height <16 || height%2)
149  die ("Invalid resolution: %d x %d", width, height);
150 
151  if (!sscanf(argv[7], "%d", &layering_mode))
152  die ("Invalid mode %s", argv[7]);
153  if (layering_mode<0 || layering_mode>8)
154  die ("Invalid mode (0..8) %s", argv[7]);
155 
156  if (argc != 8+mode_to_num_layers[layering_mode])
157  die ("Invalid number of arguments");
158 
159  if (!vpx_img_alloc (&raw, VPX_IMG_FMT_I420, width, height, 1))
160  die ("Failed to allocate image", width, height);
161 
162  printf("Using %s\n",vpx_codec_iface_name(interface));
163 
164  // Populate encoder configuration
165  res = vpx_codec_enc_config_default(interface, &cfg, 0);
166  if(res) {
167  printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
168  return EXIT_FAILURE;
169  }
170 
171  // Update the default configuration with our settings
172  cfg.g_w = width;
173  cfg.g_h = height;
174 
175  // Timebase format e.g. 30fps: numerator=1, demoninator=30
176  if (!sscanf (argv[5], "%d", &cfg.g_timebase.num ))
177  die ("Invalid timebase numerator %s", argv[5]);
178  if (!sscanf (argv[6], "%d", &cfg.g_timebase.den ))
179  die ("Invalid timebase denominator %s", argv[6]);
180 
181  for (i=8; i<8+mode_to_num_layers[layering_mode]; i++)
182  if (!sscanf(argv[i], "%d", &cfg.ts_target_bitrate[i-8]))
183  die ("Invalid data rate %s", argv[i]);
184 
185  // Real time parameters
186  cfg.rc_dropframe_thresh = 0; // 30
187  cfg.rc_end_usage = VPX_CBR;
188  cfg.rc_resize_allowed = 0;
189  cfg.rc_min_quantizer = 8;
190  cfg.rc_max_quantizer = 56;
191  cfg.rc_undershoot_pct = 100;
192  cfg.rc_overshoot_pct = 15;
193  cfg.rc_buf_initial_sz = 500;
194  cfg.rc_buf_optimal_sz = 600;
195  cfg.rc_buf_sz = 1000;
196 
197  // Enable error resilient mode
198  cfg.g_error_resilient = 1;
199  cfg.g_lag_in_frames = 0;
200  cfg.kf_mode = VPX_KF_DISABLED;
201 
202  // Disable automatic keyframe placement
203  cfg.kf_min_dist = cfg.kf_max_dist = 1000;
204 
205  // Temporal scaling parameters:
206  // NOTE: The 3 prediction frames cannot be used interchangeably due to
207  // differences in the way they are handled throughout the code. The
208  // frames should be allocated to layers in the order LAST, GF, ARF.
209  // Other combinations work, but may produce slightly inferior results.
210  switch (layering_mode)
211  {
212 
213  case 0:
214  {
215  // 2-layers, 2-frame period
216  int ids[2] = {0,1};
217  cfg.ts_number_layers = 2;
218  cfg.ts_periodicity = 2;
219  cfg.ts_rate_decimator[0] = 2;
220  cfg.ts_rate_decimator[1] = 1;
221  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
222 
223  flag_periodicity = cfg.ts_periodicity;
224 #if 1
225  // 0=L, 1=GF, Intra-layer prediction enabled
226  layer_flags[0] = VPX_EFLAG_FORCE_KF |
229  layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
231 #else
232  // 0=L, 1=GF, Intra-layer prediction disabled
233  layer_flags[0] = VPX_EFLAG_FORCE_KF |
236  layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
238 #endif
239  break;
240  }
241 
242  case 1:
243  {
244  // 2-layers, 3-frame period
245  int ids[3] = {0,1,1};
246  cfg.ts_number_layers = 2;
247  cfg.ts_periodicity = 3;
248  cfg.ts_rate_decimator[0] = 3;
249  cfg.ts_rate_decimator[1] = 1;
250  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
251 
252  flag_periodicity = cfg.ts_periodicity;
253 
254  // 0=L, 1=GF, Intra-layer prediction enabled
255  layer_flags[0] = VPX_EFLAG_FORCE_KF |
258  layer_flags[1] =
259  layer_flags[2] = VP8_EFLAG_NO_REF_GF |
262  break;
263  }
264 
265  case 2:
266  {
267  // 3-layers, 6-frame period
268  int ids[6] = {0,2,2,1,2,2};
269  cfg.ts_number_layers = 3;
270  cfg.ts_periodicity = 6;
271  cfg.ts_rate_decimator[0] = 6;
272  cfg.ts_rate_decimator[1] = 3;
273  cfg.ts_rate_decimator[2] = 1;
274  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
275 
276  flag_periodicity = cfg.ts_periodicity;
277 
278  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled
279  layer_flags[0] = VPX_EFLAG_FORCE_KF |
282  layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF |
284  layer_flags[1] =
285  layer_flags[2] =
286  layer_flags[4] =
287  layer_flags[5] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
288  break;
289  }
290 
291  case 3:
292  {
293  // 3-layers, 4-frame period
294  int ids[4] = {0,2,1,2};
295  cfg.ts_number_layers = 3;
296  cfg.ts_periodicity = 4;
297  cfg.ts_rate_decimator[0] = 4;
298  cfg.ts_rate_decimator[1] = 2;
299  cfg.ts_rate_decimator[2] = 1;
300  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
301 
302  flag_periodicity = cfg.ts_periodicity;
303 
304  // 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled
305  layer_flags[0] = VPX_EFLAG_FORCE_KF |
308  layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
311  layer_flags[1] =
312  layer_flags[3] = VP8_EFLAG_NO_REF_ARF |
315  break;
316  }
317 
318  case 4:
319  {
320  // 3-layers, 4-frame period
321  int ids[4] = {0,2,1,2};
322  cfg.ts_number_layers = 3;
323  cfg.ts_periodicity = 4;
324  cfg.ts_rate_decimator[0] = 4;
325  cfg.ts_rate_decimator[1] = 2;
326  cfg.ts_rate_decimator[2] = 1;
327  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
328 
329  flag_periodicity = cfg.ts_periodicity;
330 
331  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled in layer 1,
332  // disabled in layer 2
333  layer_flags[0] = VPX_EFLAG_FORCE_KF |
336  layer_flags[2] = VP8_EFLAG_NO_REF_ARF |
338  layer_flags[1] =
339  layer_flags[3] = VP8_EFLAG_NO_REF_ARF |
342  break;
343  }
344 
345  case 5:
346  {
347  // 3-layers, 4-frame period
348  int ids[4] = {0,2,1,2};
349  cfg.ts_number_layers = 3;
350  cfg.ts_periodicity = 4;
351  cfg.ts_rate_decimator[0] = 4;
352  cfg.ts_rate_decimator[1] = 2;
353  cfg.ts_rate_decimator[2] = 1;
354  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
355 
356  flag_periodicity = cfg.ts_periodicity;
357 
358  // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled
359  layer_flags[0] = VPX_EFLAG_FORCE_KF |
362  layer_flags[2] = VP8_EFLAG_NO_REF_ARF |
364  layer_flags[1] =
365  layer_flags[3] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
366  break;
367  }
368 
369  case 6:
370  {
371  // NOTE: Probably of academic interest only
372 
373  // 5-layers, 16-frame period
374  int ids[16] = {0,4,3,4,2,4,3,4,1,4,3,4,2,4,3,4};
375  cfg.ts_number_layers = 5;
376  cfg.ts_periodicity = 16;
377  cfg.ts_rate_decimator[0] = 16;
378  cfg.ts_rate_decimator[1] = 8;
379  cfg.ts_rate_decimator[2] = 4;
380  cfg.ts_rate_decimator[3] = 2;
381  cfg.ts_rate_decimator[4] = 1;
382  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
383 
384  flag_periodicity = cfg.ts_periodicity;
385 
386  layer_flags[0] = VPX_EFLAG_FORCE_KF;
387  layer_flags[1] =
388  layer_flags[3] =
389  layer_flags[5] =
390  layer_flags[7] =
391  layer_flags[9] =
392  layer_flags[11] =
393  layer_flags[13] =
394  layer_flags[15] = VP8_EFLAG_NO_UPD_LAST |
397  layer_flags[2] =
398  layer_flags[6] =
399  layer_flags[10] =
400  layer_flags[14] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF;
401  layer_flags[4] =
402  layer_flags[12] = VP8_EFLAG_NO_REF_LAST |
404  layer_flags[8] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
405  break;
406  }
407 
408  case 7:
409  {
410  // 2-layers
411  int ids[2] = {0,1};
412  cfg.ts_number_layers = 2;
413  cfg.ts_periodicity = 2;
414  cfg.ts_rate_decimator[0] = 2;
415  cfg.ts_rate_decimator[1] = 1;
416  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
417 
418  flag_periodicity = 8;
419 
420  // 0=L, 1=GF
421  layer_flags[0] = VPX_EFLAG_FORCE_KF |
424  layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
426  layer_flags[2] =
427  layer_flags[4] =
428  layer_flags[6] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
430  layer_flags[3] =
431  layer_flags[5] = VP8_EFLAG_NO_REF_ARF |
433  layer_flags[7] = VP8_EFLAG_NO_REF_ARF |
437  break;
438  }
439 
440  case 8:
441  default:
442  {
443  // 3-layers
444  int ids[4] = {0,2,1,2};
445  cfg.ts_number_layers = 3;
446  cfg.ts_periodicity = 4;
447  cfg.ts_rate_decimator[0] = 4;
448  cfg.ts_rate_decimator[1] = 2;
449  cfg.ts_rate_decimator[2] = 1;
450  memcpy(cfg.ts_layer_id, ids, sizeof(ids));
451 
452  flag_periodicity = 8;
453 
454  // 0=L, 1=GF, 2=ARF
455  layer_flags[0] = VPX_EFLAG_FORCE_KF |
458  layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
460  layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
462  layer_flags[3] =
463  layer_flags[5] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
464  layer_flags[4] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
466  layer_flags[6] = VP8_EFLAG_NO_REF_ARF |
468  layer_flags[7] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
471  break;
472  }
473  }
474 
475  // Open input file
476  if(!(infile = fopen(argv[1], "rb")))
477  die("Failed to open %s for reading", argv[1]);
478 
479  // Open an output file for each stream
480  for (i=0; i<cfg.ts_number_layers; i++)
481  {
482  char file_name[512];
483  sprintf (file_name, "%s_%d.ivf", argv[2], i);
484  if (!(outfile[i] = fopen(file_name, "wb")))
485  die("Failed to open %s for writing", file_name);
486  write_ivf_file_header(outfile[i], &cfg, 0);
487  }
488 
489  // Initialize codec
490  if (vpx_codec_enc_init (&codec, interface, &cfg, 0))
491  die_codec (&codec, "Failed to initialize encoder");
492 
493  // Cap CPU & first I-frame size
494  vpx_codec_control (&codec, VP8E_SET_CPUUSED, -6);
497 
498  max_intra_size_pct = (int) (((double)cfg.rc_buf_optimal_sz * 0.5)
499  * ((double) cfg.g_timebase.den / cfg.g_timebase.num)
500  / 10.0);
501  //printf ("max_intra_size_pct=%d\n", max_intra_size_pct);
502 
504  max_intra_size_pct);
505  // vpx_codec_control (&codec, VP8E_SET_TOKEN_PARTITIONS,
506  // static_cast<vp8e_token_partitions>(_tokenPartitions));
507 
508  frame_avail = 1;
509  while (frame_avail || got_data) {
510  vpx_codec_iter_t iter = NULL;
511  const vpx_codec_cx_pkt_t *pkt;
512 
513  flags = layer_flags[frame_cnt % flag_periodicity];
514 
515  frame_avail = read_frame(infile, &raw);
516  if (vpx_codec_encode(&codec, frame_avail? &raw : NULL, pts,
517  1, flags, VPX_DL_REALTIME))
518  die_codec(&codec, "Failed to encode frame");
519 
520  // Reset KF flag
521  if (layering_mode != 6)
522  layer_flags[0] &= ~VPX_EFLAG_FORCE_KF;
523 
524  got_data = 0;
525  while ( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {
526  got_data = 1;
527  switch (pkt->kind) {
529  for (i=cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
530  i<cfg.ts_number_layers; i++)
531  {
532  write_ivf_frame_header(outfile[i], pkt);
533  if (fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,
534  outfile[i]));
535  frames_in_layer[i]++;
536  }
537  break;
538  default:
539  break;
540  }
541  printf (pkt->kind == VPX_CODEC_CX_FRAME_PKT
542  && (pkt->data.frame.flags & VPX_FRAME_IS_KEY)? "K":".");
543  fflush (stdout);
544  }
545  frame_cnt++;
546  pts += frame_duration;
547  }
548  printf ("\n");
549  fclose (infile);
550 
551  printf ("Processed %d frames.\n",frame_cnt-1);
552  if (vpx_codec_destroy(&codec))
553  die_codec (&codec, "Failed to destroy codec");
554 
555  // Try to rewrite the output file headers with the actual frame count
556  for (i=0; i<cfg.ts_number_layers; i++)
557  {
558  if (!fseek(outfile[i], 0, SEEK_SET))
559  write_ivf_file_header (outfile[i], &cfg, frames_in_layer[i]);
560  fclose (outfile[i]);
561  }
562 
563  return EXIT_SUCCESS;
564 }
565 
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition: vpx_encoder.h:544
unsigned int ts_number_layers
Number of coding layers.
Definition: vpx_encoder.h:629
control function to set vp8 encoder cpuused
Definition: vp8cx.h:143
#define VP8_EFLAG_NO_REF_LAST
Don't reference the last frame.
Definition: vp8cx.h:48
#define VP8_EFLAG_NO_UPD_GF
Don't update the golden frame.
Definition: vp8cx.h:82
Image Descriptor.
Definition: vpx_image.h:97
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:41
struct vpx_rational g_timebase
Stream timebase units.
Definition: vpx_encoder.h:350
Definition: vpx_encoder.h:243
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition: vpx_encoder.h:534
#define VP8_EFLAG_NO_REF_GF
Don't reference the golden frame.
Definition: vp8cx.h:57
enum vpx_kf_mode kf_mode
Keyframe placement mode.
Definition: vpx_encoder.h:599
int den
Definition: vpx_encoder.h:226
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:486
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition: vpx_encoder.h:475
unsigned int kf_max_dist
Keyframe maximum interval.
Definition: vpx_encoder.h:619
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition: vpx_encoder.h:382
Encoder configuration structure.
Definition: vpx_encoder.h:281
Max data rate for Intra frames.
Definition: vp8cx.h:180
Encoder output packet.
Definition: vpx_encoder.h:178
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition: vpx_encoder.h:517
unsigned int ts_rate_decimator[5]
Frame rate decimation factor for each layer.
Definition: vpx_encoder.h:642
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition: vpx_encoder.h:554
unsigned int kf_min_dist
Keyframe minimum interval.
Definition: vpx_encoder.h:609
Definition: vpx_encoder.h:235
unsigned int ts_layer_id[16]
Template defining the membership of frames to coding layers.
Definition: vpx_encoder.h:660
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:56
unsigned int g_w
Width of the frame.
Definition: vpx_encoder.h:325
unsigned int ts_target_bitrate[5]
Target bitrate for each layer.
Definition: vpx_encoder.h:635
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition: vpx_encoder.h:504
unsigned int g_h
Height of the frame.
Definition: vpx_encoder.h:335
enum vpx_codec_cx_pkt_kind kind
Definition: vpx_encoder.h:180
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition: vpx_encoder.h:405
#define VP8_EFLAG_NO_UPD_LAST
Don't update the last frame.
Definition: vp8cx.h:74
unsigned char * planes[4]
Definition: vpx_image.h:126
#define VPX_DL_REALTIME
Definition: vpx_encoder.h:799
int num
Definition: vpx_encoder.h:225
Definition: vp8cx.h:145
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, unsigned int usage)
Get a default configuration.
enum vpx_enc_pass g_pass
Multi-pass Encoding Mode.
Definition: vpx_encoder.h:367
const char * vpx_codec_error_detail(vpx_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
Provides definitions for using the VP8 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:697
unsigned int rc_resize_allowed
Enable/disable spatial resampling, if supported by the codec.
Definition: vpx_encoder.h:415
unsigned int h
Definition: vpx_image.h:103
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:81
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
Definition: vpx_encoder.h:260
int64_t vpx_codec_pts_t
Time Stamp Type.
Definition: vpx_encoder.h:108
#define VPX_TS_MAX_PERIODICITY
Definition: vpx_encoder.h:38
#define vpx_codec_control(ctx, id, data)
vpx_codec_control wrapper macro
Definition: vpx_codec.h:392
unsigned int ts_periodicity
Length of the sequence defining frame layer membership.
Definition: vpx_encoder.h:651
#define VP8_EFLAG_NO_REF_ARF
Don't reference the alternate reference frame.
Definition: vp8cx.h:66
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
unsigned int w
Definition: vpx_image.h:102
Definition: vp8cx.h:147
const char * vpx_codec_error(vpx_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
#define VPX_FRAME_IS_KEY
Definition: vpx_encoder.h:119
#define VPX_EFLAG_FORCE_KF
Definition: vpx_encoder.h:272
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:182
Definition: vpx_encoder.h:166
vpx_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition: vpx_encoder.h:359
#define VP8_EFLAG_NO_UPD_ARF
Don't update the alternate reference frame.
Definition: vp8cx.h:90
#define VP8_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition: vp8cx.h:114
enum vpx_rc_mode rc_end_usage
Rate control algorithm to use.
Definition: vpx_encoder.h:444
Definition: vpx_encoder.h:233
Codec context structure.
Definition: vpx_codec.h:193