H.264完整的C语言代码和DCT的代码

源代码在线查看: idxgen_kc.cpp

软件大小: 4747 K
上传用户: aoaoaoao
关键词: 264 DCT C语言代码 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include "idb_kernelc.hpp"   
				#include "mpeg.hpp"
				#include "idb_kernelc2.hpp"   
				
				KERNELDEF(idxGen, KERNELS_DIR "idxgen_kc.uc");
				
				// *******************
				// idxGen_kc : generate indices for loading source images
				// *******************
				
				kernel idxGen(ostream   indices,    // indices into src image
				              uc&        uc_size,    // ls16bits: image width
				                                          // ms16bits: image height
				              uc&        uc_params)  // ls16bits: num macroblocks
				                                          // ms16bits: edges: 0 - neither
				                                          //                  1 - right
				                                          //                  2 - bottom
				                                          //                  3 - bottom right
				{
				  // process parameters from uc regs
				  byte4 unpack = 0x88883120;
				  int size = commclperm(ucid(), 0, uc_size);
				  double size2 = shuffled(size, unpack);
				  int width = lo(size2);
				  int height = hi(size2);
				  int parms = commclperm(ucid(), 0, uc_params);
				  double params2 = shuffled(parms, unpack);
				  int cnt = lo(params2);
				  int type = hi(params2);
				  uc uc_cnt;
				  int dummy = commclperm(ucid(), cnt, uc_cnt, 0, uc_cnt);
				
				  // calculate x values for each cluster for last mb (others are cid(), cid8)
				  int base_loc = 0;
				  int right_side = ((type == 1) | (type == 3));
				  int right_margin = (width & 0xf);
				  right_margin = select(itocc((right_margin>0) & right_side), right_margin,16);
				  right_margin = right_margin - 1;
				  int cid8 = cid() + 8;
				  expand x(2);
				  x[0] = select(itocc(cid() 				  x[1] = select(itocc(cid8 				
				  // calculate start value of each row
				  int bottom_row = ((type == 2) | (type == 3));
				  int bottom_margin = (height & 0xf);
				  bottom_margin = select(itocc((bottom_margin>0)&bottom_row),bottom_margin,16);
				  expand y(15);
				  y[0]  = select(itocc(1 < bottom_margin), width, 0);
				  y[1]  = select(itocc(2 < bottom_margin), width, 0);
				  y[2]  = select(itocc(3 < bottom_margin), width, 0);
				  y[3]  = select(itocc(4 < bottom_margin), width, 0);
				  y[4]  = select(itocc(5 < bottom_margin), width, 0);
				  y[5]  = select(itocc(6 < bottom_margin), width, 0);
				  y[6]  = select(itocc(7 < bottom_margin), width, 0);
				  y[7]  = select(itocc(8 < bottom_margin), width, 0);
				  y[8]  = select(itocc(9 < bottom_margin), width, 0);
				  y[9]  = select(itocc(10 < bottom_margin), width, 0);
				  y[10]  = select(itocc(11 < bottom_margin), width, 0);
				  y[11]  = select(itocc(12 < bottom_margin), width, 0);
				  y[12]  = select(itocc(13 < bottom_margin), width, 0);
				  y[13]  = select(itocc(14 < bottom_margin), width, 0);
				  y[14]  = select(itocc(15 < bottom_margin), width, 0);
				
				  loop_count(uc_cnt) {
				    // is this the last (rightmost) macroblock?
				    cc last_iter = itocc(cnt == 1);
				    int first = select(last_iter, x[0], cid());
				    int second = select(last_iter, x[1], cid8);
				
				    // output values
				    int loc = base_loc;
				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				    indices 				
				    // update vars
				    cnt = cnt - 1;
				    base_loc = base_loc + 16;
				  }
				}
							

相关资源