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

📄 tarith_encoder_jpeg2000.c

📁 JPEG2000 ADI BLACKFIN 压缩解压程序
💻 C
字号:
/*******************************************************************************
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved.
Developed by Joint Development Software Application Team, IPDC, Bangalore, India
for Blackfin DSPs  ( Micro Signal Architecture 1.0 specification).

By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software. 
********************************************************************************
File name   : tarith_encoder_JPEG2000.c
Description : This module tests the functionality of arith_encoder_JPEG2000().
********************************************************************************/
#include<stdio.h>

#include"tarith_encoder_JPEG2000.h"
#include "test_input.h"

int error_flag = 0;
void (*f1)();
int cycle_count[MAX_PAIR+2];

void _arith_enc_init();
void _arith_encoder_JPEG2000();
void _arith_enc_flush();

void main()
{
    int i,j,k;
    unsigned char D,cx;
    int error;

// test case : 1

    for (i = 0; i <= MAX_CONTEXTS; i++)
    {
        contexts[i].I = zero_in;
        contexts[i].MPS = zero_in;    //load Index value and MPS to each context
    }

    contexts[UNIFORM_CX].I = uniform_index;
    contexts[RUNLENGTH_CX].I=runlen_index;
    contexts[0].I = zero_index;

    f1 = _arith_enc_init;

    cycle_count[0] = Compute_Cycle_Count(&enc_reg,&arrayOut[0]);
                            //This function inturn calls arith_enc_init()

    f1 = _arith_encoder_JPEG2000;

    for (i=0;i<MAX_PAIR;i++)
    {
        cx = arrayIn1_C[i];                    // get context and decision value
        D = arrayIn1_D[i];
        cycle_count[i+1] = Compute_Cycle_Count(D, cx,&enc_reg,&mqstates[0],
                                               &contexts[0]);
                            //This function inturn calls arith_encoder_JPEG2000()
    }

    f1 = _arith_enc_flush;

    cycle_count[MAX_PAIR + 1] = Compute_Cycle_Count(&enc_reg);
                            //This function inturn calls arith_enc_flush()

    for(i=0;i<50;i++)
    {
        error=arrayOut[i]-exp_output1[i];

        if(abs(error) >MAX_PERMISSIBLE_ERROR)
        {
            error_flag = error_flag | 1;
            break;
        }
    }

// test2

    for(i=0;i<50;i++)        // clear  output array
        arrayOut[i]=zero_in;

    for (i = 0; i <= MAX_CONTEXTS; i++)
    {
        contexts[i].I = zero_in;
        contexts[i].MPS = zero_in;   // load Index value and MPS to each context
    }

    contexts[UNIFORM_CX].I = uniform_index;
    contexts[RUNLENGTH_CX].I=runlen_index;
    contexts[0].I = zero_index;

    f1 = _arith_enc_init;

    _arith_enc_init(&enc_reg,&arrayOut[0]); 
                    // call arith_init to initialize the encoder

    f1 = _arith_encoder_JPEG2000;

    for (i=0;i<MAX_PAIR;i++)
    {
        cx = arrayIn2_C[i];      // get context and decision value 
        D = arrayIn2_D[i];
        _arith_encoder_JPEG2000(D, cx,&enc_reg,&mqstates[0],&contexts[0]);
    }

    _arith_enc_flush(&enc_reg);      // finally call flush to get last bytes

    for(i=0;i<50;i++)
    {
        error=arrayOut[i]-exp_output2[i];

        if(abs(error) > MAX_PERMISSIBLE_ERROR)
        {
            error_flag = error_flag | 2;
            break;
        }
    }

// test 3

    for(i=0;i<100;i++)        // clear  output array
        arrayOut[i]=zero_in;

    for (i = 0; i <= MAX_CONTEXTS; i++)
    {
        contexts[i].I = zero_in;
        contexts[i].MPS = zero_in;   // load Index value and MPS to each context
    }

    contexts[UNIFORM_CX].I = uniform_index;
    contexts[RUNLENGTH_CX].I=runlen_index;
    contexts[0].I = zero_index;
    f1 = _arith_enc_init;

    _arith_enc_init(&enc_reg,&arrayOut[0]);
                // call arith_init to initialize the encoder

    f1 = _arith_encoder_JPEG2000;
    for (i=0;i<MAX_PAIR;i++)
    {
        cx = arrayIn3_C[i];                    // get context and decision value 
        D = arrayIn3_D[i];
        _arith_encoder_JPEG2000(D, cx,&enc_reg,&mqstates[0],&contexts[0]);
    }

    _arith_enc_flush(&enc_reg);    // finally call flush to get last bytes


    for(i=0;i<80;i++)
    {
        error=arrayOut[i]-exp_output3[i];

        if(abs(error) > MAX_PERMISSIBLE_ERROR)
        {
            error_flag = error_flag | 4;
            break;
        }
    }
    #ifdef PRINTF_SUPPORT
        if(error_flag & 1)
            printf("Test Case 1 failed\n");
        else
            printf("Test Case 1 passed\n");
        if(error_flag & 2)
            printf("Test Case 2 failed\n");
        else
            printf("Test Case 2 passed\n");
        if(error_flag & 4)
            printf("Test Case 3 failed\n");
        else
            printf("Test Case 3 passed\n");
    #endif
    
    printf("cycle_count[0]=%d,cycle_count[1]=%d,cycle_count[2]=%d\n",cycle_count[0],cycle_count[1],cycle_count[2]);
    
    
}

⌨️ 快捷键说明

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