Merge "Removed bc and bc2 vp8_readers from VP8D_COMP"
diff --git a/vp8/common/rtcd.c b/vp8/common/rtcd.c
index 4980f48..3150fff 100644
--- a/vp8/common/rtcd.c
+++ b/vp8/common/rtcd.c
@@ -11,16 +11,7 @@
#define RTCD_C
#include "vpx_rtcd.h"
-#if CONFIG_MULTITHREAD && HAVE_PTHREAD_H
-#include <pthread.h>
-static void once(void (*func)(void))
-{
- static pthread_once_t lock = PTHREAD_ONCE_INIT;
- pthread_once(&lock, func);
-}
-
-
-#elif CONFIG_MULTITHREAD && defined(_WIN32)
+#if CONFIG_MULTITHREAD && defined(_WIN32)
#include <windows.h>
static void once(void (*func)(void))
{
@@ -44,6 +35,15 @@
}
+#elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H
+#include <pthread.h>
+static void once(void (*func)(void))
+{
+ static pthread_once_t lock = PTHREAD_ONCE_INIT;
+ pthread_once(&lock, func);
+}
+
+
#else
/* No-op version that performs no synchronization. vpx_rtcd() is idempotent,
* so as long as your platform provides atomic loads/stores of pointers
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 4885587..fa66206 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -450,72 +450,52 @@
/* A simple function to cyclically refresh the background at a lower Q */
static void cyclic_background_refresh(VP8_COMP *cpi, int Q, int lf_adjustment)
{
- unsigned char *seg_map;
+ unsigned char *seg_map = cpi->segmentation_map;
signed char feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS];
int i;
int block_count = cpi->cyclic_refresh_mode_max_mbs_perframe;
int mbs_in_frame = cpi->common.mb_rows * cpi->common.mb_cols;
- /* Create a temporary map for segmentation data. */
- CHECK_MEM_ERROR(seg_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
+ cpi->cyclic_refresh_q = Q / 2;
- cpi->cyclic_refresh_q = Q;
+ // Set every macroblock to be eligible for update.
+ // For key frame this will reset seg map to 0.
+ vpx_memset(cpi->segmentation_map, 0, mbs_in_frame);
- for (i = Q; i > 0; i--)
- {
- if (vp8_bits_per_mb[cpi->common.frame_type][i] >= ((vp8_bits_per_mb[cpi->common.frame_type][Q]*(Q + 128)) / 64))
- {
- break;
- }
- }
-
- cpi->cyclic_refresh_q = i;
-
- /* Only update for inter frames */
if (cpi->common.frame_type != KEY_FRAME)
{
/* Cycle through the macro_block rows */
/* MB loop to set local segmentation map */
- for (i = cpi->cyclic_refresh_mode_index; i < mbs_in_frame; i++)
+ i = cpi->cyclic_refresh_mode_index;
+ do
{
- /* If the MB is as a candidate for clean up then mark it for
- * possible boost/refresh (segment 1) The segment id may get
- * reset to 0 later if the MB gets coded anything other than
- * last frame 0,0 as only (last frame 0,0) MBs are eligable for
- * refresh : that is to say Mbs likely to be background blocks.
- */
- if (cpi->cyclic_refresh_map[i] == 0)
- {
- seg_map[i] = 1;
- }
- else
- {
- seg_map[i] = 0;
+ /* If the MB is as a candidate for clean up then mark it for
+ * possible boost/refresh (segment 1) The segment id may get
+ * reset to 0 later if the MB gets coded anything other than
+ * last frame 0,0 as only (last frame 0,0) MBs are eligable for
+ * refresh : that is to say Mbs likely to be background blocks.
+ */
+ if (cpi->cyclic_refresh_map[i] == 0)
+ {
+ seg_map[i] = 1;
+ block_count --;
+ }
+ else if (cpi->cyclic_refresh_map[i] < 0)
+ cpi->cyclic_refresh_map[i]++;
- /* Skip blocks that have been refreshed recently anyway. */
- if (cpi->cyclic_refresh_map[i] < 0)
- cpi->cyclic_refresh_map[i]++;
- }
-
-
- if (block_count > 0)
- block_count--;
- else
- break;
+ i++;
+ if (i == mbs_in_frame)
+ i = 0;
}
+ while(block_count && i != cpi->cyclic_refresh_mode_index);
- /* If we have gone through the frame reset to the start */
cpi->cyclic_refresh_mode_index = i;
-
- if (cpi->cyclic_refresh_mode_index >= mbs_in_frame)
- cpi->cyclic_refresh_mode_index = 0;
}
- /* Set the segmentation Map */
- set_segmentation_map(cpi, seg_map);
-
/* Activate segmentation. */
+ cpi->mb.e_mbd.update_mb_segmentation_map = 1;
+ cpi->mb.e_mbd.update_mb_segmentation_data = 1;
enable_segmentation(cpi);
/* Set up the quant segment data */
@@ -533,11 +513,6 @@
/* Initialise the feature data structure */
set_segment_data(cpi, &feature_data[0][0], SEGMENT_DELTADATA);
- /* Delete sementation map */
- vpx_free(seg_map);
-
- seg_map = 0;
-
}
static void set_default_lf_deltas(VP8_COMP *cpi)
@@ -1828,7 +1803,7 @@
* Currently this is tied to error resilliant mode
*/
cpi->cyclic_refresh_mode_enabled = cpi->oxcf.error_resilient_mode;
- cpi->cyclic_refresh_mode_max_mbs_perframe = (cpi->common.mb_rows * cpi->common.mb_cols) / 40;
+ cpi->cyclic_refresh_mode_max_mbs_perframe = (cpi->common.mb_rows * cpi->common.mb_cols) / 5;
cpi->cyclic_refresh_mode_index = 0;
cpi->cyclic_refresh_q = 32;