diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-06 03:21:20 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-06 03:21:20 +0400 |
commit | 4e27c0a1fef17d73bac5f871dfe10e9ed3676f82 (patch) | |
tree | a4eddcd9712b190c96595c9ed3abe517e4ac3c4f /src/filters/transform/MPCVideoDec/ffmpeg/libavcodec | |
parent | f4c3e8e426ef40a7b081434b2e87e00bc18762a7 (diff) |
revert r2200; it causes crashes
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2201 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/MPCVideoDec/ffmpeg/libavcodec')
12 files changed, 187 insertions, 214 deletions
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c index eff067ad6..2e0e1e7dc 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c @@ -4332,6 +4332,10 @@ av_cold void attribute_align_arg dsputil_init(DSPContext* c, AVCodecContext *avc c->draw_edges = draw_edges_c;
+#if CONFIG_CAVS_DECODER
+ ff_cavsdsp_init(c,avctx);
+#endif
+
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h index 778d3dfc1..c2030f9b0 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.h @@ -327,6 +327,15 @@ typedef struct DSPContext { qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
+ /* AVS specific */
+ qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
+ qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
+ void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
+
me_cmp_func pix_abs[2][4];
/* huffyuv specific */
@@ -609,6 +618,7 @@ extern int mm_flags; void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_dwt(DSPContext *c);
+void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h index 4b19c93b9..69518fa73 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h @@ -214,7 +214,7 @@ static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) #ifndef vp56_rac_get_prob #define vp56_rac_get_prob vp56_rac_get_prob -static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) { unsigned int code_word = vp56_rac_renorm(c); unsigned int low = 1 + (((c->high - 1) * prob) >> 8); @@ -246,7 +246,7 @@ static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int pro return 0; } -static av_always_inline int vp56_rac_get(VP56RangeCoder *c) +static inline int vp56_rac_get(VP56RangeCoder *c) { unsigned int code_word = vp56_rac_renorm(c); /* equiprobable */ @@ -265,12 +265,12 @@ static av_always_inline int vp56_rac_get(VP56RangeCoder *c) } // rounding is different than vp56_rac_get, is vp56_rac_get wrong? -static av_always_inline int vp8_rac_get(VP56RangeCoder *c) +static inline int vp8_rac_get(VP56RangeCoder *c) { return vp56_rac_get_prob(c, 128); } -static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits) +static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) { int value = 0; @@ -281,7 +281,7 @@ static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits) return value; } -static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits) +static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits) { int value = 0; @@ -293,7 +293,7 @@ static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits) } // fixme: add 1 bit to all the calls to this? -static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits) +static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits) { int v; @@ -309,22 +309,21 @@ static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits) } // P(7) -static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) +static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) { int v = vp56_rac_gets(c, 7) << 1; return v + !v; } -static av_unused int vp8_rac_get_nn(VP56RangeCoder *c) +static inline int vp8_rac_get_nn(VP56RangeCoder *c) { int v = vp8_rac_get_uint(c, 7) << 1; return v + !v; } -static av_always_inline -int vp56_rac_get_tree(VP56RangeCoder *c, - const VP56Tree *tree, - const uint8_t *probs) +static inline int vp56_rac_get_tree(VP56RangeCoder *c, + const VP56Tree *tree, + const uint8_t *probs) { while (tree->val > 0) { if (vp56_rac_get_prob(c, probs[tree->prob_idx])) @@ -340,9 +339,8 @@ int vp56_rac_get_tree(VP56RangeCoder *c, * on a node other than the root node, needed for coeff decode where this is * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) */ -static av_always_inline -int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs, int i) +static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs, int i) { do { i = tree[i][vp56_rac_get_prob(c, probs[i])]; @@ -353,15 +351,14 @@ int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], // how probabilities are associated with decisions is different I think // well, the new scheme fits in the old but this way has one fewer branches per decision -static av_always_inline -int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs) +static inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) { return vp8_rac_get_tree_with_offset(c, tree, probs, 0); } // DCTextra -static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) +static inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) { int v = 0; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c index 6a1d6ac95..6524a7141 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c @@ -88,8 +88,8 @@ typedef struct { VP8FilterStrength *filter_strength; int mb_stride; - uint8_t *intra4x4_pred_mode_top; - uint8_t intra4x4_pred_mode_left[4]; + uint8_t *intra4x4_pred_mode; + uint8_t *intra4x4_pred_mode_base; uint8_t *segmentation_map; int b4_stride; @@ -117,7 +117,6 @@ typedef struct { */ DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4]; DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16]; - DECLARE_ALIGNED(16, DCTELEM, block_dc)[16]; uint8_t intra4x4_pred_mode_mb[16]; int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock @@ -195,8 +194,7 @@ typedef struct { uint8_t golden; uint8_t pred16x16[4]; uint8_t pred8x8c[3]; - /* Padded to allow overreads */ - uint8_t token[4][17][3][NUM_DCT_TOKENS-1]; + uint8_t token[4][8][3][NUM_DCT_TOKENS-1]; uint8_t mvc[2][19]; } prob[2]; } VP8Context; @@ -213,17 +211,20 @@ static void vp8_decode_flush(AVCodecContext *avctx) av_freep(&s->macroblocks_base); av_freep(&s->filter_strength); - av_freep(&s->intra4x4_pred_mode_top); + av_freep(&s->intra4x4_pred_mode_base); av_freep(&s->top_nnz); av_freep(&s->edge_emu_buffer); av_freep(&s->top_border); av_freep(&s->segmentation_map); s->macroblocks = NULL; + s->intra4x4_pred_mode = NULL; } static int update_dimensions(VP8Context *s, int width, int height) { + int i; + if (avcodec_check_dimensions(s->avctx, width, height)) return AVERROR_INVALIDDATA; @@ -241,16 +242,21 @@ static int update_dimensions(VP8Context *s, int width, int height) s->macroblocks_base = av_mallocz((s->mb_stride+s->mb_height*2+2)*sizeof(*s->macroblocks)); s->filter_strength = av_mallocz(s->mb_stride*sizeof(*s->filter_strength)); - s->intra4x4_pred_mode_top = av_mallocz(s->b4_stride*4); + s->intra4x4_pred_mode_base = av_mallocz(s->b4_stride*(4*s->mb_height+1)); s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz)); s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border)); s->segmentation_map = av_mallocz(s->mb_stride*s->mb_height); - if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_top || + if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_base || !s->top_nnz || !s->top_border || !s->segmentation_map) return AVERROR(ENOMEM); s->macroblocks = s->macroblocks_base + 1; + s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride; + + memset(s->intra4x4_pred_mode_base, DC_PRED, s->b4_stride); + for (i = 0; i < 4*s->mb_height; i++) + s->intra4x4_pred_mode[i*s->b4_stride-1] = DC_PRED; return 0; } @@ -389,7 +395,7 @@ static void update_refs(VP8Context *s) static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; - int header_size, hscale, vscale, i, j, k, l, m, ret; + int header_size, hscale, vscale, i, j, k, l, ret; int width = s->avctx->width; int height = s->avctx->height; @@ -429,10 +435,7 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) av_log_missing_feature(s->avctx, "Upscaling", 1); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; - for (i = 0; i < 4; i++) - for (j = 0; j < 16; j++) - memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]], - sizeof(s->prob->token[i][j])); + memcpy(s->prob->token , vp8_token_default_probs , sizeof(s->prob->token)); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c)); memcpy(s->prob->mvc , vp8_mv_default_prob , sizeof(s->prob->mvc)); @@ -492,11 +495,8 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) for (j = 0; j < 8; j++) for (k = 0; k < 3; k++) for (l = 0; l < NUM_DCT_TOKENS-1; l++) - if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) { - int prob = vp8_rac_get_uint(c, 8); - for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++) - s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob; - } + if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) + s->prob->token[i][j][k][l] = vp8_rac_get_uint(c, 8); if ((s->mbskip_enabled = vp8_rac_get(c))) s->prob->mbskip = vp8_rac_get_uint(c, 8); @@ -643,32 +643,19 @@ const uint8_t *get_submv_prob(uint32_t left, uint32_t top) static av_always_inline int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) { - int part_idx; - int n, num; + int part_idx = mb->partitioning = + vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob); + int n, num = vp8_mbsplit_count[part_idx]; VP8Macroblock *top_mb = &mb[2]; VP8Macroblock *left_mb = &mb[-1]; const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning], *mbsplits_top = vp8_mbsplits[top_mb->partitioning], - *mbsplits_cur, *firstidx; + *mbsplits_cur = vp8_mbsplits[part_idx], + *firstidx = vp8_mbfirstidx[part_idx]; VP56mv *top_mv = top_mb->bmv; VP56mv *left_mv = left_mb->bmv; VP56mv *cur_mv = mb->bmv; - if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) { - if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1])) { - part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]); - } else { - part_idx = VP8_SPLITMVMODE_8x8; - } - } else { - part_idx = VP8_SPLITMVMODE_4x4; - } - - num = vp8_mbsplit_count[part_idx]; - mbsplits_cur = vp8_mbsplits[part_idx], - firstidx = vp8_mbfirstidx[part_idx]; - mb->partitioning = part_idx; - for (n = 0; n < num; n++) { int k = firstidx[n]; uint32_t left, above; @@ -685,19 +672,20 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) submv_prob = get_submv_prob(left, above); - if (vp56_rac_get_prob_branchy(c, submv_prob[0])) { - if (vp56_rac_get_prob_branchy(c, submv_prob[1])) { - if (vp56_rac_get_prob_branchy(c, submv_prob[2])) { - mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]); - mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]); - } else { - AV_ZERO32(&mb->bmv[n]); - } - } else { - AV_WN32A(&mb->bmv[n], above); - } - } else { + switch (vp8_rac_get_tree(c, vp8_submv_ref_tree, submv_prob)) { + case VP8_SUBMVMODE_NEW4X4: + mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]); + mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]); + break; + case VP8_SUBMVMODE_ZERO4X4: + AV_ZERO32(&mb->bmv[n]); + break; + case VP8_SUBMVMODE_LEFT4X4: AV_WN32A(&mb->bmv[n], left); + break; + case VP8_SUBMVMODE_TOP4X4: + AV_WN32A(&mb->bmv[n], above); + break; } } @@ -705,32 +693,31 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb) } static av_always_inline -void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, - int mb_x, int keyframe) +void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4, + int stride, int keyframe) { - uint8_t *intra4x4 = s->intra4x4_pred_mode_mb; + int x, y, t, l, i; + if (keyframe) { - int x, y; - uint8_t* const top = s->intra4x4_pred_mode_top + 4 * mb_x; - uint8_t* const left = s->intra4x4_pred_mode_left; + const uint8_t *ctx; for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { - const uint8_t *ctx; - ctx = vp8_pred4x4_prob_intra[top[x]][left[y]]; - *intra4x4 = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx); - left[y] = top[x] = *intra4x4; - intra4x4++; + t = intra4x4[x - stride]; + l = intra4x4[x - 1]; + ctx = vp8_pred4x4_prob_intra[t][l]; + intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx); } + intra4x4 += stride; } } else { - int i; for (i = 0; i < 16; i++) intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree, vp8_pred4x4_prob_inter); } } static av_always_inline -void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_t *segment) +void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, + uint8_t *intra4x4, uint8_t *segment) { VP56RangeCoder *c = &s->c; @@ -744,18 +731,16 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra, vp8_pred16x16_prob_intra); if (mb->mode == MODE_I4x4) { - decode_intra4x4_modes(s, c, mb_x, 1); - } else { - const uint32_t modes = vp8_pred4x4_mode[mb->mode] * 0x01010101u; - AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes); - AV_WN32A(s->intra4x4_pred_mode_left, modes); - } + decode_intra4x4_modes(c, intra4x4, s->b4_stride, 1); + } else + fill_rectangle(intra4x4, 4, 4, s->b4_stride, vp8_pred4x4_mode[mb->mode], 1); s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, vp8_pred8x8c_prob_intra); mb->ref_frame = VP56_FRAME_CURRENT; } else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) { VP56mv near[2], best; uint8_t cnt[4] = { 0 }; + uint8_t p[4]; // inter MB, 16.2 if (vp56_rac_get_prob_branchy(c, s->prob->last)) @@ -767,30 +752,30 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ // motion vectors, 16.3 find_near_mvs(s, mb, mb_x, mb_y, near, &best, cnt); - if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[0]][0])) { - if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[1]][1])) { - if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[2]][2])) { - if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[3]][3])) { - mb->mode = VP8_MVMODE_SPLIT; - clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); - mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1]; - } else { - mb->mode = VP8_MVMODE_NEW; - clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); - mb->mv.y += + read_mv_component(c, s->prob->mvc[0]); - mb->mv.x += + read_mv_component(c, s->prob->mvc[1]); - } - } else { - mb->mode = VP8_MVMODE_NEAR; - clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); - } - } else { - mb->mode = VP8_MVMODE_NEAREST; - clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); - } - } else { - mb->mode = VP8_MVMODE_ZERO; + p[0] = vp8_mode_contexts[cnt[0]][0]; + p[1] = vp8_mode_contexts[cnt[1]][1]; + p[2] = vp8_mode_contexts[cnt[2]][2]; + p[3] = vp8_mode_contexts[cnt[3]][3]; + mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_mvinter, p); + switch (mb->mode) { + case VP8_MVMODE_SPLIT: + clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); + mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1]; + break; + case VP8_MVMODE_ZERO: AV_ZERO32(&mb->mv); + break; + case VP8_MVMODE_NEAREST: + clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); + break; + case VP8_MVMODE_NEAR: + clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); + break; + case VP8_MVMODE_NEW: + clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); + mb->mv.y += + read_mv_component(c, s->prob->mvc[0]); + mb->mv.x += + read_mv_component(c, s->prob->mvc[1]); + break; } if (mb->mode != VP8_MVMODE_SPLIT) { mb->partitioning = VP8_SPLITMVMODE_NONE; @@ -801,7 +786,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16); if (mb->mode == MODE_I4x4) - decode_intra4x4_modes(s, c, mb_x, 0); + decode_intra4x4_modes(c, intra4x4, 4, 0); s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c); mb->ref_frame = VP56_FRAME_CURRENT; @@ -821,30 +806,37 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ * @return 0 if no coeffs were decoded * otherwise, the index of the last coeff decoded plus one */ -static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16], - uint8_t probs[8][3][NUM_DCT_TOKENS-1], - int i, uint8_t *token_prob, int16_t qmul[2]) +static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], + uint8_t probs[8][3][NUM_DCT_TOKENS-1], + int i, int zero_nhood, int16_t qmul[2]) { - goto skip_eob; + uint8_t *token_prob; + int nonzero = 0; + int coeff; + do { - int coeff; + token_prob = probs[vp8_coeff_band[i]][zero_nhood]; + if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB - return i; + return nonzero; skip_eob: if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0 - if (++i == 16) - return i; // invalid input; blocks should end with EOB - token_prob = probs[i][0]; - goto skip_eob; + zero_nhood = 0; + token_prob = probs[vp8_coeff_band[++i]][0]; + if (i < 16) + goto skip_eob; + return nonzero; // invalid input; blocks should end with EOB } if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1 coeff = 1; - token_prob = probs[i+1][1]; + zero_nhood = 1; } else { + zero_nhood = 2; + if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4 - coeff = vp56_rac_get_prob_branchy(c, token_prob[4]); + coeff = vp56_rac_get_prob(c, token_prob[4]); if (coeff) coeff += vp56_rac_get_prob(c, token_prob[5]); coeff += 2; @@ -866,49 +858,36 @@ skip_eob: coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]); } } - token_prob = probs[i+1][2]; } - block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i]; - } while (++i < 16); - return i; -} + // todo: full [16] qmat? load into register? + block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i]; + nonzero = ++i; + } while (i < 16); -static av_always_inline -int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], - uint8_t probs[8][3][NUM_DCT_TOKENS-1], - int i, int zero_nhood, int16_t qmul[2]) -{ - uint8_t *token_prob = probs[i][zero_nhood]; - if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB - return 0; - return decode_block_coeffs_internal(c, block, probs, i, token_prob, qmul); + return nonzero; } static av_always_inline void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9]) { + LOCAL_ALIGNED_16(DCTELEM, dc,[16]); int i, x, y, luma_start = 0, luma_ctx = 3; int nnz_pred, nnz, nnz_total = 0; int segment = s->segment; - int block_dc = 0; if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { + AV_ZERO128(dc); + AV_ZERO128(dc+8); nnz_pred = t_nnz[8] + l_nnz[8]; // decode DC values and do hadamard - nnz = decode_block_coeffs(c, s->block_dc, s->prob->token[1], 0, nnz_pred, + nnz = decode_block_coeffs(c, dc, s->prob->token[1], 0, nnz_pred, s->qmat[segment].luma_dc_qmul); l_nnz[8] = t_nnz[8] = !!nnz; - if (nnz) { - nnz_total += nnz; - block_dc = 1; - if (nnz == 1) - s->vp8dsp.vp8_luma_dc_wht_dc(s->block, s->block_dc); - else - s->vp8dsp.vp8_luma_dc_wht(s->block, s->block_dc); - } + nnz_total += nnz; + s->vp8dsp.vp8_luma_dc_wht(s->block, dc); luma_start = 1; luma_ctx = 0; } @@ -919,8 +898,8 @@ void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, nnz_pred = l_nnz[y] + t_nnz[x]; nnz = decode_block_coeffs(c, s->block[y][x], s->prob->token[luma_ctx], luma_start, nnz_pred, s->qmat[segment].luma_qmul); - // nnz+block_dc may be one more than the actual last index, but we don't care - s->non_zero_count_cache[y][x] = nnz + block_dc; + // nnz+luma_start may be one more than the actual last index, but we don't care + s->non_zero_count_cache[y][x] = nnz + luma_start; t_nnz[x] = l_nnz[y] = !!nnz; nnz_total += nnz; } @@ -1003,7 +982,7 @@ int check_intra_pred_mode(int mode, int mb_x, int mb_y) static av_always_inline void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, - int mb_x, int mb_y) + uint8_t *intra4x4, int mb_x, int mb_y) { int x, y, mode, nnz, tr; @@ -1019,7 +998,7 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, s->hpc.pred16x16[mode](dst[0], s->linesize); } else { uint8_t *ptr = dst[0]; - uint8_t *intra4x4 = s->intra4x4_pred_mode_mb; + int stride = s->keyframe ? s->b4_stride : 4; // all blocks on the right edge of the macroblock use bottom edge // the top macroblock for their topright edge @@ -1054,7 +1033,7 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, } ptr += 4*s->linesize; - intra4x4 += 4; + intra4x4 += stride; } } @@ -1541,12 +1520,11 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, // top edge of 127 for intra prediction memset(s->top_border, 127, (s->mb_width+1)*sizeof(*s->top_border)); memset(s->ref_count, 0, sizeof(s->ref_count)); - if (s->keyframe) - memset(s->intra4x4_pred_mode_top, DC_PRED, s->b4_stride*4); for (mb_y = 0; mb_y < s->mb_height; mb_y++) { VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)]; VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2; + uint8_t *intra4x4 = s->intra4x4_pred_mode + 4*mb_y*s->b4_stride; uint8_t *segment_map = s->segmentation_map + mb_y*s->mb_stride; int mb_xy = mb_y * s->mb_stride; uint8_t *dst[3] = { @@ -1556,7 +1534,6 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, }; memset(s->left_nnz, 0, sizeof(s->left_nnz)); - AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101); // left edge of 129 for intra prediction if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) @@ -1567,13 +1544,14 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, memset(s->top_border, 129, sizeof(*s->top_border)); for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { + uint8_t *intra4x4_mb = s->keyframe ? intra4x4 + 4*mb_x : s->intra4x4_pred_mode_mb; uint8_t *segment_mb = segment_map+mb_x; /* Prefetch the current frame, 4 MBs ahead */ s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4); s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2); - decode_mb_mode(s, mb, mb_x, mb_y, segment_mb); + decode_mb_mode(s, mb, mb_x, mb_y, intra4x4_mb, segment_mb); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); @@ -1581,7 +1559,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz); if (mb->mode <= MODE_I4x4) - intra_predict(s, dst, mb, mb_x, mb_y); + intra_predict(s, dst, mb, intra4x4_mb, mb_x, mb_y); else inter_predict(s, dst, mb, mb_x, mb_y); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h index a64b7d5b4..1bdac16be 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8data.h @@ -55,6 +55,13 @@ enum inter_mvmode { VP8_MVMODE_SPLIT }; +enum inter_submvmode { + VP8_SUBMVMODE_LEFT4X4, + VP8_SUBMVMODE_TOP4X4, + VP8_SUBMVMODE_ZERO4X4, + VP8_SUBMVMODE_NEW4X4 +}; + enum inter_splitmvmode { VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical) VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal) @@ -104,6 +111,13 @@ static const int vp8_mode_contexts[6][4] = { { 234, 188, 128, 28 }, }; +static const int8_t vp8_pred16x16_tree_mvinter[4][2] = { + { -VP8_MVMODE_ZERO, 1 }, // '0' + { -VP8_MVMODE_NEAREST, 2 }, // '10' + { -VP8_MVMODE_NEAR, 3 }, // '110' + { -VP8_MVMODE_NEW, -VP8_MVMODE_SPLIT } // '1110', '1111' +}; + static const uint8_t vp8_mbsplits[5][16] = { { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, @@ -123,6 +137,12 @@ static const uint8_t vp8_mbfirstidx[4][16] = { 8, 9, 10, 11, 12, 13, 14, 15 } }; +static const int8_t vp8_mbsplit_tree[3][2] = { + { -VP8_SPLITMVMODE_4x4, 1 }, // '0' - 16 individual MVs + { -VP8_SPLITMVMODE_8x8, 2 }, // '10' - quarter-based MVs + { -VP8_SPLITMVMODE_16x8, // '110' - top/bottom MVs + -VP8_SPLITMVMODE_8x16 } // '111' - left/right MVs +}; static const uint8_t vp8_mbsplit_count[4] = { 2, 2, 4, 16 }; static const uint8_t vp8_mbsplit_prob[3] = { 110, 111, 150 }; @@ -134,6 +154,12 @@ static const uint8_t vp8_submv_prob[5][3] = { { 208, 1, 1 } }; +static const int8_t vp8_submv_ref_tree[3][2] = { + { -VP8_SUBMVMODE_LEFT4X4, 1 }, // '0' + { -VP8_SUBMVMODE_TOP4X4, 2 }, // '10' + { -VP8_SUBMVMODE_ZERO4X4, -VP8_SUBMVMODE_NEW4X4 } // '110', '111' +}; + static const uint8_t vp8_pred16x16_prob_intra[4] = { 145, 156, 163, 128 }; static const uint8_t vp8_pred16x16_prob_inter[4] = { 112, 86, 140, 37 }; @@ -301,20 +327,6 @@ static const uint8_t vp8_coeff_band[16] = 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7 }; -/* Inverse of vp8_coeff_band: mappings of bands to coefficient indexes. - * Each list is -1-terminated. */ -static const int8_t vp8_coeff_band_indexes[8][10] = -{ - {0, -1}, - {1, -1}, - {2, -1}, - {3, -1}, - {5, -1}, - {6, -1}, - {4, 7, 8, 9, 10, 11, 12, 13, 14, -1}, - {15, -1} -}; - static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 }; static const uint8_t vp8_dct_cat2_prob[] = { 165, 145, 0 }; static const uint8_t vp8_dct_cat3_prob[] = { 173, 148, 140, 0 }; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c index 5c83b6df8..0c61d9252 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.c @@ -46,31 +46,15 @@ static void vp8_luma_dc_wht_c(DCTELEM block[4][4][16], DCTELEM dc[16]) t1 = dc[i*4+1] + dc[i*4+2]; t2 = dc[i*4+1] - dc[i*4+2]; t3 = dc[i*4+0] - dc[i*4+3] + 3; // rounding - dc[i*4+0] = 0; - dc[i*4+1] = 0; - dc[i*4+2] = 0; - dc[i*4+3] = 0; - - block[i][0][0] = (t0 + t1) >> 3; - block[i][1][0] = (t3 + t2) >> 3; - block[i][2][0] = (t0 - t1) >> 3; - block[i][3][0] = (t3 - t2) >> 3; - } -} - -static void vp8_luma_dc_wht_dc_c(DCTELEM block[4][4][16], DCTELEM dc[16]) -{ - int i, val = (dc[0] + 3) >> 3; - dc[0] = 0; - for (i = 0; i < 4; i++) { - block[i][0][0] = val; - block[i][1][0] = val; - block[i][2][0] = val; - block[i][3][0] = val; + *block[i][0] = (t0 + t1) >> 3; + *block[i][1] = (t3 + t2) >> 3; + *block[i][2] = (t0 - t1) >> 3; + *block[i][3] = (t3 - t2) >> 3; } } + #define MUL_20091(a) ((((a)*20091) >> 16) + (a)) #define MUL_35468(a) (((a)*35468) >> 16) @@ -492,7 +476,6 @@ VP8_BILINEAR(4) av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) { dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c; - dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c; dsp->vp8_idct_add = vp8_idct_add_c; dsp->vp8_idct_dc_add = vp8_idct_dc_add_c; dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c; diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h index ee5c7ec0f..47b1a9077 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8dsp.h @@ -31,7 +31,6 @@ typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, int dstStride, uint8_t *src typedef struct VP8DSPContext { void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]); - void (*vp8_luma_dc_wht_dc)(DCTELEM block[4][4][16], DCTELEM dc[16]); void (*vp8_idct_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_dc_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_dc_add4y)(uint8_t *dst, DCTELEM block[4][16], int stride); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c index 616943146..cd4e46219 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c @@ -2725,6 +2725,9 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
#endif
+ if (CONFIG_CAVS_DECODER)
+ ff_cavsdsp_init_mmx2(c, avctx);
+
if (CONFIG_VC1_DECODER)
ff_vc1dsp_init_mmx(c, avctx);
@@ -2785,6 +2788,9 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow;
c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow;
+
+ if (CONFIG_CAVS_DECODER)
+ ff_cavsdsp_init_3dnow(c, avctx);
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h index 33dafed1f..13067dffc 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h @@ -162,6 +162,8 @@ void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); +void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx); +void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx); void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h index 233fd7abe..95f96e365 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp56_arith.h @@ -26,7 +26,7 @@ #if HAVE_FAST_CMOV
#define vp56_rac_get_prob vp56_rac_get_prob
-static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
+static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
{
unsigned int code_word = vp56_rac_renorm(c);
unsigned int high = c->high;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c index 40fd0e4e3..dd7dc696e 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp-init.c @@ -224,7 +224,6 @@ extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16], int str extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16], int stride); extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16], int stride); extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]); -extern void ff_vp8_luma_dc_wht_sse(DCTELEM block[4][4][16], DCTELEM dc[16]); extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); extern void ff_vp8_idct_add_sse(uint8_t *dst, DCTELEM block[16], int stride); @@ -338,7 +337,6 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) if (mm_flags & FF_MM_SSE) { c->vp8_idct_add = ff_vp8_idct_add_sse; - c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_sse; c->put_vp8_epel_pixels_tab[0][0][0] = c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse; } diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm index 6999e87b6..4f430d80c 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/vp8dsp.asm @@ -1186,23 +1186,12 @@ VP8_IDCT_ADD sse SWAP %1, %4, %3 %endmacro -%macro VP8_DC_WHT 1 -cglobal vp8_luma_dc_wht_%1, 2,3 +INIT_MMX +cglobal vp8_luma_dc_wht_mmx, 2,3 movq m0, [r1] movq m1, [r1+8] movq m2, [r1+16] movq m3, [r1+24] -%ifidn %1, sse - xorps xmm0, xmm0 - movaps [r1+ 0], xmm0 - movaps [r1+16], xmm0 -%else - pxor m4, m4 - movq [r1+ 0], m4 - movq [r1+ 8], m4 - movq [r1+16], m4 - movq [r1+24], m4 -%endif HADAMARD4_1D 0, 1, 2, 3 TRANSPOSE4x4W 0, 1, 2, 3, 4 paddw m0, [pw_3] @@ -1214,11 +1203,6 @@ cglobal vp8_luma_dc_wht_%1, 2,3 SCATTER_WHT 0, 1, 0 SCATTER_WHT 2, 3, 2 RET -%endmacro - -INIT_MMX -VP8_DC_WHT mmx -VP8_DC_WHT sse ;----------------------------------------------------------------------------- ; void vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim); |