[FFmpeg-cvslog] lavc/vp8dsp: add R-V V vp7_idct_dc_add4y

2024-06-04 Thread Rémi Denis-Courmont
ffmpeg | branch: master | Rémi Denis-Courmont  | Sat Jun  1 
21:32:56 2024 +0300| [4e120fbbbd087c3acbad6ce2e8c7b1262a5c8632] | committer: 
Rémi Denis-Courmont

lavc/vp8dsp: add R-V V vp7_idct_dc_add4y

As with idct_dc_add, most of the code is shared with, and replaces, the
previous VP8 function. To improve performance, we break down the 16x4
matrix into 4 rows, rather than 4 squares. Thus strided loads and
stores are avoided, and the 4 DC calculations are vectored.
Unfortunately this requires a vector gather to splat the DC values, but
overall this is still a win for performance:

T-Head C908:
vp7_idct_dc_add4y_c:   7.2
vp7_idct_dc_add4y_rvv_i32: 2.2
vp8_idct_dc_add4y_c:   6.2
vp8_idct_dc_add4y_rvv_i32: 2.2 (before)
vp8_idct_dc_add4y_rvv_i32: 1.7

SpacemiT X60:
vp7_idct_dc_add4y_c:   6.2
vp7_idct_dc_add4y_rvv_i32: 2.0
vp8_idct_dc_add4y_c:   5.5
vp8_idct_dc_add4y_rvv_i32: 2.5 (before)
vp8_idct_dc_add4y_rvv_i32: 1.7

I also tried to provision the DC values using indexed loads. It ends up
slower overall, especially for VP7, as we then have to compute 16 DC's
instead of just 4.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e120fbbbd087c3acbad6ce2e8c7b1262a5c8632
---

 libavcodec/riscv/vp7dsp_init.c |  2 ++
 libavcodec/riscv/vp7dsp_rvv.S  | 16 +++
 libavcodec/riscv/vp8dsp_rvv.S  | 46 +-
 3 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/libavcodec/riscv/vp7dsp_init.c b/libavcodec/riscv/vp7dsp_init.c
index 491874483f..fa5fb9d2ae 100644
--- a/libavcodec/riscv/vp7dsp_init.c
+++ b/libavcodec/riscv/vp7dsp_init.c
@@ -28,6 +28,7 @@
 void ff_vp7_luma_dc_wht_rvv(int16_t block[4][4][16], int16_t dc[16]);
 void ff_vp7_idct_add_rvv(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
 void ff_vp78_idct_dc_add_rvv(uint8_t *, int16_t block[16], ptrdiff_t, int dc);
+void ff_vp7_idct_dc_add4y_rvv(uint8_t *dst, int16_t block[4][16], ptrdiff_t);
 
 static void ff_vp7_idct_dc_add_rvv(uint8_t *dst, int16_t block[16],
ptrdiff_t stride)
@@ -49,6 +50,7 @@ av_cold void ff_vp7dsp_init_riscv(VP8DSPContext *c)
 c->vp8_idct_add = ff_vp7_idct_add_rvv;
 #endif
 c->vp8_idct_dc_add = ff_vp7_idct_dc_add_rvv;
+c->vp8_idct_dc_add4y  = ff_vp7_idct_dc_add4y_rvv;
 }
 #endif
 }
diff --git a/libavcodec/riscv/vp7dsp_rvv.S b/libavcodec/riscv/vp7dsp_rvv.S
index 2a4c404bbb..39b23c2e79 100644
--- a/libavcodec/riscv/vp7dsp_rvv.S
+++ b/libavcodec/riscv/vp7dsp_rvv.S
@@ -127,3 +127,19 @@ func ff_vp7_idct_add_rvv, zve32x
 ret
 endfunc
 #endif
+
+func ff_vp7_idct_dc_add4y_rvv, zve32x
+li   t0, 32
+vsetivli zero, 4, e16, mf2, ta, ma
+li   t1, 23170
+vlse16.v v8, (a1), t0 # block[0..3][0]
+vwmul.vx v0, v8, t1
+li   t2, 0x2
+vsetvli  zero, zero, e32, m1, ta, ma
+vsra.vi  v0, v0, 14
+vmul.vx  v0, v0, t1
+vadd.vx  v0, v0, t2
+vsetvli  zero, zero, e16, mf2, ta, ma
+vnsra.wi v8, v0, 18   # 4x DC
+tail ff_vp78_idct_dc_add4y_rvv
+endfunc
diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S
index 7a3ab576e9..8ea0a0c9bd 100644
--- a/libavcodec/riscv/vp8dsp_rvv.S
+++ b/libavcodec/riscv/vp8dsp_rvv.S
@@ -105,6 +105,7 @@ func ff_vp8_idct_dc_add_rvv, zve32x
 # fall through
 endfunc
 
+# a3 = DC
 func ff_vp78_idct_dc_add_rvv, zve32x
 csrwi  vxrm, 0
 vsetivli   zero, 4, e8, mf4, ta, ma
@@ -121,6 +122,41 @@ func ff_vp78_idct_dc_add_rvv, zve32x
 ret
 endfunc
 
+func ff_vp8_idct_dc_add4y_rvv, zve32x
+li   t0, 32
+vsetivli zero, 4, e16, mf2, ta, ma
+vlse16.v v8, (a1), t0
+vadd.vi  v8, v8, 4
+vsra.vi  v8, v8, 3
+# fall through
+endfunc
+
+.variant_cc ff_vp78_idct_dc_add4y_rvv
+# v8 = [dc0, dc1, dc2, dc3]
+func ff_vp78_idct_dc_add4y_rvv, zve32x
+vsetivlizero, 16, e16, m2, ta, ma
+vid.v   v4
+vsrl.vi v4, v4, 2
+vrgather.vv v0, v8, v4 # replicate each DC four times
+vsetvli zero, zero, e8, m1, ta, ma
+li  a4, 4
+1:
+vle8.v  v8, (a0)
+addia4, a4, -1
+vwaddu.wv   v16, v0, v8
+sh  zero, (a1)
+vsetvli zero, zero, e16, m2, ta, ma
+vmax.vx v16, v16, zero
+addia1, a1, 32
+vsetvli zero, zero, e8, m1, ta, ma
+vnclipu.wi  v8, v16, 0
+vse8.v  v8, (a0)
+add a0, a0, a2
+bneza4, 1b
+
+ret
+endfunc
+
 .macro vp8_idct_dc_add
 vlse32.v  v0, (a0), a2
 lha5, 0(a1)
@@ -143,16 +179,6 @@ endfunc
 addi  a1, a1, 32
 .endm
 
-func ff_vp8_idct_dc_add4y_rvv, zve32x
-vsetivli  zero, 4, e8, mf4, ta, ma
-.rept 3
-vp8_idct_dc_addy
-.endr
-vp8_idct_dc_add
-
-ret
-endfunc
-
 func ff_vp

[FFmpeg-cvslog] lavc/vp8dsp: add R-V V vp7_idct_dc_add

2024-06-04 Thread Rémi Denis-Courmont
ffmpeg | branch: master | Rémi Denis-Courmont  | Sat Jun  1 
18:55:44 2024 +0300| [30797e4ff6c8c537471c386cd019a6a48a721f01] | committer: 
Rémi Denis-Courmont

lavc/vp8dsp: add R-V V vp7_idct_dc_add

This just computes the direct coefficient and hands over to code shared
with VP8. Accordingly the bulk of changes are just rewriting the VP8
code to share.

Nothing to write home about:
vp7_idct_dc_add_c:   1.7
vp7_idct_dc_add_rvv_i32: 1.2

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30797e4ff6c8c537471c386cd019a6a48a721f01
---

 libavcodec/riscv/vp7dsp_init.c | 12 +++-
 libavcodec/riscv/vp8dsp_rvv.S  | 30 +++---
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/libavcodec/riscv/vp7dsp_init.c b/libavcodec/riscv/vp7dsp_init.c
index ae7f2d4277..491874483f 100644
--- a/libavcodec/riscv/vp7dsp_init.c
+++ b/libavcodec/riscv/vp7dsp_init.c
@@ -27,6 +27,15 @@
 
 void ff_vp7_luma_dc_wht_rvv(int16_t block[4][4][16], int16_t dc[16]);
 void ff_vp7_idct_add_rvv(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
+void ff_vp78_idct_dc_add_rvv(uint8_t *, int16_t block[16], ptrdiff_t, int dc);
+
+static void ff_vp7_idct_dc_add_rvv(uint8_t *dst, int16_t block[16],
+   ptrdiff_t stride)
+{
+int dc = (23170 * (23170 * block[0] >> 14) + 0x2) >> 18;
+
+ff_vp78_idct_dc_add_rvv(dst, block, stride, dc);
+}
 
 av_cold void ff_vp7dsp_init_riscv(VP8DSPContext *c)
 {
@@ -37,8 +46,9 @@ av_cold void ff_vp7dsp_init_riscv(VP8DSPContext *c)
 ff_rv_vlen_least(128)) {
 #if __riscv_xlen >= 64
 c->vp8_luma_dc_wht = ff_vp7_luma_dc_wht_rvv;
-#endif
 c->vp8_idct_add = ff_vp7_idct_add_rvv;
+#endif
+c->vp8_idct_dc_add = ff_vp7_idct_dc_add_rvv;
 }
 #endif
 }
diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S
index 3360a38cac..7a3ab576e9 100644
--- a/libavcodec/riscv/vp8dsp_rvv.S
+++ b/libavcodec/riscv/vp8dsp_rvv.S
@@ -98,6 +98,29 @@ func ff_vp8_luma_dc_wht_rvv, zve64x
 endfunc
 #endif
 
+func ff_vp8_idct_dc_add_rvv, zve32x
+lh  a3, (a1)
+addia3, a3, 4
+sraia3, a3, 3
+# fall through
+endfunc
+
+func ff_vp78_idct_dc_add_rvv, zve32x
+csrwi  vxrm, 0
+vsetivli   zero, 4, e8, mf4, ta, ma
+sh zero, (a1)
+vlse32.v   v8, (a0), a2
+vsetivli   zero, 16, e16, m2, ta, ma
+vzext.vf2  v16, v8
+vadd.vxv16, v16, a3
+vmax.vxv16, v16, zero
+vsetvlizero, zero, e8, m1, ta, ma
+vnclipu.wi v8, v16, 0
+vsetivli   zero, 4, e8, mf4, ta, ma
+vsse32.v   v8, (a0), a2
+ret
+endfunc
+
 .macro vp8_idct_dc_add
 vlse32.v  v0, (a0), a2
 lha5, 0(a1)
@@ -120,13 +143,6 @@ endfunc
 addi  a1, a1, 32
 .endm
 
-func ff_vp8_idct_dc_add_rvv, zve32x
-vsetivli  zero, 4, e8, mf4, ta, ma
-vp8_idct_dc_add
-
-ret
-endfunc
-
 func ff_vp8_idct_dc_add4y_rvv, zve32x
 vsetivli  zero, 4, e8, mf4, ta, ma
 .rept 3

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/vvc: Reallocate pixel buffers if pixel shift changes

2024-06-04 Thread Frank Plowman
ffmpeg | branch: master | Frank Plowman  | Mon Jun  3 
14:06:35 2024 +0100| [d866f49791c11f730ce3d277b16524220ca74f6d] | committer: 
Nuo Mi

lavc/vvc: Reallocate pixel buffers if pixel shift changes

Allocations in the following lines depend on the pixel shift, and so
these buffers must be reallocated if the pixel shift changes.  Patch
fixes segmentation faults in fuzzed bitstreams.

Signed-off-by: Frank Plowman 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d866f49791c11f730ce3d277b16524220ca74f6d
---

 libavcodec/vvc/dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index e53ad4e607..f5603306f3 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -214,7 +214,8 @@ static void pixel_buffer_nz_tl_init(TabList *l, 
VVCFrameContext *fc)
 const int c_end  = chroma_idc ? VVC_MAX_SAMPLE_ARRAYS : 1;
 const int changed= fc->tab.sz.chroma_format_idc != chroma_idc ||
 fc->tab.sz.width != width || fc->tab.sz.height != height ||
-fc->tab.sz.ctu_width != ctu_width || fc->tab.sz.ctu_height != 
ctu_height;
+fc->tab.sz.ctu_width != ctu_width || fc->tab.sz.ctu_height != 
ctu_height ||
+fc->tab.sz.pixel_shift != ps;
 
 tl_init(l, 0, changed);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 74b28be web: add a note about xHE-AAC

2024-06-04 Thread ffmpeg-git
The branch, master has been updated
   via  74b28be67529641bb68e9f42700d06b32d0a9904 (commit)
  from  d43df3b378028016ffc4bd13675c4fbdf3014e82 (commit)


- Log -
commit 74b28be67529641bb68e9f42700d06b32d0a9904
Author: Lynne 
AuthorDate: Sat Jun 1 19:13:32 2024 +0200
Commit: Lynne 
CommitDate: Tue Jun 4 12:38:17 2024 +0200

web: add a note about xHE-AAC

diff --git a/src/index b/src/index
index 442db4b..73e9a4c 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,18 @@
 News
   
 
+  June 2rd, 2024, native xHE-AAC decoder
+  
+  FFmpeg now implements a native xHE-AAC decoder. Currently, streams without 
(e)SBR, USAC or MPEG-H Surround
+  are supported, which means the majority of xHE-AAC streams in use should 
work. Support for USAC and (e)SBR is
+  coming soon. Work is also ongoing to improve its stability and compatibility.
+  During the process we found several specification issues, which were then 
submitted back to the authors
+  for discussion and potential inclusion in a future errata.
+  
+  
+  We recommend using Opus.
+  
+
   May 13th, 2024, Sovereign Tech Fund
   
   The FFmpeg community is excited to announce that Germany's

---

Summary of changes:
 src/index | 12 
 1 file changed, 12 insertions(+)


hooks/post-receive
-- 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevcdec: drop unused HEVCContext.width/height

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
17:03:28 2024 +0200| [9576a005271e5a20572b5c581dbf15ad77b373bb] | committer: 
Anton Khirnov

lavc/hevcdec: drop unused HEVCContext.width/height

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9576a005271e5a20572b5c581dbf15ad77b373bb
---

 libavcodec/hevc/hevcdec.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 8208268460..33ad4ac0aa 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -456,9 +456,6 @@ typedef struct HEVCContext {
 uint8_t threads_type;
 uint8_t threads_number;
 
-int width;
-int height;
-
 /** 1 if the independent slice segment header was successfully parsed */
 uint8_t slice_initialized;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevcdec: rename HEVCContext.ref to cur_frame

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:38:27 2024 +0200| [9226514cededdfe0244fbe8fe5c8fcfa3a9c75cb] | committer: 
Anton Khirnov

lavc/hevcdec: rename HEVCContext.ref to cur_frame

Since it stores a pointer to the current frame.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9226514cededdfe0244fbe8fe5c8fcfa3a9c75cb
---

 libavcodec/d3d12va_hevc.c  | 10 +++
 libavcodec/dxva2_hevc.c| 12 
 libavcodec/hevc_filter.c   | 34 ++---
 libavcodec/hevc_mvs.c  | 20 ++---
 libavcodec/hevc_refs.c | 18 +--
 libavcodec/hevcdec.c   | 68 +-
 libavcodec/hevcdec.h   |  2 +-
 libavcodec/hevcpred_template.c |  2 +-
 libavcodec/mips/hevcpred_msa.c | 68 +-
 libavcodec/nvdec_hevc.c|  6 ++--
 libavcodec/vaapi_hevc.c| 18 +--
 libavcodec/vdpau_hevc.c| 10 +++
 libavcodec/videotoolbox.c  |  2 +-
 libavcodec/vulkan_hevc.c   |  6 ++--
 14 files changed, 138 insertions(+), 138 deletions(-)

diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c
index a4964a05c6..323ade7d83 100644
--- a/libavcodec/d3d12va_hevc.c
+++ b/libavcodec/d3d12va_hevc.c
@@ -53,7 +53,7 @@ static int d3d12va_hevc_start_frame(AVCodecContext *avctx, 
av_unused const uint8
 {
 const HEVCContext*h   = avctx->priv_data;
 D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx);
-HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private;
+HEVCDecodePictureContext *ctx_pic = h->cur_frame->hwaccel_picture_private;
 
 if (!ctx)
 return -1;
@@ -76,7 +76,7 @@ static int d3d12va_hevc_start_frame(AVCodecContext *avctx, 
av_unused const uint8
 static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, const uint8_t 
*buffer, uint32_t size)
 {
 const HEVCContext*h   = avctx->priv_data;
-const HEVCFrame  *current_picture = h->ref;
+const HEVCFrame  *current_picture = h->cur_frame;
 HEVCDecodePictureContext *ctx_pic = 
current_picture->hwaccel_picture_private;
 unsigned position;
 
@@ -99,7 +99,7 @@ static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, 
const uint8_t *buffe
 static int update_input_arguments(AVCodecContext *avctx, 
D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer)
 {
 const HEVCContext*h   = avctx->priv_data;
-const HEVCFrame  *current_picture = h->ref;
+const HEVCFrame  *current_picture = h->cur_frame;
 HEVCDecodePictureContext *ctx_pic = 
current_picture->hwaccel_picture_private;
 
 int i;
@@ -149,14 +149,14 @@ static int update_input_arguments(AVCodecContext *avctx, 
D3D12_VIDEO_DECODE_INPU
 static int d3d12va_hevc_end_frame(AVCodecContext *avctx)
 {
 HEVCContext  *h   = avctx->priv_data;
-HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private;
+HEVCDecodePictureContext *ctx_pic = h->cur_frame->hwaccel_picture_private;
 
 int scale = ctx_pic->pp.dwCodingParamToolFlags & 1;
 
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-return ff_d3d12va_common_end_frame(avctx, h->ref->frame, &ctx_pic->pp, 
sizeof(ctx_pic->pp),
+return ff_d3d12va_common_end_frame(avctx, h->cur_frame->frame, 
&ctx_pic->pp, sizeof(ctx_pic->pp),
scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, 
update_input_arguments);
 }
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index b500d7917a..2d6c2f812f 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -61,7 +61,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 DXVA_PicParams_HEVC *pp)
 {
 const HEVCContext *h = avctx->priv_data;
-const HEVCFrame *current_picture = h->ref;
+const HEVCFrame *current_picture = h->cur_frame;
 const HEVCSPS *sps = h->ps.sps;
 const HEVCPPS *pps = h->ps.pps;
 int i, j;
@@ -245,7 +245,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext 
*avctx,
 {
 const HEVCContext *h = avctx->priv_data;
 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-const HEVCFrame *current_picture = h->ref;
+const HEVCFrame *current_picture = h->cur_frame;
 struct hevc_dxva2_picture_context *ctx_pic = 
current_picture->hwaccel_picture_private;
 DXVA_Slice_HEVC_Short *slice = NULL;
 void *dxva_data_ptr;
@@ -364,7 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
 {
 const HEVCContext *h = avctx->priv_data;
 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-struct hevc_dxva2_picture_context *ctx_pic = 
h->ref->hwaccel_picture_private;
+struct hevc_dxva2_picture_context *ctx_pic = 
h->cur_frame->hwaccel_picture_private;
 
 if (!DXVA_CONTEXT_VALID(avctx, ctx))
   

[FFmpeg-cvslog] lavc/hevcdec: drop HEVCContext.HEVClc

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:23:54 2024 +0200| [7ad9400952c0e2827def7a461ff7a8f7b911945b] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCContext.HEVClc

It is merely a pointer to local_ctx[0], which we can just as well use
directly.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7ad9400952c0e2827def7a461ff7a8f7b911945b
---

 libavcodec/hevcdec.c | 24 ++--
 libavcodec/hevcdec.h |  2 --
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0a9443505a..75d0ed613a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1036,14 +1036,14 @@ static int hls_slice_header(HEVCContext *s, 
GetBitContext *gb)
 return AVERROR_INVALIDDATA;
 }
 
-s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
+s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
 if (!s->ps.pps->cu_qp_delta_enabled_flag)
-s->HEVClc->qp_y = s->sh.slice_qp;
+s->local_ctx[0].qp_y = s->sh.slice_qp;
 
 s->slice_initialized = 1;
-s->HEVClc->tu.cu_qp_offset_cb = 0;
-s->HEVClc->tu.cu_qp_offset_cr = 0;
+s->local_ctx[0].tu.cu_qp_offset_cb = 0;
+s->local_ctx[0].tu.cu_qp_offset_cr = 0;
 
 return 0;
 }
@@ -2534,7 +2534,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, 
int x_ctb, int y_ctb,
 
 static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
-HEVCLocalContext *const lc = s->HEVClc;
+HEVCLocalContext *const lc = &s->local_ctx[0];
 const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
 const size_t   slice_size = gb->buffer_end - gb->buffer - 
s->sh.data_offset;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
@@ -2704,7 +2704,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 memcpy(tmp, s->local_ctx, sizeof(*s->local_ctx) * s->nb_local_ctx);
 av_free(s->local_ctx);
 s->local_ctx = tmp;
-s->HEVClc= &s->local_ctx[0];
 
 for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
 tmp = &s->local_ctx[i];
@@ -2757,7 +2756,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 
 for (i = 1; i < s->threads_number; i++) {
 s->local_ctx[i].first_qp_group = 1;
-s->local_ctx[i].qp_y = s->HEVClc->qp_y;
+s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;
 }
 
 atomic_store(&s->wpp_err, 0);
@@ -2868,7 +2867,6 @@ static int set_side_data(HEVCContext *s)
 
 static int hevc_frame_start(HEVCContext *s)
 {
-HEVCLocalContext *lc = s->HEVClc;
 int pic_size_in_ctb  = ((s->ps.sps->width  >> s->ps.sps->log2_min_cb_size) 
+ 1) *
((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) 
+ 1);
 int ret;
@@ -2885,7 +2883,7 @@ static int hevc_frame_start(HEVCContext *s)
 s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == 
HEVC_NAL_CRA_NUT && s->last_eos);
 
 if (s->ps.pps->tiles_enabled_flag)
-lc->end_of_tiles_x = s->ps.pps->column_width[0] << 
s->ps.sps->log2_ctb_size;
+s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << 
s->ps.sps->log2_ctb_size;
 
 ret = ff_hevc_set_new_ref(s, &s->frame, s->poc);
 if (ret < 0)
@@ -3505,11 +3503,9 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 return AVERROR(ENOMEM);
 s->nb_local_ctx = 1;
 
-s->HEVClc = &s->local_ctx[0];
-
-s->HEVClc->parent = s;
-s->HEVClc->logctx = avctx;
-s->HEVClc->common_cabac_state = &s->cabac;
+s->local_ctx[0].parent = s;
+s->local_ctx[0].logctx = avctx;
+s->local_ctx[0].common_cabac_state = &s->cabac;
 
 s->output_frame = av_frame_alloc();
 if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 0ed51a5392..6957cd1091 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -452,8 +452,6 @@ typedef struct HEVCContext {
 HEVCLocalContext *local_ctx;
 unsigned   nb_local_ctx;
 
-HEVCLocalContext*HEVClc;
-
 uint8_t threads_type;
 uint8_t threads_number;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevcdec: drop HEVCContext.frame

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
09:00:19 2024 +0200| [ba56a300a94bdf5520ac1324a8e7fbaeea430904] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCContext.frame

It is merely a redundant pointer to cur_frame->f

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba56a300a94bdf5520ac1324a8e7fbaeea430904
---

 libavcodec/hevc_cabac.c|  4 ++--
 libavcodec/hevc_filter.c   | 39 ++-
 libavcodec/hevc_refs.c |  3 +--
 libavcodec/hevcdec.c   | 53 +-
 libavcodec/hevcdec.h   |  3 +--
 libavcodec/hevcpred_template.c |  4 ++--
 6 files changed, 50 insertions(+), 56 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 71bd678972..c9da4d7fc1 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -1002,10 +1002,10 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
int x0, int y0,
 
 const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
 
-ptrdiff_t stride = s->frame->linesize[c_idx];
+ptrdiff_t stride = s->cur_frame->f->linesize[c_idx];
 int hshift = s->ps.sps->hshift[c_idx];
 int vshift = s->ps.sps->vshift[c_idx];
-uint8_t *dst = &s->frame->data[c_idx][(y0 >> vshift) * stride +
+uint8_t *dst = &s->cur_frame->f->data[c_idx][(y0 >> vshift) * stride +
   ((x0 >> hshift) << 
s->ps.sps->pixel_shift)];
 int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : 
lc->edge_emu_buffer);
 uint8_t significant_coeff_group_flag[8][8] = {{0}};
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index 0ba419a7b8..db7525170d 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -315,13 +315,13 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const 
HEVCContext *s, int x, in
 for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
 int x0   = x >> s->ps.sps->hshift[c_idx];
 int y0   = y >> s->ps.sps->vshift[c_idx];
-ptrdiff_t stride_src = s->frame->linesize[c_idx];
+ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx];
 int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> 
s->ps.sps->hshift[c_idx];
 int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> 
s->ps.sps->vshift[c_idx];
 int width= FFMIN(ctb_size_h, (s->ps.sps->width  >> 
s->ps.sps->hshift[c_idx]) - x0);
 int height   = FFMIN(ctb_size_v, (s->ps.sps->height >> 
s->ps.sps->vshift[c_idx]) - y0);
 int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << 
s->ps.sps->pixel_shift)];
+uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << 
s->ps.sps->pixel_shift)];
 ptrdiff_t stride_dst;
 uint8_t *dst;
 
@@ -484,6 +484,9 @@ static int get_pcm(const HEVCContext *s, int x, int y)
 
 static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 {
+uint8_t **data = s->cur_frame->f->data;
+int  *linesize = s->cur_frame->f->linesize;
+
 uint8_t *src;
 int x, y;
 int chroma, beta;
@@ -537,18 +540,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, 
int x0, int y0)
 
 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + 
(x << s->ps.sps->pixel_shift)];
+src = &data[LUMA][y * linesize[LUMA] + (x << 
s->ps.sps->pixel_shift)];
 if (pcmf) {
 no_p[0] = get_pcm(s, x - 1, y);
 no_p[1] = get_pcm(s, x - 1, y + 4);
 no_q[0] = get_pcm(s, x, y);
 no_q[1] = get_pcm(s, x, y + 4);
-s->hevcdsp.hevc_v_loop_filter_luma_c(src,
- 
s->frame->linesize[LUMA],
+s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA],
  beta, tc, no_p, no_q);
 } else
-s->hevcdsp.hevc_v_loop_filter_luma(src,
-   
s->frame->linesize[LUMA],
+s->hevcdsp.hevc_v_loop_filter_luma(src, linesize[LUMA],
beta, tc, no_p, no_q);
 }
 }
@@ -569,18 +570,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, 
int x0, int y0)
 beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + 
(x << s->ps.sps->pixel_shift)];
+src = &data[LUMA][y * linesize[LUMA] + (x << 
s->ps.sps->pixel_sh

[FFmpeg-cvslog] lavc/hevcdec: rename HEVCFrame.frame to just f

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:38:27 2024 +0200| [db84c1c6eff955150ec2a1a5211c15c9101fcbf1] | committer: 
Anton Khirnov

lavc/hevcdec: rename HEVCFrame.frame to just f

This is shorter, loses no information, and is consistent with other
similar structs.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db84c1c6eff955150ec2a1a5211c15c9101fcbf1
---

 libavcodec/d3d12va_hevc.c |  2 +-
 libavcodec/dxva2_hevc.c   |  8 
 libavcodec/hevc_refs.c| 34 
 libavcodec/hevcdec.c  | 50 +++
 libavcodec/hevcdec.h  |  2 +-
 libavcodec/nvdec_hevc.c   |  6 +++---
 libavcodec/vaapi_hevc.c   | 18 -
 libavcodec/vdpau_hevc.c   | 10 +-
 libavcodec/videotoolbox.c |  2 +-
 libavcodec/vulkan_hevc.c  | 10 +-
 10 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c
index 323ade7d83..3a886f3bc1 100644
--- a/libavcodec/d3d12va_hevc.c
+++ b/libavcodec/d3d12va_hevc.c
@@ -156,7 +156,7 @@ static int d3d12va_hevc_end_frame(AVCodecContext *avctx)
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-return ff_d3d12va_common_end_frame(avctx, h->cur_frame->frame, 
&ctx_pic->pp, sizeof(ctx_pic->pp),
+return ff_d3d12va_common_end_frame(avctx, h->cur_frame->f, &ctx_pic->pp, 
sizeof(ctx_pic->pp),
scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, 
update_input_arguments);
 }
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 2d6c2f812f..08b3b1e785 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -170,7 +170,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 }
 
 if (frame) {
-fill_picture_entry(&pp->RefPicList[i], 
ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0), !!(frame->flags & 
HEVC_FRAME_FLAG_LONG_REF));
+fill_picture_entry(&pp->RefPicList[i], 
ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0), !!(frame->flags & 
HEVC_FRAME_FLAG_LONG_REF));
 pp->PicOrderCntValList[i] = frame->poc;
 } else {
 pp->RefPicList[i].bPicEntry = 0xff;
@@ -178,7 +178,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 }
 }
 
-fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, 
current_picture->frame, 1), 0);
+fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, 
current_picture->f, 1), 0);
 
 #define DO_REF_LIST(ref_idx, ref_list) { \
 const RefPicList *rpl = &h->rps[ref_idx]; \
@@ -187,7 +187,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 while (!frame && j < rpl->nb_refs) \
 frame = rpl->ref[j++]; \
 if (frame && frame->flags & (HEVC_FRAME_FLAG_LONG_REF | 
HEVC_FRAME_FLAG_SHORT_REF)) \
-pp->ref_list[i] = get_refpic_index(pp, 
ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0)); \
+pp->ref_list[i] = get_refpic_index(pp, 
ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0)); \
 else \
 pp->ref_list[i] = 0xff; \
 } \
@@ -415,7 +415,7 @@ static int dxva2_hevc_end_frame(AVCodecContext *avctx)
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->frame,
+ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->f,
 &ctx_pic->pp, sizeof(ctx_pic->pp),
 scale ? &ctx_pic->qm : NULL, scale ? 
sizeof(ctx_pic->qm) : 0,
 commit_bitstream_and_slice_buffer);
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index ca4b2b8bfd..6019818cf0 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -79,7 +79,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 int i, j, ret;
 for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
 HEVCFrame *frame = &s->DPB[i];
-if (frame->frame)
+if (frame->f)
 continue;
 
 ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
@@ -104,10 +104,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 frame->rpl_tab[j] = frame->rpl;
 
 if (s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD)
-frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+frame->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
 if ((s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD) ||
 (s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_BOTTOM_FIELD))
-frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
+frame->f->flags |= AV_FRAME_FLAG_INTERLACED;
 
 ret = ff_hwaccel_frame_pri

[FFmpeg-cvslog] lavc/hevcdec: deduplicate calling hwaccel decode_params()

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
13:44:04 2024 +0200| [a13b892080811345c9b5ae74ed1a9dbbccd5af52] | committer: 
Anton Khirnov

lavc/hevcdec: deduplicate calling hwaccel decode_params()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a13b892080811345c9b5ae74ed1a9dbbccd5af52
---

 libavcodec/hevc/hevcdec.c | 36 
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 4a07fa6612..4e0df4d033 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2985,49 +2985,37 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 s->nal_unit_type = nal->type;
 s->temporal_id   = nal->temporal_id;
 
+if (FF_HW_HAS_CB(s->avctx, decode_params) &&
+(s->nal_unit_type == HEVC_NAL_VPS ||
+ s->nal_unit_type == HEVC_NAL_SPS ||
+ s->nal_unit_type == HEVC_NAL_PPS ||
+ s->nal_unit_type == HEVC_NAL_SEI_PREFIX ||
+ s->nal_unit_type == HEVC_NAL_SEI_SUFFIX)) {
+ret = FF_HW_CALL(s->avctx, decode_params,
+ nal->type, nal->raw_data, nal->raw_size);
+if (ret < 0)
+goto fail;
+}
+
 switch (s->nal_unit_type) {
 case HEVC_NAL_VPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_vps(&gb, s->avctx, &s->ps);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_SPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
  s->apply_defdispwin);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_PPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_pps(&gb, s->avctx, &s->ps);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_SEI_PREFIX:
 case HEVC_NAL_SEI_SUFFIX:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_sei(&gb, s->avctx, &s->sei, &s->ps, 
s->nal_unit_type);
 if (ret < 0)
 goto fail;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevc*: move to hevc/ subdir

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
09:50:48 2024 +0200| [e4601cc3390eec6ccbfc1139bdd102b4e801ae80] | committer: 
Anton Khirnov

lavc/hevc*: move to hevc/ subdir

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4601cc3390eec6ccbfc1139bdd102b4e801ae80
---

 libavcodec/Makefile| 12 ++--
 libavcodec/aarch64/hevcdsp_init_aarch64.c  |  2 +-
 libavcodec/arm/hevcdsp_arm.h   |  2 +-
 libavcodec/arm/hevcdsp_init_arm.c  |  2 +-
 libavcodec/arm/hevcdsp_init_neon.c |  2 +-
 libavcodec/bsf/extract_extradata.c |  3 +-
 libavcodec/bsf/h265_metadata.c |  3 +-
 libavcodec/bsf/hevc_mp4toannexb.c  |  3 +-
 libavcodec/bsf/remove_extradata.c  |  3 +-
 libavcodec/cbs_h2645.c |  2 +-
 libavcodec/cbs_h265.h  |  3 +-
 libavcodec/d3d12va_hevc.c  |  4 +--
 libavcodec/dxva2_hevc.c|  4 +--
 libavcodec/h2645_parse.c   |  3 +-
 libavcodec/hevc/Makefile   | 36 ++
 libavcodec/{hevc_cabac.c => hevc/cabac.c}  |  2 +-
 libavcodec/{hevc_data.c => hevc/data.c}|  2 +-
 libavcodec/{hevc_data.h => hevc/data.h}|  0
 libavcodec/{hevcdsp.c => hevc/dsp.c}   | 10 +++---
 libavcodec/{hevcdsp.h => hevc/dsp.h}   |  8 ++---
 .../{hevcdsp_template.c => hevc/dsp_template.c}|  2 +-
 libavcodec/{hevc_filter.c => hevc/filter.c}|  0
 libavcodec/{ => hevc}/hevc.h   |  6 ++--
 libavcodec/{ => hevc}/hevcdec.c|  2 +-
 libavcodec/{ => hevc}/hevcdec.h| 33 ++--
 libavcodec/{hevc_mvs.c => hevc/mvs.c}  |  0
 libavcodec/{hevc_parse.c => hevc/parse.c}  |  2 +-
 libavcodec/{hevc_parse.h => hevc/parse.h}  |  4 +--
 libavcodec/{hevc_parser.c => hevc/parser.c}|  6 ++--
 libavcodec/{hevcpred.c => hevc/pred.c} | 10 +++---
 libavcodec/{hevcpred.h => hevc/pred.h} |  6 ++--
 .../{hevcpred_template.c => hevc/pred_template.c}  |  2 +-
 libavcodec/{hevc_ps.c => hevc/ps.c}|  4 +--
 libavcodec/{hevc_ps.h => hevc/ps.h}|  7 +++--
 libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c}|  2 +-
 libavcodec/{hevc_refs.c => hevc/refs.c}|  0
 libavcodec/{hevc_sei.c => hevc/sei.c}  |  4 +--
 libavcodec/{hevc_sei.h => hevc/sei.h}  |  7 +++--
 libavcodec/loongarch/hevcdsp_lasx.h|  2 +-
 libavcodec/loongarch/hevcdsp_lsx.h |  2 +-
 libavcodec/mediacodecdec.c |  2 +-
 libavcodec/mips/hevcdsp_mips.h |  2 +-
 libavcodec/mips/hevcdsp_mmi.c  |  2 +-
 libavcodec/mips/hevcpred_mips.h|  2 +-
 libavcodec/mips/hevcpred_msa.c |  2 +-
 libavcodec/nvdec_hevc.c|  4 +--
 libavcodec/nvenc.c |  2 +-
 libavcodec/ppc/hevcdsp.c   |  2 +-
 libavcodec/qsvenc_hevc.c   |  5 +--
 libavcodec/vaapi_encode_h265.c |  3 +-
 libavcodec/vaapi_hevc.c|  3 +-
 libavcodec/vdpau_hevc.c|  4 +--
 libavcodec/videotoolbox.c  |  2 +-
 libavcodec/vulkan_hevc.c   |  6 ++--
 libavcodec/x86/hevcdsp_init.c  |  2 +-
 libavformat/hevc.c |  2 +-
 libavformat/hevcdec.c  |  2 +-
 libavformat/mov.c  |  2 +-
 libavformat/mpegtsenc.c|  2 +-
 tests/checkasm/hevc_add_res.c  |  2 +-
 tests/checkasm/hevc_deblock.c  |  2 +-
 tests/checkasm/hevc_idct.c |  2 +-
 tests/checkasm/hevc_pel.c  |  2 +-
 tests/checkasm/hevc_sao.c  |  2 +-
 64 files changed, 154 insertions(+), 114 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2443d2c6fd..8ab4398b6c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -65,6 +65,7 @@ OBJS = ac3_parser.o   
  \
 
 # subsystems
 include $(SRC_PATH)/libavcodec/aac/Makefile
