[FFmpeg-devel] [PATCH 21/40] avcodec/atrac1: Avoid indirection when calling float dsp function

2020-09-13 Thread Andreas Rheinhardt
Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/atrac1.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index 4cfb1061c5..b2a2d5e6a1 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -80,7 +80,8 @@ typedef struct AT1Ctx {
 DECLARE_ALIGNED(32, float, high)[512];
 float*  bands[3];
 FFTContext  mdct_ctx[3];
-AVFloatDSPContext   *fdsp;
+void (*vector_fmul_window)(float *dst, const float *src0,
+   const float *src1, const float *win, int len);
 } AT1Ctx;
 
 /** size of the transform in samples in the long mode for each QMF band */
@@ -140,8 +141,8 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
 at1_imdct(q, >spec[pos], >spectrum[0][ref_pos + start_pos], 
nbits, band_num);
 
 /* overlap and window */
-q->fdsp->vector_fmul_window(>bands[band_num][start_pos], 
prev_buf,
-   >spectrum[0][ref_pos + start_pos], 
ff_sine_32, 16);
+q->vector_fmul_window(>bands[band_num][start_pos], prev_buf,
+  >spectrum[0][ref_pos + start_pos], 
ff_sine_32, 16);
 
 prev_buf = >spectrum[0][ref_pos+start_pos + 16];
 start_pos += block_size;
@@ -324,8 +325,6 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx)
 ff_mdct_end(>mdct_ctx[1]);
 ff_mdct_end(>mdct_ctx[2]);
 
-av_freep(>fdsp);
-
 return 0;
 }
 
@@ -333,6 +332,7 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx)
 static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 {
 AT1Ctx *q = avctx->priv_data;
+AVFloatDSPContext *fdsp;
 int ret;
 
 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
@@ -360,10 +360,11 @@ static av_cold int atrac1_decode_init(AVCodecContext 
*avctx)
 
 ff_atrac_generate_tables();
 
-q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-if (!q->fdsp) {
+fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+if (!fdsp)
 return AVERROR(ENOMEM);
-}
+q->vector_fmul_window = fdsp->vector_fmul_window;
+av_free(fdsp);
 
 q->bands[0] = q->low;
 q->bands[1] = q->mid;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 18/40] avcodec/alacenc: Don't free unnecessarily

2020-09-13 Thread Andreas Rheinhardt
The init function of the ALAC encoder calls its own close function
if a call to ff_lpc_init() fails; yet nothing has been allocated before
that point (except extradata which is freed generically) and ff_lpc_init()
can be expected to clean up after itself on error (the documentation does
not say anything to the contrary and the current implementation can only
fail if the only allocation fails, so there is nothing to clean up on
error anyway), so this is unnecessary.

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

diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index fc5fa270e6..9d135d1350 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -535,10 +535,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
  avctx->bits_per_raw_sample);
 
 avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!avctx->extradata) {
-ret = AVERROR(ENOMEM);
-goto error;
-}
+if (!avctx->extradata)
+return AVERROR(ENOMEM);
 avctx->extradata_size = ALAC_EXTRADATA_SIZE;
 
 alac_extradata = avctx->extradata;
@@ -566,8 +564,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
avctx->min_prediction_order);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 
 s->min_prediction_order = avctx->min_prediction_order;
@@ -578,8 +575,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
avctx->max_prediction_order);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 
 s->max_prediction_order = avctx->max_prediction_order;
@@ -591,8 +587,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx, AV_LOG_ERROR,
"invalid prediction orders: min=%d max=%d\n",
s->min_prediction_order, s->max_prediction_order);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 
 s->avctx = avctx;
@@ -600,13 +595,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((ret = ff_lpc_init(>lpc_ctx, avctx->frame_size,
s->max_prediction_order,
FF_LPC_TYPE_LEVINSON)) < 0) {
-goto error;
+return ret;
 }
 
 return 0;
-error:
-alac_encode_close(avctx);
-return ret;
 }
 
 static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 24/40] avcodec/av1dec: Fix segfault upon allocation error

2020-09-13 Thread Andreas Rheinhardt
The decoder's close function simply presumed that some AVFrames have
been successfully allocated although this can of course fail.

Signed-off-by: Andreas Rheinhardt 
---
Once could btw return immediately as soon as one encounters an AVFrame
that is NULL, because these frames are the first things to be allocated
in init (and in the same order as they are freed); yet I wanted to avoid
this additional dependency.

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

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index bd8acdaafe..4b89bd83a0 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -388,11 +388,11 @@ static av_cold int av1_decode_free(AVCodecContext *avctx)
 AV1DecContext *s = avctx->priv_data;
 
 for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
-if (s->ref[i].tf.f->buf[0])
+if (s->ref[i].tf.f && s->ref[i].tf.f->buf[0])
 av1_frame_unref(avctx, >ref[i]);
 av_frame_free(>ref[i].tf.f);
 }
-if (s->cur_frame.tf.f->buf[0])
+if (s->cur_frame.tf.f && s->cur_frame.tf.f->buf[0])
 av1_frame_unref(avctx, >cur_frame);
 av_frame_free(>cur_frame.tf.f);
 
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 27/40] avcodec/avrndec: Fix memleak on error

2020-09-13 Thread Andreas Rheinhardt
If ff_codec_open2_recursive() fails, the already allocated
AVCodecContext leaks. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP
flag.

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

diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index a4b6fadfc8..c5a60acd4f 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -170,5 +170,5 @@ AVCodec ff_avrn_decoder = {
 .close  = end,
 .decode = decode_frame,
 .max_lowres = 3,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 26/40] avcodec/avrndec: Check allocation for success

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/avrndec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index f4ec490de5..a4b6fadfc8 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -54,6 +54,8 @@ static av_cold int init(AVCodecContext *avctx)
 }
 
 a->mjpeg_avctx = avcodec_alloc_context3(codec);
+if (!a->mjpeg_avctx)
+return AVERROR(ENOMEM);
 
 av_dict_set(_opt, "threads", "1", 0); // Is this needed ?
 a->mjpeg_avctx->refcounted_frames = 1;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 33/40] avcodec/dxa: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dxa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c
index f6edc03e1a..3f62eac252 100644
--- a/libavcodec/dxa.c
+++ b/libavcodec/dxa.c
@@ -343,7 +343,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 c->dsize = avctx->width * avctx->height * 2;
 c->decomp_buf = av_malloc(c->dsize + DECOMP_BUF_PADDING);
 if (!c->decomp_buf) {
-av_frame_free(>prev);
 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
 return AVERROR(ENOMEM);
 }
@@ -371,4 +370,5 @@ AVCodec ff_dxa_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 23/40] avcodec/atrac3: Avoid indirection when calling float dsp function

2020-09-13 Thread Andreas Rheinhardt
Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

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

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index ef2f8428dc..dc68e507aa 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -111,7 +111,8 @@ typedef struct ATRAC3Context {
 
 AtracGCContextgainc_ctx;
 FFTContextmdct_ctx;
-AVFloatDSPContext *fdsp;
+void (*vector_fmul)(float *dst, const float *src0, const float *src1,
+int len);
 } ATRAC3Context;
 
 static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE];
@@ -144,7 +145,7 @@ static void imlt(ATRAC3Context *q, float *input, float 
*output, int odd_band)
 q->mdct_ctx.imdct_calc(>mdct_ctx, output, input);
 
 /* Perform windowing on the output. */
-q->fdsp->vector_fmul(output, output, mdct_window, MDCT_SIZE);
+q->vector_fmul(output, output, mdct_window, MDCT_SIZE);
 }
 
 /*
@@ -194,7 +195,6 @@ static av_cold int atrac3_decode_close(AVCodecContext 
*avctx)
 
 av_freep(>units);
 av_freep(>decoded_bytes_buffer);
-av_freep(>fdsp);
 
 ff_mdct_end(>mdct_ctx);
 
@@ -874,6 +874,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
 int version, delay, samples_per_frame, frame_factor;
 const uint8_t *edata_ptr = avctx->extradata;
 ATRAC3Context *q = avctx->priv_data;
+AVFloatDSPContext *fdsp;
 
 if (avctx->channels < MIN_CHANNELS || avctx->channels > MAX_CHANNELS) {
 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
@@ -997,12 +998,15 @@ static av_cold int atrac3_decode_init(AVCodecContext 
*avctx)
 }
 
 ff_atrac_init_gain_compensation(>gainc_ctx, 4, 3);
-q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+if (!fdsp)
+return AVERROR(ENOMEM);
+q->vector_fmul = fdsp->vector_fmul;
+av_free(fdsp);
 
 q->units = av_mallocz_array(avctx->channels, sizeof(*q->units));
-if (!q->units || !q->fdsp) {
+if (!q->units)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 31/40] avcodec/cngenc: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cngenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index 8f23b7555a..b622d7bbda 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -58,10 +58,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx)
 return ret;
 p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32));
 p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef));
-if (!p->samples32 || !p->ref_coef) {
-cng_encode_close(avctx);
+if (!p->samples32 || !p->ref_coef)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -113,4 +111,5 @@ AVCodec ff_comfortnoise_encoder = {
 .close  = cng_encode_close,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
  AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 28/40] avcodec/c93: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/c93.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/c93.c b/libavcodec/c93.c
index e1808150b8..7e3bfdbc72 100644
--- a/libavcodec/c93.c
+++ b/libavcodec/c93.c
@@ -63,10 +63,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 s->pictures[0] = av_frame_alloc();
 s->pictures[1] = av_frame_alloc();
-if (!s->pictures[0] || !s->pictures[1]) {
-decode_end(avctx);
+if (!s->pictures[0] || !s->pictures[1])
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -269,5 +267,5 @@ AVCodec ff_c93_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 30/40] avcodec/cngenc: Replace av_free() by av_freep() in close function

2020-09-13 Thread Andreas Rheinhardt
This avoids leaving pointers to already freed memory in memory.

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

diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index e185c4a40a..8f23b7555a 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -37,8 +37,8 @@ static av_cold int cng_encode_close(AVCodecContext *avctx)
 {
 CNGContext *p = avctx->priv_data;
 ff_lpc_end(>lpc);
-av_free(p->samples32);
-av_free(p->ref_coef);
+av_freep(>samples32);
+av_freep(>ref_coef);
 return 0;
 }
 
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 29/40] avcodec/cfhdenc: Fix leaks on allocation errors

2020-09-13 Thread Andreas Rheinhardt
The CineForm HD encoder attempts to allocate several buffers in its init
function; yet if only some of these allocations succeed, the
successfully allocated buffers leak. This is fixed by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

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

diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 776b6da235..5554baefa3 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -919,4 +919,5 @@ AVCodec ff_cfhd_encoder = {
   AV_PIX_FMT_GBRAP12,
   AV_PIX_FMT_NONE
 },
+.caps_internal= FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 20/40] avcodec/atrac1: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/atrac1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index 9ecd49273d..4cfb1061c5 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -353,7 +353,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 (ret = ff_mdct_init(>mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) ||
 (ret = ff_mdct_init(>mdct_ctx[2], 9, 1, -1.0/ (1 << 15 {
 av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
-atrac1_decode_end(avctx);
 return ret;
 }
 
@@ -363,7 +362,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 
 q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 if (!q->fdsp) {
-atrac1_decode_end(avctx);
 return AVERROR(ENOMEM);
 }
 
@@ -393,4 +391,5 @@ AVCodec ff_atrac1_decoder = {
 .capabilities   = AV_CODEC_CAP_DR1,
 .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
   AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 19/40] avcodec/atrac1: Check allocation of AVFloatDSPContext

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/atrac1.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index a8c8c91bcc..9ecd49273d 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -362,6 +362,10 @@ static av_cold int atrac1_decode_init(AVCodecContext 
*avctx)
 ff_atrac_generate_tables();
 
 q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+if (!q->fdsp) {
+atrac1_decode_end(avctx);
+return AVERROR(ENOMEM);
+}
 
 q->bands[0] = q->low;
 q->bands[1] = q->mid;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 22/40] avcodec/atrac3: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/atrac3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 067aa23f1f..ef2f8428dc 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -977,7 +977,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
 /* initialize the MDCT transform */
 if ((ret = ff_mdct_init(>mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
-av_freep(>decoded_bytes_buffer);
 return ret;
 }
 
@@ -1002,7 +1001,6 @@ static av_cold int atrac3_decode_init(AVCodecContext 
*avctx)
 
 q->units = av_mallocz_array(avctx->channels, sizeof(*q->units));
 if (!q->units || !q->fdsp) {
-atrac3_decode_close(avctx);
 return AVERROR(ENOMEM);
 }
 
@@ -1021,6 +1019,7 @@ AVCodec ff_atrac3_decoder = {
 .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
 .sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
 AV_SAMPLE_FMT_NONE },
+.caps_internal= FF_CODEC_CAP_INIT_CLEANUP,
 };
 
 AVCodec ff_atrac3al_decoder = {
@@ -1035,4 +1034,5 @@ AVCodec ff_atrac3al_decoder = {
 .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
 .sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
 AV_SAMPLE_FMT_NONE },
+.caps_internal= FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 25/40] avcodec/av1dec: Remove redundant second free

2020-09-13 Thread Andreas Rheinhardt
The AV1 decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set and yet
the decoder's close function is called manually on some error paths.
This is unnecessary and has been removed in this commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/av1dec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 4b89bd83a0..1a9764db55 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -482,7 +482,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
 s->ref[i].tf.f = av_frame_alloc();
 if (!s->ref[i].tf.f) {
-av1_decode_free(avctx);
 av_log(avctx, AV_LOG_ERROR,
"Failed to allocate reference frame buffer %d.\n", i);
 return AVERROR(ENOMEM);
@@ -491,7 +490,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 
 s->cur_frame.tf.f = av_frame_alloc();
 if (!s->cur_frame.tf.f) {
-av1_decode_free(avctx);
 av_log(avctx, AV_LOG_ERROR,
"Failed to allocate current frame buffer.\n");
 return AVERROR(ENOMEM);
@@ -506,7 +504,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
   avctx->extradata_size);
 if (ret < 0) {
 av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
-goto end;
+return ret;
 }
 
 seq = ((CodedBitstreamAV1Context 
*)(s->cbc->priv_data))->sequence_header;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 38/40] avcodec/ffv1enc: Fix memleaks on init failure

2020-09-13 Thread Andreas Rheinhardt
The FFV1 encoder has so far not cleaned up after itself in this case;
but it can be done easily by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

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

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 97dc15eac9..611b250e96 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1354,4 +1354,5 @@ AVCodec ff_ffv1_encoder = {
 .defaults   = ffv1_defaults,
 #endif
 .priv_class = _class,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 40/40] avcodec/ffwavesynth: Cleanup generically after init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ffwavesynth.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c
index d92bb38c45..c99bac90ea 100644
--- a/libavcodec/ffwavesynth.c
+++ b/libavcodec/ffwavesynth.c
@@ -323,13 +323,11 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
 r = wavesynth_parse_extradata(avc);
 if (r < 0) {
 av_log(avc, AV_LOG_ERROR, "Invalid intervals definitions.\n");
-goto fail;
+return r;
 }
 ws->sin = av_malloc(sizeof(*ws->sin) << SIN_BITS);
-if (!ws->sin) {
-r = AVERROR(ENOMEM);
-goto fail;
-}
+if (!ws->sin)
+return AVERROR(ENOMEM);
 for (i = 0; i < 1 << SIN_BITS; i++)
 ws->sin[i] = floor(32767 * sin(2 * M_PI * i / (1 << SIN_BITS)));
 ws->dither_state = MKTAG('D','I','T','H');
@@ -340,11 +338,6 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
 wavesynth_seek(ws, 0);
 avc->sample_fmt = AV_SAMPLE_FMT_S16;
 return 0;
-
-fail:
-av_freep(>inter);
-av_freep(>sin);
-return r;
 }
 
 static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts,
@@ -476,4 +469,5 @@ AVCodec ff_ffwavesynth_decoder = {
 .close  = wavesynth_close,
 .decode = wavesynth_decode,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 37/40] avcodec/ffv1: Fix segfaults on allocation error

2020-09-13 Thread Andreas Rheinhardt
When allocating FFV1 slice contexts fails, ff_ffv1_init_slice_contexts()
frees everything that it has allocated, yet it does not reset the
counter for the number of allocated slice contexts. This inconsistent
state leads to segfaults lateron in ff_ffv1_close(), because said
function presumes that the slice contexts have been allocated.
Fix this by making sure that the number of slice contexts on error is
consistent (namely zero).

(This issue only affected the FFV1 decoder, because the encoder does not
clean up after itself on init failure.)

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ffv1.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 93cec14244..5b52849400 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -115,12 +115,11 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f)
 
 av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 {
-int i;
+int i, max_slice_count = f->num_h_slices * f->num_v_slices;
 
-f->max_slice_count = f->num_h_slices * f->num_v_slices;
-av_assert0(f->max_slice_count > 0);
+av_assert0(max_slice_count > 0);
 
-for (i = 0; i < f->max_slice_count; i++) {
+for (i = 0; i < max_slice_count; i++) {
 int sx  = i % f->num_h_slices;
 int sy  = i / f->num_h_slices;
 int sxs = f->avctx->width  *  sx  / f->num_h_slices;
@@ -152,6 +151,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 goto memfail;
 }
 }
+f->max_slice_count = max_slice_count;
 return 0;
 
 memfail:
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 39/40] avcodec/ffv1: Simplify cleanup after allocation failure

2020-09-13 Thread Andreas Rheinhardt
Now that ff_ffv1_close() for both the FFV1 encoder and decoder,
the code contained therein can be used to free the partially allocated
slice contexts if allocating the slice contexts failed. One just has to
set the correct number of slice contexts on error. This allows to remove
the code for freeing partially allocated slice contexts in
ff_ffv1_init_slice_contexts().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ffv1.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 5b52849400..1c580c3b49 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -119,7 +119,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 
 av_assert0(max_slice_count > 0);
 
-for (i = 0; i < max_slice_count; i++) {
+for (i = 0; i < max_slice_count;) {
 int sx  = i % f->num_h_slices;
 int sy  = i / f->num_h_slices;
 int sxs = f->avctx->width  *  sx  / f->num_h_slices;
@@ -131,7 +131,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 if (!fs)
 goto memfail;
 
-f->slice_context[i] = fs;
+f->slice_context[i++] = fs;
 memcpy(fs, f, sizeof(*fs));
 memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
 
@@ -144,22 +144,14 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
   sizeof(*fs->sample_buffer));
 fs->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES *
 sizeof(*fs->sample_buffer32));
-if (!fs->sample_buffer || !fs->sample_buffer32) {
-av_freep(>sample_buffer);
-av_freep(>sample_buffer32);
-av_freep(>slice_context[i]);
+if (!fs->sample_buffer || !fs->sample_buffer32)
 goto memfail;
-}
 }
 f->max_slice_count = max_slice_count;
 return 0;
 
 memfail:
-while(--i >= 0) {
-av_freep(>slice_context[i]->sample_buffer);
-av_freep(>slice_context[i]->sample_buffer32);
-av_freep(>slice_context[i]);
-}
+f->max_slice_count = i;
 return AVERROR(ENOMEM);
 }
 
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH 2/2] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-13 Thread Mark Reid
On Sun., Sep. 13, 2020, 4:04 p.m. Mark Reid,  wrote:

>
>
> On Sun, Sep 13, 2020 at 8:55 AM Michael Niedermayer 
> wrote:
>
>> On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
>> > From: Mark Reid 
>> >
>> > ---
>> >  libswscale/input.c  | 12 +---
>> >  tests/ref/fate/filter-pixfmts-scale |  8 
>> >  2 files changed, 9 insertions(+), 11 deletions(-)
>>
>> Can you provide some tests that show that this is better ?
>> Iam asking that because some of the numbers in some of the code
>> (i dont remember which) where tuned to give more accurate overall results
>>
>> an example for tests would be converting from A->B->A then compare to the
>> orig
>>
>> thx
>>
>>
> Hopefully i can explain this clearly!
>
> It's easier to see the error if you run a black image through the old
> conversion.
> zero values don't get mapped to zero. (attached sample image)
>
> ffmpeg -i 4x4_zero.exr -pix_fmt rgb48le -f rawvideo 4x4_zero.rawvideo
> The image should be rgb 0, 0, 0  everywhere but instead it's 353, 0, 407
>
>
> I think this is a error in fixed point rounding, the issue is basically
> boils down to
>
> 128 << 8 != 257 << 7
> and
> 16 << 8  != 33 << 7
>
> https://en.wikipedia.org/wiki/YUV#Studio_swing_for_BT.601
> the 8 bit rgb to yuv formula is
>
> Y = ry*r + gy*g + by*b  + 16
> U = ru*r + gu*g + bu*b + 128
> V = rv*r + gv*g + bv*b + 128
>
> I think the studio swing offsets at the end are calculated wrong in the
> old code.
> (257 << (RGB2YUV_SHIFT + bpc - 9)))
> 257 is correct for 8 bit rounding but not for 16-bit.
>
> the 257 i believe is from (128 << 1) + 1
> the +1 is for rounding
>
> for rounding 16-bit (128 << 9) + 1 = 0x10001
>
> therefore I think the correct rounding any bit depth with the old formula
> would be (untested)
> (((128 << (bpc - 7)) + 1) << (RGB2YUV_SHIFT-1) )
>
> I just simplified it to
> (0x10001 << (RGB2YUV_SHIFT - 1))
>
> The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.
>

I'm still not sure if I'm correct about all this. The rounding stuff
doesn't make 100% sense to me. But this is all I've gathered from reading
the code.



>
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> Everything should be made as simple as possible, but not simpler.
>> -- Albert Einstein
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 35/40] avcodec/ac3enc_float, eac3enc: Fix leaks on init error

2020-09-13 Thread Andreas Rheinhardt
The AC-3 encoders (both floating- as well as fixed-point) as well as
the EAC-3 encoder share code: All use ff_ac3_encode_init() as well as
ff_ac3_encode_close(). Until ee726e777b851cdd4e28cdab36b38f0c39e35ea9
ff_ac3_encode_init() called ff_ac3_encode_close() to clean up on error.
Said commit removed this and instead set the FF_CODEC_CAP_INIT_CLEANUP
flag; but it did the latter only for the fixed-point AC-3 encoder and
not for the other two users of ff_ac3_encode_init(). This caused any
already allocated buffer to leak upon a subsequent error for the two
other encoders.

This commit fixes this by adding the FF_CODEC_CAP_INIT_CLEANUP flag
to the other two encoders using ff_ac3_encode_init().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3enc_float.c | 1 +
 libavcodec/eac3enc.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index 1f3111af0e..99863a9722 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -153,4 +153,5 @@ AVCodec ff_ac3_encoder = {
 .supported_samplerates = ff_ac3_sample_rate_tab,
 .channel_layouts = ff_ac3_channel_layouts,
 .defaults= ac3_defaults,
+.caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 6a90571e56..8e1032f268 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -266,4 +266,5 @@ AVCodec ff_eac3_encoder = {
 .supported_samplerates = ff_ac3_sample_rate_tab,
 .channel_layouts = ff_ac3_channel_layouts,
 .defaults= ac3_defaults,
+.caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 36/40] avcodec/escape130: Cleanup generically on init failure

2020-09-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/escape130.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c
index 1dd7eedd74..a6fda901de 100644
--- a/libavcodec/escape130.c
+++ b/libavcodec/escape130.c
@@ -128,9 +128,6 @@ static av_cold int escape130_decode_init(AVCodecContext 
*avctx)
 s->buf1  = av_malloc(avctx->width * avctx->height * 3 / 2);
 s->buf2  = av_malloc(avctx->width * avctx->height * 3 / 2);
 if (!s->old_y_avg || !s->buf1 || !s->buf2) {
-av_freep(>old_y_avg);
-av_freep(>buf1);
-av_freep(>buf2);
 av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
 return AVERROR(ENOMEM);
 }
@@ -358,4 +355,5 @@ AVCodec ff_escape130_decoder = {
 .close  = escape130_decode_close,
 .decode = escape130_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 34/40] avcodec/ac3enc_template: Don't free uninitialized pointers on error

2020-09-13 Thread Andreas Rheinhardt
The ac3 encoders (fixed- and floating-point AC-3 as well as the EAC-3
encoder) all allocate an array whose elements are pointers to other
buffers. The array is not zeroed initially so that if an allocation of
one of the subbuffers fails, the other pointers are uninitialized.
This causes problems when cleaning, so zero the array initially.

(Only the fixed-point AC-3 encoder was affected by this, because
the other two don't clean up at all in case of errors during init.)

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

diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 985b35e5b6..b85fe51ef5 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -42,7 +42,7 @@ int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
 int ch;
 
 if (!FF_ALLOC_TYPED_ARRAY(s->windowed_samples, AC3_WINDOW_SIZE) ||
-!FF_ALLOC_TYPED_ARRAY(s->planar_samples,   s->channels))
+!FF_ALLOCZ_TYPED_ARRAY(s->planar_samples,  s->channels))
 return AVERROR(ENOMEM);
 
 for (ch = 0; ch < s->channels; ch++) {
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 32/40] avcodec/dsicinvideo: Remove redundant code for freeing

2020-09-13 Thread Andreas Rheinhardt
The dsicinvideo decoder already has the FF_CODEC_CAP_INIT_CLEANUP flag
set, so it is unnecessary to directly clean up some already allocated
buffers in case another one could not be allocated in the init function,
as all buffers will be freed anyway later in the decoder's close
function.

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

diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c
index 7f74808e6d..52f660fb51 100644
--- a/libavcodec/dsicinvideo.c
+++ b/libavcodec/dsicinvideo.c
@@ -58,7 +58,6 @@ static av_cold int allocate_buffers(CinVideoContext *cin)
 cin->bitmap_table[i] = av_mallocz(cin->bitmap_size);
 if (!cin->bitmap_table[i]) {
 av_log(cin->avctx, AV_LOG_ERROR, "Can't allocate bitmap 
buffers.\n");
-destroy_buffers(cin);
 return AVERROR(ENOMEM);
 }
 }
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 17/40] avcodec/alacenc: Remove redundant code to free extradata

2020-09-13 Thread Andreas Rheinhardt
It is already freed generically for encoders.

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

diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 804cc7b17b..fc5fa270e6 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -498,8 +498,6 @@ static av_cold int alac_encode_close(AVCodecContext *avctx)
 {
 AlacEncodeContext *s = avctx->priv_data;
 ff_lpc_end(>lpc_ctx);
-av_freep(>extradata);
-avctx->extradata_size = 0;
 return 0;
 }
 
-- 
2.25.1

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

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

[FFmpeg-devel] libx265 Closed Caption Support Development

2020-09-13 Thread Gray Capo
Hello,
 We would like to offer a bounty or a donation to assist in getting Closed 
Captioining support for libx265 ffmpeg working. See original ticket:  #8677 
(HEVC libx265 removes Closed caption) – FFmpeg

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
#8677 (HEVC libx265 removes Closed caption) – FFmpeg


 |

 |

 |


This feature is required by many heading impared persons. Is anyone available 
to assist?
Thank you,GrayC



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

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

[FFmpeg-devel] [PATCH] avfilter/vf_premultiply: add missing AV_PIX_FMT_YUVA444P12

2020-09-13 Thread mindmark
From: Mark Reid 

query_formats says its supported, but is missing from switch statement leading 
to segfault

---
 libavfilter/vf_premultiply.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index 7e5b2aa97f..e051cadac0 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -546,6 +546,7 @@ static int filter_frame(AVFilterContext *ctx,
 case AV_PIX_FMT_YUV444P10:
 case AV_PIX_FMT_YUVA444P10:
 case AV_PIX_FMT_YUV444P12:
+case AV_PIX_FMT_YUVA444P12:
 case AV_PIX_FMT_YUV444P14:
 case AV_PIX_FMT_YUV444P16:
 case AV_PIX_FMT_YUVA444P16:
@@ -597,6 +598,7 @@ static int filter_frame(AVFilterContext *ctx,
 case AV_PIX_FMT_YUV444P10:
 case AV_PIX_FMT_YUVA444P10:
 case AV_PIX_FMT_YUV444P12:
+case AV_PIX_FMT_YUVA444P12:
 case AV_PIX_FMT_YUV444P14:
 case AV_PIX_FMT_YUV444P16:
 case AV_PIX_FMT_YUVA444P16:
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix max_transform_hierarchy_depth_inter/intra

2020-09-13 Thread Xiang, Haihao
On Fri, 2020-09-04 at 10:37 +0800, Linjie Fu wrote:
> On Thu, Sep 3, 2020 at 1:32 PM Xiang, Haihao  wrote:
> > 
> > On Mon, 2020-04-13 at 13:06 +, Fu, Linjie wrote:
> > > > From: ffmpeg-devel  On Behalf Of
> > > > Mark Thompson
> > > > Sent: Monday, April 13, 2020 20:20
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix
> > > > max_transform_hierarchy_depth_inter/intra
> > > > 
> > > > On 13/04/2020 05:32, Linjie Fu wrote:
> > > > > Set the max_transform_hierarchy_depth_inter/intra to 2 by default
> > > > > based on the Programmer's Reference Manuals (PRM) in [1].
> > > > > 
> > > > > Intel Encoder only supports 2 levels of quad-tree. That is:
> > > > > - max_transform_hierarchy_depth_inter/intra <= 2.
> > > > > 
> > > > > [1] <
> > > > > https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-
> > > > 
> > > > kbl-vol10-hevc.pdf>
> > > > > 
> > > > > Signed-off-by: Linjie Fu 
> > > > > ---
> > > > > Fixed value for intel platform, makes more sense on TGL+ platform.
> > > > > (If conflict with other driver capability, we may add query support
> > > > >  later)
> > > > >  libavcodec/vaapi_encode_h265.c | 5 +++--
> > > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/libavcodec/vaapi_encode_h265.c
> > > > 
> > > > b/libavcodec/vaapi_encode_h265.c
> > > > > index cd48545..d6cb82a 100644
> > > > > --- a/libavcodec/vaapi_encode_h265.c
> > > > > +++ b/libavcodec/vaapi_encode_h265.c
> > > > > @@ -445,8 +445,9 @@ static int
> > > > 
> > > > vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> > > > >  sps->log2_min_luma_transform_block_size_minus2   = 0;
> > > > >  sps->log2_diff_max_min_luma_transform_block_size = 3;
> > > > >  // Full transform hierarchy allowed (2-5).
> > > > > -sps->max_transform_hierarchy_depth_inter = 3;
> > > > > -sps->max_transform_hierarchy_depth_intra = 3;
> > > > > +// Default to 2 based on Programmer's Reference Manuals of Intel
> > > > 
> > > > graphics
> > > > > +sps->max_transform_hierarchy_depth_inter = 2;
> > > > > +sps->max_transform_hierarchy_depth_intra = 2;
> > > > >  // AMP works.
> > > > >  sps->amp_enabled_flag = 1;
> > > > >  // SAO and temporal MVP do not work.
> > > > > 
> > > > 
> > > > I don't much like the idea of changing this based on a value in a Kaby
> > > > Lake
> > > > document given that the current value hasn't had any problems on Kaby
> > > > Lake.
> > > > Can you explain the benefits of changing this?
> > > 
> > > It fixes the encoding issue for HEVC on gen12+ platform.
> > > We didn't notice this either, until it triggers gpu hang for encoding on
> > > Tiger
> > > Lake (gen12).
> > > 
> > > > Can you confirm that it continues to work on all the other currently-
> > > > working
> > > > platforms?
> > > > 
> > > 
> > > Yes, we set up CI and runs full-round tests for conformance and catch
> > > regression on different
> > > platforms(CFL/CML/ICL/KBL/SKL).
> > > 
> > > Identical fix has been merged in gstreamer-vaapi, no regression is
> > > detected on
> > > other platforms.
> > > 
> > 
> > 
https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/282/diffs?commit_id=17d82e14e78af901f1cd7f2344e173ad6ae6a8a6
> > 
> > Hi Mark,
> > 
> > Till now we didn't see regression with Linjie's patch, do you have any other
> > concern on Linjie's patch?
> > 
> 
> Also ping for this, since TGL has been announced recently.

Ping again. Could anyone help to review and merge this patch if no 
moreconcerns? 

Thanks
Haihao


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

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

Re: [FFmpeg-devel] [PATCH 2/2] lavfi/sendcmd: correct the option flags dump

2020-09-13 Thread myp...@gmail.com
On Sun, Sep 13, 2020 at 6:30 PM Paul B Mahol  wrote:
>
> On Sun, Sep 13, 2020 at 12:40:45PM +0800, Jun Zhao wrote:
> > From: Jun Zhao 
> >
> > correct the option flags dump for sendcmd/asendcmd.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  libavfilter/f_sendcmd.c | 26 --
> >  1 file changed, 16 insertions(+), 10 deletions(-)
> >
> > diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
> > index 6b02669..5e4c891 100644
> > --- a/libavfilter/f_sendcmd.c
> > +++ b/libavfilter/f_sendcmd.c
> > @@ -103,14 +103,6 @@ typedef struct SendCmdContext {
> >  } SendCmdContext;
> >
> >  #define OFFSET(x) offsetof(SendCmdContext, x)
> > -#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | 
> > AV_OPT_FLAG_VIDEO_PARAM
> > -static const AVOption options[] = {
> > -{ "commands", "set commands", OFFSET(commands_str), 
> > AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> > -{ "c","set commands", OFFSET(commands_str), 
> > AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> > -{ "filename", "set commands file",  OFFSET(commands_filename), 
> > AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> > -{ "f","set commands file",  OFFSET(commands_filename), 
> > AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> > -{ NULL }
> > -};
>
> Cant you use macro somehow?, because you are duplicating most of lines/code.
>
Will try to remove the redundant, thx
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-13 Thread Mark Reid
On Sun, Sep 13, 2020 at 8:55 AM Michael Niedermayer 
wrote:

> On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
> > From: Mark Reid 
> >
> > ---
> >  libswscale/input.c  | 12 +---
> >  tests/ref/fate/filter-pixfmts-scale |  8 
> >  2 files changed, 9 insertions(+), 11 deletions(-)
>
> Can you provide some tests that show that this is better ?
> Iam asking that because some of the numbers in some of the code
> (i dont remember which) where tuned to give more accurate overall results
>
> an example for tests would be converting from A->B->A then compare to the
> orig
>
> thx
>
>
Hopefully i can explain this clearly!

It's easier to see the error if you run a black image through the old
conversion.
zero values don't get mapped to zero. (attached sample image)

ffmpeg -i 4x4_zero.exr -pix_fmt rgb48le -f rawvideo 4x4_zero.rawvideo
The image should be rgb 0, 0, 0  everywhere but instead it's 353, 0, 407


I think this is a error in fixed point rounding, the issue is basically
boils down to

128 << 8 != 257 << 7
and
16 << 8  != 33 << 7

https://en.wikipedia.org/wiki/YUV#Studio_swing_for_BT.601
the 8 bit rgb to yuv formula is

Y = ry*r + gy*g + by*b  + 16
U = ru*r + gu*g + bu*b + 128
V = rv*r + gv*g + bv*b + 128

I think the studio swing offsets at the end are calculated wrong in the old
code.
(257 << (RGB2YUV_SHIFT + bpc - 9)))
257 is correct for 8 bit rounding but not for 16-bit.

the 257 i believe is from (128 << 1) + 1
the +1 is for rounding

for rounding 16-bit (128 << 9) + 1 = 0x10001

therefore I think the correct rounding any bit depth with the old formula
would be (untested)
(((128 << (bpc - 7)) + 1) << (RGB2YUV_SHIFT-1) )

I just simplified it to
(0x10001 << (RGB2YUV_SHIFT - 1))

The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.


>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Everything should be made as simple as possible, but not simpler.
> -- Albert Einstein
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


4x4_zero.exr
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-13 Thread Rémi Achard
---
 libavformat/mxf.h|  1 +
 libavformat/mxfdec.c | 32 +++-
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index fc587f19f0..3fb3c6d74d 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -49,6 +49,7 @@ enum MXFMetadataSetType {
 TaggedValue,
 TapeDescriptor,
 AVCSubDescriptor,
+JPEG2000PictureSubDescriptor,
 };
 
 enum MXFFrameLayout {
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6f6e8d586c..c94876804c 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -325,9 +325,11 @@ static const uint8_t mxf_encrypted_essence_container[] 
= { 0x06,0x0e,0x2b,0x
 static const uint8_t mxf_random_index_pack_key[]   = { 
0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 
};
 static const uint8_t mxf_sony_mpeg4_extradata[]= { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 
};
 static const uint8_t mxf_avid_project_name[]   = { 
0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf 
};
-static const uint8_t mxf_jp2k_rsiz[]   = { 
0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 
};
+static const uint8_t mxf_jp2k_rsiz[]   = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 
};
 static const uint8_t mxf_indirect_value_utf16le[]  = { 
0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01
 };
 static const uint8_t mxf_indirect_value_utf16be[]  = { 
0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01
 };
+static const uint8_t mxf_subdescriptor_array_smpte[]   = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 
};
+static const uint8_t mxf_subdescriptor_array_interop[] = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 
};
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
@@ -855,15 +857,19 @@ static int mxf_read_cryptographic_context(void *arg, 
AVIOContext *pb, int tag, i
 
 static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
 {
-*count = avio_rb32(pb);
-av_free(*refs);
-*refs = av_calloc(*count, sizeof(UID));
+int local_count;
+
+local_count = avio_rb32(pb);
+*refs = av_realloc_array(*refs, *count + local_count, sizeof(UID));
+
 if (!*refs) {
 *count = 0;
 return AVERROR(ENOMEM);
 }
 avio_skip(pb, 4); /* useless size of objects, always 16 according to specs 
*/
-avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID));
+avio_read(pb, (uint8_t *)(*refs)[*count], local_count * sizeof(UID));
+*count += local_count;
+
 return 0;
 }
 
@@ -1272,6 +1278,11 @@ static int mxf_read_generic_descriptor(void *arg, 
AVIOContext *pb, int tag, int
 rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
 descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
 }
+if (IS_KLV_KEY(uid, mxf_subdescriptor_array_smpte)
+ || IS_KLV_KEY(uid, mxf_subdescriptor_array_interop)) {
+return mxf_read_strong_ref_array(pb, 
>sub_descriptors_refs,
+ 
>sub_descriptors_count);
+}
 break;
 }
 return 0;
@@ -2498,6 +2509,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 }
 }
 
+if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) {
+MXFDescriptor *desc = NULL;
+for (k = 0; k < descriptor->sub_descriptors_count; k++) {
+if ((desc = mxf_resolve_strong_ref(mxf, 
>sub_descriptors_refs[k], JPEG2000PictureSubDescriptor))) {
+st->codecpar->format = desc->pix_fmt;
+break;
+}
+}
+}
+
 if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
 st->codecpar->format = descriptor->pix_fmt;
 if (st->codecpar->format == AV_PIX_FMT_NONE) {
@@ -2753,6 +2774,7 @@ static const MXFMetadataReadTableEntry 
mxf_metadata_read_table[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* 
VANC/VBI - SMPTE 436M */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* 
MPEG2AudioDescriptor */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* DC 
Timed Text Descriptor */
+{ { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00 
}, mxf_read_generic_descriptor, 

[FFmpeg-devel] [PATCH 1/2] avcodec/wmalosslessdec: Check remaining space before padding and channel residue

2020-09-13 Thread Michael Niedermayer
Fixes: Timeout (1101sec -> 0.4sec)
Fixes: 
24491/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5725337036783616

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/wmalosslessdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 725e811070..b8d0f6220d 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -932,6 +932,8 @@ static int decode_subframe(WmallDecodeCtx *s)
 s->do_lpc = 0;
 }
 
+if (get_bits_left(>gb) < 1)
+return AVERROR_INVALIDDATA;
 
 if (get_bits1(>gb))
 padding_zeroes = get_bits(>gb, 5);
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/mv30: Check remaining mask in decode_inter()

2020-09-13 Thread Michael Niedermayer
Fixes: timeout (too long -> 4sec)
Fixes: 
25129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5642089713631232

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mv30.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index c83ba7ffbd..0dcfef23e0 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -531,8 +531,13 @@ static int decode_inter(AVCodecContext *avctx, 
GetBitContext *gb,
 for (int x = 0; x < avctx->width; x += 16) {
 if (cnt >= 4)
 cnt = 0;
-if (cnt == 0)
+if (cnt == 0) {
+if (get_bits_left() < 8) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
 flags = get_bits(, 8);
+}
 
 dst[0] = frame->data[0] + linesize[0] * y + x;
 dst[1] = frame->data[0] + linesize[0] * y + x + 8;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/4 v2] ffmpeg: move A/V non-streamcopy initialization to a later point

2020-09-13 Thread Jan Ekström
- For video, this means a single initialization point in do_video_out.
- For audio we unfortunately need to do it in two places just
  before the buffer sink is utilized (if av_buffersink_get_samples
  would still work according to its specification after a call to
  avfilter_graph_request_oldest was made, we could at least remove
  the one in transcode_step).

Other adjustments to make things work:
- As the AVFrame PTS adjustment to encoder time base needs the encoder
  to be initialized, so it is now moved to do_{video,audio}_out,
  right after the encoder has been initialized. Due to this,
  the additional parameter in do_video_out is removed as it is no
  longer necessary.
---
 fftools/ffmpeg.c | 112 ---
 1 file changed, 77 insertions(+), 35 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 54802a8ec3..8658dc0ca4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -938,6 +938,28 @@ early_exit:
 return float_pts;
 }
 
+static int init_output_stream(OutputStream *ost, char *error, int error_len);
+
+static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+{
+int ret = AVERROR_BUG;
+char error[1024] = {0};
+
+if (ost->initialized)
+return 0;
+
+ret = init_output_stream(ost, error, sizeof(error));
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
+   ost->file_index, ost->index, error);
+
+if (fatal)
+exit_program(1);
+}
+
+return ret;
+}
+
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
@@ -949,6 +971,8 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
 pkt.data = NULL;
 pkt.size = 0;
 
+adjust_frame_pts_to_encoder_tb(of, ost, frame);
+
 if (!check_recording_time(ost))
 return;
 
@@ -1083,8 +1107,7 @@ static void do_subtitle_out(OutputFile *of,
 
 static void do_video_out(OutputFile *of,
  OutputStream *ost,
- AVFrame *next_picture,
- double sync_ipts)
+ AVFrame *next_picture)
 {
 int ret, format_video_sync;
 AVPacket pkt;
@@ -1094,10 +1117,14 @@ static void do_video_out(OutputFile *of,
 int nb_frames, nb0_frames, i;
 double delta, delta0;
 double duration = 0;
+double sync_ipts = AV_NOPTS_VALUE;
 int frame_size = 0;
 InputStream *ist = NULL;
 AVFilterContext *filter = ost->filter->filter;
 
+init_output_stream_wrapper(ost, 1);
+sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture);
+
 if (ost->source_index >= 0)
 ist = input_streams[ost->source_index];
 
@@ -1431,28 +1458,6 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 }
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
-
-static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
-{
-int ret = AVERROR_BUG;
-char error[1024] = {0};
-
-if (ost->initialized)
-return 0;
-
-ret = init_output_stream(ost, error, sizeof(error));
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
-   ost->file_index, ost->index, error);
-
-if (fatal)
-exit_program(1);
-}
-
-return ret;
-}
-
 static void finish_output_stream(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -1489,7 +1494,17 @@ static int reap_filters(int flush)
 continue;
 filter = ost->filter->filter;
 
-init_output_stream_wrapper(ost, 1);
+/*
+ * Unlike video, with audio the audio frame size matters.
+ * Currently we are fully reliant on the lavfi filter chain to
+ * do the buffering deed for us, and thus the frame size parameter
+ * needs to be set accordingly. Where does one get the required
+ * frame size? From the initialized AVCodecContext of an audio
+ * encoder. Thus, if we have gotten to an audio stream, initialize
+ * the encoder earlier than receiving the first AVFrame.
+ */
+if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
+init_output_stream_wrapper(ost, 1);
 
 if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) 
{
 return AVERROR(ENOMEM);
@@ -1497,7 +1512,6 @@ static int reap_filters(int flush)
 filtered_frame = ost->filtered_frame;
 
 while (1) {
-double float_pts = AV_NOPTS_VALUE; // this is identical to 
filtered_frame.pts but with higher precision
 ret = av_buffersink_get_frame_flags(filter, filtered_frame,
AV_BUFFERSINK_FLAG_NO_REQUEST);
 if (ret < 0) {
@@ -1506,7 +1520,7 @@ static int reap_filters(int flush)
"Error in 

[FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: move AVFrame time base adjustment into a function

2020-09-13 Thread Jan Ekström
This will have to be called later for video down the line.
---
 fftools/ffmpeg.c | 69 ++--
 1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cb7644de6a..54802a8ec3 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -897,6 +897,47 @@ static int check_recording_time(OutputStream *ost)
 return 1;
 }
 
+static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
+ AVFrame *frame)
+{
+double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
+if (!frame || frame->pts == AV_NOPTS_VALUE ||
+!ost->filter || !ost->filter->graph->graph)
+goto early_exit;
+
+AVFilterContext *filter = ost->filter->filter;
+AVCodecContext *enc = ost->enc_ctx;
+
+int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
+AVRational filter_tb = av_buffersink_get_time_base(filter);
+AVRational tb = enc->time_base;
+int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
+
+tb.den <<= extra_bits;
+float_pts =
+av_rescale_q(frame->pts, filter_tb, tb) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
+float_pts /= 1 << extra_bits;
+// avoid exact midoints to reduce the chance of rounding differences, this 
can be removed in case the fps code is changed to work with integers
+float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
+
+frame->pts =
+av_rescale_q(frame->pts, filter_tb, enc->time_base) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
+
+early_exit:
+
+if (debug_ts) {
+av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f 
time_base:%d/%d\n",
+   frame ? av_ts2str(frame->pts) : "NULL",
+   frame ? av_ts2timestr(frame->pts, >time_base) : "NULL",
+   float_pts,
+   enc->time_base.num, enc->time_base.den);
+}
+
+return float_pts;
+}
+
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
@@ -1473,37 +1514,15 @@ static int reap_filters(int flush)
 av_frame_unref(filtered_frame);
 continue;
 }
-if (filtered_frame->pts != AV_NOPTS_VALUE) {
-int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
-AVRational filter_tb = av_buffersink_get_time_base(filter);
-AVRational tb = enc->time_base;
-int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
-
-tb.den <<= extra_bits;
-float_pts =
-av_rescale_q(filtered_frame->pts, filter_tb, tb) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
-float_pts /= 1 << extra_bits;
-// avoid exact midoints to reduce the chance of rounding 
differences, this can be removed in case the fps code is changed to work with 
integers
-float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
-
-filtered_frame->pts =
-av_rescale_q(filtered_frame->pts, filter_tb, 
enc->time_base) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
-}
+
+float_pts = adjust_frame_pts_to_encoder_tb(of, ost,
+   filtered_frame);
 
 switch (av_buffersink_get_type(filter)) {
 case AVMEDIA_TYPE_VIDEO:
 if (!ost->frame_aspect_ratio.num)
 enc->sample_aspect_ratio = 
filtered_frame->sample_aspect_ratio;
 
-if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s 
exact:%f time_base:%d/%d\n",
-av_ts2str(filtered_frame->pts), 
av_ts2timestr(filtered_frame->pts, >time_base),
-float_pts,
-enc->time_base.num, enc->time_base.den);
-}
-
 do_video_out(of, ost, filtered_frame, float_pts);
 break;
 case AVMEDIA_TYPE_AUDIO:
-- 
2.26.2

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mobiclip: add missing flush

2020-09-13 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 12:13:23PM -0300, James Almer wrote:
> On 9/10/2020 5:39 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavcodec/mobiclip.c | 9 +
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
> > index d147eddbae..c296ce3c78 100644
> > --- a/libavcodec/mobiclip.c
> > +++ b/libavcodec/mobiclip.c
> > @@ -1389,6 +1389,14 @@ static int mobiclip_decode(AVCodecContext *avctx, 
> > void *data,
> >  return 0;
> >  }
> >  
> > +static void mobiclip_flush(AVCodecContext *avctx)
> > +{
> > +MobiClipContext *s = avctx->priv_data;
> > +
> > +for (int i = 0; i < 6; i++)
> > +av_frame_unref(s->pic[i]);
> 
> Shouldn't you also zero s->current_pic? It's used as an index for this
> array.

Not really required as it is not important, it cycles/wraps around.

> 
> > +}
> > +
> >  static av_cold int mobiclip_close(AVCodecContext *avctx)
> >  {
> >  MobiClipContext *s = avctx->priv_data;
> > @@ -1421,6 +1429,7 @@ AVCodec ff_mobiclip_decoder = {
> >  .priv_data_size = sizeof(MobiClipContext),
> >  .init   = mobiclip_init,
> >  .decode = mobiclip_decode,
> > +.flush  = mobiclip_flush,
> >  .close  = mobiclip_close,
> >  .capabilities   = AV_CODEC_CAP_DR1,
> >  };
> > 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/4] ffmpeg: move AVFrame time base adjustment into a function

2020-09-13 Thread Michael Niedermayer
On Sun, Sep 13, 2020 at 09:07:09PM +0300, Jan Ekström wrote:
> On Sun, Sep 13, 2020 at 7:14 PM Michael Niedermayer
>  wrote:
> >
> > On Sun, Sep 13, 2020 at 01:26:20PM +0300, Jan Ekström wrote:
> > > This will have to be called later for video down the line.
> > > ---
> > >  fftools/ffmpeg.c | 77 
> > >  1 file changed, 52 insertions(+), 25 deletions(-)
> >
> > This affects the output, example:
> > ./ffmpeg -i mm-small.mpg -vf idet  -v 50 -bitexact -f null - 2>&1 | grep 
> > idet
> >
> 
> Apparently this was due to the leftover logging I left there. This
> also happens with vanilla FFmpeg if you add such logging to
> reap_filters.
> 
> In other words, just this following diff appears to fix it.

That was not what i expected to cause this but in fact you are correct.
this is a issue with log repeation removial changes from interspaced
debug messages. So this is resolved

for the record as others might run into this
use "-v repeat+50" instead of -v 50 to avoid this

thx

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

You can kill me, but you cannot change the truth.


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

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

[FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-13 Thread Rémi Achard
---
 libavformat/mxf.h|  1 +
 libavformat/mxfdec.c | 20 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index fc587f19f0..3fb3c6d74d 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -49,6 +49,7 @@ enum MXFMetadataSetType {
 TaggedValue,
 TapeDescriptor,
 AVCSubDescriptor,
+JPEG2000PictureSubDescriptor,
 };
 
 enum MXFFrameLayout {
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6f6e8d586c..8eac7fc944 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -325,9 +325,11 @@ static const uint8_t mxf_encrypted_essence_container[] 
= { 0x06,0x0e,0x2b,0x
 static const uint8_t mxf_random_index_pack_key[]   = { 
0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 
};
 static const uint8_t mxf_sony_mpeg4_extradata[]= { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 
};
 static const uint8_t mxf_avid_project_name[]   = { 
0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf 
};
-static const uint8_t mxf_jp2k_rsiz[]   = { 
0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 
};
+static const uint8_t mxf_jp2k_rsiz[]   = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 
};
 static const uint8_t mxf_indirect_value_utf16le[]  = { 
0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01
 };
 static const uint8_t mxf_indirect_value_utf16be[]  = { 
0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01
 };
+static const uint8_t mxf_subdescriptor_array_smpte[]   = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 
};
+static const uint8_t mxf_subdescriptor_array_interop[] = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 
};
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
@@ -1272,6 +1274,11 @@ static int mxf_read_generic_descriptor(void *arg, 
AVIOContext *pb, int tag, int
 rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
 descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
 }
+if (IS_KLV_KEY(uid, mxf_subdescriptor_array_smpte)
+ || IS_KLV_KEY(uid, mxf_subdescriptor_array_interop)) {
+mxf_read_strong_ref_array(pb, >sub_descriptors_refs,
+  >sub_descriptors_count);
+}
 break;
 }
 return 0;
@@ -2498,6 +2505,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 }
 }
 
+if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) {
+MXFDescriptor *desc = NULL;
+for (k = 0; k < descriptor->sub_descriptors_count; k++) {
+if ((desc = mxf_resolve_strong_ref(mxf, 
>sub_descriptors_refs[k], JPEG2000PictureSubDescriptor))) {
+st->codecpar->format = desc->pix_fmt;
+break;
+}
+}
+}
+
 if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
 st->codecpar->format = descriptor->pix_fmt;
 if (st->codecpar->format == AV_PIX_FMT_NONE) {
@@ -2753,6 +2770,7 @@ static const MXFMetadataReadTableEntry 
mxf_metadata_read_table[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* 
VANC/VBI - SMPTE 436M */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* 
MPEG2AudioDescriptor */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* DC 
Timed Text Descriptor */
+{ { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00 
}, mxf_read_generic_descriptor, sizeof(MXFDescriptor), 
JPEG2000PictureSubDescriptor }, /* JPEG2000PictureSubDescriptor */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 
}, mxf_read_track, sizeof(MXFTrack), Track }, /* Static Track */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 
}, mxf_read_track, sizeof(MXFTrack), Track }, /* Generic Track */
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 
}, mxf_read_timecode_component, sizeof(MXFTimecodeComponent), TimecodeComponent 
},
-- 
2.24.0

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

To unsubscribe, visit link above, or email

Re: [FFmpeg-devel] [PATCH 2/4] ffmpeg: move AVFrame time base adjustment into a function

2020-09-13 Thread Jan Ekström
On Sun, Sep 13, 2020 at 7:14 PM Michael Niedermayer
 wrote:
>
> On Sun, Sep 13, 2020 at 01:26:20PM +0300, Jan Ekström wrote:
> > This will have to be called later for video down the line.
> > ---
> >  fftools/ffmpeg.c | 77 
> >  1 file changed, 52 insertions(+), 25 deletions(-)
>
> This affects the output, example:
> ./ffmpeg -i mm-small.mpg -vf idet  -v 50 -bitexact -f null - 2>&1 | grep idet
>

Apparently this was due to the leftover logging I left there. This
also happens with vanilla FFmpeg if you add such logging to
reap_filters.

In other words, just this following diff appears to fix it.
Additionally, I will be moving the debug_ts log line back to
reap_filters for now since we want to know of the AV_NOPTS_VALUE
frames as well.

Jan

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7e6c0a962b..acaf6bc47a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -914,12 +914,6 @@ static double
adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
 int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);

 tb.den <<= extra_bits;
-av_log(NULL, AV_LOG_VERBOSE,
-   "%s: frame pts: %"PRId64" start_time: %"PRId64", "
-   "filter_tb: %d/%d, tb: %d/%d\n",
-   __FUNCTION__, frame->pts, start_time,
-   filter_tb.num, filter_tb.den,
-   tb.num, tb.den);

 float_pts =
 av_rescale_q(frame->pts, filter_tb, tb) -
@@ -932,10 +926,6 @@ static double
adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
 av_rescale_q(frame->pts, filter_tb, enc->time_base) -
 av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);

-av_log(NULL, AV_LOG_VERBOSE,
-   "%s: post-adjustment PTS: %"PRId64"\n",
-   __FUNCTION__, frame->pts);
-
 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s
exact:%f time_base:%d/%d\n",
 av_ts2str(frame->pts), av_ts2timestr(frame->pts,
>time_base),
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avformat: add CRI AAX demuxer

2020-09-13 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/adxdec.c  |  16 ++
 libavformat/Makefile |   1 +
 libavformat/aaxdec.c | 377 +++
 libavformat/allformats.c |   1 +
 4 files changed, 395 insertions(+)
 create mode 100644 libavformat/aaxdec.c

diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 40ed8e5ba7..81ffc8b296 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -103,6 +103,22 @@ static int adx_decode_frame(AVCodecContext *avctx, void 
*data,
 const uint8_t *buf  = avpkt->data;
 const uint8_t *buf_end = buf + avpkt->size;
 int num_blocks, ch, ret;
+int new_extradata_size;
+uint8_t *new_extradata;
+
+new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+_extradata_size);
+if (new_extradata && new_extradata_size > 0) {
+int header_size;
+if ((ret = ff_adx_decode_header(avctx, new_extradata,
+new_extradata_size, _size,
+c->coeff)) < 0) {
+av_log(avctx, AV_LOG_ERROR, "error parsing new ADX extradata\n");
+return AVERROR_INVALIDDATA;
+}
+
+c->eof = 0;
+}
 
 if (c->eof) {
 *got_frame_ptr = 0;
diff --git a/libavformat/Makefile b/libavformat/Makefile
index b4cc467268..883326770f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -68,6 +68,7 @@ OBJS-$(CONFIG_SRTP)  += srtp.o
 OBJS-$(CONFIG_A64_MUXER) += a64.o rawenc.o
 OBJS-$(CONFIG_AA_DEMUXER)+= aadec.o
 OBJS-$(CONFIG_AAC_DEMUXER)   += aacdec.o apetag.o img2.o rawdec.o
+OBJS-$(CONFIG_AAX_DEMUXER)   += aaxdec.o
 OBJS-$(CONFIG_AC3_DEMUXER)   += ac3dec.o rawdec.o
 OBJS-$(CONFIG_AC3_MUXER) += rawenc.o
 OBJS-$(CONFIG_ACM_DEMUXER)   += acm.o rawdec.o
diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
new file mode 100644
index 00..a8674fde5b
--- /dev/null
+++ b/libavformat/aaxdec.c
@@ -0,0 +1,377 @@
+/*
+ * AAX demuxer
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct AAXColumn {
+uint8_t flag;
+uint8_t type;
+const char *name;
+uint32_t offset;
+int size;
+} AAXColumn;
+
+typedef struct AAXSegment {
+int64_t start;
+int64_t end;
+} AAXSegment;
+
+typedef struct AAXContext {
+int64_t table_size;
+uint16_t version;
+int64_t rows_offset;
+int64_t strings_offset;
+int64_t data_offset;
+int64_t name_offset;
+uint16_t columns;
+uint16_t row_width;
+uint32_t nb_segments;
+int64_t schema_offset;
+int64_t strings_size;
+char *string_table;
+
+int64_t prev_pts;
+int64_t last_segment_pts;
+int current_segment;
+
+AAXColumn *xcolumns;
+AAXSegment *segments;
+} AAXContext;
+
+static int aax_probe(const AVProbeData *p)
+{
+if (AV_RB32(p->buf) != MKBETAG('@','U','T','F'))
+return 0;
+if (AV_RB32(p->buf + 4) == 0)
+return 0;
+if (AV_RB16(p->buf + 8) > 1)
+return 0;
+
+return AVPROBE_SCORE_MAX;
+}
+
+enum ColumnFlag {
+COLUMN_FLAG_NAME= 0x1,
+COLUMN_FLAG_DEFAULT = 0x2,
+COLUMN_FLAG_ROW = 0x4,
+COLUMN_FLAG_UNDEFINED   = 0x8 /* shouldn't exist */
+};
+
+enum ColumnType {
+COLUMN_TYPE_UINT8   = 0x00,
+COLUMN_TYPE_SINT8   = 0x01,
+COLUMN_TYPE_UINT16  = 0x02,
+COLUMN_TYPE_SINT16  = 0x03,
+COLUMN_TYPE_UINT32  = 0x04,
+COLUMN_TYPE_SINT32  = 0x05,
+COLUMN_TYPE_UINT64  = 0x06,
+COLUMN_TYPE_SINT64  = 0x07,
+COLUMN_TYPE_FLOAT   = 0x08,
+COLUMN_TYPE_DOUBLE  = 0x09,
+COLUMN_TYPE_STRING  = 0x0a,
+COLUMN_TYPE_VLDATA  = 0x0b,
+COLUMN_TYPE_UINT128 = 0x0c, /* for GUIDs */
+COLUMN_TYPE_UNDEFINED   = -1
+};
+
+static int aax_read_header(AVFormatContext *s)
+{
+AAXContext *a = s->priv_data;
+AVIOContext *pb = s->pb;
+AVCodecParameters *par;
+

[FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Paul B Mahol
Also check that segment delta pts is always bigger than input pts.

There is nothing much currently that can be done to recover from
this situation so just return AVERROR_INVALIDDATA error code.

Signed-off-by: Paul B Mahol 
---
 libavfilter/avf_concat.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 5608ed9ac6..df6414704d 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -251,6 +251,10 @@ static int send_silence(AVFilterContext *ctx, unsigned 
in_no, unsigned out_no,
 
 if (!rate_tb.den)
 return AVERROR_BUG;
+if (cat->in[in_no].pts < INT64_MIN + seg_delta)
+return AVERROR_INVALIDDATA;
+if (seg_delta < cat->in[in_no].pts)
+return AVERROR_INVALIDDATA;
 nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
   outlink->time_base, rate_tb);
 frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 10/16] avcodec/svq3: Avoid allocations for SVQ3Frames

2020-09-13 Thread Andreas Rheinhardt

Andreas Rheinhardt:
> These frames can be made part of the SVQ3Context; notice that the pointers
> to the frames have been retained in order to allow to just swap them as
> the code already does.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/svq3.c | 14 --
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
> index c8db08a32f..8a67836827 100644
> --- a/libavcodec/svq3.c
> +++ b/libavcodec/svq3.c
> @@ -147,6 +147,7 @@ typedef struct SVQ3Context {
>  DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
>  uint32_t dequant4_coeff[QP_MAX_NUM + 1][16];
>  int block_offset[2 * (16 * 3)];
> +SVQ3Frame frames[3];
>  } SVQ3Context;
>  
>  #define FULLPEL_MODE  1
> @@ -1135,13 +1136,9 @@ static av_cold int svq3_decode_init(AVCodecContext 
> *avctx)
>  int marker_found = 0;
>  int ret;
>  
> -s->cur_pic  = av_mallocz(sizeof(*s->cur_pic));
> -s->last_pic = av_mallocz(sizeof(*s->last_pic));
> -s->next_pic = av_mallocz(sizeof(*s->next_pic));
> -if (!s->next_pic || !s->last_pic || !s->cur_pic) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> +s->cur_pic  = >frames[0];
> +s->last_pic = >frames[1];
> +s->next_pic = >frames[2];
>  
>  s->cur_pic->f  = av_frame_alloc();
>  s->last_pic->f = av_frame_alloc();
> @@ -1631,9 +1628,6 @@ static av_cold int svq3_decode_end(AVCodecContext 
> *avctx)
>  av_frame_free(>cur_pic->f);
>  av_frame_free(>next_pic->f);
>  av_frame_free(>last_pic->f);
> -av_freep(>cur_pic);
> -av_freep(>next_pic);
> -av_freep(>last_pic);
>  av_freep(>slice_buf);
>  av_freep(>intra4x4_pred_mode);
>  av_freep(>edge_emu_buffer);
> 
I have just realized that going to fail as the old code above does is
dangerous as the close function presumes the said frames to have been
successfully allocated. Therefore I have modified the commit message as
follows:

avcodec/svq3: Fix segfault on allocation error, avoid allocations

The very first thing the SVQ3 decoder currently does is allocating several
SVQ3Frames, a structure which contains members that need to be freed on
their own. If one of these allocations fails, the decoder calls its own
close function to not leak the already allocated SVQ3Frames. Yet said
function presumes that the SVQ3Frames have been successfully allocated
as there is no check before freeing the members that need to be freed.

This commit fixes this by making these frames part of the SVQ3Context,
thereby avoiding the allocations altogether. Notice that the pointers
to the frames have been retained in order to allow to just swap them as
the code already does.

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

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

Re: [FFmpeg-devel] [PATCH] avformat: add CRI AAX demuxer

2020-09-13 Thread Andreas Rheinhardt
Paul B Mahol:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/adxdec.c  |  16 ++
>  libavformat/Makefile |   1 +
>  libavformat/aaxdec.c | 361 +++
>  libavformat/allformats.c |   1 +
>  4 files changed, 379 insertions(+)
>  create mode 100644 libavformat/aaxdec.c
> 
> diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
> index 40ed8e5ba7..81ffc8b296 100644
> --- a/libavcodec/adxdec.c
> +++ b/libavcodec/adxdec.c
> @@ -103,6 +103,22 @@ static int adx_decode_frame(AVCodecContext *avctx, void 
> *data,
>  const uint8_t *buf  = avpkt->data;
>  const uint8_t *buf_end = buf + avpkt->size;
>  int num_blocks, ch, ret;
> +int new_extradata_size;
> +uint8_t *new_extradata;
> +
> +new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
> +_extradata_size);
> +if (new_extradata && new_extradata_size > 0) {
> +int header_size;
> +if ((ret = ff_adx_decode_header(avctx, new_extradata,
> +new_extradata_size, _size,
> +c->coeff)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "error parsing new ADX extradata\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +c->eof = 0;
> +}
>  
>  if (c->eof) {
>  *got_frame_ptr = 0;
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index b4cc467268..883326770f 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -68,6 +68,7 @@ OBJS-$(CONFIG_SRTP)  += srtp.o
>  OBJS-$(CONFIG_A64_MUXER) += a64.o rawenc.o
>  OBJS-$(CONFIG_AA_DEMUXER)+= aadec.o
>  OBJS-$(CONFIG_AAC_DEMUXER)   += aacdec.o apetag.o img2.o rawdec.o
> +OBJS-$(CONFIG_AAX_DEMUXER)   += aaxdec.o
>  OBJS-$(CONFIG_AC3_DEMUXER)   += ac3dec.o rawdec.o
>  OBJS-$(CONFIG_AC3_MUXER) += rawenc.o
>  OBJS-$(CONFIG_ACM_DEMUXER)   += acm.o rawdec.o
> diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
> new file mode 100644
> index 00..1d96de0421
> --- /dev/null
> +++ b/libavformat/aaxdec.c
> @@ -0,0 +1,361 @@
> +/*
> + * AAX demuxer
> + * Copyright (c) 2020 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/intreadwrite.h"
> +#include "avformat.h"
> +#include "internal.h"
> +
> +typedef struct AAXColumn {
> +uint8_t flag;
> +uint8_t type;
> +const char *name;
> +uint32_t offset;
> +int size;
> +} AAXColumn;
> +
> +typedef struct AAXSegment {
> +int64_t start;
> +int64_t end;
> +} AAXSegment;
> +
> +typedef struct AAXContext {
> +int64_t table_size;
> +uint16_t version;
> +int64_t rows_offset;
> +int64_t strings_offset;
> +int64_t data_offset;
> +int64_t name_offset;
> +uint16_t columns;
> +uint16_t row_width;
> +uint32_t nb_segments;
> +int64_t schema_offset;
> +int64_t strings_size;
> +char *string_table;
> +
> +int64_t prev_pts;
> +int64_t last_segment_pts;
> +int current_segment;
> +
> +AAXColumn *xcolumns;
> +AAXSegment *segments;
> +} AAXContext;
> +
> +static int aax_probe(const AVProbeData *p)
> +{
> +if (AV_RB32(p->buf) != MKBETAG('@','U','T','F'))
> +return 0;
> +if (AV_RB16(p->buf + 4) <= 1U)
> +return 0;
> +
> +return AVPROBE_SCORE_MAX;
> +}
> +
> +enum ColumnFlag {
> +COLUMN_FLAG_NAME= 0x1,
> +COLUMN_FLAG_DEFAULT = 0x2,
> +COLUMN_FLAG_ROW = 0x4,
> +COLUMN_FLAG_UNDEFINED   = 0x8 /* shouldn't exist */
> +};
> +
> +enum ColumnType {
> +COLUMN_TYPE_UINT8   = 0x00,
> +COLUMN_TYPE_SINT8   = 0x01,
> +COLUMN_TYPE_UINT16  = 0x02,
> +COLUMN_TYPE_SINT16  = 0x03,
> +COLUMN_TYPE_UINT32  = 0x04,
> +COLUMN_TYPE_SINT32  = 0x05,
> +COLUMN_TYPE_UINT64  = 0x06,
> +COLUMN_TYPE_SINT64  = 0x07,
> +COLUMN_TYPE_FLOAT   = 0x08,
> +COLUMN_TYPE_DOUBLE  = 0x09,
> +COLUMN_TYPE_STRING  = 0x0a,
> +COLUMN_TYPE_VLDATA  = 0x0b,

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Nicolas George
Marton Balint (12020-09-13):
> > +if (seg_delta < -cat->in[in_no].pts)
> > +return AVERROR_BUG;
> Isn't this supposed to be simply (seg_delta < cat->in[in_no].pts) ?

You are right, thanks for noticing. Was this tested?

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 1/4] avdevice/decklink_commoh.h: remove unsupported decklink version ifdef

2020-09-13 Thread Marton Balint



On Fri, 11 Sep 2020, Moritz Barsnick wrote:


On Tue, Sep 08, 2020 at 19:52:29 +0200, Marton Balint wrote:

Subject: Re: [FFmpeg-devel] [PATCH 1/4] avdevice/decklink_commoh.h: remove

Nit: typo^


Thanks, applied the series with that changed.

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

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

Re: [FFmpeg-devel] [PATCH 1/8] avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps

2020-09-13 Thread Marton Balint



On Sat, 12 Sep 2020, Marton Balint wrote:




On Sat, 5 Sep 2020, Marton Balint wrote:

SMPTE 12M timecode can only count frames up to 39, because the 

tens-of-frames
value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode 

is

using the field bit (which is the same bit as the phase correction bit) to
signal the least significant bit of a 50/60 fps timecode. See SMPTE ST
12-1:2014 section 12.1.

Therefore we slightly change the format of the return value of
av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and 

start
using the previously unused Phase Correction bit as Field bit. (As the 

SMPTE

standard suggests)

We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling 

the
recently added av_timecode_get_smpte function in it which already handles 

this

properly.

This change affects the decklink indev and the DV and MXF muxers. MXF has 

no

fate test for 50/60fps content, DV does, therefore the changes.

MediaInfo (a recent version) confirms that half-frame timecode must be 

inserted
to DV. MXFInspect confirms valid timecode insertion to the System Item of 

MXF

files. For MXF, also see EBU R122.

Note that for DV the field flag is not used because in the HDV specs (SMPTE
370M) it is still defined as biphase mark polarity correction flag. So it
should not matter that the DV muxer overrides the field bit.


Will apply the series soon.


Applied.

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Marton Balint



On Sun, 13 Sep 2020, Paul B Mahol wrote:


There is nothing much currently that can be done to recover from
this situation so just return AVERROR_BUG error code.

Signed-off-by: Paul B Mahol 
---
libavfilter/avf_concat.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 5608ed9ac6..295a340515 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -251,6 +251,8 @@ static int send_silence(AVFilterContext *ctx, unsigned 
in_no, unsigned out_no,

if (!rate_tb.den)
return AVERROR_BUG;
+if (seg_delta < -cat->in[in_no].pts)
+return AVERROR_BUG;


Isn't this supposed to be simply (seg_delta < cat->in[in_no].pts) ?

Thanks,
Marton



nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
  outlink->time_base, rate_tb);
frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
--
2.17.1

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

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

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

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

Re: [FFmpeg-devel] [PATCH 01/16] avcodec/snowdec: Use ff_snow_common_init() directly

2020-09-13 Thread Michael Niedermayer
On Sun, Sep 13, 2020 at 04:57:38AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/snowdec.c | 13 +
>  1 file changed, 1 insertion(+), 12 deletions(-)

probably ok

thx

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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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

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

[FFmpeg-devel] request to post IPU samples

2020-09-13 Thread Amon Gibson Albuquerque Nunes
Hi.

i would like to post a google drive link containing some sample files regarding 
a PS2 movie format.
this movie format goes by the name of IPU.
it's something of a "standard movie format" alongside PSS which is a modified 
variant of MPEG-2 elementary stream designed for use on PS2 games.

even then, the IPU format i'm talking about is not the same as the PSS format.
what i'm about to post here contains about 10 IPU files that are bigger than 
3MB hence why i need the go ahead to post such a link.

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

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

Re: [FFmpeg-devel] [PATCH 2/4] ffmpeg: move AVFrame time base adjustment into a function

2020-09-13 Thread Michael Niedermayer
On Sun, Sep 13, 2020 at 01:26:20PM +0300, Jan Ekström wrote:
> This will have to be called later for video down the line.
> ---
>  fftools/ffmpeg.c | 77 
>  1 file changed, 52 insertions(+), 25 deletions(-)

This affects the output, example:
./ffmpeg -i mm-small.mpg -vf idet  -v 50 -bitexact -f null - 2>&1 | grep idet

Reading option '-vf' ... matched as option 'vf' (set video filters) with 
argument 'idet'.
Applying option vf (set video filters) with argument idet.
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single frame: 
progressive, Multi frame: progressive
[Parsed_idet_0 @ 0x557fe4426b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame: progressive

VS:

Reading option '-vf' ... matched as option 'vf' (set video filters) with 
argument 'idet'.
Applying option vf (set video filters) with argument idet.
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame:undetermined
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single frame: 
progressive, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single frame: 
progressive, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single frame: 
tff, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 
frame:undetermined, Multi frame: progressive
[Parsed_idet_0 @ 0x5567cbd30b40] Repeated Field: neither, Single 

Re: [FFmpeg-devel] [PATCH 2/2] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-13 Thread Michael Niedermayer
On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> ---
>  libswscale/input.c  | 12 +---
>  tests/ref/fate/filter-pixfmts-scale |  8 
>  2 files changed, 9 insertions(+), 11 deletions(-)

Can you provide some tests that show that this is better ?
Iam asking that because some of the numbers in some of the code
(i dont remember which) where tuned to give more accurate overall results

an example for tests would be converting from A->B->A then compare to the orig

thx


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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mobiclip: add missing flush

2020-09-13 Thread James Almer
On 9/10/2020 5:39 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/mobiclip.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
> index d147eddbae..c296ce3c78 100644
> --- a/libavcodec/mobiclip.c
> +++ b/libavcodec/mobiclip.c
> @@ -1389,6 +1389,14 @@ static int mobiclip_decode(AVCodecContext *avctx, void 
> *data,
>  return 0;
>  }
>  
> +static void mobiclip_flush(AVCodecContext *avctx)
> +{
> +MobiClipContext *s = avctx->priv_data;
> +
> +for (int i = 0; i < 6; i++)
> +av_frame_unref(s->pic[i]);

Shouldn't you also zero s->current_pic? It's used as an index for this
array.

> +}
> +
>  static av_cold int mobiclip_close(AVCodecContext *avctx)
>  {
>  MobiClipContext *s = avctx->priv_data;
> @@ -1421,6 +1429,7 @@ AVCodec ff_mobiclip_decoder = {
>  .priv_data_size = sizeof(MobiClipContext),
>  .init   = mobiclip_init,
>  .decode = mobiclip_decode,
> +.flush  = mobiclip_flush,
>  .close  = mobiclip_close,
>  .capabilities   = AV_CODEC_CAP_DR1,
>  };
> 

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Nicolas George
Paul B Mahol (12020-09-13):
> It is bug in this filter.
> 
> Filter should avoid integer overflows.
> Also expecting only monotonous timestamps from input is not valid.

Requiring monotonous and continuous timestamps on filters input is not
only valid but widely accepted and almost mandatory. No operation is
possible on several streams without valid timestamps. The bug is in the
filters that do not produce valid timestamps; we could mitigate it in
the framework. Individual filters are not the place to implement this.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 04:14:30PM +0200, Nicolas George wrote:
> Paul B Mahol (12020-09-13):
> > There is nothing much currently that can be done to recover from
> > this situation so just return AVERROR_BUG error code.
> > 
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavfilter/avf_concat.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
> > index 5608ed9ac6..295a340515 100644
> > --- a/libavfilter/avf_concat.c
> > +++ b/libavfilter/avf_concat.c
> > @@ -251,6 +251,8 @@ static int send_silence(AVFilterContext *ctx, unsigned 
> > in_no, unsigned out_no,
> >  
> >  if (!rate_tb.den)
> >  return AVERROR_BUG;
> > +if (seg_delta < -cat->in[in_no].pts)
> > +return AVERROR_BUG;
> >  nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
> >outlink->time_base, rate_tb);
> >  frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
> 
> Catching the problem here is probably ok.
> 
> But it is not a bug in this filter, and therefore AVERROR_BUG is not the
> correct error message. I suppose AVERROR_INVALIDDATA would be ok.

It is bug in this filter.

Filter should avoid integer overflows.
Also expecting only monotonous timestamps from input is not valid.
Filter should not try to allocate very big number of frame samples.
Filter should not try to allocate negative number of frame samples.
I think this last one should be checked also in calling function.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Nicolas George
Paul B Mahol (12020-09-13):
> There is nothing much currently that can be done to recover from
> this situation so just return AVERROR_BUG error code.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avf_concat.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
> index 5608ed9ac6..295a340515 100644
> --- a/libavfilter/avf_concat.c
> +++ b/libavfilter/avf_concat.c
> @@ -251,6 +251,8 @@ static int send_silence(AVFilterContext *ctx, unsigned 
> in_no, unsigned out_no,
>  
>  if (!rate_tb.den)
>  return AVERROR_BUG;
> +if (seg_delta < -cat->in[in_no].pts)
> +return AVERROR_BUG;
>  nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
>outlink->time_base, rate_tb);
>  frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */

Catching the problem here is probably ok.

But it is not a bug in this filter, and therefore AVERROR_BUG is not the
correct error message. I suppose AVERROR_INVALIDDATA would be ok.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/notchlc: Check available space for luma block code

2020-09-13 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 03:53:18PM +0200, Michael Niedermayer wrote:
> On Sun, Sep 13, 2020 at 12:39:34AM +0200, Paul B Mahol wrote:
> > On Sat, Sep 12, 2020 at 06:43:30PM +0200, Michael Niedermayer wrote:
> > > Fixes: Timeout (too long -> 2sec)
> > > Fixes: 
> > > 25439/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5688211127664640
> > > 
> > > Found-by: continuous fuzzing process 
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/notchlc.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
> > > index 3f7079da70..e7e69b0c21 100644
> > > --- a/libavcodec/notchlc.c
> > > +++ b/libavcodec/notchlc.c
> > > @@ -229,6 +229,9 @@ static int decode_blocks(AVCodecContext *avctx, 
> > > AVFrame *p, ThreadFrame *frame,
> > >  bytestream2_seek(, s->y_data_row_offsets, SEEK_SET);
> > >  bytestream2_seek(gb, s->y_control_data_offset, SEEK_SET);
> > >  
> > > +if ((avctx->height + 3) / 4 * ((avctx->width + 3) / 4) * 4 > 
> > > bytestream2_get_bytes_left(gb))
> > > +return AVERROR_INVALIDDATA;
> > > +
> > >  dsty = (uint16_t *)p->data[0];
> > >  dsta = (uint16_t *)p->data[3];
> > >  ylinesize = p->linesize[0] / 2;
> > > -- 
> > > 2.17.1
> > 
> > Is this correct at all?
> 
> Its the amount that is read from gb in the next loop just below the added 
> check

There is also alpha handling code. Also I dislike completely this reverse 
style, bytestream2.. should be first.

With that fixed and actually tested that it does not break decoding it should 
be fine.

> 
> thx
> 
> > 
> > If you do not like timeouts than get smaller samples or reduce dimensions 
> > of accepted files.
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> There will always be a question for which you do not know the correct answer.



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

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/notchlc: Check available space for luma block code

2020-09-13 Thread Michael Niedermayer
On Sun, Sep 13, 2020 at 12:39:34AM +0200, Paul B Mahol wrote:
> On Sat, Sep 12, 2020 at 06:43:30PM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout (too long -> 2sec)
> > Fixes: 
> > 25439/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5688211127664640
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/notchlc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
> > index 3f7079da70..e7e69b0c21 100644
> > --- a/libavcodec/notchlc.c
> > +++ b/libavcodec/notchlc.c
> > @@ -229,6 +229,9 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame 
> > *p, ThreadFrame *frame,
> >  bytestream2_seek(, s->y_data_row_offsets, SEEK_SET);
> >  bytestream2_seek(gb, s->y_control_data_offset, SEEK_SET);
> >  
> > +if ((avctx->height + 3) / 4 * ((avctx->width + 3) / 4) * 4 > 
> > bytestream2_get_bytes_left(gb))
> > +return AVERROR_INVALIDDATA;
> > +
> >  dsty = (uint16_t *)p->data[0];
> >  dsta = (uint16_t *)p->data[3];
> >  ylinesize = p->linesize[0] / 2;
> > -- 
> > 2.17.1
> 
> Is this correct at all?

Its the amount that is read from gb in the next loop just below the added 
check

thx

> 
> If you do not like timeouts than get smaller samples or reduce dimensions of 
> accepted files.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


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

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

[FFmpeg-devel] [PATCH] avfilter/avf_concat: check for possible integer overflow

2020-09-13 Thread Paul B Mahol
There is nothing much currently that can be done to recover from
this situation so just return AVERROR_BUG error code.

Signed-off-by: Paul B Mahol 
---
 libavfilter/avf_concat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 5608ed9ac6..295a340515 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -251,6 +251,8 @@ static int send_silence(AVFilterContext *ctx, unsigned 
in_no, unsigned out_no,
 
 if (!rate_tb.den)
 return AVERROR_BUG;
+if (seg_delta < -cat->in[in_no].pts)
+return AVERROR_BUG;
 nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
   outlink->time_base, rate_tb);
 frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avfilter/af_amix: do not leave unset PTS for frames after first stream is over

2020-09-13 Thread Paul B Mahol
First stream is used only to get number of samples to put into each output 
frame.

Signed-off-by: Paul B Mahol 
---
 libavfilter/af_amix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index cae9d4585a..c4d8916a57 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -309,6 +309,8 @@ static int output_frame(AVFilterLink *outlink)
 }
 }
 }
+
+s->next_pts = frame_list_next_pts(s->frame_list);
 } else {
 /* first input closed: use the available samples */
 nb_samples = INT_MAX;
@@ -324,7 +326,6 @@ static int output_frame(AVFilterLink *outlink)
 }
 }
 
-s->next_pts = frame_list_next_pts(s->frame_list);
 frame_list_remove_samples(s->frame_list, nb_samples);
 
 calculate_scales(s, nb_samples);
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] opusdec: do not fail when LBRR frames are present

