diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-27 16:52:02 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-27 16:52:02 +0100 |
commit | 6f784c158bd56f2cc73354974ceebb04a40e0f52 (patch) | |
tree | 42366ba91c9e9eabcc543bace6ea13c6af42fa85 | |
parent | f09fd96cee9755cfb8b4bd8f0103a3c56a6396e7 (diff) | |
parent | 549fc77273636d0d02175362af5dcd60c79f7633 (diff) | |
download | ffmpeg-6f784c158bd56f2cc73354974ceebb04a40e0f52.tar.gz |
Merge commit '549fc77273636d0d02175362af5dcd60c79f7633'
* commit '549fc77273636d0d02175362af5dcd60c79f7633':
svq3: move mb2br_xy to the SVQ3Context
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r-- | libavcodec/svq3.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 6ae67c2a82..b483eb04b6 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -97,6 +97,8 @@ typedef struct SVQ3Context { int mb_x, mb_y; int mb_xy; + uint32_t *mb2br_xy; + int chroma_pred_mode; int intra16x16_pred_mode; @@ -746,7 +748,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) */ for (m = 0; m < 2; m++) { - if (s->mb_x > 0 && s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) { + if (s->mb_x > 0 && s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - 1] + 6] != -1) { for (i = 0; i < 4; i++) AV_COPY32(s->mv_cache[m][scan8[0] - 1 + i * 8], h->cur_pic.motion_val[m][b_xy - 1 + i * h->b_stride]); @@ -759,21 +761,21 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) h->cur_pic.motion_val[m][b_xy - h->b_stride], 4 * 2 * sizeof(int16_t)); memset(&s->ref_cache[m][scan8[0] - 1 * 8], - (s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); + (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); if (s->mb_x < h->mb_width - 1) { AV_COPY32(s->mv_cache[m][scan8[0] + 4 - 1 * 8], h->cur_pic.motion_val[m][b_xy - h->b_stride + 4]); s->ref_cache[m][scan8[0] + 4 - 1 * 8] = - (s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride + 1] + 6] == -1 || - s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1; + (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride + 1] + 6] == -1 || + s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1; } else s->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE; if (s->mb_x > 0) { AV_COPY32(s->mv_cache[m][scan8[0] - 1 - 1 * 8], h->cur_pic.motion_val[m][b_xy - h->b_stride - 1]); s->ref_cache[m][scan8[0] - 1 - 1 * 8] = - (s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1; + (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1; } else s->ref_cache[m][scan8[0] - 1 - 1 * 8] = PART_NOT_AVAILABLE; } else @@ -809,7 +811,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) mb_type = MB_TYPE_16x16; } else if (mb_type == 8 || mb_type == 33) { /* INTRA4x4 */ - int8_t *i4x4 = s->intra4x4_pred_mode + h->mb2br_xy[s->mb_xy]; + int8_t *i4x4 = s->intra4x4_pred_mode + s->mb2br_xy[s->mb_xy]; int8_t *i4x4_cache = s->intra4x4_pred_mode_cache; memset(s->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t)); @@ -817,15 +819,15 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) if (mb_type == 8) { if (s->mb_x > 0) { for (i = 0; i < 4; i++) - s->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i]; + s->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - 1] + 6 - i]; if (s->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) s->left_samples_available = 0x5F5F; } if (s->mb_y > 0) { - s->intra4x4_pred_mode_cache[4 + 8 * 0] = s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 0]; - s->intra4x4_pred_mode_cache[5 + 8 * 0] = s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 1]; - s->intra4x4_pred_mode_cache[6 + 8 * 0] = s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 2]; - s->intra4x4_pred_mode_cache[7 + 8 * 0] = s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 3]; + s->intra4x4_pred_mode_cache[4 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride] + 0]; + s->intra4x4_pred_mode_cache[5 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride] + 1]; + s->intra4x4_pred_mode_cache[6 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride] + 2]; + s->intra4x4_pred_mode_cache[7 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride] + 3]; if (s->intra4x4_pred_mode_cache[4 + 8 * 0] == -1) s->top_samples_available = 0x33FF; @@ -903,7 +905,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) } } if (!IS_INTRA4x4(mb_type)) { - memset(s->intra4x4_pred_mode + h->mb2br_xy[mb_xy], DC_PRED, 8); + memset(s->intra4x4_pred_mode + s->mb2br_xy[mb_xy], DC_PRED, 8); } if (!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B) { memset(sl->non_zero_count_cache + 8, 0, 14 * 8 * sizeof(uint8_t)); @@ -1075,17 +1077,17 @@ static int svq3_decode_slice_header(AVCodecContext *avctx) /* reset intra predictors and invalidate motion vector references */ if (s->mb_x > 0) { - memset(s->intra4x4_pred_mode + h->mb2br_xy[mb_xy - 1] + 3, + memset(s->intra4x4_pred_mode + s->mb2br_xy[mb_xy - 1] + 3, -1, 4 * sizeof(int8_t)); - memset(s->intra4x4_pred_mode + h->mb2br_xy[mb_xy - s->mb_x], + memset(s->intra4x4_pred_mode + s->mb2br_xy[mb_xy - s->mb_x], -1, 8 * sizeof(int8_t) * s->mb_x); } if (s->mb_y > 0) { - memset(s->intra4x4_pred_mode + h->mb2br_xy[mb_xy - h->mb_stride], + memset(s->intra4x4_pred_mode + s->mb2br_xy[mb_xy - h->mb_stride], -1, 8 * sizeof(int8_t) * (h->mb_width - s->mb_x)); if (s->mb_x > 0) - s->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] = -1; + s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] = -1; } return 0; @@ -1096,7 +1098,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) SVQ3Context *s = avctx->priv_data; H264Context *h = &s->h; H264SliceContext *sl; - int m; + int m, x, y; unsigned char *extradata; unsigned char *extradata_end; unsigned int size; @@ -1304,6 +1306,22 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) s->h_edge_pos = h->mb_width * 16; s->v_edge_pos = h->mb_height * 16; + s->intra4x4_pred_mode = av_mallocz(h->mb_stride * 2 * 8); + if (!s->intra4x4_pred_mode) + return AVERROR(ENOMEM); + + s->mb2br_xy = av_mallocz(h->mb_stride * (h->mb_height + 1) * + sizeof(*s->mb2br_xy)); + if (!s->mb2br_xy) + return AVERROR(ENOMEM); + + for (y = 0; y < h->mb_height; y++) + for (x = 0; x < h->mb_width; x++) { + const int mb_xy = x + y * h->mb_stride; + + s->mb2br_xy[mb_xy] = 8 * (mb_xy % (2 * h->mb_stride)); + } + if ((ret = ff_h264_alloc_tables(h)) < 0) { av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n"); goto fail; @@ -1618,6 +1636,7 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx) av_freep(&s->slice_buf); av_freep(&s->intra4x4_pred_mode); av_freep(&s->edge_emu_buffer); + av_freep(&s->mb2br_xy); memset(&h->cur_pic, 0, sizeof(h->cur_pic)); |