diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 2d0c098e41..8518fc8eb2 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -411,6 +411,7 @@ typedef struct H264SliceContext { * according to picture reordering in slice header */ int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 + const uint8_t *intra_pcm_ptr; /** * non zero coeff count cache. @@ -511,7 +512,6 @@ typedef struct H264Context { GetBitContext *intra_gb_ptr; GetBitContext *inter_gb_ptr; - const uint8_t *intra_pcm_ptr; DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2]; ///< as a dct coefficient is int32_t in high depth, we need to reserve twice the space. DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2]; int16_t mb_padding[256 * 2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 889b35e243..d2a8fb0090 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -2034,7 +2034,7 @@ decode_intra_mb: // The pixels are stored in the same order as levels in h->mb array. if ((int) (h->cabac.bytestream_end - ptr) < mb_size) return -1; - h->intra_pcm_ptr = ptr; + sl->intra_pcm_ptr = ptr; ptr += mb_size; ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr); diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 33981a6b57..09b5038a18 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -778,7 +778,7 @@ decode_intra_mb: h->sps.bit_depth_luma; // We assume these blocks are very rare so we do not optimize it. - h->intra_pcm_ptr = align_get_bits(&h->gb); + sl->intra_pcm_ptr = align_get_bits(&h->gb); if (get_bits_left(&h->gb) < mb_size) { av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n"); return AVERROR_INVALIDDATA; diff --git a/libavcodec/h264_mb_template.c b/libavcodec/h264_mb_template.c index 3e3cc05b74..5d7117c6dc 100644 --- a/libavcodec/h264_mb_template.c +++ b/libavcodec/h264_mb_template.c @@ -104,7 +104,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) if (PIXEL_SHIFT) { int j; GetBitContext gb; - init_get_bits(&gb, h->intra_pcm_ptr, + init_get_bits(&gb, sl->intra_pcm_ptr, ff_h264_mb_sizes[h->sps.chroma_format_idc] * bit_depth); for (i = 0; i < 16; i++) { @@ -136,7 +136,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) } } else { for (i = 0; i < 16; i++) - memcpy(dest_y + i * linesize, h->intra_pcm_ptr + i * 16, 16); + memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < 8; i++) { @@ -144,8 +144,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) memset(dest_cr + i * uvlinesize, 1 << (bit_depth - 1), 8); } } else { - const uint8_t *src_cb = h->intra_pcm_ptr + 256; - const uint8_t *src_cr = h->intra_pcm_ptr + 256 + block_h * 8; + const uint8_t *src_cb = sl->intra_pcm_ptr + 256; + const uint8_t *src_cr = sl->intra_pcm_ptr + 256 + block_h * 8; for (i = 0; i < block_h; i++) { memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8); memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8); @@ -323,7 +323,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; GetBitContext gb; - init_get_bits(&gb, h->intra_pcm_ptr, 768 * bit_depth); + init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth); for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) { @@ -335,7 +335,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) memcpy(dest[p] + i * linesize, - h->intra_pcm_ptr + p * 256 + i * 16, 16); + sl->intra_pcm_ptr + p * 256 + i * 16, 16); } } else { if (IS_INTRA(mb_type)) { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 231f67e5a2..cb8328e58d 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -534,7 +534,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, av_freep(&h->rbsp_buffer[0]); av_freep(&h->rbsp_buffer[1]); ff_h264_unref_picture(h, &h->last_pic_for_ec); - memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr)); + memcpy(h, h1, offsetof(H264Context, mb)); memcpy(&h->cabac, &h1->cabac, sizeof(H264Context) - offsetof(H264Context, cabac)); av_assert0((void*)&h->cabac == &h->mb_padding + 1);