⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mae_fe.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* <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.c,v $ * $Id: mae_fe.c,v 1.173 2004/09/15 14:47:18 eswartz Exp $ * </CTL_AMD_STD>  *//* <DOC_AMD_STD> * </DOC_AMD_STD>  */#define MAE_SATURATE8(x)   ((x) < 0 ? 0 : ((x) > 255 ? 255 : (x)))#ifndef HAVE_MAE  #include <mae_pass_thru.h>#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <math.h>#include <stdarg.h>#ifdef HAVE_MAE  #include <netinet/in.h>  #include "mem.h"#endif#include "fcov.h"#include "swizzle.h"#include "mae_fe.h"#include "mae_vpi.h"#include "mae_fe_mcomp.h"#include "wmv9_xforms.h"#include "wmv9_filters.h"#include "mae_global.h"#ifndef PI  #ifdef M_PI    #define PI M_PI  #else    #define PI 3.14159265358979323846  #endif#endif#define MAE_FE_MPEG_COVERAGE#ifdef MAE_FE_MPEG_COVERAGE  // Macroblock back-to-back parm changing...  // MAE HEADER WORD 0  uint32 fcov_prev_bblk;          // 1-bit  uint32 fcov_prev_iqmul2;        // 9-bits  uint32 fcov_prev_wtchgmsk;      // 4-bits  uint32 fcov_prev_iqadd1;        // 6-bits  uint32 fcov_prev_dcluma;        // 6-bits  uint32 fcov_prev_dcchroma;      // 6-bits  // MAE HEADER WORD 1  uint32 fcov_prev_cbp_y0;        // 1-bit  uint32 fcov_prev_cbp_y1;        // 1-bit  uint32 fcov_prev_cbp_y2;        // 1-bit  uint32 fcov_prev_cbp_y3;        // 1-bit  uint32 fcov_prev_cbp_cb0;       // 1-bit  uint32 fcov_prev_cbp_cr0;       // 1-bit  uint32 fcov_prev_cbp_cb1;       // 1-bit  uint32 fcov_prev_cbp_cr1;       // 1-bit  uint32 fcov_prev_iqdiv3;        // 3-bits  uint32 fcov_prev_iqadd2;        // 9-bits  // MAE HEADER WORD 2  uint32 fcov_prev_mbmode_y0;     // 2-bits  uint32 fcov_prev_mbmode_y1;     // 2-bits  uint32 fcov_prev_mbmode_y2;     // 2-bits  uint32 fcov_prev_mbmode_y3;     // 2-bits  uint32 fcov_prev_mbmode_cb0;    // 2-bits  uint32 fcov_prev_mbmode_cr0;    // 2-bits  uint32 fcov_prev_mbmode_cb1;    // 2-bits  uint32 fcov_prev_mbmode_cr1;    // 2-bits  uint32 fcov_prev_xformsize_y0;  // 2-bits  uint32 fcov_prev_xformsize_y1;  // 2-bits  uint32 fcov_prev_xformsize_y2;  // 2-bits  uint32 fcov_prev_xformsize_y3;  // 2-bits  uint32 fcov_prev_xformsize_cb0; // 2-bits  uint32 fcov_prev_xformsize_cr0; // 2-bits  uint32 fcov_prev_xformsize_cb1; // 2-bits  uint32 fcov_prev_xformsize_cr1; // 2-bits  // MAE HEADER WORD 3  uint32 fcov_prev_rnd;           // 1-bit  uint32 fcov_prev_ps;            // 1-bit  uint32 fcov_prev_dctt;          // 1-bit  uint32 fcov_prev_fp;            // 1-bit  uint32 fcov_prev_ft;            // 1-bit  uint32 fcov_prev_fb;            // 1-bit  uint32 fcov_prev_bt;            // 1-bit  uint32 fcov_prev_bb;            // 1-bit  uint32 fcov_prev_mbtype;        // 2-bits  uint32 fcov_prev_mcprecy;       // 2-bits  uint32 fcov_prev_mcprecuv;      // 2-bits#endif// Useful flags//#define PROTOTYPING//#define DEBUG_BUFFER_DATA//#define DEBUG_MACROBLOCK_DATA//#define DEBUG_FILTER_DATAvoid print_buffer_data(mae_fe_config *mae_fe_cfg, uint32 mb_num);#ifdef HAVE_MAEchar rtl_printf_huge_buf[16*1024];#else  extern void InterChecksOnBlock(pINTERMEDITATE_BLOCK_CHECKERS, char *);#endif#ifdef PROTOTYPING#define PROTO_START 0x20000000;FILE   *reg_data_file, *input_data_file, *output_data_file;uint32  mb_proto_addr;uint32  mb_proto_addr_start;int     proto_frame            = 0;int     proto_frame_last       = 0;uint32  proto_addr_scratch;uint32  proto_addr_cur_y;uint32  proto_addr_cur_cb;uint32  proto_addr_cur_cr;uint32  proto_addr_fwd_y_bot;uint32  proto_addr_fwd_cb_bot;uint32  proto_addr_fwd_cr_bot;uint32  proto_addr_bwd_y_bot;uint32  proto_addr_bwd_cb_bot;uint32  proto_addr_bwd_cr_bot;uint32  proto_addr_fwd_y_top;uint32  proto_addr_fwd_cb_top;uint32  proto_addr_fwd_cr_top;uint32  proto_addr_bwd_y_top;uint32  proto_addr_bwd_cb_top;uint32  proto_addr_bwd_cr_top;uint32  proto_desc;void pack_proto_reg(mae_fe_config *cfg, mae_fe_mb *mb, int mb_num);void pack_proto_frame(mae_fe_config *cfg, mae_fe_mb *mb, MAEContext *s, uint8 *cur_y, uint8 *cur_cb, uint8 *cur_cr);#endifuint32 any_bwd             = 0;uint32 any_fwd             = 0;uint32 any_fp              = 0;int64 dp_width_mpeg = 32;int64 whole_number_prec_mpeg = 18;int64 dp_width_wmv9 = 46;int64 whole_number_prec_wmv9 = 32;int64 dp_width = 0;int64 whole_number_prec = 0;int64 fraction_prec = 14;int64 prec = 14; //fraction_prec;uint32 p_frame = 0;uint32 b_frame = 0;static char tmp_cov_str[256];// Local prototypesvoid do_malloc_if_necessary(mae_fe_config *cfg);void do_free_if_necessary();void mae_init_once(mae_fe_config * mae_fe_cfg, mae_fe_mb * mb_in);int RTL_printf(const char *fmt, ...){  int result = 0;  va_list ap;  // Paranoia says do the va_start and va_end even for a no-op version  // Just in case there is screwy stack management  va_start (ap, fmt);#ifdef HAVE_MAE  result =   vsprintf(rtl_printf_huge_buf, fmt, ap);  vpi_printf(rtl_printf_huge_buf);#endif  va_end (ap);  return result;}int64 mae_abs64(int64 num){  if ( num < 0 )    return -num;  return num;}int is_pos(int64 a){  // we're negative if the sign bit or any bits above are high  int64 sign = (a >> (fraction_prec + whole_number_prec - 1));  return (sign == UINT64(0));}int64 add(char *mesg, int64 a, int64 b){  int64 result;  result = a + b;  //check for overflow  if((is_pos(a) && is_pos(b)) && !is_pos(result)){    printf("INFO: overflow in IQuant/IDCT data path (1) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s)\n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if((!is_pos(a) && !is_pos(b)) && is_pos(result)){    printf("INFO: overflow in IQuant/IDCT data path (2) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s)\n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if( is_pos(a) && !is_pos(b) ){    if((mae_abs64(a) > mae_abs64(b)) && !is_pos(result)) {      printf("INFO: overflow in IQuant/IDCT data path (3) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s) \n",                  fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);    } else if((mae_abs64(a) < mae_abs64(b)) && is_pos(result)) {      printf("INFO: overflow in IQuant/IDCT data path (4) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s) \n",                  fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);    }  }  if( !is_pos(a) && is_pos(b) ){    if((mae_abs64(a) > mae_abs64(b)) && is_pos(result)) {      printf("INFO: overflow in IQuant/IDCT data path (5) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s) \n",                  fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);    } else if((mae_abs64(a) < mae_abs64(b)) && !is_pos(result)) {      printf("INFO: overflow in IQuant/IDCT data path (6) a+b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d> (%s) \n",                  fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);    }  }  result = fixed_sign_extend(result);  return result;}int64 mult(char *mesg, int64 a, int64 b){  int64 result;  result = (a * b)>>prec;  //check for overflow  if((is_pos(a) && is_pos(b)) && !is_pos(result)){    printf("INFO: overflow in IQuant/IDCT data path (1) a*b = %f, [a:%f, b:%f] <is_pos(result,a,b): %.1d%.1d%.1d> (%s)\n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if((!is_pos(a) && !is_pos(b)) && !is_pos(result)){    printf("INFO: overflow in IQuant/IDCT data path (2) a*b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d>  (%s) \n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if((!is_pos(a) && is_pos(b)) && is_pos(result) && (result != 0)){    printf("INFO: overflow in IQuant/IDCT data path (3) a*b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d>  (%s) \n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if((is_pos(a) && !is_pos(b)) && is_pos(result) && (result != 0)){    printf("INFO: overflow in IQuant/IDCT data path (4) a*b = %f, [a:%f, b:%f]  <is_pos(result,a,b): %.1d%.1d%.1d>  (%s) \n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), is_pos(result), is_pos(a), is_pos(b), mesg);  }  if((result >> (fraction_prec + whole_number_prec)) && (~((result >> (fraction_prec + whole_number_prec-1)) | UINT64(0xfffffffffffffffc)))) {    printf("INFO: overflow in IQuant/IDCT data path (5) a*b = %f, [a:%f, b:%f]  (%s) \n",                fixed_to_double(result), fixed_to_double(a), fixed_to_double(b), mesg);  }  result = fixed_sign_extend(result);  return result;}int64 double_to_fixed(double num){  int64 whole_number;  double fraction;  int64 int_fraction;  int64 return_val;  whole_number = (int64)floor(abs((int)num));  fraction = fabs(num) - whole_number;  int_fraction = mae_abs64((int64)(fraction * pow(2, (double)fraction_prec)));  return_val = (whole_number<<fraction_prec) | int_fraction;  return_val = (num<0) ? return_val*-1 : return_val;  //  printf("num:%f whole_number:%d whole_number shifted:%d frac:%f int_fraction:%d return_val:%d\n",  //          num, whole_number, whole_number<<fraction_prec, fraction, int_fraction, return_val);  return return_val;}double fixed_to_double(int64 num){  int64 whole_number;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -