History

Revisited rd_pick_intra4x4block

Removed unnecessary copies. No noticeable speed gains.

Scott LaVarnway committed 15 years ago

Commit 658454a1 parent 418f4211 file · +23 −42Browse files

Unified · Split

vp8/encoder/rdopt.c+23−42
@@ -584,33 +584,14 @@ static void macro_block_yrd( MACROBLOCK *mb, · 583 unmodified lines
584584 *Rate = vp8_rdcost_mby(mb);
585585 }
586586
587−static void save_predictor(unsigned char *predictor, unsigned char *dst)
587+static void copy_predictor(unsigned char *dst, const unsigned char *predictor)
588588 {
589− int r, c;
590− for (r = 0; r < 4; r++)
591− {
592− for (c = 0; c < 4; c++)
593− {
594− *dst = predictor[c];
595− dst++;
596− }
597−
598− predictor += 16;
599− }
600−}
601−static void restore_predictor(unsigned char *predictor, unsigned char *dst)
602−{
603− int r, c;
604− for (r = 0; r < 4; r++)
605− {
606− for (c = 0; c < 4; c++)
607− {
608− predictor[c] = *dst;
609− dst++;
610− }
611−
612− predictor += 16;
613− }
589+ const unsigned int *p = (const unsigned int *)predictor;
590+ unsigned int *d = (unsigned int *)dst;
591+ d[0] = p[0];
592+ d[4] = p[4];
593+ d[8] = p[8];
594+ d[12] = p[12];
614595 }
615596 static int rd_pick_intra4x4block(
616597 VP8_COMP *cpi,
@@ -633,9 +614,13 @@ static int rd_pick_intra4x4block( · 16 unmodified lines
633614
634615 ENTROPY_CONTEXT ta = *a, tempa = *a;
635616 ENTROPY_CONTEXT tl = *l, templ = *l;
636−
637− DECLARE_ALIGNED_ARRAY(16, unsigned char, predictor, 16);
638− DECLARE_ALIGNED_ARRAY(16, short, dqcoeff, 16);
617+ /*
618+ * The predictor buffer is a 2d buffer with a stride of 16. Create
619+ * a temp buffer that meets the stride requirements, but we are only
620+ * interested in the left 4x4 block
621+ * */
622+ DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16*4);
623+ DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16);
639624
640625 for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++)
641626 {
@@ -667,21 +652,17 @@ static int rd_pick_intra4x4block( · 25 unmodified lines
667652 *best_mode = mode;
668653 *a = tempa;
669654 *l = templ;
670− save_predictor(b->predictor, predictor);
671− vpx_memcpy(dqcoeff, b->dqcoeff, 32);
655+ copy_predictor(best_predictor, b->predictor);
656+ vpx_memcpy(best_dqcoeff, b->dqcoeff, 32);
672657 }
673658 }
674659
675660 b->bmi.mode = (B_PREDICTION_MODE)(*best_mode);
676661
677− restore_predictor(b->predictor, predictor);
678− vpx_memcpy(b->dqcoeff, dqcoeff, 32);
679−
680− IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(b->dqcoeff, b->diff, 32);
681− RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
662+ IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(best_dqcoeff, b->diff, 32);
663+ RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(best_predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
682664
683665 return best_rd;
684−
685666 }
686667
687668 int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
@@ -692,7 +673,7 @@ int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, · 4 unmodified lines
692673 int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];
693674 int distortion = 0;
694675 int tot_rate_y = 0;
695− int total_rd = 0;
676+ long long total_rd = 0;
696677 ENTROPY_CONTEXT_PLANES t_above, t_left;
697678 ENTROPY_CONTEXT *ta;
698679 ENTROPY_CONTEXT *tl;
@@ -733,12 +714,12 @@ int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, · 34 unmodified lines
733714 tot_rate_y += ry;
734715 mic->bmi[i].mode = xd->block[i].bmi.mode = best_mode;
735716
736− if(total_rd >= best_rd)
737− break;
717+ if(total_rd >= (long long)best_rd)
718+ break;
738719 }
739720
740− if(total_rd >= best_rd)
741− return INT_MAX;
721+ if(total_rd >= (long long)best_rd)
722+ return INT_MAX;
742723
743724 *Rate = cost;
744725 *rate_y += tot_rate_y;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t