Changeset 45

Show
Ignore:
Timestamp:
05/04/08 16:52:40 (4 months ago)
Author:
sip
Message:

Fixed overlaped image on mosaic

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • media/include/framescaler.h

    r42 r45  
    1010public: 
    1111        FrameScaler(); 
     12        ~FrameScaler(); 
    1213        int SetResize(int srcWidth,int srcHeight,int srcLineWidth,int dstWidth,int dstHeight,int dstLineWidth); 
    1314        int Resize(BYTE *srcY,BYTE *srcU,BYTE *srcV,BYTE *dstY, BYTE *dstU, BYTE *dstV); 
     
    1920        int     resizeDstWidth; 
    2021        int     resizeDstHeight; 
     22        int     resizeDstLineWidth; 
    2123        int     resizeSrc[3]; 
    2224        int     resizeDst[3]; 
    2325        int     resizeFlags; 
     26        int     tmpWidth; 
     27        int     tmpHeight; 
     28        int     tmpBufferSize; 
     29        BYTE*   tmpBuffer; 
     30        BYTE*   tmpY; 
     31        BYTE*   tmpU; 
     32        BYTE*   tmpV; 
     33 
    2434}; 
    2535 
  • media/src/framescaler.cpp

    r29 r45  
    11#include <framescaler.h> 
     2#include <stdlib.h> 
     3#include <stdio.h> 
     4#include <string.h> 
     5 
    26 
    37FrameScaler::FrameScaler() 
     
    913        resizeDstWidth  = 0; 
    1014        resizeDstHeight = 0; 
     15        resizeDstLineWidth = 0; 
     16 
     17        //tmp buffer 
     18        tmpWidth        = 0; 
     19        tmpHeight       = 0; 
     20        tmpBuffer       = NULL; 
     21        tmpBufferSize   = 0; 
     22        tmpY            = NULL; 
     23        tmpU            = NULL; 
     24        tmpV            = NULL; 
    1125 
    1226        // Bicubic by default  
    1327        resizeFlags     = SWS_BICUBIC; 
     28} 
     29FrameScaler::~FrameScaler() 
     30{ 
     31        //Free mem 
     32        if (tmpBuffer) 
     33                //free 
     34                free(tmpBuffer); 
     35        //Close resizer 
     36        //?? 
    1437} 
    1538 
     
    3861        resizeDstWidth  = dstWidth; 
    3962        resizeDstHeight = dstHeight; 
     63        resizeDstLineWidth = dstLineWidth; 
     64 
     65 
     66        //to use MM2 we need the width and heinght to be multiple of 32 
     67        tmpWidth = (resizeDstWidth/32 +1)*32; 
     68        tmpHeight = (resizeDstHeight/32 +1)*32; 
     69 
     70        //Get tmp buffer size 
     71        tmpBufferSize = tmpWidth*tmpHeight*3/2; 
     72 
     73        //Check if we had it already 
     74        if (tmpBuffer) 
     75                //Free it 
     76                free(tmpBuffer); 
     77 
     78        //Allocate it 
     79        tmpBuffer = (BYTE*)malloc(tmpBufferSize); 
    4080 
    4181        // Set values for line sizes 
     
    4383        resizeSrc[1] = srcLineWidth/2; 
    4484        resizeSrc[2] = srcLineWidth/2; 
    45         resizeDst[0] = dstLineWidth; 
     85        /*resizeDst[0] = dstLineWidth; 
    4686        resizeDst[1] = dstLineWidth/2; 
    47         resizeDst[2] = dstLineWidth/2; 
     87        resizeDst[2] = dstLineWidth/2;*/ 
     88        resizeDst[0] = tmpWidth; 
     89        resizeDst[1] = tmpWidth/2; 
     90        resizeDst[2] = tmpWidth/2; 
     91 
     92        //Get tmp planes 
     93        tmpY = tmpBuffer; 
     94        tmpU = tmpBuffer+tmpWidth*tmpHeight; 
     95        tmpV = tmpU+tmpWidth*tmpHeight/4; 
    4896 
    4997        // exit  
     
    62110                return 0; 
    63111 
    64         // Set input picture data  
    65         int numPixels = resizeWidth*resizeHeight; 
    66         int resPixels = resizeDstWidth; 
    67  
    68112        // Set pointers  
    69113        src[0] = srcY; 
    70114        src[1] = srcU; 
    71115        src[2] = srcV; 
    72         dst[0] = dstY; 
     116        /*dst[0] = dstY; 
    73117        dst[1] = dstU; 
    74         dst[2] = dstV; 
     118        dst[2] = dstV;*/ 
     119        dst[0] = tmpY; 
     120        dst[1] = tmpU; 
     121        dst[2] = tmpV; 
    75122 
    76123        // Resize frame  
    77124        sws_scale(resizeCtx, src, resizeSrc, 0, resizeHeight, dst, resizeDst); 
    78125 
     126        //Copy to destination 
     127        for (int i=0;i<resizeDstHeight;++i) 
     128                //Copy 
     129                memcpy(dstY+resizeDstLineWidth*i,tmpY+tmpWidth*i,resizeDstWidth); 
     130 
     131        //Copy to destination 
     132        for (int i=0;i<resizeDstHeight/2;++i) 
     133        { 
     134                //Copy 
     135                memcpy(dstU+resizeDstLineWidth*i/2,tmpU+tmpWidth*i/2,resizeDstWidth/2); 
     136                memcpy(dstV+resizeDstLineWidth*i/2,tmpV+tmpWidth*i/2,resizeDstWidth/2); 
     137        } 
     138 
    79139        //Done 
    80140        return 1; 
  • media/src/partedmosaic.cpp

    r31 r45  
    101101        //Get offsets 
    102102        offset = (mosaicTotalWidth*mosaicHeight*i) + mosaicWidth*j;  
    103         offset2 = (mosaicTotalWidth*mosaicHeight*i)/4+(mosaicWidth*j)/2
     103        offset2 = (mosaicTotalWidth*mosaicHeight/4)*i+(mosaicWidth/2)*j
    104104 
    105105        //Get plane pointers 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software