2020-09-13 Thread Derek Buitenhuis
On 11/09/2020 18:37, Anton Khirnov wrote:
> Decode and discard them.
> 
> Fixes ticket 4641.
> ---
>  libavcodec/opus_silk.c | 28 
>  libavcodec/opustab.c   |  3 +++
>  libavcodec/opustab.h   |  3 +++
>  3 files changed, 26 insertions(+), 8 deletions(-)

I can confirm this also fixes the samples I have at $dayjob.

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/avf_concat: nb_samples got from delta pts must be > 0

2020-09-13 Thread Nicolas George
Paul B Mahol (12020-09-13):
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avf_concat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
> index 5608ed9ac6..0b10b738a4 100644
> --- a/libavfilter/avf_concat.c
> +++ b/libavfilter/avf_concat.c
> @@ -254,7 +254,7 @@ static int send_silence(AVFilterContext *ctx, unsigned 
> in_no, unsigned out_no,
>  nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
>outlink->time_base, rate_tb);
>  frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
> -while (nb_samples) {
> +while (nb_samples > 0) {
>  frame_nb_samples = FFMIN(frame_nb_samples, nb_samples);
>  buf = ff_get_audio_buffer(outlink, frame_nb_samples);
>  if (!buf)

No. nb_samples should not be negative at this point. If it is, something
was wrong earlier and needs fixing.

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH] avfilter/avf_concat: nb_samples got from delta pts must be > 0

2020-09-13 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avf_concat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 5608ed9ac6..0b10b738a4 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -254,7 +254,7 @@ static int send_silence(AVFilterContext *ctx, unsigned 
in_no, unsigned out_no,
 nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
   outlink->time_base, rate_tb);
 frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
-while (nb_samples) {
+while (nb_samples > 0) {
 frame_nb_samples = FFMIN(frame_nb_samples, nb_samples);
 buf = ff_get_audio_buffer(outlink, frame_nb_samples);
 if (!buf)
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization

2020-09-13 Thread Jan Ekström
Additionally, reap the first rewards by being able to set the
color related encoding values based on the passed AVFrame.

The only tests that seem to have changed their results with this
change seem to be the MXF tests. There, the muxer writes the
limited/full range flag to the output container if the encoder
is not set to "unspecified".
---
 fftools/ffmpeg.c| 42 +++--
 tests/ref/lavf/mxf_d10  |  2 +-
 tests/ref/lavf/mxf_dv25 |  2 +-
 tests/ref/lavf/mxf_dvcpro50 |  2 +-
 tests/ref/lavf/mxf_opatom   |  2 +-
 5 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 66d7da695a..5425ba245d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -946,9 +946,11 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 return float_pts;
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int init_output_stream(OutputStream *ost, AVFrame *frame,
+  char *error, int error_len);
 
-static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+static int init_output_stream_wrapper(OutputStream *ost, AVFrame *frame,
+  unsigned int fatal)
 {
 int ret = AVERROR_BUG;
 char error[1024] = {0};
@@ -956,7 +958,7 @@ static int init_output_stream_wrapper(OutputStream *ost, 
unsigned int fatal)
 if (ost->initialized)
 return 0;
 
-ret = init_output_stream(ost, error, sizeof(error));
+ret = init_output_stream(ost, frame, error, sizeof(error));
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
ost->file_index, ost->index, error);
@@ -1130,7 +1132,7 @@ static void do_video_out(OutputFile *of,
 InputStream *ist = NULL;
 AVFilterContext *filter = ost->filter->filter;
 
-init_output_stream_wrapper(ost, 1);
+init_output_stream_wrapper(ost, next_picture, 1);
 sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture);
 
 if (ost->source_index >= 0)
@@ -1512,7 +1514,7 @@ static int reap_filters(int flush)
  * the encoder earlier than receiving the first AVFrame.
  */
 if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
-init_output_stream_wrapper(ost, 1);
+init_output_stream_wrapper(ost, NULL, 1);
 
 if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) 
{
 return AVERROR(ENOMEM);
@@ -1935,7 +1937,7 @@ static void flush_encoders(void)
 finish_output_stream(ost);
 }
 
-init_output_stream_wrapper(ost, 1);
+init_output_stream_wrapper(ost, NULL, 1);
 }
 
 if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != 
AVMEDIA_TYPE_AUDIO)
@@ -3307,7 +3309,7 @@ static void init_encoder_time_base(OutputStream *ost, 
AVRational default_time_ba
 enc_ctx->time_base = default_time_base;
 }
 
-static int init_output_stream_encode(OutputStream *ost)
+static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
 {
 InputStream *ist = get_input_stream(ost);
 AVCodecContext *enc_ctx = ost->enc_ctx;
@@ -3404,6 +3406,23 @@ static int init_output_stream_encode(OutputStream *ost)
 enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
  
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
+if (frame) {
+if (!av_dict_get(ost->encoder_opts, "color_range", NULL, 0))
+enc_ctx->color_range = frame->color_range;
+
+if (!av_dict_get(ost->encoder_opts, "color_primaries", NULL, 0))
+enc_ctx->color_primaries = frame->color_primaries;
+
+if (!av_dict_get(ost->encoder_opts, "color_trc", NULL, 0))
+enc_ctx->color_trc = frame->color_trc;
+
+if (!av_dict_get(ost->encoder_opts, "colorspace", NULL, 0))
+enc_ctx->colorspace = frame->colorspace;
+
+if (!av_dict_get(ost->encoder_opts, "chroma_sample_location", 
NULL, 0))
+enc_ctx->chroma_sample_location = frame->chroma_location;
+}
+
 enc_ctx->framerate = ost->frame_rate;
 
 ost->st->avg_frame_rate = ost->frame_rate;
@@ -3461,7 +3480,8 @@ static int init_output_stream_encode(OutputStream *ost)
 return 0;
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len)
+static int init_output_stream(OutputStream *ost, AVFrame *frame,
+  char *error, int error_len)
 {
 int ret = 0;
 
@@ -3470,7 +3490,7 @@ static int init_output_stream(OutputStream *ost, char 
*error, int error_len)
 AVCodecContext *dec = NULL;
 InputStream *ist;
 
-ret = init_output_stream_encode(ost);
+ret = init_output_stream_encode(ost, frame);
 if (ret < 0)
 

[FFmpeg-devel] [PATCH 1/4] ffmpeg: deduplicate init_output_stream usage logic

2020-09-13 Thread Jan Ekström
Adds a wrapper function, which handles any errors depending on how
fatal a failure would be.
---
 fftools/ffmpeg.c | 51 
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 84306818a2..cb7644de6a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1392,6 +1392,26 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 
 static int init_output_stream(OutputStream *ost, char *error, int error_len);
 
+static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+{
+int ret = AVERROR_BUG;
+char error[1024] = {0};
+
+if (ost->initialized)
+return 0;
+
+ret = init_output_stream(ost, error, sizeof(error));
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
+   ost->file_index, ost->index, error);
+
+if (fatal)
+exit_program(1);
+}
+
+return ret;
+}
+
 static void finish_output_stream(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -1428,15 +1448,7 @@ static int reap_filters(int flush)
 continue;
 filter = ost->filter->filter;
 
-if (!ost->initialized) {
-char error[1024] = "";
-ret = init_output_stream(ost, error, sizeof(error));
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream 
%d:%d -- %s\n",
-   ost->file_index, ost->index, error);
-exit_program(1);
-}
-}
+init_output_stream_wrapper(ost, 1);
 
 if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) 
{
 return AVERROR(ENOMEM);
@@ -1860,7 +1872,6 @@ static void flush_encoders(void)
 // Maybe we should just let encoding fail instead.
 if (!ost->initialized) {
 FilterGraph *fg = ost->filter->graph;
-char error[1024] = "";
 
 av_log(NULL, AV_LOG_WARNING,
"Finishing stream %d:%d without any data written to it.\n",
@@ -1886,12 +1897,7 @@ static void flush_encoders(void)
 finish_output_stream(ost);
 }
 
-ret = init_output_stream(ost, error, sizeof(error));
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream 
%d:%d -- %s\n",
-   ost->file_index, ost->index, error);
-exit_program(1);
-}
+init_output_stream_wrapper(ost, 1);
 }
 
 if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != 
AVMEDIA_TYPE_AUDIO)
@@ -3669,7 +3675,7 @@ static int transcode_init(void)
 if (output_streams[i]->filter)
 continue;
 
-ret = init_output_stream(output_streams[i], error, sizeof(error));
+ret = init_output_stream_wrapper(output_streams[i], 0);
 if (ret < 0)
 goto dump_format;
 }
@@ -4580,15 +4586,8 @@ static int transcode_step(void)
 }
 
 if (ost->filter && ost->filter->graph->graph) {
-if (!ost->initialized) {
-char error[1024] = {0};
-ret = init_output_stream(ost, error, sizeof(error));
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream 
%d:%d -- %s\n",
-   ost->file_index, ost->index, error);
-exit_program(1);
-}
-}
+init_output_stream_wrapper(ost, 1);
+
 if ((ret = transcode_from_filter(ost->filter->graph, )) < 0)
 return ret;
 if (!ist)
-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH 2/4] ffmpeg: move AVFrame time base adjustment into a function

2020-09-13 Thread Jan Ekström
This will have to be called later for video down the line.
---
 fftools/ffmpeg.c | 77 
 1 file changed, 52 insertions(+), 25 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cb7644de6a..7e6c0a962b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -897,6 +897,55 @@ static int check_recording_time(OutputStream *ost)
 return 1;
 }
 
+static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
+ AVFrame *frame)
+{
+if (!frame || frame->pts == AV_NOPTS_VALUE ||
+!ost->filter || !ost->filter->graph->graph)
+return AV_NOPTS_VALUE;
+
+double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
+AVFilterContext *filter = ost->filter->filter;
+AVCodecContext *enc = ost->enc_ctx;
+
+int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
+AVRational filter_tb = av_buffersink_get_time_base(filter);
+AVRational tb = enc->time_base;
+int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
+
+tb.den <<= extra_bits;
+av_log(NULL, AV_LOG_VERBOSE,
+   "%s: frame pts: %"PRId64" start_time: %"PRId64", "
+   "filter_tb: %d/%d, tb: %d/%d\n",
+   __FUNCTION__, frame->pts, start_time,
+   filter_tb.num, filter_tb.den,
+   tb.num, tb.den);
+
+float_pts =
+av_rescale_q(frame->pts, filter_tb, tb) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
+float_pts /= 1 << extra_bits;
+// avoid exact midoints to reduce the chance of rounding differences, this 
can be removed in case the fps code is changed to work with integers
+float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
+
+frame->pts =
+av_rescale_q(frame->pts, filter_tb, enc->time_base) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
+
+av_log(NULL, AV_LOG_VERBOSE,
+   "%s: post-adjustment PTS: %"PRId64"\n",
+   __FUNCTION__, frame->pts);
+
+if (debug_ts) {
+av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f 
time_base:%d/%d\n",
+av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
>time_base),
+float_pts,
+enc->time_base.num, enc->time_base.den);
+}
+
+return float_pts;
+}
+
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
@@ -1473,37 +1522,15 @@ static int reap_filters(int flush)
 av_frame_unref(filtered_frame);
 continue;
 }
-if (filtered_frame->pts != AV_NOPTS_VALUE) {
-int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
-AVRational filter_tb = av_buffersink_get_time_base(filter);
-AVRational tb = enc->time_base;
-int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
-
-tb.den <<= extra_bits;
-float_pts =
-av_rescale_q(filtered_frame->pts, filter_tb, tb) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
-float_pts /= 1 << extra_bits;
-// avoid exact midoints to reduce the chance of rounding 
differences, this can be removed in case the fps code is changed to work with 
integers
-float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
-
-filtered_frame->pts =
-av_rescale_q(filtered_frame->pts, filter_tb, 
enc->time_base) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
-}
+
+float_pts = adjust_frame_pts_to_encoder_tb(of, ost,
+   filtered_frame);
 
 switch (av_buffersink_get_type(filter)) {
 case AVMEDIA_TYPE_VIDEO:
 if (!ost->frame_aspect_ratio.num)
 enc->sample_aspect_ratio = 
filtered_frame->sample_aspect_ratio;
 
-if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s 
exact:%f time_base:%d/%d\n",
-av_ts2str(filtered_frame->pts), 
av_ts2timestr(filtered_frame->pts, >time_base),
-float_pts,
-enc->time_base.num, enc->time_base.den);
-}
-
 do_video_out(of, ost, filtered_frame, float_pts);
 break;
 case AVMEDIA_TYPE_AUDIO:
-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH 0/4 v2] ffmpeg: late A/V encoder init, AVFrame metadata usage

2020-09-13 Thread Jan Ekström
This patch set started with a very simple wish to not have to set color
related values manually each time when utilizing ffmpeg.c.

As of the second iteration, this patch set passes FATE on both of my machines.
Only the MXF muxer tests actually needed changing, as the MXF muxer can now
write the configured color range as it is no longer unspecified (in this case,
limited range as flagged by the AVFrame).

Unfortunately, audio still needs two locations where the encoder is
initialized, due to how avfilter_graph_request_oldest peeks and already puts
one AVFrame to be available from the filter graph (which is then utilized
as-is as an early return inside both av_buffersink_get_frame_flags and
av_buffersink_get_samples). If this would be improved in lavfi (or the call
to avfilter_graph_request_oldest removed), we could at least remove one of
these.

Currently limited to using values for video and started with the basic values,
more can be added later if needed.

This probably fixes some trac issues, but with a quick look I couldn't find
anything that explicitly was due to lack of video color metadata passthrough.


Jan


Example 1:

I have an RGB 3-D render, which I would like to encode into BT.709 YCbCr.
The video filter I'm generally using for this (zscale) does flag the matrix in
the output AVFrame.

Yet to have the video encoder have the correct metadata set, I have to
set the value(s) manually.

With this patch set, the value(s) from the first AVFrame fed to do_video_out
will be utilized.

Example 2:

I have an input video that sets one or more of the following:
matrix/primaries/transfer function/range/chroma location.

I just want to re-encode it. All of this metadata gets stripped.

With this patch set, the value(s) from the first AVFrame fed to do_video_out
will be utilized.

Example 3:

I have a video which has incorrect metadata tagged. Before, I had to set
the correct data data manually.

With this patch set, since ffmpeg.c takes color related options as dictionary
keys, the AVFrame values will only be utilized if the user has not set the
option for a given stream. Thus, this use case still works.

Jan Ekström (4):
  ffmpeg: deduplicate init_output_stream usage logic
  ffmpeg: move AVFrame time base adjustment into a function
  ffmpeg: move A/V non-streamcopy initialization to a later point
  ffmpeg: pass decoded or filtered AVFrame to output stream
initialization

 fftools/ffmpeg.c| 215 +---
 tests/ref/lavf/mxf_d10  |   2 +-
 tests/ref/lavf/mxf_dv25 |   2 +-
 tests/ref/lavf/mxf_dvcpro50 |   2 +-
 tests/ref/lavf/mxf_opatom   |   2 +-
 5 files changed, 155 insertions(+), 68 deletions(-)

-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH 3/4] ffmpeg: move A/V non-streamcopy initialization to a later point

2020-09-13 Thread Jan Ekström
- For video, this means a single initialization point in do_video_out.
- For audio we unfortunately need to do it in two places just
  before the buffer sink is utilized (if av_buffersink_get_samples
  would still work according to its specification after a call to
  avfilter_graph_request_oldest was made, we could at least remove
  the one in transcode_step).

Other adjustments to make things work:
- As the AVFrame PTS adjustment to encoder time base needs the encoder
  to be initialized, so it is now moved to do_{video,audio}_out,
  right after the encoder has been initialized. Due to this,
  the additional parameter in do_video_out is removed as it is no
  longer necessary.
---
 fftools/ffmpeg.c | 111 ---
 1 file changed, 76 insertions(+), 35 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7e6c0a962b..66d7da695a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -946,6 +946,28 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 return float_pts;
 }
 
+static int init_output_stream(OutputStream *ost, char *error, int error_len);
+
+static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+{
+int ret = AVERROR_BUG;
+char error[1024] = {0};
+
+if (ost->initialized)
+return 0;
+
+ret = init_output_stream(ost, error, sizeof(error));
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
+   ost->file_index, ost->index, error);
+
+if (fatal)
+exit_program(1);
+}
+
+return ret;
+}
+
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
@@ -957,6 +979,8 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
 pkt.data = NULL;
 pkt.size = 0;
 
+adjust_frame_pts_to_encoder_tb(of, ost, frame);
+
 if (!check_recording_time(ost))
 return;
 
@@ -1091,8 +1115,7 @@ static void do_subtitle_out(OutputFile *of,
 
 static void do_video_out(OutputFile *of,
  OutputStream *ost,
- AVFrame *next_picture,
- double sync_ipts)
+ AVFrame *next_picture)
 {
 int ret, format_video_sync;
 AVPacket pkt;
@@ -1102,10 +1125,14 @@ static void do_video_out(OutputFile *of,
 int nb_frames, nb0_frames, i;
 double delta, delta0;
 double duration = 0;
+double sync_ipts = AV_NOPTS_VALUE;
 int frame_size = 0;
 InputStream *ist = NULL;
 AVFilterContext *filter = ost->filter->filter;
 
+init_output_stream_wrapper(ost, 1);
+sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture);
+
 if (ost->source_index >= 0)
 ist = input_streams[ost->source_index];
 
@@ -1439,28 +1466,6 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 }
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
-
-static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
-{
-int ret = AVERROR_BUG;
-char error[1024] = {0};
-
-if (ost->initialized)
-return 0;
-
-ret = init_output_stream(ost, error, sizeof(error));
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
-   ost->file_index, ost->index, error);
-
-if (fatal)
-exit_program(1);
-}
-
-return ret;
-}
-
 static void finish_output_stream(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -1497,7 +1502,17 @@ static int reap_filters(int flush)
 continue;
 filter = ost->filter->filter;
 
-init_output_stream_wrapper(ost, 1);
+/*
+ * Unlike video, with audio the audio frame size matters.
+ * Currently we are fully reliant on the lavfi filter chain to
+ * do the buffering deed for us, and thus the frame size parameter
+ * needs to be set accordingly. Where does one get the required
+ * frame size? From the initialized AVCodecContext of an audio
+ * encoder. Thus, if we have gotten to an audio stream, initialize
+ * the encoder earlier than receiving the first AVFrame.
+ */
+if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
+init_output_stream_wrapper(ost, 1);
 
 if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) 
{
 return AVERROR(ENOMEM);
@@ -1505,7 +1520,6 @@ static int reap_filters(int flush)
 filtered_frame = ost->filtered_frame;
 
 while (1) {
-double float_pts = AV_NOPTS_VALUE; // this is identical to 
filtered_frame.pts but with higher precision
 ret = av_buffersink_get_frame_flags(filter, filtered_frame,
AV_BUFFERSINK_FLAG_NO_REQUEST);
 if (ret < 0) {
@@ -1514,7 +1528,7 @@ 

Re: [FFmpeg-devel] [PATCH 2/2] lavfi/sendcmd: correct the option flags dump

2020-09-13 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 12:40:45PM +0800, Jun Zhao wrote:
> From: Jun Zhao 
> 
> correct the option flags dump for sendcmd/asendcmd.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/f_sendcmd.c | 26 --
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
> index 6b02669..5e4c891 100644
> --- a/libavfilter/f_sendcmd.c
> +++ b/libavfilter/f_sendcmd.c
> @@ -103,14 +103,6 @@ typedef struct SendCmdContext {
>  } SendCmdContext;
>  
>  #define OFFSET(x) offsetof(SendCmdContext, x)
> -#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | 
> AV_OPT_FLAG_VIDEO_PARAM
> -static const AVOption options[] = {
> -{ "commands", "set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, FLAGS },
> -{ "c","set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, FLAGS },
> -{ "filename", "set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> -{ "f","set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
> -{ NULL }
> -};

Cant you use macro somehow?, because you are duplicating most of lines/code.

>  
>  #define SPACES " \f\t\n\r"
>  
> @@ -574,7 +566,14 @@ end:
>  
>  #if CONFIG_SENDCMD_FILTER
>  
> -#define sendcmd_options options
> +#define VFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
> +static const AVOption sendcmd_options[] = {
> +{ "commands", "set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, VFLAGS },
> +{ "c","set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, VFLAGS },
> +{ "filename", "set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, VFLAGS },
> +{ "f","set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, VFLAGS },
> +{ NULL }
> +};
>  AVFILTER_DEFINE_CLASS(sendcmd);
>  
>  static const AVFilterPad sendcmd_inputs[] = {
> @@ -609,7 +608,14 @@ AVFilter ff_vf_sendcmd = {
>  
>  #if CONFIG_ASENDCMD_FILTER
>  
> -#define asendcmd_options options
> +#define AFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
> +static const AVOption asendcmd_options[] = {
> +{ "commands", "set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, AFLAGS },
> +{ "c","set commands", OFFSET(commands_str), AV_OPT_TYPE_STRING, 
> {.str = NULL}, 0, 0, AFLAGS },
> +{ "filename", "set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AFLAGS },
> +{ "f","set commands file",  OFFSET(commands_filename), 
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AFLAGS },
> +{ NULL }
> +};
>  AVFILTER_DEFINE_CLASS(asendcmd);
>  
>  static const AVFilterPad asendcmd_inputs[] = {
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avformat: add CRI AAX demuxer

2020-09-13 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/adxdec.c  |  16 ++
 libavformat/Makefile |   1 +
 libavformat/aaxdec.c | 361 +++
 libavformat/allformats.c |   1 +
 4 files changed, 379 insertions(+)
 create mode 100644 libavformat/aaxdec.c

diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 40ed8e5ba7..81ffc8b296 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -103,6 +103,22 @@ static int adx_decode_frame(AVCodecContext *avctx, void 
*data,
 const uint8_t *buf  = avpkt->data;
 const uint8_t *buf_end = buf + avpkt->size;
 int num_blocks, ch, ret;
+int new_extradata_size;
+uint8_t *new_extradata;
+
+new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+_extradata_size);
+if (new_extradata && new_extradata_size > 0) {
+int header_size;
+if ((ret = ff_adx_decode_header(avctx, new_extradata,
+new_extradata_size, _size,
+c->coeff)) < 0) {
+av_log(avctx, AV_LOG_ERROR, "error parsing new ADX extradata\n");
+return AVERROR_INVALIDDATA;
+}
+
+c->eof = 0;
+}
 
 if (c->eof) {
 *got_frame_ptr = 0;
diff --git a/libavformat/Makefile b/libavformat/Makefile
index b4cc467268..883326770f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -68,6 +68,7 @@ OBJS-$(CONFIG_SRTP)  += srtp.o
 OBJS-$(CONFIG_A64_MUXER) += a64.o rawenc.o
 OBJS-$(CONFIG_AA_DEMUXER)+= aadec.o
 OBJS-$(CONFIG_AAC_DEMUXER)   += aacdec.o apetag.o img2.o rawdec.o
+OBJS-$(CONFIG_AAX_DEMUXER)   += aaxdec.o
 OBJS-$(CONFIG_AC3_DEMUXER)   += ac3dec.o rawdec.o
 OBJS-$(CONFIG_AC3_MUXER) += rawenc.o
 OBJS-$(CONFIG_ACM_DEMUXER)   += acm.o rawdec.o
diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
new file mode 100644
index 00..1d96de0421
--- /dev/null
+++ b/libavformat/aaxdec.c
@@ -0,0 +1,361 @@
+/*
+ * AAX demuxer
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct AAXColumn {
+uint8_t flag;
+uint8_t type;
+const char *name;
+uint32_t offset;
+int size;
+} AAXColumn;
+
+typedef struct AAXSegment {
+int64_t start;
+int64_t end;
+} AAXSegment;
+
+typedef struct AAXContext {
+int64_t table_size;
+uint16_t version;
+int64_t rows_offset;
+int64_t strings_offset;
+int64_t data_offset;
+int64_t name_offset;
+uint16_t columns;
+uint16_t row_width;
+uint32_t nb_segments;
+int64_t schema_offset;
+int64_t strings_size;
+char *string_table;
+
+int64_t prev_pts;
+int64_t last_segment_pts;
+int current_segment;
+
+AAXColumn *xcolumns;
+AAXSegment *segments;
+} AAXContext;
+
+static int aax_probe(const AVProbeData *p)
+{
+if (AV_RB32(p->buf) != MKBETAG('@','U','T','F'))
+return 0;
+if (AV_RB16(p->buf + 4) <= 1U)
+return 0;
+
+return AVPROBE_SCORE_MAX;
+}
+
+enum ColumnFlag {
+COLUMN_FLAG_NAME= 0x1,
+COLUMN_FLAG_DEFAULT = 0x2,
+COLUMN_FLAG_ROW = 0x4,
+COLUMN_FLAG_UNDEFINED   = 0x8 /* shouldn't exist */
+};
+
+enum ColumnType {
+COLUMN_TYPE_UINT8   = 0x00,
+COLUMN_TYPE_SINT8   = 0x01,
+COLUMN_TYPE_UINT16  = 0x02,
+COLUMN_TYPE_SINT16  = 0x03,
+COLUMN_TYPE_UINT32  = 0x04,
+COLUMN_TYPE_SINT32  = 0x05,
+COLUMN_TYPE_UINT64  = 0x06,
+COLUMN_TYPE_SINT64  = 0x07,
+COLUMN_TYPE_FLOAT   = 0x08,
+COLUMN_TYPE_DOUBLE  = 0x09,
+COLUMN_TYPE_STRING  = 0x0a,
+COLUMN_TYPE_VLDATA  = 0x0b,
+COLUMN_TYPE_UINT128 = 0x0c, /* for GUIDs */
+COLUMN_TYPE_UNDEFINED   = -1
+};
+
+static int aax_read_header(AVFormatContext *s)
+{
+AAXContext *a = s->priv_data;
+AVIOContext *pb = s->pb;
+AVCodecParameters *par;
+AVStream *st;
+int64_t column_offset = 0;
+int 

Re: [FFmpeg-devel] [PATCH] avcodec/cdgraphics: fix decoded output when seeking to start of file

2020-09-13 Thread Paul B Mahol
On Thu, Sep 10, 2020 at 12:42:57AM +0200, Paul B Mahol wrote:
> Also in cdg demuxer do not skip packets data, and remove
> private context which is not really needed.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/cdgraphics.c | 10 ++
>  libavformat/cdg.c   | 23 ---
>  2 files changed, 14 insertions(+), 19 deletions(-)
> 

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

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

Re: [FFmpeg-devel] [PATCH] avformat/flic: add support for seeking to start

2020-09-13 Thread Paul B Mahol
On Thu, Sep 10, 2020 at 01:59:21PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/flic.c | 38 +++---
>  1 file changed, 35 insertions(+), 3 deletions(-)
> 

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mobiclip: add missing flush

2020-09-13 Thread Paul B Mahol
On Thu, Sep 10, 2020 at 10:39:03PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/mobiclip.c | 9 +
>  1 file changed, 9 insertions(+)
> 

will apply this set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat: add Square SVS demuxer

2020-09-13 Thread Paul B Mahol
On Fri, Sep 11, 2020 at 12:23:59PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/Makefile |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/svs.c| 96 
>  3 files changed, 98 insertions(+)
>  create mode 100644 libavformat/svs.c
> 

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

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