| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 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 | 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 | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 | 11 | 
| 12 #include "vpx_ports/config.h" | 12 #include "vpx_ports/config.h" | 
| 13 #include "blockd.h" | 13 #include "blockd.h" | 
| 14 #include "vpx_mem/vpx_mem.h" | 14 #include "vpx_mem/vpx_mem.h" | 
| 15 #include "onyxc_int.h" | 15 #include "onyxc_int.h" | 
| 16 #include "findnearmv.h" | 16 #include "findnearmv.h" | 
| 17 #include "entropymode.h" | 17 #include "entropymode.h" | 
| 18 #include "systemdependent.h" | 18 #include "systemdependent.h" | 
| 19 | 19 | 
| 20 | 20 | 
| 21 extern  void vp8_init_scan_order_mask(); | 21 extern  void vp8_init_scan_order_mask(); | 
| 22 | 22 | 
| 23 static void update_mode_info_border(MODE_INFO *mi, int rows, int cols) | 23 static void update_mode_info_border(MODE_INFO *mi, int rows, int cols) | 
| 24 { | 24 { | 
| 25     int i; | 25     int i; | 
| 26     vpx_memset(mi - cols - 2, 0, sizeof(MODE_INFO) * (cols + 1)); | 26     vpx_memset(mi - cols - 2, 0, sizeof(MODE_INFO) * (cols + 1)); | 
| 27 | 27 | 
| 28     for (i = 0; i < rows; i++) | 28     for (i = 0; i < rows; i++) | 
| 29     { | 29     { | 
|  | 30         /* TODO(holmer): Bug? This updates the last element of each row | 
|  | 31          * rather than the border element! | 
|  | 32          */ | 
| 30         vpx_memset(&mi[i*cols-1], 0, sizeof(MODE_INFO)); | 33         vpx_memset(&mi[i*cols-1], 0, sizeof(MODE_INFO)); | 
| 31     } | 34     } | 
| 32 } | 35 } | 
| 33 | 36 | 
| 34 void vp8_de_alloc_frame_buffers(VP8_COMMON *oci) | 37 void vp8_de_alloc_frame_buffers(VP8_COMMON *oci) | 
| 35 { | 38 { | 
| 36     int i; | 39     int i; | 
| 37 | 40 | 
| 38     for (i = 0; i < NUM_YV12_BUFFERS; i++) | 41     for (i = 0; i < NUM_YV12_BUFFERS; i++) | 
| 39         vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]); | 42         vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]); | 
| 40 | 43 | 
| 41     vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame); | 44     vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame); | 
| 42     vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer); | 45     vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer); | 
| 43 | 46 | 
| 44     vpx_free(oci->above_context); | 47     vpx_free(oci->above_context); | 
| 45     vpx_free(oci->mip); | 48     vpx_free(oci->mip); | 
|  | 49     vpx_free(oci->prev_mip); | 
| 46 | 50 | 
| 47     oci->above_context = 0; | 51     oci->above_context = 0; | 
| 48     oci->mip = 0; | 52     oci->mip = 0; | 
|  | 53     oci->prev_mip = 0; | 
| 49 | 54 | 
| 50 } | 55 } | 
| 51 | 56 | 
| 52 int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) | 57 int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) | 
| 53 { | 58 { | 
| 54     int i; | 59     int i; | 
| 55 | 60 | 
| 56     vp8_de_alloc_frame_buffers(oci); | 61     vp8_de_alloc_frame_buffers(oci); | 
| 57 | 62 | 
| 58     /* our internal buffers are always multiples of 16 */ | 63     /* our internal buffers are always multiples of 16 */ | 
| 59     if ((width & 0xf) != 0) | 64     if ((width & 0xf) != 0) | 
| 60         width += 16 - (width & 0xf); | 65         width += 16 - (width & 0xf); | 
| 61 | 66 | 
| 62     if ((height & 0xf) != 0) | 67     if ((height & 0xf) != 0) | 
| 63         height += 16 - (height & 0xf); | 68         height += 16 - (height & 0xf); | 
| 64 | 69 | 
| 65 | 70 | 
| 66     for (i = 0; i < NUM_YV12_BUFFERS; i++) | 71     for (i = 0; i < NUM_YV12_BUFFERS; i++) | 
| 67     { | 72     { | 
| 68       oci->fb_idx_ref_cnt[0] = 0; | 73         oci->fb_idx_ref_cnt[i] = 0; | 
| 69 | 74         oci->yv12_fb[i].flags = 0; | 
| 70       if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i],  width, height, VP8BORDE
     RINPIXELS) < 0) | 75         if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORD
     ERINPIXELS) < 0) | 
