📄 fame_decoder_mpeg.c
字号:
&decoder_mpeg->mismatch_accumulator[0][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->y + offset0, decoder_mpeg->tmpblock, pitch); dequantize(blocks[1], decoder_mpeg->tmpblock, decoder_mpeg->yidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[1][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->y + offset1, decoder_mpeg->tmpblock, pitch); dequantize(blocks[2], decoder_mpeg->tmpblock, decoder_mpeg->yidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[2][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->y + offset2, decoder_mpeg->tmpblock, pitch); dequantize(blocks[3], decoder_mpeg->tmpblock, decoder_mpeg->yidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[3][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->y + offset3, decoder_mpeg->tmpblock, pitch); /* U */ dequantize(blocks[4], decoder_mpeg->tmpblock, decoder_mpeg->cidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[4][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->u + offset4, decoder_mpeg->tmpblock, pitch >> 1); /* V */ dequantize(blocks[5], decoder_mpeg->tmpblock, decoder_mpeg->cidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[5][y*(pitch>>3)+x]); idct_(decoder_mpeg->tmpblock); reconstruct_(decoder_mpeg->new_ref[0]->v + offset5, decoder_mpeg->tmpblock, pitch >> 1); /* fill the block if needed */ if(bab_type >= bab_border_16x16) mpeg_pad_mb(decoder, x, y);}/* mpeg_reconstruct_inter_mb *//* *//* Description: *//* Reconstruct an inter macroblock for further motion estimation. *//* *//* Arguments: *//* fame_decoder_t *decoder: the decoder *//* bitbuffer_t *bb: a bit buffer to write the resulting encoded data to. *//* short x: the x location of the macroblock in macroblock units *//* short y: the y location of the macroblock in macroblock units *//* short *blocks[6]: the DCT coded blocks *//* fame_motion_vector_t *forward: forward motion vectors *//* fame_motion_vector_t *backward: backward motion vectors *//* unsigned char q: the quantizer scale for this block *//* fame_bab_t bab_type: binary alpha block type *//* *//* Return value: *//* None. */static void mpeg_reconstruct_inter_mb(fame_decoder_t *decoder, short x, short y, short *blocks[6], fame_motion_vector_t *forward, fame_motion_vector_t *backward, fame_motion_coding_t motion_coding, unsigned char q, fame_bab_t bab_type){ fame_decoder_mpeg_t *decoder_mpeg = FAME_DECODER_MPEG(decoder); unsigned long offset[6]; signed long motion[6]; int coded[6]; signed long residual[6]; int i, j, pitch; void (* dequantize)(short *block, dct_t *cache, dct_t *dqmatrix, dct_t *psmatrix, dct_t *mismatch); pitch = decoder_mpeg->new_ref[0]->p; /* Make offsets to blocks */ offset[0] = (y << 4) * pitch + (x << 4); /* Y(0,0) */ offset[1] = offset[0] + 8; /* Y(0,1) */ offset[2] = offset[0] + (pitch << 3); /* Y(1,0) */ offset[3] = offset[2] + 8; /* Y(1,1) */ offset[4] = (y << 3) * (pitch >> 1) + (x << 3); /* Cb */ offset[5] = (y << 3) * (pitch >> 1) + (x << 3); /* Cr */ /* Compute motion offsets (motion is half-pixel coded) */ for(i = 0; i < 4; i++) { /* full-pel motion */ motion[i] = (forward[i].dy >> 1) * pitch + (forward[i].dx >> 1); /* half-pel motion */ residual[i] = ((forward[i].dy & 1) << 1) | (forward[i].dx & 1); } for(i = 4; i < 6; i++) { /* full-pel motion */ motion[i] = (forward[i].dy >> 1) * (pitch >> 1) + (forward[i].dx >> 1); /* half-pel motion */ residual[i] = ((forward[i].dy & 1) << 1) | (forward[i].dx & 1); } /* check for not coded blocks */ for(j = 0; j < 6; j++) { coded[j] = 0; if(blocks[j] != NULL) for(i = 0; i < 64; i++) { coded[j] |= blocks[j][i]; } } if(decoder_mpeg->mismatch == fame_mismatch_local) dequantize = dequantize_inter_local; else dequantize = dequantize_inter_global; /* Reconstruct blocks */ for(i = 0; i < 4; i++) { /* Y */ if(coded[i]) { dequantize(blocks[i], decoder_mpeg->tmpblock, decoder_mpeg->nidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[i][y*(pitch>>3)+x]); idct(decoder_mpeg->tmpblock); sum(decoder_mpeg->new_ref[0]->y + offset[i], decoder_mpeg->future_ref[residual[i]]->y + offset[i] + motion[i], &forward[i].error, decoder_mpeg->tmpblock, pitch); } else { move(decoder_mpeg->new_ref[0]->y + offset[i], decoder_mpeg->future_ref[residual[i]]->y + offset[i] + motion[i], pitch); forward[i].error = 0; } } /* U */ if(coded[4]) { dequantize(blocks[4], decoder_mpeg->tmpblock, decoder_mpeg->nidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[4][y*(pitch>>3)+x]); idct(decoder_mpeg->tmpblock); sum(decoder_mpeg->new_ref[0]->u + offset[4], decoder_mpeg->future_ref[residual[4]]->u + offset[4] + motion[4], &forward[4].error, decoder_mpeg->tmpblock, pitch >> 1); } else { move(decoder_mpeg->new_ref[0]->u + offset[4], decoder_mpeg->future_ref[residual[4]]->u + offset[4] + motion[4], pitch >> 1); forward[4].error = 0; } /* V */ if(coded[5]) { dequantize(blocks[5], decoder_mpeg->tmpblock, decoder_mpeg->nidqmatrixes[q], decoder_mpeg->psmatrix, &decoder_mpeg->mismatch_accumulator[5][y*(pitch>>3)+x]); idct(decoder_mpeg->tmpblock); sum(decoder_mpeg->new_ref[0]->v + offset[5], decoder_mpeg->future_ref[residual[5]]->v + offset[5] + motion[5], &forward[5].error, decoder_mpeg->tmpblock, pitch >> 1); } else { move(decoder_mpeg->new_ref[0]->v + offset[5], decoder_mpeg->future_ref[residual[5]]->v + offset[5] + motion[5], pitch >> 1); forward[5].error = 0; } /* fill the block if needed */ if(bab_type >= bab_border_16x16) mpeg_pad_mb(decoder, x, y);}/* mpeg_pad *//* *//* Description: *//* Perform extended padding for motion estimation. *//* *//* Arguments: *//* fame_decoder_t *decoder: the decoder *//* unsigned char *bab_map: binary alpha block type map *//* fame_box_t box: bounding box *//* *//* Return value: *//* None. */static void mpeg_pad(fame_decoder_t *decoder, unsigned char *bab_map, fame_box_t *box){ fame_decoder_mpeg_t *decoder_mpeg = FAME_DECODER_MPEG(decoder); int i; void (* pad)(int i, int width, int height, fame_yuv_t **frame, unsigned char *shape, /* not used */ unsigned char *bab_map, /* not used */ fame_box_t *box); if(decoder_mpeg->shape) pad = extended_pad_withmask; else pad = extended_pad_withoutmask; for(i = 0; i < 4; i++) pad(i, decoder_mpeg->width, decoder_mpeg->height, decoder_mpeg->new_ref, decoder_mpeg->shape, bab_map, box);}/* mpeg_interpolate *//* *//* Description: *//* Compute half-pel resolution frames from reference frame. *//* *//* Arguments: *//* fame_decoder_t *decoder: the decoder *//* *//* Return value: *//* None. */static void mpeg_interpolate(fame_decoder_t *decoder, int rounding){ fame_decoder_mpeg_t *decoder_mpeg = FAME_DECODER_MPEG(decoder); half_interpolate(decoder_mpeg->width, decoder_mpeg->height, decoder_mpeg->new_ref, rounding);}/* mpeg_leave *//* *//* Description: *//* End the encoding of a picture. *//* *//* Arguments: *//* fame_decoder_t *decoder: the decoder *//* *//* Return value: *//* None. */static void mpeg_leave(fame_decoder_t *decoder){ arch_leave_state();}/* mpeg_close *//* *//* Description: *//* Release the decoder. *//* *//* Arguments: *//* fame_decoder_t *decoder: the decoder *//* *//* Return value: *//* None. */static void mpeg_close(fame_decoder_t *decoder){ fame_decoder_mpeg_t *decoder_mpeg = FAME_DECODER_MPEG(decoder);#ifdef HAS_MMX /* free mismatch accumulator */ { int i; if(decoder_mpeg->mismatch == fame_mismatch_global) for(i = 0; i < 6; i++) fame_free(decoder_mpeg->mismatch_accumulator[i]); }#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -