[FFmpeg-cvslog] avformat/mov: Don't use entry[-1] in pointer arithmetic

2024-02-27 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb 26 22:37:04 2024 +0100| [1bb7d5ca9fc6dc1b961014255ada03dee40bac31] | 
committer: Andreas Rheinhardt

avformat/mov: Don't use entry[-1] in pointer arithmetic

It is undefined behaviour.
Fixes many failed tests with UBSan and GCC 13 like
"src/libavformat/mov.c:4229:44: runtime error: store to address
0x5572abe20f80 with insufficient space for an object of type 'struct
MOVIndexRange'"
(The line number does not refer to the line where [-1]
is assigned.)

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/mov.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 71e8f7ae8f..97caaa7723 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4022,7 +4022,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 int num_discarded_begin = 0;
 int first_non_zero_audio_edit = -1;
 int packet_skip_samples = 0;
-MOVIndexRange *current_index_range;
+MOVIndexRange *current_index_range = NULL;
 int found_keyframe_after_edit = 0;
 int found_non_empty_edit = 0;
 
@@ -4038,7 +4038,6 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 return;
 }
 msc->current_index_range = msc->index_ranges;
-current_index_range = msc->index_ranges - 1;
 
 // Clean AVStream from traces of old index
 sti->index_entries = NULL;
@@ -4225,8 +4224,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 }
 
 // Update the index ranges array
-if (current_index_range < msc->index_ranges || index != 
current_index_range->end) {
-current_index_range++;
+if (!current_index_range || index != current_index_range->end) {
+current_index_range = current_index_range ? 
current_index_range + 1
+  : msc->index_ranges;
 current_index_range->start = index;
 }
 current_index_range->end = index + 1;
@@ -4289,7 +4289,8 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 av_freep(_duration_buffer);
 
 // Null terminate the index ranges array
-current_index_range++;
+current_index_range = current_index_range ? current_index_range + 1
+  : msc->index_ranges;
 current_index_range->start = 0;
 current_index_range->end = 0;
 msc->current_index = msc->index_ranges[0].start;

___
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] avutil/mem: limit alignment to maximum simd align

2024-02-27 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Sun Dec  
3 21:01:50 2023 +0100| [7945d30e91b96d2f4f5b612048169087d214d41e] | committer: 
Timo Rothenpieler

avutil/mem: limit alignment to maximum simd align

FFmpeg has instances of DECLARE_ALIGNED(32, ...) in a lot of structs,
which then end up heap-allocated.
By declaring any variable in a struct, or tree of structs, to be 32 byte
aligned, it allows the compiler to safely assume the entire struct
itself is also 32 byte aligned.

This might make the compiler emit code which straight up crashes or
misbehaves in other ways, and at least in one instances is now
documented to actually do (see ticket 10549 on trac).
The issue there is that an unrelated variable in SingleChannelElement is
declared to have an alignment of 32 bytes. So if the compiler does a copy
in decode_cpe() with avx instructions, but ffmpeg is built with
--disable-avx, this results in a crash, since the memory is only 16 byte
aligned.

Mind you, even if the compiler does not emit avx instructions, the code
is still invalid and could misbehave. It just happens not to. Declaring
any variable in a struct with a 32 byte alignment promises 32 byte
alignment of the whole struct to the compiler.

This patch limits the maximum alignment to the maximum possible simd
alignment according to configure.
While not perfect, it at the very least gets rid of a lot of UB, by
matching up the maximum DECLARE_ALIGNED value with the alignment of heap
allocations done by lavu.

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

 libavutil/mem.c  |  2 +-
 libavutil/mem_internal.h | 33 -
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 36b8940a0c..62163b4cb3 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -62,7 +62,7 @@ void  free(void *ptr);
 
 #endif /* MALLOC_PREFIX */
 
-#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16))
+#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 16))
 
 /* NOTE: if you want to override these functions with your own
  * implementations (not recommended) you have to link libav* as
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index 2448c606f1..b1d89a0605 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -76,27 +76,50 @@
  */
 
 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
-#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+#define DECLARE_ALIGNED_T(n,t,v)t __attribute__ ((aligned (n))) v
 #define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
 #define DECLARE_ASM_CONST(n,t,v)const t __attribute__ ((aligned (n))) v
 #elif defined(__DJGPP__)
