Re: [FFmpeg-devel] [PATCH 10/12] avcodec: add MediaCodec encoder

2022-10-27 Thread Tomas Härdin
tor 2022-10-27 klockan 10:49 +0800 skrev zhilizhao(赵志立):
> 
> 
> > On Oct 27, 2022, at 05:17, Tomas Härdin  wrote:
> > 
> > mån 2022-10-24 klockan 11:16 +0800 skrev Zhao Zhili:
> > > 
> > > +typedef struct MediaCodecEncContext {
> > > +    AVClass *avclass;
> > > +    FFAMediaCodec *codec;
> > > +    int use_ndk_codec;
> > > +    FFANativeWindow *window;
> > > +
> > > +    int fps;
> > > +    int width;
> > > +    int height;
> > > +
> > > +    uint8_t *extradata;
> > > +    int extradata_size;
> > 
> > Why not extradata in AVCodecContext?
> 
> The extradata (BUFFER_FLAG_CODEC_CONFIG) is popped after codec
> init, I’m not sure if it’s OK to touch AVCodecContext->extradata
> after code init.

You mean that it isn't populated until after a frame has been encoded?
There's no way to specify resolution, pixel format etc to get the
extradata without encoding?

> Secondly, it isn’t specified in Android doc, but better be safe
> to handle the case of BUFFER_FLAG_CODEC_CONFIG show up multiple
> times.

Surely there's a way to signal this? I suppose one can always add a bsf
after the encoder. I'm actually not sure.
> 

> > Some tests would be nice
> 
> Did you mean fate test or manual test?
> 
> It’s an external codec wrapper, so maybe not in fate.

It would be nice if FATE could test this on machines where the hardware
is available. We had a brief discussion on IRC about this yesterday.
Just checking which encoders actually work, what profiles are supported
and so on. Maybe tabulate it somewhere. Sometimes manufacturers specify
what codecs and profiles are supported, sometimes not.

/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] configure: Remove a leftover comment about MSVC C99 support

2022-10-27 Thread Martin Storsjö

On Wed, 19 Oct 2022, Martin Storsjö wrote:


Support for building with older versions of MSVC (with the
c99wrap/c99conv frontend) was removed in
ce943dd6acbfdfc40223c0fb24d4cad438e6499c.

Signed-off-by: Martin Storsjö 
---
configure | 6 --
1 file changed, 6 deletions(-)

diff --git a/configure b/configure
index 6712d045d9..ed52212f93 100755
--- a/configure
+++ b/configure
@@ -4368,12 +4368,6 @@ case "$toolchain" in
esac
;;
msvc)
-# Check whether the current MSVC version needs the C99 converter.
-# From MSVC 2013 (compiler major version 18) onwards, it does actually
-# support enough of C99 to build ffmpeg. Default to the new
-# behaviour if the regexp was unable to match anything, since this
-# successfully parses the version number of existing supported
-# versions that require the converter (MSVC 2010 and 2012).
cl_major_ver=$(cl.exe 2>&1 | sed -n 's/.*Version 
\([[:digit:]]\{1,\}\)\..*/\1/p')
if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
cc_default="cl.exe"
--
2.37.0 (Apple Git-136)


Will push later today.

// Martin
___
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] swscale: aarch64: Fix yuv2rgb with negative strides

2022-10-27 Thread Martin Storsjö

On Tue, 25 Oct 2022, Martin Storsjö wrote:


Treat the 32 bit stride registers as signed.

Alternatively, we could make the stride arguments ptrdiff_t instead
of int, and changing all of the assembly to operate on these
registers with their full 64 bit width, but that's a much larger
and more intrusive change (and risks missing some operation, which
would clamp the intermediates to 32 bit still).

Fixes: https://trac.ffmpeg.org/ticket/9985

Signed-off-by: Martin Storsjö 
---
libswscale/aarch64/yuv2rgb_neon.S | 8 
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libswscale/aarch64/yuv2rgb_neon.S 
b/libswscale/aarch64/yuv2rgb_neon.S
index f4b220fb60..f341268c5d 100644
--- a/libswscale/aarch64/yuv2rgb_neon.S
+++ b/libswscale/aarch64/yuv2rgb_neon.S
@@ -118,8 +118,8 @@
.endm

.macro increment_yuv422p
-add x6,  x6,  w7, UXTW  // 
srcU += incU
-add x13, x13, w14, UXTW // 
srcV += incV
+add x6,  x6,  w7, SXTW  // 
srcU += incU
+add x13, x13, w14, SXTW // 
srcV += incV
.endm

.macro compute_rgba r1 g1 b1 a1 r2 g2 b2 a2
@@ -189,8 +189,8 @@ function ff_\ifmt\()_to_\ofmt\()_neon, export=1
st4 {v16.8B,v17.8B,v18.8B,v19.8B}, [x2], #32
subsw8, w8, #16 // 
width -= 16
b.gt2b
-add x2, x2, w3, UXTW// dst 
 += padding
-add x4, x4, w5, UXTW// 
srcY += paddingY
+add x2, x2, w3, SXTW// dst 
 += padding
+add x4, x4, w5, SXTW// 
srcY += paddingY
increment_\ifmt
subsw1, w1, #1  // 
height -= 1
b.gt1b
--
2.37.0 (Apple Git-136)


Will push later today, and backport to some older branches where relevant 
(a bit later).


// Martin
___
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 10/12] avcodec: add MediaCodec encoder

2022-10-27 Thread zhilizhao(赵志立)


> On Oct 27, 2022, at 17:56, Tomas Härdin  wrote:
> 
> tor 2022-10-27 klockan 10:49 +0800 skrev zhilizhao(赵志立):
>> 
>> 
>>> On Oct 27, 2022, at 05:17, Tomas Härdin  wrote:
>>> 
>>> mån 2022-10-24 klockan 11:16 +0800 skrev Zhao Zhili:
 
 +typedef struct MediaCodecEncContext {
 +AVClass *avclass;
 +FFAMediaCodec *codec;
 +int use_ndk_codec;
 +FFANativeWindow *window;
 +
 +int fps;
 +int width;
 +int height;
 +
 +uint8_t *extradata;
 +int extradata_size;
>>> 
>>> Why not extradata in AVCodecContext?
>> 
>> The extradata (BUFFER_FLAG_CODEC_CONFIG) is popped after codec
>> init, I’m not sure if it’s OK to touch AVCodecContext->extradata
>> after code init.
> 
> You mean that it isn't populated until after a frame has been encoded?
> There's no way to specify resolution, pixel format etc to get the
> extradata without encoding?

That’s the case from my test on Google Pixel 3. There is no ‘csd’ inside
MediaFormat returned by ff_AMediaCodec_getOutputFormat(), until a frame
has been sent. It may depends on the device and OS.

> 
>> Secondly, it isn’t specified in Android doc, but better be safe
>> to handle the case of BUFFER_FLAG_CODEC_CONFIG show up multiple
>> times.
> 
> Surely there's a way to signal this? I suppose one can always add a bsf
> after the encoder. I'm actually not sure.

We can use AV_PKT_DATA_NEW_EXTRADATA to signal that along with
AVCodecContext->extradata. We still need to save extradata to a place
other than AVCodecContext->extradata temporarily.

>> 
> 
>>> Some tests would be nice
>> 
>> Did you mean fate test or manual test?
>> 
>> It’s an external codec wrapper, so maybe not in fate.
> 
> It would be nice if FATE could test this on machines where the hardware
> is available. We had a brief discussion on IRC about this yesterday.
> Just checking which encoders actually work, what profiles are supported
> and so on. Maybe tabulate it somewhere. Sometimes manufacturers specify
> what codecs and profiles are supported, sometimes not.

I’m planing to add more options for codec configure and select codec by
name. Run FATE on Android is doable.

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

___
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/5] avformat/argo_cvg: Mark overrides as const

