Re: [FFmpeg-devel] [PATCH 09/11] avfilter/overlay_vaapi: enable expressions for overlay parameters

2022-10-30 Thread Soft Works



> -Original Message-
> From: Xiang, Haihao 
> Sent: Monday, October 31, 2022 6:44 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: softwo...@hotmail.com
> Subject: Re: [FFmpeg-devel] [PATCH 09/11] avfilter/overlay_vaapi:
> enable expressions for overlay parameters
> 
> On Mon, 2022-10-10 at 10:54 +, softworkz wrote:
> > From: softworkz 
> >
> > Signed-off-by: softworkz 
> > ---
> >  libavfilter/vf_overlay_vaapi.c | 141
> +
> >  1 file changed, 127 insertions(+), 14 deletions(-)
> >
> > diff --git a/libavfilter/vf_overlay_vaapi.c
> b/libavfilter/vf_overlay_vaapi.c
> > index b2c254d9dd..7be7d52589 100644
> > --- a/libavfilter/vf_overlay_vaapi.c
> > +++ b/libavfilter/vf_overlay_vaapi.c
> > @@ -27,19 +27,106 @@
> >  #include "formats.h"
> >  #include "internal.h"
> >  #include "vaapi_vpp.h"
> > +#include "libavutil/eval.h"
> > +
> > +enum var_name {
> > +VAR_MAIN_iW, VAR_MW,
> > +VAR_MAIN_iH, VAR_MH,
> > +VAR_OVERLAY_iW,
> > +VAR_OVERLAY_iH,
> 
> It is better not to mix capital and lower-case letters here, (I have
> a patch to
> change the var_name in qsv)

Yea - I had done it equal to overlay_qsv.
I'll change it, no problem.

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


Re: [FFmpeg-devel] [PATCH 01/11] avfilter/overlay_vaapi: use FILTER_SINGLE_PIXFMT

2022-10-30 Thread Xiang, Haihao
On Mon, 2022-10-10 at 10:54 +, softworkz wrote:
> From: softworkz 
> 
> Signed-off-by: softworkz 
> ---
>  libavfilter/vf_overlay_vaapi.c | 30 +-
>  1 file changed, 1 insertion(+), 29 deletions(-)
> 
> diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c
> index 3e6a0de13f..218daf571f 100644
> --- a/libavfilter/vf_overlay_vaapi.c
> +++ b/libavfilter/vf_overlay_vaapi.c
> @@ -38,34 +38,6 @@ typedef struct OverlayVAAPIContext {
>  floatalpha;
>  } OverlayVAAPIContext;
>  
> -static int overlay_vaapi_query_formats(AVFilterContext *ctx)
> -{
> -int ret;
> -enum {
> -MAIN= 0,
> -OVERLAY = 1,
> -};
> -
> -static const enum AVPixelFormat pix_fmts[] = {
> -AV_PIX_FMT_VAAPI,
> -AV_PIX_FMT_NONE
> -};
> -
> -ret = ff_formats_ref(ff_make_format_list(pix_fmts), >inputs[MAIN]-
> >outcfg.formats);
> -if (ret < 0)
> -return ret;
> -
> -ret = ff_formats_ref(ff_make_format_list(pix_fmts), 
> >inputs[OVERLAY]->outcfg.formats);
> -if (ret < 0)
> -return ret;
> -
> -ret = ff_formats_ref(ff_make_format_list(pix_fmts), >outputs[0]-
> >incfg.formats);
> -if (ret < 0)
> -return ret;
> -
> -return 0;
> -}
> -
>  static int overlay_vaapi_build_filter_params(AVFilterContext *avctx)
>  {
>  VAAPIVPPContext *vpp_ctx   = avctx->priv;
> @@ -418,6 +390,6 @@ const AVFilter ff_vf_overlay_vaapi = {
>  .activate= _vaapi_activate,
>  FILTER_INPUTS(overlay_vaapi_inputs),
>  FILTER_OUTPUTS(overlay_vaapi_outputs),
> -FILTER_QUERY_FUNC(overlay_vaapi_query_formats),
> +FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VAAPI),
>  .flags_internal  = FF_FILTER_FLAG_HWFRAME_AWARE,
>  };

Patchset LGTM except a nitpicky comment about coding style in patch 09/11. 

Thanks
Haihao

___
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 09/11] avfilter/overlay_vaapi: enable expressions for overlay parameters

2022-10-30 Thread Xiang, Haihao
On Mon, 2022-10-10 at 10:54 +, softworkz wrote:
> From: softworkz 
> 
> Signed-off-by: softworkz 
> ---
>  libavfilter/vf_overlay_vaapi.c | 141 +
>  1 file changed, 127 insertions(+), 14 deletions(-)
> 
> diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c
> index b2c254d9dd..7be7d52589 100644
> --- a/libavfilter/vf_overlay_vaapi.c
> +++ b/libavfilter/vf_overlay_vaapi.c
> @@ -27,19 +27,106 @@
>  #include "formats.h"
>  #include "internal.h"
>  #include "vaapi_vpp.h"
> +#include "libavutil/eval.h"
> +
> +enum var_name {
> +VAR_MAIN_iW, VAR_MW,
> +VAR_MAIN_iH, VAR_MH,
> +VAR_OVERLAY_iW,
> +VAR_OVERLAY_iH,

It is better not to mix capital and lower-case letters here, (I have a patch to
change the var_name in qsv)

Thanks
Haihao


> +VAR_OVERLAY_X,  VAR_OX,
> +VAR_OVERLAY_Y,  VAR_OY,
> +VAR_OVERLAY_W,  VAR_OW,
> +VAR_OVERLAY_H,  VAR_OH,
> +VAR_VARS_NB
> +};
>  
>  typedef struct OverlayVAAPIContext {
>  VAAPIVPPContext  vpp_ctx; /**< must be the first field */
>  FFFrameSync  fs;
> -int  overlay_ox;
> -int  overlay_oy;
> -int  overlay_ow;
> -int  overlay_oh;
> +
> +double   var_values[VAR_VARS_NB];
> +char *overlay_ox;
> +char *overlay_oy;
> +char *overlay_ow;
> +char *overlay_oh;
> +int  ox;
> +int  oy;
> +int  ow;
> +int  oh;
>  floatalpha;
>  unsigned int blend_flags;
>  floatblend_alpha;
>  } OverlayVAAPIContext;
>  
> +static const char *const var_names[] = {
> +"main_w", "W",   /* input width of the main layer */
> +"main_h", "H",   /* input height of the main layer */
> +"overlay_iw",/* input width of the overlay layer */
> +"overlay_ih",/* input height of the overlay layer */
> +"overlay_x",  "x",   /* x position of the overlay layer inside of main */
> +"overlay_y",  "y",   /* y position of the overlay layer inside of main */
> +"overlay_w",  "w",   /* output width of overlay layer */
> +"overlay_h",  "h",   /* output height of overlay layer */
> +NULL
> +};
> +
> +static int eval_expr(AVFilterContext *avctx)
> +{
> +OverlayVAAPIContext *ctx = avctx->priv;
> +double   *var_values = ctx->var_values;
> +int  ret = 0;
> +AVExpr *ox_expr = NULL, *oy_expr = NULL;
> +AVExpr *ow_expr = NULL, *oh_expr = NULL;
> +
> +#define PARSE_EXPR(e, s) {\
> +ret = av_expr_parse(&(e), s, var_names, NULL, NULL, NULL, NULL, 0, ctx);
> \
> +if (ret < 0) {\
> +av_log(ctx, AV_LOG_ERROR, "Error when parsing '%s'.\n", s);\
> +goto release;\
> +}\
> +}
> +PARSE_EXPR(ox_expr, ctx->overlay_ox)
> +PARSE_EXPR(oy_expr, ctx->overlay_oy)
> +PARSE_EXPR(ow_expr, ctx->overlay_ow)
> +PARSE_EXPR(oh_expr, ctx->overlay_oh)
> +#undef PASS_EXPR
> +
> +var_values[VAR_OVERLAY_W] =
> +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL);
> +var_values[VAR_OVERLAY_H] =
> +var_values[VAR_OH]= av_expr_eval(oh_expr, var_values, NULL);
> +
> +/* calc again in case ow is relative to oh */
> +var_values[VAR_OVERLAY_W] =
> +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL);
> +
> +var_values[VAR_OVERLAY_X] =
> +var_values[VAR_OX]= av_expr_eval(ox_expr, var_values, NULL);
> +var_values[VAR_OVERLAY_Y] =
> +var_values[VAR_OY]= av_expr_eval(oy_expr, var_values, NULL);
> +
> +/* calc again in case ox is relative to oy */
> +var_values[VAR_OVERLAY_X] =
> +var_values[VAR_OX]= av_expr_eval(ox_expr, var_values, NULL);
> +
> +/* calc overlay_w and overlay_h again incase relative to ox,oy */
> +var_values[VAR_OVERLAY_W] =
> +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL);
> +var_values[VAR_OVERLAY_H] =
> +var_values[VAR_OH]= av_expr_eval(oh_expr, var_values, NULL);
> +var_values[VAR_OVERLAY_W] =
> +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL);
> +
> +release:
> +av_expr_free(ox_expr);
> +av_expr_free(oy_expr);
> +av_expr_free(ow_expr);
> +av_expr_free(oh_expr);
> +
> +return ret;
> +}
> +
>  static int overlay_vaapi_build_filter_params(AVFilterContext *avctx)
>  {
>  VAAPIVPPContext *vpp_ctx   = avctx->priv;
> @@ -233,10 +320,10 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
> input_overlay->width, input_overlay->height, input_overlay-
> >pts);
>  
>  overlay_region = (VARectangle) {
> -.x  = ctx->overlay_ox,
> -.y  = ctx->overlay_oy,
> -.width  = ctx->overlay_ow ? ctx->overlay_ow : input_overlay-
> >width,
> -.height = ctx->overlay_oh ? ctx->overlay_oh : 

Re: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Clément Bœsch
> Sent: Monday, October 31, 2022 1:30 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Revert
> "avfilter/vf_palette(gen|use): support palettes with alpha"
> 
> On Sun, Oct 30, 2022 at 10:55:31PM +, Soft Works wrote:
> [...]
> 
> > Do you think it might make sense to put more weight on the
> > alpha value by tripling it? So it would be weighted equally to the
> > RGB value?
> 
> You cannot mix alpha with colors at all, they are separate domains
> and you
> need to treat them as such.
> 
> From paletteuse perspective what you need to do is first choose the
> colors
> in the palette that match exactly the alpha (or at least the closest
> if
> and only there is no exact match). Then within that set, and only
> within
> that one, you'd pick the closest color.
> 
> From palettegen perspective, you need to split the colors in
> different
> transparency domain (a first dimensional quantization), then quantize
> the
> colors in each quantized alpha dimension. And when you have all your
> quantized palettes for each level of alpha, you find an algorithm to
> reduce the number of transparency dimensions or the number of colors
> per
> dimension to make it fit inside a single palette. But you can't just
> do
> the alpha and the colors at the same time, it cannot work, whatever
> weights you choose.

Interestingly, pngquant which is supposed to have the best open source
quantization algorithms seems to be using weights (albeit in a more 
sophisticated way) and does not handle alpha separately for calculating 
color distance, variance and averaging:

https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/pam.h#L163-L182
https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/mediancut.c#L29-L49
https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/mediancut.c#L449-L476


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


Re: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Clément Bœsch
> Sent: Monday, October 31, 2022 1:30 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Revert
> "avfilter/vf_palette(gen|use): support palettes with alpha"
> 
> On Sun, Oct 30, 2022 at 10:55:31PM +, Soft Works wrote:
> [...]
> > > I understand why. I know that it's not perfect. But it's the best
> > > what's achievable within the way the filter is working.
> > >
> > > But I wouldn't go that far as saying it would be "broken". I
> think
> > > the result is quite acceptable with regards to the method being
> > > using.
> 
> It's broken because the alpha channel in the output is really
> completely
> random. If we blend the output of that "O" PNG somewhere, it's going
> to be
> a real mess.
> 
> Here is a more concrete example: if your input has some red fully
> transparent (00ff), and some red fully opaque () which
> end up
> in the same box, they will be averaged to a red with an alpha of
> 0x80, and
> I'm not even accounting for the weight and other colors with
> different
> transparency. That non-opaque average alpha might end up being used
> in
> area that are expected to be opaque, and in some area where it's
> supposed
> to be transparent. That's exactly what I showed with the "O" png.
> 
> In addition to that problem, since you're also accounting the alpha
> as a
> weight to determine the proximity of 2 colors, you're going to select
> the
> wrong colors. For example if we want to find the closest color to an
> opaque green (ff00ff00), and the palette has a slightly transparent
> green
> (fa00ff00) and an opaque blue (ffff), then now the algorithm will
> prefer the blue over the green.
> 
> That explains why in addition to the alpha being random in the "O"
> png,
> the colors are also messed up.
> 
> > > The patch I had submitted doesn't change the previous behavior
> > > without the use_alpha parameter.
> 
> Yes I noticed, but unfortunately I'm reworking the color distance to
> work
> in perceptual color space, and the way that alpha is mixed up in the
> equation just doesn't make any sense at all and prevents me from
> doing
> these changes. 

If you want to implement a new color distance algorithm, it should 
be either a new filter or a new (switchable) mode for the existing 
filter. Photoshop has these different modes as well and it would 
surely be useful, but I don't think it should be replacing the
existing behavior.

When it turns out that the use_alpha implementation doesn't fit
with your new color distance calculation and you add it as 
an additional mode, then it would be fine IMO when the filter
errors in case it would be attempted to use that mode in 
combination with use_alpha.


> > Do you think it might make sense to put more weight on the
> > alpha value by tripling it? So it would be weighted equally to the
> > RGB value?
> 
> You cannot mix alpha with colors at all, they are separate domains
> and you
> need to treat them as such.

What's interesting is that I've followed the same (simplified)
way for adding a use_alpha option to vf_elbg and it provides excellent
results without treating alpha separately.


> From paletteuse perspective what you need to do is first choose the
> colors
> in the palette that match exactly the alpha (or at least the closest
> if
> and only there is no exact match). Then within that set, and only
> within
> that one, you'd pick the closest color.
> 
> From palettegen perspective, you need to split the colors in
> different
> transparency domain (a first dimensional quantization), then quantize
> the
> colors in each quantized alpha dimension. And when you have all your
> quantized palettes for each level of alpha, you find an algorithm to
> reduce the number of transparency dimensions or the number of colors
> per
> dimension to make it fit inside a single palette. But you can't just
> do
> the alpha and the colors at the same time, it cannot work, whatever
> weights you choose.

I would be curious to see how well that would work, especially
in cases when the target palettes have just a few number of colors.


But to return to the proposal of removal: If everything from ffmpeg
would be removed which is not perfect, then it would be lacking
quite a number of features I suppose :-)

In the same way, one could say that palettegen/-use should be removed
because its results are wrong and colors are randomly mixed and 
misplaced while the vf_elbg filter does it right.

When you look at the result under the heading

"Paletteuse/gen Regular (to 8-bit non-alpha palette; only single 
transparent color)"
https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f?permalink_comment_id=3905155#gistcomment-3905155

Even without the alpha, many color pixels appear to be wrong and
random like for example the light purple pixels on the darker purple
at the bottom of the "O". That's not much different 

[FFmpeg-devel] [PATCH v2 4/4] swscale/output: add rgbaf32 output support

2022-10-30 Thread mindmark
From: Mark Reid 

---
 libswscale/output.c  | 92 
 libswscale/swscale_unscaled.c|  4 +-
 libswscale/tests/floatimg_cmp.c  |  4 +-
 libswscale/utils.c   | 16 +++--
 libswscale/yuv2rgb.c |  2 +
 tests/ref/fate/filter-pixdesc-rgbaf32be  |  1 +
 tests/ref/fate/filter-pixdesc-rgbaf32le  |  1 +
 tests/ref/fate/filter-pixdesc-rgbf32be   |  1 +
 tests/ref/fate/filter-pixdesc-rgbf32le   |  1 +
 tests/ref/fate/filter-pixfmts-copy   |  4 ++
 tests/ref/fate/filter-pixfmts-crop   |  4 ++
 tests/ref/fate/filter-pixfmts-field  |  4 ++
 tests/ref/fate/filter-pixfmts-fieldorder |  4 ++
 tests/ref/fate/filter-pixfmts-hflip  |  4 ++
 tests/ref/fate/filter-pixfmts-il |  4 ++
 tests/ref/fate/filter-pixfmts-null   |  4 ++
 tests/ref/fate/filter-pixfmts-scale  |  4 ++
 tests/ref/fate/filter-pixfmts-transpose  |  4 ++
 tests/ref/fate/filter-pixfmts-vflip  |  4 ++
 tests/ref/fate/sws-floatimg-cmp  | 16 +
 20 files changed, 170 insertions(+), 8 deletions(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le

diff --git a/libswscale/output.c b/libswscale/output.c
index 0e1c1225a0..e2ec9cbdf5 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2474,6 +2474,92 @@ yuv2gbrpf32_full_X_c(SwsContext *c, const int16_t 
*lumFilter,
 }
 }
 
+static void
+yuv2rgbaf32_full_X_c(SwsContext *c, const int16_t *lumFilter,
+const int16_t **lumSrcx, int lumFilterSize,
+const int16_t *chrFilter, const int16_t **chrUSrcx,
+const int16_t **chrVSrcx, int chrFilterSize,
+const int16_t **alpSrcx, uint8_t *dest,
+int dstW, int y)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat);
+int i;
+int alpha = desc->flags & AV_PIX_FMT_FLAG_ALPHA;
+int hasAlpha = alpha && alpSrcx;
+int pixelStep = alpha ? 4 : 3;
+uint32_t *dest32 = (uint32_t*)dest;
+const int32_t **lumSrc  = (const int32_t**)lumSrcx;
+const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
+const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
+const int32_t **alpSrc  = (const int32_t**)alpSrcx;
+static const float float_mult = 1.0f / 65535.0f;
+uint32_t a = av_float2int(1.0f);
+
+for (i = 0; i < dstW; i++) {
+int j;
+int Y = -0x4000;
+int U = -(128 << 23);
+int V = -(128 << 23);
+int R, G, B, A;
+
+for (j = 0; j < lumFilterSize; j++)
+Y += lumSrc[j][i] * (unsigned)lumFilter[j];
+
+for (j = 0; j < chrFilterSize; j++) {
+U += chrUSrc[j][i] * (unsigned)chrFilter[j];
+V += chrVSrc[j][i] * (unsigned)chrFilter[j];
+}
+
+Y >>= 14;
+Y += 0x1;
+U >>= 14;
+V >>= 14;
+
+if (hasAlpha) {
+A = -0x4000;
+
+for (j = 0; j < lumFilterSize; j++)
+A += alpSrc[j][i] * (unsigned)lumFilter[j];
+
+A >>= 1;
+A += 0x20002000;
+a = av_float2int(float_mult * (float)(av_clip_uintp2(A, 30) >> 
14));
+}
+
+Y -= c->yuv2rgb_y_offset;
+Y *= c->yuv2rgb_y_coeff;
+Y += 1 << 13;
+R = V * c->yuv2rgb_v2r_coeff;
+G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
+B =U * c->yuv2rgb_u2b_coeff;
+
+R = av_clip_uintp2(Y + R, 30);
+G = av_clip_uintp2(Y + G, 30);
+B = av_clip_uintp2(Y + B, 30);
+
+dest32[0] = av_float2int(float_mult * (float)(R >> 14));
+dest32[1] = av_float2int(float_mult * (float)(G >> 14));
+dest32[2] = av_float2int(float_mult * (float)(B >> 14));
+if (alpha)
+dest32[3] = a;
+
+dest32 += pixelStep;
+}
+if ((!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
+dest32 = (uint32_t*)dest;
+for (i = 0; i < dstW; i++) {
+dest32[0] = av_bswap32(dest32[0]);
+dest32[1] = av_bswap32(dest32[1]);
+dest32[2] = av_bswap32(dest32[2]);
+if (alpha)
+dest32[3] = av_bswap32(dest32[3]);
+
+dest32 += pixelStep;
+}
+}
+
+}
+
 static void
 yuv2ya8_1_c(SwsContext *c, const int16_t *buf0,
 const int16_t *ubuf[2], const int16_t *vbuf[2],
@@ -2986,6 +3072,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
 }
 break;
 
+case AV_PIX_FMT_RGBF32LE:
+case AV_PIX_FMT_RGBF32BE:
+case AV_PIX_FMT_RGBAF32LE:
+case AV_PIX_FMT_RGBAF32BE:
+*yuv2packedX = yuv2rgbaf32_full_X_c;
+break;
 case AV_PIX_FMT_RGB24:
 *yuv2packedX = yuv2rgb24_full_X_c;

[FFmpeg-devel] [PATCH v2 3/4] avfilter/vf_transpose: add support for packed rgb float formats

2022-10-30 Thread mindmark
From: Mark Reid 

---
 libavfilter/vf_transpose.c | 44 ++
 1 file changed, 44 insertions(+)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 469e66729f..1023d6fe82 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -174,6 +174,46 @@ static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t 
src_linesize,
 transpose_block_64_c(src, src_linesize, dst, dst_linesize, 8, 8);
 }
 
+static inline void transpose_block_96_c(uint8_t *src, ptrdiff_t src_linesize,
+uint8_t *dst, ptrdiff_t dst_linesize,
+int w, int h)
+{
+int x, y;
+for (y = 0; y < h; y++, dst += dst_linesize, src += 12) {
+for (x = 0; x < w; x++) {
+*((uint32_t *)(dst+0 + 12*x)) = *((uint32_t *)(src+0 + 
x*src_linesize));
+*((uint32_t *)(dst+4 + 12*x)) = *((uint32_t *)(src+4 + 
x*src_linesize));
+*((uint32_t *)(dst+8 + 12*x)) = *((uint32_t *)(src+8 + 
x*src_linesize));
+}
+}
+}
+
+static void transpose_8x8_96_c(uint8_t *src, ptrdiff_t src_linesize,
+   uint8_t *dst, ptrdiff_t dst_linesize)
+{
+transpose_block_96_c(src, src_linesize, dst, dst_linesize, 8, 8);
+}
+
+
+static inline void transpose_block_128_c(uint8_t *src, ptrdiff_t src_linesize,
+ uint8_t *dst, ptrdiff_t dst_linesize,
+ int w, int h)
+{
+int x, y;
+for (y = 0; y < h; y++, dst += dst_linesize, src += 16) {
+for (x = 0; x < w; x++) {
+*((uint64_t *)(dst+0 + 16*x)) = *((uint64_t *)(src+0 + 
x*src_linesize));
+*((uint64_t *)(dst+8 + 16*x)) = *((uint64_t *)(src+8 + 
x*src_linesize));
+}
+}
+}
+
+static void transpose_8x8_128_c(uint8_t *src, ptrdiff_t src_linesize,
+uint8_t *dst, ptrdiff_t dst_linesize)
+{
+transpose_block_128_c(src, src_linesize, dst, dst_linesize, 8, 8);
+}
+
 static int config_props_output(AVFilterLink *outlink)
 {
 AVFilterContext *ctx = outlink->src;
@@ -232,6 +272,10 @@ static int config_props_output(AVFilterLink *outlink)
 v->transpose_8x8   = transpose_8x8_48_c; break;
 case 8: v->transpose_block = transpose_block_64_c;
 v->transpose_8x8   = transpose_8x8_64_c; break;
+case 12: v->transpose_block = transpose_block_96_c;
+ v->transpose_8x8   = transpose_8x8_96_c; break;
+case 16: v->transpose_block = transpose_block_128_c;
+ v->transpose_8x8   = transpose_8x8_128_c; break;
 }
 }
 
-- 
2.31.1.windows.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 v2 2/4] avfilter/vf_hflip: add support for packed rgb float formats

2022-10-30 Thread mindmark
From: Mark Reid 

---
 libavfilter/vf_hflip_init.h | 25 +
 1 file changed, 25 insertions(+)

diff --git a/libavfilter/vf_hflip_init.h b/libavfilter/vf_hflip_init.h
index d0319f463d..31173f73fc 100644
--- a/libavfilter/vf_hflip_init.h
+++ b/libavfilter/vf_hflip_init.h
@@ -86,6 +86,29 @@ static void hflip_qword_c(const uint8_t *ssrc, uint8_t 
*ddst, int w)
 dst[j] = src[-j];
 }
 
+static void hflip_b96_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint32_t *in = (const uint32_t *)ssrc;
+uint32_t *out = (uint32_t *)ddst;
+
+for (int j = 0; j < w; j++, out += 3, in -= 3) {
+out[0] = in[0];
+out[1] = in[1];
+out[2] = in[2];
+}
+}
+
+static void hflip_b128_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+const uint64_t *in = (const uint64_t *)ssrc;
+uint64_t *out = (uint64_t *)ddst;
+
+for (int j = 0; j < w; j++, out += 2, in -= 2) {
+out[0] = in[0];
+out[1] = in[1];
+}
+}
+
 static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
 {
 for (int i = 0; i < nb_planes; i++) {
@@ -97,6 +120,8 @@ static av_unused int ff_hflip_init(FlipContext *s, int 
step[4], int nb_planes)
 case 4: s->flip_line[i] = hflip_dword_c; break;
 case 6: s->flip_line[i] = hflip_b48_c;   break;
 case 8: s->flip_line[i] = hflip_qword_c; break;
+case 12: s->flip_line[i] = hflip_b96_c; break;
+case 16: s->flip_line[i] = hflip_b128_c; break;
 default:
 return AVERROR_BUG;
 }
-- 
2.31.1.windows.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 v2 1/4] swscale/input: add rgbaf32 input support

2022-10-30 Thread mindmark
From: Mark Reid 

---
 libswscale/input.c | 172 +
 libswscale/utils.c |   4 ++
 2 files changed, 176 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 7ff7bfaa01..4683284b0b 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1284,6 +1284,136 @@ static void rgbaf16##endian_name##ToA_c(uint8_t *_dst, 
const uint8_t *_src, cons
 rgbaf16_funcs_endian(le, 0)
 rgbaf16_funcs_endian(be, 1)
 
+#define rdpx(src) (is_be ? av_int2float(AV_RB32()): 
av_int2float(AV_RL32()))
+
+static av_always_inline void rgbaf32ToUV_half_endian(uint16_t *dstU, uint16_t 
*dstV, int is_be,
+ const float *src, int 
width,
+ int32_t *rgb2yuv, int 
comp)
+{
+int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
+int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
+int i;
+for (i = 0; i < width; i++) {
+int r = (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+0]), 0.0f, 
65535.0f)) +
+ lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+4]), 0.0f, 
65535.0f))) >> 1;
+int g = (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+1]), 0.0f, 
65535.0f)) +
+ lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+5]), 0.0f, 
65535.0f))) >> 1;
+int b = (lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+2]), 0.0f, 
65535.0f)) +
+ lrintf(av_clipf(65535.0f * rdpx(src[i*(comp*2)+6]), 0.0f, 
65535.0f))) >> 1;
+
+dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
+dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
+}
+}
+
+static av_always_inline void rgbaf32ToUV_endian(uint16_t *dstU, uint16_t 
*dstV, int is_be,
+const float *src, int width,
+int32_t *rgb2yuv, int comp)
+{
+int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
+int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
+int i;
+for (i = 0; i < width; i++) {
+int r = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, 
65535.0f));
+int g = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, 
65535.0f));
+int b = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, 
65535.0f));
+
+dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
+dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
+}
+}
+
+static av_always_inline void rgbaf32ToY_endian(uint16_t *dst, const float 
*src, int is_be,
+   int width, int32_t *rgb2yuv, 
int comp)
+{
+int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
+int i;
+for (i = 0; i < width; i++) {
+int r = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, 
65535.0f));
+int g = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, 
65535.0f));
+int b = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, 
65535.0f));
+
+dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
+}
+}
+
+static av_always_inline void rgbaf32ToA_endian(uint16_t *dst, const float 
*src, int is_be,
+   int width, void *opq)
+{
+int i;
+for (i=0; isrcFormat;
@@ -1570,6 +1700,18 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_RGBAF16LE:
 c->chrToYV12 = rgbaf16leToUV_half_c;
 break;
+case AV_PIX_FMT_RGBF32BE:
+c->chrToYV12 = rgbf32beToUV_half_c;
+break;
+case AV_PIX_FMT_RGBAF32BE:
+c->chrToYV12 = rgbaf32beToUV_half_c;
+break;
+case AV_PIX_FMT_RGBF32LE:
+c->chrToYV12 = rgbf32leToUV_half_c;
+break;
+case AV_PIX_FMT_RGBAF32LE:
+c->chrToYV12 = rgbaf32leToUV_half_c;
+break;
 }
 } else {
 switch (srcFormat) {
@@ -1663,6 +1805,18 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_RGBAF16LE:
 c->chrToYV12 = rgbaf16leToUV_c;
 break;
+case AV_PIX_FMT_RGBF32BE:
+c->chrToYV12 = rgbf32beToUV_c;
+break;
+case AV_PIX_FMT_RGBAF32BE:
+c->chrToYV12 = rgbaf32beToUV_c;
+break;
+case AV_PIX_FMT_RGBF32LE:
+c->chrToYV12 = rgbf32leToUV_c;
+break;
+case AV_PIX_FMT_RGBAF32LE:
+c->chrToYV12 = rgbaf32leToUV_c;
+break;
 }
 }
 
@@ -1973,6 +2127,18 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_RGBAF16LE:
 c->lumToYV12 = rgbaf16leToY_c;
 break;
+case AV_PIX_FMT_RGBF32BE:
+

[FFmpeg-devel] [PATCH v2 0/4] swscale rgbaf32 input/output support

2022-10-30 Thread mindmark
From: Mark Reid 

This patch series adds swscale input/output support for the packed rgb float 
formats.
A few of the filters also needed support the larger 96/128 bit packed pixel 
sizes.

I also plan to eventually add lossless unscaled conversions between the planer 
and packed formats.

changes since v1
* output correct alpha is src doesn't have alpha

Mark Reid (4):
  swscale/input: add rgbaf32 input support
  avfilter/vf_hflip: add support for packed rgb float formats
  avfilter/vf_transpose: add support for packed rgb float formats
  swscale/output: add rgbaf32 output support

 libavfilter/vf_hflip_init.h  |  25 
 libavfilter/vf_transpose.c   |  44 ++
 libswscale/input.c   | 172 +++
 libswscale/output.c  |  92 
 libswscale/swscale_unscaled.c|   4 +-
 libswscale/tests/floatimg_cmp.c  |   4 +-
 libswscale/utils.c   |  12 +-
 libswscale/yuv2rgb.c |   2 +
 tests/ref/fate/filter-pixdesc-rgbaf32be  |   1 +
 tests/ref/fate/filter-pixdesc-rgbaf32le  |   1 +
 tests/ref/fate/filter-pixdesc-rgbf32be   |   1 +
 tests/ref/fate/filter-pixdesc-rgbf32le   |   1 +
 tests/ref/fate/filter-pixfmts-copy   |   4 +
 tests/ref/fate/filter-pixfmts-crop   |   4 +
 tests/ref/fate/filter-pixfmts-field  |   4 +
 tests/ref/fate/filter-pixfmts-fieldorder |   4 +
 tests/ref/fate/filter-pixfmts-hflip  |   4 +
 tests/ref/fate/filter-pixfmts-il |   4 +
 tests/ref/fate/filter-pixfmts-null   |   4 +
 tests/ref/fate/filter-pixfmts-scale  |   4 +
 tests/ref/fate/filter-pixfmts-transpose  |   4 +
 tests/ref/fate/filter-pixfmts-vflip  |   4 +
 tests/ref/fate/sws-floatimg-cmp  |  16 +++
 23 files changed, 411 insertions(+), 4 deletions(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be
 create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le

--
2.31.1.windows.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] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Clément Bœsch
On Sun, Oct 30, 2022 at 10:55:31PM +, Soft Works wrote:
[...]
> > I understand why. I know that it's not perfect. But it's the best
> > what's achievable within the way the filter is working.
> > 
> > But I wouldn't go that far as saying it would be "broken". I think
> > the result is quite acceptable with regards to the method being
> > using.

It's broken because the alpha channel in the output is really completely
random. If we blend the output of that "O" PNG somewhere, it's going to be
a real mess.

Here is a more concrete example: if your input has some red fully
transparent (00ff), and some red fully opaque () which end up
in the same box, they will be averaged to a red with an alpha of 0x80, and
I'm not even accounting for the weight and other colors with different
transparency. That non-opaque average alpha might end up being used in
area that are expected to be opaque, and in some area where it's supposed
to be transparent. That's exactly what I showed with the "O" png.

In addition to that problem, since you're also accounting the alpha as a
weight to determine the proximity of 2 colors, you're going to select the
wrong colors. For example if we want to find the closest color to an
opaque green (ff00ff00), and the palette has a slightly transparent green
(fa00ff00) and an opaque blue (ffff), then now the algorithm will
prefer the blue over the green.

That explains why in addition to the alpha being random in the "O" png,
the colors are also messed up.

> > The patch I had submitted doesn't change the previous behavior
> > without the use_alpha parameter.

Yes I noticed, but unfortunately I'm reworking the color distance to work
in perceptual color space, and the way that alpha is mixed up in the
equation just doesn't make any sense at all and prevents me from doing
these changes. Ignoring the alpha branches will make its output even more
terrible.

> > And when using the use_alpha parameter, the results are still
> > useful in many cases - maybe not always.

I don't think they're useful: they're unpredictable and very likely to
produce a broken output. Would you consider FFmpeg useful if half the time
the command was failing at producing a valid file?

[...]

> Do you think it might make sense to put more weight on the 
> alpha value by tripling it? So it would be weighted equally to the 
> RGB value?

You cannot mix alpha with colors at all, they are separate domains and you
need to treat them as such.

From paletteuse perspective what you need to do is first choose the colors
in the palette that match exactly the alpha (or at least the closest if
and only there is no exact match). Then within that set, and only within
that one, you'd pick the closest color.

From palettegen perspective, you need to split the colors in different
transparency domain (a first dimensional quantization), then quantize the
colors in each quantized alpha dimension. And when you have all your
quantized palettes for each level of alpha, you find an algorithm to
reduce the number of transparency dimensions or the number of colors per
dimension to make it fit inside a single palette. But you can't just do
the alpha and the colors at the same time, it cannot work, whatever
weights you choose.

-- 
Clément B.
___
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 19/19] avcodec/vc1_block: Remove redundant write

2022-10-30 Thread Andreas Rheinhardt
vc1_decode_skip_blocks() is only called if the current picture
is a P frame. So setting pict_type to AV_PICTURE_TYPE_P
is redundant; removing it makes pict_type read-only in vc1_block.c
(as it should be).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1_block.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index c6882163a1..1baa6a9bf6 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2977,7 +2977,6 @@ static void vc1_decode_skip_blocks(VC1Context *v)
 memcpy(s->dest[2], s->last_picture.f->data[2] + s->mb_y *  8 * 
s->uvlinesize, s->uvlinesize *  8);
 s->first_slice_line = 0;
 }
-s->pict_type = AV_PICTURE_TYPE_P;
 }
 
 void ff_vc1_decode_blocks(VC1Context *v)
-- 
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 18/19] avcodec/vc1dec: Split VC-1 decoders from msmpeg4

2022-10-30 Thread Andreas Rheinhardt
The only msmpeg4 code that is ever executed by the VC-1 based
decoders is ff_msmpeg4_decode_init() and what is directly
reachable from it. This is:
a) A call to av_image_check_size(), then ff_h263_decode_init(),
b) followed by setting [yc]_dc_scale_table and initializing
scantable/permutations.
c) Afterwards, some static tables are initialized.
d) Finally, slice_height is set.

The replacement for ff_msmpeg4_decode_init() performs a)
just like now; it also sets [yc]_dc_scale_table,
but it only initializes inter_scantable and intra_scantable
and not permutated_intra_[hv]_scantable: The latter are only
used inside decode_mb callbacks which are only called
in ff_h263_decode_frame() which is unused for VC-1.*

The static tables initialized in c) are not used at all by
VC-1 (the ones that are used have been factored out in
previous commits); this avoids touching 327KiB of .bss.

slice_height is also not used by the VC-1 decoder (setting
it in ff_msmpeg4_decode_init() is probably redundant after
b34397b4cd780b5692548e7d021ec884c7217dba).

*: It follows from this that the VC-1 decoder is not really
based upon the H.263 decoder either; changing this will
be done in a future commit.

Signed-off-by: Andreas Rheinhardt 
---
 configure   |  2 +-
 libavcodec/msmpeg4.c| 12 
 libavcodec/msmpeg4dec.c |  3 ---
 libavcodec/vc1dec.c | 20 ++--
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index 70c9e41dcc..545975c575 100755
--- a/configure
+++ b/configure
@@ -2981,7 +2981,7 @@ utvideo_encoder_select="bswapdsp huffman llvidencdsp"
 vble_decoder_select="llviddsp"
 vbn_decoder_select="texturedsp"
 vbn_encoder_select="texturedspenc"
-vc1_decoder_select="blockdsp h264qpel intrax8 mpegvideodec msmpeg4dec vc1dsp"
+vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp"
 vc1image_decoder_select="vc1_decoder"
 vorbis_decoder_select="mdct"
 vorbis_encoder_select="audio_frame_queue mdct"
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 4daf1666cc..a2c4c57728 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -27,8 +27,6 @@
  * MSMPEG4 backend for encoder and decoder
  */
 
-#include "config_components.h"
-
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
@@ -40,8 +38,6 @@
 #include "msmpeg4data.h"
 #include "msmpeg4_vc1_data.h"
 #include "mpegvideodata.h"
-#include "vc1data.h"
-#include "libavutil/imgutils.h"
 
 /*
  * You can also call this codec: MPEG-4 with a twist!
@@ -139,16 +135,8 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
 s->y_dc_scale_table= ff_wmv1_y_dc_scale_table;
 s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
 break;
-#if CONFIG_VC1_DECODER
-case 6:
-s->y_dc_scale_table= ff_wmv3_dc_scale_table;
-s->c_dc_scale_table= ff_wmv3_dc_scale_table;
-break;
-#endif
-
 }
 
-
 if(s->msmpeg4_version>=4){
 ff_init_scantable(s->idsp.idct_permutation, >intra_scantable,   
ff_wmv1_scantable[1]);
 ff_init_scantable(s->idsp.idct_permutation, >inter_scantable,   
ff_wmv1_scantable[0]);
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index dbcec3de74..26a196a38f 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -373,9 +373,6 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
 break;
 case 5:
 break;
-case 6:
-//FIXME + TODO VC1 decode mb
-break;
 }
 
 s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a 
keyframe
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index b50f5b45aa..bcfd2bae0b 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -33,12 +33,12 @@
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
+#include "h263dec.h"
 #include "hwconfig.h"
 #include "mpeg_er.h"
 #include "mpegvideo.h"
 #include "mpegvideodec.h"
 #include "msmpeg4_vc1_data.h"
-#include "msmpeg4dec.h"
 #include "profiles.h"
 #include "simple_idct.h"
 #include "vc1.h"
@@ -46,6 +46,7 @@
 #include "vc1_vlc_data.h"
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/thread.h"
 
 
@@ -406,11 +407,26 @@ static av_cold int 
vc1_decode_init_alloc_tables(VC1Context *v)
 
 av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
 {
-int ret = ff_msmpeg4_decode_init(avctx);
 VC1Context *const v = avctx->priv_data;
+MpegEncContext *const s = >s;
+int ret;
+
+ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
 if (ret < 0)
 return ret;
 
+ret = ff_h263_decode_init(avctx);
+if (ret < 0)
+return ret;
+
+s->y_dc_scale_table = ff_wmv3_dc_scale_table;
+s->c_dc_scale_table = ff_wmv3_dc_scale_table;
+
+ff_init_scantable(s->idsp.idct_permutation, >inter_scantable,
+  ff_wmv1_scantable[0]);
+ff_init_scantable(s->idsp.idct_permutation, 

[FFmpeg-devel] [PATCH 17/19] avcodec/msmpeg4data: Move data shared between msmpeg4 and VC-1 out

2022-10-30 Thread Andreas Rheinhardt
This is in preparation for splitting VC-1 from msmpeg4.
(msmpeg4data.c was originally intended to be just this;
9488b966c76a7a52e9a1f7756bda82dbe1070399 changed it).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile   |   8 +-
 libavcodec/intrax8.c  |   2 +-
 libavcodec/msmpeg4.c  |   1 +
 libavcodec/msmpeg4_vc1_data.c | 254 ++
 libavcodec/msmpeg4_vc1_data.h |  55 
 libavcodec/msmpeg4data.c  | 223 -
 libavcodec/msmpeg4data.h  |  20 ---
 libavcodec/msmpeg4dec.c   |   1 +
 libavcodec/msmpeg4enc.c   |   1 +
 libavcodec/vc1_block.c|   2 +-
 libavcodec/vc1dec.c   |   2 +-
 libavcodec/wmv2.c |   2 +-
 libavcodec/wmv2dec.c  |   2 +-
 libavcodec/wmv2enc.c  |   1 +
 14 files changed, 323 insertions(+), 251 deletions(-)
 create mode 100644 libavcodec/msmpeg4_vc1_data.c
 create mode 100644 libavcodec/msmpeg4_vc1_data.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 739bf757f9..ac53bbe219 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -140,8 +140,10 @@ OBJS-$(CONFIG_MPEGVIDEODEC)+= mpegvideo_dec.o 
mpegutils.o
 OBJS-$(CONFIG_MPEGVIDEOENC)+= mpegvideo_enc.o mpeg12data.o  \
   motion_est.o ratecontrol.o\
   mpegvideoencdsp.o
-OBJS-$(CONFIG_MSMPEG4DEC)  += msmpeg4dec.o msmpeg4.o msmpeg4data.o
-OBJS-$(CONFIG_MSMPEG4ENC)  += msmpeg4enc.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4DEC)  += msmpeg4dec.o msmpeg4.o msmpeg4data.o 
\
+  msmpeg4_vc1_data.o
+OBJS-$(CONFIG_MSMPEG4ENC)  += msmpeg4enc.o msmpeg4.o msmpeg4data.o 
\
+  msmpeg4_vc1_data.o
 OBJS-$(CONFIG_MSS34DSP)+= mss34dsp.o jpegquanttables.o
 OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
 OBJS-$(CONFIG_QPELDSP) += qpeldsp.o
@@ -724,7 +726,7 @@ OBJS-$(CONFIG_VBN_ENCODER) += vbnenc.o
 OBJS-$(CONFIG_VBLE_DECODER)+= vble.o
 OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o 
vc1_loopfilter.o \
   vc1_mc.o vc1_pred.o vc1.o vc1data.o \
-  wmv2data.o
+  msmpeg4_vc1_data.o wmv2data.o
 OBJS-$(CONFIG_VC1_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VC1_MMAL_DECODER)+= mmaldec.o
 OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec.o
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index d6668338fb..e4c8b96c9c 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -26,7 +26,7 @@
 #include "avcodec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
-#include "msmpeg4data.h"
+#include "msmpeg4_vc1_data.h"
 #include "intrax8huf.h"
 #include "intrax8.h"
 #include "intrax8dsp.h"
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 3f5dc23130..4daf1666cc 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -38,6 +38,7 @@
 #include "libavutil/x86/asm.h"
 #include "mpeg4videodata.h"
 #include "msmpeg4data.h"
+#include "msmpeg4_vc1_data.h"
 #include "mpegvideodata.h"
 #include "vc1data.h"
 #include "libavutil/imgutils.h"
diff --git a/libavcodec/msmpeg4_vc1_data.c b/libavcodec/msmpeg4_vc1_data.c
new file mode 100644
index 00..059c6f32dc
--- /dev/null
+++ b/libavcodec/msmpeg4_vc1_data.c
@@ -0,0 +1,254 @@
+/*
+ * Common MSMPEG-4 and VC-1 tables and VLC init code
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer 
+ *
+ * msmpeg4v1 & v2 stuff by Michael Niedermayer 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Common MSMPEG-4 and VC-1 tables and VLC init code
+ */
+
+#include "msmpeg4_vc1_data.h"
+#include "vlc.h"
+#include "libavutil/attributes.h"
+#include "libavutil/thread.h"
+
+VLC ff_msmp4_mb_i_vlc;
+VLC ff_msmp4_dc_luma_vlc[2];
+VLC ff_msmp4_dc_chroma_vlc[2];
+
+static av_cold void msmp4_vc1_vlcs_init(void)
+{
+INIT_VLC_STATIC(_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
+_table0_dc_lum[0][1], 8, 4,
+   

[FFmpeg-devel] [PATCH 16/19] avcodec/vc1dec: Return early upon error

2022-10-30 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1dec.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 682b39083b..1cf42d831f 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -332,7 +332,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
 static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
 {
 MpegEncContext *s = >s;
-int i, ret = AVERROR(ENOMEM);
+int i, ret;
 int mb_height = FFALIGN(s->mb_height, 2);
 
 /* Allocate mb bitplanes */
@@ -344,31 +344,31 @@ static av_cold int 
vc1_decode_init_alloc_tables(VC1Context *v)
 v->over_flags_plane = av_malloc (s->mb_stride * mb_height);
 if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->forward_mb_plane ||
 !v->fieldtx_plane || !v->acpred_plane || !v->over_flags_plane)
-goto error;
+return AVERROR(ENOMEM);
 
 v->n_allocated_blks = s->mb_width + 2;
 v->block= av_malloc(sizeof(*v->block) * v->n_allocated_blks);
 v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
 if (!v->block || !v->cbp_base)
-goto error;
+return AVERROR(ENOMEM);
 v->cbp  = v->cbp_base + 2 * s->mb_stride;
 v->ttblk_base   = av_malloc(sizeof(v->ttblk_base[0]) * 3 * 
s->mb_stride);
 if (!v->ttblk_base)
-goto error;
+return AVERROR(ENOMEM);
 v->ttblk= v->ttblk_base + 2 * s->mb_stride;
 v->is_intra_base= av_mallocz(sizeof(v->is_intra_base[0]) * 3 * 
s->mb_stride);
 if (!v->is_intra_base)
-goto error;
+return AVERROR(ENOMEM);
 v->is_intra = v->is_intra_base + 2 * s->mb_stride;
 v->luma_mv_base = av_mallocz(sizeof(v->luma_mv_base[0]) * 3 * 
s->mb_stride);
 if (!v->luma_mv_base)
-goto error;
+return AVERROR(ENOMEM);
 v->luma_mv  = v->luma_mv_base + 2 * s->mb_stride;
 
 /* allocate block type info in that way so it could be used with 
s->block_index[] */
 v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride * (mb_height + 1) * 2);
 if (!v->mb_type_base)
-goto error;
+return AVERROR(ENOMEM);
 v->mb_type[0]   = v->mb_type_base + s->b8_stride + 1;
 v->mb_type[1]   = v->mb_type_base + s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride + 1;
 v->mb_type[2]   = v->mb_type[1] + s->mb_stride * (mb_height + 1);
@@ -376,35 +376,32 @@ static av_cold int 
vc1_decode_init_alloc_tables(VC1Context *v)
 /* allocate memory to store block level MV info */
 v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride * (mb_height + 1) * 2);
 if (!v->blk_mv_type_base)
-goto error;
+return AVERROR(ENOMEM);
 v->blk_mv_type  = v->blk_mv_type_base + s->b8_stride + 1;
 v->mv_f_base= av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride * (mb_height + 1) * 2));
 if (!v->mv_f_base)
-goto error;
+return AVERROR(ENOMEM);
 v->mv_f[0]  = v->mv_f_base + s->b8_stride + 1;
 v->mv_f[1]  = v->mv_f[0] + (s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride * (mb_height + 1) * 2);
 v->mv_f_next_base   = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + 
s->mb_stride * (mb_height + 1) * 2));
 if (!v->mv_f_next_base)
-goto error;
+return AVERROR(ENOMEM);
 v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
 v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 
1) + s->mb_stride * (mb_height + 1) * 2);
 
 if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == 
AV_CODEC_ID_VC1IMAGE) {
 for (i = 0; i < 4; i++)
 if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width)))
-goto error;
+return AVERROR(ENOMEM);
 }
 
 ret = ff_intrax8_common_init(s->avctx, >x8,
  s->block, s->block_last_index,
  s->mb_width, s->mb_height);
 if (ret < 0)
-goto error;
+return ret;
 
 return 0;
-
-error:
-return ret;
 }
 
 av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
-- 
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 15/19] avcodec/vc1dec: Factor (re)initializing code out

2022-10-30 Thread Andreas Rheinhardt
This is in preparation for removing the msmpeg4 dependency
from VC-1.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mss2.c   |  5 ++---
 libavcodec/vc1.h|  2 +-
 libavcodec/vc1dec.c | 25 ++---
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 69494d8c44..dca2ae4921 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -29,7 +29,6 @@
 #include "error_resilience.h"
 #include "mpeg_er.h"
 #include "mpegvideodec.h"
-#include "msmpeg4dec.h"
 #include "qpeldsp.h"
 #include "vc1.h"
 #include "wmv2data.h"
@@ -852,8 +851,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
 
 ff_vc1_init_transposed_scantables(v);
 
-if ((ret = ff_msmpeg4_decode_init(avctx)) < 0 ||
-(ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
+ret = ff_vc1_decode_init(avctx);
+if (ret < 0)
 return ret;
 
 /* error concealment */
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 9b25f0872f..3b6be78141 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -413,7 +413,7 @@ int ff_vc1_parse_frame_header(VC1Context *v, 
GetBitContext *gb);
 int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
 void ff_vc1_init_common(VC1Context *v);
 
-int  ff_vc1_decode_init_alloc_tables(VC1Context *v);
+int  ff_vc1_decode_init(AVCodecContext *avctx);
 void ff_vc1_init_transposed_scantables(VC1Context *v);
 int  ff_vc1_decode_end(AVCodecContext *avctx);
 void ff_vc1_decode_blocks(VC1Context *v);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 49ecfd8a48..682b39083b 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -329,7 +329,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
 
 #endif
 
-av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
+static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
 {
 MpegEncContext *s = >s;
 int i, ret = AVERROR(ENOMEM);
@@ -404,10 +404,24 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 return 0;
 
 error:
-ff_vc1_decode_end(s->avctx);
 return ret;
 }
 
+av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
+{
+int ret = ff_msmpeg4_decode_init(avctx);
+VC1Context *const v = avctx->priv_data;
+if (ret < 0)
+return ret;
+
+ret = vc1_decode_init_alloc_tables(v);
+if (ret < 0) {
+ff_vc1_decode_end(avctx);
+return ret;
+}
+return 0;
+}
+
 av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
 {
 int i;
@@ -947,12 +961,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 }
 
 if (!s->context_initialized) {
-if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
-goto err;
-if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) {
-ff_mpv_common_end(s);
+ret = ff_vc1_decode_init(avctx);
+if (ret < 0)
 goto err;
-}
 
 s->low_delay = !avctx->has_b_frames || v->res_sprite;
 
-- 
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 14/19] avcodec/vc1dec: Don't open and close decoder during init

2022-10-30 Thread Andreas Rheinhardt
This is done since 16af29a7a6deff3f6081fca1e36ad96cf8fec77d
(and is actually unnecessary, because the tables initialized
in ff_msmpeg4_decode_init() are only ever used in vc1_block.c
which is only entered after a call to ff_msmpeg4_decode_init())
in a very ugly manner; said manner had the byproduct of
involving lots of unnecessary allocations and even opening
and closing a hwaccel in case one is used.

This commit achieves the aim of 16af29a7a6deff3f6081fca1e36ad96cf8fec77d
by initializing the VLCs used by VC-1 in ff_vc1_init_common().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1dec.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index b74956c6a3..49ecfd8a48 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -540,6 +540,7 @@ static av_cold void vc1_init_static(void)
  vc1_if_1mv_mbmode_bits[i],  1, 1,
  vc1_if_1mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
 }
+ff_msmp4_vc1_vlcs_init_once();
 }
 
 /**
@@ -672,16 +673,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 avctx->color_range = AVCOL_RANGE_MPEG;
 }
 
-// ensure static VLC tables are initialized
-if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
-return ret;
-if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
-return ret;
-// Hack to ensure the above functions will be called
-// again once we know all necessary settings.
-// That this is necessary might indicate a bug.
-ff_vc1_decode_end(avctx);
-
 ff_blockdsp_init(>bdsp);
 ff_h264chroma_init(>h264chroma, 8);
 ff_qpeldsp_init(>qdsp);
-- 
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 13/19] avcodec/msmpeg4dec: Factor initializing VLCs shared with VC-1 out

2022-10-30 Thread Andreas Rheinhardt
It will be useful in the following commits.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msmpeg4data.c | 30 ++
 libavcodec/msmpeg4data.h |  2 ++
 libavcodec/msmpeg4dec.c  | 18 +-
 3 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
index 63f30ac544..7b54eea221 100644
--- a/libavcodec/msmpeg4data.c
+++ b/libavcodec/msmpeg4data.c
@@ -30,6 +30,10 @@
 #include "h263data.h"
 #include "mpeg4videodata.h"
 #include "msmpeg4data.h"
+#include "rl.h"
+#include "vlc.h"
+#include "libavutil/attributes.h"
+#include "libavutil/thread.h"
 
 uint32_t ff_v2_dc_lum_table[512][2];
 uint32_t ff_v2_dc_chroma_table[512][2];
@@ -38,6 +42,32 @@ VLC ff_msmp4_mb_i_vlc;
 VLC ff_msmp4_dc_luma_vlc[2];
 VLC ff_msmp4_dc_chroma_vlc[2];
 
+static av_cold void msmp4_vc1_vlcs_init(void)
+{
+INIT_VLC_STATIC(_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
+_table0_dc_lum[0][1], 8, 4,
+_table0_dc_lum[0][0], 8, 4, 1158);
+INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[0], MSMP4_DC_VLC_BITS, 120,
+_table0_dc_chroma[0][1], 8, 4,
+_table0_dc_chroma[0][0], 8, 4, 1118);
+INIT_VLC_STATIC(_msmp4_dc_luma_vlc[1], MSMP4_DC_VLC_BITS, 120,
+_table1_dc_lum[0][1], 8, 4,
+_table1_dc_lum[0][0], 8, 4, 1476);
+INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[1], MSMP4_DC_VLC_BITS, 120,
+_table1_dc_chroma[0][1], 8, 4,
+_table1_dc_chroma[0][0], 8, 4, 1216);
+
+INIT_VLC_STATIC(_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 64,
+_msmp4_mb_i_table[0][1], 4, 2,
+_msmp4_mb_i_table[0][0], 4, 2, 536);
+}
+
+av_cold void ff_msmp4_vc1_vlcs_init_once(void)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+ff_thread_once(_static_once, msmp4_vc1_vlcs_init);
+}
+
 /* intra picture macroblock coded block pattern */
 const uint16_t ff_msmp4_mb_i_table[64][2] = {
 {  0x1, 1 }, {  0x17,  6 }, {   0x9,  5 }, {   0x5,  5 },
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index 4f904d7610..ccbfde36f7 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -48,6 +48,8 @@ typedef struct MVTable {
 } MVTable;
 
 FF_VISIBILITY_PUSH_HIDDEN
+void ff_msmp4_vc1_vlcs_init_once(void);
+
 #define MSMP4_MB_INTRA_VLC_BITS 9
 extern VLC ff_msmp4_mb_i_vlc;
 #define MSMP4_DC_VLC_BITS 9
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index a7ba53f68e..2be8cf2bf6 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -316,19 +316,6 @@ static av_cold void msmpeg4_decode_init_static(void)
 mv->table_mv_bits, 1, 1,
 mv->table_mv_code, 2, 2, 2694);
 
-INIT_VLC_STATIC(_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
-_table0_dc_lum[0][1], 8, 4,
-_table0_dc_lum[0][0], 8, 4, 1158);
-INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[0], MSMP4_DC_VLC_BITS, 120,
-_table0_dc_chroma[0][1], 8, 4,
-_table0_dc_chroma[0][0], 8, 4, 1118);
-INIT_VLC_STATIC(_msmp4_dc_luma_vlc[1], MSMP4_DC_VLC_BITS, 120,
-_table1_dc_lum[0][1], 8, 4,
-_table1_dc_lum[0][0], 8, 4, 1476);
-INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[1], MSMP4_DC_VLC_BITS, 120,
-_table1_dc_chroma[0][1], 8, 4,
-_table1_dc_chroma[0][0], 8, 4, 1216);
-
 INIT_VLC_STATIC(_dc_lum_vlc, MSMP4_DC_VLC_BITS, 512,
 _v2_dc_lum_table[0][1], 8, 4,
 _v2_dc_lum_table[0][0], 8, 4, 1472);
@@ -354,13 +341,10 @@ static av_cold void msmpeg4_decode_init_static(void)
 offset += ff_mb_non_intra_vlc[i].table_size;
 }
 
-INIT_VLC_STATIC(_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 64,
-_msmp4_mb_i_table[0][1], 4, 2,
-_msmp4_mb_i_table[0][0], 4, 2, 536);
-
 INIT_VLC_STATIC(_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
 _table_inter_intra[0][1], 2, 1,
 _table_inter_intra[0][0], 2, 1, 8);
+ff_msmp4_vc1_vlcs_init_once();
 }
 
 av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
-- 
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 12/19] avcodec/vc1_block: Don't duplicate #defines

2022-10-30 Thread Andreas Rheinhardt
VC1 shares some VLCs with MSMPEG-4, but vc1_block.c
simply duplicates the defines instead of including
the appropriate headers; furthermore, use a proper
prefix for these defines: DC_VLC_BITS is also used
by other codecs.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msmpeg4data.h |  2 ++
 libavcodec/msmpeg4dec.c  | 27 ++-
 libavcodec/msmpeg4dec.h  |  1 -
 libavcodec/vc1_block.c   | 27 ---
 libavcodec/wmv2dec.c |  3 ++-
 5 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index b2b5bade4d..4f904d7610 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -48,7 +48,9 @@ typedef struct MVTable {
 } MVTable;
 
 FF_VISIBILITY_PUSH_HIDDEN
+#define MSMP4_MB_INTRA_VLC_BITS 9
 extern VLC ff_msmp4_mb_i_vlc;
+#define MSMP4_DC_VLC_BITS 9
 extern VLC ff_msmp4_dc_luma_vlc[2];
 extern VLC ff_msmp4_dc_chroma_vlc[2];
 
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index bc554ed2eb..a7ba53f68e 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -37,7 +37,6 @@
 #include "mpeg4videodec.h"
 #include "msmpeg4data.h"
 
-#define DC_VLC_BITS 9
 #define V2_INTRA_CBPC_VLC_BITS 3
 #define V2_MB_TYPE_VLC_BITS 7
 #define MV_VLC_BITS 9