+include $(SRC_PATH)/libavcodec/hevc/Makefile
 include $(SRC_PATH)/libavcodec/vvc/Makefile
 -include $(SRC_PATH)/libavcodec/$(ARCH)/vvc/Makefile
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
@@ -105,10 +106,6 @@ OBJS-$(CONFIG_H264PARSE)   += h264_parse.o 
h264_ps.o h264data.o \
 OBJS-$(CONFIG_H264PRED)+= h264pred.o
 OBJS-$(CONFIG_H264QPEL)+= h264qpel.o
 OBJS-$(CONFIG_H264_SEI)+= h2

[FFmpeg-cvslog] lavc/hevcdec: drop HEVCLocalContext.gb

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:43:13 2024 +0200| [67ca18dd56956892a097388a160bb70f10539d77] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCLocalContext.gb

In all HEVCLocalContext instances except the first one, the bitreader is
never used for actually reading bits, but merely for passing the buffer
to ff_init_cabac_decoder(), which is better done directly.

The instance that actually is used for bitreading gets moved to stack in
decode_nal_unit(), which makes its lifetime clearer.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67ca18dd56956892a097388a160bb70f10539d77
---

 libavcodec/hevc_cabac.c | 17 +
 libavcodec/hevcdec.c| 43 ---
 libavcodec/hevcdec.h|  4 ++--
 3 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 3f95c9ca05..71bd678972 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -427,14 +427,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
 return skip_bytes(&lc->cc, 0) == NULL ? AVERROR_INVALIDDATA : 0;
 }
 
-static int cabac_init_decoder(HEVCLocalContext *lc)
-{
-GetBitContext *gb = &lc->gb;
-return ff_init_cabac_decoder(&lc->cc,
-  gb->buffer + get_bits_count(gb) / 8,
-  (get_bits_left(gb) + 7) / 8);
-}
-
 static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s)
 {
 int init_type = 2 - s->sh.slice_type;
@@ -459,12 +451,13 @@ static void cabac_init_state(HEVCLocalContext *lc, const 
HEVCContext *s)
 lc->stat_coeff[i] = 0;
 }
 
-int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts)
+int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
+   const uint8_t *data, size_t size)
 {
 const HEVCContext *const s = lc->parent;
 
 if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
-int ret = cabac_init_decoder(lc);
+int ret = ff_init_cabac_decoder(&lc->cc, data, size);
 if (ret < 0)
 return ret;
 if (s->sh.dependent_slice_segment_flag == 0 ||
@@ -488,7 +481,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int 
ctb_addr_ts)
 if (s->threads_number == 1)
 ret = cabac_reinit(lc);
 else {
-ret = cabac_init_decoder(lc);
+ret = ff_init_cabac_decoder(&lc->cc, data, size);
 }
 if (ret < 0)
 return ret;
@@ -501,7 +494,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int 
ctb_addr_ts)
 if (s->threads_number == 1)
 ret = cabac_reinit(lc);
 else {
-ret = cabac_init_decoder(lc);
+ret = ff_init_cabac_decoder(&lc->cc, data, size);
 }
 if (ret < 0)
 return ret;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 42fd33961b..0a9443505a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -593,9 +593,8 @@ fail:
 return ret;
 }
 
-static int hls_slice_header(HEVCContext *s)
+static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 {
-GetBitContext *gb = &s->HEVClc->gb;
 SliceHeader *sh   = &s->sh;
 int i, ret;
 
@@ -2533,9 +2532,11 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, 
int x_ctb, int y_ctb,
 lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0)  && 
(ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && 
(s->ps.pps->tile_id[ctb_addr_ts] == 
s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - 
s->ps.sps->ctb_width]]));
 }
 
-static int hls_decode_entry(HEVCContext *s)
+static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
 HEVCLocalContext *const lc = s->HEVClc;
+const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
+const size_t   slice_size = gb->buffer_end - gb->buffer - 
s->sh.data_offset;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
 int more_data   = 1;
 int x_ctb   = 0;
@@ -2563,7 +2564,7 @@ static int hls_decode_entry(HEVCContext *s)
 y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> 
s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
 hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
 
-ret = ff_hevc_cabac_init(lc, ctb_addr_ts);
+ret = ff_hevc_cabac_init(lc, ctb_addr_ts, slice_data, slice_size);
 if (ret < 0) {
 s->tab_slice_address[ctb_addr_rs] = -1;
 return ret;
@@ -2605,14 +2606,14 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + 
ctb_size - 1) >> s->ps.sps->log2_ctb_size);
 int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
 int thread = ctb_row % s->threads_number;
