[FFmpeg-devel] [PATCH v2] avcodec/mediacodecenc: enable B frames only with -strict experimental

2023-01-06 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
v2: Enable -> Enabling

 libavcodec/mediacodecenc.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 4c1809093c..a92a8dc5a9 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -276,8 +276,16 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s->level);
 ff_AMediaFormat_setInt32(format, "level", s->level);
 }
-if (avctx->max_b_frames > 0)
+if (avctx->max_b_frames > 0) {
+if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+av_log(avctx, AV_LOG_ERROR,
+"Enabling B frames will produce packets with no DTS. "
+"Use -strict experimental to use it anyway.\n");
+ret = AVERROR(EINVAL);
+goto bailout;
+}
 ff_AMediaFormat_setInt32(format, "max-bframes", avctx->max_b_frames);
+}
 if (s->pts_as_dts == -1)
 s->pts_as_dts = avctx->max_b_frames <= 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 V3 1/3] lavfi/dnn: Mark native backend as deprecated

2023-01-06 Thread Ting Fu
Mark native as deprecated for backed_type option. Modify realted error
message.

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_interface.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c
index 554a36b0dc..12d36f7fed 100644
--- a/libavfilter/dnn/dnn_interface.c
+++ b/libavfilter/dnn/dnn_interface.c
@@ -24,7 +24,6 @@
  */
 
 #include "../dnn_interface.h"
-#include "dnn_backend_native.h"
 #include "dnn_backend_tf.h"
 #include "dnn_backend_openvino.h"
 #include "libavutil/mem.h"
@@ -40,12 +39,9 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
 
 switch(backend_type){
 case DNN_NATIVE:
-dnn_module->load_model = &ff_dnn_load_model_native;
-dnn_module->execute_model = &ff_dnn_execute_model_native;
-dnn_module->get_result = &ff_dnn_get_result_native;
-dnn_module->flush = &ff_dnn_flush_native;
-dnn_module->free_model = &ff_dnn_free_model_native;
-break;
+av_log(NULL, AV_LOG_ERROR, "Native backend is deprecated, please use 
other supported DNN backends.\n");
+av_freep(&dnn_module);
+return NULL;
 case DNN_TF:
 #if (CONFIG_LIBTENSORFLOW == 1)
 dnn_module->load_model = &ff_dnn_load_model_tf;
@@ -71,7 +67,7 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
 #endif
 break;
 default:
-av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or 
tensorflow\n");
+av_log(NULL, AV_LOG_ERROR, "Module backend_type is not supported or 
enabled.\n");
 av_freep(&dnn_module);
 return NULL;
 }
-- 
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 V3 2/3] lavfi/dnn: Delete DNN native backend releated tools and docs.

2023-01-06 Thread Ting Fu
Signed-off-by: Ting Fu 
---
 doc/filters.texi|  43 +-
 tools/python/convert.py |  56 ---
 tools/python/convert_from_tensorflow.py | 607 
 tools/python/convert_header.py  |  26 -
 4 files changed, 4 insertions(+), 728 deletions(-)
 delete mode 100644 tools/python/convert.py
 delete mode 100644 tools/python/convert_from_tensorflow.py
 delete mode 100644 tools/python/convert_header.py

diff --git a/doc/filters.texi b/doc/filters.texi
index 9c32339141..797d1c9fe2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11222,9 +11222,6 @@ See 
@url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_
 Training as well as model generation scripts are provided in
 the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
 
-Native model files (.model) can be generated from TensorFlow model
-files (.pb) by using tools/python/convert.py
-
 The filter accepts the following options:
 
 @table @option
@@ -11245,21 +11242,16 @@ Specify which DNN backend to use for model loading 
and execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
 @url{https://www.tensorflow.org/install/lang_c}) and configure FFmpeg with
 @code{--enable-libtensorflow}
 @end table
-Default value is @samp{native}.
 
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow and native
-backend can load files for only its format.
+Note that different backends use different file formats. TensorFlow can load 
files for only its format.
 @end table
 
 To get full functionality (such as async execution), please use the 
@ref{dnn_processing} filter.
@@ -11583,9 +11575,6 @@ Specify which DNN backend to use for model loading and 
execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
@@ -11601,14 +11590,9 @@ be needed if the header files and libraries are not 
installed into system path)
 
 @end table
 
-Default value is @samp{native}.
-
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow, OpenVINO 
and native
-backend can load files for only its format.
-
-Native model file (.model) can be generated from TensorFlow model file (.pb) 
by using tools/python/convert.py
+Note that different backends use different file formats. TensorFlow, OpenVINO 
backend can load files for only its format.
 
 @item input
 Set the input name of the dnn network.
@@ -11634,12 +11618,6 @@ Remove rain in rgb24 frame with can.pb (see 
@ref{derain} filter):
 ./ffmpeg -i rain.jpg -vf 
format=rgb24,dnn_processing=dnn_backend=tensorflow:model=can.pb:input=x:output=y
 derain.jpg
 @end example
 
-@item
-Halve the pixel value of the frame with format gray32f:
-@example
-ffmpeg -i input.jpg -vf 
format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native
 -y out.native.png
-@end example
-
 @item
 Handle the Y channel with srcnn.pb (see @ref{sr} filter) for frame with 
yuv420p (planar YUV formats supported):
 @example
@@ -21648,13 +21626,6 @@ Efficient Sub-Pixel Convolutional Neural Network model 
(ESPCN).
 See @url{https://arxiv.org/abs/1609.05158}.
 @end itemize
 
-Training scripts as well as scripts for model file (.pb) saving can be found at
-@url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
-is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
-
-Native model files (.model) can be generated from TensorFlow model
-files (.pb) by using tools/python/convert.py
-
 The filter accepts the following options:
 
 @table @option
@@ -21663,9 +21634,6 @@ Specify which DNN backend to use for model loading and 
execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
@@ -21673,13 +21641,10 @@ need to install the TensorFlow for C library (see
 @code{--enable-libtensorflow}
 @end table
 
-Default value is @samp{native}.
-
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow backend
-can load files for both formats, while native backend can load files for only
-its format.
+Note that different backends use different file formats. TensorFlow, OpenVINO 
backend
+can load files for only its format.
 
 @item scale_factor
 Set scale factor f

Re: [FFmpeg-devel] [PATCH V2 1/2] lavfi/dnn: Modify error message for incorrect backend_type

2023-01-06 Thread Fu, Ting



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: Thursday, January 5, 2023 09:07 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] lavfi/dnn: Modify error message
> for incorrect backend_type
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> Ting
> > Fu
> > Sent: Monday, January 2, 2023 11:50 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH V2 1/2] lavfi/dnn: Modify error message
> > for incorrect backend_type
> >
> > Signed-off-by: Ting Fu 
> > ---
> >  libavfilter/dnn/dnn_interface.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/dnn/dnn_interface.c
> > b/libavfilter/dnn/dnn_interface.c index 554a36b0dc..fa484c0905 100644
> > --- a/libavfilter/dnn/dnn_interface.c
> > +++ b/libavfilter/dnn/dnn_interface.c
> > @@ -71,7 +71,7 @@ DNNModule *ff_get_dnn_module(DNNBackendType
> > backend_type)
> >  #endif
> >  break;
> >  default:
> > -av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or
> > tensorflow\n");
> > +av_log(NULL, AV_LOG_ERROR, "Module backend_type is not
> > + supported or enabled.\n");
> 
> We need to remove "case DNN_NATIVE:" in this patch, and so native
> backend will go here 'default:'.

Hi Yejun,

Updated it in PATCH V3.
> 
> >  av_freep(&dnn_module);
> >  return NULL;
> >  }
> 
> Please also update doc/filters.texi in this commit, thanks.

Sure, I delete the native part in doc/filers.texi and its related files in 
tools/python/,
and make it three commits. Hope this make sense.

Thank you
Ting Fu
> ___
> 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 V4 1/3] lavfi/dnn: Mark native backend as unsupported

2023-01-06 Thread Ting Fu
Native is deprecated value for backed_type option. Modify realted error
message.

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_interface.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c
index 554a36b0dc..5b1695a1dd 100644
--- a/libavfilter/dnn/dnn_interface.c
+++ b/libavfilter/dnn/dnn_interface.c
@@ -24,7 +24,6 @@
  */
 
 #include "../dnn_interface.h"
-#include "dnn_backend_native.h"
 #include "dnn_backend_tf.h"
 #include "dnn_backend_openvino.h"
 #include "libavutil/mem.h"
@@ -39,13 +38,6 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
 }
 
 switch(backend_type){
-case DNN_NATIVE:
-dnn_module->load_model = &ff_dnn_load_model_native;
-dnn_module->execute_model = &ff_dnn_execute_model_native;
-dnn_module->get_result = &ff_dnn_get_result_native;
-dnn_module->flush = &ff_dnn_flush_native;
-dnn_module->free_model = &ff_dnn_free_model_native;
-break;
 case DNN_TF:
 #if (CONFIG_LIBTENSORFLOW == 1)
 dnn_module->load_model = &ff_dnn_load_model_tf;
@@ -71,7 +63,7 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
 #endif
 break;
 default:
-av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or 
tensorflow\n");
+av_log(NULL, AV_LOG_ERROR, "Module backend_type is not supported or 
enabled.\n");
 av_freep(&dnn_module);
 return NULL;
 }
-- 
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 V4 2/3] lavfi/dnn: Delete DNN native backend releated tools and docs.

2023-01-06 Thread Ting Fu
Signed-off-by: Ting Fu 
---
 doc/filters.texi|  43 +-
 tools/python/convert.py |  56 ---
 tools/python/convert_from_tensorflow.py | 607 
 tools/python/convert_header.py  |  26 -
 4 files changed, 4 insertions(+), 728 deletions(-)
 delete mode 100644 tools/python/convert.py
 delete mode 100644 tools/python/convert_from_tensorflow.py
 delete mode 100644 tools/python/convert_header.py

diff --git a/doc/filters.texi b/doc/filters.texi
index 9c32339141..797d1c9fe2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11222,9 +11222,6 @@ See 
@url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_
 Training as well as model generation scripts are provided in
 the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
 
-Native model files (.model) can be generated from TensorFlow model
-files (.pb) by using tools/python/convert.py
-
 The filter accepts the following options:
 
 @table @option
@@ -11245,21 +11242,16 @@ Specify which DNN backend to use for model loading 
and execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
 @url{https://www.tensorflow.org/install/lang_c}) and configure FFmpeg with
 @code{--enable-libtensorflow}
 @end table
-Default value is @samp{native}.
 
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow and native
-backend can load files for only its format.
+Note that different backends use different file formats. TensorFlow can load 
files for only its format.
 @end table
 
 To get full functionality (such as async execution), please use the 
@ref{dnn_processing} filter.
@@ -11583,9 +11575,6 @@ Specify which DNN backend to use for model loading and 
execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
@@ -11601,14 +11590,9 @@ be needed if the header files and libraries are not 
installed into system path)
 
 @end table
 
-Default value is @samp{native}.
-
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow, OpenVINO 
and native
-backend can load files for only its format.
-
-Native model file (.model) can be generated from TensorFlow model file (.pb) 
by using tools/python/convert.py
+Note that different backends use different file formats. TensorFlow, OpenVINO 
backend can load files for only its format.
 
 @item input
 Set the input name of the dnn network.
@@ -11634,12 +11618,6 @@ Remove rain in rgb24 frame with can.pb (see 
@ref{derain} filter):
 ./ffmpeg -i rain.jpg -vf 
format=rgb24,dnn_processing=dnn_backend=tensorflow:model=can.pb:input=x:output=y
 derain.jpg
 @end example
 
-@item
-Halve the pixel value of the frame with format gray32f:
-@example
-ffmpeg -i input.jpg -vf 
format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native
 -y out.native.png
-@end example
-
 @item
 Handle the Y channel with srcnn.pb (see @ref{sr} filter) for frame with 
yuv420p (planar YUV formats supported):
 @example
@@ -21648,13 +21626,6 @@ Efficient Sub-Pixel Convolutional Neural Network model 
(ESPCN).
 See @url{https://arxiv.org/abs/1609.05158}.
 @end itemize
 
-Training scripts as well as scripts for model file (.pb) saving can be found at
-@url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
-is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
-
-Native model files (.model) can be generated from TensorFlow model
-files (.pb) by using tools/python/convert.py
-
 The filter accepts the following options:
 
 @table @option
@@ -21663,9 +21634,6 @@ Specify which DNN backend to use for model loading and 
execution. This option ac
 the following values:
 
 @table @samp
-@item native
-Native implementation of DNN loading and execution.
-
 @item tensorflow
 TensorFlow backend. To enable this backend you
 need to install the TensorFlow for C library (see
@@ -21673,13 +21641,10 @@ need to install the TensorFlow for C library (see
 @code{--enable-libtensorflow}
 @end table
 
-Default value is @samp{native}.
-
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow backend
-can load files for both formats, while native backend can load files for only
-its format.
+Note that different backends use different file formats. TensorFlow, OpenVINO 
backend
+can load files for only its format.
 
 @item scale_factor
 Set scale factor f

Re: [FFmpeg-devel] [PATCH V3 1/3] lavfi/dnn: Mark native backend as deprecated

2023-01-06 Thread Fu, Ting



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Ting
> Fu
> Sent: Friday, January 6, 2023 05:02 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V3 1/3] lavfi/dnn: Mark native backend as
> deprecated
> 
> Mark native as deprecated for backed_type option. Modify realted error
> message.
> 
> Signed-off-by: Ting Fu 
> ---
>  libavfilter/dnn/dnn_interface.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
Sorry for the incorrect patch, please omit V3 and check V4.
[...]
> 
> ___
> 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] avformat/movenc: Add loop parameter to animated AVIF

2023-01-06 Thread zhilizhao(赵志立)


> On Jan 6, 2023, at 01:34, Vignesh Venkatasubramanian 
>  wrote:
> 
> On Thu, Jan 5, 2023 at 1:45 AM "zhilizhao(赵志立)"  
> wrote:
>> 
>> 
>> 
>>> On Jan 5, 2023, at 06:16, Vignesh Venkatasubramanian 
>>>  wrote:
>>> 
>>> The HEIF specification permits specifying the looping behavior of
>>> animated sequences by using the EditList (elst) box. The track
>>> duration will be set to the total duration of all the loops (or
>>> infinite) and the duration of a single loop will be set in the edit
>>> list box.
>>> 
>>> The default behavior is to loop infinitely.
>>> 
>>> Compliance verification:
>>> * This was added in libavif recently [1] and the files produced by
>>> ffmpeg after this change have EditList boxes similar to the ones
>>> produced by libavif (and avifdec is able to parse the loop count as
>>> intended).
>>> * ComplianceWarden is ok with the produced files.
>>> * Chrome is able to play back the produced files.
>>> 
>>> Signed-off-by: Vignesh Venkatasubramanian 
>>> ---
>>> libavformat/movenc.c | 35 +++
>>> libavformat/movenc.h |  1 +
>>> 2 files changed, 32 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>> index 36c76f7f60..8d31317838 100644
>>> --- a/libavformat/movenc.c
>>> +++ b/libavformat/movenc.c
>>> @@ -3287,7 +3287,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>>int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track),
>>>  mov->movie_timescale, track->timescale,
>>>  AV_ROUND_UP);
>>> -int version = duration < INT32_MAX ? 0 : 1;
>>> +int version;
>>>int flags   = MOV_TKHD_FLAG_IN_MOVIE;
>>>int group   = 0;
>>> 
>>> @@ -3295,6 +3295,14 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>>size_t display_matrix_size;
>>>int   i;
>>> 
>>> +if (mov->mode == MODE_AVIF)
>>> +if (!mov->avif_loop_count)
>>> +duration = INT64_MAX;
>>> +else
>>> +duration *= mov->avif_loop_count;
>>> +
>>> + version = duration < INT32_MAX ? 0 : 1;
>>> +
>>>if (st) {
>>>if (mov->per_stream_grouping)
>>>group = st->index;
>>> @@ -3414,7 +3422,10 @@ static int mov_write_tapt_tag(AVIOContext *pb, 
>>> MOVTrack *track)
>>>return update_size(pb, pos);
>>> }
>>> 
>>> -// This box seems important for the psp playback ... without it the movie 
>>> seems to hang
>>> +// This box is written in the following cases:
>>> +//   * Seems important for the psp playback. Without it the movie seems to 
>>> hang.
>>> +//   * Used for specifying the looping behavior of animated AVIF (as 
>>> specified
>>> +//   in Section 9.6 of the HEIF specification ISO/IEC 23008-12).
>>> static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
>>>  MOVTrack *track)
>>> {
>>> @@ -3425,6 +3436,7 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>>int entry_size, entry_count, size;
>>>int64_t delay, start_ct = track->start_cts;
>>>int64_t start_dts = track->start_dts;
>>> +int flags = 0;
>>> 
>>>if (track->entry) {
>>>if (start_dts != track->cluster[0].dts || start_ct != 
>>> track->cluster[0].cts) {
>>> @@ -3440,6 +3452,17 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>> 
>>>delay = av_rescale_rnd(start_dts + start_ct, mov->movie_timescale,
>>>   track->timescale, AV_ROUND_DOWN);
>>> +
>>> +if (mov->mode == MODE_AVIF) {
>>> +delay = 0;
>>> +// Section 9.6.3 of ISO/IEC 23008-12: flags specifies repetition 
>>> of the
>>> +// edit list as follows: (flags & 1) equal to 0 specifies that the 
>>> edit
>>> +// list is not repeated, while (flags & 1) equal to 1 specifies 
>>> that the
>>> +// edit list is repeated.
>>> +flags = mov->avif_loop_count != 1;
>>> +start_ct = 0;
>>> +}
>>> +
>>>version |= delay < INT32_MAX ? 0 : 1;
>>> 
>>>entry_size = (version == 1) ? 20 : 12;
>>> @@ -3452,7 +3475,7 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>>avio_wb32(pb, size - 8);
>>>ffio_wfourcc(pb, "elst");
>>>avio_w8(pb, version);
>>> -avio_wb24(pb, 0); /* flags */
>>> +avio_wb24(pb, flags); /* flags */
>>> 
>>>avio_wb32(pb, entry_count);
>>>if (delay > 0) { /* add an empty edit to delay presentation */
>>> @@ -3469,7 +3492,7 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>> MOVMuxContext *mov,
>>>avio_wb32(pb, -1);
>>>}
>>>avio_wb32(pb, 0x0001);
>>> -} else {
>>> +} else if (mov->mode != MODE_AVIF) {
>>>/* Avoid accidentally ending up with start_ct = -1 which has got a
>>> * special meaning. Normally start_ct should end up positive or zero
>>> * here, but use FFMIN in case dts is a small positive integer
>>> @

Re: [FFmpeg-devel] [PATCH v4 1/4] lavc: add standalone cached bitstream reader

2023-01-06 Thread Anton Khirnov
Quoting Anton Khirnov (2023-01-03 12:19:40)
> Will push in a few days if nobody has further comments.

pushed

-- 
Anton Khirnov
___
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] avcodec/mediacodecenc: enable B frames only with -strict experimental

2023-01-06 Thread Tomas Härdin
lör 2023-01-07 klockan 00:07 +0800 skrev Zhao Zhili:
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
> v2: Enable -> Enabling
> 
>  libavcodec/mediacodecenc.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
> index 4c1809093c..a92a8dc5a9 100644
> --- a/libavcodec/mediacodecenc.c
> +++ b/libavcodec/mediacodecenc.c
> @@ -276,8 +276,16 @@ static av_cold int
> mediacodec_init(AVCodecContext *avctx)
>  av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s-
> >level);
>  ff_AMediaFormat_setInt32(format, "level", s->level);
>  }
> -    if (avctx->max_b_frames > 0)
> +    if (avctx->max_b_frames > 0) {
> +    if (avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL) {
> +    av_log(avctx, AV_LOG_ERROR,
> +    "Enabling B frames will produce packets with no
> DTS. "
> +    "Use -strict experimental to use it anyway.\n");
> +    ret = AVERROR(EINVAL);
> +    goto bailout;
> +    }
>  ff_AMediaFormat_setInt32(format, "max-bframes", avctx-
> >max_b_frames);
> +    }
>  if (s->pts_as_dts == -1)
>  s->pts_as_dts = avctx->max_b_frames <= 0;
>  

Looks OK since all packets should get dts and pts = dts by pts_as_dts

/Tomas

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

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


[FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats

2023-01-06 Thread Tomas Härdin

From eb6d090967b8ed7ea0ee0651a1f557633fa23517 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Thu, 22 Dec 2022 13:29:58 +0100
Subject: [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats

For each entry in color_formats[] an encoder is configured and opened.
If this succeeds then the corresponding pixel format is added to probed_pix_fmts[].

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodecenc.c | 76 ++
 1 file changed, 68 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 4c1809093c..fd90d41625 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -2,6 +2,7 @@
  * Android MediaCodec encoders
  *
  * Copyright (c) 2022 Zhao Zhili 
+ * Modifications by Epic Games, Inc., 2022.
  *
  * This file is part of FFmpeg.
  *
@@ -89,12 +90,8 @@ static const struct {
 { COLOR_FormatSurface,  AV_PIX_FMT_MEDIACODEC },
 };
 
-static const enum AVPixelFormat avc_pix_fmts[] = {
-AV_PIX_FMT_MEDIACODEC,
-AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_NV12,
-AV_PIX_FMT_NONE
-};
+// filled in by mediacodec_init_static_data()
+static enum AVPixelFormat probed_pix_fmts[FF_ARRAY_ELEMS(color_formats)+1];
 
 static void mediacodec_output_format(AVCodecContext *avctx)
 {
@@ -534,6 +531,69 @@ static av_cold int mediacodec_close(AVCodecContext *avctx)
 return 0;
 }
 
+static av_cold void mediacodec_init_static_data(FFCodec *ffcodec)
+{
+const char *codec_mime = ffcodec->p.id == AV_CODEC_ID_H264 ? "video/avc" : "video/hevc";
+FFAMediaCodec *codec;
+int num_pix_fmts = 0;
+int use_ndk_codec = !av_jni_get_java_vm(NULL);
+
+if (!(codec = ff_AMediaCodec_createEncoderByType(codec_mime, use_ndk_codec))) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create encoder for type %s\n", codec_mime);
+return;
+}
+
+for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
+if (color_formats[i].pix_fmt == AV_PIX_FMT_MEDIACODEC) {
+// assumme AV_PIX_FMT_MEDIACODEC always works
+// we don't have a context at this point with which to test it
+probed_pix_fmts[num_pix_fmts++] = color_formats[i].pix_fmt;
+} else {
+FFAMediaFormat *format;
+int ret;
+
+if (!(format = ff_AMediaFormat_new(use_ndk_codec))) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create media format\n");
+ff_AMediaCodec_delete(codec);
+continue;
+}
+
+ff_AMediaFormat_setString(format, "mime", codec_mime);
+ff_AMediaFormat_setInt32(format, "width", 1280);
+ff_AMediaFormat_setInt32(format, "height", 720);
+ff_AMediaFormat_setInt32(format, "color-format", color_formats[i].color_format);
+ff_AMediaFormat_setInt32(format, "bitrate", 100);
+ff_AMediaFormat_setInt32(format, "bitrate-mode", BITRATE_MODE_VBR);
+ff_AMediaFormat_setInt32(format, "frame-rate", 30);
+ff_AMediaFormat_setInt32(format, "i-frame-interval", 1);
+
+// no need to set profile, level or number of B-frames it seems
+ret = ff_AMediaCodec_getConfigureFlagEncode(codec);
+ret = ff_AMediaCodec_configure(codec, format, NULL, NULL, ret);
+if (ret) {
+av_log(NULL, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret));
+goto bailout;
+}
+
+ret = ff_AMediaCodec_start(codec);
+if (ret) {
+av_log(NULL, AV_LOG_ERROR, "MediaCodec failed to start, %s\n", av_err2str(ret));
+goto bailout;
+}
+ff_AMediaCodec_stop(codec);
+
+probed_pix_fmts[num_pix_fmts++] = color_formats[i].pix_fmt;
+bailout:
+// format is never NULL here
+ff_AMediaFormat_delete(format);
+}
+}
+
+probed_pix_fmts[num_pix_fmts] = AV_PIX_FMT_NONE;
+ffcodec->p.pix_fmts = probed_pix_fmts;
+ff_AMediaCodec_delete(codec);
+}
+
 static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = {
 &(const AVCodecHWConfigInternal) {
 .public  = {
@@ -579,7 +639,7 @@ static const AVClass name ## _mediacodec_class = {  \
 
 #define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id) \
 MEDIACODEC_ENCODER_CLASS(short_name)\
-const FFCodec ff_ ## short_name ## _mediacodec_encoder = {  \
+FFCodec ff_ ## short_name ## _mediacodec_encoder = {  \
 .p.name   = #short_name "_mediacodec",  \
 CODEC_LONG_NAME(long_name " Android MediaCodec encoder"),   \
 .p.type   = AVMEDIA_TYPE_VIDEO, \
@@ -587,7 +647,6 @@ const FFCodec ff_ ## short_name ## _mediacodec_encoder = {  \
 .p.capabiliti

[FFmpeg-devel] [PATCH 2/2] lavc/mediacodecenc: Probe actually supported color formats using JNI

2023-01-06 Thread Tomas Härdin
This should be faster than opening the encoder several times.

/Tomas
From 44c347f5a2b6160abd8fc09a0255ee21a7ba6ee4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Wed, 4 Jan 2023 16:27:26 +0100
Subject: [PATCH 2/2] lavc/mediacodecenc: Probe actually supported color
 formats using JNI

Fall back on trying to open the encoder if JNI doesn't work.

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodec_wrapper.c | 93 +
 libavcodec/mediacodec_wrapper.h | 15 ++
 libavcodec/mediacodecenc.c  | 27 +-
 3 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 4d6e9487b8..ac77672013 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -2,6 +2,7 @@
  * Android MediaCodec Wrapper
  *
  * Copyright (c) 2015-2016 Matthieu Bouron 
+ * Modifications by Epic Games, Inc., 2023.
  *
  * This file is part of FFmpeg.
  *
@@ -176,6 +177,7 @@ struct JNIAMediaCodecFields {
 jmethodID release_id;
 
 jmethodID get_output_format_id;
+jmethodID get_codec_info_id;
 
 jmethodID dequeue_input_buffer_id;
 jmethodID queue_input_buffer_id;
@@ -228,6 +230,7 @@ static const struct FFJniField jni_amediacodec_mapping[] = {
 { "android/media/MediaCodec", "release", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, release_id), 1 },
 
 { "android/media/MediaCodec", "getOutputFormat", "()Landroid/media/MediaFormat;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_output_format_id), 1 },
+{ "android/media/MediaCodec", "getCodecInfo", "()Landroid/media/MediaCodecInfo;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_codec_info_id), 1 },
 
 { "android/media/MediaCodec", "dequeueInputBuffer", "(J)I", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, dequeue_input_buffer_id), 1 },
 { "android/media/MediaCodec", "queueInputBuffer", "(IIIJI)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, queue_input_buffer_id), 1 },
@@ -604,6 +607,96 @@ done:
 return name;
 }
 
+int ff_AMediaCodec_color_formats_intersect(FFAMediaCodec *codec, const char *mime,
+   const int *in_formats, int nin_formats,
+   int *out_formats, void *log_ctx)
+{
+FFAMediaCodecJni *jni_codec = (FFAMediaCodecJni*)codec;
+jobject info = NULL;
+jobject capabilities = NULL;
+JNIEnv *env = NULL;
+jintArray color_formats = NULL;
+int color_count, ret, *elems;
+jboolean is_copy;
+jstring jmime = NULL;
+struct JNIAMediaCodecFields jfields = { 0 };
+struct JNIAMediaCodecListFields jfields2 = { 0 };
+
+// make sure we have a JVM
+JNI_GET_ENV_OR_RETURN(env, log_ctx, -1);
+
+// grab mappings
+if ((ret = ff_jni_init_jfields(env, &jfields, jni_amediacodec_mapping, 0, log_ctx)) < 0) {
+goto done;
+}
+
+if ((ret = ff_jni_init_jfields(env, &jfields2, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {
+goto done;
+}
+
+// codec.getCodecInfo().getCapabilitiesForType(mime).colorFormats
+ret = -1;
+info = (*env)->CallObjectMethod(env, jni_codec->object, jfields.get_codec_info_id);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done;
+}
+
+// convert const char* to java.lang.String
+jmime = ff_jni_utf_chars_to_jstring(env, mime, log_ctx);
+if (!jmime) {
+goto done;
+}
+
+capabilities = (*env)->CallObjectMethod(env, info, jfields2.get_codec_capabilities_id, jmime);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done;
+}
+
+color_formats = (*env)->GetObjectField(env, capabilities, jfields2.color_formats_id);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done;
+}
+
+color_count = (*env)->GetArrayLength(env, color_formats);
+elems = (*env)->GetIntArrayElements(env, color_formats, &is_copy);
+ret = 0;
+
+// out_formats = intersect(in_formats, elems)
+for (int i = 0; i < nin_formats; i++) {
+for (int j = 0; j < color_count; j++) {
+if (elems[j] == in_formats[i]) {
+out_formats[ret++] = in_formats[i];
+break;
+}
+}
+}
+
+(*env)->ReleaseIntArrayElements(env, color_formats, elems, JNI_ABORT);
+
+done:
+// clean up
+if (jmime) {
+(*env)->DeleteLocalRef(env, jmime);
+}
+
+if (color_formats) {
+(*env)->DeleteLocalRef(env, color_formats);
+}
+
+if (capabilities) {
+(*env)->DeleteLocalRef(env, capabilities);
+}
+
+if (info) {
+(*env)->DeleteLocalRef(env, info);
+}
+
+ff_jni_reset_jfields(env, &jfields, jni_amediacodec_mapping, 0, log_ctx);
+ff_jni_reset_jfields(env, &jfields2, jni_amediacodeclist_mapping, 0, log_ctx);
+
+return ret;
+}
+
 static FFAMe

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: remove the experimental flag

2023-01-06 Thread Tomas Härdin
tor 2023-01-05 klockan 15:29 -0800 skrev p...@sandflow.com:
> From: Pierre-Anthony Lemieux 
> 
> ---
>  libavformat/imfdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> index 03de9ce151..a92686e93b 100644
> --- a/libavformat/imfdec.c
> +++ b/libavformat/imfdec.c
> @@ -1018,7 +1018,7 @@ static const AVClass imf_class = {
>  const AVInputFormat ff_imf_demuxer = {
>  .name   = "imf",
>  .long_name  = NULL_IF_CONFIG_SMALL("IMF (Interoperable
> Master Format)"),
> -    .flags  = AVFMT_EXPERIMENTAL | AVFMT_NO_BYTE_SEEK,
> +    .flags  = AVFMT_NO_BYTE_SEEK,
>  .flags_internal = FF_FMT_INIT_CLEANUP,
>  .priv_class = &imf_class,
>  .priv_data_size = sizeof(IMFContext),

This demuxer is really limited though, right?

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files.

2023-01-06 Thread Tomas Härdin
ons 2022-12-28 klockan 23:20 +0300 skrev etemesica...@gmail.com:
> From: caleb 
> 
> ---
>  libavcodec/jpeg2000dec.c |  88 +---
>  libavcodec/jpeg2000dec.h | 121
> +++
>  2 files changed, 122 insertions(+), 87 deletions(-)
>  create mode 100644 libavcodec/jpeg2000dec.h

Just responding here to mark that I've noticed these two patches but
I'm not back on j2k work until probably February

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: remove the experimental flag

2023-01-06 Thread Pierre-Anthony Lemieux
On Fri, Jan 6, 2023 at 7:45 AM Tomas Härdin  wrote:
>
> tor 2023-01-05 klockan 15:29 -0800 skrev p...@sandflow.com:
> > From: Pierre-Anthony Lemieux 
> >
> > ---
> >  libavformat/imfdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> > index 03de9ce151..a92686e93b 100644
> > --- a/libavformat/imfdec.c
> > +++ b/libavformat/imfdec.c
> > @@ -1018,7 +1018,7 @@ static const AVClass imf_class = {
> >  const AVInputFormat ff_imf_demuxer = {
> >  .name   = "imf",
> >  .long_name  = NULL_IF_CONFIG_SMALL("IMF (Interoperable
> > Master Format)"),
> > -.flags  = AVFMT_EXPERIMENTAL | AVFMT_NO_BYTE_SEEK,
> > +.flags  = AVFMT_NO_BYTE_SEEK,
> >  .flags_internal = FF_FMT_INIT_CLEANUP,
> >  .priv_class = &imf_class,
> >  .priv_data_size = sizeof(IMFContext),
>
> This demuxer is really limited though, right?

Can you clarify what you mean by "limited"?

The demuxer is intended to only process IMF packages (playlist + track files).

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

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: remove the experimental flag

2023-01-06 Thread Tomas Härdin
fre 2023-01-06 klockan 07:50 -0800 skrev Pierre-Anthony Lemieux:
> On Fri, Jan 6, 2023 at 7:45 AM Tomas Härdin  wrote:
> > 
> > tor 2023-01-05 klockan 15:29 -0800 skrev p...@sandflow.com:
> > > From: Pierre-Anthony Lemieux 
> > > 
> > > ---
> > >  libavformat/imfdec.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> > > index 03de9ce151..a92686e93b 100644
> > > --- a/libavformat/imfdec.c
> > > +++ b/libavformat/imfdec.c
> > > @@ -1018,7 +1018,7 @@ static const AVClass imf_class = {
> > >  const AVInputFormat ff_imf_demuxer = {
> > >  .name   = "imf",
> > >  .long_name  = NULL_IF_CONFIG_SMALL("IMF (Interoperable
> > > Master Format)"),
> > > -    .flags  = AVFMT_EXPERIMENTAL | AVFMT_NO_BYTE_SEEK,
> > > +    .flags  = AVFMT_NO_BYTE_SEEK,
> > >  .flags_internal = FF_FMT_INIT_CLEANUP,
> > >  .priv_class = &imf_class,
> > >  .priv_data_size = sizeof(IMFContext),
> > 
> > This demuxer is really limited though, right?
> 
> Can you clarify what you mean by "limited"?
> 
> The demuxer is intended to only process IMF packages (playlist +
> track files).

Perhaps I was speaking ahead. Last time I looked lavf was not capable
of performing the kind of NLE functionality required for full IMF
support. Perhaps imfdec does that internally? It doesn't seem so..

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: remove the experimental flag

2023-01-06 Thread Pierre-Anthony Lemieux
On Fri, Jan 6, 2023 at 8:09 AM Tomas Härdin  wrote:
>
> fre 2023-01-06 klockan 07:50 -0800 skrev Pierre-Anthony Lemieux:
> > On Fri, Jan 6, 2023 at 7:45 AM Tomas Härdin  wrote:
> > >
> > > tor 2023-01-05 klockan 15:29 -0800 skrev p...@sandflow.com:
> > > > From: Pierre-Anthony Lemieux 
> > > >
> > > > ---
> > > >  libavformat/imfdec.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> > > > index 03de9ce151..a92686e93b 100644
> > > > --- a/libavformat/imfdec.c
> > > > +++ b/libavformat/imfdec.c
> > > > @@ -1018,7 +1018,7 @@ static const AVClass imf_class = {
> > > >  const AVInputFormat ff_imf_demuxer = {
> > > >  .name   = "imf",
> > > >  .long_name  = NULL_IF_CONFIG_SMALL("IMF (Interoperable
> > > > Master Format)"),
> > > > -.flags  = AVFMT_EXPERIMENTAL | AVFMT_NO_BYTE_SEEK,
> > > > +.flags  = AVFMT_NO_BYTE_SEEK,
> > > >  .flags_internal = FF_FMT_INIT_CLEANUP,
> > > >  .priv_class = &imf_class,
> > > >  .priv_data_size = sizeof(IMFContext),
> > >
> > > This demuxer is really limited though, right?
> >
> > Can you clarify what you mean by "limited"?
> >
> > The demuxer is intended to only process IMF packages (playlist +
> > track files).
>
> Perhaps I was speaking ahead. Last time I looked lavf was not capable
> of performing the kind of NLE functionality required for full IMF
> support. Perhaps imfdec does that internally? It doesn't seem so..

The demuxer supports the full range of playlist (CPL) functionality,
including multiple non-coincident resources and resource repeats.

Only audio and image are supported for now.

See the current FATE test and the additional proposal sample at:

https://patchwork.ffmpeg.org/project/ffmpeg/patch/20221230071243.24762-1-...@sandflow.com/


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

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


[FFmpeg-devel] [PATCH v2] avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI

2023-01-06 Thread Aman Karmani
From: Aman Karmani 

Signed-off-by: Aman Karmani 
---
avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI

v2: control via sei parameter

Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-46%2Ftmm1%2Fvaapi-a53cc-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-46/tmm1/vaapi-a53cc-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/46

Range-diff vs v1:

 1:  a8eb71f061 ! 1:  9a2fee07a9 avcodec/vaapi_encode_h26x: passthrough A53 CC 
data as H264/HEVC SEI
 @@ libavcodec/vaapi_encode_h264.c: static int 
vaapi_encode_h264_write_extra_header(
   
   priv->sei_needed = 0;
   
 -@@ libavcodec/vaapi_encode_h264.c: static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 - VAAPIEncodePicture  *prev = pic->prev;
 - VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : 
NULL;
 - VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
 --int i;
 -+int i, err;
 -+size_t sei_a53cc_len;
 - 
 - if (pic->type == PICTURE_TYPE_IDR) {
 - av_assert0(pic->display_order == pic->encode_order);
  @@ libavcodec/vaapi_encode_h264.c: static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
   priv->sei_needed |= SEI_RECOVERY_POINT;
   }
   
 -+av_freep(&priv->sei_a53cc_data);
 -+err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, 
&sei_a53cc_len);
 -+if (err < 0)
 -+return err;
 -+if (priv->sei_a53cc_data != NULL) {
 -+priv->sei_a53cc.itu_t_t35_country_code = 181;
 -+priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
 -+priv->sei_a53cc.data_length = sei_a53cc_len - 1;
 ++if (priv->sei & SEI_A53_CC) {
 ++int err;
 ++size_t sei_a53cc_len;
 ++av_freep(&priv->sei_a53cc_data);
 ++err = ff_alloc_a53_sei(pic->input_image, 0, 
&priv->sei_a53cc_data, &sei_a53cc_len);
 ++if (err < 0)
 ++return err;
 ++if (priv->sei_a53cc_data != NULL) {
 ++priv->sei_a53cc.itu_t_t35_country_code = 181;
 ++priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
 ++priv->sei_a53cc.data_length = sei_a53cc_len - 1;
  +
 -+priv->sei_needed |= SEI_A53_CC;
 ++priv->sei_needed |= SEI_A53_CC;
 ++}
  +}
  +
   vpic->CurrPic = (VAPictureH264) {
 @@ libavcodec/vaapi_encode_h264.c: static av_cold int 
vaapi_encode_h264_close(AVCod
   
   return ff_vaapi_encode_close(avctx);
   }
 +@@ libavcodec/vaapi_encode_h264.c: static const AVOption 
vaapi_encode_h264_options[] = {
 + 
 + { "sei", "Set SEI to include",
 +   OFFSET(sei), AV_OPT_TYPE_FLAGS,
 +-  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT },
 ++  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT | 
SEI_A53_CC },
 +   0, INT_MAX, FLAGS, "sei" },
 + { "identifier", "Include encoder version identifier",
 +   0, AV_OPT_TYPE_CONST, { .i64 = SEI_IDENTIFIER },
 +@@ libavcodec/vaapi_encode_h264.c: static const AVOption 
vaapi_encode_h264_options[] = {
 + { "recovery_point", "Include recovery points where appropriate",
 +   0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
 +   INT_MIN, INT_MAX, FLAGS, "sei" },
 ++{ "a53_cc", "Include A/53 caption data"
 ++  0, AV_OPT_TYPE_CONST, { .i64 = SEI_A53_CC },
 ++  INT_MIN, INT_MAX, FLAGS, "sei" },
 + 
 + { "profile", "Set profile (profile_idc and constraint_set*_flag)",
 +   OFFSET(profile), AV_OPT_TYPE_INT,
  
   ## libavcodec/vaapi_encode_h265.c ##
  @@
 @@ libavcodec/vaapi_encode_h265.c: static int 
vaapi_encode_h265_write_extra_header(
   
   priv->sei_needed = 0;
   
 -@@ libavcodec/vaapi_encode_h265.c: static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
 - VAAPIEncodePicture  *prev = pic->prev;
 - VAAPIEncodeH265Picture *hprev = prev ? prev->priv_data : 
NULL;
 - VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
 --int i;
 -+int i, err;
 -+size_t sei_a53cc_len;
 - 
 - if (pic->type == PICTURE_TYPE_IDR) {
 - av_assert0(pic->display_order == pic->encode_order);
  @@ libavcodec/vaapi_encode_h265.c: static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
   }
   }
   
 -+av_freep(&priv->sei_a53cc_data);
 -+err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, 
&sei_a53cc_len);
 -+if (err < 0)
 -+return err;
 -+if (priv->sei_a53cc_data != NULL) {
 -+

Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format

2023-01-06 Thread Michael Niedermayer
On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote:
> On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer 
> wrote:
> 
> > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote:
> > > Patch attached.
> >
> > >  swresample.c |3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > eee7a0685b44aa867562138a2e2437ecb8844612
> > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch
> > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 00:00:00 2001
> > > From: Paul B Mahol 
> > > Date: Thu, 5 Jan 2023 13:40:12 +0100
> > > Subject: [PATCH] libswresample/swresample: avoid s16p internal transfer
> > format
> > >
> > > Instead use float one by default for sample rate conversions.
> > > The s16p internal transfer format produces visible and hearable
> > > quantization artifacts.
> >
> > When does this occur and why?
> >
> 
> It occurs always. Just compare output with 16bit and int32/float/double.
> Look at other people report on internet.
> Look at src.infinitewave.ca

src.infinitewave.ca uses 32bit none of what it shows should touch the codepath
you change.

if we look at src.infinitewave.ca for swr we see 2 types of artifacts
1. Aliassing which is at maybe -120db with the actual signal at 0db
   i would like to see some evidence that a human can hear this
2. Reflection and attenuation at the transition frequency
With linear filters there is a tradeof between attenuation of the
passband, reflection of frequencies beyond, latency and so on
You can have a perfect sharp cutoff with no attenuation and no refelection
that requires a infinitly long filter. And while this looks best in this
frequency plot, does it actually sound best ? If you can hear -120db
signals you surely would then also hear the ringing long before a gunshot
from such long filter.

also what actually is the optimal frequency response of this filter ?
with a 22khz cutoff, a 22.1khz sine should be silence is that
really subjectively better than a 21.9khz sine ?
Iam not sure about this. Has someone done actual hearing tests with
actual real audio? the sinc filter originates from the idea of lossless
reconstruction of frequencies below nyquist if iam not mistaken, but humans
are not trying to losslessly restore a block of frequencies. A human listener
generally wants to enjoy listening to some media. Has someone looked into
what is actually best for that real use case ?
This question matters because with it we can tune the filter parameters to
target humans.

But lets push the doubts about choosing resampling purely based on frequency
analysis away.
swresample has several parameters with which you can tune this:
we have a filter_size, if thats bigger you should get closer to the ideal
sinc. Theres phase_shift which may reduce the (i assume) unhearable aliasing. 
And cutoff which should allow to tune the (i assume) hearable 
reflection/attenuation tradeoff also theres filter_type to allow you to tune the
window function. 

If there are issues reported by people using their ears, please provide more
details, iam interrested in these cases.


> 
> 
> > This change should be limited to the case that benefits, this would force
> > this
> > even without resampling in some cases.
> >
> 
> It is forced only if sample rates between input and output differs.

If iam not mistaken it affects rematrixing without resampling too

thx

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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 v3] avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI

2023-01-06 Thread Aman Karmani
From: Aman Karmani 

Signed-off-by: Aman Karmani 
---
avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI

v3: fix build failure v2: add control via sei parameter

Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-46%2Ftmm1%2Fvaapi-a53cc-v3
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-46/tmm1/vaapi-a53cc-v3
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/46

Range-diff vs v2:

 1:  9a2fee07a9 ! 1:  149fa8e61c avcodec/vaapi_encode_h26x: passthrough A53 CC 
data as H264/HEVC SEI
 @@ libavcodec/vaapi_encode_h264.c: static const AVOption 
vaapi_encode_h264_options[
   { "recovery_point", "Include recovery points where appropriate",
 0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
 INT_MIN, INT_MAX, FLAGS, "sei" },
 -+{ "a53_cc", "Include A/53 caption data"
 ++{ "a53_cc", "Include A/53 caption data",
  +  0, AV_OPT_TYPE_CONST, { .i64 = SEI_A53_CC },
  +  INT_MIN, INT_MAX, FLAGS, "sei" },
   
 @@ libavcodec/vaapi_encode_h265.c: static const AVOption 
vaapi_encode_h265_options[
 { .i64 = SEI_MASTERING_DISPLAY | SEI_CONTENT_LIGHT_LEVEL },
 INT_MIN, INT_MAX, FLAGS, "sei" },
  +{ "a53_cc",
 -+  "Include A/53 caption data"
 ++  "Include A/53 caption data",
  +  0, AV_OPT_TYPE_CONST,
  +  { .i64 = SEI_A53_CC },
  +  INT_MIN, INT_MAX, FLAGS, "sei" },


 libavcodec/vaapi_encode_h264.c | 33 +++-
 libavcodec/vaapi_encode_h265.c | 35 +-
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index b1b503b2a6..9f9d77a0e9 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -26,6 +26,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 
+#include "atsc_a53.h"
 #include "avcodec.h"
 #include "cbs.h"
 #include "cbs_h264.h"
@@ -40,6 +41,7 @@ enum {
 SEI_TIMING = 0x01,
 SEI_IDENTIFIER = 0x02,
 SEI_RECOVERY_POINT = 0x04,
+SEI_A53_CC = 0x08,
 };
 
 // Random (version 4) ISO 11578 UUID.
@@ -98,6 +100,8 @@ typedef struct VAAPIEncodeH264Context {
 H264RawSEIRecoveryPointsei_recovery_point;
 SEIRawUserDataUnregistered sei_identifier;
 char  *sei_identifier_string;
+SEIRawUserDataRegistered   sei_a53cc;
+void  *sei_a53cc_data;
 
 int aud_needed;
 int sei_needed;
@@ -248,6 +252,13 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 if (err < 0)
 goto fail;
 }
+if (priv->sei_needed & SEI_A53_CC) {
+err = ff_cbs_sei_add_message(priv->cbc, au, 1,
+ 
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
+ &priv->sei_a53cc, NULL);
+if (err < 0)
+goto fail;
+}
 
 priv->sei_needed = 0;
 
@@ -681,6 +692,22 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->sei_needed |= SEI_RECOVERY_POINT;
 }
 
+if (priv->sei & SEI_A53_CC) {
+int err;
+size_t sei_a53cc_len;
+av_freep(&priv->sei_a53cc_data);
+err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, 
&sei_a53cc_len);
+if (err < 0)
+return err;
+if (priv->sei_a53cc_data != NULL) {
+priv->sei_a53cc.itu_t_t35_country_code = 181;
+priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
+priv->sei_a53cc.data_length = sei_a53cc_len - 1;
+
+priv->sei_needed |= SEI_A53_CC;
+}
+}
+
 vpic->CurrPic = (VAPictureH264) {
 .picture_id  = pic->recon_surface,
 .frame_idx   = hpic->frame_num,
@@ -1226,6 +1253,7 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext 
*avctx)
 ff_cbs_fragment_free(&priv->current_access_unit);
 ff_cbs_close(&priv->cbc);
 av_freep(&priv->sei_identifier_string);
+av_freep(&priv->sei_a53cc_data);
 
 return ff_vaapi_encode_close(avctx);
 }
@@ -1252,7 +1280,7 @@ static const AVOption vaapi_encode_h264_options[] = {
 
 { "sei", "Set SEI to include",
   OFFSET(sei), AV_OPT_TYPE_FLAGS,
-  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT },
+  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT | SEI_A53_CC },
   0, INT_MAX, FLAGS, "sei" },
 { "identifier", "Include encoder version identifier",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_IDENTIFIER },
@@ -1263,6 +1291,9 @@ static const AVOption vaapi_encode_h264_options[] = {
 { "recovery_point", "Include recovery points where appropriate",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
   INT_MIN, INT_MAX, FLAGS, "sei"

Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format

2023-01-06 Thread Paul B Mahol
On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer 
wrote:

> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote:
> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer <
> mich...@niedermayer.cc>
> > wrote:
> >
> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote:
> > > > Patch attached.
> > >
> > > >  swresample.c |3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > eee7a0685b44aa867562138a2e2437ecb8844612
> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch
> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 00:00:00
> 2001
> > > > From: Paul B Mahol 
> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100
> > > > Subject: [PATCH] libswresample/swresample: avoid s16p internal
> transfer
> > > format
> > > >
> > > > Instead use float one by default for sample rate conversions.
> > > > The s16p internal transfer format produces visible and hearable
> > > > quantization artifacts.
> > >
> > > When does this occur and why?
> > >
> >
> > It occurs always. Just compare output with 16bit and int32/float/double.
> > Look at other people report on internet.
> > Look at src.infinitewave.ca
>
> src.infinitewave.ca uses 32bit none of what it shows should touch the
> codepath
> you change.
>
> if we look at src.infinitewave.ca for swr we see 2 types of artifacts
> 1. Aliassing which is at maybe -120db with the actual signal at 0db
>i would like to see some evidence that a human can hear this
>

For s16p<->s16p it is much lower, around -78dB thus this patch.

Also for others and reports for swr its is lower than exact -120dB


2. Reflection and attenuation at the transition frequency
> With linear filters there is a tradeof between attenuation of the
> passband, reflection of frequencies beyond, latency and so on
> You can have a perfect sharp cutoff with no attenuation and no refelection
> that requires a infinitly long filter. And while this looks best in this
> frequency plot, does it actually sound best ? If you can hear -120db
> signals you surely would then also hear the ringing long before a gunshot
> from such long filter.
>
> also what actually is the optimal frequency response of this filter ?
> with a 22khz cutoff, a 22.1khz sine should be silence is that
> really subjectively better than a 21.9khz sine ?
> Iam not sure about this. Has someone done actual hearing tests with
> actual real audio? the sinc filter originates from the idea of lossless
> reconstruction of frequencies below nyquist if iam not mistaken, but humans
> are not trying to losslessly restore a block of frequencies. A human
> listener
> generally wants to enjoy listening to some media. Has someone looked into
> what is actually best for that real use case ?
> This question matters because with it we can tune the filter parameters to
> target humans.
>
> But lets push the doubts about choosing resampling purely based on
> frequency
> analysis away.
> swresample has several parameters with which you can tune this:
> we have a filter_size, if thats bigger you should get closer to the ideal
> sinc. Theres phase_shift which may reduce the (i assume) unhearable
> aliasing.
> And cutoff which should allow to tune the (i assume) hearable
> reflection/attenuation tradeoff also theres filter_type to allow you to
> tune the
> window function.
>
> If there are issues reported by people using their ears, please provide
> more
> details, iam interrested in these cases.
>
>
> >
> >
> > > This change should be limited to the case that benefits, this would
> force
> > > this
> > > even without resampling in some cases.
> > >
> >
> > It is forced only if sample rates between input and output differs.
>
> If iam not mistaken it affects rematrixing without resampling too
>

How so?
I really doubt that this patch do that.


>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The real ebay dictionary, page 1
> "Used only once"- "Some unspecified defect prevented a second use"
> "In good condition" - "Can be repaird by experienced expert"
> "As is" - "You wouldnt want it even if you were payed for it, if you knew
> ..."
> ___
> 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] libswresample: avoid s16p internal processing format

2023-01-06 Thread Paul B Mahol
On Fri, Jan 6, 2023 at 7:01 PM Paul B Mahol  wrote:

>
>
> On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer 
> wrote:
>
>> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote:
>> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer <
>> mich...@niedermayer.cc>
>> > wrote:
>> >
>> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote:
>> > > > Patch attached.
>> > >
>> > > >  swresample.c |3 ++-
>> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
>> > > > eee7a0685b44aa867562138a2e2437ecb8844612
>> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch
>> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 00:00:00
>> 2001
>> > > > From: Paul B Mahol 
>> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100
>> > > > Subject: [PATCH] libswresample/swresample: avoid s16p internal
>> transfer
>> > > format
>> > > >
>> > > > Instead use float one by default for sample rate conversions.
>> > > > The s16p internal transfer format produces visible and hearable
>> > > > quantization artifacts.
>> > >
>> > > When does this occur and why?
>> > >
>> >
>> > It occurs always. Just compare output with 16bit and int32/float/double.
>> > Look at other people report on internet.
>> > Look at src.infinitewave.ca
>>
>> src.infinitewave.ca uses 32bit none of what it shows should touch the
>> codepath
>> you change.
>>
>> if we look at src.infinitewave.ca for swr we see 2 types of artifacts
>> 1. Aliassing which is at maybe -120db with the actual signal at 0db
>>i would like to see some evidence that a human can hear this
>>
>
> For s16p<->s16p it is much lower, around -78dB thus this patch.
>
> Also for others and reports for swr its is lower than exact -120dB
>
>
> 2. Reflection and attenuation at the transition frequency
>> With linear filters there is a tradeof between attenuation of the
>> passband, reflection of frequencies beyond, latency and so on
>> You can have a perfect sharp cutoff with no attenuation and no refelection
>> that requires a infinitly long filter. And while this looks best in this
>> frequency plot, does it actually sound best ? If you can hear -120db
>> signals you surely would then also hear the ringing long before a gunshot
>> from such long filter.
>>
>
One can always change linear FIR to be min phase FIR kernel.


>
>> also what actually is the optimal frequency response of this filter ?
>> with a 22khz cutoff, a 22.1khz sine should be silence is that
>> really subjectively better than a 21.9khz sine ?
>> Iam not sure about this. Has someone done actual hearing tests with
>> actual real audio? the sinc filter originates from the idea of lossless
>> reconstruction of frequencies below nyquist if iam not mistaken, but
>> humans
>> are not trying to losslessly restore a block of frequencies. A human
>> listener
>> generally wants to enjoy listening to some media. Has someone looked into
>> what is actually best for that real use case ?
>> This question matters because with it we can tune the filter parameters to
>> target humans.
>>
>> But lets push the doubts about choosing resampling purely based on
>> frequency
>> analysis away.
>> swresample has several parameters with which you can tune this:
>> we have a filter_size, if thats bigger you should get closer to the ideal
>> sinc. Theres phase_shift which may reduce the (i assume) unhearable
>> aliasing.
>> And cutoff which should allow to tune the (i assume) hearable
>> reflection/attenuation tradeoff also theres filter_type to allow you to
>> tune the
>> window function.
>>
>> If there are issues reported by people using their ears, please provide
>> more
>> details, iam interrested in these cases.
>>
>>
>> >
>> >
>> > > This change should be limited to the case that benefits, this would
>> force
>> > > this
>> > > even without resampling in some cases.
>> > >
>> >
>> > It is forced only if sample rates between input and output differs.
>>
>> If iam not mistaken it affects rematrixing without resampling too
>>
>
> How so?
> I really doubt that this patch do that.
>
>
>>
>> thx
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> The real ebay dictionary, page 1
>> "Used only once"- "Some unspecified defect prevented a second use"
>> "In good condition" - "Can be repaird by experienced expert"
>> "As is" - "You wouldnt want it even if you were payed for it, if you knew
>> ..."
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats

2023-01-06 Thread Zhao Zhili
On Fri, 2023-01-06 at 16:42 +0100, Tomas Härdin wrote:


> For each entry in color_formats[] an encoder is configured and opened.
> If this succeeds then the corresponding pixel format is added to 
> probed_pix_fmts[].
> 
> This patch has been released by Epic Games' legal department.
> ---
>  libavcodec/mediacodecenc.c | 76 ++
>  1 file changed, 68 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
> index 4c1809093c..fd90d41625 100644
> --- a/libavcodec/mediacodecenc.c
> +++ b/libavcodec/mediacodecenc.c
> @@ -2,6 +2,7 @@
>   * Android MediaCodec encoders
>   *
>   * Copyright (c) 2022 Zhao Zhili 
> + * Modifications by Epic Games, Inc., 2022.
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -89,12 +90,8 @@ static const struct {
>  { COLOR_FormatSurface,  AV_PIX_FMT_MEDIACODEC },
>  };
>  
> -static const enum AVPixelFormat avc_pix_fmts[] = {
> -AV_PIX_FMT_MEDIACODEC,
> -AV_PIX_FMT_YUV420P,
> -AV_PIX_FMT_NV12,
> -AV_PIX_FMT_NONE
> -};
> +// filled in by mediacodec_init_static_data()
> +static enum AVPixelFormat probed_pix_fmts[FF_ARRAY_ELEMS(color_formats)+1];
>  
>  static void mediacodec_output_format(AVCodecContext *avctx)
>  {
> @@ -534,6 +531,69 @@ static av_cold int mediacodec_close(AVCodecContext 
> *avctx)
>  return 0;
>  }
>  
> +static av_cold void mediacodec_init_static_data(FFCodec *ffcodec)
> +{
> +const char *codec_mime = ffcodec->p.id == AV_CODEC_ID_H264 ? "video/avc" 
> : "video/hevc";
> +FFAMediaCodec *codec;
> +int num_pix_fmts = 0;
> +int use_ndk_codec = !av_jni_get_java_vm(NULL);
> +
> +if (!(codec = ff_AMediaCodec_createEncoderByType(codec_mime, 
> use_ndk_codec))) {
> +av_log(NULL, AV_LOG_ERROR, "Failed to create encoder for type %s\n", 
> codec_mime);
> +return;
> +}
> +
> +for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
> +if (color_formats[i].pix_fmt == AV_PIX_FMT_MEDIACODEC) {
> +// assumme AV_PIX_FMT_MEDIACODEC always works
> +// we don't have a context at this point with which to test it
> +probed_pix_fmts[num_pix_fmts++] = color_formats[i].pix_fmt;
> +} else {
> +FFAMediaFormat *format;
> +int ret;
> +
> +if (!(format = ff_AMediaFormat_new(use_ndk_codec))) {
> +av_log(NULL, AV_LOG_ERROR, "Failed to create media 
> format\n");
> +ff_AMediaCodec_delete(codec);
> +continue;

Here is a use-after-free (codec) issue.

> +}
> +
> +ff_AMediaFormat_setString(format, "mime", codec_mime);
> +ff_AMediaFormat_setInt32(format, "width", 1280);
> +ff_AMediaFormat_setInt32(format, "height", 720);
> +ff_AMediaFormat_setInt32(format, "color-format", 
> color_formats[i].color_format);
> +ff_AMediaFormat_setInt32(format, "bitrate", 100);
> +ff_AMediaFormat_setInt32(format, "bitrate-mode", 
> BITRATE_MODE_VBR);
> +ff_AMediaFormat_setInt32(format, "frame-rate", 30);
> +ff_AMediaFormat_setInt32(format, "i-frame-interval", 1);
> +
> +// no need to set profile, level or number of B-frames it seems
> +ret = ff_AMediaCodec_getConfigureFlagEncode(codec);
> +ret = ff_AMediaCodec_configure(codec, format, NULL, NULL, ret);
> +if (ret) {
> +av_log(NULL, AV_LOG_ERROR, "MediaCodec configure failed, 
> %s\n", av_err2str(ret));
> +goto bailout;
> +}
> +
> +ret = ff_AMediaCodec_start(codec);
> +if (ret) {
> +av_log(NULL, AV_LOG_ERROR, "MediaCodec failed to start, 
> %s\n", av_err2str(ret));
> +goto bailout;
> +}
> +ff_AMediaCodec_stop(codec);
> +
> +probed_pix_fmts[num_pix_fmts++] = color_formats[i].pix_fmt;
> +bailout:
> +// format is never NULL here
> +ff_AMediaFormat_delete(format);
> +}
> +}
> +
> +probed_pix_fmts[num_pix_fmts] = AV_PIX_FMT_NONE;
> +ffcodec->p.pix_fmts = probed_pix_fmts;
> +ff_AMediaCodec_delete(codec);
> +}
> +
>  static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = {
>  &(const AVCodecHWConfigInternal) {
>  .public  = {
> @@ -579,7 +639,7 @@ static const AVClass name ## _mediacodec_class = {  \
>  
>  #define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id) \
>  MEDIACODEC_ENCODER_CLASS(short_name)\
> -const FFCodec ff_ ## short_name ## _mediacodec_encoder = {  \
> +FFCodec ff_ ## short_name ## _mediacodec_encoder = {  \
>  .p.name   = #short_name "_mediacodec",  \
>  CODEC_LONG_NAME(long_name " Android MediaCodec encoder"),   \
>  .p.type   = AVMEDIA_TYPE_VIDEO,   

Re: [FFmpeg-devel] [PATCH v3 1/4] avcodec/bswapdsp: remove unused cextern

2023-01-06 Thread Mark Reid
On Mon, Dec 26, 2022 at 1:31 PM Mark Reid  wrote:

>
>
> On Mon, Dec 12, 2022 at 6:42 PM  wrote:
>
>> From: Mark Reid 
>>
>> ---
>>  libavcodec/x86/bswapdsp.asm | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/libavcodec/x86/bswapdsp.asm b/libavcodec/x86/bswapdsp.asm
>> index 31c6c48a21..2aa235e13c 100644
>> --- a/libavcodec/x86/bswapdsp.asm
>> +++ b/libavcodec/x86/bswapdsp.asm
>> @@ -26,8 +26,6 @@
>>  SECTION_RODATA
>>  pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
>>
>> -cextern pb_80
>> -
>>  SECTION .text
>>
>>  ; %1 = aligned/unaligned
>> --
>> 2.31.1.windows.1
>>
>>
> ping
>

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

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats

2023-01-06 Thread Tomas Härdin
lör 2023-01-07 klockan 02:03 +0800 skrev Zhao Zhili:
> On Fri, 2023-01-06 at 16:42 +0100, Tomas Härdin wrote:
> 
> > +    if (!(format = ff_AMediaFormat_new(use_ndk_codec))) {
> > +    av_log(NULL, AV_LOG_ERROR, "Failed to create media
> > format\n");
> > +    ff_AMediaCodec_delete(codec);
> > +    continue;
> 
> Here is a use-after-free (codec) issue.

Oops. I had the call to ff_AMediaCodec_createEncoderByType() inside the
loop earlier. Will fix.


> init_static_data should be determinate, no matter when it was called,
> it should
> give the same result.

You mean across devices? That obviously won't work. On the same device?
I would assume it always returns the same results, modulo what you
wrote below.

> In addition to the 'different MediaCodec backends support
> different pixel format' issue, another concern of this method is that
> it's not
> determinate, it can give different results at different
> time/condition.
> 
> MediaCodec can fail for all kinds of reasons, and it can fail
> dynamically. For
> example, the supported instance is limited
> (getMaxSupportedInstances()). Some
> low end/legacy chip only support one instance. So it can fail when
> another app
> or another SDK in the same app has already created a codec instance.

Won't the encoder fail anyway in that case? Also will the JNI probe
still fail in that case?

> It can
> fail when out of other resouce (like GPU memory) temporarily. Since
> init_static_data() only being called once, there is no way to recover
> from a
> temporary failure.

Well, the code can try to probe the color formats more than once inside
the function. But that feels very wrong.

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH v3] avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI

2023-01-06 Thread Andreas Rheinhardt
Aman Karmani:
> From: Aman Karmani 
> 
> Signed-off-by: Aman Karmani 
> ---
> avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI
> 
> v3: fix build failure v2: add control via sei parameter
> 
> Published-As: 
> https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-46%2Ftmm1%2Fvaapi-a53cc-v3
> Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
> pr-ffstaging-46/tmm1/vaapi-a53cc-v3
> Pull-Request: https://github.com/ffstaging/FFmpeg/pull/46
> 
> Range-diff vs v2:
> 
>  1:  9a2fee07a9 ! 1:  149fa8e61c avcodec/vaapi_encode_h26x: passthrough A53 
> CC data as H264/HEVC SEI
>  @@ libavcodec/vaapi_encode_h264.c: static const AVOption 
> vaapi_encode_h264_options[
>{ "recovery_point", "Include recovery points where appropriate",
>  0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
>  INT_MIN, INT_MAX, FLAGS, "sei" },
>  -+{ "a53_cc", "Include A/53 caption data"
>  ++{ "a53_cc", "Include A/53 caption data",
>   +  0, AV_OPT_TYPE_CONST, { .i64 = SEI_A53_CC },
>   +  INT_MIN, INT_MAX, FLAGS, "sei" },
>
>  @@ libavcodec/vaapi_encode_h265.c: static const AVOption 
> vaapi_encode_h265_options[
>  { .i64 = SEI_MASTERING_DISPLAY | SEI_CONTENT_LIGHT_LEVEL },
>  INT_MIN, INT_MAX, FLAGS, "sei" },
>   +{ "a53_cc",
>  -+  "Include A/53 caption data"
>  ++  "Include A/53 caption data",
>   +  0, AV_OPT_TYPE_CONST,
>   +  { .i64 = SEI_A53_CC },
>   +  INT_MIN, INT_MAX, FLAGS, "sei" },
> 
> 
>  libavcodec/vaapi_encode_h264.c | 33 +++-
>  libavcodec/vaapi_encode_h265.c | 35 +-
>  2 files changed, 66 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index b1b503b2a6..9f9d77a0e9 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -26,6 +26,7 @@
>  #include "libavutil/internal.h"
>  #include "libavutil/opt.h"
>  
> +#include "atsc_a53.h"
>  #include "avcodec.h"
>  #include "cbs.h"
>  #include "cbs_h264.h"
> @@ -40,6 +41,7 @@ enum {
>  SEI_TIMING = 0x01,
>  SEI_IDENTIFIER = 0x02,
>  SEI_RECOVERY_POINT = 0x04,
> +SEI_A53_CC = 0x08,
>  };
>  
>  // Random (version 4) ISO 11578 UUID.
> @@ -98,6 +100,8 @@ typedef struct VAAPIEncodeH264Context {
>  H264RawSEIRecoveryPointsei_recovery_point;
>  SEIRawUserDataUnregistered sei_identifier;
>  char  *sei_identifier_string;
> +SEIRawUserDataRegistered   sei_a53cc;
> +void  *sei_a53cc_data;
>  
>  int aud_needed;
>  int sei_needed;
> @@ -248,6 +252,13 @@ static int 
> vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
>  if (err < 0)
>  goto fail;
>  }
> +if (priv->sei_needed & SEI_A53_CC) {
> +err = ff_cbs_sei_add_message(priv->cbc, au, 1,
> + 
> SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
> + &priv->sei_a53cc, NULL);
> +if (err < 0)
> +goto fail;
> +}
>  
>  priv->sei_needed = 0;
>  
> @@ -681,6 +692,22 @@ static int 
> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>  priv->sei_needed |= SEI_RECOVERY_POINT;
>  }
>  
> +if (priv->sei & SEI_A53_CC) {
> +int err;
> +size_t sei_a53cc_len;
> +av_freep(&priv->sei_a53cc_data);
> +err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, 
> &sei_a53cc_len);
> +if (err < 0)
> +return err;
> +if (priv->sei_a53cc_data != NULL) {
> +priv->sei_a53cc.itu_t_t35_country_code = 181;
> +priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
> +priv->sei_a53cc.data_length = sei_a53cc_len - 1;
> +
> +priv->sei_needed |= SEI_A53_CC;
> +}
> +}
> +
>  vpic->CurrPic = (VAPictureH264) {
>  .picture_id  = pic->recon_surface,
>  .frame_idx   = hpic->frame_num,
> @@ -1226,6 +1253,7 @@ static av_cold int 
> vaapi_encode_h264_close(AVCodecContext *avctx)
>  ff_cbs_fragment_free(&priv->current_access_unit);
>  ff_cbs_close(&priv->cbc);
>  av_freep(&priv->sei_identifier_string);
> +av_freep(&priv->sei_a53cc_data);
>  
>  return ff_vaapi_encode_close(avctx);
>  }
> @@ -1252,7 +1280,7 @@ static const AVOption vaapi_encode_h264_options[] = {
>  
>  { "sei", "Set SEI to include",
>OFFSET(sei), AV_OPT_TYPE_FLAGS,
> -  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT },
> +  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT | SEI_A53_CC 
> },
>0, INT_MAX, FLAGS, "sei" },
>  { "identifier", "Include encoder version identifier",
>0, AV_OPT_T

[FFmpeg-devel] [PATCH 1/2] avcodec/eac3dec: avoid float noise in fixed mode addition to overflow

2023-01-06 Thread Michael Niedermayer
Fixes: 2.28595e+09 is outside the range of representable values of type 'int'
Fixes: 
54644/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4816961584627712

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/ac3.h | 2 ++
 libavcodec/eac3dec.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 24304caa61..2386c15ad0 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -53,6 +53,7 @@
 #define AC3_DYNAMIC_RANGE1  0
 
 typedef int INTFLOAT;
+typedef unsigned intUINTFLOAT;
 typedef int16_t SHORTFLOAT;
 
 #else /* USE_FIXED */
@@ -73,6 +74,7 @@ typedef int16_t SHORTFLOAT;
 #define AC3_DYNAMIC_RANGE1  1.0f
 
 typedef float   INTFLOAT;
+typedef float   UINTFLOAT;
 typedef float   SHORTFLOAT;
 
 #endif /* USE_FIXED */
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index d360b02691..deca51dd3d 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -138,9 +138,11 @@ static void 
ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
 // spx_noise_blend and spx_signal_blend are both FP.23
 nscale *= 1.0 / (1<<23);
 sscale *= 1.0 / (1<<23);
+if (nscale < -1.0)
+nscale = -1.0;
 #endif
 for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
-float noise  = nscale * (int32_t)av_lfg_get(&s->dith_state);
+UINTFLOAT noise = (INTFLOAT)(nscale * 
(int32_t)av_lfg_get(&s->dith_state));
 s->transform_coeffs[ch][bin]   *= sscale;
 s->transform_coeffs[ch][bin++] += noise;
 }
-- 
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/mvha: Check input size for HUFY before picture allocation

2023-01-06 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
54772/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVHA_fuzzer-5484199677394944

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

diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
index b1661c1c3b..55056c91cf 100644
--- a/libavcodec/mvha.c
+++ b/libavcodec/mvha.c
@@ -159,9 +159,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 if (size < 1 || size >= avpkt->size)
 return AVERROR_INVALIDDATA;
 
-if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-return ret;
-
 if (type == MKTAG('L','Z','Y','V')) {
 z_stream *const zstream = &s->zstream.zstream;
 ret = inflateReset(zstream);
@@ -170,6 +167,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 return AVERROR_EXTERNAL;
 }
 
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+return ret;
+
 zstream->next_in  = avpkt->data + 8;
 zstream->avail_in = avpkt->size - 8;
 
@@ -218,10 +218,16 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 }
 }
 
+if (get_bits_left(gb) < avctx->height * avctx->width)
+return AVERROR_INVALIDDATA;
+
 ret = build_vlc(avctx, &s->vlc);
 if (ret < 0)
 return ret;
 
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+return ret;
+
 for (int p = 0; p < 3; p++) {
 int width = avctx->width >> (p > 0);
 ptrdiff_t stride = frame->linesize[p];
-- 
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 v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2023-01-06 Thread Basel Sayeh
V6:
 - Removed the const for filename in "hls_delete_file" to
   fix compilation warnings

 - Removed the unnecessary calls to ff_format_io_close
   this patch introduced in hls_delete_file and in
   dashenc_delete_file

V1-V5:
 hls_delete_file and dashenc_delete_file functions open a
 new HTTP connection regardless of the http_persistent value,
 So change their behaviour to keep http connections open
 if http_persistent is set


Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..39df9becc7 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -252,6 +252,7 @@ typedef struct HLSContext {
 int http_persistent;
 AVIOContext *m3u8_out;
 AVIOContext *sub_m3u8_out;
+AVIOContext *http_delete;
 int64_t timeout;
 int ignore_io_errors;
 char *headers;
@@ -565,19 +566,22 @@ static void reflush_dynbuf(VariantStream *vs, int 
*range_length)
 #endif
 
 static int hls_delete_file(HLSContext *hls, AVFormatContext *avf,
-   const char *path, const char *proto)
+   char *path, const char *proto)
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, &opt, hls);
 av_dict_set(&opt, "method", "DELETE", 0);
-ret = avf->io_open(avf, &out, path, AVIO_FLAG_WRITE, &opt);
+
+ret = hlsenc_io_open(avf, &hls->http_delete, path, &opt);
 av_dict_free(&opt);
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, &out);
+
+//Nothing to write
+hlsenc_io_close(avf, &hls->http_delete, path);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +666,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 
 proto = avio_find_protocol_name(s->url);
-if (ret = hls_delete_file(hls, vs->avf, path.str, proto))
+if (ret = hls_delete_file(hls, s, path.str, proto))
 goto fail;
 
 if ((segment->sub_filename[0] != '\0')) {
@@ -679,7 +683,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 goto fail;
 }
 
-if (ret = hls_delete_file(hls, vs->vtt_avf, path.str, proto))
+if (ret = hls_delete_file(hls, s, path.str, proto))
 goto fail;
 }
 av_bprint_clear(&path);
@@ -2707,6 +2711,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, &hls->m3u8_out);
 ff_format_io_close(s, &hls->sub_m3u8_out);
+ff_format_io_close(s, &hls->http_delete);
 av_freep(&hls->key_basename);
 av_freep(&hls->var_streams);
 av_freep(&hls->cc_streams);
-- 
2.30.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 v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2023-01-06 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..8e725a0d3f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -179,6 +179,7 @@ typedef struct DASHContext {
 int master_playlist_created;
 AVIOContext *mpd_out;
 AVIOContext *m3u8_out;
+AVIOContext *http_delete;
 int streaming;
 int64_t timeout;
 int index_correction;
@@ -642,6 +643,7 @@ static void dash_free(AVFormatContext *s)
 
 ff_format_io_close(s, &c->mpd_out);
 ff_format_io_close(s, &c->m3u8_out);
+ff_format_io_close(s, &c->http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,18 @@ static void dashenc_delete_file(AVFormatContext *s, 
char *filename) {
 int http_base_proto = ff_is_http_proto(filename);
 
 if (http_base_proto) {
-AVIOContext *out = NULL;
 AVDictionary *http_opts = NULL;
 
 set_http_options(&http_opts, c);
 av_dict_set(&http_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, &out, filename, &http_opts) < 0) {
+if (dashenc_io_open(s, &c->http_delete, filename, &http_opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
 }
-
 av_dict_free(&http_opts);
-ff_format_io_close(s, &out);
+
+//Nothing to write
+dashenc_io_close(s, &c->http_delete, filename);
 } else {
 int res = ffurl_delete(filename);
 if (res < 0) {
-- 
2.30.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] Update for my hls and dash patches?

2023-01-06 Thread Basel Sayeh


On 1/5/23 09:26, Steven Liu wrote:

Basel Sayeh  于2023年1月5日周四 09:19写道:



Hello,


Any update or comment on these patch sets?


Enable HTTP persistent connections for hls_delete_file &
dashenc_delete_file:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033

https://patchwork.ffmpeg.org/project/ffmpeg/patch/db9p191mb14827461396938910246ace9fe...@db9p191mb1482.eurp191.prod.outlook.com/

You should check the first patch of this series.

Do you mean i should take a look at the warnings?

Yes, just fix the warning should be ok.


Just sent a V6 that should have no new compilation warnings,

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8163




Use http_read_header in http_shutdown to react to response errors:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058

Is it will use block mode of socket?

Yes, it will wait for a server reply (if not sent), and react to some http 
errors, like 404
I am aware that it may slow the encoding/sending down, but is there any better 
way that it can be done?

Yes, you aware that, so that if a problem. I have no better way to do
that. :( Maybe other developer can give us some better way?


I hope developers can give their input on this


___
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] arm32/neon: Avoid using bge/beq for function calls

2023-01-06 Thread Rui Ueyama
It looks like compiler-generated code always uses `b`, `bl` or `blx`
instructions for function calls. These instructions have a 24-bit
immediate and therefore can jump anywhere between PC +- 16 MiB.

This hand-written assembly code instead uses `bge` and `beq` for
interprocedural jumps. Since these instructions have only a 19-bit
immediate (we have less bits for condition code), they can jump only
within PC +- 512 KiB. This sometimes causes a "relocation R_ARM_THM_JUMP19
out of range" error when linked with the mold linker. This error can
easily be avoided by using `b` instead of `bge` or `beq`.

Signed-off-by: Rui Ueyama 
---
 libswresample/arm/audio_convert_neon.S | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libswresample/arm/audio_convert_neon.S
b/libswresample/arm/audio_convert_neon.S
index 085d50aafa..3fe114772c 100644
--- a/libswresample/arm/audio_convert_neon.S
+++ b/libswresample/arm/audio_convert_neon.S
@@ -133,12 +133,13 @@ endfunc

 function swri_oldapi_conv_fltp_to_s16_nch_neon, export=1
 cmp r3,  #2
-itt lt
-ldrlt   r1,  [r1]
-blt .L_swri_oldapi_conv_flt_to_s16_neon
-beq .L_swri_oldapi_conv_fltp_to_s16_2ch_neon
+bgt 2f
+beq 1f
+ldr r1,  [r1]
+b   .L_swri_oldapi_conv_flt_to_s16_neon
+1:  b   .L_swri_oldapi_conv_fltp_to_s16_2ch_neon

-push{r4-r8, lr}
+2:  push{r4-r8, lr}
 cmp r3,  #4
 lsl r12, r3,  #1
 blt 4f
--
2.34.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: apply discontinuity adjustment per-stream

2023-01-06 Thread Gyan Doshi




On 2023-01-03 03:52 pm, Gyan Doshi wrote:

At present, the offset for discontinuity adjustment is applied per-file but
the check for discontinuity is intra-stream so the same discontinuity when
seen in multiple streams with copyts, leads to compounded adjustment of the
discontinuity offset. This introduces gaps in streams, leading to loss of sync
or even de facto loss of stream.

The ts_offset_discont parameter is transferred to InputStream and adjusted
based on intra-stream gaps.


Comments?


---
Here's a simulated example to demonstrate the issue:
1) generate input
ffmpeg -f lavfi -i nullsrc=s=32x32:r=1,format=gray -f lavfi -i 
anullsrc=cl=mono:r=8000 -c:v libx264 -preset superfast -bf 0 -crf 50 -c:a aac 
-b:a 64k -muxpreload 0 -muxdelay 0 -output_ts_offset 95000 -t 10 
src-10s.ts

2) demo
ffmpeg -copyts -i "src-10.ts" -vf "showinfo=checksum=0" -af "ashowinfo" -f 
null - -report

==Before patch==

timestamp discontinuity for stream #0:1 (id=257, type=audio): -95443717689, new 
offset= 95443717689
timestamp discontinuity for stream #0:0 (id=256, type=video): -95443717689, new 
offset= 190887435378

[Parsed_ashowinfo_0 @ 02700af98800] n:0 pts:759998976 pts_time:94999.9
[Parsed_ashowinfo_0 @ 02700af98800] n:1 pts:76000 pts_time:95000
  ...
[Parsed_ashowinfo_0 @ 02700af98800] n:745202 pts:1523085824 pts_time:190386
[Parsed_ashowinfo_0 @ 02700af98800] n:745203 pts:1523086848 pts_time:190386
[Parsed_ashowinfo_0 @ 02700af98800] n:745204 pts:2286637614 pts_time:285830
[Parsed_ashowinfo_0 @ 02700af98800] n:745205 pts:2286638638 pts_time:285830


[Parsed_showinfo_0 @ 02700ec34700] n:   0 pts:855000 pts_time:95000
[Parsed_showinfo_0 @ 02700ec34700] n:   1 pts:855009 pts_time:95001
  ...
[Parsed_showinfo_0 @ 02700ec34700] n:95380 pts:1713420 pts_time:190380
[Parsed_showinfo_0 @ 02700ec34700] n:95381 pts:1713429 pts_time:190381
[Parsed_showinfo_0 @ 02700ec34700] n:95382 pts:25724314592 pts_time:285826
[Parsed_showinfo_0 @ 02700ec34700] n:95383 pts:25724404592 pts_time:285827

==After patch==

timestamp discontinuity for stream #0:1 (id=257, type=audio): -95443717689, new 
stream offset= 95443717689
timestamp discontinuity for stream #0:0 (id=256, type=video): -95443717689, new 
stream offset= 95443717689

[Parsed_ashowinfo_0 @ 023c773c8880] n:0 pts:759998976 pts_time:94999.9
[Parsed_ashowinfo_0 @ 023c773c8880] n:1 pts:76000 pts_time:95000
  ...
[Parsed_ashowinfo_0 @ 023c773c8880] n:745202 pts:1523085824 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745203 pts:1523086848 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745204 pts:1523087872 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745205 pts:1523088896 pts_time:190386


[Parsed_showinfo_0 @ 023c795d07c0] n:   0 pts:855000 pts_time:95000
[Parsed_showinfo_0 @ 023c795d07c0] n:   1 pts:855009 pts_time:95001
  ...
[Parsed_showinfo_0 @ 023c795d07c0] n:95380 pts:1713420 pts_time:190380
[Parsed_showinfo_0 @ 023c795d07c0] n:95381 pts:1713429 pts_time:190381
[Parsed_showinfo_0 @ 023c795d07c0] n:95382 pts:1713438 pts_time:190382
[Parsed_showinfo_0 @ 023c795d07c0] n:95383 pts:1713447 pts_time:190383



  fftools/ffmpeg.c | 12 ++--
  fftools/ffmpeg.h |  8 
  2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 881d6f0af2..b967055059 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3418,13 +3418,13 @@ static void ts_discontinuity_detect(InputFile *ifile, 
InputStream *ist,
  if (fmt_is_discont) {
  if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE ||
  pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) {
-ifile->ts_offset_discont -= delta;
+ist->ts_offset_discont -= delta;
  av_log(NULL, AV_LOG_DEBUG,
 "timestamp discontinuity for stream #%d:%d "
-   "(id=%d, type=%s): %"PRId64", new offset= %"PRId64"\n",
+   "(id=%d, type=%s): %"PRId64", new stream offset= 
%"PRId64"\n",
 ist->file_index, ist->st->index, ist->st->id,
 av_get_media_type_string(ist->par->codec_type),
-   delta, ifile->ts_offset_discont);
+   delta, ist->ts_offset_discont);
  pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, 
ist->st->time_base);
  if (pkt->pts != AV_NOPTS_VALUE)
  pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, 
ist->st->time_base);
@@ -3447,10 +3447,10 @@ static void ts_discontinuity_detect(InputFile *ifile, 
InputStream *ist,
 fmt_is_discont && ifile->last_ts != AV_NOPTS_VALUE) {
  int64_t delta = pkt_dts - ifile->last_ts;
  if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE) {
-ifile->ts_of

Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats

2023-01-06 Thread Zhao Zhili

> From: ffmpeg-devel  On Behalf Of Tomas Härdin
> Sent: 2023年1月7日 2:22
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported 
> pixel formats
> 
> lör 2023-01-07 klockan 02:03 +0800 skrev Zhao Zhili:
> > On Fri, 2023-01-06 at 16:42 +0100, Tomas Härdin wrote:
> >
> > > +if (!(format = ff_AMediaFormat_new(use_ndk_codec))) {
> > > +av_log(NULL, AV_LOG_ERROR, "Failed to create media
> > > format\n");
> > > +ff_AMediaCodec_delete(codec);
> > > +continue;
> >
> > Here is a use-after-free (codec) issue.
> 
> Oops. I had the call to ff_AMediaCodec_createEncoderByType() inside the
> loop earlier. Will fix.
> 
> 
> > init_static_data should be determinate, no matter when it was called,
> > it should
> > give the same result.
> 
> You mean across devices? That obviously won't work. On the same device?
> I would assume it always returns the same results, modulo what you
> wrote below.

I mean on the same device.

> 
> > In addition to the 'different MediaCodec backends support
> > different pixel format' issue, another concern of this method is that
> > it's not
> > determinate, it can give different results at different
> > time/condition.
> >
> > MediaCodec can fail for all kinds of reasons, and it can fail
> > dynamically. For
> > example, the supported instance is limited
> > (getMaxSupportedInstances()). Some
> > low end/legacy chip only support one instance. So it can fail when
> > another app
> > or another SDK in the same app has already created a codec instance.
> 
> Won't the encoder fail anyway in that case? Also will the JNI probe
> still fail in that case?

Create encoder can fail, and recover after a while. If JNI probe depends on
a codec instance, it has the same issue. Use the codeclist API should be fine,
but then we don't know which omx codec is the default one.

The JNI probe can tell which pixel format is supported after encoder configure
failed at runtime. That's a safe and valid usecase. And it can be implemented
out side of FFmpeg, so it can be called earlier and multiple times, without the
limitation of init_static_data() being called only once.

> 
> > It can
> > fail when out of other resouce (like GPU memory) temporarily. Since
> > init_static_data() only being called once, there is no way to recover
> > from a
> > temporary failure.
> 
> Well, the code can try to probe the color formats more than once inside
> the function. But that feels very wrong.

That's the problem, init_static_data() can't do retry by design. Probe multiple
times inside init_static_data() doesn't work, unless there is a sleep after each
loop, and we can't put sleep inside init_static_data().

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

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

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