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