video_motion.c
来自「基于linux的DVD播放器程序」· C语言 代码 · 共 519 行 · 第 1/2 页
C
519 行
((mb.vector[1][0][0]/2) >> 1) + ((mb.vector[1][0][1]/2) >> 1) * pred_stride/2; //pred_v += ((mb.vector[1][0][0]/2) >> 1) + //((mb.vector[1][0][1]/2) >> 1) * pred_stride/2; half_flags_y = ((mb.vector[1][0][0] << 1) | (mb.vector[1][0][1] & 1)) & 3; half_flags_uv = (((mb.vector[1][0][0]/2) << 1) | ((mb.vector[1][0][1]/2) & 1)) & 3; /* Field select */ // motion_vertical_field_select is always coded if we have m.v.c. == 2 if(mb.motion_vertical_field_select[1][0]) { pred_y += padded_width; pred_u += padded_width/2; //pred_v += padded_width/2; } /* Prediction destination (field) */ if(mb.prediction_type == PRED_TYPE_16x8_MC) { // Is this right for 16x8 MC... dst_y += 8 * 2 * padded_width; dst_u += 8 * 2 * padded_width/2; //dst_v += 8 * 2 * padded_width/2; } else { dst_y += padded_width; dst_u += padded_width/2; //dst_v += padded_width/2; } // if we have m.v.c. == 2 then either field_pred in frame or a field_pic stride = padded_width*2; dd = fwd_ref_image->v - fwd_ref_image->u; motion[0][1][half_flags_y](dst_y, pred_y, stride, stride); motion[0][3][half_flags_uv](dst_u, pred_u, stride/2, stride/2); motion[0][3][half_flags_uv](dst_u+dd, pred_u+dd, stride/2, stride/2); } } if(mb.modes.macroblock_type & MACROBLOCK_MOTION_BACKWARD) { uint8_t *dst_y, *dst_u;//, *dst_v; uint8_t *block_pred_y, *block_pred_u;//, *pred_v; DPRINTF(5, "backward_motion_comp\n"); DPRINTF(5, "x: %d, y: %d\n", seq.mb_column, seq.mb_row); /* Image/Field select */ block_pred_y = bwd_ref_image->y; block_pred_u = bwd_ref_image->u; //pred_v = bwd_ref_image->v; dst_y = dst_image->y; dst_u = dst_image->u; //dst_v = dst_ref_image->v; /* Motion vector Origo (block->index) */ /* Prediction destination (block->index) */ if(pic.coding_ext.picture_structure == PIC_STRUCT_FRAME_PICTURE) { unsigned int x = seq.mb_column; unsigned int y = seq.mb_row; block_pred_y += x * 16 + y * 16 * padded_width; block_pred_u += x * 8 + y * 8 * padded_width/2; //pred_v += x * 8 + y * 8 * padded_width/2; dst_y += x * 16 + y * 16 * padded_width; dst_u += x * 8 + y * 8 * padded_width/2; //dst_v += x * 8 + y * 8 * padded_width/2; } else { unsigned int x = seq.mb_column; unsigned int y = seq.mb_row; block_pred_y += x * 16 + y * 16 * padded_width*2; block_pred_u += x * 8 + y * 8 * padded_width; //pred_v += x * 8 + y * 8 * padded_width; dst_y += x * 16 + y * 16 * padded_width*2; dst_u += x * 8 + y * 8 * padded_width; //dst_v += x * 8 + y * 8 * padded_width; /* Prediction destination (field) */ if(pic.coding_ext.picture_structure == PIC_STRUCT_BOTTOM_FIELD) { dst_y += padded_width; dst_u += padded_width/2; //dst_v += padded_width/2; } } { uint8_t *pred_y, *pred_u;//, *pred_v; int half_flags_y; int half_flags_uv; int pred_stride, stride; int half_height; int d; /* Motion vector offset */ if(mb.mv_format == MV_FORMAT_FIELD) pred_stride = padded_width * 2; else pred_stride = padded_width; pred_y = block_pred_y + (mb.vector[0][1][0] >> 1) + (mb.vector[0][1][1] >> 1) * pred_stride; pred_u = block_pred_u + ((mb.vector[0][1][0]/2) >> 1) + ((mb.vector[0][1][1]/2) >> 1) * pred_stride/2; //pred_v += ((mb.vector[0][1][0]/2) >> 1) + //((mb.vector[0][1][1]/2) >> 1) * pred_stride/2; half_flags_y = ((mb.vector[0][1][0] << 1) | (mb.vector[0][1][1] & 1)) & 3; half_flags_uv = (((mb.vector[0][1][0]/2) << 1) | ((mb.vector[0][1][1]/2) & 1)) & 3; /* Field select */ // This is wrong for Dual_Prime... if(mb.mv_format == MV_FORMAT_FIELD) { if(mb.motion_vertical_field_select[0][1]) { pred_y += padded_width; pred_u += padded_width/2; //pred_v += padded_width/2; } } if(mb.prediction_type == PRED_TYPE_FIELD_BASED) stride = padded_width * 2; else stride = padded_width; d = bwd_ref_image->v - bwd_ref_image->u; half_height = (mb.motion_vector_count == 2) ? 1 :0; // ?? /* fprintf(stderr, "motion[%d][%d][%d](%d, %d, %d, %d);", !!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD), half_height, half_flags_y, dst_y, pred_y, stride, stride); */ motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [half_height][half_flags_y](dst_y, pred_y, stride, stride); motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [half_height+2][half_flags_uv](dst_u, pred_u, stride/2, stride/2); motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [half_height+2][half_flags_uv](dst_u+d, pred_u+d, stride/2, stride/2); } // Only field_pred in frame_pictures have m.v.c. == 2 except for // field_pictures with 16x8 MC if(mb.motion_vector_count == 2) { uint8_t *pred_y, *pred_u;//, *pred_v; int pred_stride, stride; int half_flags_y, half_flags_uv; int dd; /* Motion vector offset */ pred_stride = padded_width * 2; pred_y = block_pred_y + (mb.vector[1][1][0] >> 1) + (mb.vector[1][1][1] >> 1) * pred_stride; pred_u = block_pred_u + ((mb.vector[1][1][0]/2) >> 1) + ((mb.vector[1][1][1]/2) >> 1) * pred_stride/2; //pred_v += ((mb.vector[1][1][0]/2) >> 1) + //((mb.vector[1][1][1]/2) >> 1) * pred_stride/2; half_flags_y = ((mb.vector[1][1][0] << 1) | (mb.vector[1][1][1] & 1)) & 3; half_flags_uv = (((mb.vector[1][1][0]/2) << 1) | ((mb.vector[1][1][1]/2) & 1)) & 3; /* Field select */ // motion_vertical_field_select is always coded if we have m.v.c. == 2 if(mb.motion_vertical_field_select[1][1]) { pred_y += padded_width; pred_u += padded_width/2; //pred_v += padded_width/2; } /* Prediction destination (field) */ if(mb.prediction_type == PRED_TYPE_16x8_MC) { // Is this right for 16x8 MC... dst_y += 8 * 2 * padded_width; dst_u += 8 * 2 * padded_width/2; //dst_v += 8 * 2 * padded_width/2; } else { dst_y += padded_width; dst_u += padded_width/2; //dst_v += padded_width/2; } // if we have m.v.c. == 2 then either field_pred in frame or a field_pic stride = padded_width*2; dd = bwd_ref_image->v - bwd_ref_image->u; motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [1][half_flags_y](dst_y, pred_y, stride, stride); motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [3][half_flags_uv](dst_u, pred_u, stride/2, stride/2); motion[!!(mb.modes.macroblock_type & MACROBLOCK_MOTION_FORWARD)] [3][half_flags_uv](dst_u+dd, pred_u+dd, stride/2, stride/2); } }}void motion_comp_add_coeff(unsigned int i){ int padded_width,x,y; int stride; int d; uint8_t *dst; padded_width = seq.mb_width * 16; //seq.horizontal_size; x = seq.mb_column; y = seq.mb_row; if (pic.coding_ext.picture_structure == PIC_STRUCT_FRAME_PICTURE) { if (mb.modes.dct_type) { d = 1; stride = padded_width * 2; } else { d = 8; stride = padded_width; } if(i < 4) { dst = &dst_image->y[x * 16 + y * 16 * padded_width]; dst = (i & 1) ? dst + 8 : dst; dst = (i >= 2) ? dst + padded_width * d : dst; } else { stride = padded_width / 2; // OBS if( i == 4 ) dst = &dst_image->u[x * 8 + y * 8 * stride]; else // i == 5 dst = &dst_image->v[x * 8 + y * 8 * stride]; } } else { if(i < 4) { stride = padded_width * 2; dst = &dst_image->y[x * 16 + y * 16 * stride]; dst = (i & 1) ? dst + 8 : dst; dst = (i >= 2) ? dst + stride * 8 : dst; } else { stride = padded_width; // OBS if(i == 4) dst = &dst_image->u[x * 8 + y * 8 * stride]; else // i == 5 dst = &dst_image->v[x * 8 + y * 8 * stride]; } if (pic.coding_ext.picture_structure == PIC_STRUCT_BOTTOM_FIELD) dst += stride/2; } //mlib_VideoIDCT8x8_S16_S16((int16_t *)mb.QFS, (int16_t *)mb.QFS); //mlib_VideoAddBlock_U8_S16(dst, mb.QFS, stride); mlib_VideoIDCTAdd_U8_S16(dst, mb.QFS, stride);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?