From 4f360fcb8093fd218146d7aa237307936a57cbad Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 18 Sep 2013 12:26:51 +0300 Subject: [PATCH] Split MAX_SEARCH_DEPTH to inter and intra versions. --- src/debug.c | 2 +- src/global.h | 8 ++++++-- src/search.c | 53 ++++++++++++++++++++++++++-------------------------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/debug.c b/src/debug.c index d1b69e8a..a06a8b37 100644 --- a/src/debug.c +++ b/src/debug.c @@ -46,7 +46,7 @@ unsigned render_cu_file(encoder_control *encoder, unsigned depth, uint16_t xCtb, cu->inter.cost, cu->inter.mv[0], cu->inter.mv[1]); - if(depth != MAX_SEARCH_DEPTH) + if(depth != MAX_INTER_SEARCH_DEPTH) { /* Split blocks and remember to change x and y block positions */ uint8_t change = 1<<(MAX_DEPTH-1-depth); diff --git a/src/global.h b/src/global.h index c0bf7a7d..e6baf789 100644 --- a/src/global.h +++ b/src/global.h @@ -16,8 +16,12 @@ /* CONFIG VARIABLES */ #define LCU_WIDTH 64 /*!< Largest Coding Unit (IT'S 64x64, DO NOT TOUCH!) */ -#define MAX_SEARCH_DEPTH 3 /*!< Max search depth -> min block size (3 == 8x8) */ -#define MIN_SEARCH_DEPTH 1 /*!< Min search depth -> max block size (0 == 64x64) */ +#define MAX_INTER_SEARCH_DEPTH 2 +#define MIN_INTER_SEARCH_DEPTH 0 + +#define MAX_INTRA_SEARCH_DEPTH 3 /*!< Max search depth -> min block size (3 == 8x8) */ +#define MIN_INTRA_SEARCH_DEPTH 1 /*!< Min search depth -> max block size (0 == 64x64) */ + #define MAX_DEPTH 3 /*!< smallest CU is LCU_WIDTH>>MAX_DEPTH */ #define MIN_SIZE 3 /*!< log2_min_coding_block_size */ diff --git a/src/search.c b/src/search.c index 4e1395b4..b0e7f9f1 100644 --- a/src/search.c +++ b/src/search.c @@ -194,37 +194,36 @@ void search_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t d } /* INTER SEARCH */ - if(encoder->in.cur_pic->slicetype != SLICE_I)// && (xCtb == 0) && yCtb == 0) - { - //if(depth >= MIN_SEARCH_DEPTH) + if(depth >= MIN_INTER_SEARCH_DEPTH + && depth <= MAX_INTER_SEARCH_DEPTH + && encoder->in.cur_pic->slicetype != SLICE_I) { + /* Motion estimation on P-frame */ + if(encoder->in.cur_pic->slicetype != SLICE_B) { - /* Motion estimation on P-frame */ - if(encoder->in.cur_pic->slicetype != SLICE_B) - { - } - - { - unsigned mv[2] = { 0, 0 }; // TODO: Take initial MV from adjacent blocks. - picture *cur_pic = encoder->in.cur_pic; - - picture *ref_pic = encoder->ref->pics[0]; - - int x = xCtb * CU_MIN_SIZE_PIXELS; - int y = yCtb * CU_MIN_SIZE_PIXELS; - uint8_t *cur_data = &cur_pic->yData[(y * cur_pic->width) + x]; - search_motion_vector(cur_pic, cur_data, ref_pic->yData, cur_CU, 8, x, y, 0, 0, depth); - } - - cur_CU->type = CU_INTER; - cur_CU->inter.mv_dir = 1; - inter_setBlockMode(encoder->in.cur_pic,xCtb,yCtb,depth,cur_CU); } + + { + unsigned mv[2] = { 0, 0 }; // TODO: Take initial MV from adjacent blocks. + picture *cur_pic = encoder->in.cur_pic; + + picture *ref_pic = encoder->ref->pics[0]; + + int x = xCtb * CU_MIN_SIZE_PIXELS; + int y = yCtb * CU_MIN_SIZE_PIXELS; + uint8_t *cur_data = &cur_pic->yData[(y * cur_pic->width) + x]; + search_motion_vector(cur_pic, cur_data, ref_pic->yData, cur_CU, 8, x, y, 0, 0, depth); + } + + cur_CU->type = CU_INTER; + cur_CU->inter.mv_dir = 1; + inter_setBlockMode(encoder->in.cur_pic,xCtb,yCtb,depth,cur_CU); } /* INTRA SEARCH */ - if(depth >= MIN_SEARCH_DEPTH && (encoder->in.cur_pic->slicetype == SLICE_I || USE_INTRA_IN_P)) - { + if (depth >= MIN_INTRA_SEARCH_DEPTH + && depth <= MAX_INTRA_SEARCH_DEPTH + && (encoder->in.cur_pic->slicetype == SLICE_I || USE_INTRA_IN_P)) { int x = 0,y = 0; uint8_t *base = &encoder->in.cur_pic->yData[xCtb*(LCU_WIDTH>>(MAX_DEPTH)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH))) *encoder->in.width]; uint32_t width = LCU_WIDTH>>depth; @@ -245,7 +244,7 @@ void search_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t d } /* Split and search to max_depth */ - if(depth != MAX_SEARCH_DEPTH) + if(depth < MAX_INTRA_SEARCH_DEPTH && depth < MAX_INTER_SEARCH_DEPTH) { /* Split blocks and remember to change x and y block positions */ uint8_t change = 1<<(MAX_DEPTH-1-depth); @@ -266,7 +265,7 @@ uint32_t search_best_mode(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint32_t lambdaCost = (4 * g_lambda_cost[encoder->QP]) << 4; //<<5; //TODO: Correct cost calculation /* Split and search to max_depth */ - if (depth != MAX_SEARCH_DEPTH) { + if (depth != MAX_INTRA_SEARCH_DEPTH) { /* Split blocks and remember to change x and y block positions */ uint8_t change = 1<<(MAX_DEPTH-1-depth); cost = search_best_mode(encoder,xCtb,yCtb,depth+1);