1 @TEMPLATE encoder_tmpl.c
2 VP8 Set Active and ROI Maps
3 ===========================
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
5 This is an example demonstrating how to control the VP8 encoder's
8 ROI (Reigon of Interest) maps are a way for the application to assign
9 each macroblock in the image to a region, and then set quantizer and
10 filtering parameters on that image.
12 Active maps are a way for the application to specify on a
13 macroblock-by-macroblock basis whether there is any activity in that
15 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
20 An ROI map is set on frame 22. If the width of the image in macroblocks
21 is evenly divisble by 4, then the output will appear to have distinct
22 columns, where the quantizer, loopfilter, and static threshold differ
23 from column to column.
25 An active map is set on frame 33. If the width of the image in macroblocks
26 is evenly divisble by 4, then the output will appear to have distinct
27 columns, where one column will have motion and the next will not.
29 The active map is cleared on frame 44.
30 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PER_FRAME_CFG
31 if(frame_cnt + 1 == 22) {
35 roi.rows = cfg.g_h/16;
36 roi.cols = cfg.g_w/16;
48 roi.static_threshold[0] = 1500;
49 roi.static_threshold[1] = 1000;
50 roi.static_threshold[2] = 500;
51 roi.static_threshold[3] = 0;
53 /* generate an ROI map for example */
54 roi.roi_map = malloc(roi.rows * roi.cols);
55 for(i=0;i<roi.rows*roi.cols;i++)
56 roi.roi_map[i] = i & 3;
58 if(vpx_codec_control(&codec, VP8E_SET_ROI_MAP, &roi))
59 die_codec(&codec, "Failed to set ROI map");
62 } else if(frame_cnt + 1 == 33) {
63 vpx_active_map_t active;
66 active.rows = cfg.g_h/16;
67 active.cols = cfg.g_w/16;
69 /* generate active map for example */
70 active.active_map = malloc(active.rows * active.cols);
71 for(i=0;i<active.rows*active.cols;i++)
72 active.active_map[i] = i & 1;
74 if(vpx_codec_control(&codec, VP8E_SET_ACTIVEMAP, &active))
75 die_codec(&codec, "Failed to set active map");
77 free(active.active_map);
78 } else if(frame_cnt + 1 == 44) {
79 vpx_active_map_t active;
81 active.rows = cfg.g_h/16;
82 active.cols = cfg.g_w/16;
84 /* pass in null map to disable active_map*/
85 active.active_map = NULL;
87 if(vpx_codec_control(&codec, VP8E_SET_ACTIVEMAP, &active))
88 die_codec(&codec, "Failed to set active map");
90 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PER_FRAME_CFG
95 Use the `simple_decoder` example to decode this sample, and observe
96 the change in the image at frames 22, 33, and 44.