void processinterMbType( unsigned char mb_type, unsigned char slice_type, NALU_t * nalu, unsigned char num_ref_idx_active1, unsigned char num_ref_idx_active0, char refidx0[2][2], char refidx1[2][2], int mvd0[4][4][2], int mvd1[4][4][2], char globref0[PicWidthInMBs*2][FrameHeightInMbs*2], char globref1[PicWidthInMBs*2][FrameHeightInMbs*2], int globmvd0[PicWidthInMBs*4][FrameHeightInMbs*4][2], int globmvd1[PicWidthInMBs*4][FrameHeightInMbs*4][2], int list0[MAX_REFERENCE_PICTURES], int list1[MAX_REFERENCE_PICTURES], int Mbaddress, int skipflag, char refcol[2][2], int mvcol[4][4][2], unsigned char MbType ) { unsigned char substepx[2][2]; unsigned char substepy[2][2]; unsigned char stepx; unsigned char stepy; unsigned char listuse[2][2]; unsigned char preddir[2][2]; unsigned char subtype; unsigned char dflag; int i,j; int x,y; int subx,suby; char refidx; int mvdx; int mvdy; int tpmmv[2]; int tpmmv1[2]; int foundmv0[2]; int foundmv1[2]; char tmpref01[2]; int startblkx= (Mbaddress%PicWidthInMBs)*4; int startblky= (Mbaddress/PicWidthInMBs)*4; const unsigned char val_stepX[30]= {4,4,4,2,2,2, // this part is for P slice 2,2,4,4,4, // following is for B slice 4,2,4,2, 4,2,4,2, 4,2,4,2, 4,2,4,2, 4,2,2 }; const unsigned char val_stepY[30]= {4,4,2,4,2,2, 2,2,4,4,4, 2,4,2,4, 2,4,2,4, 2,4,2,4, 2,4,2,4, 2,4,2 }; const unsigned char val_listuse[30][4]= { //following are P slice {1,1,1,1},//skip {1,1,1,1},//0 {1,1,1,1},//1 {1,1,1,1},//2 {1,1,1,1},//3 {1,1,1,1},//4 // following are B slice {0,0,0,0},//skip {0,0,0,0},//direct {1,1,1,1},//1 {2,2,2,2},//2 {3,3,3,3},//3 {1,1,1,1},//4 {1,1,1,1},//5 {2,2,2,2},//6 {2,2,2,2},//7 {1,1,2,2},//8 {1,2,1,2},//9 {2,2,1,1},//10 {2,1,2,1},//11 {1,1,3,3},//12 {1,3,1,3},//13 {2,2,3,3},//14 {2,3,2,3},//15 {3,3,1,1},//16 {3,1,3,1},//17 {3,3,2,2},//18 {3,2,3,2},//19 {3,3,3,3},//20 {3,3,3,3},//21 {0,0,0,0},//22 }; const unsigned char val_predir[30][4]= { //following are P slice {0,0,0,0},//skip {0,0,0,0},//0 {2,2,1,1},//1 {1,3,1,3},//2 {0,0,0,0},//3 {0,0,0,0},//4 //following are B slice {0,0,0,0},//skip {0,0,0,0},//direct {0,0,0,0},//1 {0,0,0,0},//2 {0,0,0,0},//3 {2,2,1,1},//4 {1,3,1,3},//5 {2,2,1,1},//6 {1,3,1,3},//7 {2,2,1,1},//8 {1,3,1,3},//9 {2,2,1,1},//10 {1,3,1,3},//11 {2,2,1,1},//12 {1,3,1,3},//13 {2,2,1,1},//14 {1,3,1,3},//15 {2,2,1,1},//16 {1,3,1,3},//17 {2,2,1,1},//18 {1,3,1,3},//19 {2,2,1,1},//20 {1,3,1,3},//21 {0,0,0,0},//22 }; const unsigned char val_sublistuse[17]= { 1,1,1,1, 0,1,2,3,1,1,2,2,3,3,1,2,3 }; const unsigned char val_subX[17]= { 2,2,1,1,// P slice 2,2,2,2, 2,1,2,1, 2,1,1,1,1 }; const unsigned char val_subY[17]= { 2,1,2,1,// P slice 2,2,2,2, 1,2,1,2, 1,2,1,1,1 }; listuse[0][0]=val_listuse[MbType][0]; listuse[1][0]=val_listuse[MbType][1]; listuse[0][1]=val_listuse[MbType][2]; listuse[1][1]=val_listuse[MbType][3]; stepx=val_stepX[MbType]; stepy=val_stepY[MbType]; substepx[0][0]=stepx; substepy[0][0]=stepy; substepx[0][1]=stepx; substepy[0][1]=stepy; substepx[1][0]=stepx; substepy[1][0]=stepy; substepx[1][1]=stepx; substepy[1][1]=stepy; preddir[0][0]=val_predir[MbType][0]; preddir[1][0]=val_predir[MbType][1]; preddir[0][1]=val_predir[MbType][2]; preddir[1][1]=val_predir[MbType][3]; if(MbType==5 || MbType==29) { for(i=0; i<2; i++) for(j=0; j<2; j++) { subtype=u_e(nalu)+slice_type*4; substepx[j][i]=val_subX[subtype]; substepy[j][i]=val_subY[subtype]; listuse[j][i]=val_sublistuse[subtype]; } } skipflag= (MbType==6 || MbType==7)?0:skipflag; if(MbType==0 || MbType==5 ) { for(i=0; i<2; i++) for(j=0; j<2; j++) { refidx0[i][j] = 0; refidx1[i][j] = -1; globref0[startblkx/2+j][startblky/2+i]=0; globref1[startblkx/2+j][startblky/2+i]=-1; } } else { if(num_ref_idx_active0>0 ) { for(y=0; y<2; y+= (stepy/2) ) for(x=0; x<2; x+= (stepx/2) ) { if(listuse[x][y]== 0) { dflag= find_directzeroflag ( globref0, globref1, tmpref01, startblkx, startblky ); refidx0[x][y]=globref0[startblkx/2+x][startblky/2+y]=tmpref01[0]; refidx1[x][y]=globref1[startblkx/2+x][startblky/2+y]=tmpref01[1]; } else if(listuse[x][y] & 0x01) { refidx=t_e(num_ref_idx_active0,nalu); #if _N_HLS_ fprintf(trace_bit,"refIdxL0[i][j] %d %d \n" ,refidx, num_ref_idx_active0); #endif // _N_HLS_ for(i=0; i<stepy/2; i++) for(j=0; j<stepx/2; j++) { refidx0[x+j][y+i]=refidx; globref0[startblkx/2+x+j][startblky/2+y+i]=refidx; } } else { for(i=0; i<stepy/2; i++) for(j=0; j<stepx/2; j++) { refidx0[x+j][y+i]=-1; globref0[startblkx/2+x+j][startblky/2+y+i]=-1; } } } } else { for(i=0; i<2; i++) for(j=0; j<2; j++) { refidx0[j][i]=0; globref0[startblkx/2+j][startblky/2+i]=0; } } if(num_ref_idx_active1>0 ) { for(y=0; y<2; y+= (stepy/2) ) for(x=0; x<2; x+= (stepx/2) ) { if(listuse[x][y]== 0) { //donotihing } else if( (listuse[x][y] & 0x02) !=0) { refidx=t_e(num_ref_idx_active1,nalu); #if _N_HLS_ fprintf(trace_bit,"refIdxL1[i][j] %d %d\n" , refidx, num_ref_idx_active1); #endif // _N_HLS_ for(i=0; i<stepy/2; i++) for(j=0; j<stepx/2; j++) { refidx1[x+j][y+i]=refidx; globref1[startblkx/2+x+j][startblky/2+y+i]=refidx; #if _N_HLS_ fprintf(trace_bit,"refIdx1[%d][%d] %d\n" ,x+j, y+i, refidx); #endif // _N_HLS_ } } else { for(i=0; i<stepy/2; i++) for(j=0; j<stepx/2; j++) { refidx1[x+j][y+i]=-1; globref1[startblkx/2+x+j][startblky/2+y+i]=-1; } } } } else { for(i=0; i<2; i++) for(j=0; j<2; j++) { refidx1[j][i]=0; globref1[startblkx/2+j][startblky/2+i]=0; } } } unsigned char stpw; unsigned char stph; for(y=0; y<4; y+=stepy) for(x=0; x<4; x+=stepx) { if(listuse[x>>1][y>>1]==0) { findmv( globref0,globmvd0,startblkx, startblky,0,4,0,0,refidx0[x/2][y/2],foundmv0,0,0); findmv( globref1,globmvd1,startblkx, startblky,0,4,0,0,refidx1[x/2][y/2],foundmv1,0,0); for(i=0; i<2; i++) for(j=0; j<2; j++) { tpmmv[0]=foundmv0[0]; tpmmv[1]=foundmv0[1]; tpmmv1[0]=foundmv1[0]; tpmmv1[1]=foundmv1[1]; find_directmv_flag(dflag,refcol,mvcol,x+i,y+j,tpmmv1,tpmmv,refidx0[x/2][y/2],refidx1[x/2][y/2]); mvd0[x+i][y+j][0]=globmvd0[startblkx+x+i][startblky+y+j][0]=tpmmv[0]; mvd0[x+i][y+j][1]=globmvd0[startblkx+x+i][startblky+y+j][1]=tpmmv[1]; mvd1[x+i][y+j][0]=globmvd1[startblkx+x+i][startblky+y+j][0]=tpmmv1[0]; mvd1[x+i][y+j][1]=globmvd1[startblkx+x+i][startblky+y+j][1]=tpmmv1[1]; } } else if( listuse[x>>1][y>>1] & 0x01 ) { stpw=substepx[x>>1][y>>1]; stph=substepy[x>>1][y>>1]; for(suby=0; suby<stepy; suby+=stph) for(subx=0; subx<stepx; subx+=stpw) { //calculate mvbase if(skipflag!=1 ) { mvdx=s_e(nalu); mvdy=s_e(nalu); #if _N_HLS_ fprintf(trace_bit," curMB->mvd_l0[%d][%d][0] %d\n" ,startblkx+x+subx,startblky+y+suby,mvdx); #endif // _N_HLS_ #if _N_HLS_ fprintf(trace_bit," curMB->mvd_l0[%d][%d][1] %d\n" ,startblkx+x+subx,startblky+y+suby,mvdy); #endif // _N_HLS_ // calculate and write x } else { mvdx=0; mvdy=0; } findmv ( globref0, globmvd0, startblkx, startblky, XYTOK(x+subx,y+suby), stpw, x+subx, y+suby, refidx0[x/2][y/2], tpmmv, preddir[x/2][y/2], skipflag ); for(i=0; i<stpw; i++) for(j=0; j<stph; j++) { mvd0[x+subx+i][y+suby+j][0]=globmvd0[startblkx+x+subx+i][startblky+y+suby+j][0]=mvdx+tpmmv[0]; mvd0[x+subx+i][y+suby+j][1]=globmvd0[startblkx+x+subx+i][startblky+y+suby+j][1]=mvdy+tpmmv[1]; } } } }
int main(const int argc, const char* const argv[]) { if (argc > 2) { std::cerr << "ERROR[BoundedTransversals_bv]:\n" " Either zero or one parameter is required, which is of the form\n" " \"=n\" or \">=n\" for some natural number n >= 0.\n" " However, the actual number of input parameters was " << argc-1 << ".\n"; return error_parameters; } typedef unsigned int vertex_type; // currently ignored typedef int literal_type; // necessary since (currently) we are using clause-set input- and output-facilities typedef std::set<literal_type> hyperedge_type; typedef hyperedge_type::size_type size_type; bool iterated_; size_type B_; if (argc == 1) { iterated_ = true; B_ = 0; } else { const std::string par(argv[1]); if (par.empty()) { std::cerr << "ERROR[BoundedTransversals_bv]:\n" "The parameter is the empty string.\n"; return error_empty; } if (par[0] == '=') { iterated_ = false; B_ = boost::lexical_cast<size_type>(par.substr(1)); } else { if (par[0] != '>') { std::cerr << "ERROR[BoundedTransversals_bv]:\n" "Unrecognised leading symbol " << par[0] << ".\n"; return error_symbol1; } if (par.size() == 1 or par[1] != '=') { std::cerr << "ERROR[BoundedTransversals_bv]:\n" "After \">\" the symbol \"=\" is expected.\n"; return error_symbol2; } iterated_ = true; B_ = boost::lexical_cast<size_type>(par.substr(2)); } } const bool iterated(iterated_); const size_type B(B_); typedef OKlib::OrderRelations::SizeLessThan<std::less<hyperedge_type> > hyperedge_ordering_type; typedef std::set<hyperedge_type, hyperedge_ordering_type> set_system_type; typedef OKlib::InputOutput::RawDimacsCLSAdaptorSets<literal_type, set_system_type> dimacs_adaptor_type; typedef OKlib::InputOutput::StandardDIMACSInput<dimacs_adaptor_type> dimacs_input_type; dimacs_adaptor_type in; dimacs_input_type(std::cin, in); typedef OKlib::Combinatorics::Hypergraphs::Transversals::Bounded::Bounded_transversals_bv<set_system_type> transversal_enumerator_type; typedef transversal_enumerator_type::transversal_list_type transversal_list_type; transversal_enumerator_type t_e(in.clause_set, B); if (iterated and not t_e.G_orig.empty() and t_e.G_orig.begin() -> empty()) { std::cerr << "ERROR[BoundedTransversals_bv]:\n" "The iteration would not terminate due to the presence of the empty hyperedge.\n"; return error_empty_hyperedge; } const transversal_list_type transversals(iterated ? t_e.iterated() : t_e()); typedef OKlib::InputOutput::CLSAdaptorDIMACSOutput<> dimacs_adaptor2_type; typedef OKlib::InputOutput::ListTransfer<dimacs_adaptor2_type> dimacs_output_type; dimacs_adaptor2_type out(std::cout); dimacs_output_type(transversals, out, "Bounded transversals of size " + boost::lexical_cast<std::string>(t_e.bound)); }