📄 mae_fe_mcomp.c
字号:
/* <LIC_AMD_STD> * Copyright (C) 2003-2005 Advanced Micro Devices, Inc. All Rights Reserved. * * Unless otherwise designated in writing, this software and any related * documentation are the confidential proprietary information of AMD. * THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * UNLESS OTHERWISE NOTED IN WRITING, EXPRESS OR IMPLIED WARRANTY OF ANY * KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, * NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE AND IN NO * EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER. * * AMD does not assume any responsibility for any errors which may appear * in the Materials nor any responsibility to support or update the * Materials. AMD retains the right to modify the Materials at any time, * without notice, and is not obligated to provide such modified * Materials to you. AMD is not obligated to furnish, support, or make * any further information available to you. * </LIC_AMD_STD> *//* <CTL_AMD_STD>// File Id and RCS Info: // $Source: /home/cvs/travis/mae/env/mae_fe_mcomp.c,v $// $Id: mae_fe_mcomp.c,v 1.151 2004/08/04 15:45:33 eswartz Exp $ * </CTL_AMD_STD> *//* <DOC_AMD_STD> * </DOC_AMD_STD> */#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>// Include fcov.h first so crazy printf define doesn't hit#include "fcov.h"#include "mae_fe_mcomp.h"#include "mae_vpi.h"#include "types.h"#ifdef HAVE_MAE #define FILTER_DEBUG 1#endif#ifndef HAVE_MAE #include "mae_pass_thru.h" #include "filecache.h"#endif#define MAE_FE_MPEG_COVERAGE// fcov helpers...static char tmp_cov_str[256];static char fcov_str_mcprecy[20];static char fcov_str_mcprecuv[20];static char fcov_str_mbtype[20];#ifdef HAVE_MAE #define PRINT_MCOMP_BUFFERS#endifvoid print_ref_blocks(uint8 *src, int srcStride, int bn, int bwd, int x_frac, int y_frac);void print_mc_blocks(uint8 *src, int srcStride, int bn, int bwd);// global FPEL MVsint src_x_y[8],src_x_uv[4],src_y_y[8],src_y_uv[4];void MAE_oof_start(MAEContext *s, unsigned y_mbmode, unsigned uv_mbmode, int32 *luty, int *lutuv) { uint32 chroma_height = (s->bc) ? s->height : s->height/2; // Only do this on the first macroblock for players#ifndef HAVE_MAE static int oncePerFrame = -1; if ((gCM.nFrameNum == oncePerFrame) || (gCM.dmv && (gCM.change_addr > 1))) return; gCM.change_addr += 1; oncePerFrame = gCM.nFrameNum;#endif // Create OOF for fp == 0 if (s->fwd_y_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_y_top_oof_fp0, (uint8 *)s->fwd_y_top_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 0); if (s->fwd_y_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_y_bot_oof_fp0, (uint8 *)s->fwd_y_bot_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 0); if (s->bwd_y_top_ptr != 0) MAE_create_out_of_frame(gCM.fut_y_top_oof_fp0, (uint8 *)s->bwd_y_top_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 0); if (s->bwd_y_bot_ptr != 0) MAE_create_out_of_frame(gCM.fut_y_bot_oof_fp0, (uint8 *)s->bwd_y_bot_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 0); if (s->fwd_cb_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_cb_top_oof_fp0, (uint8 *)s->fwd_cb_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->fwd_cr_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_cr_top_oof_fp0, (uint8 *)s->fwd_cr_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->fwd_cb_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_cb_bot_oof_fp0, (uint8 *)s->fwd_cb_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->fwd_cr_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_cr_bot_oof_fp0, (uint8 *)s->fwd_cr_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->bwd_cb_top_ptr) MAE_create_out_of_frame(gCM.fut_cb_top_oof_fp0, (uint8 *)s->bwd_cb_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->bwd_cr_top_ptr) MAE_create_out_of_frame(gCM.fut_cr_top_oof_fp0, (uint8 *)s->bwd_cr_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->bwd_cb_bot_ptr) MAE_create_out_of_frame(gCM.fut_cb_bot_oof_fp0, (uint8 *)s->bwd_cb_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); if (s->bwd_cr_bot_ptr) MAE_create_out_of_frame(gCM.fut_cr_bot_oof_fp0, (uint8 *)s->bwd_cr_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 0); // Create OOF for fp == 1 if (s->fwd_y_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_y_top_oof_fp1, (uint8 *)s->fwd_y_top_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 1); if (s->fwd_y_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_y_bot_oof_fp1, (uint8 *)s->fwd_y_bot_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 1); if (s->bwd_y_top_ptr != 0) MAE_create_out_of_frame(gCM.fut_y_top_oof_fp1, (uint8 *)s->bwd_y_top_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 1); if (s->bwd_y_bot_ptr != 0) MAE_create_out_of_frame(gCM.fut_y_bot_oof_fp1, (uint8 *)s->bwd_y_bot_ptr, s->linesz, s->height, 16, 32, s->codstyl, luty, 1); if (s->fwd_cb_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_cb_top_oof_fp1, (uint8 *)s->fwd_cb_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->fwd_cr_top_ptr != 0) MAE_create_out_of_frame(gCM.prev_cr_top_oof_fp1, (uint8 *)s->fwd_cr_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->fwd_cb_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_cb_bot_oof_fp1, (uint8 *)s->fwd_cb_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->fwd_cr_bot_ptr != 0) MAE_create_out_of_frame(gCM.prev_cr_bot_oof_fp1, (uint8 *)s->fwd_cr_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->bwd_cb_top_ptr) MAE_create_out_of_frame(gCM.fut_cb_top_oof_fp1, (uint8 *)s->bwd_cb_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->bwd_cr_top_ptr) MAE_create_out_of_frame(gCM.fut_cr_top_oof_fp1, (uint8 *)s->bwd_cr_top_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->bwd_cb_bot_ptr) MAE_create_out_of_frame(gCM.fut_cb_bot_oof_fp1, (uint8 *)s->bwd_cb_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); if (s->bwd_cr_bot_ptr) MAE_create_out_of_frame(gCM.fut_cr_bot_oof_fp1, (uint8 *)s->bwd_cr_bot_ptr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, 1); MAE_create_out_of_frame(gCM.cur_y_oof, gCM.current_y, s->linesz, s->height, 16, 32, s->codstyl, luty, s->fp); MAE_create_out_of_frame(gCM.cur_cb_oof, gCM.current_cb, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, s->fp); MAE_create_out_of_frame(gCM.cur_cr_oof, gCM.current_cr, s->linesz/2, chroma_height, 8, 16, s->codstyl, lutuv, s->fp);}void MAE_oof_end(MAEContext *s) { uint32 chroma_height = (s->bc) ? (s->height - 48) : s->height/2; // Extract the original frame from the larger frame MAE_remove_out_of_frame(gCM.current_y, gCM.cur_y_oof, s->linesz, s->height, 16, 32); MAE_remove_out_of_frame(gCM.current_cb, gCM.cur_cb_oof, (s->linesz/2), chroma_height, 8, 16); MAE_remove_out_of_frame(gCM.current_cr, gCM.cur_cr_oof, (s->linesz/2), chroma_height, 8, 16);}#ifdef REF_WMV9void MAE_oof_print(MAEContext *s) { static int oncePerFrame = -1; uint8 *ref_oof; uint8 *ref_prev_y_top_oof = (s->fp) ? gCM.prev_y_top_oof_fp1 : gCM.prev_y_top_oof_fp0; uint8 *ref_prev_cb_top_oof = (s->fp) ? gCM.prev_cb_top_oof_fp1 : gCM.prev_cb_top_oof_fp0; uint8 *ref_prev_cr_top_oof = (s->fp) ? gCM.prev_cr_top_oof_fp1 : gCM.prev_cr_top_oof_fp0; uint8 *ref_fut_y_top_oof = (s->fp) ? gCM.fut_y_top_oof_fp1 : gCM.fut_y_top_oof_fp0; uint8 *ref_fut_cb_top_oof = (s->fp) ? gCM.fut_cb_top_oof_fp1 : gCM.fut_cb_top_oof_fp0; uint8 *ref_fut_cr_top_oof = (s->fp) ? gCM.fut_cr_top_oof_fp1 : gCM.fut_cr_top_oof_fp0; if (gCM.nFrameNum == oncePerFrame) return; oncePerFrame = gCM.nFrameNum; // In the CModel(MAE) we have 48 bytes of padding on each side, but the // WMV9 (and MPEG-4) reference codes use only 32 bytes of padding on // each side. To match up the respective file dumps, we shall print only // 32 bytes on each side for the CModel as well. To do that, we need to // point the Out Of Frame luma pointer by 16. // ********************************************************************* // Forward Reference Frames // ************************ ref_oof = ref_prev_y_top_oof + (16 * (s->linesz + 96)) + 16; DumpOOFRefFrmForMAE(ref_oof, Y1_LUMA_BLOCK, s->linesz+EXPANDY_REFVOPx2, s->height+EXPANDY_REFVOPx2, MBM_FORWARD); // U OOF Reference Frame // ********************* ref_oof = ref_prev_cb_top_oof + (8 * (s->linesz/2 + 48)) + 8; DumpOOFRefFrmForMAE(ref_oof, U_CHROMA_BLOCK, s->linesz/2 + EXPANDUV_REFVOPx2, s->height/2 + EXPANDUV_REFVOPx2, MBM_FORWARD); // V OOF Reference Frame // ********************* ref_oof = ref_prev_cr_top_oof + (8 * (s->linesz/2 + 48)) + 8; DumpOOFRefFrmForMAE(ref_oof, V_CHROMA_BLOCK, s->linesz/2 + EXPANDUV_REFVOPx2, s->height/2 + EXPANDUV_REFVOPx2, MBM_FORWARD); // Backward Reference Frames // ************************* if (gCM.nFrameType == BFRAME) { ref_oof = ref_fut_y_top_oof + (16 * (s->linesz + 96)) + 16; DumpOOFRefFrmForMAE(ref_oof, Y1_LUMA_BLOCK, s->linesz+EXPANDY_REFVOPx2, s->height+EXPANDY_REFVOPx2, MBM_BACKWARD); ref_oof = ref_fut_cb_top_oof + (8 * (s->linesz/2 + 48)) + 8; DumpOOFRefFrmForMAE(ref_oof, U_CHROMA_BLOCK, s->linesz/2 + EXPANDUV_REFVOPx2, s->height/2 + EXPANDUV_REFVOPx2, MBM_BACKWARD); ref_oof = ref_fut_cr_top_oof + (8 * (s->linesz/2 + 48)) + 8; DumpOOFRefFrmForMAE(ref_oof, V_CHROMA_BLOCK, s->linesz/2 + EXPANDUV_REFVOPx2, s->height/2 + EXPANDUV_REFVOPx2, MBM_BACKWARD); }}#elif REF_DIVXvoid MAE_oof_print(MAEContext *s) { static int oncePerFrame = -1; uint8 *ref_oof; uint8 *ref_prev_y_top_oof = (s->fp) ? gCM.prev_y_top_oof_fp1 : gCM.prev_y_top_oof_fp0; uint8 *ref_prev_cb_top_oof = (s->fp) ? gCM.prev_cb_top_oof_fp1 : gCM.prev_cb_top_oof_fp0; uint8 *ref_prev_cr_top_oof = (s->fp) ? gCM.prev_cr_top_oof_fp1 : gCM.prev_cr_top_oof_fp0; uint8 *ref_fut_y_top_oof = (s->fp) ? gCM.fut_y_top_oof_fp1 : gCM.fut_y_top_oof_fp0; uint8 *ref_fut_cb_top_oof = (s->fp) ? gCM.fut_cb_top_oof_fp1 : gCM.fut_cb_top_oof_fp0; uint8 *ref_fut_cr_top_oof = (s->fp) ? gCM.fut_cr_top_oof_fp1 : gCM.fut_cr_top_oof_fp0; if (gCM.nFrameNum == oncePerFrame) return; oncePerFrame = gCM.nFrameNum; // In the CModel(MAE) we have 48 bytes of padding on each side, but the // DIVX reference codes use only 16 bytes of padding on each side. // To match up the respective file dumps, we shall print only // 16 bytes on each side for the CModel as well // ********************************************************************* // Forward Reference Frames // ************************ ref_oof = ref_prev_y_top_oof + (32 * (s->linesz + 96)) + 32; DumpOOFRefFrmForMAE(ref_oof, Y1_LUMA_BLOCK, s->linesz+32, s->height+32, MBM_FORWARD); // U OOF Reference Frame // ********************* ref_oof = ref_prev_cb_top_oof + (16 * (s->linesz/2 + 48)) + 16; DumpOOFRefFrmForMAE(ref_oof, U_CHROMA_BLOCK, s->linesz/2 + 16, s->height/2 + 16, MBM_FORWARD); // V OOF Reference Frame // ********************* ref_oof = ref_prev_cr_top_oof + (16 * (s->linesz/2 + 48)) + 16; DumpOOFRefFrmForMAE(ref_oof, V_CHROMA_BLOCK, s->linesz/2 + 16, s->height/2 + 16, MBM_FORWARD); // Backward Reference Frames // ************************* if (gCM.nFrameType == BFRAME) { ref_oof = ref_fut_y_top_oof + (32 * (s->linesz + 96)) + 32; DumpOOFRefFrmForMAE(ref_oof, Y1_LUMA_BLOCK, s->linesz+32, s->height+32, MBM_BACKWARD); ref_oof = ref_fut_cb_top_oof + (16 * (s->linesz/2 + 48)) + 16; DumpOOFRefFrmForMAE(ref_oof, U_CHROMA_BLOCK, s->linesz/2 + 16, s->height/2 + 16, MBM_BACKWARD); ref_oof = ref_fut_cr_top_oof + (16 * (s->linesz/2 + 48)) + 16; DumpOOFRefFrmForMAE(ref_oof, V_CHROMA_BLOCK, s->linesz/2 + 16, s->height/2 + 16, MBM_BACKWARD); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -