diff options
author | John Koleszar <jkoleszar@google.com> | 2010-12-14 00:05:07 -0500 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2010-12-14 00:05:07 -0500 |
commit | 7211ac407b78d26a6ddfb0f2bd8f6588e8d0fbd6 (patch) | |
tree | 309816e03e48b7b35711560495cd548b4f9ee1c2 /vp8/encoder | |
parent | 373781a24a9e96e5ccd0f96673313a3b4135c812 (diff) | |
parent | 3809d7bbd984a763cf7f288a51c9924667addf4a (diff) | |
download | libvpx-7211ac407b78d26a6ddfb0f2bd8f6588e8d0fbd6.tar libvpx-7211ac407b78d26a6ddfb0f2bd8f6588e8d0fbd6.tar.gz libvpx-7211ac407b78d26a6ddfb0f2bd8f6588e8d0fbd6.tar.bz2 libvpx-7211ac407b78d26a6ddfb0f2bd8f6588e8d0fbd6.zip |
Merge remote branch 'internal/upstream' into HEAD
Diffstat (limited to 'vp8/encoder')
-rw-r--r-- | vp8/encoder/ethreading.c | 23 | ||||
-rw-r--r-- | vp8/encoder/onyx_if.c | 5 | ||||
-rw-r--r-- | vp8/encoder/onyx_int.h | 3 | ||||
-rw-r--r-- | vp8/encoder/preproc.c | 251 | ||||
-rw-r--r-- | vp8/encoder/tokenize.c | 8 | ||||
-rw-r--r-- | vp8/encoder/tokenize.h | 7 | ||||
-rw-r--r-- | vp8/encoder/x86/preproc_mmx.c | 298 |
7 files changed, 25 insertions, 570 deletions
diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index 4d0f94871..a40897ba2 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -132,6 +132,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) else xd->mode_info_context->mbmi.segment_id = 0; // Set to Segment 0 by default + x->active_ptr = cpi->active_map + seg_map_index + mb_col; if (cm->frame_type == KEY_FRAME) { @@ -163,8 +164,28 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) if ((xd->mode_info_context->mbmi.mode == ZEROMV) && (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)) cpi->inter_zz_count ++; - } + // Special case code for cyclic refresh + // If cyclic update enabled then copy xd->mbmi.segment_id; (which may have been updated based on mode + // during vp8cx_encode_inter_macroblock()) back into the global sgmentation map + if (cpi->cyclic_refresh_mode_enabled && xd->segmentation_enabled) + { + cpi->segmentation_map[seg_map_index+mb_col] = xd->mode_info_context->mbmi.segment_id; + + // If the block has been refreshed mark it as clean (the magnitude of the -ve influences how long it will be before we consider another refresh): + // Else if it was coded (last frame 0,0) and has not already been refreshed then mark it as a candidate for cleanup next time (marked 0) + // else mark it as dirty (1). + if (xd->mode_info_context->mbmi.segment_id) + cpi->cyclic_refresh_map[seg_map_index+mb_col] = -1; + else if ((xd->mode_info_context->mbmi.mode == ZEROMV) && (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)) + { + if (cpi->cyclic_refresh_map[seg_map_index+mb_col] == 1) + cpi->cyclic_refresh_map[seg_map_index+mb_col] = 0; + } + else + cpi->cyclic_refresh_map[seg_map_index+mb_col] = 1; + } + } cpi->tplist[mb_row].stop = *tp; x->gf_active_ptr++; // Increment pointer into gf useage flags structure for next mb diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 47a3da4ce..37f22fe7e 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3882,7 +3882,6 @@ static void encode_frame_to_data_rate if (cm->frame_type == KEY_FRAME) { vp8_de_noise(cpi->Source, cpi->Source, l , 1, 0, RTCD(postproc)); - cpi->ppi.frame = 0; } else { @@ -3894,10 +3893,6 @@ static void encode_frame_to_data_rate { src += cpi->Source->y_stride * (cpi->Source->y_height - 1); } - - //temp_filter(&cpi->ppi,src,src, - // cm->last_frame.y_width * cm->last_frame.y_height, - // cpi->oxcf.noise_sensitivity); } } diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index ecc75c51f..33de6e2d7 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -18,7 +18,6 @@ #include "treewriter.h" #include "tokenize.h" #include "onyxc_int.h" -#include "preproc.h" #include "variance.h" #include "dct.h" #include "encodemb.h" @@ -468,8 +467,6 @@ typedef struct unsigned char *output_partition2; size_t output_partition2size; - pre_proc_instance ppi; - int frames_to_key; int gfu_boost; int kf_boost; diff --git a/vp8/encoder/preproc.c b/vp8/encoder/preproc.c deleted file mode 100644 index bd918fa3c..000000000 --- a/vp8/encoder/preproc.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/**************************************************************************** -* -* Module Title : preproc.c -* -* Description : Simple pre-processor. -* -****************************************************************************/ - -/**************************************************************************** -* Header Files -****************************************************************************/ - -#include "memory.h" -#include "preproc7.h" -#include "vpx_mem/vpx_mem.h" - -/**************************************************************************** -* Macros -****************************************************************************/ -#define FRAMECOUNT 7 -#define ROUNDUP32(X) ( ( ( (unsigned long) X ) + 31 )&( 0xFFFFFFE0 ) ) - -/**************************************************************************** -* Imports -****************************************************************************/ -extern void vp8_get_processor_flags(int *mmx_enabled, int *xmm_enabled, int *wmt_enabled); - -/**************************************************************************** -* Exported Global Variables -****************************************************************************/ -void (*temp_filter)(pre_proc_instance *ppi, unsigned char *s, unsigned char *d, int bytes, int strength); -void temp_filter_mmx -( - pre_proc_instance *ppi, - unsigned char *s, - unsigned char *d, - int bytes, - int strength -); -void temp_filter_wmt -( - pre_proc_instance *ppi, - unsigned char *s, - unsigned char *d, - int bytes, - int strength -); - -/**************************************************************************** - * - * ROUTINE : temp_filter_c - * - * INPUTS : pre_proc_instance *ppi : Pointer to pre-processor instance. - * unsigned char *s : Pointer to source frame. - * unsigned char *d : Pointer to destination frame. - * int bytes : Number of bytes to filter. - * int strength : Strength of filter to apply. - * - * OUTPUTS : None. - * - * RETURNS : void - * - * FUNCTION : Performs a closesness adjusted temporarl blur - * - * SPECIAL NOTES : Destination frame can be same as source frame. - * - ****************************************************************************/ -void temp_filter_c -( - pre_proc_instance *ppi, - unsigned char *s, - unsigned char *d, - int bytes, - int strength -) -{ - int byte = 0; - unsigned char *frameptr = ppi->frame_buffer; - - if (ppi->frame == 0) - { - do - { - int frame = 0; - - do - { - *frameptr = s[byte]; - ++frameptr; - ++frame; - } - while (frame < FRAMECOUNT); - - d[byte] = s[byte]; - - ++byte; - } - while (byte < bytes); - } - else - { - int modifier; - int offset = (ppi->frame % FRAMECOUNT); - - do - { - int accumulator = 0; - int count = 0; - int frame = 0; - - frameptr[offset] = s[byte]; - - do - { - int pixel_value = *frameptr; - - modifier = s[byte]; - modifier -= pixel_value; - modifier *= modifier; - modifier >>= strength; - modifier *= 3; - - if (modifier > 16) - modifier = 16; - - modifier = 16 - modifier; - - accumulator += modifier * pixel_value; - - count += modifier; - - frameptr++; - - ++frame; - } - while (frame < FRAMECOUNT); - - accumulator += (count >> 1); - accumulator *= ppi->fixed_divide[count]; - accumulator >>= 16; - - d[byte] = accumulator; - - ++byte; - } - while (byte < bytes); - } - - ++ppi->frame; -} -/**************************************************************************** - * - * ROUTINE : delete_pre_proc - * - * INPUTS : pre_proc_instance *ppi : Pointer to pre-processor instance. - * - * OUTPUTS : None. - * - * RETURNS : void - * - * FUNCTION : Deletes a pre-processing instance. - * - * SPECIAL NOTES : None. - * - ****************************************************************************/ -void delete_pre_proc(pre_proc_instance *ppi) -{ - if (ppi->frame_buffer_alloc) - vpx_free(ppi->frame_buffer_alloc); - - ppi->frame_buffer_alloc = 0; - ppi->frame_buffer = 0; - - if (ppi->fixed_divide_alloc) - vpx_free(ppi->fixed_divide_alloc); - - ppi->fixed_divide_alloc = 0; - ppi->fixed_divide = 0; -} - -/**************************************************************************** - * - * ROUTINE : init_pre_proc - * - * INPUTS : pre_proc_instance *ppi : Pointer to pre-processor instance. - * int frame_size : Number of bytes in one frame. - * - * OUTPUTS : None. - * - * RETURNS : int: 1 if successful, 0 if failed. - * - * FUNCTION : Initializes prepprocessor instance. - * - * SPECIAL NOTES : None. - * - ****************************************************************************/ -int init_pre_proc7(pre_proc_instance *ppi, int frame_size) -{ - int i; - int mmx_enabled; - int xmm_enabled; - int wmt_enabled; - - vp8_get_processor_flags(&mmx_enabled, &xmm_enabled, &wmt_enabled); - - if (wmt_enabled) - temp_filter = temp_filter_wmt; - else if (mmx_enabled) - temp_filter = temp_filter_mmx; - else - temp_filter = temp_filter_c; - - - delete_pre_proc(ppi); - - ppi->frame_buffer_alloc = vpx_malloc(32 + frame_size * FRAMECOUNT * sizeof(unsigned char)); - - if (!ppi->frame_buffer_alloc) - { - delete_pre_proc(ppi); - return 0; - } - - ppi->frame_buffer = (unsigned char *) ROUNDUP32(ppi->frame_buffer_alloc); - - ppi->fixed_divide_alloc = vpx_malloc(32 + 255 * sizeof(unsigned int)); - - if (!ppi->fixed_divide_alloc) - { - delete_pre_proc(ppi); - return 0; - } - - ppi->fixed_divide = (unsigned int *) ROUNDUP32(ppi->fixed_divide_alloc); - - for (i = 1; i < 255; i++) - ppi->fixed_divide[i] = 0x10000 / i; - - return 1; -} diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c index e4da83379..50dabf4a5 100644 --- a/vp8/encoder/tokenize.c +++ b/vp8/encoder/tokenize.c @@ -131,9 +131,6 @@ static void tokenize2nd_order_b t->Token = x; t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt]; - - t->section = frametype * BLOCK_TYPES * 2 + 2 * type + (c == 0); - t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0)); ++cpi->coef_counts [type] [band] [pt] [x]; @@ -184,8 +181,6 @@ static void tokenize1st_order_b t->Token = x; t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt]; - - t->section = frametype * BLOCK_TYPES * 2 + 2 * type + (c == 0); t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0)); ++cpi->coef_counts [type] [band] [pt] [x]; @@ -434,7 +429,6 @@ static __inline void stuff2nd_order_b t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt]; - t->section = 11; t->skip_eob_node = 0; ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN]; ++t; @@ -465,7 +459,6 @@ static __inline void stuff1st_order_b t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [0] [1] [pt]; - t->section = 8; t->skip_eob_node = 0; ++cpi->coef_counts [0] [1] [pt] [DCT_EOB_TOKEN]; ++t; @@ -495,7 +488,6 @@ void stuff1st_order_buv t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt]; - t->section = 13; t->skip_eob_node = 0; ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN]; ++t; diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h index 01e8ec6d7..cb5b15405 100644 --- a/vp8/encoder/tokenize.h +++ b/vp8/encoder/tokenize.h @@ -25,11 +25,10 @@ typedef struct typedef struct { - int Token; - int Extra; const vp8_prob *context_tree; - int skip_eob_node; - int section; + char skip_eob_node; + char Token; + short Extra; } TOKENEXTRA; int rd_cost_mby(MACROBLOCKD *); diff --git a/vp8/encoder/x86/preproc_mmx.c b/vp8/encoder/x86/preproc_mmx.c deleted file mode 100644 index a182c8856..000000000 --- a/vp8/encoder/x86/preproc_mmx.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#include "memory.h" -#include "preproc.h" -#include "pragmas.h" - -/**************************************************************************** -* Macros -****************************************************************************/ -#define FRAMECOUNT 7 -#define ROUNDUP32(X) ( ( ( (unsigned long) X ) + 31 )&( 0xFFFFFFE0 ) ) - -/**************************************************************************** -* Imports -****************************************************************************/ -extern void vpx_get_processor_flags(int *mmx_enabled, int *xmm_enabled, int *wmt_enabled); - -/**************************************************************************** -* Exported Global Variables -****************************************************************************/ -void (*temp_filter)(pre_proc_instance *ppi, unsigned char *s, unsigned char *d, int bytes, int strength); - -/**************************************************************************** - * - * ROUTINE : temp_filter_wmt - * - * INPUTS : pre_proc_instance *ppi : Pointer to pre-processor instance. - * unsigned char *s : Pointer to source frame. - * unsigned char *d : Pointer to destination frame. - * int bytes : Number of bytes to filter. - * int strength : Strength of filter to apply. - * - * OUTPUTS : None. - * - * RETURNS : void - * - * FUNCTION : Performs a closesness adjusted temporarl blur - * - * SPECIAL NOTES : Destination frame can be same as source frame. - * - ****************************************************************************/ -void temp_filter_wmt -( - pre_proc_instance *ppi, - unsigned char *s, - unsigned char *d, - int bytes, - int strength -) -{ - int byte = 0; - unsigned char *frameptr = ppi->frame_buffer; - - __declspec(align(16)) unsigned short threes[] = { 3, 3, 3, 3, 3, 3, 3, 3}; - __declspec(align(16)) unsigned short sixteens[] = {16, 16, 16, 16, 16, 16, 16, 16}; - - if (ppi->frame == 0) - { - do - { - int i; - int frame = 0; - - do - { - for (i = 0; i < 8; i++) - { - *frameptr = s[byte+i]; - ++frameptr; - } - - ++frame; - } - while (frame < FRAMECOUNT); - - for (i = 0; i < 8; i++) - d[byte+i] = s[byte+i]; - - byte += 8; - - } - while (byte < bytes); - } - else - { - int i; - int offset2 = (ppi->frame % FRAMECOUNT); - - do - { - __declspec(align(16)) unsigned short counts[8]; - __declspec(align(16)) unsigned short sums[8]; - __asm - { - mov eax, offset2 - mov edi, s // source pixels - pxor xmm1, xmm1 // accumulator - - pxor xmm7, xmm7 - - mov esi, frameptr // accumulator - pxor xmm2, xmm2 // count - - movq xmm3, QWORD PTR [edi] - - movq QWORD PTR [esi+8*eax], xmm3 - - punpcklbw xmm3, xmm2 // xmm3 source pixels - mov ecx, FRAMECOUNT - - next_frame: - movq xmm4, QWORD PTR [esi] // get frame buffer values - punpcklbw xmm4, xmm7 // xmm4 frame buffer pixels - movdqa xmm6, xmm4 // save the pixel values - psubsw xmm4, xmm3 // subtracted pixel values - pmullw xmm4, xmm4 // square xmm4 - movd xmm5, strength - psrlw xmm4, xmm5 // should be strength - pmullw xmm4, threes // 3 * modifier - movdqa xmm5, sixteens // 16s - psubusw xmm5, xmm4 // 16 - modifiers - movdqa xmm4, xmm5 // save the modifiers - pmullw xmm4, xmm6 // multiplier values - paddusw xmm1, xmm4 // accumulator - paddusw xmm2, xmm5 // count - add esi, 8 // next frame - dec ecx // next set of eight pixels - jnz next_frame - - movdqa counts, xmm2 - psrlw xmm2, 1 // divide count by 2 for rounding - paddusw xmm1, xmm2 // rounding added in - - mov frameptr, esi - - movdqa sums, xmm1 - } - - for (i = 0; i < 8; i++) - { - int blurvalue = sums[i] * ppi->fixed_divide[counts[i]]; - blurvalue >>= 16; - d[i] = blurvalue; - } - - s += 8; - d += 8; - byte += 8; - } - while (byte < bytes); - } - - ++ppi->frame; - __asm emms -} - -/**************************************************************************** - * - * ROUTINE : temp_filter_mmx - * - * INPUTS : pre_proc_instance *ppi : Pointer to pre-processor instance. - * unsigned char *s : Pointer to source frame. - * unsigned char *d : Pointer to destination frame. - * int bytes : Number of bytes to filter. - * int strength : Strength of filter to apply. - * - * OUTPUTS : None. - * - * RETURNS : void - * - * FUNCTION : Performs a closesness adjusted temporarl blur - * - * SPECIAL NOTES : Destination frame can be same as source frame. - * - ****************************************************************************/ -void temp_filter_mmx -( - pre_proc_instance *ppi, - unsigned char *s, - unsigned char *d, - int bytes, - int strength -) -{ - int byte = 0; - unsigned char *frameptr = ppi->frame_buffer; - - __declspec(align(16)) unsigned short threes[] = { 3, 3, 3, 3}; - __declspec(align(16)) unsigned short sixteens[] = {16, 16, 16, 16}; - - if (ppi->frame == 0) - { - do - { - int i; - int frame = 0; - - do - { - for (i = 0; i < 4; i++) - { - *frameptr = s[byte+i]; - ++frameptr; - } - - ++frame; - } - while (frame < FRAMECOUNT); - - for (i = 0; i < 4; i++) - d[byte+i] = s[byte+i]; - - byte += 4; - - } - while (byte < bytes); - } - else - { - int i; - int offset2 = (ppi->frame % FRAMECOUNT); - - do - { - __declspec(align(16)) unsigned short counts[8]; - __declspec(align(16)) unsigned short sums[8]; - __asm - { - - mov eax, offset2 - mov edi, s // source pixels - pxor mm1, mm1 // accumulator - pxor mm7, mm7 - - mov esi, frameptr // accumulator - pxor mm2, mm2 // count - - movd mm3, DWORD PTR [edi] - movd DWORD PTR [esi+4*eax], mm3 - - punpcklbw mm3, mm2 // mm3 source pixels - mov ecx, FRAMECOUNT - - next_frame: - movd mm4, DWORD PTR [esi] // get frame buffer values - punpcklbw mm4, mm7 // mm4 frame buffer pixels - movq mm6, mm4 // save the pixel values - psubsw mm4, mm3 // subtracted pixel values - pmullw mm4, mm4 // square mm4 - movd mm5, strength - psrlw mm4, mm5 // should be strength - pmullw mm4, threes // 3 * modifier - movq mm5, sixteens // 16s - psubusw mm5, mm4 // 16 - modifiers - movq mm4, mm5 // save the modifiers - pmullw mm4, mm6 // multiplier values - paddusw mm1, mm4 // accumulator - paddusw mm2, mm5 // count - add esi, 4 // next frame - dec ecx // next set of eight pixels - jnz next_frame - - movq counts, mm2 - psrlw mm2, 1 // divide count by 2 for rounding - paddusw mm1, mm2 // rounding added in - - mov frameptr, esi - - movq sums, mm1 - - } - - for (i = 0; i < 4; i++) - { - int blurvalue = sums[i] * ppi->fixed_divide[counts[i]]; - blurvalue >>= 16; - d[i] = blurvalue; - } - - s += 4; - d += 4; - byte += 4; - } - while (byte < bytes); - } - - ++ppi->frame; - __asm emms -} |