-#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
16 v
+#define DECLARE_ALIGNED_T(n,t,v)t __attribute__ ((aligned (FFMIN(n, 
16 v
 #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(FFMIN(n, 16 v
 #define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (FFMIN(n, 16 v
 #elif defined(__GNUC__) || defined(__clang__)
-#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+#define DECLARE_ALIGNED_T(n,t,v)t __attribute__ ((aligned (n))) v
 #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(n))) v
 #define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (n))) v
 #elif defined(_MSC_VER)
-#define DECLARE_ALIGNED(n,t,v)  __declspec(align(n)) t v
+#define DECLARE_ALIGNED_T(n,t,v)__declspec(align(n)) t v
 #define DECLARE_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v
 #define DECLARE_ASM_CONST(n,t,v)__declspec(align(n)) static const t v
 #else
-#define DECLARE_ALIGNED(n,t,v)  t v
+#define DECLARE_ALIGNED_T(n,t,v)t v
 #define DECLARE_ASM_ALIGNED(n,t,v)  t v
 #define DECLARE_ASM_CONST(n,t,v)static const t v
 #endif
 
+#if HAVE_SIMD_ALIGN_64
+#define ALIGN_64 64
+#define ALIGN_32 32
+#elif HAVE_SIMD_ALIGN_32
+#define ALIGN_64 32
+#define ALIGN_32 32
+#else
+#define ALIGN_64 16
+#define ALIGN_32 16
+#endif
+
+#define DECLARE_ALIGNED(n,t,v) DECLARE_ALIGNED_V(n,t,v)
+
+// Macro needs to be double-wrapped in order to expand
+// possible other macros being passed for n.
+#define DECLARE_ALIGNED_V(n,t,v) DECLARE_ALIGNED_##n(t,v)
+
+#define DECLARE_ALIGNED_4(t,v)  DECLARE_ALIGNED_T(   4, t, v)
+#define DECLARE_ALIGNED_8(t,v)  DECLARE_ALIGNED_T(   8, t, v)
+#define DECLARE_ALIGNED_16(t,v) DECLARE_ALIGNED_T(  16, t, v)
+#define DECLARE_ALIGNED_32(t,v) DECLARE_ALIGNED_T(ALIGN_32, t, v)
+#define DECLARE_ALIGNED_64(t,v) DECLARE_ALIGNED_T(ALIGN_64, t, v)
+
 // Some broken preprocessors need a second expansion
 // to be forced to tokenize __VA_ARGS__
 #define E1(x) x


[FFmpeg-cvslog] lavc/me_cmp: R-V V nsse

2024-02-27 Thread sunyuechi
ffmpeg | branch: master | sunyuechi  | Tue Feb  6 
22:51:47 2024 +0800| [a7ad76fbbfae29eaf8c9372b34051edf4f835fd9] | committer: 
Rémi Denis-Courmont

lavc/me_cmp: R-V V nsse

C908:
nsse_0_c: 1990.0
nsse_0_rvv_i32: 572.0
nsse_1_c: 910.0
nsse_1_rvv_i32: 456.0

Signed-off-by: Rémi Denis-Courmont 

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

 libavcodec/riscv/me_cmp_init.c |  25 +
 libavcodec/riscv/me_cmp_rvv.S  | 118 +
 2 files changed, 143 insertions(+)

diff --git a/libavcodec/riscv/me_cmp_init.c b/libavcodec/riscv/me_cmp_init.c
index 24e78e3eeb..858e2ccdb8 100644
--- a/libavcodec/riscv/me_cmp_init.c
+++ b/libavcodec/riscv/me_cmp_init.c
@@ -54,6 +54,28 @@ int ff_vsad16_rvv(MpegEncContext *c, const uint8_t *s1, 
const uint8_t *s2, ptrdi
 int ff_vsad8_rvv(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, 
ptrdiff_t stride, int h);
 int ff_vsad_intra16_rvv(MpegEncContext *c, const uint8_t *s, const uint8_t 
*dummy, ptrdiff_t stride, int h);
 int ff_vsad_intra8_rvv(MpegEncContext *c, const uint8_t *s, const uint8_t 
*dummy, ptrdiff_t stride, int h);
+int ff_nsse16_rvv(int multiplier, const uint8_t *s1, const uint8_t *s2,
+ptrdiff_t stride, int h);
+int ff_nsse8_rvv(int multiplier, const uint8_t *s1, const uint8_t *s2,
+ptrdiff_t stride, int h);
+
+static int nsse16_rvv_wrapper(MpegEncContext *c, const uint8_t *s1, const 
uint8_t *s2,
+ptrdiff_t stride, int h)
+{
+if (c)
+return ff_nsse16_rvv(c->avctx->nsse_weight, s1, s2, stride, h);
+else
+return ff_nsse16_rvv(8, s1, s2, stride, h);
+}
+
+static int nsse8_rvv_wrapper(MpegEncContext *c, const uint8_t *s1, const 
uint8_t *s2,
+ptrdiff_t stride, int h)
+{
+if (c)
+return ff_nsse8_rvv(c->avctx->nsse_weight, s1, s2, stride, h);
+else
+return ff_nsse8_rvv(8, s1, s2, stride, h);
+}
 
 av_cold void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx)
 {
@@ -82,6 +104,9 @@ av_cold void ff_me_cmp_init_riscv(MECmpContext *c, 
AVCodecContext *avctx)
 c->vsad[1] = ff_vsad8_rvv;
 c->vsad[4] = ff_vsad_intra16_rvv;
 c->vsad[5] = ff_vsad_intra8_rvv;
+
+c->nsse[0] = nsse16_rvv_wrapper;
+c->nsse[1] = nsse8_rvv_wrapper;
 }
 #endif
 }
diff --git a/libavcodec/riscv/me_cmp_rvv.S b/libavcodec/riscv/me_cmp_rvv.S
index f32ae6b259..c9ae5bb6fc 100644
--- a/libavcodec/riscv/me_cmp_rvv.S
+++ b/libavcodec/riscv/me_cmp_rvv.S
@@ -407,3 +407,121 @@ endfunc
 func ff_vsad_intra8_rvv, zve32x
 vsad_vsse_intra8 abs
 endfunc
+
+func ff_nsse16_rvv, zve32x
+.macro squarediff16
+vsetivlizero, 16, e8, m1, tu, ma
+vle8.v  v4, (a1)
+vle8.v  v12, (a2)
+vwsubu.vv   v16, v4, v12
+vsetvli zero, zero, e16, m2, tu, ma
+vwmacc.vv   v24, v16, v16
+.endm
+
+.macro gradiff16 srcx srcv
+vsetivlizero, 16, e8, m1, tu, ma
+vle8.v  v8, (\srcx)
+vslide1down.vx  v0, \srcv, t5
+vslide1down.vx  v16, v8, t5
+vwsubu.vv   v20, \srcv, v0
+vwsubu.wv   v0, v20, v8
+vwaddu.wv   v20, v0, v16
+vsetivlizero, 15, e16, m2, tu, ma
+vneg.v  v0, v20
+vmax.vv v0, v20, v0
+.endm
+
+csrwi   vxrm, 0
+vsetivlit0, 16, e32, m4, ta, ma
+addia4, a4, -1
+li  t5, 1
+vmv.v.x v24, zero
+vmv.v.x v28, zero
+1:
+add t1, a1, a3
+add t2, a2, a3
+addia4, a4, -1
+squarediff16
+gradiff16   t1, v4
+vwaddu.wv   v28, v28, v0
+gradiff16   t2, v12
+vwsubu.wv   v28, v28, v0
+add a1, a1, a3
+add a2, a2, a3
+bneza4, 1b
+
+squarediff16
+vsetivlizero, 16, e32, m4, tu, ma
+vmv.s.x v0, zero
+vmv.s.x v4, zero
+vredsum.vs  v0, v24, v0
+vredsum.vs  v4, v28, v4
+vmv.x.s t1, v0
+vmv.x.s t2, v4
+srait3, t2, 31
+xor t2, t3, t2
+sub t2, t2, t3
+mul t2, t2, a0
+add a0, t2, t1
+
+ret
+endfunc
+
+func ff_nsse8_rvv, zve32x
+.macro squarediff8
+vsetivlizero, 8, e8, mf2, tu, ma
+vle8.v  v4, (a1)
+vle8.v  v12, (a2)
+vwsubu.vv   v16, v4, v12
+vsetvli zero, zero, e16, m1, tu, ma
+vwmacc.vv   v24, v16, v16
+.endm
+
+.macro gradiff8 srcx srcv
+vsetivlizero, 8, e8, mf2, tu, ma
+vle8.v  v8, (\srcx)
+  

[FFmpeg-cvslog] lavc/dnxhdenc: add ff_dnxhdenc_init

2024-02-27 Thread sunyuechi
ffmpeg | branch: master | sunyuechi  | Wed Dec 20 
16:17:32 2023 +0800| [40911bc1a1975382891181c67417f24b8cdb2c46] | committer: 
Rémi Denis-Courmont

lavc/dnxhdenc: add ff_dnxhdenc_init

This is for clarity and use in testing, consistent with other parts of the code.

Signed-off-by: Rémi Denis-Courmont 

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

 libavcodec/dnxhdenc.c | 11 ---
 libavcodec/dnxhdenc.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index dbe2618244..feb7a76636 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -445,9 +445,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
 ctx->block_width_l2 = 3;
 }
 
-#if ARCH_X86
-ff_dnxhdenc_init_x86(ctx);
-#endif
+ff_dnxhdenc_init(ctx);
 
 ctx->m.mb_height = (avctx->height + 15) / 16;
 ctx->m.mb_width  = (avctx->width  + 15) / 16;
@@ -1377,3 +1375,10 @@ const FFCodec ff_dnxhd_encoder = {
 .p.profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
+
+void ff_dnxhdenc_init(DNXHDEncContext *ctx)
+{
+#if ARCH_X86
+ff_dnxhdenc_init_x86(ctx);
+#endif
+}
diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h
index e581312ce4..95aea83d28 100644
--- a/libavcodec/dnxhdenc.h
+++ b/libavcodec/dnxhdenc.h
@@ -111,6 +111,7 @@ typedef struct DNXHDEncContext {
const uint8_t *pixels, ptrdiff_t line_size);
 } DNXHDEncContext;
 
+void ff_dnxhdenc_init(DNXHDEncContext *ctx);
 void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx);
 
 #endif /* AVCODEC_DNXHDENC_H */

___
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] avcodec/dxvenc: Use proper alignment, write endian-independent output

2024-02-27 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb 27 00:40:32 2024 +0100| [0c204ce9f6b6d1ac3c0ed399bb8b7aa8768d05d9] | 
committer: Andreas Rheinhardt

avcodec/dxvenc: Use proper alignment, write endian-independent output

Fixes the dxv3enc-dxt1 FATE test with UBSan and on big-endian
hardware.

Reviewed-by: James Almer 
Tested-by: Sean McGovern 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dxvenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c
index 1ce2b1d014..91f4ba7619 100644
--- a/libavcodec/dxvenc.c
+++ b/libavcodec/dxvenc.c
@@ -134,7 +134,7 @@ typedef struct DXVEncContext {
 if (bytestream2_get_bytes_left_p(pbc) < 4) {  \
 return AVERROR_INVALIDDATA;   \
 } \
-value = (uint32_t*)pbc->buffer;   \
+value = pbc->buffer;  \
 bytestream2_put_le32(pbc, 0); \
 state = 0;\
 } \
@@ -149,7 +149,7 @@ typedef struct DXVEncContext {
 } else {  \
 op = 0;   \
 } \
-*value |= (op << (state * 2));\
+AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
 state++;  \
 } while (0)
 
@@ -157,7 +157,7 @@ static int dxv_compress_dxt1(AVCodecContext *avctx)
 {
 DXVEncContext *ctx = avctx->priv_data;
 PutByteContext *pbc = >pbc;
-uint32_t *value;
+void *value;
 uint32_t color, lut, idx, color_idx, lut_idx, prev_pos, state = 16, pos = 
2, op = 0;
 
 ht_init(ctx->color_lookback_ht);

___
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] avcodec/libsvtav1: send the EOS signal without a one frame delay to allow for the library to operate in a low-delay mode

2024-02-27 Thread Cosmin Stejerean
ffmpeg | branch: master | Cosmin Stejerean  | Fri Feb 23 
23:21:39 2024 +| [69dd1ce610fcffec453a0663c613c9b13165fd9e] | committer: 
James Almer

avcodec/libsvtav1: send the EOS signal without a one frame delay to allow for 
the library to operate in a low-delay mode

