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

📄 simpleintrapredictor.cpp

📁 一个可以在DM642上运新的h.264算法
💻 CPP
字号:
/*	Open H.264
 *
 *	#include	<standard_disclaimer>
 *
 *  Authors:    aitorgaray@yifan.net
 *              _
 */

#define __SIMPLEINTRAPREDICTOR_CC

#include    "SimpleIntraPredictor.h"
#include    "../BlockIndexer.h"

//-------------------------------------------------------------------------------------
void SimpleIntraPredictor::predictLuma4x4( /* in */ Block& source, bool upperLeftSampleAvailable, bool upperSamplesAvailable, bool leftSamplesAvailable,
                                           /* out */ Block predictions[ LUMA_4x4_PREDICTION_COUNT], bool validPredictions[ LUMA_4x4_PREDICTION_COUNT]) {

    //  *toDO*  replicate pixels at macroblock border

    //  prediction and predicted samples ( old notation from standard used)
    byte    M,    A, B, C, D, E, F, G, H,
            I, // a, b, c, d,
            J, // e, f, g, h,
            K, // i, j, k, l,
            L; // m, n, o, p;

    byte*   sourcePointer = source._baseAddress,
            sourceStride = source._stride;

    //  *noTE*  just to keep the compiler happy
    M = A = B = C = D = E = F = G = H = I = J = K = L = 0;

    //  load prediction samples
    if( upperLeftSampleAvailable) {

        M = sourcePointer[ -sourceStride - 1];
    }

    if( upperSamplesAvailable) {

        A = sourcePointer[ -sourceStride + 0];
        B = sourcePointer[ -sourceStride + 1];
        C = sourcePointer[ -sourceStride + 2];
        D = sourcePointer[ -sourceStride + 3];
        E = sourcePointer[ -sourceStride + 4];
        F = sourcePointer[ -sourceStride + 5];
        G = sourcePointer[ -sourceStride + 6];
        H = sourcePointer[ -sourceStride + 7];
    }

    if( leftSamplesAvailable) {

        I = sourcePointer[ ( 0 * sourceStride) - 1];
        J = sourcePointer[ ( 1 * sourceStride) - 1];
        K = sourcePointer[ ( 2 * sourceStride) - 1];
        L = sourcePointer[ ( 3 * sourceStride) - 1];
    }

    //  modes not available by default
    validPredictions[ LUMA_4x4_MODE0] =
    validPredictions[ LUMA_4x4_MODE1] =
    validPredictions[ LUMA_4x4_MODE2] =
    validPredictions[ LUMA_4x4_MODE3] =
    validPredictions[ LUMA_4x4_MODE4] =
    validPredictions[ LUMA_4x4_MODE5] =
    validPredictions[ LUMA_4x4_MODE6] =
    validPredictions[ LUMA_4x4_MODE7] =
    validPredictions[ LUMA_4x4_MODE7] = false;

    //  do predictions
    if( upperLeftSampleAvailable && upperSamplesAvailable && leftSamplesAvailable) {

        //  modes 4, 5, 6
        validPredictions[ LUMA_4x4_MODE4] =
        validPredictions[ LUMA_4x4_MODE5] =
        validPredictions[ LUMA_4x4_MODE6] = true;

        predictLuma4x4Mode4( M, A, B, C, D, E, F, G, H, I, J, K, L, predictions[ LUMA_4x4_MODE4]);
        predictLuma4x4Mode5( M, A, B, C, D, E, F, G, H, I, J, K, L, predictions[ LUMA_4x4_MODE5]);
        predictLuma4x4Mode6( M, A, B, C, D, E, F, G, H, I, J, K, L, predictions[ LUMA_4x4_MODE6]);
    }

    if( upperSamplesAvailable) {

        //  modes 0, 3, 7

        validPredictions[ LUMA_4x4_MODE0] =
        validPredictions[ LUMA_4x4_MODE3] =
        validPredictions[ LUMA_4x4_MODE7] = true;

        predictLuma4x4Mode0( A, B, C, D, predictions[ LUMA_4x4_MODE0]);
        predictLuma4x4Mode3( A, B, C, D, E, F, G, H, predictions[ LUMA_4x4_MODE3]);
        predictLuma4x4Mode7( A, B, C, D, E, F, G, H, predictions[ LUMA_4x4_MODE7]);
    }

    if( leftSamplesAvailable) {

        //  modes 1, 8
        validPredictions[ LUMA_4x4_MODE1] =
        validPredictions[ LUMA_4x4_MODE8] = true;

        predictLuma4x4Mode1( I, J, K, L, predictions[ LUMA_4x4_MODE1]);
        predictLuma4x4Mode8( I, J, K, L, predictions[ LUMA_4x4_MODE8]);
    }

    if( true) {     //  DC more is always applied

        //  mode 2
        validPredictions[ LUMA_4x4_MODE2] = true;

        predictLuma4x4Mode2( upperSamplesAvailable, leftSamplesAvailable, A, B, C, D, E, F, G, H, I, J, K, L, predictions[ LUMA_4x4_MODE2]);
    }
}

