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
584 *Rate = vp8_rdcost_mby(mb);584 *Rate = vp8_rdcost_mby(mb);
585}585}
586 586
587static void save_predictor(unsigned char *predictor, unsigned char *dst)587static void copy_predictor(unsigned char *dst, const unsigned char *predictor)
588{588{
589 int r, c;589 const unsigned int *p = (const unsigned int *)predictor;
590 for (r = 0; r < 4; r++)590 unsigned int *d = (unsigned int *)dst;
591 {591 d[0] = p[0];
592 for (c = 0; c < 4; c++)592 d[4] = p[4];
593 {593 d[8] = p[8];
594 *dst = predictor[c];594 d[12] = p[12];
595 dst++;
596 }
597
598 predictor += 16;
599 }
600}
601static 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 }
614}595}
615static int rd_pick_intra4x4block(596static int rd_pick_intra4x4block(
616 VP8_COMP *cpi,597 VP8_COMP *cpi,
@@ -633,9 +614,13 @@ static int rd_pick_intra4x4block( · 16 unmodified lines
633 614
634 ENTROPY_CONTEXT ta = *a, tempa = *a;615 ENTROPY_CONTEXT ta = *a, tempa = *a;
635 ENTROPY_CONTEXT tl = *l, templ = *l;616 ENTROPY_CONTEXT tl = *l, templ = *l;
636 617 /*
637 DECLARE_ALIGNED_ARRAY(16, unsigned char, predictor, 16);618 * The predictor buffer is a 2d buffer with a stride of 16. Create
638 DECLARE_ALIGNED_ARRAY(16, short, dqcoeff, 16);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);
639 624
640 for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++)625 for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++)
641 {626 {
@@ -667,21 +652,17 @@ static int rd_pick_intra4x4block( · 25 unmodified lines
667 *best_mode = mode;652 *best_mode = mode;
668 *a = tempa;653 *a = tempa;
669 *l = templ;654 *l = templ;
670 save_predictor(b->predictor, predictor);655 copy_predictor(best_predictor, b->predictor);
671 vpx_memcpy(dqcoeff, b->dqcoeff, 32);656 vpx_memcpy(best_dqcoeff, b->dqcoeff, 32);
672 }657 }
673 }658 }
674 659
675 b->bmi.mode = (B_PREDICTION_MODE)(*best_mode);660 b->bmi.mode = (B_PREDICTION_MODE)(*best_mode);
676 661
677 restore_predictor(b->predictor, predictor);662 IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(best_dqcoeff, b->diff, 32);
678 vpx_memcpy(b->dqcoeff, dqcoeff, 32);663 RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(best_predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
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);
682 664
683 return best_rd;665 return best_rd;
684
685}666}
686 667
687int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,668int 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
692 int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];673 int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];
693 int distortion = 0;674 int distortion = 0;
694 int tot_rate_y = 0;675 int tot_rate_y = 0;
695 int total_rd = 0;676 long long total_rd = 0;
696 ENTROPY_CONTEXT_PLANES t_above, t_left;677 ENTROPY_CONTEXT_PLANES t_above, t_left;
697 ENTROPY_CONTEXT *ta;678 ENTROPY_CONTEXT *ta;
698 ENTROPY_CONTEXT *tl;679 ENTROPY_CONTEXT *tl;
@@ -733,12 +714,12 @@ int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, · 34 unmodified lines
733 tot_rate_y += ry;714 tot_rate_y += ry;
734 mic->bmi[i].mode = xd->block[i].bmi.mode = best_mode;715 mic->bmi[i].mode = xd->block[i].bmi.mode = best_mode;
735 716
736 if(total_rd >= best_rd)717 if(total_rd >= (long long)best_rd)
737 break;718 break;
738 }719 }
739 720
740 if(total_rd >= best_rd)721 if(total_rd >= (long long)best_rd)
741 return INT_MAX;722 return INT_MAX;
742 723
743 *Rate = cost;724 *Rate = cost;
744 *rate_y += tot_rate_y;725 *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