Commit fbe8bb37 authored by David Cole's avatar David Cole
Browse files

ENH: Remove the Utilities/vtkmpeg2encode directory from the VTK source tree....

ENH: Remove the Utilities/vtkmpeg2encode directory from the VTK source tree. The directory is no longer referenced since yesterday's commit. It is now available as a separate download from the downloads page of the VTK web site.
parent 48830a2b
PROJECT(vtkMPEG2Encode)
INCLUDE_REGULAR_EXPRESSION("^.*$")
#############################################################################
# to use this library in your code you will need to SUBDIR into this
# directory so that it gets built and then you will use the following variables
# in your CMakeLists files to get the proper include paths and libraries
SET (vtkMPEG2Encode_INCLUDE_PATH
"${vtkMPEG2Encode_SOURCE_DIR};${vtkMPEG2Encode_BINARY_DIR}"
CACHE INTERNAL "include paths for vtkMPEG2Encode"
)
SET (vtkMPEG2Encode_LIBRARIES vtkMPEG2Encode
CACHE INTERNAL "libraries for vtkMPEG2Encode")
#############################################################################
# We need ansi c-flags, especially on HP
SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
# Disable some warnings so we do not have to change the code.
IF(WIN32 AND BORLAND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-8004")
ENDIF(WIN32 AND BORLAND)
SET(srcs
conform.c motion.c putbits.c putpic.c quantize.c stats.c
fdctref.c puthdr.c putseq.c ratectl.c transfrm.c
idct.c predict.c putmpg.c putvlc.c readpic.c writepic.c
)
ADD_DEFINITIONS(-DVTK_IN_MPEG2ENC)
IF(NOT BUILD_SHARED_LIBS)
SET(VTK_MPEG2ENC_STATIC 1)
ENDIF(NOT BUILD_SHARED_LIBS)
CONFIGURE_FILE(${vtkMPEG2Encode_SOURCE_DIR}/.NoDartCoverage
${vtkMPEG2Encode_BINARY_DIR}/.NoDartCoverage)
CONFIGURE_FILE(${vtkMPEG2Encode_SOURCE_DIR}/mpeg2encDllConfig.h.in
${vtkMPEG2Encode_BINARY_DIR}/mpeg2encDllConfig.h)
INCLUDE_DIRECTORIES(${vtkMPEG2Encode_INCLUDE_PATH})
ADD_LIBRARY(vtkMPEG2Encode ${srcs})
# Apply user-defined properties to the library target.
IF(VTK_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(vtkMPEG2Encode PROPERTIES ${VTK_LIBRARY_PROPERTIES})
ENDIF(VTK_LIBRARY_PROPERTIES)
IF(NOT VTK_INSTALL_NO_LIBRARIES)
IF(VTK_INSTALL_LIB_DIR)
INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtkMPEG2Encode)
ENDIF(VTK_INSTALL_LIB_DIR)
ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
#-----------------------------------------------------------------------------
# vtkmpeg2encode
#-----------------------------------------------------------------------------
This source tree for the mpeg2 library is designed to be built as a
standalone library using CMake. This is an implementation specifically
designed to link into VTK. It is not included directly with any VTK
distributions because VTK has a "patent free" policy which prohibits
including patented code in the VTK source tree...
First, build the vtkMPEG2Encode library using CMake to configure the build.
Then, assuming you are willing to take on the responsibility of including
patented code in your software project, you can turn on the
VTK_USE_MPEG2_ENCODER option and link vtkMPEG2Encode into your build of VTK
to enable the vtkMPEG2Writer class.
See the comments at the top of the source code files for the disclaimer of
warranty and comments regarding royalty payments to MPEG patent holders.
The following comments are copied from VTK's main CMakeLists.txt file -
these comments appear just prior to the definition of the
VTK_USE_MPEG2_ENCODER CMake option.
#-----------------------------------------------------------------------------
# MPEG2
#
# Portions of the mpeg2 library are patented. VTK does not enable linking to
# this library by default so VTK can remain "patent free". Users who wish to
# link in mpeg2 functionality must build that library separately and then
# turn on VTK_USE_MPEG2_ENCODER when configuring VTK. After turning on
# VTK_USE_MPEG2_ENCODER, you must also set the CMake variables
# vtkMPEG2Encode_INCLUDE_PATH and vtkMPEG2Encode_LIBRARIES.
#
# To use the patented mpeg2 library, first build it, then set the following
# CMake variables during the VTK configure step:
# VTK_USE_MPEG2_ENCODER = ON
# vtkMPEG2Encode_INCLUDE_PATH = /path/to/vtkmpeg2encode;/path/to/vtkmpeg2encode-bin
# vtkMPEG2Encode_LIBRARIES = /path/to/vtkmpeg2encode-bin/vtkMPEG2Encode.lib
#
# Or using -D args on the cmake/ccmake command line:
# -DVTK_USE_MPEG2_ENCODER:BOOL=ON
# "-DvtkMPEG2Encode_INCLUDE_PATH:PATH=/path/to/vtkmpeg2encode;/path/to/vtkmpeg2encode-bin"
# "-DvtkMPEG2Encode_LIBRARIES:STRING=/path/to/vtkmpeg2encode-bin/vtkMPEG2Encode.lib"
#
# You are solely responsible for any legal issues associated with using
# patented code in your software.
#
#-----------------------------------------------------------------------------
/* conform.c, conformance checks */
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
/*
* Disclaimer of Warranty
*
* These software programs are available to the user without any license fee or
* royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
* any and all warranties, whether express, implied, or statuary, including any
* implied warranties or merchantability or of fitness for a particular
* purpose. In no event shall the copyright-holder be liable for any
* incidental, punitive, or consequential damages of any kind whatsoever
* arising from the use of these programs.
*
* This disclaimer of warranty extends to the user of these programs and user's
* customers, employees, agents, transferees, successors, and assigns.
*
* The MPEG Software Simulation Group does not represent or warrant that the
* programs furnished hereunder are free of infringement of any third-party
* patents.
*
* Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
* are subject to royalty fees to patent holders. Many of these patents are
* general enough such that they are unavoidable regardless of implementation
* design.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "mpeg2enc_config.h"
#include "mpeg2enc_global.h"
/* check for (level independent) parameter limits */
VTK_MPEG2ENC_EXPORT void MPEG2_range_checks(mpeg2_struct)
struct MPEG2_structure *mpeg2_struct;
{
int i;
/* range and value checks */
if (mpeg2_struct->horizontal_size<1 || mpeg2_struct->horizontal_size>16383)
(*(mpeg2_struct->report_error))("horizontal_size must be between 1 and 16383");
if (mpeg2_struct->mpeg1 && mpeg2_struct->horizontal_size>4095)
(*(mpeg2_struct->report_error))("horizontal_size must be less than 4096 (MPEG-1)");
if ((mpeg2_struct->horizontal_size&4095)==0)
(*(mpeg2_struct->report_error))("horizontal_size must not be a multiple of 4096");
if (mpeg2_struct->chroma_format!=CHROMA444 && mpeg2_struct->horizontal_size%2 != 0)
(*(mpeg2_struct->report_error))("horizontal_size must be a even (4:2:0 / 4:2:2)");
if (mpeg2_struct->vertical_size<1 || mpeg2_struct->vertical_size>16383)
(*(mpeg2_struct->report_error))("vertical_size must be between 1 and 16383");
if (mpeg2_struct->mpeg1 && mpeg2_struct->vertical_size>4095)
(*(mpeg2_struct->report_error))("vertical size must be less than 4096 (MPEG-1)");
if ((mpeg2_struct->vertical_size&4095)==0)
(*(mpeg2_struct->report_error))("vertical_size must not be a multiple of 4096");
if (mpeg2_struct->chroma_format==CHROMA420 && mpeg2_struct->vertical_size%2 != 0)
(*(mpeg2_struct->report_error))("vertical_size must be a even (4:2:0)");
if(mpeg2_struct->fieldpic)
{
if (mpeg2_struct->vertical_size%2 != 0)
(*(mpeg2_struct->report_error))("vertical_size must be a even (field pictures)");
if (mpeg2_struct->chroma_format==CHROMA420 && mpeg2_struct->vertical_size%4 != 0)
(*(mpeg2_struct->report_error))("vertical_size must be a multiple of 4 (4:2:0 field pictures)");
}
if (mpeg2_struct->mpeg1)
{
if (mpeg2_struct->aspectratio<1 || mpeg2_struct->aspectratio>14)
(*(mpeg2_struct->report_error))("pel_aspect_ratio must be between 1 and 14 (MPEG-1)");
}
else
{
if (mpeg2_struct->aspectratio<1 || mpeg2_struct->aspectratio>4)
(*(mpeg2_struct->report_error))("aspect_ratio_information must be 1, 2, 3 or 4");
}
if (mpeg2_struct->frame_rate_code<1 || mpeg2_struct->frame_rate_code>8)
(*(mpeg2_struct->report_error))("frame_rate code must be between 1 and 8");
if (mpeg2_struct->bit_rate<=0.0)
(*(mpeg2_struct->report_error))("bit_rate must be positive");
if (mpeg2_struct->bit_rate > ((1<<30)-1)*400.0)
(*(mpeg2_struct->report_error))("bit_rate must be less than 429 Gbit/s");
if (mpeg2_struct->mpeg1 && mpeg2_struct->bit_rate > ((1<<18)-1)*400.0)
(*(mpeg2_struct->report_error))("bit_rate must be less than 104 Mbit/s (MPEG-1)");
if (mpeg2_struct->vbv_buffer_size<1 || mpeg2_struct->vbv_buffer_size>0x3ffff)
(*(mpeg2_struct->report_error))("vbv_buffer_size must be in range 1..(2^18-1)");
if (mpeg2_struct->mpeg1 && mpeg2_struct->vbv_buffer_size>=1024)
(*(mpeg2_struct->report_error))("vbv_buffer_size must be less than 1024 (MPEG-1)");
if (mpeg2_struct->chroma_format<CHROMA420 || mpeg2_struct->chroma_format>CHROMA444)
(*(mpeg2_struct->report_error))("chroma_format must be in range 1...3");
if (mpeg2_struct->video_format<0 || mpeg2_struct->video_format>4)
(*(mpeg2_struct->report_error))("video_format must be in range 0...4");
if (mpeg2_struct->color_primaries<1 || mpeg2_struct->color_primaries>7 || mpeg2_struct->color_primaries==3)
(*(mpeg2_struct->report_error))("color_primaries must be in range 1...2 or 4...7");
if (mpeg2_struct->transfer_characteristics<1 || mpeg2_struct->transfer_characteristics>7
|| mpeg2_struct->transfer_characteristics==3)
(*(mpeg2_struct->report_error))("transfer_characteristics must be in range 1...2 or 4...7");
if (mpeg2_struct->matrix_coefficients<1 || mpeg2_struct->matrix_coefficients>7 || mpeg2_struct->matrix_coefficients==3)
(*(mpeg2_struct->report_error))("matrix_coefficients must be in range 1...2 or 4...7");
if (mpeg2_struct->display_horizontal_size<0 || mpeg2_struct->display_horizontal_size>16383)
(*(mpeg2_struct->report_error))("display_horizontal_size must be in range 0...16383");
if (mpeg2_struct->display_vertical_size<0 || mpeg2_struct->display_vertical_size>16383)
(*(mpeg2_struct->report_error))("display_vertical_size must be in range 0...16383");
if (mpeg2_struct->dc_prec<0 || mpeg2_struct->dc_prec>3)
(*(mpeg2_struct->report_error))("intra_dc_precision must be in range 0...3");
for (i=0; i<mpeg2_struct->M_val; i++)
{
if (mpeg2_struct->motion_data[i].forw_hor_f_code<1 || mpeg2_struct->motion_data[i].forw_hor_f_code>9)
(*(mpeg2_struct->report_error))("f_code must be between 1 and 9");
if (mpeg2_struct->motion_data[i].forw_vert_f_code<1 || mpeg2_struct->motion_data[i].forw_vert_f_code>9)
(*(mpeg2_struct->report_error))("f_code must be between 1 and 9");
if (mpeg2_struct->mpeg1 && mpeg2_struct->motion_data[i].forw_hor_f_code>7)
(*(mpeg2_struct->report_error))("f_code must be le less than 8");
if (mpeg2_struct->mpeg1 && mpeg2_struct->motion_data[i].forw_vert_f_code>7)
(*(mpeg2_struct->report_error))("f_code must be le less than 8");
if (mpeg2_struct->motion_data[i].sxf<=0)
(*(mpeg2_struct->report_error))("search window must be positive"); /* doesn't belong here */
if (mpeg2_struct->motion_data[i].syf<=0)
(*(mpeg2_struct->report_error))("search window must be positive");
if (i!=0)
{
if (mpeg2_struct->motion_data[i].back_hor_f_code<1 || mpeg2_struct->motion_data[i].back_hor_f_code>9)
(*(mpeg2_struct->report_error))("f_code must be between 1 and 9");
if (mpeg2_struct->motion_data[i].back_vert_f_code<1 || mpeg2_struct->motion_data[i].back_vert_f_code>9)
(*(mpeg2_struct->report_error))("f_code must be between 1 and 9");
if (mpeg2_struct->mpeg1 && mpeg2_struct->motion_data[i].back_hor_f_code>7)
(*(mpeg2_struct->report_error))("f_code must be le less than 8");
if (mpeg2_struct->mpeg1 && mpeg2_struct->motion_data[i].back_vert_f_code>7)
(*(mpeg2_struct->report_error))("f_code must be le less than 8");
if (mpeg2_struct->motion_data[i].sxb<=0)
(*(mpeg2_struct->report_error))("search window must be positive");
if (mpeg2_struct->motion_data[i].syb<=0)
(*(mpeg2_struct->report_error))("search window must be positive");
}
}
}
/* identifies valid profile / level combinations */
static char profile_level_defined[5][4] =
{
/* HL H-14 ML LL */
{1, 1, 1, 0}, /* HP */
{0, 1, 0, 0}, /* Spat */
{0, 0, 1, 1}, /* SNR */
{1, 1, 1, 1}, /* MP */
{0, 0, 1, 0} /* SP */
};
static struct level_limits {
int hor_f_code;
int vert_f_code;
int hor_size;
int vert_size;
int sample_rate;
int bit_rate; /* Mbit/s */
int vbv_buffer_size; /* 16384 bit steps */
} maxval_tab[4] =
{
{9, 5, 1920, 1152, 62668800, 80, 597}, /* HL */
{9, 5, 1440, 1152, 47001600, 60, 448}, /* H-14 */
{8, 5, 720, 576, 10368000, 15, 112}, /* ML */
{7, 4, 352, 288, 3041280, 4, 29} /* LL */
};
#define SP 5
#define MP 4
#define SNR 3
#define SPAT 2
#define HP 1
#define LL 10
#define ML 8
#define H14 6
#define HL 4
VTK_MPEG2ENC_EXPORT void MPEG2_profile_and_level_checks(mpeg2_struct)
struct MPEG2_structure *mpeg2_struct;
{
int i;
struct level_limits *maxval;
if (mpeg2_struct->profile<0 || mpeg2_struct->profile>15)
(*(mpeg2_struct->report_error))("profile must be between 0 and 15");
if (mpeg2_struct->level<0 || mpeg2_struct->level>15)
(*(mpeg2_struct->report_error))("level must be between 0 and 15");
if (mpeg2_struct->profile>=8)
{
if (!mpeg2_struct->quiet)
fprintf(stderr,"Warning: profile uses a reserved value, conformance checks skipped\n");
return;
}
if (mpeg2_struct->profile<HP || mpeg2_struct->profile>SP)
(*(mpeg2_struct->report_error))("undefined Profile");
if (mpeg2_struct->profile==SNR || mpeg2_struct->profile==SPAT)
(*(mpeg2_struct->report_error))("This encoder currently generates no scalable bitstreams");
if (mpeg2_struct->level<HL || mpeg2_struct->level>LL || mpeg2_struct->level&1)
(*(mpeg2_struct->report_error))("undefined Level");
maxval = &maxval_tab[(mpeg2_struct->level-4) >> 1];
/* check profile@level combination */
if(!profile_level_defined[mpeg2_struct->profile-1][(mpeg2_struct->level-4) >> 1])
(*(mpeg2_struct->report_error))("undefined profile@level combination");
/* profile (syntax) constraints */
if (mpeg2_struct->profile==SP && mpeg2_struct->M_val!=1)
(*(mpeg2_struct->report_error))("Simple Profile does not allow B pictures");
if (mpeg2_struct->profile!=HP && mpeg2_struct->chroma_format!=CHROMA420)
(*(mpeg2_struct->report_error))("chroma format must be 4:2:0 in specified Profile");
if (mpeg2_struct->profile==HP && mpeg2_struct->chroma_format==CHROMA444)
(*(mpeg2_struct->report_error))("chroma format must be 4:2:0 or 4:2:2 in High Profile");
if (mpeg2_struct->profile>=MP) /* SP, MP: constrained repeat_first_field */
{
if (mpeg2_struct->frame_rate_code<=2 && mpeg2_struct->repeatfirst)
(*(mpeg2_struct->report_error))("repeat_first_first must be zero");
if (mpeg2_struct->frame_rate_code<=6 && mpeg2_struct->prog_seq && mpeg2_struct->repeatfirst)
(*(mpeg2_struct->report_error))("repeat_first_first must be zero");
}
if (mpeg2_struct->profile!=HP && mpeg2_struct->dc_prec==3)
(*(mpeg2_struct->report_error))("11 bit DC precision only allowed in High Profile");
/* level (parameter value) constraints */
/* Table 8-8 */
if (mpeg2_struct->frame_rate_code>5 && mpeg2_struct->level>=ML)
(*(mpeg2_struct->report_error))("Picture rate greater than permitted in specified Level");
for (i=0; i<mpeg2_struct->M_val; i++)
{
if (mpeg2_struct->motion_data[i].forw_hor_f_code > maxval->hor_f_code)
(*(mpeg2_struct->report_error))("forward horizontal f_code greater than permitted in specified Level");
if (mpeg2_struct->motion_data[i].forw_vert_f_code > maxval->vert_f_code)
(*(mpeg2_struct->report_error))("forward vertical f_code greater than permitted in specified Level");
if (i!=0)
{
if (mpeg2_struct->motion_data[i].back_hor_f_code > maxval->hor_f_code)
(*(mpeg2_struct->report_error))("backward horizontal f_code greater than permitted in specified Level");
if (mpeg2_struct->motion_data[i].back_vert_f_code > maxval->vert_f_code)
(*(mpeg2_struct->report_error))("backward vertical f_code greater than permitted in specified Level");
}
}
/* Table 8-10 */
if (mpeg2_struct->horizontal_size > maxval->hor_size)
(*(mpeg2_struct->report_error))("Horizontal size is greater than permitted in specified Level");
if (mpeg2_struct->vertical_size > maxval->vert_size)
(*(mpeg2_struct->report_error))("Horizontal size is greater than permitted in specified Level");
/* Table 8-11 */
if (mpeg2_struct->horizontal_size*mpeg2_struct->vertical_size*mpeg2_struct->frame_rate > maxval->sample_rate)
(*(mpeg2_struct->report_error))("Sample rate is greater than permitted in specified Level");
/* Table 8-12 */
if (mpeg2_struct->bit_rate> 1.0e6 * maxval->bit_rate)
(*(mpeg2_struct->report_error))("Bit rate is greater than permitted in specified Level");
/* Table 8-13 */
if (mpeg2_struct->vbv_buffer_size > maxval->vbv_buffer_size)
(*(mpeg2_struct->report_error))("vbv_buffer_size exceeds High Level limit");
}
/* fdctref.c, forward discrete cosine transform, double precision */
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
/*
* Disclaimer of Warranty
*
* These software programs are available to the user without any license fee or
* royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
* any and all warranties, whether express, implied, or statuary, including any
* implied warranties or merchantability or of fitness for a particular
* purpose. In no event shall the copyright-holder be liable for any
* incidental, punitive, or consequential damages of any kind whatsoever
* arising from the use of these programs.
*
* This disclaimer of warranty extends to the user of these programs and user's
* customers, employees, agents, transferees, successors, and assigns.
*
* The MPEG Software Simulation Group does not represent or warrant that the
* programs furnished hereunder are free of infringement of any third-party
* patents.
*
* Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
* are subject to royalty fees to patent holders. Many of these patents are
* general enough such that they are unavoidable regardless of implementation
* design.
*
*/
#include <math.h>
#include <stdio.h>
#include "mpeg2enc_config.h"
#include "mpeg2enc_global.h"
#ifndef PI
# ifdef M_PI
# define PI M_PI
# else
# define PI 3.14159265358979323846
# endif
#endif
/* global declarations */
void MPEG2_fdct _ANSI_ARGS_((short *block));
/* private data */
static double c[8][8]; /* transform coefficients */
VTK_MPEG2ENC_EXPORT void MPEG2_init_fdct()
{
int i, j;
double s;
for (i=0; i<8; i++)
{
s = (i==0) ? sqrt(0.125) : 0.5;
for (j=0; j<8; j++)
c[i][j] = s * cos((PI/8.0)*i*(j+0.5));
}
}
void MPEG2_fdct(block)
short *block;
{
int i, j, k;
double s;
double tmp[64];
for (i=0; i<8; i++)
for (j=0; j<8; j++)
{
s = 0.0;
for (k=0; k<8; k++)
s += c[j][k] * block[8*i+k];
tmp[8*i+j] = s;
}
for (j=0; j<8; j++)
for (i=0; i<8; i++)
{
s = 0.0;
for (k=0; k<8; k++)
s += c[i][k] * tmp[8*k+j];
block[8*i+j] = (int)floor(s+0.499999);
/*
* reason for adding 0.499999 instead of 0.5:
* s is quite often x.5 (at least for i and/or j = 0 or 4)
* and setting the rounding threshold exactly to 0.5 leads to an
* extremely high arithmetic implementation dependency of the result;
* s being between x.5 and x.500001 (which is now incorrectly rounded
* downwards instead of upwards) is assumed to occur less often
* (if at all)
*/
}
}
/* idct.c, inverse fast discrete cosine transform */
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
/*
* Disclaimer of Warranty
*
* These software programs are available to the user without any license fee or
* royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
* any and all warranties, whether express, implied, or statuary, including any
* implied warranties or merchantability or of fitness for a particular
* purpose. In no event shall the copyright-holder be liable for any
* incidental, punitive, or consequential damages of any kind whatsoever
* arising from the use of these programs.
*
* This disclaimer of warranty extends to the user of these programs and user's
* customers, employees, agents, transferees, successors, and assigns.
*
* The MPEG Software Simulation Group does not represent or warrant that the
* programs furnished hereunder are free of infringement of any third-party
* patents.
*
* Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
* are subject to royalty fees to patent holders. Many of these patents are
* general enough such that they are unavoidable regardless of implementation
* design.
*
*/
/**********************************************************/
/* inverse two dimensional DCT, Chen-Wang algorithm */
/* (cf. IEEE ASSP-32, pp. 803-816, Aug. 1984) */
/* 32-bit integer arithmetic (8 bit coefficients) */
/* 11 mults, 29 adds per DCT */
/* sE, 18.8.91 */
/**********************************************************/
/* coefficients extended to 12 bit for IEEE1180-1990 */
/* compliance sE, 2.1.94 */
/**********************************************************/
/* this code assumes >> to be a two's-complement arithmetic */
/* right shift: (-2)>>1 == -1 , (-3)>>1 == -2 */
#include <stdio.h>
#include "mpeg2enc_config.h"
#include "mpeg2enc_global.h"
#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
/* global declarations */
void MPEG2_idct _ANSI_ARGS_((short *block));
/* private data */
static short iclip[1024]; /* clipping table */
static short *iclp;
/* private prototypes */
static void MPEG2_idctrow _ANSI_ARGS_((short *blk));
static void MPEG2_idctcol _ANSI_ARGS_((short *blk));
/* row (horizontal) IDCT
*
* 7 pi 1
* dst[k] = sum c[l] * src[l] * cos( -- * ( k + - ) * l )
* l=0 8 2
*
* where: c[0] = 128
* c[1..7] = 128*sqrt(2)
*/
static void MPEG2_idctrow(blk)
short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
if (!((x1 = blk[4]<<11) | (x2 = blk[6]) | (x3 = blk[2]) |
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
{
blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
return;
}
x0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage */
/* first stage */
x8 = W7*(x4+x5);
x4 = x8 + (W1-W7)*x4;
x5 = x8 - (W1+W7)*x5;
x8 = W3*(x6+x7);
x6 = x8 - (W3-W5)*x6;
x7 = x8 - (W3+W5)*x7;
/* second stage */
x8 = x0 + x1;
x0 -= x1;
x1 = W6*(x3+x2);
x2 = x1 - (W2+W6)*x2;
x3 = x1 + (W2-W6)*x3;