@@ -237,7 +236,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t 
block[6][64])
 cbp = code & 0x3f;
 } else {
 s->mb_intra = 1;
-code = get_vlc2(>gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
+code = get_vlc2(>gb, ff_msmp4_mb_i_vlc.table, 
MSMP4_MB_INTRA_VLC_BITS, 2);
 /* predict coded block pattern */
 cbp = 0;
 for(i=0;i<6;i++) {
@@ -317,23 +316,23 @@ static av_cold void msmpeg4_decode_init_static(void)
 mv->table_mv_bits, 1, 1,
 mv->table_mv_code, 2, 2, 2694);
 
-INIT_VLC_STATIC(_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
+INIT_VLC_STATIC(_msmp4_dc_luma_vlc[0], MSMP4_DC_VLC_BITS, 120,
 _table0_dc_lum[0][1], 8, 4,
 _table0_dc_lum[0][0], 8, 4, 1158);
-INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
+INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[0], MSMP4_DC_VLC_BITS, 120,
 _table0_dc_chroma[0][1], 8, 4,
 _table0_dc_chroma[0][0], 8, 4, 1118);
-INIT_VLC_STATIC(_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
+INIT_VLC_STATIC(_msmp4_dc_luma_vlc[1], MSMP4_DC_VLC_BITS, 120,
 _table1_dc_lum[0][1], 8, 4,
 _table1_dc_lum[0][0], 8, 4, 1476);
-INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
+INIT_VLC_STATIC(_msmp4_dc_chroma_vlc[1], MSMP4_DC_VLC_BITS, 120,
 _table1_dc_chroma[0][1], 8, 4,
 _table1_dc_chroma[0][0], 8, 4, 1216);
 
-INIT_VLC_STATIC(_dc_lum_vlc, DC_VLC_BITS, 512,
+INIT_VLC_STATIC(_dc_lum_vlc, MSMP4_DC_VLC_BITS, 512,
 _v2_dc_lum_table[0][1], 8, 4,
 _v2_dc_lum_table[0][0], 8, 4, 1472);
-INIT_VLC_STATIC(_dc_chroma_vlc, DC_VLC_BITS, 512,
+INIT_VLC_STATIC(_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 512,
 _v2_dc_chroma_table[0][1], 8, 4,
 _v2_dc_chroma_table[0][0], 8, 4, 1506);
 
@@ -355,7 +354,7 @@ static av_cold void msmpeg4_decode_init_static(void)
 offset += ff_mb_non_intra_vlc[i].table_size;
 }
 
-INIT_VLC_STATIC(_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
+INIT_VLC_STATIC(_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 64,
 _msmp4_mb_i_table[0][1], 4, 2,
 _msmp4_mb_i_table[0][0], 4, 2, 536);
 
@@ -591,9 +590,9 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int 
*dir_ptr)
 
 if(s->msmpeg4_version<=2){
 if (n < 4) {
-level = get_vlc2(>gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
+level = get_vlc2(>gb, v2_dc_lum_vlc.table, MSMP4_DC_VLC_BITS, 
3);
 } else {
-level = get_vlc2(>gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
+level = get_vlc2(>gb, v2_dc_chroma_vlc.table, 
MSMP4_DC_VLC_BITS, 3);
 }
 if (level < 0) {
 av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
@@ -603,9 +602,11 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, 
int *dir_ptr)
 level-=256;
 }else{  //FIXME optimize use unified tables & index
 if (n < 4) {
-level = get_vlc2(>gb, 
ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
+level = get_vlc2(>gb, 
ff_msmp4_dc_luma_vlc[s->dc_table_index].table,
+ MSMP4_DC_VLC_BITS, 3);
 } else {
-level = get_vlc2(>gb, 
ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
+level = get_vlc2(>gb, 
ff_msmp4_dc_chroma_vlc[s->dc_table_index].table,
+ MSMP4_DC_VLC_BITS, 3);
 }
 
 if (level == DC_MAX) {
diff 

[FFmpeg-devel] [PATCH 11/19] avcodec/vc1: Move ff_vc1_init_common() to vc1dec.c

2022-10-30 Thread Andreas Rheinhardt
This is possible given that it is no longer used
by the parser.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1.c  | 362 --
 libavcodec/vc1_vlc_data.h | 221 +++
 libavcodec/vc1dec.c   | 141 +++
 3 files changed, 362 insertions(+), 362 deletions(-)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 5214bcdedf..d4014d25ab 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -26,14 +26,11 @@
  * VC-1 and WMV3 decoder common code
  */
 
-#include "libavutil/attributes.h"
-#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "decode.h"
 #include "mpegvideo.h"
 #include "vc1.h"
 #include "vc1data.h"
-#include "vc1_vlc_data.h"
 #include "wmv2data.h"
 #include "unary.h"
 
@@ -1339,362 +1336,3 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, 
GetBitContext* gb)
 
 return 0;
 }
-
-static const uint32_t vc1_ac_tables[AC_MODES][186][2] = {
-{
-{ 0x0001,  2}, { 0x0005,  3}, { 0x000D,  4}, { 0x0012,  5}, { 0x000E,  6}, { 
0x0015,  7},
-{ 0x0013,  8}, { 0x003F,  8}, { 0x004B,  9}, { 0x011F,  9}, { 0x00B8, 10}, { 
0x03E3, 10},
-{ 0x0172, 11}, { 0x024D, 12}, { 0x03DA, 12}, { 0x02DD, 13}, { 0x1F55, 13}, { 
0x05B9, 14},
-{ 0x3EAE, 14}, { 0x,  4}, { 0x0010,  5}, { 0x0008,  7}, { 0x0020,  8}, { 
0x0029,  9},
-{ 0x01F4,  9}, { 0x0233, 10}, { 0x01E0, 11}, { 0x012A, 12}, { 0x03DD, 12}, { 
0x050A, 13},
-{ 0x1F29, 13}, { 0x0A42, 14}, { 0x1272, 15}, { 0x1737, 15}, { 0x0003,  5}, { 
0x0011,  7},
-{ 0x00C4,  8}, { 0x004B, 10}, { 0x00B4, 11}, { 0x07D4, 11}, { 0x0345, 12}, { 
0x02D7, 13},
-{ 0x07BF, 13}, { 0x0938, 14}, { 0x0BBB, 14}, { 0x095E, 15}, { 0x0013,  5}, { 
0x0078,  7},
-{ 0x0069,  9}, { 0x0232, 10}, { 0x0461, 11}, { 0x03EC, 12}, { 0x0520, 13}, { 
0x1F2A, 13},
-{ 0x3E50, 14}, { 0x3E51, 14}, { 0x1486, 15}, { 0x000C,  6}, { 0x0024,  9}, { 
0x0094, 11},
-{ 0x08C0, 12}, { 0x0F09, 14}, { 0x1EF0, 15}, { 0x003D,  6}, { 0x0053,  9}, { 
0x01A0, 11},
-{ 0x02D6, 13}, { 0x0F08, 14}, { 0x0013,  7}, { 0x007C,  9}, { 0x07C1, 11}, { 
0x04AC, 14},
-{ 0x001B,  7}, { 0x00A0, 10}, { 0x0344, 12}, { 0x0F79, 14}, { 0x0079,  7}, { 
0x03E1, 10},
-{ 0x02D4, 13}, { 0x2306, 14}, { 0x0021,  8}, { 0x023C, 10}, { 0x0FAE, 12}, { 
0x23DE, 14},
-{ 0x0035,  8}, { 0x0175, 11}, { 0x07B3, 13}, { 0x00C5,  8}, { 0x0174, 11}, { 
0x0785, 13},
-{ 0x0048,  9}, { 0x01A3, 11}, { 0x049E, 13}, { 0x002C,  9}, { 0x00FA, 10}, { 
0x07D6, 11},
-{ 0x0092, 10}, { 0x05CC, 13}, { 0x1EF1, 15}, { 0x00A3, 10}, { 0x03ED, 12}, { 
0x093E, 14},
-{ 0x01E2, 11}, { 0x1273, 15}, { 0x07C4, 11}, { 0x1487, 15}, { 0x0291, 12}, { 
0x0293, 12},
-{ 0x0F8A, 12}, { 0x0509, 13}, { 0x0508, 13}, { 0x078D, 13}, { 0x07BE, 13}, { 
0x078C, 13},
-{ 0x04AE, 14}, { 0x0BBA, 14}, { 0x2307, 14}, { 0x0B9A, 14}, { 0x1736, 15}, { 
0x000E,  4},
-{ 0x0045,  7}, { 0x01F3,  9}, { 0x047A, 11}, { 0x05DC, 13}, { 0x23DF, 14}, { 
0x0019,  5},
-{ 0x0028,  9}, { 0x0176, 11}, { 0x049D, 13}, { 0x23DD, 14}, { 0x0030,  6}, { 
0x00A2, 10},
-{ 0x02EF, 12}, { 0x05B8, 14}, { 0x003F,  6}, { 0x00A5, 10}, { 0x03DB, 12}, { 
0x093F, 14},
-{ 0x0044,  7}, { 0x07CB, 11}, { 0x095F, 15}, { 0x0063,  7}, { 0x03C3, 12}, { 
0x0015,  8},
-{ 0x08F6, 12}, { 0x0017,  8}, { 0x0498, 13}, { 0x002C,  8}, { 0x07B2, 13}, { 
0x002F,  8},
-{ 0x1F54, 13}, { 0x008D,  8}, { 0x07BD, 13}, { 0x008E,  8}, { 0x1182, 13}, { 
0x00FB,  8},
-{ 0x050B, 13}, { 0x002D,  8}, { 0x07C0, 11}, { 0x0079,  9}, { 0x1F5F, 13}, { 
0x007A,  9},
-{ 0x1F56, 13}, { 0x0231, 10}, { 0x03E4, 10}, { 0x01A1, 11}, { 0x0143, 11}, { 
0x01F7, 11},
-{ 0x016F, 12}, { 0x0292, 12}, { 0x02E7, 12}, { 0x016C, 12}, { 0x016D, 12}, { 
0x03DC, 12},
-{ 0x0F8B, 12}, { 0x0499, 13}, { 0x03D8, 12}, { 0x078E, 13}, { 0x02D5, 13}, { 
0x1F5E, 13},
-{ 0x1F2B, 13}, { 0x078F, 13}, { 0x04AD, 14}, { 0x3EAF, 14}, { 0x23DC, 14}, { 
0x004A,  9}
-},
-{
-{ 0x,  3}, { 0x0003,  4}, { 0x000B,  5}, { 0x0014,  6}, { 0x003F,  6}, { 
0x005D,  7},
-{ 0x00A2,  8}, { 0x00AC,  9}, { 0x016E,  9}, { 0x020A, 10}, { 0x02E2, 10}, { 
0x0432, 11},
-{ 0x05C9, 11}, { 0x0827, 12}, { 0x0B54, 12}, { 0x04E6, 13}, { 0x105F, 13}, { 
0x172A, 13},
-{ 0x20B2, 14}, { 0x2D4E, 14}, { 0x39F0, 14}, { 0x4175, 15}, { 0x5A9E, 15}, { 
0x0004,  4},
-{ 0x001E,  5}, { 0x0042,  7}, { 0x00B6,  8}, { 0x0173,  9}, { 0x0395, 10}, { 
0x072E, 11},
-{ 0x0B94, 12}, { 0x16A4, 13}, { 0x20B3, 14}, { 0x2E45, 14}, { 0x0005,  5}, { 
0x0040,  7},
-{ 0x0049,  9}, { 0x028F, 10}, { 0x05CB, 11}, { 0x048A, 13}, { 0x09DD, 14}, { 
0x73E2, 15},
-{ 0x0018,  5}, { 0x0025,  8}, { 0x008A, 10}, { 0x051B, 11}, { 0x0E5F, 12}, { 
0x09C9, 14},
-{ 0x139C, 15}, { 0x0029,  6}, { 0x004F,  9}, { 0x0412, 11}, { 0x048D, 13}, { 
0x2E41, 14},
-{ 0x0038,  6}, { 0x010E,  9}, { 0x05A8, 11}, { 0x105C, 13}, { 0x39F2, 14}, { 
0x0058,  7},
-{ 0x021F, 10}, { 0x0E7E, 12}, { 0x39FF, 14}, { 0x0023,  8}, { 0x02E3, 10}, { 
0x04E5, 13},
-{ 0x2E40, 14}, { 0x00A1,  8}, { 0x05BE, 11}, { 0x09C8, 14}, { 0x0083,  8}, { 
0x013A, 11},
-{ 0x1721, 13}, { 0x0044,  9}, { 0x0276, 12}, { 0x39F6, 14}, { 0x008B, 10}, { 

[FFmpeg-devel] [PATCH 10/19] avcodec/vc1data: Move VLC codes/lengths tables to a header

2022-10-30 Thread Andreas Rheinhardt
and include said header at the place where the VLCs are created.
This allows to make said tables static.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1.c  |  69 ++--
 libavcodec/vc1_vlc_data.h | 842 ++
 libavcodec/vc1data.c  | 804 
 libavcodec/vc1data.h  |  70 
 4 files changed, 877 insertions(+), 908 deletions(-)
 create mode 100644 libavcodec/vc1_vlc_data.h

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 6eb0d70a68..5214bcdedf 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -33,6 +33,7 @@
 #include "mpegvideo.h"
 #include "vc1.h"
 #include "vc1data.h"
+#include "vc1_vlc_data.h"
 #include "wmv2data.h"
 #include "unary.h"
 
@@ -1575,47 +1576,47 @@ static av_cold void vc1_init_static(void)
 static VLCElem vlc_table[32372];
 
 INIT_VLC_STATIC(_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
-ff_vc1_norm2_bits,  1, 1,
-ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
+vc1_norm2_bits,  1, 1,
+vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
 INIT_VLC_STATIC(_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64,
-ff_vc1_norm6_bits,  1, 1,
-ff_vc1_norm6_codes, 2, 2, 556);
+vc1_norm6_bits,  1, 1,
+vc1_norm6_codes, 2, 2, 556);
 INIT_VLC_STATIC(_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7,
-ff_vc1_imode_bits,  1, 1,
-ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS);
+vc1_imode_bits,  1, 1,
+vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS);
 for (int i = 0; i < 3; i++) {
 ff_vc1_ttmb_vlc[i].table   = _table[vlc_offs[i * 3 + 0]];
 ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i 
* 3 + 0];
 init_vlc(_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16,
- ff_vc1_ttmb_bits[i],  1, 1,
- ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
+ vc1_ttmb_bits[i],  1, 1,
+ vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
 ff_vc1_ttblk_vlc[i].table   = _table[vlc_offs[i * 3 + 1]];
 ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i 
* 3 + 1];
 init_vlc(_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8,
- ff_vc1_ttblk_bits[i],  1, 1,
- ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
+ vc1_ttblk_bits[i],  1, 1,
+ vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
 ff_vc1_subblkpat_vlc[i].table   = _table[vlc_offs[i * 3 + 
2]];
 ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - 
vlc_offs[i * 3 + 2];
 init_vlc(_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15,
- ff_vc1_subblkpat_bits[i],  1, 1,
- ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
+ vc1_subblkpat_bits[i],  1, 1,
+ vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
 }
 for (int i = 0; i < 4; i++) {
 ff_vc1_4mv_block_pattern_vlc[i].table   = 
_table[vlc_offs[i * 3 + 9]];
 ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] 
- vlc_offs[i * 3 + 9];
 init_vlc(_vc1_4mv_block_pattern_vlc[i], 
VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16,
- ff_vc1_4mv_block_pattern_bits[i],  1, 1,
- ff_vc1_4mv_block_pattern_codes[i], 1, 1, 
INIT_VLC_USE_NEW_STATIC);
+ vc1_4mv_block_pattern_bits[i],  1, 1,
+ vc1_4mv_block_pattern_codes[i], 1, 1, 
INIT_VLC_USE_NEW_STATIC);
 ff_vc1_cbpcy_p_vlc[i].table   = _table[vlc_offs[i * 3 + 
10]];
 ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - 
vlc_offs[i * 3 + 10];
 init_vlc(_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64,
- ff_vc1_cbpcy_p_bits[i],  1, 1,
- ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
+ vc1_cbpcy_p_bits[i],  1, 1,
+ vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
 ff_vc1_mv_diff_vlc[i].table   = _table[vlc_offs[i * 3 + 
11]];
 ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - 
vlc_offs[i * 3 + 11];
 init_vlc(_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73,
- ff_vc1_mv_diff_bits[i],  1, 1,
- ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
+ vc1_mv_diff_bits[i],  1, 1,
+ vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
 }
 for (int i = 0; i < 8; i++) {
 ff_vc1_ac_coeff_table[i].table   = _table[vlc_offs[i * 2 + 
21]];
@@ -1627,55 +1628,55 @@ static av_cold void vc1_init_static(void)
 ff_vc1_2ref_mvdata_vlc[i].table   = _table[vlc_offs[i * 2 
+ 22]];
 

[FFmpeg-devel] [PATCH 09/19] avcodec/vc1data: Remove declarations of inexistent arrays

2022-10-30 Thread Andreas Rheinhardt
ff_vc1_norm6_spec has been removed in commit
356be9307cbffa1226bed52b26aa2ac9c7af174f (and it seems that it
has never been used); the declarations of the 8x8_zz arrays meanwhile
have been added in f0c02e1cbc71043ffe8c1fa44f12330a63f9df10
without having ever been defined.

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

diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
index ee4ec83263..b73e0a5f0e 100644
--- a/libavcodec/vc1data.h
+++ b/libavcodec/vc1data.h
@@ -112,8 +112,6 @@ extern const uint8_t ff_vc1_norm2_codes[4];
 extern const uint8_t ff_vc1_norm2_bits[4];
 extern const uint16_t ff_vc1_norm6_codes[64];
 extern const uint8_t ff_vc1_norm6_bits[64];
-/* Normal-6 imode */
-extern const uint8_t ff_vc1_norm6_spec[64][5];
 
 /* 4MV Block pattern VLC tables */
 extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16];
@@ -187,8 +185,6 @@ extern const uint8_t ff_vc1_adv_interlaced_8x8_zz [64];
 extern const uint8_t ff_vc1_adv_interlaced_8x4_zz [32];
 extern const uint8_t ff_vc1_adv_interlaced_4x8_zz [32];
 extern const uint8_t ff_vc1_adv_interlaced_4x4_zz [16];
-extern const uint8_t ff_vc1_intra_horz_8x8_zz [64];
-extern const uint8_t ff_vc1_intra_vert_8x8_zz [64];
 
 /* DQScale as specified in 8.1.3.9 - almost identical to 0x4/i */
 extern const int32_t ff_vc1_dqscale[63];
-- 
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 08/19] avcodec/vc1data: Remove duplicate defines

2022-10-30 Thread Andreas Rheinhardt
The defines in vc1data.c are duplicates of the ones in vc1data.h;
they are also pointless, because they are not used anywhere.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1data.c | 21 +
 libavcodec/vc1data.h |  3 ++-
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
index 01a9767d51..004b1347d4 100644
--- a/libavcodec/vc1data.c
+++ b/libavcodec/vc1data.c
@@ -98,50 +98,31 @@ const uint8_t ff_vc1_pquant_table[3][32] = {
   14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 }
 };
 
-/** @name VC-1 VLC tables and defines
+/** @name VC-1 VLC tables
  *  @todo TODO move this into the context
  */
 //@{
-#define VC1_IMODE_VLC_BITS 4
 VLC ff_vc1_imode_vlc;
-#define VC1_NORM2_VLC_BITS 3
 VLC ff_vc1_norm2_vlc;
-#define VC1_NORM6_VLC_BITS 9
 VLC ff_vc1_norm6_vlc;
 /* Could be optimized, one table only needs 8 bits */
-#define VC1_TTMB_VLC_BITS 9 //12
 VLC ff_vc1_ttmb_vlc[3];
-#define VC1_MV_DIFF_VLC_BITS 9 //15
 VLC ff_vc1_mv_diff_vlc[4];
-#define VC1_CBPCY_P_VLC_BITS 9 //14
 VLC ff_vc1_cbpcy_p_vlc[4];
-#define VC1_ICBPCY_VLC_BITS 9
 VLC ff_vc1_icbpcy_vlc[8];
-#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
 VLC ff_vc1_4mv_block_pattern_vlc[4];
-#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
 VLC ff_vc1_2mv_block_pattern_vlc[4];
-#define VC1_TTBLK_VLC_BITS 5
 VLC ff_vc1_ttblk_vlc[3];
-#define VC1_SUBBLKPAT_VLC_BITS 6
 VLC ff_vc1_subblkpat_vlc[3];
-#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
 VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
-#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
 VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
-#define VC1_IF_MMV_MBMODE_VLC_BITS 5
 VLC ff_vc1_if_mmv_mbmode_vlc[8];
-#define VC1_IF_1MV_MBMODE_VLC_BITS 5
 VLC ff_vc1_if_1mv_mbmode_vlc[8];
-#define VC1_1REF_MVDATA_VLC_BITS 9
 VLC ff_vc1_1ref_mvdata_vlc[4];
-#define VC1_2REF_MVDATA_VLC_BITS 9
 VLC ff_vc1_2ref_mvdata_vlc[8];
 
 VLC ff_vc1_ac_coeff_table[8];
 
-#define VC1_IF_MBMODE_VLC_BITS 5// as a placeholder for 
VC1_IF_MMV_MBMODE_VLC_BITS
-// or VC1_IF_1MV_MBMODE_VLC_BITS since 
they are the same
 //@}
 
 
diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
index 3e45ef1e79..ee4ec83263 100644
--- a/libavcodec/vc1data.h
+++ b/libavcodec/vc1data.h
@@ -91,7 +91,8 @@ extern VLC ff_vc1_2ref_mvdata_vlc[8];
 
 extern VLC ff_vc1_ac_coeff_table[8];
 
-#define VC1_IF_MBMODE_VLC_BITS 5
+#define VC1_IF_MBMODE_VLC_BITS 5// as a placeholder for 
VC1_IF_MMV_MBMODE_VLC_BITS
+// or VC1_IF_1MV_MBMODE_VLC_BITS since 
they are the same
 //@}
 
 #define B_FRACTION_DEN  256
-- 
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 07/19] avcodec/vc1: Move setting res_fasttx-IDCT functions to vc1dec.c

2022-10-30 Thread Andreas Rheinhardt
It allows to avoid compiling simple_idct.o for the VC-1 parser.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile |  2 +-
 libavcodec/vc1.c| 11 ---
 libavcodec/vc1dec.c |  9 +
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 72d2f92901..739bf757f9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1169,7 +1169,7 @@ OBJS-$(CONFIG_SBC_PARSER)  += sbc_parser.o
 OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o
 OBJS-$(CONFIG_TAK_PARSER)  += tak_parser.o tak.o
 OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o vc1.o vc1data.o  \
-  simple_idct.o wmv2data.o
+  wmv2data.o
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index f6468b54c7..6eb0d70a68 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -35,7 +35,6 @@
 #include "vc1data.h"
 #include "wmv2data.h"
 #include "unary.h"
-#include "simple_idct.h"
 
 /***/
 /**
@@ -314,16 +313,6 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, 
VC1Context *v, GetBitCo
 v->res_x8  = get_bits1(gb); //reserved
 v->multires= get_bits1(gb);
 v->res_fasttx  = get_bits1(gb);
-if (!v->res_fasttx) {
-v->vc1dsp.vc1_inv_trans_8x8= ff_simple_idct_int16_8bit;
-v->vc1dsp.vc1_inv_trans_8x4= ff_simple_idct84_add;
-v->vc1dsp.vc1_inv_trans_4x8= ff_simple_idct48_add;
-v->vc1dsp.vc1_inv_trans_4x4= ff_simple_idct44_add;
-v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_int16_8bit;
-v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
-v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
-v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
-}
 
 v->fastuvmc= get_bits1(gb); //common
 if (!v->profile && !v->fastuvmc) {
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index fa6b5cfd3c..2cb39430f5 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -40,6 +40,7 @@
 #include "msmpeg4data.h"
 #include "msmpeg4dec.h"
 #include "profiles.h"
+#include "simple_idct.h"
 #include "vc1.h"
 #include "vc1data.h"
 #include "libavutil/avassert.h"
@@ -562,6 +563,14 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
 v->left_blk_sh = 3;
 v->top_blk_sh  = 0;
+v->vc1dsp.vc1_inv_trans_8x8= ff_simple_idct_int16_8bit;
+v->vc1dsp.vc1_inv_trans_8x4= ff_simple_idct84_add;
+v->vc1dsp.vc1_inv_trans_4x8= ff_simple_idct48_add;
+v->vc1dsp.vc1_inv_trans_4x4= ff_simple_idct44_add;
+v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_int16_8bit;
+v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
+v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
+v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
 }
 
 if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == 
AV_CODEC_ID_VC1IMAGE) {
-- 
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 06/19] avcodec/vc1_parser: Don't call ff_vc1_init_common()

2022-10-30 Thread Andreas Rheinhardt
It is unnecessary to initialize the VLCs: The only VLC
that was only ever used by the code reachable from the parser
was ff_vc1_bfraction_vlc; and this VLC has been removed.

Yet vc1dsp is still needed for startcode_find_candidate.
Maybe this should be factored out of vc1dsp in a later
commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1_parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index d57fcdf1e1..a459a2aa7d 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -29,6 +29,7 @@
 #include "parser.h"
 #include "vc1.h"
 #include "get_bits.h"
+#include "vc1dsp.h"
 
 /** The maximum number of bytes of a sequence, entry point or
  *  frame header whose values we pay any attention to */
@@ -264,7 +265,7 @@ static av_cold int vc1_parse_init(AVCodecParserContext *s)
 vpc->bytes_to_skip = 0;
 vpc->unesc_index = 0;
 vpc->search_state = NO_MATCH;
-ff_vc1_init_common(>v);
+ff_vc1dsp_init(>v.vc1dsp); /* startcode_find_candidate */
 return 0;
 }
 
-- 
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 05/19] avcodec/vc1_parser: Set parse_only only once

2022-10-30 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 8257e0ccfa..d57fcdf1e1 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -65,7 +65,6 @@ static void vc1_extract_header(AVCodecParserContext *s, 
AVCodecContext *avctx,
 GetBitContext gb;
 int ret;
 vpc->v.s.avctx = avctx;
-vpc->v.parse_only = 1;
 init_get_bits8(, buf, buf_size);
 switch (vpc->prev_start_code) {
 case VC1_CODE_SEQHDR & 0xFF:
@@ -260,6 +259,7 @@ static av_cold int vc1_parse_init(AVCodecParserContext *s)
 VC1ParseContext *vpc = s->priv_data;
 vpc->v.s.slice_context_count = 1;
 vpc->v.first_pic_header_flag = 1;
+vpc->v.parse_only = 1;
 vpc->prev_start_code = 0;
 vpc->bytes_to_skip = 0;
 vpc->unesc_index = 0;
-- 
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 04/19] avcodec/vc1: Don't use VLC to read bfraction

2022-10-30 Thread Andreas Rheinhardt
The VLC here is very simple, so that it can just be read
by two get_bits().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1.c |  8 
 libavcodec/vc1data.c | 21 -
 libavcodec/vc1data.h |  4 
 3 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 9b4e951baa..f6468b54c7 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -613,7 +613,10 @@ static void rotate_luts(VC1Context *v)
 }
 
 static int read_bfraction(VC1Context *v, GetBitContext* gb) {
-int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, 
VC1_BFRACTION_VLC_BITS, 1);
+int bfraction_lut_index = get_bits(gb, 3);
+
+if (bfraction_lut_index == 7)
+bfraction_lut_index = 7 + get_bits(gb, 4);
 
 if (bfraction_lut_index == 21) {
 av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n");
@@ -1582,9 +1585,6 @@ static av_cold void vc1_init_static(void)
 {
 static VLCElem vlc_table[32372];
 
-INIT_VLC_STATIC(_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23,
-ff_vc1_bfraction_bits,  1, 1,
-ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS);
 INIT_VLC_STATIC(_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
 ff_vc1_norm2_bits,  1, 1,
 ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
index 844bc0f5c5..01a9767d51 100644
--- a/libavcodec/vc1data.c
+++ b/libavcodec/vc1data.c
@@ -102,8 +102,6 @@ const uint8_t ff_vc1_pquant_table[3][32] = {
  *  @todo TODO move this into the context
  */
 //@{
-#define VC1_BFRACTION_VLC_BITS 7
-VLC ff_vc1_bfraction_vlc;
 #define VC1_IMODE_VLC_BITS 4
 VLC ff_vc1_imode_vlc;
 #define VC1_NORM2_VLC_BITS 3
@@ -171,25 +169,6 @@ const int16_t ff_vc1_bfraction_lut[23] = {
 };
 #endif
 
-const uint8_t ff_vc1_bfraction_bits[23] = {
-3, 3, 3, 3,
-3, 3, 3,
-7, 7, 7, 7,
-7, 7, 7, 7,
-7, 7, 7, 7,
-7, 7,
-7, 7
-};
-const uint8_t ff_vc1_bfraction_codes[23] = {
-  0,   1,   2,   3,
-  4,   5,   6,
-112, 113, 114, 115,
-116, 117, 118, 119,
-120, 121, 122, 123,
-124, 125,
-126, 127
-};
-
 //Same as H.264
 const AVRational ff_vc1_pixel_aspect[16] = {
 {   0,  1 },
diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
index 90dd8baf61..3e45ef1e79 100644
--- a/libavcodec/vc1data.h
+++ b/libavcodec/vc1data.h
@@ -53,8 +53,6 @@ extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
  *  @todo TODO move this into the context
  */
 //@{
-#define VC1_BFRACTION_VLC_BITS 7
-extern VLC ff_vc1_bfraction_vlc;
 #define VC1_IMODE_VLC_BITS 4
 extern VLC ff_vc1_imode_vlc;
 #define VC1_NORM2_VLC_BITS 3
@@ -100,8 +98,6 @@ extern VLC ff_vc1_ac_coeff_table[8];
 
 /* pre-computed scales for all bfractions and base=256 */
 extern const int16_t ff_vc1_bfraction_lut[23];
-extern const uint8_t ff_vc1_bfraction_bits[23];
-extern const uint8_t ff_vc1_bfraction_codes[23];
 
 //Same as H.264
 extern const AVRational ff_vc1_pixel_aspect[16];
-- 
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 03/19] avcodec/vc1: Don't check for errors for complete VLC

2022-10-30 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index cacb66b15b..9b4e951baa 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -615,7 +615,7 @@ static void rotate_luts(VC1Context *v)
 static int read_bfraction(VC1Context *v, GetBitContext* gb) {
 int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, 
VC1_BFRACTION_VLC_BITS, 1);
 
-if (bfraction_lut_index == 21 || bfraction_lut_index < 0) {
+if (bfraction_lut_index == 21) {
 av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n");
 return AVERROR_INVALIDDATA;
 }
-- 
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 02/19] avcodec/vc1: Remove always-false check

2022-10-30 Thread Andreas Rheinhardt
Added in b50be4e38dc83389925dc14f24fa11e660d32197;
this check was racy back then (as the VLC could be initialized
concurrently) and it is redundant (always-false)
since commit c742ab4e81bb9dcabfdab006d6b8b09a5808c4ce.

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

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index f6de8b9e75..cacb66b15b 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -933,8 +933,6 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, 
GetBitContext* gb)
 v->rnd = get_bits1(gb);
 if (v->interlace)
 v->uvsamp = get_bits1(gb);
-if(!ff_vc1_bfraction_vlc.table)
-return 0; //parsing only, vlc tables havnt been allocated
 if (v->field_mode) {
 if (!v->refdist_flag)
 v->refdist = 0;
-- 
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 01/19] avcodec/vc1: Don't check for AVCodecContext.codec

2022-10-30 Thread Andreas Rheinhardt
This check has been added in c617bed34f39a122ab1f89581ddce9cc63885383,
merging ee769c6a7c1d4ec6560f5e5a6f457b770b10fb33 to fix
a possible segfault if AVCodecContext.codec is not set
as it may be during parsing. While this fixes the segfault,
it has the unfortunate side effect that it makes the output
of the parser dependent on whether a decoder is set (and
ultimately available). The fix later applied in
5d2be71b9ecf2a88752666a2c4039f4d98419d35 does not have this
downside and makes checking AVCodecContext.codec superfluous.
So remove this check.

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

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index c9257b290f..f6de8b9e75 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -632,8 +632,6 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* 
gb)
 v->fcm = PROGRESSIVE;
 if (v->finterpflag)
 v->interpfrm = get_bits1(gb);
-if (!v->s.avctx->codec)
-return -1;
 if (v->s.avctx->codec_id == AV_CODEC_ID_MSS2)
 v->respic   =
 v->rangered =
-- 
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 0/4] swscale rgbaf32 input/output support

2022-10-30 Thread Mark Reid
On Sun, Oct 30, 2022 at 1:48 PM Mark Reid  wrote:

>
>
> On Wed, Oct 12, 2022 at 3:06 PM Mark Reid  wrote:
>
>>
>>
>> On Thu, Sep 29, 2022 at 11:08 AM  wrote:
>>
>>> From: Mark Reid 
>>>
>>> This patch series adds swscale input/output support for the packed rgb
>>> float formats.
>>> A few of the filters also needed support the larger 96/128 bit packed
>>> pixel sizes.
>>>
>>> I also plan to eventually add lossless unscaled conversions between the
>>> planer and packed formats.
>>>
>>> Mark Reid (4):
>>>   swscale/input: add rgbaf32 input support
>>>   avfilter/vf_hflip: add support for packed rgb float formats
>>>   avfilter/vf_transpose: add support for packed rgb float formats
>>>   swscale/output: add rgbaf32 output support
>>>
>>>  libavfilter/vf_hflip_init.h  |  25 
>>>  libavfilter/vf_transpose.c   |  44 ++
>>>  libswscale/input.c   | 172 +++
>>>  libswscale/output.c  |  89 
>>>  libswscale/swscale_unscaled.c|   4 +-
>>>  libswscale/tests/floatimg_cmp.c  |   4 +-
>>>  libswscale/utils.c   |  12 +-
>>>  libswscale/yuv2rgb.c |   2 +
>>>  tests/ref/fate/filter-pixdesc-rgbaf32be  |   1 +
>>>  tests/ref/fate/filter-pixdesc-rgbaf32le  |   1 +
>>>  tests/ref/fate/filter-pixdesc-rgbf32be   |   1 +
>>>  tests/ref/fate/filter-pixdesc-rgbf32le   |   1 +
>>>  tests/ref/fate/filter-pixfmts-copy   |   4 +
>>>  tests/ref/fate/filter-pixfmts-crop   |   4 +
>>>  tests/ref/fate/filter-pixfmts-field  |   4 +
>>>  tests/ref/fate/filter-pixfmts-fieldorder |   4 +
>>>  tests/ref/fate/filter-pixfmts-hflip  |   4 +
>>>  tests/ref/fate/filter-pixfmts-il |   4 +
>>>  tests/ref/fate/filter-pixfmts-null   |   4 +
>>>  tests/ref/fate/filter-pixfmts-scale  |   4 +
>>>  tests/ref/fate/filter-pixfmts-transpose  |   4 +
>>>  tests/ref/fate/filter-pixfmts-vflip  |   4 +
>>>  tests/ref/fate/sws-floatimg-cmp  |  16 +++
>>>  23 files changed, 408 insertions(+), 4 deletions(-)
>>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be
>>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le
>>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be
>>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le
>>>
>>> --
>>> 2.31.1.windows.1
>>>
>>>
>> ping
>>
>
> ping
>

I noticed I'm not outputting an alpha value of 1.0f if src format doesn't
have alpha but the dst format needs one.
I'll submit a new version of this 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".


Re: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Soft Works
> Sent: Sunday, October 30, 2022 10:41 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Revert
> "avfilter/vf_palette(gen|use): support palettes with alpha"
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Clément Bœsch
> > Sent: Sunday, October 30, 2022 10:30 PM
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] Revert
> > "avfilter/vf_palette(gen|use): support palettes with alpha"
> >
> > On Sun, Oct 30, 2022 at 09:19:05PM +, Soft Works wrote:
> > [...]
> > > At the time of submission I did a lot of experiments and the
> > results
> > > seemed to be very useful:
> > >
> > >
> https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f
> > >
> >
> > On that page, the result of the command using palette* filters for
> > the
> > colored "O" gives a broken output, and it's not a simple bug, it's
> > more
> > fundamental. You cannot just just average the colors with different
> > levels
> > of alpha, it makes no sense.
> >
> > Do you understand why or do you need me to elaborate?
> 
> I understand why. I know that it's not perfect. But it's the best
> what's achievable within the way the filter is working.
> 
> But I wouldn't go that far as saying it would be "broken". I think
> the result is quite acceptable with regards to the method being
> using.
> 
> The patch I had submitted doesn't change the previous behavior
> without the use_alpha parameter.
> And when using the use_alpha parameter, the results are still
> useful in many cases - maybe not always.
> 
> But it don't see any reason to remove this just because it's not
> perfect. If you would have a patch to improve the results - that
> would be a different story and of course very welcome.

I'm really not an expert in image processing algorithms, and I 
haven't tried the following yet:
Do you think it might make sense to put more weight on the 
alpha value by tripling it? So it would be weighted equally to the 
RGB value?

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


Re: [FFmpeg-devel] [PATCH] avcodec/libsvtav1: Add support for multipass encoding

2022-10-30 Thread Oneric
On Sun, Oct 30, 2022 at 14:10:29 +0100, Lynne wrote:
> Sep 27, 2022, 23:06 by gustav.grus...@gmail.com:
> 
> > Implements support for 2-pass CRF and 3-pass VBR by implementing
> > reading and writing of stats file, and passing the pass number on
> > to the encoder. For 3-pass VBR, the first pass should be run with
> > '-pass 1', the second with '-pass 3' and the third with '-pass 2'.
> >
> > [...]
> 
> 2-pass doesn't seem to work, the encoder complains it's not the final pass.

fwiw, 2-pass CRF and 3-pass VBR work for me on a short sample with this
patch applied on top of 882a17068fd8e62c7d38c14e6fb160d7c9fc446a and using
SVT-AV1 1.3.0.

I'm not sure if 2-pass VBR is supposed to work, though I didn't look into
it too much. SVT-AV1 docs only mention 3-pass VBR[1] afaict and while
requesting output already in the second pass (`--pass 2` for SvtAv1EncApp
and `-pass 3` for patched ffmpeg) "works", the result misses the targeted
overall bitrate even more than singlepass VBR.

For reference here are the commands I used:

2-pass CRF:
---
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -crf 50 -g 300 -pass 1 -f null /dev/null \
  && ./ffmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -crf 50 -g 300 -pass 2 -f matroska crf_pass2.mkv


3-pass VBR:
---
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 1 \
-f null /dev/null \
 && ./fmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 3 \
-f null /dev/null \
 && ./fmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 2 \
-f matroska vbr_pass2.mkv


"2-pass VBR" (probably bad idea):
-
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 1 \
-f null /dev/null \
  && ./fmpeg -i org.mkv -c:v libsvtav1 \
-preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 3 \
-f matroska vbr_pass2.mkv


[1]: 
https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/91b94efb2809e83d9bf041d8575b32f234dfef27/Docs/svt-av1_encoder_user_guide.md#multi-pass-vbr-1000-kbps-at-maximum-quality-from-24fps-yuv-1920x1080-input
___
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] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Clément Bœsch
> Sent: Sunday, October 30, 2022 10:30 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Revert
> "avfilter/vf_palette(gen|use): support palettes with alpha"
> 
> On Sun, Oct 30, 2022 at 09:19:05PM +, Soft Works wrote:
> [...]
> > At the time of submission I did a lot of experiments and the
> results
> > seemed to be very useful:
> >
> > https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f
> >
> 
> On that page, the result of the command using palette* filters for
> the
> colored "O" gives a broken output, and it's not a simple bug, it's
> more
> fundamental. You cannot just just average the colors with different
> levels
> of alpha, it makes no sense.
> 
> Do you understand why or do you need me to elaborate?

I understand why. I know that it's not perfect. But it's the best
what's achievable within the way the filter is working.

But I wouldn't go that far as saying it would be "broken". I think
the result is quite acceptable with regards to the method being 
using.

The patch I had submitted doesn't change the previous behavior
without the use_alpha parameter.
And when using the use_alpha parameter, the results are still
useful in many cases - maybe not always.

But it don't see any reason to remove this just because it's not 
perfect. If you would have a patch to improve the results - that
would be a different story and of course very welcome.

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


Re: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Clément Bœsch
On Sun, Oct 30, 2022 at 10:30:06PM +0100, Clément Bœsch wrote:
> On Sun, Oct 30, 2022 at 09:19:05PM +, Soft Works wrote:
> [...]
> > At the time of submission I did a lot of experiments and the results
> > seemed to be very useful:
> > 
> > https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f
> > 
> 
> On that page, the result of the command using palette* filters for the
> colored "O" gives a broken output, and it's not a simple bug, it's more
> fundamental. You cannot just just average the colors with different levels
> of alpha, it makes no sense.
> 
> Do you understand why or do you need me to elaborate?
> 

Here is a alpha channel, which is the result of average them with the
colors: https://imgur.com/a/50YyRGV

-- 
Clément B.
___
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] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Clément Bœsch
On Sun, Oct 30, 2022 at 09:19:05PM +, Soft Works wrote:
[...]
> At the time of submission I did a lot of experiments and the results
> seemed to be very useful:
> 
> https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f
> 

On that page, the result of the command using palette* filters for the
colored "O" gives a broken output, and it's not a simple bug, it's more
fundamental. You cannot just just average the colors with different levels
of alpha, it makes no sense.

Do you understand why or do you need me to elaborate?

> softworkz

-- 
Clément B.
___
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] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Clément Bœsch
> Sent: Sunday, October 30, 2022 6:58 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: softwo...@hotmail.com; Clément Bœsch 
> Subject: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use):
> support palettes with alpha"
> 
> This reverts commit dea673d0d548c864ec85f9260d8900d944ef7a2a.
> 
> This change cannot work for several reasons, the most obvious ones
> are:
> 
> - the alpha is being part of the scoring of the color difference,
> even
>   though we can not interpret the alpha as part of the perception of
> the
>   color (we don't even know if it's premultiplied or postmultiplied)
> - the colors are averaged with their alpha value which simply cannot
>   work
> 
> The command proposed in the original thread of the patch actually
> produces a completely broken file:
> 
> ffmpeg -y -loglevel verbose -i fate-suite/apng/o_sample.png -
> filter_complex
> "split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[
> pal1];[split2][pal1]paletteuse=use_alpha=1" -frames:v 1 out.png
> 
> We can see that many color pixels are off, but more importantly some
> colors have a random alpha value: https://imgur.com/eFQ2UK7
> 
> I don't see any easy fix for this unfortunately, the approach appears
> to
> be flawed by design.
> ---

At the time of submission I did a lot of experiments and the results
seemed to be very useful:

https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f

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


Re: [FFmpeg-devel] FFmpeg 5.0

2022-10-30 Thread Neal Gompa
On Sun, Oct 30, 2022 at 4:10 PM Michael Niedermayer
 wrote:
>
> On Sat, Oct 29, 2022 at 02:29:56PM -0400, Neal Gompa wrote:
> > On Fri, Oct 28, 2022 at 2:23 PM Michael Niedermayer
> >  wrote:
> > >
> > > Hi
> > >
> > > According to our
> > > https://trac.ffmpeg.org/wiki/Downstreams
> > >
> > > Noone and nothing is using 5.0
> > > should i make another release of 5.0 ?
> > > should i move 5.0 to olddownloads ?
> > >
> > > does anyone use it ? plan to use it or know of someone using it ?
> > >
> >
> > Fedora 36 still uses FFmpeg 5.0 as I discovered there was an ABI break
> > that made upgrading to FFmpeg 5.1 not possible for F36. FFmpeg 5.1 is
> > used for Fedora 37, though.
> >
> > This had apparently been also discovered by openSUSE some time ago:
> > https://build.opensuse.org/package/view_file/multimedia:libs/ffmpeg-5/work-around-abi-break.patch?expand=1
>
> You can replace 5.0 by 5.1 but not 5.1 by 5.0, The compatibility is only
> in one way.
> Iam assuming here you talk about the addition of functions and there is
> not some other issue iam not aware of.
>

My understanding is that when using symbol versions, modifying the
symbol table creates a breakage on its own.

>
> >
> > Fedora 36 will still be supported until June, so I would appreciate it
> > if another release of 5.0 would be made.
>
> I have to admit i feel a bit undecided. Id like to first understand why
> this situation/"need" exists for fedora but not others
>
>

I mostly did this at the advice of Jan from openSUSE and the RPM
Fusion ffmpeg maintainers.

> >
> > Do we have ABI testing in place for submitted patches? I haven't seen
> > any evidence of CI testing of patches submitted to the mailing list,
> > but maybe I'm looking in the wrong place? If there is, maybe we can
> > consider adding some kind of ABI testing for release branches, using
> > tools like libabigail[1] with abidiff[2]?
> >
> > [1]: https://sourceware.org/libabigail/
> > [2]: https://www.mankier.com/1/abidiff
>
> iam not sure there is agreement between you and others of what is a ABI break
> so the tool maybe will not help.
>
> I have generaly done testing with replacing old libraries by new when doing
> releases. But for me a ABI break is if replacing a library by another breaks
> some binary that is not rebuild and linked to the new lib.
>
> More testing is always good and welcome of course.
>

Yeah, I think that qualifying how ABI is validated in a reproducible
way would be useful. The abigail tooling can help here, In Fedora,
every update runs through abigail validation too. I vaguely recall
that it warned me when I did the update in Rawhide, which is how I wound
up talking to Jan in openSUSE and RPM Fusion maintainers, who both
didn't refresh FFmpeg on stable branches with 5.0 to 5.1.

It's also entirely possible that I was *too* cautious, and I'm okay
with having a conversation that leads me to do differently in the future.





--
真実はいつも一つ!/ Always, there's only one truth!
___
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] FFmpeg 5.0

2022-10-30 Thread Neal Gompa
On Sun, Oct 30, 2022 at 4:16 PM Michael Niedermayer
 wrote:
>
> On Sat, Oct 29, 2022 at 02:29:56PM -0400, Neal Gompa wrote:
> > On Fri, Oct 28, 2022 at 2:23 PM Michael Niedermayer
> >  wrote:
> > >
> > > Hi
> > >
> > > According to our
> > > https://trac.ffmpeg.org/wiki/Downstreams
> > >
> > > Noone and nothing is using 5.0
> > > should i make another release of 5.0 ?
> > > should i move 5.0 to olddownloads ?
> > >
> > > does anyone use it ? plan to use it or know of someone using it ?
> > >
> >
> > Fedora 36 still uses FFmpeg 5.0 as I discovered there was an ABI break
> > that made upgrading to FFmpeg 5.1 not possible for F36. FFmpeg 5.1 is
> > used for Fedora 37, though.
>
> why is
> https://trac.ffmpeg.org/wiki/Downstreams
> not listing any of that ?

I didn't know it existed. Updated! :)



-- 
真実はいつも一つ!/ Always, there's only one truth!
___
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 0/4] swscale rgbaf32 input/output support

2022-10-30 Thread Mark Reid
On Wed, Oct 12, 2022 at 3:06 PM Mark Reid  wrote:

>
>
> On Thu, Sep 29, 2022 at 11:08 AM  wrote:
>
>> From: Mark Reid 
>>
>> This patch series adds swscale input/output support for the packed rgb
>> float formats.
>> A few of the filters also needed support the larger 96/128 bit packed
>> pixel sizes.
>>
>> I also plan to eventually add lossless unscaled conversions between the
>> planer and packed formats.
>>
>> Mark Reid (4):
>>   swscale/input: add rgbaf32 input support
>>   avfilter/vf_hflip: add support for packed rgb float formats
>>   avfilter/vf_transpose: add support for packed rgb float formats
>>   swscale/output: add rgbaf32 output support
>>
>>  libavfilter/vf_hflip_init.h  |  25 
>>  libavfilter/vf_transpose.c   |  44 ++
>>  libswscale/input.c   | 172 +++
>>  libswscale/output.c  |  89 
>>  libswscale/swscale_unscaled.c|   4 +-
>>  libswscale/tests/floatimg_cmp.c  |   4 +-
>>  libswscale/utils.c   |  12 +-
>>  libswscale/yuv2rgb.c |   2 +
>>  tests/ref/fate/filter-pixdesc-rgbaf32be  |   1 +
>>  tests/ref/fate/filter-pixdesc-rgbaf32le  |   1 +
>>  tests/ref/fate/filter-pixdesc-rgbf32be   |   1 +
>>  tests/ref/fate/filter-pixdesc-rgbf32le   |   1 +
>>  tests/ref/fate/filter-pixfmts-copy   |   4 +
>>  tests/ref/fate/filter-pixfmts-crop   |   4 +
>>  tests/ref/fate/filter-pixfmts-field  |   4 +
>>  tests/ref/fate/filter-pixfmts-fieldorder |   4 +
>>  tests/ref/fate/filter-pixfmts-hflip  |   4 +
>>  tests/ref/fate/filter-pixfmts-il |   4 +
>>  tests/ref/fate/filter-pixfmts-null   |   4 +
>>  tests/ref/fate/filter-pixfmts-scale  |   4 +
>>  tests/ref/fate/filter-pixfmts-transpose  |   4 +
>>  tests/ref/fate/filter-pixfmts-vflip  |   4 +
>>  tests/ref/fate/sws-floatimg-cmp  |  16 +++
>>  23 files changed, 408 insertions(+), 4 deletions(-)
>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be
>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le
>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be
>>  create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le
>>
>> --
>> 2.31.1.windows.1
>>
>>
> ping
>

ping
___
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] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,


Given the angles below, this should be FC+BL+BR.


+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },


Probably FC+BC+SL+SR.


+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145 },
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110 },
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180, -110, 110 },
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ -30, 30, 0, -145, 145, -110, 
110 },
+.speakers_distance = same_distance,
+},
+[TETRA] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 2,
+.near_field = NF_NONE,
+

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer

On 10/30/2022 4:19 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 3:58 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 3:29 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:



On 10/30/2022 3:19 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout =
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135
},
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout =
(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145,
145
},
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110,
110
},
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180,
-110,
110
},
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ 

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

2022-10-30 Thread Andreas Rheinhardt
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(>ch_units);
>  av_freep(>fdsp);
>  
> +av_channel_layout_uninit(>coded_ch_layout);
> +
>  ff_mdct_end(>mdct_ctx);
>  ff_mdct_end(>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(>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(>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(>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(>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, >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 

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread Paul B Mahol
On 10/30/22, James Almer  wrote:
> On 10/30/2022 3:58 PM, Paul B Mahol wrote:
>> On 10/30/22, James Almer  wrote:
>>> On 10/30/2022 3:29 PM, Paul B Mahol wrote:
 On 10/30/22, James Almer  wrote:
>
>
> On 10/30/2022 3:19 PM, Paul B Mahol wrote:
>> On 10/30/22, James Almer  wrote:
>>> On 10/30/2022 12:34 PM, Paul B Mahol wrote:
 +static const struct {
 +const int  order;
 +const int  inputs;
 +const int  speakers;
 +const int  near_field;
 +const int  type;
 +const double   xover;
 +const AVChannelLayout  outlayout;
 +const double  *speakers_azimuth;
 +const double  *speakers_elevation;
 +const double  *speakers_distance;
 +} ambisonic_tab[] = {
 +[MONO] = {
 +.order = 0,
 +.inputs = 1,
 +.speakers = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
 +.speakers_azimuth = (const double[1]){ 0. },
 +.speakers_distance = (const double[1]){ 1. },
 +},
 +[STEREO] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 2,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
 +.speakers_azimuth = (const double[2]){ -30, 30},
 +.speakers_distance = same_distance,
 +},
 +[STEREO_DOWNMIX] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 2,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout =
 (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
 +.speakers_azimuth = (const double[2]){ -90, 90 },
 +.speakers_distance = same_distance,
 +},
 +[SURROUND] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
 +.speakers_azimuth = (const double[3]){ -45, 45, 0 },
 +.speakers_distance = same_distance,
 +},
 +[L2_1] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
 +.speakers_azimuth = (const double[3]){ -45, 45, 180 },
 +.speakers_distance = same_distance,
 +},
 +[TRIANGLE] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.type = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
 +.speakers_azimuth = (const double[3]){ -120, 120, 0 },
 +.speakers_distance = same_distance,
 +},
 +[QUAD] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
 +.speakers_azimuth = (const double[4]){ -45, 45, -135, 135
 },
 +.speakers_distance = same_distance,
 +},
 +[SQUARE] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.type = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
 +.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
 +.speakers_distance = same_distance,
 +},
 +[L4_0] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
 +.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
 +.speakers_distance = same_distance,
 +},
 +[L5_0] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 5,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout =
 (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
 +

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer

On 10/30/2022 3:58 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 3:29 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:



On 10/30/2022 3:19 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout =
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout =
(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145
},
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110
},
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180,
-110,
110
},
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ -30, 30, 0, -145,
145,
-110, 110 },
+.speakers_distance = same_distance,

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread Paul B Mahol
On 10/30/22, James Almer  wrote:
> On 10/30/2022 3:29 PM, Paul B Mahol wrote:
>> On 10/30/22, James Almer  wrote:
>>>
>>>
>>> On 10/30/2022 3:19 PM, Paul B Mahol wrote:
 On 10/30/22, James Almer  wrote:
> On 10/30/2022 12:34 PM, Paul B Mahol wrote:
>> +static const struct {
>> +const int  order;
>> +const int  inputs;
>> +const int  speakers;
>> +const int  near_field;
>> +const int  type;
>> +const double   xover;
>> +const AVChannelLayout  outlayout;
>> +const double  *speakers_azimuth;
>> +const double  *speakers_elevation;
>> +const double  *speakers_distance;
>> +} ambisonic_tab[] = {
>> +[MONO] = {
>> +.order = 0,
>> +.inputs = 1,
>> +.speakers = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
>> +.speakers_azimuth = (const double[1]){ 0. },
>> +.speakers_distance = (const double[1]){ 1. },
>> +},
>> +[STEREO] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 2,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
>> +.speakers_azimuth = (const double[2]){ -30, 30},
>> +.speakers_distance = same_distance,
>> +},
>> +[STEREO_DOWNMIX] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 2,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout =
>> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
>> +.speakers_azimuth = (const double[2]){ -90, 90 },
>> +.speakers_distance = same_distance,
>> +},
>> +[SURROUND] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
>> +.speakers_azimuth = (const double[3]){ -45, 45, 0 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L2_1] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
>> +.speakers_azimuth = (const double[3]){ -45, 45, 180 },
>> +.speakers_distance = same_distance,
>> +},
>> +[TRIANGLE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.type = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
>> +.speakers_azimuth = (const double[3]){ -120, 120, 0 },
>> +.speakers_distance = same_distance,
>> +},
>> +[QUAD] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
>> +.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
>> +.speakers_distance = same_distance,
>> +},
>> +[SQUARE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.type = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
>> +.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L4_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
>> +.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L5_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 5,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout =
>> (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
>> +.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145
>> },
>> +.speakers_distance = same_distance,
>> +},
>> +[L5_0_SIDE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 5,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer

On 10/30/2022 3:29 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:



On 10/30/2022 3:19 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout =
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145
},
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110
},
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180, -110,
110
},
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ -30, 30, 0, -145, 145,
-110, 110 },
+.speakers_distance = same_distance,
+},
+[TETRA] = {
+.order = 1,
+.inputs = 4,
+

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread Paul B Mahol
On 10/30/22, James Almer  wrote:
>
>
> On 10/30/2022 3:19 PM, Paul B Mahol wrote:
>> On 10/30/22, James Almer  wrote:
>>> On 10/30/2022 12:34 PM, Paul B Mahol wrote:
 +static const struct {
 +const int  order;
 +const int  inputs;
 +const int  speakers;
 +const int  near_field;
 +const int  type;
 +const double   xover;
 +const AVChannelLayout  outlayout;
 +const double  *speakers_azimuth;
 +const double  *speakers_elevation;
 +const double  *speakers_distance;
 +} ambisonic_tab[] = {
 +[MONO] = {
 +.order = 0,
 +.inputs = 1,
 +.speakers = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
 +.speakers_azimuth = (const double[1]){ 0. },
 +.speakers_distance = (const double[1]){ 1. },
 +},
 +[STEREO] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 2,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
 +.speakers_azimuth = (const double[2]){ -30, 30},
 +.speakers_distance = same_distance,
 +},
 +[STEREO_DOWNMIX] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 2,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout =
 (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
 +.speakers_azimuth = (const double[2]){ -90, 90 },
 +.speakers_distance = same_distance,
 +},
 +[SURROUND] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
 +.speakers_azimuth = (const double[3]){ -45, 45, 0 },
 +.speakers_distance = same_distance,
 +},
 +[L2_1] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
 +.speakers_azimuth = (const double[3]){ -45, 45, 180 },
 +.speakers_distance = same_distance,
 +},
 +[TRIANGLE] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 3,
 +.type = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
 +.speakers_azimuth = (const double[3]){ -120, 120, 0 },
 +.speakers_distance = same_distance,
 +},
 +[QUAD] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
 +.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
 +.speakers_distance = same_distance,
 +},
 +[SQUARE] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.type = 1,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
 +.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
 +.speakers_distance = same_distance,
 +},
 +[L4_0] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 4,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
 +.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
 +.speakers_distance = same_distance,
 +},
 +[L5_0] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 5,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
 +.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145
 },
 +.speakers_distance = same_distance,
 +},
 +[L5_0_SIDE] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 5,
 +.near_field = NF_NONE,
 +.xover = 0.,
 +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
 +.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110
 },
 +.speakers_distance = same_distance,
 +},
 +[L6_0] = {
 +.order = 1,
 +.inputs = 4,
 +.speakers = 6,
 +.near_field = NF_NONE,
 + 

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer




On 10/30/2022 3:19 PM, Paul B Mahol wrote:

On 10/30/22, James Almer  wrote:

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145 },
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110 },
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180, -110, 110
},
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ -30, 30, 0, -145, 145,
-110, 110 },
+.speakers_distance = same_distance,
+},
+[TETRA] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 2,
+.near_field = NF_NONE,
+

Re: [FFmpeg-devel] [PATCH] avutil/channel_layout: add a cube channel layout