+
+const uint8_t *data  = s->data + s->sh.offset[ctb_row];
+co

[FFmpeg-cvslog] lavc/hevcdec: include first row in SliceHeader.offset/size

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:40:22 2024 +0200| [ac69e6caf6d9b74a215c7fc170574e7bcc4f9fda] | committer: 
Anton Khirnov

lavc/hevcdec: include first row in SliceHeader.offset/size

Will be useful in the following commit.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ac69e6caf6d9b74a215c7fc170574e7bcc4f9fda
---

 libavcodec/hevcdec.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index d3715f9de7..42fd33961b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -975,8 +975,8 @@ static int hls_slice_header(HEVCContext *s)
 av_freep(&sh->offset);
 av_freep(&sh->size);
 sh->entry_point_offset = 
av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
-sh->offset = av_malloc_array(sh->num_entry_point_offsets, 
sizeof(int));
-sh->size = av_malloc_array(sh->num_entry_point_offsets, 
sizeof(int));
+sh->offset = 
av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
+sh->size   = 
av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
 if (!sh->entry_point_offset || !sh->offset || !sh->size) {
 sh->num_entry_point_offsets = 0;
 av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
@@ -2608,10 +2608,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 int ret;
 
 if(ctb_row) {
-ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row - 1], 
s->sh.size[ctb_row - 1]);
+ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row], 
s->sh.size[ctb_row]);
 if (ret < 0)
 goto error;
-ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], 
s->sh.size[ctb_row - 1]);
+ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[ctb_row], 
s->sh.size[ctb_row]);
 }
 
 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
@@ -2738,8 +2738,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 cmpt++;
 }
 }
-s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;
-s->sh.offset[i - 1] = offset;
+s->sh.size[i]   = s->sh.entry_point_offset[i] - cmpt;
+s->sh.offset[i] = offset;
 
 }
 
@@ -2748,8 +2748,11 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
 return AVERROR_INVALIDDATA;
 }
-s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+s->sh.size  [s->sh.num_entry_point_offsets] = length - offset;
+s->sh.offset[s->sh.num_entry_point_offsets] = offset;
+
+s->sh.offset[0] = s->sh.data_offset;
+s->sh.size[0]   = s->sh.offset[1] - s->sh.offset[0];
 
 s->data = data;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevcdec: drop a useless condition

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:33:54 2024 +0200| [79c0310acaf3b638cea2258b5b18b575668f250c] | committer: 
Anton Khirnov

lavc/hevcdec: drop a useless condition

hls_slice_data_wpp() is only called when num_entry_point_offsets>0

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79c0310acaf3b638cea2258b5b18b575668f250c
---

 libavcodec/hevcdec.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ad2cbd7ece..d3715f9de7 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2742,16 +2742,15 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 s->sh.offset[i - 1] = offset;
 
 }
-if (s->sh.num_entry_point_offsets != 0) {
-offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] 
- cmpt;
-if (length < offset) {
-av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
-return AVERROR_INVALIDDATA;
-}
-s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
 
+offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - 
cmpt;
+if (length < offset) {
+av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
+return AVERROR_INVALIDDATA;
 }
+s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
+s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+
 s->data = data;
 
 for (i = 1; i < s->threads_number; i++) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/hevcdec: move handling of byte alignment at the end of slice header

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
16:59:23 2024 +0200| [74159cbfc30a0202b3c3d6f770143d0e1c30fa5a] | committer: 
Anton Khirnov

lavc/hevcdec: move handling of byte alignment at the end of slice header

Do it in hls_slice_header() rather than cabac_init_decoder() - the
former is a more logical place as according the spec the byte alignment
is a part of the slice header, not slice data. Avoids a second instance
of alignment handling in vaapi_hevc.

Also, check that alignment_bit_equal_to_one is, in fact, equal to one.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=74159cbfc30a0202b3c3d6f770143d0e1c30fa5a
---

 libavcodec/hevc_cabac.c | 2 --
 libavcodec/hevcdec.c| 7 +++
 libavcodec/hevcdec.h| 1 +
 libavcodec/vaapi_hevc.c | 4 +---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 2e639a7e41..3f95c9ca05 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -430,8 +430,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
 static int cabac_init_decoder(HEVCLocalContext *lc)
 {
 GetBitContext *gb = &lc->gb;
-skip_bits(gb, 1);
-align_get_bits(gb);
 return ff_init_cabac_decoder(&lc->cc,
   gb->buffer + get_bits_count(gb) / 8,
   (get_bits_left(gb) + 7) / 8);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ff9a418926..ad2cbd7ece 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1005,6 +1005,13 @@ static int hls_slice_header(HEVCContext *s)
 skip_bits(gb, 8);  // slice_header_extension_data_byte
 }
 
+ret = get_bits1(gb);
+if (!ret) {
+av_log(s->avctx, AV_LOG_ERROR, "alignment_bit_equal_to_one=0\n");
+return AVERROR_INVALIDDATA;
+}
+sh->data_offset = align_get_bits(gb) - gb->buffer;
+
 // Inferred parameters
 sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
 if (sh->slice_qp > 51 ||
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 5aa3d40450..3824bf621b 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -277,6 +277,7 @@ typedef struct SliceHeader {
 int16_t chroma_offset_l1[16][2];
 
 int slice_ctb_addr_rs;
+unsigned data_offset;
 } SliceHeader;
 
 typedef struct CodingUnit {
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 0f5dd50351..f0a0f295d9 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -485,9 +485,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 .slice_data_size   = size,
 .slice_data_offset = 0,
 .slice_data_flag   = VA_SLICE_DATA_FLAG_ALL,
-/* Add 1 to the bits count here to account for the byte_alignment bit, 
which
- * always is at least one bit and not accounted for otherwise. */
-.slice_data_byte_offset= (get_bits_count(&h->HEVClc->gb) + 1 + 
7) / 8,
+.slice_data_byte_offset= sh->data_offset,
 .slice_segment_address = sh->slice_segment_addr,
 .slice_qp_delta= sh->slice_qp_delta,
 .slice_cb_qp_offset= sh->slice_cb_qp_offset,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".