Re: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-03-04 Thread Wang, Fei W
On Wed, 2022-02-23 at 13:33 +, Wang, Fei W wrote:
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Wang,
> > Fei W
> > Sent: Tuesday, February 22, 2022 4:49 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265:
> > Add P
> > frame to GPB frame support for hevc_vaapi
> > 
> > On Tue, 2022-02-22 at 05:46 +, Xiang, Haihao wrote:
> > > On Mon, 2022-02-21 at 12:06 +, Mark Thompson wrote:
> > > > On 21/02/2022 02:13, Fei Wang wrote:
> > > > > From: Linjie Fu 
> > > > > 
> > > > > Use GPB frames to replace regular P frames if backend driver
> > > > > does
> > > > > not support it.
> > > > > 
> > > > > - GPB:
> > > > >  Generalized P and B picture. P frames replaced by B
> > > > > frames
> > > > > with
> > > > >  forward-predict only, L0 == L1. Normal B frames still
> > > > > have 2
> > > > >  different ref_lists and allow bi-prediction
> > > > > 
> > > > > Signed-off-by: Linjie Fu 
> > > > > Signed-off-by: Fei Wang 
> > > > > ---
> > > > >   libavcodec/vaapi_encode.c  | 33
> > > > > +++--
> > > > >   libavcodec/vaapi_encode.h  |  1 +
> > > > >   libavcodec/vaapi_encode_h265.c | 15 +++
> > > > >   3 files changed, 47 insertions(+), 2 deletions(-)
> > > > 
> > > > This always fails immediately on current iHD
> > > > (7e357b4bea76b2fe2522e6af41ae02ea69cec49e):
> > > > 
> > > > $ ./ffmpeg_g -v 44 -y -hwaccel vaapi -hwaccel_output_format
> > > > vaapi -i
> > > > in.mp4 -an -c:v hevc_vaapi -low_power 1 out.mp4 ...
> > > > [hevc_vaapi @ 0x560e81d45e80] Using input frames context
> > > > (format
> > > > vaapi) with
> > > > hevc_vaapi encoder.
> > > > [hevc_vaapi @ 0x560e81d45e80] Input surface format is nv12.
> > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI profile
> > > > VAProfileHEVCMain
> > > > (17).
> > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI entrypoint
> > > > VAEntrypointEncSliceLP (8).
> > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI render target format
> > > > YUV420 (0x1).
> > > > [hevc_vaapi @ 0x560e81d45e80] Using CTU size 64x64, min CB size
> > > > 8x8.
> > > > [hevc_vaapi @ 0x560e81d45e80] No quality level set; using
> > > > default
> > > > (25).
> > > > [hevc_vaapi @ 0x560e81d45e80] RC mode: CQP.
> > > > [hevc_vaapi @ 0x560e81d45e80] RC quality: 25.
> > > > [hevc_vaapi @ 0x560e81d45e80] RC framerate: 3/1001 (29.97
> > > > fps).
> > > > [hevc_vaapi @ 0x560e81d45e80] Use GPB B frames to replace
> > > > regular P
> > > > frames.
> > > > [hevc_vaapi @ 0x560e81d45e80] Using intra, GPB-B-frames and B-
> > > > frames (supported references: 3 / 3).
> > > > [hevc_vaapi @ 0x560e81d45e80] All wanted packed headers
> > > > available
> > > > (wanted 0xd, found 0x1f).
> > > > [hevc_vaapi @ 0x560e81d45e80] Using level 4.
> > > > ...
> > > > [hevc_vaapi @ 0x560e81d45e80] Failed to end picture encode
> > > > issue:
> > > > 24 (internal
> > > > encoding error).
> > > > [hevc_vaapi @ 0x560e81d45e80] Encode failed: -5.
> > > > Video encoding failed
> > > > ...
> > > > $ cat /proc/cpuinfo | grep 'model name' | head -1
> > > > model name  : Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
> > > > $ uname -v
> > > > #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09)
> > > > 
> > > > Do you get this too, or is your setup different somehow?
> > > 
> > > Hi Mark,
> > > 
> > > I tested this patchset with iHD
> > > (7e357b4bea76b2fe2522e6af41ae02ea69cec49e) on CFL (low_power=0),
> > > RKL
> > > and DG1, i965 on SKL, and didn't see this issue before.
> > > This day I reproduced this issue on ICL. It seems iHD driver
> > > doesn't
> > > return right values for ICL.
> > 
> > Thanks Mark to report this issue on ICL.
> > 
> > I tested on TGL and CFL before submitted this patch set, all looks
> > good. I will
> > check why this fail on ICL.
> > 
> > And will fix your other comments together in next version.
> > 
> > Fei
> > Thanks
> > 
> > 
> > > > > diff --git a/libavcodec/vaapi_encode.c
> > > > > b/libavcodec/vaapi_encode.c
> > > > > index 3bf379b1a0..95eca7c288 100644
> > > > > --- a/libavcodec/vaapi_encode.c
> > > > > +++ b/libavcodec/vaapi_encode.c
> > > > > @@ -1845,6 +1845,30 @@ static av_cold int
> > > > > vaapi_encode_init_gop_structure(AVCodecContext *avctx)
> > > > >   ref_l1 = attr.value >> 16 & 0x;
> > > > >   }
> > > > > 
> > > > > +ctx->p_to_gpb = 0;
> > > > > +
> > > > > +#if VA_CHECK_VERSION(1, 9, 0)
> > > > > +attr = (VAConfigAttrib) {
> > > > > VAConfigAttribPredictionDirection
> > > > > };
> > > > > +vas = vaGetConfigAttributes(ctx->hwctx->display,
> > > > > +ctx->va_profile,
> > > > > +ctx->va_entrypoint,
> > > > > +&attr, 1);
> > > > 
> > > > This probably shouldn't be done at all if the user has selected
> > > > a
> > > > codec without B-frames or a configuration which is intra-only,
> > > > because the log message is confusing:
> > > > 
> > > > [m

[FFmpeg-devel] [PATCH v3 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-03-04 Thread Fei Wang
From: Linjie Fu 

Use GPB frames to replace regular P frames if backend driver does not
support it.

- GPB:
Generalized P and B picture. P frames replaced by B frames with
forward-predict only, L0 == L1. Normal B frames still have 2
different ref_lists and allow bi-prediction

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
update:
1. Fix hevc encode fail on ICL platform.
2. Optimize debug log message.

 libavcodec/vaapi_encode.c  | 56 +++---
 libavcodec/vaapi_encode.h  |  1 +
 libavcodec/vaapi_encode_h265.c | 15 +
 3 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..1818da8731 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1827,6 +1827,7 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
 VAStatus vas;
 VAConfigAttrib attr = { VAConfigAttribEncMaxRefFrames };
 uint32_t ref_l0, ref_l1;
+int prediction_pre_only;
 
 vas = vaGetConfigAttributes(ctx->hwctx->display,
 ctx->va_profile,
@@ -1845,6 +1846,40 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
 ref_l1 = attr.value >> 16 & 0x;
 }
 
+ctx->p_to_gpb = 0;
+prediction_pre_only = 0;
+
+#if VA_CHECK_VERSION(1, 9, 0)
+if (!(ctx->codec->flags & FLAG_INTRA_ONLY ||
+avctx->gop_size <= 1)) {
+attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection };
+vas = vaGetConfigAttributes(ctx->hwctx->display,
+ctx->va_profile,
+ctx->va_entrypoint,
+&attr, 1);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_WARNING, "Failed to query prediction 
direction "
+   "attribute: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR_EXTERNAL;
+} else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
+av_log(avctx, AV_LOG_VERBOSE, "Driver does not report any 
additional "
+   "prediction constraints.\n");
+} else {
+if (attr.value & VA_PREDICTION_DIRECTION_BI_NOT_EMPTY) {
+ctx->p_to_gpb = 1;
+av_log(avctx, AV_LOG_VERBOSE, "Driver does not support 
P-frames, "
+   "replacing them with B-frames.\n");
+}
+
+if (!(attr.value & VA_PREDICTION_DIRECTION_FUTURE)) {
+prediction_pre_only = 1;
+av_log(avctx, AV_LOG_VERBOSE, "Driver support previous 
prediction "
+   "only.\n");
+}
+}
+}
+#endif
+
 if (ctx->codec->flags & FLAG_INTRA_ONLY ||
 avctx->gop_size <= 1) {
 av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
@@ -1854,15 +1889,26 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
"reference frames.\n");
 return AVERROR(EINVAL);
 } else if (!(ctx->codec->flags & FLAG_B_PICTURES) ||
-   ref_l1 < 1 || avctx->max_b_frames < 1) {
-av_log(avctx, AV_LOG_VERBOSE, "Using intra and P-frames "
-   "(supported references: %d / %d).\n", ref_l0, ref_l1);
+   ref_l1 < 1 || avctx->max_b_frames < 1 ||
+   prediction_pre_only) {
+if (ctx->p_to_gpb)
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra and B-frames "
+  "(supported references: %d / %d).\n",
+  ref_l0, ref_l1);
+else
+av_log(avctx, AV_LOG_VERBOSE, "Using intra and P-frames "
+   "(supported references: %d / %d).\n", ref_l0, ref_l1);
 ctx->gop_size = avctx->gop_size;
 ctx->p_per_i  = INT_MAX;
 ctx->b_per_p  = 0;
 } else {
-av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
-   "(supported references: %d / %d).\n", ref_l0, ref_l1);
+   if (ctx->p_to_gpb)
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra and B-frames "
+  "(supported references: %d / %d).\n",
+  ref_l0, ref_l1);
+   else
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
+  "(supported references: %d / %d).\n", ref_l0, ref_l1);
 ctx->gop_size = avctx->gop_size;
 ctx->p_per_i  = INT_MAX;
 ctx->b_per_p  = avctx->max_b_frames;
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..61c5615eb8 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -328,6 +328,7 @@ typedef struct VAAPIEncodeContext {
 int idr_counter;
 int gop_counter;
 int end_of_stream;
+int p_to_gpb;
 
 // Whether the driver supports ROI at all.
 int roi_allowed;
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index e1dc53dfa9..ea458935

[FFmpeg-devel] [PATCH v3 2/4] vaapi_encode: Move block size calculation after entrypoint selection

2022-03-04 Thread Fei Wang
From: Mark Thompson 

The block size can be dependent on the profile and entrypoint selected.
It defaults to 16x16, with codecs able to override this choice with their
own function.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c   | 16 
 libavcodec/vaapi_encode.h   |  7 +++
 libavcodec/vaapi_encode_h265.c  | 32 ++--
 libavcodec/vaapi_encode_mjpeg.c | 18 +++---
 libavcodec/vaapi_encode_mpeg2.c |  3 ---
 libavcodec/vaapi_encode_vp8.c   |  3 ---
 libavcodec/vaapi_encode_vp9.c   | 16 
 7 files changed, 76 insertions(+), 19 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 1818da8731..8d1a08d940 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -2058,6 +2058,8 @@ static av_cold int 
vaapi_encode_init_slice_structure(AVCodecContext *avctx)
 return 0;
 }
 
+av_assert0(ctx->slice_block_height > 0 && ctx->slice_block_width > 0);
+
 ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) /
  ctx->slice_block_height;
 ctx->slice_block_cols = (avctx->width  + ctx->slice_block_width  - 1) /
@@ -2447,6 +2449,20 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 if (err < 0)
 goto fail;
 
+if (ctx->codec->get_encoder_caps) {
+err = ctx->codec->get_encoder_caps(avctx);
+if (err < 0)
+goto fail;
+} else {
+// Assume 16x16 blocks.
+ctx->surface_width  = FFALIGN(avctx->width,  16);
+ctx->surface_height = FFALIGN(avctx->height, 16);
+if (ctx->codec->flags & FLAG_SLICE_CONTROL) {
+ctx->slice_block_width  = 16;
+ctx->slice_block_height = 16;
+}
+}
+
 err = vaapi_encode_init_rate_control(avctx);
 if (err < 0)
 goto fail;
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index 61c5615eb8..f0021acccf 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -376,6 +376,13 @@ typedef struct VAAPIEncodeType {
 // factor depending on RC mode.
 int default_quality;
 
+// Determine encode parameters like block sizes for surface alignment
+// and slices. This may need to query the profile and entrypoint,
+// which will be available when this function is called. If not set,
+// assume that all blocks are 16x16 and that surfaces should be
+// aligned to match this.
+int (*get_encoder_caps)(AVCodecContext *avctx);
+
 // Perform any extra codec-specific configuration after the
 // codec context is initialised (set up the private data and
 // add any necessary global parameters).
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index ea45893508..706ec5d849 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -55,6 +55,10 @@ typedef struct VAAPIEncodeH265Picture {
 typedef struct VAAPIEncodeH265Context {
 VAAPIEncodeContext common;
 
+// Encoder features.
+uint32_t ctu_size;
+uint32_t min_cb_size;
+
 // User options.
 int qp;
 int aud;
@@ -1091,6 +1095,27 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
 return 0;
 }
 
+static av_cold int vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx)
+{
+VAAPIEncodeContext  *ctx = avctx->priv_data;
+VAAPIEncodeH265Context *priv = avctx->priv_data;
+
+if (!priv->ctu_size) {
+priv->ctu_size = 32;
+priv->min_cb_size  = 16;
+}
+av_log(avctx, AV_LOG_VERBOSE, "Using CTU size %dx%d, "
+   "min CB size %dx%d.\n", priv->ctu_size, priv->ctu_size,
+   priv->min_cb_size, priv->min_cb_size);
+
+ctx->surface_width  = FFALIGN(avctx->width,  priv->min_cb_size);
+ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
+
+ctx->slice_block_width = ctx->slice_block_height = priv->ctu_size;
+
+return 0;
+}
+
 static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
 {
 VAAPIEncodeContext  *ctx = avctx->priv_data;
@@ -1160,6 +1185,7 @@ static const VAAPIEncodeType vaapi_encode_type_h265 = {
 
 .default_quality   = 25,
 
+.get_encoder_caps  = &vaapi_encode_h265_get_encoder_caps,
 .configure = &vaapi_encode_h265_configure,
 
 .picture_priv_data_size = sizeof(VAAPIEncodeH265Picture),
@@ -1205,12 +1231,6 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext 
*avctx)
 VA_ENC_PACKED_HEADER_SLICE| // Slice headers.
 VA_ENC_PACKED_HEADER_MISC;  // SEI
 
-ctx->surface_width  = FFALIGN(avctx->width,  16);
-ctx->surface_height = FFALIGN(avctx->height, 16);
-
-// CTU size is currently hard-coded to 32.
-ctx->slice_block_width = ctx->slice_block_height = 32;
-
 if (priv->qp > 0)
 ctx->explicit_qp = priv->qp;
 
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
ind

[FFmpeg-devel] [PATCH v3 3/4] vaapi_encode_h265: Explicitly set and correct some flags

2022-03-04 Thread Fei Wang
From: Mark Thompson 

max_14bit_constraint_flag should be set if the bit depth is not greater than
14 (currently always true).

one_picture_only_flag should not be set because we don't support the still
picture profiles.

general_profile_compatibility_flag should be set according to 
general_profile_idc
instead of bit depth.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode_h265.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 706ec5d849..cafc860772 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -303,17 +303,21 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 ptl->general_profile_idc   = avctx->profile;
 ptl->general_tier_flag = priv->tier;
 
-if (chroma_format == 1) {
-ptl->general_profile_compatibility_flag[1] = bit_depth ==  8;
-ptl->general_profile_compatibility_flag[2] = bit_depth <= 10;
+ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1;
+
+if (ptl->general_profile_compatibility_flag[1])
+ptl->general_profile_compatibility_flag[2] = 1;
+if (ptl->general_profile_compatibility_flag[3]) {
+ptl->general_profile_compatibility_flag[1] = 1;
+ptl->general_profile_compatibility_flag[2] = 1;
 }
-ptl->general_profile_compatibility_flag[4] = 1;
 
 ptl->general_progressive_source_flag= 1;
 ptl->general_interlaced_source_flag = 0;
 ptl->general_non_packed_constraint_flag = 1;
 ptl->general_frame_only_constraint_flag = 1;
 
+ptl->general_max_14bit_constraint_flag = bit_depth <= 14;
 ptl->general_max_12bit_constraint_flag = bit_depth <= 12;
 ptl->general_max_10bit_constraint_flag = bit_depth <= 10;
 ptl->general_max_8bit_constraint_flag  = bit_depth ==  8;
@@ -323,6 +327,7 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 ptl->general_max_monochrome_constraint_flag = chroma_format == 0;
 
 ptl->general_intra_constraint_flag = ctx->gop_size == 1;
+ptl->general_one_picture_only_constraint_flag = 0;
 
 ptl->general_lower_bit_rate_constraint_flag = 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 v3 4/4] vaapi_encode_h265: Query encoding block sizes and features

2022-03-04 Thread Fei Wang
From: Mark Thompson 

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode_h265.c | 112 +++--
 1 file changed, 106 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index cafc860772..b9cf3209b3 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -56,6 +56,9 @@ typedef struct VAAPIEncodeH265Context {
 VAAPIEncodeContext common;
 
 // Encoder features.
+uint32_t va_features;
+// Block size info.
+uint32_t va_bs;
 uint32_t ctu_size;
 uint32_t min_cb_size;
 
@@ -427,9 +430,9 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 vps->vps_max_latency_increase_plus1[i];
 }
 
-// These have to come from the capabilities of the encoder.  We have no
-// way to query them, so just hardcode parameters which work on the Intel
-// driver.
+// These values come from the capabilities of the first encoder
+// implementation in the i965 driver on Intel Skylake.  They may
+// fail badly with other platforms or drivers.
 // CTB size from 8x8 to 32x32.
 sps->log2_min_luma_coding_block_size_minus3   = 0;
 sps->log2_diff_max_min_luma_coding_block_size = 2;
@@ -447,6 +450,42 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 
 sps->pcm_enabled_flag = 0;
 
+// update sps setting according to queried result
+#if VA_CHECK_VERSION(1, 13, 0)
+if (priv->va_features) {
+VAConfigAttribValEncHEVCFeatures features = { .value = 
priv->va_features };
+
+// Enable feature if get queried result is VA_FEATURE_SUPPORTED | 
VA_FEATURE_REQUIRED
+sps->amp_enabled_flag =
+!!features.bits.amp;
+sps->sample_adaptive_offset_enabled_flag =
+!!features.bits.sao;
+sps->sps_temporal_mvp_enabled_flag =
+!!features.bits.temporal_mvp;
+sps->pcm_enabled_flag =
+!!features.bits.pcm;
+}
+
+if (priv->va_bs) {
+VAConfigAttribValEncHEVCBlockSizes bs = { .value = priv->va_bs };
+sps->log2_min_luma_coding_block_size_minus3 =
+ff_ctz(priv->min_cb_size) - 3;
+sps->log2_diff_max_min_luma_coding_block_size =
+ff_ctz(priv->ctu_size) - ff_ctz(priv->min_cb_size);
+
+sps->log2_min_luma_transform_block_size_minus2 =
+bs.bits.log2_min_luma_transform_block_size_minus2;
+sps->log2_diff_max_min_luma_transform_block_size =
+bs.bits.log2_max_luma_transform_block_size_minus2 -
+bs.bits.log2_min_luma_transform_block_size_minus2;
+
+sps->max_transform_hierarchy_depth_inter =
+bs.bits.max_max_transform_hierarchy_depth_inter;
+sps->max_transform_hierarchy_depth_intra =
+bs.bits.max_max_transform_hierarchy_depth_intra;
+}
+#endif
+
 // STRPSs should ideally be here rather than defined individually in
 // each slice, but the structure isn't completely fixed so for now
 // don't bother.
@@ -539,6 +578,23 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP);
 pps->diff_cu_qp_delta_depth   = 0;
 
+// update pps setting according to queried result
+#if VA_CHECK_VERSION(1, 13, 0)
+if (priv->va_features) {
+VAConfigAttribValEncHEVCFeatures features = { .value = 
priv->va_features };
+if (ctx->va_rc_mode != VA_RC_CQP)
+pps->cu_qp_delta_enabled_flag =
+!!features.bits.cu_qp_delta;
+
+pps->transform_skip_enabled_flag =
+!!features.bits.transform_skip;
+// set diff_cu_qp_delta_depth as its max value if cu_qp_delta enabled. 
Otherwise
+// 0 will make cu_qp_delta invalid.
+if (pps->cu_qp_delta_enabled_flag)
+pps->diff_cu_qp_delta_depth = 
sps->log2_diff_max_min_luma_coding_block_size;
+}
+#endif
+
 if (ctx->tile_rows && ctx->tile_cols) {
 int uniform_spacing;
 
@@ -640,8 +696,8 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 
 .coded_buf = VA_INVALID_ID,
 
-.collocated_ref_pic_index = 0xff,
-
+.collocated_ref_pic_index = sps->sps_temporal_mvp_enabled_flag ?
+0 : 0xff,
 .last_picture = 0,
 
 .pic_init_qp= pps->init_qp_minus26 + 26,
@@ -674,6 +730,8 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 .entropy_coding_sync_enabled_flag = 
pps->entropy_coding_sync_enabled_flag,
 .loop_filter_across_tiles_enabled_flag =
 pps->loop_filter_across_tiles_enabled_flag,
+.pps_loop_filter_across_slices_enabled_flag =
+pps->pps_loop_filter_across_slices_enabled_flag,
 .scaling_list_data_present_flag = 
(sps->sps_scaling_list_data_present_flag |
  

Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-03-04 Thread James Almer

On 3/3/2022 4:16 PM, Vignesh Venkatasubramanian wrote:

Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
  configure|   1 +
  libavformat/allformats.c |   1 +
  libavformat/movenc.c | 323 ---
  libavformat/movenc.h |   5 +
  4 files changed, 305 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 8c69ab0c86..6d7020e96b 100755
--- a/configure
+++ b/configure
@@ -3390,6 +3390,7 @@ asf_stream_muxer_select="asf_muxer"
  av1_demuxer_select="av1_frame_merge_bsf av1_parser"
  avi_demuxer_select="riffdec exif"
  avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
  caf_demuxer_select="iso_media"
  caf_muxer_select="iso_media"
  dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
  extern const AVInputFormat  ff_av1_demuxer;
  extern const AVInputFormat  ff_avi_demuxer;
  extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
  extern const AVInputFormat  ff_avisynth_demuxer;
  extern const AVOutputFormat ff_avm2_muxer;
  extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..504403ab0b 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
  
  avio_wb32(pb, 0);

  ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
  return update_size(pb, pos);
  }
  
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc)

  }
  }
  
-/* We should only ever be called by MOV or MP4. */

-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
  
  avio_wb32(pb, 0); /* size */

  ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
  ffio_wfourcc(pb, "nclx");
  else
  ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
  avio_wb16(pb, track->par->color_primaries);
  avio_wb16(pb, track->par->color_trc);
  avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
  int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
  avio_w8(pb, full_range << 7);
  }
@@ -2085,7 +2086,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
|| (track->par->width == 1440 && track->par->height == 1080)
|| (track->par->width == 1920 && track->par->height == 
1080);
  
-if (track->mode == MODE_MOV &&

+if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
  (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
  av_strlcpy(compressor_name, encoder->value, 32);
  } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
@@ -2106,6 +2107,25 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
  }
  }
  
+static int mov_write_ccst_tag(AVIOContext *pb)

+{
+int64_t pos = avio_tell(pb);
+// Write sane defaults:
+// all_ref_pics_intra = 0 : all samples can use any type of reference.
+// intra_pred_used = 1 : intra prediction may or may not be used.
+// max_ref_per_pic = 15 : reserved value to indicate that any number of
+//reference images can be used.
+uint8_t ccstValue = (0 << 7) |  /* all_ref_pics_intra */
+(1 << 6) |  /* intra_pred_used */
+(15 << 2);  /* max_ref_p

Re: [FFmpeg-devel] [PATCH v2] configure: Fix detecting/using getauxval

2022-03-04 Thread Martin Storsjö

On Wed, 23 Feb 2022, Martin Storsjö wrote:


While trying to detect getauxval, this actually never output
HAVE_GETAUXVAL into config.h before.

Signed-off-by: Martin Storsjö 
---
Fixed the alphabetical ordering.
---
configure | 1 +
1 file changed, 1 insertion(+)


Pushed.

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

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


Re: [FFmpeg-devel] [PATCH] avfilter/split: switch to activate()

2022-03-04 Thread Nicolas George
Paul B Mahol (12022-03-03):
> It is caused by number of sample per frame.
> 
> I tested actually with -f lavfi -i sine only.
> 
> And patch resolves issue.

I do not doubt it does. But even without activate, EOF should not depend
on the number of samples per frame. There is something wrong going on
there, and I want to understand what before this change makes it go
away: otherwise, we might be missing other similar bugs.

It has waited several months, a few days more will not hurt.

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


[FFmpeg-devel] [PATCH 1/2] fate/mov: Add test for muxing chapters

2022-03-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
The input audio stream has a title metadata tag that is written
in mov_write_track_udta_tag(); yet somehow the demuxer doesn't
pick it up.

 tests/fate/mov.mak | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index e956380909..b54c009f05 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -126,6 +126,12 @@ fate-mov-mp4-with-mov-in24-ver: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entr
 
 fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_packets -print_format compact -select_streams v 
$(TARGET_SAMPLES)/mov/extended_atom_size_probe
 
+FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OGG_DEMUXER\
+   VORBIS_DECODER MP4_MUXER MOV_DEMUXER \
+   FRAMECRC_MUXER PIPE_PROTOCOL)\
+  += fate-mov-mp4-chapters
+fate-mov-mp4-chapters: CMD = transcode ogg 
$(TARGET_SAMPLES)/vorbis/vorbis_chapter_extension_demo.ogg mp4 "-c copy" "-c 
copy -t 0.1" "" "-show_chapters"
+
 FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MOV_DEMUXER MJPEG_DECODER 
\
SCALE_FILTER PNG_ENCODER PNG_DECODER
\
MP4_MUXER FRAMECRC_MUXER PIPE_PROTOCOL) 
\
-- 
2.32.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".


[FFmpeg-devel] [PATCH 2/2] avformat/movenc: Simplify creating chapter track extradata

2022-03-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 79 +++-
 1 file changed, 26 insertions(+), 53 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..2a6cc1bc6a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6238,12 +6238,32 @@ fail:
 // as samples, and a tref pointing from the other tracks to the chapter one.
 static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
 {
-AVIOContext *pb;
-
+static const uint8_t stub_header[] = {
+// TextSampleEntry
+0x00, 0x00, 0x00, 0x01, // displayFlags
+0x00, 0x00, // horizontal + vertical justification
+0x00, 0x00, 0x00, 0x00, // bgColourRed/Green/Blue/Alpha
+// BoxRecord
+0x00, 0x00, 0x00, 0x00, // defTextBoxTop/Left
+0x00, 0x00, 0x00, 0x00, // defTextBoxBottom/Right
+// StyleRecord
+0x00, 0x00, 0x00, 0x00, // startChar + endChar
+0x00, 0x01, // fontID
+0x00, 0x00, // fontStyleFlags + fontSize
+0x00, 0x00, 0x00, 0x00, // fgColourRed/Green/Blue/Alpha
+// FontTableBox
+0x00, 0x00, 0x00, 0x0D, // box size
+'f', 't', 'a', 'b', // box atom name
+0x00, 0x01, // entry count
+// FontRecord
+0x00, 0x01, // font ID
+0x00,   // font name length
+};
 MOVMuxContext *mov = s->priv_data;
 MOVTrack *track = &mov->tracks[tracknum];
 AVPacket *pkt = mov->pkt;
 int i, len;
+int ret;
 
 track->mode = mov->mode;
 track->tag = MKTAG('t','e','x','t');
@@ -6252,57 +6272,10 @@ static int mov_create_chapter_track(AVFormatContext *s, 
int tracknum)
 if (!track->par)
 return AVERROR(ENOMEM);
 track->par->codec_type = AVMEDIA_TYPE_SUBTITLE;
-#if 0
-// These properties are required to make QT recognize the chapter track
-uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
-if (ff_alloc_extradata(track->par, sizeof(chapter_properties)))
-return AVERROR(ENOMEM);
-memcpy(track->par->extradata, chapter_properties, 
sizeof(chapter_properties));
-#else
-if (avio_open_dyn_buf(&pb) >= 0) {
-int size;
-uint8_t *buf;
-
-/* Stub header (usually for Quicktime chapter track) */
-// TextSampleEntry
-avio_wb32(pb, 0x01); // displayFlags
-avio_w8(pb, 0x00);   // horizontal justification
-avio_w8(pb, 0x00);   // vertical justification
-avio_w8(pb, 0x00);   // bgColourRed
-avio_w8(pb, 0x00);   // bgColourGreen
-avio_w8(pb, 0x00);   // bgColourBlue
-avio_w8(pb, 0x00);   // bgColourAlpha
-// BoxRecord
-avio_wb16(pb, 0x00); // defTextBoxTop
-avio_wb16(pb, 0x00); // defTextBoxLeft
-avio_wb16(pb, 0x00); // defTextBoxBottom
-avio_wb16(pb, 0x00); // defTextBoxRight
-// StyleRecord
-avio_wb16(pb, 0x00); // startChar
-avio_wb16(pb, 0x00); // endChar
-avio_wb16(pb, 0x01); // fontID
-avio_w8(pb, 0x00);   // fontStyleFlags
-avio_w8(pb, 0x00);   // fontSize
-avio_w8(pb, 0x00);   // fgColourRed
-avio_w8(pb, 0x00);   // fgColourGreen
-avio_w8(pb, 0x00);   // fgColourBlue
-avio_w8(pb, 0x00);   // fgColourAlpha
-// FontTableBox
-avio_wb32(pb, 0x0D); // box size
-ffio_wfourcc(pb, "ftab"); // box atom name
-avio_wb16(pb, 0x01); // entry count
-// FontRecord
-avio_wb16(pb, 0x01); // font ID
-avio_w8(pb, 0x00);   // font name length
-
-if ((size = avio_close_dyn_buf(pb, &buf)) > 0) {
-track->par->extradata = buf;
-track->par->extradata_size = size;
-} else {
-av_freep(&buf);
-}
-}
-#endif
+ret = ff_alloc_extradata(track->par, sizeof(stub_header));
+if (ret < 0)
+return ret;
+memcpy(track->par->extradata, stub_header, sizeof(stub_header));
 
 pkt->stream_index = tracknum;
 pkt->flags = AV_PKT_FLAG_KEY;
