[FFmpeg-cvslog] avcodec/mpeg12enc: Reindentation

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 24 14:43:46 2020 +0100| [3de3d2f5e24985bfd53b9b85122079a98816e259] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Reindentation

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg12enc.c | 114 -
 1 file changed, 55 insertions(+), 59 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index b069f2db64..2466db8a91 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1037,74 +1037,70 @@ void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t 
block[8][64],
 
 static av_cold void mpeg12_encode_init_static(void)
 {
-int f_code;
-int mv;
-int i;
+ff_rl_init(_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
+ff_rl_init(_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
-ff_rl_init(_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
-ff_rl_init(_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
+for (int i = 0; i < 64; i++) {
+mpeg1_max_level[0][i] = ff_rl_mpeg1.max_level[0][i];
+mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
+}
 
-for (i = 0; i < 64; i++) {
-mpeg1_max_level[0][i] = ff_rl_mpeg1.max_level[0][i];
-mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
-}
+init_uni_ac_vlc(_rl_mpeg1, uni_mpeg1_ac_vlc_len);
+init_uni_ac_vlc(_rl_mpeg2, uni_mpeg2_ac_vlc_len);
 
-init_uni_ac_vlc(_rl_mpeg1, uni_mpeg1_ac_vlc_len);
-init_uni_ac_vlc(_rl_mpeg2, uni_mpeg2_ac_vlc_len);
-
-/* build unified dc encoding tables */
-for (i = -255; i < 256; i++) {
-int adiff, index;
-int bits, code;
-int diff = i;
-
-adiff = FFABS(diff);
-if (diff < 0)
-diff--;
-index = av_log2(2 * adiff);
-
-bits = ff_mpeg12_vlc_dc_lum_bits[index] + index;
-code = (ff_mpeg12_vlc_dc_lum_code[index] << index) +
-av_mod_uintp2(diff, index);
-mpeg1_lum_dc_uni[i + 255] = bits + (code << 8);
-
-bits = ff_mpeg12_vlc_dc_chroma_bits[index] + index;
-code = (ff_mpeg12_vlc_dc_chroma_code[index] << index) +
-av_mod_uintp2(diff, index);
-mpeg1_chr_dc_uni[i + 255] = bits + (code << 8);
-}
+/* build unified dc encoding tables */
+for (int i = -255; i < 256; i++) {
+int adiff, index;
+int bits, code;
+int diff = i;
 
-for (f_code = 1; f_code <= MAX_FCODE; f_code++)
-for (mv = -MAX_DMV; mv <= MAX_DMV; mv++) {
-int len;
+adiff = FFABS(diff);
+if (diff < 0)
+diff--;
+index = av_log2(2 * adiff);
 
-if (mv == 0) {
-len = ff_mpeg12_mbMotionVectorTable[0][1];
-} else {
-int val, bit_size, code;
-
-bit_size = f_code - 1;
-
-val = mv;
-if (val < 0)
-val = -val;
-val--;
-code = (val >> bit_size) + 1;
-if (code < 17)
-len = ff_mpeg12_mbMotionVectorTable[code][1] +
-  1 + bit_size;
-else
-len = ff_mpeg12_mbMotionVectorTable[16][1] +
-  2 + bit_size;
-}
+bits = ff_mpeg12_vlc_dc_lum_bits[index] + index;
+code = (ff_mpeg12_vlc_dc_lum_code[index] << index) +
+   av_mod_uintp2(diff, index);
+mpeg1_lum_dc_uni[i + 255] = bits + (code << 8);
 
-mv_penalty[f_code][mv + MAX_DMV] = len;
+bits = ff_mpeg12_vlc_dc_chroma_bits[index] + index;
+code = (ff_mpeg12_vlc_dc_chroma_code[index] << index) +
+   av_mod_uintp2(diff, index);
+mpeg1_chr_dc_uni[i + 255] = bits + (code << 8);
+}
+
+for (int f_code = 1; f_code <= MAX_FCODE; f_code++)
+for (int mv = -MAX_DMV; mv <= MAX_DMV; mv++) {
+int len;
+
+if (mv == 0) {
+len = ff_mpeg12_mbMotionVectorTable[0][1];
+} else {
+int val, bit_size, code;
+
+bit_size = f_code - 1;
+
+val = mv;
+if (val < 0)
+val = -val;
+val--;
+code = (val >> bit_size) + 1;
+if (code < 17)
+len = ff_mpeg12_mbMotionVectorTable[code][1] +
+  1 + bit_size;
+else
+len = ff_mpeg12_mbMotionVectorTable[16][1] +
+  2 + bit_size;
 }
 
+mv_penalty[f_code][mv + MAX_DMV] = len;
+}
+
 
-for (f_code = MAX_FCODE; 

[FFmpeg-cvslog] avcodec/mpeg12enc: Use ff_thread_once() for static initializations

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 24 14:39:47 2020 +0100| [bf5bfcdbd373ad44fed87ddbd7ee8f6c9ee1217a] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Use ff_thread_once() for static initializations

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpeg12enc.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index eee4af0adc..b069f2db64 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -31,6 +31,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/thread.h"
 #include "libavutil/timecode.h"
 #include "libavutil/stereo3d.h"
 
@@ -1034,18 +1035,12 @@ void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t 
block[8][64],
 mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 8);
 }
 
-av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
+static av_cold void mpeg12_encode_init_static(void)
 {
-static int done = 0;
-
-ff_mpeg12_common_init(s);
-
-if (!done) {
 int f_code;
 int mv;
 int i;
 
-done = 1;
 ff_rl_init(_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
 ff_rl_init(_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
@@ -1110,7 +1105,14 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 for (f_code = MAX_FCODE; f_code > 0; f_code--)
 for (mv = -(8 << f_code); mv < (8 << f_code); mv++)
 fcode_tab[mv + MAX_MV] = f_code;
-}
+}
+
+av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+
+ff_mpeg12_common_init(s);
+
 s->me.mv_penalty = mv_penalty;
 s->fcode_tab = fcode_tab;
 if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
@@ -1129,6 +1131,8 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 }
 s->inter_ac_vlc_length  =
 s->inter_ac_vlc_last_length = uni_mpeg1_ac_vlc_len;
+
+ff_thread_once(_static_once, mpeg12_encode_init_static);
 }
 
 #define OFFSET(x) offsetof(MpegEncContext, x)

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

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

[FFmpeg-cvslog] avcodec/mpeg12enc: Always initialize MPEG-2 intra VLC table lengths

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 24 13:29:29 2020 +0100| [ef3c1670d488d1cffc98115a5e67b07ee921e47d] | 
committer: Andreas Rheinhardt

avcodec/mpeg12enc: Always initialize MPEG-2 intra VLC table lengths

The MPEG-1/2 encoders initialize several tables once during the first
time one of the encoders is initialized; the table for MPEG-2 intra VLC
lengths is only initialized if it is used for this encoder instance.
This implies that if the first MPEG-1/2 encoder to be initialized does
not use it, it will never be initialized even if a later encoder
instance makes use of them. Fix this by initializing this table
unconditionally.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 46c3424de9..eee4af0adc 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1055,7 +1055,6 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 }
 
 init_uni_ac_vlc(_rl_mpeg1, uni_mpeg1_ac_vlc_len);
-if (s->intra_vlc_format)
 init_uni_ac_vlc(_rl_mpeg2, uni_mpeg2_ac_vlc_len);
 
 /* build unified dc encoding tables */

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

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

[FFmpeg-cvslog] avfilter/vf_readeia608: add support for slice threads

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 22:14:14 
2020 +0100| [278984b3430727c850de4b67cdde248be6d99ae1] | committer: Paul B Mahol

avfilter/vf_readeia608: add support for slice threads

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

 libavfilter/vf_readeia608.c | 236 ++--
 1 file changed, 161 insertions(+), 75 deletions(-)

diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c
index 39c4703b66..bd0a950a26 100644
--- a/libavfilter/vf_readeia608.c
+++ b/libavfilter/vf_readeia608.c
@@ -57,20 +57,28 @@ typedef struct CodeItem {
 int size;
 } CodeItem;
 
+typedef struct ScanItem {
+int nb_line;
+int found;
+int white;
+int black;
+uint64_t histogram[256];
+uint8_t byte[2];
+
+CodeItem *code;
+LineItem *line;
+} ScanItem;
+
 typedef struct ReadEIA608Context {
 const AVClass *class;
+
 int start, end;
-int nb_found;
-int white;
-int black;
 float spw;
 int chp;
 int lp;
 
-uint64_t histogram[256];
-
-CodeItem *code;
-LineItem *line;
+int nb_allocated;
+ScanItem *scan;
 } ReadEIA608Context;
 
 #define OFFSET(x) offsetof(ReadEIA608Context, x)
@@ -105,53 +113,80 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, formats);
 }
 
-static int config_input(AVFilterLink *inlink)
+static int config_filter(AVFilterContext *ctx, int start, int end)
 {
-AVFilterContext *ctx = inlink->dst;
 ReadEIA608Context *s = ctx->priv;
+AVFilterLink *inlink = ctx->inputs[0];
 int size = inlink->w + LAG;
 
-if (s->end >= inlink->h) {
+if (end >= inlink->h) {
 av_log(ctx, AV_LOG_WARNING, "Last line to scan too large, 
clipping.\n");
-s->end = inlink->h - 1;
+end = inlink->h - 1;
 }
 
-if (s->start > s->end) {
+if (start > end) {
 av_log(ctx, AV_LOG_ERROR, "Invalid range.\n");
 return AVERROR(EINVAL);
 }
 
-s->line = av_calloc(size, sizeof(*s->line));
-s->code = av_calloc(size, sizeof(*s->code));
-if (!s->line || !s->code)
-return AVERROR(ENOMEM);
+if (s->nb_allocated < end - start + 1) {
+const int diff = end - start + 1 - s->nb_allocated;
+
+s->scan = av_realloc_f(s->scan, end - start + 1, sizeof(*s->scan));
+if (!s->scan)
+return AVERROR(ENOMEM);
+memset(>scan[s->nb_allocated], 0, diff * sizeof(*s->scan));
+s->nb_allocated = end - start + 1;
+}
+
+for (int i = 0; i < s->nb_allocated; i++) {
+ScanItem *scan = >scan[i];
+
+if (!scan->line)
+scan->line = av_calloc(size, sizeof(*scan->line));
+if (!scan->code)
+scan->code = av_calloc(size, sizeof(*scan->code));
+if (!scan->line || !scan->code)
+return AVERROR(ENOMEM);
+}
+
+s->start = start;
+s->end = end;
 
 return 0;
 }
 
-static void build_histogram(ReadEIA608Context *s, const LineItem *line, int 
len)
+static int config_input(AVFilterLink *inlink)
 {
-memset(s->histogram, 0, sizeof(s->histogram));
+AVFilterContext *ctx = inlink->dst;
+ReadEIA608Context *s = ctx->priv;
+
+return config_filter(ctx, s->start, s->end);
+}
+
+static void build_histogram(ReadEIA608Context *s, ScanItem *scan, const 
LineItem *line, int len)
+{
+memset(scan->histogram, 0, sizeof(scan->histogram));
 
 for (int i = LAG; i < len + LAG; i++)
-s->histogram[line[i].input]++;
+scan->histogram[line[i].input]++;
 }
 
-static void find_black_and_white(ReadEIA608Context *s)
+static void find_black_and_white(ReadEIA608Context *s, ScanItem *scan)
 {
 int start = 0, end = 0, middle;
 int black = 0, white = 0;
 int cnt;
 
 for (int i = 0; i < 256; i++) {
-if (s->histogram[i]) {
+if (scan->histogram[i]) {
 start = i;
 break;
 }
 }
 
 for (int i = 255; i >= 0; i--) {
-if (s->histogram[i]) {
+if (scan->histogram[i]) {
 end = i;
 break;
 }
@@ -161,22 +196,22 @@ static void find_black_and_white(ReadEIA608Context *s)
 
 cnt = 0;
 for (int i = start; i <= middle; i++) {
-if (s->histogram[i] > cnt) {
-cnt = s->histogram[i];
+if (scan->histogram[i] > cnt) {
+cnt = scan->histogram[i];
 black = i;
 }
 }
 
 cnt = 0;
 for (int i = end; i >= middle; i--) {
-if (s->histogram[i] > cnt) {
-cnt = s->histogram[i];
+if (scan->histogram[i] > cnt) {
+cnt = scan->histogram[i];
 white = i;
 }
 }
 
-s->black = black;
-s->white = white;
+scan->black = black;
+scan->white = white;
 }
 
 static float meanf(const LineItem *line, int len)
@@ -202,7 +237,7 @@ static float stddevf(const LineItem *line, int len)
 return sqrtf(standard_deviation / 

[FFmpeg-cvslog] avfilter/vf_readeia608: add support for commands

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 20:52:22 
2020 +0100| [97bc6900e67007c94b4a9ba7aedd81796abb5602] | committer: Paul B Mahol

avfilter/vf_readeia608: add support for commands

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

 doc/filters.texi| 4 
 libavfilter/vf_readeia608.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 15acae9709..ad8937d992 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15910,6 +15910,10 @@ Enable checking the parity bit. In the event of a 
parity error, the filter will
 Lowpass lines prior to further processing. Default is enabled.
 @end table
 
+@subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
 @subsection Examples
 
 @itemize
diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c
index 2973847d40..39c4703b66 100644
--- a/libavfilter/vf_readeia608.c
+++ b/libavfilter/vf_readeia608.c
@@ -74,7 +74,7 @@ typedef struct ReadEIA608Context {
 } ReadEIA608Context;
 
 #define OFFSET(x) offsetof(ReadEIA608Context, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption readeia608_options[] = {
 { "scan_min", "set from which line to scan for codes",   
OFFSET(start), AV_OPT_TYPE_INT,   {.i64=0}, 0, INT_MAX, FLAGS },
@@ -440,4 +440,5 @@ AVFilter ff_vf_readeia608 = {
 .outputs   = readeia608_outputs,
 .uninit= uninit,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
+.process_command = ff_filter_process_command,
 };

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

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

[FFmpeg-cvslog] avfilter/vf_xfade: ensure metadata is copied to transition frames

2020-11-24 Thread Musee Ullah
ffmpeg | branch: master | Musee Ullah  | Mon Nov 23 13:52:01 2020 
-0600| [7bb8b819556a1146eeff1863bbb42b77039c1798] | committer: Paul B Mahol

avfilter/vf_xfade: ensure metadata is copied to transition frames

I was having an issue where, using a filter chain of xfade -> ass, the
colors on the subtitles were incorrect only on the frames where xfade
was being used. This resolves that issue for me.

Signed-off-by: Musee Ullah 

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

 libavfilter/vf_xfade.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index 6b94cc7036..4e07d7b525 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -1830,6 +1830,7 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame *a, 
AVFrame *b)
 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!out)
 return AVERROR(ENOMEM);
+av_frame_copy_props(out, a);
 
 td.xf[0] = a, td.xf[1] = b, td.out = out, td.progress = progress;
 ctx->internal->execute(ctx, xfade_slice, , NULL, FFMIN(outlink->h, 
ff_filter_get_nb_threads(ctx)));

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

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

[FFmpeg-cvslog] avfilter/af_biquads: make sure that biquad filter still works

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 14:24:18 
2020 +0100| [c6a7ca271b9cead3595cef09b8e455ff4b3f198a] | committer: Paul B Mahol

avfilter/af_biquads: make sure that biquad filter still works

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

 libavfilter/af_biquads.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index 549724ec4e..3ec26d2a9d 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -440,7 +440,7 @@ static int config_filter(AVFilterLink *outlink, int reset)
 return 0;
 }
 
-if (w0 > M_PI || w0 <= 0.)
+if ((w0 > M_PI || w0 <= 0.) && (s->filter_type != biquad))
 return AVERROR(EINVAL);
 
 switch (s->width_type) {

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

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

[FFmpeg-cvslog] avfilter/af_biquads: do not abort filtering on bogus options

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 11:49:19 
2020 +0100| [040e989223f0b74c746635a7137e9f43fea28664] | committer: Paul B Mahol

avfilter/af_biquads: do not abort filtering on bogus options

Instead, continue returning unfiltered input.

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

 libavfilter/af_biquads.c | 38 +++---
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index d82eb420a7..549724ec4e 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -116,6 +116,8 @@ typedef struct BiquadsContext {
 int csg;
 int transform_type;
 
+int bypass;
+
 double gain;
 double frequency;
 double width;
@@ -139,21 +141,6 @@ typedef struct BiquadsContext {
int disabled);
 } BiquadsContext;
 
-static av_cold int init(AVFilterContext *ctx)
-{
-BiquadsContext *s = ctx->priv;
-
-if (s->filter_type != biquad) {
-if (s->frequency <= 0 || s->width <= 0) {
-av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 
0\n",
-   s->frequency, s->width);
-return AVERROR(EINVAL);
-}
-}
-
-return 0;
-}
-
 static int query_formats(AVFilterContext *ctx)
 {
 AVFilterFormats *formats;
@@ -447,13 +434,15 @@ static int config_filter(AVFilterLink *outlink, int reset)
 double K = tan(w0 / 2.);
 double alpha, beta;
 
-if (w0 > M_PI) {
-av_log(ctx, AV_LOG_ERROR,
-   "Invalid frequency %f. Frequency must be less than half the 
sample-rate %d.\n",
-   s->frequency, inlink->sample_rate);
-return AVERROR(EINVAL);
+s->bypass = (((w0 > M_PI || w0 <= 0.) && reset) || (s->width <= 0.)) && 
(s->filter_type != biquad);
+if (s->bypass) {
+av_log(ctx, AV_LOG_WARNING, "Invalid frequency and/or width!\n");
+return 0;
 }
 
+if (w0 > M_PI || w0 <= 0.)
+return AVERROR(EINVAL);
+
 switch (s->width_type) {
 case NONE:
 alpha = 0.0;
@@ -748,6 +737,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 ThreadData td;
 int ch;
 
+if (s->bypass)
+return ff_filter_frame(outlink, buf);
+
 if (av_frame_is_writable(buf)) {
 out_buf = buf;
 } else {
@@ -820,15 +812,15 @@ static const AVFilterPad outputs[] = {
 
 #define DEFINE_BIQUAD_FILTER(name_, description_)   \
 AVFILTER_DEFINE_CLASS(name_);   \
-static av_cold int name_##_init(AVFilterContext *ctx) \
+static av_cold int name_##_init(AVFilterContext *ctx)   \
 {   \
 BiquadsContext *s = ctx->priv;  \
 s->class = _##_class;  \
 s->filter_type = name_; \
-return init(ctx); \
+return 0;   \
 }   \
  \
-AVFilter ff_af_##name_ = { \
+AVFilter ff_af_##name_ = {   \
 .name  = #name_, \
 .description   = NULL_IF_CONFIG_SMALL(description_), \
 .priv_size = sizeof(BiquadsContext), \

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

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

[FFmpeg-cvslog] avcodec/mlpdec: Avoid code duplication when initializing VLCs

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Nov 21 00:24:33 2020 +0100| [08a992e018fd1c28daac1ec21cfd133ca3d7a140] | 
committer: Andreas Rheinhardt

avcodec/mlpdec: Avoid code duplication when initializing VLCs

Reviewed-by: Jai Luthra 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mlpdec.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index ec346868c6..ed25b71d2d 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -206,15 +206,14 @@ static VLC huff_vlc[3];
 
 static av_cold void init_static(void)
 {
-INIT_VLC_STATIC(_vlc[0], VLC_BITS, 18,
-_mlp_huffman_tables[0][0][1], 2, 1,
-_mlp_huffman_tables[0][0][0], 2, 1, VLC_STATIC_SIZE);
-INIT_VLC_STATIC(_vlc[1], VLC_BITS, 16,
-_mlp_huffman_tables[1][0][1], 2, 1,
-_mlp_huffman_tables[1][0][0], 2, 1, VLC_STATIC_SIZE);
-INIT_VLC_STATIC(_vlc[2], VLC_BITS, 15,
-_mlp_huffman_tables[2][0][1], 2, 1,
-_mlp_huffman_tables[2][0][0], 2, 1, VLC_STATIC_SIZE);
+for (int i = 0; i < 3; i++) {
+static VLC_TYPE vlc_buf[3 * VLC_STATIC_SIZE][2];
+huff_vlc[i].table   = _buf[i * VLC_STATIC_SIZE];
+huff_vlc[i].table_allocated = VLC_STATIC_SIZE;
+init_vlc(_vlc[i], VLC_BITS, 18,
+ _mlp_huffman_tables[i][0][1], 2, 1,
+ _mlp_huffman_tables[i][0][0], 2, 1, 
INIT_VLC_USE_NEW_STATIC);
+}
 
 ff_mlp_init_crc();
 }

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

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

[FFmpeg-cvslog] avcodec/mlpdec: Make decoders init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Nov 21 00:15:49 2020 +0100| [34aa85cd9113bde646af51440aa4528314ddfae3] | 
committer: Andreas Rheinhardt

avcodec/mlpdec: Make decoders init-threadsafe

Reviewed-by: Jai Luthra 
Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 1a2c0f29ac..ec346868c6 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -30,6 +30,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/thread.h"
 #include "get_bits.h"
 #include "internal.h"
 #include "libavutil/crc.h"
@@ -205,7 +206,6 @@ static VLC huff_vlc[3];
 
 static av_cold void init_static(void)
 {
-if (!huff_vlc[0].bits) {
 INIT_VLC_STATIC(_vlc[0], VLC_BITS, 18,
 _mlp_huffman_tables[0][0][1], 2, 1,
 _mlp_huffman_tables[0][0][0], 2, 1, VLC_STATIC_SIZE);
@@ -215,7 +215,6 @@ static av_cold void init_static(void)
 INIT_VLC_STATIC(_vlc[2], VLC_BITS, 15,
 _mlp_huffman_tables[2][0][1], 2, 1,
 _mlp_huffman_tables[2][0][0], 2, 1, VLC_STATIC_SIZE);
-}
 
 ff_mlp_init_crc();
 }
@@ -279,15 +278,17 @@ static inline int read_huff_channels(MLPDecodeContext *m, 
GetBitContext *gbp,
 
 static av_cold int mlp_decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 MLPDecodeContext *m = avctx->priv_data;
 int substr;
 
-init_static();
 m->avctx = avctx;
 for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
 m->substream[substr].lossless_check_data = 0x;
 ff_mlpdsp_init(>dsp);
 
+ff_thread_once(_static_once, init_static);
+
 return 0;
 }
 
@@ -1339,6 +1340,7 @@ AVCodec ff_mlp_decoder = {
 .init   = mlp_decode_init,
 .decode = read_access_unit,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 #if CONFIG_TRUEHD_DECODER
@@ -1351,5 +1353,6 @@ AVCodec ff_truehd_decoder = {
 .init   = mlp_decode_init,
 .decode = read_access_unit,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif /* CONFIG_TRUEHD_DECODER */

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

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

[FFmpeg-cvslog] avcodec/mpegaudiodec_template: Don't use unnecessarily many VLC bits

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 17 14:29:58 2020 +0100| [79ab46ac6e943c7ac886461f8d761e4c0036f8c3] | 
committer: Andreas Rheinhardt

avcodec/mpegaudiodec_template: Don't use unnecessarily many VLC bits

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mpegaudiodec_template.c 
b/libavcodec/mpegaudiodec_template.c
index 849e3e5c09..0634f70b05 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -108,8 +108,8 @@ static const int huff_vlc_tables_sizes[16] = {
   142,  204,  190,  170,  542,  460,  662,  414
 };
 static VLC huff_quad_vlc[2];
-static VLC_TYPE  huff_quad_vlc_tables[128+16][2];
-static const int huff_quad_vlc_tables_sizes[2] = { 128, 16 };
+static VLC_TYPE  huff_quad_vlc_tables[64+16][2];
+static const int huff_quad_vlc_tables_sizes[2] = { 64, 16 };
 /* computed from band_size_long */
 static uint16_t band_index_long[9][23];
 #include "mpegaudio_tablegen.h"
@@ -321,7 +321,7 @@ static av_cold void decode_init_static(void)
 for (i = 0; i < 2; i++) {
 huff_quad_vlc[i].table = huff_quad_vlc_tables+offset;
 huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i];
-init_vlc(_quad_vlc[i], i == 0 ? 7 : 4, 16,
+init_vlc(_quad_vlc[i], i == 0 ? 6 : 4, 16,
  mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1,
  INIT_VLC_USE_NEW_STATIC);
 offset += huff_quad_vlc_tables_sizes[i];

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

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

[FFmpeg-cvslog] avcodec/mlp: Make initializing CRCs thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Nov 21 00:11:18 2020 +0100| [1f0e27dd66dabe243b289aa332525e99036feea5] | 
committer: Andreas Rheinhardt

avcodec/mlp: Make initializing CRCs thread-safe

Reviewed-by: Jai Luthra 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mlp.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c
index ddbab60c4e..74363c3b95 100644
--- a/libavcodec/mlp.c
+++ b/libavcodec/mlp.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "mlp.h"
 
 const uint8_t ff_mlp_huffman_tables[3][18][2] = {
@@ -62,7 +63,6 @@ const uint64_t ff_mlp_channel_layouts[12] = {
 AV_CH_LAYOUT_4POINT1, AV_CH_LAYOUT_5POINT1_BACK, 0,
 };
 
-static int crc_init = 0;
 #if CONFIG_SMALL
 #define CRC_TABLE_SIZE 257
 #else
@@ -72,14 +72,17 @@ static AVCRC crc_63[CRC_TABLE_SIZE];
 static AVCRC crc_1D[CRC_TABLE_SIZE];
 static AVCRC crc_2D[CRC_TABLE_SIZE];
 
+static av_cold void mlp_init_crc(void)
+{
+av_crc_init(crc_63, 0,  8,   0x63, sizeof(crc_63));
+av_crc_init(crc_1D, 0,  8,   0x1D, sizeof(crc_1D));
+av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
+}
+
 av_cold void ff_mlp_init_crc(void)
 {
-if (!crc_init) {
-av_crc_init(crc_63, 0,  8,   0x63, sizeof(crc_63));
-av_crc_init(crc_1D, 0,  8,   0x1D, sizeof(crc_1D));
-av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
-crc_init = 1;
-}
+static AVOnce init_static_once = AV_ONCE_INIT;
+ff_thread_once(_static_once, mlp_init_crc);
 }
 
 uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)

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

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

[FFmpeg-cvslog] avcodec/mv30: Don't check for errors for complete VLCs

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Nov 16 14:50:49 2020 +0100| [37f510d3f48fb0ab127694a77858dcc78346780c] | 
committer: Andreas Rheinhardt

avcodec/mv30: Don't check for errors for complete VLCs

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mv30.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index 59088d84f8..a361873c80 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -379,9 +379,6 @@ static int decode_coeffs(GetBitContext *gb, int16_t 
*coeffs, int nb_codes)
 for (int i = 0; i < nb_codes;) {
 int value = get_vlc2(gb, cbp_tab.table, cbp_tab.bits, 1);
 
-if (value < 0)
-return AVERROR_INVALIDDATA;
-
 if (value > 0) {
 int x = get_bits(gb, value);
 

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

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

[FFmpeg-cvslog] avcodec/imm4: Don't use too big VLC table

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Nov 16 13:27:22 2020 +0100| [50d50653d106184b60f464eeba20e132c137090e] | 
committer: Andreas Rheinhardt

avcodec/imm4: Don't use too big VLC table

Using more bits than the longest code has makes no sense.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/imm4.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index d92bc30ddc..85d8526bc8 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -33,6 +33,8 @@
 #include "idctdsp.h"
 #include "internal.h"
 
+#define CBPLO_VLC_BITS   6
+
 typedef struct IMM4Context {
 BswapDSPContext bdsp;
 GetBitContext  gb;
@@ -488,8 +490,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
 static av_cold void imm4_init_static_data(void)
 {
-INIT_VLC_SPARSE_STATIC(_tab, 9, FF_ARRAY_ELEMS(cbplo_bits),
-   cbplo_bits, 1, 1, cbplo_codes, 1, 1, cbplo_symbols, 
1, 1, 512);
+INIT_VLC_SPARSE_STATIC(_tab, CBPLO_VLC_BITS, 
FF_ARRAY_ELEMS(cbplo_bits),
+   cbplo_bits, 1, 1, cbplo_codes, 1, 1, cbplo_symbols, 
1, 1,
+   1 << CBPLO_VLC_BITS);
 
 INIT_VLC_SPARSE_STATIC(_tab, 6, FF_ARRAY_ELEMS(cbphi_bits),
cbphi_bits, 1, 1, cbphi_codes, 1, 1, NULL, 0, 0, 
64);

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

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

[FFmpeg-cvslog] avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Nov 19 16:54:45 2020 +0100| [195d8ce85eb73ff283f85dcee63383ec4081e3e7] | 
committer: Andreas Rheinhardt

avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe

This table is currently initialized up to three times: Once by the
encoder and twice by the decoders (once by the fixed and once by the
floating-point decoder); each of these initializations is guarded by an
AVOnce, yet the fact that there are three of them implies that there
might be data races (the fact that each entry is only written to once
(to its final value) when initializing means that this is safe in
practice, yet it is still undefined behaviour). Fix this by only
initializing the table from one place that is guarded by a single AVOnce.
This also avoids unnecessary duplications of the init code.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/aacenc.c | 12 +---
 libavcodec/aactab.c | 52 
 libavcodec/aactab.h | 46 +-
 3 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index bb203981b2..274e5ca294 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -30,7 +30,6 @@
  ***/
 
 #include "libavutil/libm.h"
-#include "libavutil/thread.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
@@ -49,8 +48,6 @@
 
 #include "psymodel.h"
 
-static AVOnce aac_table_init = AV_ONCE_INIT;
-
 static void put_pce(PutBitContext *pb, AVCodecContext *avctx)
 {
 int i, j;
@@ -951,11 +948,6 @@ static av_cold int alloc_buffers(AVCodecContext *avctx, 
AACEncContext *s)
 return 0;
 }
 
-static av_cold void aac_encode_init_tables(void)
-{
-ff_aac_tableinit();
-}
-
 static av_cold int aac_encode_init(AVCodecContext *avctx)
 {
 AACEncContext *s = avctx->priv_data;
@@ -1107,10 +1099,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
 if (HAVE_MIPSDSP)
 ff_aac_coder_init_mips(s);
 
-if ((ret = ff_thread_once(_table_init, _encode_init_tables)) != 0)
-return AVERROR_UNKNOWN;
-
 ff_af_queue_init(avctx, >afq);
+ff_aac_tableinit();
 
 return 0;
 }
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index df551b058f..79dd13d9cb 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -28,7 +28,9 @@
  */
 
 #include "libavutil/mem.h"
+#include "libavutil/thread.h"
 #include "aac.h"
+#include "aactab.h"
 
 #include 
 
@@ -3280,3 +3282,53 @@ const DECLARE_ALIGNED(32, int, 
ff_aac_eld_window_480_fixed)[1800] = {
 0xffecff1c, 0xffed391e, 0xffed740c, 0xffedafb1,
 0xffedebe1, 0xffee287d, 0xffee654e, 0xffeea23f,
 };
+
+static void aac_tableinit(void)
+{
+/* 2^(i/16) for 0 <= i <= 15 */
+static const float exp2_lut[] = {
+1.,
+1.04427378242741384032,
+1.09050773266525765921,
+1.13878863475669165370,
+1.18920711500272106672,
+1.24185781207348404859,
+1.29683955465100966593,
+1.35425554693689272830,
+1.41421356237309504880,
+1.47682614593949931139,
+1.54221082540794082361,
+1.61049033194925430818,
+1.68179283050742908606,
+1.75625216037329948311,
+1.83400808640934246349,
+1.91520656139714729387,
+};
+float t1 = 8.8817841970012523233890533447265625e-16; // 2^(-50)
+float t2 = 3.63797880709171295166015625e-12; // 2^(-38)
+int t1_inc_cur, t2_inc_cur;
+int t1_inc_prev = 0;
+int t2_inc_prev = 8;
+
+for (int i = 0; i < 428; i++) {
+t1_inc_cur = 4 * (i % 4);
+t2_inc_cur = (8 + 3*i) % 16;
+if (t1_inc_cur < t1_inc_prev)
+t1 *= 2;
+if (t2_inc_cur < t2_inc_prev)
+t2 *= 2;
+// A much more efficient and accurate way of doing:
+// ff_aac_pow2sf_tab[i]  = pow(2, (i - POW_SF2_ZERO) / 4.0);
+// ff_aac_pow34sf_tab[i] = pow(ff_aac_pow2sf_tab[i], 3.0/4.0);
+ff_aac_pow2sf_tab[i]  = t1 * exp2_lut[t1_inc_cur];
+ff_aac_pow34sf_tab[i] = t2 * exp2_lut[t2_inc_cur];
+t1_inc_prev = t1_inc_cur;
+t2_inc_prev = t2_inc_cur;
+}
+}
+
+void ff_aac_tableinit(void)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+ff_thread_once(_static_once, aac_tableinit);
+}
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 29df6a43f0..ce6a7ba1d2 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -42,51 +42,7 @@
 extern float ff_aac_pow2sf_tab[428];
 extern float ff_aac_pow34sf_tab[428];
 
-static inline void ff_aac_tableinit(void)
-{
-int i;
-
-/* 2^(i/16) for 0 <= i <= 15 */
-static const float exp2_lut[] = {
-1.,
-1.04427378242741384032,
-1.09050773266525765921,
-

[FFmpeg-cvslog] avcodec/aactab: Fix conflicting types for ff_aac_codebook*

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Nov 19 16:50:44 2020 +0100| [c4b4cd775af0f4b83c34fd595c05d2fa99018323] | 
committer: Andreas Rheinhardt

avcodec/aactab: Fix conflicting types for ff_aac_codebook*

The header missed that these are arrays of const pointers (to const
data).

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/aactab.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 7cd8128231..29df6a43f0 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -167,9 +167,9 @@ extern const uint16_t * const ff_aac_spectral_codes[11];
 extern const uint8_t  * const ff_aac_spectral_bits [11];
 extern const uint16_t  ff_aac_spectral_sizes[11];
 
-extern const float *ff_aac_codebook_vectors[];
-extern const float *ff_aac_codebook_vector_vals[];
-extern const uint16_t *ff_aac_codebook_vector_idx[];
+extern const float *const ff_aac_codebook_vectors[];
+extern const float *const ff_aac_codebook_vector_vals[];
+extern const uint16_t *const ff_aac_codebook_vector_idx[];
 
 extern const uint16_t * const ff_swb_offset_1024[13];
 extern const uint16_t * const ff_swb_offset_960 [13];

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

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

[FFmpeg-cvslog] avcodec/qdmc: Don't check for errors for complete VLCs

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov  8 10:15:31 2020 +0100| [b81e6437ca1bb9e637b98ea862fbcd17ef2a065a] | 
committer: Andreas Rheinhardt

avcodec/qdmc: Don't check for errors for complete VLCs

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/qdmc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index ff1cc86c6b..f4e507fa60 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -370,8 +370,6 @@ static int qdmc_get_vlc(GetBitContext *gb, VLC *table, int 
flag)
 if (get_bits_left(gb) < 1)
 return AVERROR_INVALIDDATA;
 v = get_vlc2(gb, table->table, table->bits, 2);
-if (v < 0)
-return AVERROR_INVALIDDATA;
 if (v)
 v = v - 1;
 else

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

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

[FFmpeg-cvslog] avcodec/hqx: Don't check for errors for complete VLCs

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Nov  7 10:33:30 2020 +0100| [e68247d5cf3c490fe7565007cc4b24f5817b] | 
committer: Andreas Rheinhardt

avcodec/hqx: Don't check for errors for complete VLCs

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/hqx.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c
index 44c6c1883c..aa4ff22a8f 100644
--- a/libavcodec/hqx.c
+++ b/libavcodec/hqx.c
@@ -122,8 +122,6 @@ static int decode_block(GetBitContext *gb, VLC *vlc,
 
 memset(block, 0, 64 * sizeof(*block));
 dc = get_vlc2(gb, vlc->table, HQX_DC_VLC_BITS, 2);
-if (dc < 0)
-return AVERROR_INVALIDDATA;
 *last_dc += dc;
 
 block[0] = sign_extend(*last_dc << (12 - dcb), 12);

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

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

[FFmpeg-cvslog] avcodec/hqx: Inline constants

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Nov  7 10:31:59 2020 +0100| [a03caa384f8f8c7bb2ba30b1bd0e60fa77f25db6] | 
committer: Andreas Rheinhardt

avcodec/hqx: Inline constants

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/hqx.c| 4 ++--
 libavcodec/hqx.h| 1 +
 libavcodec/hqxvlc.c | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c
index e2b895ac40..44c6c1883c 100644
--- a/libavcodec/hqx.c
+++ b/libavcodec/hqx.c
@@ -197,7 +197,7 @@ static int hqx_decode_422a(HQXContext *ctx, int slice_no, 
int x, int y)
 int i, ret;
 int cbp;
 
-cbp = get_vlc2(gb, ctx->cbp_vlc.table, ctx->cbp_vlc.bits, 1);
+cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
 
 for (i = 0; i < 12; i++)
 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
@@ -283,7 +283,7 @@ static int hqx_decode_444a(HQXContext *ctx, int slice_no, 
int x, int y)
 int i, ret;
 int cbp;
 
-cbp = get_vlc2(gb, ctx->cbp_vlc.table, ctx->cbp_vlc.bits, 1);
+cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
 
 for (i = 0; i < 16; i++)
 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
diff --git a/libavcodec/hqx.h b/libavcodec/hqx.h
index 42d382de1f..50d60f9e03 100644
--- a/libavcodec/hqx.h
+++ b/libavcodec/hqx.h
@@ -77,6 +77,7 @@ typedef struct HQXContext {
 VLC dc_vlc[3];
 } HQXContext;
 
+#define HQX_CBP_VLC_BITS 5
 #define HQX_DC_VLC_BITS 9
 
 extern const HQXAC ff_hqx_ac[NUM_HQX_AC];
diff --git a/libavcodec/hqxvlc.c b/libavcodec/hqxvlc.c
index 06a8073661..7ab2427660 100644
--- a/libavcodec/hqxvlc.c
+++ b/libavcodec/hqxvlc.c
@@ -2150,7 +2150,7 @@ const HQXAC ff_hqx_ac[NUM_HQX_AC] = {
 
 av_cold int ff_hqx_init_vlcs(HQXContext *ctx)
 {
-int ret = init_vlc(>cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
+int ret = init_vlc(>cbp_vlc, HQX_CBP_VLC_BITS, 
FF_ARRAY_ELEMS(cbp_vlc_lens),
cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
 if (ret < 0)
 return ret;

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

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

[FFmpeg-cvslog] avcodec/intrax8: Make ff_intrax8_common_init() thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Nov 16 22:00:34 2020 +0100| [b1af617f519cf7bbae1379473c76cff2b0e55659] | 
committer: Andreas Rheinhardt

avcodec/intrax8: Make ff_intrax8_common_init() thread-safe

In particular, don't reinitialize VLCs every time an IntraX8Context is
initialized.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/intrax8.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 390c10272e..b85653881d 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -22,6 +22,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
@@ -725,6 +726,8 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
int block_last_index[12],
int mb_width, int mb_height)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
+
 w->avctx = avctx;
 w->idsp = *idsp;
 w->mb_width  = mb_width;
@@ -752,7 +755,7 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
 ff_intrax8dsp_init(>dsp);
 ff_blockdsp_init(>bdsp, avctx);
 
-x8_vlc_init();
+ff_thread_once(_static_once, x8_vlc_init);
 
 return 0;
 }

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

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

[FFmpeg-cvslog] avcodec/intrax8: Replace always-false check by assert

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Nov  6 13:15:24 2020 +0100| [802baf212d2ab1b9844696589fc6c18ba748194c] | 
committer: Andreas Rheinhardt

avcodec/intrax8: Replace always-false check by assert

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/intrax8.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index f385423dc1..390c10272e 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -46,7 +46,7 @@ static VLC j_ac_vlc[2][2][8];  // [quant < 13], [intra / 
inter], [select]
 static VLC j_dc_vlc[2][8]; // [quant], [select]
 static VLC j_orient_vlc[2][4]; // [quant], [select]
 
-static av_cold int x8_vlc_init(void)
+static av_cold void x8_vlc_init(void)
 {
 int i;
 int offset = 0;
@@ -115,13 +115,7 @@ static av_cold int x8_vlc_init(void)
 init_or_vlc(j_orient_vlc[1][i], x8_orient_lowquant_table[i][0]);
 #undef init_or_vlc
 
-if (offset != sizeof(table) / sizeof(VLC_TYPE) / 2) {
-av_log(NULL, AV_LOG_ERROR, "table size %"SIZE_SPECIFIER" does not 
match needed %i\n",
-   sizeof(table) / sizeof(VLC_TYPE) / 2, offset);
-return AVERROR_INVALIDDATA;
-}
-
-return 0;
+av_assert2(offset == FF_ARRAY_ELEMS(table));
 }
 
 static void x8_reset_vlc_tables(IntraX8Context *w)
@@ -731,10 +725,6 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
int block_last_index[12],
int mb_width, int mb_height)
 {
-int ret = x8_vlc_init();
-if (ret < 0)
-return ret;
-
 w->avctx = avctx;
 w->idsp = *idsp;
 w->mb_width  = mb_width;
@@ -762,6 +752,8 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
 ff_intrax8dsp_init(>dsp);
 ff_blockdsp_init(>bdsp, avctx);
 
+x8_vlc_init();
+
 return 0;
 }
 

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

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

[FFmpeg-cvslog] avcodec/atrac9tab: Add missing static to internal table

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Nov  9 14:59:13 2020 +0100| [164ce14e5caeb1052d9365541e1052b5dad9cd8b] | 
committer: Andreas Rheinhardt

avcodec/atrac9tab: Add missing static to internal table

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/atrac9tab.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/atrac9tab.h b/libavcodec/atrac9tab.h
index c25d0e2744..4e0c3ee1cc 100644
--- a/libavcodec/atrac9tab.h
+++ b/libavcodec/atrac9tab.h
@@ -104,7 +104,7 @@ static const int at9_q_unit_to_coeff_idx[] = {
 72, 80, 88, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256
 };
 
-const uint8_t at9_q_unit_to_codebookidx[] = {
+static const uint8_t at9_q_unit_to_codebookidx[] = {
 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
 };

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

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

[FFmpeg-cvslog] avcodec/atrac9dec: Use least max_depth in calls to get_vlc2()

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Nov  4 05:33:33 2020 +0100| [4a9ffce91cef3c56d34db7f5966c1b48241a2536] | 
committer: Andreas Rheinhardt

avcodec/atrac9dec: Use least max_depth in calls to get_vlc2()

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index a1af3c22ef..ecf95f1777 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -272,7 +272,7 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 c->scalefactors[0] = get_bits(gb, len);
 
 for (int i = 1; i < b->band_ext_q_unit; i++) {
-int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 2);
+int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1);
 c->scalefactors[i] = val & ((1 << len) - 1);
 }
 
@@ -302,7 +302,7 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 const VLC *tab = >sf_vlc[1][len];
 
 for (int i = 0; i < unit_cnt; i++) {
-int dist = get_vlc2(gb, tab->table, 9, 2);
+int dist = get_vlc2(gb, tab->table, 9, 1);
 c->scalefactors[i] = baseline[i] + dist;
 }
 
@@ -325,7 +325,7 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 c->scalefactors[0] = get_bits(gb, len);
 
 for (int i = 1; i < unit_cnt; i++) {
-int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 2);
+int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1);
 c->scalefactors[i] = val & ((1 << len) - 1);
 }
 

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

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

[FFmpeg-cvslog] avcodec/atrac9dec: Don't confuse max_depth of VLC with max codelength

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Nov  4 05:20:10 2020 +0100| [92209cf4c9be74197a1585e656443fedf215b344] | 
committer: Andreas Rheinhardt

avcodec/atrac9dec: Don't confuse max_depth of VLC with max codelength

The whole point of VLCs with their tables is to read more than one bit
at a time; therefore max_depth, the number of times one has to
(maximally) read further bits is given by ceil(max_code_length / table_bits)
which in the case of ATRAC9's coefficient VLCs gives an upper bound of
two. Instead the maximum length of a code of the given VLC has been used
(which is not even a compile-time constant). Use two instead.

Furthermore, given that this was the only usage of the field containing
the maximum of all the code lengths of a given VLC the field has been
removed from its containing struct.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/atrac9dec.c |   2 +-
 libavcodec/atrac9tab.h | 105 -
 2 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 075d610e75..a1af3c22ef 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -411,7 +411,7 @@ static inline void read_coeffs_coarse(ATRAC9Context *s, 
ATRAC9BlockData *b,
 const int groups = bands >> huff->value_cnt_pow;
 
 for (int j = 0; j < groups; j++) {
-uint16_t val = get_vlc2(gb, tab->table, 9, huff->max_bit_size);
+uint16_t val = get_vlc2(gb, tab->table, 9, 2);
 
 for (int k = 0; k < huff->value_cnt; k++) {
 coeffs[k] = sign_extend(val, huff->value_bits);
diff --git a/libavcodec/atrac9tab.h b/libavcodec/atrac9tab.h
index 8f290f158c..c25d0e2744 100644
--- a/libavcodec/atrac9tab.h
+++ b/libavcodec/atrac9tab.h
@@ -476,26 +476,25 @@ typedef struct HuffmanCodebook {
 const int value_cnt;
 const int value_cnt_pow;
 const int value_bits;
-const int max_bit_size;
 } HuffmanCodebook;
 
 static const HuffmanCodebook at9_huffman_sf_unsigned[] = {
 { 0 },
-{ huff_sfb_a1_bits, huff_sfb_a1_codes,  2,  1,  0,  1,  1, },
-{ huff_sfb_a2_bits, huff_sfb_a2_codes,  4,  1,  0,  2,  3, },
-{ huff_sfb_a3_bits, huff_sfb_a3_codes,  8,  1,  0,  3,  6, },
-{ huff_sfb_a4_bits, huff_sfb_a4_codes, 16,  1,  0,  4,  8, },
-{ huff_sfb_a5_bits, huff_sfb_a5_codes, 32,  1,  0,  5,  8, },
-{ huff_sfb_a6_bits, huff_sfb_a6_codes, 64,  1,  0,  6,  8, },
+{ huff_sfb_a1_bits, huff_sfb_a1_codes,  2,  1,  0,  1 },
+{ huff_sfb_a2_bits, huff_sfb_a2_codes,  4,  1,  0,  2 },
+{ huff_sfb_a3_bits, huff_sfb_a3_codes,  8,  1,  0,  3 },
+{ huff_sfb_a4_bits, huff_sfb_a4_codes, 16,  1,  0,  4 },
+{ huff_sfb_a5_bits, huff_sfb_a5_codes, 32,  1,  0,  5 },
+{ huff_sfb_a6_bits, huff_sfb_a6_codes, 64,  1,  0,  6 },
 };
 
 static const HuffmanCodebook at9_huffman_sf_signed[] = {
 { 0 },
 { 0 },
-{ huff_sfb_b2_bits, huff_sfb_b2_codes,  4,  1,  0,  2,  2, },
-{ huff_sfb_b3_bits, huff_sfb_b3_codes,  8,  1,  0,  3,  6, },
-{ huff_sfb_b4_bits, huff_sfb_b4_codes, 16,  1,  0,  4,  8, },
-{ huff_sfb_b5_bits, huff_sfb_b5_codes, 32,  1,  0,  5,  8, },
+{ huff_sfb_b2_bits, huff_sfb_b2_codes,  4,  1,  0,  2 },
+{ huff_sfb_b3_bits, huff_sfb_b3_codes,  8,  1,  0,  3 },
+{ huff_sfb_b4_bits, huff_sfb_b4_codes, 16,  1,  0,  4 },
+{ huff_sfb_b5_bits, huff_sfb_b5_codes, 32,  1,  0,  5 },
 };
 
 static const uint8_t huff_spec_a21_bits[] = {
@@ -1539,40 +1538,40 @@ static const HuffmanCodebook at9_huffman_coeffs[][8][4] 
= {
 { { 0 } },
 { { 0 } },
 {
-{ huff_spec_a21_bits, huff_spec_a21_codes,  16,   2,   1,   2,   
3, },
-{ huff_spec_a22_bits, huff_spec_a22_codes, 256,   4,   2,   2,   
8, },
-{ huff_spec_a23_bits, huff_spec_a23_codes, 256,   4,   2,   2,   
9, },
-{ huff_spec_a24_bits, huff_spec_a24_codes, 256,   4,   2,   2,  
10, },
+{ huff_spec_a21_bits, huff_spec_a21_codes,  16,   2,   1,   2 },
+{ huff_spec_a22_bits, huff_spec_a22_codes, 256,   4,   2,   2 },
+{ huff_spec_a23_bits, huff_spec_a23_codes, 256,   4,   2,   2 },
+{ huff_spec_a24_bits, huff_spec_a24_codes, 256,   4,   2,   2 },
 },
 {
-{ huff_spec_a31_bits, huff_spec_a31_codes,  64,   2,   1,   3,   
7, },
-{ huff_spec_a32_bits, huff_spec_a32_codes,  64,   2,   1,   3,   
7, },
-{ huff_spec_a33_bits, huff_spec_a33_codes,  64,   2,   1,   3,   
8, },
-{ huff_spec_a34_bits, huff_spec_a34_codes,  64,   2,   1,   3,  
10, },
+{ huff_spec_a31_bits, huff_spec_a31_codes,  64,   2,   1,   3 },
+{ huff_spec_a32_bits, huff_spec_a32_codes,  64,   2,   1,   3 },
+{ huff_spec_a33_bits, huff_spec_a33_codes,  64,   2,   

[FFmpeg-cvslog] avcodec/atrac9dec: Replace av_free() by av_freep() in close function

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Nov  5 03:51:50 2020 +0100| [6612d6d62e143599ee3c59ce81b157cecf0cdba9] | 
committer: Andreas Rheinhardt

avcodec/atrac9dec: Replace av_free() by av_freep() in close function

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 0477b304d2..a7de037b2c 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -838,7 +838,7 @@ static av_cold int atrac9_decode_close(AVCodecContext 
*avctx)
 ff_free_vlc(>coeff_vlc[i][j][k]);
 
 ff_mdct_end(>imdct);
-av_free(s->fdsp);
+av_freep(>fdsp);
 
 return 0;
 }

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

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

[FFmpeg-cvslog] avcodec/atrac9dec: Don't use unnecessarily large VLC tables

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Nov  4 05:38:31 2020 +0100| [659c61ba7caaa98a3ae6c3a3347b6ff557a4a084] | 
committer: Andreas Rheinhardt

avcodec/atrac9dec: Don't use unnecessarily large VLC tables

Using more bits for a VLC than the longest code has has no advantage.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/atrac9dec.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index ecf95f1777..0477b304d2 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -26,6 +26,8 @@
 #include "libavutil/lfg.h"
 #include "libavutil/float_dsp.h"
 
+#define ATRAC9_SF_VLC_BITS 8
+
 typedef struct ATRAC9ChannelData {
 int band_ext;
 int q_unit_cnt;
@@ -272,7 +274,8 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 c->scalefactors[0] = get_bits(gb, len);
 
 for (int i = 1; i < b->band_ext_q_unit; i++) {
-int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1);
+int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table,
+ATRAC9_SF_VLC_BITS, 1);
 c->scalefactors[i] = val & ((1 << len) - 1);
 }
 
@@ -302,7 +305,7 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 const VLC *tab = >sf_vlc[1][len];
 
 for (int i = 0; i < unit_cnt; i++) {
-int dist = get_vlc2(gb, tab->table, 9, 1);
+int dist = get_vlc2(gb, tab->table, ATRAC9_SF_VLC_BITS, 1);
 c->scalefactors[i] = baseline[i] + dist;
 }
 
@@ -325,7 +328,8 @@ static inline int read_scalefactors(ATRAC9Context *s, 
ATRAC9BlockData *b,
 c->scalefactors[0] = get_bits(gb, len);
 
 for (int i = 1; i < unit_cnt; i++) {
-int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1);
+int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table,
+ATRAC9_SF_VLC_BITS, 1);
 c->scalefactors[i] = val & ((1 << len) - 1);
 }
 
@@ -930,7 +934,8 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 for (int i = 1; i < 7; i++) {
 const HuffmanCodebook *hf = _huffman_sf_unsigned[i];
 
-init_vlc(>sf_vlc[0][i], 9, hf->size, hf->bits, 1, 1, hf->codes,
+init_vlc(>sf_vlc[0][i], ATRAC9_SF_VLC_BITS, hf->size,
+ hf->bits, 1, 1, hf->codes,
  2, 2, 0);
 }
 
@@ -943,7 +948,7 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 for (int j = 0; j < nums; j++)
 sym[j] = sign_extend(j, hf->value_bits);
 
-ff_init_vlc_sparse(>sf_vlc[1][i], 9, hf->size, hf->bits, 1, 1,
+ff_init_vlc_sparse(>sf_vlc[1][i], ATRAC9_SF_VLC_BITS, hf->size, 
hf->bits, 1, 1,
hf->codes, 2, 2, sym, sizeof(*sym), sizeof(*sym), 
0);
 }
 

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

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

[FFmpeg-cvslog] avcodec/truemotion2: Mark decoder as init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 17 11:22:09 2020 +0100| [0339af05a4eaa1adbf153b7fa2213eea7e531573] | 
committer: Andreas Rheinhardt

avcodec/truemotion2: Mark decoder as init-threadsafe

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 0f4f345a6c..ac3294d89c 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -1022,5 +1022,5 @@ AVCodec ff_truemotion2_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 };

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

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

[FFmpeg-cvslog] avcodec/g2meet: Use least max_depth in get_vlc2()

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov  1 02:17:43 2020 +0100| [73b3ea572819a79e7896627e4c1daf74ce1dfe46] | 
committer: Andreas Rheinhardt

avcodec/g2meet: Use least max_depth in get_vlc2()

The longest AC codes of the standard JPEG tables are 16 bits long; for
the DC tables, the maximum is 11, so using max_depth of two is
sufficient.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 6b870ae3d4..f6aa636bde 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -248,7 +248,7 @@ static int jpg_decode_block(JPGContext *c, GetBitContext 
*gb,
 return AVERROR_INVALIDDATA;
 
 c->bdsp.clear_block(block);
-dc = get_vlc2(gb, c->dc_vlc[is_chroma].table, 9, 3);
+dc = get_vlc2(gb, c->dc_vlc[is_chroma].table, 9, 2);
 if (dc < 0)
 return AVERROR_INVALIDDATA;
 if (dc)
@@ -259,7 +259,7 @@ static int jpg_decode_block(JPGContext *c, GetBitContext 
*gb,
 
 pos = 0;
 while (pos < 63) {
-val = get_vlc2(gb, c->ac_vlc[is_chroma].table, 9, 3);
+val = get_vlc2(gb, c->ac_vlc[is_chroma].table, 9, 2);
 if (val < 0)
 return AVERROR_INVALIDDATA;
 pos += val >> 4;

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

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

[FFmpeg-cvslog] avcodec/sheervideo: Add av_cold to build_vlc()

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov  1 01:14:36 2020 +0100| [e74621b0a8c4d8f9aecdbb72ca264bdaca17ab52] | 
committer: Andreas Rheinhardt

avcodec/sheervideo: Add av_cold to build_vlc()

It is an init function even when called from decode_frame().

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c
index 976c21c445..3e60ef26a5 100644
--- a/libavcodec/sheervideo.c
+++ b/libavcodec/sheervideo.c
@@ -1781,7 +1781,7 @@ static void decode_rgb(AVCodecContext *avctx, AVFrame *p, 
GetBitContext *gb)
 }
 }
 
-static int build_vlc(VLC *vlc, const SheerTable *table)
+static av_cold int build_vlc(VLC *vlc, const SheerTable *table)
 {
 const uint8_t *cur = table->lens;
 uint16_t codes[1024];

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

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

[FFmpeg-cvslog] avcodec/mss4: Mark decoder as init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Nov 20 03:53:42 2020 +0100| [f1919dc8fa391debebb339d5ab2268567783411e] | 
committer: Andreas Rheinhardt

avcodec/mss4: Mark decoder as init-threadsafe

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c
index c421a07c5d..a6d036f3f7 100644
--- a/libavcodec/mss4.c
+++ b/libavcodec/mss4.c
@@ -678,5 +678,5 @@ AVCodec ff_mts2_decoder = {
 .close  = mss4_decode_end,
 .decode = mss4_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 };

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

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

[FFmpeg-cvslog] avcodec/rv40vlc2: Make VLC smaller

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Oct 31 20:32:25 2020 +0100| [9a61326b0fa2f4c10e08aa4fd795ae2b0f4310bd] | 
committer: Andreas Rheinhardt

avcodec/rv40vlc2: Make VLC smaller

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/rv40vlc2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/rv40vlc2.h b/libavcodec/rv40vlc2.h
index 15119a145b..4cdc7a4193 100644
--- a/libavcodec/rv40vlc2.h
+++ b/libavcodec/rv40vlc2.h
@@ -33,7 +33,7 @@
  * codes used for the first four block types
  */
 //@{
-#define AIC_TOP_BITS  8
+#define AIC_TOP_BITS  7
 #define AIC_TOP_SIZE 16
 static const uint8_t rv40_aic_top_vlc_codes[AIC_TOP_SIZE] = {
  0x01, 0x05, 0x01, 0x00, 0x03, 0x3D, 0x1D, 0x02,

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

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

[FFmpeg-cvslog] avcodec/qdm2: Remove outdated comment

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 17 13:31:44 2020 +0100| [278a27f651e1ef72096b7eaae3976d6a9ef1d404] | 
committer: Andreas Rheinhardt

avcodec/qdm2: Remove outdated comment

Forgotten in f054e309c58894450a5d18cce9799ef58aab9f14.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/qdm2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index bd365739ce..c3e1315ef0 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -1594,8 +1594,6 @@ static void qdm2_synthesis_filter(QDM2Context *q, int 
index)
 
 /**
  * Init static data (does not depend on specific file)
- *
- * @param qcontext
  */
 static av_cold void qdm2_init_static_data(void) {
 static int done;

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

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

[FFmpeg-cvslog] avcodec/mpegaudiodsp: Make initializing synth windows thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 20:56:22 2020 +0100| [16bb8247b45a51c06e27e8563d8a546f3dddc79e] | 
committer: Andreas Rheinhardt

avcodec/mpegaudiodsp: Make initializing synth windows thread-safe

These arrays are used by the Musepack decoders, the MPEG audio decoders
as well as qdm2 and up until now, these arrays might be initialized more
than once, leading to potential data races as well as unnecessary
initializations. Therefore this commit ensures that each array will only
be initialized once.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpc.c   |  5 -
 libavcodec/mpc.h   |  1 -
 libavcodec/mpc7.c  |  2 +-
 libavcodec/mpc8.c  |  3 +--
 libavcodec/mpegaudiodec_template.c |  3 +--
 libavcodec/mpegaudiodsp.h  |  4 ++--
 libavcodec/mpegaudiodsp_template.c | 14 +-
 libavcodec/qdm2.c  |  3 ++-
 8 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c
index e56b608d8c..e29b823460 100644
--- a/libavcodec/mpc.c
+++ b/libavcodec/mpc.c
@@ -34,11 +34,6 @@
 #include "mpc.h"
 #include "mpcdata.h"
 
-av_cold void ff_mpc_init(void)
-{
-ff_mpa_synth_init_fixed(ff_mpa_synth_window_fixed);
-}
-
 /**
  * Process decoded Musepack data and produce PCM
  */
diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h
index df462af6b7..704edc9a38 100644
--- a/libavcodec/mpc.h
+++ b/libavcodec/mpc.h
@@ -70,7 +70,6 @@ typedef struct MPCContext {
 DECLARE_ALIGNED(16, int32_t, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT];
 } MPCContext;
 
-void ff_mpc_init(void);
 void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, 
int channels);
 
 #endif /* AVCODEC_MPC_H */
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index 6482029efc..e4aa8586d4 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -71,7 +71,6 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
 ff_bswapdsp_init(>bdsp);
 ff_mpadsp_init(>mpadsp);
 c->bdsp.bswap_buf((uint32_t *) buf, (const uint32_t *) avctx->extradata, 
4);
-ff_mpc_init();
 init_get_bits(, buf, 128);
 
 c->IS = get_bits1();
@@ -114,6 +113,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
 }
 }
 vlc_initialized = 1;
+ff_mpa_synth_init_fixed();
 
 return 0;
 }
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index 631bac2753..b05942bca7 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -120,8 +120,6 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
 av_lfg_init(>rnd, 0xDEADBEEF);
 ff_mpadsp_init(>mpadsp);
 
-ff_mpc_init();
-
 init_get_bits(, avctx->extradata, 16);
 
 skip_bits(, 3);//sample rate
@@ -232,6 +230,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
  _q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
 }
 vlc_initialized = 1;
+ff_mpa_synth_init_fixed();
 
 return 0;
 }
diff --git a/libavcodec/mpegaudiodec_template.c 
b/libavcodec/mpegaudiodec_template.c
index 12c1964446..849e3e5c09 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -289,8 +289,6 @@ static av_cold void decode_init_static(void)
 scale_factor_mult[i][2]);
 }
 
-RENAME(ff_mpa_synth_init)(RENAME(ff_mpa_synth_window));
-
 /* huffman decode tables */
 offset = 0;
 for (i = 1; i < 16; i++) {
@@ -408,6 +406,7 @@ static av_cold void decode_init_static(void)
 csa_table[i][3] = ca - cs;
 #endif
 }
+RENAME(ff_mpa_synth_init)();
 }
 
 static av_cold int decode_init(AVCodecContext * avctx)
diff --git a/libavcodec/mpegaudiodsp.h b/libavcodec/mpegaudiodsp.h
index 4c9b05ebac..4577d515d9 100644
--- a/libavcodec/mpegaudiodsp.h
+++ b/libavcodec/mpegaudiodsp.h
@@ -67,8 +67,8 @@ void ff_mpadsp_init_x86_tabs(void);
 void ff_mpadsp_init_mipsfpu(MPADSPContext *s);
 void ff_mpadsp_init_mipsdsp(MPADSPContext *s);
 
-void ff_mpa_synth_init_float(float *window);
-void ff_mpa_synth_init_fixed(int32_t *window);
+void ff_mpa_synth_init_float(void);
+void ff_mpa_synth_init_fixed(void);
 
 void ff_mpadsp_apply_window_float(float *synth_buf, float *window,
   int *dither_state, float *samples,
diff --git a/libavcodec/mpegaudiodsp_template.c 
b/libavcodec/mpegaudiodsp_template.c
index f8d0870df6..c67c456e8a 100644
--- a/libavcodec/mpegaudiodsp_template.c
+++ b/libavcodec/mpegaudiodsp_template.c
@@ -22,6 +22,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/mem.h"
+#include "libavutil/thread.h"
 #include "dct32.h"
 #include "mathops.h"
 #include "mpegaudiodsp.h"
@@ -192,7 +193,7 @@ void RENAME(ff_mpa_synth_filter)(MPADSPContext *s, MPA_INT 
*synth_buf_ptr,
 *synth_buf_offset = offset;
 }
 
-av_cold void RENAME(ff_mpa_synth_init)(MPA_INT *window)
+static av_cold void 

[FFmpeg-cvslog] avcodec/mpegaudiodsp: Make ff_mpadsp_init() thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 16:01:49 2020 +0100| [ead313415037bbb94954a346a17796c0f741f790] | 
committer: Andreas Rheinhardt

avcodec/mpegaudiodsp: Make ff_mpadsp_init() thread-safe

The only thing missing for this is to make ff_mpadsp_init_x86()
thread-safe; it currently isn't because a static table is initialized
every time ff_mpadsp_init() is called (when ARCH_X86 is true). Solve
this by initializing this table only once, namely together with the
ordinary not-arch specific tables. This also allows to reuse their AVOnce.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegaudiodsp.c | 3 +++
 libavcodec/mpegaudiodsp.h | 1 +
 libavcodec/x86/mpegaudiodsp.c | 9 ++---
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegaudiodsp.c b/libavcodec/mpegaudiodsp.c
index 0a14ff549e..f03e244644 100644
--- a/libavcodec/mpegaudiodsp.c
+++ b/libavcodec/mpegaudiodsp.c
@@ -73,6 +73,9 @@ static av_cold void mpadsp_init_tabs(void)
 ff_mdct_win_fixed[j + 4][i + 1] = -ff_mdct_win_fixed[j][i + 1];
 }
 }
+
+if (ARCH_X86)
+ff_mpadsp_init_x86_tabs();
 }
 
 av_cold void ff_mpadsp_init(MPADSPContext *s)
diff --git a/libavcodec/mpegaudiodsp.h b/libavcodec/mpegaudiodsp.h
index 28dcec576c..4c9b05ebac 100644
--- a/libavcodec/mpegaudiodsp.h
+++ b/libavcodec/mpegaudiodsp.h
@@ -63,6 +63,7 @@ void ff_mpadsp_init_aarch64(MPADSPContext *s);
 void ff_mpadsp_init_arm(MPADSPContext *s);
 void ff_mpadsp_init_ppc(MPADSPContext *s);
 void ff_mpadsp_init_x86(MPADSPContext *s);
+void ff_mpadsp_init_x86_tabs(void);
 void ff_mpadsp_init_mipsfpu(MPADSPContext *s);
 void ff_mpadsp_init_mipsdsp(MPADSPContext *s);
 
diff --git a/libavcodec/x86/mpegaudiodsp.c b/libavcodec/x86/mpegaudiodsp.c
index f46a5c4f3d..d646c6dbcb 100644
--- a/libavcodec/x86/mpegaudiodsp.c
+++ b/libavcodec/x86/mpegaudiodsp.c
@@ -239,10 +239,8 @@ DECL_IMDCT_BLOCKS(avx,avx)
 #endif
 #endif /* HAVE_X86ASM */
 
-av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
+av_cold void ff_mpadsp_init_x86_tabs(void)
 {
-av_unused int cpu_flags = av_get_cpu_flags();
-
 int i, j;
 for (j = 0; j < 4; j++) {
 for (i = 0; i < 40; i ++) {
@@ -256,6 +254,11 @@ av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
 mdct_win_sse[1][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
 }
 }
+}
+
+av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
+{
+av_unused int cpu_flags = av_get_cpu_flags();
 
 #if HAVE_6REGS && HAVE_SSE_INLINE
 if (INLINE_SSE(cpu_flags)) {

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

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

[FFmpeg-cvslog] avcodec/fft_template, fft_init_table: Make ff_fft_init() thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Nov 18 21:38:45 2020 +0100| [b9c1ab89078d862e0146c9d7ed277addd770e3a3] | 
committer: Andreas Rheinhardt

avcodec/fft_template, fft_init_table: Make ff_fft_init() thread-safe

Commit 1af615683e4a1a858407afbaa2fd686842da7e49 put initializing
the ff_fft_offsets_lut (which is typically used if FFT_FIXED_32)
behind an ff_thread_once() to make ff_fft_init() thread-safe; yet
there is a second place where said table may be initialized which
is not guarded by this AVOnce: ff_fft_init_mips(). MIPS uses this LUT
even for ordinary floating point FFTs, so that ff_fft_init() is not
thread-safe (on MIPS) for both 32bit fixed-point as well as
floating-point FFTs; e.g. ff_mdct_init() inherits this flaw and
therefore initializing e.g. the AAC decoders is not thread-safe (on
MIPS) despite them having FF_CODEC_CAP_INIT_CLEANUP set.

This commit fixes this by moving the AVOnce to fft_init_table.c and
using it to guard all initializations of ff_fft_offsets_lut.

(It is not that bad in practice, because every entry of
ff_fft_offsets_lut is never read during initialization and is only once
ever written to (namely to its final value); but even these are
conflicting actions which are (by definition) data races and lead to
undefined behaviour.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/fft_init_table.c | 24 
 libavcodec/fft_table.h  |  2 +-
 libavcodec/fft_template.c   | 12 +---
 libavcodec/mips/fft_mips.c  |  4 +---
 4 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/libavcodec/fft_init_table.c b/libavcodec/fft_init_table.c
index c488018f62..83e35ffb7c 100644
--- a/libavcodec/fft_init_table.c
+++ b/libavcodec/fft_init_table.c
@@ -51,6 +51,8 @@
  * @file
  * definitions and initialization of LUT table for FFT
  */
+#include "libavutil/thread.h"
+
 #include "libavcodec/fft_table.h"
 
 const int32_t ff_w_tab_sr[MAX_FFT_SIZE/(4*16)] = {
@@ -314,15 +316,29 @@ const int32_t ff_w_tab_sr[MAX_FFT_SIZE/(4*16)] = {
 
 uint16_t ff_fft_offsets_lut[21845];
 
-void ff_fft_lut_init(uint16_t *table, int off, int size, int *index)
+static void fft_lut_init(uint16_t *table, int off, int size, int *index)
 {
 if (size < 16) {
 table[*index] = off >> 2;
 (*index)++;
 }
 else {
-ff_fft_lut_init(table, off, size>>1, index);
-ff_fft_lut_init(table, off+(size>>1), size>>2, index);
-ff_fft_lut_init(table, off+3*(size>>2), size>>2, index);
+fft_lut_init(table, off,   size >> 1, index);
+fft_lut_init(table, off + (size >> 1), size >> 2, index);
+fft_lut_init(table, off + 3 * (size >> 2), size >> 2, index);
 }
 }
+
+static void fft_lut_init_start(void)
+{
+int n = 0;
+
+fft_lut_init(ff_fft_offsets_lut, 0, 1 << 17, );
+}
+
+void ff_fft_lut_init(void)
+{
+static AVOnce init_once = AV_ONCE_INIT;
+
+ff_thread_once(_once, fft_lut_init_start);
+}
diff --git a/libavcodec/fft_table.h b/libavcodec/fft_table.h
index ed0a6588b4..09df49f2b8 100644
--- a/libavcodec/fft_table.h
+++ b/libavcodec/fft_table.h
@@ -61,6 +61,6 @@
 
 extern const int32_t ff_w_tab_sr[];
 extern uint16_t ff_fft_offsets_lut[];
-void ff_fft_lut_init(uint16_t *table, int off, int size, int *index);
+void ff_fft_lut_init(void);
 
 #endif /* AVCODEC_FFT_TABLE_H */
diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
index 20a62e4290..8825e39f79 100644
--- a/libavcodec/fft_template.c
+++ b/libavcodec/fft_template.c
@@ -35,13 +35,6 @@
 
 #if FFT_FIXED_32
 #include "fft_table.h"
-
-static void av_cold fft_lut_init(void)
-{
-int n = 0;
-ff_fft_lut_init(ff_fft_offsets_lut, 0, 1 << 17, );
-}
-
 #else /* FFT_FIXED_32 */
 
 /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
@@ -236,10 +229,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int 
inverse)
 #endif
 
 #if FFT_FIXED_32
-{
-static AVOnce control = AV_ONCE_INIT;
-ff_thread_once(, fft_lut_init);
-}
+ff_fft_lut_init();
 #else /* FFT_FIXED_32 */
 #if FFT_FLOAT
 if (ARCH_AARCH64) ff_fft_init_aarch64(s);
diff --git a/libavcodec/mips/fft_mips.c b/libavcodec/mips/fft_mips.c
index 69abdc8a08..a6656d9650 100644
--- a/libavcodec/mips/fft_mips.c
+++ b/libavcodec/mips/fft_mips.c
@@ -500,9 +500,7 @@ static void ff_imdct_calc_mips(FFTContext *s, FFTSample 
*output, const FFTSample
 
 av_cold void ff_fft_init_mips(FFTContext *s)
 {
-int n=0;
-
-ff_fft_lut_init(ff_fft_offsets_lut, 0, 1 << 17, );
+ff_fft_lut_init();
 ff_init_ff_cos_tabs(17);
 
 #if HAVE_INLINE_ASM

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

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

[FFmpeg-cvslog] avcodec/mpegaudiodsp: Combine initializing float and int tables

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 15:53:34 2020 +0100| [5c45f7e15603c43e04747e5385d521ab6c8720ca] | 
committer: Andreas Rheinhardt

avcodec/mpegaudiodsp: Combine initializing float and int tables

This avoids code duplication in the functions used to initialize them
and allows to remove an AVOnce.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mpegaudiodsp.c  | 54 +++---
 libavcodec/mpegaudiodsp.h  |  3 ---
 libavcodec/mpegaudiodsp_template.c | 42 -
 3 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/libavcodec/mpegaudiodsp.c b/libavcodec/mpegaudiodsp.c
index 3cafca27bf..0a14ff549e 100644
--- a/libavcodec/mpegaudiodsp.c
+++ b/libavcodec/mpegaudiodsp.c
@@ -21,20 +21,66 @@
 #include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/thread.h"
+#include "mpegaudio.h"
 #include "mpegaudiodsp.h"
 #include "dct.h"
 #include "dct32.h"
 
-static AVOnce mpadsp_float_table_init = AV_ONCE_INIT;
-static AVOnce mpadsp_fixed_table_init = AV_ONCE_INIT;
+static AVOnce mpadsp_table_init = AV_ONCE_INIT;
+
+static av_cold void mpadsp_init_tabs(void)
+{
+int i, j;
+/* compute mdct windows */
+for (i = 0; i < 36; i++) {
+for (j = 0; j < 4; j++) {
+double d;
+
+if (j == 2 && i % 3 != 1)
+continue;
+
+d = sin(M_PI * (i + 0.5) / 36.0);
+if (j == 1) {
+if  (i >= 30) d = 0;
+else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
+else if (i >= 18) d = 1;
+} else if (j == 3) {
+if  (i <   6) d = 0;
+else if (i <  12) d = sin(M_PI * (i -  6 + 0.5) / 12.0);
+else if (i <  18) d = 1;
+}
+//merge last stage of imdct into the window coefficients
+d *= 0.5 * IMDCT_SCALAR / cos(M_PI * (2 * i + 19) / 72);
+
+if (j == 2) {
+ff_mdct_win_float[j][i/3] = d / (1 << 5);
+ff_mdct_win_fixed[j][i/3] = d / (1 << 5) * (1LL << 32) + 0.5;
+} else {
+int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
+ff_mdct_win_float[j][idx] = d / (1 << 5);
+ff_mdct_win_fixed[j][idx] = d / (1 << 5) * (1LL << 32) + 0.5;
+}
+}
+}
+
+/* NOTE: we do frequency inversion after the MDCT by changing
+the sign of the right window coefs */
+for (j = 0; j < 4; j++) {
+for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
+ff_mdct_win_float[j + 4][i] =  ff_mdct_win_float[j][i];
+ff_mdct_win_float[j + 4][i + 1] = -ff_mdct_win_float[j][i + 1];
+ff_mdct_win_fixed[j + 4][i] =  ff_mdct_win_fixed[j][i];
+ff_mdct_win_fixed[j + 4][i + 1] = -ff_mdct_win_fixed[j][i + 1];
+}
+}
+}
 
 av_cold void ff_mpadsp_init(MPADSPContext *s)
 {
 DCTContext dct;
 
 ff_dct_init(, 5, DCT_II);
-ff_thread_once(_float_table_init, _init_mpadsp_tabs_float);
-ff_thread_once(_fixed_table_init, _init_mpadsp_tabs_fixed);
+ff_thread_once(_table_init, _init_tabs);
 
 s->apply_window_float = ff_mpadsp_apply_window_float;
 s->apply_window_fixed = ff_mpadsp_apply_window_fixed;
diff --git a/libavcodec/mpegaudiodsp.h b/libavcodec/mpegaudiodsp.h
index 0e4352deab..28dcec576c 100644
--- a/libavcodec/mpegaudiodsp.h
+++ b/libavcodec/mpegaudiodsp.h
@@ -82,9 +82,6 @@ void ff_imdct36_blocks_float(float *out, float *buf, float 
*in,
 void ff_imdct36_blocks_fixed(int *out, int *buf, int *in,
  int count, int switch_point, int block_type);
 
-void ff_init_mpadsp_tabs_float(void);
-void ff_init_mpadsp_tabs_fixed(void);
-
 /** For SSE implementation, MDCT_BUF_SIZE/2 should be 128-bit aligned */
 #define MDCT_BUF_SIZE FFALIGN(36, 2*4)
 
diff --git a/libavcodec/mpegaudiodsp_template.c 
b/libavcodec/mpegaudiodsp_template.c
index e531f8a904..f8d0870df6 100644
--- a/libavcodec/mpegaudiodsp_template.c
+++ b/libavcodec/mpegaudiodsp_template.c
@@ -221,48 +221,6 @@ av_cold void RENAME(ff_mpa_synth_init)(MPA_INT *window)
 window[512+128+16*i+j] = window[64*i+48-j];
 }
 
-av_cold void RENAME(ff_init_mpadsp_tabs)(void)
-{
-int i, j;
-/* compute mdct windows */
-for (i = 0; i < 36; i++) {
-for (j = 0; j < 4; j++) {
-double d;
-
-if (j == 2 && i % 3 != 1)
-continue;
-
-d = sin(M_PI * (i + 0.5) / 36.0);
-if (j == 1) {
-if  (i >= 30) d = 0;
-else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
-else if (i >= 18) d = 1;
-} else if (j == 3) {
-if  (i <   6) d = 0;
-else if (i <  12) d = sin(M_PI * (i -  6 + 0.5) / 12.0);

[FFmpeg-cvslog] avcodec/motionpixels: Make decoder init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 17 10:50:01 2020 +0100| [af7acbb4b87ae44560dd4223b39c031c54923b63] | 
committer: Andreas Rheinhardt

avcodec/motionpixels: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motionpixels.c  | 12 ++--
 libavcodec/motionpixels_tablegen.h |  3 +--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 927f9fdc14..909299b5ef 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -19,6 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/thread.h"
+
+#include "config.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "bswapdsp.h"
@@ -65,6 +69,7 @@ static av_cold int mp_decode_end(AVCodecContext *avctx)
 
 static av_cold int mp_decode_init(AVCodecContext *avctx)
 {
+av_unused static AVOnce init_static_once = AV_ONCE_INIT;
 MotionPixelsContext *mp = avctx->priv_data;
 int w4 = (avctx->width  + 3) & ~3;
 int h4 = (avctx->height + 3) & ~3;
@@ -74,7 +79,6 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
 return AVERROR_INVALIDDATA;
 }
 
-motionpixels_tableinit();
 mp->avctx = avctx;
 ff_bswapdsp_init(>bdsp);
 mp->changes_map = av_mallocz_array(avctx->width, h4);
@@ -89,6 +93,10 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
 if (!mp->frame)
 return AVERROR(ENOMEM);
 
+#if !CONFIG_HARDCODED_TABLES
+ff_thread_once(_static_once, motionpixels_tableinit);
+#endif
+
 return 0;
 }
 
@@ -348,5 +356,5 @@ AVCodec ff_motionpixels_decoder = {
 .close  = mp_decode_end,
 .decode = mp_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/motionpixels_tablegen.h 
b/libavcodec/motionpixels_tablegen.h
index 9239b6a667..fd10c80cba 100644
--- a/libavcodec/motionpixels_tablegen.h
+++ b/libavcodec/motionpixels_tablegen.h
@@ -84,8 +84,7 @@ static av_cold void mp_build_rgb_yuv_table(YuvPixel *p)
 
 static av_cold void motionpixels_tableinit(void)
 {
-if (!mp_rgb_yuv_table[0].u)
-mp_build_rgb_yuv_table(mp_rgb_yuv_table);
+mp_build_rgb_yuv_table(mp_rgb_yuv_table);
 }
 #endif /* CONFIG_HARDCODED_TABLES */
 

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

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

[FFmpeg-cvslog] avcodec/motionpixels: Be more strict when parsing Huffman trees

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 29 10:41:01 2020 +0100| [3d95b1a8285240f150853d4a823bc225fd3f6544] | 
committer: Andreas Rheinhardt

avcodec/motionpixels: Be more strict when parsing Huffman trees

This ensures that the number of leafs in the Huffman tree equals the
number it is supposed to be and therefore ensures that the VLC tree is
complete, allowing us to remove checks.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 0bf153f883..4b9830fbed 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -133,7 +133,7 @@ static int mp_get_code(MotionPixelsContext *mp, 
GetBitContext *gb, int size, int
 if (mp_get_code(mp, gb, size, code + 1) < 0)
 return AVERROR_INVALIDDATA;
 }
-if (mp->current_codes_count >= MAX_HUFF_CODES) {
+if (mp->current_codes_count >= mp->codes_count) {
 av_log(mp->avctx, AV_LOG_ERROR, "too many codes\n");
 return AVERROR_INVALIDDATA;
 }

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

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

[FFmpeg-cvslog] avcodec/motionpixels: Use symbols table

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 29 10:56:32 2020 +0100| [cc18bcdd5204feff6724486f72fafcad15640362] | 
committer: Andreas Rheinhardt

avcodec/motionpixels: Use symbols table

If allows us to directly store the deltas in the VLC table and therefore
avoids a level of indirection.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motionpixels.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index a65250efe5..927f9fdc14 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -192,10 +192,8 @@ static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, 
int x, int y, const Yuv
 
 static av_always_inline int mp_get_vlc(MotionPixelsContext *mp, GetBitContext 
*gb)
 {
-int i;
-
-i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, 
mp->max_codes_bits, 1);
-return mp->codes[i].delta;
+return mp->vlc.table ? get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1)
+ : mp->codes[0].delta;
 }
 
 static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y)
@@ -322,9 +320,14 @@ static int mp_decode_frame(AVCodecContext *avctx,
 if (sz == 0)
 goto end;
 
-if (mp->codes_count > 1)
-if (init_vlc(>vlc, mp->max_codes_bits, mp->codes_count, 
>codes[0].size, sizeof(HuffCode), 1, >codes[0].code, sizeof(HuffCode), 
4, 0))
-goto end;
+if (mp->codes_count > 1) {
+ret = ff_init_vlc_sparse(>vlc, mp->max_codes_bits, mp->codes_count,
+ >codes[0].size,  sizeof(HuffCode), 1,
+ >codes[0].code,  sizeof(HuffCode), 4,
+ >codes[0].delta, sizeof(HuffCode), 1, 0);
+if (ret < 0)
+goto end;
+}
 mp_decode_frame_helper(mp, );
 ff_free_vlc(>vlc);
 

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

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

[FFmpeg-cvslog] avcodec/motionpixels: Don't check for errors for complete VLC

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 29 10:25:09 2020 +0100| [d3fba7480302ada9d75575ff6892fdbb9318f1ea] | 
committer: Andreas Rheinhardt

avcodec/motionpixels: Don't check for errors for complete VLC

The algorithm used here always creates a complete VLC, so it is
unnecessary to check this again.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motionpixels.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 4b9830fbed..a65250efe5 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -195,8 +195,6 @@ static av_always_inline int mp_get_vlc(MotionPixelsContext 
*mp, GetBitContext *g
 int i;
 
 i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, 
mp->max_codes_bits, 1);
-if (i < 0)
-return i;
 return mp->codes[i].delta;
 }
 

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

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

[FFmpeg-cvslog] avcodec/motionpixels: Only create VLC iff it is going to be used

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 29 09:46:34 2020 +0100| [e246ea2535da863be83d94c2da3248367f5c0684] | 
committer: Andreas Rheinhardt

avcodec/motionpixels: Only create VLC iff it is going to be used

If the Huffman tree consists of only one entry (which has length zero),
no tree is used at all for parsing as the VLC API currently can't handle
this. So it makes no sense to create a VLC in this case.

Commit 41b7389cade702383e59343561776f83bb26e17f added a check for
whether creating the VLC should be skipped, but it also skipped decoding
the packet and it used the wrong check: It checked max_codes_bits,
the maximum length of a code; but this value is only updated iff there is
more than one Huffman entry. So if there is only one Huffman entry, and
there was a previous frame with more than one entry, then a VLC was
created unnecessarily; yet if there was no previous frame with more than
one entry, then this frame will be skipped which is probably
spec-incompliant. I have no sample for the latter.

This commit improves the check to create a VLC iff it is going to be
used.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/motionpixels.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index b48200b017..0bf153f883 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -324,8 +324,7 @@ static int mp_decode_frame(AVCodecContext *avctx,
 if (sz == 0)
 goto end;
 
-if (mp->max_codes_bits <= 0)
-goto end;
+if (mp->codes_count > 1)
 if (init_vlc(>vlc, mp->max_codes_bits, mp->codes_count, 
>codes[0].size, sizeof(HuffCode), 1, >codes[0].code, sizeof(HuffCode), 
4, 0))
 goto end;
 mp_decode_frame_helper(mp, );

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

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

[FFmpeg-cvslog] avcodec/mimic: Cleanup generically upon init failure

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 13:34:57 2020 +0100| [3066b243e96f2dfa3fd405b2b89a8e8574e398dc] | 
committer: Andreas Rheinhardt

avcodec/mimic: Cleanup generically upon init failure

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mimic.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index 0f8103ef85..e91ba4353f 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -155,10 +155,8 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx)
 
 for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
 ctx->frames[i].f = av_frame_alloc();
-if (!ctx->frames[i].f) {
-mimic_decode_end(avctx);
+if (!ctx->frames[i].f)
 return AVERROR(ENOMEM);
-}
 }
 
 return 0;
@@ -460,5 +458,5 @@ AVCodec ff_mimic_decoder = {
 .decode= mimic_decode_frame,
 .capabilities  = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context),
-.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
+.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS | 
FF_CODEC_CAP_INIT_CLEANUP,
 };

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

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

[FFmpeg-cvslog] avcodec/mimic: Mark decoder as init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 13:41:41 2020 +0100| [97da1b4341a356d46e9b46f235f991a4de63195c] | 
committer: Andreas Rheinhardt

avcodec/mimic: Mark decoder as init-threadsafe

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/mimic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index e91ba4353f..7eed0729e8 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -458,5 +458,6 @@ AVCodec ff_mimic_decoder = {
 .decode= mimic_decode_frame,
 .capabilities  = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context),
-.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS | 
FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS |
+ FF_CODEC_CAP_INIT_CLEANUP | 
FF_CODEC_CAP_INIT_THREADSAFE,
 };

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

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

[FFmpeg-cvslog] avcodec/rv10: Make initializing static RV10 VLCs thread-safe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Nov 17 10:09:34 2020 +0100| [e9d06fef62d811828cf49c4d0c383ddacc22884d] | 
committer: Andreas Rheinhardt

avcodec/rv10: Make initializing static RV10 VLCs thread-safe

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/rv10.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index e594160fea..3a487a6b3e 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -28,6 +28,7 @@
 #include 
 
 #include "libavutil/imgutils.h"
+#include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "error_resilience.h"
@@ -463,11 +464,22 @@ static int rv20_decode_picture_header(RVDecContext *rv)
 return s->mb_width * s->mb_height - mb_pos;
 }
 
+static av_cold void rv10_init_static(void)
+{
+INIT_VLC_STATIC(_dc_lum, DC_VLC_BITS, 256,
+rv_lum_bits, 1, 1,
+rv_lum_code, 2, 2, 16384);
+INIT_VLC_STATIC(_dc_chrom, DC_VLC_BITS, 256,
+rv_chrom_bits, 1, 1,
+rv_chrom_code, 2, 2, 16388);
+ff_h263_decode_init_vlc();
+}
+
 static av_cold int rv10_decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 RVDecContext *rv = avctx->priv_data;
 MpegEncContext *s = >m;
-static int done = 0;
 int major_ver, minor_ver, micro_ver, ret;
 
 if (avctx->extradata_size < 8) {
@@ -525,18 +537,9 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 return ret;
 
 ff_h263dsp_init(>h263dsp);
-ff_h263_decode_init_vlc();
 
-/* init rv vlc */
-if (!done) {
-INIT_VLC_STATIC(_dc_lum, DC_VLC_BITS, 256,
-rv_lum_bits, 1, 1,
-rv_lum_code, 2, 2, 16384);
-INIT_VLC_STATIC(_dc_chrom, DC_VLC_BITS, 256,
-rv_chrom_bits, 1, 1,
-rv_chrom_code, 2, 2, 16388);
-done = 1;
-}
+/* init static VLCs */
+ff_thread_once(_static_once, rv10_init_static);
 
 return 0;
 }

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

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

[FFmpeg-cvslog] avcodec/tscc2: Mark tscc2 decoder as init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 09:53:00 2020 +0100| [a6423412c17e22ebec2823c83b991b0f8b0d30c9] | 
committer: Andreas Rheinhardt

avcodec/tscc2: Mark tscc2 decoder as init-threadsafe

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c
index 9fa28fe9fc..630e17522c 100644
--- a/libavcodec/tscc2.c
+++ b/libavcodec/tscc2.c
@@ -370,5 +370,5 @@ AVCodec ff_tscc2_decoder = {
 .close  = tscc2_decode_end,
 .decode = tscc2_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 };

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

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

[FFmpeg-cvslog] avcodec/smacker: Mark decoders as init-threadsafe

2020-11-24 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Nov 15 10:27:04 2020 +0100| [1463f9edcbdff88fd44dfe3bc17386c6b0488036] | 
committer: Andreas Rheinhardt

avcodec/smacker: Mark decoders as init-threadsafe

Both Smacker audio and video decoders don't use/modify any global state.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/smacker.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 6b1faec09e..504f20e9a2 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -732,7 +732,7 @@ AVCodec ff_smacker_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
 };
 
 AVCodec ff_smackaud_decoder = {
@@ -743,4 +743,5 @@ AVCodec ff_smackaud_decoder = {
 .init   = smka_decode_init,
 .decode = smka_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };

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

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

[FFmpeg-cvslog] avfilter/af_adenorm: add timeline and slice threading support

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 11:27:14 
2020 +0100| [68429b9465b53bbb64bf8f35ea601f7ec2ead407] | committer: Paul B Mahol

avfilter/af_adenorm: add timeline and slice threading support

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

 libavfilter/af_adenorm.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_adenorm.c b/libavfilter/af_adenorm.c
index e689fe556e..992a1fe56a 100644
--- a/libavfilter/af_adenorm.c
+++ b/libavfilter/af_adenorm.c
@@ -219,11 +219,34 @@ static int config_output(AVFilterLink *outlink)
 return 0;
 }
 
+typedef struct ThreadData {
+AVFrame *in, *out;
+} ThreadData;
+
+static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ADenormContext *s = ctx->priv;
+ThreadData *td = arg;
+AVFrame *out = td->out;
+AVFrame *in = td->in;
+const int start = (in->channels * jobnr) / nb_jobs;
+const int end = (in->channels * (jobnr+1)) / nb_jobs;
+
+for (int ch = start; ch < end; ch++) {
+s->filter(ctx, out->extended_data[ch],
+  in->extended_data[ch],
+  in->nb_samples);
+}
+
+return 0;
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
 ADenormContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
+ThreadData td;
 AVFrame *out;
 
 if (av_frame_is_writable(in)) {
@@ -238,11 +261,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 }
 
 s->level = exp(s->level_db / 20. * M_LN10);
-for (int ch = 0; ch < inlink->channels; ch++) {
-s->filter(ctx, out->extended_data[ch],
-  in->extended_data[ch],
-  in->nb_samples);
-}
+td.in = in; td.out = out;
+ctx->internal->execute(ctx, filter_channels, , NULL, 
FFMIN(inlink->channels,
+
ff_filter_get_nb_threads(ctx)));
+
 s->in_samples += in->nb_samples;
 
 if (out != in)
@@ -305,4 +327,6 @@ AVFilter ff_af_adenorm = {
 .outputs = adenorm_outputs,
 .priv_class  = _class,
 .process_command = process_command,
+.flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
+   AVFILTER_FLAG_SLICE_THREADS,
 };

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

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

[FFmpeg-cvslog] avfilter/af_asubboost: add timeline and slice threading support

2020-11-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Nov 24 10:00:34 
2020 +0100| [ee8ecc2730dadc8cdcd7be6e470d03a554f03b76] | committer: Paul B Mahol

avfilter/af_asubboost: add timeline and slice threading support

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

 libavfilter/af_asubboost.c | 72 +++---
 1 file changed, 49 insertions(+), 23 deletions(-)

diff --git a/libavfilter/af_asubboost.c b/libavfilter/af_asubboost.c
index feb1a8c068..7345d3b404 100644
--- a/libavfilter/af_asubboost.c
+++ b/libavfilter/af_asubboost.c
@@ -37,7 +37,7 @@ typedef struct ASubBoostContext {
 double a0, a1, a2;
 double b0, b1, b2;
 
-int write_pos;
+int *write_pos;
 int buffer_samples;
 
 AVFrame *w;
@@ -105,44 +105,42 @@ static int config_input(AVFilterLink *inlink)
 
 s->buffer = ff_get_audio_buffer(inlink, inlink->sample_rate / 10);
 s->w = ff_get_audio_buffer(inlink, 2);
-if (!s->buffer || !s->w)
+s->write_pos = av_calloc(inlink->channels, sizeof(*s->write_pos));
+if (!s->buffer || !s->w || !s->write_pos)
 return AVERROR(ENOMEM);
 
 return get_coeffs(ctx);
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+typedef struct ThreadData {
+AVFrame *in, *out;
+} ThreadData;
+
+static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
-AVFilterContext *ctx = inlink->dst;
-AVFilterLink *outlink = ctx->outputs[0];
 ASubBoostContext *s = ctx->priv;
-const double wet = s->wet_gain, dry = s->dry_gain, feedback = s->feedback, 
decay = s->decay;
+ThreadData *td = arg;
+AVFrame *out = td->out;
+AVFrame *in = td->in;
+const double wet = ctx->is_disabled ? 0. : s->wet_gain;
+const double dry = ctx->is_disabled ? 1. : s->dry_gain;
+const double feedback = s->feedback, decay = s->decay;
 const double b0 = s->b0;
 const double b1 = s->b1;
 const double b2 = s->b2;
 const double a1 = -s->a1;
 const double a2 = -s->a2;
-int write_pos;
-AVFrame *out;
+const int start = (in->channels * jobnr) / nb_jobs;
+const int end = (in->channels * (jobnr+1)) / nb_jobs;
+const int buffer_samples = s->buffer_samples;
 
-if (av_frame_is_writable(in)) {
-out = in;
-} else {
-out = ff_get_audio_buffer(outlink, in->nb_samples);
-if (!out) {
-av_frame_free();
-return AVERROR(ENOMEM);
-}
-av_frame_copy_props(out, in);
-}
-
-for (int ch = 0; ch < in->channels; ch++) {
+for (int ch = start; ch < end; ch++) {
 const double *src = (const double *)in->extended_data[ch];
 double *dst = (double *)out->extended_data[ch];
 double *buffer = (double *)s->buffer->extended_data[ch];
 double *w = (double *)s->w->extended_data[ch];
+int write_pos = s->write_pos[ch];
 
-write_pos = s->write_pos;
 for (int n = 0; n < in->nb_samples; n++) {
 double out_sample;
 
@@ -153,12 +151,37 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 buffer[write_pos] = buffer[write_pos] * decay + out_sample * 
feedback;
 dst[n] = src[n] * dry + buffer[write_pos] * wet;
 
-if (++write_pos >= s->buffer_samples)
+if (++write_pos >= buffer_samples)
 write_pos = 0;
 }
+
+s->write_pos[ch] = write_pos;
+}
+
+return 0;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+{
+AVFilterContext *ctx = inlink->dst;
+AVFilterLink *outlink = ctx->outputs[0];
+ThreadData td;
+AVFrame *out;
+
+if (av_frame_is_writable(in)) {
+out = in;
+} else {
+out = ff_get_audio_buffer(outlink, in->nb_samples);
+if (!out) {
+av_frame_free();
+return AVERROR(ENOMEM);
+}
+av_frame_copy_props(out, in);
 }
 
-s->write_pos = write_pos;
+td.in = in; td.out = out;
+ctx->internal->execute(ctx, filter_channels, , NULL, 
FFMIN(inlink->channels,
+
ff_filter_get_nb_threads(ctx)));
 
 if (out != in)
 av_frame_free();
@@ -171,6 +194,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 
 av_frame_free(>buffer);
 av_frame_free(>w);
+av_freep(>write_pos);
 }
 
 static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
@@ -229,4 +253,6 @@ AVFilter ff_af_asubboost = {
 .inputs = inputs,
 .outputs= outputs,
 .process_command = process_command,
+.flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
+   AVFILTER_FLAG_SLICE_THREADS,
 };

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

To unsubscribe, visit link above, or email

[FFmpeg-cvslog] avcodec: add SpeedHQ encoder

2020-11-24 Thread Jean-Baptiste Kempf
ffmpeg | branch: master | Jean-Baptiste Kempf  | Mon Nov  9 
12:25:02 2020 +0100| [052a5993adfc749b4283aac4ca0dec3087b7091a] | committer: 
Paul B Mahol

avcodec: add SpeedHQ encoder

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

 Changelog  |   1 +
 doc/general_contents.texi  |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/mpegutils.h |   1 +
 libavcodec/mpegvideo.h |   3 +
 libavcodec/mpegvideo_enc.c |  53 +++-
 libavcodec/speedhq.c   |   8 +-
 libavcodec/speedhqenc.c| 316 +
 libavcodec/speedhqenc.h|  48 +++
 libavcodec/version.h   |   4 +-
 11 files changed, 428 insertions(+), 10 deletions(-)

diff --git a/Changelog b/Changelog
index fcdabce2f2..8b2e17378c 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,7 @@ version :
 - NVDEC AV1 hwaccel
 - DXVA2/D3D11VA hardware accelerated AV1 decoding
 - speechnorm filter
+- SpeedHQ encoder
 
 
 version 4.3:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 7033816b5a..1be6f9b683 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -972,7 +972,7 @@ following image formats are supported:
 @item MPEG-4 part 2 Microsoft variant version 1  @tab @tab  X
 @item MPEG-4 part 2 Microsoft variant version 2  @tab  X  @tab  X
 @item MPEG-4 part 2 Microsoft variant version 3  @tab  X  @tab  X
-@item Newtek SpeedHQ   @tab @tab  X
+@item Newtek SpeedHQ   @tab  X  @tab  X
 @item Nintendo Gamecube THP video  @tab @tab  X
 @item NotchLC@tab @tab  X
 @item NuppelVideo/RTjpeg @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b4777be4d4..a6435c9e85 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -625,6 +625,7 @@ OBJS-$(CONFIG_SONIC_DECODER)   += sonic.o
 OBJS-$(CONFIG_SONIC_ENCODER)   += sonic.o
 OBJS-$(CONFIG_SONIC_LS_ENCODER)+= sonic.o
 OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o 
simple_idct.o
+OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o speedhqenc.o
 OBJS-$(CONFIG_SP5X_DECODER)+= sp5xdec.o
 OBJS-$(CONFIG_SRGC_DECODER)+= mscc.o
 OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8bdc0d6bf7..774d5670bf 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -297,6 +297,7 @@ extern AVCodec ff_snow_encoder;
 extern AVCodec ff_snow_decoder;
 extern AVCodec ff_sp5x_decoder;
 extern AVCodec ff_speedhq_decoder;
+extern AVCodec ff_speedhq_encoder;
 extern AVCodec ff_srgc_decoder;
 extern AVCodec ff_sunrast_encoder;
 extern AVCodec ff_sunrast_decoder;
diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
index 1ed21c19be..81f0b73bb1 100644
--- a/libavcodec/mpegutils.h
+++ b/libavcodec/mpegutils.h
@@ -125,6 +125,7 @@ enum OutputFormat {
 FMT_H261,
 FMT_H263,
 FMT_MJPEG,
+FMT_SPEEDHQ,
 };
 
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 29e692f245..974c71b6bd 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -444,6 +444,9 @@ typedef struct MpegEncContext {
 int inter_intra_pred;
 int mspel;
 
+/* SpeedHQ specific */
+int slice_start;
+
 /* decompression specific */
 GetBitContext gb;
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f16b26c9f2..7afc789ec0 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -51,6 +51,7 @@
 #include "mathops.h"
 #include "mpegutils.h"
 #include "mjpegenc.h"
+#include "speedhqenc.h"
 #include "msmpeg4.h"
 #include "pixblockdsp.h"
 #include "qpeldsp.h"
@@ -326,6 +327,15 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 break;
+case AV_CODEC_ID_SPEEDHQ:
+if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
+avctx->pix_fmt != AV_PIX_FMT_YUV422P &&
+avctx->pix_fmt != AV_PIX_FMT_YUV444P) {
+av_log(avctx, AV_LOG_ERROR,
+   "only YUV420/YUV422/YUV444 are supported (no alpha support 
yet)\n");
+return AVERROR(EINVAL);
+}
+break;
 default:
 if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
 av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
@@ -732,7 +742,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 //return -1;
 }
 
-if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id 
== AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG || 
s->codec_id==AV_CODEC_ID_AMV) {
+if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id 
== AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG || s->codec_id == 
AV_CODEC_ID_AMV || s->codec_id == AV_CODEC_ID_SPEEDHQ) {
 // (a + x * 3 

[FFmpeg-cvslog] avformat/av1: add support for passing through MP4/Matroska av1c

2020-11-24 Thread Jan Ekström
ffmpeg | branch: master | Jan Ekström  | Mon Nov 23 18:00:44 
2020 +0200| [4688017d9a1c2633c5888de5a0580d29e7680d54] | committer: Jan Ekström

avformat/av1: add support for passing through MP4/Matroska av1c

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

 libavformat/av1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/av1.c b/libavformat/av1.c
index 0cbffb1fd8..5512c4e0f7 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -375,6 +375,20 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t 
*buf, int size)
 if (size <= 0)
 return AVERROR_INVALIDDATA;
 
+if (buf[0] & 0x80) {
+// first bit is nonzero, the passed data does not consist purely of
+// OBUs. Expect that the data is already in AV1CodecConfigurationRecord
+// format.
+int config_record_version = buf[0] & 0x7f;
+if (config_record_version != 1 || size < 4) {
+return AVERROR_INVALIDDATA;
+}
+
+avio_write(pb, buf, size);
+
+return 0;
+}
+
 ret = avio_open_dyn_buf(_pb);
 if (ret < 0)
 return ret;

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

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

[FFmpeg-cvslog] avcodec/av1{dec,parser}: move to ff_cbs_read_extradata_from_codec

2020-11-24 Thread Jan Ekström
ffmpeg | branch: master | Jan Ekström  | Mon Nov 23 17:36:20 
2020 +0200| [8fbc139e6143297b8f88bc5145778787b64f4381] | committer: Jan Ekström

avcodec/av1{dec,parser}: move to ff_cbs_read_extradata_from_codec

This lets us re-utilize the extradata-related checks in the CBS
to add support for passing the AV1CodecConfigurationRecord
as extradata as-is without further filtering.

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

 libavcodec/av1_parser.c | 2 +-
 libavcodec/av1dec.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index 14826d816e..181ff3a1be 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -73,7 +73,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
 if (avctx->extradata_size && !s->parsed_extradata) {
 s->parsed_extradata = 1;
 
-ret = ff_cbs_read(s->cbc, td, avctx->extradata, avctx->extradata_size);
+ret = ff_cbs_read_extradata_from_codec(s->cbc, td, avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n");
 }
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index c1967f03bd..ce051d4e6d 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -616,8 +616,9 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 return ret;
 
 if (avctx->extradata && avctx->extradata_size) {
-ret = ff_cbs_read(s->cbc, >current_obu, avctx->extradata,
-  avctx->extradata_size);
+ret = ff_cbs_read_extradata_from_codec(s->cbc,
+   >current_obu,
+   avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
 return ret;

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

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

[FFmpeg-cvslog] cbs: Add function to read extradata from an AVCodecContext

2020-11-24 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Nov 23 17:53:57 
2020 +| [7bacf60ae5df75954a538563d19f6001aa598b3f] | committer: Jan Ekström

cbs: Add function to read extradata from an AVCodecContext

This is useful in decoders and parsers, matching the way that bitstream
filters read extradata from AVCodecParameters.

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

 libavcodec/cbs.c | 77 
 libavcodec/cbs.h | 11 
 2 files changed, 50 insertions(+), 38 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index c8c526ab12..f98531e131 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -223,66 +223,67 @@ static int cbs_fill_fragment_data(CodedBitstreamFragment 
*frag,
 return 0;
 }
 
-int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
-  CodedBitstreamFragment *frag,
-  const AVCodecParameters *par)
+static int cbs_read_data(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ AVBufferRef *buf,
+ const uint8_t *data, size_t size,
+ int header)
 {
 int err;
 
-err = cbs_fill_fragment_data(frag, par->extradata,
- par->extradata_size);
-if (err < 0)
-return err;
-
-err = ctx->codec->split_fragment(ctx, frag, 1);
-if (err < 0)
-return err;
-
-return cbs_read_fragment_content(ctx, frag);
-}
-
-int ff_cbs_read_packet(CodedBitstreamContext *ctx,
-   CodedBitstreamFragment *frag,
-   const AVPacket *pkt)
-{
-int err;
-
-if (pkt->buf) {
-frag->data_ref = av_buffer_ref(pkt->buf);
+if (buf) {
+frag->data_ref = av_buffer_ref(buf);
 if (!frag->data_ref)
 return AVERROR(ENOMEM);
 
-frag->data  = pkt->data;
-frag->data_size = pkt->size;
+frag->data  = (uint8_t *)data;
+frag->data_size = size;
 
 } else {
-err = cbs_fill_fragment_data(frag, pkt->data, pkt->size);
+err = cbs_fill_fragment_data(frag, data, size);
 if (err < 0)
 return err;
 }
 
-err = ctx->codec->split_fragment(ctx, frag, 0);
+err = ctx->codec->split_fragment(ctx, frag, header);
 if (err < 0)
 return err;
 
 return cbs_read_fragment_content(ctx, frag);
 }
 
-int ff_cbs_read(CodedBitstreamContext *ctx,
-CodedBitstreamFragment *frag,
-const uint8_t *data, size_t size)
+int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
+  CodedBitstreamFragment *frag,
+  const AVCodecParameters *par)
 {
-int err;
+return cbs_read_data(ctx, frag, NULL,
+ par->extradata,
+ par->extradata_size, 1);
+}
 
-err = cbs_fill_fragment_data(frag, data, size);
-if (err < 0)
-return err;
+int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ const AVCodecContext *avctx)
+{
+return cbs_read_data(ctx, frag, NULL,
+ avctx->extradata,
+ avctx->extradata_size, 1);
+}
 
-err = ctx->codec->split_fragment(ctx, frag, 0);
-if (err < 0)
-return err;
+int ff_cbs_read_packet(CodedBitstreamContext *ctx,
+   CodedBitstreamFragment *frag,
+   const AVPacket *pkt)
+{
+return cbs_read_data(ctx, frag, pkt->buf,
+ pkt->data, pkt->size, 0);
+}
 
-return cbs_read_fragment_content(ctx, frag);
+int ff_cbs_read(CodedBitstreamContext *ctx,
+CodedBitstreamFragment *frag,
+const uint8_t *data, size_t size)
+{
+return cbs_read_data(ctx, frag, NULL,
+ data, size, 0);
 }
 
 static int cbs_write_unit_data(CodedBitstreamContext *ctx,
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 635921b11e..3fd0a0ef33 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -262,6 +262,17 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
   CodedBitstreamFragment *frag,
   const AVCodecParameters *par);
 
+/**
+ * Read the extradata bitstream found in a codec context into a
+ * fragment, then split into units and decompose.
+ *
+ * This acts identical to ff_cbs_read_extradata() for the case where
+ * you already have a codec context.
+ */
+int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ const AVCodecContext *avctx);
+
 /**
  * Read the data bitstream from a packet into a fragment, then
  * split into units and decompose.


[FFmpeg-cvslog] avcodec/cbs_av1: add support for standard MP4/Matroska extradata

2020-11-24 Thread Jan Ekström
ffmpeg | branch: master | Jan Ekström  | Mon Nov 23 19:37:38 
2020 +0200| [a66d1779bb1b33cc54b359b142dcbcd2827fa282] | committer: Jan Ekström

avcodec/cbs_av1: add support for standard MP4/Matroska extradata

This way API clients can just pass the AV1CodecConfigurationRecord
as extradata as-is without further filtering.

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

 libavcodec/cbs_av1.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 9badfe31e4..9ae2f59872 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -758,6 +758,39 @@ static int cbs_av1_split_fragment(CodedBitstreamContext 
*ctx,
 goto fail;
 }
 
+if (header && size && data[0] & 0x80) {
+// first bit is nonzero, the extradata does not consist purely of
+// OBUs. Expect MP4/Matroska AV1CodecConfigurationRecord
+int config_record_version = data[0] & 0x7f;
+
+if (config_record_version != 1) {
+av_log(ctx->log_ctx, AV_LOG_ERROR,
+   "Unknown version %d of AV1CodecConfigurationRecord "
+   "found!\n",
+   config_record_version);
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+if (size <= 4) {
+if (size < 4) {
+av_log(ctx->log_ctx, AV_LOG_WARNING,
+   "Undersized AV1CodecConfigurationRecord v%d found!\n",
+   config_record_version);
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+goto success;
+}
+
+// In AV1CodecConfigurationRecord v1, actual OBUs start after
+// four bytes. Thus set the offset as required for properly
+// parsing them.
+data += 4;
+size -= 4;
+}
+
 while (size > 0) {
 AV1RawOBUHeader header;
 uint64_t obu_size;
@@ -803,6 +836,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext 
*ctx,
 size -= obu_length;
 }
 
+success:
 err = 0;
 fail:
 ctx->trace_enable = trace;

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

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