r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / quicktime / encore50 / mom_access.c
blobe4d5f52807310048df02ea4773baedc4408eb55b
2 /**************************************************************************
3 * *
4 * This code is developed by Adam Li. This software is an *
5 * implementation of a part of one or more MPEG-4 Video tools as *
6 * specified in ISO/IEC 14496-2 standard. Those intending to use this *
7 * software module in hardware or software products are advised that its *
8 * use may infringe existing patents or copyrights, and any such use *
9 * would be at such party's own risk. The original developer of this *
10 * software module and his/her company, and subsequent editors and their *
11 * companies (including Project Mayo), will have no liability for use of *
12 * this software or modifications or derivatives thereof. *
13 * *
14 * Project Mayo gives users of the Codec a license to this software *
15 * module or modifications thereof for use in hardware or software *
16 * products claiming conformance to the MPEG-4 Video Standard as *
17 * described in the Open DivX license. *
18 * *
19 * The complete Open DivX license can be found at *
20 * http://www.projectmayo.com/opendivx/license.php . *
21 * *
22 **************************************************************************/
24 /**************************************************************************
26 * mom_access.c
28 * Copyright (C) 2001 Project Mayo
30 * Adam Li
32 * DivX Advance Research Center <darc@projectmayo.com>
34 **************************************************************************/
36 /* This file contains memory access for the Image, Vop and VolConfig data */
37 /* structures. */
38 /* Some codes of this project come from MoMuSys MPEG-4 implementation. */
39 /* Please see seperate acknowledgement file for a list of contributors. */
41 #include "mom_access.h"
43 /***********************************************************CommentBegin******
45 * -- GetImage{xxx} -- Access components of intermediate formats
47 * Char *GetImageData(Image *image)
48 * UInt GetImageSize(Image *image)
49 * UInt GetImageSizeX(Image *image)
50 * UInt GetImageSizeY(Image *image)
51 * Int GetImageVersion(Image *image)
52 * ImageType GetImageType(Image *image)
54 * Purpose :
55 * These are common functions to access specific components
56 * of the common data structures which are used for the
57 * intermediate formats.
59 ***********************************************************CommentEnd********/
61 Char *
62 GetImageData(Image *image)
64 switch(GetImageType(image))
66 case SHORT_TYPE:
67 return((Char *)image->data->s);
68 break;
69 case FLOAT_TYPE:
70 return((Char *)image->data->f);
71 break;
72 case UCHAR_TYPE:
73 return((Char *)image->data->u);
74 break;
75 default:
76 printf("Image type >>%d<< not supported\n",image->type);
77 return(NULL);
82 UInt
83 GetImageSize(Image *image)
85 return(image->x * image->y);
89 UInt
90 GetImageSizeX(Image *image)
92 return(image->x);
96 UInt
97 GetImageSizeY(Image *image)
99 return(image->y);
104 GetImageVersion(Image *image)
106 return(image->version);
110 ImageType
111 GetImageType(Image *image)
113 return(image->type);
118 /***********************************************************CommentBegin******
120 * -- GetVop{xxx} -- Functions to access components of the Vop structure
122 * Purpose :
123 * These are common functions to access specific components
124 * of the Vop data structure.
126 ***********************************************************CommentEnd********/
129 Int GetVopNot8Bit(Vop *vop)
131 return (vop->bits_per_pixel != 8);
135 Int GetVopQuantPrecision(Vop *vop)
137 return (vop->quant_precision);
141 Int GetVopBitsPerPixel(Vop *vop)
143 return (vop->bits_per_pixel);
147 Int GetVopMidGrey(Vop *vop)
149 return (1 << (vop->bits_per_pixel - 1));
153 Int GetVopBrightWhite(Vop *vop)
155 return ((1 << vop->bits_per_pixel) - 1);
159 Int GetVopTimeIncrementResolution(Vop *vop)
161 return (vop->time_increment_resolution);
166 GetVopModTimeBase(Vop *vop)
168 return(vop->mod_time_base);
173 GetVopTimeInc(Vop *vop)
175 return((int)vop->time_inc);
180 GetVopPredictionType(Vop *vop)
182 return(vop->prediction_type);
186 Int GetVopIntraDCVlcThr(Vop *vop)
188 return (vop->intra_dc_vlc_thr);
193 GetVopRoundingType(Vop *vop)
195 return(vop->rounding_type);
200 GetVopWidth(Vop *vop)
202 return(vop->width);
207 GetVopHeight(Vop *vop)
209 return(vop->height);
214 GetVopHorSpatRef(Vop *vop)
216 return(vop->hor_spat_ref);
221 GetVopVerSpatRef(Vop *vop)
223 return(vop->ver_spat_ref);
228 GetVopQuantizer(Vop *vop)
230 return(vop->quantizer);
235 GetVopIntraQuantizer(Vop *vop)
237 return(vop->intra_quantizer);
242 GetVopIntraACDCPredDisable(Vop *vop)
244 return(vop->intra_acdc_pred_disable);
249 GetVopFCodeFor(Vop *vop)
251 return(vop->fcode_for);
256 GetVopSearchRangeFor(Vop *vop)
258 return(vop->sr_for);
262 Image *
263 GetVopY(Vop *vop)
265 return(vop->y_chan);
269 Image *
270 GetVopU(Vop *vop)
272 return(vop->u_chan);
276 Image *
277 GetVopV(Vop *vop)
279 return(vop->v_chan);
283 /***********************************************************CommentBegin******
285 * -- PutVop{xxx} -- Functions to write to components of the Vop structure
287 * These are common functions to write to specific components
288 * of the Vop structure.
290 ***********************************************************CommentEnd********/
293 Void PutVopQuantPrecision(Int quant_precision,Vop *vop)
295 vop->quant_precision = quant_precision;
299 Void PutVopBitsPerPixel(Int bits_per_pixel,Vop *vop)
301 vop->bits_per_pixel = bits_per_pixel;
305 Void PutVopTimeIncrementResolution(Int time_incre_res, Vop *vop)
307 vop->time_increment_resolution=time_incre_res;
311 Void
312 PutVopModTimeBase(Int mod_time_base, Vop *vop)
314 vop->mod_time_base = mod_time_base;
318 Void
319 PutVopTimeInc(Int time_inc, Vop *vop)
321 vop->time_inc = (float)time_inc;
325 Void
326 PutVopPredictionType(Int prediction_type, Vop *vop)
328 vop->prediction_type = prediction_type;
332 Void PutVopIntraDCVlcThr(Int intra_dc_vlc_thr,Vop *vop)
334 vop->intra_dc_vlc_thr=intra_dc_vlc_thr;
338 Void
339 PutVopRoundingType(Int rounding_type, Vop *vop)
341 vop->rounding_type = rounding_type;
345 Void
346 PutVopWidth(Int width, Vop *vop)
348 vop->width = width;
352 Void
353 PutVopHeight(Int height, Vop *vop)
355 vop->height = height;
359 Void
360 PutVopHorSpatRef(Int hor_spat_ref, Vop *vop)
362 vop->hor_spat_ref = hor_spat_ref;
366 Void
367 PutVopVerSpatRef(Int ver_spat_ref, Vop *vop)
369 vop->ver_spat_ref = ver_spat_ref;
373 Void
374 PutVopQuantizer(Int quantizer, Vop *vop)
376 vop->quantizer = quantizer;
380 Void
381 PutVopIntraACDCPredDisable(Int intra_acdc_pred_disable, Vop *vop)
383 vop->intra_acdc_pred_disable = intra_acdc_pred_disable;
387 Void
388 PutVopFCodeFor(Int fcode_for, Vop *vop)
390 vop->fcode_for = fcode_for;
394 Void
395 PutVopSearchRangeFor(Int sr_for, Vop *vop)
397 vop->sr_for = sr_for;
401 Void
402 PutVopY(Image *y_chan, Vop *vop)
404 FreeImage(vop->y_chan);
405 vop->y_chan = y_chan;
409 Void
410 PutVopU(Image *u_chan, Vop *vop)
412 FreeImage(vop->u_chan);
413 vop->u_chan = u_chan;
417 Void
418 PutVopV(Image *v_chan, Vop *vop)
420 FreeImage(vop->v_chan);
421 vop->v_chan = v_chan;
425 Void
426 PutVopIntraQuantizer(Int Q,Vop *vop)
428 vop->intra_quantizer = Q;
432 /***********************************************************CommentBegin******
434 * -- PutVolConfigXXXX -- Access functions for VolConfig
436 * Purpose :
437 * To set particular fields in a VolConfig strcuture
439 ***********************************************************CommentEnd********/
442 Void
443 PutVolConfigFrameRate(Float fr, VolConfig *cfg)
445 cfg->frame_rate = fr;
449 Void
450 PutVolConfigM(Int M, VolConfig *cfg)
452 cfg->M = M;
456 Void
457 PutVolConfigStartFrame(Int frame, VolConfig *cfg)
459 cfg->start_frame = frame;
463 Void
464 PutVolConfigEndFrame(Int frame, VolConfig *cfg)
466 cfg->end_frame = frame;
470 Void
471 PutVolConfigBitrate(Int bit_rate,VolConfig *cfg)
473 cfg->bit_rate = bit_rate;
477 Void
478 PutVolConfigIntraPeriod(Int ir,VolConfig *cfg)
480 cfg->intra_period = ir;
484 Void
485 PutVolConfigQuantizer(Int Q,VolConfig *cfg)
487 cfg->quantizer = Q;
491 Void
492 PutVolConfigIntraQuantizer(Int Q,VolConfig *cfg)
494 cfg->intra_quantizer = Q;
498 Void
499 PutVolConfigFrameSkip(Int frame_skip,VolConfig *cfg)
501 cfg->frame_skip = frame_skip;
505 Void
506 PutVolConfigModTimeBase(Int time,VolConfig *cfg)
508 cfg->modulo_time_base[0] = cfg->modulo_time_base[1];
509 cfg->modulo_time_base[1] = time;
513 /***********************************************************CommentBegin******
515 * -- GetVolConfigXXXX -- Access functions for VolConfig
517 * Purpose :
518 * To obtain the value of particular fields in a VolConfig structure
520 ***********************************************************CommentEnd********/
523 Float
524 GetVolConfigFrameRate(VolConfig *cfg)
526 return(cfg->frame_rate);
531 GetVolConfigM(VolConfig *cfg)
533 return(cfg->M);
538 GetVolConfigStartFrame(VolConfig *cfg)
540 return(cfg->start_frame);
545 GetVolConfigEndFrame(VolConfig *cfg)
547 return(cfg->end_frame);
552 GetVolConfigBitrate(VolConfig *cfg)
554 return(cfg->bit_rate);
559 GetVolConfigIntraPeriod(VolConfig *cfg)
561 return(cfg->intra_period);
566 GetVolConfigQuantizer(VolConfig *cfg)
568 return(cfg->quantizer);
573 GetVolConfigIntraQuantizer(VolConfig *cfg)
575 return(cfg->intra_quantizer);
580 GetVolConfigFrameSkip(VolConfig *cfg)
582 return(cfg->frame_skip);
587 GetVolConfigModTimeBase(VolConfig *cfg,Int i)
589 return(cfg->modulo_time_base[i]);