Co-authored-by: Amir Naghdinezhad 
Signed-off-by: Cosmin Stejerean 
Signed-off-by: James Almer 

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

 libavcodec/libsvtav1.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 3b41f5a39e..1eda63200c 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -539,6 +539,14 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 if (svt_ret == EB_NoErrorEmptyQueue)
 return AVERROR(EAGAIN);
 
+#if SVT_AV1_CHECK_VERSION(2, 0, 0)
+if (headerPtr->flags & EB_BUFFERFLAG_EOS) {
+ svt_enc->eos_flag = EOS_RECEIVED;
+ svt_av1_enc_release_out_buffer();
+ return AVERROR_EOF;
+}
+#endif
+
 ref = get_output_ref(avctx, svt_enc, headerPtr->n_filled_len);
 if (!ref) {
 av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
@@ -573,8 +581,10 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 if (headerPtr->pic_type == EB_AV1_NON_REF_PICTURE)
 pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
 
+#if !(SVT_AV1_CHECK_VERSION(2, 0, 0))
 if (headerPtr->flags & EB_BUFFERFLAG_EOS)
 svt_enc->eos_flag = EOS_RECEIVED;
+#endif
 
 ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, 
pict_type);
 

___
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] avcodec/libsvtav1: add version guard for external param

2024-02-27 Thread Gyan Doshi
ffmpeg | branch: release/6.1 | Gyan Doshi  | Wed Nov  8 
10:33:19 2023 +0530| [25abb63bfc4f99d94124ccd7b80f1eec4a7e6f67] | committer: 
James Almer

avcodec/libsvtav1: add version guard for external param

Setting of external param 'force_key_frames' was added in 7bcc1b4eb8.
It is available since v1.1.0 but ffmpeg allows linking against v0.9.0.

(cherry picked from commit 67a2571a5547d39990e7f709f24d7a5b452ff8b9)

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

 libavcodec/libsvtav1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 8d2c7f3be4..862192945b 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -250,6 +250,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 if (avctx->gop_size > 1)
 param->intra_period_length  = avctx->gop_size - 1;
 
+#if SVT_AV1_CHECK_VERSION(1, 1, 0)
 // In order for SVT-AV1 to force keyframes by setting pic_type to
 // EB_AV1_KEY_PICTURE on any frame, force_key_frames has to be set. Note
 // that this does not force all frames to be keyframes (it only forces a
@@ -260,6 +261,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 // to be updated to set force_key_frames accordingly.
 if (avctx->gop_size == 1)
 param->force_key_frames = 1;
+#endif
 
 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
 param->frame_rate_numerator   = avctx->framerate.num;

___
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] avcodec/libsvtav1: send the EOS signal without a one frame delay to allow for the library to operate in a low-delay mode

2024-02-27 Thread Cosmin Stejerean
ffmpeg | branch: release/6.1 | Cosmin Stejerean  | Fri Feb 23 
23:21:39 2024 +| [33efa50fa4508567b1d84d0a84728b400e492a6a] | committer: 
James Almer

avcodec/libsvtav1: send the EOS signal without a one frame delay to allow for 
the library to operate in a low-delay mode

Co-authored-by: Amir Naghdinezhad 
Signed-off-by: Cosmin Stejerean 
Signed-off-by: James Almer 
(cherry picked from commit 69dd1ce610fcffec453a0663c613c9b13165fd9e)

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

 libavcodec/libsvtav1.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 862192945b..66486591f2 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -539,6 +539,14 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 if (svt_ret == EB_NoErrorEmptyQueue)
 return AVERROR(EAGAIN);
 
+#if SVT_AV1_CHECK_VERSION(2, 0, 0)
+if (headerPtr->flags & EB_BUFFERFLAG_EOS) {
+ svt_enc->eos_flag = EOS_RECEIVED;
+ svt_av1_enc_release_out_buffer();
+ return AVERROR_EOF;
+}
+#endif
+
 ref = get_output_ref(avctx, svt_enc, headerPtr->n_filled_len);
 if (!ref) {
 av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
@@ -573,8 +581,10 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 if (headerPtr->pic_type == EB_AV1_NON_REF_PICTURE)
 pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
 
+#if !(SVT_AV1_CHECK_VERSION(2, 0, 0))
 if (headerPtr->flags & EB_BUFFERFLAG_EOS)
 svt_enc->eos_flag = EOS_RECEIVED;
+#endif
 
 ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, 
pict_type);
 

___
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".