-- 
2.32.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".


[FFmpeg-devel] [PATCH v2 1/2] fate/mov: Add test for muxing chapters

2022-03-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
Resending because I forgot the ref file in v1. Thanks to James for
noticing.

The input audio stream has a title metadata tag that is written
in mov_write_track_udta_tag(); yet somehow the demuxer doesn't
pick it up.

 tests/fate/mov.mak  |  6 
 tests/ref/fate/mov-mp4-chapters | 50 +
 2 files changed, 56 insertions(+)
 create mode 100644 tests/ref/fate/mov-mp4-chapters

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index e956380909..b54c009f05 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -126,6 +126,12 @@ fate-mov-mp4-with-mov-in24-ver: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entr
 
 fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_packets -print_format compact -select_streams v 
$(TARGET_SAMPLES)/mov/extended_atom_size_probe
 
+FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OGG_DEMUXER\
+   VORBIS_DECODER MP4_MUXER MOV_DEMUXER \
+   FRAMECRC_MUXER PIPE_PROTOCOL)\
+  += fate-mov-mp4-chapters
+fate-mov-mp4-chapters: CMD = transcode ogg 
$(TARGET_SAMPLES)/vorbis/vorbis_chapter_extension_demo.ogg mp4 "-c copy" "-c 
copy -t 0.1" "" "-show_chapters"
+
 FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MOV_DEMUXER MJPEG_DECODER 
\
SCALE_FILTER PNG_ENCODER PNG_DECODER
\
MP4_MUXER FRAMECRC_MUXER PIPE_PROTOCOL) 
\
diff --git a/tests/ref/fate/mov-mp4-chapters b/tests/ref/fate/mov-mp4-chapters
new file mode 100644
index 00..d072d76a83
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-chapters
@@ -0,0 +1,50 @@
+1fd844c2f5bf77c3344e88e30ad994e1 *tests/data/fate/mov-mp4-chapters.mp4
+111248 tests/data/fate/mov-mp4-chapters.mp4
+#extradata 0: 3469, 0xc6769ddc
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: vorbis
+#sample_rate 0: 44100
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,   -256,   -256,  256,   28, 0xefcf103e, F=0x5
+0,  0,  0, 1152,  198, 0xfbbe5eb5
+0,   1152,   1152, 2944,  198, 0xabd95c6c
+0,   4096,   4096,  256,   41, 0x954b12a5
+0,   4352,   4352,  256,   41, 0xbccd1463
+[CHAPTER]
+id=0
+time_base=1/1000
+start=0
+start_time=0.00
+end=5000
+end_time=5.00
+TAG:title=start
+[/CHAPTER]
+[CHAPTER]
+id=1
+time_base=1/1000
+start=5000
+start_time=5.00
+end=10500
+end_time=10.50
+TAG:title=Five Seconds
+[/CHAPTER]
+[CHAPTER]
+id=2
+time_base=1/1000
+start=10500
+start_time=10.50
+end=15000
+end_time=15.00
+TAG:title=Ten point 5 seconds
+[/CHAPTER]
+[CHAPTER]
+id=3
+time_base=1/1000
+start=15000
+start_time=15.00
+end=19849
+end_time=19.849000
+TAG:title=15 sec - over soon
+[/CHAPTER]
-- 
2.32.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".


[FFmpeg-devel] [PATCH v2 2/2] avformat/movenc: Simplify creating chapter track extradata

2022-03-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 79 +++-
 1 file changed, 26 insertions(+), 53 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..2a6cc1bc6a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6238,12 +6238,32 @@ fail:
 // as samples, and a tref pointing from the other tracks to the chapter one.
 static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
 {
-AVIOContext *pb;
-
+static const uint8_t stub_header[] = {
+// TextSampleEntry
+0x00, 0x00, 0x00, 0x01, // displayFlags
+0x00, 0x00, // horizontal + vertical justification
+0x00, 0x00, 0x00, 0x00, // bgColourRed/Green/Blue/Alpha
+// BoxRecord
+0x00, 0x00, 0x00, 0x00, // defTextBoxTop/Left
+0x00, 0x00, 0x00, 0x00, // defTextBoxBottom/Right
+// StyleRecord
+0x00, 0x00, 0x00, 0x00, // startChar + endChar
+0x00, 0x01, // fontID
+0x00, 0x00, // fontStyleFlags + fontSize
+0x00, 0x00, 0x00, 0x00, // fgColourRed/Green/Blue/Alpha
+// FontTableBox
+0x00, 0x00, 0x00, 0x0D, // box size
+'f', 't', 'a', 'b', // box atom name
+0x00, 0x01, // entry count
+// FontRecord
+0x00, 0x01, // font ID
+0x00,   // font name length
+};
 MOVMuxContext *mov = s->priv_data;
 MOVTrack *track = &mov->tracks[tracknum];
 AVPacket *pkt = mov->pkt;
 int i, len;
+int ret;
 
 track->mode = mov->mode;
 track->tag = MKTAG('t','e','x','t');
@@ -6252,57 +6272,10 @@ static int mov_create_chapter_track(AVFormatContext *s, 
int tracknum)
 if (!track->par)
 return AVERROR(ENOMEM);
 track->par->codec_type = AVMEDIA_TYPE_SUBTITLE;
-#if 0
-// These properties are required to make QT recognize the chapter track
-uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
-if (ff_alloc_extradata(track->par, sizeof(chapter_properties)))
-return AVERROR(ENOMEM);
-memcpy(track->par->extradata, chapter_properties, 
sizeof(chapter_properties));
-#else
-if (avio_open_dyn_buf(&pb) >= 0) {
-int size;
-uint8_t *buf;
-
-/* Stub header (usually for Quicktime chapter track) */
-// TextSampleEntry
-avio_wb32(pb, 0x01); // displayFlags
-avio_w8(pb, 0x00);   // horizontal justification
-avio_w8(pb, 0x00);   // vertical justification
-avio_w8(pb, 0x00);   // bgColourRed
-avio_w8(pb, 0x00);   // bgColourGreen
-avio_w8(pb, 0x00);   // bgColourBlue
-avio_w8(pb, 0x00);   // bgColourAlpha
-// BoxRecord
-avio_wb16(pb, 0x00); // defTextBoxTop
-avio_wb16(pb, 0x00); // defTextBoxLeft
-avio_wb16(pb, 0x00); // defTextBoxBottom
-avio_wb16(pb, 0x00); // defTextBoxRight
-// StyleRecord
-avio_wb16(pb, 0x00); // startChar
-avio_wb16(pb, 0x00); // endChar
-avio_wb16(pb, 0x01); // fontID
-avio_w8(pb, 0x00);   // fontStyleFlags
-avio_w8(pb, 0x00);   // fontSize
-avio_w8(pb, 0x00);   // fgColourRed
-avio_w8(pb, 0x00);   // fgColourGreen
-avio_w8(pb, 0x00);   // fgColourBlue
-avio_w8(pb, 0x00);   // fgColourAlpha
-// FontTableBox
-avio_wb32(pb, 0x0D); // box size
-ffio_wfourcc(pb, "ftab"); // box atom name
-avio_wb16(pb, 0x01); // entry count
-// FontRecord
-avio_wb16(pb, 0x01); // font ID
-avio_w8(pb, 0x00);   // font name length
-
-if ((size = avio_close_dyn_buf(pb, &buf)) > 0) {
-track->par->extradata = buf;
-track->par->extradata_size = size;
-} else {
-av_freep(&buf);
-}
-}
-#endif
+ret = ff_alloc_extradata(track->par, sizeof(stub_header));
+if (ret < 0)
+return ret;
+memcpy(track->par->extradata, stub_header, sizeof(stub_header));
 
 pkt->stream_index = tracknum;
 pkt->flags = AV_PKT_FLAG_KEY;
-- 
2.32.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".


[FFmpeg-devel] [PATCH v2] avfilter: add shader_vulkan filter

2022-03-04 Thread Wu, Jianhua
[PATCH 1/2] avfilter: add shader_vulkan filter

[PATCH 2/2] avutil/vulkan: print correct text for shader_vulkan filter

Patches attached.



0001-avfilter-add-shader_vulkan-filter.patch
Description: 0001-avfilter-add-shader_vulkan-filter.patch


0002-avutil-vulkan-print-correct-text-for-shader_vulkan-f.patch
Description: 0002-avutil-vulkan-print-correct-text-for-shader_vulkan-f.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] lavu/tests/opts: add tests for filepath options

2022-03-04 Thread Niklas Haas
From: Niklas Haas 

Using the venerable HEADER.txt as a small file to load.
---
 libavutil/tests/opt.c| 38 +-
 tests/fate/libavutil.mak |  2 +-
 tests/ref/fate/opt   |  4 
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index e6ea892373..e3d4edee4e 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -113,7 +113,7 @@ static void log_callback_help(void *ptr, int level, const 
char *fmt, va_list vl)
 vfprintf(stdout, fmt, vl);
 }
 
-int main(void)
+int main(int argc, const char **argv)
 {
 int i;
 
@@ -355,5 +355,41 @@ int main(void)
 av_opt_free(&test_ctx);
 }
 
+printf("\nTesting av_opt_set_filepath()\n");
+{
+TestContext test_ctx = { 0 };
+const char *samples;
+char buf[256];
+uint8_t *value;
+int ret = AVERROR_BUG;
+
+if (argc < 2)
+return 1;
+samples = argv[1];
+
+test_ctx.class = &test_class;
+av_opt_set_defaults(&test_ctx);
+av_log_set_level(AV_LOG_QUIET);
+
+if (snprintf(buf, sizeof(buf), "@%s/HEADER.txt", samples) >= 
sizeof(buf))
+return 1;
+
+ret = av_opt_set_filepath(&test_ctx, "bin", &buf[1], 0);
+if (!ret)
+ret = av_opt_get(&test_ctx, "bin", 0, &value);
+printf("av_opt_set_filepath: bin='%s'\n",
+   ret ? av_err2str(ret) : (char *) value);
+av_free(value);
+
+ret = av_opt_set(&test_ctx, "bin", buf, 0);
+if (!ret)
+ret = av_opt_get(&test_ctx, "bin", 0, &value);
+printf("av_opt_set: bin='%s'\n",
+   ret ? av_err2str(ret) : (char *) value);
+av_free(value);
+
+av_opt_free(&test_ctx);
+}
+
 return 0;
 }
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 1ec9ed00ad..587aa810cd 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -164,7 +164,7 @@ fate-tea: CMD = run libavutil/tests/tea$(EXESUF)
 
 FATE_LIBAVUTIL += fate-opt
 fate-opt: libavutil/tests/opt$(EXESUF)
-fate-opt: CMD = run libavutil/tests/opt$(EXESUF)
+fate-opt: CMD = run libavutil/tests/opt$(EXESUF) $(TARGET_SAMPLES)
 
 FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
 FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index aac3fa0e7e..341693d097 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -417,3 +417,7 @@ Setting options string 
'a_very_long_option_name_that_will_need_to_be_ellipsized_
 Setting 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' 
to value '42'
 Option 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' 
not found
 Error 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
+
+Testing av_opt_set_filepath()
+av_opt_set_filepath: 
bin='46415445202D2046466D706567204175746F6D617465642054657374696E6720456E7669726F6E6D656E740A687474703A2F2F666174652E6D756C74696D656469612E63782F0A0A'
+av_opt_set: 
bin='46415445202D2046466D706567204175746F6D617465642054657374696E6720456E7669726F6E6D656E740A687474703A2F2F666174652E6D756C74696D656469612E63782F0A0A'
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 1/2] lavu: add syntax for loading AV_OPT_TYPE_BINARY from files

2022-03-04 Thread Niklas Haas
From: Niklas Haas 

I arbitrarily decided to use the syntax 'opt=@filename' to match e.g.
`curl -Ffield=@filename`, and also because @ is not a valid hex
character, nor does it conflict with any other common shell or ffmpeg
syntax.

This is arguably somewhat clunky because it does not round-trip with
av_opt_get - you will get back a hex interpretation of the loaded file,
rather than the filename it was loaded from. It also implies a (perhaps
unnecessary) memcpy from mapped file memory into a allocated memory.
This is unfortunately necessary because there's no way for us to know
whether av_free or av_file_unmap is needed to clean up previous option
values.

The motivating use case was the introduction of several new binary
options for vf_libplacebo, but other filters that currently rely on
manual file-path loading could benefit from it as well.
---
 doc/APIchanges  |  4 
 libavutil/opt.c | 53 -
 libavutil/opt.h |  5 +
 libavutil/version.h |  2 +-
 4 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ea402f6118..0400b10721 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-03-04 - xx - lavu 57.23.100 - opt.h
+  Add av_opt_set_filepath() to set a binary option from a file.
+  Support '@filename' syntax in av_opt_set() for binary options.
+
 2022-02-07 - xx - lavu 57.21.100 - fifo.h
   Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(),
   av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(),
diff --git a/libavutil/opt.c b/libavutil/opt.c
index d951edca9d..151536d229 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -32,6 +32,7 @@
 #include "common.h"
 #include "dict.h"
 #include "eval.h"
+#include "file.h"
 #include "log.h"
 #include "parseutils.h"
 #include "pixdesc.h"
@@ -465,6 +466,33 @@ static int set_string_dict(void *obj, const AVOption *o, 
const char *val, uint8_
 return 0;
 }
 
+static int set_string_filepath(void *obj, const AVOption *o, const char *path, 
uint8_t **dst)
+{
+int *lendst = (int *)(dst + 1);
+uint8_t *bin;
+size_t bin_len;
+int err;
+
+av_freep(dst);
+*lendst = 0;
+
+if (!path || !path[0])
+return 0;
+
+err = av_file_map(path, &bin, &bin_len, 0, obj);
+if (err)
+return err;
+
+*dst = av_memdup(bin, bin_len);
+av_file_unmap(bin, bin_len);
+
+if (!*dst)
+return AVERROR(ENOMEM);
+
+*lendst = bin_len;
+return 0;
+}
+
 int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 {
 int ret = 0;
@@ -492,7 +520,11 @@ int av_opt_set(void *obj, const char *name, const char 
*val, int search_flags)
 case AV_OPT_TYPE_STRING:
 return set_string(obj, o, val, dst);
 case AV_OPT_TYPE_BINARY:
-return set_string_binary(obj, o, val, dst);
+if (val && val[0] == '@') {
+return set_string_filepath(obj, o, &val[1], dst);
+} else {
+return set_string_binary(obj, o, val, dst);
+}
 case AV_OPT_TYPE_FLAGS:
 case AV_OPT_TYPE_INT:
 case AV_OPT_TYPE_INT64:
@@ -631,6 +663,25 @@ int av_opt_set_bin(void *obj, const char *name, const 
uint8_t *val, int len, int
 return 0;
 }
 
+int av_opt_set_filepath(void *obj, const char *name, const char *path, int 
search_flags)
+{
+uint8_t *bin;
+size_t bin_len;
+int err;
+
+if (!path || !path[0])
+return av_opt_set_bin(obj, name, NULL, 0, search_flags);
+
+err = av_file_map(path, &bin, &bin_len, 0, obj);
+if (err)
+return err;
+
+err = av_opt_set_bin(obj, name, bin, bin_len, search_flags);
+av_file_unmap(bin, bin_len);
+
+return err;
+}
+
 int av_opt_set_image_size(void *obj, const char *name, int w, int h, int 
search_flags)
 {
 void *target_obj;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 2820435eec..97d7c69482 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -699,6 +699,11 @@ int av_opt_set_channel_layout(void *obj, const char *name, 
int64_t ch_layout, in
  * caller still owns val is and responsible for freeing it.
  */
 int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, 
int search_flags);
+/**
+ * @note This behaves like av_opt_set_bin() but loads the binary data from a
+ * file. May also return errors related to file I/O.
+ */
+int av_opt_set_filepath(void *obj, const char *name, const char *val, int 
search_flags);
 
 /**
  * Set a binary option to an integer list.
diff --git a/libavutil/version.h b/libavutil/version.h
index c7004601c8..6c5d90507c 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  22
+#define LIBAVUTIL_VERSION_MINOR  23
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTI

Re: [FFmpeg-devel] HEVC open GOP support in MOV/MP4 (v2)

2022-03-04 Thread Clément Bœsch
On Thu, Feb 24, 2022 at 12:48:58PM +0100, Clément Bœsch wrote:
> The main patch is now less intrusive by having the index building
> related lists (sample_offsets and open_key_samples) and variable
> (min_sample_duration) computed in the same place. This is a better
> segmentation between pure parsing and the index logic. The patch should
> be easier to understand too.
> 
> Also, ping on the review.
> 

Applied.

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64

2022-03-04 Thread Martin Storsjö
This fixes an inconsistency since
fed7e7a78b4bea183d0cbb107953e275f17baa4f (ntdll: Simulate a syscall
return when starting a thread); in that commit, on i386 and
x86_64, the syscall_frame used for starting the thread was
zeroed with a memset, while it wasn't on arm and arm64.

This had a noticable effect on float maths, where the
uninitialized frame->restore_flags field could have the
CONTEXT_FLOATING_POINT bit set. (call_init_thunk only ORs in
CONTEXT_INTEGER into the restore_flags field, on all architectures).
If that bit was set, it would restore uninitialized data into the
fpscr register, possibly setting the FPU in a nondefault rounding
mode.

Signed-off-by: Martin Storsjö 
---
 dlls/ntdll/unix/signal_arm.c   | 1 +
 dlls/ntdll/unix/signal_arm64.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c
index a1bcb0ddd32..1fea76f6563 100644
--- a/dlls/ntdll/unix/signal_arm.c
+++ b/dlls/ntdll/unix/signal_arm.c
@@ -1105,6 +1105,7 @@ void DECLSPEC_HIDDEN call_init_thunk( 
LPTHREAD_START_ROUTINE entry, void *arg, B
 ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
 *ctx = context;
 ctx->ContextFlags = CONTEXT_FULL;
+memset( frame, 0, sizeof(*frame) );
 NtSetContextThread( GetCurrentThread(), ctx );
 
 frame->sp = (DWORD)ctx;
diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c
index 94f280e218a..1df97f16f13 100644
--- a/dlls/ntdll/unix/signal_arm64.c
+++ b/dlls/ntdll/unix/signal_arm64.c
@@ -1202,6 +1202,7 @@ void DECLSPEC_HIDDEN call_init_thunk( 
LPTHREAD_START_ROUTINE entry, void *arg, B
 ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
 *ctx = context;
 ctx->ContextFlags = CONTEXT_FULL;
+memset( frame, 0, sizeof(*frame) );
 NtSetContextThread( GetCurrentThread(), ctx );
 
 frame->sp= (ULONG64)ctx;
-- 
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] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64

2022-03-04 Thread Martin Storsjö

On Fri, 4 Mar 2022, Martin Storsjö wrote:

Sorry, I sent this to the entirely wrong mailing list...

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

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


[FFmpeg-devel] Ping Re: [PATCH v2 7/7] avformat/concat: refactor to use av_rescale_interval()

2022-03-04 Thread Pierre-Anthony Lemieux
Hi all,

Just a quick note to check if additional work is needed on this
patchset that has been LGTMed?

The patchset is intended to address https://trac.ffmpeg.org/ticket/9648 .

Best,

-- Pierre

On Mon, Feb 21, 2022 at 2:30 AM Nicolas George  wrote:
>
> p...@sandflow.com (12022-02-20):
> > From: Pierre-Anthony Lemieux 
> >
> > ---
> >  libavformat/concatdec.c | 19 +--
> >  1 file changed, 5 insertions(+), 14 deletions(-)
>
> LGTM.
>
> Regards,
>
> --
>   Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] avformat/mov: log the right variable

2022-03-04 Thread Zhao Zhili
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5e26267810..52caa6a891 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4863,7 +4863,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 // pts = frag_stream_info->sidx_pts;
 dts = frag_stream_info->sidx_pts - sc->time_offset;
 av_log(c->fc, AV_LOG_DEBUG, "found sidx time %"PRId64
-", using it for pts\n", pts);
+", using it for dts\n", frag_stream_info->sidx_pts);
 } else {
 dts = sc->track_end - sc->time_offset;
 av_log(c->fc, AV_LOG_DEBUG, "found track end time %"PRId64
-- 
2.31.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] avformat/movenc: sidx earliest_presentation_time is applied after editlist

2022-03-04 Thread Zhao Zhili
Fix #8334
---
 libavformat/movenc.c  |  7 ---
 tests/ref/fate/movenc | 10 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..c1b455aba2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4750,9 +4750,10 @@ static int mov_write_sidx_tag(AVIOContext *pb,
 
 if (track->entry) {
 entries = 1;
-presentation_time = track->cluster[0].dts + track->cluster[0].cts;
-duration = track->end_pts -
-   (track->cluster[0].dts + track->cluster[0].cts);
+presentation_time = track->cluster[0].dts + track->cluster[0].cts -
+track->start_dts - track->start_cts;
+duration =
+track->end_pts - (track->cluster[0].dts + track->cluster[0].cts);
 starts_with_SAP = track->cluster[0].flags & MOV_SYNC_SAMPLE;
 
 // pts<0 should be cut away using edts
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 19e4e291b8..968a3d27f2 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -101,28 +101,28 @@ write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init
 write_data len 1004, time -3, type sync atom sidx
 write_data len 996, time 97, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag
 write_data len 148, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init-discont
 write_data len 996, time 97, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag-discont
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag-discont
 write_data len 110, time nopts, type trailer atom -
 write_data len 1247, time nopts, type header atom ftyp
 80511a51d1ac9cde62337eed7176ae03 1247 
delay-moov-elst-signal-init-discont-largets
 write_data len 996, time 27962123, type sync atom sidx
-dc695d65e8a0cdafee28acd8a5ccf81a 996 
delay-moov-elst-signal-second-frag-discont-largets
+471fc64644a6bf4065c489fe4e04be7d 996 
delay-moov-elst-signal-second-frag-discont-largets
 write_data len 110, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -33, type sync atom sidx
 write_data len 996, time 517, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -33, type sync atom sidx
 write_data len 996, time 517, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr-noduration
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr-noduration
 write_data len 1231, time nopts, type header atom ftyp
 write_data len 1500, time -33, type sync atom moof
 write_data len 1500, time nopts, type unknown atom -
-- 
2.31.1

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

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


[FFmpeg-devel] [PATCH v2 2/2] avformat/movenc: sidx earliest_presentation_time is applied after editlist

2022-03-04 Thread Zhao Zhili
Fix #8334
---
Remove casual change due to clang-format plugin.

 libavformat/movenc.c  |  3 ++-
 tests/ref/fate/movenc | 10 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..a2da80bc00 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4750,7 +4750,8 @@ static int mov_write_sidx_tag(AVIOContext *pb,
 
 if (track->entry) {
 entries = 1;
-presentation_time = track->cluster[0].dts + track->cluster[0].cts;
+presentation_time = track->cluster[0].dts + track->cluster[0].cts -
+track->start_dts - track->start_cts;
 duration = track->end_pts -
(track->cluster[0].dts + track->cluster[0].cts);
 starts_with_SAP = track->cluster[0].flags & MOV_SYNC_SAMPLE;
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 19e4e291b8..968a3d27f2 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -101,28 +101,28 @@ write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init
 write_data len 1004, time -3, type sync atom sidx
 write_data len 996, time 97, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag
 write_data len 148, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init-discont
 write_data len 996, time 97, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag-discont
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag-discont
 write_data len 110, time nopts, type trailer atom -
 write_data len 1247, time nopts, type header atom ftyp
 80511a51d1ac9cde62337eed7176ae03 1247 
delay-moov-elst-signal-init-discont-largets
 write_data len 996, time 27962123, type sync atom sidx
-dc695d65e8a0cdafee28acd8a5ccf81a 996 
delay-moov-elst-signal-second-frag-discont-largets
+471fc64644a6bf4065c489fe4e04be7d 996 
delay-moov-elst-signal-second-frag-discont-largets
 write_data len 110, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -33, type sync atom sidx
 write_data len 996, time 517, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -33, type sync atom sidx
 write_data len 996, time 517, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr-noduration
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr-noduration
 write_data len 1231, time nopts, type header atom ftyp
 write_data len 1500, time -33, type sync atom moof
 write_data len 1500, time nopts, type unknown atom -
-- 
2.31.1

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

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


[FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-03-04 Thread Vignesh Venkatasubramanian
Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specifiation: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verfied to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 configure|   1 +
 libavformat/allformats.c |   1 +
 libavformat/movenc.c | 326 +++
 libavformat/movenc.h |   5 +
 4 files changed, 307 insertions(+), 26 deletions(-)

diff --git a/configure b/configure
index 8c69ab0c86..6d7020e96b 100755
--- a/configure
+++ b/configure
@@ -3390,6 +3390,7 @@ asf_stream_muxer_select="asf_muxer"
 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
 avi_demuxer_select="riffdec exif"
 avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
 caf_demuxer_select="iso_media"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..400c17afbd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
 extern const AVInputFormat  ff_av1_demuxer;
 extern const AVInputFormat  ff_avi_demuxer;
 extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
 extern const AVInputFormat  ff_avisynth_demuxer;
 extern const AVOutputFormat ff_avm2_muxer;
 extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a746a67fd..8f618c22bb 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, 0);
 ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
 return update_size(pb, pos);
 }
 
@@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 }
 }
 
-/* We should only ever be called by MOV or MP4. */
-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);
 
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
 ffio_wfourcc(pb, "nclx");
 else
 ffio_wfourcc(pb, "nclc");
@@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
 avio_wb16(pb, track->par->color_primaries);
 avio_wb16(pb, track->par->color_trc);
 avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
 int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
 avio_w8(pb, full_range << 7);
 }
@@ -2085,7 +2086,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
   || (track->par->width == 1440 && track->par->height == 1080)
   || (track->par->width == 1920 && track->par->height == 1080);
 
-if (track->mode == MODE_MOV &&
+if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
 (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
 av_strlcpy(compressor_name, encoder->value, 32);
 } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
@@ -2106,6 +2107,25 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
 }
 }
 
+static int mov_write_ccst_tag(AVIOContext *pb)
+{
+int64_t pos = avio_tell(pb);
+// Write sane defaults:
+// all_ref_pics_intra = 0 : all samples can use any type of reference.
+// intra_pred_used = 1 : intra prediction may or may not be used.
+// max_ref_per_pic = 15 : reserved value to indicate that any number of
+//reference images can be used.
+uint8_t ccstValue = (0 << 7) |  /* all_ref_pics_intra */
+(1 << 6) |  /* intra_pred_used */
+(15 << 2);  /* max_ref_per_pic */
+avio_wb32(pb, 0); /* size */
+ffio_wfourcc(pb, "ccst");
+avio_wb32(pb, 0); /* Version & f

Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-03-04 Thread Vignesh Venkatasubramanian
On Fri, Mar 4, 2022 at 3:24 AM James Almer  wrote:
>
> On 3/3/2022 4:16 PM, Vignesh Venkatasubramanian wrote:
> > Add an AVIF muxer by re-using the existing the mov/mp4 muxer.
> >
> > AVIF Specifiation: https://aomediacodec.github.io/av1-avif
> >
> > Sample usage for still image:
> > ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif
> >
> > Sample usage for animated AVIF image:
> > ffmpeg -i video.mp4 animated.avif
> >
> > We can re-use any of the AV1 encoding options that will make
> > sense for image encoding (like bitrate, tiles, encoding speed,
> > etc).
> >
> > The files generated by this muxer has been verified to be valid
> > AVIF files by the following:
> > 1) Displays on Chrome (both still and animated images).
> > 2) Displays on Firefox (only still images, firefox does not support
> > animated AVIF yet).
> > 3) Verfied to be valid by Compliance Warden:
> > https://github.com/gpac/ComplianceWarden
> >
> > Fixes the encoder/muxer part of Trac Ticket #7621
> >
> > Signed-off-by: Vignesh Venkatasubramanian 
> > ---
> >   configure|   1 +
> >   libavformat/allformats.c |   1 +
> >   libavformat/movenc.c | 323 ---
> >   libavformat/movenc.h |   5 +
> >   4 files changed, 305 insertions(+), 25 deletions(-)
> >
> > diff --git a/configure b/configure
> > index 8c69ab0c86..6d7020e96b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3390,6 +3390,7 @@ asf_stream_muxer_select="asf_muxer"
> >   av1_demuxer_select="av1_frame_merge_bsf av1_parser"
> >   avi_demuxer_select="riffdec exif"
> >   avi_muxer_select="riffenc"
> > +avif_muxer_select="mov_muxer"
> >   caf_demuxer_select="iso_media"
> >   caf_muxer_select="iso_media"
> >   dash_muxer_select="mp4_muxer"
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index d066a7745b..400c17afbd 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
> >   extern const AVInputFormat  ff_av1_demuxer;
> >   extern const AVInputFormat  ff_avi_demuxer;
> >   extern const AVOutputFormat ff_avi_muxer;
> > +extern const AVOutputFormat ff_avif_muxer;
> >   extern const AVInputFormat  ff_avisynth_demuxer;
> >   extern const AVOutputFormat ff_avm2_muxer;
> >   extern const AVInputFormat  ff_avr_demuxer;
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index 1a746a67fd..504403ab0b 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -1303,7 +1303,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, 
> > MOVTrack *track)
> >
> >   avio_wb32(pb, 0);
> >   ffio_wfourcc(pb, "av1C");
> > -ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
> > +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
> > MODE_AVIF);
> >   return update_size(pb, pos);
> >   }
> >
> > @@ -2004,12 +2004,13 @@ static int mov_write_colr_tag(AVIOContext *pb, 
> > MOVTrack *track, int prefer_icc)
> >   }
> >   }
> >
> > -/* We should only ever be called by MOV or MP4. */
> > -av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
> > +/* We should only ever be called for MOV, MP4 and AVIF. */
> > +av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
> > +   track->mode == MODE_AVIF);
> >
> >   avio_wb32(pb, 0); /* size */
> >   ffio_wfourcc(pb, "colr");
> > -if (track->mode == MODE_MP4)
> > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
> >   ffio_wfourcc(pb, "nclx");
> >   else
> >   ffio_wfourcc(pb, "nclc");
> > @@ -2019,7 +2020,7 @@ static int mov_write_colr_tag(AVIOContext *pb, 
> > MOVTrack *track, int prefer_icc)
> >   avio_wb16(pb, track->par->color_primaries);
> >   avio_wb16(pb, track->par->color_trc);
> >   avio_wb16(pb, track->par->color_space);
> > -if (track->mode == MODE_MP4) {
> > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
> >   int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
> >   avio_w8(pb, full_range << 7);
> >   }
> > @@ -2085,7 +2086,7 @@ static void find_compressor(char * compressor_name, 
> > int len, MOVTrack *track)
> > || (track->par->width == 1440 && track->par->height == 
> > 1080)
> > || (track->par->width == 1920 && track->par->height == 
> > 1080);
> >
> > -if (track->mode == MODE_MOV &&
> > +if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
> >   (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) 
> > {
> >   av_strlcpy(compressor_name, encoder->value, 32);
> >   } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && 
> > xdcam_res) {
> > @@ -2106,6 +2107,25 @@ static void find_compressor(char * compressor_name, 
> > int len, MOVTrack *track)
> >   }
> >   }
> >
> > +static int mov_write_ccst_tag(AVIOContext *pb)
> > +{
> > +int6

Re: [FFmpeg-devel] [PATCH v8 1/1] avformat: Add IPFS protocol support.

2022-03-04 Thread Michael Niedermayer
On Thu, Mar 03, 2022 at 03:58:53PM +0100, Mark Gaiser wrote:
> On Tue, Mar 1, 2022 at 11:01 PM Michael Niedermayer 
> wrote:
> 
> > On Mon, Feb 28, 2022 at 02:09:15PM +0100, Tomas Härdin wrote:
> > > sön 2022-02-27 klockan 15:29 +0100 skrev Mark Gaiser:
> > > > Ping 2
> > > >
> > > > I'd really like to get this merged!
> > > > This kinda blocks me right now from proceeding with IPFS integration
> > > > in
> > > > Kodi, MPV and VLC. Implementations in those (who rely on ffmpeg) are
> > > > significantly easier once this patch is finally landed in ffmpeg.
> > >
> > > I'd like to hear at least one other dev chime in on this one
> >
> > what exactly are you not sure about ?
> > what exactly needs a 2nd look ?
> >
> 
> My assumption.
> In general just a second look by someone other than Tomas.
> And, as he was skeptical about this patch at first, likely another opinion
> if this makes sense to add in ffmpeg.
> To me it does very much but i'm biased :)

ipfs support makes sense to be added to ffmpeg. ive seen ipfs urls and ive
already been annoyed that some tools dont "just" work with them.
While if i compare this to many other formats which i have never seen
outside the context of FFmpeg. So from this biased single sample that i
am, ipfs seems more widespread and thats why iam in favor of its support

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] avcodec/ac3dec: Check expacc

2022-03-04 Thread Michael Niedermayer
On Thu, Mar 03, 2022 at 06:36:29PM +0100, Paul B Mahol wrote:
> On 11/3/16, Michael Niedermayer  wrote:
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/ac3dec.c | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> > index a95c204..499971a 100644
> > --- a/libavcodec/ac3dec.c
> > +++ b/libavcodec/ac3dec.c
> > @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s,
> >  group_size = exp_strategy + (exp_strategy == EXP_D45);
> >  for (grp = 0, i = 0; grp < ngrps; grp++) {
> >  expacc = get_bits(gbc, 7);
> > +if (expacc >= 125) {
> > +av_log(s->avctx, AV_LOG_ERROR, "expacc %d is out-of-range\n",
> > expacc);
> > +return AVERROR_INVALIDDATA;
> > +}
> >  dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0];
> >  dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1];
> >  dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2];
> > --
> 
> Please revert this ASAP. It breaks decoding valid files.

please provide an affected file / link to one

thx

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

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



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

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add pcm-bluray encoder

2022-03-04 Thread Paul B Mahol
Gonna apply this soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] libavfilter: vf_scale: Properly take in->color_range into account

2022-03-04 Thread Michael Niedermayer
On Thu, Mar 03, 2022 at 02:06:45PM +0200, Martin Storsjö wrote:
> While swscale can be reconfigured with sws_setColorspaceDetails,
> the in/out ranges also need to be set before calling
> sws_init_context, otherwise the initialization might choose
> fastpaths that don't take the ranges into account.
> 
> Therefore, look at in->color_range too, when deciding on whether
> the scaler needs to be reconfigured.
> 
> Add a new member variable for keeping track of this, for being
> able to differentiate between whether the scale filter parameter
> "in_range" has been set (which should override whatever the input
> frame has set) or whether it has been configured based on the
> latest frame (which should trigger reconfiguring the scaler if
> the input frame ranges change).
> 
> Signed-off-by: Martin Storsjö 
> ---
> To test this (without risking running many conflicting swscale
> filters in one filter pipeline), we'd need to be able to tag
> the incoming raw yuv data with colorspace and range without setting
> the in_color_matrix and in_range options on the scale filter.
> 
> When using the rawvideo demuxer, the pixel format is set via the
> ffmpeg -pix_fmt option, but there's no corresponding option for
> setting color matrix or range for it.
> ---
>  libavfilter/vf_scale.c | 13 +
>  1 file changed, 13 insertions(+)

This changes the output for:
ffmpeg -i tickets/524/AVCI50.mov   -vframes 3 file-avci50dec.nut
ffmpeg -i tickets/4493/AVCI100.mov -vframes 3 file-avci100dec.nut

https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket524/

Is that intended ?

- 233903 file-avci100dec.nut
- 383853 file-avci50dec.nut
+ 196558 file-avci100dec.nut
+ 333893 file-avci50dec.nut

thx

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

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



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

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


Re: [FFmpeg-devel] [PATCH v2 4/7] avutil/mathematics: add av_rescale_interval() function

