X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhevc.c;h=505249e6b5415d44d65443587e92ea63275b503c;hb=8259f8a7207ac0d0e9db69df9a8bc0f53bcb87a0;hp=29e0d49891b8d81ace05a7464082f6b738a21417;hpb=4c5c522fc1a55940e931ece665b2b249d8f39bb1;p=ffmpeg diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index 29e0d49891b..505249e6b54 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -1052,7 +1052,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } - s->hevcdsp.transform_add[log2_trafo_size_c-2](dst, coeffs, stride); + s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs, stride); } } @@ -1081,7 +1081,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } - s->hevcdsp.transform_add[log2_trafo_size_c-2](dst, coeffs, stride); + s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs, stride); } } } else if (s->ps.sps->chroma_format_idc && blk_idx == 3) { @@ -2973,17 +2973,15 @@ static int verify_md5(HEVCContext *s, AVFrame *frame) return 0; } -static int hevc_decode_extradata(HEVCContext *s) +static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length) { AVCodecContext *avctx = s->avctx; GetByteContext gb; int ret, i; - bytestream2_init(&gb, avctx->extradata, avctx->extradata_size); + bytestream2_init(&gb, buf, length); - if (avctx->extradata_size > 3 && - (avctx->extradata[0] || avctx->extradata[1] || - avctx->extradata[2] > 1)) { + if (length > 3 && (buf[0] || buf[1] || buf[2] > 1)) { /* It seems the extradata is encoded as hvcC format. * Temporarily, we support configurationVersion==0 until 14496-15 3rd * is finalized. When finalized, configurationVersion will be 1 and we @@ -3030,7 +3028,7 @@ static int hevc_decode_extradata(HEVCContext *s) s->nal_length_size = nal_len_size; } else { s->is_nalff = 0; - ret = decode_nal_units(s, avctx->extradata, avctx->extradata_size); + ret = decode_nal_units(s, buf, length); if (ret < 0) return ret; } @@ -3051,6 +3049,8 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt) { int ret; + int new_extradata_size; + uint8_t *new_extradata; HEVCContext *s = avctx->priv_data; if (!avpkt->size) { @@ -3062,6 +3062,14 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, return 0; } + new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, + &new_extradata_size); + if (new_extradata && new_extradata_size > 0) { + ret = hevc_decode_extradata(s, new_extradata, new_extradata_size); + if (ret < 0) + return ret; + } + s->ref = NULL; ret = decode_nal_units(s, avpkt->data, avpkt->size); if (ret < 0) @@ -3338,7 +3346,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) s->threads_number = 1; if (avctx->extradata_size > 0 && avctx->extradata) { - ret = hevc_decode_extradata(s); + ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size); if (ret < 0) { hevc_decode_free(avctx); return ret; @@ -3408,5 +3416,6 @@ AVCodec ff_hevc_decoder = { .init_thread_copy = hevc_init_thread_copy, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles), };