diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-03-21 14:16:29 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-21 14:16:29 +0100 |
commit | 2cc08cad9ecf2d2524bc572a4e9bbe659b330d5c (patch) | |
tree | 22e474fc2d32d8874b8a27766006a87239fb437a /libavcodec | |
parent | 892a6d00280215ab4c1485c0931912f82318dc63 (diff) | |
parent | 5f390eef8ee2b8adab00c5d2923a52aa261eb999 (diff) | |
download | ffmpeg-2cc08cad9ecf2d2524bc572a4e9bbe659b330d5c.tar.gz |
Merge commit '5f390eef8ee2b8adab00c5d2923a52aa261eb999'
* commit '5f390eef8ee2b8adab00c5d2923a52aa261eb999':
h264: move mb_[uv]linesize into the per-slice context
Conflicts:
libavcodec/h264.h
libavcodec/h264_mb.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.h | 5 | ||||
-rw-r--r-- | libavcodec/h264_mb.c | 94 | ||||
-rw-r--r-- | libavcodec/h264_mb_template.c | 12 | ||||
-rw-r--r-- | libavcodec/h264_mc_template.c | 8 | ||||
-rw-r--r-- | libavcodec/h264_slice.c | 8 |
5 files changed, 64 insertions, 63 deletions
diff --git a/libavcodec/h264.h b/libavcodec/h264.h index c03bd4b7dd..e41626bdef 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -379,6 +379,9 @@ typedef struct H264SliceContext { unsigned int topright_samples_available; unsigned int left_samples_available; + ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff + ptrdiff_t mb_uvlinesize; + /** * number of neighbors (top and/or left) that used 8x8 dct */ @@ -452,8 +455,6 @@ typedef struct H264Context { uint32_t *mb2br_xy; int b_stride; // FIXME use s->b4_stride - ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff - ptrdiff_t mb_uvlinesize; unsigned current_sps_id; ///< id of the current SPS SPS sps; ///< current sps diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c index c15c8feb40..45c5695a8e 100644 --- a/libavcodec/h264_mb.c +++ b/libavcodec/h264_mb.c @@ -216,7 +216,7 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl, const int mx = sl->mv_cache[list][scan8[n]][0] + src_x_offset * 8; int my = sl->mv_cache[list][scan8[n]][1] + src_y_offset * 8; const int luma_xy = (mx & 3) + ((my & 3) << 2); - ptrdiff_t offset = (mx >> 2) * (1 << pixel_shift) + (my >> 2) * h->mb_linesize; + ptrdiff_t offset = (mx >> 2) * (1 << pixel_shift) + (my >> 2) * sl->mb_linesize; uint8_t *src_y = pic->f.data[0] + offset; uint8_t *src_cb, *src_cr; int extra_width = 0; @@ -238,17 +238,17 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl, full_mx + 16 /*FIXME*/ > pic_width + extra_width || full_my + 16 /*FIXME*/ > pic_height + extra_height) { h->vdsp.emulated_edge_mc(h->edge_emu_buffer, - src_y - (2 << pixel_shift) - 2 * h->mb_linesize, - h->mb_linesize, h->mb_linesize, + src_y - (2 << pixel_shift) - 2 * sl->mb_linesize, + sl->mb_linesize, sl->mb_linesize, 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2, full_my - 2, pic_width, pic_height); - src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize; emu = 1; } - qpix_op[luma_xy](dest_y, src_y, h->mb_linesize); // FIXME try variable height perhaps? + qpix_op[luma_xy](dest_y, src_y, sl->mb_linesize); // FIXME try variable height perhaps? if (!square) - qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize); + qpix_op[luma_xy](dest_y + delta, src_y + delta, sl->mb_linesize); if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY) return; @@ -257,30 +257,30 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl, src_cb = pic->f.data[1] + offset; if (emu) { h->vdsp.emulated_edge_mc(h->edge_emu_buffer, - src_cb - (2 << pixel_shift) - 2 * h->mb_linesize, - h->mb_linesize, h->mb_linesize, + src_cb - (2 << pixel_shift) - 2 * sl->mb_linesize, + sl->mb_linesize, sl->mb_linesize, 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2, full_my - 2, pic_width, pic_height); - src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize; } - qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); // FIXME try variable height perhaps? + qpix_op[luma_xy](dest_cb, src_cb, sl->mb_linesize); // FIXME try variable height perhaps? if (!square) - qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize); + qpix_op[luma_xy](dest_cb + delta, src_cb + delta, sl->mb_linesize); src_cr = pic->f.data[2] + offset; if (emu) { h->vdsp.emulated_edge_mc(h->edge_emu_buffer, - src_cr - (2 << pixel_shift) - 2 * h->mb_linesize, - h->mb_linesize, h->mb_linesize, + src_cr - (2 << pixel_shift) - 2 * sl->mb_linesize, + sl->mb_linesize, sl->mb_linesize, 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2, full_my - 2, pic_width, pic_height); - src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize; } - qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); // FIXME try variable height perhaps? + qpix_op[luma_xy](dest_cr, src_cr, sl->mb_linesize); // FIXME try variable height perhaps? if (!square) - qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize); + qpix_op[luma_xy](dest_cr + delta, src_cr + delta, sl->mb_linesize); return; } @@ -292,29 +292,29 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl, } src_cb = pic->f.data[1] + ((mx >> 3) * (1 << pixel_shift)) + - (my >> ysh) * h->mb_uvlinesize; + (my >> ysh) * sl->mb_uvlinesize; src_cr = pic->f.data[2] + ((mx >> 3) * (1 << pixel_shift)) + - (my >> ysh) * h->mb_uvlinesize; + (my >> ysh) * sl->mb_uvlinesize; if (emu) { h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb, - h->mb_uvlinesize, h->mb_uvlinesize, + sl->mb_uvlinesize, sl->mb_uvlinesize, 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); src_cb = h->edge_emu_buffer; } - chroma_op(dest_cb, src_cb, h->mb_uvlinesize, + chroma_op(dest_cb, src_cb, sl->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), mx & 7, ((unsigned)my << (chroma_idc == 2 /* yuv422 */)) & 7); if (emu) { h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr, - h->mb_uvlinesize, h->mb_uvlinesize, + sl->mb_uvlinesize, sl->mb_uvlinesize, 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); src_cr = h->edge_emu_buffer; } - chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), + chroma_op(dest_cr, src_cr, sl->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), mx & 7, ((unsigned)my << (chroma_idc == 2 /* yuv422 */)) & 7); } @@ -334,16 +334,16 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl, qpel_mc_func *qpix_op = qpix_put; h264_chroma_mc_func chroma_op = chroma_put; - dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; + dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; if (chroma_idc == 3 /* yuv444 */) { - dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; - dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; + dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; + dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; } else if (chroma_idc == 2 /* yuv422 */) { - dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize; - dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize; + dest_cb += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize; + dest_cr += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize; } else { /* yuv420 */ - dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize; - dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize; + dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; + dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; } x_offset += 8 * h->mb_x; y_offset += 8 * (h->mb_y >> MB_FIELD(h)); @@ -383,21 +383,21 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * { int chroma_height; - dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; + dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; if (chroma_idc == 3 /* yuv444 */) { chroma_height = height; chroma_weight_avg = luma_weight_avg; chroma_weight_op = luma_weight_op; - dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; - dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize; + dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; + dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize; } else if (chroma_idc == 2 /* yuv422 */) { chroma_height = height; - dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize; - dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize; + dest_cb += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize; + dest_cr += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize; } else { /* yuv420 */ chroma_height = height >> 1; - dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize; - dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize; + dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; + dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; } x_offset += 8 * h->mb_x; y_offset += 8 * (h->mb_y >> MB_FIELD(h)); @@ -407,7 +407,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * * use implicit weights => chroma too. */ uint8_t *tmp_cb = h->bipred_scratchpad; uint8_t *tmp_cr = h->bipred_scratchpad + (16 << pixel_shift); - uint8_t *tmp_y = h->bipred_scratchpad + 16 * h->mb_uvlinesize; + uint8_t *tmp_y = h->bipred_scratchpad + 16 * sl->mb_uvlinesize; int refn0 = sl->ref_cache[0][scan8[n]]; int refn1 = sl->ref_cache[1][scan8[n]]; @@ -423,29 +423,29 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * if (sl->use_weight == 2) { int weight0 = sl->implicit_weight[refn0][refn1][h->mb_y & 1]; int weight1 = 64 - weight0; - luma_weight_avg(dest_y, tmp_y, h->mb_linesize, + luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height, 5, weight0, weight1, 0); if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { - chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, + chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height, 5, weight0, weight1, 0); - chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, + chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height, 5, weight0, weight1, 0); } } else { - luma_weight_avg(dest_y, tmp_y, h->mb_linesize, height, + luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height, sl->luma_log2_weight_denom, sl->luma_weight[refn0][0][0], sl->luma_weight[refn1][1][0], sl->luma_weight[refn0][0][1] + sl->luma_weight[refn1][1][1]); if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { - chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, chroma_height, + chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, sl->chroma_weight[refn0][0][0][0], sl->chroma_weight[refn1][1][0][0], sl->chroma_weight[refn0][0][0][1] + sl->chroma_weight[refn1][1][0][1]); - chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, chroma_height, + chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, sl->chroma_weight[refn0][0][1][0], sl->chroma_weight[refn1][1][1][0], @@ -461,17 +461,17 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put, chroma_put, pixel_shift, chroma_idc); - luma_weight_op(dest_y, h->mb_linesize, height, + luma_weight_op(dest_y, sl->mb_linesize, height, sl->luma_log2_weight_denom, sl->luma_weight[refn][list][0], sl->luma_weight[refn][list][1]); if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (sl->use_weight_chroma) { - chroma_weight_op(dest_cb, h->mb_uvlinesize, chroma_height, + chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, sl->chroma_weight[refn][list][0][0], sl->chroma_weight[refn][list][0][1]); - chroma_weight_op(dest_cr, h->mb_uvlinesize, chroma_height, + chroma_weight_op(dest_cr, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, sl->chroma_weight[refn][list][1][0], sl->chroma_weight[refn][list][1][1]); @@ -492,7 +492,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y; uint8_t **src = h->ref_list[list][refn].f.data; int off = mx * (1<< pixel_shift) + - (my + (h->mb_x & 3) * 4) * h->mb_linesize + + (my + (h->mb_x & 3) * 4) * sl->mb_linesize + (64 << pixel_shift); h->vdsp.prefetch(src[0] + off, h->linesize, 4); if (chroma_idc == 3 /* yuv444 */) { diff --git a/libavcodec/h264_mb_template.c b/libavcodec/h264_mb_template.c index 3403e8500b..c808b4e2a3 100644 --- a/libavcodec/h264_mb_template.c +++ b/libavcodec/h264_mb_template.c @@ -67,8 +67,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) h->list_counts[mb_xy] = h->list_count; if (!SIMPLE && MB_FIELD(h)) { - linesize = h->mb_linesize = h->linesize * 2; - uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2; + linesize = sl->mb_linesize = h->linesize * 2; + uvlinesize = sl->mb_uvlinesize = h->uvlinesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) { // FIXME move out of this function? dest_y -= h->linesize * 15; @@ -94,8 +94,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) } } } else { - linesize = h->mb_linesize = h->linesize; - uvlinesize = h->mb_uvlinesize = h->uvlinesize; + linesize = sl->mb_linesize = h->linesize; + uvlinesize = sl->mb_uvlinesize = h->uvlinesize; // dct_offset = s->linesize * 16; } @@ -292,7 +292,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext h->list_counts[mb_xy] = h->list_count; if (!SIMPLE && MB_FIELD(h)) { - linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize * 2; + linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) // FIXME move out of this function? for (p = 0; p < 3; p++) @@ -316,7 +316,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext } } } else { - linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize; + linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { diff --git a/libavcodec/h264_mc_template.c b/libavcodec/h264_mc_template.c index 98ce16cd1a..32b7a3c3af 100644 --- a/libavcodec/h264_mc_template.c +++ b/libavcodec/h264_mc_template.c @@ -95,11 +95,11 @@ static void MCFUNC(hl_motion)(H264Context *h, H264SliceContext *sl, weight_op, weight_avg, IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); } else if (IS_8X16(mb_type)) { - mc_part(h, sl, 0, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0, + mc_part(h, sl, 0, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0, qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], &weight_op[1], &weight_avg[1], IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); - mc_part(h, sl, 4, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0, + mc_part(h, sl, 4, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0, qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], &weight_op[1], &weight_avg[1], IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); @@ -132,12 +132,12 @@ static void MCFUNC(hl_motion)(H264Context *h, H264SliceContext *sl, &weight_op[1], &weight_avg[1], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); } else if (IS_SUB_4X8(sub_mb_type)) { - mc_part(h, sl, n, 0, 8, 4 * h->mb_linesize, + mc_part(h, sl, n, 0, 8, 4 * sl->mb_linesize, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], &weight_op[2], &weight_avg[2], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - mc_part(h, sl, n + 1, 0, 8, 4 * h->mb_linesize, + mc_part(h, sl, n + 1, 0, 8, 4 * sl->mb_linesize, dest_y, dest_cb, dest_cr, x_offset + 2, y_offset, qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], &weight_op[2], &weight_avg[2], diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 46ee8b80b2..2adefb41da 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -2307,16 +2307,16 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e // FIXME simplify above if (MB_FIELD(h)) { - linesize = h->mb_linesize = h->linesize * 2; - uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2; + linesize = sl->mb_linesize = h->linesize * 2; + uvlinesize = sl->mb_uvlinesize = h->uvlinesize * 2; if (mb_y & 1) { // FIXME move out of this function? dest_y -= h->linesize * 15; dest_cb -= h->uvlinesize * (block_h - 1); dest_cr -= h->uvlinesize * (block_h - 1); } } else { - linesize = h->mb_linesize = h->linesize; - uvlinesize = h->mb_uvlinesize = h->uvlinesize; + linesize = sl->mb_linesize = h->linesize; + uvlinesize = sl->mb_uvlinesize = h->uvlinesize; } backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0); |