[FFmpeg-cvslog] tests/fate-run: Sanitize test argument

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Feb  7 12:09:04 2024 +0100| [5e2b0862eb1d408625232b37b7a2420403cd498f] | 
committer: Andreas Rheinhardt

tests/fate-run: Sanitize test argument

test -z is a binary operator.

Signed-off-by: Andreas Rheinhardt 

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

 tests/fate-run.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 8efb1586b8..9257fb368b 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -243,7 +243,7 @@ enc_dec(){
 -f $dec_fmt_out -y $tdecfile || return
 do_md5sum $decfile
 tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
-test -z $ffprobe_opts || \
+test -z "$ffprobe_opts" || \
 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || 
return
 }
 
@@ -268,7 +268,7 @@ transcode(){
 echo $(wc -c $encfile)
 ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode 
\
 -f framecrc - || return
-test -z $ffprobe_opts || \
+test -z "$ffprobe_opts" || \
 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || 
return
 }
 
@@ -288,7 +288,7 @@ stream_remux(){
 -f $enc_fmt -y $tencfile || return
 ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
 -f framecrc - || return
-test -z $ffprobe_opts || \
+test -z "$ffprobe_opts" || \
 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || 
return
 }
 

___
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: remove some references to avcodec_close

2024-02-09 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Feb 10 00:04:16 
2024 -0300| [81c2557691b12ceb79b3ba92aa496f2301ab4d18] | committer: James Almer

avcodec: remove some references to avcodec_close

Signed-off-by: James Almer 

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

 libavcodec/hwaccel_internal.h | 2 +-
 libavcodec/pthread_frame.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hwaccel_internal.h b/libavcodec/hwaccel_internal.h
index 057b07323d..b0cc22bb68 100644
--- a/libavcodec/hwaccel_internal.h
+++ b/libavcodec/hwaccel_internal.h
@@ -128,7 +128,7 @@ typedef struct FFHWAccel {
 /**
  * Uninitialize the hwaccel private data.
  *
- * This will be called from get_format() or avcodec_close(), after hwaccel
+ * This will be called from get_format() or ff_codec_close(), after hwaccel
  * and hwaccel_context are already uninitialized.
  */
 int (*uninit)(AVCodecContext *avctx);
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 71e99a5728..2274d3fd7a 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -761,7 +761,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 ff_pthread_free(fctx, thread_ctx_offsets);
 
 /* if we have stashed hwaccel state, move it to the user-facing context,
- * so it will be freed in avcodec_close() */
+ * so it will be freed in ff_codec_close() */
 av_assert0(!avctx->hwaccel);
 FFSWAP(const AVHWAccel*, avctx->hwaccel, 
fctx->stash_hwaccel);
 FFSWAP(void*,avctx->hwaccel_context, 
fctx->stash_hwaccel_context);

___
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: do not assume channels are in native order

2024-02-09 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Jan 29 19:58:18 
2024 +0100| [3d3cad7483785191b99557c78d5a4a551088c549] | committer: Marton 
Balint

avformat/mov_chan: do not assume channels are in native order

Existing code could have caused wrong channel order signalling or reduced
channel count if a channel designation appeared multiple times. This is
actually an old bug, but the conversion to the new channel layout API made it
visible, because now the code overrides the proper channel count with the one
calculated from the mask.

Signed-off-by: Marton Balint 

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

 libavformat/mov_chan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index f3d51899e1..5cb2de3820 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -530,7 +530,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
 size -= 20;
 if (layout_tag == 0) {
 uint64_t mask_incr = mov_get_channel_mask(label);
-if (mask_incr == 0) {
+if (mask_incr == 0 || mask_incr <= label_mask) {
 label_mask = 0;
 break;
 }

___
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: never override number of channels based on chan atom

2024-02-09 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Jan 29 20:15:28 
2024 +0100| [dc9d64f7941f5b071283e16fa56e3af86e5c84d6] | committer: Marton 
Balint

avformat/mov_chan: never override number of channels based on chan atom

The channel designation metadata should not override the number of channels.
Let's warn the user if it is inconsistent, and keep the channel layout
unspecified.

Before the conversion to the channel layout API the code only set the mask, but
never overridden the channel count, so this restores the old behaviour.

Signed-off-by: Marton Balint 

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

 libavformat/mov_chan.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 5cb2de3820..6b206745b4 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -544,8 +544,13 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
 mask = mov_get_channel_layout(layout_tag, bitmap);
 
 if (mask) {
-av_channel_layout_uninit(>codecpar->ch_layout);
-av_channel_layout_from_mask(>codecpar->ch_layout, mask);
+if (!st->codecpar->ch_layout.nb_channels || av_popcount64(mask) == 
st->codecpar->ch_layout.nb_channels) {
+av_channel_layout_uninit(>codecpar->ch_layout);
+av_channel_layout_from_mask(>codecpar->ch_layout, mask);
+} else {
+av_log(s, AV_LOG_WARNING, "ignoring channel layout with %d 
channels because the real number of channels is %d\n",
+   av_popcount64(mask), st->codecpar->ch_layout.nb_channels);
+}
 }
 avio_skip(pb, size - 12);
 

___
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] avfft: avoid overreads with RDFT API users

2024-02-09 Thread Lynne
ffmpeg | branch: release/6.1 | Lynne  | Fri Feb  9 18:17:54 2024 
+0100| [8815d775322570db8ecf82124467a818c681ed90] | committer: Lynne

avfft: avoid overreads with RDFT API users

The new API requires an extra array member at the very end,
which old API users did not do.

This disables in-place RDFT transforms and instead
does the transform out of place by copying once, there shouldn't
be a significant loss of speed as our in-place FFT requires a reorder
which is likely more expensive in the majority of cases to do.

(cherry picked from commit 90adef99cab46ed1791c8096ac2ac0b89f67a266)

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

 libavcodec/avfft.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index 999b5ed79a..627fd7a0be 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -152,7 +152,7 @@ RDFTContext *av_rdft_init(int nbits, enum RDFTransformType 
trans)
 return NULL;
 
 ret = av_tx_init(>ctx, >fn, AV_TX_FLOAT_RDFT, trans == IDFT_C2R,
- 1 << nbits, , AV_TX_INPLACE);
+ 1 << nbits, , 0x0);
 if (ret < 0) {
 av_free(s);
 return NULL;
@@ -162,17 +162,35 @@ RDFTContext *av_rdft_init(int nbits, enum 
RDFTransformType trans)
 s->len = 1 << nbits;
 s->inv = trans == IDFT_C2R;
 
+s->tmp = av_malloc((s->len + 2)*sizeof(float));
+if (!s->tmp) {
+av_tx_uninit(>ctx);
+av_free(s);
+return NULL;
+}
+
 return (RDFTContext *)s;
 }
 
 void av_rdft_calc(RDFTContext *s, FFTSample *data)
 {
 AVTXWrapper *w = (AVTXWrapper *)s;
-if (w->inv)
-FFSWAP(float, data[1], data[w->len]);
-w->fn(w->ctx, data, (void *)data, w->stride);
-if (!w->inv)
-FFSWAP(float, data[1], data[w->len]);
+float *src = w->inv ? w->tmp : (float *)data;
+float *dst = w->inv ? (float *)data : w->tmp;
+
+if (w->inv) {
+memcpy(src, data, w->len*sizeof(float));
+
+src[w->len] = src[1];
+src[1] = 0.0f;
+}
+
+w->fn(w->ctx, dst, (void *)src, w->stride);
+
+if (!w->inv) {
+dst[1] = dst[w->len];
+memcpy(data, dst, w->len*sizeof(float));
+}
 }
 
 av_cold void av_rdft_end(RDFTContext *s)
@@ -180,6 +198,7 @@ av_cold void av_rdft_end(RDFTContext *s)
 if (s) {
 AVTXWrapper *w = (AVTXWrapper *)s;
 av_tx_uninit(>ctx);
+av_free(w->tmp);
 av_free(w);
 }
 }

___
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] avfft: avoid overreads with RDFT API users

2024-02-09 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Feb  9 18:17:54 2024 
+0100| [90adef99cab46ed1791c8096ac2ac0b89f67a266] | committer: Lynne

avfft: avoid overreads with RDFT API users

The new API requires an extra array member at the very end,
which old API users did not do.

This disables in-place RDFT transforms and instead
does the transform out of place by copying once, there shouldn't
be a significant loss of speed as our in-place FFT requires a reorder
which is likely more expensive in the majority of cases to do.

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

 libavcodec/avfft.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index 999b5ed79a..627fd7a0be 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -152,7 +152,7 @@ RDFTContext *av_rdft_init(int nbits, enum RDFTransformType 
trans)
 return NULL;
 
 ret = av_tx_init(>ctx, >fn, AV_TX_FLOAT_RDFT, trans == IDFT_C2R,
- 1 << nbits, , AV_TX_INPLACE);
+ 1 << nbits, , 0x0);
 if (ret < 0) {
 av_free(s);
 return NULL;
@@ -162,17 +162,35 @@ RDFTContext *av_rdft_init(int nbits, enum 
RDFTransformType trans)
 s->len = 1 << nbits;
 s->inv = trans == IDFT_C2R;
 
+s->tmp = av_malloc((s->len + 2)*sizeof(float));
+if (!s->tmp) {
+av_tx_uninit(>ctx);
+av_free(s);
+return NULL;
+}
+
 return (RDFTContext *)s;
 }
 
 void av_rdft_calc(RDFTContext *s, FFTSample *data)
 {
 AVTXWrapper *w = (AVTXWrapper *)s;
-if (w->inv)
-FFSWAP(float, data[1], data[w->len]);
-w->fn(w->ctx, data, (void *)data, w->stride);
-if (!w->inv)
-FFSWAP(float, data[1], data[w->len]);
+float *src = w->inv ? w->tmp : (float *)data;
+float *dst = w->inv ? (float *)data : w->tmp;
+
+if (w->inv) {
+memcpy(src, data, w->len*sizeof(float));
+
+src[w->len] = src[1];
+src[1] = 0.0f;
+}
+
+w->fn(w->ctx, dst, (void *)src, w->stride);
+
+if (!w->inv) {
+dst[1] = dst[w->len];
+memcpy(data, dst, w->len*sizeof(float));
+}
 }
 
 av_cold void av_rdft_end(RDFTContext *s)
@@ -180,6 +198,7 @@ av_cold void av_rdft_end(RDFTContext *s)
 if (s) {
 AVTXWrapper *w = (AVTXWrapper *)s;
 av_tx_uninit(>ctx);
+av_free(w->tmp);
 av_free(w);
 }
 }

___
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/dca_core: Remove unneeded emms.h inclusion

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Feb  9 23:08:33 2024 +0100| [ce7c90ff82afc3c147f7e277e8ddb006640eb98a] | 
committer: Andreas Rheinhardt

avcodec/dca_core: Remove unneeded emms.h inclusion

Possible since 7ec2354c38978b918dc079b611393becb6c80bf7.

Reviewed-by: Martin Storsjö 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/dca_core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 5dd727fc72..697fc74295 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -19,7 +19,6 @@
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/emms.h"
 #include "dcaadpcm.h"
 #include "dcadec.h"
 #include "dcadata.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] x86: Remove inline MMX assembly that clobbers the FPU state

2024-02-09 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Fri Jan 26 
14:55:49 2024 +0200| [7ec2354c38978b918dc079b611393becb6c80bf7] | committer: 
Martin Storsjö

x86: Remove inline MMX assembly that clobbers the FPU state

These inline implementations of AV_COPY64, AV_SWAP64 and AV_ZERO64
are known to clobber the FPU state - which has to be restored
with the 'emms' instruction afterwards.

This was known and signaled with the FF_COPY_SWAP_ZERO_USES_MMX
define, which calling code seems to have been supposed to check,
in order to call emms_c() after using them. See
0b1972d4096df5879038f0af776f87f41e90ebd4,
29c4c0886d143790fcbeddbe40a23dfc6f56345c and
df215e575850e41b19aeb1fd99e53372a6b3d537 for history on earlier
fixes in the same area.

However, new code can use these AV_*64() macros without knowing
about the need to call emms_c().

Just get rid of these dangerous inline assembly snippets; this
doesn't make any difference for 64 bit architectures anyway.

Signed-off-by: Martin Storsjö 

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

 libavcodec/dca_core.c| 16 
 libavutil/x86/intreadwrite.h | 36 
 2 files changed, 52 deletions(-)

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 60508fabb9..5dd727fc72 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -770,10 +770,6 @@ static void erase_adpcm_history(DCACoreDecoder *s)
 for (ch = 0; ch < DCA_CHANNELS; ch++)
 for (band = 0; band < DCA_SUBBANDS; band++)
 AV_ZERO128(s->subband_samples[ch][band] - DCA_ADPCM_COEFFS);
-
-#ifdef FF_COPY_SWAP_ZERO_USES_MMX
-emms_c();
-#endif
 }
 
 static int alloc_sample_buffer(DCACoreDecoder *s)
@@ -837,10 +833,6 @@ static int parse_frame_data(DCACoreDecoder *s, enum 
HeaderType header, int xch_b
 }
 }
 
-#ifdef FF_COPY_SWAP_ZERO_USES_MMX
-emms_c();
-#endif
-
 return 0;
 }
 
@@ -1283,10 +1275,6 @@ static void erase_x96_adpcm_history(DCACoreDecoder *s)
 for (ch = 0; ch < DCA_CHANNELS; ch++)
 for (band = 0; band < DCA_SUBBANDS_X96; band++)
 AV_ZERO128(s->x96_subband_samples[ch][band] - DCA_ADPCM_COEFFS);
-
-#ifdef FF_COPY_SWAP_ZERO_USES_MMX
-emms_c();
-#endif
 }
 
 static int alloc_x96_sample_buffer(DCACoreDecoder *s)
@@ -1516,10 +1504,6 @@ static int parse_x96_frame_data(DCACoreDecoder *s, int 
exss, int xch_base)
 }
 }
 
-#ifdef FF_COPY_SWAP_ZERO_USES_MMX
-emms_c();
-#endif
-
 return 0;
 }
 
diff --git a/libavutil/x86/intreadwrite.h b/libavutil/x86/intreadwrite.h
index 40f375b013..5e57d6a8cd 100644
--- a/libavutil/x86/intreadwrite.h
+++ b/libavutil/x86/intreadwrite.h
@@ -27,42 +27,6 @@
 
 #if HAVE_MMX
 
-#if !HAVE_FAST_64BIT && defined(__MMX__)
-
-#define FF_COPY_SWAP_ZERO_USES_MMX
-
-#define AV_COPY64 AV_COPY64
-static av_always_inline void AV_COPY64(void *d, const void *s)
-{
-__asm__("movq   %1, %%mm0  \n\t"
-"movq   %%mm0, %0  \n\t"
-: "=m"(*(uint64_t*)d)
-: "m" (*(const uint64_t*)s)
-: "mm0");
-}
-
-#define AV_SWAP64 AV_SWAP64
-static av_always_inline void AV_SWAP64(void *a, void *b)
-{
-__asm__("movq   %1, %%mm0  \n\t"
-"movq   %0, %%mm1  \n\t"
-"movq   %%mm0, %0  \n\t"
-"movq   %%mm1, %1  \n\t"
-: "+m"(*(uint64_t*)a), "+m"(*(uint64_t*)b)
-::"mm0", "mm1");
-}
-
-#define AV_ZERO64 AV_ZERO64
-static av_always_inline void AV_ZERO64(void *d)
-{
-__asm__("pxor %%mm0, %%mm0  \n\t"
-"movq %%mm0, %0 \n\t"
-: "=m"(*(uint64_t*)d)
-:: "mm0");
-}
-
-#endif /* !HAVE_FAST_64BIT && defined(__MMX__) */
-
 #ifdef __SSE__
 
 #define AV_COPY128 AV_COPY128

___
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/dxv: align to 4x4 blocks instead of 16x16

2024-02-09 Thread Connor Worley
ffmpeg | branch: master | Connor Worley  | Fri Feb  9 
03:26:50 2024 -0800| [d5aaed9d4c60a1c3508317bf0cbc469eab339932] | committer: 
Martin Storsjö

lavc/dxv: align to 4x4 blocks instead of 16x16

The previous assumption that DXV needs to be aligned to 16x16 was
erroneous. 4x4 works just as well, and FATE decoder tests pass for all
texture formats.

On the encoder side, we should reject input that isn't 4x4 aligned,
like the HAP encoder does, and stop aligning to 16x16. This both solves
the uninitialized reads causing current FATE tests to fail and produces
smaller encoded outputs.

With regard to correctness, I've checked the decoding path by encoding a
real-world sample with git master, and decoding it with
  ffmpeg -i dxt1-master.mov -c:v rawvideo -f framecrc -
The results are exactly the same between master and this patch.

On the encoding side, I've encoded a real-world sample with both master
and this patch, and decoded both versions with
  ffmpeg -i dxt1-{master,patch}.mov -c:v rawvideo -f framecrc -
Under this patch, results for both inputs are exactly the same.

In other words, the extra padding gained by 16x16 alignment over 4x4
alignment has no impact on decoded video.

Signed-off-by: Connor Worley 
Signed-off-by: Martin Storsjö 

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

 libavcodec/dxv.c|  6 +++---
 libavcodec/dxvenc.c | 14 +++---
 tests/ref/fate/dxv3enc-dxt1 |  2 +-
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index e1c7cee3e8..9261a5cac1 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -1238,9 +1238,9 @@ static int dxv_init(AVCodecContext *avctx)
 return ret;
 }
 
-/* Codec requires 16x16 alignment. */
-avctx->coded_width  = FFALIGN(avctx->width,  16);
-avctx->coded_height = FFALIGN(avctx->height, 16);
+/* Since codec is based on 4x4 blocks, size is aligned to 4 */
+avctx->coded_width  = FFALIGN(avctx->width,  TEXTURE_BLOCK_W);
+avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H);
 
 ff_texturedsp_init(>texdsp);
 
diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c
index b274175689..33a18d53d8 100644
--- a/libavcodec/dxvenc.c
+++ b/libavcodec/dxvenc.c
@@ -275,6 +275,14 @@ static av_cold int dxv_init(AVCodecContext *avctx)
 return ret;
 }
 
+if (avctx->width % TEXTURE_BLOCK_W || avctx->height % TEXTURE_BLOCK_H) {
+av_log(avctx,
+   AV_LOG_ERROR,
+   "Video size %dx%d is not multiple of 
"AV_STRINGIFY(TEXTURE_BLOCK_W)"x"AV_STRINGIFY(TEXTURE_BLOCK_H)".\n",
+   avctx->width, avctx->height);
+return AVERROR_INVALIDDATA;
+}
+
 ff_texturedspenc_init();
 
 switch (ctx->tex_fmt) {
@@ -288,10 +296,10 @@ static av_cold int dxv_init(AVCodecContext *avctx)
 return AVERROR_INVALIDDATA;
 }
 ctx->enc.raw_ratio = 16;
-ctx->tex_size = FFALIGN(avctx->width, 16) / TEXTURE_BLOCK_W *
-FFALIGN(avctx->height, 16) / TEXTURE_BLOCK_H *
+ctx->tex_size = avctx->width  / TEXTURE_BLOCK_W *
+avctx->height / TEXTURE_BLOCK_H *
 ctx->enc.tex_ratio;
-ctx->enc.slice_count = av_clip(avctx->thread_count, 1, 
FFALIGN(avctx->height, 16) / TEXTURE_BLOCK_H);
+ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / 
TEXTURE_BLOCK_H);
 
 ctx->tex_data = av_malloc(ctx->tex_size);
 if (!ctx->tex_data) {
diff --git a/tests/ref/fate/dxv3enc-dxt1 b/tests/ref/fate/dxv3enc-dxt1
index 3cfd73397e..74849a8031 100644
--- a/tests/ref/fate/dxv3enc-dxt1
+++ b/tests/ref/fate/dxv3enc-dxt1
@@ -3,4 +3,4 @@
 #codec_id 0: dxv
 #dimensions 0: 1920x1080
 #sar 0: 1/1
-0,  0,  0,1,76767, 0x932ecbfa
+0,  0,  0,1,76521, 0xed387a5e

___
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] fftools/ffplay: constrain supported YUV color spaces

2024-02-09 Thread Niklas Haas
ffmpeg | branch: master | Niklas Haas  | Mon Feb  5 19:28:04 
2024 +0100| [c619d20906d039060efbeaa822daf8e949f3ef24] | committer: Niklas Haas

fftools/ffplay: constrain supported YUV color spaces

SDL supports only these three matrices. Actually, it only supports these
three combinations: BT.601+JPEG, BT.601+MPEG, BT.709+MPEG, but we have
no way to restrict the specific *combination* of YUV range and YUV
colorspace with the current filter design.

See-Also: https://trac.ffmpeg.org/ticket/10839

Instead of an incorrect conversion result, trying to play a YCgCo file
with ffplay will simply error out with a "No conversion possible" error.

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

 fftools/ffplay.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 132f50a5a1..53e6fc0514 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -940,6 +940,13 @@ static int upload_texture(SDL_Texture **tex, AVFrame 
*frame)
 return ret;
 }
 
+static enum AVColorSpace sdl_supported_color_spaces[] = {
+AVCOL_SPC_BT709,
+AVCOL_SPC_BT470BG,
+AVCOL_SPC_SMPTE170M,
+AVCOL_SPC_UNSPECIFIED,
+};
+
 static void set_sdl_yuv_conversion_mode(AVFrame *frame)
 {
 #if SDL_VERSION_ATLEAST(2,0,8)
@@ -1921,6 +1928,8 @@ static int configure_video_filters(AVFilterGraph *graph, 
VideoState *is, const c
 
 if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts,  
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0)
 goto fail;
+if ((ret = av_opt_set_int_list(filt_out, "color_spaces", 
sdl_supported_color_spaces,  AVCOL_SPC_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 
0)
+goto fail;
 
 last_filter = filt_out;
 

___
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/buffersink: add color_spaces, color_ranges params

2024-02-09 Thread Niklas Haas
ffmpeg | branch: master | Niklas Haas  | Mon Feb  5 19:22:04 
2024 +0100| [75f4cb81de6437ee23ae30a201f914b78b618d75] | committer: Niklas Haas

avfilter/buffersink: add color_spaces, color_ranges params

An oversight in my previous series. This omission slipped under the
radar because fftools/ffmpeg_filter.c did not use these options, instead
preferring to insert an explicit format filter.

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

 libavfilter/buffersink.c | 29 ++---
 libavfilter/buffersink.h |  2 ++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 6ba2970dd5..af7f8ab58a 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -48,6 +48,10 @@ typedef struct BufferSinkContext {
 /* only used for video */
 enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats
 int pixel_fmts_size;
+enum AVColorSpace *color_spaces;///< list of accepted color spaces
+int color_spaces_size;
+enum AVColorRange *color_ranges;///< list of accepted color ranges
+int color_ranges_size;
 
 /* only used for audio */
 enum AVSampleFormat *sample_fmts;   ///< list of accepted sample formats
@@ -250,19 +254,36 @@ int av_buffersink_get_ch_layout(const AVFilterContext 
*ctx, AVChannelLayout *out
 static int vsink_query_formats(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
-AVFilterFormats *formats = NULL;
 unsigned i;
 int ret;
 
 CHECK_LIST_SIZE(pixel_fmts)
+CHECK_LIST_SIZE(color_spaces)
+CHECK_LIST_SIZE(color_ranges)
 if (buf->pixel_fmts_size) {
+AVFilterFormats *formats = NULL;
 for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
 if ((ret = ff_add_format(, buf->pixel_fmts[i])) < 0)
 return ret;
 if ((ret = ff_set_common_formats(ctx, formats)) < 0)
 return ret;
-} else {
-if ((ret = ff_default_query_formats(ctx)) < 0)
+}
+
+if (buf->color_spaces_size) {
+AVFilterFormats *formats = NULL;
+for (i = 0; i < NB_ITEMS(buf->color_spaces); i++)
+if ((ret = ff_add_format(, buf->color_spaces[i])) < 0)
+return ret;
+if ((ret = ff_set_common_color_spaces(ctx, formats)) < 0)
+return ret;
+}
+
+if (buf->color_ranges_size) {
+AVFilterFormats *formats = NULL;
+for (i = 0; i < NB_ITEMS(buf->color_ranges); i++)
+if ((ret = ff_add_format(, buf->color_ranges[i])) < 0)
+return ret;
+if ((ret = ff_set_common_color_ranges(ctx, formats)) < 0)
 return ret;
 }
 
@@ -365,6 +386,8 @@ static int asink_query_formats(AVFilterContext *ctx)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption buffersink_options[] = {
 { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), 
AV_OPT_TYPE_BINARY, .flags = FLAGS },
+{ "color_spaces", "set the supported color spaces", OFFSET(color_spaces), 
AV_OPT_TYPE_BINARY, .flags = FLAGS },
+{ "color_ranges", "set the supported color ranges", OFFSET(color_ranges), 
AV_OPT_TYPE_BINARY, .flags = FLAGS },
 { NULL },
 };
 #undef FLAGS
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index a9374b8b4f..5f7172028d 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -55,6 +55,8 @@
  * The format can be constrained by setting options, using av_opt_set() and
  * related functions with the AV_OPT_SEARCH_CHILDREN flag.
  *  - pix_fmts (int list),
+ *  - color_spaces (int list),
+ *  - color_ranges (int list),
  *  - sample_fmts (int list),
  *  - sample_rates (int list),
  *  - ch_layouts (string),

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

2024-02-09 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Fri Feb  
9 20:20:03 2024 +0100| [4618b5ebb95dbef95877ea49c175b1c573ca6b36] | committer: 
Timo Rothenpieler

Revert "avutil/mem: limit alignment to maximum simd align"

Patch was not intended to be part of the set it got pushed with.

This reverts commit 6154137b186734961726ae538ab5cbe287bab163.

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

 libavutil/mem.c  |  8 +---
 libavutil/mem_internal.h | 14 ++
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index b5bcaab164..36b8940a0c 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -62,13 +62,7 @@ void  free(void *ptr);
 
 #endif /* MALLOC_PREFIX */
 
-#if defined(_MSC_VER)
-/* MSVC does not support conditionally limiting alignment.
-   Set minimum value here to maximum used throughout the codebase. */
-#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : 32)
-#else
-#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 16))
-#endif
+#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 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 e2911b5610..2448c606f1 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -75,20 +75,18 @@
  * @param v Name of the variable
  */
 
-#define MAX_ALIGNMENT (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 
16))
-
 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
-#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
MAX_ALIGNMENT v
-#define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
MAX_ALIGNMENT v
-#define DECLARE_ASM_CONST(n,t,v)const t __attribute__ ((aligned 
(FFMIN(n, MAX_ALIGNMENT v
+#define DECLARE_ALIGNED(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_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 (FFMIN(n, 
MAX_ALIGNMENT v
-#define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(FFMIN(n, MAX_ALIGNMENT v
-#define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (FFMIN(n, MAX_ALIGNMENT v
+#define DECLARE_ALIGNED(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_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v

___
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-09 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Sun Dec  
3 21:01:50 2023 +0100| [6154137b186734961726ae538ab5cbe287bab163] | 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=6154137b186734961726ae538ab5cbe287bab163
---

 libavutil/mem.c  |  8 +++-
 libavutil/mem_internal.h | 14 --
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 36b8940a0c..b5bcaab164 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -62,7 +62,13 @@ void  free(void *ptr);
 
 #endif /* MALLOC_PREFIX */
 
-#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16))
+#if defined(_MSC_VER)
+/* MSVC does not support conditionally limiting alignment.
+   Set minimum value here to maximum used throughout the codebase. */
+#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : 32)
+#else
+#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 16))
+#endif
 
 /* 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..e2911b5610 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -75,18 +75,20 @@
  * @param v Name of the variable
  */
 
+#define MAX_ALIGNMENT (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 
16))
+
 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
-#define DECLARE_ALIGNED(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
+#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
MAX_ALIGNMENT v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
MAX_ALIGNMENT v
+#define DECLARE_ASM_CONST(n,t,v)const t __attribute__ ((aligned 
(FFMIN(n, MAX_ALIGNMENT v
 #elif defined(__DJGPP__)
 #define DECLARE_ALIGNED(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_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
+#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
MAX_ALIGNMENT v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(FFMIN(n, MAX_ALIGNMENT v
+#define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (FFMIN(n, MAX_ALIGNMENT v
 #elif defined(_MSC_VER)
 #define DECLARE_ALIGNED(n,t,v)  __declspec(align(n)) t v
 #define DECLARE_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v

___
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/ddagrab: only use acquired texture on valid updates

2024-02-09 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Fri Feb  
9 19:42:53 2024 +0100| [21c6d12449a2230a959da79f224b7443fe89d6d3] | committer: 
Timo Rothenpieler

avfilter/ddagrab: only use acquired texture on valid updates

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

 libavfilter/vsrc_ddagrab.c | 48 ++
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 51e928d785..b62b8a7991 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -82,6 +82,7 @@ typedef struct DdagrabContext {
 int raw_height;
 
 ID3D11Texture2D *probed_texture;
+ID3D11Texture2D *buffer_texture;
 
 ID3D11VertexShader *vertex_shader;
 ID3D11InputLayout *input_layout;
@@ -154,6 +155,7 @@ static av_cold void ddagrab_uninit(AVFilterContext *avctx)
 release_resource(>const_buffer);
 
 release_resource(>probed_texture);
+release_resource(>buffer_texture);
 
 release_resource(>dxgi_outdupl);
 release_resource(>mouse_resource_view);
@@ -707,9 +709,29 @@ static int next_frame_internal(AVFilterContext *avctx, 
ID3D11Texture2D **desktop
 goto error;
 }
 
-if (need_frame && (!frame_info.LastPresentTime.QuadPart || 
!frame_info.AccumulatedFrames)) {
-ret = AVERROR(EAGAIN);
-goto error;
+if (!frame_info.LastPresentTime.QuadPart || !frame_info.AccumulatedFrames) 
{
+if (need_frame) {
+ret = AVERROR(EAGAIN);
+goto error;
+}
+
+// Unforunately, we can't rely on the desktop_resource's format in 
this case.
+// The API might even return it in with a format that was not in the 
initial
+// list of supported formats, and it can change/flicker randomly.
+// To work around this, return an internal copy of the last valid 
texture we got.
+release_resource(_resource);
+
+// The initial probing should make this impossible.
+if (!dda->buffer_texture) {
+av_log(avctx, AV_LOG_ERROR, "No buffer texture while 
operating!\n");
+ret = AVERROR_BUG;
+goto error;
+}
+
+av_log(avctx, AV_LOG_TRACE, "Returning internal buffer for a 
frame!\n");
+ID3D11Texture2D_AddRef(dda->buffer_texture);
+*desktop_texture = dda->buffer_texture;
+return 0;
 }
 
 hr = IDXGIResource_QueryInterface(desktop_resource, _ID3D11Texture2D, 
(void**)desktop_texture);
@@ -720,6 +742,24 @@ static int next_frame_internal(AVFilterContext *avctx, 
ID3D11Texture2D **desktop
 goto error;
 }
 
+if (!dda->buffer_texture) {
+D3D11_TEXTURE2D_DESC desc;
+ID3D11Texture2D_GetDesc(*desktop_texture, );
+desc.Usage = D3D11_USAGE_DEFAULT;
+
+hr = ID3D11Device_CreateTexture2D(dda->device_hwctx->device, , 
NULL, >buffer_texture);
+if (FAILED(hr)) {
+release_resource(desktop_texture);
+av_log(avctx, AV_LOG_ERROR, "Failed creating internal buffer 
texture.\n");
+ret = AVERROR(ENOMEM);
+goto error;
+}
+}
+
+ID3D11DeviceContext_CopyResource(dda->device_hwctx->device_context,
+ (ID3D11Resource*)dda->buffer_texture,
+ (ID3D11Resource*)*desktop_texture);
+
 return 0;
 
 error:
@@ -1108,7 +1148,7 @@ static int ddagrab_request_frame(AVFilterLink *outlink)
 if (desc.Format != dda->raw_format ||
 (int)desc.Width != dda->raw_width ||
 (int)desc.Height != dda->raw_height) {
-av_log(avctx, AV_LOG_ERROR, "Output parameters changed!");
+av_log(avctx, AV_LOG_ERROR, "Output parameters changed!\n");
 ret = AVERROR_OUTPUT_CHANGED;
 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] x86/tx_init: propely indicate the extended available transform sizes

2024-02-09 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Feb  9 15:21:37 2024 
+0100| [9af87828bd787e09724b86d233ead75d6589ae79] | committer: Lynne

x86/tx_init: propely indicate the extended available transform sizes

Forgot to do this with the previous commit.

Actually makes the assembly being used.

Still the fastest FFT in the world, 15% faster than FFTW on the
largest available size.

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

 libavutil/x86/tx_float_init.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c
index d3c0beb50f..84ec1122f6 100644
--- a/libavutil/x86/tx_float_init.c
+++ b/libavutil/x86/tx_float_init.c
@@ -270,15 +270,15 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] 
= {
AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 
AV_CPU_FLAG_AVXSLOW),
 TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE 
| FF_TX_PRESHUFFLE,
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr,FFT, 64, 131072, 2, 0, 256, b8_i2, avx, AVX,  0, 
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 320, b8_i2, avx, AVX,
+TX_DEF(fft_sr,FFT, 64, 2097152, 2, 0, 256, b8_i2, avx, AVX,  0, 
AV_CPU_FLAG_AVXSLOW),
+TX_DEF(fft_sr_asm, FFT, 64, 2097152, 2, 0, 320, b8_i2, avx, AVX,
AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 320, b8_i2, avx, AVX,  
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
+TX_DEF(fft_sr_ns, FFT, 64, 2097152, 2, 0, 320, b8_i2, avx, AVX,  
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr,FFT, 64, 131072, 2, 0, 288, b8_i2, fma3,  FMA3,  0, 
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3,  FMA3,
+TX_DEF(fft_sr,FFT, 64, 2097152, 2, 0, 288, b8_i2, fma3,  FMA3,  0, 
AV_CPU_FLAG_AVXSLOW),
+TX_DEF(fft_sr_asm, FFT, 64, 2097152, 2, 0, 352, b8_i2, fma3,  FMA3,
AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 
AV_CPU_FLAG_AVXSLOW),
-TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3,  FMA3,  
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
+TX_DEF(fft_sr_ns, FFT, 64, 2097152, 2, 0, 352, b8_i2, fma3,  FMA3,  
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
AV_CPU_FLAG_AVXSLOW),
 
 #if HAVE_AVX2_EXTERNAL
@@ -287,11 +287,11 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] 
= {
 TX_DEF(fft15_ns, FFT, 15, 15, 15, 0, 384, factor_init, avx2, AVX2,
AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW),
 
-TX_DEF(fft_sr,FFT, 64, 131072, 2, 0, 320, b8_i2, avx2, AVX2, 0,
+TX_DEF(fft_sr,FFT, 64, 2097152, 2, 0, 320, b8_i2, avx2, AVX2, 0,
AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER),
-TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2,
+TX_DEF(fft_sr_asm, FFT, 64, 2097152, 2, 0, 384, b8_i2, avx2, AVX2,
AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 
AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER),
-TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2, 
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
+TX_DEF(fft_sr_ns, FFT, 64, 2097152, 2, 0, 384, b8_i2, avx2, AVX2, 
AV_TX_INPLACE | FF_TX_PRESHUFFLE,
AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER),
 
 TX_DEF(fft_pfa_15xM, FFT, 60, TX_LEN_UNLIMITED, 15, 2, 320, fft_pfa_init, 
avx2, AVX2,

___
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/refstruct: do not use max_align_t on MSVC

2024-02-09 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon Feb  5 19:48:26 
2024 +0100| [7c873fb2985f94da61eb7b41c90176fa471e6163] | committer: Anton 
Khirnov

lavc/refstruct: do not use max_align_t on MSVC

It is not available there, even when C11/17 is requested.

Signed-off-by: Anton Khirnov 

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

 libavcodec/refstruct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/refstruct.c b/libavcodec/refstruct.c
index 7597f6d0ee..81e8c9795c 100644
--- a/libavcodec/refstruct.c
+++ b/libavcodec/refstruct.c
@@ -45,7 +45,7 @@
 #define REFSTRUCT_COOKIE AV_NE((uint64_t)MKBETAG('R', 'e', 'f', 'S') << 32 | 
MKBETAG('t', 'r', 'u', 'c'), \
MKTAG('R', 'e', 'f', 'S') | 
(uint64_t)MKTAG('t', 'r', 'u', 'c') << 32)
 
-#if __STDC_VERSION__ >= 201112L
+#if __STDC_VERSION__ >= 201112L && !defined(_MSC_VER)
 #define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX3(STRIDE_ALIGN, 16, 
_Alignof(max_align_t)))
 #else
 #define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX(STRIDE_ALIGN, 16))

___
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: deprecate avcodec_close()

2024-02-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Feb  1 
09:19:46 2024 +0100| [1cc24d749569a42510399a29b034f7a77bdec34e] | committer: 
Anton Khirnov

lavc: deprecate avcodec_close()

Its use has been discouraged since 2016, but now is no longer used in
avformat, so there is no reason to keep it public.

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

 libavcodec/avcodec.c  | 12 +---
 libavcodec/avcodec.h  |  5 -
 libavcodec/avcodec_internal.h |  2 ++
 libavcodec/frame_thread_encoder.c |  5 +++--
 libavcodec/options.c  |  3 ++-
 libavcodec/version_major.h|  1 +
 6 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index a6c8629f6c..b6d27ada21 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -377,7 +377,7 @@ end:
 
 return ret;
 free_and_end:
-avcodec_close(avctx);
+ff_codec_close(avctx);
 goto end;
 }
 
@@ -432,12 +432,12 @@ void avsubtitle_free(AVSubtitle *sub)
 memset(sub, 0, sizeof(*sub));
 }
 
-av_cold int avcodec_close(AVCodecContext *avctx)
+av_cold void ff_codec_close(AVCodecContext *avctx)
 {
 int i;
 
 if (!avctx)
-return 0;
+return;
 
 if (avcodec_is_open(avctx)) {
 AVCodecInternal *avci = avctx->internal;
@@ -497,9 +497,15 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 
 avctx->codec = NULL;
 avctx->active_thread_type = 0;
+}
 
+#if FF_API_AVCODEC_CLOSE
+int avcodec_close(AVCodecContext *avctx)
+{
+ff_codec_close(avctx);
 return 0;
 }
+#endif
 
 static const char *unknown_if_null(const char *str)
 {
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7fb44e28f4..0018ccbb0c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2411,6 +2411,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
  */
 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary 
**options);
 
+#if FF_API_AVCODEC_CLOSE
 /**
  * Close a given AVCodecContext and free all the data associated with it
  * (but not the AVCodecContext itself).
@@ -2419,12 +2420,14 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec 
*codec, AVDictionary **op
  * the codec-specific data allocated in avcodec_alloc_context3() with a 
non-NULL
  * codec. Subsequent calls will do nothing.
  *
- * @note Do not use this function. Use avcodec_free_context() to destroy a
+ * @deprecated Do not use this function. Use avcodec_free_context() to destroy 
a
  * codec context (either open or closed). Opening and closing a codec context
  * multiple times is not supported anymore -- use multiple codec contexts
  * instead.
  */
+attribute_deprecated
 int avcodec_close(AVCodecContext *avctx);
+#endif
 
 /**
  * Free all allocated data in the given subtitle struct.
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index 9b93ff3d81..4d1cb3a314 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -56,4 +56,6 @@ void ff_encode_flush_buffers(struct AVCodecContext *avctx);
 struct AVCodecInternal *ff_decode_internal_alloc(void);
 struct AVCodecInternal *ff_encode_internal_alloc(void);
 
+void ff_codec_close(struct AVCodecContext *avctx);
+
 #endif // AVCODEC_AVCODEC_INTERNAL_H
diff --git a/libavcodec/frame_thread_encoder.c 
b/libavcodec/frame_thread_encoder.c
index 62d9580ad4..cda5158117 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -27,6 +27,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "encode.h"
 #include "internal.h"
 #include "pthread_internal.h"
@@ -110,7 +111,7 @@ static void * attribute_align_arg worker(void *v){
 pthread_mutex_unlock(>finished_task_mutex);
 }
 end:
-avcodec_close(avctx);
+ff_codec_close(avctx);
 av_freep();
 return NULL;
 }
@@ -230,7 +231,7 @@ av_cold int ff_frame_thread_encoder_init(AVCodecContext 
*avctx)
 
 return 0;
 fail:
-avcodec_close(thread_avctx);
+ff_codec_close(thread_avctx);
 av_freep(_avctx);
 avctx->thread_count = i;
 av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n");
diff --git a/libavcodec/options.c b/libavcodec/options.c
index a9b35ee1c3..05a355fb45 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -27,6 +27,7 @@
 #include "config_components.h"
 
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "libavutil/avassert.h"
 #include "libavutil/internal.h"
@@ -172,7 +173,7 @@ void avcodec_free_context(AVCodecContext **pavctx)
 if (!avctx)
 return;
 
-avcodec_close(avctx);
+ff_codec_close(avctx);
 
 av_freep(>extradata);
 av_freep(>subtitle_header);
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index b9164fe5c6..45209c0a4f 100644
--- a/libavcodec/version_major.h
+++ 

[FFmpeg-cvslog] lavf/demux: stop calling avcodec_close()

2024-02-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Feb  1 
08:57:24 2024 +0100| [ca18bb597223b3df5bbf8a1836d157ba58b62570] | committer: 
Anton Khirnov

lavf/demux: stop calling avcodec_close()

Replace it with recreating the codec context.

This is the last remaining blocker for deprecating avcodec_close().

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

 libavformat/demux.c | 61 -
 1 file changed, 56 insertions(+), 5 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 6f640b92b1..b70979c520 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1250,6 +1250,53 @@ static int64_t ts_to_samples(AVStream *st, int64_t ts)
 return av_rescale(ts, st->time_base.num * st->codecpar->sample_rate, 
st->time_base.den);
 }
 
+static int codec_close(FFStream *sti)
+{
+AVCodecContext *avctx_new = NULL;
+AVCodecParameters *par_tmp = NULL;
+int ret;
+
+avctx_new = avcodec_alloc_context3(sti->avctx->codec);
+if (!avctx_new) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
+par_tmp = avcodec_parameters_alloc();
+if (!par_tmp) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
+ret = avcodec_parameters_from_context(par_tmp, sti->avctx);
+if (ret < 0)
+goto fail;
+
+ret = avcodec_parameters_to_context(avctx_new, par_tmp);
+if (ret < 0)
+goto fail;
+
+avctx_new->pkt_timebase = sti->avctx->pkt_timebase;
+
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx_new->ticks_per_frame = sti->avctx->ticks_per_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+avcodec_free_context(>avctx);
+sti->avctx = avctx_new;
+
+avctx_new = NULL;
+ret   = 0;
+
+fail:
+avcodec_free_context(_new);
+avcodec_parameters_free(_tmp);
+
+return ret;
+}
+
 static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
 {
 FFFormatContext *const si = ffformatcontext(s);
@@ -1286,8 +1333,10 @@ static int read_frame_internal(AVFormatContext *s, 
AVPacket *pkt)
 if (sti->need_context_update) {
 if (avcodec_is_open(sti->avctx)) {
 av_log(s, AV_LOG_DEBUG, "Demuxer context update while decoder 
is open, closing and trying to re-open\n");
-avcodec_close(sti->avctx);
+ret = codec_close(sti);
 sti->info->found_decoder = 0;
+if (ret < 0)
+return ret;
 }
 
 /* close parser, because it depends on the codec */
@@ -3013,14 +3062,16 @@ find_stream_info_err:
 for (unsigned i = 0; i < ic->nb_streams; i++) {
 AVStream *const st  = ic->streams[i];
 FFStream *const sti = ffstream(st);
+int err;
+
 if (sti->info) {
 av_freep(>info->duration_error);
 av_freep(>info);
 }
-avcodec_close(sti->avctx);
-// FIXME: avcodec_close() frees AVOption settable fields which 
includes ch_layout,
-//so we need to restore it.
-av_channel_layout_copy(>avctx->ch_layout, 
>codecpar->ch_layout);
+
+err = codec_close(sti);
+if (err < 0 && ret >= 0)
+ret = err;
 av_bsf_free(>extract_extradata.bsf);
 }
 if (ic->pb) {

___
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] fftools/ffmpeg_demux: set stream index right before sending packet to scheduler

2024-02-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Feb  5 
18:06:52 2024 +0100| [05fc6d3ce71e7e31040becec4bca1ac9beb0f366] | committer: 
Anton Khirnov

fftools/ffmpeg_demux: set stream index right before sending packet to scheduler

This avoids assuming that it survives unchanged through bitstream
filters, if present.

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

 fftools/ffmpeg_demux.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 60dc9620c2..3bf95e2c3f 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -475,8 +475,6 @@ static int input_packet_process(Demuxer *d, AVPacket *pkt, 
unsigned *send_flags)
av_ts2str(f->ts_offset),  av_ts2timestr(f->ts_offset, 
_TIME_BASE_Q));
 }
 
-pkt->stream_index = ds->sch_idx_stream;
-
 return 0;
 }
 
@@ -505,6 +503,8 @@ static int do_send(Demuxer *d, DemuxStream *ds, AVPacket 
*pkt, unsigned flags,
 {
 int ret;
 
+pkt->stream_index = ds->sch_idx_stream;
+
 ret = sch_demux_send(d->sch, d->f.index, pkt, flags);
 if (ret == AVERROR_EOF) {
 av_packet_unref(pkt);
@@ -546,7 +546,6 @@ static int demux_send(Demuxer *d, DemuxThreadContext *dt, 
DemuxStream *ds,
 
 d->pkt_heartbeat->pts  = pkt->pts;
 d->pkt_heartbeat->time_base= pkt->time_base;
-d->pkt_heartbeat->stream_index = ds1->sch_idx_stream;
 d->pkt_heartbeat->opaque   = 
(void*)(intptr_t)PKT_OPAQUE_SUB_HEARTBEAT;
 
 ret = do_send(d, ds1, d->pkt_heartbeat, 0, "heartbeat");

___
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] lavf/flacdec: stop accessing FFStream.avctx

2024-02-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Jan 31 
16:27:59 2024 +0100| [88ba22009e401286e213c34308aabaee778f1d28] | committer: 
Anton Khirnov

lavf/flacdec: stop accessing FFStream.avctx

The demuxer opens an internal parser instance in read_timestamp(), which
requires a codec context. There is no need for it to access the FFStream
one which is used for other purposes, it can allocate its own internal
one.

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

 libavformat/flacdec.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index ab9ef052f9..bbb205078a 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -36,6 +36,8 @@
 typedef struct FLACDecContext {
 FFRawDemuxerContext rawctx;
 int found_seektable;
+
+AVCodecContext *parser_dec;
 } FLACDecContext;
 
 static void reset_index_position(int64_t metadata_head_size, AVStream *st)
@@ -269,6 +271,7 @@ static int flac_probe(const AVProbeData *p)
 static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int 
stream_index,
  int64_t *ppos, int64_t pos_limit)
 {
+FLACDecContext *flac = s->priv_data;
 FFFormatContext *const si = ffformatcontext(s);
 AVPacket *const pkt = si->parse_pkt;
 AVStream *st = s->streams[stream_index];
@@ -285,6 +288,16 @@ static av_unused int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
 }
 parser->flags |= PARSER_FLAG_USE_CODEC_TS;
 
+if (!flac->parser_dec) {
+flac->parser_dec = avcodec_alloc_context3(NULL);
+if (!flac->parser_dec)
+return AV_NOPTS_VALUE;
+
+ret = avcodec_parameters_to_context(flac->parser_dec, st->codecpar);
+if (ret < 0)
+return ret;
+}
+
 for (;;){
 uint8_t *data;
 int size;
@@ -298,7 +311,7 @@ static av_unused int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
 av_assert1(!pkt->size);
 }
 }
-av_parser_parse2(parser, ffstream(st)->avctx,
+av_parser_parse2(parser, flac->parser_dec,
  , , pkt->data, pkt->size,
  pkt->pts, pkt->dts, *ppos);
 
@@ -318,6 +331,15 @@ static av_unused int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
 return pts;
 }
 
+static int flac_close(AVFormatContext *s)
+{
+FLACDecContext *flac = s->priv_data;
+
+avcodec_free_context(>parser_dec);
+
+return 0;
+}
+
 static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, 
int flags) {
 AVStream *const st  = s->streams[0];
 FFStream *const sti = ffstream(st);
@@ -347,6 +369,7 @@ const AVInputFormat ff_flac_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("raw FLAC"),
 .read_probe = flac_probe,
 .read_header= flac_read_header,
+.read_close = flac_close,
 .read_packet= ff_raw_read_partial_packet,
 .read_seek  = flac_seek,
 .read_timestamp = flac_read_timestamp,

___
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] lavf/mpegts: drop a cargo-culted check

2024-02-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Jan 31 
15:31:43 2024 +0100| [0d54ae40123ef8dbf77210faf1edbeacc121854e] | committer: 
Anton Khirnov

lavf/mpegts: drop a cargo-culted check

This check has survived the transition to AVCodecParameters, but is no
longer relevant after it, since the codec context is no longer updated
or accessed at all from the demuxer.

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

 libavformat/mpegts.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index bef00c88e7..1cf390e98e 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -919,11 +919,6 @@ static int mpegts_set_stream_info(AVStream *st, PESContext 
*pes,
 int old_codec_id   = st->codecpar->codec_id;
 int old_codec_tag  = st->codecpar->codec_tag;
 
-if (avcodec_is_open(sti->avctx)) {
-av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, internal 
codec is open\n");
-return 0;
-}
-
 avpriv_set_pts_info(st, 33, 1, 9);
 st->priv_data = pes;
 st->codecpar->codec_type = AVMEDIA_TYPE_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] fftools/cmdutils: Don't cast const away

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Feb  9 12:06:09 2024 +0100| [8c2e86ca2856d4058cbad3c935bd02362f67db4d] | 
committer: Andreas Rheinhardt

fftools/cmdutils: Don't cast const away

Reviewed-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 

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

 fftools/cmdutils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index daf7673adb..5e181a0d85 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1121,7 +1121,7 @@ double get_rotation(const int32_t *displaymatrix)
 {
 double theta = 0;
 if (displaymatrix)
-theta = -round(av_display_rotation_get((int32_t*) displaymatrix));
+theta = -round(av_display_rotation_get(displaymatrix));
 
 theta -= 360*floor(theta/360 + 0.9/360);
 

___
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/rcwtenc: Remove redundant zeroing of buffer

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Feb  8 16:01:06 2024 +0100| [a8e55cf11846c4e44d45985dd0a8a5a53e2359aa] | 
committer: Andreas Rheinhardt

avformat/rcwtenc: Remove redundant zeroing of buffer

Resetting the counter of used elements is enough as nothing is
ever read from the currently unused elements.

Reviewed-by: Marth64 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/rcwtenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/rcwtenc.c b/libavformat/rcwtenc.c
index 1becef5f48..2ee4aae6bf 100644
--- a/libavformat/rcwtenc.c
+++ b/libavformat/rcwtenc.c
@@ -76,7 +76,6 @@ static void rcwt_init_cluster(AVFormatContext *avf)
 
 rcwt->cluster_pos = 0;
 rcwt->cluster_pts = AV_NOPTS_VALUE;
-memset(rcwt->cluster_buf, 0, sizeof(rcwt->cluster_buf));
 }
 
 static void rcwt_flush_cluster(AVFormatContext *avf)

___
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/rcwtenc: Pass RCWTContext directly in rcwt_init_cluster()

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Feb  8 16:04:19 2024 +0100| [3371250c328857cb1b55f7a7f6e4bd0f566adcc4] | 
committer: Andreas Rheinhardt

avformat/rcwtenc: Pass RCWTContext directly in rcwt_init_cluster()

It does not use the AVFormatContext at all.

Reviewed-by: Marth64 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/rcwtenc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/rcwtenc.c b/libavformat/rcwtenc.c
index 2ee4aae6bf..a6060ba7c4 100644
--- a/libavformat/rcwtenc.c
+++ b/libavformat/rcwtenc.c
@@ -70,10 +70,8 @@ typedef struct RCWTContext {
 uint8_t cluster_buf[RCWT_CLUSTER_MAX_BLOCKS * RCWT_BLOCK_SIZE];
 } RCWTContext;
 
-static void rcwt_init_cluster(AVFormatContext *avf)
+static void rcwt_init_cluster(RCWTContext *rcwt)
 {
-RCWTContext *rcwt = avf->priv_data;
-
 rcwt->cluster_pos = 0;
 rcwt->cluster_pts = AV_NOPTS_VALUE;
 }
@@ -88,7 +86,7 @@ static void rcwt_flush_cluster(AVFormatContext *avf)
 avio_write(avf->pb, rcwt->cluster_buf, rcwt->cluster_pos);
 }
 
-rcwt_init_cluster(avf);
+rcwt_init_cluster(rcwt);
 }
 
 static int rcwt_write_header(AVFormatContext *avf)
@@ -117,7 +115,7 @@ static int rcwt_write_header(AVFormatContext *avf)
 avio_wb16(avf->pb, 0x000);
 avio_w8(avf->pb, 0x00);
 
-rcwt_init_cluster(avf);
+rcwt_init_cluster(avf->priv_data);
 
 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] avformat/rcwtenc: Fix potential out-of-bounds write

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Feb  8 15:44:17 2024 +0100| [d30fe36b88983feb7c48fc22a4bc03868248c479] | 
committer: Andreas Rheinhardt

avformat/rcwtenc: Fix potential out-of-bounds write

The rcwt muxer uses several counters for how much data
it has already cached: One byte counter and one counter
for how many complete blocks (of three bytes each).
These counters can become inconsistent when the muxer is
fed incomplete blocks as the muxer presumes that it is
about to write a new block at the start of each write_packet
call. E.g. sending 65535*3+1 1-byte packets (with data[0] e.g. 0x03)
will trigger an out-of-bounds write.

This patch fixes this by processing the data in complete blocks
only. This also allows to simplify the code, e.g. to remove one of
the counters.

Reviewed-by: Marth64 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/rcwtenc.c | 38 +++---
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/libavformat/rcwtenc.c b/libavformat/rcwtenc.c
index 839436ce84..1becef5f48 100644
--- a/libavformat/rcwtenc.c
+++ b/libavformat/rcwtenc.c
@@ -65,7 +65,6 @@
 #define RCWT_BLOCK_SIZE 3
 
 typedef struct RCWTContext {
-int cluster_nb_blocks;
 int cluster_pos;
 int64_t cluster_pts;
 uint8_t cluster_buf[RCWT_CLUSTER_MAX_BLOCKS * RCWT_BLOCK_SIZE];
@@ -75,7 +74,6 @@ static void rcwt_init_cluster(AVFormatContext *avf)
 {
 RCWTContext *rcwt = avf->priv_data;
 
-rcwt->cluster_nb_blocks = 0;
 rcwt->cluster_pos = 0;
 rcwt->cluster_pts = AV_NOPTS_VALUE;
 memset(rcwt->cluster_buf, 0, sizeof(rcwt->cluster_buf));
@@ -85,10 +83,10 @@ static void rcwt_flush_cluster(AVFormatContext *avf)
 {
 RCWTContext *rcwt = avf->priv_data;
 
-if (rcwt->cluster_nb_blocks > 0) {
+if (rcwt->cluster_pos > 0) {
 avio_wl64(avf->pb, rcwt->cluster_pts);
-avio_wl16(avf->pb, rcwt->cluster_nb_blocks);
-avio_write(avf->pb, rcwt->cluster_buf, (rcwt->cluster_nb_blocks * 
RCWT_BLOCK_SIZE));
+avio_wl16(avf->pb, rcwt->cluster_pos / RCWT_BLOCK_SIZE);
+avio_write(avf->pb, rcwt->cluster_buf, rcwt->cluster_pos);
 }
 
 rcwt_init_cluster(avf);
@@ -129,10 +127,7 @@ static int rcwt_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 {
 RCWTContext *rcwt = avf->priv_data;
 
-int in_block = 0;
-int nb_block_bytes = 0;
-
-if (pkt->size == 0)
+if (pkt->size < RCWT_BLOCK_SIZE)
 return 0;
 
 /* new PTS, new cluster */
@@ -146,11 +141,11 @@ static int rcwt_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 return 0;
 }
 
-for (int i = 0; i < pkt->size; i++) {
+for (int i = 0; i <= pkt->size - RCWT_BLOCK_SIZE;) {
 uint8_t cc_valid;
 uint8_t cc_type;
 
-if (rcwt->cluster_nb_blocks == RCWT_CLUSTER_MAX_BLOCKS) {
+if (rcwt->cluster_pos == RCWT_CLUSTER_MAX_BLOCKS * RCWT_BLOCK_SIZE) {
 av_log(avf, AV_LOG_WARNING, "Starting new cluster due to size\n");
 rcwt_flush_cluster(avf);
 }
@@ -158,25 +153,14 @@ static int rcwt_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 cc_valid = (pkt->data[i] & 0x04) >> 2;
 cc_type = pkt->data[i] & 0x03;
 
-if (!in_block && !(cc_valid || cc_type == 3))
-continue;
-
-memcpy(>cluster_buf[rcwt->cluster_pos], >data[i], 1);
-rcwt->cluster_pos++;
-
-if (!in_block) {
-in_block = 1;
-nb_block_bytes = 1;
+if (!(cc_valid || cc_type == 3)) {
+i++;
 continue;
 }
 
-nb_block_bytes++;
-
-if (nb_block_bytes == RCWT_BLOCK_SIZE) {
-in_block = 0;
-nb_block_bytes = 0;
-rcwt->cluster_nb_blocks++;
-}
+memcpy(>cluster_buf[rcwt->cluster_pos], >data[i], 3);
+rcwt->cluster_pos += 3;
+i += 3;
 }
 
 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] avcodec/h263dec: Remove AVCodec.pix_fmts arrays

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Feb  6 00:17:04 2024 +0100| [2b0e9e278a410ca59c06e526c14a3b068ce5bc64] | 
committer: Andreas Rheinhardt

avcodec/h263dec: Remove AVCodec.pix_fmts arrays

They are not intended for decoders (for which there is the get_format
callback in case the user has a choice).

Also note that the list was wrong for MPEG4, because it did not contain
the high bit depth pixel formats used for studio profiles.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/flvdec.c|  2 --
 libavcodec/h263dec.c   | 43 +++
 libavcodec/h263dec.h   |  2 --
 libavcodec/intelh263dec.c  |  4 
 libavcodec/mpeg4videodec.c |  1 -
 libavcodec/msmpeg4dec.c| 16 
 libavcodec/wmv2dec.c   |  2 --
 7 files changed, 23 insertions(+), 47 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 09fefd3d1c..8baaed06a8 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -123,6 +123,4 @@ const FFCodec ff_flv_decoder = {
 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 .p.max_lowres   = 3,
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE },
 };
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index eb1d87a2fe..910df7585f 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -49,6 +49,23 @@
 #include "thread.h"
 #include "wmv2dec.h"
 
+static const enum AVPixelFormat h263_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL
+AV_PIX_FMT_VAAPI,
+#endif
+#if CONFIG_MPEG4_NVDEC_HWACCEL
+AV_PIX_FMT_CUDA,
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+AV_PIX_FMT_VDPAU,
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL || CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL
+AV_PIX_FMT_VIDEOTOOLBOX,
+#endif
+AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_NONE
+};
+
 static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)
 {
 /* MPEG-4 Studio Profile only, not supported by hardware */
@@ -63,7 +80,12 @@ static enum AVPixelFormat h263_get_format(AVCodecContext 
*avctx)
 return AV_PIX_FMT_GRAY8;
 }
 
-return avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
+if (avctx->codec_id == AV_CODEC_ID_H263  ||
+avctx->codec_id == AV_CODEC_ID_H263P ||
+avctx->codec_id == AV_CODEC_ID_MPEG4)
+return avctx->pix_fmt = ff_get_format(avctx, 
h263_hwaccel_pixfmt_list_420);
+
+return AV_PIX_FMT_YUV420P;
 }
 
 av_cold int ff_h263_decode_init(AVCodecContext *avctx)
@@ -659,23 +681,6 @@ frame_end:
 return get_consumed_bytes(s, buf_size);
 }
 
-const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL
-AV_PIX_FMT_VAAPI,
-#endif
-#if CONFIG_MPEG4_NVDEC_HWACCEL
-AV_PIX_FMT_CUDA,
-#endif
-#if CONFIG_MPEG4_VDPAU_HWACCEL
-AV_PIX_FMT_VDPAU,
-#endif
-#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL || CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL
-AV_PIX_FMT_VIDEOTOOLBOX,
-#endif
-AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_NONE
-};
-
 static const AVCodecHWConfigInternal *const h263_hw_config_list[] = {
 #if CONFIG_H263_VAAPI_HWACCEL
 HWACCEL_VAAPI(h263),
@@ -706,7 +711,6 @@ const FFCodec ff_h263_decoder = {
 .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 .flush  = ff_mpeg_flush,
 .p.max_lowres   = 3,
-.p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
 .hw_configs = h263_hw_config_list,
 };
 
@@ -724,6 +728,5 @@ const FFCodec ff_h263p_decoder = {
 .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 .flush  = ff_mpeg_flush,
 .p.max_lowres   = 3,
-.p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
 .hw_configs = h263_hw_config_list,
 };
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 06ff7c1c48..89c5fcf58f 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -38,8 +38,6 @@ extern VLCElem ff_h263_inter_MCBPC_vlc[];
 extern VLCElem ff_h263_cbpy_vlc[];
 extern VLCElem ff_h263_mv_vlc[];
 
-extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
-
 int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
 int ff_h263_decode_init(AVCodecContext *avctx);
 int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *frame,
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 2c216b00a6..f8eeb6b44e 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -138,8 +138,4 @@ const FFCodec ff_h263i_decoder = {
 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
-.p.pix_fmts = (const enum AVPixelFormat[]) {
-

[FFmpeg-cvslog] avcodec/vc1dec: Remove AVCodec.pix_fmts arrays

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb  5 23:42:14 2024 +0100| [39cfd30bf111b4f4267715ef04c29ac9fadf1257] | 
committer: Andreas Rheinhardt

avcodec/vc1dec: Remove AVCodec.pix_fmts arrays

They are not intended for decoders (for which there is the get_format
callback in case the user has a choice).

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/vc1dec.c | 64 -
 1 file changed, 29 insertions(+), 35 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 4f4aa8aa07..e71b92eef8 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -72,6 +72,30 @@ typedef struct SpriteData {
 int effect_params1[15], effect_params2[10]; ///< effect parameters in 
16.16 fixed point format
 } SpriteData;
 
+static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_VC1_DXVA2_HWACCEL
+AV_PIX_FMT_DXVA2_VLD,
+#endif
+#if CONFIG_VC1_D3D11VA_HWACCEL
+AV_PIX_FMT_D3D11VA_VLD,
+AV_PIX_FMT_D3D11,
+#endif
+#if CONFIG_VC1_D3D12VA_HWACCEL
+AV_PIX_FMT_D3D12,
+#endif
+#if CONFIG_VC1_NVDEC_HWACCEL
+AV_PIX_FMT_CUDA,
+#endif
+#if CONFIG_VC1_VAAPI_HWACCEL
+AV_PIX_FMT_VAAPI,
+#endif
+#if CONFIG_VC1_VDPAU_HWACCEL
+AV_PIX_FMT_VDPAU,
+#endif
+AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_NONE
+};
+
 static inline int get_fp_val(GetBitContext* gb)
 {
 return (get_bits_long(gb, 30) - (1 << 29)) << 1;
@@ -417,7 +441,11 @@ static enum AVPixelFormat vc1_get_format(AVCodecContext 
*avctx)
 return AV_PIX_FMT_GRAY8;
 }
 
-return ff_get_format(avctx, avctx->codec->pix_fmts);
+if (avctx->codec_id == AV_CODEC_ID_VC1IMAGE ||
+avctx->codec_id == AV_CODEC_ID_WMV3IMAGE)
+return AV_PIX_FMT_YUV420P;
+
+return ff_get_format(avctx, vc1_hwaccel_pixfmt_list_420);
 }
 
 av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
@@ -1354,30 +1382,6 @@ err:
 }
 
 
-static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_VC1_DXVA2_HWACCEL
-AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_VC1_D3D11VA_HWACCEL
-AV_PIX_FMT_D3D11VA_VLD,
-AV_PIX_FMT_D3D11,
-#endif
-#if CONFIG_VC1_D3D12VA_HWACCEL
-AV_PIX_FMT_D3D12,
-#endif
-#if CONFIG_VC1_NVDEC_HWACCEL
-AV_PIX_FMT_CUDA,
-#endif
-#if CONFIG_VC1_VAAPI_HWACCEL
-AV_PIX_FMT_VAAPI,
-#endif
-#if CONFIG_VC1_VDPAU_HWACCEL
-AV_PIX_FMT_VDPAU,
-#endif
-AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_NONE
-};
-
 const FFCodec ff_vc1_decoder = {
 .p.name = "vc1",
 CODEC_LONG_NAME("SMPTE VC-1"),
@@ -1389,7 +1393,6 @@ const FFCodec ff_vc1_decoder = {
 FF_CODEC_DECODE_CB(vc1_decode_frame),
 .flush  = ff_mpeg_flush,
 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
-.p.pix_fmts = vc1_hwaccel_pixfmt_list_420,
 .hw_configs = (const AVCodecHWConfigInternal *const []) {
 #if CONFIG_VC1_DXVA2_HWACCEL
 HWACCEL_DXVA2(vc1),
@@ -1429,7 +1432,6 @@ const FFCodec ff_wmv3_decoder = {
 FF_CODEC_DECODE_CB(vc1_decode_frame),
 .flush  = ff_mpeg_flush,
 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
-.p.pix_fmts = vc1_hwaccel_pixfmt_list_420,
 .hw_configs = (const AVCodecHWConfigInternal *const []) {
 #if CONFIG_WMV3_DXVA2_HWACCEL
 HWACCEL_DXVA2(wmv3),
@@ -1470,10 +1472,6 @@ const FFCodec ff_wmv3image_decoder = {
 FF_CODEC_DECODE_CB(vc1_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1,
 .flush  = vc1_sprite_flush,
-.p.pix_fmts = (const enum AVPixelFormat[]) {
-AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_NONE
-},
 };
 #endif
 
@@ -1489,9 +1487,5 @@ const FFCodec ff_vc1image_decoder = {
 FF_CODEC_DECODE_CB(vc1_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1,
 .flush  = vc1_sprite_flush,
-.p.pix_fmts = (const enum AVPixelFormat[]) {
-AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_NONE
-},
 };
 #endif

___
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/mmaldec: Avoid using AVCodec.pix_fmts

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb  5 19:58:20 2024 +0100| [687a287e140e87317986ad9445c3dfc2fcd0d342] | 
committer: Andreas Rheinhardt

avcodec/mmaldec: Avoid using AVCodec.pix_fmts

It is entirely unnecessary to use it given that all decoders
here share the same set of supported pixel formats. So just
hardcode this list.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mmaldec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 2dc7bbee04..a8cda27570 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -101,6 +101,10 @@ typedef struct MMALDecodeContext {
 // packets (where each packet contains 1 frame).
 #define MAX_DELAYED_FRAMES 16
 
+static const enum AVPixelFormat mmal_pixfmts[] = {
+AV_PIX_FMT_MMAL, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
+};
+
 static void ffmmal_poolref_unref(FFPoolRef *ref)
 {
 if (ref &&
@@ -367,7 +371,7 @@ static av_cold int ffmmal_init_decoder(AVCodecContext 
*avctx)
 return AVERROR(ENOSYS);
 }
 
-if ((ret = ff_get_format(avctx, avctx->codec->pix_fmts)) < 0)
+if ((ret = ff_get_format(avctx, mmal_pixfmts)) < 0)
 return ret;
 
 avctx->pix_fmt = ret;
@@ -844,9 +848,6 @@ static const AVClass ffmmal_dec_class = {
 .p.priv_class   = _dec_class, \
 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
 .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE, \
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, \
- AV_PIX_FMT_YUV420P, \
- AV_PIX_FMT_NONE}, \
 .hw_configs = mmal_hw_configs, \
 .p.wrapper_name = "mmal", \
 };

___
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/vc1dec: Don't call ff_get_format() twice

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb  5 22:49:21 2024 +0100| [ca9586375828bbb4d8ef7eeeb3ad3b55116c6fd7] | 
committer: Andreas Rheinhardt

avcodec/vc1dec: Don't call ff_get_format() twice

It is currently called once in the codecs' init function
and once when (re)initializing the VC-1 decode context
(which happens upon frame size changes as well as before
decoding the first frame). The first one is unnecessary
now that vc1_decode_frame() no longer requires avctx->hwaccel
to be already set for hwaccel to work properly.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/vc1dec.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 6462a40fd3..4f4aa8aa07 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -691,14 +691,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 if (v->profile == PROFILE_ADVANCED)
 avctx->level = v->level;
 
-if (!CONFIG_GRAY || !(avctx->flags & AV_CODEC_FLAG_GRAY))
-avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
-else {
-avctx->pix_fmt = AV_PIX_FMT_GRAY8;
-if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)
-avctx->color_range = AVCOL_RANGE_MPEG;
-}
-
 ff_blockdsp_init(>bdsp);
 ff_h264chroma_init(>h264chroma, 8);
 

___
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/vc1dec: Set pointers for hwaccel even without hwaccel

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb  5 22:15:31 2024 +0100| [38f234c06ee0d98c3568120338c1ec4078f8f9cc] | 
committer: Andreas Rheinhardt

avcodec/vc1dec: Set pointers for hwaccel even without hwaccel

VC-1 uses a 0x03 escaping scheme like H.26x and our decoder
unescapes data for this purpose, but hardware accelerations
just want the data as-is and therefore get fed the original
data. The pointers to the actual data are only setcorrectly
if avctx->hwaccel is set (after all, they are only used in
this case).

There are two problems with this: The first is that the branch
is pointless; the second is that it is harmful, because
a hardware acceleration may be added after the packet has been
parsed (in case there is a reconfiguration e.g. due to frame
size changes) in which case decoding the first few frames
won't work.

So delete these branches.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 6eff2ec04c..6462a40fd3 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -846,14 +846,12 @@ static int vc1_decode_frame(AVCodecContext *avctx, 
AVFrame *pict,
 if (size <= 0) continue;
 switch (AV_RB32(start)) {
 case VC1_CODE_FRAME:
-if (avctx->hwaccel)
-buf_start = start;
+buf_start = start;
 buf_size2 = v->vc1dsp.vc1_unescape_buffer(start + 4, size, 
buf2);
 break;
 case VC1_CODE_FIELD: {
 int buf_size3;
-if (avctx->hwaccel)
-buf_start_second_field = start;
+buf_start_second_field = start;
 av_size_mult(sizeof(*slices), n_slices+1, _allocated);
 tmp = next_allocated ? av_fast_realloc(slices, 
_allocated, next_allocated) : NULL;
 if (!tmp) {
@@ -918,8 +916,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 ret = AVERROR_INVALIDDATA;
 goto err;
 } else { // found field marker, unescape second field
-if (avctx->hwaccel)
-buf_start_second_field = divider;
+buf_start_second_field = divider;
 av_size_mult(sizeof(*slices), n_slices+1, _allocated);
 tmp = next_allocated ? av_fast_realloc(slices, 
_allocated, next_allocated) : NULL;
 if (!tmp) {

___
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: Remove redundant pix_fmts from decoders

2024-02-09 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Feb  5 19:46:14 2024 +0100| [89995cfda12ef460e945c68b49ca3172904012b8] | 
committer: Andreas Rheinhardt

avcodec: Remove redundant pix_fmts from decoders

AVCodec.pix_fmts is only intended for encoders (decoders use
the get_format callback to let the user choose a pix fmt).
So remove them for the decoders for which this is possible
without further complications; keep them for now in the codecs
that actually use them (by passing avctx->codec->pix_fmts to
ff_get_formatt()).

Also notice that some of these lists were wrong; e.g.
317b7b06fd97cd39feac7df57db22a30550351ff added support for YUV444P16
for cuviddec, but forgot to add it to pix_fmts.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/crystalhd.c |  1 -
 libavcodec/cuviddec.c  |  5 -
 libavcodec/flashsv.c   |  2 --
 libavcodec/libdavs2.c  |  2 --
 libavcodec/libuavs3d.c |  3 ---
 libavcodec/qsvdec.c| 11 ---
 libavcodec/rkmppdec.c  |  2 --
 libavcodec/rv10.c  |  8 
 libavcodec/rv30.c  |  4 
 libavcodec/rv40.c  |  4 
 libavcodec/svq1dec.c   |  2 --
 libavcodec/svq3.c  |  2 --
 libavcodec/xfacedec.c  |  1 -
 13 files changed, 47 deletions(-)

diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index 86f6cfa6c1..fb190436f5 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -797,7 +797,6 @@ static int crystalhd_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | 
AV_CODEC_CAP_HARDWARE, \
 .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
   FF_CODEC_CAP_SETS_FRAME_PROPS, \
-.p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, 
AV_PIX_FMT_NONE}, \
 .p.wrapper_name = "crystalhd", \
 };
 
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index da37207cf2..84edf5c209 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -1174,11 +1174,6 @@ static const AVCodecHWConfigInternal *const 
cuvid_hw_configs[] = {
 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | 
AV_CODEC_CAP_HARDWARE, \
 .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
   FF_CODEC_CAP_SETS_FRAME_PROPS, \
-.p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
-AV_PIX_FMT_NV12, \
-AV_PIX_FMT_P010, \
-AV_PIX_FMT_P016, \
-AV_PIX_FMT_NONE }, \
 .hw_configs = cuvid_hw_configs, \
 .p.wrapper_name = "cuvid", \
 };
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 8a01e3a4b6..fe00e529a5 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -511,7 +511,6 @@ const FFCodec ff_flashsv_decoder = {
 FF_CODEC_DECODE_CB(flashsv_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, 
AV_PIX_FMT_NONE },
 };
 #endif /* CONFIG_FLASHSV_DECODER */
 
@@ -579,6 +578,5 @@ const FFCodec ff_flashsv2_decoder = {
 FF_CODEC_DECODE_CB(flashsv_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, 
AV_PIX_FMT_NONE },
 };
 #endif /* CONFIG_FLASHSV2_DECODER */
diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 179d2f4e4b..5a605c36f6 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -234,7 +234,5 @@ const FFCodec ff_libdavs2_decoder = {
 .p.capabilities =  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
 .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
   FF_CODEC_CAP_AUTO_THREADS,
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE },
 .p.wrapper_name = "libdavs2",
 };
diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c
index 66e8d31001..f5d47f28ed 100644
--- a/libavcodec/libuavs3d.c
+++ b/libavcodec/libuavs3d.c
@@ -274,8 +274,5 @@ const FFCodec ff_libuavs3d_decoder = {
 .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
   FF_CODEC_CAP_AUTO_THREADS,
 .flush  = libuavs3d_flush,
-.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_YUV420P10LE,
- AV_PIX_FMT_NONE },
 .p.wrapper_name = "libuavs3d",
 };
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 559f63698a..812bfd8830 100644
---