1 @TEMPLATE encoder_tmpl.c
2 VP8 Scalable Frame Patterns
3 ===========================
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
5 This is an example demonstrating how to control the VP8 encoder's
6 reference frame selection and update mechanism for video applications
7 that benefit from a scalable bitstream.
8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
13 Scalable frame patterns are most useful in an error resilient context,
14 so error resiliency mode is enabled, as in the `error_resilient.c`
15 example. In addition, we want to disable automatic keyframe selection,
16 so we force an interval of 1000 frames.
17 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG2
19 /* Enable error resilient mode */
20 cfg.g_error_resilient = 1;
21 cfg.g_lag_in_frames = 0;
22 cfg.kf_mode = VPX_KF_FIXED;
24 /* Disable automatic keyframe placement */
25 cfg.kf_min_dist = cfg.kf_max_dist = 1000;
26 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG2
28 This example uses the following frame pattern (L->last_frame,
29 G->golden_frame, A->alt_ref_frame):
31 * Frame 0 Intra, use none, update L&G&A
32 * Frame 1 Inter, use LGA, update none
33 * Frame 2 Inter, use LGA, update L
34 * Frame 3 Inter, use LGA, update none
35 * Frame 4 Inter, use GA, update L&G
36 * Frame 5 Inter, use LGA, update none
37 * Frame 6 Inter, use LGA, update L
38 * Frame 7 Inter, use LGA, update none
39 * Frame 8 Inter, use A, update L&G&A
40 * Frame 9 Inter, use LGA, update none
41 * Frame 10 Inter, use LGA, update L
42 * Frame 11 Inter, use LGA, update none
43 * Frame 12 Inter, use GA, update L&G
44 * Frame 13 Inter, use LGA, update none
45 * Frame 14 Inter, use LGA, update L
46 * Frame 15 Inter, use LGA, update none
47 * ...Repeats the pattern from frame 0
49 Change this variable to test the 3 decodable streams case.
50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TWOPASS_VARS
52 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TWOPASS_VARS
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PER_FRAME_CFG
59 switch(frame_cnt % 16) {
61 flags |= VPX_EFLAG_FORCE_KF;
62 flags |= VP8_EFLAG_FORCE_GF;
63 flags |= VP8_EFLAG_FORCE_ARF;
73 flags |= VP8_EFLAG_NO_UPD_LAST;
74 flags |= VP8_EFLAG_NO_UPD_GF;
75 flags |= VP8_EFLAG_NO_UPD_ARF;
83 flags |= VP8_EFLAG_NO_REF_LAST;
84 flags |= VP8_EFLAG_FORCE_GF;
87 flags |= VP8_EFLAG_NO_REF_LAST;
88 flags |= VP8_EFLAG_NO_REF_GF;
89 flags |= VP8_EFLAG_FORCE_GF;
90 flags |= VP8_EFLAG_FORCE_ARF;
93 flags |= VP8_EFLAG_NO_REF_LAST;
94 flags |= VP8_EFLAG_FORCE_GF;
100 switch(frame_cnt % 9) {
104 flags |= VPX_EFLAG_FORCE_KF;
108 cfg.rc_max_quantizer = 26;
109 cfg.rc_min_quantizer = 0;
110 cfg.rc_target_bitrate = 300;
111 flags |= VP8_EFLAG_NO_REF_LAST;
112 flags |= VP8_EFLAG_NO_REF_ARF;
114 flags |= VP8_EFLAG_FORCE_GF;
115 flags |= VP8_EFLAG_FORCE_ARF;
123 cfg.rc_max_quantizer = 45;
124 cfg.rc_min_quantizer = 0;
125 cfg.rc_target_bitrate = 230;
129 cfg.rc_max_quantizer = 45;
130 cfg.rc_min_quantizer = 0;
131 cfg.rc_target_bitrate = 215;
132 flags |= VP8_EFLAG_NO_REF_LAST;
133 flags |= VP8_EFLAG_FORCE_ARF;
137 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PER_FRAME_CFG
139 Observing The Effects
140 ---------------------
141 Use the `decode_with_drops` example to decode with various dropped frame
142 patterns. Good patterns to start with are 1/2, 3/4, 7/8, and 15/16