2022-03-04 Thread Andreas Rheinhardt
p...@sandflow.com:
> From: Pierre-Anthony Lemieux 
> 
> Refactors a function used by avformat/concat and avformat/imf.
> 
> ---
>  libavutil/mathematics.c | 10 ++
>  libavutil/mathematics.h | 21 +
>  2 files changed, 31 insertions(+)
> 
> diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
> index f4e541fa24..2c7f57b950 100644
> --- a/libavutil/mathematics.c
> +++ b/libavutil/mathematics.c
> @@ -212,3 +212,13 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, 
> AVRational inc_tb, int64_t i
>  return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - 
> old_ts);
>  }
>  }
> +
> +void av_rescale_interval(AVRational tb_in, AVRational tb_out,
> + int64_t *min_ts, int64_t *ts, int64_t *max_ts)
> +{
> +*ts = av_rescale_q(*ts, tb_in, tb_out);
> +*min_ts = av_rescale_q_rnd(*min_ts, tb_in, tb_out,
> +   AV_ROUND_UP   | AV_ROUND_PASS_MINMAX);
> +*max_ts = av_rescale_q_rnd(*max_ts, tb_in, tb_out,
> +   AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
> +}
> diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
> index 64d4137a60..eb8a3f4002 100644
> --- a/libavutil/mathematics.h
> +++ b/libavutil/mathematics.h
> @@ -161,6 +161,27 @@ int64_t av_rescale_q(int64_t a, AVRational bq, 
> AVRational cq) av_const;
>  int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
>   enum AVRounding rnd) av_const;
>  
> +/**
> + * Rescales a timestamp and the endpoints of an interval to which the 
> temstamp
> + * belongs, from a timebase `tb_in` to a timebase `tb_out`.
> + *
> + * The upper (lower) bound of the output interval is rounded up (down) such 
> that
> + * the output interval always falls within the intput interval. The 
> timestamp is
> + * rounded to the nearest integer and halfway cases away from zero, and can
> + * therefore fall outside of the output interval.
> + * 
> + * Useful to simplify the rescaling of the arguments of 
> AVInputFormat::read_seek2()
> + *
> + * @param[in] tb_in  Timebase of the input `min_ts`, `ts` and `max_ts`
> + * @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts`
> + * @param[in,out] min_ts Lower bound of the interval
> + * @param[in,out] ts Timestamp
> + * @param[in,out] max_ts Upper bound of the interval
> + */
> +void av_rescale_interval(AVRational tb_in, AVRational tb_out,
> + int64_t *min_ts, int64_t *ts, int64_t *max_ts);
> +
> +
>  /**
>   * Compare two timestamps each in its own time base.
>   *

I don't see why this function should be public at all. It seems very
specific to a usecase in lavf.

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

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


Re: [FFmpeg-devel] [PATCH v2 4/7] avutil/mathematics: add av_rescale_interval() function

2022-03-04 Thread Pierre-Anthony Lemieux
On Fri, Mar 4, 2022 at 12:13 PM Andreas Rheinhardt
 wrote:
>
> p...@sandflow.com:
> > From: Pierre-Anthony Lemieux 
> >
> > Refactors a function used by avformat/concat and avformat/imf.
> >
> > ---
> >  libavutil/mathematics.c | 10 ++
> >  libavutil/mathematics.h | 21 +
> >  2 files changed, 31 insertions(+)
> >
> > diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
> > index f4e541fa24..2c7f57b950 100644
> > --- a/libavutil/mathematics.c
> > +++ b/libavutil/mathematics.c
> > @@ -212,3 +212,13 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, 
> > AVRational inc_tb, int64_t i
> >  return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - 
> > old_ts);
> >  }
> >  }
> > +
> > +void av_rescale_interval(AVRational tb_in, AVRational tb_out,
> > + int64_t *min_ts, int64_t *ts, int64_t *max_ts)
> > +{
> > +*ts = av_rescale_q(*ts, tb_in, tb_out);
> > +*min_ts = av_rescale_q_rnd(*min_ts, tb_in, tb_out,
> > +   AV_ROUND_UP   | AV_ROUND_PASS_MINMAX);
> > +*max_ts = av_rescale_q_rnd(*max_ts, tb_in, tb_out,
> > +   AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
> > +}
> > diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
> > index 64d4137a60..eb8a3f4002 100644
> > --- a/libavutil/mathematics.h
> > +++ b/libavutil/mathematics.h
> > @@ -161,6 +161,27 @@ int64_t av_rescale_q(int64_t a, AVRational bq, 
> > AVRational cq) av_const;
> >  int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
> >   enum AVRounding rnd) av_const;
> >
> > +/**
> > + * Rescales a timestamp and the endpoints of an interval to which the 
> > temstamp
> > + * belongs, from a timebase `tb_in` to a timebase `tb_out`.
> > + *
> > + * The upper (lower) bound of the output interval is rounded up (down) 
> > such that
> > + * the output interval always falls within the intput interval. The 
> > timestamp is
> > + * rounded to the nearest integer and halfway cases away from zero, and can
> > + * therefore fall outside of the output interval.
> > + *
> > + * Useful to simplify the rescaling of the arguments of 
> > AVInputFormat::read_seek2()
> > + *
> > + * @param[in] tb_in  Timebase of the input `min_ts`, `ts` and `max_ts`
> > + * @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts`
> > + * @param[in,out] min_ts Lower bound of the interval
> > + * @param[in,out] ts Timestamp
> > + * @param[in,out] max_ts Upper bound of the interval
> > + */
> > +void av_rescale_interval(AVRational tb_in, AVRational tb_out,
> > + int64_t *min_ts, int64_t *ts, int64_t *max_ts);
> > +
> > +
> >  /**
> >   * Compare two timestamps each in its own time base.
> >   *
>
> I don't see why this function should be public at all. It seems very
> specific to a usecase in lavf.

Ok. Unless someone objects/has a better idea, I cam move it to seek.c
as ff_rescale_interval() since it is primarily useful (today) with
seek_file().

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

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


Re: [FFmpeg-devel] [PATCH 17/17] fftools/ffmpeg_opt: Apply copyinkf for all stream types

2022-03-04 Thread Andreas Rheinhardt
Jan Ekström:
> On Tue, Nov 9, 2021 at 8:05 PM Andreas Rheinhardt
>  wrote:
>>
>> The earlier code has ignored it for all stream types except
>> video and subtitles, probably because audio was presumed
>> to only consist of keyframes. Yet this assumption is not true
>> for e.g. TrueHD.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  fftools/ffmpeg_opt.c | 7 +++
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
>> index ab4c63a362..60ee6b16b5 100644
>> --- a/fftools/ffmpeg_opt.c
>> +++ b/fftools/ffmpeg_opt.c
>> @@ -1655,6 +1655,9 @@ static OutputStream *new_output_stream(OptionsContext 
>> *o, AVFormatContext *oc, e
>>  ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket));
>>  if (!ost->muxing_queue)
>>  exit_program(1);
>> +if (ost->stream_copy)
>> +MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i,
>> + ost->copy_initial_nonkeyframes, oc, st);
> 
> Could use an extra empty line after the previous if that leads to
> exit_program since the two are not related/grouped.
> 
> I think we can follow the way it was done for subtitle streams
> previously, and just skip the ost->stream_copy check? There is no
> extra initialization done for this logic, and having the correct value
> always set in "ost" should not be a bad thing (unless I've missed
> something with my quick check-around)
> 
> Otherwise LGTM for me.
> 

Applied with these changes.

- Andreas

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

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


[FFmpeg-devel] [PATCH] avcodec/dnxhdenc: add checks for write overflows

2022-03-04 Thread Paul B Mahol
Also add compensation for extra data needed per packet.

Signed-off-by: Paul B Mahol 
---
 libavcodec/dnxhdenc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index ac92474e56..cba3a753e5 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -1220,7 +1220,7 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, 
DNXHDEncContext *ctx)
 avctx->execute2(avctx, dnxhd_mb_var_thread,
 NULL, NULL, ctx->m.mb_height);
 radix_sort(ctx->mb_cmp, ctx->mb_cmp_tmp, ctx->m.mb_num);
-for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits; x++) {
+for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits - 
ctx->m.mb_num * 2; x++) {
 int mb = ctx->mb_cmp[x].mb;
 int rc = (ctx->qscale * ctx->m.mb_num ) + mb;
 max_bits -= ctx->mb_rc[rc].bits -
@@ -1228,6 +1228,9 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, 
DNXHDEncContext *ctx)
 ctx->mb_qscale[mb] = ctx->qscale + 1;
 ctx->mb_bits[mb]   = ctx->mb_rc[rc + ctx->m.mb_num].bits;
 }
+
+if ((max_bits >> 3) > (ctx->frame_bits >> 3) - ctx->data_offset - 4)
+return AVERROR(EINVAL);
 }
 return 0;
 }
-- 
2.33.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] avfilter/split: switch to activate()

2022-03-04 Thread Paul B Mahol
On 3/4/22, Nicolas George  wrote:
> Paul B Mahol (12022-03-03):
>> It is caused by number of sample per frame.
>>
>> I tested actually with -f lavfi -i sine only.
>>
>> And patch resolves issue.
>
> I do not doubt it does. But even without activate, EOF should not depend
> on the number of samples per frame. There is something wrong going on
> there, and I want to understand what before this change makes it go
> away: otherwise, we might be missing other similar bugs.
>
> It has waited several months, a few days more will not hurt.
>

No, wait must stop.

The issue is that EOF is never reported if there is >1 frame left in
queue before EOF for filters that do not use .activate (and use >1
inputs).

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

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avcodec/dnxhdenc: fix possible out of bound writes for big w/h

2022-03-04 Thread Martin Storsjö

On Fri, 4 Mar 2022, Paul B Mahol wrote:


ffmpeg | branch: master | Paul B Mahol  | Fri Mar  4 23:25:48 
2022 +0100| [37480b1b85b0405563962b581dc2899b1b4bec59] | committer: Paul B Mahol

avcodec/dnxhdenc: fix possible out of bound writes for big w/h

It was caused by integer overflows.


http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37480b1b85b0405563962b581dc2899b1b4bec59

---


This caused changes to the hashes in the fate-lavf-mxf_opatom test - can 
you have a look?


// Martin

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

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