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

📄 iframe.c

📁 linux下将各类格式图片转换工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/*===========================================================================* * iframe.c                                  * *                                       * *  Procedures concerned with the I-frame encoding               * *                                       * * EXPORTED PROCEDURES:                              * *  GenIFrame                                * *  SetSlicesPerFrame                            * *  SetBlocksPerSlice                            * *  SetIQScale                               * *  GetIQScale                               * *  ResetIFrameStats                             * *  ShowIFrameSummary                            * *  EstimateSecondsPerIFrame                         * *  EncodeYDC                                * *  EncodeCDC                                * *      time_elapsed                                                         * *                                       * *===========================================================================*//* * Copyright (c) 1995 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. *//* *  $Header: /n/picasso/project/mpeg/mpeg_dist/mpeg_encode/RCS/iframe.c,v 1.23 1995/08/14 22:29:49 smoot Exp $ *  $Log: iframe.c,v $ *  Revision 1.23  1995/08/14 22:29:49  smoot *  changed inits in BlockComputeSNR so sgi compiler would be happy * *  Revision 1.22  1995/08/07 21:50:51  smoot *  spacing *  simplified some code *  added Laplace stuff *  minor error check bug in alloc * * Revision 1.21  1995/06/21  22:24:25  smoot * added CalcDistortion (TUNEing) * fixed timeing stuff for ANSI * fixed specifics bug * * Revision 1.20  1995/05/02  21:59:43  smoot * fixed BlockComputeSNR bugs * * Revision 1.19  1995/04/24  23:02:50  smoot * Fixed BlockComputeSNR for Linux and others * * Revision 1.18  1995/04/14  23:08:02  smoot * reorganized to ease rate control experimentation * * Revision 1.17  1995/02/24  23:49:38  smoot * added support for Specifics file version 2 * * Revision 1.16  1995/01/30  20:02:34  smoot * cleanup, killed a couple warnings * * Revision 1.15  1995/01/30  19:49:17  smoot * cosmetic * * Revision 1.14  1995/01/23  02:49:34  darryl * initialized variable * * Revision 1.13  1995/01/19  23:08:30  eyhung * Changed copyrights * * Revision 1.12  1995/01/16  08:01:34  eyhung * Added realQuiet * * Revision 1.11  1994/12/07  00:40:36  smoot * Added seperate P and B search ranges * * Revision 1.10  1994/11/14  22:30:30  smoot * Merged specifics and rate control * * Revision 1.9  1994/11/01  05:00:48  darryl * with rate control changes added * * Revision 2.2  1994/10/31  00:06:07  darryl * version before, hopefully, final changes * * Revision 2.1  1994/10/24  22:03:01  darryl * put in preliminary experiments code * * Revision 2.0  1994/10/24  02:38:04  darryl * will be adding the experiment stuff. * * Revision 1.1  1994/09/27  00:15:24  darryl * Initial revision * * Revision 1.8  1994/03/15  00:27:11  keving * nothing * * Revision 1.7  1993/12/22  19:19:01  keving * nothing * * Revision 1.6  1993/07/22  22:23:43  keving * nothing * * Revision 1.5  1993/06/30  20:06:09  keving * nothing * * Revision 1.4  1993/06/03  21:08:08  keving * nothing * * Revision 1.3  1993/03/04  22:24:06  keving * nothing * * Revision 1.2  1993/02/19  18:10:02  keving * nothing * * Revision 1.1  1993/02/18  22:56:39  keving * nothing * * *//*==============* * HEADER FILES * *==============*/#ifdef CLOCKS_PER_SEC#include <times.h>#else#include <sys/times.h>#endif#include <sys/types.h>#include <sys/param.h>#include "all.h"#include "mtypes.h"#include "frames.h"#include "prototypes.h"#include "mpeg.h"#include "param.h"#include "mheaders.h"#include "fsize.h"#include "parallel.h"#include "postdct.h"#include "rate.h"#include "specifics.h"#include "opts.h"/*==================* * STATIC VARIABLES * *==================*/static  int lastNumBits = 0;static  int lastIFrame = 0;static int numBlocks = 0;static int numBits;static int numFrames = 0;static int numFrameBits = 0;static int32 totalTime = 0;static float    totalSNR = 0.0;static float    totalPSNR = 0.0;static int lengths[256] = {    0, 1, 2, 2, 3, 3, 3, 3,     /* 0 - 7 */    4, 4, 4, 4, 4, 4, 4, 4,     /* 8 - 15 */    5, 5, 5, 5, 5, 5, 5, 5,     /* 16 - 31 */    5, 5, 5, 5, 5, 5, 5, 5,    6, 6, 6, 6, 6, 6, 6, 6,     /* 32 - 63 */    6, 6, 6, 6, 6, 6, 6, 6,    6, 6, 6, 6, 6, 6, 6, 6,    6, 6, 6, 6, 6, 6, 6, 6,    7, 7, 7, 7, 7, 7, 7, 7,     /* 64 - 127 */    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8};/*==================* * GLOBAL VARIABLES * *==================*/int qscaleI;int slicesPerFrame;int blocksPerSlice;int fCodeI, fCodeP, fCodeB;boolean printSNR = FALSE;boolean printMSE = FALSE;boolean decodeRefFrames = FALSE;Block **dct=NULL, **dctr=NULL, **dctb=NULL;dct_data_type   **dct_data; /* used in p/bframe.c */int  TIME_RATE;/*=====================* * EXPORTED PROCEDURES * *=====================*/extern void PrintItoIBitRate _ANSI_ARGS_((int numBits, int frameNum));/*===============================* * INTERNAL PROCEDURE prototypes * *===============================*/void AllocDctBlocks _ANSI_ARGS_((void ));int SetFCodeHelper _ANSI_ARGS_((int sr));void CalcDistortion _ANSI_ARGS_((MpegFrame *current, int y, int x));int  SetFCodeHelper(SR)int SR;{    int     range,fCode;    if ( pixelFullSearch ) {    range = SR;    } else {    range = SR*2;    }    if ( range < 256 ) {    if ( range < 64 ) {        if ( range < 32 ) {        fCode = 1;        } else {        fCode = 2;        }    } else {        if ( range < 128 ) {        fCode = 3;        } else {        fCode = 4;        }    }    } else {    if ( range < 1024 ) {        if ( range < 512 ) {        fCode = 5;        } else {        fCode = 6;        }    } else {        if ( range < 2048 ) {        fCode = 7;        } else {        fprintf(stderr, "ERROR:  INVALID SEARCH RANGE!!!\n");        exit(1);        }    }      }    return fCode;}/*===========================================================================* * * SetFCode * *  set the forward_f_code and backward_f_code according to the search *  range.  Must be called AFTER pixelFullSearch and searchRange have *  been initialized.  Irrelevant for I-frames, but computation is *  negligible (done only once, as well) * * RETURNS: nothing * * SIDE EFFECTS:    fCodeI,fCodeP,fCodeB * *===========================================================================*/voidSetFCode(){  fCodeI = SetFCodeHelper(1); /* GenIFrame ignores value */  fCodeP = SetFCodeHelper(searchRangeP);  fCodeB = SetFCodeHelper(searchRangeB);}/*===========================================================================* * * SetSlicesPerFrame * *  set the number of slices per frame * * RETURNS: nothing * * SIDE EFFECTS:    slicesPerFrame * *===========================================================================*/voidSetSlicesPerFrame(number)    int number;{    slicesPerFrame = number;}/*===========================================================================* * * SetBlocksPerSlice * *  set the number of blocks per slice, based on slicesPerFrame * * RETURNS: nothing * * SIDE EFFECTS:    blocksPerSlice * *===========================================================================*/voidSetBlocksPerSlice(){    int     totalBlocks;    totalBlocks = (Fsize_y>>4)*(Fsize_x>>4);    if ( slicesPerFrame > totalBlocks ) {    blocksPerSlice = 1;    } else {    blocksPerSlice = totalBlocks/slicesPerFrame;    }}/*===========================================================================* * * SetIQScale * *  set the I-frame Q-scale * * RETURNS: nothing * * SIDE EFFECTS:    qscaleI * *===========================================================================*/voidSetIQScale(qI)int qI;{    qscaleI = qI;}/*===========================================================================* * * GetIQScale * *  Get the I-frame Q-scale * * RETURNS: the Iframe Qscale * * SIDE EFFECTS:    none * *===========================================================================*/intGetIQScale(){    return qscaleI;

⌨️ 快捷键说明

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