123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- /*------------------------------------------------------------------------------
- -- --
- -- This software is confidential and proprietary and may be used --
- -- only as expressly authorized by a licensing agreement from --
- -- --
- -- Hantro Products Oy. --
- -- --
- -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
- -- ALL RIGHTS RESERVED --
- -- --
- -- The entire notice above must be reproduced --
- -- on all copies and should not be removed. --
- -- --
- --------------------------------------------------------------------------------
- --
- -- Description : Internal traces
- --
- ------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------
- 1. Include headers
- ------------------------------------------------------------------------------*/
- #include <stdio.h>
- #include "enctrace.h"
- /*------------------------------------------------------------------------------
- 2. External compiler flags
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- 3. Module defines
- ------------------------------------------------------------------------------*/
- static FILE *fileAsic = NULL;
- static FILE *filePreProcess = NULL;
- static FILE *fRegs = NULL;
- static FILE *fRecon = NULL;
- static FILE *fTrace = NULL;
- /*------------------------------------------------------------------------------
- 4. Local function prototypes
- ------------------------------------------------------------------------------*/
- void EncTraceCloseAll(void)
- {
- if(fileAsic != NULL)
- fclose(fileAsic);
- if(filePreProcess != NULL)
- fclose(filePreProcess);
- if(fRegs != NULL)
- fclose(fRegs);
- if(fRecon != NULL)
- fclose(fRecon);
- if(fTrace != NULL)
- fclose(fTrace);
- }
- /*------------------------------------------------------------------------------
- EncTraceAsic
- ------------------------------------------------------------------------------*/
- void EncTraceAsicParameters(asicData_s * asic)
- {
- if(fileAsic == NULL)
- fileAsic = fopen("sw_asic.trc", "w");
- if(fileAsic == NULL)
- {
- fprintf(stderr, "Unable to open trace file: asic.trc\n");
- return;
- }
- fprintf(fileAsic, "ASIC parameters:\n");
- fprintf(fileAsic, "Input lum bus: 0x%08x\n",
- (u32) asic->regs.inputLumBase);
- fprintf(fileAsic, "Input cb bus: 0x%08x\n",
- (u32) asic->regs.inputCbBase);
- fprintf(fileAsic, "Input cr bus: 0x%08x\n\n",
- (u32) asic->regs.inputCrBase);
- /*fprintf(fileAsic, "Internal image base W: 0x%08x\n", (u32)asic->internalImageBase.virtualAddress); */
- fprintf(fileAsic, "Encoding type: %6d\n", asic->regs.codingType);
- /*
- * fprintf(fileAsic, "Input endian mode: %6d\n",
- * asic->regs.inputEndianMode);
- * fprintf(fileAsic, "Input endian width: %6d\n",
- * asic->regs.inputEndianWidth);
- * fprintf(fileAsic, "Output endian width: %6d\n",
- * asic->regs.outputEndianWidth);
- */
- fprintf(fileAsic, "Mbs in row: %6d\n", asic->regs.mbsInRow);
- fprintf(fileAsic, "Mbs in col: %6d\n", asic->regs.mbsInCol);
- fprintf(fileAsic, "Input lum width: %6d\n", asic->regs.pixelsOnRow);
- fprintf(fileAsic, "Frame type: %6d\n",
- asic->regs.frameCodingType);
- fprintf(fileAsic, "QP: %6d\n", asic->regs.qp);
- fprintf(fileAsic, "Round control: %6d\n",
- asic->regs.roundingCtrl);
- /* fprintf(fileAsic, "MV SAD penalty: %6d\n", asic->regs.mvSadPenalty);
- fprintf(fileAsic, "Intra SAD penalty: %6d\n", asic->regs.intraSadPenalty);
- fprintf(fileAsic, "4MV SAD penalty: %6d\n", asic->regs.fourMvSadPenalty);
- */
- fprintf(fileAsic, "Burst size: %6d\n", ENC8290_BURST_LENGTH);
- }
- /*------------------------------------------------------------------------------
- EncTracePreProcess
- ------------------------------------------------------------------------------*/
- void EncTracePreProcess(preProcess_s * preProcess)
- {
- if(filePreProcess == NULL)
- filePreProcess = fopen("sw_preprocess.trc", "w");
- if(filePreProcess == NULL)
- {
- fprintf(stderr, "Unable to open trace file: preprocess.trc\n");
- return;
- }
- fprintf(filePreProcess, "Input width: %d\n", preProcess->lumWidthSrc);
- fprintf(filePreProcess, "Input height: %d\n", preProcess->lumHeightSrc);
- fprintf(filePreProcess, "Hor offset src: %d\n", preProcess->horOffsetSrc);
- fprintf(filePreProcess, "Ver offset src: %d\n", preProcess->verOffsetSrc);
- }
- /*------------------------------------------------------------------------------
- EncTraceRegs
- ------------------------------------------------------------------------------*/
- void EncTraceRegs(const void *ewl, u32 readWriteFlag, u32 mbNum)
- {
- u32 i;
- char RW = 'W';
- static i32 frame = 0;
- if(fRegs == NULL)
- fRegs = fopen("sw_reg.trc", "w");
- if(fRegs == NULL)
- fRegs = stderr;
- fprintf(fRegs, "pic=%d\n", frame);
- fprintf(fRegs, "mb=%d\n", mbNum);
- /* After frame is finished, registers are read */
- if (readWriteFlag)
- {
- RW = 'R';
- frame++;
- }
- /* Dump registers in same denali format as the system model */
- for(i = 0; i <= 0x17C; i += 4)
- if ((i != 0xA0) && (i != 0x38))
- fprintf(fRegs, "%c %08x/%08x\n", RW, i, EWLReadReg(ewl, i));
- /* Regs with enable bits last, force encoder enable high for frame start */
- fprintf(fRegs, "%c %08x/%08x\n", RW, 0xA0, EWLReadReg(ewl, 0xA0));
- fprintf(fRegs, "%c %08x/%08x\n", RW, 0x38,
- EWLReadReg(ewl, 0x38) | (readWriteFlag==0));
- fprintf(fRegs, "\n");
- /*fclose(fRegs);
- * fRegs = NULL; */
- }
- u32 SwapEndian(u32 tmp)
- {
- u32 swapped;
- swapped = tmp >> 24;
- swapped |= (tmp >> 8) & (0xFF00);
- swapped |= (tmp << 8) & (0xFF0000);
- swapped |= tmp << 24;
- return swapped;
- }
- /*------------------------------------------------------------------------------
- EncDumpRecon
- ------------------------------------------------------------------------------*/
- void EncDumpRecon(asicData_s * asic)
- {
- if(fRecon == NULL)
- fRecon = fopen("sw_recon_internal.yuv", "wb");
- if(fRecon)
- {
- u32 index;
- u32 size = asic->regs.mbsInCol * asic->regs.mbsInRow * 16 * 16;
- if(asic->regs.internalImageLumBaseW ==
- asic->internalImageLuma[0].busAddress)
- index = 0;
- else
- index = 1;
- {
- u32 *pTmp = asic->internalImageLuma[index].virtualAddress;
- fwrite(pTmp, 1, size, fRecon);
- }
- {
- u32 *pTmp = asic->internalImageChroma[index].virtualAddress;
- fwrite(pTmp, 1, size / 2, fRecon);
- }
- }
- }
|