#
# Usage: cat inputfile | perl ads2gas_apple.pl > outputfile
#
+
+my $chromium = 0;
+
+foreach my $arg (@ARGV) {
+ $chromium = 1 if ($arg eq "-chromium");
+}
+
print "@ This file was created from a .asm file\n";
print "@ using the ads2gas_apple.pl script.\n\n";
print "\t.set WIDE_REFERENCE, 0\n";
s/@/,:/g;
# Comment character
- s/;/@/g;
+ s/;/ @/g;
# Hexadecimal constants prefaced by 0x
s/#&/#0x/g;
# s/\$/\\/g; # End macro definition
s/MEND/.endm/; # No need to tell it where to stop assembling
next if /^\s*END\s*$/;
+
+ # Clang used by Chromium differs slightly from clang in XCode in what it
+ # will accept in the assembly.
+ if ($chromium) {
+ s/qsubaddx/qsax/i;
+ s/qaddsubx/qasx/i;
+ s/ldrneb/ldrbne/i;
+ s/ldrneh/ldrhne/i;
+ s/(vqshrun\.s16 .*, \#)0$/${1}8/i;
+
+ # http://llvm.org/bugs/show_bug.cgi?id=16022
+ s/\.include/#include/;
+ }
+
print;
}
;;
darwin*)
- if [ -z "${sdk_path}" ]; then
- SDK_PATH=`xcode-select -print-path 2> /dev/null`
- SDK_PATH=${SDK_PATH}/Platforms/iPhoneOS.platform/Developer
- else
- SDK_PATH=${sdk_path}
- fi
- TOOLCHAIN_PATH=${SDK_PATH}/usr/bin
- CXX=${TOOLCHAIN_PATH}/g++
- CC=${TOOLCHAIN_PATH}/gcc
- AR=${TOOLCHAIN_PATH}/ar
- LD=${TOOLCHAIN_PATH}/arm-apple-darwin10-llvm-gcc-4.2
- AS=${TOOLCHAIN_PATH}/as
- STRIP=${TOOLCHAIN_PATH}/strip
- NM=${TOOLCHAIN_PATH}/nm
+
+ XCRUN_FIND="xcrun --sdk iphoneos -find"
+ CXX="$(${XCRUN_FIND} clang++)"
+ CC="$(${XCRUN_FIND} clang)"
+ AR="$(${XCRUN_FIND} ar)"
+ LD="$(${XCRUN_FIND} ld)"
+ AS="$(${XCRUN_FIND} as)"
+ STRIP="$(${XCRUN_FIND} strip)"
+ NM="$(${XCRUN_FIND} nm)"
+ RANLIB="$(${XCRUN_FIND} ranlib)"
AS_SFX=.s
# ASFLAGS is written here instead of using check_add_asflags
# because we need to overwrite all of ASFLAGS and purge the
# options that were put in above
- ASFLAGS="-version -arch ${tgt_isa} -g"
-
- add_cflags -arch ${tgt_isa}
- add_ldflags -arch_only ${tgt_isa}
-
- if [ -z "${alt_libc}" ]; then
- alt_libc=${SDK_PATH}/SDKs/iPhoneOS6.0.sdk
- fi
-
- add_cflags "-isysroot ${alt_libc}"
+ ASFLAGS="-arch ${tgt_isa} -g"
- # Add the paths for the alternate libc
- for d in usr/include; do
- try_dir="${alt_libc}/${d}"
- [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
- done
+ alt_libc="$(xcrun --sdk iphoneos --show-sdk-path)"
+ add_cflags -arch ${tgt_isa} -isysroot ${alt_libc}
+ add_ldflags -arch ${tgt_isa} -ios_version_min 7.0
for d in lib usr/lib usr/lib/system; do
try_dir="${alt_libc}/${d}"
${toggle_unit_tests} unit tests
--libc=PATH path to alternate libc
--as={yasm|nasm|auto} use specified assembler [auto, yasm preferred]
- --sdk-path=PATH path to root of sdk (iOS, android builds only)
+ --sdk-path=PATH path to root of sdk (android builds only)
${toggle_fast_unaligned} don't use unaligned accesses, even when
supported by hardware [auto]
${toggle_codec_srcs} in/exclude codec library source code
vp9_update_mode_info_border(cm, cm->prev_mip);
}
+int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
+ const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2);
+ const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2);
+ const int ss_x = cm->subsampling_x;
+ const int ss_y = cm->subsampling_y;
+ int mi_size;
+
+ if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y,
+ VP9BORDERINPIXELS) < 0)
+ goto fail;
+
+ set_mb_mi(cm, aligned_width, aligned_height);
+
+ // Allocation
+ mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE);
+
+ vpx_free(cm->mip);
+ cm->mip = vpx_calloc(mi_size, sizeof(MODE_INFO));
+ if (!cm->mip)
+ goto fail;
+
+ vpx_free(cm->prev_mip);
+ cm->prev_mip = vpx_calloc(mi_size, sizeof(MODE_INFO));
+ if (!cm->prev_mip)
+ goto fail;
+
+ vpx_free(cm->mi_grid_base);
+ cm->mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->mi_grid_base));
+ if (!cm->mi_grid_base)
+ goto fail;
+
+ vpx_free(cm->prev_mi_grid_base);
+ cm->prev_mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base));
+ if (!cm->prev_mi_grid_base)
+ goto fail;
+
+ setup_mi(cm);
+
+ // Create the segmentation map structure and set to 0.
+ vpx_free(cm->last_frame_seg_map);
+ cm->last_frame_seg_map = vpx_calloc(cm->mi_rows * cm->mi_cols, 1);
+ if (!cm->last_frame_seg_map)
+ goto fail;
+
+ return 0;
+
+ fail:
+ vp9_free_frame_buffers(cm);
+ return 1;
+}
+
int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
int i;
void vp9_create_common(VP9_COMMON *cm);
void vp9_remove_common(VP9_COMMON *cm);
+int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height);
int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height);
void vp9_free_frame_buffers(VP9_COMMON *cm);
const int et_y = 16;
const int el_y = 16;
// Motion estimation may use src block variance with the block size up
- // to 64x64, so the right and bottom need to be extended to 64 mulitple
+ // to 64x64, so the right and bottom need to be extended to 64 multiple
// or up to 16, whichever is greater.
const int eb_y = MAX(ALIGN_POWER_OF_TWO(src->y_width, 6) - src->y_width,
16);
ht.cols(temp_in, temp_out);
for (j = 0; j < 16; ++j)
dest[j * stride + i] = clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 6)
- + dest[j * stride + i]); }
+ + dest[j * stride + i]);
+ }
}
void vp9_idct16x16_10_add_c(const int16_t *input, uint8_t *dest, int stride) {
idct32_1d(temp_in, temp_out);
for (j = 0; j < 32; ++j)
dest[j * stride + i] = clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 6)
- + dest[j * stride + i]);
+ + dest[j * stride + i]);
}
}
if (mask_16x16 & 1) {
vp9_mb_lpf_vertical_edge_w(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr);
- assert(!(mask_8x8 & 1));
- assert(!(mask_4x4 & 1));
- assert(!(mask_4x4_int & 1));
} else if (mask_8x8 & 1) {
vp9_mbloop_filter_vertical_edge(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
- assert(!(mask_16x16 & 1));
- assert(!(mask_4x4 & 1));
} else if (mask_4x4 & 1) {
vp9_loop_filter_vertical_edge(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
- assert(!(mask_16x16 & 1));
- assert(!(mask_8x8 & 1));
}
}
if (mask_4x4_int & 1)
vp9_mb_lpf_horizontal_edge_w(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
}
- assert(!(mask_8x8 & 1));
- assert(!(mask_4x4 & 1));
- assert(!(mask_4x4_int & 1));
} else if (mask_8x8 & 1) {
if ((mask_8x8 & 3) == 3) {
// Next block's thresholds
vp9_loop_filter_horizontal_edge(s + 4 * pitch, pitch, lfi->mblim,
lfi->lim, lfi->hev_thr, 1);
}
- assert(!(mask_16x16 & 1));
- assert(!(mask_4x4 & 1));
} else if (mask_4x4 & 1) {
if ((mask_4x4 & 3) == 3) {
// Next block's thresholds
vp9_loop_filter_horizontal_edge(s + 4 * pitch, pitch, lfi->mblim,
lfi->lim, lfi->hev_thr, 1);
}
- assert(!(mask_16x16 & 1));
- assert(!(mask_8x8 & 1));
} else if (mask_4x4_int & 1) {
vp9_loop_filter_horizontal_edge(s + 4 * pitch, pitch, lfi->mblim,
lfi->lim, lfi->hev_thr, 1);
lfm->left_uv[i] &= 0xeeee;
}
}
+
+ // Assert if we try to apply 2 different loop filters at the same position.
+ assert(!(lfm->left_y[TX_16X16] & lfm->left_y[TX_8X8]));
+ assert(!(lfm->left_y[TX_16X16] & lfm->left_y[TX_4X4]));
+ assert(!(lfm->left_y[TX_8X8] & lfm->left_y[TX_4X4]));
+ assert(!(lfm->int_4x4_y & lfm->left_y[TX_16X16]));
+ assert(!(lfm->left_uv[TX_16X16]&lfm->left_uv[TX_8X8]));
+ assert(!(lfm->left_uv[TX_16X16] & lfm->left_uv[TX_4X4]));
+ assert(!(lfm->left_uv[TX_8X8] & lfm->left_uv[TX_4X4]));
+ assert(!(lfm->int_4x4_uv & lfm->left_uv[TX_16X16]));
+ assert(!(lfm->above_y[TX_16X16] & lfm->above_y[TX_8X8]));
+ assert(!(lfm->above_y[TX_16X16] & lfm->above_y[TX_4X4]));
+ assert(!(lfm->above_y[TX_8X8] & lfm->above_y[TX_4X4]));
+ assert(!(lfm->int_4x4_y & lfm->above_y[TX_16X16]));
+ assert(!(lfm->above_uv[TX_16X16] & lfm->above_uv[TX_8X8]));
+ assert(!(lfm->above_uv[TX_16X16] & lfm->above_uv[TX_4X4]));
+ assert(!(lfm->above_uv[TX_8X8] & lfm->above_uv[TX_4X4]));
+ assert(!(lfm->int_4x4_uv & lfm->above_uv[TX_16X16]));
}
#if CONFIG_NON420
assert(bsl >= 0);
assert(boffset >= 0);
- for (i = 0; i < bs; i++)
- above |= (above_ctx[i] & (1 << boffset));
- for (i = 0; i < bs; i++)
- left |= (left_ctx[i] & (1 << boffset));
-
- above = (above > 0);
- left = (left > 0);
+ for (i = 0; i < bs; i++) {
+ above |= above_ctx[i];
+ left |= left_ctx[i];
+ }
+ above = (above & (1 << boffset)) > 0;
+ left = (left & (1 << boffset)) > 0;
return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
}
#define MIN_TILE_WIDTH_B64 4
#define MAX_TILE_WIDTH_B64 64
-static int to_sbs(n_mis) {
- return mi_cols_aligned_to_sb(n_mis) >> MI_BLOCK_SIZE_LOG2;
+static int get_tile_offset(int idx, int mis, int log2) {
+ const int sb_cols = mi_cols_aligned_to_sb(mis) >> MI_BLOCK_SIZE_LOG2;
+ const int offset = ((idx * sb_cols) >> log2) << MI_BLOCK_SIZE_LOG2;
+ return MIN(offset, mis);
}
-static void get_tile_offsets(int *min_tile_off, int *max_tile_off,
- int tile_idx, int log2_n_tiles, int n_mis) {
- const int n_sbs = to_sbs(n_mis);
- const int sb_off1 = (tile_idx * n_sbs) >> log2_n_tiles;
- const int sb_off2 = ((tile_idx + 1) * n_sbs) >> log2_n_tiles;
-
- *min_tile_off = MIN(sb_off1 << 3, n_mis);
- *max_tile_off = MIN(sb_off2 << 3, n_mis);
-}
-
-void vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm,
- int row_idx, int col_idx) {
- get_tile_offsets(&tile->mi_row_start, &tile->mi_row_end,
- row_idx, cm->log2_tile_rows, cm->mi_rows);
- get_tile_offsets(&tile->mi_col_start, &tile->mi_col_end,
- col_idx, cm->log2_tile_cols, cm->mi_cols);
+void vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm, int row, int col) {
+ tile->mi_row_start = get_tile_offset(row, cm->mi_rows, cm->log2_tile_rows);
+ tile->mi_row_end = get_tile_offset(row + 1, cm->mi_rows, cm->log2_tile_rows);
+ tile->mi_col_start = get_tile_offset(col, cm->mi_cols, cm->log2_tile_cols);
+ tile->mi_col_end = get_tile_offset(col + 1, cm->mi_cols, cm->log2_tile_cols);
}
void vp9_get_tile_n_bits(int mi_cols,
int *min_log2_tile_cols, int *max_log2_tile_cols) {
- const int sb_cols = to_sbs(mi_cols);
- int min_log2_n_tiles, max_log2_n_tiles;
+ const int sb_cols = mi_cols_aligned_to_sb(mi_cols) >> MI_BLOCK_SIZE_LOG2;
+ int min_log2 = 0, max_log2 = 0;
- for (max_log2_n_tiles = 0;
- (sb_cols >> max_log2_n_tiles) >= MIN_TILE_WIDTH_B64;
- max_log2_n_tiles++) {}
- max_log2_n_tiles--;
- if (max_log2_n_tiles < 0)
- max_log2_n_tiles = 0;
+ // max
+ while ((sb_cols >> max_log2) >= MIN_TILE_WIDTH_B64)
+ ++max_log2;
+ --max_log2;
+ if (max_log2 < 0)
+ max_log2 = 0;
- for (min_log2_n_tiles = 0;
- (MAX_TILE_WIDTH_B64 << min_log2_n_tiles) < sb_cols;
- min_log2_n_tiles++) {}
+ // min
+ while ((MAX_TILE_WIDTH_B64 << min_log2) < sb_cols)
+ ++min_log2;
- assert(min_log2_n_tiles <= max_log2_n_tiles);
+ assert(min_log2 <= max_log2);
- *min_log2_tile_cols = min_log2_n_tiles;
- *max_log2_tile_cols = max_log2_n_tiles;
+ *min_log2_tile_cols = min_log2;
+ *max_log2_tile_cols = max_log2;
}
int mi_col_start, mi_col_end;
} TileInfo;
-// initializes 'tile->mi_(row|col)_(start|end)' for (row_idx, col_idx) based on
+// initializes 'tile->mi_(row|col)_(start|end)' for (row, col) based on
// 'cm->log2_tile_(rows|cols)' & 'cm->mi_(rows|cols)'
void vp9_tile_init(TileInfo *tile, const struct VP9Common *cm,
- int row_idx, int col_idx);
+ int row, int col);
void vp9_get_tile_n_bits(int mi_cols,
int *min_log2_tile_cols, int *max_log2_tile_cols);
VP9_COMMON *cm = &pbi->common;
if (cm->width != width || cm->height != height) {
- if (!pbi->initial_width || !pbi->initial_height) {
- if (vp9_alloc_frame_buffers(cm, width, height))
+ // Change in frame size.
+ if (cm->width == 0 || cm->height == 0) {
+ // Assign new frame buffer on first call.
+ cm->new_fb_idx = NUM_YV12_BUFFERS - 1;
+ cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1;
+ }
+
+ // TODO(agrange) Don't test width/height, check overall size.
+ if (width > cm->width || height > cm->height) {
+ // Rescale frame buffers only if they're not big enough already.
+ if (vp9_resize_frame_buffers(cm, width, height))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffers");
- pbi->initial_width = width;
- pbi->initial_height = height;
- } else {
- if (width > pbi->initial_width)
- vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
- "Frame width too large");
-
- if (height > pbi->initial_height)
- vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
- "Frame height too large");
}
cm->width = width;
#else
const int frame_size = yplane_size + 2 * uvplane_size;
#endif
- if (!ybf->buffer_alloc) {
+ if (frame_size > ybf->buffer_alloc_sz) {
+ // Allocation to hold larger frame, or first allocation.
+ if (ybf->buffer_alloc)
+ vpx_free(ybf->buffer_alloc);
ybf->buffer_alloc = vpx_memalign(32, frame_size);
ybf->buffer_alloc_sz = frame_size;
}