1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/hevcpred: Pass HEVCLocalContext when slice-threading

The HEVC decoder has both HEVCContext and HEVCLocalContext
structures. The latter is supposed to be the structure
containing the per-slicethread state.

Yet that is not how it is handled in practice: Each HEVCLocalContext
has a unique HEVCContext allocated for it and each of these
coincides except in exactly one field: The corresponding
HEVCLocalContext. This makes it possible to pass the HEVCContext
everywhere where logically a HEVCLocalContext should be used.

This commit stops doing this for lavc/hevcpred as well as
the corresponding mips code; the latter is untested.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-06-30 17:57:35 +02:00
parent 13b3e84a4f
commit 6265b155bc
5 changed files with 26 additions and 26 deletions

View File

@ -1109,7 +1109,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
int trafo_size = 1 << log2_trafo_size; int trafo_size = 1 << log2_trafo_size;
ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size); ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size);
s->hpc.intra_pred[log2_trafo_size - 2](s, x0, y0, 0); s->hpc.intra_pred[log2_trafo_size - 2](lc, x0, y0, 0);
} }
if (cbf_luma || cbf_cb[0] || cbf_cr[0] || if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
@ -1195,7 +1195,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.pred_mode == MODE_INTRA) {
ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v); ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 1); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 1);
} }
if (cbf_cb[i]) if (cbf_cb[i])
ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c), ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c),
@ -1225,7 +1225,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.pred_mode == MODE_INTRA) {
ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c),
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 2); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 2);
} }
if (cbf_cr[i]) if (cbf_cr[i])
ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c), ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c),
@ -1254,7 +1254,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.pred_mode == MODE_INTRA) {
ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (i << log2_trafo_size), 1); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 1);
} }
if (cbf_cb[i]) if (cbf_cb[i])
ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size), ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size),
@ -1264,7 +1264,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.pred_mode == MODE_INTRA) {
ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (i << log2_trafo_size), 2); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 2);
} }
if (cbf_cr[i]) if (cbf_cr[i])
ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size), ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size),
@ -1276,26 +1276,26 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0,
int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]);
int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v); ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 1); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 1);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 2); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 2);
if (s->ps.sps->chroma_format_idc == 2) { if (s->ps.sps->chroma_format_idc == 2) {
ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c), ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c),
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (1 << log2_trafo_size_c), 1); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 1);
s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (1 << log2_trafo_size_c), 2); s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 2);
} }
} else if (blk_idx == 3) { } else if (blk_idx == 3) {
int trafo_size_h = 1 << (log2_trafo_size + 1); int trafo_size_h = 1 << (log2_trafo_size + 1);
int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]);
ff_hevc_set_neighbour_available(lc, xBase, yBase, ff_hevc_set_neighbour_available(lc, xBase, yBase,
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 1); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 1);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 2); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 2);
if (s->ps.sps->chroma_format_idc == 2) { if (s->ps.sps->chroma_format_idc == 2) {
ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << (log2_trafo_size)), ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << log2_trafo_size),
trafo_size_h, trafo_size_v); trafo_size_h, trafo_size_v);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (1 << (log2_trafo_size)), 1); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 1);
s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (1 << (log2_trafo_size)), 2); s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 2);
} }
} }
} }

View File

@ -26,10 +26,10 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
struct HEVCContext; struct HEVCLocalContext;
typedef struct HEVCPredContext { typedef struct HEVCPredContext {
void (*intra_pred[4])(struct HEVCContext *s, int x0, int y0, int c_idx); void (*intra_pred[4])(struct HEVCLocalContext *lc, int x0, int y0, int c_idx);
void (*pred_planar[4])(uint8_t *src, const uint8_t *top, void (*pred_planar[4])(uint8_t *src, const uint8_t *top,
const uint8_t *left, ptrdiff_t stride); const uint8_t *left, ptrdiff_t stride);

View File

@ -27,7 +27,7 @@
#define POS(x, y) src[(x) + stride * (y)] #define POS(x, y) src[(x) + stride * (y)]
static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc, int x0, int y0,
int log2_size, int c_idx) int log2_size, int c_idx)
{ {
#define PU(x) \ #define PU(x) \
@ -70,7 +70,7 @@ do { \
else \ else \
a = PIXEL_SPLAT_X4(ptr[i + 3]) a = PIXEL_SPLAT_X4(ptr[i + 3])
HEVCLocalContext *lc = s->HEVClc; const HEVCContext *const s = lc->parent;
int i; int i;
int hshift = s->ps.sps->hshift[c_idx]; int hshift = s->ps.sps->hshift[c_idx];
int vshift = s->ps.sps->vshift[c_idx]; int vshift = s->ps.sps->vshift[c_idx];
@ -346,9 +346,9 @@ do { \
} }
#define INTRA_PRED(size) \ #define INTRA_PRED(size) \
static void FUNC(intra_pred_ ## size)(HEVCContext *s, int x0, int y0, int c_idx) \ static void FUNC(intra_pred_ ## size)(HEVCLocalContext *lc, int x0, int y0, int c_idx) \
{ \ { \
FUNC(intra_pred)(s, x0, y0, size, c_idx); \ FUNC(intra_pred)(lc, x0, y0, size, c_idx); \
} }
INTRA_PRED(2) INTRA_PRED(2)

View File

@ -67,7 +67,7 @@ void ff_pred_intra_pred_angular_3_msa(uint8_t *dst,
const uint8_t *src_left, const uint8_t *src_left,
ptrdiff_t stride, int c_idx, int mode); ptrdiff_t stride, int c_idx, int mode);
void ff_intra_pred_8_16x16_msa(struct HEVCContext *s, int x0, int y0, int c_idx); void ff_intra_pred_8_16x16_msa(struct HEVCLocalContext *s, int x0, int y0, int c_idx);
void ff_intra_pred_8_32x32_msa(struct HEVCContext *s, int x0, int y0, int c_idx); void ff_intra_pred_8_32x32_msa(struct HEVCLocalContext *s, int x0, int y0, int c_idx);
#endif // #ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H #endif // #ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H

View File

@ -1903,10 +1903,10 @@ void ff_pred_intra_pred_angular_3_msa(uint8_t *dst,
} }
} }
void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, int y0, int c_idx) void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
{ {
v16u8 vec0; v16u8 vec0;
HEVCLocalContext *lc = s->HEVClc; const HEVCContext *const s = lc->parent;
int i; int i;
int hshift = s->ps.sps->hshift[c_idx]; int hshift = s->ps.sps->hshift[c_idx];
int vshift = s->ps.sps->vshift[c_idx]; int vshift = s->ps.sps->vshift[c_idx];
@ -2416,14 +2416,14 @@ void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, int y0, int c_idx)
} }
} }
void ff_intra_pred_8_32x32_msa(HEVCContext *s, int x0, int y0, int c_idx) void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
{ {
v16u8 vec0, vec1; v16u8 vec0, vec1;
v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
v8i16 res0, res1, res2, res3; v8i16 res0, res1, res2, res3;
v8i16 mul_val0 = { 63, 62, 61, 60, 59, 58, 57, 56 }; v8i16 mul_val0 = { 63, 62, 61, 60, 59, 58, 57, 56 };
v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 };
HEVCLocalContext *lc = s->HEVClc; const HEVCContext *const s = lc->parent;
int i; int i;
int hshift = s->ps.sps->hshift[c_idx]; int hshift = s->ps.sps->hshift[c_idx];
int vshift = s->ps.sps->vshift[c_idx]; int vshift = s->ps.sps->vshift[c_idx];