comparison cavs.c @ 3381:62e51b7a1b36 libavcodec

get rid of veccpy(), replace with simple assignment
author mru
date Sun, 02 Jul 2006 01:39:38 +0000
parents 1f47e26323bc
children b956afdc00d9
comparison
equal deleted inserted replaced
3380:1f47e26323bc 3381:62e51b7a1b36
528 * 528 *
529 * motion vector prediction 529 * motion vector prediction
530 * 530 *
531 ****************************************************************************/ 531 ****************************************************************************/
532 532
533 static inline void veccpy(vector_t *dst, vector_t *src) {
534 *((uint64_t *)dst) = *((uint64_t *)src);
535 }
536
537 static inline void set_mvs(vector_t *mv, enum block_t size) { 533 static inline void set_mvs(vector_t *mv, enum block_t size) {
538 switch(size) { 534 switch(size) {
539 case BLK_16X16: 535 case BLK_16X16:
540 veccpy(mv+MV_STRIDE ,mv); 536 mv[MV_STRIDE ] = mv[0];
541 veccpy(mv+MV_STRIDE+1,mv); 537 mv[MV_STRIDE+1] = mv[0];
542 case BLK_16X8: 538 case BLK_16X8:
543 veccpy(mv +1,mv); 539 mv[1] = mv[0];
544 break; 540 break;
545 case BLK_8X16: 541 case BLK_8X16:
546 veccpy(mv+MV_STRIDE ,mv); 542 mv[MV_STRIDE] = mv[0];
547 break; 543 break;
548 } 544 }
549 } 545 }
550 546
551 static inline void store_mvs(AVSContext *h) { 547 static inline void store_mvs(AVSContext *h) {
552 veccpy(&h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 0], &h->mv[MV_FWD_X0]); 548 h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 0] = h->mv[MV_FWD_X0];
553 veccpy(&h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 1], &h->mv[MV_FWD_X1]); 549 h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 1] = h->mv[MV_FWD_X1];
554 veccpy(&h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 2], &h->mv[MV_FWD_X2]); 550 h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 2] = h->mv[MV_FWD_X2];
555 veccpy(&h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 3], &h->mv[MV_FWD_X3]); 551 h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 3] = h->mv[MV_FWD_X3];
556 } 552 }
557 553
558 static inline void scale_mv(AVSContext *h, int *d_x, int *d_y, vector_t *src, int distp) { 554 static inline void scale_mv(AVSContext *h, int *d_x, int *d_y, vector_t *src, int distp) {
559 int den = h->scale_den[src->ref]; 555 int den = h->scale_den[src->ref];
560 556
782 static inline void init_mb(AVSContext *h) { 778 static inline void init_mb(AVSContext *h) {
783 int i; 779 int i;
784 780
785 /* copy predictors from top line (MB B and C) into cache */ 781 /* copy predictors from top line (MB B and C) into cache */
786 for(i=0;i<3;i++) { 782 for(i=0;i<3;i++) {
787 veccpy(&h->mv[MV_FWD_B2+i],&h->top_mv[0][h->mbx*2+i]); 783 h->mv[MV_FWD_B2+i] = h->top_mv[0][h->mbx*2+i];
788 veccpy(&h->mv[MV_BWD_B2+i],&h->top_mv[1][h->mbx*2+i]); 784 h->mv[MV_BWD_B2+i] = h->top_mv[1][h->mbx*2+i];
789 } 785 }
790 h->pred_mode_Y[1] = h->top_pred_Y[h->mbx*2+0]; 786 h->pred_mode_Y[1] = h->top_pred_Y[h->mbx*2+0];
791 h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1]; 787 h->pred_mode_Y[2] = h->top_pred_Y[h->mbx*2+1];
792 /* clear top predictors if MB B is not available */ 788 /* clear top predictors if MB B is not available */
793 if(!(h->flags & B_AVAIL)) { 789 if(!(h->flags & B_AVAIL)) {
794 veccpy(&h->mv[MV_FWD_B2],(vector_t *)&un_mv); 790 h->mv[MV_FWD_B2] = un_mv;
795 veccpy(&h->mv[MV_FWD_B3],(vector_t *)&un_mv); 791 h->mv[MV_FWD_B3] = un_mv;
796 veccpy(&h->mv[MV_BWD_B2],(vector_t *)&un_mv); 792 h->mv[MV_BWD_B2] = un_mv;
797 veccpy(&h->mv[MV_BWD_B3],(vector_t *)&un_mv); 793 h->mv[MV_BWD_B3] = un_mv;
798 h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL; 794 h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL;
799 h->flags &= ~(C_AVAIL|D_AVAIL); 795 h->flags &= ~(C_AVAIL|D_AVAIL);
800 } else if(h->mbx) { 796 } else if(h->mbx) {
801 h->flags |= D_AVAIL; 797 h->flags |= D_AVAIL;
802 } 798 }
803 if(h->mbx == h->mb_width-1) //MB C not available 799 if(h->mbx == h->mb_width-1) //MB C not available
804 h->flags &= ~C_AVAIL; 800 h->flags &= ~C_AVAIL;
805 /* clear top-right predictors if MB C is not available */ 801 /* clear top-right predictors if MB C is not available */
806 if(!(h->flags & C_AVAIL)) { 802 if(!(h->flags & C_AVAIL)) {
807 veccpy(&h->mv[MV_FWD_C2],(vector_t *)&un_mv); 803 h->mv[MV_FWD_C2] = un_mv;
808 veccpy(&h->mv[MV_BWD_C2],(vector_t *)&un_mv); 804 h->mv[MV_BWD_C2] = un_mv;
809 } 805 }
810 /* clear top-left predictors if MB D is not available */ 806 /* clear top-left predictors if MB D is not available */
811 if(!(h->flags & D_AVAIL)) { 807 if(!(h->flags & D_AVAIL)) {
812 veccpy(&h->mv[MV_FWD_D3],(vector_t *)&un_mv); 808 h->mv[MV_FWD_D3] = un_mv;
813 veccpy(&h->mv[MV_BWD_D3],(vector_t *)&un_mv); 809 h->mv[MV_BWD_D3] = un_mv;
814 } 810 }
815 /* set pointer for co-located macroblock type */ 811 /* set pointer for co-located macroblock type */
816 h->col_type = &h->col_type_base[h->mby*h->mb_width + h->mbx]; 812 h->col_type = &h->col_type_base[h->mby*h->mb_width + h->mbx];
817 } 813 }
818 814
825 h->cy += 16; 821 h->cy += 16;
826 h->cu += 8; 822 h->cu += 8;
827 h->cv += 8; 823 h->cv += 8;
828 /* copy mvs as predictors to the left */ 824 /* copy mvs as predictors to the left */
829 for(i=0;i<=20;i+=4) 825 for(i=0;i<=20;i+=4)
830 veccpy(&h->mv[i],&h->mv[i+2]); 826 h->mv[i] = h->mv[i+2];
831 /* copy bottom mvs from cache to top line */ 827 /* copy bottom mvs from cache to top line */
832 veccpy(&h->top_mv[0][h->mbx*2+0],&h->mv[MV_FWD_X2]); 828 h->top_mv[0][h->mbx*2+0] = h->mv[MV_FWD_X2];
833 veccpy(&h->top_mv[0][h->mbx*2+1],&h->mv[MV_FWD_X3]); 829 h->top_mv[0][h->mbx*2+1] = h->mv[MV_FWD_X3];
834 veccpy(&h->top_mv[1][h->mbx*2+0],&h->mv[MV_BWD_X2]); 830 h->top_mv[1][h->mbx*2+0] = h->mv[MV_BWD_X2];
835 veccpy(&h->top_mv[1][h->mbx*2+1],&h->mv[MV_BWD_X3]); 831 h->top_mv[1][h->mbx*2+1] = h->mv[MV_BWD_X3];
836 /* next MB address */ 832 /* next MB address */
837 h->mbx++; 833 h->mbx++;
838 if(h->mbx == h->mb_width) { //new mb line 834 if(h->mbx == h->mb_width) { //new mb line
839 h->flags = B_AVAIL|C_AVAIL; 835 h->flags = B_AVAIL|C_AVAIL;
840 /* clear left pred_modes */ 836 /* clear left pred_modes */
841 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL; 837 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
842 /* clear left mv predictors */ 838 /* clear left mv predictors */
843 for(i=0;i<=20;i+=4) 839 for(i=0;i<=20;i+=4)
844 veccpy(&h->mv[i],(vector_t *)&un_mv); 840 h->mv[i] = un_mv;
845 h->mbx = 0; 841 h->mbx = 0;
846 h->mby++; 842 h->mby++;
847 /* re-calculate sample pointers */ 843 /* re-calculate sample pointers */
848 h->cy = h->picture.data[0] + h->mby*16*h->l_stride; 844 h->cy = h->picture.data[0] + h->mby*16*h->l_stride;
849 h->cu = h->picture.data[1] + h->mby*8*h->c_stride; 845 h->cu = h->picture.data[1] + h->mby*8*h->c_stride;
933 929
934 decode_residual_chroma(h); 930 decode_residual_chroma(h);
935 filter_mb(h,I_8X8); 931 filter_mb(h,I_8X8);
936 932
937 /* mark motion vectors as intra */ 933 /* mark motion vectors as intra */
938 veccpy( &h->mv[MV_FWD_X0], (vector_t *)&intra_mv); 934 h->mv[MV_FWD_X0] = intra_mv;
939 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); 935 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
940 veccpy( &h->mv[MV_BWD_X0], (vector_t *)&intra_mv); 936 h->mv[MV_BWD_X0] = intra_mv;
941 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); 937 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
942 if(h->pic_type != FF_B_TYPE) 938 if(h->pic_type != FF_B_TYPE)
943 *h->col_type = I_8X8; 939 *h->col_type = I_8X8;
944 } 940 }
945 941
1013 int block; 1009 int block;
1014 enum sub_mb_t sub_type[4]; 1010 enum sub_mb_t sub_type[4];
1015 int flags; 1011 int flags;
1016 1012
1017 /* reset all MVs */ 1013 /* reset all MVs */
1018 veccpy( &h->mv[MV_FWD_X0], (vector_t *)&dir_mv); 1014 h->mv[MV_FWD_X0] = dir_mv;
1019 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); 1015 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
1020 veccpy( &h->mv[MV_BWD_X0], (vector_t *)&dir_mv); 1016 h->mv[MV_BWD_X0] = dir_mv;
1021 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); 1017 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
1022 switch(mb_type) { 1018 switch(mb_type) {
1023 case B_SKIP: 1019 case B_SKIP:
1024 mb_skip_b(h); 1020 mb_skip_b(h);
1025 inter_pred(h); 1021 inter_pred(h);
1161 static void init_pic(AVSContext *h) { 1157 static void init_pic(AVSContext *h) {
1162 int i; 1158 int i;
1163 1159
1164 /* clear some predictors */ 1160 /* clear some predictors */
1165 for(i=0;i<=20;i+=4) 1161 for(i=0;i<=20;i+=4)
1166 veccpy(&h->mv[i],(vector_t *)&un_mv); 1162 h->mv[i] = un_mv;
1167 veccpy(&h->mv[MV_BWD_X0], (vector_t *)&dir_mv); 1163 h->mv[MV_BWD_X0] = dir_mv;
1168 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); 1164 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
1169 veccpy(&h->mv[MV_FWD_X0], (vector_t *)&dir_mv); 1165 h->mv[MV_FWD_X0] = dir_mv;
1170 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); 1166 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
1171 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL; 1167 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
1172 h->cy = h->picture.data[0]; 1168 h->cy = h->picture.data[0];
1173 h->cu = h->picture.data[1]; 1169 h->cu = h->picture.data[1];
1174 h->cv = h->picture.data[2]; 1170 h->cv = h->picture.data[2];
1514 h->intra_pred_c[ INTRA_C_VERT] = intra_pred_vert; 1510 h->intra_pred_c[ INTRA_C_VERT] = intra_pred_vert;
1515 h->intra_pred_c[ INTRA_C_PLANE] = intra_pred_plane; 1511 h->intra_pred_c[ INTRA_C_PLANE] = intra_pred_plane;
1516 h->intra_pred_c[ INTRA_C_LP_LEFT] = intra_pred_lp_left; 1512 h->intra_pred_c[ INTRA_C_LP_LEFT] = intra_pred_lp_left;
1517 h->intra_pred_c[ INTRA_C_LP_TOP] = intra_pred_lp_top; 1513 h->intra_pred_c[ INTRA_C_LP_TOP] = intra_pred_lp_top;
1518 h->intra_pred_c[ INTRA_C_DC_128] = intra_pred_dc_128; 1514 h->intra_pred_c[ INTRA_C_DC_128] = intra_pred_dc_128;
1519 veccpy(&h->mv[ 7], (vector_t *)&un_mv); 1515 h->mv[ 7] = un_mv;
1520 veccpy(&h->mv[19], (vector_t *)&un_mv); 1516 h->mv[19] = un_mv;
1521 return 0; 1517 return 0;
1522 } 1518 }
1523 1519
1524 static int cavs_decode_end(AVCodecContext * avctx) { 1520 static int cavs_decode_end(AVCodecContext * avctx) {
1525 AVSContext *h = (AVSContext *)avctx->priv_data; 1521 AVSContext *h = (AVSContext *)avctx->priv_data;