1
2
3
4
5
6
7
8
9
10
11
12
13
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 "./y4minput.h"
23#include "../vpx_ports/vpx_timer.h"
26#include "vpx_ports/bitops.h"
27
28#include "../tools_common.h"
29#include "../video_writer.h"
30
31#define ROI_MAP 0
32
33#define zero(Dest) memset(&(Dest), 0, sizeof(Dest))
34
35static const char *exec_name;
36
37void usage_exit(void) { exit(EXIT_FAILURE); }
38
39
40enum denoiserStateVp8 {
41 kVp8DenoiserOff,
42 kVp8DenoiserOnYOnly,
43 kVp8DenoiserOnYUV,
44 kVp8DenoiserOnYUVAggressive,
45 kVp8DenoiserOnAdaptive
46};
47
48
49enum denoiserStateVp9 {
50 kVp9DenoiserOff,
51 kVp9DenoiserOnYOnly,
52
53 kVp9DenoiserOnYTwoSpatialLayers
54};
55
56static int mode_to_num_layers[13] = { 1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3, 3 };
57
58
59struct RateControlMetrics {
60
62
64
66
68
70
72
74
76
77
78 double avg_st_encoding_bitrate;
79
80 double variance_st_encoding_bitrate;
81
82 int window_size;
83
84 int window_count;
86};
87
88
89
90
91
92
93
94static void set_rate_control_metrics(struct RateControlMetrics *rc,
96 int i = 0;
97
98
102 rc->layer_pfb[0] =
103 1000.0 * rc->layer_target_bitrate[0] / rc->layer_framerate[0];
104 for (i = 0; i < ts_number_layers; ++i) {
105 if (i > 0) {
107 rc->layer_pfb[i] =
108 1000.0 *
109 (rc->layer_target_bitrate[i] - rc->layer_target_bitrate[i - 1]) /
110 (rc->layer_framerate[i] - rc->layer_framerate[i - 1]);
111 }
112 rc->layer_input_frames[i] = 0;
113 rc->layer_enc_frames[i] = 0;
114 rc->layer_tot_enc_frames[i] = 0;
115 rc->layer_encoding_bitrate[i] = 0.0;
116 rc->layer_avg_frame_size[i] = 0.0;
117 rc->layer_avg_rate_mismatch[i] = 0.0;
118 }
119 rc->window_count = 0;
120 rc->window_size = 15;
121 rc->avg_st_encoding_bitrate = 0.0;
122 rc->variance_st_encoding_bitrate = 0.0;
123
124
126}
127
128static void printout_rate_control_summary(struct RateControlMetrics *rc,
130 int frame_cnt) {
131 unsigned int i = 0;
132 int tot_num_frames = 0;
133 double perc_fluctuation = 0.0;
134 printf("Total number of processed frames: %d\n\n", frame_cnt - 1);
135 printf("Rate control layer stats for %d layer(s):\n\n",
138 const int num_dropped =
139 (i > 0) ? (rc->layer_input_frames[i] - rc->layer_enc_frames[i])
140 : (rc->layer_input_frames[i] - rc->layer_enc_frames[i] - 1);
141 tot_num_frames += rc->layer_input_frames[i];
142 rc->layer_encoding_bitrate[i] = 0.001 * rc->layer_framerate[i] *
143 rc->layer_encoding_bitrate[i] /
144 tot_num_frames;
145 rc->layer_avg_frame_size[i] =
146 rc->layer_avg_frame_size[i] / rc->layer_enc_frames[i];
147 rc->layer_avg_rate_mismatch[i] =
148 100.0 * rc->layer_avg_rate_mismatch[i] / rc->layer_enc_frames[i];
149 printf("For layer#: %d \n", i);
150 printf("Bitrate (target vs actual): %d %f \n", rc->layer_target_bitrate[i],
151 rc->layer_encoding_bitrate[i]);
152 printf("Average frame size (target vs actual): %f %f \n", rc->layer_pfb[i],
153 rc->layer_avg_frame_size[i]);
154 printf("Average rate_mismatch: %f \n", rc->layer_avg_rate_mismatch[i]);
155 printf(
156 "Number of input frames, encoded (non-key) frames, "
157 "and perc dropped frames: %d %d %f \n",
158 rc->layer_input_frames[i], rc->layer_enc_frames[i],
159 100.0 * num_dropped / rc->layer_input_frames[i]);
160 printf("\n");
161 }
162 rc->avg_st_encoding_bitrate = rc->avg_st_encoding_bitrate / rc->window_count;
163 rc->variance_st_encoding_bitrate =
164 rc->variance_st_encoding_bitrate / rc->window_count -
165 (rc->avg_st_encoding_bitrate * rc->avg_st_encoding_bitrate);
166 perc_fluctuation = 100.0 * sqrt(rc->variance_st_encoding_bitrate) /
167 rc->avg_st_encoding_bitrate;
168 printf("Short-time stats, for window of %d frames: \n", rc->window_size);
169 printf("Average, rms-variance, and percent-fluct: %f %f %f \n",
170 rc->avg_st_encoding_bitrate, sqrt(rc->variance_st_encoding_bitrate),
171 perc_fluctuation);
172 if ((frame_cnt - 1) != tot_num_frames)
173 die("Error: Number of input frames not equal to output! \n");
174}
175
176#if ROI_MAP
179 unsigned int i, j;
180 int block_size = 0;
181 uint8_t is_vp8 = strncmp(enc_name, "vp8", 3) == 0 ? 1 : 0;
182 uint8_t is_vp9 = strncmp(enc_name, "vp9", 3) == 0 ? 1 : 0;
183 if (!is_vp8 && !is_vp9) {
184 die("unsupported codec.");
185 }
186 zero(*roi);
187
188 block_size = is_vp9 && !is_vp8 ? 8 : 16;
189
190
191
192 roi->
rows = (cfg->
g_h + block_size - 1) / block_size;
193 roi->
cols = (cfg->
g_w + block_size - 1) / block_size;
194
195
196
197
198
201
202
203
204
206
207 if (is_vp8) {
208
209
210
212 }
213
214 if (is_vp9) {
215
216
218 }
219
220 if (is_vp9) {
221
222
223
224
225
226
229 }
230
231
234 for (i = 0; i < roi->
rows; ++i) {
235 for (j = 0; j < roi->
cols; ++j) {
236 if (i > (roi->
rows >> 2) && i < ((roi->
rows * 3) >> 2) &&
237 j > (roi->
cols >> 2) && j < ((roi->
cols * 3) >> 2)) {
239 }
240 }
241 }
242}
243
245 int *skip_map, int *prev_mask_map, int frame_num) {
246 const int block_size = 8;
247 unsigned int i, j;
248 roi->
rows = (cfg->
g_h + block_size - 1) / block_size;
249 roi->
cols = (cfg->
g_w + block_size - 1) / block_size;
255
259 for (i = 0; i < roi->
rows; ++i) {
260 for (j = 0; j < roi->
cols; ++j) {
261 const int idx = i * roi->
cols + j;
262
263
264
265
266 if (skip_map[idx] == 1 && prev_mask_map[idx] == 1) roi->
roi_map[idx] = 3;
267
268 if (frame_num % 10 == 0)
269 prev_mask_map[idx] = skip_map[idx];
270 else if (prev_mask_map[idx] == 1 && skip_map[idx] == 0)
271 prev_mask_map[idx] = 0;
272 }
273 }
274}
275#endif
276
277
278
279
280
281
282static void set_temporal_layer_pattern(int layering_mode,
284 int *layer_flags,
285 int *flag_periodicity) {
286 switch (layering_mode) {
287 case 0: {
288
289 int ids[1] = { 0 };
291 *flag_periodicity = 1;
295
296 layer_flags[0] =
298 break;
299 }
300 case 1: {
301
302 int ids[2] = { 0, 1 };
304 *flag_periodicity = 2;
309#if 1
310
314 layer_flags[1] =
316#else
317
323#endif
324 break;
325 }
326 case 2: {
327
328 int ids[3] = { 0, 1, 1 };
330 *flag_periodicity = 3;
335
339 layer_flags[1] = layer_flags[2] =
342 break;
343 }
344 case 3: {
345
346 int ids[6] = { 0, 2, 2, 1, 2, 2 };
348 *flag_periodicity = 6;
354
358 layer_flags[3] =
360 layer_flags[1] = layer_flags[2] = layer_flags[4] = layer_flags[5] =
362 break;
363 }
364 case 4: {
365
366 int ids[4] = { 0, 2, 1, 2 };
368 *flag_periodicity = 4;
374
380 layer_flags[1] = layer_flags[3] =
383 break;
384 }
385 case 5: {
386
387 int ids[4] = { 0, 2, 1, 2 };
389 *flag_periodicity = 4;
395
396
400 layer_flags[2] =
402 layer_flags[1] = layer_flags[3] =
405 break;
406 }
407 case 6: {
408
409 int ids[4] = { 0, 2, 1, 2 };
411 *flag_periodicity = 4;
417
421 layer_flags[2] =
423 layer_flags[1] = layer_flags[3] =
425 break;
426 }
427 case 7: {
428
429
430 int ids[16] = { 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4 };
432 *flag_periodicity = 16;
441 layer_flags[1] = layer_flags[3] = layer_flags[5] = layer_flags[7] =
442 layer_flags[9] = layer_flags[11] = layer_flags[13] = layer_flags[15] =
445 layer_flags[2] = layer_flags[6] = layer_flags[10] = layer_flags[14] =
447 layer_flags[4] = layer_flags[12] =
450 break;
451 }
452 case 8: {
453
454 int ids[2] = { 0, 1 };
456 *flag_periodicity = 8;
461
462
463
464
465
466 layer_flags[0] =
468
469 layer_flags[1] =
471
472 layer_flags[2] =
474
477
478 layer_flags[4] = layer_flags[2];
479
480 layer_flags[5] = layer_flags[3];
481
482 layer_flags[6] = layer_flags[4];
483
484 layer_flags[7] = layer_flags[5];
485 break;
486 }
487 case 9: {
488
489 int ids[4] = { 0, 2, 1, 2 };
491 *flag_periodicity = 8;
497
505 layer_flags[3] = layer_flags[5] =
509 layer_flags[6] =
513 break;
514 }
515 case 10: {
516
517
518
519
520 int ids[4] = { 0, 2, 1, 2 };
522 *flag_periodicity = 8;
528
529
530 layer_flags[0] =
532
536
537 layer_flags[2] =
539
542
543 layer_flags[4] =
545
546 layer_flags[5] = layer_flags[3];
547
549
550 layer_flags[7] = layer_flags[3];
551 break;
552 }
553 case 11: {
554
555
556
557
558
559 int ids[4] = { 0, 2, 1, 2 };
561 *flag_periodicity = 4;
567
576 break;
577 }
578 case 12:
579 default: {
580
581
582 int ids[4] = { 0, 2, 1, 2 };
584 *flag_periodicity = 8;
590
591
592 layer_flags[0] =
594 layer_flags[4] = layer_flags[0];
595
597 layer_flags[6] = layer_flags[2];
598
601 layer_flags[3] = layer_flags[1];
602 layer_flags[5] = layer_flags[1];
603 layer_flags[7] = layer_flags[1];
604 break;
605 }
606 }
607}
608
609#if ROI_MAP
610static void read_mask(FILE *mask_file, int *seg_map) {
611 int mask_rows, mask_cols, i, j;
612 int *map_start = seg_map;
613 fscanf(mask_file, "%d %d\n", &mask_cols, &mask_rows);
614 for (i = 0; i < mask_rows; i++) {
615 for (j = 0; j < mask_cols; j++) {
616 fscanf(mask_file, "%d ", &seg_map[j]);
617
618 seg_map[j] = 1 - seg_map[j];
619 }
620 seg_map += mask_cols;
621 }
622 seg_map = map_start;
623}
624#endif
625
626int main(int argc, char **argv) {
630 int frame_cnt = 0;
633 unsigned int width;
634 unsigned int height;
635 uint32_t error_resilient = 0;
636 int speed;
637 int frame_avail;
638 int got_data;
639 int flags = 0;
640 unsigned int i;
641 int pts = 0;
642 int frame_duration = 1;
643 int layering_mode = 0;
645 int flag_periodicity = 1;
646#if ROI_MAP
648#endif
650 const VpxInterface *encoder = NULL;
651 struct VpxInputContext input_ctx;
652 struct RateControlMetrics rc;
653 int64_t cx_time = 0;
654 const int min_args_base = 13;
655#if CONFIG_VP9_HIGHBITDEPTH
657 int input_bit_depth = 8;
658 const int min_args = min_args_base + 1;
659#else
660 const int min_args = min_args_base;
661#endif
662 double sum_bitrate = 0.0;
663 double sum_bitrate2 = 0.0;
664 double framerate = 30.0;
665#if ROI_MAP
666 FILE *mask_file = NULL;
667 int block_size = 8;
668 int mask_rows = 0;
669 int mask_cols = 0;
670 int *mask_map;
671 int *prev_mask_map;
672#endif
673 zero(rc.layer_target_bitrate);
675 memset(&input_ctx, 0, sizeof(input_ctx));
676
677 input_ctx.framerate.numerator = 30;
678 input_ctx.framerate.denominator = 1;
679 input_ctx.only_i420 = 1;
680 input_ctx.bit_depth = 0;
681
682 exec_name = argv[0];
683
684 if (argc < min_args) {
685#if CONFIG_VP9_HIGHBITDEPTH
686 die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
687 "<rate_num> <rate_den> <speed> <frame_drop_threshold> "
688 "<error_resilient> <threads> <mode> "
689 "<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n",
690 argv[0]);
691#else
692 die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
693 "<rate_num> <rate_den> <speed> <frame_drop_threshold> "
694 "<error_resilient> <threads> <mode> "
695 "<Rate_0> ... <Rate_nlayers-1> \n",
696 argv[0]);
697#endif
698 }
699
700 encoder = get_vpx_encoder_by_name(argv[3]);
701 if (!encoder) die("Unsupported codec.");
702
704
705 width = (unsigned int)strtoul(argv[4], NULL, 0);
706 height = (unsigned int)strtoul(argv[5], NULL, 0);
707 if (width < 16 || width % 2 || height < 16 || height % 2) {
708 die("Invalid resolution: %d x %d", width, height);
709 }
710
711 layering_mode = (int)strtol(argv[12], NULL, 0);
712 if (layering_mode < 0 || layering_mode > 13) {
713 die("Invalid layering mode (0..12) %s", argv[12]);
714 }
715
716#if ROI_MAP
717 if (argc != min_args + mode_to_num_layers[layering_mode] + 1) {
718 die("Invalid number of arguments");
719 }
720#else
721 if (argc != min_args + mode_to_num_layers[layering_mode]) {
722 die("Invalid number of arguments");
723 }
724#endif
725
726 input_ctx.filename = argv[1];
727 open_input_file(&input_ctx);
728
729#if CONFIG_VP9_HIGHBITDEPTH
730 switch (strtol(argv[argc - 1], NULL, 0)) {
731 case 8:
733 input_bit_depth = 8;
734 break;
735 case 10:
737 input_bit_depth = 10;
738 break;
739 case 12:
741 input_bit_depth = 12;
742 break;
743 default: die("Invalid bit depth (8, 10, 12) %s", argv[argc - 1]);
744 }
745
746
747 if (input_ctx.file_type != FILE_TYPE_Y4M) {
749 &raw,
751 width, height, 32)) {
752 die("Failed to allocate image (%dx%d)", width, height);
753 }
754 }
755#else
756
757 if (input_ctx.file_type != FILE_TYPE_Y4M) {
759 die("Failed to allocate image (%dx%d)", width, height);
760 }
761 }
762#endif
763
764
766 if (res) {
768 return EXIT_FAILURE;
769 }
770
771
774
775#if CONFIG_VP9_HIGHBITDEPTH
780 }
781#endif
782
783
786
787 speed = (int)strtol(argv[8], NULL, 0);
788 if (speed < 0) {
789 die("Invalid speed setting: must be positive");
790 }
791 if (strncmp(encoder->name, "vp9", 3) == 0 && speed > 9) {
792 warn("Mapping speed %d to speed 9.\n", speed);
793 }
794
795 for (i = min_args_base;
796 (int)i < min_args_base + mode_to_num_layers[layering_mode]; ++i) {
797 rc.layer_target_bitrate[i - 13] = (int)strtol(argv[i], NULL, 0);
798 if (strncmp(encoder->name, "vp8", 3) == 0)
800 else if (strncmp(encoder->name, "vp9", 3) == 0)
802 }
803
804
815
816
818
819
820 cfg.
g_threads = (
unsigned int)strtoul(argv[11], NULL, 0);
821
822 error_resilient = (uint32_t)strtoul(argv[10], NULL, 0);
823 if (error_resilient != 0 && error_resilient != 1) {
824 die("Invalid value for error resilient (0, 1): %d.", error_resilient);
825 }
826
830
831
833
835
836 set_temporal_layer_pattern(layering_mode, &cfg, layer_flags,
837 &flag_periodicity);
838
839 set_rate_control_metrics(&rc, &cfg);
840
841 if (input_ctx.file_type == FILE_TYPE_Y4M) {
842 if (input_ctx.width != cfg.
g_w || input_ctx.height != cfg.
g_h) {
843 die(
"Incorrect width or height: %d x %d", cfg.
g_w, cfg.
g_h);
844 }
847 die("Incorrect framerate: numerator %d denominator %d",
849 }
850 }
851
853
855 char file_name[PATH_MAX];
856 VpxVideoInfo info;
857 info.codec_fourcc = encoder->fourcc;
858 info.frame_width = cfg.
g_w;
859 info.frame_height = cfg.
g_h;
862
863 snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);
864 outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);
865 if (!outfile[i]) die("Failed to open %s for writing", file_name);
866
867 assert(outfile[i] != NULL);
868 }
869
871
872
873#if CONFIG_VP9_HIGHBITDEPTH
875 &codec, encoder->codec_interface(), &cfg,
877#else
879#endif
880 die("Failed to initialize encoder");
881
882#if ROI_MAP
883 mask_rows = (cfg.
g_h + block_size - 1) / block_size;
884 mask_cols = (cfg.
g_w + block_size - 1) / block_size;
885 mask_map = (int *)calloc(mask_rows * mask_cols, sizeof(*mask_map));
886 prev_mask_map = (int *)calloc(mask_rows * mask_cols, sizeof(*mask_map));
887#endif
888
889 if (strncmp(encoder->name, "vp8", 3) == 0) {
894#if ROI_MAP
895 set_roi_map(encoder->name, &cfg, &roi);
897 die_codec(&codec, "Failed to set ROI map");
898#endif
899 } else if (strncmp(encoder->name, "vp9", 3) == 0) {
901 memset(&svc_params, 0, sizeof(svc_params));
914
917 else
920 die_codec(&codec, "Failed to set SVC");
924 }
928 }
929 if (strncmp(encoder->name, "vp8", 3) == 0) {
931 }
933
934
935
936 {
937 const int max_intra_size_pct = 1000;
939 max_intra_size_pct);
940 }
941
942 frame_avail = 1;
943 while (frame_avail || got_data) {
944 struct vpx_usec_timer timer;
947#if ROI_MAP
948 char mask_file_name[255];
949#endif
950
955 if (strncmp(encoder->name, "vp9", 3) == 0) {
957 } else if (strncmp(encoder->name, "vp8", 3) == 0) {
960 }
961 flags = layer_flags[frame_cnt % flag_periodicity];
962 if (layering_mode == 0) flags = 0;
963#if ROI_MAP
964 snprintf(mask_file_name, sizeof(mask_file_name), "%s%05d.txt",
965 argv[argc - 1], frame_cnt);
966 mask_file = fopen(mask_file_name, "r");
967 if (mask_file != NULL) {
968 read_mask(mask_file, mask_map);
969 fclose(mask_file);
970
971 set_roi_skip_map(&cfg, &roi, mask_map, prev_mask_map, frame_cnt);
973 die_codec(&codec, "Failed to set ROI map");
974 }
975#endif
976 frame_avail = read_frame(&input_ctx, &raw);
978 vpx_usec_timer_start(&timer);
981 die_codec(&codec, "Failed to encode frame");
982 }
983 vpx_usec_timer_mark(&timer);
984 cx_time += vpx_usec_timer_elapsed(&timer);
985
986 if (layering_mode != 7) {
988 }
989 got_data = 0;
991 got_data = 1;
996 vpx_video_writer_write_frame(outfile[i], pkt->
data.
frame.
buf,
998 ++rc.layer_tot_enc_frames[i];
999 rc.layer_encoding_bitrate[i] += 8.0 * pkt->
data.
frame.
sz;
1000
1003 rc.layer_avg_frame_size[i] += 8.0 * pkt->
data.
frame.
sz;
1004 rc.layer_avg_rate_mismatch[i] +=
1005 fabs(8.0 * pkt->
data.
frame.
sz - rc.layer_pfb[i]) /
1006 rc.layer_pfb[i];
1007 ++rc.layer_enc_frames[i];
1008 }
1009 }
1010
1011
1012
1013 if (rc.window_size == 0) rc.window_size = 15;
1014 if (frame_cnt > rc.window_size) {
1015 sum_bitrate += 0.001 * 8.0 * pkt->
data.
frame.
sz * framerate;
1016 if (frame_cnt % rc.window_size == 0) {
1017 rc.window_count += 1;
1018 rc.avg_st_encoding_bitrate += sum_bitrate / rc.window_size;
1019 rc.variance_st_encoding_bitrate +=
1020 (sum_bitrate / rc.window_size) *
1021 (sum_bitrate / rc.window_size);
1022 sum_bitrate = 0.0;
1023 }
1024 }
1025
1026 if (frame_cnt > rc.window_size + rc.window_size / 2) {
1027 sum_bitrate2 += 0.001 * 8.0 * pkt->
data.
frame.
sz * framerate;
1028 if (frame_cnt > 2 * rc.window_size &&
1029 frame_cnt % rc.window_size == 0) {
1030 rc.window_count += 1;
1031 rc.avg_st_encoding_bitrate += sum_bitrate2 / rc.window_size;
1032 rc.variance_st_encoding_bitrate +=
1033 (sum_bitrate2 / rc.window_size) *
1034 (sum_bitrate2 / rc.window_size);
1035 sum_bitrate2 = 0.0;
1036 }
1037 }
1038 break;
1039 default: break;
1040 }
1041 }
1042 ++frame_cnt;
1043 pts += frame_duration;
1044 }
1045#if ROI_MAP
1046 free(mask_map);
1047 free(prev_mask_map);
1048#endif
1049 close_input_file(&input_ctx);
1050 printout_rate_control_summary(&rc, &cfg, frame_cnt);
1051 printf("\n");
1052 printf("Frame cnt and encoding time/FPS stats for encoding: %d %f %f \n",
1053 frame_cnt, 1000 * (float)cx_time / (double)(frame_cnt * 1000000),
1054 1000000 * (double)frame_cnt / (double)cx_time);
1055
1057
1058
1059 for (i = 0; i < cfg.
ts_number_layers; ++i) vpx_video_writer_close(outfile[i]);
1060
1061 if (input_ctx.file_type != FILE_TYPE_Y4M) {
1063 }
1064
1065#if ROI_MAP
1067#endif
1068 return EXIT_SUCCESS;
1069}
const char * vpx_codec_err_to_string(vpx_codec_err_t err)
Convert error number to printable string.
struct vpx_codec_ctx vpx_codec_ctx_t
Codec context structure.
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
const void * vpx_codec_iter_t
Iterator.
Definition vpx_codec.h:190
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
enum vpx_bit_depth vpx_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
#define vpx_codec_control(ctx, id, data)
vpx_codec_control wrapper macro
Definition vpx_codec.h:408
vpx_codec_err_t
Algorithm return codes.
Definition vpx_codec.h:93
@ VPX_BITS_8
Definition vpx_codec.h:221
@ VPX_BITS_12
Definition vpx_codec.h:223
@ VPX_BITS_10
Definition vpx_codec.h:222
#define VPX_DL_REALTIME
deadline parameter analogous to VPx REALTIME mode.
Definition vpx_encoder.h:1004
struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t
Encoder configuration structure.
#define VPX_TS_MAX_LAYERS
Definition vpx_encoder.h:41
#define vpx_codec_enc_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_enc_init_ver()
Definition vpx_encoder.h:900
#define VPX_EFLAG_FORCE_KF
Definition vpx_encoder.h:268
struct vpx_svc_parameters vpx_svc_extra_cfg_t
vp9 svc extra configure parameters
const vpx_codec_cx_pkt_t * vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Encoded data iterator.
#define VPX_TS_MAX_PERIODICITY
Definition vpx_encoder.h:38
#define VPX_CODEC_USE_HIGHBITDEPTH
Definition vpx_encoder.h:97
#define VPX_MAX_LAYERS
Definition vpx_encoder.h:44
#define VPX_FRAME_IS_KEY
Definition vpx_encoder.h:123
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.
struct vpx_codec_cx_pkt vpx_codec_cx_pkt_t
Encoder output packet.
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, vpx_enc_deadline_t deadline)
Encode a frame.
@ VPX_CODEC_CX_FRAME_PKT
Definition vpx_encoder.h:155
@ VPX_KF_AUTO
Definition vpx_encoder.h:256
@ VPX_CBR
Definition vpx_encoder.h:241
#define VP8_EFLAG_NO_UPD_ARF
Don't update the alternate reference frame.
Definition vp8cx.h:112
struct vpx_svc_layer_id vpx_svc_layer_id_t
vp9 svc layer parameters
#define VP8_EFLAG_NO_UPD_ENTROPY
Disable entropy update.
Definition vp8cx.h:133
#define VP8_EFLAG_NO_UPD_LAST
Don't update the last frame.
Definition vp8cx.h:98
#define VP8_EFLAG_NO_REF_ARF
Don't reference the alternate reference frame.
Definition vp8cx.h:91
struct vpx_roi_map vpx_roi_map_t
vpx region of interest map
#define VP8_EFLAG_NO_UPD_GF
Don't update the golden frame.
Definition vp8cx.h:105
#define VP8_EFLAG_NO_REF_GF
Don't reference the golden frame.
Definition vp8cx.h:83
#define VP8_EFLAG_NO_REF_LAST
Don't reference the last frame.
Definition vp8cx.h:75
@ VP9E_SET_FRAME_PERIODIC_BOOST
Codec control function to enable/disable periodic Q boost.
Definition vp8cx.h:431
@ VP9E_SET_SVC_LAYER_ID
Codec control function to set svc layer for spatial and temporal.
Definition vp8cx.h:471
@ VP8E_SET_MAX_INTRA_BITRATE_PCT
Codec control function to set Max data rate for Intra frames.
Definition vp8cx.h:275
@ VP9E_SET_ROI_MAP
Codec control function to pass an ROI map to encoder.
Definition vp8cx.h:454
@ VP8E_SET_ROI_MAP
Codec control function to pass an ROI map to encoder.
Definition vp8cx.h:147
@ VP9E_SET_AQ_MODE
Codec control function to set adaptive quantization mode.
Definition vp8cx.h:416
@ VP8E_SET_NOISE_SENSITIVITY
control function to set noise sensitivity
Definition vp8cx.h:191
@ VP8E_SET_TOKEN_PARTITIONS
Codec control function to set the number of token partitions.
Definition vp8cx.h:212
@ VP9E_SET_POSTENCODE_DROP
Codec control function to enable postencode frame drop.
Definition vp8cx.h:692
@ VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR
Codec control function to disable increase Q on overshoot in CBR.
Definition vp8cx.h:708
@ VP9E_SET_SVC_PARAMETERS
Codec control function to set parameters for SVC.
Definition vp8cx.h:462
@ VP9E_SET_FRAME_PARALLEL_DECODING
Codec control function to enable frame parallel decoding feature.
Definition vp8cx.h:403
@ VP8E_SET_GF_CBR_BOOST_PCT
Boost percentage for Golden Frame in CBR mode.
Definition vp8cx.h:607
@ VP9E_SET_TUNE_CONTENT
Codec control function to set content type.
Definition vp8cx.h:481
@ VP9E_SET_SVC
Codec control function to turn on/off SVC in encoder.
Definition vp8cx.h:448
@ VP9E_SET_ROW_MT
Codec control function to set row level multi-threading.
Definition vp8cx.h:576
@ VP8E_SET_CPUUSED
Codec control function to set encoder internal speed settings.
Definition vp8cx.h:173
@ VP8E_SET_TEMPORAL_LAYER_ID
Codec control function to set the temporal layer id.
Definition vp8cx.h:322
@ VP9E_SET_TILE_COLUMNS
Codec control function to set number of tile columns.
Definition vp8cx.h:369
@ VP8E_SET_STATIC_THRESHOLD
Codec control function to set the threshold for MBs treated static.
Definition vp8cx.h:206
@ VP8E_SET_SCREEN_CONTENT_MODE
Codec control function to set encoder screen content mode.
Definition vp8cx.h:330
@ VP9E_SET_DISABLE_LOOPFILTER
Codec control function to disable loopfilter.
Definition vp8cx.h:717
@ VP9E_SET_NOISE_SENSITIVITY
Codec control function to set noise sensitivity.
Definition vp8cx.h:439
@ VP9E_SET_GF_CBR_BOOST_PCT
Boost percentage for Golden Frame in CBR mode.
Definition vp8cx.h:311
@ VP9E_TEMPORAL_LAYERING_MODE_BYPASS
Bypass mode. Used when application needs to control temporal layering. This will only work when the n...
Definition vp8cx.h:808
union vpx_codec_cx_pkt::@105367030154200007005241002351245163342006201240 data
struct vpx_codec_cx_pkt::@105367030154200007005241002351245163342006201240::@337301343345304110063267327113124066016321050157 frame
vpx_codec_frame_flags_t flags
Definition vpx_encoder.h:177
enum vpx_codec_cx_pkt_kind kind
Definition vpx_encoder.h:168
size_t sz
Definition vpx_encoder.h:172
void * buf
Definition vpx_encoder.h:171
unsigned int rc_resize_allowed
Enable/disable spatial resampling, if supported by the codec.
Definition vpx_encoder.h:408
int temporal_layering_mode
Temporal layering mode indicating which temporal layering scheme to use.
Definition vpx_encoder.h:703
unsigned int kf_min_dist
Keyframe minimum interval.
Definition vpx_encoder.h:615
unsigned int rc_min_quantizer
Minimum (Best Quality) Quantizer.
Definition vpx_encoder.h:483
unsigned int ts_number_layers
Number of temporal coding layers.
Definition vpx_encoder.h:654
unsigned int ss_number_layers
Number of spatial coding layers.
Definition vpx_encoder.h:634
unsigned int g_profile
Bitstream profile to use.
Definition vpx_encoder.h:303
unsigned int layer_target_bitrate[12]
Target bitrate for each spatial/temporal layer.
Definition vpx_encoder.h:694
unsigned int g_h
Height of the frame.
Definition vpx_encoder.h:321
enum vpx_kf_mode kf_mode
Keyframe placement mode.
Definition vpx_encoder.h:606
unsigned int ts_layer_id[16]
Template defining the membership of frames to temporal layers.
Definition vpx_encoder.h:686
vpx_codec_er_flags_t g_error_resilient
Enable error resilient modes.
Definition vpx_encoder.h:359
unsigned int ts_periodicity
Length of the sequence defining frame temporal layer membership.
Definition vpx_encoder.h:677
unsigned int rc_overshoot_pct
Rate control adaptation overshoot control.
Definition vpx_encoder.h:526
unsigned int g_w
Width of the frame.
Definition vpx_encoder.h:312
unsigned int rc_buf_sz
Decoder Buffer Size.
Definition vpx_encoder.h:541
unsigned int rc_dropframe_thresh
Temporal resampling configuration, if supported by the codec.
Definition vpx_encoder.h:399
struct vpx_rational g_timebase
Stream timebase units.
Definition vpx_encoder.h:351
unsigned int rc_max_quantizer
Maximum (Worst Quality) Quantizer.
Definition vpx_encoder.h:492
unsigned int g_lag_in_frames
Allow lagged encoding.
Definition vpx_encoder.h:380
enum vpx_rc_mode rc_end_usage
Rate control algorithm to use.
Definition vpx_encoder.h:448
unsigned int rc_buf_initial_sz
Decoder Buffer Initial Size.
Definition vpx_encoder.h:550
vpx_bit_depth_t g_bit_depth
Bit-depth of the codec.
Definition vpx_encoder.h:329
unsigned int rc_buf_optimal_sz
Decoder Buffer Optimal Size.
Definition vpx_encoder.h:559
unsigned int rc_target_bitrate
Target data rate.
Definition vpx_encoder.h:470
unsigned int ts_target_bitrate[5]
Target bitrate for each temporal layer.
Definition vpx_encoder.h:661
unsigned int g_input_bit_depth
Bit-depth of the input frames.
Definition vpx_encoder.h:337
unsigned int rc_undershoot_pct
Rate control adaptation undershoot control.
Definition vpx_encoder.h:511
unsigned int ts_rate_decimator[5]
Frame rate decimation factor for each temporal layer.
Definition vpx_encoder.h:668
unsigned int kf_max_dist
Keyframe maximum interval.
Definition vpx_encoder.h:624
unsigned int g_threads
Maximum number of threads to use.
Definition vpx_encoder.h:293
int den
Definition vpx_encoder.h:228
int num
Definition vpx_encoder.h:227
int skip[8]
Definition vp8cx.h:837
unsigned int static_threshold[4]
Definition vp8cx.h:840
unsigned int rows
Definition vp8cx.h:831
unsigned int cols
Definition vp8cx.h:832
int ref_frame[8]
Definition vp8cx.h:838
int delta_q[8]
Definition vp8cx.h:834
unsigned char * roi_map
Definition vp8cx.h:830
int delta_lf[8]
Definition vp8cx.h:835
int temporal_layer_id
Definition vp8cx.h:905
int temporal_layer_id_per_spatial[5]
Definition vp8cx.h:906
int spatial_layer_id
Definition vp8cx.h:903
int min_quantizers[12]
Definition vpx_encoder.h:858
int scaling_factor_num[12]
Definition vpx_encoder.h:859
int max_quantizers[12]
Definition vpx_encoder.h:857
int scaling_factor_den[12]
Definition vpx_encoder.h:860
Provides definitions for using VP8 or VP9 encoder algorithm within the vpx Codec Interface.
Describes the encoder algorithm interface to applications.
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.
@ VPX_IMG_FMT_I42016
Definition vpx_image.h:47
@ VPX_IMG_FMT_I420
Definition vpx_image.h:42
struct vpx_image vpx_image_t
Image Descriptor.
void vpx_img_free(vpx_image_t *img)
Close an image descriptor.