From 410066986f443112ed88f501e987b6ca51ed7bd4 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 3 Jul 2013 20:46:28 +0200 Subject: [PATCH 1/3] aic: use chroma scan tables while decoding luma component in progressive mode For some unclear reason Apple decided to use the same scan tables for luma and chroma in the progressive mode while using different ones for luma in the interlaced mode. --- libavcodec/aic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/aic.c b/libavcodec/aic.c index a87176255f..e46c00349a 100644 --- a/libavcodec/aic.c +++ b/libavcodec/aic.c @@ -196,11 +196,11 @@ static int aic_decode_header(AICContext *ctx, const uint8_t *src, int size) } while (0) static int aic_decode_coeffs(GetBitContext *gb, int16_t *dst, - int band, int slice_width) + int band, int slice_width, int force_chroma) { int has_skips, coeff_type, coeff_bits, skip_type, skip_bits; const int num_coeffs = aic_num_band_coeffs[band]; - const uint8_t *scan = aic_scan[band]; + const uint8_t *scan = aic_scan[band | force_chroma]; int mb, idx, val; has_skips = get_bits1(gb); @@ -319,7 +319,8 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y, sizeof(*ctx->slice_data) * slice_width * AIC_BAND_COEFFS); for (i = 0; i < NUM_BANDS; i++) if ((ret = aic_decode_coeffs(&gb, ctx->data_ptr[i], - i, slice_width)) < 0) + i, slice_width, + !ctx->interlaced)) < 0) return ret; for (mb = 0; mb < slice_width; mb++) { @@ -334,7 +335,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y, ctx->dsp.idct(ctx->block); if (!ctx->interlaced) { - dst = Y + (blk & 1) * 8 * ystride + (blk >> 1) * 8; + dst = Y + (blk >> 1) * 8 * ystride + (blk & 1) * 8; ctx->dsp.put_signed_pixels_clamped(ctx->block, dst, ystride); } else { From d222f6e39e263c3455b9e1108cccda035889622d Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 1 Jul 2013 12:06:22 -0700 Subject: [PATCH 2/3] cabac: x86 version of get_cabac_bypass Signed-off-by: Luca Barbato --- libavcodec/cabac_functions.h | 3 ++- libavcodec/x86/cabac.h | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h index 484ba85db6..afc7c98358 100644 --- a/libavcodec/cabac_functions.h +++ b/libavcodec/cabac_functions.h @@ -113,6 +113,7 @@ static int av_unused get_cabac(CABACContext *c, uint8_t * const state){ return get_cabac_inline(c,state); } +#ifndef get_cabac_bypass static int av_unused get_cabac_bypass(CABACContext *c){ int range; c->low += c->low; @@ -128,7 +129,7 @@ static int av_unused get_cabac_bypass(CABACContext *c){ return 1; } } - +#endif #ifndef get_cabac_bypass_sign static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index a74cf0bf1f..fdb0a2975c 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -229,5 +229,45 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) return val; } +#define get_cabac_bypass get_cabac_bypass_x86 +static av_always_inline int get_cabac_bypass_x86(CABACContext *c) +{ + x86_reg tmp; + int res; + __asm__ volatile( + "movl %c6(%2), %k1 \n\t" + "movl %c3(%2), %%eax \n\t" + "shl $17, %k1 \n\t" + "add %%eax, %%eax \n\t" + "sub %k1, %%eax \n\t" + "cltd \n\t" + "and %%edx, %k1 \n\t" + "add %k1, %%eax \n\t" + "inc %%edx \n\t" + "test %%ax, %%ax \n\t" + "jnz 1f \n\t" + "mov %c4(%2), %1 \n\t" + "subl $0xFFFF, %%eax \n\t" + "movzwl (%1), %%ecx \n\t" + "bswap %%ecx \n\t" + "shrl $15, %%ecx \n\t" + "addl %%ecx, %%eax \n\t" + "cmp %c5(%2), %1 \n\t" + "jge 1f \n\t" + "add"OPSIZE" $2, %c4(%2) \n\t" + "1: \n\t" + "movl %%eax, %c3(%2) \n\t" + + : "=&d"(res), "=&r"(tmp) + : "r"(c), + "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, bytestream_end)), + "i"(offsetof(CABACContext, range)) + : "%eax", "%ecx", "memory" + ); + return res; +} + #endif /* HAVE_INLINE_ASM */ #endif /* AVCODEC_X86_CABAC_H */ From e6d8acf6a8fba4743eb56eabe72a741d1bbee3cb Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 3 Jul 2013 11:18:30 +0200 Subject: [PATCH 3/3] indeo: use a typedef for the mc function pointer --- libavcodec/ivi_common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index 4eee19be69..43795ea625 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -41,6 +41,9 @@ extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tabl static VLC ivi_mb_vlc_tabs [8]; ///< static macroblock Huffman tables static VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables +typedef void (*ivi_mc_func) (int16_t *buf, const int16_t *ref_buf, + uint32_t pitch, int mc_type); + /** * Reverse "nbits" bits of the value "val" and return the result * in the least significant bits. @@ -394,8 +397,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile uint32_t cbp, sym, lo, hi, quant, buf_offs, q; IVIMbInfo *mb; RVMapDesc *rvmap = band->rv_map; - void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); - void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); + ivi_mc_func mc_with_delta_func, mc_no_delta_func; const uint16_t *base_tab; const uint8_t *scale_tab; @@ -567,8 +569,7 @@ static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band, IVIMbInfo *mb, *ref_mb; const int16_t *src; int16_t *dst; - void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, - int mc_type); + ivi_mc_func mc_no_delta_func; if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) { av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches "