[FFmpeg-devel] [PATCH 6/6] wmaprodec: convert to lavu/tx

2022-09-23 Thread Lynne
Patch attached.

>From 4ad73f29065051c68991eb96aeae7f771039209a Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 01:08:00 +0200
Subject: [PATCH 6/6] wmaprodec: convert to lavu/tx

---
 libavcodec/wmaprodec.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 701dfa955c..68e17e0743 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -89,6 +89,7 @@
 #include 
 
 #include "libavutil/audio_fifo.h"
+#include "libavutil/tx.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/intfloat.h"
@@ -185,7 +186,8 @@ typedef struct WMAProDecodeCtx {
 uint8_t  frame_data[MAX_FRAMESIZE +
   AV_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
 PutBitContextpb;///< context for filling the frame_data buffer
-FFTContext   mdct_ctx[WMAPRO_BLOCK_SIZES];  ///< MDCT context per block size
+AVTXContext *tx[WMAPRO_BLOCK_SIZES];///< MDCT context per block size
+av_tx_fn tx_fn[WMAPRO_BLOCK_SIZES];
 DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer
 const float* windows[WMAPRO_BLOCK_SIZES];   ///< windows for the different block sizes
 
@@ -287,7 +289,7 @@ static av_cold int decode_end(WMAProDecodeCtx *s)
 av_freep(>fdsp);
 
 for (i = 0; i < WMAPRO_BLOCK_SIZES; i++)
-ff_mdct_end(>mdct_ctx[i]);
+av_tx_uninit(>tx[i]);
 
 return 0;
 }
@@ -552,12 +554,13 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu
 return AVERROR(ENOMEM);
 
 /** init MDCT, FIXME: only init needed sizes */
-for (int i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
-ret = ff_mdct_init(>mdct_ctx[i], WMAPRO_BLOCK_MIN_BITS + 1 + i, 1,
-   1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1))
-   / (1ll << (s->bits_per_sample - 1)));
-if (ret < 0)
-return ret;
+for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
+const float scale = 1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1))
+/ (1ll << (s->bits_per_sample - 1));
+int err = av_tx_init(>tx[i], >tx_fn[i], AV_TX_FLOAT_MDCT, 1,
+ 1 << (WMAPRO_BLOCK_MIN_BITS + i), , 0);
+if (err < 0)
+return err;
 }
 
 /** init MDCT windows: simple sine window */
@@ -1386,7 +1389,8 @@ static int decode_subframe(WMAProDecodeCtx *s)
 get_bits_count(>gb) - s->subframe_offset);
 
 if (transmit_coeffs) {
-FFTContext *mdct = >mdct_ctx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS];
+AVTXContext *tx = s->tx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS];
+av_tx_fn tx_fn = s->tx_fn[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS];
 /** reconstruct the per channel data */
 inverse_channel_transform(s);
 for (i = 0; i < s->channels_for_cur_subframe; i++) {
@@ -1412,7 +1416,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
 }
 
 /** apply imdct (imdct_half == DCTIV with reverse) */
-mdct->imdct_half(mdct, s->channel[c].coeffs, s->tmp);
+tx_fn(tx, s->channel[c].coeffs, s->tmp, sizeof(float));
 }
 }
 
-- 
2.37.2.609.g9ff673ca1a

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

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


[FFmpeg-devel] [PATCH 5/6] twinvq: convert to lavu/tx

2022-09-23 Thread Lynne
Patch attached.

>From 685ac65ce0f391fd1d3a06e191c9659dacd375be Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 01:07:44 +0200
Subject: [PATCH 5/6] twinvq: convert to lavu/tx

---
 libavcodec/twinvq.c | 12 +++-
 libavcodec/twinvq.h |  6 --
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index da10923d78..8cd3c91e14 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -328,7 +328,8 @@ static const uint8_t wtype_to_wsize[] = { 0, 0, 2, 2, 2, 1, 0, 1, 1 };
 static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype,
  int wtype, float *in, float *prev, int ch)
 {
-FFTContext *mdct = >mdct_ctx[ftype];
+AVTXContext *tx = tctx->tx[ftype];
+av_tx_fn tx_fn = tctx->tx_fn[ftype];
 const TwinVQModeTab *mtab = tctx->mtab;
 int bsize = mtab->size / mtab->fmode[ftype].sub;
 int size  = mtab->size;
@@ -357,7 +358,7 @@ static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype,
 
 wsize = types_sizes[wtype_to_wsize[sub_wtype]];
 
-mdct->imdct_half(mdct, buf1 + bsize * j, in + bsize * j);
+tx_fn(tx, buf1 + bsize * j, in + bsize * j, sizeof(float));
 
 tctx->fdsp->vector_fmul_window(out2, prev_buf + (bsize - wsize) / 2,
   buf1 + bsize * j,
@@ -543,8 +544,9 @@ static av_cold int init_mdct_win(TwinVQContext *tctx)
 
 for (i = 0; i < 3; i++) {
 int bsize = tctx->mtab->size / tctx->mtab->fmode[i].sub;
-if ((ret = ff_mdct_init(>mdct_ctx[i], av_log2(bsize) + 1, 1,
--sqrt(norm / bsize) / (1 << 15
+const float scale = -sqrt(norm / bsize) / (1 << 15);
+if ((ret = av_tx_init(>tx[i], >tx_fn[i], AV_TX_FLOAT_MDCT,
+  1, bsize, , 0)))
 return ret;
 }
 
@@ -745,7 +747,7 @@ av_cold int ff_twinvq_decode_close(AVCodecContext *avctx)
 int i;
 
 for (i = 0; i < 3; i++) {
-ff_mdct_end(>mdct_ctx[i]);
+av_tx_uninit(>tx[i]);
 av_freep(>cos_tabs[i]);
 }
 
diff --git a/libavcodec/twinvq.h b/libavcodec/twinvq.h
index b3c881cfac..72b9ba8198 100644
--- a/libavcodec/twinvq.h
+++ b/libavcodec/twinvq.h
@@ -25,10 +25,11 @@
 #include 
 #include 
 
+#include "libavutil/tx.h"
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
-#include "fft.h"
+#include "internal.h"
 
 enum TwinVQCodec {
 TWINVQ_CODEC_VQF,
@@ -136,7 +137,8 @@ typedef struct TwinVQModeTab {
 typedef struct TwinVQContext {
 AVCodecContext *avctx;
 AVFloatDSPContext *fdsp;
-FFTContext mdct_ctx[3];
+AVTXContext *tx[3];
+av_tx_fn tx_fn[3];
 
 const TwinVQModeTab *mtab;
 
-- 
2.37.2.609.g9ff673ca1a

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

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


[FFmpeg-devel] [PATCH 4/6] vorbisdec: convert to lavu/tx

2022-09-23 Thread Lynne
Patch attached.

>From 1334c8c26a8d1c3f8e2aa98b902b2dab6e524a84 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 01:07:15 +0200
Subject: [PATCH 4/6] vorbisdec: convert to lavu/tx

---
 libavcodec/vorbisdec.c | 29 -
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 0d04e7c2c4..44c76d0da2 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 
+#include "libavutil/tx.h"
 #include "libavutil/avassert.h"
 #include "libavutil/float_dsp.h"
 
@@ -36,7 +37,6 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "fft.h"
 #include "get_bits.h"
 #include "vorbis.h"
 #include "vorbisdsp.h"
@@ -129,7 +129,8 @@ typedef struct vorbis_context_s {
 VorbisDSPContext dsp;
 AVFloatDSPContext *fdsp;
 
-FFTContext mdct[2];
+AVTXContext *tx[2];
+av_tx_fn tx_fn[2];
 uint8_t   first_frame;
 int64_t   initial_pts;
 uint32_t  version;
@@ -201,8 +202,8 @@ static void vorbis_free(vorbis_context *vc)
 av_freep(>residues);
 av_freep(>modes);
 
-ff_mdct_end(>mdct[0]);
-ff_mdct_end(>mdct[1]);
+av_tx_uninit(>tx[0]);
+av_tx_uninit(>tx[1]);
 
 if (vc->codebooks)
 for (i = 0; i < vc->codebook_count; ++i) {
@@ -961,6 +962,8 @@ static int vorbis_parse_setup_hdr(vorbis_context *vc)
 
 static int vorbis_parse_id_hdr(vorbis_context *vc)
 {
+int ret;
+const float mdct_scale = -1.0f;
 GetBitContext *gb = >gb;
 unsigned bl0, bl1;
 
@@ -1008,8 +1011,14 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
 
 vc->previous_window  = -1;
 
-ff_mdct_init(>mdct[0], bl0, 1, -1.0);
-ff_mdct_init(>mdct[1], bl1, 1, -1.0);
+if ((ret = av_tx_init(>tx[0], >tx_fn[0], AV_TX_FLOAT_MDCT, 1, 1 << (bl0 - 1),
+  _scale, 0)))
+return ret;
+
+if ((ret = av_tx_init(>tx[1], >tx_fn[1], AV_TX_FLOAT_MDCT, 1, 1 << (bl1 - 1),
+  _scale, 0)))
+return ret;
+
 vc->fdsp = avpriv_float_dsp_alloc(vc->avctx->flags & AV_CODEC_FLAG_BITEXACT);
 if (!vc->fdsp)
 return AVERROR(ENOMEM);
@@ -1584,7 +1593,8 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
 static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
 {
 GetBitContext *gb = >gb;
-FFTContext *mdct;
+AVTXContext *tx;
+av_tx_fn tx_fn;
 int previous_window = vc->previous_window;
 unsigned mode_number, blockflag, blocksize;
 int i, j;
@@ -1706,12 +1716,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
 
 // Dotproduct, MDCT
 
-mdct = >mdct[blockflag];
+tx = vc->tx[blockflag];
+tx_fn = vc->tx_fn[blockflag];
 
 for (j = vc->audio_channels-1;j >= 0; j--) {
 ch_res_ptr   = vc->channel_residues + res_chan[j] * blocksize / 2;
 vc->fdsp->vector_fmul(floor_ptr[j], floor_ptr[j], ch_res_ptr, blocksize / 2);
-mdct->imdct_half(mdct, ch_res_ptr, floor_ptr[j]);
+tx_fn(tx, ch_res_ptr, floor_ptr[j], sizeof(float));
 }
 
 // Overlap/add, save data for next overlapping
-- 
2.37.2.609.g9ff673ca1a

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

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


[FFmpeg-devel] [PATCH 3/6] ac3: convert encoder and decoder to lavu/tx

2022-09-23 Thread Lynne
The fixed-point transforms are much better, faster, and more accurate.

Patch attached.

>From e54775cc93ceb27d9faabe1ddf9b1eacb269826b Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 01:05:19 +0200
Subject: [PATCH 3/6] ac3: convert encoder and decoder to lavu/tx

The fixed-point transforms are much better, faster, and more accurate.
---
 libavcodec/ac3dec.c  | 22 +-
 libavcodec/ac3dec.h  |  6 +++---
 libavcodec/ac3dec_fixed.c|  3 ++-
 libavcodec/ac3dec_float.c|  1 +
 libavcodec/ac3enc.c  |  2 +-
 libavcodec/ac3enc.h  |  7 ---
 libavcodec/ac3enc_fixed.c| 19 ---
 libavcodec/ac3enc_float.c| 18 +++---
 libavcodec/ac3enc_template.c |  4 ++--
 9 files changed, 33 insertions(+), 49 deletions(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index aba8e0fb7f..cd3320caa0 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -217,13 +217,17 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
 {
 static AVOnce init_static_once = AV_ONCE_INIT;
 AC3DecodeContext *s = avctx->priv_data;
+const float scale = 1.0f;
 int i, ret;
 
 s->avctx = avctx;
 
-if ((ret = ff_mdct_init(>imdct_256, 8, 1, 1.0)) < 0 ||
-(ret = ff_mdct_init(>imdct_512, 9, 1, 1.0)) < 0)
+if ((ret = av_tx_init(>tx_128, >tx_fn_128, IMDCT_TYPE, 1, 128, , 0)))
 return ret;
+
+if ((ret = av_tx_init(>tx_256, >tx_fn_256, IMDCT_TYPE, 1, 256, , 0)))
+return ret;
+
 AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
 ff_bswapdsp_init(>bdsp);
 
@@ -721,10 +725,10 @@ static inline void do_imdct(AC3DecodeContext *s, int channels, int offset)
 for (ch = 1; ch <= channels; ch++) {
 if (s->block_switch[ch]) {
 int i;
-FFTSample *x = s->tmp_output + 128;
+INTFLOAT *x = s->tmp_output + 128;
 for (i = 0; i < 128; i++)
 x[i] = s->transform_coeffs[ch][2 * i];
-s->imdct_256.imdct_half(>imdct_256, s->tmp_output, x);
+s->tx_fn_128(s->tx_128, s->tmp_output, x, sizeof(INTFLOAT));
 #if USE_FIXED
 s->fdsp->vector_fmul_window_scaled(s->outptr[ch - 1], s->delay[ch - 1 + offset],
s->tmp_output, s->window, 128, 8);
@@ -734,9 +738,9 @@ static inline void do_imdct(AC3DecodeContext *s, int channels, int offset)
 #endif
 for (i = 0; i < 128; i++)
 x[i] = s->transform_coeffs[ch][2 * i + 1];
-s->imdct_256.imdct_half(>imdct_256, s->delay[ch - 1 + offset], x);
+s->tx_fn_256(s->tx_256, s->delay[ch - 1 + offset], x, sizeof(INTFLOAT));
 } else {
-s->imdct_512.imdct_half(>imdct_512, s->tmp_output, s->transform_coeffs[ch]);
+s->tx_fn_256(s->tx_256, s->tmp_output, s->transform_coeffs[ch], sizeof(INTFLOAT));
 #if USE_FIXED
 s->fdsp->vector_fmul_window_scaled(s->outptr[ch - 1], s->delay[ch - 1 + offset],
s->tmp_output, s->window, 128, 8);
@@ -744,7 +748,7 @@ static inline void do_imdct(AC3DecodeContext *s, int channels, int offset)
 s->fdsp->vector_fmul_window(s->outptr[ch - 1], s->delay[ch - 1 + offset],
s->tmp_output, s->window, 128);
 #endif
-memcpy(s->delay[ch - 1 + offset], s->tmp_output + 128, 128 * sizeof(FFTSample));
+memcpy(s->delay[ch - 1 + offset], s->tmp_output + 128, 128 * sizeof(INTFLOAT));
 }
 }
 }
@@ -1865,8 +1869,8 @@ skip:
 static av_cold int ac3_decode_end(AVCodecContext *avctx)
 {
 AC3DecodeContext *s = avctx->priv_data;
-ff_mdct_end(>imdct_512);
-ff_mdct_end(>imdct_256);
+av_tx_uninit(>tx_256);
+av_tx_uninit(>tx_128);
 av_freep(>fdsp);
 av_freep(>downmix_coeffs[0]);
 
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 88651ae61f..138b462abb 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -50,6 +50,7 @@
 #ifndef AVCODEC_AC3DEC_H
 #define AVCODEC_AC3DEC_H
 
+#include "libavutil/tx.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
 #include "libavutil/lfg.h"
@@ -60,7 +61,6 @@
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "get_bits.h"
-#include "fft.h"
 #include "fmtconvert.h"
 
 #define AC3_OUTPUT_LFEON  8
@@ -223,8 +223,8 @@ typedef struct AC3DecodeContext {
 
 ///@name IMDCT
 int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw)
-FFTContext imdct_512;   ///< for 512 sample IMDCT
-FFTContext imdct_256;   ///< for 256 sample IMDCT
+AVTXContext *tx_128, *tx_256;
+av_tx_fn tx_fn_128, tx_fn_256;
 ///@}
 
 ///@name Optimization
diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
index 0a7ae6cfbf..c9e5cda69c 100644
--- a/libavcodec/ac3dec_fixed.c
+++ b/libavcodec/ac3dec_fixed.c
@@ -47,11 +47,12 @@
  * Foundation, Inc., 51 Franklin 

[FFmpeg-devel] [PATCH 2/6] atrac9dec: switch to lavu/tx

2022-09-23 Thread Lynne
Patch attached.

>From 5a310246569e19efd50b37016a80fe6171df0329 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 00:51:18 +0200
Subject: [PATCH 2/6] atrac9dec: switch to lavu/tx

---
 libavcodec/atrac9dec.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index d3a5d05799..60962b1676 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -25,8 +25,8 @@
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "fft.h"
 #include "atrac9tab.h"
+#include "libavutil/tx.h"
 #include "libavutil/lfg.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
@@ -86,7 +86,8 @@ typedef struct ATRAC9BlockData {
 typedef struct ATRAC9Context {
 AVCodecContext *avctx;
 AVFloatDSPContext *fdsp;
-FFTContext imdct;
+AVTXContext *tx;
+av_tx_fn tx_fn;
 ATRAC9BlockData block[5];
 AVLFG lfg;
 
@@ -101,7 +102,7 @@ typedef struct ATRAC9Context {
 uint8_t alloc_curve[48][48];
 DECLARE_ALIGNED(32, float, imdct_win)[256];
 
-DECLARE_ALIGNED(32, float, temp)[256];
+DECLARE_ALIGNED(32, float, temp)[2048];
 } ATRAC9Context;
 
 static VLC sf_vlc[2][8];/* Signed/unsigned, length */
@@ -778,7 +779,7 @@ imdct:
 const ptrdiff_t offset = wsize*frame_idx*sizeof(float);
 float *dst = (float *)(frame->extended_data[dst_idx] + offset);
 
-s->imdct.imdct_half(>imdct, s->temp, c->coeffs);
+s->tx_fn(s->tx, s->temp, c->coeffs, sizeof(float));
 s->fdsp->vector_fmul_window(dst, c->prev_win, s->temp,
 s->imdct_win, wsize >> 1);
 memcpy(c->prev_win, s->temp + (wsize >> 1), sizeof(float)*wsize >> 1);
@@ -834,7 +835,7 @@ static av_cold int atrac9_decode_close(AVCodecContext *avctx)
 {
 ATRAC9Context *s = avctx->priv_data;
 
-ff_mdct_end(>imdct);
+av_tx_uninit(>tx);
 av_freep(>fdsp);
 
 return 0;
@@ -896,10 +897,11 @@ static av_cold void atrac9_init_static(void)
 
 static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 {
+float scale;
 static AVOnce static_table_init = AV_ONCE_INIT;
 GetBitContext gb;
 ATRAC9Context *s = avctx->priv_data;
-int version, block_config_idx, superframe_idx, alloc_c_len;
+int err, version, block_config_idx, superframe_idx, alloc_c_len;
 
 s->avctx = avctx;
 
@@ -959,8 +961,11 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 s->frame_count = 1 << superframe_idx;
 s->frame_log2  = at9_tab_sri_frame_log2[s->samplerate_idx];
 
-if (ff_mdct_init(>imdct, s->frame_log2 + 1, 1, 1.0f / 32768.0f))
-return AVERROR(ENOMEM);
+scale = 1.0f / 32768.0;
+err = av_tx_init(>tx, >tx_fn, AV_TX_FLOAT_MDCT, 1,
+ 1 << s->frame_log2, , 0);
+if (err < 0)
+return err;
 
 s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 if (!s->fdsp)
-- 
2.37.2.609.g9ff673ca1a

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

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


[FFmpeg-devel] [PATCH 1/6] opus: convert encoder and decoder to lavu/tx

2022-09-23 Thread Lynne
This commit changes both the encoder and decoder to use the new lavu/tx code,
which has faster C transforms and more assembly optimizations.

Patch attached.

>From d4fdda5b57ab1e0f08eb3d78dac6b003060dfd41 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 24 Sep 2022 00:46:44 +0200
Subject: [PATCH 1/6] opus: convert encoder and decoder to lavu/tx

This commit changes both the encoder and decoder to use the new lavu/tx code,
which has faster C transforms and more assembly optimizations.
---
 libavcodec/opus_celt.c   | 20 
 libavcodec/opus_celt.h   |  5 +++--
 libavcodec/opusenc.c | 15 +--
 libavcodec/opusenc_psy.c | 13 -
 libavcodec/opusenc_psy.h |  4 +++-
 5 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
index 9dbeff1927..f1fb88a56d 100644
--- a/libavcodec/opus_celt.c
+++ b/libavcodec/opus_celt.c
@@ -323,7 +323,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
 {
 int i, j, downmix = 0;
 int consumed;   // bits of entropy consumed thus far for this frame
-MDCT15Context *imdct;
+AVTXContext *imdct;
+av_tx_fn imdct_fn;
 
 if (channels != 1 && channels != 2) {
 av_log(f->avctx, AV_LOG_ERROR, "Invalid number of coded channels: %d\n",
@@ -385,7 +386,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
 f->blocks= f->transient ? 1 << f->size : 1;
 f->blocksize = frame_size / f->blocks;
 
-imdct = f->imdct[f->transient ? 0 : f->size];
+imdct = f->tx[f->transient ? 0 : f->size];
+imdct_fn = f->tx_fn[f->transient ? 0 : f->size];
 
 if (channels == 1) {
 for (i = 0; i < CELT_MAX_BANDS; i++)
@@ -440,8 +442,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
 for (j = 0; j < f->blocks; j++) {
 float *dst  = block->buf + 1024 + j * f->blocksize;
 
-imdct->imdct_half(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j,
-  f->blocks);
+imdct_fn(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j,
+ sizeof(float)*f->blocks);
 f->dsp->vector_fmul_window(dst, dst, dst + CELT_OVERLAP / 2,
ff_celt_window, CELT_OVERLAP / 2);
 }
@@ -526,8 +528,8 @@ void ff_celt_free(CeltFrame **f)
 if (!frm)
 return;
 
-for (i = 0; i < FF_ARRAY_ELEMS(frm->imdct); i++)
-ff_mdct15_uninit(>imdct[i]);
+for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++)
+av_tx_uninit(>tx[i]);
 
 ff_celt_pvq_uninit(>pvq);
 
@@ -555,9 +557,11 @@ int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels,
 frm->output_channels = output_channels;
 frm->apply_phase_inv = apply_phase_inv;
 
-for (i = 0; i < FF_ARRAY_ELEMS(frm->imdct); i++)
-if ((ret = ff_mdct15_init(>imdct[i], 1, i + 3, -1.0f/32768)) < 0)
+for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++) {
+const float scale = -1.0f/32768;
+if ((ret = av_tx_init(>tx[i], >tx_fn[i], AV_TX_FLOAT_MDCT, 1, 15 << (i + 3), , 0)) < 0)
 goto fail;
+}
 
 if ((ret = ff_celt_pvq_init(>pvq, 0)) < 0)
 goto fail;
diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h
index 661ca251de..291a544298 100644
--- a/libavcodec/opus_celt.h
+++ b/libavcodec/opus_celt.h
@@ -30,10 +30,10 @@
 #include "opus_pvq.h"
 #include "opusdsp.h"
 
-#include "mdct15.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
 #include "libavutil/mem_internal.h"
+#include "libavutil/tx.h"
 
 #define CELT_VECTORS 11
 #define CELT_ALLOC_STEPS 6
@@ -93,7 +93,8 @@ typedef struct CeltBlock {
 struct CeltFrame {
 // constant values that do not change during context lifetime
 AVCodecContext  *avctx;
-MDCT15Context   *imdct[4];
+AVTXContext*tx[4];
+av_tx_fntx_fn[4];
 AVFloatDSPContext   *dsp;
 CeltBlock   block[2];
 CeltPVQ *pvq;
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index a7a9d3a5f5..8cdd27d930 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -40,7 +40,8 @@ typedef struct OpusEncContext {
 AVCodecContext *avctx;
 AudioFrameQueue afq;
 AVFloatDSPContext *dsp;
-MDCT15Context *mdct[CELT_BLOCK_NB];
+AVTXContext *tx[CELT_BLOCK_NB];
+av_tx_fn tx_fn[CELT_BLOCK_NB];
 CeltPVQ *pvq;
 struct FFBufQueue bufqueue;
 
@@ -204,7 +205,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f)
 s->dsp->vector_fmul_reverse([CELT_OVERLAP], src2,
 ff_celt_window - 8, 128);
 src1 = src2;
-s->mdct[0]->mdct(s->mdct[0], b->coeffs + t, win, f->blocks);
+s->tx_fn[0](s->tx[0], b->coeffs + t, win, sizeof(float)*f->blocks);
 }
 }
 } else {
@@ -226,7 +227,7 @@ static void 

Re: [FFmpeg-devel] [PATCH v2] avformat/cafenc: derive Opus frame size from the relevant stream parameters

2022-09-23 Thread James Almer

On 9/22/2022 8:14 PM, James Almer wrote:

Use the stream duration as last resort, as an off-by-one result of the
"st->duration / (caf->packets - 1)" calculation can break playback on some
devices.
Also, don't write the sample_rate value propagated by encoders like libopus.
The sample rate of the audio fed to it is irrelevant for the container after
being encoded.

Fixes ticket #9930.

Signed-off-by: James Almer 
---
  libavformat/cafenc.c | 19 ++-
  1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index fedb430b17..b90811d46f 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -53,7 +53,11 @@ static uint32_t codec_flags(enum AVCodecID codec_id) {
  }
  }
  
-static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align) {

+static uint32_t samples_per_packet(const AVCodecParameters *par) {
+enum AVCodecID codec_id = par->codec_id;
+int channels = par->ch_layout.nb_channels, block_align = par->block_align;
+int frame_size = par->frame_size, sample_rate = par->sample_rate;
+
  switch (codec_id) {
  case AV_CODEC_ID_PCM_S8:
  case AV_CODEC_ID_PCM_S16LE:
@@ -83,6 +87,8 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, 
int channels, int bl
  return 320;
  case AV_CODEC_ID_MP1:
  return 384;
+case AV_CODEC_ID_OPUS:
+return frame_size * 48000 / sample_rate;
  case AV_CODEC_ID_MP2:
  case AV_CODEC_ID_MP3:
  return 1152;
@@ -110,7 +116,7 @@ static int caf_write_header(AVFormatContext *s)
  AVDictionaryEntry *t = NULL;
  unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, 
par->codec_id);
  int64_t chunk_size = 0;
-int frame_size = par->frame_size;
+int frame_size = par->frame_size, sample_rate = par->sample_rate;
  
  if (s->nb_streams != 1) {

  av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n");
@@ -139,7 +145,10 @@ static int caf_write_header(AVFormatContext *s)
  }
  
  if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)

-frame_size = samples_per_packet(par->codec_id, 
par->ch_layout.nb_channels, par->block_align);
+frame_size = samples_per_packet(par);
+
+if (par->codec_id == AV_CODEC_ID_OPUS)
+sample_rate = 48000;
  
  ffio_wfourcc(pb, "caff"); //< mFileType

  avio_wb16(pb, 1); //< mFileVersion
@@ -147,7 +156,7 @@ static int caf_write_header(AVFormatContext *s)
  
  ffio_wfourcc(pb, "desc"); //< Audio Description chunk

  avio_wb64(pb, 32);//< mChunkSize
-avio_wb64(pb, av_double2int(par->sample_rate));   //< mSampleRate
+avio_wb64(pb, av_double2int(sample_rate));//< mSampleRate
  avio_wl32(pb, codec_tag); //< mFormatID
  avio_wb32(pb, codec_flags(par->codec_id));//< mFormatFlags
  avio_wb32(pb, par->block_align);  //< mBytesPerPacket
@@ -248,7 +257,7 @@ static int caf_write_trailer(AVFormatContext *s)
  avio_seek(pb, caf->data, SEEK_SET);
  avio_wb64(pb, file_size - caf->data - 8);
  if (!par->block_align) {
-int packet_size = samples_per_packet(par->codec_id, 
par->ch_layout.nb_channels, par->block_align);
+int packet_size = samples_per_packet(par);
  if (!packet_size) {
  packet_size = st->duration / (caf->packets - 1);
  avio_seek(pb, FRAME_SIZE_OFFSET, SEEK_SET);


Will apply.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/9] avformat/ape: Check frames size

2022-09-23 Thread Michael Niedermayer
On Sat, Sep 17, 2022 at 11:15:49PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 9223372036854775806 + 3 cannot be represented 
> in type 'long'
> Fixes: 
> 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APE_fuzzer-6389264140599296
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/ape.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] libavcodec/qsvenc: fixy typo for min/max qp reset

2022-09-23 Thread Dmitry Rogozhkin
Fixes: 005c7a4 ("libavcodec/qsvenc: Add max/min qp reset support in qsvenc")
CC: Wenbin Chen 
Signed-off-by: Dmitry Rogozhkin 
---
 libavcodec/qsvenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 84c6e29..8bd9272 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1760,8 +1760,8 @@ static int update_min_max_qp(AVCodecContext *avctx, 
QSVEncContext *q)
 if (avctx->codec_id != AV_CODEC_ID_H264)
 return 0;
 
-UPDATE_PARAM(q->old_qmax, avctx->qmin);
-UPDATE_PARAM(q->old_qmax, avctx->qmin);
+UPDATE_PARAM(q->old_qmin, avctx->qmin);
+UPDATE_PARAM(q->old_qmax, avctx->qmax);
 UPDATE_PARAM(q->old_min_qp_i, q->min_qp_i);
 UPDATE_PARAM(q->old_max_qp_i, q->max_qp_i);
 UPDATE_PARAM(q->old_min_qp_p, q->min_qp_p);
-- 
1.8.3.1

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

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


Re: [FFmpeg-devel] [PATCH 01/13] avformat/flvdec: Use 64bit for sum_flv_tag_size

2022-09-23 Thread Michael Niedermayer
On Sun, Sep 18, 2022 at 07:13:58PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2138820085 + 16130322 cannot be represented 
> in type 'int'
> Fixes: 
> 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6704728165187584
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/flvdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

i intend to apply this patchset (minus anything with objections) soon

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/parser: Remove declaration of inexistent function

2022-09-23 Thread Andreas Rheinhardt
Forgotten in e5af9203098a889f36b759652615046254d45102.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/parser.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/parser.h b/libavcodec/parser.h
index ef35547e9b..2cee5ae4ff 100644
--- a/libavcodec/parser.h
+++ b/libavcodec/parser.h
@@ -45,8 +45,6 @@ typedef struct ParseContext{
  * AVERROR(ENOMEM) if there was a memory allocation error
  */
 int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int 
*buf_size);
-int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf,
-int buf_size);
 void ff_parse_close(AVCodecParserContext *s);
 
 /**
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/opusdec: stop setting deprecated swr options

2022-09-23 Thread Andreas Rheinhardt
James Almer:
> On 9/23/2022 4:55 PM, Andreas Rheinhardt wrote:
>> James Almer:
>>> Signed-off-by: James Almer 
>>> ---
>>>   libavcodec/opusdec.c | 11 +++
>>>   1 file changed, 7 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
>>> index c04aa598b8..8b10bd1a25 100644
>>> --- a/libavcodec/opusdec.c
>>> +++ b/libavcodec/opusdec.c
>>> @@ -640,7 +640,7 @@ static av_cold int
>>> opus_decode_init(AVCodecContext *avctx)
>>>     for (i = 0; i < c->nb_streams; i++) {
>>>   OpusStreamContext *s = >streams[i];
>>> -    uint64_t layout;
>>> +    AVChannelLayout layout;
>>>     s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1;
>>>   @@ -658,14 +658,17 @@ static av_cold int
>>> opus_decode_init(AVCodecContext *avctx)
>>>   if (!s->swr)
>>>   return AVERROR(ENOMEM);
>>>   -    layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO :
>>> AV_CH_LAYOUT_STEREO;
>>> +    layout = (s->output_channels == 1) ?
>>> (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO :
>>> +
>>> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>>>   av_opt_set_int(s->swr, "in_sample_fmt", 
>>> avctx->sample_fmt,  0);
>>>   av_opt_set_int(s->swr, "out_sample_fmt",
>>> avctx->sample_fmt,  0);
>>> -    av_opt_set_int(s->swr, "in_channel_layout", 
>>> layout, 0);
>>> -    av_opt_set_int(s->swr, "out_channel_layout",
>>> layout, 0);
>>> +    av_opt_set_chlayout(s->swr, "in_chlayout",  
>>> ,    0);
>>> +    av_opt_set_chlayout(s->swr, "out_chlayout", 
>>> ,    0);
>>>   av_opt_set_int(s->swr, "out_sample_rate",   
>>> avctx->sample_rate, 0);
>>>   av_opt_set_int(s->swr, "filter_size",   
>>> 16, 0);
>>>   +    av_channel_layout_uninit();
>>
>> Unnecessary. You are not even using any of the av_channel_layout*
>> function to init layout.
> 
> I know it's unnecessary, but it's to promote the good habit of
> uninitializing layouts when you're done with them.
> 

A habit of unnecessary calls is not good.

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/opusdec: stop setting deprecated swr options

2022-09-23 Thread James Almer

On 9/23/2022 4:55 PM, Andreas Rheinhardt wrote:

James Almer:

Signed-off-by: James Almer 
---
  libavcodec/opusdec.c | 11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index c04aa598b8..8b10bd1a25 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -640,7 +640,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
  
  for (i = 0; i < c->nb_streams; i++) {

  OpusStreamContext *s = >streams[i];
-uint64_t layout;
+AVChannelLayout layout;
  
  s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1;
  
@@ -658,14 +658,17 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)

  if (!s->swr)
  return AVERROR(ENOMEM);
  
-layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;

+layout = (s->output_channels == 1) ? 
(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO :
+ 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
  av_opt_set_int(s->swr, "in_sample_fmt",  avctx->sample_fmt,  0);
  av_opt_set_int(s->swr, "out_sample_fmt", avctx->sample_fmt,  0);
-av_opt_set_int(s->swr, "in_channel_layout",  layout, 0);
-av_opt_set_int(s->swr, "out_channel_layout", layout, 0);
+av_opt_set_chlayout(s->swr, "in_chlayout",   ,0);
+av_opt_set_chlayout(s->swr, "out_chlayout",  ,0);
  av_opt_set_int(s->swr, "out_sample_rate",avctx->sample_rate, 0);
  av_opt_set_int(s->swr, "filter_size",16, 0);
  
+av_channel_layout_uninit();


Unnecessary. You are not even using any of the av_channel_layout*
function to init layout.


I know it's unnecessary, but it's to promote the good habit of 
uninitializing layouts when you're done with them.





+
  ret = ff_silk_init(avctx, >silk, s->output_channels);
  if (ret < 0)
  return ret;


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

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

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer

2022-09-23 Thread Andreas Rheinhardt
Tomas Härdin:
> fre 2022-09-23 klockan 20:48 +0200 skrev Andreas Rheinhardt:
>> Tomas Härdin:
>>> fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt:
 That way the SAR will be automatically set on the AVFrame.

 Signed-off-by: Andreas Rheinhardt
 
 ---
 If I am not mistaken, then the earlier code would set the sar
 with a delay of one frame on the returned frames in case
 there is a sar change mid-stream. But I don't have a sample
 for this.

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

 diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
 index 7d9661f29f..c3f2a7aa03 100644
 --- a/libavcodec/jpeg2000dec.c
 +++ b/libavcodec/jpeg2000dec.c
 @@ -2519,6 +2519,10 @@ static int
 jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
  if (ret = jpeg2000_read_main_headers(s))
  goto end;
  
 +    if (s->sar.num && s->sar.den)
 +    avctx->sample_aspect_ratio = s->sar;
 +    s->sar.num = s->sar.den = 0;
 +
  /* get picture buffer */
  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
  goto end;
 @@ -2547,9 +2551,6 @@ static int
 jpeg2000_decode_frame(AVCodecContext
 *avctx, AVFrame *picture,
  
  if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
  memcpy(picture->data[1], s->palette, 256 *
 sizeof(uint32_t));
 -    if (s->sar.num && s->sar.den)
 -    avctx->sample_aspect_ratio = s->sar;
 -    s->sar.num = s->sar.den = 0;
>>>
>>> I suspect not doing this is what caused my simple hack to not work
>>> when
>>> ff_thread_get_buffer() was skipped. Looks OK, passes FATE.
>>>
>>
>> FYI: Patch two passes FATE even without patch one. In what way did
>> your
>> simple hack not work when ff_thread_get_buffer() is skipped?
> 
> I had it like patch attached. I suspect the reason it didn't work is
> because it sets *got_frame. If I run it then I get
> 
>   Assertion frame->buf[0] failed at libavcodec/decode.c:502
>   Avbruten (SIGABRT)
> 
> /Tomas
> 

Yeah, that's not how it's supposed to work. Will apply my patches.
Thanks for the review.

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/opusdec: stop setting deprecated swr options

2022-09-23 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
>  libavcodec/opusdec.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
> index c04aa598b8..8b10bd1a25 100644
> --- a/libavcodec/opusdec.c
> +++ b/libavcodec/opusdec.c
> @@ -640,7 +640,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
>  
>  for (i = 0; i < c->nb_streams; i++) {
>  OpusStreamContext *s = >streams[i];
> -uint64_t layout;
> +AVChannelLayout layout;
>  
>  s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1;
>  
> @@ -658,14 +658,17 @@ static av_cold int opus_decode_init(AVCodecContext 
> *avctx)
>  if (!s->swr)
>  return AVERROR(ENOMEM);
>  
> -layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : 
> AV_CH_LAYOUT_STEREO;
> +layout = (s->output_channels == 1) ? 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO :
> + 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>  av_opt_set_int(s->swr, "in_sample_fmt",  avctx->sample_fmt,  0);
>  av_opt_set_int(s->swr, "out_sample_fmt", avctx->sample_fmt,  0);
> -av_opt_set_int(s->swr, "in_channel_layout",  layout, 0);
> -av_opt_set_int(s->swr, "out_channel_layout", layout, 0);
> +av_opt_set_chlayout(s->swr, "in_chlayout",   ,0);
> +av_opt_set_chlayout(s->swr, "out_chlayout",  ,0);
>  av_opt_set_int(s->swr, "out_sample_rate",avctx->sample_rate, 0);
>  av_opt_set_int(s->swr, "filter_size",16, 0);
>  
> +av_channel_layout_uninit();

Unnecessary. You are not even using any of the av_channel_layout*
function to init layout.

> +
>  ret = ff_silk_init(avctx, >silk, s->output_channels);
>  if (ret < 0)
>  return ret;

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

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


[FFmpeg-devel] [PATCH] avcodec/opusdec: stop setting deprecated swr options

2022-09-23 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/opusdec.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index c04aa598b8..8b10bd1a25 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -640,7 +640,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
 
 for (i = 0; i < c->nb_streams; i++) {
 OpusStreamContext *s = >streams[i];
-uint64_t layout;
+AVChannelLayout layout;
 
 s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1;
 
@@ -658,14 +658,17 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
 if (!s->swr)
 return AVERROR(ENOMEM);
 
-layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : 
AV_CH_LAYOUT_STEREO;
+layout = (s->output_channels == 1) ? 
(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO :
+ 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 av_opt_set_int(s->swr, "in_sample_fmt",  avctx->sample_fmt,  0);
 av_opt_set_int(s->swr, "out_sample_fmt", avctx->sample_fmt,  0);
-av_opt_set_int(s->swr, "in_channel_layout",  layout, 0);
-av_opt_set_int(s->swr, "out_channel_layout", layout, 0);
+av_opt_set_chlayout(s->swr, "in_chlayout",   ,0);
+av_opt_set_chlayout(s->swr, "out_chlayout",  ,0);
 av_opt_set_int(s->swr, "out_sample_rate",avctx->sample_rate, 0);
 av_opt_set_int(s->swr, "filter_size",16, 0);
 
+av_channel_layout_uninit();
+
 ret = ff_silk_init(avctx, >silk, s->output_channels);
 if (ret < 0)
 return ret;
-- 
2.37.3

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer

2022-09-23 Thread Tomas Härdin
fre 2022-09-23 klockan 20:48 +0200 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt:
> > > That way the SAR will be automatically set on the AVFrame.
> > > 
> > > Signed-off-by: Andreas Rheinhardt
> > > 
> > > ---
> > > If I am not mistaken, then the earlier code would set the sar
> > > with a delay of one frame on the returned frames in case
> > > there is a sar change mid-stream. But I don't have a sample
> > > for this.
> > > 
> > >  libavcodec/jpeg2000dec.c | 7 ---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > > index 7d9661f29f..c3f2a7aa03 100644
> > > --- a/libavcodec/jpeg2000dec.c
> > > +++ b/libavcodec/jpeg2000dec.c
> > > @@ -2519,6 +2519,10 @@ static int
> > > jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
> > >  if (ret = jpeg2000_read_main_headers(s))
> > >  goto end;
> > >  
> > > +    if (s->sar.num && s->sar.den)
> > > +    avctx->sample_aspect_ratio = s->sar;
> > > +    s->sar.num = s->sar.den = 0;
> > > +
> > >  /* get picture buffer */
> > >  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
> > >  goto end;
> > > @@ -2547,9 +2551,6 @@ static int
> > > jpeg2000_decode_frame(AVCodecContext
> > > *avctx, AVFrame *picture,
> > >  
> > >  if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
> > >  memcpy(picture->data[1], s->palette, 256 *
> > > sizeof(uint32_t));
> > > -    if (s->sar.num && s->sar.den)
> > > -    avctx->sample_aspect_ratio = s->sar;
> > > -    s->sar.num = s->sar.den = 0;
> > 
> > I suspect not doing this is what caused my simple hack to not work
> > when
> > ff_thread_get_buffer() was skipped. Looks OK, passes FATE.
> > 
> 
> FYI: Patch two passes FATE even without patch one. In what way did
> your
> simple hack not work when ff_thread_get_buffer() is skipped?

I had it like patch attached. I suspect the reason it didn't work is
because it sets *got_frame. If I run it then I get

  Assertion frame->buf[0] failed at libavcodec/decode.c:502
  Avbruten (SIGABRT)

/Tomas
From e5ca5e47053b7d7ba130eec01576df041196d5d4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Fri, 23 Sep 2022 17:41:41 +0200
Subject: [PATCH] HACKHACK

---
 libavcodec/jpeg2000dec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7d9661f29f..8cab440d13 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2519,6 +2519,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
 if (ret = jpeg2000_read_main_headers(s))
 goto end;
 
+if (avctx->skip_frame < AVDISCARD_ALL) {
 /* get picture buffer */
 if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
 goto end;
@@ -2540,6 +2541,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
 }
 
 avctx->execute2(avctx, jpeg2000_decode_tile, picture, NULL, s->numXtiles * s->numYtiles);
+}
 
 jpeg2000_dec_cleanup(s);
 
@@ -2586,4 +2588,5 @@ const FFCodec ff_jpeg2000_decoder = {
 .p.priv_class = _class,
 .p.max_lowres = 5,
 .p.profiles   = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),
+.caps_internal= FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 };
-- 
2.30.2

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

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


Re: [FFmpeg-devel] [PATCH 1/1] fate/opus: add silk LBRR test (refs #9890)

2022-09-23 Thread Tristan Matthews
On Fri, Sep 23, 2022 at 8:15 AM Andreas Rheinhardt
 wrote:
>
> Tristan Matthews:
> > On Thu, Sep 8, 2022 at 3:58 PM Tristan Matthews  wrote:
> >
> >> This adds a fate test for a sample with LBRR packets.
> >>
> >> It requires that these files be uploaded:
> >> https://people.videolan.org/~tmatth/9890-fate/silk-lbrr.mka
> >> https://people.videolan.org/~tmatth/9890-fate/silk-lbrr.dec
> >>
> >> ---
> >>  tests/fate/opus.mak | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/tests/fate/opus.mak b/tests/fate/opus.mak
> >> index 573044ed15..7d359f414a 100644
> >> --- a/tests/fate/opus.mak
> >> +++ b/tests/fate/opus.mak
> >> @@ -4,7 +4,7 @@
> >>
> >>  OPUS_CELT_SAMPLES   = $(addprefix testvector, 01 11) tron.6ch.tinypkts
> >>  OPUS_HYBRID_SAMPLES = $(addprefix testvector, 05 06)
> >> -OPUS_SILK_SAMPLES   = $(addprefix testvector, 02 03 04)
> >> +OPUS_SILK_SAMPLES   = $(addprefix testvector, 02 03 04) silk-lbrr
> >>  OPUS_OTHER_SAMPLES  = $(addprefix testvector, 07 08 09 10 12)
> >>
> >>  define FATE_OPUS_TEST
> >> @@ -33,6 +33,7 @@ fate-opus-testvector09:  CMP_TARGET = 0
> >>  fate-opus-testvector10:  CMP_TARGET = 38
> >>  fate-opus-testvector11:  CMP_TARGET = 0
> >>  fate-opus-testvector12:  CMP_TARGET = 160
> >> +fate-opus-silk-lbrr: CMP_TARGET = 0
> >>  fate-opus-tron.6ch.tinypkts: CMP_SHIFT = 1440
> >>  fate-opus-tron.6ch.tinypkts: CMP_TARGET = 0
> >>
> >> --
> >> 2.34.1
> >>
> >
> >
> > Sorry this was supposed to be in response to
> > http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/300758.html (as it
> > depends on it) but I screwed up the git-send-email.
> >
>
> Does this sample have to be so long?

I've shortened it from 4 seconds to 1 second (which is still long
enough to hear the bug when using an older build).
Note that most of the opus test vectors are on the order of 25 seconds.

Best,
Tristan

>
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer

2022-09-23 Thread Andreas Rheinhardt
Tomas Härdin:
> fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt:
>> That way the SAR will be automatically set on the AVFrame.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> If I am not mistaken, then the earlier code would set the sar
>> with a delay of one frame on the returned frames in case
>> there is a sar change mid-stream. But I don't have a sample
>> for this.
>>
>>  libavcodec/jpeg2000dec.c | 7 ---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
>> index 7d9661f29f..c3f2a7aa03 100644
>> --- a/libavcodec/jpeg2000dec.c
>> +++ b/libavcodec/jpeg2000dec.c
>> @@ -2519,6 +2519,10 @@ static int
>> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
>>  if (ret = jpeg2000_read_main_headers(s))
>>  goto end;
>>  
>> +    if (s->sar.num && s->sar.den)
>> +    avctx->sample_aspect_ratio = s->sar;
>> +    s->sar.num = s->sar.den = 0;
>> +
>>  /* get picture buffer */
>>  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
>>  goto end;
>> @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext
>> *avctx, AVFrame *picture,
>>  
>>  if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
>>  memcpy(picture->data[1], s->palette, 256 *
>> sizeof(uint32_t));
>> -    if (s->sar.num && s->sar.den)
>> -    avctx->sample_aspect_ratio = s->sar;
>> -    s->sar.num = s->sar.den = 0;
> 
> I suspect not doing this is what caused my simple hack to not work when
> ff_thread_get_buffer() was skipped. Looks OK, passes FATE.
> 

FYI: Patch two passes FATE even without patch one. In what way did your
simple hack not work when ff_thread_get_buffer() is skipped?

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

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


Re: [FFmpeg-devel] [PATCH] A-pac demuxer and decoder

2022-09-23 Thread James Almer

On 9/21/2022 4:23 AM, Paul B Mahol wrote:

Patches attached.


[...]


+static av_cold int apac_close(AVCodecContext *avctx)
+{
+APACContext *s = avctx->priv_data;
+
+av_freep(>bitstream);
+s->bitstream_size = 0;
+
+for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {


for (int ch = 0; ch < FF_ARRAY_ELEMS(s->ch); ch++)

As Andreas mentioned on IRC, this will crash if you try to initialize 
the decoder by setting more than 2 channels otherwise.



+ChContext *c = >ch[ch];
+
+av_audio_fifo_free(c->samples);
+}
+
+return 0;
+}


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

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

2022-09-23 Thread Tomas Härdin
fre 2022-09-23 klockan 17:41 +0200 skrev Andreas Rheinhardt:
> This could be improved further by not allocating the buffers
> that won't be needed lateron in the first place.

My parallellization patches do this

> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/jpeg2000dec.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index c3f2a7aa03..63a706fbf5 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -2523,6 +2523,11 @@ static int
> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
>  avctx->sample_aspect_ratio = s->sar;
>  s->sar.num = s->sar.den = 0;
>  
> +    if (avctx->skip_frame >= AVDISCARD_ALL) {
> +    jpeg2000_dec_cleanup(s);
> +    return 0;
> +    }
> +
>  /* get picture buffer */
>  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
>  goto end;
> @@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = {
>  .p.priv_class = _class,
>  .p.max_lowres = 5,
>  .p.profiles   = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),
> +    .caps_internal    = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,

Looks good

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer

2022-09-23 Thread Tomas Härdin
fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt:
> That way the SAR will be automatically set on the AVFrame.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> If I am not mistaken, then the earlier code would set the sar
> with a delay of one frame on the returned frames in case
> there is a sar change mid-stream. But I don't have a sample
> for this.
> 
>  libavcodec/jpeg2000dec.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 7d9661f29f..c3f2a7aa03 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -2519,6 +2519,10 @@ static int
> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
>  if (ret = jpeg2000_read_main_headers(s))
>  goto end;
>  
> +    if (s->sar.num && s->sar.den)
> +    avctx->sample_aspect_ratio = s->sar;
> +    s->sar.num = s->sar.den = 0;
> +
>  /* get picture buffer */
>  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
>  goto end;
> @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext
> *avctx, AVFrame *picture,
>  
>  if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
>  memcpy(picture->data[1], s->palette, 256 *
> sizeof(uint32_t));
> -    if (s->sar.num && s->sar.den)
> -    avctx->sample_aspect_ratio = s->sar;
> -    s->sar.num = s->sar.den = 0;

I suspect not doing this is what caused my simple hack to not work when
ff_thread_get_buffer() was skipped. Looks OK, passes FATE.

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH] float in tiff

2022-09-23 Thread Paul B Mahol
On 9/14/22, Paul B Mahol  wrote:
> Patches attached.
>

Will apply soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] doc/examples/extract_mvs: add motion information

2022-09-23 Thread Michael Niedermayer
On Mon, Sep 12, 2022 at 04:49:56PM -0700, Chema Gonzalez wrote:
> Note that the motion information includes subpel motion information
> 
> This was likely forgotten in 56bdf61baa04c4fd8d165f34499115ce0aa97c43.
> 
> Tested:
> ```
> $ make examples -j
> ...
> $ doc/examples/extract_mvs in.264 | head -40 | \
> csvcut -C framenum,source,flags |csvlook
> | blockw | blockh |  srcx | srcy |  dstx | dsty | motion_x | motion_y | 
> motion_scale |
> | -- | -- | - |  | - |  |  |  | 
>  |
> | 16 | 16 |20 |   26 | 8 |8 |   49 |   72 |   
>  4 |
> | 16 | 16 |   152 |   15 |   136 |8 |   65 |   28 |   
>  4 |
> | 16 |  8 |   360 |3 |   360 |4 |1 |   -6 |   
>  4 |
> | 16 |  8 |   360 |   13 |   360 |   12 |   -1 |4 |   
>  4 |
> | 16 | 16 |   440 |   10 |   440 |8 |3 |   10 |   
>  4 |
> |  8 | 16 |   829 |7 |   836 |8 |  -31 |   -6 |   
>  4 |
> |  8 | 16 |   844 |7 |   844 |8 |   -1 |   -4 |   
>  4 |
> | 16 | 16 | 1,004 |   14 | 1,048 |8 | -177 |   24 |   
>  4 |
> | 16 | 16 | 1,096 |8 | 1,096 |8 |   -1 |0 |   
>  4 |
> | 16 |  8 | 1,417 |   24 | 1,416 |4 |7 |   82 |   
>  4 |
> | 16 |  8 | 1,416 |   13 | 1,416 |   12 |0 |6 |   
>  4 |
> | 16 |  8 |87 |   20 |88 |   20 |   -7 |0 |   
>  4 |
> | 16 |  8 |99 |   44 |88 |   28 |   45 |   66 |   
>  4 |
> ...
> ```
> 
> Also:
> ```
> $ make fate -j
> ...
> ```
> ---
>  doc/examples/extract_mvs.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] A-pac demuxer and decoder

2022-09-23 Thread Paul B Mahol
On 9/21/22, Paul B Mahol  wrote:
> Patches attached.
>

WIll apply soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Zhao Zhili


> -Original Message-
> From: ffmpeg-devel-boun...@ffmpeg.org  On 
> Behalf Of Rémi Denis-Courmont
> Sent: 2022年9月23日 22:35
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses 
> warning
> 
> Le perjantaina 23. syyskuuta 2022, 20.40.30 EEST Zhao Zhili a écrit :
> > From: Zhao Zhili 
> >
> > Signed-off-by: Zhao Zhili 
> > ---
> >  libavcodec/mjpegdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> > index c594950500..d77c644d3b 100644
> > --- a/libavcodec/mjpegdec.c
> > +++ b/libavcodec/mjpegdec.c
> > @@ -2866,7 +2866,7 @@ the_end:
> >  }
> >  }
> >
> > -if (e = av_dict_get(s->exif_metadata, "Orientation", e,
> > AV_DICT_IGNORE_SUFFIX)) { +if ((e = av_dict_get(s->exif_metadata,
> > "Orientation", e, AV_DICT_IGNORE_SUFFIX))) { char *value = e->value +
> > strspn(e->value, " \n\t\r"), *endptr; int orientation = strtol(value,
> > , 0);
> 
> Isn't it easier to read if you break the assignment out, and use the result as
> predicate??

I prefer the coding style of splitting into two lines personally, but current 
coding
Style is used everywhere in the code base, so I'm not sure.

Since -Wparentheses has been disabled explicitly, the patch doesn't matter now.

> 
> --
> レミ・デニ-クールモン
> http://www.remlab.net/
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Zhao Zhili


> -Original Message-
> From: ffmpeg-devel-boun...@ffmpeg.org  On 
> Behalf Of Andreas Rheinhardt
> Sent: 2022年9月23日 23:11
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses 
> warning
> 
> Zhao Zhili:
> > From: Zhao Zhili 
> >
> > Signed-off-by: Zhao Zhili 
> > ---
> >  libavcodec/mjpegdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> > index c594950500..d77c644d3b 100644
> > --- a/libavcodec/mjpegdec.c
> > +++ b/libavcodec/mjpegdec.c
> > @@ -2866,7 +2866,7 @@ the_end:
> >  }
> >  }
> >
> > -if (e = av_dict_get(s->exif_metadata, "Orientation", e, 
> > AV_DICT_IGNORE_SUFFIX)) {
> > +if ((e = av_dict_get(s->exif_metadata, "Orientation", e, 
> > AV_DICT_IGNORE_SUFFIX))) {
> >  char *value = e->value + strspn(e->value, " \n\t\r"), *endptr;
> >  int orientation = strtol(value, , 0);
> >
> 
> Since when do we care about this type of warning? Line 7087 of configure
> adds -Wno-parentheses in case the compiler supports it.

OK. Before sending the patch, I have checked git log that there is a commit 
3fb32ae2
which fixed a bug catched by -Wparentheses. I didn't notice -Wparentheses has 
been
disabled explicitly since too much false positive. On the other hand, I'd like 
to suggest
to avoid such coding style for new code.

Please ignore the patch itself.

> 
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


[FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

2022-09-23 Thread Andreas Rheinhardt
This could be improved further by not allocating the buffers
that won't be needed lateron in the first place.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeg2000dec.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c3f2a7aa03..63a706fbf5 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2523,6 +2523,11 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 avctx->sample_aspect_ratio = s->sar;
 s->sar.num = s->sar.den = 0;
 
+if (avctx->skip_frame >= AVDISCARD_ALL) {
+jpeg2000_dec_cleanup(s);
+return 0;
+}
+
 /* get picture buffer */
 if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
 goto end;
@@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = {
 .p.priv_class = _class,
 .p.max_lowres = 5,
 .p.profiles   = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),
+.caps_internal= FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 };
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer

2022-09-23 Thread Andreas Rheinhardt
That way the SAR will be automatically set on the AVFrame.

Signed-off-by: Andreas Rheinhardt 
---
If I am not mistaken, then the earlier code would set the sar
with a delay of one frame on the returned frames in case
there is a sar change mid-stream. But I don't have a sample
for this.

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

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7d9661f29f..c3f2a7aa03 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2519,6 +2519,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 if (ret = jpeg2000_read_main_headers(s))
 goto end;
 
+if (s->sar.num && s->sar.den)
+avctx->sample_aspect_ratio = s->sar;
+s->sar.num = s->sar.den = 0;
+
 /* get picture buffer */
 if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
 goto end;
@@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 
 if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
 memcpy(picture->data[1], s->palette, 256 * sizeof(uint32_t));
-if (s->sar.num && s->sar.den)
-avctx->sample_aspect_ratio = s->sar;
-s->sar.num = s->sar.den = 0;
 
 return bytestream2_tell(>g);
 
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Andreas Rheinhardt
Zhao Zhili:
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/mjpegdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index c594950500..d77c644d3b 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -2866,7 +2866,7 @@ the_end:
>  }
>  }
>  
> -if (e = av_dict_get(s->exif_metadata, "Orientation", e, 
> AV_DICT_IGNORE_SUFFIX)) {
> +if ((e = av_dict_get(s->exif_metadata, "Orientation", e, 
> AV_DICT_IGNORE_SUFFIX))) {
>  char *value = e->value + strspn(e->value, " \n\t\r"), *endptr;
>  int orientation = strtol(value, , 0);
>  

Since when do we care about this type of warning? Line 7087 of configure
adds -Wno-parentheses in case the compiler supports it.

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

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


Re: [FFmpeg-devel] [PATCH 06/29] configure: probe RISC-V Vector extension

2022-09-23 Thread Rémi Denis-Courmont
Le torstaina 22. syyskuuta 2022, 21.37.03 EEST r...@remlab.net a écrit :
> @@ -7596,6 +7608,9 @@ if enabled loongarch; then
>  echo "LSX enabled   ${lsx-no}"
>  echo "LASX enabled  ${lasx-no}"
>  fi
> +if enabled riscv; then
> +echo "RISC-V Vector enabled ${riscv-no}"

Oopsie. Should be ${rvv-no}.

-- 
Реми Дёни-Курмон
http://www.remlab.net/



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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Rémi Denis-Courmont
Le perjantaina 23. syyskuuta 2022, 20.40.30 EEST Zhao Zhili a écrit :
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/mjpegdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index c594950500..d77c644d3b 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -2866,7 +2866,7 @@ the_end:
>  }
>  }
> 
> -if (e = av_dict_get(s->exif_metadata, "Orientation", e,
> AV_DICT_IGNORE_SUFFIX)) { +if ((e = av_dict_get(s->exif_metadata,
> "Orientation", e, AV_DICT_IGNORE_SUFFIX))) { char *value = e->value +
> strspn(e->value, " \n\t\r"), *endptr; int orientation = strtol(value,
> , 0);

Isn't it easier to read if you break the assignment out, and use the result as 
predicate??

-- 
レミ・デニ-クールモン
http://www.remlab.net/



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

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


Re: [FFmpeg-devel] [PATCH] avcodec: add a bsf to reorder DTS into PTS

2022-09-23 Thread James Almer

On 9/23/2022 10:06 AM, Anton Khirnov wrote:

Quoting James Almer (2022-09-05 03:09:55)

+static int h264_init(AVBSFContext *ctx)
+{
+DTS2PTSContext *s = ctx->priv_data;
+DTS2PTSH264Context *h264 = >u.h264;
+
+s->cbc->decompose_unit_types= h264_decompose_unit_types;
+s->cbc->nb_decompose_unit_types = 
FF_ARRAY_ELEMS(h264_decompose_unit_types);
+
+s->nb_frame = -(ctx->par_in->video_delay << 1);
+h264->last_poc = h264->highest_poc = INT_MIN;


just call h264_flush()?


Ok. I avoided doing that since the memsets in there would be run for no 
gain. But this is init() after all, so called only once.





+return 0;
+}
+
+static int get_mmco_reset(const H264RawSliceHeader *header)
+{
+if (header->nal_unit_header.nal_ref_idc == 0 ||
+!header->adaptive_ref_pic_marking_mode_flag)
+return 0;
+
+for (int i = 0; i < H264_MAX_MMCO_COUNT; i++) {
+if (header->mmco[i].memory_management_control_operation == 0)
+return 0;
+else if (header->mmco[i].memory_management_control_operation == 5)
+return 1;
+}
+
+return 0;
+}
+
+static int h264_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, int 
*queued)
+{
+DTS2PTSContext *s = ctx->priv_data;
+DTS2PTSH264Context *h264 = >u.h264;
+DTS2PTSFrame frame;
+int poc_diff, ret;
+
+poc_diff = (h264->picture_structure == 3) + 1;
+if (h264->sps.frame_mbs_only_flag && h264->poc_diff)
+poc_diff = FFMIN(poc_diff, h264->poc_diff);
+if (poc < 0) {
+av_tree_enumerate(s->root, _diff, NULL, dec_poc);
+s->nb_frame -= poc_diff;
+}
+// Check if there was a POC reset (Like an IDR slice)


I don't think this is enough. You should bump the sequence counter on
- IDR
- MMCO type 5
- SPS change
- H264_NAL_END_SEQUENCE/STREAM


This is handled when parsing the packet. ff_h264_init_poc() will return 
the actual POC value for the frame as coded in the bistream, which 
should have been reset in all those cases.



Then every sequence should get a separate tree and you sort POCs in each
tree.


When POC is reset, for example on an IDR, the last few frames of the 
previous GOP are meant to have as PTS the DTS from the first few frames 
in the new GOP. Is using separate trees really simplifying things if i 
still need to cross tree boundaries to fetch timestamps?





+if (s->nb_frame > h264->highest_poc) {
+s->nb_frame = 0;
+s->gop = (s->gop + 1) % s->fifo_size;
+h264->highest_poc = h264->last_poc;
+}
+
+ret = alloc_and_insert_node(ctx, pkt->dts, pkt->duration, s->nb_frame, 
poc_diff, s->gop);
+if (ret < 0)
+return ret;
+av_log(ctx, AV_LOG_DEBUG, "Queueing frame with POC %d, GOP %d, dts 
%"PRId64"\n",
+   poc, s->gop, pkt->dts);
+s->nb_frame += poc_diff;
+
+// Add frame to output FIFO only once
+if (*queued)
+return 0;
+
+frame = (DTS2PTSFrame) { pkt, poc, poc_diff, s->gop };
+ret = av_fifo_write(s->fifo, , 1);
+av_assert2(ret >= 0);
+*queued = 1;
+
+return 0;
+}
+
+static int h264_filter(AVBSFContext *ctx)
+{
+DTS2PTSContext *s = ctx->priv_data;
+DTS2PTSH264Context *h264 = >u.h264;
+CodedBitstreamFragment *au = >au;
+AVPacket *in;
+int output_picture_number = INT_MIN;
+int field_poc[2];
+int queued = 0, ret;
+
+ret = ff_bsf_get_packet(ctx, );
+if (ret < 0)
+return ret;
+
+ret = ff_cbs_read_packet(s->cbc, au, in);
+if (ret < 0) {
+av_log(ctx, AV_LOG_WARNING, "Failed to parse access unit.\n");
+goto fail;
+}
+
+for (int i = 0; i < au->nb_units; i++) {
+CodedBitstreamUnit *unit = >units[i];
+
+switch (unit->type) {
+case H264_NAL_IDR_SLICE:
+h264->poc.prev_frame_num= 0;
+h264->poc.prev_frame_num_offset = 0;
+h264->poc.prev_poc_msb  =
+h264->poc.prev_poc_lsb  = 0;
+// fall-through
+case H264_NAL_SLICE: {
+const H264RawSlice *slice = unit->content;
+const H264RawSliceHeader *header = >header;
+const CodedBitstreamH264Context *cbs_h264 = s->cbc->priv_data;
+const H264RawSPS *sps = cbs_h264->active_sps;
+int got_reset;
+
+if (!sps) {
+av_log(ctx, AV_LOG_ERROR, "No active SPS for a slice\n");
+goto fail;
+}
+// Initialize the SPS struct with the fields ff_h264_init_poc() 
cares about
+h264->sps.frame_mbs_only_flag= 
sps->frame_mbs_only_flag;
+h264->sps.log2_max_frame_num = 
sps->log2_max_frame_num_minus4 + 4;
+h264->sps.poc_type   = sps->pic_order_cnt_type;
+h264->sps.log2_max_poc_lsb   = 
sps->log2_max_pic_order_cnt_lsb_minus4 + 4;
+h264->sps.offset_for_non_ref_pic = 
sps->offset_for_non_ref_pic;
+

Re: [FFmpeg-devel] [PATCH] avcodec: add a bsf to reorder DTS into PTS

2022-09-23 Thread Anton Khirnov
Quoting James Almer (2022-09-05 03:09:55)
> +static int h264_init(AVBSFContext *ctx)
> +{
> +DTS2PTSContext *s = ctx->priv_data;
> +DTS2PTSH264Context *h264 = >u.h264;
> +
> +s->cbc->decompose_unit_types= h264_decompose_unit_types;
> +s->cbc->nb_decompose_unit_types = 
> FF_ARRAY_ELEMS(h264_decompose_unit_types);
> +
> +s->nb_frame = -(ctx->par_in->video_delay << 1);
> +h264->last_poc = h264->highest_poc = INT_MIN;

just call h264_flush()?

> +return 0;
> +}
> +
> +static int get_mmco_reset(const H264RawSliceHeader *header)
> +{
> +if (header->nal_unit_header.nal_ref_idc == 0 ||
> +!header->adaptive_ref_pic_marking_mode_flag)
> +return 0;
> +
> +for (int i = 0; i < H264_MAX_MMCO_COUNT; i++) {
> +if (header->mmco[i].memory_management_control_operation == 0)
> +return 0;
> +else if (header->mmco[i].memory_management_control_operation == 5)
> +return 1;
> +}
> +
> +return 0;
> +}
> +
> +static int h264_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, int 
> *queued)
> +{
> +DTS2PTSContext *s = ctx->priv_data;
> +DTS2PTSH264Context *h264 = >u.h264;
> +DTS2PTSFrame frame;
> +int poc_diff, ret;
> +
> +poc_diff = (h264->picture_structure == 3) + 1;
> +if (h264->sps.frame_mbs_only_flag && h264->poc_diff)
> +poc_diff = FFMIN(poc_diff, h264->poc_diff);
> +if (poc < 0) {
> +av_tree_enumerate(s->root, _diff, NULL, dec_poc);
> +s->nb_frame -= poc_diff;
> +}
> +// Check if there was a POC reset (Like an IDR slice)

I don't think this is enough. You should bump the sequence counter on
- IDR
- MMCO type 5
- SPS change
- H264_NAL_END_SEQUENCE/STREAM
Then every sequence should get a separate tree and you sort POCs in each
tree.

> +if (s->nb_frame > h264->highest_poc) {
> +s->nb_frame = 0;
> +s->gop = (s->gop + 1) % s->fifo_size;
> +h264->highest_poc = h264->last_poc;
> +}
> +
> +ret = alloc_and_insert_node(ctx, pkt->dts, pkt->duration, s->nb_frame, 
> poc_diff, s->gop);
> +if (ret < 0)
> +return ret;
> +av_log(ctx, AV_LOG_DEBUG, "Queueing frame with POC %d, GOP %d, dts 
> %"PRId64"\n",
> +   poc, s->gop, pkt->dts);
> +s->nb_frame += poc_diff;
> +
> +// Add frame to output FIFO only once
> +if (*queued)
> +return 0;
> +
> +frame = (DTS2PTSFrame) { pkt, poc, poc_diff, s->gop };
> +ret = av_fifo_write(s->fifo, , 1);
> +av_assert2(ret >= 0);
> +*queued = 1;
> +
> +return 0;
> +}
> +
> +static int h264_filter(AVBSFContext *ctx)
> +{
> +DTS2PTSContext *s = ctx->priv_data;
> +DTS2PTSH264Context *h264 = >u.h264;
> +CodedBitstreamFragment *au = >au;
> +AVPacket *in;
> +int output_picture_number = INT_MIN;
> +int field_poc[2];
> +int queued = 0, ret;
> +
> +ret = ff_bsf_get_packet(ctx, );
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_cbs_read_packet(s->cbc, au, in);
> +if (ret < 0) {
> +av_log(ctx, AV_LOG_WARNING, "Failed to parse access unit.\n");
> +goto fail;
> +}
> +
> +for (int i = 0; i < au->nb_units; i++) {
> +CodedBitstreamUnit *unit = >units[i];
> +
> +switch (unit->type) {
> +case H264_NAL_IDR_SLICE:
> +h264->poc.prev_frame_num= 0;
> +h264->poc.prev_frame_num_offset = 0;
> +h264->poc.prev_poc_msb  =
> +h264->poc.prev_poc_lsb  = 0;
> +// fall-through
> +case H264_NAL_SLICE: {
> +const H264RawSlice *slice = unit->content;
> +const H264RawSliceHeader *header = >header;
> +const CodedBitstreamH264Context *cbs_h264 = s->cbc->priv_data;
> +const H264RawSPS *sps = cbs_h264->active_sps;
> +int got_reset;
> +
> +if (!sps) {
> +av_log(ctx, AV_LOG_ERROR, "No active SPS for a slice\n");
> +goto fail;
> +}
> +// Initialize the SPS struct with the fields ff_h264_init_poc() 
> cares about
> +h264->sps.frame_mbs_only_flag= 
> sps->frame_mbs_only_flag;
> +h264->sps.log2_max_frame_num = 
> sps->log2_max_frame_num_minus4 + 4;
> +h264->sps.poc_type   = 
> sps->pic_order_cnt_type;
> +h264->sps.log2_max_poc_lsb   = 
> sps->log2_max_pic_order_cnt_lsb_minus4 + 4;
> +h264->sps.offset_for_non_ref_pic = 
> sps->offset_for_non_ref_pic;
> +h264->sps.offset_for_top_to_bottom_field = 
> sps->offset_for_top_to_bottom_field;
> +h264->sps.poc_cycle_length   = 
> sps->num_ref_frames_in_pic_order_cnt_cycle;
> +for (int i = 0; i < h264->sps.poc_cycle_length; i++)

moderately evil shadowing

> +h264->sps.offset_for_ref_frame[i] = 
> sps->offset_for_ref_frame[i];
> +
> +

Re: [FFmpeg-devel] [PATCH 1/1] fate/opus: add silk LBRR test (refs #9890)

2022-09-23 Thread Andreas Rheinhardt
Tristan Matthews:
> On Thu, Sep 8, 2022 at 3:58 PM Tristan Matthews  wrote:
> 
>> This adds a fate test for a sample with LBRR packets.
>>
>> It requires that these files be uploaded:
>> https://people.videolan.org/~tmatth/9890-fate/silk-lbrr.mka
>> https://people.videolan.org/~tmatth/9890-fate/silk-lbrr.dec
>>
>> ---
>>  tests/fate/opus.mak | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/fate/opus.mak b/tests/fate/opus.mak
>> index 573044ed15..7d359f414a 100644
>> --- a/tests/fate/opus.mak
>> +++ b/tests/fate/opus.mak
>> @@ -4,7 +4,7 @@
>>
>>  OPUS_CELT_SAMPLES   = $(addprefix testvector, 01 11) tron.6ch.tinypkts
>>  OPUS_HYBRID_SAMPLES = $(addprefix testvector, 05 06)
>> -OPUS_SILK_SAMPLES   = $(addprefix testvector, 02 03 04)
>> +OPUS_SILK_SAMPLES   = $(addprefix testvector, 02 03 04) silk-lbrr
>>  OPUS_OTHER_SAMPLES  = $(addprefix testvector, 07 08 09 10 12)
>>
>>  define FATE_OPUS_TEST
>> @@ -33,6 +33,7 @@ fate-opus-testvector09:  CMP_TARGET = 0
>>  fate-opus-testvector10:  CMP_TARGET = 38
>>  fate-opus-testvector11:  CMP_TARGET = 0
>>  fate-opus-testvector12:  CMP_TARGET = 160
>> +fate-opus-silk-lbrr: CMP_TARGET = 0
>>  fate-opus-tron.6ch.tinypkts: CMP_SHIFT = 1440
>>  fate-opus-tron.6ch.tinypkts: CMP_TARGET = 0
>>
>> --
>> 2.34.1
>>
> 
> 
> Sorry this was supposed to be in response to
> http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/300758.html (as it
> depends on it) but I screwed up the git-send-email.
> 

Does this sample have to be so long?

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

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


[FFmpeg-devel] [PATCH 1/1] opus_silk: reset midonly flag after skipping LBRR

2022-09-23 Thread Tristan Matthews
Fix suggested by Mark Harris. Fixes ticket #9890

Simplified after feedback from Anton Khirnov.
---
 libavcodec/opus_silk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/opus_silk.c b/libavcodec/opus_silk.c
index 8523b55ada..f9d67f4fb3 100644
--- a/libavcodec/opus_silk.c
+++ b/libavcodec/opus_silk.c
@@ -833,6 +833,8 @@ int ff_silk_decode_superframe(SilkContext *s, 
OpusRangeCoder *rc,
 int active1 = (j == 0 && !(redundancy[1] & (1 << i))) ? 0 : 1;
 silk_decode_frame(s, rc, i, j, coded_channels, 1, active1, 1);
 }
+
+s->midonly = 0;
 }
 
 for (i = 0; i < nb_frames; i++) {
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] Media 100i decoder

2022-09-23 Thread Paul B Mahol
On 9/22/22, Andreas Rheinhardt  wrote:
> Paul B Mahol:
>> On 9/22/22, Anton Khirnov  wrote:
>>> Should be straightforward to forward get_buffer2() and support
>>> AV_CODEC_CAP_DR1.
>>
>> How ?
>>
>
> You copy the get_buffer2 callback as well as AVCodecContext.opaque to
> the subdecoder.


Still triggers assert at line 616 of libavcodec/decode.c

>
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Steven Liu
Zhao Zhili  于2022年9月23日周五 17:40写道:
>
> From: Zhao Zhili 
>
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/mjpegdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
lgtm
>
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index c594950500..d77c644d3b 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -2866,7 +2866,7 @@ the_end:
>  }
>  }
>
> -if (e = av_dict_get(s->exif_metadata, "Orientation", e, 
> AV_DICT_IGNORE_SUFFIX)) {
> +if ((e = av_dict_get(s->exif_metadata, "Orientation", e, 
> AV_DICT_IGNORE_SUFFIX))) {
>  char *value = e->value + strspn(e->value, " \n\t\r"), *endptr;
>  int orientation = strtol(value, , 0);
>
> --
> 2.25.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix -Wparentheses warning

2022-09-23 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/mjpegdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index c594950500..d77c644d3b 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2866,7 +2866,7 @@ the_end:
 }
 }
 
-if (e = av_dict_get(s->exif_metadata, "Orientation", e, 
AV_DICT_IGNORE_SUFFIX)) {
+if ((e = av_dict_get(s->exif_metadata, "Orientation", e, 
AV_DICT_IGNORE_SUFFIX))) {
 char *value = e->value + strspn(e->value, " \n\t\r"), *endptr;
 int orientation = strtol(value, , 0);
 
-- 
2.25.1

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

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


Re: [FFmpeg-devel] [PATCH v2 2/7] avdevice/avdevice: Fix mismatching argument name

2022-09-23 Thread Michael Niedermayer
On Thu, Sep 22, 2022 at 04:03:55AM +0200, Marvin Scholz wrote:
> ---
>  libavdevice/avdevice.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/7] avcodec: Fix Doxygen trailing brief comments

2022-09-23 Thread Michael Niedermayer
On Thu, Sep 22, 2022 at 04:03:54AM +0200, Marvin Scholz wrote:
> The //< comment is not any magic comment supported by Doxygen,
> instead use //!< to mark them as brief doc for the members.

///< is more commonly used in ffmpeg

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 3/7] avformat/avformat: Fix mismatching argument names

2022-09-23 Thread Michael Niedermayer
On Thu, Sep 22, 2022 at 04:03:56AM +0200, Marvin Scholz wrote:
> ---
>  libavformat/avformat.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

should be ok

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 4/7] avutil: Fix mismatching argument names

2022-09-23 Thread Michael Niedermayer
On Thu, Sep 22, 2022 at 04:03:57AM +0200, Marvin Scholz wrote:
> ---
>  libavutil/hwcontext.h   | 2 +-
>  libavutil/mathematics.h | 6 --
>  libavutil/mem.h | 3 ++-
>  libavutil/rational.h| 3 ++-
>  4 files changed, 9 insertions(+), 5 deletions(-)

should be ok

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 5/7] swresample/swresample: Fix mismatching argument names

2022-09-23 Thread Michael Niedermayer
On Thu, Sep 22, 2022 at 04:03:58AM +0200, Marvin Scholz wrote:
> ---
>  libswresample/swresample.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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