| 71         { | 76         { | 
| 72             vp8_de_alloc_frame_buffers(oci); | 77             vp8_de_alloc_frame_buffers(oci); | 
| 73             return 1; | 78             return 1; | 
| 74         } | 79         } | 
| 75     } | 80     } | 
| 76 | 81 | 
| 77     oci->new_fb_idx = 0; | 82     oci->new_fb_idx = 0; | 
| 78     oci->lst_fb_idx = 1; | 83     oci->lst_fb_idx = 1; | 
| 79     oci->gld_fb_idx = 2; | 84     oci->gld_fb_idx = 2; | 
| 80     oci->alt_fb_idx = 3; | 85     oci->alt_fb_idx = 3; | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 103     oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_I
     NFO)); | 108     oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_I
     NFO)); | 
| 104 | 109 | 
| 105     if (!oci->mip) | 110     if (!oci->mip) | 
| 106     { | 111     { | 
| 107         vp8_de_alloc_frame_buffers(oci); | 112         vp8_de_alloc_frame_buffers(oci); | 
| 108         return 1; | 113         return 1; | 
| 109     } | 114     } | 
| 110 | 115 | 
| 111     oci->mi = oci->mip + oci->mode_info_stride + 1; | 116     oci->mi = oci->mip + oci->mode_info_stride + 1; | 
| 112 | 117 | 
|  | 118     /* allocate memory for last frame MODE_INFO array */ | 
|  | 119 #if CONFIG_ERROR_CONCEALMENT | 
|  | 120     oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(M
     ODE_INFO)); | 
|  | 121 | 
|  | 122     if (!oci->prev_mip) | 
|  | 123     { | 
|  | 124         vp8_de_alloc_frame_buffers(oci); | 
|  | 125         return 1; | 
|  | 126     } | 
|  | 127 | 
|  | 128     oci->prev_mi = oci->prev_mip + oci->mode_info_stride + 1; | 
|  | 129 #else | 
|  | 130     oci->prev_mip = NULL; | 
|  | 131     oci->prev_mi = NULL; | 
|  | 132 #endif | 
| 113 | 133 | 
| 114     oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_col
     s, 1); | 134     oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_col
     s, 1); | 
| 115 | 135 | 
| 116     if (!oci->above_context) | 136     if (!oci->above_context) | 
| 117     { | 137     { | 
| 118         vp8_de_alloc_frame_buffers(oci); | 138         vp8_de_alloc_frame_buffers(oci); | 
| 119         return 1; | 139         return 1; | 
| 120     } | 140     } | 
| 121 | 141 | 
| 122     update_mode_info_border(oci->mi, oci->mb_rows, oci->mb_cols); | 142     update_mode_info_border(oci->mi, oci->mb_rows, oci->mb_cols); | 
|  | 143 #if CONFIG_ERROR_CONCEALMENT | 
|  | 144     update_mode_info_border(oci->prev_mi, oci->mb_rows, oci->mb_cols); | 
|  | 145 #endif | 
| 123 | 146 | 
| 124     return 0; | 147     return 0; | 
| 125 } | 148 } | 
| 126 void vp8_setup_version(VP8_COMMON *cm) | 149 void vp8_setup_version(VP8_COMMON *cm) | 
| 127 { | 150 { | 
| 128     switch (cm->version) | 151     switch (cm->version) | 
| 129     { | 152     { | 
| 130     case 0: | 153     case 0: | 
| 131         cm->no_lpf = 0; | 154         cm->no_lpf = 0; | 
| 132         cm->simpler_lpf = 0; | 155         cm->filter_type = NORMAL_LOOPFILTER; | 
| 133         cm->use_bilinear_mc_filter = 0; | 156         cm->use_bilinear_mc_filter = 0; | 
| 134         cm->full_pixel = 0; | 157         cm->full_pixel = 0; | 
| 135         break; | 158         break; | 
| 136     case 1: | 159     case 1: | 
| 137         cm->no_lpf = 0; | 160         cm->no_lpf = 0; | 
| 138         cm->simpler_lpf = 1; | 161         cm->filter_type = SIMPLE_LOOPFILTER; | 
| 139         cm->use_bilinear_mc_filter = 1; | 162         cm->use_bilinear_mc_filter = 1; | 
| 140         cm->full_pixel = 0; | 163         cm->full_pixel = 0; | 
| 141         break; | 164         break; | 
| 142     case 2: | 165     case 2: | 
| 143         cm->no_lpf = 1; | 166         cm->no_lpf = 1; | 
| 144         cm->simpler_lpf = 0; | 167         cm->filter_type = NORMAL_LOOPFILTER; | 
| 145         cm->use_bilinear_mc_filter = 1; | 168         cm->use_bilinear_mc_filter = 1; | 
| 146         cm->full_pixel = 0; | 169         cm->full_pixel = 0; | 
| 147         break; | 170         break; | 
| 148     case 3: | 171     case 3: | 
| 149         cm->no_lpf = 1; | 172         cm->no_lpf = 1; | 
| 150         cm->simpler_lpf = 1; | 173         cm->filter_type = SIMPLE_LOOPFILTER; | 
| 151         cm->use_bilinear_mc_filter = 1; | 174         cm->use_bilinear_mc_filter = 1; | 
| 152         cm->full_pixel = 1; | 175         cm->full_pixel = 1; | 
| 153         break; | 176         break; | 
| 154     default: | 177     default: | 
| 155         /*4,5,6,7 are reserved for future use*/ | 178         /*4,5,6,7 are reserved for future use*/ | 
| 156         cm->no_lpf = 0; | 179         cm->no_lpf = 0; | 
| 157         cm->simpler_lpf = 0; | 180         cm->filter_type = NORMAL_LOOPFILTER; | 
| 158         cm->use_bilinear_mc_filter = 0; | 181         cm->use_bilinear_mc_filter = 0; | 
| 159         cm->full_pixel = 0; | 182         cm->full_pixel = 0; | 
| 160         break; | 183         break; | 
| 161     } | 184     } | 
| 162 } | 185 } | 
| 163 void vp8_create_common(VP8_COMMON *oci) | 186 void vp8_create_common(VP8_COMMON *oci) | 
| 164 { | 187 { | 
| 165     vp8_machine_specific_config(oci); | 188     vp8_machine_specific_config(oci); | 
| 166     vp8_default_coef_probs(oci); | 189     vp8_default_coef_probs(oci); | 
| 167     vp8_init_mbmode_probs(oci); | 190     vp8_init_mbmode_probs(oci); | 
| 168     vp8_default_bmode_probs(oci->fc.bmode_prob); | 191     vp8_default_bmode_probs(oci->fc.bmode_prob); | 
| 169 | 192 | 
| 170     oci->mb_no_coeff_skip = 1; | 193     oci->mb_no_coeff_skip = 1; | 
| 171     oci->no_lpf = 0; | 194     oci->no_lpf = 0; | 
| 172     oci->simpler_lpf = 0; | 195     oci->filter_type = NORMAL_LOOPFILTER; | 
| 173     oci->use_bilinear_mc_filter = 0; | 196     oci->use_bilinear_mc_filter = 0; | 
| 174     oci->full_pixel = 0; | 197     oci->full_pixel = 0; | 
| 175     oci->multi_token_partition = ONE_PARTITION; | 198     oci->multi_token_partition = ONE_PARTITION; | 
| 176     oci->clr_type = REG_YUV; | 199     oci->clr_type = REG_YUV; | 
| 177     oci->clamp_type = RECON_CLAMP_REQUIRED; | 200     oci->clamp_type = RECON_CLAMP_REQUIRED; | 
| 178 | 201 | 
| 179     /* Initialise reference frame sign bias structure to defaults */ | 202     /* Initialise reference frame sign bias structure to defaults */ | 
| 180     vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias)); | 203     vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias)); | 
| 181 | 204 | 
| 182     /* Default disable buffer to buffer copying */ | 205     /* Default disable buffer to buffer copying */ | 
| 183     oci->copy_buffer_to_gf = 0; | 206     oci->copy_buffer_to_gf = 0; | 
| 184     oci->copy_buffer_to_arf = 0; | 207     oci->copy_buffer_to_arf = 0; | 
| 185 } | 208 } | 
| 186 | 209 | 
| 187 void vp8_remove_common(VP8_COMMON *oci) | 210 void vp8_remove_common(VP8_COMMON *oci) | 
| 188 { | 211 { | 
| 189     vp8_de_alloc_frame_buffers(oci); | 212     vp8_de_alloc_frame_buffers(oci); | 
| 190 } | 213 } | 
| 191 | 214 | 
| 192 void vp8_initialize_common() | 215 void vp8_initialize_common() | 
| 193 { | 216 { | 
| 194     vp8_coef_tree_initialize(); | 217     vp8_coef_tree_initialize(); | 
| 195 | 218 | 
| 196     vp8_entropy_mode_init(); | 219     vp8_entropy_mode_init(); | 
| 197 | 220 | 
| 198     vp8_init_scan_order_mask(); | 221     vp8_init_scan_order_mask(); | 
| 199 | 222 | 
| 200 } | 223 } | 
| OLD | NEW | 
|---|