[FFmpeg-cvslog] x86: Update x86inc.asm

2024-03-24 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Sat Mar 16 
16:39:37 2024 +0100| [afa471d0efed1df5dca6eeeb2fcdd211ae4cad4e] | committer: 
Henrik Gramner

x86: Update x86inc.asm

Make things up-to-date with upstream.

https://code.videolan.org/videolan/x86inc.asm

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

 configure  |   4 -
 libavcodec/x86/celt_pvq_search.asm |   4 +-
 libavcodec/x86/h264_chromamc.asm   |  10 +-
 libavcodec/x86/h264_idct.asm   |   6 +-
 libavcodec/x86/h264_intrapred.asm  |  15 +-
 libavcodec/x86/hevc_mc.asm |  16 +-
 libavcodec/x86/rv40dsp.asm |  12 +-
 libavcodec/x86/sbrdsp.asm  |   6 +-
 libavcodec/x86/vp8dsp.asm  |  30 +-
 libavcodec/x86/vp9itxfm.asm|   2 +
 libavcodec/x86/vp9itxfm_16bpp.asm  |  12 +-
 libavutil/x86/x86inc.asm   | 672 +
 12 files changed, 519 insertions(+), 270 deletions(-)

diff --git a/configure b/configure
index b9fa8652c4..a6693edfd0 100755
--- a/configure
+++ b/configure
@@ -,7 +,6 @@ ARCH_EXT_LIST_RISCV="
 
 ARCH_EXT_LIST_X86="
 $ARCH_EXT_LIST_X86_SIMD
-cpunop
 i686
 "
 
@@ -2771,7 +2770,6 @@ mipsdsp_deps="mips"
 mipsdspr2_deps="mips"
 msa_deps="mipsfpu"
 
-cpunop_deps="i686"
 x86_64_select="i686"
 x86_64_suggest="fast_cmov"
 
@@ -6401,7 +6399,6 @@ EOF
 done
 disabled x86asm && die "nasm/yasm not found or too old. Use 
--disable-x86asm for a crippled build."
 X86ASMFLAGS="-f $objformat"
-enabled pic   && append X86ASMFLAGS "-DPIC"
 test -n "$extern_prefix"  && append X86ASMFLAGS "-DPREFIX"
 case "$objformat" in
 elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
@@ -6412,7 +6409,6 @@ EOF
 enabled avx2  && check_x86asm avx2_external  "vextracti128 
xmm0, ymm0, 0"
 enabled xop   && check_x86asm xop_external   "vpmacsdd xmm0, 
xmm1, xmm2, xmm3"
 enabled fma4  && check_x86asm fma4_external  "vfmaddps ymm0, 
ymm1, ymm2, ymm3"
-check_x86asm cpunop  "CPU amdnop"
 fi
 
 case "$cpu" in
diff --git a/libavcodec/x86/celt_pvq_search.asm 
b/libavcodec/x86/celt_pvq_search.asm
index 5c1e6d6174..e9bff02650 100644
--- a/libavcodec/x86/celt_pvq_search.asm
+++ b/libavcodec/x86/celt_pvq_search.asm
@@ -74,7 +74,7 @@ SECTION .text
 ; "movaps m0, [r5 + r4]" if PIC is enabled
 ; "movaps m0, [constant_name + r4]" if texrel are used
 %macro SET_PIC_BASE 3; reg, const_label
-%ifdef PIC
+%if PIC
 %{1} %2, [%3]  ; lea r5, [rip+const]
 %define  pic_base_%3 %2
 %else
@@ -195,7 +195,7 @@ align 16
 ; PIC relative addressing. Use this
 ; to count it in cglobal
 ;
-%ifdef PIC
+%if PIC
   %define num_pic_regs 1
 %else
   %define num_pic_regs 0
diff --git a/libavcodec/x86/h264_chromamc.asm b/libavcodec/x86/h264_chromamc.asm
index e70bc492b2..ec6288d48e 100644
--- a/libavcodec/x86/h264_chromamc.asm
+++ b/libavcodec/x86/h264_chromamc.asm
@@ -91,7 +91,7 @@ SECTION .text
 
 %macro chroma_mc8_mmx_func 2-3
 %ifidn %2, rv40
-%ifdef PIC
+%if PIC
 %define rnd_1d_rv40 r8
 %define rnd_2d_rv40 r8
 %define extra_regs 2
@@ -147,7 +147,7 @@ cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
 or   r4d, r5d   ; x + y
 
 %ifidn %2, rv40
-%ifdef PIC
+%if PIC
 lea   r8, [rnd_rv40_1d_tbl]
 %endif
 %if ARCH_X86_64 == 0
@@ -198,7 +198,7 @@ cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
 movd  m4, r4d ; x
 movd  m6, r5d ; y
 %ifidn %2, rv40
-%ifdef PIC
+%if PIC
 lea   r8, [rnd_rv40_2d_tbl]
 %endif
 %if ARCH_X86_64 == 0
@@ -283,7 +283,7 @@ cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
 %macro chroma_mc4_mmx_func 2
 %define extra_regs 0
 %ifidn %2, rv40
-%ifdef PIC
+%if PIC
 %define extra_regs 1
 %endif ; PIC
 %endif ; rv40
@@ -301,7 +301,7 @@ cglobal %1_%2_chroma_mc4, 6, 6 + extra_regs, 0
 psubw m5, m3
 
 %ifidn %2, rv40
-%ifdef PIC
+%if PIC
lear6, [rnd_rv40_2d_tbl]
 %define rnd_2d_rv40 r6
 %else
diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
index 1f86e51d82..b29ddde200 100644
--- a/libavcodec/x86/h264_idct.asm
+++ b/libavcodec/x86/h264_idct.asm
@@ -42,7 +42,7 @@ scan8_mem: db  4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
db  6+11*8, 7+11*8, 6+12*8, 7+12*8
db  4+13*8, 5+13*8, 4+14*8, 5+14*8
db  6+13*8, 7+13*8, 6+14*8, 7+14*8
-%ifdef PIC
+%if PIC
 %define npicregs 1
 %define scan8 picregq
 %else
@@ -322,7 +322,7 @@ INIT_XMM sse2
 cglobal h264_idct8_add4_8, 5, 8 + npicregs, 10, dst1, block_offset, block, 
stride, nnzc, cntr, coeff, dst2, picreg
 movsxdifnidn r3, r3d
 xor  r5, r5
-%ifdef PIC
+%if PIC
 lea picregq, [scan8_mem]
 %endif
 .nextblock:
@@ -398,7 +398,7 @@ h264_idct_add8_mmx_plane:
 cglobal h264_idct_add8_422_8, 5, 8 + npicregs, 0, dst1, block_offset, block, 
stride, nnzc, cntr, coeff,

[FFmpeg-cvslog] x86: Avoid using 'd' as an argument name

2024-03-24 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Sat Mar 16 
15:48:28 2024 +0100| [782c4df28dc91a2b5160fe7a35ad18541e8c5029] | committer: 
Henrik Gramner

x86: Avoid using 'd' as an argument name

x86inc.asm adds defines for {b,w,d,q} which clashes with
the nasm d{b,w,d,q} pseudo-instructions for writing initialized data.

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

 libavcodec/x86/rv34dsp.asm | 18 +-
 libavfilter/x86/vf_overlay.asm | 18 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm
index f29bfd715c..01a3d6f590 100644
--- a/libavcodec/x86/rv34dsp.asm
+++ b/libavcodec/x86/rv34dsp.asm
@@ -113,15 +113,15 @@ cglobal rv34_idct_dc_noround, 1, 2, 0
 movd %1, %2
 %endmacro
 INIT_MMX mmxext
-cglobal rv34_idct_add, 3,3,0, d, s, b
-ROW_TRANSFORM   bq
-COL_TRANSFORM [dq], mm0, [pw_col_coeffs+ 0], [pw_col_coeffs+ 8]
-mova   mm0, [pw_col_coeffs+ 0]
-COL_TRANSFORM  [dq+sq], mm4, mm0, [pw_col_coeffs+ 8]
-mova   mm4, [pw_col_coeffs+ 8]
-lea dq, [dq + 2*sq]
-COL_TRANSFORM [dq], mm6, mm0, mm4
-COL_TRANSFORM  [dq+sq], mm7, mm0, mm4
+cglobal rv34_idct_add, 3, 3, 0, dst, s, b
+ROW_TRANSFORMbq
+COL_TRANSFORM[dstq], mm0, [pw_col_coeffs+ 0], [pw_col_coeffs+ 8]
+movamm0, [pw_col_coeffs+ 0]
+COL_TRANSFORM [dstq+sq], mm4, mm0, [pw_col_coeffs+ 8]
+movamm4, [pw_col_coeffs+ 8]
+leadstq, [dstq + 2*sq]
+COL_TRANSFORM[dstq], mm6, mm0, mm4
+COL_TRANSFORM [dstq+sq], mm7, mm0, mm4
 ret
 
 ; ff_rv34_idct_dc_add_sse4(uint8_t *dst, int stride, int dc);
diff --git a/libavfilter/x86/vf_overlay.asm b/libavfilter/x86/vf_overlay.asm
index 14ec60ca34..8eecbbd2b2 100644
--- a/libavfilter/x86/vf_overlay.asm
+++ b/libavfilter/x86/vf_overlay.asm
@@ -33,7 +33,7 @@ pw_257:   times  8 dw 257
 SECTION .text
 
 INIT_XMM sse4
-cglobal overlay_row_44, 5, 7, 6, 0, d, da, s, a, w, r, x
+cglobal overlay_row_44, 5, 7, 6, 0, dst, da, s, a, w, r, x
 xor  xq, xq
 movsxdifnidn wq, wd
 mov  rq, wq
@@ -47,7 +47,7 @@ cglobal overlay_row_44, 5, 7, 6, 0, d, da, s, a, w, r, x
 .loop:
 pmovzxbwm0, [sq+xq]
 pmovzxbwm2, [aq+xq]
-pmovzxbwm1, [dq+xq]
+pmovzxbwm1, [dstq+xq]
 pmullw  m0, m2
 pxorm2, m3
 pmullw  m1, m2
@@ -55,7 +55,7 @@ cglobal overlay_row_44, 5, 7, 6, 0, d, da, s, a, w, r, x
 paddw   m0, m1
 pmulhuw m0, m5
 packuswbm0, m0
-movq   [dq+xq], m0
+movq [dstq+xq], m0
 add xq, mmsize/2
 cmp xq, wq
 jl .loop
@@ -65,7 +65,7 @@ cglobal overlay_row_44, 5, 7, 6, 0, d, da, s, a, w, r, x
 RET
 
 INIT_XMM sse4
-cglobal overlay_row_22, 5, 7, 6, 0, d, da, s, a, w, r, x
+cglobal overlay_row_22, 5, 7, 6, 0, dst, da, s, a, w, r, x
 xor  xq, xq
 movsxdifnidn wq, wd
 sub  wq, 1
@@ -85,7 +85,7 @@ cglobal overlay_row_22, 5, 7, 6, 0, d, da, s, a, w, r, x
 pavgw   m2, m1
 pavgw   m2, m1
 psrlw   m2, 8
-pmovzxbwm1, [dq+xq]
+pmovzxbwm1, [dstq+xq]
 pmullw  m0, m2
 pxorm2, m3
 pmullw  m1, m2
@@ -93,7 +93,7 @@ cglobal overlay_row_22, 5, 7, 6, 0, d, da, s, a, w, r, x
 paddw   m0, m1
 pmulhuw m0, m5
 packuswbm0, m0
-movq   [dq+xq], m0
+movq [dstq+xq], m0
 add xq, mmsize/2
 cmp xq, wq
 jl .loop
@@ -103,7 +103,7 @@ cglobal overlay_row_22, 5, 7, 6, 0, d, da, s, a, w, r, x
 RET
 
 INIT_XMM sse4
-cglobal overlay_row_20, 6, 7, 7, 0, d, da, s, a, w, r, x
+cglobal overlay_row_20, 6, 7, 7, 0, dst, da, s, a, w, r, x
 mov daq, aq
 add daq, rmp
 xor  xq, xq
@@ -126,7 +126,7 @@ cglobal overlay_row_20, 6, 7, 7, 0, d, da, s, a, w, r, x
 pmaddubsw   m1, m6
 paddw   m2, m1
 psrlw   m2, 2
-pmovzxbwm1, [dq+xq]
+pmovzxbwm1, [dstq+xq]
 pmullw  m0, m2
 pxorm2, m3
 pmullw  m1, m2
@@ -134,7 +134,7 @@ cglobal overlay_row_20, 6, 7, 7, 0, d, da, s, a, w, r, x
 paddw   m0, m1
 pmulhuw m0, m5
 packuswbm0, m0
-movq   [dq+xq], m0
+movq [dstq+xq], m0
 add xq, mmsize/2
 cmp xq, wq
 jl .loop

___
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/film_grain_params: remove do loop in CHECK macro

2024-03-24 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Sat Mar 23 20:10:14 
2024 -0400| [ac21582e5334388bc0ac47c273ac134023c64984] | committer: Leo Izen

avutil/film_grain_params: remove do loop in CHECK macro

The continue statement will break out of the do/while loop, not the
outer loop as intended. This is one (compound) statement anyway, so we
can remove the do/while entirely.

Signed-off-by: Leo Izen 

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

 libavutil/film_grain_params.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavutil/film_grain_params.c b/libavutil/film_grain_params.c
index b3fa37f527..8f8dcee569 100644
--- a/libavutil/film_grain_params.c
+++ b/libavutil/film_grain_params.c
@@ -70,10 +70,8 @@ const AVFilmGrainParams *av_film_grain_params_select(const 
AVFrame *frame)
 continue;
 
 #define CHECK(a, b, unspec) \
-do {\
 if ((a) != (unspec) && (b) != (unspec) && (a) != (b))   \
-continue;   \
-} while (0)
+continue
 
 CHECK(fgp->bit_depth_luma,   bit_depth_luma, 0);
 CHECK(fgp->bit_depth_chroma, bit_depth_chroma,   0);

___
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/film_grain_params: remove unused variables

2024-03-24 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Sat Mar 23 20:10:13 
2024 -0400| [438fcc3f6e0c425691643ca783613ef84e712bbc] | committer: Leo Izen

avutil/film_grain_params: remove unused variables

These variables are never read from, so they trigger -Wunused-variables

Signed-off-by: Leo Izen 

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

 libavutil/film_grain_params.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavutil/film_grain_params.c b/libavutil/film_grain_params.c
index fff7252f2f..b3fa37f527 100644
--- a/libavutil/film_grain_params.c
+++ b/libavutil/film_grain_params.c
@@ -53,8 +53,6 @@ const AVFilmGrainParams *av_film_grain_params_select(const 
AVFrame *frame)
 {
 const AVFilmGrainParams *fgp, *best = NULL;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
-const AVFilmGrainAOMParams *aom;
-const AVFilmGrainH274Params *h274;
 int bit_depth_luma, bit_depth_chroma;
 if (!desc)
 return NULL;
@@ -88,7 +86,6 @@ const AVFilmGrainParams *av_film_grain_params_select(const 
AVFrame *frame)
 case AV_FILM_GRAIN_PARAMS_NONE:
 continue;
 case AV_FILM_GRAIN_PARAMS_AV1:
-aom = &fgp->codec.aom;
 /* AOM FGS needs an exact match for the chroma resolution */
 if (fgp->subsampling_x != desc->log2_chroma_w ||
 fgp->subsampling_y != desc->log2_chroma_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] avformat/demux: Restore pkt->stream_index assert check

2024-03-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Mar 21 13:07:04 2024 +0100| [07064f9bdac3f865e039373544d53cf633aecfa6] | 
committer: Andreas Rheinhardt

avformat/demux: Restore pkt->stream_index assert check

It has been moved after "st  = s->streams[pkt->stream_index]"
in b140b8332c617b0eef4f872f3ef90c469e99920f.
Deduplicate ff_read_packet() and ff_buffer_packet()
while fixing this.
This also fixes shadowing in ff_read_packet().

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/demux.c | 75 ++---
 1 file changed, 31 insertions(+), 44 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 4c50eb5568..4345ed4c8c 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -532,9 +532,6 @@ static void update_timestamps(AVFormatContext *s, AVStream 
*st, AVPacket *pkt)
 {
 FFStream *const sti = ffstream(st);
 
-av_assert0(pkt->stream_index < (unsigned)s->nb_streams &&
-   "Invalid stream index.\n");
-
 if (update_wrap_reference(s, st, pkt->stream_index, pkt) && 
sti->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
 // correct first time stamps to negative values
 if (!is_relative(sti->first_dts))
@@ -555,13 +552,24 @@ static void update_timestamps(AVFormatContext *s, 
AVStream *st, AVPacket *pkt)
 pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, 
st->time_base);
 }
 
-int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
+/**
+ * Handle a new packet and either return it directly if possible and
+ * allow_passthrough is true or queue the packet (or drop the packet
+ * if corrupt).
+ *
+ * @return < 0 on error, 0 if the packet was passed through,
+ * 1 if it was queued or dropped
+ */
+static int handle_new_packet(AVFormatContext *s, AVPacket *pkt, int 
allow_passthrough)
 {
 FFFormatContext *const si = ffformatcontext(s);
-AVStream *st  = s->streams[pkt->stream_index];
-FFStream *sti = ffstream(st);
+AVStream *st;
+FFStream *sti;
 int err;
 
+av_assert0(pkt->stream_index < (unsigned)s->nb_streams &&
+   "Invalid stream index.\n");
+
 if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
 av_log(s, AV_LOG_WARNING,
"Packet corrupt (stream = %d, dts = %s)",
@@ -569,13 +577,19 @@ int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
 if (s->flags & AVFMT_FLAG_DISCARD_CORRUPT) {
 av_log(s, AV_LOG_WARNING, ", dropping it.\n");
 av_packet_unref(pkt);
-return 0;
+return 1;
 }
 av_log(s, AV_LOG_WARNING, ".\n");
 }
 
+st  = s->streams[pkt->stream_index];
+sti = ffstream(st);
+
 update_timestamps(s, st, pkt);
 
+if (sti->request_probe <= 0 && allow_passthrough && 
!si->raw_packet_buffer.head)
+return 0;
+
 err = avpriv_packet_list_put(&si->raw_packet_buffer, pkt, NULL, 0);
 if (err < 0) {
 av_packet_unref(pkt);
@@ -585,14 +599,18 @@ int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
 pkt = &si->raw_packet_buffer.tail->pkt;
 si->raw_packet_buffer_size += pkt->size;
 
-if (sti->request_probe <= 0)
-return 0;
-
 err = probe_codec(s, st, pkt);
 if (err < 0)
 return err;
 
-return 0;
+return 1;
+}
+
+int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
+{
+int err = handle_new_packet(s, pkt, 0);
+
+return err < 0 ? err : 0;
 }
 
 int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -612,9 +630,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 for (;;) {
 PacketListEntry *pktl = si->raw_packet_buffer.head;
-AVStream *st;
-FFStream *sti;
-const AVPacket *pkt1;
 
 if (pktl) {
 AVStream *const st = s->streams[pktl->pkt.stream_index];
@@ -656,36 +671,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return err;
 }
 
-if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
-av_log(s, AV_LOG_WARNING,
-   "Packet corrupt (stream = %d, dts = %s)",
-   pkt->stream_index, av_ts2str(pkt->dts));
-if (s->flags & AVFMT_FLAG_DISCARD_CORRUPT) {
-av_log(s, AV_LOG_WARNING, ", dropping it.\n");
-av_packet_unref(pkt);
-continue;
-}
-av_log(s, AV_LOG_WARNING, ".\n");
-}
-
-st  = s->streams[pkt->stream_index];
-sti = ffstream(st);
-
-update_timestamps(s, st, pkt);
-
-if (!pktl && sti->request_probe <= 0)
-return 0;
-
-err = avpriv_packet_list_put(&si->raw_packet_buffer,
- pkt, NULL, 0);
-if (err < 0) {
-av_packet_unref(pkt);
-return err;
-}
-pkt1 = &si->raw_packet_buffer.tail->pkt;
-si->raw_packet_buffer_size += pkt1->size;
-
-if ((err = probe

[FFmpeg-cvslog] avformat/demux: Combine "Packet corrupt" logmessages

2024-03-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Mar 21 13:32:29 2024 +0100| [ccd2b7f858d2b1d10a49629aa9b24055b7cc5646] | 
committer: Andreas Rheinhardt

avformat/demux: Combine "Packet corrupt" logmessages

Otherwise these statements might be torn apart by
av_logs from other threads.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/demux.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 4345ed4c8c..e50d1a9cfe 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -572,14 +572,13 @@ static int handle_new_packet(AVFormatContext *s, AVPacket 
*pkt, int allow_passth
 
 if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
 av_log(s, AV_LOG_WARNING,
-   "Packet corrupt (stream = %d, dts = %s)",
-   pkt->stream_index, av_ts2str(pkt->dts));
+   "Packet corrupt (stream = %d, dts = %s)%s.\n",
+   pkt->stream_index, av_ts2str(pkt->dts),
+   s->flags & AVFMT_FLAG_DISCARD_CORRUPT ? ", dropping it" : "");
 if (s->flags & AVFMT_FLAG_DISCARD_CORRUPT) {
-av_log(s, AV_LOG_WARNING, ", dropping it.\n");
 av_packet_unref(pkt);
 return 1;
 }
-av_log(s, AV_LOG_WARNING, ".\n");
 }
 
 st  = s->streams[pkt->stream_index];

___
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] configure: Explicitly check for static_assert, _Static_assert

2024-03-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Mar 21 16:27:58 2024 +0100| [0d43adcbef9a061c95db60eb351937c27e2a0609] | 
committer: Andreas Rheinhardt

configure: Explicitly check for static_assert, _Static_assert

C11 provides static assertions via _Static_assert and
provides static_assert as a convenience define for this
in assert.h. Our codebase uses the latter, as _Static_assert
has actually already been deprecated in C23.

Not all toolchains that declare support for C11 actually
support it; e.g. MSVC 19.27 does not support _Static_assert,
but somehow supports static_assert. MSVC 19.27 admits to be
a "preview implementation of the ISO C11 standard",
so this is not surprising (MSVC 19.28 does not come with
this caveat).

Furthermore some FATE boxes [1] use old GCC toolchains (with
only experimental support for C11) where _Static_assert is
supported, but assert.h does not provide the fallback define.
They are broken since the first usage of static_assert.

This commit therefore checks whether static_assert and
_Static_assert work with assert.h included; if not,
configure errors out.

This intentionally drops support for MSVC 19.27. Users like
the old FATE boxes above can still add -Dstatic_assert=_Static_assert
to cflags as a workaround if desired.

[1]: 
https://fate.ffmpeg.org/report.cgi?time=20240321123620&slot=sh4-debian-qemu-gcc-4.7

Signed-off-by: Andreas Rheinhardt 

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

 configure | 13 +
 1 file changed, 13 insertions(+)

diff --git a/configure b/configure
index a6693edfd0..e853deb51d 100755
--- a/configure
+++ b/configure
@@ -5589,6 +5589,19 @@ check_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 
201103L" ||
 check_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" ||
 { check_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" && 
stdc="c11" || die "Compiler lacks C11 support"; }
 
+test_cc <
+#include 
+struct Foo {
+int a;
+void *ptr;
+} obj;
+static_assert(offsetof(struct Foo, a) == 0,
+  "First element of struct does not have offset 0");
+_Static_assert(offsetof(struct Foo, ptr) >= offsetof(struct Foo, a) + 
sizeof(obj.a),
+   "elements not properly ordered in struct");
+EOF
+
 check_cppflags -D_FILE_OFFSET_BITS=64
 check_cppflags -D_LARGEFILE_SOURCE
 

___
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] avformat/mov_chan: respect channel order when parsing and creating chan atom

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sun Mar 17 13:10:58 
2024 +0100| [e6c2c8703732bc46395c65c530038c8146df0deb] | committer: Marton 
Balint

avformat/mov_chan: respect channel order when parsing and creating chan atom

Previously we always assumed that the channels are in native order, even if
they were not. The new channel layout API allows us to signal the proper
channel order, so let's do so.

Fixes ticket #98.

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

 libavformat/mov_chan.c | 464 ++---
 1 file changed, 211 insertions(+), 253 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index ead3a9b91b..d5225acddf 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -25,228 +25,163 @@
 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavcodec/codec_id.h"
 #include "mov_chan.h"
 
-struct MovChannelLayoutMap {
-uint32_t tag;
-uint64_t layout;
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = {
-{ MOV_CH_LAYOUT_USE_DESCRIPTIONS,   0 },
-{ MOV_CH_LAYOUT_USE_BITMAP, 0 },
-{ MOV_CH_LAYOUT_DISCRETEINORDER,0 },
-{ MOV_CH_LAYOUT_UNKNOWN,0 },
-{ MOV_CH_LAYOUT_TMH_10_2_STD,   0 }, // L,   R,  C,Vhc, Lsd, Rsd,
- // Ls,  Rs, Vhl,  Vhr, Lw,  Rw,
- // Csd, Cs, LFE1, LFE2
-{ MOV_CH_LAYOUT_TMH_10_2_FULL,  0 }, // L,   R,  C,Vhc,  Lsd, Rsd,
- // Ls,  Rs, Vhl,  Vhr,  Lw,  Rw,
- // Csd, Cs, LFE1, LFE2, Lc,  Rc,
- // HI,  VI, Haptic
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = {
-{ MOV_CH_LAYOUT_MONO,   AV_CH_LAYOUT_MONO }, // C
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = {
-{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_STEREOHEADPHONES,   AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_BINAURAL,   AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, 
sides
-{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X 
(left), Y (right)
-
-{ MOV_CH_LAYOUT_MATRIXSTEREO,   AV_CH_LAYOUT_STEREO_DOWNMIX }, // Lt, 
Rt
-
-{ MOV_CH_LAYOUT_AC3_1_0_1,  AV_CH_LAYOUT_MONO |// C, 
LFE
-AV_CH_LOW_FREQUENCY },
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = {
-{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C
-{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R
-{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R
-
-{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1  }, // L, R, Cs
-
-{ MOV_CH_LAYOUT_DVD_4,  AV_CH_LAYOUT_2POINT1  }, // L, R, LFE
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = {
-{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z
-
-{ MOV_CH_LAYOUT_QUADRAPHONIC,   AV_CH_LAYOUT_QUAD}, // L, R, Rls, 
Rrs
-
-{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, Cs
-{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, Cs
-{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, Cs
-
-{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, Rs
-
-{ MOV_CH_LAYOUT_DVD_5,  AV_CH_LAYOUT_2_1 |  // L, R, LFE, 
Cs
-AV_CH_LOW_FREQUENCY  },
-{ MOV_CH_LAYOUT_AC3_2_1_1,  AV_CH_LAYOUT_2_1 |  // L, R, Cs, 
LFE
-AV_CH_LOW_FREQUENCY  },
-
-{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, LFE
-{ MOV_CH_LAYOUT_AC3_3_0_1,  AV_CH_LAYOUT_3POINT1 }, // L, C, R, LFE
-{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, LFE
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = {
-{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, R, 
Rls, Rrs, C
-
-{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 },  // L, R, 
C,  Ls, Rs
-{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 },  // L, R, 
Ls, Rs, C
-{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 },  // L, C, 
R,  Ls, Rs
-{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 },  // C, L, 
R,  Ls, Rs
-
-{ MOV_CH_LAYOUT_DVD_6,  AV_CH_LAYOUT_2_2 |   // L, R, 
LFE, L

[FFmpeg-cvslog] avfilter/af_channelmap: fix error message if FL source channel was missing

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Mar 18 21:56:58 
2024 +0100| [9a5627ea9a213c4929020ee8c90bae74788f645c] | committer: Marton 
Balint

avfilter/af_channelmap: fix error message if FL source channel was missing

FL channel ID is 0, so for an unset value we must check for ID < 0.

Regression since 1f96db959c1235bb7079d354e09914a0a2608f62.

Signed-off-by: Marton Balint 

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

 libavfilter/af_channelmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 5e1cf57680..d13dcc317d 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -165,7 +165,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 
 for (i = 0; i < map_entries; i++) {
 int in_ch_idx = -1, out_ch_idx = -1;
-int in_ch = 0, out_ch = 0;
+int in_ch = -1, out_ch = -1;
 static const char err[] = "Failed to parse channel map\n";
 switch (mode) {
 case MAP_ONE_INT:
@@ -349,7 +349,7 @@ static int channelmap_config_input(AVFilterLink *inlink)
 
 if (m->in_channel_idx < 0 || m->in_channel_idx >= nb_channels) {
 av_channel_layout_describe(&inlink->ch_layout, layout_name, 
sizeof(layout_name));
-if (m->in_channel) {
+if (m->in_channel >= 0) {
 av_channel_name(channel_name, sizeof(channel_name), 
m->in_channel);
 av_log(ctx, AV_LOG_ERROR,
"input channel '%s' not available from input layout 
'%s'\n",

___
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] avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel was not specified

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Mar 18 22:08:54 
2024 +0100| [1bea3e9ee2f3521182eea6066fc8e8e1f8910c5b] | committer: Marton 
Balint

avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel 
was not specified

In this case in_channel_idx was never set and the default 0 was used.
Suprisingly no one noticed that the respective fate test output was wrong.

Signed-off-by: Marton Balint 

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

 libavfilter/af_channelmap.c | 2 +-
 tests/fate/filter-audio.mak | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index d13dcc317d..35dc4c4618 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -342,7 +342,7 @@ static int channelmap_config_input(AVFilterLink *inlink)
 for (i = 0; i < s->nch; i++) {
 struct ChannelMap *m = &s->map[i];
 
-if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {
+if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR || 
s->mode == MAP_ONE_STR) {
 m->in_channel_idx = av_channel_layout_index_from_channel(
 &inlink->ch_layout, m->in_channel);
 }
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 8d05e6bd77..3f22db1e05 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -302,7 +302,7 @@ fate-filter-channelmap-one-str: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-2.w
 fate-filter-channelmap-one-str: tests/data/asynth-44100-2.wav
 fate-filter-channelmap-one-str: CMD = md5 -auto_conversion_filters -i $(SRC) 
-/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/channelmap_one_str -f 
wav -fflags +bitexact
 fate-filter-channelmap-one-str: CMP = oneline
-fate-filter-channelmap-one-str: REF = 0ea3052e482c95d5d3bd9da6dac1b5fa
+fate-filter-channelmap-one-str: REF = e18791f65ce5861e130b2c3e472ab90a
 
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, CHANNELMAP ARESAMPLE, WAV, PCM_S16LE, 
PCM_S16LE, WAV) += $(FATE_FILTER_CHANNELMAP)
 

___
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] avfilter/af_channelmap: disallow channel index 64

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Mar 18 23:35:26 
2024 +0100| [2f754a96bd4ae4932923fe03c2d53f8273b6273c] | committer: Marton 
Balint

avfilter/af_channelmap: disallow channel index 64

MAX_CH is 64, therefore the maximum index is 63.

Signed-off-by: Marton Balint 

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

 libavfilter/af_channelmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 35dc4c4618..1ecbddd462 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -84,7 +84,7 @@ static char* split(char *message, char delim) {
 return next;
 }
 
-static int get_channel_idx(char **map, int *ch, char delim, int max_ch)
+static int get_channel_idx(char **map, int *ch, char delim, int 
max_nb_channels)
 {
 char *next;
 int len;
@@ -98,7 +98,7 @@ static int get_channel_idx(char **map, int *ch, char delim, 
int max_ch)
 sscanf(*map, "%d%n", ch, &n);
 if (n != len)
 return AVERROR(EINVAL);
-if (*ch < 0 || *ch > max_ch)
+if (*ch < 0 || *ch >= max_nb_channels)
 return AVERROR(EINVAL);
 *map = next;
 return 0;

___
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] doc/filters: extend af_channelmap documentation

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Tue Mar 19 03:55:12 
2024 +0100| [f1e34f158276d7cec01f12de7d0bbb6b9414e336] | committer: Marton 
Balint

doc/filters: extend af_channelmap documentation

Signed-off-by: Marton Balint 

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

 doc/filters.texi | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 913365671d..18f0d1c5a7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4291,14 +4291,18 @@ It accepts the following parameters:
 @item map
 Map channels from input to output. The argument is a '|'-separated list of
 mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
-@var{in_channel} form. @var{in_channel} can be either the name of the input
-channel (e.g. FL for front left) or its index in the input channel layout.
-@var{out_channel} is the name of the output channel or its index in the output
-channel layout. If @var{out_channel} is not given then it is implicitly an
-index, starting with zero and increasing by one for each mapping.
+@code{@var{in_channel}} form. @var{in_channel} can be either the name of the
+input channel (e.g. FL for front left) or its index in the input channel
+layout. @var{out_channel} is the name of the output channel or its index in the
+output channel layout. If @var{out_channel} is not given then it is implicitly
+an index, starting with zero and increasing by one for each mapping. Mixing
+different types of mappings is not allowed and will result in a parse error.
 
 @item channel_layout
-The channel layout of the output stream.
+The channel layout of the output stream. If not specified, then filter will
+guess it based on the @var{out_channel} names or the number of mappings.
+Guessed layouts will not necessarily contain channels in the order of the
+mappings.
 @end table
 
 If no mapping is present, the filter will implicitly map input channels to

___
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] avfilter/af_channelmap: factorize checking indexes against a channel layout

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Tue Mar 19 01:06:20 
2024 +0100| [bba6dd391f4e9fd8cbe91a202b8f5be04bf9f133] | committer: Marton 
Balint

avfilter/af_channelmap: factorize checking indexes against a channel layout

Signed-off-by: Marton Balint 

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

 libavfilter/af_channelmap.c | 41 +
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 1ecbddd462..62e11103ad 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -116,6 +116,30 @@ static int get_channel(char **map, int *ch, char delim)
 return 0;
 }
 
+static int check_idx_and_id(AVFilterContext *ctx, int channel_idx, int 
channel, AVChannelLayout *ch_layout, const char *io)
+{
+char channel_name[64];
+char layout_name[256];
+int nb_channels = ch_layout->nb_channels;
+
+if (channel_idx < 0 || channel_idx >= nb_channels) {
+av_channel_layout_describe(ch_layout, layout_name, 
sizeof(layout_name));
+if (channel >= 0) {
+av_channel_name(channel_name, sizeof(channel_name), channel);
+av_log(ctx, AV_LOG_ERROR,
+   "%sput channel '%s' not available from %sput layout '%s'\n",
+   io, channel_name, io, layout_name);
+} else {
+av_log(ctx, AV_LOG_ERROR,
+   "%sput channel #%d not available from %sput layout '%s'\n",
+   io, channel_idx, io, layout_name);
+}
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
 static av_cold int channelmap_init(AVFilterContext *ctx)
 {
 ChannelMapContext *s = ctx->priv;
@@ -334,10 +358,7 @@ static int channelmap_config_input(AVFilterLink *inlink)
 {
 AVFilterContext *ctx = inlink->dst;
 ChannelMapContext *s = ctx->priv;
-int nb_channels = inlink->ch_layout.nb_channels;
 int i, err = 0;
-char channel_name[64];
-char layout_name[256];
 
 for (i = 0; i < s->nch; i++) {
 struct ChannelMap *m = &s->map[i];
@@ -347,20 +368,8 @@ static int channelmap_config_input(AVFilterLink *inlink)
 &inlink->ch_layout, m->in_channel);
 }
 
-if (m->in_channel_idx < 0 || m->in_channel_idx >= nb_channels) {
-av_channel_layout_describe(&inlink->ch_layout, layout_name, 
sizeof(layout_name));
-if (m->in_channel >= 0) {
-av_channel_name(channel_name, sizeof(channel_name), 
m->in_channel);
-av_log(ctx, AV_LOG_ERROR,
-   "input channel '%s' not available from input layout 
'%s'\n",
-   channel_name, layout_name);
-} else {
-av_log(ctx, AV_LOG_ERROR,
-   "input channel #%d not available from input layout 
'%s'\n",
-   m->in_channel_idx, layout_name);
-}
+if (check_idx_and_id(ctx, m->in_channel_idx, m->in_channel, 
&inlink->ch_layout, "in") < 0)
 err = AVERROR(EINVAL);
-}
 }
 
 return err;

___
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] avfilter/af_channelmap: add some additional checks for the mappings

2024-03-24 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Mar 18 23:51:50 
2024 +0100| [eaca78eff8323466e1ab463d3d193cb7d60cb9ae] | committer: Marton 
Balint

avfilter/af_channelmap: add some additional checks for the mappings

- Properly initialize all the mappings to -1 by default.
- Make sure every output channel is assigned exactly once
- Autodetect a native layout when only native channels are present
- Always honor the user specified layout, but make sure the mapping is
  compatible with it

The last item is a regression from 4af412be7153405e43930ac73fc7d91d7ded19eb.

Signed-off-by: Marton Balint 

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

 libavfilter/af_channelmap.c | 53 +++--
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 62e11103ad..64efacb576 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -146,7 +146,8 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 char *mapping, separator = '|';
 int map_entries = 0;
 enum MappingMode mode;
-uint64_t out_ch_mask = 0;
+int64_t out_ch_mask = 0;
+uint64_t presence_mask;
 int i;
 
 mapping = s->mapping_str;
@@ -187,6 +188,13 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
+for (i = 0; i < MAX_CH; i++) {
+s->map[i].in_channel_idx  = -1;
+s->map[i].out_channel_idx = -1;
+s->map[i].in_channel  = -1;
+s->map[i].out_channel = -1;
+}
+
 for (i = 0; i < map_entries; i++) {
 int in_ch_idx = -1, out_ch_idx = -1;
 int in_ch = -1, out_ch = -1;
@@ -219,14 +227,16 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 break;
 case MAP_PAIR_INT_STR:
 if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||
-get_channel(&mapping, &out_ch, separator) < 0 ||
-(1ULL << out_ch) & out_ch_mask) {
+get_channel(&mapping, &out_ch, separator) < 0) {
 av_log(ctx, AV_LOG_ERROR, err);
 return AVERROR(EINVAL);
 }
 s->map[i].in_channel_idx  = in_ch_idx;
 s->map[i].out_channel = out_ch;
-out_ch_mask |= 1ULL << out_ch;
+if (out_ch < 63)
+out_ch_mask |= 1ULL << out_ch;
+else
+out_ch_mask = -1;
 break;
 case MAP_PAIR_STR_INT:
 if (get_channel(&mapping, &in_ch, '-') < 0 ||
@@ -239,23 +249,27 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 break;
 case MAP_PAIR_STR_STR:
 if (get_channel(&mapping, &in_ch, '-') < 0 ||
-get_channel(&mapping, &out_ch, separator) < 0 ||
-(1ULL << out_ch) & out_ch_mask) {
+get_channel(&mapping, &out_ch, separator) < 0) {
 av_log(ctx, AV_LOG_ERROR, err);
 return AVERROR(EINVAL);
 }
 s->map[i].in_channel = in_ch;
 s->map[i].out_channel = out_ch;
-out_ch_mask |= 1ULL << out_ch;
+if (out_ch < 63)
+out_ch_mask |= 1ULL << out_ch;
+else
+out_ch_mask = -1;
 break;
 }
 }
 s->mode  = mode;
 s->nch   = map_entries;
-if (out_ch_mask)
-av_channel_layout_from_mask(&s->output_layout, out_ch_mask);
-else if (map_entries && s->output_layout.nb_channels == 0)
-av_channel_layout_default(&s->output_layout, map_entries);
+if (s->output_layout.nb_channels == 0) {
+if (out_ch_mask > 0)
+av_channel_layout_from_mask(&s->output_layout, out_ch_mask);
+else if (map_entries)
+av_channel_layout_default(&s->output_layout, map_entries);
+}
 
 if (mode == MAP_NONE) {
 int i;
@@ -286,6 +300,23 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 }
 }
 
+presence_mask = 0;
+for (i = 0; i < s->nch; i++) {
+uint64_t idx_mask;
+int ret = check_idx_and_id(ctx, s->map[i].out_channel_idx, 
s->map[i].out_channel, &s->output_layout, "out");
+if (ret < 0)
+return ret;
+idx_mask = (1ULL << s->map[i].out_channel_idx);
+if (presence_mask & idx_mask) {
+char layout_name[256];
+av_channel_layout_describe(&s->output_layout, layout_name, 
sizeof(layout_name));
+av_log(ctx, AV_LOG_ERROR, "Mapping %d assigns channel #%d twice in 
output layout '%s'.\n",
+   i + 1, s->map[i].out_channel_idx, layout_name);
+return AVERROR(EINVAL);
+}
+presence_mask |= idx_mask;
+}
+
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
ht