2022-10-30 Thread Paul B Mahol
On 10/30/22, James Almer  wrote:
>
>
> On 10/30/2022 1:19 PM, Andreas Rheinhardt wrote:
>> 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..5aca1d1b5f 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_CUBE and AV_CHANNEL_LAYOUT_CUBE.
>>> +
>>>   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..907a6b87cb 100644
>>> --- a/doc/utils.texi
>>> +++ b/doc/utils.texi
>>> @@ -715,6 +715,8 @@ FL+FR+FC+LFE+BL+BR+FLC+FRC
>>>   FL+FR+FC+LFE+FLC+FRC+SL+SR
>>>   @item octagonal
>>>   FL+FR+FC+BL+BR+BC+SL+SR
>>> +@item cube
>>> +FL+FR+BL+BR+TFL+TFR+TBL+TBR
>>>   @item hexadecagonal
>>>   FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
>>>   @item downmix
>>> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
>>> index 21b70173b7..5af7ea0e01 100644
>>> --- a/libavutil/channel_layout.c
>>> +++ b/libavutil/channel_layout.c
>>> @@ -197,6 +197,7 @@ static const struct channel_layout_name
>>> channel_layout_map[] = {
>>>   { "7.1(wide)",  AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK   },
>>>   { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE},
>>>   { "octagonal",  AV_CHANNEL_LAYOUT_OCTAGONAL   },
>>> +{ "cube",   AV_CHANNEL_LAYOUT_CUBE},
>>>   { "hexadecagonal",  AV_CHANNEL_LAYOUT_HEXADECAGONAL   },
>>>   { "downmix",AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, },
>>>   { "22.2",   AV_CHANNEL_LAYOUT_22POINT2,   },
>>> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
>>> index 059ff70841..3e69163360 100644
>>> --- a/libavutil/channel_layout.h
>>> +++ b/libavutil/channel_layout.h
>>> @@ -233,6 +233,7 @@ enum AVChannelOrder {
>>>   #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_OCTAGONAL
>>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
>>> +#define AV_CH_LAYOUT_CUBE
>>> (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_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)
>>>   #define AV_CH_LAYOUT_22POINT2
>>> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
>>> @@ -389,6 +390,7 @@ typedef struct AVChannelLayout {
>>>   #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_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8,
>>> AV_CH_LAYOUT_OCTAGONAL)
>>> +#define AV_CHANNEL_LAYOUT_CUBE  AV_CHANNEL_LAYOUT_MASK(8,
>>> AV_CH_LAYOUT_CUBE)
>>>   #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)
>>>   #define AV_CHANNEL_LAYOUT_22POINT2  AV_CHANNEL_LAYOUT_MASK(24,
>>> AV_CH_LAYOUT_22POINT2)
>>> diff --git a/tests/ref/fate/channel_layout
>>> b/tests/ref/fate/channel_layout
>>> index 19bcbce7d8..02eaad0929 100644
>>> --- a/tests/ref/fate/channel_layout
>>> +++ b/tests/ref/fate/channel_layout
>>> @@ -25,6 +25,7 @@ hexagonal  FL+FR+FC+BL+BR+BC
>>>   7.1(wide)  FL+FR+FC+LFE+BL+BR+FLC+FRC
>>>   7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
>>>   octagonal  FL+FR+FC+BL+BR+BC+SL+SR
>>> +cube   FL+FR+BL+BR+TFL+TFR+TBL+TBR
>>>   hexadecagonal  FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR
>>>   downmixDL+DR
>>>   22.2
>>> 

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread Paul B Mahol
On 10/30/22, James Almer  wrote:
> On 10/30/2022 12:34 PM, Paul B Mahol wrote:
>> +static const struct {
>> +const int  order;
>> +const int  inputs;
>> +const int  speakers;
>> +const int  near_field;
>> +const int  type;
>> +const double   xover;
>> +const AVChannelLayout  outlayout;
>> +const double  *speakers_azimuth;
>> +const double  *speakers_elevation;
>> +const double  *speakers_distance;
>> +} ambisonic_tab[] = {
>> +[MONO] = {
>> +.order = 0,
>> +.inputs = 1,
>> +.speakers = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
>> +.speakers_azimuth = (const double[1]){ 0. },
>> +.speakers_distance = (const double[1]){ 1. },
>> +},
>> +[STEREO] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 2,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
>> +.speakers_azimuth = (const double[2]){ -30, 30},
>> +.speakers_distance = same_distance,
>> +},
>> +[STEREO_DOWNMIX] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 2,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
>> +.speakers_azimuth = (const double[2]){ -90, 90 },
>> +.speakers_distance = same_distance,
>> +},
>> +[SURROUND] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
>> +.speakers_azimuth = (const double[3]){ -45, 45, 0 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L2_1] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
>> +.speakers_azimuth = (const double[3]){ -45, 45, 180 },
>> +.speakers_distance = same_distance,
>> +},
>> +[TRIANGLE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 3,
>> +.type = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
>> +.speakers_azimuth = (const double[3]){ -120, 120, 0 },
>> +.speakers_distance = same_distance,
>> +},
>> +[QUAD] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
>> +.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
>> +.speakers_distance = same_distance,
>> +},
>> +[SQUARE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.type = 1,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
>> +.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L4_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 4,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
>> +.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L5_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 5,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
>> +.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L5_0_SIDE] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 5,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
>> +.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110 },
>> +.speakers_distance = same_distance,
>> +},
>> +[L6_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 6,
>> +.near_field = NF_NONE,
>> +.xover = 0.,
>> +.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
>> +.speakers_azimuth = (const double[6]){ -30, 30, 0, 180, -110, 110
>> },
>> +.speakers_distance = same_distance,
>> +},
>> +[L7_0] = {
>> +.order = 1,
>> +.inputs = 4,
>> +.speakers = 7,
>> +.near_field = NF_NONE,

[FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

2022-10-30 Thread Clément Bœsch
This reverts commit dea673d0d548c864ec85f9260d8900d944ef7a2a.

This change cannot work for several reasons, the most obvious ones are:

- the alpha is being part of the scoring of the color difference, even
  though we can not interpret the alpha as part of the perception of the
  color (we don't even know if it's premultiplied or postmultiplied)
- the colors are averaged with their alpha value which simply cannot
  work

The command proposed in the original thread of the patch actually
produces a completely broken file:

ffmpeg -y -loglevel verbose -i fate-suite/apng/o_sample.png -filter_complex 
"split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[pal1];[split2][pal1]paletteuse=use_alpha=1"
 -frames:v 1 out.png

We can see that many color pixels are off, but more importantly some
colors have a random alpha value: https://imgur.com/eFQ2UK7

I don't see any easy fix for this unfortunately, the approach appears to
be flawed by design.
---
 doc/filters.texi|   8 --
 libavfilter/vf_palettegen.c | 135 +++---
 libavfilter/vf_paletteuse.c | 225 +++-
 3 files changed, 138 insertions(+), 230 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index bcd19cf931..f8b78ca919 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18269,9 +18269,6 @@ Compute new histogram for each frame.
 @end table
 
 Default value is @var{full}.
-@item use_alpha
-Create a palette of colors with alpha components.
-Setting this, will automatically disable 'reserve_transparent'.
 @end table
 
 The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
@@ -18350,11 +18347,6 @@ will be treated as completely opaque, and values below 
this threshold will be
 treated as completely transparent.
 
 The option must be an integer value in the range [0,255]. Default is @var{128}.
-
-@item use_alpha
-Apply the palette by taking alpha values into account. Only useful with
-palettes that are containing multiple colors with alpha components.
-Setting this will automatically disable 'alpha_treshold'.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c
index 27f74fd147..d335ef91e6 100644
--- a/libavfilter/vf_palettegen.c
+++ b/libavfilter/vf_palettegen.c
@@ -59,7 +59,7 @@ enum {
 };
 
 #define NBITS 5
-#define HIST_SIZE (1<<(4*NBITS))
+#define HIST_SIZE (1<<(3*NBITS))
 
 typedef struct PaletteGenContext {
 const AVClass *class;
@@ -67,7 +67,6 @@ typedef struct PaletteGenContext {
 int max_colors;
 int reserve_transparent;
 int stats_mode;
-int use_alpha;
 
 AVFrame *prev_frame;// previous frame used for the 
diff stats_mode
 struct hist_node histogram[HIST_SIZE];  // histogram/hashtable of the 
colors
@@ -89,7 +88,6 @@ static const AVOption palettegen_options[] = {
 { "full", "compute full frame histograms", 0, AV_OPT_TYPE_CONST, 
{.i64=STATS_MODE_ALL_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" },
 { "diff", "compute histograms only for the part that differs from 
previous frame", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_DIFF_FRAMES}, INT_MIN, 
INT_MAX, FLAGS, "mode" },
 { "single", "compute new histogram for each frame", 0, 
AV_OPT_TYPE_CONST, {.i64=STATS_MODE_SINGLE_FRAMES}, INT_MIN, INT_MAX, FLAGS, 
"mode" },
-{ "use_alpha", "create a palette including alpha values", 
OFFSET(use_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
 { NULL }
 };
 
@@ -115,16 +113,15 @@ static int cmp_##name(const void *pa, const void *pb)   \
 {   \
 const struct color_ref * const *a = pa; \
 const struct color_ref * const *b = pb; \
-return   (int)((*a)->color >> (8 * (3 - (pos))) & 0xff)  \
-   - (int)((*b)->color >> (8 * (3 - (pos))) & 0xff); \
+return   (int)((*a)->color >> (8 * (2 - (pos))) & 0xff)  \
+   - (int)((*b)->color >> (8 * (2 - (pos))) & 0xff); \
 }
 
-DECLARE_CMP_FUNC(a, 0)
-DECLARE_CMP_FUNC(r, 1)
-DECLARE_CMP_FUNC(g, 2)
-DECLARE_CMP_FUNC(b, 3)
+DECLARE_CMP_FUNC(r, 0)
+DECLARE_CMP_FUNC(g, 1)
+DECLARE_CMP_FUNC(b, 2)
 
-static const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b};
+static const cmp_func cmp_funcs[] = {cmp_r, cmp_g, cmp_b};
 
 /**
  * Simple color comparison for sorting the final palette
@@ -146,17 +143,6 @@ static av_always_inline int diff(const uint32_t a, const 
uint32_t b)
 return dr*dr + dg*dg + db*db;
 }
 
-static av_always_inline int diff_alpha(const uint32_t a, const uint32_t b)
-{
-const uint8_t c1[] = {a >> 24 & 0xff, a >> 16 & 0xff, a >> 8 & 0xff, a & 
0xff};
-const uint8_t c2[] = {b >> 24 & 0xff, b >> 16 & 0xff, b >> 8 & 0xff, b & 
0xff};
-const int da = c1[0] - c2[0];
-const int dr = c1[1] - c2[1];
-const int dg = c1[2] - c2[2];
-const int db = c1[3] - c2[3];
-return da*da + dr*dr + dg*dg + db*db;
-}
-
 /**
  * Find the next box to split: pick the 

Re: [FFmpeg-devel] [PATCH] avutil/channel_layout: add a cube channel layout

2022-10-30 Thread James Almer




On 10/30/2022 1:19 PM, Andreas Rheinhardt wrote:

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..5aca1d1b5f 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_CUBE and AV_CHANNEL_LAYOUT_CUBE.
+
  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..907a6b87cb 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -715,6 +715,8 @@ FL+FR+FC+LFE+BL+BR+FLC+FRC
  FL+FR+FC+LFE+FLC+FRC+SL+SR
  @item octagonal
  FL+FR+FC+BL+BR+BC+SL+SR
+@item cube
+FL+FR+BL+BR+TFL+TFR+TBL+TBR
  @item hexadecagonal
  FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
  @item downmix
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 21b70173b7..5af7ea0e01 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -197,6 +197,7 @@ static const struct channel_layout_name 
channel_layout_map[] = {
  { "7.1(wide)",  AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK   },
  { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE},
  { "octagonal",  AV_CHANNEL_LAYOUT_OCTAGONAL   },
+{ "cube",   AV_CHANNEL_LAYOUT_CUBE},
  { "hexadecagonal",  AV_CHANNEL_LAYOUT_HEXADECAGONAL   },
  { "downmix",AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, },
  { "22.2",   AV_CHANNEL_LAYOUT_22POINT2,   },
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 059ff70841..3e69163360 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -233,6 +233,7 @@ enum AVChannelOrder {
  #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_OCTAGONAL 
(AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
+#define AV_CH_LAYOUT_CUBE  
(AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_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)
  #define AV_CH_LAYOUT_22POINT2  
(AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
@@ -389,6 +390,7 @@ typedef struct AVChannelLayout {
  #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_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_OCTAGONAL)
+#define AV_CHANNEL_LAYOUT_CUBE  AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_CUBE)
  #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)
  #define AV_CHANNEL_LAYOUT_22POINT2  AV_CHANNEL_LAYOUT_MASK(24, 
AV_CH_LAYOUT_22POINT2)
diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout
index 19bcbce7d8..02eaad0929 100644
--- a/tests/ref/fate/channel_layout
+++ b/tests/ref/fate/channel_layout
@@ -25,6 +25,7 @@ hexagonal  FL+FR+FC+BL+BR+BC
  7.1(wide)  FL+FR+FC+LFE+BL+BR+FLC+FRC
  7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
  octagonal  FL+FR+FC+BL+BR+BC+SL+SR
+cube   FL+FR+BL+BR+TFL+TFR+TBL+TBR
  hexadecagonal  FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR
  downmixDL+DR
  22.2   
FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR


Is this a common name or is this something you made up?


It's the same as kAudioChannelLayoutTag_Cube from AudioChannelLayoutTag 
as defined by Apple and used in mov (see MOV_CH_LAYOUT_CUBE in lavf 
mov_chan.c).




- Andreas

___

Re: [FFmpeg-devel] [PATCH] avutil/channel_layout: add a cube channel layout

2022-10-30 Thread Andreas Rheinhardt
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..5aca1d1b5f 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_CUBE and AV_CHANNEL_LAYOUT_CUBE.
> +
>  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..907a6b87cb 100644
> --- a/doc/utils.texi
> +++ b/doc/utils.texi
> @@ -715,6 +715,8 @@ FL+FR+FC+LFE+BL+BR+FLC+FRC
>  FL+FR+FC+LFE+FLC+FRC+SL+SR
>  @item octagonal
>  FL+FR+FC+BL+BR+BC+SL+SR
> +@item cube
> +FL+FR+BL+BR+TFL+TFR+TBL+TBR
>  @item hexadecagonal
>  FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
>  @item downmix
> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
> index 21b70173b7..5af7ea0e01 100644
> --- a/libavutil/channel_layout.c
> +++ b/libavutil/channel_layout.c
> @@ -197,6 +197,7 @@ static const struct channel_layout_name 
> channel_layout_map[] = {
>  { "7.1(wide)",  AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK   },
>  { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE},
>  { "octagonal",  AV_CHANNEL_LAYOUT_OCTAGONAL   },
> +{ "cube",   AV_CHANNEL_LAYOUT_CUBE},
>  { "hexadecagonal",  AV_CHANNEL_LAYOUT_HEXADECAGONAL   },
>  { "downmix",AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, },
>  { "22.2",   AV_CHANNEL_LAYOUT_22POINT2,   },
> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
> index 059ff70841..3e69163360 100644
> --- a/libavutil/channel_layout.h
> +++ b/libavutil/channel_layout.h
> @@ -233,6 +233,7 @@ enum AVChannelOrder {
>  #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_OCTAGONAL 
> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
> +#define AV_CH_LAYOUT_CUBE  
> (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_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)
>  #define AV_CH_LAYOUT_22POINT2  
> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
> @@ -389,6 +390,7 @@ typedef struct AVChannelLayout {
>  #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_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8,  
> AV_CH_LAYOUT_OCTAGONAL)
> +#define AV_CHANNEL_LAYOUT_CUBE  AV_CHANNEL_LAYOUT_MASK(8,  
> AV_CH_LAYOUT_CUBE)
>  #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)
>  #define AV_CHANNEL_LAYOUT_22POINT2  AV_CHANNEL_LAYOUT_MASK(24, 
> AV_CH_LAYOUT_22POINT2)
> diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout
> index 19bcbce7d8..02eaad0929 100644
> --- a/tests/ref/fate/channel_layout
> +++ b/tests/ref/fate/channel_layout
> @@ -25,6 +25,7 @@ hexagonal  FL+FR+FC+BL+BR+BC
>  7.1(wide)  FL+FR+FC+LFE+BL+BR+FLC+FRC
>  7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
>  octagonal  FL+FR+FC+BL+BR+BC+SL+SR
> +cube   FL+FR+BL+BR+TFL+TFR+TBL+TBR
>  hexadecagonal  FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR
>  downmixDL+DR
>  22.2   
> FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR

Is this a common name or is this something you made up?

- Andreas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH] avfilter: add ambisonic decoder filter

2022-10-30 Thread James Almer

On 10/30/2022 12:34 PM, Paul B Mahol wrote:

+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+},
+[STEREO] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+.speakers_azimuth = (const double[2]){ -30, 30},
+.speakers_distance = same_distance,
+},
+[STEREO_DOWNMIX] = {
+.order = 1,
+.inputs = 4,
+.speakers = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+.speakers_azimuth = (const double[2]){ -90, 90 },
+.speakers_distance = same_distance,
+},
+[SURROUND] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -45, 45, 0 },
+.speakers_distance = same_distance,
+},
+[L2_1] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_2_1,
+.speakers_azimuth = (const double[3]){ -45, 45, 180 },
+.speakers_distance = same_distance,
+},
+[TRIANGLE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 3,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND,
+.speakers_azimuth = (const double[3]){ -120, 120, 0 },
+.speakers_distance = same_distance,
+},
+[QUAD] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+.speakers_azimuth = (const double[4]){ -45, 45, -135, 135 },
+.speakers_distance = same_distance,
+},
+[SQUARE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ 0, -90, 180, 90 },
+.speakers_distance = same_distance,
+},
+[L4_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0,
+.speakers_azimuth = (const double[4]){ -30, 30, 0, 180 },
+.speakers_distance = same_distance,
+},
+[L5_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -145, 145 },
+.speakers_distance = same_distance,
+},
+[L5_0_SIDE] = {
+.order = 1,
+.inputs = 4,
+.speakers = 5,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0,
+.speakers_azimuth = (const double[5]){ -30, 30, 0, -110, 110 },
+.speakers_distance = same_distance,
+},
+[L6_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 6,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0,
+.speakers_azimuth = (const double[6]){ -30, 30, 0, 180, -110, 110 },
+.speakers_distance = same_distance,
+},
+[L7_0] = {
+.order = 1,
+.inputs = 4,
+.speakers = 7,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0,
+.speakers_azimuth = (const double[7]){ -30, 30, 0, -145, 145, -110, 
110 },
+.speakers_distance = same_distance,
+},
+[TETRA] = {
+.order = 1,
+.inputs = 4,
+.speakers = 4,
+.type = 2,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD,
+ 

[FFmpeg-devel] [PATCH] avutil/channel_layout: add a cube channel layout

2022-10-30 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..5aca1d1b5f 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_CUBE and AV_CHANNEL_LAYOUT_CUBE.
+
 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..907a6b87cb 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -715,6 +715,8 @@ FL+FR+FC+LFE+BL+BR+FLC+FRC
 FL+FR+FC+LFE+FLC+FRC+SL+SR
 @item octagonal
 FL+FR+FC+BL+BR+BC+SL+SR
+@item cube
+FL+FR+BL+BR+TFL+TFR+TBL+TBR
 @item hexadecagonal
 FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
 @item downmix
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 21b70173b7..5af7ea0e01 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -197,6 +197,7 @@ static const struct channel_layout_name 
channel_layout_map[] = {
 { "7.1(wide)",  AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK   },
 { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE},
 { "octagonal",  AV_CHANNEL_LAYOUT_OCTAGONAL   },
+{ "cube",   AV_CHANNEL_LAYOUT_CUBE},
 { "hexadecagonal",  AV_CHANNEL_LAYOUT_HEXADECAGONAL   },
 { "downmix",AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, },
 { "22.2",   AV_CHANNEL_LAYOUT_22POINT2,   },
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 059ff70841..3e69163360 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -233,6 +233,7 @@ enum AVChannelOrder {
 #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_OCTAGONAL 
(AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
+#define AV_CH_LAYOUT_CUBE  
(AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_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)
 #define AV_CH_LAYOUT_22POINT2  
(AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
@@ -389,6 +390,7 @@ typedef struct AVChannelLayout {
 #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_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_OCTAGONAL)
+#define AV_CHANNEL_LAYOUT_CUBE  AV_CHANNEL_LAYOUT_MASK(8,  
AV_CH_LAYOUT_CUBE)
 #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)
 #define AV_CHANNEL_LAYOUT_22POINT2  AV_CHANNEL_LAYOUT_MASK(24, 
AV_CH_LAYOUT_22POINT2)
diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout
index 19bcbce7d8..02eaad0929 100644
--- a/tests/ref/fate/channel_layout
+++ b/tests/ref/fate/channel_layout
@@ -25,6 +25,7 @@ hexagonal  FL+FR+FC+BL+BR+BC
 7.1(wide)  FL+FR+FC+LFE+BL+BR+FLC+FRC
 7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
 octagonal  FL+FR+FC+BL+BR+BC+SL+SR
+cube   FL+FR+BL+BR+TFL+TFR+TBL+TBR
 hexadecagonal  FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR
 downmixDL+DR
 22.2   
FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR
-- 
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] avfilter: add ambisonic decoder filter

2022-10-30 Thread Paul B Mahol
Patch attached.
From 1b0e75a995dfdb45e514b8ff5b7077adaaed65a1 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Thu, 11 Jan 2018 21:32:22 +0100
Subject: [PATCH] avfilter: add ambisonic decoder

Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile   |1 +
 libavfilter/af_ambisonic.c | 2332 
 libavfilter/allfilters.c   |1 +
 3 files changed, 2334 insertions(+)
 create mode 100644 libavfilter/af_ambisonic.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ace0e60ba1..0e971d5c3e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -69,6 +69,7 @@ OBJS-$(CONFIG_ALATENCY_FILTER)   += f_latency.o
 OBJS-$(CONFIG_ALIMITER_FILTER)   += af_alimiter.o
 OBJS-$(CONFIG_ALLPASS_FILTER)+= af_biquads.o
 OBJS-$(CONFIG_ALOOP_FILTER)  += f_loop.o
+OBJS-$(CONFIG_AMBISONIC_FILTER)  += af_ambisonic.o
 OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o
 OBJS-$(CONFIG_AMETADATA_FILTER)  += f_metadata.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
diff --git a/libavfilter/af_ambisonic.c b/libavfilter/af_ambisonic.c
new file mode 100644
index 00..56baebd365
--- /dev/null
+++ b/libavfilter/af_ambisonic.c
@@ -0,0 +1,2332 @@
+/*
+ * Copyright (c) 2022 Paul B Mahol
+ * Copyright (c) 2017 Sanchit Sinha
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/float_dsp.h"
+#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+#define EVEN 0
+#define ODD 1
+#define MAX_ORDER 3
+#define SQR(x) ((x) * (x))
+#define MAX_CHANNELS SQR(MAX_ORDER + 1)
+
+enum A_NAME {
+A_W, A_Y, A_Z, A_X, A_V, A_T, A_R, A_S, A_U, A_Q, A_O, A_M, A_K, A_L, A_N, A_P,
+};
+
+enum NearFieldType {
+NF_AUTO = -1,
+NF_NONE,
+NF_IN,
+NF_OUT,
+NB_NFTYPES,
+};
+
+enum PrecisionType {
+P_AUTO = -1,
+P_SINGLE,
+P_DOUBLE,
+NB_PTYPES,
+};
+
+enum PTypes {
+PT_AMP,
+PT_RMS,
+PT_ENERGY,
+PT_NBTYPES,
+};
+
+enum NormType {
+N3D,
+SN3D,
+FUMA,
+NB_NTYPES,
+};
+
+enum DirectionType {
+D_X,
+D_Y,
+D_Z,
+D_C,
+NB_DTYPES,
+};
+
+enum SequenceType {
+M_ACN,
+M_FUMA,
+M_SID,
+NB_MTYPES,
+};
+
+enum Layouts {
+MONO,
+STEREO,
+STEREO_DOWNMIX,
+SURROUND,
+L2_1,
+TRIANGLE,
+QUAD,
+SQUARE,
+L4_0,
+L5_0,
+L5_0_SIDE,
+L6_0,
+L7_0,
+TETRA,
+CUBE,
+NB_LAYOUTS,
+};
+
+typedef struct NearField {
+double d[MAX_ORDER];
+double z[MAX_ORDER];
+} NearField;
+
+typedef struct Xover {
+double b[3];
+double a[3];
+double w[2];
+} Xover;
+
+static const double gains_2d[][4] =
+{
+{ 1 },
+{ 1, 0.707107 },
+{ 1, 0.866025, 0.5 },
+{ 1, 0.92388, 0.707107, 0.382683 },
+};
+
+static const double gains_3d[][4] =
+{
+{ 1 },
+{ 1, 0.57735027 },
+{ 1, 0.774597, 0.4 },
+{ 1, 0.861136, 0.612334, 0.304747 },
+};
+
+static const double same_distance[] =
+{
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+};
+
+static const double cube_azimuth[] =
+{
+315, 45, 135, 225, 315, 45, 135, 225,
+};
+
+static const double cube_elevation[] =
+{
+ 35.26439,  35.26439,  35.26439,  35.26439,
+-35.26439, -35.26439, -35.26439, -35.26439
+};
+
+static const struct {
+const int  order;
+const int  inputs;
+const int  speakers;
+const int  near_field;
+const int  type;
+const double   xover;
+const AVChannelLayout  outlayout;
+const double  *speakers_azimuth;
+const double  *speakers_elevation;
+const double  *speakers_distance;
+} ambisonic_tab[] = {
+[MONO] = {
+.order = 0,
+.inputs = 1,
+.speakers = 1,
+.near_field = NF_NONE,
+.xover = 0.,
+.outlayout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO,
+.speakers_azimuth = (const double[1]){ 0. },
+.speakers_distance = (const double[1]){ 1. },
+   

[FFmpeg-devel] [PATCH] avfilter: add backgroundkey video filter

2022-10-30 Thread Paul B Mahol
Patch attached.
From 72aebb5d79d60d267def506092e13b0d35c4df3d Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Fri, 28 Oct 2022 22:02:29 +0200
Subject: [PATCH] avfilter: add backgroundkey video filter

Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_backgroundkey.c | 218 +
 3 files changed, 220 insertions(+)
 create mode 100644 libavfilter/vf_backgroundkey.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ff2a06c262..ace0e60ba1 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -191,6 +191,7 @@ OBJS-$(CONFIG_AVGBLUR_FILTER)+= vf_avgblur.o
 OBJS-$(CONFIG_AVGBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \
 opencl/avgblur.o boxblur.o
 OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vf_avgblur_vulkan.o vulkan.o vulkan_filter.o
+OBJS-$(CONFIG_BACKGROUNDKEY_FILTER)  += vf_backgroundkey.o
 OBJS-$(CONFIG_BBOX_FILTER)   += bbox.o vf_bbox.o
 OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BILATERAL_FILTER)  += vf_bilateral.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 119de40b25..e0598e9986 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -177,6 +177,7 @@ extern const AVFilter ff_vf_atadenoise;
 extern const AVFilter ff_vf_avgblur;
 extern const AVFilter ff_vf_avgblur_opencl;
 extern const AVFilter ff_vf_avgblur_vulkan;
+extern const AVFilter ff_vf_backgroundkey;
 extern const AVFilter ff_vf_bbox;
 extern const AVFilter ff_vf_bench;
 extern const AVFilter ff_vf_bilateral;
diff --git a/libavfilter/vf_backgroundkey.c b/libavfilter/vf_backgroundkey.c
new file mode 100644
index 00..7502ee79b2
--- /dev/null
+++ b/libavfilter/vf_backgroundkey.c
@@ -0,0 +1,218 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/intreadwrite.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct BackgroundkeyContext {
+const AVClass *class;
+
+float similarity;
+float blend;
+int max;
+
+int hsub_log2;
+int vsub_log2;
+
+AVFrame *background;
+
+int (*do_slice)(AVFilterContext *avctx, void *arg,
+int jobnr, int nb_jobs);
+} BackgroundkeyContext;
+
+static int do_backgroundkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
+{
+BackgroundkeyContext *s = avctx->priv;
+AVFrame *frame = arg;
+const int slice_start = (frame->height * jobnr) / nb_jobs;
+const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs;
+const int min_diff = s->max * s->similarity;
+const int hsub = s->hsub_log2;
+const int vsub = s->vsub_log2;
+const float blend = s->blend;
+
+for (int y = slice_start; y < slice_end; y++) {
+const uint8_t *srcy = frame->data[0] + frame->linesize[0] * y;
+const uint8_t *srcu = frame->data[1] + frame->linesize[1] * (y >> vsub);
+const uint8_t *srcv = frame->data[2] + frame->linesize[2] * (y >> vsub);
+const uint8_t *bsrcy = s->background->data[0] + s->background->linesize[0] * y;
+const uint8_t *bsrcu = s->background->data[1] + s->background->linesize[1] * (y >> vsub);
+const uint8_t *bsrcv = s->background->data[2] + s->background->linesize[2] * (y >> vsub);
+uint8_t *dst = frame->data[3] + frame->linesize[3] * y;
+for (int x = 0; x < frame->width; x++) {
+const int xx = x >> hsub;
+const int diff = FFABS(srcy[x]  - bsrcy[x]) +
+ FFABS(srcu[xx] - bsrcu[xx]) +
+ FFABS(srcv[xx] - bsrcv[xx]);
+int A;
+
+if (diff > min_diff) {
+A = 255;
+} else if (blend > 0.f) {
+A = FFMIN(255, (min_diff - diff) * blend * 255);
+} else {
+A = 0;
+}
+
+dst[x] = A;
+}
+}
+
+return 0;
+}
+
+static int do_backgroundkey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
+{
+

Re: [FFmpeg-devel] [PATCH] avcodec/libsvtav1: Add support for multipass encoding

2022-10-30 Thread Lynne
Sep 27, 2022, 23:06 by gustav.grus...@gmail.com:

> Implements support for 2-pass CRF and 3-pass VBR by implementing
> reading and writing of stats file, and passing the pass number on
> to the encoder. For 3-pass VBR, the first pass should be run with
> '-pass 1', the second with '-pass 3' and the third with '-pass 2'.
>
> Signed-off-by: Gustav Grusell 
> ---
>  libavcodec/libsvtav1.c | 82 ++
>  1 file changed, 82 insertions(+)
>
> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
> index 2f5634cee0..73fece49b7 100644
> --- a/libavcodec/libsvtav1.c
> +++ b/libavcodec/libsvtav1.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  
> +#include "libavutil/base64.h"
>  #include "libavutil/common.h"
>  #include "libavutil/frame.h"
>  #include "libavutil/imgutils.h"
> @@ -312,6 +313,22 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> *param,
>  cpb_props->avg_bitrate = avctx->bit_rate;
>  }
>  
> +if (avctx->flags & AV_CODEC_FLAG_PASS2) {
> +if (param->rate_control_mode == SVT_AV1_RC_MODE_VBR) {
> +if (avctx->flags & AV_CODEC_FLAG_PASS1) {
> +param->pass = 2;
> +} else {
> +param->pass = 3;
> +}
> +} else {
> +param->pass = 2;
> +}
> +} else if (avctx->flags & AV_CODEC_FLAG_PASS1) {
> +param->pass = 1;
> +} else {
> +param->pass = 0;
> +}
> +
>  return 0;
>  }
>  
> @@ -371,6 +388,34 @@ static av_cold int eb_enc_init(AVCodecContext *avctx)
>  return ret;
>  }
>  
> +if (svt_enc->enc_params.pass >= 2) {
> +int decode_size;
> +
> +if (!avctx->stats_in) {
> +av_log(avctx, AV_LOG_ERROR, "No stats file for %s pass\n",
> +   svt_enc->enc_params.pass == 2 ? "second" : "third");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +svt_enc->enc_params.rc_stats_buffer.sz = strlen(avctx->stats_in) * 3 
> / 4;
> +svt_enc->enc_params.rc_stats_buffer.buf = 
> av_malloc(svt_enc->enc_params.rc_stats_buffer.sz);
> +if (!svt_enc->enc_params.rc_stats_buffer.buf) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
> +   svt_enc->enc_params.rc_stats_buffer.sz);
> +svt_enc->enc_params.rc_stats_buffer.sz = 0;
> +return AVERROR(ENOMEM);
> +}
> +decode_size = 
> av_base64_decode(svt_enc->enc_params.rc_stats_buffer.buf, avctx->stats_in,
> +   
> svt_enc->enc_params.rc_stats_buffer.sz);
> +if (decode_size < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +svt_enc->enc_params.rc_stats_buffer.sz = decode_size;
> +}
> +
>  svt_ret = svt_av1_enc_set_parameter(svt_enc->svt_handle, 
> _enc->enc_params);
>  if (svt_ret != EB_ErrorNone) {
>  return svt_print_error(avctx, svt_ret, "Error setting encoder parameters");
> @@ -544,6 +589,38 @@ static int eb_receive_packet(AVCodecContext *avctx, 
> AVPacket *pkt)
>  if (headerPtr->flags & EB_BUFFERFLAG_EOS)
>  svt_enc->eos_flag = EOS_RECEIVED;
>  
> +if (svt_enc->eos_flag == EOS_RECEIVED) {
> +if (svt_enc->enc_params.pass == 1) {
> +SvtAv1FixedBuf first_pass_stat;
> +EbErrorTyperet = svt_av1_enc_get_stream_info(
> +svt_enc->svt_handle,
> +SVT_AV1_STREAM_INFO_FIRST_PASS_STATS_OUT,
> +_pass_stat);
> +if (ret == EB_ErrorNone) {
> +size_t b64_size = AV_BASE64_SIZE(first_pass_stat.sz);
> +avctx->stats_out = av_malloc(b64_size);
> +if (!avctx->stats_out) {
> +av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc 
> (%"SIZE_SPECIFIER" bytes) failed\n",
> +   b64_size);
> +return AVERROR(ENOMEM);
> +}
> +av_base64_encode(avctx->stats_out, b64_size, 
> first_pass_stat.buf,
> + first_pass_stat.sz);
> +}
> +}
> +if (svt_enc->enc_params.pass == 2) {
> +size_t b64_size = 
> AV_BASE64_SIZE(svt_enc->enc_params.rc_stats_buffer.sz);
> +avctx->stats_out = av_malloc(b64_size);
> +if (!avctx->stats_out) {
> +av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc 
> (%"SIZE_SPECIFIER" bytes) failed\n",
> +   b64_size);
> +return AVERROR(ENOMEM);
> +}
> +av_base64_encode(avctx->stats_out, b64_size, 
> svt_enc->enc_params.rc_stats_buffer.buf,
> + svt_enc->enc_params.rc_stats_buffer.sz);
> +}
> +}
> +
>  ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, 
> pict_type);
>  
>  svt_av1_enc_release_out_buffer();
> @@ -564,6 

[FFmpeg-devel] fix for avcodec/dvdsub_parser

2022-10-30 Thread Aidan MacDonald


Hi,

I was wondering if anyone has picked up this fix for DVD subtitles:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220930142009.5862-1-aidanmacdonald@gmail.com/

Regards,
Aidan
___
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/6] avcodec/mpegvideodata: Make DC scale tables smaller

2022-10-30 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> These tables are only accessed in ff_set_qscale()
> which only accesses values 1..31 as well as in
> encode_picture() in mpegvideo_enc.c, accessing
> the value with index 8. So make these tables smaller.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mpegvideodata.c | 32 
>  libavcodec/mpegvideodata.h |  2 +-
>  2 files changed, 5 insertions(+), 29 deletions(-)
> 
> diff --git a/libavcodec/mpegvideodata.c b/libavcodec/mpegvideodata.c
> index da0638e052..b98e90cf43 100644
> --- a/libavcodec/mpegvideodata.c
> +++ b/libavcodec/mpegvideodata.c
> @@ -30,46 +30,22 @@ const uint8_t ff_mpeg2_non_linear_qscale[32] = {
>  56, 64, 72, 80, 88, 96, 104, 112,
>  };
>  
> -const uint8_t ff_mpeg1_dc_scale_table[128] = {
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> -8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
> +const uint8_t ff_mpeg1_dc_scale_table[32] = {
>  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
>  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
>  };
>  
> -static const uint8_t mpeg2_dc_scale_table1[128] = {
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> -4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> +static const uint8_t mpeg2_dc_scale_table1[32] = {
>  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
>  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
>  };
>  
> -static const uint8_t mpeg2_dc_scale_table2[128] = {
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> +static const uint8_t mpeg2_dc_scale_table2[32] = {
>  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
>  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
>  };
>  
> -static const uint8_t mpeg2_dc_scale_table3[128] = {
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> +static const uint8_t mpeg2_dc_scale_table3[32] = {
>  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
>  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
>  };
> diff --git a/libavcodec/mpegvideodata.h b/libavcodec/mpegvideodata.h
> index 14f4806d66..cf783ef31c 100644
> --- a/libavcodec/mpegvideodata.h
> +++ b/libavcodec/mpegvideodata.h
> @@ -25,7 +25,7 @@
>  extern const uint8_t ff_alternate_horizontal_scan[64];
>  extern const uint8_t ff_alternate_vertical_scan[64];
>  
> -extern const uint8_t ff_mpeg1_dc_scale_table[128];
> +extern const uint8_t ff_mpeg1_dc_scale_table[32];
>  extern const uint8_t * const ff_mpeg2_dc_scale_table[4];
>  
>  extern const uint8_t ff_mpeg2_non_linear_qscale[32];

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] [PATCHv3 1/4] avcodec/svq1enc: do not use ambiguous interframe mean symbols

2022-10-30 Thread Peter Ross
On Tue, Oct 25, 2022 at 08:17:04PM +1100, Peter Ross wrote:
> Don't emit interframe mean symbols -128 and 128.
> ---
> 
> v3 patch set changes:
> - reordered patchset
> - add stds fields around extradata codec ident
> - use Lavc codec ident when operating in bitexact mode
> 
>  libavcodec/svq1enc.c  |  5 +
>  tests/ref/seek/vsynth_lena-svq1   | 28 ++--
>  tests/ref/vsynth/vsynth1-svq1 |  8 
>  tests/ref/vsynth/vsynth2-svq1 |  6 +++---
>  tests/ref/vsynth/vsynth3-svq1 |  6 +++---
>  tests/ref/vsynth/vsynth_lena-svq1 |  6 +++---
>  6 files changed, 32 insertions(+), 27 deletions(-)
> 
> diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
> index 75adbe7ea0..9bd5a04368 100644
> --- a/libavcodec/svq1enc.c
> +++ b/libavcodec/svq1enc.c

will push in a couple of days

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: use CPL start timecode if available

2022-10-30 Thread Zane van Iperen

lgtm, will apply in a few days if no objections


On 29/10/22 00:55, Pierre-Anthony Lemieux wrote:

Hi Zane et al.,

Quick ping on the revised patchset below.

It addresses https://trac.ffmpeg.org/ticket/9842.

Best,

-- Pierre

On Sun, Oct 2, 2022 at 9:28 AM  wrote:


From: Pierre-Anthony Lemieux 

The IMF CPL contains an optional timecode start address. This patch reads the
latter, if present, into the context's timecode metadata parameter.
This addresses https://trac.ffmpeg.org/ticket/9842.

---
  libavformat/imf.h |   2 +
  libavformat/imf_cpl.c | 106 ++
  libavformat/imfdec.c  |  11 +
  3 files changed, 119 insertions(+)

diff --git a/libavformat/imf.h b/libavformat/imf.h
index 4271cd9582..70ed007312 100644
--- a/libavformat/imf.h
+++ b/libavformat/imf.h
@@ -59,6 +59,7 @@
  #include "libavformat/avio.h"
  #include "libavutil/rational.h"
  #include "libavutil/uuid.h"
+#include "libavutil/timecode.h"
  #include 

  /**
@@ -130,6 +131,7 @@ typedef struct FFIMFCPL {
  AVUUID id_uuid;   /**< CompositionPlaylist/Id 
element */
  xmlChar *content_title_utf8; /**< 
CompositionPlaylist/ContentTitle element */
  AVRational edit_rate;/**< 
CompositionPlaylist/EditRate element */
+AVTimecode *tc;  /**< 
CompositionPlaylist/CompositionTimecode element */
  FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual 
Track */
  FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual 
Track */
  uint32_t main_audio_track_count; /**< Number of Main 
Audio Virtual Tracks */
diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
index 474db6b7f5..183e6dd84e 100644
--- a/libavformat/imf_cpl.c
+++ b/libavformat/imf_cpl.c
@@ -116,6 +116,22 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t 
*number)
  return ret;
  }

+static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value)
+{
+int ret = 0;
+
+xmlChar *element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") 
== 0)
+*value = 1;
+else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, 
"0") == 0)
+*value = 0;
+else
+ret = 1;
+xmlFree(element_text);
+
+return ret;
+}
+
  static void imf_base_virtual_track_init(FFIMFBaseVirtualTrack *track)
  {
  memset(track->id_uuid, 0, sizeof(track->id_uuid));
@@ -179,6 +195,90 @@ static int fill_content_title(xmlNodePtr cpl_element, 
FFIMFCPL *cpl)
  return 0;
  }

+static int digit_to_int(char digit)
+{
+if (digit >= '0' && digit <= '9')
+return digit - '0';
+return -1;
+}
+
+/**
+ * Parses a string that conform to the TimecodeType used in IMF CPL and defined
+ * in SMPTE ST 2067-3.
+ * @param[in] s string to parse
+ * @param[out] tc_comps pointer to an array of 4 integers where the parsed HH,
+ *  MM, SS and FF fields of the timecode are returned.
+ * @return 0 on success, < 0 AVERROR code on error.
+ */
+static int parse_cpl_tc_type(const char *s, int *tc_comps)
+{
+if (av_strnlen(s, 11) != 11)
+return AVERROR(EINVAL);
+
+for (int i = 0; i < 4; i++) {
+int hi;
+int lo;
+
+hi = digit_to_int(s[i * 3]);
+lo = digit_to_int(s[i * 3 + 1]);
+
+if (hi == -1 || lo == -1)
+return AVERROR(EINVAL);
+
+tc_comps[i] = 10 * hi + lo;
+}
+
+return 0;
+}
+
+static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl)
+{
+xmlNodePtr tc_element = NULL;
+xmlNodePtr element = NULL;
+xmlChar *tc_str = NULL;
+int df = 0;
+int comps[4];
+int ret = 0;
+
+tc_element = ff_imf_xml_get_child_element_by_name(cpl_element, 
"CompositionTimecode");
+if (!tc_element)
+   return 0;
+
+element = ff_imf_xml_get_child_element_by_name(tc_element, 
"TimecodeDropFrame");
+if (!element) {
+av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
+a TimecodeDropFrame child element\n");
+return AVERROR_INVALIDDATA;
+}
+
+if (ff_imf_xml_read_boolean(element, )) {
+av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n");
+return AVERROR_INVALIDDATA;
+}
+element = ff_imf_xml_get_child_element_by_name(tc_element, 
"TimecodeStartAddress");
+if (!element) {
+av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
+a TimecodeStartAddress child element\n");
+return AVERROR_INVALIDDATA;
+}
+
+tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
+ret = parse_cpl_tc_type(tc_str, comps);
+xmlFree(tc_str);
+if (ret)
+return ret;
+
+cpl->tc = av_malloc(sizeof(AVTimecode));
+