Fixed bugs in multi-layer code related to changing params
[profile/ivi/libvpx.git] / vp8 / encoder / onyx_int.h
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11
12 #ifndef __INC_VP8_INT_H
13 #define __INC_VP8_INT_H
14
15 #include <stdio.h>
16 #include "vpx_config.h"
17 #include "vp8/common/onyx.h"
18 #include "treewriter.h"
19 #include "tokenize.h"
20 #include "vp8/common/onyxc_int.h"
21 #include "variance.h"
22 #include "dct.h"
23 #include "encodemb.h"
24 #include "quantize.h"
25 #include "vp8/common/entropy.h"
26 #include "vp8/common/threading.h"
27 #include "vpx_ports/mem.h"
28 #include "vpx/internal/vpx_codec_internal.h"
29 #include "mcomp.h"
30 #include "temporal_filter.h"
31 #include "vp8/common/findnearmv.h"
32 #include "lookahead.h"
33
34 //#define SPEEDSTATS 1
35 #define MIN_GF_INTERVAL             4
36 #define DEFAULT_GF_INTERVAL         7
37
38 #define KEY_FRAME_CONTEXT 5
39
40 #define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY? 1 : 25)
41
42 #define AF_THRESH   25
43 #define AF_THRESH2  100
44 #define ARF_DECAY_THRESH 12
45 #define MAX_MODES 20
46
47 #define MIN_THRESHMULT  32
48 #define MAX_THRESHMULT  512
49
50 #define GF_ZEROMV_ZBIN_BOOST 12
51 #define LF_ZEROMV_ZBIN_BOOST 6
52 #define MV_ZBIN_BOOST        4
53 #define ZBIN_OQ_MAX 192
54
55 #if !(CONFIG_REALTIME_ONLY)
56 #define VP8_TEMPORAL_ALT_REF 1
57 #endif
58
59 #define MAX_PERIODICITY 16
60
61 #define MAX(x,y) (((x)>(y))?(x):(y))
62 #define MIN(x,y) (((x)<(y))?(x):(y))
63
64 typedef struct
65 {
66     int kf_indicated;
67     unsigned int frames_since_key;
68     unsigned int frames_since_golden;
69     int filter_level;
70     int frames_till_gf_update_due;
71     int recent_ref_frame_usage[MAX_REF_FRAMES];
72
73     MV_CONTEXT mvc[2];
74     int mvcosts[2][MVvals+1];
75
76 #ifdef MODE_STATS
77     // Stats
78     int y_modes[5];
79     int uv_modes[4];
80     int b_modes[10];
81     int inter_y_modes[10];
82     int inter_uv_modes[4];
83     int inter_b_modes[10];
84 #endif
85
86     vp8_prob ymode_prob[4], uv_mode_prob[3];   /* interframe intra mode probs */
87     vp8_prob kf_ymode_prob[4], kf_uv_mode_prob[3];   /* keyframe "" */
88
89     int ymode_count[5], uv_mode_count[4];  /* intra MB type cts this frame */
90
91     int count_mb_ref_frame_usage[MAX_REF_FRAMES];
92
93     int this_frame_percent_intra;
94     int last_frame_percent_intra;
95
96
97 } CODING_CONTEXT;
98
99 typedef struct
100 {
101     double frame;
102     double intra_error;
103     double coded_error;
104     double ssim_weighted_pred_err;
105     double pcnt_inter;
106     double pcnt_motion;
107     double pcnt_second_ref;
108     double pcnt_neutral;
109     double MVr;
110     double mvr_abs;
111     double MVc;
112     double mvc_abs;
113     double MVrv;
114     double MVcv;
115     double mv_in_out_count;
116     double new_mv_count;
117     double duration;
118     double count;
119 }
120 FIRSTPASS_STATS;
121
122 typedef struct
123 {
124     int frames_so_far;
125     double frame_intra_error;
126     double frame_coded_error;
127     double frame_pcnt_inter;
128     double frame_pcnt_motion;
129     double frame_mvr;
130     double frame_mvr_abs;
131     double frame_mvc;
132     double frame_mvc_abs;
133
134 } ONEPASS_FRAMESTATS;
135
136
137 typedef enum
138 {
139     THR_ZERO1          = 0,
140     THR_DC             = 1,
141
142     THR_NEAREST1       = 2,
143     THR_NEAR1          = 3,
144
145     THR_ZERO2          = 4,
146     THR_NEAREST2       = 5,
147
148     THR_ZERO3          = 6,
149     THR_NEAREST3       = 7,
150
151     THR_NEAR2          = 8,
152     THR_NEAR3          = 9,
153
154     THR_V_PRED         = 10,
155     THR_H_PRED         = 11,
156     THR_TM             = 12,
157
158     THR_NEW1           = 13,
159     THR_NEW2           = 14,
160     THR_NEW3           = 15,
161
162     THR_SPLIT1         = 16,
163     THR_SPLIT2         = 17,
164     THR_SPLIT3         = 18,
165
166     THR_B_PRED         = 19,
167 }
168 THR_MODES;
169
170 typedef enum
171 {
172     DIAMOND = 0,
173     NSTEP = 1,
174     HEX = 2
175 } SEARCH_METHODS;
176
177 typedef struct
178 {
179     int RD;
180     SEARCH_METHODS search_method;
181     int improved_quant;
182     int improved_dct;
183     int auto_filter;
184     int recode_loop;
185     int iterative_sub_pixel;
186     int half_pixel_search;
187     int quarter_pixel_search;
188     int thresh_mult[MAX_MODES];
189     int max_step_search_steps;
190     int first_step;
191     int optimize_coefficients;
192
193     int use_fastquant_for_pick;
194     int no_skip_block4x4_search;
195     int improved_mv_pred;
196
197 } SPEED_FEATURES;
198
199 typedef struct
200 {
201     MACROBLOCK  mb;
202     int segment_counts[MAX_MB_SEGMENTS];
203     int totalrate;
204 } MB_ROW_COMP;
205
206 typedef struct
207 {
208     TOKENEXTRA *start;
209     TOKENEXTRA *stop;
210 } TOKENLIST;
211
212 typedef struct
213 {
214     int ithread;
215     void *ptr1;
216     void *ptr2;
217 } ENCODETHREAD_DATA;
218 typedef struct
219 {
220     int ithread;
221     void *ptr1;
222 } LPFTHREAD_DATA;
223
224
225 typedef struct VP8_ENCODER_RTCD
226 {
227     VP8_COMMON_RTCD            *common;
228     vp8_variance_rtcd_vtable_t  variance;
229     vp8_fdct_rtcd_vtable_t      fdct;
230     vp8_encodemb_rtcd_vtable_t  encodemb;
231     vp8_quantize_rtcd_vtable_t  quantize;
232     vp8_search_rtcd_vtable_t    search;
233     vp8_temporal_rtcd_vtable_t  temporal;
234 } VP8_ENCODER_RTCD;
235
236 enum
237 {
238     BLOCK_16X8,
239     BLOCK_8X16,
240     BLOCK_8X8,
241     BLOCK_4X4,
242     BLOCK_16X16,
243     BLOCK_MAX_SEGMENTS
244 };
245
246 typedef struct
247 {
248     // Layer configuration
249     double frame_rate;
250     int target_bandwidth;
251
252     // Layer specific coding parameters
253     int starting_buffer_level;
254     int optimal_buffer_level;
255     int maximum_buffer_size;
256     int starting_buffer_level_in_ms;
257     int optimal_buffer_level_in_ms;
258     int maximum_buffer_size_in_ms;
259
260     int avg_frame_size_for_layer;
261
262     int buffer_level;
263     int bits_off_target;
264
265     int64_t total_actual_bits;
266     int total_target_vs_actual;
267
268     int worst_quality;
269     int active_worst_quality;
270     int best_quality;
271     int active_best_quality;
272
273     int ni_av_qi;
274     int ni_tot_qi;
275     int ni_frames;
276     int avg_frame_qindex;
277
278     double rate_correction_factor;
279     double key_frame_rate_correction_factor;
280     double gf_rate_correction_factor;
281
282     int zbin_over_quant;
283
284     int inter_frame_target;
285     int64_t total_byte_count;
286
287     int filter_level;
288
289     int last_frame_percent_intra;
290
291     int count_mb_ref_frame_usage[MAX_REF_FRAMES];
292
293 } LAYER_CONTEXT;
294
295 typedef struct VP8_COMP
296 {
297
298     DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]);
299     DECLARE_ALIGNED(16, unsigned char, Y1quant_shift[QINDEX_RANGE][16]);
300     DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]);
301     DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]);
302
303     DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]);
304     DECLARE_ALIGNED(16, unsigned char, Y2quant_shift[QINDEX_RANGE][16]);
305     DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]);
306     DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]);
307
308     DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]);
309     DECLARE_ALIGNED(16, unsigned char, UVquant_shift[QINDEX_RANGE][16]);
310     DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]);
311     DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]);
312
313     DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]);
314     DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]);
315     DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]);
316     DECLARE_ALIGNED(16, short, Y1quant_fast[QINDEX_RANGE][16]);
317     DECLARE_ALIGNED(16, short, Y2quant_fast[QINDEX_RANGE][16]);
318     DECLARE_ALIGNED(16, short, UVquant_fast[QINDEX_RANGE][16]);
319
320
321     MACROBLOCK mb;
322     VP8_COMMON common;
323     vp8_writer bc[9]; // one boolcoder for each partition
324
325     VP8_CONFIG oxcf;
326
327     struct lookahead_ctx    *lookahead;
328     struct lookahead_entry  *source;
329     struct lookahead_entry  *alt_ref_source;
330
331     YV12_BUFFER_CONFIG *Source;
332     YV12_BUFFER_CONFIG *un_scaled_source;
333     YV12_BUFFER_CONFIG scaled_source;
334
335     int source_alt_ref_pending; // frame in src_buffers has been identified to be encoded as an alt ref
336     int source_alt_ref_active;  // an alt ref frame has been encoded and is usable
337
338     int is_src_frame_alt_ref;   // source of frame to encode is an exact copy of an alt ref frame
339
340     int gold_is_last; // golden frame same as last frame ( short circuit gold searches)
341     int alt_is_last;  // Alt reference frame same as last ( short circuit altref search)
342     int gold_is_alt;  // don't do both alt and gold search ( just do gold).
343
344     //int refresh_alt_ref_frame;
345     YV12_BUFFER_CONFIG pick_lf_lvl_frame;
346
347     TOKENEXTRA *tok;
348     unsigned int tok_count;
349
350
351     unsigned int frames_since_key;
352     unsigned int key_frame_frequency;
353     unsigned int this_key_frame_forced;
354     unsigned int next_key_frame_forced;
355
356     // Ambient reconstruction err target for force key frames
357     int ambient_err;
358
359     unsigned int mode_check_freq[MAX_MODES];
360     unsigned int mode_test_hit_counts[MAX_MODES];
361     unsigned int mode_chosen_counts[MAX_MODES];
362     unsigned int mbs_tested_so_far;
363
364     int rd_thresh_mult[MAX_MODES];
365     int rd_baseline_thresh[MAX_MODES];
366     int rd_threshes[MAX_MODES];
367
368     int RDMULT;
369     int RDDIV ;
370
371     CODING_CONTEXT coding_context;
372
373     // Rate targetting variables
374     int64_t prediction_error;
375     int64_t last_prediction_error;
376     int64_t intra_error;
377     int64_t last_intra_error;
378
379     int this_frame_target;
380     int projected_frame_size;
381     int last_q[2];                   // Separate values for Intra/Inter
382
383     double rate_correction_factor;
384     double key_frame_rate_correction_factor;
385     double gf_rate_correction_factor;
386
387     int frames_till_gf_update_due;      // Count down till next GF
388     int current_gf_interval;          // GF interval chosen when we coded the last GF
389
390     int gf_overspend_bits;            // Total bits overspent becasue of GF boost (cumulative)
391
392     int non_gf_bitrate_adjustment;     // Used in the few frames following a GF to recover the extra bits spent in that GF
393
394     int kf_overspend_bits;            // Extra bits spent on key frames that need to be recovered on inter frames
395     int kf_bitrate_adjustment;        // Current number of bit s to try and recover on each inter frame.
396     int max_gf_interval;
397     int baseline_gf_interval;
398     int active_arnr_frames;           // <= cpi->oxcf.arnr_max_frames
399
400     int64_t key_frame_count;
401     int prior_key_frame_distance[KEY_FRAME_CONTEXT];
402     int per_frame_bandwidth;          // Current section per frame bandwidth target
403     int av_per_frame_bandwidth;        // Average frame size target for clip
404     int min_frame_bandwidth;          // Minimum allocation that should be used for any frame
405     int inter_frame_target;
406     double output_frame_rate;
407     int64_t last_time_stamp_seen;
408     int64_t last_end_time_stamp_seen;
409     int64_t first_time_stamp_ever;
410
411     int ni_av_qi;
412     int ni_tot_qi;
413     int ni_frames;
414     int avg_frame_qindex;
415
416     int zbin_over_quant;
417     int zbin_mode_boost;
418     int zbin_mode_boost_enabled;
419     int last_zbin_over_quant;
420     int last_zbin_mode_boost;
421
422     int64_t total_byte_count;
423
424     int buffered_mode;
425
426     double frame_rate;
427     double ref_frame_rate;
428     int64_t buffer_level;
429     int bits_off_target;
430
431     int rolling_target_bits;
432     int rolling_actual_bits;
433
434     int long_rolling_target_bits;
435     int long_rolling_actual_bits;
436
437     int64_t total_actual_bits;
438     int total_target_vs_actual;        // debug stats
439
440     int worst_quality;
441     int active_worst_quality;
442     int best_quality;
443     int active_best_quality;
444
445     int cq_target_quality;
446
447     int drop_frames_allowed;          // Are we permitted to drop frames?
448     int drop_frame;                  // Drop this frame?
449     int drop_count;                  // How many frames have we dropped?
450     int max_drop_count;               // How many frames should we drop?
451     int max_consec_dropped_frames;     // Limit number of consecutive frames that can be dropped.
452
453
454     int ymode_count [VP8_YMODES];        /* intra MB type cts this frame */
455     int uv_mode_count[VP8_UV_MODES];       /* intra MB type cts this frame */
456
457     unsigned int MVcount [2] [MVvals];  /* (row,col) MV cts this frame */
458
459     unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];  /* for this frame */
460     //DECLARE_ALIGNED(16, int, coef_counts_backup [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]);   //not used any more
461     //save vp8_tree_probs_from_distribution result for each frame to avoid repeat calculation
462     vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
463     unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
464
465     int gfu_boost;
466     int kf_boost;
467     int last_boost;
468
469     int target_bandwidth;
470     struct vpx_codec_pkt_list  *output_pkt_list;
471
472 #if 0
473     // Experimental code for lagged and one pass
474     ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
475     int one_pass_frame_index;
476 #endif
477
478     int decimation_factor;
479     int decimation_count;
480
481     // for real time encoding
482     int avg_encode_time;              //microsecond
483     int avg_pick_mode_time;            //microsecond
484     int Speed;
485     unsigned int cpu_freq;           //Mhz
486     int compressor_speed;
487
488     int interquantizer;
489     int auto_gold;
490     int auto_adjust_gold_quantizer;
491     int goldfreq;
492     int auto_worst_q;
493     int cpu_used;
494     int horiz_scale;
495     int vert_scale;
496     int pass;
497
498
499     int prob_intra_coded;
500     int prob_last_coded;
501     int prob_gf_coded;
502     int prob_skip_false;
503     int last_skip_false_probs[3];
504     int last_skip_probs_q[3];
505     int recent_ref_frame_usage[MAX_REF_FRAMES];
506
507     int count_mb_ref_frame_usage[MAX_REF_FRAMES];
508     int this_frame_percent_intra;
509     int last_frame_percent_intra;
510
511     int ref_frame_flags;
512
513     SPEED_FEATURES sf;
514     int error_bins[1024];
515
516     // Data used for real time conferencing mode to help determine if it would be good to update the gf
517     int inter_zz_count;
518     int gf_bad_count;
519     int gf_update_recommended;
520     int skip_true_count;
521     int skip_false_count;
522
523     unsigned char *segmentation_map;
524     signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS];            // Segment data (can be deltas or absolute values)
525     int  segment_encode_breakout[MAX_MB_SEGMENTS];                    // segment threashold for encode breakout
526
527     unsigned char *active_map;
528     unsigned int active_map_enabled;
529     // Video conferencing cyclic refresh mode flags etc
530     // This is a mode designed to clean up the background over time in live encoding scenarious. It uses segmentation
531     int cyclic_refresh_mode_enabled;
532     int cyclic_refresh_mode_max_mbs_perframe;
533     int cyclic_refresh_mode_index;
534     int cyclic_refresh_q;
535     signed char *cyclic_refresh_map;
536
537 #if CONFIG_MULTITHREAD
538     // multithread data
539     int * mt_current_mb_col;
540     int mt_sync_range;
541     int b_multi_threaded;
542     int encoding_thread_count;
543
544     pthread_t *h_encoding_thread;
545     pthread_t h_filter_thread;
546
547     MB_ROW_COMP *mb_row_ei;
548     ENCODETHREAD_DATA *en_thread_data;
549     LPFTHREAD_DATA lpf_thread_data;
550
551     //events
552     sem_t *h_event_start_encoding;
553     sem_t h_event_end_encoding;
554     sem_t h_event_start_lpf;
555     sem_t h_event_end_lpf;
556 #endif
557
558     TOKENLIST *tplist;
559     unsigned int partition_sz[MAX_PARTITIONS];
560     // end of multithread data
561
562
563     fractional_mv_step_fp *find_fractional_mv_step;
564     vp8_full_search_fn_t full_search_sad;
565     vp8_refining_search_fn_t refining_search_sad;
566     vp8_diamond_search_fn_t diamond_search_sad;
567     vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS];
568     unsigned int time_receive_data;
569     unsigned int time_compress_data;
570     unsigned int time_pick_lpf;
571     unsigned int time_encode_mb_row;
572
573     int base_skip_false_prob[128];
574
575     FRAME_CONTEXT lfc_n; /* last frame entropy */
576     FRAME_CONTEXT lfc_a; /* last alt ref entropy */
577     FRAME_CONTEXT lfc_g; /* last gold ref entropy */
578
579
580     struct twopass_rc
581     {
582         unsigned int section_intra_rating;
583         double section_max_qfactor;
584         unsigned int next_iiratio;
585         unsigned int this_iiratio;
586         FIRSTPASS_STATS total_stats;
587         FIRSTPASS_STATS this_frame_stats;
588         FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
589         FIRSTPASS_STATS total_left_stats;
590         int first_pass_done;
591         int64_t bits_left;
592         int64_t clip_bits_total;
593         double avg_iiratio;
594         double modified_error_total;
595         double modified_error_used;
596         double modified_error_left;
597         double kf_intra_err_min;
598         double gf_intra_err_min;
599         int frames_to_key;
600         int maxq_max_limit;
601         int maxq_min_limit;
602         int gf_decay_rate;
603         int static_scene_max_gf_interval;
604         int kf_bits;
605         int gf_group_error_left;           // Remaining error from uncoded frames in a gf group. Two pass use only
606
607         // Projected total bits available for a key frame group of frames
608         int64_t kf_group_bits;
609
610         // Error score of frames still to be coded in kf group
611         int64_t kf_group_error_left;
612
613         int gf_group_bits;                // Projected Bits available for a group of frames including 1 GF or ARF
614         int gf_bits;                     // Bits for the golden frame or ARF - 2 pass only
615         int alt_extra_bits;
616         double est_max_qcorrection_factor;
617     } twopass;
618
619 #if CONFIG_RUNTIME_CPU_DETECT
620     VP8_ENCODER_RTCD            rtcd;
621 #endif
622 #if VP8_TEMPORAL_ALT_REF
623     YV12_BUFFER_CONFIG alt_ref_buffer;
624     YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
625     int fixed_divide[512];
626 #endif
627
628 #if CONFIG_INTERNAL_STATS
629     int    count;
630     double total_y;
631     double total_u;
632     double total_v;
633     double total ;
634     double total_sq_error;
635     double totalp_y;
636     double totalp_u;
637     double totalp_v;
638     double totalp;
639     double total_sq_error2;
640     int    bytes;
641     double summed_quality;
642     double summed_weights;
643     unsigned int tot_recode_hits;
644
645
646     double total_ssimg_y;
647     double total_ssimg_u;
648     double total_ssimg_v;
649     double total_ssimg_all;
650
651     int b_calculate_ssimg;
652 #endif
653     int b_calculate_psnr;
654
655     // Per MB activity measurement
656     unsigned int activity_avg;
657     unsigned int * mb_activity_map;
658     int * mb_norm_activity_map;
659
660     // Record of which MBs still refer to last golden frame either
661     // directly or through 0,0
662     unsigned char *gf_active_flags;
663     int gf_active_count;
664
665     int output_partition;
666
667     //Store last frame's MV info for next frame MV prediction
668     int_mv *lfmv;
669     int *lf_ref_frame_sign_bias;
670     int *lf_ref_frame;
671
672     int force_next_frame_intra; /* force next frame to intra when kf_auto says so */
673
674     int droppable;
675
676     // Coding layer state variables
677     unsigned int current_layer;
678     LAYER_CONTEXT layer_context[MAX_LAYERS];
679
680     int64_t frames_in_layer[MAX_LAYERS];
681     int64_t bytes_in_layer[MAX_LAYERS];
682     double sum_psnr[MAX_LAYERS];
683     double sum_psnr_p[MAX_LAYERS];
684     double total_error2[MAX_LAYERS];
685     double total_error2_p[MAX_LAYERS];
686     double sum_ssim[MAX_LAYERS];
687     double sum_weights[MAX_LAYERS];
688
689     double total_ssimg_y_in_layer[MAX_LAYERS];
690     double total_ssimg_u_in_layer[MAX_LAYERS];
691     double total_ssimg_v_in_layer[MAX_LAYERS];
692     double total_ssimg_all_in_layer[MAX_LAYERS];
693
694 #if CONFIG_MULTI_RES_ENCODING
695     /* Number of MBs per row at lower-resolution level */
696     int    mr_low_res_mb_cols;
697 #endif
698
699 } VP8_COMP;
700
701 void control_data_rate(VP8_COMP *cpi);
702
703 void vp8_encode_frame(VP8_COMP *cpi);
704
705 void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned char *dest_end, unsigned long *size);
706
707 void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x);
708
709 int rd_cost_intra_mb(MACROBLOCKD *x);
710
711 void vp8_tokenize_mb(VP8_COMP *, MACROBLOCKD *, TOKENEXTRA **);
712
713 void vp8_set_speed_features(VP8_COMP *cpi);
714
715 #if CONFIG_DEBUG
716 #define CHECK_MEM_ERROR(lval,expr) do {\
717         lval = (expr); \
718         if(!lval) \
719             vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
720                                "Failed to allocate "#lval" at %s:%d", \
721                                __FILE__,__LINE__);\
722     } while(0)
723 #else
724 #define CHECK_MEM_ERROR(lval,expr) do {\
725         lval = (expr); \
726         if(!lval) \
727             vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
728                                "Failed to allocate "#lval);\
729     } while(0)
730 #endif
731 #endif