2022-10-27 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/argo_cvg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
> index edf75c905e..aedc7c4a32 100644
> --- a/libavformat/argo_cvg.c
> +++ b/libavformat/argo_cvg.c
> @@ -70,7 +70,7 @@ typedef struct ArgoCVGMuxContext {
>  
>  #if CONFIG_ARGO_CVG_DEMUXER
>  /* "Special" files that are played at a different rate. */
> -static ArgoCVGOverride overrides[] = {
> +static const ArgoCVGOverride overrides[] = {
>  { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */
>  { "REDCRY88.CVG", { 38280, 0, 1 }, 4134848, 88200 }, /* Beta */
>  { "DANLOOP1.CVG", { 54744, 1, 0 }, 5684641, 37800 }, /* Beta */

Will apply this patchset tomorrow unless there are objections.

- 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 v2 1/2] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer

2022-10-27 Thread Christopher Degawa
On Thu, Oct 20, 2022 at 11:56 PM Christopher Degawa 
wrote:

> From: Christopher Degawa 
>
> compressed_ten_bit_format has been deprecated upstream and has no effect
> and can be removed. Plus, technically it was never used in the first place
> since it would require the app (ffmpeg) to set it and do additional
> processing of the input frames.
>
> Also simplify alloc_buffer by removing calculations relating to the
> non-existant processing.
>
> Signed-off-by: Christopher Degawa 
> ---
>

Ping on this and the other patch?
___
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 v2 1/2] avcodec/metasound_data: Move data shared with twinvq into a new file

2022-10-27 Thread Andreas Rheinhardt
Namely into a header metasound_twinvq_data.h included
in twinvq.c (the common file of MetaSound and TwinVQ).

Signed-off-by: Andreas Rheinhardt 
---
This is the second version of a patch that has already been
sent as part of the patchset [1]. Given that the diff for it
is very big it never appeared on the list ("Message body is too big:
1997072 bytes with a limit of 1000 KB"), but is still in the
moderator queue. You can find it at [2]. James suggested that
I split the commit so that git detects it as rename so
that the diff becomes smaller. This patchset does exactly this;
yet while this improves reviewability and atomicity,
it does not make the diff smaller. Just as with the first version,
git commit recognizes that this is basically a rename
("rename libavcodec/{metasound_data.c => metasound_data.h} (99%)"),
but git send-email and git show nevertheless show the huge diff,
which will likely be rejected by the mailing list again.
Therefore you can find the patch at [3].

Will apply this patchset tomorrow unless there are objections.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-October/302981.html
[2]: 
https://github.com/mkver/FFmpeg/commit/7ad0785b431e107d7b73bc822ab23ef0228fec9d
[3]: https://github.com/mkver/FFmpeg/commits/metasound_data

 libavcodec/Makefile|   2 +-
 libavcodec/metasound_data.c| 795 +---
 libavcodec/metasound_data.h|   6 -
 libavcodec/metasound_twinvq_data.h | 814 +
 libavcodec/twinvq.c|   1 +
 libavcodec/twinvq.h|   9 +
 libavcodec/twinvqdec.c |   1 -
 7 files changed, 826 insertions(+), 802 deletions(-)
 create mode 100644 libavcodec/metasound_twinvq_data.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8930994a6a..a86c4fcbd6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -705,7 +705,7 @@ OBJS-$(CONFIG_TSCC2_DECODER)   += tscc2.o
 OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o ttadsp.o
 OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttaencdsp.o ttadata.o
 OBJS-$(CONFIG_TTML_ENCODER)+= ttmlenc.o ass_split.o
-OBJS-$(CONFIG_TWINVQ_DECODER)  += twinvqdec.o twinvq.o metasound_data.o
+OBJS-$(CONFIG_TWINVQ_DECODER)  += twinvqdec.o twinvq.o
 OBJS-$(CONFIG_TXD_DECODER) += txd.o
 OBJS-$(CONFIG_ULTI_DECODER)+= ulti.o
 OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideodsp.o
diff --git a/libavcodec/metasound_data.c b/libavcodec/metasound_data.c
index b2044364fa..bc4b7699ba 100644
--- a/libavcodec/metasound_data.c
+++ b/libavcodec/metasound_data.c
@@ -19,11 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
-#include "config_components.h"
 #include "metasound_data.h"
 
-#if CONFIG_METASOUND_DECODER
 static const int16_t cb0806sl0[] = {
   -417,   -225,-84, 16,   -106,-34,   -246,   -164,
112, 48,-47, 36,-65,-68,   -172,  -1655,
@@ -12104,796 +12101,7 @@ static const int16_t fcb44sm[] = {
   -623,   -588, 38,-58,975,   1529,   -986,   -891,
  -1121,   -619,   1967,   -463, -7,632,768,953,
 };
-#endif /* CONFIG_METASOUND_DECODER */
-
-const float ff_metasound_lsp8[] = {
- 0.2702,  0.5096,  0.6437,  0.7672,  0.9639,  1.0696,  1.2625,  1.5789,
- 1.9285,  2.2383,  2.5129,  2.8470,  0.1740,  0.3677,  0.6082,  0.8387,
- 1.1084,  1.3721,  1.6362,  1.8733,  2.0640,  2.3442,  2.6087,  2.8548,
- 0.1536,  0.3279,  0.5143,  0.6859,  0.9763,  1.2744,  1.5605,  1.8566,
- 2.1007,  2.3450,  2.6075,  2.8850,  0.2075,  0.4533,  0.7709,  1.0377,
- 1.2953,  1.5132,  1.7826,  2.0351,  2.2590,  2.4996,  2.6795,  2.8748,
- 0.1393,  0.2453,  0.3754,  0.5453,  0.8148,  1.1289,  1.4389,  1.7592,
- 2.0353,  2.3215,  2.5934,  2.8588,  0.1250,  0.3627,  0.7613,  1.1380,
- 1.4163,  1.5565,  1.6920,  1.8130,  1.8678,  2.0427,  2.4318,  2.8544,
- 0.2256,  0.4223,  0.6452,  0.8599,  1.0673,  1.3118,  1.5486,  1.8366,
- 2.0759,  2.3026,  2.5284,  2.8030,  0.2304,  0.4404,  0.6891,  0.8964,
- 1.1510,  1.4202,  1.6483,  1.8580,  2.1181,  2.3686,  2.6078,  2.9128,
- 0.2230,  0.3816,  0.5520,  0.6062,  0.7909,  1.0988,  1.4330,  1.7846,
- 2.0713,  2.3457,  2.6048,  2.8708,  0.2447,  0.5800,  0.8249,  0.9905,
- 1.1721,  1.3990,  1.6694,  1.9064,  2.1307,  2.4255,  2.6815,  2.9117,
- 0.1974,  0.3812,  0.5802,  0.7759,  0.9280,  1.1547,  1.4170,  1.6369,
- 1.8890,  2.2587,  2.5626,  2.8239,  0.1209,  0.2510,  0.4841,  0.8048,
- 1.1197,  1.3563,  1.6073,  1.8926,  2.1350,  2.3669,  2.6291,  2.8985,
- 0.2352,  0.4347,  0.6582,  0.8178,  0.9548,  1.1654,  1.4942,  1.8812,
- 2.1703,  2.3779,  2.6412,  2.8871,  0.2091,  0.4084,  0.6730,  0.9151,
- 1.1259,  1.3262,  1.5937,  1.8129,  2.0237,  2.3317,  2.5778,  2.8620,
- 0.1167,  0.2406,  0.4520,  0.7298,  0.9848,  1

[FFmpeg-devel] [PATCH] avcodec/atrac3plus: reorder channels to match the output layout

2022-10-27 Thread James Almer
The order in which the channels are coded in the bitstream do not always follow
the native, bitmask-based order of channels both signaled by the WAV container
and forced by this same decoder. This is the case with layouts containing an
LFE channel, as it's always coded last.

Fixes ticket #9964.

Signed-off-by: James Almer 
---
6.1 and 7.1 untested, but much like 5.1 they were wrong before this change.

 libavcodec/atrac3plusdec.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index ee71645a3c..8c3d20af76 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -65,6 +65,7 @@ typedef struct ATRAC3PContext {
 
 int num_channel_blocks; ///< number of channel blocks
 uint8_t channel_blocks[5];  ///< channel configuration descriptor
+AVChannelLayout coded_ch_layout; ///< order of channels as coded in the 
bitstream
 } ATRAC3PContext;
 
 static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
@@ -74,6 +75,8 @@ static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
 av_freep(&ctx->ch_units);
 av_freep(&ctx->fdsp);
 
+av_channel_layout_uninit(&ctx->coded_ch_layout);
+
 ff_mdct_end(&ctx->mdct_ctx);
 ff_mdct_end(&ctx->ipqf_dct_ctx);
 
@@ -84,6 +87,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
   AVCodecContext *avctx)
 {
 int channels = avctx->ch_layout.nb_channels;
+int ret;
 memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks));
 
 av_channel_layout_uninit(&avctx->ch_layout);
@@ -92,17 +96,20 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
 avctx->ch_layout= (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
 ctx->num_channel_blocks = 1;
 ctx->channel_blocks[0]  = CH_UNIT_MONO;
+ctx->coded_ch_layout= avctx->ch_layout;
 break;
 case 2:
 avctx->ch_layout= (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 ctx->num_channel_blocks = 1;
 ctx->channel_blocks[0]  = CH_UNIT_STEREO;
+ctx->coded_ch_layout= avctx->ch_layout;
 break;
 case 3:
 avctx->ch_layout= (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND;
 ctx->num_channel_blocks = 2;
 ctx->channel_blocks[0]  = CH_UNIT_STEREO;
 ctx->channel_blocks[1]  = CH_UNIT_MONO;
+ctx->coded_ch_layout= avctx->ch_layout;
 break;
 case 4:
 avctx->ch_layout= (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
@@ -110,6 +117,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
 ctx->channel_blocks[0]  = CH_UNIT_STEREO;
 ctx->channel_blocks[1]  = CH_UNIT_MONO;
 ctx->channel_blocks[2]  = CH_UNIT_MONO;
+ctx->coded_ch_layout= avctx->ch_layout;
 break;
 case 6:
 avctx->ch_layout= 
(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK;
@@ -118,6 +126,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
 ctx->channel_blocks[1]  = CH_UNIT_MONO;
 ctx->channel_blocks[2]  = CH_UNIT_STEREO;
 ctx->channel_blocks[3]  = CH_UNIT_MONO;
+ret = av_channel_layout_from_string(&ctx->coded_ch_layout, 
"FL+FR+FC+BL+BR+LFE");
+if (ret < 0)
+return ret;
 break;
 case 7:
 avctx->ch_layout= 
(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK;
@@ -127,6 +138,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
 ctx->channel_blocks[2]  = CH_UNIT_STEREO;
 ctx->channel_blocks[3]  = CH_UNIT_MONO;
 ctx->channel_blocks[4]  = CH_UNIT_MONO;
+ret = av_channel_layout_from_string(&ctx->coded_ch_layout, 
"FL+FR+FC+BL+BR+BC+LFE");
+if (ret < 0)
+return ret;
 break;
 case 8:
 avctx->ch_layout= (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
@@ -136,6 +150,9 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
 ctx->channel_blocks[2]  = CH_UNIT_STEREO;
 ctx->channel_blocks[3]  = CH_UNIT_STEREO;
 ctx->channel_blocks[4]  = CH_UNIT_MONO;
+ret = av_channel_layout_from_string(&ctx->coded_ch_layout, 
"FL+FR+FC+BL+BR+SL+SR+LFE");
+if (ret < 0)
+return ret;
 break;
 default:
 av_log(avctx, AV_LOG_ERROR,
@@ -377,10 +394,12 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 reconstruct_frame(ctx, &ctx->ch_units[ch_block],
   channels_to_process, avctx);
 
-for (i = 0; i < channels_to_process; i++)
-memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i],
+for (i = 0; i < channels_to_process; i++) {
+enum AVChannel ch = 
av_channel_layout_channel_from_index(&ctx->coded_ch_layout, out_ch_index + i);
+int idx = av_channel_layout_index_from_channel(&frame->ch_layout, 
ch);
+memcpy(samples_p[

[FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once

2022-10-27 Thread Andreas Rheinhardt
For encoders, mpeg_quant is an option of the MPEG-4 encoder
and therefore constant. This implies that one can set
the dct_unquantize_(intra|inter) function pointers during init.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ce363a585d..0b709974a1 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -880,6 +880,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
 ff_dct_encode_init(s);
 
+if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
+s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
+} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
+s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
+} else {
+s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
+s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
+}
+
 if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
 s->chroma_qscale_table = ff_h263_chroma_qscale_table;
 
@@ -1723,17 +1734,6 @@ static int frame_start(MpegEncContext *s)
 }
 }
 
-if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
-s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
-s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
-} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
-s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-} else {
-s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
-s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-}
-
 if (s->dct_error_sum) {
 av_assert2(s->noise_reduction && s->encoding);
 update_noise_reduction(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".


[FFmpeg-devel] [PATCH 1/3] avcodec/aacdec: fix parsing streams with channel configuration 11

2022-10-27 Thread James Almer
Set the correct amount of tags in tags_per_config[].
Also, there are no channels that correspond to a side element in this
configuration, so reflect this in the list of known/supported channel layouts.

Signed-off-by: James Almer 
---
 libavcodec/aacdec_template.c | 4 +---
 libavcodec/aacdectab.h   | 6 +++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 4a9513d53e..c10bc743b6 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -731,9 +731,7 @@ static ChannelElement *get_che(AACContext *ac, int type, 
int elem_id)
 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
 }
 case 11:
-if (ac->tags_mapped == 2 &&
-ac->oc[1].m4ac.chan_config == 11 &&
-type == TYPE_SCE) {
+if (ac->tags_mapped == 3 && type == TYPE_SCE) {
 ac->tags_mapped++;
 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
 }
diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h
index e38b93a534..327efbcde0 100644
--- a/libavcodec/aacdectab.h
+++ b/libavcodec/aacdectab.h
@@ -35,7 +35,7 @@
 
 #include 
 
-static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 
4, 5, 16, 5, 0 };
+static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 
5, 5, 16, 5, 0 };
 
 static const uint8_t aac_channel_layout_map[16][16][3] = {
 { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, },
@@ -81,7 +81,7 @@ static const uint64_t aac_channel_layout[] = {
 AV_CH_LAYOUT_5POINT0_BACK,
 AV_CH_LAYOUT_5POINT1_BACK,
 AV_CH_LAYOUT_7POINT1_WIDE_BACK,
-AV_CH_LAYOUT_6POINT1,
+AV_CH_LAYOUT_6POINT1_BACK,
 AV_CH_LAYOUT_7POINT1,
 AV_CH_LAYOUT_22POINT2,
 0,
@@ -97,7 +97,7 @@ static const AVChannelLayout aac_ch_layout[] = {
 AV_CHANNEL_LAYOUT_5POINT0_BACK,
 AV_CHANNEL_LAYOUT_5POINT1_BACK,
 AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK,
-AV_CHANNEL_LAYOUT_6POINT1,
+AV_CHANNEL_LAYOUT_6POINT1_BACK,
 AV_CHANNEL_LAYOUT_7POINT1,
 AV_CHANNEL_LAYOUT_22POINT2,
 { 0 },
-- 
2.38.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 2/3] avutil/channel_layout: add a 7.1(top) channel layout

2022-10-27 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges| 3 +++
 doc/utils.texi| 2 ++
 libavutil/channel_layout.c| 1 +
 libavutil/channel_layout.h| 2 ++
 tests/ref/fate/channel_layout | 1 +
 5 files changed, 9 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5807bf8069..75bbcaddff 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-10-xx - xx - lavu 57.xx.xxx - channel_layout.h
+  Add AV_CH_LAYOUT_7POINT1_TOP and AV_CHANNEL_LAYOUT_7POINT1_TOP.
+
 2022-10-11 - xx - lavu 57.39.101 - pixfmt.h
   Add AV_PIX_FMT_RGBF32 and AV_PIX_FMT_RGBAF32.
 
diff --git a/doc/utils.texi b/doc/utils.texi
index 627b55d154..009452c71d 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -713,6 +713,8 @@ FL+FR+FC+LFE+BL+BR+SL+SR
 FL+FR+FC+LFE+BL+BR+FLC+FRC
 @item 7.1(wide-side)
 FL+FR+FC+LFE+FLC+FRC+SL+SR
+@item 7.1(top)
+FL+FR+FC+LFE+BL+BR+TFL+TFR
 @item octagonal
 FL+FR+FC+BL+BR+BC+SL+SR
 @item hexadecagonal
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 21b70173b7..bc0016d346 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -196,6 +196,7 @@ static const struct channel_layout_name 
channel_layout_map[] = {
 { "7.1",AV_CHANNEL_LAYOUT_7POINT1 },
 { "7.1(wide)",  AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK   },
 { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE},
+{ "7.1(top)",   AV_CHANNEL_LAYOUT_7POINT1_TOP },
 { "octagonal",  AV_CHANNEL_LAYOUT_OCTAGONAL   },
 { "hexadecagonal",  AV_CHANNEL_LAYOUT_HEXADECAGONAL   },
 { "downmix",AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, },
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 059ff70841..0acbdbb9eb 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -232,6 +232,7 @@ enum AVChannelOrder {
 #define AV_CH_LAYOUT_7POINT1   
(AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
 #define AV_CH_LAYOUT_7POINT1_WIDE  
(AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
 #define AV_CH_LAYOUT_7POINT1_WIDE_BACK 
(AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
+#define AV_CH_LAYOUT_7POINT1_TOP   
(AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
 #define AV_CH_LAYOUT_OCTAGONAL 
(AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
 #define AV_CH_LAYOUT_HEXADECAGONAL 
(AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
 #define AV_CH_LAYOUT_STEREO_DOWNMIX(AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
@@ -388,6 +389,7 @@ typedef struct AVChannelLayout {
 #define AV_CHANNEL_LAYOUT_7POINT1   AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_7POINT1)
 #define AV_CHANNEL_LAYOUT_7POINT1_WIDE  AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_7POINT1_WIDE)
 #define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_7POINT1_WIDE_BACK)
+#define AV_CHANNEL_LAYOUT_7POINT1_TOP   AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_7POINT1_TOP)
 #define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_OCTAGONAL)
 #define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, 
AV_CH_LAYOUT_HEXADECAGONAL)
 #define AV_CHANNEL_LAYOUT_STEREO_DOWNMIXAV_CHANNEL_LAYOUT_MASK(2,  
AV_CH_LAYOUT_STEREO_DOWNMIX)
diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout
index 19bcbce7d8..4919e23ac4 100644
--- a/tests/ref/fate/channel_layout
+++ b/tests/ref/fate/channel_layout
@@ -24,6 +24,7 @@ hexagonal  FL+FR+FC+BL+BR+BC
 7.1FL+FR+FC+LFE+BL+BR+SL+SR
 7.1(wide)  FL+FR+FC+LFE+BL+BR+FLC+FRC
 7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
+7.1(top)   FL+FR+FC+LFE+BL+BR+TFL+TFR
 octagonal  FL+FR+FC+BL+BR+BC+SL+SR
 hexadecagonal  FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR
 downmixDL+DR
-- 
2.38.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 3/3] avcodec/aacdec: add support for channel configuration 14

2022-10-27 Thread James Almer
It corresponds to the 7.1(top) layout.

Signed-off-by: James Almer 
---
 libavcodec/aacdec_template.c | 25 +++--
 libavcodec/aacdectab.h   |  6 +++---
 libavcodec/mpeg4audio.c  |  5 +++--
 libavcodec/mpeg4audio.h  |  2 +-
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index c10bc743b6..e5ac5bebca 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -404,6 +404,21 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 i++;
 }
 
+// The previous checks would end up at 4 at this point for chan_config 14
+if (layout == AV_CH_LAYOUT_5POINT1_BACK && tags == 5 && i == 4) {
+const uint8_t (*reference_layout_map)[3] = aac_channel_layout_map[13];
+for (int j = 0; j < tags; j++) {
+if (layout_map[j][0] != reference_layout_map[j][0] ||
+layout_map[j][2] != reference_layout_map[j][2])
+goto end_of_layout_definition;
+}
+
+i += assign_pair(e2c_vec, layout_map, i,
+ AV_CH_TOP_FRONT_LEFT,
+ AV_CH_TOP_FRONT_RIGHT,
+ AAC_CHANNEL_FRONT,
+ &layout);
+}
 // The previous checks would end up at 8 at this point for 22.2
 if (layout == PREFIX_FOR_22POINT2 && tags == 16 && i == 8) {
 const uint8_t (*reference_layout_map)[3] = aac_channel_layout_map[12];
@@ -633,7 +648,7 @@ static int set_default_channel_config(AACContext *ac, 
AVCodecContext *avctx,
   int channel_config)
 {
 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
-channel_config > 13) {
+channel_config > 14) {
 av_log(avctx, AV_LOG_ERROR,
"invalid default channel configuration (%d)\n",
channel_config);
@@ -717,6 +732,12 @@ static ChannelElement *get_che(AACContext *ac, int type, 
int elem_id)
 /* For indexed channel configurations map the channels solely based
  * on position. */
 switch (ac->oc[1].m4ac.chan_config) {
+case 14:
+if (ac->tags_mapped > 2 && ((type == TYPE_CPE && elem_id < 3) ||
+(type == TYPE_LFE && elem_id < 1))) {
+ac->tags_mapped++;
+return ac->tag_che_map[type][elem_id] = ac->che[type][elem_id];
+}
 case 13:
 if (ac->tags_mapped > 3 && ((type == TYPE_CPE && elem_id < 8) ||
 (type == TYPE_SCE && elem_id < 6) ||
@@ -3194,7 +3215,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
void *data,
 
 ac->tags_mapped = 0;
 
-if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || 
chan_config >= 13) {
+if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || 
chan_config > 14) {
 avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
   chan_config);
 return AVERROR_INVALIDDATA;
diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h
index 327efbcde0..55a91cb4fe 100644
--- a/libavcodec/aacdectab.h
+++ b/libavcodec/aacdectab.h
@@ -68,8 +68,8 @@ static const uint8_t aac_channel_layout_map[16][16][3] = {
   { TYPE_SCE, 5, AAC_CHANNEL_FRONT }, // SCE6 = BtFC,
   { TYPE_CPE, 7, AAC_CHANNEL_FRONT }, // CPE8 = BtFL and BtFR
 },
+{ { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, 
{ TYPE_CPE, 1, AAC_CHANNEL_BACK }, { TYPE_LFE, 0, AAC_CHANNEL_LFE }, { 
TYPE_CPE, 2, AAC_CHANNEL_FRONT  }, },
 { { 0, } },
-/* TODO: Add 7+1 TOP configuration */
 };
 
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -84,8 +84,8 @@ static const uint64_t aac_channel_layout[] = {
 AV_CH_LAYOUT_6POINT1_BACK,
 AV_CH_LAYOUT_7POINT1,
 AV_CH_LAYOUT_22POINT2,
+AV_CH_LAYOUT_7POINT1_TOP,
 0,
-/* AV_CH_LAYOUT_7POINT1_TOP, */
 };
 #endif
 
@@ -100,8 +100,8 @@ static const AVChannelLayout aac_ch_layout[] = {
 AV_CHANNEL_LAYOUT_6POINT1_BACK,
 AV_CHANNEL_LAYOUT_7POINT1,
 AV_CHANNEL_LAYOUT_22POINT2,
+AV_CHANNEL_LAYOUT_7POINT1_TOP,
 { 0 },
-/* AV_CHANNEL_LAYOUT_7POINT1_TOP, */
 };
 
 #endif /* AVCODEC_AACDECTAB_H */
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index e38a8c0852..4a996411d1 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -56,7 +56,7 @@ static int parse_config_ALS(GetBitContext *gb, 
MPEG4AudioConfig *c, void *logctx
 return 0;
 }
 
-const uint8_t ff_mpeg4audio_channels[14] = {
+const uint8_t ff_mpeg4audio_channels[15] = {
 0,
 1, // mono (1/0)
 2, // stereo (2/0)
@@ -70,7 +70,8 @@ const uint8_t ff_mpeg4audio_channels[14] = {
 0,
 7, // 3/3.1
 8, // 3/2/2.1
-24 // 3/3/3 - 5/2/3 - 3/0/0.2
+24, // 3/3/3 - 5/2/3 - 3/0/0.2
+8 // 3/2.1 - 2/0
 };
 
 static inline int get_object_type(GetBitContext *gb)
diff --git a/libavcodec/mpe

Re: [FFmpeg-devel] [PATCH v9 23/25] avcodec/subtitles: Migrate subtitle encoders to frame-based API

2022-10-27 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Thursday, October 27, 2022 7:54 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v9 23/25] avcodec/subtitles:
> Migrate subtitle encoders to frame-based API
> 
> On Tue, Oct 25, 2022 at 09:13:44AM +, softworkz wrote:
> > From: softworkz 
> >
> > and provide a compatibility shim for the legacy api
> >
> > Signed-off-by: softworkz 
> > ---
> >  libavcodec/assenc.c | 189 ++--
> 
> >  libavcodec/avcodec.h|   5 +-
> >  libavcodec/codec_internal.h |  12 ---
> >  libavcodec/dvbsubenc.c  |  96 ++
> >  libavcodec/dvdsubenc.c  | 103 
> >  libavcodec/encode.c |  61 +++-
> >  libavcodec/movtextenc.c | 114 --
> >  libavcodec/srtenc.c | 108 ++---
> >  libavcodec/tests/avcodec.c  |   5 +-
> >  libavcodec/ttmlenc.c| 101 ++-
> >  libavcodec/utils.c  |   1 -
> >  libavcodec/webvttenc.c  |  86 +++-
> >  libavcodec/xsubenc.c|  88 ++---
> >  13 files changed, 689 insertions(+), 280 deletions(-)
> 
> Causes this testcase to fail:
> ./ffmpeg -i 'bgc.sub.dub.ogm'  -vframes 3 -bitexact -y nosubs.webm
> 
> https://samples.ffmpeg.org/ogg/
> 
> I did not investgate why or if this a bug or expected. Just reporting
> a difference
> ive seen

Hi Michael,

thanks a lot for testing my patchset! 

I have run the command with and without my patchset and I can confirm
that the output is different.

Though, from analyzing the output files, it appears that the output
with my patchset applied seems "more correct" than the output that ffmpeg
is currently creating.

The details of the investigation can be found here:
https://github.com/softworkz/SubtitleFilteringDemos/issues/2


Thanks again,
softworkz


___
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/mss2: initialise wmv9_mask variable

2022-10-27 Thread Peter Ross
initialised to -1 which indicates wmv9 codec not present
---
 libavcodec/mss2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 69494d8c44..14746505f4 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -519,7 +519,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 
 struct Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;
 struct Rectangle2 draw;
-int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask);
+int used_rects = 0, i, implicit_rect = 0, wmv9_mask = -1;
 
 if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
 return ret;
-- 
2.35.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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/svq3: perform residual slice copy before xor'ing watermark key

2022-10-27 Thread Peter Ross
Fixes ticket #5387
---
 libavcodec/svq3.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 7e8f16cc72..b96c4f61f6 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1037,15 +1037,16 @@ static int svq3_decode_slice_header(AVCodecContext 
*avctx)
 }
 memcpy(s->slice_buf, s->gb.buffer + s->gb.index / 8, slice_bytes);
 
+if (length > 0) {
+memmove(s->slice_buf, &s->slice_buf[slice_length], length - 1);
+}
+
 if (s->watermark_key) {
 uint32_t header = AV_RL32(&s->slice_buf[1]);
 AV_WL32(&s->slice_buf[1], header ^ s->watermark_key);
 }
 init_get_bits(&s->gb_slice, s->slice_buf, slice_bits);
 
-if (length > 0) {
-memmove(s->slice_buf, &s->slice_buf[slice_length], length - 1);
-}
 skip_bits_long(&s->gb, slice_bytes * 8);
 }
 
-- 
2.35.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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