void SimpleIntraPredictor::predictLuma4x4Mode0( byte A, byte B, byte C, byte D, Block& prediction) {
    BlockIndexer< 4>    blockIndexer( prediction);
    byte**              p = blockIndexer._sampleArray;

    for( int y = 0; y < 4; y++) {

        p[ y][ 0] = A;
        p[ y][ 1] = B;
        p[ y][ 2] = C;
        p[ y][ 3] = D;
    }
}

void SimpleIntraPredictor::predictLuma4x4Mode1( byte I, byte J, byte K, byte L, Block& prediction) {
    BlockIndexer< 4>    blockIndexer( prediction);
    byte**              p = blockIndexer._sampleArray;

    for( int x = 0; x < 4; x++) {

        p[ 0][ x] = I;
        p[ 1][ x] = J;
        p[ 2][ x] = K;
        p[ 3][ x] = L;
    }
}

void SimpleIntraPredictor::predictLuma4x4Mode2( bool upperSamplesAvailable, bool leftSamplesAvailable,
                                                byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, byte I, byte J, byte K, byte L, Block& prediction) {

    //  *toDO*  fill in the gaps
}

void SimpleIntraPredictor::predictLuma4x4Mode3( byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, Block& prediction) {
    BlockIndexer< 4>    blockIndexer( prediction);
    byte**              p = blockIndexer._sampleArray;

    byte    t0 = ( A + 2*B + C + 2) >> 2,
            t1 = ( B + 2*C + D + 2) >> 2,
            t2 = ( C + 2*D + E + 2) >> 2,
            t3 = ( D + 2*E + F + 2) >> 2,
            t4 = ( E + 2*F + G + 2) >> 2,
            t5 = ( F + 2*G + H + 2) >> 2,
            t6 = ( G + 3*H + 2) >> 2;

    p[ 0][ 0] = t0;     //  a
    p[ 0][ 1] = t1;     //  b
    p[ 0][ 2] = t3;     //  c
    p[ 0][ 3] = t4;     //  d
    
    p[ 1][ 0] = t1;     //  e
    p[ 1][ 1] = t2;     //  f
    p[ 1][ 2] = t3;     //  g
    p[ 1][ 3] = t4;     //  h

    p[ 2][ 0] = t2;     //  i
    p[ 2][ 1] = t3;     //  j
    p[ 2][ 2] = t4;     //  k
    p[ 2][ 3] = t5;     //  l

    p[ 3][ 0] = t3;     //  m
    p[ 3][ 1] = t4;     //  n
    p[ 3][ 2] = t5;     //  o
    p[ 3][ 3] = t6;     //  p
}

void SimpleIntraPredictor::predictLuma4x4Mode4( byte M, byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, byte I, byte J, byte K, byte L, Block& prediction) {

    //  *toDO*  fill in the gaps
}

void SimpleIntraPredictor::predictLuma4x4Mode5( byte M, byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, byte I, byte J, byte K, byte L, Block& prediction) {

    //  *toDO*  fill in the gaps
}

void SimpleIntraPredictor::predictLuma4x4Mode6( byte M, byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, byte I, byte J, byte K, byte L, Block& prediction) {

    //  *toDO*  fill in the gaps
}

void SimpleIntraPredictor::predictLuma4x4Mode7( byte A, byte B, byte C, byte D, byte E, byte F, byte G, byte H, Block& prediction) {

    //  *toDO*  fill in the gaps
}

void SimpleIntraPredictor::predictLuma4x4Mode8( byte I, byte J, byte K, byte L, Block& prediction) {

    //  *toDO*  fill in the gaps
}


//-------------------------------------------------------------------------------------
void SimpleIntraPredictor::predictLuma16x16( /* in */ LumaMacroblock& source, bool upperLeftSampleAvailable, bool upperSamplesAvailable, bool leftSamplesAvailable,
                                             /* out */ LumaMacroblock predictions[ LUMA_16x16_PREDICTION_COUNT], bool validPredictions[ LUMA_16x16_PREDICTION_COUNT]) {

    //  *toDO*  fill in the gaps
}


void SimpleIntraPredictor::predictChroma8x8( /* in */ ChromaMacroblock& source, bool upperLeftSampleAvailable, bool upperSamplesAvailable, bool leftSamplesAvailable,
                                             /* out */ ChromaMacroblock predictions[ CHROMA_8x8_PREDICTION_COUNT], bool validPredictions[ CHROMA_8x8_PREDICTION_COUNT]) {

    //  *toDO*  fill in the gaps
}

/*  $Log:$
 *
 */

⌨️ 快捷键说明

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