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

📄 decoder.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
字号:
/*************************************************************************This software module was originally developed by 	Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation	Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation	Bruce Lin (blin@microsoft.com), Microsoft Corporation	Chuang Gu (chuanggu@microsoft.com), Microsoft Corporation	(date: March, 1996)and edited by	Hiroyuki Katata (katata@imgsl.mkhar.sharp.co.jp), Sharp Corporation	Norio Ito (norio@imgsl.mkhar.sharp.co.jp), Sharp Corporation	Shuichi Watanabe (watanabe@imgsl.mkhar.sharp.co.jp), Sharp Corporation	(date: October, 1997)and also edited by	Dick van Smirren (D.vanSmirren@research.kpn.com), KPN Research	Cor Quist (C.P.Quist@research.kpn.com), KPN Research	(date: July, 1998)and also edited by 	Takefumi Nagumo (nagumo@av.crl.sony.co.jp), SONY corporation     Sehoon Son (shson@unitel.co.kr) Samsung AITin the course of development of the MPEG-4 Video (ISO/IEC 14496-2). This software module is an implementation of a part of one or more MPEG-4 Video tools as specified by the MPEG-4 Video. ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-4 Video. Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-4 Video conforming products. Sharp retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997.Module Name:	decoder.cAbstract:	caller for decoder for temporal scalabilityRevision History:	Feb. 12. 2000: Bug fix of OBSS by Takefumi Nagumo(SONY)*************************************************************************/#include <stdio.h>#include <stdlib.h>#include "typeapi.h"#include "mode.h"#include "vopses.h"#include "entropy/bitstrm.h"#include "entropy/huffman.h"#include "decoder/vopsedec.h"#ifndef __GLOBAL_VAR_#define __GLOBAL_VAR_#endif#include "global.h"#include "mae_pass_thru.h"#include "mae_fe.h"#include <sys/timeb.h> /* for ftime */#define FB_SUPPORT /* HWG050624 - added to enable MAE overlay window */#define DPRINTF(_args_) // printf _args_// Copied from the DivX-Travis-101503 tree/* stats collection */unsigned int  g_uiVideoFrameCount=0;unsigned int  g_uiAudioFrameCount=0;unsigned long g_ulBytesRead=0;unsigned int   g_uiOptionStatsLevel=99;unsigned int   g_bStatsStarted=0;unsigned long  g_uiStatsVFrameStart=0, g_uiStatsVFrameStop=0;unsigned long  g_uiStatsAFrameStart=0, g_uiStatsAFrameStop=0;unsigned long  g_ulStatsStartTime=0, g_ulStatsStopTime=0;unsigned long  g_ulStatsBytesStart=0, g_ulStatsBytesStop=0;unsigned int   g_uiVideoCompareDiffCount=0;unsigned int   g_uiAudioCompareDiffCount=0;/* SysGetTime() - return time in millisecs */unsigned long SysGetTime(){  unsigned long ulTime=0;#ifdef WIN32  LARGE_INTEGER liCount;  QueryPerformanceCounter(&liCount);  if (g_liTimeFreq.QuadPart)    ulTime=(unsigned long)((liCount.QuadPart*1000)/g_liTimeFreq.QuadPart);#else    struct timeb tm;    ftime (&tm);    ulTime = (tm.time*1000)+tm.millitm;#endif  return ulTime;}void StartStats(unsigned int uiVideoFrame, unsigned int uiAudioFrame){  if (!g_bStatsStarted)  {    g_uiStatsVFrameStart=g_uiStatsVFrameStop=uiVideoFrame;    g_uiStatsAFrameStart=g_uiStatsAFrameStop=uiAudioFrame;    g_ulStatsStartTime=g_ulStatsStopTime=SysGetTime();    g_ulStatsBytesStart=g_ulStatsBytesStop=g_ulBytesRead;    g_bStatsStarted=1;  }}void StopStats(unsigned int uiVideoFrame, unsigned int uiAudioFrame){  g_uiStatsVFrameStop=uiVideoFrame;  g_uiStatsAFrameStop=uiAudioFrame;  g_ulStatsStopTime=SysGetTime();  g_ulStatsBytesStop=g_ulBytesRead;  g_bStatsStarted=0;}void DumpStats(){  unsigned int uiVFrameCount=g_uiStatsVFrameStop-g_uiStatsVFrameStart;  unsigned int uiAFrameCount=g_uiStatsAFrameStop-g_uiStatsAFrameStart;  if (!g_uiOptionStatsLevel)    return;  if (!uiVFrameCount && !uiAFrameCount)  {    if (g_uiStatsVFrameStart==0) printf("No video or audio decoded.\r\n");  }  else  {    unsigned long ulEllapsedTime=g_ulStatsStopTime-g_ulStatsStartTime;    unsigned long ulBytesRead=g_ulStatsBytesStop-g_ulStatsBytesStart;    unsigned int ulMin, ulSec, ulMS;    unsigned long ulFramesPerSec100=0;    if (ulEllapsedTime)      ulFramesPerSec100=(uiVFrameCount*100*1000)/ulEllapsedTime;    ulMin=ulEllapsedTime/60000;    ulSec=(ulEllapsedTime/1000)%60;    ulMS=ulEllapsedTime%1000;    printf("\n  TotalTime=%5ld(msec)  FrameRate=%2d.%02d(fps)\n  AvgFrameTime=%2d.%d(msec)  VFrames=%4d\r\n",          ulEllapsedTime,          (ulFramesPerSec100/100), ulFramesPerSec100%100,          ulEllapsedTime/uiVFrameCount, ((ulEllapsedTime*10)/uiVFrameCount)%10,          uiVFrameCount);    }}#ifdef FB_SUPPORT#include "au1xxx_mae.h"#include <fcntl.h> /* for O_RDWR */#define AU1200_LCD_FB_IOCTL 0x46FF#define AU1200_LCD_SET_SCREEN 1#define AU1200_LCD_GET_SCREEN 2#define AU1200_LCD_SET_WINDOW 3#define AU1200_LCD_GET_WINDOW 4#define AU1200_LCD_SET_PANEL  5#define AU1200_LCD_GET_PANEL  6#define SCREEN_SIZE		    (1<< 1)#define SCREEN_BACKCOLOR    (1<< 2)#define SCREEN_BRIGHTNESS   (1<< 3)#define SCREEN_COLORKEY     (1<< 4)#define SCREEN_MASK         (1<< 5)typedef struct au1200_lcd_global_regs_t{    unsigned int flags;    unsigned int xsize;    unsigned int ysize;    unsigned int backcolor;    unsigned int brightness;	unsigned int colorkey;	unsigned int mask;    unsigned int panel_choice;    char panel_desc[80];} au1200_lcd_global_regs_t;#define WIN_POSITION            (1<< 0)#define WIN_ALPHA_COLOR         (1<< 1)#define WIN_ALPHA_MODE          (1<< 2)#define WIN_PRIORITY            (1<< 3)#define WIN_CHANNEL             (1<< 4)#define WIN_BUFFER_FORMAT       (1<< 5)#define WIN_COLOR_ORDER         (1<< 6)#define WIN_PIXEL_ORDER         (1<< 7)#define WIN_SIZE                (1<< 8)#define WIN_COLORKEY_MODE       (1<< 9)#define WIN_DOUBLE_BUFFER_MODE  (1<< 10)#define WIN_RAM_ARRAY_MODE      (1<< 11)#define WIN_BUFFER_SCALE        (1<< 12)#define WIN_ENABLE	            (1<< 13)typedef struct au1200_lcd_window_regs_t{    unsigned int flags;    unsigned int xpos;    unsigned int ypos;    unsigned int alpha_color;    unsigned int alpha_mode;    unsigned int priority;    unsigned int channel;    unsigned int buffer_format;    unsigned int color_order;    unsigned int pixel_order;    unsigned int xsize;    unsigned int ysize;    unsigned int colorkey_mode;    unsigned int double_buffer_mode;    unsigned int ram_array_mode;    unsigned int xscale;    unsigned int yscale;    unsigned int enable;} au1200_lcd_window_regs_t;typedef struct au1200_lcd_iodata_t{    unsigned int subcmd;    au1200_lcd_global_regs_t global;    au1200_lcd_window_regs_t window;} au1200_lcd_iodata_t;int SetupMAEWindow(unsigned int xpos, unsigned int ypos,                   unsigned int xsize, unsigned int ysize, unsigned int bVisable){    int eResult=0;    /* setup the overlay window (via framebuffer drivers) */      au1200_lcd_iodata_t iodata;      int ffb1=-1;      DPRINTF(("SetupMAEWindow(xpos=%d ypos=%d xsize=%d ysize=%d visable=%d)\n",               xpos, ypos, xsize, ysize, bVisable));      if ((ffb1=open("/dev/fb1", O_RDWR, 0)) == -1)      {          DPRINTF(("Error opening /dev/fb1\n"));          eResult=-1;          goto setup_window_done;      }      DPRINTF(("SetupMAEWindow() devices open\n"));      if (bVisable)      {          // write data from the MAI struct to the LCD and MAE          iodata.subcmd = AU1200_LCD_GET_SCREEN;          if (ioctl(ffb1, AU1200_LCD_FB_IOCTL, &iodata) < 0)          {                     DPRINTF(("VREND: Could not get screen info\n"));              eResult=-1;              goto setup_window_done;          }          DPRINTF(("SetupMAEWindow: FB1 GET_SCREEN reports: %d x %d\n", iodata.window.xsize, iodata.window.ysize));              // TEMPORARY - change the screen backcolor          // This is really the top level's job through direct          // LCD fb control...          iodata.subcmd = AU1200_LCD_SET_SCREEN;          iodata.global.flags = SCREEN_BACKCOLOR;          iodata.global.backcolor = 0x00080808; // off-black          if (ioctl(ffb1, AU1200_LCD_FB_IOCTL, &iodata) < 0) {                     DPRINTF(("Could not get screen info\n"));              eResult=MAI_STATUS_WRITEERROR;              goto setup_window_done;          }          DPRINTF(("SetupMAEWindow: set_video_out_param() fb1: BACKCOLOR set\n"));      }      iodata.subcmd = AU1200_LCD_SET_WINDOW;      iodata.window.flags = WIN_POSITION | WIN_ALPHA_COLOR | WIN_ALPHA_MODE | WIN_PRIORITY |                           WIN_CHANNEL | WIN_BUFFER_FORMAT | WIN_COLOR_ORDER | WIN_PIXEL_ORDER |                           WIN_SIZE | WIN_COLORKEY_MODE | WIN_DOUBLE_BUFFER_MODE | WIN_ENABLE;      iodata.window.xpos = xpos;      iodata.window.ypos = ypos;      iodata.window.alpha_color = 0;      iodata.window.alpha_mode = 0;        /* we'll assume Graphics plane is set to default Priority 0 */        /* use Priority 1 for MAE video plane - so app can still place overlays over video */        iodata.window.priority = 1;        /* Graphics plane should have been disabled, so just use Priority 0 */        //iodata.window.priority = 0;      iodata.window.channel = 0;      iodata.window.buffer_format = 6;      iodata.window.color_order = 0;      iodata.window.pixel_order = 0;      iodata.window.xsize = xsize;      iodata.window.ysize = ysize;      iodata.window.colorkey_mode = 0;      iodata.window.double_buffer_mode = 0;      iodata.window.enable = bVisable?1:0;      if (ioctl(ffb1, AU1200_LCD_FB_IOCTL, &iodata) < 0) {                 DPRINTF(("SetupMAEWindow: Could not set window\n"));          eResult=-1;          goto setup_window_done;      }      DPRINTF(("SetupMAEWindow() fb1: programmed winlocation: xpos=%d ypos=%d xsize=%d ysize=%d enable=%d pri=%d\n",               xpos, ypos, xsize, ysize, iodata.window.enable, iodata.window.priority)); #if 1      if (bVisable) /* setup MAE driver display size */      {        extern int fd; /* fd is a global from driverif.c */        int fdMAE=fd;                 MAE_DISP_STRUCT mae_disp;        mae_disp.display_linesize = xsize;        mae_disp.display_height = ysize;        if (fdMAE>0 && ioctl(fdMAE, AU1XXXMAE_DISPLAYSIZE, &mae_disp) < 0)         {          DPRINTF(("SetupMAEWindow() Could not set mae output size\n"));          eResult=-1;          goto setup_window_done;        }        DPRINTF(("SetupMAEWindow() programmed mae be: linesize=%d height=%d\n",               mae_disp.display_linesize, mae_disp.display_height));      }#endif    eResult=0; /* successfully setup window */setup_window_done: /* we hit this jump on failures */    if (ffb1>0)      close(ffb1);  return eResult;}#endif /* FB_SUPPORT */// Main Routineint main(int argc, char* argv[]){    Int iOrigDisplayWidth, iOrigDisplayHeight, iEof = 1;	main_short_video_header = FALSE; 	if(argc == 3)	{		if (strncmp(argv[2], "q=", 2)==0)		{			char *sQuit = strchr(argv[2], '=');			if (sQuit)				sQuit++;			nShortRun =atoi (sQuit);#ifdef ENABLE_PRINTS			printf("\nWill stop decoding after %d frame(s)", nShortRun);#endif		}	}    // Initialize the MPEG-4 video decoder    MP4V_Decoder_Init (argv [1], &iOrigDisplayWidth, &iOrigDisplayHeight); #ifdef FB_SUPPORT    SetupMAEWindow(0,0,iOrigDisplayWidth,iOrigDisplayHeight, 1/*visable*/); #endif    StartStats(nFrames, g_uiAudioFrameCount); /* make sure stats are started */    while (iEof != EOF && iEof != MP4V_UNSUPPORTED_CODING_TYPE)    {        //	Check for SHORT_RUN flag; if non-zero, check frame count and bail if greater than value        if ((nShortRun != 0) && (nFrames == nShortRun))            break;#ifdef ENABLE_PRINTS        printf("Processing Frame %d ", nFrames);#endif        if (!main_short_video_header)            iEof = decode ();         else            iEof = h263_decode ();    }    StopStats(nFrames, g_uiAudioFrameCount);    DumpStats();  #ifdef FB_SUPPORT    SetupMAEWindow(0,0,iOrigDisplayWidth,iOrigDisplayHeight, 0/*visable*/); #endif    MP4V_Decoder_CleanUp ();	return 0;}

⌨️ 快捷键说明

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