📄 mom_access.c
字号:
/************************************************************************** * * * This code is developed by Adam Li. This software is an * * implementation of a part of one or more MPEG-4 Video tools as * * specified in ISO/IEC 14496-2 standard. Those intending to use this * * software module in hardware or software products are advised that its * * use may infringe existing patents or copyrights, and any such use * * would be at such party's own risk. The original developer of this * * software module and his/her company, and subsequent editors and their * * companies (including Project Mayo), will have no liability for use of * * this software or modifications or derivatives thereof. * * * * Project Mayo gives users of the Codec a license to this software * * module or modifications thereof for use in hardware or software * * products claiming conformance to the MPEG-4 Video Standard as * * described in the Open DivX license. * * * * The complete Open DivX license can be found at * * http://www.projectmayo.com/opendivx/license.php . * * * **************************************************************************//************************************************************************** * * mom_access.c * * Copyright (C) 2001 Project Mayo * * Adam Li * * DivX Advance Research Center <darc@projectmayo.com> * **************************************************************************//* This file contains memory access for the Image, Vop and VolConfig data *//* structures. *//* Some codes of this project come from MoMuSys MPEG-4 implementation. *//* Please see seperate acknowledgement file for a list of contributors. */#include "mom_access.h"/***********************************************************CommentBegin****** * * -- GetImage{xxx} -- Access components of intermediate formats * * Char *GetImageData(Image *image) * UInt GetImageSize(Image *image) * UInt GetImageSizeX(Image *image) * UInt GetImageSizeY(Image *image) * Int GetImageVersion(Image *image) * ImageType GetImageType(Image *image) * * Purpose : * These are common functions to access specific components * of the common data structures which are used for the * intermediate formats. * ***********************************************************CommentEnd********/Char *GetImageData(Image *image){ switch(GetImageType(image)) { case SHORT_TYPE: return((Char *)image->data->s); break; case FLOAT_TYPE: return((Char *)image->data->f); break; case UCHAR_TYPE: return((Char *)image->data->u); break; default: printf("Image type >>%d<< not supported\n",image->type); return(NULL); }}UIntGetImageSize(Image *image){ return(image->x * image->y);}UIntGetImageSizeX(Image *image){ return(image->x);}UIntGetImageSizeY(Image *image){ return(image->y);}IntGetImageVersion(Image *image){ return(image->version);}ImageTypeGetImageType(Image *image){ return(image->type);}/***********************************************************CommentBegin****** * * -- GetVop{xxx} -- Functions to access components of the Vop structure * * Purpose : * These are common functions to access specific components * of the Vop data structure. * ***********************************************************CommentEnd********/Int GetVopNot8Bit(Vop *vop){ return (vop->bits_per_pixel != 8);}Int GetVopQuantPrecision(Vop *vop){ return (vop->quant_precision);}Int GetVopBitsPerPixel(Vop *vop){ return (vop->bits_per_pixel);}Int GetVopMidGrey(Vop *vop){ return (1 << (vop->bits_per_pixel - 1));}Int GetVopBrightWhite(Vop *vop){ return ((1 << vop->bits_per_pixel) - 1);}Int GetVopTimeIncrementResolution(Vop *vop){ return (vop->time_increment_resolution);}IntGetVopModTimeBase(Vop *vop){ return(vop->mod_time_base);}IntGetVopTimeInc(Vop *vop){ return((int)vop->time_inc);}IntGetVopPredictionType(Vop *vop){ return(vop->prediction_type);}Int GetVopIntraDCVlcThr(Vop *vop){ return (vop->intra_dc_vlc_thr);}IntGetVopRoundingType(Vop *vop){ return(vop->rounding_type);}IntGetVopWidth(Vop *vop){ return(vop->width);}IntGetVopHeight(Vop *vop){ return(vop->height);}IntGetVopHorSpatRef(Vop *vop){ return(vop->hor_spat_ref);}IntGetVopVerSpatRef(Vop *vop){ return(vop->ver_spat_ref);}IntGetVopQuantizer(Vop *vop){ return(vop->quantizer);}IntGetVopIntraQuantizer(Vop *vop){ return(vop->intra_quantizer);}IntGetVopIntraACDCPredDisable(Vop *vop){ return(vop->intra_acdc_pred_disable);}IntGetVopFCodeFor(Vop *vop){ return(vop->fcode_for);}IntGetVopSearchRangeFor(Vop *vop){ return(vop->sr_for);}Image *GetVopY(Vop *vop){ return(vop->y_chan);}Image *GetVopU(Vop *vop){ return(vop->u_chan);}Image *GetVopV(Vop *vop){ return(vop->v_chan);}/***********************************************************CommentBegin****** * * -- PutVop{xxx} -- Functions to write to components of the Vop structure * * These are common functions to write to specific components * of the Vop structure. * ***********************************************************CommentEnd********/Void PutVopQuantPrecision(Int quant_precision,Vop *vop){ vop->quant_precision = quant_precision;}Void PutVopBitsPerPixel(Int bits_per_pixel,Vop *vop){ vop->bits_per_pixel = bits_per_pixel;}Void PutVopTimeIncrementResolution(Int time_incre_res, Vop *vop){ vop->time_increment_resolution=time_incre_res;}VoidPutVopModTimeBase(Int mod_time_base, Vop *vop){ vop->mod_time_base = mod_time_base;}VoidPutVopTimeInc(Int time_inc, Vop *vop){ vop->time_inc = (float)time_inc;}VoidPutVopPredictionType(Int prediction_type, Vop *vop){ vop->prediction_type = prediction_type;}Void PutVopIntraDCVlcThr(Int intra_dc_vlc_thr,Vop *vop){ vop->intra_dc_vlc_thr=intra_dc_vlc_thr;}VoidPutVopRoundingType(Int rounding_type, Vop *vop){ vop->rounding_type = rounding_type;}VoidPutVopWidth(Int width, Vop *vop){ vop->width = width;}VoidPutVopHeight(Int height, Vop *vop){ vop->height = height;}VoidPutVopHorSpatRef(Int hor_spat_ref, Vop *vop){ vop->hor_spat_ref = hor_spat_ref;}VoidPutVopVerSpatRef(Int ver_spat_ref, Vop *vop){ vop->ver_spat_ref = ver_spat_ref;}VoidPutVopQuantizer(Int quantizer, Vop *vop){ vop->quantizer = quantizer;}VoidPutVopIntraACDCPredDisable(Int intra_acdc_pred_disable, Vop *vop){ vop->intra_acdc_pred_disable = intra_acdc_pred_disable;}VoidPutVopFCodeFor(Int fcode_for, Vop *vop){ vop->fcode_for = fcode_for;}VoidPutVopSearchRangeFor(Int sr_for, Vop *vop){ vop->sr_for = sr_for;}VoidPutVopY(Image *y_chan, Vop *vop){ FreeImage(vop->y_chan); vop->y_chan = y_chan;}VoidPutVopU(Image *u_chan, Vop *vop){ FreeImage(vop->u_chan); vop->u_chan = u_chan;}VoidPutVopV(Image *v_chan, Vop *vop){ FreeImage(vop->v_chan); vop->v_chan = v_chan;}VoidPutVopIntraQuantizer(Int Q,Vop *vop){ vop->intra_quantizer = Q;}/***********************************************************CommentBegin****** * * -- PutVolConfigXXXX -- Access functions for VolConfig * * Purpose : * To set particular fields in a VolConfig strcuture * ***********************************************************CommentEnd********/VoidPutVolConfigFrameRate(Float fr, VolConfig *cfg){ cfg->frame_rate = fr;}VoidPutVolConfigM(Int M, VolConfig *cfg){ cfg->M = M;}VoidPutVolConfigStartFrame(Int frame, VolConfig *cfg){ cfg->start_frame = frame;}VoidPutVolConfigEndFrame(Int frame, VolConfig *cfg){ cfg->end_frame = frame;}VoidPutVolConfigBitrate(Int bit_rate,VolConfig *cfg){ cfg->bit_rate = bit_rate;}VoidPutVolConfigIntraPeriod(Int ir,VolConfig *cfg){ cfg->intra_period = ir;}VoidPutVolConfigQuantizer(Int Q,VolConfig *cfg){ cfg->quantizer = Q;}VoidPutVolConfigIntraQuantizer(Int Q,VolConfig *cfg){ cfg->intra_quantizer = Q;}VoidPutVolConfigFrameSkip(Int frame_skip,VolConfig *cfg){ cfg->frame_skip = frame_skip;}VoidPutVolConfigModTimeBase(Int time,VolConfig *cfg){ cfg->modulo_time_base[0] = cfg->modulo_time_base[1]; cfg->modulo_time_base[1] = time;}/***********************************************************CommentBegin****** * * -- GetVolConfigXXXX -- Access functions for VolConfig * * Purpose : * To obtain the value of particular fields in a VolConfig structure * ***********************************************************CommentEnd********/FloatGetVolConfigFrameRate(VolConfig *cfg){ return(cfg->frame_rate);}IntGetVolConfigM(VolConfig *cfg){ return(cfg->M);}IntGetVolConfigStartFrame(VolConfig *cfg){ return(cfg->start_frame);}IntGetVolConfigEndFrame(VolConfig *cfg){ return(cfg->end_frame);}IntGetVolConfigBitrate(VolConfig *cfg){ return(cfg->bit_rate);}IntGetVolConfigIntraPeriod(VolConfig *cfg){ return(cfg->intra_period);}IntGetVolConfigQuantizer(VolConfig *cfg){ return(cfg->quantizer);}IntGetVolConfigIntraQuantizer(VolConfig *cfg){ return(cfg->intra_quantizer);}IntGetVolConfigFrameSkip(VolConfig *cfg){ return(cfg->frame_skip);}IntGetVolConfigModTimeBase(VolConfig *cfg,Int i){ return(cfg->modulo_time_base[i]);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -