Commit c1362ca0 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'e588615d'

* commit 'e588615d':
  hevc: fix decoding of one PU wide files

Conflicts:
	libavcodec/hevc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2b318f8c e588615d
......@@ -1041,15 +1041,19 @@ static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride,
if (x_off < extra_left || y_off < extra_top ||
x_off >= pic_width - block_w - ff_hevc_qpel_extra_after[mx] ||
y_off >= pic_height - block_h - ff_hevc_qpel_extra_after[my]) {
const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
int offset = extra_top * srcstride + (extra_left << s->sps->pixel_shift);
int buf_offset = extra_top *
edge_emu_stride + (extra_left << s->sps->pixel_shift);
s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset,
srcstride, srcstride,
edge_emu_stride, srcstride,
block_w + ff_hevc_qpel_extra[mx],
block_h + ff_hevc_qpel_extra[my],
x_off - extra_left, y_off - extra_top,
pic_width, pic_height);
src = lc->edge_emu_buffer + offset;
src = lc->edge_emu_buffer + buf_offset;
srcstride = edge_emu_stride;
}
s->hevcdsp.put_hevc_qpel[my][mx](dst, dststride, src, srcstride, block_w,
block_h, lc->mc_buffer);
......@@ -1092,27 +1096,35 @@ static void chroma_mc(HEVCContext *s, int16_t *dst1, int16_t *dst2,
if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) {
const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->sps->pixel_shift));
int buf_offset1 = EPEL_EXTRA_BEFORE *
(edge_emu_stride + (1 << s->sps->pixel_shift));
int offset2 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->sps->pixel_shift));
int buf_offset2 = EPEL_EXTRA_BEFORE *
(edge_emu_stride + (1 << s->sps->pixel_shift));
s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1,
src1stride, src1stride,
edge_emu_stride, src1stride,
block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
x_off - EPEL_EXTRA_BEFORE,
y_off - EPEL_EXTRA_BEFORE,
pic_width, pic_height);
src1 = lc->edge_emu_buffer + offset1;
src1 = lc->edge_emu_buffer + buf_offset1;
src1stride = edge_emu_stride;
s->hevcdsp.put_hevc_epel[!!my][!!mx](dst1, dststride, src1, src1stride,
block_w, block_h, mx, my, lc->mc_buffer);
s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src2 - offset2,
src2stride, src2stride,
edge_emu_stride, src2stride,
block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
x_off - EPEL_EXTRA_BEFORE,
y_off - EPEL_EXTRA_BEFORE,
pic_width, pic_height);
src2 = lc->edge_emu_buffer + offset2;
src2 = lc->edge_emu_buffer + buf_offset2;
src2stride = edge_emu_stride;
s->hevcdsp.put_hevc_epel[!!my][!!mx](dst2, dststride, src2, src2stride,
block_w, block_h, mx, my,
lc->mc_buffer);
......@@ -1974,7 +1986,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
s->sList[i] = av_malloc(sizeof(HEVCContext));
memcpy(s->sList[i], s, sizeof(HEVCContext));
s->HEVClcList[i] = av_malloc(sizeof(HEVCLocalContext));
s->HEVClcList[i]->edge_emu_buffer = av_malloc((MAX_PB_SIZE + 7) * s->frame->linesize[0]);
s->sList[i]->HEVClc = s->HEVClcList[i];
}
}
......@@ -2143,13 +2154,6 @@ static int hevc_frame_start(HEVCContext *s)
if (ret < 0)
goto fail;
av_fast_malloc(&lc->edge_emu_buffer, &lc->edge_emu_buffer_size,
(MAX_PB_SIZE + 7) * s->ref->frame->linesize[0]);
if (!lc->edge_emu_buffer) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = ff_hevc_frame_rps(s);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Error constructing the frame RPS.\n");
......@@ -2688,8 +2692,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
pic_arrays_free(s);
if (lc)
av_freep(&lc->edge_emu_buffer);
av_freep(&s->md5_ctx);
for(i=0; i < s->nals_allocated; i++) {
......@@ -2723,7 +2725,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
for (i = 1; i < s->threads_number; i++) {
lc = s->HEVClcList[i];
if (lc) {
av_freep(&lc->edge_emu_buffer);
av_freep(&s->HEVClcList[i]);
av_freep(&s->sList[i]);
}
......
......@@ -72,6 +72,8 @@
#define EPEL_EXTRA_AFTER 2
#define EPEL_EXTRA 3
#define EDGE_EMU_BUFFER_STRIDE 80
/**
* Value of the luma sample at position (x, y) in the 2D array tab.
*/
......@@ -730,8 +732,8 @@ typedef struct HEVCLocalContext {
int start_of_tiles_x;
int end_of_tiles_x;
int end_of_tiles_y;
uint8_t *edge_emu_buffer;
int edge_emu_buffer_size;
/* +7 is for subpixel interpolation, *2 for high bit depths */
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
CodingTree ct;
CodingUnit cu;
PredictionUnit pu;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment