r911: some more cleaning up of dependencies
[cinelerra_cv/mob.git] / mpeg2enc / global.h
blobed20b2eabff261496aaec989f9f6bf1ce7574423
1 /* global.h, global variables, function prototypes */
3 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
5 /*
6 * Disclaimer of Warranty
8 * These software programs are available to the user without any license fee or
9 * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
10 * any and all warranties, whether express, implied, or statuary, including any
11 * implied warranties or merchantability or of fitness for a particular
12 * purpose. In no event shall the copyright-holder be liable for any
13 * incidental, punitive, or consequential damages of any kind whatsoever
14 * arising from the use of these programs.
16 * This disclaimer of warranty extends to the user of these programs and user's
17 * customers, employees, agents, transferees, successors, and assigns.
19 * The MPEG Software Simulation Group does not represent or warrant that the
20 * programs furnished hereunder are free of infringement of any third-party
21 * patents.
23 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24 * are subject to royalty fees to patent holders. Many of these patents are
25 * general enough such that they are unavoidable regardless of implementation
26 * design.
30 #include "libmpeg3.h"
31 #include "mpeg2enc.h"
32 #include "quicktime.h"
34 #include <pthread.h>
35 #include <stdint.h>
37 /* choose between declaration (GLOBAL_ undefined)
38 * and definition (GLOBAL_ defined)
39 * GLOBAL_ is defined in exactly one file (mpeg2enc.c)
42 #ifndef GLOBAL_
43 #define EXTERN_ extern
44 #else
45 #define EXTERN_
46 #endif
48 /* global variables */
51 /* zig-zag scan */
52 EXTERN_ unsigned char mpeg2_zig_zag_scan[64]
53 #ifdef GLOBAL_
56 0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,
57 12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,
58 35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,
59 58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63
61 #endif
64 /* alternate scan */
65 EXTERN_ unsigned char alternate_scan_hv[64]
66 #ifdef GLOBAL_
69 0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
70 41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
71 51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
72 53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63
74 #endif
77 /* default intra quantization matrix */
78 EXTERN_ uint16_t default_intra_quantizer_matrix_hv[64]
79 #ifdef GLOBAL_
82 8, 16, 19, 22, 26, 27, 29, 34,
83 16, 16, 22, 24, 27, 29, 34, 37,
84 19, 22, 26, 27, 29, 34, 34, 38,
85 22, 22, 26, 27, 29, 34, 37, 40,
86 22, 26, 27, 29, 32, 35, 40, 48,
87 26, 27, 29, 32, 35, 40, 48, 58,
88 26, 27, 29, 34, 38, 46, 56, 69,
89 27, 29, 35, 38, 46, 56, 69, 83
91 #endif
94 EXTERN_ uint16_t hires_intra_quantizer_matrix_hv[64]
95 #ifdef GLOBAL_
98 8, 16, 18, 20, 24, 25, 26, 30,
99 16, 16, 20, 23, 25, 26, 30, 30,
100 18, 20, 22, 24, 26, 28, 29, 31,
101 20, 21, 23, 24, 26, 28, 31, 31,
102 21, 23, 24, 25, 28, 30, 30, 33,
103 23, 24, 25, 28, 30, 30, 33, 36,
104 24, 25, 26, 29, 29, 31, 34, 38,
105 25, 26, 28, 29, 31, 34, 38, 42
107 #endif
110 /* Our default non intra quantization matrix
111 This is *not* the MPEG default
113 EXTERN_ uint16_t default_nonintra_quantizer_matrix_hv[64]
114 #ifdef GLOBAL_
118 16, 17, 18, 19, 20, 21, 22, 23,
119 17, 18, 19, 20, 21, 22, 23, 24,
120 18, 19, 20, 21, 22, 23, 24, 25,
121 19, 20, 21, 22, 23, 24, 26, 27,
122 20, 21, 22, 23, 25, 26, 27, 28,
123 21, 22, 23, 24, 26, 27, 28, 30,
124 22, 23, 24, 26, 27, 28, 30, 31,
125 23, 24, 25, 27, 28, 30, 31, 33
128 #endif
131 /* Hires non intra quantization matrix. THis *is*
132 the MPEG default... */
133 EXTERN_ uint16_t hires_nonintra_quantizer_matrix_hv[64]
134 #ifdef GLOBAL_
137 16, 16, 16, 16, 16, 16, 16, 16,
138 16, 16, 16, 16, 16, 16, 16, 16,
139 16, 16, 16, 16, 16, 16, 16, 16,
140 16, 16, 16, 16, 16, 16, 16, 16,
141 16, 16, 16, 16, 16, 16, 16, 16,
142 16, 16, 16, 16, 16, 16, 16, 16,
143 16, 16, 16, 16, 16, 16, 16, 16,
144 16, 16, 16, 16, 16, 16, 16, 16
146 #endif
149 /* non-linear quantization coefficient table */
150 EXTERN_ unsigned char non_linear_mquant_table_hv[32]
151 #ifdef GLOBAL_
154 0, 1, 2, 3, 4, 5, 6, 7,
155 8,10,12,14,16,18,20,22,
156 24,28,32,36,40,44,48,52,
157 56,64,72,80,88,96,104,112
159 #endif
162 /* non-linear mquant table for mapping from scale to code
163 * since reconstruction levels are not bijective with the index map,
164 * it is up to the designer to determine most of the quantization levels
167 EXTERN_ unsigned char map_non_linear_mquant_hv[113]
168 #ifdef GLOBAL_
171 0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,
172 16,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,
173 22,22,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,25,26,26,
174 26,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,29,
175 29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,31,31,31,31,31
177 #endif
180 struct mc_result
182 uint16_t weight;
183 int8_t x;
184 int8_t y;
187 typedef struct mc_result mc_result_s;
189 typedef struct motion_comp
191 uint8_t **oldorg, **neworg;
192 uint8_t **oldref, **newref;
193 uint8_t **cur, **curref;
194 int sxf, syf, sxb, syb;
195 } motion_comp_s;
197 typedef struct mbinfo mbinfo_s;
199 typedef struct pict_data
202 /* picture structure (header) data */
204 int temp_ref; /* temporal reference */
205 int pict_type; /* picture coding type (I, P or B) */
206 int vbv_delay; /* video buffering verifier delay (1/90000 seconds) */
207 int forw_hor_f_code, forw_vert_f_code;
208 int back_hor_f_code, back_vert_f_code; /* motion vector ranges */
209 int dc_prec; /* DC coefficient prec for intra blocks */
210 int pict_struct; /* picture structure (frame, top / bottom) */
211 int topfirst; /* display top field first */
212 int frame_pred_dct; /* Use only frame prediction... */
213 int intravlc; /* Intra VLC format */
214 int q_scale_type; /* Quantiser scale... */
215 int altscan; /* Alternate scan */
216 int repeatfirst; /* repeat first field after second field */
217 int prog_frame; /* progressive frame */
219 /* 8*8 block data, raw (unquantised) and quantised, and (eventually but
220 not yet inverse quantised */
221 int16_t (*blocks)[64];
222 int16_t (*qblocks)[64];
224 unsigned char **curorg, **curref;
225 /* macroblock side information array */
226 mbinfo_s *mbinfo;
227 /* motion estimation parameters */
228 } pict_data_s;
230 typedef struct
232 int start_row, end_row;
233 pthread_mutex_t input_lock, output_lock;
234 pthread_t tid; /* ID of thread */
235 int done;
237 motion_comp_s *motion_comp;
238 pict_data_s *pict_data;
239 int secondfield;
240 int ipflag;
242 #define MAX_44_MATCHES (256*256/(4*4))
243 int sub22_num_mcomps;
244 int sub44_num_mcomps;
245 mc_result_s sub44_mcomps[MAX_44_MATCHES];
246 mc_result_s sub22_mcomps[MAX_44_MATCHES*4];
247 } motion_engine_t;
249 #if 0
250 typedef struct
252 pthread_mutex_t ratectl_lock;
254 double R, T, d;
255 double actsum;
256 int Np, Nb;
257 double S, Q;
258 int prev_mquant;
259 double bitcnt_EOP;
260 double next_ip_delay; /* due to frame reordering delay */
261 double decoding_time;
262 int Xi, Xp, Xb, r, d0i, d0p, d0b;
263 double avg_act;
264 } ratectl_t;
265 #endif
267 typedef struct
270 * bitcnt_EOP = 0.0;
271 * next_ip_delay = 0.0;
272 * decoding_time = 0.0;
273 * P = 0; // P distance between complete intra slice refresh
274 * r = 0; // r (reaction parameter)
275 * avg_act = 0; // avg_act (initial average activity)
276 * Xi = 0; // Xi (initial I frame global complexity measure)
277 * Xp = 0; // Xp (initial P frame global complexity measure)
278 * Xb = 0; // Xb (initial B frame global complexity measure)
279 * d0i = 0; // d0i (initial I frame virtual buffer fullness)
280 * d0p = 0; // d0p (initial P frame virtual buffer fullness)
281 * d0b = 0; // d0b (initial B frame virtual buffer fullness)
283 pthread_mutex_t ratectl_lock;
285 double Xi, Xp, Xb;
286 int r;
287 int d0i, d0pb;
288 double R;
289 int d;
290 double T;
291 int CarryR;
292 int CarryRLim;
294 /* bitcnt_EOP - Position in generated bit-stream for latest
295 end-of-picture Comparing these values with the
296 bit-stream position for when the picture is due to be
297 displayed allows us to see what the vbv buffer is up
300 gop_undershoot - If we *undershoot* our bit target the vbv buffer
301 calculations based on the actual length of the
302 bitstream will be wrong because in the final system
303 stream these bits will be padded away. I.e. frames
304 *won't* arrive as early as the length of the video
305 stream would suggest they would. To get it right we
306 have to keep track of the bits that would appear in
307 padding.
312 int64_t bitcnt_EOP;
313 int gop_undershoot;
316 actsum - Total activity (sum block variances) in frame
317 actcovered - Activity macroblocks so far quantised (used to
318 fine tune quantisation to avoid starving highly
319 active blocks appearing late in frame...) UNUSED
320 avg_act - Current average activity...
322 double actsum;
323 double actcovered;
324 double sum_avg_act;
325 double avg_act;
326 double peak_act;
328 int Np, Nb;
329 int64_t S;
330 double IR;
332 /* Note: eventually we may wish to tweak these to suit image content */
333 double Ki; /* Down-scaling of I/B/P-frame complexity */
334 double Kb; /* relative to others in bit-allocation */
335 double Kp; /* calculations. We only need 2 but have all
336 3 for readability */
338 int min_d,max_d;
339 int min_q, max_q;
341 /* TODO EXPERIMENT */
342 double avg_KI; /* TODO: These values empirically determined */
343 double avg_KB; /* for MPEG-1, may need tuning for MPEG-2 */
344 double avg_KP;
345 #define K_AVG_WINDOW_I 4.0 /* TODO: MPEG-1, hard-wired settings */
346 #define K_AVG_WINDOW_P 10.0
347 #define K_AVG_WINDOW_B 20.0
348 double bits_per_mb;
350 double SQ;
351 double AQ;
353 double current_quant;
354 int64_t frame_start;
355 int64_t frame_end;
356 } ratectl_t;
358 typedef struct
360 int start_row, end_row;
361 pthread_mutex_t input_lock, output_lock;
362 pthread_t tid; /* ID of thread */
363 int done;
365 pict_data_s *picture;
366 unsigned char **pred;
367 unsigned char **cur;
368 // Temp for MMX
369 unsigned char temp[128];
370 } transform_engine_t;
372 typedef struct
374 int start_row, end_row;
375 pthread_mutex_t input_lock, output_lock;
376 pthread_t tid; /* ID of thread */
377 int done;
379 int prev_mquant;
381 /* prediction values for DCT coefficient (0,0) */
382 int dc_dct_pred[3];
384 unsigned char *frame;
385 unsigned char *slice_buffer;
386 long slice_size;
387 long slice_allocated;
388 pict_data_s *picture;
389 ratectl_t *ratectl;
390 unsigned char outbfr;
391 int outcnt;
392 } slice_engine_t;
394 EXTERN_ pthread_mutex_t test_lock;
395 EXTERN_ motion_engine_t *motion_engines;
396 EXTERN_ transform_engine_t *transform_engines;
397 EXTERN_ transform_engine_t *itransform_engines;
398 EXTERN_ slice_engine_t *slice_engines;
399 EXTERN_ ratectl_t **ratectl;
400 EXTERN_ int quiet; /* suppress warnings */
405 EXTERN_ pict_data_s cur_picture;
407 /* reconstructed frames */
408 EXTERN_ unsigned char *newrefframe[3], *oldrefframe[3], *auxframe[3];
409 /* original frames */
410 EXTERN_ unsigned char *neworgframe[3], *oldorgframe[3], *auxorgframe[3];
411 /* prediction of current frame */
412 EXTERN_ unsigned char *predframe[3];
413 /* motion estimation parameters */
414 EXTERN_ struct motion_data *motion_data;
416 /* SCale factor for fast integer arithmetic routines */
417 /* Changed this and you *must* change the quantisation routines as they depend on its absolute
418 value */
419 #define IQUANT_SCALE_POW2 16
420 #define IQUANT_SCALE (1<<IQUANT_SCALE_POW2)
421 #define COEFFSUM_SCALE (1<<16)
423 /* Orginal intra / non_intra quantization matrices */
424 EXTERN_ uint16_t intra_q[64], inter_q[64];
425 EXTERN_ uint16_t i_intra_q[64], i_inter_q[64];
427 /* Table driven intra / non-intra quantization matrices */
428 EXTERN_ uint16_t intra_q_tbl[113][64], inter_q_tbl[113][64];
429 EXTERN_ uint16_t i_intra_q_tbl[113][64], i_inter_q_tbl[113][64];
430 EXTERN_ float intra_q_tblf[113][64], inter_q_tblf[113][64];
431 EXTERN_ float i_intra_q_tblf[113][64], i_inter_q_tblf[113][64];
433 EXTERN_ uint16_t chrom_intra_q[64],chrom_inter_q[64];
439 /* clipping (=saturation) table */
440 EXTERN_ unsigned char *clp;
442 /* name strings */
443 EXTERN_ char id_string[256], tplorg[256], tplref[256], out_path[256];
444 EXTERN_ char iqname[256], niqname[256];
445 EXTERN_ char statname[256];
446 EXTERN_ char errortext[256];
448 EXTERN_ FILE *outfile; /* file descriptors */
449 EXTERN_ FILE *statfile; /* file descriptors */
450 EXTERN_ int inputtype; /* format of input frames */
453 How many frames to read ahead (eventually intended to support
454 scene change based GOP structuring. READ_LOOK_AHEAD/2 must be
455 greater than M (otherwise buffers will be overwritten that are
456 still in use).
458 It should also be a multiple of 4 due to the way buffers are
459 filled (in 1/4's).
462 #define READ_LOOK_AHEAD 4
463 EXTERN_ uint8_t ***frame_buffers;
466 /* These determine what input format to use */
467 EXTERN_ quicktime_t *qt_file;
468 EXTERN_ mpeg3_t *mpeg_file;
469 EXTERN_ int do_stdin;
470 EXTERN_ FILE *stdin_fd;
473 EXTERN_ int do_buffers;
474 EXTERN_ pthread_mutex_t input_lock;
475 EXTERN_ pthread_mutex_t output_lock;
476 EXTERN_ pthread_mutex_t copy_lock;
477 EXTERN_ char *input_buffer_y;
478 EXTERN_ char *input_buffer_u;
479 EXTERN_ char *input_buffer_v;
480 EXTERN_ int input_buffer_end;
483 EXTERN_ int verbose;
484 EXTERN_ quicktime_t *qt_output;
485 EXTERN_ unsigned char *frame_buffer;
486 EXTERN_ unsigned char **row_pointers;
487 EXTERN_ int fixed_mquant;
488 EXTERN_ double quant_floor; /* quantisation floor [1..10] (0 for CBR) */
489 EXTERN_ double act_boost; /* Quantisation reduction for highly active blocks */
490 EXTERN_ int use_hires_quant;
491 EXTERN_ int use_denoise_quant;
492 /* Number of processors */
493 EXTERN_ int processors;
494 EXTERN_ long start_frame, end_frame; /* Range to encode in source framerate units */
495 EXTERN_ int seq_header_every_gop;
497 /* coding model parameters */
499 EXTERN_ int N; /* number of frames in Group of Pictures */
500 EXTERN_ int M; /* distance between I/P frames */
501 EXTERN_ int P; /* intra slice refresh interval */
502 EXTERN_ int nframes; /* total number of frames to encode */
503 EXTERN_ long frames_scaled; /* frame count normalized to output frame rate */
504 EXTERN_ int frame0, tc0; /* number and timecode of first frame */
505 EXTERN_ int mpeg1; /* ISO/IEC IS 11172-2 sequence */
506 EXTERN_ int fieldpic; /* use field pictures */
508 /* sequence specific data (sequence header) */
510 EXTERN_ int qsubsample_offset,
511 fsubsample_offset,
512 rowsums_offset,
513 colsums_offset; /* Offset from picture buffer start of sub-sampled data... */
514 EXTERN_ int mb_per_pict; /* Number of macro-blocks in a picture */
515 EXTERN_ int fast_mc_frac; /* inverse proportion of fast motion estimates
516 consider in detail */
517 EXTERN_ int mc_44_red; /* Sub-mean population reduction passes for 4x4 and 2x2 */
518 EXTERN_ int mc_22_red; /* Motion compensation stages */
522 EXTERN_ int horizontal_size, vertical_size; /* frame size (pels) */
523 EXTERN_ int width, height; /* encoded frame size (pels) multiples of 16 or 32 */
524 EXTERN_ int chrom_width, chrom_height, block_count;
525 EXTERN_ int mb_width, mb_height; /* frame size (macroblocks) */
526 EXTERN_ int width2, height2, mb_height2, chrom_width2; /* picture size adjusted for interlacing */
527 EXTERN_ int aspectratio; /* aspect ratio information (pel or display) */
528 EXTERN_ int frame_rate_code; /* coded value of frame rate */
529 EXTERN_ int dctsatlim; /* Value to saturated DCT coeffs to */
530 EXTERN_ double frame_rate; /* frames per second */
531 EXTERN_ double input_frame_rate; /* input frame rate */
532 EXTERN_ double bit_rate; /* bits per second */
533 EXTERN_ int video_buffer_size;
534 EXTERN_ int vbv_buffer_size; /* size of VBV buffer (* 16 kbit) */
535 EXTERN_ int constrparms; /* constrained parameters flag (MPEG-1 only) */
536 EXTERN_ int load_iquant, load_niquant; /* use non-default quant. matrices */
537 EXTERN_ int load_ciquant,load_cniquant;
540 /* sequence specific data (sequence extension) */
542 EXTERN_ int profile, level; /* syntax / parameter constraints */
543 EXTERN_ int prog_seq; /* progressive sequence */
544 EXTERN_ int chroma_format;
545 EXTERN_ int low_delay; /* no B pictures, skipped pictures */
548 /* sequence specific data (sequence display extension) */
550 EXTERN_ int video_format; /* component, PAL, NTSC, SECAM or MAC */
551 EXTERN_ int color_primaries; /* source primary chromaticity coordinates */
552 EXTERN_ int transfer_characteristics; /* opto-electronic transfer char. (gamma) */
553 EXTERN_ int matrix_coefficients; /* Eg,Eb,Er / Y,Cb,Cr matrix coefficients */
554 EXTERN_ int display_horizontal_size, display_vertical_size; /* display size */
557 /* picture specific data (picture coding extension) */
558 EXTERN_ int opt_dc_prec;
559 EXTERN_ int opt_prog_frame;
560 EXTERN_ int opt_repeatfirst;
561 EXTERN_ int opt_topfirst;
563 /* use only frame prediction and frame DCT (I,P,B,current) */
564 EXTERN_ int frame_pred_dct_tab[3];
565 EXTERN_ int conceal_tab[3]; /* use concealment motion vectors (I,P,B) */
566 EXTERN_ int qscale_tab[3]; /* linear/non-linear quantizaton table */
567 EXTERN_ int intravlc_tab[3]; /* intra vlc format (I,P,B,current) */
568 EXTERN_ int altscan_tab[3]; /* alternate scan (I,P,B,current) */
570 /* prototypes of global functions */
572 /* conform.c */
573 void range_checks _ANSI_ARGS_((void));
574 void profile_and_level_checks _ANSI_ARGS_(());
576 /* fdctref.c */
577 void init_fdct _ANSI_ARGS_((void));
579 /* idct.c */
580 void init_idct _ANSI_ARGS_((void));
582 /* motion.c */
583 void motion_estimation _ANSI_ARGS_((pict_data_s *picture,
584 motion_comp_s *mc_data,
585 int secondfield, int ipflag));
587 /* mpeg2enc.c */
588 void error _ANSI_ARGS_((char *text));
590 /* predict.c */
591 void predict _ANSI_ARGS_((pict_data_s *picture,
592 uint8_t *reff[],
593 uint8_t *refb[],
594 uint8_t *cur[3],
595 int secondfield));
597 /* putbits.c */
598 void slice_initbits(slice_engine_t *engine);
599 void slice_putbits(slice_engine_t *engine, long val, int n);
600 void slice_alignbits(slice_engine_t *engine);
601 void slice_finishslice(slice_engine_t *engine);
604 void mpeg2_initbits _ANSI_ARGS_((void));
605 void putbits _ANSI_ARGS_((int val, int n));
606 void alignbits _ANSI_ARGS_((void));
607 double bitcount _ANSI_ARGS_((void));
609 /* puthdr.c */
610 void putseqhdr _ANSI_ARGS_((void));
611 void putseqext _ANSI_ARGS_((void));
612 void putseqdispext _ANSI_ARGS_((void));
613 void putuserdata _ANSI_ARGS_((char *userdata));
614 void putgophdr _ANSI_ARGS_((int frame, int closed_gop));
615 void putpicthdr _ANSI_ARGS_((pict_data_s *picture));
616 void putpictcodext _ANSI_ARGS_((pict_data_s *picture));
617 void putseqend _ANSI_ARGS_((void));
619 /* putmpg.c */
620 void putintrablk _ANSI_ARGS_((slice_engine_t *engine, pict_data_s *picture, short *blk, int cc));
621 void putnonintrablk _ANSI_ARGS_((slice_engine_t *engine, pict_data_s *picture, short *blk));
622 void putmv _ANSI_ARGS_((slice_engine_t *engine, int dmv, int f_code));
624 /* putpic.c */
625 void putpict _ANSI_ARGS_((pict_data_s *picture));
627 /* putseq.c */
628 void putseq _ANSI_ARGS_((void));
630 /* putvlc.c */
631 void putDClum _ANSI_ARGS_((slice_engine_t *engine, int val));
632 void putDCchrom _ANSI_ARGS_((slice_engine_t *engine, int val));
633 void putACfirst _ANSI_ARGS_((slice_engine_t *engine, int run, int val));
634 void putAC _ANSI_ARGS_((slice_engine_t *engine, int run, int signed_level, int vlcformat));
635 void putaddrinc _ANSI_ARGS_((slice_engine_t *engine, int addrinc));
636 void putmbtype _ANSI_ARGS_((slice_engine_t *engine, int pict_type, int mb_type));
637 void putmotioncode _ANSI_ARGS_((slice_engine_t *engine, int motion_code));
638 void putdmv _ANSI_ARGS_((slice_engine_t *engine, int dmv));
639 void putcbp _ANSI_ARGS_((slice_engine_t *engine, int cbp));
641 extern int (*pquant_non_intra)(pict_data_s *picture, int16_t *src, int16_t *dst,
642 int mquant, int *nonsat_mquant);
644 extern int (*pquant_weight_coeff_sum)(int16_t *blk, uint16_t*i_quant_mat );
646 /* quantize.c */
648 void iquantize( pict_data_s *picture );
649 void quant_intra_hv ( pict_data_s *picture,
650 int16_t *src, int16_t *dst,
651 int mquant, int *nonsat_mquant);
652 int quant_non_intra_hv( pict_data_s *picture,
653 int16_t *src, int16_t *dst,
654 int mquant, int *nonsat_mquant);
655 void iquant_intra ( int16_t *src, int16_t *dst, int dc_prec, int mquant);
656 void iquant_non_intra (int16_t *src, int16_t *dst, int mquant);
657 void init_quantizer_hv();
658 int next_larger_quant_hv( pict_data_s *picture, int quant );
660 extern int (*pquant_non_intra)(pict_data_s *picture, int16_t *src, int16_t *dst,
661 int mquant, int *nonsat_mquant);
663 extern int (*pquant_weight_coeff_sum)(int16_t *blk, uint16_t*i_quant_mat );
665 /* ratectl.c */
666 void ratectl_init_seq _ANSI_ARGS_((ratectl_t *ratectl));
667 void ratectl_init_GOP _ANSI_ARGS_((ratectl_t *ratectl, int np, int nb));
668 void ratectl_init_pict _ANSI_ARGS_((ratectl_t *ratectl, pict_data_s *picture));
669 void ratectl_update_pict _ANSI_ARGS_((ratectl_t *ratectl, pict_data_s *picture));
670 int ratectl_start_mb _ANSI_ARGS_((ratectl_t *ratectl, pict_data_s *picture));
671 int ratectl_calc_mquant _ANSI_ARGS_((ratectl_t *ratectl, pict_data_s *picture, int j));
672 void vbv_end_of_picture _ANSI_ARGS_((void));
673 void calc_vbv_delay _ANSI_ARGS_((void));
675 /* readpic.c */
676 void readframe _ANSI_ARGS_((int frame_num, uint8_t *frame[]));
678 /* stats.c */
679 void calcSNR _ANSI_ARGS_((unsigned char *org[3], unsigned char *rec[3]));
680 void stats _ANSI_ARGS_((void));
682 /* transfrm.c */
683 void transform _ANSI_ARGS_((pict_data_s *picture,
684 uint8_t *pred[],
685 uint8_t *cur[]));
686 void itransform _ANSI_ARGS_((pict_data_s *picture,
687 uint8_t *pred[], uint8_t *cur[]));
688 void dct_type_estimation _ANSI_ARGS_((pict_data_s *picture,
689 uint8_t *pred, uint8_t *cur));