You can subscribe to this list here.
2003 |
Jan
(466) |
Feb
(545) |
Mar
(314) |
Apr
(96) |
May
(138) |
Jun
(134) |
Jul
(49) |
Aug
(71) |
Sep
(27) |
Oct
(76) |
Nov
(26) |
Dec
(24) |
---|
From: <jma...@us...> - 2003-10-30 08:13:29
|
Update of /cvsroot/xbplayer/XBMP/UI In directory sc8-pr-cvs1:/tmp/cvs-serv1898/UI Modified Files: AudioSettingsInterface.cpp Configuration.cpp Configuration.h PAudio.cpp Log Message: Added GUI option for Digital Audio Pass Through - doesn't do anything but store the value in a bool at the moment. Incremented the version number of system.bin to take account of this. Index: AudioSettingsInterface.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/UI/AudioSettingsInterface.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AudioSettingsInterface.cpp 12 Oct 2003 01:37:33 -0000 1.15 --- AudioSettingsInterface.cpp 30 Oct 2003 08:13:22 -0000 1.16 *************** *** 80,84 **** { FLOAT fTextX = CORDX(COVERCTL)+14; ! FLOAT fTextY = CORDY(COVERCTL)+80; m_bplAudio.Render(); --- 80,84 ---- { FLOAT fTextX = CORDX(COVERCTL)+14; ! FLOAT fTextY = CORDY(COVERCTL)+105; m_bplAudio.Render(); Index: Configuration.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/UI/Configuration.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** Configuration.cpp 15 Oct 2003 07:15:48 -0000 1.84 --- Configuration.cpp 30 Oct 2003 08:13:22 -0000 1.85 *************** *** 206,209 **** --- 206,210 ---- m_pPlayerSettings->bAudioNormalize=FALSE; m_pPlayerSettings->bAudioExtraStereo=FALSE; + m_pPlayerSettings->bDigitalAudioPassThrough=FALSE; m_pPlayerSettings->iVisualisation=1; m_pPlayerSettings->bCacheISO9660=FALSE; Index: Configuration.h =================================================================== RCS file: /cvsroot/xbplayer/XBMP/UI/Configuration.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** Configuration.h 12 Oct 2003 01:37:33 -0000 1.74 --- Configuration.h 30 Oct 2003 08:13:23 -0000 1.75 *************** *** 16,20 **** #define OVERLAY_STANDARD 1 ! #define CONFIG_VERSION 0x245 #include <string> --- 16,20 ---- #define OVERLAY_STANDARD 1 ! #define CONFIG_VERSION 0x246 #include <string> *************** *** 117,120 **** --- 117,121 ---- BOOL bAudioNormalize; BOOL bAudioExtraStereo; + BOOL bDigitalAudioPassThrough; int iVisualisation; // visualisation to use BOOL bViewMusicByList; // view My Music by list or icon Index: PAudio.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/UI/PAudio.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PAudio.cpp 23 Feb 2003 18:22:22 -0000 1.6 --- PAudio.cpp 30 Oct 2003 08:13:23 -0000 1.7 *************** *** 34,38 **** // Create Button Panel ! if ( FAILED(CButtonPanel::Create(pUserInterface, m_pfntCommon13, 5, NULL,FALSE)) ) { OutputDebugString("Unable to create button panel.\n"); --- 34,38 ---- // Create Button Panel ! if ( FAILED(CButtonPanel::Create(pUserInterface, m_pfntCommon13, 6, NULL,FALSE)) ) { OutputDebugString("Unable to create button panel.\n"); *************** *** 44,53 **** SetButtonText(2, STRING(263) ); SetButtonText(3, STRING(264) ); ! SetButtonText(4, STRING(267) ); SetButtonSelection(0,g_playerSettings.bAudioOnAllSpeakers); SetButtonSelection(1,g_playerSettings.bAudioNormalize); SetButtonSelection(2,g_playerSettings.bAudioExtraStereo); SetButtonSelection(3,g_playerSettings.bAmplifyAudio); ! SetButtonSelection(4,g_playerSettings.bShuffleOnLoad); SetButtonFocus(0); --- 44,55 ---- SetButtonText(2, STRING(263) ); SetButtonText(3, STRING(264) ); ! SetButtonText(4, STRING(294) ); ! SetButtonText(5, STRING(267) ); SetButtonSelection(0,g_playerSettings.bAudioOnAllSpeakers); SetButtonSelection(1,g_playerSettings.bAudioNormalize); SetButtonSelection(2,g_playerSettings.bAudioExtraStereo); SetButtonSelection(3,g_playerSettings.bAmplifyAudio); ! SetButtonSelection(4,g_playerSettings.bDigitalAudioPassThrough); ! SetButtonSelection(5,g_playerSettings.bShuffleOnLoad); SetButtonFocus(0); *************** *** 80,86 **** case 4: g_playerSettings.bShuffleOnLoad=!g_playerSettings.bShuffleOnLoad; CButtonPanel::Select(); ! break; } --- 82,93 ---- case 4: + g_playerSettings.bDigitalAudioPassThrough=!g_playerSettings.bDigitalAudioPassThrough; + CButtonPanel::Select(); + break; + + case 5: g_playerSettings.bShuffleOnLoad=!g_playerSettings.bShuffleOnLoad; CButtonPanel::Select(); ! break; } |
From: <jma...@us...> - 2003-10-30 08:13:28
|
Update of /cvsroot/xbplayer/XBMP/freestyle/Media/Resources/Locale In directory sc8-pr-cvs1:/tmp/cvs-serv1898/freestyle/Media/Resources/Locale Modified Files: lang-1.xml Log Message: Added GUI option for Digital Audio Pass Through - doesn't do anything but store the value in a bool at the moment. Incremented the version number of system.bin to take account of this. Index: lang-1.xml =================================================================== RCS file: /cvsroot/xbplayer/XBMP/freestyle/Media/Resources/Locale/lang-1.xml,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** lang-1.xml 12 Oct 2003 01:36:01 -0000 1.48 --- lang-1.xml 30 Oct 2003 08:13:24 -0000 1.49 *************** *** 158,161 **** --- 158,163 ---- <tuple>293,Goom</tuple> + <tuple>294,Digital Audio Pass Through</tuple> + <tuple>400,Mounting utility drive...</tuple> <tuple>401,Please wait.</tuple> |
From: <mon...@us...> - 2003-10-29 23:02:56
|
Update of /cvsroot/xbplayer/XBMP In directory sc8-pr-cvs1:/tmp/cvs-serv19534 Modified Files: buildtime.h Log Message: Building time changed to oct, 2003 Index: buildtime.h =================================================================== RCS file: /cvsroot/xbplayer/XBMP/buildtime.h,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** buildtime.h 26 Jul 2003 01:49:55 -0000 1.97 --- buildtime.h 29 Oct 2003 23:02:52 -0000 1.98 *************** *** 1,4 **** #ifndef BUILD_TIME_H #define BUILD_TIME_H ! #define BUILD_TIME L"Build:25 july 2003 17:30" #endif --- 1,4 ---- #ifndef BUILD_TIME_H #define BUILD_TIME_H ! #define BUILD_TIME L"Build:27 Oct. 2003 17:30" #endif |
From: <jma...@us...> - 2003-10-29 18:42:00
|
Update of /cvsroot/xbplayer/XBMP In directory sc8-pr-cvs1:/tmp/cvs-serv31550 Modified Files: XBoxMediaPlayer.cpp Log Message: Graphical Fixes for Layer issues when more than 1 info bar is onscreen Added time out to timejump feature Index: XBoxMediaPlayer.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/XBoxMediaPlayer.cpp,v retrieving revision 1.198 retrieving revision 1.199 diff -C2 -d -r1.198 -r1.199 *** XBoxMediaPlayer.cpp 24 Oct 2003 09:29:19 -0000 1.198 --- XBoxMediaPlayer.cpp 29 Oct 2003 18:41:56 -0000 1.199 *************** *** 719,723 **** OutputDebugString("Unable to create aspect Clip information rectangle.\n"); } ! m_rctInfo.SetColourDiffuse(0x404062BC); // Create texture (splash screen); --- 719,723 ---- OutputDebugString("Unable to create aspect Clip information rectangle.\n"); } ! m_rctInfo.SetColourDiffuse(0xC0204080); // Create texture (splash screen); *************** *** 2669,2673 **** //23:59:59 //01234567 ! m_dwShowTime=timeGetTime(); m_dwShowFlags |= SHOW_AV_DELAY; int iKey = chKey-'0'; --- 2669,2677 ---- //23:59:59 //01234567 ! DWORD dwCurrentTime = timeGetTime(); ! // Check if we haven't timed out... ! if (dwCurrentTime > m_dwShowTime && dwCurrentTime-m_dwShowTime > 8000) // 8 second timeout ! m_iSelectedCount=0; ! m_dwShowTime=dwCurrentTime; m_dwShowFlags |= SHOW_AV_DELAY; int iKey = chKey-'0'; *************** *** 2737,2745 **** im*=60; ih*=3600; ! long lTotalDuration; lTotalDuration = m_pMediaPlayer->GetPlaybackTime() / 1000L; ! if(lTotalDuration > (im+ih+is)) { ! m_pMediaPlayer->SetPosition(1000L*(ih+im+is)); mp_msg(0,0,"seek 2 %i:%i", ih,im); m_iSelectedCount=0; --- 2741,2750 ---- im*=60; ih*=3600; ! long lTotalDuration; ! long lSkipPos = ih+im+is; lTotalDuration = m_pMediaPlayer->GetPlaybackTime() / 1000L; ! if(lTotalDuration > lSkipPos) { ! m_pMediaPlayer->SetPosition(1000L*lSkipPos); mp_msg(0,0,"seek 2 %i:%i", ih,im); m_iSelectedCount=0; |
From: <mon...@us...> - 2003-10-29 14:15:41
|
Update of /cvsroot/xbplayer/XBMP/freestyle/Media/Resources/dll In directory sc8-pr-cvs1:/tmp/cvs-serv6403/freestyle/Media/Resources/dll Modified Files: README.TXT Log Message: Real Media Dll descriptions Index: README.TXT =================================================================== RCS file: /cvsroot/xbplayer/XBMP/freestyle/Media/Resources/dll/README.TXT,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README.TXT 26 May 2003 15:32:24 -0000 1.3 --- README.TXT 29 Oct 2003 14:15:38 -0000 1.4 *************** *** 2,6 **** Get dll's for here: http://www1.mplayerhq.hu/MPlayer/releases/codecs/ ! Currently (22/01-2003) only these DLL's are supported: wma9dmod.dll (File version: 9.0.0.2926) 409,720 bytes --- 2,8 ---- Get dll's for here: http://www1.mplayerhq.hu/MPlayer/releases/codecs/ ! Currently (29/10-2003) only these DLL's are supported: ! ! WMV9: wma9dmod.dll (File version: 9.0.0.2926) 409,720 bytes *************** *** 10,12 **** --- 12,21 ---- wmvdmod.dll (File version: 9.0.0.2926) 807,528 bytes + RealMedia:(dnet audio and RV10/13 video/audio support by native codecs) + atrc3260.dll (File version: 6.0.1.1651) 73,766 bytes ATRAC3 audio(Sony ATRAC3 codec) + cook3260.dll (File version: 6.0.8.2523) 65,575 bytes COOK audio + drv23260.dll (File version: 6.0.7.3928) 176,165 bytes RV20(G2) video(use force frame rate option) + drv33260.dll (File version: 6.0.7.4085) 208,935 bytes RV30(RV8) video + drv43260.dll (File version: 6.0.7.2389) 217,127 bytes RV40(RV9) video + sipr3260.dll (File version: 6.0.7.3922) 102,439 bytes SIPR audio(ACELP-NET Voice Codec) |
From: <mon...@us...> - 2003-10-27 08:09:03
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs In directory sc8-pr-cvs1:/tmp/cvs-serv5729/mplayerlibs/libmpcodecs Modified Files: vf_rectangle.c Log Message: Solve the non mutiple of 16 image size Green Bar issues Index: vf_rectangle.c =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs/vf_rectangle.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vf_rectangle.c 24 Apr 2003 12:52:38 -0000 1.4 --- vf_rectangle.c 27 Oct 2003 08:06:46 -0000 1.5 *************** *** 105,112 **** { memcpy_pic(dmpi->planes[1],mpi->planes[1], ! mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1],mpi->stride[1]); memcpy_pic(dmpi->planes[2],mpi->planes[2], ! mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2],mpi->stride[2]); } --- 105,112 ---- { memcpy_pic(dmpi->planes[1],mpi->planes[1], ! dmpi->chroma_width, dmpi->chroma_height, dmpi->stride[1],mpi->stride[1]); memcpy_pic(dmpi->planes[2],mpi->planes[2], ! dmpi->chroma_width, dmpi->chroma_height, dmpi->stride[2],mpi->stride[2]); } |
From: <mon...@us...> - 2003-10-27 08:00:01
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs In directory sc8-pr-cvs1:/tmp/cvs-serv3993/mplayerlibs/libmpcodecs Modified Files: vf_expand.c Log Message: Solve the non mutiple of 16 image size Green Bar issues Index: vf_expand.c =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs/vf_expand.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** vf_expand.c 22 May 2003 19:35:50 -0000 1.10 --- vf_expand.c 27 Oct 2003 07:57:49 -0000 1.11 *************** *** 377,389 **** memcpy_pic(vf->dmpi->planes[0]+ vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x, ! mpi->planes[0], mpi->w, mpi->h, vf->dmpi->stride[0],mpi->stride[0]); memcpy_pic(vf->dmpi->planes[1]+ (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift), ! mpi->planes[1], mpi->chroma_width, mpi->chroma_height, vf->dmpi->stride[1],mpi->stride[1]); memcpy_pic(vf->dmpi->planes[2]+ (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift), ! mpi->planes[2], mpi->chroma_width, mpi->chroma_height, vf->dmpi->stride[2],mpi->stride[2]); } --- 377,389 ---- memcpy_pic(vf->dmpi->planes[0]+ vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x, ! mpi->planes[0], vf->dmpi->w, vf->dmpi->h, vf->dmpi->stride[0],mpi->stride[0]); memcpy_pic(vf->dmpi->planes[1]+ (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift), ! mpi->planes[1], vf->dmpi->chroma_width, vf->dmpi->chroma_height, vf->dmpi->stride[1],mpi->stride[1]); memcpy_pic(vf->dmpi->planes[2]+ (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift), ! mpi->planes[2], vf->dmpi->chroma_width, vf->dmpi->chroma_height, vf->dmpi->stride[2],mpi->stride[2]); } |
From: <mon...@us...> - 2003-10-27 07:59:15
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs In directory sc8-pr-cvs1:/tmp/cvs-serv3731/mplayerlibs/libmpcodecs Modified Files: dec_audio.c Log Message: Fix a small memory leak Index: dec_audio.c =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayerlibs/libmpcodecs/dec_audio.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dec_audio.c 10 Jun 2003 15:14:06 -0000 1.6 --- dec_audio.c 27 Oct 2003 07:55:43 -0000 1.7 *************** *** 301,304 **** --- 301,305 ---- mp_msg(MSGT_DECAUDIO,MSGL_V,"Uninit audio filters...\n"); af_uninit(sh_audio->afilter); + free(sh_audio->afilter); //fix memory leak sh_audio->afilter=NULL; } |
From: <jma...@us...> - 2003-10-25 17:35:32
|
Update of /cvsroot/xbplayer/XBMP In directory sc8-pr-cvs1:/tmp/cvs-serv529 Modified Files: XBoxMediaPlayer.cpp Log Message: Nicer toggling of ShowTitleInfo with black button (remembers setting until XBMP shuts down) Index: XBoxMediaPlayer.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/XBoxMediaPlayer.cpp,v retrieving revision 1.197 retrieving revision 1.198 diff -C2 -d -r1.197 -r1.198 *** XBoxMediaPlayer.cpp 23 Oct 2003 19:38:24 -0000 1.197 --- XBoxMediaPlayer.cpp 24 Oct 2003 09:29:19 -0000 1.198 *************** *** 1782,1798 **** if (dwCurrentAppState == IN_MOVIE) { ! if (m_bShowTrackInfo == false && m_bShowDelay == false) ! { ! m_bShowTrackInfo = true; ! } ! else if (m_bShowTrackInfo == true && m_bShowDelay == false) { ! m_bShowTrackInfo = false; ! m_bShowDelay = true; } else { ! m_bShowTrackInfo = false; ! m_bShowDelay = false; } } --- 1782,1804 ---- if (dwCurrentAppState == IN_MOVIE) { ! if (m_pMediaPlayer->HasVideo()) // Just toggle m_bShowDelay { ! m_bShowDelay = !m_bShowDelay; } else { ! if (!m_bShowTrackInfo && !m_bShowDelay) ! { ! m_bShowTrackInfo = true; ! } ! else if (m_bShowTrackInfo && !m_bShowDelay) ! { ! m_bShowTrackInfo = false; ! m_bShowDelay = true; ! } ! else // !m_bShowTrackInfo && m_bShowDelay ! { ! m_bShowDelay = false; ! } } } *************** *** 2300,2314 **** if (OVERLAY_STANDARD == g_playerSettings.dwOverlayMode) { ! if (m_pMediaPlayer->IsPlaying() ) { ! if (!m_pMediaPlayer->HasVideo() ) ! { ! if (!ShowTrackInfo(24,30)) ! { ! // if no title to diplay, switch to delay ! m_bShowTrackInfo=false; ! m_bShowDelay=true; ! } ! } } // else m_bShowTrackInfo=false; --- 2306,2312 ---- if (OVERLAY_STANDARD == g_playerSettings.dwOverlayMode) { ! if (m_pMediaPlayer->IsPlaying() && !m_pMediaPlayer->HasVideo()) { ! ShowTrackInfo(24,30); } // else m_bShowTrackInfo=false; |
From: <yu...@us...> - 2003-10-25 02:54:15
|
Update of /cvsroot/xbplayer/XBMP In directory sc8-pr-cvs1:/tmp/cvs-serv25367 Modified Files: MoviePlayer.cpp Log Message: Fixed to link XBMP properly "out of the box" Index: MoviePlayer.cpp =================================================================== RCS file: /cvsroot/xbplayer/XBMP/MoviePlayer.cpp,v retrieving revision 1.226 retrieving revision 1.227 diff -C2 -d -r1.226 -r1.227 *** MoviePlayer.cpp 23 Sep 2003 07:24:04 -0000 1.226 --- MoviePlayer.cpp 25 Oct 2003 02:48:08 -0000 1.227 *************** *** 175,178 **** --- 175,180 ---- #pragma comment (lib,"mplayer/libmad.lib") #pragma comment (lib,"lib/xbfilezillad.lib") + #pragma comment (lib,"tvguide/debug/tvguide.lib") + #pragma comment (lib,"libgoahead/debug/libgoahead.lib") #pragma comment (lib,"libshout/debug/libshoutd.lib") #pragma comment (lib,"mplayer/liba52d.lib") *************** *** 201,204 **** --- 203,208 ---- #pragma comment (lib,"mplayer/libmad.lib") #pragma comment (lib,"lib/xbfilezilla.lib") + #pragma comment (lib,"tvguide/release/tvguide.lib") + #pragma comment (lib,"libgoahead/release/libgoahead.lib") #pragma comment (lib,"libshout/release/libshout.lib") #pragma comment (lib,"mplayer/liba52.lib") |
From: <mon...@us...> - 2003-10-19 20:32:24
|
Update of /cvsroot/xbplayer/XBMP/mplayer In directory sc8-pr-cvs1:/tmp/cvs-serv19111/mplayer Modified Files: liba52.lib Log Message: liba52ver0.7.4 with Xbox customized resample programm Index: liba52.lib =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayer/liba52.lib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsp6uQf2 and /tmp/cvs24wfcW differ |
From: <mon...@us...> - 2003-10-19 19:26:07
|
Update of /cvsroot/xbplayer/XBMP/mplayer In directory sc8-pr-cvs1:/tmp/cvs-serv19781/mplayer Modified Files: liba52d.lib Log Message: liba52ver0.7.4 with Xbox customized resample programm Index: liba52d.lib =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayer/liba52d.lib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvslxkZ5J and /tmp/cvs0hveij differ |
From: <mon...@us...> - 2003-10-19 19:25:57
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/motion/x86_asm In directory sc8-pr-cvs1:/tmp/cvs-serv7364/x86_asm Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/motion/x86_asm added to the repository |
From: <mon...@us...> - 2003-10-19 19:24:58
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/utils/x86_asm In directory sc8-pr-cvs1:/tmp/cvs-serv7495/x86_asm Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/utils/x86_asm added to the repository |
From: <mon...@us...> - 2003-10-19 18:52:33
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/dct In directory sc8-pr-cvs1:/tmp/cvs-serv7163/dct Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/dct added to the repository |
From: <mon...@us...> - 2003-10-19 18:52:33
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/mesh In directory sc8-pr-cvs1:/tmp/cvs-serv7163/mesh Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/mesh added to the repository |
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/quant In directory sc8-pr-cvs1:/tmp/cvs-serv7893/mplayerlibs/xvidcore/src/quant Added Files: adapt_quant.c adapt_quant.h quant_h263.c quant_h263.h quant_matrix.c quant_matrix.h quant_mpeg4.c quant_mpeg4.h Log Message: Xvid latest CVS 2003-10-17 --- NEW FILE: adapt_quant.c --- #include "../portab.h" #include "../global.h" #include "adapt_quant.h" #include <stdlib.h> /* free, malloc */ #define RDIFF(a,b) ((int)(a+0.5)-(int)(b+0.5)) int normalize_quantizer_field(float *in, int *out, int num, int min_quant, int max_quant) { int i; int finished; do { finished = 1; for (i = 1; i < num; i++) { if (RDIFF(in[i], in[i - 1]) > 2) { in[i] -= (float) 0.5; finished = 0; } else if (RDIFF(in[i], in[i - 1]) < -2) { in[i - 1] -= (float) 0.5; finished = 0; } if (in[i] > max_quant) { in[i] = (float) max_quant; finished = 0; } if (in[i] < min_quant) { in[i] = (float) min_quant; finished = 0; } if (in[i - 1] > max_quant) { in[i - 1] = (float) max_quant; finished = 0; } if (in[i - 1] < min_quant) { in[i - 1] = (float) min_quant; finished = 0; } } } while (!finished); out[0] = 0; for (i = 1; i < num; i++) out[i] = RDIFF(in[i], in[i - 1]); return (int) (in[0] + 0.5); } int adaptive_quantization(unsigned char *buf, int stride, int *intquant, int framequant, int min_quant, int max_quant, int mb_width, int mb_height) // no qstride because normalization { int i, j, k, l; float *quant; unsigned char *ptr; float *val; float global = 0.; uint32_t mid_range = 0; const float DarkAmpl = 14 / 2; const float BrightAmpl = 10 / 2; const float DarkThres = 70; const float BrightThres = 200; const float GlobalDarkThres = 60; const float GlobalBrightThres = 170; const float MidRangeThres = 20; const float UpperLimit = 200; const float LowerLimit = 25; if (!(quant = (float *) malloc(mb_width * mb_height * sizeof(float)))) return(-1); if(!(val = (float *) malloc(mb_width * mb_height * sizeof(float)))) return(-1); for (k = 0; k < mb_height; k++) { for (l = 0; l < mb_width; l++) // do this for all macroblocks individually { quant[k * mb_width + l] = (float) framequant; // calculate luminance-masking ptr = &buf[16 * k * stride + 16 * l]; // address of MB val[k * mb_width + l] = 0.; for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) val[k * mb_width + l] += ptr[i * stride + j]; val[k * mb_width + l] /= 256.; global +=val[k * mb_width + l]; if ((val[k * mb_width + l] > LowerLimit) && (val[k * mb_width + l] < UpperLimit)) mid_range++; } } global /=mb_width * mb_height; if (((global <GlobalBrightThres) &&(global >GlobalDarkThres)) || (mid_range < MidRangeThres)) { for (k = 0; k < mb_height; k++) { for (l = 0; l < mb_width; l++) // do this for all macroblocks individually { if (val[k * mb_width + l] < DarkThres) quant[k * mb_width + l] += DarkAmpl * (DarkThres - val[k * mb_width + l]) / DarkThres; else if (val[k * mb_width + l] > BrightThres) quant[k * mb_width + l] += BrightAmpl * (val[k * mb_width + l] - BrightThres) / (255 - BrightThres); } } } i = normalize_quantizer_field(quant, intquant, mb_width * mb_height, min_quant, max_quant); free(val); free(quant); return(i); } --- NEW FILE: adapt_quant.h --- #ifndef _ADAPT_QUANT_H_ #define _ADAPT_QUANT_H_ int adaptive_quantization(unsigned char *buf, int stride, int *intquant, int framequant, int min_quant, int max_quant, int mb_width, int mb_height); // no qstride because normalization #endif /* _ADAPT_QUANT_H_ */ --- NEW FILE: quant_h263.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * quantization/dequantization * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /************************************************************************** * * History: * * 26.12.2001 dequant_inter bug fix * 22.12.2001 clamp dequant output to [-2048,2047] * 19.11.2001 quant_inter now returns sum of abs. coefficient values * 02.11.2001 added const to function args <pr...@cs...> * 28.10.2001 total rewrite <pr...@cs...> * *************************************************************************/ #include "../global.h" #include "quant_h263.h" /* mutliply+shift division table */ #define SCALEBITS 16 #define FIX(X) ((1L << SCALEBITS) / (X) + 1) static const uint32_t multipliers[32] = { 0, FIX(2), FIX(4), FIX(6), FIX(8), FIX(10), FIX(12), FIX(14), FIX(16), FIX(18), FIX(20), FIX(22), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(34), FIX(36), FIX(38), FIX(40), FIX(42), FIX(44), FIX(46), FIX(48), FIX(50), FIX(52), FIX(54), FIX(56), FIX(58), FIX(60), FIX(62) }; // function pointers quanth263_intraFuncPtr quant_intra; quanth263_intraFuncPtr dequant_intra; quanth263_interFuncPtr quant_inter; dequanth263_interFuncPtr dequant_inter; /* quantize intra-block */ void quant_intra_c(int16_t * coeff, const int16_t * data, const uint32_t quant, const uint32_t dcscalar) { const uint32_t mult = multipliers[quant]; const uint16_t quant_m_2 = quant << 1; uint32_t i; coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar); for (i = 1; i < 64; i++) { int16_t acLevel = data[i]; if (acLevel < 0) { acLevel = -acLevel; if (acLevel < quant_m_2) { coeff[i] = 0; continue; } acLevel = (acLevel * mult) >> SCALEBITS; coeff[i] = -acLevel; } else { if (acLevel < quant_m_2) { coeff[i] = 0; continue; } acLevel = (acLevel * mult) >> SCALEBITS; coeff[i] = acLevel; } } } /* quantize inter-block */ uint32_t quant_inter_c(int16_t * coeff, const int16_t * data, const uint32_t quant) { const uint32_t mult = multipliers[quant]; const uint16_t quant_m_2 = quant << 1; const uint16_t quant_d_2 = quant >> 1; int sum = 0; uint32_t i; for (i = 0; i < 64; i++) { int16_t acLevel = data[i]; if (acLevel < 0) { acLevel = (-acLevel) - quant_d_2; if (acLevel < quant_m_2) { coeff[i] = 0; continue; } acLevel = (acLevel * mult) >> SCALEBITS; sum += acLevel; // sum += |acLevel| coeff[i] = -acLevel; } else { acLevel -= quant_d_2; if (acLevel < quant_m_2) { coeff[i] = 0; continue; } acLevel = (acLevel * mult) >> SCALEBITS; sum += acLevel; coeff[i] = acLevel; } } return sum; } /* dequantize intra-block & clamp to [-2048,2047] */ void dequant_intra_c(int16_t * data, const int16_t * coeff, const uint32_t quant, const uint32_t dcscalar) { const int32_t quant_m_2 = quant << 1; const int32_t quant_add = (quant & 1 ? quant : quant - 1); uint32_t i; data[0] = coeff[0] * dcscalar; if (data[0] < -2048) { data[0] = -2048; } else if (data[0] > 2047) { data[0] = 2047; } for (i = 1; i < 64; i++) { int32_t acLevel = coeff[i]; if (acLevel == 0) { data[i] = 0; } else if (acLevel < 0) { acLevel = quant_m_2 * -acLevel + quant_add; data[i] = (acLevel <= 2048 ? -acLevel : -2048); } else // if (acLevel > 0) { { acLevel = quant_m_2 * acLevel + quant_add; data[i] = (acLevel <= 2047 ? acLevel : 2047); } } } /* dequantize inter-block & clamp to [-2048,2047] */ void dequant_inter_c(int16_t * data, const int16_t * coeff, const uint32_t quant) { const uint16_t quant_m_2 = quant << 1; const uint16_t quant_add = (quant & 1 ? quant : quant - 1); uint32_t i; for (i = 0; i < 64; i++) { int16_t acLevel = coeff[i]; if (acLevel == 0) { data[i] = 0; } else if (acLevel < 0) { acLevel = acLevel * quant_m_2 - quant_add; data[i] = (acLevel >= -2048 ? acLevel : -2048); } else // if (acLevel > 0) { acLevel = acLevel * quant_m_2 + quant_add; data[i] = (acLevel <= 2047 ? acLevel : 2047); } } } --- NEW FILE: quant_h263.h --- #ifndef _QUANT_H263_H_ #define _QUANT_H263_H_ #include "../portab.h" // intra typedef void (quanth263_intraFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant, const uint32_t dcscalar); typedef quanth263_intraFunc *quanth263_intraFuncPtr; extern quanth263_intraFuncPtr quant_intra; extern quanth263_intraFuncPtr dequant_intra; quanth263_intraFunc quant_intra_c; quanth263_intraFunc quant_intra_mmx; quanth263_intraFunc quant_intra_3dne; quanth263_intraFunc quant_intra_sse2; quanth263_intraFunc quant_intra_ia64; quanth263_intraFunc dequant_intra_c; quanth263_intraFunc dequant_intra_mmx; quanth263_intraFunc dequant_intra_xmm; quanth263_intraFunc dequant_intra_3dne; quanth263_intraFunc dequant_intra_sse2; quanth263_intraFunc dequant_intra_ia64; // inter_quant typedef uint32_t(quanth263_interFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant); typedef quanth263_interFunc *quanth263_interFuncPtr; extern quanth263_interFuncPtr quant_inter; quanth263_interFunc quant_inter_c; quanth263_interFunc quant_inter_mmx; quanth263_interFunc quant_inter_3dne; quanth263_interFunc quant_inter_sse2; quanth263_interFunc quant_inter_ia64; //inter_dequant typedef void (dequanth263_interFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant); typedef dequanth263_interFunc *dequanth263_interFuncPtr; extern dequanth263_interFuncPtr dequant_inter; dequanth263_interFunc dequant_inter_c; dequanth263_interFunc dequant_inter_mmx; dequanth263_interFunc dequant_inter_xmm; dequanth263_interFunc dequant_inter_3dne; dequanth263_interFunc dequant_inter_sse2; dequanth263_interFunc dequant_inter_ia64; #endif /* _QUANT_H263_H_ */ --- NEW FILE: quant_matrix.c --- #include "quant_matrix.h" #define FIX(X) (((X)==1) ? 0xFFFF : ((1UL << 16) / (X) + 1)) #define FIXL(X) ((1UL << 16) / (X) - 1) uint8_t custom_intra_matrix = 0; uint8_t custom_inter_matrix = 0; uint8_t default_intra_matrix[64] = { 8, 17, 18, 19, 21, 23, 25, 27, 17, 18, 19, 21, 23, 25, 27, 28, 20, 21, 22, 23, 24, 26, 28, 30, 21, 22, 23, 24, 26, 28, 30, 32, 22, 23, 24, 26, 28, 30, 32, 35, 23, 24, 26, 28, 30, 32, 35, 38, 25, 26, 28, 30, 32, 35, 38, 41, 27, 28, 30, 32, 35, 38, 41, 45 }; int16_t intra_matrix[64] = { 8, 17, 18, 19, 21, 23, 25, 27, 17, 18, 19, 21, 23, 25, 27, 28, 20, 21, 22, 23, 24, 26, 28, 30, 21, 22, 23, 24, 26, 28, 30, 32, 22, 23, 24, 26, 28, 30, 32, 35, 23, 24, 26, 28, 30, 32, 35, 38, 25, 26, 28, 30, 32, 35, 38, 41, 27, 28, 30, 32, 35, 38, 41, 45 }; uint16_t intra_matrix_fixfix[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint16_t inter_matrix_fixfix[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint16_t intra_matrix1[64] = { 8>>1, 17>>1, 18>>1, 19>>1, 21>>1, 23>>1, 25>>1, 27>>1, 17>>1, 18>>1, 19>>1, 21>>1, 23>>1, 25>>1, 27>>1, 28>>1, 20>>1, 21>>1, 22>>1, 23>>1, 24>>1, 26>>1, 28>>1, 30>>1, 21>>1, 22>>1, 23>>1, 24>>1, 26>>1, 28>>1, 30>>1, 32>>1, 22>>1, 23>>1, 24>>1, 26>>1, 28>>1, 30>>1, 32>>1, 35>>1, 23>>1, 24>>1, 26>>1, 28>>1, 30>>1, 32>>1, 35>>1, 38>>1, 25>>1, 26>>1, 28>>1, 30>>1, 32>>1, 35>>1, 38>>1, 41>>1, 27>>1, 28>>1, 30>>1, 32>>1, 35>>1, 38>>1, 41>>1, 45>>1 }; uint16_t intra_matrix_fix[64] = { FIX(8), FIX(17), FIX(18), FIX(19), FIX(21), FIX(23), FIX(25), FIX(27), FIX(17), FIX(18), FIX(19), FIX(21), FIX(23), FIX(25), FIX(27), FIX(28), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38), FIX(25), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38), FIX(41), FIX(27), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38), FIX(41), FIX(45) }; uint16_t intra_matrix_fixl[64] = { FIXL(8), FIXL(17), FIXL(18), FIXL(19), FIXL(21), FIXL(23), FIXL(25), FIXL(27), FIXL(17), FIXL(18), FIXL(19), FIXL(21), FIXL(23), FIXL(25), FIXL(27), FIXL(28), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(28), FIXL(30), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(28), FIXL(30), FIXL(32), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(28), FIXL(30), FIXL(32), FIXL(35), FIXL(23), FIXL(24), FIXL(26), FIXL(28), FIXL(30), FIXL(32), FIXL(35), FIXL(38), FIXL(25), FIXL(26), FIXL(28), FIXL(30), FIXL(32), FIXL(35), FIXL(38), FIXL(41), FIXL(27), FIXL(28), FIXL(30), FIXL(32), FIXL(35), FIXL(38), FIXL(41), FIXL(45) }; uint16_t inter_matrix_fixl[64] = { FIXL(16), FIXL(17), FIXL(18), FIXL(19), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(17), FIXL(18), FIXL(19), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(18), FIXL(19), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(25), FIXL(19), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(27), FIXL(20), FIXL(21), FIXL(22), FIXL(23), FIXL(25), FIXL(26), FIXL(27), FIXL(28), FIXL(21), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(27), FIXL(28), FIXL(30), FIXL(22), FIXL(23), FIXL(24), FIXL(26), FIXL(27), FIXL(28), FIXL(30), FIXL(31), FIXL(23), FIXL(24), FIXL(25), FIXL(27), FIXL(28), FIXL(30), FIXL(31), FIXL(33) }; uint8_t default_inter_matrix[64] = { 16, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, 24, 25, 19, 20, 21, 22, 23, 24, 26, 27, 20, 21, 22, 23, 25, 26, 27, 28, 21, 22, 23, 24, 26, 27, 28, 30, 22, 23, 24, 26, 27, 28, 30, 31, 23, 24, 25, 27, 28, 30, 31, 33 }; int16_t inter_matrix[64] = { 16, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, 24, 25, 19, 20, 21, 22, 23, 24, 26, 27, 20, 21, 22, 23, 25, 26, 27, 28, 21, 22, 23, 24, 26, 27, 28, 30, 22, 23, 24, 26, 27, 28, 30, 31, 23, 24, 25, 27, 28, 30, 31, 33 }; uint16_t inter_matrix1[64] = { 16>>1, 17>>1, 18>>1, 19>>1, 20>>1, 21>>1, 22>>1, 23>>1, 17>>1, 18>>1, 19>>1, 20>>1, 21>>1, 22>>1, 23>>1, 24>>1, 18>>1, 19>>1, 20>>1, 21>>1, 22>>1, 23>>1, 24>>1, 25>>1, 19>>1, 20>>1, 21>>1, 22>>1, 23>>1, 24>>1, 26>>1, 27>>1, 20>>1, 21>>1, 22>>1, 23>>1, 25>>1, 26>>1, 27>>1, 28>>1, 21>>1, 22>>1, 23>>1, 24>>1, 26>>1, 27>>1, 28>>1, 30>>1, 22>>1, 23>>1, 24>>1, 26>>1, 27>>1, 28>>1, 30>>1, 31>>1, 23>>1, 24>>1, 25>>1, 27>>1, 28>>1, 30>>1, 31>>1, 33>>1 }; uint16_t inter_matrix_fix[64] = { FIX(16), FIX(17), FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(17), FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(25), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(27), FIX(20), FIX(21), FIX(22), FIX(23), FIX(25), FIX(26), FIX(27), FIX(28), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(27), FIX(28), FIX(30), FIX(22), FIX(23), FIX(24), FIX(26), FIX(27), FIX(28), FIX(30), FIX(31), FIX(23), FIX(24), FIX(25), FIX(27), FIX(28), FIX(30), FIX(31), FIX(33) }; uint8_t get_intra_matrix_status(void) { return custom_intra_matrix; } uint8_t get_inter_matrix_status(void) { return custom_inter_matrix; } void set_intra_matrix_status(uint8_t status) { custom_intra_matrix = status; } void set_inter_matrix_status(uint8_t status) { custom_inter_matrix = status; } int16_t * get_intra_matrix(void) { return intra_matrix; } int16_t * get_inter_matrix(void) { return inter_matrix; } uint8_t * get_default_intra_matrix(void) { return default_intra_matrix; } uint8_t * get_default_inter_matrix(void) { return default_inter_matrix; } uint8_t set_intra_matrix(uint8_t * matrix) { int i, change = 0; custom_intra_matrix = 0; for (i = 0; i < 64; i++) { if ((int16_t) default_intra_matrix[i] != matrix[i]) custom_intra_matrix = 1; if (intra_matrix[i] != matrix[i]) change = 1; intra_matrix1[i] = ((intra_matrix[i] = (int16_t) matrix[i])>>1); intra_matrix1[i] += ((intra_matrix[i] == 1) ? 1: 0); intra_matrix_fix[i] = FIX(intra_matrix[i]); intra_matrix_fixl[i] = FIXL(intra_matrix[i]); } return custom_intra_matrix | change; } uint8_t set_inter_matrix(uint8_t * matrix) { int i, change = 0; custom_inter_matrix = 0; for (i = 0; i < 64; i++) { if ((int16_t) default_inter_matrix[i] != matrix[i]) custom_inter_matrix = 1; if (inter_matrix[i] != matrix[i]) change = 1; inter_matrix1[i] = ((inter_matrix[i] = (int16_t) matrix[i])>>1); inter_matrix1[i] += ((inter_matrix[i] == 1) ? 1: 0); inter_matrix_fix[i] = FIX(inter_matrix[i]); inter_matrix_fixl[i] = FIXL(inter_matrix[i]); } return custom_inter_matrix | change; } --- NEW FILE: quant_matrix.h --- #ifndef _QUANT_MATRIX_H_ #define _QUANT_MATRIX_H_ #include "../portab.h" uint8_t get_intra_matrix_status(void); uint8_t get_inter_matrix_status(void); void set_intra_matrix_status(uint8_t status); void set_inter_matrix_status(uint8_t status); uint8_t set_intra_matrix(uint8_t * matrix); uint8_t set_inter_matrix(uint8_t * matrix); int16_t *get_intra_matrix(void); int16_t *get_inter_matrix(void); uint8_t *get_default_intra_matrix(void); uint8_t *get_default_inter_matrix(void); #endif /* _QUANT_MATRIX_H_ */ --- NEW FILE: quant_mpeg4.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * mpeg-4 quantization/dequantization * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /************************************************************************** * * History: * * 26.01.2002 fixed quant4_intra dcscalar signed/unsigned error * 20.01.2002 increased accuracy of >> divide * 26.12.2001 divide-by-multiplication optimization * 22.12.2001 [-127,127] clamping removed; minor tweaks * 19.11.2001 inital version <pr...@cs...> * *************************************************************************/ #include "../global.h" #include "quant_mpeg4.h" #include "quant_matrix.h" // function pointers quant_intraFuncPtr quant4_intra; quant_intraFuncPtr dequant4_intra; dequant_interFuncPtr dequant4_inter; quant_interFuncPtr quant4_inter; #define VM18P 3 #define VM18Q 4 // divide-by-multiply table // need 17 bit shift (16 causes slight errors when q > 19) #define SCALEBITS 17 #define FIX(X) ((1UL << SCALEBITS) / (X) + 1) static const uint32_t multipliers[32] = { 0, FIX(2), FIX(4), FIX(6), FIX(8), FIX(10), FIX(12), FIX(14), FIX(16), FIX(18), FIX(20), FIX(22), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(34), FIX(36), FIX(38), FIX(40), FIX(42), FIX(44), FIX(46), FIX(48), FIX(50), FIX(52), FIX(54), FIX(56), FIX(58), FIX(60), FIX(62) }; /* quantize intra-block // const int32_t quantd = DIV_DIV(VM18P*quant, VM18Q); // // level = DIV_DIV(16 * data[i], default_intra_matrix[i]); // coeff[i] = (level + quantd) / quant2; */ void quant4_intra_c(int16_t * coeff, const int16_t * data, const uint32_t quant, const uint32_t dcscalar) { const uint32_t quantd = ((VM18P * quant) + (VM18Q / 2)) / VM18Q; const uint32_t mult = multipliers[quant]; uint32_t i; int16_t *intra_matrix; intra_matrix = get_intra_matrix(); coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar); for (i = 1; i < 64; i++) { if (data[i] < 0) { uint32_t level = -data[i]; level = ((level << 4) + (intra_matrix[i] >> 1)) / intra_matrix[i]; level = ((level + quantd) * mult) >> 17; coeff[i] = -(int16_t) level; } else if (data[i] > 0) { uint32_t level = data[i]; level = ((level << 4) + (intra_matrix[i] >> 1)) / intra_matrix[i]; level = ((level + quantd) * mult) >> 17; coeff[i] = level; } else { coeff[i] = 0; } } } /* dequantize intra-block & clamp to [-2048,2047] // data[i] = (coeff[i] * default_intra_matrix[i] * quant2) >> 4; */ void dequant4_intra_c(int16_t * data, const int16_t * coeff, const uint32_t quant, const uint32_t dcscalar) { uint32_t i; int16_t *intra_matrix; intra_matrix = get_intra_matrix(); data[0] = coeff[0] * dcscalar; if (data[0] < -2048) { data[0] = -2048; } else if (data[0] > 2047) { data[0] = 2047; } for (i = 1; i < 64; i++) { if (coeff[i] == 0) { data[i] = 0; } else if (coeff[i] < 0) { uint32_t level = -coeff[i]; level = (level * intra_matrix[i] * quant) >> 3; data[i] = (level <= 2048 ? -(int16_t) level : -2048); } else // if (coeff[i] > 0) { uint32_t level = coeff[i]; level = (level * intra_matrix[i] * quant) >> 3; data[i] = (level <= 2047 ? level : 2047); } } } /* quantize inter-block // level = DIV_DIV(16 * data[i], default_intra_matrix[i]); // coeff[i] = (level + quantd) / quant2; // sum += abs(level); */ uint32_t quant4_inter_c(int16_t * coeff, const int16_t * data, const uint32_t quant) { const uint32_t mult = multipliers[quant]; uint32_t sum = 0; uint32_t i; int16_t *inter_matrix; inter_matrix = get_inter_matrix(); for (i = 0; i < 64; i++) { if (data[i] < 0) { uint32_t level = -data[i]; level = ((level << 4) + (inter_matrix[i] >> 1)) / inter_matrix[i]; level = (level * mult) >> 17; sum += level; coeff[i] = -(int16_t) level; } else if (data[i] > 0) { uint32_t level = data[i]; level = ((level << 4) + (inter_matrix[i] >> 1)) / inter_matrix[i]; level = (level * mult) >> 17; sum += level; coeff[i] = level; } else { coeff[i] = 0; } } return sum; } /* dequantize inter-block & clamp to [-2048,2047] data = ((2 * coeff + SIGN(coeff)) * inter_matrix[i] * quant) / 16 */ void dequant4_inter_c(int16_t * data, const int16_t * coeff, const uint32_t quant) { uint32_t sum = 0; uint32_t i; int16_t *inter_matrix; inter_matrix = get_inter_matrix(); for (i = 0; i < 64; i++) { if (coeff[i] == 0) { data[i] = 0; } else if (coeff[i] < 0) { int32_t level = -coeff[i]; level = ((2 * level + 1) * inter_matrix[i] * quant) >> 4; data[i] = (level <= 2048 ? -level : -2048); } else // if (coeff[i] > 0) { uint32_t level = coeff[i]; level = ((2 * level + 1) * inter_matrix[i] * quant) >> 4; data[i] = (level <= 2047 ? level : 2047); } sum ^= data[i]; } // mismatch control if ((sum & 1) == 0) { data[63] ^= 1; } } --- NEW FILE: quant_mpeg4.h --- #ifndef _QUANT_MPEG4_H_ #define _QUANT_MPEG4_H_ #include "../portab.h" // intra typedef void (quant_intraFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant, const uint32_t dcscalar); typedef quant_intraFunc *quant_intraFuncPtr; extern quant_intraFuncPtr quant4_intra; extern quant_intraFuncPtr dequant4_intra; quant_intraFunc quant4_intra_c; quant_intraFunc quant4_intra_mmx; quant_intraFunc quant4_intra_xmm; quant_intraFunc dequant4_intra_c; quant_intraFunc dequant4_intra_mmx; quant_intraFunc dequant4_intra_3dne; // inter_quant typedef uint32_t(quant_interFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant); typedef quant_interFunc *quant_interFuncPtr; extern quant_interFuncPtr quant4_inter; quant_interFunc quant4_inter_c; quant_interFunc quant4_inter_mmx; quant_interFunc quant4_inter_xmm; //inter_dequant typedef void (dequant_interFunc) (int16_t * coeff, const int16_t * data, const uint32_t quant); typedef dequant_interFunc *dequant_interFuncPtr; extern dequant_interFuncPtr dequant4_inter; dequant_interFunc dequant4_inter_c; dequant_interFunc dequant4_inter_mmx; dequant_interFunc dequant4_inter_3dne; #endif /* _QUANT_MPEG4_H_ */ |
From: <mon...@us...> - 2003-10-19 18:52:00
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/build In directory sc8-pr-cvs1:/tmp/cvs-serv6292/build Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/build added to the repository |
From: <mon...@us...> - 2003-10-19 18:51:45
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/quant/x86_asm In directory sc8-pr-cvs1:/tmp/cvs-serv7438/x86_asm Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/quant/x86_asm added to the repository |
From: <mon...@us...> - 2003-10-19 18:33:58
|
Update of /cvsroot/xbplayer/XBMP/mplayer In directory sc8-pr-cvs1:/tmp/cvs-serv18483/mplayer Modified Files: libxvidcore.lib Log Message: Xvid latest CVS 2003-10-17 Index: libxvidcore.lib =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayer/libxvidcore.lib,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 Binary files /tmp/cvsLZg60K and /tmp/cvsgsvFrq differ |
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/image In directory sc8-pr-cvs1:/tmp/cvs-serv7893/mplayerlibs/xvidcore/src/image Added Files: colorspace.c colorspace.h font.c font.h image.c image.h interpolate8x8.c interpolate8x8.h reduced.c reduced.h Log Message: Xvid latest CVS 2003-10-17 --- NEW FILE: colorspace.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * colorspace conversions * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /************************************************************************** * * History: * * 14.04.2002 added user_to_yuv_c() * 30.02.2002 out_yuv dst_stride2 fix * 26.02.2002 rgb555, rgb565 * 24.11.2001 accuracy improvement to yuyv/vyuy conversion * 28.10.2001 total rewrite <pr...@cs...> * **************************************************************************/ #include <string.h> // memcpy #include "../global.h" #include "../divx4.h" // DEC_PICTURE #include "colorspace.h" // function pointers /* input */ packedFuncPtr rgb555_to_yv12; packedFuncPtr rgb565_to_yv12; packedFuncPtr bgr_to_yv12; packedFuncPtr bgra_to_yv12; packedFuncPtr abgr_to_yv12; packedFuncPtr rgba_to_yv12; packedFuncPtr yuv_to_yv12; packedFuncPtr yuyv_to_yv12; packedFuncPtr uyvy_to_yv12; packedFuncPtr rgb555i_to_yv12; packedFuncPtr rgb565i_to_yv12; packedFuncPtr bgri_to_yv12; packedFuncPtr bgrai_to_yv12; packedFuncPtr abgri_to_yv12; packedFuncPtr rgbai_to_yv12; packedFuncPtr yuyvi_to_yv12; packedFuncPtr uyvyi_to_yv12; /* output */ packedFuncPtr yv12_to_rgb555; packedFuncPtr yv12_to_rgb565; packedFuncPtr yv12_to_bgr; packedFuncPtr yv12_to_bgra; packedFuncPtr yv12_to_abgr; packedFuncPtr yv12_to_rgba; packedFuncPtr yv12_to_yuv; packedFuncPtr yv12_to_yuyv; packedFuncPtr yv12_to_uyvy; packedFuncPtr yv12_to_rgb555i; packedFuncPtr yv12_to_rgb565i; packedFuncPtr yv12_to_bgri; packedFuncPtr yv12_to_bgrai; packedFuncPtr yv12_to_abgri; packedFuncPtr yv12_to_rgbai; packedFuncPtr yv12_to_yuyvi; packedFuncPtr yv12_to_uyvyi; planarFuncPtr yv12_to_yv12; int32_t RGB_Y_tab[256]; int32_t B_U_tab[256]; int32_t G_U_tab[256]; int32_t G_V_tab[256]; int32_t R_V_tab[256]; /********** generic colorspace macro **********/ #define MAKE_COLORSPACE(NAME,SIZE,PIXELS,VPIXELS,FUNC,C1,C2,C3,C4) \ void \ NAME(uint8_t * x_ptr, int x_stride, \ uint8_t * y_ptr, uint8_t * u_ptr, uint8_t * v_ptr, \ int y_stride, int uv_stride, \ int width, int height, int vflip) \ { \ int fixed_width = (width + 1) & ~1; \ int x_dif = x_stride - (SIZE)*fixed_width; \ int y_dif = y_stride - fixed_width; \ int uv_dif = uv_stride - (fixed_width / 2); \ int x, y; \ if (vflip) { \ x_ptr += (height - 1) * x_stride; \ x_dif = -(SIZE)*fixed_width - x_stride; \ x_stride = -x_stride; \ } \ for (y = 0; y < height; y+=(VPIXELS)) { \ FUNC##_ROW(SIZE,C1,C2,C3,C4); \ for (x = 0; x < fixed_width; x+=(PIXELS)) { \ FUNC(SIZE,C1,C2,C3,C4); \ x_ptr += (PIXELS)*(SIZE); \ y_ptr += (PIXELS); \ u_ptr += (PIXELS)/2; \ v_ptr += (PIXELS)/2; \ } \ x_ptr += x_dif + (VPIXELS-1)*x_stride; \ y_ptr += y_dif + (VPIXELS-1)*y_stride; \ u_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride; \ v_ptr += uv_dif + ((VPIXELS/2)-1)*uv_stride; \ } \ } /********** colorspace input (xxx_to_yv12) functions **********/ /* rgb -> yuv def's this following constants are "official spec" Video Demystified" (ISBN 1-878707-09-4) rgb<->yuv _is_ lossy, since most programs do the conversion differently SCALEBITS/FIX taken from ffmpeg */ #define Y_R_IN 0.257 #define Y_G_IN 0.504 #define Y_B_IN 0.098 #define Y_ADD_IN 16 #define U_R_IN 0.148 #define U_G_IN 0.291 #define U_B_IN 0.439 #define U_ADD_IN 128 #define V_R_IN 0.439 #define V_G_IN 0.368 #define V_B_IN 0.071 #define V_ADD_IN 128 #define SCALEBITS_IN 8 #define FIX_IN(x) ((uint16_t) ((x) * (1L<<SCALEBITS_IN) + 0.5)) /* rgb16/rgb16i input */ #define MK_RGB555_B(RGB) ((RGB) << 3) & 0xf8 #define MK_RGB555_G(RGB) ((RGB) >> 2) & 0xf8 #define MK_RGB555_R(RGB) ((RGB) >> 7) & 0xf8 #define MK_RGB565_B(RGB) ((RGB) << 3) & 0xf8 #define MK_RGB565_G(RGB) ((RGB) >> 3) & 0xfc #define MK_RGB565_R(RGB) ((RGB) >> 8) & 0xf8 #define READ_RGB16_Y(ROW, UVID, C1,C2,C3,C4) \ rgb = *(uint16_t *) (x_ptr + ((ROW)*x_stride) + 0); \ b##UVID += b = C1##_B(rgb); \ g##UVID += g = C1##_G(rgb); \ r##UVID += r = C1##_R(rgb); \ y_ptr[(ROW)*y_stride+0] = \ (uint8_t) ((FIX_IN(Y_R_IN) * r + FIX_IN(Y_G_IN) * g + \ FIX_IN(Y_B_IN) * b) >> SCALEBITS_IN) + Y_ADD_IN; \ rgb = *(uint16_t *) (x_ptr + ((ROW)*x_stride) + 2); \ b##UVID += b = C1##_B(rgb); \ g##UVID += g = C1##_G(rgb); \ r##UVID += r = C1##_R(rgb); \ y_ptr[(ROW)*y_stride+1] = \ (uint8_t) ((FIX_IN(Y_R_IN) * r + FIX_IN(Y_G_IN) * g + \ FIX_IN(Y_B_IN) * b) >> SCALEBITS_IN) + Y_ADD_IN; #define READ_RGB16_UV(UV_ROW,UVID) \ u_ptr[(UV_ROW)*uv_stride] = \ (uint8_t) ((-FIX_IN(U_R_IN) * r##UVID - FIX_IN(U_G_IN) * g##UVID + \ FIX_IN(U_B_IN) * b##UVID) >> (SCALEBITS_IN + 2)) + U_ADD_IN; \ v_ptr[(UV_ROW)*uv_stride] = \ (uint8_t) ((FIX_IN(V_R_IN) * r##UVID - FIX_IN(V_G_IN) * g##UVID - \ FIX_IN(V_B_IN) * b##UVID) >> (SCALEBITS_IN + 2)) + V_ADD_IN; #define RGB16_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define RGB16_TO_YV12(SIZE,C1,C2,C3,C4) \ uint32_t rgb, r, g, b, r0, g0, b0; \ r0 = g0 = b0 = 0; \ READ_RGB16_Y (0, 0, C1,C2,C3,C4) \ READ_RGB16_Y (1, 0, C1,C2,C3,C4) \ READ_RGB16_UV(0, 0) #define RGB16I_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define RGB16I_TO_YV12(SIZE,C1,C2,C3,C4) \ uint32_t rgb, r, g, b, r0, g0, b0, r1, g1, b1; \ r0 = g0 = b0 = r1 = g1 = b1 = 0; \ READ_RGB16_Y (0, 0, C1,C2,C3,C4) \ READ_RGB16_Y (1, 1, C1,C2,C3,C4) \ READ_RGB16_Y (2, 0, C1,C2,C3,C4) \ READ_RGB16_Y (3, 1, C1,C2,C3,C4) \ READ_RGB16_UV(0, 0) \ READ_RGB16_UV(1, 1) /* rgb/rgbi input */ #define READ_RGB_Y(SIZE, ROW, UVID, C1,C2,C3,C4) \ r##UVID += r = x_ptr[(ROW)*x_stride+(C1)]; \ g##UVID += g = x_ptr[(ROW)*x_stride+(C2)]; \ b##UVID += b = x_ptr[(ROW)*x_stride+(C3)]; \ y_ptr[(ROW)*y_stride+0] = \ (uint8_t) ((FIX_IN(Y_R_IN) * r + FIX_IN(Y_G_IN) * g + \ FIX_IN(Y_B_IN) * b) >> SCALEBITS_IN) + Y_ADD_IN; \ r##UVID += r = x_ptr[(ROW)*x_stride+(SIZE)+(C1)]; \ g##UVID += g = x_ptr[(ROW)*x_stride+(SIZE)+(C2)]; \ b##UVID += b = x_ptr[(ROW)*x_stride+(SIZE)+(C3)]; \ y_ptr[(ROW)*y_stride+1] = \ (uint8_t) ((FIX_IN(Y_R_IN) * r + FIX_IN(Y_G_IN) * g + \ FIX_IN(Y_B_IN) * b) >> SCALEBITS_IN) + Y_ADD_IN; #define READ_RGB_UV(UV_ROW,UVID) \ u_ptr[(UV_ROW)*uv_stride] = \ (uint8_t) ((-FIX_IN(U_R_IN) * r##UVID - FIX_IN(U_G_IN) * g##UVID + \ FIX_IN(U_B_IN) * b##UVID) >> (SCALEBITS_IN + 2)) + U_ADD_IN; \ v_ptr[(UV_ROW)*uv_stride] = \ (uint8_t) ((FIX_IN(V_R_IN) * r##UVID - FIX_IN(V_G_IN) * g##UVID - \ FIX_IN(V_B_IN) * b##UVID) >> (SCALEBITS_IN + 2)) + V_ADD_IN; #define RGB_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define RGB_TO_YV12(SIZE,C1,C2,C3,C4) \ uint32_t r, g, b, r0, g0, b0; \ r0 = g0 = b0 = 0; \ READ_RGB_Y(SIZE, 0, 0, C1,C2,C3,C4) \ READ_RGB_Y(SIZE, 1, 0, C1,C2,C3,C4) \ READ_RGB_UV( 0, 0) #define RGBI_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define RGBI_TO_YV12(SIZE,C1,C2,C3,C4) \ uint32_t r, g, b, r0, g0, b0, r1, g1, b1; \ r0 = g0 = b0 = r1 = g1 = b1 = 0; \ READ_RGB_Y(SIZE, 0, 0, C1,C2,C3,C4) \ READ_RGB_Y(SIZE, 1, 1, C1,C2,C3,C4) \ READ_RGB_Y(SIZE, 2, 0, C1,C2,C3,C4) \ READ_RGB_Y(SIZE, 3, 1, C1,C2,C3,C4) \ READ_RGB_UV( 0, 0) \ READ_RGB_UV( 1, 1) /* yuyv/yuyvi input */ #define READ_YUYV_Y(ROW,C1,C2,C3,C4) \ y_ptr[(ROW)*y_stride+0] = x_ptr[(ROW)*x_stride+(C1)]; \ y_ptr[(ROW)*y_stride+1] = x_ptr[(ROW)*x_stride+(C3)]; #define READ_YUYV_UV(UV_ROW,ROW1,ROW2,C1,C2,C3,C4) \ u_ptr[(UV_ROW)*uv_stride] = (x_ptr[(ROW1)*x_stride+(C2)] + x_ptr[(ROW2)*x_stride+(C2)] + 1) / 2; \ v_ptr[(UV_ROW)*uv_stride] = (x_ptr[(ROW1)*x_stride+(C4)] + x_ptr[(ROW2)*x_stride+(C4)] + 1) / 2; #define YUYV_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define YUYV_TO_YV12(SIZE,C1,C2,C3,C4) \ READ_YUYV_Y (0, C1,C2,C3,C4) \ READ_YUYV_Y (1, C1,C2,C3,C4) \ READ_YUYV_UV(0, 0,1, C1,C2,C3,C4) #define YUYVI_TO_YV12_ROW(SIZE,C1,C2,C3,C4) \ /* nothing */ #define YUYVI_TO_YV12(SIZE,C1,C2,C3,C4) \ READ_YUYV_Y (0, C1,C2,C3,C4) \ READ_YUYV_Y (1, C1,C2,C3,C4) \ READ_YUYV_Y (2, C1,C2,C3,C4) \ READ_YUYV_Y (3, C1,C2,C3,C4) \ READ_YUYV_UV(0, 0,2, C1,C2,C3,C4) \ READ_YUYV_UV(1, 1,3, C1,C2,C3,C4) MAKE_COLORSPACE(rgb555_to_yv12_c, 2,2,2, RGB16_TO_YV12, MK_RGB555, 0,0,0) MAKE_COLORSPACE(rgb565_to_yv12_c, 2,2,2, RGB16_TO_YV12, MK_RGB565, 0,0,0) MAKE_COLORSPACE(bgr_to_yv12_c, 3,2,2, RGB_TO_YV12, 2,1,0, 0) MAKE_COLORSPACE(bgra_to_yv12_c, 4,2,2, RGB_TO_YV12, 2,1,0, 0) MAKE_COLORSPACE(abgr_to_yv12_c, 4,2,2, RGB_TO_YV12, 3,2,1, 0) MAKE_COLORSPACE(rgba_to_yv12_c, 4,2,2, RGB_TO_YV12, 0,1,2, 0) MAKE_COLORSPACE(yuyv_to_yv12_c, 2,2,2, YUYV_TO_YV12, 0,1,2,3) MAKE_COLORSPACE(uyvy_to_yv12_c, 2,2,2, YUYV_TO_YV12, 1,0,3,2) MAKE_COLORSPACE(rgb555i_to_yv12_c, 2,2,4, RGB16I_TO_YV12, MK_RGB555, 0,0,0) MAKE_COLORSPACE(rgb565i_to_yv12_c, 2,2,4, RGB16I_TO_YV12, MK_RGB565, 0,0,0) MAKE_COLORSPACE(bgri_to_yv12_c, 3,2,4, RGBI_TO_YV12, 2,1,0, 0) MAKE_COLORSPACE(bgrai_to_yv12_c, 4,2,4, RGBI_TO_YV12, 2,1,0, 0) MAKE_COLORSPACE(abgri_to_yv12_c, 4,2,4, RGBI_TO_YV12, 3,2,1, 0) MAKE_COLORSPACE(rgbai_to_yv12_c, 4,2,4, RGBI_TO_YV12, 0,1,2, 0) MAKE_COLORSPACE(yuyvi_to_yv12_c, 2,2,4, YUYVI_TO_YV12, 0,1,2,3) MAKE_COLORSPACE(uyvyi_to_yv12_c, 2,2,4, YUYVI_TO_YV12, 1,0,3,2) /********** colorspace output (yv12_to_xxx) functions **********/ /* yuv -> rgb def's */ #define RGB_Y_OUT 1.164 #define B_U_OUT 2.018 #define Y_ADD_OUT 16 #define G_U_OUT 0.391 #define G_V_OUT 0.813 #define U_ADD_OUT 128 #define R_V_OUT 1.596 #define V_ADD_OUT 128 #define SCALEBITS_OUT 13 #define FIX_OUT(x) ((uint16_t) ((x) * (1L<<SCALEBITS_OUT) + 0.5)) /* rgb16/rgb16i output */ #define MK_RGB555(R,G,B) \ ((MAX(0,MIN(255, R)) << 7) & 0x7c00) | \ ((MAX(0,MIN(255, G)) << 2) & 0x03e0) | \ ((MAX(0,MIN(255, B)) >> 3) & 0x001f) #define MK_RGB565(R,G,B) \ ((MAX(0,MIN(255, R)) << 8) & 0xf800) | \ ((MAX(0,MIN(255, G)) << 3) & 0x07e0) | \ ((MAX(0,MIN(255, B)) >> 3) & 0x001f) #define WRITE_RGB16(ROW,UV_ROW,C1) \ rgb_y = RGB_Y_tab[ y_ptr[y_stride + 0] ]; \ b[ROW] = (b[ROW] & 0x7) + ((rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT); \ g[ROW] = (g[ROW] & 0x7) + ((rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT); \ r[ROW] = (r[ROW] & 0x7) + ((rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT); \ *(uint16_t *) (x_ptr+((ROW)*x_stride)+0) = C1(r[ROW], g[ROW], b[ROW]); \ rgb_y = RGB_Y_tab[ y_ptr[y_stride + 1] ]; \ b[ROW] = (b[ROW] & 0x7) + ((rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT); \ g[ROW] = (g[ROW] & 0x7) + ((rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT); \ r[ROW] = (r[ROW] & 0x7) + ((rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT); \ *(uint16_t *) (x_ptr+((ROW)*x_stride)+2) = C1(r[ROW], g[ROW], b[ROW]); #define YV12_TO_RGB16_ROW(SIZE,C1,C2,C3,C4) \ int r[2], g[2], b[2]; \ r[0] = r[1] = g[0] = g[1] = b[0] = b[1] = 0; #define YV12_TO_RGB16(SIZE,C1,C2,C3,C4) \ int rgb_y; \ int b_u0 = B_U_tab[ u_ptr[0] ]; \ int g_uv0 = G_U_tab[ u_ptr[0] ] + G_V_tab[ v_ptr[0] ]; \ int r_v0 = R_V_tab[ v_ptr[0] ]; \ WRITE_RGB16(0, 0, C1) \ WRITE_RGB16(1, 0, C1) #define YV12_TO_RGB16I_ROW(SIZE,C1,C2,C3,C4) \ int r[4], g[4], b[4]; \ r[0] = r[1] = r[2] = r[3] = 0; \ g[0] = g[1] = g[2] = g[3] = 0; \ b[0] = b[1] = b[2] = b[3] = 0; #define YV12_TO_RGB16I(SIZE,C1,C2,C3,C4) \ int rgb_y; \ int b_u0 = B_U_tab[ u_ptr[0] ]; \ int g_uv0 = G_U_tab[ u_ptr[0] ] + G_V_tab[ v_ptr[0] ]; \ int r_v0 = R_V_tab[ v_ptr[0] ]; \ int b_u1 = B_U_tab[ u_ptr[uv_stride] ]; \ int g_uv1 = G_U_tab[ u_ptr[uv_stride] ] + G_V_tab[ v_ptr[uv_stride] ]; \ int r_v1 = R_V_tab[ v_ptr[uv_stride] ]; \ WRITE_RGB16(0, 0, C1) \ WRITE_RGB16(1, 1, C1) \ WRITE_RGB16(2, 0, C1) \ WRITE_RGB16(3, 1, C1) \ /* rgb/rgbi output */ #define WRITE_RGB(SIZE,ROW,UV_ROW,C1,C2,C3,C4) \ rgb_y = RGB_Y_tab[ y_ptr[(ROW)*y_stride + 0] ]; \ x_ptr[(ROW)*x_stride+(C3)] = MAX(0, MIN(255, (rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT)); \ x_ptr[(ROW)*x_stride+(C2)] = MAX(0, MIN(255, (rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT)); \ x_ptr[(ROW)*x_stride+(C1)] = MAX(0, MIN(255, (rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT)); \ if ((SIZE)>3) x_ptr[(ROW)*x_stride+(C4)] = 0; \ rgb_y = RGB_Y_tab[ y_ptr[(ROW)*y_stride + 1] ]; \ x_ptr[(ROW)*x_stride+(SIZE)+(C3)] = MAX(0, MIN(255, (rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT)); \ x_ptr[(ROW)*x_stride+(SIZE)+(C2)] = MAX(0, MIN(255, (rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT)); \ x_ptr[(ROW)*x_stride+(SIZE)+(C1)] = MAX(0, MIN(255, (rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT)); \ if ((SIZE)>3) x_ptr[(ROW)*x_stride+(SIZE)+(C4)] = 0; #define YV12_TO_RGB_ROW(SIZE,C1,C2,C3,C4) /* nothing */ #define YV12_TO_RGB(SIZE,C1,C2,C3,C4) \ int rgb_y; \ int b_u0 = B_U_tab[ u_ptr[0] ]; \ int g_uv0 = G_U_tab[ u_ptr[0] ] + G_V_tab[ v_ptr[0] ]; \ int r_v0 = R_V_tab[ v_ptr[0] ]; \ WRITE_RGB(SIZE, 0, 0, C1,C2,C3,C4) \ WRITE_RGB(SIZE, 1, 0, C1,C2,C3,C4) #define YV12_TO_RGBI_ROW(SIZE,C1,C2,C3,C4) /* nothing */ #define YV12_TO_RGBI(SIZE,C1,C2,C3,C4) \ int rgb_y; \ int b_u0 = B_U_tab[ u_ptr[0] ]; \ int g_uv0 = G_U_tab[ u_ptr[0] ] + G_V_tab[ v_ptr[0] ]; \ int r_v0 = R_V_tab[ v_ptr[0] ]; \ int b_u1 = B_U_tab[ u_ptr[uv_stride] ]; \ int g_uv1 = G_U_tab[ u_ptr[uv_stride] ] + G_V_tab[ v_ptr[uv_stride] ]; \ int r_v1 = R_V_tab[ v_ptr[uv_stride] ]; \ WRITE_RGB(SIZE, 0, 0, C1,C2,C3,C4) \ WRITE_RGB(SIZE, 1, 1, C1,C2,C3,C4) \ WRITE_RGB(SIZE, 2, 0, C1,C2,C3,C4) \ WRITE_RGB(SIZE, 3, 1, C1,C2,C3,C4) /* yuyv/yuyvi output */ #define WRITE_YUYV(ROW,UV_ROW,C1,C2,C3,C4) \ x_ptr[(ROW)*x_stride+(C1)] = y_ptr[ (ROW)*y_stride +0]; \ x_ptr[(ROW)*x_stride+(C2)] = u_ptr[(UV_ROW)*uv_stride+0]; \ x_ptr[(ROW)*x_stride+(C3)] = y_ptr[ (ROW)*y_stride +1]; \ x_ptr[(ROW)*x_stride+(C4)] = v_ptr[(UV_ROW)*uv_stride+0]; \ #define YV12_TO_YUYV_ROW(SIZE,C1,C2,C3,C4) /* nothing */ #define YV12_TO_YUYV(SIZE,C1,C2,C3,C4) \ WRITE_YUYV(0, 0, C1,C2,C3,C4) \ WRITE_YUYV(1, 0, C1,C2,C3,C4) #define YV12_TO_YUYVI_ROW(SIZE,C1,C2,C3,C4) /* nothing */ #define YV12_TO_YUYVI(SIZE,C1,C2,C3,C4) \ WRITE_YUYV(0, 0, C1,C2,C3,C4) \ WRITE_YUYV(1, 1, C1,C2,C3,C4) \ WRITE_YUYV(2, 0, C1,C2,C3,C4) \ WRITE_YUYV(3, 1, C1,C2,C3,C4) MAKE_COLORSPACE(yv12_to_rgb555_c, 2,2,2, YV12_TO_RGB16, MK_RGB555, 0,0,0) MAKE_COLORSPACE(yv12_to_rgb565_c, 2,2,2, YV12_TO_RGB16, MK_RGB565, 0,0,0) MAKE_COLORSPACE(yv12_to_bgr_c, 3,2,2, YV12_TO_RGB, 2,1,0, 0) MAKE_COLORSPACE(yv12_to_bgra_c, 4,2,2, YV12_TO_RGB, 2,1,0,3) MAKE_COLORSPACE(yv12_to_abgr_c, 4,2,2, YV12_TO_RGB, 3,2,1,0) MAKE_COLORSPACE(yv12_to_rgba_c, 4,2,2, YV12_TO_RGB, 0,1,2,3) MAKE_COLORSPACE(yv12_to_yuyv_c, 2,2,2, YV12_TO_YUYV, 0,1,2,3) MAKE_COLORSPACE(yv12_to_uyvy_c, 2,2,2, YV12_TO_YUYV, 1,0,3,2) MAKE_COLORSPACE(yv12_to_rgb555i_c, 2,2,4, YV12_TO_RGB16I, MK_RGB555, 0,0,0) MAKE_COLORSPACE(yv12_to_rgb565i_c, 2,2,4, YV12_TO_RGB16I, MK_RGB565, 0,0,0) MAKE_COLORSPACE(yv12_to_bgri_c, 3,2,4, YV12_TO_RGBI, 2,1,0, 0) MAKE_COLORSPACE(yv12_to_bgrai_c, 4,2,4, YV12_TO_RGBI, 2,1,0,3) MAKE_COLORSPACE(yv12_to_abgri_c, 4,2,4, YV12_TO_RGBI, 3,2,1,0) MAKE_COLORSPACE(yv12_to_rgbai_c, 4,2,4, YV12_TO_RGBI, 0,1,2,3) MAKE_COLORSPACE(yv12_to_yuyvi_c, 2,2,4, YV12_TO_YUYVI, 0,1,2,3) MAKE_COLORSPACE(yv12_to_uyvyi_c, 2,2,4, YV12_TO_YUYVI, 1,0,3,2) /* yv12 to yv12 copy function */ void yv12_to_yv12_c(uint8_t * y_dst, uint8_t * u_dst, uint8_t * v_dst, int y_dst_stride, int uv_dst_stride, uint8_t * y_src, uint8_t * u_src, uint8_t * v_src, int y_src_stride, int uv_src_stride, int width, int height, int vflip) { int width2 = width / 2; int height2 = height / 2; int y; if (vflip) { y_src += (height - 1) * y_src_stride; u_src += (height2 - 1) * uv_src_stride; v_src += (height2 - 1) * uv_src_stride; y_src_stride = -y_src_stride; uv_src_stride = -uv_src_stride; } for (y = height; y; y--) { memcpy(y_dst, y_src, width); y_src += y_src_stride; y_dst += y_dst_stride; } for (y = height2; y; y--) { memcpy(u_dst, u_src, width2); u_src += uv_src_stride; u_dst += uv_dst_stride; } for (y = height2; y; y--) { memcpy(v_dst, v_src, width2); v_src += uv_src_stride; v_dst += uv_dst_stride; } } /* initialize rgb lookup tables */ void colorspace_init(void) { int32_t i; for (i = 0; i < 256; i++) { RGB_Y_tab[i] = FIX_OUT(RGB_Y_OUT) * (i - Y_ADD_OUT); B_U_tab[i] = FIX_OUT(B_U_OUT) * (i - U_ADD_OUT); G_U_tab[i] = FIX_OUT(G_U_OUT) * (i - U_ADD_OUT); G_V_tab[i] = FIX_OUT(G_V_OUT) * (i - V_ADD_OUT); R_V_tab[i] = FIX_OUT(R_V_OUT) * (i - V_ADD_OUT); } } --- NEW FILE: colorspace.h --- #ifndef _COLORSPACE_H #define _COLORSPACE_H #include "../portab.h" #include "../divx4.h" /* initialize tables */ void colorspace_init(void); /* colorspace conversion function (encoder) */ typedef void (packedFunc) (uint8_t * x_ptr, int x_stride, uint8_t * y_src, uint8_t * v_src, uint8_t * u_src, int y_stride, int uv_stride, int width, int height, int vflip); typedef packedFunc *packedFuncPtr; /* xxx_to_yv12 colorspace conversion functions (encoder) */ extern packedFuncPtr rgb555_to_yv12; extern packedFuncPtr rgb565_to_yv12; extern packedFuncPtr bgr_to_yv12; extern packedFuncPtr bgra_to_yv12; extern packedFuncPtr abgr_to_yv12; extern packedFuncPtr rgba_to_yv12; extern packedFuncPtr yuyv_to_yv12; extern packedFuncPtr uyvy_to_yv12; extern packedFuncPtr rgb555i_to_yv12; extern packedFuncPtr rgb565i_to_yv12; extern packedFuncPtr bgri_to_yv12; extern packedFuncPtr bgrai_to_yv12; extern packedFuncPtr abgri_to_yv12; extern packedFuncPtr rgbai_to_yv12; extern packedFuncPtr yuyvi_to_yv12; extern packedFuncPtr uyvyi_to_yv12; /* plain c */ packedFunc rgb555_to_yv12_c; packedFunc rgb565_to_yv12_c; packedFunc bgr_to_yv12_c; packedFunc bgra_to_yv12_c; packedFunc abgr_to_yv12_c; packedFunc rgba_to_yv12_c; packedFunc yuyv_to_yv12_c; packedFunc uyvy_to_yv12_c; packedFunc rgb555i_to_yv12_c; packedFunc rgb565i_to_yv12_c; packedFunc bgri_to_yv12_c; packedFunc bgrai_to_yv12_c; packedFunc abgri_to_yv12_c; packedFunc rgbai_to_yv12_c; packedFunc yuyvi_to_yv12_c; packedFunc uyvyi_to_yv12_c; /* mmx */ packedFunc bgr_to_yv12_mmx; packedFunc bgra_to_yv12_mmx; packedFunc yuyv_to_yv12_mmx; packedFunc uyvy_to_yv12_mmx; /* 3dnow */ packedFunc yuyv_to_yv12_3dn; packedFunc uyvy_to_yv12_3dn; /* xmm */ packedFunc yuyv_to_yv12_xmm; packedFunc uyvy_to_yv12_xmm; /* yv12_to_xxx colorspace conversion functions (decoder) */ extern packedFuncPtr yv12_to_rgb555; extern packedFuncPtr yv12_to_rgb565; extern packedFuncPtr yv12_to_bgr; extern packedFuncPtr yv12_to_bgra; extern packedFuncPtr yv12_to_abgr; extern packedFuncPtr yv12_to_rgba; extern packedFuncPtr yv12_to_yuyv; extern packedFuncPtr yv12_to_uyvy; extern packedFuncPtr yv12_to_rgb555i; extern packedFuncPtr yv12_to_rgb565i; extern packedFuncPtr yv12_to_bgri; extern packedFuncPtr yv12_to_bgrai; extern packedFuncPtr yv12_to_abgri; extern packedFuncPtr yv12_to_rgbai; extern packedFuncPtr yv12_to_yuyvi; extern packedFuncPtr yv12_to_uyvyi; /* plain c */ packedFunc yv12_to_rgb555_c; packedFunc yv12_to_rgb565_c; packedFunc yv12_to_bgr_c; packedFunc yv12_to_bgra_c; packedFunc yv12_to_abgr_c; packedFunc yv12_to_rgba_c; packedFunc yv12_to_yuyv_c; packedFunc yv12_to_uyvy_c; packedFunc yv12_to_rgb555i_c; packedFunc yv12_to_rgb565i_c; packedFunc yv12_to_bgri_c; packedFunc yv12_to_bgrai_c; packedFunc yv12_to_abgri_c; packedFunc yv12_to_rgbai_c; packedFunc yv12_to_yuyvi_c; packedFunc yv12_to_uyvyi_c; /* mmx */ packedFunc yv12_to_bgr_mmx; packedFunc yv12_to_bgra_mmx; packedFunc yv12_to_yuyv_mmx; packedFunc yv12_to_uyvy_mmx; packedFunc yv12_to_yuyvi_mmx; packedFunc yv12_to_uyvyi_mmx; typedef void (planarFunc) ( uint8_t * y_dst, uint8_t * u_dst, uint8_t * v_dst, int y_dst_stride, int uv_dst_stride, uint8_t * y_src, uint8_t * u_src, uint8_t * v_src, int y_src_stride, int uv_src_stride, int width, int height, int vflip); typedef planarFunc *planarFuncPtr; extern planarFuncPtr yv12_to_yv12; planarFunc yv12_to_yv12_c; planarFunc yv12_to_yv12_mmx; planarFunc yv12_to_yv12_xmm; #endif /* _COLORSPACE_H_ */ --- NEW FILE: font.c --- /****************************************************************************** * * * This file is part of XviD, a free MPEG-4 video encoder/decoder * * * * XviD is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * XviD is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * ******************************************************************************/ /****************************************************************************** * * * font.c * * * * Copyright (C) 2001 - Peter Ross <sux...@ho...> * * * * For more information visit the XviD homepage: http://www.xvid.org * * * ******************************************************************************/ /****************************************************************************** * * * Revision history: * * * * 22.06.2002 inital version * * * ******************************************************************************/ #include <stdio.h> #include <stdarg.h> #include "image.h" #include "font.h" #define FONT_WIDTH 4 #define FONT_HEIGHT 6 static const char ascii33[33][FONT_WIDTH*FONT_HEIGHT] = { { 0,0,1,0, // ! 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,0,0, 0,0,1,0 }, { 0,1,0,1, // " 0,1,0,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }, { 0,1,1,0, // # 1,1,1,1, 0,1,1,0, 0,1,1,0, 1,1,1,1, 0,1,1,0 }, { 0,1,1,0, // $ 1,0,1,1, 1,1,1,0, 0,1,1,1, 1,1,0,1, 0,1,1,0 }, { 1,1,0,1, // % 1,0,0,1, 0,0,1,0, 0,1,0,0, 1,0,0,1, 1,0,1,1 }, { 0,1,1,0, //& 1,0,0,0, 0,1,0,1, 1,0,1,0, 1,0,1,0, 0,1,0,1 }, { 0,0,1,0, // ' 0,0,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }, { 0,0,1,0, // ( 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,0,1,0 }, { 0,1,0,0, // ) 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,1,0,0 }, { 0,0,0,0, // * 1,0,0,1, 0,1,1,0, 1,1,1,1, 0,1,1,0, 1,0,0,1 }, { 0,0,0,0, // + 0,0,1,0, 0,0,1,0, 0,1,1,1, 0,0,1,0, 0,0,1,0 }, { 0,0,0,0, // , 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,0, 0,0,1,0 }, { 0,0,0,0, // - 0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0 }, { 0,0,0,0, // . 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,0, 0,1,1,0 }, { 0,0,0,1, // / 0,0,0,1, 0,0,1,0, 0,1,0,0, 1,0,0,0, 1,0,0,0 }, { 0,1,1,0, // 0 1,0,0,1, 1,0,1,1, 1,1,0,1, 1,0,0,1, 0,1,1,0 }, { 0,0,1,0, // 1 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0 }, { 0,1,1,0, // 2 1,0,0,1, 0,0,1,0, 0,1,0,0, 1,0,0,0, 1,1,1,1 }, { 0,1,1,0, // 3 1,0,0,1, 0,0,1,0, 0,0,0,1, 1,0,0,1, 0,1,1,0 }, { 0,0,1,0, // 4 0,1,1,0, 1,0,1,0, 1,1,1,1, 0,0,1,0, 0,0,1,0 }, { 1,1,1,1, // 5 1,0,0,0, 1,1,1,0, 0,0,0,1, 1,0,0,1, 0,1,1,0 }, { 0,1,1,1, //6 1,0,0,0, 1,1,1,0, 1,0,0,1, 1,0,0,1, 0,1,1,0 }, { 1,1,1,0, // 7 0,0,0,1, 0,0,0,1, 0,0,1,0, 0,0,1,0, 0,0,1,0 }, { 0,1,1,0, // 8 1,0,0,1, 0,1,1,0, 1,0,0,1, 1,0,0,1, 0,1,1,0 }, { 0,1,1,0, // 9 1,0,0,1, 1,0,0,1, 0,1,1,1, 0,0,0,1, 1,1,1,0 }, { 0,0,0,0, // : 0,0,0,0, 0,0,1,0, 0,0,0,0, 0,0,1,0, 0,0,0,0 }, { 0,0,0,0, // ; 0,0,1,0, 0,0,0,0, 0,0,0,0, 0,1,1,0, 0,0,1,0 }, { 0,0,0,1, // < 0,0,1,0, 0,1,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }, { 0,0,0,0, // = 1,1,1,1, 0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,0,0 }, { 0,1,0,0, // > 0,0,1,0, 0,0,0,1, 0,0,0,1, 0,0,1,0, 0,1,0,0 }, { 0,1,1,0, // ? 1,0,0,1, 0,0,1,0, 0,0,1,0, 0,0,0,0, 0,0,1,0 }, { 0,1,1,0, // @ 1,0,0,1, 1,0,1,1, 1,0,1,1, 1,0,0,0, 0,1,1,0 }, }; static const char ascii65[26][FONT_WIDTH*FONT_HEIGHT] = { { 0,1,1,0, // A 1,0,0,1, 1,0,0,1, 1,1,1,1, 1,0,0,1, 1,0,0,1 }, { 1,1,1,0, // B 1,0,0,1, 1,1,1,0, 1,0,0,1, 1,0,0,1, 1,1,1,0 }, { 0,1,1,0, // C 1,0,0,1, 1,0,0,0, 1,0,0,0, 1,0,0,1, 0,1,1,0 }, { 1,1,0,0, // D 1,0,1,0, 1,0,0,1, 1,0,0,1, 1,0,1,0, 1,1,0,0 }, { 1,1,1,1, // E 1,0,0,0, 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,1,1,1 }, { 1,1,1,1, // F 1,0,0,0, 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,0,0,0 }, { 0,1,1,1, // G 1,0,0,0, 1,0,1,1, 1,0,0,1, 1,0,0,1, 0,1,1,0 }, { 1,0,0,1, // H 1,0,0,1, 1,1,1,1, 1,0,0,1, 1,0,0,1, 1,0,0,1 }, { 0,1,1,1, // I 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,1,1,1 }, { 0,1,1,1, // J 0,0,1,0, 0,0,1,0, 0,0,1,0, 1,0,1,0, 0,1,0,0 }, { 1,0,0,1, // K 1,0,0,1, 1,1,1,0, 1,0,0,1, 1,0,0,1, 1,0,0,1 }, { 1,0,0,0, // L 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,1,1 }, { 1,0,0,1, // M 1,1,1,1, 1,1,1,1, 1,0,0,1, 1,0,0,1, 1,0,0,1 }, { 1,0,0,1, // N 1,1,0,1, 1,1,0,1, 1,0,1,1, 1,0,1,1, 1,0,0,1 }, { 0,1,1,0, // 0 1,0,0,1, 1,0,0,1, 1,0,0,1, 1,0,0,1, 0,1,1,0 }, { 1,1,1,0, // P 1,0,0,1, 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,0,0,0 }, { 0,1,1,0, // Q 1,0,0,1, 1,0,0,1, 1,0,0,1, 1,0,1,0, 0,1,0,1 }, { 1,1,1,0, // R 1,0,0,1, 1,1,1,0, 1,0,0,1, 1,0,0,1, 1,0,0,1 }, { 0,1,1,0, // S 1,0,0,1, 0,1,0,0, 0,0,1,0, 1,0,0,1, 0,1,1,0 }, { 0,1,1,1, // T 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0 }, { 1,0,0,1, // U 1,0,0,1, 1,0,0,1, 1,0,0,1, 1,0,0,1, 1,1,1,1 }, { 1,0,0,1, // V 1,0,0,1, 1,0,0,1, 0,1,1,0, 0,1,1,0, 0,1,1,0 }, { 1,0,0,1, // W 1,0,0,1, 1,0,0,1, 1,1,1,1, 1,1,1,1, 1,0,0,1 }, { 1,0,0,1, // X 1,0,0,1, 0,1,1,0, 1,0,0,1, 1,0,0,1, 1,0,0,1 }, { 1,0,0,1, // Y 1,0,0,1, 0,1,0,0, 0,0,1,0, 0,1,0,0, 1,0,0,0 }, { 1,1,1,1, // Z 0,0,0,1, 0,0,1,0, 0,1,0,0, 1,0,0,0, 1,1,1,1 }, }; static const char ascii91[6][FONT_WIDTH*FONT_HEIGHT] = { { 0,1,1,0, // [ 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,1,0 }, { 1,0,0,0, // '\' 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,1 }, { 0,1,1,0, // ] 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,1,1,0 }, { 0,1,0,1, // ^ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }, { 0,0,0,0, // _ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1 }, { 0,1,0,0, // ` 0,0,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 } }; #define FONT_ZOOM 4 void draw_num(IMAGE * img, const int stride, const int height, const char * font, const int x, const int y) { int i, j; for (j = 0; j < FONT_ZOOM * FONT_HEIGHT && y+j < height; j++) for (i = 0; i < FONT_ZOOM * FONT_WIDTH && x+i < stride; i++) if (font[(j/FONT_ZOOM)*FONT_WIDTH + (i/FONT_ZOOM)]) { int offset = (y+j)*stride + (x+i); int offset2 =((y+j)/2)*(stride/2) + ((x+i)/2); img->y[offset] = 255; img->u[offset2] = 127; img->v[offset2] = 127; } } #define FONT_BUF_SZ 1024 void image_printf(IMAGE * img, int edged_width, int height, int x, int y, char *fmt, ...) { va_list args; char buf[FONT_BUF_SZ]; int i; va_start(args, fmt); vsprintf(buf, fmt, args); for (i = 0; i < buf[i]; i++) { const char * font; if (buf[i] >= '!' && buf[i] <= '@') font = ascii33[buf[i]-'!']; else if (buf[i] >= 'A' && buf[i] <= 'Z') font = ascii65[buf[i]-'A']; else if (buf[i] >= '[' && buf[i] <= '`') font = ascii91[buf[i]-'[']; else if (buf[i] >= 'a' && buf[i] <= 'z') font = ascii65[buf[i]-'a']; else continue; draw_num(img, edged_width, height, font, x + i*FONT_ZOOM*(FONT_WIDTH+1), y); } } --- NEW FILE: font.h --- #ifndef _XVID_FONT_H_ #define _XVID_FONT_H_ #include "image.h" void image_printf(IMAGE * img, int edged_width, int height, int x, int y, char *fmt, ...); #endif /* _XVID_FONT_H_ */ --- NEW FILE: image.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * image stuff * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * [...1193 lines suppressed...] } for (j = 0; j < mb_height; j++) /* vertical deblocking */ for (i = 1; i < mb_width; i++) { if (mbs[j*mb_stride + i - 1].mode != MODE_NOT_CODED || mbs[j*mb_stride + i + 0].mode != MODE_NOT_CODED) { vfilter_31(img->u + (j*block)*edged_width2 + i*block - 1, img->u + (j*block)*edged_width2 + i*block + 0, edged_width2, nblocks); vfilter_31(img->v + (j*block)*edged_width2 + i*block - 1, img->v + (j*block)*edged_width2 + i*block + 0, edged_width2, nblocks); } } } } --- NEW FILE: image.h --- #ifndef _IMAGE_H_ #define _IMAGE_H_ #include <stdlib.h> #include "../portab.h" #include "../global.h" #include "colorspace.h" #include "../xvid.h" #define EDGE_SIZE 64 void init_image(uint32_t cpu_flags); static void __inline image_null(IMAGE * image) { image->y = image->u = image->v = NULL; } int32_t image_create(IMAGE * image, uint32_t edged_width, uint32_t edged_height); void image_destroy(IMAGE * image, uint32_t edged_width, uint32_t edged_height); void image_swap(IMAGE * image1, IMAGE * image2); void image_copy(IMAGE * image1, IMAGE * image2, uint32_t edged_width, uint32_t height); void image_setedges(IMAGE * image, uint32_t edged_width, uint32_t edged_height, uint32_t width, uint32_t height); void image_interpolate(const IMAGE * refn, IMAGE * refh, IMAGE * refv, IMAGE * refhv, uint32_t edged_width, uint32_t edged_height, uint32_t quarterpel, uint32_t rounding); float image_psnr(IMAGE * orig_image, IMAGE * recon_image, uint16_t stride, uint16_t width, uint16_t height); float sse_to_PSNR(long sse, int pixels); long plane_sse(uint8_t * orig, uint8_t * recon, uint16_t stride, uint16_t width, uint16_t height); void image_chroma_optimize(IMAGE * img, int width, int height, int edged_width); int image_input(IMAGE * image, uint32_t width, int height, uint32_t edged_width, uint8_t * src, int src_stride, int csp, int interlaced); int image_output(IMAGE * image, uint32_t width, int height, uint32_t edged_width, uint8_t * dst, uint32_t dst_stride, int csp, int interlaced); int image_dump_yuvpgm(const IMAGE * image, const uint32_t edged_width, const uint32_t width, const uint32_t height, char *filename); float image_mad(const IMAGE * img1, const IMAGE * img2, uint32_t stride, uint32_t width, uint32_t height); void output_slice(IMAGE * cur, int edged_width, int width, XVID_DEC_PICTURE* out_frm, int mbx, int mby,int mbl); void image_clear(IMAGE * img, int width, int height, int edged_width, int y, int u, int v); void image_deblock_rrv(IMAGE * img, int edgeg_width, const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride, int block, int flags); #endif /* _IMAGE_H_ */ --- NEW FILE: interpolate8x8.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * 8x8 block-based halfpel interpolation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /************************************************************************** * * History: * * 05.10.2002 new bilinear and qpel interpolation code - Isibaar * 27.12.2001 modified "compensate_halfpel" * 05.11.2001 initial version; (c)2001 peter ross <pr...@cs...> * *************************************************************************/ #include "../portab.h" #include "../global.h" #include "interpolate8x8.h" // function pointers INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; INTERPOLATE8X8_AVG2_PTR interpolate8x8_avg2; INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4; INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_h; INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_v; INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_h; INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_v; INTERPOLATE_LOWPASS_HV_PTR interpolate8x8_lowpass_hv; INTERPOLATE_LOWPASS_HV_PTR interpolate16x16_lowpass_hv; INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_h; INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_v; void interpolate8x8_avg2_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint32_t stride, const uint32_t rounding, const uint32_t height) { uint32_t i; const int32_t round = 1 - rounding; for(i = 0; i < height; i++) { dst[0] = (src1[0] + src2[0] + round) >> 1; dst[1] = (src1[1] + src2[1] + round) >> 1; dst[2] = (src1[2] + src2[2] + round) >> 1; dst[3] = (src1[3] + src2[3] + round) >> 1; dst[4] = (src1[4] + src2[4] + round) >> 1; dst[5] = (src1[5] + src2[5] + round) >> 1; dst[6] = (src1[6] + src2[6] + round) >> 1; dst[7] = (src1[7] + src2[7] + round) >> 1; dst += stride; src1 += stride; src2 += stride; } } void interpolate8x8_avg4_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4, const uint32_t stride, const uint32_t rounding) { int32_t i; const int32_t round = 2 - rounding; for(i = 0; i < 8; i++) { dst[0] = (src1[0] + src2[0] + src3[0] + src4[0] + round) >> 2; dst[1] = (src1[1] + src2[1] + src3[1] + src4[1] + round) >> 2; dst[2] = (src1[2] + src2[2] + src3[2] + src4[2] + round) >> 2; dst[3] = (src1[3] + src2[3] + src3[3] + src4[3] + round) >> 2; dst[4] = (src1[4] + src2[4] + src3[4] + src4[4] + round) >> 2; dst[5] = (src1[5] + src2[5] + src3[5] + src4[5] + round) >> 2; dst[6] = (src1[6] + src2[6] + src3[6] + src4[6] + round) >> 2; dst[7] = (src1[7] + src2[7] + src3[7] + src4[7] + round) >> 2; dst += stride; src1 += stride; src2 += stride; src3 += stride; src4 += stride; } } // dst = interpolate(src) void interpolate8x8_halfpel_h_c(uint8_t * const dst, const uint8_t * const src, const uint32_t stride, const uint32_t rounding) { intptr_t j; if (rounding) for (j = 7*stride; j >= 0; j-=stride) { dst[j + 0] = (uint8_t)((src[j + 0] + src[j + 1] )>>1); dst[j + 1] = (uint8_t)((src[j + 1] + src[j + 2] )>>1); dst[j + 2] = (uint8_t)((src[j + 2] + src[j + 3] )>>1); dst[j + 3] = (uint8_t)((src[j + 3] + src[j + 4] )>>1); dst[j + 4] = (uint8_t)((src[j + 4] + src[j + 5] )>>1); dst[j + 5] = (uint8_t)((src[j + 5] + src[j + 6] )>>1); dst[j + 6] = (uint8_t)((src[j + 6] + src[j + 7] )>>1); dst[j + 7] = (uint8_t)((src[j + 7] + src[j + 8] )>>1); } else for (j = 0; j < 8*stride; j+=stride) /* forward or backwards? Who knows ... */ { dst[j + 0] = (uint8_t)((src[j + 0] + src[j + 1] + 1)>>1); dst[j + 1] = (uint8_t)((src[j + 1] + src[j + 2] + 1)>>1); dst[j + 2] = (uint8_t)((src[j + 2] + src[j + 3] + 1)>>1); dst[j + 3] = (uint8_t)((src[j + 3] + src[j + 4] + 1)>>1); dst[j + 4] = (uint8_t)((src[j + 4] + src[j + 5] + 1)>>1); dst[j + 5] = (uint8_t)((src[j + 5] + src[j + 6] + 1)>>1); dst[j + 6] = (uint8_t)((src[j + 6] + src[j + 7] + 1)>>1); dst[j + 7] = (uint8_t)((src[j + 7] + src[j + 8] + 1)>>1); } } void interpolate8x8_halfpel_v_c(uint8_t * const dst, const uint8_t * const src, const uint32_t stride, const uint32_t rounding) { intptr_t j; // const uint8_t * const src2 = src+stride; /* using a second pointer is _not_ faster here */ if (rounding) for (j = 0; j < 8*stride; j+=stride) /* forward is better. Some automatic prefetch perhaps. */ { dst[j + 0] = (uint8_t)((src[j + 0] + src[j + stride + 0] )>>1); dst[j + 1] = (uint8_t)((src[j + 1] + src[j + stride + 1] )>>1); dst[j + 2] = (uint8_t)((src[j + 2] + src[j + stride + 2] )>>1); dst[j + 3] = (uint8_t)((src[j + 3] + src[j + stride + 3] )>>1); dst[j + 4] = (uint8_t)((src[j + 4] + src[j + stride + 4] )>>1); dst[j + 5] = (uint8_t)((src[j + 5] + src[j + stride + 5] )>>1); dst[j + 6] = (uint8_t)((src[j + 6] + src[j + stride + 6] )>>1); dst[j + 7] = (uint8_t)((src[j + 7] + src[j + stride + 7] )>>1); } else for (j = 0; j < 8*stride; j+=stride) { dst[j + 0] = (uint8_t)((src[j + 0] + src[j + stride + 0] + 1)>>1); dst[j + 1] = (uint8_t)((src[j + 1] + src[j + stride + 1] + 1)>>1); dst[j + 2] = (uint8_t)((src[j + 2] + src[j + stride + 2] + 1)>>1); dst[j + 3] = (uint8_t)((src[j + 3] + src[j + stride + 3] + 1)>>1); dst[j + 4] = (uint8_t)((src[j + 4] + src[j + stride + 4] + 1)>>1); dst[j + 5] = (uint8_t)((src[j + 5] + src[j + stride + 5] + 1)>>1); dst[j + 6] = (uint8_t)((src[j + 6] + src[j + stride + 6] + 1)>>1); dst[j + 7] = (uint8_t)((src[j + 7] + src[j + stride + 7] + 1)>>1); } } void interpolate8x8_halfpel_hv_c(uint8_t * const dst, const uint8_t * const src, const uint32_t stride, const uint32_t rounding) { intptr_t j; if (rounding) for (j = 7*stride; j >= 0; j-=stride) { dst[j + 0] = (uint8_t)((src[j+0] + src[j+1] + src[j+stride+0] + src[j+stride+1] +1)>>2); dst[j + 1] = (uint8_t)((src[j+1] + src[j+2] + src[j+stride+1] + src[j+stride+2] +1)>>2); dst[j + 2] = (uint8_t)((src[j+2] + src[j+3] + src[j+stride+2] + src[j+stride+3] +1)>>2); dst[j + 3] = (uint8_t)((src[j+3] + src[j+4] + src[j+stride+3] + src[j+stride+4] +1)>>2); dst[j + 4] = (uint8_t)((src[j+4] + src[j+5] + src[j+stride+4] + src[j+stride+5] +1)>>2); dst[j + 5] = (uint8_t)((src[j+5] + src[j+6] + src[j+stride+5] + src[j+stride+6] +1)>>2); dst[j + 6] = (uint8_t)((src[j+6] + src[j+7] + src[j+stride+6] + src[j+stride+7] +1)>>2); dst[j + 7] = (uint8_t)((src[j+7] + src[j+8] + src[j+stride+7] + src[j+stride+8] +1)>>2); } else for (j = 7*stride; j >= 0; j-=stride) { dst[j + 0] = (uint8_t)((src[j+0] + src[j+1] + src[j+stride+0] + src[j+stride+1] +2)>>2); dst[j + 1] = (uint8_t)((src[j+1] + src[j+2] + src[j+stride+1] + src[j+stride+2] +2)>>2); dst[j + 2] = (uint8_t)((src[j+2] + src[j+3] + src[j+stride+2] + src[j+stride+3] +2)>>2); dst[j + 3] = (uint8_t)((src[j+3] + src[j+4] + src[j+stride+3] + src[j+stride+4] +2)>>2); dst[j + 4] = (uint8_t)((src[j+4] + src[j+5] + src[j+stride+4] + src[j+stride+5] +2)>>2); dst[j + 5] = (uint8_t)((src[j+5] + src[j+6] + src[j+stride+5] + src[j+stride+6] +2)>>2); dst[j + 6] = (uint8_t)((src[j+6] + src[j+7] + src[j+stride+6] + src[j+stride+7] +2)>>2); dst[j + 7] = (uint8_t)((src[j+7] + src[j+8] + src[j+stride+7] + src[j+stride+8] +2)>>2); } } /************************************************************* * QPEL STUFF STARTS HERE * *************************************************************/ void interpolate8x8_6tap_lowpass_h_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 8; i++) { dst[0] = CLIP((((src[-2] + src[3]) + 5 * (((src[0] + src[1])<<2) - (src[-1] + src[2])) + round_add) >> 5), 0, 255); dst[1] = CLIP((((src[-1] + src[4]) + 5 * (((src[1] + src[2])<<2) - (src[0] + src[3])) + round_add) >> 5), 0, 255); dst[2] = CLIP((((src[0] + src[5]) + 5 * (((src[2] + src[3])<<2) - (src[1] + src[4])) + round_add) >> 5), 0, 255); dst[3] = CLIP((((src[1] + src[6]) + 5 * (((src[3] + src[4])<<2) - (src[2] + src[5])) + round_add) >> 5), 0, 255); dst[4] = CLIP((((src[2] + src[7]) + 5 * (((src[4] + src[5])<<2) - (src[3] + src[6])) + round_add) >> 5), 0, 255); dst[5] = CLIP((((src[3] + src[8]) + 5 * (((src[5] + src[6])<<2) - (src[4] + src[7])) + round_add) >> 5), 0, 255); dst[6] = CLIP((((src[4] + src[9]) + 5 * (((src[6] + src[7])<<2) - (src[5] + src[8])) + round_add) >> 5), 0, 255); dst[7] = CLIP((((src[5] + src[10]) + 5 * (((src[7] + src[8])<<2) - (src[6] + src[9])) + round_add) >> 5), 0, 255); dst += stride; src += stride; } } void interpolate16x16_lowpass_h_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 17; i++) { dst[0] = CLIP(((7 * ((src[0]<<1) - src[2]) + 23 * src[1] + 3 * src[3] - src[4] + round_add) >> 5), 0, 255); dst[1] = CLIP(((19 * src[1] + 20 * src[2] - src[5] + 3 * (src[4] - src[0] - (src[3]<<1)) + round_add) >> 5), 0, 255); dst[2] = CLIP(((20 * (src[2] + src[3]) + (src[0]<<1) + 3 * (src[5] - ((src[1] + src[4])<<1)) - src[6] + round_add) >> 5), 0, 255); dst[3] = CLIP(((20 * (src[3] + src[4]) + 3 * ((src[6] + src[1]) - ((src[2] + src[5])<<1)) - (src[0] + src[7]) + round_add) >> 5), 0, 255); dst[4] = CLIP(((20 * (src[4] + src[5]) - 3 * (((src[3] + src[6])<<1) - (src[2] + src[7])) - (src[1] + src[8]) + round_add) >> 5), 0, 255); dst[5] = CLIP(((20 * (src[5] + src[6]) - 3 * (((src[4] + src[7])<<1) - (src[3] + src[8])) - (src[2] + src[9]) + round_add) >> 5), 0, 255); dst[6] = CLIP(((20 * (src[6] + src[7]) - 3 * (((src[5] + src[8])<<1) - (src[4] + src[9])) - (src[3] + src[10]) + round_add) >> 5), 0, 255); dst[7] = CLIP(((20 * (src[7] + src[8]) - 3 * (((src[6] + src[9])<<1) - (src[5] + src[10])) - (src[4] + src[11]) + round_add) >> 5), 0, 255); dst[8] = CLIP(((20 * (src[8] + src[9]) - 3 * (((src[7] + src[10])<<1) - (src[6] + src[11])) - (src[5] + src[12]) + round_add) >> 5), 0, 255); dst[9] = CLIP(((20 * (src[9] + src[10]) - 3 * (((src[8] + src[11])<<1) - (src[7] + src[12])) - (src[6] + src[13]) + round_add) >> 5), 0, 255); dst[10] = CLIP(((20 * (src[10] + src[11]) - 3 * (((src[9] + src[12])<<1) - (src[8] + src[13])) - (src[7] + src[14]) + round_add) >> 5), 0, 255); dst[11] = CLIP(((20 * (src[11] + src[12]) - 3 * (((src[10] + src[13])<<1) - (src[9] + src[14])) - (src[8] + src[15]) + round_add) >> 5), 0, 255); dst[12] = CLIP(((20 * (src[12] + src[13]) - 3 * (((src[11] + src[14])<<1) - (src[10] + src[15])) - (src[9] + src[16]) + round_add) >> 5), 0, 255); dst[13] = CLIP(((20 * (src[13] + src[14]) + (src[16]<<1) + 3 * (src[11] - ((src[12] + src[15]) << 1)) - src[10] + round_add) >> 5), 0, 255); dst[14] = CLIP(((19 * src[15] + 20 * src[14] + 3 * (src[12] - src[16] - (src[13] << 1)) - src[11] + round_add) >> 5), 0, 255); dst[15] = CLIP(((23 * src[15] + 7 * ((src[16]<<1) - src[14]) + 3 * src[13] - src[12] + round_add) >> 5), 0, 255); dst += stride; src += stride; } } void interpolate8x8_lowpass_h_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 9; i++) { dst[0] = CLIP(((7 * ((src[0]<<1) - src[2]) + 23 * src[1] + 3 * src[3] - src[4] + round_add) >> 5), 0, 255); dst[1] = CLIP(((19 * src[1] + 20 * src[2] - src[5] + 3 * (src[4] - src[0] - (src[3]<<1)) + round_add) >> 5), 0, 255); dst[2] = CLIP(((20 * (src[2] + src[3]) + (src[0]<<1) + 3 * (src[5] - ((src[1] + src[4])<<1)) - src[6] + round_add) >> 5), 0, 255); dst[3] = CLIP(((20 * (src[3] + src[4]) + 3 * ((src[6] + src[1]) - ((src[2] + src[5])<<1)) - (src[0] + src[7]) + round_add) >> 5), 0, 255); dst[4] = CLIP(((20 * (src[4] + src[5]) - 3 * (((src[3] + src[6])<<1) - (src[2] + src[7])) - (src[1] + src[8]) + round_add) >> 5), 0, 255); dst[5] = CLIP(((20 * (src[5] + src[6]) + (src[8]<<1) + 3 * (src[3] - ((src[4] + src[7]) << 1)) - src[2] + round_add) >> 5), 0, 255); dst[6] = CLIP(((19 * src[7] + 20 * src[6] + 3 * (src[4] - src[8] - (src[5] << 1)) - src[3] + round_add) >> 5), 0, 255); dst[7] = CLIP(((23 * src[7] + 7 * ((src[8]<<1) - src[6]) + 3 * src[5] - src[4] + round_add) >> 5), 0, 255); dst += stride; src += stride; } } void interpolate8x8_6tap_lowpass_v_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 8; i++) { int32_t src_2 = src[-2*stride]; int32_t src_1 = src[-stride]; int32_t src0 = src[0]; int32_t src1 = src[stride]; int32_t src2 = src[2 * stride]; int32_t src3 = src[3 * stride]; int32_t src4 = src[4 * stride]; int32_t src5 = src[5 * stride]; int32_t src6 = src[6 * stride]; int32_t src7 = src[7 * stride]; int32_t src8 = src[8 * stride]; int32_t src9 = src[9 * stride]; int32_t src10 = src[10 * stride]; dst[0] = CLIP((((src_2 + src3) + 5 * (((src0 + src1)<<2) - (src_1 + src2)) + round_add) >> 5), 0, 255); dst[stride] = CLIP((((src_1 + src4) + 5 * (((src1 + src2)<<2) - (src0 + src3)) + round_add) >> 5), 0, 255); dst[2 * stride] = CLIP((((src0 + src5) + 5 * (((src2 + src3)<<2) - (src1 + src4)) + round_add) >> 5), 0, 255); dst[3 * stride] = CLIP((((src1 + src6) + 5 * (((src3 + src4)<<2) - (src2 + src5)) + round_add) >> 5), 0, 255); dst[4 * stride] = CLIP((((src2 + src7) + 5 * (((src4 + src5)<<2) - (src3 + src6)) + round_add) >> 5), 0, 255); dst[5 * stride] = CLIP((((src3 + src8) + 5 * (((src5 + src6)<<2) - (src4 + src7)) + round_add) >> 5), 0, 255); dst[6 * stride] = CLIP((((src4 + src9) + 5 * (((src6 + src7)<<2) - (src5 + src8)) + round_add) >> 5), 0, 255); dst[7 * stride] = CLIP((((src5 + src10) + 5 * (((src7 + src8)<<2) - (src6 + src9)) + round_add) >> 5), 0, 255); dst++; src++; } } void interpolate16x16_lowpass_v_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 17; i++) { int32_t src0 = src[0]; int32_t src1 = src[stride]; int32_t src2 = src[2 * stride]; int32_t src3 = src[3 * stride]; int32_t src4 = src[4 * stride]; int32_t src5 = src[5 * stride]; int32_t src6 = src[6 * stride]; int32_t src7 = src[7 * stride]; int32_t src8 = src[8 * stride]; int32_t src9 = src[9 * stride]; int32_t src10 = src[10 * stride]; int32_t src11 = src[11 * stride]; int32_t src12 = src[12 * stride]; int32_t src13 = src[13 * stride]; int32_t src14 = src[14 * stride]; int32_t src15 = src[15 * stride]; int32_t src16 = src[16 * stride]; dst[0] = CLIP(((7 * ((src0<<1) - src2) + 23 * src1 + 3 * src3 - src4 + round_add) >> 5), 0, 255); dst[stride] = CLIP(((19 * src1 + 20 * src2 - src5 + 3 * (src4 - src0 - (src3<<1)) + round_add) >> 5), 0, 255); dst[2*stride] = CLIP(((20 * (src2 + src3) + (src0<<1) + 3 * (src5 - ((src1 + src4)<<1)) - src6 + round_add) >> 5), 0, 255); dst[3*stride] = CLIP(((20 * (src3 + src4) + 3 * ((src6 + src1) - ((src2 + src5)<<1)) - (src0 + src7) + round_add) >> 5), 0, 255); dst[4*stride] = CLIP(((20 * (src4 + src5) - 3 * (((src3 + src6)<<1) - (src2 + src7)) - (src1 + src8) + round_add) >> 5), 0, 255); dst[5*stride] = CLIP(((20 * (src5 + src6) - 3 * (((src4 + src7)<<1) - (src3 + src8)) - (src2 + src9) + round_add) >> 5), 0, 255); dst[6*stride] = CLIP(((20 * (src6 + src7) - 3 * (((src5 + src8)<<1) - (src4 + src9)) - (src3 + src10) + round_add) >> 5), 0, 255); dst[7*stride] = CLIP(((20 * (src7 + src8) - 3 * (((src6 + src9)<<1) - (src5 + src10)) - (src4 + src11) + round_add) >> 5), 0, 255); dst[8*stride] = CLIP(((20 * (src8 + src9) - 3 * (((src7 + src10)<<1) - (src6 + src11)) - (src5 + src12) + round_add) >> 5), 0, 255); dst[9*stride] = CLIP(((20 * (src9 + src10) - 3 * (((src8 + src11)<<1) - (src7 + src12)) - (src6 + src13) + round_add) >> 5), 0, 255); dst[10*stride] = CLIP(((20 * (src10 + src11) - 3 * (((src9 + src12)<<1) - (src8 + src13)) - (src7 + src14) + round_add) >> 5), 0, 255); dst[11*stride] = CLIP(((20 * (src11 + src12) - 3 * (((src10 + src13)<<1) - (src9 + src14)) - (src8 + src15) + round_add) >> 5), 0, 255); dst[12*stride] = CLIP(((20 * (src12 + src13) - 3 * (((src11 + src14)<<1) - (src10 + src15)) - (src9 + src16) + round_add) >> 5), 0, 255); dst[13*stride] = CLIP(((20 * (src13 + src14) + (src16<<1) + 3 * (src11 - ((src12 + src15) << 1)) - src10 + round_add) >> 5), 0, 255); dst[14*stride] = CLIP(((19 * src15 + 20 * src14 + 3 * (src12 - src16 - (src13 << 1)) - src11 + round_add) >> 5), 0, 255); dst[15*stride] = CLIP(((23 * src15 + 7 * ((src16<<1) - src14) + 3 * src13 - src12 + round_add) >> 5), 0, 255); dst++; src++; } } void interpolate8x8_lowpass_v_c(uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; for(i = 0; i < 9; i++) { int32_t src0 = src[0]; int32_t src1 = src[stride]; int32_t src2 = src[2 * stride]; int32_t src3 = src[3 * stride]; int32_t src4 = src[4 * stride]; int32_t src5 = src[5 * stride]; int32_t src6 = src[6 * stride]; int32_t src7 = src[7 * stride]; int32_t src8 = src[8 * stride]; dst[0] = CLIP(((7 * ((src0<<1) - src2) + 23 * src1 + 3 * src3 - src4 + round_add) >> 5), 0, 255); dst[stride] = CLIP(((19 * src1 + 20 * src2 - src5 + 3 * (src4 - src0 - (src3 << 1)) + round_add) >> 5), 0, 255); dst[2 * stride] = CLIP(((20 * (src2 + src3) + (src0<<1) + 3 * (src5 - ((src1 + src4) <<1 )) - src6 + round_add) >> 5), 0, 255); dst[3 * stride] = CLIP(((20 * (src3 + src4) + 3 * ((src6 + src1) - ((src2 + src5)<<1)) - (src0 + src7) + round_add) >> 5), 0, 255); dst[4 * stride] = CLIP(((20 * (src4 + src5) + 3 * ((src2 + src7) - ((src3 + src6)<<1)) - (src1 + src8) + round_add) >> 5), 0, 255); dst[5 * stride] = CLIP(((20 * (src5 + src6) + (src8<<1) + 3 * (src3 - ((src4 + src7) << 1)) - src2 + round_add) >> 5), 0, 255); dst[6 * stride] = CLIP(((19 * src7 + 20 * src6 - src3 + 3 * (src4 - src8 - (src5 << 1)) + round_add) >> 5), 0, 255); dst[7 * stride] = CLIP(((7 * ((src8<<1) - src6) + 23 * src7 + 3 * src5 - src4 + round_add) >> 5), 0, 255); dst++; src++; } } void interpolate16x16_lowpass_hv_c(uint8_t *dst1, uint8_t *dst2, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; uint8_t *h_ptr = dst2; for(i = 0; i < 17; i++) { h_ptr[0] = CLIP(((7 * ((src[0]<<1) - src[2]) + 23 * src[1] + 3 * src[3] - src[4] + round_add) >> 5), 0, 255); h_ptr[1] = CLIP(((19 * src[1] + 20 * src[2] - src[5] + 3 * (src[4] - src[0] - (src[3]<<1)) + round_add) >> 5), 0, 255); h_ptr[2] = CLIP(((20 * (src[2] + src[3]) + (src[0]<<1) + 3 * (src[5] - ((src[1] + src[4])<<1)) - src[6] + round_add) >> 5), 0, 255); h_ptr[3] = CLIP(((20 * (src[3] + src[4]) + 3 * ((src[6] + src[1]) - ((src[2] + src[5])<<1)) - (src[0] + src[7]) + round_add) >> 5), 0, 255); h_ptr[4] = CLIP(((20 * (src[4] + src[5]) - 3 * (((src[3] + src[6])<<1) - (src[2] + src[7])) - (src[1] + src[8]) + round_add) >> 5), 0, 255); h_ptr[5] = CLIP(((20 * (src[5] + src[6]) - 3 * (((src[4] + src[7])<<1) - (src[3] + src[8])) - (src[2] + src[9]) + round_add) >> 5), 0, 255); h_ptr[6] = CLIP(((20 * (src[6] + src[7]) - 3 * (((src[5] + src[8])<<1) - (src[4] + src[9])) - (src[3] + src[10]) + round_add) >> 5), 0, 255); h_ptr[7] = CLIP(((20 * (src[7] + src[8]) - 3 * (((src[6] + src[9])<<1) - (src[5] + src[10])) - (src[4] + src[11]) + round_add) >> 5), 0, 255); h_ptr[8] = CLIP(((20 * (src[8] + src[9]) - 3 * (((src[7] + src[10])<<1) - (src[6] + src[11])) - (src[5] + src[12]) + round_add) >> 5), 0, 255); h_ptr[9] = CLIP(((20 * (src[9] + src[10]) - 3 * (((src[8] + src[11])<<1) - (src[7] + src[12])) - (src[6] + src[13]) + round_add) >> 5), 0, 255); h_ptr[10] = CLIP(((20 * (src[10] + src[11]) - 3 * (((src[9] + src[12])<<1) - (src[8] + src[13])) - (src[7] + src[14]) + round_add) >> 5), 0, 255); h_ptr[11] = CLIP(((20 * (src[11] + src[12]) - 3 * (((src[10] + src[13])<<1) - (src[9] + src[14])) - (src[8] + src[15]) + round_add) >> 5), 0, 255); h_ptr[12] = CLIP(((20 * (src[12] + src[13]) - 3 * (((src[11] + src[14])<<1) - (src[10] + src[15])) - (src[9] + src[16]) + round_add) >> 5), 0, 255); h_ptr[13] = CLIP(((20 * (src[13] + src[14]) + (src[16]<<1) + 3 * (src[11] - ((src[12] + src[15]) << 1)) - src[10] + round_add) >> 5), 0, 255); h_ptr[14] = CLIP(((19 * src[15] + 20 * src[14] + 3 * (src[12] - src[16] - (src[13] << 1)) - src[11] + round_add) >> 5), 0, 255); h_ptr[15] = CLIP(((23 * src[15] + 7 * ((src[16]<<1) - src[14]) + 3 * src[13] - src[12] + round_add) >> 5), 0, 255); h_ptr += stride; src += stride; } interpolate16x16_lowpass_v_c(dst1, dst2, stride, rounding); } void interpolate8x8_lowpass_hv_c(uint8_t *dst1, uint8_t *dst2, uint8_t *src, int32_t stride, int32_t rounding) { int32_t i; uint8_t round_add = 16 - rounding; uint8_t *h_ptr = dst2; for(i = 0; i < 9; i++) { h_ptr[0] = CLIP(((7 * ((src[0]<<1) - src[2]) + 23 * src[1] + 3 * src[3] - src[4] + round_add) >> 5), 0, 255); h_ptr[1] = CLIP(((19 * src[1] + 20 * src[2] - src[5] + 3 * (src[4] - src[0] - (src[3]<<1)) + round_add) >> 5), 0, 255); h_ptr[2] = CLIP(((20 * (src[2] + src[3]) + (src[0]<<1) + 3 * (src[5] - ((src[1] + src[4])<<1)) - src[6] + round_add) >> 5), 0, 255); h_ptr[3] = CLIP(((20 * (src[3] + src[4]) + 3 * ((src[6] + src[1]) - ((src[2] + src[5])<<1)) - (src[0] + src[7]) + round_add) >> 5), 0, 255); h_ptr[4] = CLIP(((20 * (src[4] + src[5]) - 3 * (((src[3] + src[6])<<1) - (src[2] + src[7])) - (src[1] + src[8]) + round_add) >> 5), 0, 255); h_ptr[5] = CLIP(((20 * (src[5] + src[6]) + (src[8]<<1) + 3 * (src[3] - ((src[4] + src[7]) << 1)) - src[2] + round_add) >> 5), 0, 255); h_ptr[6] = CLIP(((19 * src[7] + 20 * src[6] + 3 * (src[4] - src[8] - (src[5] << 1)) - src[3] + round_add) >> 5), 0, 255); h_ptr[7] = CLIP(((23 * src[7] + 7 * ((src[8]<<1) - src[6]) + 3 * src[5] - src[4] + round_add) >> 5), 0, 255); h_ptr += stride; src += stride; } interpolate8x8_lowpass_v_c(dst1, dst2, stride, rounding); } --- NEW FILE: interpolate8x8.h --- #ifndef _INTERPOLATE8X8_H_ #define _INTERPOLATE8X8_H_ #include "../utils/mem_transfer.h" typedef void (INTERPOLATE8X8) (uint8_t * const dst, const uint8_t * const src, const uint32_t stride, const uint32_t rounding); typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR; typedef void (INTERPOLATE8X8_AVG2) (uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint32_t stride, const uint32_t rounding, const uint32_t height); typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR; typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4, const uint32_t stride, const uint32_t rounding); typedef INTERPOLATE8X8_AVG4 *INTERPOLATE8X8_AVG4_PTR; typedef void (INTERPOLATE_LOWPASS) (uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding); typedef INTERPOLATE_LOWPASS *INTERPOLATE_LOWPASS_PTR; typedef void (INTERPOLATE_LOWPASS_HV) (uint8_t *dst1, uint8_t *dst2, uint8_t *src, int32_t stride, int32_t rounding); typedef INTERPOLATE_LOWPASS_HV *INTERPOLATE_LOWPASS_HV_PTR; typedef void (INTERPOLATE8X8_6TAP_LOWPASS) (uint8_t *dst, uint8_t *src, int32_t stride, int32_t rounding); typedef INTERPOLATE8X8_6TAP_LOWPASS *INTERPOLATE8X8_6TAP_LOWPASS_PTR; extern INTERPOLATE8X8_PTR interpolate8x8_ha... [truncated message content] |
From: <mon...@us...> - 2003-10-19 17:48:48
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/prediction In directory sc8-pr-cvs1:/tmp/cvs-serv7163/prediction Log Message: Directory /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/prediction added to the repository |
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/motion In directory sc8-pr-cvs1:/tmp/cvs-serv7893/mplayerlibs/xvidcore/src/motion Added Files: motion.h motion_comp.c motion_est.c motion_est.h sad.c sad.h smp_motion_est.c smp_motion_est.h Log Message: Xvid latest CVS 2003-10-17 --- NEW FILE: motion.h --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * - Motion sad header - * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: motion.h,v 1.1 2003/10/19 16:20:45 monkeyhappy Exp $ * ***************************************************************************/ #ifndef _MOTION_H_ #define _MOTION_H_ #include "../portab.h" #include "../global.h" // fast ((A)/2)*2 #define EVEN(A) (((A)<0?(A)+1:(A)) & ~1) #define MVzero(A) ( ((A).x)==(0) && ((A).y)==(0) ) #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) /***************************************************************************** * Modified rounding tables -- defined in motion_est.c * Original tables see ISO spec tables 7-6 -> 7-9 ****************************************************************************/ extern const uint32_t roundtab[16]; /* K = 4 */ extern const uint32_t roundtab_76[16]; /* K = 2 */ extern const uint32_t roundtab_78[8]; /* K = 1 */ extern const uint32_t roundtab_79[4]; /* * getref: calculate reference image pointer * the decision to use interpolation h/v/hv or the normal image is * based on dx & dy. */ static __inline const uint8_t * get_ref(const uint8_t * const refn, const uint8_t * const refh, const uint8_t * const refv, const uint8_t * const refhv, const uint32_t x, const uint32_t y, const uint32_t block, /* block dimension, 8 or 16 */ const int32_t dx, const int32_t dy, const int32_t stride) { switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ case 0: return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); case 1: return refv + (int) ((x * block + dx / 2) + (y * block + (dy - 1) / 2) * stride); case 2: return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + dy / 2) * stride); default: return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + (dy - 1) / 2) * stride); } } void MotionEstimationBVOP(MBParam * const pParam, FRAMEINFO * const frame, // forward (past) reference const int32_t time_bp, const int32_t time_pp, const MACROBLOCK * const f_mbs, const IMAGE * const f_ref, const IMAGE * const f_refH, const IMAGE * const f_refV, const IMAGE * const f_refHV, // backward (future) reference const FRAMEINFO * const b_reference, const IMAGE * const b_ref, const IMAGE * const b_refH, const IMAGE * const b_refV, const IMAGE * const b_refHV); void MBMotionCompensationBVOP(MBParam * pParam, MACROBLOCK * const mb, const uint32_t i, const uint32_t j, IMAGE * const cur, const IMAGE * const f_ref, const IMAGE * const f_refh, const IMAGE * const f_refv, const IMAGE * const f_refhv, const IMAGE * const b_ref, const IMAGE * const b_refh, const IMAGE * const b_refv, const IMAGE * const b_refhv, int16_t * dct_codes); /* GMC stuff. Maybe better put it into a separate file */ void generate_GMCparameters( const int num_wp, // [input]: number of warppoints const int res, // [input]: resolution const WARPPOINTS *const warp, // [input]: warp points const int width, const int height, // [input]: without edges! GMC_DATA *const gmc); // [output] precalculated parameters void generate_GMCimage( const GMC_DATA *const gmc_data, // [input] precalculated data const IMAGE *const pRef, // [input] const int mb_width, const int mb_height, const int stride, const int stride2, const int fcode, // [input] some parameters... const int32_t quarterpel, // [input] for rounding avgMV const int reduced_resolution, // [input] ignored const int32_t rounding, // [input] for rounding image data MACROBLOCK *const pMBs, // [output] average motion vectors IMAGE *const pGMC); // [output] full warped image VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */ const IMAGE *const pRef, // [input] const int mi, const int mj, /* [input] MB position */ const int stride, /* [input] Lumi stride */ const int stride2, /* [input] chroma stride */ const int quarterpel, /* [input] for rounding of AvgMV */ const int rounding, IMAGE *const pGMC); /* [outut] generate image */ int MEanalysis( const IMAGE * const pRef, const FRAMEINFO * const Current, const MBParam * const pParam, const int maxIntra, const int intraCount, const int bCount, const int b_thresh); #endif /* _MOTION_H_ */ --- NEW FILE: motion_comp.c --- // 30.10.2002 corrected qpel chroma rounding // 04.10.2002 added qpel support to MBMotionCompensation // 01.05.2002 updated MBMotionCompensationBVOP // 14.04.2002 bframe compensation #include <stdio.h> #include "../encoder.h" #include "../utils/mbfunctions.h" #include "../image/interpolate8x8.h" #include "../image/reduced.h" #include "../utils/timer.h" #include "motion.h" #ifndef ABS #define ABS(X) (((X)>0)?(X):-(X)) #endif #ifndef SIGN #define SIGN(X) (((X)>0)?1:-1) [...1041 lines suppressed...] /* bilinear interpolation */ C00 = ((s-ri)*C00 + ri*C01); C10 = ((s-ri)*C10 + ri*C11); C00 = ((s-rj)*C00 + rj*C10 + s*s/2 - rounding ) >> (sigma+sigma); pGMC->v[J*stride2+I] = (uint8_t)C00; /* output 1 V-pixel */ } /* The average vector is rounded from 1/s-pel to 1/2 or 1/4 using the '//' operator*/ avgMV.x = RSHIFT( avgMV.x, (sigma+7-quarterpel) ); avgMV.y = RSHIFT( avgMV.y, (sigma+7-quarterpel) ); /* ^^^^ this is the way MS Reference Software does it */ return avgMV; /* clipping to fcode area is done outside! */ } #endif --- NEW FILE: motion_est.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * motion estimation * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * [...2630 lines suppressed...] if (bits >= Data->iMinSAD[0]) return bits; } bits += BITS_MULT*xvid_cbpy_tab[cbp>>2].len; //chroma U transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2); bits += Block_CalcBitsIntra(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 4, &dc); if (bits >= Data->iMinSAD[0]) return bits; //chroma V transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2); bits += Block_CalcBitsIntra(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 5, &dc); bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTRA & 7) | ((cbp & 3) << 3)].len; return bits; } --- NEW FILE: motion_est.h --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * - Motion estimation header - * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: motion_est.h,v 1.1 2003/10/19 16:20:45 monkeyhappy Exp $ * ***************************************************************************/ #ifndef _MOTION_EST_H_ #define _MOTION_EST_H_ #include "../portab.h" #include "../global.h" #include "../image/reduced.h" /* hard coded motion search parameters for motion_est and smp_motion_est */ // very large value #define MV_MAX_ERROR (4096 * 256) /* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ #define MV16_INTER_BIAS 512 /* vector map (vlc delta size) smoother parameters ! float !*/ #define NEIGH_TEND_16X16 10.5 #define NEIGH_TEND_8X8 40.0 #define NEIGH_8X8_BIAS 30 #define BITS_MULT 16 /* Parameters which control inter/inter4v decision */ #define IMV16X16 2 static const int lambda_vec16[32] = { 0 ,(int)(1.00235 * NEIGH_TEND_16X16 + 0.5), (int)(1.15582*NEIGH_TEND_16X16 + 0.5), (int)(1.31976*NEIGH_TEND_16X16 + 0.5), (int)(1.49591*NEIGH_TEND_16X16 + 0.5), (int)(1.68601*NEIGH_TEND_16X16 + 0.5), (int)(1.89187*NEIGH_TEND_16X16 + 0.5), (int)(2.11542*NEIGH_TEND_16X16 + 0.5), (int)(2.35878*NEIGH_TEND_16X16 + 0.5), (int)(2.62429*NEIGH_TEND_16X16 + 0.5), (int)(2.91455*NEIGH_TEND_16X16 + 0.5), (int)(3.23253*NEIGH_TEND_16X16 + 0.5), (int)(3.58158*NEIGH_TEND_16X16 + 0.5), (int)(3.96555*NEIGH_TEND_16X16 + 0.5), (int)(4.38887*NEIGH_TEND_16X16 + 0.5), (int)(4.85673*NEIGH_TEND_16X16 + 0.5), (int)(5.37519*NEIGH_TEND_16X16 + 0.5), (int)(5.95144*NEIGH_TEND_16X16 + 0.5), (int)(6.59408*NEIGH_TEND_16X16 + 0.5), (int)(7.31349*NEIGH_TEND_16X16 + 0.5), (int)(8.12242*NEIGH_TEND_16X16 + 0.5), (int)(9.03669*NEIGH_TEND_16X16 + 0.5), (int)(10.0763*NEIGH_TEND_16X16 + 0.5), (int)(11.2669*NEIGH_TEND_16X16 + 0.5), (int)(12.6426*NEIGH_TEND_16X16 + 0.5), (int)(14.2493*NEIGH_TEND_16X16 + 0.5), (int)(16.1512*NEIGH_TEND_16X16 + 0.5), (int)(18.442*NEIGH_TEND_16X16 + 0.5), (int)(21.2656*NEIGH_TEND_16X16 + 0.5), (int)(24.8580*NEIGH_TEND_16X16 + 0.5), (int)(29.6436*NEIGH_TEND_16X16 + 0.5), (int)(36.4949*NEIGH_TEND_16X16 + 0.5) }; static const int lambda_vec8[32] = { 0 ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5), (int)(1.15582 + NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), (int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5), (int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5), (int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5), (int)(2.91455*NEIGH_TEND_8X8 + 0.5), (int)(3.23253*NEIGH_TEND_8X8 + 0.5), (int)(3.58158*NEIGH_TEND_8X8 + 0.5), (int)(3.96555*NEIGH_TEND_8X8 + 0.5), (int)(4.38887*NEIGH_TEND_8X8 + 0.5), (int)(4.85673*NEIGH_TEND_8X8 + 0.5), (int)(5.37519*NEIGH_TEND_8X8 + 0.5), (int)(5.95144*NEIGH_TEND_8X8 + 0.5), (int)(6.59408*NEIGH_TEND_8X8 + 0.5), (int)(7.31349*NEIGH_TEND_8X8 + 0.5), (int)(8.12242*NEIGH_TEND_8X8 + 0.5), (int)(9.03669*NEIGH_TEND_8X8 + 0.5), (int)(10.0763*NEIGH_TEND_8X8 + 0.5), (int)(11.2669*NEIGH_TEND_8X8 + 0.5), (int)(12.6426*NEIGH_TEND_8X8 + 0.5), (int)(14.2493*NEIGH_TEND_8X8 + 0.5), (int)(16.1512*NEIGH_TEND_8X8 + 0.5), (int)(18.442*NEIGH_TEND_8X8 + 0.5), (int)(21.2656*NEIGH_TEND_8X8 + 0.5), (int)(24.8580*NEIGH_TEND_8X8 + 0.5), (int)(29.6436*NEIGH_TEND_8X8 + 0.5), (int)(36.4949*NEIGH_TEND_8X8 + 0.5) }; // mv.length table static const int mvtab[64] = { 1, 2, 3, 4, 6, 7, 7, 7, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }; static const int DQtab[4] = { -1, -2, 1, 2 }; #define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) typedef struct { // general fields int max_dx, min_dx, max_dy, min_dy; uint32_t rounding; VECTOR predMV; VECTOR * currentMV; VECTOR * currentQMV; int32_t * iMinSAD; const uint8_t * RefP[6]; // N, V, H, HV, cU, cV const uint8_t * CurU; const uint8_t * CurV; uint8_t * RefQ; const uint8_t * Cur; uint32_t lambda16; uint32_t lambda8; uint32_t iEdgedWidth; uint32_t iFcode; int * temp; int qpel, qpel_precision; int chroma; int rrv; //fields for interpolate and direct modes const uint8_t * b_RefP[6]; // N, V, H, HV, cU, cV VECTOR bpredMV; uint32_t bFcode; // fields for direct mode VECTOR directmvF[4]; VECTOR directmvB[4]; const VECTOR * referencemv; // BITS/R-D stuff int16_t * dctSpace; uint32_t iQuant; uint32_t quant_type; } SearchData; typedef void(CheckFunc)(const int x, const int y, const int Direction, int * const dir, const SearchData * const Data); CheckFunc *CheckCandidate; /* * Calculate the min/max range * relative to the _MACROBLOCK_ position */ static void __inline get_range(int32_t * const min_dx, int32_t * const max_dx, int32_t * const min_dy, int32_t * const max_dy, const uint32_t x, const uint32_t y, uint32_t block_sz, /* block dimension, 8 or 16 */ const uint32_t width, const uint32_t height, const uint32_t fcode, const int qpel, /* 1 if the resulting range should be in qpel precision; otherwise 0 */ const int rrv) { int k, m = qpel ? 4 : 2; const int search_range = 32 << (fcode - 1); int high = search_range - 1; int low = -search_range; if (rrv) { high = RRV_MV_SCALEUP(high); low = RRV_MV_SCALEUP(low); block_sz *= 2; } k = m * (int)(width - x * block_sz); *max_dx = MIN(high, k); k = m * (int)(height - y * block_sz); *max_dy = MIN(high, k); k = -m * (int)((x+1) * block_sz); *min_dx = MAX(low, k); k = -m * (int)((y+1) * block_sz); *min_dy = MAX(low, k); } typedef void MainSearchFunc(int x, int y, const SearchData * const Data, int bDirection); static MainSearchFunc DiamondSearch, AdvDiamondSearch, SquareSearch; static void Search8(const SearchData * const OldData, const int x, const int y, const uint32_t MotionFlags, const MBParam * const pParam, MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, const int block, SearchData * const Data); bool MotionEstimation(MBParam * const pParam, FRAMEINFO * const current, FRAMEINFO * const reference, const IMAGE * const pRefH, const IMAGE * const pRefV, const IMAGE * const pRefHV, const uint32_t iLimit); static void SearchP(const IMAGE * const pRef, const uint8_t * const pRefH, const uint8_t * const pRefV, const uint8_t * const pRefHV, const IMAGE * const pCur, const int x, const int y, const uint32_t MotionFlags, const uint32_t GlobalFlags, SearchData * const Data, const MBParam * const pParam, const MACROBLOCK * const pMBs, const MACROBLOCK * const prevMBs, MACROBLOCK * const pMB); static WARPPOINTS GlobalMotionEst(const MACROBLOCK * const pMBs, const MBParam * const pParam, const FRAMEINFO * const current, const FRAMEINFO * const reference, const IMAGE * const pRefH, const IMAGE * const pRefV, const IMAGE * const pRefHV ); #define iDiamondSize 2 static __inline uint32_t MakeGoodMotionFlags(const uint32_t MotionFlags, const uint32_t GlobalFlags) { uint32_t Flags = MotionFlags; if (!(GlobalFlags & XVID_MODEDECISION_BITS)) Flags &= ~(QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS+HALFPELREFINE16_BITS+HALFPELREFINE8_BITS+EXTSEARCH_BITS); if (Flags & EXTSEARCH_BITS) Flags |= HALFPELREFINE16_BITS; if (Flags & EXTSEARCH_BITS && MotionFlags & PMV_EXTSEARCH8) Flags |= HALFPELREFINE8_BITS; if (Flags & HALFPELREFINE16_BITS) Flags |= QUARTERPELREFINE16_BITS; if (Flags & HALFPELREFINE8_BITS) { Flags |= QUARTERPELREFINE8_BITS; Flags &= ~PMV_HALFPELREFINE8; } if (Flags & QUARTERPELREFINE8_BITS) Flags &= ~PMV_QUARTERPELREFINE8; if (Flags & QUARTERPELREFINE16_BITS) Flags &= ~PMV_QUARTERPELREFINE16; if (!(GlobalFlags & XVID_QUARTERPEL)) Flags &= ~(PMV_QUARTERPELREFINE16+PMV_QUARTERPELREFINE8+QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS); if (!(GlobalFlags & XVID_HALFPEL)) Flags &= ~(PMV_EXTSEARCH16+PMV_HALFPELREFINE16+PMV_HALFPELREFINE8+HALFPELREFINE16_BITS+HALFPELREFINE8_BITS); if (GlobalFlags & (XVID_GREYSCALE + XVID_REDUCED)) Flags &= ~(PMV_CHROMA16 + PMV_CHROMA8); return Flags; } /* BITS mode decision and search */ #include "../bitstream/zigzag.h" #include "../quant/quant_mpeg4.h" #include "../quant/quant_h263.h" #include "../bitstream/vlc_codes.h" #include "../dct/fdct.h" static int CountMBBitsInter(SearchData * const Data, const MACROBLOCK * const pMBs, const int x, const int y, const MBParam * const pParam, const uint32_t MotionFlags); static int CountMBBitsInter4v(const SearchData * const Data, MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, const int x, const int y, const MBParam * const pParam, const uint32_t MotionFlags, const VECTOR * const backup); static int CountMBBitsIntra(const SearchData * const Data); int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); /* one over lambda for R-D mode decision and motion search */ #define LAMBDA ( (int)(BITS_MULT/1.0) ) static __inline unsigned int Block_CalcBits( int16_t * const coeff, int16_t * const data, int16_t * const dqcoeff, const uint32_t quant, const int quant_type, uint32_t * cbp, const int block) { int sum; int bits; int distortion = 0; int i; fdct(data); if (quant_type == 0) sum = quant_inter(coeff, data, quant); else sum = quant4_inter(coeff, data, quant); if (sum > 0) { *cbp |= 1 << (5 - block); bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_tables[0]); } else bits = 0; if (quant_type == 0) dequant_inter(dqcoeff, coeff, quant); else dequant4_inter(dqcoeff, coeff, quant); for (i = 0; i < 64; i++) { distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); } bits += (LAMBDA*distortion)/(quant*quant); return bits; } static __inline unsigned int Block_CalcBitsIntra(int16_t * const coeff, int16_t * const data, int16_t * const dqcoeff, const uint32_t quant, const int quant_type, uint32_t * cbp, const int block, int * dcpred) { int bits, i; int distortion = 0; uint32_t iDcScaler = get_dc_scaler(quant, block < 4); int b_dc; fdct(data); data[0] -= 1024; if (quant_type == 0) quant_intra(coeff, data, quant, iDcScaler); else quant4_intra(coeff, data, quant, iDcScaler); b_dc = coeff[0]; if (block < 4) { coeff[0] -= *dcpred; *dcpred = b_dc; } bits = BITS_MULT*CodeCoeffIntra_CalcBits(coeff, scan_tables[0]); if (bits != 0) *cbp |= 1 << (5 - block); if (block < 4) bits += BITS_MULT*dcy_tab[coeff[0] + 255].len; else bits += BITS_MULT*dcc_tab[coeff[0] + 255].len; coeff[0] = b_dc; if (quant_type == 0) dequant_intra(dqcoeff, coeff, quant, iDcScaler); else dequant4_intra(dqcoeff, coeff, quant, iDcScaler); for (i = 0; i < 64; i++) { distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); } bits += (LAMBDA*distortion)/(quant*quant); return bits; } #endif /* _MOTION_EST_H_ */ --- NEW FILE: sad.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * sum of absolute difference * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /************************************************************************** * * History: * * 14.02.2002 added sad16bi_c() * 10.11.2001 initial version; (c)2001 peter ross <pr...@cs...> * *************************************************************************/ #include "../portab.h" #include "../global.h" #include "sad.h" sad16FuncPtr sad16; sad8FuncPtr sad8; sad16biFuncPtr sad16bi; sad8biFuncPtr sad8bi; // not really sad16, but no difference in prototype dev16FuncPtr dev16; sad16vFuncPtr sad16v; sadInitFuncPtr sadInit; uint32_t sad16_c(const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, const uint32_t best_sad) { uint32_t sad = 0; uint32_t j; uint8_t const *ptr_cur = cur; uint8_t const *ptr_ref = ref; for (j = 0; j < 16; j++) { sad += ABS(ptr_cur[0] - ptr_ref[0]); sad += ABS(ptr_cur[1] - ptr_ref[1]); sad += ABS(ptr_cur[2] - ptr_ref[2]); sad += ABS(ptr_cur[3] - ptr_ref[3]); sad += ABS(ptr_cur[4] - ptr_ref[4]); sad += ABS(ptr_cur[5] - ptr_ref[5]); sad += ABS(ptr_cur[6] - ptr_ref[6]); sad += ABS(ptr_cur[7] - ptr_ref[7]); sad += ABS(ptr_cur[8] - ptr_ref[8]); sad += ABS(ptr_cur[9] - ptr_ref[9]); sad += ABS(ptr_cur[10] - ptr_ref[10]); sad += ABS(ptr_cur[11] - ptr_ref[11]); sad += ABS(ptr_cur[12] - ptr_ref[12]); sad += ABS(ptr_cur[13] - ptr_ref[13]); sad += ABS(ptr_cur[14] - ptr_ref[14]); sad += ABS(ptr_cur[15] - ptr_ref[15]); if (sad >= best_sad) return sad; ptr_cur += stride; ptr_ref += stride; } return sad; } uint32_t sad16bi_c(const uint8_t * const cur, const uint8_t * const ref1, const uint8_t * const ref2, const uint32_t stride) { uint32_t sad = 0; uint32_t i, j; uint8_t const *ptr_cur = cur; uint8_t const *ptr_ref1 = ref1; uint8_t const *ptr_ref2 = ref2; for (j = 0; j < 16; j++) { for (i = 0; i < 16; i++) { int pixel = (ptr_ref1[i] + ptr_ref2[i] + 1) / 2; sad += ABS(ptr_cur[i] - pixel); } ptr_cur += stride; ptr_ref1 += stride; ptr_ref2 += stride; } return sad; } uint32_t sad8bi_c(const uint8_t * const cur, const uint8_t * const ref1, const uint8_t * const ref2, const uint32_t stride) { uint32_t sad = 0; uint32_t i, j; uint8_t const *ptr_cur = cur; uint8_t const *ptr_ref1 = ref1; uint8_t const *ptr_ref2 = ref2; for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { int pixel = (ptr_ref1[i] + ptr_ref2[i] + 1) / 2; sad += ABS(ptr_cur[i] - pixel); } ptr_cur += stride; ptr_ref1 += stride; ptr_ref2 += stride; } return sad; } uint32_t sad8_c(const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride) { uint32_t sad = 0; uint32_t j; uint8_t const *ptr_cur = cur; uint8_t const *ptr_ref = ref; for (j = 0; j < 8; j++) { sad += ABS(ptr_cur[0] - ptr_ref[0]); sad += ABS(ptr_cur[1] - ptr_ref[1]); sad += ABS(ptr_cur[2] - ptr_ref[2]); sad += ABS(ptr_cur[3] - ptr_ref[3]); sad += ABS(ptr_cur[4] - ptr_ref[4]); sad += ABS(ptr_cur[5] - ptr_ref[5]); sad += ABS(ptr_cur[6] - ptr_ref[6]); sad += ABS(ptr_cur[7] - ptr_ref[7]); ptr_cur += stride; ptr_ref += stride; } return sad; } /* average deviation from mean */ uint32_t dev16_c(const uint8_t * const cur, const uint32_t stride) { uint32_t mean = 0; uint32_t dev = 0; uint32_t i, j; uint8_t const *ptr_cur = cur; for (j = 0; j < 16; j++) { for (i = 0; i < 16; i++) mean += *(ptr_cur + i); ptr_cur += stride; } mean /= (16 * 16); ptr_cur = cur; for (j = 0; j < 16; j++) { for (i = 0; i < 16; i++) dev += ABS(*(ptr_cur + i) - (int32_t) mean); ptr_cur += stride; } return dev; } uint32_t sad16v_c(const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, int32_t *sad) { sad[0] = sad8(cur, ref, stride); sad[1] = sad8(cur + 8, ref + 8, stride); sad[2] = sad8(cur + 8*stride, ref + 8*stride, stride); sad[3] = sad8(cur + 8*stride + 8, ref + 8*stride + 8, stride); return sad[0]+sad[1]+sad[2]+sad[3]; } uint32_t sad32v_c(const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, int32_t *sad) { sad[0] = sad16(cur, ref, stride, 256*4096); sad[1] = sad16(cur + 8, ref + 8, stride, 256*4096); sad[2] = sad16(cur + 8*stride, ref + 8*stride, stride, 256*4096); sad[3] = sad16(cur + 8*stride + 8, ref + 8*stride + 8, stride, 256*4096); return sad[0]+sad[1]+sad[2]+sad[3]; } #define MRSAD16_CORRFACTOR 8 uint32_t mrsad16_c(const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, const uint32_t best_sad) { uint32_t sad = 0; int32_t mean = 0; uint32_t i, j; uint8_t const *ptr_cur = cur; uint8_t const *ptr_ref = ref; for (j = 0; j < 16; j++) { for (i = 0; i < 16; i++) { mean += ((int) *(ptr_cur + i) - (int) *(ptr_ref + i)); } ptr_cur += stride; ptr_ref += stride; } mean /= 256; for (j = 0; j < 16; j++) { ptr_cur -= stride; ptr_ref -= stride; for (i = 0; i < 16; i++) { sad += ABS(*(ptr_cur + i) - *(ptr_ref + i) - mean); if (sad >= best_sad) { return MRSAD16_CORRFACTOR * sad; } } } return MRSAD16_CORRFACTOR * sad; } --- NEW FILE: sad.h --- #ifndef _ENCODER_SAD_H_ #define _ENCODER_SAD_H_ #include "../portab.h" typedef void (sadInitFunc) (void); typedef sadInitFunc *sadInitFuncPtr; extern sadInitFuncPtr sadInit; sadInitFunc sadInit_altivec; typedef uint32_t(sad16Func) (const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, const uint32_t best_sad); typedef sad16Func *sad16FuncPtr; extern sad16FuncPtr sad16; sad16Func sad16_c; sad16Func sad16_mmx; sad16Func sad16_xmm; sad16Func sad16_3dne; sad16Func sad16_sse2; sad16Func sad16_altivec; sad16Func sad16_ia64; sad16Func mrsad16_c; typedef uint32_t(sad8Func) (const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride); typedef sad8Func *sad8FuncPtr; extern sad8FuncPtr sad8; sad8Func sad8_c; sad8Func sad8_mmx; sad8Func sad8_xmm; sad8Func sad8_3dne; sad8Func sad8_altivec; sad8Func sad8_ia64; typedef uint32_t(sad16biFunc) (const uint8_t * const cur, const uint8_t * const ref1, const uint8_t * const ref2, const uint32_t stride); typedef sad16biFunc *sad16biFuncPtr; extern sad16biFuncPtr sad16bi; sad16biFunc sad16bi_c; sad16biFunc sad16bi_ia64; sad16biFunc sad16bi_mmx; sad16biFunc sad16bi_xmm; sad16biFunc sad16bi_3dne; sad16biFunc sad16bi_3dn; typedef uint32_t(sad8biFunc) (const uint8_t * const cur, const uint8_t * const ref1, const uint8_t * const ref2, const uint32_t stride); typedef sad8biFunc *sad8biFuncPtr; extern sad8biFuncPtr sad8bi; sad8biFunc sad8bi_c; sad8biFunc sad8bi_mmx; sad8biFunc sad8bi_xmm; sad8biFunc sad8bi_3dne; sad8biFunc sad8bi_3dn; typedef uint32_t(dev16Func) (const uint8_t * const cur, const uint32_t stride); typedef dev16Func *dev16FuncPtr; extern dev16FuncPtr dev16; dev16Func dev16_c; dev16Func dev16_mmx; dev16Func dev16_xmm; dev16Func dev16_3dne; dev16Func dev16_sse2; dev16Func dev16_altivec; dev16Func dev16_ia64; typedef uint32_t (sad16vFunc)( const uint8_t * const cur, const uint8_t * const ref, const uint32_t stride, int32_t *sad8); typedef sad16vFunc *sad16vFuncPtr; extern sad16vFuncPtr sad16v; sad16vFunc sad16v_xmm; sad16vFunc sad16v_mmx; sad16vFunc sad16v_c; sad16vFunc sad32v_c; sad16vFunc mrsad16v; sad16vFunc mrsad16v_c; int32_t sad8x8mean_mmx( const uint8_t * const current, const uint8_t * const reference, const uint32_t stride, const int mean); void sad16x8total_mmx(const uint8_t *, const uint32_t, int32_t[]); #endif /* _ENCODER_SAD_H_ */ --- NEW FILE: smp_motion_est.c --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * multithreaded motion estimation * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ /* WARNING ! * This is early alpha code, only published for debugging and testing * I cannot garantee that it will not break compiliing, encoding * or your marriage etc. YOU HAVE BEEN WARNED! */ #ifdef _SMP #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <signal.h> #ifndef WIN32 #include <unistd.h> #endif #include "../encoder.h" #include "../utils/mbfunctions.h" #include "../prediction/mbprediction.h" #include "../global.h" #include "../utils/timer.h" #include "motion.h" #include "sad.h" #include "smp_motion_est.h" /* global variables for SMP search control, the are not needed anywhere else than here */ pthread_mutex_t me_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t me_inqueue_cond = PTHREAD_COND_INITIALIZER; pthread_cond_t me_corrqueue_cond = PTHREAD_COND_INITIALIZER; pthread_cond_t me_outqueue_cond = PTHREAD_COND_INITIALIZER; int me_iIntra=0; int me_inqueue=0; // input queue int me_corrqueue=0; // correction queue int me_outqueue=0; // output queue void SMP_correct_pmv(int x, int y, int iWcount, MACROBLOCK* pMBs) { MACROBLOCK *const pMB = &pMBs[x + y * iWcount]; VECTOR pmv; int k; switch (pMB->mode) { case MODE_INTER: case MODE_INTER_Q: pmv = get_pmv2(pMBs, iWcount, 0, x, y, 0); pMB->pmvs[0].x = pMB->mvs[0].x - pmv.x; pMB->pmvs[0].y = pMB->mvs[0].y - pmv.y; break; case MODE_INTER4V: for (k=0;k<4;k++) { pmv = get_pmv2(pMBs, iWcount, 0, x, y, k); pMB->pmvs[k].x = pMB->mvs[k].x - pmv.x; pMB->pmvs[k].y = pMB->mvs[k].y - pmv.y; } break; default: break; /* e.g. everything without prediction, e.g. MODE_INTRA */ } return; } void SMP_MotionEstimationWorker(jobdata *arg) { const VECTOR zeroMV = { 0, 0 }; // long long time; int32_t x, y; VECTOR pmv; globaldata* gdata; MBParam * pParam; FRAMEINFO * current; FRAMEINFO * reference; IMAGE * pRefH; IMAGE * pRefV; IMAGE * pRefHV; // uint32_t iLimit; uint32_t iWcount; uint32_t iHcount; MACROBLOCK * pMBs; MACROBLOCK * prevMBs; IMAGE * pCurrent; IMAGE * pRef; int minx = arg->minx; int maxx = arg->maxx; int miny = arg->miny; int maxy = arg->maxy; // int run=0; int iIntra; pthread_mutex_lock(&me_mutex); while (1) { // run++; iIntra = 0; // fprintf(stderr,"[%d,%d] wait inqueue %d init\n",arg->id,run,me_inqueue); while (!me_inqueue) pthread_cond_wait(&me_inqueue_cond,&me_mutex); // fprintf(stderr,"[%d,%d] wait inqueue %d done\n",arg->id,run,me_inqueue); me_inqueue--; pthread_mutex_unlock(&me_mutex); gdata = arg->gdata; pParam = gdata->pParam; current = gdata->current; reference = gdata->reference; pRefH = gdata->pRefH; pRefV = gdata->pRefV; pRefHV = gdata->pRefHV; // iLimit = gdata->iLimit; iWcount = pParam->mb_width; iHcount = pParam->mb_height; pMBs = current->mbs; prevMBs = reference->mbs; pCurrent = ¤t->image; pRef = &reference->image; // time = read_counter(); for (y = miny; y < maxy; y++) { for (x = minx; x < maxx; x++) { MACROBLOCK *const pMB = &pMBs[x + y * iWcount]; pMB->sad16 = SEARCH16(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, y, current->motion_flags, current->quant, current->fcode, pParam, pMBs, prevMBs, &pMB->mv16, &pMB->pmvs[0]); if (0 < (pMB->sad16 - MV16_INTER_BIAS)) { int32_t deviation; deviation = dev16(pCurrent->y + x * 16 + y * 16 * pParam->edged_width, pParam->edged_width); if (deviation < (pMB->sad16 - MV16_INTER_BIAS)) { pMB->mode = MODE_INTRA; pMB->mv16 = pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = zeroMV; pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = 0; iIntra++; continue; } } pmv = pMB->pmvs[0]; if (current->global_flags & XVID_INTER4V) if ((!(current->global_flags & XVID_LUMIMASKING) || pMB->dquant == NO_CHANGE)) { int32_t sad8 = IMV16X16 * current->quant; if (sad8 < pMB->sad16) sad8 += pMB->sad8[0] = SEARCH8(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, 2 * x, 2 * y, pMB->mv16.x, pMB->mv16.y, current->motion_flags, current->quant, current->fcode, pParam, pMBs, prevMBs, &pMB->mvs[0], &pMB->pmvs[0]); if (sad8 < pMB->sad16) sad8 += pMB->sad8[1] = SEARCH8(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, 2 * x + 1, 2 * y, pMB->mv16.x, pMB->mv16.y, current->motion_flags, current->quant, current->fcode, pParam, pMBs, prevMBs, &pMB->mvs[1], &pMB->pmvs[1]); if (sad8 < pMB->sad16) sad8 += pMB->sad8[2] = SEARCH8(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, 2 * x, 2 * y + 1, pMB->mv16.x, pMB->mv16.y, current->motion_flags, current->quant, current->fcode, pParam, pMBs, prevMBs, &pMB->mvs[2], &pMB->pmvs[2]); if (sad8 < pMB->sad16) sad8 += pMB->sad8[3] = SEARCH8(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, 2 * x + 1, 2 * y + 1, pMB->mv16.x, pMB->mv16.y, current->motion_flags, current->quant, current->fcode, pParam, pMBs, prevMBs, &pMB->mvs[3], &pMB->pmvs[3]); /* decide: MODE_INTER or MODE_INTER4V mpeg4: if (sad8 < pMB->sad16 - nb/2+1) use_inter4v */ if (sad8 < pMB->sad16) { pMB->mode = MODE_INTER4V; pMB->sad8[0] *= 4; pMB->sad8[1] *= 4; pMB->sad8[2] *= 4; pMB->sad8[3] *= 4; continue; } } pMB->mode = MODE_INTER; pMB->pmvs[0] = pmv; /* pMB->pmvs[1] = pMB->pmvs[2] = pMB->pmvs[3] are not needed for INTER */ pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->mv16; pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = pMB->sad16; } } /* end of x/y loop */ // fprintf(stderr,"[%d,%d] Full ME %lld ticks \n",arg->id,run,read_counter()-time); pthread_mutex_lock(&me_mutex); me_corrqueue--; // the last to finish wakes the others to start correction me_iIntra += iIntra; if (me_corrqueue==0) { // fprintf(stderr,"[%d,%d] corrqueue %d waking neighbours\n",arg->id,run,me_corrqueue); pthread_cond_broadcast(&me_corrqueue_cond); } // fprintf(stderr,"[%d,%d] wait corrqueue %d init\n",arg->id,run,me_corrqueue); while (me_corrqueue) pthread_cond_wait(&me_corrqueue_cond,&me_mutex); // fprintf(stderr,"[%d,%d] wait corrqueue %d done\n",arg->id,run,me_corrqueue); // time = read_counter(); // if (me_iIntra <= iLimit) // { // pthread_mutex_unlock(&me_mutex); if (minx!=0) for (y=miny; y<maxy; y++) SMP_correct_pmv(minx, y,iWcount,pMBs); if (maxx!=iWcount) for (y=miny; y<maxy; y++) SMP_correct_pmv(maxx-1,y,iWcount,pMBs); if (miny!=0) for (x=minx;x<maxx; x++) SMP_correct_pmv(x,miny, iWcount,pMBs); if (maxy!=iHcount) for (x=minx;x<maxx; x++) SMP_correct_pmv(x,maxy-1,iWcount,pMBs); // pthread_mutex_lock(&me_mutex); // } // fprintf(stderr,"[%d,%d] Full CORR %lld ticks \n",arg->id,run,read_counter()-time); me_outqueue--; if (me_outqueue==0) // the last to finish wakes the master pthread_cond_signal(&me_outqueue_cond); // fprintf(stderr,"[%d,%d] wait outqueue %d init\n",arg->id,run,me_outqueue); // while (me_outqueue) // pthread_cond_wait(&me_outqueue_cond,&me_mutex); // fprintf(stderr,"[%d,%d] wait outqueue %d done\n",arg->id,run,me_outqueue); } /* end of while(1) */ pthread_mutex_unlock(&me_mutex); } bool SMP_MotionEstimation(MBParam * const pParam, FRAMEINFO * const current, FRAMEINFO * const reference, const IMAGE * const pRefH, const IMAGE * const pRefV, const IMAGE * const pRefHV, const uint32_t iLimit) { int i; static int threadscreated=0; const int iWcount = pParam->mb_width; const int iHcount = pParam->mb_height; static globaldata gdata; static jobdata jdata[MAXNUMTHREADS]; static pthread_t me_thread[MAXNUMTHREADS]; gdata.pParam = pParam; gdata.reference = reference; gdata.current = current; gdata.pRefH = pRefH; gdata.pRefV = pRefV; gdata.pRefHV = pRefHV; // gdata.iLimit = iLimit; if (sadInit) (*sadInit) (); pthread_mutex_lock(&me_mutex); me_iIntra=0; me_inqueue=pParam->num_threads; me_corrqueue=pParam->num_threads; me_outqueue=pParam->num_threads; if (!threadscreated) { for (i=0;i<pParam->num_threads;i++) { /* split domain into NUMTHREADS parts */ jdata[i].id = i; jdata[i].minx = i*iWcount/pParam->num_threads; jdata[i].maxx = (i+1)*iWcount/pParam->num_threads; jdata[i].miny = 0; jdata[i].maxy = iHcount; jdata[i].gdata = &gdata; pthread_create(&me_thread[i],NULL, (void*)SMP_MotionEstimationWorker,(void*)&jdata[i]); } threadscreated=1; } pthread_cond_broadcast(&me_inqueue_cond); // start working while (me_outqueue) pthread_cond_wait(&me_outqueue_cond,&me_mutex); if (me_iIntra > iLimit) { pthread_mutex_unlock(&me_mutex); return 1; } pthread_mutex_unlock(&me_mutex); return 0; } #endif --- NEW FILE: smp_motion_est.h --- /************************************************************************** * * XVID MPEG-4 VIDEO CODEC * - SMP Motion search header - * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are * advised that its use may infringe existing patents or copyrights, and * any such use would be at such party's own risk. The original * developer of this software module and his/her company, and subsequent * editors and their companies, will have no liability for use of this * software or modifications or derivatives thereof. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: smp_motion_est.h,v 1.1 2003/10/19 16:20:45 monkeyhappy Exp $ * ***************************************************************************/ #ifndef _SMP_MOTION_EST_H #define _SMP_MOTION_EST_H #ifdef _SMP #define MAXNUMTHREADS 16 //#define NUMTHREADS 2 typedef struct { MBParam * pParam; FRAMEINFO* reference; FRAMEINFO* current; IMAGE* pRef; IMAGE* pRefH; IMAGE* pRefV; IMAGE* pRefHV; // int iLimit; /* currently unused */ MACROBLOCK * pMBs; MACROBLOCK * prevMBs; } globaldata; /* this data is the same for all threads */ typedef struct { int id; int minx; int maxx; int miny; int maxy; globaldata *gdata; } jobdata; /* every thread get it's personal version of these */ void SMP_correct_pmv(int x, int y, int iWcount, MACROBLOCK* pMBs); void SMP_MotionEstimationWorker(jobdata *arg); bool SMP_MotionEstimation(MBParam * const pParam, FRAMEINFO * const current, FRAMEINFO * const reference, const IMAGE * const pRefH, const IMAGE * const pRefV, const IMAGE * const pRefHV, const uint32_t iLimit); #endif #endif |
From: <mon...@us...> - 2003-10-19 17:43:52
|
Update of /cvsroot/xbplayer/XBMP/mplayer In directory sc8-pr-cvs1:/tmp/cvs-serv18585/mplayer Modified Files: libxvidcored.lib Log Message: Xvid latest CVS 2003-10-17 Index: libxvidcored.lib =================================================================== RCS file: /cvsroot/xbplayer/XBMP/mplayer/libxvidcored.lib,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 Binary files /tmp/cvs9eRvK9 and /tmp/cvsDU2raP differ |
From: <mon...@us...> - 2003-10-19 17:32:10
|
Update of /cvsroot/xbplayer/XBMP/mplayerlibs/xvidcore/src/mesh In directory sc8-pr-cvs1:/tmp/cvs-serv7893/mplayerlibs/xvidcore/src/mesh Added Files: readme.txt Log Message: Xvid latest CVS 2003-10-17 --- NEW FILE: readme.txt --- I will add the Mesh support in here! |