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